bitpull 0.1.23 → 0.1.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/README.md +2 -1
  2. package/bitpull.cjs +11701 -10690
  3. package/package.json +3 -2
  4. package/ui/ide-terminal.js +57 -0
  5. package/ui/ide.css +271 -0
  6. package/ui/ide.html +178 -0
  7. package/ui/ide.js +1336 -0
  8. package/ui/monaco/vs/abap-D-t0cyap.js +1 -0
  9. package/ui/monaco/vs/apex-CcIm7xu6.js +1 -0
  10. package/ui/monaco/vs/assets/css.worker-BpD9FCKP.js +97 -0
  11. package/ui/monaco/vs/assets/editor.worker-_vAIFJDs.js +30 -0
  12. package/ui/monaco/vs/assets/editorWebWorkerMain-DEgFqX2K.js +30 -0
  13. package/ui/monaco/vs/assets/html.worker-CLuInTTy.js +474 -0
  14. package/ui/monaco/vs/assets/json.worker-Csf_TLih.js +62 -0
  15. package/ui/monaco/vs/assets/ts.worker-g3pjEjl4.js +67722 -0
  16. package/ui/monaco/vs/azcli-BA0tQDCg.js +1 -0
  17. package/ui/monaco/vs/basic-languages/monaco.contribution.js +1 -0
  18. package/ui/monaco/vs/bat-C397hTD6.js +1 -0
  19. package/ui/monaco/vs/bicep-DF5aW17k.js +2 -0
  20. package/ui/monaco/vs/cameligo-plsz8qhj.js +1 -0
  21. package/ui/monaco/vs/clojure-Y2auQMzK.js +1 -0
  22. package/ui/monaco/vs/coffee-Bu45yuWE.js +1 -0
  23. package/ui/monaco/vs/cpp-CkKPQIni.js +1 -0
  24. package/ui/monaco/vs/csharp-CX28MZyh.js +1 -0
  25. package/ui/monaco/vs/csp-D8uWnyxW.js +1 -0
  26. package/ui/monaco/vs/css-CaeNmE3S.js +3 -0
  27. package/ui/monaco/vs/css.worker-BInK4lsP.js +1 -0
  28. package/ui/monaco/vs/cssMode-eIUIN_ru.js +1 -0
  29. package/ui/monaco/vs/cypher-DVThT8BS.js +1 -0
  30. package/ui/monaco/vs/dart-CmGfCvrO.js +1 -0
  31. package/ui/monaco/vs/dockerfile-CZqqYdch.js +1 -0
  32. package/ui/monaco/vs/ecl-30fUercY.js +1 -0
  33. package/ui/monaco/vs/editor/editor.main.css +1 -0
  34. package/ui/monaco/vs/editor/editor.main.js +1 -0
  35. package/ui/monaco/vs/editor/editor.worker.js +1 -0
  36. package/ui/monaco/vs/editor-BdtEMBbM.js +892 -0
  37. package/ui/monaco/vs/editor.js +1 -0
  38. package/ui/monaco/vs/editorWorkerHost-B_VpI68A.js +35 -0
  39. package/ui/monaco/vs/elixir-xjPaIfzF.js +1 -0
  40. package/ui/monaco/vs/flow9-DqtmStfK.js +1 -0
  41. package/ui/monaco/vs/freemarker2-B-FhRNBn.js +3 -0
  42. package/ui/monaco/vs/fsharp-BOMdg4U1.js +1 -0
  43. package/ui/monaco/vs/go-D_hbi-Jt.js +1 -0
  44. package/ui/monaco/vs/graphql-CKUU4kLG.js +1 -0
  45. package/ui/monaco/vs/handlebars-BJBfNnbX.js +1 -0
  46. package/ui/monaco/vs/hcl-DTaboeZW.js +1 -0
  47. package/ui/monaco/vs/html-BTio3wpy.js +1 -0
  48. package/ui/monaco/vs/html.worker-C1TNvQ72.js +1 -0
  49. package/ui/monaco/vs/htmlMode-aw5QYZo7.js +1 -0
  50. package/ui/monaco/vs/index-049xrXrp.js +1 -0
  51. package/ui/monaco/vs/index-DZH_zysX.js +5 -0
  52. package/ui/monaco/vs/index.js +1 -0
  53. package/ui/monaco/vs/ini-CsNwO04R.js +1 -0
  54. package/ui/monaco/vs/initialize-CAIC7-3s.js +1 -0
  55. package/ui/monaco/vs/java-CI4ZMsH9.js +1 -0
  56. package/ui/monaco/vs/javascript-B_IYblwB.js +1 -0
  57. package/ui/monaco/vs/json.worker-Bp7U0-9w.js +1 -0
  58. package/ui/monaco/vs/jsonMode-w7Q_ZLTt.js +1 -0
  59. package/ui/monaco/vs/julia-BwzEvaQw.js +1 -0
  60. package/ui/monaco/vs/kotlin-IUYPiTV8.js +1 -0
  61. package/ui/monaco/vs/less-C0eDYdqa.js +2 -0
  62. package/ui/monaco/vs/lexon-iON-Kj97.js +1 -0
  63. package/ui/monaco/vs/liquid-CXh4HpyA.js +1 -0
  64. package/ui/monaco/vs/loader.js +1368 -0
  65. package/ui/monaco/vs/lspLanguageFeatures-Cog3rVVE.js +2 -0
  66. package/ui/monaco/vs/lua-DtygF91M.js +1 -0
  67. package/ui/monaco/vs/m3-CsR4AuFi.js +1 -0
  68. package/ui/monaco/vs/main-BEx-Fmlo.js +15 -0
  69. package/ui/monaco/vs/main-DsK8pnKg.js +3 -0
  70. package/ui/monaco/vs/markdown-C_rD0bIw.js +1 -0
  71. package/ui/monaco/vs/mdx-BcFcCtz9.js +1 -0
  72. package/ui/monaco/vs/mips-CiYP61RB.js +1 -0
  73. package/ui/monaco/vs/monaco.contribution-BuX2NvO2.js +1 -0
  74. package/ui/monaco/vs/monaco.contribution-C7tY_xnl.js +1 -0
  75. package/ui/monaco/vs/monaco.contribution-CY2lwFI8.js +1 -0
  76. package/ui/monaco/vs/monaco.contribution-D1-wBxcq.js +1 -0
  77. package/ui/monaco/vs/msdax-C38-sJlp.js +1 -0
  78. package/ui/monaco/vs/mysql-CdtbpvbG.js +1 -0
  79. package/ui/monaco/vs/nls/lang/de.js +9 -0
  80. package/ui/monaco/vs/nls/lang/es.js +9 -0
  81. package/ui/monaco/vs/nls/lang/fr.js +9 -0
  82. package/ui/monaco/vs/nls/lang/it.js +9 -0
  83. package/ui/monaco/vs/nls/lang/pt-br.js +9 -0
  84. package/ui/monaco/vs/nls/lang/ru.js +9 -0
  85. package/ui/monaco/vs/nls/lang/zh-cn.js +9 -0
  86. package/ui/monaco/vs/nls.messages-loader.js +1 -0
  87. package/ui/monaco/vs/objective-c-CntZFaHX.js +1 -0
  88. package/ui/monaco/vs/pascal-r6kuqfl_.js +1 -0
  89. package/ui/monaco/vs/pascaligo-BiXoTmXh.js +1 -0
  90. package/ui/monaco/vs/perl-DABw_TcH.js +1 -0
  91. package/ui/monaco/vs/pgsql-me_jFXeX.js +1 -0
  92. package/ui/monaco/vs/php-D_kh-9LK.js +1 -0
  93. package/ui/monaco/vs/pla-VfZjczW0.js +1 -0
  94. package/ui/monaco/vs/postiats-BBSzz8Pk.js +1 -0
  95. package/ui/monaco/vs/powerquery-Dt-g_2cc.js +1 -0
  96. package/ui/monaco/vs/powershell-B-7ap1zc.js +1 -0
  97. package/ui/monaco/vs/protobuf-BmtuEB1A.js +2 -0
  98. package/ui/monaco/vs/pug-BRpRNeEb.js +1 -0
  99. package/ui/monaco/vs/python-CasA8BlK.js +1 -0
  100. package/ui/monaco/vs/qsharp-BzsFaUU9.js +1 -0
  101. package/ui/monaco/vs/r-f8dDdrp4.js +1 -0
  102. package/ui/monaco/vs/razor-IGOwKAHu.js +1 -0
  103. package/ui/monaco/vs/redis-fvZQY4PI.js +1 -0
  104. package/ui/monaco/vs/redshift-45Et0LQi.js +1 -0
  105. package/ui/monaco/vs/restructuredtext-C7UUFKFD.js +1 -0
  106. package/ui/monaco/vs/ruby-CZO8zYTz.js +1 -0
  107. package/ui/monaco/vs/rust-Bfetafyc.js +1 -0
  108. package/ui/monaco/vs/sb-3GYllVck.js +1 -0
  109. package/ui/monaco/vs/scala-foMgrKo1.js +1 -0
  110. package/ui/monaco/vs/scheme-CHdMtr7p.js +1 -0
  111. package/ui/monaco/vs/scss-C1cmLt9V.js +3 -0
  112. package/ui/monaco/vs/shell-ClXCKCEW.js +1 -0
  113. package/ui/monaco/vs/solidity-MZ6ExpPy.js +1 -0
  114. package/ui/monaco/vs/sophia-DWkuSsPQ.js +1 -0
  115. package/ui/monaco/vs/sparql-AUGFYSyk.js +1 -0
  116. package/ui/monaco/vs/sql-32GpJSV2.js +1 -0
  117. package/ui/monaco/vs/st-CuDFIVZ_.js +1 -0
  118. package/ui/monaco/vs/swift-t-PfMj7W.js +1 -0
  119. package/ui/monaco/vs/systemverilog-Ch4vA8Yt.js +1 -0
  120. package/ui/monaco/vs/tcl-D74tq1nH.js +1 -0
  121. package/ui/monaco/vs/toggleHighContrast-DuqAmExZ.js +65 -0
  122. package/ui/monaco/vs/ts.worker-BLYAhMkX.js +1 -0
  123. package/ui/monaco/vs/tsMode-DB1GiNun.js +11 -0
  124. package/ui/monaco/vs/twig-C6taOxMV.js +1 -0
  125. package/ui/monaco/vs/typescript-BTLNeq8B.js +1 -0
  126. package/ui/monaco/vs/typespec-8OfoLt6R.js +1 -0
  127. package/ui/monaco/vs/vb-Dyb2648j.js +1 -0
  128. package/ui/monaco/vs/wgsl-BhLXMOR0.js +298 -0
  129. package/ui/monaco/vs/workers-BeMslOxK.js +1 -0
  130. package/ui/monaco/vs/xml-DHCggo_L.js +1 -0
  131. package/ui/monaco/vs/yaml-C-RIivnc.js +1 -0
  132. package/ui/terminal.js +328 -0
  133. package/ui/vendor/addon-fit.mjs +18 -0
  134. package/ui/vendor/xterm.css +285 -0
  135. package/ui/vendor/xterm.mjs +53 -0
@@ -0,0 +1,65 @@
1
+ define("vs/toggleHighContrast-DuqAmExZ",["exports","./editorWorkerHost-B_VpI68A","./editor-BdtEMBbM"],(function(vC,a,o){"use strict";var vn,mi,bn,Cn,Sn,Vt,_i,Ws,mt,_t,vi,eo,yn,wn,bi,Ci,Si,In,xn,En,Ln,Dn,Bt,Rn,Tn,Nn,Mn,Pn,On,An,wi,Ii,Fn,zn,io,no,Vn,Bn,it,Un,$n,Di,jn,qn,nt,Ri,Gn,Zn,oo,Xn,Ct,Ti,ro,Yn,ao,lo,Ni,Mi,Qn,Jn,Wn,Hn,co,Pi,ho,es,uo,go,Oi,ts,po,is,ns,ss,st,St,ot;class bC extends o.Action2{constructor(){super({id:"diffEditor.toggleCollapseUnchangedRegions",title:a.localize2(101,"Toggle Collapse Unchanged Regions"),icon:a.Codicon.map,toggled:o.ContextKeyExpr.has("config.diffEditor.hideUnchangedRegions.enabled"),precondition:o.ContextKeyExpr.has("isInDiffEditor"),menu:{when:o.ContextKeyExpr.has("isInDiffEditor"),id:o.MenuId.EditorTitle,order:22,group:"navigation"}})}run(e,...t){const i=e.get(o.IConfigurationService),n=!i.getValue("diffEditor.hideUnchangedRegions.enabled");i.updateValue("diffEditor.hideUnchangedRegions.enabled",n)}}class wf extends o.Action2{constructor(){super({id:"diffEditor.toggleShowMovedCodeBlocks",title:a.localize2(102,"Toggle Show Moved Code Blocks"),precondition:o.ContextKeyExpr.has("isInDiffEditor")})}run(e,...t){const i=e.get(o.IConfigurationService),n=!i.getValue("diffEditor.experimental.showMoves");i.updateValue("diffEditor.experimental.showMoves",n)}}class CC extends o.Action2{constructor(){super({id:"diffEditor.toggleUseInlineViewWhenSpaceIsLimited",title:a.localize2(103,"Toggle Use Inline View When Space Is Limited"),precondition:o.ContextKeyExpr.has("isInDiffEditor")})}run(e,...t){const i=e.get(o.IConfigurationService),n=!i.getValue("diffEditor.useInlineViewWhenSpaceIsLimited");i.updateValue("diffEditor.useInlineViewWhenSpaceIsLimited",n)}}const fo=a.localize2(104,"Diff Editor");class SC extends o.EditorAction2{constructor(){super({id:"diffEditor.switchSide",title:a.localize2(105,"Switch Side"),icon:a.Codicon.arrowSwap,precondition:o.ContextKeyExpr.has("isInDiffEditor"),f1:!0,category:fo})}runEditorCommand(e,t,i){const n=zi(e);if(n instanceof o.DiffEditorWidget){if(i&&i.dryRun)return{destinationSelection:n.mapToOtherSide().destinationSelection};n.switchSide()}}}class yC extends o.EditorAction2{constructor(){super({id:"diffEditor.exitCompareMove",title:a.localize2(106,"Exit Compare Move"),icon:a.Codicon.close,precondition:o.EditorContextKeys.comparingMovedCode,f1:!1,category:fo,keybinding:{weight:1e4,primary:9}})}runEditorCommand(e,t,...i){const n=zi(e);n instanceof o.DiffEditorWidget&&n.exitCompareMove()}}class wC extends o.EditorAction2{constructor(){super({id:"diffEditor.collapseAllUnchangedRegions",title:a.localize2(107,"Collapse All Unchanged Regions"),icon:a.Codicon.fold,precondition:o.ContextKeyExpr.has("isInDiffEditor"),f1:!0,category:fo})}runEditorCommand(e,t,...i){const n=zi(e);n instanceof o.DiffEditorWidget&&n.collapseAllUnchangedRegions()}}class IC extends o.EditorAction2{constructor(){super({id:"diffEditor.showAllUnchangedRegions",title:a.localize2(108,"Show All Unchanged Regions"),icon:a.Codicon.unfold,precondition:o.ContextKeyExpr.has("isInDiffEditor"),f1:!0,category:fo})}runEditorCommand(e,t,...i){const n=zi(e);n instanceof o.DiffEditorWidget&&n.showAllUnchangedRegions()}}class fd extends o.Action2{constructor(){super({id:"diffEditor.revert",title:a.localize2(109,"Revert"),f1:!0,category:fo,precondition:o.ContextKeyExpr.has("isInDiffEditor")})}run(e,t){return t?this.runViaToolbarContext(e,t):this.runViaCursorOrSelection(e)}runViaCursorOrSelection(e){const t=zi(e);t instanceof o.DiffEditorWidget&&t.revertFocusedRangeMappings()}runViaToolbarContext(e,t){const i=xC(e,t.originalUri,t.modifiedUri);i instanceof o.DiffEditorWidget&&i.revertRangeMappings(t.mapping.innerChanges??[])}}const If=a.localize2(110,"Accessible Diff Viewer"),Sc=class Sc extends o.Action2{constructor(){super({id:Sc.id,title:a.localize2(111,"Go to Next Difference"),category:If,precondition:o.ContextKeyExpr.has("isInDiffEditor"),keybinding:{primary:65,weight:100},f1:!0})}run(e){zi(e)?.accessibleDiffViewerNext()}};Sc.id="editor.action.accessibleDiffViewer.next";let mo=Sc;const yc=class yc extends o.Action2{constructor(){super({id:yc.id,title:a.localize2(112,"Go to Previous Difference"),category:If,precondition:o.ContextKeyExpr.has("isInDiffEditor"),keybinding:{primary:1089,weight:100},f1:!0})}run(e){zi(e)?.accessibleDiffViewerPrev()}};yc.id="editor.action.accessibleDiffViewer.prev";let Xr=yc;function xC(c,e,t){return c.get(o.ICodeEditorService).listDiffEditors().find(s=>{const r=s.getModifiedEditor(),l=s.getOriginalEditor();return r&&r.getModel()?.uri.toString()===t.toString()&&l&&l.getModel()?.uri.toString()===e.toString()})||null}function zi(c){const t=c.get(o.ICodeEditorService).listDiffEditors(),i=o.getActiveElement();if(i){for(const n of t)if(n.getContainerDomNode().contains(i))return n}return null}o.registerAction2(bC),o.registerAction2(wf),o.registerAction2(CC),o.MenuRegistry.appendMenuItem(o.MenuId.EditorTitle,{command:{id:new wf().desc.id,title:a.localize(135,"Show Moved Code Blocks"),icon:a.Codicon.move,toggled:o.ContextKeyEqualsExpr.create("config.diffEditor.experimental.showMoves",!0),precondition:o.ContextKeyExpr.has("isInDiffEditor")},order:10,group:"1_diff",when:o.ContextKeyExpr.has("isInDiffEditor")}),o.registerAction2(fd);for(const c of[{icon:a.Codicon.arrowRight,key:o.EditorContextKeys.diffEditorInlineMode.toNegated()},{icon:a.Codicon.discard,key:o.EditorContextKeys.diffEditorInlineMode}])o.MenuRegistry.appendMenuItem(o.MenuId.DiffEditorHunkToolbar,{command:{id:new fd().desc.id,title:a.localize(136,"Revert Block"),icon:c.icon},when:o.ContextKeyExpr.and(o.EditorContextKeys.diffEditorModifiedWritable,c.key),order:5,group:"primary"}),o.MenuRegistry.appendMenuItem(o.MenuId.DiffEditorSelectionToolbar,{command:{id:new fd().desc.id,title:a.localize(137,"Revert Selection"),icon:c.icon},when:o.ContextKeyExpr.and(o.EditorContextKeys.diffEditorModifiedWritable,c.key),order:5,group:"primary"});o.registerAction2(SC),o.registerAction2(yC),o.registerAction2(wC),o.registerAction2(IC),o.MenuRegistry.appendMenuItem(o.MenuId.EditorTitle,{command:{id:mo.id,title:a.localize(138,"Open Accessible Diff Viewer"),precondition:o.ContextKeyExpr.has("isInDiffEditor")},order:10,group:"2_diff",when:o.ContextKeyExpr.and(o.EditorContextKeys.accessibleDiffViewerVisible.negate(),o.ContextKeyExpr.has("isInDiffEditor"))}),o.CommandsRegistry.registerCommandAlias("editor.action.diffReview.next",mo.id),o.registerAction2(mo),o.CommandsRegistry.registerCommandAlias("editor.action.diffReview.prev",Xr.id),o.registerAction2(Xr);var EC=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},LC=function(c,e){return function(t,i){e(t,i,c)}},md;const Yr=new o.RawContextKey("selectionAnchorSet",!1);let Kt=(vn=class{static get(e){return e.getContribution(md.ID)}constructor(e,t){this.editor=e,this.selectionAnchorSetContextKey=Yr.bindTo(t),this.modelChangeListener=e.onDidChangeModel(()=>this.selectionAnchorSetContextKey.reset())}setSelectionAnchor(){if(this.editor.hasModel()){const e=this.editor.getPosition();this.editor.changeDecorations(t=>{this.decorationId&&t.removeDecoration(this.decorationId),this.decorationId=t.addDecoration(a.Selection.fromPositions(e,e),{description:"selection-anchor",stickiness:1,hoverMessage:new o.MarkdownString().appendText(a.localize(849,"Selection Anchor")),className:"selection-anchor"})}),this.selectionAnchorSetContextKey.set(!!this.decorationId),o.alert(a.localize(850,"Anchor set at {0}:{1}",e.lineNumber,e.column))}}goToSelectionAnchor(){if(this.editor.hasModel()&&this.decorationId){const e=this.editor.getModel().getDecorationRange(this.decorationId);e&&this.editor.setPosition(e.getStartPosition())}}selectFromAnchorToCursor(){if(this.editor.hasModel()&&this.decorationId){const e=this.editor.getModel().getDecorationRange(this.decorationId);if(e){const t=this.editor.getPosition();this.editor.setSelection(a.Selection.fromPositions(e.getStartPosition(),t)),this.cancelSelectionAnchor()}}}cancelSelectionAnchor(){if(this.decorationId){const e=this.decorationId;this.editor.changeDecorations(t=>{t.removeDecoration(e),this.decorationId=void 0}),this.selectionAnchorSetContextKey.set(!1)}}dispose(){this.cancelSelectionAnchor(),this.modelChangeListener.dispose()}},md=vn,vn.ID="editor.contrib.selectionAnchorController",vn);Kt=md=EC([LC(1,o.IContextKeyService)],Kt);class DC extends o.EditorAction{constructor(){super({id:"editor.action.setSelectionAnchor",label:a.localize2(851,"Set Selection Anchor"),precondition:void 0,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:a.KeyChord(2089,2080),weight:100}})}async run(e,t){Kt.get(t)?.setSelectionAnchor()}}class RC extends o.EditorAction{constructor(){super({id:"editor.action.goToSelectionAnchor",label:a.localize2(852,"Go to Selection Anchor"),precondition:Yr})}async run(e,t){Kt.get(t)?.goToSelectionAnchor()}}class TC extends o.EditorAction{constructor(){super({id:"editor.action.selectFromAnchorToCursor",label:a.localize2(853,"Select from Anchor to Cursor"),precondition:Yr,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:a.KeyChord(2089,2089),weight:100}})}async run(e,t){Kt.get(t)?.selectFromAnchorToCursor()}}class NC extends o.EditorAction{constructor(){super({id:"editor.action.cancelSelectionAnchor",label:a.localize2(854,"Cancel Selection Anchor"),precondition:Yr,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:9,weight:100}})}async run(e,t){Kt.get(t)?.cancelSelectionAnchor()}}o.registerEditorContribution(Kt.ID,Kt,4),o.registerEditorAction(DC),o.registerEditorAction(RC),o.registerEditorAction(TC),o.registerEditorAction(NC);const MC=o.registerColor("editorOverviewRuler.bracketMatchForeground","#A0A0A0",a.localize(855,"Overview ruler marker color for matching brackets."));class PC extends o.EditorAction{constructor(){super({id:"editor.action.jumpToBracket",label:a.localize2(857,"Go to Bracket"),precondition:void 0,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:3165,weight:100}})}run(e,t){Vi.get(t)?.jumpToBracket()}}class OC extends o.EditorAction{constructor(){super({id:"editor.action.selectToBracket",label:a.localize2(858,"Select to Bracket"),precondition:void 0,metadata:{description:a.localize2(859,"Select the text inside and including the brackets or curly braces"),args:[{name:"args",schema:{type:"object",properties:{selectBrackets:{type:"boolean",default:!0}}}}]}})}run(e,t,i){let n=!0;i&&i.selectBrackets===!1&&(n=!1),Vi.get(t)?.selectToBracket(n)}}class AC extends o.EditorAction{constructor(){super({id:"editor.action.removeBrackets",label:a.localize2(860,"Remove Brackets"),precondition:void 0,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:2561,weight:100},canTriggerInlineEdits:!0})}run(e,t){Vi.get(t)?.removeBrackets(this.id)}}class FC{constructor(e,t,i){this.position=e,this.brackets=t,this.options=i}}const fi=class fi extends a.Disposable{static get(e){return e.getContribution(fi.ID)}constructor(e){super(),this._editor=e,this._lastBracketsData=[],this._lastVersionId=0,this._decorations=this._editor.createDecorationsCollection(),this._updateBracketsSoon=this._register(new a.RunOnceScheduler(()=>this._updateBrackets(),50)),this._matchBrackets=this._editor.getOption(80),this._updateBracketsSoon.schedule(),this._register(e.onDidChangeCursorPosition(t=>{this._matchBrackets!=="never"&&this._updateBracketsSoon.schedule()})),this._register(e.onDidChangeModelContent(t=>{this._updateBracketsSoon.schedule()})),this._register(e.onDidChangeModel(t=>{this._lastBracketsData=[],this._updateBracketsSoon.schedule()})),this._register(e.onDidChangeModelLanguageConfiguration(t=>{this._lastBracketsData=[],this._updateBracketsSoon.schedule()})),this._register(e.onDidChangeConfiguration(t=>{t.hasChanged(80)&&(this._matchBrackets=this._editor.getOption(80),this._decorations.clear(),this._lastBracketsData=[],this._lastVersionId=0,this._updateBracketsSoon.schedule())})),this._register(e.onDidBlurEditorWidget(()=>{this._updateBracketsSoon.schedule()})),this._register(e.onDidFocusEditorWidget(()=>{this._updateBracketsSoon.schedule()}))}jumpToBracket(){if(!this._editor.hasModel())return;const e=this._editor.getModel(),t=this._editor.getSelections().map(i=>{const n=i.getStartPosition(),s=e.bracketPairs.matchBracket(n);let r=null;if(s)s[0].containsPosition(n)&&!s[1].containsPosition(n)?r=s[1].getStartPosition():s[1].containsPosition(n)&&(r=s[0].getStartPosition());else{const l=e.bracketPairs.findEnclosingBrackets(n);if(l)r=l[1].getStartPosition();else{const d=e.bracketPairs.findNextBracket(n);d&&d.range&&(r=d.range.getStartPosition())}}return r?new a.Selection(r.lineNumber,r.column,r.lineNumber,r.column):new a.Selection(n.lineNumber,n.column,n.lineNumber,n.column)});this._editor.setSelections(t),this._editor.revealRange(t[0])}selectToBracket(e){if(!this._editor.hasModel())return;const t=this._editor.getModel(),i=[];this._editor.getSelections().forEach(n=>{const s=n.getStartPosition();let r=t.bracketPairs.matchBracket(s);if(!r&&(r=t.bracketPairs.findEnclosingBrackets(s),!r)){const h=t.bracketPairs.findNextBracket(s);h&&h.range&&(r=t.bracketPairs.matchBracket(h.range.getStartPosition()))}let l=null,d=null;if(r){r.sort(a.Range.compareRangesUsingStarts);const[h,u]=r;if(l=e?h.getStartPosition():h.getEndPosition(),d=e?u.getEndPosition():u.getStartPosition(),u.containsPosition(s)){const g=l;l=d,d=g}}l&&d&&i.push(new a.Selection(l.lineNumber,l.column,d.lineNumber,d.column))}),i.length>0&&(this._editor.setSelections(i),this._editor.revealRange(i[0]))}removeBrackets(e){if(!this._editor.hasModel())return;const t=this._editor.getModel();this._editor.getSelections().forEach(i=>{const n=i.getPosition();let s=t.bracketPairs.matchBracket(n);s||(s=t.bracketPairs.findEnclosingBrackets(n)),s&&(this._editor.pushUndoStop(),this._editor.executeEdits(e,[{range:s[0],text:""},{range:s[1],text:""}]),this._editor.pushUndoStop())})}_updateBrackets(){if(this._matchBrackets==="never")return;this._recomputeBrackets();const e=[];let t=0;for(const i of this._lastBracketsData){const n=i.brackets;n&&(e[t++]={range:n[0],options:i.options},e[t++]={range:n[1],options:i.options})}this._decorations.set(e)}_recomputeBrackets(){if(!this._editor.hasModel()||!this._editor.hasWidgetFocus()){this._lastBracketsData=[],this._lastVersionId=0;return}const e=this._editor.getSelections();if(e.length>100){this._lastBracketsData=[],this._lastVersionId=0;return}const t=this._editor.getModel(),i=t.getVersionId();let n=[];this._lastVersionId===i&&(n=this._lastBracketsData);const s=[];let r=0;for(let g=0,p=e.length;g<p;g++){const f=e[g];f.isEmpty()&&(s[r++]=f.getStartPosition())}s.length>1&&s.sort(a.Position.compare);const l=[];let d=0,h=0;const u=n.length;for(let g=0,p=s.length;g<p;g++){const f=s[g];for(;h<u&&n[h].position.isBefore(f);)h++;if(h<u&&n[h].position.equals(f))l[d++]=n[h];else{let m=t.bracketPairs.matchBracket(f,20),_=fi._DECORATION_OPTIONS_WITH_OVERVIEW_RULER;!m&&this._matchBrackets==="always"&&(m=t.bracketPairs.findEnclosingBrackets(f,20),_=fi._DECORATION_OPTIONS_WITHOUT_OVERVIEW_RULER),l[d++]=new FC(f,m,_)}}this._lastBracketsData=l,this._lastVersionId=i}};fi.ID="editor.contrib.bracketMatchingController",fi._DECORATION_OPTIONS_WITH_OVERVIEW_RULER=o.ModelDecorationOptions.register({description:"bracket-match-overview",stickiness:1,className:"bracket-match",inlineClassName:"bracket-match-inline",overviewRuler:{color:o.themeColorFromId(MC),position:a.OverviewRulerLane.Center}}),fi._DECORATION_OPTIONS_WITHOUT_OVERVIEW_RULER=o.ModelDecorationOptions.register({description:"bracket-match-no-overview",stickiness:1,className:"bracket-match",inlineClassName:"bracket-match-inline"});let Vi=fi;o.registerEditorContribution(Vi.ID,Vi,1),o.registerEditorAction(OC),o.registerEditorAction(PC),o.registerEditorAction(AC),o.MenuRegistry.appendMenuItem(o.MenuId.MenubarGoMenu,{group:"5_infile_nav",command:{id:"editor.action.jumpToBracket",title:a.localize(856,"Go to &&Bracket")},order:2}),o.registerThemingParticipant((c,e)=>{const t=c.getColor(o.editorBracketMatchForeground);t&&e.addRule(`.monaco-editor .bracket-match-inline { color: ${t} !important; }`)});class zC{constructor(e,t){this._selection=e,this._isMovingLeft=t}getEditOperations(e,t){if(this._selection.startLineNumber!==this._selection.endLineNumber||this._selection.isEmpty())return;const i=this._selection.startLineNumber,n=this._selection.startColumn,s=this._selection.endColumn;if(!(this._isMovingLeft&&n===1)&&!(!this._isMovingLeft&&s===e.getLineMaxColumn(i)))if(this._isMovingLeft){const r=new a.Range(i,n-1,i,n),l=e.getValueInRange(r);t.addEditOperation(r,null),t.addEditOperation(new a.Range(i,s,i,s),l)}else{const r=new a.Range(i,s,i,s+1),l=e.getValueInRange(r);t.addEditOperation(r,null),t.addEditOperation(new a.Range(i,n,i,n),l)}}computeCursorState(e,t){return this._isMovingLeft?new a.Selection(this._selection.startLineNumber,this._selection.startColumn-1,this._selection.endLineNumber,this._selection.endColumn-1):new a.Selection(this._selection.startLineNumber,this._selection.startColumn+1,this._selection.endLineNumber,this._selection.endColumn+1)}}class xf extends o.EditorAction{constructor(e,t){super(t),this.left=e}run(e,t){if(!t.hasModel())return;const i=[],n=t.getSelections();for(const s of n)i.push(new zC(s,this.left));t.pushUndoStop(),t.executeCommands(this.id,i),t.pushUndoStop()}}class VC extends xf{constructor(){super(!0,{id:"editor.action.moveCarretLeftAction",label:a.localize2(861,"Move Selected Text Left"),precondition:o.EditorContextKeys.writable})}}class BC extends xf{constructor(){super(!1,{id:"editor.action.moveCarretRightAction",label:a.localize2(862,"Move Selected Text Right"),precondition:o.EditorContextKeys.writable})}}o.registerEditorAction(VC),o.registerEditorAction(BC);class KC extends o.EditorAction{constructor(){super({id:"editor.action.transposeLetters",label:a.localize2(863,"Transpose Letters"),precondition:o.EditorContextKeys.writable,kbOpts:{kbExpr:o.EditorContextKeys.textInputFocus,primary:0,mac:{primary:306},weight:100}})}run(e,t){if(!t.hasModel())return;const i=t.getModel(),n=[],s=t.getSelections();for(const r of s){if(!r.isEmpty())continue;const l=r.startLineNumber,d=r.startColumn,h=i.getLineMaxColumn(l);if(l===1&&(d===1||d===2&&h===2))continue;const u=d===h?r.getPosition():o.MoveOperations.rightPosition(i,r.getPosition().lineNumber,r.getPosition().column),g=o.MoveOperations.leftPosition(i,u),p=o.MoveOperations.leftPosition(i,g),f=i.getValueInRange(a.Range.fromPositions(p,g)),m=i.getValueInRange(a.Range.fromPositions(g,u)),_=a.Range.fromPositions(p,u);n.push(new o.ReplaceCommand(_,m+f))}n.length>0&&(t.pushUndoStop(),t.executeCommands(this.id,n),t.pushUndoStop())}}o.registerEditorAction(KC);const ft=class ft{constructor(e){this.value=e}equals(e){return this.value===e.value}contains(e){return this.equals(e)||this.value===""||e.value.startsWith(this.value+ft.sep)}intersects(e){return this.contains(e)||e.contains(this)}append(...e){return new ft((this.value?[this.value,...e]:e).join(ft.sep))}};ft.sep=".",ft.None=new ft("@@none@@"),ft.Empty=new ft("");let Z=ft;var kC=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},UC=function(c,e){return function(t,i){e(t,i,c)}};const $C=o.ModelDecorationOptions.register({description:"inline-progress-widget",stickiness:1,showIfCollapsed:!0,after:{content:a.noBreakWhitespace,inlineClassName:"inline-editor-progress-decoration",inlineClassNameAffectsLetterSpacing:!0,widthInEm:1}}),wc=class wc extends a.Disposable{constructor(e,t,i,n,s){super(),this.typeId=e,this.editor=t,this.range=i,this.delegate=s,this.allowEditorOverflow=!1,this.suppressMouseDown=!0,this.create(n),this.editor.addContentWidget(this),this.editor.layoutContentWidget(this)}create(e){this.domNode=o.$(".inline-progress-widget"),this.domNode.role="button",this.domNode.title=e;const t=o.$("span.icon");this.domNode.append(t),t.classList.add(...o.ThemeIcon.asClassNameArray(a.Codicon.loading),"codicon-modifier-spin");const i=()=>{const n=this.editor.getOption(75);this.domNode.style.height=`${n}px`,this.domNode.style.width=`${Math.ceil(.8*n)}px`};i(),this._register(this.editor.onDidChangeConfiguration(n=>{(n.hasChanged(61)||n.hasChanged(75))&&i()})),this._register(o.addDisposableListener(this.domNode,o.EventType.CLICK,n=>{this.delegate.cancel()}))}getId(){return wc.baseId+"."+this.typeId}getDomNode(){return this.domNode}getPosition(){return{position:{lineNumber:this.range.startLineNumber,column:this.range.startColumn},preference:[0]}}dispose(){super.dispose(),this.editor.removeContentWidget(this)}};wc.baseId="editor.widget.inlineProgressWidget";let _d=wc,Qr=class extends a.Disposable{constructor(e,t,i){super(),this.id=e,this._editor=t,this._instantiationService=i,this._showDelay=500,this._showPromise=this._register(new a.MutableDisposable),this._currentWidget=this._register(new a.MutableDisposable),this._operationIdPool=0,this._currentDecorations=t.createDecorationsCollection()}dispose(){super.dispose(),this._currentDecorations.clear()}async showWhile(e,t,i,n,s){const r=this._operationIdPool++;this._currentOperation=r,this.clear(),this._showPromise.value=a.disposableTimeout(()=>{const l=a.Range.fromPositions(e);this._currentDecorations.set([{range:l,options:$C}]).length>0&&(this._currentWidget.value=this._instantiationService.createInstance(_d,this.id,this._editor,l,t,n))},s??this._showDelay);try{return await i}finally{this._currentOperation===r&&(this.clear(),this._currentOperation=void 0)}}clear(){this._showPromise.clear(),this._currentDecorations.clear(),this._currentWidget.clear()}};Qr=kC([UC(2,o.IInstantiationService)],Qr);var jC=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Ef=function(c,e){return function(t,i){e(t,i,c)}},Jr;let ve=(mi=class{static get(e){return e.getContribution(Jr.ID)}constructor(e,t,i){this._openerService=i,this._messageWidget=new a.MutableDisposable,this._messageListeners=new a.DisposableStore,this._mouseOverMessage=!1,this._editor=e,this._visible=Jr.MESSAGE_VISIBLE.bindTo(t)}dispose(){this._messageListeners.dispose(),this._messageWidget.dispose(),this._visible.reset()}showMessage(e,t){if(o.alert(o.isMarkdownString(e)?e.value:e),this._visible.set(!0),this._messageWidget.clear(),this._messageListeners.clear(),o.isMarkdownString(e)){const n=this._messageListeners.add(o.renderMarkdown(e,{actionHandler:(s,r)=>{this.closeMessage(),o.openLinkFromMarkdown(this._openerService,s,r.isTrusted)}}));this._messageWidget.value=new vd(this._editor,t,n.element)}else this._messageWidget.value=new vd(this._editor,t,e);this._messageListeners.add(a.Event.debounce(this._editor.onDidBlurEditorText,(n,s)=>s,0)(()=>{this._mouseOverMessage||this._messageWidget.value&&o.isAncestor(o.getActiveElement(),this._messageWidget.value.getDomNode())||this.closeMessage()})),this._messageListeners.add(this._editor.onDidChangeCursorPosition(()=>this.closeMessage())),this._messageListeners.add(this._editor.onDidDispose(()=>this.closeMessage())),this._messageListeners.add(this._editor.onDidChangeModel(()=>this.closeMessage())),this._messageListeners.add(o.addDisposableListener(this._messageWidget.value.getDomNode(),o.EventType.MOUSE_ENTER,()=>this._mouseOverMessage=!0,!0)),this._messageListeners.add(o.addDisposableListener(this._messageWidget.value.getDomNode(),o.EventType.MOUSE_LEAVE,()=>this._mouseOverMessage=!1,!0));let i;this._messageListeners.add(this._editor.onMouseMove(n=>{n.target.position&&(i?i.containsPosition(n.target.position)||this.closeMessage():i=new a.Range(t.lineNumber-3,1,n.target.position.lineNumber+3,1))}))}closeMessage(){this._visible.reset(),this._messageListeners.clear(),this._messageWidget.value&&this._messageListeners.add(vd.fadeOut(this._messageWidget.value))}},Jr=mi,mi.ID="editor.contrib.messageController",mi.MESSAGE_VISIBLE=new o.RawContextKey("messageVisible",!1,a.localize(1353,"Whether the editor is currently showing an inline message")),mi);ve=Jr=jC([Ef(1,o.IContextKeyService),Ef(2,o.IOpenerService)],ve);const qC=o.EditorCommand.bindToContribution(ve.get);o.registerEditorCommand(new qC({id:"leaveEditorMessage",precondition:ve.MESSAGE_VISIBLE,handler:c=>c.closeMessage(),kbOpts:{weight:130,primary:9}}));let vd=class{static fadeOut(e){const t=()=>{e.dispose(),clearTimeout(i),e.getDomNode().removeEventListener("animationend",t)},i=setTimeout(t,110);return e.getDomNode().addEventListener("animationend",t),e.getDomNode().classList.add("fadeOut"),{dispose:t}}constructor(e,{lineNumber:t,column:i},n){this.allowEditorOverflow=!0,this.suppressMouseDown=!1,this._editor=e,this._editor.revealLinesInCenterIfOutsideViewport(t,t,0),this._position={lineNumber:t,column:i},this._domNode=document.createElement("div"),this._domNode.classList.add("monaco-editor-overlaymessage"),this._domNode.style.marginLeft="-6px";const s=document.createElement("div");s.classList.add("anchor","top"),this._domNode.appendChild(s);const r=document.createElement("div");typeof n=="string"?(r.classList.add("message"),r.textContent=n):(n.classList.add("message"),r.appendChild(n)),this._domNode.appendChild(r);const l=document.createElement("div");l.classList.add("anchor","below"),this._domNode.appendChild(l),this._editor.addContentWidget(this),this._domNode.classList.add("fadeIn")}dispose(){this._editor.removeContentWidget(this)}getId(){return"messageoverlay"}getDomNode(){return this._domNode}getPosition(){return{position:this._position,preference:[1,2],positionAffinity:1}}afterRender(e){this._domNode.classList.toggle("below",e===2)}};o.registerEditorContribution(ve.ID,ve,4);var bd=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},_o=function(c,e){return function(t,i){e(t,i,c)}};class Cd{constructor(e){this.copyMimeTypes=[],this.kind=e,this.providedDropEditKinds=[this.kind],this.providedPasteEditKinds=[this.kind]}async provideDocumentPasteEdits(e,t,i,n,s){const r=await this.getEdit(i,s);if(r)return{edits:[{insertText:r.insertText,title:r.title,kind:r.kind,handledMimeType:r.handledMimeType,yieldTo:r.yieldTo}],dispose(){}}}async provideDocumentDropEdits(e,t,i,n){const s=await this.getEdit(i,n);if(s)return{edits:[{insertText:s.insertText,title:s.title,kind:s.kind,handledMimeType:s.handledMimeType,yieldTo:s.yieldTo}],dispose(){}}}}const Ic=class Ic extends Cd{constructor(){super(Z.Empty.append("text","plain")),this.id=Ic.id,this.dropMimeTypes=[o.Mimes.text],this.pasteMimeTypes=[o.Mimes.text]}async getEdit(e,t){const i=e.get(o.Mimes.text);if(!i||e.has(o.Mimes.uriList))return;const n=await i.asString();return{handledMimeType:o.Mimes.text,title:a.localize(980,"Insert Plain Text"),insertText:n,kind:this.kind}}};Ic.id="text";let Bi=Ic;class Lf extends Cd{constructor(){super(Z.Empty.append("uri","path","absolute")),this.dropMimeTypes=[o.Mimes.uriList],this.pasteMimeTypes=[o.Mimes.uriList]}async getEdit(e,t){const i=await Df(e);if(!i.length||t.isCancellationRequested)return;let n=0;const s=i.map(({uri:l,originalText:d})=>l.scheme===a.Schemas.file?l.fsPath:(n++,d)).join(" ");let r;return n>0?r=i.length>1?a.localize(981,"Insert Uris"):a.localize(982,"Insert Uri"):r=i.length>1?a.localize(983,"Insert Paths"):a.localize(984,"Insert Path"),{handledMimeType:o.Mimes.uriList,insertText:s,title:r,kind:this.kind}}}let Wr=class extends Cd{constructor(e){super(Z.Empty.append("uri","path","relative")),this._workspaceContextService=e,this.dropMimeTypes=[o.Mimes.uriList],this.pasteMimeTypes=[o.Mimes.uriList]}async getEdit(e,t){const i=await Df(e);if(!i.length||t.isCancellationRequested)return;const n=a.coalesce(i.map(({uri:s})=>{const r=this._workspaceContextService.getWorkspaceFolder(s);return r?o.relativePath(r.uri,s):void 0}));if(n.length)return{handledMimeType:o.Mimes.uriList,insertText:n.join(" "),title:i.length>1?a.localize(985,"Insert Relative Paths"):a.localize(986,"Insert Relative Path"),kind:this.kind}}};Wr=bd([_o(0,o.IWorkspaceContextService)],Wr);class GC{constructor(){this.kind=new Z("html"),this.providedPasteEditKinds=[this.kind],this.copyMimeTypes=[],this.pasteMimeTypes=["text/html"],this._yieldTo=[{mimeType:o.Mimes.text}]}async provideDocumentPasteEdits(e,t,i,n,s){if(n.triggerKind!==a.DocumentPasteTriggerKind.PasteAs&&!n.only?.contains(this.kind))return;const l=await i.get("text/html")?.asString();if(!(!l||s.isCancellationRequested))return{dispose(){},edits:[{insertText:l,yieldTo:this._yieldTo,title:a.localize(987,"Insert HTML"),kind:this.kind}]}}}async function Df(c){const e=c.get(o.Mimes.uriList);if(!e)return[];const t=await e.asString(),i=[];for(const n of o.UriList.parse(t))try{i.push({uri:a.URI.parse(n),originalText:n})}catch{}return i}const Ki={scheme:"*",hasAccessToAllModels:!0};let Sd=class extends a.Disposable{constructor(e,t){super(),this._register(e.documentDropEditProvider.register(Ki,new Bi)),this._register(e.documentDropEditProvider.register(Ki,new Lf)),this._register(e.documentDropEditProvider.register(Ki,new Wr(t)))}};Sd=bd([_o(0,o.ILanguageFeaturesService),_o(1,o.IWorkspaceContextService)],Sd);let yd=class extends a.Disposable{constructor(e,t){super(),this._register(e.documentPasteEditProvider.register(Ki,new Bi)),this._register(e.documentPasteEditProvider.register(Ki,new Lf)),this._register(e.documentPasteEditProvider.register(Ki,new Wr(t))),this._register(e.documentPasteEditProvider.register(Ki,new GC))}};yd=bd([_o(0,o.ILanguageFeaturesService),_o(1,o.IWorkspaceContextService)],yd);const ke=class ke{constructor(){this.value="",this.pos=0}static isDigitCharacter(e){return e>=48&&e<=57}static isVariableCharacter(e){return e===95||e>=97&&e<=122||e>=65&&e<=90}text(e){this.value=e,this.pos=0}tokenText(e){return this.value.substr(e.pos,e.len)}next(){if(this.pos>=this.value.length)return{type:14,pos:this.pos,len:0};const e=this.pos;let t=0,i=this.value.charCodeAt(e),n;if(n=ke._table[i],typeof n=="number")return this.pos+=1,{type:n,pos:e,len:1};if(ke.isDigitCharacter(i)){n=8;do t+=1,i=this.value.charCodeAt(e+t);while(ke.isDigitCharacter(i));return this.pos+=t,{type:n,pos:e,len:t}}if(ke.isVariableCharacter(i)){n=9;do i=this.value.charCodeAt(e+ ++t);while(ke.isVariableCharacter(i)||ke.isDigitCharacter(i));return this.pos+=t,{type:n,pos:e,len:t}}n=10;do t+=1,i=this.value.charCodeAt(e+t);while(!isNaN(i)&&typeof ke._table[i]>"u"&&!ke.isDigitCharacter(i)&&!ke.isVariableCharacter(i));return this.pos+=t,{type:n,pos:e,len:t}}};ke._table={36:0,58:1,44:2,123:3,125:4,92:5,47:6,124:7,43:11,45:12,63:13};let wd=ke;class rs{constructor(){this._children=[]}appendChild(e){return e instanceof le&&this._children[this._children.length-1]instanceof le?this._children[this._children.length-1].value+=e.value:(e.parent=this,this._children.push(e)),this}replace(e,t){const{parent:i}=e,n=i.children.indexOf(e),s=i.children.slice(0);s.splice(n,1,...t),i._children=s,(function r(l,d){for(const h of l)h.parent=d,r(h.children,h)})(t,i)}get children(){return this._children}get rightMostDescendant(){return this._children.length>0?this._children[this._children.length-1].rightMostDescendant:this}get snippet(){let e=this;for(;;){if(!e)return;if(e instanceof vo)return e;e=e.parent}}toString(){return this.children.reduce((e,t)=>e+t.toString(),"")}len(){return 0}}class le extends rs{constructor(e){super(),this.value=e}toString(){return this.value}len(){return this.value.length}clone(){return new le(this.value)}}class Rf extends rs{}class Re extends Rf{static compareByIndex(e,t){return e.index===t.index?0:e.isFinalTabstop?1:t.isFinalTabstop||e.index<t.index?-1:e.index>t.index?1:0}constructor(e){super(),this.index=e}get isFinalTabstop(){return this.index===0}get choice(){return this._children.length===1&&this._children[0]instanceof as?this._children[0]:void 0}clone(){const e=new Re(this.index);return this.transform&&(e.transform=this.transform.clone()),e._children=this.children.map(t=>t.clone()),e}}class as extends rs{constructor(){super(...arguments),this.options=[]}appendChild(e){return e instanceof le&&(e.parent=this,this.options.push(e)),this}toString(){return this.options[0].value}len(){return this.options[0].len()}clone(){const e=new as;return this.options.forEach(e.appendChild,e),e}}class Id extends rs{constructor(){super(...arguments),this.regexp=new RegExp("")}resolve(e){const t=this;let i=!1,n=e.replace(this.regexp,function(){return i=!0,t._replace(Array.prototype.slice.call(arguments,0,-2))});return!i&&this._children.some(s=>s instanceof qe&&!!s.elseValue)&&(n=this._replace([])),n}_replace(e){let t="";for(const i of this._children)if(i instanceof qe){let n=e[i.index]||"";n=i.resolve(n),t+=n}else t+=i.toString();return t}toString(){return""}clone(){const e=new Id;return e.regexp=new RegExp(this.regexp.source,(this.regexp.ignoreCase?"i":"")+(this.regexp.global?"g":"")),e._children=this.children.map(t=>t.clone()),e}}class qe extends rs{constructor(e,t,i,n){super(),this.index=e,this.shorthandName=t,this.ifValue=i,this.elseValue=n}resolve(e){return this.shorthandName==="upcase"?e?e.toLocaleUpperCase():"":this.shorthandName==="downcase"?e?e.toLocaleLowerCase():"":this.shorthandName==="capitalize"?e?e[0].toLocaleUpperCase()+e.substr(1):"":this.shorthandName==="pascalcase"?e?this._toPascalCase(e):"":this.shorthandName==="camelcase"?e?this._toCamelCase(e):"":this.shorthandName==="kebabcase"?e?this._toKebabCase(e):"":this.shorthandName==="snakecase"?e?this._toSnakeCase(e):"":e&&typeof this.ifValue=="string"?this.ifValue:!e&&typeof this.elseValue=="string"?this.elseValue:e||""}_toKebabCase(e){if(!e.match(/[\p{L}0-9]+/gu))return e;if(!e.match(/[\p{L}0-9]/u))return e.trim().toLowerCase().replace(/^_+|_+$/g,"").replace(/[\s_]+/g,"-");const i=e.trim().replace(/^_+|_+$/g,""),n=i.match(new RegExp("\\p{Lu}{2,}(?=\\p{Lu}\\p{Ll}+[0-9]*|[\\s_-]|$)|\\p{Lu}?\\p{Ll}+[0-9]*|\\p{Lu}(?=\\p{Lu}\\p{Ll})|\\p{Lu}(?=[\\s_-]|$)|[0-9]+","gu"));return n?n.map(s=>s.toLowerCase()).join("-"):i.split(/[\s_-]+/).filter(s=>s.length>0).map(s=>s.toLowerCase()).join("-")}_toPascalCase(e){const t=e.match(/[\p{L}0-9]+/gu);return t?t.map(i=>i.charAt(0).toUpperCase()+i.substr(1)).join(""):e}_toCamelCase(e){const t=e.match(/[\p{L}0-9]+/gu);return t?t.map((i,n)=>n===0?i.charAt(0).toLowerCase()+i.substr(1):i.charAt(0).toUpperCase()+i.substr(1)).join(""):e}_toSnakeCase(e){return e.replace(new RegExp("(\\p{Ll})(\\p{Lu})","gu"),"$1_$2").replace(/[\s\-]+/g,"_").toLowerCase()}clone(){return new qe(this.index,this.shorthandName,this.ifValue,this.elseValue)}}class ki extends Rf{constructor(e){super(),this.name=e}resolve(e){let t=e.resolve(this);return this.transform&&(t=this.transform.resolve(t||"")),t!==void 0?(this._children=[new le(t)],!0):!1}clone(){const e=new ki(this.name);return this.transform&&(e.transform=this.transform.clone()),e._children=this.children.map(t=>t.clone()),e}}function Tf(c,e){const t=[...c];for(;t.length>0;){const i=t.shift();if(!e(i))break;t.unshift(...i.children)}}class vo extends rs{get placeholderInfo(){if(!this._placeholders){const e=[];let t;this.walk(function(i){return i instanceof Re&&(e.push(i),t=!t||t.index<i.index?i:t),!0}),this._placeholders={all:e,last:t}}return this._placeholders}get placeholders(){const{all:e}=this.placeholderInfo;return e}offset(e){let t=0,i=!1;return this.walk(n=>n===e?(i=!0,!1):(t+=n.len(),!0)),i?t:-1}fullLen(e){let t=0;return Tf([e],i=>(t+=i.len(),!0)),t}enclosingPlaceholders(e){const t=[];let{parent:i}=e;for(;i;)i instanceof Re&&t.push(i),i=i.parent;return t}resolveVariables(e){return this.walk(t=>(t instanceof ki&&t.resolve(e)&&(this._placeholders=void 0),!0)),this}appendChild(e){return this._placeholders=void 0,super.appendChild(e)}replace(e,t){return this._placeholders=void 0,super.replace(e,t)}clone(){const e=new vo;return e._children=this.children.map(t=>t.clone()),e}walk(e){Tf(this.children,e)}}class Ui{constructor(){this._scanner=new wd,this._token={type:14,pos:0,len:0}}static escape(e){return e.replace(/\$|}|\\/g,"\\$&")}static guessNeedsClipboard(e){return/\${?CLIPBOARD/.test(e)}parse(e,t,i){const n=new vo;return this.parseFragment(e,n),this.ensureFinalTabstop(n,i??!1,t??!1),n}parseFragment(e,t){const i=t.children.length;for(this._scanner.text(e),this._token=this._scanner.next();this._parse(t););const n=new Map,s=[];t.walk(d=>(d instanceof Re&&(d.isFinalTabstop?n.set(0,void 0):!n.has(d.index)&&d.children.length>0?n.set(d.index,d.children):s.push(d)),!0));const r=(d,h)=>{const u=n.get(d.index);if(!u)return;const g=new Re(d.index);g.transform=d.transform;for(const p of u){const f=p.clone();g.appendChild(f),f instanceof Re&&n.has(f.index)&&!h.has(f.index)&&(h.add(f.index),r(f,h),h.delete(f.index))}t.replace(d,[g])},l=new Set;for(const d of s)r(d,l);return t.children.slice(i)}ensureFinalTabstop(e,t,i){(t||i&&e.placeholders.length>0)&&(e.placeholders.find(s=>s.index===0)||e.appendChild(new Re(0)))}_accept(e,t){if(e===void 0||this._token.type===e){const i=t?this._scanner.tokenText(this._token):!0;return this._token=this._scanner.next(),i}return!1}_backTo(e){return this._scanner.pos=e.pos+e.len,this._token=e,!1}_until(e){const t=this._token;for(;this._token.type!==e;){if(this._token.type===14)return!1;if(this._token.type===5){const n=this._scanner.next();if(n.type!==0&&n.type!==4&&n.type!==5)return!1}this._token=this._scanner.next()}const i=this._scanner.value.substring(t.pos,this._token.pos).replace(/\\(\$|}|\\)/g,"$1");return this._token=this._scanner.next(),i}_parse(e){return this._parseEscaped(e)||this._parseTabstopOrVariableName(e)||this._parseComplexPlaceholder(e)||this._parseComplexVariable(e)||this._parseAnything(e)}_parseEscaped(e){let t;return(t=this._accept(5,!0))?(t=this._accept(0,!0)||this._accept(4,!0)||this._accept(5,!0)||t,e.appendChild(new le(t)),!0):!1}_parseTabstopOrVariableName(e){let t;const i=this._token;return this._accept(0)&&(t=this._accept(9,!0)||this._accept(8,!0))?(e.appendChild(/^\d+$/.test(t)?new Re(Number(t)):new ki(t)),!0):this._backTo(i)}_parseComplexPlaceholder(e){let t;const i=this._token;if(!(this._accept(0)&&this._accept(3)&&(t=this._accept(8,!0))))return this._backTo(i);const s=new Re(Number(t));if(this._accept(1))for(;;){if(this._accept(4))return e.appendChild(s),!0;if(!this._parse(s))return e.appendChild(new le("${"+t+":")),s.children.forEach(e.appendChild,e),!0}else if(s.index>0&&this._accept(7)){const r=new as;for(;;){if(this._parseChoiceElement(r)){if(this._accept(2))continue;if(this._accept(7)&&(s.appendChild(r),this._accept(4)))return e.appendChild(s),!0}return this._backTo(i),!1}}else return this._accept(6)?this._parseTransform(s)?(e.appendChild(s),!0):(this._backTo(i),!1):this._accept(4)?(e.appendChild(s),!0):this._backTo(i)}_parseChoiceElement(e){const t=this._token,i=[];for(;!(this._token.type===2||this._token.type===7);){let n;if((n=this._accept(5,!0))?n=this._accept(2,!0)||this._accept(7,!0)||this._accept(5,!0)||n:n=this._accept(void 0,!0),!n)return this._backTo(t),!1;i.push(n)}return i.length===0?(this._backTo(t),!1):(e.appendChild(new le(i.join(""))),!0)}_parseComplexVariable(e){let t;const i=this._token;if(!(this._accept(0)&&this._accept(3)&&(t=this._accept(9,!0))))return this._backTo(i);const s=new ki(t);if(this._accept(1))for(;;){if(this._accept(4))return e.appendChild(s),!0;if(!this._parse(s))return e.appendChild(new le("${"+t+":")),s.children.forEach(e.appendChild,e),!0}else return this._accept(6)?this._parseTransform(s)?(e.appendChild(s),!0):(this._backTo(i),!1):this._accept(4)?(e.appendChild(s),!0):this._backTo(i)}_parseTransform(e){const t=new Id;let i="",n="";for(;!this._accept(6);){let s;if(s=this._accept(5,!0)){s=this._accept(6,!0)||s,i+=s;continue}if(this._token.type!==14){i+=this._accept(void 0,!0);continue}return!1}for(;!this._accept(6);){let s;if(s=this._accept(5,!0)){s=this._accept(5,!0)||this._accept(6,!0)||s,t.appendChild(new le(s));continue}if(!(this._parseFormatString(t)||this._parseAnything(t)))return!1}for(;!this._accept(4);){if(this._token.type!==14){n+=this._accept(void 0,!0);continue}return!1}try{t.regexp=new RegExp(i,n)}catch{return!1}return e.transform=t,!0}_parseFormatString(e){const t=this._token;if(!this._accept(0))return!1;let i=!1;this._accept(3)&&(i=!0);const n=this._accept(8,!0);if(n)if(i){if(this._accept(4))return e.appendChild(new qe(Number(n))),!0;if(!this._accept(1))return this._backTo(t),!1}else return e.appendChild(new qe(Number(n))),!0;else return this._backTo(t),!1;if(this._accept(6)){const s=this._accept(9,!0);return!s||!this._accept(4)?(this._backTo(t),!1):(e.appendChild(new qe(Number(n),s)),!0)}else if(this._accept(11)){const s=this._until(4);if(s)return e.appendChild(new qe(Number(n),void 0,s,void 0)),!0}else if(this._accept(12)){const s=this._until(4);if(s)return e.appendChild(new qe(Number(n),void 0,void 0,s)),!0}else if(this._accept(13)){const s=this._until(1);if(s){const r=this._until(4);if(r)return e.appendChild(new qe(Number(n),void 0,s,r)),!0}}else{const s=this._until(4);if(s)return e.appendChild(new qe(Number(n),void 0,void 0,s)),!0}return this._backTo(t),!1}_parseAnything(e){return this._token.type!==14?(e.appendChild(new le(this._scanner.tokenText(this._token))),this._accept(void 0),!0):!1}}function Nf(c,e,t){return(typeof t.insertText=="string"?t.insertText==="":t.insertText.snippet==="")?{edits:t.additionalEdit?.edits??[]}:{edits:[...e.map(i=>new o.ResourceTextEdit(c,{range:i,text:typeof t.insertText=="string"?Ui.escape(t.insertText)+"$0":t.insertText.snippet,insertAsSnippet:!0})),...t.additionalEdit?.edits??[]]}}function Mf(c){function e(r,l){return"mimeType"in r?r.mimeType===l.handledMimeType:!!l.kind&&r.kind.contains(l.kind)}const t=new Map;for(const r of c)for(const l of r.yieldTo??[])for(const d of c)if(d!==r&&e(l,d)){let h=t.get(r);h||(h=[],t.set(r,h)),h.push(d)}if(!t.size)return Array.from(c);const i=new Set,n=[];function s(r){if(!r.length)return[];const l=r[0];if(n.includes(l))return console.warn("Yield to cycle detected",l),r;if(i.has(l))return s(r.slice(1));let d=[];const h=t.get(l);return h&&(n.push(l),d=s(h),n.pop()),i.add(l),[...d,l,...s(r.slice(1))]}return s(Array.from(c))}function xd(c,e){return e&&(c.stack||c.stacktrace)?a.localize(33,"{0}: {1}",Of(c),Pf(c.stack)||Pf(c.stacktrace)):Of(c)}function Pf(c){return Array.isArray(c)?c.join(`
2
+ `):c}function Of(c){return c.code==="ERR_UNC_HOST_NOT_ALLOWED"?`${c.message}. Please update the 'security.allowedUNCHosts' setting if you want to allow this host.`:typeof c.code=="string"&&typeof c.errno=="number"&&typeof c.syscall=="string"?a.localize(34,"A system error occurred ({0})",c.message):c.message||a.localize(35,"An unknown error occurred. Please consult the log for more details.")}function Hr(c=null,e=!1){if(!c)return a.localize(36,"An unknown error occurred. Please consult the log for more details.");if(Array.isArray(c)){const t=a.coalesce(c),i=Hr(t[0],e);return t.length>1?a.localize(37,"{0} ({1} errors in total)",i,t.length):i}if(a.isString(c))return c;if(c.detail){const t=c.detail;if(t.error)return xd(t.error,e);if(t.exception)return xd(t.exception,e)}return c.stack?xd(c,e):c.message?c.message:a.localize(38,"An unknown error occurred. Please consult the log for more details.")}class ZC extends a.Disposable{constructor(e){super(),this._onChange=this._register(new a.Emitter),this.onChange=this._onChange.event,this._checked=!!e.checked,this._title=e.title??e.ariaLabel,this.domNode=o.$("button.monaco-switch"),this.domNode.type="button",this.domNode.setAttribute("role","switch"),o.append(this.domNode,o.$(".monaco-switch-thumb")),this._register(o.getBaseLayerHoverDelegate().setupDelayedHover(this.domNode,()=>({content:this._title,style:1}))),this.setAriaLabel(e.ariaLabel,e.title),this.disabled=!!e.disabled,this._applyState(),this._register(o.addDisposableListener(this.domNode,o.EventType.CLICK,t=>{o.EventHelper.stop(t,!0),!this.domNode.disabled&&(this._checked=!this._checked,this._applyState(),this._onChange.fire(this._checked))}))}get checked(){return this._checked}set checked(e){this._checked!==e&&(this._checked=e,this._applyState())}get disabled(){return this.domNode.disabled}set disabled(e){this.domNode.disabled=e}setAriaLabel(e,t=e){this.domNode.setAttribute("aria-label",e),this._title=t}_applyState(){this.domNode.setAttribute("aria-checked",String(this._checked)),this.domNode.classList.toggle("checked",this._checked)}}var XC=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Af=function(c,e){return function(t,i){e(t,i,c)}};let ea=class extends a.Disposable{get enabled(){return this._enabled}set enabled(e){e?(this.el.setAttribute("aria-disabled","false"),this.el.tabIndex=0,this.el.style.pointerEvents="auto",this.el.style.opacity="1",this.el.style.cursor="pointer",this._enabled=!1):(this.el.setAttribute("aria-disabled","true"),this.el.tabIndex=-1,this.el.style.pointerEvents="none",this.el.style.opacity="0.4",this.el.style.cursor="default",this._enabled=!0),this._enabled=e}constructor(e,t,i={},n,s){super(),this._link=t,this._hoverService=n,this._enabled=!0,this.el=o.append(e,o.$("a.monaco-link",{tabIndex:t.tabIndex??0,href:t.href},t.label)),this.hoverDelegate=i.hoverDelegate??o.getDefaultHoverDelegate("mouse"),this.setTooltip(t.title),this.el.setAttribute("role","button");const r=this._register(new o.DomEmitter(this.el,"click")),l=this._register(new o.DomEmitter(this.el,"keydown")),d=a.Event.chain(l.event,g=>g.map(p=>new o.StandardKeyboardEvent(p)).filter(p=>p.keyCode===3||p.keyCode===10)),h=this._register(new o.DomEmitter(this.el,o.EventType$1.Tap)).event;this._register(o.Gesture.addTarget(this.el));const u=a.Event.any(r.event,d,h);this._register(u(g=>{this.enabled&&(o.EventHelper.stop(g,!0),i?.opener?i.opener(this._link.href):s.open(this._link.href,{allowCommands:!0}))})),this.enabled=!0}setTooltip(e){!this.hover&&e?this.hover=this._register(this._hoverService.setupManagedHover(this.hoverDelegate,this.el,e)):this.hover&&this.hover.update(e)}};ea=XC([Af(3,o.IHoverService),Af(4,o.IOpenerService)],ea);var Ed=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},kt=function(c,e){return function(t,i){e(t,i,c)}},Ld;const Dd="acceptSelectedCodeAction",Rd="previewSelectedCodeAction",YC=new Set([Dd,Rd,"toggleSectionCodeAction"]),QC="actionList.remove";class JC{get templateId(){return"header"}renderTemplate(e){e.classList.add("group-header");const t=document.createElement("span");return e.append(t),{container:e,text:t}}renderElement(e,t,i){i.text.textContent=e.group?.title??e.label??""}disposeTemplate(e){}}class WC{get templateId(){return"separator"}renderTemplate(e){e.classList.add("separator");const t=document.createElement("span");return e.append(t),{container:e,text:t}}renderElement(e,t,i){i.container.classList.toggle("has-label",!!e.label),i.text.textContent=e.label??""}disposeTemplate(e){}}function Ff(c){return!!c.submenuActions?.length&&!c.hover?.content||!!c.hover?.expandable}function zf(c){return Ff(c)&&c.hover?.showIndicator!==!1}let Td=class{get templateId(){return"action"}constructor(e,t,i,n,s,r,l,d,h,u,g,p){this._supportsPreview=e,this._onRemoveItem=t,this._onShowSubmenu=i,this._reservesSubmenuSpace=n,this._groupTitleByIndex=s,this._linkHandler=r,this._hideDefaultKeybindingTooltip=l,this._stopToolbarPointerPropagation=d,this._registerStandaloneToggle=h,this._registerToolbar=u,this._keybindingService=g,this._openerService=p}renderTemplate(e){e.classList.add(this.templateId);const t=document.createElement("div");t.className="icon",e.append(t);const i=document.createElement("span");i.className="title",e.append(i);const n=document.createElement("span");n.className="action-item-badge",n.ariaHidden="true",e.append(n);const s=document.createElement("span");s.className="description",e.append(s);const r=document.createElement("span");r.className="group-title",e.append(r);const l=document.createElement("span");l.className="detail",e.append(l);const d=new o.KeybindingLabel(e,a.OS),h=document.createElement("div");h.className="action-list-item-toolbar",e.append(h);const u=document.createElement("div");u.className="action-list-submenu-indicator",e.append(u);const g=document.createElement("div");g.className="action-list-item-inline-toggle",e.append(g);const p=new a.DisposableStore;return{container:e,icon:t,text:i,detail:l,badge:n,description:s,groupTitle:r,keybinding:d,toolbar:h,submenuIndicator:u,inlineToggleContainer:g,elementDisposables:p}}renderElement(e,t,i){if(i.elementDisposables.clear(),e.iconClasses?.length?(i.icon.className=["icon",...e.iconClasses].join(" "),i.icon.style.color=""):e.group?.icon?(i.icon.className=o.ThemeIcon.asClassName(e.group.icon),i.icon.style.color=e.group.icon.color?o.asCssVariable(e.group.icon.color.id):""):(i.icon.className=o.ThemeIcon.asClassName(a.Codicon.lightBulb),i.icon.style.color="var(--vscode-editorLightBulb-foreground)"),!e.item&&!e.standaloneToggle||!e.label)return;if(o.setVisibility(!e.hideIcon,i.icon),e.isSectionToggle){const u=e.group?.icon===a.Codicon.chevronDown;i.container.setAttribute("aria-expanded",String(u))}else i.container.removeAttribute("aria-expanded");i.previousClassNames?.length&&i.container.classList.remove(...i.previousClassNames);const n=e.className?.split(/\s+/).filter(u=>u.length>0)??[];if(i.container.classList.toggle("action-list-custom",n.length>0),n.length&&i.container.classList.add(...n),i.previousClassNames=n,i.text.textContent=Me(e.label),e.badge?(i.badge.textContent=e.badge,i.badge.style.display=""):(i.badge.textContent="",i.badge.style.display="none"),e.keybinding)i.description.textContent=e.keybinding.getLabel(),i.description.style.display="inline",i.description.style.letterSpacing="0.5px";else if(e.description){if(o.clearNode(i.description),typeof e.description=="string")i.description.textContent=Me(e.description);else{const u=o.renderMarkdown(e.description,{actionHandler:g=>{const p=a.URI.parse(g);this._linkHandler?this._linkHandler(p,e):this._openerService.open(p,{allowCommands:!0})}});i.elementDisposables.add(u),i.description.appendChild(u.element)}i.description.style.display="inline"}else i.description.textContent="",i.description.style.display="none";const s=this._groupTitleByIndex.get(t);s?(i.groupTitle.textContent=s,i.groupTitle.style.display=""):(i.groupTitle.textContent="",i.groupTitle.style.display="none"),e.detail?(i.detail.textContent=Me(e.detail),i.detail.style.display=""):(i.detail.textContent="",i.detail.style.display="none"),i.container.classList.toggle("has-detail",!!e.detail),o.clearNode(i.inlineToggleContainer);const r=e.standaloneToggle??e.inlineToggle;if(r){const u=document.createElement("span");u.className="action-list-item-inline-toggle-label",u.textContent=Me(r.label),e.standaloneToggle||i.inlineToggleContainer.append(u),i.inlineToggleContainer.style.display="",i.container.classList.toggle("has-inline-toggle",!!e.inlineToggle),i.container.classList.toggle("has-standalone-toggle",!!e.standaloneToggle);const g=i.elementDisposables.add(new ZC({ariaLabel:r.title??r.label,checked:r.checked,disabled:r.disabled}));i.inlineToggleContainer.append(g.domNode),e.standaloneToggle&&i.elementDisposables.add(this._registerStandaloneToggle(e,g)),i.elementDisposables.add(g.onChange(()=>r.onChange(g.checked))),i.elementDisposables.add(o.addDisposableListener(i.inlineToggleContainer,o.EventType.CLICK,p=>p.stopPropagation()))}else i.inlineToggleContainer.style.display="none",i.container.classList.remove("has-inline-toggle"),i.container.classList.remove("has-standalone-toggle");const l=this._keybindingService.lookupKeybinding(Dd)?.getLabel(),d=this._keybindingService.lookupKeybinding(Rd)?.getLabel();i.container.classList.toggle("option-disabled",!!e.disabled),e.hover!==void 0?i.container.title="":e.tooltip?i.container.title=e.tooltip:e.disabled?i.container.title=e.label:e.standaloneToggle||this._hideDefaultKeybindingTooltip?i.container.title="":l&&d?this._supportsPreview&&e.canPreview?i.container.title=a.localize(1731,"{0} to Apply, {1} to Preview",l,d):i.container.title=a.localize(1732,"{0} to Apply",l):i.container.title="",o.clearNode(i.toolbar);const h=[...e.toolbarActions??[]];if(e.onRemove&&h.push(o.toAction({id:QC,label:a.localize(1733,"Remove"),class:o.ThemeIcon.asClassName(a.Codicon.close),run:async()=>{await e.onRemove(),this._onRemoveItem?.(e)}})),i.container.classList.toggle("has-toolbar",h.length>0),h.length>0){const u=new o.ActionBar(i.toolbar);i.elementDisposables.add(u),this._stopToolbarPointerPropagation?(i.elementDisposables.add(o.addDisposableGenericMouseDownListener(i.toolbar,g=>{g.preventDefault(),g.stopPropagation()})),i.elementDisposables.add(o.addDisposableListener(i.toolbar,o.EventType.CLICK,g=>g.stopPropagation())),i.elementDisposables.add(o.addDisposableListener(i.toolbar,o.EventType$1.Tap,g=>g.stopPropagation()))):i.elementDisposables.add(o.addDisposableGenericMouseDownListener(i.toolbar,g=>g.preventDefault())),u.push(h,{icon:!0,label:!1}),i.elementDisposables.add(this._registerToolbar(e,u))}zf(e)?(i.submenuIndicator.className="action-list-submenu-indicator has-submenu "+o.ThemeIcon.asClassName(a.Codicon.chevronRight),i.submenuIndicator.style.display="",i.submenuIndicator.style.visibility="",i.elementDisposables.add(o.addDisposableListener(i.submenuIndicator,o.EventType.CLICK,u=>{u.stopPropagation(),this._onShowSubmenu?.(e)}))):this._reservesSubmenuSpace()?(i.submenuIndicator.className="action-list-submenu-indicator",i.submenuIndicator.style.display="",i.submenuIndicator.style.visibility="hidden"):(i.submenuIndicator.className="action-list-submenu-indicator",i.submenuIndicator.style.display="none"),Ff(e)?(i.container.setAttribute("aria-haspopup",e.hover?.expandable?"dialog":"menu"),i.container.setAttribute("aria-expanded","false")):(i.container.removeAttribute("aria-haspopup"),e.isSectionToggle||i.container.removeAttribute("aria-expanded"))}disposeTemplate(e){e.keybinding.dispose(),e.elementDisposables.dispose()}};Td=Ed([kt(10,o.IKeybindingService),kt(11,o.IOpenerService)],Td);class Vf extends UIEvent{constructor(){super("acceptSelectedAction")}}class Bf extends UIEvent{constructor(){super("previewSelectedAction")}}function HC(c){if(c.kind==="action")return c.label}let Nd=Ld=class extends a.Disposable{constructor(e,t,i,n,s,r,l,d,h){if(super(),this._supportsPreview=t,this._delegate=n,this._options=r,this._keybindingService=l,this._openerService=d,this._instantiationService=h,this._headerLineHeight=24,this._separatorLineHeight=8,this.cts=this._register(new a.CancellationTokenSource),this._submenuDisposables=this._register(new a.DisposableStore),this._submenuHoverActionElements=[],this._itemMoveAnimation=this._register(new a.MutableDisposable),this._collapsedSections=new Set,this._filterText="",this._imeSessionInProgress=!1,this._isMeasuringWidth=!1,this._suppressHover=!1,this._hoverEnabled=!0,this._ignoreInitialHover=!0,this._hasLaidOut=!1,this._filterCts=this._register(new a.MutableDisposable),this._groupTitleByIndex=new Map,this._standaloneToggles=new Map,this._itemToolbars=new Map,this._onDidRequestLayout=this._register(new a.Emitter),this.onDidRequestLayout=this._onDidRequestLayout.event,this._visibleMenuItems=i,this._initialFocusItemId=this._options?.initialFocusItemId,this._filterText=this._options?.showFilter?this._options.initialFilterValue??"":"",this.domNode=document.createElement("div"),this.domNode.classList.add("actionList"),this._options?.inlineDescription&&this.domNode.classList.add("inline-description"),this._options?.className){const f=this._options.className.split(/\s+/).filter(m=>m.length>0);f.length>0&&this.domNode.classList.add(...f)}if(this._actionLineHeight=24,this._submenuContainer=document.createElement("div"),this._submenuContainer.className="action-list-submenu-panel action-widget",this._submenuContainer.style.display="none",this._options?.persistentHover&&(this._submenuContainer.style.boxSizing="border-box"),this._submenuContainer.tabIndex=-1,this.domNode.append(this._submenuContainer),this._register(o.addDisposableListener(this._submenuContainer,"keydown",f=>{if((f.key==="Enter"||f.key===" ")&&this._currentSubmenuElement?.hover?.tabThroughPanel){const _=o.isHTMLElement(f.target)?f.target:void 0;if(_&&this._currentSubmenuElement.hover.getTabbableElements?.().includes(_)){f.stopPropagation();return}}if(f.key!=="ArrowLeft"&&f.key!=="Escape")return;o.EventHelper.stop(f,!0);const m=f.key==="Escape"&&this._currentSubmenuWidget!==void 0;if(this._hideSubmenu(),m){this.hide();return}this._setKeyboardNavigation(!0),this._list.domFocus()})),this._register(o.addDisposableListener(this._submenuContainer,"mouseenter",()=>{this._cancelSubmenuHide(),this._usesSubmenuPointerIntent()&&(this._cancelSubmenuShow(),this._resetSubmenuPointer())})),this._register(o.addDisposableListener(this._submenuContainer,"mouseleave",()=>{this._scheduleSubmenuHide()})),this._register(o.addDisposableListener(this.domNode,o.EventType.MOUSE_LEAVE,()=>{this._cancelSubmenuShow(),this._resetSubmenuPointer()})),this._usesSubmenuPointerIntent()&&this._register(o.addDisposableListener(this.domNode,o.EventType.MOUSE_MOVE,f=>{o.isHTMLElement(f.target)&&this._expandedTrigger?.contains(f.target)&&this._updateSubmenuPointer(f)})),this._register(a.toDisposable(()=>{this._cancelSubmenuHide(),this._cancelSubmenuShow()})),this._options?.collapsedByDefault)for(const f of this._options.collapsedByDefault)this._collapsedSections.add(f);const u={getHeight:f=>this._getItemHeight(f),getTemplateId:f=>f.kind},g=()=>{const f=this._options?.reserveSubmenuSpace??!0;return f==="always"||f&&this._allMenuItems.some(zf)};this._list=this._register(new o.List(e,this.domNode,u,[new Td(this._supportsPreview,f=>this._removeItem(f),f=>this._showSubmenuForItem(f),g,this._groupTitleByIndex,this._options?.linkHandler,this._options?.hideDefaultKeybindingTooltip??!1,this._options?.stopToolbarPointerPropagation??!1,(f,m)=>(this._standaloneToggles.set(f,m),a.toDisposable(()=>{this._standaloneToggles.get(f)===m&&this._standaloneToggles.delete(f)})),(f,m)=>(this._itemToolbars.set(f,m),this._updateToolbarFocusability(),a.toDisposable(()=>{this._itemToolbars.get(f)===m&&this._itemToolbars.delete(f)})),this._keybindingService,this._openerService),new JC,new WC],{keyboardSupport:!1,typeNavigationEnabled:!this._options?.showFilter&&!this._options?.onType,keyboardNavigationLabelProvider:{getKeyboardNavigationLabel:HC},accessibilityProvider:{getAriaLabel:f=>{if(f.kind==="action"){let m=f.label?Me(f?.label):"";if(f.badge&&(m=m+", "+Me(f.badge)),f.detail&&(m=m+", "+Me(f.detail)),f.ariaDescription)m=m+", "+Me(f.ariaDescription);else if(f.description){const v=typeof f.description=="string"?f.description:f.description.value;m=m+", "+Me(v)}if(f.hover?.content&&!f.ariaDescription&&!f.description){const v=f.hover.content,b=typeof v=="string"?v:o.isMarkdownString(v)?v.value:o.isHTMLElement(v)?v.textContent??void 0:void 0;b&&(!f.detail||Me(f.detail)!==Me(b))&&(m=m+", "+Me(b))}f.group?.title&&(m=m+", "+f.group.title);const _=f.standaloneToggle??f.inlineToggle;return _&&(m=f.standaloneToggle?_.checked?a.localize(1734,"{0}, on",_.label):a.localize(1735,"{0}, off",_.label):m+", "+(_.checked?a.localize(1736,"{0}, on",_.label):a.localize(1737,"{0}, off",_.label))),f.disabled&&(m=a.localize(1738,"{0}, Disabled Reason: {1}",m,f.disabled)),f.submenuActions?.length&&(m=a.localize(1739,"{0}, use right arrow to access options",m)),m}return null},getWidgetAriaLabel:()=>a.localize(1740,"Action Widget"),getSetSize:()=>this._visibleMenuItems.filter(f=>f.kind==="action").length,getPosInSet:(f,m)=>Math.max(this._visibleMenuItems.slice(0,m+1).filter(_=>_.kind==="action").length,1),getRole:f=>{switch(f.kind){case"action":return"option";case"separator":return"separator";default:return"separator"}},getWidgetRole:()=>"listbox",...s}})),this._list.style(o.defaultListStyles),this._register(this._list.onKeyDown(()=>this._setKeyboardNavigation(!0))),this._register(o.addDisposableListener(this._list.getHTMLElement(),o.EventType.MOUSE_MOVE,f=>{(f.movementX!==0||f.movementY!==0)&&this._setKeyboardNavigation(!1)})),this._register(this._list.onMouseClick(f=>this.onListClick(f))),this._register(this._list.onMouseOver(f=>{this._ignoreInitialHover||this.onListHover(f)}));const p=this._register(new a.MutableDisposable);if(p.value=this._list.onMouseMove(f=>{(f.browserEvent.movementX!==0||f.browserEvent.movementY!==0)&&(p.clear(),this._ignoreInitialHover=!1,this.onListHover(f))}),this._register(this._list.onMouseDown(()=>{p.clear(),this._ignoreInitialHover=!1,this._setKeyboardNavigation(!1)})),this._register(this._list.onDidChangeFocus(()=>{this._updateToolbarFocusability(),this.onFocus()})),this._register(this._list.onDidChangeSelection(f=>this.onListSelection(f))),this._register(this._list.onDidScroll(()=>{this._isMeasuringWidth||this._layoutSubmenu?.()})),this._allMenuItems=[...i],this._options?.showFilter||this._options?.secondaryHeading){this._filterContainer=document.createElement("div"),this._filterContainer.className="action-list-filter";const f=o.append(this._filterContainer,o.$(".action-list-filter-row"));if(this._options?.showFilter){if(this._filterInput=document.createElement("input"),this._filterInput.type="text",this._filterInput.className="action-list-filter-input",this._filterInput.placeholder=this._options?.filterPlaceholder??a.localize(1741,"Search..."),this._filterInput.value=this._filterText,this._filterInput.setAttribute("aria-label",a.localize(1742,"Filter items")),f.appendChild(this._filterInput),this._register(o.addDisposableListener(this._filterInput,o.EventType.KEY_DOWN,v=>{if(this._setKeyboardNavigation(!0),v.isComposing||!this._filterInput?.closest(".action-list-submenu-panel"))return;const b=this._keybindingService.softDispatch(new o.StandardKeyboardEvent(v),this._filterInput);(b.kind===2&&b.commandId!==null&&YC.has(b.commandId)||v.key.length===1&&!v.ctrlKey&&!v.metaKey&&!v.altKey)&&v.stopPropagation()})),this._register(o.addDisposableListener(this._filterInput,o.EventType.MOUSE_DOWN,()=>this._setKeyboardNavigation(!1))),this._options.tabThroughItemActions&&this._register(o.addDisposableListener(this._filterInput,"keydown",v=>this._handleTabThroughPanelKeyDown(v),!0)),this._options.filterAsCombobox){const v=this._list.getHTMLElement();v.id=this._list.domId,this._filterInput.setAttribute("role","combobox"),this._filterInput.setAttribute("aria-label",this._filterInput.placeholder),this._filterInput.setAttribute("aria-autocomplete","list"),this._filterInput.setAttribute("aria-expanded","true"),this._filterInput.setAttribute("aria-controls",v.id),this._register(this._list.onDidChangeFocus(()=>this._updateFilterActiveDescendant())),this._register(o.addDisposableListener(this._filterInput,"focus",()=>this._updateFilterActiveDescendant())),this._register(o.addDisposableListener(this._filterInput,"blur",()=>this._updateFilterActiveDescendant())),this._register(o.addStandardDisposableListener(this._filterInput,"keydown",b=>{if(this._imeSessionInProgress||b.browserEvent.isComposing||b.keyCode===114||b.keyCode===15||b.keyCode===17||b.keyCode===14||b.keyCode===13){b.stopPropagation();return}const y=b.keyCode===16||b.keyCode===18;if(!(!y&&b.keyCode!==3)){if(b.ctrlKey||b.metaKey||b.altKey||b.shiftKey){y&&b.stopPropagation();return}o.EventHelper.stop(b,!0),b.keyCode===16?this.focusPrevious():b.keyCode===18?this.focusNext():this.acceptSelected()}}))}const m=this._options?.filterActions??[];if(m.length>0){const v=o.append(f,o.$(".action-list-filter-actions"));this._register(new o.ActionBar(v)).push(m,{icon:!0,label:!1})}const _=()=>{const v=this._filterInput.value;this._imeSessionInProgress||v===this._filterText&&!this._filterCts.value?.token.isCancellationRequested||(this._filterText=v,this._applyOrUpdateFilter())};this._register(o.addDisposableListener(this._filterInput,"compositionstart",()=>{this._imeSessionInProgress=!0,this._filterCts.value?.cancel()})),this._register(o.addDisposableListener(this._filterInput,"compositionend",()=>{this._imeSessionInProgress=!1,_()})),this._register(o.addDisposableListener(this._filterInput,"input",_))}if(this._options?.secondaryHeading){const m=o.append(f,o.$(".action-list-filter-label"));m.textContent=this._options.secondaryHeading}}if(this._options?.footerText&&(this._footerContainer=document.createElement("div"),this._footerContainer.className="action-list-footer",this._footerContainer.textContent=this._options.footerText),this._options?.headerText){if(this._headerContainer=document.createElement("div"),this._headerContainer.className="action-list-header",this._options.headerIcon){const m=o.append(this._headerContainer,o.$("span.action-list-header-icon"));m.classList.add(...o.ThemeIcon.asClassNameArray(this._options.headerIcon)),m.setAttribute("aria-hidden","true")}const f=o.append(this._headerContainer,o.$("span.action-list-header-text"));if(f.textContent=this._options.headerText,this._register(o.addDisposableListener(this._headerContainer,o.EventType.MOUSE_ENTER,()=>{this._options?.persistentHover?(this._cancelSubmenuShow(),this._resetSubmenuPointer()):this._hideSubmenu()})),this._options.headerLink){const{label:m,uri:_}=this._options.headerLink;f.textContent+=" ",this._register(this._instantiationService.createInstance(ea,f,{label:m,href:_.toString(!0)},{}))}if(this._options.headerDismiss){const m=this._options.headerDismiss,_=o.append(this._headerContainer,o.$("span.action-list-header-dismiss"));_.appendChild(o.$(o.ThemeIcon.asCSSSelector(a.Codicon.close))),_.tabIndex=0,_.setAttribute("role","button"),_.setAttribute("aria-label",a.localize(1743,"Dismiss"));const v=()=>{m(),this.focus(),this._headerContainer?.remove(),this._headerContainer=void 0,this._onDidRequestLayout.fire()};this._register(o.addDisposableGenericMouseUpListener(_,()=>v())),this._register(o.addDisposableListener(_,o.EventType.KEY_DOWN,b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),v())}))}}this._applyFilter(),this._list.length&&this._focusCheckedOrFirst(),this._register(o.addDisposableListener(this.domNode,"keydown",f=>{if(f.key==="ArrowRight"&&!f.isComposing){const m=this._list.getFocus();if(m.length>0){const _=this._list.element(m[0]);if(_?.submenuActions?.length||_?.hover?.expandable){o.EventHelper.stop(f,!0);const v=this._getRowElement(m[0]);v&&(this._showSubmenuForElement(_,v),_.hover?.tabThroughPanel?this._focusFirstTabThroughPanelControl(_,v):this._currentSubmenuWidget?this._currentSubmenuWidget.focus():this._submenuContainer.focus())}}}})),this._register(o.addDisposableListener(this.domNode,"keydown",f=>this._handleTabThroughPanelKeyDown(f),!0)),(this._filterInput||this._options?.onType)&&this._register(o.addDisposableListener(this.domNode,"keydown",f=>{const m=f.target;(this._options?.onType||this._options?.filterAsCombobox)&&o.isHTMLElement(m)&&(o.isEditableElement(m)||m.closest('button, a, [contenteditable="true"], .action-list-submenu-panel'))||(!this._filterInput||!o.isActiveElement(this._filterInput))&&!f.isComposing&&f.key.length===1&&f.key!==" "&&!f.ctrlKey&&!f.metaKey&&!f.altKey&&(f.preventDefault(),f.stopPropagation(),this._filterInput?(this._filterInput.focus(),this._filterInput.value=f.key,this._filterText=f.key,this._applyOrUpdateFilter()):this._options?.onType?.(f.key))}))}_toggleSection(e){const t=this._collapsedSections.has(e);if(t)this._collapsedSections.delete(e);else{this._collapsedSections.add(e);const i=this.getFocusedElement();if(i?.section===e&&!i.isSectionToggle){const n=this._visibleMenuItems.findIndex(s=>s.section===e&&s.isSectionToggle);n>=0&&this._list.setFocus([n])}}this._options?.onDidToggleSection?.(e,this._collapsedSections.has(e)),this._applyFilter(),t&&this._revealFirstItemOfSection(e)}_revealFirstItemOfSection(e){for(let t=0;t<this._list.length;t++){const i=this._list.element(t);if(i.section===e&&!i.isSectionToggle){this._list.reveal(t);return}}}_applyOrUpdateFilter(){if(!this._delegate.onFilter){this._applyFilter();return}const e=this._filterText;this._filterCts.value?.cancel();const t=new a.CancellationTokenSource;this._filterCts.value=t,this._delegate.onFilter(e,t.token).then(i=>{t.token.isCancellationRequested||(this._allMenuItems=[...i],this._applyFilter(!0))}).catch(()=>{}).finally(()=>{this._filterCts.value===t&&!t.token.isCancellationRequested&&this._filterCts.clear()})}_applyFilter(e=!1,t=!0,i){this._itemMoveAnimation.clear();const n=e?"":this._filterText.toLowerCase(),s=!e&&n.length>0,r=[],l=this._list.getFocus();let d;if(l.length>0&&(d=this._list.element(l[0])),s){let _,v=[],b=!1;const C=()=>{_&&b&&r.push(_),r.push(...v),_=void 0,v=[],b=!1},y=I=>{const x=(I.label??"").toLowerCase(),S=typeof I.description=="string"?I.description:I.description?.value??"";return x.includes(n)||S.toLowerCase().includes(n)};for(const I of this._allMenuItems)if(I.kind!=="header"){if(I.kind==="separator"){C(),_=I.label?I:void 0;continue}if(I.showAlways){v.push(I);continue}if(!I.isSectionToggle){if(I.filterItems){const x=y(I)?I.filterItems:I.filterItems.filter(y);x.length>0&&(b=!0,v.push(...x));continue}y(I)&&(b=!0,v.push(I))}}C()}else for(const _ of this._allMenuItems){if(_.kind==="header"){r.push(_);continue}if(_.kind==="separator"){if(_.section&&this._collapsedSections.has(_.section))continue;r.push(_);continue}if(_.isSectionToggle&&_.section){const v=this._collapsedSections.has(_.section);r.push({..._,group:{..._.group,icon:v?a.Codicon.chevronRight:a.Codicon.chevronDown}});continue}_.section&&this._collapsedSections.has(_.section)||r.push(_)}const h=[];let u=!1;for(let _=0;_<r.length;_++)h[_]=u,r[_].kind==="action"&&(u=!0);const g=[];let p=!1;for(let _=r.length-1;_>=0;_--){if(r[_].kind==="action"){p=!0;continue}r[_].kind==="separator"&&(g[_]=p,p=!1)}for(let _=r.length-1;_>=0;_--){const v=r[_];if(v.kind!=="separator")continue;const b=g[_],C=!v.label&&!h[_];(!b||C)&&r.splice(_,1)}this._options?.showGroupTitleOnFirstItem&&this._recomputeGroupTitles(r);const f=this._filterInput&&o.isActiveElement(this._filterInput),m=o.isAncestorOfActiveElement(this._list.getHTMLElement());if(this._visibleMenuItems=r,this._list.splice(0,this._list.length,r),t&&this._onDidRequestLayout.fire(),f)this._filterInput?.focus(),this._focusCheckedOrFirst();else if(this._hasLaidOut&&(d||i)){const _=i??d?.item?.id;if(_){for(let v=0;v<this._list.length;v++)if(this._list.element(v).item?.id===_){this._list.setFocus([v]),this._list.reveal(v);break}m&&(this._focusCheckedOrFirst(),this._list.domFocus())}}}get filterContainer(){return this._filterContainer}get footerContainer(){return this._footerContainer}get headerContainer(){return this._headerContainer}get filterInput(){return this._filterInput}get closeAnimation(){return this._options?.closeAnimation}focusCondition(e){return!e.disabled&&e.kind==="action"}_setKeyboardNavigation(e){if(this._keyboardNavigation===e)return;this._keyboardNavigation=e;const t=this._list.getHTMLElement();t.classList.toggle("keyboard-navigation",e===!0),t.classList.toggle("mouse-navigation",e===!1)}_updateFilterActiveDescendant(){if(!this._filterInput)return;const[e]=this._list.getFocus();o.isActiveElement(this._filterInput)&&e!==void 0?this._filterInput.setAttribute("aria-activedescendant",this._list.getElementID(e)):this._filterInput.removeAttribute("aria-activedescendant")}focus(){if(this._setKeyboardNavigation(void 0),this._filterInput&&this._options?.focusFilterOnOpen){this._filterInput.focus(),this._focusCheckedOrFirst();return}this._list.domFocus(),this._focusCheckedOrFirst(),this._showTabThroughPanelForFocusedItem()}clearFocus(){this._list.setFocus([])}getFocusedElement(){const e=this._list.getFocus();if(e.length>0)return this._list.element(e[0])}_updateToolbarFocusability(){if(!this._options?.tabThroughItemActions)return;const[e]=this._list.getFocus(),t=e!==void 0&&e<this._list.length?this._list.element(e):void 0;for(const[i,n]of this._itemToolbars)n.setFocusable(i===t)}_focusCheckedOrFirst(){const e=this._suppressHover;this._suppressHover=!0;try{const t=this._initialFocusItemId;if(this._initialFocusItemId=void 0,t)for(let s=0;s<this._list.length;s++){const r=this._list.element(s);if(this.focusCondition(r)&&r.item?.id===t){this._list.setFocus([s]),this._list.reveal(s);return}}const[i]=this._list.getFocus();if(i!==void 0){const s=this._list.element(i);if(s&&this.focusCondition(s)){this._list.reveal(i);return}}for(let s=0;s<this._list.length;s++){const r=this._list.element(s);if(this.focusCondition(r)&&r.item?.checked){this._list.setFocus([s]),this._list.reveal(s);return}}this._list.focusFirst(void 0,this.focusCondition);const n=this._list.getFocus();n.length>0&&this._list.reveal(n[0])}finally{this._suppressHover=e,this._options?.filterAsCombobox&&this._updateFilterActiveDescendant()}}hide(e){this._delegate.onHide(e),this.cts.cancel(),this._filterCts.value?.cancel(),this._filterCts.clear(),this._hideSubmenu()}clearFilter(){return this._filterInput&&this._filterText?(this._filterInput.value="",this._filterText="",this._applyOrUpdateFilter(),!0):!1}get hasDynamicHeight(){return this._options?.showFilter?!0:this._allMenuItems.some(e=>e.isSectionToggle)}get lineHeight(){return this._actionLineHeight}_getItemHeight(e){return this._itemHeightWith(e,this._options)}_itemHeightWith(e,t){switch(e.kind){case"header":return this._headerLineHeight;case"separator":return e.label?this._actionLineHeight:this._separatorLineHeight;default:return e.inlineToggle?t?.inlineToggleItemHeight??70:e.detail?t?.detailItemHeight??48:this._actionLineHeight}}computeFullHeight(){return this.computeHeightForItems(this._allMenuItems,void 0,this._options)}computeHeightForItems(e,t,i){let n=0;for(const s of e)t&&s.section&&!s.isSectionToggle&&t.has(s.section)||(n+=this._itemHeightWith(s,i));return n}computeListHeight(){const e=this._list.length;let t=0;for(let i=0;i<e;i++){const n=this._list.element(i);t+=this._getItemHeight(n)}return t}layout(e,t){this._hasLaidOut=!0,this._list.layout(e,t),this.domNode.style.height=`${e}px`;const i=this.domNode.parentElement;i&&this._filterContainer?.parentElement===i&&i.insertBefore(this._filterContainer,this.domNode),this._layoutSubmenu?.()}computeMaxWidth(e){const t=this._list.length,i=Math.max(e,this._options?.minWidth??0),n=this._options?.maxWidth??Number.POSITIVE_INFINITY,s=Math.max(n,i),r=u=>Math.min(Math.max(u,i),s),l=this._allMenuItems.length;if(l>=50)return r(380);if(l>t){const u=[];for(let _=0;_<t;_++)u.push(this._list.element(_));const g=this._list.renderHeight,p=this._list.scrollTop,f=this._list.getFocus(),m=this._isMeasuringWidth;this._isMeasuringWidth=!0;try{const _=[...this._allMenuItems];this._list.splice(0,t,_);let v=0;for(const C of _)v+=this._getItemHeight(C);this._list.layout(v);const b=this._measureItemWidths(_);return r(Math.max(...b))}finally{try{this._list.splice(0,this._list.length,u),this._list.layout(g),this._list.scrollTop=p;const _=this._suppressHover;this._suppressHover=!0;try{this._list.setFocus(f)}finally{this._suppressHover=_}}finally{this._isMeasuringWidth=m}}}const d=[];for(let u=0;u<t;u++)d.push(this._list.element(u));const h=this._measureItemWidths(d);return r(Math.max(...h))}focusPrevious(){if(this._setKeyboardNavigation(!0),this._focusFilterResult("previous"))return;if(this._filterInput&&o.isActiveElement(this._filterInput)){this._list.domFocus();const i=this._list.getFocus();if(i.length>0){this._list.focusPrevious(1,!1,void 0,this.focusCondition);const n=this._list.getFocus();n.length>0&&n[0]>=i[0]?this._filterInput.focus():n.length>0&&this._list.reveal(n[0])}else{this._list.focusLast(void 0,this.focusCondition);const n=this._list.getFocus();n.length>0&&this._list.reveal(n[0])}return}const e=this._list.getFocus();this._list.focusPrevious(1,!0,void 0,this.focusCondition);const t=this._list.getFocus();if(t.length>0){if(this._filterInput&&e.length>0&&t[0]>e[0]){this._list.setFocus([]),this._filterInput.focus();return}this._list.reveal(t[0])}}focusNext(){if(this._setKeyboardNavigation(!0),this._focusFilterResult("next"))return;if(this._filterInput&&o.isActiveElement(this._filterInput)){if(this._list.domFocus(),this._list.getFocus().length>0){this._list.focusNext(1,!1,void 0,this.focusCondition);const n=this._list.getFocus();n.length>0&&this._list.reveal(n[0])}else{this._list.focusFirst(void 0,this.focusCondition);const n=this._list.getFocus();n.length>0&&this._list.reveal(n[0])}return}const e=this._list.getFocus();this._list.focusNext(1,!0,void 0,this.focusCondition);const t=this._list.getFocus();if(t.length>0){if(this._filterInput&&e.length>0&&t[0]<e[0]){this._list.setFocus([]),this._filterInput.focus();return}this._list.reveal(t[0])}}_focusFilterResult(e){if(!this._options?.filterAsCombobox||!this._filterInput||!o.isActiveElement(this._filterInput))return!1;e==="previous"?this._list.focusPrevious(1,!0,void 0,this.focusCondition):this._list.focusNext(1,!0,void 0,this.focusCondition);const[t]=this._list.getFocus();return t!==void 0&&this._list.reveal(t),!0}collapseFocusedSection(){const e=this._getFocusedSection();e&&!this._collapsedSections.has(e)&&this._toggleSection(e)}expandFocusedSection(){const e=this._getFocusedSection();e&&this._collapsedSections.has(e)&&this._toggleSection(e)}toggleFocusedSection(){const e=this._list.getFocus();if(e.length===0)return!1;const t=this._list.element(e[0]);return t.isSectionToggle&&t.section?(this._toggleSection(t.section),!0):!1}_getFocusedSection(){const e=this._list.getFocus();if(e.length===0)return;const t=this._list.element(e[0]);return t.isSectionToggle&&t.section,t.section}acceptSelected(e){const t=this._list.getFocus();if(t.length===0)return;const i=t[0],n=this._list.element(i);if(!this.focusCondition(n))return;const s=e?new Bf:new Vf;this._list.setSelection([i],s)}onListSelection(e){if(!e.elements.length)return;const t=e.elements[0];if(t.standaloneToggle){this._list.setSelection([]);const n=this._standaloneToggles.get(t);n&&!n.disabled&&(n.checked=!n.checked,t.standaloneToggle.onChange(n.checked));return}if(t.isSectionToggle&&t.section){this._list.setSelection([]);const n=t.section;queueMicrotask(()=>{this._toggleSection(n)});return}const i=o.isMouseEvent(e.browserEvent)||e.browserEvent?.type===o.EventType$1.Tap;if(i){const n=e.browserEvent.target;if(o.isHTMLElement(n)&&(n.closest(".action-list-item-toolbar")||n.closest(".action-list-submenu-indicator")||n.closest(".action-list-item-inline-toggle"))){this._list.setSelection([]);return}}if(t.openSubmenuOnClick&&t.submenuActions?.length&&(i||e.browserEvent instanceof Vf)){this._list.setSelection([]),this._showSubmenuForItem(t),i||this._currentSubmenuWidget?.focus();return}if(t.item&&this.focusCondition(t)){const n=e.browserEvent instanceof Bf;this._delegate.onSelect(t.item,n&&this._supportsPreview)}else this._list.setSelection([])}onFocus(){const e=this._list.getFocus();if(e.length===0)return;const t=e[0],i=this._list.element(t);this._delegate.onFocus?.(i.item),this._suppressHover||(this._options?.persistentHover&&(this._cancelSubmenuShow(),this._resetSubmenuPointer(),this._list.reveal(t)),this._showHoverForElement(i,t))}_removeItem(e){const t=this._allMenuItems.indexOf(e);t>=0&&(this._allMenuItems.splice(t,1),this._applyFilter())}_recomputeGroupTitles(e){this._groupTitleByIndex.clear();const t=new Set;for(let i=0;i<e.length;i++){const n=e[i];n.kind==="action"&&n.group?.title&&!t.has(n.group.title)&&(t.add(n.group.title),this._groupTitleByIndex.set(i,n.group.title))}}_measureItemWidths(e){const t=[];for(let i=0;i<e.length;i++){const n=this._getRowElement(i);n&&(n.style.width="auto",t.push({element:n,item:e[i]}))}try{return t.map(({element:i,item:n})=>i.getBoundingClientRect().width+(n.detail?0:this._computeToolbarWidth(n)))}finally{for(const{element:i}of t)i.style.width=""}}_computeToolbarWidth(e){let t=e.toolbarActions?.length??0;return e.onRemove&&t++,t===0?0:t*22+6+10}_getRowElement(e){return e<0?null:this.domNode.ownerDocument.getElementById(this._list.getElementID(e))}_showTabThroughPanelForFocusedItem(){const e=this._list.getFocus();if(e.length===0)return;const t=e[0],i=this._list.element(t);if(!i.hover?.tabThroughPanel)return;const n=this._getRowElement(t);n&&this._showSubmenuForElement(i,n)}_getTabThroughPanelControls(e,t){return e.hover?.tabThroughPanel&&this._currentSubmenuElement!==e&&this._showSubmenuForElement(e,t),{toolbar:this._itemToolbars.get(e),panelControls:[...e.hover?.getTabbableElements?.()??[],...this._submenuHoverActionElements]}}_focusFirstTabThroughPanelControl(e,t){const i=this._getTabThroughPanelControls(e,t);i.toolbar?.length()?i.toolbar.focus(0):(i.panelControls[0]??this._list.getHTMLElement()).focus()}_handleTabThroughPanelKeyDown(e){if(e.isComposing)return;const t=this._list.getFocus();if(t.length===0)return;const i=t[0],n=this._list.element(i);if(!n.hover?.tabThroughPanel&&!this._options?.tabThroughItemActions)return;const s=this._getRowElement(i),r=o.getActiveElement();if(!s||!o.isHTMLElement(r))return;const l=this._getTabThroughPanelControls(n,s),d=l.toolbar?.isFocused()??!1,h=this._submenuContainer.contains(r);if((e.key==="ArrowUp"||e.key==="ArrowDown")&&(d||h)){o.EventHelper.stop(e,!0),this._list.domFocus(),e.key==="ArrowUp"?this.focusPrevious():this.focusNext();return}if(e.key!=="Tab"||e.ctrlKey||e.metaKey||e.altKey)return;let u;if(e.shiftKey){if(h){const g=l.panelControls.indexOf(r);if(g>0)u=l.panelControls[g-1];else if(l.toolbar?.length()){o.EventHelper.stop(e,!0),l.toolbar.focus(l.toolbar.length()-1);return}else u=this._list.getHTMLElement()}else if(l.toolbar?.isFocused()){const g=l.toolbar.viewItems.findIndex((p,f)=>l.toolbar?.isFocused(f));if(g>0){o.EventHelper.stop(e,!0),l.toolbar.focus(g-1);return}u=this._options?.filterAsCombobox?this._filterInput:this._list.getHTMLElement()}}else if(r===this._list.getHTMLElement()||r===this._filterInput){if(l.toolbar?.length()){o.EventHelper.stop(e,!0),l.toolbar.focus(0);return}u=l.panelControls[0]}else if(l.toolbar?.isFocused()){const g=l.toolbar.viewItems.findIndex((p,f)=>l.toolbar?.isFocused(f));if(g+1<l.toolbar.length()){o.EventHelper.stop(e,!0),l.toolbar.focus(g+1);return}u=l.panelControls[0]}else{const g=l.panelControls.indexOf(r);g>=0&&(u=l.panelControls[g+1]??this._list.getHTMLElement())}u&&(o.EventHelper.stop(e,!0),u.focus())}_showHoverForElement(e,t){if(this._currentSubmenuElement===e)return;const i=!!e.hover?.content,n=!!e.submenuActions?.length;if(i||n){const s=this._getRowElement(t);s&&this._showSubmenuForElement(e,s);return}this._options?.persistentHover||this._hideSubmenu()}_showSubmenuForItem(e){const t=this._list.indexOf(e);if(t>=0){const i=this._getRowElement(t);i&&this._showSubmenuForElement(e,i)}}_showSubmenuForElement(e,t){if(!this._hoverEnabled||this._currentSubmenuElement===e)return;this._currentSubmenuElement=e,this._clearSubmenuContainer(),t.setAttribute("aria-expanded","true"),this._expandedTrigger=t,this._submenuPanelClassName=e.hover?.panelClassName,this._submenuPanelClassName&&this._submenuContainer.classList.add(this._submenuPanelClassName);const i=e.hover?.preserveVerticalPosition,n=!!e.submenuActions?.length,s=i?o.$(".action-list-submenu-content"):this._submenuContainer,r=i?o.$(".action-list-submenu-viewport",void 0,s):void 0,l=r&&!n?this._submenuDisposables.add(new o.DomScrollableElement(r,{horizontal:2,vertical:1,consumeMouseWheelIfScrollbarIsNeeded:!0,useShadows:!1})):void 0;l&&r?(this._submenuContainer.appendChild(l.getDomNode()),this._submenuDisposables.add(o.addDisposableListener(r,o.EventType.SCROLL,()=>l.scanDomNode())),this._submenuDisposables.add(o.addDisposableListener(this._submenuContainer,o.EventType.KEY_DOWN,b=>{const C=new o.StandardKeyboardEvent(b);(C.equals(12)||C.equals(11))&&(o.EventHelper.stop(b,!0),l.setScrollPosition({scrollTop:l.getScrollPosition().scrollTop+(C.equals(12)?1:-1)*r.clientHeight}))}))):r&&this._submenuContainer.appendChild(r);let d;const h=typeof e.hover?.content=="function"?e.hover.content():e.hover?.content;if(h){if(o.isHTMLElement(h))d=h,e.hover?.disposable&&this._register(e.hover.disposable);else{const b=typeof h=="string"?new o.MarkdownString(h):h,C=this._options?.linkHandler,y=o.renderMarkdown(b,{actionHandler:I=>{const x=a.URI.parse(I);C?C(x,e):this._openerService.open(x,{allowCommands:!0})}});this._submenuDisposables.add(y),d=y.element}d.classList.add("action-list-submenu-hover-header"),d.classList.toggle("content-owns-padding",e.hover?.contentOwnsPadding===!0),e.submenuActions?.length&&d.classList.add("has-submenu"),s.appendChild(d)}if(e.hover?.actions?.length){const b=o.$(".hover-row.status-bar"),C=o.append(b,o.$(".actions"));for(const y of e.hover.actions){const I=this._keybindingService.lookupKeybinding(y.commandId),x=this._submenuDisposables.add(o.HoverAction.render(C,{label:y.label,commandId:y.commandId,run:S=>y.run(S),iconClass:y.iconClass},I?.getLabel()??null));this._submenuHoverActionElements.push(x.actionContainer)}this._submenuContainer.appendChild(b)}this._submenuContainer.style.display="",this._submenuContainer.style.position="absolute",e.hover?.expandable?(this._submenuContainer.setAttribute("role","dialog"),e.label&&this._submenuContainer.setAttribute("aria-label",e.label)):this._submenuContainer.removeAttribute("role");const u=o.getWindow(this.domNode);let g=0,p=d?d.offsetWidth:0,f;if(n){const b=this._createSubmenuItems(e.submenuActions),C={onHide:()=>{},onSelect:x=>{x.run();const S=this._currentSubmenuElement?.item;this._hideSubmenu(),S&&this._delegate.onSelect(S),this.hide()}},y=this._submenuDisposables.add(this._instantiationService.createInstance(Ld,"submenu",!1,b,C,void 0,e.submenuOptions));f=y,y.headerContainer&&s.appendChild(y.headerContainer),y.filterContainer&&s.appendChild(y.filterContainer),s.appendChild(y.domNode),y.footerContainer&&s.appendChild(y.footerContainer),this._currentSubmenuWidget=y,y.clearFocus(),g=y.computeListHeight(),y.layout(g);const I=y.computeMaxWidth(0);p=Math.max(p,I,y.footerContainer?.offsetWidth??0),y.layout(g,p),y.domNode.style.width=`${p}px`,e.submenuOptions&&(this._submenuContainer.style.boxSizing="border-box",this._submenuContainer.style.width=`${p+10}px`),this._submenuDisposables.add(y.onDidRequestLayout(()=>{g=y.computeListHeight(),y.layout(g,p),this._layoutSubmenu?.()})),this._submenuDisposables.add(o.addDisposableListener(s,"keydown",x=>{x.key==="Escape"?(o.EventHelper.stop(x,!0),this._hideSubmenu(),this.hide()):x.key==="ArrowLeft"?(o.EventHelper.stop(x,!0),this._hideSubmenu(),this._setKeyboardNavigation(!0),this._list.domFocus()):x.key==="Enter"||x.key===" "?(o.EventHelper.stop(x,!0),y.acceptSelected()):x.key==="ArrowDown"?(o.EventHelper.stop(x,!0),y.focusNext()):x.key==="ArrowUp"&&(o.EventHelper.stop(x,!0),y.focusPrevious())}))}let m,_;const v=()=>{const b=this._currentSubmenuElement;if(!b||this._layoutSubmenu!==v)return;const C=this._list.indexOf(b),y=C>=0?this._getRowElement(C):null,I=this._options?.persistentHover;if(!y&&(!I||!this._allMenuItems.includes(b))){this._hideSubmenu();return}this._expandedTrigger!==y&&(this._expandedTrigger?.hasAttribute("aria-expanded")&&this._expandedTrigger.setAttribute("aria-expanded","false"),this._expandedTrigger=y??void 0),y?.setAttribute("aria-expanded","true");const x=this.domNode.getBoundingClientRect(),S=I||b.hover?.alignToParent,w=S?this.domNode.parentElement?.closest(".action-widget")?.getBoundingClientRect()??x:x,E=y?.getBoundingClientRect()??w,L=S||i?o.getDomNodeZoomLevel(this.domNode):1;I&&(this._submenuContainer.style.width=`${w.width/L}px`);const R=this._submenuContainer.getBoundingClientRect();let D=S?R.width:p+10;const T=u.innerWidth-(S?w.right:E.right),P=w.left,M=S?0:4,V=4;if(!S){const W=u.innerWidth-2*V;D>W&&(D=Math.max(W,0)),this._submenuContainer.style.boxSizing="border-box",this._submenuContainer.style.width=`${D}px`}let F=T>=D||T>=P;I&&this._submenuSide&&(this._submenuSide==="right"?T:P)>=D&&(F=this._submenuSide==="right"),I&&(this._submenuSide=F?"right":"left");let K=F?w.right-x.left+M:w.left-x.left-D-M;const O=x.left+K;O<V?K+=V-O:O+D>u.innerWidth-V&&(K-=O+D-(u.innerWidth-V)),this._submenuContainer.style.left=`${K/L}px`;const z=R.height;i&&(m??=z/L);const Q=m!==void 0?m*L:z;let j=_!==void 0?_*L:y&&b.hover?.alignToAnchorTop?E.top-x.top:y?E.top-x.top+(E.height-Q)/2:R.top-x.top;if(i&&b.hover?.alignToAnchorTop&&r&&f){const W=R.height-r.getBoundingClientRect().height,Y=(f.headerContainer?.offsetHeight??0)+(f.filterContainer?.offsetHeight??0)+(f.footerContainer?.offsetHeight??0),G=W+(Y+g)*L;j=Math.min(j,u.innerHeight-x.top-G-8)}const U=x.top+j+Q;if(U>u.innerHeight&&!(i&&b.hover?.alignToAnchorTop)&&(j-=U-u.innerHeight+8),x.top+j<0&&(j=-x.top),i&&(_??=j/L),r&&l){const W=(R.height-l.getDomNode().getBoundingClientRect().height)/L,Y=Math.max(0,(u.innerHeight-x.top-j-8)/L-W);r.style.height=`${Math.min(s.getBoundingClientRect().height/L,Y)}px`,l.scanDomNode()}else if(r&&f){const W=(R.height-r.getBoundingClientRect().height)/L,Y=Math.max(0,(u.innerHeight-x.top-j-8)/L-W),G=(f.headerContainer?.offsetHeight??0)+(f.filterContainer?.offsetHeight??0)+(f.footerContainer?.offsetHeight??0),ae=g===0?0:Math.max(this._actionLineHeight,Math.min(g,Y-G));f.layout(ae,p),r.style.height=`${G+ae}px`}this._submenuContainer.style.top=`${j/L}px`};if(this._layoutSubmenu=v,v(),(this._options?.persistentHover||e.hover?.alignToParent||e.hover?.tabThroughPanel||i)&&this._currentSubmenuElement===e){if(!f){const b=this._submenuDisposables.add(new a.MutableDisposable),C=this._submenuDisposables.add(new o.DisposableResizeObserver("ActionListWidget.hoverPanel",()=>{b.value||(b.value=o.scheduleAtNextAnimationFrame(u,()=>{b.clear(),v()}))},u));this._submenuDisposables.add(C.observe(i?s:this._submenuContainer,{box:"border-box"}))}(this._options?.persistentHover||i)&&this._submenuDisposables.add(o.addDisposableListener(u,o.EventType.RESIZE,()=>{this._cancelSubmenuShow(),this._resetSubmenuPointer(),v()}))}}_createSubmenuItems(e){const t=[],n=e.filter(s=>s instanceof o.SubmenuAction).filter(s=>s.actions.length>0);for(let s=0;s<n.length;s++){const r=n[s];r.label&&t.push({kind:"header",group:{title:r.label},label:r.label});for(const l of r.actions){const d=l,h=d.icon??o.ThemeIcon.fromId(l.checked?a.Codicon.check.id:a.Codicon.blank.id),u=d.hoverContent,g=u?new o.MarkdownString().appendText(`${l.label}
3
+ `).appendMarkdown(u):void 0;t.push({item:l,kind:"action",label:l.label,description:l.tooltip&&l.tooltip!==l.label?l.tooltip:void 0,group:{title:"",icon:h},hideIcon:!1,hover:g?{content:g}:void 0,tooltip:l.tooltip||l.label,onRemove:d.onRemove,submenuActions:l instanceof o.SubmenuAction?[new o.SubmenuAction(l.id,"",l.actions)]:void 0})}s<n.length-1&&t.push({kind:"separator",label:""})}for(const s of e)if(!(s instanceof o.SubmenuAction)){const r=s,l=r.icon??o.ThemeIcon.fromId(s.checked?a.Codicon.check.id:a.Codicon.blank.id),d=r.hoverContent,h=d?new o.MarkdownString().appendText(`${s.label}
4
+ `).appendMarkdown(d):void 0;t.push({item:s,kind:"action",label:s.label,description:s.tooltip&&s.tooltip!==s.label?s.tooltip:void 0,group:{title:"",icon:l},hideIcon:!1,hover:h?{content:h}:void 0,tooltip:s.tooltip||s.label,onRemove:r.onRemove})}return t}_hideSubmenu(){this._cancelSubmenuHide(),this._cancelSubmenuShow(),this._currentSubmenuElement=void 0,this._submenuSide=void 0,this._clearSubmenuContainer(),this._submenuContainer.style.display="none"}_clearSubmenuContainer(){this._layoutSubmenu=void 0,this._resetSubmenuPointer(),this._submenuContainer.contains(o.getActiveElement())&&this._list.domFocus(),this._submenuDisposables.clear(),this._currentSubmenuWidget=void 0,this._submenuHoverActionElements=[],this._submenuPanelClassName&&(this._submenuContainer.classList.remove(this._submenuPanelClassName),this._submenuPanelClassName=void 0),this._submenuContainer.removeAttribute("role"),this._submenuContainer.removeAttribute("aria-label"),this._expandedTrigger?.hasAttribute("aria-expanded")&&this._expandedTrigger.setAttribute("aria-expanded","false"),this._expandedTrigger=void 0,o.clearNode(this._submenuContainer),this._submenuContainer.style.width="",this._submenuContainer.style.boxSizing=this._options?.persistentHover?"border-box":""}_scheduleSubmenuHide(){this._cancelSubmenuHide(),!this._options?.persistentHover&&(this._submenuHideTimeout=setTimeout(()=>{this._hideSubmenu()},300))}_cancelSubmenuHide(){this._submenuHideTimeout!==void 0&&(clearTimeout(this._submenuHideTimeout),this._submenuHideTimeout=void 0)}_scheduleSubmenuShow(e,t){this._cancelSubmenuShow();let i=this._options?.submenuHoverDelay??500;if(this._usesSubmenuPointerIntent()){i=0;const s=this._submenuPointerOrigin;if(s&&t.clientX!==s.x&&this._currentSubmenuElement&&new o.SafeTriangle(s.x,s.y,this._submenuContainer).contains(t.clientX,t.clientY)){const r=Date.now();this._submenuPointerGraceDeadline??=r+200,i=Math.max(0,this._submenuPointerGraceDeadline-r)}}const n=()=>{this._submenuShowTimeout=void 0;const s=this._list.indexOf(e),r=s>=0?this._getRowElement(s):null;r&&(this._showSubmenuForElement(e,r),this._usesSubmenuPointerIntent()&&this._updateSubmenuPointer(t))};i===0?n():this._submenuShowTimeout=setTimeout(n,i)}_updateSubmenuPointer(e){this._submenuPointerOrigin={x:e.clientX,y:e.clientY},this._submenuPointerGraceDeadline=void 0}_resetSubmenuPointer(){this._submenuPointerOrigin=void 0,this._submenuPointerGraceDeadline=void 0}_usesSubmenuPointerIntent(){return this._options?.persistentHover===!0||this._options?.submenuPointerIntent===!0}_cancelSubmenuShow(){this._submenuShowTimeout!==void 0&&(clearTimeout(this._submenuShowTimeout),this._submenuShowTimeout=void 0)}async onListHover(e){this._setKeyboardNavigation(!1);const t=e.element;if(t&&t.item&&this.focusCondition(t)){const i=typeof e.index=="number"?[e.index]:[],n=o.getActiveElement();if(this._options?.tabThroughItemActions&&this._list.getFocus()[0]!==e.index&&o.isHTMLElement(n)&&this.domNode.contains(n)&&n.closest(".action-list-item-toolbar")&&this._list.domFocus(),o.isHTMLElement(e.browserEvent.target)&&e.browserEvent.target.closest(".action-list-item-toolbar")!==null){t.submenuActions?.length||this._cancelSubmenuShow(),this._list.setFocus(this._options?.tabThroughItemActions?i:[]);return}const r=!!(t.submenuActions?.length||t.hover?.content),l=this._suppressHover;(r||this._usesSubmenuPointerIntent())&&(this._suppressHover=!0);try{this._list.setFocus(i)}finally{this._suppressHover=l}if(r){this._currentSubmenuElement===t?(this._cancelSubmenuHide(),this._cancelSubmenuShow(),this._usesSubmenuPointerIntent()&&this._updateSubmenuPointer(e.browserEvent)):(this._usesSubmenuPointerIntent()||this._hideSubmenu(),this._scheduleSubmenuShow(t,e.browserEvent));return}if(this._currentSubmenuElement===t?this._cancelSubmenuHide():(this._cancelSubmenuShow(),this._options?.submenuPointerIntent?this._scheduleSubmenuHide():this._options?.persistentHover||this._hideSubmenu()),this._delegate.onHover&&!t.disabled&&t.kind==="action"&&this._currentSubmenuElement!==t){const d=await this._delegate.onHover(t.item,this.cts.token),h=d?d.canPreview:void 0;h!==t.canPreview&&(t.canPreview=h,typeof e.index=="number"&&(this._list.splice(e.index,1,[t]),this._list.setFocus([e.index])))}}else t&&t.hover?.content&&typeof e.index=="number"&&(this._currentSubmenuElement===t?(this._cancelSubmenuHide(),this._cancelSubmenuShow()):(this._options?.persistentHover||this._hideSubmenu(),this._scheduleSubmenuShow(t,e.browserEvent)))}onListClick(e){e.element&&this.focusCondition(e.element)&&this._list.setFocus([])}};Nd=Ld=Ed([kt(6,o.IKeybindingService),kt(7,o.IOpenerService),kt(8,o.IInstantiationService)],Nd);let Md=class extends a.Disposable{get domNode(){return this._widget.domNode}get filterContainer(){return this._widget.filterContainer}get footerContainer(){return this._widget.footerContainer}get headerContainer(){return this._widget.headerContainer}get filterInput(){return this._widget.filterInput}get closeAnimation(){return this._widget.closeAnimation}get widgetClassName(){return this._widgetClassName}get anchorPosition(){if(this._preferredAnchorPosition!==void 0)return this._preferredAnchorPosition;if(this._showAbove!==void 0)return this._showAbove?1:0}constructor(e,t,i,n,s,r,l,d,h,u){super(),this._contextViewService=d,this._layoutService=h,this._lastMinWidth=0,this._hasLaidOut=!1,this._anchor=l,this._preferredAnchorPosition=r?.anchorPosition,this._useFullHeight=r?.useFullHeight??!1,this._widgetClassName=r?.widgetClassName,this._widget=this._register(u.createInstance(Nd,e,t,i,n,s,r)),this._register(this._widget.onDidRequestLayout(()=>{this._hasLaidOut&&(this.layout(this._lastMinWidth),this._contextViewService.layout())}))}focus(){this._widget.focus()}hide(e,t=!0){this._widget.hide(e),t&&this._contextViewService.hideContextView()}clearFilter(){return this._widget.clearFilter()}focusPrevious(){this._widget.focusPrevious()}focusNext(){this._widget.focusNext()}collapseFocusedSection(){this._widget.collapseFocusedSection()}expandFocusedSection(){this._widget.expandFocusedSection()}toggleFocusedSection(){return this._widget.toggleFocusedSection()}acceptSelected(e){this._widget.acceptSelected(e)}hasDynamicHeight(){return this._widget.hasDynamicHeight}computeActionWidgetVerticalChromeHeight(){const e=this.domNode.parentElement?.closest(".action-widget");if(!e)return 0;const t=o.getWindow(e).getComputedStyle(e),i=n=>Number.parseFloat(n)||0;return i(t.paddingTop)+i(t.paddingBottom)+i(t.borderTopWidth)+i(t.borderBottomWidth)}computeHeight(){const e=this._fixedContentHeight??this._widget.computeListHeight(),t=this._widget.filterContainer?36:0,i=this._widget.footerContainer?32:0,n=this._widget.headerContainer&&!this._widget.headerContainer.hidden?this._widget.headerContainer.offsetHeight||36:0,s=t+i+n,r=o.getWindow(this.domNode);let l;if(this.hasDynamicHeight()||this._preferredAnchorPosition!==void 0){const p=r.innerHeight,f=o.getAnchorRect(this._anchor),m=f.top-r.pageYOffset,v=p-m-f.height-30,b=m;if(this._showAbove===void 0){const C=this._fixedContentHeight??this._widget.computeFullHeight();this._showAbove=this._preferredAnchorPosition!==void 0?this._preferredAnchorPosition===1:s+C>v&&b>v}l=Math.max(0,(this._showAbove?b:v)-this.computeActionWidgetVerticalChromeHeight())}else{const f=this._layoutService.getContainer(r).clientHeight,m=this.domNode.getBoundingClientRect().top;l=m>0?f-m-10:f*.7}const d=this._useFullHeight?r.innerHeight:Math.floor(r.innerHeight*.6),h=this._widget.lineHeight;if(this._preferredAnchorPosition!==void 0){const p=Math.min(l,d),f=Math.min(e+s,Math.max(0,p));return Math.max(0,f-s)}const u=Math.min(Math.max(l,h*3+s),d);return Math.min(e+s,u)-s}layout(e,t){this._hasLaidOut=!0,this._lastMinWidth=e,t!==void 0&&(this._fixedContentHeight=t);const i=this.computeHeight();this._widget.layout(i);const n=this._widget.computeMaxWidth(e);return this._cachedMaxWidth=n,this._widget.layout(i,this._cachedMaxWidth),this._cachedMaxWidth}};Md=Ed([kt(7,o.IContextViewService),kt(8,o.ILayoutService),kt(9,o.IInstantiationService)],Md);function Me(c){return c.replace(/\r\n|\r|\n/g," ")}var eS=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Pd=function(c,e){return function(t,i){e(t,i,c)}};o.registerColor("actionBar.toggledBackground",o.inputActiveOptionBackground,a.localize(1744,"Background color for toggled action items in action bar."));const Kf="--action-widget-close-start-opacity",kf="--action-widget-close-start-transform",ge={Visible:new o.RawContextKey("codeActionMenuVisible",!1,a.localize(1745,"Whether the action widget list is visible")),FilterFocused:new o.RawContextKey("codeActionMenuFilterFocused",!1,a.localize(1746,"Whether the action widget filter input is focused"))},Pe=o.createDecorator("actionWidgetService");let Ge=class extends a.Disposable{get isVisible(){return ge.Visible.getValue(this._contextKeyService)||!1}constructor(e,t,i){super(),this._contextViewService=e,this._contextKeyService=t,this._instantiationService=i,this._list=this._register(new a.MutableDisposable),this._closeAnimation=this._register(new a.MutableDisposable)}show(e,t,i,n,s,r,l,d,h){const u=ge.Visible.bindTo(this._contextKeyService),g=this._instantiationService.createInstance(Md,e,t,i,n,d,h,s);this._contextViewService.showContextView({getAnchor:()=>s,render:p=>(u.set(!0),this._renderWidget(p,g,l??[],h)),onHide:p=>{u.reset(),this._onWidgetClosed(p)},get anchorPosition(){return g.anchorPosition},focus:()=>g.focus()},r,!1)}acceptSelected(e){this._list.value?.acceptSelected(e)}focusPrevious(){this._list?.value?.focusPrevious()}focusNext(){this._list?.value?.focusNext()}collapseSection(){this._list?.value?.collapseFocusedSection()}expandSection(){this._list?.value?.expandFocusedSection()}toggleSection(){return this._list?.value?.toggleFocusedSection()??!1}clearFilter(){return this._list?.value?.clearFilter()??!1}hide(e){const t=this._list.value,i=this._widgetElement;if(!t||this._closingList===t)return;const n=t.closeAnimation;if(!i||!n||n.duration<=0||!this._hasRequiredAncestorClasses(i,n.requiredAncestorClasses)){this._closingList=t,t.hide(e);return}this._closingList=t;const s=o.getWindow(i).getComputedStyle(i);i.style.setProperty(Kf,s.opacity),i.style.setProperty(kf,s.transform),i.classList.add(n.className),t.hide(e,!1),this._closeAnimation.value=a.disposableTimeout(()=>{this._list.value===t&&this._contextViewService.hideContextView(e)},n.duration)}clear(){this._closeAnimation.clear(),this._closingList=void 0,this._widgetElement?.style.removeProperty(Kf),this._widgetElement?.style.removeProperty(kf),this._widgetElement=void 0,this._list.clear()}_renderWidget(e,t,i,n){const s=document.createElement("div");s.classList.add("action-widget");const r=t.widgetClassName?.split(/\s+/).filter(Boolean);if(r?.length&&s.classList.add(...r),e.appendChild(s),this._widgetElement=s,this._list.value=t,this._list.value)this._list.value.headerContainer&&s.appendChild(this._list.value.headerContainer),this._list.value.filterContainer&&s.appendChild(this._list.value.filterContainer),s.appendChild(this._list.value.domNode),this._list.value.footerContainer&&s.appendChild(this._list.value.footerContainer);else throw new Error("List has no value");const l=new a.DisposableStore;n?.filterAsCombobox&&l.add(o.addStandardDisposableListener(s,"keydown",b=>{b.keyCode===9&&!b.browserEvent.isComposing&&(o.EventHelper.stop(b,!0),this.hide(!0))}));const d=this._list.value.headerContainer;d&&l.add(o.addDisposableGenericMouseDownListener(d,b=>b.preventDefault()));let h=0;l.add(o.addDisposableGenericMouseDownListener(s,()=>{h=Date.now()+1e3}));const u=document.createElement("div"),g=e.appendChild(u);g.classList.add("context-view-block"),l.add(o.addDisposableGenericMouseDownListener(g,b=>b.stopPropagation()));let p=0;if(i.length){const b=this._createActionBar(".action-widget-action-bar",i);b&&(s.appendChild(b.getContainer().parentElement),l.add(b),p=b.getContainer().offsetWidth)}const f=this._list.value?.layout(p);s.style.width=`${f}px`;const m=ge.FilterFocused.bindTo(this._contextKeyService);if(l.add({dispose:()=>m.reset()}),this._list.value?.filterInput){const b=this._list.value.filterInput;l.add(o.addDisposableListener(b,"focus",()=>m.set(!0))),l.add(o.addDisposableListener(b,"blur",()=>m.set(!1)))}const _=l.add(o.trackFocus(e)),v=l.add(new a.MutableDisposable);return l.add(_.onDidFocus(()=>v.clear())),l.add(_.onDidBlur(()=>{const b=()=>{const C=h-Date.now();if(C>0){v.value=a.disposableTimeout(b,C);return}const y=o.getActiveElement();y&&(e.contains(y)||y.closest(".action-widget-hover")||y.closest(".action-list-submenu-panel"))||this.hide(!0)};v.value=a.disposableTimeout(b,75)})),l}_createActionBar(e,t){if(!t.length)return;const i=o.$(e),n=new o.ActionBar(i);return n.push(t,{icon:!1,label:!0}),n}_hasRequiredAncestorClasses(e,t){if(!t?.length)return!0;for(let i=e;i;i=i.parentElement)if(t.every(n=>i.classList.contains(n)))return!0;return!1}_onWidgetClosed(e){if(this._closingList===this._list.value){this.clear();return}this._closeAnimation.clear(),this._closingList=void 0,this._widgetElement=void 0,this._list.value?.hide(e)}};Ge=eS([Pd(0,o.IContextViewService),Pd(1,o.IContextKeyService),Pd(2,o.IInstantiationService)],Ge),o.registerSingleton(Pe,Ge,1);const wt=1100;o.registerAction2(class extends o.Action2{constructor(){super({id:"hideCodeActionWidget",title:a.localize2(1747,"Hide action widget"),precondition:ge.Visible,keybinding:{weight:wt,primary:9,secondary:[1033]}})}run(c){c.get(Pe).hide(!0)}}),o.registerAction2(class extends o.Action2{constructor(){super({id:"clearFilterCodeActionWidget",title:a.localize2(1748,"Clear action widget filter"),precondition:o.ContextKeyExpr.and(ge.Visible,ge.FilterFocused),keybinding:{weight:wt+1,primary:9}})}run(c){const e=c.get(Pe);e instanceof Ge&&(e.clearFilter()||e.hide(!0))}}),o.registerAction2(class extends o.Action2{constructor(){super({id:"selectPrevCodeAction",title:a.localize2(1749,"Select previous action"),precondition:ge.Visible,keybinding:{weight:wt,primary:16,secondary:[2064],mac:{primary:16,secondary:[2064,302]}}})}run(c){const e=c.get(Pe);e instanceof Ge&&e.focusPrevious()}}),o.registerAction2(class extends o.Action2{constructor(){super({id:"selectNextCodeAction",title:a.localize2(1750,"Select next action"),precondition:ge.Visible,keybinding:{weight:wt,primary:18,secondary:[2066],mac:{primary:18,secondary:[2066,300]}}})}run(c){const e=c.get(Pe);e instanceof Ge&&e.focusNext()}}),o.registerAction2(class extends o.Action2{constructor(){super({id:"collapseSectionCodeAction",title:a.localize2(1751,"Collapse section"),precondition:o.ContextKeyExpr.and(ge.Visible,ge.FilterFocused.negate()),keybinding:{weight:wt,primary:15}})}run(c){const e=c.get(Pe);e instanceof Ge&&e.collapseSection()}}),o.registerAction2(class extends o.Action2{constructor(){super({id:"expandSectionCodeAction",title:a.localize2(1752,"Expand section"),precondition:o.ContextKeyExpr.and(ge.Visible,ge.FilterFocused.negate()),keybinding:{weight:wt,primary:17}})}run(c){const e=c.get(Pe);e instanceof Ge&&e.expandSection()}}),o.registerAction2(class extends o.Action2{constructor(){super({id:"toggleSectionCodeAction",title:a.localize2(1753,"Toggle section"),precondition:o.ContextKeyExpr.and(ge.Visible,ge.FilterFocused.negate()),keybinding:{weight:wt,primary:10}})}run(c){const e=c.get(Pe);e instanceof Ge&&(e.toggleSection()||e.acceptSelected())}}),o.registerAction2(class extends o.Action2{constructor(){super({id:Dd,title:a.localize2(1754,"Accept selected action"),precondition:ge.Visible,keybinding:{weight:wt,primary:3,secondary:[2137]}})}run(c){const e=c.get(Pe);e instanceof Ge&&e.acceptSelected()}}),o.registerAction2(class extends o.Action2{constructor(){super({id:Rd,title:a.localize2(1755,"Preview selected action"),precondition:ge.Visible,keybinding:{weight:wt,primary:2051}})}run(c){const e=c.get(Pe);e instanceof Ge&&e.acceptSelected(!0)}});var Uf=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},ls=function(c,e){return function(t,i){e(t,i,c)}},Od;let Ad=(bn=class extends a.Disposable{constructor(e,t,i,n,s,r,l,d,h,u,g){super(),this.typeId=e,this.editor=t,this.showCommand=n,this.range=s,this.edits=r,this.onSelectNewEdit=l,this.additionalActions=d,this._keybindingService=u,this._actionWidgetService=g,this.allowEditorOverflow=!0,this.suppressMouseDown=!0,this.create(),this.visibleContext=i.bindTo(h),this.visibleContext.set(!0),this._register(a.toDisposable(()=>this.visibleContext.reset())),this.editor.addContentWidget(this),this.editor.layoutContentWidget(this),this._register(a.toDisposable((()=>this.editor.removeContentWidget(this)))),this._register(this.editor.onDidChangeCursorPosition(p=>{this.dispose()})),this._register(a.Event.runAndSubscribe(u.onDidUpdateKeybindings,()=>{this._updateButtonTitle()}))}_updateButtonTitle(){this.button.element.title=this._keybindingService.appendKeybinding(this.showCommand.label,this.showCommand.id)}create(){this.domNode=o.$(".post-edit-widget"),this.button=this._register(new o.Button(this.domNode,{supportIcons:!0})),this.button.label="$(insert)",this._register(o.addDisposableListener(this.domNode,o.EventType.CLICK,()=>this.showSelector()))}getId(){return Od.baseId+"."+this.typeId}getDomNode(){return this.domNode}getPosition(){return{position:this.range.getEndPosition(),preference:[2]}}showSelector(){const e=o.getDomNodePagePosition(this.button.element),t={x:e.left+e.width,y:e.top+e.height};this._actionWidgetService.show("postEditWidget",!1,this.edits.allEdits.map((i,n)=>({kind:"action",item:i,label:i.title,disabled:!1,canPreview:!1,group:{title:"",icon:o.ThemeIcon.fromId(n===this.edits.activeEditIndex?a.Codicon.check.id:a.Codicon.blank.id)}})),{onHide:()=>{this.editor.focus()},onSelect:i=>{this._actionWidgetService.hide(!1);const n=this.edits.allEdits.findIndex(s=>s===i);if(n!==this.edits.activeEditIndex)return this.onSelectNewEdit(n)}},t,this.editor.getDomNode()??void 0,this.additionalActions)}},Od=bn,bn.baseId="editor.widget.postEditWidget",bn);Ad=Od=Uf([ls(8,o.IContextKeyService),ls(9,o.IKeybindingService),ls(10,Pe)],Ad);let ta=class extends a.Disposable{constructor(e,t,i,n,s,r,l,d){super(),this._id=e,this._editor=t,this._visibleContext=i,this._showCommand=n,this._getAdditionalActions=s,this._instantiationService=r,this._bulkEditService=l,this._notificationService=d,this._currentWidget=this._register(new a.MutableDisposable),this._register(a.Event.any(t.onDidChangeModel,t.onDidChangeModelContent)(()=>this.clear()))}async applyEditAndShowIfNeeded(e,t,i,n,s){if(!e.length||!this._editor.hasModel())return;const r=this._editor.getModel(),l=t.allEdits.at(t.activeEditIndex);if(!l)return;const d=async b=>{const C=this._editor.getModel();C&&(await C.undo(),this.applyEditAndShowIfNeeded(e,{activeEditIndex:b,allEdits:t.allEdits},i,n,s))},h=(b,C)=>{a.isCancellationError(b)||(this._notificationService.error(C),i&&this.show(e[0],t,d))},u=new o.EditorStateCancellationTokenSource(this._editor,3,void 0,s);let g;try{g=await a.raceCancellationError(n(l,u.token),u.token)}catch(b){return h(b,a.localize(991,`Error resolving edit '{0}':
5
+ {1}`,l.title,Hr(b)))}finally{u.dispose()}if(s.isCancellationRequested)return;const p=Nf(r.uri,e,g),f=e[0],m=r.deltaDecorations([],[{range:f,options:{description:"paste-line-suffix",stickiness:0}}]);this._editor.focus();let _,v;try{_=await this._bulkEditService.apply(p,{editor:this._editor,token:s}),v=r.getDecorationRange(m[0])}catch(b){return h(b,a.localize(992,`Error applying edit '{0}':
6
+ {1}`,l.title,Hr(b)))}finally{r.deltaDecorations(m,[])}s.isCancellationRequested||i&&_.isApplied&&t.allEdits.length>1&&this.show(v??f,t,d)}show(e,t,i){this.clear(),this._editor.hasModel()&&(this._currentWidget.value=this._instantiationService.createInstance(Ad,this._id,this._editor,this._visibleContext,this._showCommand,e,t,i,this._getAdditionalActions()))}clear(){this._currentWidget.clear()}tryShowSelector(){this._currentWidget.value?.showSelector()}};ta=Uf([ls(5,o.IInstantiationService),ls(6,o.IBulkEditService),ls(7,o.INotificationService)],ta);var tS=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},It=function(c,e){return function(t,i){e(t,i,c)}},Oe;const $f="editor.changePasteType",iS="editor.pasteAs.preferences",Fd=new o.RawContextKey("pasteWidgetVisible",!1,a.localize(971,"Whether the paste widget is showing")),zd="application/vnd.code.copymetadata";let xt=(Cn=class extends a.Disposable{static get(e){return e.getContribution(Oe.ID)}constructor(e,t,i,n,s,r,l,d,h,u){super(),this._logService=i,this._bulkEditService=n,this._clipboardService=s,this._commandService=r,this._configService=l,this._languageFeaturesService=d,this._quickInputService=h,this._progressService=u,this._editor=e,this._register(e.onWillCopy(g=>this.handleCopy(g))),this._register(e.onWillCut(g=>this.handleCopy(g))),this._register(e.onWillPaste(g=>this.handlePaste(g))),this._pasteProgressManager=this._register(new Qr("pasteIntoEditor",e,t)),this._postPasteWidgetManager=this._register(t.createInstance(ta,"pasteIntoEditor",e,Fd,{id:$f,label:a.localize(972,"Show paste options...")},()=>Oe._configureDefaultAction?[Oe._configureDefaultAction]:[]))}changePasteType(){this._postPasteWidgetManager.tryShowSelector()}async pasteAs(e){this._logService.trace("CopyPasteController.pasteAs"),this._editor.focus();try{this._logService.trace("Before calling editor.action.clipboardPasteAction"),this._pasteAsActionContext={preferred:e},await this._commandService.executeCommand("editor.action.clipboardPasteAction")}finally{this._pasteAsActionContext=void 0}}clearWidgets(){this._postPasteWidgetManager.clear()}isPasteAsEnabled(){return this._editor.getOption(97).enabled}async finishedPaste(){await this._currentPasteOperation}handleCopy(e){if(this._logService.trace("CopyPasteController#handleCopy"),!this._editor.hasTextFocus()||(this._clipboardService.clearInternalState?.(),!this.isPasteAsEnabled()))return;const t=this._editor.getModel(),i=this._editor._getViewModel(),n=this._editor.getSelections();if(!t||!i||!n?.length)return;const s={multicursorText:e.dataToCopy.multicursorText??null,pasteOnNewLine:e.dataToCopy.isFromEmptySelection,mode:null},r=this._languageFeaturesService.documentPasteEditProvider.ordered(t).filter(g=>!!g.prepareDocumentPaste);if(!r.length){this.setCopyMetadata(e.clipboardData,{defaultPastePayload:s});return}const l=new o.VSDataTransfer,d=r.flatMap(g=>g.copyMimeTypes??[]),h=o.generateUuid();this.setCopyMetadata(e.clipboardData,{id:h,providerCopyMimeTypes:d,defaultPastePayload:s});const u=r.map(g=>({providerMimeTypes:g.copyMimeTypes,operation:a.createCancelablePromise(p=>g.prepareDocumentPaste(t,e.dataToCopy.sourceRanges,l,p).catch(f=>{console.error(f)}))}));Oe._currentCopyOperation?.operations.forEach(g=>g.operation.cancel()),Oe._currentCopyOperation={handle:h,operations:u}}async handlePaste(e){if(this._logService.trace("CopyPasteController#handlePaste for id : ",e.metadata?.id),!this._editor.hasTextFocus())return;const t=e.toExternalVSDataTransfer();if(!t)return;t.delete(zd),ve.get(this._editor)?.closeMessage(),this._currentPasteOperation?.cancel(),this._currentPasteOperation=void 0;const i=this._editor.getModel(),n=this._editor.getSelections();if(!n?.length||!i||this._editor.getOption(104)||!this.isPasteAsEnabled()&&!this._pasteAsActionContext)return;const s=this.fetchCopyMetadata(e);this._logService.trace("CopyPasteController#handlePaste with metadata : ",s?.id," and text.length : ",e.clipboardData.getData("text/plain").length);const r=Array.from(e.clipboardData.files).map(h=>h.type),l=[...e.clipboardData.types,...r,...s?.providerCopyMimeTypes??[],o.Mimes.uriList],d=this._languageFeaturesService.documentPasteEditProvider.ordered(i).filter(h=>{const u=this._pasteAsActionContext?.preferred;return u&&!this.providerMatchesPreference(h,u)?!1:h.pasteMimeTypes?.some(g=>o.matchesMimeType(g,l))});if(!d.length){this._pasteAsActionContext?.preferred&&(this.showPasteAsNoEditMessage(n,this._pasteAsActionContext.preferred),e.setHandled());return}e.setHandled(),this._pasteAsActionContext?this.showPasteAsPick(this._pasteAsActionContext.preferred,d,n,t,s):this.doPasteInline(d,n,t,s,e.browserEvent)}showPasteAsNoEditMessage(e,t){const i="only"in t?t.only.value:"preferences"in t?t.preferences.length?t.preferences.map(n=>n.value).join(", "):a.localize(973,"empty"):t.providerId;ve.get(this._editor)?.showMessage(a.localize(974,"No paste edits for '{0}' found",i),e[0].getStartPosition())}doPasteInline(e,t,i,n,s){this._logService.trace("CopyPasteController#doPasteInline");const r=this._editor;if(!r.hasModel())return;const l=new o.EditorStateCancellationTokenSource(r,3,void 0),d=a.createCancelablePromise(async h=>{const u=this._editor;if(!u.hasModel())return;const g=u.getModel(),p=new a.DisposableStore,f=p.add(new a.CancellationTokenSource(h));p.add(l.token.onCancellationRequested(()=>f.cancel()));const m=f.token;try{if(await this.mergeInDataFromCopy(e,i,n,m),m.isCancellationRequested)return;const _=e.filter(C=>this.isSupportedPasteProvider(C,i));if(!_.length||_.length===1&&_[0]instanceof Bi)return this.applyDefaultPasteHandler(i,n,m,s);const v={triggerKind:a.DocumentPasteTriggerKind.Automatic},b=await this.getPasteEdits(_,i,g,t,v,m);if(p.add(b),m.isCancellationRequested)return;if(b.edits.length===1&&b.edits[0].provider instanceof Bi)return this.applyDefaultPasteHandler(i,n,m,s);if(b.edits.length){const C=u.getOption(97).showPasteSelector==="afterPaste";return this._postPasteWidgetManager.applyEditAndShowIfNeeded(t,{activeEditIndex:this.getInitialActiveEditIndex(g,b.edits),allEdits:b.edits},C,async(y,I)=>{if(!y.provider.resolveDocumentPasteEdit)return y;const x=y.provider.resolveDocumentPasteEdit(y,I),S=new a.DeferredPromise,w=await this._pasteProgressManager.showWhile(t[0].getEndPosition(),a.localize(975,"Resolving paste edit for '{0}'. Click to cancel",y.title),a.raceCancellation(Promise.race([S.p,x]),I),{cancel:()=>S.cancel()},0);return w&&(y.insertText=w.insertText,y.additionalEdit=w.additionalEdit),y},m)}await this.applyDefaultPasteHandler(i,n,m,s)}finally{p.dispose(),this._currentPasteOperation===d&&(this._currentPasteOperation=void 0)}});this._pasteProgressManager.showWhile(t[0].getEndPosition(),a.localize(976,"Running paste handlers. Click to cancel and do basic paste"),d,{cancel:async()=>{d.cancel(),!l.token.isCancellationRequested&&await this.applyDefaultPasteHandler(i,n,l.token,s)}}).finally(()=>{l.dispose()}),this._currentPasteOperation=d}showPasteAsPick(e,t,i,n,s){this._logService.trace("CopyPasteController#showPasteAsPick");const r=a.createCancelablePromise(async l=>{const d=this._editor;if(!d.hasModel())return;const h=d.getModel(),u=new a.DisposableStore,g=u.add(new o.EditorStateCancellationTokenSource(d,3,void 0,l));try{if(await this.mergeInDataFromCopy(t,n,s,g.token),g.token.isCancellationRequested)return;let p=t.filter(b=>this.isSupportedPasteProvider(b,n,e));e&&(p=p.filter(b=>this.providerMatchesPreference(b,e)));const f={triggerKind:a.DocumentPasteTriggerKind.PasteAs,only:e&&"only"in e?e.only:void 0};let m=u.add(await this.getPasteEdits(p,n,h,i,f,g.token));if(g.token.isCancellationRequested)return;if(e&&(m={edits:m.edits.filter(b=>"only"in e?e.only.contains(b.kind):"preferences"in e?e.preferences.some(C=>C.contains(b.kind)):e.providerId===b.provider.id),dispose:m.dispose}),!m.edits.length){e&&this.showPasteAsNoEditMessage(i,e);return}let _;if(e)_=m.edits.at(0);else{const b={id:"editor.pasteAs.default",label:a.localize(977,"Configure default paste action"),edit:void 0},C=await this._quickInputService.pick([...m.edits.map(y=>({label:y.title,description:y.kind?.value,edit:y})),...Oe._configureDefaultAction?[a.upcast({type:"separator"}),{label:Oe._configureDefaultAction.label,edit:void 0}]:[]],{placeHolder:a.localize(978,"Select Paste Action")});if(C===b){Oe._configureDefaultAction?.run();return}_=C?.edit}if(!_)return;const v=Nf(h.uri,i,_);await this._bulkEditService.apply(v,{editor:this._editor})}finally{u.dispose(),this._currentPasteOperation===r&&(this._currentPasteOperation=void 0)}});this._progressService.withProgress({location:10,title:a.localize(979,"Running paste handlers")},()=>r)}setCopyMetadata(e,t){this._logService.trace("CopyPasteController#setCopyMetadata new id : ",t.id),e.setData(zd,JSON.stringify(t))}fetchCopyMetadata(e){this._logService.trace("CopyPasteController#fetchCopyMetadata");const t=e.clipboardData.getData(zd);if(t)try{return JSON.parse(t)}catch{return}if(e.metadata)return{defaultPastePayload:{mode:e.metadata.mode,multicursorText:e.metadata.multicursorText??null,pasteOnNewLine:!!e.metadata.isFromEmptySelection}}}async mergeInDataFromCopy(e,t,i,n){if(this._logService.trace("CopyPasteController#mergeInDataFromCopy with metadata : ",i?.id),i?.id&&Oe._currentCopyOperation?.handle===i.id){const s=Oe._currentCopyOperation.operations.filter(l=>e.some(d=>d.pasteMimeTypes.some(h=>o.matchesMimeType(h,l.providerMimeTypes)))).map(l=>l.operation),r=await Promise.all(s);if(n.isCancellationRequested)return;for(const l of r.reverse())if(l)for(const[d,h]of l)t.replace(d,h)}if(!t.has(o.Mimes.uriList)){const s=await this._clipboardService.readResources();if(n.isCancellationRequested)return;s.length&&t.append(o.Mimes.uriList,o.createStringDataTransferItem(o.UriList.create(s)))}}async getPasteEdits(e,t,i,n,s,r){const l=new a.DisposableStore,d=await a.raceCancellation(Promise.all(e.map(async u=>{try{const g=await u.provideDocumentPasteEdits?.(i,n,t,s,r);return g&&l.add(g),g?.edits?.map(p=>({...p,provider:u}))}catch(g){a.isCancellationError(g)||console.error(g);return}})),r),h=a.coalesce(d??[]).flat().filter(u=>!s.only||s.only.contains(u.kind));return{edits:Mf(h),dispose:()=>l.dispose()}}async applyDefaultPasteHandler(e,t,i,n){const r=await(e.get(o.Mimes.text)??e.get("text"))?.asString()??"";if(i.isCancellationRequested)return;const l={clipboardEvent:n,text:r,pasteOnNewLine:t?.defaultPastePayload.pasteOnNewLine??!1,multicursorText:t?.defaultPastePayload.multicursorText??null,mode:null};this._logService.trace("CopyPasteController#applyDefaultPasteHandler for id : ",t?.id),this._editor.trigger("keyboard","paste",l)}isSupportedPasteProvider(e,t,i){return e.pasteMimeTypes?.some(n=>t.matches(n))?!i||this.providerMatchesPreference(e,i):!1}providerMatchesPreference(e,t){return"only"in t?e.providedPasteEditKinds.some(i=>t.only.contains(i)):"preferences"in t?e.providedPasteEditKinds.some(i=>t.preferences.some(n=>n.contains(i))):e.id===t.providerId}getInitialActiveEditIndex(e,t){const i=this._configService.getValue(iS,{resource:e.uri});for(const n of Array.isArray(i)?i:[]){const s=new Z(n),r=t.findIndex(l=>s.contains(l.kind));if(r>=0)return r}return 0}},Oe=Cn,Cn.ID="editor.contrib.copyPasteActionController",Cn);xt=Oe=tS([It(1,o.IInstantiationService),It(2,o.ILogService),It(3,o.IBulkEditService),It(4,o.IClipboardService),It(5,o.ICommandService),It(6,o.IConfigurationService),It(7,o.ILanguageFeaturesService),It(8,o.IQuickInputService),It(9,o.IProgressService)],xt);const $i="9_cutcopypaste",nS=a.isNative||document.queryCommandSupported&&document.queryCommandSupported("cut"),jf=a.isNative||document.queryCommandSupported&&document.queryCommandSupported("copy"),sS=typeof navigator.clipboard>"u"||o.isFirefox?document.queryCommandSupported&&document.queryCommandSupported("paste"):!0;function Vd(c){return c.register(),c}const oS=nS?Vd(new o.MultiCommand({id:"editor.action.clipboardCutAction",precondition:void 0,kbOpts:a.isNative?{primary:2102,win:{primary:2102,secondary:[1044]},weight:100}:void 0,menuOpts:[{menuId:o.MenuId.MenubarEditMenu,group:"2_ccp",title:a.localize(864,"Cu&&t"),order:1},{menuId:o.MenuId.EditorContext,group:$i,title:a.localize(865,"Cut"),when:o.EditorContextKeys.writable,order:1},{menuId:o.MenuId.CommandPalette,group:"",title:a.localize(866,"Cut"),order:1},{menuId:o.MenuId.SimpleEditorContext,group:$i,title:a.localize(867,"Cut"),when:o.EditorContextKeys.writable,order:1}]})):void 0,rS=jf?Vd(new o.MultiCommand({id:"editor.action.clipboardCopyAction",precondition:void 0,kbOpts:a.isNative?{primary:2081,win:{primary:2081,secondary:[2067]},weight:100}:void 0,menuOpts:[{menuId:o.MenuId.MenubarEditMenu,group:"2_ccp",title:a.localize(868,"&&Copy"),order:2},{menuId:o.MenuId.EditorContext,group:$i,title:a.localize(869,"Copy"),order:2},{menuId:o.MenuId.CommandPalette,group:"",title:a.localize(870,"Copy"),order:1},{menuId:o.MenuId.SimpleEditorContext,group:$i,title:a.localize(871,"Copy"),order:2}]})):void 0;o.MenuRegistry.appendMenuItem(o.MenuId.MenubarEditMenu,{submenu:o.MenuId.MenubarCopy,title:a.localize2(876,"Copy As"),group:"2_ccp",order:3}),o.MenuRegistry.appendMenuItem(o.MenuId.EditorContext,{submenu:o.MenuId.EditorContextCopy,title:a.localize2(877,"Copy As"),group:$i,order:3}),o.MenuRegistry.appendMenuItem(o.MenuId.EditorContext,{submenu:o.MenuId.EditorContextShare,title:a.localize2(878,"Share"),group:"11_share",order:-1,when:o.ContextKeyExpr.and(o.ContextKeyExpr.notEquals("resourceScheme","output"),o.EditorContextKeys.editorTextFocus)}),o.MenuRegistry.appendMenuItem(o.MenuId.ExplorerContext,{submenu:o.MenuId.ExplorerContextShare,title:a.localize2(879,"Share"),group:"11_share",order:-1});const Bd=sS?Vd(new o.MultiCommand({id:"editor.action.clipboardPasteAction",precondition:void 0,kbOpts:a.isNative?{primary:2100,win:{primary:2100,secondary:[1043]},linux:{primary:2100,secondary:[1043]},weight:100}:void 0,menuOpts:[{menuId:o.MenuId.MenubarEditMenu,group:"2_ccp",title:a.localize(872,"&&Paste"),order:4},{menuId:o.MenuId.EditorContext,group:$i,title:a.localize(873,"Paste"),when:o.EditorContextKeys.writable,order:4},{menuId:o.MenuId.CommandPalette,group:"",title:a.localize(874,"Paste"),order:1},{menuId:o.MenuId.SimpleEditorContext,group:$i,title:a.localize(875,"Paste"),when:o.EditorContextKeys.writable,order:4}]})):void 0;class aS extends o.EditorAction{constructor(){super({id:"editor.action.clipboardCopyWithSyntaxHighlightingAction",label:a.localize2(880,"Copy with Syntax Highlighting"),precondition:void 0,kbOpts:{kbExpr:o.EditorContextKeys.textInputFocus,primary:0,weight:100}})}run(e,t){const i=e.get(o.ILogService),n=e.get(o.IClipboardService);i.trace("ExecCommandCopyWithSyntaxHighlightingAction#run"),!(!t.hasModel()||!t.getOption(45)&&t.getSelection().isEmpty())&&(o.CopyOptions.forceCopyWithSyntaxHighlighting=!0,t.focus(),i.trace("ExecCommandCopyWithSyntaxHighlightingAction (before execCommand copy)"),Kd(t,n),i.trace("ExecCommandCopyWithSyntaxHighlightingAction (after execCommand copy)"),o.CopyOptions.forceCopyWithSyntaxHighlighting=!1)}}function Kd(c,e){if(o.CopyOptions.electronBugWorkaroundCopyEventHasFired=!1,c.getContainerDomNode().ownerDocument.execCommand("copy"),a.isNative&&o.CopyOptions.electronBugWorkaroundCopyEventHasFired===!1){const{dataToCopy:t}=o.generateDataToCopyAndStoreInMemory(c._getViewModel(),void 0,o.isFirefox);e.writeText(t.text)}}function qf(c,e){c&&(c.addImplementation(1e4,"code-editor",(t,i)=>{const n=t.get(o.ILogService),s=t.get(o.IClipboardService);n.trace("registerExecCommandImpl (addImplementation code-editor for : ",e,")");const r=t.get(o.ICodeEditorService).getFocusedCodeEditor();if(r&&r.hasTextFocus()&&r.hasModel()){const l=r.getOption(45),d=r.getSelection();return d&&d.isEmpty()&&!l||(r.getOption(171)&&e==="cut"?(Gf(r),n.trace("registerExecCommandImpl (before execCommand copy)"),Kd(r,s),r.trigger(void 0,"cut",void 0),n.trace("registerExecCommandImpl (after execCommand copy)")):(Gf(r),n.trace("registerExecCommandImpl (before execCommand "+e+")"),e==="copy"?Kd(r,s):r.getContainerDomNode().ownerDocument.execCommand(e),n.trace("registerExecCommandImpl (after execCommand "+e+")"))),!0}return!1}),c.addImplementation(0,"generic-dom",(t,i)=>{const n=t.get(o.ILogService);return n.trace("registerExecCommandImpl (addImplementation generic-dom for : ",e,")"),n.trace("registerExecCommandImpl (before execCommand "+e+")"),o.getActiveDocument().execCommand(e),n.trace("registerExecCommandImpl (after execCommand "+e+")"),!0}))}function Gf(c){if(c.getOption(171)){const t=o.NativeEditContextRegistry.get(c.getId());t&&t.handleWillCopy()}}qf(oS,"cut"),qf(rS,"copy"),Bd&&(Bd.addImplementation(1e4,"code-editor",(c,e)=>{const t=c.get(o.ILogService);t.trace("registerExecCommandImpl (addImplementation code-editor for : paste)");const i=c.get(o.ICodeEditorService),n=c.get(o.IClipboardService),s=i.getFocusedCodeEditor();if(s&&s.hasModel()&&s.hasTextFocus()){if(s.getOption(171)){const d=o.NativeEditContextRegistry.get(s.getId());d&&d.handleWillPaste()}t.trace("registerExecCommandImpl (before triggerPaste)");const l=n.triggerPaste(o.getActiveWindow().vscodeWindowId);return l?(t.trace("registerExecCommandImpl (triggerPaste defined)"),l.then(async()=>(t.trace("registerExecCommandImpl (after triggerPaste)"),xt.get(s)?.finishedPaste()??Promise.resolve()))):(t.trace("registerExecCommandImpl (triggerPaste undefined)"),a.isWeb?(t.trace("registerExecCommandImpl (Paste handling on web)"),(async()=>{const d=await n.readText();if(d!==""){const h=o.InMemoryClipboardMetadataManager.INSTANCE.get(d);let u=!1,g=null,p=null;h&&(u=s.getOption(45)&&!!h.isFromEmptySelection,g=typeof h.multicursorText<"u"?h.multicursorText:null,p=h.mode),t.trace("registerExecCommandImpl (clipboardText.length : ",d.length," id : ",h?.id,")"),s.trigger("keyboard","paste",{text:d,pasteOnNewLine:u,multicursorText:g,mode:p})}})()):!0)}return!1}),Bd.addImplementation(0,"generic-dom",(c,e)=>(c.get(o.ILogService).trace("registerExecCommandImpl (addImplementation generic-dom for : paste)"),c.get(o.IClipboardService).triggerPaste(o.getActiveWindow().vscodeWindowId)??!1))),jf&&o.registerEditorAction(aS);const q=new class{constructor(){this.QuickFix=new Z("quickfix"),this.Refactor=new Z("refactor"),this.RefactorExtract=this.Refactor.append("extract"),this.RefactorInline=this.Refactor.append("inline"),this.RefactorMove=this.Refactor.append("move"),this.RefactorRewrite=this.Refactor.append("rewrite"),this.Notebook=new Z("notebook"),this.Source=new Z("source"),this.SourceOrganizeImports=this.Source.append("organizeImports"),this.SourceFixAll=this.Source.append("fixAll"),this.SurroundWith=this.Refactor.append("surround")}};var be;(function(c){c.Refactor="refactor",c.RefactorPreview="refactor preview",c.Lightbulb="lightbulb",c.Default="other (default)",c.SourceAction="source action",c.QuickFix="quick fix action",c.FixAll="fix all",c.OrganizeImports="organize imports",c.AutoFix="auto fix",c.QuickFixHover="quick fix hover window",c.OnSave="save participants",c.ProblemsView="problems view"})(be||(be={}));function lS(c,e){return!(c.include&&!c.include.intersects(e)||c.excludes&&c.excludes.some(t=>Zf(e,t,c.include))||!c.includeSourceActions&&q.Source.contains(e))}function cS(c,e){const t=e.kind?new Z(e.kind):void 0;return!(c.include&&(!t||!c.include.contains(t))||c.excludes&&t&&c.excludes.some(i=>Zf(t,i,c.include))||!c.includeSourceActions&&t&&q.Source.contains(t)||c.onlyIncludePreferredActions&&!e.isPreferred)}function Zf(c,e,t){return!(!e.contains(c)||t&&e.contains(t))}class rt{static fromUser(e,t){return!e||typeof e!="object"?new rt(t.kind,t.apply,!1):new rt(rt.getKindFromUser(e,t.kind),rt.getApplyFromUser(e,t.apply),rt.getPreferredUser(e))}static getApplyFromUser(e,t){switch(typeof e.apply=="string"?e.apply.toLowerCase():""){case"first":return"first";case"never":return"never";case"ifsingle":return"ifSingle";default:return t}}static getKindFromUser(e,t){return typeof e.kind=="string"?new Z(e.kind):t}static getPreferredUser(e){return typeof e.preferred=="boolean"?e.preferred:!1}constructor(e,t,i){this.kind=e,this.apply=t,this.preferred=i}}class dS{constructor(e,t,i){this.action=e,this.provider=t,this.highlightRange=i}async resolve(e){if(this.provider?.resolveCodeAction&&!this.action.edit){let t;try{t=await this.provider.resolveCodeAction(this.action,e)}catch(i){a.onUnexpectedExternalError(i)}t&&(this.action.edit=t.edit)}return this}}const Xf="editor.action.codeAction",ia="editor.action.quickFix",kd="editor.action.autoFix",Yf="editor.action.refactor",Qf="editor.action.sourceAction",Ud="editor.action.organizeImports",$d="editor.action.fixAll",hS=1e3;class bo extends a.Disposable{static codeActionsPreferredComparator(e,t){return e.isPreferred&&!t.isPreferred?-1:!e.isPreferred&&t.isPreferred?1:0}static codeActionsComparator({action:e},{action:t}){return e.isAI&&!t.isAI?1:!e.isAI&&t.isAI?-1:a.isNonEmptyArray(e.diagnostics)?a.isNonEmptyArray(t.diagnostics)?bo.codeActionsPreferredComparator(e,t):-1:a.isNonEmptyArray(t.diagnostics)?1:bo.codeActionsPreferredComparator(e,t)}constructor(e,t,i){super(),this.documentation=t,this._register(i),this.allActions=[...e].sort(bo.codeActionsComparator),this.validActions=this.allActions.filter(({action:n})=>!n.disabled)}get hasAutoFix(){return this.validActions.some(({action:e})=>!!e.kind&&q.QuickFix.contains(new Z(e.kind))&&!!e.isPreferred)}get hasAIFix(){return this.validActions.some(({action:e})=>!!e.isAI)}get allAIFixes(){return this.validActions.every(({action:e})=>!!e.isAI)}}const Jf={actions:[],documentation:void 0};async function cs(c,e,t,i,n,s){const r=i.filter||{},l={...r,excludes:[...r.excludes||[],q.Notebook]},d={only:r.include?.value,trigger:i.type},h=new o.TextModelCancellationTokenSource(e,s),u=i.type===2,g=uS(c,e,u?l:r),p=new a.DisposableStore,f=g.map(async _=>{const v=setTimeout(()=>n.report(_),1250);try{const b=await _.provideCodeActions(e,t,d,h.token);if(h.token.isCancellationRequested)return b?.dispose(),Jf;b&&p.add(b);const C=(b?.actions||[]).filter(I=>I&&cS(r,I)),y=pS(_,C,r.include);return{actions:C.map(I=>new dS(I,_)),documentation:y}}catch(b){if(a.isCancellationError(b))throw b;return a.onUnexpectedExternalError(b),Jf}finally{clearTimeout(v)}}),m=c.onDidChange(()=>{const _=c.all(e);a.equals(_,g)||h.cancel()});try{const _=await Promise.all(f),v=_.map(y=>y.actions).flat(),b=[...a.coalesce(_.map(y=>y.documentation)),...gS(c,e,i,v)],C=new bo(v,b,p);return p.add(C),C}catch(_){throw p.dispose(),_}finally{m.dispose(),h.dispose()}}function uS(c,e,t){return c.all(e).filter(i=>i.providedCodeActionKinds?i.providedCodeActionKinds.some(n=>lS(t,new Z(n))):!0)}function*gS(c,e,t,i){if(e&&i.length)for(const n of c.all(e))n._getAdditionalMenuItems&&(yield*n._getAdditionalMenuItems?.({trigger:t.type,only:t.filter?.include?.value},i.map(s=>s.action)))}function pS(c,e,t){if(!c.documentation)return;const i=c.documentation.map(n=>({kind:new Z(n.kind),command:n.command}));if(t){let n;for(const s of i)s.kind.contains(t)&&(n?n.kind.contains(s.kind)&&(n=s):n=s);if(n)return n?.command}for(const n of e)if(n.kind){for(const s of i)if(s.kind.contains(new Z(n.kind)))return s.command}}var Ut;(function(c){c.OnSave="onSave",c.FromProblemsView="fromProblemsView",c.FromCodeActions="fromCodeActions",c.FromAILightbulb="fromAILightbulb",c.FromProblemsHover="fromProblemsHover"})(Ut||(Ut={}));async function fS(c,e,t,i,n=a.CancellationToken.None){const s=c.get(o.IBulkEditService),r=c.get(o.ICommandService),l=c.get(o.ITelemetryService),d=c.get(o.INotificationService),h=c.get(o.IAccessibilitySignalService);if(l.publicLog2("codeAction.applyCodeAction",{codeActionTitle:e.action.title,codeActionKind:e.action.kind,codeActionIsPreferred:!!e.action.isPreferred,reason:t}),h.playSignal(o.AccessibilitySignal.codeActionTriggered),await e.resolve(n),!n.isCancellationRequested&&!(e.action.edit?.edits.length&&!(await s.apply(e.action.edit,{editor:i?.editor,label:e.action.title,quotableLabel:e.action.title,code:"undoredo.codeAction",respectAutoSaveConfig:t!==Ut.OnSave,showPreview:i?.preview,reason:o.EditSources.codeAction({kind:e.action.kind,providerId:a.ProviderId.fromExtensionId(e.provider?.extensionId)})})).isApplied)){if(e.action.command)try{await r.executeCommand(e.action.command.id,...e.action.command.arguments||[])}catch(u){const g=mS(u);d.error(typeof g=="string"?g:a.localize(881,"An unknown error occurred while applying the code action"))}setTimeout(()=>h.playSignal(o.AccessibilitySignal.codeActionApplied),hS)}}function mS(c){return typeof c=="string"?c:c instanceof Error&&typeof c.message=="string"?c.message:void 0}o.CommandsRegistry.registerCommand("_executeCodeActionProvider",async function(c,e,t,i,n){if(!(e instanceof a.URI))throw a.illegalArgument();const{codeActionProvider:s}=c.get(o.ILanguageFeaturesService),r=c.get(o.IModelService).getModel(e);if(!r)throw a.illegalArgument();const l=a.Selection.isISelection(t)?a.Selection.liftSelection(t):a.Range.isIRange(t)?r.validateRange(t):void 0;if(!l)throw a.illegalArgument();const d=typeof i=="string"?new Z(i):void 0,h=await cs(s,r,l,{type:1,triggerAction:be.Default,filter:{includeSourceActions:!0,include:d}},o.Progress.None,a.CancellationToken.None),u=[],g=Math.min(h.validActions.length,typeof n=="number"?n:0);for(let p=0;p<g;p++)u.push(h.validActions[p].resolve(a.CancellationToken.None));try{return await Promise.all(u),h.validActions.map(p=>p.action)}finally{setTimeout(()=>h.dispose(),100)}});var _S=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},vS=function(c,e){return function(t,i){e(t,i,c)}},jd;let qd=(Sn=class{constructor(e){this.keybindingService=e}getResolver(){const e=new a.Lazy(()=>this.keybindingService.getKeybindings().filter(t=>jd.codeActionCommands.indexOf(t.command)>=0).filter(t=>t.resolvedKeybinding).map(t=>{let i=t.commandArgs;return t.command===Ud?i={kind:q.SourceOrganizeImports.value}:t.command===$d&&(i={kind:q.SourceFixAll.value}),{resolvedKeybinding:t.resolvedKeybinding,...rt.fromUser(i,{kind:Z.None,apply:"never"})}}));return t=>{if(t.kind)return this.bestKeybindingForCodeAction(t,e.value)?.resolvedKeybinding}}bestKeybindingForCodeAction(e,t){if(!e.kind)return;const i=new Z(e.kind);return t.filter(n=>n.kind.contains(i)).filter(n=>n.preferred?e.isPreferred:!0).reduceRight((n,s)=>n?n.kind.contains(s.kind)?s:n:s,void 0)}},jd=Sn,Sn.codeActionCommands=[Yf,Xf,Qf,Ud,$d],Sn);qd=jd=_S([vS(0,o.IKeybindingService)],qd),o.registerColor("symbolIcon.arrayForeground",o.foreground,a.localize(1569,"The foreground color for array symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.booleanForeground",o.foreground,a.localize(1570,"The foreground color for boolean symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.classForeground",{dark:"#EE9D28",light:"#D67E00",hcDark:"#EE9D28",hcLight:"#D67E00"},a.localize(1571,"The foreground color for class symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.colorForeground",o.foreground,a.localize(1572,"The foreground color for color symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.constantForeground",o.foreground,a.localize(1573,"The foreground color for constant symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.constructorForeground",{dark:"#B180D7",light:"#652D90",hcDark:"#B180D7",hcLight:"#652D90"},a.localize(1574,"The foreground color for constructor symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.enumeratorForeground",{dark:"#EE9D28",light:"#D67E00",hcDark:"#EE9D28",hcLight:"#D67E00"},a.localize(1575,"The foreground color for enumerator symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.enumeratorMemberForeground",{dark:"#75BEFF",light:"#007ACC",hcDark:"#75BEFF",hcLight:"#007ACC"},a.localize(1576,"The foreground color for enumerator member symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.eventForeground",{dark:"#EE9D28",light:"#D67E00",hcDark:"#EE9D28",hcLight:"#D67E00"},a.localize(1577,"The foreground color for event symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.fieldForeground",{dark:"#75BEFF",light:"#007ACC",hcDark:"#75BEFF",hcLight:"#007ACC"},a.localize(1578,"The foreground color for field symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.fileForeground",o.foreground,a.localize(1579,"The foreground color for file symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.folderForeground",o.foreground,a.localize(1580,"The foreground color for folder symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.functionForeground",{dark:"#B180D7",light:"#652D90",hcDark:"#B180D7",hcLight:"#652D90"},a.localize(1581,"The foreground color for function symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.interfaceForeground",{dark:"#75BEFF",light:"#007ACC",hcDark:"#75BEFF",hcLight:"#007ACC"},a.localize(1582,"The foreground color for interface symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.keyForeground",o.foreground,a.localize(1583,"The foreground color for key symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.keywordForeground",o.foreground,a.localize(1584,"The foreground color for keyword symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.methodForeground",{dark:"#B180D7",light:"#652D90",hcDark:"#B180D7",hcLight:"#652D90"},a.localize(1585,"The foreground color for method symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.moduleForeground",o.foreground,a.localize(1586,"The foreground color for module symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.namespaceForeground",o.foreground,a.localize(1587,"The foreground color for namespace symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.nullForeground",o.foreground,a.localize(1588,"The foreground color for null symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.numberForeground",o.foreground,a.localize(1589,"The foreground color for number symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.objectForeground",o.foreground,a.localize(1590,"The foreground color for object symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.operatorForeground",o.foreground,a.localize(1591,"The foreground color for operator symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.packageForeground",o.foreground,a.localize(1592,"The foreground color for package symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.propertyForeground",o.foreground,a.localize(1593,"The foreground color for property symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.referenceForeground",o.foreground,a.localize(1594,"The foreground color for reference symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.snippetForeground",o.foreground,a.localize(1595,"The foreground color for snippet symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.stringForeground",o.foreground,a.localize(1596,"The foreground color for string symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.structForeground",o.foreground,a.localize(1597,"The foreground color for struct symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.textForeground",o.foreground,a.localize(1598,"The foreground color for text symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.typeParameterForeground",o.foreground,a.localize(1599,"The foreground color for type parameter symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.unitForeground",o.foreground,a.localize(1600,"The foreground color for unit symbols. These symbols appear in the outline, breadcrumb, and suggest widget.")),o.registerColor("symbolIcon.variableForeground",{dark:"#75BEFF",light:"#007ACC",hcDark:"#75BEFF",hcLight:"#007ACC"},a.localize(1601,"The foreground color for variable symbols. These symbols appear in the outline, breadcrumb, and suggest widget."));const Wf=Object.freeze({kind:Z.Empty,title:a.localize(917,"More Actions...")}),bS=Object.freeze([{kind:q.QuickFix,title:a.localize(918,"Quick Fix")},{kind:q.RefactorExtract,title:a.localize(919,"Extract"),icon:a.Codicon.wrench},{kind:q.RefactorInline,title:a.localize(920,"Inline"),icon:a.Codicon.wrench},{kind:q.RefactorRewrite,title:a.localize(921,"Rewrite"),icon:a.Codicon.wrench},{kind:q.RefactorMove,title:a.localize(922,"Move"),icon:a.Codicon.wrench},{kind:q.SurroundWith,title:a.localize(923,"Surround With"),icon:a.Codicon.surroundWith},{kind:q.Source,title:a.localize(924,"Source Action"),icon:a.Codicon.symbolFile},Wf]);function CS(c,e,t){if(!e)return c.map(s=>({kind:"action",item:s,group:Wf,disabled:!!s.action.disabled,label:s.action.disabled||s.action.title,canPreview:!!s.action.edit?.edits.length}));const i=bS.map(s=>({group:s,actions:[]}));for(const s of c){const r=s.action.kind?new Z(s.action.kind):Z.None;for(const l of i)if(l.group.kind.contains(r)){l.actions.push(s);break}}const n=[];for(const s of i)if(s.actions.length){n.push({kind:"header",group:s.group});for(const r of s.actions){const l=s.group;n.push({kind:"action",item:r,group:r.action.isAI?{title:l.title,kind:l.kind,icon:a.Codicon.sparkle}:l,label:r.action.title,disabled:!!r.action.disabled,keybinding:t(r.action)})}}return n}const Hf=new o.RawContextKey("supportedCodeAction",""),em="_typescript.applyFixAllCodeAction";class SS extends a.Disposable{constructor(e,t,i,n=250){super(),this._editor=e,this._markerService=t,this._signalChange=i,this._delay=n,this._autoTriggerTimer=this._register(new a.TimeoutTimer),this.ignoreLightbulbOff=!1,this._register(this._markerService.onMarkerChanged(s=>this._onMarkerChanges(s))),this._register(this._editor.onDidChangeCursorPosition(()=>this._tryAutoTrigger()))}trigger(e){const t=this._getRangeOfSelectionUnlessWhitespaceEnclosed(e);this._signalChange(t?{trigger:e,selection:t}:void 0)}_onMarkerChanges(e){const t=this._editor.getModel();t&&e.some(i=>o.isEqual(i,t.uri))&&this._tryAutoTrigger()}_tryAutoTrigger(){this._autoTriggerTimer.cancelAndSet(()=>{this.trigger({type:2,triggerAction:be.Default})},this._delay)}_getRangeOfSelectionUnlessWhitespaceEnclosed(e){if(!this._editor.hasModel())return;const t=this._editor.getSelection();if(e.type===1)return t;const i=this._editor.getOption(73).enabled;if(!(i===o.ShowLightbulbIconMode.Off&&!this.ignoreLightbulbOff)){{if(i===o.ShowLightbulbIconMode.Off||i===o.ShowLightbulbIconMode.On)return t;if(i===o.ShowLightbulbIconMode.OnCode){if(!t.isEmpty())return t;const s=this._editor.getModel(),{lineNumber:r,column:l}=t.getPosition(),d=s.getLineContent(r);if(d.length===0)return;if(l===1){if(/\s/.test(d[0]))return}else if(l===s.getLineMaxColumn(r)){if(/\s/.test(d[d.length-1]))return}else if(/\s/.test(d[l-2])&&/\s/.test(d[l-1]))return}}return t}}}var ji;(function(c){c.Empty={type:0};class e{constructor(i,n,s){this.trigger=i,this.position=n,this._cancellablePromise=s,this.type=1,this.actions=s.catch(r=>{if(a.isCancellationError(r))return Co;throw r})}cancel(){this._cancellablePromise.cancel()}}c.Triggered=e})(ji||(ji={}));const Co=Object.freeze({allActions:[],validActions:[],dispose:()=>{},documentation:[],hasAutoFix:!1,hasAIFix:!1,allAIFixes:!1});class yS extends a.Disposable{constructor(e,t,i,n,s,r){super(),this._editor=e,this._registry=t,this._markerService=i,this._progressService=s,this._configurationService=r,this._codeActionOracle=this._register(new a.MutableDisposable),this._state=ji.Empty,this._onDidChangeState=this._register(new a.Emitter),this.onDidChangeState=this._onDidChangeState.event,this.codeActionsDisposable=this._register(new a.MutableDisposable),this._disposed=!1,this._ignoreLightbulbOff=!1,this._supportedCodeActions=Hf.bindTo(n),this._register(this._editor.onDidChangeModel(()=>this._update())),this._register(this._editor.onDidChangeModelLanguage(()=>this._update())),this._register(this._registry.onDidChange(()=>this._update())),this._register(this._editor.onDidChangeConfiguration(l=>{l.hasChanged(73)&&this._update()})),this._update()}dispose(){this._disposed||(this._disposed=!0,super.dispose(),this.setState(ji.Empty,!0))}_settingEnabledNearbyQuickfixes(){const e=this._editor?.getModel();return this._configurationService?this._configurationService.getValue("editor.codeActionWidget.includeNearbyQuickFixes",{resource:e?.uri}):!1}_update(){if(this._disposed)return;this._codeActionOracle.value=void 0,this.setState(ji.Empty),this.codeActionsDisposable.clear();const e=this._editor.getModel();if(e&&this._registry.has(e)&&!this._editor.getOption(104)){const t=this._registry.all(e).flatMap(n=>n.providedCodeActionKinds??[]);this._supportedCodeActions.set(t.join(" "));const i=new SS(this._editor,this._markerService,n=>{if(!n){this.setState(ji.Empty);return}const s=n.selection.getStartPosition(),r=a.createCancelablePromise(async h=>{if(this._settingEnabledNearbyQuickfixes()&&n.trigger.type===1&&(n.trigger.triggerAction===be.QuickFix||n.trigger.filter?.include?.contains(q.QuickFix))){const g=new a.DisposableStore;let p=!1;try{const f=g.add(await cs(this._registry,e,n.selection,n.trigger,o.Progress.None,h)),m=[...f.allActions];if(h.isCancellationRequested)return Co;const _=f.validActions?.some(b=>b.action.kind&&q.QuickFix.contains(new Z(b.action.kind))&&!b.action.isAI),v=this._markerService.read({resource:e.uri});if(_){for(const C of f.validActions)C.action.command?.arguments?.some(y=>typeof y=="string"&&y.includes(em))&&(C.action.diagnostics=[...v.filter(y=>y.relatedInformation)]);const b=this._setCodeActions({validActions:f.validActions,allActions:m,documentation:f.documentation,hasAutoFix:f.hasAutoFix,hasAIFix:f.hasAIFix,allAIFixes:f.allAIFixes,dispose:()=>g.dispose()});return p=!0,b}else if(!_&&v.length>0){const b=n.selection.getPosition();let C=b,y=Number.MAX_VALUE;const I=[...f.validActions];for(const w of v){const E=w.endColumn,L=w.endLineNumber,R=w.startLineNumber;if(L===b.lineNumber||R===b.lineNumber){C=new a.Position(L,E);const D={type:n.trigger.type,triggerAction:n.trigger.triggerAction,filter:{include:n.trigger.filter?.include?n.trigger.filter?.include:q.QuickFix},autoApply:n.trigger.autoApply,context:{notAvailableMessage:n.trigger.context?.notAvailableMessage||"",position:C}},T=new a.Selection(C.lineNumber,C.column,C.lineNumber,C.column),P=g.add(await cs(this._registry,e,T,D,o.Progress.None,h));if(h.isCancellationRequested)return Co;if(P.validActions.length!==0){for(const M of P.validActions)M.action.command?.arguments?.some(V=>typeof V=="string"&&V.includes(em))&&(M.action.diagnostics=[...v.filter(V=>V.relatedInformation)]);f.allActions.length===0&&m.push(...P.allActions),Math.abs(b.column-E)<y?I.unshift(...P.validActions):I.push(...P.validActions)}y=Math.abs(b.column-E)}}const x=I.filter((w,E,L)=>L.findIndex(R=>R.action.title===w.action.title)===E);x.sort((w,E)=>w.action.isPreferred&&!E.action.isPreferred?-1:!w.action.isPreferred&&E.action.isPreferred||w.action.isAI&&!E.action.isAI?1:!w.action.isAI&&E.action.isAI?-1:0);const S=this._setCodeActions({validActions:x,allActions:m,documentation:f.documentation,hasAutoFix:f.hasAutoFix,hasAIFix:f.hasAIFix,allAIFixes:f.allAIFixes,dispose:()=>g.dispose()});return p=!0,S}}finally{p||g.dispose()}}if(n.trigger.type===1){const g=await cs(this._registry,e,n.selection,n.trigger,o.Progress.None,h);return h.isCancellationRequested?(g.dispose(),Co):this._setCodeActions(g)}const u=await cs(this._registry,e,n.selection,n.trigger,o.Progress.None,h);return h.isCancellationRequested?(u.dispose(),Co):this._setCodeActions(u)});n.trigger.type===1&&this._progressService?.showWhile(r,250);const l=new ji.Triggered(n.trigger,s,r);let d=!1;this._state.type===1&&(d=this._state.trigger.type===1&&l.type===1&&l.trigger.type===2&&this._state.position!==l.position),d?setTimeout(()=>{this.setState(l)},500):this.setState(l)},void 0);i.ignoreLightbulbOff=this._ignoreLightbulbOff,this._codeActionOracle.value=i,this._codeActionOracle.value.trigger({type:2,triggerAction:be.Default})}else this._supportedCodeActions.reset()}_setCodeActions(e){return this.codeActionsDisposable.value=e,e}takeCodeActions(e){if(this.codeActionsDisposable.value===e)return this.codeActionsDisposable.clearAndLeak(),e}trigger(e){this._codeActionOracle.value?.trigger(e),this.codeActionsDisposable.clear()}setState(e,t){e!==this._state&&(this._state.type===1&&this._state.cancel(),this._state=e,!t&&!this._disposed&&this._onDidChangeState.fire(e))}}var wS=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},IS=function(c,e){return function(t,i){e(t,i,c)}},$t;const tm=o.registerIcon("gutter-lightbulb",a.Codicon.lightBulb,a.localize(925,"Icon which spawns code actions menu from the gutter when there is no space in the editor.")),im=o.registerIcon("gutter-lightbulb-auto-fix",a.Codicon.lightbulbAutofix,a.localize(926,"Icon which spawns code actions menu from the gutter when there is no space in the editor and a quick fix is available.")),nm=o.registerIcon("gutter-lightbulb-sparkle",a.Codicon.lightbulbSparkle,a.localize(927,"Icon which spawns code actions menu from the gutter when there is no space in the editor and an AI fix is available.")),sm=o.registerIcon("gutter-lightbulb-aifix-auto-fix",a.Codicon.lightbulbSparkleAutofix,a.localize(928,"Icon which spawns code actions menu from the gutter when there is no space in the editor and an AI fix and a quick fix is available.")),om=o.registerIcon("gutter-lightbulb-sparkle-filled",a.Codicon.sparkleFilled,a.localize(929,"Icon which spawns code actions menu from the gutter when there is no space in the editor and an AI fix and a quick fix is available."));var Ze;(function(c){c.Hidden={type:0};class e{constructor(i,n,s,r){this.actions=i,this.trigger=n,this.editorPosition=s,this.widgetPosition=r,this.type=1}}c.Showing=e})(Ze||(Ze={}));function rm(c,e,t,i,n=!1){if(c.validActions.length<=0)return;let s,r=!1;c.allAIFixes?(s=n?om:a.Codicon.sparkleFilled,c.validActions.length===1&&(r=!0)):c.hasAutoFix?c.hasAIFix?s=n?sm:a.Codicon.lightbulbSparkleAutofix:s=n?im:a.Codicon.lightbulbAutofix:c.hasAIFix?s=n?nm:a.Codicon.lightbulbSparkle:s=n?tm:a.Codicon.lightBulb;let l;return r?l=a.localize(930,"Run: {0}",c.validActions[0].action.title):c.hasAutoFix&&t?l=a.localize(931,"Show Code Actions. Preferred Quick Fix Available ({0})",t):!c.hasAutoFix&&i?l=a.localize(932,"Show Code Actions ({0})",i):l=a.localize(933,"Show Code Actions"),{actions:c,trigger:e,icon:s,autoRun:r,title:l,isGutter:n}}let So=(Vt=class extends a.Disposable{static _computeLightBulbInfo(e,t,i,n){if(e.type===1)return rm(e.actions,e.trigger,i,n,t)}constructor(e,t){super(),this._editor=e,this._keybindingService=t,this.onlyWithEmptySelection=!1,this._onClick=this._register(new a.Emitter),this.onClick=this._onClick.event,this._state=o.observableValue(this,Ze.Hidden),this._gutterState=o.observableValue(this,Ze.Hidden),this._combinedInfo=o.derived(this,i=>{const n=this._gutterState.read(i);if(n.type===1)return $t._computeLightBulbInfo(n,!0,this._preferredKbLabel.read(i),this._quickFixKbLabel.read(i));const s=this._state.read(i);if(s.type===1)return $t._computeLightBulbInfo(s,!1,this._preferredKbLabel.read(i),this._quickFixKbLabel.read(i))}),this._iconClasses=[],this.lightbulbClasses=["codicon-"+tm.id,"codicon-"+sm.id,"codicon-"+im.id,"codicon-"+nm.id,"codicon-"+om.id],this._preferredKbLabel=o.observableValue(this,void 0),this._quickFixKbLabel=o.observableValue(this,void 0),this.gutterDecoration=$t.GUTTER_DECORATION,this._domNode=o.$("div.lightBulbWidget"),this._domNode.role="listbox",this._register(o.Gesture.ignoreTarget(this._domNode)),this._editor.addContentWidget(this),this._register(this._editor.onDidChangeModelContent(i=>{const n=this._editor.getModel(),s=this._state.get();(s.type!==1||!n||s.editorPosition.lineNumber>=n.getLineCount())&&this.hide();const r=this._gutterState.get();(r.type!==1||!n||r.editorPosition.lineNumber>=n.getLineCount())&&this.gutterHide()})),this._register(o.addStandardDisposableGenericMouseDownListener(this._domNode,i=>{const n=this._state.get();if(n.type!==1)return;this._editor.focus(),i.preventDefault();const{top:s,height:r}=o.getDomNodePagePosition(this._domNode),l=this._editor.getOption(75);let d=Math.floor(l/3);n.widgetPosition.position!==null&&n.widgetPosition.position.lineNumber<n.editorPosition.lineNumber&&(d+=l),this._onClick.fire({x:i.posx,y:s+r+d,actions:n.actions,trigger:n.trigger})})),this._register(o.addDisposableListener(this._domNode,"mouseenter",i=>{(i.buttons&1)===1&&this.hide()})),this._register(a.Event.runAndSubscribe(this._keybindingService.onDidUpdateKeybindings,()=>{this._preferredKbLabel.set(this._keybindingService.lookupKeybinding(kd)?.getLabel()??void 0,void 0),this._quickFixKbLabel.set(this._keybindingService.lookupKeybinding(ia)?.getLabel()??void 0,void 0)})),this._register(o.autorun(i=>{const n=this._combinedInfo.read(i);this._updateLightBulbTitleAndIcon(n),this._updateGutterDecorationOptions(n)})),this._register(this._editor.onMouseDown(async i=>{if(!i.target.element||!this.lightbulbClasses.some(h=>i.target.element&&i.target.element.classList.contains(h)))return;const n=this._gutterState.get();if(n.type!==1)return;this._editor.focus();const{top:s,height:r}=o.getDomNodePagePosition(i.target.element),l=this._editor.getOption(75);let d=Math.floor(l/3);n.widgetPosition.position!==null&&n.widgetPosition.position.lineNumber<n.editorPosition.lineNumber&&(d+=l),this._onClick.fire({x:i.event.posx,y:s+r+d,actions:n.actions,trigger:n.trigger})}))}dispose(){super.dispose(),this._editor.removeContentWidget(this),this._gutterDecorationID&&this._removeGutterDecoration(this._gutterDecorationID)}getId(){return"LightBulbWidget"}getDomNode(){return this._domNode}getPosition(){const e=this._state.get();return e.type===1?e.widgetPosition:null}update(e,t,i){if(e.validActions.length<=0)return this.gutterHide(),this.hide();if(this.onlyWithEmptySelection&&!this._editor.getSelection()?.isEmpty())return this.gutterHide(),this.hide();if(!this._editor.hasTextFocus())return this.gutterHide(),this.hide();if(this._editor.getOptions().get(73).enabled===o.ShowLightbulbIconMode.Off)return this.gutterHide(),this.hide();const r=this._editor.getModel();if(!r)return this.gutterHide(),this.hide();const{lineNumber:l,column:d}=r.validatePosition(i),h=r.getOptions().tabSize,u=this._editor.getOptions().get(59),g=r.getLineContent(l),p=o.computeIndentLevel(g,h),f=u.spaceWidth*p>22,m=x=>x>2&&this._editor.getTopForLineNumber(x)===this._editor.getTopForLineNumber(x-1),_=this._editor.getLineDecorations(l);let v=!1;if(_)for(const x of _){const S=x.options.glyphMarginClassName;if(S&&!this.lightbulbClasses.some(w=>S.includes(w))){v=!0;break}}let b=l,C=1;if(!f){const x=S=>{const w=r.getLineContent(S);return/^\s*$|^\s+/.test(w)||w.length<=C};if(l>1&&!m(l-1)){const S=r.getLineCount(),w=l===S,E=l>1&&x(l-1),L=!w&&x(l+1),R=x(l),D=!L&&!E;if(!L&&!E&&!v)return this._gutterState.set(new Ze.Showing(e,t,i,{position:{lineNumber:b,column:C},preference:$t._posPref}),void 0),this.renderGutterLightbub(),this.hide();E||w||E&&!R?b-=1:(L||D&&R)&&(b+=1)}else if(l===1&&(l===r.getLineCount()||!x(l+1)&&!x(l)))if(this._gutterState.set(new Ze.Showing(e,t,i,{position:{lineNumber:b,column:C},preference:$t._posPref}),void 0),v)this.gutterHide();else return this.renderGutterLightbub(),this.hide();else if(l<r.getLineCount()&&!m(l+1))b+=1;else if(d*u.spaceWidth<22)return this.hide();C=/^\S\s*$/.test(r.getLineContent(b))?2:1}this._state.set(new Ze.Showing(e,t,i,{position:{lineNumber:b,column:C},preference:$t._posPref}),void 0),this._gutterDecorationID&&(this._removeGutterDecoration(this._gutterDecorationID),this.gutterHide());const y=e.validActions,I=e.validActions[0].action.kind;if(y.length!==1||!I){this._editor.layoutContentWidget(this);return}this._editor.layoutContentWidget(this)}hide(){this._state.get()!==Ze.Hidden&&(this._state.set(Ze.Hidden,void 0),this._editor.layoutContentWidget(this))}gutterHide(){this._gutterState.get()!==Ze.Hidden&&(this._gutterDecorationID&&this._removeGutterDecoration(this._gutterDecorationID),this._gutterState.set(Ze.Hidden,void 0))}_updateLightBulbTitleAndIcon(e){this._domNode.classList.remove(...this._iconClasses),this._iconClasses=[],!(!e||e.isGutter)&&(this._domNode.title=e.title,this._iconClasses=o.ThemeIcon.asClassNameArray(e.icon),this._domNode.classList.add(...this._iconClasses))}_updateGutterDecorationOptions(e){!e||!e.isGutter||(this.gutterDecoration=o.ModelDecorationOptions.register({description:"codicon-gutter-lightbulb-decoration",glyphMarginClassName:o.ThemeIcon.asClassName(e.icon),glyphMargin:{position:a.GlyphMarginLane.Left},stickiness:1}))}renderGutterLightbub(){const e=this._editor.getSelection();e&&(this._gutterDecorationID===void 0?this._addGutterDecoration(e.startLineNumber):this._updateGutterDecoration(this._gutterDecorationID,e.startLineNumber))}_addGutterDecoration(e){this._editor.changeDecorations(t=>{this._gutterDecorationID=t.addDecoration(new a.Range(e,0,e,0),this.gutterDecoration)})}_removeGutterDecoration(e){this._editor.changeDecorations(t=>{t.removeDecoration(e),this._gutterDecorationID=void 0})}_updateGutterDecoration(e,t){this._editor.changeDecorations(i=>{i.changeDecoration(e,new a.Range(t,0,t,0)),i.changeDecorationOptions(e,this.gutterDecoration)})}},$t=Vt,Vt.GUTTER_DECORATION=o.ModelDecorationOptions.register({description:"codicon-gutter-lightbulb-decoration",glyphMarginClassName:o.ThemeIcon.asClassName(a.Codicon.lightBulb),glyphMargin:{position:a.GlyphMarginLane.Left},stickiness:1}),Vt.ID="editor.contrib.lightbulbWidget",Vt._posPref=[0],Vt);So=$t=wS([IS(1,o.IKeybindingService)],So);var xS=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Xe=function(c,e){return function(t,i){e(t,i,c)}},ds;const ES="quickfix-edit-highlight";let qi=(_i=class extends a.Disposable{static get(e){return e.getContribution(ds.ID)}constructor(e,t,i,n,s,r,l,d,h,u,g,p){super(),this._commandService=l,this._configurationService=d,this._actionWidgetService=h,this._instantiationService=u,this._progressService=g,this._keybindingService=p,this._activeCodeActions=this._register(new a.MutableDisposable),this._showDisabled=!1,this._disposed=!1,this._onlyLightBulbWithEmptySelection=!1,this._lightBulbInfoObs=o.observableValue(this,void 0),this._preferredKbLabel=o.observableValue(this,void 0),this._quickFixKbLabel=o.observableValue(this,void 0),this._editor=e,this._model=this._register(new yS(this._editor,s.codeActionProvider,t,i,r,d)),this._register(this._model.onDidChangeState(f=>this.update(f))),this._register(a.Event.runAndSubscribe(this._keybindingService.onDidUpdateKeybindings,()=>{this._preferredKbLabel.set(this._keybindingService.lookupKeybinding(kd)?.getLabel()??void 0,void 0),this._quickFixKbLabel.set(this._keybindingService.lookupKeybinding(ia)?.getLabel()??void 0,void 0)})),this._lightBulbWidget=new a.Lazy(()=>{const f=this._editor.getContribution(So.ID);return f&&(this._register(f.onClick(m=>this.showCodeActionsFromLightbulb(m.actions,m))),f.onlyWithEmptySelection=this._onlyLightBulbWithEmptySelection),f}),this._resolver=n.createInstance(qd),this._register(this._editor.onDidLayoutChange(()=>this._actionWidgetService.hide()))}dispose(){this._disposed=!0,super.dispose()}async showCodeActionsFromLightbulb(e,t){if(e.allAIFixes&&e.validActions.length===1){const i=e.validActions[0],n=i.action.command;n&&n.id==="inlineChat.start"&&n.arguments&&n.arguments.length>=1&&n.arguments[0]&&(n.arguments[0]={...n.arguments[0],autoSend:!1}),await this.applyCodeAction(i,!1,!1,Ut.FromAILightbulb);return}await this.showCodeActionList(e,t,{includeDisabledActions:!1,fromLightbulb:!0})}showCodeActions(e,t,i){return this.showCodeActionList(t,i,{includeDisabledActions:!1,fromLightbulb:!1})}manualTriggerAtCurrentPosition(e,t,i,n){if(!this._editor.hasModel())return;ve.get(this._editor)?.closeMessage();const s=this._editor.getPosition();this._trigger({type:1,triggerAction:t,filter:i,autoApply:n,context:{notAvailableMessage:e,position:s}})}_trigger(e){return this._model.trigger(e)}async applyCodeAction(e,t,i,n){const s=this._progressService.show(!0,500);try{await this._instantiationService.invokeFunction(fS,e,n,{preview:i,editor:this._editor})}finally{t&&this._trigger({type:2,triggerAction:be.QuickFix,filter:{}}),s.done()}}hideLightBulbWidget(){this._lightBulbWidget.rawValue?.hide(),this._lightBulbWidget.rawValue?.gutterHide()}async update(e){if(e.type!==1){this.hideLightBulbWidget(),this._lightBulbInfoObs.set(void 0,void 0);return}let t;try{t=this._model.takeCodeActions(await e.actions)}catch(n){a.onUnexpectedError(n);return}if(!t)return;if(this._disposed){t.dispose();return}if(this._editor.getSelection()?.startLineNumber!==e.position.lineNumber){t.dispose();return}if(this._lightBulbWidget.value?.update(t,e.trigger,e.position),this._lightBulbInfoObs.set(rm(t,e.trigger,this._preferredKbLabel.get(),this._quickFixKbLabel.get()),void 0),e.trigger.type===1){if(e.trigger.filter?.include){const s=this.tryGetValidActionToApply(e.trigger,t);if(s){try{this.hideLightBulbWidget(),await this.applyCodeAction(s,!1,!1,Ut.FromCodeActions)}finally{t.dispose()}return}if(e.trigger.context){const r=this.getInvalidActionThatWouldHaveBeenApplied(e.trigger,t);if(r&&r.action.disabled){ve.get(this._editor)?.showMessage(r.action.disabled,e.trigger.context.position),t.dispose();return}}}const n=!!e.trigger.filter?.include;if(e.trigger.context&&(!t.allActions.length||!n&&!t.validActions.length)){ve.get(this._editor)?.showMessage(e.trigger.context.notAvailableMessage,e.trigger.context.position),this._activeCodeActions.value=t,t.dispose();return}this._activeCodeActions.value=t,this.showCodeActionList(t,this.toCoords(e.position),{includeDisabledActions:n,fromLightbulb:!1})}else this._actionWidgetService.isVisible?t.dispose():this._activeCodeActions.value=t}getInvalidActionThatWouldHaveBeenApplied(e,t){if(t.allActions.length&&(e.autoApply==="first"&&t.validActions.length===0||e.autoApply==="ifSingle"&&t.allActions.length===1))return t.allActions.find(({action:i})=>i.disabled)}tryGetValidActionToApply(e,t){if(t.validActions.length&&(e.autoApply==="first"&&t.validActions.length>0||e.autoApply==="ifSingle"&&t.validActions.length===1))return t.validActions[0]}async showCodeActionList(e,t,i){const n=this._editor.createDecorationsCollection(),s=this._editor.getDomNode();if(!s)return;const r=i.includeDisabledActions&&(this._showDisabled||e.validActions.length===0)?e.allActions:e.validActions;if(!r.length)return;const l=a.Position.isIPosition(t)?this.toCoords(t):t,d={onSelect:async(h,u)=>{this.applyCodeAction(h,!0,!!u,i.fromLightbulb?Ut.FromAILightbulb:Ut.FromCodeActions),this._actionWidgetService.hide(!1),n.clear()},onHide:h=>{this._editor?.focus(),n.clear()},onHover:async(h,u)=>{if(u.isCancellationRequested)return;let g=!1;const p=h.action.kind;if(p){const f=new Z(p);g=[q.RefactorExtract,q.RefactorInline,q.RefactorRewrite,q.RefactorMove,q.Source].some(_=>_.contains(f))}return{canPreview:g||!!h.action.edit?.edits.length}},onFocus:h=>{if(h&&h.action){const u=h.action.ranges,g=h.action.diagnostics;if(n.clear(),u&&u.length>0){const p=g&&g?.length>1?g.map(f=>({range:f,options:ds.DECORATION})):u.map(f=>({range:f,options:ds.DECORATION}));n.set(p)}else if(g&&g.length>0){const p=g.map(m=>({range:m,options:ds.DECORATION}));n.set(p);const f=g[0];if(f.startLineNumber&&f.startColumn){const m=this._editor.getModel()?.getWordAtPosition({lineNumber:f.startLineNumber,column:f.startColumn})?.word;o.status(a.localize(914,"Context: {0} at line {1} and column {2}.",m,f.startLineNumber,f.startColumn))}}}else n.clear()}};this._actionWidgetService.show("codeActionWidget",!0,CS(r,this._shouldShowHeaders(),this._resolver.getResolver()),d,l,s,this._getActionBarActions(e,t,i))}toCoords(e){if(!this._editor.hasModel())return{x:0,y:0};this._editor.revealPosition(e,1),this._editor.render();const t=this._editor.getScrolledVisiblePosition(e),i=o.getDomNodePagePosition(this._editor.getDomNode()),n=i.left+t.left,s=i.top+t.top+t.height;return{x:n,y:s}}_shouldShowHeaders(){const e=this._editor?.getModel();return this._configurationService.getValue("editor.codeActionWidget.showHeaders",{resource:e?.uri})}_getActionBarActions(e,t,i){if(i.fromLightbulb)return[];const n=e.documentation.map(s=>({id:s.id,label:s.title,tooltip:s.tooltip??"",class:void 0,enabled:!0,run:()=>this._commandService.executeCommand(s.id,...s.arguments??[])}));return i.includeDisabledActions&&e.validActions.length>0&&e.allActions.length!==e.validActions.length&&n.push(this._showDisabled?{id:"hideMoreActions",label:a.localize(915,"Hide Disabled"),enabled:!0,tooltip:"",class:void 0,run:()=>(this._showDisabled=!1,this.showCodeActionList(e,t,i))}:{id:"showMoreActions",label:a.localize(916,"Show Disabled"),enabled:!0,tooltip:"",class:void 0,run:()=>(this._showDisabled=!0,this.showCodeActionList(e,t,i))}),n}},ds=_i,_i.ID="editor.contrib.codeActionController",_i.DECORATION=o.ModelDecorationOptions.register({description:"quickfix-highlight",className:ES}),_i);qi=ds=xS([Xe(1,o.IMarkerService),Xe(2,o.IContextKeyService),Xe(3,o.IInstantiationService),Xe(4,o.ILanguageFeaturesService),Xe(5,o.IEditorProgressService),Xe(6,o.ICommandService),Xe(7,o.IConfigurationService),Xe(8,Pe),Xe(9,o.IInstantiationService),Xe(10,o.IEditorProgressService),Xe(11,o.IKeybindingService)],qi),o.registerThemingParticipant((c,e)=>{((n,s)=>{s&&e.addRule(`.monaco-editor ${n} { background-color: ${s}; }`)})(".quickfix-edit-highlight",c.getColor(o.editorFindMatchHighlight));const i=c.getColor(o.editorFindMatchHighlightBorder);i&&e.addRule(`.monaco-editor .quickfix-edit-highlight { border: 1px ${o.isHighContrast(c.type)?"dotted":"solid"} ${i}; box-sizing: border-box; }`)});function yo(c){return o.ContextKeyExpr.regex(Hf.keys()[0],new RegExp("(\\s|^)"+a.escapeRegExpCharacters(c.value)+"\\b"))}const Gd={type:"object",defaultSnippets:[{body:{kind:""}}],properties:{kind:{type:"string",description:a.localize(882,"Kind of the code action to run.")},apply:{type:"string",description:a.localize(883,"Controls when the returned actions are applied."),default:"ifSingle",enum:["first","ifSingle","never"],enumDescriptions:[a.localize(884,"Always apply the first returned code action."),a.localize(885,"Apply the first returned code action if it is the only one."),a.localize(886,"Do not apply the returned code actions.")]},preferred:{type:"boolean",default:!1,description:a.localize(887,"Controls if only preferred code actions should be returned.")}}};function Gi(c,e,t,i,n=be.Default){c.hasModel()&&qi.get(c)?.manualTriggerAtCurrentPosition(e,n,t,i)}class LS extends o.EditorAction2{constructor(){super({id:ia,title:a.localize2(904,"Quick Fix..."),precondition:o.ContextKeyExpr.and(o.EditorContextKeys.writable,o.EditorContextKeys.hasCodeActionsProvider),icon:a.Codicon.lightBulb,f1:!0,keybinding:{when:o.EditorContextKeys.textInputFocus,primary:2137,weight:100},menu:{id:o.MenuId.InlineChatEditorAffordance,group:"1_quickfix",order:0,when:o.ContextKeyExpr.and(o.EditorContextKeys.writable,o.EditorContextKeys.hasCodeActionsProvider)}})}runEditorCommand(e,t){return Gi(t,a.localize(888,"No code actions available"),void 0,void 0,be.QuickFix)}}class DS extends o.EditorCommand{constructor(){super({id:Xf,precondition:o.ContextKeyExpr.and(o.EditorContextKeys.writable,o.EditorContextKeys.hasCodeActionsProvider),metadata:{description:"Trigger a code action",args:[{name:"args",schema:Gd}]}})}runEditorCommand(e,t,i){const n=rt.fromUser(i,{kind:Z.Empty,apply:"ifSingle"});return Gi(t,typeof i?.kind=="string"?n.preferred?a.localize(889,"No preferred code actions for '{0}' available",i.kind):a.localize(890,"No code actions for '{0}' available",i.kind):n.preferred?a.localize(891,"No preferred code actions available"):a.localize(892,"No code actions available"),{include:n.kind,includeSourceActions:!0,onlyIncludePreferredActions:n.preferred},n.apply)}}class RS extends o.EditorAction{constructor(){super({id:Yf,label:a.localize2(905,"Refactor..."),precondition:o.ContextKeyExpr.and(o.EditorContextKeys.writable,o.EditorContextKeys.hasCodeActionsProvider),kbOpts:{kbExpr:o.EditorContextKeys.textInputFocus,primary:3120,mac:{primary:1328},weight:100},contextMenuOpts:{group:"1_modification",order:2,when:o.ContextKeyExpr.and(o.EditorContextKeys.writable,yo(q.Refactor))},metadata:{description:"Refactor...",args:[{name:"args",schema:Gd}]}})}run(e,t,i){const n=rt.fromUser(i,{kind:q.Refactor,apply:"never"});return Gi(t,typeof i?.kind=="string"?n.preferred?a.localize(893,"No preferred refactorings for '{0}' available",i.kind):a.localize(894,"No refactorings for '{0}' available",i.kind):n.preferred?a.localize(895,"No preferred refactorings available"):a.localize(896,"No refactorings available"),{include:q.Refactor.contains(n.kind)?n.kind:Z.None,onlyIncludePreferredActions:n.preferred},n.apply,be.Refactor)}}class TS extends o.EditorAction{constructor(){super({id:Qf,label:a.localize2(906,"Source Action..."),precondition:o.ContextKeyExpr.and(o.EditorContextKeys.writable,o.EditorContextKeys.hasCodeActionsProvider),contextMenuOpts:{group:"1_modification",order:2.1,when:o.ContextKeyExpr.and(o.EditorContextKeys.writable,yo(q.Source))},metadata:{description:"Source Action...",args:[{name:"args",schema:Gd}]}})}run(e,t,i){const n=rt.fromUser(i,{kind:q.Source,apply:"never"});return Gi(t,typeof i?.kind=="string"?n.preferred?a.localize(897,"No preferred source actions for '{0}' available",i.kind):a.localize(898,"No source actions for '{0}' available",i.kind):n.preferred?a.localize(899,"No preferred source actions available"):a.localize(900,"No source actions available"),{include:q.Source.contains(n.kind)?n.kind:Z.None,includeSourceActions:!0,onlyIncludePreferredActions:n.preferred},n.apply,be.SourceAction)}}class NS extends o.EditorAction{constructor(){super({id:Ud,label:a.localize2(907,"Organize Imports"),precondition:o.ContextKeyExpr.and(o.EditorContextKeys.writable,yo(q.SourceOrganizeImports)),kbOpts:{kbExpr:o.EditorContextKeys.textInputFocus,primary:1581,weight:100},metadata:{description:a.localize2(908,"Organize imports in the current file. Also called 'Optimize Imports' by some tools")}})}run(e,t){return Gi(t,a.localize(901,"No organize imports action available"),{include:q.SourceOrganizeImports,includeSourceActions:!0},"ifSingle",be.OrganizeImports)}}class MS extends o.EditorAction{constructor(){super({id:$d,label:a.localize2(909,"Fix All"),precondition:o.ContextKeyExpr.and(o.EditorContextKeys.writable,yo(q.SourceFixAll))})}run(e,t){return Gi(t,a.localize(902,"No fix all action available"),{include:q.SourceFixAll,includeSourceActions:!0},"ifSingle",be.FixAll)}}class PS extends o.EditorAction{constructor(){super({id:kd,label:a.localize2(910,"Auto Fix..."),precondition:o.ContextKeyExpr.and(o.EditorContextKeys.writable,yo(q.QuickFix)),kbOpts:{kbExpr:o.EditorContextKeys.textInputFocus,primary:1625,mac:{primary:2649},weight:100}})}run(e,t){return Gi(t,a.localize(903,"No auto fixes available"),{include:q.QuickFix,onlyIncludePreferredActions:!0},"ifSingle",be.AutoFix)}}o.registerEditorContribution(qi.ID,qi,3),o.registerEditorContribution(So.ID,So,4),o.registerAction2(LS),o.registerEditorAction(RS),o.registerEditorAction(TS),o.registerEditorAction(NS),o.registerEditorAction(PS),o.registerEditorAction(MS),o.registerEditorCommand(new DS),o.Registry.as(o.Extensions.Configuration).registerConfiguration({...o.editorConfigurationBaseNode,properties:{"editor.codeActionWidget.showHeaders":{type:"boolean",scope:6,description:a.localize(911,"Enable/disable showing group headers in the Code Action menu."),default:!0}}}),o.Registry.as(o.Extensions.Configuration).registerConfiguration({...o.editorConfigurationBaseNode,properties:{"editor.codeActionWidget.includeNearbyQuickFixes":{type:"boolean",scope:6,description:a.localize(912,"Enable/disable showing nearest Quick Fix within a line when not currently on a diagnostic."),default:!0}}}),o.Registry.as(o.Extensions.Configuration).registerConfiguration({...o.editorConfigurationBaseNode,properties:{"editor.codeActions.triggerOnFocusChange":{type:"boolean",scope:6,markdownDescription:a.localize(913,"Enable triggering {0} when {1} is set to {2}. Code Actions must be set to {3} to be triggered for window and focus changes.","`#editor.codeActionsOnSave#`","`#files.autoSave#`","`afterDelay`","`always`"),default:!1}}});const xc=class xc{constructor(){this.lenses=[]}dispose(){this._store?.dispose()}get isDisposed(){return this._store?.isDisposed??!1}add(e,t){a.isDisposable(e)&&(this._store??=new a.DisposableStore,this._store.add(e));for(const i of e.lenses)this.lenses.push({symbol:i,provider:t})}};xc.Empty=new xc;let hs=xc;async function am(c,e,t){const i=c.ordered(e),n=new Map,s=new hs,r=i.map(async(l,d)=>{n.set(l,d);try{const h=await Promise.resolve(l.provideCodeLenses(e,t));h&&s.add(h,l)}catch(h){a.onUnexpectedExternalError(h)}});return await Promise.all(r),t.isCancellationRequested?(s.dispose(),hs.Empty):(s.lenses=s.lenses.sort((l,d)=>l.symbol.range.startLineNumber<d.symbol.range.startLineNumber?-1:l.symbol.range.startLineNumber>d.symbol.range.startLineNumber?1:n.get(l.provider)<n.get(d.provider)?-1:n.get(l.provider)>n.get(d.provider)?1:l.symbol.range.startColumn<d.symbol.range.startColumn?-1:l.symbol.range.startColumn>d.symbol.range.startColumn?1:0),s)}o.CommandsRegistry.registerCommand("_executeCodeLensProvider",function(c,...e){let[t,i]=e;a.assertType(a.URI.isUri(t)),a.assertType(typeof i=="number"||!i);const{codeLensProvider:n}=c.get(o.ILanguageFeaturesService),s=c.get(o.IModelService).getModel(t);if(!s)throw a.illegalArgument();const r=[],l=new a.DisposableStore;return am(n,s,a.CancellationToken.None).then(d=>{l.add(d);const h=[];for(const u of d.lenses)i==null||u.symbol.command?r.push(u.symbol):i-- >0&&u.provider.resolveCodeLens&&h.push(Promise.resolve(u.provider.resolveCodeLens(s,u.symbol,a.CancellationToken.None)).then(g=>r.push(g||u.symbol)));return Promise.all(h)}).then(()=>r).finally(()=>{setTimeout(()=>l.dispose(),100)})});var OS=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},AS=function(c,e){return function(t,i){e(t,i,c)}};const lm=o.createDecorator("ICodeLensCache");class cm{constructor(e,t){this.lineCount=e,this.data=t}}let Zd=class{constructor(e){this._fakeProvider=new class{provideCodeLenses(){throw new Error("not supported")}},this._cache=new a.LRUCache(20,.75);const t="codelens/cache";o.runWhenWindowIdle(o.mainWindow,()=>e.remove(t,1));const i="codelens/cache2",n=e.get(i,1,"{}");this._deserialize(n);const s=a.Event.filter(e.onWillSaveState,r=>r.reason===o.WillSaveStateReason.SHUTDOWN);a.Event.once(s)(r=>{e.store(i,this._serialize(),1,1)})}put(e,t){const i=t.lenses.map(r=>({range:r.symbol.range,command:r.symbol.command&&{id:"",title:r.symbol.command?.title}})),n=new hs;n.add({lenses:i},this._fakeProvider);const s=new cm(e.getLineCount(),n);this._cache.set(e.uri.toString(),s)}get(e){const t=this._cache.get(e.uri.toString());return t&&t.lineCount===e.getLineCount()?t.data:void 0}delete(e){this._cache.delete(e.uri.toString())}_serialize(){const e=Object.create(null);for(const[t,i]of this._cache){const n=new Set;for(const s of i.data.lenses)n.add(s.symbol.range.startLineNumber);e[t]={lineCount:i.lineCount,lines:[...n.values()]}}return JSON.stringify(e)}_deserialize(e){try{const t=JSON.parse(e);for(const i in t){const n=t[i],s=[];for(const l of n.lines)s.push({range:new a.Range(l,1,l,11)});const r=new hs;r.add({lenses:s},this._fakeProvider),this._cache.set(i,new cm(n.lineCount,r))}}catch{}}};Zd=OS([AS(0,o.IStorageService)],Zd),o.registerSingleton(lm,Zd,1);class FS{constructor(e,t,i){this.afterColumn=1073741824,this.afterLineNumber=e,this.heightInPx=t,this._onHeight=i,this.suppressMouseDown=!0,this.domNode=document.createElement("div")}onComputedHeight(e){this._lastHeight===void 0?this._lastHeight=e:this._lastHeight!==e&&(this._lastHeight=e,this._onHeight())}isVisible(){return this._lastHeight!==0&&this.domNode.hasAttribute("monaco-visible-view-zone")}}const qr=class qr{constructor(e,t){this.allowEditorOverflow=!1,this.suppressMouseDown=!0,this._commands=new Map,this._isEmpty=!0,this._editor=e,this._id=`codelens.widget-${qr._idPool++}`,this.updatePosition(t),this._domNode=document.createElement("span"),this._domNode.className="codelens-decoration"}withCommands(e,t){this._commands.clear();const i=[];let n=!1;for(let s=0;s<e.length;s++){const r=e[s];if(r&&(n=!0,r.command)){const l=o.renderLabelWithIcons(r.command.title.trim());if(r.command.id){const d=`c${qr._idPool++}`;i.push(o.$("a",{id:d,title:r.command.tooltip,role:"button"},...l)),this._commands.set(d,r.command)}else i.push(o.$("span",{title:r.command.tooltip},...l));s+1<e.length&&i.push(o.$("span",void 0," | "))}}n?(o.reset(this._domNode,...i),this._isEmpty&&t&&this._domNode.classList.add("fadein"),this._isEmpty=!1):o.reset(this._domNode,o.$("span",void 0,"no commands"))}getCommand(e){return e.parentElement===this._domNode?this._commands.get(e.id):void 0}getId(){return this._id}getDomNode(){return this._domNode}updatePosition(e){const t=this._editor.getModel().getLineFirstNonWhitespaceColumn(e);this._widgetPosition={position:{lineNumber:e,column:t},preference:[1]}}getPosition(){return this._widgetPosition||null}};qr._idPool=0;let Xd=qr;class Yd{constructor(){this._removeDecorations=[],this._addDecorations=[],this._addDecorationsCallbacks=[]}addDecoration(e,t){this._addDecorations.push(e),this._addDecorationsCallbacks.push(t)}removeDecoration(e){this._removeDecorations.push(e)}commit(e){const t=e.deltaDecorations(this._removeDecorations,this._addDecorations);for(let i=0,n=t.length;i<n;i++)this._addDecorationsCallbacks[i](t[i])}}const dm=o.ModelDecorationOptions.register({collapseOnReplaceEdit:!0,description:"codelens"});class hm{constructor(e,t,i,n,s,r){this._isDisposed=!1,this._editor=t,this._data=e,this._decorationIds=[];let l;const d=[];this._data.forEach((h,u)=>{h.symbol.command&&d.push(h.symbol),i.addDecoration({range:h.symbol.range,options:dm},g=>this._decorationIds[u]=g),l?l=a.Range.plusRange(l,h.symbol.range):l=a.Range.lift(h.symbol.range)}),this._viewZone=new FS(l.startLineNumber-1,s,r),this._viewZoneId=n.addZone(this._viewZone),d.length>0&&(this._createContentWidgetIfNecessary(),this._contentWidget.withCommands(d,!1))}_createContentWidgetIfNecessary(){this._contentWidget?this._editor.layoutContentWidget(this._contentWidget):(this._contentWidget=new Xd(this._editor,this._viewZone.afterLineNumber+1),this._editor.addContentWidget(this._contentWidget))}dispose(e,t){this._decorationIds.forEach(e.removeDecoration,e),this._decorationIds=[],t?.removeZone(this._viewZoneId),this._contentWidget&&(this._editor.removeContentWidget(this._contentWidget),this._contentWidget=void 0),this._isDisposed=!0}isDisposed(){return this._isDisposed}isValid(){return this._decorationIds.some((e,t)=>{const i=this._editor.getModel().getDecorationRange(e),n=this._data[t].symbol;return!!(i&&a.Range.isEmpty(n.range)===i.isEmpty())})}updateCodeLensSymbols(e,t){this._decorationIds.forEach(t.removeDecoration,t),this._decorationIds=[],this._data=e,this._data.forEach((i,n)=>{t.addDecoration({range:i.symbol.range,options:dm},s=>this._decorationIds[n]=s)})}updateHeight(e,t){this._viewZone.heightInPx=e,t.layoutZone(this._viewZoneId),this._contentWidget&&this._editor.layoutContentWidget(this._contentWidget)}computeIfNecessary(e){if(!this._viewZone.isVisible())return null;for(let t=0;t<this._decorationIds.length;t++){const i=e.getDecorationRange(this._decorationIds[t]);i&&(this._data[t].symbol.range=i)}return this._data}updateCommands(e){this._createContentWidgetIfNecessary(),this._contentWidget.withCommands(e,!0);for(let t=0;t<this._data.length;t++){const i=e[t];if(i){const{symbol:n}=this._data[t];n.command=i.command||n.command}}}getCommand(e){return this._contentWidget?.getCommand(e)}getLineNumber(){const e=this._editor.getModel().getDecorationRange(this._decorationIds[0]);return e?e.startLineNumber:-1}update(e){if(this.isValid()){const t=this._editor.getModel().getDecorationRange(this._decorationIds[0]);t&&(this._viewZone.afterLineNumber=t.startLineNumber-1,e.layoutZone(this._viewZoneId),this._contentWidget&&(this._contentWidget.updatePosition(t.startLineNumber),this._editor.layoutContentWidget(this._contentWidget)))}}}var zS=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},wo=function(c,e){return function(t,i){e(t,i,c)}};let Io=(Ws=class{constructor(e,t,i,n,s,r){this._editor=e,this._languageFeaturesService=t,this._commandService=n,this._notificationService=s,this._codeLensCache=r,this._disposables=new a.DisposableStore,this._localToDispose=new a.DisposableStore,this._lenses=[],this._oldCodeLensModels=new a.DisposableStore,this._provideCodeLensDebounce=i.for(t.codeLensProvider,"CodeLensProvide",{min:250}),this._resolveCodeLensesDebounce=i.for(t.codeLensProvider,"CodeLensResolve",{min:250,salt:"resolve"}),this._resolveCodeLensesScheduler=new a.RunOnceScheduler(()=>this._resolveCodeLensesInViewport(),this._resolveCodeLensesDebounce.default()),this._disposables.add(this._editor.onDidChangeModel(()=>this._onModelChange())),this._disposables.add(this._editor.onDidChangeModelLanguage(()=>this._onModelChange())),this._disposables.add(this._editor.onDidChangeConfiguration(l=>{(l.hasChanged(59)||l.hasChanged(25)||l.hasChanged(24))&&this._updateLensStyle(),l.hasChanged(23)&&this._onModelChange()})),this._disposables.add(t.codeLensProvider.onDidChange(this._onModelChange,this)),this._onModelChange(),this._updateLensStyle()}dispose(){this._localDispose(),this._localToDispose.dispose(),this._disposables.dispose(),this._resolveCodeLensesScheduler.dispose(),this._oldCodeLensModels.dispose(),this._currentCodeLensModel?.dispose()}_getLayoutInfo(){const e=Math.max(1.3,this._editor.getOption(75)/this._editor.getOption(61));let t=this._editor.getOption(25);return(!t||t<5)&&(t=this._editor.getOption(61)*.9|0),{fontSize:t,codeLensHeight:t*e|0}}_updateLensStyle(){const{codeLensHeight:e,fontSize:t}=this._getLayoutInfo(),i=this._editor.getOption(24),n=this._editor.getOption(59),{style:s}=this._editor.getContainerDomNode();s.setProperty("--vscode-editorCodeLens-lineHeight",`${e}px`),s.setProperty("--vscode-editorCodeLens-fontSize",`${t}px`),s.setProperty("--vscode-editorCodeLens-fontFeatureSettings",n.fontFeatureSettings),i&&(s.setProperty("--vscode-editorCodeLens-fontFamily",i),s.setProperty("--vscode-editorCodeLens-fontFamilyDefault",o.EDITOR_FONT_DEFAULTS.fontFamily)),this._editor.changeViewZones(r=>{for(const l of this._lenses)l.updateHeight(e,r)})}_localDispose(){this._getCodeLensModelPromise?.cancel(),this._getCodeLensModelPromise=void 0,this._resolveCodeLensesPromise?.cancel(),this._resolveCodeLensesPromise=void 0,this._localToDispose.clear(),this._oldCodeLensModels.clear(),this._currentCodeLensModel?.dispose()}_onModelChange(){this._localDispose();const e=this._editor.getModel();if(!e||!this._editor.getOption(23)||e.isTooLargeForTokenization())return;const t=this._codeLensCache.get(e);if(t&&this._renderCodeLensSymbols(t),!this._languageFeaturesService.codeLensProvider.has(e)){t&&a.disposableTimeout(()=>{const n=this._codeLensCache.get(e);t===n&&(this._codeLensCache.delete(e),this._onModelChange())},30*1e3,this._localToDispose);return}for(const n of this._languageFeaturesService.codeLensProvider.all(e))if(typeof n.onDidChange=="function"){const s=n.onDidChange(()=>i.schedule());this._localToDispose.add(s)}const i=new a.RunOnceScheduler(()=>{const n=Date.now();this._getCodeLensModelPromise?.cancel(),this._getCodeLensModelPromise=a.createCancelablePromise(s=>am(this._languageFeaturesService.codeLensProvider,e,s)),this._getCodeLensModelPromise.then(s=>{this._currentCodeLensModel&&this._oldCodeLensModels.add(this._currentCodeLensModel),this._currentCodeLensModel=s,this._codeLensCache.put(e,s);const r=this._provideCodeLensDebounce.update(e,Date.now()-n);i.delay=r,this._renderCodeLensSymbols(s),this._resolveCodeLensesInViewportSoon()},a.onUnexpectedError)},this._provideCodeLensDebounce.get(e));this._localToDispose.add(i),this._localToDispose.add(a.toDisposable(()=>this._resolveCodeLensesScheduler.cancel())),this._localToDispose.add(this._editor.onDidChangeModelContent(()=>{this._editor.changeDecorations(n=>{this._editor.changeViewZones(s=>{const r=[];let l=-1;this._lenses.forEach(h=>{!h.isValid()||l===h.getLineNumber()?r.push(h):(h.update(s),l=h.getLineNumber())});const d=new Yd;r.forEach(h=>{h.dispose(d,s),this._lenses.splice(this._lenses.indexOf(h),1)}),d.commit(n)})}),i.schedule(),this._resolveCodeLensesScheduler.cancel(),this._resolveCodeLensesPromise?.cancel(),this._resolveCodeLensesPromise=void 0})),this._localToDispose.add(this._editor.onDidFocusEditorText(()=>{i.schedule()})),this._localToDispose.add(this._editor.onDidBlurEditorText(()=>{i.cancel()})),this._localToDispose.add(this._editor.onDidScrollChange(n=>{n.scrollTopChanged&&this._lenses.length>0&&this._resolveCodeLensesInViewportSoon()})),this._localToDispose.add(this._editor.onDidLayoutChange(()=>{this._resolveCodeLensesInViewportSoon()})),this._localToDispose.add(a.toDisposable(()=>{if(this._editor.getModel()){const n=o.StableEditorScrollState.capture(this._editor);this._editor.changeDecorations(s=>{this._editor.changeViewZones(r=>{this._disposeAllLenses(s,r)})}),n.restore(this._editor)}else this._disposeAllLenses(void 0,void 0)})),this._localToDispose.add(this._editor.onMouseDown(n=>{if(n.target.type!==9)return;let s=n.target.element;if(s?.tagName==="SPAN"&&(s=s.parentElement),s?.tagName==="A")for(const r of this._lenses){const l=r.getCommand(s);if(l){this._commandService.executeCommand(l.id,...l.arguments||[]).catch(d=>this._notificationService.error(d));break}}})),i.schedule()}_disposeAllLenses(e,t){const i=new Yd;for(const n of this._lenses)n.dispose(i,t);e&&i.commit(e),this._lenses.length=0}_renderCodeLensSymbols(e){if(!this._editor.hasModel())return;const t=this._editor.getModel().getLineCount(),i=[];let n;for(const l of e.lenses){const d=l.symbol.range.startLineNumber;d<1||d>t||(n&&n[n.length-1].symbol.range.startLineNumber===d?n.push(l):(n=[l],i.push(n)))}if(!i.length&&!this._lenses.length)return;const s=o.StableEditorScrollState.capture(this._editor),r=this._getLayoutInfo();this._editor.changeDecorations(l=>{this._editor.changeViewZones(d=>{const h=new Yd;let u=0,g=0;for(;g<i.length&&u<this._lenses.length;){const p=i[g][0].symbol.range.startLineNumber,f=this._lenses[u].getLineNumber();f<p?(this._lenses[u].dispose(h,d),this._lenses.splice(u,1)):f===p?(this._lenses[u].updateCodeLensSymbols(i[g],h),g++,u++):(this._lenses.splice(u,0,new hm(i[g],this._editor,h,d,r.codeLensHeight,()=>this._resolveCodeLensesInViewportSoon())),u++,g++)}for(;u<this._lenses.length;)this._lenses[u].dispose(h,d),this._lenses.splice(u,1);for(;g<i.length;)this._lenses.push(new hm(i[g],this._editor,h,d,r.codeLensHeight,()=>this._resolveCodeLensesInViewportSoon())),g++;h.commit(l)})}),s.restore(this._editor)}_resolveCodeLensesInViewportSoon(){this._editor.getModel()&&this._resolveCodeLensesScheduler.schedule()}_resolveCodeLensesInViewport(){this._resolveCodeLensesPromise?.cancel(),this._resolveCodeLensesPromise=void 0;const e=this._editor.getModel();if(!e)return;const t=[],i=[];if(this._lenses.forEach(r=>{const l=r.computeIfNecessary(e);l&&(t.push(l),i.push(r))}),t.length===0){this._oldCodeLensModels.clear();return}const n=Date.now(),s=a.createCancelablePromise(r=>{const l=t.map((d,h)=>{const u=new Array(d.length),g=d.map((p,f)=>!p.symbol.command&&typeof p.provider.resolveCodeLens=="function"?Promise.resolve(p.provider.resolveCodeLens(e,p.symbol,r)).then(m=>{u[f]=m},a.onUnexpectedExternalError):(u[f]=p.symbol,Promise.resolve(void 0)));return Promise.all(g).then(()=>{!r.isCancellationRequested&&!i[h].isDisposed()&&i[h].updateCommands(u)})});return Promise.all(l)});this._resolveCodeLensesPromise=s,this._resolveCodeLensesPromise.then(()=>{const r=this._resolveCodeLensesDebounce.update(e,Date.now()-n);this._resolveCodeLensesScheduler.delay=r,this._currentCodeLensModel&&this._codeLensCache.put(e,this._currentCodeLensModel),this._oldCodeLensModels.clear(),s===this._resolveCodeLensesPromise&&(this._resolveCodeLensesPromise=void 0)},r=>{a.onUnexpectedError(r),s===this._resolveCodeLensesPromise&&(this._resolveCodeLensesPromise=void 0)})}async getModel(){return await this._getCodeLensModelPromise,await this._resolveCodeLensesPromise,this._currentCodeLensModel?.isDisposed?void 0:this._currentCodeLensModel}},Ws.ID="css.editor.codeLens",Ws);Io=zS([wo(1,o.ILanguageFeaturesService),wo(2,o.ILanguageFeatureDebounceService),wo(3,o.ICommandService),wo(4,o.INotificationService),wo(5,lm)],Io),o.registerEditorContribution(Io.ID,Io,1),o.registerEditorAction(class extends o.EditorAction{constructor(){super({id:"codelens.showLensesInCurrentLine",precondition:o.EditorContextKeys.hasCodeLensProvider,label:a.localize2(935,"Show CodeLens Commands for Current Line")})}async run(e,t){if(!t.hasModel())return;const i=e.get(o.IQuickInputService),n=e.get(o.ICommandService),s=e.get(o.INotificationService),r=t.getSelection().positionLineNumber,l=t.getContribution(Io.ID);if(!l)return;const d=await l.getModel();if(!d)return;const h=[];for(const p of d.lenses)p.symbol.command&&p.symbol.range.startLineNumber===r&&h.push({label:p.symbol.command.title,command:p.symbol.command});if(h.length===0)return;const u=await i.pick(h,{canPickMany:!1,placeHolder:a.localize(934,"Select a command")});if(!u)return;let g=u.command;if(d.isDisposed){const f=(await l.getModel())?.lenses.find(m=>m.symbol.range.startLineNumber===r&&m.symbol.command?.title===g.title);if(!f||!f.symbol.command)return;g=f.symbol.command}try{await n.executeCommand(g.id,...g.arguments||[])}catch(p){s.error(p)}}});class Qd{constructor(e,t,i,n){this.priority=e,this.range=t,this.initialMousePosX=i,this.initialMousePosY=n,this.type=1}equals(e){return e.type===1&&this.range.equalsRange(e.range)}canAdoptVisibleHover(e,t){return e.type===1&&t.lineNumber===this.range.startLineNumber}}class xo{constructor(e,t,i,n,s,r){this.priority=e,this.owner=t,this.range=i,this.initialMousePosX=n,this.initialMousePosY=s,this.supportsMarkerHover=r,this.type=2}equals(e){return e.type===2&&this.owner===e.owner}canAdoptVisibleHover(e,t){return e.type===2&&this.owner===e.owner}}class Zi{constructor(e,t){this.renderedHoverParts=e,this.disposables=t}dispose(){for(const e of this.renderedHoverParts)e.dispose();this.disposables?.dispose()}}const Xi=new class{constructor(){this._participants=[]}register(e){this._participants.push(e)}getAll(){return this._participants}};var um=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Jd=function(c,e){return function(t,i){e(t,i,c)}};let Eo=class{constructor(e){this._editorWorkerService=e}async provideDocumentColors(e,t){return this._editorWorkerService.computeDefaultDocumentColors(e.uri)}provideColorPresentations(e,t,i){const n=t.range,s=t.color,r=new a.Color(new a.RGBA(Math.round(255*s.red),Math.round(255*s.green),Math.round(255*s.blue),s.alpha)),l=a.Color.Format.CSS.formatRGB(r),d=a.Color.Format.CSS.formatHSL(r),h=a.Color.Format.CSS.formatHexA(r,!0),u=[];return u.push({label:l,textEdit:{range:n,text:l}}),u.push({label:d,textEdit:{range:n,text:d}}),u.push({label:h,textEdit:{range:n,text:h}}),u}};Eo=um([Jd(0,o.IEditorWorkerService)],Eo);let Wd=class extends a.Disposable{constructor(e,t){super(),this._register(e.colorProvider.register("*",new Eo(t)))}};Wd=um([Jd(0,o.ILanguageFeaturesService),Jd(1,o.IEditorWorkerService)],Wd);async function gm(c,e,t,i="auto"){return Hd(new VS,c,e,t,i)}function pm(c,e,t,i){return Promise.resolve(t.provideColorPresentations(c,e,i))}class VS{constructor(){}async compute(e,t,i,n){const s=await e.provideDocumentColors(t,i);if(Array.isArray(s))for(const r of s)n.push({colorInfo:r,provider:e});return Array.isArray(s)}}class BS{constructor(){}async compute(e,t,i,n){const s=await e.provideDocumentColors(t,i);if(Array.isArray(s))for(const r of s)n.push({range:r.range,color:[r.color.red,r.color.green,r.color.blue,r.color.alpha]});return Array.isArray(s)}}class KS{constructor(e){this.colorInfo=e}async compute(e,t,i,n){const s=await e.provideColorPresentations(t,this.colorInfo,a.CancellationToken.None);return Array.isArray(s)&&n.push(...s),Array.isArray(s)}}async function Hd(c,e,t,i,n){let s=!1,r;const l=[],d=e.ordered(t);for(let h=d.length-1;h>=0;h--){const u=d[h];if(n!=="always"&&u instanceof Eo)r=u;else try{await c.compute(u,t,i,l)&&(s=!0)}catch(g){a.onUnexpectedExternalError(g)}}return s?l:r&&n!=="never"?(await c.compute(r,t,i,l),l):[]}function fm(c,e){const{colorProvider:t}=c.get(o.ILanguageFeaturesService),i=c.get(o.IModelService).getModel(e);if(!i)throw a.illegalArgument();const n=c.get(o.IConfigurationService).getValue("editor.defaultColorDecorators",{resource:e});return{model:i,colorProviderRegistry:t,defaultColorDecoratorsEnablement:n}}var kS=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},eh=function(c,e){return function(t,i){e(t,i,c)}},Yi;const mm=Object.create({});let us=(mt=class extends a.Disposable{constructor(e,t,i,n){super(),this._editor=e,this._configurationService=t,this._languageFeaturesService=i,this._localToDispose=this._register(new a.DisposableStore),this._decorationsIds=[],this._colorDatas=new Map,this._decoratorLimitReporter=this._register(new US),this._colorDecorationClassRefs=this._register(new a.DisposableStore),this._colorDecoratorIds=this._editor.createDecorationsCollection(),this._ruleFactory=this._register(new o.DynamicCssRules(this._editor));const s=this._editor.getContainerDomNode();s.style.setProperty("--vscode-colorPicker-colorDecoratorWidth",`${Yi.colorDecoratorInnerWidthInEm}em`),s.style.setProperty("--vscode-colorPicker-colorDecoratorMargin",`${Yi.colorDecoratorMarginInEm}em`),this._register(a.toDisposable(()=>{s.style.removeProperty("--vscode-colorPicker-colorDecoratorWidth"),s.style.removeProperty("--vscode-colorPicker-colorDecoratorMargin")})),this._debounceInformation=n.for(i.colorProvider,"Document Colors",{min:Yi.RECOMPUTE_TIME}),this._register(e.onDidChangeModel(()=>{this._isColorDecoratorsEnabled=this.isEnabled(),this.updateColors()})),this._register(e.onDidChangeModelLanguage(()=>this.updateColors())),this._register(i.colorProvider.onDidChange(()=>this.updateColors())),this._register(e.onDidChangeConfiguration(r=>{const l=this._isColorDecoratorsEnabled;this._isColorDecoratorsEnabled=this.isEnabled(),this._defaultColorDecoratorsEnablement=this._editor.getOption(168);const d=l!==this._isColorDecoratorsEnabled||r.hasChanged(27),h=r.hasChanged(168);(d||h)&&(this._isColorDecoratorsEnabled?this.updateColors():this.removeAllDecorations())})),this._timeoutTimer=null,this._computePromise=null,this._isColorDecoratorsEnabled=this.isEnabled(),this._defaultColorDecoratorsEnablement=this._editor.getOption(168),this.updateColors()}isEnabled(){const e=this._editor.getModel();if(!e)return!1;const t=e.getLanguageId(),i=this._configurationService.getValue(t);if(i&&typeof i=="object"){const n=i.colorDecorators;if(n&&n.enable!==void 0&&!n.enable)return n.enable}return this._editor.getOption(26)}static get(e){return e.getContribution(this.ID)}dispose(){this.stop(),this.removeAllDecorations(),super.dispose()}updateColors(){if(this.stop(),!this._isColorDecoratorsEnabled){this.removeAllDecorations();return}const e=this._editor.getModel();!e||!this._languageFeaturesService.colorProvider.has(e)||(this._localToDispose.add(this._editor.onDidChangeModelContent(()=>{this._timeoutTimer||(this._timeoutTimer=new a.TimeoutTimer,this._timeoutTimer.cancelAndSet(()=>{this._timeoutTimer=null,this.beginCompute()},this._debounceInformation.get(e)))})),this.beginCompute())}async beginCompute(){this._computePromise=a.createCancelablePromise(async e=>{const t=this._editor.getModel();if(!t)return[];const i=new a.StopWatch(!1),n=await gm(this._languageFeaturesService.colorProvider,t,e,this._defaultColorDecoratorsEnablement);return this._debounceInformation.update(t,i.elapsed()),n});try{const e=await this._computePromise;this.updateDecorations(e),this.updateColorDecorators(e),this._computePromise=null}catch(e){a.onUnexpectedError(e)}}stop(){this._timeoutTimer&&(this._timeoutTimer.cancel(),this._timeoutTimer=null),this._computePromise&&(this._computePromise.cancel(),this._computePromise=null),this._localToDispose.clear()}updateDecorations(e){const t=e.map(i=>({range:{startLineNumber:i.colorInfo.range.startLineNumber,startColumn:i.colorInfo.range.startColumn,endLineNumber:i.colorInfo.range.endLineNumber,endColumn:i.colorInfo.range.endColumn},options:o.ModelDecorationOptions.EMPTY}));this._editor.changeDecorations(i=>{this._decorationsIds=i.deltaDecorations(this._decorationsIds,t),this._colorDatas=new Map,this._decorationsIds.forEach((n,s)=>this._colorDatas.set(n,e[s]))})}updateColorDecorators(e){this._colorDecorationClassRefs.clear();const t=[],i=Yi.colorDecoratorInnerWidthInEm+2*Yi.colorDecoratorMarginInEm,n=this._editor.getOption(27);for(let r=0;r<e.length&&t.length<n;r++){const{red:l,green:d,blue:h,alpha:u}=e[r].colorInfo.color,g=new a.RGBA(Math.round(l*255),Math.round(d*255),Math.round(h*255),u),p=`rgba(${g.r}, ${g.g}, ${g.b}, ${g.a})`,f=this._colorDecorationClassRefs.add(this._ruleFactory.createClassNameRef({backgroundColor:p}));t.push({range:{startLineNumber:e[r].colorInfo.range.startLineNumber,startColumn:e[r].colorInfo.range.startColumn,endLineNumber:e[r].colorInfo.range.endLineNumber,endColumn:e[r].colorInfo.range.endColumn},options:{description:"colorDetector",before:{content:a.noBreakWhitespace,inlineClassName:`${f.className} colorpicker-color-decoration`,inlineClassNameAffectsLetterSpacing:!0,attachedData:mm,widthInEm:i}}})}const s=n<e.length?n:!1;this._decoratorLimitReporter.update(e.length,s),this._colorDecoratorIds.set(t)}removeAllDecorations(){this._editor.removeDecorations(this._decorationsIds),this._decorationsIds=[],this._colorDecoratorIds.clear(),this._colorDecorationClassRefs.clear()}getColorData(e){const t=this._editor.getModel();if(!t)return null;const i=t.getDecorationsInRange(a.Range.fromPositions(e,e)).filter(n=>this._colorDatas.has(n.id));return i.length===0?null:this._colorDatas.get(i[0].id)}isColorDecoration(e){return this._colorDecoratorIds.has(e)}},Yi=mt,mt.ID="editor.contrib.colorDetector",mt.RECOMPUTE_TIME=1e3,mt.colorDecoratorInnerWidthInEm=.8,mt.colorDecoratorMarginInEm=.2,mt);us=Yi=kS([eh(1,o.IConfigurationService),eh(2,o.ILanguageFeaturesService),eh(3,o.ILanguageFeatureDebounceService)],us);class US extends a.Disposable{constructor(){super(...arguments),this._onDidChange=this._register(new a.Emitter),this._computed=0,this._limited=!1}update(e,t){(e!==this._computed||t!==this._limited)&&(this._computed=e,this._limited=t,this._onDidChange.fire())}}const _m="editor.action.showHover",$S="editor.action.showDefinitionPreviewHover",jS="editor.action.hideHover",qS="editor.action.scrollUpHover",GS="editor.action.scrollDownHover",ZS="editor.action.scrollLeftHover",XS="editor.action.scrollRightHover",YS="editor.action.pageUpHover",QS="editor.action.pageDownHover",JS="editor.action.goToTopHover",WS="editor.action.goToBottomHover",na="editor.action.increaseHoverVerbosityLevel",HS=a.localize(1160,"Increase Hover Verbosity Level"),sa="editor.action.decreaseHoverVerbosityLevel",ey=a.localize(1161,"Decrease Hover Verbosity Level"),th="editor.action.hideLongLineWarningHover",Qi="editor.action.inlineSuggest.commit",oa="editor.action.inlineSuggest.commitAlternativeAction",vm="editor.action.inlineSuggest.showPrevious",bm="editor.action.inlineSuggest.showNext",ih="editor.action.inlineSuggest.jump",Cm="editor.action.inlineSuggest.hide",nh="editor.action.inlineSuggest.toggleShowCollapsed",Sm="editor.action.inlineSuggest.renameSymbol";var sh=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Ae=function(c,e){return function(t,i){e(t,i,c)}},ra;let oh=class extends a.Disposable{constructor(e,t,i){super(),this.editor=e,this.model=t,this.instantiationService=i,this.alwaysShowToolbar=o.observableFromEvent(this,this.editor.onDidChangeConfiguration,()=>this.editor.getOption(71).showToolbar==="always"),this.sessionPosition=void 0,this.position=o.derived(this,n=>{const s=this.model.read(n)?.primaryGhostText.read(n);if(!this.alwaysShowToolbar.read(n)||!s||s.parts.length===0)return this.sessionPosition=void 0,null;const r=s.parts[0].column;this.sessionPosition&&this.sessionPosition.lineNumber!==s.lineNumber&&(this.sessionPosition=void 0);const l=new a.Position(s.lineNumber,Math.min(r,this.sessionPosition?.column??Number.MAX_SAFE_INTEGER));return this.sessionPosition=l,l}),this._register(o.autorunWithStore((n,s)=>{const r=this.model.read(n);if(!r||!this.alwaysShowToolbar.read(n))return;const l=o.derived(h=>{const u=h.store.add(this.instantiationService.createInstance(gs.hot.read(h),this.editor,!0,this.position,r.selectedInlineCompletionIndex,r.inlineCompletionsCount,r.activeCommands,r.warning,()=>{}));return e.addContentWidget(u),h.store.add(a.toDisposable(()=>e.removeContentWidget(u))),h.store.add(o.autorun(g=>{this.position.read(g)&&r.lastTriggerKind.read(g)!==a.InlineCompletionTriggerKind.Explicit&&r.triggerExplicitly()})),u}),d=o.derivedObservableWithCache(this,(h,u)=>!!this.position.read(h)||!!u);s.add(o.autorun(h=>{d.read(h)&&l.read(h)}))}))}};oh=sh([Ae(2,o.IInstantiationService)],oh);const ty=o.registerIcon("inline-suggestion-hints-next",a.Codicon.chevronRight,a.localize(1270,"Icon for show next parameter hint.")),iy=o.registerIcon("inline-suggestion-hints-previous",a.Codicon.chevronLeft,a.localize(1271,"Icon for show previous parameter hint."));let gs=(_t=class extends a.Disposable{static get dropDownVisible(){return this._dropDownVisible}createCommandAction(e,t,i){const n=new o.Action(e,t,i,!0,()=>this._commandService.executeCommand(e));return n.tooltip=this.keybindingService.appendKeybinding(t,e,this._contextKeyService),n}constructor(e,t,i,n,s,r,l,d,h,u,g,p,f){super(),this.editor=e,this.withBorder=t,this._position=i,this._currentSuggestionIdx=n,this._suggestionCount=s,this._extraCommands=r,this._warning=l,this._relayout=d,this._commandService=h,this.keybindingService=g,this._contextKeyService=p,this._menuService=f,this.id=`InlineSuggestionHintsContentWidget${ra.id++}`,this.allowEditorOverflow=!0,this.suppressMouseDown=!1,this._warningMessageContentNode=o.derived(m=>{const _=this._warning.read(m);return _?typeof _.message=="string"?_.message:m.store.add(o.renderMarkdown(_.message)).element:void 0}),this._warningMessageNode=o.n.div({class:"warningMessage",style:{maxWidth:400,margin:4,marginBottom:4,display:o.derived(m=>this._warning.read(m)?"block":"none")}},[this._warningMessageContentNode]).keepUpdated(this._store),this.nodes=o.h("div.inlineSuggestionsHints",{className:this.withBorder?"monaco-hover monaco-hover-content":""},[this._warningMessageNode.element,o.h("div@toolBar")]),this.previousAction=this._register(this.createCommandAction(vm,a.localize(1272,"Previous"),o.ThemeIcon.asClassName(iy))),this.availableSuggestionCountAction=this._register(new o.Action("inlineSuggestionHints.availableSuggestionCount","",void 0,!1)),this.nextAction=this._register(this.createCommandAction(bm,a.localize(1273,"Next"),o.ThemeIcon.asClassName(ty))),this.inlineCompletionsActionsMenus=this._register(this._menuService.createMenu(o.MenuId.InlineCompletionsActions,this._contextKeyService)),this.clearAvailableSuggestionCountLabelDebounced=this._register(new a.RunOnceScheduler(()=>{this.availableSuggestionCountAction.label=""},100)),this.disableButtonsDebounced=this._register(new a.RunOnceScheduler(()=>{this.previousAction.enabled=this.nextAction.enabled=!1},100)),this._register(o.autorun(m=>{this._warningMessageContentNode.read(m),this._warningMessageNode.readEffect(m),this._relayout()})),this.toolBar=this._register(u.createInstance(rh,this.nodes.toolBar,o.MenuId.InlineSuggestionToolbar,{menuOptions:{renderShortTitle:!0},toolbarOptions:{primaryGroup:m=>m.startsWith("primary")},actionViewItemProvider:(m,_)=>{if(m instanceof o.MenuItemAction)return u.createInstance(sy,m,void 0);if(m===this.availableSuggestionCountAction){const v=new ny(void 0,m,{label:!0,icon:!1});return v.setClass("availableSuggestionCount"),v}},telemetrySource:"InlineSuggestionToolbar"})),this.toolBar.setPrependedPrimaryActions([this.previousAction,this.availableSuggestionCountAction,this.nextAction]),this._register(this.toolBar.onDidChangeDropdownVisibility(m=>{ra._dropDownVisible=m})),this._register(o.autorun(m=>{this._position.read(m),this.editor.layoutContentWidget(this)})),this._register(o.autorun(m=>{const _=this._suggestionCount.read(m),v=this._currentSuggestionIdx.read(m);_!==void 0?(this.clearAvailableSuggestionCountLabelDebounced.cancel(),this.availableSuggestionCountAction.label=`${v+1}/${_}`):this.clearAvailableSuggestionCountLabelDebounced.schedule(),_!==void 0&&_>1?(this.disableButtonsDebounced.cancel(),this.previousAction.enabled=this.nextAction.enabled=!0):this.disableButtonsDebounced.schedule()})),this._register(o.autorun(m=>{const v=this._extraCommands.read(m).map(b=>({class:void 0,id:b.command.id,enabled:!0,tooltip:b.command.tooltip||"",label:b.command.title,run:()=>this._commandService.executeCommand(b.command.id,...b.command.arguments??[])}));for(const[b,C]of this.inlineCompletionsActionsMenus.getActions())for(const y of C)y instanceof o.MenuItemAction&&v.push(y);v.length>0&&v.unshift(new o.Separator),this.toolBar.setAdditionalSecondaryActions(v)}))}getId(){return this.id}getDomNode(){return this.nodes.root}getPosition(){return{position:this._position.get(),preference:[1,2],positionAffinity:3}}},ra=_t,_t.hot=o.createHotClass(_t),_t._dropDownVisible=!1,_t.id=0,_t);gs=ra=sh([Ae(8,o.ICommandService),Ae(9,o.IInstantiationService),Ae(10,o.IKeybindingService),Ae(11,o.IContextKeyService),Ae(12,o.IMenuService)],gs);class ny extends o.ActionViewItem{constructor(){super(...arguments),this._className=void 0}setClass(e){this._className=e}render(e){super.render(e),this._className&&e.classList.add(this._className)}updateTooltip(){}}class sy extends o.MenuEntryActionViewItem{updateLabel(){const e=this._keybindingService.lookupKeybinding(this._action.id,this._contextKeyService,!0);if(!e)return super.updateLabel();if(this.label){const t=o.h("div.keybinding").root;this._register(new o.KeybindingLabel(t,a.OS,{disableTitle:!0,...o.unthemedKeybindingLabelOptions})).set(e),this.label.textContent=this._action.label,this.label.appendChild(t),this.label.classList.add("inlineSuggestionStatusBarItemLabel")}}updateTooltip(){}}let rh=class extends o.WorkbenchToolBar{constructor(e,t,i,n,s,r,l,d,h){super(e,{resetMenu:t,...i},n,s,r,l,d,h),this.menuId=t,this.options2=i,this.menuService=n,this.contextKeyService=s,this.menu=this._store.add(this.menuService.createMenu(this.menuId,this.contextKeyService,{emitEventsForSubmenuChanges:!0})),this.additionalActions=[],this.prependedPrimaryActions=[],this.additionalPrimaryActions=[],this._store.add(this.menu.onDidChange(()=>this.updateToolbar())),this.updateToolbar()}updateToolbar(){const{primary:e,secondary:t}=o.getActionBarActions(this.menu.getActions(this.options2?.menuOptions),this.options2?.toolbarOptions?.primaryGroup,this.options2?.toolbarOptions?.shouldInlineSubmenu,this.options2?.toolbarOptions?.useSeparatorsInPrimaryActions);t.push(...this.additionalActions),e.unshift(...this.prependedPrimaryActions),e.push(...this.additionalPrimaryActions),this.setActions(e,t)}setPrependedPrimaryActions(e){a.equals(this.prependedPrimaryActions,e,(t,i)=>t===i)||(this.prependedPrimaryActions=e,this.updateToolbar())}setAdditionalSecondaryActions(e){a.equals(this.additionalActions,e,(t,i)=>t===i)||(this.additionalActions=e,this.updateToolbar())}};rh=sh([Ae(3,o.IMenuService),Ae(4,o.IContextKeyService),Ae(5,o.IContextMenuService),Ae(6,o.IKeybindingService),Ae(7,o.ICommandService),Ae(8,o.ITelemetryService)],rh);function aa(c,e,t){const i=o.getDomNodePagePosition(c);return!(e<i.left+3||e>i.left+i.width-3||t<i.top+3||t>i.top+i.height-3)}function ym(c,e,t){return c==="on"?!0:c==="off"?!1:ah(e,t.event)}function ah(c,e){return c==="altKey"?e.ctrlKey||e.metaKey:e.altKey}class oy{constructor(e,t,i,n){this.value=e,this.isComplete=t,this.hasLoadingMessage=i,this.options=n}}class wm extends a.Disposable{constructor(e,t){super(),this._editor=e,this._computer=t,this._onResult=this._register(new a.Emitter),this.onResult=this._onResult.event,this._asyncComputationScheduler=this._register(new lh(i=>this._triggerAsyncComputation(i),0)),this._syncComputationScheduler=this._register(new lh(i=>this._triggerSyncComputation(i),0)),this._loadingMessageScheduler=this._register(new lh(i=>this._triggerLoadingMessage(i),0)),this._state=0,this._asyncIterable=null,this._asyncIterableDone=!1,this._result=[]}dispose(){this._asyncIterable&&(this._asyncIterable.cancel(),this._asyncIterable=null),this._options=void 0,super.dispose()}get _hoverTime(){return this._editor.getOption(69).delay}get _firstWaitTime(){return this._hoverTime/2}get _secondWaitTime(){return this._hoverTime-this._firstWaitTime}get _loadingMessageTime(){return 3*this._hoverTime}_setState(e,t){this._options=t,this._state=e,this._fireResult(t)}_triggerAsyncComputation(e){this._setState(2,e),this._syncComputationScheduler.schedule(e,this._secondWaitTime),this._computer.computeAsync?(this._asyncIterableDone=!1,this._asyncIterable=a.createCancelableAsyncIterableProducer(t=>this._computer.computeAsync(e,t)),(async()=>{try{for await(const t of this._asyncIterable)t&&(this._result.push(t),this._fireResult(e));this._asyncIterableDone=!0,(this._state===3||this._state===4)&&this._setState(0,e)}catch(t){a.onUnexpectedError(t)}})()):this._asyncIterableDone=!0}_triggerSyncComputation(e){this._computer.computeSync&&(this._result=this._result.concat(this._computer.computeSync(e))),this._setState(this._asyncIterableDone?0:3,e)}_triggerLoadingMessage(e){this._state===3&&this._setState(4,e)}_fireResult(e){if(this._state===1||this._state===2)return;const t=this._state===0,i=this._state===4;this._onResult.fire(new oy(this._result.slice(0),t,i,e))}start(e,t){if(e===0)this._state===0&&(this._setState(1,t),this._asyncComputationScheduler.schedule(t,this._firstWaitTime),this._loadingMessageScheduler.schedule(t,this._loadingMessageTime));else switch(this._state){case 0:this._triggerAsyncComputation(t),this._syncComputationScheduler.cancel(),this._triggerSyncComputation(t);break;case 2:this._syncComputationScheduler.cancel(),this._triggerSyncComputation(t);break}}cancel(){this._asyncComputationScheduler.cancel(),this._syncComputationScheduler.cancel(),this._loadingMessageScheduler.cancel(),this._asyncIterable&&(this._asyncIterable.cancel(),this._asyncIterable=null),this._result=[],this._options=void 0,this._state=0}get options(){return this._options}}class lh extends a.Disposable{constructor(e,t){super(),this._scheduler=this._register(new a.RunOnceScheduler(()=>e(this._options),t))}schedule(e,t){this._options=e,this._scheduler.schedule(t)}cancel(){this._scheduler.cancel()}}class ch{get onDidWillResize(){return this._onDidWillResize.event}get onDidResize(){return this._onDidResize.event}constructor(){this._onDidWillResize=new a.Emitter,this._onDidResize=new a.Emitter,this._sashListener=new a.DisposableStore,this._size=new o.Dimension(0,0),this._minSize=new o.Dimension(0,0),this._maxSize=new o.Dimension(Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER),this.domNode=document.createElement("div"),this._eastSash=new o.Sash(this.domNode,{getVerticalSashLeft:()=>this._size.width},{orientation:0}),this._westSash=new o.Sash(this.domNode,{getVerticalSashLeft:()=>0},{orientation:0}),this._northSash=new o.Sash(this.domNode,{getHorizontalSashTop:()=>0},{orientation:1,orthogonalEdge:o.OrthogonalEdge.North}),this._southSash=new o.Sash(this.domNode,{getHorizontalSashTop:()=>this._size.height},{orientation:1,orthogonalEdge:o.OrthogonalEdge.South}),this._northSash.orthogonalStartSash=this._westSash,this._northSash.orthogonalEndSash=this._eastSash,this._southSash.orthogonalStartSash=this._westSash,this._southSash.orthogonalEndSash=this._eastSash;let e,t=0,i=0;this._sashListener.add(a.Event.any(this._northSash.onDidStart,this._eastSash.onDidStart,this._southSash.onDidStart,this._westSash.onDidStart)(()=>{e===void 0&&(this._onDidWillResize.fire(),e=this._size,t=0,i=0)})),this._sashListener.add(a.Event.any(this._northSash.onDidEnd,this._eastSash.onDidEnd,this._southSash.onDidEnd,this._westSash.onDidEnd)(()=>{e!==void 0&&(e=void 0,t=0,i=0,this._onDidResize.fire({dimension:this._size,done:!0}))})),this._sashListener.add(this._eastSash.onDidChange(n=>{e&&(i=n.currentX-n.startX,this.layout(e.height+t,e.width+i),this._onDidResize.fire({dimension:this._size,done:!1,east:!0}))})),this._sashListener.add(this._westSash.onDidChange(n=>{e&&(i=-(n.currentX-n.startX),this.layout(e.height+t,e.width+i),this._onDidResize.fire({dimension:this._size,done:!1,west:!0}))})),this._sashListener.add(this._northSash.onDidChange(n=>{e&&(t=-(n.currentY-n.startY),this.layout(e.height+t,e.width+i),this._onDidResize.fire({dimension:this._size,done:!1,north:!0}))})),this._sashListener.add(this._southSash.onDidChange(n=>{e&&(t=n.currentY-n.startY,this.layout(e.height+t,e.width+i),this._onDidResize.fire({dimension:this._size,done:!1,south:!0}))})),this._sashListener.add(a.Event.any(this._eastSash.onDidReset,this._westSash.onDidReset)(n=>{this._preferredSize&&(this.layout(this._size.height,this._preferredSize.width),this._onDidResize.fire({dimension:this._size,done:!0}))})),this._sashListener.add(a.Event.any(this._northSash.onDidReset,this._southSash.onDidReset)(n=>{this._preferredSize&&(this.layout(this._preferredSize.height,this._size.width),this._onDidResize.fire({dimension:this._size,done:!0}))}))}dispose(){this._northSash.dispose(),this._southSash.dispose(),this._eastSash.dispose(),this._westSash.dispose(),this._sashListener.dispose(),this._onDidResize.dispose(),this._onDidWillResize.dispose(),this.domNode.remove()}enableSashes(e,t,i,n){this._northSash.state=e?3:0,this._eastSash.state=t?3:0,this._southSash.state=i?3:0,this._westSash.state=n?3:0}layout(e=this.size.height,t=this.size.width){const{height:i,width:n}=this._minSize,{height:s,width:r}=this._maxSize;e=Math.max(i,Math.min(s,e)),t=Math.max(n,Math.min(r,t));const l=new o.Dimension(t,e);o.Dimension.equals(l,this._size)||(this.domNode.style.height=e+"px",this.domNode.style.width=t+"px",this._size=l,this._northSash.layout(),this._eastSash.layout(),this._southSash.layout(),this._westSash.layout())}clearSashHoverState(){this._eastSash.clearSashHoverState(),this._westSash.clearSashHoverState(),this._northSash.clearSashHoverState(),this._southSash.clearSashHoverState()}get size(){return this._size}set maxSize(e){this._maxSize=e}get maxSize(){return this._maxSize}set minSize(e){this._minSize=e}get minSize(){return this._minSize}set preferredSize(e){this._preferredSize=e}get preferredSize(){return this._preferredSize}}const ry=30,ay=24;class ly extends a.Disposable{constructor(e,t=new o.Dimension(10,10)){super(),this._editor=e,this.allowEditorOverflow=!0,this.suppressMouseDown=!1,this._resizableNode=this._register(new ch),this._contentPosition=null,this._isResizing=!1,this._resizableNode.domNode.style.position="absolute",this._resizableNode.minSize=o.Dimension.lift(t),this._resizableNode.layout(t.height,t.width),this._resizableNode.enableSashes(!0,!0,!0,!0),this._register(this._resizableNode.onDidResize(i=>{this._resize(new o.Dimension(i.dimension.width,i.dimension.height)),i.done&&(this._isResizing=!1)})),this._register(this._resizableNode.onDidWillResize(()=>{this._isResizing=!0}))}get isResizing(){return this._isResizing}getDomNode(){return this._resizableNode.domNode}getPosition(){return this._contentPosition}get position(){return this._contentPosition?.position?a.Position.lift(this._contentPosition.position):void 0}_availableVerticalSpaceAbove(e){const t=this._editor.getDomNode(),i=this._editor.getScrolledVisiblePosition(e);return!t||!i?void 0:o.getDomNodePagePosition(t).top+i.top-ry}_availableVerticalSpaceBelow(e){const t=this._editor.getDomNode(),i=this._editor.getScrolledVisiblePosition(e);if(!t||!i)return;const n=o.getDomNodePagePosition(t),s=o.getClientArea(t.ownerDocument.body),r=n.top+i.top+i.height;return s.height-r-ay}_findPositionPreference(e,t){const i=Math.min(this._availableVerticalSpaceBelow(t)??1/0,e),n=Math.min(this._availableVerticalSpaceAbove(t)??1/0,e),s=Math.min(Math.max(n,i),e),r=Math.min(e,s);let l;return this._editor.getOption(69).above?l=r<=n?1:2:l=r<=i?2:1,l===1?this._resizableNode.enableSashes(!0,!0,!1,!1):this._resizableNode.enableSashes(!1,!0,!0,!1),l}_resize(e){this._resizableNode.layout(e.height,e.width)}}var cy=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},la=function(c,e){return function(t,i){e(t,i,c)}},Fe;const Im=30;let dh=(vi=class extends ly{get isVisibleFromKeyboard(){return this._renderedHover?.source===2}get isVisible(){return this._hoverVisibleKey.get()??!1}get isFocused(){return this._hoverFocusedKey.get()??!1}constructor(e,t,i,n,s){const r=e.getOption(75)+8,l=150,d=new o.Dimension(l,r);super(e,d),this._configurationService=i,this._accessibilityService=n,this._keybindingService=s,this._hover=this._register(new o.HoverWidget(!0)),this._onDidResize=this._register(new a.Emitter),this.onDidResize=this._onDidResize.event,this._onDidScroll=this._register(new a.Emitter),this.onDidScroll=this._onDidScroll.event,this._onContentsChanged=this._register(new a.Emitter),this.onContentsChanged=this._onContentsChanged.event,this._minimumSize=d,this._hoverVisibleKey=o.EditorContextKeys.hoverVisible.bindTo(t),this._hoverFocusedKey=o.EditorContextKeys.hoverFocused.bindTo(t),o.append(this._resizableNode.domNode,this._hover.containerDomNode),this._resizableNode.domNode.style.zIndex="50",this._resizableNode.domNode.className="monaco-resizable-hover",this._register(this._editor.onDidLayoutChange(()=>{this.isVisible&&this._updateMaxDimensions()})),this._register(this._editor.onDidChangeConfiguration(u=>{u.hasChanged(59)&&this._updateFont()}));const h=this._register(o.trackFocus(this._resizableNode.domNode));this._register(h.onDidFocus(()=>{this._hoverFocusedKey.set(!0)})),this._register(h.onDidBlur(()=>{this._hoverFocusedKey.set(!1)})),this._register(this._hover.scrollbar.onScroll(u=>{this._onDidScroll.fire(u)})),this._setRenderedHover(void 0),this._editor.addContentWidget(this)}dispose(){super.dispose(),this._renderedHover?.dispose(),this._editor.removeContentWidget(this)}getId(){return Fe.ID}static _applyDimensions(e,t,i){const n=typeof t=="number"?`${t}px`:t,s=typeof i=="number"?`${i}px`:i;e.style.width=n,e.style.height=s}_setContentsDomNodeDimensions(e,t){const i=this._hover.contentsDomNode;return Fe._applyDimensions(i,e,t)}_setContainerDomNodeDimensions(e,t){const i=this._hover.containerDomNode;return Fe._applyDimensions(i,e,t)}_setScrollableElementDimensions(e,t){const i=this._hover.scrollbar.getDomNode();return Fe._applyDimensions(i,e,t)}_setHoverWidgetDimensions(e,t){this._setContainerDomNodeDimensions(e,t),this._setScrollableElementDimensions(e,t),this._setContentsDomNodeDimensions(e,t),this._layoutContentWidget()}static _applyMaxDimensions(e,t,i){const n=typeof t=="number"?`${t}px`:t,s=typeof i=="number"?`${i}px`:i;e.style.maxWidth=n,e.style.maxHeight=s}_setHoverWidgetMaxDimensions(e,t){Fe._applyMaxDimensions(this._hover.contentsDomNode,e,t),Fe._applyMaxDimensions(this._hover.scrollbar.getDomNode(),e,t),Fe._applyMaxDimensions(this._hover.containerDomNode,e,t),this._hover.containerDomNode.style.setProperty("--vscode-hover-maxWidth",typeof e=="number"?`${e}px`:e),this._layoutContentWidget()}_setAdjustedHoverWidgetDimensions(e){this._setHoverWidgetMaxDimensions("none","none"),this._setHoverWidgetDimensions(e.width,e.height)}_updateResizableNodeMaxDimensions(){const e=this._findMaximumRenderingWidth()??1/0,t=this._findMaximumRenderingHeight()??1/0;this._resizableNode.maxSize=new o.Dimension(e,t),this._setHoverWidgetMaxDimensions(e,t)}_resize(e){Fe._lastDimensions=new o.Dimension(e.width,e.height),this._setAdjustedHoverWidgetDimensions(e),this._resizableNode.layout(e.height,e.width),this._updateResizableNodeMaxDimensions(),this._hover.scrollbar.scanDomNode(),this._editor.layoutContentWidget(this),this._onDidResize.fire()}_findAvailableSpaceVertically(){const e=this._renderedHover?.showAtPosition;if(e)return this._positionPreference===1?this._availableVerticalSpaceAbove(e):this._availableVerticalSpaceBelow(e)}_findMaximumRenderingHeight(){const e=this._findAvailableSpaceVertically();if(!e)return;let i=this._hover.contentsDomNode.children.length-1;return Array.from(this._hover.contentsDomNode.children).forEach(n=>{i+=n.clientHeight}),Math.min(e,i)}_isHoverTextOverflowing(){this._hover.containerDomNode.style.setProperty("--vscode-hover-whiteSpace","nowrap"),this._hover.containerDomNode.style.setProperty("--vscode-hover-sourceWhiteSpace","nowrap");const e=Array.from(this._hover.contentsDomNode.children).some(t=>t.scrollWidth>t.clientWidth);return this._hover.containerDomNode.style.removeProperty("--vscode-hover-whiteSpace"),this._hover.containerDomNode.style.removeProperty("--vscode-hover-sourceWhiteSpace"),e}_findMaximumRenderingWidth(){if(!this._editor||!this._editor.hasModel())return;const e=this._isHoverTextOverflowing(),t=typeof this._contentWidth>"u"?0:this._contentWidth;return e||this._hover.containerDomNode.clientWidth<t?o.getClientArea(this._hover.containerDomNode.ownerDocument.body).width-14:this._hover.containerDomNode.clientWidth}isMouseGettingCloser(e,t){if(!this._renderedHover)return!1;if(this._renderedHover.initialMousePosX===void 0||this._renderedHover.initialMousePosY===void 0)return this._renderedHover.initialMousePosX=e,this._renderedHover.initialMousePosY=t,!1;const i=o.getDomNodePagePosition(this.getDomNode());this._renderedHover.closestMouseDistance===void 0&&(this._renderedHover.closestMouseDistance=xm(this._renderedHover.initialMousePosX,this._renderedHover.initialMousePosY,i.left,i.top,i.width,i.height));const n=xm(e,t,i.left,i.top,i.width,i.height);return n>this._renderedHover.closestMouseDistance+4?!1:(this._renderedHover.closestMouseDistance=Math.min(this._renderedHover.closestMouseDistance,n),!0)}_setRenderedHover(e){this._renderedHover?.dispose(),this._renderedHover=e,this._hoverVisibleKey.set(!!e),this._hover.containerDomNode.classList.toggle("hidden",!e)}_updateFont(){const{fontSize:e,lineHeight:t}=this._editor.getOption(59),i=this._hover.contentsDomNode;i.style.fontSize=`${e}px`,i.style.lineHeight=`${t/e}`,Array.prototype.slice.call(this._hover.contentsDomNode.getElementsByClassName("code")).forEach(s=>this._editor.applyFontInfo(s))}_updateContent(e){const t=this._hover.contentsDomNode;t.style.paddingBottom="",t.textContent="",t.appendChild(e)}_layoutContentWidget(){this._editor.layoutContentWidget(this),this._hover.onContentsChanged()}_updateMaxDimensions(){const e=Math.max(this._editor.getLayoutInfo().height/4,250,Fe._lastDimensions.height),t=Math.max(this._editor.getLayoutInfo().width*.66,750,Fe._lastDimensions.width);this._resizableNode.maxSize=new o.Dimension(t,e),this._setHoverWidgetMaxDimensions(t,e)}_render(e){this._setRenderedHover(e),this._updateFont(),this._updateContent(e.domNode),this.handleContentsChanged(),this._editor.render()}getPosition(){return this._renderedHover?{position:this._renderedHover.showAtPosition,secondaryPosition:this._renderedHover.showAtSecondaryPosition,positionAffinity:this._renderedHover.shouldAppearBeforeContent?3:void 0,preference:[this._positionPreference??1]}:null}show(e){if(!this._editor||!this._editor.hasModel())return;this._render(e);const t=o.getTotalHeight(this._hover.containerDomNode),i=e.showAtPosition;this._positionPreference=this._findPositionPreference(t,i)??1,this.handleContentsChanged(),e.shouldFocus&&this._hover.containerDomNode.focus(),this._onDidResize.fire();const s=this._hover.containerDomNode.ownerDocument.activeElement===this._hover.containerDomNode&&o.getHoverAccessibleViewHint(this._configurationService.getValue("accessibility.verbosity.hover")===!0&&this._accessibilityService.isScreenReaderOptimized(),this._keybindingService.lookupKeybinding("editor.action.accessibleView")?.getAriaLabel()??"");s&&(this._hover.contentsDomNode.ariaLabel=this._hover.contentsDomNode.textContent+", "+s)}hide(){if(!this._renderedHover)return;const e=this._renderedHover.shouldFocus||this._hoverFocusedKey.get();this._setRenderedHover(void 0),this._resizableNode.maxSize=new o.Dimension(1/0,1/0),this._resizableNode.clearSashHoverState(),this._hoverFocusedKey.set(!1),this._editor.layoutContentWidget(this),e&&this._editor.focus()}_removeConstraintsRenderNormally(){const e=this._editor.getLayoutInfo();this._resizableNode.layout(e.height,e.width),this._setHoverWidgetDimensions("auto","auto"),this._updateMaxDimensions()}setMinimumDimensions(e){this._minimumSize=new o.Dimension(Math.max(this._minimumSize.width,e.width),Math.max(this._minimumSize.height,e.height)),this._updateMinimumWidth()}_updateMinimumWidth(){const e=typeof this._contentWidth>"u"?this._minimumSize.width:Math.min(this._contentWidth,this._minimumSize.width);this._resizableNode.minSize=new o.Dimension(e,this._minimumSize.height)}handleContentsChanged(){this._removeConstraintsRenderNormally();const e=this._hover.contentsDomNode;let t=o.getTotalHeight(e),i=o.getTotalWidth(e)+2;if(this._resizableNode.layout(t,i),this._setHoverWidgetDimensions(i,t),t=o.getTotalHeight(e),i=o.getTotalWidth(e),this._contentWidth=i,this._updateMinimumWidth(),this._resizableNode.layout(t,i),this._renderedHover?.showAtPosition){const n=o.getTotalHeight(this._hover.containerDomNode);this._positionPreference=this._findPositionPreference(n,this._renderedHover.showAtPosition)}this._layoutContentWidget(),this._onContentsChanged.fire()}focus(){this._hover.containerDomNode.focus()}scrollUp(){const e=this._hover.scrollbar.getScrollPosition().scrollTop,t=this._editor.getOption(59);this._hover.scrollbar.setScrollPosition({scrollTop:e-t.lineHeight})}scrollDown(){const e=this._hover.scrollbar.getScrollPosition().scrollTop,t=this._editor.getOption(59);this._hover.scrollbar.setScrollPosition({scrollTop:e+t.lineHeight})}scrollLeft(){const e=this._hover.scrollbar.getScrollPosition().scrollLeft;this._hover.scrollbar.setScrollPosition({scrollLeft:e-Im})}scrollRight(){const e=this._hover.scrollbar.getScrollPosition().scrollLeft;this._hover.scrollbar.setScrollPosition({scrollLeft:e+Im})}pageUp(){const e=this._hover.scrollbar.getScrollPosition().scrollTop,t=this._hover.scrollbar.getScrollDimensions().height;this._hover.scrollbar.setScrollPosition({scrollTop:e-t})}pageDown(){const e=this._hover.scrollbar.getScrollPosition().scrollTop,t=this._hover.scrollbar.getScrollDimensions().height;this._hover.scrollbar.setScrollPosition({scrollTop:e+t})}goToTop(){this._hover.scrollbar.setScrollPosition({scrollTop:0})}goToBottom(){this._hover.scrollbar.setScrollPosition({scrollTop:this._hover.scrollbar.getScrollDimensions().scrollHeight})}},Fe=vi,vi.ID="editor.contrib.resizableContentHoverWidget",vi._lastDimensions=new o.Dimension(0,0),vi);dh=Fe=cy([la(1,o.IContextKeyService),la(2,o.IConfigurationService),la(3,o.IAccessibilityService),la(4,o.IKeybindingService)],dh);function xm(c,e,t,i,n,s){const r=t+n/2,l=i+s/2,d=Math.max(Math.abs(c-r)-n/2,0),h=Math.max(Math.abs(e-l)-s/2,0);return Math.sqrt(d*d+h*h)}class ca{constructor(e,t){this._editor=e,this._participants=t}static _getLineDecorations(e,t){if(t.type!==1&&!t.supportsMarkerHover)return[];const i=e.getModel(),n=t.range.startLineNumber;if(n>i.getLineCount())return[];const s=i.getLineMaxColumn(n);return e.getLineDecorations(n).filter(r=>{if(r.options.isWholeLine)return!0;const l=r.range.startLineNumber===n?r.range.startColumn:1,d=r.range.endLineNumber===n?r.range.endColumn:s;if(r.options.showIfCollapsed){if(l>t.range.startColumn+1||t.range.endColumn-1>d)return!1}else if(l>t.range.startColumn||t.range.endColumn>d)return!1;return!0})}computeAsync(e,t){const i=e.anchor;if(!this._editor.hasModel()||!i)return a.AsyncIterableProducer.EMPTY;const n=ca._getLineDecorations(this._editor,i);return a.AsyncIterableProducer.merge(this._participants.map(s=>s.computeAsync?s.computeAsync(i,n,e.source,t):a.AsyncIterableProducer.EMPTY))}computeSync(e){if(!this._editor.hasModel())return[];const t=e.anchor,i=ca._getLineDecorations(this._editor,t);let n=[];for(const s of this._participants)n=n.concat(s.computeSync(t,i,e.source));return a.coalesce(n)}}class Em{constructor(e,t,i){this.hoverParts=e,this.isComplete=t,this.options=i}filter(e){const t=this.hoverParts.filter(i=>i.isValidForHoverAnchor(e));return t.length===this.hoverParts.length?this:new dy(this,t,this.isComplete,this.options)}}class dy extends Em{constructor(e,t,i,n){super(t,i,n),this.original=e}filter(e){return this.original.filter(e)}}var hy=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Lm=function(c,e){return function(t,i){e(t,i,c)}};const Dm=o.$;let da=class extends a.Disposable{get hasContent(){return this._hasContent}constructor(e,t){super(),this._keybindingService=e,this._hoverService=t,this.actions=[],this._hasContent=!1,this.hoverElement=Dm("div.hover-row.status-bar"),this.hoverElement.tabIndex=0,this.actionsElement=o.append(this.hoverElement,Dm("div.actions"))}addAction(e){const t=this._keybindingService.lookupKeybinding(e.commandId),i=t?t.getLabel():null;this._hasContent=!0;const n=this._register(o.HoverAction.render(this.actionsElement,e,i));return this._register(this._hoverService.setupManagedHover(o.getDefaultHoverDelegate("element"),n.actionContainer,n.actionRenderedLabel)),this.actions.push(n),n}append(e){const t=o.append(this.actionsElement,e);return this._hasContent=!0,t}};da=hy([Lm(0,o.IKeybindingService),Lm(1,o.IHoverService)],da);const re=class re{constructor(e){this._editor=e,this._decorations=[],this._overviewRulerApproximateDecorations=[],this._findScopeDecorationIds=[],this._rangeHighlightDecorationId=null,this._highlightedDecorationId=null,this._startPosition=this._editor.getPosition()}dispose(){this._editor.removeDecorations(this._allDecorations()),this._decorations=[],this._overviewRulerApproximateDecorations=[],this._findScopeDecorationIds=[],this._rangeHighlightDecorationId=null,this._highlightedDecorationId=null}reset(){this._decorations=[],this._overviewRulerApproximateDecorations=[],this._findScopeDecorationIds=[],this._rangeHighlightDecorationId=null,this._highlightedDecorationId=null}getCount(){return this._decorations.length}getFindScope(){return this._findScopeDecorationIds[0]?this._editor.getModel().getDecorationRange(this._findScopeDecorationIds[0]):null}getFindScopes(){if(this._findScopeDecorationIds.length){const e=this._findScopeDecorationIds.map(t=>this._editor.getModel().getDecorationRange(t)).filter(t=>!!t);if(e.length)return e}return null}getStartPosition(){return this._startPosition}setStartPosition(e){this._startPosition=e,this.setCurrentFindMatch(null)}_getDecorationIndex(e){const t=this._decorations.indexOf(e);return t>=0?t+1:1}getDecorationRangeAt(e){const t=e<this._decorations.length?this._decorations[e]:null;return t?this._editor.getModel().getDecorationRange(t):null}getCurrentMatchesPosition(e){const t=this._editor.getModel().getDecorationsInRange(e);for(const i of t){const n=i.options;if(n===re._FIND_MATCH_DECORATION||n===re._FIND_MATCH_NO_OVERVIEW_DECORATION||n===re._CURRENT_FIND_MATCH_DECORATION)return this._getDecorationIndex(i.id)}return 0}setCurrentFindMatch(e){let t=null,i=0;if(e)for(let n=0,s=this._decorations.length;n<s;n++){const r=this._editor.getModel().getDecorationRange(this._decorations[n]);if(e.equalsRange(r)){t=this._decorations[n],i=n+1;break}}return(this._highlightedDecorationId!==null||t!==null)&&this._editor.changeDecorations(n=>{if(this._highlightedDecorationId!==null&&(n.changeDecorationOptions(this._highlightedDecorationId,re._FIND_MATCH_DECORATION),this._highlightedDecorationId=null),t!==null&&(this._highlightedDecorationId=t,n.changeDecorationOptions(this._highlightedDecorationId,re._CURRENT_FIND_MATCH_DECORATION)),this._rangeHighlightDecorationId!==null&&(n.removeDecoration(this._rangeHighlightDecorationId),this._rangeHighlightDecorationId=null),t!==null){let s=this._editor.getModel().getDecorationRange(t);if(s.startLineNumber!==s.endLineNumber&&s.endColumn===1){const r=s.endLineNumber-1,l=this._editor.getModel().getLineMaxColumn(r);s=new a.Range(s.startLineNumber,s.startColumn,r,l)}this._rangeHighlightDecorationId=n.addDecoration(s,re._RANGE_HIGHLIGHT_DECORATION)}}),i}set(e,t){this._editor.changeDecorations(i=>{let n=re._FIND_MATCH_DECORATION;const s=[];if(e.length>1e3){n=re._FIND_MATCH_NO_OVERVIEW_DECORATION;const l=this._editor.getModel().getLineCount(),h=this._editor.getLayoutInfo().height/l,u=Math.max(2,Math.ceil(3/h));let g=e[0].range.startLineNumber,p=e[0].range.endLineNumber;for(let f=1,m=e.length;f<m;f++){const _=e[f].range;p+u>=_.startLineNumber?_.endLineNumber>p&&(p=_.endLineNumber):(s.push({range:new a.Range(g,1,p,1),options:re._FIND_MATCH_ONLY_OVERVIEW_DECORATION}),g=_.startLineNumber,p=_.endLineNumber)}s.push({range:new a.Range(g,1,p,1),options:re._FIND_MATCH_ONLY_OVERVIEW_DECORATION})}const r=new Array(e.length);for(let l=0,d=e.length;l<d;l++)r[l]={range:e[l].range,options:n};this._decorations=i.deltaDecorations(this._decorations,r),this._overviewRulerApproximateDecorations=i.deltaDecorations(this._overviewRulerApproximateDecorations,s),this._rangeHighlightDecorationId&&(i.removeDecoration(this._rangeHighlightDecorationId),this._rangeHighlightDecorationId=null),this._findScopeDecorationIds.length&&(this._findScopeDecorationIds.forEach(l=>i.removeDecoration(l)),this._findScopeDecorationIds=[]),t?.length&&(this._findScopeDecorationIds=t.map(l=>i.addDecoration(l,re._FIND_SCOPE_DECORATION)))})}matchBeforePosition(e){if(this._decorations.length===0)return null;for(let t=this._decorations.length-1;t>=0;t--){const i=this._decorations[t],n=this._editor.getModel().getDecorationRange(i);if(!(!n||n.endLineNumber>e.lineNumber)){if(n.endLineNumber<e.lineNumber)return n;if(!(n.endColumn>e.column))return n}}return this._editor.getModel().getDecorationRange(this._decorations[this._decorations.length-1])}matchAfterPosition(e){if(this._decorations.length===0)return null;for(let t=0,i=this._decorations.length;t<i;t++){const n=this._decorations[t],s=this._editor.getModel().getDecorationRange(n);if(!(!s||s.startLineNumber<e.lineNumber)){if(s.startLineNumber>e.lineNumber)return s;if(!(s.startColumn<e.column))return s}}return this._editor.getModel().getDecorationRange(this._decorations[0])}_allDecorations(){let e=[];return e=e.concat(this._decorations),e=e.concat(this._overviewRulerApproximateDecorations),this._findScopeDecorationIds.length&&e.push(...this._findScopeDecorationIds),this._rangeHighlightDecorationId&&e.push(this._rangeHighlightDecorationId),e}};re._CURRENT_FIND_MATCH_DECORATION=o.ModelDecorationOptions.register({description:"current-find-match",stickiness:1,zIndex:13,className:"currentFindMatch",inlineClassName:"currentFindMatchInline",showIfCollapsed:!0,overviewRuler:{color:o.themeColorFromId(o.overviewRulerFindMatchForeground),position:a.OverviewRulerLane.Center},minimap:{color:o.themeColorFromId(o.minimapFindMatch),position:1}}),re._FIND_MATCH_DECORATION=o.ModelDecorationOptions.register({description:"find-match",stickiness:1,zIndex:10,className:"findMatch",inlineClassName:"findMatchInline",showIfCollapsed:!0,overviewRuler:{color:o.themeColorFromId(o.overviewRulerFindMatchForeground),position:a.OverviewRulerLane.Center},minimap:{color:o.themeColorFromId(o.minimapFindMatch),position:1}}),re._FIND_MATCH_NO_OVERVIEW_DECORATION=o.ModelDecorationOptions.register({description:"find-match-no-overview",stickiness:1,className:"findMatch",showIfCollapsed:!0}),re._FIND_MATCH_ONLY_OVERVIEW_DECORATION=o.ModelDecorationOptions.register({description:"find-match-only-overview",stickiness:1,overviewRuler:{color:o.themeColorFromId(o.overviewRulerFindMatchForeground),position:a.OverviewRulerLane.Center}}),re._RANGE_HIGHLIGHT_DECORATION=o.ModelDecorationOptions.register({description:"find-range-highlight",stickiness:1,className:"rangeHighlight",isWholeLine:!0}),re._FIND_SCOPE_DECORATION=o.ModelDecorationOptions.register({description:"find-scope",className:"findScope",isWholeLine:!0});let hh=re;class uy{constructor(e,t,i){this._editorSelection=e,this._ranges=t,this._replaceStrings=i,this._trackedEditorSelectionId=null}getEditOperations(e,t){if(this._ranges.length>0){const i=[];for(let r=0;r<this._ranges.length;r++)i.push({range:this._ranges[r],text:this._replaceStrings[r]});i.sort((r,l)=>a.Range.compareRangesUsingStarts(r.range,l.range));const n=[];let s=i[0];for(let r=1;r<i.length;r++)s.range.endLineNumber===i[r].range.startLineNumber&&s.range.endColumn===i[r].range.startColumn?(s.range=s.range.plusRange(i[r].range),s.text=s.text+i[r].text):(n.push(s),s=i[r]);n.push(s);for(const r of n)t.addEditOperation(r.range,r.text)}this._trackedEditorSelectionId=t.trackSelection(this._editorSelection)}computeCursorState(e,t){return t.getTrackedSelection(this._trackedEditorSelectionId)}}function Rm(c,e){if(c&&c[0]!==""){const t=Tm(c,e,"-"),i=Tm(c,e,"_");return t&&!i?Nm(c,e,"-"):!t&&i?Nm(c,e,"_"):c[0].toUpperCase()===c[0]?e.toUpperCase():c[0].toLowerCase()===c[0]?e.toLowerCase():a.containsUppercaseCharacter(c[0][0])&&e.length>0?e[0].toUpperCase()+e.substr(1):c[0][0].toUpperCase()!==c[0][0]&&e.length>0?e[0].toLowerCase()+e.substr(1):e}else return e}function Tm(c,e,t){return c[0].indexOf(t)!==-1&&e.indexOf(t)!==-1&&c[0].split(t).length===e.split(t).length}function Nm(c,e,t){const i=e.split(t),n=c[0].split(t);let s="";return i.forEach((r,l)=>{s+=Rm([n[l]],r)+t}),s.slice(0,-1)}class Mm{constructor(e){this.staticValue=e,this.kind=0}}class gy{constructor(e){this.pieces=e,this.kind=1}}class ps{static fromStaticValue(e){return new ps([Ji.staticValue(e)])}get hasReplacementPatterns(){return this._state.kind===1}constructor(e){!e||e.length===0?this._state=new Mm(""):e.length===1&&e[0].staticValue!==null?this._state=new Mm(e[0].staticValue):this._state=new gy(e)}buildReplaceString(e,t){if(this._state.kind===0)return t?Rm(e,this._state.staticValue):this._state.staticValue;let i="";for(let n=0,s=this._state.pieces.length;n<s;n++){const r=this._state.pieces[n];if(r.staticValue!==null){i+=r.staticValue;continue}let l=ps._substitute(r.matchIndex,e);if(r.caseOps!==null&&r.caseOps.length>0){const d=[],h=r.caseOps.length;let u=0;for(let g=0,p=l.length;g<p;g++){if(u>=h){d.push(l.slice(g));break}switch(r.caseOps[u]){case"U":d.push(l[g].toUpperCase());break;case"u":d.push(l[g].toUpperCase()),u++;break;case"L":d.push(l[g].toLowerCase());break;case"l":d.push(l[g].toLowerCase()),u++;break;default:d.push(l[g])}}l=d.join("")}i+=l}return i}static _substitute(e,t){if(t===null)return"";if(e===0)return t[0];let i="";for(;e>0;){if(e<t.length)return(t[e]||"")+i;i=String(e%10)+i,e=Math.floor(e/10)}return"$"+i}}class Ji{static staticValue(e){return new Ji(e,-1,null)}static caseOps(e,t){return new Ji(null,e,t)}constructor(e,t,i){this.staticValue=e,this.matchIndex=t,!i||i.length===0?this.caseOps=null:this.caseOps=i.slice(0)}}class py{constructor(e){this._source=e,this._lastCharIndex=0,this._result=[],this._resultLen=0,this._currentStaticPiece=""}emitUnchanged(e){this._emitStatic(this._source.substring(this._lastCharIndex,e)),this._lastCharIndex=e}emitStatic(e,t){this._emitStatic(e),this._lastCharIndex=t}_emitStatic(e){e.length!==0&&(this._currentStaticPiece+=e)}emitMatchIndex(e,t,i){this._currentStaticPiece.length!==0&&(this._result[this._resultLen++]=Ji.staticValue(this._currentStaticPiece),this._currentStaticPiece=""),this._result[this._resultLen++]=Ji.caseOps(e,i),this._lastCharIndex=t}finalize(){return this.emitUnchanged(this._source.length),this._currentStaticPiece.length!==0&&(this._result[this._resultLen++]=Ji.staticValue(this._currentStaticPiece),this._currentStaticPiece=""),new ps(this._result)}}function fy(c){if(!c||c.length===0)return new ps(null);const e=[],t=new py(c);for(let i=0,n=c.length;i<n;i++){const s=c.charCodeAt(i);if(s===92){if(i++,i>=n)break;const r=c.charCodeAt(i);switch(r){case 92:t.emitUnchanged(i-1),t.emitStatic("\\",i+1);break;case 110:t.emitUnchanged(i-1),t.emitStatic(`
7
+ `,i+1);break;case 116:t.emitUnchanged(i-1),t.emitStatic(" ",i+1);break;case 117:case 85:case 108:case 76:t.emitUnchanged(i-1),t.emitStatic("",i+1),e.push(String.fromCharCode(r));break}continue}if(s===36){if(i++,i>=n)break;const r=c.charCodeAt(i);if(r===36){t.emitUnchanged(i-1),t.emitStatic("$",i+1);continue}if(r===48||r===38){t.emitUnchanged(i-1),t.emitMatchIndex(0,i+1,e),e.length=0;continue}if(49<=r&&r<=57){let l=r-48;if(i+1<n){const d=c.charCodeAt(i+1);if(48<=d&&d<=57){i++,l=l*10+(d-48),t.emitUnchanged(i-2),t.emitMatchIndex(l,i+1,e),e.length=0;continue}}t.emitUnchanged(i-1),t.emitMatchIndex(l,i+1,e),e.length=0;continue}}}return t.finalize()}const Et=new o.RawContextKey("findWidgetVisible",!1);Et.toNegated();const ha=new o.RawContextKey("findInputFocussed",!1),uh=new o.RawContextKey("replaceInputFocussed",!1),my=new o.RawContextKey("findWidgetFocused",!1),ua={primary:545,mac:{primary:2593}},ga={primary:565,mac:{primary:2613}},pa={primary:560,mac:{primary:2608}},fa={primary:554,mac:{primary:2602}},ma={primary:558,mac:{primary:2606}},$={StartFindAction:"actions.find",StartFindWithSelection:"actions.findWithSelection",StartFindWithArgs:"editor.actions.findWithArgs",NextMatchFindAction:"editor.action.nextMatchFindAction",PreviousMatchFindAction:"editor.action.previousMatchFindAction",GoToMatchFindAction:"editor.action.goToMatchFindAction",NextSelectionMatchFindAction:"editor.action.nextSelectionMatchFindAction",PreviousSelectionMatchFindAction:"editor.action.previousSelectionMatchFindAction",StartFindReplaceAction:"editor.action.startFindReplaceAction",CloseFindWidgetCommand:"closeFindWidget",ToggleCaseSensitiveCommand:"toggleFindCaseSensitive",ToggleWholeWordCommand:"toggleFindWholeWord",ToggleRegexCommand:"toggleFindRegex",ToggleSearchScopeCommand:"toggleFindInSelection",TogglePreserveCaseCommand:"togglePreserveCase",ReplaceOneAction:"editor.action.replaceOne",ReplaceAllAction:"editor.action.replaceAll",SelectAllMatchesAction:"editor.action.selectAllMatches"},jt=19999,_y=240;class Lo{constructor(e,t){this._toDispose=new a.DisposableStore,this._editor=e,this._state=t,this._isDisposed=!1,this._startSearchingTimer=new a.TimeoutTimer,this._decorations=new hh(e),this._toDispose.add(this._decorations),this._updateDecorationsScheduler=new a.RunOnceScheduler(()=>{if(this._editor.hasModel())return this.research(!1)},100),this._toDispose.add(this._updateDecorationsScheduler),this._toDispose.add(this._editor.onDidChangeCursorPosition(i=>{(i.reason===3||i.reason===5||i.reason===6)&&this._decorations.setStartPosition(this._editor.getPosition())})),this._ignoreModelContentChanged=!1,this._toDispose.add(this._editor.onDidChangeModelContent(i=>{this._ignoreModelContentChanged||(i.isFlush&&this._decorations.reset(),this._decorations.setStartPosition(this._editor.getPosition()),this._updateDecorationsScheduler.schedule())})),this._toDispose.add(this._state.onFindReplaceStateChange(i=>this._onStateChanged(i))),this.research(!1,this._state.searchScope)}dispose(){this._isDisposed=!0,a.dispose(this._startSearchingTimer),this._toDispose.dispose()}_onStateChanged(e){this._isDisposed||this._editor.hasModel()&&(e.searchString||e.isReplaceRevealed||e.isRegex||e.wholeWord||e.matchCase||e.searchScope)&&(this._editor.getModel().isTooLargeForSyncing()?(this._startSearchingTimer.cancel(),this._startSearchingTimer.setIfNotSet(()=>{e.searchScope?this.research(e.moveCursor,this._state.searchScope):this.research(e.moveCursor)},_y)):e.searchScope?this.research(e.moveCursor,this._state.searchScope):this.research(e.moveCursor))}static _getSearchRange(e,t){return t||e.getFullModelRange()}research(e,t){let i=null;typeof t<"u"?t!==null&&(Array.isArray(t)?i=t:i=[t]):i=this._decorations.getFindScopes(),i!==null&&(i=i.map(l=>{if(l.startLineNumber!==l.endLineNumber){let d=l.endLineNumber;return l.endColumn===1&&(d=d-1),new a.Range(l.startLineNumber,1,d,this._editor.getModel().getLineMaxColumn(d))}return l}));const n=this._findMatches(i,!1,jt);this._decorations.set(n,i);const s=this._editor.getSelection();let r=this._decorations.getCurrentMatchesPosition(s);if(r===0&&n.length>0){const l=a.findFirstIdxMonotonousOrArrLen(n.map(d=>d.range),d=>a.Range.compareRangesUsingStarts(d,s)>=0);r=l>0?l-1+1:r}this._state.changeMatchInfo(r,this._decorations.getCount(),void 0),e&&this._editor.getOption(50).cursorMoveOnType&&this._moveToNextMatch(this._decorations.getStartPosition())}_hasMatches(){return this._state.matchesCount>0}_cannotFind(){if(!this._hasMatches()){const e=this._decorations.getFindScope();return e&&this._editor.revealRangeInCenterIfOutsideViewport(e,0),!0}return!1}_setCurrentFindMatch(e){const t=this._decorations.setCurrentFindMatch(e);this._state.changeMatchInfo(t,this._decorations.getCount(),e),this._editor.setSelection(e),this._editor.revealRangeInCenterIfOutsideViewport(e,0)}_prevSearchPosition(e){const t=this._state.isRegex&&(this._state.searchString.indexOf("^")>=0||this._state.searchString.indexOf("$")>=0);let{lineNumber:i,column:n}=e;const s=this._editor.getModel();return t||n===1?(i===1?i=s.getLineCount():i--,n=s.getLineMaxColumn(i)):n--,new a.Position(i,n)}_moveToPrevMatch(e,t=!1){if(!this._state.canNavigateBack()){const u=this._decorations.matchAfterPosition(e);u&&this._setCurrentFindMatch(u);return}if(this._decorations.getCount()<jt){let u=this._decorations.matchBeforePosition(e);u&&u.isEmpty()&&u.getStartPosition().equals(e)&&(e=this._prevSearchPosition(e),u=this._decorations.matchBeforePosition(e)),u&&this._setCurrentFindMatch(u);return}if(this._cannotFind())return;const i=this._decorations.getFindScope(),n=Lo._getSearchRange(this._editor.getModel(),i);n.getEndPosition().isBefore(e)&&(e=n.getEndPosition()),e.isBefore(n.getStartPosition())&&(e=n.getEndPosition());const{lineNumber:s,column:r}=e,l=this._editor.getModel();let d=new a.Position(s,r),h=l.findPreviousMatch(this._state.searchString,d,this._state.isRegex,this._state.matchCase,this._state.wholeWord?this._editor.getOption(148):null,!1);if(h&&h.range.isEmpty()&&h.range.getStartPosition().equals(d)&&(d=this._prevSearchPosition(d),h=l.findPreviousMatch(this._state.searchString,d,this._state.isRegex,this._state.matchCase,this._state.wholeWord?this._editor.getOption(148):null,!1)),!!h){if(!t&&!n.containsRange(h.range))return this._moveToPrevMatch(h.range.getStartPosition(),!0);this._setCurrentFindMatch(h.range)}}moveToPrevMatch(){this._moveToPrevMatch(this._editor.getSelection().getStartPosition())}_nextSearchPosition(e){const t=this._state.isRegex&&(this._state.searchString.indexOf("^")>=0||this._state.searchString.indexOf("$")>=0);let{lineNumber:i,column:n}=e;const s=this._editor.getModel();return t||n===s.getLineMaxColumn(i)?(i===s.getLineCount()?i=1:i++,n=1):n++,new a.Position(i,n)}_moveToNextMatch(e){if(!this._state.canNavigateForward()){const i=this._decorations.matchBeforePosition(e);i&&this._setCurrentFindMatch(i);return}if(this._decorations.getCount()<jt){let i=this._decorations.matchAfterPosition(e);i&&i.isEmpty()&&i.getStartPosition().equals(e)&&(e=this._nextSearchPosition(e),i=this._decorations.matchAfterPosition(e)),i&&this._setCurrentFindMatch(i);return}const t=this._getNextMatch(e,!1,!0);t&&this._setCurrentFindMatch(t.range)}_getNextMatch(e,t,i,n=!1){if(this._cannotFind())return null;const s=this._decorations.getFindScope(),r=Lo._getSearchRange(this._editor.getModel(),s);r.getEndPosition().isBefore(e)&&(e=r.getStartPosition()),e.isBefore(r.getStartPosition())&&(e=r.getStartPosition());const{lineNumber:l,column:d}=e,h=this._editor.getModel();let u=new a.Position(l,d),g=h.findNextMatch(this._state.searchString,u,this._state.isRegex,this._state.matchCase,this._state.wholeWord?this._editor.getOption(148):null,t);return i&&g&&g.range.isEmpty()&&g.range.getStartPosition().equals(u)&&(u=this._nextSearchPosition(u),g=h.findNextMatch(this._state.searchString,u,this._state.isRegex,this._state.matchCase,this._state.wholeWord?this._editor.getOption(148):null,t)),g?!n&&!r.containsRange(g.range)?this._getNextMatch(g.range.getEndPosition(),t,i,!0):g:null}moveToNextMatch(){this._moveToNextMatch(this._editor.getSelection().getEndPosition())}_moveToMatch(e){const t=this._decorations.getDecorationRangeAt(e);t&&this._setCurrentFindMatch(t)}moveToMatch(e){this._moveToMatch(e)}_getReplacePattern(){return this._state.isRegex?fy(this._state.replaceString):ps.fromStaticValue(this._state.replaceString)}replace(){if(!this._hasMatches())return;const e=this._getReplacePattern(),t=this._editor.getSelection(),i=this._getNextMatch(t.getStartPosition(),!0,!1);if(i)if(t.equalsRange(i.range)){const n=e.buildReplaceString(i.matches,this._state.preserveCase),s=new o.ReplaceCommand(t,n);this._executeEditorCommand("replace",s),this._decorations.setStartPosition(new a.Position(t.startLineNumber,t.startColumn+n.length)),this.research(!0)}else this._decorations.setStartPosition(this._editor.getPosition()),this._setCurrentFindMatch(i.range)}_findMatches(e,t,i){const n=(e||[null]).map(s=>Lo._getSearchRange(this._editor.getModel(),s));return this._editor.getModel().findMatches(this._state.searchString,n,this._state.isRegex,this._state.matchCase,this._state.wholeWord?this._editor.getOption(148):null,t,i)}replaceAll(){if(!this._hasMatches())return;const e=this._decorations.getFindScopes();e===null&&this._state.matchesCount>=jt?this._largeReplaceAll():this._regularReplaceAll(e),this.research(!1)}_largeReplaceAll(){const t=new a.SearchParams(this._state.searchString,this._state.isRegex,this._state.matchCase,this._state.wholeWord?this._editor.getOption(148):null).parseSearchRequest();if(!t)return;let i=t.regex;if(!i.multiline){let g="mu";i.ignoreCase&&(g+="i"),i.global&&(g+="g"),i=new RegExp(i.source,g)}const n=this._editor.getModel(),s=n.getValue(1),r=n.getFullModelRange(),l=this._getReplacePattern();let d;const h=this._state.preserveCase;l.hasReplacementPatterns||h?d=s.replace(i,function(){return l.buildReplaceString(arguments,h)}):d=s.replace(i,l.buildReplaceString(null,h));const u=new o.ReplaceCommandThatPreservesSelection(r,d,this._editor.getSelection());this._executeEditorCommand("replaceAll",u)}_regularReplaceAll(e){const t=this._getReplacePattern(),i=this._findMatches(e,t.hasReplacementPatterns||this._state.preserveCase,1073741824),n=[];for(let r=0,l=i.length;r<l;r++)n[r]=t.buildReplaceString(i[r].matches,this._state.preserveCase);const s=new uy(this._editor.getSelection(),i.map(r=>r.range),n);this._executeEditorCommand("replaceAll",s)}selectAllMatches(){if(!this._hasMatches())return;const e=this._decorations.getFindScopes();let i=this._findMatches(e,!1,1073741824).map(s=>new a.Selection(s.range.startLineNumber,s.range.startColumn,s.range.endLineNumber,s.range.endColumn));const n=this._editor.getSelection();for(let s=0,r=i.length;s<r;s++)if(i[s].equalsRange(n)){i=[n].concat(i.slice(0,s)).concat(i.slice(s+1));break}this._editor.setSelections(i)}_executeEditorCommand(e,t){try{this._ignoreModelContentChanged=!0,this._editor.pushUndoStop(),this._editor.executeCommand(e,t),this._editor.pushUndoStop()}finally{this._ignoreModelContentChanged=!1}}}const vy=a.localize(5,"input"),by=a.localize(6,"Preserve Case");class Cy extends o.Toggle{constructor(e){super({icon:a.Codicon.preserveCase,title:by+e.appendTitle,isChecked:e.isChecked,hoverLifecycleOptions:e.hoverLifecycleOptions,inputActiveOptionBorder:e.inputActiveOptionBorder,inputActiveOptionForeground:e.inputActiveOptionForeground,inputActiveOptionBackground:e.inputActiveOptionBackground})}}class Sy extends o.Widget{get onDidOptionChange(){return this._onDidOptionChange.event}get onKeyDown(){return this._onKeyDown.event}get onPreserveCaseKeyDown(){return this._onPreserveCaseKeyDown.event}constructor(e,t,i,n){super(),this._showOptionButtons=i,this.fixFocusOnOptionClickEnabled=!0,this.cachedOptionsWidth=0,this._onDidOptionChange=this._register(new a.Emitter),this._onKeyDown=this._register(new a.Emitter),this._onMouseDown=this._register(new a.Emitter),this._onInput=this._register(new a.Emitter),this._onKeyUp=this._register(new a.Emitter),this._onPreserveCaseKeyDown=this._register(new a.Emitter),this.contextViewProvider=t,this.placeholder=n.placeholder||"",this.validation=n.validation,this.label=n.label||vy;const s=n.appendPreserveCaseLabel||"",r=n.history||new Set([]),l=!!n.flexibleHeight,d=!!n.flexibleWidth,h=n.flexibleMaxHeight;this.domNode=document.createElement("div"),this.domNode.classList.add("monaco-findInput"),this.inputBox=this._register(new o.HistoryInputBox(this.domNode,this.contextViewProvider,{ariaLabel:this.label||"",placeholder:this.placeholder||"",validationOptions:{validation:this.validation},history:r,showHistoryHint:n.showHistoryHint,flexibleHeight:l,flexibleWidth:d,flexibleMaxHeight:h,inputBoxStyles:n.inputBoxStyles})),this.preserveCase=this._register(new Cy({appendTitle:s,isChecked:!1,hoverLifecycleOptions:n.hoverLifecycleOptions,...n.toggleStyles})),this._register(this.preserveCase.onChange(p=>{this._onDidOptionChange.fire(p),!p&&this.fixFocusOnOptionClickEnabled&&this.inputBox.focus(),this.validate()})),this._register(this.preserveCase.onKeyDown(p=>{this._onPreserveCaseKeyDown.fire(p)})),this._showOptionButtons?this.cachedOptionsWidth=this.preserveCase.width():this.cachedOptionsWidth=0;const u=[this.preserveCase.domNode];this.onkeydown(this.domNode,p=>{o.navigateToggles(p,this.domNode,()=>u,()=>this.inputBox.focus())});const g=document.createElement("div");g.className="controls",g.style.display=this._showOptionButtons?"block":"none",g.appendChild(this.preserveCase.domNode),this.domNode.appendChild(g),e?.appendChild(this.domNode),this.onkeydown(this.inputBox.inputElement,p=>this._onKeyDown.fire(p)),this.onkeyup(this.inputBox.inputElement,p=>this._onKeyUp.fire(p)),this.oninput(this.inputBox.inputElement,p=>this._onInput.fire()),this.onmousedown(this.inputBox.inputElement,p=>this._onMouseDown.fire(p))}enable(){this.domNode.classList.remove("disabled"),this.inputBox.enable(),this.preserveCase.enable()}disable(){this.domNode.classList.add("disabled"),this.inputBox.disable(),this.preserveCase.disable()}setEnabled(e){e?this.enable():this.disable()}select(){this.inputBox.select()}focus(){this.inputBox.focus()}getPreserveCase(){return this.preserveCase.checked}setPreserveCase(e){this.preserveCase.checked=e}focusOnPreserve(){this.preserveCase.focus()}validate(){this.inputBox?.validate()}set width(e){this.inputBox.paddingRight=this.cachedOptionsWidth,this.domNode.style.width=e+"px"}}var Pm=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Om=function(c,e){return function(t,i){e(t,i,c)}};const gh=new o.RawContextKey("suggestWidgetVisible",!1,a.localize(1793,"Whether suggestion are visible")),ph="historyNavigationWidgetFocus",Am="historyNavigationForwardsEnabled",Fm="historyNavigationBackwardsEnabled";let Do;const _a=[];function zm(c,e){if(_a.includes(e))throw new Error("Cannot register the same widget multiple times");_a.push(e);const t=new a.DisposableStore,i=new o.RawContextKey(ph,!1).bindTo(c),n=new o.RawContextKey(Am,!0).bindTo(c),s=new o.RawContextKey(Fm,!0).bindTo(c),r=()=>{i.set(!0),Do=e},l=()=>{i.set(!1),Do===e&&(Do=void 0)};return o.isActiveElement(e.element)&&r(),t.add(e.onDidFocus(()=>r())),t.add(e.onDidBlur(()=>l())),t.add(a.toDisposable(()=>{_a.splice(_a.indexOf(e),1),l()})),{historyNavigationForwardsEnablement:n,historyNavigationBackwardsEnablement:s,dispose(){t.dispose()}}}let fh=class extends o.FindInput{constructor(e,t,i,n){super(e,t,i);const s=this._register(n.createScoped(this.inputBox.element));this._register(zm(s,this.inputBox))}};fh=Pm([Om(3,o.IContextKeyService)],fh);let mh=class extends Sy{constructor(e,t,i,n,s=!1){super(e,t,s,i);const r=this._register(n.createScoped(this.inputBox.element));this._register(zm(r,this.inputBox))}};mh=Pm([Om(3,o.IContextKeyService)],mh),o.KeybindingsRegistry.registerCommandAndKeybindingRule({id:"history.showPrevious",weight:200,when:o.ContextKeyExpr.and(o.ContextKeyExpr.has(ph),o.ContextKeyExpr.equals(Fm,!0),gh.isEqualTo(!1)),primary:16,secondary:[528],handler:c=>{Do?.showPreviousValue()}}),o.KeybindingsRegistry.registerCommandAndKeybindingRule({id:"history.showNext",weight:200,when:o.ContextKeyExpr.and(o.ContextKeyExpr.has(ph),o.ContextKeyExpr.equals(Am,!0),gh.isEqualTo(!1)),primary:18,secondary:[530],handler:c=>{Do?.showNextValue()}});function Vm(c){return c.lookupKeybinding("history.showPrevious")?.getElectronAccelerator()==="Up"&&c.lookupKeybinding("history.showNext")?.getElectronAccelerator()==="Down"}const Bm=o.registerIcon("find-collapsed",a.Codicon.chevronRight,a.localize(1011,"Icon to indicate that the editor find widget is collapsed.")),Km=o.registerIcon("find-expanded",a.Codicon.chevronDown,a.localize(1012,"Icon to indicate that the editor find widget is expanded.")),yy=o.registerIcon("find-selection",a.Codicon.selection,a.localize(1013,"Icon for 'Find in Selection' in the editor find widget.")),wy=o.registerIcon("find-replace",a.Codicon.replace,a.localize(1014,"Icon for 'Replace' in the editor find widget.")),Iy=o.registerIcon("find-replace-all",a.Codicon.replaceAll,a.localize(1015,"Icon for 'Replace All' in the editor find widget.")),xy=o.registerIcon("find-previous-match",a.Codicon.arrowUp,a.localize(1016,"Icon for 'Find Previous' in the editor find widget.")),Ey=o.registerIcon("find-next-match",a.Codicon.arrowDown,a.localize(1017,"Icon for 'Find Next' in the editor find widget.")),Ly=a.localize(1018,"Find / Replace"),_h=a.localize(1019,"Find"),Dy=a.localize(1020,"Find"),Ry=a.localize(1021,"Previous Match"),Ty=a.localize(1022,"Next Match"),Ny=a.localize(1023,"Find in Selection"),My=a.localize(1024,"Close"),vh=a.localize(1025,"Replace"),Py=a.localize(1026,"Replace"),Oy=a.localize(1027,"Replace"),Ay=a.localize(1028,"Replace All"),Fy=a.localize(1029,"Toggle Replace"),zy=a.localize(1030,"Only the first {0} results are highlighted, but all find operations work on the entire text.",jt),Vy=a.localize(1031,"{0} of {1}"),bh=a.localize(1032,"No results"),at=419,By=275-54;let Ro=69;const Ky=33,km=a.isMacintosh?256:2048;class Ch{constructor(e){this.afterLineNumber=e,this.heightInPx=Ky,this.suppressMouseDown=!1,this.domNode=document.createElement("div"),this.domNode.className="dock-find-viewzone"}}function Um(c,e,t){const i=!!e.match(/\n/);if(t&&i&&t.selectionStart>0){c.stopPropagation();return}}function $m(c,e,t){const i=!!e.match(/\n/);if(t&&i&&t.selectionEnd<t.value.length){c.stopPropagation();return}}const Ec=class Ec extends o.Widget{constructor(e,t,i,n,s,r,l,d,h,u,g){super(),this._hoverService=l,this._findWidgetSearchHistory=d,this._replaceWidgetHistory=h,this._configurationService=u,this._accessibilityService=g,this._cachedHeight=null,this._lastFocusedInputWasReplace=!1,this._lastFocusedElement=null,this._revealTimeouts=[],this._codeEditor=e,this._controller=t,this._state=i,this._contextViewProvider=n,this._keybindingService=s,this._contextKeyService=r,this._isVisible=!1,this._isReplaceVisible=!1,this._ignoreChangeEvent=!1,this._accessibilityHelpHintAnnounced=!1,this._updateHistoryDelayer=new a.Delayer(500),this._register(a.toDisposable(()=>this._updateHistoryDelayer.cancel())),this._register(this._state.onFindReplaceStateChange(p=>this._onStateChanged(p))),this._buildDomNode(),this._updateButtons(),this._tryUpdateWidgetWidth(),this._findInput.inputBox.layout(),this._register(this._codeEditor.onDidChangeConfiguration(p=>{if(p.hasChanged(104)&&(this._codeEditor.getOption(104)&&this._state.change({isReplaceRevealed:!1},!1),this._updateButtons()),p.hasChanged(166)&&this._tryUpdateWidgetWidth(),p.hasChanged(2)&&this.updateAccessibilitySupport(),p.hasChanged(50)){const f=this._codeEditor.getOption(50).loop;this._state.change({loop:f},!1);const m=this._codeEditor.getOption(50).addExtraSpaceOnTop;m&&!this._viewZone&&(this._viewZone=new Ch(0),this._showViewZone()),!m&&this._viewZone&&this._removeViewZone()}})),this.updateAccessibilitySupport(),this._register(this._codeEditor.onDidChangeCursorSelection(()=>{this._isVisible&&this._updateToggleSelectionFindButton()})),this._register(this._codeEditor.onDidFocusEditorWidget(async()=>{if(this._isVisible){const p=await this._controller.getGlobalBufferTerm();p&&p!==this._state.searchString&&(this._state.change({searchString:p},!1),this._findInput.select())}})),this._findInputFocused=ha.bindTo(r),this._findFocusTracker=this._register(o.trackFocus(this._findInput.inputBox.inputElement)),this._register(this._findFocusTracker.onDidFocus(()=>{this._findInputFocused.set(!0),this._lastFocusedInputWasReplace=!1,this._updateSearchScope()})),this._register(this._findFocusTracker.onDidBlur(()=>{this._findInputFocused.set(!1)})),this._replaceInputFocused=uh.bindTo(r),this._replaceFocusTracker=this._register(o.trackFocus(this._replaceInput.inputBox.inputElement)),this._register(this._replaceFocusTracker.onDidFocus(()=>{this._replaceInputFocused.set(!0),this._lastFocusedInputWasReplace=!0,this._updateSearchScope()})),this._register(this._replaceFocusTracker.onDidBlur(()=>{this._replaceInputFocused.set(!1)})),this._findWidgetFocused=my.bindTo(r),this._widgetFocusTracker=this._register(o.trackFocus(this._domNode)),this._register(this._widgetFocusTracker.onDidFocus(()=>{this._findWidgetFocused.set(!0)})),this._register(this._widgetFocusTracker.onDidBlur(()=>{this._findWidgetFocused.set(!1)})),this._register(o.addDisposableListener(this._domNode,"focusin",p=>{o.isHTMLElement(p.target)&&(this._lastFocusedElement=p.target)})),this._codeEditor.addOverlayWidget(this),this._codeEditor.getOption(50).addExtraSpaceOnTop&&(this._viewZone=new Ch(0)),this._register(this._codeEditor.onDidChangeModel(()=>{this._isVisible&&(this._viewZoneId=void 0)})),this._register(this._codeEditor.onDidScrollChange(p=>{if(p.scrollTopChanged){this._layoutViewZone();return}setTimeout(()=>{this._layoutViewZone()},0)}))}getId(){return Ec.ID}getDomNode(){return this._domNode}getPosition(){return this._isVisible?{preference:0}:null}_onStateChanged(e){if(e.searchString){try{this._ignoreChangeEvent=!0,this._findInput.setValue(this._state.searchString)}finally{this._ignoreChangeEvent=!1}this._updateButtons()}if(e.replaceString&&(this._replaceInput.inputBox.value=this._state.replaceString),e.isRevealed&&(this._state.isRevealed?this._reveal():this._hide(!0)),e.isReplaceRevealed&&(this._state.isReplaceRevealed?!this._codeEditor.getOption(104)&&!this._isReplaceVisible&&(this._isReplaceVisible=!0,this._replaceInput.width=o.getTotalWidth(this._findInput.domNode),this._updateButtons(),this._replaceInput.inputBox.layout()):this._isReplaceVisible&&(this._isReplaceVisible=!1,this._updateButtons())),(e.isRevealed||e.isReplaceRevealed)&&(this._state.isRevealed||this._state.isReplaceRevealed)&&this._tryUpdateHeight()&&this._showViewZone(),e.isRegex&&this._findInput.setRegex(this._state.isRegex),e.wholeWord&&this._findInput.setWholeWords(this._state.wholeWord),e.matchCase&&this._findInput.setCaseSensitive(this._state.matchCase),e.preserveCase&&this._replaceInput.setPreserveCase(this._state.preserveCase),e.searchScope&&(this._state.searchScope?this._toggleSelectionFind.checked=!0:this._toggleSelectionFind.checked=!1,this._updateToggleSelectionFindButton()),e.searchString||e.matchesCount||e.matchesPosition){const t=this._state.searchString.length>0&&this._state.matchesCount===0;this._domNode.classList.toggle("no-results",t),this._updateMatchesCount(),this._updateButtons()}(e.searchString||e.currentMatch)&&this._layoutViewZone(),e.updateHistory&&this._delayedUpdateHistory(),e.loop&&this._updateButtons()}_delayedUpdateHistory(){this._updateHistoryDelayer.trigger(this._updateHistory.bind(this)).then(void 0,a.onUnexpectedError)}_updateHistory(){this._state.searchString&&this._findInput.inputBox.addToHistory(),this._state.replaceString&&this._replaceInput.inputBox.addToHistory()}_updateMatchesCount(){this._matchesCount.style.minWidth=Ro+"px",this._state.matchesCount>=jt?this._matchesCount.title=zy:this._matchesCount.title="",this._matchesCount.firstChild?.remove();let e;if(this._state.matchesCount>0){let t=String(this._state.matchesCount);this._state.matchesCount>=jt&&(t+="+");let i=String(this._state.matchesPosition);i==="0"&&(i="?"),e=a.format(Vy,i,t)}else e=bh;this._matchesCount.appendChild(document.createTextNode(e)),o.alert(this._getAriaLabel(e,this._state.currentMatch,this._state.searchString)),Ro=Math.max(Ro,this._matchesCount.clientWidth)}_getAriaLabel(e,t,i){let n;if(e===bh)n=i===""?a.localize(1033,"{0} found",e):a.localize(1034,"{0} found for '{1}'",e,i);else if(t){const s=a.localize(1035,"{0} found for '{1}', at {2}",e,i,t.startLineNumber+":"+t.startColumn),r=this._codeEditor.getModel();r&&t.startLineNumber<=r.getLineCount()&&t.startLineNumber>=1?n=`${r.getLineContent(t.startLineNumber)}, ${s}`:n=s}else n=a.localize(1036,"{0} found for '{1}'",e,i);return n}_updateToggleSelectionFindButton(){const e=this._codeEditor.getSelection(),t=e?e.startLineNumber!==e.endLineNumber||e.startColumn!==e.endColumn:!1,i=this._toggleSelectionFind.checked;this._isVisible&&(i||t)?this._toggleSelectionFind.enable():this._toggleSelectionFind.disable()}_updateButtons(){this._findInput.setEnabled(this._isVisible),this._replaceInput.setEnabled(this._isVisible&&this._isReplaceVisible),this._updateToggleSelectionFindButton(),this._closeBtn.setEnabled(this._isVisible);const e=this._state.searchString.length>0,t=!!this._state.matchesCount;this._prevBtn.setEnabled(this._isVisible&&e&&t&&this._state.canNavigateBack()),this._nextBtn.setEnabled(this._isVisible&&e&&t&&this._state.canNavigateForward()),this._replaceBtn.setEnabled(this._isVisible&&this._isReplaceVisible&&e),this._replaceAllBtn.setEnabled(this._isVisible&&this._isReplaceVisible&&e),this._domNode.classList.toggle("replaceToggled",this._isReplaceVisible),this._toggleReplaceBtn.setExpanded(this._isReplaceVisible);const i=!this._codeEditor.getOption(104);this._toggleReplaceBtn.setEnabled(this._isVisible&&i)}_reveal(){if(this._revealTimeouts.forEach(e=>{clearTimeout(e)}),this._revealTimeouts=[],!this._isVisible){this._isVisible=!0;const e=this._codeEditor.getSelection();switch(this._codeEditor.getOption(50).autoFindInSelection){case"always":this._toggleSelectionFind.checked=!0;break;case"never":this._toggleSelectionFind.checked=!1;break;case"multiline":{const i=!!e&&e.startLineNumber!==e.endLineNumber;this._toggleSelectionFind.checked=i;break}}this._tryUpdateWidgetWidth(),this._updateButtons(),this._revealTimeouts.push(setTimeout(()=>{this._domNode.classList.add("visible"),this._domNode.setAttribute("aria-hidden","false"),this._updateFindInputAriaLabel()},0)),this._revealTimeouts.push(setTimeout(()=>{this._findInput.validate()},200)),this._codeEditor.layoutOverlayWidget(this);let t=!0;if(this._codeEditor.getOption(50).seedSearchStringFromSelection&&e){const i=this._codeEditor.getDomNode();if(i){const n=o.getDomNodePagePosition(i),s=this._codeEditor.getScrolledVisiblePosition(e.getStartPosition()),r=n.left+(s?s.left:0),l=s?s.top:0;if(this._viewZone&&l<this._viewZone.heightInPx){e.endLineNumber>e.startLineNumber&&(t=!1);const d=o.getTopLeftOffset(this._domNode).left;r>d&&(t=!1);const h=this._codeEditor.getScrolledVisiblePosition(e.getEndPosition());n.left+(h?h.left:0)>d&&(t=!1)}}}this._showViewZone(t)}}_hide(e){this._revealTimeouts.forEach(t=>{clearTimeout(t)}),this._revealTimeouts=[],this._isVisible&&(this._isVisible=!1,this._accessibilityHelpHintAnnounced=!1,this._updateButtons(),this._domNode.classList.remove("visible"),this._domNode.setAttribute("aria-hidden","true"),this._findInput.clearMessage(),e&&this._codeEditor.focus(),this._codeEditor.layoutOverlayWidget(this),this._removeViewZone())}_layoutViewZone(e){if(!this._codeEditor.getOption(50).addExtraSpaceOnTop){this._removeViewZone();return}if(!this._isVisible)return;const i=this._viewZone;this._viewZoneId!==void 0||!i||this._codeEditor.changeViewZones(n=>{i.heightInPx=this._getHeight(),this._viewZoneId=n.addZone(i),this._codeEditor.setScrollTop(e||this._codeEditor.getScrollTop()+i.heightInPx)})}_showViewZone(e=!0){if(!this._isVisible||!this._codeEditor.getOption(50).addExtraSpaceOnTop)return;this._viewZone===void 0&&(this._viewZone=new Ch(0));const i=this._viewZone;this._codeEditor.changeViewZones(n=>{if(this._viewZoneId!==void 0){const s=this._getHeight();if(s===i.heightInPx)return;const r=s-i.heightInPx;i.heightInPx=s,n.layoutZone(this._viewZoneId),e&&this._codeEditor.setScrollTop(this._codeEditor.getScrollTop()+r);return}else{let s=this._getHeight();if(s-=this._codeEditor.getOption(96).top,s<=0)return;i.heightInPx=s,this._viewZoneId=n.addZone(i),e&&this._codeEditor.setScrollTop(this._codeEditor.getScrollTop()+s)}})}_removeViewZone(){this._codeEditor.changeViewZones(e=>{this._viewZoneId!==void 0&&(e.removeZone(this._viewZoneId),this._viewZoneId=void 0,this._viewZone&&(this._codeEditor.setScrollTop(this._codeEditor.getScrollTop()-this._viewZone.heightInPx),this._viewZone=void 0))})}_tryUpdateWidgetWidth(){if(!this._isVisible||!this._domNode.isConnected)return;const e=this._codeEditor.getLayoutInfo();if(e.contentWidth<=0){this._domNode.classList.add("hiddenEditor");return}else this._domNode.classList.contains("hiddenEditor")&&this._domNode.classList.remove("hiddenEditor");const i=e.width,n=e.minimap.minimapWidth;let s=!1,r=!1,l=!1;if(this._resized&&o.getTotalWidth(this._domNode)>at){this._domNode.style.maxWidth=`${i-28-n-15}px`,this._replaceInput.width=o.getTotalWidth(this._findInput.domNode);return}if(at+28+n>=i&&(r=!0),at+28+n-Ro>=i&&(l=!0),at+28+n-Ro>=i+50&&(s=!0),this._domNode.classList.toggle("collapsed-find-widget",s),this._domNode.classList.toggle("narrow-find-widget",l),this._domNode.classList.toggle("reduced-find-widget",r),!l&&!s&&(this._domNode.style.maxWidth=`${i-28-n-15}px`),this._findInput.layout({collapsedFindWidget:s,narrowFindWidget:l,reducedFindWidget:r}),this._resized){const d=this._findInput.inputBox.element.clientWidth;d>0&&(this._replaceInput.width=d)}else this._isReplaceVisible&&(this._replaceInput.width=o.getTotalWidth(this._findInput.domNode))}_getHeight(){let e=0;return e+=4,e+=this._findInput.inputBox.height+2,this._isReplaceVisible&&(e+=4,e+=this._replaceInput.inputBox.height+2),e+=4,e}_tryUpdateHeight(){const e=this._getHeight();return this._cachedHeight!==null&&this._cachedHeight===e?!1:(this._cachedHeight=e,this._domNode.style.height=`${e}px`,!0)}focusFindInput(){this._findInput.select(),this._findInput.focus()}focusReplaceInput(){this._replaceInput.select(),this._replaceInput.focus()}highlightFindOptions(){this._findInput.highlightFindOptions()}_updateSearchScope(){if(this._codeEditor.hasModel()&&this._toggleSelectionFind.checked){const e=this._codeEditor.getSelections();e.map(t=>{t.endColumn===1&&t.endLineNumber>t.startLineNumber&&(t=t.setEndPosition(t.endLineNumber-1,this._codeEditor.getModel().getLineMaxColumn(t.endLineNumber-1)));const i=this._state.currentMatch;return t.startLineNumber!==t.endLineNumber&&!a.Range.equalsRange(t,i)?t:null}).filter(t=>!!t),e.length&&this._state.change({searchScope:e},!0)}}_onFindInputMouseDown(e){e.middleButton&&e.stopPropagation()}_onFindInputKeyDown(e){if(e.equals(km|3))if(this._keybindingService.dispatchEvent(e,e.target)){e.preventDefault();return}else{this._findInput.inputBox.insertAtCursor(`
8
+ `),e.preventDefault();return}if(e.equals(2)){this._isReplaceVisible?this._replaceInput.focus():this._findInput.focusOnCaseSensitive(),e.preventDefault();return}if(e.equals(2066)){this._codeEditor.focus(),e.preventDefault();return}if(e.equals(16))return Um(e,this._findInput.getValue(),this._findInput.domNode.querySelector("textarea"));if(e.equals(18))return $m(e,this._findInput.getValue(),this._findInput.domNode.querySelector("textarea"))}_onReplaceInputKeyDown(e){if(e.equals(km|3))if(this._keybindingService.dispatchEvent(e,e.target)){e.preventDefault();return}else{this._replaceInput.inputBox.insertAtCursor(`
9
+ `),e.preventDefault();return}if(e.equals(2)){this._findInput.focusOnCaseSensitive(),e.preventDefault();return}if(e.equals(1026)){this._findInput.focus(),e.preventDefault();return}if(e.equals(2066)){this._codeEditor.focus(),e.preventDefault();return}if(e.equals(16))return Um(e,this._replaceInput.inputBox.value,this._replaceInput.inputBox.element.querySelector("textarea"));if(e.equals(18))return $m(e,this._replaceInput.inputBox.value,this._replaceInput.inputBox.element.querySelector("textarea"))}getVerticalSashLeft(e){return 0}_keybindingLabelFor(e){return this._keybindingService.appendKeybinding("",e)}_buildDomNode(){const i=this._codeEditor.getOption(50).history,n=this._codeEditor.getOption(50).replaceHistory;this._findInput=this._register(new fh(null,this._contextViewProvider,{width:By,label:_h,placeholder:Dy,appendCaseSensitiveLabel:this._keybindingLabelFor($.ToggleCaseSensitiveCommand),appendWholeWordsLabel:this._keybindingLabelFor($.ToggleWholeWordCommand),appendRegexLabel:this._keybindingLabelFor($.ToggleRegexCommand),validation:g=>{if(g.length===0||!this._findInput.getRegex())return null;try{return new RegExp(g,"gu"),null}catch(p){return{content:p.message}}},flexibleHeight:!0,flexibleWidth:!0,flexibleMaxHeight:118,showCommonFindToggles:!0,showHistoryHint:()=>Vm(this._keybindingService),inputBoxStyles:o.defaultInputBoxStyles,toggleStyles:o.defaultToggleStyles,history:i==="workspace"?this._findWidgetSearchHistory:new Set([])},this._contextKeyService)),this._findInput.setRegex(!!this._state.isRegex),this._findInput.setCaseSensitive(!!this._state.matchCase),this._findInput.setWholeWords(!!this._state.wholeWord),this._register(this._findInput.onKeyDown(g=>{g.equals(3)&&!this._codeEditor.getOption(50).findOnType&&this._state.change({searchString:this._findInput.getValue()},!0),this._onFindInputKeyDown(g)})),this._register(this._findInput.inputBox.onDidChange(()=>{this._ignoreChangeEvent||!this._codeEditor.getOption(50).findOnType||this._state.change({searchString:this._findInput.getValue()},!0)})),this._register(this._findInput.onDidOptionChange(()=>{this._state.change({isRegex:this._findInput.getRegex(),wholeWord:this._findInput.getWholeWords(),matchCase:this._findInput.getCaseSensitive()},!0)})),this._register(this._findInput.onCaseSensitiveKeyDown(g=>{g.equals(1026)&&this._isReplaceVisible&&(this._replaceInput.focus(),g.preventDefault())})),this._register(this._findInput.onRegexKeyDown(g=>{g.equals(2)&&this._isReplaceVisible&&(this._replaceInput.focusOnPreserve(),g.preventDefault())})),this._register(this._findInput.inputBox.onDidHeightChange(g=>{this._tryUpdateHeight()&&this._showViewZone()})),a.isLinux&&this._register(this._findInput.onMouseDown(g=>this._onFindInputMouseDown(g))),this._matchesCount=document.createElement("div"),this._matchesCount.className="matchesCount",this._updateMatchesCount();const s={groupId:"find-widget"};this._prevBtn=this._register(new Wi({label:Ry+this._keybindingLabelFor($.PreviousMatchFindAction),icon:xy,hoverLifecycleOptions:s,onTrigger:()=>{a.assertReturnsDefined(this._codeEditor.getAction($.PreviousMatchFindAction)).run().then(void 0,a.onUnexpectedError)}},this._hoverService)),this._nextBtn=this._register(new Wi({label:Ty+this._keybindingLabelFor($.NextMatchFindAction),icon:Ey,hoverLifecycleOptions:s,onTrigger:()=>{a.assertReturnsDefined(this._codeEditor.getAction($.NextMatchFindAction)).run().then(void 0,a.onUnexpectedError)}},this._hoverService));const r=document.createElement("div");r.className="find-part",r.appendChild(this._findInput.domNode);const l=document.createElement("div");l.className="find-actions",r.appendChild(l),l.appendChild(this._matchesCount),l.appendChild(this._prevBtn.domNode),l.appendChild(this._nextBtn.domNode),this._toggleSelectionFind=this._register(new o.Toggle({icon:yy,title:Ny+this._keybindingLabelFor($.ToggleSearchScopeCommand),isChecked:!1,hoverLifecycleOptions:s,inputActiveOptionBackground:o.asCssVariable(o.inputActiveOptionBackground),inputActiveOptionBorder:o.asCssVariable(o.inputActiveOptionBorder),inputActiveOptionForeground:o.asCssVariable(o.inputActiveOptionForeground)})),this._register(this._toggleSelectionFind.onChange(()=>{if(this._toggleSelectionFind.checked){if(this._codeEditor.hasModel()){let g=this._codeEditor.getSelections();g=g.map(p=>(p.endColumn===1&&p.endLineNumber>p.startLineNumber&&(p=p.setEndPosition(p.endLineNumber-1,this._codeEditor.getModel().getLineMaxColumn(p.endLineNumber-1))),p.isEmpty()?null:p)).filter(p=>!!p),g.length&&this._state.change({searchScope:g},!0)}}else this._state.change({searchScope:null},!0)})),l.appendChild(this._toggleSelectionFind.domNode),this._closeBtn=this._register(new Wi({label:My+this._keybindingLabelFor($.CloseFindWidgetCommand),icon:o.widgetClose,hoverLifecycleOptions:s,onTrigger:()=>{this._state.change({isRevealed:!1,searchScope:null},!1)},onKeyDown:g=>{g.equals(2)&&this._isReplaceVisible&&(this._replaceBtn.isEnabled()?this._replaceBtn.focus():this._codeEditor.focus(),g.preventDefault())}},this._hoverService)),this._replaceInput=this._register(new mh(null,void 0,{label:vh,placeholder:Py,appendPreserveCaseLabel:this._keybindingLabelFor($.TogglePreserveCaseCommand),history:n==="workspace"?this._replaceWidgetHistory:new Set([]),flexibleHeight:!0,flexibleWidth:!0,flexibleMaxHeight:118,showHistoryHint:()=>Vm(this._keybindingService),inputBoxStyles:o.defaultInputBoxStyles,toggleStyles:o.defaultToggleStyles,hoverLifecycleOptions:s},this._contextKeyService,!0)),this._replaceInput.setPreserveCase(!!this._state.preserveCase),this._register(this._replaceInput.onKeyDown(g=>this._onReplaceInputKeyDown(g))),this._register(this._replaceInput.inputBox.onDidChange(()=>{this._state.change({replaceString:this._replaceInput.inputBox.value},!1)})),this._register(this._replaceInput.inputBox.onDidHeightChange(g=>{this._isReplaceVisible&&this._tryUpdateHeight()&&this._showViewZone()})),this._register(this._replaceInput.onDidOptionChange(()=>{this._state.change({preserveCase:this._replaceInput.getPreserveCase()},!0)})),this._register(this._replaceInput.onPreserveCaseKeyDown(g=>{g.equals(2)&&(this._prevBtn.isEnabled()?this._prevBtn.focus():this._nextBtn.isEnabled()?this._nextBtn.focus():this._toggleSelectionFind.enabled?this._toggleSelectionFind.focus():this._closeBtn.isEnabled()&&this._closeBtn.focus(),g.preventDefault())})),this._replaceBtn=this._register(new Wi({label:Oy+this._keybindingLabelFor($.ReplaceOneAction),icon:wy,hoverLifecycleOptions:s,onTrigger:()=>{this._controller.replace()},onKeyDown:g=>{g.equals(1026)&&(this._closeBtn.focus(),g.preventDefault())}},this._hoverService)),this._replaceAllBtn=this._register(new Wi({label:Ay+this._keybindingLabelFor($.ReplaceAllAction),icon:Iy,hoverLifecycleOptions:s,onTrigger:()=>{this._controller.replaceAll()}},this._hoverService));const d=document.createElement("div");d.className="replace-part",d.appendChild(this._replaceInput.domNode);const h=document.createElement("div");h.className="replace-actions",d.appendChild(h),h.appendChild(this._replaceBtn.domNode),h.appendChild(this._replaceAllBtn.domNode),this._toggleReplaceBtn=this._register(new Wi({label:Fy,className:"codicon toggle left",onTrigger:()=>{this._state.change({isReplaceRevealed:!this._isReplaceVisible},!1),this._isReplaceVisible&&(this._replaceInput.width=o.getTotalWidth(this._findInput.domNode),this._replaceInput.inputBox.layout()),this._showViewZone()}},this._hoverService)),this._toggleReplaceBtn.setExpanded(this._isReplaceVisible),this._domNode=document.createElement("div"),this._domNode.className="editor-widget find-widget",this._domNode.setAttribute("aria-hidden","true"),this._domNode.ariaLabel=Ly,this._domNode.role="dialog",this._domNode.style.width=`${at}px`,this._domNode.appendChild(this._toggleReplaceBtn.domNode),this._domNode.appendChild(r),this._domNode.appendChild(this._closeBtn.domNode),this._domNode.appendChild(d),this._resizeSash=this._register(new o.Sash(this._domNode,this,{orientation:0,size:2})),this._resized=!1;let u=at;this._register(this._resizeSash.onDidStart(()=>{u=o.getTotalWidth(this._domNode)})),this._register(this._resizeSash.onDidChange(g=>{this._resized=!0;const p=u+g.startX-g.currentX;if(p<at)return;const f=parseFloat(o.getComputedStyle(this._domNode).maxWidth)||0;p>f||(this._domNode.style.width=`${p}px`,this._isReplaceVisible&&(this._replaceInput.width=o.getTotalWidth(this._findInput.domNode)),this._findInput.inputBox.layout(),this._tryUpdateHeight())})),this._register(this._resizeSash.onDidReset(()=>{const g=o.getTotalWidth(this._domNode);if(g<at)return;let p=at;if(!this._resized||g===at){const f=this._codeEditor.getLayoutInfo();p=f.width-28-f.minimap.minimapWidth-15,this._resized=!0}this._domNode.style.width=`${p}px`,this._isReplaceVisible&&(this._replaceInput.width=o.getTotalWidth(this._findInput.domNode)),this._findInput.inputBox.layout()}))}updateAccessibilitySupport(){const e=this._codeEditor.getOption(2);this._findInput.setFocusInputOnOptionClick(e!==2),this._updateFindInputAriaLabel()}_updateFindInputAriaLabel(){let e=_h,t=vh;if(!this._accessibilityHelpHintAnnounced&&this._configurationService.getValue("accessibility.verbosity.find")&&this._accessibilityService.isScreenReaderOptimized()){const i=this._keybindingService.lookupKeybinding("editor.action.accessibilityHelp")?.getAriaLabel();if(i){const n=a.localize(1037,"Press {0} for accessibility help",i);e=a.localize(1038,"{0}, {1}",e,n),t=a.localize(1039,"{0}, {1}",t,n)}this._accessibilityHelpHintAnnounced=!0,this._labelResetTimeout?.dispose(),this._labelResetTimeout=a.disposableTimeout(()=>{this._isVisible&&(this._findInput.inputBox.setAriaLabel(_h),this._replaceInput.inputBox.setAriaLabel(vh))},1e3)}this._findInput.inputBox.setAriaLabel(e),this._replaceInput.inputBox.setAriaLabel(t)}getViewState(){let e=!1;return this._viewZone&&this._viewZoneId&&(e=this._viewZone.heightInPx>this._codeEditor.getScrollTop()),{widgetViewZoneVisible:e,scrollTop:this._codeEditor.getScrollTop()}}setViewState(e){e&&e.widgetViewZoneVisible&&this._layoutViewZone(e.scrollTop)}};Ec.ID="editor.contrib.findWidget";let va=Ec;class Wi extends o.Widget{constructor(e,t){super(),this._opts=e;let i="button";this._opts.className&&(i=i+" "+this._opts.className),this._opts.icon&&(i=i+" "+o.ThemeIcon.asClassName(this._opts.icon)),this._domNode=document.createElement("div"),this._domNode.tabIndex=0,this._domNode.className=i,this._domNode.setAttribute("role","button"),this._domNode.setAttribute("aria-label",this._opts.label),this._register(t.setupDelayedHover(this._domNode,{content:this._opts.label,style:1},e.hoverLifecycleOptions)),this.onclick(this._domNode,n=>{this._opts.onTrigger(),n.preventDefault()}),this.onkeydown(this._domNode,n=>{if(n.equals(10)||n.equals(3)){this._opts.onTrigger(),n.preventDefault();return}this._opts.onKeyDown?.(n)})}get domNode(){return this._domNode}isEnabled(){return this._domNode.tabIndex>=0}focus(){this._domNode.focus()}setEnabled(e){this._domNode.classList.toggle("disabled",!e),this._domNode.setAttribute("aria-disabled",String(!e)),this._domNode.tabIndex=e?0:-1}setExpanded(e){this._domNode.setAttribute("aria-expanded",String(!!e)),e?(this._domNode.classList.remove(...o.ThemeIcon.asClassNameArray(Bm)),this._domNode.classList.add(...o.ThemeIcon.asClassNameArray(Km))):(this._domNode.classList.remove(...o.ThemeIcon.asClassNameArray(Km)),this._domNode.classList.add(...o.ThemeIcon.asClassNameArray(Bm)))}}o.registerThemingParticipant((c,e)=>{const t=c.getColor(o.editorFindMatchHighlightBorder);t&&e.addRule(`.monaco-editor .findMatch { border: 1px ${o.isHighContrast(c.type)?"dotted":"solid"} ${t}; box-sizing: border-box; }`);const i=c.getColor(o.editorFindRangeHighlightBorder);i&&e.addRule(`.monaco-editor .findScope { border: 1px ${o.isHighContrast(c.type)?"dashed":"solid"} ${i}; }`);const n=c.getColor(o.contrastBorder);n&&e.addRule(`.monaco-editor .find-widget { border: 1px solid ${n}; }`);const s=c.getColor(o.editorFindMatchForeground);s&&e.addRule(`.monaco-editor .findMatchInline { color: ${s}; }`);const r=c.getColor(o.editorFindMatchHighlightForeground);r&&e.addRule(`.monaco-editor .currentFindMatchInline { color: ${r}; }`)});var ky=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},jm=function(c,e){return function(t,i){e(t,i,c)}};let Sh=class extends a.Disposable{constructor(e,t,i,n){super(),this._container=e,this._getContent=t,this._clipboardService=i,this._hoverService=n,this._container.classList.add("hover-row-with-copy"),this._button=this._register(new Wi({label:a.localize(1186,"Copy"),icon:a.Codicon.copy,onTrigger:()=>this._copyContent(),className:"hover-copy-button"},this._hoverService)),this._container.appendChild(this._button.domNode)}async _copyContent(){const e=this._getContent();e&&(await this._clipboardService.writeText(e),o.status(a.localize(1187,"Copied to clipboard")))}};Sh=ky([jm(2,o.IClipboardService),jm(3,o.IHoverService)],Sh);class Uy{constructor(e,t,i){this.provider=e,this.hover=t,this.ordinal=i}}async function $y(c,e,t,i,n){const s=await Promise.resolve(c.provideHover(t,i,n)).catch(a.onUnexpectedExternalError);if(!(!s||!jy(s)))return new Uy(c,s,e)}function yh(c,e,t,i,n=!1){const r=c.ordered(e,n).map((l,d)=>$y(l,d,e,t,i));return a.AsyncIterableProducer.fromPromisesResolveOrder(r).coalesce()}async function qm(c,e,t,i,n=!1){const s=[];for await(const r of yh(c,e,t,i,n))s.push(r.hover);return s}o.registerModelAndPositionCommand("_executeHoverProvider",(c,e,t)=>{const i=c.get(o.ILanguageFeaturesService);return qm(i.hoverProvider,e,t,a.CancellationToken.None)}),o.registerModelAndPositionCommand("_executeHoverProvider_recursive",(c,e,t)=>{const i=c.get(o.ILanguageFeaturesService);return qm(i.hoverProvider,e,t,a.CancellationToken.None,!0)});function jy(c){const e=typeof c.range<"u",t=typeof c.contents<"u"&&c.contents&&c.contents.length>0;return e&&t}var qy=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},fs=function(c,e){return function(t,i){e(t,i,c)}};const Hi=o.$,Gy=o.registerIcon("hover-increase-verbosity",a.Codicon.addSmall,a.localize(1188,"Icon for increaseing hover verbosity.")),Zy=o.registerIcon("hover-decrease-verbosity",a.Codicon.removeSmall,a.localize(1189,"Icon for decreasing hover verbosity."));class ze{constructor(e,t,i,n,s,r=void 0){this.owner=e,this.range=t,this.contents=i,this.isBeforeContent=n,this.ordinal=s,this.source=r}isValidForHoverAnchor(e){return e.type===1&&this.range.startColumn<=e.range.startColumn&&this.range.endColumn>=e.range.endColumn}}class Gm{constructor(e,t,i){this.hover=e,this.hoverProvider=t,this.hoverPosition=i}supportsVerbosityAction(e){switch(e){case a.HoverVerbosityAction.Increase:return this.hover.canIncreaseVerbosity??!1;case a.HoverVerbosityAction.Decrease:return this.hover.canDecreaseVerbosity??!1}}}let To=class{constructor(e,t,i,n,s,r,l){this._editor=e,this._markdownRendererService=t,this._configurationService=i,this._languageFeaturesService=n,this._keybindingService=s,this._hoverService=r,this._commandService=l,this.hoverOrdinal=3}createLoadingMessage(e){return new ze(this,e.range,[new o.MarkdownString().appendText(a.localize(1190,"Loading..."))],!1,2e3)}computeSync(e,t){if(!this._editor.hasModel()||e.type!==1)return[];const i=this._editor.getModel(),n=e.range.startLineNumber,s=i.getLineMaxColumn(n),r=[];let l=1e3;const d=i.getLineLength(n),h=i.getLanguageIdAtPosition(e.range.startLineNumber,e.range.startColumn),u=this._editor.getOption(133),g=this._configurationService.getValue("editor.maxTokenizationLineLength",{overrideIdentifier:h}),p=this._editor.getOption(69).showLongLineWarning;let f=!1;u>=0&&d>u&&e.range.startColumn>=u&&(f=!0,p&&r.push(new ze(this,e.range,[{value:a.localize(1191,"Rendering paused for long line for performance reasons. This can be configured via `editor.stopRenderingLineAfter`. [Don't Show Again](command:{0})",th),isTrusted:!0}],!1,l++))),!f&&typeof g=="number"&&d>=g&&p&&r.push(new ze(this,e.range,[{value:a.localize(1192,"Tokenization is skipped for long lines for performance reasons. This can be configured via `editor.maxTokenizationLineLength`. [Don't Show Again](command:{0})",th),isTrusted:!0}],!1,l++));let m=!1;for(const _ of t){const v=_.range.startLineNumber===n?_.range.startColumn:1,b=_.range.endLineNumber===n?_.range.endColumn:s,C=_.options.hoverMessage;if(!C||o.isEmptyMarkdownString(C))continue;_.options.beforeContentClassName&&(m=!0);const y=new a.Range(e.range.startLineNumber,v,e.range.startLineNumber,b);r.push(new ze(this,y,a.asArray(C),m,l++))}return r}computeAsync(e,t,i,n){if(!this._editor.hasModel()||e.type!==1)return a.AsyncIterableProducer.EMPTY;const s=this._editor.getModel(),r=this._languageFeaturesService.hoverProvider;return r.has(s)?this._getMarkdownHovers(r,s,e,n):a.AsyncIterableProducer.EMPTY}async*_getMarkdownHovers(e,t,i,n){const s=i.range.getStartPosition(),r=yh(e,t,s,n);for await(const l of r)if(!o.isEmptyMarkdownString(l.hover.contents)){const d=l.hover.range?a.Range.lift(l.hover.range):i.range,h=new Gm(l.hover,l.provider,s);yield new ze(this,d,l.hover.contents,!1,l.ordinal,h)}}renderHoverParts(e,t){return this._renderedHoverParts=new Xy(t,e.fragment,this,this._editor,this._commandService,this._keybindingService,this._hoverService,this._configurationService,this._markdownRendererService,e.onContentsChanged),this._renderedHoverParts}handleScroll(e){this._renderedHoverParts?.handleScroll(e)}getAccessibleContent(e){return this._renderedHoverParts?.getAccessibleContent(e)??""}updateMarkdownHoverVerbosityLevel(e,t){return Promise.resolve(this._renderedHoverParts?.updateMarkdownHoverPartVerbosityLevel(e,t))}};To=qy([fs(1,o.IMarkdownRendererService),fs(2,o.IConfigurationService),fs(3,o.ILanguageFeaturesService),fs(4,o.IKeybindingService),fs(5,o.IHoverService),fs(6,o.ICommandService)],To);class ba{constructor(e,t,i,n){this.hoverPart=e,this.hoverElement=t,this.disposables=i,this.actionsContainer=n}dispose(){this.disposables.dispose()}}class Xy{constructor(e,t,i,n,s,r,l,d,h,u){this._hoverParticipant=i,this._editor=n,this._commandService=s,this._keybindingService=r,this._hoverService=l,this._configurationService=d,this._markdownRendererService=h,this._onFinishedRendering=u,this._ongoingHoverOperations=new Map,this._disposables=new a.DisposableStore,this.renderedHoverParts=this._renderHoverParts(e,t,this._onFinishedRendering),this._disposables.add(a.toDisposable(()=>{this.renderedHoverParts.forEach(g=>{g.dispose()}),this._ongoingHoverOperations.forEach(g=>{g.tokenSource.dispose(!0)})}))}_renderHoverParts(e,t,i){return e.sort(a.compareBy(n=>n.ordinal,a.numberComparator)),e.map(n=>{const s=this._renderHoverPart(n,i);return t.appendChild(s.hoverElement),s})}_renderHoverPart(e,t){const i=this._renderMarkdownHover(e,t),n=i.hoverElement,s=e.source,r=new a.DisposableStore;if(r.add(i),!s)return new ba(e,n,r);const l=s.supportsVerbosityAction(a.HoverVerbosityAction.Increase),d=s.supportsVerbosityAction(a.HoverVerbosityAction.Decrease);if(!l&&!d)return new ba(e,n,r);const h=Hi("div.verbosity-actions");n.prepend(h);const u=Hi("div.verbosity-actions-inner");return h.append(u),r.add(this._renderHoverExpansionAction(u,a.HoverVerbosityAction.Increase,l)),r.add(this._renderHoverExpansionAction(u,a.HoverVerbosityAction.Decrease,d)),new ba(e,n,r,u)}_renderMarkdownHover(e,t){return Zm(this._editor,e,this._markdownRendererService,t)}_renderHoverExpansionAction(e,t,i){const n=new a.DisposableStore,s=t===a.HoverVerbosityAction.Increase,r=o.append(e,Hi(o.ThemeIcon.asCSSSelector(s?Gy:Zy)));r.tabIndex=0;const l=n.add(new o.WorkbenchHoverDelegate("mouse",void 0,{target:e,position:{hoverPosition:0}},this._configurationService,this._hoverService));if(n.add(this._hoverService.setupManagedHover(l,r,Qy(this._keybindingService,t))),!i)return r.classList.add("disabled"),n;r.classList.add("enabled");const d=()=>this._commandService.executeCommand(t===a.HoverVerbosityAction.Increase?na:sa,{focus:!0});return n.add(new o.ClickAction(r,d)),n.add(new o.KeyDownAction(r,d,[3,10])),n}handleScroll(e){this.renderedHoverParts.forEach(t=>{const i=t.actionsContainer;if(!i)return;const n=t.hoverElement,r=e.scrollTop+e.height,l=n.offsetTop,d=n.clientHeight,h=l+d,u=22;let g;h<=r||l>=r?g=d-u:g=r-l-u,i.style.top=`${g}px`})}async updateMarkdownHoverPartVerbosityLevel(e,t){const i=this._editor.getModel();if(!i)return;const n=this._getRenderedHoverPartAtIndex(t),s=n?.hoverPart.source;if(!n||!s?.supportsVerbosityAction(e))return;const r=await this._fetchHover(s,i,e);if(!r)return;const l=new Gm(r,s.hoverProvider,s.hoverPosition),d=n.hoverPart,h=new ze(this._hoverParticipant,d.range,r.contents,d.isBeforeContent,d.ordinal,l),u=this._updateRenderedHoverPart(t,h);if(u)return{hoverPart:h,hoverElement:u.hoverElement}}getAccessibleContent(e){const t=this.renderedHoverParts.findIndex(r=>r.hoverPart===e);if(t===-1)return;const i=this._getRenderedHoverPartAtIndex(t);return i?i.hoverElement.innerText.replace(/[^\S\n\r]+/gu," "):void 0}async _fetchHover(e,t,i){let n=i===a.HoverVerbosityAction.Increase?1:-1;const s=e.hoverProvider,r=this._ongoingHoverOperations.get(s);r&&(r.tokenSource.cancel(),n+=r.verbosityDelta);const l=new a.CancellationTokenSource;this._ongoingHoverOperations.set(s,{verbosityDelta:n,tokenSource:l});const d={verbosityRequest:{verbosityDelta:n,previousHover:e.hover}};let h;try{h=await Promise.resolve(s.provideHover(t,e.hoverPosition,l.token,d))}catch(u){a.onUnexpectedExternalError(u)}return l.dispose(),this._ongoingHoverOperations.delete(s),h}_updateRenderedHoverPart(e,t){if(e>=this.renderedHoverParts.length||e<0)return;const i=this._renderHoverPart(t,this._onFinishedRendering),n=this.renderedHoverParts[e],s=n.hoverElement,r=i.hoverElement,l=Array.from(r.children);s.replaceChildren(...l);const d=new ba(t,s,i.disposables,i.actionsContainer);return n.dispose(),this.renderedHoverParts[e]=d,d}_getRenderedHoverPartAtIndex(e){return this.renderedHoverParts[e]}dispose(){this._disposables.dispose()}}function Yy(c,e,t,i){e.sort(a.compareBy(s=>s.ordinal,a.numberComparator));const n=[];for(const s of e){const r=Zm(t,s,i,c.onContentsChanged);c.fragment.appendChild(r.hoverElement),n.push(r)}return new Zi(n)}function Zm(c,e,t,i){const n=new a.DisposableStore,s=Hi("div.hover-row"),r=Hi("div.hover-row-contents");s.appendChild(r);const l=e.contents;for(const h of l){if(o.isEmptyMarkdownString(h))continue;const u=Hi("div.markdown-hover"),g=o.append(u,Hi("div.hover-contents")),p=n.add(t.render(h,{context:c,asyncRenderCallback:()=>{g.className="hover-contents code-hover-contents",i()}}));g.appendChild(p.element),r.appendChild(u)}return{hoverPart:e,hoverElement:s,dispose(){n.dispose()}}}function Qy(c,e){switch(e){case a.HoverVerbosityAction.Increase:return c.appendKeybinding(a.localize(1193,"Increase Hover Verbosity"),na);case a.HoverVerbosityAction.Decrease:return c.appendKeybinding(a.localize(1194,"Decrease Hover Verbosity"),sa)}}const Xm=o.$;class Jy extends a.Disposable{constructor(e,t,i){super(),this.model=t,this.pixelRatio=i,this._onDidChange=this._register(new a.Emitter),this.onDidChange=this._onDidChange.event,this._onColorFlushed=this._register(new a.Emitter),this.onColorFlushed=this._onColorFlushed.event,this._domNode=Xm(".saturation-wrap"),o.append(e,this._domNode),this._canvas=document.createElement("canvas"),this._canvas.className="saturation-box",o.append(this._domNode,this._canvas),this.selection=Xm(".saturation-selection"),o.append(this._domNode,this.selection),this.layout(),this._register(o.addDisposableListener(this._domNode,o.EventType.POINTER_DOWN,n=>this.onPointerDown(n))),this._register(this.model.onDidChangeColor(this.onDidChangeColor,this)),this.monitor=null}get domNode(){return this._domNode}onPointerDown(e){if(!e.target||!(e.target instanceof Element))return;this.monitor=this._register(new o.GlobalPointerMoveMonitor);const t=o.getDomNodePagePosition(this._domNode);e.target!==this.selection&&this.onDidChangePosition(e.offsetX,e.offsetY),this.monitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>this.onDidChangePosition(n.pageX-t.left,n.pageY-t.top),()=>null);const i=o.addDisposableListener(e.target.ownerDocument,o.EventType.POINTER_UP,()=>{this._onColorFlushed.fire(),i.dispose(),this.monitor&&(this.monitor.stopMonitoring(!0),this.monitor=null)},!0)}onDidChangePosition(e,t){const i=Math.max(0,Math.min(1,e/this.width)),n=Math.max(0,Math.min(1,1-t/this.height));this.paintSelection(i,n),this._onDidChange.fire({s:i,v:n})}layout(){this.width=this._domNode.offsetWidth,this.height=this._domNode.offsetHeight,this._canvas.width=this.width*this.pixelRatio,this._canvas.height=this.height*this.pixelRatio,this.paint();const e=this.model.color.hsva;this.paintSelection(e.s,e.v)}paint(){const e=this.model.color.hsva,t=new a.Color(new a.HSVA(e.h,1,1,1)),i=this._canvas.getContext("2d"),n=i.createLinearGradient(0,0,this._canvas.width,0);n.addColorStop(0,"rgba(255, 255, 255, 1)"),n.addColorStop(.5,"rgba(255, 255, 255, 0.5)"),n.addColorStop(1,"rgba(255, 255, 255, 0)");const s=i.createLinearGradient(0,0,0,this._canvas.height);s.addColorStop(0,"rgba(0, 0, 0, 0)"),s.addColorStop(1,"rgba(0, 0, 0, 1)"),i.rect(0,0,this._canvas.width,this._canvas.height),i.fillStyle=a.Color.Format.CSS.format(t),i.fill(),i.fillStyle=n,i.fill(),i.fillStyle=s,i.fill()}paintSelection(e,t){this.selection.style.left=`${e*this.width}px`,this.selection.style.top=`${this.height-t*this.height}px`}onDidChangeColor(e){if(this.monitor&&this.monitor.isMonitoring())return;this.paint();const t=e.hsva;this.paintSelection(t.s,t.v)}}class Wy extends a.Disposable{constructor(e){super(),this._onClicked=this._register(new a.Emitter),this.onClicked=this._onClicked.event,this._button=o.append(e,document.createElement("button")),this._button.classList.add("insert-button"),this._button.textContent="Insert",this._register(o.addDisposableListener(this._button,o.EventType.CLICK,()=>{this._onClicked.fire()}))}get button(){return this._button}}const No=o.$;class Ym extends a.Disposable{constructor(e,t,i){super(),this.model=t,this._onDidChange=this._register(new a.Emitter),this.onDidChange=this._onDidChange.event,this._onColorFlushed=this._register(new a.Emitter),this.onColorFlushed=this._onColorFlushed.event,i==="standalone"?(this.domNode=o.append(e,No(".standalone-strip")),this.overlay=o.append(this.domNode,No(".standalone-overlay"))):(this.domNode=o.append(e,No(".strip")),this.overlay=o.append(this.domNode,No(".overlay"))),this.slider=o.append(this.domNode,No(".slider")),this.slider.style.top="0px",this._register(o.addDisposableListener(this.domNode,o.EventType.POINTER_DOWN,n=>this.onPointerDown(n))),this._register(t.onDidChangeColor(this.onDidChangeColor,this)),this.layout()}layout(){this.height=this.domNode.offsetHeight-this.slider.offsetHeight;const e=this.getValue(this.model.color);this.updateSliderPosition(e)}onDidChangeColor(e){const t=this.getValue(e);this.updateSliderPosition(t)}onPointerDown(e){if(!e.target||!(e.target instanceof Element))return;const t=this._register(new o.GlobalPointerMoveMonitor),i=o.getDomNodePagePosition(this.domNode);this.domNode.classList.add("grabbing"),e.target!==this.slider&&this.onDidChangeTop(e.offsetY),t.startMonitoring(e.target,e.pointerId,e.buttons,s=>this.onDidChangeTop(s.pageY-i.top),()=>null);const n=o.addDisposableListener(e.target.ownerDocument,o.EventType.POINTER_UP,()=>{this._onColorFlushed.fire(),n.dispose(),t.stopMonitoring(!0),this.domNode.classList.remove("grabbing")},!0)}onDidChangeTop(e){const t=Math.max(0,Math.min(1,1-e/this.height));this.updateSliderPosition(t),this._onDidChange.fire(t)}updateSliderPosition(e){this.slider.style.top=`${(1-e)*this.height}px`}}class Hy extends Ym{constructor(e,t,i){super(e,t,i),this.domNode.classList.add("opacity-strip"),this.onDidChangeColor(this.model.color)}onDidChangeColor(e){super.onDidChangeColor(e);const{r:t,g:i,b:n}=e.rgba,s=new a.Color(new a.RGBA(t,i,n,1)),r=new a.Color(new a.RGBA(t,i,n,0));this.overlay.style.background=`linear-gradient(to bottom, ${s} 0%, ${r} 100%)`}getValue(e){return e.hsva.a}}class ew extends Ym{constructor(e,t,i){super(e,t,i),this.domNode.classList.add("hue-strip")}getValue(e){return 1-e.hsva.h/360}}const tw=o.$;class iw extends a.Disposable{constructor(e,t,i,n){super(),this.model=t,this.pixelRatio=i,this._insertButton=null,this._domNode=tw(".colorpicker-body"),o.append(e,this._domNode),this._saturationBox=new Jy(this._domNode,this.model,this.pixelRatio),this._register(this._saturationBox),this._register(this._saturationBox.onDidChange(this.onDidSaturationValueChange,this)),this._register(this._saturationBox.onColorFlushed(this.flushColor,this)),this._opacityStrip=new Hy(this._domNode,this.model,n),this._register(this._opacityStrip),this._register(this._opacityStrip.onDidChange(this.onDidOpacityChange,this)),this._register(this._opacityStrip.onColorFlushed(this.flushColor,this)),this._hueStrip=new ew(this._domNode,this.model,n),this._register(this._hueStrip),this._register(this._hueStrip.onDidChange(this.onDidHueChange,this)),this._register(this._hueStrip.onColorFlushed(this.flushColor,this)),n==="standalone"&&(this._insertButton=this._register(new Wy(this._domNode)),this._domNode.classList.add("standalone-colorpicker"))}flushColor(){this.model.flushColor()}onDidSaturationValueChange({s:e,v:t}){const i=this.model.color.hsva;this.model.color=new a.Color(new a.HSVA(i.h,e,t,i.a))}onDidOpacityChange(e){const t=this.model.color.hsva;this.model.color=new a.Color(new a.HSVA(t.h,t.s,t.v,e))}onDidHueChange(e){const t=this.model.color.hsva,i=(1-e)*360;this.model.color=new a.Color(new a.HSVA(i===360?0:i,t.s,t.v,t.a))}get domNode(){return this._domNode}get saturationBox(){return this._saturationBox}get enterButton(){return this._insertButton}layout(){this._saturationBox.layout(),this._opacityStrip.layout(),this._hueStrip.layout()}}const nw=o.$;class sw extends a.Disposable{constructor(e){super(),this._onClicked=this._register(new a.Emitter),this.onClicked=this._onClicked.event,this._button=document.createElement("div"),this._button.classList.add("close-button"),o.append(e,this._button);const t=document.createElement("div");t.classList.add("close-button-inner-div"),o.append(this._button,t),o.append(t,nw(".button"+o.ThemeIcon.asCSSSelector(o.registerIcon("color-picker-close",a.Codicon.close,a.localize(936,"Icon to close the color picker"))))).classList.add("close-icon"),this._register(o.addDisposableListener(this._button,o.EventType.CLICK,()=>{this._onClicked.fire()}))}}const Ca=o.$;class ow extends a.Disposable{constructor(e,t,i,n){super(),this.model=t,this.type=n,this._closeButton=null,this._domNode=Ca(".colorpicker-header"),o.append(e,this._domNode),this._pickedColorNode=o.append(this._domNode,Ca(".picked-color")),o.append(this._pickedColorNode,Ca("span.codicon.codicon-color-mode")),this._pickedColorPresentation=o.append(this._pickedColorNode,document.createElement("span")),this._pickedColorPresentation.classList.add("picked-color-presentation");const s=a.localize(937,"Click to toggle color options (rgb/hsl/hex)");this._pickedColorNode.setAttribute("title",s),this._originalColorNode=o.append(this._domNode,Ca(".original-color")),this._originalColorNode.style.backgroundColor=a.Color.Format.CSS.format(this.model.originalColor)||"",this.backgroundColor=i.getColorTheme().getColor(o.editorHoverBackground)||a.Color.white,this._register(i.onDidColorThemeChange(r=>{this.backgroundColor=r.getColor(o.editorHoverBackground)||a.Color.white})),this._register(o.addDisposableListener(this._pickedColorNode,o.EventType.CLICK,()=>this.model.selectNextColorPresentation())),this._register(o.addDisposableListener(this._originalColorNode,o.EventType.CLICK,()=>{this.model.color=this.model.originalColor,this.model.flushColor()})),this._register(t.onDidChangeColor(this.onDidChangeColor,this)),this._register(t.onDidChangePresentation(this.onDidChangePresentation,this)),this._pickedColorNode.style.backgroundColor=a.Color.Format.CSS.format(t.color)||"",this._pickedColorNode.classList.toggle("light",t.color.rgba.a<.5?this.backgroundColor.isLighter():t.color.isLighter()),this.onDidChangeColor(this.model.color),this.type==="standalone"&&(this._domNode.classList.add("standalone-colorpicker"),this._closeButton=this._register(new sw(this._domNode)))}get closeButton(){return this._closeButton}get pickedColorNode(){return this._pickedColorNode}get originalColorNode(){return this._originalColorNode}onDidChangeColor(e){this._pickedColorNode.style.backgroundColor=a.Color.Format.CSS.format(e)||"",this._pickedColorNode.classList.toggle("light",e.rgba.a<.5?this.backgroundColor.isLighter():e.isLighter()),this.onDidChangePresentation()}onDidChangePresentation(){this._pickedColorPresentation.textContent=this.model.presentation?this.model.presentation.label:""}}const rw=o.$;class Qm extends o.Widget{constructor(e,t,i,n,s){super(),this.model=t,this.pixelRatio=i,this._register(o.PixelRatio.getInstance(o.getWindow(e)).onDidChange(()=>this.layout())),this._domNode=rw(".colorpicker-widget"),e.appendChild(this._domNode),this.header=this._register(new ow(this._domNode,this.model,n,s)),this.body=this._register(new iw(this._domNode,this.model,this.pixelRatio,s))}layout(){this.body.layout()}get domNode(){return this._domNode}}class aw extends a.Disposable{get color(){return this._color}set color(e){this._color.equals(e)||(this._color=e,this._onDidChangeColor.fire(e))}get presentation(){return this.colorPresentations[this.presentationIndex]}get colorPresentations(){return this._colorPresentations}set colorPresentations(e){this._colorPresentations=e,this.presentationIndex>e.length-1&&(this.presentationIndex=0),this._onDidChangePresentation.fire(this.presentation)}constructor(e,t,i){super(),this.presentationIndex=i,this._onColorFlushed=this._register(new a.Emitter),this.onColorFlushed=this._onColorFlushed.event,this._onDidChangeColor=this._register(new a.Emitter),this.onDidChangeColor=this._onDidChangeColor.event,this._onDidChangePresentation=this._register(new a.Emitter),this.onDidChangePresentation=this._onDidChangePresentation.event,this.originalColor=e,this._color=e,this._colorPresentations=t}selectNextColorPresentation(){this.presentationIndex=(this.presentationIndex+1)%this.colorPresentations.length,this.flushColor(),this._onDidChangePresentation.fire(this.presentation)}guessColorPresentation(e,t){let i=-1;for(let n=0;n<this.colorPresentations.length;n++)if(t.toLowerCase()===this.colorPresentations[n].label){i=n;break}if(i===-1){const n=t.split("(")[0].toLowerCase();for(let s=0;s<this.colorPresentations.length;s++)if(this.colorPresentations[s].label.toLowerCase().startsWith(n)){i=s;break}}i!==-1&&i!==this.presentationIndex&&(this.presentationIndex=i,this._onDidChangePresentation.fire(this.presentation))}flushColor(){this._onColorFlushed.fire(this._color)}}async function Jm(c,e,t){const i=c.getValueInRange(e.range),{red:n,green:s,blue:r,alpha:l}=e.color,d=new a.RGBA(Math.round(n*255),Math.round(s*255),Math.round(r*255),l),h=new a.Color(d),u=await pm(c,e,t,a.CancellationToken.None),g=new aw(h,[],0);return g.colorPresentations=u||[],g.guessColorPresentation(h,i),{range:a.Range.lift(e.range),model:g,provider:t}}function Wm(c,e,t,i){const n=[],s=t.presentation.textEdit??{range:e,text:t.presentation.label,forceMoveMarkers:!1};t.presentation.additionalTextEdits&&n.push(...t.presentation.additionalTextEdits);const r=a.Range.lift(s.range),l=c.getModel()._setTrackedRange(null,r,3);return i?n.push(...i.map(d=>({range:d,text:s.text,forceMoveMarkers:!1}))):n.push(s),c.executeEdits("colorpicker",n),c.pushUndoStop(),c.getModel()._getTrackedRange(l)??r}async function Mo(c,e,t,i,n){const s=await pm(c,{range:i,color:{red:t.rgba.r/255,green:t.rgba.g/255,blue:t.rgba.b/255,alpha:t.rgba.a}},n.provider,a.CancellationToken.None);e.colorPresentations=s||[]}var lw=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},cw=function(c,e){return function(t,i){e(t,i,c)}};class Po{constructor(e,t,i,n){this.owner=e,this.range=t,this.model=i,this.provider=n,this.forceShowAtRange=!0}isValidForHoverAnchor(e){return e.type===1&&this.range.startColumn<=e.range.startColumn&&this.range.endColumn>=e.range.endColumn}static fromBaseColor(e,t){return new Po(e,t.range,t.model,t.provider)}}let Sa=class{constructor(e,t){this._editor=e,this._themeService=t,this.hoverOrdinal=2}computeSync(e,t,i){return[]}computeAsync(e,t,i,n){return a.AsyncIterableProducer.fromPromise(this._computeAsync(e,t,i))}async _computeAsync(e,t,i){if(!this._editor.hasModel())return[];if(!this._isValidRequest(i))return[];const n=us.get(this._editor);if(!n)return[];for(const s of t){if(!n.isColorDecoration(s))continue;const r=n.getColorData(s.range.getStartPosition());if(r)return[Po.fromBaseColor(this,await Jm(this._editor.getModel(),r.colorInfo,r.provider))]}return[]}_isValidRequest(e){const t=this._editor.getOption(169);switch(e){case 0:return t==="hover"||t==="clickAndHover";case 1:return t==="click"||t==="clickAndHover";case 2:return!0}}renderHoverParts(e,t){const i=this._editor;if(t.length===0||!i.hasModel())return new Zi([]);const n=i.getOption(75)+8;e.setMinimumDimensions(new o.Dimension(302,n));const s=new a.DisposableStore,r=t[0],l=i.getModel(),d=r.model;this._colorPicker=s.add(new Qm(e.fragment,d,i.getOption(164),this._themeService,"hover"));let h=!1,u=new a.Range(r.range.startLineNumber,r.range.startColumn,r.range.endLineNumber,r.range.endColumn);s.add(d.onColorFlushed(async p=>{await Mo(l,d,p,u,r),h=!0,u=Wm(i,u,d)})),s.add(d.onDidChangeColor(p=>{Mo(l,d,p,u,r)})),s.add(i.onDidChangeModelContent(p=>{h?h=!1:(e.hide(),i.focus())}));const g={hoverPart:Po.fromBaseColor(this,r),hoverElement:this._colorPicker.domNode,dispose(){s.dispose()}};return new Zi([g])}getAccessibleContent(e){return a.localize(938,"There is a color picker here.")}handleResize(){this._colorPicker?.layout()}handleContentsChanged(){this._colorPicker?.layout()}handleHide(){this._colorPicker?.dispose(),this._colorPicker=void 0}isColorPickerVisible(){return!!this._colorPicker}};Sa=lw([cw(1,o.IThemeService)],Sa);function wh(c,e){return!!c[e]}class Ih{constructor(e,t){this.target=e.target,this.isLeftClick=e.event.leftButton,this.isMiddleClick=e.event.middleButton,this.isRightClick=e.event.rightButton,this.mouseMiddleClickAction=t.mouseMiddleClickAction,this.hasTriggerModifier=wh(e.event,t.triggerModifier),this.isMiddleClick&&t.mouseMiddleClickAction==="ctrlLeftClick"&&(this.isMiddleClick=!1,this.isLeftClick=!0,this.hasTriggerModifier=!0),this.hasSideBySideModifier=wh(e.event,t.triggerSideBySideModifier),this.isNoneOrSingleMouseDown=e.event.detail<=1}}class Hm{constructor(e,t){this.keyCodeIsTriggerKey=e.keyCode===t.triggerKey,this.keyCodeIsSideBySideKey=e.keyCode===t.triggerSideBySideKey,this.hasTriggerModifier=wh(e,t.triggerModifier)}}class ya{constructor(e,t,i,n,s){this.mouseMiddleClickAction=s,this.triggerKey=e,this.triggerModifier=t,this.triggerSideBySideKey=i,this.triggerSideBySideModifier=n}equals(e){return this.triggerKey===e.triggerKey&&this.triggerModifier===e.triggerModifier&&this.triggerSideBySideKey===e.triggerSideBySideKey&&this.triggerSideBySideModifier===e.triggerSideBySideModifier&&this.mouseMiddleClickAction===e.mouseMiddleClickAction}}function e_(c,e){return c==="altKey"?a.isMacintosh?new ya(57,"metaKey",6,"altKey",e):new ya(5,"ctrlKey",6,"altKey",e):a.isMacintosh?new ya(6,"altKey",57,"metaKey",e):new ya(6,"altKey",5,"ctrlKey",e)}class wa extends a.Disposable{constructor(e,t){super(),this._onMouseMoveOrRelevantKeyDown=this._register(new a.Emitter),this.onMouseMoveOrRelevantKeyDown=this._onMouseMoveOrRelevantKeyDown.event,this._onExecute=this._register(new a.Emitter),this.onExecute=this._onExecute.event,this._onCancel=this._register(new a.Emitter),this.onCancel=this._onCancel.event,this._editor=e,this._extractLineNumberFromMouseEvent=t?.extractLineNumberFromMouseEvent??(i=>i.target.position?i.target.position.lineNumber:0),this._opts=e_(this._editor.getOption(86),this._editor.getOption(87)),this._lastMouseMoveEvent=null,this._hasTriggerKeyOnMouseDown=!1,this._lineNumberOnMouseDown=0,this._register(this._editor.onDidChangeConfiguration(i=>{if(i.hasChanged(86)||i.hasChanged(87)){const n=e_(this._editor.getOption(86),this._editor.getOption(87));if(this._opts.equals(n))return;this._opts=n,this._lastMouseMoveEvent=null,this._hasTriggerKeyOnMouseDown=!1,this._lineNumberOnMouseDown=0,this._onCancel.fire()}})),this._register(this._editor.onMouseMove(i=>this._onEditorMouseMove(new Ih(i,this._opts)))),this._register(this._editor.onMouseDown(i=>this._onEditorMouseDown(new Ih(i,this._opts)))),this._register(this._editor.onMouseUp(i=>this._onEditorMouseUp(new Ih(i,this._opts)))),this._register(this._editor.onKeyDown(i=>this._onEditorKeyDown(new Hm(i,this._opts)))),this._register(this._editor.onKeyUp(i=>this._onEditorKeyUp(new Hm(i,this._opts)))),this._register(this._editor.onMouseDrag(()=>this._resetHandler())),this._register(this._editor.onDidChangeCursorSelection(i=>this._onDidChangeCursorSelection(i))),this._register(this._editor.onDidChangeModel(i=>this._resetHandler())),this._register(this._editor.onDidChangeModelContent(()=>this._resetHandler())),this._register(this._editor.onDidScrollChange(i=>{(i.scrollTopChanged||i.scrollLeftChanged)&&this._resetHandler()}))}_onDidChangeCursorSelection(e){e.selection&&e.selection.startColumn!==e.selection.endColumn&&this._resetHandler()}_onEditorMouseMove(e){this._lastMouseMoveEvent=e,this._onMouseMoveOrRelevantKeyDown.fire([e,null])}_onEditorMouseDown(e){this._hasTriggerKeyOnMouseDown=e.hasTriggerModifier,this._lineNumberOnMouseDown=this._extractLineNumberFromMouseEvent(e)}_onEditorMouseUp(e){const t=this._extractLineNumberFromMouseEvent(e);this._lineNumberOnMouseDown&&this._lineNumberOnMouseDown===t&&(this._hasTriggerKeyOnMouseDown||e.isMiddleClick&&e.mouseMiddleClickAction==="openLink")&&this._onExecute.fire(e)}_onEditorKeyDown(e){this._lastMouseMoveEvent&&(e.keyCodeIsTriggerKey||e.keyCodeIsSideBySideKey&&e.hasTriggerModifier)?this._onMouseMoveOrRelevantKeyDown.fire([this._lastMouseMoveEvent,e]):e.hasTriggerModifier&&this._onCancel.fire()}_onEditorKeyUp(e){e.keyCodeIsTriggerKey&&this._onCancel.fire()}_resetHandler(){this._lastMouseMoveEvent=null,this._hasTriggerKeyOnMouseDown=!1,this._onCancel.fire()}}class t_{constructor(e,t){this.range=e,this.direction=t}}class xh{constructor(e,t,i){this.hint=e,this.anchor=t,this.provider=i,this._isResolved=!1}with(e){const t=new xh(this.hint,e.anchor,this.provider);return t._isResolved=this._isResolved,t._currentResolve=this._currentResolve,t}async resolve(e){if(typeof this.provider.resolveInlayHint=="function"){if(this._currentResolve)return await this._currentResolve,e.isCancellationRequested?void 0:this.resolve(e);this._isResolved||(this._currentResolve=this._doResolve(e).finally(()=>this._currentResolve=void 0)),await this._currentResolve}}async _doResolve(e){try{const t=await Promise.resolve(this.provider.resolveInlayHint(this.hint,e));this.hint.tooltip=t?.tooltip??this.hint.tooltip,this.hint.label=t?.label??this.hint.label,this.hint.textEdits=t?.textEdits??this.hint.textEdits,this._isResolved=!0}catch(t){a.onUnexpectedExternalError(t),this._isResolved=!1}}}const Hs=class Hs{static async create(e,t,i,n){const s=[],r=e.ordered(t).reverse().map(l=>i.map(async d=>{try{const h=await l.provideInlayHints(t,d,n);(h?.hints.length||l.onDidChangeInlayHints)&&s.push([h??Hs._emptyInlayHintList,l])}catch(h){a.onUnexpectedExternalError(h)}}));if(await Promise.all(r.flat()),n.isCancellationRequested||t.isDisposed())throw new a.CancellationError;return new Hs(i,s,t)}constructor(e,t,i){this._disposables=new a.DisposableStore,this.ranges=e,this.provider=new Set;const n=[];for(const[s,r]of t){this._disposables.add(s),this.provider.add(r);for(const l of s.hints){const d=i.validatePosition(l.position);let h="before";const u=Hs._getRangeAtPosition(i,d);let g;u.getStartPosition().isBefore(d)?(g=a.Range.fromPositions(u.getStartPosition(),d),h="after"):(g=a.Range.fromPositions(d,u.getEndPosition()),h="before"),n.push(new xh(l,new t_(g,h),r))}}this.items=n.sort((s,r)=>a.Position.compare(s.hint.position,r.hint.position))}dispose(){this._disposables.dispose()}static _getRangeAtPosition(e,t){const i=t.lineNumber,n=e.getWordAtPosition(t);if(n)return new a.Range(i,n.startColumn,i,n.endColumn);e.tokenization.tokenizeIfCheap(i);const s=e.tokenization.getLineTokens(i),r=t.column-1,l=s.findTokenIndexAtOffset(r);let d=s.getStartOffset(l),h=s.getEndOffset(l);return h-d===1&&(d===r&&l>1?(d=s.getStartOffset(l-1),h=s.getEndOffset(l-1)):h===r&&l<s.getCount()-1&&(d=s.getStartOffset(l+1),h=s.getEndOffset(l+1))),new a.Range(i,d+1,i,h+1)}};Hs._emptyInlayHintList=Object.freeze({dispose(){},hints:[]});let Ia=Hs;function dw(c){return o.createCommandUri(c.id,...c.arguments??[]).toString()}var hw=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},lt=function(c,e){return function(t,i){e(t,i,c)}};let ct=class extends o.CodeEditorWidget{constructor(e,t,i,n,s,r,l,d,h,u,g,p,f,m){super(e,{...n.getRawOptions(),overflowWidgetsDomNode:n.getOverflowWidgetsDomNode()},i,s,r,l,d,h,u,g,p,f,m),this._parentEditor=n,this._overwriteOptions=t,super.updateOptions(this._overwriteOptions),this._register(n.onDidChangeConfiguration(_=>this._onParentConfigurationChanged(_)))}getParentEditor(){return this._parentEditor}_onParentConfigurationChanged(e){super.updateOptions(this._parentEditor.getRawOptions()),super.updateOptions(this._overwriteOptions)}updateOptions(e){a.mixin(this._overwriteOptions,e,!0),super.updateOptions(this._overwriteOptions)}};ct=hw([lt(4,o.IInstantiationService),lt(5,o.ICodeEditorService),lt(6,o.ICommandService),lt(7,o.IContextKeyService),lt(8,o.IThemeService),lt(9,o.INotificationService),lt(10,o.IAccessibilityService),lt(11,o.ILanguageConfigurationService),lt(12,o.ILanguageFeaturesService),lt(13,o.IUserInteractionService)],ct);function i_(c){const e=c.get(o.ICodeEditorService).getFocusedCodeEditor();return e instanceof ct?e.getParentEditor():e}const n_=new a.Color(new a.RGBA(0,122,204)),uw={showArrow:!0,showFrame:!0,className:"",frameColor:n_,arrowColor:n_,keepEditorSelection:!1},gw="vs.editor.contrib.zoneWidget";class pw{constructor(e,t,i,n,s,r,l,d){this.id="",this.domNode=e,this.afterLineNumber=t,this.afterColumn=i,this.heightInLines=n,this.showInHiddenAreas=l,this.ordinal=d,this._onDomNodeTop=s,this._onComputedHeight=r}onDomNodeTop(e){this._onDomNodeTop(e)}onComputedHeight(e){this._onComputedHeight(e)}}class fw{constructor(e,t){this._id=e,this._domNode=t}getId(){return this._id}getDomNode(){return this._domNode}getPosition(){return null}}const Lc=class Lc{constructor(e){this._editor=e,this._ruleName=Lc._IdGenerator.nextId(),this._color=null,this._height=-1,this._decorations=this._editor.createDecorationsCollection()}dispose(){this.hide(),o.removeCSSRulesContainingSelector(this._ruleName)}set color(e){this._color!==e&&(this._color=e,this._updateStyle())}set height(e){this._height!==e&&(this._height=e,this._updateStyle())}_updateStyle(){o.removeCSSRulesContainingSelector(this._ruleName),o.createCSSRule(`.monaco-editor ${this._ruleName}`,`border-style: solid; border-color: transparent; border-bottom-color: ${this._color}; border-width: ${this._height}px; bottom: -${this._height}px !important; margin-left: -${this._height}px; `)}show(e){e.column===1&&(e={lineNumber:e.lineNumber,column:2}),this._decorations.set([{range:a.Range.fromPositions(e),options:{description:"zone-widget-arrow",className:this._ruleName,stickiness:1}}])}hide(){this._decorations.clear()}};Lc._IdGenerator=new o.IdGenerator(".arrow-decoration-");let Eh=Lc;class mw{constructor(e,t={}){this._arrow=null,this._overlayWidget=null,this._resizeSash=null,this._isSashResizeHeight=!1,this._viewZone=null,this._disposables=new a.DisposableStore,this.container=null,this._isShowing=!1,this.editor=e,this._positionMarkerId=this.editor.createDecorationsCollection(),this.options=a.deepClone(t),a.mixin(this.options,uw,!1),this.domNode=document.createElement("div"),this.options.isAccessible||(this.domNode.setAttribute("aria-hidden","true"),this.domNode.setAttribute("role","presentation")),this._disposables.add(this.editor.onDidLayoutChange(i=>{const n=this._getWidth(i);this.domNode.style.width=n+"px",this.domNode.style.left=this._getLeft(i)+"px",this._onWidth(n)}))}dispose(){this._overlayWidget&&(this.editor.removeOverlayWidget(this._overlayWidget),this._overlayWidget=null),this._viewZone&&this.editor.changeViewZones(e=>{this._viewZone&&e.removeZone(this._viewZone.id),this._viewZone=null}),this._positionMarkerId.clear(),this._disposables.dispose()}create(){this.domNode.classList.add("zone-widget"),this.options.className&&this.domNode.classList.add(this.options.className),this.container=document.createElement("div"),this.container.classList.add("zone-widget-container"),this.domNode.appendChild(this.container),this.options.showArrow&&(this._arrow=new Eh(this.editor),this._disposables.add(this._arrow)),this._fillContainer(this.container),this._initSash(),this._applyStyles()}style(e){e.frameColor&&(this.options.frameColor=e.frameColor),e.arrowColor&&(this.options.arrowColor=e.arrowColor),this._applyStyles()}_applyStyles(){if(this.container&&this.options.frameColor){const e=this.options.frameColor.toString();this.container.style.borderTopColor=e,this.container.style.borderBottomColor=e}if(this._arrow&&this.options.arrowColor){const e=this.options.arrowColor.toString();this._arrow.color=e}}_getWidth(e){return e.width-e.minimap.minimapWidth-e.verticalScrollbarWidth}_getLeft(e){return e.minimap.minimapWidth>0&&e.minimap.minimapLeft===0?e.minimap.minimapWidth:0}_onViewZoneTop(e){this.domNode.style.top=e+"px"}_onViewZoneHeight(e){if(this.domNode.style.height=`${e}px`,this.container){const t=e-this._decoratingElementsHeight();this.container.style.height=`${t}px`;const i=this.editor.getLayoutInfo();this._doLayout(t,this._getWidth(i))}this._resizeSash?.layout()}get position(){const e=this._positionMarkerId.getRange(0);if(e)return e.getStartPosition()}show(e,t){const i=a.Range.isIRange(e)?a.Range.lift(e):a.Range.fromPositions(e);this._isShowing=!0,this._showImpl(i,t),this._isShowing=!1,this._positionMarkerId.set([{range:i,options:o.ModelDecorationOptions.EMPTY}])}hide(){this._viewZone&&(this.editor.changeViewZones(e=>{this._viewZone&&e.removeZone(this._viewZone.id)}),this._viewZone=null),this._overlayWidget&&(this.editor.removeOverlayWidget(this._overlayWidget),this._overlayWidget=null),this._arrow?.hide(),this._positionMarkerId.clear(),this._isSashResizeHeight=!1}_decoratingElementsHeight(){const e=this.editor.getOption(75);let t=0;if(this.options.showArrow){const i=Math.round(e/3);t+=2*i}if(this.options.showFrame){const i=this.options.frameWidth??Math.round(e/9);t+=2*i}return t}_getMaximumHeightInLines(){return Math.max(12,this.editor.getLayoutInfo().height/this.editor.getOption(75)*.8)}_showImpl(e,t){const i=e.getStartPosition(),n=this.editor.getLayoutInfo(),s=this._getWidth(n);this.domNode.style.width=`${s}px`,this.domNode.style.left=this._getLeft(n)+"px";const r=document.createElement("div");r.style.overflow="hidden";const l=this.editor.getOption(75),d=this._getMaximumHeightInLines();d!==void 0&&(t=Math.min(t,d));let h=0,u=0;if(this._arrow&&this.options.showArrow&&(h=Math.round(l/3),this._arrow.height=h,this._arrow.show(i)),this.options.showFrame&&(u=Math.round(l/9)),this.editor.changeViewZones(f=>{this._viewZone&&f.removeZone(this._viewZone.id),this._overlayWidget&&(this.editor.removeOverlayWidget(this._overlayWidget),this._overlayWidget=null),this.domNode.style.top="-1000px",this._viewZone=new pw(r,i.lineNumber,i.column,t,m=>this._onViewZoneTop(m),m=>this._onViewZoneHeight(m),this.options.showInHiddenAreas,this.options.ordinal),this._viewZone.id=f.addZone(this._viewZone),this._overlayWidget=new fw(gw+this._viewZone.id,this.domNode),this.editor.addOverlayWidget(this._overlayWidget)}),this._updateSashEnablement(),this.container&&this.options.showFrame){const f=this.options.frameWidth?this.options.frameWidth:u;this.container.style.borderTopWidth=f+"px",this.container.style.borderBottomWidth=f+"px"}const g=t*l-this._decoratingElementsHeight();this.container&&(this.container.style.top=h+"px",this.container.style.height=g+"px",this.container.style.overflow="hidden"),this._doLayout(g,s),this.options.keepEditorSelection||this.editor.setSelection(e);const p=this.editor.getModel();if(p){const f=p.validateRange(new a.Range(e.startLineNumber,1,e.endLineNumber+1,1));this.revealRange(f,f.startLineNumber===p.getLineCount())}}revealRange(e,t){t?this.editor.revealLineNearTop(e.endLineNumber,0):this.editor.revealRange(e,0)}setCssClass(e,t){this.container&&(t&&this.container.classList.remove(t),this.container.classList.add(e))}_onWidth(e){}_doLayout(e,t){}_relayout(e,t){const i=this._getMaximumHeightInLines(),n=t&&i!==void 0?Math.min(i,e):e;this._viewZone&&this._viewZone.heightInLines!==n&&(this.editor.changeViewZones(s=>{this._viewZone&&(this._viewZone.heightInLines=n,s.layoutZone(this._viewZone.id))}),this._updateSashEnablement())}_initSash(){if(this._resizeSash)return;this._resizeSash=this._disposables.add(new o.Sash(this.domNode,this,{orientation:1})),this.options.isResizeable||(this._resizeSash.state=0);let e;this._disposables.add(this._resizeSash.onDidStart(t=>{this._viewZone&&(e={startY:t.startY,heightInLines:this._viewZone.heightInLines,...this._getResizeBounds()})})),this._disposables.add(this._resizeSash.onDidEnd(()=>{e=void 0})),this._disposables.add(this._resizeSash.onDidChange(t=>{if(e){const i=(t.currentY-e.startY)/this.editor.getOption(75),n=i<0?Math.ceil(i):Math.floor(i),s=e.heightInLines+n;s>e.minLines&&s<e.maxLines&&(this._isSashResizeHeight=!0,this._relayout(s))}}))}_updateSashEnablement(){if(this._resizeSash){const{minLines:e,maxLines:t}=this._getResizeBounds();this._resizeSash.state=e===t?0:3}}_getResizeBounds(){return{minLines:5,maxLines:35}}getHorizontalSashLeft(){return 0}getHorizontalSashTop(){return(this.domNode.style.height===null?0:parseInt(this.domNode.style.height))-this._decoratingElementsHeight()/2}getHorizontalSashWidth(){const e=this.editor.getLayoutInfo();return e.width-e.minimap.minimapWidth}}var s_=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},o_=function(c,e){return function(t,i){e(t,i,c)}};const r_=o.createDecorator("IPeekViewService");o.registerSingleton(r_,class{constructor(){this._widgets=new Map}addExclusiveWidget(c,e){const t=this._widgets.get(c);t&&(t.listener.dispose(),t.widget.dispose());const i=()=>{const n=this._widgets.get(c);n&&n.widget===e&&(n.listener.dispose(),this._widgets.delete(c))};this._widgets.set(c,{widget:e,listener:e.onDidClose(i)})}},1);var pe;(function(c){c.inPeekEditor=new o.RawContextKey("inReferenceSearchEditor",!0,a.localize(1382,"Whether the current code editor is embedded inside peek")),c.notInPeekEditor=c.inPeekEditor.toNegated()})(pe||(pe={}));let xa=(eo=class{constructor(e,t){e instanceof ct&&pe.inPeekEditor.bindTo(t)}dispose(){}},eo.ID="editor.contrib.referenceController",eo);xa=s_([o_(1,o.IContextKeyService)],xa),o.registerEditorContribution(xa.ID,xa,0);const _w={headerBackgroundColor:a.Color.white,primaryHeadingColor:a.Color.fromHex("#333333"),secondaryHeadingColor:a.Color.fromHex("#6c6c6cb3")};let Ea=class extends mw{constructor(e,t,i){super(e,t),this.instantiationService=i,this._onDidClose=new a.Emitter,this.onDidClose=this._onDidClose.event,a.mixin(this.options,_w,!1);const n=o.observableCodeEditor(this.editor);n.openedPeekWidgets.set(n.openedPeekWidgets.get()+1,void 0)}dispose(){if(!this.disposed){this.disposed=!0,super.dispose(),this._onDidClose.fire(this),this._onDidClose.dispose();const e=o.observableCodeEditor(this.editor);e.openedPeekWidgets.set(e.openedPeekWidgets.get()-1,void 0)}}style(e){const t=this.options;e.headerBackgroundColor&&(t.headerBackgroundColor=e.headerBackgroundColor),e.primaryHeadingColor&&(t.primaryHeadingColor=e.primaryHeadingColor),e.secondaryHeadingColor&&(t.secondaryHeadingColor=e.secondaryHeadingColor),super.style(e)}_applyStyles(){super._applyStyles();const e=this.options;this._headElement&&e.headerBackgroundColor&&(this._headElement.style.backgroundColor=e.headerBackgroundColor.toString()),this._primaryHeading&&e.primaryHeadingColor&&(this._primaryHeading.style.color=e.primaryHeadingColor.toString()),this._secondaryHeading&&e.secondaryHeadingColor&&(this._secondaryHeading.style.color=e.secondaryHeadingColor.toString()),this._bodyElement&&e.frameColor&&(this._bodyElement.style.borderColor=e.frameColor.toString())}_fillContainer(e){this.setCssClass("peekview-widget"),this._headElement=o.$(".head"),this._bodyElement=o.$(".body"),this._fillHead(this._headElement),this._fillBody(this._bodyElement),e.appendChild(this._headElement),e.appendChild(this._bodyElement)}_fillHead(e,t){this._titleElement=o.$(".peekview-title"),this.options.supportOnTitleClick&&(this._titleElement.classList.add("clickable"),o.addStandardDisposableListener(this._titleElement,"click",s=>this._onTitleClick(s))),o.append(this._headElement,this._titleElement),this._fillTitleIcon(this._titleElement),this._primaryHeading=o.$("span.filename"),this._secondaryHeading=o.$("span.dirname"),this._metaHeading=o.$("span.meta"),o.append(this._titleElement,this._primaryHeading,this._secondaryHeading,this._metaHeading);const i=o.$(".peekview-actions");o.append(this._headElement,i);const n=this._getActionBarOptions();this._actionbarWidget=new o.ActionBar(i,n),this._disposables.add(this._actionbarWidget),t||this._actionbarWidget.push(this._disposables.add(new o.Action("peekview.close",a.localize(1383,"Close"),o.ThemeIcon.asClassName(a.Codicon.close),!0,()=>(this.dispose(),Promise.resolve()))),{label:!1,icon:!0})}_fillTitleIcon(e){}_getActionBarOptions(){return{actionViewItemProvider:o.createActionViewItem.bind(void 0,this.instantiationService),orientation:0}}_onTitleClick(e){}setTitle(e,t){this._primaryHeading&&this._secondaryHeading&&(this._primaryHeading.innerText=e,this._primaryHeading.setAttribute("title",e),t?this._secondaryHeading.innerText=t:o.clearNode(this._secondaryHeading))}setMetaTitle(e){this._metaHeading&&(e?(this._metaHeading.innerText=e,o.show(this._metaHeading)):o.hide(this._metaHeading))}_doLayout(e,t){if(!this._isShowing&&e<0){this.dispose();return}const i=Math.ceil(this.editor.getOption(75)*1.2),n=Math.round(e-(i+1));this._doLayoutHead(i,t),this._doLayoutBody(n,t)}_doLayoutHead(e,t){this._headElement&&(this._headElement.style.height=`${e}px`,this._headElement.style.lineHeight=this._headElement.style.height)}_doLayoutBody(e,t){this._bodyElement&&(this._bodyElement.style.height=`${e}px`)}};Ea=s_([o_(2,o.IInstantiationService)],Ea);const vw=o.registerColor("peekViewTitle.background",{dark:"#252526",light:"#F3F3F3",hcDark:a.Color.black,hcLight:a.Color.white},a.localize(1384,"Background color of the peek view title area.")),a_=o.registerColor("peekViewTitleLabel.foreground",{dark:a.Color.white,light:a.Color.black,hcDark:a.Color.white,hcLight:o.editorForeground},a.localize(1385,"Color of the peek view title.")),l_=o.registerColor("peekViewTitleDescription.foreground",{dark:"#ccccccb3",light:"#616161",hcDark:"#FFFFFF99",hcLight:"#292929"},a.localize(1386,"Color of the peek view title info.")),bw=o.registerColor("peekView.border",{dark:o.editorInfoForeground,light:o.editorInfoForeground,hcDark:o.contrastBorder,hcLight:o.contrastBorder},a.localize(1387,"Color of the peek view borders and arrow.")),Cw=o.registerColor("peekViewResult.background",{dark:"#252526",light:"#F3F3F3",hcDark:a.Color.black,hcLight:a.Color.white},a.localize(1388,"Background color of the peek view result list."));o.registerColor("peekViewResult.lineForeground",{dark:"#bbbbbb",light:"#646465",hcDark:a.Color.white,hcLight:o.editorForeground},a.localize(1389,"Foreground color for line nodes in the peek view result list.")),o.registerColor("peekViewResult.fileForeground",{dark:a.Color.white,light:"#1E1E1E",hcDark:a.Color.white,hcLight:o.editorForeground},a.localize(1390,"Foreground color for file nodes in the peek view result list.")),o.registerColor("peekViewResult.selectionBackground",{dark:"#3399ff33",light:"#3399ff33",hcDark:null,hcLight:null},a.localize(1391,"Background color of the selected entry in the peek view result list.")),o.registerColor("peekViewResult.selectionForeground",{dark:a.Color.white,light:"#6C6C6C",hcDark:a.Color.white,hcLight:o.editorForeground},a.localize(1392,"Foreground color of the selected entry in the peek view result list."));const Lh=o.registerColor("peekViewEditor.background",{dark:"#001F33",light:"#F2F8FC",hcDark:a.Color.black,hcLight:a.Color.white},a.localize(1393,"Background color of the peek view editor."));o.registerColor("peekViewEditorGutter.background",Lh,a.localize(1394,"Background color of the gutter in the peek view editor.")),o.registerColor("peekViewEditorStickyScroll.background",Lh,a.localize(1395,"Background color of sticky scroll in the peek view editor.")),o.registerColor("peekViewEditorStickyScrollGutter.background",Lh,a.localize(1396,"Background color of the gutter part of sticky scroll in the peek view editor.")),o.registerColor("peekViewResult.matchHighlightBackground",{dark:"#ea5c004d",light:"#ea5c004d",hcDark:null,hcLight:null},a.localize(1397,"Match highlight color in the peek view result list.")),o.registerColor("peekViewEditor.matchHighlightBackground",{dark:"#ff8f0099",light:"#f5d802de",hcDark:null,hcLight:null},a.localize(1398,"Match highlight color in the peek view editor.")),o.registerColor("peekViewEditor.matchHighlightBorder",{dark:null,light:null,hcDark:o.activeContrastBorder,hcLight:o.activeContrastBorder},a.localize(1399,"Match highlight border in the peek view editor."));class Lt{constructor(e,t,i,n){this.isProviderFirst=e,this.parent=t,this.link=i,this._rangeCallback=n,this.id=o.defaultGenerator.nextId()}get uri(){return this.link.uri}get range(){return this._range??this.link.targetSelectionRange??this.link.range}set range(e){this._range=e,this._rangeCallback(this)}get ariaMessage(){const e=this.parent.getPreview(this)?.preview(this.range);return e?a.localize(1146,"{0} in {1} on line {2} at column {3}",e.value,o.basename(this.uri),this.range.startLineNumber,this.range.startColumn):a.localize(1145,"in {0} on line {1} at column {2}",o.basename(this.uri),this.range.startLineNumber,this.range.startColumn)}}class Sw{constructor(e){this._modelReference=e}dispose(){this._modelReference.dispose()}preview(e,t=8){const i=this._modelReference.object.textEditorModel;if(!i)return;const{startLineNumber:n,startColumn:s,endLineNumber:r,endColumn:l}=e,d=i.getWordUntilPosition({lineNumber:n,column:s-t}),h=new a.Range(n,d.startColumn,n,s),u=new a.Range(r,l,r,1073741824),g=i.getValueInRange(h).replace(/^\s+/,""),p=i.getValueInRange(e),f=i.getValueInRange(u).replace(/\s+$/,"");return{value:g+p+f,highlight:{start:g.length,end:g.length+p.length}}}}class ms{constructor(e,t){this.parent=e,this.uri=t,this.children=[],this._previews=new a.ResourceMap}dispose(){a.dispose(this._previews.values()),this._previews.clear()}getPreview(e){return this._previews.get(e.uri)}get ariaMessage(){const e=this.children.length;return e===1?a.localize(1147,"1 symbol in {0}, full path {1}",o.basename(this.uri),this.uri.fsPath):a.localize(1148,"{0} symbols in {1}, full path {2}",e,o.basename(this.uri),this.uri.fsPath)}async resolve(e){if(this._previews.size!==0)return this;for(const t of this.children)if(!this._previews.has(t.uri))try{const i=await e.createModelReference(t.uri);this._previews.set(t.uri,new Sw(i))}catch(i){a.onUnexpectedError(i)}return this}}class Ce{constructor(e,t){this.groups=[],this.references=[],this._onDidChangeReferenceRange=new a.Emitter,this.onDidChangeReferenceRange=this._onDidChangeReferenceRange.event,this._links=e,this._title=t;const[i]=e;e.sort(Ce._compareReferences);let n;for(const s of e)if((!n||!o.extUri.isEqual(n.uri,s.uri,!0))&&(n=new ms(this,s.uri),this.groups.push(n)),n.children.length===0||Ce._compareReferences(s,n.children[n.children.length-1])!==0){const r=new Lt(i===s,n,s,l=>this._onDidChangeReferenceRange.fire(l));this.references.push(r),n.children.push(r)}}dispose(){a.dispose(this.groups),this._onDidChangeReferenceRange.dispose(),this.groups.length=0}clone(){return new Ce(this._links,this._title)}get title(){return this._title}get isEmpty(){return this.groups.length===0}get ariaMessage(){return this.isEmpty?a.localize(1149,"No results found"):this.references.length===1?a.localize(1150,"Found 1 symbol in {0}",this.references[0].uri.fsPath):this.groups.length===1?a.localize(1151,"Found {0} symbols in {1}",this.references.length,this.groups[0].uri.fsPath):a.localize(1152,"Found {0} symbols in {1} files",this.references.length,this.groups.length)}nextOrPreviousReference(e,t){const{parent:i}=e;let n=i.children.indexOf(e);const s=i.children.length,r=i.parent.groups.length;return r===1||t&&n+1<s||!t&&n>0?(t?n=(n+1)%s:n=(n+s-1)%s,i.children[n]):(n=i.parent.groups.indexOf(i),t?(n=(n+1)%r,i.parent.groups[n].children[0]):(n=(n+r-1)%r,i.parent.groups[n].children[i.parent.groups[n].children.length-1]))}nearestReference(e,t){const i=this.references.map((n,s)=>({idx:s,prefixLen:a.commonPrefixLength(n.uri.toString(),e.toString()),offsetDist:Math.abs(n.range.startLineNumber-t.lineNumber)*100+Math.abs(n.range.startColumn-t.column)})).sort((n,s)=>n.prefixLen>s.prefixLen?-1:n.prefixLen<s.prefixLen?1:n.offsetDist<s.offsetDist?-1:n.offsetDist>s.offsetDist?1:0)[0];if(i)return this.references[i.idx]}referenceAt(e,t){for(const i of this.references)if(i.uri.toString()===e.toString()&&a.Range.containsPosition(i.range,t))return i}firstReference(){for(const e of this.references)if(e.isProviderFirst)return e;return this.references[0]}static _compareReferences(e,t){return o.extUri.compare(e.uri,t.uri)||a.Range.compareRangesUsingStarts(e.range,t.range)}}var La=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Da=function(c,e){return function(t,i){e(t,i,c)}},Dh;let Rh=class{constructor(e){this._resolverService=e}hasChildren(e){return e instanceof Ce||e instanceof ms}getChildren(e){if(e instanceof Ce)return e.groups;if(e instanceof ms)return e.resolve(this._resolverService).then(t=>t.children);throw new Error("bad tree")}};Rh=La([Da(0,o.ITextModelService)],Rh);class yw{getHeight(){return 23}getTemplateId(e){return e instanceof ms?Ra.id:Ta.id}}let Th=class{constructor(e){this._keybindingService=e}getKeyboardNavigationLabel(e){if(e instanceof Lt){const t=e.parent.getPreview(e)?.preview(e.range);if(t)return t.value}return o.basename(e.uri)}};Th=La([Da(0,o.IKeybindingService)],Th);class ww{getId(e){return e instanceof Lt?e.id:e.uri}}let Nh=class extends a.Disposable{constructor(e,t){super(),this._labelService=t;const i=document.createElement("div");i.classList.add("reference-file"),this.file=this._register(new o.IconLabel(i,{supportHighlights:!0})),this.badge=this._register(new o.CountBadge(o.append(i,o.$(".count")),{},o.defaultCountBadgeStyles)),e.appendChild(i)}set(e,t){const i=o.dirname(e.uri);this.file.setLabel(this._labelService.getUriBasenameLabel(e.uri),this._labelService.getUriLabel(i,{relative:!0}),{title:this._labelService.getUriLabel(e.uri),matches:t});const n=e.children.length;this.badge.setCount(n),n>1?this.badge.setTitleFormat(a.localize(1139,"{0} references",n)):this.badge.setTitleFormat(a.localize(1140,"{0} reference",n))}};Nh=La([Da(1,o.ILabelService)],Nh);let Ra=(yn=class{constructor(e){this._instantiationService=e,this.templateId=Dh.id}renderTemplate(e){return this._instantiationService.createInstance(Nh,e)}renderElement(e,t,i){i.set(e.element,o.createMatches(e.filterData))}disposeTemplate(e){e.dispose()}},Dh=yn,yn.id="FileReferencesRenderer",yn);Ra=Dh=La([Da(0,o.IInstantiationService)],Ra);class Iw extends a.Disposable{constructor(e){super(),this.label=this._register(new o.HighlightedLabel(e))}set(e,t){const i=e.parent.getPreview(e)?.preview(e.range);if(!i||!i.value)this.label.set(`${o.basename(e.uri)}:${e.range.startLineNumber+1}:${e.range.startColumn+1}`);else{const{value:n,highlight:s}=i;t&&!o.FuzzyScore.isDefault(t)?(this.label.element.classList.toggle("referenceMatch",!1),this.label.set(n,o.createMatches(t))):(this.label.element.classList.toggle("referenceMatch",!0),this.label.set(n,[s]))}}}const Dc=class Dc{constructor(){this.templateId=Dc.id}renderTemplate(e){return new Iw(e)}renderElement(e,t,i){i.set(e.element,e.filterData)}disposeTemplate(e){e.dispose()}};Dc.id="OneReferenceRenderer";let Ta=Dc;class xw{getWidgetAriaLabel(){return a.localize(1141,"References")}getAriaLabel(e){return e.ariaMessage}}var c_=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},en=function(c,e){return function(t,i){e(t,i,c)}};const Rc=class Rc{constructor(e,t){this._editor=e,this._model=t,this._decorations=new Map,this._decorationIgnoreSet=new Set,this._callOnDispose=new a.DisposableStore,this._callOnModelChange=new a.DisposableStore,this._callOnDispose.add(this._editor.onDidChangeModel(()=>this._onModelChanged())),this._onModelChanged()}dispose(){this._callOnModelChange.dispose(),this._callOnDispose.dispose(),this.removeDecorations()}_onModelChanged(){this._callOnModelChange.clear();const e=this._editor.getModel();if(e){for(const t of this._model.references)if(t.uri.toString()===e.uri.toString()){this._addDecorations(t.parent);return}}}_addDecorations(e){if(!this._editor.hasModel())return;this._callOnModelChange.add(this._editor.getModel().onDidChangeDecorations(()=>this._onDecorationChanged()));const t=[],i=[];for(let n=0,s=e.children.length;n<s;n++){const r=e.children[n];this._decorationIgnoreSet.has(r.id)||r.uri.toString()===this._editor.getModel().uri.toString()&&(t.push({range:r.range,options:Rc.DecorationOptions}),i.push(n))}this._editor.changeDecorations(n=>{const s=n.deltaDecorations([],t);for(let r=0;r<s.length;r++)this._decorations.set(s[r],e.children[i[r]])})}_onDecorationChanged(){const e=[],t=this._editor.getModel();if(t){for(const[i,n]of this._decorations){const s=t.getDecorationRange(i);if(!s)continue;let r=!1;if(!a.Range.equalsRange(s,n.range)){if(a.Range.spansMultipleLines(s))r=!0;else{const l=n.range.endColumn-n.range.startColumn,d=s.endColumn-s.startColumn;l!==d&&(r=!0)}r?(this._decorationIgnoreSet.add(n.id),e.push(i)):n.range=s}}for(let i=0,n=e.length;i<n;i++)this._decorations.delete(e[i]);this._editor.removeDecorations(e)}}removeDecorations(){this._editor.removeDecorations([...this._decorations.keys()]),this._decorations.clear()}};Rc.DecorationOptions=o.ModelDecorationOptions.register({description:"reference-decoration",stickiness:1,className:"reference-decoration"});let Mh=Rc;class Ew{constructor(){this.ratio=.7,this.heightInLines=18}static fromJSON(e){let t,i;try{const n=JSON.parse(e);t=n.ratio,i=n.heightInLines}catch{}return{ratio:t||.7,heightInLines:i||18}}}class Lw extends o.WorkbenchAsyncDataTree{}let Ph=class{constructor(e){this.labelService=e,this.disposables=new a.DisposableStore}getDragURI(e){return e instanceof ms?e.uri.toString():e instanceof Lt?o.withSelection(e.uri,e.range).toString():null}getDragLabel(e){return e.length===0?void 0:e.map(i=>this.labelService.getUriBasenameLabel(i.uri)).join(", ")}onDragStart(e,t){if(!t.dataTransfer)return;const n=e.elements.map(s=>this.getDragURI(s)).filter(Boolean);n.length&&(t.dataTransfer.setData(o.DataTransfers.RESOURCES,JSON.stringify(n)),t.dataTransfer.setData(o.DataTransfers.TEXT,n.join(`
10
+ `)))}onDragOver(){return!1}drop(){}dispose(){this.disposables.dispose()}};Ph=c_([en(0,o.ILabelService)],Ph);let Oh=class extends Ea{constructor(e,t,i,n,s,r,l,d,h){super(e,{showFrame:!1,showArrow:!0,isResizeable:!0,isAccessible:!0,supportOnTitleClick:!0},r),this._defaultTreeKeyboardSupport=t,this.layoutData=i,this._textModelResolverService=s,this._instantiationService=r,this._peekViewService=l,this._uriLabel=d,this._keybindingService=h,this._disposeOnNewModel=new a.DisposableStore,this._callOnDispose=new a.DisposableStore,this._onDidSelectReference=this._callOnDispose.add(new a.Emitter),this.onDidSelectReference=this._onDidSelectReference.event,this._dim=new o.Dimension(0,0),this._isClosing=!1,this._applyTheme(n.getColorTheme()),this._callOnDispose.add(n.onDidColorThemeChange(this._applyTheme.bind(this))),this._peekViewService.addExclusiveWidget(e,this),this.create()}get isClosing(){return this._isClosing}dispose(){this._isClosing=!0,this.setModel(void 0),this._callOnDispose.dispose(),this._disposeOnNewModel.dispose(),a.dispose(this._preview),a.dispose(this._previewNotAvailableMessage),a.dispose(this._tree),a.dispose(this._previewModelReference),this._splitView.dispose(),super.dispose()}_applyTheme(e){const t=e.getColor(bw)||a.Color.transparent;this.style({arrowColor:t,frameColor:t,headerBackgroundColor:e.getColor(vw)||a.Color.transparent,primaryHeadingColor:e.getColor(a_),secondaryHeadingColor:e.getColor(l_)})}show(e){super.show(e,this.layoutData.heightInLines||18)}focusOnReferenceTree(){this._tree.domFocus()}focusOnPreviewEditor(){this._preview.focus()}isPreviewEditorFocused(){return this._preview.hasTextFocus()}_onTitleClick(e){this._preview&&this._preview.getModel()&&this._onDidSelectReference.fire({element:this._getFocusedReference(),kind:e.ctrlKey||e.metaKey||e.altKey?"side":"open",source:"title"})}_fillBody(e){this.setCssClass("reference-zone-widget"),this._messageContainer=o.append(e,o.$("div.messages")),o.hide(this._messageContainer),this._splitView=new o.SplitView(e,{orientation:1}),this._previewContainer=o.append(e,o.$("div.preview.inline"));const t={scrollBeyondLastLine:!1,scrollbar:{verticalScrollbarSize:14,horizontal:"auto",useShadows:!0,verticalHasArrows:!1,horizontalHasArrows:!1,alwaysConsumeMouseWheel:!0},overviewRulerLanes:2,fixedOverflowWidgets:!0,minimap:{enabled:!1}};this._preview=this._instantiationService.createInstance(ct,this._previewContainer,t,{},this.editor),o.hide(this._previewContainer),this._previewNotAvailableMessage=this._instantiationService.createInstance(o.TextModel,a.localize(1142,"no preview available"),o.PLAINTEXT_LANGUAGE_ID,o.TextModel.DEFAULT_CREATION_OPTIONS,null),this._treeContainer=o.append(e,o.$("div.ref-tree.inline"));const i={keyboardSupport:this._defaultTreeKeyboardSupport,accessibilityProvider:new xw,keyboardNavigationLabelProvider:this._instantiationService.createInstance(Th),identityProvider:new ww,openOnSingleClick:!0,selectionNavigation:!0,overrideStyles:{listBackground:Cw},dnd:this._instantiationService.createInstance(Ph)};this._defaultTreeKeyboardSupport&&this._callOnDispose.add(o.addStandardDisposableListener(this._treeContainer,"keydown",s=>{s.equals(9)&&(this._keybindingService.dispatchEvent(s,s.target),s.stopPropagation())},!0)),this._tree=this._instantiationService.createInstance(Lw,"ReferencesWidget",this._treeContainer,new yw,[this._instantiationService.createInstance(Ra),this._instantiationService.createInstance(Ta)],this._instantiationService.createInstance(Rh),i),this._splitView.addView({onDidChange:a.Event.None,element:this._previewContainer,minimumSize:200,maximumSize:Number.MAX_VALUE,layout:s=>{this._preview.layout({height:this._dim.height,width:s})}},o.Sizing.Distribute),this._splitView.addView({onDidChange:a.Event.None,element:this._treeContainer,minimumSize:100,maximumSize:Number.MAX_VALUE,layout:s=>{this._treeContainer.style.height=`${this._dim.height}px`,this._treeContainer.style.width=`${s}px`,this._tree.layout(this._dim.height,s)}},o.Sizing.Distribute),this._disposables.add(this._splitView.onDidSashChange(()=>{this._dim.width&&(this.layoutData.ratio=this._splitView.getViewSize(0)/this._dim.width)},void 0));const n=(s,r)=>{s instanceof Lt&&(r==="show"&&this._revealReference(s,!1),this._onDidSelectReference.fire({element:s,kind:r,source:"tree"}))};this._disposables.add(this._tree.onDidOpen(s=>{s.sideBySide?n(s.element,"side"):s.editorOptions.pinned?n(s.element,"goto"):n(s.element,"show")})),o.hide(this._treeContainer)}_onWidth(e){this._dim&&this._doLayoutBody(this._dim.height,e)}_doLayoutBody(e,t){super._doLayoutBody(e,t),this._dim=new o.Dimension(t,e),this.layoutData.heightInLines=this._viewZone?this._viewZone.heightInLines:this.layoutData.heightInLines,this._splitView.layout(t),this._splitView.resizeView(0,t*this.layoutData.ratio)}setSelection(e){return this._revealReference(e,!0).then(()=>{this._model&&(this._tree.setSelection([e]),this._tree.setFocus([e]))})}setModel(e){return this._disposeOnNewModel.clear(),this._model=e,this._model?this._onNewModel():Promise.resolve()}_onNewModel(){return this._model?this._model.isEmpty?(this.setTitle(""),this._messageContainer.innerText=a.localize(1143,"No results"),o.show(this._messageContainer),Promise.resolve(void 0)):(o.hide(this._messageContainer),this._decorationsManager=new Mh(this._preview,this._model),this._disposeOnNewModel.add(this._decorationsManager),this._disposeOnNewModel.add(this._model.onDidChangeReferenceRange(e=>this._tree.rerender(e))),this._disposeOnNewModel.add(this._preview.onMouseDown(e=>{const{event:t,target:i}=e;if(t.detail!==2)return;const n=this._getFocusedReference();n&&this._onDidSelectReference.fire({element:{uri:n.uri,range:i.range},kind:t.ctrlKey||t.metaKey||t.altKey?"side":"open",source:"editor"})})),this.container.classList.add("results-loaded"),o.show(this._treeContainer),o.show(this._previewContainer),this._splitView.layout(this._dim.width),this.focusOnReferenceTree(),this._tree.setInput(this._model.groups.length===1?this._model.groups[0]:this._model)):Promise.resolve(void 0)}_getFocusedReference(){const[e]=this._tree.getFocus();if(e instanceof Lt)return e;if(e instanceof ms&&e.children.length>0)return e.children[0]}async revealReference(e){await this._revealReference(e,!1),this._onDidSelectReference.fire({element:e,kind:"goto",source:"tree"})}async _revealReference(e,t){if(this._revealedReference===e)return;this._revealedReference=e,e.uri.scheme!==a.Schemas.inMemory?this.setTitle(o.basenameOrAuthority(e.uri),this._uriLabel.getUriLabel(o.dirname(e.uri))):this.setTitle(a.localize(1144,"References"));const i=this._textModelResolverService.createModelReference(e.uri);this._tree.getInput()===e.parent?this._tree.reveal(e):(t&&this._tree.reveal(e.parent),await this._tree.expand(e.parent),this._tree.reveal(e));const n=await i;if(!this._model){n.dispose();return}a.dispose(this._previewModelReference);const s=n.object;if(s){const r=this._preview.getModel()===s.textEditorModel?0:1,l=a.Range.lift(e.range).collapseToStart();this._previewModelReference=n,this._preview.setModel(s.textEditorModel),this._preview.setSelection(l),this._preview.revealRangeInCenter(l,r)}else this._preview.setModel(this._previewNotAvailableMessage),n.dispose()}};Oh=c_([en(3,o.IThemeService),en(4,o.ITextModelService),en(5,o.IInstantiationService),en(6,r_),en(7,o.ILabelService),en(8,o.IKeybindingService)],Oh);var Dw=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},_s=function(c,e){return function(t,i){e(t,i,c)}},Na;const tn=new o.RawContextKey("referenceSearchVisible",!1,a.localize(1136,"Whether reference peek is visible, like 'Peek References' or 'Peek Definition'"));let nn=(wn=class{static get(e){return e.getContribution(Na.ID)}constructor(e,t,i,n,s,r,l,d){this._defaultTreeKeyboardSupport=e,this._editor=t,this._editorService=n,this._notificationService=s,this._instantiationService=r,this._storageService=l,this._configurationService=d,this._disposables=new a.DisposableStore,this._requestIdPool=0,this._ignoreModelChangeEvent=!1,this._referenceSearchVisible=tn.bindTo(i)}dispose(){this._referenceSearchVisible.reset(),this._disposables.dispose(),this._widget?.dispose(),this._model?.dispose(),this._widget=void 0,this._model=void 0}toggleWidget(e,t,i){let n;if(this._widget&&(n=this._widget.position),this.closeWidget(),n&&e.containsPosition(n))return;this._peekMode=i,this._referenceSearchVisible.set(!0),this._disposables.add(this._editor.onDidChangeModelLanguage(()=>{this.closeWidget()})),this._disposables.add(this._editor.onDidChangeModel(()=>{this._ignoreModelChangeEvent||this.closeWidget()}));const s="peekViewLayout",r=Ew.fromJSON(this._storageService.get(s,0,"{}"));this._widget=this._instantiationService.createInstance(Oh,this._editor,this._defaultTreeKeyboardSupport,r),this._widget.setTitle(a.localize(1137,"Loading...")),this._widget.show(e),this._disposables.add(this._widget.onDidClose(()=>{t.cancel(),this._widget?(this._storageService.store(s,JSON.stringify(this._widget.layoutData),0,1),this._widget.isClosing||this.closeWidget(),this._widget=void 0):this.closeWidget()})),this._disposables.add(this._widget.onDidSelectReference(d=>{const{element:h,kind:u}=d;if(h)switch(u){case"open":(d.source!=="editor"||!this._configurationService.getValue("editor.stablePeek"))&&this.openReference(h,!1,!1);break;case"side":this.openReference(h,!0,!1);break;case"goto":i?this._gotoReference(h,!0):this.openReference(h,!1,!0);break}}));const l=++this._requestIdPool;t.then(d=>{if(l!==this._requestIdPool||!this._widget){d.dispose();return}return this._model?.dispose(),this._model=d,this._widget.setModel(this._model).then(()=>{if(this._widget&&this._model&&this._editor.hasModel()){this._model.isEmpty?this._widget.setMetaTitle(""):this._widget.setMetaTitle(a.localize(1138,"{0} ({1})",this._model.title,this._model.references.length));const h=this._editor.getModel().uri,u=new a.Position(e.startLineNumber,e.startColumn),g=this._model.nearestReference(h,u);if(g)return this._widget.setSelection(g).then(()=>{this._widget&&this._editor.getOption(99)==="editor"&&this._widget.focusOnPreviewEditor()})}})},d=>{this._notificationService.error(d)})}changeFocusBetweenPreviewAndReferences(){this._widget&&(this._widget.isPreviewEditorFocused()?this._widget.focusOnReferenceTree():this._widget.focusOnPreviewEditor())}async goToNextOrPreviousReference(e){if(!this._editor.hasModel()||!this._model||!this._widget)return;const t=this._widget.position;if(!t)return;const i=this._model.nearestReference(this._editor.getModel().uri,t);if(!i)return;const n=this._model.nextOrPreviousReference(i,e),s=this._editor.hasTextFocus(),r=this._widget.isPreviewEditorFocused();await this._widget.setSelection(n),await this._gotoReference(n,!1),s?this._editor.focus():this._widget&&r&&this._widget.focusOnPreviewEditor()}async revealReference(e){!this._editor.hasModel()||!this._model||!this._widget||await this._widget.revealReference(e)}closeWidget(e=!0){this._widget?.dispose(),this._model?.dispose(),this._referenceSearchVisible.reset(),this._disposables.clear(),this._widget=void 0,this._model=void 0,e&&this._editor.focus(),this._requestIdPool+=1}_gotoReference(e,t){this._widget?.hide(),this._ignoreModelChangeEvent=!0;const i=a.Range.lift(e.range).collapseToStart();return this._editorService.openCodeEditor({resource:e.uri,options:{selection:i,selectionSource:"code.jump",pinned:t}},this._editor).then(n=>{if(this._ignoreModelChangeEvent=!1,!n||!this._widget){this.closeWidget();return}if(this._editor===n)this._widget.show(i),this._widget.focusOnReferenceTree();else{const s=Na.get(n),r=this._model.clone();this.closeWidget(),n.focus(),s?.toggleWidget(i,a.createCancelablePromise(l=>Promise.resolve(r)),this._peekMode??!1)}},n=>{this._ignoreModelChangeEvent=!1,a.onUnexpectedError(n)})}openReference(e,t,i){t||this.closeWidget();const{uri:n,range:s}=e;this._editorService.openCodeEditor({resource:n,options:{selection:s,selectionSource:"code.jump",pinned:i}},this._editor,t)}},Na=wn,wn.ID="editor.contrib.referencesController",wn);nn=Na=Dw([_s(2,o.IContextKeyService),_s(3,o.ICodeEditorService),_s(4,o.INotificationService),_s(5,o.IInstantiationService),_s(6,o.IStorageService),_s(7,o.IConfigurationService)],nn);function sn(c,e){const t=i_(c);if(!t)return;const i=nn.get(t);i&&e(i)}o.KeybindingsRegistry.registerCommandAndKeybindingRule({id:"togglePeekWidgetFocus",weight:100,primary:a.KeyChord(2089,60),when:o.ContextKeyExpr.or(tn,pe.inPeekEditor),handler(c){sn(c,e=>{e.changeFocusBetweenPreviewAndReferences()})}}),o.KeybindingsRegistry.registerCommandAndKeybindingRule({id:"goToNextReference",weight:90,primary:62,secondary:[70],when:o.ContextKeyExpr.or(tn,pe.inPeekEditor),handler(c){sn(c,e=>{e.goToNextOrPreviousReference(!0)})}}),o.KeybindingsRegistry.registerCommandAndKeybindingRule({id:"goToPreviousReference",weight:90,primary:1086,secondary:[1094],when:o.ContextKeyExpr.or(tn,pe.inPeekEditor),handler(c){sn(c,e=>{e.goToNextOrPreviousReference(!1)})}}),o.CommandsRegistry.registerCommandAlias("goToNextReferenceFromEmbeddedEditor","goToNextReference"),o.CommandsRegistry.registerCommandAlias("goToPreviousReferenceFromEmbeddedEditor","goToPreviousReference"),o.CommandsRegistry.registerCommandAlias("closeReferenceSearchEditor","closeReferenceSearch"),o.CommandsRegistry.registerCommand("closeReferenceSearch",c=>sn(c,e=>e.closeWidget())),o.KeybindingsRegistry.registerKeybindingRule({id:"closeReferenceSearch",weight:-1,primary:9,secondary:[1033],when:o.ContextKeyExpr.and(pe.inPeekEditor,o.ContextKeyExpr.not("config.editor.stablePeek"))}),o.KeybindingsRegistry.registerKeybindingRule({id:"closeReferenceSearch",weight:250,primary:9,secondary:[1033],when:o.ContextKeyExpr.and(tn,o.ContextKeyExpr.not("config.editor.stablePeek"),o.ContextKeyExpr.or(o.EditorContextKeys.editorTextFocus,o.InputFocusedContext.negate()))}),o.KeybindingsRegistry.registerCommandAndKeybindingRule({id:"revealReference",weight:200,primary:3,mac:{primary:3,secondary:[2066]},when:o.ContextKeyExpr.and(tn,o.WorkbenchListFocusContextKey,o.WorkbenchTreeElementCanCollapse.negate(),o.WorkbenchTreeElementCanExpand.negate()),handler(c){const t=c.get(o.IListService).lastFocusedList?.getFocus();Array.isArray(t)&&t[0]instanceof Lt&&sn(c,i=>i.revealReference(t[0]))}}),o.KeybindingsRegistry.registerCommandAndKeybindingRule({id:"openReferenceToSide",weight:100,primary:2051,mac:{primary:259},when:o.ContextKeyExpr.and(tn,o.WorkbenchListFocusContextKey,o.WorkbenchTreeElementCanCollapse.negate(),o.WorkbenchTreeElementCanExpand.negate()),handler(c){const t=c.get(o.IListService).lastFocusedList?.getFocus();Array.isArray(t)&&t[0]instanceof Lt&&sn(c,i=>i.openReference(t[0],!0,!0))}}),o.CommandsRegistry.registerCommand("openReference",c=>{const t=c.get(o.IListService).lastFocusedList?.getFocus();Array.isArray(t)&&t[0]instanceof Lt&&sn(c,i=>i.openReference(t[0],!1,!0))});var d_=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Oo=function(c,e){return function(t,i){e(t,i,c)}};const Ah=new o.RawContextKey("hasSymbols",!1,a.localize(1153,"Whether there are symbol locations that can be navigated via keyboard-only.")),Ma=o.createDecorator("ISymbolNavigationService");let Fh=class{constructor(e,t,i,n){this._editorService=t,this._notificationService=i,this._keybindingService=n,this._currentModel=void 0,this._currentIdx=-1,this._ignoreEditorChange=!1,this._ctxHasSymbols=Ah.bindTo(e)}reset(){this._ctxHasSymbols.reset(),this._currentState?.dispose(),this._currentMessage?.close(),this._currentModel=void 0,this._currentIdx=-1}put(e){const t=e.parent.parent;if(t.references.length<=1){this.reset();return}this._currentModel=t,this._currentIdx=t.references.indexOf(e),this._ctxHasSymbols.set(!0),this._showMessage();const i=new zh(this._editorService),n=i.onDidChange(s=>{if(this._ignoreEditorChange)return;const r=this._editorService.getActiveCodeEditor();if(!r)return;const l=r.getModel(),d=r.getPosition();if(!l||!d)return;let h=!1,u=!1;for(const g of t.references)if(o.isEqual(g.uri,l.uri))h=!0,u=u||a.Range.containsPosition(g.range,d);else if(h)break;(!h||!u)&&this.reset()});this._currentState=a.combinedDisposable(i,n)}revealNext(e){if(!this._currentModel)return Promise.resolve();this._currentIdx+=1,this._currentIdx%=this._currentModel.references.length;const t=this._currentModel.references[this._currentIdx];return this._showMessage(),this._ignoreEditorChange=!0,this._editorService.openCodeEditor({resource:t.uri,options:{selection:a.Range.collapseToStart(t.range),selectionRevealType:3}},e).finally(()=>{this._ignoreEditorChange=!1})}_showMessage(){this._currentMessage?.close();const e=this._keybindingService.lookupKeybinding("editor.gotoNextSymbolFromResult"),t=e?a.localize(1154,"Symbol {0} of {1}, {2} for next",this._currentIdx+1,this._currentModel.references.length,e.getLabel()):a.localize(1155,"Symbol {0} of {1}",this._currentIdx+1,this._currentModel.references.length);this._currentMessage=this._notificationService.status(t)}};Fh=d_([Oo(0,o.IContextKeyService),Oo(1,o.ICodeEditorService),Oo(2,o.INotificationService),Oo(3,o.IKeybindingService)],Fh),o.registerSingleton(Ma,Fh,1),o.registerEditorCommand(new class extends o.EditorCommand{constructor(){super({id:"editor.gotoNextSymbolFromResult",precondition:Ah,kbOpts:{weight:100,primary:70}})}runEditorCommand(c,e){return c.get(Ma).revealNext(e)}}),o.KeybindingsRegistry.registerCommandAndKeybindingRule({id:"editor.gotoNextSymbolFromResult.cancel",weight:100,when:Ah,primary:9,handler(c){c.get(Ma).reset()}});let zh=class{constructor(e){this._listener=new Map,this._disposables=new a.DisposableStore,this._onDidChange=new a.Emitter,this.onDidChange=this._onDidChange.event,this._disposables.add(e.onCodeEditorRemove(this._onDidRemoveEditor,this)),this._disposables.add(e.onCodeEditorAdd(this._onDidAddEditor,this)),e.listCodeEditors().forEach(this._onDidAddEditor,this)}dispose(){this._disposables.dispose(),this._onDidChange.dispose(),a.dispose(this._listener.values())}_onDidAddEditor(e){this._listener.set(e,a.combinedDisposable(e.onDidChangeCursorPosition(t=>this._onDidChange.fire({editor:e})),e.onDidChangeModelContent(t=>this._onDidChange.fire({editor:e}))))}_onDidRemoveEditor(e){this._listener.get(e)?.dispose(),this._listener.delete(e)}};zh=d_([Oo(0,o.ICodeEditorService)],zh);function Vh(c,e){return e.uri.scheme===c.uri.scheme?!0:!a.matchesSomeScheme(e.uri,a.Schemas.walkThroughSnippet,a.Schemas.vscodeChatCodeBlock,a.Schemas.vscodeChatCodeCompareBlock)}async function Ao(c,e,t,i,n){const r=t.ordered(c,i).map(d=>Promise.resolve(n(d,c,e)).then(void 0,h=>{a.onUnexpectedExternalError(h)})),l=await Promise.all(r);return a.coalesce(l.flat()).filter(d=>Vh(c,d))}function Fo(c,e,t,i,n){return Ao(e,t,c,i,(s,r,l)=>s.provideDefinition(r,l,n))}function Bh(c,e,t,i,n){return Ao(e,t,c,i,(s,r,l)=>s.provideDeclaration(r,l,n))}function Kh(c,e,t,i,n){return Ao(e,t,c,i,(s,r,l)=>s.provideImplementation(r,l,n))}function kh(c,e,t,i,n){return Ao(e,t,c,i,(s,r,l)=>s.provideTypeDefinition(r,l,n))}function zo(c,e,t,i,n,s){return Ao(e,t,c,n,async(r,l,d)=>{const h=(await r.provideReferences(l,d,{includeDeclaration:!0},s))?.filter(g=>Vh(l,g));if(!i||!h||h.length!==2)return h;const u=(await r.provideReferences(l,d,{includeDeclaration:!1},s))?.filter(g=>Vh(l,g));return u&&u.length===1?u:h})}async function dt(c){const e=await c(),t=new Ce(e,""),i=t.references.map(n=>n.link);return t.dispose(),i}o.registerModelAndPositionCommand("_executeDefinitionProvider",(c,e,t)=>{const i=c.get(o.ILanguageFeaturesService),n=Fo(i.definitionProvider,e,t,!1,a.CancellationToken.None);return dt(()=>n)}),o.registerModelAndPositionCommand("_executeDefinitionProvider_recursive",(c,e,t)=>{const i=c.get(o.ILanguageFeaturesService),n=Fo(i.definitionProvider,e,t,!0,a.CancellationToken.None);return dt(()=>n)}),o.registerModelAndPositionCommand("_executeTypeDefinitionProvider",(c,e,t)=>{const i=c.get(o.ILanguageFeaturesService),n=kh(i.typeDefinitionProvider,e,t,!1,a.CancellationToken.None);return dt(()=>n)}),o.registerModelAndPositionCommand("_executeTypeDefinitionProvider_recursive",(c,e,t)=>{const i=c.get(o.ILanguageFeaturesService),n=kh(i.typeDefinitionProvider,e,t,!0,a.CancellationToken.None);return dt(()=>n)}),o.registerModelAndPositionCommand("_executeDeclarationProvider",(c,e,t)=>{const i=c.get(o.ILanguageFeaturesService),n=Bh(i.declarationProvider,e,t,!1,a.CancellationToken.None);return dt(()=>n)}),o.registerModelAndPositionCommand("_executeDeclarationProvider_recursive",(c,e,t)=>{const i=c.get(o.ILanguageFeaturesService),n=Bh(i.declarationProvider,e,t,!0,a.CancellationToken.None);return dt(()=>n)}),o.registerModelAndPositionCommand("_executeReferenceProvider",(c,e,t)=>{const i=c.get(o.ILanguageFeaturesService),n=zo(i.referenceProvider,e,t,!1,!1,a.CancellationToken.None);return dt(()=>n)}),o.registerModelAndPositionCommand("_executeReferenceProvider_recursive",(c,e,t)=>{const i=c.get(o.ILanguageFeaturesService),n=zo(i.referenceProvider,e,t,!1,!0,a.CancellationToken.None);return dt(()=>n)}),o.registerModelAndPositionCommand("_executeImplementationProvider",(c,e,t)=>{const i=c.get(o.ILanguageFeaturesService),n=Kh(i.implementationProvider,e,t,!1,a.CancellationToken.None);return dt(()=>n)}),o.registerModelAndPositionCommand("_executeImplementationProvider_recursive",(c,e,t)=>{const i=c.get(o.ILanguageFeaturesService),n=Kh(i.implementationProvider,e,t,!0,a.CancellationToken.None);return dt(()=>n)}),o.MenuRegistry.appendMenuItem(o.MenuId.EditorContext,{submenu:o.MenuId.EditorContextPeek,title:a.localize(1096,"Peek"),group:"navigation",order:100});class vs{static is(e){return!e||typeof e!="object"?!1:!!(e instanceof vs||a.Position.isIPosition(e.position)&&e.model)}constructor(e,t){this.model=e,this.position=t}}const Ue=class Ue extends o.EditorAction2{static all(){return Ue._allSymbolNavigationCommands.values()}static _patchConfig(e){const t={...e,f1:!0};if(t.menu)for(const i of a.Iterable.wrap(t.menu))(i.id===o.MenuId.EditorContext||i.id===o.MenuId.EditorContextPeek)&&(i.when=o.ContextKeyExpr.and(e.precondition,i.when));return t}constructor(e,t){super(Ue._patchConfig(t)),this.configuration=e,Ue._allSymbolNavigationCommands.set(t.id,this)}runEditorCommand(e,t,i,n){if(!t.hasModel())return Promise.resolve(void 0);const s=e.get(o.INotificationService),r=e.get(o.ICodeEditorService),l=e.get(o.IEditorProgressService),d=e.get(Ma),h=e.get(o.ILanguageFeaturesService),u=e.get(o.IInstantiationService),g=t.getModel(),p=t.getPosition(),f=vs.is(i)?i:new vs(g,p),m=new o.EditorStateCancellationTokenSource(t,5),_=a.raceCancellation(this._getLocationModel(h,f.model,f.position,m.token),m.token).then(async v=>{if(!v||m.token.isCancellationRequested)return;o.alert(v.ariaMessage);let b;if(v.referenceAt(g.uri,p)){const y=this._getAlternativeCommand(t);y!==void 0&&!Ue._activeAlternativeCommands.has(y)&&Ue._allSymbolNavigationCommands.has(y)&&(b=Ue._allSymbolNavigationCommands.get(y))}const C=v.references.length;if(C===0){if(!this.configuration.muteMessage){const y=g.getWordAtPosition(p);ve.get(t)?.showMessage(this._getNoResultFoundMessage(y),p)}}else if(C===1&&b)Ue._activeAlternativeCommands.add(this.desc.id),u.invokeFunction(y=>b.runEditorCommand(y,t,i,n).finally(()=>{Ue._activeAlternativeCommands.delete(this.desc.id)}));else return this._onResult(r,d,t,v,n)},v=>{s.error(v)}).finally(()=>{m.dispose()});return l.showWhile(_,250),_}async _onResult(e,t,i,n,s){const r=this._getGoToPreference(i);if(!(i instanceof ct)&&(this.configuration.openInPeek||r==="peek"&&n.references.length>1))this._openInPeek(i,n,s);else{const l=n.firstReference(),d=n.references.length>1&&r==="gotoAndPeek",h=await this._openReference(i,e,l,this.configuration.openToSide,!d);d&&h?this._openInPeek(h,n,s):n.dispose(),r==="goto"&&t.put(l)}}async _openReference(e,t,i,n,s){let r;if(a.isLocationLink(i)&&(r=i.targetSelectionRange),r||(r=i.range),!r)return;const l=await t.openCodeEditor({resource:i.uri,options:{selection:a.Range.collapseToStart(r),selectionRevealType:3,selectionSource:"code.jump"}},e,n);if(l){if(s){const d=l.getModel(),h=l.createDecorationsCollection([{range:r,options:{description:"symbol-navigate-action-highlight",className:"symbolHighlight"}}]);setTimeout(()=>{l.getModel()===d&&h.clear()},350)}return l}}_openInPeek(e,t,i){const n=nn.get(e);n&&e.hasModel()?n.toggleWidget(i??e.getSelection(),a.createCancelablePromise(s=>Promise.resolve(t)),this.configuration.openInPeek):t.dispose()}};Ue._allSymbolNavigationCommands=new Map,Ue._activeAlternativeCommands=new Set;let Dt=Ue;class Vo extends Dt{async _getLocationModel(e,t,i,n){return new Ce(await Fo(e.definitionProvider,t,i,!1,n),a.localize(1097,"Definitions"))}_getNoResultFoundMessage(e){return e&&e.word?a.localize(1098,"No definition found for '{0}'",e.word):a.localize(1099,"No definition found")}_getAlternativeCommand(e){return e.getOption(67).alternativeDefinitionCommand}_getGoToPreference(e){return e.getOption(67).multipleDefinitions}}o.registerAction2((bi=class extends Vo{constructor(){super({openToSide:!1,openInPeek:!1,muteMessage:!1},{id:bi.id,title:{...a.localize2(1123,"Go to Definition"),mnemonicTitle:a.localize(1100,"Go to &&Definition")},precondition:o.EditorContextKeys.hasDefinitionProvider,keybinding:[{when:o.EditorContextKeys.editorTextFocus,primary:70,weight:100},{when:o.ContextKeyExpr.and(o.EditorContextKeys.editorTextFocus,o.IsWebContext),primary:2118,weight:100}],menu:[{id:o.MenuId.EditorContext,group:"navigation",order:1.1},{id:o.MenuId.MenubarGoMenu,precondition:null,group:"4_symbol_nav",order:2}]}),o.CommandsRegistry.registerCommandAlias("editor.action.goToDeclaration",bi.id)}},bi.id="editor.action.revealDefinition",bi)),o.registerAction2((Ci=class extends Vo{constructor(){super({openToSide:!0,openInPeek:!1,muteMessage:!1},{id:Ci.id,title:a.localize2(1124,"Open Definition to the Side"),precondition:o.ContextKeyExpr.and(o.EditorContextKeys.hasDefinitionProvider,o.EditorContextKeys.isInEmbeddedEditor.toNegated()),keybinding:[{when:o.EditorContextKeys.editorTextFocus,primary:a.KeyChord(2089,70),weight:100},{when:o.ContextKeyExpr.and(o.EditorContextKeys.editorTextFocus,o.IsWebContext),primary:a.KeyChord(2089,2118),weight:100}]}),o.CommandsRegistry.registerCommandAlias("editor.action.openDeclarationToTheSide",Ci.id)}},Ci.id="editor.action.revealDefinitionAside",Ci)),o.registerAction2((Si=class extends Vo{constructor(){super({openToSide:!1,openInPeek:!0,muteMessage:!1},{id:Si.id,title:a.localize2(1125,"Peek Definition"),precondition:o.ContextKeyExpr.and(o.EditorContextKeys.hasDefinitionProvider,pe.notInPeekEditor,o.EditorContextKeys.isInEmbeddedEditor.toNegated()),keybinding:{when:o.EditorContextKeys.editorTextFocus,primary:582,linux:{primary:3140},weight:100},menu:{id:o.MenuId.EditorContextPeek,group:"peek",order:2}}),o.CommandsRegistry.registerCommandAlias("editor.action.previewDeclaration",Si.id)}},Si.id="editor.action.peekDefinition",Si));class h_ extends Dt{async _getLocationModel(e,t,i,n){return new Ce(await Bh(e.declarationProvider,t,i,!1,n),a.localize(1101,"Declarations"))}_getNoResultFoundMessage(e){return e&&e.word?a.localize(1102,"No declaration found for '{0}'",e.word):a.localize(1103,"No declaration found")}_getAlternativeCommand(e){return e.getOption(67).alternativeDeclarationCommand}_getGoToPreference(e){return e.getOption(67).multipleDeclarations}}o.registerAction2((In=class extends h_{constructor(){super({openToSide:!1,openInPeek:!1,muteMessage:!1},{id:In.id,title:{...a.localize2(1126,"Go to Declaration"),mnemonicTitle:a.localize(1104,"Go to &&Declaration")},precondition:o.ContextKeyExpr.and(o.EditorContextKeys.hasDeclarationProvider,o.EditorContextKeys.isInEmbeddedEditor.toNegated()),menu:[{id:o.MenuId.EditorContext,group:"navigation",order:1.3},{id:o.MenuId.MenubarGoMenu,precondition:null,group:"4_symbol_nav",order:3}]})}_getNoResultFoundMessage(e){return e&&e.word?a.localize(1105,"No declaration found for '{0}'",e.word):a.localize(1106,"No declaration found")}},In.id="editor.action.revealDeclaration",In)),o.registerAction2(class extends h_{constructor(){super({openToSide:!1,openInPeek:!0,muteMessage:!1},{id:"editor.action.peekDeclaration",title:a.localize2(1127,"Peek Declaration"),precondition:o.ContextKeyExpr.and(o.EditorContextKeys.hasDeclarationProvider,pe.notInPeekEditor,o.EditorContextKeys.isInEmbeddedEditor.toNegated()),menu:{id:o.MenuId.EditorContextPeek,group:"peek",order:3}})}});class u_ extends Dt{async _getLocationModel(e,t,i,n){return new Ce(await kh(e.typeDefinitionProvider,t,i,!1,n),a.localize(1107,"Type Definitions"))}_getNoResultFoundMessage(e){return e&&e.word?a.localize(1108,"No type definition found for '{0}'",e.word):a.localize(1109,"No type definition found")}_getAlternativeCommand(e){return e.getOption(67).alternativeTypeDefinitionCommand}_getGoToPreference(e){return e.getOption(67).multipleTypeDefinitions}}o.registerAction2((xn=class extends u_{constructor(){super({openToSide:!1,openInPeek:!1,muteMessage:!1},{id:xn.ID,title:{...a.localize2(1128,"Go to Type Definition"),mnemonicTitle:a.localize(1110,"Go to &&Type Definition")},precondition:o.EditorContextKeys.hasTypeDefinitionProvider,keybinding:{when:o.EditorContextKeys.editorTextFocus,primary:0,weight:100},menu:[{id:o.MenuId.EditorContext,group:"navigation",order:1.4},{id:o.MenuId.MenubarGoMenu,precondition:null,group:"4_symbol_nav",order:3}]})}},xn.ID="editor.action.goToTypeDefinition",xn)),o.registerAction2((En=class extends u_{constructor(){super({openToSide:!1,openInPeek:!0,muteMessage:!1},{id:En.ID,title:a.localize2(1129,"Peek Type Definition"),precondition:o.ContextKeyExpr.and(o.EditorContextKeys.hasTypeDefinitionProvider,pe.notInPeekEditor,o.EditorContextKeys.isInEmbeddedEditor.toNegated()),menu:{id:o.MenuId.EditorContextPeek,group:"peek",order:4}})}},En.ID="editor.action.peekTypeDefinition",En));class g_ extends Dt{async _getLocationModel(e,t,i,n){return new Ce(await Kh(e.implementationProvider,t,i,!1,n),a.localize(1111,"Implementations"))}_getNoResultFoundMessage(e){return e&&e.word?a.localize(1112,"No implementation found for '{0}'",e.word):a.localize(1113,"No implementation found")}_getAlternativeCommand(e){return e.getOption(67).alternativeImplementationCommand}_getGoToPreference(e){return e.getOption(67).multipleImplementations}}o.registerAction2((Ln=class extends g_{constructor(){super({openToSide:!1,openInPeek:!1,muteMessage:!1},{id:Ln.ID,title:{...a.localize2(1130,"Go to Implementations"),mnemonicTitle:a.localize(1114,"Go to &&Implementations")},precondition:o.EditorContextKeys.hasImplementationProvider,keybinding:{when:o.EditorContextKeys.editorTextFocus,primary:2118,weight:100},menu:[{id:o.MenuId.EditorContext,group:"navigation",order:1.45},{id:o.MenuId.MenubarGoMenu,precondition:null,group:"4_symbol_nav",order:4}]})}},Ln.ID="editor.action.goToImplementation",Ln)),o.registerAction2((Dn=class extends g_{constructor(){super({openToSide:!1,openInPeek:!0,muteMessage:!1},{id:Dn.ID,title:a.localize2(1131,"Peek Implementations"),precondition:o.ContextKeyExpr.and(o.EditorContextKeys.hasImplementationProvider,pe.notInPeekEditor,o.EditorContextKeys.isInEmbeddedEditor.toNegated()),keybinding:{when:o.EditorContextKeys.editorTextFocus,primary:3142,weight:100},menu:{id:o.MenuId.EditorContextPeek,group:"peek",order:5}})}},Dn.ID="editor.action.peekImplementation",Dn));class p_ extends Dt{_getNoResultFoundMessage(e){return e?a.localize(1115,"No references found for '{0}'",e.word):a.localize(1116,"No references found")}_getAlternativeCommand(e){return e.getOption(67).alternativeReferenceCommand}_getGoToPreference(e){return e.getOption(67).multipleReferences}}o.registerAction2(class extends p_{constructor(){super({openToSide:!1,openInPeek:!1,muteMessage:!1},{id:"editor.action.goToReferences",title:{...a.localize2(1132,"Go to References"),mnemonicTitle:a.localize(1117,"Go to &&References")},precondition:o.ContextKeyExpr.and(o.EditorContextKeys.hasReferenceProvider,pe.notInPeekEditor,o.EditorContextKeys.isInEmbeddedEditor.toNegated()),keybinding:{when:o.EditorContextKeys.editorTextFocus,primary:1094,weight:100},menu:[{id:o.MenuId.EditorContext,group:"navigation",order:1.45},{id:o.MenuId.MenubarGoMenu,precondition:null,group:"4_symbol_nav",order:5}]})}async _getLocationModel(e,t,i,n){return new Ce(await zo(e.referenceProvider,t,i,!0,!1,n),a.localize(1118,"References"))}}),o.registerAction2(class extends p_{constructor(){super({openToSide:!1,openInPeek:!0,muteMessage:!1},{id:"editor.action.referenceSearch.trigger",title:a.localize2(1133,"Peek References"),precondition:o.ContextKeyExpr.and(o.EditorContextKeys.hasReferenceProvider,pe.notInPeekEditor,o.EditorContextKeys.isInEmbeddedEditor.toNegated()),menu:{id:o.MenuId.EditorContextPeek,group:"peek",order:6}})}async _getLocationModel(e,t,i,n){return new Ce(await zo(e.referenceProvider,t,i,!1,!1,n),a.localize(1119,"References"))}});class Rw extends Dt{constructor(e,t,i){super(e,{id:"editor.action.goToLocation",title:a.localize2(1134,"Go to Any Symbol"),precondition:o.ContextKeyExpr.and(pe.notInPeekEditor,o.EditorContextKeys.isInEmbeddedEditor.toNegated())}),this._references=t,this._gotoMultipleBehaviour=i}async _getLocationModel(e,t,i,n){return new Ce(this._references,a.localize(1120,"Locations"))}_getNoResultFoundMessage(e){return e&&a.localize(1121,"No results for '{0}'",e.word)||""}_getGoToPreference(e){return this._gotoMultipleBehaviour??e.getOption(67).multipleReferences}_getAlternativeCommand(){}}o.CommandsRegistry.registerCommand({id:"editor.action.goToLocations",metadata:{description:"Go to locations from a position in a file",args:[{name:"uri",description:"The text document in which to start",constraint:a.URI},{name:"position",description:"The position at which to start",constraint:a.Position.isIPosition},{name:"locations",description:"An array of locations.",constraint:Array},{name:"multiple",description:"Define what to do when having multiple results, either `peek`, `gotoAndPeek`, or `goto`"},{name:"noResultsMessage",description:"Human readable message that shows when locations is empty."}]},handler:async(c,e,t,i,n,s,r)=>{a.assertType(a.URI.isUri(e)),a.assertType(a.Position.isIPosition(t)),a.assertType(Array.isArray(i)),a.assertType(typeof n>"u"||typeof n=="string"),a.assertType(typeof r>"u"||typeof r=="boolean");const l=c.get(o.ICodeEditorService),d=await l.openCodeEditor({resource:e},l.getFocusedCodeEditor());if(o.isCodeEditor(d))return d.setPosition(t),d.revealPositionInCenterIfOutsideViewport(t,0),d.invokeWithinContext(h=>{const u=new class extends Rw{_getNoResultFoundMessage(g){return s||super._getNoResultFoundMessage(g)}}({muteMessage:!s,openInPeek:!!r,openToSide:!1},i,n);h.get(o.IInstantiationService).invokeFunction(u.run.bind(u),d)})}}),o.CommandsRegistry.registerCommand({id:"editor.action.peekLocations",metadata:{description:"Peek locations from a position in a file",args:[{name:"uri",description:"The text document in which to start",constraint:a.URI},{name:"position",description:"The position at which to start",constraint:a.Position.isIPosition},{name:"locations",description:"An array of locations.",constraint:Array},{name:"multiple",description:"Define what to do when having multiple results, either `peek`, `gotoAndPeek`, or `goto`"}]},handler:async(c,e,t,i,n)=>{c.get(o.ICommandService).executeCommand("editor.action.goToLocations",e,t,i,n,void 0,!0)}}),o.CommandsRegistry.registerCommand({id:"editor.action.findReferences",handler:(c,e,t)=>{a.assertType(a.URI.isUri(e)),a.assertType(a.Position.isIPosition(t));const i=c.get(o.ILanguageFeaturesService),n=c.get(o.ICodeEditorService);return n.openCodeEditor({resource:e},n.getFocusedCodeEditor()).then(s=>{if(!o.isCodeEditor(s)||!s.hasModel())return;const r=nn.get(s);if(!r)return;const l=a.createCancelablePromise(h=>zo(i.referenceProvider,s.getModel(),a.Position.lift(t),!1,!1,h).then(u=>new Ce(u,a.localize(1122,"References")))),d=new a.Range(t.lineNumber,t.column,t.lineNumber,t.column);return Promise.resolve(r.toggleWidget(d,l,!1))})}}),o.CommandsRegistry.registerCommandAlias("editor.action.showReferences","editor.action.peekLocations");async function Tw(c,e,t,i){const n=c.get(o.ITextModelService),s=c.get(o.IContextMenuService),r=c.get(o.ICommandService),l=c.get(o.IInstantiationService),d=c.get(o.INotificationService);if(await i.item.resolve(a.CancellationToken.None),!i.part.location)return;const h=i.part.location,u=[],g=new Set(o.MenuRegistry.getMenuItems(o.MenuId.EditorContext).map(f=>o.isIMenuItem(f)?f.command.id:o.generateUuid()));for(const f of Dt.all())g.has(f.desc.id)&&u.push(new o.Action(f.desc.id,o.MenuItemAction.label(f.desc,{renderShortTitle:!0}),void 0,!0,async()=>{const m=await n.createModelReference(h.uri);try{const _=new vs(m.object.textEditorModel,a.Range.getStartPosition(h.range)),v=i.item.anchor.range;await l.invokeFunction(f.runEditorCommand.bind(f),e,_,v)}finally{m.dispose()}}));if(i.part.command){const{command:f}=i.part;u.push(new o.Separator),u.push(new o.Action(f.id,f.title,void 0,!0,async()=>{try{await r.executeCommand(f.id,...f.arguments??[])}catch(m){d.notify({severity:o.Severity.Error,source:i.item.provider.displayName,message:m})}}))}const p=e.getOption(144);s.showContextMenu({domForShadowRoot:p?e.getDomNode()??void 0:void 0,getAnchor:()=>{const f=o.getDomNodePagePosition(t);return{x:f.left,y:f.top+f.height+8}},getActions:()=>u,onHide:()=>{e.focus()},autoSelectFirstItem:!0})}async function f_(c,e,t,i){const s=await c.get(o.ITextModelService).createModelReference(i.uri);await t.invokeWithinContext(async r=>{const l=e.hasSideBySideModifier,d=r.get(o.IContextKeyService),h=pe.inPeekEditor.getValue(d),u=!l&&t.getOption(101)&&!h;return new Vo({openToSide:l,openInPeek:u,muteMessage:!0},{title:{value:"",original:""},id:"",precondition:void 0}).run(r,new vs(s.object.textEditorModel,a.Range.getStartPosition(i.range)),a.Range.lift(i.range))}),s.dispose()}var Nw=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},bs=function(c,e){return function(t,i){e(t,i,c)}},Cs;class Pa{constructor(){this._entries=new a.LRUCache(50)}get(e){const t=Pa._key(e);return this._entries.get(t)}set(e,t){const i=Pa._key(e);this._entries.set(i,t)}static _key(e){return`${e.uri.toString()}/${e.getVersionId()}`}}const m_=o.createDecorator("IInlayHintsCache");o.registerSingleton(m_,Pa,1);class Uh{constructor(e,t){this.item=e,this.index=t}get part(){const e=this.item.hint.label;return typeof e=="string"?{label:e}:e[this.index]}}class Mw{constructor(e,t){this.part=e,this.hasTriggerModifier=t}}class Pw{constructor(){this._store=new a.MutableDisposable,this._tokenSource=new a.CancellationTokenSource}dispose(){this._store.dispose(),this._tokenSource.dispose(!0)}reset(){return this._tokenSource.dispose(!0),this._tokenSource=new a.CancellationTokenSource,this._store.value=new a.DisposableStore,{store:this._store.value,token:this._tokenSource.token}}}let Bo=(Bt=class{static get(e){return e.getContribution(Cs.ID)??void 0}constructor(e,t,i,n,s,r,l){this._editor=e,this._languageFeaturesService=t,this._inlayHintsCache=n,this._commandService=s,this._notificationService=r,this._instaService=l,this._disposables=new a.DisposableStore,this._sessionDisposables=new a.DisposableStore,this._decorationsMetadata=new Map,this._activeRenderMode=0,this._ruleFactory=this._disposables.add(new o.DynamicCssRules(this._editor)),this._debounceInfo=i.for(t.inlayHintsProvider,"InlayHint",{min:25}),this._disposables.add(t.inlayHintsProvider.onDidChange(()=>this._update())),this._disposables.add(e.onDidChangeModel(()=>this._update())),this._disposables.add(e.onDidChangeModelLanguage(()=>this._update())),this._disposables.add(e.onDidChangeConfiguration(d=>{d.hasChanged(159)&&this._update()})),this._update()}dispose(){this._sessionDisposables.dispose(),this._removeAllDecorations(),this._disposables.dispose()}_update(){this._sessionDisposables.clear(),this._removeAllDecorations();const e=this._editor.getOption(159);if(e.enabled==="off")return;const t=this._editor.getModel();if(!t||!this._languageFeaturesService.inlayHintsProvider.has(t))return;if(e.enabled==="on")this._activeRenderMode=0;else{let h,u;e.enabled==="onUnlessPressed"?(h=0,u=1):(h=1,u=0),this._activeRenderMode=h,this._sessionDisposables.add(o.ModifierKeyEmitter.getInstance().event(g=>{if(!this._editor.hasModel())return;const p=g.altKey&&g.ctrlKey&&!(g.shiftKey||g.metaKey)?u:h;if(p!==this._activeRenderMode){this._activeRenderMode=p;const f=this._editor.getModel(),m=this._copyInlayHintsWithCurrentAnchor(f);this._updateHintsDecorators([f.getFullModelRange()],m),l.schedule(0)}}))}const i=this._inlayHintsCache.get(t);i&&this._updateHintsDecorators([t.getFullModelRange()],i),this._sessionDisposables.add(a.toDisposable(()=>{t.isDisposed()||this._cacheHintsForFastRestore(t)}));let n;const s=new Set;this._sessionDisposables.add(t.onWillDispose(()=>n?.cancel()));const r=this._sessionDisposables.add(new Pw),l=new a.RunOnceScheduler(async()=>{const h=Date.now(),{store:u,token:g}=r.reset();try{const p=await Ia.create(this._languageFeaturesService.inlayHintsProvider,t,this._getHintsRanges(),g);if(l.delay=this._debounceInfo.update(t,Date.now()-h),g.isCancellationRequested){p.dispose();return}for(const f of p.provider)typeof f.onDidChangeInlayHints=="function"&&!s.has(f)&&(s.add(f),u.add(f.onDidChangeInlayHints(()=>{l.isScheduled()||l.schedule()})));u.add(p),u.add(a.toDisposable(()=>s.clear())),this._updateHintsDecorators(p.ranges,p.items),this._cacheHintsForFastRestore(t)}catch(p){a.onUnexpectedError(p)}},this._debounceInfo.get(t));this._sessionDisposables.add(l),l.schedule(0),this._sessionDisposables.add(this._editor.onDidScrollChange(h=>{(h.scrollTopChanged||!l.isScheduled())&&l.schedule()}));const d=this._sessionDisposables.add(new a.MutableDisposable);this._sessionDisposables.add(this._editor.onDidChangeModelContent(h=>{const u=Math.max(l.delay,800);this._cursorInfo={position:this._editor.getPosition(),notEarlierThan:Date.now()+u},d.value=a.disposableTimeout(()=>l.schedule(0),u),l.schedule()})),this._sessionDisposables.add(this._editor.onDidChangeConfiguration(h=>{h.hasChanged(159)&&l.schedule()})),this._sessionDisposables.add(this._installDblClickGesture(()=>l.schedule(0))),this._sessionDisposables.add(this._installLinkGesture()),this._sessionDisposables.add(this._installContextMenu())}_installLinkGesture(){const e=new a.DisposableStore,t=e.add(new wa(this._editor)),i=new a.DisposableStore;return e.add(i),e.add(t.onMouseMoveOrRelevantKeyDown(n=>{const[s]=n,r=this._getInlayHintLabelPart(s),l=this._editor.getModel();if(!r||!l){i.clear();return}const d=new a.CancellationTokenSource;i.add(a.toDisposable(()=>d.dispose(!0))),r.item.resolve(d.token),this._activeInlayHintPart=r.part.command||r.part.location?new Mw(r,s.hasTriggerModifier):void 0;const h=l.validatePosition(r.item.hint.position).lineNumber,u=new a.Range(h,1,h,l.getLineMaxColumn(h)),g=this._getInlineHintsForRange(u);this._updateHintsDecorators([u],g),i.add(a.toDisposable(()=>{this._activeInlayHintPart=void 0,this._updateHintsDecorators([u],g)}))})),e.add(t.onCancel(()=>i.clear())),e.add(t.onExecute(async n=>{const s=this._getInlayHintLabelPart(n);if(s){const r=s.part;r.location?this._instaService.invokeFunction(f_,n,this._editor,r.location):a.Command.is(r.command)&&await this._invokeCommand(r.command,s.item)}})),e}_getInlineHintsForRange(e){const t=new Set;for(const i of this._decorationsMetadata.values())e.containsRange(i.item.anchor.range)&&t.add(i.item);return Array.from(t)}_installDblClickGesture(e){return this._editor.onMouseUp(async t=>{if(t.event.detail!==2)return;const i=this._getInlayHintLabelPart(t);if(i&&(t.event.preventDefault(),await i.item.resolve(a.CancellationToken.None),a.isNonEmptyArray(i.item.hint.textEdits))){const n=i.item.hint.textEdits.map(s=>o.EditOperation.replace(a.Range.lift(s.range),s.text));this._editor.executeEdits("inlayHint.default",n),e()}})}_installContextMenu(){return this._editor.onContextMenu(async e=>{if(!o.isHTMLElement(e.event.target))return;const t=this._getInlayHintLabelPart(e);t&&await this._instaService.invokeFunction(Tw,this._editor,e.event.target,t)})}_getInlayHintLabelPart(e){if(e.target.type!==6)return;const t=e.target.detail.injectedText?.options;if(t instanceof o.ModelDecorationInjectedTextOptions&&t?.attachedData instanceof Uh)return t.attachedData}async _invokeCommand(e,t){try{await this._commandService.executeCommand(e.id,...e.arguments??[])}catch(i){this._notificationService.notify({severity:o.Severity.Error,source:t.provider.displayName,message:i})}}_cacheHintsForFastRestore(e){const t=this._copyInlayHintsWithCurrentAnchor(e);this._inlayHintsCache.set(e,t)}_copyInlayHintsWithCurrentAnchor(e){const t=new Map;for(const[i,n]of this._decorationsMetadata){if(t.has(n.item))continue;const s=e.getDecorationRange(i);if(s){const r=new t_(s,n.item.anchor.direction),l=n.item.with({anchor:r});t.set(n.item,l)}}return Array.from(t.values())}_getHintsRanges(){const t=this._editor.getModel(),i=this._editor.getVisibleRangesPlusViewportAboveBelow(),n=[];for(const s of i.sort(a.Range.compareRangesUsingStarts)){const r=t.validateRange(new a.Range(s.startLineNumber-30,s.startColumn,s.endLineNumber+30,s.endColumn));n.length===0||!a.Range.areIntersectingOrTouching(n[n.length-1],r)?n.push(r):n[n.length-1]=a.Range.plusRange(n[n.length-1],r)}return n}_updateHintsDecorators(e,t){const i=new Map;if(this._cursorInfo&&this._cursorInfo.notEarlierThan>Date.now()&&e.some(b=>b.containsPosition(this._cursorInfo.position))){const{position:b}=this._cursorInfo;this._cursorInfo=void 0;const C=new Map;for(const S of this._editor.getLineDecorations(b.lineNumber)??[]){const w=this._decorationsMetadata.get(S.id);if(S.range.startColumn>b.column)continue;const E=w?.decoration.options[w.item.anchor.direction];if(E&&E.attachedData!==Cs._whitespaceData){const L=C.get(w.item)??0;C.set(w.item,L+E.content.length)}}const y=t.filter(S=>S.anchor.range.startLineNumber===b.lineNumber&&S.anchor.range.endColumn<=b.column),I=Array.from(C.values());let x;for(;;){const S=y.shift(),w=I.shift();if(!w&&!S)break;if(S)i.set(S,w??0),x=S;else if(x&&w){let E=i.get(x);E+=w,E+=I.reduce((L,R)=>L+R,0),I.length=0;break}}}const{fontSize:n,fontFamily:s,padding:r,isUniform:l}=this._getLayoutInfo(),d=this._editor.getOption(61),h=[],u=(b,C,y,I,x,S)=>{const w={content:y,inlineClassNameAffectsLetterSpacing:!0,inlineClassName:C.className,cursorStops:I,attachedData:x,widthInEm:S};h.push({item:b,classNameRef:C,decoration:{range:b.anchor.range,options:{description:"InlayHint",showIfCollapsed:b.anchor.range.isEmpty(),collapseOnReplaceEdit:!b.anchor.range.isEmpty(),stickiness:0,[b.anchor.direction]:this._activeRenderMode===0?w:void 0}}})},g=(b,C)=>{const y=n/3|0,I=y/d,x=this._ruleFactory.createClassNameRef({width:`${y}px`,display:"inline-block"});u(b,x,"",C?a.InjectedTextCursorStops.Right:a.InjectedTextCursorStops.None,Cs._whitespaceData,I)},p=this._editor.getOption(159).maximumLength,f="--code-editorInlayHintsFontFamily";this._editor.getContainerDomNode().style.setProperty(f,s);let m={line:0,totalLen:0};for(let b=0;b<t.length;b++){const C=t[b];if(m.line!==C.anchor.range.startLineNumber&&(m={line:C.anchor.range.startLineNumber,totalLen:0}),p&&m.totalLen>p)continue;C.hint.paddingLeft&&g(C,!1);const y=typeof C.hint.label=="string"?[{label:C.hint.label}]:C.hint.label,I=i.get(C);let x=0;for(let S=0;S<y.length;S++){const w=y[S],E=S===0,L=S===y.length-1,R={fontSize:`${n}px`,fontFamily:`var(${f}), ${o.EDITOR_FONT_DEFAULTS.fontFamily}`,verticalAlign:l?"baseline":"middle",unicodeBidi:"isolate"};a.isNonEmptyArray(C.hint.textEdits)&&(R.cursor="default"),this._fillInColors(R,C.hint),(w.command||w.location)&&this._activeInlayHintPart?.part.item===C&&this._activeInlayHintPart.part.index===S&&(R.textDecoration="underline",this._activeInlayHintPart.hasTriggerModifier&&(R.color=o.themeColorFromId(o.editorActiveLinkForeground),R.cursor="pointer"));let D=w.label;m.totalLen+=D.length;let T=!1;const P=p!==0?m.totalLen-p:0;if(P>0&&(D=D.slice(0,-P)+"…",T=!0),x+=D.length,I!==void 0){const M=x-I;M>=0&&(x-=M,D=D.slice(0,-(1+M))+"…",T=!0)}if(r&&(E&&(L||T)?(R.padding=`1px ${Math.max(1,n/4)|0}px`,R.borderRadius=`${n/4|0}px`):E?(R.padding=`1px 0 1px ${Math.max(1,n/4)|0}px`,R.borderRadius=`${n/4|0}px 0 0 ${n/4|0}px`):L||T?(R.padding=`1px ${Math.max(1,n/4)|0}px 1px 0`,R.borderRadius=`0 ${n/4|0}px ${n/4|0}px 0`):R.padding="1px 0 1px 0"),u(C,this._ruleFactory.createClassNameRef(R),Ow(D),L&&!C.hint.paddingRight?a.InjectedTextCursorStops.Right:a.InjectedTextCursorStops.None,new Uh(C,S)),T)break}if(I!==void 0&&x<I){const S=I-x;u(C,this._ruleFactory.createClassNameRef({})," ".repeat(S),a.InjectedTextCursorStops.None)}if(C.hint.paddingRight&&g(C,!0),h.length>Cs._MAX_DECORATORS)break}const _=[];for(const[b,C]of this._decorationsMetadata){const y=this._editor.getModel()?.getDecorationRange(b);y&&e.some(I=>I.containsRange(y))&&(_.push(b),C.classNameRef.dispose(),this._decorationsMetadata.delete(b))}const v=o.StableEditorScrollState.capture(this._editor);this._editor.changeDecorations(b=>{const C=b.deltaDecorations(_,h.map(y=>y.decoration));for(let y=0;y<C.length;y++){const I=h[y];this._decorationsMetadata.set(C[y],I)}}),v.restore(this._editor)}_fillInColors(e,t){t.kind===a.InlayHintKind.Parameter?(e.backgroundColor=o.themeColorFromId(o.editorInlayHintParameterBackground),e.color=o.themeColorFromId(o.editorInlayHintParameterForeground)):t.kind===a.InlayHintKind.Type?(e.backgroundColor=o.themeColorFromId(o.editorInlayHintTypeBackground),e.color=o.themeColorFromId(o.editorInlayHintTypeForeground)):(e.backgroundColor=o.themeColorFromId(o.editorInlayHintBackground),e.color=o.themeColorFromId(o.editorInlayHintForeground))}_getLayoutInfo(){const e=this._editor.getOption(159),t=e.padding,i=this._editor.getOption(61),n=this._editor.getOption(58);let s=e.fontSize;(!s||s<5||s>i)&&(s=i);const r=e.fontFamily||n;return{fontSize:s,fontFamily:r,padding:t,isUniform:!t&&r===n&&s===i}}_removeAllDecorations(){this._editor.removeDecorations(Array.from(this._decorationsMetadata.keys()));for(const e of this._decorationsMetadata.values())e.classNameRef.dispose();this._decorationsMetadata.clear()}},Cs=Bt,Bt.ID="editor.contrib.InlayHints",Bt._MAX_DECORATORS=1500,Bt._whitespaceData={},Bt);Bo=Cs=Nw([bs(1,o.ILanguageFeaturesService),bs(2,o.ILanguageFeatureDebounceService),bs(3,m_),bs(4,o.ICommandService),bs(5,o.INotificationService),bs(6,o.IInstantiationService)],Bo);function Ow(c){return c.replace(/[ \t]/g," ")}o.CommandsRegistry.registerCommand("_executeInlayHintProvider",async(c,...e)=>{const[t,i]=e;a.assertType(a.URI.isUri(t)),a.assertType(a.Range.isIRange(i));const{inlayHintsProvider:n}=c.get(o.ILanguageFeaturesService),s=await c.get(o.ITextModelService).createModelReference(t);try{const r=await Ia.create(n,s.object.textEditorModel,[a.Range.lift(i)],a.CancellationToken.None),l=r.items.map(d=>d.hint);return setTimeout(()=>r.dispose(),0),l}finally{s.dispose()}});var Aw=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},on=function(c,e){return function(t,i){e(t,i,c)}};class __ extends xo{constructor(e,t,i,n){super(10,t,e.item.anchor.range,i,n,!0),this.part=e}}let Oa=class extends To{constructor(e,t,i,n,s,r,l,d){super(e,t,s,l,i,n,d),this._resolverService=r,this.hoverOrdinal=6}suggestHoverAnchor(e){if(!Bo.get(this._editor)||e.target.type!==6)return null;const i=e.target.detail.injectedText?.options;return i instanceof o.ModelDecorationInjectedTextOptions&&i.attachedData instanceof Uh?new __(i.attachedData,this,e.event.posx,e.event.posy):null}computeSync(){return[]}computeAsync(e,t,i,n){return e instanceof __?new a.AsyncIterableProducer(async s=>{const{part:r}=e;if(await r.item.resolve(n),n.isCancellationRequested)return;let l;typeof r.item.hint.tooltip=="string"?l=new o.MarkdownString().appendText(r.item.hint.tooltip):r.item.hint.tooltip&&(l=r.item.hint.tooltip),l&&s.emitOne(new ze(this,e.range,[l],!1,0)),a.isNonEmptyArray(r.item.hint.textEdits)&&s.emitOne(new ze(this,e.range,[new o.MarkdownString().appendText(a.localize(1220,"Double-click to insert"))],!1,10001));let d;if(typeof r.part.tooltip=="string"?d=new o.MarkdownString().appendText(r.part.tooltip):r.part.tooltip&&(d=r.part.tooltip),d&&s.emitOne(new ze(this,e.range,[d],!1,1)),r.part.location||r.part.command){let u;const p=this._editor.getOption(86)==="altKey"?a.isMacintosh?a.localize(1221,"cmd + click"):a.localize(1222,"ctrl + click"):a.isMacintosh?a.localize(1223,"option + click"):a.localize(1224,"alt + click");r.part.location&&r.part.command?u=new o.MarkdownString().appendText(a.localize(1225,"Go to Definition ({0}), right click for more",p)):r.part.location?u=new o.MarkdownString().appendText(a.localize(1226,"Go to Definition ({0})",p)):r.part.command&&(u=new o.MarkdownString(`[${a.localize(1227,"Execute Command")}](${dw(r.part.command)} "${r.part.command.title}") (${p})`,{isTrusted:!0})),u&&s.emitOne(new ze(this,e.range,[u],!1,1e4))}const h=this._resolveInlayHintLabelPartHover(r,n);for await(const u of h)s.emitOne(u)}):a.AsyncIterableProducer.EMPTY}async*_resolveInlayHintLabelPartHover(e,t){if(!e.part.location)return;const{uri:i,range:n}=e.part.location,s=await this._resolverService.createModelReference(i);try{const r=s.object.textEditorModel;if(!this._languageFeaturesService.hoverProvider.has(r))return;for await(const l of yh(this._languageFeaturesService.hoverProvider,r,new a.Position(n.startLineNumber,n.startColumn),t))o.isEmptyMarkdownString(l.hover.contents)||(yield new ze(this,e.item.anchor.range,l.hover.contents,!1,2+l.ordinal))}finally{s.dispose()}}};Oa=Aw([on(1,o.IMarkdownRendererService),on(2,o.IKeybindingService),on(3,o.IHoverService),on(4,o.IConfigurationService),on(5,o.ITextModelService),on(6,o.ILanguageFeaturesService),on(7,o.ICommandService)],Oa);var v_=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Ss=function(c,e){return function(t,i){e(t,i,c)}},$h,jh;let qh=$h=class extends a.Disposable{constructor(e,t,i,n,s,r,l){super();const d=t.hoverParts;this._renderedHoverParts=this._register(new Gh(e,i,d,n,s,r,l));const h=t.options,u=h.anchor,{showAtPosition:g,showAtSecondaryPosition:p}=$h.computeHoverPositions(e,u.range,d);this.shouldAppearBeforeContent=d.some(f=>f.isBeforeContent),this.showAtPosition=g,this.showAtSecondaryPosition=p,this.initialMousePosX=u.initialMousePosX,this.initialMousePosY=u.initialMousePosY,this.shouldFocus=h.shouldFocus,this.source=h.source}get domNode(){return this._renderedHoverParts.domNode}get domNodeHasChildren(){return this._renderedHoverParts.domNodeHasChildren}get focusedHoverPartIndex(){return this._renderedHoverParts.focusedHoverPartIndex}get hoverPartsCount(){return this._renderedHoverParts.hoverPartsCount}focusHoverPartWithIndex(e){this._renderedHoverParts.focusHoverPartWithIndex(e)}async updateHoverVerbosityLevel(e,t,i){this._renderedHoverParts.updateHoverVerbosityLevel(e,t,i)}isColorPickerVisible(){return this._renderedHoverParts.isColorPickerVisible()}static computeHoverPositions(e,t,i){let n=1;if(e.hasModel()){const u=e._getViewModel(),g=u.coordinatesConverter,p=g.convertModelRangeToViewRange(t),f=u.getLineMinColumn(p.startLineNumber),m=new a.Position(p.startLineNumber,f);n=g.convertViewPositionToModelPosition(m).column}const s=t.startLineNumber;let r=t.startColumn,l;for(const u of i){const g=u.range,p=g.startLineNumber===s,f=g.endLineNumber===s;if(p&&f){const _=g.startColumn,v=Math.min(r,_);r=Math.max(v,n)}u.forceShowAtRange&&(l=g)}let d,h;if(l){const u=l.getStartPosition();d=u,h=u}else d=t.getStartPosition(),h=new a.Position(s,r);return{showAtPosition:d,showAtSecondaryPosition:h}}};qh=$h=v_([Ss(4,o.IKeybindingService),Ss(5,o.IHoverService),Ss(6,o.IClipboardService)],qh);class Fw{constructor(e,t){this._statusBar=t,e.appendChild(this._statusBar.hoverElement)}get hoverElement(){return this._statusBar.hoverElement}get actions(){return this._statusBar.actions}dispose(){this._statusBar.dispose()}}let Gh=(Rn=class extends a.Disposable{constructor(e,t,i,n,s,r,l){super(),this._hoverService=r,this._clipboardService=l,this._renderedParts=[],this._perPartDisposables=new Map,this._focusedHoverPartIndex=-1,this._context=n,this._fragment=document.createDocumentFragment(),this._register(this._renderParts(t,i,n,s,this._hoverService)),this._register(this._registerListenersOnRenderedParts()),this._register(this._createEditorDecorations(e,i)),this._updateMarkdownAndColorParticipantInfo(t)}_createEditorDecorations(e,t){if(t.length===0)return a.Disposable.None;let i=t[0].range;for(const s of t){const r=s.range;i=a.Range.plusRange(i,r)}const n=e.createDecorationsCollection();return n.set([{range:i,options:jh._DECORATION_OPTIONS}]),a.toDisposable(()=>{n.clear()})}_renderParts(e,t,i,n,s){const r=new da(n,s),l={fragment:this._fragment,statusBar:r,...i},d=new a.DisposableStore;d.add(r);for(const u of e){const g=this._renderHoverPartsForParticipant(t,u,l);d.add(g);for(const p of g.renderedHoverParts)this._renderedParts.push({type:"hoverPart",participant:u,hoverPart:p.hoverPart,hoverElement:p.hoverElement})}const h=this._renderStatusBar(this._fragment,r);return h&&(d.add(h),this._renderedParts.push({type:"statusBar",hoverElement:h.hoverElement,actions:h.actions})),d}_renderHoverPartsForParticipant(e,t,i){const n=e.filter(r=>r.owner===t);return n.length>0?t.renderHoverParts(i,n):new Zi([])}_renderStatusBar(e,t){if(t.hasContent)return new Fw(e,t)}_registerListenersOnRenderedParts(){return this._renderedParts.forEach((e,t)=>{this._createListenersForPart(t,e)}),a.toDisposable(()=>{for(const e of this._perPartDisposables.values())e.dispose();this._perPartDisposables.clear()})}_createListenersForPart(e,t){const i=new a.DisposableStore,n=t.hoverElement;n.tabIndex=0,i.add(o.addDisposableListener(n,o.EventType.FOCUS_IN,s=>{s.stopPropagation(),this._focusedHoverPartIndex=e})),i.add(o.addDisposableListener(n,o.EventType.FOCUS_OUT,s=>{s.stopPropagation(),this._focusedHoverPartIndex=-1})),t.type==="hoverPart"&&!(t.hoverPart instanceof Po)&&!t.participant.hideCopyButton&&i.add(new Sh(n,()=>t.participant.getAccessibleContent(t.hoverPart),this._clipboardService,this._hoverService)),this._perPartDisposables.set(e,i)}_updateMarkdownAndColorParticipantInfo(e){const t=e.find(i=>i instanceof To&&!(i instanceof Oa));t&&(this._markdownHoverParticipant=t),this._colorHoverParticipant=e.find(i=>i instanceof Sa)}focusHoverPartWithIndex(e){e<0||e>=this._renderedParts.length||this._renderedParts[e].hoverElement.focus()}async updateHoverVerbosityLevel(e,t,i){if(!this._markdownHoverParticipant)return;let n;t>=0?n={start:t,endExclusive:t+1}:n=this._findRangeOfMarkdownHoverParts(this._markdownHoverParticipant);for(let s=n.start;s<n.endExclusive;s++){const r=this._normalizedIndexToMarkdownHoverIndexRange(this._markdownHoverParticipant,s);if(r===void 0)continue;const l=await this._markdownHoverParticipant.updateMarkdownHoverVerbosityLevel(e,r);if(!l)continue;const d=this._perPartDisposables.get(s);d&&(d.dispose(),this._perPartDisposables.delete(s)),this._renderedParts[s]={type:"hoverPart",participant:this._markdownHoverParticipant,hoverPart:l.hoverPart,hoverElement:l.hoverElement},this._createListenersForPart(s,this._renderedParts[s])}i&&(t>=0?this.focusHoverPartWithIndex(t):this._context.focus()),this._context.onContentsChanged()}isColorPickerVisible(){return this._colorHoverParticipant?.isColorPickerVisible()??!1}_normalizedIndexToMarkdownHoverIndexRange(e,t){const i=this._renderedParts[t];if(!i||i.type!=="hoverPart"||!(i.participant===e))return;const s=this._renderedParts.findIndex(r=>r.type==="hoverPart"&&r.participant===e);if(s===-1)throw new a.BugIndicatingError;return t-s}_findRangeOfMarkdownHoverParts(e){const t=this._renderedParts.slice(),i=t.findIndex(r=>r.type==="hoverPart"&&r.participant===e),n=t.reverse().findIndex(r=>r.type==="hoverPart"&&r.participant===e),s=n>=0?t.length-n:n;return{start:i,endExclusive:s+1}}get domNode(){return this._fragment}get domNodeHasChildren(){return this._fragment.hasChildNodes()}get focusedHoverPartIndex(){return this._focusedHoverPartIndex}get hoverPartsCount(){return this._renderedParts.length}},jh=Rn,Rn._DECORATION_OPTIONS=o.ModelDecorationOptions.register({description:"content-hover-highlight",className:"hoverHighlight"}),Rn);Gh=jh=v_([Ss(4,o.IKeybindingService),Ss(5,o.IHoverService),Ss(6,o.IClipboardService)],Gh);var zw=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Aa=function(c,e){return function(t,i){e(t,i,c)}};let Zh=class extends a.Disposable{constructor(e,t,i,n,s){super(),this._editor=e,this._instantiationService=t,this._keybindingService=i,this._hoverService=n,this._clipboardService=s,this._currentResult=null,this._renderedContentHover=this._register(new a.MutableDisposable),this._onContentsChanged=this._register(new a.Emitter),this.onContentsChanged=this._onContentsChanged.event,this._contentHoverWidget=this._register(this._instantiationService.createInstance(dh,this._editor)),this._participants=this._initializeHoverParticipants(),this._hoverOperation=this._register(new wm(this._editor,new ca(this._editor,this._participants))),this._registerListeners()}_initializeHoverParticipants(){const e=[];for(const t of Xi.getAll()){const i=this._instantiationService.createInstance(t,this._editor);e.push(i)}return e.sort((t,i)=>t.hoverOrdinal-i.hoverOrdinal),this._register(this._contentHoverWidget.onDidResize(()=>{this._participants.forEach(t=>t.handleResize?.())})),this._register(this._contentHoverWidget.onDidScroll(t=>{this._participants.forEach(i=>i.handleScroll?.(t))})),this._register(this._contentHoverWidget.onContentsChanged(()=>{this._participants.forEach(t=>t.handleContentsChanged?.())})),e}_registerListeners(){this._register(this._hoverOperation.onResult(t=>{const i=t.hasLoadingMessage?this._addLoadingMessage(t):t.value;this._withResult(new Em(i,t.isComplete,t.options))}));const e=this._contentHoverWidget.getDomNode();this._register(o.addStandardDisposableListener(e,"keydown",t=>{t.equals(9)&&this.hide()})),this._register(o.addStandardDisposableListener(e,"mouseleave",t=>{this._onMouseLeave(t)})),this._register(a.TokenizationRegistry.onDidChange(()=>{this._contentHoverWidget.position&&this._currentResult&&this._setCurrentResult(this._currentResult)})),this._register(this._contentHoverWidget.onContentsChanged(()=>{this._onContentsChanged.fire()}))}_startShowingOrUpdateHover(e,t,i,n,s){if(!(this._contentHoverWidget.position&&this._currentResult))return e?(this._startHoverOperationIfNecessary(e,t,i,n,!1),!0):!1;const l=this._editor.getOption(69).sticky,d=s&&this._contentHoverWidget.isMouseGettingCloser(s.event.posx,s.event.posy);return l&&d?(e&&this._startHoverOperationIfNecessary(e,t,i,n,!0),!0):e?this._currentResult&&this._currentResult.options.anchor.equals(e)?!0:this._currentResult&&e.canAdoptVisibleHover(this._currentResult.options.anchor,this._contentHoverWidget.position)?(this._currentResult&&this._setCurrentResult(this._currentResult.filter(e)),this._startHoverOperationIfNecessary(e,t,i,n,!1),!0):(this._setCurrentResult(null),this._startHoverOperationIfNecessary(e,t,i,n,!1),!0):(this._setCurrentResult(null),!1)}_startHoverOperationIfNecessary(e,t,i,n,s){if(this._hoverOperation.options&&this._hoverOperation.options.anchor.equals(e))return;this._hoverOperation.cancel();const l={anchor:e,source:i,shouldFocus:n,insistOnKeepingHoverVisible:s};this._hoverOperation.start(t,l)}_setCurrentResult(e){let t=e;if(this._currentResult===t)return;t&&t.hoverParts.length===0&&(t=null),this._currentResult=t,this._currentResult?this._showHover(this._currentResult):this._hideHover()}_addLoadingMessage(e){for(const t of this._participants){if(!t.createLoadingMessage)continue;const i=t.createLoadingMessage(e.options.anchor);if(i)return e.value.slice(0).concat([i])}return e.value}_withResult(e){if(this._contentHoverWidget.position&&this._currentResult&&this._currentResult.isComplete||this._setCurrentResult(e),!e.isComplete)return;const n=e.hoverParts.length===0,s=e.options.insistOnKeepingHoverVisible;n&&s||this._setCurrentResult(e)}_showHover(e){const t=this._getHoverContext();this._renderedContentHover.value=new qh(this._editor,e,this._participants,t,this._keybindingService,this._hoverService,this._clipboardService),this._renderedContentHover.value.domNodeHasChildren?this._contentHoverWidget.show(this._renderedContentHover.value):this._renderedContentHover.clear()}_hideHover(){this._contentHoverWidget.hide(),this._participants.forEach(e=>e.handleHide?.())}_getHoverContext(){return{hide:()=>{this.hide()},onContentsChanged:()=>{this._contentHoverWidget.handleContentsChanged()},setMinimumDimensions:s=>{this._contentHoverWidget.setMinimumDimensions(s)},focus:()=>this.focus()}}showsOrWillShow(e){if(this._contentHoverWidget.isResizing||this._isMouseOnCodeActionWidget(e))return!0;const i=this._findHoverAnchorCandidates(e);if(!(i.length>0))return this._startShowingOrUpdateHover(null,0,0,!1,e);const s=i[0];return this._startShowingOrUpdateHover(s,0,0,!1,e)}_findHoverAnchorCandidates(e){const t=[];for(const n of this._participants){if(!n.suggestHoverAnchor)continue;const s=n.suggestHoverAnchor(e);s&&t.push(s)}const i=e.target;switch(i.type){case 6:{t.push(new Qd(0,i.range,e.event.posx,e.event.posy));break}case 7:{const n=this._editor.getOption(59).typicalHalfwidthCharacterWidth/2;if(!(!i.detail.isAfterLines&&typeof i.detail.horizontalDistanceToText=="number"&&i.detail.horizontalDistanceToText<n))break;t.push(new Qd(0,i.range,e.event.posx,e.event.posy));break}}return t.sort((n,s)=>s.priority-n.priority),t}_isMouseOnCodeActionWidget(e){const t=e.event.browserEvent.target;return!!(t instanceof Element&&t.closest(".action-widget"))}_onMouseLeave(e){const t=this._editor.getDomNode();(!t||!aa(t,e.x,e.y))&&this.hide()}startShowingAtRange(e,t,i,n){this._startShowingOrUpdateHover(new Qd(0,e,void 0,void 0),t,i,n,null)}async updateHoverVerbosityLevel(e,t,i){this._renderedContentHover.value?.updateHoverVerbosityLevel(e,t,i)}focusedHoverPartIndex(){return this._renderedContentHover.value?.focusedHoverPartIndex??-1}containsNode(e){return e?this._contentHoverWidget.getDomNode().contains(e):!1}focus(){if(this._renderedContentHover.value?.hoverPartsCount===1){this.focusHoverPartWithIndex(0);return}this._contentHoverWidget.focus()}focusHoverPartWithIndex(e){this._renderedContentHover.value?.focusHoverPartWithIndex(e)}scrollUp(){this._contentHoverWidget.scrollUp()}scrollDown(){this._contentHoverWidget.scrollDown()}scrollLeft(){this._contentHoverWidget.scrollLeft()}scrollRight(){this._contentHoverWidget.scrollRight()}pageUp(){this._contentHoverWidget.pageUp()}pageDown(){this._contentHoverWidget.pageDown()}goToTop(){this._contentHoverWidget.goToTop()}goToBottom(){this._contentHoverWidget.goToBottom()}hide(){this._hoverOperation.cancel(),this._setCurrentResult(null)}getDomNode(){return this._contentHoverWidget.getDomNode()}get isColorPickerVisible(){return this._renderedContentHover.value?.isColorPickerVisible()??!1}get isVisibleFromKeyboard(){return this._contentHoverWidget.isVisibleFromKeyboard}get isVisible(){return this._contentHoverWidget.isVisible}get isFocused(){return this._contentHoverWidget.isFocused}get isResizing(){return this._contentHoverWidget.isResizing}get widget(){return this._contentHoverWidget}};Zh=zw([Aa(1,o.IInstantiationService),Aa(2,o.IKeybindingService),Aa(3,o.IHoverService),Aa(4,o.IClipboardService)],Zh);function b_(c){const e=c.target;return!!e&&e.type===6&&e.detail.injectedText?.options.attachedData===mm}var Vw=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Xh=function(c,e){return function(t,i){e(t,i,c)}},Yh;let oe=(Tn=class extends a.Disposable{constructor(e,t,i,n){super(),this._editor=e,this._instantiationService=i,this._keybindingService=n,this._onHoverContentsChanged=this._register(new a.Emitter),this.shouldKeepOpenOnEditorMouseMoveOrLeave=!1,this._listenersStore=new a.DisposableStore,this._isMouseDown=!1,this._ignoreMouseEvents=!1,this._reactToEditorMouseMoveRunner=this._register(new a.RunOnceScheduler(()=>{this._mouseMoveEvent&&this._reactToEditorMouseMove(this._mouseMoveEvent)},0)),this._register(t.onDidShowContextMenu(()=>{this.hideContentHover(),this._ignoreMouseEvents=!0})),this._register(t.onDidHideContextMenu(()=>{this._ignoreMouseEvents=!1})),this._hookListeners(),this._register(this._editor.onDidChangeConfiguration(s=>{s.hasChanged(69)&&(this._unhookListeners(),this._hookListeners())}))}static get(e){return e.getContribution(Yh.ID)}_hookListeners(){const e=this._editor.getOption(69);this._hoverSettings={enabled:e.enabled,sticky:e.sticky,hidingDelay:e.hidingDelay},e.enabled==="off"&&this._cancelSchedulerAndHide(),this._listenersStore.add(this._editor.onMouseDown(t=>this._onEditorMouseDown(t))),this._listenersStore.add(this._editor.onMouseUp(()=>this._onEditorMouseUp())),this._listenersStore.add(this._editor.onMouseMove(t=>this._onEditorMouseMove(t))),this._listenersStore.add(this._editor.onKeyDown(t=>this._onKeyDown(t))),this._listenersStore.add(this._editor.onMouseLeave(t=>this._onEditorMouseLeave(t))),this._listenersStore.add(this._editor.onDidChangeModel(()=>this._cancelSchedulerAndHide())),this._listenersStore.add(this._editor.onDidChangeModelContent(()=>this._cancelScheduler())),this._listenersStore.add(this._editor.onDidScrollChange(t=>this._onEditorScrollChanged(t)))}_unhookListeners(){this._listenersStore.clear()}_cancelSchedulerAndHide(){this._cancelScheduler(),this.hideContentHover()}_cancelScheduler(){this._mouseMoveEvent=void 0,this._reactToEditorMouseMoveRunner.cancel()}_onEditorScrollChanged(e){this._ignoreMouseEvents||(e.scrollTopChanged||e.scrollLeftChanged)&&this.hideContentHover()}_onEditorMouseDown(e){this._ignoreMouseEvents||(this._isMouseDown=!0,this._shouldKeepHoverWidgetVisible(e))||this.hideContentHover()}_shouldKeepHoverWidgetVisible(e){return this._isMouseOnContentHoverWidget(e)||this._isContentWidgetResizing()||b_(e)}_isMouseOnContentHoverWidget(e){return!this._contentWidget||!this._contentWidget.getDomNode().isConnected?!1:aa(this._contentWidget.getDomNode(),e.event.posx,e.event.posy)}_onEditorMouseUp(){this._ignoreMouseEvents||(this._isMouseDown=!1)}_onEditorMouseLeave(e){this._ignoreMouseEvents||this.shouldKeepOpenOnEditorMouseMoveOrLeave||(this._cancelScheduler(),this._shouldKeepHoverWidgetVisible(e))||this.hideContentHover()}_shouldKeepCurrentHover(e){const t=this._contentWidget;if(!t)return!1;const i=this._hoverSettings.sticky,n=(u,g)=>{const p=this._isMouseOnContentHoverWidget(u);return g&&p},s=u=>{const g=t.isColorPickerVisible,p=this._isMouseOnContentHoverWidget(u),f=g&&p,m=g&&this._isMouseDown;return f||m},r=(u,g)=>{const p=u.event.browserEvent.view;return p?g&&t.containsNode(p.document.activeElement)&&!p.getSelection()?.isCollapsed:!1},l=t.isFocused,d=t.isResizing,h=this._hoverSettings.sticky&&t.isVisibleFromKeyboard;return this.shouldKeepOpenOnEditorMouseMoveOrLeave||l||d||h||n(e,i)||s(e)||r(e,i)}_onEditorMouseMove(e){if(this._ignoreMouseEvents)return;if(this._isMouseDown&&!this._shouldKeepHoverWidgetVisible(e)){this._cancelSchedulerAndHide();return}if(this._mouseMoveEvent=e,this._shouldKeepCurrentHover(e)){this._reactToEditorMouseMoveRunner.cancel();return}if(this._shouldRescheduleHoverComputation()){this._reactToEditorMouseMoveRunner.isScheduled()||this._reactToEditorMouseMoveRunner.schedule(this._hoverSettings.hidingDelay);return}this._reactToEditorMouseMove(e)}_shouldRescheduleHoverComputation(){const e=this._hoverSettings.hidingDelay;return(this._contentWidget?.isVisible??!1)&&this._hoverSettings.sticky&&e>0}_reactToEditorMouseMove(e){ym(this._hoverSettings.enabled,this._editor.getOption(86),e)&&this._getOrCreateContentWidget().showsOrWillShow(e)||this.hideContentHover()}_onKeyDown(e){if(this._ignoreMouseEvents||!this._contentWidget)return;if(this._hoverSettings.enabled==="onKeyboardModifier"&&ah(this._editor.getOption(86),e)&&this._mouseMoveEvent){this._contentWidget.isVisible||this._contentWidget.showsOrWillShow(this._mouseMoveEvent);return}const t=this._isPotentialKeyboardShortcut(e),i=a.isModifierKey(e.keyCode);t||i||this._contentWidget.isFocused&&e.keyCode===2||this.hideContentHover()}_isPotentialKeyboardShortcut(e){if(!this._editor.hasModel()||!this._contentWidget)return!1;const t=this._keybindingService.softDispatch(e,this._editor.getDomNode()),i=t.kind===1,n=t.kind===2&&(t.commandId===_m||t.commandId===na||t.commandId===sa)&&this._contentWidget.isVisible;return i||n}hideContentHover(){gs.dropDownVisible||this._contentWidget?.hide()}_getOrCreateContentWidget(){return this._contentWidget||(this._contentWidget=this._instantiationService.createInstance(Zh,this._editor),this._listenersStore.add(this._contentWidget.onContentsChanged(()=>this._onHoverContentsChanged.fire()))),this._contentWidget}showContentHover(e,t,i,n){this._getOrCreateContentWidget().startShowingAtRange(e,t,i,n)}_isContentWidgetResizing(){return this._contentWidget?.widget.isResizing||!1}focusedHoverPartIndex(){return this._getOrCreateContentWidget().focusedHoverPartIndex()}updateHoverVerbosityLevel(e,t,i){this._getOrCreateContentWidget().updateHoverVerbosityLevel(e,t,i)}focus(){this._contentWidget?.focus()}scrollUp(){this._contentWidget?.scrollUp()}scrollDown(){this._contentWidget?.scrollDown()}scrollLeft(){this._contentWidget?.scrollLeft()}scrollRight(){this._contentWidget?.scrollRight()}pageUp(){this._contentWidget?.pageUp()}pageDown(){this._contentWidget?.pageDown()}goToTop(){this._contentWidget?.goToTop()}goToBottom(){this._contentWidget?.goToBottom()}get isColorPickerVisible(){return this._contentWidget?.isColorPickerVisible}get isHoverVisible(){return this._contentWidget?.isVisible}dispose(){super.dispose(),this._unhookListeners(),this._listenersStore.dispose(),this._contentWidget?.dispose()}},Yh=Tn,Tn.ID="editor.contrib.contentHover",Tn);oe=Yh=Vw([Xh(1,o.IContextMenuService),Xh(2,o.IInstantiationService),Xh(3,o.IKeybindingService)],oe);const ff=class ff extends a.Disposable{constructor(e){super(),this._editor=e,this._register(e.onMouseDown(t=>this.onMouseDown(t)))}dispose(){super.dispose()}onMouseDown(e){const t=this._editor.getOption(169);if(t!=="click"&&t!=="clickAndHover"||!b_(e))return;const i=this._editor.getContribution(oe.ID);if(!i||i.isColorPickerVisible)return;const n=e.target.range;if(!n)return;const s=new a.Range(n.startLineNumber,n.startColumn+1,n.endLineNumber,n.endColumn+1);i.showContentHover(s,1,1,!1)}};ff.ID="editor.contrib.colorContribution";let Fa=ff;var Bw=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Kw=function(c,e){return function(t,i){e(t,i,c)}};class Qh{constructor(e,t,i,n){this.owner=e,this.range=t,this.model=i,this.provider=n}static fromBaseColor(e,t){return new Qh(e,t.range,t.model,t.provider)}}class kw extends a.Disposable{constructor(e,t,i,n){super();const s=e.getModel(),r=i.model;this.color=i.model.color,this.colorPicker=this._register(new Qm(t.fragment,r,e.getOption(164),n,"standalone")),this._register(r.onColorFlushed(l=>{this.color=l})),this._register(r.onDidChangeColor(l=>{Mo(s,r,l,i.range,i)})),this._register(e.onDidChangeModelContent(l=>{t.hide(),e.focus()})),Mo(s,r,this.color,i.range,i)}}let Jh=class{constructor(e,t){this._editor=e,this._themeService=t}async createColorHover(e,t,i){if(!this._editor.hasModel()||!us.get(this._editor))return null;const s=await gm(i,this._editor.getModel(),a.CancellationToken.None);let r=null,l=null;for(const p of s){const f=p.colorInfo;a.Range.containsRange(f.range,e.range)&&(r=f,l=p.provider)}const d=r??e,h=l??t,u=!!r;return{colorHover:Qh.fromBaseColor(this,await Jm(this._editor.getModel(),d,h)),foundInEditor:u}}async updateEditorModel(e,t){if(!this._editor.hasModel())return;const i=e.model;let n=new a.Range(e.range.startLineNumber,e.range.startColumn,e.range.endLineNumber,e.range.endColumn);this._color&&(await Mo(this._editor.getModel(),i,this._color,n,e),n=Wm(this._editor,n,i,t))}renderHoverParts(e,t){if(!(t.length===0||!this._editor.hasModel()))return this._setMinimumDimensions(e),this._renderedParts=new kw(this._editor,e,t[0],this._themeService),this._renderedParts}_setMinimumDimensions(e){const t=this._editor.getOption(75)+8;e.setMinimumDimensions(new o.Dimension(302,t))}get _color(){return this._renderedParts?.color}};Jh=Bw([Kw(1,o.IThemeService)],Jh);var Uw=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Ko=function(c,e){return function(t,i){e(t,i,c)}},Wh;class $w{constructor(e,t){this.value=e,this.foundInEditor=t}}const C_=8,jw=22;let Hh=(Nn=class extends a.Disposable{constructor(e,t,i,n,s,r,l,d){super(),this._editor=e,this._standaloneColorPickerVisible=t,this._standaloneColorPickerFocused=i,this._keybindingService=s,this._languageFeaturesService=r,this._editorWorkerService=l,this._hoverService=d,this.allowEditorOverflow=!0,this._position=void 0,this._body=document.createElement("div"),this._colorHover=null,this._selectionSetInEditor=!1,this._onResult=this._register(new a.Emitter),this.onResult=this._onResult.event,this._renderedHoverParts=this._register(new a.MutableDisposable),this._renderedStatusBar=this._register(new a.MutableDisposable),this._standaloneColorPickerVisible.set(!0),this._standaloneColorPickerParticipant=n.createInstance(Jh,this._editor),this._position=this._editor._getViewModel()?.getPrimaryCursorState().modelState.position;const h=this._editor.getSelection();this._selections=this._editor.getSelections()??[];const u=h?{startLineNumber:h.startLineNumber,startColumn:h.startColumn,endLineNumber:h.endLineNumber,endColumn:h.endColumn}:{startLineNumber:0,endLineNumber:0,endColumn:0,startColumn:0},g=this._register(o.trackFocus(this._body));this._register(g.onDidBlur(p=>{this.hide()})),this._register(g.onDidFocus(p=>{this.focus()})),this._register(this._editor.onDidChangeCursorPosition(()=>{this._selectionSetInEditor?this._selectionSetInEditor=!1:this.hide(),this._selections=this._editor.getSelections()??[]})),this._register(this._editor.onMouseMove(p=>{const f=p.target.element?.classList;f&&f.contains("colorpicker-color-decoration")&&this.hide()})),this._register(this.onResult(p=>{this._render(p.value,p.foundInEditor)})),this._start(u),this._body.style.zIndex="50",this._editor.addContentWidget(this)}updateEditor(){this._colorHover&&this._standaloneColorPickerParticipant.updateEditorModel(this._colorHover,this._selections)}getId(){return Wh.ID}getDomNode(){return this._body}getPosition(){if(!this._position)return null;const e=this._editor.getOption(69).above;return{position:this._position,secondaryPosition:this._position,preference:e?[1,2]:[2,1],positionAffinity:2}}hide(){this.dispose(),this._standaloneColorPickerVisible.set(!1),this._standaloneColorPickerFocused.set(!1),this._editor.removeContentWidget(this),this._editor.focus()}focus(){this._standaloneColorPickerFocused.set(!0),this._body.focus()}async _start(e){const t=await this._computeAsync(e);t&&this._onResult.fire(new $w(t.result,t.foundInEditor))}async _computeAsync(e){if(!this._editor.hasModel())return null;const t={range:e,color:{red:0,green:0,blue:0,alpha:1}},i=await this._standaloneColorPickerParticipant.createColorHover(t,new Eo(this._editorWorkerService),this._languageFeaturesService.colorProvider);return i?{result:i.colorHover,foundInEditor:i.foundInEditor}:null}_render(e,t){const i=document.createDocumentFragment();this._renderedStatusBar.value=this._register(new da(this._keybindingService,this._hoverService));const n={fragment:i,statusBar:this._renderedStatusBar.value,onContentsChanged:()=>{},setMinimumDimensions:()=>{},hide:()=>this.hide(),focus:()=>this.focus()};if(this._colorHover=e,this._renderedHoverParts.value=this._standaloneColorPickerParticipant.renderHoverParts(n,[e]),!this._renderedHoverParts.value){this._renderedStatusBar.clear(),this._renderedHoverParts.clear();return}const s=this._renderedHoverParts.value.colorPicker;this._body.classList.add("standalone-colorpicker-body"),this._body.style.maxHeight=Math.max(this._editor.getLayoutInfo().height/4,250)+"px",this._body.style.maxWidth=Math.max(this._editor.getLayoutInfo().width*.66,500)+"px",this._body.tabIndex=0,this._body.appendChild(i),s.layout();const r=s.body,l=r.saturationBox.domNode.clientWidth,d=r.domNode.clientWidth-l-jw-C_,h=s.body.enterButton;h?.onClicked(()=>{this.updateEditor(),this.hide()});const u=s.header,g=u.pickedColorNode;g.style.width=l+C_+"px";const p=u.originalColorNode;p.style.width=d+"px",s.header.closeButton?.onClicked(()=>{this.hide()}),t&&(h&&(h.button.textContent="Replace"),this._selectionSetInEditor=!0,this._editor.setSelection(e.range)),this._editor.layoutContentWidget(this)}},Wh=Nn,Nn.ID="editor.contrib.standaloneColorPickerWidget",Nn);Hh=Wh=Uw([Ko(3,o.IInstantiationService),Ko(4,o.IKeybindingService),Ko(5,o.ILanguageFeaturesService),Ko(6,o.IEditorWorkerService),Ko(7,o.IHoverService)],Hh);var qw=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},S_=function(c,e){return function(t,i){e(t,i,c)}},eu;let rn=(Mn=class extends a.Disposable{constructor(e,t,i){super(),this._editor=e,this._instantiationService=i,this._standaloneColorPickerWidget=null,this._standaloneColorPickerVisible=o.EditorContextKeys.standaloneColorPickerVisible.bindTo(t),this._standaloneColorPickerFocused=o.EditorContextKeys.standaloneColorPickerFocused.bindTo(t)}showOrFocus(){this._editor.hasModel()&&(this._standaloneColorPickerVisible.get()?this._standaloneColorPickerFocused.get()||this._standaloneColorPickerWidget?.focus():this._standaloneColorPickerWidget=this._instantiationService.createInstance(Hh,this._editor,this._standaloneColorPickerVisible,this._standaloneColorPickerFocused))}hide(){this._standaloneColorPickerFocused.set(!1),this._standaloneColorPickerVisible.set(!1),this._standaloneColorPickerWidget?.hide(),this._editor.focus()}insertColor(){this._standaloneColorPickerWidget?.updateEditor(),this.hide()}static get(e){return e.getContribution(eu.ID)}},eu=Mn,Mn.ID="editor.contrib.standaloneColorPickerController",Mn);rn=eu=qw([S_(1,o.IContextKeyService),S_(2,o.IInstantiationService)],rn);class Gw extends o.EditorAction2{constructor(){super({id:"editor.action.showOrFocusStandaloneColorPicker",title:{...a.localize2(940,"Show or Focus Standalone Color Picker"),mnemonicTitle:a.localize(939,"&&Show or Focus Standalone Color Picker")},precondition:void 0,menu:[{id:o.MenuId.CommandPalette}],metadata:{description:a.localize2(941,"Show or focus a standalone color picker which uses the default color provider. It displays hex/rgb/hsl colors.")}})}runEditorCommand(e,t){rn.get(t)?.showOrFocus()}}class Zw extends o.EditorAction{constructor(){super({id:"editor.action.hideColorPicker",label:a.localize2(942,"Hide the Color Picker"),precondition:o.EditorContextKeys.standaloneColorPickerVisible.isEqualTo(!0),kbOpts:{primary:9,weight:100},metadata:{description:a.localize2(943,"Hide the standalone color picker.")}})}run(e,t){rn.get(t)?.hide()}}class Xw extends o.EditorAction{constructor(){super({id:"editor.action.insertColorWithStandaloneColorPicker",label:a.localize2(944,"Insert Color with Standalone Color Picker"),precondition:o.EditorContextKeys.standaloneColorPickerFocused.isEqualTo(!0),kbOpts:{primary:3,weight:100},metadata:{description:a.localize2(945,"Insert hex/rgb/hsl colors with the focused standalone color picker.")}})}run(e,t){rn.get(t)?.insertColor()}}o.registerEditorAction(Zw),o.registerEditorAction(Xw),o.registerAction2(Gw),o.registerEditorContribution(Fa.ID,Fa,2),o.registerEditorContribution(rn.ID,rn,1),o.registerEditorContribution(us.ID,us,1),o.registerEditorFeature(Wd),Xi.register(Sa),o.CommandsRegistry.registerCommand("_executeDocumentColorProvider",function(c,...e){const[t]=e;if(!(t instanceof a.URI))throw a.illegalArgument();const{model:i,colorProviderRegistry:n,defaultColorDecoratorsEnablement:s}=fm(c,t);return Hd(new BS,n,i,a.CancellationToken.None,s)}),o.CommandsRegistry.registerCommand("_executeColorPresentationProvider",function(c,...e){const[t,i]=e;if(!i)return;const{uri:n,range:s}=i;if(!(n instanceof a.URI)||!Array.isArray(t)||t.length!==4||!a.Range.isIRange(s))throw a.illegalArgument();const{model:r,colorProviderRegistry:l,defaultColorDecoratorsEnablement:d}=fm(c,n),[h,u,g,p]=t;return Hd(new KS({range:s,color:{red:h,green:u,blue:g,alpha:p}}),l,r,a.CancellationToken.None,d)});class qt{constructor(e,t,i){this.languageConfigurationService=i,this._selection=e,this._insertSpace=t,this._usedEndToken=null}static _haystackHasNeedleAtOffset(e,t,i){if(i<0)return!1;const n=t.length,s=e.length;if(i+n>s)return!1;for(let r=0;r<n;r++){const l=e.charCodeAt(i+r),d=t.charCodeAt(r);if(l!==d&&!(l>=65&&l<=90&&l+32===d)&&!(d>=65&&d<=90&&d+32===l))return!1}return!0}_createOperationsForBlockComment(e,t,i,n,s,r){const l=e.startLineNumber,d=e.startColumn,h=e.endLineNumber,u=e.endColumn,g=s.getLineContent(l),p=s.getLineContent(h);let f=g.lastIndexOf(t,d-1+t.length),m=p.indexOf(i,u-1-i.length);if(f!==-1&&m!==-1)if(l===h)g.substring(f+t.length,m).indexOf(i)>=0&&(f=-1,m=-1);else{const v=g.substring(f+t.length),b=p.substring(0,m);(v.indexOf(i)>=0||b.indexOf(i)>=0)&&(f=-1,m=-1)}let _;f!==-1&&m!==-1?(n&&f+t.length<g.length&&g.charCodeAt(f+t.length)===32&&(t=t+" "),n&&m>0&&p.charCodeAt(m-1)===32&&(i=" "+i,m-=1),_=qt._createRemoveBlockCommentOperations(new a.Range(l,f+t.length+1,h,m+1),t,i)):(_=qt._createAddBlockCommentOperations(e,t,i,this._insertSpace),this._usedEndToken=_.length===1?i:null);for(const v of _)r.addTrackedEditOperation(v.range,v.text)}static _createRemoveBlockCommentOperations(e,t,i){const n=[];return a.Range.isEmpty(e)?n.push(o.EditOperation.delete(new a.Range(e.startLineNumber,e.startColumn-t.length,e.endLineNumber,e.endColumn+i.length))):(n.push(o.EditOperation.delete(new a.Range(e.startLineNumber,e.startColumn-t.length,e.startLineNumber,e.startColumn))),n.push(o.EditOperation.delete(new a.Range(e.endLineNumber,e.endColumn,e.endLineNumber,e.endColumn+i.length)))),n}static _createAddBlockCommentOperations(e,t,i,n){const s=[];return a.Range.isEmpty(e)?s.push(o.EditOperation.replace(new a.Range(e.startLineNumber,e.startColumn,e.endLineNumber,e.endColumn),t+" "+i)):(s.push(o.EditOperation.insert(new a.Position(e.startLineNumber,e.startColumn),t+(n?" ":""))),s.push(o.EditOperation.insert(new a.Position(e.endLineNumber,e.endColumn),(n?" ":"")+i))),s}getEditOperations(e,t){const i=this._selection.startLineNumber,n=this._selection.startColumn;e.tokenization.tokenizeIfCheap(i);const s=e.getLanguageIdAtPosition(i,n),r=this.languageConfigurationService.getLanguageConfiguration(s).comments;!r||!r.blockCommentStartToken||!r.blockCommentEndToken||this._createOperationsForBlockComment(this._selection,r.blockCommentStartToken,r.blockCommentEndToken,this._insertSpace,e,t)}computeCursorState(e,t){const i=t.getInverseEditOperations();if(i.length===2){const n=i[0],s=i[1];return new a.Selection(n.range.endLineNumber,n.range.endColumn,s.range.startLineNumber,s.range.startColumn)}else{const n=i[0].range,s=this._usedEndToken?-this._usedEndToken.length-1:0;return new a.Selection(n.endLineNumber,n.endColumn+s,n.endLineNumber,n.endColumn+s)}}}class Rt{constructor(e,t,i,n,s,r,l){this.languageConfigurationService=e,this._selection=t,this._indentSize=i,this._type=n,this._insertSpace=s,this._selectionId=null,this._deltaColumn=0,this._moveEndPositionDown=!1,this._ignoreEmptyLines=r,this._ignoreFirstLine=l||!1}static _gatherPreflightCommentStrings(e,t,i,n){e.tokenization.tokenizeIfCheap(t);const s=e.getLanguageIdAtPosition(t,1),r=n.getLanguageConfiguration(s).comments,l=r?r.lineCommentToken:null;if(!l)return null;const d=[];for(let h=0,u=i-t+1;h<u;h++)d[h]={ignore:!1,commentStr:l,commentStrOffset:0,commentStrLength:l.length};return d}static _analyzeLines(e,t,i,n,s,r,l,d,h){let u=!0;const p=d.getLanguageConfiguration(h).comments?.lineCommentNoIndent??!1;let f;e===0?f=!0:e===1?f=!1:f=!0;for(let m=0,_=n.length;m<_;m++){const v=n[m],b=s+m;if(b===s&&l){v.ignore=!0;continue}const C=i.getLineContent(b),y=a.firstNonWhitespaceIndex(C);if(y===-1){v.ignore=r,v.commentStrOffset=p?0:C.length;continue}u=!1;const I=p?0:y;if(v.ignore=!1,v.commentStrOffset=I,f&&!qt._haystackHasNeedleAtOffset(C,v.commentStr,I)&&(e===0?f=!1:e===1||(v.ignore=!0)),f&&t){const x=y+v.commentStrLength;x<C.length&&C.charCodeAt(x)===32&&(v.commentStrLength+=1)}}if(e===0&&u){f=!1;for(let m=0,_=n.length;m<_;m++)n[m].ignore=!1}return{supported:!0,shouldRemoveComments:f,lines:n}}static _gatherPreflightData(e,t,i,n,s,r,l,d){const h=Rt._gatherPreflightCommentStrings(i,n,s,d),u=i.getLanguageIdAtPosition(n,1);return h===null?{supported:!1}:Rt._analyzeLines(e,t,i,h,n,r,l,d,u)}_executeLineComments(e,t,i,n){let s;i.shouldRemoveComments?s=Rt._createRemoveLineCommentsOperations(i.lines,n.startLineNumber):(Rt._normalizeInsertionPoint(e,i.lines,n.startLineNumber,this._indentSize),s=this._createAddLineCommentsOperations(i.lines,n.startLineNumber));const r=new a.Position(n.positionLineNumber,n.positionColumn);for(let l=0,d=s.length;l<d;l++)t.addEditOperation(s[l].range,s[l].text),a.Range.isEmpty(s[l].range)&&a.Range.getStartPosition(s[l].range).equals(r)&&e.getLineContent(r.lineNumber).length+1===r.column&&(this._deltaColumn=(s[l].text||"").length);this._selectionId=t.trackSelection(n)}_attemptRemoveBlockComment(e,t,i,n){let s=t.startLineNumber,r=t.endLineNumber;const l=n.length+Math.max(e.getLineFirstNonWhitespaceColumn(t.startLineNumber),t.startColumn);let d=e.getLineContent(s).lastIndexOf(i,l-1),h=e.getLineContent(r).indexOf(n,t.endColumn-1-i.length);return d!==-1&&h===-1&&(h=e.getLineContent(s).indexOf(n,d+i.length),r=s),d===-1&&h!==-1&&(d=e.getLineContent(r).lastIndexOf(i,h),s=r),t.isEmpty()&&(d===-1||h===-1)&&(d=e.getLineContent(s).indexOf(i),d!==-1&&(h=e.getLineContent(s).indexOf(n,d+i.length))),d!==-1&&e.getLineContent(s).charCodeAt(d+i.length)===32&&(i+=" "),h!==-1&&e.getLineContent(r).charCodeAt(h-1)===32&&(n=" "+n,h-=1),d!==-1&&h!==-1?qt._createRemoveBlockCommentOperations(new a.Range(s,d+i.length+1,r,h+1),i,n):null}_executeBlockComment(e,t,i){e.tokenization.tokenizeIfCheap(i.startLineNumber);const n=e.getLanguageIdAtPosition(i.startLineNumber,1),s=this.languageConfigurationService.getLanguageConfiguration(n).comments;if(!s||!s.blockCommentStartToken||!s.blockCommentEndToken)return;const r=s.blockCommentStartToken,l=s.blockCommentEndToken;let d=this._attemptRemoveBlockComment(e,i,r,l);if(!d){if(i.isEmpty()){const h=e.getLineContent(i.startLineNumber);let u=a.firstNonWhitespaceIndex(h);u===-1&&(u=h.length),d=qt._createAddBlockCommentOperations(new a.Range(i.startLineNumber,u+1,i.startLineNumber,h.length+1),r,l,this._insertSpace)}else d=qt._createAddBlockCommentOperations(new a.Range(i.startLineNumber,e.getLineFirstNonWhitespaceColumn(i.startLineNumber),i.endLineNumber,e.getLineMaxColumn(i.endLineNumber)),r,l,this._insertSpace);d.length===1&&(this._deltaColumn=r.length+1)}this._selectionId=t.trackSelection(i);for(const h of d)t.addEditOperation(h.range,h.text)}getEditOperations(e,t){let i=this._selection;if(this._moveEndPositionDown=!1,i.startLineNumber===i.endLineNumber&&this._ignoreFirstLine){t.addEditOperation(new a.Range(i.startLineNumber,e.getLineMaxColumn(i.startLineNumber),i.startLineNumber+1,1),i.startLineNumber===e.getLineCount()?"":`
11
+ `),this._selectionId=t.trackSelection(i);return}i.startLineNumber<i.endLineNumber&&i.endColumn===1&&(this._moveEndPositionDown=!0,i=i.setEndPosition(i.endLineNumber-1,e.getLineMaxColumn(i.endLineNumber-1)));const n=Rt._gatherPreflightData(this._type,this._insertSpace,e,i.startLineNumber,i.endLineNumber,this._ignoreEmptyLines,this._ignoreFirstLine,this.languageConfigurationService);return n.supported?this._executeLineComments(e,t,n,i):this._executeBlockComment(e,t,i)}computeCursorState(e,t){let i=t.getTrackedSelection(this._selectionId);return this._moveEndPositionDown&&(i=i.setEndPosition(i.endLineNumber+1,1)),new a.Selection(i.selectionStartLineNumber,i.selectionStartColumn+this._deltaColumn,i.positionLineNumber,i.positionColumn+this._deltaColumn)}static _createRemoveLineCommentsOperations(e,t){const i=[];for(let n=0,s=e.length;n<s;n++){const r=e[n];r.ignore||i.push(o.EditOperation.delete(new a.Range(t+n,r.commentStrOffset+1,t+n,r.commentStrOffset+r.commentStrLength+1)))}return i}_createAddLineCommentsOperations(e,t){const i=[],n=this._insertSpace?" ":"";for(let s=0,r=e.length;s<r;s++){const l=e[s];l.ignore||i.push(o.EditOperation.insert(new a.Position(t+s,l.commentStrOffset+1),l.commentStr+n))}return i}static nextVisibleColumn(e,t,i,n){return i?e+(t-e%t):e+n}static _normalizeInsertionPoint(e,t,i,n){let s=1073741824,r,l;for(let d=0,h=t.length;d<h;d++){if(t[d].ignore)continue;const u=e.getLineContent(i+d);let g=0;for(let p=0,f=t[d].commentStrOffset;g<s&&p<f;p++)g=Rt.nextVisibleColumn(g,n,u.charCodeAt(p)===9,1);g<s&&(s=g)}s=Math.floor(s/n)*n;for(let d=0,h=t.length;d<h;d++){if(t[d].ignore)continue;const u=e.getLineContent(i+d);let g=0;for(r=0,l=t[d].commentStrOffset;g<s&&r<l;r++)g=Rt.nextVisibleColumn(g,n,u.charCodeAt(r)===9,1);g>s?t[d].commentStrOffset=r-1:t[d].commentStrOffset=r}}}class tu extends o.EditorAction{constructor(e,t){super(t),this._type=e}run(e,t){const i=e.get(o.ILanguageConfigurationService);if(!t.hasModel())return;const n=t.getModel(),s=[],r=n.getOptions(),l=t.getOption(29),d=t.getSelections().map((u,g)=>({selection:u,index:g,ignoreFirstLine:!1}));d.sort((u,g)=>a.Range.compareRangesUsingStarts(u.selection,g.selection));let h=d[0];for(let u=1;u<d.length;u++){const g=d[u];h.selection.endLineNumber===g.selection.startLineNumber&&(h.index<g.index?g.ignoreFirstLine=!0:(h.ignoreFirstLine=!0,h=g))}for(const u of d)s.push(new Rt(i,u.selection,r.indentSize,this._type,l.insertSpace,l.ignoreEmptyLines,u.ignoreFirstLine));t.pushUndoStop(),t.executeCommands(this.id,s),t.pushUndoStop()}}class Yw extends tu{constructor(){super(0,{id:"editor.action.commentLine",label:a.localize2(948,"Toggle Line Comment"),precondition:o.EditorContextKeys.writable,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:2138,weight:100},menuOpts:{menuId:o.MenuId.MenubarEditMenu,group:"5_insert",title:a.localize(946,"&&Toggle Line Comment"),order:1},canTriggerInlineEdits:!0})}}class Qw extends tu{constructor(){super(1,{id:"editor.action.addCommentLine",label:a.localize2(949,"Add Line Comment"),precondition:o.EditorContextKeys.writable,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:a.KeyChord(2089,2081),weight:100},canTriggerInlineEdits:!0})}}class Jw extends tu{constructor(){super(2,{id:"editor.action.removeCommentLine",label:a.localize2(950,"Remove Line Comment"),precondition:o.EditorContextKeys.writable,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:a.KeyChord(2089,2099),weight:100},canTriggerInlineEdits:!0})}}class Ww extends o.EditorAction{constructor(){super({id:"editor.action.blockComment",label:a.localize2(951,"Toggle Block Comment"),precondition:o.EditorContextKeys.writable,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:1567,linux:{primary:3103},weight:100},menuOpts:{menuId:o.MenuId.MenubarEditMenu,group:"5_insert",title:a.localize(947,"Toggle &&Block Comment"),order:2},canTriggerInlineEdits:!0})}run(e,t){const i=e.get(o.ILanguageConfigurationService);if(!t.hasModel())return;const n=t.getOption(29),s=[],r=t.getSelections();for(const l of r)s.push(new qt(l,n.insertSpace,i));t.pushUndoStop(),t.executeCommands(this.id,s),t.pushUndoStop()}}o.registerEditorAction(Yw),o.registerEditorAction(Qw),o.registerEditorAction(Jw),o.registerEditorAction(Ww);var Hw=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},an=function(c,e){return function(t,i){e(t,i,c)}},iu;let ko=(Pn=class{static get(e){return e.getContribution(iu.ID)}constructor(e,t,i,n,s,r,l,d){this._contextMenuService=t,this._contextViewService=i,this._contextKeyService=n,this._keybindingService=s,this._menuService=r,this._configurationService=l,this._workspaceContextService=d,this._toDispose=new a.DisposableStore,this._contextMenuIsBeingShownCount=0,this._editor=e,this._toDispose.add(this._editor.onContextMenu(h=>this._onContextMenu(h))),this._toDispose.add(this._editor.onMouseWheel(h=>{if(this._contextMenuIsBeingShownCount>0){const u=this._contextViewService.getContextViewElement(),g=h.srcElement;g.shadowRoot&&o.getShadowRoot(u)===g.shadowRoot||this._contextViewService.hideContextView()}})),this._toDispose.add(this._editor.onKeyDown(h=>{this._editor.getOption(30)&&h.keyCode===58&&(h.preventDefault(),h.stopPropagation(),this.showContextMenu())}))}_onContextMenu(e){if(!this._editor.hasModel())return;if(!this._editor.getOption(30)){this._editor.focus(),e.target.position&&!this._editor.getSelection().containsPosition(e.target.position)&&this._editor.setPosition(e.target.position);return}if(e.target.type===12||e.target.type===6&&e.target.detail.injectedText)return;if(e.event.preventDefault(),e.event.stopPropagation(),e.target.type===11)return this._showScrollbarContextMenu(e.event);if(e.target.type!==6&&e.target.type!==7&&e.target.type!==1)return;if(this._editor.focus(),e.target.position){let i=!1;for(const n of this._editor.getSelections())if(n.containsPosition(e.target.position)){i=!0;break}i||this._editor.setPosition(e.target.position)}let t=null;e.target.type!==1&&(t=e.event),this.showContextMenu(t)}showContextMenu(e){if(!this._editor.getOption(30)||!this._editor.hasModel())return;const t=this._getMenuActions(this._editor.getModel(),this._editor.contextMenuId);t.length>0&&this._doShowContextMenu(t,e)}_getMenuActions(e,t){const i=[],n=this._menuService.getMenuActions(t,this._contextKeyService,{arg:e.uri});for(const s of n){const[,r]=s;let l=0;for(const d of r)if(d instanceof o.SubmenuItemAction){const h=this._getMenuActions(e,d.item.submenu);h.length>0&&(i.push(new o.SubmenuAction(d.id,d.label,h)),l++)}else i.push(d),l++;l&&i.push(new o.Separator)}return i.length&&i.pop(),i}_doShowContextMenu(e,t=null){if(!this._editor.hasModel())return;let i=t;if(!i){this._editor.revealPosition(this._editor.getPosition(),1),this._editor.render();const s=this._editor.getScrolledVisiblePosition(this._editor.getPosition()),r=o.getDomNodePagePosition(this._editor.getDomNode()),l=r.left+s.left,d=r.top+s.top+s.height;i={x:l,y:d}}const n=this._editor.getOption(144)&&!a.isIOS;this._contextMenuIsBeingShownCount++,this._contextMenuService.showContextMenu({domForShadowRoot:n?this._editor.getOverflowWidgetsDomNode()??this._editor.getDomNode():void 0,useWindowContainerForShadowRoot:n&&this._editor.getOption(51),getAnchor:()=>i,getActions:()=>e,getActionViewItem:s=>{const r=this._keybindingFor(s);if(r)return new o.ActionViewItem(s,s,{label:!0,keybinding:r.getLabel(),isMenu:!0});const l=s;return typeof l.getActionViewItem=="function"?l.getActionViewItem():new o.ActionViewItem(s,s,{icon:!0,label:!0,isMenu:!0})},getKeyBinding:s=>this._keybindingFor(s),onHide:s=>{this._contextMenuIsBeingShownCount--}})}_showScrollbarContextMenu(e){if(!this._editor.hasModel()||o.isStandaloneEditorWorkspace(this._workspaceContextService.getWorkspace()))return;const t=this._editor.getOption(81);let i=0;const n=h=>({id:`menu-action-${++i}`,label:h.label,tooltip:"",class:void 0,enabled:typeof h.enabled>"u"?!0:h.enabled,checked:h.checked,run:h.run}),s=(h,u)=>new o.SubmenuAction(`menu-action-${++i}`,h,u,void 0),r=(h,u,g,p,f)=>{if(!u)return n({label:h,enabled:u,run:()=>{}});const m=v=>()=>{this._configurationService.updateValue(g,v)},_=[];for(const v of f)_.push(n({label:v.label,checked:p===v.value,run:m(v.value)}));return s(h,_)},l=[];l.push(n({label:a.localize(952,"Minimap"),checked:t.enabled,run:()=>{this._configurationService.updateValue("editor.minimap.enabled",!t.enabled)}})),l.push(new o.Separator),l.push(n({label:a.localize(953,"Render Characters"),enabled:t.enabled,checked:t.renderCharacters,run:()=>{this._configurationService.updateValue("editor.minimap.renderCharacters",!t.renderCharacters)}})),l.push(r(a.localize(954,"Vertical size"),t.enabled,"editor.minimap.size",t.size,[{label:a.localize(955,"Proportional"),value:"proportional"},{label:a.localize(956,"Fill"),value:"fill"},{label:a.localize(957,"Fit"),value:"fit"}])),l.push(r(a.localize(958,"Slider"),t.enabled,"editor.minimap.showSlider",t.showSlider,[{label:a.localize(959,"Mouse Over"),value:"mouseover"},{label:a.localize(960,"Always"),value:"always"}])),l.push(r(a.localize(961,"Side"),t.enabled,"editor.minimap.side",t.side,[{label:a.localize(962,"Right"),value:"right"},{label:a.localize(963,"Left"),value:"left"}]));const d=this._editor.getOption(144)&&!a.isIOS;this._contextMenuIsBeingShownCount++,this._contextMenuService.showContextMenu({domForShadowRoot:d?this._editor.getDomNode():void 0,useWindowContainerForShadowRoot:d&&this._editor.getOption(51),getAnchor:()=>e,getActions:()=>l,onHide:h=>{this._contextMenuIsBeingShownCount--,this._editor.focus()}})}_keybindingFor(e){return this._keybindingService.lookupKeybinding(e.id)}dispose(){this._contextMenuIsBeingShownCount>0&&this._contextViewService.hideContextView(),this._toDispose.dispose()}},iu=Pn,Pn.ID="editor.contrib.contextmenu",Pn);ko=iu=Hw([an(1,o.IContextMenuService),an(2,o.IContextViewService),an(3,o.IContextKeyService),an(4,o.IKeybindingService),an(5,o.IMenuService),an(6,o.IConfigurationService),an(7,o.IWorkspaceContextService)],ko);class eI extends o.EditorAction{constructor(){super({id:"editor.action.showContextMenu",label:a.localize2(964,"Show Editor Context Menu"),precondition:void 0,kbOpts:{kbExpr:o.EditorContextKeys.textInputFocus,primary:1092,weight:100}})}run(e,t){ko.get(t)?.showContextMenu()}}o.registerEditorContribution(ko.ID,ko,2),o.registerEditorAction(eI);class nu{constructor(e){this.selections=e}equals(e){const t=this.selections.length,i=e.selections.length;if(t!==i)return!1;for(let n=0;n<t;n++)if(!this.selections[n].equalsSelection(e.selections[n]))return!1;return!0}}class su{constructor(e,t,i){this.cursorState=e,this.scrollTop=t,this.scrollLeft=i}}const Tc=class Tc extends a.Disposable{static get(e){return e.getContribution(Tc.ID)}constructor(e){super(),this._editor=e,this._isCursorUndoRedo=!1,this._undoStack=[],this._redoStack=[],this._register(e.onDidChangeModel(t=>{this._undoStack=[],this._redoStack=[]})),this._register(e.onDidChangeModelContent(t=>{this._undoStack=[],this._redoStack=[]})),this._register(e.onDidChangeCursorSelection(t=>{if(this._isCursorUndoRedo||!t.oldSelections||t.oldModelVersionId!==t.modelVersionId)return;const i=new nu(t.oldSelections);this._undoStack.length>0&&this._undoStack[this._undoStack.length-1].cursorState.equals(i)||(this._undoStack.push(new su(i,e.getScrollTop(),e.getScrollLeft())),this._redoStack=[],this._undoStack.length>50&&this._undoStack.shift())}))}cursorUndo(){!this._editor.hasModel()||this._undoStack.length===0||(this._redoStack.push(new su(new nu(this._editor.getSelections()),this._editor.getScrollTop(),this._editor.getScrollLeft())),this._applyState(this._undoStack.pop()))}cursorRedo(){!this._editor.hasModel()||this._redoStack.length===0||(this._undoStack.push(new su(new nu(this._editor.getSelections()),this._editor.getScrollTop(),this._editor.getScrollLeft())),this._applyState(this._redoStack.pop()))}_applyState(e){this._isCursorUndoRedo=!0,this._editor.setSelections(e.cursorState.selections),this._editor.setScrollPosition({scrollTop:e.scrollTop,scrollLeft:e.scrollLeft}),this._isCursorUndoRedo=!1}};Tc.ID="editor.contrib.cursorUndoRedoController";let ys=Tc;class tI extends o.EditorAction{constructor(){super({id:"cursorUndo",label:a.localize2(965,"Cursor Undo"),precondition:void 0,kbOpts:{kbExpr:o.EditorContextKeys.textInputFocus,primary:2099,weight:100}})}run(e,t,i){ys.get(t)?.cursorUndo()}}class iI extends o.EditorAction{constructor(){super({id:"cursorRedo",label:a.localize2(966,"Cursor Redo"),precondition:void 0})}run(e,t,i){ys.get(t)?.cursorRedo()}}o.registerEditorContribution(ys.ID,ys,0),o.registerEditorAction(tI),o.registerEditorAction(iI);class nI{constructor(e,t,i){this.selection=e,this.targetPosition=t,this.copy=i,this.targetSelection=null}getEditOperations(e,t){const i=e.getValueInRange(this.selection);if(this.copy||t.addEditOperation(this.selection,null),t.addEditOperation(new a.Range(this.targetPosition.lineNumber,this.targetPosition.column,this.targetPosition.lineNumber,this.targetPosition.column),i),this.selection.containsPosition(this.targetPosition)&&!(this.copy&&(this.selection.getEndPosition().equals(this.targetPosition)||this.selection.getStartPosition().equals(this.targetPosition)))){this.targetSelection=this.selection;return}if(this.copy){this.targetSelection=new a.Selection(this.targetPosition.lineNumber,this.targetPosition.column,this.selection.endLineNumber-this.selection.startLineNumber+this.targetPosition.lineNumber,this.selection.startLineNumber===this.selection.endLineNumber?this.targetPosition.column+this.selection.endColumn-this.selection.startColumn:this.selection.endColumn);return}if(this.targetPosition.lineNumber>this.selection.endLineNumber){this.targetSelection=new a.Selection(this.targetPosition.lineNumber-this.selection.endLineNumber+this.selection.startLineNumber,this.targetPosition.column,this.targetPosition.lineNumber,this.selection.startLineNumber===this.selection.endLineNumber?this.targetPosition.column+this.selection.endColumn-this.selection.startColumn:this.selection.endColumn);return}if(this.targetPosition.lineNumber<this.selection.endLineNumber){this.targetSelection=new a.Selection(this.targetPosition.lineNumber,this.targetPosition.column,this.targetPosition.lineNumber+this.selection.endLineNumber-this.selection.startLineNumber,this.selection.startLineNumber===this.selection.endLineNumber?this.targetPosition.column+this.selection.endColumn-this.selection.startColumn:this.selection.endColumn);return}this.selection.endColumn<=this.targetPosition.column?this.targetSelection=new a.Selection(this.targetPosition.lineNumber-this.selection.endLineNumber+this.selection.startLineNumber,this.selection.startLineNumber===this.selection.endLineNumber?this.targetPosition.column-this.selection.endColumn+this.selection.startColumn:this.targetPosition.column-this.selection.endColumn+this.selection.startColumn,this.targetPosition.lineNumber,this.selection.startLineNumber===this.selection.endLineNumber?this.targetPosition.column:this.selection.endColumn):this.targetSelection=new a.Selection(this.targetPosition.lineNumber-this.selection.endLineNumber+this.selection.startLineNumber,this.targetPosition.column,this.targetPosition.lineNumber,this.targetPosition.column+this.selection.endColumn-this.selection.startColumn)}computeCursorState(e,t){return this.targetSelection}}function ws(c){return a.isMacintosh?c.altKey:c.ctrlKey}const yi=class yi extends a.Disposable{constructor(e){super(),this._editor=e,this._dndDecorationIds=this._editor.createDecorationsCollection(),this._register(this._editor.onMouseDown(t=>this._onEditorMouseDown(t))),this._register(this._editor.onMouseUp(t=>this._onEditorMouseUp(t))),this._register(this._editor.onMouseDrag(t=>this._onEditorMouseDrag(t))),this._register(this._editor.onMouseDrop(t=>this._onEditorMouseDrop(t))),this._register(this._editor.onMouseDropCanceled(()=>this._onEditorMouseDropCanceled())),this._register(this._editor.onKeyDown(t=>this.onEditorKeyDown(t))),this._register(this._editor.onKeyUp(t=>this.onEditorKeyUp(t))),this._register(this._editor.onDidBlurEditorWidget(()=>this.onEditorBlur())),this._register(this._editor.onDidBlurEditorText(()=>this.onEditorBlur())),this._mouseDown=!1,this._modifierPressed=!1,this._dragSelection=null}onEditorBlur(){this._removeDecoration(),this._dragSelection=null,this._mouseDown=!1,this._modifierPressed=!1}onEditorKeyDown(e){!this._editor.getOption(42)||this._editor.getOption(28)||(ws(e)&&(this._modifierPressed=!0),this._mouseDown&&ws(e)&&this._editor.updateOptions({mouseStyle:"copy"}))}onEditorKeyUp(e){!this._editor.getOption(42)||this._editor.getOption(28)||(ws(e)&&(this._modifierPressed=!1),this._mouseDown&&e.keyCode===yi.TRIGGER_KEY_VALUE&&this._editor.updateOptions({mouseStyle:"default"}))}_onEditorMouseDown(e){this._mouseDown=!0}_onEditorMouseUp(e){this._mouseDown=!1,this._editor.updateOptions({mouseStyle:"text"})}_onEditorMouseDrag(e){const t=e.target;if(this._dragSelection===null){const n=(this._editor.getSelections()||[]).filter(s=>t.position&&s.containsPosition(t.position));if(n.length===1)this._dragSelection=n[0];else return}ws(e.event)?this._editor.updateOptions({mouseStyle:"copy"}):this._editor.updateOptions({mouseStyle:"default"}),t.position&&(this._dragSelection.containsPosition(t.position)?this._removeDecoration():this.showAt(t.position))}_onEditorMouseDropCanceled(){this._editor.updateOptions({mouseStyle:"text"}),this._removeDecoration(),this._dragSelection=null,this._mouseDown=!1}_onEditorMouseDrop(e){if(e.target&&(this._hitContent(e.target)||this._hitMargin(e.target))&&e.target.position){const t=new a.Position(e.target.position.lineNumber,e.target.position.column);if(this._dragSelection===null){let i=null;if(e.event.shiftKey){const n=this._editor.getSelection();if(n){const{selectionStartLineNumber:s,selectionStartColumn:r}=n;i=[new a.Selection(s,r,t.lineNumber,t.column)]}}else i=(this._editor.getSelections()||[]).map(n=>n.containsPosition(t)?new a.Selection(t.lineNumber,t.column,t.lineNumber,t.column):n);this._editor.setSelections(i||[],"mouse",3)}else(!this._dragSelection.containsPosition(t)||(ws(e.event)||this._modifierPressed)&&(this._dragSelection.getEndPosition().equals(t)||this._dragSelection.getStartPosition().equals(t)))&&(this._editor.pushUndoStop(),this._editor.executeCommand(yi.ID,new nI(this._dragSelection,t,ws(e.event)||this._modifierPressed)),this._editor.pushUndoStop())}this._editor.updateOptions({mouseStyle:"text"}),this._removeDecoration(),this._dragSelection=null,this._mouseDown=!1}showAt(e){this._dndDecorationIds.set([{range:new a.Range(e.lineNumber,e.column,e.lineNumber,e.column),options:yi._DECORATION_OPTIONS}]),this._editor.revealPosition(e,1)}_removeDecoration(){this._dndDecorationIds.clear()}_hitContent(e){return e.type===6||e.type===7}_hitMargin(e){return e.type===2||e.type===3||e.type===4}dispose(){this._removeDecoration(),this._dragSelection=null,this._mouseDown=!1,this._modifierPressed=!1,super.dispose()}};yi.ID="editor.contrib.dragAndDrop",yi.TRIGGER_KEY_VALUE=a.isMacintosh?6:5,yi._DECORATION_OPTIONS=o.ModelDecorationOptions.register({description:"dnd-target",className:"dnd-target"});let za=yi;o.registerEditorContribution(za.ID,za,2);const sI="editor.action.pasteAs";o.registerEditorContribution(xt.ID,xt,0),o.registerEditorFeature(yd),o.registerEditorCommand(new class extends o.EditorCommand{constructor(){super({id:$f,precondition:Fd,kbOpts:{weight:100,primary:2137}})}runEditorCommand(c,e){return xt.get(e)?.changePasteType()}}),o.registerEditorCommand(new class extends o.EditorCommand{constructor(){super({id:"editor.hidePasteWidget",precondition:Fd,kbOpts:{weight:100,primary:9}})}runEditorCommand(c,e){xt.get(e)?.clearWidgets()}}),o.registerEditorAction((On=class extends o.EditorAction{constructor(){super({id:sI,label:a.localize2(969,"Paste As..."),precondition:o.EditorContextKeys.writable,metadata:{description:"Paste as",args:[{name:"args",schema:On.argsSchema}]},canTriggerInlineEdits:!0})}run(e,t,i){let n;return i&&("kind"in i?n={only:new Z(i.kind)}:"preferences"in i&&(n={preferences:i.preferences.map(s=>new Z(s))})),xt.get(t)?.pasteAs(n)}},On.argsSchema={oneOf:[{type:"object",required:["kind"],properties:{kind:{type:"string",description:a.localize(967,`The kind of the paste edit to try pasting with.
12
+ If there are multiple edits for this kind, the editor will show a picker. If there are no edits of this kind, the editor will show an error message.`)}}},{type:"object",required:["preferences"],properties:{preferences:{type:"array",description:a.localize(968,`List of preferred paste edit kind to try applying.
13
+ The first edit matching the preferences will be applied.`),items:{type:"string"}}}}]},On)),o.registerEditorAction(class extends o.EditorAction{constructor(){super({id:"editor.action.pasteAsText",label:a.localize2(970,"Paste as Text"),precondition:o.EditorContextKeys.writable,canTriggerInlineEdits:!0})}run(c,e){return xt.get(e)?.pasteAs({providerId:Bi.id})}});class oI{constructor(){this._dragOperations=new Map}removeDragOperationTransfer(e){if(e&&this._dragOperations.has(e)){const t=this._dragOperations.get(e);return this._dragOperations.delete(e),t}}}class y_{constructor(e){this.identifier=e}}const w_=o.createDecorator("treeViewsDndService");o.registerSingleton(w_,oI,1);var rI=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Va=function(c,e){return function(t,i){e(t,i,c)}},Tt;const aI="editor.dropIntoEditor.preferences",I_="editor.changeDropType",ou=new o.RawContextKey("dropWidgetVisible",!1,a.localize(988,"Whether the drop widget is showing"));let Is=(An=class extends a.Disposable{static get(e){return e.getContribution(Tt.ID)}constructor(e,t,i,n,s){super(),this._configService=i,this._languageFeaturesService=n,this._treeViewsDragAndDropService=s,this.treeItemsTransfer=o.LocalSelectionTransfer.getInstance(),this._dropProgressManager=this._register(t.createInstance(Qr,"dropIntoEditor",e)),this._postDropWidgetManager=this._register(t.createInstance(ta,"dropIntoEditor",e,ou,{id:I_,label:a.localize(989,"Show drop options...")},()=>Tt._configureDefaultAction?[Tt._configureDefaultAction]:[])),this._register(e.onDropIntoEditor(r=>this.onDropIntoEditor(e,r.position,r.event)))}clearWidgets(){this._postDropWidgetManager.clear()}changeDropType(){this._postDropWidgetManager.tryShowSelector()}async onDropIntoEditor(e,t,i){if(!i.dataTransfer||!e.hasModel())return;Tt._currentDropOperation?.cancel(),e.focus(),e.setPosition(t);const n=a.createCancelablePromise(async s=>{const r=new a.DisposableStore,l=r.add(new o.EditorStateCancellationTokenSource(e,1,void 0,s));try{const d=await this.extractDataTransferData(i);if(d.size===0||l.token.isCancellationRequested)return;const h=e.getModel();if(!h)return;const u=this._languageFeaturesService.documentDropEditProvider.ordered(h).filter(p=>p.dropMimeTypes?p.dropMimeTypes.some(f=>d.matches(f)):!0),g=r.add(await this.getDropEdits(u,h,t,d,l.token));if(l.token.isCancellationRequested)return;if(g.edits.length){const p=this.getInitialActiveEditIndex(h,g.edits),f=e.getOption(43).showDropSelector==="afterDrop";await this._postDropWidgetManager.applyEditAndShowIfNeeded([a.Range.fromPositions(t)],{activeEditIndex:p,allEdits:g.edits},f,async m=>m,s)}}finally{r.dispose(),Tt._currentDropOperation===n&&(Tt._currentDropOperation=void 0)}});this._dropProgressManager.showWhile(t,a.localize(990,"Running drop handlers. Click to cancel"),n,{cancel:()=>n.cancel()}),Tt._currentDropOperation=n}async getDropEdits(e,t,i,n,s){const r=new a.DisposableStore,l=await a.raceCancellation(Promise.all(e.map(async h=>{try{const u=await h.provideDocumentDropEdits(t,i,n,s);return u&&r.add(u),u?.edits.map(g=>({...g,providerId:h.id}))}catch(u){a.isCancellationError(u)||console.error(u),console.error(u)}})),s),d=a.coalesce(l??[]).flat();return{edits:Mf(d),dispose:()=>r.dispose()}}getInitialActiveEditIndex(e,t){const i=this._configService.getValue(aI,{resource:e.uri});for(const n of Array.isArray(i)?i:[]){const s=new Z(n),r=t.findIndex(l=>l.kind&&s.contains(l.kind));if(r>=0)return r}return 0}async extractDataTransferData(e){if(!e.dataTransfer)return new o.VSDataTransfer;const t=o.toExternalVSDataTransfer(e.dataTransfer);if(this.treeItemsTransfer.hasData(y_.prototype)){const i=this.treeItemsTransfer.getData(y_.prototype);if(Array.isArray(i))for(const n of i){const s=await this._treeViewsDragAndDropService.removeDragOperationTransfer(n.identifier);if(s)for(const[r,l]of s)t.replace(r,l)}}return t}},Tt=An,An.ID="editor.contrib.dropIntoEditorController",An);Is=Tt=rI([Va(1,o.IInstantiationService),Va(2,o.IConfigurationService),Va(3,o.ILanguageFeaturesService),Va(4,w_)],Is),o.registerEditorContribution(Is.ID,Is,2),o.registerEditorFeature(Sd),o.registerEditorCommand(new class extends o.EditorCommand{constructor(){super({id:I_,precondition:ou,kbOpts:{weight:100,primary:2137}})}runEditorCommand(c,e,t){Is.get(e)?.changeDropType()}}),o.registerEditorCommand(new class extends o.EditorCommand{constructor(){super({id:"editor.hideDropWidget",precondition:ou,kbOpts:{weight:100,primary:9}})}runEditorCommand(c,e,t){Is.get(e)?.clearWidgets()}});const Nc=class Nc extends o.Widget{constructor(e,t,i){super(),this._hideSoon=this._register(new a.RunOnceScheduler(()=>this._hide(),2e3)),this._isVisible=!1,this._editor=e,this._state=t,this._keybindingService=i,this._domNode=document.createElement("div"),this._domNode.className="findOptionsWidget",this._domNode.style.display="none",this._domNode.style.top="10px",this._domNode.style.zIndex="12",this._domNode.setAttribute("role","presentation"),this._domNode.setAttribute("aria-hidden","true");const n={inputActiveOptionBorder:o.asCssVariable(o.inputActiveOptionBorder),inputActiveOptionForeground:o.asCssVariable(o.inputActiveOptionForeground),inputActiveOptionBackground:o.asCssVariable(o.inputActiveOptionBackground)},s={groupId:"find-options-widget"};this.caseSensitive=this._register(new o.CaseSensitiveToggle({appendTitle:this._keybindingLabelFor($.ToggleCaseSensitiveCommand),isChecked:this._state.matchCase,hoverLifecycleOptions:s,...n})),this._domNode.appendChild(this.caseSensitive.domNode),this._register(this.caseSensitive.onChange(()=>{this._state.change({matchCase:this.caseSensitive.checked},!1)})),this.wholeWords=this._register(new o.WholeWordsToggle({appendTitle:this._keybindingLabelFor($.ToggleWholeWordCommand),isChecked:this._state.wholeWord,hoverLifecycleOptions:s,...n})),this._domNode.appendChild(this.wholeWords.domNode),this._register(this.wholeWords.onChange(()=>{this._state.change({wholeWord:this.wholeWords.checked},!1)})),this.regex=this._register(new o.RegexToggle({appendTitle:this._keybindingLabelFor($.ToggleRegexCommand),isChecked:this._state.isRegex,hoverLifecycleOptions:s,...n})),this._domNode.appendChild(this.regex.domNode),this._register(this.regex.onChange(()=>{this._state.change({isRegex:this.regex.checked},!1)})),this._editor.addOverlayWidget(this),this._register(this._state.onFindReplaceStateChange(r=>{let l=!1;r.isRegex&&(this.regex.checked=this._state.isRegex,l=!0),r.wholeWord&&(this.wholeWords.checked=this._state.wholeWord,l=!0),r.matchCase&&(this.caseSensitive.checked=this._state.matchCase,l=!0),!this._state.isRevealed&&l&&this._revealTemporarily()})),this._register(o.addDisposableListener(this._domNode,o.EventType.MOUSE_LEAVE,r=>this._onMouseLeave())),this._register(o.addDisposableListener(this._domNode,"mouseover",r=>this._onMouseOver()))}_keybindingLabelFor(e){return this._keybindingService.appendKeybinding("",e)}dispose(){this._editor.removeOverlayWidget(this),super.dispose()}getId(){return Nc.ID}getDomNode(){return this._domNode}getPosition(){return{preference:0}}highlightFindOptions(){this._revealTemporarily()}_revealTemporarily(){this._show(),this._hideSoon.schedule()}_onMouseLeave(){this._hideSoon.schedule()}_onMouseOver(){this._hideSoon.cancel()}_show(){this._isVisible||(this._isVisible=!0,this._domNode.style.display="block")}_hide(){this._isVisible&&(this._isVisible=!1,this._domNode.style.display="none")}};Nc.ID="editor.contrib.findOptionsWidget";let ru=Nc;function Ba(c,e){return c===1?!0:c===2?!1:e}class lI extends a.Disposable{get searchString(){return this._searchString}get replaceString(){return this._replaceString}get isRevealed(){return this._isRevealed}get isReplaceRevealed(){return this._isReplaceRevealed}get isRegex(){return Ba(this._isRegexOverride,this._isRegex)}get wholeWord(){return Ba(this._wholeWordOverride,this._wholeWord)}get matchCase(){return Ba(this._matchCaseOverride,this._matchCase)}get preserveCase(){return Ba(this._preserveCaseOverride,this._preserveCase)}get actualIsRegex(){return this._isRegex}get actualWholeWord(){return this._wholeWord}get actualMatchCase(){return this._matchCase}get actualPreserveCase(){return this._preserveCase}get searchScope(){return this._searchScope}get matchesPosition(){return this._matchesPosition}get matchesCount(){return this._matchesCount}get currentMatch(){return this._currentMatch}constructor(){super(),this._onFindReplaceStateChange=this._register(new a.Emitter),this.onFindReplaceStateChange=this._onFindReplaceStateChange.event,this._searchString="",this._replaceString="",this._isRevealed=!1,this._isReplaceRevealed=!1,this._isRegex=!1,this._isRegexOverride=0,this._wholeWord=!1,this._wholeWordOverride=0,this._matchCase=!1,this._matchCaseOverride=0,this._preserveCase=!1,this._preserveCaseOverride=0,this._searchScope=null,this._matchesPosition=0,this._matchesCount=0,this._currentMatch=null,this._loop=!0,this._isSearching=!1,this._filters=null}changeMatchInfo(e,t,i){const n={moveCursor:!1,updateHistory:!1,searchString:!1,replaceString:!1,isRevealed:!1,isReplaceRevealed:!1,isRegex:!1,wholeWord:!1,matchCase:!1,preserveCase:!1,searchScope:!1,matchesPosition:!1,matchesCount:!1,currentMatch:!1,loop:!1,isSearching:!1,filters:!1};let s=!1;t===0&&(e=0),e>t&&(e=t),this._matchesPosition!==e&&(this._matchesPosition=e,n.matchesPosition=!0,s=!0),this._matchesCount!==t&&(this._matchesCount=t,n.matchesCount=!0,s=!0),typeof i<"u"&&(a.Range.equalsRange(this._currentMatch,i)||(this._currentMatch=i,n.currentMatch=!0,s=!0)),s&&this._onFindReplaceStateChange.fire(n)}change(e,t,i=!0){const n={moveCursor:t,updateHistory:i,searchString:!1,replaceString:!1,isRevealed:!1,isReplaceRevealed:!1,isRegex:!1,wholeWord:!1,matchCase:!1,preserveCase:!1,searchScope:!1,matchesPosition:!1,matchesCount:!1,currentMatch:!1,loop:!1,isSearching:!1,filters:!1};let s=!1;const r=this.isRegex,l=this.wholeWord,d=this.matchCase,h=this.preserveCase;typeof e.searchString<"u"&&this._searchString!==e.searchString&&(this._searchString=e.searchString,n.searchString=!0,s=!0),typeof e.replaceString<"u"&&this._replaceString!==e.replaceString&&(this._replaceString=e.replaceString,n.replaceString=!0,s=!0),typeof e.isRevealed<"u"&&this._isRevealed!==e.isRevealed&&(this._isRevealed=e.isRevealed,n.isRevealed=!0,s=!0),typeof e.isReplaceRevealed<"u"&&this._isReplaceRevealed!==e.isReplaceRevealed&&(this._isReplaceRevealed=e.isReplaceRevealed,n.isReplaceRevealed=!0,s=!0),typeof e.isRegex<"u"&&(this._isRegex=e.isRegex),typeof e.wholeWord<"u"&&(this._wholeWord=e.wholeWord),typeof e.matchCase<"u"&&(this._matchCase=e.matchCase),typeof e.preserveCase<"u"&&(this._preserveCase=e.preserveCase),typeof e.searchScope<"u"&&(e.searchScope?.every(u=>this._searchScope?.some(g=>!a.Range.equalsRange(g,u)))||(this._searchScope=e.searchScope,n.searchScope=!0,s=!0)),typeof e.loop<"u"&&this._loop!==e.loop&&(this._loop=e.loop,n.loop=!0,s=!0),typeof e.isSearching<"u"&&this._isSearching!==e.isSearching&&(this._isSearching=e.isSearching,n.isSearching=!0,s=!0),typeof e.filters<"u"&&(this._filters?this._filters.update(e.filters):this._filters=e.filters,n.filters=!0,s=!0),this._isRegexOverride=typeof e.isRegexOverride<"u"?e.isRegexOverride:0,this._wholeWordOverride=typeof e.wholeWordOverride<"u"?e.wholeWordOverride:0,this._matchCaseOverride=typeof e.matchCaseOverride<"u"?e.matchCaseOverride:0,this._preserveCaseOverride=typeof e.preserveCaseOverride<"u"?e.preserveCaseOverride:0,r!==this.isRegex&&(s=!0,n.isRegex=!0),l!==this.wholeWord&&(s=!0,n.wholeWord=!0),d!==this.matchCase&&(s=!0,n.matchCase=!0),h!==this.preserveCase&&(s=!0,n.preserveCase=!0),s&&this._onFindReplaceStateChange.fire(n)}canNavigateBack(){return this.canNavigateInLoop()||this.matchesPosition!==1}canNavigateForward(){return this.canNavigateInLoop()||this.matchesPosition<this.matchesCount}canNavigateInLoop(){return this._loop||this.matchesCount>=jt}}var cI=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},dI=function(c,e){return function(t,i){e(t,i,c)}},Gt;let au=(wi=class{static getOrCreate(e){return Gt._instance||(Gt._instance=new Gt(e)),Gt._instance}constructor(e){this.storageService=e,this.inMemoryValues=new Set,this._onDidChangeEmitter=new a.Emitter,this.onDidChange=this._onDidChangeEmitter.event,this.load()}delete(e){const t=this.inMemoryValues.delete(e);return this.save(),t}add(e){return this.inMemoryValues.add(e),this.save(),this}has(e){return this.inMemoryValues.has(e)}forEach(e,t){return this.load(),this.inMemoryValues.forEach(e)}replace(e){this.inMemoryValues=new Set(e),this.save()}load(){let e;const t=this.storageService.get(Gt.FIND_HISTORY_KEY,1);if(t)try{e=JSON.parse(t)}catch{}this.inMemoryValues=new Set(e||[])}save(){const e=[];return this.inMemoryValues.forEach(t=>e.push(t)),new Promise(t=>{this.storageService.store(Gt.FIND_HISTORY_KEY,JSON.stringify(e),1,0),this._onDidChangeEmitter.fire(e),t()})}},Gt=wi,wi.FIND_HISTORY_KEY="workbench.find.history",wi._instance=null,wi);au=Gt=cI([dI(0,o.IStorageService)],au);var hI=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},uI=function(c,e){return function(t,i){e(t,i,c)}},Zt;let lu=(Ii=class{static getOrCreate(e){return Zt._instance||(Zt._instance=new Zt(e)),Zt._instance}constructor(e){this.storageService=e,this.inMemoryValues=new Set,this._onDidChangeEmitter=new a.Emitter,this.onDidChange=this._onDidChangeEmitter.event,this.load()}delete(e){const t=this.inMemoryValues.delete(e);return this.save(),t}add(e){return this.inMemoryValues.add(e),this.save(),this}has(e){return this.inMemoryValues.has(e)}forEach(e,t){return this.load(),this.inMemoryValues.forEach(e)}replace(e){this.inMemoryValues=new Set(e),this.save()}load(){let e;const t=this.storageService.get(Zt.FIND_HISTORY_KEY,1);if(t)try{e=JSON.parse(t)}catch{}this.inMemoryValues=new Set(e||[])}save(){const e=[];return this.inMemoryValues.forEach(t=>e.push(t)),new Promise(t=>{this.storageService.store(Zt.FIND_HISTORY_KEY,JSON.stringify(e),1,0),this._onDidChangeEmitter.fire(e),t()})}},Zt=Ii,Ii.FIND_HISTORY_KEY="workbench.replace.history",Ii._instance=null,Ii);lu=Zt=hI([uI(0,o.IStorageService)],lu);var x_=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Ie=function(c,e){return function(t,i){e(t,i,c)}},cu;const gI=524288;function du(c,e="single",t=!1){if(!c.hasModel())return null;const i=c.getSelection();if(e==="single"&&i.startLineNumber===i.endLineNumber||e==="multiple"){if(i.isEmpty()){const n=c.getConfiguredWordAtPosition(i.getStartPosition());if(n&&t===!1)return n.word}else if(c.getModel().getValueLengthInRange(i)<gI)return c.getModel().getValueInRange(i)}return null}let fe=(Fn=class extends a.Disposable{get editor(){return this._editor}static get(e){return e.getContribution(cu.ID)}constructor(e,t,i,n,s,r){super(),this._editor=e,this._findWidgetVisible=Et.bindTo(t),this._contextKeyService=t,this._storageService=i,this._clipboardService=n,this._notificationService=s,this._hoverService=r,this._updateHistoryDelayer=this._register(new a.Delayer(500)),this._state=this._register(new lI),this.loadQueryState(),this._register(this._state.onFindReplaceStateChange(l=>this._onStateChanged(l))),this._model=null,this._register(this._editor.onDidChangeModel(()=>{const l=this._editor.getModel()&&this._state.isRevealed;this.disposeModel(),this._state.change({searchScope:null,matchCase:this._storageService.getBoolean("editor.matchCase",1,!1),wholeWord:this._storageService.getBoolean("editor.wholeWord",1,!1),isRegex:this._storageService.getBoolean("editor.isRegex",1,!1),preserveCase:this._storageService.getBoolean("editor.preserveCase",1,!1)},!1),l&&this._start({forceRevealReplace:!1,seedSearchStringFromSelection:"none",seedSearchStringFromNonEmptySelection:!1,seedSearchStringFromGlobalClipboard:!1,shouldFocus:0,shouldAnimate:!1,updateSearchScope:!1,loop:this._editor.getOption(50).loop})}))}dispose(){this.disposeModel(),super.dispose()}disposeModel(){this._model&&(this._model.dispose(),this._model=null)}_onStateChanged(e){this.saveQueryState(e),e.isRevealed&&(this._state.isRevealed?this._findWidgetVisible.set(!0):(this._findWidgetVisible.reset(),this.disposeModel())),e.searchString&&this.setGlobalBufferTerm(this._state.searchString)}saveQueryState(e){e.isRegex&&this._storageService.store("editor.isRegex",this._state.actualIsRegex,1,1),e.wholeWord&&this._storageService.store("editor.wholeWord",this._state.actualWholeWord,1,1),e.matchCase&&this._storageService.store("editor.matchCase",this._state.actualMatchCase,1,1),e.preserveCase&&this._storageService.store("editor.preserveCase",this._state.actualPreserveCase,1,1)}loadQueryState(){this._state.change({matchCase:this._storageService.getBoolean("editor.matchCase",1,this._state.matchCase),wholeWord:this._storageService.getBoolean("editor.wholeWord",1,this._state.wholeWord),isRegex:this._storageService.getBoolean("editor.isRegex",1,this._state.isRegex),preserveCase:this._storageService.getBoolean("editor.preserveCase",1,this._state.preserveCase)},!1)}isFindInputFocused(){return!!ha.getValue(this._contextKeyService)}getState(){return this._state}closeFindWidget(){this._state.change({isRevealed:!1,searchScope:null},!1),this._editor.focus()}toggleCaseSensitive(){this._state.change({matchCase:!this._state.matchCase},!1),this._state.isRevealed||this.highlightFindOptions()}toggleWholeWords(){this._state.change({wholeWord:!this._state.wholeWord},!1),this._state.isRevealed||this.highlightFindOptions()}toggleRegex(){this._state.change({isRegex:!this._state.isRegex},!1),this._state.isRevealed||this.highlightFindOptions()}togglePreserveCase(){this._state.change({preserveCase:!this._state.preserveCase},!1),this._state.isRevealed||this.highlightFindOptions()}toggleSearchScope(){if(this._state.searchScope)this._state.change({searchScope:null},!0);else if(this._editor.hasModel()){let e=this._editor.getSelections();e=e.map(t=>(t.endColumn===1&&t.endLineNumber>t.startLineNumber&&(t=t.setEndPosition(t.endLineNumber-1,this._editor.getModel().getLineMaxColumn(t.endLineNumber-1))),t.isEmpty()?null:t)).filter(t=>!!t),e.length&&this._state.change({searchScope:e},!0)}}setSearchString(e){this._state.isRegex&&(e=a.escapeRegExpCharacters(e)),this._state.change({searchString:e},!1)}highlightFindOptions(e=!1){}async _start(e,t){if(this.disposeModel(),!this._editor.hasModel())return;const i={...t,isRevealed:!0};if(e.seedSearchStringFromSelection==="single"){const n=du(this._editor,e.seedSearchStringFromSelection,e.seedSearchStringFromNonEmptySelection);n&&(this._state.isRegex?i.searchString=a.escapeRegExpCharacters(n):i.searchString=n)}else if(e.seedSearchStringFromSelection==="multiple"&&!e.updateSearchScope){const n=du(this._editor,e.seedSearchStringFromSelection);n&&(i.searchString=n)}if(!i.searchString&&e.seedSearchStringFromGlobalClipboard){const n=await this.getGlobalBufferTerm();if(!this._editor.hasModel())return;n&&(i.searchString=n)}if(e.forceRevealReplace||i.isReplaceRevealed?i.isReplaceRevealed=!0:this._findWidgetVisible.get()||(i.isReplaceRevealed=!1),e.updateSearchScope){const n=this._editor.getSelections();n.some(s=>!s.isEmpty())&&(i.searchScope=n)}i.loop=e.loop,this._state.change(i,!1),this._model||(this._model=new Lo(this._editor,this._state))}start(e,t){return this._start(e,t)}moveToNextMatch(){return this._model?(this._model.moveToNextMatch(),!0):!1}moveToPrevMatch(){return this._model?(this._model.moveToPrevMatch(),!0):!1}goToMatch(e){return this._model?(this._model.moveToMatch(e),!0):!1}replace(){return this._model?(this._model.replace(),!0):!1}replaceAll(){return this._model?this._editor.getModel()?.isTooLargeForHeapOperation()?(this._notificationService.warn(a.localize(994,"The file is too large to perform a replace all operation.")),!1):(this._model.replaceAll(),!0):!1}selectAllMatches(){return this._model?(this._model.selectAllMatches(),this._editor.focus(),!0):!1}async getGlobalBufferTerm(){return this._editor.getOption(50).globalFindClipboard&&this._editor.hasModel()&&!this._editor.getModel().isTooLargeForSyncing()?this._clipboardService.readFindText():""}setGlobalBufferTerm(e){this._editor.getOption(50).globalFindClipboard&&this._editor.hasModel()&&!this._editor.getModel().isTooLargeForSyncing()&&this._clipboardService.writeFindText(e)}},cu=Fn,Fn.ID="editor.contrib.findController",Fn);fe=cu=x_([Ie(1,o.IContextKeyService),Ie(2,o.IStorageService),Ie(3,o.IClipboardService),Ie(4,o.INotificationService),Ie(5,o.IHoverService)],fe);let hu=class extends fe{constructor(e,t,i,n,s,r,l,d,h,u){super(e,i,r,l,s,d),this._contextViewService=t,this._keybindingService=n,this._configurationService=h,this._accessibilityService=u,this._widget=null,this._findOptionsWidget=null,this._findWidgetSearchHistory=au.getOrCreate(r),this._replaceWidgetHistory=lu.getOrCreate(r)}async _start(e,t){this._widget||this._createFindWidget();const i=this._editor.getSelection();let n=!1;switch(this._editor.getOption(50).autoFindInSelection){case"always":n=!0;break;case"never":n=!1;break;case"multiline":{n=!!i&&i.startLineNumber!==i.endLineNumber;break}}e.updateSearchScope=e.updateSearchScope||n,await super._start(e,t),this._widget&&(e.shouldFocus===2?this._widget.focusReplaceInput():e.shouldFocus===1&&this._widget.focusFindInput())}highlightFindOptions(e=!1){this._widget||this._createFindWidget(),this._state.isRevealed&&!e?this._widget.highlightFindOptions():this._findOptionsWidget.highlightFindOptions()}_createFindWidget(){this._widget=this._register(new va(this._editor,this,this._state,this._contextViewService,this._keybindingService,this._contextKeyService,this._hoverService,this._findWidgetSearchHistory,this._replaceWidgetHistory,this._configurationService,this._accessibilityService)),this._findOptionsWidget=this._register(new ru(this._editor,this._state,this._keybindingService))}saveViewState(){return this._widget?.getViewState()}restoreViewState(e){this._widget?.setViewState(e)}};hu=x_([Ie(1,o.IContextViewService),Ie(2,o.IContextKeyService),Ie(3,o.IKeybindingService),Ie(4,o.INotificationService),Ie(5,o.IStorageService),Ie(6,o.IClipboardService),Ie(7,o.IHoverService),Ie(8,o.IConfigurationService),Ie(9,o.IAccessibilityService)],hu),o.registerMultiEditorAction(new o.MultiEditorAction({id:$.StartFindAction,label:a.localize2(1002,"Find"),precondition:o.ContextKeyExpr.or(o.EditorContextKeys.focus,o.ContextKeyExpr.has("editorIsOpen")),kbOpts:{kbExpr:null,primary:2084,weight:100},menuOpts:{menuId:o.MenuId.MenubarEditMenu,group:"3_find",title:a.localize(995,"&&Find"),order:1}})).addImplementation(0,(c,e,t)=>{const i=fe.get(e);return i?i.start({forceRevealReplace:!1,seedSearchStringFromSelection:e.getOption(50).seedSearchStringFromSelection!=="never"?"single":"none",seedSearchStringFromNonEmptySelection:e.getOption(50).seedSearchStringFromSelection==="selection",seedSearchStringFromGlobalClipboard:e.getOption(50).globalFindClipboard,shouldFocus:1,shouldAnimate:!0,updateSearchScope:!1,loop:e.getOption(50).loop}):!1});const pI={description:"Open a new In-Editor Find Widget.",args:[{name:"Open a new In-Editor Find Widget args",schema:{properties:{searchString:{type:"string"},replaceString:{type:"string"},isRegex:{type:"boolean"},matchWholeWord:{type:"boolean"},isCaseSensitive:{type:"boolean"},preserveCase:{type:"boolean"},findInSelection:{type:"boolean"}}}}]};class fI extends o.EditorAction{constructor(){super({id:$.StartFindWithArgs,label:a.localize2(1003,"Find with Arguments"),precondition:void 0,kbOpts:{kbExpr:null,primary:0,weight:100},metadata:pI})}async run(e,t,i){const n=fe.get(t);if(n){const s=i?{searchString:i.searchString,replaceString:i.replaceString,isReplaceRevealed:i.replaceString!==void 0,isRegex:i.isRegex,wholeWord:i.matchWholeWord,matchCase:i.isCaseSensitive,preserveCase:i.preserveCase}:{};await n.start({forceRevealReplace:!1,seedSearchStringFromSelection:n.getState().searchString.length===0&&t.getOption(50).seedSearchStringFromSelection!=="never"?"single":"none",seedSearchStringFromNonEmptySelection:t.getOption(50).seedSearchStringFromSelection==="selection",seedSearchStringFromGlobalClipboard:!0,shouldFocus:1,shouldAnimate:!0,updateSearchScope:i?.findInSelection||!1,loop:t.getOption(50).loop},s),n.setGlobalBufferTerm(n.getState().searchString)}}}class mI extends o.EditorAction{constructor(){super({id:$.StartFindWithSelection,label:a.localize2(1004,"Find with Selection"),precondition:void 0,kbOpts:{kbExpr:null,primary:0,mac:{primary:2083},weight:100}})}async run(e,t){const i=fe.get(t);i&&(await i.start({forceRevealReplace:!1,seedSearchStringFromSelection:"multiple",seedSearchStringFromNonEmptySelection:!1,seedSearchStringFromGlobalClipboard:!1,shouldFocus:0,shouldAnimate:!0,updateSearchScope:!1,loop:t.getOption(50).loop}),i.setGlobalBufferTerm(i.getState().searchString))}}async function E_(c,e){const t=fe.get(c);if(!t)return;const i=c.getOption(50).closeOnResult,n=t.getState().isRevealed,s=()=>{const r=t.editor.getSelection(),l=e?t.moveToNextMatch():t.moveToPrevMatch();let d=!1;if(l){const h=t.editor.getSelection();(!r&&h||r&&h&&!r.equalsSelection(h))&&(d=!0)}return d?(t.editor.pushUndoStop(),i&&n&&t.isFindInputFocused()&&t.closeFindWidget(),!0):!1};if(!s()&&(await t.start({forceRevealReplace:!1,seedSearchStringFromSelection:t.getState().searchString.length===0&&c.getOption(50).seedSearchStringFromSelection!=="never"?"single":"none",seedSearchStringFromNonEmptySelection:c.getOption(50).seedSearchStringFromSelection==="selection",seedSearchStringFromGlobalClipboard:!0,shouldFocus:0,shouldAnimate:!0,updateSearchScope:!1,loop:c.getOption(50).loop}),!s())){const r=t.getState();n&&r.matchesCount===0&&r.searchString&&o.alert(a.localize(996,"{0} found for '{1}'",bh,r.searchString))}}o.registerMultiEditorAction(new o.MultiEditorAction({id:$.NextMatchFindAction,label:a.localize2(1005,"Find Next"),precondition:void 0,kbOpts:[{kbExpr:o.EditorContextKeys.focus,primary:61,mac:{primary:2085,secondary:[61]},weight:100},{kbExpr:o.ContextKeyExpr.and(o.EditorContextKeys.focus,ha),primary:3,weight:100}]})).addImplementation(0,async(c,e,t)=>E_(e,!0)),o.registerMultiEditorAction(new o.MultiEditorAction({id:$.PreviousMatchFindAction,label:a.localize2(1006,"Find Previous"),precondition:void 0,kbOpts:[{kbExpr:o.EditorContextKeys.focus,primary:1085,mac:{primary:3109,secondary:[1085]},weight:100},{kbExpr:o.ContextKeyExpr.and(o.EditorContextKeys.focus,ha),primary:1027,weight:100}]})).addImplementation(0,async(c,e,t)=>E_(e,!1));class _I extends o.EditorAction{constructor(){super({id:$.GoToMatchFindAction,label:a.localize2(1007,"Go to Match..."),precondition:Et}),this._highlightDecorations=[]}run(e,t){const i=fe.get(t);if(!i)return;const n=i.getState().matchesCount;if(n<1){e.get(o.INotificationService).notify({severity:o.Severity.Warning,message:a.localize(997,"No matches. Try searching for something else.")});return}const s=e.get(o.IQuickInputService),r=new a.DisposableStore,l=r.add(s.createInputBox());l.placeholder=a.localize(998,"Type a number to go to a specific match (between 1 and {0})",n);const d=u=>{const g=parseInt(u);if(isNaN(g))return;const p=i.getState().matchesCount;if(g>0&&g<=p)return g-1;if(g<0&&g>=-p)return p+g},h=u=>{const g=d(u);if(typeof g=="number"){l.validationMessage=void 0,i.goToMatch(g);const p=i.getState().currentMatch;p&&this.addDecorations(t,p)}else l.validationMessage=a.localize(999,"Please type a number between 1 and {0}",i.getState().matchesCount),this.clearDecorations(t)};r.add(l.onDidChangeValue(u=>{h(u)})),r.add(l.onDidAccept(()=>{const u=d(l.value);typeof u=="number"?(i.goToMatch(u),l.hide()):l.validationMessage=a.localize(1e3,"Please type a number between 1 and {0}",i.getState().matchesCount)})),r.add(l.onDidHide(()=>{this.clearDecorations(t),r.dispose()})),l.show()}clearDecorations(e){e.changeDecorations(t=>{this._highlightDecorations=t.deltaDecorations(this._highlightDecorations,[])})}addDecorations(e,t){e.changeDecorations(i=>{this._highlightDecorations=i.deltaDecorations(this._highlightDecorations,[{range:t,options:{description:"find-match-quick-access-range-highlight",className:"rangeHighlight",isWholeLine:!0}},{range:t,options:{description:"find-match-quick-access-range-highlight-overview",overviewRuler:{color:o.themeColorFromId(o.overviewRulerRangeHighlight),position:a.OverviewRulerLane.Full}}}])})}}class L_ extends o.EditorAction{async run(e,t){const i=fe.get(t);if(!i)return;const n=du(t,"single",!1);n&&i.setSearchString(n),this._run(i)||(await i.start({forceRevealReplace:!1,seedSearchStringFromSelection:"none",seedSearchStringFromNonEmptySelection:!1,seedSearchStringFromGlobalClipboard:!1,shouldFocus:0,shouldAnimate:!0,updateSearchScope:!1,loop:t.getOption(50).loop}),this._run(i))}}class vI extends L_{constructor(){super({id:$.NextSelectionMatchFindAction,label:a.localize2(1008,"Find Next Selection"),precondition:void 0,kbOpts:{kbExpr:o.EditorContextKeys.focus,primary:2109,weight:100}})}_run(e){return e.moveToNextMatch()}}class bI extends L_{constructor(){super({id:$.PreviousSelectionMatchFindAction,label:a.localize2(1009,"Find Previous Selection"),precondition:void 0,kbOpts:{kbExpr:o.EditorContextKeys.focus,primary:3133,weight:100}})}_run(e){return e.moveToPrevMatch()}}o.registerMultiEditorAction(new o.MultiEditorAction({id:$.StartFindReplaceAction,label:a.localize2(1010,"Replace"),precondition:o.ContextKeyExpr.or(o.EditorContextKeys.focus,o.ContextKeyExpr.has("editorIsOpen")),kbOpts:{kbExpr:null,primary:2086,mac:{primary:2596},weight:100},menuOpts:{menuId:o.MenuId.MenubarEditMenu,group:"3_find",title:a.localize(1001,"&&Replace"),order:2}})).addImplementation(0,(c,e,t)=>{if(!e.hasModel()||e.getOption(104))return!1;const i=fe.get(e);if(!i)return!1;const n=e.getSelection(),s=i.isFindInputFocused(),r=!n.isEmpty()&&n.startLineNumber===n.endLineNumber&&e.getOption(50).seedSearchStringFromSelection!=="never"&&!s,l=s||r?2:1;return i.start({forceRevealReplace:!0,seedSearchStringFromSelection:r?"single":"none",seedSearchStringFromNonEmptySelection:e.getOption(50).seedSearchStringFromSelection==="selection",seedSearchStringFromGlobalClipboard:e.getOption(50).seedSearchStringFromSelection!=="never",shouldFocus:l,shouldAnimate:!0,updateSearchScope:!1,loop:e.getOption(50).loop})}),o.registerEditorContribution(fe.ID,hu,0),o.registerEditorAction(fI),o.registerEditorAction(mI),o.registerEditorAction(_I),o.registerEditorAction(vI),o.registerEditorAction(bI);const Ye=o.EditorCommand.bindToContribution(fe.get);o.registerEditorCommand(new Ye({id:$.CloseFindWidgetCommand,precondition:Et,handler:c=>c.closeFindWidget(),kbOpts:{weight:105,kbExpr:o.EditorContextKeys.focus,primary:9,secondary:[1033]}})),o.registerEditorCommand(new Ye({id:$.ToggleCaseSensitiveCommand,precondition:void 0,handler:c=>c.toggleCaseSensitive(),kbOpts:{weight:105,kbExpr:o.EditorContextKeys.focus,primary:ua.primary,mac:ua.mac,win:ua.win,linux:ua.linux}})),o.registerEditorCommand(new Ye({id:$.ToggleWholeWordCommand,precondition:void 0,handler:c=>c.toggleWholeWords(),kbOpts:{weight:105,kbExpr:o.EditorContextKeys.focus,primary:ga.primary,mac:ga.mac,win:ga.win,linux:ga.linux}})),o.registerEditorCommand(new Ye({id:$.ToggleRegexCommand,precondition:void 0,handler:c=>c.toggleRegex(),kbOpts:{weight:105,kbExpr:o.EditorContextKeys.focus,primary:pa.primary,mac:pa.mac,win:pa.win,linux:pa.linux}})),o.registerEditorCommand(new Ye({id:$.ToggleSearchScopeCommand,precondition:void 0,handler:c=>c.toggleSearchScope(),kbOpts:{weight:105,kbExpr:o.EditorContextKeys.focus,primary:fa.primary,mac:fa.mac,win:fa.win,linux:fa.linux}})),o.registerEditorCommand(new Ye({id:$.TogglePreserveCaseCommand,precondition:void 0,handler:c=>c.togglePreserveCase(),kbOpts:{weight:105,kbExpr:o.EditorContextKeys.focus,primary:ma.primary,mac:ma.mac,win:ma.win,linux:ma.linux}})),o.registerEditorCommand(new Ye({id:$.ReplaceOneAction,precondition:Et,handler:c=>c.replace(),kbOpts:{weight:105,kbExpr:o.EditorContextKeys.focus,primary:3094}})),o.registerEditorCommand(new Ye({id:$.ReplaceOneAction,precondition:Et,handler:c=>c.replace(),kbOpts:{weight:105,kbExpr:o.ContextKeyExpr.and(o.EditorContextKeys.focus,uh),primary:3}})),o.registerEditorCommand(new Ye({id:$.ReplaceAllAction,precondition:Et,handler:c=>c.replaceAll(),kbOpts:{weight:105,kbExpr:o.EditorContextKeys.focus,primary:2563}})),o.registerEditorCommand(new Ye({id:$.ReplaceAllAction,precondition:Et,handler:c=>c.replaceAll(),kbOpts:{weight:105,kbExpr:o.ContextKeyExpr.and(o.EditorContextKeys.focus,uh),primary:void 0,mac:{primary:2051}}})),o.registerEditorCommand(new Ye({id:$.SelectAllMatchesAction,precondition:Et,handler:c=>c.selectAllMatches(),kbOpts:{weight:105,kbExpr:o.EditorContextKeys.focus,primary:515}}));const CI={0:" ",1:"u",2:"r"},D_=65535,Qe=16777215,R_=4278190080;class uu{constructor(e){const t=Math.ceil(e/32);this._states=new Uint32Array(t)}get(e){const t=e/32|0,i=e%32;return(this._states[t]&1<<i)!==0}set(e,t){const i=e/32|0,n=e%32,s=this._states[i];t?this._states[i]=s|1<<n:this._states[i]=s&~(1<<n)}}class xe{constructor(e,t,i){if(e.length!==t.length||e.length>D_)throw new Error("invalid startIndexes or endIndexes size");this._startIndexes=e,this._endIndexes=t,this._collapseStates=new uu(e.length),this._userDefinedStates=new uu(e.length),this._recoveredStates=new uu(e.length),this._types=i,this._parentsComputed=!1}ensureParentIndices(){if(!this._parentsComputed){this._parentsComputed=!0;const e=[],t=(i,n)=>{const s=e[e.length-1];return this.getStartLineNumber(s)<=i&&this.getEndLineNumber(s)>=n};for(let i=0,n=this._startIndexes.length;i<n;i++){const s=this._startIndexes[i],r=this._endIndexes[i];if(s>Qe||r>Qe)throw new Error("startLineNumber or endLineNumber must not exceed "+Qe);for(;e.length>0&&!t(s,r);)e.pop();const l=e.length>0?e[e.length-1]:-1;e.push(i),this._startIndexes[i]=s+((l&255)<<24),this._endIndexes[i]=r+((l&65280)<<16)}}}get length(){return this._startIndexes.length}getStartLineNumber(e){return this._startIndexes[e]&Qe}getEndLineNumber(e){return this._endIndexes[e]&Qe}getType(e){return this._types?this._types[e]:void 0}hasTypes(){return!!this._types}isCollapsed(e){return this._collapseStates.get(e)}setCollapsed(e,t){this._collapseStates.set(e,t)}isUserDefined(e){return this._userDefinedStates.get(e)}setUserDefined(e,t){return this._userDefinedStates.set(e,t)}isRecovered(e){return this._recoveredStates.get(e)}setRecovered(e,t){return this._recoveredStates.set(e,t)}getSource(e){return this.isUserDefined(e)?1:this.isRecovered(e)?2:0}setSource(e,t){t===1?(this.setUserDefined(e,!0),this.setRecovered(e,!1)):t===2?(this.setUserDefined(e,!1),this.setRecovered(e,!0)):(this.setUserDefined(e,!1),this.setRecovered(e,!1))}setCollapsedAllOfType(e,t){let i=!1;if(this._types)for(let n=0;n<this._types.length;n++)this._types[n]===e&&(this.setCollapsed(n,t),i=!0);return i}toRegion(e){return new SI(this,e)}getParentIndex(e){this.ensureParentIndices();const t=((this._startIndexes[e]&R_)>>>24)+((this._endIndexes[e]&R_)>>>16);return t===D_?-1:t}contains(e,t){return this.getStartLineNumber(e)<=t&&this.getEndLineNumber(e)>=t}findIndex(e){let t=0,i=this._startIndexes.length;if(i===0)return-1;for(;t<i;){const n=Math.floor((t+i)/2);e<this.getStartLineNumber(n)?i=n:t=n+1}return t-1}findRange(e){let t=this.findIndex(e);if(t>=0){if(this.getEndLineNumber(t)>=e)return t;for(t=this.getParentIndex(t);t!==-1;){if(this.contains(t,e))return t;t=this.getParentIndex(t)}}return-1}toString(){const e=[];for(let t=0;t<this.length;t++)e[t]=`[${CI[this.getSource(t)]}${this.isCollapsed(t)?"+":"-"}] ${this.getStartLineNumber(t)}/${this.getEndLineNumber(t)}`;return e.join(", ")}toFoldRange(e){return{startLineNumber:this._startIndexes[e]&Qe,endLineNumber:this._endIndexes[e]&Qe,type:this._types?this._types[e]:void 0,isCollapsed:this.isCollapsed(e),source:this.getSource(e)}}static fromFoldRanges(e){const t=e.length,i=new Uint32Array(t),n=new Uint32Array(t);let s=[],r=!1;for(let d=0;d<t;d++){const h=e[d];i[d]=h.startLineNumber,n[d]=h.endLineNumber,s.push(h.type),h.type&&(r=!0)}r||(s=void 0);const l=new xe(i,n,s);for(let d=0;d<t;d++)e[d].isCollapsed&&l.setCollapsed(d,!0),l.setSource(d,e[d].source);return l}static sanitizeAndMerge(e,t,i,n){i=i??Number.MAX_VALUE;const s=(v,b)=>Array.isArray(v)?(C=>C<b?v[C]:void 0):(C=>C<b?v.toFoldRange(C):void 0),r=s(e,e.length),l=s(t,t.length);let d=0,h=0,u=r(0),g=l(0);const p=[];let f,m=0;const _=[];for(;u||g;){let v;if(g&&(!u||u.startLineNumber>=g.startLineNumber))u&&u.startLineNumber===g.startLineNumber?(g.source===1?v=g:(v=u,v.isCollapsed=g.isCollapsed&&(u.endLineNumber===g.endLineNumber||!n?.startsInside(u.startLineNumber+1,u.endLineNumber+1)),v.source=0),u=r(++d)):(v=g,g.isCollapsed&&g.source===0&&(v.source=2)),g=l(++h);else{let b=h,C=g;for(;;){if(!C||C.startLineNumber>u.endLineNumber){v=u;break}if(C.source===1&&C.endLineNumber>u.endLineNumber)break;C=l(++b)}u=r(++d)}if(v){for(;f&&f.endLineNumber<v.startLineNumber;)f=p.pop();v.endLineNumber>v.startLineNumber&&v.startLineNumber>m&&v.endLineNumber<=i&&(!f||f.endLineNumber>=v.endLineNumber)&&(_.push(v),m=v.startLineNumber,f&&p.push(f),f=v)}}return _}}class SI{constructor(e,t){this.ranges=e,this.index=t}get startLineNumber(){return this.ranges.getStartLineNumber(this.index)}get endLineNumber(){return this.ranges.getEndLineNumber(this.index)}get regionIndex(){return this.index}get parentIndex(){return this.ranges.getParentIndex(this.index)}get isCollapsed(){return this.ranges.isCollapsed(this.index)}containedBy(e){return e.startLineNumber<=this.startLineNumber&&e.endLineNumber>=this.endLineNumber}containsLine(e){return this.startLineNumber<=e&&e<=this.endLineNumber}}class yI{get regions(){return this._regions}get textModel(){return this._textModel}constructor(e,t){this._updateEventEmitter=new a.Emitter,this.onDidChange=this._updateEventEmitter.event,this._textModel=e,this._decorationProvider=t,this._regions=new xe(new Uint32Array(0),new Uint32Array(0)),this._editorDecorationIds=[]}toggleCollapseState(e){if(!e.length)return;e=e.sort((i,n)=>i.regionIndex-n.regionIndex);const t={};this._decorationProvider.changeDecorations(i=>{let n=0,s=-1,r=-1;const l=d=>{for(;n<d;){const h=this._regions.getEndLineNumber(n),u=this._regions.isCollapsed(n);if(h<=s){const g=this.regions.getSource(n)!==0;i.changeDecorationOptions(this._editorDecorationIds[n],this._decorationProvider.getDecorationOption(u,h<=r,g))}u&&h>r&&(r=h),n++}};for(const d of e){const h=d.regionIndex,u=this._editorDecorationIds[h];if(u&&!t[u]){t[u]=!0,l(h);const g=!this._regions.isCollapsed(h);this._regions.setCollapsed(h,g),s=Math.max(s,this._regions.getEndLineNumber(h))}}l(this._regions.length)}),this._updateEventEmitter.fire({model:this,collapseStateChanged:e})}removeManualRanges(e){const t=new Set;let i=!1;for(const r of e)if(a.Range.isEmpty(r)){let l=this._regions.findRange(r.startLineNumber);for(;l!==-1&&this._regions.getSource(l)===0;)l=this._regions.getParentIndex(l);l===-1?i=!0:t.add(l)}const n=new Array,s=r=>{for(const l of e)if(!a.Range.isEmpty(l)&&!(l.startLineNumber>r.endLineNumber||r.startLineNumber>l.endLineNumber))return!0;return!1};for(let r=0;r<this._regions.length;r++){const l=this._regions.toFoldRange(r);(l.source===0||!i&&!t.has(r)&&!s(l))&&n.push(l)}this.updatePost(xe.fromFoldRanges(n))}update(e,t){const i=this._currentFoldedOrManualRanges(t),n=xe.sanitizeAndMerge(e,i,this._textModel.getLineCount(),t);this.updatePost(xe.fromFoldRanges(n))}updatePost(e){const t=[];let i=-1;for(let n=0,s=e.length;n<s;n++){const r=e.getStartLineNumber(n),l=e.getEndLineNumber(n),d=e.isCollapsed(n),h=e.getSource(n)!==0,u={startLineNumber:r,startColumn:this._textModel.getLineMaxColumn(r),endLineNumber:l,endColumn:this._textModel.getLineMaxColumn(l)+1};t.push({range:u,options:this._decorationProvider.getDecorationOption(d,l<=i,h)}),d&&l>i&&(i=l)}this._decorationProvider.changeDecorations(n=>this._editorDecorationIds=n.deltaDecorations(this._editorDecorationIds,t)),this._regions=e,this._updateEventEmitter.fire({model:this})}_currentFoldedOrManualRanges(e){const t=[];for(let i=0,n=this._regions.length;i<n;i++){let s=this.regions.isCollapsed(i);const r=this.regions.getSource(i);if(s||r!==0){const l=this._regions.toFoldRange(i),d=this._textModel.getDecorationRange(this._editorDecorationIds[i]);d&&(s&&e?.startsInside(d.startLineNumber+1,d.endLineNumber)&&(s=!1),t.push({startLineNumber:d.startLineNumber,endLineNumber:d.endLineNumber,type:l.type,isCollapsed:s,source:r}))}}return t}getMemento(){const e=this._currentFoldedOrManualRanges(),t=[],i=this._textModel.getLineCount();for(let n=0,s=e.length;n<s;n++){const r=e[n];if(r.startLineNumber>=r.endLineNumber||r.startLineNumber<1||r.endLineNumber>i)continue;const l=this._getLinesChecksum(r.startLineNumber+1,r.endLineNumber);t.push({startLineNumber:r.startLineNumber,endLineNumber:r.endLineNumber,isCollapsed:r.isCollapsed,source:r.source,checksum:l})}return t.length>0?t:void 0}applyMemento(e){if(!Array.isArray(e))return;const t=[],i=this._textModel.getLineCount();for(const s of e){if(s.startLineNumber>=s.endLineNumber||s.startLineNumber<1||s.endLineNumber>i)continue;const r=this._getLinesChecksum(s.startLineNumber+1,s.endLineNumber);(!s.checksum||r===s.checksum)&&t.push({startLineNumber:s.startLineNumber,endLineNumber:s.endLineNumber,type:void 0,isCollapsed:s.isCollapsed??!0,source:s.source??0})}const n=xe.sanitizeAndMerge(this._regions,t,i);this.updatePost(xe.fromFoldRanges(n))}_getLinesChecksum(e,t){return a.hash(this._textModel.getLineContent(e)+this._textModel.getLineContent(t))%1e6}dispose(){this._decorationProvider.removeDecorations(this._editorDecorationIds),this._updateEventEmitter.dispose()}getAllRegionsAtLine(e,t){const i=[];if(this._regions){let n=this._regions.findRange(e),s=1;for(;n>=0;){const r=this._regions.toRegion(n);(!t||t(r,s))&&i.push(r),s++,n=r.parentIndex}}return i}getRegionAtLine(e){if(this._regions){const t=this._regions.findRange(e);if(t>=0)return this._regions.toRegion(t)}return null}getRegionsInside(e,t){const i=[],n=e?e.regionIndex+1:0,s=e?e.endLineNumber:Number.MAX_VALUE;if(t&&t.length===2){const r=[];for(let l=n,d=this._regions.length;l<d;l++){const h=this._regions.toRegion(l);if(this._regions.getStartLineNumber(l)<s){for(;r.length>0&&!h.containedBy(r[r.length-1]);)r.pop();r.push(h),t(h,r.length)&&i.push(h)}else break}}else for(let r=n,l=this._regions.length;r<l;r++){const d=this._regions.toRegion(r);if(this._regions.getStartLineNumber(r)<s)(!t||t(d))&&i.push(d);else break}return i}}function gu(c,e,t){const i=[];for(const n of t){const s=c.getRegionAtLine(n);if(s){const r=!s.isCollapsed;if(i.push(s),e>1){const l=c.getRegionsInside(s,(d,h)=>d.isCollapsed!==r&&h<e);i.push(...l)}}}c.toggleCollapseState(i)}function xs(c,e,t=Number.MAX_VALUE,i){const n=[];if(i&&i.length>0)for(const s of i){const r=c.getRegionAtLine(s);if(r&&(r.isCollapsed!==e&&n.push(r),t>1)){const l=c.getRegionsInside(r,(d,h)=>d.isCollapsed!==e&&h<t);n.push(...l)}}else{const s=c.getRegionsInside(null,(r,l)=>r.isCollapsed!==e&&l<t);n.push(...s)}c.toggleCollapseState(n)}function T_(c,e,t,i){const n=[];for(const s of i){const r=c.getAllRegionsAtLine(s,(l,d)=>l.isCollapsed!==e&&d<=t);n.push(...r)}c.toggleCollapseState(n)}function wI(c,e,t){const i=[];for(const n of t){const s=c.getAllRegionsAtLine(n,r=>r.isCollapsed!==e);s.length>0&&i.push(s[0])}c.toggleCollapseState(i)}function II(c,e,t,i){const n=(r,l)=>l===e&&r.isCollapsed!==t&&!i.some(d=>r.containsLine(d)),s=c.getRegionsInside(null,n);c.toggleCollapseState(s)}function N_(c,e,t){const i=[];for(const r of t){const l=c.getAllRegionsAtLine(r,void 0);l.length>0&&i.push(l[0])}const n=r=>i.every(l=>!l.containedBy(r)&&!r.containedBy(l))&&r.isCollapsed!==e,s=c.getRegionsInside(null,n);c.toggleCollapseState(s)}function pu(c,e,t){const i=c.textModel,n=c.regions,s=[];for(let r=n.length-1;r>=0;r--)if(t!==n.isCollapsed(r)){const l=n.getStartLineNumber(r);e.test(i.getLineContent(l))&&s.push(n.toRegion(r))}c.toggleCollapseState(s)}function fu(c,e,t){const i=c.regions,n=[];for(let s=i.length-1;s>=0;s--)t!==i.isCollapsed(s)&&e===i.getType(s)&&n.push(i.toRegion(s));c.toggleCollapseState(n)}function xI(c,e){let t=null;const i=e.getRegionAtLine(c);if(i!==null&&(t=i.startLineNumber,c===t)){const n=i.parentIndex;n!==-1?t=e.regions.getStartLineNumber(n):t=null}return t}function EI(c,e){let t=e.getRegionAtLine(c);if(t!==null&&t.startLineNumber===c){if(c!==t.startLineNumber)return t.startLineNumber;{const i=t.parentIndex;let n=0;for(i!==-1&&(n=e.regions.getStartLineNumber(t.parentIndex));t!==null;)if(t.regionIndex>0){if(t=e.regions.toRegion(t.regionIndex-1),t.startLineNumber<=n)return null;if(t.parentIndex===i)return t.startLineNumber}else return null}}else if(e.regions.length>0)for(t=e.regions.toRegion(e.regions.length-1);t!==null;){if(t.startLineNumber<c)return t.startLineNumber;t.regionIndex>0?t=e.regions.toRegion(t.regionIndex-1):t=null}return null}function LI(c,e){let t=e.getRegionAtLine(c);if(t!==null&&t.startLineNumber===c){const i=t.parentIndex;let n=0;if(i!==-1)n=e.regions.getEndLineNumber(t.parentIndex);else{if(e.regions.length===0)return null;n=e.regions.getEndLineNumber(e.regions.length-1)}for(;t!==null;)if(t.regionIndex<e.regions.length){if(t=e.regions.toRegion(t.regionIndex+1),t.startLineNumber>=n)return null;if(t.parentIndex===i)return t.startLineNumber}else return null}else if(e.regions.length>0)for(t=e.regions.toRegion(0);t!==null;){if(t.startLineNumber>c)return t.startLineNumber;t.regionIndex<e.regions.length?t=e.regions.toRegion(t.regionIndex+1):t=null}return null}class DI{get onDidChange(){return this._updateEventEmitter.event}get hiddenRanges(){return this._hiddenRanges}constructor(e){this._updateEventEmitter=new a.Emitter,this._hasLineChanges=!1,this._foldingModel=e,this._foldingModelListener=e.onDidChange(t=>this.updateHiddenRanges()),this._hiddenRanges=[],e.regions.length&&this.updateHiddenRanges()}notifyChangeModelContent(e){this._hiddenRanges.length&&!this._hasLineChanges&&(this._hasLineChanges=e.changes.some(t=>t.range.endLineNumber!==t.range.startLineNumber||o.countEOL(t.text)[0]!==0))}updateHiddenRanges(){let e=!1;const t=[];let i=0,n=0,s=Number.MAX_VALUE,r=-1;const l=this._foldingModel.regions;for(;i<l.length;i++){if(!l.isCollapsed(i))continue;const d=l.getStartLineNumber(i)+1,h=l.getEndLineNumber(i);s<=d&&h<=r||(!e&&n<this._hiddenRanges.length&&this._hiddenRanges[n].startLineNumber===d&&this._hiddenRanges[n].endLineNumber===h?(t.push(this._hiddenRanges[n]),n++):(e=!0,t.push(new a.Range(d,1,h,1))),s=d,r=h)}(this._hasLineChanges||e||n<this._hiddenRanges.length)&&this.applyHiddenRanges(t)}applyHiddenRanges(e){this._hiddenRanges=e,this._hasLineChanges=!1,this._updateEventEmitter.fire(e)}hasRanges(){return this._hiddenRanges.length>0}isHidden(e){return M_(this._hiddenRanges,e)!==null}adjustSelections(e){let t=!1;const i=this._foldingModel.textModel;let n=null;const s=r=>((!n||!RI(r,n))&&(n=M_(this._hiddenRanges,r)),n?n.startLineNumber-1:null);for(let r=0,l=e.length;r<l;r++){let d=e[r];const h=s(d.startLineNumber);h&&(d=d.setStartPosition(h,i.getLineMaxColumn(h)),t=!0);const u=s(d.endLineNumber);u&&(d=d.setEndPosition(u,i.getLineMaxColumn(u)),t=!0),e[r]=d}return t}dispose(){this.hiddenRanges.length>0&&(this._hiddenRanges=[],this._updateEventEmitter.fire(this._hiddenRanges)),this._foldingModelListener&&(this._foldingModelListener.dispose(),this._foldingModelListener=null),this._updateEventEmitter.dispose()}}function RI(c,e){return c>=e.startLineNumber&&c<=e.endLineNumber}function M_(c,e){const t=a.findFirstIdxMonotonousOrArrLen(c,i=>e<i.startLineNumber)-1;return t>=0&&c[t].endLineNumber>=e?c[t]:null}const TI=5e3,NI="indent";class mu{constructor(e,t,i){this.editorModel=e,this.languageConfigurationService=t,this.foldingRangesLimit=i,this.id=NI}dispose(){}compute(e){const t=this.languageConfigurationService.getLanguageConfiguration(this.editorModel.getLanguageId()).foldingRules,i=t&&!!t.offSide,n=t&&t.markers;return Promise.resolve(OI(this.editorModel,i,n,this.foldingRangesLimit))}}let MI=class{constructor(e){this._startIndexes=[],this._endIndexes=[],this._indentOccurrences=[],this._length=0,this._foldingRangesLimit=e}insertFirst(e,t,i){if(e>Qe||t>Qe)return;const n=this._length;this._startIndexes[n]=e,this._endIndexes[n]=t,this._length++,i<1e3&&(this._indentOccurrences[i]=(this._indentOccurrences[i]||0)+1)}toIndentRanges(e){const t=this._foldingRangesLimit.limit;if(this._length<=t){this._foldingRangesLimit.update(this._length,!1);const i=new Uint32Array(this._length),n=new Uint32Array(this._length);for(let s=this._length-1,r=0;s>=0;s--,r++)i[r]=this._startIndexes[s],n[r]=this._endIndexes[s];return new xe(i,n)}else{this._foldingRangesLimit.update(this._length,t);let i=0,n=this._indentOccurrences.length;for(let d=0;d<this._indentOccurrences.length;d++){const h=this._indentOccurrences[d];if(h){if(h+i>t){n=d;break}i+=h}}const s=e.getOptions().tabSize,r=new Uint32Array(t),l=new Uint32Array(t);for(let d=this._length-1,h=0;d>=0;d--){const u=this._startIndexes[d],g=e.getLineContent(u),p=o.computeIndentLevel(g,s);(p<n||p===n&&i++<t)&&(r[h]=u,l[h]=this._endIndexes[d],h++)}return new xe(r,l)}}};const PI={limit:TI,update:()=>{}};function OI(c,e,t,i=PI){const n=c.getOptions().tabSize,s=new MI(i);let r,l,d;t&&(t.start.flags===t.end.flags?r=new RegExp(`(${t.start.source})|(?:${t.end.source})`,t.start.flags):(l=t.start,d=t.end));const h=[],u=c.getLineCount()+1;h.push({indent:-1,endAbove:u,line:u});for(let g=c.getLineCount();g>0;g--){const p=c.getLineContent(g),f=o.computeIndentLevel(p,n);let m=h[h.length-1];if(f===-1){e&&(m.endAbove=g);continue}let _=!1,v=!1,b;if(r?(r.lastIndex=0,(b=r.exec(p))&&(_=!!b[1],v=!_)):(l&&(l.lastIndex=0,_=l.test(p)),!_&&d&&(d.lastIndex=0,v=d.test(p))),_||v)if(_){let C=h.length-1;for(;C>0&&h[C].indent!==-2;)C--;if(C>0){h.length=C+1,m=h[C],s.insertFirst(g,m.line,f),m.line=g,m.indent=f,m.endAbove=g;continue}}else{h.push({indent:-2,endAbove:g,line:g});continue}if(m.indent>f){do h.pop(),m=h[h.length-1];while(m.indent>f);const C=m.endAbove-1;C-g>=1&&s.insertFirst(g,C,f)}m.indent===f?m.endAbove=g:h.push({indent:f,endAbove:g,line:g})}return s.toIndentRanges(c)}const AI=o.registerColor("editor.foldBackground",{light:o.transparent(o.editorSelectionBackground,.3),dark:o.transparent(o.editorSelectionBackground,.3),hcDark:null,hcLight:null},a.localize(1060,"Background color behind folded ranges. The color must not be opaque so as not to hide underlying decorations."),!0);o.registerColor("editor.foldPlaceholderForeground",{light:"#808080",dark:"#808080",hcDark:null,hcLight:null},a.localize(1061,"Color of the collapsed text after the first line of a folded range.")),o.registerColor("editorGutter.foldingControlForeground",o.iconForeground,a.localize(1062,"Color of the folding control in the editor gutter."));const Ka=o.registerIcon("folding-expanded",a.Codicon.chevronDown,a.localize(1063,"Icon for expanded ranges in the editor glyph margin.")),ka=o.registerIcon("folding-collapsed",a.Codicon.chevronRight,a.localize(1064,"Icon for collapsed ranges in the editor glyph margin.")),P_=o.registerIcon("folding-manual-collapsed",ka,a.localize(1065,"Icon for manually collapsed ranges in the editor glyph margin.")),O_=o.registerIcon("folding-manual-expanded",Ka,a.localize(1066,"Icon for manually expanded ranges in the editor glyph margin.")),_u={color:o.themeColorFromId(AI),position:1},Es=a.localize(1067,"Click to expand the range."),Ua=a.localize(1068,"Click to collapse the range."),ee=class ee{constructor(e){this.editor=e,this.showFoldingControls="mouseover",this.showFoldingHighlights=!0}getDecorationOption(e,t,i){return t?ee.HIDDEN_RANGE_DECORATION:this.showFoldingControls==="never"?e?this.showFoldingHighlights?ee.NO_CONTROLS_COLLAPSED_HIGHLIGHTED_RANGE_DECORATION:ee.NO_CONTROLS_COLLAPSED_RANGE_DECORATION:ee.NO_CONTROLS_EXPANDED_RANGE_DECORATION:e?i?this.showFoldingHighlights?ee.MANUALLY_COLLAPSED_HIGHLIGHTED_VISUAL_DECORATION:ee.MANUALLY_COLLAPSED_VISUAL_DECORATION:this.showFoldingHighlights?ee.COLLAPSED_HIGHLIGHTED_VISUAL_DECORATION:ee.COLLAPSED_VISUAL_DECORATION:this.showFoldingControls==="mouseover"?i?ee.MANUALLY_EXPANDED_AUTO_HIDE_VISUAL_DECORATION:ee.EXPANDED_AUTO_HIDE_VISUAL_DECORATION:i?ee.MANUALLY_EXPANDED_VISUAL_DECORATION:ee.EXPANDED_VISUAL_DECORATION}changeDecorations(e){return this.editor.changeDecorations(e)}removeDecorations(e){this.editor.removeDecorations(e)}};ee.COLLAPSED_VISUAL_DECORATION=o.ModelDecorationOptions.register({description:"folding-collapsed-visual-decoration",stickiness:0,afterContentClassName:"inline-folded",isWholeLine:!0,linesDecorationsTooltip:Es,firstLineDecorationClassName:o.ThemeIcon.asClassName(ka)}),ee.COLLAPSED_HIGHLIGHTED_VISUAL_DECORATION=o.ModelDecorationOptions.register({description:"folding-collapsed-highlighted-visual-decoration",stickiness:0,afterContentClassName:"inline-folded",className:"folded-background",minimap:_u,isWholeLine:!0,linesDecorationsTooltip:Es,firstLineDecorationClassName:o.ThemeIcon.asClassName(ka)}),ee.MANUALLY_COLLAPSED_VISUAL_DECORATION=o.ModelDecorationOptions.register({description:"folding-manually-collapsed-visual-decoration",stickiness:0,afterContentClassName:"inline-folded",isWholeLine:!0,linesDecorationsTooltip:Es,firstLineDecorationClassName:o.ThemeIcon.asClassName(P_)}),ee.MANUALLY_COLLAPSED_HIGHLIGHTED_VISUAL_DECORATION=o.ModelDecorationOptions.register({description:"folding-manually-collapsed-highlighted-visual-decoration",stickiness:0,afterContentClassName:"inline-folded",className:"folded-background",minimap:_u,isWholeLine:!0,linesDecorationsTooltip:Es,firstLineDecorationClassName:o.ThemeIcon.asClassName(P_)}),ee.NO_CONTROLS_COLLAPSED_RANGE_DECORATION=o.ModelDecorationOptions.register({description:"folding-no-controls-range-decoration",stickiness:0,afterContentClassName:"inline-folded",isWholeLine:!0,linesDecorationsTooltip:Es}),ee.NO_CONTROLS_COLLAPSED_HIGHLIGHTED_RANGE_DECORATION=o.ModelDecorationOptions.register({description:"folding-no-controls-range-decoration",stickiness:0,afterContentClassName:"inline-folded",className:"folded-background",minimap:_u,isWholeLine:!0,linesDecorationsTooltip:Es}),ee.EXPANDED_VISUAL_DECORATION=o.ModelDecorationOptions.register({description:"folding-expanded-visual-decoration",stickiness:1,isWholeLine:!0,firstLineDecorationClassName:"alwaysShowFoldIcons "+o.ThemeIcon.asClassName(Ka),linesDecorationsTooltip:Ua}),ee.EXPANDED_AUTO_HIDE_VISUAL_DECORATION=o.ModelDecorationOptions.register({description:"folding-expanded-auto-hide-visual-decoration",stickiness:1,isWholeLine:!0,firstLineDecorationClassName:o.ThemeIcon.asClassName(Ka),linesDecorationsTooltip:Ua}),ee.MANUALLY_EXPANDED_VISUAL_DECORATION=o.ModelDecorationOptions.register({description:"folding-manually-expanded-visual-decoration",stickiness:0,isWholeLine:!0,firstLineDecorationClassName:"alwaysShowFoldIcons "+o.ThemeIcon.asClassName(O_),linesDecorationsTooltip:Ua}),ee.MANUALLY_EXPANDED_AUTO_HIDE_VISUAL_DECORATION=o.ModelDecorationOptions.register({description:"folding-manually-expanded-auto-hide-visual-decoration",stickiness:0,isWholeLine:!0,firstLineDecorationClassName:o.ThemeIcon.asClassName(O_),linesDecorationsTooltip:Ua}),ee.NO_CONTROLS_EXPANDED_RANGE_DECORATION=o.ModelDecorationOptions.register({description:"folding-no-controls-range-decoration",stickiness:0,isWholeLine:!0}),ee.HIDDEN_RANGE_DECORATION=o.ModelDecorationOptions.register({description:"folding-hidden-range-decoration",stickiness:1});let vu=ee;const FI={},zI="syntax";class bu{constructor(e,t,i,n,s){this.editorModel=e,this.providers=t,this.handleFoldingRangesChange=i,this.foldingRangesLimit=n,this.fallbackRangeProvider=s,this.id=zI,this.disposables=new a.DisposableStore,s&&this.disposables.add(s);for(const r of t)typeof r.onDidChange=="function"&&this.disposables.add(r.onDidChange(i))}compute(e){return VI(this.providers,this.editorModel,e).then(t=>this.editorModel.isDisposed()?null:t?KI(t,this.foldingRangesLimit):this.fallbackRangeProvider?.compute(e)??null)}dispose(){this.disposables.dispose()}}function VI(c,e,t){let i=null;const n=c.map((s,r)=>Promise.resolve(s.provideFoldingRanges(e,FI,t)).then(l=>{if(!t.isCancellationRequested&&Array.isArray(l)){Array.isArray(i)||(i=[]);const d=e.getLineCount();for(const h of l)h.start>0&&h.end>h.start&&h.end<=d&&i.push({start:h.start,end:h.end,rank:r,kind:h.kind})}},a.onUnexpectedExternalError));return Promise.all(n).then(s=>i)}class BI{constructor(e){this._startIndexes=[],this._endIndexes=[],this._nestingLevels=[],this._nestingLevelCounts=[],this._types=[],this._length=0,this._foldingRangesLimit=e}add(e,t,i,n){if(e>Qe||t>Qe)return;const s=this._length;this._startIndexes[s]=e,this._endIndexes[s]=t,this._nestingLevels[s]=n,this._types[s]=i,this._length++,n<30&&(this._nestingLevelCounts[n]=(this._nestingLevelCounts[n]||0)+1)}toIndentRanges(){const e=this._foldingRangesLimit.limit;if(this._length<=e){this._foldingRangesLimit.update(this._length,!1);const t=new Uint32Array(this._length),i=new Uint32Array(this._length);for(let n=0;n<this._length;n++)t[n]=this._startIndexes[n],i[n]=this._endIndexes[n];return new xe(t,i,this._types)}else{this._foldingRangesLimit.update(this._length,e);let t=0,i=this._nestingLevelCounts.length;for(let l=0;l<this._nestingLevelCounts.length;l++){const d=this._nestingLevelCounts[l];if(d){if(d+t>e){i=l;break}t+=d}}const n=new Uint32Array(e),s=new Uint32Array(e),r=[];for(let l=0,d=0;l<this._length;l++){const h=this._nestingLevels[l];(h<i||h===i&&t++<e)&&(n[d]=this._startIndexes[l],s[d]=this._endIndexes[l],r[d]=this._types[l],d++)}return new xe(n,s,r)}}}function KI(c,e){const t=c.sort((r,l)=>{let d=r.start-l.start;return d===0&&(d=r.rank-l.rank),d}),i=new BI(e);let n;const s=[];for(const r of t)if(!n)n=r,i.add(r.start,r.end,r.kind&&r.kind.value,s.length);else if(r.start>n.start)if(r.end<=n.end)s.push(n),n=r,i.add(r.start,r.end,r.kind&&r.kind.value,s.length);else{if(r.start>n.end){do n=s.pop();while(n&&r.start>n.end);n&&s.push(n),n=r}i.add(r.start,r.end,r.kind&&r.kind.value,s.length)}return i.toIndentRanges()}var kI=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Uo=function(c,e){return function(t,i){e(t,i,c)}},$o;const ie=new o.RawContextKey("foldingEnabled",!1);let Xt=(zn=class extends a.Disposable{static get(e){return e.getContribution($o.ID)}static getFoldingRangeProviders(e,t){const i=e.foldingRangeProvider.ordered(t);return $o._foldingRangeSelector?.(i,t)??i}constructor(e,t,i,n,s,r){super(),this.contextKeyService=t,this.languageConfigurationService=i,this.languageFeaturesService=r,this.localToDispose=this._register(new a.DisposableStore),this.editor=e,this._foldingLimitReporter=this._register(new A_(e));const l=this.editor.getOptions();this._isEnabled=l.get(52),this._useFoldingProviders=l.get(53)!=="indentation",this._unfoldOnClickAfterEndOfLine=l.get(57),this._restoringViewState=!1,this._currentModelHasFoldedImports=!1,this._foldingImportsByDefault=l.get(55),this.updateDebounceInfo=s.for(r.foldingRangeProvider,"Folding",{min:200}),this.foldingModel=null,this.hiddenRangeModel=null,this.rangeProvider=null,this.foldingRegionPromise=null,this.foldingModelPromise=null,this.updateScheduler=null,this.cursorChangedScheduler=null,this.mouseDownInfo=null,this.foldingDecorationProvider=new vu(e),this.foldingDecorationProvider.showFoldingControls=l.get(126),this.foldingDecorationProvider.showFoldingHighlights=l.get(54),this.foldingEnabled=ie.bindTo(this.contextKeyService),this.foldingEnabled.set(this._isEnabled),this._register(this.editor.onDidChangeModel(()=>this.onModelChanged())),this._register(this.editor.onDidChangeConfiguration(d=>{if(d.hasChanged(52)&&(this._isEnabled=this.editor.getOptions().get(52),this.foldingEnabled.set(this._isEnabled),this.onModelChanged()),d.hasChanged(56)&&this.onModelChanged(),d.hasChanged(126)||d.hasChanged(54)){const h=this.editor.getOptions();this.foldingDecorationProvider.showFoldingControls=h.get(126),this.foldingDecorationProvider.showFoldingHighlights=h.get(54),this.triggerFoldingModelChanged()}d.hasChanged(53)&&(this._useFoldingProviders=this.editor.getOptions().get(53)!=="indentation",this.onFoldingStrategyChanged()),d.hasChanged(57)&&(this._unfoldOnClickAfterEndOfLine=this.editor.getOptions().get(57)),d.hasChanged(55)&&(this._foldingImportsByDefault=this.editor.getOptions().get(55))})),this.onModelChanged()}saveViewState(){const e=this.editor.getModel();if(!e||!this._isEnabled||e.isTooLargeForTokenization())return{};if(this.foldingModel){const t=this.foldingModel.getMemento(),i=this.rangeProvider?this.rangeProvider.id:void 0;return{collapsedRegions:t,lineCount:e.getLineCount(),provider:i,foldedImports:this._currentModelHasFoldedImports}}}restoreViewState(e){const t=this.editor.getModel();if(!(!t||!this._isEnabled||t.isTooLargeForTokenization()||!this.hiddenRangeModel)&&e&&(this._currentModelHasFoldedImports=!!e.foldedImports,e.collapsedRegions&&e.collapsedRegions.length>0&&this.foldingModel)){this._restoringViewState=!0;try{this.foldingModel.applyMemento(e.collapsedRegions)}finally{this._restoringViewState=!1}}}onModelChanged(){this.localToDispose.clear();const e=this.editor.getModel();!this._isEnabled||!e||e.isTooLargeForTokenization()||(this._currentModelHasFoldedImports=!1,this.foldingModel=new yI(e,this.foldingDecorationProvider),this.localToDispose.add(this.foldingModel),this.hiddenRangeModel=new DI(this.foldingModel),this.localToDispose.add(this.hiddenRangeModel),this.localToDispose.add(this.hiddenRangeModel.onDidChange(t=>this.onHiddenRangesChanges(t))),this.updateScheduler=new a.Delayer(this.updateDebounceInfo.get(e)),this.localToDispose.add(this.updateScheduler),this.cursorChangedScheduler=new a.RunOnceScheduler(()=>this.revealCursor(),200),this.localToDispose.add(this.cursorChangedScheduler),this.localToDispose.add(this.languageFeaturesService.foldingRangeProvider.onDidChange(()=>this.onFoldingStrategyChanged())),this.localToDispose.add(this.editor.onDidChangeModelLanguageConfiguration(()=>this.onFoldingStrategyChanged())),this.localToDispose.add(this.editor.onDidChangeModelContent(t=>this.onDidChangeModelContent(t))),this.localToDispose.add(this.editor.onDidChangeCursorPosition(()=>this.onCursorPositionChanged())),this.localToDispose.add(this.editor.onMouseDown(t=>this.onEditorMouseDown(t))),this.localToDispose.add(this.editor.onMouseUp(t=>this.onEditorMouseUp(t))),this.localToDispose.add({dispose:()=>{this.foldingRegionPromise&&(this.foldingRegionPromise.cancel(),this.foldingRegionPromise=null),this.updateScheduler?.cancel(),this.updateScheduler=null,this.foldingModel=null,this.foldingModelPromise=null,this.hiddenRangeModel=null,this.cursorChangedScheduler=null,this.rangeProvider?.dispose(),this.rangeProvider=null}}),this.triggerFoldingModelChanged())}onFoldingStrategyChanged(){this.rangeProvider?.dispose(),this.rangeProvider=null,this.triggerFoldingModelChanged()}getRangeProvider(e){if(this.rangeProvider)return this.rangeProvider;const t=new mu(e,this.languageConfigurationService,this._foldingLimitReporter);if(this.rangeProvider=t,this._useFoldingProviders&&this.foldingModel){const i=$o.getFoldingRangeProviders(this.languageFeaturesService,e);i.length>0&&(this.rangeProvider=new bu(e,i,()=>this.triggerFoldingModelChanged(),this._foldingLimitReporter,t))}return this.rangeProvider}getFoldingModel(){return this.foldingModelPromise}onDidChangeModelContent(e){this.hiddenRangeModel?.notifyChangeModelContent(e),this.triggerFoldingModelChanged()}triggerFoldingModelChanged(){this.updateScheduler&&(this.foldingRegionPromise&&(this.foldingRegionPromise.cancel(),this.foldingRegionPromise=null),this.foldingModelPromise=this.updateScheduler.trigger(()=>{const e=this.foldingModel;if(!e)return null;const t=new a.StopWatch,i=this.getRangeProvider(e.textModel),n=this.foldingRegionPromise=a.createCancelablePromise(s=>i.compute(s));return n.then(s=>{if(s&&n===this.foldingRegionPromise){let r;if(this._foldingImportsByDefault&&!this._currentModelHasFoldedImports){const h=s.setCollapsedAllOfType(a.FoldingRangeKind.Imports.value,!0);h&&(r=o.StableEditorScrollState.capture(this.editor),this._currentModelHasFoldedImports=h)}const l=this.editor.getSelections();e.update(s,UI(l)),r?.restore(this.editor);const d=this.updateDebounceInfo.update(e.textModel,t.elapsed());this.updateScheduler&&(this.updateScheduler.defaultDelay=d)}return e})}).then(void 0,e=>(a.onUnexpectedError(e),null)))}onHiddenRangesChanges(e){if(this.hiddenRangeModel&&e.length&&!this._restoringViewState){const t=this.editor.getSelections();t&&this.hiddenRangeModel.adjustSelections(t)&&this.editor.setSelections(t)}this.editor.setHiddenAreas(e,this)}onCursorPositionChanged(){this.hiddenRangeModel&&this.hiddenRangeModel.hasRanges()&&this.cursorChangedScheduler.schedule()}revealCursor(){const e=this.getFoldingModel();e&&e.then(t=>{if(t){const i=this.editor.getSelections();if(i&&i.length>0){const n=[];for(const s of i){const r=s.selectionStartLineNumber;this.hiddenRangeModel&&this.hiddenRangeModel.isHidden(r)&&n.push(...t.getAllRegionsAtLine(r,l=>l.isCollapsed&&r>l.startLineNumber))}n.length&&(t.toggleCollapseState(n),this.reveal(i[0].getPosition()))}}}).then(void 0,a.onUnexpectedError)}onEditorMouseDown(e){if(this.mouseDownInfo=null,!this.hiddenRangeModel||!e.target||!e.target.range||!e.event.leftButton&&!e.event.middleButton)return;const t=e.target.range;let i=!1;switch(e.target.type){case 4:{const n=e.target.detail,s=e.target.element.offsetLeft;if(n.offsetX-s<4)return;i=!0;break}case 7:{if(this._unfoldOnClickAfterEndOfLine&&this.hiddenRangeModel.hasRanges()&&!e.target.detail.isAfterLines)break;return}case 6:{if(this.hiddenRangeModel.hasRanges()){const n=this.editor.getModel();if(n&&t.startColumn===n.getLineMaxColumn(t.startLineNumber))break}return}default:return}this.mouseDownInfo={lineNumber:t.startLineNumber,iconClicked:i}}onEditorMouseUp(e){const t=this.foldingModel;if(!t||!this.mouseDownInfo||!e.target)return;const i=this.mouseDownInfo.lineNumber,n=this.mouseDownInfo.iconClicked,s=e.target.range;if(!s||s.startLineNumber!==i)return;if(n){if(e.target.type!==4)return}else{const l=this.editor.getModel();if(!l||s.startColumn!==l.getLineMaxColumn(i))return}const r=t.getRegionAtLine(i);if(r&&r.startLineNumber===i){const l=r.isCollapsed;if(n||l){const d=e.event.altKey;let h=[];if(d){const u=p=>!p.containedBy(r)&&!r.containedBy(p),g=t.getRegionsInside(null,u);for(const p of g)p.isCollapsed&&h.push(p);h.length===0&&(h=g)}else{const u=e.event.middleButton||e.event.shiftKey;if(u)for(const g of t.getRegionsInside(r))g.isCollapsed===l&&h.push(g);(l||!u||h.length===0)&&h.push(r)}t.toggleCollapseState(h),this.reveal({lineNumber:i,column:1})}}}reveal(e){this.editor.revealPositionInCenterIfOutsideViewport(e,0)}},$o=zn,zn.ID="editor.contrib.folding",zn);Xt=$o=kI([Uo(1,o.IContextKeyService),Uo(2,o.ILanguageConfigurationService),Uo(3,o.INotificationService),Uo(4,o.ILanguageFeatureDebounceService),Uo(5,o.ILanguageFeaturesService)],Xt);class A_ extends a.Disposable{constructor(e){super(),this.editor=e,this._onDidChange=this._register(new a.Emitter),this._computed=0,this._limited=!1}get limit(){return this.editor.getOptions().get(56)}update(e,t){(e!==this._computed||t!==this._limited)&&(this._computed=e,this._limited=t,this._onDidChange.fire())}}class se extends o.EditorAction{runEditorCommand(e,t,i){const n=e.get(o.ILanguageConfigurationService),s=Xt.get(t);if(!s)return;const r=s.getFoldingModel();if(r)return this.reportTelemetry(e,t),r.then(l=>{if(l){this.invoke(s,l,t,i,n);const d=t.getSelection();d&&s.reveal(d.getStartPosition())}})}getSelectedLines(e){const t=e.getSelections();return t?t.map(i=>i.startLineNumber):[]}getLineNumbers(e,t){return e&&e.selectionLines?e.selectionLines.map(i=>i+1):this.getSelectedLines(t)}run(e,t){}}function UI(c){return!c||c.length===0?{startsInside:()=>!1}:{startsInside(e,t){for(const i of c){const n=i.startLineNumber;if(n>=e&&n<=t)return!0}return!1}}}function F_(c){if(!a.isUndefined(c)){if(!a.isObject(c))return!1;const e=c;if(!a.isUndefined(e.levels)&&!a.isNumber(e.levels)||!a.isUndefined(e.direction)&&!a.isString(e.direction)||!a.isUndefined(e.selectionLines)&&(!Array.isArray(e.selectionLines)||!e.selectionLines.every(a.isNumber)))return!1}return!0}class $I extends se{constructor(){super({id:"editor.unfold",label:a.localize2(1040,"Unfold"),precondition:ie,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:3166,mac:{primary:2654},weight:100},metadata:{description:"Unfold the content in the editor",args:[{name:"Unfold editor argument",description:`Property-value pairs that can be passed through this argument:
14
+ * 'levels': Number of levels to unfold. If not set, defaults to 1.
15
+ * 'direction': If 'up', unfold given number of levels up otherwise unfolds down.
16
+ * 'selectionLines': Array of the start lines (0-based) of the editor selections to apply the unfold action to. If not set, the active selection(s) will be used.
17
+ `,constraint:F_,schema:{type:"object",properties:{levels:{type:"number",default:1},direction:{type:"string",enum:["up","down"],default:"down"},selectionLines:{type:"array",items:{type:"number"}}}}}]}})}invoke(e,t,i,n){const s=n&&n.levels||1,r=this.getLineNumbers(n,i);n&&n.direction==="up"?T_(t,!1,s,r):xs(t,!1,s,r)}}class jI extends se{constructor(){super({id:"editor.unfoldRecursively",label:a.localize2(1041,"Unfold Recursively"),precondition:ie,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:a.KeyChord(2089,2142),weight:100}})}invoke(e,t,i,n){xs(t,!1,Number.MAX_VALUE,this.getSelectedLines(i))}}class qI extends se{constructor(){super({id:"editor.fold",label:a.localize2(1042,"Fold"),precondition:ie,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:3164,mac:{primary:2652},weight:100},metadata:{description:"Fold the content in the editor",args:[{name:"Fold editor argument",description:`Property-value pairs that can be passed through this argument:
18
+ * 'levels': Number of levels to fold.
19
+ * 'direction': If 'up', folds given number of levels up otherwise folds down.
20
+ * 'selectionLines': Array of the start lines (0-based) of the editor selections to apply the fold action to. If not set, the active selection(s) will be used.
21
+ If no levels or direction is set, folds the region at the locations or if already collapsed, the first uncollapsed parent instead.
22
+ `,constraint:F_,schema:{type:"object",properties:{levels:{type:"number"},direction:{type:"string",enum:["up","down"]},selectionLines:{type:"array",items:{type:"number"}}}}}]}})}invoke(e,t,i,n){const s=this.getLineNumbers(n,i),r=n&&n.levels,l=n&&n.direction;typeof r!="number"&&typeof l!="string"?wI(t,!0,s):l==="up"?T_(t,!0,r||1,s):xs(t,!0,r||1,s)}}class GI extends se{constructor(){super({id:"editor.toggleFold",label:a.localize2(1043,"Toggle Fold"),precondition:ie,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:a.KeyChord(2089,2090),weight:100}})}invoke(e,t,i){const n=this.getSelectedLines(i);gu(t,1,n)}}class ZI extends se{constructor(){super({id:"editor.foldRecursively",label:a.localize2(1044,"Fold Recursively"),precondition:ie,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:a.KeyChord(2089,2140),weight:100}})}invoke(e,t,i){const n=this.getSelectedLines(i);xs(t,!0,Number.MAX_VALUE,n)}}class XI extends se{constructor(){super({id:"editor.toggleFoldRecursively",label:a.localize2(1045,"Toggle Fold Recursively"),precondition:ie,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:a.KeyChord(2089,3114),weight:100}})}invoke(e,t,i){const n=this.getSelectedLines(i);gu(t,Number.MAX_VALUE,n)}}class YI extends se{constructor(){super({id:"editor.foldAllBlockComments",label:a.localize2(1046,"Fold All Block Comments"),precondition:ie,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:a.KeyChord(2089,2138),weight:100}})}invoke(e,t,i,n,s){if(t.regions.hasTypes())fu(t,a.FoldingRangeKind.Comment.value,!0);else{const r=i.getModel();if(!r)return;const l=s.getLanguageConfiguration(r.getLanguageId()).comments;if(l&&l.blockCommentStartToken){const d=new RegExp("^\\s*"+a.escapeRegExpCharacters(l.blockCommentStartToken));pu(t,d,!0)}}}}class QI extends se{constructor(){super({id:"editor.foldAllMarkerRegions",label:a.localize2(1047,"Fold All Regions"),precondition:ie,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:a.KeyChord(2089,2077),weight:100}})}invoke(e,t,i,n,s){if(t.regions.hasTypes())fu(t,a.FoldingRangeKind.Region.value,!0);else{const r=i.getModel();if(!r)return;const l=s.getLanguageConfiguration(r.getLanguageId()).foldingRules;if(l&&l.markers&&l.markers.start){const d=new RegExp(l.markers.start);pu(t,d,!0)}}}}class JI extends se{constructor(){super({id:"editor.unfoldAllMarkerRegions",label:a.localize2(1048,"Unfold All Regions"),precondition:ie,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:a.KeyChord(2089,2078),weight:100}})}invoke(e,t,i,n,s){if(t.regions.hasTypes())fu(t,a.FoldingRangeKind.Region.value,!1);else{const r=i.getModel();if(!r)return;const l=s.getLanguageConfiguration(r.getLanguageId()).foldingRules;if(l&&l.markers&&l.markers.start){const d=new RegExp(l.markers.start);pu(t,d,!1)}}}}class WI extends se{constructor(){super({id:"editor.foldAllExcept",label:a.localize2(1049,"Fold All Except Selected"),precondition:ie,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:a.KeyChord(2089,2136),weight:100}})}invoke(e,t,i){const n=this.getSelectedLines(i);N_(t,!0,n)}}class HI extends se{constructor(){super({id:"editor.unfoldAllExcept",label:a.localize2(1050,"Unfold All Except Selected"),precondition:ie,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:a.KeyChord(2089,2134),weight:100}})}invoke(e,t,i){const n=this.getSelectedLines(i);N_(t,!1,n)}}class ex extends se{constructor(){super({id:"editor.foldAll",label:a.localize2(1051,"Fold All"),precondition:ie,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:a.KeyChord(2089,2069),weight:100}})}invoke(e,t,i){xs(t,!0)}}class tx extends se{constructor(){super({id:"editor.unfoldAll",label:a.localize2(1052,"Unfold All"),precondition:ie,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:a.KeyChord(2089,2088),weight:100}})}invoke(e,t,i){xs(t,!1)}}const to=class to extends se{getFoldingLevel(){return parseInt(this.id.substr(to.ID_PREFIX.length))}invoke(e,t,i){II(t,this.getFoldingLevel(),!0,this.getSelectedLines(i))}};to.ID_PREFIX="editor.foldLevel",to.ID=e=>to.ID_PREFIX+e;let $a=to;class ix extends se{constructor(){super({id:"editor.gotoParentFold",label:a.localize2(1053,"Go to Parent Fold"),precondition:ie,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,weight:100}})}invoke(e,t,i){const n=this.getSelectedLines(i);if(n.length>0){const s=xI(n[0],t);s!==null&&i.setSelection({startLineNumber:s,startColumn:1,endLineNumber:s,endColumn:1})}}}class nx extends se{constructor(){super({id:"editor.gotoPreviousFold",label:a.localize2(1054,"Go to Previous Folding Range"),precondition:ie,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,weight:100}})}invoke(e,t,i){const n=this.getSelectedLines(i);if(n.length>0){const s=EI(n[0],t);s!==null&&i.setSelection({startLineNumber:s,startColumn:1,endLineNumber:s,endColumn:1})}}}class sx extends se{constructor(){super({id:"editor.gotoNextFold",label:a.localize2(1055,"Go to Next Folding Range"),precondition:ie,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,weight:100}})}invoke(e,t,i){const n=this.getSelectedLines(i);if(n.length>0){const s=LI(n[0],t);s!==null&&i.setSelection({startLineNumber:s,startColumn:1,endLineNumber:s,endColumn:1})}}}class ox extends se{constructor(){super({id:"editor.createFoldingRangeFromSelection",label:a.localize2(1056,"Create Folding Range from Selection"),precondition:ie,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:a.KeyChord(2089,2135),weight:100}})}invoke(e,t,i){const n=[],s=i.getSelections();if(s){for(const r of s){let l=r.endLineNumber;r.endColumn===1&&--l,l>r.startLineNumber&&(n.push({startLineNumber:r.startLineNumber,endLineNumber:l,type:void 0,isCollapsed:!0,source:1}),i.setSelection({startLineNumber:r.startLineNumber,startColumn:1,endLineNumber:r.startLineNumber,endColumn:1}))}if(n.length>0){n.sort((l,d)=>l.startLineNumber-d.startLineNumber);const r=xe.sanitizeAndMerge(t.regions,n,i.getModel()?.getLineCount());t.updatePost(xe.fromFoldRanges(r))}}}}class rx extends se{constructor(){super({id:"editor.removeManualFoldingRanges",label:a.localize2(1057,"Remove Manual Folding Ranges"),precondition:ie,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:a.KeyChord(2089,2137),weight:100}})}invoke(e,t,i){const n=i.getSelections();n&&(t.removeManualRanges(n),e.triggerFoldingModelChanged())}}class ax extends se{constructor(){super({id:"editor.toggleImportFold",label:a.localize2(1058,"Toggle Import Fold"),precondition:ie,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,weight:100}})}async invoke(e,t){const i=[],n=t.regions;for(let s=n.length-1;s>=0;s--)n.getType(s)===a.FoldingRangeKind.Imports.value&&i.push(n.toRegion(s));t.toggleCollapseState(i),e.triggerFoldingModelChanged()}}o.registerEditorContribution(Xt.ID,Xt,0),o.registerEditorAction($I),o.registerEditorAction(jI),o.registerEditorAction(qI),o.registerEditorAction(ZI),o.registerEditorAction(XI),o.registerEditorAction(ex),o.registerEditorAction(tx),o.registerEditorAction(YI),o.registerEditorAction(QI),o.registerEditorAction(JI),o.registerEditorAction(WI),o.registerEditorAction(HI),o.registerEditorAction(GI),o.registerEditorAction(ix),o.registerEditorAction(nx),o.registerEditorAction(sx),o.registerEditorAction(ox),o.registerEditorAction(rx),o.registerEditorAction(ax);for(let c=1;c<=7;c++)o.registerInstantiatedEditorAction(new $a({id:$a.ID(c),label:a.localize2(1059,"Fold Level {0}",c),precondition:ie,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:a.KeyChord(2089,2048|21+c),weight:100}}));o.CommandsRegistry.registerCommand("_executeFoldingRangeProvider",async function(c,...e){const[t]=e;if(!(t instanceof a.URI))throw a.illegalArgument();const i=c.get(o.ILanguageFeaturesService),n=c.get(o.IModelService).getModel(t);if(!n)throw a.illegalArgument();const s=c.get(o.IConfigurationService);if(!s.getValue("editor.folding",{resource:t}))return[];const r=c.get(o.ILanguageConfigurationService),l=s.getValue("editor.foldingStrategy",{resource:t}),d={get limit(){return s.getValue("editor.foldingMaximumRegions",{resource:t})},update:(f,m)=>{}},h=new mu(n,r,d);let u=h;if(l!=="indentation"){const f=Xt.getFoldingRangeProviders(i,n);f.length&&(u=new bu(n,f,()=>{},d,h))}const g=await u.compute(a.CancellationToken.None),p=[];try{if(g)for(let f=0;f<g.length;f++){const m=g.getType(f);p.push({start:g.getStartLineNumber(f),end:g.getEndLineNumber(f),kind:m?a.FoldingRangeKind.fromValue(m):void 0})}return p}finally{u.dispose()}});class lx extends o.EditorAction{constructor(){super({id:"editor.action.fontZoomIn",label:a.localize2(1069,"Increase Editor Font Size"),precondition:void 0})}run(e,t){o.EditorZoom.setZoomLevel(o.EditorZoom.getZoomLevel()+1)}}class cx extends o.EditorAction{constructor(){super({id:"editor.action.fontZoomOut",label:a.localize2(1070,"Decrease Editor Font Size"),precondition:void 0})}run(e,t){o.EditorZoom.setZoomLevel(o.EditorZoom.getZoomLevel()-1)}}class dx extends o.EditorAction{constructor(){super({id:"editor.action.fontZoomReset",label:a.localize2(1071,"Reset Editor Font Size"),precondition:void 0})}run(e,t){o.EditorZoom.setZoomLevel(0)}}o.registerEditorAction(lx),o.registerEditorAction(cx),o.registerEditorAction(dx);var z_=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},jo=function(c,e){return function(t,i){e(t,i,c)}};let ja=(io=class{constructor(e,t,i,n){this._editor=e,this._languageFeaturesService=t,this._workerService=i,this._accessibilitySignalService=n,this._disposables=new a.DisposableStore,this._sessionDisposables=new a.DisposableStore,this._disposables.add(t.onTypeFormattingEditProvider.onDidChange(this._update,this)),this._disposables.add(e.onDidChangeModel(()=>this._update())),this._disposables.add(e.onDidChangeModelLanguage(()=>this._update())),this._disposables.add(e.onDidChangeConfiguration(s=>{s.hasChanged(65)&&this._update()})),this._update()}dispose(){this._disposables.dispose(),this._sessionDisposables.dispose()}_update(){if(this._sessionDisposables.clear(),!this._editor.getOption(65)||!this._editor.hasModel())return;const e=this._editor.getModel(),[t]=this._languageFeaturesService.onTypeFormattingEditProvider.ordered(e);if(!t||!t.autoFormatTriggerCharacters)return;const i=new a.CharacterSet;for(const n of t.autoFormatTriggerCharacters)i.add(n.charCodeAt(0));this._sessionDisposables.add(this._editor.onDidType(n=>{const s=n.charCodeAt(n.length-1);i.has(s)&&this._trigger(String.fromCharCode(s))}))}_trigger(e){if(!this._editor.hasModel()||this._editor.getSelections().length>1||!this._editor.getSelection().isEmpty())return;const t=this._editor.getModel(),i=this._editor.getPosition(),n=new a.CancellationTokenSource,s=this._editor.onDidChangeModelContent(r=>{if(r.isFlush){n.cancel(),s.dispose();return}for(let l=0,d=r.changes.length;l<d;l++)if(r.changes[l].range.endLineNumber<=i.lineNumber){n.cancel(),s.dispose();return}});o.getOnTypeFormattingEdits(this._workerService,this._languageFeaturesService,t,i,e,t.getFormattingOptions(),n.token).then(r=>{n.token.isCancellationRequested||a.isNonEmptyArray(r)&&(this._accessibilitySignalService.playSignal(o.AccessibilitySignal.format,{userGesture:!1}),o.FormattingEdit.execute(this._editor,r,!0))}).finally(()=>{s.dispose()})}},io.ID="editor.contrib.autoFormat",io);ja=z_([jo(1,o.ILanguageFeaturesService),jo(2,o.IEditorWorkerService),jo(3,o.IAccessibilitySignalService)],ja);let qa=(no=class{constructor(e,t,i){this.editor=e,this._languageFeaturesService=t,this._instantiationService=i,this._callOnDispose=new a.DisposableStore,this._callOnModel=new a.DisposableStore,this._callOnDispose.add(e.onDidChangeConfiguration(()=>this._update())),this._callOnDispose.add(e.onDidChangeModel(()=>this._update())),this._callOnDispose.add(e.onDidChangeModelLanguage(()=>this._update())),this._callOnDispose.add(t.documentRangeFormattingEditProvider.onDidChange(this._update,this))}dispose(){this._callOnDispose.dispose(),this._callOnModel.dispose()}_update(){this._callOnModel.clear(),this.editor.getOption(64)&&this.editor.hasModel()&&this._languageFeaturesService.documentRangeFormattingEditProvider.has(this.editor.getModel())&&this._callOnModel.add(this.editor.onDidPaste(({range:e})=>this._trigger(e)))}_trigger(e){this.editor.hasModel()&&(this.editor.getSelections().length>1||this._instantiationService.invokeFunction(o.formatDocumentRangesWithSelectedProvider,this.editor,e,2,o.Progress.None,a.CancellationToken.None,!1).catch(a.onUnexpectedError))}},no.ID="editor.contrib.formatOnPaste",no);qa=z_([jo(1,o.ILanguageFeaturesService),jo(2,o.IInstantiationService)],qa);class hx extends o.EditorAction{constructor(){super({id:"editor.action.formatDocument",label:a.localize2(1072,"Format Document"),precondition:o.ContextKeyExpr.and(o.EditorContextKeys.notInCompositeEditor,o.EditorContextKeys.writable,o.EditorContextKeys.hasDocumentFormattingProvider),kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:1572,linux:{primary:3111},weight:100},contextMenuOpts:{group:"1_modification",order:1.3}})}async run(e,t){if(t.hasModel()){const i=e.get(o.IInstantiationService);await e.get(o.IEditorProgressService).showWhile(i.invokeFunction(o.formatDocumentWithSelectedProvider,t,1,o.Progress.None,a.CancellationToken.None,!0),250)}}}class ux extends o.EditorAction{constructor(){super({id:"editor.action.formatSelection",label:a.localize2(1073,"Format Selection"),precondition:o.ContextKeyExpr.and(o.EditorContextKeys.writable,o.EditorContextKeys.hasDocumentSelectionFormattingProvider),kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:a.KeyChord(2089,2084),weight:100},contextMenuOpts:{when:o.EditorContextKeys.hasNonEmptySelection,group:"1_modification",order:1.31}})}async run(e,t){if(!t.hasModel())return;const i=e.get(o.IInstantiationService),n=t.getModel(),s=t.getSelections().map(l=>l.isEmpty()?new a.Range(l.startLineNumber,1,l.startLineNumber,n.getLineMaxColumn(l.startLineNumber)):l);await e.get(o.IEditorProgressService).showWhile(i.invokeFunction(o.formatDocumentRangesWithSelectedProvider,t,s,1,o.Progress.None,a.CancellationToken.None,!0),250)}}o.registerEditorContribution(ja.ID,ja,2),o.registerEditorContribution(qa.ID,qa,2),o.registerEditorAction(hx),o.registerEditorAction(ux),o.CommandsRegistry.registerCommand("editor.action.format",async c=>{const e=c.get(o.ICodeEditorService).getFocusedCodeEditor();if(!e||!e.hasModel())return;const t=c.get(o.ICommandService);e.getSelection().isEmpty()?await t.executeCommand("editor.action.formatDocument"):await t.executeCommand("editor.action.formatSelection")});var gx=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Cu=function(c,e){return function(t,i){e(t,i,c)}};class Ls{remove(){this.parent?.children.delete(this.id)}static findId(e,t){let i;typeof e=="string"?i=`${t.id}/${e}`:(i=`${t.id}/${e.name}`,t.children.get(i)!==void 0&&(i=`${t.id}/${e.name}_${e.range.startLineNumber}_${e.range.startColumn}`));let n=i;for(let s=0;t.children.get(n)!==void 0;s++)n=`${i}_${s}`;return n}static empty(e){return e.children.size===0}}class Su extends Ls{constructor(e,t,i){super(),this.id=e,this.parent=t,this.symbol=i,this.children=new Map}}class V_ extends Ls{constructor(e,t,i,n){super(),this.id=e,this.parent=t,this.label=i,this.order=n,this.children=new Map}}class Nt extends Ls{static create(e,t,i){const n=new a.CancellationTokenSource(i),s=new Nt(t.uri),r=e.ordered(t),l=r.map((h,u)=>{const g=Ls.findId(`provider_${u}`,s),p=new V_(g,s,h.displayName??"Unknown Outline Provider",u);return Promise.resolve(h.provideDocumentSymbols(t,n.token)).then(f=>{for(const m of f||[])Nt._makeOutlineElement(m,p);return p},f=>(a.onUnexpectedExternalError(f),p)).then(f=>{Ls.empty(f)?f.remove():s._groups.set(g,f)})}),d=e.onDidChange(()=>{const h=e.ordered(t);a.equals(h,r)||n.cancel()});return Promise.all(l).then(()=>n.token.isCancellationRequested&&!i.isCancellationRequested?Nt.create(e,t,i):s._compact()).finally(()=>{n.dispose(),d.dispose(),n.dispose()})}static _makeOutlineElement(e,t){const i=Ls.findId(e,t),n=new Su(i,t,e);if(e.children)for(const s of e.children)Nt._makeOutlineElement(s,n);t.children.set(n.id,n)}constructor(e){super(),this.uri=e,this.id="root",this.parent=void 0,this._groups=new Map,this.children=new Map,this.id="root",this.parent=void 0}_compact(){let e=0;for(const[t,i]of this._groups)i.children.size===0?this._groups.delete(t):e+=1;if(e!==1)this.children=this._groups;else{const t=a.Iterable.first(this._groups.values());for(const[,i]of t.children)i.parent=this,this.children.set(i.id,i)}return this}getTopLevelSymbols(){const e=[];for(const t of this.children.values())t instanceof Su?e.push(t.symbol):e.push(...a.Iterable.map(t.children.values(),i=>i.symbol));return e.sort((t,i)=>a.Range.compareRangesUsingStarts(t.range,i.range))}asListOfDocumentSymbols(){const e=this.getTopLevelSymbols(),t=[];return Nt._flattenDocumentSymbols(t,e,""),t.sort((i,n)=>a.Position.compare(a.Range.getStartPosition(i.range),a.Range.getStartPosition(n.range))||a.Position.compare(a.Range.getEndPosition(n.range),a.Range.getEndPosition(i.range)))}static _flattenDocumentSymbols(e,t,i){for(const n of t)e.push({kind:n.kind,tags:n.tags,name:n.name,detail:n.detail,containerName:n.containerName||i,range:n.range,selectionRange:n.selectionRange,children:void 0}),n.children&&Nt._flattenDocumentSymbols(e,n.children,n.name)}}const qo=o.createDecorator("IOutlineModelService");let yu=class{constructor(e,t,i){this._languageFeaturesService=e,this._disposables=new a.DisposableStore,this._cache=new a.LRUCache(15,.7),this._debounceInformation=t.for(e.documentSymbolProvider,"DocumentSymbols",{min:350}),this._disposables.add(i.onModelRemoved(n=>{this._cache.delete(n.id)}))}dispose(){this._disposables.dispose()}async getOrCreate(e,t){const i=this._languageFeaturesService.documentSymbolProvider,n=i.ordered(e);let s=this._cache.get(e.id);if(!s||s.versionId!==e.getVersionId()||!a.equals(s.provider,n)){const l=new a.CancellationTokenSource;s={versionId:e.getVersionId(),provider:n,promiseCnt:0,source:l,promise:Nt.create(i,e,l.token),model:void 0},this._cache.set(e.id,s);const d=Date.now();s.promise.then(h=>{s.model=h,this._debounceInformation.update(e,Date.now()-d)}).catch(h=>{this._cache.delete(e.id)})}if(s.model)return s.model;s.promiseCnt+=1;const r=t.onCancellationRequested(()=>{--s.promiseCnt===0&&(s.source.cancel(),this._cache.delete(e.id))});try{return await s.promise}finally{r.dispose()}}};yu=gx([Cu(0,o.ILanguageFeaturesService),Cu(1,o.ILanguageFeatureDebounceService),Cu(2,o.IModelService)],yu),o.registerSingleton(qo,yu,1),o.CommandsRegistry.registerCommand("_executeDocumentSymbolProvider",async function(c,...e){const[t]=e;a.assertType(a.URI.isUri(t));const i=c.get(qo),s=await c.get(o.ITextModelService).createModelReference(t);try{return(await i.getOrCreate(s.object.textEditorModel,a.CancellationToken.None)).getTopLevelSymbols()}finally{s.dispose()}});const Ga=new class{constructor(){this._implementations=[]}register(e){return this._implementations.push(e),{dispose:()=>{const t=this._implementations.indexOf(e);t!==-1&&this._implementations.splice(t,1)}}}getImplementations(){return this._implementations}};var px=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},fx=function(c,e){return function(t,i){e(t,i,c)}};function mx(c){return c instanceof B_?c._instance:c}let B_=class{constructor(e){this.instantiationService=e}init(...e){}};function _x(c){return c.get()}let K_=class extends B_{constructor(e,t){super(t),this.init(e)}};K_=px([fx(1,o.IInstantiationService)],K_);class Ds{validateOrThrow(e){const t=this.validate(e);if(t.error)throw new Error(t.error.message);return t.content}}class Za extends Ds{constructor(e){super(),this.type=e}validate(e){return typeof e!==this.type?{content:void 0,error:{message:`Expected ${this.type}, but got ${typeof e}`}}:{content:e,error:void 0}}getJSONSchema(){return{type:this.type}}}const vx=new Za("string");function bx(){return vx}new Za("number");const Cx=new Za("boolean");function k_(){return Cx}new Za("object");class Sx extends Ds{validate(e){return{content:e,error:void 0}}getJSONSchema(){return{}}}function yx(){return new Sx}class U_ extends Ds{validate(e){return e!==void 0?{content:void 0,error:{message:`Expected undefined, but got ${typeof e}`}}:{content:void 0,error:void 0}}getJSONSchema(){return{}}}function wx(){return new U_}class wu{constructor(e){this.validator=e}}function Xa(c){return new wu(c)}class Ix extends Ds{constructor(e){super(),this.properties=e}validate(e){if(typeof e!="object"||e===null)return{content:void 0,error:{message:"Expected object"}};const t={};for(const i in this.properties){const n=this.properties[i],s=e[i],r=n instanceof wu,l=r?n.validator:n;if(r&&s===void 0)continue;const{content:d,error:h}=l.validate(s);if(h)return{content:void 0,error:{message:`Error in property '${i}': ${h.message}`}};t[i]=d}return{content:t,error:void 0}}getJSONSchema(){const e=[],t={};for(const[n,s]of Object.entries(this.properties)){const r=s instanceof wu,l=r?s.validator:s;t[n]=l.getJSONSchema(),r||e.push(n)}return{type:"object",properties:t,...e.length>0?{required:e}:{}}}}function xx(c){return new Ix(c)}class Ex extends Ds{constructor(e){super(),this.validators=e}validate(e){let t;for(const i of this.validators){const{content:n,error:s}=i.validate(e);if(!s)return{content:n,error:void 0};t=s}return{content:void 0,error:t}}getJSONSchema(){return{oneOf:a.mapFilter(this.validators,e=>{if(!(e instanceof U_))return e.getJSONSchema()})}}}function Lx(...c){return new Ex(c)}class Dx extends Ds{constructor(e,t){super(),this._ref=e,this._validator=t}validate(e){return this._validator.validate(e)}getJSONSchema(){return{$ref:this._ref}}}function Rx(c,e){return new Dx(c,e)}const N={Visible:gh,HasFocusedSuggestion:new o.RawContextKey("suggestWidgetHasFocusedSuggestion",!1,a.localize(1525,"Whether any suggestion is focused")),DetailsVisible:new o.RawContextKey("suggestWidgetDetailsVisible",!1,a.localize(1526,"Whether suggestion details are visible")),DetailsFocused:new o.RawContextKey("suggestWidgetDetailsFocused",!1,a.localize(1527,"Whether the details pane of the suggest widget has focus")),MultipleSuggestions:new o.RawContextKey("suggestWidgetMultipleSuggestions",!1,a.localize(1528,"Whether there are multiple suggestions to pick from")),MakesTextEdit:new o.RawContextKey("suggestionMakesTextEdit",!0,a.localize(1529,"Whether inserting the current suggestion yields in a change or has everything already been typed")),AcceptSuggestionsOnEnter:new o.RawContextKey("acceptSuggestionOnEnter",!0,a.localize(1530,"Whether suggestions are inserted when pressing Enter")),HasInsertAndReplaceRange:new o.RawContextKey("suggestionHasInsertAndReplaceRange",!1,a.localize(1531,"Whether the current suggestion has insert and replace behaviour")),InsertMode:new o.RawContextKey("suggestionInsertMode",void 0,{type:"string",description:a.localize(1532,"Whether the default behaviour is to insert or replace")}),CanResolve:new o.RawContextKey("suggestionCanResolve",!1,a.localize(1533,"Whether the current suggestion supports to resolve further details"))},Mt=new o.MenuId("suggestWidgetStatusBar");class Tx{constructor(e,t,i,n){this.position=e,this.completion=t,this.container=i,this.provider=n,this.isInvalid=!1,this.score=o.FuzzyScore.Default,this.distance=0,this.textLabel=typeof t.label=="string"?t.label:t.label?.label,this.labelLow=this.textLabel.toLowerCase(),this.isInvalid=!this.textLabel,this.sortTextLow=t.sortText&&t.sortText.toLowerCase(),this.filterTextLow=t.filterText&&t.filterText.toLowerCase(),this.extensionId=t.extensionId,a.Range.isIRange(t.range)?(this.editStart=new a.Position(t.range.startLineNumber,t.range.startColumn),this.editInsertEnd=new a.Position(t.range.endLineNumber,t.range.endColumn),this.editReplaceEnd=new a.Position(t.range.endLineNumber,t.range.endColumn),this.isInvalid=this.isInvalid||a.Range.spansMultipleLines(t.range)||t.range.startLineNumber!==e.lineNumber):(this.editStart=new a.Position(t.range.insert.startLineNumber,t.range.insert.startColumn),this.editInsertEnd=new a.Position(t.range.insert.endLineNumber,t.range.insert.endColumn),this.editReplaceEnd=new a.Position(t.range.replace.endLineNumber,t.range.replace.endColumn),this.isInvalid=this.isInvalid||a.Range.spansMultipleLines(t.range.insert)||a.Range.spansMultipleLines(t.range.replace)||t.range.insert.startLineNumber!==e.lineNumber||t.range.replace.startLineNumber!==e.lineNumber||t.range.insert.startColumn!==t.range.replace.startColumn),typeof n.resolveCompletionItem!="function"&&(this._resolveCache=Promise.resolve(),this._resolveDuration=0)}get isResolved(){return this._resolveDuration!==void 0}get resolveDuration(){return this._resolveDuration!==void 0?this._resolveDuration:-1}async resolve(e){if(!this._resolveCache){const t=e.onCancellationRequested(()=>{this._resolveCache=void 0,this._resolveDuration=void 0}),i=new a.StopWatch(!0);this._resolveCache=Promise.resolve(this.provider.resolveCompletionItem(this.completion,e)).then(n=>{Object.assign(this.completion,n),this._resolveDuration=i.elapsed()},n=>{a.isCancellationError(n)&&(this._resolveCache=void 0,this._resolveDuration=void 0)}).finally(()=>{t.dispose()})}return this._resolveCache}}const Mc=class Mc{constructor(e=2,t=new Set,i=new Set,n=new Map,s=!0){this.snippetSortOrder=e,this.kindFilter=t,this.providerFilter=i,this.providerItemsToReuse=n,this.showDeprecated=s}};Mc.default=new Mc;let Go=Mc;class Nx{constructor(e,t,i,n){this.items=e,this.needsClipboard=t,this.durations=i,this.disposable=n}}async function Iu(c,e,t,i=Go.default,n={triggerKind:0},s=a.CancellationToken.None){const r=new a.StopWatch;t=t.clone();const l=e.getWordAtPosition(t),d=l?new a.Range(t.lineNumber,l.startColumn,t.lineNumber,l.endColumn):a.Range.fromPositions(t),h={replace:d,insert:d.setEndPosition(t.lineNumber,t.column)},u=[],g=new a.DisposableStore,p=[];let f=!1;const m=(v,b,C)=>{let y=!1;if(!b)return y;for(const I of b.suggestions)if(!i.kindFilter.has(I.kind)){if(!i.showDeprecated&&I?.tags?.includes(1))continue;I.range||(I.range=h),I.sortText||(I.sortText=typeof I.label=="string"?I.label:I.label.label),!f&&I.insertTextRules&&I.insertTextRules&4&&(f=Ui.guessNeedsClipboard(I.insertText)),u.push(new Tx(t,I,b,v)),y=!0}return a.isDisposable(b)&&g.add(b),p.push({providerName:v._debugDisplayName??"unknown_provider",elapsedProvider:b.duration??-1,elapsedOverall:C.elapsed()}),y},_=(async()=>{})();for(const v of c.orderedGroups(e)){let b=!1;if(await Promise.all(v.map(async C=>{if(i.providerItemsToReuse.has(C)){const y=i.providerItemsToReuse.get(C);y.forEach(I=>u.push(I)),b=b||y.length>0;return}if(!(i.providerFilter.size>0&&!i.providerFilter.has(C)))try{const y=new a.StopWatch,I=await C.provideCompletionItems(e,t,n,s);b=m(C,I,y)||b}catch(y){a.onUnexpectedExternalError(y)}})),b||s.isCancellationRequested)break}return await _,s.isCancellationRequested?(g.dispose(),Promise.reject(new a.CancellationError)):new Nx(u.sort(Ox(i.snippetSortOrder)),f,{entries:p,elapsed:r.elapsed()},g)}function xu(c,e){if(c.sortTextLow&&e.sortTextLow){if(c.sortTextLow<e.sortTextLow)return-1;if(c.sortTextLow>e.sortTextLow)return 1}return c.textLabel<e.textLabel?-1:c.textLabel>e.textLabel?1:c.completion.kind-e.completion.kind}function Mx(c,e){if(c.completion.kind!==e.completion.kind){if(c.completion.kind===28)return-1;if(e.completion.kind===28)return 1}return xu(c,e)}function Px(c,e){if(c.completion.kind!==e.completion.kind){if(c.completion.kind===28)return 1;if(e.completion.kind===28)return-1}return xu(c,e)}const Ya=new Map;Ya.set(0,Mx),Ya.set(2,Px),Ya.set(1,xu);function Ox(c){return Ya.get(c)}o.CommandsRegistry.registerCommand("_executeCompletionItemProvider",async(c,...e)=>{const[t,i,n,s]=e;a.assertType(a.URI.isUri(t)),a.assertType(a.Position.isIPosition(i)),a.assertType(typeof n=="string"||!n),a.assertType(typeof s=="number"||!s);const{completionProvider:r}=c.get(o.ILanguageFeaturesService),l=await c.get(o.ITextModelService).createModelReference(t);try{const d={incomplete:!1,suggestions:[]},h=[],u=l.object.textEditorModel.validatePosition(i),g=await Iu(r,l.object.textEditorModel,u,void 0,{triggerCharacter:n??void 0,triggerKind:n?1:0});for(const p of g.items)h.length<(s??0)&&h.push(p.resolve(a.CancellationToken.None)),d.incomplete=d.incomplete||p.container.incomplete,d.suggestions.push(p.completion);try{return await Promise.all(h),d}finally{setTimeout(()=>g.disposable.dispose(),100)}}finally{l.dispose()}});function Ax(c,e){c.getContribution("editor.contrib.suggestController")?.triggerSuggest(new Set().add(e),void 0,!0)}class Rs{static isAllOff(e){return e.other==="off"&&e.comments==="off"&&e.strings==="off"}static isAllOn(e){return e.other==="on"&&e.comments==="on"&&e.strings==="on"}static valueFor(e,t){switch(t){case 1:return e.comments;case 2:return e.strings;default:return e.other}}}const we=class we{};we.inlineSuggestionVisible=new o.RawContextKey("inlineSuggestionVisible",!1,a.localize(1249,"Whether an inline suggestion is visible")),we.inlineSuggestionAlternativeActionVisible=new o.RawContextKey("inlineSuggestionAlternativeActionVisible",!1,a.localize(1250,"Whether an alternative action for the inline suggestion is visible.")),we.inlineSuggestionHasIndentation=new o.RawContextKey("inlineSuggestionHasIndentation",!1,a.localize(1251,"Whether the inline suggestion starts with whitespace")),we.inlineSuggestionHasIndentationLessThanTabSize=new o.RawContextKey("inlineSuggestionHasIndentationLessThanTabSize",!0,a.localize(1252,"Whether the inline suggestion starts with whitespace that is less than what would be inserted by tab")),we.suppressSuggestions=new o.RawContextKey("inlineSuggestionSuppressSuggestions",void 0,a.localize(1253,"Whether suggestions should be suppressed for the current suggestion")),we.cursorBeforeGhostText=new o.RawContextKey("cursorBeforeGhostText",!1,a.localize(1254,"Whether the cursor is at ghost text")),we.cursorInIndentation=new o.RawContextKey("cursorInIndentation",!1,a.localize(1255,"Whether the cursor is in indentation")),we.hasSelection=new o.RawContextKey("editor.hasSelection",!1,a.localize(1256,"Whether the editor has a selection")),we.cursorAtInlineEdit=new o.RawContextKey("cursorAtInlineEdit",!1,a.localize(1257,"Whether the cursor is at an inline edit")),we.inlineEditVisible=new o.RawContextKey("inlineEditIsVisible",!1,a.localize(1258,"Whether an inline edit is visible")),we.tabShouldJumpToInlineEdit=new o.RawContextKey("tabShouldJumpToInlineEdit",!1,a.localize(1259,"Whether tab should jump to an inline edit.")),we.tabShouldAcceptInlineEdit=new o.RawContextKey("tabShouldAcceptInlineEdit",!1,a.localize(1260,"Whether tab should accept the inline edit.")),we.inInlineEditsPreviewEditor=new o.RawContextKey("inInlineEditsPreviewEditor",!0,a.localize(1261,"Whether the current code editor is showing an inline edits preview"));let B=we;var $_=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Qa=function(c,e){return function(t,i){e(t,i,c)}};class j_{constructor(e,t,i){this.marker=e,this.index=t,this.total=i}}let Eu=class{constructor(e,t,i){this._markerService=t,this._configService=i,this._onDidChange=new a.Emitter,this.onDidChange=this._onDidChange.event,this._dispoables=new a.DisposableStore,this._markers=[],this._nextIdx=-1,a.URI.isUri(e)?this._resourceFilter=l=>l.toString()===e.toString():e&&(this._resourceFilter=e);const n=this._configService.getValue("problems.sortOrder"),s=(l,d)=>{let h=a.compare(l.resource.toString(),d.resource.toString());return h===0&&(n==="position"?h=a.Range.compareRangesUsingStarts(l,d)||o.MarkerSeverity$1.compare(l.severity,d.severity):h=o.MarkerSeverity$1.compare(l.severity,d.severity)||a.Range.compareRangesUsingStarts(l,d)),h},r=()=>{let l=this._markerService.read({resource:a.URI.isUri(e)?e:void 0,severities:o.MarkerSeverity$1.Error|o.MarkerSeverity$1.Warning|o.MarkerSeverity$1.Info});return typeof e=="function"&&(l=l.filter(d=>this._resourceFilter(d.resource))),l.sort(s),a.equals(l,this._markers,(d,h)=>d.resource.toString()===h.resource.toString()&&d.startLineNumber===h.startLineNumber&&d.startColumn===h.startColumn&&d.endLineNumber===h.endLineNumber&&d.endColumn===h.endColumn&&d.severity===h.severity&&d.message===h.message)?!1:(this._markers=l,!0)};r(),this._dispoables.add(t.onMarkerChanged(l=>{(!this._resourceFilter||l.some(d=>this._resourceFilter(d)))&&r()&&(this._nextIdx=-1,this._onDidChange.fire())}))}dispose(){this._dispoables.dispose(),this._onDidChange.dispose()}matches(e){return!this._resourceFilter&&!e?!0:!this._resourceFilter||!e?!1:this._resourceFilter(e)}get selected(){const e=this._markers[this._nextIdx];return e&&new j_(e,this._nextIdx+1,this._markers.length)}_initIdx(e,t,i){let n=this._markers.findIndex(s=>o.isEqual(s.resource,e.uri));if(n<0)n=a.binarySearch2(this._markers.length,s=>a.compare(this._markers[s].resource.toString(),e.uri.toString())),n<0&&(n=~n),i?this._nextIdx=n:this._nextIdx=(this._markers.length+n-1)%this._markers.length;else{let s=!1,r=!1;for(let l=n;l<this._markers.length;l++){let d=a.Range.lift(this._markers[l]);if(d.isEmpty()){const h=e.getWordAtPosition(d.getStartPosition());h&&(d=new a.Range(d.startLineNumber,h.startColumn,d.startLineNumber,h.endColumn))}if(t&&(d.containsPosition(t)||t.isBeforeOrEqual(d.getStartPosition()))){this._nextIdx=l,s=!0,r=!d.containsPosition(t);break}if(this._markers[l].resource.toString()!==e.uri.toString())break}s?r&&!i&&(this._nextIdx-=1):this._nextIdx=i?0:this._markers.length-1}this._nextIdx<0&&(this._nextIdx=this._markers.length-1)}resetIndex(){this._nextIdx=-1}move(e,t,i){if(this._markers.length===0)return!1;const n=this._nextIdx;return this._nextIdx===-1?this._initIdx(t,i,e):e?this._nextIdx=(this._nextIdx+1)%this._markers.length:e||(this._nextIdx=(this._nextIdx-1+this._markers.length)%this._markers.length),n!==this._nextIdx}find(e,t){let i=this._markers.findIndex(n=>n.resource.toString()===e.toString());if(!(i<0)){for(;i<this._markers.length;i++)if(a.Range.containsPosition(this._markers[i],t))return new j_(this._markers[i],i+1,this._markers.length)}}};Eu=$_([Qa(1,o.IMarkerService),Qa(2,o.IConfigurationService)],Eu);const q_=o.createDecorator("IMarkerNavigationService");let Lu=class{constructor(e,t){this._markerService=e,this._configService=t,this._provider=new a.LinkedList}getMarkerList(e){for(const t of this._provider){const i=t.getMarkerList(e);if(i)return i}return new Eu(e,this._markerService,this._configService)}};Lu=$_([Qa(0,o.IMarkerService),Qa(1,o.IConfigurationService)],Lu),o.registerSingleton(q_,Lu,1);var Du;(function(c){function e(t){switch(t){case o.Severity$1.Ignore:return"severity-ignore "+o.ThemeIcon.asClassName(a.Codicon.info);case o.Severity$1.Info:return o.ThemeIcon.asClassName(a.Codicon.info);case o.Severity$1.Warning:return o.ThemeIcon.asClassName(a.Codicon.warning);case o.Severity$1.Error:return o.ThemeIcon.asClassName(a.Codicon.error);default:return""}}c.className=e})(Du||(Du={}));var Fx=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Ts=function(c,e){return function(t,i){e(t,i,c)}},Ru;class zx{constructor(e,t,i,n,s){this._openerService=n,this._labelService=s,this._lines=0,this._longestLineLength=0,this._relatedDiagnostics=new WeakMap,this._disposables=new a.DisposableStore,this._editor=t;const r=document.createElement("div");r.className="descriptioncontainer",this._messageBlock=document.createElement("div"),this._messageBlock.classList.add("message"),this._messageBlock.setAttribute("aria-live","assertive"),this._messageBlock.setAttribute("role","alert"),r.appendChild(this._messageBlock),this._relatedBlock=document.createElement("div"),r.appendChild(this._relatedBlock),this._disposables.add(o.addStandardDisposableListener(this._relatedBlock,"click",l=>{l.preventDefault();const d=this._relatedDiagnostics.get(l.target);d&&i(d)})),this._scrollable=new o.ScrollableElement(r,{horizontal:1,vertical:1,useShadows:!1,horizontalScrollbarSize:6,verticalScrollbarSize:6}),e.appendChild(this._scrollable.getDomNode()),this._disposables.add(this._scrollable.onScroll(l=>{r.style.left=`-${l.scrollLeft}px`,r.style.top=`-${l.scrollTop}px`})),this._disposables.add(this._scrollable)}dispose(){a.dispose(this._disposables)}update(e){const{source:t,message:i,relatedInformation:n,code:s}=e;let r=(t?.length||0)+2;s&&(typeof s=="string"?r+=s.length:r+=s.value.length);const l=a.splitLines(i);this._lines=l.length,this._longestLineLength=0;for(const p of l)this._longestLineLength=Math.max(p.length+r,this._longestLineLength);o.clearNode(this._messageBlock),this._messageBlock.setAttribute("aria-label",this.getAriaLabel(e)),o.status(this.getAriaLabel(e)),this._editor.applyFontInfo(this._messageBlock);let d=this._messageBlock;for(const p of l)d=document.createElement("div"),d.innerText=p,p===""&&(d.style.height=this._messageBlock.style.lineHeight),this._messageBlock.appendChild(d);if(t||s){const p=document.createElement("span");if(p.classList.add("details"),d.appendChild(p),t){const f=document.createElement("span");f.innerText=t,f.classList.add("source"),p.appendChild(f)}if(s)if(typeof s=="string"){const f=document.createElement("span");f.innerText=`(${s})`,f.classList.add("code"),p.appendChild(f)}else{this._codeLink=o.$("a.code-link"),this._codeLink.setAttribute("href",`${s.target.toString()}`),this._codeLink.onclick=m=>{this._openerService.open(s.target),m.preventDefault(),m.stopPropagation()};const f=o.append(this._codeLink,o.$("span"));f.innerText=s.value,p.appendChild(this._codeLink)}}if(o.clearNode(this._relatedBlock),this._editor.applyFontInfo(this._relatedBlock),a.isNonEmptyArray(n)){const p=this._relatedBlock.appendChild(document.createElement("div"));p.style.paddingTop=`${Math.floor(this._editor.getOption(75)*.66)}px`,this._lines+=1;for(const f of n){const m=document.createElement("div"),_=document.createElement("a");_.classList.add("filename"),_.innerText=`${this._labelService.getUriBasenameLabel(f.resource)}(${f.startLineNumber}, ${f.startColumn}): `,_.title=this._labelService.getUriLabel(f.resource),this._relatedDiagnostics.set(_,f);const v=document.createElement("span");v.innerText=f.message,m.appendChild(_),m.appendChild(v),this._lines+=1,p.appendChild(m)}}const h=this._editor.getOption(59),u=Math.ceil(h.typicalFullwidthCharacterWidth*this._longestLineLength*.75),g=h.lineHeight*this._lines;this._scrollable.setScrollDimensions({scrollWidth:u,scrollHeight:g})}layout(e,t){this._scrollable.getDomNode().style.height=`${e}px`,this._scrollable.getDomNode().style.width=`${t}px`,this._scrollable.setScrollDimensions({width:t,height:e})}getHeightInLines(){return Math.min(17,this._lines)}getAriaLabel(e){let t="";switch(e.severity){case o.MarkerSeverity$1.Error:t=a.localize(1082,"Error");break;case o.MarkerSeverity$1.Warning:t=a.localize(1083,"Warning");break;case o.MarkerSeverity$1.Info:t=a.localize(1084,"Info");break;case o.MarkerSeverity$1.Hint:t=a.localize(1085,"Hint");break}let i=a.localize(1086,"{0}: {1} at {2}. ",t,e.message,e.startLineNumber+":"+e.startColumn);const n=this._editor.getModel();return n&&e.startLineNumber<=n.getLineCount()&&e.startLineNumber>=1&&(i=`${n.getLineContent(e.startLineNumber)}, ${i}`),i}}let Zo=(Vn=class extends Ea{constructor(e,t,i,n,s,r,l){super(e,{showArrow:!0,showFrame:!0,isAccessible:!0,frameWidth:1},s),this._themeService=t,this._openerService=i,this._menuService=n,this._contextKeyService=r,this._labelService=l,this._callOnDispose=new a.DisposableStore,this._onDidSelectRelatedInformation=new a.Emitter,this.onDidSelectRelatedInformation=this._onDidSelectRelatedInformation.event,this._severity=o.MarkerSeverity$1.Warning,this._backgroundColor=a.Color.white,this._applyTheme(t.getColorTheme()),this._callOnDispose.add(t.onDidColorThemeChange(this._applyTheme.bind(this))),this.create()}_applyTheme(e){this._backgroundColor=e.getColor(kx);let t=Tu,i=Vx;this._severity===o.MarkerSeverity$1.Warning?(t=Ja,i=Bx):this._severity===o.MarkerSeverity$1.Info&&(t=Nu,i=Kx);const n=e.getColor(t),s=e.getColor(i);this.style({arrowColor:n,frameColor:n,headerBackgroundColor:s,primaryHeadingColor:e.getColor(a_),secondaryHeadingColor:e.getColor(l_)})}_applyStyles(){this._parentContainer&&(this._parentContainer.style.backgroundColor=this._backgroundColor?this._backgroundColor.toString():""),super._applyStyles()}dispose(){this._callOnDispose.dispose(),this._onDidSelectRelatedInformation.dispose(),super.dispose()}_fillHead(e){super._fillHead(e),this._disposables.add(this._actionbarWidget.actionRunner.onWillRun(n=>this.editor.focus()));const t=this._menuService.getMenuActions(Ru.TitleMenu,this._contextKeyService),i=o.getFlatActionBarActions(t);this._actionbarWidget.push(i,{label:!1,icon:!0,index:0})}_fillTitleIcon(e){this._icon=o.append(e,o.$(""))}_fillBody(e){this._parentContainer=e,e.classList.add("marker-widget"),this._parentContainer.tabIndex=0,this._parentContainer.setAttribute("role","tooltip"),this._container=document.createElement("div"),e.appendChild(this._container),this._message=new zx(this._container,this.editor,t=>this._onDidSelectRelatedInformation.fire(t),this._openerService,this._labelService),this._disposables.add(this._message)}show(){throw new Error("call showAtMarker")}showAtMarker(e,t,i){this._container.classList.remove("stale"),this._message.update(e),this._severity=e.severity,this._applyTheme(this._themeService.getColorTheme());const n=a.Range.lift(e),s=this.editor.getPosition(),r=s&&n.containsPosition(s)?s:n.getStartPosition();super.show(r,this.computeRequiredHeight());const l=this.editor.getModel();if(l){const d=i>1?a.localize(1087,"{0} of {1} problems",t,i):a.localize(1088,"{0} of {1} problem",t,i);this.setTitle(o.basename(l.uri),d)}this._icon.className=`codicon ${Du.className(o.MarkerSeverity$1.toSeverity(this._severity))}`,this.editor.revealPositionInCenterIfOutsideViewport(r,0),this.editor.focus()}updateMarker(e){this._container.classList.remove("stale"),this._message.update(e)}showStale(){this._container.classList.add("stale"),this._relayout()}_doLayoutBody(e,t){super._doLayoutBody(e,t),this._heightInPixel=e,this._message.layout(e,t),this._container.style.height=`${e}px`}_onWidth(e){this._message.layout(this._heightInPixel,e)}_relayout(){super._relayout(this.computeRequiredHeight())}computeRequiredHeight(){return 3+this._message.getHeightInLines()}},Ru=Vn,Vn.TitleMenu=new o.MenuId("gotoErrorTitleMenu"),Vn);Zo=Ru=Fx([Ts(1,o.IThemeService),Ts(2,o.IOpenerService),Ts(3,o.IMenuService),Ts(4,o.IInstantiationService),Ts(5,o.IContextKeyService),Ts(6,o.ILabelService)],Zo);const G_=o.oneOf(o.editorErrorForeground,o.editorErrorBorder),Z_=o.oneOf(o.editorWarningForeground,o.editorWarningBorder),X_=o.oneOf(o.editorInfoForeground,o.editorInfoBorder),Tu=o.registerColor("editorMarkerNavigationError.background",{dark:G_,light:G_,hcDark:o.contrastBorder,hcLight:o.contrastBorder},a.localize(1089,"Editor marker navigation widget error color.")),Vx=o.registerColor("editorMarkerNavigationError.headerBackground",{dark:o.transparent(Tu,.1),light:o.transparent(Tu,.1),hcDark:null,hcLight:null},a.localize(1090,"Editor marker navigation widget error heading background.")),Ja=o.registerColor("editorMarkerNavigationWarning.background",{dark:Z_,light:Z_,hcDark:o.contrastBorder,hcLight:o.contrastBorder},a.localize(1091,"Editor marker navigation widget warning color.")),Bx=o.registerColor("editorMarkerNavigationWarning.headerBackground",{dark:o.transparent(Ja,.1),light:o.transparent(Ja,.1),hcDark:"#0C141F",hcLight:o.transparent(Ja,.2)},a.localize(1092,"Editor marker navigation widget warning heading background.")),Nu=o.registerColor("editorMarkerNavigationInfo.background",{dark:X_,light:X_,hcDark:o.contrastBorder,hcLight:o.contrastBorder},a.localize(1093,"Editor marker navigation widget info color.")),Kx=o.registerColor("editorMarkerNavigationInfo.headerBackground",{dark:o.transparent(Nu,.1),light:o.transparent(Nu,.1),hcDark:null,hcLight:null},a.localize(1094,"Editor marker navigation widget info heading background.")),kx=o.registerColor("editorMarkerNavigation.background",o.editorBackground,a.localize(1095,"Editor marker navigation widget background."));var Ux=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Wa=function(c,e){return function(t,i){e(t,i,c)}},Xo;let ln=(Bn=class{static get(e){return e.getContribution(Xo.ID)}constructor(e,t,i,n,s){this._markerNavigationService=t,this._contextKeyService=i,this._editorService=n,this._instantiationService=s,this._sessionDispoables=new a.DisposableStore,this._editor=e,this._widgetVisible=Y_.bindTo(this._contextKeyService)}dispose(){this._cleanUp(),this._sessionDispoables.dispose()}_cleanUp(){this._widgetVisible.reset(),this._sessionDispoables.clear(),this._widget=void 0,this._model=void 0}_getOrCreateModel(e){if(this._model&&this._model.matches(e))return this._model;let t=!1;return this._model&&(t=!0,this._cleanUp()),this._model=this._markerNavigationService.getMarkerList(e),t&&this._model.move(!0,this._editor.getModel(),this._editor.getPosition()),this._widget=this._instantiationService.createInstance(Zo,this._editor),this._widget.onDidClose(()=>this.close(),this,this._sessionDispoables),this._widgetVisible.set(!0),this._sessionDispoables.add(this._model),this._sessionDispoables.add(this._widget),this._sessionDispoables.add(this._editor.onDidChangeCursorPosition(i=>{(!this._model?.selected||!a.Range.containsPosition(this._model?.selected.marker,i.position))&&this._model?.resetIndex()})),this._sessionDispoables.add(this._model.onDidChange(()=>{if(!this._widget||!this._widget.position||!this._model)return;const i=this._model.find(this._editor.getModel().uri,this._widget.position);i?this._widget.updateMarker(i.marker):this._widget.showStale()})),this._sessionDispoables.add(this._widget.onDidSelectRelatedInformation(i=>{this._editorService.openCodeEditor({resource:i.resource,options:{pinned:!0,revealIfOpened:!0,selection:a.Range.lift(i).collapseToStart()}},this._editor),this.close(!1)})),this._sessionDispoables.add(this._editor.onDidChangeModel(()=>this._cleanUp())),this._model}close(e=!0){this._cleanUp(),e&&this._editor.focus()}showAtMarker(e){if(!this._editor.hasModel())return;const t=this._editor.getModel(),i=this._getOrCreateModel(t.uri);i.resetIndex(),i.move(!0,t,new a.Position(e.startLineNumber,e.startColumn)),i.selected&&this._widget.showAtMarker(i.selected.marker,i.selected.index,i.selected.total)}async navigate(e,t){if(!this._editor.hasModel())return;const i=this._editor.getModel(),n=this._getOrCreateModel(t?void 0:i.uri);if(n.move(e,i,this._editor.getPosition()),!!n.selected)if(n.selected.marker.resource.toString()!==i.uri.toString()){this._cleanUp();const s=await this._editorService.openCodeEditor({resource:n.selected.marker.resource,options:{pinned:!1,revealIfOpened:!0,selectionRevealType:2,selection:n.selected.marker}},this._editor);s&&(Xo.get(s)?.close(),Xo.get(s)?.navigate(e,t))}else this._widget.showAtMarker(n.selected.marker,n.selected.index,n.selected.total)}},Xo=Bn,Bn.ID="editor.contrib.markerController",Bn);ln=Xo=Ux([Wa(1,q_),Wa(2,o.IContextKeyService),Wa(3,o.ICodeEditorService),Wa(4,o.IInstantiationService)],ln);class Ha extends o.EditorAction{constructor(e,t,i){super(i),this._next=e,this._multiFile=t}async run(e,t){t.hasModel()&&await ln.get(t)?.navigate(this._next,this._multiFile)}}const Kn=class Kn extends Ha{constructor(){super(!0,!1,{id:Kn.ID,label:Kn.LABEL,precondition:void 0,kbOpts:{kbExpr:o.EditorContextKeys.focus,primary:578,weight:100},menuOpts:{menuId:Zo.TitleMenu,title:Kn.LABEL.value,icon:o.registerIcon("marker-navigation-next",a.Codicon.arrowDown,a.localize(1074,"Icon for goto next marker.")),group:"navigation",order:1}})}};Kn.ID="editor.action.marker.next",Kn.LABEL=a.localize2(1078,"Go to Next Problem (Error, Warning, Info)");let Yo=Kn;const kn=class kn extends Ha{constructor(){super(!1,!1,{id:kn.ID,label:kn.LABEL,precondition:void 0,kbOpts:{kbExpr:o.EditorContextKeys.focus,primary:1602,weight:100},menuOpts:{menuId:Zo.TitleMenu,title:kn.LABEL.value,icon:o.registerIcon("marker-navigation-previous",a.Codicon.arrowUp,a.localize(1075,"Icon for goto previous marker.")),group:"navigation",order:2}})}};kn.ID="editor.action.marker.prev",kn.LABEL=a.localize2(1079,"Go to Previous Problem (Error, Warning, Info)");let el=kn;const Pc=class Pc extends Ha{constructor(){super(!0,!0,{id:Pc.ID,label:a.localize2(1080,"Go to Next Problem in Files (Error, Warning, Info)"),precondition:void 0,kbOpts:{kbExpr:o.EditorContextKeys.focus,primary:66,weight:100},menuOpts:{menuId:o.MenuId.MenubarGoMenu,title:a.localize(1076,"Next &&Problem"),group:"6_problem_nav",order:1}})}};Pc.ID="editor.action.marker.nextInFiles";let tl=Pc;const Oc=class Oc extends Ha{constructor(){super(!1,!0,{id:Oc.ID,label:a.localize2(1081,"Go to Previous Problem in Files (Error, Warning, Info)"),precondition:void 0,kbOpts:{kbExpr:o.EditorContextKeys.focus,primary:1090,weight:100},menuOpts:{menuId:o.MenuId.MenubarGoMenu,title:a.localize(1077,"Previous &&Problem"),group:"6_problem_nav",order:2}})}};Oc.ID="editor.action.marker.prevInFiles";let il=Oc;o.registerEditorContribution(ln.ID,ln,4),o.registerEditorAction(Yo),o.registerEditorAction(el),o.registerEditorAction(tl),o.registerEditorAction(il);const Y_=new o.RawContextKey("markersNavigationVisible",!1),$x=o.EditorCommand.bindToContribution(ln.get);o.registerEditorCommand(new $x({id:"closeMarkersNavigation",precondition:Y_,handler:c=>c.close(),kbOpts:{weight:150,kbExpr:o.EditorContextKeys.focus,primary:9,secondary:[1033]}}));class jx{constructor(e,t,i){this._selection=e,this._cursors=t,this._selectionId=null,this._trimInRegexesAndStrings=i}getEditOperations(e,t){const i=qx(e,this._cursors,this._trimInRegexesAndStrings);for(let n=0,s=i.length;n<s;n++){const r=i[n];t.addEditOperation(r.range,r.text)}this._selectionId=t.trackSelection(this._selection)}computeCursorState(e,t){return t.getTrackedSelection(this._selectionId)}}function qx(c,e,t){e.sort((l,d)=>l.lineNumber===d.lineNumber?l.column-d.column:l.lineNumber-d.lineNumber);for(let l=e.length-2;l>=0;l--)e[l].lineNumber===e[l+1].lineNumber&&e.splice(l,1);const i=[];let n=0,s=0;const r=e.length;for(let l=1,d=c.getLineCount();l<=d;l++){const h=c.getLineContent(l),u=h.length+1;let g=0;if(s<r&&e[s].lineNumber===l&&(g=e[s].column,s++,g===u)||h.length===0)continue;const p=a.lastNonWhitespaceIndex(h);let f=0;if(p===-1)f=1;else if(p!==h.length-1)f=p+2;else continue;if(!t){if(!c.tokenization.hasAccurateTokensForLine(l))continue;const m=c.tokenization.getLineTokens(l),_=m.getStandardTokenType(m.findTokenIndexAtOffset(f));if(_===2||_===3)continue}f=Math.max(g,f),i[n++]=o.EditOperation.delete(new a.Range(l,f,l,u))}return i}class Q_{constructor(e,t,i){this._selection=e,this._isCopyingDown=t,this._noop=i||!1,this._selectionDirection=0,this._selectionId=null,this._startLineNumberDelta=0,this._endLineNumberDelta=0}getEditOperations(e,t){let i=this._selection;this._startLineNumberDelta=0,this._endLineNumberDelta=0,i.startLineNumber<i.endLineNumber&&i.endColumn===1&&(this._endLineNumberDelta=1,i=i.setEndPosition(i.endLineNumber-1,e.getLineMaxColumn(i.endLineNumber-1)));const n=[];for(let r=i.startLineNumber;r<=i.endLineNumber;r++)n.push(e.getLineContent(r));const s=n.join(`
23
+ `);s===""&&this._isCopyingDown&&(this._startLineNumberDelta++,this._endLineNumberDelta++),this._noop?t.addEditOperation(new a.Range(i.endLineNumber,e.getLineMaxColumn(i.endLineNumber),i.endLineNumber+1,1),i.endLineNumber===e.getLineCount()?"":`
24
+ `):this._isCopyingDown?t.addEditOperation(new a.Range(i.startLineNumber,1,i.startLineNumber,1),s+`
25
+ `):t.addEditOperation(new a.Range(i.endLineNumber,e.getLineMaxColumn(i.endLineNumber),i.endLineNumber,e.getLineMaxColumn(i.endLineNumber)),`
26
+ `+s),this._selectionId=t.trackSelection(i),this._selectionDirection=this._selection.getDirection()}computeCursorState(e,t){let i=t.getTrackedSelection(this._selectionId);if(this._startLineNumberDelta!==0||this._endLineNumberDelta!==0){let n=i.startLineNumber,s=i.startColumn,r=i.endLineNumber,l=i.endColumn;this._startLineNumberDelta!==0&&(n=n+this._startLineNumberDelta,s=1),this._endLineNumberDelta!==0&&(r=r+this._endLineNumberDelta,l=1),i=a.Selection.createWithDirection(n,s,r,l,this._selectionDirection)}return i}}function Se(c,e){let t=0;for(let i=0;i<c.length;i++)c.charAt(i)===" "?t+=e:t++;return t}function Qo(c,e,t){c=c<0?0:c;let i="";if(!t){const n=Math.floor(c/e);c=c%e;for(let s=0;s<n;s++)i+=" "}for(let n=0;n<c;n++)i+=" ";return i}var Gx=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Zx=function(c,e){return function(t,i){e(t,i,c)}};let Mu=class{constructor(e,t,i,n){this._languageConfigurationService=n,this._selection=e,this._isMovingDown=t,this._autoIndent=i,this._selectionId=null,this._moveEndLineSelectionShrink=!1}createVirtualModel(e,t,i){return{tokenization:{getLineTokens:n=>e.tokenization.getLineTokens(t(n)),getLanguageId:()=>e.getLanguageId(),getLanguageIdAtPosition:(n,s)=>e.getLanguageIdAtPosition(n,s)},getLineContent:n=>{const s=i?.(n);return s!==void 0?s:e.getLineContent(t(n))}}}getEditOperations(e,t){const i=e.getLineCount();if(this._isMovingDown&&this._selection.endLineNumber===i){this._selectionId=t.trackSelection(this._selection);return}if(!this._isMovingDown&&this._selection.startLineNumber===1){this._selectionId=t.trackSelection(this._selection);return}this._moveEndPositionDown=!1;let n=this._selection;n.startLineNumber<n.endLineNumber&&n.endColumn===1&&(this._moveEndPositionDown=!0,n=n.setEndPosition(n.endLineNumber-1,e.getLineMaxColumn(n.endLineNumber-1)));const{tabSize:s,indentSize:r,insertSpaces:l}=e.getOptions(),d=this.buildIndentConverter(s,r,l);if(n.startLineNumber===n.endLineNumber&&e.getLineMaxColumn(n.startLineNumber)===1){const h=n.startLineNumber,u=this._isMovingDown?h+1:h-1;e.getLineMaxColumn(u)===1?t.addEditOperation(new a.Range(1,1,1,1),null):(t.addEditOperation(new a.Range(h,1,h,1),e.getLineContent(u)),t.addEditOperation(new a.Range(u,1,u,e.getLineMaxColumn(u)),null)),n=new a.Selection(u,1,u,1)}else{let h,u;if(this._isMovingDown){h=n.endLineNumber+1,u=e.getLineContent(h),t.addEditOperation(new a.Range(h-1,e.getLineMaxColumn(h-1),h,e.getLineMaxColumn(h)),null);let g=u;if(this.shouldAutoIndent(e,n)){const p=this.matchEnterRule(e,d,s,h,n.startLineNumber-1);if(p!==null){const m=a.getLeadingWhitespace(e.getLineContent(h)),_=p+Se(m,s);g=Qo(_,s,l)+this.trimStart(u)}else{const m=this.createVirtualModel(e,v=>v===n.startLineNumber?h:v),_=o.getGoodIndentForLine(this._autoIndent,m,e.getLanguageIdAtPosition(h,1),n.startLineNumber,d,this._languageConfigurationService);if(_!==null){const v=a.getLeadingWhitespace(e.getLineContent(h)),b=Se(_,s),C=Se(v,s);b!==C&&(g=Qo(b,s,l)+this.trimStart(u))}}t.addEditOperation(new a.Range(n.startLineNumber,1,n.startLineNumber,1),g+`
27
+ `);const f=this.matchEnterRuleMovingDown(e,d,s,n.startLineNumber,h,g);if(f!==null)f!==0&&this.getIndentEditsOfMovingBlock(e,t,n,s,l,f);else{const m=this.createVirtualModel(e,v=>v===n.startLineNumber?h:v>=n.startLineNumber+1&&v<=n.endLineNumber+1?v-1:v,v=>v===n.startLineNumber?g:void 0),_=o.getGoodIndentForLine(this._autoIndent,m,e.getLanguageIdAtPosition(h,1),n.startLineNumber+1,d,this._languageConfigurationService);if(_!==null){const v=a.getLeadingWhitespace(e.getLineContent(n.startLineNumber)),b=Se(_,s),C=Se(v,s);if(b!==C){const y=b-C;this.getIndentEditsOfMovingBlock(e,t,n,s,l,y)}}}}else t.addEditOperation(new a.Range(n.startLineNumber,1,n.startLineNumber,1),g+`
28
+ `)}else if(h=n.startLineNumber-1,u=e.getLineContent(h),t.addEditOperation(new a.Range(h,1,h+1,1),null),t.addEditOperation(new a.Range(n.endLineNumber,e.getLineMaxColumn(n.endLineNumber),n.endLineNumber,e.getLineMaxColumn(n.endLineNumber)),`
29
+ `+u),this.shouldAutoIndent(e,n)){const g=this.createVirtualModel(e,f=>f===h?n.startLineNumber:f),p=this.matchEnterRule(e,d,s,n.startLineNumber,n.startLineNumber-2);if(p!==null)p!==0&&this.getIndentEditsOfMovingBlock(e,t,n,s,l,p);else{const f=o.getGoodIndentForLine(this._autoIndent,g,e.getLanguageIdAtPosition(n.startLineNumber,1),h,d,this._languageConfigurationService);if(f!==null){const m=a.getLeadingWhitespace(e.getLineContent(n.startLineNumber)),_=Se(f,s),v=Se(m,s);if(_!==v){const b=_-v;this.getIndentEditsOfMovingBlock(e,t,n,s,l,b)}}}}}this._selectionId=t.trackSelection(n)}buildIndentConverter(e,t,i){return{shiftIndent:n=>o.ShiftCommand.shiftIndent(n,n.length+1,e,t,i),unshiftIndent:n=>o.ShiftCommand.unshiftIndent(n,n.length+1,e,t,i)}}parseEnterResult(e,t,i,n,s){if(s){let r=s.indentation;s.indentAction===o.IndentAction.None||s.indentAction===o.IndentAction.Indent?r=s.indentation+s.appendText:s.indentAction===o.IndentAction.IndentOutdent?r=s.indentation:s.indentAction===o.IndentAction.Outdent&&(r=t.unshiftIndent(s.indentation)+s.appendText);const l=e.getLineContent(n);if(this.trimStart(l).indexOf(this.trimStart(r))>=0){const d=a.getLeadingWhitespace(e.getLineContent(n));let h=a.getLeadingWhitespace(r);const u=o.getIndentMetadata(e,n,this._languageConfigurationService);u!==null&&u&2&&(h=t.unshiftIndent(h));const g=Se(h,i),p=Se(d,i);return g-p}}return null}matchEnterRuleMovingDown(e,t,i,n,s,r){if(a.lastNonWhitespaceIndex(r)>=0){const l=e.getLineMaxColumn(s),d=o.getEnterAction(this._autoIndent,e,new a.Range(s,l,s,l),this._languageConfigurationService);return this.parseEnterResult(e,t,i,n,d)}else{let l=n-1;for(;l>=1;){const u=e.getLineContent(l);if(a.lastNonWhitespaceIndex(u)>=0)break;l--}if(l<1||n>e.getLineCount())return null;const d=e.getLineMaxColumn(l),h=o.getEnterAction(this._autoIndent,e,new a.Range(l,d,l,d),this._languageConfigurationService);return this.parseEnterResult(e,t,i,n,h)}}matchEnterRule(e,t,i,n,s,r){let l=s;for(;l>=1;){let u;if(l===s&&r!==void 0?u=r:u=e.getLineContent(l),a.lastNonWhitespaceIndex(u)>=0)break;l--}if(l<1||n>e.getLineCount())return null;const d=e.getLineMaxColumn(l),h=o.getEnterAction(this._autoIndent,e,new a.Range(l,d,l,d),this._languageConfigurationService);return this.parseEnterResult(e,t,i,n,h)}trimStart(e){return e.replace(/^\s+/,"")}shouldAutoIndent(e,t){if(this._autoIndent<4||!e.tokenization.isCheapToTokenize(t.startLineNumber))return!1;const i=e.getLanguageIdAtPosition(t.startLineNumber,1),n=e.getLanguageIdAtPosition(t.endLineNumber,1);return!(i!==n||this._languageConfigurationService.getLanguageConfiguration(i).indentRulesSupport===null)}getIndentEditsOfMovingBlock(e,t,i,n,s,r){for(let l=i.startLineNumber;l<=i.endLineNumber;l++){const d=e.getLineContent(l),h=a.getLeadingWhitespace(d),g=Se(h,n)+r,p=Qo(g,n,s);p!==h&&(t.addEditOperation(new a.Range(l,1,l,h.length+1),p),l===i.endLineNumber&&i.endColumn<=h.length+1&&p===""&&(this._moveEndLineSelectionShrink=!0))}}computeCursorState(e,t){let i=t.getTrackedSelection(this._selectionId);return this._moveEndPositionDown&&(i=i.setEndPosition(i.endLineNumber+1,1)),this._moveEndLineSelectionShrink&&i.startLineNumber<i.endLineNumber&&(i=i.setEndPosition(i.endLineNumber,2)),i}};Mu=Gx([Zx(3,o.ILanguageConfigurationService)],Mu);const mf=class mf{constructor(e,t){this.selection=e,this.descending=t,this.selectionId=null}getEditOperations(e,t){const i=Xx(e,this.selection,this.descending);i&&t.addEditOperation(i.range,i.text),this.selectionId=t.trackSelection(this.selection)}computeCursorState(e,t){return t.getTrackedSelection(this.selectionId)}static canRun(e,t,i){if(e===null)return!1;const n=J_(e,t,i);if(!n)return!1;for(let s=0,r=n.before.length;s<r;s++)if(n.before[s]!==n.after[s])return!0;return!1}};mf._COLLATOR=a.safeIntl.Collator();let Jo=mf;function J_(c,e,t){const i=e.startLineNumber;let n=e.endLineNumber;if(e.endColumn===1&&n--,i>=n)return null;const s=[];for(let l=i;l<=n;l++)s.push(c.getLineContent(l));let r=s.slice(0);return r.sort(Jo._COLLATOR.value.compare),t===!0&&(r=r.reverse()),{startLineNumber:i,endLineNumber:n,before:s,after:r}}function Xx(c,e,t){const i=J_(c,e,t);return i?o.EditOperation.replace(new a.Range(i.startLineNumber,1,i.endLineNumber,c.getLineMaxColumn(i.endLineNumber)),i.after.join(`
30
+ `)):null}class W_ extends o.EditorAction{constructor(e,t){super(t),this.down=e}run(e,t){if(!t.hasModel())return;const i=t.getSelections().map((r,l)=>({selection:r,index:l,ignore:!1}));i.sort((r,l)=>a.Range.compareRangesUsingStarts(r.selection,l.selection));let n=i[0];for(let r=1;r<i.length;r++){const l=i[r];n.selection.endLineNumber===l.selection.startLineNumber&&(n.index<l.index?l.ignore=!0:(n.ignore=!0,n=l))}const s=[];for(const r of i)s.push(new Q_(r.selection,this.down,r.ignore));t.pushUndoStop(),t.executeCommands(this.id,s),t.pushUndoStop()}}class Yx extends W_{constructor(){super(!1,{id:"editor.action.copyLinesUpAction",label:a.localize2(1315,"Copy Line Up"),precondition:o.EditorContextKeys.writable,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:1552,linux:{primary:3600},weight:100},menuOpts:{menuId:o.MenuId.MenubarSelectionMenu,group:"2_line",title:a.localize(1310,"&&Copy Line Up"),order:1},canTriggerInlineEdits:!0})}}class Qx extends W_{constructor(){super(!0,{id:"editor.action.copyLinesDownAction",label:a.localize2(1316,"Copy Line Down"),precondition:o.EditorContextKeys.writable,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:1554,linux:{primary:3602},weight:100},menuOpts:{menuId:o.MenuId.MenubarSelectionMenu,group:"2_line",title:a.localize(1311,"Co&&py Line Down"),order:2},canTriggerInlineEdits:!0})}}class Jx extends o.EditorAction{constructor(){super({id:"editor.action.duplicateSelection",label:a.localize2(1317,"Duplicate Selection"),precondition:o.EditorContextKeys.writable,menuOpts:{menuId:o.MenuId.MenubarSelectionMenu,group:"2_line",title:a.localize(1312,"&&Duplicate Selection"),order:5},canTriggerInlineEdits:!0})}run(e,t,i){if(!t.hasModel())return;const n=[],s=t.getSelections(),r=t.getModel();for(const l of s)if(l.isEmpty())n.push(new Q_(l,!0));else{const d=new a.Selection(l.endLineNumber,l.endColumn,l.endLineNumber,l.endColumn);n.push(new o.ReplaceCommandThatSelectsText(d,r.getValueInRange(l)))}t.pushUndoStop(),t.executeCommands(this.id,n),t.pushUndoStop()}}class H_ extends o.EditorAction{constructor(e,t){super(t),this.down=e}run(e,t){const i=e.get(o.ILanguageConfigurationService),n=[],s=t.getSelections()||[],r=t.getOption(16);for(const l of s)n.push(new Mu(l,this.down,r,i));t.pushUndoStop(),t.executeCommands(this.id,n),t.pushUndoStop()}}class Wx extends H_{constructor(){super(!1,{id:"editor.action.moveLinesUpAction",label:a.localize2(1318,"Move Line Up"),precondition:o.EditorContextKeys.writable,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:528,linux:{primary:528},weight:100},menuOpts:{menuId:o.MenuId.MenubarSelectionMenu,group:"2_line",title:a.localize(1313,"Mo&&ve Line Up"),order:3},canTriggerInlineEdits:!0})}}class Hx extends H_{constructor(){super(!0,{id:"editor.action.moveLinesDownAction",label:a.localize2(1319,"Move Line Down"),precondition:o.EditorContextKeys.writable,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:530,linux:{primary:530},weight:100},menuOpts:{menuId:o.MenuId.MenubarSelectionMenu,group:"2_line",title:a.localize(1314,"Move &&Line Down"),order:4},canTriggerInlineEdits:!0})}}class ev extends o.EditorAction{constructor(e,t){super(t),this.descending=e}run(e,t){if(!t.hasModel())return;const i=t.getModel();let n=t.getSelections();n.length===1&&n[0].isSingleLine()&&(n=[new a.Selection(1,1,i.getLineCount(),i.getLineMaxColumn(i.getLineCount()))]);for(const r of n)if(!Jo.canRun(t.getModel(),r,this.descending))return;const s=[];for(let r=0,l=n.length;r<l;r++)s[r]=new Jo(n[r],this.descending);t.pushUndoStop(),t.executeCommands(this.id,s),t.pushUndoStop()}}class eE extends ev{constructor(){super(!1,{id:"editor.action.sortLinesAscending",label:a.localize2(1320,"Sort Lines Ascending"),precondition:o.EditorContextKeys.writable,canTriggerInlineEdits:!0})}}class tE extends ev{constructor(){super(!0,{id:"editor.action.sortLinesDescending",label:a.localize2(1321,"Sort Lines Descending"),precondition:o.EditorContextKeys.writable,canTriggerInlineEdits:!0})}}class iE extends o.EditorAction{constructor(){super({id:"editor.action.removeDuplicateLines",label:a.localize2(1322,"Delete Duplicate Lines"),precondition:o.EditorContextKeys.writable,canTriggerInlineEdits:!0})}run(e,t){if(!t.hasModel())return;const i=t.getModel();if(i.getLineCount()===1&&i.getLineMaxColumn(1)===1)return;const n=[],s=[];let r=0,l=!0,d=t.getSelections();d.length===1&&d[0].isSingleLine()&&(d=[new a.Selection(1,1,i.getLineCount(),i.getLineMaxColumn(i.getLineCount()))],l=!1);for(const h of d){const u=new Set,g=[];for(let _=h.startLineNumber;_<=h.endLineNumber;_++){const v=i.getLineContent(_);u.has(v)||(g.push(v),u.add(v))}const p=new a.Selection(h.startLineNumber,1,h.endLineNumber,i.getLineMaxColumn(h.endLineNumber)),f=h.startLineNumber-r,m=new a.Selection(f,1,f+g.length-1,g[g.length-1].length+1);n.push(o.EditOperation.replace(p,g.join(`
31
+ `))),s.push(m),r+=h.endLineNumber-h.startLineNumber+1-g.length}t.pushUndoStop(),t.executeEdits(this.id,n,l?s:void 0),t.pushUndoStop()}}class nE extends o.EditorAction{constructor(){super({id:"editor.action.reverseLines",label:a.localize2(1323,"Reverse lines"),precondition:o.EditorContextKeys.writable,canTriggerInlineEdits:!0})}run(e,t){if(!t.hasModel())return;const i=t.getModel(),n=t.getSelections();let s=n;s.length===1&&s[0].isSingleLine()&&(s=[new a.Selection(1,1,i.getLineCount(),i.getLineMaxColumn(i.getLineCount()))]);const r=[],l=[];for(let d=0;d<s.length;d++){const h=s[d],u=n[d];let g=h.endLineNumber;h.startLineNumber<h.endLineNumber&&h.endColumn===1&&g--;let p=new a.Range(h.startLineNumber,1,g,i.getLineMaxColumn(g));g===i.getLineCount()&&i.getLineContent(p.endLineNumber)===""&&(p=p.setEndPosition(p.endLineNumber-1,i.getLineMaxColumn(p.endLineNumber-1)));const f=[];for(let b=p.endLineNumber;b>=p.startLineNumber;b--)f.push(i.getLineContent(b));const m=o.EditOperation.replace(p,f.join(`
32
+ `));r.push(m);const _=function(b){return b<=p.endLineNumber?p.endLineNumber-b+p.startLineNumber:b},v=function(b){if(b.isEmpty())return new a.Selection(_(b.positionLineNumber),b.positionColumn,_(b.positionLineNumber),b.positionColumn);{const C=_(b.selectionStartLineNumber),y=_(b.positionLineNumber),I=b.selectionStartColumn,x=b.positionColumn;return new a.Selection(C,I,y,x)}};l.push(v(u))}t.pushUndoStop(),t.executeEdits(this.id,r,l),t.pushUndoStop()}}const Ac=class Ac extends o.EditorAction{constructor(){super({id:Ac.ID,label:a.localize2(1324,"Trim Trailing Whitespace"),precondition:o.EditorContextKeys.writable,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:a.KeyChord(2089,2102),weight:100}})}run(e,t,i){let n=[];i.reason==="auto-save"&&(n=(t.getSelections()||[]).map(u=>new a.Position(u.positionLineNumber,u.positionColumn)));const s=t.getSelection();if(s===null)return;const r=e.get(o.IConfigurationService),l=t.getModel(),d=r.getValue("files.trimTrailingWhitespaceInRegexAndStrings",{overrideIdentifier:l?.getLanguageId(),resource:l?.uri}),h=new jx(s,n,d);t.pushUndoStop(),t.executeCommands(this.id,[h]),t.pushUndoStop()}};Ac.ID="editor.action.trimTrailingWhitespace";let Pu=Ac;class sE extends o.EditorAction{constructor(){super({id:"editor.action.deleteLines",label:a.localize2(1325,"Delete Line"),precondition:o.EditorContextKeys.writable,kbOpts:{kbExpr:o.EditorContextKeys.textInputFocus,primary:3113,weight:100},canTriggerInlineEdits:!0})}run(e,t){if(!t.hasModel())return;const i=this._getLinesToRemove(t),n=t.getModel();if(n.getLineCount()===1&&n.getLineMaxColumn(1)===1)return;let s=0;const r=[],l=[];for(let d=0,h=i.length;d<h;d++){const u=i[d];let g=u.startLineNumber,p=u.endLineNumber,f=1,m=n.getLineMaxColumn(p);p<n.getLineCount()?(p+=1,m=1):g>1&&(g-=1,f=n.getLineMaxColumn(g)),r.push(o.EditOperation.replace(new a.Selection(g,f,p,m),"")),l.push(new a.Selection(g-s,u.positionColumn,g-s,u.positionColumn)),s+=u.endLineNumber-u.startLineNumber+1}t.pushUndoStop(),t.executeEdits(this.id,r,l),t.revealAllCursors(!0),t.pushUndoStop()}_getLinesToRemove(e){const t=e.getSelections().map(s=>{let r=s.endLineNumber;return s.startLineNumber<s.endLineNumber&&s.endColumn===1&&(r-=1),{startLineNumber:s.startLineNumber,selectionStartColumn:s.selectionStartColumn,endLineNumber:r,positionColumn:s.positionColumn}});t.sort((s,r)=>s.startLineNumber===r.startLineNumber?s.endLineNumber-r.endLineNumber:s.startLineNumber-r.startLineNumber);const i=[];let n=t[0];for(let s=1;s<t.length;s++)n.endLineNumber+1>=t[s].startLineNumber?n.endLineNumber=t[s].endLineNumber:(i.push(n),n=t[s]);return i.push(n),i}}class oE extends o.EditorAction{constructor(){super({id:"editor.action.indentLines",label:a.localize2(1326,"Indent Line"),precondition:o.EditorContextKeys.writable,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:2142,weight:100},canTriggerInlineEdits:!0})}run(e,t){const i=t._getViewModel();i&&(t.pushUndoStop(),t.executeCommands(this.id,o.TypeOperations.indent(i.cursorConfig,t.getModel(),t.getSelections())),t.pushUndoStop())}}class rE extends o.EditorAction{constructor(){super({id:"editor.action.outdentLines",label:a.localize2(1327,"Outdent Line"),precondition:o.EditorContextKeys.writable,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:2140,weight:100},canTriggerInlineEdits:!0})}run(e,t){o.CoreEditingCommands.Outdent.runEditorCommand(e,t,null)}}const Fc=class Fc extends o.EditorAction{constructor(){super({id:Fc.ID,label:a.localize2(1328,"Insert Line Above"),precondition:o.EditorContextKeys.writable,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:3075,weight:100},canTriggerInlineEdits:!0})}run(e,t){const i=t._getViewModel();i&&(t.pushUndoStop(),t.executeCommands(this.id,o.EnterOperation.lineInsertBefore(i.cursorConfig,t.getModel(),t.getSelections())))}};Fc.ID="editor.action.insertLineBefore";let nl=Fc;const zc=class zc extends o.EditorAction{constructor(){super({id:zc.ID,label:a.localize2(1329,"Insert Line Below"),precondition:o.EditorContextKeys.writable,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:2051,weight:100},canTriggerInlineEdits:!0})}run(e,t){const i=t._getViewModel();i&&(t.pushUndoStop(),t.executeCommands(this.id,o.EnterOperation.lineInsertAfter(i.cursorConfig,t.getModel(),t.getSelections())))}};zc.ID="editor.action.insertLineAfter";let sl=zc;class tv extends o.EditorAction{run(e,t){if(!t.hasModel())return;const i=t.getSelection(),n=this._getRangesToDelete(t),s=[];for(let d=0,h=n.length-1;d<h;d++){const u=n[d],g=n[d+1];a.Range.intersectRanges(u,g)===null?s.push(u):n[d+1]=a.Range.plusRange(u,g)}s.push(n[n.length-1]);const r=this._getEndCursorState(i,s),l=s.map(d=>o.EditOperation.replace(d,""));t.pushUndoStop(),t.executeEdits(this.id,l,r),t.pushUndoStop()}}class aE extends tv{constructor(){super({id:"deleteAllLeft",label:a.localize2(1330,"Delete All Left"),precondition:o.EditorContextKeys.writable,kbOpts:{kbExpr:o.EditorContextKeys.textInputFocus,primary:0,mac:{primary:2049},weight:100},canTriggerInlineEdits:!0})}_getEndCursorState(e,t){let i=null;const n=[];let s=0;return t.forEach(r=>{let l;if(r.endColumn===1&&s>0){const d=r.startLineNumber-s;l=new a.Selection(d,r.startColumn,d,r.startColumn)}else l=new a.Selection(r.startLineNumber,r.startColumn,r.startLineNumber,r.startColumn);s+=r.endLineNumber-r.startLineNumber,r.intersectRanges(e)?i=l:n.push(l)}),i&&n.unshift(i),n}_getRangesToDelete(e){const t=e.getSelections();if(t===null)return[];let i=t;const n=e.getModel();return n===null?[]:(i.sort(a.Range.compareRangesUsingStarts),i=i.map(s=>{if(s.isEmpty())if(s.startColumn===1){const r=Math.max(1,s.startLineNumber-1),l=s.startLineNumber===1?1:n.getLineLength(r)+1;return new a.Range(r,l,s.startLineNumber,1)}else return new a.Range(s.startLineNumber,1,s.startLineNumber,s.startColumn);else return new a.Range(s.startLineNumber,1,s.endLineNumber,s.endColumn)}),i)}}class lE extends tv{constructor(){super({id:"deleteAllRight",label:a.localize2(1331,"Delete All Right"),precondition:o.EditorContextKeys.writable,kbOpts:{kbExpr:o.EditorContextKeys.textInputFocus,primary:0,mac:{primary:297,secondary:[2068]},weight:100},canTriggerInlineEdits:!0})}_getEndCursorState(e,t){let i=null;const n=[];for(let s=0,r=t.length,l=0;s<r;s++){const d=t[s],h=new a.Selection(d.startLineNumber-l,d.startColumn,d.startLineNumber-l,d.startColumn);d.intersectRanges(e)?i=h:n.push(h)}return i&&n.unshift(i),n}_getRangesToDelete(e){const t=e.getModel();if(t===null)return[];const i=e.getSelections();if(i===null)return[];const n=i.map(s=>{if(s.isEmpty()){const r=t.getLineMaxColumn(s.startLineNumber);return s.startColumn===r?new a.Range(s.startLineNumber,s.startColumn,s.startLineNumber+1,1):new a.Range(s.startLineNumber,s.startColumn,s.startLineNumber,r)}return s});return n.sort(a.Range.compareRangesUsingStarts),n}}class cE extends o.EditorAction{constructor(){super({id:"editor.action.joinLines",label:a.localize2(1332,"Join Lines"),precondition:o.EditorContextKeys.writable,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:0,mac:{primary:296},weight:100},canTriggerInlineEdits:!0})}run(e,t){const i=t.getSelections();if(i===null)return;let n=t.getSelection();if(n===null)return;i.sort(a.Range.compareRangesUsingStarts);const s=[],r=i.reduce((p,f)=>p.isEmpty()?p.endLineNumber===f.startLineNumber?(n.equalsSelection(p)&&(n=f),f):f.startLineNumber>p.endLineNumber+1?(s.push(p),f):new a.Selection(p.startLineNumber,p.startColumn,f.endLineNumber,f.endColumn):f.startLineNumber>p.endLineNumber?(s.push(p),f):new a.Selection(p.startLineNumber,p.startColumn,f.endLineNumber,f.endColumn));s.push(r);const l=t.getModel();if(l===null)return;const d=[],h=[];let u=n,g=0;for(let p=0,f=s.length;p<f;p++){const m=s[p],_=m.startLineNumber,v=1;let b=0,C,y;const I=l.getLineLength(m.endLineNumber)-m.endColumn;if(m.isEmpty()||m.startLineNumber===m.endLineNumber){const w=m.getStartPosition();w.lineNumber<l.getLineCount()?(C=_+1,y=l.getLineMaxColumn(C)):(C=w.lineNumber,y=l.getLineMaxColumn(w.lineNumber))}else C=m.endLineNumber,y=l.getLineMaxColumn(C);let x=l.getLineContent(_);for(let w=_+1;w<=C;w++){const E=l.getLineContent(w),L=l.getLineFirstNonWhitespaceColumn(w);if(L>=1){let R=!0;x===""&&(R=!1),R&&(x.charAt(x.length-1)===" "||x.charAt(x.length-1)===" ")&&(R=!1,x=x.replace(/[\s\uFEFF\xA0]+$/g," "));const D=E.substr(L-1);x+=(R?" ":"")+D,R?b=D.length+1:b=D.length}else b=0}const S=new a.Range(_,v,C,y);if(!S.isEmpty()){let w;m.isEmpty()?(d.push(o.EditOperation.replace(S,x)),w=new a.Selection(S.startLineNumber-g,x.length-b+1,_-g,x.length-b+1)):m.startLineNumber===m.endLineNumber?(d.push(o.EditOperation.replace(S,x)),w=new a.Selection(m.startLineNumber-g,m.startColumn,m.endLineNumber-g,m.endColumn)):(d.push(o.EditOperation.replace(S,x)),w=new a.Selection(m.startLineNumber-g,m.startColumn,m.startLineNumber-g,x.length-I)),a.Range.intersectRanges(S,n)!==null?u=w:h.push(w)}g+=S.endLineNumber-S.startLineNumber}h.unshift(u),t.pushUndoStop(),t.executeEdits(this.id,d,h),t.pushUndoStop()}}class dE extends o.EditorAction{constructor(){super({id:"editor.action.transpose",label:a.localize2(1333,"Transpose Characters around the Cursor"),precondition:o.EditorContextKeys.writable,canTriggerInlineEdits:!0})}run(e,t){const i=t.getSelections();if(i===null)return;const n=t.getModel();if(n===null)return;const s=[];for(let r=0,l=i.length;r<l;r++){const d=i[r];if(!d.isEmpty())continue;const h=d.getStartPosition(),u=n.getLineMaxColumn(h.lineNumber);if(h.column>=u){if(h.lineNumber===n.getLineCount())continue;const g=new a.Range(h.lineNumber,Math.max(1,h.column-1),h.lineNumber+1,1),p=n.getValueInRange(g).split("").reverse().join("");s.push(new o.ReplaceCommand(new a.Selection(h.lineNumber,Math.max(1,h.column-1),h.lineNumber+1,1),p))}else{const g=new a.Range(h.lineNumber,Math.max(1,h.column-1),h.lineNumber,h.column+1),p=n.getValueInRange(g).split("").reverse().join("");s.push(new o.ReplaceCommandThatPreservesSelection(g,p,new a.Selection(h.lineNumber,h.column+1,h.lineNumber,h.column+1)))}}t.pushUndoStop(),t.executeCommands(this.id,s),t.pushUndoStop()}}class cn extends o.EditorAction{run(e,t){const i=t.getSelections();if(i===null)return;const n=t.getModel();if(n===null)return;const s=t.getOption(148),r=[];for(const l of i)if(l.isEmpty()){const d=l.getStartPosition(),h=t.getConfiguredWordAtPosition(d);if(!h)continue;const u=new a.Range(d.lineNumber,h.startColumn,d.lineNumber,h.endColumn),g=n.getValueInRange(u);r.push(o.EditOperation.replace(u,this._modifyText(g,s)))}else{const d=n.getValueInRange(l);r.push(o.EditOperation.replace(l,this._modifyText(d,s)))}t.pushUndoStop(),t.executeEdits(this.id,r),t.pushUndoStop()}}class hE extends cn{constructor(){super({id:"editor.action.transformToUppercase",label:a.localize2(1334,"Transform to Uppercase"),precondition:o.EditorContextKeys.writable,canTriggerInlineEdits:!0})}_modifyText(e,t){return e.toLocaleUpperCase()}}class uE extends cn{constructor(){super({id:"editor.action.transformToLowercase",label:a.localize2(1335,"Transform to Lowercase"),precondition:o.EditorContextKeys.writable,canTriggerInlineEdits:!0})}_modifyText(e,t){return e.toLocaleLowerCase()}}class Ve{constructor(e,t){this._pattern=e,this._flags=t,this._actual=null,this._evaluated=!1}get(){if(!this._evaluated){this._evaluated=!0;try{this._actual=new RegExp(this._pattern,this._flags)}catch{}}return this._actual}isSupported(){return this.get()!==null}}const Vc=class Vc extends cn{constructor(){super({id:"editor.action.transformToTitlecase",label:a.localize2(1336,"Transform to Title Case"),precondition:o.EditorContextKeys.writable,canTriggerInlineEdits:!0})}_modifyText(e,t){const i=Vc.titleBoundary.get();return i?e.toLocaleLowerCase().replace(i,n=>n.toLocaleUpperCase()):e}};Vc.titleBoundary=new Ve("(^|[^\\p{L}\\p{N}']|((^|\\P{L})'))\\p{L}","gmu");let ol=Vc;const so=class so extends cn{constructor(){super({id:"editor.action.transformToSnakecase",label:a.localize2(1337,"Transform to Snake Case"),precondition:o.EditorContextKeys.writable,canTriggerInlineEdits:!0})}_modifyText(e,t){const i=so.caseBoundary.get(),n=so.singleLetters.get();return!i||!n?e:e.replace(i,"$1_$2").replace(n,"$1_$2$3").toLocaleLowerCase()}};so.caseBoundary=new Ve("(\\p{Ll})(\\p{Lu})","gmu"),so.singleLetters=new Ve("(\\p{Lu}|\\p{N})(\\p{Lu})(\\p{Ll})","gmu");let Wo=so;const xi=class xi extends cn{constructor(){super({id:"editor.action.transformToCamelcase",label:a.localize2(1338,"Transform to Camel Case"),precondition:o.EditorContextKeys.writable,canTriggerInlineEdits:!0})}_modifyText(e,t){const i=/\r\n|\r|\n/.test(e)?xi.multiLineWordBoundary.get():xi.singleLineWordBoundary.get(),n=xi.validWordStart.get();if(!i||!n)return e;const s=e.split(i);return s.shift()?.replace(n,l=>l.toLocaleLowerCase())+s.map(l=>l.substring(0,1).toLocaleUpperCase()+l.substring(1)).join("")}};xi.singleLineWordBoundary=new Ve("[_\\s-]+","gm"),xi.multiLineWordBoundary=new Ve("[_-]+","gm"),xi.validWordStart=new Ve("^(\\p{Lu}[^\\p{Lu}])","gmu");let Ho=xi;const Ei=class Ei extends cn{constructor(){super({id:"editor.action.transformToPascalcase",label:a.localize2(1339,"Transform to Pascal Case"),precondition:o.EditorContextKeys.writable,canTriggerInlineEdits:!0})}_modifyText(e,t){const i=Ei.wordBoundary.get(),n=Ei.wordBoundaryToMaintain.get(),s=Ei.upperCaseWordMatcher.get();return!i||!n||!s?e:e.split(n).map(d=>d.split(i)).flat().map(d=>{const h=d.charAt(0).toLocaleUpperCase()+d.slice(1);return h.length>1&&s.test(h)?h.charAt(0)+h.slice(1).toLocaleLowerCase():h}).join("")}};Ei.wordBoundary=new Ve("[_ \\t-]","gm"),Ei.wordBoundaryToMaintain=new Ve("(?<=\\.)","gm"),Ei.upperCaseWordMatcher=new Ve("^\\p{Lu}+$","mu");let rl=Ei;const Li=class Li extends cn{static isSupported(){return[this.caseBoundary,this.singleLetters,this.underscoreBoundary].every(t=>t.isSupported())}constructor(){super({id:"editor.action.transformToKebabcase",label:a.localize2(1340,"Transform to Kebab Case"),precondition:o.EditorContextKeys.writable,canTriggerInlineEdits:!0})}_modifyText(e,t){const i=Li.caseBoundary.get(),n=Li.singleLetters.get(),s=Li.underscoreBoundary.get();return!i||!n||!s?e:e.replace(s,"$1-$3").replace(i,"$1-$2").replace(n,"$1-$2").toLocaleLowerCase()}};Li.caseBoundary=new Ve("(\\p{Ll})(\\p{Lu})","gmu"),Li.singleLetters=new Ve("(\\p{Lu}|\\p{N})(\\p{Lu}\\p{Ll})","gmu"),Li.underscoreBoundary=new Ve("(\\S)(_)(\\S)","gm");let al=Li;o.registerEditorAction(Yx),o.registerEditorAction(Qx),o.registerEditorAction(Jx),o.registerEditorAction(Wx),o.registerEditorAction(Hx),o.registerEditorAction(eE),o.registerEditorAction(tE),o.registerEditorAction(iE),o.registerEditorAction(Pu),o.registerEditorAction(sE),o.registerEditorAction(oE),o.registerEditorAction(rE),o.registerEditorAction(nl),o.registerEditorAction(sl),o.registerEditorAction(aE),o.registerEditorAction(lE),o.registerEditorAction(cE),o.registerEditorAction(dE),o.registerEditorAction(hE),o.registerEditorAction(uE),o.registerEditorAction(nE),Wo.caseBoundary.isSupported()&&Wo.singleLetters.isSupported()&&o.registerEditorAction(Wo),Ho.singleLineWordBoundary.isSupported()&&Ho.multiLineWordBoundary.isSupported()&&o.registerEditorAction(Ho),rl.wordBoundary.isSupported()&&o.registerEditorAction(rl),ol.titleBoundary.isSupported()&&o.registerEditorAction(ol),al.isSupported()&&o.registerEditorAction(al);var gE=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},iv=function(c,e){return function(t,i){e(t,i,c)}};function pE(c){return c.sourceId+" @@ "+JSON.stringify({...c,modelUri:c.modelUri?.toString(),sourceId:void 0})}let ll=class extends a.Disposable{static cast(){return this}constructor(e,t,i){super(),this._key=e,this._contextKeyService=t,this._dataChannelService=i,this._isEnabledContextKeyValue=fE("structuredLogger.enabled:"+this._key,this._contextKeyService).recomputeInitiallyAndOnChange(this._store),this.isEnabled=this._isEnabledContextKeyValue.map(n=>n!==void 0)}log(e){return this._isEnabledContextKeyValue.get()?(this._dataChannelService.getDataChannel("structuredLogger:"+this._key).sendData(e),!0):!1}};ll=gE([iv(1,o.IContextKeyService),iv(2,o.IDataChannelService)],ll);function fE(c,e){return o.observableFromEvent(e.onDidChangeContext,()=>e.getContextKeyValue(c))}var mE=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},nv=function(c,e){return function(t,i){e(t,i,c)}};let Ou=class extends a.Disposable{constructor(e,t,i){super(),this._editor=e,this._instantiationService=t,this._loggerService=i,this._structuredLogger=this._register(this._instantiationService.createInstance(ll.cast(),"editor.inlineSuggest.logChangeReason.commandId"));const n=this._loggerService?.createLogger("textModelChanges",{hidden:!1,name:"Text Model Changes Reason"}),s=o.observableFromEvent(this,n.onDidChangeLogLevel,()=>n.getLevel());this._register(o.autorun(r=>{o.canLog(s.read(r),o.LogLevel.Trace)&&r.store.add(this._editor.onDidChangeModelContent(l=>{this._editor.getModel()?.uri.scheme!=="output"&&n.trace("onDidChangeModelContent: "+l.detailedReasons.map(d=>d.toKey(Number.MAX_VALUE)).join(", "))}))})),this._register(o.autorun(r=>{this._editor instanceof o.CodeEditorWidget&&this._structuredLogger.isEnabled.read(r)&&r.store.add(this._editor.onDidChangeModelContent(l=>{const d=this._editor.getModel();if(!d)return;const h=l.detailedReasons[0],u={...h.metadata,sourceId:"TextModel.setChangeReason",source:h.metadata.source,time:Date.now(),modelUri:d.uri,modelVersion:d.getVersionId()};setTimeout(()=>{this._structuredLogger.log(u)},0)}))}))}};Ou=mE([nv(1,o.IInstantiationService),nv(2,o.ILoggerService)],Ou);function sv(c,e=a.isWindows){return o.hasDriveLetter(c,e)?c.charAt(0).toUpperCase()+c.slice(1):c}var _E=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},vE=function(c,e){return function(t,i){e(t,i,c)}};class ov{constructor(e){this._delegates=e}resolve(e){for(const t of this._delegates){const i=t.resolve(e);if(i!==void 0)return i}}}class rv{constructor(e,t,i,n){this._model=e,this._selection=t,this._selectionIdx=i,this._overtypingCapturer=n}resolve(e){const{name:t}=e;if(t==="SELECTION"||t==="TM_SELECTED_TEXT"){let i=this._model.getValueInRange(this._selection)||void 0,n=this._selection.startLineNumber!==this._selection.endLineNumber;if(!i&&this._overtypingCapturer){const s=this._overtypingCapturer.getLastOvertypedInfo(this._selectionIdx);s&&(i=s.value,n=s.multiline)}if(i&&n&&e.snippet){const s=this._model.getLineContent(this._selection.startLineNumber),r=a.getLeadingWhitespace(s,0,this._selection.startColumn-1);let l=r;e.snippet.walk(h=>h===e?!1:(h instanceof le&&(l=a.getLeadingWhitespace(a.splitLines(h.value).pop())),!0));const d=a.commonPrefixLength(l,r);i=i.replace(/(\r\n|\r|\n)(.*)/g,(h,u,g)=>`${u}${l.substr(d)}${g}`)}return i}else{if(t==="TM_CURRENT_LINE")return this._model.getLineContent(this._selection.positionLineNumber);if(t==="TM_CURRENT_WORD"){const i=this._model.getWordAtPosition({lineNumber:this._selection.positionLineNumber,column:this._selection.positionColumn});return i&&i.word||void 0}else{if(t==="TM_LINE_INDEX")return String(this._selection.positionLineNumber-1);if(t==="TM_LINE_NUMBER")return String(this._selection.positionLineNumber);if(t==="CURSOR_INDEX")return String(this._selectionIdx);if(t==="CURSOR_NUMBER")return String(this._selectionIdx+1)}}}}class av{constructor(e,t){this._labelService=e,this._model=t}resolve(e){const{name:t}=e;if(t==="TM_FILENAME")return a.basename(this._model.uri.fsPath);if(t==="TM_FILENAME_BASE"){const i=a.basename(this._model.uri.fsPath),n=i.lastIndexOf(".");return n<=0?i:i.slice(0,n)}else{if(t==="TM_DIRECTORY")return a.dirname(this._model.uri.fsPath)==="."?"":this._labelService.getUriLabel(o.dirname(this._model.uri));if(t==="TM_DIRECTORY_BASE")return a.dirname(this._model.uri.fsPath)==="."?"":a.basename(a.dirname(this._model.uri.fsPath));if(t==="TM_FILEPATH")return this._labelService.getUriLabel(this._model.uri);if(t==="RELATIVE_FILEPATH")return this._labelService.getUriLabel(this._model.uri,{relative:!0,noPrefix:!0})}}}class lv{constructor(e,t,i,n){this._readClipboardText=e,this._selectionIdx=t,this._selectionCount=i,this._spread=n}resolve(e){if(e.name!=="CLIPBOARD")return;const t=this._readClipboardText();if(t){if(this._spread){const i=t.split(/\r\n|\n|\r/).filter(n=>!a.isFalsyOrWhitespace(n));if(i.length===this._selectionCount)return i[this._selectionIdx]}return t}}}let cl=class{constructor(e,t,i){this._model=e,this._selection=t,this._languageConfigurationService=i}resolve(e){const{name:t}=e,i=this._model.getLanguageIdAtPosition(this._selection.selectionStartLineNumber,this._selection.selectionStartColumn),n=this._languageConfigurationService.getLanguageConfiguration(i).comments;if(n){if(t==="LINE_COMMENT")return n.lineCommentToken||void 0;if(t==="BLOCK_COMMENT_START")return n.blockCommentStartToken||void 0;if(t==="BLOCK_COMMENT_END")return n.blockCommentEndToken||void 0}}};cl=_E([vE(2,o.ILanguageConfigurationService)],cl);const vt=class vt{constructor(){this._date=new Date}resolve(e){const{name:t}=e;switch(t){case"CURRENT_YEAR":return String(this._date.getFullYear());case"CURRENT_YEAR_SHORT":return String(this._date.getFullYear()).slice(-2);case"CURRENT_MONTH":return String(this._date.getMonth().valueOf()+1).padStart(2,"0");case"CURRENT_DATE":return String(this._date.getDate().valueOf()).padStart(2,"0");case"CURRENT_HOUR":return String(this._date.getHours().valueOf()).padStart(2,"0");case"CURRENT_MINUTE":return String(this._date.getMinutes().valueOf()).padStart(2,"0");case"CURRENT_SECOND":return String(this._date.getSeconds().valueOf()).padStart(2,"0");case"CURRENT_MILLISECOND":return String(this._date.getMilliseconds().valueOf()).padStart(3,"0");case"CURRENT_DAY_NAME":return vt.dayNames[this._date.getDay()];case"CURRENT_DAY_NAME_SHORT":return vt.dayNamesShort[this._date.getDay()];case"CURRENT_MONTH_NAME":return vt.monthNames[this._date.getMonth()];case"CURRENT_MONTH_NAME_SHORT":return vt.monthNamesShort[this._date.getMonth()];case"CURRENT_SECONDS_UNIX":return String(Math.floor(this._date.getTime()/1e3));case"CURRENT_MILLISECONDS_UNIX":return String(this._date.getTime());case"CURRENT_TIMEZONE_OFFSET":{const i=this._date.getTimezoneOffset(),n=i>0?"-":"+",s=Math.trunc(Math.abs(i/60)),r=s<10?"0"+s:s,l=Math.abs(i)-s*60,d=l<10?"0"+l:l;return n+r+":"+d}case"CURRENT_TIMEZONE_NAME":return this._timezoneName??=Intl.DateTimeFormat().resolvedOptions().timeZone}}};vt.dayNames=[a.localize(1476,"Sunday"),a.localize(1477,"Monday"),a.localize(1478,"Tuesday"),a.localize(1479,"Wednesday"),a.localize(1480,"Thursday"),a.localize(1481,"Friday"),a.localize(1482,"Saturday")],vt.dayNamesShort=[a.localize(1483,"Sun"),a.localize(1484,"Mon"),a.localize(1485,"Tue"),a.localize(1486,"Wed"),a.localize(1487,"Thu"),a.localize(1488,"Fri"),a.localize(1489,"Sat")],vt.monthNames=[a.localize(1490,"January"),a.localize(1491,"February"),a.localize(1492,"March"),a.localize(1493,"April"),a.localize(1494,"May"),a.localize(1495,"June"),a.localize(1496,"July"),a.localize(1497,"August"),a.localize(1498,"September"),a.localize(1499,"October"),a.localize(1500,"November"),a.localize(1501,"December")],vt.monthNamesShort=[a.localize(1502,"Jan"),a.localize(1503,"Feb"),a.localize(1504,"Mar"),a.localize(1505,"Apr"),a.localize(1506,"May"),a.localize(1507,"Jun"),a.localize(1508,"Jul"),a.localize(1509,"Aug"),a.localize(1510,"Sep"),a.localize(1511,"Oct"),a.localize(1512,"Nov"),a.localize(1513,"Dec")];let dl=vt;class cv{constructor(e){this._workspaceService=e}resolve(e){if(!this._workspaceService)return;const t=o.toWorkspaceIdentifier(this._workspaceService.getWorkspace());if(!o.isEmptyWorkspaceIdentifier(t)){if(e.name==="WORKSPACE_NAME")return this._resolveWorkspaceName(t);if(e.name==="WORKSPACE_FOLDER")return this._resoveWorkspacePath(t)}}_resolveWorkspaceName(e){if(o.isSingleFolderWorkspaceIdentifier(e))return a.basename(e.uri.path);let t=a.basename(e.configPath.path);return t.endsWith(o.WORKSPACE_EXTENSION)&&(t=t.substr(0,t.length-o.WORKSPACE_EXTENSION.length-1)),t}_resoveWorkspacePath(e){if(o.isSingleFolderWorkspaceIdentifier(e))return sv(e.uri.fsPath);const t=a.basename(e.configPath.path);let i=e.configPath.fsPath;return i.endsWith(t)&&(i=i.substr(0,i.length-t.length-1)),i?sv(i):"/"}}class dv{resolve(e){const{name:t}=e;if(t==="RANDOM")return Math.random().toString().slice(-6);if(t==="RANDOM_HEX")return Math.random().toString(16).slice(-6);if(t==="UUID")return o.generateUuid()}}var bE=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},CE=function(c,e){return function(t,i){e(t,i,c)}},Je;const $e=class $e{constructor(e,t,i){this._editor=e,this._snippet=t,this._snippetLineLeadingWhitespace=i,this._offset=-1,this._nestingLevel=1,this._placeholderGroups=a.groupBy(t.placeholders,Re.compareByIndex),this._placeholderGroupsIdx=-1}initialize(e){this._offset=e.newPosition}dispose(){this._placeholderDecorations&&this._editor.removeDecorations([...this._placeholderDecorations.values()]),this._placeholderGroups.length=0}_initDecorations(){if(this._offset===-1)throw new Error("Snippet not initialized!");if(this._placeholderDecorations)return;this._placeholderDecorations=new Map;const e=this._editor.getModel();this._editor.changeDecorations(t=>{for(const i of this._snippet.placeholders){const n=this._snippet.offset(i),s=this._snippet.fullLen(i),r=a.Range.fromPositions(e.getPositionAt(this._offset+n),e.getPositionAt(this._offset+n+s)),l=i.isFinalTabstop?$e._decor.inactiveFinal:$e._decor.inactive,d=t.addDecoration(r,l);this._placeholderDecorations.set(i,d)}})}move(e){if(!this._editor.hasModel())return[];this._initDecorations();const t=this._editor.getModel();if(this._placeholderGroupsIdx>=0){const s=[];for(const r of this._placeholderGroups[this._placeholderGroupsIdx])if(r.transform){const l=this._placeholderDecorations.get(r),d=l?t.getDecorationRange(l):null;if(d){const h=t.getValueInRange(d),u=r.transform.resolve(h).split(/\r\n|\r|\n/);for(let g=1;g<u.length;g++)u[g]=t.normalizeIndentation(this._snippetLineLeadingWhitespace+u[g]);s.push(o.EditOperation.replace(d,u.join(t.getEOL())))}}s.length>0&&this._editor.executeEdits("snippet.placeholderTransform",s)}let i=!1;e===!0&&this._placeholderGroupsIdx<this._placeholderGroups.length-1?(this._placeholderGroupsIdx+=1,i=!0):e===!1&&this._placeholderGroupsIdx>0&&(this._placeholderGroupsIdx-=1,i=!0);const n=t.changeDecorations(s=>{const r=new Set,l=[];for(const d of this._placeholderGroups[this._placeholderGroupsIdx]){const h=this._placeholderDecorations.get(d),u=h?t.getDecorationRange(h):null;if(i=i&&this._hasPlaceholderBeenCollapsed(d),!(!h||!u)){l.push(new a.Selection(u.startLineNumber,u.startColumn,u.endLineNumber,u.endColumn)),s.changeDecorationOptions(h,d.isFinalTabstop?$e._decor.activeFinal:$e._decor.active),r.add(d);for(const g of this._snippet.enclosingPlaceholders(d)){const p=this._placeholderDecorations.get(g);p&&(s.changeDecorationOptions(p,g.isFinalTabstop?$e._decor.activeFinal:$e._decor.active),r.add(g))}}}for(const[d,h]of this._placeholderDecorations)r.has(d)||s.changeDecorationOptions(h,d.isFinalTabstop?$e._decor.inactiveFinal:$e._decor.inactive);return l});return i?this.move(e):n??[]}_hasPlaceholderBeenCollapsed(e){const t=this._editor.getModel();let i=e;for(;i;){if(i instanceof Re){const n=this._placeholderDecorations.get(i),s=n?t.getDecorationRange(n):null;if((!s||s.isEmpty())&&i.toString().length>0)return!0}i=i.parent}return!1}get isAtFirstPlaceholder(){return this._placeholderGroupsIdx<=0||this._placeholderGroups.length===0}get isAtLastPlaceholder(){return this._placeholderGroupsIdx===this._placeholderGroups.length-1}get hasPlaceholder(){return this._snippet.placeholders.length>0}get isTrivialSnippet(){if(this._snippet.placeholders.length===0)return!0;if(this._snippet.placeholders.length===1){const[e]=this._snippet.placeholders;if(e.isFinalTabstop&&this._snippet.rightMostDescendant===e)return!0}return!1}computePossibleSelections(){const e=new Map;for(const t of this._placeholderGroups){let i;for(const n of t){if(n.isFinalTabstop)break;i||(i=[],e.set(n.index,i));const s=this._placeholderDecorations.get(n),r=this._editor.getModel().getDecorationRange(s);if(!r){e.delete(n.index);break}i.push(r)}}return e}get activeChoice(){if(!this._placeholderDecorations)return;const e=this._placeholderGroups[this._placeholderGroupsIdx][0];if(!e?.choice)return;const t=this._placeholderDecorations.get(e);if(!t)return;const i=this._editor.getModel().getDecorationRange(t);if(i)return{range:i,choice:e.choice}}get hasChoice(){let e=!1;return this._snippet.walk(t=>(e=t instanceof as,!e)),e}get activePlaceholderCount(){return this._placeholderGroupsIdx<0?0:this._placeholderGroups[this._placeholderGroupsIdx].length}merge(e){const t=this._editor.getModel();this._nestingLevel*=10,this._editor.changeDecorations(i=>{for(const n of this._placeholderGroups[this._placeholderGroupsIdx]){const s=e.shift();console.assert(s._offset!==-1),console.assert(!s._placeholderDecorations);const r=s._snippet.placeholderInfo.last.index;for(const d of s._snippet.placeholderInfo.all)d.isFinalTabstop?d.index=n.index+(r+1)/this._nestingLevel:d.index=n.index+d.index/this._nestingLevel;this._snippet.replace(n,s._snippet.children);const l=this._placeholderDecorations.get(n);i.removeDecoration(l),this._placeholderDecorations.delete(n);for(const d of s._snippet.placeholders){const h=s._snippet.offset(d),u=s._snippet.fullLen(d),g=a.Range.fromPositions(t.getPositionAt(s._offset+h),t.getPositionAt(s._offset+h+u)),p=i.addDecoration(g,$e._decor.inactive);this._placeholderDecorations.set(d,p)}}this._renormalizePlaceholderIndices(),this._placeholderGroups=a.groupBy(this._snippet.placeholders,Re.compareByIndex)})}_renormalizePlaceholderIndices(){const e=this._snippet.placeholders,t=new Set;for(const s of e)s.isFinalTabstop||t.add(s.index);const i=[...t].sort((s,r)=>s-r),n=new Map;for(let s=0;s<i.length;s++)n.set(i[s],s+1);for(const s of e)s.isFinalTabstop||(s.index=n.get(s.index));this._nestingLevel=1}};$e._decor={active:o.ModelDecorationOptions.register({description:"snippet-placeholder-1",stickiness:0,className:"snippet-placeholder"}),inactive:o.ModelDecorationOptions.register({description:"snippet-placeholder-2",stickiness:1,className:"snippet-placeholder"}),activeFinal:o.ModelDecorationOptions.register({description:"snippet-placeholder-3",stickiness:1,className:"finish-snippet-placeholder"}),inactiveFinal:o.ModelDecorationOptions.register({description:"snippet-placeholder-4",stickiness:1,className:"finish-snippet-placeholder"})};let hl=$e;const hv={overwriteBefore:0,overwriteAfter:0,adjustWhitespace:!0,clipboardText:void 0,overtypingCapturer:void 0};let ul=Je=class{static adjustWhitespace(e,t,i,n,s){const r=e.getLineContent(t.lineNumber),l=a.getLeadingWhitespace(r,0,t.column-1);let d;return n.walk(h=>{if(!(h instanceof le)||h.parent instanceof as||s&&!s.has(h))return!0;const u=h.value.split(/\r\n|\r|\n/);if(i){const p=n.offset(h);if(p===0)u[0]=e.normalizeIndentation(u[0]);else{d=d??n.toString();const f=d.charCodeAt(p-1);(f===10||f===13)&&(u[0]=e.normalizeIndentation(l+u[0]))}for(let f=1;f<u.length;f++)u[f]=e.normalizeIndentation(l+u[f])}const g=u.join(e.getEOL());return g!==h.value&&(h.parent.replace(h,[new le(g)]),d=void 0),!0}),l}static adjustSelection(e,t,i,n){if(i!==0||n!==0){const{positionLineNumber:s,positionColumn:r}=t,l=r-i,d=r+n,h=e.validateRange({startLineNumber:s,startColumn:l,endLineNumber:s,endColumn:d});t=a.Selection.createWithDirection(h.startLineNumber,h.startColumn,h.endLineNumber,h.endColumn,t.getDirection())}return t}static createEditsAndSnippetsFromSelections(e,t,i,n,s,r,l,d,h){const u=[],g=[];if(!e.hasModel())return{edits:u,snippets:g};const p=e.getModel(),f=e.invokeWithinContext(I=>I.get(o.IWorkspaceContextService)),m=e.invokeWithinContext(I=>new av(I.get(o.ILabelService),p)),_=()=>l,v=p.getValueInRange(Je.adjustSelection(p,e.getSelection(),i,0)),b=p.getValueInRange(Je.adjustSelection(p,e.getSelection(),0,n)),C=p.getLineFirstNonWhitespaceColumn(e.getSelection().positionLineNumber),y=e.getSelections().map((I,x)=>({selection:I,idx:x})).sort((I,x)=>a.Range.compareRangesUsingStarts(I.selection,x.selection));for(const{selection:I,idx:x}of y){let S=Je.adjustSelection(p,I,i,0),w=Je.adjustSelection(p,I,0,n);v!==p.getValueInRange(S)&&(S=I),b!==p.getValueInRange(w)&&(w=I);const E=I.setStartPosition(S.startLineNumber,S.startColumn).setEndPosition(w.endLineNumber,w.endColumn),L=new Ui().parse(t,!0,s),R=E.getStartPosition(),D=Je.adjustWhitespace(p,R,r||x>0&&C!==p.getLineFirstNonWhitespaceColumn(I.positionLineNumber),L);L.resolveVariables(new ov([m,new lv(_,x,y.length,e.getOption(88)==="spread"),new rv(p,I,x,d),new cl(p,I,h),new dl,new cv(f),new dv])),u[x]=o.EditOperation.replace(E,L.toString()),u[x].identifier={major:x,minor:0},u[x]._isTracked=!0,g[x]=new hl(e,L,D)}return{edits:u,snippets:g}}static createEditsAndSnippetsFromEdits(e,t,i,n,s,r,l){if(!e.hasModel()||t.length===0)return{edits:[],snippets:[]};const d=[],h=e.getModel(),u=new Ui,g=new vo,p=e.invokeWithinContext(I=>new av(I.get(o.ILabelService),h)),f=new dl,m=new cv(e.invokeWithinContext(I=>I.get(o.IWorkspaceContextService))),_=new dv,v=()=>s,b=e.getOption(88)==="spread",C=t.map((I,x)=>({edit:I,idx:x})).sort((I,x)=>a.Range.compareRangesUsingStarts(I.edit.range,x.edit.range));let y=0;for(let I=0;I<C.length;I++){const{edit:{range:x,template:S,keepWhitespace:w},idx:E}=C[I];if(I>0){const F=C[I-1].edit.range,K=a.Range.fromPositions(F.getEndPosition(),x.getStartPosition()),O=new le(h.getValueInRange(K));g.appendChild(O),y+=O.value.length}const L=new Set;g.walk(F=>(F instanceof ki&&L.add(F),!0));const R=u.parseFragment(S,g);Je.adjustWhitespace(h,x.getStartPosition(),w!==void 0?!w:n,g,new Set(R));const D=a.Selection.fromRange(x,0),T=new ov([p,new lv(v,E,C.length,b),new rv(h,D,E,r),new cl(h,D,l),f,m,_]);g.walk(F=>(F instanceof ki&&!L.has(F)&&F.resolve(T),!0));const P=g.toString(),M=P.slice(y);y=P.length;const V=o.EditOperation.replace(x,M);V.identifier={major:I,minor:0},V._isTracked=!0,d.push(V)}return u.ensureFinalTabstop(g,i,!0),{edits:d,snippets:[new hl(e,g,"")]}}constructor(e,t,i=hv,n){this._editor=e,this._template=t,this._options=i,this._languageConfigurationService=n,this._templateMerges=[],this._snippets=[]}dispose(){a.dispose(this._snippets)}_logInfo(){return`template="${this._template}", merged_templates="${this._templateMerges.join(" -> ")}"`}insert(e){if(!this._editor.hasModel())return;const{edits:t,snippets:i}=typeof this._template=="string"?Je.createEditsAndSnippetsFromSelections(this._editor,this._template,this._options.overwriteBefore,this._options.overwriteAfter,!1,this._options.adjustWhitespace,this._options.clipboardText,this._options.overtypingCapturer,this._languageConfigurationService):Je.createEditsAndSnippetsFromEdits(this._editor,this._template,!1,this._options.adjustWhitespace,this._options.clipboardText,this._options.overtypingCapturer,this._languageConfigurationService);this._snippets=i,this._editor.executeEdits(e??o.EditSources.snippet(),t,n=>{const s=n.filter(r=>!!r.identifier);for(let r=0;r<i.length;r++)i[r].initialize(s[r].textChange);return this._snippets[0].hasPlaceholder?this._move(!0):s.map(r=>a.Selection.fromPositions(r.range.getEndPosition()))}),this._editor.revealRange(this._editor.getSelections()[0])}merge(e,t=hv){if(!this._editor.hasModel())return;this._templateMerges.push([this._snippets[0]._nestingLevel,this._snippets[0]._placeholderGroupsIdx,e]);const{edits:i,snippets:n}=Je.createEditsAndSnippetsFromSelections(this._editor,e,t.overwriteBefore,t.overwriteAfter,!0,t.adjustWhitespace,t.clipboardText,t.overtypingCapturer,this._languageConfigurationService);this._editor.executeEdits("snippet",i,s=>{const r=s.filter(h=>!!h.identifier);for(let h=0;h<n.length;h++)n[h].initialize(r[h].textChange);const l=n[0].isTrivialSnippet,d=n.length===this._snippets.reduce((h,u)=>h+u.activePlaceholderCount,0);if(!l&&d){for(const h of this._snippets)h.merge(n);console.assert(n.length===0)}return this._snippets[0].hasPlaceholder&&!l&&d?this._move(void 0):r.map(h=>a.Selection.fromPositions(h.range.getEndPosition()))})}next(){const e=this._move(!0);e.length>0&&(this._editor.setSelections(e),this._editor.revealPositionInCenterIfOutsideViewport(e[0].getPosition()))}prev(){const e=this._move(!1);e.length>0&&(this._editor.setSelections(e),this._editor.revealPositionInCenterIfOutsideViewport(e[0].getPosition()))}_move(e){const t=[];for(const i of this._snippets){const n=i.move(e);t.push(...n)}return t}get isAtFirstPlaceholder(){return this._snippets[0].isAtFirstPlaceholder}get isAtLastPlaceholder(){return this._snippets[0].isAtLastPlaceholder}get hasPlaceholder(){return this._snippets[0].hasPlaceholder}get hasChoice(){return this._snippets[0].hasChoice}get activeChoice(){return this._snippets[0].activeChoice}isSelectionWithinPlaceholders(){if(!this.hasPlaceholder)return!1;const e=this._editor.getSelections();if(e.length<this._snippets.length)return!1;const t=new Map;for(const i of this._snippets){const n=i.computePossibleSelections();if(t.size===0)for(const[s,r]of n){r.sort(a.Range.compareRangesUsingStarts);for(const l of e)if(r[0].containsRange(l)){t.set(s,[]);break}}if(t.size===0)return!1;t.forEach((s,r)=>{s.push(...n.get(r))})}e.sort(a.Range.compareRangesUsingStarts);for(const[i,n]of t){if(n.length!==e.length){t.delete(i);continue}n.sort(a.Range.compareRangesUsingStarts);for(let s=0;s<n.length;s++)if(!n[s].containsRange(e[s])){t.delete(i);continue}}return t.size>0}};ul=Je=bE([CE(3,o.ILanguageConfigurationService)],ul);var SE=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},gl=function(c,e){return function(t,i){e(t,i,c)}},dn;const uv={overwriteBefore:0,overwriteAfter:0,undoStopBefore:!0,undoStopAfter:!0,adjustWhitespace:!0,clipboardText:void 0,overtypingCapturer:void 0};let ne=(it=class{static get(e){return e.getContribution(dn.ID)}constructor(e,t,i,n,s){this._editor=e,this._logService=t,this._languageFeaturesService=i,this._languageConfigurationService=s,this._inSnippetObservable=o.observableValue(this,!1),this._snippetListener=new a.DisposableStore,this._modelVersionId=-1,this._inSnippet=dn.InSnippetMode.bindTo(n),this._hasNextTabstop=dn.HasNextTabstop.bindTo(n),this._hasPrevTabstop=dn.HasPrevTabstop.bindTo(n),this._inSnippetChoice=dn.InSnippetChoice.bindTo(n)}dispose(){this._inSnippet.reset(),this._inSnippetObservable.set(!1,void 0),this._hasPrevTabstop.reset(),this._hasNextTabstop.reset(),this._inSnippetChoice.reset(),this._session?.dispose(),this._snippetListener.dispose()}insert(e,t){try{this._doInsert(e,typeof t>"u"?uv:{...uv,...t})}catch(i){this.cancel(),this._logService.error(i),this._logService.error("snippet_error"),this._logService.error("insert_template=",e),this._logService.error("existing_template=",this._session?this._session._logInfo():"<no_session>")}}_doInsert(e,t){if(this._editor.hasModel()){if(this._snippetListener.clear(),t.undoStopBefore&&this._editor.getModel().pushStackElement(),this._session&&typeof e!="string"&&this.cancel(),this._session?(a.assertType(typeof e=="string"),this._session.merge(e,t)):(this._modelVersionId=this._editor.getModel().getAlternativeVersionId(),this._session=new ul(this._editor,e,t,this._languageConfigurationService),this._session.insert(t.reason)),t.undoStopAfter&&this._editor.getModel().pushStackElement(),this._session?.hasChoice){const i={_debugDisplayName:"snippetChoiceCompletions",provideCompletionItems:(h,u)=>{if(!this._session||h!==this._editor.getModel()||!a.Position.equals(this._editor.getPosition(),u))return;const{activeChoice:g}=this._session;if(!g||g.choice.options.length===0)return;const p=h.getValueInRange(g.range),f=!!g.choice.options.find(_=>_.value===p),m=[];for(let _=0;_<g.choice.options.length;_++){const v=g.choice.options[_];m.push({kind:13,label:v.value,insertText:v.value,sortText:"a".repeat(_+1),range:g.range,filterText:f?`${p}_${v.value}`:void 0,command:{id:"jumpToNextSnippetPlaceholder",title:a.localize(1475,"Go to next placeholder...")}})}return{suggestions:m}}},n=this._editor.getModel();let s,r=!1;const l=()=>{s?.dispose(),r=!1},d=()=>{r||(s=this._languageFeaturesService.completionProvider.register({language:n.getLanguageId(),pattern:n.uri.fsPath,scheme:n.uri.scheme,exclusive:!0},i),this._snippetListener.add(s),r=!0)};this._choiceCompletions={provider:i,enable:d,disable:l}}this._updateState(),this._snippetListener.add(this._editor.onDidChangeModelContent(i=>i.isFlush&&this.cancel())),this._snippetListener.add(this._editor.onDidChangeModel(()=>this.cancel())),this._snippetListener.add(this._editor.onDidChangeCursorSelection(()=>this._updateState()))}}_updateState(){if(!(!this._session||!this._editor.hasModel())){if(this._modelVersionId===this._editor.getModel().getAlternativeVersionId())return this.cancel();if(!this._session.hasPlaceholder)return this.cancel();if(this._session.isAtLastPlaceholder||!this._session.isSelectionWithinPlaceholders())return this._editor.getModel().pushStackElement(),this.cancel();this._inSnippet.set(!0),this._inSnippetObservable.set(!0,void 0),this._hasPrevTabstop.set(!this._session.isAtFirstPlaceholder),this._hasNextTabstop.set(!this._session.isAtLastPlaceholder),this._handleChoice()}}_handleChoice(){if(!this._session||!this._editor.hasModel()){this._currentChoice=void 0,this._inSnippetChoice.reset();return}const{activeChoice:e}=this._session;if(!e||!this._choiceCompletions){this._choiceCompletions?.disable(),this._currentChoice=void 0,this._inSnippetChoice.reset();return}this._inSnippetChoice.set(!0),this._currentChoice!==e.choice&&(this._currentChoice=e.choice,this._choiceCompletions.enable(),queueMicrotask(()=>{Ax(this._editor,this._choiceCompletions.provider)}))}finish(){for(;this._inSnippet.get();)this.next()}cancel(e=!1){this._inSnippet.reset(),this._inSnippetObservable.set(!1,void 0),this._hasPrevTabstop.reset(),this._hasNextTabstop.reset(),this._inSnippetChoice.reset(),this._snippetListener.clear(),this._currentChoice=void 0,this._session?.dispose(),this._session=void 0,this._modelVersionId=-1,e&&this._editor.setSelections([this._editor.getSelection()])}prev(){this._session?.prev(),this._updateState()}next(){this._session?.next(),this._updateState()}isInSnippet(){return!!this._inSnippet.get()}get isInSnippetObservable(){return this._inSnippetObservable}},dn=it,it.ID="snippetController2",it.InSnippetMode=new o.RawContextKey("inSnippetMode",!1,a.localize(1471,"Whether the editor in current in snippet mode")),it.HasNextTabstop=new o.RawContextKey("hasNextTabstop",!1,a.localize(1472,"Whether there is a next tab stop when in snippet mode")),it.HasPrevTabstop=new o.RawContextKey("hasPrevTabstop",!1,a.localize(1473,"Whether there is a previous tab stop when in snippet mode")),it.InSnippetChoice=new o.RawContextKey("inSnippetChoice",!1,a.localize(1474,"Whether the current snippet tab stop is a choice")),it);ne=dn=SE([gl(1,o.ILogService),gl(2,o.ILanguageFeaturesService),gl(3,o.IContextKeyService),gl(4,o.ILanguageConfigurationService)],ne),o.registerEditorContribution(ne.ID,ne,4);const pl=o.EditorCommand.bindToContribution(ne.get);o.registerEditorCommand(new pl({id:"jumpToNextSnippetPlaceholder",precondition:o.ContextKeyExpr.and(ne.InSnippetMode,ne.HasNextTabstop),handler:c=>c.next(),kbOpts:{weight:130,kbExpr:o.EditorContextKeys.textInputFocus,primary:2}})),o.registerEditorCommand(new pl({id:"jumpToPrevSnippetPlaceholder",precondition:o.ContextKeyExpr.and(ne.InSnippetMode,ne.HasPrevTabstop),handler:c=>c.prev(),kbOpts:{weight:130,kbExpr:o.EditorContextKeys.textInputFocus,primary:1026}})),o.KeybindingsRegistry.registerKeybindingRule({id:"jumpToPrevSnippetPlaceholder",weight:191,when:o.ContextKeyExpr.and(ne.InSnippetMode,ne.HasPrevTabstop,ne.InSnippetChoice,o.EditorContextKeys.textInputFocus),primary:1026}),o.registerEditorCommand(new pl({id:"leaveSnippet",precondition:ne.InSnippetMode,handler:c=>c.cancel(!0),kbOpts:{weight:130,kbExpr:o.EditorContextKeys.textInputFocus,primary:9,secondary:[1033]}})),o.registerEditorCommand(new pl({id:"acceptSnippet",precondition:ne.InSnippetMode,handler:c=>c.finish()}));function fl(c){return new yE(c)}class yE extends a.PositionOffsetTransformerBase{constructor(e){super(),this._textModel=e}getOffset(e){return this._textModel.getOffsetAt(e)}getPosition(e){return this._textModel.getPositionAt(e)}}const wE=[];function IE(){return wE}function gv(c){return xE(c).map(t=>t.getEndPosition())}function xE(c){const e=a.Permutation.createSortPermutation(c,a.compareBy(n=>n.range,a.Range.compareRangesUsingStarts)),i=new a.TextEdit(e.apply(c)).getNewRanges();return e.inverse().apply(i)}function EE(c,e){const t=fl(e),i=e.getValue();return c.map(r=>t.getStringReplacement(r)).map(r=>r.removeCommonSuffixPrefix(i)).map(r=>t.getTextReplacement(r))}function LE(c,e){const t=o.observableValue("result",[]),i=[];return e.add(o.autorun(n=>{const s=c.read(n);o.transaction(r=>{if(s.length!==i.length){i.length=s.length;for(let l=0;l<i.length;l++)i[l]||(i[l]=o.observableValue("item",s[l]));t.set([...i],r)}i.forEach((l,d)=>l.set(s[d],r))})})),t}class DE{constructor(e){this._contextKeyService=e}bind(e,t){return o.bindContextKey(e,this._contextKeyService,t instanceof Function?t:i=>t.read(i))}}function pv(c,e){return new Promise(t=>{let i;const n=setTimeout(()=>{i&&i.dispose(),t()},c);e&&(i=e.onCancellationRequested(()=>{clearTimeout(n),i&&i.dispose(),t()}))})}class er{static message(e){return new er(void 0,e)}constructor(e,t=void 0){this.error=e,this.message=t}static is(e){return e instanceof er}logError(){this.message?console.error(`ErrorResult: ${this.message}`,this.error):console.error("ErrorResult: An unexpected error-case occurred, usually caused by invalid input.",this.error)}}class Au{static startNow(e,t,i,n=fv){return new Au(e,t,i,Date.now(),n)}constructor(e,t,i,n,s=fv){this.startValue=e,this.endValue=t,this.durationMs=i,this.startTimeMs=n,this._interpolationFunction=s,e===t&&(this.durationMs=0)}isFinished(e){return e>=this.startTimeMs+this.durationMs}getValue(e){const t=e-this.startTimeMs;return t>=this.durationMs?this.endValue:this._interpolationFunction(t,this.startValue,this.endValue-this.startValue,this.durationMs)}}function fv(c,e,t,i){return c===i?e+t:t*(-Math.pow(2,-10*c/i)+1)+e}function RE(c,e,t,i){return t*((c=c/i-1)*c*c+1)+e}class TE{constructor(e){this._value=e}getValue(e){const t=Date.now();return this._value.isFinished(t)||tr.instance.invalidateOnNextAnimationFrame(e),this._value.getValue(t)}isFinished(e){const t=Date.now(),i=this._value.isFinished(t);return i||tr.instance.invalidateOnNextAnimationFrame(e),i}}const Bc=class Bc{constructor(){this._counter=o.observableSignal(this),this._isScheduled=!1}invalidateOnNextAnimationFrame(e){this._counter.read(e),this._isScheduled||(this._isScheduled=!0,o.getActiveWindow().requestAnimationFrame(()=>{this._isScheduled=!1,this._update()}))}_update(){this._counter.trigger(void 0)}};Bc.instance=new Bc;let tr=Bc;class ir{constructor(e,t){this.lineNumber=e,this.parts=t,a.assertFn(()=>a.checkAdjacentItems(t,(i,n)=>i.column<=n.column))}equals(e){return this.lineNumber===e.lineNumber&&this.parts.length===e.parts.length&&this.parts.every((t,i)=>t.equals(e.parts[i]))}renderForScreenReader(e){if(this.parts.length===0)return"";const t=this.parts[this.parts.length-1],i=e.substr(0,t.column-1);return new a.TextEdit([...this.parts.map(s=>new a.TextReplacement(a.Range.fromPositions(new a.Position(1,s.column)),s.lines.map(r=>r.line).join(`
33
+ `)))]).applyToString(i).substring(this.parts[0].column-1)}isEmpty(){return this.parts.every(e=>e.lines.length===0)}get lineCount(){return 1+this.parts.reduce((e,t)=>e+t.lines.length-1,0)}}class ml{constructor(e,t,i,n=[]){this.column=e,this.text=t,this.preview=i,this._inlineDecorations=n,this.lines=a.splitLines(this.text).map((s,r)=>({line:s,lineDecorations:o.LineDecoration.filter(this._inlineDecorations,r+1,1,s.length+1)}))}equals(e){return this.column===e.column&&this.lines.length===e.lines.length&&this.lines.every((t,i)=>t.line===e.lines[i].line&&o.LineDecoration.equalsArr(t.lineDecorations,e.lines[i].lineDecorations))}}class Fu{constructor(e,t,i,n=0){this.lineNumber=e,this.columnRange=t,this.text=i,this.additionalReservedLineCount=n,this.parts=[new ml(this.columnRange.endColumnExclusive,this.text,!1)],this.newLines=a.splitLines(this.text)}renderForScreenReader(e){return this.newLines.join(`
34
+ `)}get lineCount(){return this.newLines.length}isEmpty(){return this.parts.every(e=>e.lines.length===0)}equals(e){return this.lineNumber===e.lineNumber&&this.columnRange.equals(e.columnRange)&&this.newLines.length===e.newLines.length&&this.newLines.every((t,i)=>t===e.newLines[i])&&this.additionalReservedLineCount===e.additionalReservedLineCount}}function mv(c,e){return a.equals(c,e,_v)}function _v(c,e){return c===e?!0:!c||!e?!1:c instanceof ir&&e instanceof ir||c instanceof Fu&&e instanceof Fu?c.equals(e):!1}function Yt(c,e,t){const i=t?c.range.intersectRanges(t):c.range;if(!i)return c;const n=c.text.replaceAll(`\r
35
+ `,`
36
+ `),s=e.getValueInRange(i,1),r=a.commonPrefixLength(s,n),l=a.TextLength.ofText(s.substring(0,r)).addToPosition(c.range.getStartPosition()),d=n.substring(r),h=a.Range.fromPositions(l,c.range.getEndPosition());return new a.TextReplacement(h,d)}function vv(c,e){return c.text.startsWith(e.text)&&NE(c.range,e.range)}function NE(c,e){return e.getStartPosition().equals(c.getStartPosition())&&e.getEndPosition().isBeforeOrEqual(c.getEndPosition())}function bv(c,e,t,i,n=0){let s=Yt(c,e);if(s.range.endLineNumber!==s.range.startLineNumber)return;const r=e.getLineContent(s.range.startLineNumber),l=a.getLeadingWhitespace(r).length;if(s.range.startColumn-1<=l){const m=a.getLeadingWhitespace(s.text).length,_=r.substring(s.range.startColumn-1,l),[v,b]=[s.range.getStartPosition(),s.range.getEndPosition()],C=v.column+_.length<=b.column?v.delta(0,_.length):b,y=a.Range.fromPositions(C,b),I=s.text.startsWith(_)?s.text.substring(_.length):s.text.substring(m);s=new a.TextReplacement(y,I)}const h=e.getValueInRange(s.range),u=ME(h,s.text);if(!u)return;const g=s.range.startLineNumber,p=new Array;if(t==="prefix"){const m=u.filter(_=>_.originalLength===0);if(m.length>1||m.length===1&&m[0].originalStart!==h.length)return}const f=s.text.length-n;for(const m of u){const _=s.range.startColumn+m.originalStart+m.originalLength;if(t==="subwordSmart"&&i&&i.lineNumber===s.range.startLineNumber&&_<i.column||m.originalLength>0)return;if(m.modifiedLength===0)continue;const v=m.modifiedStart+m.modifiedLength,b=Math.max(m.modifiedStart,Math.min(v,f)),C=s.text.substring(m.modifiedStart,b),y=s.text.substring(b,Math.max(m.modifiedStart,v));C.length>0&&p.push(new ml(_,C,!1)),y.length>0&&p.push(new ml(_,y,!0))}return new ir(g,p)}let _l;function ME(c,e){if(_l?.originalValue===c&&_l?.newValue===e)return _l?.changes;{let t=Sv(c,e,!0);if(t){const i=Cv(t);if(i>0){const n=Sv(c,e,!1);n&&Cv(n)<i&&(t=n)}}return _l={originalValue:c,newValue:e,changes:t},t}}function Cv(c){let e=0;for(const t of c)e+=t.originalLength;return e}function Sv(c,e,t){if(c.length>5e3||e.length>5e3)return;function i(h){let u=0;for(let g=0,p=h.length;g<p;g++){const f=h.charCodeAt(g);f>u&&(u=f)}return u}const n=Math.max(i(c),i(e));function s(h){if(h<0)throw new Error("unexpected");return n+h+1}function r(h){let u=0,g=0;const p=new Int32Array(h.length);for(let f=0,m=h.length;f<m;f++)if(t&&h[f]==="("){const _=g*100+u;p[f]=s(2*_),u++}else if(t&&h[f]===")"){u=Math.max(u-1,0);const _=g*100+u;p[f]=s(2*_+1),u===0&&g++}else p[f]=h.charCodeAt(f);return p}const l=r(c),d=r(e);return new a.LcsDiff({getElements:()=>l},{getElements:()=>d}).ComputeDiff(!1).changes}function PE(c,e){let t,i=!1;const n=new o.DerivedWithSetter(new o.DebugNameData(c,void 0,e.update),(s,r)=>{i||(t=e.initial instanceof Function?e.initial():e.initial,i=!0);const l=e.update(s,t,r);return t=l,l},e.changeTracker,()=>{i&&(e.disposeFinal?.(t),i=!1)},e.equalityComparer??o.strictEquals,(s,r,l)=>{if(!i)throw new a.BugIndicatingError("Can only set when there is a listener! This is to prevent leaks.");o.subtransaction(r,d=>{t=s,n.setValue(s,d,l)})},o.DebugLocation.ofCaller());return n}var OE=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},yv=function(c,e){return function(t,i){e(t,i,c)}};class AE{constructor(e,t){this._baseService=e,this._intercept=t}publicLog2(e,t){this._intercept(e,t),this._baseService.publicLog2(e,t)}}let zu=class extends AE{constructor(e,t){super(e,(i,n)=>{let s=!0;n&&Vu in n&&(s=!!n[Vu]),s&&t.getDataChannel("editTelemetry").sendData({eventName:i,data:n??{}})})}};zu=OE([yv(0,o.ITelemetryService),yv(1,o.IDataChannelService)],zu);const Vu=Symbol("shouldForwardToChannel");function FE(c){return{[Vu]:c}}function wv(c){if(!c)return!1;const e=c.toLowerCase();return e==="github.copilot"||e==="github.copilot-chat"}function zE(c,e){c.publicLog2("inlineCompletion.endOfLife",e)}const VE=new Set([";",",","=","+","-","*","/","{","}","(",")","[","]","<",">",":",".","!","?","&","|","^","%","@","#","~","`","\\","'",'"',"$"]);function BE(c){return VE.has(c)}function KE(c){return/[a-zA-Z0-9_]/.test(c)}function kE(c){return c===" "||c===" "}function vl(c){const e=c.split(/\r\n|\r|\n/);if(e.length>1)return{kind:"multiLine",lineCount:e.length};const t=c.length===1;let i;t&&(BE(c)?i="syntactical":KE(c)?i="identifier":kE(c)&&(i="whitespace"));const n=c.match(/[ \t]+/g)||[],s=n.some(u=>u.length>1),r=n.some(u=>u.includes(" ")||u.includes(" ")),l=c.split(/\s+/).filter(u=>u.length>0),d=l.length===1&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(l[0]),h=l.length>1;return{kind:"singleLine",isSingleCharacter:t,singleCharacterKind:i,isWord:d,isMultipleWords:h,isMultipleWhitespace:s,hasDuplicatedWhitespace:r}}class UE{constructor(e){this.edits=e}toString(){return JSON.stringify({edits:this.edits})}}function Iv(c,e,t){if(c.replacements.length!==0)return new UE(c.replacements.map(i=>$E(i,e)))}function Bu(c){return c.length===0?0:c.split(/\r\n|\r|\n/).length-1}function $E(c,e,t){const i=c.replaceRange,n=c.newText,s=i.length,r=n.length,l=Bu(n);switch(i.isEmpty?"insert":n.length===0?"delete":"replace"){case"insert":return{operation:"insert",properties:jE(i.start,n,e),charactersInserted:r,charactersDeleted:0,linesInserted:l,linesDeleted:0};case"delete":{const h=e.getValue().substring(i.start,i.endExclusive);return{operation:"delete",properties:qE(i.start,i.endExclusive,e),charactersInserted:0,charactersDeleted:s,linesInserted:0,linesDeleted:Bu(h)}}case"replace":{const h=e.getValue().substring(i.start,i.endExclusive);return{operation:"replace",properties:GE(h,n),charactersInserted:r,charactersDeleted:s,linesInserted:l,linesDeleted:Bu(h)}}}}function jE(c,e,t,i){const n=vl(e),s=t.getPositionAt(c),r=t.getLineContent(s.lineNumber),l=r.length;let d;const h=r.trim().length===0,u=s.column>l,g=s.column===1;return h?d="emptyLine":u?d="endOfLine":g?d="startOfLine":d="middleOfLine",{textShape:n,locationShape:d,relativeToCursor:void 0}}function qE(c,e,t){const i=t.getValue().substring(c,e),n=vl(i),s=t.getPositionAt(c),r=t.getPositionAt(e),l=t.getLineContent(r.lineNumber),d=r.column>l.length,h=s.lineNumber===r.lineNumber&&s.column===1&&r.column>l.length;return{textShape:n,isAtEndOfLine:d,deletesEntireLineContent:h}}function GE(c,e){const t=vl(c),i=vl(e),n=t.kind==="singleLine"&&t.isWord,s=i.kind==="singleLine"&&i.isWord,r=n&&s,l=e.length>c.length,d=e.length<c.length,h=t.kind==="singleLine"&&i.kind==="singleLine",u=t.kind==="singleLine"&&i.kind==="multiLine",g=t.kind==="multiLine"&&i.kind==="singleLine";return{isWordToWordReplacement:r,isAdditive:l,isSubtractive:d,isSingleLineToSingleLine:h,isSingleLineToMultiLine:u,isMultiLineToSingleLine:g}}function xv(c,e,t,i){const n=Yt(c,t),s=c.range;if(!s||e&&!e.getStartPosition().equals(s.getStartPosition())||i.lineNumber!==n.range.startLineNumber||n.isEmpty)return!1;const r=t.getValueInRange(n.range,1),l=n.text,d=Math.max(0,i.column-n.range.startColumn);let h=l.substring(0,d),u=l.substring(d),g=r.substring(0,d),p=r.substring(d);const f=t.getLineIndentColumn(n.range.startLineNumber);return n.range.startColumn<=f&&(g=g.trimStart(),g.length===0&&(p=p.trimStart()),h=h.trimStart(),h.length===0&&(u=u.trimStart())),h.startsWith(g)&&!!o.matchesSubString(p,u)}var Ku;(function(c){function e(t){return t?.command.id??void 0}c.toString=e})(Ku||(Ku={}));class Ns extends a.AbstractText{static snapshot(e){return new Ns(e)}constructor(e){super(),this._textModel=e,this._version=e.getVersionId()}get uri(){return this._textModel.uri}_assertValid(){this._textModel.getVersionId()!==this._version&&a.onUnexpectedError(new Error(`TextModel has changed: expected version ${this._version}, got ${this._textModel.getVersionId()}`))}targets(e){return this._textModel.uri.toString()===e.uri.toString()}getValueOfRange(e){return this._assertValid(),this._textModel.getValueInRange(e)}getLineLength(e){return this._assertValid(),this._textModel.getLineLength(e)}get length(){this._assertValid();const e=this._textModel.getLineCount(),t=this._textModel.getLineLength(e);return new a.TextLength(e-1,t)}getEOL(){return this._assertValid(),this._textModel.getEOL()}getPositionAt(e){return this._assertValid(),this._textModel.getPositionAt(e)}getValueInRange(e){return this._assertValid(),this._textModel.getValueInRange(e)}getVersionId(){return this._version}dangerouslyGetUnderlyingModel(){return this._textModel}}var bl;(function(c){function e(t,i,n=!0){return!t.isInlineEdit&&!t.action?.uri&&t.action?.kind==="edit"?sr.create(t,i,t.action):or.create(t,i,n)}c.create=e})(bl||(bl={}));function ZE(c){const e=c?.kind==="edit"?{...c,alternativeAction:Ku.toString(c.alternativeAction),target:c?.target.uri.toString()}:{...c,target:c?.target.uri.toString()};return JSON.stringify(e)}class Ev{constructor(e,t,i,n){this._data=e,this.identity=t,this.hint=i,this.originalTextRef=n}get source(){return this._data.source}get isFromExplicitRequest(){return this._data.context.triggerKind===a.InlineCompletionTriggerKind.Explicit}get forwardStable(){return this.source.inlineSuggestions.enableForwardStability??!1}get targetRange(){if(this.hint)return this.hint.range;if(this.action?.kind==="edit")return this.action.textReplacement.range;if(this.action?.kind==="jumpTo")return a.Range.fromPositions(this.action.position);throw new a.BugIndicatingError("InlineSuggestionItem: Either hint or action must be set")}get semanticId(){return this.hash}get gutterMenuLinkAction(){return this._sourceInlineCompletion.gutterMenuLinkAction}get command(){return this._sourceInlineCompletion.command}get supportsRename(){return this._data.supportsRename}get warning(){return this._sourceInlineCompletion.warning}get showInlineEditMenu(){return!!this._sourceInlineCompletion.showInlineEditMenu}get hash(){return ZE(this.action)}get requestUuid(){return this._data.context.requestUuid}get partialAccepts(){return this._data.partialAccepts}get _sourceInlineCompletion(){return this._data.sourceInlineCompletion}addRef(){this.identity.addRef(),this.source.addRef()}removeRef(){this.identity.removeRef(),this.source.removeRef()}reportInlineEditShown(e,t,i,n,s){const r=this.action?.kind==="edit"?this.action.textReplacement.text:"";this._data.reportInlineEditShown(e,r,t,i,this.computeEditKind(n),s)}reportPartialAccept(e,t,i){this._data.reportPartialAccept(e,t,i)}reportEndOfLife(e){this._data.reportEndOfLife(e)}setEndOfLifeReason(e){this._data.setEndOfLifeReason(e)}setIsPreceeded(e){this._data.setIsPreceeded(e.partialAccepts)}setNotShownReasonIfNotSet(e){this._data.setNotShownReason(e)}getSourceCompletion(){return this._sourceInlineCompletion}setRenameProcessingInfo(e){this._data.setRenameProcessingInfo(e)}withAction(e){return this._data.withAction(e)}addPerformanceMarker(e){this._data.addPerformanceMarker(e)}}const Kc=class Kc{constructor(){this._onDispose=o.observableSignal(this),this.onDispose=this._onDispose,this._jumpedTo=o.observableValue(this,!1),this._refCount=0,this.id="InlineCompletionIdentity"+Kc.idCounter++}get jumpedTo(){return this._jumpedTo}addRef(){this._refCount++}removeRef(){this._refCount--,this._refCount===0&&this._onDispose.trigger(void 0)}setJumpTo(e){this._jumpedTo.set(!0,e)}};Kc.idCounter=0;let Cl=Kc;class nr{static create(e){return new nr(a.Range.lift(e.range),e.content,e.style)}constructor(e,t,i){this.range=e,this.content=t,this.style=i}withEdit(e,t){const i=new a.OffsetRange(t.getOffset(this.range.getStartPosition()),t.getOffset(this.range.getEndPosition())),n=a.applyEditsToRanges([i],e)[0];if(!n)return;const s=t.getRange(n);return new nr(s,this.content,this.style)}}class sr extends Ev{static create(e,t,i){const n=new Cl,s=t.getTransformer(),r=i.insertText.replace(/\r\n|\r|\n/g,t.getEOL()),l=QE(new a.StringReplacement(s.getOffsetRange(i.range),r),t),d=l.removeCommonSuffixAndPrefix(t.getValue()),h=s.getTextReplacement(l),u=e.hint?nr.create(e.hint):void 0;return new sr(l,d,h,h.range,i.snippetInfo,e.additionalTextEdits,e,n,u,t)}constructor(e,t,i,n,s,r,l,d,h,u){super(l,d,h,u),this._edit=e,this._trimmedEdit=t,this._textEdit=i,this._originalRange=n,this.snippetInfo=s,this.additionalTextEdits=r,this.isInlineEdit=!1}get action(){return{kind:"edit",textReplacement:this.getSingleTextEdit(),snippetInfo:this.snippetInfo,stringEdit:new a.StringEdit([this._trimmedEdit]),alternativeAction:void 0,target:this.originalTextRef}}get hash(){return JSON.stringify(this._trimmedEdit.toJson())}getSingleTextEdit(){return this._textEdit}withIdentity(e){return new sr(this._edit,this._trimmedEdit,this._textEdit,this._originalRange,this.snippetInfo,this.additionalTextEdits,this._data,e,this.hint,this.originalTextRef)}withEdit(e,t){if(!this.originalTextRef.targets(t))return this;const i=a.applyEditsToRanges([this._edit.replaceRange],e);if(i.length===0)return;const n=new a.StringReplacement(i[0],this._textEdit.text),s=fl(t),r=s.getTextReplacement(n);let l=this.hint;if(l&&(l=l.withEdit(e,s),!l))return;const d=n.removeCommonSuffixAndPrefix(t.getValue());return new sr(n,d,r,this._originalRange,this.snippetInfo,this.additionalTextEdits,this._data,this.identity,l,this.originalTextRef)}canBeReused(e,t){const i=this._textEdit.range;return!!i&&i.containsPosition(t)&&this.isVisible(e,t)&&a.TextLength.ofRange(i).isGreaterThanOrEqualTo(a.TextLength.ofRange(this._originalRange))}isVisible(e,t){const i=this.getSingleTextEdit();return xv(i,this._originalRange,e,t)}computeEditKind(e){return Iv(new a.StringEdit([this._edit]),e)}get editRange(){return this.getSingleTextEdit().range}}class or extends Ev{static create(e,t,i=!0){let n,s=[];if(e.action?.kind==="edit"){const d=i?XE(t,e.action.range,e.action.insertText):YE(t,e.action.range,e.action.insertText),h=a.TextEdit.fromStringEdit(d,t),u=d.isEmpty()?new a.TextReplacement(new a.Range(1,1,1,1),""):h.toReplacement(t);s=d.replacements.map(g=>{const p=a.Range.fromPositions(t.getPositionAt(g.replaceRange.start),t.getTransformer().getPosition(g.replaceRange.endExclusive)),f=t.getValueInRange(p);return Sl.create(g,f)}),n={kind:"edit",snippetInfo:e.action.snippetInfo,stringEdit:d,textReplacement:u,alternativeAction:e.action.alternativeAction,target:t}}else if(e.action?.kind==="jumpTo")n={kind:"jumpTo",position:e.action.position,offset:t.getTransformer().getOffset(e.action.position),target:t};else if(n=void 0,!e.hint)throw new a.BugIndicatingError("InlineEditItem: action is undefined and no hint is provided");const r=new Cl,l=e.hint?nr.create(e.hint):void 0;return new or(n,e,r,s,l,!1,t.getVersionId(),t)}constructor(e,t,i,n,s,r=!1,l,d){super(t,i,s,d),this._action=e,this._edits=n,this._lastChangePartOfInlineEdit=r,this._inlineEditModelVersion=l,this.snippetInfo=void 0,this.additionalTextEdits=[],this.isInlineEdit=!0}get updatedEditModelVersion(){return this._inlineEditModelVersion}get action(){return this._action}withIdentity(e){return new or(this._action,this._data,e,this._edits,this.hint,this._lastChangePartOfInlineEdit,this._inlineEditModelVersion,this.originalTextRef)}canBeReused(e,t){return this._lastChangePartOfInlineEdit&&this.updatedEditModelVersion===e.getVersionId()}withEdit(e,t){return this.originalTextRef.targets(t)?this._applyTextModelChanges(e,this._edits,t):this}_applyTextModelChanges(e,t,i){const n=fl(i);let s=!1,r=this._inlineEditModelVersion,l;const d=Ns.snapshot(i);if(this.action?.kind==="edit"){if(t=t.map(f=>f.applyTextModelChanges(e)),t.some(f=>f.edit===void 0))return;const u=i.getVersionId();if(s=t.some(f=>f.lastChangeUpdatedEdit),s&&(r=u??-1),u===null||r+20<u||(t=t.filter(f=>!f.edit.isEmpty),t.length===0))return;const g=new a.StringEdit(t.map(f=>f.edit));l={kind:"edit",textReplacement:n.getTextEdit(g).toReplacement(new o.TextModelText(i)),snippetInfo:this.snippetInfo,stringEdit:g,alternativeAction:this.action.alternativeAction,target:d}}else if(this.action?.kind==="jumpTo"){const u=this.action.offset,g=e.applyToOffsetOrUndefined(u);if(g===void 0)return;l={kind:"jumpTo",position:n.getPosition(g),offset:g,target:d}}else l=void 0;let h=this.hint;if(!(h&&(h=h.withEdit(e,n),!h)))return new or(l,this._data,this.identity,t,h,s,r,d)}computeEditKind(e){const t=this.action?.kind==="edit"?this.action.stringEdit:void 0;if(t)return Iv(t,e)}}function XE(c,e,t){const i=c.getEOL(),n=c.getValueOfRange(e),s=t.replace(/\r\n|\r|\n/g,i),d=a.linesDiffComputers.getDefault().computeDiff(a.splitLines(n),a.splitLines(s),{ignoreTrimWhitespace:!1,computeMoves:!1,extendToSubwords:!0,maxComputationTimeMs:50}).changes.flatMap(p=>p.innerChanges??[]);function h(p,f){const m=a.TextLength.fromPosition(f.getStartPosition());return a.TextLength.ofRange(f).createRange(m.addToPosition(p))}const u=new a.StringText(s);return new a.StringEdit(d.map(p=>{const f=h(e.getStartPosition(),p.originalRange),m=c.getTransformer().getOffsetRange(f),_=u.getValueOfRange(p.modifiedRange),v=new a.StringReplacement(m,_),b=c.getValueOfRange(f);return JE(v,b,d.length,c)}))}function YE(c,e,t){return new a.StringEdit([new a.StringReplacement(c.getTransformer().getOffsetRange(e),t)])}class Sl{static create(e,t){const i=a.commonPrefixLength(e.newText,t),n=a.commonSuffixLength(e.newText,t),s=e.newText.substring(i,e.newText.length-n);return new Sl(e,s,i,n)}get edit(){return this._edit}get lastChangeUpdatedEdit(){return this._lastChangeUpdatedEdit}constructor(e,t,i,n,s=!1){this._edit=e,this._trimmedNewText=t,this._prefixLength=i,this._suffixLength=n,this._lastChangeUpdatedEdit=s}applyTextModelChanges(e){const t=this._clone();return t._applyTextModelChanges(e),t}_clone(){return new Sl(this._edit,this._trimmedNewText,this._prefixLength,this._suffixLength,this._lastChangeUpdatedEdit)}_applyTextModelChanges(e){if(this._lastChangeUpdatedEdit=!1,!this._edit)throw new a.BugIndicatingError("UpdatedInnerEdits: No edit to apply changes to");const t=this._applyChanges(this._edit,e);if(!t){this._edit=void 0;return}this._edit=t.edit,this._lastChangeUpdatedEdit=t.editHasChanged}_applyChanges(e,t){let i=e.replaceRange.start,n=e.replaceRange.endExclusive,s=e.newText,r=!1;const l=this._prefixLength>0||this._suffixLength>0;for(let d=t.replacements.length-1;d>=0;d--){const h=t.replacements[d],u=h.newText.length>0&&h.replaceRange.isEmpty;if(u&&!l&&h.replaceRange.start===i&&s.startsWith(h.newText)){i+=h.newText.length,s=s.substring(h.newText.length),n+=h.newText.length,r=!0;continue}if(u&&l&&h.replaceRange.start===i+this._prefixLength&&this._trimmedNewText.startsWith(h.newText)){n+=h.newText.length,r=!0,this._prefixLength+=h.newText.length,this._trimmedNewText=this._trimmedNewText.substring(h.newText.length);continue}if(h.newText.length===0&&h.replaceRange.length>0&&h.replaceRange.start>=i+this._prefixLength&&h.replaceRange.endExclusive<=n-this._suffixLength){n-=h.replaceRange.length,r=!0;continue}if(h.equals(e)){r=!0,i=h.replaceRange.endExclusive,s="";continue}if(!(h.replaceRange.start>n)){if(h.replaceRange.endExclusive<i){i+=h.newText.length-h.replaceRange.length,n+=h.newText.length-h.replaceRange.length;continue}return}}return this._trimmedNewText.length===0&&i+this._prefixLength===n-this._suffixLength?{edit:new a.StringReplacement(new a.OffsetRange(i+this._prefixLength,i+this._prefixLength),""),editHasChanged:!0}:{edit:new a.StringReplacement(new a.OffsetRange(i,n),s),editHasChanged:r}}}function QE(c,e){const t=e.getEOL();return c.replaceRange.isEmpty&&c.newText.includes(t)&&(c=Lv(c,e)),c}function JE(c,e,t,i){const n=i.getEOL();if(c.newText.endsWith(n)&&e.endsWith(n)&&(c=new a.StringReplacement(c.replaceRange.deltaEnd(-n.length),c.newText.slice(0,-n.length))),t===1&&c.replaceRange.isEmpty&&c.newText.includes(n)){const s=i.getTransformer().getPosition(c.replaceRange.start);i.getLineLength(s.lineNumber)!==0&&(c=Lv(c,i))}if(t===1){const s=a.commonPrefixLength(e,c.newText),r=a.commonSuffixLength(e.slice(s),c.newText.slice(s));if(s+r===e.length)return new a.StringReplacement(c.replaceRange.deltaStart(s).deltaEnd(-r),c.newText.substring(s,c.newText.length-r));if(s+r===c.newText.length)return new a.StringReplacement(c.replaceRange.deltaStart(s).deltaEnd(-r),"")}return c}function Lv(c,e){if(!c.replaceRange.isEmpty)throw new a.BugIndicatingError("Unexpected original range");if(c.replaceRange.start===0)return c;const t=e.getEOL(),i=e.getTransformer().getPosition(c.replaceRange.start),n=i.column,s=i.lineNumber;return n===1&&s>1&&c.newText.endsWith(t)&&!c.newText.startsWith(t)?new a.StringReplacement(c.replaceRange.delta(-1),t+c.newText.slice(0,-t.length)):c}function WE(c,e){const t=new o.DenseKeyProvider,i=new o.LanguageAgnosticBracketTokens(t,h=>e.getLanguageConfiguration(h)),n=new o.TextBufferTokenizer(new HE([c]),i),s=o.parseDocument(n,[],void 0,!0);let r="";const l=c.getLineContent();function d(h,u){if(h.kind===2)if(d(h.openingBracket,u),u=o.lengthAdd(u,h.openingBracket.length),h.child&&(d(h.child,u),u=o.lengthAdd(u,h.child.length)),h.closingBracket)d(h.closingBracket,u),u=o.lengthAdd(u,h.closingBracket.length);else{const p=i.getSingleLanguageBracketTokens(h.openingBracket.languageId).findClosingTokenText(h.openingBracket.bracketIds);r+=p}else if(h.kind!==3){if(h.kind===0||h.kind===1)r+=l.substring(o.lengthGetColumnCountIfZeroLineCount(u),o.lengthGetColumnCountIfZeroLineCount(o.lengthAdd(u,h.length)));else if(h.kind===4)for(const g of h.children)d(g,u),u=o.lengthAdd(u,g.length)}}return d(s,o.lengthZero),r}class HE{constructor(e){this.lines=e,this.tokenization={getLineTokens:t=>this.lines[t-1]}}getLineCount(){return this.lines.length}getLineLength(e){return this.lines[e-1].getLineContent().length}}var H;(function(c){c.Jump="jump",c.Accept="accept",c.Inactive="inactive"})(H||(H={}));class Qt{static create(e,t=!1){return new Qt(new o.StandardMouseEvent(o.getWindow(e),e),t)}constructor(e,t=!1){this.event=e,this.alternativeAction=t}}var A;(function(c){c.GhostText="ghostText",c.Custom="custom",c.SideBySide="sideBySide",c.Deletion="deletion",c.InsertionInline="insertionInline",c.InsertionMultiLine="insertionMultiLine",c.WordReplacements="wordReplacements",c.LineReplacement="lineReplacement",c.Collapsed="collapsed",c.JumpTo="jumpTo"})(A||(A={}));class ku{constructor(e,t,i,n,s,r,l,d){this.cursorColumnDistance=e,this.cursorLineDistance=t,this.lineCountOriginal=i,this.lineCountModified=n,this.characterCountOriginal=s,this.characterCountModified=r,this.disjointReplacements=l,this.sameShapeReplacements=d,this.longDistanceHintVisible=void 0,this.longDistanceHintDistance=void 0,this.isForAnotherDocument=void 0}setLongDistanceViewData(e,t){this.longDistanceHintVisible=!0,this.longDistanceHintDistance=Math.abs(t-e)}getData(){return{cursorColumnDistance:this.cursorColumnDistance,cursorLineDistance:this.cursorLineDistance,lineCountOriginal:this.lineCountOriginal,lineCountModified:this.lineCountModified,characterCountOriginal:this.characterCountOriginal,characterCountModified:this.characterCountModified,disjointReplacements:this.disjointReplacements,sameShapeReplacements:this.sameShapeReplacements,longDistanceHintVisible:this.longDistanceHintVisible,longDistanceHintDistance:this.longDistanceHintDistance,isForAnotherDocument:this.isForAnotherDocument}}}class Uu{constructor(){this._nodes=new Set,this._outgoingEdges=new Map}static from(e,t){const i=new Uu;for(const n of e)i._nodes.add(n);for(const n of e){const s=t(n);if(s.length>0){const r=new Set;for(const l of s)r.add(l);i._outgoingEdges.set(n,r)}}return i}removeCycles(){const e=[],t=new Set,i=new Set,n=[],s=r=>{t.add(r),i.add(r);const l=this._outgoingEdges.get(r);if(l)for(const d of l)t.has(d)?i.has(d)&&(e.push(d),n.push({from:r,to:d})):s(d);i.delete(r)};for(const r of this._nodes)t.has(r)||s(r);for(const{from:r,to:l}of n){const d=this._outgoingEdges.get(r);d&&d.delete(l)}return{foundCycles:e}}getOutgoing(e){const t=this._outgoingEdges.get(e);return t?Array.from(t):[]}}function eL(c,e,t,i,n,s){const r=o.prefixedUuid("icr"),l=new a.CancellationTokenSource;let d;const h={...i,requestUuid:r},u=oL(e,t),g=o.groupByMap(c,b=>b.groupId),p=Uu.from(c,b=>b.yieldsToGroupIds?.flatMap(C=>g.get(C)??[])??[]),{foundCycles:f}=p.removeCycles();f.length>0&&a.onUnexpectedExternalError(new Error(`Inline completions: cyclic yield-to dependency detected. Path: ${f.map(b=>b.toString?b.toString():""+b).join(" -> ")}`));let m=0;const _=new a.CachedFunction(async b=>{try{if(m++,l.token.isCancellationRequested)return;const C=p.getOutgoing(b);for(const E of C){const L=await _.get(E);if(L)for(const R of L.inlineSuggestions.items){if(R.isInlineEdit||typeof R.insertText!="string"&&R.insertText!==void 0)return;if(R.insertText!==void 0){const D=new a.TextReplacement(a.Range.lift(R.range)??u,R.insertText);if(xv(D,void 0,t,e))return}}}let y;const I=Date.now();try{y=await b.provideInlineCompletions(t,e,h,l.token)}catch(E){a.onUnexpectedExternalError(E);return}const x=Date.now();if(!y)return;const S=[],w=new sL(y,S,b);if(w.addRef(),Dv(l.token,()=>w.removeRef(d)),l.token.isCancellationRequested)return;for(const E of y.items){const L=tL(E,w,u,t,s,h,n,{startTime:I,endTime:x});if(er.is(L)){L.logError();continue}S.push(L)}return w}finally{m--}}),v=a.AsyncIterableProducer.fromPromisesResolveOrder(c.map(b=>_.get(b))).filter(a.isDefined);return{contextWithUuid:h,get didAllProvidersReturn(){return m===0},lists:v,cancelAndDispose:b=>{d===void 0&&(d=b,l.dispose(!0))}}}function Dv(c,e){if(c.isCancellationRequested)return e(),a.Disposable.None;{const t=c.onCancellationRequested(()=>{t.dispose(),e()});return{dispose:()=>t.dispose()}}}function tL(c,e,t,i,n,s,r,l){let d;const h=c.uri?a.URI.revive(c.uri):void 0;if(c.jumpToPosition!==void 0)d={kind:"jumpTo",position:a.Position.lift(c.jumpToPosition),uri:h};else if(c.insertText!==void 0){let u,g,p=c.range?a.Range.lift(c.range):t;if(typeof c.insertText=="string"){if(u=c.insertText,n&&c.completeBracketPairs){u=Rv(u,p.getStartPosition(),i,n);const f=u.length-c.insertText.length;f!==0&&(p=new a.Range(p.startLineNumber,p.startColumn,p.endLineNumber,p.endColumn+f))}g=void 0}else if("snippet"in c.insertText){const f=c.insertText.snippet.length;if(n&&c.completeBracketPairs){c.insertText.snippet=Rv(c.insertText.snippet,p.getStartPosition(),i,n);const _=c.insertText.snippet.length-f;_!==0&&(p=new a.Range(p.startLineNumber,p.startColumn,p.endLineNumber,p.endColumn+_))}const m=new Ui().parse(c.insertText.snippet);m.children.length===1&&m.children[0]instanceof le?(u=m.children[0].value,g=void 0):(u=m.toString(),g={snippet:c.insertText.snippet,range:p})}else a.assertNever(c.insertText);d={kind:"edit",range:p,insertText:u,snippetInfo:g,uri:h,alternativeAction:void 0}}else if(d=void 0,!c.hint)return er.message("Inline completion has no insertText, jumpToPosition nor hint.");return new iL(d,c.hint,c.additionalTextEdits||IE(),c,e,s,c.isInlineEdit??!1,c.supportsRename??!1,r,l,c.correlationId)}class iL{get action(){return this._action}constructor(e,t,i,n,s,r,l,d,h,u,g){this._action=e,this.hint=t,this.additionalTextEdits=i,this.sourceInlineCompletion=n,this.source=s,this.context=r,this.isInlineEdit=l,this.supportsRename=d,this._requestInfo=h,this._providerRequestInfo=u,this._correlationId=g,this._didShow=!1,this._timeUntilShown=void 0,this._timeUntilActuallyShown=void 0,this._showStartTime=void 0,this._shownDuration=0,this._showUncollapsedStartTime=void 0,this._showUncollapsedDuration=0,this._notShownReason=void 0,this._didReportEndOfLife=!1,this._lastSetEndOfLifeReason=void 0,this._isPreceeded=!1,this._partiallyAcceptedCount=0,this._partiallyAcceptedSinceOriginal={characters:0,ratio:0,count:0},this._renameInfo=void 0,this._editKind=void 0,this.performance=new nL,this._viewData={editorType:h.editorType}}get showInlineEditMenu(){return this.sourceInlineCompletion.showInlineEditMenu??!1}get partialAccepts(){return this._partiallyAcceptedSinceOriginal}async reportInlineEditShown(e,t,i,n,s,r){if(this.updateShownDuration(i),this._didShow||this._didReportEndOfLife)return;this.addPerformanceMarker("shown"),this._didShow=!0,this._editKind=s,this._viewData.viewKind=i,this._viewData.renderData=n,this._timeUntilShown=r-this._requestInfo.startTime,this._timeUntilActuallyShown=Date.now()-this._requestInfo.startTime;const l=new o.EditDeltaInfo(n.lineCountModified,n.lineCountOriginal,n.characterCountModified,n.characterCountOriginal);this.source.provider.handleItemDidShow?.(this.source.inlineSuggestions,this.sourceInlineCompletion,t,l),this.sourceInlineCompletion.shownCommand&&await e.executeCommand(this.sourceInlineCompletion.shownCommand.id,...this.sourceInlineCompletion.shownCommand.arguments||[])}reportPartialAccept(e,t,i){this._partiallyAcceptedCount++,this._partiallyAcceptedSinceOriginal.characters+=i.characters,this._partiallyAcceptedSinceOriginal.ratio=Math.min(this._partiallyAcceptedSinceOriginal.ratio+(1-this._partiallyAcceptedSinceOriginal.ratio)*i.ratio,1),this._partiallyAcceptedSinceOriginal.count+=i.count,this.source.provider.handlePartialAccept?.(this.source.inlineSuggestions,this.sourceInlineCompletion,e,t)}reportEndOfLife(e){if(!this._didReportEndOfLife&&(this._didReportEndOfLife=!0,this.reportInlineEditHidden(),e||(e=this._lastSetEndOfLifeReason??{kind:a.InlineCompletionEndOfLifeReasonKind.Ignored,userTypingDisagreed:!1,supersededBy:void 0}),e.kind===a.InlineCompletionEndOfLifeReasonKind.Rejected&&!this._didShow&&(e={kind:a.InlineCompletionEndOfLifeReasonKind.Ignored,userTypingDisagreed:!1,supersededBy:void 0}),e.kind===a.InlineCompletionEndOfLifeReasonKind.Rejected&&this.source.provider.handleRejection&&this.source.provider.handleRejection(this.source.inlineSuggestions,this.sourceInlineCompletion),this.source.provider.handleEndOfLifetime)){const t={requestUuid:this.context.requestUuid,correlationId:this._correlationId,selectedSuggestionInfo:!!this.context.selectedSuggestionInfo,partiallyAccepted:this._partiallyAcceptedCount,partiallyAcceptedCountSinceOriginal:this._partiallyAcceptedSinceOriginal.count,partiallyAcceptedRatioSinceOriginal:this._partiallyAcceptedSinceOriginal.ratio,partiallyAcceptedCharactersSinceOriginal:this._partiallyAcceptedSinceOriginal.characters,shown:this._didShow,shownDuration:this._shownDuration,shownDurationUncollapsed:this._showUncollapsedDuration,editKind:this._editKind?.toString(),preceeded:this._isPreceeded,timeUntilShown:this._timeUntilShown,timeUntilActuallyShown:this._timeUntilActuallyShown,timeUntilProviderRequest:this._providerRequestInfo.startTime-this._requestInfo.startTime,timeUntilProviderResponse:this._providerRequestInfo.endTime-this._requestInfo.startTime,editorType:this._viewData.editorType,languageId:this._requestInfo.languageId,requestReason:this._requestInfo.reason,viewKind:this._viewData.viewKind,notShownReason:this._notShownReason,performanceMarkers:this.performance.toString(),renameCreated:this._renameInfo?.createdRename,renameDuration:this._renameInfo?.duration,renameTimedOut:this._renameInfo?.timedOut,renameDroppedOtherEdits:this._renameInfo?.droppedOtherEdits,renameDroppedRenameEdits:this._renameInfo?.droppedRenameEdits,typingInterval:this._requestInfo.typingInterval,typingIntervalCharacterCount:this._requestInfo.typingIntervalCharacterCount,skuPlan:this._requestInfo.sku?.plan,skuType:this._requestInfo.sku?.type,availableProviders:this._requestInfo.availableProviders.map(i=>i.toString()).join(","),...this._viewData.renderData?.getData()};this.source.provider.handleEndOfLifetime(this.source.inlineSuggestions,this.sourceInlineCompletion,e,t)}}setIsPreceeded(e){this._isPreceeded=!0,(this._partiallyAcceptedSinceOriginal.characters!==0||this._partiallyAcceptedSinceOriginal.ratio!==0||this._partiallyAcceptedSinceOriginal.count!==0)&&console.warn("Expected partiallyAcceptedCountSinceOriginal to be { characters: 0, rate: 0, partialAcceptances: 0 } before setIsPreceeded."),this._partiallyAcceptedSinceOriginal=e}setNotShownReason(e){this._notShownReason??=e}setEndOfLifeReason(e){this.reportInlineEditHidden(),this._lastSetEndOfLifeReason=e}updateShownDuration(e){const t=Date.now();this._showStartTime||(this._showStartTime=t);const i=e===A.Collapsed;!i&&this._showUncollapsedStartTime===void 0&&(this._showUncollapsedStartTime=t),i&&this._showUncollapsedStartTime!==void 0&&(this._showUncollapsedDuration+=t-this._showUncollapsedStartTime)}reportInlineEditHidden(){if(this._showStartTime===void 0)return;const e=Date.now();this._shownDuration+=e-this._showStartTime,this._showStartTime=void 0,this._showUncollapsedStartTime!==void 0&&(this._showUncollapsedDuration+=e-this._showUncollapsedStartTime,this._showUncollapsedStartTime=void 0)}setRenameProcessingInfo(e){if(this._renameInfo)throw new a.BugIndicatingError("Rename info has already been set.");this._renameInfo=e}withAction(e){return this._action=e,this}addPerformanceMarker(e){this.performance.mark(e)}}class nL{constructor(){this.markers=[],this.markers.push({name:"start",timeStamp:Date.now()})}mark(e){this.markers.push({name:e,timeStamp:Date.now()})}toString(){const e=[];for(let t=1;t<this.markers.length;t++){const i=this.markers[t].timeStamp-this.markers[t-1].timeStamp;e.push({[this.markers[t].name]:i})}return JSON.stringify(e)}}var te;(function(c){c.TextEditor="textEditor",c.DiffEditor="diffEditor",c.Notebook="notebook"})(te||(te={}));class sL{constructor(e,t,i){this.inlineSuggestions=e,this.inlineSuggestionsData=t,this.provider=i,this.refCount=0}addRef(){this.refCount++}removeRef(e={kind:"other"}){if(this.refCount--,this.refCount===0){for(const t of this.inlineSuggestionsData)t.reportEndOfLife();this.provider.disposeInlineCompletions(this.inlineSuggestions,e)}else this.refCount<0&&a.onUnexpectedError(new a.BugIndicatingError(`InlineSuggestionList (provider=${this.provider.providerId?.toString()}) refCount went negative (${this.refCount}) — more removeRef than addRef calls.`))}}function oL(c,e){const t=e.getWordAtPosition(c),i=e.getLineMaxColumn(c.lineNumber);return t?new a.Range(c.lineNumber,t.startColumn,c.lineNumber,i):a.Range.fromPositions(c,c.with(void 0,i))}function Rv(c,e,t,i){const n=t.getLineContent(e.lineNumber),s=a.StringReplacement.replace(new a.OffsetRange(e.column-1,n.length),c),l=t.tokenization.tokenizeLinesAt(e.lineNumber,[s.replace(n)])?.[0].sliceZeroCopy(s.getRangeAfterReplace());return l?WE(l,i):c}var rL=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},yl=function(c,e){return function(t,i){e(t,i,c)}};const Ms=new o.RawContextKey("renameInputVisible",!1,a.localize(1460,"Whether the rename input widget is visible"));new o.RawContextKey("renameInputFocused",!1,a.localize(1461,"Whether the rename input widget is focused"));let $u=class{constructor(e,t,i,n,s,r){this._editor=e,this._acceptKeybindings=t,this._themeService=i,this._keybindingService=n,this._logService=r,this.allowEditorOverflow=!0,this._disposables=new a.DisposableStore,this._visibleContextKey=Ms.bindTo(s),this._isEditingRenameCandidate=!1,this._nRenameSuggestionsInvocations=0,this._hadAutomaticRenameSuggestionsInvocation=!1,this._candidates=new Set,this._beforeFirstInputFieldEditSW=new a.StopWatch,this._inputWithButton=new aL,this._disposables.add(this._inputWithButton),this._editor.addContentWidget(this),this._disposables.add(this._editor.onDidChangeConfiguration(l=>{l.hasChanged(59)&&this._updateFont()})),this._disposables.add(i.onDidColorThemeChange(this._updateStyles,this))}dispose(){this._disposables.dispose(),this._editor.removeContentWidget(this)}getId(){return"__renameInputWidget"}getDomNode(){return this._domNode||(this._domNode=document.createElement("div"),this._domNode.className="monaco-editor rename-box",this._domNode.appendChild(this._inputWithButton.domNode),this._renameCandidateListView=this._disposables.add(new ju(this._domNode,{fontInfo:this._editor.getOption(59),onFocusChange:e=>{this._inputWithButton.input.value=e,this._isEditingRenameCandidate=!1},onSelectionChange:()=>{this._isEditingRenameCandidate=!1,this.acceptInput(!1)}})),this._disposables.add(this._inputWithButton.onDidInputChange(()=>{this._renameCandidateListView?.focusedCandidate!==void 0&&(this._isEditingRenameCandidate=!0),this._timeBeforeFirstInputFieldEdit??=this._beforeFirstInputFieldEditSW.elapsed(),this._renameCandidateProvidersCts?.token.isCancellationRequested===!1&&this._renameCandidateProvidersCts.cancel(),this._renameCandidateListView?.clearFocus()})),this._label=document.createElement("div"),this._label.className="rename-label",this._domNode.appendChild(this._label),this._updateFont(),this._updateStyles(this._themeService.getColorTheme())),this._domNode}_updateStyles(e){if(!this._domNode)return;const t=e.getColor(o.widgetShadow),i=e.getColor(o.widgetBorder);this._domNode.style.backgroundColor=String(e.getColor(o.editorWidgetBackground)??""),this._domNode.style.boxShadow=t?` 0 0 8px 2px ${t}`:"",this._domNode.style.border=i?`1px solid ${i}`:"",this._domNode.style.color=String(e.getColor(o.inputForeground)??"");const n=e.getColor(o.inputBorder);this._inputWithButton.domNode.style.backgroundColor=String(e.getColor(o.inputBackground)??""),this._inputWithButton.input.style.backgroundColor=String(e.getColor(o.inputBackground)??""),this._inputWithButton.domNode.style.borderWidth=n?"1px":"0px",this._inputWithButton.domNode.style.borderStyle=n?"solid":"none",this._inputWithButton.domNode.style.borderColor=n?.toString()??"none"}_updateFont(){if(this._domNode===void 0)return;a.assertType(this._label!==void 0,"RenameWidget#_updateFont: _label must not be undefined given _domNode is defined"),this._editor.applyFontInfo(this._inputWithButton.input);const e=this._editor.getOption(59);this._label.style.fontSize=`${this._computeLabelFontSize(e.fontSize)}px`}_computeLabelFontSize(e){return e*.8}getPosition(){if(!this._visible||!this._editor.hasModel()||!this._editor.getDomNode())return null;const e=o.getClientArea(this.getDomNode().ownerDocument.body),t=o.getDomNodePagePosition(this._editor.getDomNode()),i=this._getTopForPosition();this._nPxAvailableAbove=i+t.top,this._nPxAvailableBelow=e.height-this._nPxAvailableAbove;const n=this._editor.getOption(75),{totalHeight:s}=rr.getLayoutInfo({lineHeight:n}),r=this._nPxAvailableBelow>s*6?[2,1]:[1,2];return{position:this._position,preference:r}}beforeRender(){const[e,t]=this._acceptKeybindings;return this._label.innerText=a.localize(1462,"{0} to Rename, {1} to Preview",this._keybindingService.lookupKeybinding(e)?.getLabel(),this._keybindingService.lookupKeybinding(t)?.getLabel()),this._domNode.style.minWidth="200px",null}afterRender(e){if(e===null){this.cancelInput(!0,"afterRender (because position is null)");return}if(!this._editor.hasModel()||!this._editor.getDomNode())return;a.assertType(this._renameCandidateListView),a.assertType(this._nPxAvailableAbove!==void 0),a.assertType(this._nPxAvailableBelow!==void 0);const t=o.getTotalHeight(this._inputWithButton.domNode),i=o.getTotalHeight(this._label);let n;e===2?n=this._nPxAvailableBelow:n=this._nPxAvailableAbove,this._renameCandidateListView.layout({height:n-i-t,width:o.getTotalWidth(this._inputWithButton.domNode)})}acceptInput(e){this._trace("invoking acceptInput"),this._currentAcceptInput?.(e)}cancelInput(e,t){this._currentCancelInput?.(e)}focusNextRenameSuggestion(){this._renameCandidateListView?.focusNext()||(this._inputWithButton.input.value=this._currentName)}focusPreviousRenameSuggestion(){this._renameCandidateListView?.focusPrevious()||(this._inputWithButton.input.value=this._currentName)}getInput(e,t,i,n,s){const{start:r,end:l}=this._getSelection(e,t);this._renameCts=s;const d=new a.DisposableStore;this._nRenameSuggestionsInvocations=0,this._hadAutomaticRenameSuggestionsInvocation=!1,n===void 0?this._inputWithButton.button.style.display="none":(this._inputWithButton.button.style.display="flex",this._requestRenameCandidatesOnce=n,this._requestRenameCandidates(t,!1),d.add(o.addDisposableListener(this._inputWithButton.button,"click",()=>this._requestRenameCandidates(t,!0))),d.add(o.addDisposableListener(this._inputWithButton.button,o.EventType.KEY_DOWN,u=>{const g=new o.StandardKeyboardEvent(u);(g.equals(3)||g.equals(10))&&(g.stopPropagation(),g.preventDefault(),this._requestRenameCandidates(t,!0))}))),this._isEditingRenameCandidate=!1,this._domNode.classList.toggle("preview",i),this._position=new a.Position(e.startLineNumber,e.startColumn),this._currentName=t,this._inputWithButton.input.value=t,this._inputWithButton.input.setAttribute("selectionStart",r.toString()),this._inputWithButton.input.setAttribute("selectionEnd",l.toString()),this._inputWithButton.input.size=Math.max((e.endColumn-e.startColumn)*1.1,20),this._beforeFirstInputFieldEditSW.reset(),d.add(a.toDisposable(()=>{this._renameCts=void 0,s.dispose(!0)})),d.add(a.toDisposable(()=>{this._renameCandidateProvidersCts!==void 0&&(this._renameCandidateProvidersCts.dispose(!0),this._renameCandidateProvidersCts=void 0)})),d.add(a.toDisposable(()=>this._candidates.clear()));const h=new a.DeferredPromise;return h.p.finally(()=>{d.dispose(),this._hide()}),this._currentCancelInput=u=>(this._trace("invoking _currentCancelInput"),this._currentAcceptInput=void 0,this._currentCancelInput=void 0,this._renameCandidateListView?.clearCandidates(),h.complete(u),!0),this._currentAcceptInput=u=>{this._trace("invoking _currentAcceptInput"),a.assertType(this._renameCandidateListView!==void 0);const g=this._renameCandidateListView.nCandidates;let p,f;const m=this._renameCandidateListView.focusedCandidate;if(m!==void 0?(this._trace("using new name from renameSuggestion"),p=m,f={k:"renameSuggestion"}):(this._trace("using new name from inputField"),p=this._inputWithButton.input.value,f=this._isEditingRenameCandidate?{k:"userEditedRenameSuggestion"}:{k:"inputField"}),p===t||p.trim().length===0){this.cancelInput(!0,"_currentAcceptInput (because newName === value || newName.trim().length === 0)");return}this._currentAcceptInput=void 0,this._currentCancelInput=void 0,this._renameCandidateListView.clearCandidates(),h.complete({newName:p,wantsPreview:i&&u,stats:{source:f,nRenameSuggestions:g,timeBeforeFirstInputFieldEdit:this._timeBeforeFirstInputFieldEdit,nRenameSuggestionsInvocations:this._nRenameSuggestionsInvocations,hadAutomaticRenameSuggestionsInvocation:this._hadAutomaticRenameSuggestionsInvocation}})},d.add(s.token.onCancellationRequested(()=>this.cancelInput(!0,"cts.token.onCancellationRequested"))),d.add(this._editor.onDidBlurEditorWidget(()=>this.cancelInput(!this._domNode?.ownerDocument.hasFocus(),"editor.onDidBlurEditorWidget"))),this._show(),h.p}_requestRenameCandidates(e,t){if(this._requestRenameCandidatesOnce!==void 0&&(this._renameCandidateProvidersCts!==void 0&&this._renameCandidateProvidersCts.dispose(!0),a.assertType(this._renameCts),this._inputWithButton.buttonState!=="stop")){this._renameCandidateProvidersCts=new a.CancellationTokenSource;const i=t?a.NewSymbolNameTriggerKind.Invoke:a.NewSymbolNameTriggerKind.Automatic,n=this._requestRenameCandidatesOnce(i,this._renameCandidateProvidersCts.token);if(n.length===0){this._inputWithButton.setSparkleButton();return}t||(this._hadAutomaticRenameSuggestionsInvocation=!0),this._nRenameSuggestionsInvocations+=1,this._inputWithButton.setStopButton(),this._updateRenameCandidates(n,e,this._renameCts.token)}}_getSelection(e,t){a.assertType(this._editor.hasModel());const i=this._editor.getSelection();let n=0,s=t.length;return!a.Range.isEmpty(i)&&!a.Range.spansMultipleLines(i)&&a.Range.containsRange(e,i)&&(n=Math.max(0,i.startColumn-e.startColumn),s=Math.min(e.endColumn,i.endColumn)-e.startColumn),{start:n,end:s}}_show(){this._trace("invoking _show"),this._editor.revealLineInCenterIfOutsideViewport(this._position.lineNumber,0),this._visible=!0,this._visibleContextKey.set(!0),this._editor.layoutContentWidget(this),setTimeout(()=>{this._inputWithButton.input.focus(),this._inputWithButton.input.setSelectionRange(parseInt(this._inputWithButton.input.getAttribute("selectionStart")),parseInt(this._inputWithButton.input.getAttribute("selectionEnd")))},100)}async _updateRenameCandidates(e,t,i){const n=(...h)=>this._trace("_updateRenameCandidates",...h);n("start");const s=await a.raceCancellation(Promise.allSettled(e),i);if(this._inputWithButton.setSparkleButton(),s===void 0){n("returning early - received updateRenameCandidates results - undefined");return}const r=s.flatMap(h=>h.status==="fulfilled"&&a.isDefined(h.value)?h.value:[]);n(`received updateRenameCandidates results - total (unfiltered) ${r.length} candidates.`);const l=a.distinct(r,h=>h.newSymbolName);n(`distinct candidates - ${l.length} candidates.`);const d=l.filter(({newSymbolName:h})=>h.trim().length>0&&h!==this._inputWithButton.input.value&&h!==t&&!this._candidates.has(h));if(n(`valid distinct candidates - ${r.length} candidates.`),d.forEach(h=>this._candidates.add(h.newSymbolName)),d.length<1){n("returning early - no valid distinct candidates");return}n("setting candidates"),this._renameCandidateListView.setCandidates(d),n("asking editor to re-layout"),this._editor.layoutContentWidget(this)}_hide(){this._trace("invoked _hide"),this._visible=!1,this._visibleContextKey.reset(),this._editor.layoutContentWidget(this)}_getTopForPosition(){const e=this._editor.getVisibleRanges();let t;return e.length>0?t=e[0].startLineNumber:(this._logService.warn("RenameWidget#_getTopForPosition: this should not happen - visibleRanges is empty"),t=Math.max(1,this._position.lineNumber-5)),this._editor.getTopForLineNumber(this._position.lineNumber)-this._editor.getTopForLineNumber(t)}_trace(...e){this._logService.trace("RenameWidget",...e)}};$u=rL([yl(2,o.IThemeService),yl(3,o.IKeybindingService),yl(4,o.IContextKeyService),yl(5,o.ILogService)],$u);class ju{constructor(e,t){this._disposables=new a.DisposableStore,this._availableHeight=0,this._minimumWidth=0,this._lineHeight=t.fontInfo.lineHeight,this._typicalHalfwidthCharacterWidth=t.fontInfo.typicalHalfwidthCharacterWidth,this._listContainer=document.createElement("div"),this._listContainer.className="rename-box rename-candidate-list-container",e.appendChild(this._listContainer),this._listWidget=ju._createListWidget(this._listContainer,this._candidateViewHeight,t.fontInfo),this._disposables.add(this._listWidget.onDidChangeFocus(i=>{i.elements.length===1&&t.onFocusChange(i.elements[0].newSymbolName)},this._disposables)),this._disposables.add(this._listWidget.onDidChangeSelection(i=>{i.elements.length===1&&t.onSelectionChange()},this._disposables)),this._disposables.add(this._listWidget.onDidBlur(i=>{this._listWidget.setFocus([])})),this._listWidget.style(o.getListStyles({listInactiveFocusForeground:o.quickInputListFocusForeground,listInactiveFocusBackground:o.quickInputListFocusBackground}))}dispose(){this._listWidget.dispose(),this._disposables.dispose()}layout({height:e,width:t}){this._availableHeight=e,this._minimumWidth=t}setCandidates(e){this._listWidget.splice(0,0,e);const t=this._pickListHeight(this._listWidget.length),i=this._pickListWidth(e);this._listWidget.layout(t,i),this._listContainer.style.height=`${t}px`,this._listContainer.style.width=`${i}px`,o.status(a.localize(1463,"Received {0} rename suggestions",e.length))}clearCandidates(){this._listContainer.style.height="0px",this._listContainer.style.width="0px",this._listWidget.splice(0,this._listWidget.length,[])}get nCandidates(){return this._listWidget.length}get focusedCandidate(){if(this._listWidget.length===0)return;const e=this._listWidget.getSelectedElements()[0];if(e!==void 0)return e.newSymbolName;const t=this._listWidget.getFocusedElements()[0];if(t!==void 0)return t.newSymbolName}focusNext(){if(this._listWidget.length===0)return!1;const e=this._listWidget.getFocus();if(e.length===0)return this._listWidget.focusFirst(),this._listWidget.reveal(0),!0;if(e[0]===this._listWidget.length-1)return this._listWidget.setFocus([]),this._listWidget.reveal(0),!1;{this._listWidget.focusNext();const t=this._listWidget.getFocus()[0];return this._listWidget.reveal(t),!0}}focusPrevious(){if(this._listWidget.length===0)return!1;const e=this._listWidget.getFocus();if(e.length===0){this._listWidget.focusLast();const t=this._listWidget.getFocus()[0];return this._listWidget.reveal(t),!0}else{if(e[0]===0)return this._listWidget.setFocus([]),!1;{this._listWidget.focusPrevious();const t=this._listWidget.getFocus()[0];return this._listWidget.reveal(t),!0}}}clearFocus(){this._listWidget.setFocus([])}get _candidateViewHeight(){const{totalHeight:e}=rr.getLayoutInfo({lineHeight:this._lineHeight});return e}_pickListHeight(e){const t=this._candidateViewHeight*e;return Math.min(t,this._availableHeight,this._candidateViewHeight*7)}_pickListWidth(e){const t=Math.ceil(Math.max(...e.map(n=>n.newSymbolName.length))*this._typicalHalfwidthCharacterWidth);return Math.max(this._minimumWidth,25+t+10)}static _createListWidget(e,t,i){const n=new class{getTemplateId(r){return"candidate"}getHeight(r){return t}},s=new class{constructor(){this.templateId="candidate"}renderTemplate(r){return new rr(r,i)}renderElement(r,l,d){d.populate(r)}disposeTemplate(r){r.dispose()}};return new o.List("NewSymbolNameCandidates",e,n,[s],{keyboardSupport:!1,mouseSupport:!0,multipleSelectionSupport:!1})}}class aL{constructor(){this._buttonHoverContent="",this._disposables=new a.DisposableStore,this._onDidInputChange=this._disposables.add(new a.Emitter),this.onDidInputChange=this._onDidInputChange.event}get domNode(){return this._domNode||(this._domNode=document.createElement("div"),this._domNode.className="rename-input-with-button",this._domNode.style.display="flex",this._domNode.style.flexDirection="row",this._domNode.style.alignItems="center",this._inputNode=document.createElement("input"),this._inputNode.className="rename-input",this._inputNode.type="text",this._inputNode.style.border="none",this._inputNode.setAttribute("aria-label",a.localize(1464,"Rename input. Type new name and press Enter to commit.")),this._domNode.appendChild(this._inputNode),this._buttonNode=document.createElement("div"),this._buttonNode.className="rename-suggestions-button",this._buttonNode.setAttribute("tabindex","0"),this._buttonGenHoverText=a.localize(1465,"Generate New Name Suggestions"),this._buttonCancelHoverText=a.localize(1466,"Cancel"),this._buttonHoverContent=this._buttonGenHoverText,this._disposables.add(o.getBaseLayerHoverDelegate().setupDelayedHover(this._buttonNode,()=>({content:this._buttonHoverContent,style:1}))),this._domNode.appendChild(this._buttonNode),this._disposables.add(o.addDisposableListener(this.input,o.EventType.INPUT,()=>this._onDidInputChange.fire())),this._disposables.add(o.addDisposableListener(this.input,o.EventType.KEY_DOWN,e=>{const t=new o.StandardKeyboardEvent(e);(t.keyCode===15||t.keyCode===17)&&this._onDidInputChange.fire()})),this._disposables.add(o.addDisposableListener(this.input,o.EventType.CLICK,()=>this._onDidInputChange.fire())),this._disposables.add(o.addDisposableListener(this.input,o.EventType.FOCUS,()=>{this.domNode.style.outlineWidth="1px",this.domNode.style.outlineStyle="solid",this.domNode.style.outlineOffset="-1px",this.domNode.style.outlineColor="var(--vscode-focusBorder)"})),this._disposables.add(o.addDisposableListener(this.input,o.EventType.BLUR,()=>{this.domNode.style.outline="none"}))),this._domNode}get input(){return a.assertType(this._inputNode),this._inputNode}get button(){return a.assertType(this._buttonNode),this._buttonNode}get buttonState(){return this._buttonState}setSparkleButton(){this._buttonState="sparkle",this._sparkleIcon??=o.renderIcon(a.Codicon.sparkle),o.clearNode(this.button),this.button.appendChild(this._sparkleIcon),this.button.setAttribute("aria-label","Generating new name suggestions"),this._buttonHoverContent=this._buttonGenHoverText,this.input.focus()}setStopButton(){this._buttonState="stop",this._stopIcon??=o.renderIcon(a.Codicon.stopCircle),o.clearNode(this.button),this.button.appendChild(this._stopIcon),this.button.setAttribute("aria-label","Cancel generating new name suggestions"),this._buttonHoverContent=this._buttonCancelHoverText,this.input.focus()}dispose(){this._disposables.dispose()}}const Gr=class Gr{constructor(e,t){this._domNode=document.createElement("div"),this._domNode.className="rename-box rename-candidate",this._domNode.style.display="flex",this._domNode.style.columnGap="5px",this._domNode.style.alignItems="center",this._domNode.style.height=`${t.lineHeight}px`,this._domNode.style.padding=`${Gr._PADDING}px`;const i=document.createElement("div");i.style.display="flex",i.style.alignItems="center",i.style.width=i.style.height=`${t.lineHeight*.8}px`,this._domNode.appendChild(i),this._icon=o.renderIcon(a.Codicon.sparkle),this._icon.style.display="none",i.appendChild(this._icon),this._label=document.createElement("div"),o.applyFontInfo(this._label,t),this._domNode.appendChild(this._label),e.appendChild(this._domNode)}populate(e){this._updateIcon(e),this._updateLabel(e)}_updateIcon(e){const t=!!e.tags?.includes(a.NewSymbolNameTag.AIGenerated);this._icon.style.display=t?"inherit":"none"}_updateLabel(e){this._label.innerText=e.newSymbolName}static getLayoutInfo({lineHeight:e}){return{totalHeight:e+Gr._PADDING*2}}dispose(){}};Gr._PADDING=2;let rr=Gr;var lL=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},hn=function(c,e){return function(t,i){e(t,i,c)}},qu;class wl{constructor(e,t,i){this.model=e,this.position=t,this._providerRenameIdx=0,this._providers=i.ordered(e)}hasProvider(){return this._providers.length>0}async resolveRenameLocation(e){const t=[];for(this._providerRenameIdx=0;this._providerRenameIdx<this._providers.length;this._providerRenameIdx++){const n=this._providers[this._providerRenameIdx];if(!n.resolveRenameLocation)break;const s=await n.resolveRenameLocation(this.model,this.position,e);if(s){if(s.rejectReason){t.push(s.rejectReason);continue}return s}}this._providerRenameIdx=0;const i=this.model.getWordAtPosition(this.position);return i?{range:new a.Range(this.position.lineNumber,i.startColumn,this.position.lineNumber,i.endColumn),text:i.word,rejectReason:t.length>0?t.join(`
37
+ `):void 0}:{range:a.Range.fromPositions(this.position),text:"",rejectReason:t.length>0?t.join(`
38
+ `):void 0}}async provideRenameEdits(e,t){return this._provideRenameEdits(e,this._providerRenameIdx,[],t)}async _provideRenameEdits(e,t,i,n){const s=this._providers[t];if(!s)return{edits:[],rejectReason:i.join(`
39
+ `)};const r=await s.provideRenameEdits(this.model,this.position,e,n);if(r){if(r.rejectReason)return this._provideRenameEdits(e,t+1,i.concat(r.rejectReason),n)}else return this._provideRenameEdits(e,t+1,i.concat(a.localize(1449,"No result.")),n);return r}}function cL(c,e){return c.ordered(e).length>0}async function dL(c,e,t,i,n){return new wl(e,t,c).provideRenameEdits(i,n??a.CancellationToken.None)}async function hL(c,e,t,i){const n=new wl(e,t,c),s=await n.resolveRenameLocation(a.CancellationToken.None);return s?.rejectReason?{edits:[],rejectReason:s.rejectReason}:n.provideRenameEdits(i,a.CancellationToken.None)}let Jt=(Un=class{static get(e){return e.getContribution(qu.ID)}constructor(e,t,i,n,s,r,l,d){this.editor=e,this._instaService=t,this._notificationService=i,this._bulkEditService=n,this._progressService=s,this._logService=r,this._configService=l,this._languageFeaturesService=d,this._disposableStore=new a.DisposableStore,this._cts=new a.CancellationTokenSource,this._renameWidget=this._disposableStore.add(this._instaService.createInstance($u,this.editor,["acceptRenameInput","acceptRenameInputWithPreview"]))}dispose(){this._disposableStore.dispose(),this._cts.dispose(!0)}async run(){const e=this._logService.trace.bind(this._logService,"[rename]");if(this._cts.dispose(!0),this._cts=new a.CancellationTokenSource,!this.editor.hasModel()){e("editor has no model");return}const t=this.editor.getPosition(),i=new wl(this.editor.getModel(),t,this._languageFeaturesService.renameProvider);if(!i.hasProvider()){e("skeleton has no provider");return}const n=new o.EditorStateCancellationTokenSource(this.editor,5,void 0,this._cts.token);let s;try{e("resolving rename location");const m=i.resolveRenameLocation(n.token);this._progressService.showWhile(m,250),s=await m,e("resolved rename location")}catch(m){m instanceof a.CancellationError?e("resolve rename location cancelled",JSON.stringify(m,null," ")):(e("resolve rename location failed",m instanceof Error?m:JSON.stringify(m,null," ")),(typeof m=="string"||o.isMarkdownString(m))&&ve.get(this.editor)?.showMessage(m||a.localize(1450,"An unknown error occurred while resolving rename location"),t));return}finally{n.dispose()}if(!s){e("returning early - no loc");return}if(s.rejectReason){e(`returning early - rejected with reason: ${s.rejectReason}`,s.rejectReason),ve.get(this.editor)?.showMessage(s.rejectReason,t);return}if(n.token.isCancellationRequested){e("returning early - cts1 cancelled");return}const r=new o.EditorStateCancellationTokenSource(this.editor,5,s.range,this._cts.token),l=this.editor.getModel(),d=this._languageFeaturesService.newSymbolNamesProvider.all(l),h=await Promise.all(d.map(async m=>[m,await m.supportsAutomaticNewSymbolNamesTriggerKind??!1])),u=(m,_)=>{let v=h.slice();return m===a.NewSymbolNameTriggerKind.Automatic&&(v=v.filter(([b,C])=>C)),v.map(([b])=>b.provideNewSymbolNames(l,s.range,m,_))};e("creating rename input field and awaiting its result");const g=this._bulkEditService.hasPreviewHandler()&&this._configService.getValue(this.editor.getModel().uri,"editor.rename.enablePreview"),p=await this._renameWidget.getInput(s.range,s.text,g,d.length>0?u:void 0,r);if(e("received response from rename input field"),typeof p=="boolean"){e(`returning early - rename input field response - ${p}`),p&&this.editor.focus(),r.dispose();return}this.editor.focus(),e("requesting rename edits");const f=a.raceCancellation(i.provideRenameEdits(p.newName,r.token),r.token).then(async m=>{if(!m){e("returning early - no rename edits result");return}if(!this.editor.hasModel()){e("returning early - no model after rename edits are provided");return}if(m.rejectReason){e(`returning early - rejected with reason: ${m.rejectReason}`),this._notificationService.info(m.rejectReason);return}this.editor.setSelection(a.Range.fromPositions(this.editor.getSelection().getPosition())),e("applying edits"),this._bulkEditService.apply(m,{editor:this.editor,showPreview:p.wantsPreview,label:a.localize(1451,"Renaming '{0}' to '{1}'",s?.text,p.newName),code:"undoredo.rename",quotableLabel:a.localize(1452,"Renaming {0} to {1}",s?.text,p.newName),respectAutoSaveConfig:!0,reason:o.EditSources.rename(s?.text,p.newName)}).then(_=>{e("edits applied"),_.ariaSummary&&o.alert(a.localize(1453,"Successfully renamed '{0}' to '{1}'. Summary: {2}",s.text,p.newName,_.ariaSummary))}).catch(_=>{e(`error when applying edits ${JSON.stringify(_,null," ")}`),this._notificationService.error(a.localize(1454,"Rename failed to apply edits")),this._logService.error(_)})},m=>{e("error when providing rename edits",JSON.stringify(m,null," ")),this._notificationService.error(a.localize(1455,"Rename failed to compute edits")),this._logService.error(m)}).finally(()=>{r.dispose()});return e("returning rename operation"),this._progressService.showWhile(f,250),f}acceptRenameInput(e){this._renameWidget.acceptInput(e)}cancelRenameInput(){this._renameWidget.cancelInput(!0,"cancelRenameInput command")}focusNextRenameSuggestion(){this._renameWidget.focusNextRenameSuggestion()}focusPreviousRenameSuggestion(){this._renameWidget.focusPreviousRenameSuggestion()}},qu=Un,Un.ID="editor.contrib.renameController",Un);Jt=qu=lL([hn(1,o.IInstantiationService),hn(2,o.INotificationService),hn(3,o.IBulkEditService),hn(4,o.IEditorProgressService),hn(5,o.ILogService),hn(6,o.ITextResourceConfigurationService),hn(7,o.ILanguageFeaturesService)],Jt);class uL extends o.EditorAction{constructor(){super({id:"editor.action.rename",label:a.localize2(1457,"Rename Symbol"),precondition:o.ContextKeyExpr.and(o.EditorContextKeys.writable,o.EditorContextKeys.hasRenameProvider),kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:60,weight:100},contextMenuOpts:{group:"1_modification",order:1.1},canTriggerInlineEdits:!0})}runCommand(e,t){const i=e.get(o.ICodeEditorService),[n,s]=Array.isArray(t)&&t||[void 0,void 0];return a.URI.isUri(n)&&a.Position.isIPosition(s)?i.openCodeEditor({resource:n},i.getActiveCodeEditor()).then(r=>{r&&(r.setPosition(s),r.invokeWithinContext(l=>(this.reportTelemetry(l,r),this.run(l,r))))},a.onUnexpectedError):super.runCommand(e,t)}run(e,t){const i=e.get(o.ILogService),n=Jt.get(t);return n?(i.trace("[RenameAction] got controller, running..."),n.run()):(i.trace("[RenameAction] returning early - controller missing"),Promise.resolve())}}o.registerEditorContribution(Jt.ID,Jt,4),o.registerEditorAction(uL);const Gu=o.EditorCommand.bindToContribution(Jt.get);o.registerEditorCommand(new Gu({id:"acceptRenameInput",precondition:Ms,handler:c=>c.acceptRenameInput(!1),kbOpts:{weight:199,kbExpr:o.EditorContextKeys.focus,primary:3}})),o.registerEditorCommand(new Gu({id:"acceptRenameInputWithPreview",precondition:o.ContextKeyExpr.and(Ms,o.ContextKeyExpr.has("config.editor.rename.enablePreview")),handler:c=>c.acceptRenameInput(!0),kbOpts:{weight:199,kbExpr:o.EditorContextKeys.focus,primary:2051}})),o.registerEditorCommand(new Gu({id:"cancelRenameInput",precondition:Ms,handler:c=>c.cancelRenameInput(),kbOpts:{weight:199,kbExpr:o.EditorContextKeys.focus,primary:9,secondary:[1033]}})),o.registerAction2(class extends o.Action2{constructor(){super({id:"focusNextRenameSuggestion",title:{...a.localize2(1458,"Focus Next Rename Suggestion")},precondition:Ms,keybinding:[{primary:18,weight:199}]})}run(e){const t=e.get(o.ICodeEditorService).getFocusedCodeEditor();if(!t)return;const i=Jt.get(t);i&&i.focusNextRenameSuggestion()}}),o.registerAction2(class extends o.Action2{constructor(){super({id:"focusPreviousRenameSuggestion",title:{...a.localize2(1459,"Focus Previous Rename Suggestion")},precondition:Ms,keybinding:[{primary:16,weight:199}]})}run(e){const t=e.get(o.ICodeEditorService).getFocusedCodeEditor();if(!t)return;const i=Jt.get(t);i&&i.focusPreviousRenameSuggestion()}}),o.registerModelAndPositionCommand("_executeDocumentRenameProvider",function(c,e,t,...i){const[n]=i;a.assertType(typeof n=="string");const{renameProvider:s}=c.get(o.ILanguageFeaturesService);return hL(s,e,t,n)}),o.registerModelAndPositionCommand("_executePrepareRename",async function(c,e,t){const{renameProvider:i}=c.get(o.ILanguageFeaturesService),s=await new wl(e,t,i).resolveRenameLocation(a.CancellationToken.None);if(s?.rejectReason)throw new Error(s.rejectReason);return s}),o.Registry.as(o.Extensions.Configuration).registerConfiguration({id:"editor",properties:{"editor.rename.enablePreview":{scope:6,description:a.localize(1456,"Enable/disable the ability to preview changes before renaming"),default:!0,type:"boolean"}}});var gL=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Ps=function(c,e){return function(t,i){e(t,i,c)}},Pt;(function(c){c.no="no",c.yes="yes",c.maybe="maybe"})(Pt||(Pt={})),(function(c){function e(t){switch(t){case"no":return c.no;case"yes":return c.yes;case"maybe":return c.maybe;default:return c.no}}c.fromString=e})(Pt||(Pt={}));class pL{constructor(){}inferRename(e,t,i,n){const s=new a.Range(t.startLineNumber,1,t.endLineNumber,e.getLineMaxColumn(t.endLineNumber)),r=t.startColumn-s.startColumn,l=s.endColumn-t.endColumn,d=e.getValueInRange(s),h=e.getValueInRange(new a.Range(s.startLineNumber,s.startColumn,s.startLineNumber,s.startColumn+r))+i+e.getValueInRange(new a.Range(s.endLineNumber,s.endColumn-l,s.endLineNumber,s.endColumn)),u=[],g=[];let p,f,m;const _=e.getOffsetAt(s.getStartPosition()),{changes:v}=new a.LcsDiff(new a.StringDiffSequence(d),new a.StringDiffSequence(h)).ComputeDiff(!0);if(v.length===0)return;const b=[];for(const I of v){if(b.length===0){b.push(I);continue}const x=b[b.length-1],S=I.originalStart-(x.originalStart+x.originalLength);if(S>0){const w=_+x.originalStart+x.originalLength,E=e.getPositionAt(w),L=e.getWordAtPosition(E);if(L){const R=e.getOffsetAt(new a.Position(E.lineNumber,L.startColumn)),D=e.getOffsetAt(new a.Position(E.lineNumber,L.endColumn)),T=w+S;if(R<=w&&T<=D&&R<=T&&T<=D){x.originalLength=I.originalStart+I.originalLength-x.originalStart,x.modifiedLength=I.modifiedStart+I.modifiedLength-x.modifiedStart;continue}}}b.push(I)}let C=0;for(const I of b){const x=d.substring(I.originalStart,I.originalStart+I.originalLength),S=h.substring(I.modifiedStart,I.modifiedStart+I.modifiedLength),w=_+I.originalStart,E=e.getPositionAt(w),L=w+I.originalLength,R=e.getPositionAt(L),D=a.Range.fromPositions(E,R),T=S.length-I.originalLength;if(/\s/.test(x)){u.push(new a.TextReplacement(D,S)),C+=T;continue}if(x.length>0){n.lastIndex=0;const K=n.exec(x);if(K===null||K.index!==0||K[0].length!==x.length){u.push(new a.TextReplacement(D,S)),C+=T;continue}}if(/\s/.test(S)){u.push(new a.TextReplacement(D,S)),C+=T;continue}if(S.length>0){n.lastIndex=0;const K=n.exec(S);if(K===null||K.index!==0||K[0].length!==S.length){u.push(new a.TextReplacement(D,S)),C+=T;continue}}const P=e.getWordAtPosition(E);if(P===null){u.push(new a.TextReplacement(D,S)),C+=T;continue}const M=I.originalStart+1,V=I.originalLength===0&&I.modifiedLength>0;let F;if(V&&M===P.endColumn&&P.endColumn>P.startColumn?F=this.getTokenAtPosition(e,new a.Position(E.lineNumber,P.startColumn)):F=this.getTokenAtPosition(e,E),P.startColumn!==F.range.startColumn||P.endColumn!==F.range.endColumn){u.push(new a.TextReplacement(D,S)),C+=T;continue}if(F.type===0){let K=e.getValueInRange(F.range);if(K.length===0){u.push(new a.TextReplacement(D,S)),C+=T;continue}if(p===void 0)p=K;else if(p!==K){u.push(new a.TextReplacement(D,S)),C+=T;continue}const O=e.getOffsetAt(F.range.getStartPosition())-_+C,z=e.getOffsetAt(F.range.getEndPosition())-_+C;if(K=h.substring(O,z+T),K.length===0){u.push(new a.TextReplacement(D,S)),C+=T;continue}if(f===void 0)f=K;else if(f!==K){u.push(new a.TextReplacement(D,S)),C+=T;continue}m===void 0&&(m=F.range.getStartPosition()),p!==void 0&&f!==void 0&&p.length>0&&f.length>0&&p!==f?g.push(new a.TextReplacement(F.range,f)):g.push(new a.TextReplacement(D,S)),C+=T}else u.push(new a.TextReplacement(D,S)),C+=S.length-I.originalLength}if(p===void 0||f===void 0||m===void 0||p.length===0||f.length===0||p===f)return;n.lastIndex=0;let y=n.exec(p);if(!(y===null||y.index!==0||y[0].length!==p.length)&&(n.lastIndex=0,y=n.exec(f),!(y===null||y.index!==0||y[0].length!==f.length)))return{renames:{edits:g,position:m,oldName:p,newName:f},others:{edits:u}}}getTokenAtPosition(e,t){e.tokenization.tokenizeIfCheap(t.lineNumber);const i=e.tokenization.getLineTokens(t.lineNumber),n=i.findTokenIndexAtOffset(t.column-1);return{type:i.getStandardTokenType(n),range:new a.Range(t.lineNumber,1+i.getStartOffset(n),t.lineNumber,1+i.getEndOffset(n))}}}class ar{static create(e,t){const i=e.getFocusedCodeEditor();if(i!==null&&i.getModel()===t)return new ar(i,t.getVersionId())}constructor(e,t){this.editor=e,this.versionId=t}equals(e){return e===void 0?!1:this.editor===e.editor&&this.versionId===e.versionId}}class fL{constructor(e,t,i,n,s,r,l,d,h){if(this._result=void 0,this._commandService=t,this._textModel=n,this._state=s,this._requestUuid=i,this._cancellationTokenSource=new a.CancellationTokenSource,d===void 0||h===void 0){this._promise=dL(e.renameProvider,n,r,l,this._cancellationTokenSource.token);return}else this._promise=this.sendNesRenameRequest(n,r,h,l,d)}get requestUuid(){return this._requestUuid}isValid(e){return this._state.equals(ar.create(e,this._textModel))}cancel(){this._cancellationTokenSource.cancel()}async getCount(){if(this._cancellationTokenSource.token.isCancellationRequested)return 0;const e=await this.getResult();return e===void 0||this._cancellationTokenSource.token.isCancellationRequested?0:e.edits.length}async getWorkspaceEdit(){return this.getResult()}async getResult(){if(!this._cancellationTokenSource.token.isCancellationRequested&&(this._result===void 0&&(this._result=await this._promise),!(this._result.rejectReason||this._cancellationTokenSource.token.isCancellationRequested)))return this._result}async sendNesRenameRequest(e,t,i,n,s){try{const r=await this._commandService.executeCommand("github.copilot.nes.postRename",e.uri,t,i,n,s);if(r===void 0)return{rejectReason:"Rename failed",edits:[]};const l=[];for(const d of r)for(const h of d.changes){const u=new a.Range(h.range.start.line+1,h.range.start.character+1,h.range.end.line+1,h.range.end.character+1),g=new o.ResourceTextEdit(d.file,new a.TextReplacement(u,h.newText??n));l.push(g)}return{edits:l}}catch{return{rejectReason:"Rename failed",edits:[]}}}}let Zu=class extends a.Disposable{constructor(e,t,i,n,s,r){super(),this._commandService=e,this._languageFeaturesService=t,this._languageConfigurationService=i,this._renameSymbolTrackerService=s,this._codeEditorService=r,this._renameInferenceEngine=new pL,this._renameRunnable=void 0,this._register(o.CommandsRegistry.registerCommand(Sm,async(l,d,h)=>{if(!(h===void 0||!h.isValid(this._codeEditorService)))try{const u=await h.getWorkspaceEdit();if(u===void 0)return;n.apply(u,{reason:d})}finally{this._renameRunnable===h&&(this._renameRunnable=void 0)}}))}async proposeRenameRefactoring(e,t,i){if(!t.supportsRename||t.action?.kind!=="edit"||i.selectedSuggestionInfo||!cL(this._languageFeaturesService.renameProvider,e))return t;const n=ar.create(this._codeEditorService,e);if(n===void 0)return t;const s=Date.now(),r=t.action.textReplacement,l=this._languageConfigurationService.getLanguageConfiguration(e.getLanguageId()),d=this._renameInferenceEngine.inferRename(e,r.range,r.text,l.wordDefinition);if(d===void 0||d.renames.edits.length===0)return t;const{oldName:h,newName:u,position:g,edits:p}=d.renames,f=this._renameSymbolTrackerService.trackedWord.get();let m;f!==void 0&&f.model===e&&f.originalWord===h&&f.currentWord===u&&(m=f.currentRange);let _=!1;const v=await a.raceTimeout(this.checkRenamePrecondition(t,e,g,h,u,m),100,()=>{_=!0}),b=this.isRenamePossible(t,v,n,e);if(t.setRenameProcessingInfo({createdRename:b,duration:Date.now()-s,timedOut:_,droppedOtherEdits:b?d.others.edits.length:void 0,droppedRenameEdits:b?p.length-1:void 0}),!b)return t;this._renameRunnable===void 0&&(this._renameRunnable=new fL(this._languageFeaturesService,this._commandService,t.requestUuid,e,n,g,u,m,m!==void 0?h:void 0));const C=o.EditSources.inlineCompletionAccept({nes:t.isInlineEdit,requestUuid:t.requestUuid,providerId:t.source.provider.providerId,languageId:e.getLanguageId(),correlationId:t.getSourceCompletion().correlationId}),y={id:Sm,title:a.localize(1274,"Rename"),arguments:[C,this._renameRunnable]},I={label:a.localize(1275,"Rename"),icon:a.Codicon.replaceAll,command:y,count:this._renameRunnable.getCount()},x={kind:"edit",range:p[0].range,insertText:p[0].text,snippetInfo:t.snippetInfo,alternativeAction:I,uri:e.uri},S=Ns.snapshot(e);return bl.create(t.withAction(x),S,!1)}async checkRenamePrecondition(e,t,i,n,s,r){const l={canRename:Pt.no,timedOut:!1};try{const d=await this._commandService.executeCommand("github.copilot.nes.prepareRename",t.uri,i,n,s,e.requestUuid,r);if(d===void 0)return l;if(typeof d=="string"){const h=Pt.fromString(d);return h===Pt.yes||h===Pt.maybe?{canRename:h,oldName:n,onOldState:!1}:{canRename:h,timedOut:!1}}else return d}catch{return l}}isRenamePossible(e,t,i,n){return t===void 0||t.canRename===Pt.no||!i.equals(ar.create(this._codeEditorService,n))?!1:this._renameRunnable===void 0?!0:this._renameRunnable.requestUuid===e.requestUuid?!1:(this._renameRunnable.cancel(),this._renameRunnable=void 0,!0)}};Zu=gL([Ps(0,o.ICommandService),Ps(1,o.ILanguageFeaturesService),Ps(2,o.ILanguageConfigurationService),Ps(3,o.IBulkEditService),Ps(4,o.IRenameSymbolTrackerService),Ps(5,o.ICodeEditorService)],Zu);var mL=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Os=function(c,e){return function(t,i){e(t,i,c)}},Xu;let Yu=($n=class extends a.Disposable{constructor(e,t,i,n,s,r,l,d,h,u,g){super(),this._textModel=e,this._versionId=t,this._debounceValue=i,this._cursorPosition=n,this._languageConfigurationService=r,this._logService=l,this._configurationService=d,this._instantiationService=h,this._contextKeyService=u,this._textModelService=g,this._updateOperation=this._register(new a.MutableDisposable),this._state=PE(this,{initial:()=>({inlineCompletions:Ee.createEmpty(),suggestWidgetInlineCompletions:Ee.createEmpty()}),disposeFinal:p=>{p.inlineCompletions.dispose(),p.suggestWidgetInlineCompletions.dispose()},changeTracker:o.recordChangesLazy(()=>({versionId:this._versionId})),update:(p,f,m)=>{const _=a.StringEdit.compose(m.changes.map(v=>v.change?o.offsetEditFromContentChanges(v.change.changes):a.StringEdit.empty).filter(a.isDefined));if(_.isEmpty())return f;try{return{inlineCompletions:f.inlineCompletions.createStateWithAppliedEdit(_,this._textModel),suggestWidgetInlineCompletions:f.suggestWidgetInlineCompletions.createStateWithAppliedEdit(_,this._textModel)}}finally{f.inlineCompletions.dispose(),f.suggestWidgetInlineCompletions.dispose()}}}),this.inlineCompletions=this._state.map(this,p=>p.inlineCompletions),this.suggestWidgetInlineCompletions=this._state.map(this,p=>p.suggestWidgetInlineCompletions),this._completionsEnabled=void 0,this.clearOperationOnTextModelChange=o.derived(this,p=>{this._versionId.read(p),this._updateOperation.clear()}),this._loadingCount=o.observableValue(this,0),this.loading=this._loadingCount.map(this,p=>p>0),this._dataChannelTelemetryService=this._instantiationService.createInstance(zu),this._loggingEnabled=o.observableConfigValue("editor.inlineSuggest.logFetch",!1,this._configurationService).recomputeInitiallyAndOnChange(this._store),this._sendRequestData=o.observableConfigValue("editor.inlineSuggest.emptyResponseInformation",!0,this._configurationService).recomputeInitiallyAndOnChange(this._store),this._structuredFetchLogger=this._register(this._instantiationService.createInstance(ll.cast(),"editor.inlineSuggest.logFetch.commandId")),this._renameProcessor=this._store.add(this._instantiationService.createInstance(Zu)),this.clearOperationOnTextModelChange.recomputeInitiallyAndOnChange(this._store),s&&(this._updateCompletionsEnablement(s),this._register(this._configurationService.onDidChangeConfiguration(p=>{p.affectsConfiguration(s)&&this._updateCompletionsEnablement(s)}))),this._state.recomputeInitiallyAndOnChange(this._store)}_updateCompletionsEnablement(e){const t=this._configurationService.getValue(e);a.isObject(t)?this._completionsEnabled=t:this._completionsEnabled=void 0}_log(e){this._loggingEnabled.get()&&this._logService.info(pE(e)),this._structuredFetchLogger.log(e)}fetch(e,t,i,n,s,r,l){const d=this._cursorPosition.get(),h=new _L(d,i,this._textModel.getVersionId(),new Set(e)),u=i.selectedSuggestionInfo?this.suggestWidgetInlineCompletions.get():this.inlineCompletions.get();if(this._updateOperation.value?.request.satisfies(h))return this._updateOperation.value.promise;if(u?.request?.satisfies(h))return Promise.resolve(!0);const g=!!this._updateOperation.value;this._updateOperation.clear();const p=new a.CancellationTokenSource,f=(async()=>{const _=new a.DisposableStore;this._loadingCount.set(this._loadingCount.get()+1,void 0);let v=!1;const b=()=>{v||(v=!0,this._loadingCount.set(this._loadingCount.get()-1,void 0))};_.add(new a.RunOnceScheduler(()=>b(),10*1e3)).schedule();const y=e.filter(x=>x.providerId),I=new vL(i,l,y);try{const x=this._debounceValue.get(this._textModel),S=a.findLastMax(e.map(O=>O.debounceDelayMs),a.compareUndefinedSmallest(a.numberComparator))??x;if((g||s&&i.triggerKind===a.InlineCompletionTriggerKind.Automatic)&&await pv(S,p.token),p.token.isCancellationRequested||this._store.isDisposed||this._textModel.getVersionId()!==h.versionId)return I.setNoSuggestionReasonIfNotSet("canceled:beforeFetch"),!1;const E=Xu._requestId++;(this._loggingEnabled.get()||this._structuredFetchLogger.isEnabled.get())&&this._log({sourceId:"InlineCompletions.fetch",kind:"start",requestId:E,modelUri:this._textModel.uri,modelVersion:this._textModel.getVersionId(),context:{triggerKind:i.triggerKind,suggestInfo:i.selectedSuggestionInfo?!0:void 0},time:Date.now(),provider:t});const L=new Date,R=eL(e,this._cursorPosition.get(),this._textModel,i,l,this._languageConfigurationService);Dv(p.token,()=>R.cancelAndDispose({kind:"tokenCancellation"}));let D=!1,T=!1;const P=[];for await(const O of R.lists)if(O){O.addRef(),_.add(a.toDisposable(()=>O.removeRef(O.inlineSuggestionsData.length===0?{kind:"empty"}:{kind:"notTaken"})));for(const z of O.inlineSuggestionsData){if(T=!0,!i.includeInlineEdits&&(z.isInlineEdit||z.showInlineEditMenu)){z.setNotShownReason("notInlineEditRequested");continue}if(!i.includeInlineCompletions&&!(z.isInlineEdit||z.showInlineEditMenu)){z.setNotShownReason("notInlineCompletionRequested");continue}z.addPerformanceMarker("providerReturned");const Q=z.action?.uri;let j,U;if(Q&&Q.toString()!==this._textModel.uri.toString()){const G=await this._textModelService.createModelReference(Q);j=G.object.textEditorModel,U=G}else j=this._textModel,U=void 0;const W=Ns.snapshot(j),Y=bl.create(z,W);if(U){const G=o.runOnChange(Y.identity.onDispose,()=>{U?.dispose(),G.dispose()})}z.addPerformanceMarker("itemCreated"),P.push(Y),!Y.isInlineEdit&&!Y.showInlineEditMenu&&i.triggerKind===a.InlineCompletionTriggerKind.Automatic&&Y.isVisible(this._textModel,this._cursorPosition.get())&&(D=!0)}if(D)break}P.forEach(O=>O.addPerformanceMarker("providersResolved"));const M=await Promise.all(P.map(async O=>this._renameProcessor.proposeRenameRefactoring(this._textModel,O,i)));if(M.forEach(O=>O.addPerformanceMarker("renameProcessed")),R.cancelAndDispose({kind:"lostRace"}),this._loggingEnabled.get()||this._structuredFetchLogger.isEnabled.get()){const O=R.didAllProvidersReturn;let z;(p.token.isCancellationRequested||this._store.isDisposed||this._textModel.getVersionId()!==h.versionId)&&(z="canceled");const Q=M.map(j=>{const U=j.getSourceCompletion();if(U.doNotLog)return;const W={insertText:U.insertText,range:U.range,additionalTextEdits:U.additionalTextEdits,uri:U.uri,command:U.command,gutterMenuLinkAction:U.gutterMenuLinkAction,shownCommand:U.shownCommand,completeBracketPairs:U.completeBracketPairs,isInlineEdit:U.isInlineEdit,showInlineEditMenu:U.showInlineEditMenu,showRange:U.showRange,warning:U.warning,hint:U.hint,supportsRename:U.supportsRename,correlationId:U.correlationId,jumpToPosition:U.jumpToPosition};return{...a.cloneAndChange(W,Y=>a.Range.isIRange(Y)?a.Range.lift(Y).toString():a.Position.isIPosition(Y)?a.Position.lift(Y).toString():a.Command.is(Y)?{$commandId:Y.id}:Y),$providerId:j.source.provider.providerId?.toString()}}).filter(j=>j!==void 0);this._log({sourceId:"InlineCompletions.fetch",kind:"end",requestId:E,durationMs:Date.now()-L.getTime(),error:z,result:Q,time:Date.now(),didAllProvidersReturn:O})}if(I.setRequestUuid(R.contextWithUuid.requestUuid),T)I.setHasProducedSuggestion(),M.length>0&&p.token.isCancellationRequested&&M.forEach(O=>O.setNotShownReasonIfNotSet("canceled:whileAwaitingOtherProviders"));else if(p.token.isCancellationRequested)I.setNoSuggestionReasonIfNotSet("canceled:whileFetching");else{const O=this._contextKeyService.getContextKeyValue("completionsQuotaExceeded");I.setNoSuggestionReasonIfNotSet(O?"completionsQuotaExceeded":"noSuggestion")}const V=i.earliestShownDateTime-Date.now();if(V>0&&await pv(V,p.token),M.forEach(O=>O.addPerformanceMarker("minShowDelayPassed")),p.token.isCancellationRequested||this._store.isDisposed||this._textModel.getVersionId()!==h.versionId||r.get()){const O=p.token.isCancellationRequested?"canceled:afterMinShowDelay":this._store.isDisposed?"canceled:disposed":this._textModel.getVersionId()!==h.versionId?"canceled:documentChanged":r.get()?"canceled:userJumped":"unknown";return M.forEach(z=>z.setNotShownReasonIfNotSet(O)),!1}const F=new Date;this._debounceValue.update(this._textModel,F.getTime()-L.getTime());const K=this._cursorPosition.get();this._updateOperation.clear(),o.transaction(O=>{const z=this._state.get();i.selectedSuggestionInfo?this._state.set({inlineCompletions:Ee.createEmpty(),suggestWidgetInlineCompletions:z.suggestWidgetInlineCompletions.createStateWithAppliedResults(M,h,this._textModel,K,n)},O):this._state.set({inlineCompletions:z.inlineCompletions.createStateWithAppliedResults(M,h,this._textModel,K,n),suggestWidgetInlineCompletions:Ee.createEmpty()},O),z.inlineCompletions.dispose(),z.suggestWidgetInlineCompletions.dispose()})}finally{_.dispose(),b(),this._sendInlineCompletionsRequestTelemetry(I)}return!0})(),m=new CL(h,p,f);return this._updateOperation.value=m,f}clear(e){if(this._store.isDisposed)return;this._updateOperation.clear();const t=this._state.get();this._state.set({inlineCompletions:Ee.createEmpty(),suggestWidgetInlineCompletions:Ee.createEmpty()},e),t.inlineCompletions.dispose(),t.suggestWidgetInlineCompletions.dispose()}seedInlineCompletionsWithSuggestWidget(){const e=this.inlineCompletions.get(),t=this.suggestWidgetInlineCompletions.get();t&&o.transaction(i=>{if(!e||(t.request?.versionId??-1)>(e.request?.versionId??-1)){e?.dispose();const n=this._state.get();this._state.set({inlineCompletions:t.clone(),suggestWidgetInlineCompletions:Ee.createEmpty()},i),n.inlineCompletions.dispose(),n.suggestWidgetInlineCompletions.dispose()}this.clearSuggestWidgetInlineCompletions(i)})}seedWithCompletion(e,t){const i=this._state.get();this._state.set({inlineCompletions:new Ee([e],void 0),suggestWidgetInlineCompletions:Ee.createEmpty()},t),i.inlineCompletions.dispose(),i.suggestWidgetInlineCompletions.dispose()}_sendInlineCompletionsRequestTelemetry(e){if(!this._sendRequestData.get()&&!this._contextKeyService.getContextKeyValue("isRunningUnificationExperiment")||e.requestUuid===void 0||e.hasProducedSuggestion||!o.isCompletionsEnabledFromObject(this._completionsEnabled,this._textModel.getLanguageId())||!e.providers.some(i=>wv(i.providerId?.extensionId)))return;const t={opportunityId:e.requestUuid,noSuggestionReason:e.noSuggestionReason??"unknown",extensionId:"vscode-core",extensionVersion:"0.0.0",groupId:"empty",shown:!1,skuPlan:e.requestInfo.sku?.plan,skuType:e.requestInfo.sku?.type,editorType:e.requestInfo.editorType,requestReason:e.requestInfo.reason,typingInterval:e.requestInfo.typingInterval,typingIntervalCharacterCount:e.requestInfo.typingIntervalCharacterCount,languageId:e.requestInfo.languageId,selectedSuggestionInfo:!!e.context.selectedSuggestionInfo,availableProviders:e.providers.map(i=>i.providerId?.toString()).filter(a.isDefined).join(","),...FE(e.providers.some(i=>wv(i.providerId?.extensionId))),timeUntilProviderRequest:void 0,timeUntilProviderResponse:void 0,viewKind:void 0,preceeded:void 0,superseded:void 0,reason:void 0,acceptedAlternativeAction:void 0,correlationId:void 0,shownDuration:void 0,shownDurationUncollapsed:void 0,timeUntilShown:void 0,partiallyAccepted:void 0,partiallyAcceptedCountSinceOriginal:void 0,partiallyAcceptedRatioSinceOriginal:void 0,partiallyAcceptedCharactersSinceOriginal:void 0,cursorColumnDistance:void 0,cursorLineDistance:void 0,lineCountOriginal:void 0,lineCountModified:void 0,characterCountOriginal:void 0,characterCountModified:void 0,disjointReplacements:void 0,sameShapeReplacements:void 0,longDistanceHintVisible:void 0,longDistanceHintDistance:void 0,isForAnotherDocument:void 0,notShownReason:void 0,renameCreated:!1,renameDuration:void 0,renameTimedOut:!1,renameDroppedOtherEdits:void 0,renameDroppedRenameEdits:void 0,performanceMarkers:void 0,editKind:void 0};zE(this._dataChannelTelemetryService,t)}clearSuggestWidgetInlineCompletions(e){this._updateOperation.value?.request.context.selectedSuggestionInfo&&this._updateOperation.clear()}cancelUpdate(){this._updateOperation.clear()}},Xu=$n,$n._requestId=0,$n);Yu=Xu=mL([Os(5,o.ILanguageConfigurationService),Os(6,o.ILogService),Os(7,o.IConfigurationService),Os(8,o.IInstantiationService),Os(9,o.IContextKeyService),Os(10,o.ITextModelService)],Yu);class _L{constructor(e,t,i,n){this.position=e,this.context=t,this.versionId=i,this.providers=n}satisfies(e){return this.position.equals(e.position)&&o.equalsIfDefined(this.context.selectedSuggestionInfo,e.context.selectedSuggestionInfo,o.thisEqualsC())&&(e.context.triggerKind===a.InlineCompletionTriggerKind.Automatic||this.context.triggerKind===a.InlineCompletionTriggerKind.Explicit)&&this.versionId===e.versionId&&bL(e.providers,this.providers)}}class vL{constructor(e,t,i){this.context=e,this.requestInfo=t,this.providers=i,this.hasProducedSuggestion=!1}setRequestUuid(e){this.requestUuid=e}setNoSuggestionReasonIfNotSet(e){this.noSuggestionReason??=e}setHasProducedSuggestion(){this.hasProducedSuggestion=!0}}function bL(c,e){return[...c].every(t=>e.has(t))}class CL{constructor(e,t,i){this.request=e,this.cancellationTokenSource=t,this.promise=i}dispose(){this.cancellationTokenSource.cancel()}}class Ee extends a.Disposable{static createEmpty(){return new Ee([],void 0)}constructor(e,t){super(),this.inlineCompletions=e,this.request=t;for(const i of this.inlineCompletions)i.addRef();this._register({dispose:()=>{for(const i of this.inlineCompletions)i.removeRef()}})}_findById(e){return this.inlineCompletions.find(t=>t.identity===e)}_findByHash(e){return this.inlineCompletions.find(t=>t.hash===e)}createStateWithAppliedEdit(e,t){const i=this.inlineCompletions.map(n=>n.withEdit(e,t)).filter(a.isDefined);return new Ee(i,this.request)}createStateWithAppliedResults(e,t,i,n,s){let r;if(s){const h=this._findById(s);if(h&&h.canBeReused(i,t.position)){r=h;const u=e.find(g=>g.hash===h.hash);u?e=yL(u,e):e=[h,...e]}}const l=r?!r.isInlineEdit:e.some(h=>!h.isInlineEdit&&h.isVisible(i,n));let d=[];for(const h of e){const u=this._findByHash(h.hash);let g;u&&u!==h?(g=h.withIdentity(u.identity),h.setIsPreceeded(u),u.setEndOfLifeReason({kind:a.InlineCompletionEndOfLifeReasonKind.Ignored,userTypingDisagreed:!1,supersededBy:h.getSourceCompletion()})):g=h,l!==g.isInlineEdit&&d.push(g)}return d.sort(a.compareBy(h=>h.showInlineEditMenu,a.booleanComparator)),d=SL(d,h=>h.semanticId),new Ee(d,t)}clone(){return new Ee(this.inlineCompletions,this.request)}}function SL(c,e){const t=new Set;return c.filter(i=>{const n=e(i);return t.has(n)?!1:(t.add(n),!0)})}function yL(c,e){const t=e.indexOf(c);return t>-1?[c,...e.slice(0,t),...e.slice(t+1)]:e}const Te=class Te extends a.Disposable{getTypingInterval(){return(this._cacheInvalidated||this._cachedTypingIntervalResult===null)&&(this._cachedTypingIntervalResult=this._calculateTypingInterval(),this._cacheInvalidated=!1),this._cachedTypingIntervalResult}constructor(e){super(),this._textModel=e,this._typingSessions=[],this._currentSession=null,this._lastChangeTime=0,this._cachedTypingIntervalResult=null,this._cacheInvalidated=!0,this._register(this._textModel.onDidChangeContent(t=>this._updateTypingSpeed(t)))}_updateTypingSpeed(e){const t=Date.now();if(!this._isUserTyping(e)){this._finalizeCurrentSession();return}this._currentSession&&t-this._lastChangeTime>Te.MAX_SESSION_GAP_MS&&this._finalizeCurrentSession(),this._currentSession||(this._currentSession={startTime:t,endTime:t,characterCount:0}),this._currentSession.endTime=t,this._currentSession.characterCount+=this._getActualCharacterCount(e),this._lastChangeTime=t,this._cacheInvalidated=!0}_getActualCharacterCount(e){let t=0;for(const i of e.changes)t+=Math.max(i.text.length,i.rangeLength);return t}_isUserTyping(e){if(!e.detailedReasons||e.detailedReasons.length===0)return!1;for(const t of e.detailedReasons)if(this._isUserTypingReason(t))return!0;return!1}_isUserTypingReason(e){if(e.metadata.isUndoing||e.metadata.isRedoing)return!1;if(e.metadata.source==="cursor"){const t=e.metadata.kind;return t==="type"||t==="compositionType"||t==="compositionEnd"}else return!1}_finalizeCurrentSession(){if(!this._currentSession)return;this._currentSession.endTime-this._currentSession.startTime>=Te.MIN_SESSION_DURATION_MS&&this._currentSession.characterCount>0&&(this._typingSessions.push(this._currentSession),this._typingSessions.length>Te.SESSION_HISTORY_LIMIT&&this._typingSessions.shift()),this._currentSession=null}_calculateTypingInterval(){if(this._currentSession){const e={...this._currentSession};if(e.endTime-e.startTime>=Te.MIN_SESSION_DURATION_MS&&e.characterCount>0){const i=[...this._typingSessions,e];return this._calculateSpeedFromSessions(i)}}return this._calculateSpeedFromSessions(this._typingSessions)}_calculateSpeedFromSessions(e){if(e.length===0)return{averageInterval:0,characterCount:0};const t=[...e].sort((u,g)=>g.endTime-u.endTime),i=Date.now()-Te.TYPING_SPEED_WINDOW_MS,n=t.filter(u=>u.endTime>i),s=t.splice(n.length);let r=a.sum(n.map(u=>u.characterCount));for(let u=0;u<s.length&&r<Te.MIN_CHARS_FOR_RELIABLE_SPEED;u++)n.push(s[u]),r+=s[u].characterCount;const l=a.sum(n.map(u=>u.endTime-u.startTime));if(l===0||r<=1)return{averageInterval:0,characterCount:r};const d=Math.max(1,r-1),h=l/d;return{averageInterval:Math.round(h),characterCount:r}}dispose(){this._finalizeCurrentSession(),super.dispose()}};Te.MAX_SESSION_GAP_MS=3e3,Te.MIN_SESSION_DURATION_MS=1e3,Te.SESSION_HISTORY_LIMIT=50,Te.TYPING_SPEED_WINDOW_MS=3e5,Te.MIN_CHARS_FOR_RELIABLE_SPEED=20;let Qu=Te,Tv;function Nv(c){return Tv?.(c)??null}function wL(c){Tv=c}var IL=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Wt=function(c,e){return function(t,i){e(t,i,c)}};let Ju=class extends a.Disposable{get isAcceptingPartially(){return this._isAcceptingPartially}get editor(){return this._editor}constructor(e,t,i,n,s,r,l,d,h,u,g,p,f,m,_,v){super(),this.textModel=e,this._selectedSuggestItem=t,this._textModelVersionId=i,this._positions=n,this._debounceValue=s,this._enabled=r,this._isSuppressed=l,this._editor=d,this._instantiationService=h,this._commandService=u,this._languageConfigurationService=g,this._accessibilityService=p,this._languageFeaturesService=f,this._codeEditorService=m,this._inlineCompletionsService=_,this._isActive=o.observableValue(this,!1),this._onlyRequestInlineEditsSignal=o.observableSignal(this),this._forceUpdateExplicitlySignal=o.observableSignal(this),this._noDelaySignal=o.observableSignal(this),this._fetchSpecificProviderSignal=o.observableSignal(this),this._selectedInlineCompletionId=o.observableValue(this,void 0),this.primaryPosition=o.derived(this,S=>this._positions.read(S)[0]??new a.Position(1,1)),this.allPositions=o.derived(this,S=>this._positions.read(S)),this.sku=o.observableValue(this,void 0),this._isAcceptingPartially=!1,this._appearedInsideViewport=o.derived(this,S=>{const w=this.state.read(S);return!w||!w.inlineSuggestion?!1:Mv(this._editor,w.inlineSuggestion,S)}),this._onDidAccept=this._register(new a.Emitter),this.onDidAccept=this._onDidAccept.event,this._lastShownInlineCompletionInfo=void 0,this._lastAcceptedInlineCompletionInfo=void 0,this._didUndoInlineEdits=o.derivedHandleChanges({owner:this,changeTracker:{createChangeSummary:()=>({didUndo:!1}),handleChange:(S,w)=>(w.didUndo=S.didChange(this._textModelVersionId)&&!!S.change?.isUndoing,!0)}},(S,w)=>{const E=this._textModelVersionId.read(S);return E!==null&&this._lastAcceptedInlineCompletionInfo&&this._lastAcceptedInlineCompletionInfo.textModelVersionIdAfter===E-1&&this._lastAcceptedInlineCompletionInfo.inlineCompletion.isInlineEdit&&w.didUndo?(this._lastAcceptedInlineCompletionInfo=void 0,!0):!1}),this._preserveCurrentCompletionReasons=new Set([Ot.Redo,Ot.Undo,Ot.AcceptWord]),this.dontRefetchSignal=o.observableSignal(this),this._fetchInlineCompletionsPromise=o.derivedHandleChanges({owner:this,changeTracker:{createChangeSummary:()=>({dontRefetch:!1,preserveCurrentCompletion:!1,inlineCompletionTriggerKind:a.InlineCompletionTriggerKind.Automatic,onlyRequestInlineEdits:!1,shouldDebounce:!0,provider:void 0,changeHint:void 0,textChange:!1,changeReason:""}),handleChange:(S,w)=>{if(S.didChange(this._textModelVersionId)){this._preserveCurrentCompletionReasons.has(this._getReason(S.change))&&(w.preserveCurrentCompletion=!0);const E=S.change?.detailedReasons??[];w.changeReason=E.length>0?E[0].getType():"",w.textChange=!0}else S.didChange(this._forceUpdateExplicitlySignal)?(w.preserveCurrentCompletion=!0,w.inlineCompletionTriggerKind=a.InlineCompletionTriggerKind.Explicit):S.didChange(this.dontRefetchSignal)?w.dontRefetch=!0:S.didChange(this._onlyRequestInlineEditsSignal)?w.onlyRequestInlineEdits=!0:S.didChange(this._fetchSpecificProviderSignal)&&(w.provider=S.change?.provider,w.changeHint=S.change?.changeHint);return!0}}},(S,w)=>{if(this._source.clearOperationOnTextModelChange.read(S),this._noDelaySignal.read(S),this.dontRefetchSignal.read(S),this._onlyRequestInlineEditsSignal.read(S),this._forceUpdateExplicitlySignal.read(S),this._fetchSpecificProviderSignal.read(S),!(!this._isSuppressed()&&(this._enabled.read(S)&&this._selectedSuggestItem.read(S)||this._isActive.read(S))&&(!this._inlineCompletionsService.isSnoozing()||w.inlineCompletionTriggerKind===a.InlineCompletionTriggerKind.Explicit))){this._source.cancelUpdate();return}this._textModelVersionId.read(S);const L=this._source.suggestWidgetInlineCompletions.read(void 0);let R=this._selectedSuggestItem.read(S);if(this._shouldShowOnSuggestConflict.read(void 0)&&(R=void 0),L&&!R&&this._source.seedInlineCompletionsWithSuggestWidget(),w.dontRefetch)return Promise.resolve(!0);if(this._didUndoInlineEdits.read(S)&&w.inlineCompletionTriggerKind!==a.InlineCompletionTriggerKind.Explicit){o.transaction(Q=>{this._source.clear(Q)});return}let D="";w.provider?D+="providerOnDidChange":w.inlineCompletionTriggerKind===a.InlineCompletionTriggerKind.Explicit&&(D+="explicit"),w.changeReason&&(D+=D.length>0?`:${w.changeReason}`:w.changeReason);const T=this._typing.getTypingInterval(),P={editorType:this.editorType,startTime:Date.now(),languageId:this.textModel.getLanguageId(),reason:D,typingInterval:T.averageInterval,typingIntervalCharacterCount:T.characterCount,availableProviders:[],sku:this.sku.read(void 0)};let M={triggerKind:w.inlineCompletionTriggerKind,selectedSuggestionInfo:R?.toSelectedSuggestionInfo(),includeInlineCompletions:!w.onlyRequestInlineEdits,includeInlineEdits:this._inlineEditsEnabled.read(S),requestIssuedDateTime:P.startTime,earliestShownDateTime:P.startTime+(w.inlineCompletionTriggerKind===a.InlineCompletionTriggerKind.Explicit||this.inAcceptFlow.read(void 0)?0:this._minShowDelay.read(void 0)),changeHint:w.changeHint};M.triggerKind===a.InlineCompletionTriggerKind.Automatic&&w.textChange&&this.textModel.getAlternativeVersionId()===this._lastShownInlineCompletionInfo?.alternateTextModelVersionId&&(M={...M,includeInlineCompletions:!this._lastShownInlineCompletionInfo.inlineCompletion.isInlineEdit,includeInlineEdits:this._lastShownInlineCompletionInfo.inlineCompletion.isInlineEdit});const V=this.selectedInlineCompletion.read(void 0)??this._inlineSuggestionItems.read(void 0)?.inlineEdit,F=w.preserveCurrentCompletion||V?.forwardStable?V:void 0,K=this._jumpedToId.map(Q=>!!Q&&Q===this._inlineSuggestionItems.read(void 0)?.inlineEdit?.semanticId),O=w.provider?{providers:[w.provider],label:"single:"+w.provider.providerId?.toString()}:{providers:this._languageFeaturesService.inlineCompletionsProvider.all(this.textModel),label:void 0},z=this.getAvailableProviders(O.providers);return P.availableProviders=z.map(Q=>Q.providerId).filter(a.isDefined),this._source.fetch(z,O.label,M,F?.identity,w.shouldDebounce,K,P)}),this._inlineSuggestionItems=o.derivedOpts({owner:this},S=>{const w=this._source.inlineCompletions.read(S);if(!w)return;const E=this.primaryPosition.read(S);let L;const R=[];for(const D of w.inlineCompletions)D.isInlineEdit?L=D:D.isVisible(this.textModel,E)&&R.push(D);return R.length!==0&&(L=void 0),{inlineCompletions:R,inlineEdit:L}}),this._inlineCompletionItems=o.derivedOpts({owner:this,equalsFn:o.arrayEqualsC()},S=>this._inlineSuggestionItems.read(S)?.inlineCompletions??[]),this.selectedInlineCompletionIndex=o.derived(this,S=>{const w=this._selectedInlineCompletionId.read(S),E=this._inlineCompletionItems.read(S),L=this._selectedInlineCompletionId===void 0?-1:E.findIndex(R=>R.semanticId===w);return L===-1?(this._selectedInlineCompletionId.set(void 0,void 0),0):L}),this.selectedInlineCompletion=o.derived(this,S=>{const w=this._inlineCompletionItems.read(S),E=this.selectedInlineCompletionIndex.read(S);return w[E]}),this.activeCommands=o.derivedOpts({owner:this,equalsFn:o.arrayEqualsC()},S=>this.selectedInlineCompletion.read(S)?.source.inlineSuggestions.commands??[]),this.inlineCompletionsCount=o.derived(this,S=>{if(this.lastTriggerKind.read(S)===a.InlineCompletionTriggerKind.Explicit)return this._inlineCompletionItems.read(S).length}),this._hasVisiblePeekWidgets=o.derived(this,S=>this._editorObs.openedPeekWidgets.read(S)>0),this._shouldShowOnSuggestConflict=o.derived(this,S=>{const w=this._showOnSuggestConflict.read(S);if(w!=="never"&&!!this.selectedInlineCompletion.read(S)){const L=this._selectedSuggestItem.read(S);return L?w==="whenSuggestListIsIncomplete"?L.listIncomplete:!0:!1}return!1}),this.state=o.derivedOpts({owner:this,equalsFn:(S,w)=>!S||!w?S===w:S.kind==="ghostText"&&w.kind==="ghostText"?mv(S.ghostTexts,w.ghostTexts)&&S.inlineSuggestion===w.inlineSuggestion&&S.suggestItem===w.suggestItem:S.kind==="inlineEdit"&&w.kind==="inlineEdit"?S.inlineSuggestion===w.inlineSuggestion:!1},S=>{const w=this.textModel;if(this._suppressInSnippetMode.read(S)&&this._isInSnippetMode.read(S))return;const E=this._inlineSuggestionItems.read(S),L=E?.inlineEdit;if(L){if(this._hasVisiblePeekWidgets.read(S))return;const D=this.primaryPosition.map(V=>a.LineRange.fromRangeInclusive(L.targetRange).addMargin(1,1).contains(V.lineNumber)),T=L.action?.kind==="edit"?L.action.stringEdit:void 0,P=T?a.TextEdit.fromStringEdit(T,new o.TextModelText(this.textModel)).replacements:[];let M=(E.inlineEdit?.command?.id==="vscode.open"||E.inlineEdit?.command?.id==="_workbench.open")&&E.inlineEdit?.command.arguments?.length?a.URI.from(E.inlineEdit?.command.arguments[0]):void 0;return L.originalTextRef.targets(this.textModel)||(M=L.originalTextRef.uri),{kind:"inlineEdit",inlineSuggestion:L,edits:P,cursorAtInlineEdit:D,nextEditUri:M}}const R=this._selectedSuggestItem.read(S);if(!this._shouldShowOnSuggestConflict.read(S)&&R){const D=Yt(R.getSingleTextEdit(),w),T=this._computeAugmentation(D,S);if(!this._suggestPreviewEnabled.read(S)&&!T)return;const M=T?.edit??D,V=T?T.edit.text.length-D.text.length:0,F=this._suggestPreviewMode.read(S),K=this._positions.read(S),z=[M,...Wu(this.textModel,K,M)].map((W,Y)=>({edit:W,ghostText:W?bv(W,w,F,K[Y],V):void 0})).filter(({edit:W,ghostText:Y})=>W!==void 0&&Y!==void 0),Q=z.map(({edit:W})=>W),j=z.map(({ghostText:W})=>W),U=j[0]??new ir(M.range.endLineNumber,[]);return{kind:"ghostText",edits:Q,primaryGhostText:U,ghostTexts:j,inlineSuggestion:T?.completion,suggestItem:R}}else{if(!this._isActive.read(S))return;const D=this.selectedInlineCompletion.read(S);if(!D)return;const T=D.getSingleTextEdit(),P=this._inlineSuggestMode.read(S),M=this._positions.read(S),F=[T,...Wu(this.textModel,M,T)].map((z,Q)=>({edit:z,ghostText:z?bv(z,w,P,M[Q],0):void 0})).filter(({edit:z,ghostText:Q})=>z!==void 0&&Q!==void 0),K=F.map(({edit:z})=>z),O=F.map(({ghostText:z})=>z);return O[0]?{kind:"ghostText",edits:K,primaryGhostText:O[0],ghostTexts:O,inlineSuggestion:D,suggestItem:void 0}:void 0}}),this.status=o.derived(this,S=>{if(this._source.loading.read(S))return"loading";const w=this.state.read(S);return w?.kind==="ghostText"?"ghostText":w?.kind==="inlineEdit"?"inlineEdit":"noSuggestion"}),this.inlineCompletionState=o.derived(this,S=>{const w=this.state.read(S);if(!(!w||w.kind!=="ghostText")&&!this._editorObs.inComposition.read(S))return w}),this.inlineEditState=o.derived(this,S=>{const w=this.state.read(S);if(!(!w||w.kind!=="inlineEdit"))return w}),this.inlineEditAvailable=o.derived(this,S=>!!this.inlineEditState.read(S)),this.warning=o.derived(this,S=>this.inlineCompletionState.read(S)?.inlineSuggestion?.warning),this.ghostTexts=o.derivedOpts({owner:this,equalsFn:mv},S=>{const w=this.inlineCompletionState.read(S);if(w)return w.ghostTexts}),this.primaryGhostText=o.derivedOpts({owner:this,equalsFn:_v},S=>{const w=this.inlineCompletionState.read(S);if(w)return w?.primaryGhostText}),this.showCollapsed=o.derived(this,S=>{const w=this.state.read(S);if(!w||w.kind!=="inlineEdit"||w.inlineSuggestion.hint||w.inlineSuggestion.action?.kind==="jumpTo")return!1;const E=w.inlineSuggestion.updatedEditModelVersion===this._textModelVersionId.read(S);return(this._inlineEditsShowCollapsedEnabled.read(S)||!E)&&this._jumpedToId.read(S)!==w.inlineSuggestion.semanticId&&!this._inAcceptFlow.read(S)}),this._tabShouldIndent=o.derived(this,S=>{if(this._inAcceptFlow.read(S))return!1;function w(R){return R.startLineNumber!==R.endLineNumber}function E(R,D){const T=R.getLineIndentColumn(D),P=R.getLineLastNonWhitespaceColumn(D),M=Math.max(P,T);return new a.Range(D,T,D,M)}return this._editorObs.selections.read(S)?.some(R=>R.isEmpty()?this.textModel.getLineLength(R.startLineNumber)===0:w(R)||R.containsRange(E(this.textModel,R.startLineNumber)))}),this.tabShouldJumpToInlineEdit=o.derived(this,S=>{if(this._tabShouldIndent.read(S))return!1;const w=this.inlineEditState.read(S);return w?w.inlineSuggestion.action?.kind==="jumpTo"||this.showCollapsed.read(S)?!0:this._inAcceptFlow.read(S)&&this._appearedInsideViewport.read(S)?!1:!w.cursorAtInlineEdit.read(S):!1}),this.tabShouldAcceptInlineEdit=o.derived(this,S=>{const w=this.inlineEditState.read(S);return!w||w.inlineSuggestion.action?.kind==="jumpTo"||this.showCollapsed.read(S)||this._tabShouldIndent.read(S)?!1:this._inAcceptFlow.read(S)&&this._appearedInsideViewport.read(S)||w.inlineSuggestion.targetRange.startLineNumber===this._editorObs.cursorLineNumber.read(S)||this._jumpedToId.read(S)===w.inlineSuggestion.semanticId?!0:w.cursorAtInlineEdit.read(S)}),this._jumpedToId=o.observableValue(this,void 0),this._inAcceptFlow=o.observableValue(this,!1),this.inAcceptFlow=this._inAcceptFlow,this._source=this._register(this._instantiationService.createInstance(Yu,this.textModel,this._textModelVersionId,this._debounceValue,this.primaryPosition,o.product.defaultChatAgent?.completionsEnablementSetting)),this.lastTriggerKind=this._source.inlineCompletions.map(this,S=>S?.request?.context.triggerKind),this._editorObs=o.observableCodeEditor(this._editor);const b=this._editorObs.getOption(134);this._suggestPreviewEnabled=b.map(S=>S.preview),this._suggestPreviewMode=b.map(S=>S.previewMode);const C=this._editorObs.getOption(71);this._inlineSuggestMode=C.map(S=>S.mode),this._suppressedInlineCompletionGroupIds=C.map(S=>new Set(S.experimental.suppressInlineSuggestions.split(","))),this._inlineEditsEnabled=C.map(S=>!!S.edits.enabled),this._inlineEditsShowCollapsedEnabled=C.map(S=>S.edits.showCollapsed),this._triggerCommandOnProviderChange=C.map(S=>S.triggerCommandOnProviderChange),this._minShowDelay=C.map(S=>S.minShowDelay),this._showOnSuggestConflict=C.map(S=>S.experimental.showOnSuggestConflict),this._suppressInSnippetMode=C.map(S=>S.suppressInSnippetMode);const y=ne.get(this._editor);this._isInSnippetMode=y?.isInSnippetObservable??o.constObservable(!1),v.getDefaultAccount().then(LL(S=>this.sku.set(Pv(S),void 0),this._store)),this._register(v.onDidChangeDefaultAccount(S=>this.sku.set(Pv(S),void 0))),this._typing=this._register(new Qu(this.textModel)),this._register(this._inlineCompletionsService.onDidChangeIsSnoozing(S=>{S&&this.stop()}));{const S=this.textModel.uri.scheme===a.Schemas.vscodeNotebookCell,[w]=this._codeEditorService.listDiffEditors().filter(E=>E.getOriginalEditor().getId()===this._editor.getId()||E.getModifiedEditor().getId()===this._editor.getId());this.isInDiffEditor=!!w,this.editorType=S?te.Notebook:this.isInDiffEditor?te.DiffEditor:te.TextEditor}this._register(o.recomputeInitiallyAndOnChange(this.state,S=>{S&&S.inlineSuggestion&&this._inlineCompletionsService.reportNewCompletion(S.inlineSuggestion.requestUuid)})),this._register(o.recomputeInitiallyAndOnChange(this._fetchInlineCompletionsPromise)),this._register(o.autorun(S=>{this._editorObs.versionId.read(S),this._inAcceptFlow.set(!1,void 0)})),this._register(o.autorun(S=>{this.state.map((E,L)=>!E||E.kind==="inlineEdit"&&!E.cursorAtInlineEdit.read(L)).read(S)&&this._jumpedToId.set(void 0,void 0)})),this._register(o.autorun(S=>{const w=this.state.map(E=>E?.inlineSuggestion).read(S);w&&w.addPerformanceMarker("activeSuggestion")}));const I=this.inlineEditState.map(S=>S?.inlineSuggestion.semanticId);this._register(o.autorun(S=>{I.read(S)&&(this._editor.pushUndoStop(),this._lastShownInlineCompletionInfo={alternateTextModelVersionId:this.textModel.getAlternativeVersionId(),inlineCompletion:this.state.get().inlineSuggestion})}));const x=o.observableFromEvent(this._languageFeaturesService.inlineCompletionsProvider.onDidChange,()=>this._languageFeaturesService.inlineCompletionsProvider.all(e));o.mapObservableArrayCached(this,x,(S,w)=>{S.onDidChangeInlineCompletions&&w.add(S.onDidChangeInlineCompletions(E=>{if(!this._enabled.get()||(this._codeEditorService.getFocusedCodeEditor()||this._codeEditorService.getActiveCodeEditor())!==this._editor)return;if(this._triggerCommandOnProviderChange.get()){this.trigger(void 0,{onlyFetchInlineEdits:!0});return}const R=this.state.get();R&&(R.inlineSuggestion||R.edits)&&R.inlineSuggestion?.source.provider!==S||o.transaction(D=>{this._fetchSpecificProviderSignal.trigger(D,{provider:S,changeHint:E??void 0}),this.trigger(D)})}))}).recomputeInitiallyAndOnChange(this._store),this._didUndoInlineEdits.recomputeInitiallyAndOnChange(this._store)}getIndentationInfo(e){let t=!1,i=!0;const n=this?.primaryGhostText.read(e);if(this?._selectedSuggestItem&&n&&n.parts.length>0){const{column:s,lines:r}=n.parts[0],l=r[0].line,d=this.textModel.getLineIndentColumn(n.lineNumber);if(s<=d){let u=a.firstNonWhitespaceIndex(l);u===-1&&(u=l.length-1),t=u>0;const g=this.textModel.getOptions().tabSize;i=o.CursorColumns.visibleColumnFromColumn(l,u+1,g)<g}}return{startsWithIndentation:t,startsWithIndentationLessThanTabSize:i}}_getReason(e){return e?.isUndoing?Ot.Undo:e?.isRedoing?Ot.Redo:this.isAcceptingPartially?Ot.AcceptWord:Ot.Other}getAvailableProviders(e){const t=this._suppressedInlineCompletionGroupIds.get(),i=e.filter(r=>!(r.groupId&&t.has(r.groupId))),n=new Set;for(const r of i)r.excludesGroupIds?.forEach(l=>n.add(l));const s=[];for(const r of i)r.groupId&&n.has(r.groupId)||s.push(r);return s}async trigger(e,t={}){o.subtransaction(e,i=>{t.onlyFetchInlineEdits&&this._onlyRequestInlineEditsSignal.trigger(i),t.noDelay&&this._noDelaySignal.trigger(i),this._isActive.set(!0,i),t.explicit&&(this._inAcceptFlow.set(!0,i),this._forceUpdateExplicitlySignal.trigger(i)),t.provider&&this._fetchSpecificProviderSignal.trigger(i,{provider:t.provider,changeHint:t.changeHint})}),await this._fetchInlineCompletionsPromise.get()}async triggerExplicitly(e,t=!1){return this.trigger(e,{onlyFetchInlineEdits:t,explicit:!0})}stop(e="automatic",t){o.subtransaction(t,i=>{if(e==="explicitCancel"){const n=this.state.get()?.inlineSuggestion;n&&n.reportEndOfLife({kind:a.InlineCompletionEndOfLifeReasonKind.Rejected})}this._isActive.set(!1,i),this._source.clear(i)})}_computeAugmentation(e,t){const i=this.textModel,n=this._source.suggestWidgetInlineCompletions.read(t),s=n?n.inlineCompletions.filter(l=>!l.isInlineEdit):[this.selectedInlineCompletion.read(t)].filter(a.isDefined);return a.mapFindFirst(s,l=>{let d=l.getSingleTextEdit();return d=Yt(d,i,a.Range.fromPositions(d.range.getStartPosition(),e.range.getEndPosition())),vv(d,e)?{completion:l,edit:d}:void 0})}async _deltaSelectedInlineCompletionIndex(e){await this.triggerExplicitly();const t=this._inlineCompletionItems.get()||[];if(t.length>0){const i=(this.selectedInlineCompletionIndex.get()+e+t.length)%t.length;this._selectedInlineCompletionId.set(t[i].semanticId,void 0)}else this._selectedInlineCompletionId.set(void 0,void 0)}async next(){await this._deltaSelectedInlineCompletionIndex(1)}async previous(){await this._deltaSelectedInlineCompletionIndex(-1)}_getMetadata(e,t,i=void 0){return i?o.EditSources.inlineCompletionPartialAccept({nes:e.isInlineEdit,requestUuid:e.requestUuid,providerId:e.source.provider.providerId,languageId:t,type:i,correlationId:e.getSourceCompletion().correlationId}):o.EditSources.inlineCompletionAccept({nes:e.isInlineEdit,requestUuid:e.requestUuid,correlationId:e.getSourceCompletion().correlationId,providerId:e.source.provider.providerId,languageId:t})}async accept(e=this._editor,t=!1){if(e.getModel()!==this.textModel)throw new a.BugIndicatingError;let i,n=!1;const s=this.state.get();if(s?.kind==="ghostText"){if(!s||s.primaryGhostText.isEmpty()||!s.inlineSuggestion)return;i=s.inlineSuggestion}else if(s?.kind==="inlineEdit")i=s.inlineSuggestion,n=!!s.nextEditUri;else return;i.addRef();try{let r=!1;if(e.pushUndoStop(),i.originalTextRef.targets(this.textModel)){if(!n){if(i.action?.kind==="edit"){const l=i.action;if(t&&l.alternativeAction){r=!0;const d=l.alternativeAction.command;await this._commandService.executeCommand(d.id,...d.arguments||[]).then(void 0,a.onUnexpectedExternalError)}else if(l.snippetInfo){const d=a.TextReplacement.delete(l.textReplacement.range),h=i.additionalTextEdits.map(g=>new a.TextReplacement(a.Range.lift(g.range),g.text??"")),u=a.TextEdit.fromParallelReplacementsUnsorted([d,...h]);e.edit(u,this._getMetadata(i,this.textModel.getLanguageId())),e.setPosition(l.snippetInfo.range.getStartPosition(),"inlineCompletionAccept"),ne.get(e)?.insert(l.snippetInfo.snippet,{undoStopBefore:!1})}else{const d=s.edits;let h=d;s.kind==="ghostText"&&(h=EE(d,this.textModel));const u=gv(h).map(f=>a.Selection.fromPositions(f)),g=i.additionalTextEdits.map(f=>new a.TextReplacement(a.Range.lift(f.range),f.text??"")),p=a.TextEdit.fromParallelReplacementsUnsorted([...d,...g]);if(e.edit(p,this._getMetadata(i,this.textModel.getLanguageId())),i.hint===void 0&&e.setSelections(s.kind==="inlineEdit"?u.slice(-1):u,"inlineCompletionAccept"),s.kind==="inlineEdit"&&!this._accessibilityService.isMotionReduced()){const f=p.getNewRanges(),m=this._store.add(new xL(e,f,()=>{this._store.delete(m)}))}}}}}else{const l=await this._codeEditorService.openCodeEditor({resource:i.originalTextRef.uri},this._editor);if(l){const h=Nv(l)?.model.get();l.focus(),h?.transplantCompletion(i),l.revealLineInCenter(i.targetRange.startLineNumber)}}this._onDidAccept.fire(),this.stop(),i.command&&await this._commandService.executeCommand(i.command.id,...i.command.arguments||[]).then(void 0,a.onUnexpectedExternalError),r&&this.trigger(void 0),i.reportEndOfLife({kind:a.InlineCompletionEndOfLifeReasonKind.Accepted,alternativeAction:t})}finally{i.removeRef(),this._inAcceptFlow.set(!0,void 0),this._lastAcceptedInlineCompletionInfo={textModelVersionIdAfter:this.textModel.getVersionId(),inlineCompletion:i}}}async acceptNextWord(){await this._acceptNext(this._editor,"word",(e,t)=>{const i=this.textModel.getLanguageIdAtPosition(e.lineNumber,e.column),n=this._languageConfigurationService.getLanguageConfiguration(i),s=new RegExp(n.wordDefinition.source,n.wordDefinition.flags.replace("g","")),r=t.match(s);let l=0;r&&r.index!==void 0?r.index===0?l=r[0].length:l=r.index:l=t.length;const h=/\s+/g.exec(t);return h&&h.index!==void 0&&h.index+h[0].length<l&&(l=h.index+h[0].length),l},0)}async acceptNextLine(){await this._acceptNext(this._editor,"line",(e,t)=>{const i=t.match(/\n/);return i&&i.index!==void 0?i.index+1:t.length},1)}async _acceptNext(e,t,i,n){if(e.getModel()!==this.textModel)throw new a.BugIndicatingError;const s=this.inlineCompletionState.get();if(!s||s.primaryGhostText.isEmpty()||!s.inlineSuggestion)return;const r=s.primaryGhostText,l=s.inlineSuggestion;if(l.snippetInfo){await this.accept(e);return}const d=r.parts[0],h=new a.Position(r.lineNumber,d.column),u=d.text,g=i(h,u);if(g===u.length&&r.parts.length===1){this.accept(e);return}const p=u.substring(0,g),f=this._positions.get(),m=f[0];l.addRef();try{this._isAcceptingPartially=!0;try{e.pushUndoStop();const C=a.Range.fromPositions(m,h),y=e.getModel().getValueInRange(C)+p,I=new a.TextReplacement(C,y),x=[I,...Wu(this.textModel,f,I)].filter(a.isDefined),S=gv(x).map(w=>a.Selection.fromPositions(w));e.edit(a.TextEdit.fromParallelReplacementsUnsorted(x),this._getMetadata(l,this.textModel.getLanguageId(),t)),e.setSelections(S,"inlineCompletionPartialAccept"),e.revealPositionInCenterIfOutsideViewport(e.getPosition(),0)}finally{this._isAcceptingPartially=!1}const _=a.Range.fromPositions(l.editRange.getStartPosition(),a.TextLength.ofText(p).addToPosition(h)),b=e.getModel().getValueInRange(_,1).length;l.reportPartialAccept(b,{kind:n,acceptedLength:b},{characters:g,ratio:g/u.length,count:1})}finally{l.removeRef()}}handleSuggestAccepted(e){const t=Yt(e.getSingleTextEdit(),this.textModel),i=this._computeAugmentation(t,void 0);if(!i)return;const s=this.textModel.getValueInRange(i.completion.editRange,1).length+t.text.length;i.completion.reportPartialAccept(t.text.length,{kind:2,acceptedLength:s},{characters:t.text.length,count:1,ratio:1})}extractReproSample(){const e=this.textModel.getValue(),t=this.state.get()?.inlineSuggestion;return{documentValue:e,inlineCompletion:t?.getSourceCompletion()}}jump(){const e=this.inlineEditState.get();if(!e)return;const t=e.inlineSuggestion;if(!t.originalTextRef.targets(this.textModel)){this.accept(this._editor);return}t.addRef();try{o.transaction(i=>{t.action?.kind==="jumpTo"&&(this.stop(void 0,i),t.reportEndOfLife({kind:a.InlineCompletionEndOfLifeReasonKind.Accepted,alternativeAction:!1})),this._jumpedToId.set(e.inlineSuggestion.semanticId,i),this.dontRefetchSignal.trigger(i);const n=e.inlineSuggestion.targetRange,s=n.getStartPosition();if(this._editor.setPosition(s,"inlineCompletions.jump"),n.isSingleLine()&&(e.inlineSuggestion.hint||e.inlineSuggestion.action?.kind==="edit"&&!e.inlineSuggestion.action.textReplacement.text.includes(`
40
+ `))||e.inlineSuggestion.action?.kind==="jumpTo")this._editor.revealPosition(s,0);else{const l=new a.Range(n.startLineNumber-1,1,n.endLineNumber+1,1);this._editor.revealRange(l,0)}e.inlineSuggestion.identity.setJumpTo(i),this._editor.focus()})}finally{t.removeRef()}}async handleInlineSuggestionShown(e,t,i,n){await e.reportInlineEditShown(this._commandService,t,i,this.textModel,n)}transplantCompletion(e){o.transaction(t=>{this._source.seedWithCompletion(e,t),this._isActive.set(!0,t),this._inAcceptFlow.set(!0,t),this.dontRefetchSignal.trigger(t)})}};Ju=IL([Wt(8,o.IInstantiationService),Wt(9,o.ICommandService),Wt(10,o.ILanguageConfigurationService),Wt(11,o.IAccessibilityService),Wt(12,o.ILanguageFeaturesService),Wt(13,o.ICodeEditorService),Wt(14,o.IInlineCompletionsService),Wt(15,o.IDefaultAccountService)],Ju);var Ot;(function(c){c[c.Undo=0]="Undo",c[c.Redo=1]="Redo",c[c.AcceptWord=2]="AcceptWord",c[c.Other=3]="Other"})(Ot||(Ot={}));function Wu(c,e,t){if(e.length===1)return[];const i=new o.TextModelText(c),n=i.getTransformer(),s=n.getOffset(e[0]),r=e.slice(1).map(p=>n.getOffset(p));t=t.removeCommonPrefixAndSuffix(i);const l=n.getStringReplacement(t),d=l.replaceRange.start-s,h=l.replaceRange.join(a.OffsetRange.emptyAt(s)),u=i.getValueOfOffsetRange(h);return r.map(p=>{const f=p+d,m=f+l.replaceRange.length,_=new a.OffsetRange(f,m),v=_.join(a.OffsetRange.emptyAt(p));if(i.getValueOfOffsetRange(v)!==u)return;const C=new a.StringReplacement(_,l.newText);return n.getTextReplacement(C)}).filter(a.isDefined)}class xL extends a.Disposable{constructor(e,t,i){super(),i&&this._register({dispose:()=>i()}),this._register(o.observableCodeEditor(e).setDecorations(o.constObservable(t.map(s=>({range:s,options:{description:"animation",className:"edits-fadeout-decoration",zIndex:1}})))));const n=new TE(Au.startNow(1,0,1e3,RE));this._register(o.autorun(s=>{const r=n.getValue(s);e.getContainerDomNode().style.setProperty("--animation-opacity",r.toString()),n.isFinished(s)&&this.dispose()}))}}function Mv(c,e,t=void 0){const i=e.targetRange;o.observableCodeEditor(c).scrollTop.read(t);const n=c.getVisibleRanges();return n.length<1?!1:new a.Range(n[0].startLineNumber,n[0].startColumn,n[n.length-1].endLineNumber,n[n.length-1].endColumn).containsRange(i)}function Pv(c){if(c?.entitlementsData?.access_type_sku&&c?.entitlementsData?.copilot_plan)return{type:c.entitlementsData.access_type_sku,plan:c.entitlementsData.copilot_plan}}class EL{constructor(e){this.handler=t=>this._cb?.(t),this._cb=e}dispose(){this._cb=void 0}}function LL(c,e){const t=new EL(c);return e.add(t),t.handler}var DL=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Ov=function(c,e){return function(t,i){e(t,i,c)}},lr;class Hu{constructor(e){this.name=e}select(e,t,i){if(i.length===0)return 0;const n=i[0].score[0];for(let s=0;s<i.length;s++){const{score:r,completion:l}=i[s];if(r[0]!==n)break;if(l.preselect)return s}return 0}}class Av extends Hu{constructor(){super("first")}memorize(e,t,i){}toJSON(){}fromJSON(){}}class RL extends Hu{constructor(){super("recentlyUsed"),this._cache=new a.LRUCache(300,.66),this._seq=0}memorize(e,t,i){const n=`${e.getLanguageId()}/${i.textLabel}`;this._cache.set(n,{touch:this._seq++,type:i.completion.kind,insertText:i.completion.insertText})}select(e,t,i){if(i.length===0)return 0;const n=e.getLineContent(t.lineNumber).substr(t.column-10,t.column-1);if(/\s$/.test(n))return super.select(e,t,i);const s=i[0].score[0];let r=-1,l=-1,d=-1;for(let h=0;h<i.length&&i[h].score[0]===s;h++){const u=`${e.getLanguageId()}/${i[h].textLabel}`,g=this._cache.peek(u);if(g&&g.touch>d&&g.type===i[h].completion.kind&&g.insertText===i[h].completion.insertText&&(d=g.touch,l=h),i[h].completion.preselect&&r===-1)return r=h}return l!==-1?l:r!==-1?r:0}toJSON(){return this._cache.toJSON()}fromJSON(e){this._cache.clear();const t=0;for(const[i,n]of e)n.touch=t,n.type=typeof n.type=="number"?n.type:a.CompletionItemKinds.fromString(n.type),this._cache.set(i,n);this._seq=this._cache.size}}class TL extends Hu{constructor(){super("recentlyUsedByPrefix"),this._trie=o.TernarySearchTree.forStrings(),this._seq=0}memorize(e,t,i){const{word:n}=e.getWordUntilPosition(t),s=`${e.getLanguageId()}/${n}`;this._trie.set(s,{type:i.completion.kind,insertText:i.completion.insertText,touch:this._seq++})}select(e,t,i){const{word:n}=e.getWordUntilPosition(t);if(!n)return super.select(e,t,i);const s=`${e.getLanguageId()}/${n}`;let r=this._trie.get(s);if(r||(r=this._trie.findSubstr(s)),r)for(let l=0;l<i.length;l++){const{kind:d,insertText:h}=i[l].completion;if(d===r.type&&h===r.insertText)return l}return super.select(e,t,i)}toJSON(){const e=[];return this._trie.forEach((t,i)=>e.push([i,t])),e.sort((t,i)=>-(t[1].touch-i[1].touch)).forEach((t,i)=>t[1].touch=i),e.slice(0,200)}fromJSON(e){if(this._trie.clear(),e.length>0){this._seq=e[0][1].touch+1;for(const[t,i]of e)i.type=typeof i.type=="number"?i.type:a.CompletionItemKinds.fromString(i.type),this._trie.set(t,i)}}}let eg=(Di=class{constructor(e,t){this._storageService=e,this._configService=t,this._disposables=new a.DisposableStore,this._persistSoon=new a.RunOnceScheduler(()=>this._saveState(),500),this._disposables.add(e.onWillSaveState(i=>{i.reason===o.WillSaveStateReason.SHUTDOWN&&this._saveState()}))}dispose(){this._disposables.dispose(),this._persistSoon.dispose()}memorize(e,t,i){this._withStrategy(e,t).memorize(e,t,i),this._persistSoon.schedule()}select(e,t,i){return this._withStrategy(e,t).select(e,t,i)}_withStrategy(e,t){const i=this._configService.getValue("editor.suggestSelection",{overrideIdentifier:e.getLanguageIdAtPosition(t.lineNumber,t.column),resource:e.uri});if(this._strategy?.name!==i){this._saveState();const n=lr._strategyCtors.get(i)||Av;this._strategy=new n;try{const r=this._configService.getValue("editor.suggest.shareSuggestSelections")?0:1,l=this._storageService.get(`${lr._storagePrefix}/${i}`,r);l&&this._strategy.fromJSON(JSON.parse(l))}catch{}}return this._strategy}_saveState(){if(this._strategy){const t=this._configService.getValue("editor.suggest.shareSuggestSelections")?0:1,i=JSON.stringify(this._strategy);this._storageService.store(`${lr._storagePrefix}/${this._strategy.name}`,i,t,1)}}},lr=Di,Di._strategyCtors=new Map([["recentlyUsedByPrefix",TL],["recentlyUsed",RL],["first",Av]]),Di._storagePrefix="suggest/memories",Di);eg=lr=DL([Ov(0,o.IStorageService),Ov(1,o.IConfigurationService)],eg);const Il=o.createDecorator("ISuggestMemories");o.registerSingleton(Il,eg,1);var NL=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},ML=function(c,e){return function(t,i){e(t,i,c)}},tg;let xl=(jn=class{constructor(e,t){this._editor=e,this._enabled=!1,this._ckAtEnd=tg.AtEnd.bindTo(t),this._configListener=this._editor.onDidChangeConfiguration(i=>i.hasChanged(139)&&this._update()),this._update()}dispose(){this._configListener.dispose(),this._selectionListener?.dispose(),this._ckAtEnd.reset()}_update(){const e=this._editor.getOption(139)==="on";if(this._enabled!==e)if(this._enabled=e,this._enabled){const t=()=>{if(!this._editor.hasModel()){this._ckAtEnd.set(!1);return}const i=this._editor.getModel(),n=this._editor.getSelection(),s=i.getWordAtPosition(n.getStartPosition());if(!s){this._ckAtEnd.set(!1);return}this._ckAtEnd.set(s.endColumn===n.getStartPosition().column&&n.getStartPosition().lineNumber===n.getEndPosition().lineNumber)};this._selectionListener=this._editor.onDidChangeCursorSelection(t),t()}else this._selectionListener&&(this._ckAtEnd.reset(),this._selectionListener.dispose(),this._selectionListener=void 0)}},tg=jn,jn.AtEnd=new o.RawContextKey("atEndOfWord",!1,{type:"boolean",description:a.localize(1568,"A context key that is true when at the end of a word. Note that this is only defined when tab-completions are enabled")}),jn);xl=tg=NL([ML(1,o.IContextKeyService)],xl);var PL=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},OL=function(c,e){return function(t,i){e(t,i,c)}},cr;let As=(qn=class{constructor(e,t){this._editor=e,this._index=0,this._ckOtherSuggestions=cr.OtherSuggestions.bindTo(t)}dispose(){this.reset()}reset(){this._ckOtherSuggestions.reset(),this._listener?.dispose(),this._model=void 0,this._acceptNext=void 0,this._ignore=!1}set({model:e,index:t},i){if(e.items.length===0){this.reset();return}if(cr._moveIndex(!0,e,t)===t){this.reset();return}this._acceptNext=i,this._model=e,this._index=t,this._listener=this._editor.onDidChangeCursorPosition(()=>{this._ignore||this.reset()}),this._ckOtherSuggestions.set(!0)}static _moveIndex(e,t,i){let n=i;for(let s=t.items.length;s>0&&(n=(n+t.items.length+(e?1:-1))%t.items.length,!(n===i||!t.items[n].completion.additionalTextEdits));s--);return n}next(){this._move(!0)}prev(){this._move(!1)}_move(e){if(this._model)try{this._ignore=!0,this._index=cr._moveIndex(e,this._model,this._index),this._acceptNext({index:this._index,item:this._model.items[this._index],model:this._model})}finally{this._ignore=!1}}},cr=qn,qn.OtherSuggestions=new o.RawContextKey("hasOtherSuggestions",!1),qn);As=cr=PL([OL(1,o.IContextKeyService)],As);class AL{constructor(e,t,i,n){this._disposables=new a.DisposableStore,this._disposables.add(i.onDidSuggest(s=>{s.completionModel.items.length===0&&this.reset()})),this._disposables.add(i.onDidCancel(s=>{this.reset()})),this._disposables.add(t.onDidShow(()=>this._onItem(t.getFocusedItem()))),this._disposables.add(t.onDidFocus(this._onItem,this)),this._disposables.add(t.onDidHide(this.reset,this)),this._disposables.add(e.onWillType(s=>{if(this._active&&!t.isFrozen()&&i.state!==0){const r=s.charCodeAt(s.length-1);this._active.acceptCharacters.has(r)&&e.getOption(0)&&n(this._active.item)}}))}_onItem(e){if(!e||!a.isNonEmptyArray(e.item.completion.commitCharacters)){this.reset();return}if(this._active&&this._active.item.item===e.item)return;const t=new a.CharacterSet;for(const i of e.item.completion.commitCharacters)i.length>0&&t.add(i.charCodeAt(0));this._active={acceptCharacters:t,item:e}}reset(){this._active=void 0}dispose(){this._disposables.dispose()}}let Fv=class{constructor(e,t){this.leadingLineContent=e,this.characterCountDelta=t}};class Ht{constructor(e,t,i,n,s,r,l=o.FuzzyScoreOptions.default,d=void 0){this.clipboardText=d,this._snippetCompareFn=Ht._compareCompletionItems,this._items=e,this._column=t,this._wordDistance=n,this._options=s,this._refilterKind=1,this._lineContext=i,this._fuzzyScoreOptions=l,r==="top"?this._snippetCompareFn=Ht._compareCompletionItemsSnippetsUp:r==="bottom"&&(this._snippetCompareFn=Ht._compareCompletionItemsSnippetsDown)}get lineContext(){return this._lineContext}set lineContext(e){(this._lineContext.leadingLineContent!==e.leadingLineContent||this._lineContext.characterCountDelta!==e.characterCountDelta)&&(this._refilterKind=this._lineContext.characterCountDelta<e.characterCountDelta&&this._filteredItems?2:1,this._lineContext=e)}get items(){return this._ensureCachedState(),this._filteredItems}getItemsByProvider(){return this._ensureCachedState(),this._itemsByProvider}getIncompleteProvider(){this._ensureCachedState();const e=new Set;for(const[t,i]of this.getItemsByProvider())i.length>0&&i[0].container.incomplete&&e.add(t);return e}get stats(){return this._ensureCachedState(),this._stats}_ensureCachedState(){this._refilterKind!==0&&this._createCachedState()}_createCachedState(){this._itemsByProvider=new Map;const e=[],{leadingLineContent:t,characterCountDelta:i}=this._lineContext;let n="",s="";const r=this._refilterKind===1?this._items:this._filteredItems,l=[],d=!this._options.filterGraceful||r.length>2e3?o.fuzzyScore:o.fuzzyScoreGracefulAggressive;for(let h=0;h<r.length;h++){const u=r[h];if(u.isInvalid)continue;const g=this._itemsByProvider.get(u.provider);g?g.push(u):this._itemsByProvider.set(u.provider,[u]);const p=u.position.column-u.editStart.column,f=p+i-(u.position.column-this._column);if(n.length!==f&&(n=f===0?"":t.slice(-f),s=n.toLowerCase()),u.word=n,f===0)u.score=o.FuzzyScore.Default;else{let m=0;for(;m<p;){const _=n.charCodeAt(m);if(_===32||_===9)m+=1;else break}if(m>=f)u.score=o.FuzzyScore.Default;else if(typeof u.completion.filterText=="string"){const _=d(n,s,m,u.completion.filterText,u.filterTextLow,0,this._fuzzyScoreOptions);if(!_)continue;a.compareIgnoreCase(u.completion.filterText,u.textLabel)===0?u.score=_:(u.score=o.anyScore(n,s,m,u.textLabel,u.labelLow,0),u.score[0]=_[0])}else{const _=d(n,s,m,u.textLabel,u.labelLow,0,this._fuzzyScoreOptions);if(!_)continue;u.score=_}}u.idx=h,u.distance=this._wordDistance.distance(u.position,u.completion),l.push(u),e.push(u.textLabel.length)}this._filteredItems=l.sort(this._snippetCompareFn),this._refilterKind=0,this._stats={pLabelLen:e.length?a.quickSelect(e.length-.85,e,(h,u)=>h-u):0}}static _compareCompletionItems(e,t){return e.score[0]>t.score[0]?-1:e.score[0]<t.score[0]?1:e.distance<t.distance?-1:e.distance>t.distance?1:e.idx<t.idx?-1:e.idx>t.idx?1:0}static _compareCompletionItemsSnippetsDown(e,t){if(e.completion.kind!==t.completion.kind){if(e.completion.kind===28)return 1;if(t.completion.kind===28)return-1}return Ht._compareCompletionItems(e,t)}static _compareCompletionItemsSnippetsUp(e,t){if(e.completion.kind!==t.completion.kind){if(e.completion.kind===28)return-1;if(t.completion.kind===28)return 1}return Ht._compareCompletionItems(e,t)}}const Ne=class Ne{async provideSelectionRanges(e,t){const i=[];for(const n of t){const s=[];i.push(s);const r=new Map;await new Promise(l=>Ne._bracketsRightYield(l,0,e,n,r)),await new Promise(l=>Ne._bracketsLeftYield(l,0,e,n,r,s))}return i}static _bracketsRightYield(e,t,i,n,s){const r=new Map,l=Date.now();for(;;){if(t>=Ne._maxRounds){e();break}if(!n){e();break}const d=i.bracketPairs.findNextBracket(n);if(!d){e();break}if(Date.now()-l>Ne._maxDuration){setTimeout(()=>Ne._bracketsRightYield(e,t+1,i,n,s));break}if(d.bracketInfo.isOpeningBracket){const u=d.bracketInfo.bracketText,g=r.has(u)?r.get(u):0;r.set(u,g+1)}else{const u=d.bracketInfo.getOpeningBrackets()[0].bracketText;let g=r.has(u)?r.get(u):0;if(g-=1,r.set(u,Math.max(0,g)),g<0){let p=s.get(u);p||(p=new a.LinkedList,s.set(u,p)),p.push(d.range)}}n=d.range.getEndPosition()}}static _bracketsLeftYield(e,t,i,n,s,r){const l=new Map,d=Date.now();for(;;){if(t>=Ne._maxRounds&&s.size===0){e();break}if(!n){e();break}const h=i.bracketPairs.findPrevBracket(n);if(!h){e();break}if(Date.now()-d>Ne._maxDuration){setTimeout(()=>Ne._bracketsLeftYield(e,t+1,i,n,s,r));break}if(h.bracketInfo.isOpeningBracket){const g=h.bracketInfo.bracketText;let p=l.has(g)?l.get(g):0;if(p-=1,l.set(g,Math.max(0,p)),p<0){const f=s.get(g);if(f){const m=f.shift();f.size===0&&s.delete(g);const _=a.Range.fromPositions(h.range.getEndPosition(),m.getStartPosition()),v=a.Range.fromPositions(h.range.getStartPosition(),m.getEndPosition());r.push({range:_}),r.push({range:v}),Ne._addBracketLeading(i,v,r)}}}else{const g=h.bracketInfo.getOpeningBrackets()[0].bracketText,p=l.has(g)?l.get(g):0;l.set(g,p+1)}n=h.range.getStartPosition()}}static _addBracketLeading(e,t,i){if(t.startLineNumber===t.endLineNumber)return;const n=t.startLineNumber,s=e.getLineFirstNonWhitespaceColumn(n);s!==0&&s!==t.startColumn&&(i.push({range:a.Range.fromPositions(new a.Position(n,s),t.getEndPosition())}),i.push({range:a.Range.fromPositions(new a.Position(n,1),t.getEndPosition())}));const r=n-1;if(r>0){const l=e.getLineFirstNonWhitespaceColumn(r);l===t.startColumn&&l!==e.getLineLastNonWhitespaceColumn(r)&&(i.push({range:a.Range.fromPositions(new a.Position(r,l),t.getEndPosition())}),i.push({range:a.Range.fromPositions(new a.Position(r,1),t.getEndPosition())}))}}};Ne._maxDuration=30,Ne._maxRounds=2;let El=Ne;const bt=class bt{static async create(e,t){if(!t.getOption(134).localityBonus||!t.hasModel())return bt.None;const i=t.getModel(),n=t.getPosition();if(!e.canComputeWordRanges(i.uri))return bt.None;const[s]=await new El().provideSelectionRanges(i,[n]);if(s.length===0)return bt.None;const r=await e.computeWordRanges(i.uri,s[0].range);if(!r)return bt.None;const l=i.getWordUntilPosition(n);return delete r[l.word],new class extends bt{distance(d,h){if(!n.equals(t.getPosition()))return 0;if(h.kind===17)return 2<<20;const u=typeof h.label=="string"?h.label:h.label.label,g=r[u];if(a.isFalsyOrEmpty(g))return 2<<20;const p=a.binarySearch(g,a.Range.fromPositions(d),a.Range.compareRangesUsingStarts),f=p>=0?g[p]:g[Math.max(0,~p-1)];let m=s.length;for(const _ of s){if(!a.Range.containsRange(_.range,f))break;m-=1}return m}}}};bt.None=new class extends bt{distance(){return 0}};let Ll=bt;var FL=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},ei=function(c,e){return function(t,i){e(t,i,c)}},ig;class un{static shouldAutoTrigger(e){if(!e.hasModel())return!1;const t=e.getModel(),i=e.getPosition();t.tokenization.tokenizeIfCheap(i.lineNumber);const n=t.getWordAtPosition(i);return!(!n||n.endColumn!==i.column&&n.startColumn+1!==i.column||!isNaN(Number(n.word)))}constructor(e,t,i){this.leadingLineContent=e.getLineContent(t.lineNumber).substr(0,t.column-1),this.leadingWord=e.getWordUntilPosition(t),this.lineNumber=t.lineNumber,this.column=t.column,this.triggerOptions=i}}function zL(c,e,t){if(!e.getContextKeyValue(B.inlineSuggestionVisible.key))return!0;const i=e.getContextKeyValue(B.suppressSuggestions.key);return i!==void 0?!i:!c.getOption(71).suppressSuggestions}function VL(c,e,t){if(!e.getContextKeyValue("inlineSuggestionVisible"))return!0;const i=e.getContextKeyValue(B.suppressSuggestions.key);return i!==void 0?!i:!c.getOption(71).suppressSuggestions}let Dl=ig=class{constructor(e,t,i,n,s,r,l,d,h){this._editor=e,this._editorWorkerService=t,this._clipboardService=i,this._telemetryService=n,this._logService=s,this._contextKeyService=r,this._configurationService=l,this._languageFeaturesService=d,this._envService=h,this._toDispose=new a.DisposableStore,this._triggerCharacterListener=new a.DisposableStore,this._triggerQuickSuggest=new a.TimeoutTimer,this._triggerState=void 0,this._completionDisposables=new a.DisposableStore,this._onDidCancel=new a.Emitter,this._onDidTrigger=new a.Emitter,this._onDidSuggest=new a.Emitter,this.onDidCancel=this._onDidCancel.event,this.onDidTrigger=this._onDidTrigger.event,this.onDidSuggest=this._onDidSuggest.event,this._currentSelection=this._editor.getSelection()||new a.Selection(1,1,1,1),this._toDispose.add(this._editor.onDidChangeModel(()=>{this._updateTriggerCharacters(),this.cancel()})),this._toDispose.add(this._editor.onDidChangeModelLanguage(()=>{this._updateTriggerCharacters(),this.cancel()})),this._toDispose.add(this._editor.onDidChangeConfiguration(()=>{this._updateTriggerCharacters()})),this._toDispose.add(this._languageFeaturesService.completionProvider.onDidChange(()=>{this._updateTriggerCharacters(),this._updateActiveSuggestSession()}));let u=!1;this._toDispose.add(this._editor.onDidCompositionStart(()=>{u=!0})),this._toDispose.add(this._editor.onDidCompositionEnd(()=>{u=!1,this._onCompositionEnd()})),this._toDispose.add(this._editor.onDidChangeCursorSelection(g=>{u||this._onCursorChange(g)})),this._toDispose.add(this._editor.onDidChangeModelContent(()=>{!u&&this._triggerState!==void 0&&this._refilterCompletionItems()})),this._updateTriggerCharacters()}dispose(){a.dispose(this._triggerCharacterListener),a.dispose([this._onDidCancel,this._onDidSuggest,this._onDidTrigger,this._triggerQuickSuggest]),this._waitForInlineCompletions?.dispose(),this._toDispose.dispose(),this._completionDisposables.dispose(),this.cancel()}_updateTriggerCharacters(){if(this._triggerCharacterListener.clear(),this._editor.getOption(104)||!this._editor.hasModel()||!this._editor.getOption(137))return;const e=new Map;for(const i of this._languageFeaturesService.completionProvider.all(this._editor.getModel()))for(const n of i.triggerCharacters||[]){let s=e.get(n);s||(s=new Set,e.set(n,s)),s.add(i)}const t=i=>{if(!VL(this._editor,this._contextKeyService,this._configurationService)||un.shouldAutoTrigger(this._editor))return;if(!i){const r=this._editor.getPosition();i=this._editor.getModel().getLineContent(r.lineNumber).substr(0,r.column-1)}let n="";a.isLowSurrogate(i.charCodeAt(i.length-1))?a.isHighSurrogate(i.charCodeAt(i.length-2))&&(n=i.substr(i.length-2)):n=i.charAt(i.length-1);const s=e.get(n);if(s){const r=new Map;if(this._completionModel)for(const[l,d]of this._completionModel.getItemsByProvider())s.has(l)||r.set(l,d);this.trigger({auto:!0,triggerKind:1,triggerCharacter:n,retrigger:!!this._completionModel,clipboardText:this._completionModel?.clipboardText,completionOptions:{providerFilter:s,providerItemsToReuse:r}})}};this._triggerCharacterListener.add(this._editor.onDidType(t)),this._triggerCharacterListener.add(this._editor.onDidCompositionEnd(()=>t()))}get state(){return this._triggerState?this._triggerState.auto?2:1:0}cancel(e=!1){this._triggerQuickSuggest.cancel(),this._waitForInlineCompletions?.dispose(),this._waitForInlineCompletions=void 0,this._triggerState!==void 0&&(this._requestToken?.cancel(),this._requestToken=void 0,this._triggerState=void 0,this._completionModel=void 0,this._context=void 0,this._onDidCancel.fire({retrigger:e}))}clear(){this._completionDisposables.clear()}_updateActiveSuggestSession(){this._triggerState!==void 0&&(!this._editor.hasModel()||!this._languageFeaturesService.completionProvider.has(this._editor.getModel())?this.cancel():this.trigger({auto:this._triggerState.auto,retrigger:!0}))}_onCursorChange(e){if(!this._editor.hasModel())return;const t=this._currentSelection;if(this._currentSelection=this._editor.getSelection(),!e.selection.isEmpty()||e.reason!==0&&e.reason!==3||e.source!=="keyboard"&&e.source!=="deleteLeft"){this.cancel();return}this._triggerState===void 0&&e.reason===0?(t.containsRange(this._currentSelection)||t.getEndPosition().isBeforeOrEqual(this._currentSelection.getPosition()))&&this._doTriggerQuickSuggest():this._triggerState!==void 0&&e.reason===3&&this._refilterCompletionItems()}_onCompositionEnd(){this._triggerState===void 0?this._doTriggerQuickSuggest():this._refilterCompletionItems()}_doTriggerQuickSuggest(){Rs.isAllOff(this._editor.getOption(102))||this._editor.getOption(134).snippetsPreventQuickSuggestions&&ne.get(this._editor)?.isInSnippet()||(this.cancel(),this._waitForInlineCompletions?.dispose(),this._waitForInlineCompletions=void 0,this._triggerQuickSuggest.cancelAndSet(()=>{if(this._triggerState!==void 0||!un.shouldAutoTrigger(this._editor)||!this._editor.hasModel()||!this._editor.hasWidgetFocus())return;const e=this._editor.getModel(),t=this._editor.getPosition(),i=this._editor.getOption(102);if(Rs.isAllOff(i))return;let n=!1;if(!Rs.isAllOn(i)){e.tokenization.tokenizeIfCheap(t.lineNumber);const s=e.tokenization.getLineTokens(t.lineNumber),r=s.getStandardTokenType(s.findTokenIndexAtOffset(Math.max(t.column-1-1,0))),l=Rs.valueFor(i,r);if(l==="off"||l==="inline")return;l==="offWhenInlineCompletions"&&(n=this._languageFeaturesService.inlineCompletionsProvider.has(e)&&this._editor.getOption(71).enabled)}zL(this._editor,this._contextKeyService,this._configurationService)&&this._languageFeaturesService.completionProvider.has(e)&&(n?this._waitForInlineCompletionsAndTrigger(e,t):this.trigger({auto:!0}))},this._editor.getOption(103)))}_waitForInlineCompletionsAndTrigger(e,t){const i=e.getVersionId(),n=Nv(this._editor),s=n?.model.get();if(!n||!s){this.trigger({auto:!0});return}if(s.state.get()?.inlineSuggestion)return;const l=new a.DisposableStore;this._waitForInlineCompletions=l;const d=h=>{if(l.dispose(),this._waitForInlineCompletions===l&&(this._waitForInlineCompletions=void 0),this._triggerState!==void 0||!h)return;const u=this._editor.getModel(),g=this._editor.getPosition();u===e&&u.getVersionId()===i&&g?.equals(t)&&this._editor.hasWidgetFocus()&&this.trigger({auto:!0})};a.disposableTimeout(()=>{d(!0),s.stop("automatic")},750,l),o.registerAutorunSelfDisposable(l,h=>{if(n.model.read(h)!==s){h.dispose(),d(!1);return}const g=s.status.read(h),p=s.state.read(h);!p&&g==="loading"||(h.dispose(),d(!p))})}_refilterCompletionItems(){a.assertType(this._editor.hasModel()),a.assertType(this._triggerState!==void 0);const e=this._editor.getModel(),t=this._editor.getPosition(),i=new un(e,t,{...this._triggerState,refilter:!0});this._onNewContext(i)}trigger(e){if(!this._editor.hasModel())return;const t=this._editor.getModel(),i=new un(t,this._editor.getPosition(),e);this.cancel(e.retrigger),this._triggerState=e,this._onDidTrigger.fire({auto:e.auto,shy:e.shy??!1,position:this._editor.getPosition()}),this._context=i;let n={triggerKind:e.triggerKind??0};e.triggerCharacter&&(n={triggerKind:1,triggerCharacter:e.triggerCharacter}),this._requestToken=new a.CancellationTokenSource;const s=this._editor.getOption(128);let r=1;switch(s){case"top":r=0;break;case"bottom":r=2;break}const{itemKind:l,showDeprecated:d}=ig.createSuggestFilter(this._editor),h=new Go(r,e.completionOptions?.kindFilter??l,e.completionOptions?.providerFilter,e.completionOptions?.providerItemsToReuse,d),u=Ll.create(this._editorWorkerService,this._editor),g=Iu(this._languageFeaturesService.completionProvider,t,this._editor.getPosition(),h,n,this._requestToken.token);Promise.all([g,u]).then(async([p,f])=>{if(this._requestToken?.dispose(),!this._editor.hasModel()){p.disposable.dispose();return}let m=e?.clipboardText;if(!m&&p.needsClipboard&&(m=await this._clipboardService.readText()),this._triggerState===void 0){p.disposable.dispose();return}const _=this._editor.getModel(),v=new un(_,this._editor.getPosition(),e),b={...o.FuzzyScoreOptions.default,firstMatchCanBeWeak:!this._editor.getOption(134).matchOnWordStartOnly};if(this._completionModel=new Ht(p.items,this._context.column,{leadingLineContent:v.leadingLineContent,characterCountDelta:v.column-this._context.column},f,this._editor.getOption(134),this._editor.getOption(128),b,m),this._completionDisposables.add(p.disposable),this._onNewContext(v),this._reportDurationsTelemetry(p.durations),!this._envService.isBuilt||this._envService.isExtensionDevelopment)for(const C of p.items)C.isInvalid&&this._logService.warn(`[suggest] did IGNORE invalid completion item from ${C.provider._debugDisplayName}`,C.completion)}).catch(a.onUnexpectedError)}_reportDurationsTelemetry(e){Math.random()>1e-4||setTimeout(()=>{this._telemetryService.publicLog2("suggest.durations.json",{data:JSON.stringify(e)}),this._logService.debug("suggest.durations.json",e)})}static createSuggestFilter(e){const t=new Set;e.getOption(128)==="none"&&t.add(28);const n=e.getOption(134);return n.showMethods||t.add(0),n.showFunctions||t.add(1),n.showConstructors||t.add(2),n.showFields||t.add(3),n.showVariables||t.add(4),n.showClasses||t.add(5),n.showStructs||t.add(6),n.showInterfaces||t.add(7),n.showModules||t.add(8),n.showProperties||t.add(9),n.showEvents||t.add(10),n.showOperators||t.add(11),n.showUnits||t.add(12),n.showValues||t.add(13),n.showConstants||t.add(14),n.showEnums||t.add(15),n.showEnumMembers||t.add(16),n.showKeywords||t.add(17),n.showWords||t.add(18),n.showColors||t.add(19),n.showFiles||t.add(20),n.showReferences||t.add(21),n.showColors||t.add(22),n.showFolders||t.add(23),n.showTypeParameters||t.add(24),n.showSnippets||t.add(28),n.showUsers||t.add(25),n.showIssues||t.add(26),{itemKind:t,showDeprecated:n.showDeprecated}}_onNewContext(e){if(this._context){if(e.lineNumber!==this._context.lineNumber){this.cancel();return}if(a.getLeadingWhitespace(e.leadingLineContent)!==a.getLeadingWhitespace(this._context.leadingLineContent)){this.cancel();return}if(e.column<this._context.column){e.leadingWord.word?this.trigger({auto:this._context.triggerOptions.auto,retrigger:!0}):this.cancel();return}if(this._completionModel){if(e.leadingWord.word.length!==0&&e.leadingWord.startColumn>this._context.leadingWord.startColumn){if(un.shouldAutoTrigger(this._editor)&&this._context){const i=this._completionModel.getItemsByProvider();this.trigger({auto:this._context.triggerOptions.auto,retrigger:!0,clipboardText:this._completionModel.clipboardText,completionOptions:{providerItemsToReuse:i}})}return}if(e.column>this._context.column&&this._completionModel.getIncompleteProvider().size>0&&e.leadingWord.word.length!==0){const t=new Map,i=new Set;for(const[n,s]of this._completionModel.getItemsByProvider())s.length>0&&s[0].container.incomplete?i.add(n):t.set(n,s);this.trigger({auto:this._context.triggerOptions.auto,triggerKind:2,retrigger:!0,clipboardText:this._completionModel.clipboardText,completionOptions:{providerFilter:i,providerItemsToReuse:t}})}else{const t=this._completionModel.lineContext;let i=!1;if(this._completionModel.lineContext={leadingLineContent:e.leadingLineContent,characterCountDelta:e.column-this._context.column},this._completionModel.items.length===0){const n=un.shouldAutoTrigger(this._editor);if(!this._context){this.cancel();return}if(n&&this._context.leadingWord.endColumn<e.leadingWord.startColumn){this.trigger({auto:this._context.triggerOptions.auto,retrigger:!0});return}if(this._context.triggerOptions.auto){this.cancel();return}else if(this._completionModel.lineContext=t,i=this._completionModel.items.length>0,i&&e.leadingWord.word.length===0){this.cancel();return}}this._onDidSuggest.fire({completionModel:this._completionModel,triggerOptions:e.triggerOptions,isFrozen:i})}}}}};Dl=ig=FL([ei(1,o.IEditorWorkerService),ei(2,o.IClipboardService),ei(3,o.ITelemetryService),ei(4,o.ILogService),ei(5,o.IContextKeyService),ei(6,o.IConfigurationService),ei(7,o.ILanguageFeaturesService),ei(8,o.IEnvironmentService)],Dl);const kc=class kc{constructor(e,t){this._disposables=new a.DisposableStore,this._lastOvertyped=[],this._locked=!1,this._disposables.add(e.onWillType(()=>{if(this._locked||!e.hasModel())return;const i=e.getSelections(),n=i.length;let s=!1;for(let l=0;l<n;l++)if(!i[l].isEmpty()){s=!0;break}if(!s){this._lastOvertyped.length!==0&&(this._lastOvertyped.length=0);return}this._lastOvertyped=[];const r=e.getModel();for(let l=0;l<n;l++){const d=i[l];if(r.getValueLengthInRange(d)>kc._maxSelectionLength)return;this._lastOvertyped[l]={value:r.getValueInRange(d),multiline:d.startLineNumber!==d.endLineNumber}}})),this._disposables.add(t.onDidTrigger(i=>{this._locked=!0})),this._disposables.add(t.onDidCancel(i=>{this._locked=!1}))}getLastOvertypedInfo(e){if(e>=0&&e<this._lastOvertyped.length)return this._lastOvertyped[e]}dispose(){this._disposables.dispose()}};kc._maxSelectionLength=51200;let ng=kc;var BL=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},sg=function(c,e){return function(t,i){e(t,i,c)}};let og=class{constructor(e,t,i,n,s,r){this._menuId=t,this._menuService=s,this._contextKeyService=r,this._menuDisposables=new a.DisposableStore,this.element=o.append(e,o.$(".suggest-status-bar"));const l=(d=>i?.showIconsNoKeybindings?d instanceof o.MenuItemAction?n.createInstance(o.MenuEntryActionViewItem,d,void 0):void 0:d instanceof o.MenuItemAction?n.createInstance(o.TextOnlyMenuEntryActionViewItem,d,{useComma:!1}):void 0);this._leftActions=new o.ActionBar(this.element,{actionViewItemProvider:l}),this._rightActions=new o.ActionBar(this.element,{actionViewItemProvider:l}),this._leftActions.domNode.classList.add("left"),this._rightActions.domNode.classList.add("right")}dispose(){this._menuDisposables.dispose(),this._leftActions.dispose(),this._rightActions.dispose(),this.element.remove()}show(){const e=this._menuService.createMenu(this._menuId,this._contextKeyService),t=()=>{const i=[],n=[];for(const[s,r]of e.getActions())s==="left"?i.push(...r):n.push(...r);this._leftActions.clear(),this._leftActions.push(i),this._rightActions.clear(),this._rightActions.push(n)};this._menuDisposables.add(e.onDidChange(()=>t())),this._menuDisposables.add(e)}hide(){this._menuDisposables.clear()}};og=BL([sg(3,o.IInstantiationService),sg(4,o.IMenuService),sg(5,o.IContextKeyService)],og);var KL=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},zv=function(c,e){return function(t,i){e(t,i,c)}};function rg(c){return!!c&&!!(c.completion.documentation||c.completion.detail&&c.completion.detail!==c.completion.label)}let ag=class{constructor(e,t,i){this._editor=e,this._themeService=t,this._markdownRendererService=i,this._onDidClose=new a.Emitter,this.onDidClose=this._onDidClose.event,this._onDidChangeContents=new a.Emitter,this.onDidChangeContents=this._onDidChangeContents.event,this._disposables=new a.DisposableStore,this._renderDisposeable=new a.DisposableStore,this._size=new o.Dimension(330,0),this.domNode=o.$(".suggest-details"),this.domNode.classList.add("no-docs"),this._body=o.$(".body"),this._scrollbar=new o.DomScrollableElement(this._body,{alwaysConsumeMouseWheel:!0}),o.append(this.domNode,this._scrollbar.getDomNode()),this._disposables.add(this._scrollbar),this._header=o.append(this._body,o.$(".header")),this._close=o.append(this._header,o.$("span"+o.ThemeIcon.asCSSSelector(a.Codicon.close))),this._close.title=a.localize(1563,"Close"),this._close.ariaLabel=a.localize(1564,"Close"),this._close.role="button",this._close.tabIndex=-1,this._type=o.append(this._header,o.$("p.type")),this._docs=o.append(this._body,o.$("p.docs")),this._configureFont(),this._disposables.add(this._editor.onDidChangeConfiguration(n=>{n.hasChanged(59)&&this._configureFont()}))}dispose(){this._disposables.dispose(),this._renderDisposeable.dispose(),this._onDidClose.dispose(),this._onDidChangeContents.dispose()}_configureFont(){const e=this._editor.getOptions(),t=e.get(59),i=t.getMassagedFontFamily(),n=e.get(135)||t.fontSize,s=e.get(136)||t.lineHeight,r=t.fontWeight,l=`${n}px`,d=`${s}px`;this.domNode.style.fontSize=l,this.domNode.style.lineHeight=`${s/n}`,this.domNode.style.fontWeight=r,this.domNode.style.fontFeatureSettings=t.fontFeatureSettings,this._type.style.fontFamily=i,this._close.style.height=d,this._close.style.width=d}getLayoutInfo(){const e=this._editor.getOption(136)||this._editor.getOption(59).lineHeight,t=o.isHighContrast(this._themeService.getColorTheme().type)?2:1,i=t*2;return{lineHeight:e,borderWidth:t,borderHeight:i,verticalPadding:22,horizontalPadding:14}}renderLoading(){this._type.textContent=a.localize(1565,"Loading..."),this._docs.textContent="",this.domNode.classList.remove("no-docs","no-type"),this.layout(this.size.width,this.getLayoutInfo().lineHeight*2),this._onDidChangeContents.fire(this)}renderItem(e,t){this._renderDisposeable.clear();let{detail:i,documentation:n}=e.completion;if(t){let s="";s+=`score: ${e.score[0]}
41
+ `,s+=`prefix: ${e.word??"(no prefix)"}
42
+ `,s+=`word: ${e.completion.filterText?e.completion.filterText+" (filterText)":e.textLabel}
43
+ `,s+=`distance: ${e.distance} (localityBonus-setting)
44
+ `,s+=`index: ${e.idx}, based on ${e.completion.sortText&&`sortText: "${e.completion.sortText}"`||"label"}
45
+ `,s+=`commit_chars: ${e.completion.commitCharacters?.join("")}
46
+ `,n=new o.MarkdownString().appendCodeblock("empty",s),i=`Provider: ${e.provider._debugDisplayName}`}if(!t&&!rg(e)){this.clearContents();return}if(this.domNode.classList.remove("no-docs","no-type"),i){const s=i.length>1e5?`${i.substr(0,1e5)}…`:i;this._type.textContent=s,this._type.title=s,o.show(this._type),this._type.classList.toggle("auto-wrap",!/\r?\n^\s+/gmi.test(s))}else o.clearNode(this._type),this._type.title="",o.hide(this._type),this.domNode.classList.add("no-type");if(o.clearNode(this._docs),typeof n=="string")this._docs.classList.remove("markdown-docs"),this._docs.textContent=n;else if(n){this._docs.classList.add("markdown-docs"),o.clearNode(this._docs);const s=this._markdownRendererService.render(n,{context:this._editor,asyncRenderCallback:()=>{this.layout(this._size.width,this._type.clientHeight+this._docs.clientHeight),this._onDidChangeContents.fire(this)}});this._docs.appendChild(s.element),this._renderDisposeable.add(s)}this.domNode.classList.toggle("detail-and-doc",!!i&&!!n),this.domNode.style.userSelect="text",this.domNode.tabIndex=-1,this._close.onmousedown=s=>{s.preventDefault(),s.stopPropagation()},this._close.onclick=s=>{s.preventDefault(),s.stopPropagation(),this._onDidClose.fire()},this._body.scrollTop=0,this.layout(this._size.width,this._type.clientHeight+this._docs.clientHeight),this._onDidChangeContents.fire(this)}clearContents(){this.domNode.classList.add("no-docs"),this._type.textContent="",this._docs.textContent=""}get isEmpty(){return this.domNode.classList.contains("no-docs")}get size(){return this._size}layout(e,t){const i=new o.Dimension(e,t);o.Dimension.equals(i,this._size)||(this._size=i,o.size(this.domNode,e,t)),this._scrollbar.scanDomNode()}scrollDown(e=8){this._body.scrollTop+=e}scrollUp(e=8){this._body.scrollTop-=e}scrollTop(){this._body.scrollTop=0}scrollBottom(){this._body.scrollTop=this._body.scrollHeight}pageDown(){this.scrollDown(80)}pageUp(){this.scrollUp(80)}focus(){this.domNode.focus()}};ag=KL([zv(1,o.IThemeService),zv(2,o.IMarkdownRendererService)],ag);class kL{constructor(e,t){this.widget=e,this._editor=t,this.allowEditorOverflow=!0,this._disposables=new a.DisposableStore,this._added=!1,this._preferAlignAtTop=!0,this._resizable=new ch,this._resizable.domNode.classList.add("suggest-details-container"),this._resizable.domNode.appendChild(e.domNode),this._resizable.enableSashes(!1,!0,!0,!1);let i,n,s=0,r=0;this._disposables.add(this._resizable.onDidWillResize(()=>{i=this._topLeft,n=this._resizable.size})),this._disposables.add(this._resizable.onDidResize(l=>{if(i&&n){this.widget.layout(l.dimension.width,l.dimension.height);let d=!1;l.west&&(r=n.width-l.dimension.width,d=!0),l.north&&(s=n.height-l.dimension.height,d=!0),d&&this._applyTopLeft({top:i.top+s,left:i.left+r})}l.done&&(i=void 0,n=void 0,s=0,r=0,this._userSize=l.dimension)})),this._disposables.add(this.widget.onDidChangeContents(()=>{this._anchorBox&&this._placeAtAnchor(this._anchorBox,this._userSize??this.widget.size,this._preferAlignAtTop)}))}dispose(){this._resizable.dispose(),this._disposables.dispose(),this.hide()}getId(){return"suggest.details"}getDomNode(){return this._resizable.domNode}getPosition(){return this._topLeft?{preference:this._topLeft}:null}show(){this._added||(this._editor.addOverlayWidget(this),this._added=!0)}hide(e=!1){this._resizable.clearSashHoverState(),this._added&&(this._editor.removeOverlayWidget(this),this._added=!1,this._anchorBox=void 0,this._topLeft=void 0),e&&(this._userSize=void 0,this.widget.clearContents())}placeAtAnchor(e,t){const i=e.getBoundingClientRect();this._anchorBox=i,this._preferAlignAtTop=t,this._placeAtAnchor(this._anchorBox,this._userSize??this.widget.size,t)}_placeAtAnchor(e,t,i){const n=o.getClientArea(this.getDomNode().ownerDocument.body),s=this.widget.getLayoutInfo(),r=new o.Dimension(220,2*s.lineHeight),l=e.top,d=(function(){const w=n.width-(e.left+e.width+s.borderWidth+s.horizontalPadding),E=-s.borderWidth+e.left+e.width,L=new o.Dimension(w,n.height-e.top-s.borderHeight-s.verticalPadding),R=L.with(void 0,e.top+e.height-s.borderHeight-s.verticalPadding);return{top:l,left:E,fit:w-t.width,maxSizeTop:L,maxSizeBottom:R,minSize:r.with(Math.min(w,r.width))}})(),h=(function(){const w=e.left-s.borderWidth-s.horizontalPadding,E=Math.max(s.horizontalPadding,e.left-t.width-s.borderWidth),L=new o.Dimension(w,n.height-e.top-s.borderHeight-s.verticalPadding),R=L.with(void 0,e.top+e.height-s.borderHeight-s.verticalPadding);return{top:l,left:E,fit:w-t.width,maxSizeTop:L,maxSizeBottom:R,minSize:r.with(Math.min(w,r.width))}})(),u=(function(){const w=e.left,E=-s.borderWidth+e.top+e.height,L=new o.Dimension(e.width-s.borderHeight,n.height-e.top-e.height-s.verticalPadding);return{top:E,left:w,fit:L.height-t.height,maxSizeBottom:L,maxSizeTop:L,minSize:r.with(L.width)}})(),g=(function(){const w=e.left,E=new o.Dimension(e.width-s.borderHeight,e.top-s.verticalPadding);return{top:Math.max(s.verticalPadding,e.top-t.height),left:w,fit:E.height-t.height,maxSizeTop:E,maxSizeBottom:E,minSize:r.with(E.width)}})(),f=[d,h,i?u:g],m=f.find(w=>w.fit>=0)??f.sort((w,E)=>E.fit-w.fit)[0],_=e.top+e.height-s.borderHeight;let v,b=t.height;const C=Math.max(m.maxSizeTop.height,m.maxSizeBottom.height);b>C&&(b=C);let y;i?b<=m.maxSizeTop.height?(v=!0,y=m.maxSizeTop):(v=!1,y=m.maxSizeBottom):b<=m.maxSizeBottom.height?(v=!1,y=m.maxSizeBottom):(v=!0,y=m.maxSizeTop);let{top:I,left:x}=m;m===g?I=e.top-b+s.borderWidth:!v&&b>e.height&&(I=_-b);const S=this._editor.getDomNode();if(S){const w=S.getBoundingClientRect();I-=w.top,x-=w.left}this._applyTopLeft({left:x,top:I}),m===g?this._resizable.enableSashes(!0,!1,!1,!0):this._resizable.enableSashes(!v,m===d,v,m!==d),this._resizable.minSize=m.minSize,this._resizable.maxSize=y,this._resizable.layout(b,Math.min(y.width,t.width)),this.widget.layout(this._resizable.size.width,this._resizable.size.height)}_applyTopLeft(e){this._topLeft=e,this._editor.layoutOverlayWidget(this)}}const Vv=o.createDecorator("fileService");var We;(function(c){c[c.FILE=0]="FILE",c[c.FOLDER=1]="FOLDER",c[c.ROOT_FOLDER=2]="ROOT_FOLDER"})(We||(We={}));const UL=/(?:\/|^)(?:([^\/]+)\/)?([^\/]+)$/;function dr(c,e,t,i,n){if(o.ThemeIcon.isThemeIcon(n))return[`codicon-${n.id}`,"predefined-file-icon"];if(a.URI.isUri(n))return[];const s=i===We.ROOT_FOLDER?["rootfolder-icon"]:i===We.FOLDER?["folder-icon"]:["file-icon"];if(t){let r;if(t.scheme===a.Schemas.data)r=o.DataUri.parseMetaData(t).get(o.DataUri.META_DATA_LABEL);else{const l=t.path.match(UL);l?(r=Rl(l[2].toLowerCase()),l[1]&&s.push(`${Rl(l[1].toLowerCase())}-name-dir-icon`)):r=Rl(t.authority.toLowerCase())}if(i===We.ROOT_FOLDER)s.push(`${r}-root-name-folder-icon`);else if(i===We.FOLDER)s.push(`${r}-name-folder-icon`);else{if(r){if(s.push(`${r}-name-file-icon`),s.push("name-file-icon"),r.length<=255){const d=r.split(".");for(let h=1;h<d.length;h++)s.push(`${d.slice(h).join(".")}-ext-file-icon`)}s.push("ext-file-icon")}const l=$L(c,e,t);l&&s.push(`${Rl(l)}-lang-file-icon`)}}return s}function $L(c,e,t){if(!t)return null;let i=null;if(t.scheme===a.Schemas.data){const s=o.DataUri.parseMetaData(t).get(o.DataUri.META_DATA_MIME);s&&(i=e.getLanguageIdByMimeType(s))}else{const n=c.getModel(t);n&&(i=n.getLanguageId())}return i&&i!==o.PLAINTEXT_LANGUAGE_ID?i:e.guessLanguageIdByFilepathOrFirstLine(t)}function Rl(c){return c.replace(/[\s]/g,"/")}var jL=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},lg=function(c,e){return function(t,i){e(t,i,c)}};const qL=o.registerIcon("suggest-more-info",a.Codicon.chevronRight,a.localize(1566,"Icon for more information in the suggest widget.")),GL=new(nt=class{extract(e,t){if(e.textLabel.match(nt._regexStrict))return t[0]=e.textLabel,!0;if(e.completion.detail&&e.completion.detail.match(nt._regexStrict))return t[0]=e.completion.detail,!0;if(e.completion.documentation){const i=typeof e.completion.documentation=="string"?e.completion.documentation:e.completion.documentation.value,n=nt._regexRelaxed.exec(i);if(n&&(n.index===0||n.index+n[0].length===i.length))return t[0]=n[0],!0}return!1}},nt._regexRelaxed=/(#([\da-fA-F]{3}){1,2}|(rgb|hsl)a\(\s*(\d{1,3}%?\s*,\s*){3}(1|0?\.\d+)\)|(rgb|hsl)\(\s*\d{1,3}%?(\s*,\s*\d{1,3}%?){2}\s*\))/,nt._regexStrict=new RegExp(`^${nt._regexRelaxed.source}$`,"i"),nt);let cg=class{constructor(e,t,i,n){this._editor=e,this._modelService=t,this._languageService=i,this._themeService=n,this._onDidToggleDetails=new a.Emitter,this.onDidToggleDetails=this._onDidToggleDetails.event,this.templateId="suggestion"}dispose(){this._onDidToggleDetails.dispose()}renderTemplate(e){const t=new a.DisposableStore,i=e;i.classList.add("show-file-icons");const n=o.append(e,o.$(".icon")),s=o.append(n,o.$("span.colorspan")),r=o.append(e,o.$(".contents")),l=o.append(r,o.$(".main")),d=o.append(l,o.$(".icon-label.codicon")),h=o.append(l,o.$("span.left")),u=o.append(l,o.$("span.right")),g=new o.IconLabel(h,{supportHighlights:!0,supportIcons:!0});t.add(g);const p=o.append(h,o.$("span.signature-label")),f=o.append(h,o.$("span.qualifier-label")),m=o.append(u,o.$("span.details-label")),_=o.append(u,o.$("span.readMore"+o.ThemeIcon.asCSSSelector(qL)));return _.title=a.localize(1567,"Read More"),{root:i,left:h,right:u,icon:n,colorspan:s,iconLabel:g,iconContainer:d,parametersLabel:p,qualifierLabel:f,detailsLabel:m,readMore:_,disposables:t,configureFont:()=>{const b=this._editor.getOptions(),C=b.get(59),y=C.getMassagedFontFamily(),I=C.fontFeatureSettings,x=C.fontVariationSettings,S=b.get(135)||C.fontSize,w=b.get(136)||C.lineHeight,E=C.fontWeight,L=C.letterSpacing,R=`${S}px`,D=`${w}px`,T=`${L}px`;i.style.fontSize=R,i.style.fontWeight=E,i.style.letterSpacing=T,l.style.fontFamily=y,l.style.fontFeatureSettings=I,l.style.fontVariationSettings=x,l.style.lineHeight=D,n.style.height=D,n.style.width=D,_.style.height=D,_.style.width=D}}}renderElement(e,t,i){i.configureFont();const{completion:n}=e;i.colorspan.style.backgroundColor="";const s={labelEscapeNewLines:!0,matches:o.createMatches(e.score)},r=[];if(n.kind===19&&GL.extract(e,r))i.icon.className="icon customcolor",i.iconContainer.className="icon hide",i.colorspan.style.backgroundColor=r[0];else if(n.kind===20&&this._themeService.getFileIconTheme().hasFileIcons){i.icon.className="icon hide",i.iconContainer.className="icon hide";const l=dr(this._modelService,this._languageService,a.URI.from({scheme:"fake",path:e.textLabel}),We.FILE),d=dr(this._modelService,this._languageService,a.URI.from({scheme:"fake",path:n.detail}),We.FILE);s.extraClasses=l.length>d.length?l:d}else n.kind===23&&this._themeService.getFileIconTheme().hasFolderIcons?(i.icon.className="icon hide",i.iconContainer.className="icon hide",s.extraClasses=[dr(this._modelService,this._languageService,a.URI.from({scheme:"fake",path:e.textLabel}),We.FOLDER),dr(this._modelService,this._languageService,a.URI.from({scheme:"fake",path:n.detail}),We.FOLDER)].flat()):(i.icon.className="icon hide",i.iconContainer.className="",i.iconContainer.classList.add("suggest-icon",...o.ThemeIcon.asClassNameArray(a.CompletionItemKinds.toIcon(n.kind))));n.tags&&n.tags.indexOf(1)>=0&&(s.extraClasses=(s.extraClasses||[]).concat(["deprecated"]),s.matches=[]),i.iconLabel.setLabel(e.textLabel,void 0,s),typeof n.label=="string"?(i.parametersLabel.textContent="",i.detailsLabel.textContent=dg(n.detail||""),i.root.classList.add("string-label")):(i.parametersLabel.textContent=dg(n.label.detail||""),i.detailsLabel.textContent=dg(n.label.description||""),i.root.classList.remove("string-label")),this._editor.getOption(134).showInlineDetails?o.show(i.detailsLabel):o.hide(i.detailsLabel),rg(e)?(i.right.classList.add("can-expand-details"),o.show(i.readMore),i.readMore.onmousedown=l=>{l.stopPropagation(),l.preventDefault()},i.readMore.onclick=l=>{l.stopPropagation(),l.preventDefault(),this._onDidToggleDetails.fire()}):(i.right.classList.remove("can-expand-details"),o.hide(i.readMore),i.readMore.onmousedown=null,i.readMore.onclick=null)}disposeTemplate(e){e.disposables.dispose()}};cg=jL([lg(1,o.IModelService),lg(2,o.ILanguageService),lg(3,o.IThemeService)],cg);function dg(c){return c.replace(/\r\n|\r|\n/g,"")}var ZL=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Tl=function(c,e){return function(t,i){e(t,i,c)}},Fs;const Nl=o.registerColor("editorSuggestWidget.background",o.editorWidgetBackground,a.localize(1545,"Background color of the suggest widget."));o.registerColor("editorSuggestWidget.border",o.editorWidgetBorder,a.localize(1546,"Border color of the suggest widget."));const hg=o.registerColor("editorSuggestWidget.foreground",o.editorForeground,a.localize(1547,"Foreground color of the suggest widget.")),Bv=o.registerColor("editorSuggestWidget.selectedForeground",{dark:o.quickInputListFocusForeground,light:o.quickInputListFocusForeground,hcDark:Nl,hcLight:Nl},a.localize(1548,"Foreground color of the selected entry in the suggest widget."));o.registerColor("editorSuggestWidget.selectedIconForeground",{dark:o.quickInputListFocusIconForeground,light:o.quickInputListFocusIconForeground,hcDark:Nl,hcLight:Nl},a.localize(1549,"Icon foreground color of the selected entry in the suggest widget."));const XL=o.registerColor("editorSuggestWidget.selectedBackground",{dark:o.quickInputListFocusBackground,light:o.quickInputListFocusBackground,hcDark:hg,hcLight:hg},a.localize(1550,"Background color of the selected entry in the suggest widget.")),YL=o.registerColor("editorSuggestWidget.focusOutline",o.activeContrastBorder,a.localize(1551,"Outline color of the focused (keyboard-navigated) entry in the suggest widget."));o.registerColor("editorSuggestWidget.highlightForeground",o.listHighlightForeground,a.localize(1552,"Color of the match highlights in the suggest widget.")),o.registerColor("editorSuggestWidget.focusHighlightForeground",{dark:o.listFocusHighlightForeground,light:o.listFocusHighlightForeground,hcDark:Bv,hcLight:Bv},a.localize(1553,"Color of the match highlights in the suggest widget when an item is focused.")),o.registerColor("editorSuggestWidgetStatus.foreground",o.transparent(hg,.5),a.localize(1554,"Foreground color of the suggest widget status."));class QL{constructor(e,t){this._service=e,this._key=`suggestWidget.size/${t.getEditorType()}/${t instanceof ct}`}restore(){const e=this._service.get(this._key,0)??"";try{const t=JSON.parse(e);if(o.Dimension.is(t))return o.Dimension.lift(t)}catch{}}store(e){this._service.store(this._key,JSON.stringify(e),0,1)}reset(){this._service.remove(this._key,0)}}let ug=(Ri=class{constructor(e,t,i,n,s){this.editor=e,this._storageService=t,this._state=0,this._isAuto=!1,this._loadingTimeout=new a.MutableDisposable,this._pendingLayout=new a.MutableDisposable,this._pendingShowDetails=new a.MutableDisposable,this._ignoreFocusEvents=!1,this._forceRenderingAbove=!1,this._explainMode=!1,this._showTimeout=new a.TimeoutTimer,this._disposables=new a.DisposableStore,this._onDidSelect=new a.PauseableEmitter,this._onDidFocus=new a.PauseableEmitter,this._onDidHide=new a.Emitter,this._onDidShow=new a.Emitter,this.onDidSelect=this._onDidSelect.event,this.onDidFocus=this._onDidFocus.event,this.onDidHide=this._onDidHide.event,this.onDidShow=this._onDidShow.event,this._onDetailsKeydown=new a.Emitter,this.element=new ch,this.element.domNode.classList.add("editor-widget","suggest-widget"),this._contentWidget=new JL(this,e),this._persistedSize=new QL(t,e);class r{constructor(_,v,b=!1,C=!1){this.persistedSize=_,this.currentSize=v,this.persistHeight=b,this.persistWidth=C}}let l;this._disposables.add(this.element.onDidWillResize(()=>{this._contentWidget.lockPreference(),l=new r(this._persistedSize.restore(),this.element.size)})),this._disposables.add(this.element.onDidResize(m=>{if(this._resize(m.dimension.width,m.dimension.height),l&&(l.persistHeight=l.persistHeight||!!m.north||!!m.south,l.persistWidth=l.persistWidth||!!m.east||!!m.west),!!m.done){if(l){const{itemHeight:_,defaultSize:v}=this.getLayoutInfo(),b=Math.round(_/2);let{width:C,height:y}=this.element.size;(!l.persistHeight||Math.abs(l.currentSize.height-y)<=b)&&(y=l.persistedSize?.height??v.height),(!l.persistWidth||Math.abs(l.currentSize.width-C)<=b)&&(C=l.persistedSize?.width??v.width),this._persistedSize.store(new o.Dimension(C,y))}this._contentWidget.unlockPreference(),l=void 0}})),this._messageElement=o.append(this.element.domNode,o.$(".message")),this._listElement=o.append(this.element.domNode,o.$(".tree"));const d=this._disposables.add(s.createInstance(ag,this.editor));d.onDidClose(()=>this.toggleDetails(),this,this._disposables),this._details=new kL(d,this.editor);const h=()=>this.element.domNode.classList.toggle("no-icons",!this.editor.getOption(134).showIcons);h();const u=()=>this.element.domNode.classList.toggle("fit-width-to-details",this.editor.getOption(134).fitWidthToDetails);u();const g=s.createInstance(cg,this.editor);this._disposables.add(g),this._disposables.add(g.onDidToggleDetails(()=>this.toggleDetails())),this._list=new o.List("SuggestWidget",this._listElement,{getHeight:m=>this.getLayoutInfo().itemHeight,getTemplateId:m=>"suggestion"},[g],{alwaysConsumeMouseWheel:!0,useShadows:!1,mouseSupport:!1,multipleSelectionSupport:!1,accessibilityProvider:{getRole:()=>a.isWindows?"listitem":"option",getWidgetAriaLabel:()=>a.localize(1557,"Suggest"),getWidgetRole:()=>"listbox",getAriaLabel:m=>{let _=m.textLabel;const v=a.CompletionItemKinds.toLabel(m.completion.kind);if(typeof m.completion.label!="string"){const{detail:I,description:x}=m.completion.label;I&&x?_=a.localize(1558,"{0} {1}, {2}, {3}",_,I,x,v):I?_=a.localize(1559,"{0} {1}, {2}",_,I,v):x&&(_=a.localize(1560,"{0}, {1}, {2}",_,x,v))}else _=a.localize(1561,"{0}, {1}",_,v);if(!m.isResolved||!this._isDetailsVisible())return _;const{documentation:b,detail:C}=m.completion,y=a.format("{0}{1}",C||"",b?typeof b=="string"?b:b.value:"");return a.localize(1562,"{0}, docs: {1}",_,y)}}}),this._list.style(o.getListStyles({listInactiveFocusBackground:XL,listInactiveFocusOutline:YL})),this._status=s.createInstance(og,this.element.domNode,Mt,void 0);const p=()=>this.element.domNode.classList.toggle("with-status-bar",this.editor.getOption(134).showStatusBar);p(),this._disposables.add(this._list.onMouseDown(m=>this._onListMouseDownOrTap(m))),this._disposables.add(this._list.onTap(m=>this._onListMouseDownOrTap(m))),this._disposables.add(this._list.onDidChangeSelection(m=>this._onListSelection(m))),this._disposables.add(this._list.onDidChangeFocus(m=>this._onListFocus(m))),this._disposables.add(this.editor.onDidChangeCursorSelection(()=>this._onCursorSelectionChanged())),this._disposables.add(this.editor.onDidChangeConfiguration(m=>{m.hasChanged(134)&&(p(),h(),u()),this._completionModel&&(m.hasChanged(59)||m.hasChanged(135)||m.hasChanged(136))&&this._list.splice(0,this._list.length,this._completionModel.items)})),this._ctxSuggestWidgetVisible=N.Visible.bindTo(i),this._ctxSuggestWidgetDetailsVisible=N.DetailsVisible.bindTo(i),this._ctxSuggestWidgetMultipleSuggestions=N.MultipleSuggestions.bindTo(i),this._ctxSuggestWidgetHasFocusedSuggestion=N.HasFocusedSuggestion.bindTo(i),this._ctxSuggestWidgetDetailsFocused=N.DetailsFocused.bindTo(i);const f=o.trackFocus(this._details.widget.domNode);this._disposables.add(f),this._disposables.add(f.onDidFocus(()=>this._ctxSuggestWidgetDetailsFocused.set(!0))),this._disposables.add(f.onDidBlur(()=>this._ctxSuggestWidgetDetailsFocused.set(!1))),this._disposables.add(o.addStandardDisposableListener(this._details.widget.domNode,"keydown",m=>{this._onDetailsKeydown.fire(m)})),this._disposables.add(this.editor.onMouseDown(m=>this._onEditorMouseDown(m)))}dispose(){this._details.widget.dispose(),this._details.dispose(),this._list.dispose(),this._status.dispose(),this._disposables.dispose(),this._loadingTimeout.dispose(),this._pendingLayout.dispose(),this._pendingShowDetails.dispose(),this._showTimeout.dispose(),this._contentWidget.dispose(),this.element.dispose(),this._onDidSelect.dispose(),this._onDidFocus.dispose(),this._onDidHide.dispose(),this._onDidShow.dispose(),this._onDetailsKeydown.dispose()}_onEditorMouseDown(e){this._details.widget.domNode.contains(e.target.element)?this._details.widget.domNode.focus():this.element.domNode.contains(e.target.element)&&this.editor.focus()}_onCursorSelectionChanged(){this._state!==0&&this._contentWidget.layout()}_onListMouseDownOrTap(e){typeof e.element>"u"||typeof e.index>"u"||(e.browserEvent.preventDefault(),e.browserEvent.stopPropagation(),this._select(e.element,e.index))}_onListSelection(e){e.elements.length&&this._select(e.elements[0],e.indexes[0])}_select(e,t){const i=this._completionModel;i&&(this._onDidSelect.fire({item:e,index:t,model:i}),this.editor.focus())}_onListFocus(e){if(this._ignoreFocusEvents)return;if(this._state===5&&this._setState(3),!e.elements.length){this._currentSuggestionDetails&&(this._currentSuggestionDetails.cancel(),this._currentSuggestionDetails=void 0,this._focusedItem=void 0),this.editor.setAriaOptions({activeDescendant:void 0}),this._ctxSuggestWidgetHasFocusedSuggestion.set(!1);return}if(!this._completionModel)return;this._ctxSuggestWidgetHasFocusedSuggestion.set(!0);const t=e.elements[0],i=e.indexes[0];t!==this._focusedItem&&(this._currentSuggestionDetails?.cancel(),this._currentSuggestionDetails=void 0,this._focusedItem=t,this._list.reveal(i),this._currentSuggestionDetails=a.createCancelablePromise(async n=>{const s=a.disposableTimeout(()=>{this._isDetailsVisible()&&this._showDetails(!0,!1)},250),r=n.onCancellationRequested(()=>s.dispose());try{return await t.resolve(n)}finally{s.dispose(),r.dispose()}}),this._currentSuggestionDetails.then(()=>{i>=this._list.length||t!==this._list.element(i)||(this._ignoreFocusEvents=!0,this._list.splice(i,1,[t]),this._list.setFocus([i]),this._ignoreFocusEvents=!1,this._isDetailsVisible()?this._showDetails(!1,!1):this.element.domNode.classList.remove("docs-side"),this.editor.setAriaOptions({activeDescendant:this._list.getElementID(i)}))}).catch(a.onUnexpectedError)),this._onDidFocus.fire({item:t,index:i,model:this._completionModel})}_setState(e){if(this._state!==e)switch(this._state=e,this.element.domNode.classList.toggle("frozen",e===4),this.element.domNode.classList.remove("message"),e){case 0:o.hide(this._messageElement,this._listElement,this._status.element),this._details.hide(!0),this._status.hide(),this._contentWidget.hide(),this._ctxSuggestWidgetVisible.reset(),this._ctxSuggestWidgetMultipleSuggestions.reset(),this._ctxSuggestWidgetHasFocusedSuggestion.reset(),this._showTimeout.cancel(),this.element.domNode.classList.remove("visible"),this._list.splice(0,this._list.length),this._focusedItem=void 0,this._cappedHeight=void 0,this._explainMode=!1;break;case 1:this.element.domNode.classList.add("message"),this._messageElement.textContent=Fs.LOADING_MESSAGE,o.hide(this._listElement,this._status.element),o.show(this._messageElement),this._details.hide(),this._show(),this._focusedItem=void 0,o.status(Fs.LOADING_MESSAGE);break;case 2:this.element.domNode.classList.add("message"),this._messageElement.textContent=Fs.NO_SUGGESTIONS_MESSAGE,o.hide(this._listElement,this._status.element),o.show(this._messageElement),this._details.hide(),this._show(),this._focusedItem=void 0,o.status(Fs.NO_SUGGESTIONS_MESSAGE);break;case 3:o.hide(this._messageElement),o.show(this._listElement,this._status.element),this._show();break;case 4:o.hide(this._messageElement),o.show(this._listElement,this._status.element),this._show();break;case 5:o.hide(this._messageElement),o.show(this._listElement,this._status.element),this._details.show(),this._show(),this._details.widget.focus();break}}_show(){this._status.show(),this._contentWidget.show(),this._layout(this._persistedSize.restore()),this._ctxSuggestWidgetVisible.set(!0),this._showTimeout.cancelAndSet(()=>{this.element.domNode.classList.add("visible"),this._onDidShow.fire(this)},100)}showTriggered(e,t){this._state===0&&(this._contentWidget.setPosition(this.editor.getPosition()),this._isAuto=!!e,this._isAuto||(this._loadingTimeout.value=a.disposableTimeout(()=>this._setState(1),t)))}showSuggestions(e,t,i,n,s){if(this._contentWidget.setPosition(this.editor.getPosition()),this._loadingTimeout.clear(),this._currentSuggestionDetails?.cancel(),this._currentSuggestionDetails=void 0,this._completionModel!==e&&(this._completionModel=e),i&&this._state!==2&&this._state!==0){this._setState(4);return}const r=this._completionModel.items.length,l=r===0;if(this._ctxSuggestWidgetMultipleSuggestions.set(r>1),l){this._setState(n?0:2),this._completionModel=void 0;return}this._focusedItem=void 0,this._onDidFocus.pause(),this._onDidSelect.pause();try{this._list.splice(0,this._list.length,this._completionModel.items),this._setState(i?4:3),this._list.reveal(t,0,t===0?0:this.getLayoutInfo().itemHeight*.33),this._list.setFocus(s?[]:[t])}finally{this._onDidFocus.resume(),this._onDidSelect.resume()}this._pendingLayout.value=o.runAtThisOrScheduleAtNextAnimationFrame(o.getWindow(this.element.domNode),()=>{this._pendingLayout.clear(),this._layout(this.element.size),this._details.widget.domNode.classList.remove("focused")})}focusSelected(){this._list.length>0&&this._list.setFocus([0])}selectNextPage(){switch(this._state){case 0:return!1;case 5:return this._details.widget.pageDown(),!0;case 1:return!this._isAuto;default:return this._list.focusNextPage(),!0}}selectNext(){switch(this._state){case 0:return!1;case 1:return!this._isAuto;default:return this._list.focusNext(1,!0),!0}}selectLast(){switch(this._state){case 0:return!1;case 5:return this._details.widget.scrollBottom(),!0;case 1:return!this._isAuto;default:return this._list.focusLast(),!0}}selectPreviousPage(){switch(this._state){case 0:return!1;case 5:return this._details.widget.pageUp(),!0;case 1:return!this._isAuto;default:return this._list.focusPreviousPage(),!0}}selectPrevious(){switch(this._state){case 0:return!1;case 1:return!this._isAuto;default:return this._list.focusPrevious(1,!0),!1}}selectFirst(){switch(this._state){case 0:return!1;case 5:return this._details.widget.scrollTop(),!0;case 1:return!this._isAuto;default:return this._list.focusFirst(),!0}}getFocusedItem(){if(this._state!==0&&this._state!==2&&this._state!==1&&this._completionModel&&this._list.getFocus().length>0)return{item:this._list.getFocusedElements()[0],index:this._list.getFocus()[0],model:this._completionModel}}toggleDetailsFocus(){this._state===5?(this._list.setFocus(this._list.getFocus()),this._setState(3)):this._state===3&&(this._setState(5),this._isDetailsVisible()?this._details.widget.focus():this.toggleDetails(!0))}toggleDetails(e=!1){this._isDetailsVisible()?(this._pendingShowDetails.clear(),this._ctxSuggestWidgetDetailsVisible.set(!1),this._setDetailsVisible(!1),this._details.hide(),this.element.domNode.classList.remove("shows-details")):(rg(this._list.getFocusedElements()[0])||this._explainMode)&&(this._state===3||this._state===5||this._state===4)&&(this._ctxSuggestWidgetDetailsVisible.set(!0),this._setDetailsVisible(!0),this._showDetails(!1,e))}_showDetails(e,t){this._pendingShowDetails.value=o.runAtThisOrScheduleAtNextAnimationFrame(o.getWindow(this.element.domNode),()=>{this._pendingShowDetails.clear(),this._details.show();let i=!1;e?this._details.widget.renderLoading():this._details.widget.renderItem(this._list.getFocusedElements()[0],this._explainMode),this._details.widget.isEmpty?this._details.hide():(this._positionDetails(),this.element.domNode.classList.add("shows-details"),t&&(this._details.widget.focus(),i=!0)),i||this.editor.focus()})}toggleExplainMode(){this._list.getFocusedElements()[0]&&(this._explainMode=!this._explainMode,this._isDetailsVisible()?this._showDetails(!1,!1):this.toggleDetails())}resetPersistedSize(){this._persistedSize.reset()}hideWidget(){this._pendingLayout.clear(),this._pendingShowDetails.clear(),this._loadingTimeout.clear(),this._setState(0),this._onDidHide.fire(this),this.element.clearSashHoverState();const e=this._persistedSize.restore(),t=Math.ceil(this.getLayoutInfo().itemHeight*4.3);e&&e.height<t&&this._persistedSize.store(e.with(void 0,t))}isFrozen(){return this._state===4}_afterRender(e){if(e===null){this._isDetailsVisible()&&this._details.hide();return}this._state===2||this._state===1||(this._isDetailsVisible()&&!this._details.widget.isEmpty&&this._details.show(),this._positionDetails())}_layout(e){if(!this.editor.hasModel()||!this.editor.getDomNode())return;const t=o.getClientArea(this.element.domNode.ownerDocument.body),i=this.getLayoutInfo();e||(e=i.defaultSize);let n=e.height,s=e.width;if(this._status.element.style.height=`${i.itemHeight}px`,this._state===2||this._state===1)n=i.itemHeight+i.borderHeight,s=i.defaultSize.width/2,this.element.enableSashes(!1,!1,!1,!1),this.element.minSize=this.element.maxSize=new o.Dimension(s,n),this._contentWidget.setPreference(2);else{const r=t.width-i.borderHeight-2*i.horizontalPadding;s>r&&(s=r);let l=this._completionModel?this._completionModel.stats.pLabelLen*i.typicalHalfwidthCharacterWidth:s;if(this.editor.getOption(134).fitWidthToDetails&&this._completionModel&&!this._persistedSize.restore()){const C=Math.min(r,this.editor.getLayoutInfo().width),y=Math.min(C,this._measureContentWidth(i));s=Math.max(s,y),l=Math.max(l,y)}const d=i.statusBarHeight+this._list.contentHeight+i.borderHeight,h=i.itemHeight+i.statusBarHeight,u=o.getDomNodePagePosition(this.editor.getDomNode()),g=this.editor.getScrolledVisiblePosition(this.editor.getPosition()),p=u.top+g.top+g.height,f=Math.min(t.height-p-i.verticalPadding,d),m=u.top+g.top-i.verticalPadding,_=Math.min(m,d);let v=Math.min(Math.max(_,f)+i.borderHeight,d);n===this._cappedHeight?.capped&&(n=this._cappedHeight.wanted),n<h&&(n=h),n>v&&(n=v),n>f&&_>f||this._forceRenderingAbove&&m>150?(this._contentWidget.setPreference(1),this.element.enableSashes(!0,!0,!1,!1),v=_):(this._contentWidget.setPreference(2),this.element.enableSashes(!1,!0,!0,!1),v=f),this.element.preferredSize=new o.Dimension(l,i.defaultSize.height),this.element.maxSize=new o.Dimension(r,v),this.element.minSize=new o.Dimension(220,h),this._cappedHeight=n===d?{wanted:this._cappedHeight?.wanted??e.height,capped:n}:void 0}this._resize(s,n)}_resize(e,t){const{width:i,height:n}=this.element.maxSize;e=Math.min(i,e),t=Math.min(n,t);const{statusBarHeight:s}=this.getLayoutInfo();this._list.layout(t-s,e),this._listElement.style.height=`${t-s}px`,this.element.layout(t,e),this._contentWidget.layout(),this._positionDetails()}_positionDetails(){this._isDetailsVisible()&&this._details.placeAtAnchor(this.element.domNode,this._contentWidget.getPosition()?.preference[0]===2)}_measureContentWidth(e){const t=this._completionModel;if(!t)return 0;if(this._fitContentWidth?.model===t)return this._fitContentWidth.width;this._measureContext===void 0&&(this._measureContext=o.$("canvas").getContext("2d"));let i;if(this._measureContext){const r=this.editor.getOptions(),l=r.get(59),d=r.get(135)||l.fontSize;this._measureContext.font=`${l.fontWeight} ${d}px ${l.getMassagedFontFamily()}`,i=0;for(const h of t.items){const{completion:u}=h;let g=h.textLabel;typeof u.label=="string"?g+=u.detail??"":g+=(u.label.detail??"")+(u.label.description??""),i=Math.max(i,this._measureContext.measureText(g).width)}}else i=t.stats.pLabelLen*e.typicalHalfwidthCharacterWidth;const n=2*e.itemHeight+2*e.horizontalPadding+20,s=i+n;return this._fitContentWidth={model:t,width:s},s}getLayoutInfo(){const e=this.editor.getOption(59),t=o.clamp(this.editor.getOption(136)||e.lineHeight,8,1e3),i=!this.editor.getOption(134).showStatusBar||this._state===2||this._state===1?0:t,n=this._details.widget.getLayoutInfo().borderWidth,s=2*n;return{itemHeight:t,statusBarHeight:i,borderWidth:n,borderHeight:s,typicalHalfwidthCharacterWidth:e.typicalHalfwidthCharacterWidth,verticalPadding:22,horizontalPadding:14,defaultSize:new o.Dimension(430,i+12*t)}}_isDetailsVisible(){return this._storageService.getBoolean("expandSuggestionDocs",0,!1)}_setDetailsVisible(e){this._storageService.store("expandSuggestionDocs",e,0,0)}forceRenderingAbove(){this._forceRenderingAbove||(this._forceRenderingAbove=!0,this._layout(this._persistedSize.restore()))}stopForceRenderingAbove(){this._forceRenderingAbove=!1}},Fs=Ri,Ri.LOADING_MESSAGE=a.localize(1555,"Loading..."),Ri.NO_SUGGESTIONS_MESSAGE=a.localize(1556,"No suggestions."),Ri);ug=Fs=ZL([Tl(1,o.IStorageService),Tl(2,o.IContextKeyService),Tl(3,o.IThemeService),Tl(4,o.IInstantiationService)],ug);class JL{constructor(e,t){this._widget=e,this._editor=t,this.allowEditorOverflow=!0,this.suppressMouseDown=!1,this._preferenceLocked=!1,this._added=!1,this._hidden=!1}dispose(){this._added&&(this._added=!1,this._editor.removeContentWidget(this))}getId(){return"editor.widget.suggestWidget"}getDomNode(){return this._widget.element.domNode}show(){this._hidden=!1,this._added||(this._added=!0,this._editor.addContentWidget(this))}hide(){this._hidden||(this._hidden=!0,this.layout())}layout(){this._editor.layoutContentWidget(this)}getPosition(){return this._hidden||!this._position||!this._preference?null:{position:this._position,preference:[this._preference]}}beforeRender(){const{height:e,width:t}=this._widget.element.size,{borderWidth:i,horizontalPadding:n}=this._widget.getLayoutInfo();return new o.Dimension(t+2*i+n,e+2*i)}afterRender(e){this._widget._afterRender(e)}setPreference(e){this._preferenceLocked||(this._preference=e)}lockPreference(){this._preferenceLocked=!0}unlockPreference(){this._preferenceLocked=!1}setPosition(e){this._position=e}}var WL=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},zs=function(c,e){return function(t,i){e(t,i,c)}},gg;class HL{constructor(e,t){if(this._model=e,this._position=t,this._decorationOptions=o.ModelDecorationOptions.register({description:"suggest-line-suffix",stickiness:1}),e.getLineMaxColumn(t.lineNumber)!==t.column){const n=e.getOffsetAt(t),s=e.getPositionAt(n+1);e.changeDecorations(r=>{this._marker&&r.removeDecoration(this._marker),this._marker=r.addDecoration(a.Range.fromPositions(t,s),this._decorationOptions)})}}dispose(){this._marker&&!this._model.isDisposed()&&this._model.changeDecorations(e=>{e.removeDecoration(this._marker),this._marker=void 0})}delta(e){if(this._model.isDisposed()||this._position.lineNumber!==e.lineNumber)return 0;if(this._marker){const t=this._model.getDecorationRange(this._marker);return this._model.getOffsetAt(t.getStartPosition())-this._model.getOffsetAt(e)}else return this._model.getLineMaxColumn(e.lineNumber)-e.column}}let He=(Gn=class{static get(e){return e.getContribution(gg.ID)}get onWillInsertSuggestItem(){return this._onWillInsertSuggestItem.event}constructor(e,t,i,n,s,r,l){this._memoryService=t,this._commandService=i,this._contextKeyService=n,this._instantiationService=s,this._logService=r,this._telemetryService=l,this._lineSuffix=new a.MutableDisposable,this._toDispose=new a.DisposableStore,this._selectors=new eD(g=>g.priority),this._onWillInsertSuggestItem=new a.Emitter,this._wantsForceRenderingAbove=!1,this.editor=e,this.model=s.createInstance(Dl,this.editor),this._selectors.register({priority:0,select:(g,p,f)=>this._memoryService.select(g,p,f)});const d=N.InsertMode.bindTo(n);d.set(e.getOption(134).insertMode),this._toDispose.add(this.model.onDidTrigger(()=>d.set(e.getOption(134).insertMode))),this.widget=this._toDispose.add(new o.WindowIdleValue(o.getWindow(e.getDomNode()),()=>{const g=this._instantiationService.createInstance(ug,this.editor);this._toDispose.add(g),this._toDispose.add(g.onDidSelect(v=>this._insertSuggestion(v,0),this));const p=new AL(this.editor,g,this.model,v=>this._insertSuggestion(v,2));this._toDispose.add(p);const f=N.MakesTextEdit.bindTo(this._contextKeyService),m=N.HasInsertAndReplaceRange.bindTo(this._contextKeyService),_=N.CanResolve.bindTo(this._contextKeyService);return this._toDispose.add(a.toDisposable(()=>{f.reset(),m.reset(),_.reset()})),this._toDispose.add(g.onDidFocus(({item:v})=>{const b=this.editor.getPosition(),C=v.editStart.column,y=b.column;let I=!0;this.editor.getOption(1)==="smart"&&this.model.state===2&&!v.completion.additionalTextEdits&&!(v.completion.insertTextRules&4)&&y-C===v.completion.insertText.length&&(I=this.editor.getModel().getValueInRange({startLineNumber:b.lineNumber,startColumn:C,endLineNumber:b.lineNumber,endColumn:y})!==v.completion.insertText),f.set(I),m.set(!a.Position.equals(v.editInsertEnd,v.editReplaceEnd)),_.set(!!v.provider.resolveCompletionItem||!!v.completion.documentation||v.completion.detail!==v.completion.label)})),this._wantsForceRenderingAbove&&g.forceRenderingAbove(),g})),this._overtypingCapturer=this._toDispose.add(new o.WindowIdleValue(o.getWindow(e.getDomNode()),()=>this._toDispose.add(new ng(this.editor,this.model)))),this._alternatives=this._toDispose.add(new o.WindowIdleValue(o.getWindow(e.getDomNode()),()=>this._toDispose.add(new As(this.editor,this._contextKeyService)))),this._toDispose.add(s.createInstance(xl,e)),this._toDispose.add(this.model.onDidTrigger(g=>{this.widget.value.showTriggered(g.auto,g.shy?250:50),this._lineSuffix.value=new HL(this.editor.getModel(),g.position)})),this._toDispose.add(this.model.onDidSuggest(g=>{if(g.triggerOptions.shy)return;let p=-1;for(const m of this._selectors.itemsOrderedByPriorityDesc)if(p=m.select(this.editor.getModel(),this.editor.getPosition(),g.completionModel.items),p!==-1)break;if(p===-1&&(p=0),this.model.state===0)return;let f=!1;if(g.triggerOptions.auto){const m=this.editor.getOption(134);m.selectionMode==="never"||m.selectionMode==="always"?f=m.selectionMode==="never":m.selectionMode==="whenTriggerCharacter"?f=g.triggerOptions.triggerKind!==1:m.selectionMode==="whenQuickSuggestion"&&(f=g.triggerOptions.triggerKind===1&&!g.triggerOptions.refilter)}this.widget.value.showSuggestions(g.completionModel,p,g.isFrozen,g.triggerOptions.auto,f)})),this._toDispose.add(this.model.onDidCancel(g=>{g.retrigger||this.widget.value.hideWidget()})),this._toDispose.add(this.editor.onDidBlurEditorWidget(()=>{this.model.cancel(),this.model.clear()}));const h=N.AcceptSuggestionsOnEnter.bindTo(n),u=()=>{const g=this.editor.getOption(1);h.set(g==="on"||g==="smart")};this._toDispose.add(this.editor.onDidChangeConfiguration(()=>u())),u()}dispose(){this._alternatives.dispose(),this._toDispose.dispose(),this.widget.dispose(),this.model.dispose(),this._lineSuffix.dispose(),this._onWillInsertSuggestItem.dispose()}_insertSuggestion(e,t){if(!e||!e.item){this._alternatives.value.reset(),this.model.cancel(),this.model.clear();return}if(!this.editor.hasModel())return;const i=ne.get(this.editor);if(!i)return;this._onWillInsertSuggestItem.fire({item:e.item});const n=this.editor.getModel(),s=n.getAlternativeVersionId(),{item:r}=e,l=[],d=new a.CancellationTokenSource;t&1||this.editor.pushUndoStop();const h=this.getOverwriteInfo(r,!!(t&8));this._memoryService.memorize(n,this.editor.getPosition(),r);const u=r.isResolved;let g=-1,p=-1;if(Array.isArray(r.completion.additionalTextEdits)){this.model.cancel();const m=o.StableEditorScrollState.capture(this.editor);this.editor.executeEdits("suggestController.additionalTextEdits.sync",r.completion.additionalTextEdits.map(_=>{let v=a.Range.lift(_.range);if(v.startLineNumber===r.position.lineNumber&&v.startColumn>r.position.column){const b=this.editor.getPosition().column-r.position.column,C=b,y=a.Range.spansMultipleLines(v)?0:b;v=new a.Range(v.startLineNumber,v.startColumn+C,v.endLineNumber,v.endColumn+y)}return o.EditOperation.replaceMove(v,_.text)})),m.restoreRelativeVerticalPositionOfCursor(this.editor)}else if(!u){const m=new a.StopWatch;let _;const v=n.onDidChangeContent(I=>{if(I.isFlush){d.cancel(),v.dispose();return}for(const x of I.changes){const S=a.Range.getEndPosition(x.range);(!_||a.Position.isBefore(S,_))&&(_=S)}}),b=t;t|=2;let C=!1;const y=this.editor.onWillType(()=>{y.dispose(),C=!0,b&2||this.editor.pushUndoStop()});l.push(r.resolve(d.token).then(()=>{if(!r.completion.additionalTextEdits||d.token.isCancellationRequested)return;if(_&&r.completion.additionalTextEdits.some(x=>a.Position.isBefore(_,a.Range.getStartPosition(x.range))))return!1;C&&this.editor.pushUndoStop();const I=o.StableEditorScrollState.capture(this.editor);return this.editor.executeEdits("suggestController.additionalTextEdits.async",r.completion.additionalTextEdits.map(x=>o.EditOperation.replaceMove(a.Range.lift(x.range),x.text))),I.restoreRelativeVerticalPositionOfCursor(this.editor),(C||!(b&2))&&this.editor.pushUndoStop(),!0}).then(I=>{this._logService.trace("[suggest] async resolving of edits DONE (ms, applied?)",m.elapsed(),I),p=I===!0?1:I===!1?0:-2}).finally(()=>{v.dispose(),y.dispose()}))}let{insertText:f}=r.completion;if(r.completion.insertTextRules&4||(f=Ui.escape(f)),this.model.cancel(),i.insert(f,{overwriteBefore:h.overwriteBefore,overwriteAfter:h.overwriteAfter,undoStopBefore:!1,undoStopAfter:!1,adjustWhitespace:!(r.completion.insertTextRules&1),clipboardText:e.model.clipboardText,overtypingCapturer:this._overtypingCapturer.value,reason:o.EditSources.suggest({providerId:a.ProviderId.fromExtensionId(r.extensionId?.value)})}),t&2||this.editor.pushUndoStop(),r.completion.command)if(r.completion.command.id===Ml.id)this.model.trigger({auto:!0,retrigger:!0});else{const m=new a.StopWatch;l.push(this._commandService.executeCommand(r.completion.command.id,...r.completion.command.arguments?[...r.completion.command.arguments]:[]).catch(_=>{r.completion.extensionId?a.onUnexpectedExternalError(_):a.onUnexpectedError(_)}).finally(()=>{g=m.elapsed()}))}t&4&&this._alternatives.value.set(e,m=>{for(d.cancel();n.canUndo();){s!==n.getAlternativeVersionId()&&n.undo(),this._insertSuggestion(m,3|(t&8?8:0));break}}),this._alertCompletionItem(r),Promise.all(l).finally(()=>{this._reportSuggestionAcceptedTelemetry(r,n,u,g,p,e.index,e.model.items),this.model.clear(),d.dispose()})}_reportSuggestionAcceptedTelemetry(e,t,i,n,s,r,l){if(Math.random()>1e-4)return;const d=new Map;for(let p=0;p<Math.min(30,l.length);p++){const f=l[p].textLabel;d.has(f)?d.get(f).push(p):d.set(f,[p])}const h=d.get(e.textLabel),g=h&&h.length>1?h[0]:-1;this._telemetryService.publicLog2("suggest.acceptedSuggestion",{extensionId:e.extensionId?.value??"unknown",providerId:e.provider._debugDisplayName??"unknown",kind:e.completion.kind,basenameHash:a.hash(o.basename(t.uri)).toString(16),languageId:t.getLanguageId(),fileExtension:o.extname(t.uri),resolveInfo:e.provider.resolveCompletionItem?i?1:0:-1,resolveDuration:e.resolveDuration,commandDuration:n,additionalEditsAsync:s,index:r,firstIndex:g})}getOverwriteInfo(e,t){a.assertType(this.editor.hasModel());let i=this.editor.getOption(134).insertMode==="replace";t&&(i=!i);const n=e.position.column-e.editStart.column,s=(i?e.editReplaceEnd.column:e.editInsertEnd.column)-e.position.column,r=this.editor.getPosition().column-e.position.column,l=this._lineSuffix.value?this._lineSuffix.value.delta(this.editor.getPosition()):0;return{overwriteBefore:n+r,overwriteAfter:s+l}}_alertCompletionItem(e){if(a.isNonEmptyArray(e.completion.additionalTextEdits)){const t=a.localize(1534,"Accepting '{0}' made {1} additional edits",e.textLabel,e.completion.additionalTextEdits.length);o.alert(t)}}triggerSuggest(e,t,i){this.editor.hasModel()&&(this.model.trigger({auto:t??!1,completionOptions:{providerFilter:e,kindFilter:i?new Set:void 0}}),this.editor.revealPosition(this.editor.getPosition(),0),this.editor.focus())}triggerSuggestAndAcceptBest(e){if(!this.editor.hasModel())return;const t=this.editor.getPosition(),i=()=>{t.equals(this.editor.getPosition())&&this._commandService.executeCommand(e.fallback)},n=s=>{if(s.completion.insertTextRules&4||s.completion.additionalTextEdits)return!0;const r=this.editor.getPosition(),l=s.editStart.column,d=r.column;return d-l!==s.completion.insertText.length?!0:this.editor.getModel().getValueInRange({startLineNumber:r.lineNumber,startColumn:l,endLineNumber:r.lineNumber,endColumn:d})!==s.completion.insertText};a.Event.once(this.model.onDidTrigger)(s=>{const r=[];a.Event.any(this.model.onDidTrigger,this.model.onDidCancel)(()=>{a.dispose(r),i()},void 0,r),this.model.onDidSuggest(({completionModel:l})=>{if(a.dispose(r),l.items.length===0){i();return}const d=this._memoryService.select(this.editor.getModel(),this.editor.getPosition(),l.items),h=l.items[d];if(!n(h)){i();return}this.editor.pushUndoStop(),this._insertSuggestion({index:d,item:h,model:l},7)},void 0,r)}),this.model.trigger({auto:!1,shy:!0}),this.editor.revealPosition(t,0),this.editor.focus()}acceptSelectedSuggestion(e,t){const i=this.widget.value.getFocusedItem();let n=0;e&&(n|=4),t&&(n|=8),this._insertSuggestion(i,n)}acceptNextSuggestion(){this._alternatives.value.next()}acceptPrevSuggestion(){this._alternatives.value.prev()}cancelSuggestWidget(){this.model.cancel(),this.model.clear(),this.widget.value.hideWidget()}focusSuggestion(){this.widget.value.focusSelected()}selectNextSuggestion(){this.widget.value.selectNext()}selectNextPageSuggestion(){this.widget.value.selectNextPage()}selectLastSuggestion(){this.widget.value.selectLast()}selectPrevSuggestion(){this.widget.value.selectPrevious()}selectPrevPageSuggestion(){this.widget.value.selectPreviousPage()}selectFirstSuggestion(){this.widget.value.selectFirst()}toggleSuggestionDetails(){this.widget.value.toggleDetails()}toggleExplainMode(){this.widget.value.toggleExplainMode()}toggleSuggestionFocus(){this.widget.value.toggleDetailsFocus()}resetWidgetSize(){this.widget.value.resetPersistedSize()}forceRenderingAbove(){this.widget.isInitialized?this.widget.value.forceRenderingAbove():this._wantsForceRenderingAbove=!0}stopForceRenderingAbove(){this.widget.isInitialized?this.widget.value.stopForceRenderingAbove():this._wantsForceRenderingAbove=!1}registerSelector(e){return this._selectors.register(e)}},gg=Gn,Gn.ID="editor.contrib.suggestController",Gn);He=gg=WL([zs(1,Il),zs(2,o.ICommandService),zs(3,o.IContextKeyService),zs(4,o.IInstantiationService),zs(5,o.ILogService),zs(6,o.ITelemetryService)],He);class eD{constructor(e){this.prioritySelector=e,this._items=new Array}register(e){if(this._items.indexOf(e)!==-1)throw new Error("Value is already registered");return this._items.push(e),this._items.sort((t,i)=>this.prioritySelector(i)-this.prioritySelector(t)),{dispose:()=>{const t=this._items.indexOf(e);t>=0&&this._items.splice(t,1)}}}get itemsOrderedByPriorityDesc(){return this._items}}const Uc=class Uc extends o.EditorAction{constructor(){super({id:Uc.id,label:a.localize2(1543,"Trigger Suggest"),precondition:o.ContextKeyExpr.and(o.EditorContextKeys.writable,o.EditorContextKeys.hasCompletionItemProvider,N.Visible.toNegated()),kbOpts:{kbExpr:o.EditorContextKeys.textInputFocus,primary:2058,secondary:[2087],mac:{primary:266,secondary:[521,2087]},weight:100}})}run(e,t,i){const n=He.get(t);if(!n)return;let s;i&&typeof i=="object"&&i.auto===!0&&(s=!0),n.triggerSuggest(void 0,s,void 0)}};Uc.id="editor.action.triggerSuggest";let Ml=Uc;o.registerEditorContribution(He.ID,He,2),o.registerEditorAction(Ml);const ye=190,ce=o.EditorCommand.bindToContribution(He.get);o.registerEditorCommand(new ce({id:"acceptSelectedSuggestion",precondition:o.ContextKeyExpr.and(N.Visible,N.HasFocusedSuggestion),handler(c){c.acceptSelectedSuggestion(!0,!1)},kbOpts:[{primary:2,kbExpr:o.ContextKeyExpr.and(N.Visible,o.EditorContextKeys.textInputFocus),weight:ye},{primary:3,kbExpr:o.ContextKeyExpr.and(N.Visible,o.EditorContextKeys.textInputFocus,N.AcceptSuggestionsOnEnter,N.MakesTextEdit),weight:ye}],menuOpts:[{menuId:Mt,title:a.localize(1535,"Insert"),group:"left",order:1,when:o.ContextKeyExpr.and(N.HasFocusedSuggestion,N.HasInsertAndReplaceRange.toNegated())},{menuId:Mt,title:a.localize(1536,"Insert"),group:"left",order:1,when:o.ContextKeyExpr.and(N.HasFocusedSuggestion,N.HasInsertAndReplaceRange,N.InsertMode.isEqualTo("insert"))},{menuId:Mt,title:a.localize(1537,"Replace"),group:"left",order:1,when:o.ContextKeyExpr.and(N.HasFocusedSuggestion,N.HasInsertAndReplaceRange,N.InsertMode.isEqualTo("replace"))}]})),o.registerEditorCommand(new ce({id:"acceptAlternativeSelectedSuggestion",precondition:o.ContextKeyExpr.and(N.Visible,o.EditorContextKeys.textInputFocus,N.HasFocusedSuggestion),kbOpts:{weight:ye,kbExpr:o.EditorContextKeys.textInputFocus,primary:1027,secondary:[1026]},handler(c){c.acceptSelectedSuggestion(!1,!0)},menuOpts:[{menuId:Mt,group:"left",order:2,when:o.ContextKeyExpr.and(N.HasFocusedSuggestion,N.HasInsertAndReplaceRange,N.InsertMode.isEqualTo("insert")),title:a.localize(1538,"Replace")},{menuId:Mt,group:"left",order:2,when:o.ContextKeyExpr.and(N.HasFocusedSuggestion,N.HasInsertAndReplaceRange,N.InsertMode.isEqualTo("replace")),title:a.localize(1539,"Insert")}]})),o.CommandsRegistry.registerCommandAlias("acceptSelectedSuggestionOnEnter","acceptSelectedSuggestion"),o.registerEditorCommand(new ce({id:"hideSuggestWidget",precondition:N.Visible,handler:c=>c.cancelSuggestWidget(),kbOpts:{weight:ye,kbExpr:o.EditorContextKeys.textInputFocus,primary:9,secondary:[1033]}})),o.registerEditorCommand(new ce({id:"selectNextSuggestion",precondition:o.ContextKeyExpr.and(N.Visible,o.ContextKeyExpr.or(N.MultipleSuggestions,N.HasFocusedSuggestion.negate())),handler:c=>c.selectNextSuggestion(),kbOpts:{weight:ye,kbExpr:o.EditorContextKeys.textInputFocus,primary:18,secondary:[2066],mac:{primary:18,secondary:[2066,300]}},menuOpts:{menuId:Mt,group:"left",order:0,when:N.HasFocusedSuggestion.toNegated(),title:a.localize(1540,"Select")}})),o.registerEditorCommand(new ce({id:"selectNextPageSuggestion",precondition:o.ContextKeyExpr.and(N.Visible,o.ContextKeyExpr.or(N.MultipleSuggestions,N.HasFocusedSuggestion.negate())),handler:c=>c.selectNextPageSuggestion(),kbOpts:{weight:ye,kbExpr:o.EditorContextKeys.textInputFocus,primary:12,secondary:[2060]}})),o.registerEditorCommand(new ce({id:"selectLastSuggestion",precondition:o.ContextKeyExpr.and(N.Visible,o.ContextKeyExpr.or(N.MultipleSuggestions,N.HasFocusedSuggestion.negate())),handler:c=>c.selectLastSuggestion()})),o.registerEditorCommand(new ce({id:"selectPrevSuggestion",precondition:o.ContextKeyExpr.and(N.Visible,o.ContextKeyExpr.or(N.MultipleSuggestions,N.HasFocusedSuggestion.negate())),handler:c=>c.selectPrevSuggestion(),kbOpts:{weight:ye,kbExpr:o.EditorContextKeys.textInputFocus,primary:16,secondary:[2064],mac:{primary:16,secondary:[2064,302]}}})),o.registerEditorCommand(new ce({id:"selectPrevPageSuggestion",precondition:o.ContextKeyExpr.and(N.Visible,o.ContextKeyExpr.or(N.MultipleSuggestions,N.HasFocusedSuggestion.negate())),handler:c=>c.selectPrevPageSuggestion(),kbOpts:{weight:ye,kbExpr:o.EditorContextKeys.textInputFocus,primary:11,secondary:[2059]}})),o.registerEditorCommand(new ce({id:"selectFirstSuggestion",precondition:o.ContextKeyExpr.and(N.Visible,o.ContextKeyExpr.or(N.MultipleSuggestions,N.HasFocusedSuggestion.negate())),handler:c=>c.selectFirstSuggestion()})),o.registerEditorCommand(new ce({id:"focusSuggestion",precondition:o.ContextKeyExpr.and(N.Visible,N.HasFocusedSuggestion.negate()),handler:c=>c.focusSuggestion(),kbOpts:{weight:ye,kbExpr:o.EditorContextKeys.textInputFocus,primary:2058,secondary:[2087],mac:{primary:266,secondary:[2087]}}})),o.registerEditorCommand(new ce({id:"focusAndAcceptSuggestion",precondition:o.ContextKeyExpr.and(N.Visible,N.HasFocusedSuggestion.negate()),handler:c=>{c.focusSuggestion(),c.acceptSelectedSuggestion(!0,!1)}})),o.registerEditorCommand(new ce({id:"toggleSuggestionDetails",precondition:o.ContextKeyExpr.and(N.Visible,N.HasFocusedSuggestion),handler:c=>c.toggleSuggestionDetails(),kbOpts:{weight:ye,kbExpr:o.EditorContextKeys.textInputFocus,primary:2058,secondary:[2087],mac:{primary:266,secondary:[2087]}},menuOpts:[{menuId:Mt,group:"right",order:1,when:o.ContextKeyExpr.and(N.DetailsVisible,N.CanResolve),title:a.localize(1541,"Show Less")},{menuId:Mt,group:"right",order:1,when:o.ContextKeyExpr.and(N.DetailsVisible.toNegated(),N.CanResolve),title:a.localize(1542,"Show More")}]})),o.registerEditorCommand(new ce({id:"toggleExplainMode",precondition:N.Visible,handler:c=>c.toggleExplainMode(),kbOpts:{weight:100,primary:2138}})),o.registerEditorCommand(new ce({id:"toggleSuggestionFocus",precondition:N.Visible,handler:c=>c.toggleSuggestionFocus(),kbOpts:{weight:ye,kbExpr:o.EditorContextKeys.textInputFocus,primary:2570,mac:{primary:778}}})),o.registerEditorCommand(new ce({id:"insertBestCompletion",precondition:o.ContextKeyExpr.and(o.EditorContextKeys.textInputFocus,o.ContextKeyExpr.equals("config.editor.tabCompletion","on"),xl.AtEnd,N.Visible.toNegated(),As.OtherSuggestions.toNegated(),ne.InSnippetMode.toNegated()),handler:(c,e)=>{c.triggerSuggestAndAcceptBest(a.isObject(e)?{fallback:"tab",...e}:{fallback:"tab"})},kbOpts:{weight:ye,primary:2}})),o.registerEditorCommand(new ce({id:"insertNextSuggestion",precondition:o.ContextKeyExpr.and(o.EditorContextKeys.textInputFocus,o.ContextKeyExpr.equals("config.editor.tabCompletion","on"),As.OtherSuggestions,N.Visible.toNegated(),ne.InSnippetMode.toNegated()),handler:c=>c.acceptNextSuggestion(),kbOpts:{weight:ye,kbExpr:o.EditorContextKeys.textInputFocus,primary:2}})),o.registerEditorCommand(new ce({id:"insertPrevSuggestion",precondition:o.ContextKeyExpr.and(o.EditorContextKeys.textInputFocus,o.ContextKeyExpr.equals("config.editor.tabCompletion","on"),As.OtherSuggestions,N.Visible.toNegated(),ne.InSnippetMode.toNegated()),handler:c=>c.acceptPrevSuggestion(),kbOpts:{weight:ye,kbExpr:o.EditorContextKeys.textInputFocus,primary:1026}})),o.registerEditorCommand(new class extends o.EditorCommand{constructor(){super({id:"suggestWidgetCopy",precondition:N.DetailsFocused,kbOpts:{weight:ye+10,kbExpr:N.DetailsFocused,primary:2081,win:{primary:2081,secondary:[2067]}}})}runEditorCommand(c,e){o.getWindow(e.getDomNode()).document.execCommand("copy")}}),o.registerEditorAction(class extends o.EditorAction{constructor(){super({id:"editor.action.resetSuggestSize",label:a.localize2(1544,"Reset Suggest Widget Size"),precondition:void 0})}run(c,e){He.get(e)?.resetWidgetSize()}});class tD extends a.Disposable{get selectedItem(){return this._currentSuggestItemInfo}constructor(e,t,i){super(),this.editor=e,this.suggestControllerPreselector=t,this.onWillAccept=i,this.isSuggestWidgetVisible=!1,this.isShiftKeyPressed=!1,this._isActive=!1,this._currentSuggestItemInfo=void 0,this._onDidSelectedItemChange=this._register(new a.Emitter),this.onDidSelectedItemChange=this._onDidSelectedItemChange.event,this._register(e.onKeyDown(s=>{s.shiftKey&&!this.isShiftKeyPressed&&(this.isShiftKeyPressed=!0,this.update(this._isActive))})),this._register(e.onKeyUp(s=>{s.shiftKey&&this.isShiftKeyPressed&&(this.isShiftKeyPressed=!1,this.update(this._isActive))}));const n=He.get(this.editor);if(n){this._register(n.registerSelector({priority:100,select:(l,d,h)=>{const u=this.editor.getModel();if(!u)return-1;const g=this.suggestControllerPreselector(),p=g?Yt(g,u):void 0;if(!p)return-1;const f=a.Position.lift(d),m=h.map((v,b)=>{const C=hr.fromSuggestion(n,u,f,v,this.isShiftKeyPressed),y=Yt(C.getSingleTextEdit(),u),I=vv(p,y);return{index:b,valid:I,prefixLength:y.text.length,suggestItem:v}}).filter(v=>v&&v.valid&&v.prefixLength>0),_=a.findFirstMax(m,a.compareBy(v=>v.prefixLength,a.numberComparator));return _?_.index:-1}}));let s=!1;const r=()=>{s||(s=!0,this._register(n.widget.value.onDidShow(()=>{this.isSuggestWidgetVisible=!0,this.update(!0)})),this._register(n.widget.value.onDidHide(()=>{this.isSuggestWidgetVisible=!1,this.update(!1)})),this._register(n.widget.value.onDidFocus(()=>{this.isSuggestWidgetVisible=!0,this.update(!0)})))};this._register(a.Event.once(n.model.onDidTrigger)(l=>{r()})),this._register(n.onWillInsertSuggestItem(l=>{const d=this.editor.getPosition(),h=this.editor.getModel();if(!d||!h)return;const u=hr.fromSuggestion(n,h,d,l.item,this.isShiftKeyPressed);this.onWillAccept(u)}))}this.update(this._isActive)}update(e){const t=this.getSuggestItemInfo();(this._isActive!==e||!iD(this._currentSuggestItemInfo,t))&&(this._isActive=e,this._currentSuggestItemInfo=t,this._onDidSelectedItemChange.fire())}getSuggestItemInfo(){const e=He.get(this.editor);if(!e||!this.isSuggestWidgetVisible)return;const t=e.widget.value.getFocusedItem(),i=this.editor.getPosition(),n=this.editor.getModel();if(!(!t||!i||!n))return hr.fromSuggestion(e,n,i,t.item,this.isShiftKeyPressed)}stopForceRenderingAbove(){He.get(this.editor)?.stopForceRenderingAbove()}forceRenderingAbove(){He.get(this.editor)?.forceRenderingAbove()}}class hr{static fromSuggestion(e,t,i,n,s){let{insertText:r}=n.completion,l=!1;if(n.completion.insertTextRules&4){const h=new Ui().parse(r);h.children.length<100&&ul.adjustWhitespace(t,i,!0,h),r=h.toString(),l=!0}const d=e.getOverwriteInfo(n,s);return new hr(a.Range.fromPositions(i.delta(0,-d.overwriteBefore),i.delta(0,Math.max(d.overwriteAfter,0))),r,n.completion.kind,l,n.container.incomplete??!1)}constructor(e,t,i,n,s){this.range=e,this.insertText=t,this.completionItemKind=i,this.isSnippetText=n,this.listIncomplete=s}equals(e){return this.range.equalsRange(e.range)&&this.insertText===e.insertText&&this.completionItemKind===e.completionItemKind&&this.isSnippetText===e.isSnippetText}toSelectedSuggestionInfo(){return new a.SelectedSuggestionInfo(this.range,this.insertText,this.completionItemKind,this.isSnippetText)}getSingleTextEdit(){return new a.TextReplacement(this.range,this.insertText)}}function iD(c,e){return c===e?!0:!c||!e?!1:c.equals(e)}class nD extends a.Disposable{constructor(e,t,i){super(),this._editorObs=e,this._handleSuggestAccepted=t,this._suggestControllerPreselector=i,this._suggestWidgetAdaptor=this._register(new tD(this._editorObs.editor,()=>(this._editorObs.forceUpdate(),this._suggestControllerPreselector()),n=>this._editorObs.forceUpdate(s=>{this._handleSuggestAccepted(n)}))),this.selectedItem=o.observableFromEvent(this,n=>this._suggestWidgetAdaptor.onDidSelectedItemChange(()=>{this._editorObs.forceUpdate(s=>n(void 0))}),()=>this._suggestWidgetAdaptor.selectedItem)}stopForceRenderingAbove(){this._suggestWidgetAdaptor.stopForceRenderingAbove()}forceRenderingAbove(){this._suggestWidgetAdaptor.forceRenderingAbove()}}class sD{constructor(e,t){this.lineNumber=e,this.columnRange=t}}class Kv{constructor(e,t){if(this.startColumn=e,this.endColumnExclusive=t,e>t)throw new a.BugIndicatingError(`startColumn ${e} cannot be after endColumnExclusive ${t}`)}toRange(e){return new a.Range(e,this.startColumn,e,this.endColumnExclusive)}equals(e){return this.startColumn===e.startColumn&&this.endColumnExclusive===e.endColumnExclusive}toZeroBasedOffsetRange(){return new a.OffsetRange(this.startColumn-1,this.endColumnExclusive-1)}}class gn{static fromLineTokens(e){const t=[];for(let i=0;i<e.getCount();i++)t.push(new kv(e.getTokenText(i),e.getMetadata(i)));return gn.create(t)}static create(e){return new gn(e)}constructor(e){this._tokenInfo=e}toLineTokens(e){return o.LineTokens.createFromTextAndMetadata(this.map((t,i)=>({text:i.text,metadata:i.metadata})),e)}map(e){const t=[];let i=0;for(const n of this._tokenInfo){const s=new a.OffsetRange(i,i+n.text.length);t.push(e(s,n)),i+=n.text.length}return t}slice(e){const t=[];let i=0;for(const n of this._tokenInfo){const s=i,r=s+n.text.length;if(r>e.start){if(s>=e.endExclusive)break;const l=Math.max(0,e.start-s),d=Math.max(0,r-e.endExclusive);t.push(new kv(n.text.slice(l,n.text.length-d),n.metadata))}i+=n.text.length}return gn.create(t)}append(e){const t=this._tokenInfo.concat(e._tokenInfo);return gn.create(t)}}class kv{constructor(e,t){this.text=e,this.metadata=t}}var oD=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},rD=function(c,e){return function(t,i){e(t,i,c)}};class pg{static from(e){if(e)return new pg(e.icon)}constructor(e=a.Codicon.warning){this.icon=e}}const Uv="ghost-text";let ur=class extends a.Disposable{constructor(e,t,i,n){super(),this._editor=e,this._data=t,this._languageService=n,this._isDisposed=o.observableValue(this,!1),this._warningState=o.derived(s=>{const r=this._data.read(s),l=r?.warning;if(!r||!l)return;const d=r.ghostText;return{lineNumber:d.lineNumber,position:new a.Position(d.lineNumber,d.parts[0].column),icon:l.icon}}),this._onDidClick=this._register(new a.Emitter),this.onDidClick=this._onDidClick.event,this._nonWhitespaceCount=o.derived(this,s=>{const r=this._data.read(s);return r?r.ghostText.parts.map(h=>h.lines.map(u=>u.line).join("")).join("").replace(/\s/g,"").length:void 0}),this._extraClassNames=o.derived(this,s=>{const r=this._extraClasses.slice();this._warningState.read(s)&&r.push("warning");const l=this._nonWhitespaceCount.read(s);return this._highlightShortText&&l&&l<3?r.push("short-text"):this._useSyntaxHighlighting.read(s)&&r.push("syntax-highlighted"),r.map(h=>` ${h}`).join("")}),this._state=o.derived(this,s=>{if(this._isDisposed.read(s))return;const r=this._data.read(s);if(!r)return;const l=this._editorObs.model.read(s);if(!l)return;const d=r.ghostText,h=d instanceof Fu?d.columnRange:void 0,u=this._useSyntaxHighlighting.read(s),g=this._extraClassNames.read(s),{inlineTexts:p,additionalLines:f,hiddenRange:m,additionalLinesOriginalSuffix:_}=aD(d,l,Uv+g),v=l.getLineContent(d.lineNumber),b=new a.StringEdit(p.map(R=>a.StringReplacement.insert(R.column-1,R.text))),C=u?l.tokenization.tokenizeLinesAt(d.lineNumber,[b.apply(v),...f.map(R=>R.content)]):void 0,y=b.getNewRanges(),I=p.map((R,D)=>({...R,tokens:C?.[0]?.getTokensInRange(y[D])})),x=f.map((R,D)=>{let T=C?.[D+1]??o.LineTokens.createEmpty(R.content,this._languageService.languageIdCodec);if(D===f.length-1&&_){const M=gn.fromLineTokens(l.tokenization.getLineTokens(_.lineNumber)).slice(_.columnRange.toZeroBasedOffsetRange());T=gn.fromLineTokens(T).append(M).toLineTokens(T.languageIdCodec)}return new dD(T,R.decorations)}),S=this._editor.getSelection()?.getStartPosition().column,w=I.filter(R=>R.text!==""),E=w.length!==0,L=new ku((E?w[0].column:1)-S,E?0:f.findIndex(R=>R.content!=="")+1,E?1:0,f.length+(E?1:0),0,a.sum(w.map(R=>R.text.length))+a.sum(x.map(R=>R.content.getTextLength())),w.length+(f.length>0?1:0),w.length>1&&x.length===0?w.every(R=>R.text===w[0].text):void 0);return{replacedRange:h,inlineTexts:I,additionalLines:x,hiddenRange:m,lineNumber:d.lineNumber,additionalReservedLineCount:this._minReservedLineCount.read(s),targetTextModel:l,syntaxHighlightingEnabled:u,telemetryViewData:L,handleInlineCompletionShown:r.handleInlineCompletionShown}}),this._decorations=o.derived(this,s=>{const r=this._state.read(s);if(!r)return[];const l=[],d=this._extraClassNames.read(s);r.replacedRange&&l.push({range:r.replacedRange.toRange(r.lineNumber),options:{inlineClassName:"inline-completion-text-to-replace"+d,description:"GhostTextReplacement"}}),r.hiddenRange&&l.push({range:r.hiddenRange.toRange(r.lineNumber),options:{inlineClassName:"ghost-text-hidden",description:"ghost-text-hidden"}});for(const h of r.inlineTexts){let u="";this._highlightShortText&&h.text.length<5&&(u+=" short-text"),l.push({range:a.Range.fromPositions(new a.Position(r.lineNumber,h.column)),options:{description:"ghost-text-decoration",after:{content:h.text,tokens:h.tokens,inlineClassName:(h.preview?"ghost-text-decoration-preview":"ghost-text-decoration")+(this._isClickable?" clickable":"")+d+u+h.lineDecorations.map(g=>" "+g.className).join(" "),cursorStops:a.InjectedTextCursorStops.Left,attachedData:new fg(this)},showIfCollapsed:!0}})}return l}),this.isHovered=o.derived(this,s=>this._isDisposed.read(s)?!1:this._isInlineTextHovered.read(s)||this._additionalLinesWidget.isHovered.read(s)),this._extraClasses=i.extraClasses??[],this._isClickable=i.isClickable??!1,this._shouldKeepCursorStable=i.shouldKeepCursorStable??!1,this._minReservedLineCount=i.minReservedLineCount??o.constObservable(0),this._useSyntaxHighlighting=i.useSyntaxHighlighting??o.constObservable(!0),this._highlightShortText=i.highlightShortSuggestions??!1,this._editorObs=o.observableCodeEditor(this._editor),this._additionalLinesWidget=this._register(new cD(this._editor,o.derivedOpts({owner:this,equalsFn:o.equalsIfDefinedC(o.thisEqualsC())},s=>{const r=this._state.read(s);return r?new lD(r.lineNumber,r.additionalLines,r.additionalReservedLineCount):void 0}),this._shouldKeepCursorStable,this._isClickable)),this._isInlineTextHovered=this._editorObs.isTargetHovered(s=>s.target.type===6&&s.target.detail.injectedText?.options.attachedData instanceof fg&&s.target.detail.injectedText.options.attachedData.owner===this,this._store),this._register(a.toDisposable(()=>{this._isDisposed.set(!0,void 0)})),this._register(this._editorObs.setDecorations(this._decorations)),this._isClickable&&(this._register(this._additionalLinesWidget.onDidClick(s=>this._onDidClick.fire(s))),this._register(this._editor.onMouseUp(s=>{if(s.target.type!==6)return;const r=s.target.detail.injectedText?.options.attachedData;r instanceof fg&&r.owner===this&&this._onDidClick.fire(s.event)}))),this._register(o.autorun(s=>{const r=this._state.read(s);r?.handleInlineCompletionShown(r.telemetryViewData)})),this._register(o.autorunWithStore((s,r)=>{}))}static getWarningWidgetContext(e){const t=e.ghostTextViewWarningWidgetData;if(t)return t;if(e.parentElement)return this.getWarningWidgetContext(e.parentElement)}ownsViewZone(e){return this._additionalLinesWidget.viewZoneId===e}};ur=oD([rD(3,o.ILanguageService)],ur);class fg{constructor(e){this.owner=e}}function aD(c,e,t){const i=[],n=[];function s(g,p){if(n.length>0){const f=n[n.length-1];p&&f.decorations.push(new o.LineDecoration(f.content.length+1,f.content.length+1+g[0].line.length,p,0)),f.content+=g[0].line,g=g.slice(1)}for(const f of g)n.push({content:f.line,decorations:p?[new o.LineDecoration(1,f.line.length+1,p,0),...f.lineDecorations]:[...f.lineDecorations]})}const r=e.getLineContent(c.lineNumber);let l,d=0;for(const g of c.parts){let p=g.lines;l===void 0?(i.push({column:g.column,text:p[0].line,preview:g.preview,lineDecorations:p[0].lineDecorations}),p=p.slice(1)):s([{line:r.substring(d,g.column-1),lineDecorations:[]}],void 0),p.length>0&&(s(p,t),l===void 0&&g.column<=r.length&&(l=g.column)),d=g.column-1}let h;l!==void 0&&(h=new sD(c.lineNumber,new Kv(d+1,r.length+1)));const u=l!==void 0?new Kv(l,r.length+1):void 0;return{inlineTexts:i,additionalLines:n,hiddenRange:u,additionalLinesOriginalSuffix:h}}class lD{constructor(e,t,i){this.lineNumber=e,this.additionalLines=t,this.minReservedLineCount=i}equals(e){return this.lineNumber!==e.lineNumber||this.minReservedLineCount!==e.minReservedLineCount?!1:a.equals(this.additionalLines,e.additionalLines,o.thisEqualsC())}}class cD extends a.Disposable{get viewZoneId(){return this._viewZoneInfo?.viewZoneId}constructor(e,t,i,n){super(),this._editor=e,this._lines=t,this._shouldKeepCursorStable=i,this._isClickable=n,this._viewZoneHeight=o.observableValue("viewZoneHeight",void 0),this.editorOptionsChanged=o.observableSignalFromEvent("editorOptionChanged",a.Event.filter(this._editor.onDidChangeConfiguration,s=>s.hasChanged(40)||s.hasChanged(133)||s.hasChanged(113)||s.hasChanged(108)||s.hasChanged(60)||s.hasChanged(59)||s.hasChanged(75)||s.hasChanged(176))),this._onDidClick=this._register(new a.Emitter),this.onDidClick=this._onDidClick.event,this._viewZoneListener=this._register(new a.MutableDisposable),this.isHovered=o.observableCodeEditor(this._editor).isTargetHovered(s=>$v(s.target.element),this._store),this.hasBeenAccepted=!1,this._editor instanceof o.CodeEditorWidget&&this._shouldKeepCursorStable&&this._register(this._editor.onBeforeExecuteEdit(s=>this.hasBeenAccepted=s.source==="inlineCompletionAccept")),this._register(o.autorun(s=>{const r=this._lines.read(s);this.editorOptionsChanged.read(s),r?(this.hasBeenAccepted=!1,this.updateLines(r.lineNumber,r.additionalLines,r.minReservedLineCount)):this.clear()}))}dispose(){super.dispose(),this.clear()}clear(){this._viewZoneListener.clear(),this._editor.changeViewZones(e=>{this.removeActiveViewZone(e)})}updateLines(e,t,i){const n=this._editor.getModel();if(!n)return;const{tabSize:s}=n.getOptions();o.observableCodeEditor(this._editor).transaction(r=>{this._editor.changeViewZones(l=>{const d=new a.DisposableStore;this.removeActiveViewZone(l);const h=Math.max(t.length,i);if(h>0){const u=document.createElement("div");hD(u,s,t,this._editor.getOptions(),this._isClickable),this._isClickable&&(d.add(o.addDisposableListener(u,"mousedown",g=>{g.preventDefault()})),d.add(o.addDisposableListener(u,"click",g=>{$v(g.target)&&this._onDidClick.fire(new o.StandardMouseEvent(o.getWindow(g),g))}))),this.addViewZone(l,e,h,u)}this._viewZoneListener.value=d})})}addViewZone(e,t,i,n){const s=e.addZone({afterLineNumber:t,heightInLines:i,domNode:n,afterColumnAffinity:1,onComputedHeight:r=>{this._viewZoneHeight.set(r,void 0)}});this.keepCursorStable(t,i),this._viewZoneInfo={viewZoneId:s,heightInLines:i,lineNumber:t}}removeActiveViewZone(e){this._viewZoneInfo&&(e.removeZone(this._viewZoneInfo.viewZoneId),this.hasBeenAccepted||this.keepCursorStable(this._viewZoneInfo.lineNumber,-this._viewZoneInfo.heightInLines),this._viewZoneInfo=void 0,this._viewZoneHeight.set(void 0,void 0))}keepCursorStable(e,t){if(!this._shouldKeepCursorStable)return;const i=this._editor.getSelection()?.getStartPosition()?.lineNumber;i!==void 0&&e<i&&this._editor.setScrollTop(this._editor.getScrollTop()+t*this._editor.getOption(75))}}function $v(c){return o.isHTMLElement(c)&&c.classList.contains(Uv)}class dD{constructor(e,t){this.content=e,this.decorations=t}equals(e){return this.content.equals(e.content)?o.LineDecoration.equalsArr(this.decorations,e.decorations):!1}}function hD(c,e,t,i,n){const s=i.get(40),r=i.get(133),l="none",d=i.get(108),h=i.get(60),u=i.get(59),g=i.get(75),p=i.get(176)==="twoCells";let f="suggest-preview-text";n&&(f+=" clickable");const m=new o.StringBuilder(1e4);m.appendString(`<div class="${f}">`);for(let b=0,C=t.length;b<C;b++){const y=t[b],I=y.content;m.appendString('<div class="view-line'),m.appendString('" style="top:'),m.appendString(String(b*g)),m.appendString('px;width:1000000px;">');const x=I.getLineContent(),S=a.isBasicASCII(x),w=a.containsRTL(x);o.renderViewLine(new o.RenderLineInput(u.isMonospace&&!s,u.canUseHalfwidthRightwardsArrow,x,!1,S,w,0,I,y.decorations.slice(),e,0,u.spaceWidth,u.middotWidth,u.wsmiddotWidth,r,l,d,h!==o.EditorFontLigatures.OFF,null,null,0,!1,p),m),m.appendString("</div>")}m.appendString("</div>"),o.applyFontInfo(c,u);const _=m.build(),v=jv?jv.createHTML(_):_;c.innerHTML=v}const jv=o.createTrustedTypesPolicy("editorGhostText",{createHTML:c=>c});class gr{constructor(e,t){this.width=e,this.height=t}toString(){return`(${this.width},${this.height})`}transpose(){return new gr(this.height,this.width)}toDimension(){return{width:this.width,height:this.height}}}class k{static fromPoints(e,t){return new k(e.x,e.y,t.x,t.y)}static fromPointSize(e,t){return new k(e.x,e.y,e.x+t.x,e.y+t.y)}static fromLeftTopRightBottom(e,t,i,n){return new k(e,t,i,n)}static fromLeftTopWidthHeight(e,t,i,n){return new k(e,t,e+i,t+n)}static fromRanges(e,t){return new k(e.start,t.start,e.endExclusive,t.endExclusive)}static hull(e){let t=Number.MAX_SAFE_INTEGER,i=Number.MAX_SAFE_INTEGER,n=Number.MIN_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER;for(const r of e)t=Math.min(t,r.left),i=Math.min(i,r.top),n=Math.max(n,r.right),s=Math.max(s,r.bottom);return new k(t,i,n,s)}get width(){return this.right-this.left}get height(){return this.bottom-this.top}constructor(e,t,i,n){if(this.left=e,this.top=t,this.right=i,this.bottom=n,e>i)throw new a.BugIndicatingError("Invalid arguments: Horizontally offset by "+(e-i));if(t>n)throw new a.BugIndicatingError("Invalid arguments: Vertically offset by "+(t-n))}withMargin(e,t,i,n){let s,r,l,d;return t===void 0&&i===void 0&&n===void 0?s=r=l=d=e:i===void 0&&n===void 0?(s=r=t,l=d=e):(s=n,r=t,l=e,d=i),new k(this.left-s,this.top-l,this.right+r,this.bottom+d)}intersectVertical(e){const t=Math.max(this.top,e.start),i=Math.min(this.bottom,e.endExclusive);return new k(this.left,t,this.right,Math.max(t,i))}intersectHorizontal(e){const t=Math.max(this.left,e.start),i=Math.min(this.right,e.endExclusive);return new k(t,this.top,Math.max(t,i),this.bottom)}toString(){return`Rect{(${this.left},${this.top}), (${this.right},${this.bottom})}`}intersect(e){const t=Math.max(this.left,e.left),i=Math.min(this.right,e.right),n=Math.max(this.top,e.top),s=Math.min(this.bottom,e.bottom);if(!(t>i||n>s))return new k(t,n,i,s)}containsRect(e){return this.left<=e.left&&this.top<=e.top&&this.right>=e.right&&this.bottom>=e.bottom}containsPoint(e){return this.left<=e.x&&this.top<=e.y&&this.right>=e.x&&this.bottom>=e.y}moveToBeContainedIn(e){const t=this.width,i=this.height;let n=this.left,s=this.top;return n<e.left?n=e.left:n+t>e.right&&(n=e.right-t),s<e.top?s=e.top:s+i>e.bottom&&(s=e.bottom-i),new k(n,s,n+t,s+i)}withWidth(e){return new k(this.left,this.top,this.left+e,this.bottom)}withHeight(e){return new k(this.left,this.top,this.right,this.top+e)}withTop(e){return new k(this.left,e,this.right,this.bottom)}withLeft(e){return new k(e,this.top,this.right,this.bottom)}translateX(e){return new k(this.left+e,this.top,this.right+e,this.bottom)}translateY(e){return new k(this.left,this.top+e,this.right,this.bottom+e)}getLeftBottom(){return new o.Point(this.left,this.bottom)}getRightBottom(){return new o.Point(this.right,this.bottom)}getRightTop(){return new o.Point(this.right,this.top)}toStyles(){return{position:"absolute",left:`${this.left}px`,top:`${this.top}px`,width:`${this.width}px`,height:`${this.height}px`}}withHorizontalRange(e){return new k(e.start,this.top,e.endExclusive,this.bottom)}getSize(){return new gr(this.width,this.height)}}class pr{constructor(e,t,i,n=null){this.startLineNumbers=e,this.endLineNumbers=t,this.lastLineRelativePosition=i,this.showEndForLine=n}equals(e){return!!e&&this.lastLineRelativePosition===e.lastLineRelativePosition&&this.showEndForLine===e.showEndForLine&&a.equals(this.startLineNumbers,e.startLineNumbers)&&a.equals(this.endLineNumbers,e.endLineNumbers)}static get Empty(){return new pr([],[],0)}}const qv=o.createTrustedTypesPolicy("stickyScrollViewLayer",{createHTML:c=>c}),mg="data-sticky-line-index",Gv="data-sticky-is-line",uD="data-sticky-is-line-number",Zv="data-sticky-is-folding-icon";class gD extends a.Disposable{get height(){return this._height}constructor(e){super(),this._foldingIconStore=this._register(new a.DisposableStore),this._rootDomNode=document.createElement("div"),this._lineNumbersDomNode=document.createElement("div"),this._linesDomNodeScrollable=document.createElement("div"),this._linesDomNode=document.createElement("div"),this._renderedStickyLines=[],this._lineNumbers=[],this._lastLineRelativePosition=0,this._minContentWidthInPx=0,this._isOnGlyphMargin=!1,this._height=-1,this._onDidChangeStickyScrollHeight=this._register(new a.Emitter),this.onDidChangeStickyScrollHeight=this._onDidChangeStickyScrollHeight.event,this._editor=e,this._lineNumbersDomNode.className="sticky-widget-line-numbers",this._lineNumbersDomNode.setAttribute("role","none"),this._linesDomNode.className="sticky-widget-lines",this._linesDomNode.setAttribute("role","list"),this._linesDomNodeScrollable.className="sticky-widget-lines-scrollable",this._linesDomNodeScrollable.appendChild(this._linesDomNode),this._rootDomNode.className="sticky-widget",this._rootDomNode.classList.toggle("peek",e instanceof ct),this._rootDomNode.appendChild(this._lineNumbersDomNode),this._rootDomNode.appendChild(this._linesDomNodeScrollable),this._setHeight(0);const t=()=>{this._linesDomNode.style.left=this._editor.getOption(131).scrollWithEditor?`-${this._editor.getScrollLeft()}px`:"0px"};this._register(this._editor.onDidChangeConfiguration(i=>{i.hasChanged(131)&&t()})),this._register(this._editor.onDidScrollChange(i=>{i.scrollLeftChanged&&t(),i.scrollWidthChanged&&this._updateWidgetWidth()})),this._register(this._editor.onDidChangeModel(()=>{t(),this._updateWidgetWidth()})),t(),this._register(this._editor.onDidLayoutChange(i=>{this._updateWidgetWidth()})),this._updateWidgetWidth()}get lineNumbers(){return this._lineNumbers}get lineNumberCount(){return this._lineNumbers.length}getRenderedStickyLine(e){return this._renderedStickyLines.find(t=>t.lineNumber===e)}getCurrentLines(){return this._lineNumbers}setState(e,t,i){const n=!this._state&&!e,s=this._state&&this._state.equals(e);if(i===void 0&&(n||s))return;const r=this._findRenderingData(e),l=this._lineNumbers;this._lineNumbers=r.lineNumbers,this._lastLineRelativePosition=r.lastLineRelativePosition;const d=this._findIndexToRebuildFrom(l,this._lineNumbers,i);this._renderRootNode(this._lineNumbers,this._lastLineRelativePosition,t,d),this._state=e}_findRenderingData(e){if(!e)return{lineNumbers:[],lastLineRelativePosition:0};const t=[...e.startLineNumbers];e.showEndForLine!==null&&(t[e.showEndForLine]=e.endLineNumbers[e.showEndForLine]);let i=0;for(let n=0;n<t.length;n++){const s=new a.Position(t[n],1),r=this._editor._getViewModel();r&&s.lineNumber<=r.getLineCount()&&(i+=this._editor.getLineHeightForPosition(new a.Position(t[n],1)))}return i===0?{lineNumbers:[],lastLineRelativePosition:0}:{lineNumbers:t,lastLineRelativePosition:e.lastLineRelativePosition}}_findIndexToRebuildFrom(e,t,i){if(t.length===0)return 0;if(i!==void 0)return i;const n=t.findIndex(s=>!e.includes(s));return n===-1?0:n}_updateWidgetWidth(){const e=this._editor.getLayoutInfo(),t=e.contentLeft;this._lineNumbersDomNode.style.width=`${t}px`,this._linesDomNodeScrollable.style.setProperty("--vscode-editorStickyScroll-scrollableWidth",`${this._editor.getScrollWidth()-e.verticalScrollbarWidth}px`),this._rootDomNode.style.width=`${e.width-e.verticalScrollbarWidth}px`}_useFoldingOpacityTransition(e){this._lineNumbersDomNode.style.setProperty("--vscode-editorStickyScroll-foldingOpacityTransition",`opacity ${e?.5:0}s`)}_setFoldingIconsVisibility(e){for(const t of this._renderedStickyLines){const i=t.foldingIcon;i&&i.setVisible(e?!0:i.isCollapsed)}}async _renderRootNode(e,t,i,n){const s=this._editor._getViewModel();if(!s){this._clearWidget();return}if(e.length===0){this._clearWidget();return}const r=[],l=e[e.length-1];let d=0;for(let u=0;u<this._renderedStickyLines.length;u++)if(u<n){const g=this._renderedStickyLines[u];r.push(this._updatePosition(g,d,g.lineNumber===l)),d+=g.height}else{const g=this._renderedStickyLines[u];g.lineNumberDomNode.remove(),g.lineDomNode.remove()}const h=this._editor.getLayoutInfo();for(let u=n;u<e.length;u++){const g=e[u];if(g>s.getLineCount())continue;const p=this._renderChildNode(s,u,g,d,l===g,i,h);d+=p.height,this._linesDomNode.appendChild(p.lineDomNode),this._lineNumbersDomNode.appendChild(p.lineNumberDomNode),r.push(p)}i&&(this._setFoldingHoverListeners(),this._useFoldingOpacityTransition(!this._isOnGlyphMargin)),this._minContentWidthInPx=Math.max(...this._renderedStickyLines.map(u=>u.scrollWidth))+h.verticalScrollbarWidth,this._renderedStickyLines=r,this._setHeight(d+t),this._editor.layoutOverlayWidget(this)}_clearWidget(){for(let e=0;e<this._renderedStickyLines.length;e++){const t=this._renderedStickyLines[e];t.lineNumberDomNode.remove(),t.lineDomNode.remove()}this._setHeight(0)}_setHeight(e){this._height!==e&&(this._height=e,this._height===0?this._rootDomNode.style.display="none":(this._rootDomNode.style.display="block",this._lineNumbersDomNode.style.height=`${this._height}px`,this._linesDomNodeScrollable.style.height=`${this._height}px`,this._rootDomNode.style.height=`${this._height}px`),this._onDidChangeStickyScrollHeight.fire({height:this._height}))}_setFoldingHoverListeners(){this._foldingIconStore.clear(),this._editor.getOption(126)==="mouseover"&&(this._foldingIconStore.clear(),this._foldingIconStore.add(o.addDisposableListener(this._lineNumbersDomNode,o.EventType.MOUSE_ENTER,()=>{this._isOnGlyphMargin=!0,this._setFoldingIconsVisibility(!0)})),this._foldingIconStore.add(o.addDisposableListener(this._lineNumbersDomNode,o.EventType.MOUSE_LEAVE,()=>{this._isOnGlyphMargin=!1,this._useFoldingOpacityTransition(!0),this._setFoldingIconsVisibility(!1)})))}_renderChildNode(e,t,i,n,s,r,l){const d=new pD(this._editor,e,l,r,this._isOnGlyphMargin,t,i);return this._updatePosition(d,n,s)}_updatePosition(e,t,i){const n=e.lineDomNode,s=e.lineNumberDomNode;if(i){n.style.zIndex="0",s.style.zIndex="0";const l=`${t+this._lastLineRelativePosition+(e.foldingIcon?.isCollapsed?1:0)}px`;n.style.top=l,s.style.top=l}else n.style.zIndex="1",s.style.zIndex="1",n.style.top=`${t}px`,s.style.top=`${t}px`;return e}getId(){return"editor.contrib.stickyScrollWidget"}getDomNode(){return this._rootDomNode}getPosition(){return{preference:2,stackOrdinal:10}}getMinContentWidthInPx(){return this._minContentWidthInPx}focusLineWithIndex(e){0<=e&&e<this._renderedStickyLines.length&&this._renderedStickyLines[e].lineDomNode.focus()}getEditorPositionFromNode(e){if(!e||e.children.length>0)return null;const t=this._getRenderedStickyLineFromChildDomNode(e);if(!t)return null;const i=o.getColumnOfNodeOffset(t.characterMapping,e,0);return new a.Position(t.lineNumber,i)}getLineNumberFromChildDomNode(e){return this._getRenderedStickyLineFromChildDomNode(e)?.lineNumber??null}_getRenderedStickyLineFromChildDomNode(e){const t=this.getLineIndexFromChildDomNode(e);return t===null||t<0||t>=this._renderedStickyLines.length?null:this._renderedStickyLines[t]}getLineIndexFromChildDomNode(e){const t=this._getAttributeValue(e,mg);return t?parseInt(t,10):null}isInStickyLine(e){return this._getAttributeValue(e,Gv)!==void 0}isInFoldingIconDomNode(e){return this._getAttributeValue(e,Zv)!==void 0}_getAttributeValue(e,t){for(;e&&e!==this._rootDomNode;){const i=e.getAttribute(t);if(i!==null)return i;e=e.parentElement}}}class pD{constructor(e,t,i,n,s,r,l){this.index=r,this.lineNumber=l;const d=t.coordinatesConverter.convertModelPositionToViewPosition(new a.Position(l,1)).lineNumber,h=t.getViewLineRenderingData(d),u=e.getOption(76),g=e.getOption(117).verticalScrollbarSize;let p;try{p=o.LineDecoration.filter(h.inlineDecorations,d,h.minColumn,h.maxColumn)}catch{p=[]}const f=e.getLineHeightForPosition(new a.Position(l,1)),m=t.getTextDirection(l),_=e.getOption(59),v=new o.RenderLineInput(!0,!0,h.content,h.continuesWithWrappedLine,h.isBasicASCII,h.containsRTL,0,h.tokens,p,h.tabSize,h.startVisibleColumn,_.spaceWidth,1,1,500,"none",!0,!0,null,m,g,!1,e.getOption(176)==="twoCells"),b=new o.StringBuilder(2e3),C=o.renderViewLine(v,b);this.characterMapping=C.characterMapping;let y;qv?y=qv.createHTML(b.build()):y=b.build();const I=document.createElement("span");I.setAttribute(mg,String(r)),I.setAttribute(Gv,""),I.setAttribute("role","listitem"),I.tabIndex=0,I.className="sticky-line-content",I.classList.add(`stickyLine${l}`),I.style.lineHeight=`${f}px`,I.innerHTML=y;const x=document.createElement("span");x.setAttribute(mg,String(r)),x.setAttribute(uD,""),x.className="sticky-line-number",x.style.lineHeight=`${f}px`;const S=i.contentLeft;x.style.width=`${S}px`;const w=document.createElement("span");u.renderType===1||u.renderType===3&&l%10===0?w.innerText=l.toString():u.renderType===2&&(w.innerText=Math.abs(l-e.getPosition().lineNumber).toString()),w.className="sticky-line-number-inner",w.style.width=`${i.lineNumbersWidth}px`,w.style.paddingLeft=`${i.lineNumbersLeft}px`,x.appendChild(w),this.foldingIcon=this._renderFoldingIconForLine(e,n,l,f,s),this.foldingIcon&&(x.appendChild(this.foldingIcon.domNode),this.foldingIcon.domNode.style.left=`${i.lineNumbersWidth+i.lineNumbersLeft}px`,this.foldingIcon.domNode.style.lineHeight=`${f}px`),e.applyFontInfo(I),e.applyFontInfo(x),x.style.lineHeight=`${f}px`,I.style.lineHeight=`${f}px`,x.style.height=`${f}px`,I.style.height=`${f}px`,this.scrollWidth=I.scrollWidth,this.lineDomNode=I,this.lineNumberDomNode=x,this.height=f}_renderFoldingIconForLine(e,t,i,n,s){const r=e.getOption(126);if(!t||r==="never")return;const l=t.regions,d=l.findRange(i),h=l.getStartLineNumber(d);if(!(i===h))return;const g=l.isCollapsed(d),p=new fD(g,h,l.getEndLineNumber(d),n);return p.setVisible(s?!0:g||r==="always"),p.domNode.setAttribute(Zv,""),p}}class fD{constructor(e,t,i,n){this.isCollapsed=e,this.foldingStartLine=t,this.foldingEndLine=i,this.dimension=n,this.domNode=document.createElement("div"),this.domNode.style.width="26px",this.domNode.style.height=`${n}px`,this.domNode.style.lineHeight=`${n}px`,this.domNode.className=o.ThemeIcon.asClassName(e?ka:Ka)}setVisible(e){this.domNode.style.cursor=e?"pointer":"default",this.domNode.style.opacity=e?"1":"0"}}class fr{constructor(e,t){this.startLineNumber=e,this.endLineNumber=t}}class Pl{constructor(e,t,i){this.range=e,this.children=t,this.parent=i}}class Xv{constructor(e,t,i,n){this.uri=e,this.version=t,this.element=i,this.outlineProviderId=n}}var Ol=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},mr=function(c,e){return function(t,i){e(t,i,c)}},_r;(function(c){c.OUTLINE_MODEL="outlineModel",c.FOLDING_PROVIDER_MODEL="foldingProviderModel",c.INDENTATION_MODEL="indentationModel"})(_r||(_r={}));var ti;(function(c){c[c.VALID=0]="VALID",c[c.INVALID=1]="INVALID",c[c.CANCELED=2]="CANCELED"})(ti||(ti={}));let _g=class extends a.Disposable{constructor(e,t,i,n){switch(super(),this._editor=e,this._modelProviders=[],this._modelPromise=null,this._updateScheduler=this._register(new a.Delayer(300)),this._updateOperation=this._register(new a.DisposableStore),this._editor.getOption(131).defaultModel){case _r.OUTLINE_MODEL:this._modelProviders.push(new vg(this._editor,n));case _r.FOLDING_PROVIDER_MODEL:this._modelProviders.push(new Cg(this._editor,t,n));case _r.INDENTATION_MODEL:this._modelProviders.push(new bg(this._editor,i));break}}dispose(){this._modelProviders.forEach(e=>e.dispose()),this._updateOperation.clear(),this._cancelModelPromise(),super.dispose()}_cancelModelPromise(){this._modelPromise&&(this._modelPromise.cancel(),this._modelPromise=null)}async update(e){return this._updateOperation.clear(),this._updateOperation.add({dispose:()=>{this._cancelModelPromise(),this._updateScheduler.cancel()}}),this._cancelModelPromise(),await this._updateScheduler.trigger(async()=>{for(const t of this._modelProviders){const{statusPromise:i,modelPromise:n}=t.computeStickyModel(e);this._modelPromise=n;const s=await i;if(this._modelPromise!==n)return null;switch(s){case ti.CANCELED:return this._updateOperation.clear(),null;case ti.VALID:return t.stickyModel}}return null}).catch(t=>(a.onUnexpectedError(t),null))}};_g=Ol([mr(2,o.IInstantiationService),mr(3,o.ILanguageFeaturesService)],_g);class Yv extends a.Disposable{constructor(e){super(),this._editor=e,this._stickyModel=null}get stickyModel(){return this._stickyModel}_invalid(){return this._stickyModel=null,ti.INVALID}computeStickyModel(e){if(e.isCancellationRequested||!this.isProviderValid())return{statusPromise:this._invalid(),modelPromise:null};const t=a.createCancelablePromise(i=>this.createModelFromProvider(i));return{statusPromise:t.then(i=>this.isModelValid(i)?e.isCancellationRequested?ti.CANCELED:(this._stickyModel=this.createStickyModel(e,i),ti.VALID):this._invalid()).then(void 0,i=>(a.onUnexpectedError(i),ti.CANCELED)),modelPromise:t}}isModelValid(e){return!0}isProviderValid(){return!0}}let vg=class extends Yv{constructor(e,t){super(e),this._languageFeaturesService=t}createModelFromProvider(e){return Nt.create(this._languageFeaturesService.documentSymbolProvider,this._editor.getModel(),e)}createStickyModel(e,t){const{stickyOutlineElement:i,providerID:n}=this._stickyModelFromOutlineModel(t,this._stickyModel?.outlineProviderId),s=this._editor.getModel();return new Xv(s.uri,s.getVersionId(),i,n)}isModelValid(e){return e&&e.children.size>0}_stickyModelFromOutlineModel(e,t){let i;if(a.Iterable.first(e.children.values())instanceof V_){const l=a.Iterable.find(e.children.values(),d=>d.id===t);if(l)i=l.children;else{let d="",h=-1,u;for(const[g,p]of e.children.entries()){const f=this._findSumOfRangesOfGroup(p);f>h&&(u=p,h=f,d=p.id)}t=d,i=u.children}}else i=e.children;const n=[],s=Array.from(i.values()).sort((l,d)=>{const h=new fr(l.symbol.range.startLineNumber,l.symbol.range.endLineNumber),u=new fr(d.symbol.range.startLineNumber,d.symbol.range.endLineNumber);return this._comparator(h,u)});for(const l of s)n.push(this._stickyModelFromOutlineElement(l,l.symbol.selectionRange.startLineNumber));return{stickyOutlineElement:new Pl(void 0,n,void 0),providerID:t}}_stickyModelFromOutlineElement(e,t){const i=[];for(const s of e.children.values())if(s.symbol.selectionRange.startLineNumber!==s.symbol.range.endLineNumber)if(s.symbol.selectionRange.startLineNumber!==t)i.push(this._stickyModelFromOutlineElement(s,s.symbol.selectionRange.startLineNumber));else for(const r of s.children.values())i.push(this._stickyModelFromOutlineElement(r,s.symbol.selectionRange.startLineNumber));i.sort((s,r)=>this._comparator(s.range,r.range));const n=new fr(e.symbol.selectionRange.startLineNumber,e.symbol.range.endLineNumber);return new Pl(n,i,void 0)}_comparator(e,t){return e.startLineNumber!==t.startLineNumber?e.startLineNumber-t.startLineNumber:t.endLineNumber-e.endLineNumber}_findSumOfRangesOfGroup(e){let t=0;for(const i of e.children.values())t+=this._findSumOfRangesOfGroup(i);return e instanceof Su?t+e.symbol.range.endLineNumber-e.symbol.selectionRange.startLineNumber:t}};vg=Ol([mr(1,o.ILanguageFeaturesService)],vg);class Qv extends Yv{constructor(e){super(e),this._foldingLimitReporter=this._register(new A_(e))}createStickyModel(e,t){const i=this._fromFoldingRegions(t),n=this._editor.getModel();return new Xv(n.uri,n.getVersionId(),i,void 0)}isModelValid(e){return e!==null}_fromFoldingRegions(e){const t=e.length,i=[],n=new Pl(void 0,[],void 0);for(let s=0;s<t;s++){const r=e.getParentIndex(s);let l;r!==-1?l=i[r]:l=n;const d=new Pl(new fr(e.getStartLineNumber(s),e.getEndLineNumber(s)+1),[],l);l.children.push(d),i.push(d)}return n}}let bg=class extends Qv{constructor(e,t){super(e),this._languageConfigurationService=t,this.provider=this._register(new mu(e.getModel(),this._languageConfigurationService,this._foldingLimitReporter))}async createModelFromProvider(e){return this.provider.compute(e)}};bg=Ol([mr(1,o.ILanguageConfigurationService)],bg);let Cg=class extends Qv{constructor(e,t,i){super(e),this._languageFeaturesService=i,this.provider=this._register(new a.MutableDisposable),this._register(this._languageFeaturesService.foldingRangeProvider.onDidChange(()=>{this._updateProvider(e,t)})),this._updateProvider(e,t)}_updateProvider(e,t){const i=Xt.getFoldingRangeProviders(this._languageFeaturesService,e.getModel());i.length!==0&&(this.provider.value=new bu(e.getModel(),i,t,this._foldingLimitReporter,void 0))}isProviderValid(){return this.provider!==void 0}async createModelFromProvider(e){return this.provider.value?.compute(e)??null}};Cg=Ol([mr(2,o.ILanguageFeaturesService)],Cg);var mD=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Jv=function(c,e){return function(t,i){e(t,i,c)}};class _D{constructor(e,t,i,n){this.startLineNumber=e,this.endLineNumber=t,this.top=i,this.height=n}}let Sg=class extends a.Disposable{constructor(e,t,i){super(),this._languageFeaturesService=t,this._languageConfigurationService=i,this._onDidChangeStickyScroll=this._register(new a.Emitter),this.onDidChangeStickyScroll=this._onDidChangeStickyScroll.event,this._model=null,this._cts=null,this._stickyModelProvider=null,this._editor=e,this._sessionStore=this._register(new a.DisposableStore),this._updateSoon=this._register(new a.RunOnceScheduler(()=>this.update(),50)),this._register(this._editor.onDidChangeConfiguration(n=>{n.hasChanged(131)&&this.readConfiguration()})),this.readConfiguration()}readConfiguration(){this._sessionStore.clear(),this._editor.getOption(131).enabled&&(this._sessionStore.add(this._editor.onDidChangeModel(()=>{this._model=null,this.updateStickyModelProvider(),this._onDidChangeStickyScroll.fire(),this.update()})),this._sessionStore.add(this._editor.onDidChangeHiddenAreas(()=>this.update())),this._sessionStore.add(this._editor.onDidChangeModelContent(()=>this._updateSoon.schedule())),this._sessionStore.add(this._languageFeaturesService.documentSymbolProvider.onDidChange(()=>this.update())),this._sessionStore.add(a.toDisposable(()=>{this._stickyModelProvider?.dispose(),this._stickyModelProvider=null})),this.updateStickyModelProvider(),this.update())}getVersionId(){return this._model?.version}updateStickyModelProvider(){this._stickyModelProvider?.dispose(),this._stickyModelProvider=null,this._editor.hasModel()&&(this._stickyModelProvider=new _g(this._editor,()=>this._updateSoon.schedule(),this._languageConfigurationService,this._languageFeaturesService))}async update(){this._cts?.dispose(!0),this._cts=new a.CancellationTokenSource,await this.updateStickyModel(this._cts.token),this._onDidChangeStickyScroll.fire()}async updateStickyModel(e){if(!this._editor.hasModel()||!this._stickyModelProvider||this._editor.getModel().isTooLargeForTokenization()){this._model=null;return}const t=await this._stickyModelProvider.update(e);e.isCancellationRequested||(this._model=t)}getCandidateStickyLinesIntersecting(e){if(!this._model?.element)return[];const t=[];return this.getCandidateStickyLinesIntersectingFromStickyModel(e,this._model.element,t,0,0,-1),this.filterHiddenRanges(t)}getCandidateStickyLinesIntersectingFromStickyModel(e,t,i,n,s,r){const l=this._editor.getModel();if(!l||t.children.length===0)return;let d=r;const h=[];for(let p=0;p<t.children.length;p++){const f=t.children[p];f.range&&h.push(f.range.startLineNumber)}const u=this.updateIndex(a.binarySearch(h,e.startLineNumber,(p,f)=>p-f)),g=this.updateIndex(a.binarySearch(h,e.endLineNumber,(p,f)=>p-f));for(let p=u;p<=g;p++){const f=t.children[p];if(!f||!f.range)continue;const{startLineNumber:m,endLineNumber:_}=f.range;if(_>m+1&&e.startLineNumber<=_+1&&m-1<=e.endLineNumber&&m!==d&&l.isValidRange(new a.Range(m,1,_,1))){d=m;const v=this._editor.getLineHeightForPosition(new a.Position(m,1));i.push(new _D(m,_-1,s,v)),this.getCandidateStickyLinesIntersectingFromStickyModel(e,f,i,n+1,s+v,m)}}}filterHiddenRanges(e){const t=this._editor._getViewModel()?.getHiddenAreas();return t?e.filter(i=>!t.some(n=>i.startLineNumber>=n.startLineNumber&&i.endLineNumber<=n.endLineNumber+1)):e}updateIndex(e){return e===-1?0:e<0?-e-2:e}};Sg=mD([Jv(1,o.ILanguageFeaturesService),Jv(2,o.ILanguageConfigurationService)],Sg);var vD=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Vs=function(c,e){return function(t,i){e(t,i,c)}},yg;let Be=(Zn=class extends a.Disposable{constructor(e,t,i,n,s,r,l){super(),this._editor=e,this._contextMenuService=t,this._languageFeaturesService=i,this._instaService=n,this._contextKeyService=l,this._sessionStore=new a.DisposableStore,this._maxStickyLines=Number.MAX_SAFE_INTEGER,this._candidateDefinitionsLength=-1,this._focusedStickyElementIndex=-1,this._enabled=!1,this._focused=!1,this._positionRevealed=!1,this._onMouseDown=!1,this._endLineNumbers=[],this._mouseTarget=null,this._onDidChangeStickyScrollHeight=this._register(new a.Emitter),this.onDidChangeStickyScrollHeight=this._onDidChangeStickyScrollHeight.event,this._stickyScrollWidget=new gD(this._editor),this._stickyLineCandidateProvider=new Sg(this._editor,i,s),this._register(this._stickyScrollWidget),this._register(this._stickyLineCandidateProvider),this._widgetState=pr.Empty;const d=this._stickyScrollWidget.getDomNode();this._register(this._editor.onDidChangeLineHeight(u=>{u.changes.forEach(g=>{const p=g.lineNumber;this._widgetState.startLineNumbers.includes(p)&&this._renderStickyScroll(p)})})),this._register(this._editor.onDidChangeFont(u=>{u.changes.forEach(g=>{const p=g.lineNumber;this._widgetState.startLineNumbers.includes(p)&&this._renderStickyScroll(p)})})),this._register(this._editor.onDidChangeConfiguration(u=>{this._readConfigurationChange(u)})),this._register(o.addDisposableListener(d,o.EventType.CONTEXT_MENU,async u=>{this._onContextMenu(o.getWindow(d),u)})),this._stickyScrollFocusedContextKey=o.EditorContextKeys.stickyScrollFocused.bindTo(this._contextKeyService),this._stickyScrollVisibleContextKey=o.EditorContextKeys.stickyScrollVisible.bindTo(this._contextKeyService);const h=this._register(o.trackFocus(d));this._register(h.onDidBlur(u=>{this._positionRevealed===!1&&d.clientHeight===0?(this._focusedStickyElementIndex=-1,this.focus()):this._disposeFocusStickyScrollStore()})),this._register(h.onDidFocus(u=>{this.focus()})),this._registerMouseListeners(),this._register(o.addDisposableListener(d,o.EventType.MOUSE_DOWN,u=>{this._onMouseDown=!0})),this._register(this._stickyScrollWidget.onDidChangeStickyScrollHeight(u=>{this._onDidChangeStickyScrollHeight.fire(u)})),this._onDidResize(),this._readConfiguration()}get stickyScrollWidgetHeight(){return this._stickyScrollWidget.height}static get(e){return e.getContribution(yg.ID)}_disposeFocusStickyScrollStore(){this._stickyScrollFocusedContextKey.set(!1),this._focusDisposableStore?.dispose(),this._focused=!1,this._positionRevealed=!1,this._onMouseDown=!1}isFocused(){return this._focused}focus(){if(this._onMouseDown){this._onMouseDown=!1,this._editor.focus();return}this._stickyScrollFocusedContextKey.get()!==!0&&(this._focused=!0,this._focusDisposableStore=new a.DisposableStore,this._stickyScrollFocusedContextKey.set(!0),this._focusedStickyElementIndex=this._stickyScrollWidget.lineNumbers.length-1,this._stickyScrollWidget.focusLineWithIndex(this._focusedStickyElementIndex))}focusNext(){this._focusedStickyElementIndex<this._stickyScrollWidget.lineNumberCount-1&&this._focusNav(!0)}focusPrevious(){this._focusedStickyElementIndex>0&&this._focusNav(!1)}selectEditor(){this._editor.focus()}_focusNav(e){this._focusedStickyElementIndex=e?this._focusedStickyElementIndex+1:this._focusedStickyElementIndex-1,this._stickyScrollWidget.focusLineWithIndex(this._focusedStickyElementIndex)}goToFocused(){const e=this._stickyScrollWidget.lineNumbers;this._disposeFocusStickyScrollStore(),this._revealPosition({lineNumber:e[this._focusedStickyElementIndex],column:1})}_revealPosition(e){this._reveaInEditor(e,()=>this._editor.revealPosition(e))}_revealLineInCenterIfOutsideViewport(e){this._reveaInEditor(e,()=>this._editor.revealLineInCenterIfOutsideViewport(e.lineNumber,0))}_reveaInEditor(e,t){this._focused&&this._disposeFocusStickyScrollStore(),this._positionRevealed=!0,t(),this._editor.setSelection(a.Range.fromPositions(e)),this._editor.focus()}_registerMouseListeners(){const e=this._register(new a.DisposableStore),t=this._register(new wa(this._editor,{extractLineNumberFromMouseEvent:s=>{const r=this._stickyScrollWidget.getEditorPositionFromNode(s.target.element);return r?r.lineNumber:0}})),i=s=>{if(!this._editor.hasModel()||s.target.type!==12||s.target.detail!==this._stickyScrollWidget.getId())return null;const r=s.target.element;if(!r||r.innerText!==r.innerHTML)return null;const l=this._stickyScrollWidget.getEditorPositionFromNode(r);return l?{range:new a.Range(l.lineNumber,l.column,l.lineNumber,l.column+r.innerText.length),textElement:r}:null},n=this._stickyScrollWidget.getDomNode();this._register(o.addStandardDisposableListener(n,o.EventType.CLICK,s=>{if(s.ctrlKey||s.altKey||s.metaKey||!s.leftButton)return;if(s.shiftKey){const h=this._stickyScrollWidget.getLineIndexFromChildDomNode(s.target);if(h===null)return;const u=new a.Position(this._endLineNumbers[h],1);this._revealLineInCenterIfOutsideViewport(u);return}if(this._stickyScrollWidget.isInFoldingIconDomNode(s.target)){const h=this._stickyScrollWidget.getLineNumberFromChildDomNode(s.target);this._toggleFoldingRegionForLine(h);return}if(!this._stickyScrollWidget.isInStickyLine(s.target))return;let d=this._stickyScrollWidget.getEditorPositionFromNode(s.target);if(!d){const h=this._stickyScrollWidget.getLineNumberFromChildDomNode(s.target);if(h===null)return;d=new a.Position(h,1)}this._revealPosition(d)})),this._register(o.addDisposableListener(o.mainWindow,o.EventType.MOUSE_MOVE,s=>{this._mouseTarget=s.target,this._onMouseMoveOrKeyDown(s)})),this._register(o.addDisposableListener(o.mainWindow,o.EventType.KEY_DOWN,s=>{this._onMouseMoveOrKeyDown(s)})),this._register(o.addDisposableListener(o.mainWindow,o.EventType.KEY_UP,()=>{this._showEndForLine!==void 0&&(this._showEndForLine=void 0,this._renderStickyScroll())})),this._register(t.onMouseMoveOrRelevantKeyDown(([s,r])=>{const l=i(s);if(!l||!s.hasTriggerModifier||!this._editor.hasModel()){e.clear();return}const{range:d,textElement:h}=l;if(!d.equalsRange(this._stickyRangeProjectedOnEditor))this._stickyRangeProjectedOnEditor=d,e.clear();else if(h.style.textDecoration==="underline")return;const u=new a.CancellationTokenSource;e.add(a.toDisposable(()=>u.dispose(!0)));let g;Fo(this._languageFeaturesService.definitionProvider,this._editor.getModel(),new a.Position(d.startLineNumber,d.startColumn+1),!1,u.token).then((p=>{if(!u.token.isCancellationRequested)if(p.length!==0){this._candidateDefinitionsLength=p.length;const f=h;g!==f?(e.clear(),g=f,g.style.textDecoration="underline",e.add(a.toDisposable(()=>{g.style.textDecoration="none"}))):g||(g=f,g.style.textDecoration="underline",e.add(a.toDisposable(()=>{g.style.textDecoration="none"})))}else e.clear()}))})),this._register(t.onCancel(()=>{e.clear()})),this._register(t.onExecute(async s=>{if(s.target.type!==12||s.target.detail!==this._stickyScrollWidget.getId())return;const r=this._stickyScrollWidget.getEditorPositionFromNode(s.target.element);r&&(!this._editor.hasModel()||!this._stickyRangeProjectedOnEditor||(this._candidateDefinitionsLength>1&&(this._focused&&this._disposeFocusStickyScrollStore(),this._revealPosition({lineNumber:r.lineNumber,column:1})),this._instaService.invokeFunction(f_,s,this._editor,{uri:this._editor.getModel().uri,range:this._stickyRangeProjectedOnEditor})))}))}_onContextMenu(e,t){const i=new o.StandardMouseEvent(e,t);this._contextMenuService.showContextMenu({menuId:o.MenuId.StickyScrollContext,getAnchor:()=>i,menuActionOptions:{renderShortTitle:!0}})}_onMouseMoveOrKeyDown(e){if(!e.shiftKey||!this._mouseTarget||!o.isHTMLElement(this._mouseTarget))return;const t=this._stickyScrollWidget.getLineIndexFromChildDomNode(this._mouseTarget);t===null||this._showEndForLine===t||(this._showEndForLine=t,this._renderStickyScroll())}_toggleFoldingRegionForLine(e){if(!this._foldingModel||e===null)return;const t=this._stickyScrollWidget.getRenderedStickyLine(e),i=t?.foldingIcon;if(!i)return;gu(this._foldingModel,1,[e]),i.isCollapsed=!i.isCollapsed;const n=(i.isCollapsed?this._editor.getTopForLineNumber(i.foldingEndLine):this._editor.getTopForLineNumber(i.foldingStartLine))-this._editor.getOption(75)*t.index+1;this._editor.setScrollTop(n),this._renderStickyScroll(e)}_readConfiguration(){const e=this._editor.getOption(131);if(e.enabled===!1){this._editor.removeOverlayWidget(this._stickyScrollWidget),this._resetState(),this._sessionStore.clear(),this._enabled=!1;return}else e.enabled&&!this._enabled&&(this._editor.addOverlayWidget(this._stickyScrollWidget),this._sessionStore.add(this._editor.onDidScrollChange(i=>{i.scrollTopChanged&&(this._showEndForLine=void 0,this._renderStickyScroll())})),this._sessionStore.add(this._editor.onDidLayoutChange(()=>this._onDidResize())),this._sessionStore.add(this._editor.onDidChangeModelTokens(i=>this._onTokensChange(i))),this._sessionStore.add(this._stickyLineCandidateProvider.onDidChangeStickyScroll(()=>{this._showEndForLine=void 0,this._renderStickyScroll()})),this._enabled=!0);this._editor.getOption(76).renderType===2?this._cursorPositionListener||(this._cursorPositionListener=this._editor.onDidChangeCursorPosition(i=>{this._positionLineNumber!==i.position.lineNumber&&(this._positionLineNumber=i.position.lineNumber,this._showEndForLine=void 0,this._renderStickyScroll(0))}),this._sessionStore.add(this._cursorPositionListener)):this._cursorPositionListener&&(this._sessionStore.delete(this._cursorPositionListener),this._cursorPositionListener.dispose(),this._cursorPositionListener=void 0)}_readConfigurationChange(e){(e.hasChanged(131)||e.hasChanged(81)||e.hasChanged(75)||e.hasChanged(126)||e.hasChanged(76))&&this._readConfiguration(),(e.hasChanged(76)||e.hasChanged(52)||e.hasChanged(126)||e.hasChanged(59)||e.hasChanged(176))&&this._renderStickyScroll(0)}_needsUpdate(e){const t=this._stickyScrollWidget.getCurrentLines();for(const i of t)for(const n of e.ranges)if(i>=n.fromLineNumber&&i<=n.toLineNumber)return!0;return!1}_onTokensChange(e){this._needsUpdate(e)&&this._renderStickyScroll(0)}_onDidResize(){const t=this._editor.getLayoutInfo().height/this._editor.getOption(75);this._maxStickyLines=Math.round(t*.25),this._renderStickyScroll(0)}async _renderStickyScroll(e){const t=this._editor.getModel();if(!t||t.isTooLargeForTokenization()){this._resetState();return}const i=this._updateAndGetMinRebuildFromLine(e),n=this._stickyLineCandidateProvider.getVersionId();if(n===void 0||n===t.getVersionId())if(!this._focused)await this._updateState(i);else if(this._focusedStickyElementIndex===-1)await this._updateState(i),this._focusedStickyElementIndex=this._stickyScrollWidget.lineNumberCount-1,this._focusedStickyElementIndex!==-1&&this._stickyScrollWidget.focusLineWithIndex(this._focusedStickyElementIndex);else{const r=this._stickyScrollWidget.lineNumbers[this._focusedStickyElementIndex];await this._updateState(i),this._stickyScrollWidget.lineNumberCount===0?this._focusedStickyElementIndex=-1:(this._stickyScrollWidget.lineNumbers.includes(r)||(this._focusedStickyElementIndex=this._stickyScrollWidget.lineNumberCount-1),this._stickyScrollWidget.focusLineWithIndex(this._focusedStickyElementIndex))}}_updateAndGetMinRebuildFromLine(e){if(e!==void 0){const t=this._minRebuildFromLine!==void 0?this._minRebuildFromLine:1/0;this._minRebuildFromLine=Math.min(e,t)}return this._minRebuildFromLine}async _updateState(e){this._minRebuildFromLine=void 0,this._foldingModel=await Xt.get(this._editor)?.getFoldingModel()??void 0,this._widgetState=this.findScrollWidgetState();const t=this._widgetState.startLineNumbers.length>0;this._stickyScrollVisibleContextKey.set(t),this._stickyScrollWidget.setState(this._widgetState,this._foldingModel,e)}async _resetState(){this._minRebuildFromLine=void 0,this._foldingModel=void 0,this._widgetState=pr.Empty,this._stickyScrollVisibleContextKey.set(!1),this._stickyScrollWidget.setState(void 0,void 0)}findScrollWidgetState(){const e=Math.min(this._maxStickyLines,this._editor.getOption(131).maxLineCount),t=this._editor.getScrollTop();let i=0;const n=[],s=[],r=this._editor.getVisibleRanges();if(r.length!==0){const l=new fr(r[0].startLineNumber,r[r.length-1].endLineNumber),d=this._stickyLineCandidateProvider.getCandidateStickyLinesIntersecting(l);for(const h of d){const u=h.startLineNumber,g=h.endLineNumber,p=h.top,f=p+h.height,m=this._editor.getTopForLineNumber(u)-t,_=this._editor.getBottomForLineNumber(g)-t;if(p>m&&p<=_&&(n.push(u),s.push(g+1),f>_&&(i=_-f)),n.length===e)break}}return this._endLineNumbers=s,new pr(n,s,i,this._showEndForLine)}dispose(){super.dispose(),this._sessionStore.dispose()}},yg=Zn,Zn.ID="store.contrib.stickyScrollController",Zn);Be=yg=vD([Vs(1,o.IContextMenuService),Vs(2,o.ILanguageFeaturesService),Vs(3,o.IInstantiationService),Vs(4,o.ILanguageConfigurationService),Vs(5,o.ILanguageFeatureDebounceService),Vs(6,o.IContextKeyService)],Be);const vr=o.registerColor("inlineEdit.originalBackground",o.transparent(o.diffRemoved,.2),a.localize(1286,"Background color for the original text in inline edits."),!0),Wv=o.registerColor("inlineEdit.modifiedBackground",o.transparent(o.diffInserted,.3),a.localize(1287,"Background color for the modified text in inline edits."),!0);o.registerColor("inlineEdit.originalChangedLineBackground",o.transparent(o.diffRemoved,.8),a.localize(1288,"Background color for the changed lines in the original text of inline edits."),!0);const bD=o.registerColor("inlineEdit.originalChangedTextBackground",o.transparent(o.diffRemoved,.8),a.localize(1289,"Overlay color for the changed text in the original text of inline edits."),!0),CD=o.registerColor("inlineEdit.modifiedChangedLineBackground",{light:o.transparent(o.diffInsertedLine,.7),dark:o.transparent(o.diffInsertedLine,.7),hcDark:o.diffInsertedLine,hcLight:o.diffInsertedLine},a.localize(1290,"Background color for the changed lines in the modified text of inline edits."),!0),SD=o.registerColor("inlineEdit.modifiedChangedTextBackground",o.transparent(o.diffInserted,.7),a.localize(1291,"Overlay color for the changed text in the modified text of inline edits."),!0),br=o.registerColor("inlineEdit.gutterIndicator.primaryForeground",o.buttonForeground,a.localize(1292,"Foreground color for the primary inline edit gutter indicator.")),ii=o.registerColor("inlineEdit.gutterIndicator.primaryBorder",o.buttonBackground,a.localize(1293,"Border color for the primary inline edit gutter indicator.")),Cr=o.registerColor("inlineEdit.gutterIndicator.primaryBackground",{light:o.transparent(ii,.5),dark:o.transparent(ii,.4),hcDark:o.transparent(ii,.4),hcLight:o.transparent(ii,.5)},a.localize(1294,"Background color for the primary inline edit gutter indicator.")),yD=o.registerColor("inlineEdit.gutterIndicator.secondaryForeground",o.editorHoverForeground,a.localize(1295,"Foreground color for the secondary inline edit gutter indicator.")),wD=o.registerColor("inlineEdit.gutterIndicator.secondaryBorder",o.editorHoverBorder,a.localize(1296,"Border color for the secondary inline edit gutter indicator.")),wg=o.registerColor("inlineEdit.gutterIndicator.secondaryBackground",o.editorHoverBackground,a.localize(1297,"Background color for the secondary inline edit gutter indicator.")),ID=o.registerColor("inlineEdit.gutterIndicator.successfulForeground",o.buttonForeground,a.localize(1298,"Foreground color for the successful inline edit gutter indicator.")),Hv=o.registerColor("inlineEdit.gutterIndicator.successfulBorder",o.buttonBackground,a.localize(1299,"Border color for the successful inline edit gutter indicator.")),Ig=o.registerColor("inlineEdit.gutterIndicator.successfulBackground",Hv,a.localize(1300,"Background color for the successful inline edit gutter indicator.")),xD=o.registerColor("inlineEdit.gutterIndicator.background",{hcDark:o.transparent("tab.inactiveBackground",.5),hcLight:o.transparent("tab.inactiveBackground",.5),dark:o.transparent("tab.inactiveBackground",.5),light:"#5f5f5f18"},a.localize(1301,"Background color for the inline edit gutter indicator.")),Sr=o.registerColor("inlineEdit.originalBorder",{light:o.diffRemoved,dark:o.diffRemoved,hcDark:o.diffRemoved,hcLight:o.diffRemoved},a.localize(1302,"Border color for the original text in inline edits.")),yr=o.registerColor("inlineEdit.modifiedBorder",{light:o.darken(o.diffInserted,.6),dark:o.diffInserted,hcDark:o.diffInserted,hcLight:o.diffInserted},a.localize(1303,"Border color for the modified text in inline edits.")),ED=o.registerColor("inlineEdit.tabWillAcceptModifiedBorder",{light:o.darken(yr,0),dark:o.darken(yr,0),hcDark:o.darken(yr,0),hcLight:o.darken(yr,0)},a.localize(1304,"Modified border color for the inline edits widget when tab will accept it.")),LD=o.registerColor("inlineEdit.tabWillAcceptOriginalBorder",{light:o.darken(Sr,0),dark:o.darken(Sr,0),hcDark:o.darken(Sr,0),hcLight:o.darken(Sr,0)},a.localize(1305,"Original border color for the inline edits widget over the original text when tab will accept it."));function wr(c){return c.map(e=>e===H.Accept?ED:yr)}function Al(c){return c.map(e=>e===H.Accept?LD:Sr)}function de(c,e){let t;typeof c=="string"?t=Bs(c,e):t=c.map((n,s)=>Bs(n,e).read(s));const i=Bs(o.editorBackground,e);return t.map((n,s)=>n.makeOpaque(i.read(s)))}function ni(c){let e;switch(c){case te.TextEditor:e=o.editorBackground;break;case te.DiffEditor:e=o.editorBackground;break;case te.Notebook:e="notebook.cellEditorBackground";break;default:a.assertNever(c,"Not supported editor type yet")}return o.asCssVariable(e)}function Bs(c,e){return o.observableFromEventOpts({owner:{observeColor:c},equalsFn:(t,i)=>t.equals(i),debugName:()=>`observeColor(${c})`},e.onDidColorThemeChange,()=>{const t=e.getColorTheme().getColor(c);if(!t)throw new a.BugIndicatingError(`Missing color: ${c}`);return t})}const me=3;function At(c,e,t){const i=c.model.read(t);if(!i)return 0;let n=0;for(let r=e.startLineNumber;r<e.endLineNumberExclusive;r++){const l=c.getWidthOfLine(r,t);n=Math.max(n,l)}const s=e.mapToLineArray(r=>i.getLineContent(r));return n<5&&s.some(r=>r.length>0)&&i.uri.scheme!=="file"&&console.log("unexpected width"),n}function DD(c,e,t){o.observableSignalFromEvent(c,c.editor.onDidChangeLineHeight).read(t);const i=c.model.read(t);if(!i)throw new a.BugIndicatingError("Model is required");const n=[];for(let s=e.startLineNumber;s<e.endLineNumberExclusive;s++){let r=c.getWidthOfLine(s,t);if(r===-1){const d=i.getLineMaxColumn(s),h=c.editor.getOption(59).typicalHalfwidthCharacterWidth;r=d*h}const l=c.editor.getLineHeightForPosition(new a.Position(s,1));n.push(new gr(r,l))}return n}function RD(c,e,t){return c.layoutInfo.read(t),c.value.read(t),c.model.read(t)?(c.scrollTop.read(t),c.editor.getOffsetForColumn(e.lineNumber,e.column)):0}function xg(c,e,t,i,n=void 0){const s=i.getModel();if(!s)return{prefixTrim:0,prefixLeftOffset:0};const r=c.map(p=>p.isSingleLine()?p.startColumn-1:0),l=e.mapToLineArray(p=>o.indentOfLine(s.getLineContent(p))),d=t.filter(p=>p!=="").map(p=>o.indentOfLine(p)),h=Math.min(...r,...l,...d);let u;if(s.getLineIndentColumn(e.startLineNumber)>=h+1)o.observableCodeEditor(i).scrollTop.read(n),u=i.getOffsetForColumn(e.startLineNumber,h+1);else if(t.length>0)u=Eg(t[0].slice(0,h),i,s);else return{prefixTrim:0,prefixLeftOffset:0};return{prefixTrim:h,prefixLeftOffset:u}}function Eg(c,e,t){const i=e.getOption(59).typicalHalfwidthCharacterWidth,n=t.getOptions().tabSize*i,s=c.split(" ").length-1;return(c.length-s)*i+s*n}function Lg(c){const e=c.layoutInfoContentLeft,t=o.derived({name:"editor.validOverlay.width"},n=>{const s=c.layoutInfoMinimap.read(n).minimapLeft!==0,r=Math.max(0,c.layoutInfoWidth.read(n)-e.read(n));if(s){const l=c.layoutInfoMinimap.read(n).minimapWidth+c.layoutInfoVerticalScrollbarWidth.read(n);return Math.max(0,r-l)}return r}),i=o.derived({name:"editor.validOverlay.height"},n=>c.layoutInfoHeight.read(n)+c.contentHeight.read(n));return o.derived({name:"editor.validOverlay"},n=>k.fromLeftTopWidthHeight(e.read(n),0,t.read(n),i.read(n)))}function TD(c,e){const t=[];for(const i of c){const n=e.mapRange(i.modifiedRange);t.push(new a.RangeMapping(i.originalRange,n))}return t}function Fl(...c){return c.filter(e=>typeof e=="string").join(" ")}function ND(c,e){return new a.Range(e.lineNumber,e.column+c.start,e.lineNumber,e.column+c.endExclusive)}function MD(c,e){let t=0;e:for(let i=0,n=c.length;i<n;i++)switch(c.charCodeAt(i)){case 9:t+=e;break;case 32:t++;break;default:break e}return t-t%e}function PD(c,e,t){let i=e-e%t,n=0;for(;n<c.length&&i!==0;n++)switch(c.charCodeAt(n)){case 9:i-=t;break;case 32:i--;break;default:throw new a.BugIndicatingError("Unexpected character found while calculating indent length")}return n}function OD(c,e,t){const i=a.splitLines(c),n=[],s=a.findFirstMin(e.mapToLineArray(r=>MD(i[r-1],t)),a.numberComparator);return e.forEach(r=>{const l=PD(i[r-1],s,t);n.push(new a.TextReplacement(ND(new a.OffsetRange(0,l),new a.Position(r,1)),""))}),new a.TextEdit(n)}class Dg{constructor(){this._data=""}moveTo(e){return this._data+=`M ${e.x} ${e.y} `,this}lineTo(e){return this._data+=`L ${e.x} ${e.y} `,this}build(){return this._data}}function ht(c){const e=o.derivedObservableWithCache(void 0,(t,i)=>c.read(t)||i);return o.derivedOpts({debugName:()=>`${c.debugName}.mapOutFalsy`},t=>{if(e.read(t),!!c.read(t))return e})}function _e(c,e=o.DebugLocation.ofCaller()){return{left:o.derived({name:"editor.validOverlay.left"},t=>c(t)?.left,e),top:o.derived({name:"editor.validOverlay.top"},t=>c(t)?.top,e),width:o.derived({name:"editor.validOverlay.width"},t=>{const i=c(t);if(i)return i.width},e),height:o.derived({name:"editor.validOverlay.height"},t=>{const i=c(t);if(i)return i.height},e)}}function AD(c,e){const t=c.getContainerDomNode(),i=o.observableValue("domRect",t.getBoundingClientRect());return e.add(c.onDidLayoutChange(n=>{i.set(t.getBoundingClientRect(),void 0)})),i}var FD=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Rg=function(c,e){return function(t,i){e(t,i,c)}};let Tg=class{constructor(e,t,i,n,s,r){this._editorObs=e,this._data=t,this._close=i,this._contextKeyService=n,this._keybindingService=s,this._commandService=r,this._inlineEditsShowCollapsed=this._editorObs.getOption(71).map(l=>l.edits.showCollapsed)}toDisposableLiveElement(){return this._createHoverContent().toDisposableLiveElement()}_createHoverContent(){const e=o.observableValue("active",void 0),t=_=>({title:_.title,icon:_.icon,keybinding:typeof _.commandId=="string"?this._getKeybinding(_.commandArgs?void 0:_.commandId):o.derived(this,v=>typeof _.commandId=="string"?void 0:this._getKeybinding(_.commandArgs?void 0:_.commandId.read(v)).read(v)),isActive:e.map(v=>v===_.id),onHoverChange:v=>e.set(v?_.id:void 0,void 0),onAction:()=>{const v=typeof _.commandId=="string"?_.commandId:_.commandId.get();return this._close(!0,v),this._commandService.executeCommand(v,..._.commandArgs??[])}}),i=this._data.extensionCommands.map(_=>_.map((v,b)=>si(t({id:v.command.id+"_"+b,title:v.command.title,icon:v.icon??a.Codicon.symbolEvent,commandId:v.command.id,commandArgs:v.command.arguments})))),n=[];for(const _ of i)_.length>0&&(n.push(Ng()),n.push(..._));if(this._data.extensionCommandsOnly)return eb(n.slice(1));const s=zD(this._data.displayName),r=si(t({id:"gotoAndAccept",title:a.localize(1276,"Go To / Accept"),icon:a.Codicon.check,commandId:Qi})),l=si(t({id:"reject",title:a.localize(1277,"Reject"),icon:a.Codicon.close,commandId:Cm})),d=this._data.alternativeAction?si(t({id:"alternativeCommand",title:this._data.alternativeAction.command.title,icon:this._data.alternativeAction.icon,commandId:oa})):void 0,h=[],u=this._inlineEditsShowCollapsed.map(_=>si(t(_?{id:"showExpanded",title:a.localize(1278,"Show Expanded"),icon:a.Codicon.expandAll,commandId:nh}:{id:"showCollapsed",title:a.localize(1279,"Show Collapsed"),icon:a.Codicon.collapseAll,commandId:nh}))),g=si(t({id:"snooze",title:a.localize(1280,"Snooze"),icon:a.Codicon.bellSlash,commandId:"editor.action.inlineSuggest.snooze"})),p=si(t({id:"settings",title:a.localize(1281,"Settings"),icon:a.Codicon.gear,commandId:"workbench.action.openSettings",commandArgs:["@tag:nextEditSuggestions"]})),f=this._data.action?[this._data.action]:[],m=f.length>0?VD(f.map(_=>({id:_.id,label:_.title+"...",enabled:!0,run:()=>this._commandService.executeCommand(_.id,..._.arguments??[]),class:void 0,tooltip:_.tooltip??_.title})),{hoverDelegate:o.nativeHoverDelegate}):void 0;return eb([s,r,d,l,u,h.length?Ng():void 0,...h,g,p,...n,m?Ng():void 0,m])}_getKeybinding(e){return e?o.observableFromEvent(this._contextKeyService.onDidChangeContext,()=>this._keybindingService.lookupKeybinding(e)):o.constObservable(void 0)}};Tg=FD([Rg(3,o.IContextKeyService),Rg(4,o.IKeybindingService),Rg(5,o.ICommandService)],Tg);function eb(c){return o.n.div({class:"content",style:{margin:4,minWidth:180}},c)}function zD(c){return o.n.div({class:"header",style:{color:o.asCssVariable(o.descriptionForeground),fontSize:"13px",fontWeight:"600",padding:"0 4px",lineHeight:28}},[c])}function si(c){return o.derived({name:"inlineEdits.option"},e=>o.n.div({class:["monaco-menu-option",c.isActive?.map(t=>t&&"active")],onmouseenter:()=>c.onHoverChange?.(!0),onmouseleave:()=>c.onHoverChange?.(!1),onclick:c.onAction,onkeydown:t=>{t.key==="Enter"&&c.onAction?.()},tabIndex:0,style:{borderRadius:3}},[o.n.elem("span",{style:{fontSize:16,display:"flex"}},[o.ThemeIcon.isThemeIcon(c.icon)?o.renderIcon(c.icon):c.icon.map(t=>o.renderIcon(t))]),o.n.elem("span",{},[c.title]),o.n.div({style:{marginLeft:"auto"},ref:t=>{const i=e.store.add(new o.KeybindingLabel(t,a.OS,{disableTitle:!0,...o.defaultKeybindingLabelStyles,keybindingLabelShadow:void 0,keybindingLabelForeground:o.asCssVariable(o.descriptionForeground),keybindingLabelBackground:"transparent",keybindingLabelBorder:"transparent",keybindingLabelBottomBorder:void 0}));e.store.add(o.autorun(n=>{i.set(c.keybinding.read(n))}))}})]))}function VD(c,e){return o.derived({name:"inlineEdits.actionBar"},t=>o.n.div({class:["action-widget-action-bar"],style:{padding:"3px 24px"}},[o.n.div({ref:i=>{t.store.add(new o.ActionBar(i,e)).push(c,{icon:!1,label:!0})}})]))}function Ng(){return o.n.div({id:"inline-edit-gutter-indicator-menu-separator",class:"menu-separator",style:{color:o.asCssVariable(o.editorActionListForeground),padding:"2px 0"}},o.n.div({style:{borderBottom:`1px solid ${o.asCssVariable(o.editorHoverBorder)}`}}))}var BD=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Ir=function(c,e){return function(t,i){e(t,i,c)}};class tb{constructor(e,t,i,n,s){this.gutterMenuData=e,this.originalRange=t,this.model=i,this.altAction=n,this.customization=s}}class zl{static fromInlineSuggestion(e){const t=e.action?.kind==="edit"?e.action.alternativeAction:void 0,i=e.source.inlineSuggestions.commands??[];return new zl(e.gutterMenuLinkAction,e.source.provider.displayName??a.localize(1282,"Inline Suggestion"),i.length>0?[i]:[],t,e.source.provider.modelInfo,e.source.provider.setModelId?.bind(e.source.provider))}constructor(e,t,i,n,s,r,l=!1){this.action=e,this.displayName=t,this.extensionCommands=i,this.alternativeAction=n,this.modelInfo=s,this.setModelId=r,this.extensionCommandsOnly=l}}class Vl{static fromInlineCompletionModel(e){return new Vl(()=>e.accept(),()=>e.jump())}constructor(e,t){this.accept=e,this.jump=t}}const Mg=16,ib=2;let Bl=class extends a.Disposable{constructor(e,t,i,n,s,r,l,d,h,u,g){super(),this._editorObs=e,this._data=t,this._tabAction=i,this._verticalOffset=n,this._isHoveringOverInlineEdit=s,this._focusIsInMenu=r,this._hoverService=l,this._instantiationService=d,this._accessibilityService=h,this._themeService=u,this._userInteractionService=g,this._onDidCloseWithCommand=this._register(new a.Emitter),this._modifierPressed=o.derived(this,f=>this._userInteractionService.readModifierKeyStatus(this._editorObs.editor.getDomNode(),f).shiftKey),this._gutterIndicatorStyles=o.derived(this,f=>{let m=this._tabAction.read(f);const _=this._data.read(f)?.altAction,v=this._modifierPressed.read(f);switch(_&&v&&(m=H.Inactive),m){case H.Inactive:return{background:de(wg,this._themeService).read(f).toString(),foreground:de(yD,this._themeService).read(f).toString(),border:de(wD,this._themeService).read(f).toString()};case H.Jump:return{background:de(Cr,this._themeService).read(f).toString(),foreground:de(br,this._themeService).read(f).toString(),border:de(ii,this._themeService).read(f).toString()};case H.Accept:return{background:de(Ig,this._themeService).read(f).toString(),foreground:de(ID,this._themeService).read(f).toString(),border:de(Hv,this._themeService).read(f).toString()};default:a.assertNever()}}),this._state=o.derived(this,f=>{const m=this._originalRangeObs.read(f);if(m)return{range:m,lineOffsetRange:this._editorObs.observeLineOffsetRange(m,f.store)}}),this._lineNumberToRender=o.derived(this,f=>{if(this._verticalOffset.read(f)!==0)return"";const m=this._data.read(f)?.originalRange.startLineNumber,_=this._editorObs.getOption(76).read(f);if(m===void 0||_.renderType===0)return"";if(_.renderType===3){const v=this._editorObs.cursorPosition.read(f);return m%10===0||v&&v.lineNumber===m?m.toString():""}if(_.renderType===2){const v=this._editorObs.cursorPosition.read(f);if(!v)return"";const b=Math.abs(m-v.lineNumber);return b===0?m.toString():b.toString()}return _.renderType===4?_.renderFn?_.renderFn(m):"":m.toString()}),this._availableWidthForIcon=o.derived(this,f=>{const m=this._editorObs.editor.getModel(),_=this._editorObs.editor,v=this._editorObs.layoutInfo.read(f),b=v.decorationsLeft+v.decorationsWidth-v.glyphMarginLeft;if(!m||b<=0)return()=>0;if(v.lineNumbersLeft===0)return()=>b;const C=this._editorObs.getOption(76).read(f);if(C.renderType===2||C.renderType===0)return()=>b;const y=_.getOption(59).typicalHalfwidthCharacterWidth,I=v.lineNumbersLeft+v.lineNumbersWidth,S=(m.getLineCount()+1).toString().length,w=[];for(let E=1;E<=S;E++){const L=10**(E-1),R=_.getTopForLineNumber(L),D=E*y,T=Math.min(b,Math.max(0,I-D-v.glyphMarginLeft));w.push({firstLineNumberWithDigitCount:L,topOfLineNumber:R,usableWidthLeftOfLineNumber:T})}return E=>{for(let L=w.length-1;L>=0;L--)if(E>=w[L].topOfLineNumber)return w[L].usableWidthLeftOfLineNumber;throw new a.BugIndicatingError("Could not find avilable width for icon")}}),this._layout=o.derived(this,f=>{const m=this._state.read(f);if(!m)return;const _=this._editorObs.layoutInfo.read(f),v=this._editorObs.observeLineHeightForLine(m.range.map(G=>G.startLineNumber)).read(f),b=1,C=2,y=_.decorationsLeft+_.decorationsWidth-_.glyphMarginLeft-2*b,I=_.height-2*C,x=k.fromLeftTopWidthHeight(b,C,y,I),S=x.withTop(this._stickyScrollHeight.read(f)),w=x.withTop(S.top+C),E=m.lineOffsetRange.read(f),L=k.fromRanges(a.OffsetRange.fromTo(w.left,w.right),E),R=v,D=this._verticalOffset.read(f),T=L.withHeight(R).translateY(D),P=S.containsRect(T),M=this._data.read(f)?.customization?.icon,V=M?o.constObservable(M):this._tabAction.map(G=>G===H.Accept?a.Codicon.keyboardTab:a.Codicon.arrowRight),F=M?o.constObservable(M):o.derived(this,G=>{if(this._isHoveredOverIconDebounced.read(G)||this._isHoveredOverInlineEditDebounced.read(G))return a.Codicon.check;if(this._tabAction.read(G)===H.Accept)return a.Codicon.keyboardTab;const ae=this._editorObs.cursorLineNumber.read(G)??0,Fi=m.range.read(G).startLineNumber;return ae<=Fi?a.Codicon.keyboardTabAbove:a.Codicon.keyboardTabBelow}),K=22,O=G=>{const ae=this._availableWidthForIcon.read(void 0)(G.bottom+this._editorObs.editor.getScrollTop())-b;return Math.max(Math.min(ae,K),Mg)};if(P){const G=T;let ae;_.lineNumbersWidth===0?ae=Math.max(0,Math.min(Math.max(_.lineNumbersLeft-x.left,0),G.width-K)):ae=Math.max(_.lineNumbersLeft+_.lineNumbersWidth-x.left,0);const Fi=G.withWidth(ae),je=Mg+ib,yt=Math.min(G.width-ae,K),os=G.withWidth(Math.max(yt,je)).translateX(ae),yf=yt>=je;return{gutterEditArea:L,icon:F,iconDirection:"right",iconRect:os,iconVisible:yf,pillRect:G,lineNumberRect:Fi}}const z=x.intersect(L);if(z&&z.height>=R){const G=T.moveToBeContainedIn(w).moveToBeContainedIn(z),ae=G.withWidth(O(G));return{gutterEditArea:L,icon:F,iconDirection:"right",iconRect:ae,pillRect:ae,iconVisible:!0}}const j=T.moveToBeContainedIn(x),U=j.withWidth(O(j)),W=U,Y=U.top<T.top?"top":"bottom";return{gutterEditArea:L,icon:V,iconDirection:Y,iconRect:W,pillRect:U,iconVisible:!0}}),this._iconRef=o.n.ref(),this.isVisible=this._layout.map(f=>!!f),this._hoverVisible=o.observableValue(this,!1),this.isHoverVisible=this._hoverVisible,this._isHoveredOverIcon=o.observableValue(this,!1),this._isHoveredOverIconDebounced=o.debouncedObservable(this._isHoveredOverIcon,100),this.isHoveredOverIcon=this._isHoveredOverIconDebounced,this._indicator=o.n.div({class:"inline-edits-view-gutter-indicator",style:{position:"absolute",overflow:"visible"}},ht(this._layout).map(f=>f?[o.n.div({style:{position:"absolute",background:o.asCssVariable(xD),borderRadius:`${me}px`,..._e(m=>f.read(m).gutterEditArea)}}),o.n.div({class:"icon",ref:this._iconRef,tabIndex:0,onclick:()=>{const _=this._layout.get()?.icon.get()===a.Codicon.check,v=this._data.get();if(!v)throw new a.BugIndicatingError("Gutter indicator data not available");this._editorObs.editor.focus(),_?v.model.accept():v.model.jump()},onmouseenter:()=>{this._isHoveredOverIcon.set(!0,void 0),this._showHover()},onmouseleave:()=>this._isHoveredOverIcon.set(!1,void 0),style:{cursor:"pointer",zIndex:"20",position:"absolute",backgroundColor:this._gutterIndicatorStyles.map(m=>m.background),"--vscodeIconForeground":this._gutterIndicatorStyles.map(m=>m.foreground),border:this._gutterIndicatorStyles.map(m=>`1px solid ${m.border}`),boxSizing:"border-box",borderRadius:`${me}px`,display:"flex",justifyContent:f.map(m=>m.iconDirection==="bottom"?"flex-start":"flex-end"),transition:this._modifierPressed.map(m=>m?"":"background-color 0.2s ease-in-out, width 0.2s ease-in-out"),..._e(m=>f.read(m).pillRect)}},[o.n.div({className:"line-number",style:{lineHeight:f.map(m=>m.lineNumberRect?m.lineNumberRect.height:0),display:f.map(m=>m.lineNumberRect?"flex":"none"),alignItems:"center",justifyContent:"flex-end",width:f.map(m=>m.lineNumberRect?m.lineNumberRect.width:0),height:"100%",color:this._gutterIndicatorStyles.map(m=>m.foreground)}},this._lineNumberToRender),o.n.div({style:{transform:f.map(m=>`rotate(${KD(m.iconDirection)}deg)`),transition:"rotate 0.2s ease-in-out, opacity 0.2s ease-in-out",display:"flex",alignItems:"center",justifyContent:"center",height:"100%",opacity:f.map(m=>m.iconVisible?"1":"0"),marginRight:f.map(m=>m.pillRect.width-m.iconRect.width-(m.lineNumberRect?.width??0)),width:f.map(m=>m.iconRect.width),position:"relative",right:f.map(m=>m.iconDirection==="top"?"1px":"0"),color:this._data.map(m=>m?.customization?.icon?.color?o.asCssVariable(m.customization.icon.color.id):void 0)}},[f.map((m,_)=>kD(o.renderIcon(m.icon.read(_)),{fontSize:UD(Math.min(m.iconRect.width-ib,Mg))}))])])]:[])),this._originalRangeObs=ht(this._data.map(f=>f?.originalRange)),this._stickyScrollController=Be.get(this._editorObs.editor),this._stickyScrollHeight=this._stickyScrollController?o.observableFromEvent(this._stickyScrollController.onDidChangeStickyScrollHeight,()=>this._stickyScrollController.stickyScrollWidgetHeight):o.constObservable(0),this._isHoveredOverInlineEditDebounced=o.debouncedObservable(this._isHoveringOverInlineEdit,100);const p=this._indicator.keepUpdated(this._store);this._register(this._editorObs.createOverlayWidget({domNode:p.element,position:o.constObservable(null),allowEditorOverflow:!1,minContentWidthInPx:o.constObservable(0)})),this._register(this._editorObs.editor.onDidScrollChange(()=>{this._isHoveredOverIcon.set(!1,void 0)})),this._register(o.runOnChange(this._isHoveredOverInlineEditDebounced,f=>{f&&this.triggerAnimation()})),this._register(o.autorun(f=>{p.readEffect(f),p.element&&this._editorObs.editor.applyFontInfo(p.element)}))}triggerAnimation(){return this._accessibilityService.isMotionReduced()?new Animation(null,null).finished:this._iconRef.element.animate([{outline:`2px solid ${this._gutterIndicatorStyles.map(t=>t.border).get()}`,outlineOffset:"-1px",offset:0},{outline:"2px solid transparent",outlineOffset:"10px",offset:1}],{duration:500}).finished}_showHover(){if(this._hoverVisible.get())return;const e=this._data.get();if(!e)throw new a.BugIndicatingError("Gutter indicator data not available");const t=new a.DisposableStore,i=t.add(this._instantiationService.createInstance(Tg,this._editorObs,e.gutterMenuData,(r,l)=>{r&&this._editorObs.editor.focus(),l&&this._onDidCloseWithCommand.fire(l),s?.dispose()}).toDisposableLiveElement()),n=this._userInteractionService.createFocusTracker(i.element,t);t.add(o.autorun(r=>{this._focusIsInMenu.set(n.read(r),void 0)})),t.add(a.toDisposable(()=>this._focusIsInMenu.set(!1,void 0)));const s=this._hoverService.showInstantHover({target:this._iconRef.element,content:i.element});s?(this._hoverVisible.set(!0,void 0),t.add(this._editorObs.editor.onDidScrollChange(()=>s.dispose())),t.add(s.onDispose(()=>{this._hoverVisible.set(!1,void 0),t.dispose()}))):t.dispose()}};Bl=BD([Ir(6,o.IHoverService),Ir(7,o.IInstantiationService),Ir(8,o.IAccessibilityService),Ir(9,o.IThemeService),Ir(10,o.IUserInteractionService)],Bl);function KD(c){switch(c){case"top":return 90;case"bottom":return-90;case"right":return 0}}function kD(c,e){for(const t in e)c.style[t]=e[t];return c}function UD(c){return`${c}px`}var $D=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},nb=function(c,e){return function(t,i){e(t,i,c)}},Le;(function(c){c.FirstTime="firstTime",c.SecondTime="secondTime",c.Active="active"})(Le||(Le={}));let Pg=class extends a.Disposable{constructor(e,t,i,n,s){super(),this._model=e,this._indicator=t,this._collapsedView=i,this._storageService=n,this._configurationService=s,this._disposables=this._register(new a.MutableDisposable),this._setupDone=o.observableValue({name:"setupDone"},!1),this._activeCompletionId=o.derived(r=>{const l=this._model.read(r);if(!l||!this._setupDone.read(r))return;const d=this._indicator.read(r);if(!(!d||!d.isVisible.read(r)))return l.inlineEdit.inlineCompletion.identity.id}),this._register(this._initializeDebugSetting()),this._disposables.value=this.setupNewUserExperience(),this._setupDone.set(!0,void 0)}setupNewUserExperience(){if(this.getNewUserType()===Le.Active)return;const e=new a.DisposableStore;let t=!1,i=!1,n=0,s=0;return e.add(o.runOnChangeWithCancellationToken(this._activeCompletionId,async(r,l,d,h)=>{if(r===void 0)return;let u=this.getNewUserType();switch(u){case Le.FirstTime:{(n++>=5||t)&&(u=Le.SecondTime,this.setNewUserType(u));break}case Le.SecondTime:{s++>=3&&i&&(u=Le.Active,this.setNewUserType(u));break}}switch(u){case Le.FirstTime:{for(let g=0;g<3&&!h.isCancellationRequested;g++)await this._indicator.get()?.triggerAnimation(),await a.timeout(500);break}case Le.SecondTime:{this._indicator.get()?.triggerAnimation();break}}})),e.add(o.autorun(r=>{this._collapsedView.isVisible.read(r)&&this.getNewUserType()!==Le.Active&&this._collapsedView.triggerAnimation()})),e.add(o.autorun(r=>{const l=this._indicator.read(r);l&&r.store.add(o.runOnChange(l.isHoveredOverIcon,async d=>{d&&(t=!0)}))})),e.add(o.autorun(r=>{const l=this._model.read(r);l&&r.store.add(l.onDidAccept(()=>{i=!0}))})),e}getNewUserType(){return this._storageService.get("inlineEditsGutterIndicatorUserKind",-1,Le.FirstTime)}setNewUserType(e){switch(e){case Le.FirstTime:throw new a.BugIndicatingError("UserKind should not be set to first time");case Le.SecondTime:break;case Le.Active:this._disposables.clear();break}this._storageService.store("inlineEditsGutterIndicatorUserKind",e,-1,0)}_initializeDebugSetting(){const e="editor.inlineSuggest.edits.resetNewUserExperience";return this._configurationService.getValue(e)&&this._storageService.remove("inlineEditsGutterIndicatorUserKind",-1),this._configurationService.onDidChangeConfiguration(i=>{i.affectsConfiguration(e)&&this._configurationService.getValue(e)&&(this._storageService.remove("inlineEditsGutterIndicatorUserKind",-1),this._disposables.value=this.setupNewUserExperience())})}};Pg=$D([nb(3,o.IStorageService),nb(4,o.IConfigurationService)],Pg);const $c=class $c{constructor(e){this.replacements=e,a.assert(a.checkAdjacentItems(e,(t,i)=>t.lineRange.endLineNumberExclusive<=i.lineRange.startLineNumber))}toString(){return this.replacements.map(e=>e.toString()).join(",")}getNewLineRanges(){const e=[];let t=0;for(const i of this.replacements)e.push(a.LineRange.ofLength(i.lineRange.startLineNumber+t,i.newLines.length)),t+=i.newLines.length-i.lineRange.length;return e}};$c.empty=new $c([]);let Og=$c;class xr{static fromSingleTextEdit(e,t){const i=a.splitLines(e.text);let n=e.range.startLineNumber;const s=t.getValueOfRange(a.Range.fromPositions(new a.Position(e.range.startLineNumber,1),e.range.getStartPosition()));i[0]=s+i[0];let r=e.range.endLineNumber+1;const l=t.getTransformer().getLineLength(e.range.endLineNumber)+1,d=t.getValueOfRange(a.Range.fromPositions(e.range.getEndPosition(),new a.Position(e.range.endLineNumber,l)));i[i.length-1]=i[i.length-1]+d;const h=e.range.startColumn===t.getTransformer().getLineLength(e.range.startLineNumber)+1,u=e.range.endColumn===1;return h&&i[0].length===s.length&&(n++,i.shift()),i.length>0&&n<r&&u&&i[i.length-1].length===d.length&&(r--,i.pop()),new xr(new a.LineRange(n,r),i)}constructor(e,t){this.lineRange=e,this.newLines=t}toString(){return`${this.lineRange}->${JSON.stringify(this.newLines)}`}toLineEdit(){return new Og([this])}}class jD{get lineEdit(){return this.action?.kind==="jumpTo"?new xr(a.LineRange.ofLength(this.action.position.lineNumber,0),[]):this.action?.kind==="edit"?xr.fromSingleTextEdit(this.edit.toReplacement(this.originalText),this.originalText):new xr(new a.LineRange(1,1),[])}get originalLineRange(){return this.lineEdit.lineRange}get modifiedLineRange(){return this.lineEdit.toLineEdit().getNewLineRanges()[0]}get displayRange(){return this.originalText.lineRange.intersect(this.originalLineRange.join(a.LineRange.ofLength(this.originalLineRange.startLineNumber,this.lineEdit.newLines.length)))}constructor(e,t,i,n,s,r,l){this.originalText=e,this.action=t,this.edit=i,this.cursorPosition=n,this.multiCursorPositions=s,this.commands=r,this.inlineCompletion=l}}class qD{constructor(e,t,i){this._model=e,this.inlineEdit=t,this.tabAction=i,this.editorType=this._model.editorType,this.displayLocation=this.inlineEdit.inlineCompletion.hint,this.inViewPort=o.derived(this,n=>Mv(this._model.editor,this.inlineEdit.inlineCompletion,n)),this.onDidAccept=this._model.onDidAccept}accept(e){this._model.accept(void 0,e)}handleInlineEditShownNextFrame(e,t){const i=this.inlineEdit.inlineCompletion,n=Date.now();i.addRef(),a.setTimeout0(()=>{this._model.handleInlineSuggestionShown(i,e,t,n),i.removeRef()})}}var GD=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},ZD=function(c,e){return function(t,i){e(t,i,c)}};let Ag=class extends a.Disposable{constructor(e,t,i){super(),this._editor=e,this._edit=t,this._accessibilityService=i,this.onDidClick=a.Event.None,this._iconRef=o.n.ref(),this.isHovered=o.constObservable(!1),this._editorObs=o.observableCodeEditor(this._editor);const s=this._edit.map(h=>h?.edit?.replacements[0]??null).map(h=>h?Yt(h,this._editor.getModel()).range.getStartPosition():null),r=this._editorObs.observePosition(s,this._store),l=o.derived(h=>{const u=r.read(h);if(!u)return null;const g=this._editorObs.layoutInfoContentLeft.read(h),p=this._editorObs.scrollLeft.read(h);return new o.Point(g+u.x-p,u.y)}),d=o.n.div({class:"inline-edits-collapsed-view",style:{position:"absolute",overflow:"visible",top:"0px",left:"0px",display:"block"}},[[this.getCollapsedIndicator(l)]]).keepUpdated(this._store).element;this._register(this._editorObs.createOverlayWidget({domNode:d,position:o.constObservable(null),allowEditorOverflow:!1,minContentWidthInPx:o.constObservable(0)})),this.isVisible=this._edit.map((h,u)=>!!h&&l.read(u)!==null)}triggerAnimation(){return this._accessibilityService.isMotionReduced()?new Animation(null,null).finished:this._iconRef.element.animate([{offset:0,transform:"translateY(-3px)"},{offset:.2,transform:"translateY(1px)"},{offset:.36,transform:"translateY(-1px)"},{offset:.52,transform:"translateY(1px)"},{offset:.68,transform:"translateY(-1px)"},{offset:.84,transform:"translateY(1px)"},{offset:1,transform:"translateY(0px)"}],{duration:2e3}).finished}getCollapsedIndicator(e){const t=this._editorObs.layoutInfoContentLeft,i=e.map((s,r)=>s?s.deltaX(-t.read(r)):null),n=this.createIconPath(i);return o.n.svg({class:"collapsedView",ref:this._iconRef,style:{position:"absolute",..._e(s=>Lg(this._editorObs).read(s)),overflow:"hidden",pointerEvents:"none"}},[o.n.svgElem("path",{class:"collapsedViewPath",d:n,fill:o.asCssVariable(ii)})])}createIconPath(e){return e.map(s=>{if(!s)return new Dg().build();const r=s.deltaX(-6/2).deltaY(-1),l=r.deltaX(6),d=r.deltaY(1),h=l.deltaY(1),u=d.deltaX(6/2).deltaY(3);return new Dg().moveTo(r).lineTo(l).lineTo(h).lineTo(u).lineTo(d).lineTo(r).build()})}};Ag=GD([ZD(2,o.IAccessibilityService)],Ag);var XD=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},sb=function(c,e){return function(t,i){e(t,i,c)}};const Kl=14,Fg=0,Ft=4,kl=4,ob=2;let zg=class extends a.Disposable{constructor(e,t,i,n,s,r){super(),this._editor=e,this._languageService=r,this._onDidClick=this._register(new a.Emitter),this.onDidClick=this._onDidClick.event,this._isHovered=o.observableValue(this,!1),this.isHovered=this._isHovered,this._viewRef=o.n.ref(),this._editorObs=o.observableCodeEditor(this._editor);const l=i.map((g,p)=>{let f;switch(g){case H.Inactive:f=wg;break;case H.Jump:f=Cr;break;case H.Accept:f=Ig;break}return{border:de(f,s).read(p).toString(),background:ni(n.read(p))}}),d=t.map(g=>g?this.getState(g):void 0),h=d.map(g=>g?this.getRendering(g,l):void 0);this.minEditorScrollHeight=o.derived(this,g=>{const p=d.read(g);return p?p.rect.read(g).bottom+this._editor.getScrollTop():0});const u=o.n.div({class:"inline-edits-custom-view",style:{position:"absolute",overflow:"visible",top:"0px",left:"0px",display:"block"}},[h]).keepUpdated(this._store);this._register(this._editorObs.createOverlayWidget({domNode:u.element,position:o.constObservable(null),allowEditorOverflow:!1,minContentWidthInPx:o.derivedObservableWithCache(this,(g,p)=>{const f=d.read(g);if(!f)return p??0;const m=f.rect.map(_=>_.right).read(g)+this._editorObs.layoutInfoVerticalScrollbarWidth.read(g)+Ft-this._editorObs.layoutInfoContentLeft.read(g);return Math.max(p??0,m)}).recomputeInitiallyAndOnChange(this._store)})),this._register(o.autorun(g=>{if(!h.read(g)){this._isHovered.set(!1,void 0);return}this._isHovered.set(u.isHovered.read(g),void 0)}))}fitsInsideViewport(e,t,i){const n=this._editorObs.layoutInfoWidth.read(i),s=this._editorObs.layoutInfoContentLeft.read(i),r=this._editor.getLayoutInfo().verticalScrollbarWidth,l=this._editorObs.layoutInfoMinimap.read(i).minimapLeft!==0?this._editorObs.layoutInfoMinimap.read(i).minimapWidth:0,d=At(this._editorObs,e,void 0),h=Eg(t,this._editor,this._editor.getModel()),u=Ft+Kl;return d+h+u<n-s-r-l}getState(e){const t=o.derived(this,l=>{const d=e.range.startLineNumber,h=e.range.endLineNumber,u=e.range.startColumn,g=e.range.endColumn,p=this._editor.getModel()?.getLineCount()??0,f=At(this._editorObs,new a.LineRange(d,d+1),l),m=d+1<=p?At(this._editorObs,new a.LineRange(d+1,d+2),l):void 0,_=d-1>=1?At(this._editorObs,new a.LineRange(d-1,d),l):void 0,v=this._editor.getOffsetForColumn(d,u),b=this._editor.getOffsetForColumn(h,g);return{lineWidth:f,lineWidthBelow:m,lineWidthAbove:_,startContentLeftOffset:v,endContentLeftOffset:b}}),i=e.range.startLineNumber,n=e.range.endLineNumber,s=this.fitsInsideViewport(new a.LineRange(i,n+1),e.content,void 0);return{rect:o.derived(this,l=>{const d=this._editorObs.getOption(59).read(l).typicalHalfwidthCharacterWidth,{lineWidth:h,lineWidthBelow:u,lineWidthAbove:g,startContentLeftOffset:p,endContentLeftOffset:f}=t.read(l),m=this._editorObs.layoutInfoContentLeft.read(l),_=this._editorObs.observeLineHeightForLine(i).recomputeInitiallyAndOnChange(l.store).read(l),v=this._editorObs.scrollTop.read(l),b=this._editorObs.scrollLeft.read(l);let C;i===n&&f+5*d>=h&&s?C="end":u!==void 0&&u+Kl-kl-Ft<p?C="below":g!==void 0&&g+Kl-kl-Ft<p?C="above":C="end";let y,I,x=0,S=0;switch(C){case"end":{y=this._editorObs.editor.getTopForLineNumber(i),I=h,x=Ft+Kl;break}case"below":{y=this._editorObs.editor.getTopForLineNumber(i+1),I=p,x=Ft+kl,S=Fg+ob;break}case"above":{y=this._editorObs.editor.getTopForLineNumber(i-1),I=p,x=Ft+kl,S=-Fg+ob;break}}return k.fromLeftTopWidthHeight(m+I-b,y-v,d*e.content.length,_).withMargin(Fg,Ft).translateX(x).translateY(S)}),label:e.content,kind:e.style}}getRendering(e,t){const i=document.createElement("div"),n=this._editor.getModel().tokenization.tokenizeLinesAt(1,[e.label])?.[0];let s;n&&e.kind===a.InlineCompletionHintStyle.Code?s=o.TokenArray.fromLineTokens(n).toLineTokens(e.label,this._languageService.languageIdCodec):s=o.LineTokens.createEmpty(e.label,this._languageService.languageIdCodec);const r=o.renderLines(new o.LineSource([s]),o.RenderOptions.fromEditor(this._editor).withSetWidth(!1).withScrollBeyondLastColumn(0),[],i,!0);i.style.width=`${r.minWidthInPx}px`;const l=e.rect.map(d=>d.withMargin(0,Ft));return o.n.div({class:"collapsedView",ref:this._viewRef,style:{position:"absolute",..._e(d=>l.read(d)),overflow:"hidden",boxSizing:"border-box",cursor:"pointer",border:t.map(d=>`1px solid ${d.border}`),borderRadius:`${me}px`,backgroundColor:t.map(d=>d.background),display:"flex",alignItems:"center",justifyContent:"center",whiteSpace:"nowrap"},onmousedown:d=>{d.preventDefault()},onclick:d=>{this._onDidClick.fire(Qt.create(d))}},[i])}};zg=XD([sb(4,o.IThemeService),sb(5,o.ILanguageService)],zg);const YD=0,QD=0,Vg=1,JD=1,WD=3,Bg=me;class HD extends a.Disposable{constructor(e,t,i,n){super(),this._editor=e,this._edit=t,this._uiState=i,this._tabAction=n,this.onDidClick=a.Event.None,this._display=o.derived(this,l=>this._uiState.read(l)?"block":"none"),this._editorMaxContentWidthInRange=o.derived(this,l=>{const d=this._originalDisplayRange.read(l);return d?(this._editorObs.versionId.read(l),o.derivedObservableWithCache(this,(h,u)=>{const g=At(this._editorObs,d,h);return Math.max(g,u??0)})):o.constObservable(0)}).map((l,d)=>l.read(d)),this._maxPrefixTrim=o.derived(this,l=>{const d=this._uiState.read(l);return d?xg(d.deletions,d.originalRange,[],this._editor):{prefixTrim:0,prefixLeftOffset:0}}),this._editorLayoutInfo=o.derived(this,l=>{const d=this._edit.read(l);if(!d||!this._uiState.read(l))return null;const u=this._editorObs.layoutInfo.read(l),g=this._editorObs.scrollLeft.read(l),p=this._editorObs.getOption(59).map(y=>y.typicalHalfwidthCharacterWidth).read(l),f=u.contentLeft+Math.max(this._editorMaxContentWidthInRange.read(l),p)-g,m=d.originalLineRange,_=this._originalVerticalStartPosition.read(l)??this._editor.getTopForLineNumber(m.startLineNumber)-this._editorObs.scrollTop.read(l),v=this._originalVerticalEndPosition.read(l)??this._editor.getTopForLineNumber(m.endLineNumberExclusive)-this._editorObs.scrollTop.read(l),b=u.contentLeft+this._maxPrefixTrim.read(l).prefixLeftOffset-g;return f<=b?null:{codeRect:k.fromLeftTopRightBottom(b,_,f,v).withMargin(QD,YD),contentLeft:u.contentLeft}}).recomputeInitiallyAndOnChange(this._store),this._originalOverlay=o.n.div({style:{pointerEvents:"none"}},o.derived(this,l=>{const d=ht(this._editorLayoutInfo).read(l);if(!d)return;const h=d.map(m=>k.fromLeftTopRightBottom(m.contentLeft-Bg-Vg,m.codeRect.top,m.contentLeft,m.codeRect.bottom)),u=o.derived(this,m=>{const _=d.read(m).codeRect,v=h.read(m);return _.intersectHorizontal(new a.OffsetRange(v.left,Number.MAX_SAFE_INTEGER))}),g=this._uiState.map(m=>m?.editorType===te.DiffEditor?WD:JD).read(l),p=u.map(m=>m.withMargin(g,g)),f=ni(this._uiState.map(m=>m?.editorType??te.TextEditor).read(l));return[o.n.div({class:"originalSeparatorDeletion",style:{...p.read(l).toStyles(),borderRadius:`${Bg}px`,border:`${Vg+g}px solid ${f}`,boxSizing:"border-box"}}),o.n.div({class:"originalOverlayDeletion",style:{...u.read(l).toStyles(),borderRadius:`${Bg}px`,border:Al(this._tabAction).map(m=>`${Vg}px solid ${o.asCssVariable(m)}`),boxSizing:"border-box",backgroundColor:o.asCssVariable(vr)}}),o.n.div({class:"originalOverlayHiderDeletion",style:{...h.read(l).toStyles(),backgroundColor:f}})]})).keepUpdated(this._store),this._nonOverflowView=o.n.div({class:"inline-edits-view",style:{position:"absolute",overflow:"visible",top:"0px",left:"0px",display:this._display}},[[this._originalOverlay]]).keepUpdated(this._store),this.isHovered=o.constObservable(!1),this._editorObs=o.observableCodeEditor(this._editor);const s=o.derived(this,l=>{const d=this._edit.read(l);return d?new a.Position(d.originalLineRange.startLineNumber,1):null}),r=o.derived(this,l=>{const d=this._edit.read(l);return d?new a.Position(d.originalLineRange.endLineNumberExclusive,1):null});this._originalDisplayRange=this._uiState.map(l=>l?.originalRange),this._originalVerticalStartPosition=this._editorObs.observePosition(s,this._store).map(l=>l?.y),this._originalVerticalEndPosition=this._editorObs.observePosition(r,this._store).map(l=>l?.y),this._register(this._editorObs.createOverlayWidget({domNode:this._nonOverflowView.element,position:o.constObservable(null),allowEditorOverflow:!1,minContentWidthInPx:o.derived(this,l=>{const d=this._editorLayoutInfo.read(l);return d===null?0:d.codeRect.width})}))}}var eR=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},rb=function(c,e){return function(t,i){e(t,i,c)}};const Ks=1,tR=1,iR=3,Kg=me;let kg=class extends a.Disposable{constructor(e,t,i,n,s){super(),this._editor=e,this._input=t,this._tabAction=i,this._languageService=s,this._onDidClick=this._register(new a.Emitter),this.onDidClick=this._onDidClick.event,this._state=o.derived(this,r=>{const l=this._input.read(r);if(!l)return;const d=this._editor.getModel(),h=d.getEOL();if(l.startColumn===1&&l.lineNumber>1&&d.getLineLength(l.lineNumber)!==0&&l.text.endsWith(h)&&!l.text.startsWith(h)){const u=d.getLineLength(l.lineNumber-1)+1;return{lineNumber:l.lineNumber-1,column:u,text:h+l.text.slice(0,-h.length)}}return{lineNumber:l.lineNumber,column:l.startColumn,text:l.text}}),this._trimVertically=o.derived(this,r=>{const l=this._state.read(r);if(!l)return{topOffset:0,contentHeight:0,linesTop:0,linesBottom:0};const d=l.text,h=this._editor.getLineHeightForPosition(new a.Position(l.lineNumber,1)),u=this._editor.getModel().getEOL(),g=d.split(u).length;let p=0,f=0;if(d.trim()!==""){let m=0;for(;m<d.length&&d.startsWith(u,m);m+=u.length)p+=1;for(let _=d.length;_>m&&d.endsWith(u,_);_-=u.length)f+=1}return{topOffset:p*h,contentHeight:(g-p-f)*h,linesTop:p,linesBottom:f}}),this._maxPrefixTrim=o.derived(this,r=>{const l=this._state.read(r);if(!l)return{prefixLeftOffset:0,prefixTrim:0};const d=this._editor.getModel(),h=d.getEOL(),u=this._trimVertically.read(r),g=l.text.split(h),p=g.slice(u.linesTop,g.length-u.linesBottom);u.linesTop===0&&(p[0]=d.getLineContent(l.lineNumber)+p[0]);const f=new a.LineRange(l.lineNumber,l.lineNumber+(u.linesTop>0?0:1));return xg([],f,p,this._editor)}),this._ghostText=o.derived(r=>{const l=this._state.read(r),d=this._maxPrefixTrim.read(r);if(!l)return;const u=this._editor.getModel().getEOL(),p=l.text.split(u).map((f,m)=>new o.InlineDecoration(new a.Range(m+1,m===0?1:d.prefixTrim+1,m+1,f.length+1),"modified-background",0));return new ir(l.lineNumber,[new ml(l.column,l.text,!1,p)])}),this._display=o.derived(this,r=>this._state.read(r)?"block":"none"),this._editorMaxContentWidthInRange=o.derived(this,r=>{const l=this._state.read(r);if(!l)return 0;this._editorObs.versionId.read(r);const d=this._editor.getModel(),h=d.getEOL(),u=l.text.startsWith(h)?"":d.getValueInRange(new a.Range(l.lineNumber,1,l.lineNumber,l.column)),g=d.getValueInRange(new a.Range(l.lineNumber,l.column,l.lineNumber,d.getLineLength(l.lineNumber)+1)),f=(u+l.text+g).split(h),m=o.RenderOptions.fromEditor(this._editor).withSetWidth(!1).withScrollBeyondLastColumn(0),_=f.map(v=>{const b=d.tokenization.tokenizeLinesAt(l.lineNumber,[v])?.[0];let C;return b?C=o.TokenArray.fromLineTokens(b).toLineTokens(v,this._languageService.languageIdCodec):C=o.LineTokens.createEmpty(v,this._languageService.languageIdCodec),o.renderLines(new o.LineSource([C]),m,[],o.$("div"),!0).minWidthInPx});return Math.max(..._)}),this.startLineOffset=this._trimVertically.map(r=>r.topOffset),this.originalLines=this._state.map(r=>r?new a.LineRange(r.lineNumber,Math.min(r.lineNumber+2,this._editor.getModel().getLineCount()+1)):void 0),this._overlayLayout=o.derived(this,r=>{this._ghostText.read(r);const l=this._state.read(r);if(!l)return null;this._editorObs.observePosition(o.observableValue(this,new a.Position(l.lineNumber,l.column)),r.store).read(r);const d=this._editorObs.layoutInfo.read(r),h=this._editorObs.scrollLeft.read(r),u=this._editorObs.layoutInfoVerticalScrollbarWidth.read(r),g=d.contentLeft+this._editorMaxContentWidthInRange.read(r)-h,p=this._maxPrefixTrim.read(r).prefixLeftOffset??0,f=d.contentLeft+p-h;if(g<=f)return null;const{topOffset:m,contentHeight:_}=this._trimVertically.read(r),v=this._editorObs.scrollTop.read(r),b=this._editor.getTopForLineNumber(l.lineNumber)-v+m,C=b+_,y=new k(f,b,g,C);return{overlay:y,startsAtContentLeft:p===0,contentLeft:d.contentLeft,minContentWidthRequired:p+y.width+u}}).recomputeInitiallyAndOnChange(this._store),this._modifiedOverlay=o.n.div({style:{pointerEvents:"none"}},o.derived(this,r=>{const l=ht(this._overlayLayout).read(r);if(!l)return;const d=l.map(f=>k.fromLeftTopRightBottom(f.contentLeft-Kg-Ks,f.overlay.top,f.contentLeft,f.overlay.bottom)).read(r),h=this._input.map(f=>f?.editorType===te.DiffEditor?iR:tR).read(r),u=l.map(f=>f.overlay.withMargin(0,Ks,Ks,f.startsAtContentLeft?0:Ks).intersectHorizontal(new a.OffsetRange(d.left,Number.MAX_SAFE_INTEGER))),g=u.map(f=>f.withMargin(h,h)),p=ni(this._input.read(void 0)?.editorType??te.TextEditor);return[o.n.div({class:"originalUnderlayInsertion",style:{...g.read(r).toStyles(),borderRadius:Kg,border:`${Ks+h}px solid ${p}`,boxSizing:"border-box"}}),o.n.div({class:"originalOverlayInsertion",style:{...u.read(r).toStyles(),borderRadius:Kg,border:wr(this._tabAction).map(f=>`${Ks}px solid ${o.asCssVariable(f)}`),boxSizing:"border-box",backgroundColor:o.asCssVariable(Wv)}}),o.n.div({class:"originalOverlayHiderInsertion",style:{...d.toStyles(),backgroundColor:p}})]})).keepUpdated(this._store),this._view=o.n.div({class:"inline-edits-view",style:{position:"absolute",overflow:"visible",top:"0px",left:"0px",display:this._display}},[[this._modifiedOverlay]]).keepUpdated(this._store),this._editorObs=o.observableCodeEditor(this._editor),this._ghostTextView=this._register(n.createInstance(ur,this._editor,o.derived(r=>{const l=this._ghostText.read(r);if(l)return{ghostText:l,handleInlineCompletionShown:d=>{},warning:void 0}}),{extraClasses:["inline-edit"],isClickable:!0,shouldKeepCursorStable:!0})),this.isHovered=this._ghostTextView.isHovered,this._register(this._ghostTextView.onDidClick(r=>{this._onDidClick.fire(new Qt(r))})),this._register(this._editorObs.createOverlayWidget({domNode:this._view.element,position:o.constObservable(null),allowEditorOverflow:!1,minContentWidthInPx:o.derived(this,r=>{const l=this._overlayLayout.read(r);return l===null?0:l.minContentWidthRequired})}))}};kg=eR([rb(3,o.IInstantiationService),rb(4,o.ILanguageService)],kg);var nR=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},ab=function(c,e){return function(t,i){e(t,i,c)}};let Ug=class extends a.Disposable{constructor(e,t,i,n,s,r){super(),this._editor=e,this._edit=t,this._editorType=i,this._tabAction=n,this._languageService=s,this._themeService=r,this._onDidClick=this._register(new a.Emitter),this.onDidClick=this._onDidClick.event,this._maxPrefixTrim=this._edit.map((l,d)=>l?xg(l.replacements.flatMap(h=>[h.originalRange,h.modifiedRange]),l.originalRange,l.modifiedLines,this._editor.editor,d):void 0),this._modifiedLineElements=o.derived(this,l=>{const d=[];let h=0;const u=this._maxPrefixTrim.read(l),g=this._edit.read(l);if(!g||!u)return;const p=u.prefixTrim,f=sR(g.replacements.map(v=>v.modifiedRange)).map(v=>new a.Range(v.startLineNumber,v.startColumn-p,v.endLineNumber,v.endColumn-p)),m=this._editor.model.get(),_=g.modifiedRange.startLineNumber;for(let v=0;v<g.modifiedRange.length;v++){const b=document.createElement("div"),C=_+v,y=g.modifiedLines[v].slice(p),I=m.tokenization.tokenizeLinesAt(C,[y])?.[0];let x;I?x=o.TokenArray.fromLineTokens(I).toLineTokens(y,this._languageService.languageIdCodec):x=o.LineTokens.createEmpty(y,this._languageService.languageIdCodec);const S=[];for(const E of f.filter(L=>L.startLineNumber===C)){const L=Math.min(E.endColumn,y.length+1);S.push(new o.InlineDecoration(new a.Range(1,E.startColumn,1,L),"inlineCompletions-modified-bubble",0))}const w=o.renderLines(new o.LineSource([x]),o.RenderOptions.fromEditor(this._editor.editor).withSetWidth(!1).withScrollBeyondLastColumn(0),S,b,!0);this._editor.getOption(59).read(l),h=Math.max(h,w.minWidthInPx),d.push(b)}return{lines:d,requiredWidth:h}}),this._layout=o.derived(this,l=>{const d=this._modifiedLineElements.read(l),h=this._maxPrefixTrim.read(l),u=this._edit.read(l);if(!d||!h||!u)return;const{prefixLeftOffset:g}=h,{requiredWidth:p}=d,f=this._editor.observeLineHeightsForLineRange(u.originalRange).read(l),m=(()=>{const F=f.slice(0,u.modifiedRange.length);for(;F.length<u.modifiedRange.length;)F.push(f[f.length-1]);return F})(),_=this._editor.layoutInfoContentLeft.read(l),v=this._editor.layoutInfoVerticalScrollbarWidth.read(l),b=this._editor.scrollLeft.read(l),C=this._editor.scrollTop.read(l),y=_-b,I=this._editor.editor.getModel(),x=u.originalRange.mapToLineArray(F=>this._editor.editor.getOffsetForColumn(F,I.getLineMaxColumn(F))-g),S=Math.max(...x,p),w=u.originalRange.startLineNumber,E=u.originalRange.endLineNumberExclusive-1,L=this._editor.editor.getTopForLineNumber(w)-C,R=this._editor.editor.getBottomForLineNumber(E)-C,D=k.fromLeftTopWidthHeight(y+g,L,S,R-L),T=k.fromLeftTopWidthHeight(D.left,D.bottom,D.width,m.reduce((F,K)=>F+K,0)),P=k.hull([D,T]),M=P.intersectVertical(new a.OffsetRange(D.bottom,Number.MAX_SAFE_INTEGER)),V=new k(M.left,M.top,M.right,M.bottom);return{originalLinesOverlay:D,modifiedLinesOverlay:T,background:P,lowerBackground:M,lowerText:V,modifiedLineHeights:m,minContentWidthRequired:g+S+v}}),this._viewZoneInfo=o.derived(l=>{if(!this._editor.getOption(71).map(f=>f.edits.allowCodeShifting==="always").read(l))return;const h=this._layout.read(l),u=this._edit.read(l);if(!h||!u)return;const g=h.lowerBackground.height,p=u.originalRange.endLineNumberExclusive;return{height:g,lineNumber:p}}),this.minEditorScrollHeight=o.derived(this,l=>{const d=ht(this._layout).read(l);return!d||this._viewZoneInfo.read(l)!==void 0?0:d.read(l).lowerText.bottom+this._editor.editor.getScrollTop()}),this._div=o.n.div({class:"line-replacement"},[o.derived(this,l=>{const d=ht(this._layout).read(l),h=this._modifiedLineElements.read(l);if(!d||!h)return[];const u=d.read(l),g=this._editor.layoutInfoContentLeft.read(l),p=this._editorType.read(l)===te.DiffEditor?3:1;h.lines.forEach((v,b)=>{v.style.width=`${u.lowerText.width}px`,v.style.height=`${u.modifiedLineHeights[b]}px`,v.style.position="relative"});const f=wr(this._tabAction).read(l),m=Al(this._tabAction).read(l),_=ni(this._editorType.read(l));return[o.n.div({style:{position:"absolute",..._e(v=>Lg(this._editor).read(v)),overflow:"hidden",pointerEvents:"none"}},[o.n.div({class:"borderAroundLineReplacement",style:{position:"absolute",..._e(v=>d.read(v).background.translateX(-g).withMargin(p)),borderRadius:`${me}px`,border:`${p+1}px solid ${_}`,boxSizing:"border-box",pointerEvents:"none"}}),o.n.div({class:"originalOverlayLineReplacement",style:{position:"absolute",..._e(v=>d.read(v).background.translateX(-g)),borderRadius:`${me}px`,border:de(m,this._themeService).map(v=>`1px solid ${v.toString()}`),pointerEvents:"none",boxSizing:"border-box",background:o.asCssVariable(vr)}}),o.n.div({class:"modifiedOverlayLineReplacement",style:{position:"absolute",..._e(v=>d.read(v).lowerBackground.translateX(-g)),borderRadius:`0 0 ${me}px ${me}px`,background:_,boxShadow:`${o.asCssVariable(o.scrollbarShadow)} 0 6px 6px -6px`,border:`1px solid ${o.asCssVariable(f)}`,boxSizing:"border-box",overflow:"hidden",cursor:"pointer",pointerEvents:"auto"},onmousedown:v=>{v.preventDefault()},onclick:v=>this._onDidClick.fire(Qt.create(v))},[o.n.div({style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",background:o.asCssVariable(CD)}})]),o.n.div({class:"modifiedLinesLineReplacement",style:{position:"absolute",boxSizing:"border-box",..._e(v=>d.read(v).lowerText.translateX(-g)),fontFamily:this._editor.getOption(58),fontSize:this._editor.getOption(61),fontWeight:this._editor.getOption(62),pointerEvents:"none",whiteSpace:"nowrap",borderRadius:`0 0 ${me}px ${me}px`,overflow:"hidden"}},[...h.lines])])]})]).keepUpdated(this._store),this.isHovered=this._editor.isTargetHovered(l=>this._isMouseOverWidget(l),this._store),this._previousViewZoneInfo=void 0,this._register(a.toDisposable(()=>this._editor.editor.changeViewZones(l=>this.removePreviousViewZone(l)))),this._register(o.autorunDelta(this._viewZoneInfo,({lastValue:l,newValue:d})=>{l===d||l?.height===d?.height&&l?.lineNumber===d?.lineNumber||this._editor.editor.changeViewZones(h=>{this.removePreviousViewZone(h),d&&this.addViewZone(d,h)})})),this._register(this._editor.createOverlayWidget({domNode:this._div.element,minContentWidthInPx:o.derived(this,l=>this._layout.read(l)?.minContentWidthRequired??0),position:o.constObservable({preference:{top:0,left:0}}),allowEditorOverflow:!1}))}_isMouseOverWidget(e){const t=this._layout.get();return!t||!(e.event instanceof o.EditorMouseEvent)?!1:t.lowerBackground.containsPoint(new o.Point(e.event.relativePos.x,e.event.relativePos.y))}removePreviousViewZone(e){if(!this._previousViewZoneInfo)return;e.removeZone(this._previousViewZoneInfo.id);const t=this._editor.cursorLineNumber.get();t!==null&&t>=this._previousViewZoneInfo.lineNumber&&this._editor.editor.setScrollTop(this._editor.scrollTop.get()-this._previousViewZoneInfo.height),this._previousViewZoneInfo=void 0}addViewZone(e,t){const i=t.addZone({afterLineNumber:e.lineNumber-1,heightInPx:e.height,domNode:o.$("div")});this._previousViewZoneInfo={height:e.height,lineNumber:e.lineNumber,id:i};const n=this._editor.cursorLineNumber.get();n!==null&&n>=e.lineNumber&&this._editor.editor.setScrollTop(this._editor.scrollTop.get()+e.height)}};Ug=nR([ab(4,o.ILanguageService),ab(5,o.IThemeService)],Ug);function sR(c){const e=[];for(;c.length;){let t=c.shift();t.startLineNumber!==t.endLineNumber&&(c.push(new a.Range(t.startLineNumber+1,1,t.endLineNumber,t.endColumn)),t=new a.Range(t.startLineNumber,t.startColumn,t.startLineNumber,Number.MAX_SAFE_INTEGER)),e.push(t)}return e}function oR(c,e){const t={};for(const[r,l]of Object.entries(e))Array.isArray(l)?t[r]={min:0,rules:l}:t[r]={min:l.min??0,rules:l.rules??[{max:l.max,priority:l.priority,share:l.share}]};const i={};let n=0;for(const[r,l]of Object.entries(t))i[r]=l.min,n+=l.min;if(n>c)return null;let s=c-n;for(;s>0;){const r=[];for(const[p,f]of Object.entries(t))for(let m=0;m<f.rules.length;m++){const _=f.rules[m],v=i[p],b=_.max??1/0;v<b&&r.push({partKey:p,ruleIndex:m,rule:_,priority:_.priority??0,share:_.share??1})}if(r.length===0)break;const l=Math.max(...r.map(p=>p.priority)),d=r.filter(p=>p.priority===l),h=d.reduce((p,f)=>p+f.share,0);let u=0;const g=[];for(const p of d){const f=p.rule,m=i[p.partKey],v=(f.max??1/0)-m,b=s*p.share/h,C=Math.min(b,v);g.push({partKey:p.partKey,ruleIndex:p.ruleIndex,amount:C}),u+=C}if(u===0)break;for(const p of g)i[p.partKey]+=p.amount;if(s-=u,s<1e-4)break}return i}var rR=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},$g=function(c,e){return function(t,i){e(t,i,c)}};let jg=class extends a.Disposable{constructor(e,t,i,n,s,r){super(),this._editor=e,this._data=i,this._themeService=n,this._keybindingService=s,this._contextKeyService=r,this._styles=o.derived(this,d=>({background:de(Cr,this._themeService).read(d).toString(),foreground:de(br,this._themeService).read(d).toString(),border:de(ii,this._themeService).read(d).toString()})),this._pos=o.derived(this,d=>this._editor.observePosition(o.derived(h=>this._data.read(h)?.jumpToPosition||null),d.store)).flatten(),this._layout=o.derived(this,d=>{const h=this._data.read(d);if(!h)return;const u=h.jumpToPosition,g=this._editor.observeLineHeightForLine(o.constObservable(u.lineNumber)).read(d),p=this._editor.scrollLeft.read(d),f=this._pos.read(d);if(!f)return;const m=this._editor.layoutInfo.read(d);return{widgetRect:k.fromLeftTopWidthHeight(f.x+m.contentLeft+2-p,f.y,100,g)}}),this._blink=aR([{value:!0,durationMs:600},{value:!1,durationMs:600}]),this._widget=o.n.div({class:"inline-edit-jump-to-widget",style:{position:"absolute",display:this._layout.map(d=>d?"flex":"none"),alignItems:"center",cursor:"pointer",userSelect:"none",..._e(d=>this._layout.read(d)?.widgetRect)}},o.derived(d=>this._data.read(d)===void 0?[]:o.n.div({style:{display:"flex",alignItems:"center",gap:"4px",padding:"0 4px",height:"100%",backgroundColor:this._styles.map(h=>h.background),"--vscodeIconForeground":this._styles.map(h=>h.foreground),border:this._styles.map(h=>`1px solid ${h.border}`),borderRadius:"3px",boxSizing:"border-box",fontSize:"11px",color:this._styles.map(h=>h.foreground)}},[this._style==="cursor"?o.n.elem("div",{style:{borderLeft:"2px solid",height:14,opacity:this._blink.map(h=>h?"0":"1")}}):[o.derived(()=>o.n.elem("div",{},lR(this._keybinding))),o.n.elem("div",{style:{lineHeight:this._layout.map(h=>h?.widgetRect.height),marginTop:"-2px"}},["to jump"])]]))),this._style=t.style,this._keybinding=this._getKeybinding(Qi);const l=this._widget.keepUpdated(this._store);this._register(this._editor.createOverlayWidget({domNode:l.element,position:o.constObservable(null),allowEditorOverflow:!1,minContentWidthInPx:o.constObservable(0)})),this._register(this._editor.setDecorations(o.derived(d=>{const h=this._data.read(d);return h?[{range:a.Range.fromPositions(h.jumpToPosition,h.jumpToPosition),options:{description:"inline-edit-jump-to-decoration",inlineClassNameAffectsLetterSpacing:!0,showIfCollapsed:!0,after:{content:this._style==="label"?" ":" "}}}]:[]})))}_getKeybinding(e,t=o.DebugLocation.ofCaller()){return e?o.observableFromEvent(this,this._contextKeyService.onDidChangeContext,()=>this._keybindingService.lookupKeybinding(e),t):o.constObservable(void 0)}};jg=rR([$g(3,o.IThemeService),$g(4,o.IKeybindingService),$g(5,o.IContextKeyService)],jg);function aR(c,e=o.DebugLocation.ofCaller()){let t=0;return o.observableFromEvent(void 0,i=>{t=0;const n=new a.RunOnceScheduler(()=>{t=(t+1)%c.length,i(null),n.schedule(c[t].durationMs)},0);return n.schedule(0),n},()=>c[t].value,e)}function lR(c){return o.derived(e=>o.n.div({style:{},ref:t=>{const i=e.store.add(new o.KeybindingLabel(t,a.OS,{disableTitle:!0,...o.defaultKeybindingLabelStyles,keybindingLabelShadow:void 0,keybindingLabelForeground:o.asCssVariable(br),keybindingLabelBackground:"transparent",keybindingLabelBorder:o.asCssVariable(br),keybindingLabelBottomBorder:void 0}));e.store.add(o.autorun(n=>{i.set(c.read(n))}))}}))}var cR=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},dR=function(c,e){return function(t,i){e(t,i,c)}};function hR(c,e,t){const i=Math.max(1,Math.min(t,c)),n=Math.max(1,i-e),s=Math.min(t+1,i+e+1);return new a.LineRange(n,s)}let qg=class extends a.Disposable{constructor(e,t,i,n,s){super(),this._previewTextModel=e,this._properties=t,this._parentEditor=i,this._tabAction=n,this._instantiationService=s,this._previewRef=o.n.ref(),this.element=o.n.div({class:"preview",style:{},ref:this._previewRef}),this._state=o.derived(this,r=>{const l=this._properties.read(r);if(!l)return;let d,h;l.nextCursorPosition!==null?(d="original",h=l.nextCursorPosition.lineNumber):l.diff[0].innerChanges?.every(m=>m.modifiedRange.isEmpty())?(d="original",h=l.diff[0].original.startLineNumber):(d="modified",h=l.diff[0].modified.startLineNumber);const u=d==="modified"?Ns.snapshot(this._previewTextModel):l.target,g=this._parentEditorObs.getOption(71).read(r).edits.longDistanceHintContextLineCount,p=d==="modified"?this._previewTextModel:l.target.dangerouslyGetUnderlyingModel(),f=hR(h,g,p.getLineCount());return{mode:d,targetLineNumber:h,visibleLineRange:f,textModel:u,diff:l.diff}}),this.updatePreviewEditorEffect=o.derived(this,r=>{this._previewEditorObs.model.read(r);const l=this._state.read(r)?.visibleLineRange;if(!l)return;const d=[];l.startLineNumber>1&&d.push(new a.Range(1,1,l.startLineNumber-1,1)),l.endLineNumberExclusive<this._previewTextModel.getLineCount()+1&&d.push(new a.Range(l.endLineNumberExclusive,1,this._previewTextModel.getLineCount()+1,1)),this.previewEditor.setHiddenAreas(d,void 0,!0)}),this.horizontalContentRangeInPreviewEditorToShow=o.derived(this,r=>this._getHorizontalContentRangeInPreviewEditorToShow(this.previewEditor,r)),this.contentHeight=o.derived(this,r=>{const l=this._state.read(r);return l?this._previewEditorObs.observeLineHeightsForLineRange(l.visibleLineRange).map(d=>d.reduce((h,u)=>h+u,0)):o.constObservable(null)}).flatten(),this._editorDecorations=o.derived(this,r=>{const l=this._state.read(r);if(!l)return;const d={diff:l.diff},h=[],u=[],g=o.ModelDecorationOptions.register({className:"inlineCompletions-char-delete",description:"char-delete",isWholeLine:!1,zIndex:1}),p=o.ModelDecorationOptions.register({className:"inlineCompletions-char-insert",description:"char-insert",isWholeLine:!0}),f=o.ModelDecorationOptions.register({className:"inlineCompletions-char-insert",description:"char-insert",shouldFillLineOnLineBreak:!0});for(const m of d.diff)if(m.modified.isEmpty||m.original.isEmpty)m.original.isEmpty||h.push({range:m.original.toInclusiveRange(),options:g}),m.modified.isEmpty||u.push({range:m.modified.toInclusiveRange(),options:p});else for(const _ of m.innerChanges||[])m.original.contains(_.originalRange.startLineNumber)&&!_.originalRange.isEmpty()&&h.push({range:_.originalRange,options:{description:"char-delete",shouldFillLineOnLineBreak:!1,className:Fl("inlineCompletions-char-delete",_.originalRange.isEmpty()&&"empty"),zIndex:1}}),m.modified.contains(_.modifiedRange.startLineNumber)&&u.push({range:_.modifiedRange,options:f});return{originalDecorations:h,modifiedDecorations:u}}),this.previewEditor=this._register(this._createPreviewEditor()),this._parentEditorObs=o.observableCodeEditor(this._parentEditor),this._register(o.autorun(r=>{const l=this._state.read(r)?.textModel||null;l&&this.previewEditor.setModel(l.dangerouslyGetUnderlyingModel())})),this._previewEditorObs=o.observableCodeEditor(this.previewEditor),this._register(this._previewEditorObs.setDecorations(o.derived(r=>{const l=this._state.read(r),d=this._editorDecorations.read(r);return(l?.mode==="original"?d?.originalDecorations:d?.modifiedDecorations)??[]}))),this._register(o.autorun(r=>{if(!this._properties.read(r))return;const l=this._parentEditorObs.cursorPosition.read(r);l&&this.previewEditor.setPosition(this._previewTextModel.validatePosition(l),"longDistanceHintPreview")})),this._register(o.autorun(r=>{const l=this._state.read(r);if(!l)return;const d=(l.visibleLineRange.endLineNumberExclusive-1).toString().length;this.previewEditor.updateOptions({lineNumbersMinChars:d+1})})),this._register(this._instantiationService.createInstance(Bl,this._previewEditorObs,o.derived(r=>{const l=this._state.read(r);if(!l)return;const d=this._properties.read(r);if(d)return new tb(d.inlineSuggestInfo,a.LineRange.ofLength(l.targetLineNumber,1),d.model,void 0)}),this._tabAction,o.constObservable(0),o.constObservable(!1),o.observableValue(this,!1))),this.updatePreviewEditorEffect.recomputeInitiallyAndOnChange(this._store)}_createPreviewEditor(){return this._instantiationService.createInstance(ct,this._previewRef.element,{glyphMargin:!1,lineNumbers:"on",minimap:{enabled:!1},guides:{indentation:!1,bracketPairs:!1,bracketPairsHorizontal:!1,highlightActiveIndentation:!1},editContext:!1,rulers:[],padding:{top:0,bottom:0},selectOnLineNumbers:!1,selectionHighlight:!1,columnSelection:!1,overviewRulerBorder:!1,overviewRulerLanes:0,revealHorizontalRightPadding:0,bracketPairColorization:{enabled:!0,independentColorPoolPerBracketType:!1},scrollBeyondLastLine:!1,scrollbar:{vertical:"hidden",horizontal:"hidden",handleMouseWheel:!1},readOnly:!0,wordWrap:"off",wordWrapOverride1:"off",wordWrapOverride2:"off"},{contextKeyValues:{[B.inInlineEditsPreviewEditor.key]:!0},contributions:[]},this._parentEditor)}_getHorizontalContentRangeInPreviewEditorToShow(e,t){const i=this._state.read(t);if(!i)return;const n=i.diff,s=this._properties.read(t)?.nextCursorPosition,r=i.visibleLineRange,l=this._previewEditorObs.layoutInfo.read(t),d=At(this._previewEditorObs,r,t);let h;if(s)h=a.Range.fromPositions(s);else if(n[0].innerChanges)h=i.mode==="modified"?n[0].innerChanges[0].modifiedRange:n[0].innerChanges[0].originalRange;else return;const u=uR(e.getModel(),h,5),g=this._previewEditorObs.getLeftOfPosition(u.getStartPosition(),t),p=this._previewEditorObs.getLeftOfPosition(u.getEndPosition(),t),f=o.clamp(g,0,d),m=o.clamp(p,f,d),_=e.getModel().getLineFirstNonWhitespaceColumn(u.startLineNumber),v=this._previewEditorObs.getLeftOfPosition(new a.Position(u.startLineNumber,_),t),b=new a.OffsetRange(f,m);return{indentationEnd:v,preferredRangeToReveal:b,maxEditorWidth:d+l.contentLeft,contentWidth:d,nonContentWidth:l.contentLeft}}layout(e,t){this.previewEditor.layout(e),this._previewEditorObs.editor.setScrollLeft(t)}};qg=cR([dR(4,o.IInstantiationService)],qg);function uR(c,e,t){const i=e.getStartPosition(),n=e.getEndPosition(),s=c.getLineContent(i.lineNumber);function r(u){const g=s.charAt(u-1);return/[a-zA-Z0-9_]/.test(g)}function l(u){const g=s.charAt(u-1);return g===" "||g===" "}let d=i.column;for(;d>1&&r(d)&&!l(d-1)&&i.column-d<t;)d--;let h=n.column-1;for(;h<=s.length&&r(h)&&!l(h+1)&&h-n.column<t;)h++;return new a.Range(i.lineNumber,d,n.lineNumber,h+1)}function gR(c,e){const t=c.start,i=c.endExclusive;let n=Number.MAX_VALUE,s=0;for(const r of e){const l=s+r.width,d=Math.max(t,s),h=Math.min(i,l);d<h&&(n=Math.min(n,r.height)),s=l}return i>s||n===Number.MAX_VALUE?0:n}class lb{constructor(e,t,i){this._lineRangeInfo=e,this.availableSpaceSizes=e.sizes.map((n,s)=>{const r=e.lineRange.startLineNumber+s,l=i(r);return new gr(Math.max(0,t-n.width-l),n.height)}),this.availableSpaceHeightPrefixSums=mR(this.availableSpaceSizes,n=>n.height),this.availableSpaceSizesTransposed=this.availableSpaceSizes.map(n=>n.transpose())}getWidgetVerticalOutline(e,t,i){const n=e-this._lineRangeInfo.lineRange.startLineNumber,s=this._lineRangeInfo.top+this.availableSpaceHeightPrefixSums[n],r=a.OffsetRange.ofStartAndLength(s,t),{previewEditorMargin:l,widgetPadding:d,widgetBorder:h,lowerBarHeight:u}=i;return r.withMargin(l+d+h).withMargin(0,u)}tryFindWidgetOutline(e,t,i,n){if(!(this._lineRangeInfo.lineRange.length<3))return fR(this._lineRangeInfo.lineRange.addMargin(-1,-1),e,s=>{const r=this.getWidgetVerticalOutline(s,t,n),l=gR(r.delta(-this._lineRangeInfo.top),this.availableSpaceSizesTransposed);return l<n.minWidgetWidth?void 0:{horizontalWidgetRange:a.OffsetRange.ofStartAndLength(i-l,l),verticalWidgetRange:r}})}}function pR(c,e,t,i,n){const s=[];let r=c.startLineNumber,l=t,d=[];for(let h=0;h<e.length;h++){const u=c.startLineNumber+h,g=l+d.reduce((f,m)=>f+m.height,0),p=i.editor.getTopForLineNumber(u);h>0&&p!==g&&(s.push({lineRange:a.LineRange.ofLength(r,u-r),top:l,sizes:d}),r=u,l=p,d=[]),d.push(e[h])}return s.push({lineRange:a.LineRange.ofLength(r,c.endLineNumberExclusive-r),top:l,sizes:d}),o.derived({owner:"splitIntoContinuousLineRanges"},h=>i.observeTopForLineNumber(c.endLineNumberExclusive-1).read(h)).read(n),s}function fR(c,e,t){for(let i=0;;i++){const n=e+i;if(n<=c.endLineNumberExclusive){const r=t(n);if(r!==void 0)return r}const s=e-i;if(s>=c.startLineNumber){const r=t(s);if(r!==void 0)return r}if(s<c.startLineNumber&&n>c.endLineNumberExclusive)return}}function mR(c,e){const t=[0];let i=0;for(const n of c)i+=e(n),t.push(i);return t}var _R=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Er=function(c,e){return function(t,i){e(t,i,c)}};const vR=6,Gg={EMPTY_SPACE:425,OVERLAY:375},bR={previewEditorMargin:2,widgetPadding:2,widgetBorder:1,lowerBarHeight:20,minWidgetWidth:250};let Zg=class extends a.Disposable{constructor(e,t,i,n,s,r,l,d,h){super(),this._editor=e,this._viewState=t,this._previewTextModel=i,this._tabAction=n,this._instantiationService=s,this._themeService=r,this._keybindingService=l,this._modelService=d,this._languageService=h,this.onDidClick=a.Event.None,this._viewWithElement=void 0,this._hintTextPosition=o.derived(this,u=>{const g=this._viewState.read(u);return g?new a.Position(g.hint.lineNumber,Number.MAX_SAFE_INTEGER):null}),this._lineSizesAroundHintPosition=o.derived(this,u=>{const g=this._viewState.read(u),p=this._hintTextPosition.read(u);if(!g||!p)return[];const f=this._editorObs.model.read(u);if(!f)return[];const m=a.LineRange.ofLength(p.lineNumber,1).addMargin(5,5).intersect(a.LineRange.ofLength(1,f.getLineCount()));if(!m)return[];const _=DD(this._editorObs,m,u),v=this._editorObs.observeTopForLineNumber(m.startLineNumber).read(u);return pR(m,_,v,this._editorObs,u)}),this._isVisibleDelayed=o.debouncedObservable2(o.derived(this,u=>this._viewState.read(u)?.hint.isVisible),(u,g)=>u===!0&&g===!1?200:0),this._previewEditorLayoutInfo=o.derived(this,u=>{const g=this._viewState.read(u);if(!g||!this._isVisibleDelayed.read(u))return;const p=this._lineSizesAroundHintPosition.read(u);if(p.length===0)return;const f=this._editorObs.scrollTop.read(u),m=this._editorObs.scrollLeft.read(u),_=this._editorObs.layoutInfo.read(u),v=this._previewEditor.contentHeight.read(u),b=this._previewEditor.horizontalContentRangeInPreviewEditorToShow.read(u);if(!v||!b)return;const C=_.contentWidth-_.verticalScrollbarWidth,y=_.contentLeft+C;if(!this._editorObs.cursorLineNumber.read(u))return;const x=bR,w=v+2;let E,L;const R=je=>je===g.hint.lineNumber?40:20;for(const je of p){const yt=new lb(je,C,R);if(L=yt,E=yt.tryFindWidgetOutline(g.hint.lineNumber,w,y,x),E)break}let D="empty-space";if(!E){D="overlay";const je=Math.min(_.width-_.contentLeft,Gg.OVERLAY),yt=L??new lb(p[0],C,R);E={horizontalWidgetRange:a.OffsetRange.ofStartAndLength(y-je,je),verticalWidgetRange:yt.getWidgetVerticalOutline(g.hint.lineNumber+2,w,x).delta(10)}}if(!E)return;const T=k.fromRanges(E.horizontalWidgetRange,E.verticalWidgetRange).translateX(-m).translateY(-f),{previewEditorMargin:P,widgetPadding:M,widgetBorder:V,lowerBarHeight:F}=x,K=D==="overlay"?Gg.OVERLAY:Gg.EMPTY_SPACE,O=b.maxEditorWidth+P+M,z=Math.min(K,Math.max(O,x.minWidgetWidth)),Q=oR(T.width,{spaceBefore:{min:0,max:10,priority:1},content:{min:50,rules:[{max:150,priority:2},{max:z,priority:1}]},spaceAfter:{min:10}});if(!Q)return null;const j=CR([Q.spaceBefore,Q.content,Q.spaceAfter],T.left);T.withHorizontalRange(j[0]);const U=T.withHorizontalRange(j[1]);T.withHorizontalRange(j[2]);const W=U.withMargin(-M-V-P).withMargin(0,0,-F,0),Y=W.width-b.nonContentWidth,G=Y*.8,ae=b.preferredRangeToReveal.intersect(a.OffsetRange.ofStartAndLength(b.preferredRangeToReveal.start,G))??b.preferredRangeToReveal,Fi=SR(b.indentationEnd,Y,ae);return{codeEditorSize:W.getSize(),codeScrollLeft:m,contentLeft:_.contentLeft,widgetRect:U,previewEditorMargin:P,widgetPadding:M,widgetBorder:V,lowerBarHeight:F,desiredPreviewEditorScrollLeft:Fi.newScrollPosition}}),this._view=o.n.div({class:"inline-edits-view",style:{position:"absolute",overflow:"visible",top:"0px",left:"0px",display:o.derived(this,u=>this._previewEditorLayoutInfo.read(u)?"block":"none")}},[o.derived(this,u=>[this._widgetContent])]),this._widgetContent=o.derived(this,u=>o.n.div({class:["inline-edits-long-distance-hint-widget","show-file-icons"],style:{position:"absolute",overflow:"hidden",cursor:"pointer",background:o.asCssVariable(o.editorWidgetBackground),padding:this._previewEditorLayoutInfo.map(g=>g?.widgetPadding),boxSizing:"border-box",borderRadius:vR,border:o.derived(g=>`${this._previewEditorLayoutInfo.read(g)?.widgetBorder}px solid ${this._styles.read(g).border}`),display:"flex",flexDirection:"column",opacity:o.derived(g=>this._viewState.read(g)?.hint.isVisible?"1":"0"),transition:"opacity 200ms ease-in-out",..._e(g=>this._previewEditorLayoutInfo.read(g)?.widgetRect)},onmousedown:g=>{g.preventDefault()},onclick:()=>{this._viewState.read(void 0)?.model.jump()}},[o.n.div({class:["editorContainer"],style:{overflow:"hidden",padding:this._previewEditorLayoutInfo.map(g=>g?.previewEditorMargin),background:this._styles.map(g=>g.background),pointerEvents:"none"}},[o.derived(this,g=>this._previewEditor.element)]),o.n.div({class:"bar",style:{color:o.asCssVariable(o.descriptionForeground),pointerEvents:"none",margin:"0 4px",height:this._previewEditorLayoutInfo.map(g=>g?.lowerBarHeight),display:"flex",justifyContent:"space-between",alignItems:"center"}},[o.derived(this,g=>{const p=[],f=this._viewState.read(g);if(!f)return p;const m=this._editorObs.model.read(g),_=f.target.uri,v=!m||!f.target.targets(m);if(v){const x=o.basename(_),S=dr(this._modelService,this._languageService,_,We.FILE);p.push(o.n.div({class:"target-file",style:{display:"flex",alignItems:"center",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},[o.n.elem("span",{class:S,style:{flexShrink:"0",marginRight:"4px"}}),x]))}else{const x=this._originalOutlineSource.read(g),S=this._originalTargetLineNumber.read(g),w=x?.getAt(S,g).slice(0,1)??[],E=[];if(w.length>0)for(let L=0;L<w.length;L++){const R=w[L],D=a.SymbolKinds.toIcon(R.kind);E.push(o.n.div({class:"breadcrumb-item",style:{display:"flex",alignItems:"center",flex:"1 1 auto",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},[o.renderIcon(D)," ",R.name,...L===w.length-1?[]:[o.renderIcon(a.Codicon.chevronRight)]]))}p.push(o.n.div({class:"outline-elements",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},E))}const b=this._originalTargetLineNumber.read(g),C=v?a.Codicon.arrowRight:f.hint.lineNumber<b?a.Codicon.arrowDown:a.Codicon.arrowUp,y=this._keybindingService.lookupKeybinding(ih);let I=v?"Go to file":"Go to suggestion";return y&&y.getLabel()==="Tab"&&(I=v?"Tab to open":"Tab to jump"),p.push(o.n.div({class:"go-to-label",style:{position:"relative",display:"flex",alignItems:"center",flex:"0 0 auto",paddingLeft:"6px"}},[I," ",o.renderIcon(C)])),p})])])),this._originalTargetLineNumber=o.derived(this,u=>{const g=this._viewState.read(u);return g?g.edit.action?.kind==="jumpTo"?g.edit.action.position.lineNumber:g.diff[0]?.original.startLineNumber??-1:-1}),this._originalOutlineSource=o.derivedDisposable(this,u=>{const g=this._editorObs.model.read(u),p=o.HideUnchangedRegionsFeature._breadcrumbsSourceFactory.read(u);return!g||!p?void 0:p(g,this._instantiationService)}),this._styles=o.derived(u=>{const g=this._tabAction.read(u),p=Bs(o.editorWidgetBorder,this._themeService).read(u),f=o.observableFromEvent(this._themeService.onDidColorThemeChange,()=>{const _=this._themeService.getColorTheme();return _.type==="hcDark"||_.type==="hcLight"}).read(u);let m;if(f)m=p;else{let _;switch(g){case H.Inactive:_=wg;break;case H.Jump:_=Cr;break;case H.Accept:_=Ig;break}m=de(_,this._themeService).read(u)}return{border:m.toString(),background:ni(this._viewState.map(_=>_?.editorType??te.TextEditor).read(u))}}),this._editorObs=o.observableCodeEditor(this._editor),this._previewEditor=this._register(this._instantiationService.createInstance(qg,this._previewTextModel,o.derived(u=>{const g=this._viewState.read(u);if(g)return{diff:g.diff,model:g.model,inlineSuggestInfo:g.inlineSuggestInfo,nextCursorPosition:g.nextCursorPosition,target:g.target}}),this._editor,this._tabAction)),this._viewWithElement=this._view.keepUpdated(this._store),this._register(this._editorObs.createOverlayWidget({domNode:this._viewWithElement.element,position:o.constObservable(null),allowEditorOverflow:!1,minContentWidthInPx:o.constObservable(0)})),this._widgetContent.get().keepUpdated(this._store),this._register(o.autorun(u=>{const g=this._previewEditorLayoutInfo.read(u);g&&this._previewEditor.layout(g.codeEditorSize.toDimension(),g.desiredPreviewEditorScrollLeft)})),this._isVisibleDelayed.recomputeInitiallyAndOnChange(this._store)}get isHovered(){return this._widgetContent.get().didMouseMoveDuringHover}};Zg=_R([Er(4,o.IInstantiationService),Er(5,o.IThemeService),Er(6,o.IKeybindingService),Er(7,o.IModelService),Er(8,o.ILanguageService)],Zg);function CR(c,e=0){const t=[];let i=e;for(const n of c)t.push(new a.OffsetRange(i,i+n)),i+=n;return t}function SR(c,e,t){const i=new a.OffsetRange(c,c+e);return i.containsRange(t)?{newScrollPosition:c}:t.length>e?{newScrollPosition:t.start}:t.endExclusive>i.endExclusive?{newScrollPosition:t.endExclusive-e}:t.start<i.start?{newScrollPosition:t.start}:{newScrollPosition:c}}var yR=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Xg=function(c,e){return function(t,i){e(t,i,c)}};const ks=0,Lr=0,et=1,wR=1,IR=3,zt=me,Yg=20,cb=12;let Ul=class extends a.Disposable{static fitsInsideViewport(e,t,i,n){const s=o.observableCodeEditor(e),r=s.layoutInfoWidth.read(n),l=s.layoutInfoContentLeft.read(n),d=e.getLayoutInfo().verticalScrollbarWidth,h=s.layoutInfoMinimap.read(n).minimapLeft!==0?s.layoutInfoMinimap.read(n).minimapWidth:0,u=At(s,i.displayRange,void 0),g=i.lineEdit.newLines.reduce((m,_)=>Math.max(m,Eg(_,e,t)),0),p=Yg,f=cb+2*et;return u+g+p+f<r-l-d-h}constructor(e,t,i,n,s,r,l,d){super(),this._editor=e,this._edit=t,this._previewTextModel=i,this._uiState=n,this._tabAction=s,this._instantiationService=r,this._themeService=l,this._userInteractionService=d,this._onDidClick=this._register(new a.Emitter),this.onDidClick=this._onDidClick.event,this._editorObs=o.observableCodeEditor(this._editor),this._display=o.derived(this,g=>this._uiState.read(g)?"block":"none"),this.previewRef=o.n.ref();const h=this._uiState.map(g=>g?.editorType===te.DiffEditor?IR:wR);this._editorContainer=o.n.div({class:["editorContainer"],style:{position:"absolute",overflow:"hidden",cursor:"pointer"},onmousedown:g=>{g.preventDefault()},onclick:g=>{this._onDidClick.fire(Qt.create(g))}},[o.n.div({class:"preview",style:{pointerEvents:"none"},ref:this.previewRef})]).keepUpdated(this._store),this.isHovered=this._userInteractionService.createHoverTracker(this._editorContainer.element,this._store),this.previewEditor=this._register(this._instantiationService.createInstance(ct,this.previewRef.element,{glyphMargin:!1,lineNumbers:"off",minimap:{enabled:!1},guides:{indentation:!1,bracketPairs:!1,bracketPairsHorizontal:!1,highlightActiveIndentation:!1},editContext:!1,rulers:[],padding:{top:0,bottom:0},folding:!1,selectOnLineNumbers:!1,selectionHighlight:!1,columnSelection:!1,overviewRulerBorder:!1,overviewRulerLanes:0,lineDecorationsWidth:0,lineNumbersMinChars:0,revealHorizontalRightPadding:0,bracketPairColorization:{enabled:!0,independentColorPoolPerBracketType:!1},scrollBeyondLastLine:!1,scrollbar:{vertical:"hidden",horizontal:"hidden",handleMouseWheel:!1},readOnly:!0,wordWrap:"off",wordWrapOverride1:"off",wordWrapOverride2:"off"},{contextKeyValues:{[B.inInlineEditsPreviewEditor.key]:!0},contributions:[]},this._editor)),this._previewEditorObs=o.observableCodeEditor(this.previewEditor),this._activeViewZones=[],this._updatePreviewEditor=o.derived(this,g=>{this._editorContainer.readEffect(g),this._previewEditorObs.model.read(g),this._display.read(g),this._nonOverflowView&&(this._nonOverflowView.element.style.display=this._display.read(g));const p=this._uiState.read(g),f=this._edit.read(g);if(!p||!f)return;const m=f.originalLineRange,_=[];m.startLineNumber>1&&_.push(new a.Range(1,1,m.startLineNumber-1,1)),m.startLineNumber+p.newTextLineCount<this._previewTextModel.getLineCount()+1&&_.push(new a.Range(m.startLineNumber+p.newTextLineCount,1,this._previewTextModel.getLineCount()+1,1)),this.previewEditor.setHiddenAreas(_,void 0,!0);const v=[...this._activeViewZones];this._activeViewZones=[];const b=m.endLineNumberExclusive-m.startLineNumber-p.newTextLineCount;this.previewEditor.changeViewZones(C=>{v.forEach(y=>C.removeZone(y)),b>0&&this._activeViewZones.push(C.addZone({afterLineNumber:m.startLineNumber+p.newTextLineCount-1,heightInLines:b,showInHiddenAreas:!0,domNode:o.$("div.diagonal-fill.inline-edits-view-zone")}))})}),this._previewEditorWidth=o.derived(this,g=>{const p=this._edit.read(g);return p?(this._updatePreviewEditor.read(g),At(this._previewEditorObs,p.modifiedLineRange,g)):0}),this._cursorPosIfTouchesEdit=o.derived(this,g=>{const p=this._editorObs.cursorPosition.read(g),f=this._edit.read(g);if(!(!f||!p))return f.modifiedLineRange.contains(p.lineNumber)?p:void 0}),this._originalStartPosition=o.derived(this,g=>{const p=this._edit.read(g);return p?new a.Position(p.originalLineRange.startLineNumber,1):null}),this._originalEndPosition=o.derived(this,g=>{const p=this._edit.read(g);return p?new a.Position(p.originalLineRange.endLineNumberExclusive,1):null}),this._originalVerticalStartPosition=this._editorObs.observePosition(this._originalStartPosition,this._store).map(g=>g?.y),this._originalVerticalEndPosition=this._editorObs.observePosition(this._originalEndPosition,this._store).map(g=>g?.y),this._originalDisplayRange=this._edit.map(g=>g?.displayRange),this._editorMaxContentWidthInRange=o.derived(this,g=>{const p=this._originalDisplayRange.read(g);return p?(this._editorObs.versionId.read(g),o.derivedObservableWithCache(this,(f,m)=>{const _=At(this._editorObs,p,f);return Math.max(_,m??0)})):o.constObservable(0)}).map((g,p)=>g.read(p));const u=AD(this._editor,this._store);this._previewEditorLayoutInfo=o.derived(this,g=>{const p=this._edit.read(g);if(!p||!this._uiState.read(g))return null;const m=p.originalLineRange,_=this._editorObs.scrollLeft.read(g),v=this._editorMaxContentWidthInRange.read(g),b=this._editorObs.layoutInfo.read(g),C=this._previewEditorWidth.read(g),y=b.contentWidth-b.verticalScrollbarWidth,I=u.read(g),x=b.contentLeft+b.contentWidth+I.left,S=o.getWindow(this._editor.getContainerDomNode()).innerWidth-x,w=o.getWindow(this._editor.getContainerDomNode()).innerWidth-I.right,E=Math.min(b.contentWidth*.3,C,100),L=0,R=L+S,D=this._cursorPosIfTouchesEdit.read(g),T=Math.max(y+_-L-Math.max(0,E-R),Math.min(D?RD(this._editorObs,D,g)+50:0,y+_)),P=Math.min(v+Yg,T),M=v+Yg+C+70,V=T-P;let F,K;P>_?(F=0,K=b.contentLeft+P-_):(F=_-P,K=b.contentLeft);const O=this._originalVerticalStartPosition.read(g)??this._editor.getTopForLineNumber(m.startLineNumber)-this._editorObs.scrollTop.read(g),z=this._originalVerticalEndPosition.read(g)??this._editor.getBottomForLineNumber(m.endLineNumberExclusive-1)-this._editorObs.scrollTop.read(g),Q=b.contentLeft-_;let j=k.fromLeftTopRightBottom(Q,O,K,z);const U=j.height===0;U||(j=j.withMargin(Lr,ks));const Y=this._previewEditorObs.observeLineHeightsForLineRange(p.modifiedLineRange).read(g).reduce((yf,DN)=>yf+DN,0),G=z-O,ae=Math.max(G,Y),Fi=V===0,je=0,yt=Math.min(C+cb,w+b.width-b.contentLeft-je);let os=k.fromLeftTopWidthHeight(j.right+je,O,yt,ae);return U?os=os.withMargin(Lr,ks).translateY(Lr):os=os.withMargin(Lr,ks).translateX(ks+et),{codeRect:j,editRect:os,codeScrollLeft:_,contentLeft:b.contentLeft,isInsertion:U,maxContentWidth:M,shouldShowShadow:Fi,desiredPreviewEditorScrollLeft:F,previewEditorWidth:yt}}),this._stickyScrollController=Be.get(this._editorObs.editor),this._stickyScrollHeight=this._stickyScrollController?o.observableFromEvent(this._stickyScrollController.onDidChangeStickyScrollHeight,()=>this._stickyScrollController.stickyScrollWidgetHeight):o.constObservable(0),this._shouldOverflow=o.derived(this,g=>!1),this._originalBackgroundColor=o.observableFromEvent(this,this._themeService.onDidColorThemeChange,()=>this._themeService.getColorTheme().getColor(vr)??a.Color.transparent),this._editorBackgroundColor=this._uiState.map(g=>ni(g?.editorType??te.TextEditor)),this._backgroundSvg=o.n.svg({transform:"translate(-0.5 -0.5)",style:{overflow:"visible",pointerEvents:"none",position:"absolute"}},[o.n.svgElem("path",{class:"rightOfModifiedBackgroundCoverUp",d:o.derived(this,g=>{const p=this._previewEditorLayoutInfo.read(g);if(!(!p||this._originalBackgroundColor.read(g).isTransparent()))return new Dg().moveTo(p.codeRect.getRightTop()).lineTo(p.codeRect.getRightTop().deltaX(1e3)).lineTo(p.codeRect.getRightBottom().deltaX(1e3)).lineTo(p.codeRect.getRightBottom()).build()}),style:{fill:this._editorBackgroundColor}})]).keepUpdated(this._store),this._originalOverlay=o.n.div({style:{pointerEvents:"none",display:this._previewEditorLayoutInfo.map(g=>g?.isInsertion?"none":"block")}},o.derived(this,g=>{const p=ht(this._previewEditorLayoutInfo).read(g);if(!p)return;const f=this._editorBackgroundColor.read(g),m=h.read(g),_=Al(this._tabAction).map(L=>`${et}px solid ${o.asCssVariable(L)}`),v=`${et+m}px solid ${f}`,b=p.read(g).codeScrollLeft!==0,C=p.map(L=>L.codeRect.bottom<L.editRect.bottom),y=zt*2+et*2,I=p.map(L=>k.fromLeftTopRightBottom(L.contentLeft-zt-et,L.codeRect.top,L.contentLeft,L.codeRect.bottom+y)).read(g),x=new a.OffsetRange(I.left,Number.MAX_SAFE_INTEGER),S=p.map(L=>L.codeRect.intersectHorizontal(x)),w=S.map(L=>L.withMargin(m,0,m,m).intersectHorizontal(x)),E=S.map(L=>k.fromLeftTopWidthHeight(L.right-y+et,L.bottom-et,y,y).intersectHorizontal(x));return[o.n.div({class:"originalSeparatorSideBySide",style:{...w.read(g).toStyles(),boxSizing:"border-box",borderRadius:`${zt}px 0 0 ${zt}px`,borderTop:v,borderBottom:v,borderLeft:b?"none":v}}),o.n.div({class:"originalOverlaySideBySide",style:{...S.read(g).toStyles(),boxSizing:"border-box",borderRadius:`${zt}px 0 0 ${zt}px`,borderTop:_,borderBottom:_,borderLeft:b?"none":_,backgroundColor:o.asCssVariable(vr)}}),o.n.div({class:"originalCornerCutoutSideBySide",style:{pointerEvents:"none",display:C.map(L=>L?"block":"none"),...E.read(g).toStyles()}},[o.n.div({class:"originalCornerCutoutBackground",style:{position:"absolute",top:"0px",left:"0px",width:"100%",height:"100%",backgroundColor:de(vr,this._themeService).map(L=>L.toString())}}),o.n.div({class:"originalCornerCutoutBorder",style:{position:"absolute",top:"0px",left:"0px",width:"100%",height:"100%",boxSizing:"border-box",borderTop:_,borderRight:_,borderRadius:"0 100% 0 0",backgroundColor:f}})]),o.n.div({class:"originalOverlaySideBySideHider",style:{...I.toStyles(),backgroundColor:f}})]})).keepUpdated(this._store),this._modifiedOverlay=o.n.div({style:{pointerEvents:"none"}},o.derived(this,g=>{const p=ht(this._previewEditorLayoutInfo).read(g);if(!p)return;const f=p.map(S=>S.codeRect.bottom<S.editRect.bottom),m=this._editorBackgroundColor.read(g),_=h.read(g),v=f.map(S=>`0 ${zt}px ${zt}px ${S?zt:0}px`),b=de(wr(this._tabAction),this._themeService).map(S=>`1px solid ${S.toString()}`),C=`${et+_}px solid ${m}`,y=p.map(S=>S.editRect.withMargin(0,et)),I=y.map(S=>S.withMargin(_,_,_,0)),x=o.derived(this,S=>{const w=y.read(S),E=p.read(S);return!E.isInsertion||E.contentLeft>=w.left?k.fromLeftTopWidthHeight(w.left,w.top,0,0):new k(E.contentLeft,w.top,w.left,w.top+et*2)});return[o.n.div({class:"modifiedInsertionSideBySide",style:{...x.read(g).toStyles(),backgroundColor:wr(this._tabAction).map(S=>o.asCssVariable(S))}}),o.n.div({class:"modifiedSeparatorSideBySide",style:{...I.read(g).toStyles(),borderRadius:v,borderTop:C,borderBottom:C,borderRight:C,boxSizing:"border-box"}}),o.n.div({class:"modifiedOverlaySideBySide",style:{...y.read(g).toStyles(),borderRadius:v,border:b,boxSizing:"border-box",backgroundColor:o.asCssVariable(Wv)}})]})).keepUpdated(this._store),this._nonOverflowView=o.n.div({class:"inline-edits-view",style:{position:"absolute",overflow:"visible",top:"0px",left:"0px",display:this._display}},[this._backgroundSvg,o.derived(this,g=>this._shouldOverflow.read(g)?[]:[this._editorContainer,this._originalOverlay,this._modifiedOverlay])]).keepUpdated(this._store),this._register(this._editorObs.createOverlayWidget({domNode:this._nonOverflowView.element,position:o.constObservable(null),allowEditorOverflow:!1,minContentWidthInPx:o.derived(this,g=>{const p=this._previewEditorLayoutInfo.read(g)?.maxContentWidth;return p===void 0?0:p})})),this.previewEditor.setModel(this._previewTextModel),this._register(o.autorun(g=>{const p=this._previewEditorLayoutInfo.read(g);if(!p)return;const f=p.editRect.withMargin(-Lr,-ks);this.previewEditor.layout({height:f.height,width:p.previewEditorWidth+15}),this._editorContainer.element.style.top=`${f.top}px`,this._editorContainer.element.style.left=`${f.left}px`,this._editorContainer.element.style.width=`${p.previewEditorWidth+ks}px`})),this._register(o.autorun(g=>{const p=this._previewEditorLayoutInfo.read(g);p&&this._previewEditorObs.editor.setScrollLeft(p.desiredPreviewEditorScrollLeft)})),this._updatePreviewEditor.recomputeInitiallyAndOnChange(this._store)}};Ul=yR([Xg(5,o.IInstantiationService),Xg(6,o.IThemeService),Xg(7,o.IUserInteractionService)],Ul);var xR=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Dr=function(c,e){return function(t,i){e(t,i,c)}};class ER{constructor(e,t,i){this.edit=e,this.editorType=t,this.alternativeAction=i}equals(e){return this.edit.equals(e.edit)&&this.alternativeAction===e.alternativeAction}}const he=1,db="word-replacement-view-overlay",hb="word-replacement-view-widget",ub="word-replacement-view-replacement",Qg="word-replacement-view-rename";let Us=(oo=class extends a.Disposable{constructor(e,t,i,n,s,r,l,d){super(),this._editor=e,this._viewData=t,this._tabAction=i,this._languageService=n,this._themeService=s,this._keybindingService=r,this._hoverService=l,this._userInteractionService=d,this._onDidClick=this._register(new a.Emitter),this.onDidClick=this._onDidClick.event,this._start=this._editor.observePosition(o.constObservable(this._viewData.edit.range.getStartPosition()),this._store),this._end=this._editor.observePosition(o.constObservable(this._viewData.edit.range.getEndPosition()),this._store),this._line=document.createElement("div"),this._primaryElement=o.observableValue(this,null),this._secondaryElement=o.observableValue(this,null),this.isHovered=o.derived(this,p=>{const f=this._primaryElement.read(p);return f?this._userInteractionService.createHoverTracker(f.element,p.store).read(p):!1}),this._renderTextEffect=o.derived(this,p=>{const f=this._editor.model.read(void 0);if(!f)return;const m=f.getLineContent(this._viewData.edit.range.startLineNumber),_=a.StringReplacement.replace(new a.OffsetRange(this._viewData.edit.range.startColumn-1,this._viewData.edit.range.endColumn-1),this._viewData.edit.text),v=_.replace(m),b=f.tokenization.tokenizeLinesAt(this._viewData.edit.range.startLineNumber,[v])?.[0];let C;b?C=o.TokenArray.fromLineTokens(b).slice(_.getRangeAfterReplace()).toLineTokens(this._viewData.edit.text,this._languageService.languageIdCodec):C=o.LineTokens.createEmpty(this._viewData.edit.text,this._languageService.languageIdCodec);const y=o.renderLines(new o.LineSource([C]),o.RenderOptions.fromEditor(this._editor.editor).withSetWidth(!1).withScrollBeyondLastColumn(0),[],this._line,!0);this._line.style.width=`${y.minWidthInPx}px`});const h=this._editor.observeLineHeightForPosition(this._viewData.edit.range.getStartPosition()),u=o.observableFromPromise(this._viewData.alternativeAction?.count??new Promise(p=>p(void 0))).map(p=>p.value),g=o.derived(this,p=>this._userInteractionService.readModifierKeyStatus(this._editor.editor.getDomNode(),p).shiftKey);this._layout=o.derived(this,p=>{this._renderTextEffect.read(p);const f=this._start.read(p),m=this._end.read(p);if(!f||!m||f.x>m.x||f.y>m.y)return;const _=h.read(p);if(_<=0)return;const v=this._editor.scrollLeft.read(p),b=this._editor.getOption(59).read(p).typicalHalfwidthCharacterWidth,C=3*b,y=4,I=new o.Point(C,y);let x;if(this._viewData.alternativeAction){const R=this._viewData.alternativeAction.label,D=u.read(p),T=g.read(p),P=D!==void 0?D===1?a.localize(1283,"{0} 1 occurrence",R):a.localize(1284,"{0} {1} occurrences",R,D):R,M=a.localize(1285,"{0} show occurrences","[shift]");x={label:D!==void 0&&T?P:R,tooltip:P?`${P}
47
+ ${M}`:void 0,icon:void 0,count:D,keybinding:this._keybindingService.lookupKeybinding(oa),active:g}}const S=k.fromPoints(f,m).withHeight(_).translateX(-v),w=k.fromPointSize(S.getLeftBottom().add(I),new o.Point(this._viewData.edit.text.length*b,S.height)),E=w.withWidth(w.width+(x?x.label.length*b+8+4+12:0)),L=E.withLeft(S.left);return{alternativeAction:x,originalLine:S,codeLine:w,modifiedLine:E,lowerBackground:L,lineHeight:_}}),this.minEditorScrollHeight=o.derived(this,p=>{const f=ht(this._layout).read(p);return f?f.read(p).modifiedLine.bottom+he+this._editor.editor.getScrollTop():0}),this._root=o.n.div({class:"word-replacement"},[o.derived(this,p=>{const f=ht(this._layout).read(p);if(!f)return[];const m=Al(this._tabAction).map(D=>o.asCssVariable(D)).read(p),_=wr(this._tabAction).map(D=>o.asCssVariable(D)).read(p);this._line.style.lineHeight=`${f.read(p).modifiedLine.height+2*he}px`;const v=o.constObservable(!1),b=f.map(D=>D.alternativeAction),C=o.derived(D=>(b.read(D)?.active.read(D)??!1)||v.read(D)),I=o.observableFromEvent(this._themeService.onDidColorThemeChange,()=>{const D=this._themeService.getColorTheme();return D.type==="hcDark"||D.type==="hcLight"}).read(p)?Bs(o.contrastBorder,this._themeService).read(p):null,x={borderColor:I?I.toString():_,backgroundColor:o.asCssVariable(SD),color:"",opacity:"1"},S={borderColor:I?I.toString():o.asCssVariable(ii),backgroundColor:o.asCssVariable(Cr),color:o.asCssVariable(br),opacity:"1"},w={borderColor:I?I.toString():Bs(o.editorHoverForeground,this._themeService).map(D=>D.transparent(.2).toString()).read(p),backgroundColor:ni(this._viewData.editorType),color:"",opacity:"0.7"},E=ni(this._viewData.editorType),L=o.derived(this,D=>(C.read(D),x)),R=o.derived(this,D=>C.read(D)?S:w);return[o.n.div({id:db,style:{position:"absolute",..._e(D=>Lg(this._editor).read(D)),overflow:"hidden",pointerEvents:"none"}},[o.n.div({style:{position:"absolute",..._e(D=>f.read(D).lowerBackground.withMargin(he,2*he,he,0)),background:E,cursor:"pointer",pointerEvents:"auto"},onmousedown:D=>this._mouseDown(D)}),o.n.div({id:hb,style:{position:"absolute",..._e(D=>f.read(D).modifiedLine.withMargin(he,2*he)),width:void 0,pointerEvents:"auto",boxSizing:"border-box",borderRadius:`${me}px`,background:E,display:"flex",justifyContent:"left",outline:`2px solid ${E}`},onmousedown:D=>this._mouseDown(D)},[o.n.div({id:ub,style:{fontFamily:this._editor.getOption(58),fontSize:this._editor.getOption(61),fontWeight:this._editor.getOption(62),width:_e(D=>f.read(D).codeLine.withMargin(he,2*he)).width,borderRadius:`${me}px`,border:L.map(D=>`${he}px solid ${D.borderColor}`),boxSizing:"border-box",padding:`${he}px`,opacity:L.map(D=>D.opacity),background:L.map(D=>D.backgroundColor),display:"flex",justifyContent:"left",alignItems:"center",pointerEvents:"auto",cursor:"pointer"},obsRef:D=>{this._primaryElement.set(D,void 0)}},[this._line]),o.derived(this,D=>{const T=b.read(D);if(!T)return;const P=document.createElement("div");return D.store.add(new o.KeybindingLabel(P,a.OS,{...o.unthemedKeybindingLabelOptions,disableTitle:!0})).set(T.keybinding),o.n.div({id:Qg,style:{position:"relative",borderRadius:`${me}px`,borderTop:`${he}px solid`,borderRight:`${he}px solid`,borderBottom:`${he}px solid`,borderLeft:`${he}px solid`,borderColor:R.map(V=>V.borderColor),opacity:R.map(V=>V.opacity),color:R.map(V=>V.color),display:"flex",justifyContent:"center",alignItems:"center",padding:"0 4px 0 1px",marginLeft:"4px",background:R.map(V=>V.backgroundColor),cursor:"pointer",textWrap:"nowrap"},class:"inline-edit-alternative-action-label",obsRef:V=>{this._secondaryElement.set(V,void 0)},ref:V=>{T.tooltip&&D.store.add(this._hoverService.setupDelayedHoverAtMouse(V,{content:T.tooltip,appearance:{compact:!0}}))}},[P,o.$("div.inline-edit-alternative-action-label-separator"),T.icon?o.renderIcon(T.icon):void 0,T.label])})]),o.n.div({style:{position:"absolute",..._e(D=>f.read(D).originalLine.withMargin(he)),boxSizing:"border-box",borderRadius:`${me}px`,border:`${he}px solid ${m}`,background:o.asCssVariable(bD),pointerEvents:"none"}},[]),o.n.svg({width:11,height:14,viewBox:"0 0 11 14",fill:"none",style:{position:"absolute",left:f.map(D=>D.modifiedLine.left-16),top:f.map(D=>D.modifiedLine.top+Math.round((D.lineHeight-14-5)/2)),pointerEvents:"none"},onmousedown:D=>this._mouseDown(D)},[o.n.svgElem("path",{d:"M1 0C1 2.98966 1 5.92087 1 8.49952C1 9.60409 1.89543 10.5 3 10.5H10.5",stroke:o.asCssVariable(o.editorHoverForeground)}),o.n.svgElem("path",{d:"M6 7.5L9.99999 10.49998L6 13.5",stroke:o.asCssVariable(o.editorHoverForeground)})])])]})]).keepUpdated(this._store),this._register(this._editor.createOverlayWidget({domNode:this._root.element,minContentWidthInPx:o.constObservable(0),position:o.constObservable({preference:{top:0,left:0}}),allowEditorOverflow:!1}))}_mouseDown(e){const t=LR(e.target,new Set([hb,ub,Qg,db]));t&&(e.preventDefault(),this._onDidClick.fire(Qt.create(e,t===Qg)))}},oo.MAX_LENGTH=100,oo);Us=xR([Dr(3,o.ILanguageService),Dr(4,o.IThemeService),Dr(5,o.IKeybindingService),Dr(6,o.IHoverService),Dr(7,o.IUserInteractionService)],Us);function LR(c,e){let t=c;for(;t;){if(e.has(t.id))return t.id;t=t.parentElement}return null}class DR extends a.Disposable{constructor(e,t,i){super(),this._originalEditor=e,this._state=t,this._modifiedTextModel=i,this._onDidClick=this._register(new a.Emitter),this.onDidClick=this._onDidClick.event,this.isHovered=o.observableCodeEditor(this._originalEditor).isTargetHovered(s=>s.target.type===6&&s.target.detail.injectedText?.options.attachedData instanceof Jg&&s.target.detail.injectedText.options.attachedData.owner===this,this._store),this._tokenizationFinished=NR(this._modifiedTextModel),this._decorations=o.derived(this,s=>{const r=this._state.read(s);if(!r)return;const l=r.modifiedText,d=r.mode==="insertionInline",h=r.diff.length===1&&r.diff[0].innerChanges?.length===1,u=!0,g=[],p=[],f=o.ModelDecorationOptions.register({className:"inlineCompletions-line-insert",description:"line-insert",isWholeLine:!0,marginClassName:"gutter-insert"}),m=o.ModelDecorationOptions.register({className:"inlineCompletions-line-delete",description:"line-delete",isWholeLine:!0,marginClassName:"gutter-delete"}),_=o.ModelDecorationOptions.register({className:"inlineCompletions-char-delete",description:"char-delete",isWholeLine:!1,zIndex:1}),v=o.ModelDecorationOptions.register({className:"inlineCompletions-char-insert",description:"char-insert",isWholeLine:!0}),b=o.ModelDecorationOptions.register({className:"inlineCompletions-char-insert",description:"char-insert",shouldFillLineOnLineBreak:!0}),C=o.ModelDecorationOptions.register({className:"inlineCompletions-char-insert diff-range-empty",description:"char-insert diff-range-empty"}),y=o.ModelDecorationOptions.register({className:"inlineCompletions-original-lines",description:"inlineCompletions-original-lines",isWholeLine:!1,shouldFillLineOnLineBreak:!0}),I=r.mode!=="sideBySide"&&r.mode!=="deletion"&&r.mode!=="insertionInline"&&r.mode!=="lineReplacement",x=r.mode==="lineReplacement";for(const S of r.diff)if(I&&(S.original.isEmpty||g.push({range:S.original.toInclusiveRange(),options:m}),S.modified.isEmpty||p.push({range:S.modified.toInclusiveRange(),options:f})),S.modified.isEmpty||S.original.isEmpty)S.original.isEmpty||g.push({range:S.original.toInclusiveRange(),options:_}),S.modified.isEmpty||p.push({range:S.modified.toInclusiveRange(),options:v});else{const w=d&&RR(S);for(const E of S.innerChanges||[]){if(S.original.contains(E.originalRange.startLineNumber)&&!(x&&E.originalRange.isEmpty())){const L=this._originalEditor.getModel()?.getValueInRange(E.originalRange,1);g.push({range:E.originalRange,options:{description:"char-delete",shouldFillLineOnLineBreak:!1,className:Fl("inlineCompletions-char-delete",E.originalRange.isSingleLine()&&r.mode==="insertionInline"&&"single-line-inline",E.originalRange.isEmpty()&&"empty",(E.originalRange.isEmpty()&&h||r.mode==="deletion"&&L===`
48
+ `)&&u&&!w&&"diff-range-empty"),inlineClassName:w?Fl("strike-through","inlineCompletions"):null,zIndex:1}})}if(S.modified.contains(E.modifiedRange.startLineNumber)&&p.push({range:E.modifiedRange,options:E.modifiedRange.isEmpty()&&u&&!w&&h?C:b}),w){const L=l.getValueOfRange(E.modifiedRange),R=L.length>3?[{text:L.slice(0,1),extraClasses:["start"],offsetRange:new a.OffsetRange(E.modifiedRange.startColumn-1,E.modifiedRange.startColumn)},{text:L.slice(1,-1),extraClasses:[],offsetRange:new a.OffsetRange(E.modifiedRange.startColumn,E.modifiedRange.endColumn-2)},{text:L.slice(-1),extraClasses:["end"],offsetRange:new a.OffsetRange(E.modifiedRange.endColumn-2,E.modifiedRange.endColumn-1)}]:[{text:L,extraClasses:["start","end"],offsetRange:new a.OffsetRange(E.modifiedRange.startColumn-1,E.modifiedRange.endColumn)}];this._tokenizationFinished.read(s);const D=this._modifiedTextModel.tokenization.getLineTokens(E.modifiedRange.startLineNumber);for(const{text:T,extraClasses:P,offsetRange:M}of R)g.push({range:a.Range.fromPositions(E.originalRange.getEndPosition()),options:{description:"inserted-text",before:{tokens:D.getTokensInRange(M),content:T,inlineClassName:Fl("inlineCompletions-char-insert",E.modifiedRange.isSingleLine()&&r.mode==="insertionInline"&&"single-line-inline",...P),cursorStops:a.InjectedTextCursorStops.None,attachedData:new Jg(this)},zIndex:2,showIfCollapsed:!0}})}}}if(r.editorType===te.DiffEditor)for(const S of r.diff)S.original.isEmpty||g.push({range:S.original.toExclusiveRange(),options:y});return{originalDecorations:g,modifiedDecorations:p}}),this._register(o.observableCodeEditor(this._originalEditor).setDecorations(this._decorations.map(s=>s?.originalDecorations??[])));const n=this._state.map(s=>s?.modifiedCodeEditor);this._register(o.autorunWithStore((s,r)=>{const l=n.read(s);l&&r.add(o.observableCodeEditor(l).setDecorations(this._decorations.map(d=>d?.modifiedDecorations??[])))})),this._register(this._originalEditor.onMouseUp(s=>{if(s.target.type!==6)return;const r=s.target.detail.injectedText?.options.attachedData;r instanceof Jg&&r.owner===this&&this._onDidClick.fire(new Qt(s.event))}))}}class Jg{constructor(e){this.owner=e}}function RR(c){return c.innerChanges?c.innerChanges.every(e=>o.rangeIsSingleLine(e.modifiedRange)&&o.rangeIsSingleLine(e.originalRange)):!1}let TR=0;function NR(c){return o.observableFromEvent(c.onDidChangeTokens,()=>TR++)}var MR=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},PR=function(c,e){return function(t,i){e(t,i,c)}};let Wg=class extends a.Disposable{constructor(e,t,i,n,s,r){super(),this._editor=e,this._model=t,this._simpleModel=i,this._inlineSuggestInfo=n,this._showCollapsed=s,this._instantiationService=r,this._tabAction=o.derived(u=>this._model.read(u)?.tabAction.read(u)??H.Inactive),this.displayRange=o.derived(this,u=>{const g=this._uiState.read(u);if(g&&g.target.uri.toString()===this._editorObs.model.read(u)?.uri.toString()){if(g.state?.kind==="custom"){const p=g.state.displayLocation?.range;if(!p)throw new a.BugIndicatingError("custom view should have a range");return new a.LineRange(p.startLineNumber,p.endLineNumber)}return g.state?.kind==="insertionMultiLine"?this._insertion.originalLines.read(u):g.edit.displayRange}}),this._currentInlineEditCache=void 0,this._uiState=o.derived(this,u=>{const g=this._model.read(u),p=this._editorObs.model.read(u);if(!g||!p||!this._constructorDone.read(u))return;const f=g.inlineEdit;let m,_,v;f.edit?(_=a.RangeMapping.fromEdit(f.edit),v=new a.StringText(f.edit.apply(f.originalText)),m=a.lineRangeMappingFromRangeMappings(_,f.originalText,v)):(_=[],m=[],v=f.originalText);let b=this._determineRenderState(g,u,m,v);if(!b){a.onUnexpectedError(new Error(`unable to determine view: tried to render ${this._previousView?.view}`));return}const C=this._getLongDistanceHintState(g,u);if(C&&C.isVisible&&b.viewData.setLongDistanceViewData(C.lineNumber,f.lineEdit.lineRange.startLineNumber),b.viewData.isForAnotherDocument=!f.originalText.targets(p),b.kind===A.SideBySide){const x=OD(v.getValue(),f.modifiedLineRange,p.getOptions().tabSize);v=new a.StringText(x.applyToString(v.getValue())),_=TD(_,x),m=a.lineRangeMappingFromRangeMappings(_,f.originalText,v)}this._previewTextModel.setLanguage(p.getLanguageId());const y=this._previewTextModel.getValue();if(y!==v.getValue()){this._previewTextModel.setEOL(p.getEndOfLineSequence());const S=a.StringEdit.replace(new a.OffsetRange(0,y.length),v.getValue()).removeCommonSuffixPrefix(y),w=fl(this._previewTextModel).getTextEdit(S);this._previewTextModel.edit(w)}this._showCollapsed.read(u)&&(b={kind:A.Collapsed,viewData:b.viewData}),g.handleInlineEditShownNextFrame(b.kind,b.viewData);const I=f.action?.kind==="jumpTo"?f.action.position:null;return{state:b,diff:m,edit:f,newText:v.getValue(),newTextLineCount:f.modifiedLineRange.length,editorType:g.editorType,longDistanceHint:C,nextCursorPosition:I,target:f.inlineCompletion.originalTextRef}}),this.inlineEditsIsHovered=o.derived(this,u=>this._sideBySide.isHovered.read(u)||this._wordReplacementViews.read(u).some(g=>g.isHovered.read(u))||this._deletion.isHovered.read(u)||this._inlineDiffView.isHovered.read(u)||this._lineReplacementView.isHovered.read(u)||this._insertion.isHovered.read(u)||this._customView.isHovered.read(u)||this._longDistanceHint.map((g,p)=>g?.isHovered.read(p)??!1).read(u)),this.gutterIndicatorOffset=o.derived(this,u=>this._uiState.read(u)?.state?.kind==="insertionMultiLine"?this._insertion.startLineOffset.read(u):0),this._editorObs=o.observableCodeEditor(this._editor),this._constructorDone=o.observableValue(this,!1),this._previewTextModel=this._register(this._instantiationService.createInstance(o.TextModel,"",this._editor.getModel().getLanguageId(),{...o.TextModel.DEFAULT_CREATION_OPTIONS,bracketPairColorizationOptions:{enabled:!0,independentColorPoolPerBracketType:!1}},null)),this._sideBySide=this._register(this._instantiationService.createInstance(Ul,this._editor,this._model.map(u=>u?.inlineEdit),this._previewTextModel,this._uiState.map(u=>u&&u.state?.kind===A.SideBySide?{newTextLineCount:u.newTextLineCount,editorType:u.editorType}:void 0),this._tabAction)),this._deletion=this._register(this._instantiationService.createInstance(HD,this._editor,this._model.map(u=>u?.inlineEdit),this._uiState.map(u=>u&&u.state?.kind===A.Deletion?{originalRange:u.state.originalRange,deletions:u.state.deletions,editorType:u.editorType}:void 0),this._tabAction)),this._insertion=this._register(this._instantiationService.createInstance(kg,this._editor,this._uiState.map(u=>u&&u.state?.kind===A.InsertionMultiLine?{lineNumber:u.state.lineNumber,startColumn:u.state.column,text:u.state.text,editorType:u.editorType}:void 0),this._tabAction)),this._inlineCollapsedView=this._register(this._instantiationService.createInstance(Ag,this._editor,this._model.map((u,g)=>this._uiState.read(g)?.state?.kind===A.Collapsed?u?.inlineEdit:void 0))),this._customView=this._register(this._instantiationService.createInstance(zg,this._editor,this._model.map((u,g)=>this._uiState.read(g)?.state?.kind===A.Custom?u?.displayLocation:void 0),this._tabAction,this._uiState.map(u=>u?.editorType??te.TextEditor))),this._showLongDistanceHint=this._editorObs.getOption(71).map(this,u=>u.edits.showLongDistanceHint),this._longDistanceHint=o.derived(this,u=>{if(this._showLongDistanceHint.read(u))return u.store.add(this._instantiationService.createInstance(Zg,this._editor,this._uiState.map((g,p)=>g?.longDistanceHint?{hint:g.longDistanceHint,newTextLineCount:g.newTextLineCount,edit:g.edit,diff:g.diff,editorType:g.editorType,model:this._simpleModel.read(p),inlineSuggestInfo:this._inlineSuggestInfo.read(p),nextCursorPosition:g.nextCursorPosition,target:g.target}:void 0),this._previewTextModel,this._tabAction))}).recomputeInitiallyAndOnChange(this._store),this._inlineDiffViewState=o.derived(this,u=>{const g=this._uiState.read(u);if(!(!g||!g.state)&&!(g.state.kind==="wordReplacements"||g.state.kind==="insertionMultiLine"||g.state.kind==="collapsed"||g.state.kind==="custom"||g.state.kind==="jumpTo"))return{modifiedText:new a.StringText(g.newText),diff:g.diff,mode:g.state.kind,modifiedCodeEditor:this._sideBySide.previewEditor,editorType:g.editorType}}),this._inlineDiffView=this._register(new DR(this._editor,this._inlineDiffViewState,this._previewTextModel)),this._jumpToView=this._register(this._instantiationService.createInstance(jg,this._editorObs,{style:"label"},o.derived(u=>{const g=this._uiState.read(u);if(g?.state?.kind===A.JumpTo)return{jumpToPosition:g.state.position}})));const l=o.derivedOpts({equalsFn:o.equals.arrayC(o.equals.thisC())},u=>{const g=this._uiState.read(u);return g?.state?.kind===A.WordReplacements?g.state.replacements.map(p=>new ER(p,g.editorType,g.state?.alternativeAction)):[]});this._wordReplacementViews=o.mapObservableArrayCached(this,l,(u,g)=>g.add(this._instantiationService.createInstance(Us,this._editorObs,u,this._tabAction))),this._lineReplacementView=this._register(this._instantiationService.createInstance(Ug,this._editorObs,this._uiState.map(u=>u?.state?.kind===A.LineReplacement?{originalRange:u.state.originalRange,modifiedRange:u.state.modifiedRange,modifiedLines:u.state.modifiedLines,replacements:u.state.replacements}:void 0),this._uiState.map(u=>u?.editorType??te.TextEditor),this._tabAction)),this._useCodeShifting=this._editorObs.getOption(71).map(u=>u.edits.allowCodeShifting),this._renderSideBySide=this._editorObs.getOption(71).map(u=>u.edits.renderSideBySide),this._register(o.autorun(u=>{const g=this._model.read(u);g&&u.store.add(a.Event.any(this._sideBySide.onDidClick,this._lineReplacementView.onDidClick,this._insertion.onDidClick,...this._wordReplacementViews.read(u).map(p=>p.onDidClick),this._inlineDiffView.onDidClick,this._customView.onDidClick)(p=>{this._viewHasBeenShownLongerThan(350)&&(p.event.preventDefault(),g.accept(p.alternativeAction))}))})),this._wordReplacementViews.recomputeInitiallyAndOnChange(this._store);const d=o.derived(this,u=>Math.max(...this._wordReplacementViews.read(u).map(g=>g.minEditorScrollHeight.read(u)),this._lineReplacementView.minEditorScrollHeight.read(u),this._customView.minEditorScrollHeight.read(u))).recomputeInitiallyAndOnChange(this._store);let h;this._register(o.autorun(u=>{const g=d.read(u),p=this._editorObs.model.read(u);p&&this._editor.changeViewZones(f=>{const m=this._editor.getScrollHeight(),_=g-m+1;_!==0&&h!==void 0&&(f.removeZone(h),h=void 0),!(_<=0)&&(h=f.addZone({afterLineNumber:p.getLineCount(),heightInPx:_,domNode:o.$("div.minScrollHeightViewZone")}))})})),this._constructorDone.set(!0,void 0)}_getLongDistanceHintState(e,t){if(e.inlineEdit.inlineCompletion.identity.jumpedTo.read(t)||e.inlineEdit.action===void 0)return;const i=this._editorObs.model.read(t);return!i||!e.inlineEdit.originalText.targets(i)?{isVisible:!0,lineNumber:e.inlineEdit.cursorPosition.lineNumber}:(this._currentInlineEditCache?.inlineSuggestionIdentity!==e.inlineEdit.inlineCompletion.identity&&(this._currentInlineEditCache={inlineSuggestionIdentity:e.inlineEdit.inlineCompletion.identity,firstCursorLineNumber:e.inlineEdit.cursorPosition.lineNumber}),{lineNumber:this._currentInlineEditCache.firstCursorLineNumber,isVisible:!e.inViewPort.read(t)})}_getCacheId(e){return e.inlineEdit.inlineCompletion.identity.id}_determineView(e,t,i,n){const s=e.inlineEdit,r=this._previousView?.id===this._getCacheId(e)&&this._previousView?.uri.toString()===this._editorObs.model.get().uri.toString(),l=this._previousView?.editorWidth!==this._editorObs.layoutInfoWidth.read(t)&&(this._previousView?.view===A.SideBySide||this._previousView?.view===A.LineReplacement);if(r&&!l)return this._previousView.view;const d=e.inlineEdit.inlineCompletion.action;if(d?.kind==="edit"&&d.alternativeAction)return A.WordReplacements;const h=e.inlineEdit.inlineCompletion.originalTextRef.uri,u=this._editorObs.model.read(t)?.uri;if(u&&h.toString()!==u.toString()||e.displayLocation&&!e.inlineEdit.inlineCompletion.identity.jumpedTo.read(t))return A.Custom;const g=s.originalLineRange.length,p=s.modifiedLineRange.length,f=i.flatMap(_=>_.innerChanges??[]),m=f.length===1;if(e.editorType!==te.DiffEditor){if(m&&this._useCodeShifting.read(t)!=="never"&&pb(i))return AR(i,s.cursorPosition)?A.InsertionInline:A.LineReplacement;if(mb(f,s,n))return A.Deletion;if(fb(i)&&this._useCodeShifting.read(t)==="always")return A.InsertionMultiLine;if(f.every(v=>a.TextLength.ofRange(v.originalRange).columnCount<Us.MAX_LENGTH&&a.TextLength.ofRange(v.modifiedRange).columnCount<Us.MAX_LENGTH)&&m&&g===1&&p===1){const v=f.map(C=>n.getValueOfRange(C.modifiedRange)),b=f.map(C=>e.inlineEdit.originalText.getValueOfRange(C.originalRange));if(!v.some(C=>C.includes(" "))&&!b.some(C=>C.includes(" "))&&(!f.some(C=>C.originalRange.isEmpty())||!_b(f.map(C=>new a.TextReplacement(C.originalRange,"")),s.originalText).some(C=>C.range.isEmpty()&&a.TextLength.ofRange(C.range).columnCount<Us.MAX_LENGTH)))return A.WordReplacements}}if(g>0&&p>0)return g===1&&p===1&&e.editorType!==te.DiffEditor?A.LineReplacement:this._renderSideBySide.read(t)!=="never"&&Ul.fitsInsideViewport(this._editor,this._previewTextModel,s,t)?A.SideBySide:A.LineReplacement;if(e.editorType===te.DiffEditor){if(mb(f,s,n))return A.Deletion;if(fb(i)&&this._useCodeShifting.read(t)==="always")return A.InsertionMultiLine}return A.SideBySide}_determineRenderState(e,t,i,n){if(e.inlineEdit.action?.kind==="jumpTo")return{kind:A.JumpTo,position:e.inlineEdit.action.position,viewData:gb()};const s=e.inlineEdit;let r=this._determineView(e,t,i,n);if(this._willRenderAboveCursor(t,s,r))switch(r){case A.LineReplacement:case A.WordReplacements:r=A.SideBySide;break}this._previousView={id:this._getCacheId(e),view:r,editorWidth:this._editor.getLayoutInfo().width,timestamp:Date.now(),uri:this._editorObs.model.get().uri};const l=i.flatMap(p=>p.innerChanges??[]),d=this._editor.getModel(),h=l.map(p=>({originalRange:p.originalRange,modifiedRange:p.modifiedRange,original:s.originalText.getValueOfRange(p.originalRange),modified:n.getValueOfRange(p.modifiedRange)})),u=OR(s,h,d);switch(r){case A.InsertionInline:return{kind:A.InsertionInline,viewData:u};case A.SideBySide:return{kind:A.SideBySide,viewData:u};case A.Collapsed:return{kind:A.Collapsed,viewData:u};case A.Custom:return{kind:A.Custom,displayLocation:e.displayLocation,viewData:u}}if(r===A.Deletion)return{kind:A.Deletion,originalRange:s.originalLineRange,deletions:l.map(p=>p.originalRange),viewData:u};if(r===A.InsertionMultiLine){const p=l[0];return{kind:A.InsertionMultiLine,lineNumber:p.originalRange.startLineNumber,column:p.originalRange.startColumn,text:n.getValueOfRange(p.modifiedRange),viewData:u}}const g=h.map(p=>new a.TextReplacement(p.originalRange,p.modified));if(g.length!==0){if(r===A.WordReplacements){let p=FR(g,s.originalText);return p.some(f=>f.range.isEmpty())&&(p=_b(g,s.originalText)),{kind:A.WordReplacements,replacements:p,alternativeAction:e.inlineEdit.action?.alternativeAction,viewData:u}}if(r===A.LineReplacement)return{kind:A.LineReplacement,originalRange:s.originalLineRange,modifiedRange:s.modifiedLineRange,modifiedLines:s.modifiedLineRange.mapToLineArray(p=>n.getLineAt(p)),replacements:l.map(p=>({originalRange:p.originalRange,modifiedRange:p.modifiedRange})),viewData:u}}}_willRenderAboveCursor(e,t,i){if(this._useCodeShifting.read(e)==="always")return!1;for(const s of t.multiCursorPositions)if(i===A.WordReplacements&&s.lineNumber===t.originalLineRange.startLineNumber+1||i===A.LineReplacement&&s.lineNumber>=t.originalLineRange.endLineNumberExclusive&&s.lineNumber<t.modifiedLineRange.endLineNumberExclusive+t.modifiedLineRange.length)return!0;return!1}_viewHasBeenShownLongerThan(e){const t=this._previousView?.timestamp;if(!t)throw new a.BugIndicatingError("viewHasBeenShownLongThan called before a view has been shown");return Date.now()-t>=e}};Wg=MR([PR(5,o.IInstantiationService)],Wg);const gb=()=>new ku(-1,-1,-1,-1,-1,-1,-1,!0);function OR(c,e,t){if(!c.edit)return gb();const i=c.cursorPosition,n=e.length===0?!1:e[0].modified.startsWith(t.getEOL());return new ku(c.edit.replacements.length===0?0:c.edit.replacements[0].range.getStartPosition().column-i.column,c.lineEdit.lineRange.startLineNumber-i.lineNumber+(n&&c.lineEdit.lineRange.startLineNumber>=i.lineNumber?1:0),c.lineEdit.lineRange.length,c.lineEdit.newLines.length,e.reduce((r,l)=>r+l.original.length,0),e.reduce((r,l)=>r+l.modified.length,0),e.length,e.every(r=>r.original===e[0].original&&r.modified===e[0].modified))}function pb(c){return c.every(t=>t.innerChanges.every(i=>e(i)));function e(t){return!(!t.originalRange.isEmpty()||!(t.modifiedRange.startLineNumber===t.modifiedRange.endLineNumber))}}function AR(c,e){if(!e||!pb(c))return!1;const t=e;return c.every(n=>n.innerChanges.every(s=>i(s)));function i(n){const s=n.originalRange.getStartPosition();return!!(t.isBeforeOrEqual(s)||s.lineNumber<t.lineNumber)}}function fb(c){const e=c.flatMap(i=>i.innerChanges??[]);if(e.length!==1)return!1;const t=e[0];return!(!t.originalRange.isEmpty()||t.modifiedRange.startLineNumber===t.modifiedRange.endLineNumber)}function mb(c,e,t){return c.map(n=>({original:e.originalText.getValueOfRange(n.originalRange),modified:t.getValueOfRange(n.modifiedRange)})).every(({original:n,modified:s})=>s.trim()===""&&n.length>0&&(n.length>s.length||n.trim()!==""))}function FR(c,e){return vb(c,e,t=>/^[a-zA-Z]$/.test(t))}function _b(c,e){return vb(c,e,t=>!/^\s$/.test(t))}function vb(c,e,t){const i=[];c.sort((s,r)=>a.Range.compareRangesUsingStarts(s.range,r.range));for(const s of c){let r=s.range.startColumn-1,l=s.range.endColumn-2,d="",h="";const u=e.getLineAt(s.range.startLineNumber),g=e.getLineAt(s.range.endLineNumber);if(n(u[r]))for(;n(u[r-1]);)d=u[r-1]+d,r--;if(n(g[l])||l<r)for(;n(g[l+1]);)h+=g[l+1],l++;let p=new a.TextReplacement(new a.Range(s.range.startLineNumber,r+1,s.range.endLineNumber,l+2),d+s.text+h);i.length>0&&a.Range.areIntersectingOrTouching(i[i.length-1].range,p.range)&&(p=a.TextReplacement.joinReplacements([i.pop(),p],e)),i.push(p)}function n(s){return s===void 0?!1:t(s)}return i}var zR=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},VR=function(c,e){return function(t,i){e(t,i,c)}};let Hg=class extends a.Disposable{constructor(e,t,i,n){super(),this._editor=e,this._model=t,this._showCollapsed=i,this._inlineEdit=o.derived(this,s=>{const r=this._model.read(s);if(!r||!this._editor.getModel())return;const d=r.inlineEditState.read(s);if(!d)return;const h=d.inlineSuggestion.action;let u;if(h?.kind==="edit"){const g=h.stringEdit,p=d.inlineSuggestion.originalTextRef.getTransformer(),f=g.replacements.map(m=>{const _=a.Range.fromPositions(p.getPosition(m.replaceRange.start),p.getPosition(m.replaceRange.endExclusive));return new a.TextReplacement(_,m.newText)});u=new a.TextEdit(f)}else u=void 0;return new jD(d.inlineSuggestion.originalTextRef,h,u,r.primaryPosition.read(void 0),r.allPositions.read(void 0),d.inlineSuggestion.source.inlineSuggestions.commands??[],d.inlineSuggestion)}),this._inlineEditModel=o.derived(this,s=>{const r=this._model.read(s);if(!r)return;const l=this._inlineEdit.read(s);if(!l)return;const d=o.derived(this,h=>{if(this._editorObs.isFocused.read(h)){if(r.tabShouldJumpToInlineEdit.read(h))return H.Jump;if(r.tabShouldAcceptInlineEdit.read(h))return H.Accept}return H.Inactive});return new qD(r,l,d)}),this._editorObs=o.observableCodeEditor(this._editor),this.view=this._register(n.createInstance(Wg,this._editor,this._inlineEditModel,this._model.map(s=>s?Vl.fromInlineCompletionModel(s):void 0),this._inlineEdit.map(s=>s?zl.fromInlineSuggestion(s.inlineCompletion):void 0),this._showCollapsed))}};Hg=zR([VR(3,o.IInstantiationService)],Hg);var BR=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},KR=function(c,e){return function(t,i){e(t,i,c)}};let ep=(Xn=class extends a.Disposable{constructor(e,t,i,n){super(),this._editor=e,this._model=t,this._focusIsInMenu=i,this._instantiationService=n,this._ghostTexts=o.derived(this,s=>this._model.read(s)?.ghostTexts.read(s)??[]),this._inlineEdit=o.derived(this,s=>this._model.read(s)?.inlineEditState.read(s)?.inlineSuggestion),this._everHadInlineEdit=o.derivedObservableWithCache(this,(s,r)=>r||!!this._inlineEdit.read(s)||!!this._model.read(s)?.inlineCompletionState.read(s)?.inlineSuggestion?.showInlineEditMenu),this._indicatorIsHoverVisible=o.observableValue(this,void 0),this._showInlineEditCollapsed=o.derived(this,s=>(this._model.read(s)?.showCollapsed.read(s)??!1)&&!this._indicatorIsHoverVisible.read(s)?.read(s)),this._inlineEditWidget=o.derivedDisposable(s=>{if(this._everHadInlineEdit.read(s))return this._instantiationService.createInstance(Hg,this._editor,this._model,this._showInlineEditCollapsed)}),this._gutterIndicatorState=o.derived(s=>{const r=this._model.read(s);if(!r)return;const l=r.state.read(s);if(l?.kind==="ghostText"&&l.inlineSuggestion?.showInlineEditMenu)return{displayRange:a.LineRange.ofLength(l.primaryGhostText.lineNumber,1),tabAction:o.derived(this,d=>this._editorObs.isFocused.read(d)?H.Accept:H.Inactive),gutterIndicatorOffset:o.constObservable(kR(l.inlineSuggestion,this._editor)),inlineSuggestion:l.inlineSuggestion,model:r};if(l?.kind==="inlineEdit"){const d=this._inlineEditWidget.read(s)?.view;if(!d)return;const h=d.displayRange.read(s);return h?{displayRange:h,tabAction:o.derived(u=>{if(this._editorObs.isFocused.read(u)){if(r.tabShouldJumpToInlineEdit.read(u))return H.Jump;if(r.tabShouldAcceptInlineEdit.read(u))return H.Accept}return H.Inactive}),gutterIndicatorOffset:d.gutterIndicatorOffset,inlineSuggestion:l.inlineSuggestion,model:r}:void 0}else return}),this._stablizedGhostTexts=LE(this._ghostTexts,this._store),this._editorObs=o.observableCodeEditor(this._editor),this._ghostTextWidgets=o.mapObservableArrayCached(this,this._stablizedGhostTexts,(s,r)=>r.add(this._createGhostText(s))).recomputeInitiallyAndOnChange(this._store),this._inlineEditWidget.recomputeInitiallyAndOnChange(this._store),this._fontFamily=this._editorObs.getOption(71).map(s=>s.fontFamily),this._register(o.createStyleSheetFromObservable(o.derived(s=>`
49
+ .monaco-editor .ghost-text-decoration,
50
+ .monaco-editor .ghost-text-decoration-preview,
51
+ .monaco-editor .ghost-text {
52
+ font-family: ${this._fontFamily.read(s)};
53
+ }`))),this._register(new oh(this._editor,this._model,this._instantiationService)),this._indicator=this._register(this._instantiationService.createInstance(Bl,this._editorObs,o.derived(s=>{const r=this._gutterIndicatorState.read(s);if(r)return new tb(zl.fromInlineSuggestion(r.inlineSuggestion),r.displayRange,Vl.fromInlineCompletionModel(r.model),r.inlineSuggestion.action?.kind==="edit"?r.inlineSuggestion.action.alternativeAction:void 0)}),this._gutterIndicatorState.map((s,r)=>s?.tabAction?.read(r)??H.Inactive),this._gutterIndicatorState.map((s,r)=>s?.gutterIndicatorOffset?.read(r)??0),this._inlineEditWidget.map((s,r)=>s?.view.inlineEditsIsHovered.read(r)??!1),this._focusIsInMenu)),this._indicatorIsHoverVisible.set(this._indicator.isHoverVisible,void 0),o.derived(s=>{const r=this._inlineEditWidget.read(s);if(r)return s.store.add(this._instantiationService.createInstance(Pg,r._inlineEditModel,o.constObservable(this._indicator),r.view._inlineCollapsedView))}).recomputeInitiallyAndOnChange(this._store)}_createGhostText(e){return this._instantiationService.createInstance(ur,this._editor,o.derived(t=>{const i=this._model.read(t),n=i?.inlineCompletionState.read(t)?.inlineSuggestion;return!i||!n?{ghostText:e.read(t),handleInlineCompletionShown:()=>{},warning:void 0}:{ghostText:e.read(t),handleInlineCompletionShown:s=>i.handleInlineSuggestionShown(n,A.GhostText,s,Date.now()),warning:pg.from(i?.warning.read(t))}}),{useSyntaxHighlighting:this._editorObs.getOption(71).map(t=>t.syntaxHighlightingEnabled),highlightShortSuggestions:!0})}shouldShowHoverAtViewZone(e){return this._ghostTextWidgets.get()[0]?.ownsViewZone(e)??!1}},Xn.hot=o.createHotClass(Xn),Xn);ep=BR([KR(3,o.IInstantiationService)],ep);function kR(c,e){const t=c.getSingleTextEdit(),i=e.getModel();if(!i)return 0;const n=i.getEOL();if(t.range.isEmpty()&&t.text.startsWith(n)){const s=e.getLineHeightForPosition(t.range.getStartPosition());return UR(t.text,n)*s}return 0}function UR(c,e){if(!e.length)return 0;let t=0,i=0;for(;c.startsWith(e,i);)t++,i+=e.length;return t}var $R=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},oi=function(c,e){return function(t,i){e(t,i,c)}},ut;wL(c=>ue.get(c));let ue=(Ct=class extends a.Disposable{static getInFocusedEditorOrParent(e){const t=i_(e);return t?ut.get(t):null}static get(e){return mx(e.getContribution(ut.ID))}constructor(e,t,i,n,s,r,l,d,h){super(),this.editor=e,this._instantiationService=t,this._contextKeyService=i,this._configurationService=n,this._commandService=s,this._debounceService=r,this._languageFeaturesService=l,this._accessibilitySignalService=d,this._keybindingService=h,this._focusIsInMenu=o.observableValue(this,!1),this._focusIsInEditorOrMenu=o.derived(this,m=>{const _=this._editorObs.isFocused.read(m),v=this._focusIsInMenu.read(m);return _||v}),this._cursorIsInIndentation=o.derived(this,m=>{const _=this._editorObs.cursorPosition.read(m);if(_===null)return!1;const v=this._editorObs.model.read(m);if(!v)return!1;this._editorObs.versionId.read(m);const b=v.getLineIndentColumn(_.lineNumber);return _.column<=b}),this.model=o.derivedDisposable(this,m=>{if(this._editorObs.isReadonly.read(m))return;const _=this._editorObs.model.read(m);return _?this._instantiationService.createInstance(Ju,_,this._suggestWidgetAdapter.selectedItem,this._editorObs.versionId,this._positions,this._debounceValue,this._enabledInConfig,()=>this._isEditorDictationInProgress(),this.editor):void 0}),this._playAccessibilitySignal=o.observableSignal(this),this._view=o.derived(m=>m.store.add(this._instantiationService.createInstance(ep.hot.read(m),this.editor,this.model,this._focusIsInMenu))),this._editorObs=o.observableCodeEditor(this.editor),this._positions=o.derived(this,m=>this._editorObs.selections.read(m)?.map(_=>_.getEndPosition())??[new a.Position(1,1)]),this._suggestWidgetAdapter=this._register(new nD(this._editorObs,m=>this.model.get()?.handleSuggestAccepted(m),()=>this.model.get()?.selectedInlineCompletion.get()?.getSingleTextEdit())),this._enabledInConfig=o.observableFromEvent(this,this.editor.onDidChangeConfiguration,()=>this.editor.getOption(71).enabled),this._register(this._contextKeyService.onDidChangeContext(m=>{m.affectsSome(new Set(["editorDictation.inProgress"]))&&this._isEditorDictationInProgress()&&this.model.get()?.stop()})),this._debounceValue=this._debounceService.for(this._languageFeaturesService.inlineCompletionsProvider,"InlineCompletionsDebounce",{min:50,max:50}),this.model.recomputeInitiallyAndOnChange(this._store),this._hideInlineEditOnSelectionChange=this._editorObs.getOption(71).map(m=>!0),this._view.recomputeInitiallyAndOnChange(this._store),ut._instances.add(this),this._register(a.toDisposable(()=>ut._instances.delete(this))),this._register(o.autorun(m=>{const _=this.model.read(m);if(!_)return;const v=_.state.read(m);if(!v||!this._focusIsInEditorOrMenu.read(void 0))return;const b=v.kind==="inlineEdit"?v.nextEditUri:void 0;for(const C of ut._instances)C!==this&&(b&&o.isEqual(b,C.editor.getModel()?.uri)?C.model.read(void 0)?.trigger():C.reject())})),this._register(o.autorun(m=>{const _=this.model.read(m),v=this.editor.getModel()?.uri;!_||!v||m.store.add(_.onDidAccept(()=>{for(const b of ut._instances){if(b===this)continue;const C=b.model.read(void 0)?.state.read(void 0);C?.kind==="inlineEdit"&&o.isEqual(C.nextEditUri,v)&&b.model.read(void 0)?.stop("automatic")}}))})),this._register(o.runOnChange(this._editorObs.onDidType,(m,_)=>{this._enabledInConfig.get()&&!this._isEditorDictationInProgress()&&this.model.get()?.trigger()})),this._register(o.runOnChange(this._editorObs.onDidPaste,(m,_)=>{this._enabledInConfig.get()&&!this._isEditorDictationInProgress()&&this.model.get()?.trigger()}));const u=new Set([o.CoreEditingCommands.Tab.id,o.CoreEditingCommands.DeleteLeft.id,o.CoreEditingCommands.DeleteRight.id,Qi,"acceptSelectedSuggestion",sl.ID,nl.ID,$.NextMatchFindAction,Yo.ID,el.ID,tl.ID,il.ID,...o.TriggerInlineEditCommandsRegistry.getRegisteredCommands()]);this._register(this._commandService.onDidExecuteCommand(m=>{if(u.has(m.commandId)&&e.hasTextFocus()&&this._enabledInConfig.get()&&!this._isEditorDictationInProgress()){let _=!1;m.commandId===Qi&&(_=!0),this._editorObs.forceUpdate(v=>{this.model.get()?.trigger(v,{noDelay:_})})}})),this._register(o.runOnChange(this._editorObs.selections,(m,_,v)=>{if(v.some(b=>b.reason===3||b.source==="api")){if(!this._hideInlineEditOnSelectionChange.get()&&this.model.get()?.state.get()?.kind==="inlineEdit")return;const b=this.model.get();if(!b)return;b.state.get()?.kind==="ghostText"&&this.model.get()?.stop()}})),this._register(o.autorun(m=>{const _=this._focusIsInEditorOrMenu.read(m),v=this.model.read(void 0);if(_){const b=v?.state.read(void 0);(!b||b.kind!=="inlineEdit"||!b.nextEditUri)&&o.transaction(C=>{for(const y of ut._instances)y!==this&&y.model.read(void 0)?.stop("automatic",C)});return}this._contextKeyService.getContextKeyValue("accessibleViewIsShown")||this._configurationService.getValue("editor.inlineSuggest.keepOnBlur")||e.getOption(71).keepOnBlur||gs.dropDownVisible||v&&(v.state.read(void 0)?.inlineSuggestion?.isFromExplicitRequest&&v.inlineEditAvailable.read(void 0)||o.transaction(b=>{v.stop("automatic",b)}))})),this._register(o.autorun(m=>{const _=this.model.read(m)?.inlineCompletionState.read(m);_?.suggestItem?_.primaryGhostText.lineCount>=2&&this._suggestWidgetAdapter.forceRenderingAbove():this._suggestWidgetAdapter.stopForceRenderingAbove()})),this._register(a.toDisposable(()=>{this._suggestWidgetAdapter.stopForceRenderingAbove()}));const g=o.derivedObservableWithCache(this,(m,_)=>{const b=this.model.read(m)?.state.read(m);return this._suggestWidgetAdapter.selectedItem.get()?_:b?.inlineSuggestion?.semanticId});this._register(o.runOnChangeWithStore(o.derived(m=>(this._playAccessibilitySignal.read(m),g.read(m),{})),async(m,_,v,b)=>{let C=this.model.get(),y=C?.state.get();if(!y||!C||(await a.timeout(50,a.cancelOnDispose(b)),await o.waitForState(this._suggestWidgetAdapter.selectedItem,a.isUndefined,()=>!1,a.cancelOnDispose(b)),C=this.model.get(),y=C?.state.get(),!y||!C))return;const I=y.kind==="ghostText"?C.textModel.getLineContent(y.primaryGhostText.lineNumber):"";if(this._accessibilitySignalService.playSignal(y.kind==="ghostText"?o.AccessibilitySignal.inlineSuggestion:o.AccessibilitySignal.nextEditSuggestion),this.editor.getOption(12))if(y.kind==="ghostText")this._provideScreenReaderUpdate(y.primaryGhostText.renderForScreenReader(I));else{const x=y.inlineSuggestion.targetRange.startLineNumber,S=C.tabShouldAcceptInlineEdit.get(),w=C.tabShouldJumpToInlineEdit.get();let E;if(S){const L=this._keybindingService.lookupKeybinding(Qi)?.getAriaLabel();E=L?a.localize(1262,"Next edit suggestion available on line {0}, press {1} to accept",x,L):a.localize(1263,"Next edit suggestion available on line {0}, accept it to apply",x)}else if(w){const L=this._keybindingService.lookupKeybinding(ih)?.getAriaLabel();E=L?a.localize(1264,"Next edit suggestion available on line {0}, press {1} to jump",x,L):a.localize(1265,"Next edit suggestion available on line {0}",x)}else E=a.localize(1266,"Next edit suggestion available on line {0}",x);this._provideScreenReaderUpdate(E)}})),this._register(this._configurationService.onDidChangeConfiguration(m=>{m.affectsConfiguration("accessibility.verbosity.inlineCompletions")&&this.editor.updateOptions({inlineCompletionsAccessibilityVerbose:this._configurationService.getValue("accessibility.verbosity.inlineCompletions")})})),this.editor.updateOptions({inlineCompletionsAccessibilityVerbose:this._configurationService.getValue("accessibility.verbosity.inlineCompletions")});const p=new DE(this._contextKeyService);this._register(p.bind(B.cursorInIndentation,this._cursorIsInIndentation)),this._register(p.bind(B.hasSelection,m=>!this._editorObs.cursorSelection.read(m)?.isEmpty())),this._register(p.bind(B.cursorAtInlineEdit,this.model.map((m,_)=>m?.inlineEditState?.read(_)?.cursorAtInlineEdit.read(_)))),this._register(p.bind(B.tabShouldAcceptInlineEdit,this.model.map((m,_)=>!!m?.tabShouldAcceptInlineEdit.read(_)))),this._register(p.bind(B.tabShouldJumpToInlineEdit,this.model.map((m,_)=>!!m?.tabShouldJumpToInlineEdit.read(_)))),this._register(p.bind(B.inlineEditVisible,m=>this.model.read(m)?.inlineEditState.read(m)!==void 0)),this._register(p.bind(B.inlineSuggestionHasIndentation,m=>this.model.read(m)?.getIndentationInfo(m)?.startsWithIndentation)),this._register(p.bind(B.inlineSuggestionHasIndentationLessThanTabSize,m=>this.model.read(m)?.getIndentationInfo(m)?.startsWithIndentationLessThanTabSize)),this._register(p.bind(B.suppressSuggestions,m=>{const v=this.model.read(m)?.inlineCompletionState.read(m);return v?.primaryGhostText&&v?.inlineSuggestion?v.inlineSuggestion.source.inlineSuggestions.suppressSuggestions:void 0})),this._register(p.bind(B.inlineSuggestionAlternativeActionVisible,m=>{const b=this.model.read(m)?.inlineEditState.read(m)?.inlineSuggestion.action;return b&&b.kind==="edit"&&b.alternativeAction!==void 0})),this._register(p.bind(B.inlineSuggestionVisible,m=>{const v=this.model.read(m)?.inlineCompletionState.read(m);return!!v?.inlineSuggestion&&v?.primaryGhostText!==void 0&&!v?.primaryGhostText.isEmpty()}));const f=o.derived(this,m=>{const b=this.model.read(m)?.inlineCompletionState.read(m)?.primaryGhostText;return!b||b.isEmpty()?void 0:new a.Position(b.lineNumber,b.parts[0].column)});this._register(p.bind(B.cursorBeforeGhostText,m=>{const _=f.read(m);if(!_)return!1;const v=this._editorObs.cursorPosition.read(m);return v?_.equals(v):!1})),this._register(this._instantiationService.createInstance(Ou,this.editor))}_isEditorDictationInProgress(){return this._contextKeyService.getContext(this.editor.getDomNode())?.getValue("editorDictation.inProgress")===!0}playAccessibilitySignal(e){this._playAccessibilitySignal.trigger(e)}_provideScreenReaderUpdate(e){const t=this._contextKeyService.getContextKeyValue("accessibleViewIsShown"),i=this._keybindingService.lookupKeybinding("editor.action.accessibleView");let n;!t&&i&&this.editor.getOption(170)&&(n=a.localize(1267,"Inspect this in the accessible view ({0})",i.getAriaLabel())),o.alert(n?e+", "+n:e)}shouldShowHoverAt(e){const t=this.model.get()?.primaryGhostText.get();return t?t.parts.some(i=>e.containsPosition(new a.Position(t.lineNumber,i.column))):!1}shouldShowHoverAtViewZone(e){return this._view.get().shouldShowHoverAtViewZone(e)}reject(){o.transaction(e=>{const t=this.model.get();if(t&&(t.stop("explicitCancel",e),this._focusIsInEditorOrMenu.get()))for(const i of ut._instances)i!==this&&!i._focusIsInEditorOrMenu.get()&&i.model.get()?.stop("automatic",e)})}jump(){const e=this.model.get();e&&e.jump()}},ut=Ct,Ct._instances=new Set,Ct.hot=o.createHotClass(Ct),Ct.ID="editor.contrib.inlineCompletionsController",Ct);ue=ut=$R([oi(1,o.IInstantiationService),oi(2,o.IContextKeyService),oi(3,o.IConfigurationService),oi(4,o.ICommandService),oi(5,o.ILanguageFeatureDebounceService),oi(6,o.ILanguageFeaturesService),oi(7,o.IAccessibilitySignalService),oi(8,o.IKeybindingService)],ue);const jc=class jc extends o.EditorAction{constructor(){super({id:jc.ID,label:a.localize2(1239,"Show Next Inline Suggestion"),precondition:o.ContextKeyExpr.and(o.EditorContextKeys.writable,B.inlineSuggestionVisible),kbOpts:{weight:100,primary:606}})}async run(e,t){ue.get(t)?.model.get()?.next()}};jc.ID=bm;let tp=jc;const qc=class qc extends o.EditorAction{constructor(){super({id:qc.ID,label:a.localize2(1240,"Show Previous Inline Suggestion"),precondition:o.ContextKeyExpr.and(o.EditorContextKeys.writable,B.inlineSuggestionVisible),kbOpts:{weight:100,primary:604}})}async run(e,t){ue.get(t)?.model.get()?.previous()}};qc.ID=vm;let ip=qc;const jR="vscode://schemas/inlineCompletionProviderIdArgs";function qR(c){const e=[];return c.providerId&&(e.push(c.providerId.toStringWithoutVersion()),e.push(c.providerId.extensionId+":*")),e}const bb=Lx(xx({showNoResultNotification:Xa(k_()),providerId:Xa(Rx(jR,bx())),explicit:Xa(k_()),changeHintData:Xa(yx())}),wx());class GR extends o.EditorAction{constructor(){super({id:"editor.action.inlineSuggest.trigger",label:a.localize2(1241,"Trigger Inline Suggestion"),precondition:o.EditorContextKeys.writable,metadata:{description:a.localize(1228,"Triggers an inline suggestion in the editor."),args:[{name:"args",description:a.localize(1229,"Options for triggering inline suggestions."),isOptional:!0,schema:bb.getJSONSchema()}]}})}async run(e,t,i){const n=e.get(o.INotificationService),s=e.get(o.ILanguageFeaturesService),r=ue.get(t),l=bb.validateOrThrow(i),d=l?.providerId?s.inlineCompletionsProvider.all(t.getModel()).find(h=>qR(h).some(u=>u===l.providerId)):void 0;await o.asyncTransaction(async h=>{await r?.model.get()?.trigger(h,{provider:d,explicit:l?.explicit??!0,changeHint:l?.changeHintData?{data:l.changeHintData}:void 0}),r?.playAccessibilitySignal(h)}),l?.showNoResultNotification&&(r?.model.get()?.state.get()||n.notify({severity:o.Severity.Info,message:a.localize(1230,"No inline suggestion is available.")}))}}class ZR extends o.EditorAction{constructor(){super({id:"editor.action.inlineSuggest.acceptNextWord",label:a.localize2(1242,"Accept Next Word Of Inline Suggestion"),precondition:o.ContextKeyExpr.and(o.EditorContextKeys.writable,B.inlineSuggestionVisible),kbOpts:{weight:101,primary:2065,kbExpr:o.ContextKeyExpr.and(o.EditorContextKeys.writable,B.inlineSuggestionVisible,B.cursorBeforeGhostText,o.CONTEXT_ACCESSIBILITY_MODE_ENABLED.negate())},menuOpts:[{menuId:o.MenuId.InlineSuggestionToolbar,title:a.localize(1231,"Accept Word"),group:"primary",order:2}]})}async run(e,t){await ue.get(t)?.model.get()?.acceptNextWord()}}class XR extends o.EditorAction{constructor(){super({id:"editor.action.inlineSuggest.acceptNextLine",label:a.localize2(1243,"Accept Next Line Of Inline Suggestion"),precondition:o.ContextKeyExpr.and(o.EditorContextKeys.writable,B.inlineSuggestionVisible),kbOpts:{weight:101},menuOpts:[{menuId:o.MenuId.InlineSuggestionToolbar,title:a.localize(1232,"Accept Line"),group:"secondary",order:2}]})}async run(e,t){await ue.get(t)?.model.get()?.acceptNextLine()}}class YR extends o.EditorAction{constructor(){super({id:Qi,label:a.localize2(1244,"Accept Inline Suggestion"),precondition:o.ContextKeyExpr.or(B.inlineSuggestionVisible,B.inlineEditVisible),menuOpts:[{menuId:o.MenuId.InlineSuggestionToolbar,title:a.localize(1233,"Accept"),group:"primary",order:2},{menuId:o.MenuId.InlineEditsActions,title:a.localize(1234,"Accept"),group:"primary",order:2}],kbOpts:[{primary:2,weight:200,kbExpr:o.ContextKeyExpr.or(o.ContextKeyExpr.and(B.inlineSuggestionVisible,o.EditorContextKeys.tabMovesFocus.toNegated(),N.Visible.toNegated(),o.EditorContextKeys.hoverFocused.toNegated(),B.hasSelection.toNegated(),B.inlineSuggestionHasIndentationLessThanTabSize),o.ContextKeyExpr.and(B.inlineEditVisible,o.EditorContextKeys.tabMovesFocus.toNegated(),N.Visible.toNegated(),o.EditorContextKeys.hoverFocused.toNegated(),B.tabShouldAcceptInlineEdit))}]})}async run(e,t){const i=ue.getInFocusedEditorOrParent(e);i&&(i.model.get()?.accept(i.editor),i.editor.focus())}}o.KeybindingsRegistry.registerKeybindingRule({id:Qi,weight:202,primary:2,when:o.ContextKeyExpr.and(B.inInlineEditsPreviewEditor)});class QR extends o.EditorAction{constructor(){super({id:oa,label:a.localize2(1245,"Accept Inline Suggestion Alternative Action"),precondition:o.ContextKeyExpr.and(B.inlineSuggestionAlternativeActionVisible,B.inlineEditVisible),menuOpts:[],kbOpts:[{primary:1026,weight:203}]})}async run(e,t){const i=ue.getInFocusedEditorOrParent(e);i&&(i.model.get()?.accept(i.editor,!0),i.editor.focus())}}o.KeybindingsRegistry.registerKeybindingRule({id:oa,weight:203,primary:1026,when:o.ContextKeyExpr.and(B.inInlineEditsPreviewEditor)});class JR extends o.EditorAction{constructor(){super({id:ih,label:a.localize2(1246,"Jump to next inline edit"),precondition:B.inlineEditVisible,menuOpts:[{menuId:o.MenuId.InlineEditsActions,title:a.localize(1235,"Jump"),group:"primary",order:1,when:B.cursorAtInlineEdit.toNegated()}],kbOpts:{primary:2,weight:201,kbExpr:o.ContextKeyExpr.and(B.inlineEditVisible,o.EditorContextKeys.tabMovesFocus.toNegated(),N.Visible.toNegated(),o.EditorContextKeys.hoverFocused.toNegated(),B.tabShouldJumpToInlineEdit)}})}async run(e,t){const i=ue.get(t);i&&i.jump()}}const Gc=class Gc extends o.EditorAction{constructor(){super({id:Gc.ID,label:a.localize2(1247,"Hide Inline Suggestion"),precondition:o.ContextKeyExpr.or(B.inlineSuggestionVisible,B.inlineEditVisible),kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,weight:190,primary:9},menuOpts:[{menuId:o.MenuId.InlineEditsActions,title:a.localize(1236,"Reject"),group:"primary",order:3}]})}async run(e,t){const i=ue.getInFocusedEditorOrParent(e);o.transaction(n=>{i?.model.get()?.stop("explicitCancel",n)}),i?.editor.focus()}};Gc.ID=Cm;let $l=Gc;const Zc=class Zc extends o.EditorAction{constructor(){super({id:Zc.ID,label:a.localize2(1248,"Toggle Inline Suggestions Show Collapsed"),precondition:o.ContextKeyExpr.true()})}async run(e,t){const i=e.get(o.IConfigurationService),n=i.getValue("editor.inlineSuggest.edits.showCollapsed");i.updateValue("editor.inlineSuggest.edits.showCollapsed",!n)}};Zc.ID=nh;let np=Zc;o.KeybindingsRegistry.registerKeybindingRule({id:$l.ID,weight:-1,primary:9,secondary:[1033],when:o.ContextKeyExpr.and(B.inInlineEditsPreviewEditor)});const Xc=class Xc extends o.Action2{constructor(){super({id:Xc.ID,title:a.localize(1237,"Always Show Toolbar"),f1:!1,precondition:void 0,menu:[{id:o.MenuId.InlineSuggestionToolbar,group:"secondary",order:10}],toggled:o.ContextKeyExpr.equals("config.editor.inlineSuggest.showToolbar","always")})}async run(e){const t=e.get(o.IConfigurationService),n=t.getValue("editor.inlineSuggest.showToolbar")==="always"?"onHover":"always";t.updateValue("editor.inlineSuggest.showToolbar",n)}};Xc.ID="editor.action.inlineSuggest.toggleAlwaysShowToolbar";let sp=Xc;class WR extends o.EditorAction{constructor(){super({id:"editor.action.inlineSuggest.dev.extractRepro",label:a.localize(1238,"Developer: Extract Inline Suggest State"),alias:"Developer: Inline Suggest Extract Repro",precondition:o.ContextKeyExpr.or(B.inlineEditVisible,B.inlineSuggestionVisible)})}async run(e,t){const i=e.get(o.IClipboardService),s=ue.get(t)?.model.get();if(!s)return;const r=s.extractReproSample(),d=a.splitLines(JSON.stringify({inlineCompletion:r.inlineCompletion},null,4)).map(u=>"// "+u).join(`
54
+ `),h=`${r.documentValue}
55
+
56
+ // <json>
57
+ ${d}
58
+ // </json>
59
+ `;return await i.writeText(h),{reproCase:h}}}var HR=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},jl=function(c,e){return function(t,i){e(t,i,c)}};class eT{constructor(e,t,i){this.owner=e,this.range=t,this.controller=i}isValidForHoverAnchor(e){return e.type===1&&this.range.startColumn<=e.range.startColumn&&this.range.endColumn>=e.range.endColumn}}let op=class{constructor(e,t,i,n,s){this._editor=e,this.accessibilityService=t,this._instantiationService=i,this._telemetryService=n,this._markdownRendererService=s,this.hoverOrdinal=4,this.hideCopyButton=!0}suggestHoverAnchor(e){const t=ue.get(this._editor);if(!t)return null;const i=e.target;if(i.type===8){const n=i.detail;if(t.shouldShowHoverAtViewZone(n.viewZoneId))return new xo(1e3,this,a.Range.fromPositions(this._editor.getModel().validatePosition(n.positionBefore||n.position)),e.event.posx,e.event.posy,!1)}if(i.type===7&&t.shouldShowHoverAt(i.range))return new xo(1e3,this,i.range,e.event.posx,e.event.posy,!1);if(i.type===6&&i.detail.mightBeForeignElement&&t.shouldShowHoverAt(i.range))return new xo(1e3,this,i.range,e.event.posx,e.event.posy,!1);if(i.type===9&&i.element){const n=ur.getWarningWidgetContext(i.element);if(n&&t.shouldShowHoverAt(n.range))return new xo(1e3,this,n.range,e.event.posx,e.event.posy,!1)}return null}computeSync(e,t){if(this._editor.getOption(71).showToolbar!=="onHover")return[];const i=ue.get(this._editor);return i&&i.shouldShowHoverAt(e.range)?[new eT(this,e.range,i)]:[]}renderHoverParts(e,t){const i=new a.DisposableStore,n=t[0];this._telemetryService.publicLog2("inlineCompletionHover.shown"),this.accessibilityService.isScreenReaderOptimized()&&!this._editor.getOption(12)&&i.add(this.renderScreenReaderText(e,n));const s=n.controller.model.get(),r=document.createElement("div");e.fragment.appendChild(r),i.add(o.autorunWithStore((d,h)=>{const u=h.add(this._instantiationService.createInstance(gs.hot.read(d),this._editor,!1,o.constObservable(null),s.selectedInlineCompletionIndex,s.inlineCompletionsCount,s.activeCommands,s.warning,()=>{e.onContentsChanged()}));r.replaceChildren(u.getDomNode())})),s.triggerExplicitly();const l={hoverPart:n,hoverElement:r,dispose(){i.dispose()}};return new Zi([l])}getAccessibleContent(e){return a.localize(1268,"There are inline completions here")}renderScreenReaderText(e,t){const i=new a.DisposableStore,n=o.$,s=n("div.hover-row.markdown-hover"),r=o.append(s,n("div.hover-contents",{"aria-live":"assertive"})),l=d=>{const h=a.localize(1269,"Suggestion:"),u=i.add(this._markdownRendererService.render(new o.MarkdownString().appendText(h).appendCodeblock("text",d),{context:this._editor,asyncRenderCallback:()=>{r.className="hover-contents code-hover-contents",e.onContentsChanged()}}));r.replaceChildren(u.element)};return i.add(o.autorun(d=>{const h=t.controller.model.read(d)?.primaryGhostText.read(d);if(h){const u=this._editor.getModel().getLineContent(h.lineNumber);l(h.renderForScreenReader(u))}else o.reset(r)})),e.fragment.appendChild(s),i}};op=HR([jl(1,o.IAccessibilityService),jl(2,o.IInstantiationService),jl(3,o.ITelemetryService),jl(4,o.IMarkdownRendererService)],op);class tT{}o.registerEditorContribution(ue.ID,_x(ue.hot),3),o.registerEditorAction(GR),o.registerEditorAction(tp),o.registerEditorAction(ip),o.registerEditorAction(ZR),o.registerEditorAction(XR),o.registerEditorAction(YR),o.registerEditorAction(QR),o.registerEditorAction(np),o.registerEditorAction($l),o.registerEditorAction(JR),o.registerAction2(sp),o.registerEditorAction(WR),o.registerAction2(o.SnoozeInlineCompletion),o.registerAction2(o.CancelSnoozeInlineCompletion),Xi.register(op),Ga.register(new tT);var iT=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},rp=function(c,e){return function(t,i){e(t,i,c)}},Rr;let Tr=(Ti=class{constructor(e,t,i,n){this.textModelResolverService=t,this.languageService=i,this.languageFeaturesService=n,this.toUnhook=new a.DisposableStore,this.toUnhookForKeyboard=new a.DisposableStore,this.currentWordAtPosition=null,this.previousPromise=null,this.editor=e,this.linkDecorations=this.editor.createDecorationsCollection();const s=new wa(e);this.toUnhook.add(s),this.toUnhook.add(s.onMouseMoveOrRelevantKeyDown(([r,l])=>{this.startFindDefinitionFromMouse(r,l??void 0)})),this.toUnhook.add(s.onExecute(r=>{this.isEnabled(r)&&this.gotoDefinition(r.target.position,r.hasSideBySideModifier).catch(l=>{a.onUnexpectedError(l)}).finally(()=>{this.removeLinkDecorations()})})),this.toUnhook.add(s.onCancel(()=>{this.removeLinkDecorations(),this.currentWordAtPosition=null}))}static get(e){return e.getContribution(Rr.ID)}async startFindDefinitionFromCursor(e){await this.startFindDefinition(e),this.toUnhookForKeyboard.add(this.editor.onDidChangeCursorPosition(()=>{this.currentWordAtPosition=null,this.removeLinkDecorations(),this.toUnhookForKeyboard.clear()})),this.toUnhookForKeyboard.add(this.editor.onKeyDown(t=>{t&&(this.currentWordAtPosition=null,this.removeLinkDecorations(),this.toUnhookForKeyboard.clear())}))}startFindDefinitionFromMouse(e,t){if(e.target.type===9&&this.linkDecorations.length>0)return;if(!this.editor.hasModel()||!this.isEnabled(e,t)){this.currentWordAtPosition=null,this.removeLinkDecorations();return}const i=e.target.position;this.startFindDefinition(i)}async startFindDefinition(e){this.toUnhookForKeyboard.clear();const t=e?this.editor.getModel()?.getWordAtPosition(e):null;if(!t){this.currentWordAtPosition=null,this.removeLinkDecorations();return}if(this.currentWordAtPosition&&this.currentWordAtPosition.startColumn===t.startColumn&&this.currentWordAtPosition.endColumn===t.endColumn&&this.currentWordAtPosition.word===t.word)return;this.currentWordAtPosition=t;const i=new o.EditorState(this.editor,15);this.previousPromise&&(this.previousPromise.cancel(),this.previousPromise=null),this.previousPromise=a.createCancelablePromise(r=>this.findDefinition(e,r));let n;try{n=await this.previousPromise}catch(r){a.onUnexpectedError(r);return}if(!n||!n.length||!i.validate(this.editor)){this.removeLinkDecorations();return}const s=n[0].originSelectionRange?a.Range.lift(n[0].originSelectionRange):new a.Range(e.lineNumber,t.startColumn,e.lineNumber,t.endColumn);if(n.length>1){let r=s;for(const{originSelectionRange:l}of n)l&&(r=a.Range.plusRange(r,l));this.addDecoration(r,new o.MarkdownString().appendText(a.localize(1135,"Click to show {0} definitions.",n.length)))}else{const r=n[0];return r.uri?this.textModelResolverService.createModelReference(r.uri).then(l=>{if(!l.object||!l.object.textEditorModel){l.dispose();return}const{object:{textEditorModel:d}}=l,{startLineNumber:h}=r.range;if(h<1||h>d.getLineCount()){l.dispose();return}const u=this.getPreviewValue(d,h,r),g=this.languageService.guessLanguageIdByFilepathOrFirstLine(d.uri);this.addDecoration(s,u?new o.MarkdownString().appendCodeblock(g||"",u):void 0),l.dispose()}):void 0}}getPreviewValue(e,t,i){let n=i.range;return n.endLineNumber-n.startLineNumber>=Rr.MAX_SOURCE_PREVIEW_LINES&&(n=this.getPreviewRangeBasedOnIndentation(e,t)),n=e.validateRange(n),this.stripIndentationFromPreviewRange(e,t,n)}stripIndentationFromPreviewRange(e,t,i){let s=e.getLineFirstNonWhitespaceColumn(t);for(let l=t+1;l<i.endLineNumber;l++){const d=e.getLineFirstNonWhitespaceColumn(l);s=Math.min(s,d)}return e.getValueInRange(i).replace(new RegExp(`^\\s{${s-1}}`,"gm"),"").trim()}getPreviewRangeBasedOnIndentation(e,t){const i=e.getLineFirstNonWhitespaceColumn(t),n=Math.min(e.getLineCount(),t+Rr.MAX_SOURCE_PREVIEW_LINES);let s=t+1;for(;s<n;s++){const r=e.getLineFirstNonWhitespaceColumn(s);if(i===r)break}return new a.Range(t,1,s+1,1)}addDecoration(e,t){const i={range:e,options:{description:"goto-definition-link",inlineClassName:"goto-definition-link",hoverMessage:t}};this.linkDecorations.set([i])}removeLinkDecorations(){this.linkDecorations.clear()}isEnabled(e,t){return this.editor.hasModel()&&e.isLeftClick&&e.isNoneOrSingleMouseDown&&e.target.type===6&&!(e.target.detail.injectedText?.options instanceof o.ModelDecorationInjectedTextOptions)&&(e.hasTriggerModifier||(t?t.keyCodeIsTriggerKey:!1))&&this.languageFeaturesService.definitionProvider.has(this.editor.getModel())}findDefinition(e,t){const i=this.editor.getModel();return i?Fo(this.languageFeaturesService.definitionProvider,i,e,!1,t):Promise.resolve(null)}async gotoDefinition(e,t){return this.editor.setPosition(e),this.editor.invokeWithinContext(i=>{const n=!t&&this.editor.getOption(101)&&!this.isInPeekEditor(i);return new Vo({openToSide:t,openInPeek:n,muteMessage:!0},{title:{value:"",original:""},id:"",precondition:void 0}).run(i)})}isInPeekEditor(e){const t=e.get(o.IContextKeyService);return pe.inPeekEditor.getValue(t)}dispose(){this.toUnhook.dispose(),this.toUnhookForKeyboard.dispose()}},Rr=Ti,Ti.ID="editor.contrib.gotodefinitionatposition",Ti.MAX_SOURCE_PREVIEW_LINES=8,Ti);Tr=Rr=iT([rp(1,o.ITextModelService),rp(2,o.ILanguageService),rp(3,o.ILanguageFeaturesService)],Tr),o.registerEditorContribution(Tr.ID,Tr,2);var nT=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Cb=function(c,e){return function(t,i){e(t,i,c)}};let ql=(ro=class extends a.Disposable{constructor(e,t,i){super(),this._editor=e,this._markerService=i,this._ctxHasDiagnostics=o.EditorContextKeys.selectionHasDiagnostics.bindTo(t),this._store.add(this._editor.onDidChangeCursorSelection(()=>this._update())),this._store.add(this._editor.onDidChangeModel(()=>this._update())),this._store.add(this._markerService.onMarkerChanged(n=>{const s=this._editor.getModel();s&&n.some(r=>o.isEqual(r,s.uri))&&this._update()})),this._update()}dispose(){this._ctxHasDiagnostics.reset(),super.dispose()}_update(){const e=this._editor.getModel(),t=this._editor.getSelection();if(!e||!t){this._ctxHasDiagnostics.reset();return}const n=this._markerService.read({resource:e.uri,severities:o.MarkerSeverity$1.Error|o.MarkerSeverity$1.Warning|o.MarkerSeverity$1.Info}).some(s=>a.Range.areIntersecting({startLineNumber:s.startLineNumber,startColumn:s.startColumn,endLineNumber:s.endLineNumber,endColumn:s.endColumn},t));this._ctxHasDiagnostics.set(n)}},ro.ID="editor.contrib.markerSelectionStatus",ro);ql=nT([Cb(1,o.IContextKeyService),Cb(2,o.IMarkerService)],ql),o.registerEditorContribution(ql.ID,ql,1);class sT extends o.EditorAction{constructor(){super({id:"editor.action.debugEditorGpuRenderer",label:a.localize2(1159,"Developer: Debug Editor GPU Renderer"),precondition:o.ContextKeyExpr.true()})}async run(e,t){const i=e.get(o.IInstantiationService),s=await e.get(o.IQuickInputService).pick([{label:a.localize(1156,"Log Texture Atlas Stats"),id:"logTextureAtlasStats"},{label:a.localize(1157,"Save Texture Atlas"),id:"saveTextureAtlas"},{label:a.localize(1158,"Draw Glyph"),id:"drawGlyph"}],{canPickMany:!1});if(s)switch(s.id){case"logTextureAtlasStats":i.invokeFunction(r=>{const l=r.get(o.ILogService),d=o.ViewGpuContext.atlas;if(!o.ViewGpuContext.atlas){l.error("No texture atlas found");return}const h=d.getStats();l.info(["Texture atlas stats",...h].join(`
60
+
61
+ `))});break;case"saveTextureAtlas":i.invokeFunction(async r=>{const l=r.get(o.IWorkspaceContextService),d=r.get(Vv),h=l.getWorkspace().folders;if(h.length>0){const u=o.ViewGpuContext.atlas,g=[];for(const[p,f]of u.pages.entries())g.push(d.writeFile(a.URI.joinPath(h[0].uri,`textureAtlasPage${p}_actual.png`),a.VSBuffer.wrap(new Uint8Array(await(await f.source.convertToBlob()).arrayBuffer()))),d.writeFile(a.URI.joinPath(h[0].uri,`textureAtlasPage${p}_usage.png`),a.VSBuffer.wrap(new Uint8Array(await(await f.getUsagePreview()).arrayBuffer()))));await Promise.all(g)}});break;case"drawGlyph":i.invokeFunction(async r=>{const l=r.get(o.IConfigurationService),d=r.get(Vv),h=r.get(o.IQuickInputService),g=r.get(o.IWorkspaceContextService).getWorkspace().folders;if(g.length===0)return;const p=o.ViewGpuContext.atlas,f=l.getValue("editor.fontFamily"),m=l.getValue("editor.fontSize"),_=new o.GlyphRasterizer(m,f,o.getActiveWindow().devicePixelRatio,o.ViewGpuContext.decorationStyleCache);let v=await h.input({prompt:"Enter a character to draw (prefix with 0x for code point))"});if(!v)return;const b=v.match(/0x(?<codePoint>[0-9a-f]+)/i)?.groups?.codePoint;b!==void 0&&(v=String.fromCodePoint(parseInt(b,16)));const C=0,I=p.getGlyph(_,v,C,0,0);if(!I)return;const x=p.pages[I.pageIndex].source.getContext("2d")?.getImageData(I.x,I.y,I.w,I.h);if(!x)return;const S=new OffscreenCanvas(x.width,x.height);o.ensureNonNullable(S.getContext("2d")).putImageData(x,0,0);const E=await S.convertToBlob({type:"image/png"}),L=a.URI.joinPath(g[0].uri,`glyph_${v}_${C}_${m}px_${f.replaceAll(/[,\\\/\.'\s]/g,"_")}.png`);await d.writeFile(L,a.VSBuffer.wrap(new Uint8Array(await E.arrayBuffer())))});break}}}o.registerEditorAction(sT);var tt;(function(c){c.NoAutoFocus="noAutoFocus",c.FocusIfVisible="focusIfVisible",c.AutoFocusImmediately="autoFocusImmediately"})(tt||(tt={}));class oT extends o.EditorAction{constructor(){super({id:_m,label:a.localize2(1165,"Show or Focus Hover"),metadata:{description:a.localize2(1166,"Show or focus the editor hover which shows documentation, references, and other content for a symbol at the current cursor position."),args:[{name:"args",schema:{type:"object",properties:{focus:{description:"Controls if and when the hover should take focus upon being triggered by this action.",enum:[tt.NoAutoFocus,tt.FocusIfVisible,tt.AutoFocusImmediately],enumDescriptions:[a.localize(1162,"The hover will not automatically take focus."),a.localize(1163,"The hover will take focus only if it is already visible."),a.localize(1164,"The hover will automatically take focus when it appears.")],default:tt.FocusIfVisible}}}}]},precondition:void 0,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:a.KeyChord(2089,2087),weight:100}})}run(e,t,i){if(!t.hasModel())return;const n=oe.get(t);if(!n)return;const s=i?.focus;let r=tt.FocusIfVisible;Object.values(tt).includes(s)?r=s:typeof s=="boolean"&&s&&(r=tt.AutoFocusImmediately);const l=h=>{const u=t.getPosition(),g=new a.Range(u.lineNumber,u.column,u.lineNumber,u.column);n.showContentHover(g,1,2,h)},d=t.getOption(2)===2;n.isHoverVisible?r!==tt.NoAutoFocus?n.focus():l(d):l(d||r===tt.AutoFocusImmediately)}}class rT extends o.EditorAction{constructor(){super({id:$S,label:a.localize2(1167,"Show Definition Preview Hover"),precondition:void 0,metadata:{description:a.localize2(1168,"Show the definition preview hover in the editor.")}})}run(e,t){const i=oe.get(t);if(!i)return;const n=t.getPosition();if(!n)return;const s=new a.Range(n.lineNumber,n.column,n.lineNumber,n.column),r=Tr.get(t);if(!r)return;r.startFindDefinitionFromCursor(n).then(()=>{i.showContentHover(s,1,2,!0)})}}class aT extends o.EditorAction{constructor(){super({id:jS,label:a.localize2(1169,"Hide Hover"),alias:"Hide Content Hover",precondition:void 0})}run(e,t){oe.get(t)?.hideContentHover()}}class lT extends o.EditorAction{constructor(){super({id:qS,label:a.localize2(1170,"Scroll Up Hover"),precondition:o.EditorContextKeys.hoverFocused,kbOpts:{kbExpr:o.EditorContextKeys.hoverFocused,primary:16,weight:100},metadata:{description:a.localize2(1171,"Scroll up the editor hover.")}})}run(e,t){const i=oe.get(t);i&&i.scrollUp()}}class cT extends o.EditorAction{constructor(){super({id:GS,label:a.localize2(1172,"Scroll Down Hover"),precondition:o.EditorContextKeys.hoverFocused,kbOpts:{kbExpr:o.EditorContextKeys.hoverFocused,primary:18,weight:100},metadata:{description:a.localize2(1173,"Scroll down the editor hover.")}})}run(e,t){const i=oe.get(t);i&&i.scrollDown()}}class dT extends o.EditorAction{constructor(){super({id:ZS,label:a.localize2(1174,"Scroll Left Hover"),precondition:o.EditorContextKeys.hoverFocused,kbOpts:{kbExpr:o.EditorContextKeys.hoverFocused,primary:15,weight:100},metadata:{description:a.localize2(1175,"Scroll left the editor hover.")}})}run(e,t){const i=oe.get(t);i&&i.scrollLeft()}}class hT extends o.EditorAction{constructor(){super({id:XS,label:a.localize2(1176,"Scroll Right Hover"),precondition:o.EditorContextKeys.hoverFocused,kbOpts:{kbExpr:o.EditorContextKeys.hoverFocused,primary:17,weight:100},metadata:{description:a.localize2(1177,"Scroll right the editor hover.")}})}run(e,t){const i=oe.get(t);i&&i.scrollRight()}}class uT extends o.EditorAction{constructor(){super({id:YS,label:a.localize2(1178,"Page Up Hover"),precondition:o.EditorContextKeys.hoverFocused,kbOpts:{kbExpr:o.EditorContextKeys.hoverFocused,primary:11,secondary:[528],weight:100},metadata:{description:a.localize2(1179,"Page up the editor hover.")}})}run(e,t){const i=oe.get(t);i&&i.pageUp()}}class gT extends o.EditorAction{constructor(){super({id:QS,label:a.localize2(1180,"Page Down Hover"),precondition:o.EditorContextKeys.hoverFocused,kbOpts:{kbExpr:o.EditorContextKeys.hoverFocused,primary:12,secondary:[530],weight:100},metadata:{description:a.localize2(1181,"Page down the editor hover.")}})}run(e,t){const i=oe.get(t);i&&i.pageDown()}}class pT extends o.EditorAction{constructor(){super({id:JS,label:a.localize2(1182,"Go To Top Hover"),precondition:o.EditorContextKeys.hoverFocused,kbOpts:{kbExpr:o.EditorContextKeys.hoverFocused,primary:14,secondary:[2064],weight:100},metadata:{description:a.localize2(1183,"Go to the top of the editor hover.")}})}run(e,t){const i=oe.get(t);i&&i.goToTop()}}class fT extends o.EditorAction{constructor(){super({id:WS,label:a.localize2(1184,"Go To Bottom Hover"),precondition:o.EditorContextKeys.hoverFocused,kbOpts:{kbExpr:o.EditorContextKeys.hoverFocused,primary:13,secondary:[2066],weight:100},metadata:{description:a.localize2(1185,"Go to the bottom of the editor hover.")}})}run(e,t){const i=oe.get(t);i&&i.goToBottom()}}class mT extends o.EditorAction{constructor(){super({id:na,label:HS,alias:"Increase Hover Verbosity Level",precondition:o.EditorContextKeys.hoverVisible})}run(e,t,i){const n=oe.get(t);if(!n)return;const s=i?.index!==void 0?i.index:n.focusedHoverPartIndex();n.updateHoverVerbosityLevel(a.HoverVerbosityAction.Increase,s,i?.focus)}}class _T extends o.EditorAction{constructor(){super({id:sa,label:ey,alias:"Decrease Hover Verbosity Level",precondition:o.EditorContextKeys.hoverVisible})}run(e,t,i){const n=oe.get(t);if(!n)return;const s=i?.index!==void 0?i.index:n.focusedHoverPartIndex();oe.get(t)?.updateHoverVerbosityLevel(a.HoverVerbosityAction.Decrease,s,i?.focus)}}var vT=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Nr=function(c,e){return function(t,i){e(t,i,c)}};const Ke=o.$;class bT{constructor(e,t,i){this.owner=e,this.range=t,this.marker=i}isValidForHoverAnchor(e){return e.type===1&&this.range.startColumn<=e.range.startColumn&&this.range.endColumn>=e.range.endColumn}}const Sb={type:1,filter:{include:q.QuickFix},triggerAction:be.QuickFixHover};let ap=class{constructor(e,t,i,n,s,r){this._editor=e,this._markerDecorationsService=t,this._openerService=i,this._languageFeaturesService=n,this._menuService=s,this._contextKeyService=r,this.hoverOrdinal=1,this.recentMarkerCodeActionsInfo=void 0}computeSync(e,t){if(!this._editor.hasModel()||e.type!==1&&!e.supportsMarkerHover)return[];const i=this._editor.getModel(),n=e.range;if(!i.isValidRange(e.range))return[];const s=n.startLineNumber,r=i.getLineMaxColumn(s),l=[];for(const d of t){const h=d.range.startLineNumber===s?d.range.startColumn:1,u=d.range.endLineNumber===s?d.range.endColumn:r,g=this._markerDecorationsService.getMarker(i.uri,d);if(!g)continue;const p=new a.Range(e.range.startLineNumber,h,e.range.startLineNumber,u);l.push(new bT(this,p,g))}return l}renderHoverParts(e,t){if(!t.length)return new Zi([]);const i=[];t.forEach(r=>{const l=this._renderMarkerHover(r);e.fragment.appendChild(l.hoverElement),i.push(l)});const n=t.length===1?t[0]:t.sort((r,l)=>o.MarkerSeverity$1.compare(r.marker.severity,l.marker.severity))[0],s=this._renderMarkerStatusbar(e,n);return new Zi(i,s)}getAccessibleContent(e){const{marker:t}=e,i=a.isNonEmptyArray(t.relatedInformation)?t.relatedInformation.map(n=>`${o.basename(n.resource)}(${n.startLineNumber}, ${n.startColumn}): ${n.message}`).join(`
62
+ `):void 0;return[t.message,i].filter(n=>!!n).join(`
63
+ `)}_renderMarkerHover(e){const t=new a.DisposableStore,i=Ke("div.hover-row"),n=o.append(i,Ke("div.marker.hover-contents")),{source:s,message:r,code:l,relatedInformation:d}=e.marker;this._editor.applyFontInfo(n);const h=o.append(n,Ke("span"));if(h.style.whiteSpace="pre-wrap",h.innerText=r,s||l)if(l&&typeof l!="string"){const g=Ke("span");if(s){const _=o.append(g,Ke("span"));_.innerText=s}const p=o.append(g,Ke("a.code-link"));p.setAttribute("href",l.target.toString(!0)),t.add(o.addDisposableListener(p,"click",_=>{this._openerService.open(l.target),_.preventDefault(),_.stopPropagation()}));const f=o.append(p,Ke("span"));f.innerText=l.value;const m=o.append(n,g);m.style.opacity="0.6",m.style.paddingLeft="6px"}else{const g=o.append(n,Ke("span"));g.style.opacity="0.6",g.style.paddingLeft="6px",g.innerText=s&&l?`${s}(${l})`:s||`(${l})`}if(a.isNonEmptyArray(d))for(const{message:g,resource:p,startLineNumber:f,startColumn:m}of d){const _=o.append(n,Ke("div"));_.style.marginTop="8px";const v=o.append(_,Ke("a"));v.innerText=`${o.basename(p)}(${f}, ${m}): `,v.style.cursor="pointer",t.add(o.addDisposableListener(v,"click",C=>{if(C.stopPropagation(),C.preventDefault(),this._openerService){const y={selection:{startLineNumber:f,startColumn:m}};this._openerService.open(p,{fromUserGesture:!0,editorOptions:y}).catch(a.onUnexpectedError)}}));const b=o.append(_,Ke("span"));b.innerText=g,this._editor.applyFontInfo(b)}return{hoverPart:e,hoverElement:i,dispose:()=>t.dispose()}}_renderMarkerStatusbar(e,t){const i=new a.DisposableStore;if(t.marker.severity===o.MarkerSeverity$1.Error||t.marker.severity===o.MarkerSeverity$1.Warning||t.marker.severity===o.MarkerSeverity$1.Info){const r=ln.get(this._editor);r&&e.statusBar.addAction({label:a.localize(1195,"View Problem"),commandId:Yo.ID,run:()=>{e.hide(),r.showAtMarker(t.marker),this._editor.focus()}})}const n=[];for(const[,r]of this._menuService.getMenuActions(o.MenuId.MarkerHoverStatusBar,this._contextKeyService))for(const l of r)l instanceof o.MenuItemAction&&l.enabled&&n.push(l);const s=()=>{for(const r of n)e.statusBar.addAction({label:r.label,commandId:r.id,iconClass:r.class,run:()=>{e.hide(),this._editor.setSelection(a.Range.lift(t.range)),r.run()}})};if(this._editor.getOption(104))s();else{const r=e.statusBar.append(Ke("div"));this.recentMarkerCodeActionsInfo&&(o.IMarkerData.makeKey(this.recentMarkerCodeActionsInfo.marker)===o.IMarkerData.makeKey(t.marker)?this.recentMarkerCodeActionsInfo.hasCodeActions||n.length===0&&(r.textContent=a.localize(1196,"No quick fixes available")):this.recentMarkerCodeActionsInfo=void 0);const l=this.recentMarkerCodeActionsInfo&&!this.recentMarkerCodeActionsInfo.hasCodeActions?a.Disposable.None:a.disposableTimeout(()=>r.textContent=a.localize(1197,"Checking for quick fixes..."),200,i);r.textContent||(r.textContent=" ");const d=this.getCodeActions(t.marker);i.add(a.toDisposable(()=>d.cancel())),d.then(h=>{if(l.dispose(),this.recentMarkerCodeActionsInfo={marker:t.marker,hasCodeActions:h.validActions.length>0},!this.recentMarkerCodeActionsInfo.hasCodeActions){h.dispose(),n.length===0?r.textContent=a.localize(1198,"No quick fixes available"):r.style.display="none",s();return}r.style.display="none";let u=!1;i.add(a.toDisposable(()=>{u||h.dispose()})),e.statusBar.addAction({label:a.localize(1199,"Quick Fix..."),commandId:ia,run:p=>{u=!0;const f=qi.get(this._editor),m=o.getDomNodePagePosition(p);f?.showCodeActions(Sb,h,{x:m.left,y:m.top,width:m.width,height:m.height})}});const g=h.validActions.find(p=>p.action.isAI);g?e.statusBar.addAction({label:g.action.title,commandId:g.action.command?.id??"",iconClass:o.ThemeIcon.asClassName(a.Codicon.sparkle),run:()=>{qi.get(this._editor)?.applyCodeAction(g,!1,!1,Ut.FromProblemsHover)}}):s(),e.onContentsChanged()},a.onUnexpectedError)}return i}getCodeActions(e){return a.createCancelablePromise(t=>cs(this._languageFeaturesService.codeActionProvider,this._editor.getModel(),new a.Range(e.startLineNumber,e.startColumn,e.endLineNumber,e.endColumn),Sb,o.Progress.None,t))}};ap=vT([Nr(1,o.IMarkerDecorationsService),Nr(2,o.IOpenerService),Nr(3,o.ILanguageFeaturesService),Nr(4,o.IMenuService),Nr(5,o.IContextKeyService)],ap);class CT{constructor(e){this._editor=e}computeSync(e){const t=r=>({value:r}),i=this._editor.getLineDecorations(e.lineNumber),n=[],s=e.laneOrLine==="lineNo";if(!i)return n;for(const r of i){const l=r.options.glyphMargin?.position??a.GlyphMarginLane.Center;if(!s&&l!==e.laneOrLine)continue;const d=s?r.options.lineNumberHoverMessage:r.options.glyphMarginHoverMessage;!d||o.isEmptyMarkdownString(d)||n.push(...a.asArray(d).map(t))}return n}}var ST=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},yT=function(c,e){return function(t,i){e(t,i,c)}},lp;const yb=o.$;let cp=(Yn=class extends a.Disposable{constructor(e,t){super(),this._markdownRendererService=t,this.allowEditorOverflow=!0,this._renderDisposeables=this._register(new a.DisposableStore),this._editor=e,this._isVisible=!1,this._messages=[],this._hover=this._register(new o.HoverWidget(!0)),this._hover.containerDomNode.classList.toggle("hidden",!this._isVisible),this._hoverOperation=this._register(new wm(this._editor,new CT(this._editor))),this._register(this._hoverOperation.onResult(i=>this._withResult(i))),this._register(this._editor.onDidChangeModelDecorations(()=>this._onModelDecorationsChanged())),this._register(this._editor.onDidChangeConfiguration(i=>{i.hasChanged(59)&&this._updateFont()})),this._register(o.addStandardDisposableListener(this._hover.containerDomNode,"mouseleave",i=>{this._onMouseLeave(i)})),this._editor.addOverlayWidget(this)}dispose(){this._hoverComputerOptions=void 0,this._editor.removeOverlayWidget(this),super.dispose()}getId(){return lp.ID}getDomNode(){return this._hover.containerDomNode}getPosition(){return null}_updateFont(){Array.prototype.slice.call(this._hover.contentsDomNode.getElementsByClassName("code")).forEach(t=>this._editor.applyFontInfo(t))}_onModelDecorationsChanged(){this._isVisible&&this._hoverComputerOptions&&(this._hoverOperation.cancel(),this._hoverOperation.start(0,this._hoverComputerOptions))}showsOrWillShow(e){const t=e.target;return t.type===2&&t.detail.glyphMarginLane?(this._startShowingAt(t.position.lineNumber,t.detail.glyphMarginLane),!0):t.type===3?(this._startShowingAt(t.position.lineNumber,"lineNo"),!0):!1}_startShowingAt(e,t){this._hoverComputerOptions&&this._hoverComputerOptions.lineNumber===e&&this._hoverComputerOptions.laneOrLine===t||(this._hoverOperation.cancel(),this.hide(),this._hoverComputerOptions={lineNumber:e,laneOrLine:t},this._hoverOperation.start(0,this._hoverComputerOptions))}hide(){this._hoverComputerOptions=void 0,this._hoverOperation.cancel(),this._isVisible&&(this._isVisible=!1,this._hover.containerDomNode.classList.toggle("hidden",!this._isVisible))}_withResult(e){this._messages=e.value,this._messages.length>0?this._renderMessages(e.options.lineNumber,e.options.laneOrLine,this._messages):this.hide()}_renderMessages(e,t,i){this._renderDisposeables.clear();const n=document.createDocumentFragment();for(const s of i){const r=yb("div.hover-row.markdown-hover"),l=o.append(r,yb("div.hover-contents")),d=this._renderDisposeables.add(this._markdownRendererService.render(s.value,{context:this._editor}));l.appendChild(d.element),n.appendChild(r)}this._updateContents(n),this._showAt(e,t)}_updateContents(e){this._hover.contentsDomNode.textContent="",this._hover.contentsDomNode.appendChild(e),this._updateFont()}_showAt(e,t){this._isVisible||(this._isVisible=!0,this._hover.containerDomNode.classList.toggle("hidden",!this._isVisible));const i=this._editor.getLayoutInfo(),n=this._editor.getTopForLineNumber(e),s=this._editor.getScrollTop(),r=this._editor.getOption(75),l=this._hover.containerDomNode.clientHeight,d=n-s-(l-r)/2,h=i.glyphMarginLeft+i.glyphMarginWidth+(t==="lineNo"?i.lineNumbersWidth:0),g=i.height-l,p=Math.max(0,Math.min(Math.round(d),g));if(this._editor.getOption(51)){const m=this._editor.getDomNode();if(m){const _=o.getDomNodePagePosition(m);this._hover.containerDomNode.style.position="fixed",this._hover.containerDomNode.style.left=`${_.left+h}px`,this._hover.containerDomNode.style.top=`${_.top+p}px`}}else this._hover.containerDomNode.style.position="absolute",this._hover.containerDomNode.style.left=`${h}px`,this._hover.containerDomNode.style.top=`${p}px`;this._hover.containerDomNode.style.zIndex="11"}_onMouseLeave(e){const t=this._editor.getDomNode();(!t||!aa(t,e.x,e.y))&&this.hide()}},lp=Yn,Yn.ID="editor.contrib.modesGlyphHoverWidget",Yn);cp=lp=ST([yT(1,o.IMarkdownRendererService)],cp);var wT=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},IT=function(c,e){return function(t,i){e(t,i,c)}};let Gl=(ao=class extends a.Disposable{constructor(e,t){super(),this._editor=e,this._instantiationService=t,this.shouldKeepOpenOnEditorMouseMoveOrLeave=!1,this._listenersStore=new a.DisposableStore,this._hoverState={mouseDown:!1},this._reactToEditorMouseMoveRunner=this._register(new a.RunOnceScheduler(()=>this._reactToEditorMouseMove(this._mouseMoveEvent),0)),this._hookListeners(),this._register(this._editor.onDidChangeConfiguration(i=>{i.hasChanged(69)&&(this._unhookListeners(),this._hookListeners())}))}_hookListeners(){const e=this._editor.getOption(69);this._hoverSettings={enabled:e.enabled,sticky:e.sticky,hidingDelay:e.hidingDelay},e.enabled!=="off"?(this._listenersStore.add(this._editor.onMouseDown(t=>this._onEditorMouseDown(t))),this._listenersStore.add(this._editor.onMouseUp(()=>this._onEditorMouseUp())),this._listenersStore.add(this._editor.onMouseMove(t=>this._onEditorMouseMove(t))),this._listenersStore.add(this._editor.onKeyDown(t=>this._onKeyDown(t)))):(this._listenersStore.add(this._editor.onMouseMove(t=>this._onEditorMouseMove(t))),this._listenersStore.add(this._editor.onKeyDown(t=>this._onKeyDown(t)))),this._listenersStore.add(this._editor.onMouseLeave(t=>this._onEditorMouseLeave(t))),this._listenersStore.add(this._editor.onDidChangeModel(()=>{this._cancelScheduler(),this.hideGlyphHover()})),this._listenersStore.add(this._editor.onDidChangeModelContent(()=>this._cancelScheduler())),this._listenersStore.add(this._editor.onDidScrollChange(t=>this._onEditorScrollChanged(t)))}_unhookListeners(){this._listenersStore.clear()}_cancelScheduler(){this._mouseMoveEvent=void 0,this._reactToEditorMouseMoveRunner.cancel()}_onEditorScrollChanged(e){(e.scrollTopChanged||e.scrollLeftChanged)&&this.hideGlyphHover()}_onEditorMouseDown(e){this._hoverState.mouseDown=!0,!this._isMouseOnGlyphHoverWidget(e)&&this.hideGlyphHover()}_isMouseOnGlyphHoverWidget(e){const t=this._glyphWidget?.getDomNode();return t?aa(t,e.event.posx,e.event.posy):!1}_onEditorMouseUp(){this._hoverState.mouseDown=!1}_onEditorMouseLeave(e){this.shouldKeepOpenOnEditorMouseMoveOrLeave||(this._cancelScheduler(),this._isMouseOnGlyphHoverWidget(e))||this.hideGlyphHover()}_shouldNotRecomputeCurrentHoverWidget(e){const t=this._hoverSettings.sticky,i=this._isMouseOnGlyphHoverWidget(e);return t&&i}_onEditorMouseMove(e){if(this.shouldKeepOpenOnEditorMouseMoveOrLeave)return;if(this._mouseMoveEvent=e,this._shouldNotRecomputeCurrentHoverWidget(e)){this._reactToEditorMouseMoveRunner.cancel();return}this._reactToEditorMouseMove(e)}_reactToEditorMouseMove(e){if(!e)return;if(!ym(this._hoverSettings.enabled,this._editor.getOption(86),e)){this.hideGlyphHover();return}this._tryShowHoverWidget(e)||this.hideGlyphHover()}_tryShowHoverWidget(e){return this._getOrCreateGlyphWidget().showsOrWillShow(e)}_onKeyDown(e){if(this._editor.hasModel()){if(this._hoverSettings.enabled==="onKeyboardModifier"&&ah(this._editor.getOption(86),e)&&this._mouseMoveEvent){this._tryShowHoverWidget(this._mouseMoveEvent);return}a.isModifierKey(e.keyCode)||this.hideGlyphHover()}}hideGlyphHover(){this._glyphWidget?.hide()}_getOrCreateGlyphWidget(){return this._glyphWidget||(this._glyphWidget=this._instantiationService.createInstance(cp,this._editor)),this._glyphWidget}dispose(){super.dispose(),this._unhookListeners(),this._listenersStore.dispose(),this._glyphWidget?.dispose()}},ao.ID="editor.contrib.marginHover",ao);Gl=wT([IT(1,o.IInstantiationService)],Gl);class xT{}class ET{}class LT{}o.registerEditorContribution(oe.ID,oe,2),o.registerEditorContribution(Gl.ID,Gl,2),o.registerEditorAction(oT),o.registerEditorAction(rT),o.registerEditorAction(aT),o.registerEditorAction(lT),o.registerEditorAction(cT),o.registerEditorAction(dT),o.registerEditorAction(hT),o.registerEditorAction(uT),o.registerEditorAction(gT),o.registerEditorAction(pT),o.registerEditorAction(fT),o.registerEditorAction(mT),o.registerEditorAction(_T),Xi.register(To),Xi.register(ap),o.CommandsRegistry.registerCommand(th,c=>{c.get(o.IConfigurationService).updateValue("editor.hover.showLongLineWarning",!1)}),o.registerThemingParticipant((c,e)=>{const t=c.getColor(o.editorHoverBorder);t&&(e.addRule(`.monaco-editor .monaco-hover .hover-row:not(:first-child):not(:empty) { border-top: 1px solid ${t.transparent(.5)}; }`),e.addRule(`.monaco-editor .monaco-hover hr { border-top: 1px solid ${t.transparent(.5)}; }`),e.addRule(`.monaco-editor .monaco-hover hr { border-bottom: 0px solid ${t.transparent(.5)}; }`))}),Ga.register(new xT),Ga.register(new ET),Ga.register(new LT);function wb(c,e,t,i){if(c.getLineCount()===1&&c.getLineMaxColumn(1)===1)return[];const n=e.getLanguageConfiguration(c.getLanguageId()).indentRulesSupport;if(!n)return[];const s=new o.ProcessedIndentRulesSupport(c,n,e);for(i=Math.min(i,c.getLineCount());t<=i&&s.shouldIgnore(t);)t++;if(t>i-1)return[];const{tabSize:r,indentSize:l,insertSpaces:d}=c.getOptions(),h=(_,v)=>(v=v||1,o.ShiftCommand.shiftIndent(_,_.length+v,r,l,d)),u=(_,v)=>(v=v||1,o.ShiftCommand.unshiftIndent(_,_.length+v,r,l,d)),g=[],p=c.getLineContent(t);let f=a.getLeadingWhitespace(p),m=f;s.shouldIncrease(t)?(m=h(m),f=h(f)):s.shouldIndentNextLine(t)&&(m=h(m)),t++;for(let _=t;_<=i;_++){if(DT(c,_))continue;const v=c.getLineContent(_),b=a.getLeadingWhitespace(v),C=m;s.shouldDecrease(_,C)&&(m=u(m),f=u(f)),b!==m&&g.push(o.EditOperation.replaceMove(new a.Selection(_,1,_,b.length+1),o.normalizeIndentation(m,l,d))),!s.shouldIgnore(_)&&(s.shouldIncrease(_,C)?(f=h(f),m=f):s.shouldIndentNextLine(_,C)?m=h(m):m=f)}return g}function DT(c,e){return c.tokenization.isCheapToTokenize(e)?c.tokenization.getLineTokens(e).getStandardTokenType(0)===2:!1}var RT=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},TT=function(c,e){return function(t,i){e(t,i,c)}};const Yc=class Yc extends o.EditorAction{constructor(){super({id:Yc.ID,label:a.localize2(1204,"Convert Indentation to Spaces"),precondition:o.EditorContextKeys.writable,metadata:{description:a.localize2(1205,"Convert the tab indentation to spaces.")}})}run(e,t){const i=t.getModel();if(!i)return;const n=i.getOptions(),s=t.getSelection();if(!s)return;const r=new AT(s,n.tabSize);t.pushUndoStop(),t.executeCommands(this.id,[r]),t.pushUndoStop(),i.updateOptions({insertSpaces:!0})}};Yc.ID="editor.action.indentationToSpaces";let dp=Yc;const Qc=class Qc extends o.EditorAction{constructor(){super({id:Qc.ID,label:a.localize2(1206,"Convert Indentation to Tabs"),precondition:o.EditorContextKeys.writable,metadata:{description:a.localize2(1207,"Convert the spaces indentation to tabs.")}})}run(e,t){const i=t.getModel();if(!i)return;const n=i.getOptions(),s=t.getSelection();if(!s)return;const r=new FT(s,n.tabSize);t.pushUndoStop(),t.executeCommands(this.id,[r]),t.pushUndoStop(),i.updateOptions({insertSpaces:!1})}};Qc.ID="editor.action.indentationToTabs";let hp=Qc;class up extends o.EditorAction{constructor(e,t,i){super(i),this.insertSpaces=e,this.displaySizeOnly=t}run(e,t){const i=e.get(o.IQuickInputService),n=e.get(o.IModelService),s=t.getModel();if(!s)return;const r=n.getCreationOptions(s.getLanguageId(),s.uri,s.isForSimpleWidget),l=s.getOptions(),d=[1,2,3,4,5,6,7,8].map(u=>({id:u.toString(),label:u.toString(),description:u===r.tabSize&&u===l.tabSize?a.localize(1200,"Configured Tab Size"):u===r.tabSize?a.localize(1201,"Default Tab Size"):u===l.tabSize?a.localize(1202,"Current Tab Size"):void 0})),h=Math.min(s.getOptions().tabSize-1,7);setTimeout(()=>{i.pick(d,{placeHolder:a.localize(1203,"Select Tab Size for Current File"),activeItem:d[h]}).then(u=>{if(u&&s&&!s.isDisposed()){const g=parseInt(u.label,10);this.displaySizeOnly?s.updateOptions({tabSize:g}):s.updateOptions({tabSize:g,indentSize:g,insertSpaces:this.insertSpaces})}})},50)}}const Jc=class Jc extends up{constructor(){super(!1,!1,{id:Jc.ID,label:a.localize2(1208,"Indent Using Tabs"),precondition:void 0,metadata:{description:a.localize2(1209,"Use indentation with tabs.")}})}};Jc.ID="editor.action.indentUsingTabs";let gp=Jc;const Wc=class Wc extends up{constructor(){super(!0,!1,{id:Wc.ID,label:a.localize2(1210,"Indent Using Spaces"),precondition:void 0,metadata:{description:a.localize2(1211,"Use indentation with spaces.")}})}};Wc.ID="editor.action.indentUsingSpaces";let pp=Wc;const Hc=class Hc extends up{constructor(){super(!0,!0,{id:Hc.ID,label:a.localize2(1212,"Change Tab Display Size"),precondition:void 0,metadata:{description:a.localize2(1213,"Change the space size equivalent of the tab.")}})}};Hc.ID="editor.action.changeTabDisplaySize";let fp=Hc;const ed=class ed extends o.EditorAction{constructor(){super({id:ed.ID,label:a.localize2(1214,"Detect Indentation from Content"),precondition:void 0,metadata:{description:a.localize2(1215,"Detect the indentation from content.")}})}run(e,t){const i=e.get(o.IModelService),n=t.getModel();if(!n)return;const s=i.getCreationOptions(n.getLanguageId(),n.uri,n.isForSimpleWidget);n.detectIndentation(s.insertSpaces,s.tabSize)}};ed.ID="editor.action.detectIndentation";let mp=ed;class NT extends o.EditorAction{constructor(){super({id:"editor.action.reindentlines",label:a.localize2(1216,"Reindent Lines"),precondition:o.EditorContextKeys.writable,metadata:{description:a.localize2(1217,"Reindent the lines of the editor.")},canTriggerInlineEdits:!0})}run(e,t){const i=e.get(o.ILanguageConfigurationService),n=t.getModel();if(!n)return;const s=wb(n,i,1,n.getLineCount());s.length>0&&(t.pushUndoStop(),t.executeEdits(this.id,s),t.pushUndoStop())}}class MT extends o.EditorAction{constructor(){super({id:"editor.action.reindentselectedlines",label:a.localize2(1218,"Reindent Selected Lines"),precondition:o.EditorContextKeys.writable,metadata:{description:a.localize2(1219,"Reindent the selected lines of the editor.")},canTriggerInlineEdits:!0})}run(e,t){const i=e.get(o.ILanguageConfigurationService),n=t.getModel();if(!n)return;const s=t.getSelections();if(s===null)return;const r=[];for(const l of s){let d=l.startLineNumber,h=l.endLineNumber;if(d!==h&&l.endColumn===1&&h--,d===1){if(d===h)continue}else d--;const u=wb(n,i,d,h);r.push(...u)}r.length>0&&(t.pushUndoStop(),t.executeEdits(this.id,r),t.pushUndoStop())}}class PT{constructor(e,t){this._initialSelection=t,this._edits=[],this._selectionId=null;for(const i of e)i.range&&typeof i.text=="string"&&this._edits.push(i)}getEditOperations(e,t){for(const n of this._edits)t.addEditOperation(a.Range.lift(n.range),n.text);let i=!1;Array.isArray(this._edits)&&this._edits.length===1&&this._initialSelection.isEmpty()&&(this._edits[0].range.startColumn===this._initialSelection.endColumn&&this._edits[0].range.startLineNumber===this._initialSelection.endLineNumber?(i=!0,this._selectionId=t.trackSelection(this._initialSelection,!0)):this._edits[0].range.endColumn===this._initialSelection.startColumn&&this._edits[0].range.endLineNumber===this._initialSelection.startLineNumber&&(i=!0,this._selectionId=t.trackSelection(this._initialSelection,!1))),i||(this._selectionId=t.trackSelection(this._initialSelection))}computeCursorState(e,t){return t.getTrackedSelection(this._selectionId)}}let Zl=(lo=class{constructor(e,t){this.editor=e,this._languageConfigurationService=t,this.callOnDispose=new a.DisposableStore,this.callOnModel=new a.DisposableStore,this.callOnDispose.add(e.onDidChangeConfiguration(()=>this.update())),this.callOnDispose.add(e.onDidChangeModel(()=>this.update())),this.callOnDispose.add(e.onDidChangeModelLanguage(()=>this.update()))}update(){this.callOnModel.clear(),!(!this.editor.getOption(17)||this.editor.getOption(16)<4)&&this.editor.hasModel()&&this.callOnModel.add(this.editor.onDidPaste(({range:e})=>{this.trigger(e)}))}trigger(e){const t=this.editor.getSelections();if(t===null||t.length>1)return;const i=this.editor.getModel();if(!i||this.rangeContainsOnlyWhitespaceCharacters(i,e)||!this.editor.getOption(18)&&OT(i,e)||!i.tokenization.isCheapToTokenize(e.getStartPosition().lineNumber))return;const s=this.editor.getOption(16),{tabSize:r,indentSize:l,insertSpaces:d}=i.getOptions(),h=[],u={shiftIndent:m=>o.ShiftCommand.shiftIndent(m,m.length+1,r,l,d),unshiftIndent:m=>o.ShiftCommand.unshiftIndent(m,m.length+1,r,l,d)};let g=e.startLineNumber,p=i.getLineContent(g);if(!/\S/.test(p.substring(0,e.startColumn-1))){const m=o.getGoodIndentForLine(s,i,i.getLanguageId(),g,u,this._languageConfigurationService);if(m!==null){const _=a.getLeadingWhitespace(p),v=Se(m,r),b=Se(_,r);if(v!==b){const C=Qo(v,r,d);h.push({range:new a.Range(g,1,g,_.length+1),text:C}),p=C+p.substring(_.length)}else{const C=o.getIndentMetadata(i,g,this._languageConfigurationService);if(C===0||C===8)return}}}const f=g;for(;g<e.endLineNumber;){if(!/\S/.test(i.getLineContent(g+1))){g++;continue}break}if(g!==e.endLineNumber){const m={tokenization:{getLineTokens:v=>i.tokenization.getLineTokens(v),getLanguageId:()=>i.getLanguageId(),getLanguageIdAtPosition:(v,b)=>i.getLanguageIdAtPosition(v,b)},getLineContent:v=>v===f?p:i.getLineContent(v)},_=o.getGoodIndentForLine(s,m,i.getLanguageId(),g+1,u,this._languageConfigurationService);if(_!==null){const v=Se(_,r),b=Se(a.getLeadingWhitespace(i.getLineContent(g+1)),r);if(v!==b){const C=v-b;for(let y=g+1;y<=e.endLineNumber;y++){const I=i.getLineContent(y),x=a.getLeadingWhitespace(I),w=Se(x,r)+C,E=Qo(w,r,d);E!==x&&h.push({range:new a.Range(y,1,y,x.length+1),text:E})}}}}if(h.length>0){this.editor.pushUndoStop();const m=new PT(h,this.editor.getSelection());this.editor.executeCommand("autoIndentOnPaste",m),this.editor.pushUndoStop()}}rangeContainsOnlyWhitespaceCharacters(e,t){const i=s=>s.trim().length===0;let n=!0;if(t.startLineNumber===t.endLineNumber){const r=e.getLineContent(t.startLineNumber).substring(t.startColumn-1,t.endColumn-1);n=i(r)}else for(let s=t.startLineNumber;s<=t.endLineNumber;s++){const r=e.getLineContent(s);if(s===t.startLineNumber){const l=r.substring(t.startColumn-1);n=i(l)}else if(s===t.endLineNumber){const l=r.substring(0,t.endColumn-1);n=i(l)}else n=e.getLineFirstNonWhitespaceColumn(s)===0;if(!n)break}return n}dispose(){this.callOnDispose.dispose(),this.callOnModel.dispose()}},lo.ID="editor.contrib.autoIndentOnPaste",lo);Zl=RT([TT(1,o.ILanguageConfigurationService)],Zl);function OT(c,e){const t=i=>o.getStandardTokenTypeAtPosition(c,i)===2;return t(e.getStartPosition())||t(e.getEndPosition())}function Ib(c,e,t,i){if(c.getLineCount()===1&&c.getLineMaxColumn(1)===1)return;let n="";for(let r=0;r<t;r++)n+=" ";const s=new RegExp(n,"gi");for(let r=1,l=c.getLineCount();r<=l;r++){let d=c.getLineFirstNonWhitespaceColumn(r);if(d===0&&(d=c.getLineMaxColumn(r)),d===1)continue;const h=new a.Range(r,1,r,d),u=c.getValueInRange(h),g=i?u.replace(/\t/ig,n):u.replace(s," ");e.addEditOperation(h,g)}}class AT{constructor(e,t){this.selection=e,this.tabSize=t,this.selectionId=null}getEditOperations(e,t){this.selectionId=t.trackSelection(this.selection),Ib(e,t,this.tabSize,!0)}computeCursorState(e,t){return t.getTrackedSelection(this.selectionId)}}class FT{constructor(e,t){this.selection=e,this.tabSize=t,this.selectionId=null}getEditOperations(e,t){this.selectionId=t.trackSelection(this.selection),Ib(e,t,this.tabSize,!1)}computeCursorState(e,t){return t.getTrackedSelection(this.selectionId)}}o.registerEditorContribution(Zl.ID,Zl,2),o.registerEditorAction(dp),o.registerEditorAction(hp),o.registerEditorAction(gp),o.registerEditorAction(pp),o.registerEditorAction(fp),o.registerEditorAction(mp),o.registerEditorAction(NT),o.registerEditorAction(MT),o.registerEditorContribution(Bo.ID,Bo,1),Xi.register(Oa);class zT{constructor(e,t,i){this._editRange=e,this._originalSelection=t,this._text=i}getEditOperations(e,t){t.addTrackedEditOperation(this._editRange,this._text)}computeCursorState(e,t){const n=t.getInverseEditOperations()[0].range;return this._originalSelection.isEmpty()?new a.Selection(n.endLineNumber,Math.min(this._originalSelection.positionColumn,n.endColumn),n.endLineNumber,Math.min(this._originalSelection.positionColumn,n.endColumn)):new a.Selection(n.endLineNumber,n.endColumn-this._text.length,n.endLineNumber,n.endColumn)}}var VT=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},BT=function(c,e){return function(t,i){e(t,i,c)}},Xl;let $s=(Ni=class{static get(e){return e.getContribution(Xl.ID)}constructor(e,t){this.editor=e,this.editorWorkerService=t,this.decorations=this.editor.createDecorationsCollection()}dispose(){}run(e,t){this.currentRequest?.cancel();const i=this.editor.getSelection(),n=this.editor.getModel();if(!n||!i)return;let s=i;if(s.startLineNumber!==s.endLineNumber)return;const r=new o.EditorState(this.editor,5),l=n.uri;return this.editorWorkerService.canNavigateValueSet(l)?(this.currentRequest=a.createCancelablePromise(d=>this.editorWorkerService.navigateValueSet(l,s,t)),this.currentRequest.then(d=>{if(!d||!d.range||!d.value||!r.validate(this.editor))return;const h=a.Range.lift(d.range);let u=d.range;const g=d.value.length-(s.endColumn-s.startColumn);u={startLineNumber:u.startLineNumber,startColumn:u.startColumn,endLineNumber:u.endLineNumber,endColumn:u.startColumn+d.value.length},g>1&&(s=new a.Selection(s.startLineNumber,s.startColumn,s.endLineNumber,s.endColumn+g-1));const p=new zT(h,s,d.value);this.editor.pushUndoStop(),this.editor.executeCommand(e,p),this.editor.pushUndoStop(),this.decorations.set([{range:u,options:Xl.DECORATION}]),this.decorationRemover?.cancel(),this.decorationRemover=a.timeout(350),this.decorationRemover.then(()=>this.decorations.clear()).catch(a.onUnexpectedError)}).catch(a.onUnexpectedError)):Promise.resolve(void 0)}},Xl=Ni,Ni.ID="editor.contrib.inPlaceReplaceController",Ni.DECORATION=o.ModelDecorationOptions.register({description:"in-place-replace",className:"valueSetReplacement"}),Ni);$s=Xl=VT([BT(1,o.IEditorWorkerService)],$s);class KT extends o.EditorAction{constructor(){super({id:"editor.action.inPlaceReplace.up",label:a.localize2(1306,"Replace with Previous Value"),precondition:o.EditorContextKeys.writable,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:3159,weight:100}})}run(e,t){const i=$s.get(t);return i?i.run(this.id,!1):Promise.resolve(void 0)}}class kT extends o.EditorAction{constructor(){super({id:"editor.action.inPlaceReplace.down",label:a.localize2(1307,"Replace with Next Value"),precondition:o.EditorContextKeys.writable,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:3161,weight:100}})}run(e,t){const i=$s.get(t);return i?i.run(this.id,!0):Promise.resolve(void 0)}}o.registerEditorContribution($s.ID,$s,4),o.registerEditorAction(KT),o.registerEditorAction(kT);class UT{constructor(e){this._selection=e,this._selectionId=null}getEditOperations(e,t){const i=$T(e);i&&t.addEditOperation(i.range,i.text),this._selectionId=t.trackSelection(this._selection)}computeCursorState(e,t){return t.getTrackedSelection(this._selectionId)}}function $T(c){const e=c.getLineCount();return o.EditOperation.insert(new a.Position(e,c.getLineMaxColumn(e)),c.getEOL())}const td=class td extends o.EditorAction{constructor(){super({id:td.ID,label:a.localize2(1308,"Insert Final New Line"),precondition:o.EditorContextKeys.writable})}run(e,t,i){const n=t.getSelection();if(n===null)return;const s=new UT(n);t.pushUndoStop(),t.executeCommands(this.id,[s]),t.pushUndoStop()}};td.ID="editor.action.insertFinalNewLine";let _p=td;o.registerEditorAction(_p);class jT extends o.EditorAction{constructor(){super({id:"expandLineSelection",label:a.localize2(1309,"Expand Line Selection"),precondition:void 0,kbOpts:{weight:0,kbExpr:o.EditorContextKeys.textInputFocus,primary:2090}})}run(e,t,i){if(i=i||{},!t.hasModel())return;const n=t._getViewModel();n.model.pushStackElement(),n.setCursorStates(i.source,3,o.CursorMoveCommands.expandLineSelection(n,n.getCursorStates())),n.revealAllCursors(i.source,!0)}}o.registerEditorAction(jT);var qT=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Yl=function(c,e){return function(t,i){e(t,i,c)}},Ql;const xb=new o.RawContextKey("LinkedEditingInputVisible",!1),GT="linked-editing-decoration";let js=(Mi=class extends a.Disposable{static get(e){return e.getContribution(Ql.ID)}constructor(e,t,i,n,s){super(),this.languageConfigurationService=n,this._syncRangesToken=0,this._localToDispose=this._register(new a.DisposableStore),this._editor=e,this._providers=i.linkedEditingRangeProvider,this._enabled=!1,this._visibleContextKey=xb.bindTo(t),this._debounceInformation=s.for(this._providers,"Linked Editing",{max:200}),this._currentDecorations=this._editor.createDecorationsCollection(),this._languageWordPattern=null,this._currentWordPattern=null,this._ignoreChangeEvent=!1,this._localToDispose=this._register(new a.DisposableStore),this._rangeUpdateTriggerPromise=null,this._rangeSyncTriggerPromise=null,this._currentRequestCts=null,this._currentRequestPosition=null,this._currentRequestModelVersion=null,this._register(this._editor.onDidChangeModel(()=>this.reinitialize(!0))),this._register(this._editor.onDidChangeConfiguration(r=>{(r.hasChanged(78)||r.hasChanged(106))&&this.reinitialize(!1)})),this._register(this._providers.onDidChange(()=>this.reinitialize(!1))),this._register(this._editor.onDidChangeModelLanguage(()=>this.reinitialize(!0))),this.reinitialize(!0)}reinitialize(e){const t=this._editor.getModel(),i=t!==null&&(this._editor.getOption(78)||this._editor.getOption(106))&&this._providers.has(t);if(i===this._enabled&&!e||(this._enabled=i,this.clearRanges(),this._localToDispose.clear(),!i||t===null))return;this._localToDispose.add(a.Event.runAndSubscribe(t.onDidChangeLanguageConfiguration,()=>{this._languageWordPattern=this.languageConfigurationService.getLanguageConfiguration(t.getLanguageId()).getWordDefinition()}));const n=new a.Delayer(this._debounceInformation.get(t)),s=()=>{this._rangeUpdateTriggerPromise=n.trigger(()=>this.updateRanges(),this._debounceDuration??this._debounceInformation.get(t))},r=new a.Delayer(0),l=d=>{this._rangeSyncTriggerPromise=r.trigger(()=>this._syncRanges(d))};this._localToDispose.add(this._editor.onDidChangeCursorPosition(()=>{s()})),this._localToDispose.add(this._editor.onDidChangeModelContent(d=>{if(!this._ignoreChangeEvent&&this._currentDecorations.length>0){const h=this._currentDecorations.getRange(0);if(h&&d.changes.every(u=>h.intersectRanges(u.range))){l(this._syncRangesToken);return}}s()})),this._localToDispose.add({dispose:()=>{n.dispose(),r.dispose()}}),this.updateRanges()}_syncRanges(e){if(!this._editor.hasModel()||e!==this._syncRangesToken||this._currentDecorations.length===0)return;const t=this._editor.getModel(),i=this._currentDecorations.getRange(0);if(!i||i.startLineNumber!==i.endLineNumber)return this.clearRanges();const n=t.getValueInRange(i);if(this._currentWordPattern){const r=n.match(this._currentWordPattern);if((r?r[0].length:0)!==n.length)return this.clearRanges()}const s=[];for(let r=1,l=this._currentDecorations.length;r<l;r++){const d=this._currentDecorations.getRange(r);if(d)if(d.startLineNumber!==d.endLineNumber)s.push({range:d,text:n});else{let h=t.getValueInRange(d),u=n,g=d.startColumn,p=d.endColumn;const f=a.commonPrefixLength(h,u);g+=f,h=h.substr(f),u=u.substr(f);const m=a.commonSuffixLength(h,u);p-=m,h=h.substr(0,h.length-m),u=u.substr(0,u.length-m),(g!==p||u.length!==0)&&s.push({range:new a.Range(d.startLineNumber,g,d.endLineNumber,p),text:u})}}if(s.length!==0)try{this._editor.popUndoStop(),this._ignoreChangeEvent=!0;const r=this._editor._getViewModel().getPrevEditOperationType();this._editor.executeEdits("linkedEditing",s),this._editor._getViewModel().setPrevEditOperationType(r)}finally{this._ignoreChangeEvent=!1}}dispose(){this.clearRanges(),super.dispose()}clearRanges(){this._visibleContextKey.set(!1),this._currentDecorations.clear(),this._currentRequestCts&&(this._currentRequestCts.cancel(),this._currentRequestCts=null,this._currentRequestPosition=null)}async updateRanges(e=!1){if(!this._editor.hasModel()){this.clearRanges();return}const t=this._editor.getPosition();if(!this._enabled&&!e||this._editor.getSelections().length>1){this.clearRanges();return}const i=this._editor.getModel(),n=i.getVersionId();if(this._currentRequestPosition&&this._currentRequestModelVersion===n){if(t.equals(this._currentRequestPosition))return;if(this._currentDecorations.length>0){const r=this._currentDecorations.getRange(0);if(r&&r.containsPosition(t))return}}this._currentRequestPosition?.equals(t)||this._currentDecorations.getRange(0)?.containsPosition(t)||this.clearRanges(),this._currentRequestPosition=t,this._currentRequestModelVersion=n;const s=this._currentRequestCts=new a.CancellationTokenSource;try{const r=new a.StopWatch(!1),l=await Eb(this._providers,i,t,s.token);if(this._debounceInformation.update(i,r.elapsed()),s!==this._currentRequestCts||(this._currentRequestCts=null,n!==i.getVersionId()))return;let d=[];l?.ranges&&(d=l.ranges),this._currentWordPattern=l?.wordPattern||this._languageWordPattern;let h=!1;for(let g=0,p=d.length;g<p;g++)if(a.Range.containsPosition(d[g],t)){if(h=!0,g!==0){const f=d[g];d.splice(g,1),d.unshift(f)}break}if(!h){this.clearRanges();return}const u=d.map(g=>({range:g,options:Ql.DECORATION}));this._visibleContextKey.set(!0),this._currentDecorations.set(u),this._syncRangesToken++}catch(r){a.isCancellationError(r)||a.onUnexpectedError(r),(this._currentRequestCts===s||!this._currentRequestCts)&&this.clearRanges()}}},Ql=Mi,Mi.ID="editor.contrib.linkedEditing",Mi.DECORATION=o.ModelDecorationOptions.register({description:"linked-editing",stickiness:0,className:GT}),Mi);js=Ql=qT([Yl(1,o.IContextKeyService),Yl(2,o.ILanguageFeaturesService),Yl(3,o.ILanguageConfigurationService),Yl(4,o.ILanguageFeatureDebounceService)],js);class ZT extends o.EditorAction{constructor(){super({id:"editor.action.linkedEditing",label:a.localize2(1342,"Start Linked Editing"),precondition:o.ContextKeyExpr.and(o.EditorContextKeys.writable,o.EditorContextKeys.hasRenameProvider),kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:3132,weight:100}})}runCommand(e,t){const i=e.get(o.ICodeEditorService),[n,s]=Array.isArray(t)&&t||[void 0,void 0];return a.URI.isUri(n)&&a.Position.isIPosition(s)?i.openCodeEditor({resource:n},i.getActiveCodeEditor()).then(r=>{r&&(r.setPosition(s),r.invokeWithinContext(l=>(this.reportTelemetry(l,r),this.run(l,r))))},a.onUnexpectedError):super.runCommand(e,t)}run(e,t){const i=js.get(t);return i?Promise.resolve(i.updateRanges(!0)):Promise.resolve()}}const XT=o.EditorCommand.bindToContribution(js.get);o.registerEditorCommand(new XT({id:"cancelLinkedEditingInput",precondition:xb,handler:c=>c.clearRanges(),kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,weight:199,primary:9,secondary:[1033]}}));function Eb(c,e,t,i){const n=c.ordered(e);return a.first(n.map(s=>async()=>{try{return await s.provideLinkedEditingRanges(e,t,i)}catch(r){a.onUnexpectedExternalError(r);return}}),s=>!!s&&a.isNonEmptyArray(s?.ranges))}o.registerColor("editor.linkedEditingBackground",{dark:a.Color.fromHex("#f00").transparent(.3),light:a.Color.fromHex("#f00").transparent(.3),hcDark:a.Color.fromHex("#f00").transparent(.3),hcLight:a.Color.white},a.localize(1341,"Background color when the editor auto renames on type.")),o.registerModelAndPositionCommand("_executeLinkedEditingProvider",(c,e,t)=>{const{linkedEditingRangeProvider:i}=c.get(o.ILanguageFeaturesService);return Eb(i,e,t,a.CancellationToken.None)}),o.registerEditorContribution(js.ID,js,1),o.registerEditorAction(ZT);class YT{constructor(e,t){this._link=e,this._provider=t}toJSON(){return{range:this.range,url:this.url,tooltip:this.tooltip}}get range(){return this._link.range}get url(){return this._link.url}get tooltip(){return this._link.tooltip}async resolve(e){return this._link.url?this._link.url:typeof this._provider.resolveLink=="function"?Promise.resolve(this._provider.resolveLink(this._link,e)).then(t=>(this._link=t||this._link,this._link.url?this.resolve(e):Promise.reject(new Error("missing")))):Promise.reject(new Error("missing"))}}const Zr=class Zr{constructor(e){this._disposables=new a.DisposableStore;let t=[];for(const[i,n]of e){const s=i.links.map(r=>new YT(r,n));t=Zr._union(t,s),a.isDisposable(i)&&(this._disposables??=new a.DisposableStore,this._disposables.add(i))}this.links=t}dispose(){this._disposables?.dispose(),this.links.length=0}static _union(e,t){const i=[];let n,s,r,l;for(n=0,r=0,s=e.length,l=t.length;n<s&&r<l;){const d=e[n],h=t[r];if(a.Range.areIntersectingOrTouching(d.range,h.range)){n++;continue}a.Range.compareRangesUsingStarts(d.range,h.range)<0?(i.push(d),n++):(i.push(h),r++)}for(;n<s;n++)i.push(e[n]);for(;r<l;r++)i.push(t[r]);return i}};Zr.Empty=new Zr([]);let Jl=Zr;async function Lb(c,e,t){const i=[],n=c.ordered(e).reverse().map(async(r,l)=>{try{const d=await r.provideLinks(e,t);d&&(i[l]=[d,r])}catch(d){a.onUnexpectedExternalError(d)}});await Promise.all(n);let s=new Jl(a.coalesce(i));return t.isCancellationRequested&&(s.dispose(),s=Jl.Empty),s}o.CommandsRegistry.registerCommand("_executeLinkProvider",async(c,...e)=>{let[t,i]=e;a.assertType(t instanceof a.URI),typeof i!="number"&&(i=0);const{linkProvider:n}=c.get(o.ILanguageFeaturesService),s=c.get(o.IModelService).getModel(t);if(!s)return[];const r=await Lb(n,s,a.CancellationToken.None);if(!r)return[];for(let d=0;d<Math.min(i,r.links.length);d++)await r.links[d].resolve(a.CancellationToken.None);const l=r.links.slice(0);return r.dispose(),l});var QT=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Wl=function(c,e){return function(t,i){e(t,i,c)}},vp;let Mr=(Qn=class extends a.Disposable{static get(e){return e.getContribution(vp.ID)}constructor(e,t,i,n,s){super(),this.editor=e,this.openerService=t,this.notificationService=i,this.languageFeaturesService=n,this.providers=this.languageFeaturesService.linkProvider,this.debounceInformation=s.for(this.providers,"Links",{min:1e3,max:4e3}),this.computeLinks=this._register(new a.RunOnceScheduler(()=>this.computeLinksNow(),1e3)),this.computePromise=null,this.activeLinksList=null,this.currentOccurrences={},this.activeLinkDecorationId=null;const r=this._register(new wa(e));this._register(r.onMouseMoveOrRelevantKeyDown(([l,d])=>{this._onEditorMouseMove(l,d)})),this._register(r.onExecute(l=>{this.onEditorMouseUp(l)})),this._register(r.onCancel(l=>{this.cleanUpActiveLinkDecoration()})),this._register(e.onDidChangeConfiguration(l=>{l.hasChanged(79)&&(this.updateDecorations([]),this.stop(),this.computeLinks.schedule(0))})),this._register(e.onDidChangeModelContent(l=>{this.editor.hasModel()&&this.computeLinks.schedule(this.debounceInformation.get(this.editor.getModel()))})),this._register(e.onDidChangeModel(l=>{this.currentOccurrences={},this.activeLinkDecorationId=null,this.stop(),this.computeLinks.schedule(0)})),this._register(e.onDidChangeModelLanguage(l=>{this.stop(),this.computeLinks.schedule(0)})),this._register(this.providers.onDidChange(l=>{this.stop(),this.computeLinks.schedule(0)})),this.computeLinks.schedule(0)}async computeLinksNow(){if(!this.editor.hasModel()||!this.editor.getOption(79))return;const e=this.editor.getModel();if(!e.isTooLargeForSyncing()&&this.providers.has(e)){this.activeLinksList&&(this.activeLinksList.dispose(),this.activeLinksList=null),this.computePromise=a.createCancelablePromise(t=>Lb(this.providers,e,t));try{const t=new a.StopWatch(!1);if(this.activeLinksList=await this.computePromise,this.debounceInformation.update(e,t.elapsed()),e.isDisposed())return;this.updateDecorations(this.activeLinksList.links)}catch(t){a.onUnexpectedError(t)}finally{this.computePromise=null}}}updateDecorations(e){const t=this.editor.getOption(86)==="altKey",i=[],n=Object.keys(this.currentOccurrences);for(const r of n){const l=this.currentOccurrences[r];i.push(l.decorationId)}const s=[];if(e)for(const r of e)s.push(qs.decoration(r,t));this.editor.changeDecorations(r=>{const l=r.deltaDecorations(i,s);this.currentOccurrences={},this.activeLinkDecorationId=null;for(let d=0,h=l.length;d<h;d++){const u=new qs(e[d],l[d]);this.currentOccurrences[u.decorationId]=u}})}_onEditorMouseMove(e,t){const i=this.editor.getOption(86)==="altKey";if(this.isEnabled(e,t)){this.cleanUpActiveLinkDecoration();const n=this.getLinkOccurrence(e.target.position);n&&this.editor.changeDecorations(s=>{n.activate(s,i),this.activeLinkDecorationId=n.decorationId})}else this.cleanUpActiveLinkDecoration()}cleanUpActiveLinkDecoration(){const e=this.editor.getOption(86)==="altKey";if(this.activeLinkDecorationId){const t=this.currentOccurrences[this.activeLinkDecorationId];t&&this.editor.changeDecorations(i=>{t.deactivate(i,e)}),this.activeLinkDecorationId=null}}onEditorMouseUp(e){if(!this.isEnabled(e))return;const t=this.getLinkOccurrence(e.target.position);t&&this.openLinkOccurrence(t,e.hasSideBySideModifier,!0)}openLinkOccurrence(e,t,i=!1){if(!this.openerService)return;const{link:n}=e;n.resolve(a.CancellationToken.None).then(s=>{if(typeof s=="string"&&this.editor.hasModel()){const r=this.editor.getModel().uri;if(r.scheme===a.Schemas.file&&s.startsWith(`${a.Schemas.file}:`)){const l=a.URI.parse(s);if(l.scheme===a.Schemas.file){const d=o.originalFSPath(l);let h=null;d.startsWith("/./")||d.startsWith("\\.\\")?h=`.${d.substr(1)}`:(d.startsWith("//./")||d.startsWith("\\\\.\\"))&&(h=`.${d.substr(2)}`),h&&(s=o.joinPath(r,h))}}}return this.openerService.open(s,{openToSide:t,fromUserGesture:i,allowContributedOpeners:!0,allowCommands:!0,fromWorkspace:!0})},s=>{const r=s instanceof Error?s.message:s;r==="invalid"?this.notificationService.warn(a.localize(1343,"Failed to open this link because it is not well-formed: {0}",n.url.toString())):r==="missing"?this.notificationService.warn(a.localize(1344,"Failed to open this link because its target is missing.")):a.onUnexpectedError(s)})}getLinkOccurrence(e){if(!this.editor.hasModel()||!e)return null;const t=this.editor.getModel().getDecorationsInRange({startLineNumber:e.lineNumber,startColumn:e.column,endLineNumber:e.lineNumber,endColumn:e.column},0,!0);for(const i of t){const n=this.currentOccurrences[i.id];if(n)return n}return null}isEnabled(e,t){return!!(e.target.type===6&&(e.hasTriggerModifier||t&&t.keyCodeIsTriggerKey||e.isMiddleClick&&e.mouseMiddleClickAction==="openLink"))}stop(){this.computeLinks.cancel(),this.activeLinksList&&(this.activeLinksList?.dispose(),this.activeLinksList=null),this.computePromise&&(this.computePromise.cancel(),this.computePromise=null)}dispose(){super.dispose(),this.stop()}},vp=Qn,Qn.ID="editor.linkDetector",Qn);Mr=vp=QT([Wl(1,o.IOpenerService),Wl(2,o.INotificationService),Wl(3,o.ILanguageFeaturesService),Wl(4,o.ILanguageFeatureDebounceService)],Mr);const Db={general:o.ModelDecorationOptions.register({description:"detected-link",stickiness:1,collapseOnReplaceEdit:!0,inlineClassName:"detected-link"}),active:o.ModelDecorationOptions.register({description:"detected-link-active",stickiness:1,collapseOnReplaceEdit:!0,inlineClassName:"detected-link-active"})};class qs{static decoration(e,t){return{range:e.range,options:qs._getOptions(e,t,!1)}}static _getOptions(e,t,i){const n={...i?Db.active:Db.general};return n.hoverMessage=JT(e,t),n}constructor(e,t){this.link=e,this.decorationId=t}activate(e,t){e.changeDecorationOptions(this.decorationId,qs._getOptions(this.link,t,!0))}deactivate(e,t){e.changeDecorationOptions(this.decorationId,qs._getOptions(this.link,t,!1))}}function JT(c,e){const t=c.url&&/^command:/i.test(c.url.toString()),i=c.tooltip?c.tooltip:t?a.localize(1345,"Execute command"):a.localize(1346,"Follow link"),n=e?a.isMacintosh?a.localize(1347,"cmd + click"):a.localize(1348,"ctrl + click"):a.isMacintosh?a.localize(1349,"option + click"):a.localize(1350,"alt + click");if(c.url){let s="";if(/^command:/i.test(c.url.toString())){const l=c.url.toString().match(/^command:([^?#]+)/);if(l){const d=l[1];s=a.localize(1351,"Execute command {0}",d)}}return new o.MarkdownString("",!0).appendLink(c.url.toString(!0).replace(/ /g,"%20"),i,s).appendMarkdown(` (${n})`)}else return new o.MarkdownString().appendText(`${i} (${n})`)}class WT extends o.EditorAction{constructor(){super({id:"editor.action.openLink",label:a.localize2(1352,"Open Link"),precondition:void 0})}run(e,t){const i=Mr.get(t);if(!i||!t.hasModel())return;const n=t.getSelections();for(const s of n){const r=i.getLinkOccurrence(s.getEndPosition());r&&i.openLinkOccurrence(r,!1)}}}o.registerEditorContribution(Mr.ID,Mr,1),o.registerEditorAction(WT);const _f=class _f extends a.Disposable{constructor(e){super(),this._editor=e,this._register(this._editor.onMouseDown(t=>{const i=this._editor.getOption(133);i>=0&&t.target.type===6&&t.target.position.column>=i&&this._editor.updateOptions({stopRenderingLineAfter:-1})}))}};_f.ID="editor.contrib.longLinesHelper";let Hl=_f;o.registerEditorContribution(Hl.ID,Hl,2);const vf=class vf extends a.Disposable{constructor(e){super(),this._editor=e;const t=o.observableCodeEditor(this._editor),i=t.getOption(172);this._register(o.autorun(n=>{if(!i.read(n))return;const s=t.domNode.read(n);if(!s)return;const r=n.store.add(o.disposableObservableValue("scrollingSession",void 0));n.store.add(this._editor.onMouseDown(d=>{if(r.read(void 0)){r.set(void 0,void 0);return}if(!d.event.middleButton)return;d.event.stopPropagation(),d.event.preventDefault();const u=new a.DisposableStore,g=new o.Point(d.event.posx,d.event.posy),f=HT(o.getWindow(s),g,u).map(v=>v.subtract(g).withThreshold(5)),m=s.getBoundingClientRect(),_=new o.Point(g.x-m.left,g.y-m.top);r.set({mouseDeltaAfterThreshold:f,initialMousePosInEditor:_,didScroll:!1,dispose:()=>u.dispose()},void 0),u.add(this._editor.onMouseUp(v=>{const b=r.read(void 0);b&&b.didScroll&&r.set(void 0,void 0)})),u.add(this._editor.onKeyDown(v=>{r.set(void 0,void 0)}))})),n.store.add(o.autorun(d=>{const h=r.read(d);if(!h)return;let u=Date.now();d.store.add(o.autorun(p=>{tr.instance.invalidateOnNextAnimationFrame(p);const f=Date.now(),m=f-u;u=f;const _=h.mouseDeltaAfterThreshold.read(void 0),v=m/32,b=_.scale(v),C=new o.Point(this._editor.getScrollLeft(),this._editor.getScrollTop());this._editor.setScrollPosition(e0(C.add(b))),b.isZero()||(h.didScroll=!0)}));const g=o.derived(p=>{const f=h.mouseDeltaAfterThreshold.read(p);let m="";return m+=f.y<0?"n":f.y>0?"s":"",m+=f.x<0?"w":f.x>0?"e":"",m});d.store.add(o.autorun(p=>{s.setAttribute("data-scroll-direction",g.read(p))}))}));const l=n.store.add(o.n.div({class:["scroll-editor-on-middle-click-dot",r.map(d=>d?"":"hidden")],style:{left:r.map(d=>d?d.initialMousePosInEditor.x:0),top:r.map(d=>d?d.initialMousePosInEditor.y:0)}}).toDisposableLiveElement());n.store.add(o.appendRemoveOnDispose(s,l.element)),n.store.add(o.autorun(d=>{const h=r.read(d);s.classList.toggle("scroll-editor-on-middle-click-editor",!!h)}))}))}};vf.ID="editor.contrib.middleScroll";let ec=vf;function HT(c,e,t){const i=o.observableValue("pos",e);return t.add(o.addDisposableListener(c,"mousemove",n=>{i.set(new o.Point(n.pageX,n.pageY),void 0)})),i}function e0(c){return{scrollLeft:c.x,scrollTop:c.y}}o.registerEditorContribution(ec.ID,ec,2);const t0=o.registerColor("editor.wordHighlightBackground",{dark:"#575757B8",light:"#57575740",hcDark:null,hcLight:null},a.localize(1637,"Background color of a symbol during read-access, like reading a variable. The color must not be opaque so as not to hide underlying decorations."),!0);o.registerColor("editor.wordHighlightStrongBackground",{dark:"#004972B8",light:"#0e639c40",hcDark:null,hcLight:null},a.localize(1638,"Background color of a symbol during write-access, like writing to a variable. The color must not be opaque so as not to hide underlying decorations."),!0),o.registerColor("editor.wordHighlightTextBackground",t0,a.localize(1639,"Background color of a textual occurrence for a symbol. The color must not be opaque so as not to hide underlying decorations."),!0);const i0=o.registerColor("editor.wordHighlightBorder",{light:null,dark:null,hcDark:o.activeContrastBorder,hcLight:o.activeContrastBorder},a.localize(1640,"Border color of a symbol during read-access, like reading a variable."));o.registerColor("editor.wordHighlightStrongBorder",{light:null,dark:null,hcDark:o.activeContrastBorder,hcLight:o.activeContrastBorder},a.localize(1641,"Border color of a symbol during write-access, like writing to a variable.")),o.registerColor("editor.wordHighlightTextBorder",i0,a.localize(1642,"Border color of a textual occurrence for a symbol."));const n0=o.registerColor("editorOverviewRuler.wordHighlightForeground","#A0A0A0CC",a.localize(1643,"Overview ruler marker color for symbol highlights. The color must not be opaque so as not to hide underlying decorations."),!0),s0=o.registerColor("editorOverviewRuler.wordHighlightStrongForeground","#C0A0C0CC",a.localize(1644,"Overview ruler marker color for write-access symbol highlights. The color must not be opaque so as not to hide underlying decorations."),!0),o0=o.registerColor("editorOverviewRuler.wordHighlightTextForeground",o.overviewRulerSelectionHighlightForeground,a.localize(1645,"Overview ruler marker color of a textual occurrence for a symbol. The color must not be opaque so as not to hide underlying decorations."),!0),r0=o.ModelDecorationOptions.register({description:"word-highlight-strong",stickiness:1,className:"wordHighlightStrong",overviewRuler:{color:o.themeColorFromId(s0),position:a.OverviewRulerLane.Center},minimap:{color:o.themeColorFromId(o.minimapSelectionOccurrenceHighlight),position:1}}),a0=o.ModelDecorationOptions.register({description:"word-highlight-text",stickiness:1,className:"wordHighlightText",overviewRuler:{color:o.themeColorFromId(o0),position:a.OverviewRulerLane.Center},minimap:{color:o.themeColorFromId(o.minimapSelectionOccurrenceHighlight),position:1}}),l0=o.ModelDecorationOptions.register({description:"selection-highlight-overview",stickiness:1,className:"selectionHighlight",overviewRuler:{color:o.themeColorFromId(o.overviewRulerSelectionHighlightForeground),position:a.OverviewRulerLane.Center},minimap:{color:o.themeColorFromId(o.minimapSelectionOccurrenceHighlight),position:1}}),c0=o.ModelDecorationOptions.register({description:"selection-highlight",stickiness:1,className:"selectionHighlight"}),d0=o.ModelDecorationOptions.register({description:"word-highlight",stickiness:1,className:"wordHighlight",overviewRuler:{color:o.themeColorFromId(n0),position:a.OverviewRulerLane.Center},minimap:{color:o.themeColorFromId(o.minimapSelectionOccurrenceHighlight),position:1}});function h0(c){return c===a.DocumentHighlightKind.Write?r0:c===a.DocumentHighlightKind.Text?a0:d0}function u0(c){return c?c0:l0}o.registerThemingParticipant((c,e)=>{const t=c.getColor(o.editorSelectionHighlight);t&&e.addRule(`.monaco-editor .selectionHighlight { background-color: ${t.transparent(.5)}; }`)});var g0=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},p0=function(c,e){return function(t,i){e(t,i,c)}},bp;function ri(c,e){const t=e.filter(i=>!c.find(n=>n.equals(i)));if(t.length>=1){const i=t.map(s=>`line ${s.viewState.position.lineNumber} column ${s.viewState.position.column}`).join(", "),n=t.length===1?a.localize(1354,"Cursor added: {0}",i):a.localize(1355,"Cursors added: {0}",i);o.status(n)}}class f0 extends o.EditorAction{constructor(){super({id:"editor.action.insertCursorAbove",label:a.localize2(1364,"Add Cursor Above"),precondition:void 0,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:2576,linux:{primary:1552,secondary:[3088]},weight:100},menuOpts:{menuId:o.MenuId.MenubarSelectionMenu,group:"3_multi",title:a.localize(1356,"&&Add Cursor Above"),order:2}})}run(e,t,i){if(!t.hasModel())return;let n=!0;i&&i.logicalLine===!1&&(n=!1);const s=t._getViewModel();if(s.cursorConfig.readOnly)return;s.model.pushStackElement();const r=s.getCursorStates();s.setCursorStates(i.source,3,o.CursorMoveCommands.addCursorUp(s,r,n)),s.revealTopMostCursor(i.source),ri(r,s.getCursorStates())}}class m0 extends o.EditorAction{constructor(){super({id:"editor.action.insertCursorBelow",label:a.localize2(1365,"Add Cursor Below"),precondition:void 0,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:2578,linux:{primary:1554,secondary:[3090]},weight:100},menuOpts:{menuId:o.MenuId.MenubarSelectionMenu,group:"3_multi",title:a.localize(1357,"A&&dd Cursor Below"),order:3}})}run(e,t,i){if(!t.hasModel())return;let n=!0;i&&i.logicalLine===!1&&(n=!1);const s=t._getViewModel();if(s.cursorConfig.readOnly)return;s.model.pushStackElement();const r=s.getCursorStates();s.setCursorStates(i.source,3,o.CursorMoveCommands.addCursorDown(s,r,n)),s.revealBottomMostCursor(i.source),ri(r,s.getCursorStates())}}class _0 extends o.EditorAction{constructor(){super({id:"editor.action.insertCursorAtEndOfEachLineSelected",label:a.localize2(1366,"Add Cursors to Line Ends"),precondition:void 0,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:1575,weight:100},menuOpts:{menuId:o.MenuId.MenubarSelectionMenu,group:"3_multi",title:a.localize(1358,"Add C&&ursors to Line Ends"),order:4}})}getCursorsForSelection(e,t,i){if(!e.isEmpty()){for(let n=e.startLineNumber;n<e.endLineNumber;n++){const s=t.getLineMaxColumn(n);i.push(new a.Selection(n,s,n,s))}e.endColumn>1&&i.push(new a.Selection(e.endLineNumber,e.endColumn,e.endLineNumber,e.endColumn))}}run(e,t){if(!t.hasModel())return;const i=t.getModel(),n=t.getSelections(),s=t._getViewModel(),r=s.getCursorStates(),l=[];n.forEach(d=>this.getCursorsForSelection(d,i,l)),l.length>0&&t.setSelections(l),ri(r,s.getCursorStates())}}class v0 extends o.EditorAction{constructor(){super({id:"editor.action.addCursorsToBottom",label:a.localize2(1367,"Add Cursors to Bottom"),precondition:void 0})}run(e,t){if(!t.hasModel())return;const i=t.getSelections(),n=t.getModel().getLineCount(),s=[];for(let d=i[0].startLineNumber;d<=n;d++)s.push(new a.Selection(d,i[0].startColumn,d,i[0].endColumn));const r=t._getViewModel(),l=r.getCursorStates();s.length>0&&t.setSelections(s),ri(l,r.getCursorStates())}}class b0 extends o.EditorAction{constructor(){super({id:"editor.action.addCursorsToTop",label:a.localize2(1368,"Add Cursors to Top"),precondition:void 0})}run(e,t){if(!t.hasModel())return;const i=t.getSelections(),n=[];for(let l=i[0].startLineNumber;l>=1;l--)n.push(new a.Selection(l,i[0].startColumn,l,i[0].endColumn));const s=t._getViewModel(),r=s.getCursorStates();n.length>0&&t.setSelections(n),ri(r,s.getCursorStates())}}class tc{constructor(e,t,i){this.selections=e,this.revealRange=t,this.revealScrollType=i}}class Pr{static create(e,t){if(!e.hasModel())return null;const i=t.getState();if(!e.hasTextFocus()&&i.isRevealed&&i.searchString.length>0)return new Pr(e,t,!1,i.searchString,i.wholeWord,i.matchCase,null);let n=!1,s,r;const l=e.getSelections();l.length===1&&l[0].isEmpty()?(n=!0,s=!0,r=!0):(s=i.wholeWord,r=i.matchCase);const d=e.getSelection();let h,u=null;if(d.isEmpty()){const g=e.getConfiguredWordAtPosition(d.getStartPosition());if(!g)return null;h=g.word,u=new a.Selection(d.startLineNumber,g.startColumn,d.startLineNumber,g.endColumn)}else h=e.getModel().getValueInRange(d).replace(/\r\n/g,`
64
+ `);return new Pr(e,t,n,h,s,r,u)}constructor(e,t,i,n,s,r,l){this._editor=e,this.findController=t,this.isDisconnectedFromFindController=i,this.searchText=n,this.wholeWord=s,this.matchCase=r,this.currentMatch=l}addSelectionToNextFindMatch(){if(!this._editor.hasModel())return null;const e=this._getNextMatch();if(!e)return null;const t=this._editor.getSelections();return new tc(t.concat(e),e,0)}moveSelectionToNextFindMatch(){if(!this._editor.hasModel())return null;const e=this._getNextMatch();if(!e)return null;const t=this._editor.getSelections();return new tc(t.slice(0,t.length-1).concat(e),e,0)}_getNextMatch(){if(!this._editor.hasModel())return null;if(this.currentMatch){const n=this.currentMatch;return this.currentMatch=null,n}this.findController.highlightFindOptions();const e=this._editor.getSelections(),t=e[e.length-1],i=this._editor.getModel().findNextMatch(this.searchText,t.getEndPosition(),!1,this.matchCase,this.wholeWord?this._editor.getOption(148):null,!1);return i?new a.Selection(i.range.startLineNumber,i.range.startColumn,i.range.endLineNumber,i.range.endColumn):null}addSelectionToPreviousFindMatch(){if(!this._editor.hasModel())return null;const e=this._getPreviousMatch();if(!e)return null;const t=this._editor.getSelections();return new tc(t.concat(e),e,0)}moveSelectionToPreviousFindMatch(){if(!this._editor.hasModel())return null;const e=this._getPreviousMatch();if(!e)return null;const t=this._editor.getSelections();return new tc(t.slice(0,t.length-1).concat(e),e,0)}_getPreviousMatch(){if(!this._editor.hasModel())return null;if(this.currentMatch){const n=this.currentMatch;return this.currentMatch=null,n}this.findController.highlightFindOptions();const e=this._editor.getSelections(),t=e[e.length-1],i=this._editor.getModel().findPreviousMatch(this.searchText,t.getStartPosition(),!1,this.matchCase,this.wholeWord?this._editor.getOption(148):null,!1);return i?new a.Selection(i.range.startLineNumber,i.range.startColumn,i.range.endLineNumber,i.range.endColumn):null}selectAll(e){if(!this._editor.hasModel())return[];this.findController.highlightFindOptions();const t=this._editor.getModel();return e?t.findMatches(this.searchText,e,!1,this.matchCase,this.wholeWord?this._editor.getOption(148):null,!1,1073741824):t.findMatches(this.searchText,!0,!1,this.matchCase,this.wholeWord?this._editor.getOption(148):null,!1,1073741824)}}const id=class id extends a.Disposable{static get(e){return e.getContribution(id.ID)}constructor(e){super(),this._sessionDispose=this._register(new a.DisposableStore),this._editor=e,this._ignoreSelectionChange=!1,this._session=null}dispose(){this._endSession(),super.dispose()}_beginSessionIfNeeded(e){if(!this._session){const t=Pr.create(this._editor,e);if(!t)return;this._session=t;const i={searchString:this._session.searchText};this._session.isDisconnectedFromFindController&&(i.wholeWordOverride=1,i.matchCaseOverride=1,i.isRegexOverride=2),e.getState().change(i,!1),this._sessionDispose.add(this._editor.onDidChangeCursorSelection(n=>{this._ignoreSelectionChange||this._endSession()})),this._sessionDispose.add(this._editor.onDidBlurEditorText(()=>{this._endSession()})),this._sessionDispose.add(e.getState().onFindReplaceStateChange(n=>{(n.matchCase||n.wholeWord)&&this._endSession()}))}}_endSession(){if(this._sessionDispose.clear(),this._session&&this._session.isDisconnectedFromFindController){const e={wholeWordOverride:0,matchCaseOverride:0,isRegexOverride:0};this._session.findController.getState().change(e,!1)}this._session=null}_setSelections(e){this._ignoreSelectionChange=!0,this._editor.setSelections(e),this._ignoreSelectionChange=!1}_expandEmptyToWord(e,t){if(!t.isEmpty())return t;const i=this._editor.getConfiguredWordAtPosition(t.getStartPosition());return i?new a.Selection(t.startLineNumber,i.startColumn,t.startLineNumber,i.endColumn):t}_applySessionResult(e){e&&(this._setSelections(e.selections),e.revealRange&&this._editor.revealRangeInCenterIfOutsideViewport(e.revealRange,e.revealScrollType))}getSession(e){return this._session}addSelectionToNextFindMatch(e){if(this._editor.hasModel()){if(!this._session){const t=this._editor.getSelections();if(t.length>1){const n=e.getState().matchCase;if(!Rb(this._editor.getModel(),t,n)){const r=this._editor.getModel(),l=[];for(let d=0,h=t.length;d<h;d++)l[d]=this._expandEmptyToWord(r,t[d]);this._editor.setSelections(l);return}}}this._beginSessionIfNeeded(e),this._session&&this._applySessionResult(this._session.addSelectionToNextFindMatch())}}addSelectionToPreviousFindMatch(e){this._beginSessionIfNeeded(e),this._session&&this._applySessionResult(this._session.addSelectionToPreviousFindMatch())}moveSelectionToNextFindMatch(e){this._beginSessionIfNeeded(e),this._session&&this._applySessionResult(this._session.moveSelectionToNextFindMatch())}moveSelectionToPreviousFindMatch(e){this._beginSessionIfNeeded(e),this._session&&this._applySessionResult(this._session.moveSelectionToPreviousFindMatch())}selectAll(e){if(!this._editor.hasModel())return;let t=null;const i=e.getState();if(i.isRevealed&&i.searchString.length>0&&i.isRegex){const n=this._editor.getModel();i.searchScope?t=n.findMatches(i.searchString,i.searchScope,i.isRegex,i.matchCase,i.wholeWord?this._editor.getOption(148):null,!1,1073741824):t=n.findMatches(i.searchString,!0,i.isRegex,i.matchCase,i.wholeWord?this._editor.getOption(148):null,!1,1073741824)}else{if(this._beginSessionIfNeeded(e),!this._session)return;t=this._session.selectAll(i.searchScope)}if(t.length>0){const n=this._editor.getSelection();for(let s=0,r=t.length;s<r;s++){const l=t[s];if(l.range.intersectRanges(n)){t[s]=t[0],t[0]=l;break}}this._setSelections(t.map(s=>new a.Selection(s.range.startLineNumber,s.range.startColumn,s.range.endLineNumber,s.range.endColumn)))}}};id.ID="editor.contrib.multiCursorController";let Gs=id;class Zs extends o.EditorAction{run(e,t){const i=Gs.get(t);if(!i)return;const n=t._getViewModel();if(n){const s=n.getCursorStates(),r=fe.get(t);if(r)this._run(i,r);else{const l=e.get(o.IInstantiationService).createInstance(fe,t);this._run(i,l),l.dispose()}ri(s,n.getCursorStates())}}}class C0 extends Zs{constructor(){super({id:"editor.action.addSelectionToNextFindMatch",label:a.localize2(1369,"Add Selection to Next Find Match"),precondition:void 0,kbOpts:{kbExpr:o.EditorContextKeys.focus,primary:2082,weight:100},menuOpts:{menuId:o.MenuId.MenubarSelectionMenu,group:"3_multi",title:a.localize(1359,"Add &&Next Occurrence"),order:5}})}_run(e,t){e.addSelectionToNextFindMatch(t)}}class S0 extends Zs{constructor(){super({id:"editor.action.addSelectionToPreviousFindMatch",label:a.localize2(1370,"Add Selection to Previous Find Match"),precondition:void 0,menuOpts:{menuId:o.MenuId.MenubarSelectionMenu,group:"3_multi",title:a.localize(1360,"Add P&&revious Occurrence"),order:6}})}_run(e,t){e.addSelectionToPreviousFindMatch(t)}}class y0 extends Zs{constructor(){super({id:"editor.action.moveSelectionToNextFindMatch",label:a.localize2(1371,"Move Last Selection to Next Find Match"),precondition:void 0,kbOpts:{kbExpr:o.EditorContextKeys.focus,primary:a.KeyChord(2089,2082),weight:100}})}_run(e,t){e.moveSelectionToNextFindMatch(t)}}class w0 extends Zs{constructor(){super({id:"editor.action.moveSelectionToPreviousFindMatch",label:a.localize2(1372,"Move Last Selection to Previous Find Match"),precondition:void 0})}_run(e,t){e.moveSelectionToPreviousFindMatch(t)}}class I0 extends Zs{constructor(){super({id:"editor.action.selectHighlights",label:a.localize2(1373,"Select All Occurrences of Find Match"),precondition:void 0,kbOpts:{kbExpr:o.EditorContextKeys.focus,primary:3114,weight:100},menuOpts:{menuId:o.MenuId.MenubarSelectionMenu,group:"3_multi",title:a.localize(1361,"Select All &&Occurrences"),order:7}})}_run(e,t){e.selectAll(t)}}class x0 extends Zs{constructor(){super({id:"editor.action.changeAll",label:a.localize2(1374,"Change All Occurrences"),precondition:o.ContextKeyExpr.and(o.EditorContextKeys.writable,o.EditorContextKeys.editorTextFocus),kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:2108,weight:100},contextMenuOpts:{group:"1_modification",order:1.2}})}_run(e,t){e.selectAll(t)}}class E0{constructor(e,t,i,n,s){this._model=e,this._searchText=t,this._matchCase=i,this._wordSeparators=n,this._cachedFindMatches=null,this._modelVersionId=this._model.getVersionId(),s&&this._model===s._model&&this._searchText===s._searchText&&this._matchCase===s._matchCase&&this._wordSeparators===s._wordSeparators&&this._modelVersionId===s._modelVersionId&&(this._cachedFindMatches=s._cachedFindMatches)}findMatches(){return this._cachedFindMatches===null&&(this._cachedFindMatches=this._model.findMatches(this._searchText,!0,!1,this._matchCase,this._wordSeparators,!1).map(e=>e.range),this._cachedFindMatches.sort(a.Range.compareRangesUsingStarts)),this._cachedFindMatches}}let ic=(Jn=class extends a.Disposable{constructor(e,t){super(),this._languageFeaturesService=t,this.editor=e,this._isEnabled=e.getOption(122),this._isEnabledMultiline=e.getOption(124),this._maxLength=e.getOption(123),this._decorations=e.createDecorationsCollection(),this.updateSoon=this._register(new a.RunOnceScheduler(()=>this._update(),300)),this.state=null,this._register(e.onDidChangeConfiguration(n=>{this._isEnabled=e.getOption(122),this._isEnabledMultiline=e.getOption(124),this._maxLength=e.getOption(123)})),this._register(e.onDidChangeCursorSelection(n=>{this._isEnabled&&(n.selection.isEmpty()?n.reason===3?(this.state&&this._setState(null),this.updateSoon.schedule()):this._setState(null):this._update())})),this._register(e.onDidChangeModel(n=>{this._setState(null)})),this._register(e.onDidChangeModelContent(n=>{this._isEnabled&&this.updateSoon.schedule()}));const i=fe.get(e);i&&this._register(i.getState().onFindReplaceStateChange(n=>{this._update()})),this.updateSoon.schedule()}_update(){this._setState(bp._createState(this.state,this._isEnabled,this._isEnabledMultiline,this._maxLength,this.editor))}static _createState(e,t,i,n,s){if(!t||!s.hasModel())return null;if(!i){const g=s.getSelection();if(g.startLineNumber!==g.endLineNumber)return null}const r=Gs.get(s);if(!r)return null;const l=fe.get(s);if(!l)return null;let d=r.getSession(l);if(!d){const g=s.getSelections();if(g.length>1){const f=l.getState().matchCase;if(!Rb(s.getModel(),g,f))return null}d=Pr.create(s,l)}if(!d||d.currentMatch||/^[ \t]+$/.test(d.searchText)||n>0&&d.searchText.length>n)return null;const h=l.getState(),u=h.matchCase;if(h.isRevealed){let g=h.searchString;u||(g=g.toLowerCase());let p=d.searchText;if(u||(p=p.toLowerCase()),g===p&&d.matchCase===h.matchCase&&d.wholeWord===h.wholeWord&&!h.isRegex)return null}return new E0(s.getModel(),d.searchText,d.matchCase,d.wholeWord?s.getOption(148):null,e)}_setState(e){if(this.state=e,!this.state){this._decorations.clear();return}if(!this.editor.hasModel())return;const t=this.editor.getModel();if(t.isTooLargeForTokenization())return;const i=this.state.findMatches(),n=this.editor.getSelections();n.sort(a.Range.compareRangesUsingStarts);const s=[];for(let h=0,u=0,g=i.length,p=n.length;h<g;){const f=i[h];if(u>=p)s.push(f),h++;else{const m=a.Range.compareRangesUsingStarts(f,n[u]);m<0?((n[u].isEmpty()||!a.Range.areIntersecting(f,n[u]))&&s.push(f),h++):(m>0||h++,u++)}}const r=this.editor.getOption(90)!=="off",l=this._languageFeaturesService.documentHighlightProvider.has(t)&&r,d=s.map(h=>({range:h,options:u0(l)}));this._decorations.set(d)}dispose(){this._setState(null),super.dispose()}},bp=Jn,Jn.ID="editor.contrib.selectionHighlighter",Jn);ic=bp=g0([p0(1,o.ILanguageFeaturesService)],ic);function Rb(c,e,t){const i=Tb(c,e[0],!t);for(let n=1,s=e.length;n<s;n++){const r=e[n];if(r.isEmpty())return!1;const l=Tb(c,r,!t);if(i!==l)return!1}return!0}function Tb(c,e,t){const i=c.getValueInRange(e);return t?i.toLowerCase():i}class L0 extends o.EditorAction{constructor(){super({id:"editor.action.focusNextCursor",label:a.localize2(1375,"Focus Next Cursor"),metadata:{description:a.localize(1362,"Focuses the next cursor"),args:[]},precondition:void 0})}run(e,t,i){if(!t.hasModel())return;const n=t._getViewModel();if(n.cursorConfig.readOnly)return;n.model.pushStackElement();const s=Array.from(n.getCursorStates()),r=s.shift();r&&(s.push(r),n.setCursorStates(i.source,3,s),n.revealPrimaryCursor(i.source,!0),ri(s,n.getCursorStates()))}}class D0 extends o.EditorAction{constructor(){super({id:"editor.action.focusPreviousCursor",label:a.localize2(1376,"Focus Previous Cursor"),metadata:{description:a.localize(1363,"Focuses the previous cursor"),args:[]},precondition:void 0})}run(e,t,i){if(!t.hasModel())return;const n=t._getViewModel();if(n.cursorConfig.readOnly)return;n.model.pushStackElement();const s=Array.from(n.getCursorStates()),r=s.pop();r&&(s.unshift(r),n.setCursorStates(i.source,3,s),n.revealPrimaryCursor(i.source,!0),ri(s,n.getCursorStates()))}}o.registerEditorContribution(Gs.ID,Gs,4),o.registerEditorContribution(ic.ID,ic,1),o.registerEditorAction(f0),o.registerEditorAction(m0),o.registerEditorAction(_0),o.registerEditorAction(C0),o.registerEditorAction(S0),o.registerEditorAction(y0),o.registerEditorAction(w0),o.registerEditorAction(I0),o.registerEditorAction(x0),o.registerEditorAction(v0),o.registerEditorAction(b0),o.registerEditorAction(L0),o.registerEditorAction(D0);const pn={Visible:new o.RawContextKey("parameterHintsVisible",!1),MultipleSignatures:new o.RawContextKey("parameterHintsMultipleSignatures",!1)};async function Nb(c,e,t,i,n){const s=c.ordered(e);for(const r of s)try{const l=await r.provideSignatureHelp(e,t,n,i);if(l)return l}catch(l){a.onUnexpectedExternalError(l)}}o.CommandsRegistry.registerCommand("_executeSignatureHelpProvider",async(c,...e)=>{const[t,i,n]=e;a.assertType(a.URI.isUri(t)),a.assertType(a.Position.isIPosition(i)),a.assertType(typeof n=="string"||!n);const s=c.get(o.ILanguageFeaturesService),r=await c.get(o.ITextModelService).createModelReference(t);try{const l=await Nb(s.signatureHelpProvider,r.object.textEditorModel,a.Position.lift(i),{triggerKind:a.SignatureHelpTriggerKind.Invoke,isRetrigger:!1,triggerCharacter:n},a.CancellationToken.None);return l?(setTimeout(()=>l.dispose(),0),l.value):void 0}finally{r.dispose()}});var ai;(function(c){c.Default={type:0};class e{constructor(n,s){this.request=n,this.previouslyActiveHints=s,this.type=2}}c.Pending=e;class t{constructor(n){this.hints=n,this.type=1}}c.Active=t})(ai||(ai={}));const nd=class nd extends a.Disposable{constructor(e,t,i=nd.DEFAULT_DELAY){super(),this._onChangedHints=this._register(new a.Emitter),this.onChangedHints=this._onChangedHints.event,this.triggerOnType=!1,this._state=ai.Default,this._pendingTriggers=[],this._lastSignatureHelpResult=this._register(new a.MutableDisposable),this.triggerChars=new a.CharacterSet,this.retriggerChars=new a.CharacterSet,this.triggerId=0,this.editor=e,this.providers=t,this.throttledDelayer=this._register(new a.Delayer(i)),this._register(this.editor.onDidBlurEditorWidget(()=>this.cancel())),this._register(this.editor.onDidChangeConfiguration(()=>this.onEditorConfigurationChange())),this._register(this.editor.onDidChangeModel(n=>this.onModelChanged())),this._register(this.editor.onDidChangeModelLanguage(n=>this.onModelChanged())),this._register(this.editor.onDidChangeCursorSelection(n=>this.onCursorChange(n))),this._register(this.editor.onDidChangeModelContent(n=>this.onModelContentChange())),this._register(this.providers.onDidChange(this.onModelChanged,this)),this._register(this.editor.onDidType(n=>this.onDidType(n))),this.onEditorConfigurationChange(),this.onModelChanged()}get state(){return this._state}set state(e){this._state.type===2&&this._state.request.cancel(),this._state=e}cancel(e=!1){this.state=ai.Default,this.throttledDelayer.cancel(),e||this._onChangedHints.fire(void 0)}trigger(e,t){const i=this.editor.getModel();if(!i||!this.providers.has(i))return;const n=++this.triggerId;this._pendingTriggers.push(e),this.throttledDelayer.trigger(()=>this.doTrigger(n),t).catch(a.onUnexpectedError)}next(){if(this.state.type!==1)return;const e=this.state.hints.signatures.length,t=this.state.hints.activeSignature,i=t%e===e-1,n=this.editor.getOption(98).cycle;if((e<2||i)&&!n){this.cancel();return}this.updateActiveSignature(i&&n?0:t+1)}previous(){if(this.state.type!==1)return;const e=this.state.hints.signatures.length,t=this.state.hints.activeSignature,i=t===0,n=this.editor.getOption(98).cycle;if((e<2||i)&&!n){this.cancel();return}this.updateActiveSignature(i&&n?e-1:t-1)}updateActiveSignature(e){this.state.type===1&&(this.state=new ai.Active({...this.state.hints,activeSignature:e}),this._onChangedHints.fire(this.state.hints))}async doTrigger(e){const t=this.state.type===1||this.state.type===2,i=this.getLastActiveHints();if(this.cancel(!0),this._pendingTriggers.length===0)return!1;const n=this._pendingTriggers.reduce(R0);this._pendingTriggers=[];const s={triggerKind:n.triggerKind,triggerCharacter:n.triggerCharacter,isRetrigger:t,activeSignatureHelp:i};if(!this.editor.hasModel())return!1;const r=this.editor.getModel(),l=this.editor.getPosition();this.state=new ai.Pending(a.createCancelablePromise(d=>Nb(this.providers,r,l,s,d)),i);try{const d=await this.state.request;return e!==this.triggerId?(d?.dispose(),!1):!d||!d.value.signatures||d.value.signatures.length===0?(d?.dispose(),this._lastSignatureHelpResult.clear(),this.cancel(),!1):(this.state=new ai.Active(d.value),this._lastSignatureHelpResult.value=d,this._onChangedHints.fire(this.state.hints),!0)}catch(d){return e===this.triggerId&&(this.state=ai.Default),a.onUnexpectedError(d),!1}}getLastActiveHints(){switch(this.state.type){case 1:return this.state.hints;case 2:return this.state.previouslyActiveHints;default:return}}get isTriggered(){return this.state.type===1||this.state.type===2||this.throttledDelayer.isTriggered()}onModelChanged(){this.cancel(),this.triggerChars.clear(),this.retriggerChars.clear();const e=this.editor.getModel();if(e)for(const t of this.providers.ordered(e)){for(const i of t.signatureHelpTriggerCharacters||[])if(i.length){const n=i.charCodeAt(0);this.triggerChars.add(n),this.retriggerChars.add(n)}for(const i of t.signatureHelpRetriggerCharacters||[])i.length&&this.retriggerChars.add(i.charCodeAt(0))}}onDidType(e){if(!this.triggerOnType)return;const t=e.length-1,i=e.charCodeAt(t);(this.triggerChars.has(i)||this.isTriggered&&this.retriggerChars.has(i))&&this.trigger({triggerKind:a.SignatureHelpTriggerKind.TriggerCharacter,triggerCharacter:e.charAt(t)})}onCursorChange(e){e.source==="mouse"?this.cancel():this.isTriggered&&this.trigger({triggerKind:a.SignatureHelpTriggerKind.ContentChange})}onModelContentChange(){this.isTriggered&&this.trigger({triggerKind:a.SignatureHelpTriggerKind.ContentChange})}onEditorConfigurationChange(){this.triggerOnType=this.editor.getOption(98).enabled,this.triggerOnType||this.cancel()}dispose(){this.cancel(!0),super.dispose()}};nd.DEFAULT_DELAY=120;let Cp=nd;function R0(c,e){switch(e.triggerKind){case a.SignatureHelpTriggerKind.Invoke:return e;case a.SignatureHelpTriggerKind.ContentChange:return c;case a.SignatureHelpTriggerKind.TriggerCharacter:default:return e}}var T0=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Mb=function(c,e){return function(t,i){e(t,i,c)}},Sp;const De=o.$,N0=o.registerIcon("parameter-hints-next",a.Codicon.chevronDown,a.localize(1378,"Icon for show next parameter hint.")),M0=o.registerIcon("parameter-hints-previous",a.Codicon.chevronUp,a.localize(1379,"Icon for show previous parameter hint."));let yp=(Wn=class extends a.Disposable{constructor(e,t,i,n){super(),this.editor=e,this.model=t,this.markdownRendererService=n,this.renderDisposeables=this._register(new a.DisposableStore),this.visible=!1,this.announcedLabel=null,this.allowEditorOverflow=!0,this.keyVisible=pn.Visible.bindTo(i),this.keyMultipleSignatures=pn.MultipleSignatures.bindTo(i)}createParameterHintDOMNodes(){const e=De(".editor-widget.parameter-hints-widget"),t=o.append(e,De(".phwrapper"));t.tabIndex=-1;const i=o.append(t,De(".controls")),n=o.append(i,De(".button"+o.ThemeIcon.asCSSSelector(M0))),s=o.append(i,De(".overloads")),r=o.append(i,De(".button"+o.ThemeIcon.asCSSSelector(N0)));this._register(o.addDisposableListener(n,"click",p=>{o.EventHelper.stop(p),this.previous()})),this._register(o.addDisposableListener(r,"click",p=>{o.EventHelper.stop(p),this.next()}));const l=De(".body"),d=new o.DomScrollableElement(l,{alwaysConsumeMouseWheel:!0});this._register(d),t.appendChild(d.getDomNode());const h=o.append(l,De(".signature")),u=o.append(l,De(".docs"));e.style.userSelect="text",this.domNodes={element:e,signature:h,overloads:s,docs:u,scrollbar:d},this.editor.addContentWidget(this),this.hide(),this._register(this.editor.onDidChangeCursorSelection(p=>{this.visible&&this.editor.layoutContentWidget(this)}));const g=()=>{if(!this.domNodes)return;const p=this.editor.getOption(59),f=this.domNodes.element;f.style.fontSize=`${p.fontSize}px`,f.style.lineHeight=`${p.lineHeight/p.fontSize}`,f.style.setProperty("--vscode-parameterHintsWidget-editorFontFamily",p.fontFamily),f.style.setProperty("--vscode-parameterHintsWidget-editorFontFamilyDefault",o.EDITOR_FONT_DEFAULTS.fontFamily)};g(),this._register(a.Event.chain(this.editor.onDidChangeConfiguration.bind(this.editor),p=>p.filter(f=>f.hasChanged(59)))(g)),this._register(this.editor.onDidLayoutChange(p=>this.updateMaxHeight())),this.updateMaxHeight()}show(){this.visible||(this.domNodes||this.createParameterHintDOMNodes(),this.keyVisible.set(!0),this.visible=!0,setTimeout(()=>{this.domNodes?.element.classList.add("visible")},100),this.editor.layoutContentWidget(this))}hide(){this.renderDisposeables.clear(),this.visible&&(this.keyVisible.reset(),this.visible=!1,this.announcedLabel=null,this.domNodes?.element.classList.remove("visible"),this.editor.layoutContentWidget(this))}getPosition(){return this.visible?{position:this.editor.getPosition(),preference:[1,2]}:null}render(e){if(this.renderDisposeables.clear(),!this.domNodes)return;const t=e.signatures.length>1;this.domNodes.element.classList.toggle("multiple",t),this.keyMultipleSignatures.set(t),this.domNodes.signature.innerText="",this.domNodes.docs.innerText="";const i=e.signatures[e.activeSignature];if(!i)return;const n=o.append(this.domNodes.signature,De(".code")),s=i.parameters.length>0,r=i.activeParameter??e.activeParameter;if(s)this.renderParameters(n,i,r);else{const h=o.append(n,De("span"));h.textContent=i.label}const l=i.parameters[r];if(l?.documentation){const h=De("span.documentation");if(typeof l.documentation=="string")h.textContent=l.documentation;else{const u=this.renderMarkdownDocs(l.documentation);h.appendChild(u.element)}o.append(this.domNodes.docs,De("p",{},h))}if(i.documentation!==void 0)if(typeof i.documentation=="string")o.append(this.domNodes.docs,De("p",{},i.documentation));else{const h=this.renderMarkdownDocs(i.documentation);o.append(this.domNodes.docs,h.element)}const d=this.hasDocs(i,l);if(this.domNodes.signature.classList.toggle("has-docs",d),this.domNodes.docs.classList.toggle("empty",!d),this.domNodes.overloads.textContent=String(e.activeSignature+1).padStart(e.signatures.length.toString().length,"0")+"/"+e.signatures.length,l){let h="";const u=i.parameters[r];Array.isArray(u.label)?h=i.label.substring(u.label[0],u.label[1]):h=u.label,u.documentation&&(h+=typeof u.documentation=="string"?`, ${u.documentation}`:`, ${u.documentation.value}`),i.documentation&&(h+=typeof i.documentation=="string"?`, ${i.documentation}`:`, ${i.documentation.value}`),this.announcedLabel!==h&&(o.alert(a.localize(1380,"{0}, hint",h)),this.announcedLabel=h)}this.editor.layoutContentWidget(this),this.domNodes.scrollbar.scanDomNode()}renderMarkdownDocs(e){const t=this.renderDisposeables.add(this.markdownRendererService.render(e,{context:this.editor,asyncRenderCallback:()=>{this.domNodes?.scrollbar.scanDomNode()}}));return t.element.classList.add("markdown-docs"),t}hasDocs(e,t){return!!(t&&typeof t.documentation=="string"&&a.assertReturnsDefined(t.documentation).length>0||t&&typeof t.documentation=="object"&&a.assertReturnsDefined(t.documentation).value.length>0||e.documentation&&typeof e.documentation=="string"&&a.assertReturnsDefined(e.documentation).length>0||e.documentation&&typeof e.documentation=="object"&&a.assertReturnsDefined(e.documentation.value).length>0)}renderParameters(e,t,i){const[n,s]=this.getParameterLabelOffsets(t,i),r=document.createElement("span");r.textContent=t.label.substring(0,n);const l=document.createElement("span");l.textContent=t.label.substring(n,s),l.className="parameter active";const d=document.createElement("span");d.textContent=t.label.substring(s),o.append(e,r,l,d)}getParameterLabelOffsets(e,t){const i=e.parameters[t];if(i){if(Array.isArray(i.label))return i.label;if(i.label.length){const n=new RegExp(`(\\W|^)${a.escapeRegExpCharacters(i.label)}(?=\\W|$)`,"g");n.test(e.label);const s=n.lastIndex-i.label.length;return s>=0?[s,n.lastIndex]:[0,0]}else return[0,0]}else return[0,0]}next(){this.editor.focus(),this.model.next()}previous(){this.editor.focus(),this.model.previous()}getDomNode(){return this.domNodes||this.createParameterHintDOMNodes(),this.domNodes.element}getId(){return Sp.ID}updateMaxHeight(){if(!this.domNodes)return;const t=`${Math.max(this.editor.getLayoutInfo().height/4,250)}px`;this.domNodes.element.style.maxHeight=t;const i=this.domNodes.element.getElementsByClassName("phwrapper");i.length&&(i[0].style.maxHeight=t)}},Sp=Wn,Wn.ID="editor.widget.parameterHintsWidget",Wn);yp=Sp=T0([Mb(2,o.IContextKeyService),Mb(3,o.IMarkdownRendererService)],yp),o.registerColor("editorHoverWidget.highlightForeground",o.listHighlightForeground,a.localize(1381,"Foreground color of the active item in the parameter hint."));var P0=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Pb=function(c,e){return function(t,i){e(t,i,c)}},wp;let Xs=(Hn=class extends a.Disposable{static get(e){return e.getContribution(wp.ID)}constructor(e,t,i){super(),this.editor=e,this.model=this._register(new Cp(e,i.signatureHelpProvider)),this._register(this.model.onChangedHints(n=>{n?(this.widget.value.show(),this.widget.value.render(n)):this.widget.rawValue?.hide()})),this.widget=new a.Lazy(()=>this._register(t.createInstance(yp,this.editor,this.model)))}cancel(){this.model.cancel()}previous(){this.widget.rawValue?.previous()}next(){this.widget.rawValue?.next()}trigger(e){this.model.trigger(e,0)}},wp=Hn,Hn.ID="editor.controller.parameterHints",Hn);Xs=wp=P0([Pb(1,o.IInstantiationService),Pb(2,o.ILanguageFeaturesService)],Xs);class O0 extends o.EditorAction{constructor(){super({id:"editor.action.triggerParameterHints",label:a.localize2(1377,"Trigger Parameter Hints"),precondition:o.EditorContextKeys.hasSignatureHelpProvider,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:3082,weight:100}})}run(e,t){Xs.get(t)?.trigger({triggerKind:a.SignatureHelpTriggerKind.Invoke})}}o.registerEditorContribution(Xs.ID,Xs,2),o.registerEditorAction(O0);const Ip=175,xp=o.EditorCommand.bindToContribution(Xs.get);o.registerEditorCommand(new xp({id:"closeParameterHints",precondition:pn.Visible,handler:c=>c.cancel(),kbOpts:{weight:Ip,kbExpr:o.EditorContextKeys.focus,primary:9,secondary:[1033]}})),o.registerEditorCommand(new xp({id:"showPrevParameterHint",precondition:o.ContextKeyExpr.and(pn.Visible,pn.MultipleSignatures),handler:c=>c.previous(),kbOpts:{weight:Ip,kbExpr:o.EditorContextKeys.focus,primary:16,secondary:[528],mac:{primary:16,secondary:[528,302]}}})),o.registerEditorCommand(new xp({id:"showNextParameterHint",precondition:o.ContextKeyExpr.and(pn.Visible,pn.MultipleSignatures),handler:c=>c.next(),kbOpts:{weight:Ip,kbExpr:o.EditorContextKeys.focus,primary:18,secondary:[530],mac:{primary:18,secondary:[530,300]}}}));const bf=class bf extends a.Disposable{constructor(e){super(),this._editor=e,this._editorObs=o.observableCodeEditor(this._editor),this._placeholderText=this._editorObs.getOption(100),this._state=o.derivedOpts({owner:this,equalsFn:o.structuralEquals},t=>{const i=this._placeholderText.read(t);if(i&&this._editorObs.valueIsEmpty.read(t))return{placeholder:i}}),this._shouldViewBeAlive=A0(this,t=>this._state.read(t)?.placeholder!==void 0),this._view=o.derived(t=>{if(!this._shouldViewBeAlive.read(t))return;const i=o.h("div.editorPlaceholder");t.store.add(o.autorun(n=>{const s=this._state.read(n),r=s?.placeholder!==void 0;i.root.style.display=r?"block":"none",i.root.innerText=s?.placeholder??""})),t.store.add(o.autorun(n=>{const s=this._editorObs.layoutInfo.read(n);i.root.style.left=`${s.contentLeft}px`,i.root.style.width=s.contentWidth-s.verticalScrollbarWidth+"px",i.root.style.top=`${this._editor.getTopForLineNumber(0)}px`})),t.store.add(o.autorun(n=>{i.root.style.fontFamily=this._editorObs.getOption(58).read(n),i.root.style.fontSize=this._editorObs.getOption(61).read(n)+"px",i.root.style.lineHeight=this._editorObs.getOption(75).read(n)+"px"})),t.store.add(this._editorObs.createOverlayWidget({allowEditorOverflow:!1,minContentWidthInPx:o.constObservable(0),position:o.constObservable(null),domNode:i.root}))}),this._view.recomputeInitiallyAndOnChange(this._store)}};bf.ID="editor.contrib.placeholderText";let nc=bf;function A0(c,e){return o.derivedObservableWithCache(c,(t,i)=>i===!0?!0:e(t))}var F0=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},z0=function(c,e){return function(t,i){e(t,i,c)}};class V0{constructor(e){this.instantiationService=e}init(...e){}}function B0(c){return c()}let Ob=class extends V0{constructor(e,t){super(t),this.init(e)}};Ob=F0([z0(1,o.IInstantiationService)],Ob),o.registerEditorContribution(nc.ID,B0(()=>nc),0),o.registerColor("editor.placeholder.foreground",o.ghostTextForeground,a.localize(1400,"Foreground color of the placeholder text in the editor."));var K0=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Ab=function(c,e){return function(t,i){e(t,i,c)}};let sc=(co=class extends a.Disposable{constructor(e,t,i){super(),this.editor=e,this.languageConfigurationService=t,this.editorWorkerService=i,this.decorations=this.editor.createDecorationsCollection(),this.options=this.createOptions(e.getOption(81)),this.computePromise=null,this.currentOccurrences={},this._register(e.onDidChangeModel(n=>{this.currentOccurrences={},this.options=this.createOptions(e.getOption(81)),this.stop(),this.computeSectionHeaders.schedule(0)})),this._register(e.onDidChangeModelLanguage(n=>{this.currentOccurrences={},this.options=this.createOptions(e.getOption(81)),this.stop(),this.computeSectionHeaders.schedule(0)})),this._register(t.onDidChange(n=>{const s=this.editor.getModel()?.getLanguageId();s&&n.affects(s)&&(this.currentOccurrences={},this.options=this.createOptions(e.getOption(81)),this.stop(),this.computeSectionHeaders.schedule(0))})),this._register(e.onDidChangeConfiguration(n=>{this.options&&!n.hasChanged(81)||(this.options=this.createOptions(e.getOption(81)),this.updateDecorations([]),this.stop(),this.computeSectionHeaders.schedule(0))})),this._register(this.editor.onDidChangeModelContent(n=>{this.computeSectionHeaders.schedule()})),this._register(e.onDidChangeModelTokens(n=>{this.computeSectionHeaders.isScheduled()||this.computeSectionHeaders.schedule(1e3)})),this.computeSectionHeaders=this._register(new a.RunOnceScheduler(()=>{this.findSectionHeaders()},250)),this.computeSectionHeaders.schedule(0)}createOptions(e){if(!e||!this.editor.hasModel())return;const t=this.editor.getModel().getLanguageId();if(!t)return;const i=this.languageConfigurationService.getLanguageConfiguration(t).comments,n=this.languageConfigurationService.getLanguageConfiguration(t).foldingRules;if(!(!i&&!n?.markers))return{foldingRules:n,markSectionHeaderRegex:e.markSectionHeaderRegex,findMarkSectionHeaders:e.showMarkSectionHeaders,findRegionSectionHeaders:e.showRegionSectionHeaders}}findSectionHeaders(){if(!this.editor.hasModel()||!this.options?.findMarkSectionHeaders&&!this.options?.findRegionSectionHeaders)return;const e=this.editor.getModel();if(e.isDisposed()||e.isTooLargeForSyncing())return;const t=e.getVersionId();this.editorWorkerService.findSectionHeaders(e.uri,this.options).then(i=>{e.isDisposed()||e.getVersionId()!==t||this.updateDecorations(i)})}updateDecorations(e){const t=this.editor.getModel();t&&(e=e.filter(s=>{if(!s.shouldBeInComments)return!0;const r=t.validateRange(s.range),l=t.tokenization.getLineTokens(r.startLineNumber),d=l.findTokenIndexAtOffset(r.startColumn-1),h=l.getStandardTokenType(d),u=t.getLanguageIdAtPosition(r.startLineNumber,r.startColumn);return l.getLanguageId(d)===u&&h===1}));const i=Object.values(this.currentOccurrences).map(s=>s.decorationId),n=e.map(s=>k0(s));this.editor.changeDecorations(s=>{const r=s.deltaDecorations(i,n);this.currentOccurrences={};for(let l=0,d=r.length;l<d;l++){const h={sectionHeader:e[l],decorationId:r[l]};this.currentOccurrences[h.decorationId]=h}})}stop(){this.computeSectionHeaders.cancel(),this.computePromise&&(this.computePromise.cancel(),this.computePromise=null)}dispose(){super.dispose(),this.stop(),this.decorations.clear()}},co.ID="editor.sectionHeaderDetector",co);sc=K0([Ab(1,o.ILanguageConfigurationService),Ab(2,o.IEditorWorkerService)],sc);function k0(c){return{range:c.range,options:o.ModelDecorationOptions.createDynamic({description:"section-header",stickiness:3,collapseOnReplaceEdit:!0,minimap:{color:void 0,position:1,sectionHeaderStyle:c.hasSeparatorLine?2:1,sectionHeaderText:c.text}})}}o.registerEditorContribution(sc.ID,sc,1);function U0(c){for(let e=0,t=c.length;e<t;e+=4){const i=c[e+0],n=c[e+1],s=c[e+2],r=c[e+3];c[e+0]=r,c[e+1]=s,c[e+2]=n,c[e+3]=i}}function $0(c){const e=new Uint8Array(c.buffer,c.byteOffset,c.length*4);return a.isLittleEndian()||U0(e),a.VSBuffer.wrap(e)}function Fb(c){const e=new Uint32Array(j0(c));let t=0;if(e[t++]=c.id,c.type==="full")e[t++]=1,e[t++]=c.data.length,e.set(c.data,t),t+=c.data.length;else{e[t++]=2,e[t++]=c.deltas.length;for(const i of c.deltas)e[t++]=i.start,e[t++]=i.deleteCount,i.data?(e[t++]=i.data.length,e.set(i.data,t),t+=i.data.length):e[t++]=0}return $0(e)}function j0(c){let e=0;if(e+=2,c.type==="full")e+=1+c.data.length;else{e+=1,e+=3*c.deltas.length;for(const t of c.deltas)t.data&&(e+=t.data.length)}return e}function oc(c){return c&&!!c.data}function zb(c){return c&&Array.isArray(c.edits)}class q0{constructor(e,t,i){this.provider=e,this.tokens=t,this.error=i}}function Vb(c,e){return c.has(e)}function G0(c,e){const t=c.orderedGroups(e);return t.length>0?t[0]:[]}async function Bb(c,e,t,i,n){const s=G0(c,e),r=await Promise.all(s.map(async l=>{let d,h=null;try{d=await l.provideDocumentSemanticTokens(e,l===t?i:null,n)}catch(u){h=u,d=null}return(!d||!oc(d)&&!zb(d))&&(d=null),new q0(l,d,h)}));for(const l of r){if(l.error)throw l.error;if(l.tokens)return l}return r.length>0?r[0]:null}function Z0(c,e){const t=c.orderedGroups(e);return t.length>0?t[0]:null}class X0{constructor(e,t){this.provider=e,this.tokens=t}}function Y0(c,e){return c.has(e)}function Kb(c,e){const t=c.orderedGroups(e);return t.length>0?t[0]:[]}async function Ep(c,e,t,i){const n=Kb(c,e),s=await Promise.all(n.map(async r=>{let l;try{l=await r.provideDocumentRangeSemanticTokens(e,t,i)}catch(d){a.onUnexpectedExternalError(d),l=null}return(!l||!oc(l))&&(l=null),new X0(r,l)}));for(const r of s)if(r.tokens)return r;return s.length>0?s[0]:null}o.CommandsRegistry.registerCommand("_provideDocumentSemanticTokensLegend",async(c,...e)=>{const[t]=e;a.assertType(t instanceof a.URI);const i=c.get(o.IModelService).getModel(t);if(!i)return;const{documentSemanticTokensProvider:n}=c.get(o.ILanguageFeaturesService),s=Z0(n,i);return s?s[0].getLegend():c.get(o.ICommandService).executeCommand("_provideDocumentRangeSemanticTokensLegend",t)}),o.CommandsRegistry.registerCommand("_provideDocumentSemanticTokens",async(c,...e)=>{const[t]=e;a.assertType(t instanceof a.URI);const i=c.get(o.IModelService).getModel(t);if(!i)return;const{documentSemanticTokensProvider:n}=c.get(o.ILanguageFeaturesService);if(!Vb(n,i))return c.get(o.ICommandService).executeCommand("_provideDocumentRangeSemanticTokens",t,i.getFullModelRange());const s=await Bb(n,i,null,null,a.CancellationToken.None);if(!s)return;const{provider:r,tokens:l}=s;if(!l||!oc(l))return;const d=Fb({id:0,type:"full",data:l.data});return l.resultId&&r.releaseDocumentSemanticTokens(l.resultId),d}),o.CommandsRegistry.registerCommand("_provideDocumentRangeSemanticTokensLegend",async(c,...e)=>{const[t,i]=e;a.assertType(t instanceof a.URI);const n=c.get(o.IModelService).getModel(t);if(!n)return;const{documentRangeSemanticTokensProvider:s}=c.get(o.ILanguageFeaturesService),r=Kb(s,n);if(r.length===0)return;if(r.length===1)return r[0].getLegend();if(!i||!a.Range.isIRange(i))return console.warn("provideDocumentRangeSemanticTokensLegend might be out-of-sync with provideDocumentRangeSemanticTokens unless a range argument is passed in"),r[0].getLegend();const l=await Ep(s,n,a.Range.lift(i),a.CancellationToken.None);if(l)return l.provider.getLegend()}),o.CommandsRegistry.registerCommand("_provideDocumentRangeSemanticTokens",async(c,...e)=>{const[t,i]=e;a.assertType(t instanceof a.URI),a.assertType(a.Range.isIRange(i));const n=c.get(o.IModelService).getModel(t);if(!n)return;const{documentRangeSemanticTokensProvider:s}=c.get(o.ILanguageFeaturesService),r=await Ep(s,n,a.Range.lift(i),a.CancellationToken.None);if(!(!r||!r.tokens))return Fb({id:0,type:"full",data:r.tokens.data})});const Lp="editor.semanticHighlighting";function rc(c,e,t){const i=t.getValue(Lp,{overrideIdentifier:c.getLanguageId(),resource:c.uri})?.enabled;return typeof i=="boolean"?i:e.getColorTheme().semanticHighlighting}var kb=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},gt=function(c,e){return function(t,i){e(t,i,c)}},li;let Dp=class extends a.Disposable{constructor(e,t,i,n,s,r){super(),this._watchers=new a.ResourceMap,this._providerChangeListeners=this._register(new a.DisposableStore);const l=r.documentSemanticTokensProvider,d=p=>{this._watchers.get(p.uri)?.dispose(),this._watchers.set(p.uri,new Rp(p,e,i,s,r))},h=(p,f)=>{f.dispose(),this._watchers.delete(p.uri)},u=()=>{for(const p of t.getModels()){const f=this._watchers.get(p.uri);rc(p,i,n)?f||d(p):f&&h(p,f)}},g=()=>{this._providerChangeListeners.clear();for(const p of l.allNoModel())typeof p.onDidChange=="function"&&this._providerChangeListeners.add(p.onDidChange(()=>{for(const f of this._watchers.values())f.handleProviderDidChange(p)}))};t.getModels().forEach(p=>{rc(p,i,n)&&d(p)}),this._register(t.onModelAdded(p=>{rc(p,i,n)&&d(p)})),this._register(t.onModelRemoved(p=>{const f=this._watchers.get(p.uri);f&&h(p,f)})),this._register(n.onDidChangeConfiguration(p=>{p.affectsConfiguration(Lp)&&u()})),this._register(i.onDidColorThemeChange(u)),g(),this._register(l.onDidChange(()=>{g();for(const p of this._watchers.values())p.handleRegistryChange()}))}dispose(){a.dispose(this._watchers.values()),this._watchers.clear(),super.dispose()}};Dp=kb([gt(0,o.ISemanticTokensStylingService),gt(1,o.IModelService),gt(2,o.IThemeService),gt(3,o.IConfigurationService),gt(4,o.ILanguageFeatureDebounceService),gt(5,o.ILanguageFeaturesService)],Dp);let Rp=(Pi=class extends a.Disposable{constructor(e,t,i,n,s){super(),this._semanticTokensStylingService=t,this._relevantProviders=new Set,this._isDisposed=!1,this._model=e,this._provider=s.documentSemanticTokensProvider,this._debounceInformation=n.for(this._provider,"DocumentSemanticTokens",{min:li.REQUEST_MIN_DELAY,max:li.REQUEST_MAX_DELAY}),this._fetchDocumentSemanticTokens=this._register(new a.RunOnceScheduler(()=>this._fetchDocumentSemanticTokensNow(),li.REQUEST_MIN_DELAY)),this._currentDocumentResponse=null,this._currentDocumentRequestCancellationTokenSource=null,this._providersChangedDuringRequest=!1,this._updateRelevantProviders(),this._register(this._model.onDidChangeContent(()=>{this._fetchDocumentSemanticTokens.isScheduled()||this._fetchDocumentSemanticTokens.schedule(this._debounceInformation.get(this._model))})),this._register(this._model.onDidChangeAttached(()=>{this._fetchDocumentSemanticTokens.isScheduled()||this._fetchDocumentSemanticTokens.schedule(this._debounceInformation.get(this._model))})),this._register(this._model.onDidChangeLanguage(()=>{this._currentDocumentResponse&&(this._currentDocumentResponse.dispose(),this._currentDocumentResponse=null),this._currentDocumentRequestCancellationTokenSource&&(this._currentDocumentRequestCancellationTokenSource.cancel(),this._currentDocumentRequestCancellationTokenSource=null),this._setDocumentSemanticTokens(null,null,null,[]),this._updateRelevantProviders(),this._fetchDocumentSemanticTokens.schedule(0)})),this._register(i.onDidColorThemeChange(r=>{this._setDocumentSemanticTokens(null,null,null,[]),this._fetchDocumentSemanticTokens.schedule(this._debounceInformation.get(this._model))})),this._fetchDocumentSemanticTokens.schedule(0)}handleRegistryChange(){this._updateRelevantProviders(),this._fetchDocumentSemanticTokens.schedule(this._debounceInformation.get(this._model))}handleProviderDidChange(e){if(this._relevantProviders.has(e)){if(this._currentDocumentRequestCancellationTokenSource){this._providersChangedDuringRequest=!0;return}this._fetchDocumentSemanticTokens.schedule(0)}}_updateRelevantProviders(){this._relevantProviders=new Set(this._provider.all(this._model))}dispose(){this._currentDocumentResponse&&(this._currentDocumentResponse.dispose(),this._currentDocumentResponse=null),this._currentDocumentRequestCancellationTokenSource&&(this._currentDocumentRequestCancellationTokenSource.cancel(),this._currentDocumentRequestCancellationTokenSource=null),this._setDocumentSemanticTokens(null,null,null,[]),this._isDisposed=!0,super.dispose()}_fetchDocumentSemanticTokensNow(){if(this._currentDocumentRequestCancellationTokenSource)return;if(!Vb(this._provider,this._model)){this._currentDocumentResponse&&this._model.tokenization.setSemanticTokens(null,!1);return}if(!this._model.isAttachedToEditor())return;const e=new a.CancellationTokenSource,t=this._currentDocumentResponse?this._currentDocumentResponse.provider:null,i=this._currentDocumentResponse&&this._currentDocumentResponse.resultId||null,n=Bb(this._provider,this._model,t,i,e.token);this._currentDocumentRequestCancellationTokenSource=e,this._providersChangedDuringRequest=!1;const s=[],r=this._model.onDidChangeContent(d=>{s.push(d)}),l=new a.StopWatch(!1);n.then(d=>{if(this._debounceInformation.update(this._model,l.elapsed()),this._currentDocumentRequestCancellationTokenSource=null,r.dispose(),!d)this._setDocumentSemanticTokens(null,null,null,s);else{const{provider:h,tokens:u}=d,g=this._semanticTokensStylingService.getStyling(h);this._setDocumentSemanticTokens(h,u||null,g,s)}},d=>{d&&(a.isCancellationError(d)||typeof d.message=="string"&&d.message.indexOf("busy")!==-1)||a.onUnexpectedError(d),this._currentDocumentRequestCancellationTokenSource=null,r.dispose(),(s.length>0||this._providersChangedDuringRequest)&&(this._fetchDocumentSemanticTokens.isScheduled()||this._fetchDocumentSemanticTokens.schedule(this._debounceInformation.get(this._model)))})}static _copy(e,t,i,n,s){s=Math.min(s,i.length-n,e.length-t);for(let r=0;r<s;r++)i[n+r]=e[t+r]}_setDocumentSemanticTokens(e,t,i,n){const s=this._currentDocumentResponse,r=()=>{(n.length>0||this._providersChangedDuringRequest)&&!this._fetchDocumentSemanticTokens.isScheduled()&&this._fetchDocumentSemanticTokens.schedule(this._debounceInformation.get(this._model))};if(this._currentDocumentResponse&&(this._currentDocumentResponse.dispose(),this._currentDocumentResponse=null),this._isDisposed){e&&t&&e.releaseDocumentSemanticTokens(t.resultId);return}if(!e||!i){this._model.tokenization.setSemanticTokens(null,!1);return}if(!t){this._model.tokenization.setSemanticTokens(null,!0),r();return}if(zb(t)){const l=t.resultId,d=h=>{e.releaseDocumentSemanticTokens(l),this._model.tokenization.setSemanticTokens(null,!0),h&&this._fetchDocumentSemanticTokens.schedule(0)};if(!s){d(!1);return}if(t.edits.length===0)t={resultId:t.resultId,data:s.data};else{let h=0;for(const _ of t.edits)h+=(_.data?_.data.length:0)-_.deleteCount;const u=s.data,g=u.length+h;if(g<0){i.warnInvalidEditDeleteCount(s.resultId,l,u.length,h),d(!0);return}const p=new Uint32Array(g);let f=u.length,m=p.length;for(let _=t.edits.length-1;_>=0;_--){const v=t.edits[_];if(v.start>u.length){i.warnInvalidEditStart(s.resultId,l,_,v.start,u.length),d(!0);return}const b=f-(v.start+v.deleteCount);b>0&&(li._copy(u,f-b,p,m-b,b),m-=b),v.data&&(li._copy(v.data,0,p,m-v.data.length,v.data.length),m-=v.data.length),f=v.start}f>0&&li._copy(u,0,p,0,f),t={resultId:t.resultId,data:p}}}if(oc(t)){this._currentDocumentResponse=new Q0(e,t.resultId,t.data);const l=o.toMultilineTokens2(t,i,this._model.getLanguageId());if(n.length>0)for(const d of n)for(const h of l)for(const u of d.changes)h.applyEdit(u.range,u.text);this._model.tokenization.setSemanticTokens(l,!0)}else this._model.tokenization.setSemanticTokens(null,!0);r()}},li=Pi,Pi.REQUEST_MIN_DELAY=300,Pi.REQUEST_MAX_DELAY=2e3,Pi);Rp=li=kb([gt(1,o.ISemanticTokensStylingService),gt(2,o.IThemeService),gt(3,o.ILanguageFeatureDebounceService),gt(4,o.ILanguageFeaturesService)],Rp);class Q0{constructor(e,t,i){this.provider=e,this.resultId=t,this.data=i}dispose(){this.provider.releaseDocumentSemanticTokens(this.resultId)}}o.registerEditorFeature(Dp);var J0=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Or=function(c,e){return function(t,i){e(t,i,c)}};let ac=(ho=class extends a.Disposable{constructor(e,t,i,n,s,r){super(),this._semanticTokensStylingService=t,this._themeService=i,this._configurationService=n,this._editor=e,this._provider=r.documentRangeSemanticTokensProvider,this._debounceInformation=s.for(this._provider,"DocumentRangeSemanticTokens",{min:100,max:500}),this._tokenizeViewport=this._register(new a.RunOnceScheduler(()=>this._tokenizeViewportNow(),100)),this._outstandingRequests=[],this._rangeProvidersChangeListeners=[];const l=()=>{this._editor.hasModel()&&this._tokenizeViewport.schedule(this._debounceInformation.get(this._editor.getModel()))},d=()=>{if(this._cleanupProviderListeners(),this._editor.hasModel()){const h=this._editor.getModel();for(const u of this._provider.all(h)){const g=u.onDidChange?.(()=>{this._cancelAll(),l()});g&&this._rangeProvidersChangeListeners.push(g)}}};this._register(this._editor.onDidScrollChange(()=>{l()})),this._register(this._editor.onDidChangeModel(()=>{d(),this._cancelAll(),l()})),this._register(this._editor.onDidChangeModelLanguage(()=>{d(),this._cancelAll(),l()})),this._register(this._editor.onDidChangeModelContent(h=>{this._cancelAll(),l()})),d(),this._register(this._provider.onDidChange(()=>{d(),this._cancelAll(),l()})),this._register(this._configurationService.onDidChangeConfiguration(h=>{h.affectsConfiguration(Lp)&&(this._cancelAll(),l())})),this._register(this._themeService.onDidColorThemeChange(()=>{this._cancelAll(),l()})),l()}dispose(){this._cleanupProviderListeners(),super.dispose()}_cleanupProviderListeners(){a.dispose(this._rangeProvidersChangeListeners),this._rangeProvidersChangeListeners=[]}_cancelAll(){for(const e of this._outstandingRequests)e.cancel();this._outstandingRequests=[]}_removeOutstandingRequest(e){for(let t=0,i=this._outstandingRequests.length;t<i;t++)if(this._outstandingRequests[t]===e){this._outstandingRequests.splice(t,1);return}}_tokenizeViewportNow(){if(!this._editor.hasModel())return;const e=this._editor.getModel();if(e.tokenization.hasCompleteSemanticTokens())return;if(!rc(e,this._themeService,this._configurationService)){e.tokenization.hasSomeSemanticTokens()&&e.tokenization.setSemanticTokens(null,!1);return}if(!Y0(this._provider,e)){e.tokenization.hasSomeSemanticTokens()&&e.tokenization.setSemanticTokens(null,!1);return}const t=this._editor.getVisibleRangesPlusViewportAboveBelow();this._outstandingRequests=this._outstandingRequests.concat(t.map(i=>this._requestRange(e,i)))}_requestRange(e,t){const i=e.getVersionId(),n=a.createCancelablePromise(r=>Promise.resolve(Ep(this._provider,e,t,r))),s=new a.StopWatch(!1);return n.then(r=>{if(this._debounceInformation.update(e,s.elapsed()),!r||!r.tokens||e.isDisposed()||e.getVersionId()!==i)return;const{provider:l,tokens:d}=r,h=this._semanticTokensStylingService.getStyling(l);e.tokenization.setPartialSemanticTokens(t,o.toMultilineTokens2(d,h,e.getLanguageId()))}).then(()=>this._removeOutstandingRequest(n),()=>this._removeOutstandingRequest(n)),n}},ho.ID="editor.contrib.viewportSemanticTokens",ho);ac=J0([Or(1,o.ISemanticTokensStylingService),Or(2,o.IThemeService),Or(3,o.IConfigurationService),Or(4,o.ILanguageFeatureDebounceService),Or(5,o.ILanguageFeaturesService)],ac),o.registerEditorContribution(ac.ID,ac,1);class W0{constructor(e=!0){this.selectSubwords=e}provideSelectionRanges(e,t){const i=[];for(const n of t){const s=[];i.push(s),this.selectSubwords&&this._addInWordRanges(s,e,n),this._addWordRanges(s,e,n),this._addWhitespaceLine(s,e,n),s.push({range:e.getFullModelRange()})}return i}_addInWordRanges(e,t,i){const n=t.getWordAtPosition(i);if(!n)return;const{word:s,startColumn:r}=n,l=i.column-r;let d=l,h=l,u=0;for(;d>=0;d--){const g=s.charCodeAt(d);if(d!==l&&(g===95||g===45))break;if(a.isLowerAsciiLetter(g)&&a.isUpperAsciiLetter(u))break;u=g}for(d+=1;h<s.length;h++){const g=s.charCodeAt(h);if(a.isUpperAsciiLetter(g)&&a.isLowerAsciiLetter(u))break;if(g===95||g===45)break;u=g}d<h&&e.push({range:new a.Range(i.lineNumber,r+d,i.lineNumber,r+h)})}_addWordRanges(e,t,i){const n=t.getWordAtPosition(i);n&&e.push({range:new a.Range(i.lineNumber,n.startColumn,i.lineNumber,n.endColumn)})}_addWhitespaceLine(e,t,i){t.getLineLength(i.lineNumber)>0&&t.getLineFirstNonWhitespaceColumn(i.lineNumber)===0&&t.getLineLastNonWhitespaceColumn(i.lineNumber)===0&&e.push({range:new a.Range(i.lineNumber,1,i.lineNumber,t.getLineMaxColumn(i.lineNumber))})}}var H0=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},e1=function(c,e){return function(t,i){e(t,i,c)}},Tp;class Np{constructor(e,t){this.index=e,this.ranges=t}mov(e){const t=this.index+(e?1:-1);if(t<0||t>=this.ranges.length)return this;const i=new Np(t,this.ranges);return i.ranges[t].equalsRange(this.ranges[this.index])?i.mov(e):i}}let Ar=(es=class{static get(e){return e.getContribution(Tp.ID)}constructor(e,t){this._editor=e,this._languageFeaturesService=t,this._ignoreSelection=!1}dispose(){this._selectionListener?.dispose()}async run(e){if(!this._editor.hasModel())return;const t=this._editor.getSelections(),i=this._editor.getModel();if(this._state||await $b(this._languageFeaturesService.selectionRangeProvider,i,t.map(s=>s.getPosition()),this._editor.getOption(129),a.CancellationToken.None).then(s=>{if(!(!a.isNonEmptyArray(s)||s.length!==t.length)&&!(!this._editor.hasModel()||!a.equals(this._editor.getSelections(),t,(r,l)=>r.equalsSelection(l)))){for(let r=0;r<s.length;r++)s[r]=s[r].filter(l=>l.containsPosition(t[r].getStartPosition())&&l.containsPosition(t[r].getEndPosition())),s[r].unshift(t[r]);this._state=s.map(r=>new Np(0,r)),this._selectionListener?.dispose(),this._selectionListener=this._editor.onDidChangeCursorPosition(()=>{this._ignoreSelection||(this._selectionListener?.dispose(),this._state=void 0)})}}),!this._state)return;this._state=this._state.map(s=>s.mov(e));const n=this._state.map(s=>a.Selection.fromPositions(s.ranges[s.index].getStartPosition(),s.ranges[s.index].getEndPosition()));this._ignoreSelection=!0;try{this._editor.setSelections(n)}finally{this._ignoreSelection=!1}}},Tp=es,es.ID="editor.contrib.smartSelectController",es);Ar=Tp=H0([e1(1,o.ILanguageFeaturesService)],Ar);class Ub extends o.EditorAction{constructor(e,t){super(t),this._forward=e}async run(e,t){const i=Ar.get(t);i&&await i.run(this._forward)}}class t1 extends Ub{constructor(){super(!0,{id:"editor.action.smartSelect.expand",label:a.localize2(1469,"Expand Selection"),precondition:void 0,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:1553,mac:{primary:3345,secondary:[1297]},weight:100},menuOpts:{menuId:o.MenuId.MenubarSelectionMenu,group:"1_basic",title:a.localize(1467,"&&Expand Selection"),order:2}})}}o.CommandsRegistry.registerCommandAlias("editor.action.smartSelect.grow","editor.action.smartSelect.expand");class i1 extends Ub{constructor(){super(!1,{id:"editor.action.smartSelect.shrink",label:a.localize2(1470,"Shrink Selection"),precondition:void 0,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:1551,mac:{primary:3343,secondary:[1295]},weight:100},menuOpts:{menuId:o.MenuId.MenubarSelectionMenu,group:"1_basic",title:a.localize(1468,"&&Shrink Selection"),order:3}})}}o.registerEditorContribution(Ar.ID,Ar,4),o.registerEditorAction(t1),o.registerEditorAction(i1);async function $b(c,e,t,i,n){const s=c.all(e).concat(new W0(i.selectSubwords));s.length===1&&s.unshift(new El);const r=[],l=[];for(const d of s)r.push(Promise.resolve(d.provideSelectionRanges(e,t,n)).then(h=>{if(a.isNonEmptyArray(h)&&h.length===t.length)for(let u=0;u<t.length;u++){l[u]||(l[u]=[]);for(const g of h[u])a.Range.isIRange(g.range)&&a.Range.containsPosition(g.range,t[u])&&l[u].push(a.Range.lift(g.range))}},a.onUnexpectedExternalError));return await Promise.all(r),l.map(d=>{if(d.length===0)return[];d.sort((p,f)=>a.Position.isBefore(p.getStartPosition(),f.getStartPosition())?1:a.Position.isBefore(f.getStartPosition(),p.getStartPosition())||a.Position.isBefore(p.getEndPosition(),f.getEndPosition())?-1:a.Position.isBefore(f.getEndPosition(),p.getEndPosition())?1:0);const h=[];let u;for(const p of d)(!u||a.Range.containsRange(p,u)&&!a.Range.equalsRange(p,u))&&(h.push(p),u=p);if(!i.selectLeadingAndTrailingWhitespace)return h;const g=[h[0]];for(let p=1;p<h.length;p++){const f=h[p-1],m=h[p];if(m.startLineNumber!==f.startLineNumber||m.endLineNumber!==f.endLineNumber){const _=new a.Range(f.startLineNumber,e.getLineFirstNonWhitespaceColumn(f.startLineNumber),f.endLineNumber,e.getLineLastNonWhitespaceColumn(f.endLineNumber));_.containsRange(f)&&!_.equalsRange(f)&&m.containsRange(_)&&!m.equalsRange(_)&&g.push(_);const v=new a.Range(f.startLineNumber,1,f.endLineNumber,e.getLineMaxColumn(f.endLineNumber));v.containsRange(f)&&!v.equalsRange(_)&&m.containsRange(v)&&!m.equalsRange(v)&&g.push(v)}g.push(m)}return g})}o.CommandsRegistry.registerCommand("_executeSelectionRangeProvider",async function(c,...e){const[t,i]=e;a.assertType(a.URI.isUri(t)),a.assertType(a.isArrayOf(i,r=>a.Position.isIPosition(r)));const n=c.get(o.ILanguageFeaturesService).selectionRangeProvider,s=await c.get(o.ITextModelService).createModelReference(t);try{return $b(n,s.object.textEditorModel,i.map(a.Position.lift),{selectLeadingAndTrailingWhitespace:!0,selectSubwords:!0},a.CancellationToken.None)}finally{s.dispose()}});const Mp=Object.freeze({View:a.localize2(1718,"View"),Help:a.localize2(1719,"Help"),Test:a.localize2(1720,"Test"),File:a.localize2(1721,"File"),Preferences:a.localize2(1722,"Preferences"),Developer:a.localize2(1723,"Developer")});class n1 extends o.EditorAction2{constructor(){super({id:"editor.action.toggleStickyScroll",title:{...a.localize2(1518,"Toggle Editor Sticky Scroll"),mnemonicTitle:a.localize(1514,"&&Toggle Editor Sticky Scroll")},metadata:{description:a.localize2(1519,"Toggle/enable the editor sticky scroll which shows the nested scopes at the top of the viewport")},category:Mp.View,toggled:{condition:o.ContextKeyExpr.equals("config.editor.stickyScroll.enabled",!0),title:a.localize(1515,"Sticky Scroll"),mnemonicTitle:a.localize(1516,"&&Sticky Scroll")},menu:[{id:o.MenuId.CommandPalette},{id:o.MenuId.MenubarAppearanceMenu,group:"4_editor",order:3},{id:o.MenuId.StickyScrollContext}]})}async runEditorCommand(e,t){const i=e.get(o.IConfigurationService),n=!i.getValue("editor.stickyScroll.enabled"),s=Be.get(t)?.isFocused();i.updateValue("editor.stickyScroll.enabled",n),s&&t.focus()}}const lc=100;class s1 extends o.EditorAction2{constructor(){super({id:"editor.action.focusStickyScroll",title:{...a.localize2(1520,"Focus Editor Sticky Scroll"),mnemonicTitle:a.localize(1517,"&&Focus Editor Sticky Scroll")},precondition:o.ContextKeyExpr.and(o.ContextKeyExpr.has("config.editor.stickyScroll.enabled"),o.EditorContextKeys.stickyScrollVisible),menu:[{id:o.MenuId.CommandPalette}]})}runEditorCommand(e,t){Be.get(t)?.focus()}}class o1 extends o.EditorAction2{constructor(){super({id:"editor.action.selectNextStickyScrollLine",title:a.localize2(1521,"Select the next editor sticky scroll line"),precondition:o.EditorContextKeys.stickyScrollFocused.isEqualTo(!0),keybinding:{weight:lc,primary:18}})}runEditorCommand(e,t){Be.get(t)?.focusNext()}}class r1 extends o.EditorAction2{constructor(){super({id:"editor.action.selectPreviousStickyScrollLine",title:a.localize2(1522,"Select the previous sticky scroll line"),precondition:o.EditorContextKeys.stickyScrollFocused.isEqualTo(!0),keybinding:{weight:lc,primary:16}})}runEditorCommand(e,t){Be.get(t)?.focusPrevious()}}class a1 extends o.EditorAction2{constructor(){super({id:"editor.action.goToFocusedStickyScrollLine",title:a.localize2(1523,"Go to the focused sticky scroll line"),precondition:o.EditorContextKeys.stickyScrollFocused.isEqualTo(!0),keybinding:{weight:lc,primary:3}})}runEditorCommand(e,t){Be.get(t)?.goToFocused()}}class l1 extends o.EditorAction2{constructor(){super({id:"editor.action.selectEditor",title:a.localize2(1524,"Select Editor"),precondition:o.EditorContextKeys.stickyScrollFocused.isEqualTo(!0),keybinding:{weight:lc,primary:9}})}runEditorCommand(e,t){Be.get(t)?.selectEditor()}}o.registerEditorContribution(Be.ID,Be,1),o.registerAction2(n1),o.registerAction2(s1),o.registerAction2(r1),o.registerAction2(o1),o.registerAction2(a1),o.registerAction2(l1);var jb=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Fr=function(c,e){return function(t,i){e(t,i,c)}};class c1{constructor(e,t,i,n,s,r,l){this.range=e,this.insertText=t,this.filterText=i,this.additionalTextEdits=n,this.command=s,this.gutterMenuLinkAction=r,this.completion=l,this.doNotLog=!0}}let Pp=class extends a.RefCountedDisposable{constructor(e,t,i,n,s,r){super(s.disposable),this.model=e,this.line=t,this.word=i,this.completionModel=n,this._suggestMemoryService=r}canBeReused(e,t,i){return this.model===e&&this.line===t&&this.word.word.length>0&&this.word.startColumn===i.startColumn&&this.word.endColumn<i.endColumn&&this.completionModel.getIncompleteProvider().size===0}get items(){const e=[],{items:t}=this.completionModel,i=this._suggestMemoryService.select(this.model,{lineNumber:this.line,column:this.word.endColumn+this.completionModel.lineContext.characterCountDelta},t),n=a.Iterable.slice(t,i),s=a.Iterable.slice(t,0,i);let r=5;for(const l of a.Iterable.concat(n,s)){if(l.score===o.FuzzyScore.Default)continue;const d=new a.Range(l.editStart.lineNumber,l.editStart.column,l.editInsertEnd.lineNumber,l.editInsertEnd.column+this.completionModel.lineContext.characterCountDelta),h=l.completion.insertTextRules&&l.completion.insertTextRules&4?{snippet:l.completion.insertText}:l.completion.insertText;e.push(new c1(d,h,l.filterTextLow??l.labelLow,l.completion.additionalTextEdits,l.completion.command,l.completion.action,l)),r-->=0&&l.resolve(a.CancellationToken.None)}return e}};Pp=jb([Fr(5,Il)],Pp);let Op=class extends a.Disposable{constructor(e,t,i,n){super(),this._languageFeatureService=e,this._clipboardService=t,this._suggestMemoryService=i,this._editorService=n,this._store.add(e.inlineCompletionsProvider.register("*",this))}async provideInlineCompletions(e,t,i,n){if(i.selectedSuggestionInfo)return;let s;for(const f of this._editorService.listCodeEditors())if(f.getModel()===e){s=f;break}if(!s)return;const r=s.getOption(102);if(Rs.isAllOff(r))return;e.tokenization.tokenizeIfCheap(t.lineNumber);const l=e.tokenization.getLineTokens(t.lineNumber),d=l.getStandardTokenType(l.findTokenIndexAtOffset(Math.max(t.column-1-1,0)));if(Rs.valueFor(r,d)!=="inline")return;let h=e.getWordAtPosition(t),u;if(h?.word||(u=this._getTriggerCharacterInfo(e,t)),!h?.word&&!u||(h||(h=e.getWordUntilPosition(t)),h.endColumn!==t.column))return;let g;const p=e.getValueInRange(new a.Range(t.lineNumber,1,t.lineNumber,t.column));if(!u&&this._lastResult?.canBeReused(e,t.lineNumber,h)){const f=new Fv(p,t.column-this._lastResult.word.endColumn);this._lastResult.completionModel.lineContext=f,this._lastResult.acquire(),g=this._lastResult}else{const f=await Iu(this._languageFeatureService.completionProvider,e,t,new Go(void 0,Dl.createSuggestFilter(s).itemKind,u?.providers),u&&{triggerKind:1,triggerCharacter:u.ch},n);let m;f.needsClipboard&&(m=await this._clipboardService.readText());const _=new Ht(f.items,t.column,new Fv(p,0),Ll.None,s.getOption(134),s.getOption(128),{boostFullMatch:!1,firstMatchCanBeWeak:!1},m);g=new Pp(e,t.lineNumber,h,_,f,this._suggestMemoryService)}return this._lastResult=g,g}handleItemDidShow(e,t){t.completion.resolve(a.CancellationToken.None)}disposeInlineCompletions(e){e.release()}_getTriggerCharacterInfo(e,t){const i=e.getValueInRange(a.Range.fromPositions({lineNumber:t.lineNumber,column:t.column-1},t)),n=new Set;for(const s of this._languageFeatureService.completionProvider.all(e))s.triggerCharacters?.includes(i)&&n.add(s);if(n.size!==0)return{providers:n,ch:i}}};Op=jb([Fr(0,o.ILanguageFeaturesService),Fr(1,o.IClipboardService),Fr(2,Il),Fr(3,o.ICodeEditorService)],Op),o.registerEditorFeature(Op);class d1 extends o.EditorAction{constructor(){super({id:"editor.action.forceRetokenize",label:a.localize2(1606,"Developer: Force Retokenize"),precondition:void 0})}run(e,t){if(!t.hasModel())return;const i=t.getModel();i.tokenization.resetTokenization();const n=new a.StopWatch;i.tokenization.forceTokenization(i.getLineCount()),n.stop(),console.log(`tokenization took ${n.elapsed()}`)}}o.registerEditorAction(d1);const sd=class sd extends o.Action2{constructor(){super({id:sd.ID,title:a.localize2(1604,"Toggle Tab Key Moves Focus"),precondition:void 0,keybinding:{primary:2091,mac:{primary:1323},weight:100},metadata:{description:a.localize2(1605,"Determines whether the tab key moves focus around the workbench or inserts the tab character in the current editor. This is also called tab trapping, tab navigation, or tab focus mode.")},f1:!0})}run(){const t=!o.TabFocus.getTabFocusMode();o.TabFocus.setTabFocusMode(t),t?o.alert(a.localize(1602,"Pressing Tab will now move focus to the next focusable element")):o.alert(a.localize(1603,"Pressing Tab will now insert the tab character"))}};sd.ID="editor.action.toggleTabFocusMode";let Ap=sd;o.registerAction2(Ap);var qb=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Fp=function(c,e){return function(t,i){e(t,i,c)}};const h1=26;let zp=class extends a.Disposable{constructor(e,t){super(),this._editor=e,this.instantiationService=t,this.banner=this._register(this.instantiationService.createInstance(Vp))}hide(){this._editor.setBanner(null,0),this.banner.clear()}show(e){this.banner.show({...e,onClose:()=>{this.hide(),e.onClose?.()}}),this._editor.setBanner(this.banner.element,h1)}};zp=qb([Fp(1,o.IInstantiationService)],zp);let Vp=class extends a.Disposable{constructor(e,t){super(),this.instantiationService=e,this.markdownRendererService=t,this.element=o.$("div.editor-banner"),this.element.tabIndex=0}getAriaLabel(e){if(e.ariaLabel)return e.ariaLabel;if(typeof e.message=="string")return e.message}getBannerMessage(e){if(typeof e=="string"){const t=o.$("span");return t.innerText=e,t}return this.markdownRendererService.render(e).element}clear(){o.clearNode(this.element)}show(e){o.clearNode(this.element);const t=this.getAriaLabel(e);t&&this.element.setAttribute("aria-label",t);const i=o.append(this.element,o.$("div.icon-container"));i.setAttribute("aria-hidden","true"),e.icon&&i.appendChild(o.$(`div${o.ThemeIcon.asCSSSelector(e.icon)}`));const n=o.append(this.element,o.$("div.message-container"));if(n.setAttribute("aria-hidden","true"),n.appendChild(this.getBannerMessage(e.message)),this.messageActionsContainer=o.append(this.element,o.$("div.message-actions-container")),e.actions)for(const r of e.actions)this._register(this.instantiationService.createInstance(ea,this.messageActionsContainer,{...r,tabIndex:-1},{}));const s=o.append(this.element,o.$("div.action-container"));this.actionBar=this._register(new o.ActionBar(s)),this.actionBar.push(this._register(new o.Action("banner.close",a.localize(1607,"Close Banner"),o.ThemeIcon.asClassName(o.widgetClose),!0,()=>{typeof e.onClose=="function"&&e.onClose()})),{icon:!0,label:!1}),this.actionBar.setFocusable(!1)}};Vp=qb([Fp(0,o.IInstantiationService),Fp(1,o.IMarkdownRendererService)],Vp);var Bp=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},zr=function(c,e){return function(t,i){e(t,i,c)}};const u1=o.registerIcon("extensions-warning-message",a.Codicon.warning,a.localize(1608,"Icon shown with a warning message in the extensions editor."));let Vr=(uo=class extends a.Disposable{constructor(e,t,i,n){super(),this._editor=e,this._editorWorkerService=t,this._workspaceTrustService=i,this._highlighter=null,this._bannerClosed=!1,this._updateState=s=>{if(s&&s.hasMore){if(this._bannerClosed)return;const r=Math.max(s.ambiguousCharacterCount,s.nonBasicAsciiCharacterCount,s.invisibleCharacterCount);let l;if(s.nonBasicAsciiCharacterCount>=r)l={message:a.localize(1609,"This document contains many non-basic ASCII unicode characters"),command:new Kr};else if(s.ambiguousCharacterCount>=r)l={message:a.localize(1610,"This document contains many ambiguous unicode characters"),command:new fn};else if(s.invisibleCharacterCount>=r)l={message:a.localize(1611,"This document contains many invisible unicode characters"),command:new Br};else throw new Error("Unreachable");this._bannerController.show({id:"unicodeHighlightBanner",message:l.message,icon:u1,actions:[{label:l.command.shortLabel,href:`command:${l.command.desc.id}`}],onClose:()=>{this._bannerClosed=!0}})}else this._bannerController.hide()},this._bannerController=this._register(n.createInstance(zp,e)),this._register(this._editor.onDidChangeModel(()=>{this._bannerClosed=!1,this._updateHighlighter()})),this._options=e.getOption(142),this._register(i.onDidChangeTrust(s=>{this._updateHighlighter()})),this._register(e.onDidChangeConfiguration(s=>{s.hasChanged(142)&&(this._options=e.getOption(142),this._updateHighlighter())})),this._updateHighlighter()}dispose(){this._highlighter&&(this._highlighter.dispose(),this._highlighter=null),super.dispose()}_updateHighlighter(){if(this._updateState(null),this._highlighter&&(this._highlighter.dispose(),this._highlighter=null),!this._editor.hasModel())return;const e=g1(this._workspaceTrustService.isWorkspaceTrusted(),this._options);if([e.nonBasicASCII,e.ambiguousCharacters,e.invisibleCharacters].every(i=>i===!1))return;const t={nonBasicASCII:e.nonBasicASCII,ambiguousCharacters:e.ambiguousCharacters,invisibleCharacters:e.invisibleCharacters,includeComments:e.includeComments,includeStrings:e.includeStrings,allowedCodePoints:Object.keys(e.allowedCharacters).map(i=>i.codePointAt(0)),allowedLocales:Object.keys(e.allowedLocales).map(i=>i==="_os"?a.safeIntl.NumberFormat().value.resolvedOptions().locale:i==="_vscode"?a.language:i)};this._editorWorkerService.canComputeUnicodeHighlights(this._editor.getModel().uri)?this._highlighter=new Kp(this._editor,t,this._updateState,this._editorWorkerService):this._highlighter=new p1(this._editor,t,this._updateState)}getDecorationInfo(e){return this._highlighter?this._highlighter.getDecorationInfo(e):null}},uo.ID="editor.contrib.unicodeHighlighter",uo);Vr=Bp([zr(1,o.IEditorWorkerService),zr(2,o.IWorkspaceTrustManagementService),zr(3,o.IInstantiationService)],Vr);function g1(c,e){return{nonBasicASCII:e.nonBasicASCII===o.inUntrustedWorkspace?!c:e.nonBasicASCII,ambiguousCharacters:e.ambiguousCharacters,invisibleCharacters:e.invisibleCharacters,includeComments:e.includeComments===o.inUntrustedWorkspace?!c:e.includeComments,includeStrings:e.includeStrings===o.inUntrustedWorkspace?!c:e.includeStrings,allowedCharacters:e.allowedCharacters,allowedLocales:e.allowedLocales}}let Kp=class extends a.Disposable{constructor(e,t,i,n){super(),this._editor=e,this._options=t,this._updateState=i,this._editorWorkerService=n,this._model=this._editor.getModel(),this._decorations=this._editor.createDecorationsCollection(),this._updateSoon=this._register(new a.RunOnceScheduler(()=>this._update(),250)),this._register(this._editor.onDidChangeModelContent(()=>{this._updateSoon.schedule()})),this._updateSoon.schedule()}dispose(){this._decorations.clear(),super.dispose()}_update(){if(this._model.isDisposed())return;if(!this._model.mightContainNonBasicASCII()){this._decorations.clear();return}const e=this._model.getVersionId();this._editorWorkerService.computedUnicodeHighlights(this._model.uri,this._options).then(t=>{if(this._model.isDisposed()||this._model.getVersionId()!==e)return;this._updateState(t);const i=[];if(!t.hasMore)for(const n of t.ranges)i.push({range:n,options:cc.instance.getDecorationFromOptions(this._options)});this._decorations.set(i)})}getDecorationInfo(e){if(!this._decorations.has(e))return null;const t=this._editor.getModel();if(!o.isModelDecorationVisible(t,e))return null;const i=t.getValueInRange(e.range);return{reason:Zb(i,this._options),inComment:o.isModelDecorationInComment(t,e),inString:o.isModelDecorationInString(t,e)}}};Kp=Bp([zr(3,o.IEditorWorkerService)],Kp);class p1 extends a.Disposable{constructor(e,t,i){super(),this._editor=e,this._options=t,this._updateState=i,this._model=this._editor.getModel(),this._decorations=this._editor.createDecorationsCollection(),this._updateSoon=this._register(new a.RunOnceScheduler(()=>this._update(),250)),this._register(this._editor.onDidLayoutChange(()=>{this._updateSoon.schedule()})),this._register(this._editor.onDidScrollChange(()=>{this._updateSoon.schedule()})),this._register(this._editor.onDidChangeHiddenAreas(()=>{this._updateSoon.schedule()})),this._register(this._editor.onDidChangeModelContent(()=>{this._updateSoon.schedule()})),this._updateSoon.schedule()}dispose(){this._decorations.clear(),super.dispose()}_update(){if(this._model.isDisposed())return;if(!this._model.mightContainNonBasicASCII()){this._decorations.clear();return}const e=this._editor.getVisibleRanges(),t=[],i={ranges:[],ambiguousCharacterCount:0,invisibleCharacterCount:0,nonBasicAsciiCharacterCount:0,hasMore:!1};for(const n of e){const s=a.UnicodeTextModelHighlighter.computeUnicodeHighlights(this._model,this._options,n);for(const r of s.ranges)i.ranges.push(r);i.ambiguousCharacterCount+=i.ambiguousCharacterCount,i.invisibleCharacterCount+=i.invisibleCharacterCount,i.nonBasicAsciiCharacterCount+=i.nonBasicAsciiCharacterCount,i.hasMore=i.hasMore||s.hasMore}if(!i.hasMore)for(const n of i.ranges)t.push({range:n,options:cc.instance.getDecorationFromOptions(this._options)});this._updateState(i),this._decorations.set(t)}getDecorationInfo(e){if(!this._decorations.has(e))return null;const t=this._editor.getModel(),i=t.getValueInRange(e.range);return o.isModelDecorationVisible(t,e)?{reason:Zb(i,this._options),inComment:o.isModelDecorationInComment(t,e),inString:o.isModelDecorationInString(t,e)}:null}}const Gb=a.localize(1612,"Configure Unicode Highlight Options");let kp=class{constructor(e,t){this._editor=e,this._markdownRendererService=t,this.hoverOrdinal=5}computeSync(e,t){if(!this._editor.hasModel()||e.type!==1)return[];const i=this._editor.getModel(),n=this._editor.getContribution(Vr.ID);if(!n)return[];const s=[],r=new Set;let l=300;for(const d of t){const h=n.getDecorationInfo(d);if(!h)continue;const g=i.getValueInRange(d.range).codePointAt(0),p=$p(g);let f;switch(h.reason.kind){case 0:{a.isBasicASCII(h.reason.confusableWith)?f=a.localize(1613,"The character {0} could be confused with the ASCII character {1}, which is more common in source code.",p,$p(h.reason.confusableWith.codePointAt(0))):f=a.localize(1614,"The character {0} could be confused with the character {1}, which is more common in source code.",p,$p(h.reason.confusableWith.codePointAt(0)));break}case 1:f=a.localize(1615,"The character {0} is invisible.",p);break;case 2:f=a.localize(1616,"The character {0} is not a basic ASCII character.",p);break}if(r.has(f))continue;r.add(f);const m={codePoint:g,reason:h.reason,inComment:h.inComment,inString:h.inString},_=a.localize(1617,"Adjust settings"),v=o.createCommandUri(dc.ID,m),b=new o.MarkdownString("",!0).appendMarkdown(f).appendText(" ").appendLink(v,_,Gb);s.push(new ze(this,d.range,[b],!1,l++))}return s}renderHoverParts(e,t){return Yy(e,t,this._editor,this._markdownRendererService)}getAccessibleContent(e){return e.contents.map(t=>t.value).join(`
65
+ `)}};kp=Bp([zr(1,o.IMarkdownRendererService)],kp);function Up(c){return`U+${c.toString(16).padStart(4,"0")}`}function $p(c){let e=`\`${Up(c)}\``;return a.InvisibleCharacters.isInvisibleCharacter(c)||(e+=` "${`${f1(c)}`}"`),e}function f1(c){return c===96?"`` ` ``":"`"+String.fromCodePoint(c)+"`"}function Zb(c,e){return a.UnicodeTextModelHighlighter.computeUnicodeHighlightReason(c,e)}const od=class od{constructor(){this.map=new Map}getDecorationFromOptions(e){return this.getDecoration(!e.includeComments,!e.includeStrings)}getDecoration(e,t){const i=`${e}${t}`;let n=this.map.get(i);return n||(n=o.ModelDecorationOptions.createDynamic({description:"unicode-highlight",stickiness:1,className:"unicode-highlight",showIfCollapsed:!0,overviewRuler:null,minimap:null,hideInCommentTokens:e,hideInStringTokens:t}),this.map.set(i,n)),n}};od.instance=new od;let cc=od;class m1 extends o.EditorAction{constructor(){super({id:fn.ID,label:a.localize2(1626,"Disable highlighting of characters in comments"),precondition:void 0}),this.shortLabel=a.localize(1618,"Disable Highlight In Comments")}async run(e,t){const i=e.get(o.IConfigurationService);i&&this.runAction(i)}async runAction(e){await e.updateValue(o.unicodeHighlightConfigKeys.includeComments,!1,2)}}class _1 extends o.EditorAction{constructor(){super({id:fn.ID,label:a.localize2(1627,"Disable highlighting of characters in strings"),precondition:void 0}),this.shortLabel=a.localize(1619,"Disable Highlight In Strings")}async run(e,t){const i=e.get(o.IConfigurationService);i&&this.runAction(i)}async runAction(e){await e.updateValue(o.unicodeHighlightConfigKeys.includeStrings,!1,2)}}const rd=class rd extends o.Action2{constructor(){super({id:rd.ID,title:a.localize2(1628,"Disable highlighting of ambiguous characters"),precondition:void 0,f1:!1}),this.shortLabel=a.localize(1620,"Disable Ambiguous Highlight")}async run(e,t){const i=e.get(o.IConfigurationService);i&&this.runAction(i)}async runAction(e){await e.updateValue(o.unicodeHighlightConfigKeys.ambiguousCharacters,!1,2)}};rd.ID="editor.action.unicodeHighlight.disableHighlightingOfAmbiguousCharacters";let fn=rd;const ad=class ad extends o.Action2{constructor(){super({id:ad.ID,title:a.localize2(1629,"Disable highlighting of invisible characters"),precondition:void 0,f1:!1}),this.shortLabel=a.localize(1621,"Disable Invisible Highlight")}async run(e,t){const i=e.get(o.IConfigurationService);i&&this.runAction(i)}async runAction(e){await e.updateValue(o.unicodeHighlightConfigKeys.invisibleCharacters,!1,2)}};ad.ID="editor.action.unicodeHighlight.disableHighlightingOfInvisibleCharacters";let Br=ad;const ld=class ld extends o.Action2{constructor(){super({id:ld.ID,title:a.localize2(1630,"Disable highlighting of non basic ASCII characters"),precondition:void 0,f1:!1}),this.shortLabel=a.localize(1622,"Disable Non ASCII Highlight")}async run(e,t){const i=e.get(o.IConfigurationService);i&&this.runAction(i)}async runAction(e){await e.updateValue(o.unicodeHighlightConfigKeys.nonBasicASCII,!1,2)}};ld.ID="editor.action.unicodeHighlight.disableHighlightingOfNonBasicAsciiCharacters";let Kr=ld;const cd=class cd extends o.Action2{constructor(){super({id:cd.ID,title:a.localize2(1631,"Show Exclude Options"),precondition:void 0,f1:!1})}async run(e,t){const{codePoint:i,reason:n,inString:s,inComment:r}=t,l=String.fromCodePoint(i),d=e.get(o.IQuickInputService),h=e.get(o.IConfigurationService);function u(m){return a.InvisibleCharacters.isInvisibleCharacter(m)?a.localize(1623,"Exclude {0} (invisible character) from being highlighted",Up(m)):a.localize(1624,"Exclude {0} from being highlighted",`${Up(m)} "${l}"`)}const g=[];if(n.kind===0)for(const m of n.notAmbiguousInLocales)g.push({label:a.localize(1625,'Allow unicode characters that are more common in the language "{0}".',m),run:async()=>{b1(h,[m])}});if(g.push({label:u(i),run:()=>v1(h,[i])}),r){const m=new m1;g.push({label:m.label,run:async()=>m.runAction(h)})}else if(s){const m=new _1;g.push({label:m.label,run:async()=>m.runAction(h)})}function p(m){return typeof m.desc.title=="string"?m.desc.title:m.desc.title.value}if(n.kind===0){const m=new fn;g.push({label:p(m),run:async()=>m.runAction(h)})}else if(n.kind===1){const m=new Br;g.push({label:p(m),run:async()=>m.runAction(h)})}else if(n.kind===2){const m=new Kr;g.push({label:p(m),run:async()=>m.runAction(h)})}else C1(n);const f=await d.pick(g,{title:Gb});f&&await f.run()}};cd.ID="editor.action.unicodeHighlight.showExcludeOptions";let dc=cd;async function v1(c,e){const t=c.getValue(o.unicodeHighlightConfigKeys.allowedCharacters);let i;typeof t=="object"&&t?i=t:i={};for(const n of e)i[String.fromCodePoint(n)]=!0;await c.updateValue(o.unicodeHighlightConfigKeys.allowedCharacters,i,2)}async function b1(c,e){const t=c.inspect(o.unicodeHighlightConfigKeys.allowedLocales).user?.value;let i;typeof t=="object"&&t?i=Object.assign({},t):i={};for(const n of e)i[n]=!0;await c.updateValue(o.unicodeHighlightConfigKeys.allowedLocales,i,2)}function C1(c){throw new Error(`Unexpected value: ${c}`)}o.registerAction2(fn),o.registerAction2(Br),o.registerAction2(Kr),o.registerAction2(dc),o.registerEditorContribution(Vr.ID,Vr,1),Xi.register(kp);var S1=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Xb=function(c,e){return function(t,i){e(t,i,c)}};const Yb="ignoreUnusualLineTerminators";function y1(c,e,t){c.setModelProperty(e.uri,Yb,t)}function w1(c,e){return c.getModelProperty(e.uri,Yb)}let hc=(go=class extends a.Disposable{constructor(e,t,i){super(),this._editor=e,this._dialogService=t,this._codeEditorService=i,this._isPresentingDialog=!1,this._config=this._editor.getOption(143),this._register(this._editor.onDidChangeConfiguration(n=>{n.hasChanged(143)&&(this._config=this._editor.getOption(143),this._checkForUnusualLineTerminators())})),this._register(this._editor.onDidChangeModel(()=>{this._checkForUnusualLineTerminators()})),this._register(this._editor.onDidChangeModelContent(n=>{n.isUndoing||this._checkForUnusualLineTerminators()})),this._checkForUnusualLineTerminators()}async _checkForUnusualLineTerminators(){if(this._config==="off"||!this._editor.hasModel())return;const e=this._editor.getModel();if(!e.mightContainUnusualLineTerminators()||w1(this._codeEditorService,e)===!0||this._editor.getOption(104))return;if(this._config==="auto"){e.removeUnusualLineTerminators(this._editor.getSelections());return}if(this._isPresentingDialog)return;let i;try{this._isPresentingDialog=!0,i=await this._dialogService.confirm({title:a.localize(1632,"Unusual Line Terminators"),message:a.localize(1633,"Detected unusual line terminators"),detail:a.localize(1634,"The file '{0}' contains one or more unusual line terminator characters, like Line Separator (LS) or Paragraph Separator (PS).\n\nIt is recommended to remove them from the file. This can be configured via `editor.unusualLineTerminators`.",o.basename(e.uri)),primaryButton:a.localize(1635,"&&Remove Unusual Line Terminators"),cancelButton:a.localize(1636,"Ignore")})}finally{this._isPresentingDialog=!1}if(!i.confirmed){y1(this._codeEditorService,e,!0);return}e.removeUnusualLineTerminators(this._editor.getSelections())}},go.ID="editor.contrib.unusualLineTerminatorsDetector",go);hc=S1([Xb(1,o.IDialogService),Xb(2,o.ICodeEditorService)],hc),o.registerEditorContribution(hc.ID,hc,1);var I1=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},x1=function(c,e){return function(t,i){e(t,i,c)}};class Qb{constructor(){this.selector={language:"*"}}provideDocumentHighlights(e,t,i){if(e.isDisposed())return;const n=[],s=e.getWordAtPosition({lineNumber:t.lineNumber,column:t.column});return s?e.findMatches(s.word,!0,!1,!0,a.USUAL_WORD_SEPARATORS,!1).map(l=>({range:l.range,kind:a.DocumentHighlightKind.Text})):Promise.resolve(n)}provideMultiDocumentHighlights(e,t,i,n){if(e.isDisposed())return;const s=new a.ResourceMap,r=e.getWordAtPosition({lineNumber:t.lineNumber,column:t.column});if(!r)return Promise.resolve(s);for(const l of[e,...i]){if(l.isDisposed())continue;const h=l.findMatches(r.word,!0,!1,!0,a.USUAL_WORD_SEPARATORS,!1).map(u=>({range:u.range,kind:a.DocumentHighlightKind.Text}));h&&s.set(l.uri,h)}return s}}let jp=class extends a.Disposable{constructor(e){super(),this._register(e.documentHighlightProvider.register("*",new Qb)),this._register(e.multiDocumentHighlightProvider.register("*",new Qb))}};jp=I1([x1(0,o.ILanguageFeaturesService)],jp);var Jb=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},pt=function(c,e){return function(t,i){e(t,i,c)}},X,qp;const Gp=new o.RawContextKey("hasWordHighlights",!1);function Wb(c,e,t,i){const n=c.ordered(e);return a.first(n.map(s=>()=>Promise.resolve(s.provideDocumentHighlights(e,t,i)).then(void 0,a.onUnexpectedExternalError)),s=>s!=null).then(s=>{if(s){const r=new a.ResourceMap;return r.set(e.uri,s),r}return new a.ResourceMap})}function E1(c,e,t,i,n){const s=c.ordered(e);return a.first(s.map(r=>()=>{const l=n.filter(d=>a.shouldSynchronizeModel(d)).filter(d=>o.score(r.selector,d.uri,d.getLanguageId(),!0,void 0,void 0)>0);return Promise.resolve(r.provideMultiDocumentHighlights(e,t,l,i)).then(void 0,a.onUnexpectedExternalError)}),r=>r!=null)}class Hb{constructor(e,t,i){this._model=e,this._selection=t,this._wordSeparators=i,this._wordRange=this._getCurrentWordRange(e,t),this._result=null}get result(){return this._result||(this._result=a.createCancelablePromise(e=>this._compute(this._model,this._selection,this._wordSeparators,e))),this._result}_getCurrentWordRange(e,t){const i=e.getWordAtPosition(t.getPosition());return i?new a.Range(t.startLineNumber,i.startColumn,t.startLineNumber,i.endColumn):null}cancel(){this.result.cancel()}}class L1 extends Hb{constructor(e,t,i,n){super(e,t,i),this._providers=n}_compute(e,t,i,n){return Wb(this._providers,e,t.getPosition(),n).then(s=>s||new a.ResourceMap)}}class D1 extends Hb{constructor(e,t,i,n,s){super(e,t,i),this._providers=n,this._otherModels=s}_compute(e,t,i,n){return E1(this._providers,e,t.getPosition(),n,this._otherModels).then(s=>s||new a.ResourceMap)}}function R1(c,e,t,i){return new L1(e,t,i,c)}function T1(c,e,t,i,n){return new D1(e,t,i,c,n)}o.registerModelAndPositionCommand("_executeDocumentHighlights",async(c,e,t)=>{const i=c.get(o.ILanguageFeaturesService);return(await Wb(i.documentHighlightProvider,e,t,a.CancellationToken.None))?.get(e.uri)});let Zp=(Oi=class{constructor(e,t,i,n,s,r,l,d){this.toUnhook=new a.DisposableStore,this.workerRequestTokenId=0,this.workerRequestCompleted=!1,this.workerRequestValue=new a.ResourceMap,this.lastCursorPositionChangeTime=0,this.renderDecorationsTimer=void 0,this.runDelayer=this.toUnhook.add(new a.Delayer(50)),this.editor=e,this.providers=t,this.multiDocumentProviders=i,this.codeEditorService=r,this.textModelService=s,this.configurationService=l,this.logService=d,this._hasWordHighlights=Gp.bindTo(n),this._ignorePositionChangeEvent=!1,this.occurrencesHighlightEnablement=this.editor.getOption(90),this.occurrencesHighlightDelay=this.configurationService.getValue("editor.occurrencesHighlightDelay"),this.model=this.editor.getModel(),this.toUnhook.add(e.onDidChangeCursorPosition(h=>{this._ignorePositionChangeEvent||this.occurrencesHighlightEnablement!=="off"&&this.runDelayer.trigger(()=>{this._onPositionChanged(h)}).catch(a.onUnexpectedError)})),this.toUnhook.add(e.onDidFocusEditorText(h=>{this.occurrencesHighlightEnablement!=="off"&&(this.workerRequest||this.runDelayer.trigger(()=>{this._run()}).catch(a.onUnexpectedError))})),this.toUnhook.add(e.onDidChangeModelContent(h=>{a.matchesScheme(this.model.uri,"output")||this._stopAll()})),this.toUnhook.add(e.onDidChangeModel(h=>{!h.newModelUrl&&h.oldModelUrl?this._stopSingular():X.query&&this._run()})),this.toUnhook.add(e.onDidChangeConfiguration(h=>{const u=this.editor.getOption(90);if(this.occurrencesHighlightEnablement!==u)switch(this.occurrencesHighlightEnablement=u,u){case"off":this._stopAll();break;case"singleFile":this._stopAll(X.query?.modelInfo?.modelURI);break;case"multiFile":X.query&&this._run(!0);break;default:console.warn("Unknown occurrencesHighlight setting value:",u);break}})),this.toUnhook.add(this.configurationService.onDidChangeConfiguration(h=>{if(h.affectsConfiguration("editor.occurrencesHighlightDelay")){const u=l.getValue("editor.occurrencesHighlightDelay");this.occurrencesHighlightDelay!==u&&(this.occurrencesHighlightDelay=u)}})),this.toUnhook.add(e.onDidBlurEditorWidget(()=>{const h=this.codeEditorService.getFocusedCodeEditor();h?h.getModel()?.uri.scheme===a.Schemas.vscodeNotebookCell&&this.editor.getModel()?.uri.scheme!==a.Schemas.vscodeNotebookCell&&this._stopAll():this._stopAll()})),this.decorations=this.editor.createDecorationsCollection(),this.workerRequestTokenId=0,this.workerRequest=null,this.workerRequestCompleted=!1,this.lastCursorPositionChangeTime=0,this.renderDecorationsTimer=void 0,X.query&&this._run()}hasDecorations(){return this.decorations.length>0}restore(e){this.occurrencesHighlightEnablement!=="off"&&(this.runDelayer.cancel(),this.runDelayer.trigger(()=>{this._run(!1,e)}).catch(a.onUnexpectedError))}stop(){this.occurrencesHighlightEnablement!=="off"&&this._stopAll()}_getSortedHighlights(){return this.decorations.getRanges().sort(a.Range.compareRangesUsingStarts)}moveNext(){const e=this._getSortedHighlights(),i=(e.findIndex(s=>s.containsPosition(this.editor.getPosition()))+1)%e.length,n=e[i];try{this._ignorePositionChangeEvent=!0,this.editor.setPosition(n.getStartPosition()),this.editor.revealRangeInCenterIfOutsideViewport(n);const s=this._getWord();if(s){const r=this.editor.getModel().getLineContent(n.startLineNumber);o.alert(`${r}, ${i+1} of ${e.length} for '${s.word}'`)}}finally{this._ignorePositionChangeEvent=!1}}moveBack(){const e=this._getSortedHighlights(),i=(e.findIndex(s=>s.containsPosition(this.editor.getPosition()))-1+e.length)%e.length,n=e[i];try{this._ignorePositionChangeEvent=!0,this.editor.setPosition(n.getStartPosition()),this.editor.revealRangeInCenterIfOutsideViewport(n);const s=this._getWord();if(s){const r=this.editor.getModel().getLineContent(n.startLineNumber);o.alert(`${r}, ${i+1} of ${e.length} for '${s.word}'`)}}finally{this._ignorePositionChangeEvent=!1}}_removeSingleDecorations(){if(!this.editor.hasModel())return;const e=X.storedDecorationIDs.get(this.editor.getModel().uri);e&&(this.editor.removeDecorations(e),X.storedDecorationIDs.delete(this.editor.getModel().uri),this.decorations.length>0&&(this.decorations.clear(),this._hasWordHighlights.set(!1)))}_removeAllDecorations(e){const t=this.codeEditorService.listCodeEditors(),i=[];for(const n of t){if(!n.hasModel()||o.isEqual(n.getModel().uri,e))continue;const s=X.storedDecorationIDs.get(n.getModel().uri);if(!s)continue;n.removeDecorations(s),i.push(n.getModel().uri);const r=ci.get(n);r?.wordHighlighter&&r.wordHighlighter.decorations.length>0&&(r.wordHighlighter.decorations.clear(),r.wordHighlighter.workerRequest=null,r.wordHighlighter._hasWordHighlights.set(!1))}for(const n of i)X.storedDecorationIDs.delete(n)}_stopSingular(){this._removeSingleDecorations(),this.editor.hasTextFocus()&&(this.editor.getModel()?.uri.scheme!==a.Schemas.vscodeNotebookCell&&X.query?.modelInfo?.modelURI.scheme!==a.Schemas.vscodeNotebookCell?(X.query=null,this._run()):X.query?.modelInfo&&(X.query.modelInfo=null)),this.renderDecorationsTimer!==void 0&&(clearTimeout(this.renderDecorationsTimer),this.renderDecorationsTimer=void 0),this.workerRequest!==null&&(this.workerRequest.cancel(),this.workerRequest=null),this.workerRequestCompleted||(this.workerRequestTokenId++,this.workerRequestCompleted=!0)}_stopAll(e){this._removeAllDecorations(e),this.renderDecorationsTimer!==void 0&&(clearTimeout(this.renderDecorationsTimer),this.renderDecorationsTimer=void 0),this.workerRequest!==null&&(this.workerRequest.cancel(),this.workerRequest=null),this.workerRequestCompleted||(this.workerRequestTokenId++,this.workerRequestCompleted=!0)}_onPositionChanged(e){if(this.occurrencesHighlightEnablement==="off"){this._stopAll();return}if(e.source!=="api"&&e.reason!==3){this._stopAll();return}this._run()}_getWord(){const e=this.editor.getSelection(),t=e.startLineNumber,i=e.startColumn;return this.model.isDisposed()?null:this.model.getWordAtPosition({lineNumber:t,column:i})}getOtherModelsToHighlight(e){if(!e)return[];if(e.uri.scheme===a.Schemas.vscodeNotebookCell){const s=[],r=this.codeEditorService.listCodeEditors();for(const l of r){const d=l.getModel();d&&d!==e&&d.uri.scheme===a.Schemas.vscodeNotebookCell&&s.push(d)}return s}const i=[],n=this.codeEditorService.listCodeEditors();for(const s of n){if(!o.isDiffEditor(s))continue;const r=s.getModel();r&&e===r.modified&&i.push(r.modified)}if(i.length)return i;if(this.occurrencesHighlightEnablement==="singleFile")return[];for(const s of n){const r=s.getModel();r&&r!==e&&i.push(r)}return i}async _run(e,t){if(this.editor.hasTextFocus()){const n=this.editor.getSelection();if(!n||n.startLineNumber!==n.endLineNumber){X.query=null,this._stopAll();return}const s=n.startColumn,r=n.endColumn,l=this._getWord();if(!l||l.startColumn>s||l.endColumn<r){X.query=null,this._stopAll();return}X.query={modelInfo:{modelURI:this.model.uri,selection:n}}}else if(!X.query){this._stopAll();return}if(this.lastCursorPositionChangeTime=new Date().getTime(),o.isEqual(this.editor.getModel().uri,X.query.modelInfo?.modelURI)){if(!e){const l=this.decorations.getRanges();for(const d of l)if(d.containsPosition(this.editor.getPosition()))return}this._stopAll(e?this.model.uri:void 0);const n=++this.workerRequestTokenId;this.workerRequestCompleted=!1;const s=this.getOtherModelsToHighlight(this.editor.getModel());if(!X.query||!X.query.modelInfo)return;const r=await this.textModelService.createModelReference(X.query.modelInfo.modelURI);try{this.workerRequest=this.computeWithModel(r.object.textEditorModel,X.query.modelInfo.selection,s),this.workerRequest?.result.then(l=>{n===this.workerRequestTokenId&&(this.workerRequestCompleted=!0,this.workerRequestValue=l||[],this._beginRenderDecorations(t??this.occurrencesHighlightDelay))},a.onUnexpectedError)}catch(l){this.logService.error("Unexpected error during occurrence request. Log: ",l)}finally{r.dispose()}}else if(this.model.uri.scheme===a.Schemas.vscodeNotebookCell){const n=++this.workerRequestTokenId;if(this.workerRequestCompleted=!1,!X.query||!X.query.modelInfo)return;const s=await this.textModelService.createModelReference(X.query.modelInfo.modelURI);try{this.workerRequest=this.computeWithModel(s.object.textEditorModel,X.query.modelInfo.selection,[this.model]),this.workerRequest?.result.then(r=>{n===this.workerRequestTokenId&&(this.workerRequestCompleted=!0,this.workerRequestValue=r||[],this._beginRenderDecorations(t??this.occurrencesHighlightDelay))},a.onUnexpectedError)}catch(r){this.logService.error("Unexpected error during occurrence request. Log: ",r)}finally{s.dispose()}}}computeWithModel(e,t,i){return i.length?T1(this.multiDocumentProviders,e,t,this.editor.getOption(148),i):R1(this.providers,e,t,this.editor.getOption(148))}_beginRenderDecorations(e){const t=new Date().getTime(),i=this.lastCursorPositionChangeTime+e;t>=i?(this.renderDecorationsTimer=void 0,this.renderDecorations()):this.renderDecorationsTimer=setTimeout(()=>{this.renderDecorations()},i-t)}renderDecorations(){this.renderDecorationsTimer=void 0;const e=this.codeEditorService.listCodeEditors();for(const t of e){const i=ci.get(t);if(!i)continue;const n=[],s=t.getModel()?.uri;if(s&&this.workerRequestValue.has(s)){const r=X.storedDecorationIDs.get(s),l=this.workerRequestValue.get(s);if(l)for(const h of l)h.range&&n.push({range:h.range,options:h0(h.kind)});let d=[];t.changeDecorations(h=>{d=h.deltaDecorations(r??[],n)}),X.storedDecorationIDs=X.storedDecorationIDs.set(s,d),n.length>0&&(i.wordHighlighter?.decorations.set(n),i.wordHighlighter?._hasWordHighlights.set(!0))}}this.workerRequest=null}dispose(){this._stopSingular(),this.toUnhook.dispose()}},X=Oi,Oi.storedDecorationIDs=new a.ResourceMap,Oi.query=null,Oi);Zp=X=Jb([pt(4,o.ITextModelService),pt(5,o.ICodeEditorService),pt(6,o.IConfigurationService),pt(7,o.ILogService)],Zp);let ci=(ts=class extends a.Disposable{static get(e){return e.getContribution(qp.ID)}constructor(e,t,i,n,s,r,l){super(),this._wordHighlighter=null;const d=()=>{e.hasModel()&&!e.getModel().isTooLargeForTokenization()&&e.getModel().uri.scheme!==a.Schemas.accessibleView&&(this._wordHighlighter=new Zp(e,i.documentHighlightProvider,i.multiDocumentHighlightProvider,t,s,n,r,l))};this._register(e.onDidChangeModel(h=>{this._wordHighlighter&&(!h.newModelUrl&&h.oldModelUrl?.scheme!==a.Schemas.vscodeNotebookCell&&this.wordHighlighter?.stop(),this._wordHighlighter.dispose(),this._wordHighlighter=null),d()})),d()}get wordHighlighter(){return this._wordHighlighter}saveViewState(){return!!(this._wordHighlighter&&this._wordHighlighter.hasDecorations())}moveNext(){this._wordHighlighter?.moveNext()}moveBack(){this._wordHighlighter?.moveBack()}restoreViewState(e){this._wordHighlighter&&e&&this._wordHighlighter.restore(250)}dispose(){this._wordHighlighter&&(this._wordHighlighter.dispose(),this._wordHighlighter=null),super.dispose()}},qp=ts,ts.ID="editor.contrib.wordHighlighter",ts);ci=qp=Jb([pt(1,o.IContextKeyService),pt(2,o.ILanguageFeaturesService),pt(3,o.ICodeEditorService),pt(4,o.ITextModelService),pt(5,o.IConfigurationService),pt(6,o.ILogService)],ci);class eC extends o.EditorAction{constructor(e,t){super(t),this._isNext=e}run(e,t){const i=ci.get(t);i&&(this._isNext?i.moveNext():i.moveBack())}}class N1 extends eC{constructor(){super(!0,{id:"editor.action.wordHighlight.next",label:a.localize2(1646,"Go to Next Symbol Highlight"),precondition:Gp,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:65,weight:100}})}}class M1 extends eC{constructor(){super(!1,{id:"editor.action.wordHighlight.prev",label:a.localize2(1647,"Go to Previous Symbol Highlight"),precondition:Gp,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:1089,weight:100}})}}class P1 extends o.EditorAction{constructor(){super({id:"editor.action.wordHighlight.trigger",label:a.localize2(1648,"Trigger Symbol Highlight"),precondition:void 0,kbOpts:{kbExpr:o.EditorContextKeys.editorTextFocus,primary:0,weight:100}})}run(e,t){const i=ci.get(t);i&&i.restoreViewState(!0)}}o.registerEditorContribution(ci.ID,ci,0),o.registerEditorAction(N1),o.registerEditorAction(M1),o.registerEditorAction(P1),o.registerEditorFeature(jp);class uc extends o.EditorCommand{constructor(e){super(e),this._inSelectionMode=e.inSelectionMode,this._wordNavigationType=e.wordNavigationType}runEditorCommand(e,t,i){if(!t.hasModel())return;const n=a.getMapForWordSeparators(t.getOption(148),t.getOption(147)),s=t.getModel(),r=t.getSelections(),l=r.length>1,d=r.map(h=>{const u=new a.Position(h.positionLineNumber,h.positionColumn),g=this._move(n,s,u,this._wordNavigationType,l);return this._moveTo(h,g,this._inSelectionMode)});if(s.pushStackElement(),t._getViewModel().setCursorStates("moveWordCommand",3,d.map(h=>o.CursorState.fromModelSelection(h))),d.length===1){const h=new a.Position(d[0].positionLineNumber,d[0].positionColumn);t.revealPosition(h,0)}}_moveTo(e,t,i){return i?new a.Selection(e.selectionStartLineNumber,e.selectionStartColumn,t.lineNumber,t.column):new a.Selection(t.lineNumber,t.column,t.lineNumber,t.column)}}class di extends uc{_move(e,t,i,n,s){return o.WordOperations.moveWordLeft(e,t,i,n,s)}}class hi extends uc{_move(e,t,i,n,s){return o.WordOperations.moveWordRight(e,t,i,n)}}class O1 extends di{constructor(){super({inSelectionMode:!1,wordNavigationType:0,id:"cursorWordStartLeft",precondition:void 0})}}class A1 extends di{constructor(){super({inSelectionMode:!1,wordNavigationType:2,id:"cursorWordEndLeft",precondition:void 0})}}class F1 extends di{constructor(){super({inSelectionMode:!1,wordNavigationType:1,id:"cursorWordLeft",precondition:void 0,kbOpts:{kbExpr:o.ContextKeyExpr.and(o.EditorContextKeys.textInputFocus,o.ContextKeyExpr.and(o.CONTEXT_ACCESSIBILITY_MODE_ENABLED,o.IsWindowsContext)?.negate()),primary:2063,mac:{primary:527},weight:100}})}}class z1 extends di{constructor(){super({inSelectionMode:!0,wordNavigationType:0,id:"cursorWordStartLeftSelect",precondition:void 0})}}class V1 extends di{constructor(){super({inSelectionMode:!0,wordNavigationType:2,id:"cursorWordEndLeftSelect",precondition:void 0})}}class B1 extends di{constructor(){super({inSelectionMode:!0,wordNavigationType:1,id:"cursorWordLeftSelect",precondition:void 0,kbOpts:{kbExpr:o.ContextKeyExpr.and(o.EditorContextKeys.textInputFocus,o.ContextKeyExpr.and(o.CONTEXT_ACCESSIBILITY_MODE_ENABLED,o.IsWindowsContext)?.negate()),primary:3087,mac:{primary:1551},weight:100}})}}class K1 extends di{constructor(){super({inSelectionMode:!1,wordNavigationType:3,id:"cursorWordAccessibilityLeft",precondition:void 0})}_move(e,t,i,n,s){return super._move(a.getMapForWordSeparators(o.EditorOptions.wordSeparators.defaultValue,e.intlSegmenterLocales),t,i,n,s)}}class k1 extends di{constructor(){super({inSelectionMode:!0,wordNavigationType:3,id:"cursorWordAccessibilityLeftSelect",precondition:void 0})}_move(e,t,i,n,s){return super._move(a.getMapForWordSeparators(o.EditorOptions.wordSeparators.defaultValue,e.intlSegmenterLocales),t,i,n,s)}}class U1 extends hi{constructor(){super({inSelectionMode:!1,wordNavigationType:0,id:"cursorWordStartRight",precondition:void 0})}}class $1 extends hi{constructor(){super({inSelectionMode:!1,wordNavigationType:2,id:"cursorWordEndRight",precondition:void 0,kbOpts:{kbExpr:o.ContextKeyExpr.and(o.EditorContextKeys.textInputFocus,o.ContextKeyExpr.and(o.CONTEXT_ACCESSIBILITY_MODE_ENABLED,o.IsWindowsContext)?.negate()),primary:2065,mac:{primary:529},weight:100}})}}class j1 extends hi{constructor(){super({inSelectionMode:!1,wordNavigationType:2,id:"cursorWordRight",precondition:void 0})}}class q1 extends hi{constructor(){super({inSelectionMode:!0,wordNavigationType:0,id:"cursorWordStartRightSelect",precondition:void 0})}}class G1 extends hi{constructor(){super({inSelectionMode:!0,wordNavigationType:2,id:"cursorWordEndRightSelect",precondition:void 0,kbOpts:{kbExpr:o.ContextKeyExpr.and(o.EditorContextKeys.textInputFocus,o.ContextKeyExpr.and(o.CONTEXT_ACCESSIBILITY_MODE_ENABLED,o.IsWindowsContext)?.negate()),primary:3089,mac:{primary:1553},weight:100}})}}class Z1 extends hi{constructor(){super({inSelectionMode:!0,wordNavigationType:2,id:"cursorWordRightSelect",precondition:void 0})}}class X1 extends hi{constructor(){super({inSelectionMode:!1,wordNavigationType:3,id:"cursorWordAccessibilityRight",precondition:void 0})}_move(e,t,i,n,s){return super._move(a.getMapForWordSeparators(o.EditorOptions.wordSeparators.defaultValue,e.intlSegmenterLocales),t,i,n,s)}}class Y1 extends hi{constructor(){super({inSelectionMode:!0,wordNavigationType:3,id:"cursorWordAccessibilityRightSelect",precondition:void 0})}_move(e,t,i,n,s){return super._move(a.getMapForWordSeparators(o.EditorOptions.wordSeparators.defaultValue,e.intlSegmenterLocales),t,i,n,s)}}class gc extends o.EditorCommand{constructor(e){super({canTriggerInlineEdits:!0,...e}),this._whitespaceHeuristics=e.whitespaceHeuristics,this._wordNavigationType=e.wordNavigationType}runEditorCommand(e,t,i){const n=e?.get(o.ILanguageConfigurationService);if(!t.hasModel()||!n)return;const s=a.getMapForWordSeparators(t.getOption(148),t.getOption(147)),r=t.getModel(),l=t.getSelections(),d=t.getOption(10),h=t.getOption(15),u=n.getLanguageConfiguration(r.getLanguageId()).getAutoClosingPairs(),g=t._getViewModel(),p=l.map(f=>{const m=this._delete({wordSeparators:s,model:r,selection:f,whitespaceHeuristics:this._whitespaceHeuristics,autoClosingDelete:t.getOption(13),autoClosingBrackets:d,autoClosingQuotes:h,autoClosingPairs:u,autoClosedCharacters:g.getCursorAutoClosedCharacters()},this._wordNavigationType);return new o.ReplaceCommand(m,"")});t.pushUndoStop(),t.executeCommands(this.id,p),t.pushUndoStop()}}class Xp extends gc{_delete(e,t){const i=o.WordOperations.deleteWordLeft(e,t);return i||new a.Range(1,1,1,1)}}class Yp extends gc{_delete(e,t){const i=o.WordOperations.deleteWordRight(e,t);if(i)return i;const n=e.model.getLineCount(),s=e.model.getLineMaxColumn(n);return new a.Range(n,s,n,s)}}class Q1 extends Xp{constructor(){super({whitespaceHeuristics:!1,wordNavigationType:0,id:"deleteWordStartLeft",precondition:o.EditorContextKeys.writable})}}class J1 extends Xp{constructor(){super({whitespaceHeuristics:!1,wordNavigationType:2,id:"deleteWordEndLeft",precondition:o.EditorContextKeys.writable})}}class W1 extends Xp{constructor(){super({whitespaceHeuristics:!0,wordNavigationType:0,id:"deleteWordLeft",precondition:o.EditorContextKeys.writable,kbOpts:{kbExpr:o.EditorContextKeys.textInputFocus,primary:2049,mac:{primary:513},weight:100}})}}class H1 extends Yp{constructor(){super({whitespaceHeuristics:!1,wordNavigationType:0,id:"deleteWordStartRight",precondition:o.EditorContextKeys.writable})}}class eN extends Yp{constructor(){super({whitespaceHeuristics:!1,wordNavigationType:2,id:"deleteWordEndRight",precondition:o.EditorContextKeys.writable})}}class tN extends Yp{constructor(){super({whitespaceHeuristics:!0,wordNavigationType:2,id:"deleteWordRight",precondition:o.EditorContextKeys.writable,kbOpts:{kbExpr:o.EditorContextKeys.textInputFocus,primary:2068,mac:{primary:532},weight:100}})}}class iN extends o.EditorAction{constructor(){super({id:"deleteInsideWord",precondition:o.EditorContextKeys.writable,label:a.localize2(1650,"Delete Word"),metadata:{description:a.localize2(1651,"Delete the word at the cursor"),args:[{name:"args",schema:{type:"object",properties:{onlyWord:{type:"boolean",default:!1,description:a.localize(1649,"Delete only the word and leave surrounding whitespace")}}}}]}})}run(e,t,i){if(!t.hasModel())return;const n=!!(i&&typeof i=="object"&&i.onlyWord),s=a.getMapForWordSeparators(t.getOption(148),t.getOption(147)),r=t.getModel(),d=t.getSelections().map(h=>{const u=o.WordOperations.deleteInsideWord(s,r,h,n);return new o.ReplaceCommand(u,"")});t.pushUndoStop(),t.executeCommands(this.id,d),t.pushUndoStop()}}o.registerEditorCommand(new O1),o.registerEditorCommand(new A1),o.registerEditorCommand(new F1),o.registerEditorCommand(new z1),o.registerEditorCommand(new V1),o.registerEditorCommand(new B1),o.registerEditorCommand(new U1),o.registerEditorCommand(new $1),o.registerEditorCommand(new j1),o.registerEditorCommand(new q1),o.registerEditorCommand(new G1),o.registerEditorCommand(new Z1),o.registerEditorCommand(new K1),o.registerEditorCommand(new k1),o.registerEditorCommand(new X1),o.registerEditorCommand(new Y1),o.registerEditorCommand(new Q1),o.registerEditorCommand(new J1),o.registerEditorCommand(new W1),o.registerEditorCommand(new H1),o.registerEditorCommand(new eN),o.registerEditorCommand(new tN),o.registerEditorAction(iN);class nN extends gc{constructor(){super({whitespaceHeuristics:!0,wordNavigationType:0,id:"deleteWordPartLeft",precondition:o.EditorContextKeys.writable,kbOpts:{kbExpr:o.EditorContextKeys.textInputFocus,primary:0,mac:{primary:769},weight:100}})}_delete(e,t){const i=o.WordPartOperations.deleteWordPartLeft(e);return i||new a.Range(1,1,1,1)}}class sN extends gc{constructor(){super({whitespaceHeuristics:!0,wordNavigationType:2,id:"deleteWordPartRight",precondition:o.EditorContextKeys.writable,kbOpts:{kbExpr:o.EditorContextKeys.textInputFocus,primary:0,mac:{primary:788},weight:100}})}_delete(e,t){const i=o.WordPartOperations.deleteWordPartRight(e);if(i)return i;const n=e.model.getLineCount(),s=e.model.getLineMaxColumn(n);return new a.Range(n,s,n,s)}}class tC extends uc{_move(e,t,i,n,s){return o.WordPartOperations.moveWordPartLeft(e,t,i,s)}}class oN extends tC{constructor(){super({inSelectionMode:!1,wordNavigationType:0,id:"cursorWordPartLeft",precondition:void 0,kbOpts:{kbExpr:o.EditorContextKeys.textInputFocus,primary:0,mac:{primary:783},weight:100}})}}o.CommandsRegistry.registerCommandAlias("cursorWordPartStartLeft","cursorWordPartLeft");class rN extends tC{constructor(){super({inSelectionMode:!0,wordNavigationType:0,id:"cursorWordPartLeftSelect",precondition:void 0,kbOpts:{kbExpr:o.EditorContextKeys.textInputFocus,primary:0,mac:{primary:1807},weight:100}})}}o.CommandsRegistry.registerCommandAlias("cursorWordPartStartLeftSelect","cursorWordPartLeftSelect");class iC extends uc{_move(e,t,i,n,s){return o.WordPartOperations.moveWordPartRight(e,t,i)}}class aN extends iC{constructor(){super({inSelectionMode:!1,wordNavigationType:2,id:"cursorWordPartRight",precondition:void 0,kbOpts:{kbExpr:o.EditorContextKeys.textInputFocus,primary:0,mac:{primary:785},weight:100}})}}class lN extends iC{constructor(){super({inSelectionMode:!0,wordNavigationType:2,id:"cursorWordPartRightSelect",precondition:void 0,kbOpts:{kbExpr:o.EditorContextKeys.textInputFocus,primary:0,mac:{primary:1809},weight:100}})}}o.registerEditorCommand(new nN),o.registerEditorCommand(new sN),o.registerEditorCommand(new oN),o.registerEditorCommand(new rN),o.registerEditorCommand(new aN),o.registerEditorCommand(new lN);const Cf=class Cf extends a.Disposable{constructor(e){super(),this.editor=e,this._register(this.editor.onDidAttemptReadOnlyEdit(()=>this._onDidAttemptReadOnlyEdit()))}_onDidAttemptReadOnlyEdit(){const e=ve.get(this.editor);if(e&&this.editor.hasModel()){let t=this.editor.getOptions().get(105);t||(this.editor.isSimpleWidget?t=new o.MarkdownString(a.localize(1447,"Cannot edit in read-only input")):t=new o.MarkdownString(a.localize(1448,"Cannot edit in read-only editor"))),e.showMessage(t,this.editor.getPosition())}}};Cf.ID="editor.contrib.readOnlyMessageController";let pc=Cf;o.registerEditorContribution(pc.ID,pc,2);var cN=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},nC=function(c,e){return function(t,i){e(t,i,c)}};let Qp=class extends a.Disposable{constructor(e,t,i){super(),this._textModel=e,this._languageFeaturesService=t,this._outlineModelService=i,this._currentModel=o.observableValue(this,void 0);const n=o.observableSignalFromEvent("documentSymbolProvider.onDidChange",this._languageFeaturesService.documentSymbolProvider.onDidChange),s=o.observableSignalFromEvent("_textModel.onDidChangeContent",a.Event.debounce(r=>this._textModel.onDidChangeContent(r),()=>{},100));this._register(o.autorunWithStore(async(r,l)=>{n.read(r),s.read(r);const d=l.add(new o.DisposableCancellationTokenSource),h=await this._outlineModelService.getOrCreate(this._textModel,d.token);l.isDisposed||this._currentModel.set(h,void 0)}))}getBreadcrumbItems(e,t){const i=this._currentModel.read(t);if(!i)return[];const n=i.asListOfDocumentSymbols().filter(s=>e.contains(s.range.startLineNumber)&&!e.contains(s.range.endLineNumber));return n.sort(a.reverseOrder(a.compareBy(s=>s.range.endLineNumber-s.range.startLineNumber,a.numberComparator))),n.map(s=>({name:s.name,kind:s.kind,startLineNumber:s.range.startLineNumber}))}getAt(e,t){const i=this._currentModel.read(t);if(!i)return[];const n=i.asListOfDocumentSymbols().filter(s=>new a.LineRange(s.range.startLineNumber,s.range.endLineNumber).contains(e));return n.length===0?[]:(n.sort(a.reverseOrder(a.compareBy(s=>s.range.endLineNumber-s.range.startLineNumber,a.numberComparator))),n.map(s=>({name:s.name,kind:s.kind,startLineNumber:s.range.startLineNumber})))}};Qp=cN([nC(1,o.ILanguageFeaturesService),nC(2,qo)],Qp),o.HideUnchangedRegionsFeature.setBreadcrumbsSourceFactory((c,e)=>e.createInstance(Qp,c));var sC=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Ys=function(c,e){return function(t,i){e(t,i,c)}};let fc=(po=class extends a.Disposable{constructor(e,t,i,n){super();const s=this._register(o.observableCodeEditor(e)),r=o.derived(d=>s.model.read(d)?.uri),l=this._register(t.createInstance(Jp,o.MenuId.EditorContent,e.contextKeyService,r));this._register(o.autorun(d=>{l.hasActions.read(d)&&d.store.add(s.createOverlayWidget({allowEditorOverflow:!1,domNode:l.element,minContentWidthInPx:o.constObservable(0),position:o.constObservable({preference:1})}))}))}},po.ID="editor.contrib.floatingToolbar",po);fc=sC([Ys(1,o.IInstantiationService),Ys(2,o.IKeybindingService),Ys(3,o.IMenuService)],fc);let Jp=class extends a.Disposable{constructor(e,t,i,n,s,r){super();const l=this._register(r.createMenu(e,t)),d=o.observableFromEvent(this,l.onDidChange,()=>l.getActions()),h=o.derived(u=>{const g=d.read(u),{primary:p}=o.getActionBarActions(g,()=>!0);return p.filter(f=>f.id!==o.Separator.ID)});this.hasActions=o.derived(u=>h.read(u).length>0),this.element=o.h("div.floating-menu-overlay-widget").root,this._register(a.toDisposable(()=>this.element.remove())),this._register(o.autorun(u=>{const g=h.read(u),p=g.length>0,f=p?g[0].id:void 0,m=g.length===1;if(this.element.classList.toggle("single-button",m),this.element.style.height=m?"28px":"26px",!p)return;const _=n.createInstance(o.MenuWorkbenchToolBar,this.element,e,{actionViewItemProvider:(v,b)=>{if(v instanceof o.MenuItemAction)return n.createInstance(class extends o.MenuEntryActionViewItem{render(C){super.render(C),v.id===f&&this.element?.classList.add("primary")}updateLabel(){const C=s.lookupKeybinding(v.id),y=C?C.getLabel():void 0;this.options.label&&this.label&&(this.label.textContent=y?`${this._commandAction.label} (${y})`:this._commandAction.label)}},v,{...b,keybindingNotRenderedWithLabel:!0})},hiddenItemStrategy:0,menuOptions:{shouldForwardArgs:!0},telemetrySource:"editor.overlayToolbar",toolbarOptions:{primaryGroup:()=>!0,useSeparatorsInPrimaryActions:!0}});u.store.add(_),u.store.add(o.autorun(v=>{const b=i.read(v);_.context=b}))}))}};Jp=sC([Ys(3,o.IInstantiationService),Ys(4,o.IKeybindingService),Ys(5,o.IMenuService)],Jp),o.registerEditorContribution(fc.ID,fc,1);const Sf=class Sf extends a.Disposable{constructor(e){super(),this.editor=e,this.widget=null,a.isIOS&&(this._register(e.onDidChangeConfiguration(()=>this.update())),this.update())}update(){const e=!this.editor.getOption(104);!this.widget&&e?this.widget=new Wp(this.editor):this.widget&&!e&&(this.widget.dispose(),this.widget=null)}dispose(){super.dispose(),this.widget&&(this.widget.dispose(),this.widget=null)}};Sf.ID="editor.contrib.iPadShowKeyboard";let mc=Sf;const dd=class dd extends a.Disposable{constructor(e){super(),this.editor=e,this._domNode=document.createElement("textarea"),this._domNode.className="iPadShowKeyboard",this._register(o.addDisposableListener(this._domNode,"touchstart",t=>{this.editor.focus()})),this._register(o.addDisposableListener(this._domNode,"focus",t=>{this.editor.focus()})),this.editor.addOverlayWidget(this)}dispose(){this.editor.removeOverlayWidget(this),super.dispose()}getId(){return dd.ID}getDomNode(){return this._domNode}getPosition(){return{preference:1}}};dd.ID="editor.contrib.ShowKeyboardWidget";let Wp=dd;o.registerEditorContribution(mc.ID,mc,3);var dN=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},oC=function(c,e){return function(t,i){e(t,i,c)}},Hp;let kr=(is=class extends a.Disposable{static get(e){return e.getContribution(Hp.ID)}constructor(e,t,i){super(),this._editor=e,this._languageService=i,this._widget=null,this._register(this._editor.onDidChangeModel(n=>this.stop())),this._register(this._editor.onDidChangeModelLanguage(n=>this.stop())),this._register(a.TokenizationRegistry.onDidChange(n=>this.stop())),this._register(this._editor.onKeyUp(n=>n.keyCode===9&&this.stop()))}dispose(){this.stop(),super.dispose()}launch(){this._widget||this._editor.hasModel()&&(this._widget=new ef(this._editor,this._languageService))}stop(){this._widget&&(this._widget.dispose(),this._widget=null)}},Hp=is,is.ID="editor.contrib.inspectTokens",is);kr=Hp=dN([oC(1,o.IStandaloneThemeService),oC(2,o.ILanguageService)],kr);class hN extends o.EditorAction{constructor(){super({id:"editor.action.inspectTokens",label:o.InspectTokensNLS.inspectTokensAction,alias:"Developer: Inspect Tokens",precondition:void 0})}run(e,t){kr.get(t)?.launch()}}function uN(c){let e="";for(let t=0,i=c.length;t<i;t++){const n=c.charCodeAt(t);switch(n){case 9:e+="→";break;case 32:e+="·";break;default:e+=String.fromCharCode(n)}}return e}function gN(c,e){const t=a.TokenizationRegistry.get(e);if(t)return t;const i=c.encodeLanguageId(e);return{getInitialState:()=>o.NullState,tokenize:(n,s,r)=>o.nullTokenize(e,r),tokenizeEncoded:(n,s,r)=>o.nullTokenizeEncoded(i,r)}}const hd=class hd extends a.Disposable{constructor(e,t){super(),this.allowEditorOverflow=!0,this._editor=e,this._languageService=t,this._model=this._editor.getModel(),this._domNode=document.createElement("div"),this._domNode.className="tokens-inspect-widget",this._tokenizationSupport=gN(this._languageService.languageIdCodec,this._model.getLanguageId()),this._compute(this._editor.getPosition()),this._register(this._editor.onDidChangeCursorPosition(i=>this._compute(this._editor.getPosition()))),this._editor.addContentWidget(this)}dispose(){this._editor.removeContentWidget(this),super.dispose()}getId(){return hd._ID}_compute(e){const t=this._getTokensAtLine(e.lineNumber);let i=0;for(let d=t.tokens1.length-1;d>=0;d--){const h=t.tokens1[d];if(e.column-1>=h.offset){i=d;break}}let n=0;for(let d=t.tokens2.length>>>1;d>=0;d--)if(e.column-1>=t.tokens2[d<<1]){n=d;break}const s=this._model.getLineContent(e.lineNumber);let r="";if(i<t.tokens1.length){const d=t.tokens1[i].offset,h=i+1<t.tokens1.length?t.tokens1[i+1].offset:s.length;r=s.substring(d,h)}o.reset(this._domNode,o.$("h2.tm-token",void 0,uN(r),o.$("span.tm-token-length",void 0,`${r.length} ${r.length===1?"char":"chars"}`))),o.append(this._domNode,o.$("hr.tokens-inspect-separator",{style:"clear:both"}));const l=(n<<1)+1<t.tokens2.length?this._decodeMetadata(t.tokens2[(n<<1)+1]):null;o.append(this._domNode,o.$("table.tm-metadata-table",void 0,o.$("tbody",void 0,o.$("tr",void 0,o.$("td.tm-metadata-key",void 0,"language"),o.$("td.tm-metadata-value",void 0,`${l?l.languageId:"-?-"}`)),o.$("tr",void 0,o.$("td.tm-metadata-key",void 0,"token type"),o.$("td.tm-metadata-value",void 0,`${l?this._tokenTypeToString(l.tokenType):"-?-"}`)),o.$("tr",void 0,o.$("td.tm-metadata-key",void 0,"font style"),o.$("td.tm-metadata-value",void 0,`${l?this._fontStyleToString(l.fontStyle):"-?-"}`)),o.$("tr",void 0,o.$("td.tm-metadata-key",void 0,"foreground"),o.$("td.tm-metadata-value",void 0,`${l?a.Color.Format.CSS.formatHex(l.foreground):"-?-"}`)),o.$("tr",void 0,o.$("td.tm-metadata-key",void 0,"background"),o.$("td.tm-metadata-value",void 0,`${l?a.Color.Format.CSS.formatHex(l.background):"-?-"}`))))),o.append(this._domNode,o.$("hr.tokens-inspect-separator")),i<t.tokens1.length&&o.append(this._domNode,o.$("span.tm-token-type",void 0,t.tokens1[i].type)),this._editor.layoutContentWidget(this)}_decodeMetadata(e){const t=a.TokenizationRegistry.getColorMap(),i=o.TokenMetadata.getLanguageId(e),n=o.TokenMetadata.getTokenType(e),s=o.TokenMetadata.getFontStyle(e),r=o.TokenMetadata.getForeground(e),l=o.TokenMetadata.getBackground(e);return{languageId:this._languageService.languageIdCodec.decodeLanguageId(i),tokenType:n,fontStyle:s,foreground:t[r],background:t[l]}}_tokenTypeToString(e){switch(e){case 0:return"Other";case 1:return"Comment";case 2:return"String";case 3:return"RegEx";default:return"??"}}_fontStyleToString(e){let t="";return e&1&&(t+="italic "),e&2&&(t+="bold "),e&4&&(t+="underline "),e&8&&(t+="strikethrough "),t.length===0&&(t="---"),t}_getTokensAtLine(e){const t=this._getStateBeforeLine(e),i=this._tokenizationSupport.tokenize(this._model.getLineContent(e),!0,t),n=this._tokenizationSupport.tokenizeEncoded(this._model.getLineContent(e),!0,t);return{startState:t,tokens1:i.tokens,tokens2:n.tokens,endState:i.endState}}_getStateBeforeLine(e){let t=this._tokenizationSupport.getInitialState();for(let i=1;i<e;i++)t=this._tokenizationSupport.tokenize(this._model.getLineContent(i),!0,t).endState;return t}getDomNode(){return this._domNode}getPosition(){return{position:this._editor.getPosition(),preference:[2,1]}}};hd._ID="editor.contrib.inspectTokensWidget";let ef=hd;o.registerEditorContribution(kr.ID,kr,4),o.registerEditorAction(hN);var pN=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},tf=function(c,e){return function(t,i){e(t,i,c)}},Ur;let nf=(ns=class{constructor(e,t,i){this.quickInputService=e,this.keybindingService=t,this.contextKeyService=i,this.registry=o.Registry.as(o.Extensions$1.Quickaccess)}provide(e){const t=new a.DisposableStore;return t.add(e.onDidAccept(()=>{const[i]=e.selectedItems;i&&this.quickInputService.quickAccess.show(i.prefix,{preserveValue:!0})})),t.add(e.onDidChangeValue(i=>{const n=this.registry.getQuickAccessProvider(i.substr(Ur.PREFIX.length),this.contextKeyService);n?.prefix&&n.prefix!==Ur.PREFIX&&this.quickInputService.quickAccess.show(n.prefix,{preserveValue:!0})})),e.items=this.getQuickAccessProviders().filter(i=>i.prefix!==Ur.PREFIX),t}getQuickAccessProviders(){return this.registry.getQuickAccessProviders(this.contextKeyService).sort((t,i)=>t.prefix.localeCompare(i.prefix)).flatMap(t=>this.createPicks(t))}createPicks(e){return e.helpEntries.map(t=>{const i=t.prefix||e.prefix,n=i||"…";return{prefix:i,label:n,keybinding:t.commandId?this.keybindingService.lookupKeybinding(t.commandId):void 0,ariaLabel:a.localize(1844,"{0}, {1}",n,t.description),description:t.description}})}},Ur=ns,ns.PREFIX="?",ns);nf=Ur=pN([tf(0,o.IQuickInputService),tf(1,o.IKeybindingService),tf(2,o.IContextKeyService)],nf),o.Registry.as(o.Extensions$1.Quickaccess).registerQuickAccessProvider({ctor:nf,prefix:"",helpEntries:[{description:o.QuickHelpNLS.helpQuickAccessActionLabel}]});class rC{constructor(e){this.options=e,this.rangeHighlightDecorationId=void 0}provide(e,t,i){const n=new a.DisposableStore;e.canAcceptInBackground=!!this.options?.canAcceptInBackground,e.matchOnLabel=e.matchOnDescription=e.matchOnDetail=e.sortByLabel=!1;const s=n.add(new a.MutableDisposable);return s.value=this.doProvide(e,t,i),n.add(this.onDidActiveTextEditorControlChange(()=>{s.value=void 0,s.value=this.doProvide(e,t)})),n}doProvide(e,t,i){const n=new a.DisposableStore,s=this.activeTextEditorControl;if(s&&this.canProvideWithTextEditor(s)){const r={editor:s},l=o.getCodeEditor(s);if(l){let d=s.saveViewState()??void 0;n.add(l.onDidChangeCursorPosition(()=>{d=s.saveViewState()??void 0})),r.restoreViewState=()=>{d&&s===this.activeTextEditorControl&&s.restoreViewState(d)},n.add(a.createSingleCallFunction(t.onCancellationRequested)(()=>r.restoreViewState?.()))}n.add(a.toDisposable(()=>this.clearDecorations(s))),n.add(this.provideWithTextEditor(r,e,t,i))}else n.add(this.provideWithoutTextEditor(e,t));return n}canProvideWithTextEditor(e){return!0}gotoLocation({editor:e},t){e.setSelection(t.range,"code.jump"),e.revealRangeInCenter(t.range,0),t.preserveFocus||e.focus();const i=this.getModel(e);if(i){const n=i.getLineContent(t.range.startLineNumber);o.status(a.localize(1401,"Line {0}, column {1}: {2}",t.range.startLineNumber,t.range.startColumn,n))}}getModel(e){return o.isDiffEditor(e)?e.getModel()?.modified:e.getModel()}addDecorations(e,t){e.changeDecorations(i=>{const n=[];this.rangeHighlightDecorationId&&(n.push(this.rangeHighlightDecorationId.overviewRulerDecorationId),n.push(this.rangeHighlightDecorationId.rangeHighlightId),this.rangeHighlightDecorationId=void 0);const s=[{range:t,options:{description:"quick-access-range-highlight",className:"rangeHighlight",isWholeLine:!0}},{range:t,options:{description:"quick-access-range-highlight-overview",overviewRuler:{color:o.themeColorFromId(o.overviewRulerRangeHighlight),position:a.OverviewRulerLane.Full}}}],[r,l]=i.deltaDecorations(n,s);this.rangeHighlightDecorationId={rangeHighlightId:r,overviewRulerDecorationId:l}})}clearDecorations(e){const t=this.rangeHighlightDecorationId;t&&(e.changeDecorations(i=>{i.deltaDecorations([t.overviewRulerDecorationId,t.rangeHighlightId],[])}),this.rangeHighlightDecorationId=void 0)}}const Ai=class Ai extends rC{constructor(){super({canAcceptInBackground:!0})}get useZeroBasedOffset(){return this.storageService.getBoolean(Ai.ZERO_BASED_OFFSET_STORAGE_KEY,-1,!1)}set useZeroBasedOffset(e){this.storageService.store(Ai.ZERO_BASED_OFFSET_STORAGE_KEY,e,-1,0)}provideWithoutTextEditor(e){const t=a.localize(1402,"Open a text editor first to go to a line or an offset.");return e.items=[{label:t}],e.ariaLabel=t,a.Disposable.None}provideWithTextEditor(e,t,i){const n=e.editor,s=new a.DisposableStore;t.ariaLabel=a.localize(1403,"Go to line. Type a line number, optionally followed by colon and column number."),s.add(t.onDidAccept(h=>{const[u]=t.selectedItems;if(u){if(!u.lineNumber)return;this.gotoLocation(e,{range:this.toRange(u.lineNumber,u.column),keyMods:t.keyMods,preserveFocus:h.inBackground}),h.inBackground||t.hide()}}));const r={iconClass:o.ThemeIcon.asClassName(a.Codicon.indexZero),tooltip:a.localize(1404,"Toggle Zero-Based Offset"),location:o.QuickInputButtonLocation.Input,toggle:{checked:this.useZeroBasedOffset}},l=()=>{const h=t.value.trim().substring(Ai.GO_TO_LINE_PREFIX.length),{inOffsetMode:u,lineNumber:g,column:p,label:f}=this.parsePosition(n,h);if(t.buttons=u?[r]:[],t.items=[{lineNumber:g,column:p,label:f,ariaLabel:g?a.localize(1405,"Go to line {0}, column {1}. Press Enter to navigate.",g,p||1):f}],!g){this.clearDecorations(n);return}const m=this.toRange(g,p);n.revealRangeInCenter(m,0),this.addDecorations(n,m)};s.add(t.onDidTriggerButton(h=>{h===r&&(this.useZeroBasedOffset=h.toggle?.checked??!this.useZeroBasedOffset,l())})),l(),s.add(t.onDidChangeValue(()=>l()));const d=o.getCodeEditor(n);return d&&d.getOptions().get(76).renderType===2&&(d.updateOptions({lineNumbers:"on"}),s.add(a.toDisposable(()=>d.updateOptions({lineNumbers:"relative"})))),s}toRange(e=1,t=1){return{startLineNumber:e,startColumn:t,endLineNumber:e,endColumn:t}}parsePosition(e,t){const i=this.getModel(e);if(!i)return{label:a.localize(1406,"Open a text editor first to go to a line or an offset.")};if(t.startsWith(":")){let n=parseInt(t.substring(1),10);const s=i.getValueLength();if(isNaN(n))return{inOffsetMode:!0,label:this.useZeroBasedOffset?a.localize(1407,"Type a character position to go to (from 0 to {0}).",s-1):a.localize(1408,"Type a character position to go to (from 1 to {0}).",s)};{const r=n<0;this.useZeroBasedOffset||(n-=Math.sign(n)),r&&(n+=s);const l=i.getPositionAt(n),d=o.CursorColumns.visibleColumnFromColumn(i.getLineContent(l.lineNumber),l.column,i.getOptions().tabSize)+1;return{...l,inOffsetMode:!0,label:a.localize(1409,"Press 'Enter' to go to line {0} at column {1}.",l.lineNumber,d)}}}else{const n=t.split(/,|:|#/),s=i.getLineCount();let r=parseInt(n[0]?.trim(),10);if(n.length<1||isNaN(r))return{label:a.localize(1410,"Type a line number to go to (from 1 to {0}).",s)};r=r>=0?r:s+1+r,r=Math.min(Math.max(1,r),s);const l=i.getOptions().tabSize,d=i.getLineContent(r),h=o.CursorColumns.visibleColumnFromColumn(d,i.getLineMaxColumn(r),l)+1;let u=parseInt(n[1]?.trim(),10);if(n.length<2||isNaN(u))return{lineNumber:r,column:1,label:n.length<2?a.localize(1411,"Press 'Enter' to go to line {0} or enter colon : to add a column number.",r):a.localize(1412,"Press 'Enter' to go to line {0} or enter a column number (from 1 to {1}).",r,h)};u=u>=0?u:h+u,u=Math.min(Math.max(1,u),h);const g=o.CursorColumns.columnFromVisibleColumn(d,u-1,l);return{lineNumber:r,column:g,label:a.localize(1413,"Press 'Enter' to go to line {0} at column {1}.",r,u)}}}};Ai.GO_TO_LINE_PREFIX=":",Ai.GO_TO_OFFSET_PREFIX="::",Ai.ZERO_BASED_OFFSET_STORAGE_KEY="gotoLine.useZeroBasedOffset";let sf=Ai;var fN=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},aC=function(c,e){return function(t,i){e(t,i,c)}};let ui=class extends sf{constructor(e,t){super(),this.editorService=e,this.storageService=t,this.onDidActiveTextEditorControlChange=a.Event.None}get activeTextEditorControl(){return this.editorService.getFocusedCodeEditor()??void 0}};ui=fN([aC(0,o.ICodeEditorService),aC(1,o.IStorageService)],ui);let lC=(ss=class extends o.EditorAction{constructor(){super({id:ss.ID,label:o.GoToLineNLS.gotoLineActionLabel,alias:"Go to Line/Column...",precondition:void 0,kbOpts:{kbExpr:o.EditorContextKeys.focus,primary:2085,mac:{primary:293},weight:100}})}run(e){e.get(o.IQuickInputService).quickAccess.show(ui.GO_TO_LINE_PREFIX)}},ss.ID="editor.action.gotoLine",ss);o.registerEditorAction(lC),o.Registry.as(o.Extensions$1.Quickaccess).registerQuickAccessProvider({ctor:ui,prefix:ui.GO_TO_LINE_PREFIX,helpEntries:[{description:o.GoToLineNLS.gotoLineActionLabel,commandId:lC.ID}]});const ud=class ud extends o.EditorAction{constructor(){super({id:ud.ID,label:o.GoToLineNLS.gotoOffsetActionLabel,alias:"Go to Offset...",precondition:void 0})}run(e){e.get(o.IQuickInputService).quickAccess.show(ui.GO_TO_OFFSET_PREFIX)}};ud.ID="editor.action.gotoOffset";let _c=ud;o.registerEditorAction(_c),o.Registry.as(o.Extensions$1.Quickaccess).registerQuickAccessProvider({ctor:ui,prefix:ui.GO_TO_OFFSET_PREFIX,helpEntries:[{description:o.GoToLineNLS.gotoOffsetActionLabel,commandId:_c.ID}]});const cC=[void 0,[]];function of(c,e,t=0,i=0){const n=e;return n.values&&n.values.length>1?mN(c,n.values,t,i):dC(c,e,t,i)}function mN(c,e,t,i){let n=0;const s=[];for(const r of e){const[l,d]=dC(c,r,t,i);if(typeof l!="number")return cC;n+=l,s.push(...d)}return[n,_N(s)]}function dC(c,e,t,i){const n=o.fuzzyScore(e.normalized,e.normalizedLowercase,t,c,c.toLowerCase(),i,{firstMatchCanBeWeak:!0,boostFullMatch:!0});return n?[n[0],o.createMatches(n)]:cC}new a.ConstantStringHash("allowNonContiguousMatches"),new a.ConstantStringHash("description"),new a.ConstantStringHash("label"),new a.ConstantStringHash("values"),new a.ConstantStringHash("expectContiguousMatch"),new a.ConstantStringHash("value");function _N(c){const e=c.sort((n,s)=>n.start-s.start),t=[];let i;for(const n of e)!i||!vN(i,n)?(i=n,t.push(n)):(i.start=Math.min(i.start,n.start),i.end=Math.max(i.end,n.end));return t}function vN(c,e){return!(c.end<e.start||e.end<c.start)}function hC(c){return c.startsWith('"')&&c.endsWith('"')}const uC=" ";function rf(c){typeof c!="string"&&(c="");const e=c.toLowerCase(),{pathNormalized:t,normalized:i,normalizedLowercase:n}=gC(c),s=t.indexOf(a.sep)>=0,r=hC(c);let l;const d=c.split(uC);if(d.length>1)for(const h of d){const u=hC(h),{pathNormalized:g,normalized:p,normalizedLowercase:f}=gC(h);p&&(l||(l=[]),l.push({original:h,originalLowercase:h.toLowerCase(),pathNormalized:g,normalized:p,normalizedLowercase:f,expectContiguousMatch:u}))}return{original:c,originalLowercase:e,pathNormalized:t,normalized:i,normalizedLowercase:n,values:l,containsPathSeparator:s,expectContiguousMatch:r}}function gC(c){let e;a.isWindows?e=c.replace(/\//g,a.sep):e=c.replace(/\\/g,a.sep);const t=e.replace(/[\*\u2026\s"]/g,"").replace(new RegExp("(?<=.)#$"),"");return{pathNormalized:e,normalized:t,normalizedLowercase:t.toLowerCase()}}function pC(c){return Array.isArray(c)?rf(c.map(e=>e.original).join(uC)):rf(c.original)}var bN=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},fC=function(c,e){return function(t,i){e(t,i,c)}},vc;let mn=(st=class extends rC{constructor(e,t,i=Object.create(null)){super(i),this._languageFeaturesService=e,this._outlineModelService=t,this.options=i,this.options.canAcceptInBackground=!0}provideWithoutTextEditor(e){return this.provideLabelPick(e,a.localize(1414,"To go to a symbol, first open a text editor with symbol information.")),a.Disposable.None}provideWithTextEditor(e,t,i,n){const s=e.editor,r=this.getModel(s);return r?this._languageFeaturesService.documentSymbolProvider.has(r)?this.doProvideWithEditorSymbols(e,r,t,i,n):this.doProvideWithoutEditorSymbols(e,r,t,i):a.Disposable.None}doProvideWithoutEditorSymbols(e,t,i,n){const s=new a.DisposableStore;return this.provideLabelPick(i,a.localize(1415,"The active text editor does not provide symbol information.")),(async()=>!await this.waitForLanguageSymbolRegistry(t,s)||n.isCancellationRequested||s.add(this.doProvideWithEditorSymbols(e,t,i,n)))(),s}provideLabelPick(e,t){e.items=[{label:t,index:0,kind:14}],e.ariaLabel=t}async waitForLanguageSymbolRegistry(e,t){if(this._languageFeaturesService.documentSymbolProvider.has(e))return!0;const i=new a.DeferredPromise,n=t.add(this._languageFeaturesService.documentSymbolProvider.onDidChange(()=>{this._languageFeaturesService.documentSymbolProvider.has(e)&&(n.dispose(),i.complete(!0))}));return t.add(a.toDisposable(()=>i.complete(!1))),i.p}doProvideWithEditorSymbols(e,t,i,n,s){const r=e.editor,l=new a.DisposableStore;l.add(i.onDidAccept(g=>{const[p]=i.selectedItems;if(p&&p.range){if(i.keyMods.shift&&p.attach){p.attach(i.keyMods,g);return}this.gotoLocation(e,{range:p.range.selection,keyMods:i.keyMods,preserveFocus:g.inBackground}),s?.handleAccept?.(p,g.inBackground),g.inBackground||i.hide()}})),l.add(i.onDidTriggerItemButton(({item:g})=>{g&&g.range&&(this.gotoLocation(e,{range:g.range.selection,keyMods:i.keyMods,forceSideBySide:!0}),i.hide())}));const d=this.getDocumentSymbols(t,n),h=l.add(new a.MutableDisposable),u=async g=>{h?.value?.cancel(),i.busy=!1,h.value=new a.CancellationTokenSource,i.busy=!0;try{const p=rf(i.value.substr(vc.PREFIX.length).trim()),f=await this.doGetSymbolPicks(d,p,void 0,h.value.token,t);if(n.isCancellationRequested)return;if(f.length>0){if(i.items=f,g&&p.original.length===0){const m=a.findLast(f,_=>!!(_.type!=="separator"&&_.range&&a.Range.containsPosition(_.range.decoration,g)));m&&(i.activeItems=[m])}}else p.original.length>0?this.provideLabelPick(i,a.localize(1416,"No matching editor symbols")):this.provideLabelPick(i,a.localize(1417,"No editor symbols"))}finally{n.isCancellationRequested||(i.busy=!1)}};return l.add(i.onDidChangeValue(()=>u(void 0))),u(r.getSelection()?.getPosition()),l.add(i.onDidChangeActive(()=>{const[g]=i.activeItems;g&&g.range&&(r.revealRangeInCenter(g.range.selection,0),this.addDecorations(r,g.range.decoration))})),l}async doGetSymbolPicks(e,t,i,n,s){const r=await e;if(n.isCancellationRequested)return[];const l=t.original.indexOf(vc.SCOPE_PREFIX)===0,d=l?1:0;let h,u;t.values&&t.values.length>1?(h=pC(t.values[0]),u=pC(t.values.slice(1))):h=t;let g;const p=this.options?.openSideBySideDirection?.();p&&(g=[{iconClass:p==="right"?o.ThemeIcon.asClassName(a.Codicon.splitHorizontal):o.ThemeIcon.asClassName(a.Codicon.splitVertical),tooltip:p==="right"?a.localize(1418,"Open to the Side"):a.localize(1419,"Open to the Bottom")}]);const f=[];for(let v=0;v<r.length;v++){const b=r[v],C=a.trim(b.name),y=`$(${a.SymbolKinds.toIcon(b.kind).id}) ${C}`,I=y.length-C.length;let x=b.containerName;i?.extraContainerLabel&&(x?x=`${i.extraContainerLabel} • ${x}`:x=i.extraContainerLabel);let S,w,E,L;if(t.original.length>d){let D=!1;if(h!==t&&([S,w]=of(y,{...t,values:void 0},d,I),typeof S=="number"&&(D=!0)),typeof S!="number"&&([S,w]=of(y,h,d,I),typeof S!="number"))continue;if(!D&&u){if(x&&u.original.length>0&&([E,L]=of(x,u)),typeof E!="number")continue;typeof S=="number"&&(S+=E)}}const R=b.tags&&b.tags.indexOf(1)>=0;f.push({index:v,kind:b.kind,score:S,label:y,ariaLabel:a.getAriaLabelForSymbol(b.name,b.kind),description:x,highlights:R?void 0:{label:w,description:L},range:{selection:a.Range.collapseToStart(b.selectionRange),decoration:b.range},uri:s.uri,symbolName:C,strikethrough:R,buttons:g})}const m=f.sort((v,b)=>l?this.compareByKindAndScore(v,b):this.compareByScore(v,b));let _=[];if(l){let y=function(){b&&typeof v=="number"&&C>0&&(b.label=a.format(lf[v]||af,C))},v,b,C=0;for(const I of m)v!==I.kind?(y(),v=I.kind,C=1,b={type:"separator"},_.push(b)):C++,_.push(I);y()}else m.length>0&&(_=[{label:a.localize(1420,"symbols ({0})",f.length),type:"separator"},...m]);return _}compareByScore(e,t){if(typeof e.score!="number"&&typeof t.score=="number")return 1;if(typeof e.score=="number"&&typeof t.score!="number")return-1;if(typeof e.score=="number"&&typeof t.score=="number"){if(e.score>t.score)return-1;if(e.score<t.score)return 1}return e.index<t.index?-1:e.index>t.index?1:0}compareByKindAndScore(e,t){const i=lf[e.kind]||af,n=lf[t.kind]||af,s=i.localeCompare(n);return s===0?this.compareByScore(e,t):s}async getDocumentSymbols(e,t){const i=await this._outlineModelService.getOrCreate(e,t);return t.isCancellationRequested?[]:i.asListOfDocumentSymbols()}},vc=st,st.PREFIX="@",st.SCOPE_PREFIX=":",st.PREFIX_BY_CATEGORY=`${st.PREFIX}${st.SCOPE_PREFIX}`,st);mn=vc=bN([fC(0,o.ILanguageFeaturesService),fC(1,qo)],mn);const af=a.localize(1421,"properties ({0})"),lf={5:a.localize(1422,"methods ({0})"),11:a.localize(1423,"functions ({0})"),8:a.localize(1424,"constructors ({0})"),12:a.localize(1425,"variables ({0})"),4:a.localize(1426,"classes ({0})"),22:a.localize(1427,"structs ({0})"),23:a.localize(1428,"events ({0})"),24:a.localize(1429,"operators ({0})"),10:a.localize(1430,"interfaces ({0})"),2:a.localize(1431,"namespaces ({0})"),3:a.localize(1432,"packages ({0})"),25:a.localize(1433,"type parameters ({0})"),1:a.localize(1434,"modules ({0})"),6:a.localize(1435,"properties ({0})"),9:a.localize(1436,"enumerations ({0})"),21:a.localize(1437,"enumeration members ({0})"),14:a.localize(1438,"strings ({0})"),0:a.localize(1439,"files ({0})"),17:a.localize(1440,"arrays ({0})"),15:a.localize(1441,"numbers ({0})"),16:a.localize(1442,"booleans ({0})"),18:a.localize(1443,"objects ({0})"),19:a.localize(1444,"keys ({0})"),7:a.localize(1445,"fields ({0})"),13:a.localize(1446,"constants ({0})")};var CN=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},cf=function(c,e){return function(t,i){e(t,i,c)}};let df=class extends mn{constructor(e,t,i){super(t,i),this.editorService=e,this.onDidActiveTextEditorControlChange=a.Event.None}get activeTextEditorControl(){return this.editorService.getFocusedCodeEditor()??void 0}};df=CN([cf(0,o.ICodeEditorService),cf(1,o.ILanguageFeaturesService),cf(2,qo)],df);const gd=class gd extends o.EditorAction{constructor(){super({id:gd.ID,label:o.QuickOutlineNLS.quickOutlineActionLabel,alias:"Go to Symbol...",precondition:o.EditorContextKeys.hasDocumentSymbolProvider,kbOpts:{kbExpr:o.EditorContextKeys.focus,primary:3117,weight:100},contextMenuOpts:{group:"navigation",order:3}})}run(e){e.get(o.IQuickInputService).quickAccess.show(mn.PREFIX,{itemActivation:o.ItemActivation.NONE})}};gd.ID="editor.action.quickOutline";let bc=gd;o.registerEditorAction(bc),o.Registry.as(o.Extensions$1.Quickaccess).registerQuickAccessProvider({ctor:df,prefix:mn.PREFIX,helpEntries:[{description:o.QuickOutlineNLS.quickOutlineActionLabel,prefix:mn.PREFIX,commandId:bc.ID},{description:o.QuickOutlineNLS.quickOutlineByCategoryActionLabel,prefix:mn.PREFIX_BY_CATEGORY}]});function SN(c){const e=new Map;for(const t of c)e.set(t,(e.get(t)??0)+1);return e}class $r{constructor(){this.chunkCount=0,this.chunkOccurrences=new Map,this.documents=new Map}calculateScores(e,t){const i=this.computeEmbedding(e),n=new Map,s=[];for(const[r,l]of this.documents){if(t.isCancellationRequested)return[];for(const d of l.chunks){const h=this.computeSimilarityScore(d,i,n);h>0&&s.push({key:r,score:h})}}return s}static termFrequencies(e){return SN($r.splitTerms(e))}static*splitTerms(e){const t=i=>i.toLowerCase();for(const[i]of e.matchAll(new RegExp("\\b\\p{Letter}[\\p{Letter}\\d]{2,}\\b","gu"))){yield t(i);const n=i.replace(/([a-z])([A-Z])/g,"$1 $2").split(/\s+/g);if(n.length>1)for(const s of n)s.length>2&&new RegExp("\\p{Letter}{3,}","gu").test(s)&&(yield t(s))}}updateDocuments(e){for(const{key:t}of e)this.deleteDocument(t);for(const t of e){const i=[];for(const n of t.textChunks){const s=$r.termFrequencies(n);for(const r of s.keys())this.chunkOccurrences.set(r,(this.chunkOccurrences.get(r)??0)+1);i.push({text:n,tf:s})}this.chunkCount+=i.length,this.documents.set(t.key,{chunks:i})}return this}deleteDocument(e){const t=this.documents.get(e);if(t){this.documents.delete(e),this.chunkCount-=t.chunks.length;for(const i of t.chunks)for(const n of i.tf.keys()){const s=this.chunkOccurrences.get(n);if(typeof s=="number"){const r=s-1;r<=0?this.chunkOccurrences.delete(n):this.chunkOccurrences.set(n,r)}}}}computeSimilarityScore(e,t,i){let n=0;for(const[s,r]of Object.entries(t)){const l=e.tf.get(s);if(!l)continue;let d=i.get(s);typeof d!="number"&&(d=this.computeIdf(s),i.set(s,d));const h=l*d;n+=h*r}return n}computeEmbedding(e){const t=$r.termFrequencies(e);return this.computeTfidf(t)}computeIdf(e){const t=this.chunkOccurrences.get(e)??0;return t>0?Math.log((this.chunkCount+1)/t):0}computeTfidf(e){const t=Object.create(null);for(const[i,n]of e){const s=this.computeIdf(i);s>0&&(t[i]=n*s)}return t}}function yN(c){const e=c.slice(0);e.sort((i,n)=>n.score-i.score);const t=e[0]?.score??0;if(t>0)for(const i of e)i.score/=t;return e}var gi;(function(c){c[c.NO_ACTION=0]="NO_ACTION",c[c.CLOSE_PICKER=1]="CLOSE_PICKER",c[c.REFRESH_PICKER=2]="REFRESH_PICKER",c[c.REMOVE_ITEM=3]="REMOVE_ITEM"})(gi||(gi={}));function hf(c){return Array.isArray(c.items)}function mC(c){const e=c;return!!e.picks&&e.additionalPicks instanceof Promise}class wN extends a.Disposable{constructor(e,t){super(),this.prefix=e,this.options=t}provide(e,t,i){const n=new a.DisposableStore;e.canAcceptInBackground=!!this.options?.canAcceptInBackground,e.matchOnLabel=e.matchOnDescription=e.matchOnDetail=e.sortByLabel=!1;let s;const r=n.add(new a.MutableDisposable),l=async()=>{s?.dispose(!0),e.busy=!1;const h=r.value=new a.DisposableStore;s=h.add(new a.CancellationTokenSource(t));const u=s.token;let g=e.value.substring(this.prefix.length);this.options?.shouldSkipTrimPickFilter||(g=g.trim());const p=this._getPicks(g,h,u,i),f=(_,v)=>{let b,C;if(hf(_)?(b=_.items,C=_.active):b=_,b.length===0){if(v)return!1;(g.length>0||e.hideInput)&&this.options?.noResultsPick&&(a.isFunction(this.options.noResultsPick)?b=[this.options.noResultsPick(g)]:b=[this.options.noResultsPick])}return e.items=b,C&&(e.activeItems=[C]),!0},m=async _=>{let v=!1,b=!1;await Promise.all([(async()=>{typeof _.mergeDelay=="number"&&(await a.timeout(_.mergeDelay),u.isCancellationRequested)||b||(v=f(_.picks,!0))})(),(async()=>{e.busy=!0;try{const C=await _.additionalPicks;if(u.isCancellationRequested)return;let y,I;hf(_.picks)?(y=_.picks.items,I=_.picks.active):y=_.picks;let x,S;if(hf(C)?(x=C.items,S=C.active):x=C,x.length>0||!v){let w;if(!I&&!S){const E=e.activeItems[0];E&&y.indexOf(E)!==-1&&(w=E)}f({items:[...y,...x],active:I||S||w})}}finally{u.isCancellationRequested||(e.busy=!1),b=!0}})()])};if(p!==null)if(mC(p))await m(p);else if(!(p instanceof Promise))f(p);else{e.busy=!0;try{const _=await p;if(u.isCancellationRequested)return;mC(_)?await m(_):f(_)}finally{u.isCancellationRequested||(e.busy=!1)}}};n.add(e.onDidChangeValue(()=>l())),l(),n.add(e.onDidAccept(h=>{if(i?.handleAccept){h.inBackground||e.hide(),i.handleAccept?.(e.activeItems[0],h.inBackground);return}const[u]=e.selectedItems;if(typeof u?.accept=="function"){if(o.isKeyModified(e.keyMods)&&!!u.attach){u.attach(e.keyMods,h);return}h.inBackground||e.hide(),u.accept(e.keyMods,h)}}));const d=async(h,u)=>{if(typeof u.trigger!="function")return;const g=u.buttons?.indexOf(h)??-1;if(g>=0){const p=u.trigger(g,e.keyMods),f=typeof p=="number"?p:await p;if(t.isCancellationRequested)return;switch(f){case gi.NO_ACTION:break;case gi.CLOSE_PICKER:e.hide();break;case gi.REFRESH_PICKER:l();break;case gi.REMOVE_ITEM:{const m=e.items.indexOf(u);if(m!==-1){const _=e.items.slice(),v=_.splice(m,1),b=e.activeItems.filter(y=>y!==v[0]),C=e.keepScrollPosition;e.keepScrollPosition=!0,e.items=_,b&&(e.activeItems=b),e.keepScrollPosition=C}break}}}};return n.add(e.onDidTriggerItemButton(({button:h,item:u})=>d(h,u))),n.add(e.onDidTriggerSeparatorButton(({button:h,separator:u})=>d(h,u))),n}}var _C=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},pi=function(c,e){return function(t,i){e(t,i,c)}},_n,J;let uf=(St=class extends wN{constructor(e,t,i,n,s,r){super(_n.PREFIX,e),this.keybindingService=i,this.commandService=n,this.telemetryService=s,this.dialogService=r,this.commandsHistory=this._register(t.createInstance(gf)),this.options=e}async _getPicks(e,t,i,n){const s=await this.getCommandPicks(i);if(i.isCancellationRequested)return[];const r=a.createSingleCallFunction(()=>{const f=new $r;f.updateDocuments(s.map(_=>({key:_.commandId,textChunks:[this.getTfIdfChunk(_)]})));const m=f.calculateScores(e,i);return yN(m).filter(_=>_.score>_n.TFIDF_THRESHOLD).slice(0,_n.TFIDF_MAX_RESULTS)}),l=[];for(const f of s){const m=_n.WORD_FILTER(e,f.label)??void 0;let _;if(f.commandAlias&&(_=_n.WORD_FILTER(e,f.commandAlias)??void 0),m||_)f.highlights={label:m,detail:this.options.showAlias?_:void 0},l.push(f);else if(e===f.commandId)l.push(f);else if(e.length>=3){const v=r();if(i.isCancellationRequested)return[];const b=v.find(C=>C.key===f.commandId);b&&(f.tfIdfScore=b.score,l.push(f))}}const d=new Map;for(const f of l){const m=d.get(f.label);m?(f.description=f.commandId,m.description=m.commandId):d.set(f.label,f)}l.sort((f,m)=>{if(f.tfIdfScore&&m.tfIdfScore)return f.tfIdfScore===m.tfIdfScore?f.label.localeCompare(m.label):m.tfIdfScore-f.tfIdfScore;if(f.tfIdfScore)return 1;if(m.tfIdfScore)return-1;const _=this.commandsHistory.peek(f.commandId),v=this.commandsHistory.peek(m.commandId);if(_&&v)return _>v?-1:1;if(_)return-1;if(v)return 1;if(this.options.suggestedCommandIds){const y=this.options.suggestedCommandIds.has(f.commandId),I=this.options.suggestedCommandIds.has(m.commandId);if(y&&I)return 0;if(y)return-1;if(I)return 1}const b=f.commandCategory===Mp.Developer.value,C=m.commandCategory===Mp.Developer.value;return b&&!C?1:!b&&C?-1:f.label.localeCompare(m.label)});const h=[];let u=!1,g=!0,p=!!this.options.suggestedCommandIds;for(let f=0;f<l.length;f++){const m=l[f],_=!!this.commandsHistory.peek(m.commandId);f===0&&_&&(h.push({type:"separator",label:a.localize(1836,"recently used")}),u=!0),g&&m.tfIdfScore!==void 0&&(h.push({type:"separator",label:a.localize(1837,"similar commands")}),g=!1),p&&m.tfIdfScore===void 0&&!_&&this.options.suggestedCommandIds?.has(m.commandId)&&(h.push({type:"separator",label:a.localize(1838,"commonly used")}),u=!0,p=!1),u&&m.tfIdfScore===void 0&&!_&&!this.options.suggestedCommandIds?.has(m.commandId)&&(h.push({type:"separator",label:a.localize(1839,"other commands")}),u=!1),h.push(this.toCommandPick(m,n,_))}return this.hasAdditionalCommandPicks(e,i)?{picks:h,additionalPicks:(async()=>{const f=await this.getAdditionalCommandPicks(s,l,e,i);if(i.isCancellationRequested)return[];const m=f.map(_=>this.toCommandPick(_,n));return g&&m[0]?.type!=="separator"&&m.unshift({type:"separator",label:a.localize(1840,"similar commands")}),m})()}:h}toCommandPick(e,t,i=!1){if(e.type==="separator")return e;const n=e.tooltip??e.commandDescription?.value,s=this.keybindingService.lookupKeybinding(e.commandId),r=s?a.localize(1841,"{0}, {1}",e.label,s.getAriaLabel()):e.label,l=e.buttons||[],d=i?[...l,{iconClass:o.ThemeIcon.asClassName(a.Codicon.close),tooltip:a.localize(1842,"Remove from Recently Used")}]:e.buttons;return{...e,id:e.commandId,tooltip:n,ariaLabel:r,detail:this.options.showAlias&&e.commandAlias!==e.label?e.commandAlias:void 0,keybinding:s,buttons:d,accept:async()=>{this.commandsHistory.push(e.commandId),this.telemetryService.publicLog2("workbenchActionExecuted",{id:e.commandId,from:t?.from??"quick open"});try{e.args?.length?await this.commandService.executeCommand(e.commandId,...e.args):await this.commandService.executeCommand(e.commandId)}catch(h){a.isCancellationError(h)||this.dialogService.error(a.localize(1843,"Command '{0}' resulted in an error",e.label),Hr(h))}},trigger:i?(h,u)=>{const g=l.length;return h===g?(this.commandsHistory.remove(e.commandId),gi.REMOVE_ITEM):e.trigger?e.trigger(h,u):gi.NO_ACTION}:e.trigger}}getTfIdfChunk({label:e,commandAlias:t,commandDescription:i}){let n=e;return t&&t!==e&&(n+=` - ${t}`),i&&i.value!==e&&(n+=` - ${i.value===i.original?i.value:`${i.value} (${i.original})`}`),n}},_n=St,St.PREFIX=">",St.TFIDF_THRESHOLD=.5,St.TFIDF_MAX_RESULTS=5,St.WORD_FILTER=o.or(o.matchesBaseContiguousSubString,o.matchesWords),St);uf=_n=_C([pi(1,o.IInstantiationService),pi(2,o.IKeybindingService),pi(3,o.ICommandService),pi(4,o.ITelemetryService),pi(5,o.IDialogService)],uf);let gf=(ot=class extends a.Disposable{constructor(e,t,i){super(),this.storageService=e,this.configurationService=t,this.logService=i,this.configuredCommandsHistoryLength=0,this.updateConfiguration(),this.load(),this.registerListeners()}registerListeners(){this._register(this.configurationService.onDidChangeConfiguration(e=>this.updateConfiguration(e))),this._register(this.storageService.onWillSaveState(e=>{e.reason===o.WillSaveStateReason.SHUTDOWN&&this.saveState()}))}updateConfiguration(e){e&&!e.affectsConfiguration("workbench.commandPalette.history")||(this.configuredCommandsHistoryLength=J.getConfiguredCommandHistoryLength(this.configurationService),J.cache&&J.cache.limit!==this.configuredCommandsHistoryLength&&(J.cache.limit=this.configuredCommandsHistoryLength,J.hasChanges=!0))}load(){const e=this.storageService.get(J.PREF_KEY_CACHE,0);let t;if(e)try{t=JSON.parse(e)}catch(n){this.logService.error(`[CommandsHistory] invalid data: ${n}`)}const i=J.cache=new a.LRUCache(this.configuredCommandsHistoryLength,1);if(t){let n;t.usesLRU?n=t.entries:n=t.entries.sort((s,r)=>s.value-r.value),n.forEach(s=>i.set(s.key,s.value))}J.counter=this.storageService.getNumber(J.PREF_KEY_COUNTER,0,J.counter)}push(e){J.cache&&(J.cache.set(e,J.counter++),J.hasChanges=!0)}peek(e){return J.cache?.peek(e)}remove(e){J.cache&&(J.cache.delete(e),J.hasChanges=!0)}saveState(){if(!J.cache||!J.hasChanges)return;const e={usesLRU:!0,entries:[]};J.cache.forEach((t,i)=>e.entries.push({key:i,value:t})),this.storageService.store(J.PREF_KEY_CACHE,JSON.stringify(e),0,0),this.storageService.store(J.PREF_KEY_COUNTER,J.counter,0,0),J.hasChanges=!1}static getConfiguredCommandHistoryLength(e){const i=e.getValue().workbench?.commandPalette?.history;return typeof i=="number"?i:J.DEFAULT_COMMANDS_HISTORY_LENGTH}},J=ot,ot.DEFAULT_COMMANDS_HISTORY_LENGTH=50,ot.PREF_KEY_CACHE="commandPalette.mru.cache",ot.PREF_KEY_COUNTER="commandPalette.mru.counter",ot.counter=1,ot.hasChanges=!1,ot);gf=J=_C([pi(0,o.IStorageService),pi(1,o.IConfigurationService),pi(2,o.ILogService)],gf);class IN extends uf{constructor(e,t,i,n,s,r){super(e,t,i,n,s,r)}getCodeEditorCommandPicks(){const e=this.activeTextEditorControl;if(!e)return[];const t=[];for(const i of e.getSupportedActions()){let n;i.metadata?.description&&(o.isLocalizedString(i.metadata.description)?n=i.metadata.description:n={original:i.metadata.description,value:i.metadata.description}),t.push({commandId:i.id,commandAlias:i.alias,commandDescription:n,label:o.stripIcons(i.label)||i.id})}return t}}var xN=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Qs=function(c,e){return function(t,i){e(t,i,c)}};let jr=class extends IN{get activeTextEditorControl(){return this.codeEditorService.getFocusedCodeEditor()??void 0}constructor(e,t,i,n,s,r){super({showAlias:!1},e,i,n,s,r),this.codeEditorService=t}async getCommandPicks(){return this.getCodeEditorCommandPicks()}hasAdditionalCommandPicks(){return!1}async getAdditionalCommandPicks(){return[]}};jr=xN([Qs(0,o.IInstantiationService),Qs(1,o.ICodeEditorService),Qs(2,o.IKeybindingService),Qs(3,o.ICommandService),Qs(4,o.ITelemetryService),Qs(5,o.IDialogService)],jr);const pd=class pd extends o.EditorAction{constructor(){super({id:pd.ID,label:o.QuickCommandNLS.quickCommandActionLabel,alias:"Command Palette",precondition:void 0,kbOpts:{kbExpr:o.EditorContextKeys.focus,primary:59,weight:100},contextMenuOpts:{group:"z_commands",order:1}})}run(e){e.get(o.IQuickInputService).quickAccess.show(jr.PREFIX)}};pd.ID="editor.action.quickCommand";let Cc=pd;o.registerEditorAction(Cc),o.Registry.as(o.Extensions$1.Quickaccess).registerQuickAccessProvider({ctor:jr,prefix:jr.PREFIX,helpEntries:[{description:o.QuickCommandNLS.quickCommandHelp,commandId:Cc.ID}]});var EN=function(c,e,t,i){var n=arguments.length,s=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(c,e,t,i);else for(var l=c.length-1;l>=0;l--)(r=c[l])&&(s=(n<3?r(s):n>3?r(e,t,s):r(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},Js=function(c,e){return function(t,i){e(t,i,c)}};let pf=class extends nn{constructor(e,t,i,n,s,r,l){super(!0,e,t,i,n,s,r,l)}};pf=EN([Js(1,o.IContextKeyService),Js(2,o.ICodeEditorService),Js(3,o.INotificationService),Js(4,o.IInstantiationService),Js(5,o.IStorageService),Js(6,o.IConfigurationService)],pf),o.registerEditorContribution(nn.ID,pf,4);class LN extends o.EditorAction{constructor(){super({id:"editor.action.toggleHighContrast",label:o.ToggleHighContrastNLS.toggleHighContrast,alias:"Toggle High Contrast Theme",precondition:void 0}),this._originalThemeName=null}run(e,t){const i=e.get(o.IStandaloneThemeService),n=i.getColorTheme();o.isHighContrast(n.type)?(i.setTheme(this._originalThemeName||(o.isDark(n.type)?o.VS_DARK_THEME_NAME:o.VS_LIGHT_THEME_NAME)),this._originalThemeName=null):(i.setTheme(o.isDark(n.type)?o.HC_BLACK_THEME_NAME:o.HC_LIGHT_THEME_NAME),this._originalThemeName=n.themeName)}}o.registerEditorAction(LN),vC.FindWidget=va}));