@kingsoftcloud/ksadk-web 0.2.7 → 0.2.8

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 (104) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +14 -3
  3. package/dist-ksadk/assets/{ArtifactsPanel-CMS54WAp.js → ArtifactsPanel-Z9gYhqIC.js} +1 -1
  4. package/dist-ksadk/assets/{CodeBlock-CHZaDmho.js → CodeBlock-BK8ioKOV.js} +1 -1
  5. package/dist-ksadk/assets/{MathMessageMarkdown-Cx9VSNQ8.js → MathMessageMarkdown-D1NgYJhw.js} +1 -1
  6. package/dist-ksadk/assets/{MermaidBlock-CV56XpfU.js → MermaidBlock-Cgzb0dEp.js} +6 -6
  7. package/dist-ksadk/assets/{NativeTerminalPanel-BrbZygfC.js → NativeTerminalPanel-Cyqpkjbr.js} +1 -1
  8. package/dist-ksadk/assets/{arc-D3eSpKQi.js → arc-B8XCYxQr.js} +1 -1
  9. package/dist-ksadk/assets/architecture-7EHR7CIX-C-uhPv8O.js +1 -0
  10. package/dist-ksadk/assets/{architectureDiagram-3BPJPVTR-DLe5RfvU.js → architectureDiagram-3BPJPVTR-BGRXkycc.js} +1 -1
  11. package/dist-ksadk/assets/{blockDiagram-GPEHLZMM-jrFAO8Bq.js → blockDiagram-GPEHLZMM-ivIHWi2C.js} +1 -1
  12. package/dist-ksadk/assets/{c4Diagram-AAUBKEIU-BFwiG9fe.js → c4Diagram-AAUBKEIU-WIhL3FVN.js} +1 -1
  13. package/dist-ksadk/assets/channel-Ci9yKHuZ.js +1 -0
  14. package/dist-ksadk/assets/{chunk-2J33WTMH-5Qlobtnj.js → chunk-2J33WTMH-CY-mD8DJ.js} +1 -1
  15. package/dist-ksadk/assets/{chunk-4BX2VUAB-ou66Tq9f.js → chunk-4BX2VUAB-Cy9gwj_G.js} +1 -1
  16. package/dist-ksadk/assets/{chunk-55IACEB6-CDvMSeFu.js → chunk-55IACEB6-kLgiYAgg.js} +1 -1
  17. package/dist-ksadk/assets/{chunk-727SXJPM-t3ZfYPXH.js → chunk-727SXJPM-DPKu7-e-.js} +1 -1
  18. package/dist-ksadk/assets/{chunk-AQP2D5EJ-CqPYcHtF.js → chunk-AQP2D5EJ-HIdrXcue.js} +1 -1
  19. package/dist-ksadk/assets/{chunk-FMBD7UC4-C79rRamw.js → chunk-FMBD7UC4-9_-0Mwod.js} +1 -1
  20. package/dist-ksadk/assets/{chunk-ND2GUHAM-EqP27pbM.js → chunk-ND2GUHAM-rQfUwpN0.js} +1 -1
  21. package/dist-ksadk/assets/chunk-QZHKN3VN-DBcvEZ0d.js +1 -0
  22. package/dist-ksadk/assets/classDiagram-4FO5ZUOK-D6n5-2lp.js +1 -0
  23. package/dist-ksadk/assets/classDiagram-v2-Q7XG4LA2-D6n5-2lp.js +1 -0
  24. package/dist-ksadk/assets/{cose-bilkent-S5V4N54A-QMqM6zta.js → cose-bilkent-S5V4N54A-bNtnGuJb.js} +1 -1
  25. package/dist-ksadk/assets/{dagre-BM42HDAG-CEakrtKq.js → dagre-BM42HDAG-DZY9agUg.js} +1 -1
  26. package/dist-ksadk/assets/{diagram-2AECGRRQ-BxdbhhCX.js → diagram-2AECGRRQ-BcCcFBXZ.js} +1 -1
  27. package/dist-ksadk/assets/{diagram-5GNKFQAL-DBpIlxtZ.js → diagram-5GNKFQAL-91Ll9YWG.js} +1 -1
  28. package/dist-ksadk/assets/{diagram-KO2AKTUF-D4COO3HT.js → diagram-KO2AKTUF-BBIIxvwB.js} +1 -1
  29. package/dist-ksadk/assets/{diagram-LMA3HP47-DBSZ6aUz.js → diagram-LMA3HP47-DxWrcR2m.js} +1 -1
  30. package/dist-ksadk/assets/{diagram-OG6HWLK6-CxLsy00E.js → diagram-OG6HWLK6-D0HI_jcf.js} +1 -1
  31. package/dist-ksadk/assets/{dist-BeLlHcxS.js → dist-7Jji4hMv.js} +1 -1
  32. package/dist-ksadk/assets/{dist-z5-DHNYg.js → dist-B8czu-Qc.js} +1 -1
  33. package/dist-ksadk/assets/{dist-Cpz8Cm0v.js → dist-B9a_6axG.js} +1 -1
  34. package/dist-ksadk/assets/{dist-BEmeO2N2.js → dist-BAQH6Sdn.js} +1 -1
  35. package/dist-ksadk/assets/{dist-DGm-pByN.js → dist-BBayeLLe.js} +1 -1
  36. package/dist-ksadk/assets/{dist-Cxij5I4C.js → dist-BXA3YG1m.js} +1 -1
  37. package/dist-ksadk/assets/{dist-CTCQXcX7.js → dist-C--QxXYi.js} +1 -1
  38. package/dist-ksadk/assets/{dist-BWf6mC8G.js → dist-CA8U0v5G.js} +1 -1
  39. package/dist-ksadk/assets/{dist-DxJZpRF1.js → dist-CsFBiJzz.js} +1 -1
  40. package/dist-ksadk/assets/{dist-Cqzpy7oO.js → dist-Cu40b2RQ.js} +1 -1
  41. package/dist-ksadk/assets/{dist-CJmvMGxs.js → dist-D0cssRbL.js} +1 -1
  42. package/dist-ksadk/assets/{dist-CqCrM4le.js → dist-DJeSTOZu.js} +1 -1
  43. package/dist-ksadk/assets/{dist-CXnbkk51.js → dist-DeIyG_Yw.js} +1 -1
  44. package/dist-ksadk/assets/{dist-aq2knWnw.js → dist-DgPAQK3Q.js} +1 -1
  45. package/dist-ksadk/assets/{dist-C4IRfjf3.js → dist-DpPvxuVN.js} +1 -1
  46. package/dist-ksadk/assets/{dist-JOlStfdO.js → dist-Dv3mIdmJ.js} +1 -1
  47. package/dist-ksadk/assets/{dist-D_gCRUxt.js → dist-J2Ks-ZqQ.js} +1 -1
  48. package/dist-ksadk/assets/{dist-DqLb8QP7.js → dist-UxQaQA4j.js} +1 -1
  49. package/dist-ksadk/assets/{dist-DelwQd2b.js → dist-Z8OZFHSc.js} +1 -1
  50. package/dist-ksadk/assets/{dist-6WsdpRSO.js → dist-jY01heep.js} +1 -1
  51. package/dist-ksadk/assets/{dist-BOHSAqwD.js → dist-qU1gRG7_.js} +1 -1
  52. package/dist-ksadk/assets/{dist-O8eCswTX.js → dist-uPv3jeT5.js} +1 -1
  53. package/dist-ksadk/assets/{erDiagram-TEJ5UH35-CsjpG1Xb.js → erDiagram-TEJ5UH35-DgCMVp9E.js} +1 -1
  54. package/dist-ksadk/assets/eventmodeling-FCH6USID-B_sBONqE.js +1 -0
  55. package/dist-ksadk/assets/{flowDiagram-I6XJVG4X-DZo3QdjC.js → flowDiagram-I6XJVG4X-DN-muBt0.js} +1 -1
  56. package/dist-ksadk/assets/{ganttDiagram-6RSMTGT7-BGeXMpCW.js → ganttDiagram-6RSMTGT7-H5vifLHR.js} +1 -1
  57. package/dist-ksadk/assets/gitGraph-WXDBUCRP-DXIxi1x7.js +1 -0
  58. package/dist-ksadk/assets/{gitGraphDiagram-PVQCEYII-CEgx70IJ.js → gitGraphDiagram-PVQCEYII-Dl4neKoT.js} +1 -1
  59. package/dist-ksadk/assets/{index-DiS5sSwc.js → index-D5_6kUT7.js} +5 -5
  60. package/dist-ksadk/assets/info-J43DQDTF-D4tIflDz.js +1 -0
  61. package/dist-ksadk/assets/{infoDiagram-5YYISTIA-D7Mjh6YU.js → infoDiagram-5YYISTIA-eO_oIRLZ.js} +1 -1
  62. package/dist-ksadk/assets/{ishikawaDiagram-YF4QCWOH-Dd4tDuCg.js → ishikawaDiagram-YF4QCWOH-CJSADXug.js} +1 -1
  63. package/dist-ksadk/assets/{journeyDiagram-JHISSGLW-D8l_bo2Y.js → journeyDiagram-JHISSGLW-DnORHBWj.js} +1 -1
  64. package/dist-ksadk/assets/{kanban-definition-UN3LZRKU-CPTqBqad.js → kanban-definition-UN3LZRKU-DOrZlejw.js} +1 -1
  65. package/dist-ksadk/assets/{katex-Cj6SHGk0.js → katex-Bak1iKwY.js} +1 -1
  66. package/dist-ksadk/assets/{linear-CtOo2EUV.js → linear-DkEeqtZQ.js} +1 -1
  67. package/dist-ksadk/assets/{mermaid-parser.core-BeKhTKTv.js → mermaid-parser.core-Pkp3v6Nd.js} +2 -2
  68. package/dist-ksadk/assets/{mindmap-definition-RKZ34NQL-Cyeeb4Uv.js → mindmap-definition-RKZ34NQL-Dh20TZFT.js} +1 -1
  69. package/dist-ksadk/assets/packet-YPE3B663-D_sVaF4e.js +1 -0
  70. package/dist-ksadk/assets/pie-LRSECV5Y-BBQErvVp.js +1 -0
  71. package/dist-ksadk/assets/{pieDiagram-4H26LBE5-CYoruq9a.js → pieDiagram-4H26LBE5-CYMD4pWv.js} +1 -1
  72. package/dist-ksadk/assets/{quadrantDiagram-W4KKPZXB-9Iyq0jYH.js → quadrantDiagram-W4KKPZXB-Ck4oAyPK.js} +1 -1
  73. package/dist-ksadk/assets/radar-GUYGQ44K-C_YJqhWD.js +1 -0
  74. package/dist-ksadk/assets/{requirementDiagram-4Y6WPE33-Dm-mLxH0.js → requirementDiagram-4Y6WPE33-BdIO_5Zu.js} +1 -1
  75. package/dist-ksadk/assets/{sankeyDiagram-5OEKKPKP-BhpH0-7G.js → sankeyDiagram-5OEKKPKP-C_wJgAIG.js} +1 -1
  76. package/dist-ksadk/assets/{sequenceDiagram-3UESZ5HK-DUPsgMMP.js → sequenceDiagram-3UESZ5HK-s-Vxixrb.js} +1 -1
  77. package/dist-ksadk/assets/{stateDiagram-AJRCARHV-XbM4cbgm.js → stateDiagram-AJRCARHV-DKP5_2dP.js} +1 -1
  78. package/dist-ksadk/assets/stateDiagram-v2-BHNVJYJU-ccBp8leq.js +1 -0
  79. package/dist-ksadk/assets/{timeline-definition-PNZ67QCA-Tday4gED.js → timeline-definition-PNZ67QCA-SkcJBZyI.js} +1 -1
  80. package/dist-ksadk/assets/treeView-BLDUP644-BszQ3ftU.js +1 -0
  81. package/dist-ksadk/assets/treemap-LRROVOQU-DJwCPK-A.js +1 -0
  82. package/dist-ksadk/assets/{vennDiagram-CIIHVFJN-BOg1GA8S.js → vennDiagram-CIIHVFJN-C7xBs0Ud.js} +1 -1
  83. package/dist-ksadk/assets/wardley-L42UT6IY-BSARP5Ll.js +1 -0
  84. package/dist-ksadk/assets/{wardleyDiagram-YWT4CUSO-Cy5RnJwi.js → wardleyDiagram-YWT4CUSO-D3oLVyk-.js} +1 -1
  85. package/dist-ksadk/assets/{xychartDiagram-2RQKCTM6-DHamdSL0.js → xychartDiagram-2RQKCTM6-BG-2oHar.js} +1 -1
  86. package/dist-ksadk/index.html +1 -1
  87. package/dist-lib/App.d.ts.map +1 -1
  88. package/dist-lib/runtime.js +15 -16
  89. package/package.json +1 -1
  90. package/dist-ksadk/assets/architecture-7EHR7CIX-aKvaoHF-.js +0 -1
  91. package/dist-ksadk/assets/channel-BNEchGhD.js +0 -1
  92. package/dist-ksadk/assets/chunk-QZHKN3VN-DVqYdfgL.js +0 -1
  93. package/dist-ksadk/assets/classDiagram-4FO5ZUOK-DoFK3UDf.js +0 -1
  94. package/dist-ksadk/assets/classDiagram-v2-Q7XG4LA2-DoFK3UDf.js +0 -1
  95. package/dist-ksadk/assets/eventmodeling-FCH6USID-CnNj0sZg.js +0 -1
  96. package/dist-ksadk/assets/gitGraph-WXDBUCRP-CYAnXGvP.js +0 -1
  97. package/dist-ksadk/assets/info-J43DQDTF-CqhaeVQF.js +0 -1
  98. package/dist-ksadk/assets/packet-YPE3B663-D42EsLYz.js +0 -1
  99. package/dist-ksadk/assets/pie-LRSECV5Y-Cgre-V_q.js +0 -1
  100. package/dist-ksadk/assets/radar-GUYGQ44K-_FsLsLP1.js +0 -1
  101. package/dist-ksadk/assets/stateDiagram-v2-BHNVJYJU-C1h6ve7b.js +0 -1
  102. package/dist-ksadk/assets/treeView-BLDUP644-5bkV6oHA.js +0 -1
  103. package/dist-ksadk/assets/treemap-LRROVOQU-Ck8wquEY.js +0 -1
  104. package/dist-ksadk/assets/wardley-L42UT6IY-DPQZ7fpa.js +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./MathMessageMarkdown-Cx9VSNQ8.js","./CodeBlock-CHZaDmho.js","./MermaidBlock-CV56XpfU.js","./katex-Cj6SHGk0.js","./MathMessageMarkdown-DeYh8QPr.css","./NativeTerminalPanel-BrbZygfC.js","./NativeTerminalPanel-CHOd7Rch.css","./dist-CXnbkk51.js","./dist-BeLlHcxS.js","./dist-6WsdpRSO.js","./dist-DqLb8QP7.js","./dist-JOlStfdO.js","./dist-DxJZpRF1.js","./dist-Cxij5I4C.js","./dist-DGm-pByN.js","./dist-z5-DHNYg.js","./dist-C4IRfjf3.js","./dist-CJmvMGxs.js","./dist-aq2knWnw.js","./dist-BOHSAqwD.js","./dist-DelwQd2b.js","./dist-O8eCswTX.js","./dist-BEmeO2N2.js","./dist-CTCQXcX7.js","./dist-CqCrM4le.js","./dist-Cqzpy7oO.js","./dist-BWf6mC8G.js","./dockerfile-BLkNEvjs.js","./simple-mode-DRpGK0lJ.js","./factor-D7LVTn2l.js","./nsis-AQ_alPln.js","./pug-Bugr-47h.js","./javascript-9Tg8ixDm.js","./dist-D_gCRUxt.js","./dist-Cpz8Cm0v.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./MathMessageMarkdown-D1NgYJhw.js","./CodeBlock-BK8ioKOV.js","./MermaidBlock-Cgzb0dEp.js","./katex-Bak1iKwY.js","./MathMessageMarkdown-DeYh8QPr.css","./NativeTerminalPanel-Cyqpkjbr.js","./NativeTerminalPanel-CHOd7Rch.css","./dist-DeIyG_Yw.js","./dist-7Jji4hMv.js","./dist-jY01heep.js","./dist-UxQaQA4j.js","./dist-Dv3mIdmJ.js","./dist-CsFBiJzz.js","./dist-BXA3YG1m.js","./dist-BBayeLLe.js","./dist-B8czu-Qc.js","./dist-DpPvxuVN.js","./dist-D0cssRbL.js","./dist-DgPAQK3Q.js","./dist-qU1gRG7_.js","./dist-Z8OZFHSc.js","./dist-uPv3jeT5.js","./dist-BAQH6Sdn.js","./dist-C--QxXYi.js","./dist-DJeSTOZu.js","./dist-Cu40b2RQ.js","./dist-CA8U0v5G.js","./dockerfile-BLkNEvjs.js","./simple-mode-DRpGK0lJ.js","./factor-D7LVTn2l.js","./nsis-AQ_alPln.js","./pug-Bugr-47h.js","./javascript-9Tg8ixDm.js","./dist-J2Ks-ZqQ.js","./dist-B9a_6axG.js"])))=>i.map(i=>d[i]);
2
2
  var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var u=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&ne(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&ne(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var ee=new MessageChannel,te=ee.port2;ee.port1.onmessage=D,O=function(){te.postMessage(null)}}else O=function(){_(D,0)};function ne(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,ne(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),d=o(((e,t)=>{t.exports=u()})),f=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function ee(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var te=/\/+/g;function ne(e,t){return typeof e==`object`&&e&&e.key!=null?ee(``+e.key):t.toString(36)}function re(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function ie(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,ie(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+ne(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(te,`$&/`)+`/`),ie(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(te,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+ne(a,u),c+=ie(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+ne(a,u++),c+=ie(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return ie(re(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function ae(e,t,n){if(e==null)return e;var r=[],i=0;return ie(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function oe(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var k=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},A={map:ae,forEach:function(e,t,n){ae(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return ae(e,function(){t++}),t},toArray:function(e){return ae(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=A,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:oe}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,k)}catch(e){k(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.4`})),p=o(((e,t)=>{t.exports=f()})),m=o((e=>{var t=p();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.4`})),h=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=m()})),g=o((e=>{var t=d(),n=p(),r=h();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}var m=Object.assign,g=Symbol.for(`react.element`),_=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),S=Symbol.for(`react.consumer`),C=Symbol.for(`react.context`),w=Symbol.for(`react.forward_ref`),T=Symbol.for(`react.suspense`),E=Symbol.for(`react.suspense_list`),D=Symbol.for(`react.memo`),O=Symbol.for(`react.lazy`),ee=Symbol.for(`react.activity`),te=Symbol.for(`react.memo_cache_sentinel`),ne=Symbol.iterator;function re(e){return typeof e!=`object`||!e?null:(e=ne&&e[ne]||e[`@@iterator`],typeof e==`function`?e:null)}var ie=Symbol.for(`react.client.reference`);function ae(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ie?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case y:return`Fragment`;case x:return`Profiler`;case b:return`StrictMode`;case T:return`Suspense`;case E:return`SuspenseList`;case ee:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case C:return e.displayName||`Context`;case S:return(e._context.displayName||`Context`)+`.Consumer`;case w:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case D:return t=e.displayName||null,t===null?ae(e.type)||`Memo`:t;case O:t=e._payload,e=e._init;try{return ae(e(t))}catch{}}return null}var oe=Array.isArray,k=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,A=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,se={pending:!1,data:null,method:null,action:null},ce=[],le=-1;function ue(e){return{current:e}}function j(e){0>le||(e.current=ce[le],ce[le]=null,le--)}function de(e,t){le++,ce[le]=e.current,e.current=t}var fe=ue(null),M=ue(null),pe=ue(null),me=ue(null);function he(e,t){switch(de(pe,t),de(M,e),de(fe,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Zd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Zd(t),e=Qd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}j(fe),de(fe,e)}function ge(){j(fe),j(M),j(pe)}function _e(e){e.memoizedState!==null&&de(me,e);var t=fe.current,n=Qd(t,e.type);t!==n&&(de(M,e),de(fe,n))}function ve(e){M.current===e&&(j(fe),j(M)),me.current===e&&(j(me),cp._currentValue=se)}var ye,be;function xe(e){if(ye===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ye=t&&t[1]||``,be=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+ye+e+be}var Se=!1;function Ce(e,t){if(!e||Se)return``;Se=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
@@ -115,10 +115,10 @@ $2`),t=t.replace(/([。;;::\.])\s*-(?!-)\s*/g,`$1
115
115
  `:i||a?`
116
116
  `:r})}function Ny(e){if(!e)return e;let t=String(e).replace(/\r\n/g,`
117
117
  `).replace(/\r/g,`
118
- `).trim();return t=xy(t),(t.match(/```/g)||[]).length%2==1&&(t=`${t}\n\`\`\``),My(t.split("```")).join("```").trim()}var Py=`modulepreload`,Fy=function(e,t){return new URL(e,t).href},Iy={},W=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=Fy(t,n),t in Iy)return;Iy[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:Py,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Ly=b.lazy(()=>W(()=>import(`./CodeBlock-CHZaDmho.js`).then(e=>({default:e.CodeBlock})),[],import.meta.url)),Ry=b.lazy(()=>W(()=>import(`./MermaidBlock-CV56XpfU.js`).then(e=>({default:e.MermaidBlock})),[],import.meta.url)),zy=b.lazy(()=>W(()=>import(`./MathMessageMarkdown-Cx9VSNQ8.js`).then(e=>({default:e.MathMessageMarkdown})),__vite__mapDeps([0,1,2,3,4]),import.meta.url));function By(e){return/\$[^$]+\$|\$\$[^$]+\$\$/.test(e)}var Vy={code({className:e,children:t,...n}){let r=/language-(\w+)/.exec(e||``),i=String(t??``);if(!r&&!i.includes(`
118
+ `).trim();return t=xy(t),(t.match(/```/g)||[]).length%2==1&&(t=`${t}\n\`\`\``),My(t.split("```")).join("```").trim()}var Py=`modulepreload`,Fy=function(e,t){return new URL(e,t).href},Iy={},W=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=Fy(t,n),t in Iy)return;Iy[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:Py,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Ly=b.lazy(()=>W(()=>import(`./CodeBlock-BK8ioKOV.js`).then(e=>({default:e.CodeBlock})),[],import.meta.url)),Ry=b.lazy(()=>W(()=>import(`./MermaidBlock-Cgzb0dEp.js`).then(e=>({default:e.MermaidBlock})),[],import.meta.url)),zy=b.lazy(()=>W(()=>import(`./MathMessageMarkdown-D1NgYJhw.js`).then(e=>({default:e.MathMessageMarkdown})),__vite__mapDeps([0,1,2,3,4]),import.meta.url));function By(e){return/\$[^$]+\$|\$\$[^$]+\$\$/.test(e)}var Vy={code({className:e,children:t,...n}){let r=/language-(\w+)/.exec(e||``),i=String(t??``);if(!r&&!i.includes(`
119
119
  `))return(0,R.jsx)(`code`,{className:`bg-slate-100 dark:bg-slate-800 px-1.5 py-0.5 rounded-md text-[13.5px] font-mono text-slate-800 dark:text-slate-200 before:content-none after:content-none border border-slate-200 dark:border-slate-700`,...n,children:t});let a=r?r[1]:``;return a===`mermaid`?(0,R.jsx)(b.Suspense,{fallback:(0,R.jsx)(`div`,{className:`h-32 animate-pulse bg-slate-100 dark:bg-slate-800 rounded`}),children:(0,R.jsx)(Ry,{chart:i})}):(0,R.jsx)(b.Suspense,{fallback:(0,R.jsx)(`pre`,{className:`p-4 text-sm`,children:i}),children:(0,R.jsx)(Ly,{language:a,value:i})})},table({children:e,...t}){return(0,R.jsx)(`div`,{className:`overflow-x-auto my-4 border border-slate-200 dark:border-slate-700 rounded-lg`,children:(0,R.jsx)(`table`,{className:`w-full text-sm text-left my-0`,...t,children:e})})},th({children:e,...t}){return(0,R.jsx)(`th`,{className:`bg-slate-50 dark:bg-slate-800/50 px-4 py-2 font-semibold border-b border-slate-200 dark:border-slate-700`,...t,children:e})},td({children:e,...t}){return(0,R.jsx)(`td`,{className:`px-4 py-2 border-b border-slate-100 dark:border-slate-800 last:border-0`,...t,children:e})},a({children:e,href:t,...n}){return(0,R.jsx)(`a`,{href:t,className:`text-blue-600 dark:text-blue-400 hover:underline`,target:`_blank`,rel:`noopener noreferrer`,...n,children:e})}},Hy=b.memo(({content:e})=>{let t=Ny(e);return(0,R.jsx)(`div`,{className:`prose prose-slate dark:prose-invert max-w-none break-words text-[15px] leading-7 prose-headings:mb-3 prose-headings:mt-6 prose-headings:font-semibold prose-headings:text-slate-900 dark:prose-headings:text-slate-50 prose-h1:text-[1.95rem] prose-h1:leading-tight prose-h1:tracking-[-0.02em] prose-h2:text-[1.55rem] prose-h2:leading-tight prose-h2:tracking-[-0.015em] prose-h3:text-[1.2rem] prose-h3:leading-snug prose-p:my-3 prose-p:leading-7 prose-strong:text-slate-900 dark:prose-strong:text-slate-100 prose-ol:my-3 prose-ul:my-3 prose-li:my-1.5 prose-li:leading-7 prose-hr:my-5 prose-hr:border-slate-200 dark:prose-hr:border-slate-700 prose-pre:m-0 prose-pre:bg-transparent prose-pre:p-0 [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,children:(0,R.jsx)(gg,{remarkPlugins:[by],components:Vy,children:t})})}),Uy=b.memo(({content:e})=>By(e)?(0,R.jsx)(b.Suspense,{fallback:(0,R.jsx)(Hy,{content:e}),children:(0,R.jsx)(zy,{content:e})}):(0,R.jsx)(Hy,{content:e}));async function Wy(e,t=globalThis){let n=String(e??``),r=t?.navigator;if(r?.clipboard?.writeText)try{return await r.clipboard.writeText(n),!0}catch{}let i=t?.document,a=i?.body;if(!i?.createElement||!a?.appendChild||!a?.removeChild)return!1;let o=i.createElement(`textarea`);o.value=n,o.setAttribute?.(`readonly`,``),o.style&&(o.style.position=`fixed`,o.style.top=`0`,o.style.left=`-9999px`,o.style.opacity=`0`,o.style.pointerEvents=`none`);let s=i.activeElement;a.appendChild(o),o.focus?.(),o.select?.(),o.setSelectionRange?.(0,n.length);try{return typeof i.execCommand==`function`?!!i.execCommand(`copy`):!1}finally{a.removeChild(o),s?.focus?.()}}function Gy(e){let t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/60),r=t%60;return n<=0?`${r}s`:`${n}m ${String(r).padStart(2,`0`)}s`}function Ky(e){return e<1e3?`刚刚`:e<6e4?`${Math.floor(e/1e3)} 秒前`:`${Math.floor(e/6e4)} 分钟前`}function qy(e){let t=Number(e);return!Number.isFinite(t)||t<=0?`0`:t<1e3?String(Math.round(t)):t<1e6?`${Math.round(t/100)/10}k`:`${Math.round(t/1e5)/10}m`}function Jy({contextIndicator:e}){let t=e?.usedTokens,n=e?.contextWindowTokens;return!t||!n?null:(0,R.jsxs)(`span`,{className:`token-count-pulse hidden font-mono text-slate-400 dark:text-slate-500 sm:inline`,title:`估算 token:${Math.round(t)} / ${Math.round(n)}`,children:[`估算 token `,qy(t),` / `,qy(n)]},Math.round(t))}function Yy({activity:e,contextIndicator:t,onStopGeneration:n,onCancelRemote:r}){let[i,a]=(0,b.useState)(()=>Date.now());(0,b.useEffect)(()=>{let e=window.setInterval(()=>a(Date.now()),1e3);return()=>window.clearInterval(e)},[]);let o=e.status===`connecting`||e.status===`running`||e.status===`waiting`,s=i-e.lastEventAt<2e4;return(0,R.jsxs)(`div`,{className:`inline-flex max-w-full items-center gap-2 rounded-full border border-slate-200/70 bg-white/90 px-2.5 py-1 text-[11px] leading-4 text-slate-500 shadow-sm shadow-slate-900/5 backdrop-blur dark:border-slate-700/60 dark:bg-slate-900/90 dark:text-slate-400`,children:[e.status===`failed`?(0,R.jsx)(Rr,{className:`h-3 w-3 text-rose-500`}):e.status===`completed`?(0,R.jsx)(Ir,{className:`h-3 w-3 text-emerald-500`}):e.status===`stopped`?(0,R.jsx)(ui,{className:`h-3 w-3 text-amber-500`}):(0,R.jsx)(ai,{className:`h-3 w-3 animate-spin text-slate-400`}),(0,R.jsx)(`span`,{className:`max-w-[16rem] truncate text-slate-600 dark:text-slate-300`,title:e.detail||e.phase,children:e.phase}),(0,R.jsxs)(`span`,{children:[e.source===`restore`?`恢复`:`运行`,` `,Gy(i-e.startedAt)]}),o?(0,R.jsx)(`span`,{className:L(`inline-block h-1.5 w-1.5 flex-shrink-0 rounded-full`,s?`bg-emerald-400`:`bg-slate-300 dark:bg-slate-600`),title:s?`连接存活`:`连接超时`}):null,(0,R.jsxs)(`span`,{className:`text-slate-400 dark:text-slate-500`,children:[e.eventCount,` ev`]}),(0,R.jsx)(Jy,{contextIndicator:t}),(0,R.jsx)(`span`,{className:`hidden text-slate-400 dark:text-slate-500 sm:inline`,children:Ky(i-e.lastEventAt)}),o&&(n||r)?(0,R.jsxs)(`div`,{className:`flex flex-shrink-0 gap-1`,children:[n?(0,R.jsxs)(`button`,{type:`button`,onClick:n,className:`flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[11px] text-slate-400 transition hover:bg-slate-100 hover:text-slate-700 dark:text-slate-500 dark:hover:bg-slate-800 dark:hover:text-slate-200`,children:[(0,R.jsx)(Rr,{className:`h-3 w-3`}),`停止`]}):null,r?(0,R.jsxs)(`button`,{type:`button`,"aria-label":`取消运行并保留恢复点`,title:`取消运行并保留最近 checkpoint`,onClick:r,className:`flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[11px] text-slate-400 transition hover:bg-rose-50 hover:text-rose-600 dark:text-slate-500 dark:hover:bg-rose-950/30 dark:hover:text-rose-300`,children:[(0,R.jsx)(zr,{className:`h-3 w-3`}),`取消`]}):null]}):null]})}function Xy({agentName:e}){return(0,R.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-[50vh] px-4`,children:[(0,R.jsx)(`div`,{className:`mb-6 h-16 w-16 rounded-2xl bg-gradient-to-br from-blue-500 to-indigo-600
120
120
  flex items-center justify-center shadow-lg shadow-blue-500/20`,children:(0,R.jsx)(Fr,{className:`h-8 w-8 text-white`})}),(0,R.jsx)(`h2`,{className:`text-xl font-semibold text-slate-900 dark:text-slate-50`,children:`有什么我可以帮您的吗?`}),(0,R.jsxs)(`p`,{className:`mt-2 text-sm text-slate-500`,children:[`我是 `,e,`,由 Ksyun AgentEngine 驱动`]})]})}function Zy(e){let t=String(e||``).trim();return t?{stream:`流式执行中`,running:`运行中`,interrupted:`已中断`,cancelled:`已取消`,completed:`已完成`,before_tool:`工具执行前`,after_tool:`工具执行后`}[t]||t:`保存运行状态`}function Qy(e){return{completed:`已完成`,checkpointed:`已保存`,running:`执行中`,ready_to_resume:`可恢复`,cancelled:`已取消`,canceled:`已取消`,failed:`失败`,pending:`等待中`}[String(e||``).trim().toLowerCase()]||``}function $y(e,t){return t.stage?t.stage:t.phase&&![`stream`,`running`,`interrupted`,`cancelled`,`completed`,`before_tool`,`after_tool`].includes(t.phase)?t.phase:e===0?`最新状态快照`:`状态快照 #${e+1}`}function eb(e,t){return`第 ${Math.max(1,t-e)}/${Math.max(1,t)} 阶段`}function tb(e,t=8,n=4){let r=String(e||``).trim();return r?r.length<=t+n+1?r:`${r.slice(0,t)}...${r.slice(-n)}`:``}function nb({checkpoints:e,isStreaming:t,onResumeCheckpoint:n}){if(!e.length||!n)return null;let r=e.filter(e=>{let t=String(e.status||``).trim().toLowerCase();return t===`completed`||t===`checkpointed`||t===`ready_to_resume`}).length;return(0,R.jsxs)(`div`,{className:`mb-4 rounded-lg border border-slate-200 bg-white px-3 py-3 text-xs text-slate-600 shadow-sm shadow-slate-900/[0.04] dark:border-slate-700 dark:bg-slate-900/70 dark:text-slate-300`,children:[(0,R.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center justify-between gap-2`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`div`,{className:`font-medium text-slate-800 dark:text-slate-100`,children:`会话恢复区`}),(0,R.jsx)(`div`,{className:`mt-0.5 text-[11px] text-slate-400`,children:`选择 LangGraph 状态快照,从对应图状态继续`})]}),(0,R.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-1.5`,children:[r>0?(0,R.jsxs)(`span`,{className:`rounded-full bg-emerald-50 px-2 py-1 text-[11px] font-medium text-emerald-700 ring-1 ring-emerald-100 dark:bg-emerald-950/25 dark:text-emerald-300 dark:ring-emerald-900/50`,children:[`已捕获 `,r,` 个快照`]}):null,(0,R.jsxs)(`span`,{className:`rounded-full bg-white px-2 py-1 text-[11px] font-medium text-slate-500 ring-1 ring-slate-200 dark:bg-slate-950/40 dark:text-slate-300 dark:ring-slate-700`,children:[`共 `,e.length,` 个`]})]})]}),(0,R.jsx)(`div`,{className:`custom-scrollbar flex max-h-[24rem] flex-col gap-1.5 overflow-y-auto pr-1`,children:e.map((r,i)=>{let a=t||!r.sessionId,o=eb(i,e.length),s=$y(i,r),c=Zy(r.phase),l=Qy(r.status)||(i===0?`推荐`:``),u=tb(r.checkpointId),d=tb(r.runId,10,4);return(0,R.jsxs)(`div`,{className:`grid min-h-[4.35rem] grid-cols-[1.75rem_minmax(0,1fr)_auto] items-center gap-2 rounded-md border border-slate-200/70 bg-slate-50/70 px-2.5 py-2 transition hover:border-blue-200 hover:bg-blue-50/40 dark:border-slate-700/70 dark:bg-slate-950/30 dark:hover:border-blue-800 dark:hover:bg-blue-950/20`,title:[r.timestamp?`时间:${xr(r.timestamp)}`:``,u?`checkpoint:${r.checkpointId}`:``,d?`run:${r.runId}`:``].filter(Boolean).join(`
121
- `)||void 0,children:[(0,R.jsx)(`div`,{className:`flex h-7 w-7 items-center justify-center rounded-full bg-white text-emerald-600 ring-1 ring-slate-200 dark:bg-slate-900 dark:text-emerald-300 dark:ring-slate-700`,children:(0,R.jsx)(Ir,{className:`h-3.5 w-3.5`})}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`flex-shrink-0 rounded-full bg-blue-50 px-2 py-0.5 text-[11px] font-medium text-blue-600 dark:bg-blue-950/40 dark:text-blue-300`,children:o}),i===0?(0,R.jsx)(`span`,{className:`flex-shrink-0 rounded-full bg-white px-2 py-0.5 text-[11px] font-medium text-blue-600 ring-1 ring-blue-100 dark:bg-slate-950/40 dark:text-blue-300 dark:ring-blue-900/50`,children:`最新`}):null,l?(0,R.jsx)(`span`,{className:`flex-shrink-0 rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-600 dark:bg-emerald-950/30 dark:text-emerald-300`,children:l}):null,(0,R.jsx)(`span`,{className:`truncate font-medium text-slate-800 dark:text-slate-100`,children:s})]}),r.summary?(0,R.jsx)(`div`,{className:`mt-1 truncate text-[12px] leading-5 text-slate-600 dark:text-slate-300`,children:r.summary}):(0,R.jsx)(`div`,{className:`mt-1 text-[12px] leading-5 text-slate-500 dark:text-slate-400`,children:c}),(0,R.jsxs)(`div`,{className:`mt-1 flex min-w-0 items-center gap-1.5 text-[11px] leading-4 text-slate-400`,children:[r.nextAction?(0,R.jsxs)(`span`,{className:`truncate text-blue-600 dark:text-blue-300`,children:[`恢复后阶段:`,r.nextAction]}):(0,R.jsx)(`span`,{className:`truncate`,children:c}),r.timestamp?(0,R.jsx)(`span`,{className:`hidden flex-shrink-0 sm:inline`,children:xr(r.timestamp)}):null]})]}),(0,R.jsxs)(`button`,{type:`button`,"aria-label":`恢复到${o}`,disabled:a,title:a?`当前会话正在运行,暂不能恢复`:`从该 LangGraph checkpoint 恢复`,onClick:()=>{r.sessionId&&n({sessionId:r.sessionId,runId:r.runId,checkpointId:r.checkpointId})},className:`inline-flex h-8 flex-shrink-0 items-center gap-1 rounded-md border border-slate-200 bg-white px-2.5 text-[11px] font-medium text-slate-600 transition hover:border-blue-300 hover:text-blue-600 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-300 dark:hover:border-blue-500 dark:hover:text-blue-300`,children:[(0,R.jsx)(ai,{className:`h-3 w-3`}),`恢复`]})]},r.checkpointId)})})]})}function rb({attachments:e,isMobile:t,onOpenAttachmentPreview:n}){return(0,R.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-3`,children:e.map((e,r)=>e.type.startsWith(`image/`)?e.url?(0,R.jsx)(`button`,{type:`button`,onClick:()=>n(e),className:L(`group relative overflow-hidden rounded-xl border border-slate-200 shadow-sm dark:border-slate-700`,t?`w-full max-w-full`:`max-w-[200px]`),children:(0,R.jsx)(`img`,{src:e.url,alt:e.name,className:L(`object-cover transition group-hover:scale-[1.02]`,t?`max-h-[16rem] w-full max-w-full`:`max-h-[200px] max-w-[200px]`)})},`${e.name}-${r}`):(0,R.jsx)(`div`,{className:L(`flex items-center justify-center rounded-xl border border-dashed border-slate-300 bg-slate-50 px-4 text-sm text-slate-500 dark:border-slate-700 dark:bg-slate-900/40 dark:text-slate-400`,t?`h-28 w-full`:`h-[120px] w-[200px]`),children:e.name},`${e.name}-${r}`):(0,R.jsxs)(`div`,{className:L(`flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-100 px-3 py-2 shadow-sm dark:border-slate-700 dark:bg-slate-800`,t?`w-full max-w-full`:`w-max max-w-full`),children:[(0,R.jsx)(ri,{className:`h-4 w-4 flex-shrink-0 text-blue-500`}),e.url?(0,R.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`truncate text-sm text-slate-700 hover:underline dark:text-slate-300`,title:e.name,children:e.name}):(0,R.jsx)(`span`,{className:`truncate text-sm text-slate-700 dark:text-slate-300`,title:e.name,children:e.name})]},`${e.name}-${r}`))})}function ib({message:e}){return(0,R.jsx)(`div`,{className:`w-full px-0 py-2 sm:px-4`,children:(0,R.jsxs)(`div`,{className:`mx-auto max-w-3xl rounded-2xl border border-amber-200/80 bg-amber-50/80 px-4 py-3 text-sm text-amber-900 shadow-sm dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[e.status===`running`?(0,R.jsx)(ai,{className:`h-4 w-4 animate-spin text-amber-600 dark:text-amber-300`}):e.status===`failed`?(0,R.jsx)(Rr,{className:`h-4 w-4 text-rose-600 dark:text-rose-400`}):(0,R.jsx)(Ir,{className:`h-4 w-4 text-emerald-600 dark:text-emerald-400`}),(0,R.jsx)(`span`,{children:e.content})]}),e.compactedUntilSeqId?(0,R.jsxs)(`div`,{className:`mt-1 text-xs text-amber-700/80 dark:text-amber-200/80`,children:[`已折叠到会话事件 #`,e.compactedUntilSeqId]}):null,e.summary?(0,R.jsxs)(`details`,{className:`mt-3 rounded-xl border border-amber-200/80 bg-white/70 px-3 py-2 dark:border-amber-900/60 dark:bg-slate-950/40`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer select-none text-xs font-medium text-amber-800 dark:text-amber-200`,children:`查看压缩摘要`}),(0,R.jsx)(`div`,{className:`mt-2 text-[13px] leading-relaxed text-slate-700 dark:text-slate-200`,children:(0,R.jsx)(Uy,{content:e.summary})})]}):null]})})}function ab({label:e,tone:t,value:n}){let[r,i]=(0,b.useState)(`idle`),a=Cn(n);(0,b.useEffect)(()=>{if(r===`idle`)return;let e=window.setTimeout(()=>i(`idle`),1600);return()=>window.clearTimeout(e)},[r]);let o=async()=>{i(await Wy(a)?`copied`:`failed`)};return(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,R.jsx)(`div`,{className:L(`text-xs font-semibold uppercase`,t===`input`?`text-blue-500`:t===`error`?`text-rose-500`:`text-emerald-500`),children:e}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{o()},className:`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-[11px] font-medium text-slate-500 transition hover:bg-white hover:text-slate-900 dark:text-slate-400 dark:hover:bg-slate-900 dark:hover:text-slate-100`,children:[r===`copied`?(0,R.jsx)(Ir,{className:`h-3.5 w-3.5 text-emerald-500`}):(0,R.jsx)(Vr,{className:`h-3.5 w-3.5`}),r===`copied`?`已复制`:r===`failed`?`复制失败`:`复制`]})]}),(0,R.jsx)(`div`,{className:`custom-scrollbar max-h-[220px] overflow-y-auto whitespace-pre-wrap break-words rounded-xl border border-slate-200/30 bg-white/70 p-3 text-slate-600 shadow-sm dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-300 sm:max-h-[300px]`,children:a})]})}function ob({isLastMessage:e,isStreaming:t,message:n,onDeleteFeedback:r,onSubmitFeedback:i}){let[a,o]=(0,b.useState)(!1),[s,c]=(0,b.useState)(n.feedback?.comment||``),l=or(n,t,e),u=!!n.feedback?.pending,d=n.feedback?.rating;return l?(0,R.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-slate-500 dark:text-slate-400`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:`本次回复有帮助吗?`}),(0,R.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>i({message:n,rating:`up`,comment:``}),className:L(`inline-flex items-center gap-1 rounded-full border px-2.5 py-1 font-medium transition disabled:cursor-not-allowed disabled:opacity-60`,d===`up`?`border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-900/70 dark:bg-emerald-950/30 dark:text-emerald-200`:`border-slate-200 bg-white text-slate-600 hover:border-emerald-200 hover:text-emerald-700 dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-300 dark:hover:border-emerald-900/70 dark:hover:text-emerald-200`),children:[(0,R.jsx)(pi,{className:`h-3.5 w-3.5`}),`有帮助`]}),(0,R.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>{c(n.feedback?.comment||``),o(e=>!e)},className:L(`inline-flex items-center gap-1 rounded-full border px-2.5 py-1 font-medium transition disabled:cursor-not-allowed disabled:opacity-60`,d===`down`?`border-rose-200 bg-rose-50 text-rose-700 dark:border-rose-900/70 dark:bg-rose-950/30 dark:text-rose-200`:`border-slate-200 bg-white text-slate-600 hover:border-rose-200 hover:text-rose-700 dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-300 dark:hover:border-rose-900/70 dark:hover:text-rose-200`),children:[(0,R.jsx)(fi,{className:`h-3.5 w-3.5`}),`需改进`]}),n.feedback?(0,R.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>r(n),className:`inline-flex items-center gap-1 rounded-full border border-transparent px-2 py-1 font-medium text-slate-400 transition hover:border-slate-200 hover:text-slate-700 disabled:cursor-not-allowed disabled:opacity-60 dark:hover:border-slate-800 dark:hover:text-slate-200`,children:[(0,R.jsx)(mi,{className:`h-3.5 w-3.5`}),`删除反馈`]}):null,u?(0,R.jsx)(`span`,{className:`text-slate-400`,children:`提交中…`}):null]}),a?(0,R.jsxs)(`div`,{className:`max-w-xl rounded-2xl border border-rose-100 bg-rose-50/60 p-3 shadow-sm dark:border-rose-900/60 dark:bg-rose-950/20`,children:[(0,R.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),placeholder:`可以补充哪里不准确、缺失或不符合预期。`,className:`min-h-[84px] w-full resize-y rounded-xl border border-rose-100 bg-white px-3 py-2 text-sm text-slate-700 outline-none transition placeholder:text-slate-400 focus:border-rose-300 focus:ring-2 focus:ring-rose-100 dark:border-rose-900/70 dark:bg-slate-950 dark:text-slate-100 dark:focus:border-rose-700 dark:focus:ring-rose-950`}),(0,R.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:`rounded-xl px-3 py-1.5 text-xs font-semibold text-slate-500 transition hover:bg-white hover:text-slate-800 dark:text-slate-400 dark:hover:bg-slate-950 dark:hover:text-slate-100`,children:`取消`}),(0,R.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>{i({message:n,rating:`down`,comment:s}),o(!1)},className:`rounded-xl bg-rose-600 px-3 py-1.5 text-xs font-semibold text-white shadow-sm transition hover:bg-rose-500 disabled:cursor-not-allowed disabled:opacity-60`,children:`提交点踩`})]})]}):d===`down`&&n.feedback?.comment?(0,R.jsxs)(`div`,{className:`max-w-xl rounded-xl border border-rose-100 bg-rose-50/50 px-3 py-2 text-xs text-rose-700 dark:border-rose-900/60 dark:bg-rose-950/20 dark:text-rose-200`,children:[`反馈:`,n.feedback.comment]}):null,n.feedback?.error?(0,R.jsx)(`div`,{className:`text-xs text-rose-600 dark:text-rose-300`,children:n.feedback.error}):null]}):null}function sb({agentName:e,isMobile:t,isStreaming:n,isLastMessage:r,message:i,onDeleteFeedback:a,onOpenAttachmentPreview:o,onRespondToApproval:s,onSubmitFeedback:c}){return i.role===`user`?(0,R.jsx)(`div`,{className:`mb-3 flex justify-end`,children:(0,R.jsxs)(`div`,{className:`max-w-[80%] rounded-2xl rounded-br-sm bg-blue-600 px-3.5 py-2.5 text-[14px] leading-relaxed text-white dark:bg-blue-500`,children:[i.attachments?.length?(0,R.jsx)(rb,{attachments:i.attachments,isMobile:t,onOpenAttachmentPreview:o}):null,i.content]})}):(0,R.jsxs)(`div`,{className:`mb-3 max-w-none`,children:[(0,R.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-xs text-slate-400`,children:[(0,R.jsx)(Fr,{className:`w-3.5 h-3.5`}),(0,R.jsx)(`span`,{children:e})]}),i.attachments?.length?(0,R.jsx)(rb,{attachments:i.attachments,isMobile:t,onOpenAttachmentPreview:o}):null,i.reasoning?(0,R.jsxs)(`details`,{className:`group/details mb-3 overflow-hidden rounded-lg border border-emerald-200/70 bg-emerald-50/40 text-sm text-slate-600 transition-colors open:bg-white dark:border-emerald-900/50 dark:bg-emerald-950/10 dark:text-slate-300 dark:open:bg-slate-950/30`,children:[(0,R.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 border-l-2 border-emerald-400 px-3 py-2 font-medium outline-none marker:hidden dark:border-emerald-500`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[n&&r&&!i.content?(0,R.jsx)(ai,{className:`h-4 w-4 animate-spin text-emerald-500`}):(0,R.jsx)(Ir,{className:`h-4 w-4 text-emerald-500`}),(0,R.jsx)(`span`,{className:`truncate`,children:`思考过程`}),(0,R.jsx)(`span`,{className:`rounded-full bg-emerald-100 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300`,children:n&&r&&!i.content?`生成中`:`已完成`})]}),(0,R.jsx)(Lr,{className:`h-4 w-4 flex-shrink-0 text-slate-400 transition-transform group-open/details:rotate-180`})]}),(0,R.jsx)(`div`,{className:`border-t border-emerald-100/80 bg-white/70 dark:border-emerald-950 dark:bg-slate-950/20`,children:(0,R.jsx)(`div`,{className:`custom-scrollbar max-h-[min(46vh,28rem)] overflow-y-auto px-4 py-3 text-[14px] leading-7 text-slate-600 dark:text-slate-300 [&_p]:my-2 [&_pre]:my-2`,children:(0,R.jsx)(Uy,{content:i.reasoning})})})]}):null,i.tools?Object.values(i.tools).map((e,t)=>(0,R.jsxs)(`details`,{open:e.status===`paused`?!0:void 0,className:L(`group/details mb-3 rounded-xl border px-3 py-2.5 text-sm transition-all`,e.status===`paused`?`border-amber-200 bg-amber-50/50 text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/20 dark:text-amber-200`:e.status===`error`?`border-rose-200 bg-rose-50/40 text-rose-700 dark:border-rose-900/60 dark:bg-rose-950/20 dark:text-rose-200`:`border-blue-200 bg-blue-50/30 text-blue-600 dark:border-blue-900/50 dark:bg-blue-950/20 dark:text-blue-400`),children:[(0,R.jsx)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 font-medium`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.status===`running`?(0,R.jsx)(ai,{className:`h-4 w-4 animate-spin text-blue-500`}):e.status===`paused`?(0,R.jsx)(ui,{className:`h-4 w-4 text-amber-500`}):e.status===`error`?(0,R.jsx)(zr,{className:`h-4 w-4 text-rose-500`}):(0,R.jsx)(Ir,{className:`h-4 w-4 text-emerald-500`}),(0,R.jsxs)(`span`,{children:[e.status===`paused`?`等待审批:`:e.status===`error`?`工具调用失败:`:`工具调用:`,e.name]})]})}),(0,R.jsxs)(`div`,{className:L(`mx-1 mt-3 flex flex-col gap-3 border-l-2 py-1 pl-4 font-mono text-[13px] leading-relaxed opacity-90`,e.status===`paused`?`border-amber-200 dark:border-amber-800`:e.status===`error`?`border-rose-200 dark:border-rose-800`:`border-blue-200 dark:border-blue-800`),children:[e.status===`paused`&&e.approvalRequestId?(0,R.jsxs)(`div`,{className:`rounded-2xl border border-amber-200 bg-white/75 p-3 font-sans text-sm text-amber-900 shadow-sm dark:border-amber-900/70 dark:bg-slate-950/40 dark:text-amber-100`,children:[(0,R.jsx)(`div`,{className:`font-medium`,children:`该工具调用需要人工确认后继续。`}),e.serverLabel?(0,R.jsxs)(`div`,{className:`mt-1 text-xs text-amber-700/80 dark:text-amber-200/80`,children:[`MCP Server: `,e.serverLabel]}):null,(0,R.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,R.jsxs)(`button`,{type:`button`,disabled:e.approvalStatus===`approved`||e.approvalStatus===`rejected`,onClick:()=>s({approvalRequestId:e.approvalRequestId||``,approve:!0,previousResponseId:e.previousResponseId}),className:`inline-flex items-center gap-1.5 rounded-xl bg-emerald-600 px-3 py-1.5 text-xs font-semibold text-white shadow-sm transition hover:bg-emerald-500 disabled:cursor-not-allowed disabled:opacity-55`,children:[(0,R.jsx)(Ir,{className:`h-3.5 w-3.5`}),`批准并继续`]}),(0,R.jsxs)(`button`,{type:`button`,disabled:e.approvalStatus===`approved`||e.approvalStatus===`rejected`,onClick:()=>s({approvalRequestId:e.approvalRequestId||``,approve:!1,previousResponseId:e.previousResponseId}),className:`inline-flex items-center gap-1.5 rounded-xl border border-rose-200 bg-white px-3 py-1.5 text-xs font-semibold text-rose-600 shadow-sm transition hover:bg-rose-50 disabled:cursor-not-allowed disabled:opacity-55 dark:border-rose-900/70 dark:bg-slate-950 dark:text-rose-300 dark:hover:bg-rose-950/30`,children:[(0,R.jsx)(zr,{className:`h-3.5 w-3.5`}),`拒绝`]})]})]}):null,e.args?(0,R.jsx)(ab,{label:`入参 (Args)`,tone:`input`,value:e.args}):null,e.output?(0,R.jsx)(ab,{label:`输出 (Output)`,tone:e.status===`error`?`error`:`output`,value:e.output}):null]})]},`${e.name}-${t}`)):null,(0,R.jsx)(`div`,{className:`w-full break-words`,children:i.content?(0,R.jsx)(Uy,{content:i.content}):n&&r&&!i.reasoning&&!i.tools?(0,R.jsx)(`span`,{className:`ml-1 mt-2 inline-block h-4 w-2 animate-pulse rounded-sm bg-emerald-500 align-middle opacity-80 shadow-sm`}):null}),(0,R.jsx)(ob,{isLastMessage:r,isStreaming:n,message:i,onDeleteFeedback:a,onSubmitFeedback:c})]})}function cb({agentName:e,isMobile:t,isStreaming:n,activity:r,contextIndicator:i,messages:a,onDeleteFeedback:o,onOpenAttachmentPreview:s,onRespondToApproval:c,onSubmitFeedback:l,onStopGeneration:u,onCancelRemote:d,checkpoints:f=[],onResumeCheckpoint:p,scrollRef:m}){return(0,R.jsxs)(`div`,{ref:m,className:L(`custom-scrollbar relative min-h-0 flex-1 overflow-y-auto scroll-smooth`,t?`px-3 py-3`:`px-4 py-5`),children:[(0,R.jsxs)(`div`,{className:L(`mx-auto flex w-full max-w-[64rem] flex-col`,r?`pb-10 sm:pb-10`:`pb-6 sm:pb-8`),children:[(0,R.jsx)(nb,{checkpoints:f,isStreaming:n,onResumeCheckpoint:p}),a.length===0?(0,R.jsx)(Xy,{agentName:e}):a.map((r,i)=>r.role===`system`?(0,R.jsx)(ib,{message:r},r.id||i):(0,R.jsx)(sb,{agentName:e,isMobile:t,isStreaming:n,isLastMessage:i===a.length-1,message:r,onDeleteFeedback:o,onOpenAttachmentPreview:s,onRespondToApproval:c,onSubmitFeedback:l},r.id||i))]}),r?(0,R.jsx)(`div`,{className:`sticky bottom-1 z-20 mx-auto flex w-full max-w-[64rem] justify-end`,children:(0,R.jsx)(Yy,{activity:r,contextIndicator:i,onStopGeneration:u,onCancelRemote:d})}):null]})}var lb=ml,ub=hl,db=b.forwardRef(({className:e,...t},n)=>(0,R.jsx)(gl,{ref:n,className:L(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t}));db.displayName=gl.displayName;var fb=b.forwardRef(({className:e,children:t,...n},r)=>(0,R.jsxs)(ub,{children:[(0,R.jsx)(db,{}),(0,R.jsxs)(_l,{ref:r,className:L(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg`,e),...n,children:[t,(0,R.jsxs)(bl,{className:`absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground`,children:[(0,R.jsx)(gi,{className:`h-4 w-4`}),(0,R.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}));fb.displayName=_l.displayName;var pb=({className:e,...t})=>(0,R.jsx)(`div`,{className:L(`flex flex-col space-y-1.5 text-center sm:text-left`,e),...t});pb.displayName=`DialogHeader`;var mb=({className:e,...t})=>(0,R.jsx)(`div`,{className:L(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});mb.displayName=`DialogFooter`;var hb=b.forwardRef(({className:e,...t},n)=>(0,R.jsx)(vl,{ref:n,className:L(`text-lg font-semibold leading-none tracking-tight`,e),...t}));hb.displayName=vl.displayName;var gb=b.forwardRef(({className:e,...t},n)=>(0,R.jsx)(yl,{ref:n,className:L(`text-sm text-muted-foreground`,e),...t}));gb.displayName=yl.displayName;function _b(e,t){if(!(!t||e))return{width:`min(${t.width}px, calc(100vw - 5rem))`,height:`min(${t.height}px, calc(100vh - 9rem))`}}function vb(e,t){if(!(!t||e))return{width:`min(${t.width+32}px, calc(100vw - 3rem))`}}function yb({attachment:e,isMobile:t,previewImageSize:n,onClose:r,onImageLoad:i}){return(0,R.jsx)(lb,{open:!!e?.url,onOpenChange:e=>!e&&r(),children:(0,R.jsxs)(fb,{className:L(`gap-0 overflow-hidden border-slate-700 bg-slate-950 p-0 text-slate-100 shadow-2xl [&>button]:right-3 [&>button]:top-3 [&>button]:rounded-md [&>button]:border [&>button]:border-slate-700 [&>button]:bg-slate-900/70 [&>button]:p-1.5 [&>button]:text-slate-200 [&>button]:opacity-100`,t?`left-0 top-0 h-[var(--app-height)] max-h-[var(--app-height)] w-screen max-w-none translate-x-0 translate-y-0 rounded-none border-0`:`max-h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)] rounded-2xl`),style:vb(t,n),children:[(0,R.jsx)(`div`,{className:`flex items-center gap-3 border-b border-slate-800 px-4 py-3 pr-16`,children:(0,R.jsx)(hb,{className:`truncate text-sm font-medium`,children:e?.name||`附件预览`})}),(0,R.jsx)(`div`,{className:L(`flex items-center justify-center overflow-auto bg-slate-950`,t?`h-full p-4 pb-[calc(var(--safe-area-bottom)+1rem)]`:`max-h-[calc(100vh-7rem)] p-4`),children:e?e.type.startsWith(`image/`)?(0,R.jsx)(`img`,{src:e.url,alt:e.name,className:L(`object-contain`,t?`h-auto max-h-full w-full max-w-full`:`h-auto w-auto max-h-[calc(100vh-9rem)] max-w-[calc(100vw-5rem)]`),style:_b(t,n),onLoad:e=>{let t=e.currentTarget;i({width:t.naturalWidth,height:t.naturalHeight})}}):(0,R.jsx)(`iframe`,{src:e.url,title:e.name,className:`h-full min-h-[24rem] w-full rounded-xl border border-slate-800 bg-white`}):null})]})})}function bb(e){if(typeof e==`number`&&Number.isFinite(e)&&e>0)return e;if(typeof e==`string`&&e.trim()){let t=Number(e);if(Number.isFinite(t)&&t>0)return t}return null}function xb(e){return/[\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF]/u.test(e)}function Sb(e){let t=String(e||``).trim();if(!t)return 0;let n=0,r=0;for(let e of t){if(xb(e)){n+=1;continue}r+=1}return Math.max(1,n+Math.ceil(r/4))}function Cb(e){if(!e)return 0;if(e.role===`system`)return e.eventType===`context_checkpoint`?Sb(e.summary||``):0;let t=Sb(e.content||``);return e.tools&&(t+=Object.values(e.tools).reduce((e,t)=>e+Sb(t?.name||``)+Sb(t?.args||``)+Sb(t?.output||``),0)),t}function wb(e){return e?bb(e.context_window_tokens)??bb(e?.limits?.context_window_tokens):null}function Tb(e){return e?bb(e.auto_compact_threshold_percentage)??84:84}function Eb({messages:e,draftInput:t,selectedModel:n}){let r=wb(n);if(!r)return null;let i=[...e||[]].reverse().find(e=>e?.role===`system`&&e?.eventType===`context_checkpoint`&&e?.status===`running`);if(i){let e=Cb(i);return{label:`正在压缩上下文…`,phase:`compressing`,usedTokens:e,contextWindowTokens:r,percent:Math.min(100,Math.max(0,Math.round(e/r*100)))}}let a=(e||[]).reduce((e,t)=>e+Cb(t),0)+Sb(t||``);if(a<=0)return null;let o=Math.min(100,Math.max(0,Math.round(a/r*100)));return o>=Tb(n)?{label:`估算上下文 ${o}% · 即将压缩`,phase:`warning`,percent:o,usedTokens:a,contextWindowTokens:r}:{label:`估算上下文 ${o}%`,phase:`normal`,percent:o,usedTokens:a,contextWindowTokens:r}}function Db({agentName:e,isMobile:t,onDeleteFeedback:n,onSubmitFeedback:r,onRespondToApproval:i,onStopGeneration:a,onCancelRemote:o,checkpointResumeEnabled:s=!1,onResumeCheckpoint:c}){let l=vt(e=>e.messages),u=M(e=>e.currentSessionId),d=j(e=>!!(e.getSessionActivity(u)&&e.isSessionStreaming(u))),f=j(e=>e.getSessionActivity(u)),p=pn(e=>e.getSessionCheckpoints(u)),m=D(e=>e.input),h=le(e=>e.availableModels),g=le(e=>e.selectedModel),_=D(e=>e.previewAttachment),v=D(e=>e.previewImageSize),y=(0,b.useRef)(null),x=(0,b.useRef)(!0),S=(0,b.useRef)(!1),C=(0,b.useRef)(0),w=(0,b.useRef)(d),T=(0,b.useMemo)(()=>h.find(e=>e.id===g)||null,[h,g]),E=(0,b.useMemo)(()=>Eb({messages:l,draftInput:m,selectedModel:T}),[m,l,T]);return(0,b.useEffect)(()=>{w.current=d},[d]),(0,b.useEffect)(()=>{let e=y.current;if(!e)return;let t=()=>{let t=e.scrollHeight-e.scrollTop-e.clientHeight,n=e.scrollTop<C.current-2;if(C.current=e.scrollTop,w.current&&n){S.current=!0,x.current=!1;return}if(S.current){let e=t<=12;S.current=!e,x.current=e;return}x.current=t<96};return t(),e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[]),(0,b.useEffect)(()=>{let e=y.current;!e||!x.current||(e.scrollTop=e.scrollHeight,C.current=e.scrollTop)},[l,d]),(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(cb,{agentName:e,isMobile:t,isStreaming:d,activity:f,contextIndicator:E,messages:l,onDeleteFeedback:n,onOpenAttachmentPreview:e=>{D.getState().setPreviewAttachment(e),D.getState().setPreviewImageSize(null)},onRespondToApproval:i,onSubmitFeedback:r,onStopGeneration:a,onCancelRemote:o,checkpoints:s?p:[],onResumeCheckpoint:c,scrollRef:y}),(0,R.jsx)(yb,{attachment:_,isMobile:t,previewImageSize:v,onClose:()=>{D.getState().setPreviewAttachment(null),D.getState().setPreviewImageSize(null)},onImageLoad:e=>D.getState().setPreviewImageSize(e)})]})}function Ob({attachments:e,composerContextIndicator:t,composerMaxHeight:n,fileInputRef:r,input:i,isMobile:a,isStreaming:o,queuedDrafts:s,onAppendAttachments:c,onInputChange:l,onPaste:u,onRemoveAttachment:d,onStopGeneration:f,onCancelRemote:p,onSubmit:m,textareaRef:h}){let g=a?`发送消息...`:`发送消息... (Shift + Enter 换行)`,_=p?`保留恢复点并结束本次执行`:`停止生成`;return(0,R.jsx)(`div`,{className:`relative z-10 flex-shrink-0 bg-white/95 px-3 py-3 backdrop-blur dark:bg-slate-900/95 sm:px-4 sm:py-3`,children:(0,R.jsxs)(`div`,{className:`mx-auto w-full max-w-[64rem]`,children:[s.length>0?(0,R.jsxs)(`div`,{className:`mb-2 rounded-2xl border border-amber-200/80 bg-amber-50/80 px-3 py-2 text-xs text-amber-900 shadow-sm dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100`,children:[(0,R.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`span`,{className:`font-semibold`,children:[`发送队列 · `,s.length]}),(0,R.jsx)(`span`,{className:`text-amber-700/75 dark:text-amber-200/75`,children:`当前回复完成后依次发送`})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[s.slice(0,3).map((e,t)=>{let n=e.text.trim()||(e.attachments.length>0?`仅附件消息`:`空消息`);return(0,R.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-white/70 px-2 py-1.5 dark:bg-slate-950/35`,children:[(0,R.jsx)(`span`,{className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-full bg-amber-100 font-mono text-[10px] text-amber-700 dark:bg-amber-900/50 dark:text-amber-100`,children:t+1}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-slate-700 dark:text-slate-200`,children:n}),e.attachments.length>0?(0,R.jsxs)(`span`,{className:`flex-shrink-0 rounded-full bg-amber-100 px-2 py-0.5 text-[10px] text-amber-700 dark:bg-amber-900/50 dark:text-amber-100`,children:[e.attachments.length,` 附件`]}):null]},`${t}-${n}-${e.attachments.length}`)}),s.length>3?(0,R.jsxs)(`div`,{className:`px-2 pt-0.5 text-[11px] text-amber-700/80 dark:text-amber-200/80`,children:[`还有 `,s.length-3,` 条等待发送`]}):null]})]}):null,(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsxs)(`form`,{onSubmit:t=>{if(t.preventDefault(),o){p?p():f();return}let n=i.trim();!n&&e.length===0||m(n,e)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.files&&e.dataTransfer.files.length>0&&c(Array.from(e.dataTransfer.files))},className:`relative flex min-w-0 flex-1 flex-col rounded-[1.25rem] border border-slate-200 bg-white p-1.5 shadow-[0_8px_22px_rgba(15,23,42,0.07)] transition-all focus-within:border-slate-300 focus-within:ring-1 focus-within:ring-slate-300 dark:border-slate-700 dark:bg-slate-900 dark:focus-within:border-slate-600 dark:focus-within:ring-slate-600`,children:[e.length>0?(0,R.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-2 px-1.5 pt-1.5`,children:e.map((e,t)=>(0,R.jsxs)(`div`,{className:L(`flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-100 px-3 py-1.5 text-xs text-slate-600 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300`,a?`max-w-full`:``),children:[(0,R.jsx)(`span`,{className:`max-w-[10rem] truncate font-medium sm:max-w-[12rem]`,children:e.name}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>d(t),className:`text-slate-400 transition hover:text-red-500`,"aria-label":`移除附件 ${e.name}`,children:`×`})]},`${e.name}-${e.size}-${t}`))}):null,(0,R.jsxs)(`div`,{className:`flex w-full items-end gap-2`,children:[(0,R.jsxs)(`label`,{className:`relative flex h-9 w-9 flex-shrink-0 items-center justify-center overflow-hidden rounded-xl text-slate-400 transition hover:bg-slate-100 hover:text-slate-600 dark:hover:bg-slate-800 dark:hover:text-slate-200`,title:`上传附件`,children:[(0,R.jsx)(`input`,{ref:r,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&e.target.files.length>0&&(c(Array.from(e.target.files)),e.target.value=``)}}),(0,R.jsx)(ri,{className:`h-5 w-5`})]}),(0,R.jsx)(`textarea`,{ref:h,rows:1,value:i,onChange:l,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},onPaste:u,placeholder:g,className:L(`custom-scrollbar min-h-[38px] w-full resize-none border-0 bg-transparent px-2 py-1.5 text-[15px] leading-6 outline-none placeholder:text-slate-400 dark:text-slate-100 dark:placeholder:text-slate-500`,a?`text-[16px]`:`text-[15px]`),style:{maxHeight:`${n}px`,overflowY:`auto`}}),(0,R.jsx)(`button`,{type:`submit`,disabled:!o&&!i.trim()&&e.length===0,className:L(`flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-xl transition-all`,o||i.trim()||e.length>0?`bg-slate-900 text-white hover:bg-slate-800 dark:bg-slate-100 dark:text-slate-900 dark:hover:bg-white`:`bg-slate-100 text-slate-400 dark:bg-slate-800 dark:text-slate-600`),title:o?_:`发送消息`,children:o?(0,R.jsx)(Rr,{className:`h-4 w-4`}):(0,R.jsx)(li,{className:`ml-0.5 h-4 w-4`})})]})]}),t?(0,R.jsxs)(`div`,{className:L(`hidden flex-shrink-0 items-center gap-1.5 rounded-full px-2.5 py-1 text-right text-[11px] leading-5 transition-colors sm:inline-flex`,t.phase===`compressing`?`bg-amber-50 text-amber-600 dark:bg-amber-950/30 dark:text-amber-300`:t.phase===`warning`?`bg-rose-50 text-rose-600 dark:bg-rose-950/30 dark:text-rose-300`:`bg-slate-50 text-slate-400 dark:bg-slate-800/50 dark:text-slate-500`),children:[(0,R.jsx)(ui,{className:`h-3 w-3`}),t.label]}):null]})]})})}function kb(e){return[e.name,e.size,e.lastModified,e.type].join(`:`)}function Ab(e,t){let n=new Map;for(let t of e)n.set(kb(t),t);for(let e of t)n.set(kb(e),e);return Array.from(n.values())}function jb(e){return Array.from(e.clipboardData.items||[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>!!e)}function Mb({composerMaxHeight:e,submitDraft:t,stopGeneration:n,cancelRemote:r,isMobile:i}){let a=D(e=>e.input),o=D(e=>e.attachments),s=M(e=>e.currentSessionId),c=j(e=>!!(e.getSessionActivity(s)&&e.isSessionStreaming(s))),l=D(e=>e.queuedDrafts),u=vt(e=>e.messages),d=le(e=>e.availableModels),f=le(e=>e.selectedModel),p=(0,b.useRef)(null),m=(0,b.useRef)(null),h=(0,b.useMemo)(()=>d.find(e=>e.id===f)||null,[d,f]),g=(0,b.useMemo)(()=>Eb({messages:u,draftInput:a,selectedModel:h}),[a,u,h]),_=(0,b.useCallback)((e,n)=>{!e&&n.length===0||(D.getState().setInput(``),D.getState().setAttachments([]),t(e,n))},[t]);(0,b.useEffect)(()=>{m.current&&(m.current.style.height=`auto`,m.current.style.height=`${Math.min(m.current.scrollHeight,e)}px`)},[a,e]);let v=t=>{D.getState().setInput(t.target.value),t.target.style.height=`auto`,t.target.style.height=`${Math.min(t.target.scrollHeight,e)}px`},y=e=>{e.length&&D.getState().setAttachments(t=>Ab(t,e))};return(0,R.jsx)(Ob,{attachments:o,composerContextIndicator:g,composerMaxHeight:e,fileInputRef:p,input:a,isMobile:i,isStreaming:c,queuedDrafts:l,onAppendAttachments:y,onInputChange:v,onPaste:e=>{let t=jb(e);t.length&&(e.preventDefault(),e.stopPropagation(),y(t))},onRemoveAttachment:e=>D.getState().setAttachments(t=>t.filter((t,n)=>n!==e)),onStopGeneration:n,onCancelRemote:r,onSubmit:_,textareaRef:m})}var Nb=(0,b.lazy)(()=>W(()=>import(`./NativeTerminalPanel-BrbZygfC.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function Pb({availableModels:e,selectedModel:t,onSelectModel:n,selectedModelLabel:r,modelCatalogLoaded:i,modelSource:a,thinkingEnabled:o,thinkingMode:s,onSelectThinkingMode:c,compact:l=!1}){let u=L(`rounded-full border border-slate-200 bg-white px-3 py-2 text-sm text-slate-700 outline-none transition-colors focus:ring-1 focus:ring-blue-500 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-300`,l?`w-full`:`max-w-[13rem]`),d=e.length>1?(0,R.jsx)(`select`,{value:t,onChange:e=>n(e.target.value),className:u,children:e.map(e=>(0,R.jsx)(`option`,{value:e.id,children:e.display_name||e.id},e.id))}):r?(0,R.jsx)(`span`,{className:L(u,`inline-flex max-w-full items-center`,l?`justify-start`:``),title:a||r,children:(0,R.jsx)(`span`,{className:`truncate`,children:r})}):(0,R.jsx)(`span`,{className:`text-sm text-slate-400`,children:i?`未配置模型`:`Loading models...`}),f=o?(0,R.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),className:L(u,l?``:`max-w-[9rem]`),title:`控制模型 thinking/reasoning 参数`,children:[(0,R.jsx)(`option`,{value:`auto`,children:`思考自动`}),(0,R.jsx)(`option`,{value:`enabled`,children:`开启思考`}),(0,R.jsx)(`option`,{value:`disabled`,children:`关闭思考`})]}):null;return(0,R.jsxs)(`div`,{className:L(`flex min-w-0 gap-2`,l?`w-full flex-col`:`items-center`),children:[d,f]})}function Fb({agentName:e,currentSessionId:t,isMobile:n,sidebarOpen:r,mobileSidebarOpen:i,onToggleSidebar:a,availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m,mobileActionsOpen:h,onMobileActionsOpenChange:g,workspaceEnabled:_,onOpenWorkspace:v,nativeManagementLink:y,nativeTerminal:x,nativeLauncherMode:S=!1}){let[C,w]=(0,b.useState)(!1),T=!!x?.Enabled,E=n?i?(0,R.jsx)(ti,{className:`h-5 w-5`}):(0,R.jsx)(ni,{className:`h-5 w-5`}):r?(0,R.jsx)(ti,{className:`h-5 w-5`}):(0,R.jsx)(ni,{className:`h-5 w-5`});return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`header`,{className:L(`flex flex-shrink-0 items-center justify-between border-b border-slate-200/30 bg-white/95 px-3 py-2 backdrop-blur dark:border-slate-800 dark:bg-slate-900/95 sm:px-4`,n?`pt-[calc(var(--safe-area-top)+0.5rem)]`:`h-14`),children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[S?null:(0,R.jsx)(`button`,{type:`button`,onClick:a,className:`rounded-lg p-2 text-slate-500 transition-colors hover:bg-slate-100 dark:hover:bg-slate-800`,"aria-label":n?`打开历史记录`:`切换侧边栏`,children:E}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100 sm:text-base`,children:e}),(0,R.jsx)(`div`,{className:`text-[11px] text-slate-400 dark:text-slate-500`,children:S?`原生运行时入口`:`智能体`})]})]}),n?(0,R.jsx)(`button`,{type:`button`,onClick:()=>g(!0),className:`rounded-lg p-2 text-slate-500 transition-colors hover:bg-slate-100 dark:hover:bg-slate-800`,"aria-label":`打开会话操作`,children:(0,R.jsx)(Ur,{className:`h-5 w-5`})}):(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[y?(0,R.jsxs)(`a`,{href:y.href,target:`_blank`,rel:`noreferrer`,title:y.title,className:`inline-flex flex-shrink-0 items-center gap-1.5 whitespace-nowrap rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm font-medium leading-none text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,R.jsx)(Wr,{className:`h-4 w-4`}),(0,R.jsx)(`span`,{children:y.label})]}):null,_?(0,R.jsxs)(`button`,{type:`button`,onClick:v,className:`inline-flex flex-shrink-0 items-center gap-1.5 whitespace-nowrap rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm font-medium leading-none text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,R.jsx)(Jr,{className:`h-4 w-4`}),(0,R.jsx)(`span`,{children:`Workspace`})]}):null,T?(0,R.jsxs)(`button`,{type:`button`,onClick:()=>w(!0),className:`inline-flex flex-shrink-0 items-center gap-1.5 whitespace-nowrap rounded-xl border border-emerald-200 bg-emerald-50 px-3 py-2 text-sm font-medium leading-none text-emerald-800 transition hover:bg-emerald-100 dark:border-emerald-900/70 dark:bg-emerald-950/40 dark:text-emerald-200`,children:[(0,R.jsx)(di,{className:`h-4 w-4`}),(0,R.jsx)(`span`,{children:`TUI`})]}):null,S?null:(0,R.jsx)(Pb,{availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m}),!S&&t?(0,R.jsxs)(`span`,{className:`rounded bg-slate-50 px-2 py-1 text-xs font-mono text-slate-400 dark:bg-slate-800`,children:[`ID: `,t.slice(0,8)]}):null]})]}),n?(0,R.jsx)(wl,{open:h,onOpenChange:g,children:(0,R.jsxs)(Ol,{side:`bottom`,className:`rounded-t-[1.75rem] border-slate-200 bg-white px-4 pb-[calc(var(--safe-area-bottom)+1rem)] pt-6 dark:border-slate-800 dark:bg-slate-900`,children:[(0,R.jsxs)(kl,{className:`text-left`,children:[(0,R.jsx)(jl,{children:`会话设置`}),(0,R.jsx)(Ml,{className:`sr-only`,children:`调整当前会话的模型和 Workspace 操作。`})]}),(0,R.jsxs)(`div`,{className:`mt-6 flex flex-col gap-4`,children:[_?(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{g(!1),v()},className:`inline-flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm font-medium text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,R.jsx)(Jr,{className:`h-4 w-4`}),`工作区文件`]}):null,T?(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{g(!1),w(!0)},className:`inline-flex items-center gap-2 rounded-xl border border-emerald-200 bg-emerald-50 px-3 py-3 text-sm font-medium text-emerald-800 transition hover:bg-emerald-100 dark:border-emerald-900/70 dark:bg-emerald-950/40 dark:text-emerald-200`,children:[(0,R.jsx)(di,{className:`h-4 w-4`}),`原生 TUI`]}):null,y?(0,R.jsxs)(`a`,{href:y.href,target:`_blank`,rel:`noreferrer`,title:y.title,onClick:()=>g(!1),className:`inline-flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm font-medium text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,R.jsx)(Wr,{className:`h-4 w-4`}),y.label]}):null,S?(0,R.jsx)(`div`,{className:`rounded-2xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm leading-6 text-slate-600 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300`,children:`当前运行时对话在原生管理台中进行;这里保留管理入口和 Workspace 文件操作。`}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-slate-400 dark:text-slate-500`,children:`模型`}),(0,R.jsx)(Pb,{availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m,compact:!0})]}),(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-slate-400 dark:text-slate-500`,children:`当前会话`}),(0,R.jsx)(`div`,{className:`rounded-2xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm text-slate-600 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300`,children:t?(0,R.jsx)(`span`,{className:`break-all font-mono`,children:t}):`新对话尚未创建会话 ID`})]})]})]})]})}):null,x&&C?(0,R.jsx)(b.Suspense,{fallback:null,children:(0,R.jsx)(Nb,{capability:x,open:C,onClose:()=>w(!1)})}):null]})}var Ib=(0,b.lazy)(()=>W(()=>import(`./NativeTerminalPanel-BrbZygfC.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function Lb({productLabel:e=`原生运行时`,nativeManagementLink:t,nativeTerminal:n,workspaceEnabled:r,onOpenWorkspace:i}){let a=!!n?.Enabled,[o,s]=(0,b.useState)(!1);return(0,R.jsxs)(`section`,{className:`flex min-h-0 flex-1 overflow-y-auto bg-[radial-gradient(circle_at_top_left,rgba(14,165,233,0.12),transparent_34%),linear-gradient(135deg,#f8fafc_0%,#ffffff_48%,#f1f5f9_100%)] px-4 py-8 dark:bg-[radial-gradient(circle_at_top_left,rgba(14,165,233,0.16),transparent_34%),linear-gradient(135deg,#020617_0%,#0f172a_52%,#111827_100%)] sm:px-8`,children:[(0,R.jsx)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col justify-center`,children:(0,R.jsxs)(`div`,{className:`overflow-hidden rounded-[2rem] border border-slate-200/80 bg-white/90 shadow-xl shadow-slate-200/60 backdrop-blur dark:border-slate-800 dark:bg-slate-900/85 dark:shadow-black/30`,children:[(0,R.jsxs)(`div`,{className:`border-b border-slate-200/80 bg-slate-50/80 px-6 py-5 dark:border-slate-800 dark:bg-slate-950/40 sm:px-8`,children:[(0,R.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full border border-sky-200 bg-sky-50 px-3 py-1 text-xs font-medium text-sky-700 dark:border-sky-900/60 dark:bg-sky-950/50 dark:text-sky-300`,children:[(0,R.jsx)(ui,{className:`h-3.5 w-3.5`}),e,` native runtime`]}),(0,R.jsx)(`h1`,{className:`mt-5 text-2xl font-semibold tracking-tight text-slate-950 dark:text-slate-50 sm:text-3xl`,children:`对话请使用原生管理台`}),(0,R.jsx)(`p`,{className:`mt-3 max-w-2xl text-sm leading-6 text-slate-600 dark:text-slate-300 sm:text-base`,children:`当前运行时的对话状态由原生管理台承载。AgentEngine Hosted UI 在这里保留统一入口和 Workspace 文件管理,不重复实现运行时内部已有的复杂对话状态机。`})]}),(0,R.jsxs)(`div`,{className:`grid gap-4 p-6 md:grid-cols-3 sm:p-8`,children:[(0,R.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,R.jsx)(`div`,{className:`flex h-11 w-11 items-center justify-center rounded-2xl bg-slate-950 text-white dark:bg-slate-100 dark:text-slate-950`,children:(0,R.jsx)(Qr,{className:`h-5 w-5`})}),(0,R.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`原生管理台`}),(0,R.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`使用原生管理台处理对话、工具卡片、思考流、审批、中断和运行时历史,避免跨状态机不一致。`}),t?(0,R.jsxs)(`a`,{href:t.href,target:`_blank`,rel:`noreferrer`,title:t.title,className:`mt-5 inline-flex items-center gap-2 rounded-2xl bg-slate-950 px-4 py-2.5 text-sm font-medium text-white transition hover:bg-slate-800 dark:bg-slate-100 dark:text-slate-950 dark:hover:bg-white`,children:[(0,R.jsx)(Wr,{className:`h-4 w-4`}),`打开`,t.label]}):(0,R.jsx)(`div`,{className:`mt-5 rounded-2xl border border-amber-200 bg-amber-50 px-4 py-3 text-sm leading-6 text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-200`,children:`当前访问模式不开放原生管理入口。需要完整对话体验时,请使用 owner/private 链接或 CLI。`})]}),(0,R.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,R.jsx)(`div`,{className:`flex h-11 w-11 items-center justify-center rounded-2xl bg-sky-100 text-sky-700 dark:bg-sky-950 dark:text-sky-300`,children:(0,R.jsx)(Jr,{className:`h-5 w-5`})}),(0,R.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`Workspace 文件管理`}),(0,R.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`文件浏览、上传、预览仍由 Hosted UI 提供,和原生管理台组合使用覆盖对话与工作区。`}),r?(0,R.jsxs)(`button`,{type:`button`,onClick:i,className:`mt-5 inline-flex items-center gap-2 rounded-2xl border border-slate-200 bg-slate-50 px-4 py-2.5 text-sm font-medium text-slate-800 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-100 dark:hover:bg-slate-700`,children:[(0,R.jsx)(Jr,{className:`h-4 w-4`}),`打开 Workspace`]}):(0,R.jsx)(`div`,{className:`mt-5 rounded-2xl border border-slate-200 bg-slate-50 px-4 py-3 text-sm leading-6 text-slate-500 dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-400`,children:`当前链接未开放 Workspace 文件管理。Owner 或 private 链接可使用该能力。`})]}),(0,R.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,R.jsx)(`div`,{className:`flex h-11 w-11 items-center justify-center rounded-2xl bg-emerald-100 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300`,children:(0,R.jsx)(di,{className:`h-5 w-5`})}),(0,R.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`原生 TUI`}),(0,R.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`如果运行时暴露安全的 ks-terminal.v1 通道,可以在这里进入原生终端 UI;share 链接不会开放该入口。`}),a?(0,R.jsxs)(`button`,{type:`button`,onClick:()=>s(!0),className:`mt-5 inline-flex items-center gap-2 rounded-2xl border border-emerald-200 bg-emerald-50 px-4 py-2.5 text-sm font-medium text-emerald-800 transition hover:bg-emerald-100 dark:border-emerald-900/70 dark:bg-emerald-950/40 dark:text-emerald-200`,children:[(0,R.jsx)(di,{className:`h-4 w-4`}),`打开 TUI`]}):(0,R.jsx)(`div`,{className:`mt-5 rounded-2xl border border-slate-200 bg-slate-50 px-4 py-3 text-sm leading-6 text-slate-500 dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-400`,children:`当前运行时未声明可用的浏览器 TUI 能力。`})]})]})]})}),n&&o?(0,R.jsx)(b.Suspense,{fallback:null,children:(0,R.jsx)(Ib,{capability:n,open:o,onClose:()=>s(!1)})}):null]})}var Rb=[],zb=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?zb:Rb).push(n+=e[t])})();function Bb(e){if(e<768)return!1;for(let t=0,n=Rb.length;;){let r=t+n>>1;if(e<Rb[r])n=r;else if(e>=zb[r])t=r+1;else return!0;if(t==n)return!1}}function Vb(e){return e>=127462&&e<=127487}var Hb=8205;function Ub(e,t,n=!0,r=!0){return(n?Wb:Gb)(e,t,r)}function Wb(e,t,n){if(t==e.length)return t;t&&qb(e.charCodeAt(t))&&Jb(e.charCodeAt(t-1))&&t--;let r=Kb(e,t);for(t+=Yb(r);t<e.length;){let i=Kb(e,t);if(r==Hb||i==Hb||n&&Bb(i))t+=Yb(i),r=i;else if(Vb(i)){let n=0,r=t-2;for(;r>=0&&Vb(Kb(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function Gb(e,t,n){for(;t>0;){let r=Wb(e,t-2,n);if(r<t)return r;t--}return 0}function Kb(e,t){let n=e.charCodeAt(t);if(!Jb(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return qb(r)?(n-55296<<10)+(r-56320)+65536:n}function qb(e){return e>=56320&&e<57344}function Jb(e){return e>=55296&&e<56320}function Yb(e){return e<65536?1:2}var Xb=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=ox(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),Qb.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=ox(this,e,t);let n=[];return this.decompose(e,t,n,0),Qb.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new nx(this),i=new nx(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new nx(this,e)}iterRange(e,t=this.length){return new rx(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new ix(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new Zb(t):Qb.from(Zb.split(t,[]))}},Zb=class e extends Xb{constructor(e,t=$b(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new ax(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(tx(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=ex(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=ox(this,t,n);let i=ex(this.text,ex(r.text,tx(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):Qb.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
121
+ `)||void 0,children:[(0,R.jsx)(`div`,{className:`flex h-7 w-7 items-center justify-center rounded-full bg-white text-emerald-600 ring-1 ring-slate-200 dark:bg-slate-900 dark:text-emerald-300 dark:ring-slate-700`,children:(0,R.jsx)(Ir,{className:`h-3.5 w-3.5`})}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`flex-shrink-0 rounded-full bg-blue-50 px-2 py-0.5 text-[11px] font-medium text-blue-600 dark:bg-blue-950/40 dark:text-blue-300`,children:o}),i===0?(0,R.jsx)(`span`,{className:`flex-shrink-0 rounded-full bg-white px-2 py-0.5 text-[11px] font-medium text-blue-600 ring-1 ring-blue-100 dark:bg-slate-950/40 dark:text-blue-300 dark:ring-blue-900/50`,children:`最新`}):null,l?(0,R.jsx)(`span`,{className:`flex-shrink-0 rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-600 dark:bg-emerald-950/30 dark:text-emerald-300`,children:l}):null,(0,R.jsx)(`span`,{className:`truncate font-medium text-slate-800 dark:text-slate-100`,children:s})]}),r.summary?(0,R.jsx)(`div`,{className:`mt-1 truncate text-[12px] leading-5 text-slate-600 dark:text-slate-300`,children:r.summary}):(0,R.jsx)(`div`,{className:`mt-1 text-[12px] leading-5 text-slate-500 dark:text-slate-400`,children:c}),(0,R.jsxs)(`div`,{className:`mt-1 flex min-w-0 items-center gap-1.5 text-[11px] leading-4 text-slate-400`,children:[r.nextAction?(0,R.jsxs)(`span`,{className:`truncate text-blue-600 dark:text-blue-300`,children:[`恢复后阶段:`,r.nextAction]}):(0,R.jsx)(`span`,{className:`truncate`,children:c}),r.timestamp?(0,R.jsx)(`span`,{className:`hidden flex-shrink-0 sm:inline`,children:xr(r.timestamp)}):null]})]}),(0,R.jsxs)(`button`,{type:`button`,"aria-label":`恢复到${o}`,disabled:a,title:a?`当前会话正在运行,暂不能恢复`:`从该 LangGraph checkpoint 恢复`,onClick:()=>{r.sessionId&&n({sessionId:r.sessionId,runId:r.runId,checkpointId:r.checkpointId})},className:`inline-flex h-8 flex-shrink-0 items-center gap-1 rounded-md border border-slate-200 bg-white px-2.5 text-[11px] font-medium text-slate-600 transition hover:border-blue-300 hover:text-blue-600 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-300 dark:hover:border-blue-500 dark:hover:text-blue-300`,children:[(0,R.jsx)(ai,{className:`h-3 w-3`}),`恢复`]})]},r.checkpointId)})})]})}function rb({attachments:e,isMobile:t,onOpenAttachmentPreview:n}){return(0,R.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-3`,children:e.map((e,r)=>e.type.startsWith(`image/`)?e.url?(0,R.jsx)(`button`,{type:`button`,onClick:()=>n(e),className:L(`group relative overflow-hidden rounded-xl border border-slate-200 shadow-sm dark:border-slate-700`,t?`w-full max-w-full`:`max-w-[200px]`),children:(0,R.jsx)(`img`,{src:e.url,alt:e.name,className:L(`object-cover transition group-hover:scale-[1.02]`,t?`max-h-[16rem] w-full max-w-full`:`max-h-[200px] max-w-[200px]`)})},`${e.name}-${r}`):(0,R.jsx)(`div`,{className:L(`flex items-center justify-center rounded-xl border border-dashed border-slate-300 bg-slate-50 px-4 text-sm text-slate-500 dark:border-slate-700 dark:bg-slate-900/40 dark:text-slate-400`,t?`h-28 w-full`:`h-[120px] w-[200px]`),children:e.name},`${e.name}-${r}`):(0,R.jsxs)(`div`,{className:L(`flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-100 px-3 py-2 shadow-sm dark:border-slate-700 dark:bg-slate-800`,t?`w-full max-w-full`:`w-max max-w-full`),children:[(0,R.jsx)(ri,{className:`h-4 w-4 flex-shrink-0 text-blue-500`}),e.url?(0,R.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`truncate text-sm text-slate-700 hover:underline dark:text-slate-300`,title:e.name,children:e.name}):(0,R.jsx)(`span`,{className:`truncate text-sm text-slate-700 dark:text-slate-300`,title:e.name,children:e.name})]},`${e.name}-${r}`))})}function ib({message:e}){return(0,R.jsx)(`div`,{className:`w-full px-0 py-2 sm:px-4`,children:(0,R.jsxs)(`div`,{className:`mx-auto max-w-3xl rounded-2xl border border-amber-200/80 bg-amber-50/80 px-4 py-3 text-sm text-amber-900 shadow-sm dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[e.status===`running`?(0,R.jsx)(ai,{className:`h-4 w-4 animate-spin text-amber-600 dark:text-amber-300`}):e.status===`failed`?(0,R.jsx)(Rr,{className:`h-4 w-4 text-rose-600 dark:text-rose-400`}):(0,R.jsx)(Ir,{className:`h-4 w-4 text-emerald-600 dark:text-emerald-400`}),(0,R.jsx)(`span`,{children:e.content})]}),e.compactedUntilSeqId?(0,R.jsxs)(`div`,{className:`mt-1 text-xs text-amber-700/80 dark:text-amber-200/80`,children:[`已折叠到会话事件 #`,e.compactedUntilSeqId]}):null,e.summary?(0,R.jsxs)(`details`,{className:`mt-3 rounded-xl border border-amber-200/80 bg-white/70 px-3 py-2 dark:border-amber-900/60 dark:bg-slate-950/40`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer select-none text-xs font-medium text-amber-800 dark:text-amber-200`,children:`查看压缩摘要`}),(0,R.jsx)(`div`,{className:`mt-2 text-[13px] leading-relaxed text-slate-700 dark:text-slate-200`,children:(0,R.jsx)(Uy,{content:e.summary})})]}):null]})})}function ab({label:e,tone:t,value:n}){let[r,i]=(0,b.useState)(`idle`),a=Cn(n);(0,b.useEffect)(()=>{if(r===`idle`)return;let e=window.setTimeout(()=>i(`idle`),1600);return()=>window.clearTimeout(e)},[r]);let o=async()=>{i(await Wy(a)?`copied`:`failed`)};return(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,R.jsx)(`div`,{className:L(`text-xs font-semibold uppercase`,t===`input`?`text-blue-500`:t===`error`?`text-rose-500`:`text-emerald-500`),children:e}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{o()},className:`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-[11px] font-medium text-slate-500 transition hover:bg-white hover:text-slate-900 dark:text-slate-400 dark:hover:bg-slate-900 dark:hover:text-slate-100`,children:[r===`copied`?(0,R.jsx)(Ir,{className:`h-3.5 w-3.5 text-emerald-500`}):(0,R.jsx)(Vr,{className:`h-3.5 w-3.5`}),r===`copied`?`已复制`:r===`failed`?`复制失败`:`复制`]})]}),(0,R.jsx)(`div`,{className:`custom-scrollbar max-h-[220px] overflow-y-auto whitespace-pre-wrap break-words rounded-xl border border-slate-200/30 bg-white/70 p-3 text-slate-600 shadow-sm dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-300 sm:max-h-[300px]`,children:a})]})}function ob({isLastMessage:e,isStreaming:t,message:n,onDeleteFeedback:r,onSubmitFeedback:i}){let[a,o]=(0,b.useState)(!1),[s,c]=(0,b.useState)(n.feedback?.comment||``),l=or(n,t,e),u=!!n.feedback?.pending,d=n.feedback?.rating;return l?(0,R.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-slate-500 dark:text-slate-400`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:`本次回复有帮助吗?`}),(0,R.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>i({message:n,rating:`up`,comment:``}),className:L(`inline-flex items-center gap-1 rounded-full border px-2.5 py-1 font-medium transition disabled:cursor-not-allowed disabled:opacity-60`,d===`up`?`border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-900/70 dark:bg-emerald-950/30 dark:text-emerald-200`:`border-slate-200 bg-white text-slate-600 hover:border-emerald-200 hover:text-emerald-700 dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-300 dark:hover:border-emerald-900/70 dark:hover:text-emerald-200`),children:[(0,R.jsx)(pi,{className:`h-3.5 w-3.5`}),`有帮助`]}),(0,R.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>{c(n.feedback?.comment||``),o(e=>!e)},className:L(`inline-flex items-center gap-1 rounded-full border px-2.5 py-1 font-medium transition disabled:cursor-not-allowed disabled:opacity-60`,d===`down`?`border-rose-200 bg-rose-50 text-rose-700 dark:border-rose-900/70 dark:bg-rose-950/30 dark:text-rose-200`:`border-slate-200 bg-white text-slate-600 hover:border-rose-200 hover:text-rose-700 dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-300 dark:hover:border-rose-900/70 dark:hover:text-rose-200`),children:[(0,R.jsx)(fi,{className:`h-3.5 w-3.5`}),`需改进`]}),n.feedback?(0,R.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>r(n),className:`inline-flex items-center gap-1 rounded-full border border-transparent px-2 py-1 font-medium text-slate-400 transition hover:border-slate-200 hover:text-slate-700 disabled:cursor-not-allowed disabled:opacity-60 dark:hover:border-slate-800 dark:hover:text-slate-200`,children:[(0,R.jsx)(mi,{className:`h-3.5 w-3.5`}),`删除反馈`]}):null,u?(0,R.jsx)(`span`,{className:`text-slate-400`,children:`提交中…`}):null]}),a?(0,R.jsxs)(`div`,{className:`max-w-xl rounded-2xl border border-rose-100 bg-rose-50/60 p-3 shadow-sm dark:border-rose-900/60 dark:bg-rose-950/20`,children:[(0,R.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),placeholder:`可以补充哪里不准确、缺失或不符合预期。`,className:`min-h-[84px] w-full resize-y rounded-xl border border-rose-100 bg-white px-3 py-2 text-sm text-slate-700 outline-none transition placeholder:text-slate-400 focus:border-rose-300 focus:ring-2 focus:ring-rose-100 dark:border-rose-900/70 dark:bg-slate-950 dark:text-slate-100 dark:focus:border-rose-700 dark:focus:ring-rose-950`}),(0,R.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:`rounded-xl px-3 py-1.5 text-xs font-semibold text-slate-500 transition hover:bg-white hover:text-slate-800 dark:text-slate-400 dark:hover:bg-slate-950 dark:hover:text-slate-100`,children:`取消`}),(0,R.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>{i({message:n,rating:`down`,comment:s}),o(!1)},className:`rounded-xl bg-rose-600 px-3 py-1.5 text-xs font-semibold text-white shadow-sm transition hover:bg-rose-500 disabled:cursor-not-allowed disabled:opacity-60`,children:`提交点踩`})]})]}):d===`down`&&n.feedback?.comment?(0,R.jsxs)(`div`,{className:`max-w-xl rounded-xl border border-rose-100 bg-rose-50/50 px-3 py-2 text-xs text-rose-700 dark:border-rose-900/60 dark:bg-rose-950/20 dark:text-rose-200`,children:[`反馈:`,n.feedback.comment]}):null,n.feedback?.error?(0,R.jsx)(`div`,{className:`text-xs text-rose-600 dark:text-rose-300`,children:n.feedback.error}):null]}):null}function sb({agentName:e,isMobile:t,isStreaming:n,isLastMessage:r,message:i,onDeleteFeedback:a,onOpenAttachmentPreview:o,onRespondToApproval:s,onSubmitFeedback:c}){return i.role===`user`?(0,R.jsx)(`div`,{className:`mb-3 flex justify-end`,children:(0,R.jsxs)(`div`,{className:`max-w-[80%] rounded-2xl rounded-br-sm bg-blue-600 px-3.5 py-2.5 text-[14px] leading-relaxed text-white dark:bg-blue-500`,children:[i.attachments?.length?(0,R.jsx)(rb,{attachments:i.attachments,isMobile:t,onOpenAttachmentPreview:o}):null,i.content]})}):(0,R.jsxs)(`div`,{className:`mb-3 max-w-none`,children:[(0,R.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-xs text-slate-400`,children:[(0,R.jsx)(Fr,{className:`w-3.5 h-3.5`}),(0,R.jsx)(`span`,{children:e})]}),i.attachments?.length?(0,R.jsx)(rb,{attachments:i.attachments,isMobile:t,onOpenAttachmentPreview:o}):null,i.reasoning?(0,R.jsxs)(`details`,{className:`group/details mb-3 overflow-hidden rounded-lg border border-emerald-200/70 bg-emerald-50/40 text-sm text-slate-600 transition-colors open:bg-white dark:border-emerald-900/50 dark:bg-emerald-950/10 dark:text-slate-300 dark:open:bg-slate-950/30`,children:[(0,R.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 border-l-2 border-emerald-400 px-3 py-2 font-medium outline-none marker:hidden dark:border-emerald-500`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[n&&r&&!i.content?(0,R.jsx)(ai,{className:`h-4 w-4 animate-spin text-emerald-500`}):(0,R.jsx)(Ir,{className:`h-4 w-4 text-emerald-500`}),(0,R.jsx)(`span`,{className:`truncate`,children:`思考过程`}),(0,R.jsx)(`span`,{className:`rounded-full bg-emerald-100 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300`,children:n&&r&&!i.content?`生成中`:`已完成`})]}),(0,R.jsx)(Lr,{className:`h-4 w-4 flex-shrink-0 text-slate-400 transition-transform group-open/details:rotate-180`})]}),(0,R.jsx)(`div`,{className:`border-t border-emerald-100/80 bg-white/70 dark:border-emerald-950 dark:bg-slate-950/20`,children:(0,R.jsx)(`div`,{className:`custom-scrollbar max-h-[min(46vh,28rem)] overflow-y-auto px-4 py-3 text-[14px] leading-7 text-slate-600 dark:text-slate-300 [&_p]:my-2 [&_pre]:my-2`,children:(0,R.jsx)(Uy,{content:i.reasoning})})})]}):null,i.tools?Object.values(i.tools).map((e,t)=>(0,R.jsxs)(`details`,{open:e.status===`paused`?!0:void 0,className:L(`group/details mb-3 rounded-xl border px-3 py-2.5 text-sm transition-all`,e.status===`paused`?`border-amber-200 bg-amber-50/50 text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/20 dark:text-amber-200`:e.status===`error`?`border-rose-200 bg-rose-50/40 text-rose-700 dark:border-rose-900/60 dark:bg-rose-950/20 dark:text-rose-200`:`border-blue-200 bg-blue-50/30 text-blue-600 dark:border-blue-900/50 dark:bg-blue-950/20 dark:text-blue-400`),children:[(0,R.jsx)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 font-medium`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.status===`running`?(0,R.jsx)(ai,{className:`h-4 w-4 animate-spin text-blue-500`}):e.status===`paused`?(0,R.jsx)(ui,{className:`h-4 w-4 text-amber-500`}):e.status===`error`?(0,R.jsx)(zr,{className:`h-4 w-4 text-rose-500`}):(0,R.jsx)(Ir,{className:`h-4 w-4 text-emerald-500`}),(0,R.jsxs)(`span`,{children:[e.status===`paused`?`等待审批:`:e.status===`error`?`工具调用失败:`:`工具调用:`,e.name]})]})}),(0,R.jsxs)(`div`,{className:L(`mx-1 mt-3 flex flex-col gap-3 border-l-2 py-1 pl-4 font-mono text-[13px] leading-relaxed opacity-90`,e.status===`paused`?`border-amber-200 dark:border-amber-800`:e.status===`error`?`border-rose-200 dark:border-rose-800`:`border-blue-200 dark:border-blue-800`),children:[e.status===`paused`&&e.approvalRequestId?(0,R.jsxs)(`div`,{className:`rounded-2xl border border-amber-200 bg-white/75 p-3 font-sans text-sm text-amber-900 shadow-sm dark:border-amber-900/70 dark:bg-slate-950/40 dark:text-amber-100`,children:[(0,R.jsx)(`div`,{className:`font-medium`,children:`该工具调用需要人工确认后继续。`}),e.serverLabel?(0,R.jsxs)(`div`,{className:`mt-1 text-xs text-amber-700/80 dark:text-amber-200/80`,children:[`MCP Server: `,e.serverLabel]}):null,(0,R.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,R.jsxs)(`button`,{type:`button`,disabled:e.approvalStatus===`approved`||e.approvalStatus===`rejected`,onClick:()=>s({approvalRequestId:e.approvalRequestId||``,approve:!0,previousResponseId:e.previousResponseId}),className:`inline-flex items-center gap-1.5 rounded-xl bg-emerald-600 px-3 py-1.5 text-xs font-semibold text-white shadow-sm transition hover:bg-emerald-500 disabled:cursor-not-allowed disabled:opacity-55`,children:[(0,R.jsx)(Ir,{className:`h-3.5 w-3.5`}),`批准并继续`]}),(0,R.jsxs)(`button`,{type:`button`,disabled:e.approvalStatus===`approved`||e.approvalStatus===`rejected`,onClick:()=>s({approvalRequestId:e.approvalRequestId||``,approve:!1,previousResponseId:e.previousResponseId}),className:`inline-flex items-center gap-1.5 rounded-xl border border-rose-200 bg-white px-3 py-1.5 text-xs font-semibold text-rose-600 shadow-sm transition hover:bg-rose-50 disabled:cursor-not-allowed disabled:opacity-55 dark:border-rose-900/70 dark:bg-slate-950 dark:text-rose-300 dark:hover:bg-rose-950/30`,children:[(0,R.jsx)(zr,{className:`h-3.5 w-3.5`}),`拒绝`]})]})]}):null,e.args?(0,R.jsx)(ab,{label:`入参 (Args)`,tone:`input`,value:e.args}):null,e.output?(0,R.jsx)(ab,{label:`输出 (Output)`,tone:e.status===`error`?`error`:`output`,value:e.output}):null]})]},`${e.name}-${t}`)):null,(0,R.jsx)(`div`,{className:`w-full break-words`,children:i.content?(0,R.jsx)(Uy,{content:i.content}):n&&r&&!i.reasoning&&!i.tools?(0,R.jsx)(`span`,{className:`ml-1 mt-2 inline-block h-4 w-2 animate-pulse rounded-sm bg-emerald-500 align-middle opacity-80 shadow-sm`}):null}),(0,R.jsx)(ob,{isLastMessage:r,isStreaming:n,message:i,onDeleteFeedback:a,onSubmitFeedback:c})]})}function cb({agentName:e,isMobile:t,isStreaming:n,activity:r,contextIndicator:i,messages:a,onDeleteFeedback:o,onOpenAttachmentPreview:s,onRespondToApproval:c,onSubmitFeedback:l,onStopGeneration:u,onCancelRemote:d,checkpoints:f=[],onResumeCheckpoint:p,scrollRef:m}){return(0,R.jsxs)(`div`,{ref:m,className:L(`custom-scrollbar relative min-h-0 flex-1 overflow-y-auto scroll-smooth`,t?`px-3 py-3`:`px-4 py-5`),children:[(0,R.jsxs)(`div`,{className:L(`mx-auto flex w-full max-w-[64rem] flex-col`,r?`pb-10 sm:pb-10`:`pb-6 sm:pb-8`),children:[(0,R.jsx)(nb,{checkpoints:f,isStreaming:n,onResumeCheckpoint:p}),a.length===0?(0,R.jsx)(Xy,{agentName:e}):a.map((r,i)=>r.role===`system`?(0,R.jsx)(ib,{message:r},r.id||i):(0,R.jsx)(sb,{agentName:e,isMobile:t,isStreaming:n,isLastMessage:i===a.length-1,message:r,onDeleteFeedback:o,onOpenAttachmentPreview:s,onRespondToApproval:c,onSubmitFeedback:l},r.id||i))]}),r?(0,R.jsx)(`div`,{className:`sticky bottom-1 z-20 mx-auto flex w-full max-w-[64rem] justify-end`,children:(0,R.jsx)(Yy,{activity:r,contextIndicator:i,onStopGeneration:u,onCancelRemote:d})}):null]})}var lb=ml,ub=hl,db=b.forwardRef(({className:e,...t},n)=>(0,R.jsx)(gl,{ref:n,className:L(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t}));db.displayName=gl.displayName;var fb=b.forwardRef(({className:e,children:t,...n},r)=>(0,R.jsxs)(ub,{children:[(0,R.jsx)(db,{}),(0,R.jsxs)(_l,{ref:r,className:L(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg`,e),...n,children:[t,(0,R.jsxs)(bl,{className:`absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground`,children:[(0,R.jsx)(gi,{className:`h-4 w-4`}),(0,R.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}));fb.displayName=_l.displayName;var pb=({className:e,...t})=>(0,R.jsx)(`div`,{className:L(`flex flex-col space-y-1.5 text-center sm:text-left`,e),...t});pb.displayName=`DialogHeader`;var mb=({className:e,...t})=>(0,R.jsx)(`div`,{className:L(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});mb.displayName=`DialogFooter`;var hb=b.forwardRef(({className:e,...t},n)=>(0,R.jsx)(vl,{ref:n,className:L(`text-lg font-semibold leading-none tracking-tight`,e),...t}));hb.displayName=vl.displayName;var gb=b.forwardRef(({className:e,...t},n)=>(0,R.jsx)(yl,{ref:n,className:L(`text-sm text-muted-foreground`,e),...t}));gb.displayName=yl.displayName;function _b(e,t){if(!(!t||e))return{width:`min(${t.width}px, calc(100vw - 5rem))`,height:`min(${t.height}px, calc(100vh - 9rem))`}}function vb(e,t){if(!(!t||e))return{width:`min(${t.width+32}px, calc(100vw - 3rem))`}}function yb({attachment:e,isMobile:t,previewImageSize:n,onClose:r,onImageLoad:i}){return(0,R.jsx)(lb,{open:!!e?.url,onOpenChange:e=>!e&&r(),children:(0,R.jsxs)(fb,{className:L(`gap-0 overflow-hidden border-slate-700 bg-slate-950 p-0 text-slate-100 shadow-2xl [&>button]:right-3 [&>button]:top-3 [&>button]:rounded-md [&>button]:border [&>button]:border-slate-700 [&>button]:bg-slate-900/70 [&>button]:p-1.5 [&>button]:text-slate-200 [&>button]:opacity-100`,t?`left-0 top-0 h-[var(--app-height)] max-h-[var(--app-height)] w-screen max-w-none translate-x-0 translate-y-0 rounded-none border-0`:`max-h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)] rounded-2xl`),style:vb(t,n),children:[(0,R.jsx)(`div`,{className:`flex items-center gap-3 border-b border-slate-800 px-4 py-3 pr-16`,children:(0,R.jsx)(hb,{className:`truncate text-sm font-medium`,children:e?.name||`附件预览`})}),(0,R.jsx)(`div`,{className:L(`flex items-center justify-center overflow-auto bg-slate-950`,t?`h-full p-4 pb-[calc(var(--safe-area-bottom)+1rem)]`:`max-h-[calc(100vh-7rem)] p-4`),children:e?e.type.startsWith(`image/`)?(0,R.jsx)(`img`,{src:e.url,alt:e.name,className:L(`object-contain`,t?`h-auto max-h-full w-full max-w-full`:`h-auto w-auto max-h-[calc(100vh-9rem)] max-w-[calc(100vw-5rem)]`),style:_b(t,n),onLoad:e=>{let t=e.currentTarget;i({width:t.naturalWidth,height:t.naturalHeight})}}):(0,R.jsx)(`iframe`,{src:e.url,title:e.name,className:`h-full min-h-[24rem] w-full rounded-xl border border-slate-800 bg-white`}):null})]})})}function bb(e){if(typeof e==`number`&&Number.isFinite(e)&&e>0)return e;if(typeof e==`string`&&e.trim()){let t=Number(e);if(Number.isFinite(t)&&t>0)return t}return null}function xb(e){return/[\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF]/u.test(e)}function Sb(e){let t=String(e||``).trim();if(!t)return 0;let n=0,r=0;for(let e of t){if(xb(e)){n+=1;continue}r+=1}return Math.max(1,n+Math.ceil(r/4))}function Cb(e){if(!e)return 0;if(e.role===`system`)return e.eventType===`context_checkpoint`?Sb(e.summary||``):0;let t=Sb(e.content||``);return e.tools&&(t+=Object.values(e.tools).reduce((e,t)=>e+Sb(t?.name||``)+Sb(t?.args||``)+Sb(t?.output||``),0)),t}function wb(e){return e?bb(e.context_window_tokens)??bb(e?.limits?.context_window_tokens):null}function Tb(e){return e?bb(e.auto_compact_threshold_percentage)??84:84}function Eb({messages:e,draftInput:t,selectedModel:n}){let r=wb(n);if(!r)return null;let i=[...e||[]].reverse().find(e=>e?.role===`system`&&e?.eventType===`context_checkpoint`&&e?.status===`running`);if(i){let e=Cb(i);return{label:`正在压缩上下文…`,phase:`compressing`,usedTokens:e,contextWindowTokens:r,percent:Math.min(100,Math.max(0,Math.round(e/r*100)))}}let a=(e||[]).reduce((e,t)=>e+Cb(t),0)+Sb(t||``);if(a<=0)return null;let o=Math.min(100,Math.max(0,Math.round(a/r*100)));return o>=Tb(n)?{label:`估算上下文 ${o}% · 即将压缩`,phase:`warning`,percent:o,usedTokens:a,contextWindowTokens:r}:{label:`估算上下文 ${o}%`,phase:`normal`,percent:o,usedTokens:a,contextWindowTokens:r}}function Db({agentName:e,isMobile:t,onDeleteFeedback:n,onSubmitFeedback:r,onRespondToApproval:i,onStopGeneration:a,onCancelRemote:o,checkpointResumeEnabled:s=!1,onResumeCheckpoint:c}){let l=vt(e=>e.messages),u=M(e=>e.currentSessionId),d=j(e=>!!(e.getSessionActivity(u)&&e.isSessionStreaming(u))),f=j(e=>e.getSessionActivity(u)),p=pn(e=>e.getSessionCheckpoints(u)),m=D(e=>e.input),h=le(e=>e.availableModels),g=le(e=>e.selectedModel),_=D(e=>e.previewAttachment),v=D(e=>e.previewImageSize),y=(0,b.useRef)(null),x=(0,b.useRef)(!0),S=(0,b.useRef)(!1),C=(0,b.useRef)(0),w=(0,b.useRef)(d),T=(0,b.useMemo)(()=>h.find(e=>e.id===g)||null,[h,g]),E=(0,b.useMemo)(()=>Eb({messages:l,draftInput:m,selectedModel:T}),[m,l,T]);return(0,b.useEffect)(()=>{w.current=d},[d]),(0,b.useEffect)(()=>{let e=y.current;if(!e)return;let t=()=>{let t=e.scrollHeight-e.scrollTop-e.clientHeight,n=e.scrollTop<C.current-2;if(C.current=e.scrollTop,w.current&&n){S.current=!0,x.current=!1;return}if(S.current){let e=t<=12;S.current=!e,x.current=e;return}x.current=t<96};return t(),e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[]),(0,b.useEffect)(()=>{let e=y.current;!e||!x.current||(e.scrollTop=e.scrollHeight,C.current=e.scrollTop)},[l,d]),(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(cb,{agentName:e,isMobile:t,isStreaming:d,activity:f,contextIndicator:E,messages:l,onDeleteFeedback:n,onOpenAttachmentPreview:e=>{D.getState().setPreviewAttachment(e),D.getState().setPreviewImageSize(null)},onRespondToApproval:i,onSubmitFeedback:r,onStopGeneration:a,onCancelRemote:o,checkpoints:s?p:[],onResumeCheckpoint:c,scrollRef:y}),(0,R.jsx)(yb,{attachment:_,isMobile:t,previewImageSize:v,onClose:()=>{D.getState().setPreviewAttachment(null),D.getState().setPreviewImageSize(null)},onImageLoad:e=>D.getState().setPreviewImageSize(e)})]})}function Ob({attachments:e,composerContextIndicator:t,composerMaxHeight:n,fileInputRef:r,input:i,isMobile:a,isStreaming:o,queuedDrafts:s,onAppendAttachments:c,onInputChange:l,onPaste:u,onRemoveAttachment:d,onStopGeneration:f,onCancelRemote:p,onSubmit:m,textareaRef:h}){let g=a?`发送消息...`:`发送消息... (Shift + Enter 换行)`,_=p?`保留恢复点并结束本次执行`:`停止生成`;return(0,R.jsx)(`div`,{className:`relative z-10 flex-shrink-0 bg-white/95 px-3 py-3 backdrop-blur dark:bg-slate-900/95 sm:px-4 sm:py-3`,children:(0,R.jsxs)(`div`,{className:`mx-auto w-full max-w-[64rem]`,children:[s.length>0?(0,R.jsxs)(`div`,{className:`mb-2 rounded-2xl border border-amber-200/80 bg-amber-50/80 px-3 py-2 text-xs text-amber-900 shadow-sm dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100`,children:[(0,R.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`span`,{className:`font-semibold`,children:[`发送队列 · `,s.length]}),(0,R.jsx)(`span`,{className:`text-amber-700/75 dark:text-amber-200/75`,children:`当前回复完成后依次发送`})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[s.slice(0,3).map((e,t)=>{let n=e.text.trim()||(e.attachments.length>0?`仅附件消息`:`空消息`);return(0,R.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-white/70 px-2 py-1.5 dark:bg-slate-950/35`,children:[(0,R.jsx)(`span`,{className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-full bg-amber-100 font-mono text-[10px] text-amber-700 dark:bg-amber-900/50 dark:text-amber-100`,children:t+1}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-slate-700 dark:text-slate-200`,children:n}),e.attachments.length>0?(0,R.jsxs)(`span`,{className:`flex-shrink-0 rounded-full bg-amber-100 px-2 py-0.5 text-[10px] text-amber-700 dark:bg-amber-900/50 dark:text-amber-100`,children:[e.attachments.length,` 附件`]}):null]},`${t}-${n}-${e.attachments.length}`)}),s.length>3?(0,R.jsxs)(`div`,{className:`px-2 pt-0.5 text-[11px] text-amber-700/80 dark:text-amber-200/80`,children:[`还有 `,s.length-3,` 条等待发送`]}):null]})]}):null,(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsxs)(`form`,{onSubmit:t=>{if(t.preventDefault(),o){p?p():f();return}let n=i.trim();!n&&e.length===0||m(n,e)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.files&&e.dataTransfer.files.length>0&&c(Array.from(e.dataTransfer.files))},className:`relative flex min-w-0 flex-1 flex-col rounded-[1.25rem] border border-slate-200 bg-white p-1.5 shadow-[0_8px_22px_rgba(15,23,42,0.07)] transition-all focus-within:border-slate-300 focus-within:ring-1 focus-within:ring-slate-300 dark:border-slate-700 dark:bg-slate-900 dark:focus-within:border-slate-600 dark:focus-within:ring-slate-600`,children:[e.length>0?(0,R.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-2 px-1.5 pt-1.5`,children:e.map((e,t)=>(0,R.jsxs)(`div`,{className:L(`flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-100 px-3 py-1.5 text-xs text-slate-600 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300`,a?`max-w-full`:``),children:[(0,R.jsx)(`span`,{className:`max-w-[10rem] truncate font-medium sm:max-w-[12rem]`,children:e.name}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>d(t),className:`text-slate-400 transition hover:text-red-500`,"aria-label":`移除附件 ${e.name}`,children:`×`})]},`${e.name}-${e.size}-${t}`))}):null,(0,R.jsxs)(`div`,{className:`flex w-full items-end gap-2`,children:[(0,R.jsxs)(`label`,{className:`relative flex h-9 w-9 flex-shrink-0 items-center justify-center overflow-hidden rounded-xl text-slate-400 transition hover:bg-slate-100 hover:text-slate-600 dark:hover:bg-slate-800 dark:hover:text-slate-200`,title:`上传附件`,children:[(0,R.jsx)(`input`,{ref:r,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&e.target.files.length>0&&(c(Array.from(e.target.files)),e.target.value=``)}}),(0,R.jsx)(ri,{className:`h-5 w-5`})]}),(0,R.jsx)(`textarea`,{ref:h,rows:1,value:i,onChange:l,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},onPaste:u,placeholder:g,className:L(`custom-scrollbar min-h-[38px] w-full resize-none border-0 bg-transparent px-2 py-1.5 text-[15px] leading-6 outline-none placeholder:text-slate-400 dark:text-slate-100 dark:placeholder:text-slate-500`,a?`text-[16px]`:`text-[15px]`),style:{maxHeight:`${n}px`,overflowY:`auto`}}),(0,R.jsx)(`button`,{type:`submit`,disabled:!o&&!i.trim()&&e.length===0,className:L(`flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-xl transition-all`,o||i.trim()||e.length>0?`bg-slate-900 text-white hover:bg-slate-800 dark:bg-slate-100 dark:text-slate-900 dark:hover:bg-white`:`bg-slate-100 text-slate-400 dark:bg-slate-800 dark:text-slate-600`),title:o?_:`发送消息`,children:o?(0,R.jsx)(Rr,{className:`h-4 w-4`}):(0,R.jsx)(li,{className:`ml-0.5 h-4 w-4`})})]})]}),t?(0,R.jsxs)(`div`,{className:L(`hidden flex-shrink-0 items-center gap-1.5 rounded-full px-2.5 py-1 text-right text-[11px] leading-5 transition-colors sm:inline-flex`,t.phase===`compressing`?`bg-amber-50 text-amber-600 dark:bg-amber-950/30 dark:text-amber-300`:t.phase===`warning`?`bg-rose-50 text-rose-600 dark:bg-rose-950/30 dark:text-rose-300`:`bg-slate-50 text-slate-400 dark:bg-slate-800/50 dark:text-slate-500`),children:[(0,R.jsx)(ui,{className:`h-3 w-3`}),t.label]}):null]})]})})}function kb(e){return[e.name,e.size,e.lastModified,e.type].join(`:`)}function Ab(e,t){let n=new Map;for(let t of e)n.set(kb(t),t);for(let e of t)n.set(kb(e),e);return Array.from(n.values())}function jb(e){return Array.from(e.clipboardData.items||[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>!!e)}function Mb({composerMaxHeight:e,submitDraft:t,stopGeneration:n,cancelRemote:r,isMobile:i}){let a=D(e=>e.input),o=D(e=>e.attachments),s=M(e=>e.currentSessionId),c=j(e=>!!(e.getSessionActivity(s)&&e.isSessionStreaming(s))),l=D(e=>e.queuedDrafts),u=vt(e=>e.messages),d=le(e=>e.availableModels),f=le(e=>e.selectedModel),p=(0,b.useRef)(null),m=(0,b.useRef)(null),h=(0,b.useMemo)(()=>d.find(e=>e.id===f)||null,[d,f]),g=(0,b.useMemo)(()=>Eb({messages:u,draftInput:a,selectedModel:h}),[a,u,h]),_=(0,b.useCallback)((e,n)=>{!e&&n.length===0||(D.getState().setInput(``),D.getState().setAttachments([]),t(e,n))},[t]);(0,b.useEffect)(()=>{m.current&&(m.current.style.height=`auto`,m.current.style.height=`${Math.min(m.current.scrollHeight,e)}px`)},[a,e]);let v=t=>{D.getState().setInput(t.target.value),t.target.style.height=`auto`,t.target.style.height=`${Math.min(t.target.scrollHeight,e)}px`},y=e=>{e.length&&D.getState().setAttachments(t=>Ab(t,e))};return(0,R.jsx)(Ob,{attachments:o,composerContextIndicator:g,composerMaxHeight:e,fileInputRef:p,input:a,isMobile:i,isStreaming:c,queuedDrafts:l,onAppendAttachments:y,onInputChange:v,onPaste:e=>{let t=jb(e);t.length&&(e.preventDefault(),e.stopPropagation(),y(t))},onRemoveAttachment:e=>D.getState().setAttachments(t=>t.filter((t,n)=>n!==e)),onStopGeneration:n,onCancelRemote:r,onSubmit:_,textareaRef:m})}var Nb=(0,b.lazy)(()=>W(()=>import(`./NativeTerminalPanel-Cyqpkjbr.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function Pb({availableModels:e,selectedModel:t,onSelectModel:n,selectedModelLabel:r,modelCatalogLoaded:i,modelSource:a,thinkingEnabled:o,thinkingMode:s,onSelectThinkingMode:c,compact:l=!1}){let u=L(`rounded-full border border-slate-200 bg-white px-3 py-2 text-sm text-slate-700 outline-none transition-colors focus:ring-1 focus:ring-blue-500 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-300`,l?`w-full`:`max-w-[13rem]`),d=e.length>1?(0,R.jsx)(`select`,{value:t,onChange:e=>n(e.target.value),className:u,children:e.map(e=>(0,R.jsx)(`option`,{value:e.id,children:e.display_name||e.id},e.id))}):r?(0,R.jsx)(`span`,{className:L(u,`inline-flex max-w-full items-center`,l?`justify-start`:``),title:a||r,children:(0,R.jsx)(`span`,{className:`truncate`,children:r})}):(0,R.jsx)(`span`,{className:`text-sm text-slate-400`,children:i?`未配置模型`:`Loading models...`}),f=o?(0,R.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),className:L(u,l?``:`max-w-[9rem]`),title:`控制模型 thinking/reasoning 参数`,children:[(0,R.jsx)(`option`,{value:`auto`,children:`思考自动`}),(0,R.jsx)(`option`,{value:`enabled`,children:`开启思考`}),(0,R.jsx)(`option`,{value:`disabled`,children:`关闭思考`})]}):null;return(0,R.jsxs)(`div`,{className:L(`flex min-w-0 gap-2`,l?`w-full flex-col`:`items-center`),children:[d,f]})}function Fb({agentName:e,currentSessionId:t,isMobile:n,sidebarOpen:r,mobileSidebarOpen:i,onToggleSidebar:a,availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m,mobileActionsOpen:h,onMobileActionsOpenChange:g,workspaceEnabled:_,onOpenWorkspace:v,nativeManagementLink:y,nativeTerminal:x,nativeLauncherMode:S=!1}){let[C,w]=(0,b.useState)(!1),T=!!x?.Enabled,E=n?i?(0,R.jsx)(ti,{className:`h-5 w-5`}):(0,R.jsx)(ni,{className:`h-5 w-5`}):r?(0,R.jsx)(ti,{className:`h-5 w-5`}):(0,R.jsx)(ni,{className:`h-5 w-5`});return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`header`,{className:L(`flex flex-shrink-0 items-center justify-between border-b border-slate-200/30 bg-white/95 px-3 py-2 backdrop-blur dark:border-slate-800 dark:bg-slate-900/95 sm:px-4`,n?`pt-[calc(var(--safe-area-top)+0.5rem)]`:`h-14`),children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[S?null:(0,R.jsx)(`button`,{type:`button`,onClick:a,className:`rounded-lg p-2 text-slate-500 transition-colors hover:bg-slate-100 dark:hover:bg-slate-800`,"aria-label":n?`打开历史记录`:`切换侧边栏`,children:E}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100 sm:text-base`,children:e}),(0,R.jsx)(`div`,{className:`text-[11px] text-slate-400 dark:text-slate-500`,children:S?`原生运行时入口`:`智能体`})]})]}),n?(0,R.jsx)(`button`,{type:`button`,onClick:()=>g(!0),className:`rounded-lg p-2 text-slate-500 transition-colors hover:bg-slate-100 dark:hover:bg-slate-800`,"aria-label":`打开会话操作`,children:(0,R.jsx)(Ur,{className:`h-5 w-5`})}):(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[y?(0,R.jsxs)(`a`,{href:y.href,target:`_blank`,rel:`noreferrer`,title:y.title,className:`inline-flex flex-shrink-0 items-center gap-1.5 whitespace-nowrap rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm font-medium leading-none text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,R.jsx)(Wr,{className:`h-4 w-4`}),(0,R.jsx)(`span`,{children:y.label})]}):null,_?(0,R.jsxs)(`button`,{type:`button`,onClick:v,className:`inline-flex flex-shrink-0 items-center gap-1.5 whitespace-nowrap rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm font-medium leading-none text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,R.jsx)(Jr,{className:`h-4 w-4`}),(0,R.jsx)(`span`,{children:`Workspace`})]}):null,T?(0,R.jsxs)(`button`,{type:`button`,onClick:()=>w(!0),className:`inline-flex flex-shrink-0 items-center gap-1.5 whitespace-nowrap rounded-xl border border-emerald-200 bg-emerald-50 px-3 py-2 text-sm font-medium leading-none text-emerald-800 transition hover:bg-emerald-100 dark:border-emerald-900/70 dark:bg-emerald-950/40 dark:text-emerald-200`,children:[(0,R.jsx)(di,{className:`h-4 w-4`}),(0,R.jsx)(`span`,{children:`TUI`})]}):null,S?null:(0,R.jsx)(Pb,{availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m}),!S&&t?(0,R.jsxs)(`span`,{className:`rounded bg-slate-50 px-2 py-1 text-xs font-mono text-slate-400 dark:bg-slate-800`,children:[`ID: `,t.slice(0,8)]}):null]})]}),n?(0,R.jsx)(wl,{open:h,onOpenChange:g,children:(0,R.jsxs)(Ol,{side:`bottom`,className:`rounded-t-[1.75rem] border-slate-200 bg-white px-4 pb-[calc(var(--safe-area-bottom)+1rem)] pt-6 dark:border-slate-800 dark:bg-slate-900`,children:[(0,R.jsxs)(kl,{className:`text-left`,children:[(0,R.jsx)(jl,{children:`会话设置`}),(0,R.jsx)(Ml,{className:`sr-only`,children:`调整当前会话的模型和 Workspace 操作。`})]}),(0,R.jsxs)(`div`,{className:`mt-6 flex flex-col gap-4`,children:[_?(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{g(!1),v()},className:`inline-flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm font-medium text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,R.jsx)(Jr,{className:`h-4 w-4`}),`工作区文件`]}):null,T?(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{g(!1),w(!0)},className:`inline-flex items-center gap-2 rounded-xl border border-emerald-200 bg-emerald-50 px-3 py-3 text-sm font-medium text-emerald-800 transition hover:bg-emerald-100 dark:border-emerald-900/70 dark:bg-emerald-950/40 dark:text-emerald-200`,children:[(0,R.jsx)(di,{className:`h-4 w-4`}),`原生 TUI`]}):null,y?(0,R.jsxs)(`a`,{href:y.href,target:`_blank`,rel:`noreferrer`,title:y.title,onClick:()=>g(!1),className:`inline-flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm font-medium text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,R.jsx)(Wr,{className:`h-4 w-4`}),y.label]}):null,S?(0,R.jsx)(`div`,{className:`rounded-2xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm leading-6 text-slate-600 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300`,children:`当前运行时对话在原生管理台中进行;这里保留管理入口和 Workspace 文件操作。`}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-slate-400 dark:text-slate-500`,children:`模型`}),(0,R.jsx)(Pb,{availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m,compact:!0})]}),(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-slate-400 dark:text-slate-500`,children:`当前会话`}),(0,R.jsx)(`div`,{className:`rounded-2xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm text-slate-600 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300`,children:t?(0,R.jsx)(`span`,{className:`break-all font-mono`,children:t}):`新对话尚未创建会话 ID`})]})]})]})]})}):null,x&&C?(0,R.jsx)(b.Suspense,{fallback:null,children:(0,R.jsx)(Nb,{capability:x,open:C,onClose:()=>w(!1)})}):null]})}var Ib=(0,b.lazy)(()=>W(()=>import(`./NativeTerminalPanel-Cyqpkjbr.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function Lb({productLabel:e=`原生运行时`,nativeManagementLink:t,nativeTerminal:n,workspaceEnabled:r,onOpenWorkspace:i}){let a=!!n?.Enabled,[o,s]=(0,b.useState)(!1);return(0,R.jsxs)(`section`,{className:`flex min-h-0 flex-1 overflow-y-auto bg-[radial-gradient(circle_at_top_left,rgba(14,165,233,0.12),transparent_34%),linear-gradient(135deg,#f8fafc_0%,#ffffff_48%,#f1f5f9_100%)] px-4 py-8 dark:bg-[radial-gradient(circle_at_top_left,rgba(14,165,233,0.16),transparent_34%),linear-gradient(135deg,#020617_0%,#0f172a_52%,#111827_100%)] sm:px-8`,children:[(0,R.jsx)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col justify-center`,children:(0,R.jsxs)(`div`,{className:`overflow-hidden rounded-[2rem] border border-slate-200/80 bg-white/90 shadow-xl shadow-slate-200/60 backdrop-blur dark:border-slate-800 dark:bg-slate-900/85 dark:shadow-black/30`,children:[(0,R.jsxs)(`div`,{className:`border-b border-slate-200/80 bg-slate-50/80 px-6 py-5 dark:border-slate-800 dark:bg-slate-950/40 sm:px-8`,children:[(0,R.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full border border-sky-200 bg-sky-50 px-3 py-1 text-xs font-medium text-sky-700 dark:border-sky-900/60 dark:bg-sky-950/50 dark:text-sky-300`,children:[(0,R.jsx)(ui,{className:`h-3.5 w-3.5`}),e,` native runtime`]}),(0,R.jsx)(`h1`,{className:`mt-5 text-2xl font-semibold tracking-tight text-slate-950 dark:text-slate-50 sm:text-3xl`,children:`对话请使用原生管理台`}),(0,R.jsx)(`p`,{className:`mt-3 max-w-2xl text-sm leading-6 text-slate-600 dark:text-slate-300 sm:text-base`,children:`当前运行时的对话状态由原生管理台承载。AgentEngine Hosted UI 在这里保留统一入口和 Workspace 文件管理,不重复实现运行时内部已有的复杂对话状态机。`})]}),(0,R.jsxs)(`div`,{className:`grid gap-4 p-6 md:grid-cols-3 sm:p-8`,children:[(0,R.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,R.jsx)(`div`,{className:`flex h-11 w-11 items-center justify-center rounded-2xl bg-slate-950 text-white dark:bg-slate-100 dark:text-slate-950`,children:(0,R.jsx)(Qr,{className:`h-5 w-5`})}),(0,R.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`原生管理台`}),(0,R.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`使用原生管理台处理对话、工具卡片、思考流、审批、中断和运行时历史,避免跨状态机不一致。`}),t?(0,R.jsxs)(`a`,{href:t.href,target:`_blank`,rel:`noreferrer`,title:t.title,className:`mt-5 inline-flex items-center gap-2 rounded-2xl bg-slate-950 px-4 py-2.5 text-sm font-medium text-white transition hover:bg-slate-800 dark:bg-slate-100 dark:text-slate-950 dark:hover:bg-white`,children:[(0,R.jsx)(Wr,{className:`h-4 w-4`}),`打开`,t.label]}):(0,R.jsx)(`div`,{className:`mt-5 rounded-2xl border border-amber-200 bg-amber-50 px-4 py-3 text-sm leading-6 text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-200`,children:`当前访问模式不开放原生管理入口。需要完整对话体验时,请使用 owner/private 链接或 CLI。`})]}),(0,R.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,R.jsx)(`div`,{className:`flex h-11 w-11 items-center justify-center rounded-2xl bg-sky-100 text-sky-700 dark:bg-sky-950 dark:text-sky-300`,children:(0,R.jsx)(Jr,{className:`h-5 w-5`})}),(0,R.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`Workspace 文件管理`}),(0,R.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`文件浏览、上传、预览仍由 Hosted UI 提供,和原生管理台组合使用覆盖对话与工作区。`}),r?(0,R.jsxs)(`button`,{type:`button`,onClick:i,className:`mt-5 inline-flex items-center gap-2 rounded-2xl border border-slate-200 bg-slate-50 px-4 py-2.5 text-sm font-medium text-slate-800 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-100 dark:hover:bg-slate-700`,children:[(0,R.jsx)(Jr,{className:`h-4 w-4`}),`打开 Workspace`]}):(0,R.jsx)(`div`,{className:`mt-5 rounded-2xl border border-slate-200 bg-slate-50 px-4 py-3 text-sm leading-6 text-slate-500 dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-400`,children:`当前链接未开放 Workspace 文件管理。Owner 或 private 链接可使用该能力。`})]}),(0,R.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,R.jsx)(`div`,{className:`flex h-11 w-11 items-center justify-center rounded-2xl bg-emerald-100 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300`,children:(0,R.jsx)(di,{className:`h-5 w-5`})}),(0,R.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`原生 TUI`}),(0,R.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`如果运行时暴露安全的 ks-terminal.v1 通道,可以在这里进入原生终端 UI;share 链接不会开放该入口。`}),a?(0,R.jsxs)(`button`,{type:`button`,onClick:()=>s(!0),className:`mt-5 inline-flex items-center gap-2 rounded-2xl border border-emerald-200 bg-emerald-50 px-4 py-2.5 text-sm font-medium text-emerald-800 transition hover:bg-emerald-100 dark:border-emerald-900/70 dark:bg-emerald-950/40 dark:text-emerald-200`,children:[(0,R.jsx)(di,{className:`h-4 w-4`}),`打开 TUI`]}):(0,R.jsx)(`div`,{className:`mt-5 rounded-2xl border border-slate-200 bg-slate-50 px-4 py-3 text-sm leading-6 text-slate-500 dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-400`,children:`当前运行时未声明可用的浏览器 TUI 能力。`})]})]})]})}),n&&o?(0,R.jsx)(b.Suspense,{fallback:null,children:(0,R.jsx)(Ib,{capability:n,open:o,onClose:()=>s(!1)})}):null]})}var Rb=[],zb=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?zb:Rb).push(n+=e[t])})();function Bb(e){if(e<768)return!1;for(let t=0,n=Rb.length;;){let r=t+n>>1;if(e<Rb[r])n=r;else if(e>=zb[r])t=r+1;else return!0;if(t==n)return!1}}function Vb(e){return e>=127462&&e<=127487}var Hb=8205;function Ub(e,t,n=!0,r=!0){return(n?Wb:Gb)(e,t,r)}function Wb(e,t,n){if(t==e.length)return t;t&&qb(e.charCodeAt(t))&&Jb(e.charCodeAt(t-1))&&t--;let r=Kb(e,t);for(t+=Yb(r);t<e.length;){let i=Kb(e,t);if(r==Hb||i==Hb||n&&Bb(i))t+=Yb(i),r=i;else if(Vb(i)){let n=0,r=t-2;for(;r>=0&&Vb(Kb(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function Gb(e,t,n){for(;t>0;){let r=Wb(e,t-2,n);if(r<t)return r;t--}return 0}function Kb(e,t){let n=e.charCodeAt(t);if(!Jb(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return qb(r)?(n-55296<<10)+(r-56320)+65536:n}function qb(e){return e>=56320&&e<57344}function Jb(e){return e>=55296&&e<56320}function Yb(e){return e<65536?1:2}var Xb=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=ox(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),Qb.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=ox(this,e,t);let n=[];return this.decompose(e,t,n,0),Qb.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new nx(this),i=new nx(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new nx(this,e)}iterRange(e,t=this.length){return new rx(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new ix(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new Zb(t):Qb.from(Zb.split(t,[]))}},Zb=class e extends Xb{constructor(e,t=$b(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new ax(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(tx(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=ex(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=ox(this,t,n);let i=ex(this.text,ex(r.text,tx(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):Qb.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
122
122
  `){[e,t]=ox(this,e,t);let r=``;for(let i=0,a=0;i<=t&&a<this.text.length;a++){let o=this.text[a],s=i+o.length;i>e&&a&&(r+=n),e<s&&t>i&&(r+=o.slice(Math.max(0,e-i),t-i)),i=s+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(t,n){let r=[],i=-1;for(let a of t)r.push(a),i+=a.length+1,r.length==32&&(n.push(new e(r,i)),r=[],i=-1);return i>-1&&n.push(new e(r,i)),n}},Qb=class e extends Xb{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.children[i],o=r+a.length,s=n+a.lines-1;if((t?s:o)>=e)return a.lineInner(e,t,n,r);r=o+1,n=s+1}}decompose(e,t,n,r){for(let i=0,a=0;a<=t&&i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(e<=s&&t>=a){let i=r&(a<=e|(s>=t?2:0));a>=e&&s<=t&&!i?n.push(o):o.decompose(e-a,t-a,n,i)}a=s+1}}replace(t,n,r){if([t,n]=ox(this,t,n),r.lines<this.lines)for(let i=0,a=0;i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(t>=a&&n<=s){let c=o.replace(t-a,n-a,r),l=this.lines-o.lines+c.lines;if(c.lines<l>>4&&c.lines>l>>6){let a=this.children.slice();return a[i]=c,new e(a,this.length-(n-t)+r.length)}return super.replace(a,s,c)}a=s+1}return super.replace(t,n,r)}sliceString(e,t=this.length,n=`
123
123
  `){[e,t]=ox(this,e,t);let r=``;for(let i=0,a=0;i<this.children.length&&a<=t;i++){let o=this.children[i],s=a+o.length;a>e&&i&&(r+=n),e<s&&t>a&&(r+=o.sliceString(e-a,t-a,n)),a=s+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(t,n){if(!(t instanceof e))return 0;let r=0,[i,a,o,s]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=n,a+=n){if(i==o||a==s)return r;let e=this.children[i],c=t.children[a];if(e!=c)return r+e.scanIdentical(c,n);r+=e.length+1}}static from(t,n=t.reduce((e,t)=>e+t.length+1,-1)){let r=0;for(let e of t)r+=e.lines;if(r<32){let e=[];for(let n of t)n.flatten(e);return new Zb(e,n)}let i=Math.max(32,r>>5),a=i<<1,o=i>>1,s=[],c=0,l=-1,u=[];function d(t){let n;if(t.lines>a&&t instanceof e)for(let e of t.children)d(e);else t.lines>o&&(c>o||!c)?(f(),s.push(t)):t instanceof Zb&&c&&(n=u[u.length-1])instanceof Zb&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new Zb(n.text.concat(t.text),n.length+1+t.length)):(c+t.lines>i&&f(),c+=t.lines,l+=t.length+1,u.push(t))}function f(){c!=0&&(s.push(u.length==1?u[0]:e.from(u,l)),l=-1,c=u.length=0)}for(let e of t)d(e);return f(),s.length==1?s[0]:new e(s,n)}};Xb.empty=new Zb([``],0);function $b(e){let t=-1;for(let n of e)t+=n.length+1;return t}function ex(e,t,n=0,r=1e9){for(let i=0,a=0,o=!0;a<e.length&&i<=r;a++){let s=e[a],c=i+s.length;c>=n&&(c>r&&(s=s.slice(0,r-i)),i<n&&(s=s.slice(n-i)),o?(t[t.length-1]+=s,o=!1):t.push(s)),i=c+1}return t}function tx(e,t,n){return ex(e,[``],t,n)}var nx=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value=``,this.nodes=[e],this.offsets=[t>0?1:(e instanceof Zb?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],a=i>>1,o=r instanceof Zb?r.text.length:r.children.length;if(a==(t>0?o:0)){if(n==0)return this.done=!0,this.value=``,this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
124
124
  `,this;e--}else if(r instanceof Zb){let i=r.text[a+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=e==0?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[a+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof Zb?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},rx=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new nx(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value=``,this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=``}},ix=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value=``,this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value=``,this.afterBreak=!1):t?(this.done=!0,this.value=``):n?this.afterBreak?this.value=``:(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<`u`&&(Xb.prototype[Symbol.iterator]=function(){return this.iter()},nx.prototype[Symbol.iterator]=rx.prototype[Symbol.iterator]=ix.prototype[Symbol.iterator]=function(){return this});var ax=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function ox(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function sx(e,t,n=!0,r=!0){return Ub(e,t,n,r)}function cx(e){return e>=56320&&e<57344}function lx(e){return e>=55296&&e<56320}function ux(e,t){let n=e.charCodeAt(t);if(!lx(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return cx(r)?(n-55296<<10)+(r-56320)+65536:n}function dx(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function fx(e){return e<65536?1:2}var px=/\r\n?|\n/,mx=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(mx||={}),hx=class e{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let i=this.sections[t++],a=this.sections[t++];a<0?(e(n,r,i),r+=i):r+=a,n+=i}}iterChangedRanges(e,t=!1){yx(this,e,t)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let n=this.sections[e++],r=this.sections[e++];r<0?t.push(n,r):t.push(r,n)}return new e(t)}composeDesc(e){return this.empty?e:e.empty?this:xx(this,e)}mapDesc(e,t=!1){return e.empty?this:bx(this,e,t)}mapPos(e,t=-1,n=mx.Simple){let r=0,i=0;for(let a=0;a<this.sections.length;){let o=this.sections[a++],s=this.sections[a++],c=r+o;if(s<0){if(c>e)return i+(e-r);i+=o}else{if(n!=mx.Simple&&c>=e&&(n==mx.TrackDel&&r<e&&c>e||n==mx.TrackBefore&&r<e||n==mx.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!o)return e==r||t<0?i:i+s;i+=s}r=c}if(e>r)throw RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let i=this.sections[n++],a=this.sections[n++],o=r+i;if(a>=0&&r<=t&&o>=e)return r<e&&o>t?`cover`:!0;r=o}return!1}toString(){let e=``;for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?` `:``)+n+(r>=0?`:`+r:``)}return e}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!=`number`))throw RangeError(`Invalid JSON representation of ChangeDesc`);return new e(t)}static create(t){return new e(t)}},gx=class e extends hx{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw RangeError(`Applying change set to a document with the wrong length`);return yx(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return bx(this,e,t,!0)}invert(t){let n=this.sections.slice(),r=[];for(let e=0,i=0;e<n.length;e+=2){let a=n[e],o=n[e+1];if(o>=0){n[e]=o,n[e+1]=a;let s=e>>1;for(;r.length<s;)r.push(Xb.empty);r.push(a?t.slice(i,i+a):Xb.empty)}i+=a}return new e(n,r)}compose(e){return this.empty?e:e.empty?this:xx(this,e,!0)}map(e,t=!1){return e.empty?this:bx(this,e,t,!0)}iterChanges(e,t=!1){yx(this,e,t)}get desc(){return hx.create(this.sections)}filter(t){let n=[],r=[],i=[],a=new Sx(this);done:for(let e=0,o=0;;){let s=e==t.length?1e9:t[e++];for(;o<s||o==s&&a.len==0;){if(a.done)break done;let e=Math.min(a.len,s-o);_x(i,e,-1);let t=a.ins==-1?-1:a.off==0?a.ins:0;_x(n,e,t),t>0&&vx(r,n,a.text),a.forward(e),o+=e}let c=t[e++];for(;o<c;){if(a.done)break done;let e=Math.min(a.len,c-o);_x(n,e,-1),_x(i,e,a.ins==-1?-1:a.off==0?a.ins:0),a.forward(e),o+=e}}return{changes:new e(n,r),filtered:hx.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):r==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(t,n,r){let i=[],a=[],o=0,s=null;function c(t=!1){if(!t&&!i.length)return;o<n&&_x(i,n-o,-1);let r=new e(i,a);s=s?s.compose(r.map(s)):r,i=[],a=[],o=0}function l(t){if(Array.isArray(t))for(let e of t)l(e);else if(t instanceof e){if(t.length!=n)throw RangeError(`Mismatched change set length (got ${t.length}, expected ${n})`);c(),s=s?s.compose(t.map(s)):t}else{let{from:e,to:s=e,insert:l}=t;if(e>s||e<0||s>n)throw RangeError(`Invalid change range ${e} to ${s} (in doc of length ${n})`);let u=l?typeof l==`string`?Xb.of(l.split(r||px)):l:Xb.empty,d=u.length;if(e==s&&d==0)return;e<o&&c(),e>o&&_x(i,e-o,-1),_x(i,s-e,d),vx(a,i,u),o=s}}return l(t),c(!s),s}static empty(t){return new e(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw RangeError(`Invalid JSON representation of ChangeSet`);let n=[],r=[];for(let e=0;e<t.length;e++){let i=t[e];if(typeof i==`number`)n.push(i,-1);else if(!Array.isArray(i)||typeof i[0]!=`number`||i.some((e,t)=>t&&typeof e!=`string`))throw RangeError(`Invalid JSON representation of ChangeSet`);else if(i.length==1)n.push(i[0],0);else{for(;r.length<e;)r.push(Xb.empty);r[e]=Xb.of(i.slice(1)),n.push(i[0],r[e].length)}}return new e(n,r)}static createSet(t,n){return new e(t,n)}};function _x(e,t,n,r=!1){if(t==0&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&t==0&&e[i]==0?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function vx(e,t,n){if(n.length==0)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(Xb.empty);e.push(n)}}function yx(e,t,n){let r=e.inserted;for(let i=0,a=0,o=0;o<e.sections.length;){let s=e.sections[o++],c=e.sections[o++];if(c<0)i+=s,a+=s;else{let l=i,u=a,d=Xb.empty;for(;l+=s,u+=c,c&&r&&(d=d.append(r[o-2>>1])),!(n||o==e.sections.length||e.sections[o+1]<0);)s=e.sections[o++],c=e.sections[o++];t(i,l,a,u,d),i=l,a=u}}}function bx(e,t,n,r=!1){let i=[],a=r?[]:null,o=new Sx(e),s=new Sx(t);for(let e=-1;;)if(o.done&&s.len||s.done&&o.len)throw Error(`Mismatched change set lengths`);else if(o.ins==-1&&s.ins==-1){let e=Math.min(o.len,s.len);_x(i,e,-1),o.forward(e),s.forward(e)}else if(s.ins>=0&&(o.ins<0||e==o.i||o.off==0&&(s.len<o.len||s.len==o.len&&!n))){let t=s.len;for(_x(i,s.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(_x(i,0,o.ins),a&&vx(a,i,o.text),e=o.i),o.forward(n),t-=n}s.next()}else if(o.ins>=0){let t=0,n=o.len;for(;n;)if(s.ins==-1){let e=Math.min(n,s.len);t+=e,n-=e,s.forward(e)}else if(s.ins==0&&s.len<n)n-=s.len,s.next();else break;_x(i,t,e<o.i?o.ins:0),a&&e<o.i&&vx(a,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&s.done)return a?gx.createSet(i,a):hx.create(i);else throw Error(`Mismatched change set lengths`)}function xx(e,t,n=!1){let r=[],i=n?[]:null,a=new Sx(e),o=new Sx(t);for(let e=!1;;)if(a.done&&o.done)return i?gx.createSet(r,i):hx.create(r);else if(a.ins==0)_x(r,a.len,0,e),a.next();else if(o.len==0&&!o.done)_x(r,0,o.ins,e),i&&vx(i,r,o.text),o.next();else if(a.done||o.done)throw Error(`Mismatched change set lengths`);else{let t=Math.min(a.len2,o.len),n=r.length;if(a.ins==-1){let n=o.ins==-1?-1:o.off?0:o.ins;_x(r,t,n,e),i&&n&&vx(i,r,o.text)}else o.ins==-1?(_x(r,a.off?0:a.len,t,e),i&&vx(i,r,a.textBit(t))):(_x(r,a.off?0:a.len,o.off?0:o.ins,e),i&&!o.off&&vx(i,r,o.text));e=(a.ins>t||o.ins>=0&&o.len>t)&&(e||r.length>n),a.forward2(t),o.forward(t)}}var Sx=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?Xb.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?Xb.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},Cx=class e{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(t,n=-1){let r,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new e(r,i,this.flags)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return G.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return G.range(this.anchor,r,void 0,void 0,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!=`number`||typeof e.head!=`number`)throw RangeError(`Invalid JSON representation for SelectionRange`);return G.range(e.anchor,e.head)}static create(t,n,r){return new e(t,n,r)}},G=class e{constructor(e,t){this.ranges=e,this.mainIndex=t}map(t,n=-1){return t.empty?this:e.create(this.ranges.map(e=>e.map(t,n)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new e([this.main],0)}addRange(t,n=!0){return e.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,e.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!=`number`||t.main>=t.ranges.length)throw RangeError(`Invalid JSON representation for EditorSelection`);return new e(t.ranges.map(e=>Cx.fromJSON(e)),t.main)}static single(t,n=t){return new e([e.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw RangeError(`A selection needs at least one range`);for(let r=0,i=0;i<t.length;i++){let a=t[i];if(a.empty?a.from<=r:a.from<r)return e.normalized(t.slice(),n);r=a.to}return new e(t,n)}static cursor(e,t=0,n,r){return Cx.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n))|(r??16777215)<<6)}static range(e,t,n,r,i){let a=(n??16777215)<<6|(r==null?7:Math.min(6,r));return!i&&e!=t&&(i=t<e?1:-1),t<e?Cx.create(t,e,48|a):Cx.create(e,t,(i?i<0?8:16:0)|a)}static normalized(t,n=0){let r=t[n];t.sort((e,t)=>e.from-t.from),n=t.indexOf(r);for(let r=1;r<t.length;r++){let i=t[r],a=t[r-1];if(i.empty?i.from<=a.to:i.from<a.to){let o=a.from,s=Math.max(i.to,a.to);r<=n&&n--,t.splice(--r,2,i.anchor>i.head?e.range(s,o):e.range(o,s))}}return new e(t,n)}};function wx(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var Tx=0,K=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=Tx++,this.default=e([]),this.extensions=typeof i==`function`?i(this):i}get reader(){return this}static define(t={}){return new e(t.combine||(e=>e),t.compareInput||((e,t)=>e===t),t.compare||(t.combine?(e,t)=>e===t:Ex),!!t.static,t.enables)}of(e){return new Dx([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new Dx(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new Dx(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function Ex(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var Dx=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=Tx++}dynamicSlot(e){let t=this.value,n=this.facet.compareInput,r=this.id,i=e[r]>>1,a=this.type==2,o=!1,s=!1,c=[];for(let t of this.dependencies)t==`doc`?o=!0:t==`selection`?s=!0:(e[t.id]??1)&1||c.push(e[t.id]);return{create(e){return e.values[i]=t(e),1},update(e,r){if(o&&r.docChanged||s&&(r.docChanged||r.selection)||kx(e,c)){let r=t(e);if(a?!Ox(r,e.values[i],n):!n(r,e.values[i]))return e.values[i]=r,1}return 0},reconfigure:(e,o)=>{let s,c=o.config.address[r];if(c!=null){let r=Hx(o,c);if(this.dependencies.every(t=>t instanceof K?o.facet(t)===e.facet(t):t instanceof Mx?o.field(t,!1)==e.field(t,!1):!0)||(a?Ox(s=t(e),r,n):n(s=t(e),r)))return e.values[i]=r,0}else s=t(e);return e.values[i]=s,1}}}};function Ox(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function kx(e,t){let n=!1;for(let r of t)Vx(e,r)&1&&(n=!0);return n}function Ax(e,t,n){let r=n.map(t=>e[t.id]),i=n.map(e=>e.type),a=r.filter(e=>!(e&1)),o=e[t.id]>>1;function s(e){let n=[];for(let t=0;t<r.length;t++){let a=Hx(e,r[t]);if(i[t]==2)for(let e of a)n.push(e);else n.push(a)}return t.combine(n)}return{create(e){for(let t of r)Vx(e,t);return e.values[o]=s(e),1},update(e,n){if(!kx(e,a))return 0;let r=s(e);return t.compare(r,e.values[o])?0:(e.values[o]=r,1)},reconfigure(e,i){let a=kx(e,r),c=i.config.facets[t.id],l=i.facet(t);if(c&&!a&&Ex(n,c))return e.values[o]=l,0;let u=s(e);return t.compare(u,l)?(e.values[o]=l,0):(e.values[o]=u,1)}}}var jx=K.define({static:!0}),Mx=class e{constructor(e,t,n,r,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=i,this.provides=void 0}static define(t){let n=new e(Tx++,t.create,t.update,t.compare||((e,t)=>e===t),t);return t.provide&&(n.provides=t.provide(n)),n}create(e){return(e.facet(jx).find(e=>e.field==this)?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r=e.facet(jx),i=n.facet(jx),a;return(a=r.find(e=>e.field==this))&&a!=i.find(e=>e.field==this)?(e.values[t]=a.create(e),1):n.config.address[this.id]==null?(e.values[t]=this.create(e),1):(e.values[t]=n.field(this),0)}}}init(e){return[this,jx.of({field:this,create:e})]}get extension(){return this}},Nx={lowest:4,low:3,default:2,high:1,highest:0};function Px(e){return t=>new Ix(t,e)}var Fx={highest:Px(Nx.highest),high:Px(Nx.high),default:Px(Nx.default),low:Px(Nx.low),lowest:Px(Nx.lowest)},Ix=class{constructor(e,t){this.inner=e,this.prec=t}},Lx=class e{of(e){return new Rx(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},Rx=class{constructor(e,t){this.compartment=e,this.inner=t}},zx=class e{constructor(e,t,n,r,i,a){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(t,n,r){let i=[],a=Object.create(null),o=new Map;for(let e of Bx(t,n,o))e instanceof Mx?i.push(e):(a[e.facet.id]||(a[e.facet.id]=[])).push(e);let s=Object.create(null),c=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let u=r?.config.facets;for(let e in a){let t=a[e],n=t[0].facet,i=u&&u[e]||[];if(t.every(e=>e.type==0))if(s[n.id]=c.length<<1|1,Ex(i,t))c.push(r.facet(n));else{let e=n.combine(t.map(e=>e.value));c.push(r&&n.compare(e,r.facet(n))?r.facet(n):e)}else{for(let e of t)e.type==0?(s[e.id]=c.length<<1|1,c.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[n.id]=l.length<<1,l.push(e=>Ax(e,n,t))}}return new e(t,o,l.map(e=>e(s)),s,c,a)}};function Bx(e,t,n){let r=[[],[],[],[],[]],i=new Map;function a(e,o){let s=i.get(e);if(s!=null){if(s<=o)return;let t=r[s].indexOf(e);t>-1&&r[s].splice(t,1),e instanceof Rx&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof Rx){if(n.has(e.compartment))throw RangeError(`Duplicate use of compartment in extensions`);let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),a(r,o)}else if(e instanceof Ix)a(e.inner,e.prec);else if(e instanceof Mx)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof Dx)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,Nx.default);else{let t=e.extension;if(!t)throw Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(t,o)}}return a(e,Nx.default),r.reduce((e,t)=>e.concat(t))}function Vx(e,t){if(t&1)return 2;let n=t>>1,r=e.status[n];if(r==4)throw Error(`Cyclic dependency between fields and/or facets`);if(r&2)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function Hx(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var Ux=K.define(),Wx=K.define({combine:e=>e.some(e=>e),static:!0}),Gx=K.define({combine:e=>e.length?e[0]:void 0,static:!0}),Kx=K.define(),qx=K.define(),Jx=K.define(),Yx=K.define({combine:e=>e.length?e[0]:!1}),Xx=class{constructor(e,t){this.type=e,this.value=t}static define(){return new Zx}},Zx=class{of(e){return new Xx(this,e)}},Qx=class{constructor(e){this.map=e}of(e){return new $x(this,e)}},$x=class e{constructor(e,t){this.type=e,this.value=t}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new e(this.type,n)}is(e){return this.type==e}static define(e={}){return new Qx(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}};$x.reconfigure=$x.define(),$x.appendConfig=$x.define();var eS=class e{constructor(t,n,r,i,a,o){this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=a,this.scrollIntoView=o,this._doc=null,this._state=null,r&&wx(r,n.newLength),a.some(t=>t.type==e.time)||(this.annotations=a.concat(e.time.of(Date.now())))}static create(t,n,r,i,a,o){return new e(t,n,r,i,a,o)}get newDoc(){return this._doc||=this.changes.apply(this.startState.doc)}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let n=this.annotation(e.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]==`.`))}};eS.time=Xx.define(),eS.userEvent=Xx.define(),eS.addToHistory=Xx.define(),eS.remote=Xx.define();function tS(e,t){let n=[];for(let r=0,i=0;;){let a,o;if(r<e.length&&(i==t.length||t[i]>=e[r]))a=e[r++],o=e[r++];else if(i<t.length)a=t[i++],o=t[i++];else return n;!n.length||n[n.length-1]<a?n.push(a,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function nS(e,t,n){let r,i,a;return n?(r=t.changes,i=gx.empty(t.changes.length),a=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),i=e.changes.mapDesc(t.changes,!0),a=e.changes.compose(r)),{changes:a,selection:t.selection?t.selection.map(i):e.selection?.map(r),effects:$x.mapEffects(e.effects,r).concat($x.mapEffects(t.effects,i)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function rS(e,t,n){let r=t.selection,i=cS(t.annotations);return t.userEvent&&(i=i.concat(eS.userEvent.of(t.userEvent))),{changes:t.changes instanceof gx?t.changes:gx.of(t.changes||[],n,e.facet(Gx)),selection:r&&(r instanceof G?r:G.single(r.anchor,r.head)),effects:cS(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function iS(e,t,n){let r=rS(e,t.length?t[0]:{},e.doc.length);t.length&&t[0].filter===!1&&(n=!1);for(let i=1;i<t.length;i++){t[i].filter===!1&&(n=!1);let a=!!t[i].sequential;r=nS(r,rS(e,t[i],a?r.changes.newLength:e.doc.length),a)}let i=eS.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return oS(n?aS(i):i)}function aS(e){let t=e.startState,n=!0;for(let r of t.facet(Kx)){let t=r(e);if(t===!1){n=!1;break}Array.isArray(t)&&(n=n===!0?t:tS(n,t))}if(n!==!0){let r,i;if(n===!1)i=e.changes.invertedDesc,r=gx.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=eS.create(t,r,e.selection&&e.selection.map(i),$x.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(qx);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof eS?i:Array.isArray(i)&&i.length==1&&i[0]instanceof eS?i[0]:iS(t,cS(i),!1)}return e}function oS(e){let t=e.startState,n=t.facet(Jx),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=nS(r,rS(t,a,e.changes.newLength),!0))}return r==e?e:eS.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var sS=[];function cS(e){return e==null?sS:Array.isArray(e)?e:[e]}var lS=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(lS||={}),uS=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,dS;try{dS=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function fS(e){if(dS)return dS.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>`€`&&(n.toUpperCase()!=n.toLowerCase()||uS.test(n)))return!0}return!1}function pS(e){return t=>{if(!/\S/.test(t))return lS.Space;if(fS(t))return lS.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return lS.Word;return lS.Other}}var mS=class e{constructor(e,t,n,r,i,a){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,a&&(a._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)Vx(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw RangeError(`Field is not present in this state`);return}return Vx(this,n),Hx(this,n)}update(...e){return iS(this,e,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let e of t.effects)e.is(Lx.reconfigure)?(n&&=(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),null),i.set(e.value.compartment,e.value.extension)):e.is($x.reconfigure)?(n=null,r=e.value):e.is($x.appendConfig)&&(n=null,r=cS(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=zx.resolve(r,i,this),a=new e(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values);let o=t.startState.facet(Wx)?t.newSelection:t.newSelection.asSingle();new e(n,t.newDoc,o,a,(e,n)=>n.update(e,t),t)}replaceSelection(e){return typeof e==`string`&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:G.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],a=cS(n.effects);for(let n=1;n<t.ranges.length;n++){let o=e(t.ranges[n]),s=this.changes(o.changes),c=s.map(r);for(let e=0;e<n;e++)i[e]=i[e].map(c);let l=r.mapDesc(s,!0);i.push(o.range.map(l)),r=r.compose(c),a=$x.mapEffects(a,c).concat($x.mapEffects(cS(o.effects),l))}return{changes:r,selection:G.create(i,t.mainIndex),effects:a}}changes(t=[]){return t instanceof gx?t:gx.of(t,this.doc.length,this.facet(e.lineSeparator))}toText(t){return Xb.of(t.split(this.facet(e.lineSeparator)||px))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Vx(this,t),Hx(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof Mx&&this.config.address[r.id]!=null&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(t,n={},r){if(!t||typeof t.doc!=`string`)throw RangeError(`Invalid JSON representation for EditorState`);let i=[];if(r){for(let e in r)if(Object.prototype.hasOwnProperty.call(t,e)){let n=r[e],a=t[e];i.push(n.init(e=>n.spec.fromJSON(a,e)))}}return e.create({doc:t.doc,selection:G.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=zx.resolve(t.extensions||[],new Map),r=t.doc instanceof Xb?t.doc:Xb.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||px)),i=t.selection?t.selection instanceof G?t.selection:G.single(t.selection.anchor,t.selection.head):G.single(0);return wx(i,r.length),n.staticFacet(Wx)||(i=i.asSingle()),new e(n,r,i,n.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(e.tabSize)}get lineBreak(){return this.facet(e.lineSeparator)||`
@@ -130,7 +130,7 @@ $2`),t=t.replace(/([。;;::\.])\s*-(?!-)\s*/g,`$1
130
130
  `))};if((q.mac||q.android)&&u.from==a-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute(`autocorrect`)==`off`&&(u={from:o,to:s,insert:Xb.of([n.text.replace(`.`,` `)])}),this.pendingContextChange=u,!e.state.readOnly){let t=this.to-this.from+(u.to-u.from+u.insert.length);sE(e,u,G.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from<u.to&&!u.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],i=null;for(let t=this.toEditorPos(n.rangeStart),a=this.toEditorPos(n.rangeEnd);t<a;t++){let n=e.coordsForChar(t);i=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||i||new DOMRect,r.push(i)}t.updateCharacterBounds(n.rangeStart,r)},this.handlers.textformatupdate=t=>{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,r=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(r)){let i=this.toEditorPos(e.rangeStart),a=this.toEditorPos(e.rangeEnd);if(i<a){let e=`text-decoration: underline ${/^[a-z]/.test(t)?t+` `:t==`Dashed`?`dashed `:t==`Squiggle`?`wavy `:``}${/thin/i.test(r)?1:2}px`;n.push(J.mark({attributes:{style:e}}).range(i,a))}}}e.dispatch({effects:Nw.of(J.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=wC(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((i,a,o,s,c)=>{if(n)return;let l=c.length-(a-i);if(r&&a>=r.to)if(r.from==i&&r.to==a&&r.insert.eq(c)){r=this.pendingContextChange=null,t+=l,this.to+=l;return}else r=null,this.revertPending(e.state);if(i+=t,a+=t,a<=this.from)this.from+=l,this.to+=l;else if(i<this.to){if(i<this.from||a>this.to||this.to-this.from+c.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(i),this.toContextPos(a),c.toString()),this.to+=l}t+=l}),r&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(e=>!e.isUserEvent(`input.type`)&&e.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(n,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},Y=class e{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement(`div`),this.scrollDOM=document.createElement(`div`),this.scrollDOM.tabIndex=-1,this.scrollDOM.className=`cm-scroller`,this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement(`div`),this.announceDOM.className=`cm-announced`,this.announceDOM.setAttribute(`aria-live`,`polite`),this.dom=document.createElement(`div`),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(e=>e.forEach(e=>t(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||WC(e.parent)||document,this.viewState=new xD(this,e.state||mS.create(e)),e.scrollTo&&e.scrollTo.is(Mw)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Lw).map(e=>new zw(e));for(let e of this.plugins)e.update(this);this.observer=new VD(this),this.inputState=new pE(this),this.inputState.ensureHandlers(this.plugins),this.docView=new DT(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),document.fonts?.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent=`refresh`,this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof eS?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(t){if(this.updateState!=0)throw Error(`Calls to EditorView.update are not allowed while an update is in progress`);let n=!1,r=!1,i,a=this.state;for(let e of t){if(e.startState!=a)throw RangeError(`Trying to update state with a transaction that doesn't start from the previous state.`);a=e.state}if(this.destroyed){this.viewState.state=a;return}let o=this.hasFocus,s=0,c=null;t.some(e=>e.annotation(GE))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,c=KE(a,o),c||(s=1));let l=this.observer.delayedAndroidKey,u=null;if(l?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(u=null)):this.observer.clear(),a.facet(mS.phrases)!=this.state.facet(mS.phrases))return this.setState(a);i=Qw.create(this,a,t),i.flags|=s;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let n of t){if(d&&=d.map(n.changes),n.scrollIntoView){let{main:t}=n.state.selection,{x:r,y:i}=this.state.facet(e.cursorScrollMargin);d=new jw(t.empty?t:G.cursor(t.head,t.head>t.anchor?-1:1),`nearest`,`nearest`,i,r)}for(let e of n.effects)e.is(Mw)&&(d=e.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=JD.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(Xw)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(e=>e.isUserEvent(`select.pointer`)))}finally{this.updateState=0}if(i.startState.facet(jD)!=i.state.facet(jD)&&(this.viewState.mustMeasureContent=!0),(n||r||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let e of this.state.facet(Cw))try{e(i)}catch(e){Pw(this.state,e,`update listener`)}(c||u)&&Promise.resolve().then(()=>{c&&this.state==c.startState&&this.dispatch(c),u&&!oE(this,u)&&l.force&&UC(this.contentDOM,l.key,l.keyCode)})}setState(e){if(this.updateState!=0)throw Error(`Calls to EditorView.setState are not allowed while an update is in progress`);if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new xD(this,e),this.plugins=e.facet(Lw).map(e=>new zw(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new DT(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Lw),n=e.state.facet(Lw);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new zw(i));else{let t=this.plugins[n];t.mustUpdate=e,r.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(e){Pw(this.state,e,`doc view update listener`)}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:i,scrollAnchorHeight:a}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(a<0)if(KC(n||this.win))i=-1,a=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(r);i=e.from,a=e.top}this.updateState=1;let o=this.viewState.measure();if(!o&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(e>5){console.warn(this.measureRequests.length?`Measure loop restarted more than 5 times`:`Viewport failed to stabilize`);break}let s=[];o&4||([this.measureRequests,s]=[s,this.measureRequests]);let c=s.map(e=>{try{return e.read(this)}catch(e){return Pw(this.state,e),qD}}),l=Qw.create(this,this.state,[]),u=!1;l.flags|=o,t?t.flags|=o:t=l,this.updateState=2,l.empty||(this.updatePlugins(l),this.inputState.update(l),this.updateAttrs(),u=this.docView.update(l),u&&this.docViewUpdate());for(let e=0;e<s.length;e++)if(c[e]!=qD)try{let t=s[e];t.write&&t.write(c[e],this)}catch(e){Pw(this.state,e)}if(u&&this.docView.updateSelection(!0),!l.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,a=-1;continue}else{let e=((i<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(i).top)-a)/this.scaleY;if((e>1||e<-1)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r+=e,n?n.scrollTop+=e:this.win.scrollBy(0,e),a=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(Cw))e(t)}get themeClasses(){return ND+` `+(this.state.facet(MD)?FD:PD)+` `+this.state.facet(jD)}updateAttrs(){let e=YD(this,Bw,{class:`cm-editor`+(this.hasFocus?` cm-focused `:` `)+this.themeClasses}),t={spellcheck:`false`,autocorrect:`off`,autocapitalize:`off`,writingsuggestions:`false`,translate:`no`,contenteditable:this.state.facet(Fw)?`true`:`false`,class:`cm-content`,style:`${q.tabSize}: ${this.state.tabSize}`,role:`textbox`,"aria-multiline":`true`};this.state.readOnly&&(t[`aria-readonly`]=`true`),YD(this,Vw,t);let n=this.observer.ignore(()=>{let n=pC(this.contentDOM,this.contentAttrs,t),r=pC(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(t){let n=!0;for(let r of t)for(let t of r.effects)if(t.is(e.announce)){n&&(this.announceDOM.textContent=``),n=!1;let e=this.announceDOM.appendChild(document.createElement(`div`));e.textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(Xw);let t=this.state.facet(e.cspNonce);BS.mount(this.root,this.styleModules.concat(RD).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw Error(`Reading the editor layout isn't allowed during an update`);this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(t=>t.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return YT(this,e,WT(this,e,t,n))}moveByGroup(e,t){return YT(this,e,WT(this,e,t,t=>GT(this,e.head,t)))}visualLineSide(e,t){let n=this.bidiSpans(e),r=this.textDirectionAt(e.from),i=n[t?n.length-1:0];return G.cursor(i.side(t,r)+e.from,i.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,n=!0){return UT(this,e,t,n)}moveVertically(e,t,n){return YT(this,e,KT(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=ZT(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),ZT(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let r=this.state.doc.lineAt(e),i=this.bidiSpans(r),a=i[ow.find(i,e-r.from,-1,t)];return NC(n,a.dir==XC.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(Ow)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>KD)return hw(e.length);let t=this.textDirectionAt(e.from),n;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||sw(r.isolates,n=qw(this,e))))return r.order;n||=qw(this,e);let r=mw(e.text,t,n);return this.bidiCache.push(new JD(e.from,e.to,t,n,!0,r)),r}get hasFocus(){return(this.dom.ownerDocument.hasFocus()||q.safari&&this.inputState?.lastContextMenu>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{BC(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Mw.of(new jw(typeof e==`number`?G.cursor(e):e,t.y??`nearest`,t.x??`nearest`,t.yMargin??5,t.xMargin??5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return Mw.of(new jw(G.cursor(n.from),`start`,`start`,n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e==`boolean`?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Rw.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Rw.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=BS.newName(),r=[jD.of(n),Xw.of(LD(`.${n}`,e))];return t&&t.dark&&r.push(MD.of(!0)),r}static baseTheme(e){return Fx.lowest(Xw.of(LD(`.`+ND,e,ID)))}static findFromDOM(e){let t=e.querySelector(`.cm-content`);return(t&&eT.get(t)||eT.get(e))?.root?.view||null}};Y.styleModule=Xw,Y.inputHandler=ww,Y.clipboardInputFilter=Ew,Y.clipboardOutputFilter=Dw,Y.scrollHandler=Aw,Y.focusChangeEffect=Tw,Y.perLineTextDirection=Ow,Y.exceptionSink=Sw,Y.updateListener=Cw,Y.editable=Fw,Y.mouseSelectionStyle=xw,Y.dragMovesSelection=bw,Y.clickAddsSelectionRange=yw,Y.decorations=Hw,Y.blockWrappers=Uw,Y.outerDecorations=Ww,Y.atomicRanges=Gw,Y.bidiIsolatedRanges=Kw,Y.cursorScrollMargin=K.define({combine:e=>{let t=5,n=5;for(let r of e)typeof r==`number`?t=n=r:{x:t,y:n}=r;return{x:t,y:n}}}),Y.scrollMargins=Jw,Y.darkTheme=MD,Y.cspNonce=K.define({combine:e=>e.length?e[0]:``}),Y.contentAttributes=Vw,Y.editorAttributes=Bw,Y.lineWrapping=Y.contentAttributes.of({class:`cm-lineWrapping`}),Y.announce=$x.define();var KD=4096,qD={},JD=class e{constructor(e,t,n,r,i,a){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=i,this.order=a}static update(t,n){if(n.empty&&!t.some(e=>e.fresh))return t;let r=[],i=t.length?t[t.length-1].dir:XC.LTR;for(let a=Math.max(0,t.length-10);a<t.length;a++){let o=t[a];o.dir==i&&!n.touchesRange(o.from,o.to)&&r.push(new e(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}};function YD(e,t,n){for(let r=e.state.facet(t),i=r.length-1;i>=0;i--){let t=r[i],a=typeof t==`function`?t(e):t;a&&lC(a,n)}return n}var XD=q.mac?`mac`:q.windows?`win`:q.linux?`linux`:`key`;function ZD(e,t){let n=e.split(/-(?!$)/),r=n[n.length-1];r==`Space`&&(r=` `);let i,a,o,s;for(let e=0;e<n.length-1;++e){let r=n[e];if(/^(cmd|meta|m)$/i.test(r))s=!0;else if(/^a(lt)?$/i.test(r))i=!0;else if(/^(c|ctrl|control)$/i.test(r))a=!0;else if(/^s(hift)?$/i.test(r))o=!0;else if(/^mod$/i.test(r))t==`mac`?s=!0:a=!0;else throw Error(`Unrecognized modifier name: `+r)}return i&&(r=`Alt-`+r),a&&(r=`Ctrl-`+r),s&&(r=`Meta-`+r),o&&(r=`Shift-`+r),r}function QD(e,t,n){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n!==!1&&t.shiftKey&&(e=`Shift-`+e),e}var $D=Fx.default(Y.domEventHandlers({keydown(e,t){return cO(nO(t.state),e,t,`editor`)}})),eO=K.define({enables:$D}),tO=new WeakMap;function nO(e){let t=e.facet(eO),n=tO.get(t);return n||tO.set(t,n=oO(t.reduce((e,t)=>e.concat(t),[]))),n}function rO(e,t,n){return cO(nO(e.state),t,e,n)}var iO=null,aO=4e3;function oO(e,t=XD){let n=Object.create(null),r=Object.create(null),i=(e,t)=>{let n=r[e];if(n==null)r[e]=t;else if(n!=t)throw Error(`Key binding `+e+` is used both as a regular binding and as a multi-stroke prefix`)},a=(e,r,a,o,s)=>{let c=n[e]||(n[e]=Object.create(null)),l=r.split(/ (?!$)/).map(e=>ZD(e,t));for(let t=1;t<l.length;t++){let n=l.slice(0,t).join(` `);i(n,!0),c[n]||(c[n]={preventDefault:!0,stopPropagation:!1,run:[t=>{let r=iO={view:t,prefix:n,scope:e};return setTimeout(()=>{iO==r&&(iO=null)},aO),!0}]})}let u=l.join(` `);i(u,!1);let d=c[u]||(c[u]={preventDefault:!1,stopPropagation:!1,run:(c._any?.run)?.slice()||[]});a&&d.run.push(a),o&&(d.preventDefault=!0),s&&(d.stopPropagation=!0)};for(let r of e){let e=r.scope?r.scope.split(` `):[`editor`];if(r.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||={preventDefault:!1,stopPropagation:!1,run:[]};let{any:i}=r;for(let t in e)e[t].run.push(e=>i(e,sO))}let i=r[t]||r.key;if(i)for(let t of e)a(t,i,r.run,r.preventDefault,r.stopPropagation),r.shift&&a(t,`Shift-`+i,r.shift,r.preventDefault,r.stopPropagation)}return n}var sO=null;function cO(e,t,n,r){sO=t;let i=YS(t),a=fx(ux(i,0))==i.length&&i!=` `,o=``,s=!1,c=!1,l=!1;iO&&iO.view==n&&iO.scope==r&&(o=iO.prefix+` `,vE.indexOf(t.keyCode)<0&&(c=!0,iO=null));let u=new Set,d=e=>{if(e){for(let t of e.run)if(!u.has(t)&&(u.add(t),t(n)))return e.stopPropagation&&(l=!0),!0;e.preventDefault&&(e.stopPropagation&&(l=!0),c=!0)}return!1},f=e[r],p,m;return f&&(d(f[o+QD(i,t,!a)])?s=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(q.windows&&t.ctrlKey&&t.altKey)&&!(q.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=US[t.keyCode])&&p!=i?(d(f[o+QD(p,t,!0)])||t.shiftKey&&(m=WS[t.keyCode])!=i&&m!=p&&d(f[o+QD(m,t,!1)]))&&(s=!0):a&&t.shiftKey&&d(f[o+QD(i,t,!0)])&&(s=!0),!s&&d(f._any)&&(s=!0)),c&&(s=!0),s&&l&&t.stopPropagation(),sO=null,s}var lO=class e{constructor(e,t,n,r,i){this.className=e,this.left=t,this.top=n,this.width=r,this.height=i}draw(){let e=document.createElement(`div`);return e.className=this.className,this.adjust(e),e}update(e,t){return t.className==this.className?(this.adjust(e),!0):!1}adjust(e){e.style.left=this.left+`px`,e.style.top=this.top+`px`,this.width!=null&&(e.style.width=this.width+`px`),e.style.height=this.height+`px`}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(t,n,r){if(r.empty){let i=t.coordsAtPos(r.head,r.assoc||1);if(!i)return[];let a=uO(t);return[new e(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}else return fO(t,n,r)}};function uO(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==XC.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function dO(e,t,n,r){let i=e.coordsAtPos(t,n*2);if(!i)return r;let a=e.dom.getBoundingClientRect(),o=(i.top+i.bottom)/2,s=e.posAtCoords({x:a.left+1,y:o}),c=e.posAtCoords({x:a.right-1,y:o});return s==null||c==null?r:{from:Math.max(r.from,Math.min(s,c)),to:Math.min(r.to,Math.max(s,c))}}function fO(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let r=Math.max(n.from,e.viewport.from),i=Math.min(n.to,e.viewport.to),a=e.textDirection==XC.LTR,o=e.contentDOM,s=o.getBoundingClientRect(),c=uO(e),l=o.querySelector(`.cm-line`),u=l&&window.getComputedStyle(l),d=s.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),f=s.right-(u?parseInt(u.paddingRight):0),p=HT(e,r,1),m=HT(e,i,-1),h=p.type==gC.Text?p:null,g=m.type==gC.Text?m:null;if(h&&(e.lineWrapping||p.widgetLineBreaks)&&(h=dO(e,r,1,h)),g&&(e.lineWrapping||m.widgetLineBreaks)&&(g=dO(e,i,-1,g)),h&&g&&h.from==g.from&&h.to==g.to)return v(y(n.from,n.to,h));{let t=h?y(n.from,null,h):b(p,!1),r=g?y(null,n.to,g):b(m,!0),i=[];return(h||p).to<(g||m).from-(h&&g?1:0)||p.widgetLineBreaks>1&&t.bottom+e.defaultLineHeight/2<r.top?i.push(_(d,t.bottom,f,r.top)):t.bottom<r.top&&e.elementAtHeight((t.bottom+r.top)/2).type==gC.Text&&(t.bottom=r.top=(t.bottom+r.top)/2),v(t).concat(i).concat(v(r))}function _(e,n,r,i){return new lO(t,e-c.left,n-c.top,Math.max(0,r-e),i-n)}function v({top:e,bottom:t,horizontal:n}){let r=[];for(let i=0;i<n.length;i+=2)r.push(_(n[i],e,n[i+1],t));return r}function y(t,n,r){let i=1e9,o=-1e9,s=[];function c(t,n,c,l,u){let p=e.coordsAtPos(t,t==r.to?-2:2),m=e.coordsAtPos(c,c==r.from?2:-2);!p||!m||(i=Math.min(p.top,m.top,i),o=Math.max(p.bottom,m.bottom,o),u==XC.LTR?s.push(a&&n?d:p.left,a&&l?f:m.right):s.push(!a&&l?d:m.left,!a&&n?f:p.right))}let l=t??r.from,u=n??r.to;for(let r of e.visibleRanges)if(r.to>l&&r.from<u)for(let i=Math.max(r.from,l),a=Math.min(r.to,u);;){let r=e.state.doc.lineAt(i);for(let o of e.bidiSpans(r)){let e=o.from+r.from,s=o.to+r.from;if(e>=a)break;s>i&&c(Math.max(e,i),t==null&&e<=l,Math.min(s,a),n==null&&s>=u,o.dir)}if(i=r.to+1,i>=a)break}return s.length==0&&c(l,t==null,u,n==null,e.textDirection),{top:i,bottom:o,horizontal:s}}function b(e,t){let n=s.top+(t?e.top:e.bottom);return{top:n,bottom:n,horizontal:[]}}}function pO(e,t){return e.constructor==t.constructor&&e.eq(t)}var mO=class{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement(`div`)),this.dom.classList.add(`cm-layer`),t.above&&this.dom.classList.add(`cm-layer-above`),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute(`aria-hidden`,`true`),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(hO)!=e.state.facet(hO)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(hO);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((e,t)=>!pO(e,this.drawn[t]))){let t=this.dom.firstChild,n=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[n].constructor&&r.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(r.draw(),t);for(;t;){let e=t.nextSibling;t.remove(),t=e}this.drawn=e,q.webkit&&(this.dom.style.display=this.dom.firstChild?``:`none`)}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},hO=K.define();function gO(e){return[Rw.define(t=>new mO(t,e)),hO.of(e)]}var _O=K.define({combine(e){return hS(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function vO(e={}){return[_O.of(e),bO,SO,CO,kw.of(!0)]}function yO(e){return e.startState.facet(_O)!=e.state.facet(_O)}var bO=gO({above:!0,markers(e){let{state:t}=e,n=t.facet(_O),r=[];for(let i of t.selection.ranges){let a=i==t.selection.main;if(i.empty||n.drawRangeCursor&&!(a&&q.ios&&n.iosSelectionHandles)){let t=a?`cm-cursor cm-cursor-primary`:`cm-cursor cm-cursor-secondary`,n=i.empty?i:G.cursor(i.head,i.assoc);for(let i of lO.forRange(e,t,n))r.push(i)}}return r},update(e,t){e.transactions.some(e=>e.selection)&&(t.style.animationName=t.style.animationName==`cm-blink`?`cm-blink2`:`cm-blink`);let n=yO(e);return n&&xO(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){xO(t.state,e)},class:`cm-cursorLayer`});function xO(e,t){t.style.animationDuration=e.facet(_O).cursorBlinkRate+`ms`}var SO=gO({above:!1,markers(e){let t=[],{main:n,ranges:r}=e.state.selection;for(let n of r)if(!n.empty)for(let r of lO.forRange(e,`cm-selectionBackground`,n))t.push(r);if(q.ios&&!n.empty&&e.state.facet(_O).iosSelectionHandles){for(let r of lO.forRange(e,`cm-selectionHandle cm-selectionHandle-start`,G.cursor(n.from,1)))t.push(r);for(let r of lO.forRange(e,`cm-selectionHandle cm-selectionHandle-end`,G.cursor(n.to,1)))t.push(r)}return t},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||yO(e)},class:`cm-selectionLayer`}),CO=Fx.highest(Y.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`transparent !important`},caretColor:`transparent !important`},".cm-content":{caretColor:`transparent !important`,"& :focus":{caretColor:`initial !important`,"&::selection, & ::selection":{backgroundColor:`Highlight !important`}}}})),wO=$x.define({map(e,t){return e==null?null:t.mapPos(e)}}),TO=Mx.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((e,t)=>t.is(wO)?t.value:e,e)}}),EO=Rw.fromClass(class{constructor(e){this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(e){var t;let n=e.state.field(TO);n==null?this.cursor!=null&&((t=this.cursor)==null||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement(`div`)),this.cursor.className=`cm-dropCursor`),(e.startState.field(TO)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(TO),n=t!=null&&e.coordsAtPos(t);if(!n)return null;let r=e.scrollDOM.getBoundingClientRect();return{left:n.left-r.left+e.scrollDOM.scrollLeft*e.scaleX,top:n.top-r.top+e.scrollDOM.scrollTop*e.scaleY,height:n.bottom-n.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:n}=this.view;e?(this.cursor.style.left=e.left/t+`px`,this.cursor.style.top=e.top/n+`px`,this.cursor.style.height=e.height/n+`px`):this.cursor.style.left=`-100000px`}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field(TO)!=e&&this.view.dispatch({effects:wO.of(e)})}},{eventObservers:{dragover(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave(e){(e.target==this.view.contentDOM||!this.view.contentDOM.contains(e.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function DO(){return[TO,EO]}/x/.unicode;function OO(){return AO}var kO=J.line({class:`cm-activeLine`}),AO=Rw.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let r of e.state.selection.ranges){let i=e.lineBlockAt(r.head);i.from>t&&(n.push(kO.range(i.from)),t=i.from)}return J.set(n)}},{decorations:e=>e.decorations}),jO=2e3;function MO(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),a=[];if(t.off>jO||n.off>jO||t.col<0||n.col<0){let o=Math.min(t.off,n.off),s=Math.max(t.off,n.off);for(let t=r;t<=i;t++){let n=e.doc.line(t);n.length<=s&&a.push(G.range(n.from+o,n.to+s))}}else{let o=Math.min(t.col,n.col),s=Math.max(t.col,n.col);for(let t=r;t<=i;t++){let n=e.doc.line(t),r=FS(n.text,o,e.tabSize,!0);if(r<0)a.push(G.cursor(n.to));else{let t=FS(n.text,s,e.tabSize);a.push(G.range(n.from+r,n.from+t))}}}return a}function NO(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function PO(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),r=e.state.doc.lineAt(n),i=n-r.from,a=i>jO?-1:i==r.length?NO(e,t.clientX):PS(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:a,off:i}}function FO(e,t){let n=PO(e,t),r=e.state.selection;return n?{update(e){if(e.docChanged){let t=e.changes.mapPos(e.startState.doc.line(n.line).from),i=e.state.doc.lineAt(t);n={line:i.number,col:n.col,off:Math.min(n.off,i.length)},r=r.map(e.changes)}},get(t,i,a){let o=PO(e,t);if(!o)return r;let s=MO(e.state,n,o);return s.length?a?G.create(s.concat(r.ranges)):G.create(s):r}}:null}function IO(e){let t=e?.eventFilter||(e=>e.altKey&&e.button==0);return Y.mouseSelectionStyle.of((e,n)=>t(n)?FO(e,n):null)}var LO={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},RO={style:`cursor: crosshair`};function zO(e={}){let[t,n]=LO[e.key||`Alt`],r=Rw.fromClass(class{constructor(e){this.view=e,this.isDown=!1}set(e){this.isDown!=e&&(this.isDown=e,this.view.update([]))}},{eventObservers:{keydown(e){this.set(e.keyCode==t||n(e))},keyup(e){(e.keyCode==t||!n(e))&&this.set(!1)},mousemove(e){this.set(n(e))}}});return[r,Y.contentAttributes.of(e=>e.plugin(r)?.isDown?RO:null)]}var BO=`-10000px`,VO=class{constructor(e,t,n,r){this.facet=t,this.createTooltipView=n,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let i=null;this.tooltipViews=this.tooltips.map(e=>i=n(e,i))}update(e,t){var n;let r=e.state.facet(this.facet),i=r.filter(e=>e);if(r===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let a=[],o=t?[]:null;for(let n=0;n<i.length;n++){let r=i[n],s=-1;if(r){for(let e=0;e<this.tooltips.length;e++){let t=this.tooltips[e];t&&t.create==r.create&&(s=e)}if(s<0)a[n]=this.createTooltipView(r,n?a[n-1]:null),o&&(o[n]=!!r.above);else{let r=a[n]=this.tooltipViews[s];o&&(o[n]=t[s]),r.update&&r.update(e)}}}for(let e of this.tooltipViews)a.indexOf(e)<0&&(this.removeTooltipView(e),(n=e.destroy)==null||n.call(e));return t&&(o.forEach((e,n)=>t[n]=e),t.length=o.length),this.input=r,this.tooltips=i,this.tooltipViews=a,!0}};function HO(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}var UO=K.define({combine:e=>({position:q.ios?`absolute`:e.find(e=>e.position)?.position||`fixed`,parent:e.find(e=>e.parent)?.parent||null,tooltipSpace:e.find(e=>e.tooltipSpace)?.tooltipSpace||HO})}),WO=new WeakMap,GO=Rw.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(UO);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver==`function`?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new VO(e,YO,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver=typeof IntersectionObserver==`function`?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.win.addEventListener(`resize`,this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement(`div`),this.container.style.position=`relative`,this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,r=e.state.facet(UO);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let e of this.manager.tooltipViews)e.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let e of this.manager.tooltipViews)this.container.appendChild(e.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add(`cm-tooltip`),e.arrow&&!n.dom.querySelector(`.cm-tooltip > .cm-tooltip-arrow`)){let e=document.createElement(`div`);e.className=`cm-tooltip-arrow`,n.dom.appendChild(e)}return n.dom.style.position=this.position,n.dom.style.top=BO,n.dom.style.left=`0px`,this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener(`resize`,this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),(e=t.destroy)==null||e.call(t);this.parent&&this.container.remove(),(t=this.resizeObserver)==null||t.disconnect(),(n=this.intersectionObserver)==null||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if(this.position==`fixed`&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(q.safari){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}else n=!!e.offsetParent&&e.offsetParent!=this.container.ownerDocument.body}if(n||this.position==`absolute`)if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else ({scaleX:e,scaleY:t}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=Yw(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((e,t)=>{let n=this.manager.tooltipViews[t];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(UO).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){if(e.makeAbsolute){this.madeAbsolute=!0,this.position=`absolute`;for(let e of this.manager.tooltipViews)e.dom.style.position=`absolute`}let{visible:t,space:n,scaleX:r,scaleY:i}=e,a=[];for(let o=0;o<this.manager.tooltips.length;o++){let s=this.manager.tooltips[o],c=this.manager.tooltipViews[o],{dom:l}=c,u=e.pos[o],d=e.size[o];if(!u||s.clip!==!1&&(u.bottom<=Math.max(t.top,n.top)||u.top>=Math.min(t.bottom,n.bottom)||u.right<Math.max(t.left,n.left)-.1||u.left>Math.min(t.right,n.right)+.1)){l.style.top=BO;continue}let f=s.arrow?c.dom.querySelector(`.cm-tooltip-arrow`):null,p=f?7:0,m=d.right-d.left,h=WO.get(c)??d.bottom-d.top,g=c.offset||JO,_=this.view.textDirection==XC.LTR,v=d.width>n.right-n.left?_?n.left:n.right-d.width:_?Math.max(n.left,Math.min(u.left-(f?14:0)+g.x,n.right-m)):Math.min(Math.max(n.left,u.left-m+(f?14:0)-g.x),n.right-m),y=this.above[o];!s.strictSide&&(y?u.top-h-p-g.y<n.top:u.bottom+h+p+g.y>n.bottom)&&y==n.bottom-u.bottom>u.top-n.top&&(y=this.above[o]=!y);let b=(y?u.top-n.top:n.bottom-u.bottom)-p;if(b<h&&c.resize!==!1){if(b<this.view.defaultLineHeight){l.style.top=BO;continue}WO.set(c,h),l.style.height=(h=b)/i+`px`}else l.style.height&&(l.style.height=``);let x=y?u.top-h-p-g.y:u.bottom+p+g.y,S=v+m;if(c.overlap!==!0)for(let e of a)e.left<S&&e.right>v&&e.top<x+h&&e.bottom>x&&(x=y?e.top-h-2-p:e.bottom+p+2);if(this.position==`absolute`?(l.style.top=(x-e.parent.top)/i+`px`,KO(l,(v-e.parent.left)/r)):(l.style.top=x/i+`px`,KO(l,v/r)),f){let e=u.left+(_?g.x:-g.x)-(v+14-7);f.style.left=e/r+`px`}c.overlap!==!0&&a.push({left:v,top:x,right:S,bottom:x+h}),l.classList.toggle(`cm-tooltip-above`,y),l.classList.toggle(`cm-tooltip-below`,!y),c.positioned&&c.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=BO}},{eventObservers:{scroll(){this.maybeMeasure()}}});function KO(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+`px`)}var qO=Y.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:`border-box`},"&light .cm-tooltip":{border:`1px solid #bbb`,backgroundColor:`#f5f5f5`},"&light .cm-tooltip-section:not(:first-child)":{borderTop:`1px solid #bbb`},"&dark .cm-tooltip":{backgroundColor:`#333338`,color:`white`},".cm-tooltip-arrow":{height:`7px`,width:`14px`,position:`absolute`,zIndex:-1,overflow:`hidden`,"&:before, &:after":{content:`''`,position:`absolute`,width:0,height:0,borderLeft:`7px solid transparent`,borderRight:`7px solid transparent`},".cm-tooltip-above &":{bottom:`-7px`,"&:before":{borderTop:`7px solid #bbb`},"&:after":{borderTop:`7px solid #f5f5f5`,bottom:`1px`}},".cm-tooltip-below &":{top:`-7px`,"&:before":{borderBottom:`7px solid #bbb`},"&:after":{borderBottom:`7px solid #f5f5f5`,top:`1px`}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:`#333338`,borderBottomColor:`#333338`},"&:after":{borderTopColor:`transparent`,borderBottomColor:`transparent`}}}),JO={x:0,y:0},YO=K.define({enables:[GO,qO]});function XO(e,t){let n=e.plugin(GO);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}var ZO=K.define({combine(e){let t,n;for(let r of e)t||=r.topContainer,n||=r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function QO(e,t){let n=e.plugin($O),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}var $O=Rw.fromClass(class{constructor(e){this.input=e.state.facet(nk),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(ZO);this.top=new ek(e,!0,t.topContainer),this.bottom=new ek(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}update(e){let t=e.state.facet(ZO);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new ek(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new ek(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(nk);if(n!=this.input){let t=n.filter(e=>e),r=[],i=[],a=[],o=[];for(let n of t){let t=this.specs.indexOf(n),s;t<0?(s=n(e.view),o.push(s)):(s=this.panels[t],s.update&&s.update(e)),r.push(s),(s.top?i:a).push(s)}this.specs=t,this.panels=r,this.top.sync(i),this.bottom.sync(a);for(let e of o)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>Y.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})}),ek=class{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes=``,this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&=(this.dom.remove(),void 0);return}if(!this.dom){this.dom=document.createElement(`div`),this.dom.className=this.top?`cm-panels cm-panels-top`:`cm-panels cm-panels-bottom`,this.dom.style[this.top?`top`:`bottom`]=`0`;let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=tk(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=tk(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(` `))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(` `))e&&this.container.classList.add(e)}}};function tk(e){let t=e.nextSibling;return e.remove(),t}var nk=K.define({enables:$O});function rk(e,t){let n,r=new Promise(e=>n=e),i=e=>sk(e,t,n);e.state.field(ik,!1)?e.dispatch({effects:ak.of(i)}):e.dispatch({effects:$x.appendConfig.of(ik.init(()=>[i]))});let a=ok.of(i);return{close:a,result:r.then(t=>((e.win.queueMicrotask||(t=>e.win.setTimeout(t,10)))(()=>{e.state.field(ik).indexOf(i)>-1&&e.dispatch({effects:a})}),t))}}var ik=Mx.define({create(){return[]},update(e,t){for(let n of t.effects)n.is(ak)?e=[n.value].concat(e):n.is(ok)&&(e=e.filter(e=>e!=n.value));return e},provide:e=>nk.computeN([e],t=>t.field(e))}),ak=$x.define(),ok=$x.define();function sk(e,t,n){let r=t.content?t.content(e,()=>o(null)):null;if(!r){if(r=XS(`form`),t.input){let e=XS(`input`,t.input);/^(text|password|number|email|tel|url)$/.test(e.type)&&e.classList.add(`cm-textfield`),e.name||=`input`,r.appendChild(XS(`label`,(t.label||``)+`: `,e))}else r.appendChild(document.createTextNode(t.label||``));r.appendChild(document.createTextNode(` `)),r.appendChild(XS(`button`,{class:`cm-button`,type:`submit`},t.submitLabel||`OK`))}let i=r.nodeName==`FORM`?[r]:r.querySelectorAll(`form`);for(let e=0;e<i.length;e++){let t=i[e];t.addEventListener(`keydown`,e=>{e.keyCode==27?(e.preventDefault(),o(null)):e.keyCode==13&&(e.preventDefault(),o(t))}),t.addEventListener(`submit`,e=>{e.preventDefault(),o(t)})}let a=XS(`div`,r,XS(`button`,{onclick:()=>o(null),"aria-label":e.state.phrase(`close`),class:`cm-dialog-close`,type:`button`},[`×`]));t.class&&(a.className=t.class),a.classList.add(`cm-dialog`);function o(t){a.contains(a.ownerDocument.activeElement)&&e.focus(),n(t)}return{dom:a,top:t.top,mount:()=>{if(t.focus){let e;e=typeof t.focus==`string`?r.querySelector(t.focus):r.querySelector(`input`)||r.querySelector(`button`),e&&`select`in e?e.select():e&&`focus`in e&&e.focus()}}}}var ck=class extends gS{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};ck.prototype.elementClass=``,ck.prototype.toDOM=void 0,ck.prototype.mapMode=mx.TrackBefore,ck.prototype.startSide=ck.prototype.endSide=-1,ck.prototype.point=!0;var lk=K.define(),uk=K.define(),dk={class:``,renderEmptyElements:!1,elementStyle:``,markers:()=>xS.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:`before`},fk=K.define();function pk(e){return[hk(),fk.of({...dk,...e})]}var mk=K.define({combine:e=>e.some(e=>e)});function hk(e){let t=[gk];return e&&e.fixed===!1&&t.push(mk.of(!0)),t}var gk=Rw.fromClass(class{constructor(e){this.view=e,this.domAfter=null,this.prevViewport=e.viewport,this.dom=document.createElement(`div`),this.dom.className=`cm-gutters cm-gutters-before`,this.dom.setAttribute(`aria-hidden`,`true`),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+`px`,this.gutters=e.state.facet(fk).map(t=>new bk(e,t)),this.fixed=!e.state.facet(mk);for(let e of this.gutters)e.config.side==`after`?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position=`sticky`),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement(`div`),this.domAfter.className=`cm-gutters cm-gutters-after`,this.domAfter.setAttribute(`aria-hidden`,`true`),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+`px`,this.domAfter.style.position=this.fixed?`sticky`:``,this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,r=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(e.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+`px`;this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(mk)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?`sticky`:``,this.domAfter&&(this.domAfter.style.position=this.fixed?`sticky`:``)),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=xS.iter(this.view.state.facet(lk),this.view.viewport.from),r=[],i=this.gutters.map(e=>new yk(e,this.view.viewport,-this.view.documentPadding.top));for(let e of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(e.type)){let t=!0;for(let a of e.type)if(a.type==gC.Text&&t){vk(n,r,a.from);for(let e of i)e.line(this.view,a,r);t=!1}else if(a.widget)for(let e of i)e.widget(this.view,a)}else if(e.type==gC.Text){vk(n,r,e.from);for(let t of i)t.line(this.view,e,r)}else if(e.widget)for(let t of i)t.widget(this.view,e);for(let e of i)e.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(fk),n=e.state.facet(fk),r=e.docChanged||e.heightChanged||e.viewportChanged||!xS.eq(e.startState.facet(lk),e.state.facet(lk),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let t of this.gutters)t.update(e)&&(r=!0);else{r=!0;let i=[];for(let r of n){let n=t.indexOf(r);n<0?i.push(new bk(this.view,r)):(this.gutters[n].update(e),i.push(this.gutters[n]))}for(let e of this.gutters)e.dom.remove(),i.indexOf(e)<0&&e.destroy();for(let e of i)e.config.side==`after`?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.gutters=i}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>Y.scrollMargins.of(t=>{let n=t.plugin(e);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*t.scaleX,i=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==XC.LTR?{left:r,right:i}:{right:r,left:i}})});function _k(e){return Array.isArray(e)?e:[e]}function vk(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}var yk=class{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=xS.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:r}=this,i=(t.top-this.height)/e.scaleY,a=t.height/e.scaleY;if(this.i==r.elements.length){let t=new xk(e,a,i,n);r.elements.push(t),r.dom.appendChild(t.dom)}else r.elements[this.i].update(e,a,i,n);this.height=t.bottom,this.i++}line(e,t,n){let r=[];vk(this.cursor,r,t.from),n.length&&(r=r.concat(n));let i=this.gutter.config.lineMarker(e,t,r);i&&r.unshift(i);let a=this.gutter;r.length==0&&!a.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),r=n?[n]:null;for(let n of e.state.facet(uk)){let i=n(e,t.widget,t);i&&(r||=[]).push(i)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},bk=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement(`div`),this.dom.className=`cm-gutter`+(this.config.class?` `+this.config.class:``);for(let n in t.domEventHandlers)this.dom.addEventListener(n,r=>{let i=r.target,a;if(i!=this.dom&&this.dom.contains(i)){for(;i.parentNode!=this.dom;)i=i.parentNode;let e=i.getBoundingClientRect();a=(e.top+e.bottom)/2}else a=r.clientY;let o=e.lineBlockAtHeight(a-e.documentTop);t.domEventHandlers[n](e,o,r)&&r.preventDefault()});this.markers=_k(t.markers(e)),t.initialSpacer&&(this.spacer=new xk(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+=`visibility: hidden; pointer-events: none`)}update(e){let t=this.markers;if(this.markers=_k(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let t=this.config.updateSpacer(this.spacer.markers[0],e);t!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[t])}let n=e.view.viewport;return!xS.eq(this.markers,t,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},xk=class{constructor(e,t,n,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement(`div`),this.dom.className=`cm-gutterElement`,this.update(e,t,n,r)}update(e,t,n,r){this.height!=t&&(this.height=t,this.dom.style.height=t+`px`),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+`px`:``),Sk(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let n=`cm-gutterElement`,r=this.dom.firstChild;for(let i=0,a=0;;){let o=a,s=i<t.length?t[i++]:null,c=!1;if(s){let e=s.elementClass;e&&(n+=` `+e);for(let e=a;e<this.markers.length;e++)if(this.markers[e].compare(s)){o=e,c=!0;break}}else o=this.markers.length;for(;a<o;){let e=this.markers[a++];if(e.toDOM){e.destroy(r);let t=r.nextSibling;r.remove(),r=t}}if(!s)break;s.toDOM&&(c?r=r.nextSibling:this.dom.insertBefore(s.toDOM(e),r)),c&&a++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}};function Sk(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].compare(t[n]))return!1;return!0}var Ck=K.define(),wk=K.define(),Tk=K.define({combine(e){return hS(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let e in t){let r=n[e],i=t[e];n[e]=r?(e,t,n)=>r(e,t,n)||i(e,t,n):i}return n}})}}),Ek=class extends ck{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function Dk(e,t){return e.state.facet(Tk).formatNumber(t,e.state)}var Ok=fk.compute([Tk],e=>({class:`cm-lineNumbers`,renderEmptyElements:!1,markers(e){return e.state.facet(Ck)},lineMarker(e,t,n){return n.some(e=>e.toDOM)?null:new Ek(Dk(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let r of e.state.facet(wk)){let i=r(e,t,n);if(i)return i}return null},lineMarkerChange:e=>e.startState.facet(Tk)!=e.state.facet(Tk),initialSpacer(e){return new Ek(Dk(e,Ak(e.state.doc.lines)))},updateSpacer(e,t){let n=Dk(t.view,Ak(t.view.state.doc.lines));return n==e.number?e:new Ek(n)},domEventHandlers:e.facet(Tk).domEventHandlers,side:`before`}));function kk(e={}){return[Tk.of(e),hk(),Ok]}function Ak(e){let t=9;for(;t<e;)t=t*10+9;return t}var jk=new class extends ck{constructor(){super(...arguments),this.elementClass=`cm-activeLineGutter`}},Mk=lk.compute([`selection`],e=>{let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.head).from;i>n&&(n=i,t.push(jk.range(i)))}return xS.of(t)});function Nk(){return Mk}var Pk=1024,Fk=0,Ik=class{constructor(e,t){this.from=e,this.to=t}},Lk=class{constructor(e={}){this.id=Fk++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error(`This node type doesn't define a deserialize function`)}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError(`Can't add per-node props to node types`);return typeof e!=`function`&&(e=Bk.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};Lk.closedBy=new Lk({deserialize:e=>e.split(` `)}),Lk.openedBy=new Lk({deserialize:e=>e.split(` `)}),Lk.group=new Lk({deserialize:e=>e.split(` `)}),Lk.isolate=new Lk({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),Lk.contextHash=new Lk({perNode:!0}),Lk.lookAhead=new Lk({perNode:!0}),Lk.mounted=new Lk({perNode:!0});var Rk=class{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[Lk.mounted.id]}},zk=Object.create(null),Bk=class e{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(t){let n=t.props&&t.props.length?Object.create(null):zk,r=!!t.top|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new e(t.name||``,n,t.id,r);if(t.props){for(let e of t.props)if(Array.isArray(e)||(e=e(i)),e){if(e[0].perNode)throw RangeError(`Can't store a per-node prop on a node type`);n[e[0].id]=e[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e==`string`){if(this.name==e)return!0;let t=this.prop(Lk.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(` `))t[r]=e[n];return e=>{for(let n=e.prop(Lk.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};Bk.none=new Bk(``,Object.create(null),0,8);var Vk=class e{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw RangeError(`Node type ids should correspond to array positions when creating a node set`)}extend(...t){let n=[];for(let e of this.types){let r=null;for(let n of t){let t=n(e);if(t){r||=Object.assign({},e.props);let n=t[1],i=t[0];i.combine&&i.id in r&&(n=i.combine(r[i.id],n)),r[i.id]=n}}n.push(r?new Bk(e.name,r,e.id,e.flags):e)}return new e(n)}},Hk=new WeakMap,Uk=new WeakMap,Wk;(function(e){e[e.ExcludeBuffers=1]=`ExcludeBuffers`,e[e.IncludeAnonymous=2]=`IncludeAnonymous`,e[e.IgnoreMounts=4]=`IgnoreMounts`,e[e.IgnoreOverlays=8]=`IgnoreOverlays`,e[e.EnterBracketed=16]=`EnterBracketed`})(Wk||={});var Gk=class e{constructor(e,t,n,r,i){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props[typeof e==`number`?e:e.id]=t}}toString(){let e=Rk.get(this);if(e&&!e.overlay)return e.tree.toString();let t=``;for(let e of this.children){let n=e.toString();n&&(t&&(t+=`,`),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?`(`+t+`)`:``):t}cursor(e=0){return new aA(this.topNode,e)}cursorAt(e,t=0,n=0){let r=new aA(Hk.get(this)||this.topNode);return r.moveTo(e,t),Hk.set(this,r._tree),r}get topNode(){return new Zk(this,0,0,null)}resolve(e,t=0){let n=Yk(Hk.get(this)||this.topNode,e,t,!1);return Hk.set(this,n),n}resolveInner(e,t=0){let n=Yk(Uk.get(this)||this.topNode,e,t,!0);return Uk.set(this,n),n}resolveStack(e,t=0){return iA(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,a=e.mode||0,o=(a&Wk.IncludeAnonymous)>0;for(let e=this.cursor(a|Wk.IncludeAnonymous);;){let a=!1;if(e.from<=i&&e.to>=r&&(!o&&e.type.isAnonymous||t(e)!==!1)){if(e.firstChild())continue;a=!0}for(;a&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;a=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(t={}){return this.children.length<=8?this:uA(Bk.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new e(this.type,t,n,r,this.propValues),t.makeTree||((t,n,r)=>new e(Bk.none,t,n,r)))}static build(e){return sA(e)}};Gk.empty=new Gk(Bk.none,[],[],0);var Kk=class e{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new e(this.buffer,this.index)}},qk=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return Bk.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(`,`)}childString(e){let t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),e+=4,n==e)return i;let a=[];for(;e<n;)a.push(this.childString(e)),e=this.buffer[e+3];return i+`(`+a.join(`,`)+`)`}findChild(e,t,n,r,i){let{buffer:a}=this,o=-1;for(let s=e;s!=t&&!(Jk(i,r,a[s+1],a[s+2])&&(o=s,n>0));s=a[s+3]);return o}slice(t,n,r){let i=this.buffer,a=new Uint16Array(n-t),o=0;for(let e=t,s=0;e<n;){a[s++]=i[e++],a[s++]=i[e++]-r;let n=a[s++]=i[e++]-r;a[s++]=i[e++]-t,o=Math.max(o,n)}return new e(a,o,this.set)}};function Jk(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function Yk(e,t,n,r){for(;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!r&&e instanceof Zk&&e.index<0?null:e.parent;if(!t)return e;e=t}let i=r?0:Wk.IgnoreOverlays;if(r)for(let r=e,a=r.parent;a;r=a,a=r.parent)r instanceof Zk&&r.index<0&&a.enter(t,n,i)?.from!=r.from&&(e=a);for(;;){let r=e.enter(t,n,i);if(!r)return e;e=r}}var Xk=class{cursor(e=0){return new aA(this,e)}getChild(e,t=null,n=null){let r=Qk(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return Qk(this,e,t,n)}resolve(e,t=0){return Yk(this,e,t,!1)}resolveInner(e,t=0){return Yk(this,e,t,!0)}matchContext(e){return $k(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}},Zk=class e extends Xk{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,n,r,i,a=0){for(let o=this;;){for(let{children:s,positions:c}=o._tree,l=n>0?s.length:-1;t!=l;t+=n){let l=s[t],u=c[t]+o.from,d;if(!(!(a&Wk.EnterBracketed&&l instanceof Gk&&(d=Rk.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length)&&!Jk(i,r,u,u+l.length))){if(l instanceof qk){if(a&Wk.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new tA(new eA(o,l,t,u),null,e)}else if(a&Wk.IncludeAnonymous||!l.type.isAnonymous||oA(l)){let s;if(!(a&Wk.IgnoreMounts)&&(s=Rk.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&Wk.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&Wk.IncludeAnonymous||!o.type.isAnonymous||(t=o.index>=0?o.index+n:n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(t,n,r=0){let i;if(!(r&Wk.IgnoreOverlays)&&(i=Rk.get(this._tree))&&i.overlay){let a=t-this.from,o=r&Wk.EnterBracketed&&i.bracketed;for(let{from:t,to:r}of i.overlay)if((n>0||o?t<=a:t<a)&&(n<0||o?r>=a:r>a))return new e(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function Qk(e,t,n,r){let i=e.cursor(),a=[];if(!i.firstChild())return a;if(n!=null){for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return a}for(;;){if(r!=null&&i.type.is(r))return a;if(i.type.is(t)&&a.push(i.node),!i.nextSibling())return r==null?a:[]}}function $k(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}var eA=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},tA=class e extends Xk{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(t,n,r){let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return a<0?null:new e(this.context,this,a)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(t,n,r=0){if(r&Wk.ExcludeBuffers)return null;let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return a<0?null:new e(this.context,this,a)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new e(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new e(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let a=n.buffer[this.index+1];e.push(n.slice(r,i,a)),t.push(0)}return new Gk(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function nA(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;r<e.length;r++){let i=e[r];(i.from>n.from||i.to<n.to)&&(n=i,t=r)}let r=n instanceof Zk&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new rA(i,n)}var rA=class{constructor(e,t){this.heads=e,this.node=t}get next(){return nA(this.heads)}};function iA(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof Zk?r:r.context.parent;e;e=e.parent)if(e.index<0){let a=e.parent;(i||=[r]).push(a.resolve(t,n)),e=a}else{let a=Rk.get(e.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new Zk(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(Yk(o,t,n,!1))}}return i?nA(i):r}var aA=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~Wk.EnterBracketed,e instanceof Zk)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof Zk?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&Wk.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Wk.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Wk.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(r.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=r)}else ({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&Wk.IncludeAnonymous||e instanceof qk||!e.type.isAnonymous||oA(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)scan:for(let r=this.index,i=this.stack.length;i>=0;){for(let a=e;a;a=a._parent)if(a.index==r){if(r==this.index)return a;t=a,n=i+1;break scan}r=this.stack[--i]}for(let e=n;e<this.stack.length;e++)t=new tA(this.buffer,t,this.stack[e]);return this.bufferNode=new tA(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return $k(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return $k(this._tree,e,r);let a=n[t.buffer[this.stack[i]]];if(!a.isAnonymous){if(e[r]&&e[r]!=a.name)return!1;r--}}return!0}};function oA(e){return e.children.some(e=>e instanceof qk||!e.type.isAnonymous||oA(e))}function sA(e){let{buffer:t,nodeSet:n,maxBufferLength:r=Pk,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new Kk(t,t.length):t,s=n.types,c=0,l=0;function u(e,t,_,v,y,b){let{id:x,start:S,end:C,size:w}=o,T=l,E=c;if(w<0)if(o.next(),w==-1){let t=i[x];_.push(t),v.push(S-e);return}else if(w==-3){c=x;return}else if(w==-4){l=x;return}else throw RangeError(`Unrecognized record size: ${w}`);let D=s[x],O,ee,te=S-e;if(C-S<=r&&(ee=h(o.pos-t,y))){let t=new Uint16Array(ee.size-ee.skip),r=o.pos-ee.size,i=t.length;for(;o.pos>r;)i=g(ee.start,t,i);O=new qk(t,C-ee.start,n),te=ee.start-e}else{let e=o.pos-w;o.next();let t=[],n=[],i=x>=a?x:-1,s=0,c=C;for(;o.pos>e;)i>=0&&o.id==i&&o.size>=0?(o.end<=c-r&&(p(t,n,S,s,o.end,c,i,T,E),s=t.length,c=o.end),o.next()):b>2500?d(S,e,t,n):u(S,e,t,n,i,b+1);if(i>=0&&s>0&&s<t.length&&p(t,n,S,s,S,c,i,T,E),t.reverse(),n.reverse(),i>-1&&s>0){let e=f(D,E);O=uA(D,t,n,0,t.length,0,C-S,e,e)}else O=m(D,t,n,C-S,T-C,E)}_.push(O),v.push(te)}function d(e,t,i,a){let s=[],c=0,l=-1;for(;o.pos>t;){let{id:e,start:t,end:n,size:i}=o;if(i>4)o.next();else if(l>-1&&t<l)break;else l<0&&(l=n-r),s.push(e,t,n),c++,o.next()}if(c){let t=new Uint16Array(c*4),r=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;i.push(new qk(t,s[2]-r,n)),a.push(r-e)}}function f(e,t){return(n,r,i)=>{let a=0,o=n.length-1,s,c;if(o>=0&&(s=n[o])instanceof Gk){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(Lk.lookAhead))&&(a=r[o]+s.length+c)}return m(e,n,r,i,a,t)}}function p(e,t,r,i,a,o,s,c,l){let u=[],d=[];for(;e.length>i;)u.push(e.pop()),d.push(t.pop()+r-a);e.push(m(n.types[s],u,d,o-a,c-o,l)),t.push(a-r)}function m(e,t,n,r,i,a,o){if(a){let e=[Lk.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[Lk.lookAhead,i];o=o?[e].concat(o):[e]}return new Gk(e,t,n,r,o)}function h(e,t){let n=o.fork(),i=0,s=0,c=0,l=n.end-r,u={size:0,start:0,skip:0};scan:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){u.size=i,u.start=s,u.skip=c,c+=4,i+=4,n.next();continue}let o=n.pos-e;if(e<0||o<r||n.start<l)break;let d=n.id>=a?4:0,f=n.start;for(n.next();n.pos>o;){if(n.size<0)if(n.size==-3||n.size==-4)d+=4;else break scan;else n.id>=a&&(d+=4);n.next()}s=f,i+=e,c+=d}return(t<0||i==e)&&(u.size=i,u.start=s,u.skip=c),u.size>4?u:void 0}function g(e,t,n){let{id:r,start:i,end:s,size:u}=o;if(o.next(),u>=0&&r<a){let a=n;if(u>4){let r=o.pos-(u-4);for(;o.pos>r;)n=g(e,t,n)}t[--n]=a,t[--n]=s-e,t[--n]=i-e,t[--n]=r}else u==-3?c=r:u==-4&&(l=r);return n}let _=[],v=[];for(;o.pos>0;)u(e.start||0,e.bufferStart||0,_,v,-1,0);let y=e.length??(_.length?v[0]+_[0].length:0);return new Gk(s[e.topID],_.reverse(),v.reverse(),y)}var cA=new WeakMap;function lA(e,t){if(!e.isAnonymous||t instanceof qk||t.type!=e)return 1;let n=cA.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof Gk)){n=1;break}n+=lA(e,r)}cA.set(t,n)}return n}function uA(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n<i;n++)l+=lA(e,t[n]);let u=Math.ceil(l*1.5/8),d=[],f=[];function p(t,n,r,i,o){for(let s=r;s<i;){let r=s,l=n[s],m=lA(e,t[s]);for(s++;s<i;s++){let n=lA(e,t[s]);if(m+n>=u)break;m+=n}if(s==r+1){if(m>u){let e=t[r];p(e.children,e.positions,0,e.children.length,n[r]+o);continue}d.push(t[r])}else{let i=n[s-1]+t[s-1].length-l;d.push(uA(e,t,n,r,s,l,i,null,c))}f.push(l+o-a)}}return p(t,n,r,i,0),(s||c)(d,f,o)}var dA=class{constructor(){this.map=new WeakMap}setBuffer(e,t,n){let r=this.map.get(e);r||this.map.set(e,r=new Map),r.set(t,n)}getBuffer(e,t){let n=this.map.get(e);return n&&n.get(t)}set(e,t){e instanceof tA?this.setBuffer(e.context.buffer,e.index,t):e instanceof Zk&&this.map.set(e.tree,t)}get(e){return e instanceof tA?this.getBuffer(e.context.buffer,e.index):e instanceof Zk?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}},fA=class e{constructor(e,t,n,r,i=!1,a=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=!!i|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new e(0,t.length,t,0,!1,r)];for(let e of n)e.to>t.length&&i.push(e);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],a=1,o=t.length?t[0]:null;for(let s=0,c=0,l=0;;s++){let u=s<n.length?n[s]:null,d=u?u.fromA:1e9;if(d-c>=r)for(;o&&o.from<d;){let n=o;if(c>=n.from||d<=n.to||l){let t=Math.max(n.from,c)-l,r=Math.min(n.to,d)-l;n=t>=r?null:new e(t,r,n.tree,n.offset+l,s>0,!!u)}if(n&&i.push(n),o.to>d)break;o=a<t.length?t[a++]:null}if(!u)break;c=u.toA,l=u.toA-u.toB}return i}},pA=class{startParse(e,t,n){return typeof e==`string`&&(e=new mA(e)),n=n?n.length?n.map(e=>new Ik(e.from,e.to)):[new Ik(0,0)]:[new Ik(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}},mA=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};function hA(e){return(t,n,r,i)=>new bA(t,e,n,r,i)}var gA=class{constructor(e,t,n,r,i,a){this.parser=e,this.parse=t,this.overlay=n,this.bracketed=r,this.target=i,this.from=a}};function _A(e){if(!e.length||e.some(e=>e.from>=e.to))throw RangeError(`Invalid inner parse ranges given: `+JSON.stringify(e))}var vA=class{constructor(e,t,n,r,i,a,o,s){this.parser=e,this.predicate=t,this.mounts=n,this.index=r,this.start=i,this.bracketed=a,this.target=o,this.prev=s,this.depth=0,this.ranges=[]}},yA=new Lk({perNode:!0}),bA=class{constructor(e,t,n,r,i){this.nest=t,this.input=n,this.fragments=r,this.ranges=i,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let e=this.baseParse.advance();if(!e)return null;if(this.baseParse=null,this.baseTree=e,this.startInner(),this.stoppedAt!=null)for(let e of this.inner)e.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let e=this.baseTree;return this.stoppedAt!=null&&(e=new Gk(e.type,e.children,e.positions,e.length,e.propValues.concat([[yA,this.stoppedAt]]))),e}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let n=Object.assign(Object.create(null),e.target.props);n[Lk.mounted.id]=new Rk(t,e.overlay,e.parser,e.bracketed),e.target.props=n}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].from<e&&(e=Math.min(e,this.inner[t].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].parse.stopAt(e)}startInner(){let e=new TA(this.fragments),t=null,n=null,r=new aA(new Zk(this.baseTree,this.ranges[0].from,0,null),Wk.IncludeAnonymous|Wk.IgnoreMounts);scan:for(let i,a;;){let o=!0,s;if(this.stoppedAt!=null&&r.from>=this.stoppedAt)o=!1;else if(e.hasNode(r)){if(t){let e=t.mounts.find(e=>e.frag.from<=r.from&&e.frag.to>=r.to&&e.mount.overlay);if(e)for(let n of e.mount.overlay){let i=n.from+e.pos,a=n.to+e.pos;i>=r.from&&a<=r.to&&!t.ranges.some(e=>e.from<a&&e.to>i)&&t.ranges.push({from:i,to:a})}}o=!1}else if(n&&(a=xA(n.ranges,r.from,r.to)))o=a!=2;else if(!r.type.isAnonymous&&(i=this.nest(r,this.input))&&(r.from<r.to||!i.overlay)){r.tree||(CA(r),t&&t.depth++,n&&n.depth++);let a=e.findMounts(r.from,i.parser);if(typeof i.overlay==`function`)t=new vA(i.parser,i.overlay,a,this.inner.length,r.from,!!i.bracketed,r.tree,t);else{let e=EA(this.ranges,i.overlay||(r.from<r.to?[new Ik(r.from,r.to)]:[]));e.length&&_A(e),(e.length||!i.overlay)&&this.inner.push(new gA(i.parser,e.length?i.parser.startParse(this.input,OA(a,e),e):i.parser.startParse(``),i.overlay?i.overlay.map(e=>new Ik(e.from-r.from,e.to-r.from)):null,!!i.bracketed,r.tree,e.length?e[0].from:r.from)),i.overlay?e.length&&(n={ranges:e,depth:0,prev:n}):o=!1}}else if(t&&(s=t.predicate(r))&&(s===!0&&(s=new Ik(r.from,r.to)),s.from<s.to)){let e=t.ranges.length-1;e>=0&&t.ranges[e].to==s.from?t.ranges[e]={from:t.ranges[e].from,to:s.to}:t.ranges.push(s)}if(o&&r.firstChild())t&&t.depth++,n&&n.depth++;else for(;!r.nextSibling();){if(!r.parent())break scan;if(t&&!--t.depth){let e=EA(this.ranges,t.ranges);e.length&&(_A(e),this.inner.splice(t.index,0,new gA(t.parser,t.parser.startParse(this.input,OA(t.mounts,e),e),t.ranges.map(e=>new Ik(e.from-t.start,e.to-t.start)),t.bracketed,t.target,e[0].from))),t=t.prev}n&&!--n.depth&&(n=n.prev)}}}};function xA(e,t,n){for(let r of e){if(r.from>=n)break;if(r.to>t)return r.from<=t&&r.to>=n?2:1}return 0}function SA(e,t,n,r,i,a){if(t<n){let o=e.buffer[t+1];r.push(e.slice(t,n,o)),i.push(o-a)}}function CA(e){let{node:t}=e,n=[],r=t.context.buffer;do n.push(e.index),e.parent();while(!e.tree);let i=e.tree,a=i.children.indexOf(r),o=i.children[a],s=o.buffer,c=[a];function l(e,r,i,a,u,d){let f=n[d],p=[],m=[];SA(o,e,f,p,m,a);let h=s[f+1],g=s[f+2];c.push(p.length);let _=d?l(f+4,s[f+3],o.set.types[s[f]],h,g-h,d-1):t.toTree();return p.push(_),m.push(h-a),SA(o,s[f+3],r,p,m,a),new Gk(i,p,m,u)}i.children[a]=l(0,s.length,Bk.none,0,o.length,n.length-1);for(let t of c){let n=e.tree.children[t],r=e.tree.positions[t];e.yield(new Zk(n,r+e.from,t,e._tree))}}var wA=class{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(Wk.IncludeAnonymous|Wk.IgnoreMounts)}moveTo(e){let{cursor:t}=this,n=e-this.offset;for(;!this.done&&t.from<n;)if(!(t.to>=e&&t.enter(n,1,Wk.IgnoreOverlays|Wk.ExcludeBuffers)))if(t.to<=e)t.next(!1)||(this.done=!0);else break}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&t.positions[0]==0&&t.children[0]instanceof Gk)t=t.children[0];else break}return!1}},TA=class{constructor(e){if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let t=this.curFrag=e[0];this.curTo=t.tree.prop(yA)??t.to,this.inner=new wA(t.tree,-t.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let e=this.curFrag=this.fragments[this.fragI];this.curTo=e.tree.prop(yA)??e.to,this.inner=new wA(e.tree,-e.offset)}}findMounts(e,t){let n=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let e=this.inner.cursor.node;e;e=e.parent){let r=e.tree?.prop(Lk.mounted);if(r&&r.parser==t)for(let t=this.fragI;t<this.fragments.length;t++){let i=this.fragments[t];if(i.from>=e.to)break;i.tree==this.curFrag.tree&&n.push({frag:i,pos:e.from-i.offset,mount:r})}}}return n}};function EA(e,t){let n=null,r=t;for(let i=1,a=0;i<e.length;i++){let o=e[i-1].to,s=e[i].from;for(;a<r.length;a++){let e=r[a];if(e.from>=s)break;e.to<=o||(n||(r=n=t.slice()),e.from<o?(n[a]=new Ik(e.from,o),e.to>s&&n.splice(a+1,0,new Ik(s,e.to))):e.to>s?n[a--]=new Ik(s,e.to):n.splice(a--,1))}}return r}function DA(e,t,n,r){let i=0,a=0,o=!1,s=!1,c=-1e9,l=[];for(;;){let u=i==e.length?1e9:o?e[i].to:e[i].from,d=a==t.length?1e9:s?t[a].to:t[a].from;if(o!=s){let e=Math.max(c,n),t=Math.min(u,d,r);e<t&&l.push(new Ik(e,t))}if(c=Math.min(u,d),c==1e9)break;u==c&&(o?(o=!1,i++):o=!0),d==c&&(s?(s=!1,a++):s=!0)}return l}function OA(e,t){let n=[];for(let{pos:r,mount:i,frag:a}of e){let e=r+(i.overlay?i.overlay[0].from:0),o=e+i.tree.length,s=Math.max(a.from,e),c=Math.min(a.to,o);if(i.overlay){let o=DA(t,i.overlay.map(e=>new Ik(e.from+r,e.to+r)),s,c);for(let t=0,r=s;;t++){let s=t==o.length,l=s?c:o[t].from;if(l>r&&n.push(new fA(r,l,i.tree,-e,a.from>=r||a.openStart,a.to<=l||a.openEnd)),s)break;r=o[t].to}}else n.push(new fA(s,c,i.tree,-e,a.from>=e||a.openStart,a.to<=o||a.openEnd))}return n}var kA=0,AA=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=kA++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(t,n){let r=typeof t==`string`?t:`?`;if(t instanceof e&&(n=t),n?.base)throw Error(`Can not derive from a modified tag`);let i=new e(r,[],null,[]);if(i.set.push(i),n)for(let e of n.set)i.set.push(e);return i}static defineModifier(e){let t=new MA(e);return e=>e.modified.indexOf(t)>-1?e:MA.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},jA=0,MA=class e{constructor(e){this.name=e,this.instances=[],this.id=jA++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&NA(n,e.modified));if(r)return r;let i=[],a=new AA(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=PA(n);for(let n of t.set)if(!n.modified.length)for(let t of o)i.push(e.get(n,t));return a}};function NA(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function PA(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}function FA(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(` `))if(e){let n=[],i=2,a=e;for(let t=0;;){if(a==`...`&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!r)throw RangeError(`Invalid path: `+e);if(n.push(r[0]==`*`?``:r[0][0]==`"`?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&o==`!`){i=0;break}if(o!=`/`)throw RangeError(`Invalid path: `+e);a=e.slice(t)}let o=n.length-1,s=n[o];if(!s)throw RangeError(`Invalid path: `+e);t[s]=new LA(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return IA.add(t)}var IA=new Lk({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth>=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let a=new LA(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),LA=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};LA.empty=new LA([],2,null);function RA(e,t){let n=Object.create(null);for(let t of e)if(!Array.isArray(t.tag))n[t.tag.id]=t.class;else for(let e of t.tag)n[e.id]=t.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+` `+r:r;break}}return t},scope:r}}function zA(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+` `+e:e)}return n}function BA(e,t,n,r=0,i=e.length){let a=new VA(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,``,a.highlighters),a.flush(i)}var VA=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=``}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,i){let{type:a,from:o,to:s}=e;if(o>=n||s<=t)return;a.isTop&&(i=this.highlighters.filter(e=>!e.scope||e.scope(a)));let c=r,l=HA(e)||LA.empty,u=zA(i,l.tags);if(u&&(c&&(c+=` `),c+=u,l.mode==1&&(r+=(r?` `:``)+u)),this.startSpan(Math.max(t,o),c),l.opaque)return;let d=e.tree&&e.tree.prop(Lk.mounted);if(d&&d.overlay){let a=e.node.enter(d.overlay[0].from+o,1),l=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),u=e.firstChild();for(let f=0,p=o;;f++){let m=f<d.overlay.length?d.overlay[f]:null,h=m?m.from+o:s,g=Math.max(t,p),_=Math.min(n,h);if(g<_&&u)for(;e.from<_&&(this.highlightRange(e,g,_,r,i),this.startSpan(Math.min(_,e.to),c),!(e.to>=h||!e.nextSibling())););if(!m||h>n)break;p=m.to+o,p>t&&(this.highlightRange(a.cursor(),Math.max(t,m.from+o),Math.min(n,p),``,l),this.startSpan(Math.min(n,p),c))}u&&e.parent()}else if(e.firstChild()){d&&(r=``);do{if(e.to<=t)continue;if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function HA(e){let t=e.type.prop(IA);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var X=AA.define,UA=X(),WA=X(),GA=X(WA),KA=X(WA),qA=X(),JA=X(qA),YA=X(qA),XA=X(),ZA=X(XA),QA=X(),$A=X(),ej=X(),tj=X(ej),nj=X(),Z={comment:UA,lineComment:X(UA),blockComment:X(UA),docComment:X(UA),name:WA,variableName:X(WA),typeName:GA,tagName:X(GA),propertyName:KA,attributeName:X(KA),className:X(WA),labelName:X(WA),namespace:X(WA),macroName:X(WA),literal:qA,string:JA,docString:X(JA),character:X(JA),attributeValue:X(JA),number:YA,integer:X(YA),float:X(YA),bool:X(qA),regexp:X(qA),escape:X(qA),color:X(qA),url:X(qA),keyword:QA,self:X(QA),null:X(QA),atom:X(QA),unit:X(QA),modifier:X(QA),operatorKeyword:X(QA),controlKeyword:X(QA),definitionKeyword:X(QA),moduleKeyword:X(QA),operator:$A,derefOperator:X($A),arithmeticOperator:X($A),logicOperator:X($A),bitwiseOperator:X($A),compareOperator:X($A),updateOperator:X($A),definitionOperator:X($A),typeOperator:X($A),controlOperator:X($A),punctuation:ej,separator:X(ej),bracket:tj,angleBracket:X(tj),squareBracket:X(tj),paren:X(tj),brace:X(tj),content:XA,heading:ZA,heading1:X(ZA),heading2:X(ZA),heading3:X(ZA),heading4:X(ZA),heading5:X(ZA),heading6:X(ZA),contentSeparator:X(XA),list:X(XA),quote:X(XA),emphasis:X(XA),strong:X(XA),link:X(XA),monospace:X(XA),strikethrough:X(XA),inserted:X(),deleted:X(),changed:X(),invalid:X(),meta:nj,documentMeta:X(nj),annotation:X(nj),processingInstruction:X(nj),definition:AA.defineModifier(`definition`),constant:AA.defineModifier(`constant`),function:AA.defineModifier(`function`),standard:AA.defineModifier(`standard`),local:AA.defineModifier(`local`),special:AA.defineModifier(`special`)};for(let e in Z){let t=Z[e];t instanceof AA&&(t.name=e)}RA([{tag:Z.link,class:`tok-link`},{tag:Z.heading,class:`tok-heading`},{tag:Z.emphasis,class:`tok-emphasis`},{tag:Z.strong,class:`tok-strong`},{tag:Z.keyword,class:`tok-keyword`},{tag:Z.atom,class:`tok-atom`},{tag:Z.bool,class:`tok-bool`},{tag:Z.url,class:`tok-url`},{tag:Z.labelName,class:`tok-labelName`},{tag:Z.inserted,class:`tok-inserted`},{tag:Z.deleted,class:`tok-deleted`},{tag:Z.literal,class:`tok-literal`},{tag:Z.string,class:`tok-string`},{tag:Z.number,class:`tok-number`},{tag:[Z.regexp,Z.escape,Z.special(Z.string)],class:`tok-string2`},{tag:Z.variableName,class:`tok-variableName`},{tag:Z.local(Z.variableName),class:`tok-variableName tok-local`},{tag:Z.definition(Z.variableName),class:`tok-variableName tok-definition`},{tag:Z.special(Z.variableName),class:`tok-variableName2`},{tag:Z.definition(Z.propertyName),class:`tok-propertyName tok-definition`},{tag:Z.typeName,class:`tok-typeName`},{tag:Z.namespace,class:`tok-namespace`},{tag:Z.className,class:`tok-className`},{tag:Z.macroName,class:`tok-macroName`},{tag:Z.propertyName,class:`tok-propertyName`},{tag:Z.operator,class:`tok-operator`},{tag:Z.comment,class:`tok-comment`},{tag:Z.meta,class:`tok-meta`},{tag:Z.invalid,class:`tok-invalid`},{tag:Z.punctuation,class:`tok-punctuation`}]);var rj=new Lk;function ij(e){return K.define({combine:e?t=>t.concat(e):void 0})}var aj=new Lk,oj=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,mS.prototype.hasOwnProperty(`tree`)||Object.defineProperty(mS.prototype,"tree",{get(){return lj(this)}}),this.parser=t,this.extension=[vj.of(this),mS.languageData.of((e,t,n)=>{let r=sj(e,t,n),i=r.type.prop(rj);if(!i)return[];let a=e.facet(i),o=r.type.prop(aj);if(o){let i=r.resolve(t-r.from,n);for(let t of o)if(t.test(i,e)){let n=e.facet(t.facet);return t.type==`replace`?n:n.concat(a)}}return a})].concat(n)}isActiveAt(e,t,n=-1){return sj(e,t,n).type.prop(rj)==this.data}findRegions(e){let t=e.facet(vj);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(rj)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(Lk.mounted);if(i){if(i.tree.prop(rj)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}else if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let i=e.children[n];i instanceof Gk&&r(i,e.positions[n]+t)}};return r(lj(e),0),n}get allowsNesting(){return!0}};oj.setState=$x.define();function sj(e,t,n){let r=e.facet(vj),i=lj(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,Wk.ExcludeBuffers|Wk.EnterBracketed))e.type.isTop&&(i=e);return i}var cj=class e extends oj{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(t){let n=ij(t.languageData);return new e(n,t.parser.configure({props:[rj.add(e=>e.isTop?n:void 0)]}),t.name)}configure(t,n){return new e(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function lj(e){let t=e.field(oj.state,!1);return t?t.tree:Gk.empty}var uj=class{constructor(e){this.doc=e,this.cursorPos=0,this.string=``,this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},dj=null,fj=class e{constructor(e,t,n=[],r,i,a,o,s){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=a,this.skipped=o,this.scheduleOn=s,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new e(t,n,[],Gk.empty,0,r,[],null)}startParse(){return this.parser.startParse(new uj(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=Gk.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{if(typeof e==`number`){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||=this.startParse(),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let n=this.parse.advance();if(n)if(this.fragments=this.withoutTempSkipped(fA.addTree(n,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=this.parse.stoppedAt??this.state.doc.length,this.tree=n,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(fA.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=dj;dj=this;try{return e()}finally{dj=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=pj(e,t.from,t.to);return e}changes(t,n){let{fragments:r,tree:i,treeLen:a,viewport:o,skipped:s}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,n,r,i)=>e.push({fromA:t,toA:n,fromB:r,toB:i})),r=fA.applyChanges(r,e),i=Gk.empty,a=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){s=[];for(let e of this.skipped){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);n<r&&s.push({from:n,to:r})}}}return new e(this.parser,n,r,i,a,o,s,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:r}=this.skipped[t];n<e.to&&r>e.from&&(this.fragments=pj(this.fragments,n,r),this.skipped.splice(t--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&=(this.takeTree(),null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends pA{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=dj;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=a,new Gk(Bk.none,[],[],a-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return dj}};function pj(e,t,n){return fA.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var mj=class e{constructor(e){this.context=e,this.tree=e.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new e(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=fj.create(t.facet(vj).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};oj.state=Mx.define({create:mj.init,update(e,t){for(let e of t.effects)if(e.is(oj.setState))return e.value;return t.startState.facet(vj)==t.state.facet(vj)?e.apply(t):mj.init(t.state)}});var hj=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(hj=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var gj=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,_j=Rw.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(oj.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(oj.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=hj(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,i=n.field(oj.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!gj?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<r&&n.doc.length>r+1e3,s=i.context.work(()=>gj&&gj()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:oj.setState.of(new mj(i.context))})),this.chunkBudget>0&&!(s&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&=(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>Pw(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),vj=K.define({combine(e){return e.length?e[0]:null},enables:e=>[oj.state,_j,Y.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),yj=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},Q=class e{constructor(e,t,n,r,i,a=void 0){this.name=e,this.alias=t,this.extensions=n,this.filename=r,this.loadFunc=i,this.support=a,this.loading=null}load(){return this.loading||=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e})}static of(t){let{load:n,support:r}=t;if(!n){if(!r)throw RangeError(`Must pass either 'load' or 'support' to LanguageDescription.of`);n=()=>Promise.resolve(r)}return new e(t.name,(t.alias||[]).concat(t.name).map(e=>e.toLowerCase()),t.extensions||[],t.filename,n,r)}static matchFilename(e,t){for(let n of e)if(n.filename&&n.filename.test(t))return n;let n=/\.([^.]+)$/.exec(t);if(n){for(let t of e)if(t.extensions.indexOf(n[1])>-1)return t}return null}static matchLanguageName(e,t,n=!0){t=t.toLowerCase();for(let n of e)if(n.alias.some(e=>e==t))return n;if(n)for(let n of e)for(let e of n.alias){let r=t.indexOf(e);if(r>-1&&(e.length>2||!/\w/.test(t[r-1])&&!/\w/.test(t[r+e.length])))return n}return null}},bj=K.define(),xj=K.define({combine:e=>{if(!e.length)return` `;let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw Error(`Invalid indent unit: `+JSON.stringify(e[0]));return t}});function Sj(e){let t=e.facet(xj);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function Cj(e,t){let n=``,r=e.tabSize,i=e.facet(xj)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e<t;e++)n+=i;return n}function wj(e,t){e instanceof mS&&(e=new Tj(e));for(let n of e.state.facet(bj)){let r=n(e,t);if(r!==void 0)return r}let n=lj(e.state);return n.length>=t?Dj(e,n,t):null}var Tj=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Sj(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=n.from&&r<=n.to?i&&r==e?{text:``,from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return``;let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),a=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return a>-1&&(i+=a-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return PS(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},Ej=new Lk;function Dj(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t&&!(t.from<r.node.from||t.to>r.node.to||t.from==r.node.from&&t.type==r.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return Oj(r,e,n)}function Oj(e,t,n){for(let r=e;r;r=r.next){let e=Aj(r.node);if(e)return e(Mj.create(t,n,r))}return 0}function kj(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function Aj(e){let t=e.type.prop(Ej);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(Lk.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>Ij(e,!0,1,void 0,n&&!kj(e)?t.from:void 0)}return e.parent==null?jj:null}function jj(){return 0}var Mj=class e extends Tj{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(t,n,r){return new e(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(Nj(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return Oj(this.context.next,this.base,this.pos)}};function Nj(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function Pj(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,a=e.state.doc.lineAt(n.from),o=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==r)return null;if(!i.type.isSkipped){if(i.from>=o)return null;let e=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}function Fj({closing:e,align:t=!0,units:n=1}){return r=>Ij(r,t,n,e)}function Ij(e,t,n,r,i){let a=e.textAfter,o=a.match(/^\s*/)[0].length,s=r&&a.slice(o,o+r.length)==r||i==e.pos+o,c=t?Pj(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}var Lj=e=>e.baseIndent;function Rj({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var zj=200;function Bj(){return mS.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent(`input.type`)&&!e.isUserEvent(`input.complete`))return e;let t=e.startState.languageDataAt(`indentOnInput`,e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+zj)return e;let a=n.sliceString(i.from,r);if(!t.some(e=>e.test(a)))return e;let{state:o}=e,s=-1,c=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==s)continue;s=t.from;let n=wj(o,t.from);if(n==null)continue;let r=/^\s*/.exec(t.text)[0],i=Cj(o,n);r!=i&&c.push({from:t.from,to:t.from+r.length,insert:i})}return c.length?[e,{changes:c,sequential:!0}]:e})}var Vj=K.define(),Hj=new Lk;function Uj(e){let t=e.firstChild,n=e.lastChild;return t&&t.to<n.from?{from:t.to,to:n.type.isError?e.to:n.from}:null}function Wj(e,t,n){let r=lj(e);if(r.length<n)return null;let i=r.resolveStack(n,1),a=null;for(let o=i;o;o=o.next){let i=o.node;if(i.to<=n||i.from>n)continue;if(a&&i.from<t)break;let s=i.type.prop(Hj);if(s&&(i.to<r.length-50||r.length==e.doc.length||!Gj(i))){let r=s(i,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(a=r)}}return a}function Gj(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function Kj(e,t,n){for(let r of e.facet(Vj)){let i=r(e,t,n);if(i)return i}return Wj(e,t,n)}function qj(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}var Jj=$x.define({map:qj}),Yj=$x.define({map:qj});function Xj(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(e=>e.from<=n&&e.to>=n)||t.push(e.lineBlockAt(n));return t}var Zj=Mx.define({create(){return J.none},update(e,t){t.isUserEvent(`delete`)&&t.changes.iterChangedRanges((t,n)=>e=Qj(e,t,n)),e=e.map(t.changes);for(let n of t.effects)if(n.is(Jj)&&!eM(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(sM),i=r?J.replace({widget:new dM(r(t.state,n.value))}):uM;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(Yj)&&(e=e.update({filter:(e,t)=>n.value.from!=e||n.value.to!=t,filterFrom:n.value.from,filterTo:n.value.to}));return t.selection&&(e=Qj(e,t.selection.main.head)),e},provide:e=>Y.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(e,t)=>{n.push(e,t)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw RangeError(`Invalid JSON for fold state`);let t=[];for(let n=0;n<e.length;){let r=e[n++],i=e[n++];if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid JSON for fold state`);t.push(uM.range(r,i))}return J.set(t,!0)}});function Qj(e,t,n=t){let r=!1;return e.between(t,n,(e,i)=>{e<n&&i>t&&(r=!0)}),r?e.update({filterFrom:t,filterTo:n,filter:(e,r)=>e>=n||r<=t}):e}function $j(e,t,n){var r;let i=null;return(r=e.field(Zj,!1))==null||r.between(t,n,(e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})}),i}function eM(e,t,n){let r=!1;return e.between(t,t,(e,i)=>{e==t&&i==n&&(r=!0)}),r}function tM(e,t){return e.field(Zj,!1)?t:t.concat($x.appendConfig.of(cM()))}var nM=e=>{for(let t of Xj(e)){let n=Kj(e.state,t.from,t.to);if(n)return e.dispatch({effects:tM(e.state,[Jj.of(n),iM(e,n)])}),!0}return!1},rM=e=>{if(!e.state.field(Zj,!1))return!1;let t=[];for(let n of Xj(e)){let r=$j(e.state,n.from,n.to);r&&t.push(Yj.of(r),iM(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function iM(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return Y.announce.of(`${e.state.phrase(n?`Folded lines`:`Unfolded lines`)} ${r} ${e.state.phrase(`to`)} ${i}.`)}var aM=[{key:`Ctrl-Shift-[`,mac:`Cmd-Alt-[`,run:nM},{key:`Ctrl-Shift-]`,mac:`Cmd-Alt-]`,run:rM},{key:`Ctrl-Alt-[`,run:e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=Kj(t,i.from,i.to);a&&n.push(Jj.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:tM(e.state,n)}),!!n.length}},{key:`Ctrl-Alt-]`,run:e=>{let t=e.state.field(Zj,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(Yj.of({from:e,to:t}))}),e.dispatch({effects:n}),!0}}],oM={placeholderDOM:null,preparePlaceholder:null,placeholderText:`…`},sM=K.define({combine(e){return hS(e,oM)}});function cM(e){let t=[Zj,hM];return e&&t.push(sM.of(e)),t}function lM(e,t){let{state:n}=e,r=n.facet(sM),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=$j(e.state,n.from,n.to);r&&e.dispatch({effects:Yj.of(r)}),t.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let a=document.createElement(`span`);return a.textContent=r.placeholderText,a.setAttribute(`aria-label`,n.phrase(`folded code`)),a.title=n.phrase(`unfold`),a.className=`cm-foldPlaceholder`,a.onclick=i,a}var uM=J.replace({widget:new class extends hC{toDOM(e){return lM(e,null)}}}),dM=class extends hC{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return lM(e,this.value)}},fM={openText:`⌄`,closedText:`›`,markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},pM=class extends ck{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement(`span`);return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?`Fold line`:`Unfold line`),t}};function mM(e={}){let t={...fM,...e},n=new pM(t,!0),r=new pM(t,!1),i=Rw.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(vj)!=e.state.facet(vj)||e.startState.field(Zj,!1)!=e.state.field(Zj,!1)||lj(e.startState)!=lj(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new CS;for(let i of e.viewportLineBlocks){let a=$j(e.state,i.from,i.to)?r:Kj(e.state,i.from,i.to)?n:null;a&&t.add(i.from,i.from,a)}return t.finish()}}),{domEventHandlers:a}=t;return[i,pk({class:`cm-foldGutter`,markers(e){return e.plugin(i)?.markers||xS.empty},initialSpacer(){return new pM(t,!1)},domEventHandlers:{...a,click:(e,t,n)=>{if(a.click&&a.click(e,t,n))return!0;let r=$j(e.state,t.from,t.to);if(r)return e.dispatch({effects:Yj.of(r)}),!0;let i=Kj(e.state,t.from,t.to);return i?(e.dispatch({effects:Jj.of(i)}),!0):!1}}}),cM()]}var hM=Y.baseTheme({".cm-foldPlaceholder":{backgroundColor:`#eee`,border:`1px solid #ddd`,color:`#888`,borderRadius:`.2em`,margin:`0 1px`,padding:`0 1px`,cursor:`pointer`},".cm-foldGutter span":{padding:`0 1px`,cursor:`pointer`}}),gM=class e{constructor(e,t){this.specs=e;let n;function r(e){let t=BS.newName();return(n||=Object.create(null))[`.`+t]=e,t}let i=typeof t.all==`string`?t.all:t.all?r(t.all):void 0,a=t.scope;this.scope=a instanceof oj?e=>e.prop(rj)==a.data:a?e=>e==a:void 0,this.style=RA(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new BS(n):null,this.themeType=t.themeType}static define(t,n){return new e(t,n||{})}},_M=K.define(),vM=K.define({combine(e){return e.length?[e[0]]:null}});function yM(e){let t=e.facet(_M);return t.length?t:e.facet(vM)}function bM(e,t){let n=[SM],r;return e instanceof gM&&(e.module&&n.push(Y.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(vM.of(e)):r?n.push(_M.computeN([Y.darkTheme],t=>t.facet(Y.darkTheme)==(r==`dark`)?[e]:[])):n.push(_M.of(e)),n}var xM=class{constructor(e){this.markCache=Object.create(null),this.tree=lj(e.state),this.decorations=this.buildDeco(e,yM(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=lj(e.state),n=yM(e.state),r=n!=yM(e.startState),{viewport:i}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length<i.to&&!r&&t.type==this.tree.type&&a>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return J.none;let n=new CS;for(let{from:r,to:i}of e.visibleRanges)BA(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=J.mark({class:r})))},r,i);return n.finish()}},SM=Fx.high(Rw.fromClass(xM,{decorations:e=>e.decorations})),CM=gM.define([{tag:Z.meta,color:`#404740`},{tag:Z.link,textDecoration:`underline`},{tag:Z.heading,textDecoration:`underline`,fontWeight:`bold`},{tag:Z.emphasis,fontStyle:`italic`},{tag:Z.strong,fontWeight:`bold`},{tag:Z.strikethrough,textDecoration:`line-through`},{tag:Z.keyword,color:`#708`},{tag:[Z.atom,Z.bool,Z.url,Z.contentSeparator,Z.labelName],color:`#219`},{tag:[Z.literal,Z.inserted],color:`#164`},{tag:[Z.string,Z.deleted],color:`#a11`},{tag:[Z.regexp,Z.escape,Z.special(Z.string)],color:`#e40`},{tag:Z.definition(Z.variableName),color:`#00f`},{tag:Z.local(Z.variableName),color:`#30a`},{tag:[Z.typeName,Z.namespace],color:`#085`},{tag:Z.className,color:`#167`},{tag:[Z.special(Z.variableName),Z.macroName],color:`#256`},{tag:Z.definition(Z.propertyName),color:`#00c`},{tag:Z.comment,color:`#940`},{tag:Z.invalid,color:`#f00`}]),wM=Y.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:`#328c8252`},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bb555544`}}),TM=1e4,EM=`()[]{}`,DM=K.define({combine(e){return hS(e,{afterCursor:!0,brackets:EM,maxScanDistance:TM,renderMatch:AM})}}),OM=J.mark({class:`cm-matchingBracket`}),kM=J.mark({class:`cm-nonmatchingBracket`});function AM(e){let t=[],n=e.matched?OM:kM;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}function jM(e){let t=[],n=e.facet(DM);for(let r of e.selection.ranges){if(!r.empty)continue;let i=LM(e,r.head,-1,n)||r.head>0&&LM(e,r.head-1,1,n)||n.afterCursor&&(LM(e,r.head,1,n)||r.head<e.doc.length&&LM(e,r.head+1,-1,n));i&&(t=t.concat(n.renderMatch(i,e)))}return J.set(t,!0)}var MM=[Rw.fromClass(class{constructor(e){this.paused=!1,this.decorations=jM(e.state)}update(e){(e.docChanged||e.selectionSet||this.paused)&&(e.view.composing?(this.decorations=this.decorations.map(e.changes),this.paused=!0):(this.decorations=jM(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),wM];function NM(e={}){return[DM.of(e),MM]}var PM=new Lk;function FM(e,t,n){let r=e.prop(t<0?Lk.openedBy:Lk.closedBy);if(r)return r;if(e.name.length==1){let r=n.indexOf(e.name);if(r>-1&&r%2==+(t<0))return[n[r+t]]}return null}function IM(e){let t=e.type.prop(PM);return t?t(e.node):e}function LM(e,t,n,r={}){let i=r.maxScanDistance||TM,a=r.brackets||EM,o=lj(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=FM(r.type,n,a);if(i&&r.from<r.to){let o=IM(r);if(o&&(n>0?t>=o.from&&t<o.to:t>o.from&&t<=o.to))return RM(e,t,n,r,o,i,a)}}return zM(e,t,n,o,s.type,i,a)}function RM(e,t,n,r,i,a,o){let s=r.parent,c={from:i.from,to:i.to},l=0,u=s?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(l==0&&a.indexOf(u.type.name)>-1&&u.from<u.to){let e=IM(u);return{start:c,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}else if(FM(u.type,n,o))l++;else if(FM(u.type,-n,o)){if(l==0){let e=IM(u);return{start:c,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}l--}}while(n<0?u.prevSibling():u.nextSibling());return{start:c,matched:!1}}function zM(e,t,n,r,i,a,o){if(n<0?!t:t==e.doc.length)return null;let s=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),c=o.indexOf(s);if(c<0||c%2==0!=n>0)return null;let l={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let e=0;!u.next().done&&e<=a;){let a=u.value;n<0&&(e+=a.length);let s=t+e*n;for(let e=n>0?0:a.length-1,t=n>0?a.length:-1;e!=t;e+=n){let t=o.indexOf(a[e]);if(!(t<0||r.resolveInner(s+e,1).type!=i))if(t%2==0==n>0)d++;else if(d==1)return{start:l,end:{from:s+e,to:s+e+1},matched:t>>1==c>>1};else d--}n>0&&(e+=a.length)}return u.done?{start:l,matched:!1}:null}function BM(e,t,n,r=0,i=0){t??(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));let a=i;for(let i=r;i<t;i++)e.charCodeAt(i)==9?a+=n-a%n:a++;return a}var VM=class{constructor(e,t,n,r){this.string=e,this.tabSize=t,this.indentUnit=n,this.overrideIndent=r,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(e){let t=this.string.charAt(this.pos),n;if(n=typeof e==`string`?t==e:t&&(e instanceof RegExp?e.test(t):e(t)),n)return++this.pos,t}eatWhile(e){let t=this.pos;for(;this.eat(e););return this.pos>t}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=BM(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){return this.overrideIndent??BM(this.string,null,this.tabSize)}match(e,t,n){if(typeof e==`string`){let r=e=>n?e.toLowerCase():e;return r(this.string.substr(this.pos,e.length))==r(e)?(t!==!1&&(this.pos+=e.length),!0):null}else{let n=this.string.slice(this.pos).match(e);return n&&n.index>0?null:(n&&t!==!1&&(this.pos+=n[0].length),n)}}current(){return this.string.slice(this.start,this.pos)}};function HM(e){return{name:e.name||``,token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||UM,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||ZM,mergeTokens:e.mergeTokens!==!1}}function UM(e){if(typeof e!=`object`)return e;let t={};for(let n in e){let r=e[n];t[n]=r instanceof Array?r.slice():r}return t}var WM=new WeakMap,GM=class e extends oj{constructor(e){let t=ij(e.languageData),n=HM(e),r,i=new class extends pA{createParse(e,t,n){return new YM(r,e,t,n)}};super(t,i,[],e.name),this.topNode=sN(t,this),r=this,this.streamParser=n,this.stateAfter=new Lk({perNode:!0}),this.tokenTable=e.tokenTable?new rN(n.tokenTable):iN}static define(t){return new e(t)}getIndent(e){let t,{overrideIndentation:n}=e.options;n&&(t=WM.get(e.state),t!=null&&t<e.pos-1e4&&(t=void 0));let r=KM(this,e.node.tree,e.node.from,e.node.from,t??e.pos),i,a;if(r?(a=r.state,i=r.pos+1):(a=this.streamParser.startState(e.unit),i=e.node.from),e.pos-i>1e4)return null;for(;i<e.pos;){let t=e.state.doc.lineAt(i),r=Math.min(e.pos,t.to);if(t.length){let i=n?n(t.from):-1,o=new VM(t.text,e.state.tabSize,e.unit,i<0?void 0:i);for(;o.pos<r-t.from;)XM(this.streamParser.token,o,a)}else this.streamParser.blankLine(a,e.unit);if(r==e.pos)break;i=t.to+1}let o=e.lineAt(e.pos);return n&&t==null&&WM.set(e.state,o.from),this.streamParser.indent(a,/^\s*(.*)/.exec(o.text)[1],e)}get allowsNesting(){return!1}};function KM(e,t,n,r,i){let a=n>=r&&n+t.length<=i&&t.prop(e.stateAfter);if(a)return{state:e.streamParser.copyState(a),pos:n+t.length};for(let a=t.children.length-1;a>=0;a--){let o=t.children[a],s=n+t.positions[a],c=o instanceof Gk&&s<i&&KM(e,o,s,r,i);if(c)return c}return null}function qM(e,t,n,r,i){if(i&&n<=0&&r>=t.length)return t;!i&&n==0&&t.type==e.topNode&&(i=!0);for(let a=t.children.length-1;a>=0;a--){let o=t.positions[a],s=t.children[a],c;if(o<r&&s instanceof Gk){if(!(c=qM(e,s,n-o,r-o,i)))break;return i?new Gk(t.type,t.children.slice(0,a).concat(c),t.positions.slice(0,a+1),o+c.length):c}}return null}function JM(e,t,n,r,i){for(let i of t){let t=i.from+(i.openStart?25:0),a=i.to-(i.openEnd?25:0),o=t<=n&&a>n&&KM(e,i.tree,0-i.offset,n,a),s;if(o&&o.pos<=r&&(s=qM(e,i.tree,n+i.offset,o.pos+i.offset,!1)))return{state:o.state,tree:s}}return{state:e.streamParser.startState(i?Sj(i):4),tree:Gk.empty}}var YM=class{constructor(e,t,n,r){this.lang=e,this.input=t,this.fragments=n,this.ranges=r,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=r[r.length-1].to;let i=fj.get(),a=r[0].from,{state:o,tree:s}=JM(e,n,a,this.to,i?.state);this.state=o,this.parsedPos=this.chunkStart=a+s.length;for(let e=0;e<s.children.length;e++)this.chunks.push(s.children[e]),this.chunkPos.push(s.positions[e]);i&&this.parsedPos<i.viewport.from-1e5&&r.some(e=>e.from<=i.viewport.from&&e.to>=i.viewport.from)&&(this.state=this.lang.streamParser.startState(Sj(i.state)),i.skipUntilInView(this.parsedPos,i.viewport.from),this.parsedPos=i.viewport.from),this.moveRangeIndex()}advance(){let e=fj.get(),t=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),n=Math.min(t,this.chunkStart+512);for(e&&(n=Math.min(n,e.viewport.to));this.parsedPos<n;)this.parseLine(e);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=t?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,t),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let t=this.input.chunk(e);if(this.input.lineChunks)t==`
131
131
  `&&(t=``);else{let e=t.indexOf(`
132
132
  `);e>-1&&(t=t.slice(0,e))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),n=e+t.length;for(let e=this.rangeIndex;;){let r=this.ranges[e].to;if(r>=n||(t=t.slice(0,r-(n-t.length)),e++,e==this.ranges.length))break;let i=this.ranges[e].from,a=this.lineAfter(i);t+=a,n=i+a.length}return{line:t,end:n}}skipGapsTo(e,t,n){for(;;){let r=this.ranges[this.rangeIndex].to,i=e+t;if(n>0?r>i:r>=i)break;let a=this.ranges[++this.rangeIndex].from;t+=a-r}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(e,t,n,r){let i=4;if(this.ranges.length>1){r=this.skipGapsTo(t,r,1),t+=r;let e=this.chunk.length;r=this.skipGapsTo(n,r,-1),n+=r,i+=this.chunk.length-e}let a=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&i==4&&a>=0&&this.chunk[a]==e&&this.chunk[a+2]==t?this.chunk[a+2]=n:this.chunk.push(e,t,n,i),r}parseLine(e){let{line:t,end:n}=this.nextLine(),r=0,{streamParser:i}=this.lang,a=new VM(t,e?e.state.tabSize:4,e?Sj(e.state):2);if(a.eol())i.blankLine(this.state,a.indentUnit);else for(;!a.eol();){let e=XM(i.token,a,this.state);if(e&&(r=this.emitToken(this.lang.tokenTable.resolve(e),this.parsedPos+a.start,this.parsedPos+a.pos,r)),a.start>1e4)break}this.parsedPos=n,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let e=Gk.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:$M,topID:0,maxBufferLength:512,reused:this.chunkReused});e=new Gk(e.type,e.children,e.positions,e.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(e),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new Gk(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function XM(e,t,n){t.start=t.pos;for(let r=0;r<10;r++){let r=e(t,n);if(t.pos>t.start)return r}throw Error(`Stream parser failed to advance stream.`)}var ZM=Object.create(null),QM=[Bk.none],$M=new Vk(QM),eN=[],tN=Object.create(null),nN=Object.create(null);for(let[e,t]of[[`variable`,`variableName`],[`variable-2`,`variableName.special`],[`string-2`,`string.special`],[`def`,`variableName.definition`],[`tag`,`tagName`],[`attribute`,`attributeName`],[`type`,`typeName`],[`builtin`,`variableName.standard`],[`qualifier`,`modifier`],[`error`,`invalid`],[`header`,`heading`],[`property`,`propertyName`]])nN[e]=oN(ZM,t);var rN=class{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),nN)}resolve(e){return e?this.table[e]||(this.table[e]=oN(this.extra,e)):0}},iN=new rN(ZM);function aN(e,t){eN.indexOf(e)>-1||(eN.push(e),console.warn(t))}function oN(e,t){let n=[];for(let r of t.split(` `)){let t=[];for(let n of r.split(`.`)){let r=e[n]||Z[n];r?typeof r==`function`?t.length?t=t.map(r):aN(n,`Modifier ${n} used at start of tag`):t.length?aN(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:aN(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,`_`),i=r+` `+n.map(e=>e.id),a=tN[i];if(a)return a.id;let o=tN[i]=Bk.define({id:QM.length,name:r,props:[FA({[r]:n})]});return QM.push(o),o.id}function sN(e,t){let n=Bk.define({id:QM.length,name:`Document`,props:[rj.add(()=>e),Ej.add(()=>e=>t.getIndent(e))],top:!0});return QM.push(n),n}XC.RTL,XC.LTR;var cN=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=pN(e.state,n.from);return r.line?uN(e):r.block?fN(e):!1};function lN(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var uN=lN(vN,0),dN=lN(_N,0),fN=lN((e,t)=>_N(e,t,gN(t)),0);function pN(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var mN=50;function hN(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-mN,r),o=e.sliceDoc(i,i+mN),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=2*mN?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+mN),d=e.sliceDoc(i-mN,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function gN(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function _N(e,t,n=t.selection.ranges){let r=n.map(e=>pN(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>hN(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function vN(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=pN(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}else if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var yN=Xx.define(),bN=Xx.define(),xN=K.define(),SN=K.define({combine(e){return hS(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),CN=Mx.define({create(){return HN.empty},update(e,t){let n=t.state.facet(SN),r=t.annotation(yN);if(r){let i=AN.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?jN(o,o.length,n.minDepth,i):LN(o,t.startState.selection),new HN(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(bN);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(eS.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=AN.fromTransaction(t),o=t.annotation(eS.time),s=t.annotation(eS.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new HN(e.done.map(AN.fromJSON),e.undone.map(AN.fromJSON))}});function wN(e={}){return[CN,SN.of(e),Y.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?EN:e.inputType==`historyRedo`?DN:null;return n?(e.preventDefault(),n(t)):!1}})]}function TN(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(CN,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var EN=TN(0,!1),DN=TN(1,!1),ON=TN(0,!0),kN=TN(1,!0),AN=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&gx.fromJSON(t.changes),[],t.mapped&&hx.fromJSON(t.mapped),t.startSelection&&G.fromJSON(t.startSelection),t.selectionsAfter.map(G.fromJSON))}static fromTransaction(t,n){let r=FN;for(let e of t.startState.facet(xN)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,FN)}static selection(t){return new e(void 0,FN,void 0,void 0,t)}};function jN(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function MN(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function NN(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function PN(e,t){return e.length?t.length?e.concat(t):e:t}var FN=[],IN=200;function LN(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-IN));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),jN(e,e.length-1,1e9,n.setSelAfter(r)))}else return[AN.selection([t])]}function RN(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function zN(e,t){if(!e.length)return e;let n=e.length,r=FN;for(;n;){let i=BN(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[AN.selection(r)]:FN}function BN(e,t,n){let r=PN(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):FN,n);if(!e.changes)return AN.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new AN(i,$x.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var VN=/^(input\.type|delete)($|\.)/,HN=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||VN.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,MN(s.changes,t.changes))||r==`input.type.compose`)?jN(o,o.length-1,i.minDepth,new AN(t.changes.compose(s.changes),PN($x.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,FN)):jN(o,o.length,i.minDepth,t),new e(o,FN,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:FN;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&NN(a[a.length-1],t)?this:new e(LN(this.done,t),this.undone,n,r)}addMapping(t){return new e(zN(this.done,t),zN(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:yN.of({side:e,rest:RN(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?FN:r.slice(0,r.length-1);return i.mapped&&(n=zN(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:yN.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};HN.empty=new HN(FN,FN);var UN=[{key:`Mod-z`,run:EN,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:DN,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:DN,preventDefault:!0},{key:`Mod-u`,run:ON,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:kN,preventDefault:!0}];function WN(e,t){return G.create(e.ranges.map(t),e.mainIndex)}function GN(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function KN({state:e,dispatch:t},n){let r=WN(e.selection,n);return r.eq(e.selection,!0)?!1:(t(GN(e,r)),!0)}function qN(e,t){return G.cursor(t?e.to:e.from)}function JN(e,t){return KN(e,n=>n.empty?e.moveByChar(n,t):qN(n,t))}function YN(e){return e.textDirectionAt(e.state.selection.main.head)==XC.LTR}var XN=e=>JN(e,!YN(e)),ZN=e=>JN(e,YN(e));function QN(e,t){return KN(e,n=>n.empty?e.moveByGroup(n,t):qN(n,t))}var $N=e=>QN(e,!YN(e)),eP=e=>QN(e,YN(e));typeof Intl<`u`&&Intl.Segmenter;function tP(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function nP(e,t,n){let r=lj(e).resolveInner(t.head),i=n?Lk.closedBy:Lk.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;tP(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?LM(e,r.from,1):LM(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,G.cursor(s,n?-1:1)}var rP=e=>KN(e,t=>nP(e.state,t,!YN(e))),iP=e=>KN(e,t=>nP(e.state,t,YN(e)));function aP(e,t){return KN(e,n=>{if(!n.empty)return qN(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var oP=e=>aP(e,!1),sP=e=>aP(e,!0);function cP(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(Y.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function lP(e,t){let n=cP(e),{state:r}=e,i=WN(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):qN(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=Y.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(GN(r,i),{effects:a}),!0}var uP=e=>lP(e,!1),dP=e=>lP(e,!0);function fP(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=G.cursor(r.from+n))}return i}var pP=e=>KN(e,t=>fP(e,t,!0)),mP=e=>KN(e,t=>fP(e,t,!1)),hP=e=>KN(e,t=>fP(e,t,!YN(e))),gP=e=>KN(e,t=>fP(e,t,YN(e))),_P=e=>KN(e,t=>G.cursor(e.lineBlockAt(t.head).from,1)),vP=e=>KN(e,t=>G.cursor(e.lineBlockAt(t.head).to,-1));function yP(e,t,n){let r=!1,i=WN(e.selection,t=>{let i=LM(e,t.head,-1)||LM(e,t.head,1)||t.head>0&&LM(e,t.head-1,1)||t.head<e.doc.length&&LM(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?G.range(t.anchor,a):G.cursor(a)});return r?(t(GN(e,i)),!0):!1}var bP=({state:e,dispatch:t})=>yP(e,t,!1);function xP(e,t){let n=WN(e.state.selection,e=>{let n=t(e);return G.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(GN(e.state,n)),!0)}function SP(e,t){return xP(e,n=>e.moveByChar(n,t))}var CP=e=>SP(e,!YN(e)),wP=e=>SP(e,YN(e));function TP(e,t){return xP(e,n=>e.moveByGroup(n,t))}var EP=e=>TP(e,!YN(e)),DP=e=>TP(e,YN(e)),OP=e=>xP(e,t=>nP(e.state,t,!YN(e))),kP=e=>xP(e,t=>nP(e.state,t,YN(e)));function AP(e,t){return xP(e,n=>e.moveVertically(n,t))}var jP=e=>AP(e,!1),MP=e=>AP(e,!0);function NP(e,t){return xP(e,n=>e.moveVertically(n,t,cP(e).height))}var PP=e=>NP(e,!1),FP=e=>NP(e,!0),IP=e=>xP(e,t=>fP(e,t,!0)),LP=e=>xP(e,t=>fP(e,t,!1)),RP=e=>xP(e,t=>fP(e,t,!YN(e))),zP=e=>xP(e,t=>fP(e,t,YN(e))),BP=e=>xP(e,t=>G.cursor(e.lineBlockAt(t.head).from)),VP=e=>xP(e,t=>G.cursor(e.lineBlockAt(t.head).to)),HP=({state:e,dispatch:t})=>(t(GN(e,{anchor:0})),!0),UP=({state:e,dispatch:t})=>(t(GN(e,{anchor:e.doc.length})),!0),WP=({state:e,dispatch:t})=>(t(GN(e,{anchor:e.selection.main.anchor,head:0})),!0),GP=({state:e,dispatch:t})=>(t(GN(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),KP=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),qP=({state:e,dispatch:t})=>{let n=fF(e).map(({from:t,to:n})=>G.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:G.create(n),userEvent:`select`})),!0},JP=({state:e,dispatch:t})=>{let n=WN(e.selection,t=>{let n=lj(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return G.range(n.to,n.from)}return t});return n.eq(e.selection)?!1:(t(GN(e,n)),!0)};function YP(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}else if(r.head==n.head)break;else n=r}}return i.length==r.ranges.length?!1:(e.dispatch(GN(n,G.create(i,i.length-1))),!0)}var XP=e=>YP(e,!1),ZP=e=>YP(e,!0),QP=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=G.create([n.main]):n.main.empty||(r=G.create([G.cursor(n.main.head)])),r?(t(GN(e,r)),!0):!1};function $P(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=eF(e,o,!1)):o>i&&(n=`delete.forward`,o=eF(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=eF(e,i,!1),a=eF(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:G.cursor(i,i<r.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?Y.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function eF(e,t,n){if(e instanceof Y)for(let r of e.state.facet(Y.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var tF=(e,t,n)=>$P(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=PS(s,a.tabSize)%Sj(a)||Sj(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=sx(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=sx(o.text,c-o.from,!1,!1)+o.from);return c}),nF=e=>tF(e,!1,!0),rF=e=>tF(e,!0,!1),iF=(e,t)=>$P(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=sx(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),aF=e=>iF(e,!1),oF=e=>iF(e,!0),sF=e=>$P(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),cF=e=>$P(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),lF=e=>$P(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),uF=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:Xb.of([``,``])},range:G.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},dF=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:sx(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:sx(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:G.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function fF(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function pF(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of fF(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(G.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(G.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:G.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var mF=({state:e,dispatch:t})=>pF(e,t,!1),hF=({state:e,dispatch:t})=>pF(e,t,!0);function gF(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of fF(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var _F=({state:e,dispatch:t})=>gF(e,t,!1),vF=({state:e,dispatch:t})=>gF(e,t,!0),yF=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(fF(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=WN(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function bF(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=lj(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(Lk.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var xF=CF(!1),SF=CF(!0);function CF(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&bF(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new Tj(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=wj(s,r);for(c??=PS(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,Cj(t,c)];return o&&l.push(Cj(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:Xb.of(l)},range:G.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function wF(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:G.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var TF=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new Tj(e,{overrideIndentation:e=>n[e]??-1}),i=wF(e,(t,i,a)=>{let o=wj(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=Cj(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},EF=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(wF(e,(t,n)=>{n.push({from:t.from,insert:e.facet(xj)})}),{userEvent:`input.indent`})),!0),DF=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(wF(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=PS(r,e.tabSize),a=0,o=Cj(e,Math.max(0,i-Sj(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),OF=e=>(e.setTabFocusMode(),!0),kF=[{key:`Ctrl-b`,run:XN,shift:CP,preventDefault:!0},{key:`Ctrl-f`,run:ZN,shift:wP},{key:`Ctrl-p`,run:oP,shift:jP},{key:`Ctrl-n`,run:sP,shift:MP},{key:`Ctrl-a`,run:_P,shift:BP},{key:`Ctrl-e`,run:vP,shift:VP},{key:`Ctrl-d`,run:rF},{key:`Ctrl-h`,run:nF},{key:`Ctrl-k`,run:sF},{key:`Ctrl-Alt-h`,run:aF},{key:`Ctrl-o`,run:uF},{key:`Ctrl-t`,run:dF},{key:`Ctrl-v`,run:dP}],AF=[{key:`ArrowLeft`,run:XN,shift:CP,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:$N,shift:EP,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:hP,shift:RP,preventDefault:!0},{key:`ArrowRight`,run:ZN,shift:wP,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:eP,shift:DP,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:gP,shift:zP,preventDefault:!0},{key:`ArrowUp`,run:oP,shift:jP,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:HP,shift:WP},{mac:`Ctrl-ArrowUp`,run:uP,shift:PP},{key:`ArrowDown`,run:sP,shift:MP,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:UP,shift:GP},{mac:`Ctrl-ArrowDown`,run:dP,shift:FP},{key:`PageUp`,run:uP,shift:PP},{key:`PageDown`,run:dP,shift:FP},{key:`Home`,run:mP,shift:LP,preventDefault:!0},{key:`Mod-Home`,run:HP,shift:WP},{key:`End`,run:pP,shift:IP,preventDefault:!0},{key:`Mod-End`,run:UP,shift:GP},{key:`Enter`,run:xF,shift:xF},{key:`Mod-a`,run:KP},{key:`Backspace`,run:nF,shift:nF,preventDefault:!0},{key:`Delete`,run:rF,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:aF,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:oF,preventDefault:!0},{mac:`Mod-Backspace`,run:cF,preventDefault:!0},{mac:`Mod-Delete`,run:lF,preventDefault:!0}].concat(kF.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),jF=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:rP,shift:OP},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:iP,shift:kP},{key:`Alt-ArrowUp`,run:mF},{key:`Shift-Alt-ArrowUp`,run:_F},{key:`Alt-ArrowDown`,run:hF},{key:`Shift-Alt-ArrowDown`,run:vF},{key:`Mod-Alt-ArrowUp`,run:XP},{key:`Mod-Alt-ArrowDown`,run:ZP},{key:`Escape`,run:QP},{key:`Mod-Enter`,run:SF},{key:`Alt-l`,mac:`Ctrl-l`,run:qP},{key:`Mod-i`,run:JP,preventDefault:!0},{key:`Mod-[`,run:DF},{key:`Mod-]`,run:EF},{key:`Mod-Alt-\\`,run:TF},{key:`Shift-Mod-k`,run:yF},{key:`Shift-Mod-\\`,run:bP},{key:`Mod-/`,run:cN},{key:`Alt-A`,run:dN},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:OF}].concat(AF),MF={key:`Tab`,run:EF,shift:DF},NF=`#e5c07b`,PF=`#e06c75`,FF=`#56b6c2`,IF=`#ffffff`,LF=`#abb2bf`,RF=`#7d8799`,zF=`#61afef`,BF=`#98c379`,VF=`#d19a66`,HF=`#c678dd`,UF=`#21252b`,WF=`#2c313a`,GF=`#282c34`,KF=`#353a42`,qF=`#3E4451`,JF=`#528bff`,YF=[Y.theme({"&":{color:LF,backgroundColor:GF},".cm-content":{caretColor:JF},".cm-cursor, .cm-dropCursor":{borderLeftColor:JF},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:qF},".cm-panels":{backgroundColor:UF,color:LF},".cm-panels.cm-panels-top":{borderBottom:`2px solid black`},".cm-panels.cm-panels-bottom":{borderTop:`2px solid black`},".cm-searchMatch":{backgroundColor:`#72a1ff59`,outline:`1px solid #457dff`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:`#6199ff2f`},".cm-activeLine":{backgroundColor:`#6699ff0b`},".cm-selectionMatch":{backgroundColor:`#aafe661a`},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bad0f847`},".cm-gutters":{backgroundColor:GF,color:RF,border:`none`},".cm-activeLineGutter":{backgroundColor:WF},".cm-foldPlaceholder":{backgroundColor:`transparent`,border:`none`,color:`#ddd`},".cm-tooltip":{border:`none`,backgroundColor:KF},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:`transparent`,borderBottomColor:`transparent`},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:KF,borderBottomColor:KF},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:WF,color:LF}}},{dark:!0}),bM(gM.define([{tag:Z.keyword,color:HF},{tag:[Z.name,Z.deleted,Z.character,Z.propertyName,Z.macroName],color:PF},{tag:[Z.function(Z.variableName),Z.labelName],color:zF},{tag:[Z.color,Z.constant(Z.name),Z.standard(Z.name)],color:VF},{tag:[Z.definition(Z.name),Z.separator],color:LF},{tag:[Z.typeName,Z.className,Z.number,Z.changed,Z.annotation,Z.modifier,Z.self,Z.namespace],color:NF},{tag:[Z.operator,Z.operatorKeyword,Z.url,Z.escape,Z.regexp,Z.link,Z.special(Z.string)],color:FF},{tag:[Z.meta,Z.comment],color:RF},{tag:Z.strong,fontWeight:`bold`},{tag:Z.emphasis,fontStyle:`italic`},{tag:Z.strikethrough,textDecoration:`line-through`},{tag:Z.link,color:RF,textDecoration:`underline`},{tag:Z.heading,fontWeight:`bold`,color:PF},{tag:[Z.atom,Z.bool,Z.special(Z.variableName)],color:VF},{tag:[Z.processingInstruction,Z.string,Z.inserted],color:BF},{tag:Z.invalid,color:IF}]))],XF=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,ZF=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(XF(e)):XF,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return ux(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=dx(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=fx(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n,a=!0;;e++){let n=r.charCodeAt(e),o=this.match(n,i,a,this.bufferPos+this.bufferStart,e==r.length-1);if(o)return this.value=o,this;if(e==r.length-1)break;a&&e<t.length&&t.charCodeAt(e)==n?i++:a=!1}}}match(e,t,n,r,i){let a=null;for(let t=0;t<this.matches.length;){let n=this.matches[t],o=!1;this.query.charCodeAt(n.index)==e&&(n.index==this.query.length-1?a={from:n.from,to:r,precise:i&&n.precise}:(n.index++,o=!0)),o?t++:this.matches.splice(t,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?a={from:t,to:r,precise:n&&i}:this.matches.push({from:t,index:1,precise:n})),a&&this.test&&!this.test(a.from,a.to,this.buffer,this.bufferStart)&&(a=null),a}};typeof Symbol<`u`&&(ZF.prototype[Symbol.iterator]=function(){return this});var QF={from:-1,to:-1,match:/.*/.exec(``),precise:!0},$F=`gm`+(/x/.unicode==null?``:`u`),eI=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=QF,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new rI(e,t,n,r,i);this.re=new RegExp(t,$F+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter();let a=e.lineAt(r);this.curLineStart=a.from,this.matchPos=aI(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=aI(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},tI=new WeakMap,nI=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=tI.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return tI.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),tI.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},rI=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=QF,this.matchPos=aI(e,r),this.re=new RegExp(t,$F+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=nI.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,precise:!0,match:t},this.matchPos=aI(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=nI.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(eI.prototype[Symbol.iterator]=rI.prototype[Symbol.iterator]=function(){return this});function iI(e){try{return new RegExp(e,$F),!0}catch{return!1}}function aI(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var oI=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=rk(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),p=G.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,Y.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},sI={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},cI=K.define({combine(e){return hS(e,sI,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function lI(e){let t=[hI,mI];return e&&t.push(cI.of(e)),t}var uI=J.mark({class:`cm-selectionMatch`}),dI=J.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function fI(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=lS.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=lS.Word)}function pI(e,t,n,r){return e(t.sliceDoc(n,n+1))==lS.Word&&e(t.sliceDoc(r-1,r))==lS.Word}var mI=Rw.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(cI),{state:n}=e,r=n.selection;if(r.ranges.length>1)return J.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return J.none;let e=n.wordAt(i.head);if(!e)return J.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return J.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(fI(o,n,i.from,i.to)&&pI(o,n,i.from,i.to)))return J.none}else if(a=n.sliceDoc(i.from,i.to),!a)return J.none}let s=[];for(let r of e.visibleRanges){let e=new ZF(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||fI(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(dI.range(r,a)):(r>=i.to||a<=i.from)&&s.push(uI.range(r,a)),s.length>t.maxMatches))return J.none}}return J.set(s)}},{decorations:e=>e.decorations}),hI=Y.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),gI=({state:e,dispatch:t})=>{let{selection:n}=e,r=G.create(n.ranges.map(t=>e.wordAt(t.head)||G.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function _I(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new ZF(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new ZF(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var vI=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return gI({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=_I(e,r);return i?(t(e.update({selection:e.selection.addRange(G.range(i.from,i.to),!1),effects:Y.scrollIntoView(i.to)})),!0):!1},yI=K.define({combine(e){return hS(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new $I(e),scrollToMatch:e=>Y.scrollIntoView(e)})}}),bI=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||iI(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
133
- `:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new jI(this):new TI(this)}getCursor(e,t=0,n){let r=e.doc?e:mS.create({doc:e});return n??=r.doc.length,this.regexp?DI(this,r,t,n):CI(this,r,t,n)}},xI=class{constructor(e){this.spec=e}};function SI(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function CI(e,t,n,r){let i;return e.wholeWord&&(i=wI(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=SI(e.test,t,i)),new ZF(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function wI(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(OI(i,n-a))!=lS.Word||t(kI(i,n-a))!=lS.Word)&&(t(kI(i,r-a))!=lS.Word||t(OI(i,r-a))!=lS.Word))}var TI=class extends xI{constructor(e){super(e)}nextMatch(e,t,n){let r=CI(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=CI(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=CI(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=CI(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=CI(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function EI(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function DI(e,t,n,r){let i;return e.wholeWord&&(i=AI(t.charCategorizer(t.selection.main.head))),e.test&&(i=EI(e.test,t,i)),new eI(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function OI(e,t){return e.slice(sx(e,t,!1),t)}function kI(e,t){return e.slice(t,sx(e,t))}function AI(e){return(t,n,r)=>!r[0].length||(e(OI(r.input,r.index))!=lS.Word||e(kI(r.input,r.index))!=lS.Word)&&(e(kI(r.input,r.index+r[0].length))!=lS.Word||e(OI(r.input,r.index+r[0].length))!=lS.Word)}var jI=class extends xI{nextMatch(e,t,n){let r=DI(this.spec,e,n,e.doc.length).next();return r.done&&(r=DI(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=DI(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=DI(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=DI(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},MI=$x.define(),NI=$x.define(),PI=Mx.define({create(e){return new FI(qI(e).create(),null)},update(e,t){for(let n of t.effects)n.is(MI)?e=new FI(n.value.create(),e.panel):n.is(NI)&&(e=new FI(e.query,n.value?KI:null));return e},provide:e=>nk.from(e,e=>e.panel)}),FI=class{constructor(e,t){this.query=e,this.panel=t}},II=J.mark({class:`cm-searchMatch`}),LI=J.mark({class:`cm-searchMatch cm-searchMatch-selected`}),RI=Rw.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(PI))}update(e){let t=e.state.field(PI);(t!=e.startState.field(PI)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return J.none;let{view:n}=this,r=new CS;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?LI:II)})}return r.finish()}},{decorations:e=>e.decorations});function zI(e){return t=>{let n=t.state.field(PI,!1);return n&&n.query.spec.valid?e(t,n):XI(t)}}var BI=zI((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=G.single(r.from,r.to),a=e.state.facet(yI);return e.dispatch({selection:i,effects:[rL(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),YI(e),!0}),VI=zI((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=G.single(i.from,i.to),o=e.state.facet(yI);return e.dispatch({selection:a,effects:[rL(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),YI(e),!0}),HI=zI((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:G.create(n.map(e=>G.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),UI=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new ZF(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(G.range(t.value.from,t.value.to))}return t(e.update({selection:G.create(a,o),userEvent:`select.search.matches`})),!0},WI=zI((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.precise?o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),u.push(Y.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`))):o=t.nextMatch(n,o.from,o.to);let d=e.state.changes(s);return o&&(c=G.single(o.from,o.to).map(d),u.push(rL(e,o)),u.push(n.facet(yI).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),GI=zI((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let r of t.matchAll(e.state,1e9)){let{from:e,to:i,precise:a}=r;a&&n.push({from:e,to:i,insert:t.getReplacement(r)})}if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:Y.announce.of(r),userEvent:`input.replace.all`}),!0});function KI(e){return e.state.facet(yI).createPanel(e)}function qI(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(yI);return new bI({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function JI(e){let t=QO(e,KI);return t&&t.dom.querySelector(`[main-field]`)}function YI(e){let t=JI(e);t&&t==e.root.activeElement&&t.select()}var XI=e=>{let t=e.state.field(PI,!1);if(t&&t.panel){let n=JI(e);if(n&&n!=e.root.activeElement){let r=qI(e.state,t.query.spec);r.valid&&e.dispatch({effects:MI.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[NI.of(!0),t?MI.of(qI(e.state,t.query.spec)):$x.appendConfig.of(aL)]});return!0},ZI=e=>{let t=e.state.field(PI,!1);if(!t||!t.panel)return!1;let n=QO(e,KI);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:NI.of(!1)}),!0},QI=[{key:`Mod-f`,run:XI,scope:`editor search-panel`},{key:`F3`,run:BI,shift:VI,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:BI,shift:VI,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:ZI,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:UI},{key:`Mod-Alt-g`,run:oI},{key:`Mod-d`,run:vI,preventDefault:!0}],$I=class{constructor(e){this.view=e;let t=this.query=e.state.field(PI).query.spec;this.commit=this.commit.bind(this),this.searchField=XS(`input`,{value:t.search,placeholder:eL(e,`Find`),"aria-label":eL(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=XS(`input`,{value:t.replace,placeholder:eL(e,`Replace`),"aria-label":eL(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=XS(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=XS(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=XS(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return XS(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=XS(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>BI(e),[eL(e,`next`)]),n(`prev`,()=>VI(e),[eL(e,`previous`)]),n(`select`,()=>HI(e),[eL(e,`all`)]),XS(`label`,null,[this.caseField,eL(e,`match case`)]),XS(`label`,null,[this.reField,eL(e,`regexp`)]),XS(`label`,null,[this.wordField,eL(e,`by word`)]),...e.state.readOnly?[]:[XS(`br`),this.replaceField,n(`replace`,()=>WI(e),[eL(e,`replace`)]),n(`replaceAll`,()=>GI(e),[eL(e,`replace all`)])],XS(`button`,{name:`close`,onclick:()=>ZI(e),"aria-label":eL(e,`close`),type:`button`},[`×`])])}commit(){let e=new bI({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:MI.of(e)}))}keydown(e){rO(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?VI:BI)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),WI(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(MI)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(yI).top}};function eL(e,t){return e.state.phrase(t)}var tL=30,nL=/[\s\.,:;?!]/;function rL(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-tL),o=Math.min(i,n+tL),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<tL;e++)if(!nL.test(s[e+1])&&nL.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-tL;e--)if(!nL.test(s[e-1])&&nL.test(s[e])){s=s.slice(0,e);break}}return Y.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var iL=Y.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),aL=[PI,Fx.low(RI),iL],oL=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=lj(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(pL(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e==`abort`&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function sL(e){let t=Object.keys(e).join(``),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,``)),`[${n?`\\w`:``}${t.replace(/[^\w\s]/g,`\\$&`)}]`}function cL(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=sL(t)+sL(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function lL(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:cL(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function uL(e,t){return n=>{for(let t=lj(n.state).resolveInner(n.pos,-1);t;t=t.parent){if(e.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(n)}}var dL=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function fL(e){return e.selection.main.from}function pL(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}var mL=Xx.define();function hL(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return{...e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let c=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:c},range:G.cursor(s.from+a+c.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var gL=new WeakMap;function _L(e){if(!Array.isArray(e))return e;let t=gL.get(e);return t||gL.set(e,t=lL(e)),t}var vL=$x.define(),yL=$x.define(),bL=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=ux(e,t),r=fx(n);this.chars.push(n);let i=e.slice(t,t+r),a=i.toUpperCase();this.folded.push(ux(a==i?i.toLowerCase():a,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:r,precise:i,byWord:a}=this;if(t.length==1){let r=ux(e,0),i=fx(r),a=i==e.length?0:-100;if(r!=t[0])if(r==n[0])a+=-200;else return null;return this.ret(a,[0,i])}let o=e.indexOf(this.pattern);if(o==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let s=t.length,c=0;if(o<0){for(let i=0,a=Math.min(e.length,200);i<a&&c<s;){let a=ux(e,i);(a==t[c]||a==n[c])&&(r[c++]=i),i+=fx(a)}if(c<s)return null}let l=0,u=0,d=!1,f=0,p=-1,m=-1,h=/[a-z]/.test(e),g=!0;for(let r=0,c=Math.min(e.length,200),_=0;r<c&&u<s;){let c=ux(e,r);o<0&&(l<s&&c==t[l]&&(i[l++]=r),f<s&&(c==t[f]||c==n[f]?(f==0&&(p=r),m=r+1,f++):f=0));let v,y=c<255?c>=48&&c<=57||c>=97&&c<=122?2:+(c>=65&&c<=90):(v=dx(c))==v.toLowerCase()?v==v.toUpperCase()?0:2:1;(!r||y==1&&h||_==0&&y!=0)&&(t[u]==c||n[u]==c&&(d=!0)?a[u++]=r:a.length&&(g=!1)),_=y,r+=fx(c)}return u==s&&a[0]==0&&g?this.result(-100+(d?-200:0),a,e):f==s&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):f==s?this.ret(-900-e.length,[p,m]):u==s?this.result(-100+(d?-200:0)+-700+(g?0:-1100),a,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,n){let r=[],i=0;for(let e of t){let t=e+(this.astral?fx(ux(n,e)):1);i&&r[i-1]==e?r[i-1]=t:(r[i++]=e,r[i++]=t)}return this.ret(e-n.length,r)}},xL=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}},SL=K.define({combine(e){return hS(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>``,optionClass:()=>``,aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:wL,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>CL(e(n),t(n)),optionClass:(e,t)=>n=>CL(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function CL(e,t){return e?t?e+` `+t:e:t}function wL(e,t,n,r,i,a){let o=e.textDirection==XC.RTL,s=o,c=!1,l=`top`,u,d,f=t.left-i.left,p=i.right-t.right,m=r.right-r.left,h=r.bottom-r.top;if(s&&f<Math.min(m,p)?s=!1:!s&&p<Math.min(m,f)&&(s=!0),m<=(s?f:p))u=Math.max(i.top,Math.min(n.top,i.bottom-h))-t.top,d=Math.min(400,s?f:p);else{c=!0,d=Math.min(400,(o?t.right:i.right-t.left)-30);let e=i.bottom-t.bottom;e>=h||e>t.top?u=n.bottom-t.top:(l=`bottom`,u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,_=(t.right-t.left)/a.offsetWidth;return{style:`${l}: ${u/g}px; max-width: ${d/_}px`,class:`cm-completionInfo-`+(c?o?`left-narrow`:`right-narrow`:s?`left`:`right`)}}var TL=$x.define();function EL(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement(`div`);return t.classList.add(`cm-completionIcon`),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>`cm-completionIcon-`+e)),t.setAttribute(`aria-hidden`,`true`),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement(`span`);i.className=`cm-completionLabel`;let a=e.displayLabel||e.label,o=0;for(let e=0;e<r.length;){let t=r[e++],n=r[e++];t>o&&i.appendChild(document.createTextNode(a.slice(o,t)));let s=i.appendChild(document.createElement(`span`));s.appendChild(document.createTextNode(a.slice(t,n))),s.className=`cm-completionMatchedText`,o=n}return o<a.length&&i.appendChild(document.createTextNode(a.slice(o))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement(`span`);return t.className=`cm-completionDetail`,t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}function DL(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.ceil((e-t)/n);return{from:e-r*n,to:e-(r-1)*n}}var OL=class{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass=``;let r=e.state.field(t),{options:i,selected:a}=r.open,o=e.state.facet(SL);this.optionContent=EL(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=DL(i.length,a,o.maxRenderedOptions),this.dom=document.createElement(`div`),this.dom.className=`cm-tooltip-autocomplete`,this.updateTooltipClass(e.state),this.dom.addEventListener(`mousedown`,n=>{let{options:r}=e.state.field(t).open;for(let t=n.target,i;t&&t!=this.dom;t=t.parentNode)if(t.nodeName==`LI`&&(i=/-(\d+)$/.exec(t.id))&&+i[1]<r.length){this.applyCompletion(e,r[+i[1]]),n.preventDefault();return}if(n.target==this.list){let t=this.list.classList.contains(`cm-completionListIncompleteTop`)&&n.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains(`cm-completionListIncompleteBottom`)&&n.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;t!=null&&(e.dispatch({effects:TL.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(SL).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:yL.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener(`scroll`,()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){let t=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),t!=n){let{options:r,selected:i,disabled:a}=t.open;(!n.open||n.open.options!=r)&&(this.range=DL(r.length,i,e.state.facet(SL).maxRenderedOptions),this.showOptions(r,t.id)),this.updateSel(),a!=n.open?.disabled&&this.dom.classList.toggle(`cm-tooltip-autocomplete-disabled`,!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(` `))e&&this.dom.classList.remove(e);for(let e of t.split(` `))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=DL(t.options.length,t.selected,this.view.state.facet(SL).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let a=typeof i==`string`?document.createTextNode(i):i(r);if(!a)return;`then`in a?a.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,r)}).catch(e=>Pw(this.view.state,e,`completion info`)):(this.addInfoPane(a,r),n.setAttribute(`aria-describedby`,this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement(`div`);if(n.className=`cm-tooltip cm-completionInfo`,n.id=`cm-completionInfo-`+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!=`LI`||!n.id?r--:r==e?n.hasAttribute(`aria-selected`)||(n.setAttribute(`aria-selected`,`true`),t=n):n.hasAttribute(`aria-selected`)&&(n.removeAttribute(`aria-selected`),n.removeAttribute(`aria-describedby`));return t&&AL(this.list,t),t}measureInfo(){let e=this.dom.querySelector(`[aria-selected]`);if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(SL).positionInfo(this.view,t,r,n,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className=`cm-tooltip cm-completionInfo `+(e.class||``)):this.info.style.cssText=`top: -1e6px`)}createListBox(e,t,n){let r=document.createElement(`ul`);r.id=t,r.setAttribute(`role`,`listbox`),r.setAttribute(`aria-expanded`,`true`),r.setAttribute(`aria-label`,this.view.state.phrase(`Completions`)),r.addEventListener(`mousedown`,e=>{e.target==r&&e.preventDefault()});let i=null;for(let a=n.from;a<n.to;a++){let{completion:o,match:s}=e[a],{section:c}=o;if(c){let e=typeof c==`string`?c:c.name;if(e!=i&&(a>n.from||n.from==0))if(i=e,typeof c!=`string`&&c.header)r.appendChild(c.header(c));else{let t=r.appendChild(document.createElement(`completion-section`));t.textContent=e}}let l=r.appendChild(document.createElement(`li`));l.id=t+`-`+a,l.setAttribute(`role`,`option`);let u=this.optionClass(o);u&&(l.className=u);for(let e of this.optionContent){let t=e(o,this.view.state,this.view,s);t&&l.appendChild(t)}}return n.from&&r.classList.add(`cm-completionListIncompleteTop`),n.to<e.length&&r.classList.add(`cm-completionListIncompleteBottom`),r}destroyInfo(){this.info&&=(this.infoDestroy&&this.infoDestroy(),this.info.remove(),null)}destroy(){this.destroyInfo()}};function kL(e,t){return n=>new OL(n,e,t)}function AL(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function jL(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+ +!!e.type}function ML(e,t){let n=[],r=null,i=null,a=e=>{n.push(e);let{section:t}=e.completion;if(t){r||=[];let e=typeof t==`string`?t:t.name;r.some(t=>t.name==e)||r.push(typeof t==`string`?{name:e}:t)}},o=t.facet(SL);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(r.result.filter===!1)for(let t of r.result.options)a(new dL(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new xL(n):new bL(n);for(let t of r.result.options)if(s=c.match(t.label)){let n=t.displayLabel?e?e(t,s.matched):[]:s.matched,o=s.score+(t.boost||0);if(a(new dL(t,r.source,n,o)),typeof t.section==`object`&&t.section.rank===`dynamic`){let{name:e}=t.section;i||=Object.create(null),i[e]=Math.max(o,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,a=(e,t)=>(e.rank===`dynamic`&&t.rank===`dynamic`?i[t.name]-i[e.name]:0)||(typeof e.rank==`number`?e.rank:1e9)-(typeof t.rank==`number`?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of r.sort(a))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e[typeof n==`string`?n:n.name])}}let s=[],c=null,l=o.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||l(e.completion,t.completion))){let t=e.completion;!c||c.label!=t.label||c.detail!=t.detail||c.type!=null&&t.type!=null&&c.type!=t.type||c.apply!=t.apply||c.boost!=t.boost?s.push(e):jL(e.completion)>jL(c)&&(s[s.length-1]=e),c=e.completion}return s}var NL=class e{constructor(e,t,n,r,i,a){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new e(this.options,RL(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(e=>e.isPending))return i.setDisabled();let s=ML(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(SL).selectOnOpen?0:-1;if(i&&i.selected!=c&&i.selected!=-1){let e=i.options[i.selected].completion;for(let t=0;t<s.length;t++)if(s[t].completion==e){c=t;break}}return new e(s,RL(r,c),{pos:t.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:qL,above:a.aboveCursor},i?i.timestamp:Date.now(),c,!1)}map(t){return new e(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new e(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},PL=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e(zL,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(SL),i=(r.override||n.languageDataAt(`autocomplete`,fL(n)).map(_L)).map(e=>(this.active.find(t=>t.source==e)||new VL(e,+!!this.active.some(e=>e.state!=0))).update(t,r));i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let a=this.open,o=t.effects.some(e=>e.is(WL));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!FL(i,this.active)||o?a=NL.build(i,n,this.id,a,r,o):a&&a.disabled&&!i.some(e=>e.isPending)&&(a=null),!a&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new VL(e.source,0):e));for(let e of t.effects)e.is(TL)&&(a&&=a.setSelected(e.value,this.id));return i==this.active&&a==this.open?this:new e(i,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?IL:LL}};function FL(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}var IL={"aria-autocomplete":`list`},LL={};function RL(e,t){let n={"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-controls":e};return t>-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var zL=[];function BL(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(mL);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent(`input.type`);return n&&t.activateOnTyping?5:n?1:e.isUserEvent(`delete.backward`)?2:e.selection?8:e.docChanged?16:0}var VL=class e{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=BL(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new e(i.source,0)),r&4&&i.state==0&&(i=new e(this.source,1)),i=i.updateFor(t,r);for(let n of t.effects)if(n.is(vL))i=new e(i.source,1,n.value);else if(n.is(yL))i=new e(i.source,0);else if(n.is(WL))for(let e of n.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(fL(e.state))}},HL=class e extends VL{constructor(e,t,n,r,i,a){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=a}hasResult(){return!0}updateFor(t,n){if(!(n&3))return this.map(t.changes);let r=this.result;r.map&&!t.changes.empty&&(r=r.map(r,t.changes));let i=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=fL(t.state);if(o>a||!r||n&2&&(fL(t.startState)==this.from||o<this.limit))return new VL(this.source,n&4?1:0);let s=t.changes.mapPos(this.limit);return UL(r.validFor,t.state,i,a)?new e(this.source,this.explicit,s,r,i,a):r.update&&(r=r.update(r,i,a,new oL(t.state,o,!1)))?new e(this.source,this.explicit,s,r,r.from,r.to??fL(t.state)):new VL(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new e(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new VL(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function UL(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e==`function`?e(i,n,r,t):pL(e,!0).test(i)}var WL=$x.define({map(e,t){return e.map(e=>e.map(t))}}),GL=Mx.define({create(){return PL.start()},update(e,t){return e.update(t)},provide:e=>[YO.from(e,e=>e.tooltip),Y.contentAttributes.from(e,e=>e.attrs)]});function KL(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(GL).active.find(e=>e.source==t.source);return r instanceof HL?(typeof n==`string`?e.dispatch({...hL(e.state,n,r.from,r.to),annotations:mL.of(t.completion)}):n(e,t.completion,r.from,r.to),!0):!1}var qL=kL(GL,KL);function JL(e,t=`option`){return n=>{let r=n.state.field(GL,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(SL).interactionDelay)return!1;let i=1,a;t==`page`&&(a=XO(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector(`li`).offsetHeight)-1));let{length:o}=r.open.options,s=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:o-1;return s<0?s=t==`page`?0:o-1:s>=o&&(s=t==`page`?o-1:0),n.dispatch({effects:TL.of(s)}),!0}}var YL=e=>{let t=e.state.field(GL,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(SL).interactionDelay?!1:KL(e,t.open.options[t.open.selected])},XL=e=>e.state.field(GL,!1)?(e.dispatch({effects:vL.of(!0)}),!0):!1,ZL=e=>{let t=e.state.field(GL,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:yL.of(null)}),!0)},QL=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},$L=50,eR=1e3,tR=Rw.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(GL).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(GL),n=e.state.facet(SL);if(!e.selectionSet&&!e.docChanged&&e.startState.field(GL)==t)return;let r=e.transactions.some(e=>{let t=BL(e,n);return t&8||(e.selection||e.docChanged)&&!(t&3)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(r||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>$L&&Date.now()-n.time>eR){for(let e of n.context.abortListeners)try{e()}catch(e){Pw(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(vL)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let t of e.transactions)t.isUserEvent(`input.type`)?this.composing=2:this.composing==2&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(GL);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(SL).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=new oL(t,fL(t),e.explicit,this.view),r=new QL(e,n);this.running.push(r),Promise.resolve(e.source(n)).then(e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:yL.of(null)}),Pw(this.view.state,e)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(SL).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(SL),n=this.view.state.field(GL);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(i.done===void 0)continue;if(this.running.splice(r--,1),i.done){let n=fL(i.updates.length?i.updates[0].startState:this.view.state),r=Math.min(n,i.done.from+ +!i.active.explicit),a=new HL(i.active.source,i.active.explicit,r,i.done,i.done.from,i.done.to??n);for(let e of i.updates)a=a.update(e,t);if(a.hasResult()){e.push(a);continue}}let a=n.active.find(e=>e.source==i.active.source);if(a&&a.isPending)if(i.done==null){let n=new VL(i.active.source,0);for(let e of i.updates)n=n.update(e,t);n.isPending||e.push(n)}else this.startQuery(a)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:WL.of(e)})}},{eventHandlers:{blur(e){let t=this.view.state.field(GL,!1);if(t&&t.tooltip&&this.view.state.facet(SL).closeOnBlur){let n=t.open&&XO(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:yL.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:vL.of(!1)}),20),this.composing=0}}}),nR=typeof navigator==`object`&&/Win/.test(navigator.platform),rR=Fx.highest(Y.domEventHandlers({keydown(e,t){let n=t.state.field(GL,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(nR&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&KL(t,r),!1}})),iR=Y.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:`monospace`,whiteSpace:`nowrap`,overflow:`hidden auto`,maxWidth_fallback:`700px`,maxWidth:`min(700px, 95vw)`,minWidth:`250px`,maxHeight:`10em`,height:`100%`,listStyle:`none`,margin:0,padding:0,"& > li, & > completion-section":{padding:`1px 3px`,lineHeight:1.2},"& > li":{overflowX:`hidden`,textOverflow:`ellipsis`,cursor:`pointer`},"& > completion-section":{display:`list-item`,borderBottom:`1px solid silver`,paddingLeft:`0.5em`,opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#17c`,color:`white`},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#777`},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#347`,color:`white`},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#444`},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:`"···"`,opacity:.5,display:`block`,textAlign:`center`,cursor:`pointer`},".cm-tooltip.cm-completionInfo":{position:`absolute`,padding:`3px 9px`,width:`max-content`,maxWidth:`400px`,boxSizing:`border-box`,whiteSpace:`pre-line`},".cm-completionInfo.cm-completionInfo-left":{right:`100%`},".cm-completionInfo.cm-completionInfo-right":{left:`100%`},".cm-completionInfo.cm-completionInfo-left-narrow":{right:`30px`},".cm-completionInfo.cm-completionInfo-right-narrow":{left:`30px`},"&light .cm-snippetField":{backgroundColor:`#00000022`},"&dark .cm-snippetField":{backgroundColor:`#ffffff22`},".cm-snippetFieldPosition":{verticalAlign:`text-top`,width:0,height:`1.15em`,display:`inline-block`,margin:`0 -0.7px -.7em`,borderLeft:`1.4px dotted #888`},".cm-completionMatchedText":{textDecoration:`underline`},".cm-completionDetail":{marginLeft:`0.5em`,fontStyle:`italic`},".cm-completionIcon":{fontSize:`90%`,width:`.8em`,display:`inline-block`,textAlign:`center`,paddingRight:`.6em`,opacity:`0.6`,boxSizing:`content-box`},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:`'ƒ'`}},".cm-completionIcon-class":{"&:after":{content:`'○'`}},".cm-completionIcon-interface":{"&:after":{content:`'◌'`}},".cm-completionIcon-variable":{"&:after":{content:`'𝑥'`}},".cm-completionIcon-constant":{"&:after":{content:`'𝐶'`}},".cm-completionIcon-type":{"&:after":{content:`'𝑡'`}},".cm-completionIcon-enum":{"&:after":{content:`'∪'`}},".cm-completionIcon-property":{"&:after":{content:`'□'`}},".cm-completionIcon-keyword":{"&:after":{content:`'🔑︎'`}},".cm-completionIcon-namespace":{"&:after":{content:`'▢'`}},".cm-completionIcon-text":{"&:after":{content:`'abc'`,fontSize:`50%`,verticalAlign:`middle`}}}),aR=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},oR=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(t){let n=t.mapPos(this.from,-1,mx.TrackDel),r=t.mapPos(this.to,1,mx.TrackDel);return n==null||r==null?null:new e(this.field,n,r)}},sR=class e{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],r=[t],i=e.doc.lineAt(t),a=/^\s*/.exec(i.text)[0];for(let i of this.lines){if(n.length){let n=a,o=/^\t*/.exec(i)[0].length;for(let t=0;t<o;t++)n+=e.facet(xj);r.push(t+n.length-o),i=n+i.slice(o)}n.push(i),t+=i.length+1}return{text:n,ranges:this.fieldPositions.map(e=>new oR(e.field,r[e.line]+e.from,r[e.line]+e.to))}}static parse(t){let n=[],r=[],i=[],a;for(let e of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(e);){let t=a[1]?+a[1]:null,o=a[2]||a[3]||``,s=-1,c=o.replace(/\\[{}]/g,e=>e[1]);for(let e=0;e<n.length;e++)(t==null?c&&n[e].name==c:n[e].seq==t)&&(s=e);if(s<0){let e=0;for(;e<n.length&&(t==null||n[e].seq!=null&&n[e].seq<t);)e++;n.splice(e,0,{seq:t,name:c}),s=e;for(let e of i)e.field>=s&&e.field++}for(let e of i)if(e.line==r.length&&e.from>a.index){let t=a[2]?3+(a[1]||``).length:2;e.from-=t,e.to-=t}i.push(new aR(s,r.length,a.index,a.index+c.length)),e=e.slice(0,a.index)+o+e.slice(a.index+a[0].length)}e=e.replace(/\\([{}])/g,(e,t,n)=>{for(let e of i)e.line==r.length&&e.from>n&&(e.from--,e.to--);return t}),r.push(e)}return new e(r,i)}},cR=J.widget({widget:new class extends hC{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),lR=J.mark({class:`cm-snippetField`}),uR=class e{constructor(e,t){this.ranges=e,this.active=t,this.deco=J.set(e.map(e=>(e.from==e.to?cR:lR).range(e.from,e.to)),!0)}map(t){let n=[];for(let e of this.ranges){let r=e.map(t);if(!r)return null;n.push(r)}return new e(n,this.active)}selectionInsideField(e){return e.ranges.every(e=>this.ranges.some(t=>t.field==this.active&&t.from<=e.from&&t.to>=e.to))}},dR=$x.define({map(e,t){return e&&e.map(t)}}),fR=$x.define(),pR=Mx.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(dR))return n.value;if(n.is(fR)&&e)return new uR(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>Y.decorations.from(e,e=>e?e.deco:J.none)});function mR(e,t){return G.create(e.filter(e=>e.field==t).map(e=>G.range(e.from,e.to)))}function hR(e){let t=sR.parse(e);return(e,n,r,i)=>{let{text:a,ranges:o}=t.instantiate(e.state,r),{main:s}=e.state.selection,c={changes:{from:r,to:i==s.from?s.to:i,insert:Xb.of(a)},scrollIntoView:!0,annotations:n?[mL.of(n),eS.userEvent.of(`input.complete`)]:void 0};if(o.length&&(c.selection=mR(o,0)),o.some(e=>e.field>0)){let t=new uR(o,0),n=c.effects=[dR.of(t)];e.state.field(pR,!1)===void 0&&n.push($x.appendConfig.of([pR,yR,xR,iR]))}e.dispatch(e.state.update(c))}}function gR(e){return({state:t,dispatch:n})=>{let r=t.field(pR,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(t=>t.field==i+e);return n(t.update({selection:mR(r.ranges,i),effects:dR.of(a?null:new uR(r.ranges,i)),scrollIntoView:!0})),!0}}var _R=[{key:`Tab`,run:gR(1),shift:gR(-1)},{key:`Escape`,run:({state:e,dispatch:t})=>e.field(pR,!1)?(t(e.update({effects:dR.of(null)})),!0):!1}],vR=K.define({combine(e){return e.length?e[0]:_R}}),yR=Fx.highest(eO.compute([vR],e=>e.facet(vR)));function bR(e,t){return{...t,apply:hR(e)}}var xR=Y.domEventHandlers({mousedown(e,t){let n=t.state.field(pR,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(e=>e.from<=r&&e.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:mR(n.ranges,i.field),effects:dR.of(n.ranges.some(e=>e.field>i.field)?new uR(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),SR={brackets:[`(`,`[`,`{`,`'`,`"`],before:`)]}:;>`,stringPrefixes:[]},CR=$x.define({map(e,t){return t.mapPos(e,-1,mx.TrackAfter)??void 0}}),wR=new class extends gS{};wR.startSide=1,wR.endSide=-1;var TR=Mx.define({create(){return xS.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(CR)&&(e=e.update({add:[wR.range(n.value,n.value+1)]}));return e}});function ER(){return[jR,TR]}var DR=`()[]{}<>«»»«[]{}`;function OR(e){for(let t=0;t<16;t+=2)if(DR.charCodeAt(t)==e)return DR.charAt(t+1);return dx(e<128?e:e+1)}function kR(e,t){return e.languageDataAt(`closeBrackets`,t)[0]||SR}var AR=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),jR=Y.inputHandler.of((e,t,n,r)=>{if((AR?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&fx(ux(r,0))==1||t!=i.from||n!=i.to)return!1;let a=NR(e.state,r);return a?(e.dispatch(a),!0):!1}),MR=[{key:`Backspace`,run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=kR(e,e.selection.main.head).brackets||SR.brackets,r=null,i=e.changeByRange(t=>{if(t.empty){let r=IR(e.doc,t.head);for(let i of n)if(i==r&&FR(e.doc,t.head)==OR(ux(i,0)))return{changes:{from:t.head-i.length,to:t.head+i.length},range:G.cursor(t.head-i.length)}}return{range:r=t}});return r||t(e.update(i,{scrollIntoView:!0,userEvent:`delete.backward`})),!r}}];function NR(e,t){let n=kR(e,e.selection.main.head),r=n.brackets||SR.brackets;for(let i of r){let a=OR(ux(i,0));if(t==i)return a==i?zR(e,i,r.indexOf(i+i+i)>-1,n):LR(e,i,a,n.before||SR.before);if(t==a&&PR(e,e.selection.main.from))return RR(e,i,a)}return null}function PR(e,t){let n=!1;return e.field(TR).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function FR(e,t){let n=e.sliceString(t,t+2);return n.slice(0,fx(ux(n,0)))}function IR(e,t){let n=e.sliceString(t-2,t);return fx(ux(n,0))==n.length?n:n.slice(1)}function LR(e,t,n,r){let i=null,a=e.changeByRange(a=>{if(!a.empty)return{changes:[{insert:t,from:a.from},{insert:n,from:a.to}],effects:CR.of(a.to+t.length),range:G.range(a.anchor+t.length,a.head+t.length)};let o=FR(e.doc,a.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:CR.of(a.head+t.length),range:G.cursor(a.head+t.length)}:{range:i=a}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:`input.type`})}function RR(e,t,n){let r=null,i=e.changeByRange(t=>t.empty&&FR(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:G.cursor(t.head+n.length)}:r={range:t});return r?null:e.update(i,{scrollIntoView:!0,userEvent:`input.type`})}function zR(e,t,n,r){let i=r.stringPrefixes||SR.stringPrefixes,a=null,o=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:CR.of(r.to+t.length),range:G.range(r.anchor+t.length,r.head+t.length)};let o=r.head,s=FR(e.doc,o),c;if(s==t){if(BR(e,o))return{changes:{insert:t+t,from:o},effects:CR.of(o+t.length),range:G.cursor(o+t.length)};if(PR(e,o)){let r=n&&e.sliceDoc(o,o+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:o,to:o+r.length,insert:r},range:G.cursor(o+r.length)}}}else if(n&&e.sliceDoc(o-2*t.length,o)==t+t&&(c=HR(e,o-2*t.length,i))>-1&&BR(e,c))return{changes:{insert:t+t+t+t,from:o},effects:CR.of(o+t.length),range:G.cursor(o+t.length)};else if(e.charCategorizer(o)(s)!=lS.Word&&HR(e,o,i)>-1&&!VR(e,o,t,i))return{changes:{insert:t+t,from:o},effects:CR.of(o+t.length),range:G.cursor(o+t.length)};return{range:a=r}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:`input.type`})}function BR(e,t){let n=lj(e).resolveInner(t+1);return n.parent&&n.from==t}function VR(e,t,n,r){let i=lj(e).resolveInner(t,-1),a=r.reduce((e,t)=>Math.max(e,t.length),0);for(let o=0;o<5;o++){let o=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+a)),s=o.indexOf(n);if(!s||s>-1&&r.indexOf(o.slice(0,s))>-1){let t=i.firstChild;for(;t&&t.from==i.from&&t.to-t.from>n.length+s;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let c=i.to==t&&i.parent;if(!c)break;i=c}return!1}function HR(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=lS.Word)return t;for(let i of n){let n=t-i.length;if(e.sliceDoc(n,t)==i&&r(e.sliceDoc(n-1,n))!=lS.Word)return n}return-1}function UR(e={}){return[rR,GL,SL.of(e),tR,GR,iR]}var WR=[{key:`Ctrl-Space`,run:XL},{mac:"Alt-`",run:XL},{mac:`Alt-i`,run:XL},{key:`Escape`,run:ZL},{key:`ArrowDown`,run:JL(!0)},{key:`ArrowUp`,run:JL(!1)},{key:`PageDown`,run:JL(!0,`page`)},{key:`PageUp`,run:JL(!1,`page`)},{key:`Enter`,run:YL}],GR=Fx.highest(eO.computeN([SL],e=>e.facet(SL).defaultKeymap?[WR]:[]));function $(e){return new yj(GM.define(e))}function KR(e){return W(()=>import(`./dist-CXnbkk51.js`).then(t=>t.sql({dialect:t[e]})),__vite__mapDeps([7,8]),import.meta.url)}var qR=[Q.of({name:`C`,extensions:[`c`,`h`,`ino`],load(){return W(()=>import(`./dist-6WsdpRSO.js`).then(e=>e.cpp()),__vite__mapDeps([9,8]),import.meta.url)}}),Q.of({name:`C++`,alias:[`cpp`],extensions:[`cpp`,`c++`,`cc`,`cxx`,`hpp`,`h++`,`hh`,`hxx`],load(){return W(()=>import(`./dist-6WsdpRSO.js`).then(e=>e.cpp()),__vite__mapDeps([9,8]),import.meta.url)}}),Q.of({name:`CQL`,alias:[`cassandra`],extensions:[`cql`],load(){return KR(`Cassandra`)}}),Q.of({name:`CSS`,extensions:[`css`],load(){return W(()=>import(`./dist-DqLb8QP7.js`).then(e=>e.i).then(e=>e.css()),__vite__mapDeps([10,8]),import.meta.url)}}),Q.of({name:`Go`,extensions:[`go`],load(){return W(()=>import(`./dist-JOlStfdO.js`).then(e=>e.go()),__vite__mapDeps([11,8]),import.meta.url)}}),Q.of({name:`HTML`,alias:[`xhtml`],extensions:[`html`,`htm`,`handlebars`,`hbs`],load(){return W(()=>import(`./dist-DxJZpRF1.js`).then(e=>e.html()),__vite__mapDeps([12,10,8,13]),import.meta.url)}}),Q.of({name:`Java`,extensions:[`java`],load(){return W(()=>import(`./dist-DGm-pByN.js`).then(e=>e.java()),__vite__mapDeps([14,8]),import.meta.url)}}),Q.of({name:`JavaScript`,alias:[`ecmascript`,`js`,`node`],extensions:[`js`,`mjs`,`cjs`],load(){return W(()=>import(`./dist-Cxij5I4C.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`Jinja`,extensions:[`j2`,`jinja`,`jinja2`],load(){return W(()=>import(`./dist-z5-DHNYg.js`).then(e=>e.jinja()),__vite__mapDeps([15,12,10,8,13]),import.meta.url)}}),Q.of({name:`JSON`,alias:[`json5`],extensions:[`json`,`map`],load(){return W(()=>import(`./dist-C4IRfjf3.js`).then(e=>e.json()),__vite__mapDeps([16,8]),import.meta.url)}}),Q.of({name:`JSX`,extensions:[`jsx`],load(){return W(()=>import(`./dist-Cxij5I4C.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`LESS`,extensions:[`less`],load(){return W(()=>import(`./dist-CJmvMGxs.js`).then(e=>e.less()),__vite__mapDeps([17,10,8]),import.meta.url)}}),Q.of({name:`Liquid`,extensions:[`liquid`],load(){return W(()=>import(`./dist-aq2knWnw.js`).then(e=>e.liquid()),__vite__mapDeps([18,12,10,8,13]),import.meta.url)}}),Q.of({name:`MariaDB SQL`,load(){return KR(`MariaSQL`)}}),Q.of({name:`Markdown`,extensions:[`md`,`markdown`,`mkd`],load(){return W(()=>import(`./dist-BOHSAqwD.js`).then(e=>e.markdown()),__vite__mapDeps([19,12,10,8,13]),import.meta.url)}}),Q.of({name:`MS SQL`,load(){return KR(`MSSQL`)}}),Q.of({name:`MySQL`,load(){return KR(`MySQL`)}}),Q.of({name:`PHP`,extensions:[`php`,`php3`,`php4`,`php5`,`php7`,`phtml`],load(){return W(()=>import(`./dist-DelwQd2b.js`).then(e=>e.php()),__vite__mapDeps([20,12,10,8,13]),import.meta.url)}}),Q.of({name:`PLSQL`,extensions:[`pls`],load(){return KR(`PLSQL`)}}),Q.of({name:`PostgreSQL`,load(){return KR(`PostgreSQL`)}}),Q.of({name:`Python`,extensions:[`BUILD`,`bzl`,`py`,`pyw`],filename:/^(BUCK|BUILD)$/,load(){return W(()=>import(`./dist-O8eCswTX.js`).then(e=>e.python()),__vite__mapDeps([21,8]),import.meta.url)}}),Q.of({name:`Rust`,extensions:[`rs`],load(){return W(()=>import(`./dist-BEmeO2N2.js`).then(e=>e.rust()),__vite__mapDeps([22,8]),import.meta.url)}}),Q.of({name:`Sass`,extensions:[`sass`],load(){return W(()=>import(`./dist-CTCQXcX7.js`).then(e=>e.sass({indented:!0})),__vite__mapDeps([23,10,8]),import.meta.url)}}),Q.of({name:`SCSS`,extensions:[`scss`],load(){return W(()=>import(`./dist-CTCQXcX7.js`).then(e=>e.sass()),__vite__mapDeps([23,10,8]),import.meta.url)}}),Q.of({name:`SQL`,extensions:[`sql`],load(){return KR(`StandardSQL`)}}),Q.of({name:`SQLite`,load(){return KR(`SQLite`)}}),Q.of({name:`TSX`,extensions:[`tsx`],load(){return W(()=>import(`./dist-Cxij5I4C.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0,typescript:!0})),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`TypeScript`,alias:[`ts`],extensions:[`ts`,`mts`,`cts`],load(){return W(()=>import(`./dist-Cxij5I4C.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`WebAssembly`,extensions:[`wat`,`wast`],load(){return W(()=>import(`./dist-CqCrM4le.js`).then(e=>e.wast()),__vite__mapDeps([24,8]),import.meta.url)}}),Q.of({name:`XML`,alias:[`rss`,`wsdl`,`xsd`],extensions:[`xml`,`xsl`,`xsd`,`svg`],load(){return W(()=>import(`./dist-Cqzpy7oO.js`).then(e=>e.xml()),__vite__mapDeps([25,8]),import.meta.url)}}),Q.of({name:`YAML`,alias:[`yml`],extensions:[`yaml`,`yml`],load(){return W(()=>import(`./dist-BWf6mC8G.js`).then(e=>e.yaml()),__vite__mapDeps([26,8]),import.meta.url)}}),Q.of({name:`APL`,extensions:[`dyalog`,`apl`],load(){return W(()=>import(`./apl-CnwPGSsG.js`).then(e=>$(e.apl)),[],import.meta.url)}}),Q.of({name:`PGP`,alias:[`asciiarmor`],extensions:[`asc`,`pgp`,`sig`],load(){return W(()=>import(`./asciiarmor-qTkVPQu6.js`).then(e=>$(e.asciiArmor)),[],import.meta.url)}}),Q.of({name:`ASN.1`,extensions:[`asn`,`asn1`],load(){return W(()=>import(`./asn1-Dr8qZg38.js`).then(e=>$(e.asn1({}))),[],import.meta.url)}}),Q.of({name:`Asterisk`,filename:/^extensions\.conf$/i,load(){return W(()=>import(`./asterisk-Bja0s6e1.js`).then(e=>$(e.asterisk)),[],import.meta.url)}}),Q.of({name:`Brainfuck`,extensions:[`b`,`bf`],load(){return W(()=>import(`./brainfuck-D5EjA2JK.js`).then(e=>$(e.brainfuck)),[],import.meta.url)}}),Q.of({name:`Cobol`,extensions:[`cob`,`cpy`],load(){return W(()=>import(`./cobol-B_OZ4V-R.js`).then(e=>$(e.cobol)),[],import.meta.url)}}),Q.of({name:`C#`,alias:[`csharp`,`cs`],extensions:[`cs`],load(){return W(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.csharp)),[],import.meta.url)}}),Q.of({name:`Clojure`,extensions:[`clj`,`cljc`,`cljx`],load(){return W(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`ClojureScript`,extensions:[`cljs`],load(){return W(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`Closure Stylesheets (GSS)`,extensions:[`gss`],load(){return W(()=>import(`./css-CYpP4FRV.js`).then(e=>$(e.gss)),[],import.meta.url)}}),Q.of({name:`CMake`,extensions:[`cmake`,`cmake.in`],filename:/^CMakeLists\.txt$/,load(){return W(()=>import(`./cmake-CyVbuzPu.js`).then(e=>$(e.cmake)),[],import.meta.url)}}),Q.of({name:`CoffeeScript`,alias:[`coffee`,`coffee-script`],extensions:[`coffee`],load(){return W(()=>import(`./coffeescript-B2pKbFk8.js`).then(e=>$(e.coffeeScript)),[],import.meta.url)}}),Q.of({name:`Common Lisp`,alias:[`lisp`],extensions:[`cl`,`lisp`,`el`],load(){return W(()=>import(`./commonlisp-CcllspGY.js`).then(e=>$(e.commonLisp)),[],import.meta.url)}}),Q.of({name:`Cypher`,extensions:[`cyp`,`cypher`],load(){return W(()=>import(`./cypher-p9eYesGn.js`).then(e=>$(e.cypher)),[],import.meta.url)}}),Q.of({name:`Cython`,extensions:[`pyx`,`pxd`,`pxi`],load(){return W(()=>import(`./python-BqYw9LYJ.js`).then(e=>$(e.cython)),[],import.meta.url)}}),Q.of({name:`Crystal`,extensions:[`cr`],load(){return W(()=>import(`./crystal-M5-qzICs.js`).then(e=>$(e.crystal)),[],import.meta.url)}}),Q.of({name:`D`,extensions:[`d`],load(){return W(()=>import(`./d-BhMjBjQP.js`).then(e=>$(e.d)),[],import.meta.url)}}),Q.of({name:`Dart`,extensions:[`dart`],load(){return W(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.dart)),[],import.meta.url)}}),Q.of({name:`diff`,extensions:[`diff`,`patch`],load(){return W(()=>import(`./diff-ChtP43wD.js`).then(e=>$(e.diff)),[],import.meta.url)}}),Q.of({name:`Dockerfile`,filename:/^Dockerfile$/,load(){return W(()=>import(`./dockerfile-BLkNEvjs.js`).then(e=>$(e.dockerFile)),__vite__mapDeps([27,28]),import.meta.url)}}),Q.of({name:`DTD`,extensions:[`dtd`],load(){return W(()=>import(`./dtd-DTF72YNO.js`).then(e=>$(e.dtd)),[],import.meta.url)}}),Q.of({name:`Dylan`,extensions:[`dylan`,`dyl`,`intr`],load(){return W(()=>import(`./dylan-C6jEEEk-.js`).then(e=>$(e.dylan)),[],import.meta.url)}}),Q.of({name:`EBNF`,load(){return W(()=>import(`./ebnf-D4c0_ac3.js`).then(e=>$(e.ebnf)),[],import.meta.url)}}),Q.of({name:`ECL`,extensions:[`ecl`],load(){return W(()=>import(`./ecl-BSZaIHnp.js`).then(e=>$(e.ecl)),[],import.meta.url)}}),Q.of({name:`edn`,extensions:[`edn`],load(){return W(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`Eiffel`,extensions:[`e`],load(){return W(()=>import(`./eiffel-BEjRio4Q.js`).then(e=>$(e.eiffel)),[],import.meta.url)}}),Q.of({name:`Elm`,extensions:[`elm`],load(){return W(()=>import(`./elm-Cshzl8qu.js`).then(e=>$(e.elm)),[],import.meta.url)}}),Q.of({name:`Erlang`,extensions:[`erl`],load(){return W(()=>import(`./erlang-DaB2Rkuy.js`).then(e=>$(e.erlang)),[],import.meta.url)}}),Q.of({name:`Esper`,load(){return W(()=>import(`./sql-DcCJ9jop.js`).then(e=>$(e.esper)),[],import.meta.url)}}),Q.of({name:`Factor`,extensions:[`factor`],load(){return W(()=>import(`./factor-D7LVTn2l.js`).then(e=>$(e.factor)),__vite__mapDeps([29,28]),import.meta.url)}}),Q.of({name:`FCL`,load(){return W(()=>import(`./fcl-ClOhbFR7.js`).then(e=>$(e.fcl)),[],import.meta.url)}}),Q.of({name:`Forth`,extensions:[`forth`,`fth`,`4th`],load(){return W(()=>import(`./forth-Cezjo90N.js`).then(e=>$(e.forth)),[],import.meta.url)}}),Q.of({name:`Fortran`,extensions:[`f`,`for`,`f77`,`f90`,`f95`],load(){return W(()=>import(`./fortran-Bt6PBEDR.js`).then(e=>$(e.fortran)),[],import.meta.url)}}),Q.of({name:`F#`,alias:[`fsharp`],extensions:[`fs`],load(){return W(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.fSharp)),[],import.meta.url)}}),Q.of({name:`Gas`,extensions:[`s`],load(){return W(()=>import(`./gas-BHEdbvp9.js`).then(e=>$(e.gas)),[],import.meta.url)}}),Q.of({name:`Gherkin`,extensions:[`feature`],load(){return W(()=>import(`./gherkin-oBAE_ms0.js`).then(e=>$(e.gherkin)),[],import.meta.url)}}),Q.of({name:`Groovy`,extensions:[`groovy`,`gradle`],filename:/^Jenkinsfile$/,load(){return W(()=>import(`./groovy-BC3IOsC8.js`).then(e=>$(e.groovy)),[],import.meta.url)}}),Q.of({name:`Haskell`,extensions:[`hs`],load(){return W(()=>import(`./haskell-BRsoo5mP.js`).then(e=>$(e.haskell)),[],import.meta.url)}}),Q.of({name:`Haxe`,extensions:[`hx`],load(){return W(()=>import(`./haxe-DIz0ZZqd.js`).then(e=>$(e.haxe)),[],import.meta.url)}}),Q.of({name:`HXML`,extensions:[`hxml`],load(){return W(()=>import(`./haxe-DIz0ZZqd.js`).then(e=>$(e.hxml)),[],import.meta.url)}}),Q.of({name:`HTTP`,load(){return W(()=>import(`./http-CLVgA2GD.js`).then(e=>$(e.http)),[],import.meta.url)}}),Q.of({name:`IDL`,extensions:[`pro`],load(){return W(()=>import(`./idl-BUZw3wgd.js`).then(e=>$(e.idl)),[],import.meta.url)}}),Q.of({name:`JSON-LD`,alias:[`jsonld`],extensions:[`jsonld`],load(){return W(()=>import(`./javascript-9Tg8ixDm.js`).then(e=>$(e.jsonld)),[],import.meta.url)}}),Q.of({name:`Julia`,extensions:[`jl`],load(){return W(()=>import(`./julia-CQfgDRfP.js`).then(e=>$(e.julia)),[],import.meta.url)}}),Q.of({name:`Kotlin`,extensions:[`kt`,`kts`],load(){return W(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.kotlin)),[],import.meta.url)}}),Q.of({name:`LiveScript`,alias:[`ls`],extensions:[`ls`],load(){return W(()=>import(`./livescript-BXxG0Yva.js`).then(e=>$(e.liveScript)),[],import.meta.url)}}),Q.of({name:`Lua`,extensions:[`lua`],load(){return W(()=>import(`./lua-CiA1ziua.js`).then(e=>$(e.lua)),[],import.meta.url)}}),Q.of({name:`mIRC`,extensions:[`mrc`],load(){return W(()=>import(`./mirc-C9zpzAZU.js`).then(e=>$(e.mirc)),[],import.meta.url)}}),Q.of({name:`Mathematica`,extensions:[`m`,`nb`,`wl`,`wls`],load(){return W(()=>import(`./mathematica-u8YMmbU0.js`).then(e=>$(e.mathematica)),[],import.meta.url)}}),Q.of({name:`Modelica`,extensions:[`mo`],load(){return W(()=>import(`./modelica-CqHI_q-D.js`).then(e=>$(e.modelica)),[],import.meta.url)}}),Q.of({name:`MUMPS`,extensions:[`mps`],load(){return W(()=>import(`./mumps-CW_TBmxz.js`).then(e=>$(e.mumps)),[],import.meta.url)}}),Q.of({name:`Mbox`,extensions:[`mbox`],load(){return W(()=>import(`./mbox-BEMVcqjs.js`).then(e=>$(e.mbox)),[],import.meta.url)}}),Q.of({name:`Nginx`,filename:/nginx.*\.conf$/i,load(){return W(()=>import(`./nginx-BMaDbqW3.js`).then(e=>$(e.nginx)),[],import.meta.url)}}),Q.of({name:`NSIS`,extensions:[`nsh`,`nsi`],load(){return W(()=>import(`./nsis-AQ_alPln.js`).then(e=>$(e.nsis)),__vite__mapDeps([30,28]),import.meta.url)}}),Q.of({name:`NTriples`,extensions:[`nt`,`nq`],load(){return W(()=>import(`./ntriples-d28e9m0E.js`).then(e=>$(e.ntriples)),[],import.meta.url)}}),Q.of({name:`Objective-C`,alias:[`objective-c`,`objc`],extensions:[`m`],load(){return W(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.objectiveC)),[],import.meta.url)}}),Q.of({name:`Objective-C++`,alias:[`objective-c++`,`objc++`],extensions:[`mm`],load(){return W(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.objectiveCpp)),[],import.meta.url)}}),Q.of({name:`OCaml`,extensions:[`ml`,`mli`,`mll`,`mly`],load(){return W(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.oCaml)),[],import.meta.url)}}),Q.of({name:`Octave`,extensions:[`m`],load(){return W(()=>import(`./octave-D2Q8cUp1.js`).then(e=>$(e.octave)),[],import.meta.url)}}),Q.of({name:`Oz`,extensions:[`oz`],load(){return W(()=>import(`./oz-BwTct_5T.js`).then(e=>$(e.oz)),[],import.meta.url)}}),Q.of({name:`Pascal`,extensions:[`p`,`pas`],load(){return W(()=>import(`./pascal-Dp_KdFgX.js`).then(e=>$(e.pascal)),[],import.meta.url)}}),Q.of({name:`Perl`,extensions:[`pl`,`pm`],load(){return W(()=>import(`./perl-CdEHsPfU.js`).then(e=>$(e.perl)),[],import.meta.url)}}),Q.of({name:`Pig`,extensions:[`pig`],load(){return W(()=>import(`./pig-AF4Hwhju.js`).then(e=>$(e.pig)),[],import.meta.url)}}),Q.of({name:`PowerShell`,extensions:[`ps1`,`psd1`,`psm1`],load(){return W(()=>import(`./powershell-CzG71I4L.js`).then(e=>$(e.powerShell)),[],import.meta.url)}}),Q.of({name:`Properties files`,alias:[`ini`,`properties`],extensions:[`properties`,`ini`,`in`],load(){return W(()=>import(`./properties-C357ku5U.js`).then(e=>$(e.properties)),[],import.meta.url)}}),Q.of({name:`ProtoBuf`,extensions:[`proto`],load(){return W(()=>import(`./protobuf-D1ij_kNL.js`).then(e=>$(e.protobuf)),[],import.meta.url)}}),Q.of({name:`Pug`,alias:[`jade`],extensions:[`pug`,`jade`],load(){return W(()=>import(`./pug-Bugr-47h.js`).then(e=>$(e.pug)),__vite__mapDeps([31,32]),import.meta.url)}}),Q.of({name:`Puppet`,extensions:[`pp`],load(){return W(()=>import(`./puppet-B4hC2X4m.js`).then(e=>$(e.puppet)),[],import.meta.url)}}),Q.of({name:`Q`,extensions:[`q`],load(){return W(()=>import(`./q-B9NhS7L_.js`).then(e=>$(e.q)),[],import.meta.url)}}),Q.of({name:`R`,alias:[`rscript`],extensions:[`r`,`R`],load(){return W(()=>import(`./r-DADKenSm.js`).then(e=>$(e.r)),[],import.meta.url)}}),Q.of({name:`RPM Changes`,load(){return W(()=>import(`./rpm-gpDK5sbt.js`).then(e=>$(e.rpmChanges)),[],import.meta.url)}}),Q.of({name:`RPM Spec`,extensions:[`spec`],load(){return W(()=>import(`./rpm-gpDK5sbt.js`).then(e=>$(e.rpmSpec)),[],import.meta.url)}}),Q.of({name:`Ruby`,alias:[`jruby`,`macruby`,`rake`,`rb`,`rbx`],extensions:[`rb`],filename:/^(Gemfile|Rakefile)$/,load(){return W(()=>import(`./ruby-DsYpTuWg.js`).then(e=>$(e.ruby)),[],import.meta.url)}}),Q.of({name:`SAS`,extensions:[`sas`],load(){return W(()=>import(`./sas-C2OyD2Y6.js`).then(e=>$(e.sas)),[],import.meta.url)}}),Q.of({name:`Scala`,extensions:[`scala`],load(){return W(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.scala)),[],import.meta.url)}}),Q.of({name:`Scheme`,extensions:[`scm`,`ss`],load(){return W(()=>import(`./scheme-CyDdOh7e.js`).then(e=>$(e.scheme)),[],import.meta.url)}}),Q.of({name:`Shell`,alias:[`bash`,`sh`,`zsh`],extensions:[`sh`,`ksh`,`bash`],filename:/^PKGBUILD$/,load(){return W(()=>import(`./shell-Du5Qg9im.js`).then(e=>$(e.shell)),[],import.meta.url)}}),Q.of({name:`Sieve`,extensions:[`siv`,`sieve`],load(){return W(()=>import(`./sieve-BAxa3IjF.js`).then(e=>$(e.sieve)),[],import.meta.url)}}),Q.of({name:`Smalltalk`,extensions:[`st`],load(){return W(()=>import(`./smalltalk-BLp5-jwC.js`).then(e=>$(e.smalltalk)),[],import.meta.url)}}),Q.of({name:`Solr`,load(){return W(()=>import(`./solr-BBopId9w.js`).then(e=>$(e.solr)),[],import.meta.url)}}),Q.of({name:`SML`,extensions:[`sml`,`sig`,`fun`,`smackspec`],load(){return W(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.sml)),[],import.meta.url)}}),Q.of({name:`SPARQL`,alias:[`sparul`],extensions:[`rq`,`sparql`],load(){return W(()=>import(`./sparql-Dz-mlCAC.js`).then(e=>$(e.sparql)),[],import.meta.url)}}),Q.of({name:`Spreadsheet`,alias:[`excel`,`formula`],load(){return W(()=>import(`./spreadsheet-CTIncYxj.js`).then(e=>$(e.spreadsheet)),[],import.meta.url)}}),Q.of({name:`Squirrel`,extensions:[`nut`],load(){return W(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.squirrel)),[],import.meta.url)}}),Q.of({name:`Stylus`,extensions:[`styl`],load(){return W(()=>import(`./stylus-DLLZ8dgm.js`).then(e=>$(e.stylus)),[],import.meta.url)}}),Q.of({name:`Swift`,extensions:[`swift`],load(){return W(()=>import(`./swift-DKB6_1j6.js`).then(e=>$(e.swift)),[],import.meta.url)}}),Q.of({name:`sTeX`,load(){return W(()=>import(`./stex-sDrdk2BW.js`).then(e=>$(e.stex)),[],import.meta.url)}}),Q.of({name:`LaTeX`,alias:[`tex`],extensions:[`text`,`ltx`,`tex`],load(){return W(()=>import(`./stex-sDrdk2BW.js`).then(e=>$(e.stex)),[],import.meta.url)}}),Q.of({name:`SystemVerilog`,extensions:[`v`,`sv`,`svh`],load(){return W(()=>import(`./verilog-D-x6ne0Z.js`).then(e=>$(e.verilog)),[],import.meta.url)}}),Q.of({name:`Tcl`,extensions:[`tcl`],load(){return W(()=>import(`./tcl-BGfruO1u.js`).then(e=>$(e.tcl)),[],import.meta.url)}}),Q.of({name:`Textile`,extensions:[`textile`],load(){return W(()=>import(`./textile-DWBqthVk.js`).then(e=>$(e.textile)),[],import.meta.url)}}),Q.of({name:`TiddlyWiki`,load(){return W(()=>import(`./tiddlywiki-VlUiK86J.js`).then(e=>$(e.tiddlyWiki)),[],import.meta.url)}}),Q.of({name:`Tiki wiki`,load(){return W(()=>import(`./tiki-CxVlf5KZ.js`).then(e=>$(e.tiki)),[],import.meta.url)}}),Q.of({name:`TOML`,extensions:[`toml`],load(){return W(()=>import(`./toml-LvoKBwCs.js`).then(e=>$(e.toml)),[],import.meta.url)}}),Q.of({name:`Troff`,extensions:[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],load(){return W(()=>import(`./troff-C2dAgh7P.js`).then(e=>$(e.troff)),[],import.meta.url)}}),Q.of({name:`TTCN`,extensions:[`ttcn`,`ttcn3`,`ttcnpp`],load(){return W(()=>import(`./ttcn-BePYh-hG.js`).then(e=>$(e.ttcn)),[],import.meta.url)}}),Q.of({name:`TTCN_CFG`,extensions:[`cfg`],load(){return W(()=>import(`./ttcn-cfg-CY0aot7Q.js`).then(e=>$(e.ttcnCfg)),[],import.meta.url)}}),Q.of({name:`Turtle`,extensions:[`ttl`],load(){return W(()=>import(`./turtle-BDLWE2cD.js`).then(e=>$(e.turtle)),[],import.meta.url)}}),Q.of({name:`Web IDL`,extensions:[`webidl`],load(){return W(()=>import(`./webidl-D5jiJvOU.js`).then(e=>$(e.webIDL)),[],import.meta.url)}}),Q.of({name:`VB.NET`,extensions:[`vb`],load(){return W(()=>import(`./vb-BthdM_4N.js`).then(e=>$(e.vb)),[],import.meta.url)}}),Q.of({name:`VBScript`,extensions:[`vbs`],load(){return W(()=>import(`./vbscript-D9f6rSsU.js`).then(e=>$(e.vbScript)),[],import.meta.url)}}),Q.of({name:`Velocity`,extensions:[`vtl`],load(){return W(()=>import(`./velocity-CqftRsjg.js`).then(e=>$(e.velocity)),[],import.meta.url)}}),Q.of({name:`Verilog`,extensions:[`v`],load(){return W(()=>import(`./verilog-D-x6ne0Z.js`).then(e=>$(e.verilog)),[],import.meta.url)}}),Q.of({name:`VHDL`,extensions:[`vhd`,`vhdl`],load(){return W(()=>import(`./vhdl-CMrOq2q1.js`).then(e=>$(e.vhdl)),[],import.meta.url)}}),Q.of({name:`XQuery`,extensions:[`xy`,`xquery`,`xq`,`xqm`,`xqy`],load(){return W(()=>import(`./xquery-fj_R-kMw.js`).then(e=>$(e.xQuery)),[],import.meta.url)}}),Q.of({name:`Yacas`,extensions:[`ys`],load(){return W(()=>import(`./yacas-CXXgtw0p.js`).then(e=>$(e.yacas)),[],import.meta.url)}}),Q.of({name:`Z80`,extensions:[`z80`],load(){return W(()=>import(`./z80-CL1naaMV.js`).then(e=>$(e.z80)),[],import.meta.url)}}),Q.of({name:`MscGen`,extensions:[`mscgen`,`mscin`,`msc`],load(){return W(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.mscgen)),[],import.meta.url)}}),Q.of({name:`Xù`,extensions:[`xu`],load(){return W(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.xu)),[],import.meta.url)}}),Q.of({name:`MsGenny`,extensions:[`msgenny`],load(){return W(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.msgenny)),[],import.meta.url)}}),Q.of({name:`Vue`,extensions:[`vue`],load(){return W(()=>import(`./dist-D_gCRUxt.js`).then(e=>e.vue()),__vite__mapDeps([33,12,10,8,13]),import.meta.url)}}),Q.of({name:`Angular Template`,load(){return W(()=>import(`./dist-Cpz8Cm0v.js`).then(e=>e.angular()),__vite__mapDeps([34,12,10,8,13]),import.meta.url)}})];function JR(e){let t=String(e||``).split(`/`).pop()||``,n=t.lastIndexOf(`.`);return n>=0?t.slice(n):``}function YR(e){return Q.matchFilename(qR,`file${e}`)}function XR({content:e,path:t,readOnly:n=!1,onSave:r,onDirtyChange:i,onContentChange:a,getContentRef:o}){let s=(0,b.useRef)(null),c=(0,b.useRef)(null),l=(0,b.useRef)(new Lx),u=(0,b.useRef)(new Lx),d=(0,b.useRef)(new Lx),f=(0,b.useRef)(!1),p=(0,b.useRef)(r),m=(0,b.useRef)(i),h=(0,b.useRef)(a);(0,b.useEffect)(()=>{p.current=r,m.current=i,h.current=a},[r,i,a]);let g=(0,b.useCallback)(e=>{f.current!==e&&(f.current=e,m.current?.(e))},[]);return(0,b.useEffect)(()=>{if(!s.current)return;let r=document.documentElement.classList.contains(`dark`),i=eO.of([{key:`Mod-s`,run:e=>{let t=e.state.doc.toString();return p.current?.(t),g(!1),!0},preventDefault:!0}]),a=new Y({state:mS.create({doc:e,extensions:[kk(),Nk(),wN(),mM(),vO(),DO(),mS.allowMultipleSelections.of(!0),Bj(),bM(CM,{fallback:!0}),NM(),ER(),UR(),IO(),zO(),OO(),lI(),eO.of([...MR,...jF,...QI,...UN,...aM,...WR,MF]),i,Y.updateListener.of(e=>{e.docChanged&&(g(!0),h.current?.(e.state.doc.toString()))}),d.current.of(mS.readOnly.of(n)),l.current.of([]),u.current.of(r?YF:[]),Y.theme({"&":{height:`100%`},".cm-scroller":{overflow:`auto`}})]}),parent:s.current});c.current=a,o&&(o.current=()=>a.state.doc.toString());let f=YR(JR(t));return f&&f.load().then(e=>{c.current&&c.current.dispatch({effects:l.current.reconfigure(e)})}).catch(()=>{}),()=>{a.destroy(),c.current=null,o&&(o.current=null)}},[]),(0,b.useEffect)(()=>{let t=c.current;if(!t)return;let n=t.state.doc.toString();n!==e&&(t.dispatch({changes:{from:0,to:n.length,insert:e}}),g(!1))},[e,g]),(0,b.useEffect)(()=>{let e=c.current;if(!e)return;let n=YR(JR(t));n?n.load().then(e=>{c.current&&c.current.dispatch({effects:l.current.reconfigure(e)})}).catch(()=>{}):e.dispatch({effects:l.current.reconfigure([])})},[t]),(0,b.useEffect)(()=>{let e=c.current;e&&e.dispatch({effects:d.current.reconfigure(mS.readOnly.of(n))})},[n]),(0,b.useEffect)(()=>{let e=new MutationObserver(()=>{let e=c.current;if(!e)return;let t=document.documentElement.classList.contains(`dark`);e.dispatch({effects:u.current.reconfigure(t?YF:[])})});return e.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>e.disconnect()},[]),(0,R.jsx)(`div`,{ref:s,className:`h-full w-full overflow-hidden [&_.cm-editor]:h-full [&_.cm-scroller]:auto`})}function ZR({content:e,objectUrl:t,kind:n,filename:r,path:i}){return n===`markdown`?(0,R.jsx)(Uy,{content:e||``}):n===`image`&&t?(0,R.jsx)(`div`,{className:`flex items-center justify-center p-4`,children:(0,R.jsx)(`img`,{src:t,alt:r,className:`max-h-[70vh] max-w-full rounded object-contain`})}):n===`pdf`&&t?(0,R.jsx)(`iframe`,{src:t,title:r,className:`h-full w-full border-0`}):(n===`text`||n===`code`)&&e!==null?(0,R.jsx)(XR,{content:e,path:i||r,readOnly:!0,onSave:()=>{},onDirtyChange:()=>{},getContentRef:{current:()=>e||``}}):(0,R.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,R.jsx)(`div`,{className:`w-full max-w-md rounded-2xl border border-dashed border-slate-300 bg-slate-50 px-5 py-5 text-slate-500 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-400`,children:`该文件类型暂不支持在线预览,请直接下载查看。`})})}function QR(e){return e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}function $R(e){let t=e.endsWith(`/`)?e:`${e}/`;if(typeof window>`u`)return`'self'`;try{return new URL(t,window.location.origin).toString()}catch{return`'self'`}}function ez(...e){return Array.from(new Set(e.filter(e=>!!e))).join(` `)}function tz(e){let t=e?$R(e):void 0,n=ez(`'unsafe-inline'`,`'unsafe-eval'`,`'self'`,`https:`,t),r=ez(`'self'`,`https:`,t);return[`default-src 'none'`,`script-src ${n}`,`style-src 'unsafe-inline' data: ${r}`,`img-src data: blob: ${r}`,`font-src data: ${r}`,`media-src data: blob: ${r}`,`worker-src blob:`,`connect-src 'none'`,`form-action 'none'`,`base-uri 'self'`].join(`; `)}function nz(e){try{let t=new URL(e,window.location.href);return[`http:`,`https:`,`mailto:`].includes(t.protocol)}catch{return!1}}function rz(e,t={}){let{channelId:n,basePath:r}=typeof t==`string`?{channelId:t}:t,i=tz(r),a=`<script>
133
+ `:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new jI(this):new TI(this)}getCursor(e,t=0,n){let r=e.doc?e:mS.create({doc:e});return n??=r.doc.length,this.regexp?DI(this,r,t,n):CI(this,r,t,n)}},xI=class{constructor(e){this.spec=e}};function SI(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function CI(e,t,n,r){let i;return e.wholeWord&&(i=wI(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=SI(e.test,t,i)),new ZF(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function wI(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(OI(i,n-a))!=lS.Word||t(kI(i,n-a))!=lS.Word)&&(t(kI(i,r-a))!=lS.Word||t(OI(i,r-a))!=lS.Word))}var TI=class extends xI{constructor(e){super(e)}nextMatch(e,t,n){let r=CI(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=CI(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=CI(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=CI(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=CI(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function EI(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function DI(e,t,n,r){let i;return e.wholeWord&&(i=AI(t.charCategorizer(t.selection.main.head))),e.test&&(i=EI(e.test,t,i)),new eI(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function OI(e,t){return e.slice(sx(e,t,!1),t)}function kI(e,t){return e.slice(t,sx(e,t))}function AI(e){return(t,n,r)=>!r[0].length||(e(OI(r.input,r.index))!=lS.Word||e(kI(r.input,r.index))!=lS.Word)&&(e(kI(r.input,r.index+r[0].length))!=lS.Word||e(OI(r.input,r.index+r[0].length))!=lS.Word)}var jI=class extends xI{nextMatch(e,t,n){let r=DI(this.spec,e,n,e.doc.length).next();return r.done&&(r=DI(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=DI(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=DI(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=DI(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},MI=$x.define(),NI=$x.define(),PI=Mx.define({create(e){return new FI(qI(e).create(),null)},update(e,t){for(let n of t.effects)n.is(MI)?e=new FI(n.value.create(),e.panel):n.is(NI)&&(e=new FI(e.query,n.value?KI:null));return e},provide:e=>nk.from(e,e=>e.panel)}),FI=class{constructor(e,t){this.query=e,this.panel=t}},II=J.mark({class:`cm-searchMatch`}),LI=J.mark({class:`cm-searchMatch cm-searchMatch-selected`}),RI=Rw.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(PI))}update(e){let t=e.state.field(PI);(t!=e.startState.field(PI)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return J.none;let{view:n}=this,r=new CS;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?LI:II)})}return r.finish()}},{decorations:e=>e.decorations});function zI(e){return t=>{let n=t.state.field(PI,!1);return n&&n.query.spec.valid?e(t,n):XI(t)}}var BI=zI((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=G.single(r.from,r.to),a=e.state.facet(yI);return e.dispatch({selection:i,effects:[rL(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),YI(e),!0}),VI=zI((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=G.single(i.from,i.to),o=e.state.facet(yI);return e.dispatch({selection:a,effects:[rL(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),YI(e),!0}),HI=zI((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:G.create(n.map(e=>G.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),UI=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new ZF(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(G.range(t.value.from,t.value.to))}return t(e.update({selection:G.create(a,o),userEvent:`select.search.matches`})),!0},WI=zI((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.precise?o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),u.push(Y.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`))):o=t.nextMatch(n,o.from,o.to);let d=e.state.changes(s);return o&&(c=G.single(o.from,o.to).map(d),u.push(rL(e,o)),u.push(n.facet(yI).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),GI=zI((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let r of t.matchAll(e.state,1e9)){let{from:e,to:i,precise:a}=r;a&&n.push({from:e,to:i,insert:t.getReplacement(r)})}if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:Y.announce.of(r),userEvent:`input.replace.all`}),!0});function KI(e){return e.state.facet(yI).createPanel(e)}function qI(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(yI);return new bI({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function JI(e){let t=QO(e,KI);return t&&t.dom.querySelector(`[main-field]`)}function YI(e){let t=JI(e);t&&t==e.root.activeElement&&t.select()}var XI=e=>{let t=e.state.field(PI,!1);if(t&&t.panel){let n=JI(e);if(n&&n!=e.root.activeElement){let r=qI(e.state,t.query.spec);r.valid&&e.dispatch({effects:MI.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[NI.of(!0),t?MI.of(qI(e.state,t.query.spec)):$x.appendConfig.of(aL)]});return!0},ZI=e=>{let t=e.state.field(PI,!1);if(!t||!t.panel)return!1;let n=QO(e,KI);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:NI.of(!1)}),!0},QI=[{key:`Mod-f`,run:XI,scope:`editor search-panel`},{key:`F3`,run:BI,shift:VI,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:BI,shift:VI,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:ZI,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:UI},{key:`Mod-Alt-g`,run:oI},{key:`Mod-d`,run:vI,preventDefault:!0}],$I=class{constructor(e){this.view=e;let t=this.query=e.state.field(PI).query.spec;this.commit=this.commit.bind(this),this.searchField=XS(`input`,{value:t.search,placeholder:eL(e,`Find`),"aria-label":eL(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=XS(`input`,{value:t.replace,placeholder:eL(e,`Replace`),"aria-label":eL(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=XS(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=XS(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=XS(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return XS(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=XS(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>BI(e),[eL(e,`next`)]),n(`prev`,()=>VI(e),[eL(e,`previous`)]),n(`select`,()=>HI(e),[eL(e,`all`)]),XS(`label`,null,[this.caseField,eL(e,`match case`)]),XS(`label`,null,[this.reField,eL(e,`regexp`)]),XS(`label`,null,[this.wordField,eL(e,`by word`)]),...e.state.readOnly?[]:[XS(`br`),this.replaceField,n(`replace`,()=>WI(e),[eL(e,`replace`)]),n(`replaceAll`,()=>GI(e),[eL(e,`replace all`)])],XS(`button`,{name:`close`,onclick:()=>ZI(e),"aria-label":eL(e,`close`),type:`button`},[`×`])])}commit(){let e=new bI({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:MI.of(e)}))}keydown(e){rO(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?VI:BI)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),WI(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(MI)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(yI).top}};function eL(e,t){return e.state.phrase(t)}var tL=30,nL=/[\s\.,:;?!]/;function rL(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-tL),o=Math.min(i,n+tL),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<tL;e++)if(!nL.test(s[e+1])&&nL.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-tL;e--)if(!nL.test(s[e-1])&&nL.test(s[e])){s=s.slice(0,e);break}}return Y.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var iL=Y.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),aL=[PI,Fx.low(RI),iL],oL=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=lj(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(pL(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e==`abort`&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function sL(e){let t=Object.keys(e).join(``),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,``)),`[${n?`\\w`:``}${t.replace(/[^\w\s]/g,`\\$&`)}]`}function cL(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=sL(t)+sL(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function lL(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:cL(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function uL(e,t){return n=>{for(let t=lj(n.state).resolveInner(n.pos,-1);t;t=t.parent){if(e.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(n)}}var dL=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function fL(e){return e.selection.main.from}function pL(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}var mL=Xx.define();function hL(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return{...e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let c=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:c},range:G.cursor(s.from+a+c.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var gL=new WeakMap;function _L(e){if(!Array.isArray(e))return e;let t=gL.get(e);return t||gL.set(e,t=lL(e)),t}var vL=$x.define(),yL=$x.define(),bL=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=ux(e,t),r=fx(n);this.chars.push(n);let i=e.slice(t,t+r),a=i.toUpperCase();this.folded.push(ux(a==i?i.toLowerCase():a,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:r,precise:i,byWord:a}=this;if(t.length==1){let r=ux(e,0),i=fx(r),a=i==e.length?0:-100;if(r!=t[0])if(r==n[0])a+=-200;else return null;return this.ret(a,[0,i])}let o=e.indexOf(this.pattern);if(o==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let s=t.length,c=0;if(o<0){for(let i=0,a=Math.min(e.length,200);i<a&&c<s;){let a=ux(e,i);(a==t[c]||a==n[c])&&(r[c++]=i),i+=fx(a)}if(c<s)return null}let l=0,u=0,d=!1,f=0,p=-1,m=-1,h=/[a-z]/.test(e),g=!0;for(let r=0,c=Math.min(e.length,200),_=0;r<c&&u<s;){let c=ux(e,r);o<0&&(l<s&&c==t[l]&&(i[l++]=r),f<s&&(c==t[f]||c==n[f]?(f==0&&(p=r),m=r+1,f++):f=0));let v,y=c<255?c>=48&&c<=57||c>=97&&c<=122?2:+(c>=65&&c<=90):(v=dx(c))==v.toLowerCase()?v==v.toUpperCase()?0:2:1;(!r||y==1&&h||_==0&&y!=0)&&(t[u]==c||n[u]==c&&(d=!0)?a[u++]=r:a.length&&(g=!1)),_=y,r+=fx(c)}return u==s&&a[0]==0&&g?this.result(-100+(d?-200:0),a,e):f==s&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):f==s?this.ret(-900-e.length,[p,m]):u==s?this.result(-100+(d?-200:0)+-700+(g?0:-1100),a,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,n){let r=[],i=0;for(let e of t){let t=e+(this.astral?fx(ux(n,e)):1);i&&r[i-1]==e?r[i-1]=t:(r[i++]=e,r[i++]=t)}return this.ret(e-n.length,r)}},xL=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}},SL=K.define({combine(e){return hS(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>``,optionClass:()=>``,aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:wL,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>CL(e(n),t(n)),optionClass:(e,t)=>n=>CL(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function CL(e,t){return e?t?e+` `+t:e:t}function wL(e,t,n,r,i,a){let o=e.textDirection==XC.RTL,s=o,c=!1,l=`top`,u,d,f=t.left-i.left,p=i.right-t.right,m=r.right-r.left,h=r.bottom-r.top;if(s&&f<Math.min(m,p)?s=!1:!s&&p<Math.min(m,f)&&(s=!0),m<=(s?f:p))u=Math.max(i.top,Math.min(n.top,i.bottom-h))-t.top,d=Math.min(400,s?f:p);else{c=!0,d=Math.min(400,(o?t.right:i.right-t.left)-30);let e=i.bottom-t.bottom;e>=h||e>t.top?u=n.bottom-t.top:(l=`bottom`,u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,_=(t.right-t.left)/a.offsetWidth;return{style:`${l}: ${u/g}px; max-width: ${d/_}px`,class:`cm-completionInfo-`+(c?o?`left-narrow`:`right-narrow`:s?`left`:`right`)}}var TL=$x.define();function EL(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement(`div`);return t.classList.add(`cm-completionIcon`),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>`cm-completionIcon-`+e)),t.setAttribute(`aria-hidden`,`true`),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement(`span`);i.className=`cm-completionLabel`;let a=e.displayLabel||e.label,o=0;for(let e=0;e<r.length;){let t=r[e++],n=r[e++];t>o&&i.appendChild(document.createTextNode(a.slice(o,t)));let s=i.appendChild(document.createElement(`span`));s.appendChild(document.createTextNode(a.slice(t,n))),s.className=`cm-completionMatchedText`,o=n}return o<a.length&&i.appendChild(document.createTextNode(a.slice(o))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement(`span`);return t.className=`cm-completionDetail`,t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}function DL(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.ceil((e-t)/n);return{from:e-r*n,to:e-(r-1)*n}}var OL=class{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass=``;let r=e.state.field(t),{options:i,selected:a}=r.open,o=e.state.facet(SL);this.optionContent=EL(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=DL(i.length,a,o.maxRenderedOptions),this.dom=document.createElement(`div`),this.dom.className=`cm-tooltip-autocomplete`,this.updateTooltipClass(e.state),this.dom.addEventListener(`mousedown`,n=>{let{options:r}=e.state.field(t).open;for(let t=n.target,i;t&&t!=this.dom;t=t.parentNode)if(t.nodeName==`LI`&&(i=/-(\d+)$/.exec(t.id))&&+i[1]<r.length){this.applyCompletion(e,r[+i[1]]),n.preventDefault();return}if(n.target==this.list){let t=this.list.classList.contains(`cm-completionListIncompleteTop`)&&n.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains(`cm-completionListIncompleteBottom`)&&n.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;t!=null&&(e.dispatch({effects:TL.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(SL).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:yL.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener(`scroll`,()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){let t=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),t!=n){let{options:r,selected:i,disabled:a}=t.open;(!n.open||n.open.options!=r)&&(this.range=DL(r.length,i,e.state.facet(SL).maxRenderedOptions),this.showOptions(r,t.id)),this.updateSel(),a!=n.open?.disabled&&this.dom.classList.toggle(`cm-tooltip-autocomplete-disabled`,!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(` `))e&&this.dom.classList.remove(e);for(let e of t.split(` `))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=DL(t.options.length,t.selected,this.view.state.facet(SL).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let a=typeof i==`string`?document.createTextNode(i):i(r);if(!a)return;`then`in a?a.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,r)}).catch(e=>Pw(this.view.state,e,`completion info`)):(this.addInfoPane(a,r),n.setAttribute(`aria-describedby`,this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement(`div`);if(n.className=`cm-tooltip cm-completionInfo`,n.id=`cm-completionInfo-`+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!=`LI`||!n.id?r--:r==e?n.hasAttribute(`aria-selected`)||(n.setAttribute(`aria-selected`,`true`),t=n):n.hasAttribute(`aria-selected`)&&(n.removeAttribute(`aria-selected`),n.removeAttribute(`aria-describedby`));return t&&AL(this.list,t),t}measureInfo(){let e=this.dom.querySelector(`[aria-selected]`);if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(SL).positionInfo(this.view,t,r,n,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className=`cm-tooltip cm-completionInfo `+(e.class||``)):this.info.style.cssText=`top: -1e6px`)}createListBox(e,t,n){let r=document.createElement(`ul`);r.id=t,r.setAttribute(`role`,`listbox`),r.setAttribute(`aria-expanded`,`true`),r.setAttribute(`aria-label`,this.view.state.phrase(`Completions`)),r.addEventListener(`mousedown`,e=>{e.target==r&&e.preventDefault()});let i=null;for(let a=n.from;a<n.to;a++){let{completion:o,match:s}=e[a],{section:c}=o;if(c){let e=typeof c==`string`?c:c.name;if(e!=i&&(a>n.from||n.from==0))if(i=e,typeof c!=`string`&&c.header)r.appendChild(c.header(c));else{let t=r.appendChild(document.createElement(`completion-section`));t.textContent=e}}let l=r.appendChild(document.createElement(`li`));l.id=t+`-`+a,l.setAttribute(`role`,`option`);let u=this.optionClass(o);u&&(l.className=u);for(let e of this.optionContent){let t=e(o,this.view.state,this.view,s);t&&l.appendChild(t)}}return n.from&&r.classList.add(`cm-completionListIncompleteTop`),n.to<e.length&&r.classList.add(`cm-completionListIncompleteBottom`),r}destroyInfo(){this.info&&=(this.infoDestroy&&this.infoDestroy(),this.info.remove(),null)}destroy(){this.destroyInfo()}};function kL(e,t){return n=>new OL(n,e,t)}function AL(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function jL(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+ +!!e.type}function ML(e,t){let n=[],r=null,i=null,a=e=>{n.push(e);let{section:t}=e.completion;if(t){r||=[];let e=typeof t==`string`?t:t.name;r.some(t=>t.name==e)||r.push(typeof t==`string`?{name:e}:t)}},o=t.facet(SL);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(r.result.filter===!1)for(let t of r.result.options)a(new dL(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new xL(n):new bL(n);for(let t of r.result.options)if(s=c.match(t.label)){let n=t.displayLabel?e?e(t,s.matched):[]:s.matched,o=s.score+(t.boost||0);if(a(new dL(t,r.source,n,o)),typeof t.section==`object`&&t.section.rank===`dynamic`){let{name:e}=t.section;i||=Object.create(null),i[e]=Math.max(o,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,a=(e,t)=>(e.rank===`dynamic`&&t.rank===`dynamic`?i[t.name]-i[e.name]:0)||(typeof e.rank==`number`?e.rank:1e9)-(typeof t.rank==`number`?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of r.sort(a))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e[typeof n==`string`?n:n.name])}}let s=[],c=null,l=o.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||l(e.completion,t.completion))){let t=e.completion;!c||c.label!=t.label||c.detail!=t.detail||c.type!=null&&t.type!=null&&c.type!=t.type||c.apply!=t.apply||c.boost!=t.boost?s.push(e):jL(e.completion)>jL(c)&&(s[s.length-1]=e),c=e.completion}return s}var NL=class e{constructor(e,t,n,r,i,a){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new e(this.options,RL(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(e=>e.isPending))return i.setDisabled();let s=ML(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(SL).selectOnOpen?0:-1;if(i&&i.selected!=c&&i.selected!=-1){let e=i.options[i.selected].completion;for(let t=0;t<s.length;t++)if(s[t].completion==e){c=t;break}}return new e(s,RL(r,c),{pos:t.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:qL,above:a.aboveCursor},i?i.timestamp:Date.now(),c,!1)}map(t){return new e(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new e(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},PL=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e(zL,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(SL),i=(r.override||n.languageDataAt(`autocomplete`,fL(n)).map(_L)).map(e=>(this.active.find(t=>t.source==e)||new VL(e,+!!this.active.some(e=>e.state!=0))).update(t,r));i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let a=this.open,o=t.effects.some(e=>e.is(WL));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!FL(i,this.active)||o?a=NL.build(i,n,this.id,a,r,o):a&&a.disabled&&!i.some(e=>e.isPending)&&(a=null),!a&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new VL(e.source,0):e));for(let e of t.effects)e.is(TL)&&(a&&=a.setSelected(e.value,this.id));return i==this.active&&a==this.open?this:new e(i,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?IL:LL}};function FL(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}var IL={"aria-autocomplete":`list`},LL={};function RL(e,t){let n={"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-controls":e};return t>-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var zL=[];function BL(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(mL);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent(`input.type`);return n&&t.activateOnTyping?5:n?1:e.isUserEvent(`delete.backward`)?2:e.selection?8:e.docChanged?16:0}var VL=class e{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=BL(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new e(i.source,0)),r&4&&i.state==0&&(i=new e(this.source,1)),i=i.updateFor(t,r);for(let n of t.effects)if(n.is(vL))i=new e(i.source,1,n.value);else if(n.is(yL))i=new e(i.source,0);else if(n.is(WL))for(let e of n.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(fL(e.state))}},HL=class e extends VL{constructor(e,t,n,r,i,a){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=a}hasResult(){return!0}updateFor(t,n){if(!(n&3))return this.map(t.changes);let r=this.result;r.map&&!t.changes.empty&&(r=r.map(r,t.changes));let i=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=fL(t.state);if(o>a||!r||n&2&&(fL(t.startState)==this.from||o<this.limit))return new VL(this.source,n&4?1:0);let s=t.changes.mapPos(this.limit);return UL(r.validFor,t.state,i,a)?new e(this.source,this.explicit,s,r,i,a):r.update&&(r=r.update(r,i,a,new oL(t.state,o,!1)))?new e(this.source,this.explicit,s,r,r.from,r.to??fL(t.state)):new VL(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new e(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new VL(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function UL(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e==`function`?e(i,n,r,t):pL(e,!0).test(i)}var WL=$x.define({map(e,t){return e.map(e=>e.map(t))}}),GL=Mx.define({create(){return PL.start()},update(e,t){return e.update(t)},provide:e=>[YO.from(e,e=>e.tooltip),Y.contentAttributes.from(e,e=>e.attrs)]});function KL(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(GL).active.find(e=>e.source==t.source);return r instanceof HL?(typeof n==`string`?e.dispatch({...hL(e.state,n,r.from,r.to),annotations:mL.of(t.completion)}):n(e,t.completion,r.from,r.to),!0):!1}var qL=kL(GL,KL);function JL(e,t=`option`){return n=>{let r=n.state.field(GL,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(SL).interactionDelay)return!1;let i=1,a;t==`page`&&(a=XO(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector(`li`).offsetHeight)-1));let{length:o}=r.open.options,s=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:o-1;return s<0?s=t==`page`?0:o-1:s>=o&&(s=t==`page`?o-1:0),n.dispatch({effects:TL.of(s)}),!0}}var YL=e=>{let t=e.state.field(GL,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(SL).interactionDelay?!1:KL(e,t.open.options[t.open.selected])},XL=e=>e.state.field(GL,!1)?(e.dispatch({effects:vL.of(!0)}),!0):!1,ZL=e=>{let t=e.state.field(GL,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:yL.of(null)}),!0)},QL=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},$L=50,eR=1e3,tR=Rw.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(GL).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(GL),n=e.state.facet(SL);if(!e.selectionSet&&!e.docChanged&&e.startState.field(GL)==t)return;let r=e.transactions.some(e=>{let t=BL(e,n);return t&8||(e.selection||e.docChanged)&&!(t&3)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(r||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>$L&&Date.now()-n.time>eR){for(let e of n.context.abortListeners)try{e()}catch(e){Pw(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(vL)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let t of e.transactions)t.isUserEvent(`input.type`)?this.composing=2:this.composing==2&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(GL);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(SL).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=new oL(t,fL(t),e.explicit,this.view),r=new QL(e,n);this.running.push(r),Promise.resolve(e.source(n)).then(e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:yL.of(null)}),Pw(this.view.state,e)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(SL).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(SL),n=this.view.state.field(GL);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(i.done===void 0)continue;if(this.running.splice(r--,1),i.done){let n=fL(i.updates.length?i.updates[0].startState:this.view.state),r=Math.min(n,i.done.from+ +!i.active.explicit),a=new HL(i.active.source,i.active.explicit,r,i.done,i.done.from,i.done.to??n);for(let e of i.updates)a=a.update(e,t);if(a.hasResult()){e.push(a);continue}}let a=n.active.find(e=>e.source==i.active.source);if(a&&a.isPending)if(i.done==null){let n=new VL(i.active.source,0);for(let e of i.updates)n=n.update(e,t);n.isPending||e.push(n)}else this.startQuery(a)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:WL.of(e)})}},{eventHandlers:{blur(e){let t=this.view.state.field(GL,!1);if(t&&t.tooltip&&this.view.state.facet(SL).closeOnBlur){let n=t.open&&XO(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:yL.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:vL.of(!1)}),20),this.composing=0}}}),nR=typeof navigator==`object`&&/Win/.test(navigator.platform),rR=Fx.highest(Y.domEventHandlers({keydown(e,t){let n=t.state.field(GL,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(nR&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&KL(t,r),!1}})),iR=Y.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:`monospace`,whiteSpace:`nowrap`,overflow:`hidden auto`,maxWidth_fallback:`700px`,maxWidth:`min(700px, 95vw)`,minWidth:`250px`,maxHeight:`10em`,height:`100%`,listStyle:`none`,margin:0,padding:0,"& > li, & > completion-section":{padding:`1px 3px`,lineHeight:1.2},"& > li":{overflowX:`hidden`,textOverflow:`ellipsis`,cursor:`pointer`},"& > completion-section":{display:`list-item`,borderBottom:`1px solid silver`,paddingLeft:`0.5em`,opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#17c`,color:`white`},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#777`},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#347`,color:`white`},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#444`},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:`"···"`,opacity:.5,display:`block`,textAlign:`center`,cursor:`pointer`},".cm-tooltip.cm-completionInfo":{position:`absolute`,padding:`3px 9px`,width:`max-content`,maxWidth:`400px`,boxSizing:`border-box`,whiteSpace:`pre-line`},".cm-completionInfo.cm-completionInfo-left":{right:`100%`},".cm-completionInfo.cm-completionInfo-right":{left:`100%`},".cm-completionInfo.cm-completionInfo-left-narrow":{right:`30px`},".cm-completionInfo.cm-completionInfo-right-narrow":{left:`30px`},"&light .cm-snippetField":{backgroundColor:`#00000022`},"&dark .cm-snippetField":{backgroundColor:`#ffffff22`},".cm-snippetFieldPosition":{verticalAlign:`text-top`,width:0,height:`1.15em`,display:`inline-block`,margin:`0 -0.7px -.7em`,borderLeft:`1.4px dotted #888`},".cm-completionMatchedText":{textDecoration:`underline`},".cm-completionDetail":{marginLeft:`0.5em`,fontStyle:`italic`},".cm-completionIcon":{fontSize:`90%`,width:`.8em`,display:`inline-block`,textAlign:`center`,paddingRight:`.6em`,opacity:`0.6`,boxSizing:`content-box`},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:`'ƒ'`}},".cm-completionIcon-class":{"&:after":{content:`'○'`}},".cm-completionIcon-interface":{"&:after":{content:`'◌'`}},".cm-completionIcon-variable":{"&:after":{content:`'𝑥'`}},".cm-completionIcon-constant":{"&:after":{content:`'𝐶'`}},".cm-completionIcon-type":{"&:after":{content:`'𝑡'`}},".cm-completionIcon-enum":{"&:after":{content:`'∪'`}},".cm-completionIcon-property":{"&:after":{content:`'□'`}},".cm-completionIcon-keyword":{"&:after":{content:`'🔑︎'`}},".cm-completionIcon-namespace":{"&:after":{content:`'▢'`}},".cm-completionIcon-text":{"&:after":{content:`'abc'`,fontSize:`50%`,verticalAlign:`middle`}}}),aR=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},oR=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(t){let n=t.mapPos(this.from,-1,mx.TrackDel),r=t.mapPos(this.to,1,mx.TrackDel);return n==null||r==null?null:new e(this.field,n,r)}},sR=class e{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],r=[t],i=e.doc.lineAt(t),a=/^\s*/.exec(i.text)[0];for(let i of this.lines){if(n.length){let n=a,o=/^\t*/.exec(i)[0].length;for(let t=0;t<o;t++)n+=e.facet(xj);r.push(t+n.length-o),i=n+i.slice(o)}n.push(i),t+=i.length+1}return{text:n,ranges:this.fieldPositions.map(e=>new oR(e.field,r[e.line]+e.from,r[e.line]+e.to))}}static parse(t){let n=[],r=[],i=[],a;for(let e of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(e);){let t=a[1]?+a[1]:null,o=a[2]||a[3]||``,s=-1,c=o.replace(/\\[{}]/g,e=>e[1]);for(let e=0;e<n.length;e++)(t==null?c&&n[e].name==c:n[e].seq==t)&&(s=e);if(s<0){let e=0;for(;e<n.length&&(t==null||n[e].seq!=null&&n[e].seq<t);)e++;n.splice(e,0,{seq:t,name:c}),s=e;for(let e of i)e.field>=s&&e.field++}for(let e of i)if(e.line==r.length&&e.from>a.index){let t=a[2]?3+(a[1]||``).length:2;e.from-=t,e.to-=t}i.push(new aR(s,r.length,a.index,a.index+c.length)),e=e.slice(0,a.index)+o+e.slice(a.index+a[0].length)}e=e.replace(/\\([{}])/g,(e,t,n)=>{for(let e of i)e.line==r.length&&e.from>n&&(e.from--,e.to--);return t}),r.push(e)}return new e(r,i)}},cR=J.widget({widget:new class extends hC{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),lR=J.mark({class:`cm-snippetField`}),uR=class e{constructor(e,t){this.ranges=e,this.active=t,this.deco=J.set(e.map(e=>(e.from==e.to?cR:lR).range(e.from,e.to)),!0)}map(t){let n=[];for(let e of this.ranges){let r=e.map(t);if(!r)return null;n.push(r)}return new e(n,this.active)}selectionInsideField(e){return e.ranges.every(e=>this.ranges.some(t=>t.field==this.active&&t.from<=e.from&&t.to>=e.to))}},dR=$x.define({map(e,t){return e&&e.map(t)}}),fR=$x.define(),pR=Mx.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(dR))return n.value;if(n.is(fR)&&e)return new uR(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>Y.decorations.from(e,e=>e?e.deco:J.none)});function mR(e,t){return G.create(e.filter(e=>e.field==t).map(e=>G.range(e.from,e.to)))}function hR(e){let t=sR.parse(e);return(e,n,r,i)=>{let{text:a,ranges:o}=t.instantiate(e.state,r),{main:s}=e.state.selection,c={changes:{from:r,to:i==s.from?s.to:i,insert:Xb.of(a)},scrollIntoView:!0,annotations:n?[mL.of(n),eS.userEvent.of(`input.complete`)]:void 0};if(o.length&&(c.selection=mR(o,0)),o.some(e=>e.field>0)){let t=new uR(o,0),n=c.effects=[dR.of(t)];e.state.field(pR,!1)===void 0&&n.push($x.appendConfig.of([pR,yR,xR,iR]))}e.dispatch(e.state.update(c))}}function gR(e){return({state:t,dispatch:n})=>{let r=t.field(pR,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(t=>t.field==i+e);return n(t.update({selection:mR(r.ranges,i),effects:dR.of(a?null:new uR(r.ranges,i)),scrollIntoView:!0})),!0}}var _R=[{key:`Tab`,run:gR(1),shift:gR(-1)},{key:`Escape`,run:({state:e,dispatch:t})=>e.field(pR,!1)?(t(e.update({effects:dR.of(null)})),!0):!1}],vR=K.define({combine(e){return e.length?e[0]:_R}}),yR=Fx.highest(eO.compute([vR],e=>e.facet(vR)));function bR(e,t){return{...t,apply:hR(e)}}var xR=Y.domEventHandlers({mousedown(e,t){let n=t.state.field(pR,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(e=>e.from<=r&&e.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:mR(n.ranges,i.field),effects:dR.of(n.ranges.some(e=>e.field>i.field)?new uR(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),SR={brackets:[`(`,`[`,`{`,`'`,`"`],before:`)]}:;>`,stringPrefixes:[]},CR=$x.define({map(e,t){return t.mapPos(e,-1,mx.TrackAfter)??void 0}}),wR=new class extends gS{};wR.startSide=1,wR.endSide=-1;var TR=Mx.define({create(){return xS.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(CR)&&(e=e.update({add:[wR.range(n.value,n.value+1)]}));return e}});function ER(){return[jR,TR]}var DR=`()[]{}<>«»»«[]{}`;function OR(e){for(let t=0;t<16;t+=2)if(DR.charCodeAt(t)==e)return DR.charAt(t+1);return dx(e<128?e:e+1)}function kR(e,t){return e.languageDataAt(`closeBrackets`,t)[0]||SR}var AR=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),jR=Y.inputHandler.of((e,t,n,r)=>{if((AR?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&fx(ux(r,0))==1||t!=i.from||n!=i.to)return!1;let a=NR(e.state,r);return a?(e.dispatch(a),!0):!1}),MR=[{key:`Backspace`,run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=kR(e,e.selection.main.head).brackets||SR.brackets,r=null,i=e.changeByRange(t=>{if(t.empty){let r=IR(e.doc,t.head);for(let i of n)if(i==r&&FR(e.doc,t.head)==OR(ux(i,0)))return{changes:{from:t.head-i.length,to:t.head+i.length},range:G.cursor(t.head-i.length)}}return{range:r=t}});return r||t(e.update(i,{scrollIntoView:!0,userEvent:`delete.backward`})),!r}}];function NR(e,t){let n=kR(e,e.selection.main.head),r=n.brackets||SR.brackets;for(let i of r){let a=OR(ux(i,0));if(t==i)return a==i?zR(e,i,r.indexOf(i+i+i)>-1,n):LR(e,i,a,n.before||SR.before);if(t==a&&PR(e,e.selection.main.from))return RR(e,i,a)}return null}function PR(e,t){let n=!1;return e.field(TR).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function FR(e,t){let n=e.sliceString(t,t+2);return n.slice(0,fx(ux(n,0)))}function IR(e,t){let n=e.sliceString(t-2,t);return fx(ux(n,0))==n.length?n:n.slice(1)}function LR(e,t,n,r){let i=null,a=e.changeByRange(a=>{if(!a.empty)return{changes:[{insert:t,from:a.from},{insert:n,from:a.to}],effects:CR.of(a.to+t.length),range:G.range(a.anchor+t.length,a.head+t.length)};let o=FR(e.doc,a.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:CR.of(a.head+t.length),range:G.cursor(a.head+t.length)}:{range:i=a}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:`input.type`})}function RR(e,t,n){let r=null,i=e.changeByRange(t=>t.empty&&FR(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:G.cursor(t.head+n.length)}:r={range:t});return r?null:e.update(i,{scrollIntoView:!0,userEvent:`input.type`})}function zR(e,t,n,r){let i=r.stringPrefixes||SR.stringPrefixes,a=null,o=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:CR.of(r.to+t.length),range:G.range(r.anchor+t.length,r.head+t.length)};let o=r.head,s=FR(e.doc,o),c;if(s==t){if(BR(e,o))return{changes:{insert:t+t,from:o},effects:CR.of(o+t.length),range:G.cursor(o+t.length)};if(PR(e,o)){let r=n&&e.sliceDoc(o,o+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:o,to:o+r.length,insert:r},range:G.cursor(o+r.length)}}}else if(n&&e.sliceDoc(o-2*t.length,o)==t+t&&(c=HR(e,o-2*t.length,i))>-1&&BR(e,c))return{changes:{insert:t+t+t+t,from:o},effects:CR.of(o+t.length),range:G.cursor(o+t.length)};else if(e.charCategorizer(o)(s)!=lS.Word&&HR(e,o,i)>-1&&!VR(e,o,t,i))return{changes:{insert:t+t,from:o},effects:CR.of(o+t.length),range:G.cursor(o+t.length)};return{range:a=r}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:`input.type`})}function BR(e,t){let n=lj(e).resolveInner(t+1);return n.parent&&n.from==t}function VR(e,t,n,r){let i=lj(e).resolveInner(t,-1),a=r.reduce((e,t)=>Math.max(e,t.length),0);for(let o=0;o<5;o++){let o=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+a)),s=o.indexOf(n);if(!s||s>-1&&r.indexOf(o.slice(0,s))>-1){let t=i.firstChild;for(;t&&t.from==i.from&&t.to-t.from>n.length+s;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let c=i.to==t&&i.parent;if(!c)break;i=c}return!1}function HR(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=lS.Word)return t;for(let i of n){let n=t-i.length;if(e.sliceDoc(n,t)==i&&r(e.sliceDoc(n-1,n))!=lS.Word)return n}return-1}function UR(e={}){return[rR,GL,SL.of(e),tR,GR,iR]}var WR=[{key:`Ctrl-Space`,run:XL},{mac:"Alt-`",run:XL},{mac:`Alt-i`,run:XL},{key:`Escape`,run:ZL},{key:`ArrowDown`,run:JL(!0)},{key:`ArrowUp`,run:JL(!1)},{key:`PageDown`,run:JL(!0,`page`)},{key:`PageUp`,run:JL(!1,`page`)},{key:`Enter`,run:YL}],GR=Fx.highest(eO.computeN([SL],e=>e.facet(SL).defaultKeymap?[WR]:[]));function $(e){return new yj(GM.define(e))}function KR(e){return W(()=>import(`./dist-DeIyG_Yw.js`).then(t=>t.sql({dialect:t[e]})),__vite__mapDeps([7,8]),import.meta.url)}var qR=[Q.of({name:`C`,extensions:[`c`,`h`,`ino`],load(){return W(()=>import(`./dist-jY01heep.js`).then(e=>e.cpp()),__vite__mapDeps([9,8]),import.meta.url)}}),Q.of({name:`C++`,alias:[`cpp`],extensions:[`cpp`,`c++`,`cc`,`cxx`,`hpp`,`h++`,`hh`,`hxx`],load(){return W(()=>import(`./dist-jY01heep.js`).then(e=>e.cpp()),__vite__mapDeps([9,8]),import.meta.url)}}),Q.of({name:`CQL`,alias:[`cassandra`],extensions:[`cql`],load(){return KR(`Cassandra`)}}),Q.of({name:`CSS`,extensions:[`css`],load(){return W(()=>import(`./dist-UxQaQA4j.js`).then(e=>e.i).then(e=>e.css()),__vite__mapDeps([10,8]),import.meta.url)}}),Q.of({name:`Go`,extensions:[`go`],load(){return W(()=>import(`./dist-Dv3mIdmJ.js`).then(e=>e.go()),__vite__mapDeps([11,8]),import.meta.url)}}),Q.of({name:`HTML`,alias:[`xhtml`],extensions:[`html`,`htm`,`handlebars`,`hbs`],load(){return W(()=>import(`./dist-CsFBiJzz.js`).then(e=>e.html()),__vite__mapDeps([12,10,8,13]),import.meta.url)}}),Q.of({name:`Java`,extensions:[`java`],load(){return W(()=>import(`./dist-BBayeLLe.js`).then(e=>e.java()),__vite__mapDeps([14,8]),import.meta.url)}}),Q.of({name:`JavaScript`,alias:[`ecmascript`,`js`,`node`],extensions:[`js`,`mjs`,`cjs`],load(){return W(()=>import(`./dist-BXA3YG1m.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`Jinja`,extensions:[`j2`,`jinja`,`jinja2`],load(){return W(()=>import(`./dist-B8czu-Qc.js`).then(e=>e.jinja()),__vite__mapDeps([15,12,10,8,13]),import.meta.url)}}),Q.of({name:`JSON`,alias:[`json5`],extensions:[`json`,`map`],load(){return W(()=>import(`./dist-DpPvxuVN.js`).then(e=>e.json()),__vite__mapDeps([16,8]),import.meta.url)}}),Q.of({name:`JSX`,extensions:[`jsx`],load(){return W(()=>import(`./dist-BXA3YG1m.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`LESS`,extensions:[`less`],load(){return W(()=>import(`./dist-D0cssRbL.js`).then(e=>e.less()),__vite__mapDeps([17,10,8]),import.meta.url)}}),Q.of({name:`Liquid`,extensions:[`liquid`],load(){return W(()=>import(`./dist-DgPAQK3Q.js`).then(e=>e.liquid()),__vite__mapDeps([18,12,10,8,13]),import.meta.url)}}),Q.of({name:`MariaDB SQL`,load(){return KR(`MariaSQL`)}}),Q.of({name:`Markdown`,extensions:[`md`,`markdown`,`mkd`],load(){return W(()=>import(`./dist-qU1gRG7_.js`).then(e=>e.markdown()),__vite__mapDeps([19,12,10,8,13]),import.meta.url)}}),Q.of({name:`MS SQL`,load(){return KR(`MSSQL`)}}),Q.of({name:`MySQL`,load(){return KR(`MySQL`)}}),Q.of({name:`PHP`,extensions:[`php`,`php3`,`php4`,`php5`,`php7`,`phtml`],load(){return W(()=>import(`./dist-Z8OZFHSc.js`).then(e=>e.php()),__vite__mapDeps([20,12,10,8,13]),import.meta.url)}}),Q.of({name:`PLSQL`,extensions:[`pls`],load(){return KR(`PLSQL`)}}),Q.of({name:`PostgreSQL`,load(){return KR(`PostgreSQL`)}}),Q.of({name:`Python`,extensions:[`BUILD`,`bzl`,`py`,`pyw`],filename:/^(BUCK|BUILD)$/,load(){return W(()=>import(`./dist-uPv3jeT5.js`).then(e=>e.python()),__vite__mapDeps([21,8]),import.meta.url)}}),Q.of({name:`Rust`,extensions:[`rs`],load(){return W(()=>import(`./dist-BAQH6Sdn.js`).then(e=>e.rust()),__vite__mapDeps([22,8]),import.meta.url)}}),Q.of({name:`Sass`,extensions:[`sass`],load(){return W(()=>import(`./dist-C--QxXYi.js`).then(e=>e.sass({indented:!0})),__vite__mapDeps([23,10,8]),import.meta.url)}}),Q.of({name:`SCSS`,extensions:[`scss`],load(){return W(()=>import(`./dist-C--QxXYi.js`).then(e=>e.sass()),__vite__mapDeps([23,10,8]),import.meta.url)}}),Q.of({name:`SQL`,extensions:[`sql`],load(){return KR(`StandardSQL`)}}),Q.of({name:`SQLite`,load(){return KR(`SQLite`)}}),Q.of({name:`TSX`,extensions:[`tsx`],load(){return W(()=>import(`./dist-BXA3YG1m.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0,typescript:!0})),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`TypeScript`,alias:[`ts`],extensions:[`ts`,`mts`,`cts`],load(){return W(()=>import(`./dist-BXA3YG1m.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`WebAssembly`,extensions:[`wat`,`wast`],load(){return W(()=>import(`./dist-DJeSTOZu.js`).then(e=>e.wast()),__vite__mapDeps([24,8]),import.meta.url)}}),Q.of({name:`XML`,alias:[`rss`,`wsdl`,`xsd`],extensions:[`xml`,`xsl`,`xsd`,`svg`],load(){return W(()=>import(`./dist-Cu40b2RQ.js`).then(e=>e.xml()),__vite__mapDeps([25,8]),import.meta.url)}}),Q.of({name:`YAML`,alias:[`yml`],extensions:[`yaml`,`yml`],load(){return W(()=>import(`./dist-CA8U0v5G.js`).then(e=>e.yaml()),__vite__mapDeps([26,8]),import.meta.url)}}),Q.of({name:`APL`,extensions:[`dyalog`,`apl`],load(){return W(()=>import(`./apl-CnwPGSsG.js`).then(e=>$(e.apl)),[],import.meta.url)}}),Q.of({name:`PGP`,alias:[`asciiarmor`],extensions:[`asc`,`pgp`,`sig`],load(){return W(()=>import(`./asciiarmor-qTkVPQu6.js`).then(e=>$(e.asciiArmor)),[],import.meta.url)}}),Q.of({name:`ASN.1`,extensions:[`asn`,`asn1`],load(){return W(()=>import(`./asn1-Dr8qZg38.js`).then(e=>$(e.asn1({}))),[],import.meta.url)}}),Q.of({name:`Asterisk`,filename:/^extensions\.conf$/i,load(){return W(()=>import(`./asterisk-Bja0s6e1.js`).then(e=>$(e.asterisk)),[],import.meta.url)}}),Q.of({name:`Brainfuck`,extensions:[`b`,`bf`],load(){return W(()=>import(`./brainfuck-D5EjA2JK.js`).then(e=>$(e.brainfuck)),[],import.meta.url)}}),Q.of({name:`Cobol`,extensions:[`cob`,`cpy`],load(){return W(()=>import(`./cobol-B_OZ4V-R.js`).then(e=>$(e.cobol)),[],import.meta.url)}}),Q.of({name:`C#`,alias:[`csharp`,`cs`],extensions:[`cs`],load(){return W(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.csharp)),[],import.meta.url)}}),Q.of({name:`Clojure`,extensions:[`clj`,`cljc`,`cljx`],load(){return W(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`ClojureScript`,extensions:[`cljs`],load(){return W(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`Closure Stylesheets (GSS)`,extensions:[`gss`],load(){return W(()=>import(`./css-CYpP4FRV.js`).then(e=>$(e.gss)),[],import.meta.url)}}),Q.of({name:`CMake`,extensions:[`cmake`,`cmake.in`],filename:/^CMakeLists\.txt$/,load(){return W(()=>import(`./cmake-CyVbuzPu.js`).then(e=>$(e.cmake)),[],import.meta.url)}}),Q.of({name:`CoffeeScript`,alias:[`coffee`,`coffee-script`],extensions:[`coffee`],load(){return W(()=>import(`./coffeescript-B2pKbFk8.js`).then(e=>$(e.coffeeScript)),[],import.meta.url)}}),Q.of({name:`Common Lisp`,alias:[`lisp`],extensions:[`cl`,`lisp`,`el`],load(){return W(()=>import(`./commonlisp-CcllspGY.js`).then(e=>$(e.commonLisp)),[],import.meta.url)}}),Q.of({name:`Cypher`,extensions:[`cyp`,`cypher`],load(){return W(()=>import(`./cypher-p9eYesGn.js`).then(e=>$(e.cypher)),[],import.meta.url)}}),Q.of({name:`Cython`,extensions:[`pyx`,`pxd`,`pxi`],load(){return W(()=>import(`./python-BqYw9LYJ.js`).then(e=>$(e.cython)),[],import.meta.url)}}),Q.of({name:`Crystal`,extensions:[`cr`],load(){return W(()=>import(`./crystal-M5-qzICs.js`).then(e=>$(e.crystal)),[],import.meta.url)}}),Q.of({name:`D`,extensions:[`d`],load(){return W(()=>import(`./d-BhMjBjQP.js`).then(e=>$(e.d)),[],import.meta.url)}}),Q.of({name:`Dart`,extensions:[`dart`],load(){return W(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.dart)),[],import.meta.url)}}),Q.of({name:`diff`,extensions:[`diff`,`patch`],load(){return W(()=>import(`./diff-ChtP43wD.js`).then(e=>$(e.diff)),[],import.meta.url)}}),Q.of({name:`Dockerfile`,filename:/^Dockerfile$/,load(){return W(()=>import(`./dockerfile-BLkNEvjs.js`).then(e=>$(e.dockerFile)),__vite__mapDeps([27,28]),import.meta.url)}}),Q.of({name:`DTD`,extensions:[`dtd`],load(){return W(()=>import(`./dtd-DTF72YNO.js`).then(e=>$(e.dtd)),[],import.meta.url)}}),Q.of({name:`Dylan`,extensions:[`dylan`,`dyl`,`intr`],load(){return W(()=>import(`./dylan-C6jEEEk-.js`).then(e=>$(e.dylan)),[],import.meta.url)}}),Q.of({name:`EBNF`,load(){return W(()=>import(`./ebnf-D4c0_ac3.js`).then(e=>$(e.ebnf)),[],import.meta.url)}}),Q.of({name:`ECL`,extensions:[`ecl`],load(){return W(()=>import(`./ecl-BSZaIHnp.js`).then(e=>$(e.ecl)),[],import.meta.url)}}),Q.of({name:`edn`,extensions:[`edn`],load(){return W(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`Eiffel`,extensions:[`e`],load(){return W(()=>import(`./eiffel-BEjRio4Q.js`).then(e=>$(e.eiffel)),[],import.meta.url)}}),Q.of({name:`Elm`,extensions:[`elm`],load(){return W(()=>import(`./elm-Cshzl8qu.js`).then(e=>$(e.elm)),[],import.meta.url)}}),Q.of({name:`Erlang`,extensions:[`erl`],load(){return W(()=>import(`./erlang-DaB2Rkuy.js`).then(e=>$(e.erlang)),[],import.meta.url)}}),Q.of({name:`Esper`,load(){return W(()=>import(`./sql-DcCJ9jop.js`).then(e=>$(e.esper)),[],import.meta.url)}}),Q.of({name:`Factor`,extensions:[`factor`],load(){return W(()=>import(`./factor-D7LVTn2l.js`).then(e=>$(e.factor)),__vite__mapDeps([29,28]),import.meta.url)}}),Q.of({name:`FCL`,load(){return W(()=>import(`./fcl-ClOhbFR7.js`).then(e=>$(e.fcl)),[],import.meta.url)}}),Q.of({name:`Forth`,extensions:[`forth`,`fth`,`4th`],load(){return W(()=>import(`./forth-Cezjo90N.js`).then(e=>$(e.forth)),[],import.meta.url)}}),Q.of({name:`Fortran`,extensions:[`f`,`for`,`f77`,`f90`,`f95`],load(){return W(()=>import(`./fortran-Bt6PBEDR.js`).then(e=>$(e.fortran)),[],import.meta.url)}}),Q.of({name:`F#`,alias:[`fsharp`],extensions:[`fs`],load(){return W(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.fSharp)),[],import.meta.url)}}),Q.of({name:`Gas`,extensions:[`s`],load(){return W(()=>import(`./gas-BHEdbvp9.js`).then(e=>$(e.gas)),[],import.meta.url)}}),Q.of({name:`Gherkin`,extensions:[`feature`],load(){return W(()=>import(`./gherkin-oBAE_ms0.js`).then(e=>$(e.gherkin)),[],import.meta.url)}}),Q.of({name:`Groovy`,extensions:[`groovy`,`gradle`],filename:/^Jenkinsfile$/,load(){return W(()=>import(`./groovy-BC3IOsC8.js`).then(e=>$(e.groovy)),[],import.meta.url)}}),Q.of({name:`Haskell`,extensions:[`hs`],load(){return W(()=>import(`./haskell-BRsoo5mP.js`).then(e=>$(e.haskell)),[],import.meta.url)}}),Q.of({name:`Haxe`,extensions:[`hx`],load(){return W(()=>import(`./haxe-DIz0ZZqd.js`).then(e=>$(e.haxe)),[],import.meta.url)}}),Q.of({name:`HXML`,extensions:[`hxml`],load(){return W(()=>import(`./haxe-DIz0ZZqd.js`).then(e=>$(e.hxml)),[],import.meta.url)}}),Q.of({name:`HTTP`,load(){return W(()=>import(`./http-CLVgA2GD.js`).then(e=>$(e.http)),[],import.meta.url)}}),Q.of({name:`IDL`,extensions:[`pro`],load(){return W(()=>import(`./idl-BUZw3wgd.js`).then(e=>$(e.idl)),[],import.meta.url)}}),Q.of({name:`JSON-LD`,alias:[`jsonld`],extensions:[`jsonld`],load(){return W(()=>import(`./javascript-9Tg8ixDm.js`).then(e=>$(e.jsonld)),[],import.meta.url)}}),Q.of({name:`Julia`,extensions:[`jl`],load(){return W(()=>import(`./julia-CQfgDRfP.js`).then(e=>$(e.julia)),[],import.meta.url)}}),Q.of({name:`Kotlin`,extensions:[`kt`,`kts`],load(){return W(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.kotlin)),[],import.meta.url)}}),Q.of({name:`LiveScript`,alias:[`ls`],extensions:[`ls`],load(){return W(()=>import(`./livescript-BXxG0Yva.js`).then(e=>$(e.liveScript)),[],import.meta.url)}}),Q.of({name:`Lua`,extensions:[`lua`],load(){return W(()=>import(`./lua-CiA1ziua.js`).then(e=>$(e.lua)),[],import.meta.url)}}),Q.of({name:`mIRC`,extensions:[`mrc`],load(){return W(()=>import(`./mirc-C9zpzAZU.js`).then(e=>$(e.mirc)),[],import.meta.url)}}),Q.of({name:`Mathematica`,extensions:[`m`,`nb`,`wl`,`wls`],load(){return W(()=>import(`./mathematica-u8YMmbU0.js`).then(e=>$(e.mathematica)),[],import.meta.url)}}),Q.of({name:`Modelica`,extensions:[`mo`],load(){return W(()=>import(`./modelica-CqHI_q-D.js`).then(e=>$(e.modelica)),[],import.meta.url)}}),Q.of({name:`MUMPS`,extensions:[`mps`],load(){return W(()=>import(`./mumps-CW_TBmxz.js`).then(e=>$(e.mumps)),[],import.meta.url)}}),Q.of({name:`Mbox`,extensions:[`mbox`],load(){return W(()=>import(`./mbox-BEMVcqjs.js`).then(e=>$(e.mbox)),[],import.meta.url)}}),Q.of({name:`Nginx`,filename:/nginx.*\.conf$/i,load(){return W(()=>import(`./nginx-BMaDbqW3.js`).then(e=>$(e.nginx)),[],import.meta.url)}}),Q.of({name:`NSIS`,extensions:[`nsh`,`nsi`],load(){return W(()=>import(`./nsis-AQ_alPln.js`).then(e=>$(e.nsis)),__vite__mapDeps([30,28]),import.meta.url)}}),Q.of({name:`NTriples`,extensions:[`nt`,`nq`],load(){return W(()=>import(`./ntriples-d28e9m0E.js`).then(e=>$(e.ntriples)),[],import.meta.url)}}),Q.of({name:`Objective-C`,alias:[`objective-c`,`objc`],extensions:[`m`],load(){return W(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.objectiveC)),[],import.meta.url)}}),Q.of({name:`Objective-C++`,alias:[`objective-c++`,`objc++`],extensions:[`mm`],load(){return W(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.objectiveCpp)),[],import.meta.url)}}),Q.of({name:`OCaml`,extensions:[`ml`,`mli`,`mll`,`mly`],load(){return W(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.oCaml)),[],import.meta.url)}}),Q.of({name:`Octave`,extensions:[`m`],load(){return W(()=>import(`./octave-D2Q8cUp1.js`).then(e=>$(e.octave)),[],import.meta.url)}}),Q.of({name:`Oz`,extensions:[`oz`],load(){return W(()=>import(`./oz-BwTct_5T.js`).then(e=>$(e.oz)),[],import.meta.url)}}),Q.of({name:`Pascal`,extensions:[`p`,`pas`],load(){return W(()=>import(`./pascal-Dp_KdFgX.js`).then(e=>$(e.pascal)),[],import.meta.url)}}),Q.of({name:`Perl`,extensions:[`pl`,`pm`],load(){return W(()=>import(`./perl-CdEHsPfU.js`).then(e=>$(e.perl)),[],import.meta.url)}}),Q.of({name:`Pig`,extensions:[`pig`],load(){return W(()=>import(`./pig-AF4Hwhju.js`).then(e=>$(e.pig)),[],import.meta.url)}}),Q.of({name:`PowerShell`,extensions:[`ps1`,`psd1`,`psm1`],load(){return W(()=>import(`./powershell-CzG71I4L.js`).then(e=>$(e.powerShell)),[],import.meta.url)}}),Q.of({name:`Properties files`,alias:[`ini`,`properties`],extensions:[`properties`,`ini`,`in`],load(){return W(()=>import(`./properties-C357ku5U.js`).then(e=>$(e.properties)),[],import.meta.url)}}),Q.of({name:`ProtoBuf`,extensions:[`proto`],load(){return W(()=>import(`./protobuf-D1ij_kNL.js`).then(e=>$(e.protobuf)),[],import.meta.url)}}),Q.of({name:`Pug`,alias:[`jade`],extensions:[`pug`,`jade`],load(){return W(()=>import(`./pug-Bugr-47h.js`).then(e=>$(e.pug)),__vite__mapDeps([31,32]),import.meta.url)}}),Q.of({name:`Puppet`,extensions:[`pp`],load(){return W(()=>import(`./puppet-B4hC2X4m.js`).then(e=>$(e.puppet)),[],import.meta.url)}}),Q.of({name:`Q`,extensions:[`q`],load(){return W(()=>import(`./q-B9NhS7L_.js`).then(e=>$(e.q)),[],import.meta.url)}}),Q.of({name:`R`,alias:[`rscript`],extensions:[`r`,`R`],load(){return W(()=>import(`./r-DADKenSm.js`).then(e=>$(e.r)),[],import.meta.url)}}),Q.of({name:`RPM Changes`,load(){return W(()=>import(`./rpm-gpDK5sbt.js`).then(e=>$(e.rpmChanges)),[],import.meta.url)}}),Q.of({name:`RPM Spec`,extensions:[`spec`],load(){return W(()=>import(`./rpm-gpDK5sbt.js`).then(e=>$(e.rpmSpec)),[],import.meta.url)}}),Q.of({name:`Ruby`,alias:[`jruby`,`macruby`,`rake`,`rb`,`rbx`],extensions:[`rb`],filename:/^(Gemfile|Rakefile)$/,load(){return W(()=>import(`./ruby-DsYpTuWg.js`).then(e=>$(e.ruby)),[],import.meta.url)}}),Q.of({name:`SAS`,extensions:[`sas`],load(){return W(()=>import(`./sas-C2OyD2Y6.js`).then(e=>$(e.sas)),[],import.meta.url)}}),Q.of({name:`Scala`,extensions:[`scala`],load(){return W(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.scala)),[],import.meta.url)}}),Q.of({name:`Scheme`,extensions:[`scm`,`ss`],load(){return W(()=>import(`./scheme-CyDdOh7e.js`).then(e=>$(e.scheme)),[],import.meta.url)}}),Q.of({name:`Shell`,alias:[`bash`,`sh`,`zsh`],extensions:[`sh`,`ksh`,`bash`],filename:/^PKGBUILD$/,load(){return W(()=>import(`./shell-Du5Qg9im.js`).then(e=>$(e.shell)),[],import.meta.url)}}),Q.of({name:`Sieve`,extensions:[`siv`,`sieve`],load(){return W(()=>import(`./sieve-BAxa3IjF.js`).then(e=>$(e.sieve)),[],import.meta.url)}}),Q.of({name:`Smalltalk`,extensions:[`st`],load(){return W(()=>import(`./smalltalk-BLp5-jwC.js`).then(e=>$(e.smalltalk)),[],import.meta.url)}}),Q.of({name:`Solr`,load(){return W(()=>import(`./solr-BBopId9w.js`).then(e=>$(e.solr)),[],import.meta.url)}}),Q.of({name:`SML`,extensions:[`sml`,`sig`,`fun`,`smackspec`],load(){return W(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.sml)),[],import.meta.url)}}),Q.of({name:`SPARQL`,alias:[`sparul`],extensions:[`rq`,`sparql`],load(){return W(()=>import(`./sparql-Dz-mlCAC.js`).then(e=>$(e.sparql)),[],import.meta.url)}}),Q.of({name:`Spreadsheet`,alias:[`excel`,`formula`],load(){return W(()=>import(`./spreadsheet-CTIncYxj.js`).then(e=>$(e.spreadsheet)),[],import.meta.url)}}),Q.of({name:`Squirrel`,extensions:[`nut`],load(){return W(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.squirrel)),[],import.meta.url)}}),Q.of({name:`Stylus`,extensions:[`styl`],load(){return W(()=>import(`./stylus-DLLZ8dgm.js`).then(e=>$(e.stylus)),[],import.meta.url)}}),Q.of({name:`Swift`,extensions:[`swift`],load(){return W(()=>import(`./swift-DKB6_1j6.js`).then(e=>$(e.swift)),[],import.meta.url)}}),Q.of({name:`sTeX`,load(){return W(()=>import(`./stex-sDrdk2BW.js`).then(e=>$(e.stex)),[],import.meta.url)}}),Q.of({name:`LaTeX`,alias:[`tex`],extensions:[`text`,`ltx`,`tex`],load(){return W(()=>import(`./stex-sDrdk2BW.js`).then(e=>$(e.stex)),[],import.meta.url)}}),Q.of({name:`SystemVerilog`,extensions:[`v`,`sv`,`svh`],load(){return W(()=>import(`./verilog-D-x6ne0Z.js`).then(e=>$(e.verilog)),[],import.meta.url)}}),Q.of({name:`Tcl`,extensions:[`tcl`],load(){return W(()=>import(`./tcl-BGfruO1u.js`).then(e=>$(e.tcl)),[],import.meta.url)}}),Q.of({name:`Textile`,extensions:[`textile`],load(){return W(()=>import(`./textile-DWBqthVk.js`).then(e=>$(e.textile)),[],import.meta.url)}}),Q.of({name:`TiddlyWiki`,load(){return W(()=>import(`./tiddlywiki-VlUiK86J.js`).then(e=>$(e.tiddlyWiki)),[],import.meta.url)}}),Q.of({name:`Tiki wiki`,load(){return W(()=>import(`./tiki-CxVlf5KZ.js`).then(e=>$(e.tiki)),[],import.meta.url)}}),Q.of({name:`TOML`,extensions:[`toml`],load(){return W(()=>import(`./toml-LvoKBwCs.js`).then(e=>$(e.toml)),[],import.meta.url)}}),Q.of({name:`Troff`,extensions:[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],load(){return W(()=>import(`./troff-C2dAgh7P.js`).then(e=>$(e.troff)),[],import.meta.url)}}),Q.of({name:`TTCN`,extensions:[`ttcn`,`ttcn3`,`ttcnpp`],load(){return W(()=>import(`./ttcn-BePYh-hG.js`).then(e=>$(e.ttcn)),[],import.meta.url)}}),Q.of({name:`TTCN_CFG`,extensions:[`cfg`],load(){return W(()=>import(`./ttcn-cfg-CY0aot7Q.js`).then(e=>$(e.ttcnCfg)),[],import.meta.url)}}),Q.of({name:`Turtle`,extensions:[`ttl`],load(){return W(()=>import(`./turtle-BDLWE2cD.js`).then(e=>$(e.turtle)),[],import.meta.url)}}),Q.of({name:`Web IDL`,extensions:[`webidl`],load(){return W(()=>import(`./webidl-D5jiJvOU.js`).then(e=>$(e.webIDL)),[],import.meta.url)}}),Q.of({name:`VB.NET`,extensions:[`vb`],load(){return W(()=>import(`./vb-BthdM_4N.js`).then(e=>$(e.vb)),[],import.meta.url)}}),Q.of({name:`VBScript`,extensions:[`vbs`],load(){return W(()=>import(`./vbscript-D9f6rSsU.js`).then(e=>$(e.vbScript)),[],import.meta.url)}}),Q.of({name:`Velocity`,extensions:[`vtl`],load(){return W(()=>import(`./velocity-CqftRsjg.js`).then(e=>$(e.velocity)),[],import.meta.url)}}),Q.of({name:`Verilog`,extensions:[`v`],load(){return W(()=>import(`./verilog-D-x6ne0Z.js`).then(e=>$(e.verilog)),[],import.meta.url)}}),Q.of({name:`VHDL`,extensions:[`vhd`,`vhdl`],load(){return W(()=>import(`./vhdl-CMrOq2q1.js`).then(e=>$(e.vhdl)),[],import.meta.url)}}),Q.of({name:`XQuery`,extensions:[`xy`,`xquery`,`xq`,`xqm`,`xqy`],load(){return W(()=>import(`./xquery-fj_R-kMw.js`).then(e=>$(e.xQuery)),[],import.meta.url)}}),Q.of({name:`Yacas`,extensions:[`ys`],load(){return W(()=>import(`./yacas-CXXgtw0p.js`).then(e=>$(e.yacas)),[],import.meta.url)}}),Q.of({name:`Z80`,extensions:[`z80`],load(){return W(()=>import(`./z80-CL1naaMV.js`).then(e=>$(e.z80)),[],import.meta.url)}}),Q.of({name:`MscGen`,extensions:[`mscgen`,`mscin`,`msc`],load(){return W(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.mscgen)),[],import.meta.url)}}),Q.of({name:`Xù`,extensions:[`xu`],load(){return W(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.xu)),[],import.meta.url)}}),Q.of({name:`MsGenny`,extensions:[`msgenny`],load(){return W(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.msgenny)),[],import.meta.url)}}),Q.of({name:`Vue`,extensions:[`vue`],load(){return W(()=>import(`./dist-J2Ks-ZqQ.js`).then(e=>e.vue()),__vite__mapDeps([33,12,10,8,13]),import.meta.url)}}),Q.of({name:`Angular Template`,load(){return W(()=>import(`./dist-B9a_6axG.js`).then(e=>e.angular()),__vite__mapDeps([34,12,10,8,13]),import.meta.url)}})];function JR(e){let t=String(e||``).split(`/`).pop()||``,n=t.lastIndexOf(`.`);return n>=0?t.slice(n):``}function YR(e){return Q.matchFilename(qR,`file${e}`)}function XR({content:e,path:t,readOnly:n=!1,onSave:r,onDirtyChange:i,onContentChange:a,getContentRef:o}){let s=(0,b.useRef)(null),c=(0,b.useRef)(null),l=(0,b.useRef)(new Lx),u=(0,b.useRef)(new Lx),d=(0,b.useRef)(new Lx),f=(0,b.useRef)(!1),p=(0,b.useRef)(r),m=(0,b.useRef)(i),h=(0,b.useRef)(a);(0,b.useEffect)(()=>{p.current=r,m.current=i,h.current=a},[r,i,a]);let g=(0,b.useCallback)(e=>{f.current!==e&&(f.current=e,m.current?.(e))},[]);return(0,b.useEffect)(()=>{if(!s.current)return;let r=document.documentElement.classList.contains(`dark`),i=eO.of([{key:`Mod-s`,run:e=>{let t=e.state.doc.toString();return p.current?.(t),g(!1),!0},preventDefault:!0}]),a=new Y({state:mS.create({doc:e,extensions:[kk(),Nk(),wN(),mM(),vO(),DO(),mS.allowMultipleSelections.of(!0),Bj(),bM(CM,{fallback:!0}),NM(),ER(),UR(),IO(),zO(),OO(),lI(),eO.of([...MR,...jF,...QI,...UN,...aM,...WR,MF]),i,Y.updateListener.of(e=>{e.docChanged&&(g(!0),h.current?.(e.state.doc.toString()))}),d.current.of(mS.readOnly.of(n)),l.current.of([]),u.current.of(r?YF:[]),Y.theme({"&":{height:`100%`},".cm-scroller":{overflow:`auto`}})]}),parent:s.current});c.current=a,o&&(o.current=()=>a.state.doc.toString());let f=YR(JR(t));return f&&f.load().then(e=>{c.current&&c.current.dispatch({effects:l.current.reconfigure(e)})}).catch(()=>{}),()=>{a.destroy(),c.current=null,o&&(o.current=null)}},[]),(0,b.useEffect)(()=>{let t=c.current;if(!t)return;let n=t.state.doc.toString();n!==e&&(t.dispatch({changes:{from:0,to:n.length,insert:e}}),g(!1))},[e,g]),(0,b.useEffect)(()=>{let e=c.current;if(!e)return;let n=YR(JR(t));n?n.load().then(e=>{c.current&&c.current.dispatch({effects:l.current.reconfigure(e)})}).catch(()=>{}):e.dispatch({effects:l.current.reconfigure([])})},[t]),(0,b.useEffect)(()=>{let e=c.current;e&&e.dispatch({effects:d.current.reconfigure(mS.readOnly.of(n))})},[n]),(0,b.useEffect)(()=>{let e=new MutationObserver(()=>{let e=c.current;if(!e)return;let t=document.documentElement.classList.contains(`dark`);e.dispatch({effects:u.current.reconfigure(t?YF:[])})});return e.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>e.disconnect()},[]),(0,R.jsx)(`div`,{ref:s,className:`h-full w-full overflow-hidden [&_.cm-editor]:h-full [&_.cm-scroller]:auto`})}function ZR({content:e,objectUrl:t,kind:n,filename:r,path:i}){return n===`markdown`?(0,R.jsx)(Uy,{content:e||``}):n===`image`&&t?(0,R.jsx)(`div`,{className:`flex items-center justify-center p-4`,children:(0,R.jsx)(`img`,{src:t,alt:r,className:`max-h-[70vh] max-w-full rounded object-contain`})}):n===`pdf`&&t?(0,R.jsx)(`iframe`,{src:t,title:r,className:`h-full w-full border-0`}):(n===`text`||n===`code`)&&e!==null?(0,R.jsx)(XR,{content:e,path:i||r,readOnly:!0,onSave:()=>{},onDirtyChange:()=>{},getContentRef:{current:()=>e||``}}):(0,R.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,R.jsx)(`div`,{className:`w-full max-w-md rounded-2xl border border-dashed border-slate-300 bg-slate-50 px-5 py-5 text-slate-500 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-400`,children:`该文件类型暂不支持在线预览,请直接下载查看。`})})}function QR(e){return e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}function $R(e){let t=e.endsWith(`/`)?e:`${e}/`;if(typeof window>`u`)return`'self'`;try{return new URL(t,window.location.origin).toString()}catch{return`'self'`}}function ez(...e){return Array.from(new Set(e.filter(e=>!!e))).join(` `)}function tz(e){let t=e?$R(e):void 0,n=ez(`'unsafe-inline'`,`'unsafe-eval'`,`'self'`,`https:`,t),r=ez(`'self'`,`https:`,t);return[`default-src 'none'`,`script-src ${n}`,`style-src 'unsafe-inline' data: ${r}`,`img-src data: blob: ${r}`,`font-src data: ${r}`,`media-src data: blob: ${r}`,`worker-src blob:`,`connect-src 'none'`,`form-action 'none'`,`base-uri 'self'`].join(`; `)}function nz(e){try{let t=new URL(e,window.location.href);return[`http:`,`https:`,`mailto:`].includes(t.protocol)}catch{return!1}}function rz(e,t={}){let{channelId:n,basePath:r}=typeof t==`string`?{channelId:t}:t,i=tz(r),a=`<script>
134
134
  function ksadkScrollToHash(rawHref) {
135
135
  if (!rawHref || rawHref === '#') return;
136
136
  var rawId = rawHref.slice(1);
@@ -162,4 +162,4 @@ document.addEventListener('click', function(event) {
162
162
  }, '*');
163
163
  }
164
164
  }, true);
165
- <\/script>`,o=`${`<meta http-equiv="Content-Security-Policy" content="${QR(i)}">`}${r?`<base href="${QR(r)}">`:``}${a}`;return/<head[^>]*>/i.test(e)?e.replace(/<head[^>]*>/i,`$&${o}`):`${o}${e}`}function iz(e,t){let n=(0,b.useRef)(null);(0,b.useEffect)(()=>(n.current=n=>{if(n.source!==e.current?.contentWindow||n.data?.type!==`ksadk:linkClick`||t&&n.data?.channelId!==t)return;let r=n.data?.href;typeof r==`string`&&r&&nz(r)&&window.open(r,`_blank`,`noopener,noreferrer`)},window.addEventListener(`message`,n.current),()=>{n.current&&window.removeEventListener(`message`,n.current)}),[e,t])}function az({content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i,isMobile:a}){let o=(0,b.useRef)(null),s=(0,b.useId)(),[c,l]=(0,b.useState)(`preview`),u=De(t),d=Ee(t),f=(0,b.useCallback)(()=>rz(e,{basePath:u,channelId:s}),[e,u,s]),[p,m]=(0,b.useState)(f());(0,b.useEffect)(()=>{let e=setTimeout(()=>{m(f())},300);return()=>clearTimeout(e)},[f]),iz(o,s);let h=(0,b.useCallback)(()=>{let e=new Blob([p],{type:`text/html;charset=utf-8`}),t=URL.createObjectURL(e),n=window.open(t,`_blank`,`noopener,noreferrer`);window.setTimeout(()=>URL.revokeObjectURL(t),3e4),n||window.open(d,`_blank`,`noopener,noreferrer`)},[d,p]);return a?(0,R.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-slate-200 px-2 py-1.5 dark:border-slate-700`,children:[(0,R.jsxs)(`button`,{onClick:()=>l(`editor`),className:L(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,c===`editor`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,R.jsx)(Br,{className:`h-3.5 w-3.5`}),`编辑`]}),(0,R.jsxs)(`button`,{onClick:()=>l(`preview`),className:L(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,c===`preview`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,R.jsx)(Gr,{className:`h-3.5 w-3.5`}),`预览`]})]}),c===`editor`?(0,R.jsx)(XR,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}):(0,R.jsx)(`iframe`,{ref:o,srcDoc:p,sandbox:`allow-scripts allow-downloads allow-same-origin`,title:`HTML 预览`,className:`h-full w-full border-0 bg-white`})]}):c===`editor`?(0,R.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,R.jsx)(XR,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}),(0,R.jsxs)(`button`,{onClick:()=>l(`preview`),className:`absolute right-3 top-3 z-10 inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,R.jsx)(Gr,{className:`h-3.5 w-3.5`}),`预览`]})]}):(0,R.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,R.jsx)(`iframe`,{ref:o,srcDoc:p,sandbox:`allow-scripts allow-downloads allow-same-origin`,title:`HTML 预览`,className:`h-full w-full border-0 bg-white`}),(0,R.jsxs)(`div`,{className:`absolute right-3 top-3 z-10 flex gap-1.5`,children:[(0,R.jsxs)(`button`,{onClick:h,className:`inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,title:`在新窗口中打开当前预览`,children:[(0,R.jsx)(Wr,{className:`h-3.5 w-3.5`}),`新窗口`]}),(0,R.jsxs)(`button`,{onClick:()=>l(`editor`),className:`inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,R.jsx)(Br,{className:`h-3.5 w-3.5`}),`编辑`]})]})]})}function oz(e){e.current&&clearTimeout(e.current)}function sz({content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i,isMobile:a}){let[o,s]=(0,b.useState)(`editor`),[c,l]=(0,b.useState)(e),u=(0,b.useRef)(null);return(0,b.useEffect)(()=>(oz(u),u.current=setTimeout(()=>l(e),300),()=>oz(u)),[e]),a?(0,R.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-slate-200/30 px-2 py-1.5 dark:border-slate-700/30`,children:[(0,R.jsxs)(`button`,{onClick:()=>s(`editor`),className:L(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,o===`editor`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,R.jsx)(Br,{className:`h-3.5 w-3.5`}),`编辑`]}),(0,R.jsxs)(`button`,{onClick:()=>s(`preview`),className:L(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,o===`preview`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,R.jsx)(Gr,{className:`h-3.5 w-3.5`}),`预览`]})]}),o===`editor`?(0,R.jsx)(XR,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}):(0,R.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:(0,R.jsx)(Uy,{content:c})})]}):o===`editor`?(0,R.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,R.jsx)(XR,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}),(0,R.jsxs)(`button`,{onClick:()=>s(`preview`),className:`absolute right-3 top-3 z-10 inline-flex items-center gap-1.5 rounded-lg border border-slate-200/30 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,R.jsx)(Gr,{className:`h-3.5 w-3.5`}),`预览`]})]}):(0,R.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,R.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:(0,R.jsx)(Uy,{content:c})}),(0,R.jsxs)(`button`,{onClick:()=>s(`editor`),className:`absolute right-3 top-3 z-10 inline-flex items-center gap-1.5 rounded-lg border border-slate-200/30 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,R.jsx)(Br,{className:`h-3.5 w-3.5`}),`编辑`]})]})}var cz=`/agentengine/api/v1/GetWorkspaceFileContent`,lz=4e3;function uz(e){let t=we(e);if(!t||t===`.`)return`.`;let n=t.split(`/`).filter(Boolean);return n.length<=1?`.`:n.slice(0,-1).join(`/`)}function dz(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function fz(e){let t=Number(e);return!Number.isFinite(t)||t<=0?`0 B`:t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(1)} GB`}var pz=[{label:`Markdown`,detail:`.md .markdown .mdx`},{label:`代码/文本`,detail:`.py .js .ts .tsx .json .yaml .log .txt`},{label:`图片`,detail:`PNG JPG GIF WebP SVG`},{label:`PDF`,detail:`.pdf`},{label:`表格文本`,detail:`CSV TSV`}];function mz(e){return Ee(e)}function hz({label:e,showSupportedTypes:t=!1}){return(0,R.jsx)(`div`,{className:`flex h-full min-h-[16rem] flex-col items-center justify-center px-6 text-center`,children:(0,R.jsxs)(`div`,{className:`w-full max-w-md rounded-2xl border border-dashed border-slate-300 bg-slate-50 px-5 py-5 text-slate-500 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-400`,children:[(0,R.jsx)(`div`,{children:e}),t?(0,R.jsxs)(`div`,{className:`mt-4 text-left`,children:[(0,R.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-[0.12em] text-slate-400`,children:`支持在线预览`}),(0,R.jsx)(`div`,{className:`mt-2 grid gap-2`,children:pz.map(e=>(0,R.jsxs)(`div`,{className:`rounded-xl border border-slate-200 bg-white px-3 py-2 dark:border-slate-800 dark:bg-slate-950`,children:[(0,R.jsx)(`div`,{className:`text-sm font-medium text-slate-700 dark:text-slate-200`,children:e.label}),(0,R.jsx)(`div`,{className:`mt-0.5 font-mono text-[11px] text-slate-400`,children:e.detail})]},e.label))}),(0,R.jsx)(`div`,{className:`mt-3 text-xs leading-5 text-slate-400`,children:`Word、Excel、PPT 当前不支持在线预览,可下载后查看。`})]}):null]})})}function gz({agentId:e,capability:t,open:n,onClose:r,isFullscreen:i=!1,onToggleFullscreen:a,isMobile:o=!1,api:s}){let c=(0,b.useRef)(null),l=(0,b.useRef)(null),[u,d]=(0,b.useState)(!1),[f,p]=(0,b.useState)(`.`),[m,h]=(0,b.useState)([]),[g,_]=(0,b.useState)(!1),[v,y]=(0,b.useState)(!1),[x,S]=(0,b.useState)(!1),[C,w]=(0,b.useState)(``),[T,E]=(0,b.useState)(null),[D,O]=(0,b.useState)(null),[ee,te]=(0,b.useState)(!1),[ne,re]=(0,b.useState)(!1),ie=(0,b.useRef)(null),ae=(0,b.useRef)(null),oe=(0,b.useRef)(`selection`),k=(0,b.useRef)(Le()),A=(0,b.useMemo)(()=>m.find(e=>e.Path===T)??null,[m,T]),se=(0,b.useMemo)(()=>A?Fe({path:A.Path,mimeType:A.MimeType}):null,[A]),ce=(0,b.useCallback)(()=>ee?window.confirm(`当前文件有未保存的更改,确定要离开吗?`):!0,[ee]),le=t.ContentPath||cz,ue=t.RootLabel||`Workspace`,j=ue?`${ue.charAt(0).toUpperCase()}${ue.slice(1)}`:`Workspace`,de=ke(f),fe=(0,b.useCallback)(()=>{l.current&&=(URL.revokeObjectURL(l.current),null)},[]);(0,b.useEffect)(()=>()=>fe(),[fe]);let M=(0,b.useCallback)(async(t,n={})=>{let r=!!n.background;r?y(!0):_(!0),r||w(``);try{let n=await s.listWorkspaceFiles(e,t,!1),i=we(String(n?.Path||t||`.`)),a=Array.isArray(n?.Entries)?n.Entries:[];p(i),h(a),oe.current=r?`background-refresh`:`selection`,E(e=>{if(e){let t=a.find(t=>t.Path===e);if(t&&t.Type===`file`)return e}return a.find(e=>e.Type===`file`)?.Path??null})}catch(e){console.error(`Failed to load workspace entries:`,e),r||w(e instanceof Error?e.message:String(e))}finally{r?y(!1):_(!1)}},[e,s]);(0,b.useEffect)(()=>{!n||u||(d(!0),M(`.`))},[u,M,n]),(0,b.useEffect)(()=>{if(!n||ee||!u)return;let e=window.setInterval(()=>{M(f,{background:!0})},lz);return()=>window.clearInterval(e)},[f,ee,u,M,n]);let pe=(0,b.useCallback)(async t=>{let n=k.current.next(t.Path),r=Ne({path:t.Path,mimeType:t.MimeType});if(ae.current=t.Path,r===`unsupported`){fe(),O({path:t.Path,kind:r,status:`ready`,mimeType:t.MimeType??void 0});return}fe(),O({path:t.Path,kind:r,status:`loading`,mimeType:t.MimeType??void 0});try{let r=await s.getWorkspaceFileContent(e,t.Path,{asText:!1});if(!k.current.isCurrent(n))return;if(r instanceof Blob){let e=t.MimeType||``,i=Ne({path:t.Path,mimeType:e});if(i===`image`||i===`pdf`){let n=URL.createObjectURL(r);l.current=n,O({path:t.Path,kind:i,status:`ready`,mimeType:e,objectUrl:n});return}let a=await r.text();if(!k.current.isCurrent(n))return;let o=Ne({path:t.Path,mimeType:e});O({path:t.Path,kind:o,status:`ready`,mimeType:e,content:a})}else{let e=t.MimeType||``,n=Ne({path:t.Path,mimeType:e});O({path:t.Path,kind:n,status:`ready`,mimeType:e,content:r})}}catch(e){if(!k.current.isCurrent(n))return;console.error(`Failed to preview workspace file:`,e),O({path:t.Path,kind:r,status:`error`,mimeType:t.MimeType??void 0,error:e instanceof Error?e.message:String(e)})}},[e,s,fe]);(0,b.useEffect)(()=>{if(!A||A.Type!==`file`){fe(),O(null),te(!1),ae.current=null;return}if(oe.current===`background-refresh`&&ae.current===A.Path){oe.current=`selection`;return}oe.current=`selection`,pe(A)},[fe,pe,A]);let me=async n=>{if(!(!n||n.length===0)){S(!0),w(``);try{for(let r of Array.from(n)){if(r.size>t.MaxUploadBytes)throw Error(`文件 ${r.name} 超过上传上限`);let n=Oe(f)?r.name:`${f}/${r.name}`,i=new FormData;i.append(`file`,r),i.append(`AgentId`,e),i.append(`Path`,n),await s.addWorkspaceFile(i)}await M(f)}catch(e){console.error(`Failed to upload workspace files:`,e),w(e instanceof Error?e.message:String(e))}finally{c.current&&(c.current.value=``),S(!1)}}},he=async n=>{if(!t.SupportsDelete)return;let r=we(n.Path);if(window.confirm(`删除 ${r} ?`)){w(``);try{await s.deleteWorkspaceFile(e,r),T&&we(T)===r&&(E(null),te(!1)),await M(n.Type===`directory`&&(we(f)===r||we(f).startsWith(`${r}/`))?uz(r):f)}catch(e){console.error(`Failed to delete workspace file:`,e),w(e instanceof Error?e.message:String(e))}}},ge=()=>!A||A.Type!==`file`?(0,R.jsx)(hz,{label:`从左侧选择文件后在这里查看内容预览。`,showSupportedTypes:!0}):!D||D.path!==A.Path||D.status===`loading`?(0,R.jsx)(`div`,{className:`flex h-full min-h-[16rem] items-center justify-center`,children:(0,R.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full border border-slate-200 bg-white px-4 py-2 text-sm text-slate-500 shadow-sm dark:border-slate-800 dark:bg-slate-900 dark:text-slate-400`,children:[(0,R.jsx)(Xr,{className:`h-4 w-4 animate-spin`}),`正在加载预览...`]})}):D.status===`error`?(0,R.jsx)(hz,{label:D.error||`文件预览加载失败。`}):D.kind===`markdown`?(0,R.jsx)(sz,{content:D.content||``,path:A.Path,onSave:_e,onDirtyChange:te,getContentRef:ie,isMobile:o}):D.kind===`image`&&D.objectUrl?(0,R.jsx)(ZR,{content:null,objectUrl:D.objectUrl,kind:`image`,filename:A.Name,mimeType:D.mimeType||``}):D.kind===`pdf`&&D.objectUrl?(0,R.jsx)(ZR,{content:null,objectUrl:D.objectUrl,kind:`pdf`,filename:A.Name,mimeType:D.mimeType||``}):D.kind===`html`?(0,R.jsx)(az,{content:D.content||``,path:A.Path,onSave:_e,onDirtyChange:te,getContentRef:ie,isMobile:o,agentId:e,contentPath:le}):D.kind===`text`||D.kind===`code`?(0,R.jsx)(XR,{content:D.content||``,path:A.Path,onSave:_e,onDirtyChange:te,getContentRef:ie}):(0,R.jsx)(ZR,{content:null,kind:`unsupported`,filename:A.Name,mimeType:D.mimeType||``}),_e=async t=>{if(A){re(!0),w(``);try{let n=new Blob([t],{type:A.MimeType||`text/plain`}),r=new FormData;r.append(`file`,n,A.Name),r.append(`AgentId`,e),r.append(`Path`,A.Path),await s.addWorkspaceFile(r),k.current.invalidate(),te(!1),O(e=>e&&e.path===A.Path?{...e,content:t}:e),ae.current=A.Path,await M(f,{background:!0})}catch(e){console.error(`Failed to save workspace file:`,e),w(e instanceof Error?e.message:String(e))}finally{re(!1)}}},ve=A?.Type===`file`&&D?.path===A.Path&&D.status===`ready`&&(D.kind===`text`||D.kind===`code`||D.kind===`html`||D.kind===`markdown`),ye=A?.Type===`file`&&D?.path===A.Path&&D.status===`ready`&&D.kind===`pdf`;return(0,R.jsxs)(`div`,{className:`flex h-full min-h-[22rem] w-full min-w-0 flex-col bg-white text-slate-800 dark:bg-slate-950 dark:text-slate-200`,children:[(0,R.jsxs)(`div`,{className:`flex h-14 flex-shrink-0 items-center gap-3 border-b border-slate-200/30 px-4 dark:border-slate-800/40`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,R.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100`,children:j}),(0,R.jsx)(`div`,{className:`hidden h-4 w-px bg-slate-200/70 dark:bg-slate-800 sm:block`}),(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`flex-shrink-0 text-xs text-slate-400`,children:`当前目录`}),(0,R.jsx)(`div`,{className:`custom-scrollbar max-w-[min(42vw,34rem)] overflow-x-auto whitespace-nowrap rounded-md bg-slate-50 px-2 py-1 font-mono text-[11px] text-slate-600 dark:bg-slate-900 dark:text-slate-300`,title:`${de},来自 ListWorkspaceFiles 返回的 Data.Path 字段`,children:de})]}),(0,R.jsx)(`div`,{className:`hidden truncate text-[11px] text-slate-400 xl:block`,children:`工作区内相对路径,不是宿主机绝对路径。`})]}),(0,R.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-1.5`,children:[(0,R.jsx)(`input`,{ref:c,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void me(e.target.files)}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>c.current?.click(),disabled:x,className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium text-slate-600 transition hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-50 dark:text-slate-300 dark:hover:bg-slate-900`,title:`上传文件,上限 ${Math.floor(t.MaxUploadBytes/(1024*1024))}MB`,children:[(0,R.jsx)(hi,{className:`h-3.5 w-3.5`}),x?`上传中`:`上传`]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{let e=new URLSearchParams({Path:f}).toString();window.open(`/agentengine/api/v1/ExportWorkspaceZip?${e}`,`_blank`,`noopener,noreferrer`)},className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium text-slate-600 transition hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-slate-900`,title:`导出当前目录为 ZIP`,children:[(0,R.jsx)(ei,{className:`h-3.5 w-3.5`}),`导出`]}),a?(0,R.jsx)(`button`,{type:`button`,onClick:a,className:`rounded-lg p-1.5 text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-slate-900 dark:hover:text-slate-100`,"aria-label":i?`退出全屏`:`全屏查看 Workspace`,title:i?`退出全屏`:`全屏查看`,children:i?(0,R.jsx)($r,{className:`h-4 w-4`}):(0,R.jsx)(Zr,{className:`h-4 w-4`})}):null,r?(0,R.jsx)(`button`,{type:`button`,onClick:()=>{ce()&&r?.()},className:`rounded-lg p-1.5 text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-slate-900 dark:hover:text-slate-100`,"aria-label":`关闭 Workspace`,title:`关闭`,children:(0,R.jsx)(gi,{className:`h-4 w-4`})}):null]})]}),(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col md:flex-row`,children:[(0,R.jsxs)(`div`,{className:`flex w-full flex-col border-b border-slate-200/30 dark:border-slate-800/40 md:w-[13.5rem] md:border-b-0 md:border-r`,children:[(0,R.jsxs)(`div`,{className:`flex h-14 flex-shrink-0 items-center border-b border-slate-200/30 px-3 dark:border-slate-800/40`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`div`,{className:`text-xs font-medium text-slate-900 dark:text-slate-100`,children:`文件`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] text-slate-400`,children:[(0,R.jsxs)(`span`,{children:[m.length,` 项`]}),v?(0,R.jsx)(oi,{className:`h-3 w-3 animate-spin`,"aria-label":`正在同步 Workspace 目录`}):null]})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>{ce()&&M(uz(f))},disabled:g||Oe(f),className:`rounded-md p-1.5 text-slate-500 transition hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-40 dark:text-slate-400 dark:hover:bg-slate-900`,title:`返回上级目录`,children:(0,R.jsx)(Pr,{className:`h-4 w-4`})}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>{ce()&&M(f)},disabled:g,className:`rounded-md p-1.5 text-slate-500 transition hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-40 dark:text-slate-400 dark:hover:bg-slate-900`,title:`刷新目录`,children:(0,R.jsx)(oi,{className:`h-4 w-4 ${g?`animate-spin`:``}`})})]})]}),C?(0,R.jsx)(`div`,{className:`mt-3 rounded-xl border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-600 dark:border-red-900/60 dark:bg-red-950/40 dark:text-red-300`,children:C}):null]}),(0,R.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto px-2 py-2`,children:!u&&!n?(0,R.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`打开面板后加载 workspace 文件。`}):g?(0,R.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`正在加载目录...`}):m.length===0?(0,R.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`当前目录为空。`}):(0,R.jsx)(`div`,{className:`space-y-0.5`,children:m.map(e=>{let n=Ne({path:e.Path,mimeType:e.MimeType}),r=T===e.Path,i=e.Type===`file`?mz(e.Path):``;return(0,R.jsxs)(`div`,{title:e.Path,className:L(`group flex items-center gap-1 rounded-lg px-1.5 py-1 transition`,r?`bg-slate-100 text-slate-950 dark:bg-slate-800 dark:text-slate-50`:`text-slate-700 hover:bg-slate-50 dark:text-slate-300 dark:hover:bg-slate-900`),children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{if(e.Type===`directory`){M(e.Path);return}T!==e.Path&&!ce()||E(e.Path)},className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,R.jsx)(`div`,{className:L(`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-md`,r?`text-slate-900 dark:text-slate-50`:`text-slate-400 dark:text-slate-500`),children:e.Type===`directory`?(0,R.jsx)(Jr,{className:`h-3.5 w-3.5`}):n===`image`?(0,R.jsx)(Yr,{className:`h-3.5 w-3.5`}):n===`markdown`||n===`text`||n===`html`?(0,R.jsx)(Kr,{className:`h-3.5 w-3.5`}):(0,R.jsx)(qr,{className:`h-3.5 w-3.5`})}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`div`,{className:`truncate text-[13px] leading-5`,children:e.Name}),(0,R.jsx)(`div`,{className:L(`truncate text-[11px] leading-4`,r?`text-slate-500 dark:text-slate-400`:`text-slate-400`),children:e.Type===`directory`?`目录`:fz(e.SizeBytes)})]})]}),(0,R.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-0.5 opacity-0 transition group-hover:opacity-100`,children:[e.Type===`file`?(0,R.jsx)(`a`,{href:i,download:e.Name,className:L(`rounded-md p-1.5 transition`,r?`hover:bg-white dark:hover:bg-slate-700`:`hover:bg-slate-100 dark:hover:bg-slate-800`),title:`下载`,children:(0,R.jsx)(Hr,{className:`h-3.5 w-3.5`})}):null,t.SupportsDelete?(0,R.jsx)(`button`,{type:`button`,onClick:()=>void he(e),className:L(`rounded-md p-1.5 transition`,r?`hover:bg-white dark:hover:bg-slate-700`:`hover:bg-slate-100 dark:hover:bg-slate-800`),title:`删除`,children:(0,R.jsx)(mi,{className:`h-3.5 w-3.5`})}):null]})]},e.Path)})})})]}),(0,R.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,R.jsx)(`div`,{className:`flex h-14 flex-shrink-0 items-center border-b border-slate-200/30 px-4 dark:border-slate-800/40`,children:A?(0,R.jsxs)(`div`,{className:`flex w-full items-start justify-between gap-3`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100`,children:A.Name}),(0,R.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-[11px] text-slate-400`,children:A.Path}),(0,R.jsxs)(`div`,{className:`mt-1 text-[11px] text-slate-400`,children:[fz(A.SizeBytes),A.MimeType?` · ${A.MimeType}`:``,A.ModifiedAt?` · ${dz(A.ModifiedAt)}`:``]})]}),se===`text`||se===`code`||se===`html`||se===`markdown`?(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{let e=ie.current;e&&_e(e())},disabled:!ee||ne,className:L(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition`,ee&&!ne?`bg-blue-600 text-white hover:bg-blue-700`:`text-slate-400 dark:text-slate-500 cursor-not-allowed`),children:[(0,R.jsx)(si,{className:`h-3.5 w-3.5`}),ne?`保存中`:ee?`保存`:`已保存`]}):null]}):(0,R.jsxs)(`div`,{className:`w-full`,children:[(0,R.jsx)(`div`,{className:`text-sm font-semibold text-slate-900 dark:text-slate-100`,children:`文件预览`}),(0,R.jsx)(`div`,{className:`mt-0.5 text-xs text-slate-500 dark:text-slate-400`,children:`选择左侧文件后可在此查看内容。`})]})}),(0,R.jsx)(`div`,{className:L(`custom-scrollbar min-h-0 flex-1`,ye||ve?`overflow-hidden p-0`:`overflow-y-auto px-4 py-4`),children:ge()})]})]})]})}function _z({agentId:e,capability:t,workspacePanelOpen:n,workspacePanelWidth:r,workspacePanelFullscreen:i,isMobile:a,workspaceEnabled:o,workspaceFiles:s,workspacePanelPresentation:c,closeWorkspacePanel:l,handleWorkspacePanelResizeStart:u,api:d}){let f=c.renderMode===`inline`,p=c.renderMode===`sheet`;return!o||!s?null:(0,R.jsxs)(R.Fragment,{children:[f?(0,R.jsxs)(R.Fragment,{children:[n&&!i?(0,R.jsx)(`div`,{role:`separator`,"aria-label":`调整 Workspace 宽度`,"aria-orientation":`vertical`,onPointerDown:u,className:`hidden h-full w-1 cursor-col-resize bg-transparent transition-colors hover:bg-blue-200/60 dark:hover:bg-blue-900/50 md:block`}):null,(0,R.jsx)(`aside`,{style:n&&!i?{width:`${r}px`}:void 0,className:L(i?`fixed inset-0 z-40 flex h-[var(--app-height)] w-screen overflow-hidden bg-white dark:bg-slate-950`:`hidden h-full flex-shrink-0 overflow-hidden bg-white transition-[width] duration-200 ease-out dark:bg-slate-950 md:flex`,n?`border-l border-slate-200/30 dark:border-slate-800/40`:`w-0 border-l border-transparent`),children:n?(0,R.jsx)(gz,{agentId:e,capability:t,open:n,onClose:l,isFullscreen:i,onToggleFullscreen:()=>D.getState().setWorkspacePanelFullscreen(!i),isMobile:a,api:d}):null})]}):null,p?(0,R.jsx)(wl,{open:n,onOpenChange:e=>{e||D.getState().setWorkspacePanelFullscreen(!1),D.getState().setWorkspacePanelOpen(e)},modal:c.modal,children:(0,R.jsxs)(Ol,{side:c.side,showOverlay:c.showOverlay,onInteractOutside:e=>{c.preventOutsideClose&&e.preventDefault()},showCloseButton:!1,className:L(`border-slate-200 bg-white p-0 dark:border-slate-800 dark:bg-slate-950`,a?`h-[70vh] rounded-t-[1.75rem]`:`h-[calc(100vh-1.5rem)] w-[min(72rem,calc(100vw-1.5rem))] max-w-[calc(100vw-1.5rem)] rounded-l-[1.5rem] border-l shadow-2xl`),children:[(0,R.jsx)(jl,{className:`sr-only`,children:`Workspace 文件`}),(0,R.jsx)(Ml,{className:`sr-only`,children:`浏览、上传和预览 Workspace 文件。`}),(0,R.jsx)(gz,{agentId:e,capability:t,open:n,onClose:l,isMobile:a,api:d})]})}):null]})}async function vz(e,t){return(await ct(`ListSessions`,{AgentId:e},t)).Sessions??[]}async function yz(e,t){return(await ct(`CreateSession`,{AgentId:e},t)).Session}async function bz(e,t){await ct(`DeleteSession`,{SessionId:e},t)}async function xz(e){return ct(`ListSessionEvents`,{SessionId:e})}async function Sz(e,t){return dt(`RunAgent`,e,t)}async function Cz(e,t){let n={AgentId:e.agentId,SessionId:e.sessionId};return e.runId&&(n.RunId=e.runId),ct(`ListSessionCheckpoints`,n,t)}async function wz(e,t){return ct(`PreviewCheckpointResume`,{AgentId:e.agentId,SessionId:e.sessionId,RunId:e.runId,CheckpointId:e.checkpointId},t)}async function Tz(e,t){let n={AgentId:e.agentId,SessionId:e.sessionId};return e.runId&&(n.RunId=e.runId),e.checkpointId&&(n.CheckpointId=e.checkpointId),ct(`ListToolReceipts`,n,t)}async function Ez(e,t){let n={AgentId:e.agentId,SessionId:e.sessionId,RunId:e.runId,CheckpointId:e.checkpointId,Stream:!0};return e.resumeAttemptId&&(n.ResumeAttemptId=e.resumeAttemptId),e.invocationId&&(n.InvocationId=e.invocationId),dt(`ResumeRun`,n,t)}async function Dz(e,t,n){return ct(`ListWorkspaceFiles`,{AgentId:e,Path:t,Recursive:n})}async function Oz(e){return lt(`AddWorkspaceFile`,e)}async function kz(e,t){return ct(`DeleteWorkspaceFile`,{AgentId:e,Path:t})}async function Az(e,t,n){return ut(`GetWorkspaceFileContent`,{AgentId:e,FilePath:t},{signal:n?.signal,asText:n?.asText??!0})}async function jz(e,t){return lt(`UploadFile`,e,t)}var Mz=new class{async listSessions(e,t){return await vz(e,t)}async createSession(e,t){return{SessionId:(await yz(e,t)).SessionId}}async deleteSession(e,t){await bz(e,t)}async listSessionEvents(e){return xz(e)}async listSessionCheckpoints(e,t){return Cz(e,t)}async previewCheckpointResume(e,t){return wz(e,t)}async listToolReceipts(e,t){return Tz(e,t)}async runAgent(e,t){return Sz(e,t)}async resumeRun(e,t){return Ez(e,t)}async subscribeRunEvents(e,t){return ft(`SubscribeRunEvents`,{SessionId:e.sessionId,InvocationId:e.invocationId,AfterSeqId:String(e.afterSeqId)},t)}async cancelRun(e,t,n){return ct(`CancelRun`,{AgentId:e,InvocationId:t},n)}async getResponseFeedback(e,t){return ct(`GetResponseFeedback`,e,t)}async upsertResponseFeedback(e,t){return ct(`UpsertResponseFeedback`,e,t)}async deleteResponseFeedback(e,t){await ct(`DeleteResponseFeedback`,e,t)}async listWorkspaceFiles(e,t,n){return Dz(e,t,n)}async addWorkspaceFile(e){return Oz(e)}async deleteWorkspaceFile(e,t){await kz(e,t)}async getWorkspaceFileContent(e,t,n){return Az(e,t,n)}async listAgentModels(e){return mt(e)}async getAgentUiBootstrap(){return pt()}async uploadFile(e,t){return jz(e,t)}},Nz=b.lazy(()=>W(()=>import(`./ArtifactsPanel-CMS54WAp.js`).then(e=>({default:e.ArtifactsPanel})),[],import.meta.url));function Pz({apiAdapter:e,routeShell:t}={}){let n=e||Mz,r=se(e=>e.agentId),i=M(e=>e.currentSessionId),a=j(e=>e.isStreaming),o=D(e=>e.sidebarOpen),s=D(e=>e.mobileSidebarOpen),c=D(e=>e.mobileActionsOpen),l=se(e=>e.agentName),u=le(e=>e.selectedModel),d=le(e=>e.availableModels),f=le(e=>e.modelSource),p=le(e=>e.modelCatalogLoaded),m=le(e=>e.thinkingMode),h=se(e=>e.agentFramework),g=se(e=>e.workspaceFiles),_=se(e=>e.accessMode),v=D(e=>e.workspacePanelOpen),y=D(e=>e.workspacePanelWidth),x=D(e=>e.workspacePanelFullscreen),S=se(e=>e.apiFormats),C=se(e=>e.capabilities),w=pe(e=>e.visible&&!!e.content),T=(0,b.useRef)([]),E=(0,b.useRef)(null),{isMobile:O,viewportHeight:ee}=nt(),te=_e({isMobile:O,viewportHeight:ee}),{fetchSessions:ne,loadSession:re,createNewSession:ie,deleteSession:ae,currentSessionIdRef:oe,agentIdRef:k,runSubscriptionAbortRef:ce}=wr({agentId:r,currentSessionId:i,isMobile:O,uiCapabilities:C,api:n,resetCompaction:()=>{},disconnectRun:()=>E.current?.()}),ue=(0,b.useCallback)(e=>{if(!e)return;let t=()=>{ne(k.current,e),oe.current===e&&!j.getState().isStreaming&&re(e)};queueMicrotask(t),window.setTimeout(t,1800),window.setTimeout(t,5e3)},[k,oe,ne,re]),{submitDraft:de,stopGeneration:fe,disconnectRun:me,resumeCheckpoint:he}=nr({agentId:r,currentSessionId:i,agentFramework:h,apiFormats:S,selectedModel:u,thinkingMode:m,uiCapabilities:C,isMobile:O,api:n,currentSessionIdRef:oe,agentIdRef:k,queuedDraftRef:T,onRunSettled:ue});(0,b.useEffect)(()=>{E.current=me},[me]);let ge=(0,b.useCallback)(()=>{ce.current?.abort(),j.getState().stopActivity(),fe()},[ce,fe]),ve=(0,b.useCallback)(async()=>{let e=j.getState().currentRunId;if(e)try{await n.cancelRun(r,e),j.getState().updateActivity({sessionId:oe.current,status:`waiting`,phase:`取消请求已发送`,detail:`等待运行时停在最近 checkpoint`,countEvent:!1})}catch(e){console.warn(`[App] cancelRun failed:`,e),j.getState().updateActivity({sessionId:oe.current,status:`failed`,phase:`取消请求失败`,detail:e instanceof Error?e.message:String(e),countEvent:!1})}ue(oe.current)},[n,r,oe,ue]),{submitResponseFeedback:ye,deleteResponseFeedback:be,respondToApproval:xe}=pr({agentId:r,currentSessionId:i,isStreaming:a,api:n,submitDraft:de});_t({fetchSessions:ne}),(0,b.useEffect)(()=>{k.current=r,oe.current=i,We(r,i)},[r,i,k,oe]),(0,b.useEffect)(()=>{O?D.getState().setWorkspacePanelFullscreen(!1):(D.getState().setMobileSidebarOpen(!1),D.getState().setMobileActionsOpen(!1))},[O]),(0,b.useEffect)(()=>{v||D.getState().setWorkspacePanelFullscreen(!1)},[v]),(0,b.useEffect)(()=>()=>{ce.current?.abort()},[ce]);let Se=A(C),Ce=!!C.Thinking,we=Re({workspaceFiles:g,accessMode:_}),Te=Ie({isMobile:O}),Ee=Xe({capability:C.NativeDashboard,agentFramework:h,accessMode:_,origin:window.location.origin}),De=!Se,Oe=h===`openclaw`?`OpenClaw`:h===`hermes`?`Hermes`:`原生运行时`,ke=(d.find(e=>e.id===u)||null)?.display_name||u||``,Ae=!O&&o&&Se,je=(0,R.jsxs)(`div`,{className:`flex h-[var(--app-height)] min-h-[var(--app-height)] overflow-hidden bg-white font-sans text-slate-800 dark:bg-slate-900 dark:text-slate-200`,children:[(0,R.jsx)(Nl,{uiCapabilities:C,createNewSession:ie,deleteSession:ae,loadSession:re}),(0,R.jsxs)(`main`,{className:`relative flex min-w-0 flex-1 flex-col bg-white dark:bg-slate-900`,children:[(0,R.jsx)(Fb,{agentName:l,currentSessionId:i,nativeLauncherMode:De,isMobile:O,sidebarOpen:o,mobileSidebarOpen:s,onToggleSidebar:()=>{O?D.getState().toggleMobileSidebar():D.getState().toggleSidebar()},availableModels:d,selectedModel:u,onSelectModel:e=>{le.getState().setSelectedModel(e),O&&D.getState().setMobileActionsOpen(!1)},selectedModelLabel:ke,modelCatalogLoaded:p,modelSource:f,thinkingEnabled:Ce,thinkingMode:m,onSelectThinkingMode:e=>le.getState().setThinkingMode(Qe(e)),mobileActionsOpen:c,onMobileActionsOpenChange:e=>D.getState().setMobileActionsOpen(e),workspaceEnabled:we,onOpenWorkspace:()=>D.getState().setWorkspacePanelOpen(!0),nativeManagementLink:Ee,nativeTerminal:C.NativeTerminal}),De?(0,R.jsx)(Lb,{productLabel:Oe,nativeManagementLink:Ee,nativeTerminal:C.NativeTerminal,workspaceEnabled:we,onOpenWorkspace:()=>D.getState().setWorkspacePanelOpen(!0)}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Db,{agentName:l,isMobile:O,onDeleteFeedback:be,onSubmitFeedback:ye,onRespondToApproval:xe,onStopGeneration:ge,onCancelRemote:C.StopRun?ve:void 0,checkpointResumeEnabled:C.RunLifecycle.Enabled&&C.RunLifecycle.Checkpoints&&C.RunLifecycle.CheckpointResume,onResumeCheckpoint:he}),(0,R.jsx)(Mb,{composerMaxHeight:te,submitDraft:de,stopGeneration:ge,cancelRemote:C.StopRun?ve:void 0,isMobile:O})]})]}),(0,R.jsx)(_z,{agentId:r,capability:g,workspacePanelOpen:v,workspacePanelWidth:y,workspacePanelFullscreen:x,isMobile:O,workspaceEnabled:we,workspaceFiles:g,workspacePanelPresentation:Te,closeWorkspacePanel:()=>{D.getState().setWorkspacePanelFullscreen(!1),D.getState().setWorkspacePanelOpen(!1)},handleWorkspacePanelResizeStart:e=>{if(x||O)return;e.preventDefault();let t=e.clientX,n=y,r=Se&&Ae?280:0,i=document.body.style.cursor,a=document.body.style.userSelect;document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let o=e=>{let i=n+t-e.clientX;D.getState().setWorkspacePanelWidth(Gt(i,window.innerWidth,r))},s=()=>{document.body.style.cursor=i,document.body.style.userSelect=a,window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},api:n}),w&&(0,R.jsx)(b.Suspense,{fallback:null,children:(0,R.jsx)(Nz,{})})]});return t?(0,R.jsx)(t,{children:je}):je}function Fz(){return(0,R.jsx)(Pz,{})}function Iz(e){let t=e instanceof Error?e.message:String(e||``);return/loading chunk|chunkloaderror|failed to fetch dynamically imported module|error loading dynamically imported module|importing a module script failed/i.test(t)}var Lz=`agentengine-ui:chunk-reload-attempted`,Rz=class extends b.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){if(console.error(`UI 渲染错误:`,e,t),Iz(e))try{window.sessionStorage.getItem(Lz)||(window.sessionStorage.setItem(Lz,String(Date.now())),window.location.reload())}catch{window.location.reload()}}handleReload=()=>{try{window.sessionStorage.removeItem(Lz)}catch{}this.setState({hasError:!1,error:null}),window.location.reload()};render(){return this.state.hasError?(0,R.jsx)(`div`,{className:`flex h-screen w-screen items-center justify-center bg-slate-50 dark:bg-slate-900`,children:(0,R.jsxs)(`div`,{className:`max-w-md rounded-2xl border border-red-200 bg-white p-8 text-center shadow-lg dark:border-red-900 dark:bg-slate-950`,children:[(0,R.jsx)(`div`,{className:`mb-4 text-4xl`,children:`⚠`}),(0,R.jsx)(`h1`,{className:`mb-2 text-xl font-semibold text-red-600 dark:text-red-400`,children:`页面渲染出错`}),(0,R.jsx)(`p`,{className:`mb-6 text-sm text-slate-600 dark:text-slate-400`,children:this.state.error?.message||`发生了未知错误,请刷新页面重试。`}),(0,R.jsx)(`button`,{onClick:this.handleReload,className:`rounded-lg bg-blue-600 px-6 py-2.5 text-sm font-medium text-white transition hover:bg-blue-700`,children:`刷新页面`})]})}):this.props.children}};function zz(){let e=D(e=>e.toasts),t=D(e=>e.dismissToast);return(0,b.useEffect)(()=>{if(!e.length)return;let n=e[0],r=3e3-(Date.now()-n.createdAt);if(r<=0){t(n.id);return}let i=setTimeout(()=>t(n.id),r);return()=>clearTimeout(i)},[e,t]),e.length?(0,R.jsx)(`div`,{className:`fixed bottom-4 right-4 z-50 flex flex-col gap-2`,children:e.map(e=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg px-4 py-3 text-sm shadow-lg transition-all ${e.variant===`error`?`bg-red-600 text-white`:`bg-slate-800 text-white dark:bg-slate-200 dark:text-slate-900`}`,children:[(0,R.jsx)(`span`,{className:`flex-1`,children:e.message}),(0,R.jsx)(`button`,{onClick:()=>t(e.id),className:`shrink-0 rounded p-0.5 opacity-70 hover:opacity-100`,children:(0,R.jsx)(gi,{size:14})})]},e.id))}):null}T.createRoot(document.getElementById(`root`)).render((0,R.jsxs)(Rz,{children:[(0,R.jsx)(Fz,{}),(0,R.jsx)(zz,{})]}));export{U as $,Lk as A,mS as B,aj as C,s as Ct,Z as D,FA as E,Gk as F,Ny as G,PS as H,hA as I,gg as J,by as K,Y as L,Bk as M,dA as N,Pk as O,pA as P,Bd as Q,eO as R,rj as S,o as St,AA as T,Wy as U,Fx as V,W,gh as X,hh as Y,oh as Z,Uj as _,Vr as _t,uL as a,Kl as at,Ej as b,pe as bt,oj as c,Qa as ct,fj as d,mi as dt,vd as et,PM as f,di as ft,Lj as g,Hr as gt,Fj as h,Gr as ht,lL as i,_u as it,Vk as j,Wk as k,Q as l,L as lt,ij as m,ii as mt,iz as n,bu as nt,bR as o,Fl as ot,Rj as p,oi as pt,y_ as q,oL as r,xu as rt,cj as s,Pl as st,rz as t,Su as tt,yj as u,gi as ut,Hj as v,Ir as vt,lj as w,l as wt,xj as x,p as xt,Vj as y,N as yt,G as z};
165
+ <\/script>`,o=`${`<meta http-equiv="Content-Security-Policy" content="${QR(i)}">`}${r?`<base href="${QR(r)}">`:``}${a}`;return/<head[^>]*>/i.test(e)?e.replace(/<head[^>]*>/i,`$&${o}`):`${o}${e}`}function iz(e,t){let n=(0,b.useRef)(null);(0,b.useEffect)(()=>(n.current=n=>{if(n.source!==e.current?.contentWindow||n.data?.type!==`ksadk:linkClick`||t&&n.data?.channelId!==t)return;let r=n.data?.href;typeof r==`string`&&r&&nz(r)&&window.open(r,`_blank`,`noopener,noreferrer`)},window.addEventListener(`message`,n.current),()=>{n.current&&window.removeEventListener(`message`,n.current)}),[e,t])}function az({content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i,isMobile:a}){let o=(0,b.useRef)(null),s=(0,b.useId)(),[c,l]=(0,b.useState)(`preview`),u=De(t),d=Ee(t),f=(0,b.useCallback)(()=>rz(e,{basePath:u,channelId:s}),[e,u,s]),[p,m]=(0,b.useState)(f());(0,b.useEffect)(()=>{let e=setTimeout(()=>{m(f())},300);return()=>clearTimeout(e)},[f]),iz(o,s);let h=(0,b.useCallback)(()=>{let e=new Blob([p],{type:`text/html;charset=utf-8`}),t=URL.createObjectURL(e),n=window.open(t,`_blank`,`noopener,noreferrer`);window.setTimeout(()=>URL.revokeObjectURL(t),3e4),n||window.open(d,`_blank`,`noopener,noreferrer`)},[d,p]);return a?(0,R.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-slate-200 px-2 py-1.5 dark:border-slate-700`,children:[(0,R.jsxs)(`button`,{onClick:()=>l(`editor`),className:L(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,c===`editor`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,R.jsx)(Br,{className:`h-3.5 w-3.5`}),`编辑`]}),(0,R.jsxs)(`button`,{onClick:()=>l(`preview`),className:L(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,c===`preview`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,R.jsx)(Gr,{className:`h-3.5 w-3.5`}),`预览`]})]}),c===`editor`?(0,R.jsx)(XR,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}):(0,R.jsx)(`iframe`,{ref:o,srcDoc:p,sandbox:`allow-scripts allow-downloads allow-same-origin`,title:`HTML 预览`,className:`h-full w-full border-0 bg-white`})]}):c===`editor`?(0,R.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,R.jsx)(XR,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}),(0,R.jsxs)(`button`,{onClick:()=>l(`preview`),className:`absolute right-3 top-3 z-10 inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,R.jsx)(Gr,{className:`h-3.5 w-3.5`}),`预览`]})]}):(0,R.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,R.jsx)(`iframe`,{ref:o,srcDoc:p,sandbox:`allow-scripts allow-downloads allow-same-origin`,title:`HTML 预览`,className:`h-full w-full border-0 bg-white`}),(0,R.jsxs)(`div`,{className:`absolute right-3 top-3 z-10 flex gap-1.5`,children:[(0,R.jsxs)(`button`,{onClick:h,className:`inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,title:`在新窗口中打开当前预览`,children:[(0,R.jsx)(Wr,{className:`h-3.5 w-3.5`}),`新窗口`]}),(0,R.jsxs)(`button`,{onClick:()=>l(`editor`),className:`inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,R.jsx)(Br,{className:`h-3.5 w-3.5`}),`编辑`]})]})]})}function oz(e){e.current&&clearTimeout(e.current)}function sz({content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i,isMobile:a}){let[o,s]=(0,b.useState)(`editor`),[c,l]=(0,b.useState)(e),u=(0,b.useRef)(null);return(0,b.useEffect)(()=>(oz(u),u.current=setTimeout(()=>l(e),300),()=>oz(u)),[e]),a?(0,R.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-slate-200/30 px-2 py-1.5 dark:border-slate-700/30`,children:[(0,R.jsxs)(`button`,{onClick:()=>s(`editor`),className:L(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,o===`editor`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,R.jsx)(Br,{className:`h-3.5 w-3.5`}),`编辑`]}),(0,R.jsxs)(`button`,{onClick:()=>s(`preview`),className:L(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,o===`preview`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,R.jsx)(Gr,{className:`h-3.5 w-3.5`}),`预览`]})]}),o===`editor`?(0,R.jsx)(XR,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}):(0,R.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:(0,R.jsx)(Uy,{content:c})})]}):o===`editor`?(0,R.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,R.jsx)(XR,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}),(0,R.jsxs)(`button`,{onClick:()=>s(`preview`),className:`absolute right-3 top-3 z-10 inline-flex items-center gap-1.5 rounded-lg border border-slate-200/30 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,R.jsx)(Gr,{className:`h-3.5 w-3.5`}),`预览`]})]}):(0,R.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,R.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:(0,R.jsx)(Uy,{content:c})}),(0,R.jsxs)(`button`,{onClick:()=>s(`editor`),className:`absolute right-3 top-3 z-10 inline-flex items-center gap-1.5 rounded-lg border border-slate-200/30 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,R.jsx)(Br,{className:`h-3.5 w-3.5`}),`编辑`]})]})}var cz=`/agentengine/api/v1/GetWorkspaceFileContent`,lz=4e3;function uz(e){let t=we(e);if(!t||t===`.`)return`.`;let n=t.split(`/`).filter(Boolean);return n.length<=1?`.`:n.slice(0,-1).join(`/`)}function dz(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function fz(e){let t=Number(e);return!Number.isFinite(t)||t<=0?`0 B`:t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(1)} GB`}var pz=[{label:`Markdown`,detail:`.md .markdown .mdx`},{label:`代码/文本`,detail:`.py .js .ts .tsx .json .yaml .log .txt`},{label:`图片`,detail:`PNG JPG GIF WebP SVG`},{label:`PDF`,detail:`.pdf`},{label:`表格文本`,detail:`CSV TSV`}];function mz(e){return Ee(e)}function hz({label:e,showSupportedTypes:t=!1}){return(0,R.jsx)(`div`,{className:`flex h-full min-h-[16rem] flex-col items-center justify-center px-6 text-center`,children:(0,R.jsxs)(`div`,{className:`w-full max-w-md rounded-2xl border border-dashed border-slate-300 bg-slate-50 px-5 py-5 text-slate-500 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-400`,children:[(0,R.jsx)(`div`,{children:e}),t?(0,R.jsxs)(`div`,{className:`mt-4 text-left`,children:[(0,R.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-[0.12em] text-slate-400`,children:`支持在线预览`}),(0,R.jsx)(`div`,{className:`mt-2 grid gap-2`,children:pz.map(e=>(0,R.jsxs)(`div`,{className:`rounded-xl border border-slate-200 bg-white px-3 py-2 dark:border-slate-800 dark:bg-slate-950`,children:[(0,R.jsx)(`div`,{className:`text-sm font-medium text-slate-700 dark:text-slate-200`,children:e.label}),(0,R.jsx)(`div`,{className:`mt-0.5 font-mono text-[11px] text-slate-400`,children:e.detail})]},e.label))}),(0,R.jsx)(`div`,{className:`mt-3 text-xs leading-5 text-slate-400`,children:`Word、Excel、PPT 当前不支持在线预览,可下载后查看。`})]}):null]})})}function gz({agentId:e,capability:t,open:n,onClose:r,isFullscreen:i=!1,onToggleFullscreen:a,isMobile:o=!1,api:s}){let c=(0,b.useRef)(null),l=(0,b.useRef)(null),[u,d]=(0,b.useState)(!1),[f,p]=(0,b.useState)(`.`),[m,h]=(0,b.useState)([]),[g,_]=(0,b.useState)(!1),[v,y]=(0,b.useState)(!1),[x,S]=(0,b.useState)(!1),[C,w]=(0,b.useState)(``),[T,E]=(0,b.useState)(null),[D,O]=(0,b.useState)(null),[ee,te]=(0,b.useState)(!1),[ne,re]=(0,b.useState)(!1),ie=(0,b.useRef)(null),ae=(0,b.useRef)(null),oe=(0,b.useRef)(`selection`),k=(0,b.useRef)(Le()),A=(0,b.useMemo)(()=>m.find(e=>e.Path===T)??null,[m,T]),se=(0,b.useMemo)(()=>A?Fe({path:A.Path,mimeType:A.MimeType}):null,[A]),ce=(0,b.useCallback)(()=>ee?window.confirm(`当前文件有未保存的更改,确定要离开吗?`):!0,[ee]),le=t.ContentPath||cz,ue=t.RootLabel||`Workspace`,j=ue?`${ue.charAt(0).toUpperCase()}${ue.slice(1)}`:`Workspace`,de=ke(f),fe=(0,b.useCallback)(()=>{l.current&&=(URL.revokeObjectURL(l.current),null)},[]);(0,b.useEffect)(()=>()=>fe(),[fe]);let M=(0,b.useCallback)(async(t,n={})=>{let r=!!n.background;r?y(!0):_(!0),r||w(``);try{let n=await s.listWorkspaceFiles(e,t,!1),i=we(String(n?.Path||t||`.`)),a=Array.isArray(n?.Entries)?n.Entries:[];p(i),h(a),oe.current=r?`background-refresh`:`selection`,E(e=>{if(e){let t=a.find(t=>t.Path===e);if(t&&t.Type===`file`)return e}return a.find(e=>e.Type===`file`)?.Path??null})}catch(e){console.error(`Failed to load workspace entries:`,e),r||w(e instanceof Error?e.message:String(e))}finally{r?y(!1):_(!1)}},[e,s]);(0,b.useEffect)(()=>{!n||u||(d(!0),M(`.`))},[u,M,n]),(0,b.useEffect)(()=>{if(!n||ee||!u)return;let e=window.setInterval(()=>{M(f,{background:!0})},lz);return()=>window.clearInterval(e)},[f,ee,u,M,n]);let pe=(0,b.useCallback)(async t=>{let n=k.current.next(t.Path),r=Ne({path:t.Path,mimeType:t.MimeType});if(ae.current=t.Path,r===`unsupported`){fe(),O({path:t.Path,kind:r,status:`ready`,mimeType:t.MimeType??void 0});return}fe(),O({path:t.Path,kind:r,status:`loading`,mimeType:t.MimeType??void 0});try{let r=await s.getWorkspaceFileContent(e,t.Path,{asText:!1});if(!k.current.isCurrent(n))return;if(r instanceof Blob){let e=t.MimeType||``,i=Ne({path:t.Path,mimeType:e});if(i===`image`||i===`pdf`){let n=URL.createObjectURL(r);l.current=n,O({path:t.Path,kind:i,status:`ready`,mimeType:e,objectUrl:n});return}let a=await r.text();if(!k.current.isCurrent(n))return;let o=Ne({path:t.Path,mimeType:e});O({path:t.Path,kind:o,status:`ready`,mimeType:e,content:a})}else{let e=t.MimeType||``,n=Ne({path:t.Path,mimeType:e});O({path:t.Path,kind:n,status:`ready`,mimeType:e,content:r})}}catch(e){if(!k.current.isCurrent(n))return;console.error(`Failed to preview workspace file:`,e),O({path:t.Path,kind:r,status:`error`,mimeType:t.MimeType??void 0,error:e instanceof Error?e.message:String(e)})}},[e,s,fe]);(0,b.useEffect)(()=>{if(!A||A.Type!==`file`){fe(),O(null),te(!1),ae.current=null;return}if(oe.current===`background-refresh`&&ae.current===A.Path){oe.current=`selection`;return}oe.current=`selection`,pe(A)},[fe,pe,A]);let me=async n=>{if(!(!n||n.length===0)){S(!0),w(``);try{for(let r of Array.from(n)){if(r.size>t.MaxUploadBytes)throw Error(`文件 ${r.name} 超过上传上限`);let n=Oe(f)?r.name:`${f}/${r.name}`,i=new FormData;i.append(`file`,r),i.append(`AgentId`,e),i.append(`Path`,n),await s.addWorkspaceFile(i)}await M(f)}catch(e){console.error(`Failed to upload workspace files:`,e),w(e instanceof Error?e.message:String(e))}finally{c.current&&(c.current.value=``),S(!1)}}},he=async n=>{if(!t.SupportsDelete)return;let r=we(n.Path);if(window.confirm(`删除 ${r} ?`)){w(``);try{await s.deleteWorkspaceFile(e,r),T&&we(T)===r&&(E(null),te(!1)),await M(n.Type===`directory`&&(we(f)===r||we(f).startsWith(`${r}/`))?uz(r):f)}catch(e){console.error(`Failed to delete workspace file:`,e),w(e instanceof Error?e.message:String(e))}}},ge=()=>!A||A.Type!==`file`?(0,R.jsx)(hz,{label:`从左侧选择文件后在这里查看内容预览。`,showSupportedTypes:!0}):!D||D.path!==A.Path||D.status===`loading`?(0,R.jsx)(`div`,{className:`flex h-full min-h-[16rem] items-center justify-center`,children:(0,R.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full border border-slate-200 bg-white px-4 py-2 text-sm text-slate-500 shadow-sm dark:border-slate-800 dark:bg-slate-900 dark:text-slate-400`,children:[(0,R.jsx)(Xr,{className:`h-4 w-4 animate-spin`}),`正在加载预览...`]})}):D.status===`error`?(0,R.jsx)(hz,{label:D.error||`文件预览加载失败。`}):D.kind===`markdown`?(0,R.jsx)(sz,{content:D.content||``,path:A.Path,onSave:_e,onDirtyChange:te,getContentRef:ie,isMobile:o}):D.kind===`image`&&D.objectUrl?(0,R.jsx)(ZR,{content:null,objectUrl:D.objectUrl,kind:`image`,filename:A.Name,mimeType:D.mimeType||``}):D.kind===`pdf`&&D.objectUrl?(0,R.jsx)(ZR,{content:null,objectUrl:D.objectUrl,kind:`pdf`,filename:A.Name,mimeType:D.mimeType||``}):D.kind===`html`?(0,R.jsx)(az,{content:D.content||``,path:A.Path,onSave:_e,onDirtyChange:te,getContentRef:ie,isMobile:o,agentId:e,contentPath:le}):D.kind===`text`||D.kind===`code`?(0,R.jsx)(XR,{content:D.content||``,path:A.Path,onSave:_e,onDirtyChange:te,getContentRef:ie}):(0,R.jsx)(ZR,{content:null,kind:`unsupported`,filename:A.Name,mimeType:D.mimeType||``}),_e=async t=>{if(A){re(!0),w(``);try{let n=new Blob([t],{type:A.MimeType||`text/plain`}),r=new FormData;r.append(`file`,n,A.Name),r.append(`AgentId`,e),r.append(`Path`,A.Path),await s.addWorkspaceFile(r),k.current.invalidate(),te(!1),O(e=>e&&e.path===A.Path?{...e,content:t}:e),ae.current=A.Path,await M(f,{background:!0})}catch(e){console.error(`Failed to save workspace file:`,e),w(e instanceof Error?e.message:String(e))}finally{re(!1)}}},ve=A?.Type===`file`&&D?.path===A.Path&&D.status===`ready`&&(D.kind===`text`||D.kind===`code`||D.kind===`html`||D.kind===`markdown`),ye=A?.Type===`file`&&D?.path===A.Path&&D.status===`ready`&&D.kind===`pdf`;return(0,R.jsxs)(`div`,{className:`flex h-full min-h-[22rem] w-full min-w-0 flex-col bg-white text-slate-800 dark:bg-slate-950 dark:text-slate-200`,children:[(0,R.jsxs)(`div`,{className:`flex h-14 flex-shrink-0 items-center gap-3 border-b border-slate-200/30 px-4 dark:border-slate-800/40`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,R.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100`,children:j}),(0,R.jsx)(`div`,{className:`hidden h-4 w-px bg-slate-200/70 dark:bg-slate-800 sm:block`}),(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`flex-shrink-0 text-xs text-slate-400`,children:`当前目录`}),(0,R.jsx)(`div`,{className:`custom-scrollbar max-w-[min(42vw,34rem)] overflow-x-auto whitespace-nowrap rounded-md bg-slate-50 px-2 py-1 font-mono text-[11px] text-slate-600 dark:bg-slate-900 dark:text-slate-300`,title:`${de},来自 ListWorkspaceFiles 返回的 Data.Path 字段`,children:de})]}),(0,R.jsx)(`div`,{className:`hidden truncate text-[11px] text-slate-400 xl:block`,children:`工作区内相对路径,不是宿主机绝对路径。`})]}),(0,R.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-1.5`,children:[(0,R.jsx)(`input`,{ref:c,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void me(e.target.files)}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>c.current?.click(),disabled:x,className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium text-slate-600 transition hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-50 dark:text-slate-300 dark:hover:bg-slate-900`,title:`上传文件,上限 ${Math.floor(t.MaxUploadBytes/(1024*1024))}MB`,children:[(0,R.jsx)(hi,{className:`h-3.5 w-3.5`}),x?`上传中`:`上传`]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{let e=new URLSearchParams({Path:f}).toString();window.open(`/agentengine/api/v1/ExportWorkspaceZip?${e}`,`_blank`,`noopener,noreferrer`)},className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium text-slate-600 transition hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-slate-900`,title:`导出当前目录为 ZIP`,children:[(0,R.jsx)(ei,{className:`h-3.5 w-3.5`}),`导出`]}),a?(0,R.jsx)(`button`,{type:`button`,onClick:a,className:`rounded-lg p-1.5 text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-slate-900 dark:hover:text-slate-100`,"aria-label":i?`退出全屏`:`全屏查看 Workspace`,title:i?`退出全屏`:`全屏查看`,children:i?(0,R.jsx)($r,{className:`h-4 w-4`}):(0,R.jsx)(Zr,{className:`h-4 w-4`})}):null,r?(0,R.jsx)(`button`,{type:`button`,onClick:()=>{ce()&&r?.()},className:`rounded-lg p-1.5 text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-slate-900 dark:hover:text-slate-100`,"aria-label":`关闭 Workspace`,title:`关闭`,children:(0,R.jsx)(gi,{className:`h-4 w-4`})}):null]})]}),(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col md:flex-row`,children:[(0,R.jsxs)(`div`,{className:`flex w-full flex-col border-b border-slate-200/30 dark:border-slate-800/40 md:w-[13.5rem] md:border-b-0 md:border-r`,children:[(0,R.jsxs)(`div`,{className:`flex h-14 flex-shrink-0 items-center border-b border-slate-200/30 px-3 dark:border-slate-800/40`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`div`,{className:`text-xs font-medium text-slate-900 dark:text-slate-100`,children:`文件`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] text-slate-400`,children:[(0,R.jsxs)(`span`,{children:[m.length,` 项`]}),v?(0,R.jsx)(oi,{className:`h-3 w-3 animate-spin`,"aria-label":`正在同步 Workspace 目录`}):null]})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>{ce()&&M(uz(f))},disabled:g||Oe(f),className:`rounded-md p-1.5 text-slate-500 transition hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-40 dark:text-slate-400 dark:hover:bg-slate-900`,title:`返回上级目录`,children:(0,R.jsx)(Pr,{className:`h-4 w-4`})}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>{ce()&&M(f)},disabled:g,className:`rounded-md p-1.5 text-slate-500 transition hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-40 dark:text-slate-400 dark:hover:bg-slate-900`,title:`刷新目录`,children:(0,R.jsx)(oi,{className:`h-4 w-4 ${g?`animate-spin`:``}`})})]})]}),C?(0,R.jsx)(`div`,{className:`mt-3 rounded-xl border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-600 dark:border-red-900/60 dark:bg-red-950/40 dark:text-red-300`,children:C}):null]}),(0,R.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto px-2 py-2`,children:!u&&!n?(0,R.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`打开面板后加载 workspace 文件。`}):g?(0,R.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`正在加载目录...`}):m.length===0?(0,R.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`当前目录为空。`}):(0,R.jsx)(`div`,{className:`space-y-0.5`,children:m.map(e=>{let n=Ne({path:e.Path,mimeType:e.MimeType}),r=T===e.Path,i=e.Type===`file`?mz(e.Path):``;return(0,R.jsxs)(`div`,{title:e.Path,className:L(`group flex items-center gap-1 rounded-lg px-1.5 py-1 transition`,r?`bg-slate-100 text-slate-950 dark:bg-slate-800 dark:text-slate-50`:`text-slate-700 hover:bg-slate-50 dark:text-slate-300 dark:hover:bg-slate-900`),children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{if(e.Type===`directory`){M(e.Path);return}T!==e.Path&&!ce()||E(e.Path)},className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,R.jsx)(`div`,{className:L(`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-md`,r?`text-slate-900 dark:text-slate-50`:`text-slate-400 dark:text-slate-500`),children:e.Type===`directory`?(0,R.jsx)(Jr,{className:`h-3.5 w-3.5`}):n===`image`?(0,R.jsx)(Yr,{className:`h-3.5 w-3.5`}):n===`markdown`||n===`text`||n===`html`?(0,R.jsx)(Kr,{className:`h-3.5 w-3.5`}):(0,R.jsx)(qr,{className:`h-3.5 w-3.5`})}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`div`,{className:`truncate text-[13px] leading-5`,children:e.Name}),(0,R.jsx)(`div`,{className:L(`truncate text-[11px] leading-4`,r?`text-slate-500 dark:text-slate-400`:`text-slate-400`),children:e.Type===`directory`?`目录`:fz(e.SizeBytes)})]})]}),(0,R.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-0.5 opacity-0 transition group-hover:opacity-100`,children:[e.Type===`file`?(0,R.jsx)(`a`,{href:i,download:e.Name,className:L(`rounded-md p-1.5 transition`,r?`hover:bg-white dark:hover:bg-slate-700`:`hover:bg-slate-100 dark:hover:bg-slate-800`),title:`下载`,children:(0,R.jsx)(Hr,{className:`h-3.5 w-3.5`})}):null,t.SupportsDelete?(0,R.jsx)(`button`,{type:`button`,onClick:()=>void he(e),className:L(`rounded-md p-1.5 transition`,r?`hover:bg-white dark:hover:bg-slate-700`:`hover:bg-slate-100 dark:hover:bg-slate-800`),title:`删除`,children:(0,R.jsx)(mi,{className:`h-3.5 w-3.5`})}):null]})]},e.Path)})})})]}),(0,R.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,R.jsx)(`div`,{className:`flex h-14 flex-shrink-0 items-center border-b border-slate-200/30 px-4 dark:border-slate-800/40`,children:A?(0,R.jsxs)(`div`,{className:`flex w-full items-start justify-between gap-3`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100`,children:A.Name}),(0,R.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-[11px] text-slate-400`,children:A.Path}),(0,R.jsxs)(`div`,{className:`mt-1 text-[11px] text-slate-400`,children:[fz(A.SizeBytes),A.MimeType?` · ${A.MimeType}`:``,A.ModifiedAt?` · ${dz(A.ModifiedAt)}`:``]})]}),se===`text`||se===`code`||se===`html`||se===`markdown`?(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{let e=ie.current;e&&_e(e())},disabled:!ee||ne,className:L(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition`,ee&&!ne?`bg-blue-600 text-white hover:bg-blue-700`:`text-slate-400 dark:text-slate-500 cursor-not-allowed`),children:[(0,R.jsx)(si,{className:`h-3.5 w-3.5`}),ne?`保存中`:ee?`保存`:`已保存`]}):null]}):(0,R.jsxs)(`div`,{className:`w-full`,children:[(0,R.jsx)(`div`,{className:`text-sm font-semibold text-slate-900 dark:text-slate-100`,children:`文件预览`}),(0,R.jsx)(`div`,{className:`mt-0.5 text-xs text-slate-500 dark:text-slate-400`,children:`选择左侧文件后可在此查看内容。`})]})}),(0,R.jsx)(`div`,{className:L(`custom-scrollbar min-h-0 flex-1`,ye||ve?`overflow-hidden p-0`:`overflow-y-auto px-4 py-4`),children:ge()})]})]})]})}function _z({agentId:e,capability:t,workspacePanelOpen:n,workspacePanelWidth:r,workspacePanelFullscreen:i,isMobile:a,workspaceEnabled:o,workspaceFiles:s,workspacePanelPresentation:c,closeWorkspacePanel:l,handleWorkspacePanelResizeStart:u,api:d}){let f=c.renderMode===`inline`,p=c.renderMode===`sheet`;return!o||!s?null:(0,R.jsxs)(R.Fragment,{children:[f?(0,R.jsxs)(R.Fragment,{children:[n&&!i?(0,R.jsx)(`div`,{role:`separator`,"aria-label":`调整 Workspace 宽度`,"aria-orientation":`vertical`,onPointerDown:u,className:`hidden h-full w-1 cursor-col-resize bg-transparent transition-colors hover:bg-blue-200/60 dark:hover:bg-blue-900/50 md:block`}):null,(0,R.jsx)(`aside`,{style:n&&!i?{width:`${r}px`}:void 0,className:L(i?`fixed inset-0 z-40 flex h-[var(--app-height)] w-screen overflow-hidden bg-white dark:bg-slate-950`:`hidden h-full flex-shrink-0 overflow-hidden bg-white transition-[width] duration-200 ease-out dark:bg-slate-950 md:flex`,n?`border-l border-slate-200/30 dark:border-slate-800/40`:`w-0 border-l border-transparent`),children:n?(0,R.jsx)(gz,{agentId:e,capability:t,open:n,onClose:l,isFullscreen:i,onToggleFullscreen:()=>D.getState().setWorkspacePanelFullscreen(!i),isMobile:a,api:d}):null})]}):null,p?(0,R.jsx)(wl,{open:n,onOpenChange:e=>{e||D.getState().setWorkspacePanelFullscreen(!1),D.getState().setWorkspacePanelOpen(e)},modal:c.modal,children:(0,R.jsxs)(Ol,{side:c.side,showOverlay:c.showOverlay,onInteractOutside:e=>{c.preventOutsideClose&&e.preventDefault()},showCloseButton:!1,className:L(`border-slate-200 bg-white p-0 dark:border-slate-800 dark:bg-slate-950`,a?`h-[70vh] rounded-t-[1.75rem]`:`h-[calc(100vh-1.5rem)] w-[min(72rem,calc(100vw-1.5rem))] max-w-[calc(100vw-1.5rem)] rounded-l-[1.5rem] border-l shadow-2xl`),children:[(0,R.jsx)(jl,{className:`sr-only`,children:`Workspace 文件`}),(0,R.jsx)(Ml,{className:`sr-only`,children:`浏览、上传和预览 Workspace 文件。`}),(0,R.jsx)(gz,{agentId:e,capability:t,open:n,onClose:l,isMobile:a,api:d})]})}):null]})}async function vz(e,t){return(await ct(`ListSessions`,{AgentId:e},t)).Sessions??[]}async function yz(e,t){return(await ct(`CreateSession`,{AgentId:e},t)).Session}async function bz(e,t){await ct(`DeleteSession`,{SessionId:e},t)}async function xz(e){return ct(`ListSessionEvents`,{SessionId:e})}async function Sz(e,t){return dt(`RunAgent`,e,t)}async function Cz(e,t){let n={AgentId:e.agentId,SessionId:e.sessionId};return e.runId&&(n.RunId=e.runId),ct(`ListSessionCheckpoints`,n,t)}async function wz(e,t){return ct(`PreviewCheckpointResume`,{AgentId:e.agentId,SessionId:e.sessionId,RunId:e.runId,CheckpointId:e.checkpointId},t)}async function Tz(e,t){let n={AgentId:e.agentId,SessionId:e.sessionId};return e.runId&&(n.RunId=e.runId),e.checkpointId&&(n.CheckpointId=e.checkpointId),ct(`ListToolReceipts`,n,t)}async function Ez(e,t){let n={AgentId:e.agentId,SessionId:e.sessionId,RunId:e.runId,CheckpointId:e.checkpointId,Stream:!0};return e.resumeAttemptId&&(n.ResumeAttemptId=e.resumeAttemptId),e.invocationId&&(n.InvocationId=e.invocationId),dt(`ResumeRun`,n,t)}async function Dz(e,t,n){return ct(`ListWorkspaceFiles`,{AgentId:e,Path:t,Recursive:n})}async function Oz(e){return lt(`AddWorkspaceFile`,e)}async function kz(e,t){return ct(`DeleteWorkspaceFile`,{AgentId:e,Path:t})}async function Az(e,t,n){return ut(`GetWorkspaceFileContent`,{AgentId:e,FilePath:t},{signal:n?.signal,asText:n?.asText??!0})}async function jz(e,t){return lt(`UploadFile`,e,t)}var Mz=new class{async listSessions(e,t){return await vz(e,t)}async createSession(e,t){return{SessionId:(await yz(e,t)).SessionId}}async deleteSession(e,t){await bz(e,t)}async listSessionEvents(e){return xz(e)}async listSessionCheckpoints(e,t){return Cz(e,t)}async previewCheckpointResume(e,t){return wz(e,t)}async listToolReceipts(e,t){return Tz(e,t)}async runAgent(e,t){return Sz(e,t)}async resumeRun(e,t){return Ez(e,t)}async subscribeRunEvents(e,t){return ft(`SubscribeRunEvents`,{SessionId:e.sessionId,InvocationId:e.invocationId,AfterSeqId:String(e.afterSeqId)},t)}async cancelRun(e,t,n){return ct(`CancelRun`,{AgentId:e,InvocationId:t},n)}async getResponseFeedback(e,t){return ct(`GetResponseFeedback`,e,t)}async upsertResponseFeedback(e,t){return ct(`UpsertResponseFeedback`,e,t)}async deleteResponseFeedback(e,t){await ct(`DeleteResponseFeedback`,e,t)}async listWorkspaceFiles(e,t,n){return Dz(e,t,n)}async addWorkspaceFile(e){return Oz(e)}async deleteWorkspaceFile(e,t){await kz(e,t)}async getWorkspaceFileContent(e,t,n){return Az(e,t,n)}async listAgentModels(e){return mt(e)}async getAgentUiBootstrap(){return pt()}async uploadFile(e,t){return jz(e,t)}},Nz=b.lazy(()=>W(()=>import(`./ArtifactsPanel-Z9gYhqIC.js`).then(e=>({default:e.ArtifactsPanel})),[],import.meta.url));function Pz({apiAdapter:e,routeShell:t}={}){let n=e||Mz,r=se(e=>e.agentId),i=M(e=>e.currentSessionId),a=j(e=>e.isStreaming),o=D(e=>e.sidebarOpen),s=D(e=>e.mobileSidebarOpen),c=D(e=>e.mobileActionsOpen),l=se(e=>e.agentName),u=le(e=>e.selectedModel),d=le(e=>e.availableModels),f=le(e=>e.modelSource),p=le(e=>e.modelCatalogLoaded),m=le(e=>e.thinkingMode),h=se(e=>e.agentFramework),g=se(e=>e.workspaceFiles),_=se(e=>e.accessMode),v=D(e=>e.workspacePanelOpen),y=D(e=>e.workspacePanelWidth),x=D(e=>e.workspacePanelFullscreen),S=se(e=>e.apiFormats),C=se(e=>e.capabilities),w=pe(e=>e.visible&&!!e.content),T=(0,b.useRef)([]),E=(0,b.useRef)(null),{isMobile:O,viewportHeight:ee}=nt(),te=_e({isMobile:O,viewportHeight:ee}),{fetchSessions:ne,loadSession:re,createNewSession:ie,deleteSession:ae,currentSessionIdRef:oe,agentIdRef:k,runSubscriptionAbortRef:ce}=wr({agentId:r,currentSessionId:i,isMobile:O,uiCapabilities:C,api:n,resetCompaction:()=>{},disconnectRun:()=>E.current?.()}),ue=(0,b.useCallback)(e=>{if(!e)return;let t=()=>{ne(k.current,e),oe.current===e&&!j.getState().isStreaming&&re(e)};queueMicrotask(t),window.setTimeout(t,1800),window.setTimeout(t,5e3)},[k,oe,ne,re]),{submitDraft:de,stopGeneration:fe,disconnectRun:me,resumeCheckpoint:he}=nr({agentId:r,currentSessionId:i,agentFramework:h,apiFormats:S,selectedModel:u,thinkingMode:m,uiCapabilities:C,isMobile:O,api:n,currentSessionIdRef:oe,agentIdRef:k,queuedDraftRef:T,onRunSettled:ue});(0,b.useEffect)(()=>{E.current=me},[me]);let ge=(0,b.useCallback)(()=>{let e=oe.current;ce.current?.abort(),j.getState().stopActivity(),j.getState().stopSessionActivity(e),fe()},[oe,ce,fe]),ve=(0,b.useCallback)(async()=>{let e=oe.current,t=j.getState(),i=t.currentRunId||t.getSessionActivity(e)?.runId||``;if(i)try{await n.cancelRun(r,i),j.getState().stopSessionActivity(e,`取消请求已发送,后台运行会停在最近 checkpoint。`)}catch(t){console.warn(`[App] cancelRun failed:`,t),j.getState().updateActivity({sessionId:e,status:`failed`,phase:`取消请求失败`,detail:t instanceof Error?t.message:String(t),countEvent:!1})}ue(e)},[n,r,oe,ue]),{submitResponseFeedback:ye,deleteResponseFeedback:be,respondToApproval:xe}=pr({agentId:r,currentSessionId:i,isStreaming:a,api:n,submitDraft:de});_t({fetchSessions:ne}),(0,b.useEffect)(()=>{k.current=r,oe.current=i,We(r,i)},[r,i,k,oe]),(0,b.useEffect)(()=>{O?D.getState().setWorkspacePanelFullscreen(!1):(D.getState().setMobileSidebarOpen(!1),D.getState().setMobileActionsOpen(!1))},[O]),(0,b.useEffect)(()=>{v||D.getState().setWorkspacePanelFullscreen(!1)},[v]),(0,b.useEffect)(()=>()=>{ce.current?.abort()},[ce]);let Se=A(C),Ce=!!C.Thinking,we=Re({workspaceFiles:g,accessMode:_}),Te=Ie({isMobile:O}),Ee=Xe({capability:C.NativeDashboard,agentFramework:h,accessMode:_,origin:window.location.origin}),De=!Se,Oe=h===`openclaw`?`OpenClaw`:h===`hermes`?`Hermes`:`原生运行时`,ke=(d.find(e=>e.id===u)||null)?.display_name||u||``,Ae=!O&&o&&Se,je=(0,R.jsxs)(`div`,{className:`flex h-[var(--app-height)] min-h-[var(--app-height)] overflow-hidden bg-white font-sans text-slate-800 dark:bg-slate-900 dark:text-slate-200`,children:[(0,R.jsx)(Nl,{uiCapabilities:C,createNewSession:ie,deleteSession:ae,loadSession:re}),(0,R.jsxs)(`main`,{className:`relative flex min-w-0 flex-1 flex-col bg-white dark:bg-slate-900`,children:[(0,R.jsx)(Fb,{agentName:l,currentSessionId:i,nativeLauncherMode:De,isMobile:O,sidebarOpen:o,mobileSidebarOpen:s,onToggleSidebar:()=>{O?D.getState().toggleMobileSidebar():D.getState().toggleSidebar()},availableModels:d,selectedModel:u,onSelectModel:e=>{le.getState().setSelectedModel(e),O&&D.getState().setMobileActionsOpen(!1)},selectedModelLabel:ke,modelCatalogLoaded:p,modelSource:f,thinkingEnabled:Ce,thinkingMode:m,onSelectThinkingMode:e=>le.getState().setThinkingMode(Qe(e)),mobileActionsOpen:c,onMobileActionsOpenChange:e=>D.getState().setMobileActionsOpen(e),workspaceEnabled:we,onOpenWorkspace:()=>D.getState().setWorkspacePanelOpen(!0),nativeManagementLink:Ee,nativeTerminal:C.NativeTerminal}),De?(0,R.jsx)(Lb,{productLabel:Oe,nativeManagementLink:Ee,nativeTerminal:C.NativeTerminal,workspaceEnabled:we,onOpenWorkspace:()=>D.getState().setWorkspacePanelOpen(!0)}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Db,{agentName:l,isMobile:O,onDeleteFeedback:be,onSubmitFeedback:ye,onRespondToApproval:xe,onStopGeneration:ge,onCancelRemote:C.StopRun?ve:void 0,checkpointResumeEnabled:C.RunLifecycle.Enabled&&C.RunLifecycle.Checkpoints&&C.RunLifecycle.CheckpointResume,onResumeCheckpoint:he}),(0,R.jsx)(Mb,{composerMaxHeight:te,submitDraft:de,stopGeneration:ge,cancelRemote:C.StopRun?ve:void 0,isMobile:O})]})]}),(0,R.jsx)(_z,{agentId:r,capability:g,workspacePanelOpen:v,workspacePanelWidth:y,workspacePanelFullscreen:x,isMobile:O,workspaceEnabled:we,workspaceFiles:g,workspacePanelPresentation:Te,closeWorkspacePanel:()=>{D.getState().setWorkspacePanelFullscreen(!1),D.getState().setWorkspacePanelOpen(!1)},handleWorkspacePanelResizeStart:e=>{if(x||O)return;e.preventDefault();let t=e.clientX,n=y,r=Se&&Ae?280:0,i=document.body.style.cursor,a=document.body.style.userSelect;document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let o=e=>{let i=n+t-e.clientX;D.getState().setWorkspacePanelWidth(Gt(i,window.innerWidth,r))},s=()=>{document.body.style.cursor=i,document.body.style.userSelect=a,window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},api:n}),w&&(0,R.jsx)(b.Suspense,{fallback:null,children:(0,R.jsx)(Nz,{})})]});return t?(0,R.jsx)(t,{children:je}):je}function Fz(){return(0,R.jsx)(Pz,{})}function Iz(e){let t=e instanceof Error?e.message:String(e||``);return/loading chunk|chunkloaderror|failed to fetch dynamically imported module|error loading dynamically imported module|importing a module script failed/i.test(t)}var Lz=`agentengine-ui:chunk-reload-attempted`,Rz=class extends b.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){if(console.error(`UI 渲染错误:`,e,t),Iz(e))try{window.sessionStorage.getItem(Lz)||(window.sessionStorage.setItem(Lz,String(Date.now())),window.location.reload())}catch{window.location.reload()}}handleReload=()=>{try{window.sessionStorage.removeItem(Lz)}catch{}this.setState({hasError:!1,error:null}),window.location.reload()};render(){return this.state.hasError?(0,R.jsx)(`div`,{className:`flex h-screen w-screen items-center justify-center bg-slate-50 dark:bg-slate-900`,children:(0,R.jsxs)(`div`,{className:`max-w-md rounded-2xl border border-red-200 bg-white p-8 text-center shadow-lg dark:border-red-900 dark:bg-slate-950`,children:[(0,R.jsx)(`div`,{className:`mb-4 text-4xl`,children:`⚠`}),(0,R.jsx)(`h1`,{className:`mb-2 text-xl font-semibold text-red-600 dark:text-red-400`,children:`页面渲染出错`}),(0,R.jsx)(`p`,{className:`mb-6 text-sm text-slate-600 dark:text-slate-400`,children:this.state.error?.message||`发生了未知错误,请刷新页面重试。`}),(0,R.jsx)(`button`,{onClick:this.handleReload,className:`rounded-lg bg-blue-600 px-6 py-2.5 text-sm font-medium text-white transition hover:bg-blue-700`,children:`刷新页面`})]})}):this.props.children}};function zz(){let e=D(e=>e.toasts),t=D(e=>e.dismissToast);return(0,b.useEffect)(()=>{if(!e.length)return;let n=e[0],r=3e3-(Date.now()-n.createdAt);if(r<=0){t(n.id);return}let i=setTimeout(()=>t(n.id),r);return()=>clearTimeout(i)},[e,t]),e.length?(0,R.jsx)(`div`,{className:`fixed bottom-4 right-4 z-50 flex flex-col gap-2`,children:e.map(e=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg px-4 py-3 text-sm shadow-lg transition-all ${e.variant===`error`?`bg-red-600 text-white`:`bg-slate-800 text-white dark:bg-slate-200 dark:text-slate-900`}`,children:[(0,R.jsx)(`span`,{className:`flex-1`,children:e.message}),(0,R.jsx)(`button`,{onClick:()=>t(e.id),className:`shrink-0 rounded p-0.5 opacity-70 hover:opacity-100`,children:(0,R.jsx)(gi,{size:14})})]},e.id))}):null}T.createRoot(document.getElementById(`root`)).render((0,R.jsxs)(Rz,{children:[(0,R.jsx)(Fz,{}),(0,R.jsx)(zz,{})]}));export{U as $,Lk as A,mS as B,aj as C,s as Ct,Z as D,FA as E,Gk as F,Ny as G,PS as H,hA as I,gg as J,by as K,Y as L,Bk as M,dA as N,Pk as O,pA as P,Bd as Q,eO as R,rj as S,o as St,AA as T,Wy as U,Fx as V,W,gh as X,hh as Y,oh as Z,Uj as _,Vr as _t,uL as a,Kl as at,Ej as b,pe as bt,oj as c,Qa as ct,fj as d,mi as dt,vd as et,PM as f,di as ft,Lj as g,Hr as gt,Fj as h,Gr as ht,lL as i,_u as it,Vk as j,Wk as k,Q as l,L as lt,ij as m,ii as mt,iz as n,bu as nt,bR as o,Fl as ot,Rj as p,oi as pt,y_ as q,oL as r,xu as rt,cj as s,Pl as st,rz as t,Su as tt,yj as u,gi as ut,Hj as v,Ir as vt,lj as w,l as wt,xj as x,p as xt,Vj as y,N as yt,G as z};