@kingsoftcloud/ksadk-web 0.3.10 → 0.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RELEASE_PROVENANCE.json +2 -2
- package/dist-ksadk/assets/{ArtifactsPanel-KzcO_tZH.js → ArtifactsPanel-C1YoaKhx.js} +1 -1
- package/dist-ksadk/assets/{CodeBlock-BGqAhmyz.js → CodeBlock-DHuAWfr5.js} +1 -1
- package/dist-ksadk/assets/{MathMessageMarkdown-Bu5YkZz8.js → MathMessageMarkdown-cvdrBwYr.js} +1 -1
- package/dist-ksadk/assets/{MermaidBlock-ibbHIg-B.js → MermaidBlock-DeBkbJvI.js} +6 -6
- package/dist-ksadk/assets/{NativeTerminalPanel-DYD4i8DH.js → NativeTerminalPanel-oJj44_sV.js} +1 -1
- package/dist-ksadk/assets/{abnfDiagram-VCTEODGH-DSzm798d.js → abnfDiagram-VCTEODGH-Dhfv25o2.js} +1 -1
- package/dist-ksadk/assets/{arc-BdSe5xC-.js → arc-C35w-pn1.js} +1 -1
- package/dist-ksadk/assets/architecture-7GRP2DOG-BCsa26zi.js +1 -0
- package/dist-ksadk/assets/{architectureDiagram-5GKGNRK7-IlUSNE0r.js → architectureDiagram-5GKGNRK7-FoMY_u6D.js} +1 -1
- package/dist-ksadk/assets/{blockDiagram-NRAW4CY4-D27YbdEM.js → blockDiagram-NRAW4CY4-zD4Rt7oE.js} +1 -1
- package/dist-ksadk/assets/{c4Diagram-UCG6FXSJ-BOTD9bzX.js → c4Diagram-UCG6FXSJ-BCtGGkhN.js} +1 -1
- package/dist-ksadk/assets/channel-_KDifNys.js +1 -0
- package/dist-ksadk/assets/chunk-2Q5K7J3B-HdVkJ9F0.js +1 -0
- package/dist-ksadk/assets/{chunk-5VM5RSS4-9c10Ee3a.js → chunk-5VM5RSS4-C2Ms13_k.js} +1 -1
- package/dist-ksadk/assets/{chunk-F27PBJKO-DndCmxKx.js → chunk-F27PBJKO-BoTj-qgx.js} +1 -1
- package/dist-ksadk/assets/{chunk-G27WJ6UU-ph1aR2ew.js → chunk-G27WJ6UU-DOMyyjHH.js} +1 -1
- package/dist-ksadk/assets/{chunk-JWPE2WC7-MGRKkdNg.js → chunk-JWPE2WC7-DbJJqDli.js} +1 -1
- package/dist-ksadk/assets/{chunk-LCL6LL3I-Crfo5Bg9.js → chunk-LCL6LL3I-CLuRCt_W.js} +1 -1
- package/dist-ksadk/assets/{chunk-POPQ4Y6H-CKzGLlYk.js → chunk-POPQ4Y6H-D0Dz847e.js} +1 -1
- package/dist-ksadk/assets/{chunk-RHFEMEQ7-D8MCYaSK.js → chunk-RHFEMEQ7-BWSRzEcd.js} +1 -1
- package/dist-ksadk/assets/{chunk-SVP7TREG-BzTXc0wA.js → chunk-SVP7TREG-CPoHqkCY.js} +1 -1
- package/dist-ksadk/assets/{chunk-XXDRQBXY-BC5ReyyI.js → chunk-XXDRQBXY-Bx1jS-X-.js} +1 -1
- package/dist-ksadk/assets/classDiagram-DTDB5LWJ-BVCW3ZqZ.js +1 -0
- package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-BVCW3ZqZ.js +1 -0
- package/dist-ksadk/assets/{cose-bilkent-JH36ORCC-CpYw536e.js → cose-bilkent-JH36ORCC-LzyWm4m0.js} +1 -1
- package/dist-ksadk/assets/cynefin-OW5HDTMX-CNXjFctL.js +1 -0
- package/dist-ksadk/assets/{cynefinDiagram-5FMLGOSQ-BLnqs2UC.js → cynefinDiagram-5FMLGOSQ-BlW_bHED.js} +1 -1
- package/dist-ksadk/assets/{dagre-3AP2YEHR-DnRoksk8.js → dagre-3AP2YEHR-Bu_S86_i.js} +1 -1
- package/dist-ksadk/assets/{dagre-C-q_cMTM.js → dagre-B7nCawed.js} +1 -1
- package/dist-ksadk/assets/{diagram-S7CK7UJ4-DD5tL35w.js → diagram-S7CK7UJ4-W_Zow2Km.js} +1 -1
- package/dist-ksadk/assets/{diagram-UQ7AKVKN-BpAtdFE6.js → diagram-UQ7AKVKN-CLIKAHON.js} +1 -1
- package/dist-ksadk/assets/{diagram-VSXAHHWV-CMehUJPO.js → diagram-VSXAHHWV-Dv6_QAlN.js} +1 -1
- package/dist-ksadk/assets/{diagram-VX7I27RA-QbNJzCSv.js → diagram-VX7I27RA-BWAWRDtZ.js} +1 -1
- package/dist-ksadk/assets/{diagram-Z3DM3KII-B4X85Tlu.js → diagram-Z3DM3KII-XA_rWMss.js} +1 -1
- package/dist-ksadk/assets/{dist-DYNUYmYr.js → dist-0X_j2Rcc.js} +1 -1
- package/dist-ksadk/assets/{dist-I8jZ1y80.js → dist-1nXCdsej.js} +1 -1
- package/dist-ksadk/assets/{dist-Dq-1VFQW.js → dist-2vL2sAdF.js} +1 -1
- package/dist-ksadk/assets/{dist-n_EDf0JP.js → dist-B3bA05-e.js} +1 -1
- package/dist-ksadk/assets/{dist-2TJ1ZCOL.js → dist-BLpRy_Yx.js} +1 -1
- package/dist-ksadk/assets/{dist-DDKMMWtJ.js → dist-BO_UwatH.js} +1 -1
- package/dist-ksadk/assets/{dist-ZHG09ibd.js → dist-BdNFAney.js} +1 -1
- package/dist-ksadk/assets/{dist-A2T1KeTr.js → dist-C0J5_3qM.js} +1 -1
- package/dist-ksadk/assets/{dist-DHafuXFW.js → dist-CGt_UGeO.js} +1 -1
- package/dist-ksadk/assets/{dist-D1HTEtve.js → dist-CIRMvUM4.js} +1 -1
- package/dist-ksadk/assets/{dist-TRJ8GXB4.js → dist-CIpWk_5f.js} +1 -1
- package/dist-ksadk/assets/{dist-smDVDmJ_.js → dist-CPyieXEf.js} +1 -1
- package/dist-ksadk/assets/{dist-CqqLUjBZ.js → dist-D-92S-Fd.js} +1 -1
- package/dist-ksadk/assets/{dist-DKoNUyW5.js → dist-DNKuMzWc.js} +1 -1
- package/dist-ksadk/assets/{dist-a8wIzj7Z.js → dist-DWfdmz9s.js} +1 -1
- package/dist-ksadk/assets/{dist-C7sM-UN3.js → dist-DppE_r-D.js} +1 -1
- package/dist-ksadk/assets/{dist-BEyTkcDY.js → dist-DyG6Ya-z.js} +1 -1
- package/dist-ksadk/assets/{dist-8jyOcR4w.js → dist-M-SrdhhZ.js} +1 -1
- package/dist-ksadk/assets/{dist-Cp7irw0l.js → dist-mqD5TZup.js} +1 -1
- package/dist-ksadk/assets/{dist-vvj-wd6e.js → dist-n3n6t_FO.js} +1 -1
- package/dist-ksadk/assets/{dist-CZYb4PF9.js → dist-qe8xjesy.js} +1 -1
- package/dist-ksadk/assets/{dist-Bi-CzopW.js → dist-t6MzE0jU.js} +1 -1
- package/dist-ksadk/assets/{ebnfDiagram-PWID7BFC-DoytR8yo.js → ebnfDiagram-PWID7BFC-BfCzF1Xi.js} +1 -1
- package/dist-ksadk/assets/{erDiagram-SSCWMZ5O-D5wO7Xx9.js → erDiagram-SSCWMZ5O-Dpz9_0zn.js} +1 -1
- package/dist-ksadk/assets/eventmodeling-NTZA5JFV-B5-8RH9c.js +1 -0
- package/dist-ksadk/assets/flowDiagram-A5DVABFB-BppFxEKw.js +1 -0
- package/dist-ksadk/assets/{ganttDiagram-EL5Y4UJY-DXwswSTx.js → ganttDiagram-EL5Y4UJY-DDaG1f4_.js} +1 -1
- package/dist-ksadk/assets/gitGraph-4MIJSDKK-B-AhYj4C.js +1 -0
- package/dist-ksadk/assets/{gitGraphDiagram-WWUBYQGX-BQ35_U5m.js → gitGraphDiagram-WWUBYQGX-DcxzRwYC.js} +1 -1
- package/dist-ksadk/assets/{index-C9lq1_sV.js → index-D5qyyhTH.js} +5 -5
- package/dist-ksadk/assets/info-A6RAGUB7-0uiKrC35.js +1 -0
- package/dist-ksadk/assets/{infoDiagram-RXCK75RN-BNKK7mwC.js → infoDiagram-RXCK75RN-CYMdn6lQ.js} +1 -1
- package/dist-ksadk/assets/{ishikawaDiagram-5VMMS53U-RrBchfXo.js → ishikawaDiagram-5VMMS53U-CLHFAD6c.js} +1 -1
- package/dist-ksadk/assets/{journeyDiagram-EYS64GPL-DbeWuBTU.js → journeyDiagram-EYS64GPL-BHSKQGAl.js} +1 -1
- package/dist-ksadk/assets/{kanban-definition-3QL26DDD-CgMJQBFh.js → kanban-definition-3QL26DDD-D5W3tjTT.js} +1 -1
- package/dist-ksadk/assets/{katex-cfBDFis_.js → katex-mtjOi4KM.js} +1 -1
- package/dist-ksadk/assets/{linear-CvMJLkoS.js → linear-BETqsxE_.js} +1 -1
- package/dist-ksadk/assets/{mermaid-parser.core-DBD4MgAK.js → mermaid-parser.core-DPWrvs90.js} +2 -2
- package/dist-ksadk/assets/{mindmap-definition-FBJOCRG2-DOfK5ncl.js → mindmap-definition-FBJOCRG2-CJG2mfBP.js} +1 -1
- package/dist-ksadk/assets/packet-AYTQ26CC-BVTmZ_cw.js +1 -0
- package/dist-ksadk/assets/{pegDiagram-XKGWAZYB--xu_koqY.js → pegDiagram-XKGWAZYB-GjAPNaqn.js} +1 -1
- package/dist-ksadk/assets/pie-WAS4IAKB-DyfxBU7V.js +1 -0
- package/dist-ksadk/assets/{pieDiagram-E7YTZNPT-CPOVLG46.js → pieDiagram-E7YTZNPT-ToIewrqr.js} +1 -1
- package/dist-ksadk/assets/{quadrantDiagram-AXDQQJYC-DOL7ryOQ.js → quadrantDiagram-AXDQQJYC-4d78KiEY.js} +1 -1
- package/dist-ksadk/assets/radar-RG4KPBEZ-FFontjL2.js +1 -0
- package/dist-ksadk/assets/railroad-74A4TZTK-D0Uidzen.js +1 -0
- package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-BOo_9T2h.js +1 -0
- package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-D6-BjW7Z.js +1 -0
- package/dist-ksadk/assets/railroad-peg-WCYAUIDC-CXx__yMm.js +1 -0
- package/dist-ksadk/assets/{railroadDiagram-O6MQD6OU-B4dCVq9q.js → railroadDiagram-O6MQD6OU-DKzx4xfv.js} +1 -1
- package/dist-ksadk/assets/{requirementDiagram-EFPCY7ZU-im_O4Plh.js → requirementDiagram-EFPCY7ZU-CJYljxQS.js} +1 -1
- package/dist-ksadk/assets/{sankeyDiagram-P5KCCOFB-DJ0_PPoR.js → sankeyDiagram-P5KCCOFB-DLU2fV1w.js} +1 -1
- package/dist-ksadk/assets/{sequenceDiagram-WJ2MYXX4-ULwMzB2T.js → sequenceDiagram-WJ2MYXX4-CVqysrA9.js} +1 -1
- package/dist-ksadk/assets/{sizeCapture-X5ZJPWSS-K_Fuf0h2.js → sizeCapture-X5ZJPWSS-BUxfmTHc.js} +1 -1
- package/dist-ksadk/assets/{stateDiagram-HBIQ2CUA-CsDLAfeQ.js → stateDiagram-HBIQ2CUA-CNFgYI9E.js} +1 -1
- package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-BXAFScz8.js +1 -0
- package/dist-ksadk/assets/{swimlanes-XN3QIQJK-QxQHBdN8.js → swimlanes-XN3QIQJK-B6qCMe8N.js} +1 -1
- package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-uIQ2lJKH.js +8 -0
- package/dist-ksadk/assets/{timeline-definition-24CTP7MA-C42CTqeJ.js → timeline-definition-24CTP7MA-CMD3x_U_.js} +1 -1
- package/dist-ksadk/assets/treeView-Q6P3EWNA-CK5GgucZ.js +1 -0
- package/dist-ksadk/assets/treemap-WGGIJYW6-Bq1u1SpG.js +1 -0
- package/dist-ksadk/assets/{vennDiagram-4TSXK5OY-BY55il3e.js → vennDiagram-4TSXK5OY-BqtUqvXM.js} +1 -1
- package/dist-ksadk/assets/wardley-WFR3VGLG-QAt06uEz.js +1 -0
- package/dist-ksadk/assets/{wardleyDiagram-VM6X3IG4-DiFB1AdX.js → wardleyDiagram-VM6X3IG4-B5KfDjI-.js} +1 -1
- package/dist-ksadk/assets/{xychartDiagram-S5SC5T6Z-BFPyOnRF.js → xychartDiagram-S5SC5T6Z-BaUlSZrn.js} +1 -1
- package/dist-ksadk/index.html +1 -1
- package/dist-lib/{ConnectedComposer-Cz5HKWFx.js → ConnectedComposer-BaRxxvhk.js} +23 -21
- package/dist-lib/chat-composer.js +1 -1
- package/dist-lib/components/chat/ConnectedComposer.d.ts.map +1 -1
- package/dist-lib/components.js +1 -1
- package/dist-lib/runtime.js +1 -1
- package/package.json +1 -1
- package/dist-ksadk/assets/architecture-7GRP2DOG-DT48U0B8.js +0 -1
- package/dist-ksadk/assets/channel-s-qBe2RL.js +0 -1
- package/dist-ksadk/assets/chunk-2Q5K7J3B-Lg7OmxrP.js +0 -1
- package/dist-ksadk/assets/classDiagram-DTDB5LWJ-COCLgDEs.js +0 -1
- package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-COCLgDEs.js +0 -1
- package/dist-ksadk/assets/cynefin-OW5HDTMX-C-xt1CX-.js +0 -1
- package/dist-ksadk/assets/eventmodeling-NTZA5JFV-3qcv137n.js +0 -1
- package/dist-ksadk/assets/flowDiagram-A5DVABFB-BXo2QnbF.js +0 -1
- package/dist-ksadk/assets/gitGraph-4MIJSDKK-C1qYB3cc.js +0 -1
- package/dist-ksadk/assets/info-A6RAGUB7-B4MWRy7s.js +0 -1
- package/dist-ksadk/assets/packet-AYTQ26CC-BaJsmR1u.js +0 -1
- package/dist-ksadk/assets/pie-WAS4IAKB-mlz4CzK6.js +0 -1
- package/dist-ksadk/assets/radar-RG4KPBEZ-DW6k0WrX.js +0 -1
- package/dist-ksadk/assets/railroad-74A4TZTK-CvdY089q.js +0 -1
- package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-CrOcKyhi.js +0 -1
- package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-D9yFdUVf.js +0 -1
- package/dist-ksadk/assets/railroad-peg-WCYAUIDC-BfPsg4va.js +0 -1
- package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-DgIVh3e1.js +0 -1
- package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-Fx2sfhbU.js +0 -8
- package/dist-ksadk/assets/treeView-Q6P3EWNA-B-2NNYeb.js +0 -1
- package/dist-ksadk/assets/treemap-WGGIJYW6-Csy9dR_3.js +0 -1
- package/dist-ksadk/assets/wardley-WFR3VGLG-Cx-uCkSS.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./MathMessageMarkdown-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./MathMessageMarkdown-cvdrBwYr.js","./CodeBlock-DHuAWfr5.js","./MermaidBlock-DeBkbJvI.js","./katex-mtjOi4KM.js","./MathMessageMarkdown-BorAY7qD.css","./NativeTerminalPanel-oJj44_sV.js","./NativeTerminalPanel-CHOd7Rch.css","./dist-BLpRy_Yx.js","./dist-CIpWk_5f.js","./dist-DNKuMzWc.js","./dist-0X_j2Rcc.js","./dist-BdNFAney.js","./dist-t6MzE0jU.js","./dist-DWfdmz9s.js","./dist-BO_UwatH.js","./dist-DppE_r-D.js","./dist-M-SrdhhZ.js","./dist-qe8xjesy.js","./dist-n3n6t_FO.js","./dist-D-92S-Fd.js","./dist-DyG6Ya-z.js","./dist-CPyieXEf.js","./dist-2vL2sAdF.js","./dist-B3bA05-e.js","./dist-1nXCdsej.js","./dist-CIRMvUM4.js","./dist-CGt_UGeO.js","./dockerfile-BLkNEvjs.js","./simple-mode-DRpGK0lJ.js","./factor-D7LVTn2l.js","./nsis-AQ_alPln.js","./pug-Bugr-47h.js","./javascript-9Tg8ixDm.js","./dist-mqD5TZup.js","./dist-C0J5_3qM.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,E());else{var t=n(l);t!==null&&ie(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function ee(){return g?!0:!(e.unstable_now()-T<w)}function te(){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&&ee());){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&&ie(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?E():S=!1}}}var E;if(typeof y==`function`)E=function(){y(te)};else if(typeof MessageChannel<`u`){var ne=new MessageChannel,re=ne.port2;ne.port1.onmessage=te,E=function(){re.postMessage(null)}}else E=function(){_(te,0)};function ie(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,ie(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,E()))),r},e.unstable_shouldYield=ee,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 ee(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function te(e,t){return ee(e.type,t,e.props)}function E(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function ne(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var re=/\/+/g;function ie(e,t){return typeof e==`object`&&e&&e.key!=null?ne(``+e.key):t.toString(36)}function ae(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 oe(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,oe(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+ie(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(re,`$&/`)+`/`),oe(o,r,i,``,function(e){return e})):o!=null&&(E(o)&&(o=te(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(re,`$&/`)+`/`)+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+ie(a,u),c+=oe(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+ie(a,u++),c+=oe(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return oe(ae(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 se(e,t,n){if(e==null)return e;var r=[],i=0;return oe(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function ce(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 D=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)},O={map:se,forEach:function(e,t,n){se(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return se(e,function(){t++}),t},toArray:function(e){return se(e,function(e){return e})||[]},only:function(e){if(!E(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=O,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 ee(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 ee(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=E,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:ce}},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,D)}catch(e){D(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`),ee=Symbol.for(`react.suspense_list`),te=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),ne=Symbol.for(`react.activity`),re=Symbol.for(`react.memo_cache_sentinel`),ie=Symbol.iterator;function ae(e){return typeof e!=`object`||!e?null:(e=ie&&e[ie]||e[`@@iterator`],typeof e==`function`?e:null)}var oe=Symbol.for(`react.client.reference`);function se(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===oe?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 ee:return`SuspenseList`;case ne: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 te:return t=e.displayName||null,t===null?se(e.type)||`Memo`:t;case E:t=e._payload,e=e._init;try{return se(e(t))}catch{}}return null}var ce=Array.isArray,D=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,O=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,le={pending:!1,data:null,method:null,action:null},ue=[],de=-1;function fe(e){return{current:e}}function pe(e){0>de||(e.current=ue[de],ue[de]=null,de--)}function k(e,t){de++,ue[de]=e.current,e.current=t}var me=fe(null),he=fe(null),ge=fe(null),_e=fe(null);function ve(e,t){switch(k(ge,t),k(he,e),k(me,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?sf(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=sf(t),e=cf(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}pe(me),k(me,e)}function ye(){pe(me),pe(he),pe(ge)}function be(e){e.memoizedState!==null&&k(_e,e);var t=me.current,n=cf(t,e.type);t!==n&&(k(he,e),k(me,n))}function xe(e){he.current===e&&(pe(me),pe(he)),_e.current===e&&(pe(_e),gp._currentValue=le)}var Se,Ce;function we(e){if(Se===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Se=t&&t[1]||``,Ce=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+Se+e+Ce}var Te=!1;function Ee(e,t){if(!e||Te)return``;Te=!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(`
|
|
@@ -193,11 +193,11 @@ $2`),t=t.replace(/([。;;::\.])\s*-(?!-)\s*/g,`$1
|
|
|
193
193
|
`:i||a?`
|
|
194
194
|
`:r})}function uq(e){if(!e)return e;let t=String(e).replace(/\r\n/g,`
|
|
195
195
|
`).replace(/\r/g,`
|
|
196
|
-
`).trim();return t=YK(t),t=eq(t),(t.match(/```/g)||[]).length%2==1&&(t=`${t}\n\`\`\``),lq(t.split("```")).join("```").trim()}var dq=new RegExp([`/(?:[^\\s\`'"()\\[\\]{}<>,。;!?、:·…]+/)+[^\\s\`'"()\\[\\]{}<>,。;!?、:·…]+\\.(?:md|markdown|txt|json|csv|tsv|log|py|js|ts|tsx|jsx|html|css|yaml|yml|toml|xml|sh|sql|go|rs|java|c|cpp|h|diff|ini|png|jpg|jpeg|gif|webp|svg|bmp|ico)`,`\\.{1,2}/[^\\s\`'"()\\[\\]{}<>,。;!?、:·…]+\\.(?:md|markdown|txt|json|csv|tsv|log|py|js|ts|tsx|jsx|html|css|yaml|yml|toml|xml|sh|sql|png|jpg|jpeg|gif|webp|svg)`].join(`|`),`g`),fq=new Set([`a`,`script`,`style`,`head`]);function pq(e){let t=[],n=0;dq.lastIndex=0;let r;for(;r=dq.exec(e);)r.index>n&&t.push({type:`text`,value:e.slice(n,r.index)}),t.push({type:`element`,tagName:`a`,properties:{href:`#`,dataWorkspaceFile:r[0]},children:[{type:`text`,value:r[0]}]}),n=r.index+r[0].length;return n<e.length&&t.push({type:`text`,value:e.slice(n)}),t.length?t:[{type:`text`,value:e}]}function mq(){return e=>{let t=(e,n)=>{if(!e.children)return;let r=n||fq.has(e.tagName||``),i=[];for(let n of e.children){if(!r&&n.type===`text`&&typeof n.value==`string`&&(dq.lastIndex=0,dq.test(n.value))){i.push(...pq(n.value));continue}t(n,r),i.push(n)}e.children=i};t(e,!1)}}function hq(e){let t=[],n=0;dq.lastIndex=0;let r;for(;r=dq.exec(e);)r.index>n&&t.push({type:`text`,value:e.slice(n,r.index)}),t.push({type:`file`,value:r[0]}),n=r.index+r[0].length;return n===0?[{type:`text`,value:e}]:(n<e.length&&t.push({type:`text`,value:e.slice(n)}),t)}var gq=`ksadk-workspace-file-preview`;function _q(e){typeof window>`u`||window.dispatchEvent(new CustomEvent(gq,{detail:{path:e}}))}var vq=`modulepreload`,yq=function(e,t){return new URL(e,t).href},bq={},J=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=yq(t,n),t in bq)return;bq[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`:vq,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)})},xq=v.lazy(()=>J(()=>import(`./CodeBlock-
|
|
196
|
+
`).trim();return t=YK(t),t=eq(t),(t.match(/```/g)||[]).length%2==1&&(t=`${t}\n\`\`\``),lq(t.split("```")).join("```").trim()}var dq=new RegExp([`/(?:[^\\s\`'"()\\[\\]{}<>,。;!?、:·…]+/)+[^\\s\`'"()\\[\\]{}<>,。;!?、:·…]+\\.(?:md|markdown|txt|json|csv|tsv|log|py|js|ts|tsx|jsx|html|css|yaml|yml|toml|xml|sh|sql|go|rs|java|c|cpp|h|diff|ini|png|jpg|jpeg|gif|webp|svg|bmp|ico)`,`\\.{1,2}/[^\\s\`'"()\\[\\]{}<>,。;!?、:·…]+\\.(?:md|markdown|txt|json|csv|tsv|log|py|js|ts|tsx|jsx|html|css|yaml|yml|toml|xml|sh|sql|png|jpg|jpeg|gif|webp|svg)`].join(`|`),`g`),fq=new Set([`a`,`script`,`style`,`head`]);function pq(e){let t=[],n=0;dq.lastIndex=0;let r;for(;r=dq.exec(e);)r.index>n&&t.push({type:`text`,value:e.slice(n,r.index)}),t.push({type:`element`,tagName:`a`,properties:{href:`#`,dataWorkspaceFile:r[0]},children:[{type:`text`,value:r[0]}]}),n=r.index+r[0].length;return n<e.length&&t.push({type:`text`,value:e.slice(n)}),t.length?t:[{type:`text`,value:e}]}function mq(){return e=>{let t=(e,n)=>{if(!e.children)return;let r=n||fq.has(e.tagName||``),i=[];for(let n of e.children){if(!r&&n.type===`text`&&typeof n.value==`string`&&(dq.lastIndex=0,dq.test(n.value))){i.push(...pq(n.value));continue}t(n,r),i.push(n)}e.children=i};t(e,!1)}}function hq(e){let t=[],n=0;dq.lastIndex=0;let r;for(;r=dq.exec(e);)r.index>n&&t.push({type:`text`,value:e.slice(n,r.index)}),t.push({type:`file`,value:r[0]}),n=r.index+r[0].length;return n===0?[{type:`text`,value:e}]:(n<e.length&&t.push({type:`text`,value:e.slice(n)}),t)}var gq=`ksadk-workspace-file-preview`;function _q(e){typeof window>`u`||window.dispatchEvent(new CustomEvent(gq,{detail:{path:e}}))}var vq=`modulepreload`,yq=function(e,t){return new URL(e,t).href},bq={},J=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=yq(t,n),t in bq)return;bq[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`:vq,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)})},xq=v.lazy(()=>J(()=>import(`./CodeBlock-DHuAWfr5.js`).then(e=>({default:e.CodeBlock})),[],import.meta.url)),Sq=v.lazy(()=>J(()=>import(`./MermaidBlock-DeBkbJvI.js`).then(e=>({default:e.MermaidBlock})),[],import.meta.url)),Cq=v.lazy(()=>J(()=>import(`./MathMessageMarkdown-cvdrBwYr.js`).then(e=>({default:e.MathMessageMarkdown})),__vite__mapDeps([0,1,2,3,4]),import.meta.url));function wq(e){return/\$[^$]+\$|\$\$[^$]+\$\$/.test(e)}function Tq(e){if(e)try{let t=new URL(e,typeof window>`u`?`http://localhost/`:window.location.href).protocol.toLowerCase();return[`http:`,`https:`,`mailto:`].includes(t)?e:void 0}catch{return}}function Eq(e){if(e)try{let t=new URL(e,typeof window>`u`?`http://localhost/`:window.location.href).protocol.toLowerCase();return[`http:`,`https:`].includes(t)?e:void 0}catch{return}}function Dq({src:e,alt:t,...n}){let r=Eq(e),[i,a]=(0,v.useState)(r?`loading`:`error`),[o,s]=(0,v.useState)(null);return!r||i===`error`?(0,k.jsx)(`span`,{role:`img`,"aria-label":t||`图片无法加载`,className:`my-2 inline-flex rounded-md border border-border bg-muted px-3 py-2 text-xs text-text-secondary`,children:t||`图片无法加载`}):(0,k.jsxs)(`figure`,{className:`my-3 max-w-full`,children:[(0,k.jsx)(`a`,{href:r,target:`_blank`,rel:`noopener noreferrer`,title:`查看原图`,children:(0,k.jsx)(`img`,{...n,src:r,alt:t||`图片`,loading:`lazy`,decoding:`async`,onLoad:e=>{a(`loaded`),s({width:e.currentTarget.naturalWidth,height:e.currentTarget.naturalHeight})},onError:()=>a(`error`),className:`max-h-[28rem] max-w-full cursor-zoom-in rounded-lg border border-border object-contain shadow-sm`})}),(0,k.jsxs)(`figcaption`,{className:`mt-1 flex items-center gap-2 text-xs text-text-secondary`,children:[(0,k.jsx)(`span`,{children:i===`loading`?`图片加载中…`:`点击查看原图`}),o?(0,k.jsxs)(`span`,{"aria-label":`图片尺寸`,children:[`· `,o.width,` × `,o.height]}):null,(0,k.jsx)(`a`,{href:r,download:!0,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary hover:underline`,children:`下载`})]})]})}var Oq={h1({children:e}){return(0,k.jsx)(`h1`,{className:`mb-3.5 mt-5 text-[17px] font-semibold text-foreground`,children:e})},h2({children:e}){return(0,k.jsx)(`h2`,{className:`mb-2.5 mt-4.5 text-[15px] font-semibold text-foreground`,children:e})},h3({children:e}){return(0,k.jsx)(`h3`,{className:`mb-2 mt-3.5 text-[14px] font-semibold text-foreground`,children:e})},p({children:e}){return(0,k.jsx)(`p`,{className:`mb-2.5 min-w-0 break-words leading-[1.65] text-foreground`,children:e})},ul({children:e}){return(0,k.jsx)(`ul`,{className:`mb-3 list-disc space-y-1.5 pl-5 text-foreground`,children:e})},ol({children:e}){return(0,k.jsx)(`ol`,{className:`mb-3 list-decimal space-y-1.5 pl-8 text-foreground`,children:e})},li({children:e}){return(0,k.jsx)(`li`,{className:`min-w-0 break-words pl-1 leading-6 text-foreground`,children:e})},strong({children:e}){return(0,k.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e})},blockquote({children:e}){return(0,k.jsx)(`blockquote`,{className:`mb-3 border-l-2 border-border pl-4 text-text-secondary`,children:e})},code({className:e,children:t,...n}){let r=/language-(\w+)/.exec(e||``),i=String(t??``);if(!r&&!i.includes(`
|
|
197
197
|
`))return(0,k.jsx)(`code`,{className:`break-all font-mono text-[0.92em] text-text-primary before:content-none after:content-none`,...n,children:t});let a=r?r[1]:``;return a===`mermaid`?(0,k.jsx)(v.Suspense,{fallback:(0,k.jsx)(`div`,{className:`h-32 animate-pulse rounded bg-muted`}),children:(0,k.jsx)(Sq,{chart:i})}):(0,k.jsx)(v.Suspense,{fallback:(0,k.jsx)(`pre`,{className:`p-4 text-sm`,children:i}),children:(0,k.jsx)(xq,{language:a,value:i})})},table({children:e,...t}){return(0,k.jsx)(`div`,{className:`mb-3 max-w-full overflow-x-auto rounded-lg border border-border`,children:(0,k.jsx)(`table`,{className:`w-full min-w-[36rem] table-auto border-collapse text-sm text-foreground`,...t,children:e})})},th({children:e,...t}){return(0,k.jsx)(`th`,{className:`break-words border-b border-border bg-muted/40 px-3 py-2 text-left align-top font-semibold text-foreground`,...t,children:e})},td({children:e,...t}){return(0,k.jsx)(`td`,{className:`break-words border-b border-border px-3 py-2 align-top text-text-secondary`,...t,children:e})},a({children:e,href:t,...n}){let r=n[`data-workspace-file`];if(typeof r==`string`&&r)return(0,k.jsx)(`a`,{href:`#`,className:`text-primary underline decoration-primary/40 underline-offset-2 hover:decoration-primary`,title:`预览 ${r}`,onClick:e=>{e.preventDefault(),_q(r)},...n,children:e});let i=Tq(t);return i?(0,k.jsx)(`a`,{href:i,className:`text-primary hover:underline`,target:`_blank`,rel:`noopener noreferrer`,...n,children:e}):(0,k.jsx)(`span`,{className:`text-text-secondary`,children:e})},img({src:e,alt:t,...n}){return(0,k.jsx)(Dq,{src:e,alt:t,...n})}},kq=v.memo(({content:e})=>{let t=uq(e);return(0,k.jsx)(`div`,{className:`max-w-none break-words text-[14px] leading-[1.65] [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,children:(0,k.jsx)(VU,{remarkPlugins:[GK,JK],rehypePlugins:[mq],components:Oq,children:t})})}),Aq=v.memo(({content:e})=>wq(e)?(0,k.jsx)(v.Suspense,{fallback:(0,k.jsx)(kq,{content:e}),children:(0,k.jsx)(Cq,{content:e})}):(0,k.jsx)(kq,{content:e})),jq=/^diff --git "?a\/(.+?)"? "?b\/(.+?)"?$/;function Mq(e){let t=[],n=new Map,r=null;for(let i of e.split(`
|
|
198
198
|
`)){let e=i.match(jq);if(e){let a=e[2],o=n.get(a);if(o){o.lines.push(i),r=o;continue}r={oldPath:e[1],path:a,lines:[i]},n.set(a,r),t.push(r);continue}r?.lines.push(i)}return t}function Nq(e){let t=0,n=0;for(let r of e.lines)r.startsWith(`+`)&&!r.startsWith(`+++`)?t+=1:r.startsWith(`-`)&&!r.startsWith(`---`)&&(n+=1);return{added:t,removed:n}}function Pq(e){return/^diff --git /m.test(e)}function Fq(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Iq(e){let t=Fq(e.properties)||{},n=Array.isArray(e.required)?new Set(e.required.map(String)):new Set,r=[];for(let[e,i]of Object.entries(t)){let t=Fq(i),a=String(t?.type||``).toLowerCase(),o=a===`string`||a===`number`||a===`boolean`||a===`array`?a:`unknown`,s=Fq(t?.items),c=Array.isArray(t?.[`x-codex-options`])?t[`x-codex-options`].map(Fq).map(e=>e?.label).filter(e=>typeof e==`string`):[],l=c.length?c:void 0;r.push({name:e,title:typeof t?.title==`string`?t.title:void 0,description:typeof t?.description==`string`?t.description:void 0,allowOther:t?.[`x-codex-is-other`]===!0,secret:t?.[`x-codex-is-secret`]===!0,type:o,required:n.has(e),enumValues:Array.isArray(t?.enum)?t.enum:Array.isArray(s?.enum)?s.enum:l})}return r}function Lq({schema:e,values:t,onChange:n,disabled:r,onSubmit:i,onCancel:a}){let o=Iq(e),[s,c]=(0,v.useState)(``);return(0,k.jsxs)(`form`,{className:`mt-3`,"data-testid":`interaction-schema-form`,onKeyDown:e=>{e.key===`Enter`&&e.nativeEvent.isComposing&&e.preventDefault()},onSubmit:e=>{if(e.preventDefault(),!r){if(!o.every(e=>{let n=t[e.name];return!e.required||(Array.isArray(n)?n.length>0:String(n??``).trim().length>0)})){c(`请回答必填问题后再提交。`);return}c(``),i()}},children:[o.map(e=>(0,k.jsxs)(`div`,{className:`mb-2 block text-xs text-[var(--ksadk-interaction-muted)]`,children:[(0,k.jsxs)(`span`,{className:`mb-1 block font-medium`,children:[e.description||e.title||e.name,e.required?(0,k.jsx)(`span`,{className:`ml-0.5 text-rose-500`,children:`*`}):null]}),e.enumValues&&e.enumValues.length>0?(0,k.jsxs)(`div`,{className:`space-y-1`,"data-testid":`interaction-field-${e.name}`,children:[e.enumValues.map((i,a)=>{let o=e.type===`array`?Array.isArray(t[e.name])&&t[e.name].includes(i):t[e.name]===i;return(0,k.jsxs)(`label`,{className:`flex min-h-10 cursor-pointer items-center gap-2 rounded-xl px-2 text-sm text-[var(--ksadk-interaction-foreground)] hover:bg-[var(--ksadk-interaction-muted-background)]`,children:[(0,k.jsx)(`span`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-[var(--ksadk-interaction-muted-background)] text-xs text-[var(--ksadk-interaction-muted)]`,children:a+1}),(0,k.jsx)(`input`,{type:e.type===`array`?`checkbox`:`radio`,name:e.name,disabled:r,checked:!!o,onChange:r=>{let a=Array.isArray(t[e.name])?t[e.name]:[],o=e.type===`array`?r.target.checked?[...a,i]:a.filter(e=>e!==i):i;n({...t,[e.name]:o})},className:`h-4 w-4 accent-current`}),(0,k.jsx)(`span`,{children:String(i)})]},String(i))}),e.allowOther?(0,k.jsx)(`input`,{"aria-label":`${e.title||e.name}:自定义回答`,placeholder:`或填写自己的回答`,type:e.secret?`password`:`text`,disabled:r,value:e.type===`array`?(Array.isArray(t[e.name])?t[e.name]:[]).filter(t=>!e.enumValues.includes(t)).join(`
|
|
199
199
|
`):e.enumValues.includes(t[e.name])?``:String(t[e.name]??``),onChange:r=>{let i=r.target.value,a=(Array.isArray(t[e.name])?t[e.name]:[]).filter(t=>e.enumValues.includes(t));n({...t,[e.name]:e.type===`array`?[...a,...i.trim()?[i]:[]]:i})},className:`w-full rounded-lg border border-[var(--ksadk-interaction-border)] bg-[var(--ksadk-interaction-control-background)] px-3 py-2 text-sm text-[var(--ksadk-interaction-foreground)]`}):null]}):e.type===`boolean`?(0,k.jsx)(`input`,{type:`checkbox`,"data-testid":`interaction-field-${e.name}`,disabled:r,checked:!!t[e.name],onChange:r=>n({...t,[e.name]:r.target.checked}),className:`h-4 w-4`}):e.type===`number`?(0,k.jsx)(`input`,{type:`number`,"data-testid":`interaction-field-${e.name}`,disabled:r,value:t[e.name]===void 0?``:String(t[e.name]),onChange:r=>n({...t,[e.name]:r.target.value===``?void 0:Number(r.target.value)}),className:`w-full rounded-md border border-[var(--ksadk-interaction-border)] bg-[var(--ksadk-interaction-control-background)] px-2 py-1.5 text-sm text-foreground`}):(0,k.jsx)(`input`,{type:e.secret?`password`:`text`,"data-testid":`interaction-field-${e.name}`,disabled:r,value:String(t[e.name]??``),onChange:r=>n({...t,[e.name]:r.target.value}),className:`w-full rounded-md border border-[var(--ksadk-interaction-border)] bg-[var(--ksadk-interaction-control-background)] px-2 py-1.5 text-sm text-foreground`})]},e.name)),s?(0,k.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-rose-600`,children:s}):null,(0,k.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,k.jsx)(`button`,{type:`submit`,"data-testid":`interaction-submit`,disabled:r,className:`inline-flex min-h-8 items-center rounded-md bg-[var(--ksadk-interaction-primary-background)] px-3 py-1.5 text-xs font-semibold text-[var(--ksadk-interaction-primary-foreground)] disabled:cursor-not-allowed disabled:opacity-55`,children:`提交`}),(0,k.jsx)(`button`,{type:`button`,"data-testid":`interaction-form-cancel`,disabled:r,onClick:a,className:`inline-flex min-h-8 items-center rounded-md px-3 py-1.5 text-xs font-medium text-slate-500 underline-offset-2 hover:underline disabled:cursor-not-allowed disabled:opacity-55 dark:text-slate-400`,children:`取消本次确认`})]})]})}function Rq({surfaceId:e,serializedMessages:t}){let{processMessages:n}=RO();return(0,v.useEffect)(()=>{n(JSON.parse(t))},[t,n]),(0,k.jsx)(Hte,{surfaceId:e,className:`w-full`,fallback:(0,k.jsx)(`div`,{className:`text-sm text-slate-500 dark:text-slate-400`,children:`界面内容暂不可用`}),loadingFallback:(0,k.jsx)(`div`,{className:`text-sm text-slate-500 dark:text-slate-400`,children:`正在加载界面`})})}function zq({surfaceId:e,messages:t,onAction:n}){let r=e.startsWith(`input-`)?Yte(t):null;if(r)return(0,k.jsxs)(`details`,{className:`mx-auto mb-3 w-full max-w-3xl px-6 text-sm text-muted-foreground`,"data-testid":`legacy-question-history`,children:[(0,k.jsxs)(`summary`,{className:`cursor-pointer`,children:[`历史提问 · `,r.length,` 个问题`]}),(0,k.jsx)(`ul`,{className:`mt-2 list-disc space-y-1 pl-5`,children:r.map((e,t)=>(0,k.jsx)(`li`,{children:e},t))})]});let i=JSON.stringify(t);return(0,k.jsx)(`div`,{className:`mb-3 w-full overflow-hidden rounded-lg border border-slate-200 bg-white p-3 shadow-sm dark:border-slate-700 dark:bg-slate-900`,children:(0,k.jsx)(Lte,{catalog:VO,onAction:n,children:(0,k.jsx)(Rq,{surfaceId:e,serializedMessages:i})},`${e}:${i}`)})}function Bq({a2ui:e,disabled:t,onSubmit:n,onCancel:r}){return(0,k.jsxs)(`div`,{className:`mt-3`,"data-testid":`interaction-a2ui-surface`,children:[(0,k.jsx)(zq,{surfaceId:`interaction-${e.wireVersion}`,messages:e.messages,onAction:t?void 0:e=>{let t=e.userAction?.context||{};n(typeof t.payload==`object`&&t.payload!==null?t.payload:{...t})}}),t?null:(0,k.jsx)(`button`,{type:`button`,"data-testid":`interaction-a2ui-cancel`,onClick:r,className:`mt-1 inline-flex min-h-8 items-center rounded-md px-3 py-1.5 text-xs font-medium text-slate-500 underline-offset-2 hover:underline dark:text-slate-400`,children:`取消本次确认`})]})}function Vq(e){for(let t of e?.messages||[]){let e=t.inputSchema??t.input_schema??t.schema;if(typeof e==`object`&&e)return e}return null}function Hq(e){if(!e.expiresAt)return!1;let t=Date.parse(e.expiresAt);return Number.isFinite(t)&&t<=Date.now()}function Uq(e){let t=e.extensions.submit_error;return typeof t==`object`&&t&&`code`in t&&`message`in t?{code:String(t.code),message:String(t.message),retryable:!!(`retryable`in t&&t.retryable)}:null}function Wq(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Gq(e){let t=Wq(e);if(t)return t;if(typeof e!=`string`)return null;try{return Wq(JSON.parse(e))}catch{return null}}function Kq(e){return Array.isArray(e)?e.map(String).join(` `):typeof e==`string`?e:``}function qq(e){let t=Gq(e.extensions.detail),n=Gq(e.extensions.arguments),r=t||n||{},i=e.title.replace(/^审批[::]\s*/,``).trim();return{operation:{command_execution:`命令执行`,file_change:`文件修改`,mcp_tool_call:`MCP 工具调用`}[i]||i,command:Kq(r.command??r.cmd),reason:Kq(r.reason??r.justification),cwd:Kq(r.cwd??r.workdir)}}var Jq={approved:`已同意`,rejected:`已拒绝`,submitted:`已提交`,cancelled:`已取消`,expired:`已过期`};function Yq({interactions:e,activeIndex:t,onSelectIndex:n,onRespond:r,localCatalog:i,className:a}){let[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)({}),u=e[Math.min(t,Math.max(e.length-1,0))];if(!u)return null;let d=Hq(u),f=Uq(u),p=qq(u),m=d||u.status===`resolving`,h=Cne(u.presentation?.a2ui,i),g=u.requestSchema??Vq(u.presentation?.a2ui)??null,_=u.kind===`approval`?`basic-controls`:h===`a2ui`?`a2ui`:h===`json-schema-form`&&g||u.requestSchema&&!u.presentation?`json-schema-form`:`basic-controls`,y=_===`json-schema-form`&&g||u.requestSchema,b=(e,t)=>{m||Promise.resolve(r({interactionId:u.interactionId,expectedRevision:u.revision,action:e,response:t,idempotencyKey:$k(u.interactionId,u.revision)})).catch(()=>{})};return(0,k.jsx)(`div`,{"data-testid":`interaction-tray`,"data-slot":`interaction-tray`,"data-ui":`interaction-tray`,"data-interaction-status":u.status,"data-interaction-count":e.length,className:K(`mx-auto mb-2 w-full max-w-[64rem] px-3 sm:px-4`,a),children:(0,k.jsxs)(`div`,{"data-slot":`interaction-card`,className:`rounded-2xl border border-[var(--ksadk-interaction-border)] bg-[var(--ksadk-interaction-background)] px-3 py-3 text-[var(--ksadk-interaction-foreground)] shadow-sm`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs text-[var(--ksadk-interaction-muted)]`,children:[(0,k.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,k.jsx)(Rne,{className:`h-3.5 w-3.5 shrink-0`,strokeWidth:1.7,"aria-hidden":`true`}),(0,k.jsx)(`span`,{"data-testid":`interaction-tray-title`,children:u.title}),p.operation?(0,k.jsx)(`span`,{className:`truncate text-[11px] text-[var(--ksadk-interaction-muted)]`,children:p.operation}):null]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-1`,children:[e.length>1?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,"data-testid":`interaction-tray-prev`,disabled:t<=0,onClick:()=>n(Math.max(t-1,0)),className:`rounded p-1 transition hover:bg-[var(--ksadk-interaction-muted-background)] disabled:opacity-30`,"aria-label":`上一条待确认`,children:(0,k.jsx)(kne,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})}),(0,k.jsxs)(`span`,{"data-testid":`interaction-tray-count`,className:`min-w-10 text-center`,children:[t+1,` of `,e.length]}),(0,k.jsx)(`button`,{type:`button`,"data-testid":`interaction-tray-next`,disabled:t>=e.length-1,onClick:()=>n(Math.min(t+1,e.length-1)),className:`rounded p-1 transition hover:bg-[var(--ksadk-interaction-muted-background)] disabled:opacity-30`,"aria-label":`下一条待确认`,children:(0,k.jsx)(Ane,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})]}):null,(0,k.jsx)(`button`,{type:`button`,"data-testid":`interaction-cancel`,disabled:m,onClick:()=>b(`cancel`,{}),className:`rounded p-1 transition hover:bg-[var(--ksadk-interaction-muted-background)] hover:text-[var(--ksadk-interaction-foreground)] disabled:opacity-30`,"aria-label":`取消本次确认`,children:(0,k.jsx)(jN,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})]})]}),u.message===p.command?null:(0,k.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-sm font-medium leading-5 text-[var(--ksadk-interaction-foreground)]`,"data-testid":`interaction-tray-message`,children:u.message}),p.command||p.reason||p.cwd?(0,k.jsxs)(`div`,{"data-slot":`interaction-summary`,className:`mt-1.5 space-y-1 rounded-xl bg-[var(--ksadk-interaction-muted-background)] px-2.5 py-2 text-xs leading-5`,children:[p.command?(0,k.jsx)(`code`,{className:`block max-h-12 overflow-auto whitespace-pre-wrap break-all font-mono text-[var(--ksadk-interaction-foreground)]`,children:p.command}):null,p.reason?(0,k.jsx)(`p`,{className:`text-[var(--ksadk-interaction-muted)]`,children:p.reason}):null,p.cwd?(0,k.jsx)(`p`,{className:`truncate font-mono text-[11px] text-[var(--ksadk-interaction-muted)]`,title:p.cwd,children:p.cwd}):null]}):null,d?(0,k.jsxs)(`p`,{className:`mt-2 text-xs font-medium text-rose-600 dark:text-rose-400`,"data-testid":`interaction-tray-expired`,children:[`该确认已过期(`,Jq.expired,`),等待运行时继续处理。`]}):null,f?(0,k.jsxs)(`p`,{className:`mt-2 text-xs font-medium text-rose-600 dark:text-rose-400`,"data-testid":`interaction-tray-error`,children:[`提交失败(`,f.code,`):`,f.message,f.retryable?`,可重试。`:``]}):null,_===`a2ui`&&u.presentation?.a2ui?(0,k.jsx)(Bq,{a2ui:u.presentation.a2ui,disabled:m,onSubmit:e=>b(`submit`,e),onCancel:()=>b(`cancel`,{})}):_===`json-schema-form`&&y?(0,k.jsx)(Lq,{schema:y,values:c,onChange:l,disabled:m,onSubmit:()=>b(`submit`,c),onCancel:()=>b(`cancel`,{})}):u.kind===`approval`?(0,k.jsxs)(`div`,{className:`mt-2 flex flex-col gap-1`,"data-testid":`interaction-tray-basic`,children:[(0,k.jsxs)(`button`,{type:`button`,"data-testid":`interaction-approve`,disabled:m,onClick:()=>b(`approve`,{decision:`approve`}),className:`group flex min-h-9 w-full items-center gap-2.5 rounded-xl px-2.5 py-1.5 text-left text-sm font-medium text-[var(--ksadk-interaction-foreground)] transition hover:bg-[var(--ksadk-interaction-muted-background)] disabled:cursor-not-allowed disabled:opacity-55`,children:[(0,k.jsx)(`span`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-[var(--ksadk-interaction-muted-background)] text-xs text-[var(--ksadk-interaction-muted)]`,children:`1`}),(0,k.jsx)(`span`,{className:`min-w-0 flex-1`,children:`批准并继续`}),(0,k.jsx)(iN,{className:`h-3.5 w-3.5 text-[var(--ksadk-interaction-muted)] opacity-0 transition group-hover:opacity-100`,"aria-hidden":`true`})]}),(0,k.jsxs)(`button`,{type:`button`,"data-testid":`interaction-reject`,disabled:m,onClick:()=>b(`reject`,{decision:`reject`}),className:`group flex min-h-9 w-full items-center gap-2.5 rounded-xl px-2.5 py-1.5 text-left text-sm font-medium text-[var(--ksadk-interaction-foreground)] transition hover:bg-[var(--ksadk-interaction-muted-background)] disabled:cursor-not-allowed disabled:opacity-55`,children:[(0,k.jsx)(`span`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-[var(--ksadk-interaction-muted-background)] text-xs text-[var(--ksadk-interaction-muted)]`,children:`2`}),(0,k.jsx)(`span`,{className:`min-w-0 flex-1`,children:`拒绝`}),(0,k.jsx)(iN,{className:`h-3.5 w-3.5 text-[var(--ksadk-interaction-muted)] opacity-0 transition group-hover:opacity-100`,"aria-hidden":`true`})]}),(0,k.jsxs)(`label`,{className:`mt-0.5 flex min-w-0 items-center gap-2.5 rounded-xl bg-[var(--ksadk-interaction-muted-background)]/60 px-2.5 py-1.5`,children:[(0,k.jsx)(`span`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-[var(--ksadk-interaction-border)] bg-[var(--ksadk-interaction-control-background)] text-[var(--ksadk-interaction-muted)]`,children:(0,k.jsx)(Une,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})}),(0,k.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key!==`Enter`||e.nativeEvent.isComposing||!o.trim()||(e.preventDefault(),b(`cancel`,{feedback:o.trim()}))},placeholder:`告诉 Agent 要如何修改`,disabled:m,"data-testid":`interaction-tray-comment`,className:`h-8 min-w-0 flex-1 border-0 bg-transparent px-0 text-sm font-medium text-[var(--ksadk-interaction-foreground)] outline-none placeholder:text-[var(--ksadk-interaction-muted)] disabled:cursor-not-allowed disabled:opacity-55`}),(0,k.jsx)(`button`,{type:`button`,"data-testid":`interaction-feedback-submit`,"aria-label":`提交修改意见`,disabled:m||!o.trim(),onClick:()=>b(`cancel`,{feedback:o.trim()}),className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-[var(--ksadk-interaction-muted)] transition hover:bg-[var(--ksadk-interaction-control-background)] hover:text-[var(--ksadk-interaction-foreground)] disabled:opacity-30`,children:(0,k.jsx)(iN,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})]})]}):(0,k.jsxs)(`div`,{className:`mt-2.5`,"data-testid":`interaction-tray-basic`,children:[(0,k.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key!==`Enter`||e.nativeEvent.isComposing||!o.trim()||(e.preventDefault(),b(`submit`,{value:o.trim()}))},placeholder:`输入回复`,disabled:m,"data-testid":`interaction-tray-comment`,className:`mb-2 h-8 w-full rounded-lg border border-[var(--ksadk-interaction-border)] bg-[var(--ksadk-interaction-control-background)] px-2.5 text-sm text-[var(--ksadk-interaction-foreground)] outline-none placeholder:text-[var(--ksadk-interaction-muted)] focus:ring-1 focus:ring-[var(--ksadk-interaction-focus-ring)]`}),(0,k.jsx)(`div`,{className:`flex justify-end gap-2`,children:(0,k.jsx)(`button`,{type:`button`,"data-testid":`interaction-submit`,disabled:m,onClick:()=>b(`submit`,{value:o}),className:`inline-flex h-8 items-center gap-1.5 rounded-lg bg-[var(--ksadk-interaction-primary-background)] px-3 text-xs font-medium text-[var(--ksadk-interaction-primary-foreground)] shadow-sm transition hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-55`,children:`提交`})})]}),u.status===`resolving`?(0,k.jsx)(`p`,{className:`mt-2 text-xs text-[var(--ksadk-interaction-muted)]`,children:`正在提交,请稍候…`}):null]})})}function Xq({outcome:e}){return(0,k.jsx)(`span`,{className:K(`rounded border px-1.5 py-0.5 text-xs font-medium`,e===`approved`?`border-emerald-300 text-emerald-700 dark:border-emerald-900 dark:text-emerald-300`:e===`rejected`?`border-rose-300 text-rose-700 dark:border-rose-900 dark:text-rose-300`:`border-slate-300 text-slate-600 dark:border-slate-700 dark:text-slate-300`),children:Jq[e]||e})}function Zq(e){if(!e)return``;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function Qq(e){let t=e?.properties;return typeof t!=`object`||!t?[]:Object.keys(t)}function $q({interaction:e}){if(e.outcome===`cancelled`||e.status===`cancelled`)return null;let t=e.status===`resolved`||e.status===`expired`,n=Qq(e.requestSchema);return(0,k.jsxs)(`div`,{"data-testid":`interaction-history-anchor`,"data-interaction-id":e.interactionId,"data-interaction-status":e.status,className:`mt-2 rounded-lg border border-border bg-muted/55 px-3 py-2 text-xs text-text-secondary`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,k.jsx)(`span`,{className:`font-medium text-text-primary`,children:e.title}),(0,k.jsx)(Xq,{outcome:e.outcome||e.status})]}),t?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`mt-1 leading-relaxed`,children:[e.actor?(0,k.jsxs)(`span`,{children:[`操作人:`,e.actor,` · `]}):null,e.resolvedAt?(0,k.jsxs)(`span`,{children:[`决定时间:`,Zq(e.resolvedAt),` · `]}):null,(0,k.jsx)(`span`,{"data-testid":`interaction-history-response-summary`,children:e.responseSummary||`响应内容已脱敏`})]}),(0,k.jsxs)(`details`,{"data-testid":`interaction-history-detail`,className:`mt-1`,children:[(0,k.jsx)(`summary`,{className:`cursor-pointer select-none text-text-muted hover:text-text-primary`,children:`查看确认快照`}),(0,k.jsxs)(`div`,{"data-testid":`interaction-history-snapshot`,className:`mt-1 rounded border border-border bg-card px-2 py-1.5 leading-relaxed text-card-foreground`,children:[(0,k.jsxs)(`div`,{children:[`操作者:`,(0,k.jsx)(`span`,{"data-testid":`interaction-history-actor-ref`,children:e.actor||`—`})]}),(0,k.jsxs)(`div`,{children:[`决定时间:`,Zq(e.resolvedAt)||`—`]}),(0,k.jsxs)(`div`,{children:[`关键参数:`,n.length>0?(0,k.jsx)(`span`,{"data-testid":`interaction-history-schema-keys`,children:n.join(`、`)}):(0,k.jsx)(`span`,{children:`无结构化参数`})]})]})]})]}):(0,k.jsxs)(`div`,{className:`mt-1`,children:[`状态:`,e.status===`pending`?`待处理(见输入区确认面板)`:`处理中…`]})]})}function eJ({summary:e,children:t,defaultOpen:n=!1,streaming:r=!1}){let[i,a]=(0,v.useState)(n);return(0,k.jsxs)(`div`,{className:`mb-1.5`,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`flex w-full items-center gap-1.5 rounded px-1 py-1 text-left text-[13px] text-slate-500 transition-colors hover:bg-slate-100/70 dark:text-slate-400 dark:hover:bg-slate-800/40`,children:[r?(0,k.jsx)(yN,{className:`h-3.5 w-3.5 animate-spin text-slate-400`}):(0,k.jsx)(cN,{className:K(`h-3.5 w-3.5 text-slate-400 transition-transform`,i&&`rotate-90`)}),(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e})]}),i&&(0,k.jsx)(`div`,{className:`mt-1.5 border-l border-slate-200 pl-3.5 dark:border-slate-700/60`,children:t})]})}function tJ({block:e}){let[t,n]=(0,v.useState)(!1),r=e.status===`streaming`,i=e.content.length,a=`${e.id}-thinking-detail`;return(0,k.jsxs)(`div`,{className:`mb-1.5 min-w-0`,children:[(0,k.jsxs)(`button`,{type:`button`,"aria-expanded":t,"aria-controls":a,onClick:()=>n(e=>!e),className:`inline-flex max-w-full items-center gap-1.5 rounded px-1 py-1 text-left text-[13px] leading-5 text-slate-400 transition-colors hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300`,children:[!r&&(0,k.jsx)(Jne,{className:`h-3.5 w-3.5 shrink-0`}),(0,k.jsx)(`span`,{className:K(`min-w-0 truncate`,r&&`waiting-thinking-text`),"data-testid":r?`thinking-indicator`:void 0,role:r?`status`:void 0,children:r?`正在思考…`:`已思考`}),!r&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{className:`text-slate-300 dark:text-slate-600`,children:`·`}),(0,k.jsxs)(`span`,{className:`font-mono text-xs text-slate-400 dark:text-slate-500`,children:[i,` 字`]})]}),(0,k.jsx)(cN,{className:K(`h-3.5 w-3.5 shrink-0 transition-transform`,t&&`rotate-180`)})]}),t&&e.content&&(0,k.jsx)(`div`,{id:a,className:`custom-scrollbar mt-1.5 max-h-[min(46vh,28rem)] overflow-y-auto border-l border-slate-200/80 pl-3.5 text-[12px] leading-5 text-slate-500 dark:border-slate-700/60 dark:text-slate-400 [&_h1]:!mb-2 [&_h1]:!mt-3 [&_h1]:!text-[13px] [&_h2]:!mb-1.5 [&_h2]:!mt-3 [&_h2]:!text-[12px] [&_h3]:!mb-1 [&_h3]:!mt-2.5 [&_h3]:!text-[12px] [&_li]:!text-[12px] [&_li]:!leading-5 [&_p]:!my-1.5 [&_p]:!text-[12px] [&_p]:!leading-5 [&_p]:!text-slate-500 dark:[&_p]:!text-slate-400 [&_pre]:!my-1.5`,children:(0,k.jsx)(Aq,{content:e.content})})]})}function nJ({block:e,tool:t,isStreaming:n,interactionRecord:r,onRespondToApproval:i,onRespondToAguiApproval:a}){let o=t?.status??e.status,s=t?.args??e.args,c=t?.output??e.output,l=e.extra||{},u=(r?.outcome===`cancelled`||r?.outcome===`expired`||r?.status===`cancelled`||r?.status===`expired`?`cancelled`:r?.outcome===`rejected`?`rejected`:r?.outcome===`approved`?`approved`:void 0)||l.approvalStatus||t?.approvalStatus,d=l.approvalRequestId||t?.approvalRequestId,f=l.approvalMessage||t?.approvalMessage,p=l.approvalProtocol||t?.approvalProtocol,m=l.previousResponseId||t?.previousResponseId,h=o===`running`,g=String(l.summary??t?.summary??``).trim(),_=Number(l.durationMs??t?.durationMs),v=u===`cancelled`||u===`rejected`,y=o===`error`&&!v,b=o===`paused`,x=y?`执行失败`:u===`pending`?`等待确认`:u===`rejected`?`已拒绝`:u===`cancelled`?`已取消`:h?u===`approved`?`已授权 · 执行中`:`正在运行`:u===`approved`?`已授权`:b?`已暂停`:`已完成`,S=y?`text-rose-500 dark:text-rose-400`:b?`text-amber-500 dark:text-amber-400`:h?`text-slate-500 dark:text-slate-400`:`text-slate-400 dark:text-slate-500`;return(0,k.jsx)(eJ,{streaming:h&&!s,defaultOpen:u===`pending`||b,summary:(0,k.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,k.jsx)(ere,{className:K(`h-3.5 w-3.5 shrink-0`,S)}),(0,k.jsx)(`span`,{className:S,children:x}),(0,k.jsx)(`span`,{className:`truncate font-medium text-slate-600 dark:text-slate-300`,children:e.toolName}),g?(0,k.jsxs)(`span`,{className:`truncate text-slate-400 dark:text-slate-500`,children:[`· `,g]}):null,Number.isFinite(_)&&_>=0?(0,k.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] text-slate-400 dark:text-slate-500`,children:[`· `,cJ(_)]}):null,h&&s&&(0,k.jsx)(`span`,{className:`ml-0.5 animate-pulse text-slate-400`,children:`…`})]}),children:(0,k.jsxs)(`div`,{className:`flex flex-col gap-2.5 py-1 text-[13px]`,children:[d&&u===`pending`&&!r&&(0,k.jsxs)(`section`,{"data-slot":`tool-approval-card`,className:`flex flex-wrap items-center gap-x-3 gap-y-2 rounded-lg border border-[var(--ksadk-approval-border)] bg-[var(--ksadk-approval-background)] px-2.5 py-2 font-sans text-[12px] text-[var(--ksadk-approval-foreground)] shadow-[0_1px_2px_rgba(15,23,42,0.03)]`,children:[(0,k.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,k.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--ksadk-approval-foreground)]`,"aria-hidden":`true`}),(0,k.jsx)(`span`,{className:`shrink-0 font-medium`,children:`需要确认`}),(0,k.jsx)(`span`,{className:`min-w-0 truncate opacity-75`,children:f||`允许后将执行此工具调用。`})]}),(0,k.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,k.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>p===`ag-ui`?a?.({interruptId:d||``,approve:!0}):i?.({approvalRequestId:d||``,approve:!0,previousResponseId:m}),className:`inline-flex h-7 items-center rounded-md bg-primary px-2.5 text-[12px] font-medium text-primary-foreground transition hover:bg-primary/90 disabled:opacity-55`,children:`允许执行`}),(0,k.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>p===`ag-ui`?a?.({interruptId:d||``,approve:!1}):i?.({approvalRequestId:d||``,approve:!1,previousResponseId:m}),className:`inline-flex h-7 items-center rounded-md px-2 text-[12px] font-medium text-slate-500 transition hover:bg-slate-100 hover:text-rose-600 disabled:opacity-55 dark:text-slate-400 dark:hover:bg-slate-800`,children:`拒绝`})]})]}),d&&u===`pending`&&r?(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5 font-sans text-xs text-slate-500 dark:text-slate-400`,children:[(0,k.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-amber-400`,"aria-hidden":`true`}),`请在输入区确认面板中操作。`]}):null,d&&u&&u!==`pending`&&(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5 font-sans text-xs text-slate-500 dark:text-slate-400`,children:[(0,k.jsx)(`span`,{children:u===`approved`?`已授权`:u===`cancelled`?`已取消`:`已拒绝`}),u===`approved`&&h?(0,k.jsx)(`span`,{children:`· 工具执行中`}):null,u===`approved`&&y?(0,k.jsx)(`span`,{children:`· 工具执行失败`}):null]}),s?(0,k.jsx)(lJ,{label:`入参`,value:s,tone:`input`}):null,c&&!v?rJ(e.toolName,c,y):null]})})}function rJ(e,t,n){if(Pq(t))return(0,k.jsx)(iJ,{output:t});let r=e.toLowerCase();if(r.includes(`web_search`)||r.includes(`search`)){let e=aJ(t);if(e.length>0)return(0,k.jsx)(oJ,{sources:e})}return(0,k.jsx)(lJ,{label:`输出`,value:t,tone:n?`error`:`output`})}function iJ({output:e}){let t=Mq(e),[n,r]=(0,v.useState)(!1),i=n?t:t.slice(0,3);return(0,k.jsxs)(`div`,{className:`my-2 overflow-hidden rounded-xl border border-border bg-background`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border px-3 py-2 text-xs font-medium text-text-secondary`,children:[(0,k.jsx)(Pne,{className:`h-3.5 w-3.5 text-primary`}),(0,k.jsxs)(`span`,{children:[`改动 `,t.length,` 个文件`]})]}),(0,k.jsx)(`div`,{className:`flex flex-col`,children:i.map(e=>{let{added:t,removed:n}=Nq(e);return(0,k.jsxs)(`div`,{className:`group/file-change-row flex min-w-0 items-center gap-2 px-3 py-2 text-sm transition-colors hover:bg-muted`,children:[(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[13px] text-text-primary`,children:e.path}),(0,k.jsxs)(`span`,{className:`flex-shrink-0 text-[11px] font-mono`,children:[(0,k.jsxs)(`span`,{className:`text-emerald-600`,children:[`+`,t]}),` `,(0,k.jsxs)(`span`,{className:`text-rose-500`,children:[`−`,n]})]})]},e.path)})}),t.length>3?(0,k.jsx)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:`flex w-full items-center justify-center gap-1 border-t border-border py-1.5 text-xs text-text-muted transition hover:bg-muted hover:text-text-primary`,children:n?`收起`:`展开剩余 ${t.length-3} 个文件`}):null]})}function aJ(e){try{let t=JSON.parse(e),n=Array.isArray(t)?t:t?.results??t?.sources??[];return Array.isArray(n)?n.map(e=>{let t=e,n=String(t?.url??t?.link??t?.href??``),r=``;try{let e=new URL(n,typeof window>`u`?`http://localhost/`:window.location.href).protocol.toLowerCase();[`http:`,`https:`].includes(e)&&(r=n)}catch{r=``}let i=String(t?.title??t?.name??r);return r?{url:r,title:i}:null}).filter(e=>e!==null):[]}catch{return[]}}function oJ({sources:e}){return(0,k.jsx)(`div`,{className:`mt-2 flex min-w-0`,children:(0,k.jsxs)(`span`,{className:`group/web-search-sources relative inline-flex min-w-0`,children:[(0,k.jsxs)(`button`,{type:`button`,className:`inline-flex h-7 min-w-0 items-center gap-1.5 rounded-md border border-border bg-surface px-2 text-xs text-text-secondary transition-colors hover:bg-muted hover:text-text-primary`,children:[(0,k.jsx)(pN,{className:`h-3.5 w-3.5 shrink-0`,strokeWidth:1.7}),(0,k.jsxs)(`span`,{children:[`来源 · `,e.length]})]}),(0,k.jsx)(`span`,{className:`absolute bottom-full left-0 z-30 hidden max-w-[calc(100vw-3rem)] pb-1 group-hover/web-search-sources:block`,children:(0,k.jsx)(`span`,{className:`block w-[min(26rem,calc(100vw-3rem))] rounded-xl border border-border bg-popover p-2 text-left text-text-primary shadow-2xl`,children:(0,k.jsx)(`span`,{className:`flex min-w-0 flex-col gap-1`,children:e.map((e,t)=>(0,k.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`flex min-w-0 items-center gap-2 rounded-lg px-2 py-1.5 text-sm leading-5 text-text-secondary transition-colors hover:bg-muted hover:text-text-primary`,children:[(0,k.jsx)(pN,{className:`h-3.5 w-3.5 shrink-0`,strokeWidth:1.7}),(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title})]},`${e.url}-${t}`))})})})]})})}var sJ=12e3;function cJ(e){return e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`}function lJ({label:e,tone:t,value:n}){let[r,i]=(0,v.useState)(!1),a=n.length>sJ,o=a&&!r?n.slice(0,sJ):n;return(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:`mb-1 text-[11px] font-semibold uppercase tracking-wide text-slate-400`,children:e}),(0,k.jsx)(`pre`,{className:K(`custom-scrollbar max-h-60 overflow-auto rounded-lg px-3 py-2 text-[12.5px] leading-relaxed whitespace-pre-wrap break-all`,t===`error`?`bg-rose-50/60 text-rose-700 dark:bg-rose-950/20 dark:text-rose-200`:t===`output`?`bg-emerald-50/40 text-emerald-800 dark:bg-emerald-950/20 dark:text-emerald-200`:`bg-slate-50 text-slate-700 dark:bg-slate-900/40 dark:text-slate-200`),children:hq(o).map((e,t)=>e.type===`text`?(0,k.jsx)(`span`,{children:e.value},t):(0,k.jsx)(`a`,{href:`#`,style:{textDecoration:`underline`,textUnderlineOffset:2,textDecorationColor:`rgba(0,0,0,0.35)`},title:`预览 ${e.value}`,onClick:t=>{t.preventDefault(),_q(e.value)},children:e.value},t))}),a?(0,k.jsx)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`mt-1 text-xs text-primary hover:underline`,"aria-expanded":r,children:r?`收起完整日志`:`查看完整日志(已显示前 ${sJ.toLocaleString()} 字符)`}):null]})}function uJ({block:e}){return e.content?(0,k.jsx)(`div`,{className:`w-full break-words py-0.5 text-[14px] leading-[1.65]`,children:(0,k.jsx)(Aq,{content:e.content})}):null}function dJ({message:e,isStreaming:t,onRespondToApproval:n,onRespondToAguiApproval:r,interactionRecords:i,className:a}){let o=e.blocks??[];return(0,k.jsx)(`div`,{className:K(`mb-3 min-w-0`,a),"data-slot":`processing-blocks`,children:o.map(a=>{if(a.type===`thinking`)return(0,k.jsx)(tJ,{block:a},a.id);if(a.type===`tool`){let o=a.extra||{},s=String(o.approvalRequestId||e.tools?.[a.toolName]?.approvalRequestId||``),c=String(o.callId||o.call_id||``),l=s?i?.find(e=>e.interactionId===s):c?i?.find(e=>String(e.extensions.call_id||``)===c):void 0;return(0,k.jsxs)(`div`,{children:[(0,k.jsx)(nJ,{block:a,tool:e.tools?.[a.toolName],isStreaming:t,interactionRecord:l,onRespondToApproval:n,onRespondToAguiApproval:r}),l?(0,k.jsx)($q,{interaction:l}):null]},a.id)}return(0,k.jsx)(uJ,{block:a},a.id)})})}function fJ({onRetry:e}){let t=nt(e=>e.banner);if(!t)return null;let n=t.kind===`rate_limited`?(0,k.jsx)(pJ,{message:t.message,retryAfterSec:t.retryAfterSec},t.createdAt||`${t.sessionId||``}:${t.retryAfterSec||0}`):null,r={rate_limited:{icon:(0,k.jsx)(tre,{className:`h-4 w-4 text-neutral-500`}),bg:`border-neutral-200/70 bg-neutral-50/70 dark:border-neutral-900/40 dark:bg-neutral-950/20`,text:`text-neutral-700 dark:text-neutral-200`,label:n},network:{icon:(0,k.jsx)(yN,{className:`h-4 w-4 animate-spin text-text-secondary`}),bg:`border-border/70 bg-muted/60`,text:`text-text-secondary`,label:t.message||`网络异常,正在重连…`},error:{icon:(0,k.jsx)($ne,{className:`h-4 w-4 text-rose-500`}),bg:`border-rose-200/70 bg-rose-50/70 dark:border-rose-900/40 dark:bg-rose-950/20`,text:`text-rose-600 dark:text-rose-300`,label:t.message||`运行失败,请重试`}}[t.kind];return(0,k.jsxs)(`div`,{className:K(`mx-auto mb-3 flex w-full max-w-3xl items-center gap-2.5 rounded-xl border px-3.5 py-2.5 text-sm shadow-sm`,r.bg,r.text),role:`status`,children:[r.icon,(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:r.label}),t.kind===`error`&&e?(0,k.jsxs)(`button`,{type:`button`,onClick:e,className:`flex items-center gap-1 rounded-full px-2.5 py-1 text-xs font-medium text-rose-600 transition hover:bg-rose-100 dark:text-rose-300 dark:hover:bg-rose-950/40`,children:[(0,k.jsx)(TN,{className:`h-3 w-3`}),`重试`]}):null]})}function pJ({message:e,retryAfterSec:t}){let[n,r]=(0,v.useState)(t||0);return(0,v.useEffect)(()=>{if(!t)return;let e=setInterval(()=>{r(e=>e>0?e-1:0)},1e3);return()=>clearInterval(e)},[t]),n>0?`${e}(${n}s 后可重试)`:e}async function mJ(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 hJ(e,t,n){return Math.max(t,Math.min(n,e))}function gJ({items:e=[],scrollTop:t=0,viewportHeight:n=0,overscan:r=4,defaultItemHeight:i=120,measuredHeights:a=new Map,getItemKey:o=(e,t)=>e?.id||String(t)}={}){let s=Math.max(0,Number(n)||0),c=Math.max(0,Number(t)||0),l=Math.max(0,Number(r)||0),u=Math.max(1,Number(i)||120);if(!e.length)return{startIndex:0,endIndex:0,offsetTop:0,totalHeight:0,visibleItems:[]};let d=e.map((e,t)=>{let n=o(e,t),r=Number(a.get(n));return Number.isFinite(r)&&r>0?r:u}),f=Array(e.length),p=0;for(let t=0;t<e.length;t+=1)f[t]=p,p+=d[t];let m=p,h=c+s,g=0;for(;g<e.length&&f[g]+d[g]<=c;)g+=1;let _=g;for(;_<e.length&&f[_]<h;)_+=1;return g=hJ(g-l,0,e.length),_=hJ(Math.max(g+1,_+l),0,e.length),{startIndex:g,endIndex:_,offsetTop:f[g]||0,totalHeight:m,visibleItems:e.slice(g,_).map((e,t)=>{let n=g+t;return{index:n,item:e,top:f[n]||0,height:d[n]||u}})}}function _J({scrollHeight:e,scrollTop:t,clientHeight:n}){return Math.max(0,e-t-n)}function vJ(e){return e.scrollHeight>e.clientHeight+1&&_J(e)>96}function yJ(e){return String(e?.runId||e?.invocationId||``).trim()}function bJ(e,t){if(e?.role!==`model`||t.role!==`model`)return!1;let n=yJ(e);return!!(n&&n===yJ(t))}var xJ=140,SJ=4;function CJ(e){let t=String(e||``).trim().toLowerCase();return t===`elevated`?`高风险`:t===`always`?`始终确认`:t===`confirm`?`需确认`:e||``}function wJ(e){return String(e||``).trim().toLowerCase()===`elevated`?`border-[var(--ksadk-approval-elevated-border)] bg-[var(--ksadk-approval-elevated-background)] text-[var(--ksadk-approval-elevated-foreground)]`:`border-[var(--ksadk-approval-border)] bg-[var(--ksadk-approval-background)] text-[var(--ksadk-approval-foreground)]`}function TJ({messageId:e,top:t,onMeasure:n,children:r,highlighted:i}){let a=(0,v.useRef)(null);return(0,v.useLayoutEffect)(()=>{let r=a.current;if(!r)return;let i=()=>n(e,r.offsetHeight,t);if(i(),typeof ResizeObserver>`u`)return;let o=new ResizeObserver(i);return o.observe(r),()=>o.disconnect()},[e,n,t]),(0,k.jsx)(`div`,{ref:a,"data-message-id":e,"data-search-target":i||void 0,tabIndex:-1,style:{position:`absolute`,top:t,left:0,right:0},children:r})}function EJ({agentName:e}){return(0,k.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-[50vh] px-4`,children:[(0,k.jsx)(`div`,{className:`mb-6 h-16 w-16 rounded-2xl bg-gradient-to-br from-blue-500 to-indigo-600
|
|
200
|
-
flex items-center justify-center shadow-lg shadow-blue-500/20`,children:(0,k.jsx)(oN,{className:`h-8 w-8 text-white`})}),(0,k.jsx)(`h2`,{className:`text-xl font-semibold text-slate-900 dark:text-slate-50`,children:`有什么我可以帮您的吗?`}),(0,k.jsxs)(`p`,{className:`mt-2 text-sm text-slate-500`,children:[`我是 `,e,`,由 Ksyun AgentEngine 驱动`]})]})}function DJ(){return(0,k.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[44rem] flex-col gap-5 px-2 py-8`,"aria-label":`正在加载会话历史`,children:[(0,k.jsx)(`div`,{className:`h-4 w-28 animate-pulse rounded bg-slate-200/80 dark:bg-slate-800`}),(0,k.jsx)(`div`,{className:`h-20 w-4/5 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900`}),(0,k.jsx)(`div`,{className:`ml-auto h-12 w-3/5 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900`}),(0,k.jsx)(`div`,{className:`h-16 w-11/12 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900`})]})}function OJ({attachments:e,isMobile:t,onOpenAttachmentPreview:n}){let r=e=>typeof e!=`number`||!Number.isFinite(e)||e<0?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`,i=e=>{let t=e.status===`pending`?`生成中`:e.status===`failed`?`生成失败`:``;return[e.type,r(e.sizeBytes),t,e.runId&&`run ${e.runId.slice(0,12)}`].filter(Boolean).join(` · `)},a=e=>!!(e.artifactId||e.itemId||e.runId||e.sizeBytes!=null);return(0,k.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-3`,children:e.map((e,r)=>e.type.startsWith(`image/`)?e.url?(0,k.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>n(e),className:K(`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,k.jsx)(`img`,{src:e.url,alt:e.name,className:K(`object-cover transition group-hover:scale-[1.02]`,t?`max-h-[16rem] w-full max-w-full`:`max-h-[200px] max-w-[200px]`)})}),a(e)&&(0,k.jsx)(`span`,{className:`max-w-[200px] truncate text-[11px] text-slate-500 dark:text-slate-400`,title:`来源 item ${e.itemId||`未知`} · run ${e.runId||`未知`}`,children:i(e)})]},`${e.name}-${r}`):(0,k.jsx)(`div`,{className:K(`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,k.jsxs)(`div`,{className:K(`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,k.jsx)(SN,{className:`h-4 w-4 flex-shrink-0 text-blue-500`}),e.url?(0,k.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,k.jsx)(`span`,{className:`truncate text-sm text-slate-700 dark:text-slate-300`,title:e.name,children:e.name}),a(e)&&(0,k.jsx)(`span`,{className:`text-[11px] text-slate-500 dark:text-slate-400`,title:`来源 item ${e.itemId||`未知`} · run ${e.runId||`未知`}`,children:i(e)})]},`${e.name}-${r}`))})}function kJ({message:e}){return(0,k.jsx)(`div`,{className:`w-full px-0 py-2 sm:px-4`,children:(0,k.jsxs)(`div`,{className:`mx-auto max-w-3xl rounded-xl border border-neutral-200/70 bg-neutral-50/60 px-4 py-3 text-sm text-neutral-600 dark:border-neutral-800 dark:bg-neutral-900/40 dark:text-neutral-300`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[e.status===`running`?(0,k.jsx)(wN,{className:`h-4 w-4 animate-spin text-neutral-600 dark:text-neutral-300`}):e.status===`failed`?(0,k.jsx)(jne,{className:`h-4 w-4 text-rose-600 dark:text-rose-400`}):(0,k.jsx)(sN,{className:`h-4 w-4 text-emerald-600 dark:text-emerald-400`}),(0,k.jsx)(`span`,{children:e.content})]}),e.compactedUntilSeqId?(0,k.jsxs)(`div`,{className:`mt-1 text-xs text-neutral-700/80 dark:text-neutral-200/80`,children:[`已折叠到会话事件 #`,e.compactedUntilSeqId]}):null,e.summary?(0,k.jsxs)(`details`,{className:`mt-3 rounded-xl border border-neutral-200/80 bg-white/70 px-3 py-2 dark:border-neutral-900/60 dark:bg-slate-950/40`,children:[(0,k.jsx)(`summary`,{className:`cursor-pointer select-none text-xs font-medium text-neutral-800 dark:text-neutral-200`,children:`查看压缩摘要`}),(0,k.jsx)(`div`,{className:`mt-2 text-[13px] leading-relaxed text-slate-700 dark:text-slate-200`,children:(0,k.jsx)(Aq,{content:e.summary})})]}):null]})})}function AJ({label:e,tone:t,value:n}){let[r,i]=(0,v.useState)(`idle`),a=Dne(n);(0,v.useEffect)(()=>{if(r===`idle`)return;let e=window.setTimeout(()=>i(`idle`),1600);return()=>window.clearTimeout(e)},[r]);let o=async()=>{i(await mJ(a)?`copied`:`failed`)};return(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,k.jsx)(`div`,{className:K(`text-xs font-semibold uppercase`,t===`input`?`text-blue-500`:t===`error`?`text-rose-500`:`text-emerald-500`),children:e}),(0,k.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,k.jsx)(sN,{className:`h-3.5 w-3.5 text-emerald-500`}):(0,k.jsx)(dN,{className:`h-3.5 w-3.5`}),r===`copied`?`已复制`:r===`failed`?`复制失败`:`复制`]})]}),(0,k.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 jJ({isLastMessage:e,isStreaming:t,message:n,onDeleteFeedback:r,onSubmitFeedback:i,alwaysVisible:a=!1}){let[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(n.feedback?.comment||``),u=eM(n,t,e),d=!!n.feedback?.pending,f=n.feedback?.rating,p=async()=>{let e=n.content||``;e&&mJ(e)};return u?(0,k.jsxs)(`div`,{className:K(`mt-2 flex flex-col gap-2 transition-opacity duration-150 focus-within:opacity-100`,a?`opacity-100`:`opacity-0 group-hover:opacity-100`),children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-xs text-text-muted`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>{p()},className:`inline-flex items-center gap-1 rounded-full px-2 py-1 font-medium text-text-secondary transition hover:bg-muted hover:text-text-primary`,title:`复制`,children:(0,k.jsx)(dN,{className:`h-3.5 w-3.5`})}),(0,k.jsx)(`span`,{className:`text-text-muted/60`,children:`·`}),(0,k.jsx)(`span`,{className:`font-medium`,children:`本次回复有帮助吗?`}),(0,k.jsxs)(`button`,{type:`button`,disabled:d,onClick:()=>i({message:n,rating:`up`,comment:``}),className:K(`inline-flex items-center gap-1 rounded-full border px-2.5 py-1 font-medium transition disabled:cursor-not-allowed disabled:opacity-60`,f===`up`?`border-primary/30 bg-primary/10 text-primary`:`border-border bg-background text-text-secondary hover:border-primary/30 hover:text-primary`),children:[(0,k.jsx)(Qne,{className:`h-3.5 w-3.5`}),`有帮助`]}),(0,k.jsxs)(`button`,{type:`button`,disabled:d,onClick:()=>{l(n.feedback?.comment||``),s(e=>!e)},className:K(`inline-flex items-center gap-1 rounded-full border px-2.5 py-1 font-medium transition disabled:cursor-not-allowed disabled:opacity-60`,f===`down`?`border-rose-300 bg-rose-50 text-rose-600 dark:border-rose-900/70 dark:bg-rose-950/30 dark:text-rose-300`:`border-border bg-background text-text-secondary hover:border-rose-300 hover:text-rose-600`),children:[(0,k.jsx)(Zne,{className:`h-3.5 w-3.5`}),`需改进`]}),n.feedback?(0,k.jsxs)(`button`,{type:`button`,disabled:d,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,k.jsx)(kN,{className:`h-3.5 w-3.5`}),`删除反馈`]}):null,d?(0,k.jsx)(`span`,{className:`text-slate-400`,children:`提交中…`}):null]}),o?(0,k.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,k.jsx)(`textarea`,{value:c,onChange:e=>l(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,k.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>s(!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,k.jsx)(`button`,{type:`button`,disabled:d,onClick:()=>{i({message:n,rating:`down`,comment:c}),s(!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:`提交点踩`})]})]}):f===`down`&&n.feedback?.comment?(0,k.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,k.jsx)(`div`,{className:`text-xs text-rose-600 dark:text-rose-300`,children:n.feedback.error}):null]}):null}function MJ({agentName:e,isMobile:t,isStreaming:n,isLastMessage:r,suppressWaitingIndicator:i=!1,showAgentHeader:a,message:o,onDeleteFeedback:s,onOpenAttachmentPreview:c,onRespondToApproval:l,onRespondToAguiApproval:u,onSubmitFeedback:d,onSubmitAguiAction:f,interactionRecords:p}){if(o.role===`user`)return(0,k.jsx)(`div`,{className:`mb-3 flex justify-end`,children:(0,k.jsxs)(`div`,{"data-slot":`user-message`,className:`max-w-[80%] rounded-2xl bg-muted px-3 py-2 text-[14px] leading-relaxed text-foreground`,children:[o.attachments?.length?(0,k.jsx)(OJ,{attachments:o.attachments,isMobile:t,onOpenAttachmentPreview:c}):null,o.content]})});if(o.role===`a2ui`&&o.aguiActivity)return(0,k.jsx)(zq,{surfaceId:o.aguiActivity.surfaceId,messages:o.aguiActivity.messages,onAction:f});let m=n&&r&&!o.content;return(0,k.jsxs)(`div`,{"data-slot":`assistant-message`,className:`group mx-auto mb-3 w-full max-w-[60rem] px-2 sm:px-4`,children:[a?(0,k.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-xs text-text-muted`,children:[(0,k.jsx)(oN,{className:`w-3.5 h-3.5`}),(0,k.jsx)(`span`,{children:e})]}):null,o.attachments?.length?(0,k.jsx)(OJ,{attachments:o.attachments,isMobile:t,onOpenAttachmentPreview:c}):null,o.blocks?.length?(0,k.jsx)(dJ,{message:o,isStreaming:n,onRespondToApproval:l,interactionRecords:p,onRespondToAguiApproval:u}):(0,k.jsxs)(k.Fragment,{children:[o.reasoning?(0,k.jsxs)(`details`,{className:`group/details mb-3 overflow-hidden rounded-md border border-slate-200/80 bg-slate-50/60 text-sm text-slate-600 transition-colors open:bg-white dark:border-slate-700/80 dark:bg-slate-900/40 dark:text-slate-300 dark:open:bg-slate-950/30`,children:[(0,k.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 px-3 py-2 font-medium outline-none marker:hidden`,children:[(0,k.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[m?null:(0,k.jsx)(sN,{className:`h-4 w-4 text-slate-400`}),(0,k.jsx)(`span`,{className:K(`truncate`,m&&`waiting-thinking-text`),"data-testid":m?`legacy-thinking-indicator`:void 0,role:m?`status`:void 0,children:m?`正在思考…`:`思考过程`}),m?null:(0,k.jsx)(`span`,{className:`rounded-full bg-slate-200/70 px-2 py-0.5 text-[11px] font-medium text-slate-600 dark:bg-slate-800 dark:text-slate-300`,children:`已完成`})]}),(0,k.jsx)(cN,{className:`h-4 w-4 flex-shrink-0 text-slate-400 transition-transform group-open/details:rotate-180`})]}),(0,k.jsx)(`div`,{className:`border-t border-slate-200/70 bg-white/70 dark:border-slate-800 dark:bg-slate-950/20`,children:(0,k.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,k.jsx)(Aq,{content:o.reasoning})})})]}):null,o.tools?Object.values(o.tools).map((e,t)=>(0,k.jsxs)(`details`,{open:e.approvalStatus===`pending`||e.status===`paused`?!0:void 0,className:K(`group/details mb-2 overflow-hidden rounded-md border text-sm transition-colors`,e.status===`paused`?`border-neutral-200/80 bg-neutral-50/25 text-slate-700 dark:border-neutral-900/60 dark:bg-neutral-950/10 dark:text-slate-200`:e.status===`error`?`border-rose-200/80 bg-rose-50/25 text-rose-700 dark:border-rose-900/60 dark:bg-rose-950/10 dark:text-rose-200`:`border-slate-200/80 bg-slate-50/40 text-slate-600 dark:border-slate-700/80 dark:bg-slate-900/30 dark:text-slate-300`),children:[(0,k.jsx)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 px-3 py-2 font-medium`,children:(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.status===`running`?(0,k.jsx)(wN,{className:`h-4 w-4 animate-spin text-slate-500`}):e.status===`paused`?(0,k.jsx)(DN,{className:`h-4 w-4 text-neutral-500`}):e.status===`error`?(0,k.jsx)(lN,{className:`h-4 w-4 text-rose-500`}):(0,k.jsx)(sN,{className:`h-4 w-4 text-slate-400`}),(0,k.jsxs)(`span`,{children:[e.approvalStatus===`pending`?`等待审批:`:e.approvalStatus===`approved`?`已批准:`:e.approvalStatus===`rejected`?`已拒绝:`:e.approvalStatus===`cancelled`?`已取消:`:e.status===`error`?`工具调用失败:`:`工具调用:`,e.name]})]})}),(0,k.jsxs)(`div`,{className:K(`flex flex-col gap-3 border-t px-3 py-3 font-mono text-[13px] leading-relaxed`,e.status===`paused`?`border-neutral-200/70 dark:border-neutral-900/60`:e.status===`error`?`border-rose-200/70 dark:border-rose-900/60`:`border-slate-200/70 dark:border-slate-800`),children:[e.approvalRequestId?(0,k.jsxs)(`div`,{className:`font-sans text-sm text-slate-700 dark:text-slate-200`,children:[(0,k.jsx)(`div`,{className:`font-medium`,children:e.approvalStatus===`approved`?`已批准该工具调用。`:e.approvalStatus===`rejected`?`已拒绝该工具调用。`:e.approvalStatus===`cancelled`?`已取消该工具调用。`:e.approvalMessage||`该工具调用需要人工确认后继续。`}),e.approvalLevel?(0,k.jsxs)(`div`,{className:K(`mt-2 inline-flex items-center rounded border px-1.5 py-0.5 text-xs font-medium`,wJ(e.approvalLevel)),children:[`审批级别:`,CJ(e.approvalLevel)]}):null,e.serverLabel?(0,k.jsxs)(`div`,{className:`mt-1 text-xs text-neutral-700/80 dark:text-neutral-200/80`,children:[`MCP Server: `,e.serverLabel]}):null,e.approvalStatus===`pending`?(0,k.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,k.jsxs)(`button`,{type:`button`,disabled:n||e.approvalStatus!==`pending`,onClick:()=>e.approvalProtocol===`ag-ui`?u?.({interruptId:e.approvalRequestId||``,approve:!0}):l({approvalRequestId:e.approvalRequestId||``,approve:!0,previousResponseId:e.previousResponseId}),className:`inline-flex min-h-8 items-center gap-1.5 rounded-md 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,k.jsx)(sN,{className:`h-3.5 w-3.5`}),`批准并继续`]}),(0,k.jsxs)(`button`,{type:`button`,disabled:n||e.approvalStatus!==`pending`,onClick:()=>e.approvalProtocol===`ag-ui`?u?.({interruptId:e.approvalRequestId||``,approve:!1}):l({approvalRequestId:e.approvalRequestId||``,approve:!1,previousResponseId:e.previousResponseId}),className:`inline-flex min-h-8 items-center gap-1.5 rounded-md border border-slate-300 bg-white px-3 py-1.5 text-xs font-semibold text-slate-600 transition hover:border-rose-300 hover:bg-rose-50 hover:text-rose-600 disabled:cursor-not-allowed disabled:opacity-55 dark:border-slate-700 dark:bg-slate-950 dark:text-slate-300 dark:hover:border-rose-800 dark:hover:bg-rose-950/30 dark:hover:text-rose-300`,children:[(0,k.jsx)(lN,{className:`h-3.5 w-3.5`}),`拒绝`]})]}):(0,k.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-1.5 text-xs font-medium text-slate-500 dark:text-slate-400`,children:[e.approvalStatus===`approved`?(0,k.jsx)(sN,{className:`h-3.5 w-3.5 text-emerald-500`}):(0,k.jsx)(lN,{className:`h-3.5 w-3.5 text-rose-500`}),e.approvalStatus===`approved`?`已批准`:e.approvalStatus===`cancelled`?`已取消`:`已拒绝`]})]}):null,e.args?(0,k.jsx)(AJ,{label:`入参 (Args)`,tone:`input`,value:e.args}):null,e.output?(0,k.jsx)(AJ,{label:`输出 (Output)`,tone:e.status===`error`?`error`:`output`,value:e.output}):null]})]},`${e.name}-${t}`)):null,o.tools?Object.values(o.tools).filter(e=>p?.some(t=>t.interactionId===e.approvalRequestId)).map(e=>(0,k.jsx)($q,{interaction:p.find(t=>t.interactionId===e.approvalRequestId)},`anchor-${e.approvalRequestId}`)):null,(0,k.jsx)(`div`,{"data-slot":`assistant-content`,className:`w-full break-words`,children:o.content?(0,k.jsx)(Aq,{content:o.content}):!i&&(n&&r&&!o.reasoning&&!o.tools||o.eventType===`optimistic_assistant_placeholder`)?(0,k.jsx)(`span`,{className:`relative mt-1 inline-flex h-4 w-4 items-center justify-center`,role:`status`,"aria-label":`正在生成`,children:(0,k.jsx)(`span`,{className:`waiting-generation-breathe h-2.5 w-2.5 rounded-full`})}):null})]}),o.aguiActivities?.map(e=>(0,k.jsx)(zq,{surfaceId:e.surfaceId,messages:e.messages,onAction:f},e.surfaceId)),(0,k.jsx)(jJ,{isLastMessage:r,isStreaming:n,message:o,onDeleteFeedback:s,onSubmitFeedback:d})]})}function NJ({agentName:e,emptyState:t,isMobile:n,isStreaming:r,activity:i,contextIndicator:a,messages:o,showWaitingIndicator:s=!1,isLoadingInitialHistory:c=!1,onDeleteFeedback:l,onOpenAttachmentPreview:u,onRespondToApproval:d,onRespondToAguiApproval:f,onSubmitFeedback:p,onSubmitAguiAction:m,onStopGeneration:h,onCancelRemote:g,onScrollToBottom:_,checkpoints:y=[],onResumeCheckpoint:b,interactionRecords:x,scrollRef:S,className:C,revealMessage:w}){let[T,ee]=(0,v.useState)(0),[te,E]=(0,v.useState)(0),[ne,re]=(0,v.useState)(0),[ie,ae]=(0,v.useState)(new Map),oe=(0,v.useRef)(ie);(0,v.useLayoutEffect)(()=>{let e=S.current;if(!e)return;let t=()=>{ee(e.scrollTop),E(e.clientHeight),re(e.scrollHeight)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>t());return n.observe(e),e.firstElementChild instanceof HTMLElement&&n.observe(e.firstElementChild),()=>n.disconnect()},[S]);let se=(0,v.useMemo)(()=>gJ({items:o,scrollTop:T,viewportHeight:te,overscan:SJ,defaultItemHeight:xJ,measuredHeights:ie,getItemKey:(e,t)=>e?.id||String(t)}),[ie,o,T,te]),ce=se.visibleItems;(0,v.useEffect)(()=>{if(!w)return;let e=S.current,t=o.findIndex(e=>e.id===w.id);if(!e||t<0)return;let n=e.style.scrollBehavior;e.style.scrollBehavior=`auto`;let r=0,i=0,a=0,s=-1,c=()=>{let l=o.slice(0,t).reduce((e,t)=>e+(oe.current.get(t.id)||xJ),0);e.scrollTop=Math.max(0,l-24),ee(e.scrollTop),E(e.clientHeight);let u=Array.from(e.querySelectorAll(`[data-message-id]`)).find(e=>e.dataset.messageId===w.id);if(a=u&&Math.abs(s-l)<1?a+1:0,s=l,u&&(a>=3||i>=30)){e.scrollTop+=u.getBoundingClientRect().top-e.getBoundingClientRect().top-24,u.focus({preventScroll:!0}),e.dispatchEvent(new Event(`scroll`)),e.style.scrollBehavior=n;return}++i<30?r=requestAnimationFrame(c):e.style.scrollBehavior=n};return r=requestAnimationFrame(c),()=>{cancelAnimationFrame(r),e.style.scrollBehavior=n}},[w,S]);let D=(0,v.useCallback)((e,t,n)=>{if(!e||!Number.isFinite(t)||t<=0)return;let r=oe.current,i=r.get(e)??xJ;if(i===t)return;let a=new Map(r);a.set(e,t),oe.current=a,ae(a);let o=S.current;o&&n<o.scrollTop&&(o.scrollTop+=t-i,ee(o.scrollTop),re(o.scrollHeight))},[S]),O=_J({scrollHeight:ne,scrollTop:T,clientHeight:te}),le=vJ({scrollHeight:ne,scrollTop:T,clientHeight:te});return(0,k.jsxs)(`div`,{ref:S,onScroll:e=>{ee(e.currentTarget.scrollTop),E(e.currentTarget.clientHeight),re(e.currentTarget.scrollHeight)},className:K(`custom-scrollbar relative min-h-0 flex-1 overflow-y-auto scroll-smooth`,n?`px-3 py-3`:`px-4 py-5`,C),"data-slot":`message-list`,style:{overflowAnchor:`none`},children:[(0,k.jsx)(`div`,{"data-slot":`message-list-content`,className:`mx-auto flex w-full max-w-[64rem] flex-col pb-6 sm:pb-8`,children:o.length===0&&c?(0,k.jsx)(DJ,{}):o.length===0&&!s?t===void 0?(0,k.jsx)(EJ,{agentName:e}):t:(0,k.jsxs)(k.Fragment,{children:[o.length>0&&(0,k.jsx)(`div`,{style:{height:se.totalHeight},className:`relative`,children:ce.map(t=>(0,k.jsx)(TJ,{messageId:t.item.id||String(t.index),highlighted:t.item.id===w?.id,top:t.top,onMeasure:D,children:t.item.role===`system`?(0,k.jsx)(kJ,{message:t.item}):(0,k.jsx)(MJ,{agentName:e,isMobile:n,isStreaming:r,suppressWaitingIndicator:s,isLastMessage:t.index===o.length-1,showAgentHeader:!bJ(o[t.index-1],t.item),message:t.item,onDeleteFeedback:l,onOpenAttachmentPreview:u,onRespondToApproval:d,interactionRecords:x,onRespondToAguiApproval:f,onSubmitFeedback:p,onSubmitAguiAction:m})},t.item.id||t.index))}),s&&(0,k.jsx)(`div`,{className:`mx-auto w-full max-w-[60rem] px-2 sm:px-4`,role:`status`,"data-testid":`waiting-first-token`,children:(0,k.jsx)(`span`,{className:`waiting-thinking-text`,children:`正在思考…`})})]})}),(0,k.jsx)(fJ,{}),le?(0,k.jsx)(`button`,{type:`button`,"aria-label":`回到底部`,"data-distance-from-bottom":Math.round(O),onClick:()=>{if(_){_();return}let e=S.current;e&&e.scrollTo({top:e.scrollHeight,behavior:`auto`})},className:`sticky bottom-4 left-1/2 z-20 mx-auto flex h-9 w-9 -translate-x-1/2 items-center justify-center rounded-full border border-border bg-surface text-text-secondary shadow-[0_8px_24px_rgba(15,23,42,0.12)] transition hover:text-text-primary`,title:`回到底部`,children:r?(0,k.jsx)(`span`,{"aria-hidden":`true`,className:`flex items-center gap-0.5`,"data-scroll-indicator":`streaming`,children:[0,1,2].map(e=>(0,k.jsx)(`span`,{className:`h-1 w-1 animate-bounce rounded-full bg-current motion-reduce:animate-none`,style:{animationDelay:`${e*120}ms`}},e))}):(0,k.jsx)(cN,{"aria-hidden":`true`,className:`h-5 w-5`,"data-scroll-indicator":`idle`})}):null]})}var PJ=CR,FJ=wR,IJ=v.forwardRef(({className:e,...t},n)=>(0,k.jsx)(TR,{ref:n,className:K(`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}));IJ.displayName=TR.displayName;var LJ=v.forwardRef(({className:e,children:t,...n},r)=>(0,k.jsxs)(FJ,{children:[(0,k.jsx)(IJ,{}),(0,k.jsxs)(ER,{ref:r,className:K(`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,k.jsxs)(kR,{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,k.jsx)(jN,{className:`h-4 w-4`}),(0,k.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}));LJ.displayName=ER.displayName;var RJ=({className:e,...t})=>(0,k.jsx)(`div`,{className:K(`flex flex-col space-y-1.5 text-center sm:text-left`,e),...t});RJ.displayName=`DialogHeader`;var zJ=({className:e,...t})=>(0,k.jsx)(`div`,{className:K(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});zJ.displayName=`DialogFooter`;var BJ=v.forwardRef(({className:e,...t},n)=>(0,k.jsx)(DR,{ref:n,className:K(`text-lg font-semibold leading-none tracking-tight`,e),...t}));BJ.displayName=DR.displayName;var VJ=v.forwardRef(({className:e,...t},n)=>(0,k.jsx)(OR,{ref:n,className:K(`text-sm text-muted-foreground`,e),...t}));VJ.displayName=OR.displayName;function HJ(e,t){if(!(!t||e))return{width:`min(${t.width}px, calc(100vw - 5rem))`,height:`min(${t.height}px, calc(100vh - 9rem))`}}function UJ(e,t){if(!(!t||e))return{width:`min(${t.width+32}px, calc(100vw - 3rem))`}}function WJ({attachment:e,isMobile:t,previewImageSize:n,onClose:r,onImageLoad:i}){return(0,k.jsx)(PJ,{open:!!e?.url,onOpenChange:e=>!e&&r(),children:(0,k.jsxs)(LJ,{className:K(`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:UJ(t,n),children:[(0,k.jsx)(`div`,{className:`flex items-center gap-3 border-b border-slate-800 px-4 py-3 pr-16`,children:(0,k.jsx)(BJ,{className:`truncate text-sm font-medium`,children:e?.name||`附件预览`})}),(0,k.jsx)(`div`,{className:K(`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,k.jsx)(`img`,{src:e.url,alt:e.name,className:K(`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:HJ(t,n),onLoad:e=>{let t=e.currentTarget;i({width:t.naturalWidth,height:t.naturalHeight})}}):(0,k.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 GJ(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 KJ(e){return e?GJ(e.context_window_tokens)??GJ(e?.limits?.context_window_tokens):null}function qJ(e){return e?GJ(e.auto_compact_threshold_percentage)??84:84}function JJ({selectedModel:e,contextUsage:t}){let n=t&&(!t.model||t.model===e?.id)?t:null,r=GJ(n?.used_tokens),i=GJ(n?.context_window_tokens),a=i??KJ(e),o={contextWindowTokens:a??void 0,contextWindowSource:a?i?`runtime`:`model`:void 0},s=n?.source===`last_request`?`上次请求输入`:`上下文占用`;if(!r)return{label:`上下文用量暂不可用`,phase:`default`,...o};let c=a?Math.round(r/a*100):void 0;return{label:s,phase:c!==void 0&&c>=qJ(e)?`warning`:`normal`,percent:c,usedTokens:r,...o}}function YJ(e){return e.requestedSessionId===e.activeSessionId&&e.requestToken===e.activeRequestToken}function XJ({agentName:e,emptyState:t,isMobile:n,onDeleteFeedback:r,onSubmitFeedback:i,onRespondToApproval:a,onRespondToAguiApproval:o,onSubmitAguiAction:s,onStopGeneration:c,onCancelRemote:l,checkpointResumeEnabled:u=!1,onResumeCheckpoint:d,onLoadOlderSessionMessages:f,interactionRecords:p,className:m,revealMessage:h}){let g=el(e=>e.messages),_=D(e=>e.currentSessionId),y=D(e=>e.isLoadingSessions),b=nt(e=>e.isSessionStreaming(_)),x=nt(e=>e.getSessionActivity(_)),S=xj(e=>e.getSessionCheckpoints(_)),C=D(e=>_?e.messageHistory[_]:null),w=y||!!C?.isLoadingInitial,T=D(e=>e.sessions.find(e=>e.SessionId===_)?.ContextUsage),ee=Ue(e=>e.availableModels),te=Ue(e=>e.selectedModel),E=_e(e=>e.previewAttachment),ne=_e(e=>e.previewImageSize),re=(0,v.useRef)(null),ie=(0,v.useRef)(!0),ae=(0,v.useRef)(!1),oe=(0,v.useRef)(0),se=(0,v.useRef)(b),ce=(0,v.useRef)(!1),O=(0,v.useRef)(null),le=(0,v.useRef)(!0),ue=(0,v.useRef)(``),de=(0,v.useRef)(h);(0,v.useEffect)(()=>{de.current=h});let fe=(0,v.useMemo)(()=>ee.find(e=>e.id===te)||null,[ee,te]),pe=(0,v.useMemo)(()=>JJ({selectedModel:fe,contextUsage:T}),[fe,T]),me=g.reduce((e,t,n)=>t.role===`user`?n:e,-1),he=b&&!g.slice(me+1).some(e=>!!(e.role===`model`&&(e.content||e.reasoning||e.blocks?.some(e=>e.type===`text`||e.type===`thinking`?e.content:!0)||e.attachments?.length||e.a2ui||e.aguiActivity||e.aguiActivities?.length||Object.keys(e.tools||{}).length))),ge=(0,v.useCallback)(()=>{let e=re.current;if(!e)return;ie.current=!0,ae.current=!1;let t=e.style.scrollBehavior;e.style.scrollBehavior=`auto`;let n=0,r=0,i=-1,a=()=>{if(re.current===e){if(e.scrollTop=e.scrollHeight,oe.current=e.scrollTop,e.dispatchEvent(new Event(`scroll`)),r=e.scrollHeight===i?r+1:0,i=e.scrollHeight,n+=1,r>=3||n>=12){e.style.scrollBehavior=t;return}requestAnimationFrame(a)}};a()},[]);return(0,v.useEffect)(()=>{se.current=b},[b]),(0,v.useEffect)(()=>{le.current=!0,ie.current=!0,ae.current=!1,oe.current=0,ce.current=!1,O.current=null,ue.current=``},[_]),(0,v.useEffect)(()=>{h&&(ie.current=!1,ae.current=!0,le.current=!1)},[h]),(0,v.useEffect)(()=>{let e=g.at(-1),t=ue.current;ue.current=String(e?.id||``),e?.role===`user`&&e.id!==t&&!le.current&&ge()},[g,ge]),(0,v.useEffect)(()=>{let e=re.current;if(!e)return;let t=()=>{let t=e.scrollHeight-e.scrollTop-e.clientHeight,n=e.scrollTop<oe.current-2;if(oe.current=e.scrollTop,!le.current&&n&&e.scrollTop<200&&_&&C?.hasMore&&!C.isLoadingOlder&&!ce.current&&f){let t=e.scrollHeight,n=_,r=Symbol(n);ce.current=!0,O.current=r,f(n).then(()=>{YJ({requestedSessionId:n,activeSessionId:D.getState().currentSessionId,requestToken:r,activeRequestToken:O.current})&&requestAnimationFrame(()=>{if(!YJ({requestedSessionId:n,activeSessionId:D.getState().currentSessionId,requestToken:r,activeRequestToken:O.current}))return;let e=re.current;if(!e)return;let i=e.scrollHeight-t;e.scrollTop+=i,oe.current=e.scrollTop})}).finally(()=>{O.current===r&&(O.current=null,ce.current=!1)})}if(se.current&&n){ae.current=!0,ie.current=!1;return}if(ae.current){let e=t<=12;ae.current=!e,ie.current=e;return}ie.current=t<96};return t(),e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[C,_,f]),(0,v.useEffect)(()=>{let e=re.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{!le.current&&!ie.current||(e.scrollTop=e.scrollHeight,oe.current=e.scrollTop,e.dispatchEvent(new Event(`scroll`)))});return t.observe(e),e.firstElementChild instanceof HTMLElement&&t.observe(e.firstElementChild),()=>t.disconnect()},[_]),(0,v.useEffect)(()=>{let e=re.current;if(e){if(g.length>0&&le.current){let e=de.current,t=D.getState().currentSessionId,n=re.current,r=n?n.style.scrollBehavior:``;n&&(n.style.scrollBehavior=`auto`,n.scrollTop=n.scrollHeight,oe.current=n.scrollTop);let i=0,a=n?.scrollHeight??-1,o=!1,s=0,c=()=>{let e=re.current;e&&(e.scrollTop=e.scrollHeight,oe.current=e.scrollTop,e.dispatchEvent(new Event(`scroll`)))},l=()=>{if(!o){if(o=!0,de.current!==e){n&&(n.style.scrollBehavior=r);return}c(),n&&(n.style.scrollBehavior=r),ie.current=!0,ae.current=!1,le.current=!1}},u=()=>{if(o)return;if(de.current!==e){l();return}if(D.getState().currentSessionId!==t){o=!0;return}let n=re.current;if(n){if(n.scrollHeight!==a)a=n.scrollHeight,c(),i=0;else if(i+=1,i>=3){l();return}s=requestAnimationFrame(u)}},d=window.setTimeout(l,2e3);return s=requestAnimationFrame(u),()=>{if(cancelAnimationFrame(s),window.clearTimeout(d),D.getState().currentSessionId!==t){l();return}n&&(n.style.scrollBehavior=r)}}ie.current&&(e.scrollTop=e.scrollHeight,oe.current=e.scrollTop)}},[g,b,h]),(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(NJ,{revealMessage:h,emptyState:t,agentName:e,isMobile:n,isStreaming:b,activity:x,contextIndicator:pe,messages:g,showWaitingIndicator:he,isLoadingInitialHistory:w,onDeleteFeedback:r,onOpenAttachmentPreview:e=>{_e.getState().setPreviewAttachment(e),_e.getState().setPreviewImageSize(null)},onRespondToApproval:a,onRespondToAguiApproval:o,interactionRecords:p,onScrollToBottom:ge,onSubmitFeedback:i,onSubmitAguiAction:s,onStopGeneration:c,onCancelRemote:l,checkpoints:u?S:[],onResumeCheckpoint:d,scrollRef:re,className:m}),(0,k.jsx)(WJ,{attachment:E,isMobile:n,previewImageSize:ne,onClose:()=>{_e.getState().setPreviewAttachment(null),_e.getState().setPreviewImageSize(null)},onImageLoad:e=>_e.getState().setPreviewImageSize(e)})]})}function ZJ({indicator:e,onCompact:t,disabled:n}){let r=(0,v.useRef)(null),[i,a]=(0,v.useState)(!1),o=(0,v.useRef)(!1);(0,v.useEffect)(()=>{if(!i)return;let e=e=>{e.target instanceof Node&&!r.current?.contains(e.target)&&(o.current=!1,a(!1))},t=e=>{e.key===`Escape`&&(o.current=!1,a(!1),r.current?.querySelector(`button`)?.focus())};return document.addEventListener(`pointerdown`,e,!0),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e,!0),document.removeEventListener(`keydown`,t)}},[i]);let[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(``),d=typeof e.usedTokens==`number`&&Number.isFinite(e.usedTokens)&&e.usedTokens>=0,f=d&&typeof e.percent==`number`&&Number.isFinite(e.percent)?Math.max(0,Math.min(100,e.percent)):void 0,p=async()=>{if(!(!t||s||n)){c(!0),u(``);try{await t(),u(`上下文已压缩`)}catch(e){u(e instanceof Error?e.message:`压缩失败,请重试`)}finally{c(!1)}}};return(0,k.jsxs)(`div`,{ref:r,className:`relative flex h-8 w-8 items-center justify-center`,onPointerEnter:e=>{e.pointerType!==`touch`&&a(!0)},onPointerLeave:()=>{o.current||a(!1)},children:[(0,k.jsx)(`button`,{type:`button`,"aria-label":`上下文用量与压缩`,"aria-expanded":i,onClick:()=>{o.current=!o.current,a(o.current),u(``)},className:K(`flex h-8 w-8 items-center justify-center rounded-full`,e.phase===`warning`?`text-text-primary`:`text-text-muted`),children:(0,k.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,className:s?`animate-pulse`:void 0,style:{display:`block`,flexShrink:0},children:[(0,k.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`,fill:`none`,stroke:`var(--ksadk-menu-border, #b8bcb5)`,strokeWidth:`2`}),f!==void 0&&(0,k.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,pathLength:`100`,strokeDasharray:`${f} 100`,transform:`rotate(-90 8 8)`})]})}),(0,k.jsxs)(`div`,{style:{background:`var(--ksadk-menu-background, hsl(var(--popover)))`,borderColor:`var(--ksadk-menu-border, hsl(var(--border)))`,boxShadow:`var(--ksadk-menu-shadow, 0 18px 44px rgba(15, 23, 42, 0.16))`},role:i?`dialog`:void 0,"aria-label":i?`上下文`:void 0,className:K(`absolute bottom-full right-0 z-30 w-60 rounded-xl border border-border bg-background p-4 text-sm text-foreground shadow-lg`,i?`block`:`hidden`),children:[(0,k.jsx)(`p`,{className:K(`font-medium`,s&&`waiting-thinking-text`),children:s?`正在压缩上下文…`:d?e.label:`上下文用量暂不可用`}),d&&(0,k.jsxs)(`p`,{className:`mt-1 text-text-secondary`,children:[`${QJ(e.usedTokens)} tokens`,e.contextWindowTokens?` / ${QJ(e.contextWindowTokens)}`:``]}),e.contextWindowTokens&&(0,k.jsxs)(`p`,{className:`mt-1 text-text-muted`,children:[`模型窗口:`,QJ(e.contextWindowTokens),` tokens`]}),d&&!e.contextWindowTokens&&(0,k.jsx)(`p`,{className:`mt-1 text-text-muted`,children:`模型窗口大小未报告`}),f!==void 0&&(0,k.jsxs)(`p`,{className:`text-text-muted`,children:[f,`% 已使用`]}),i&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>void p(),disabled:!t||s||n,className:`mt-3 w-full rounded-lg border border-border bg-muted px-3 py-2 disabled:opacity-50`,children:s?`正在压缩…`:`压缩上下文`}),(0,k.jsx)(`p`,{className:`mt-2 text-xs text-text-muted`,children:n?`请等待当前运行结束`:t?`压缩模型上下文,保留聊天记录`:`当前会话尚不支持手动压缩`}),l&&(0,k.jsx)(`p`,{role:`status`,className:`mt-2 text-xs`,children:l})]})]})]})}function QJ(e){return new Intl.NumberFormat(`zh-CN`).format(e)}var $J=[{value:`plan`,label:`计划模式`,description:`先分析并形成可执行计划`,icon:Ine},{value:`goal`,label:`设定目标`,description:`朝可验证的停止条件持续推进`,icon:Xne}],eY={plan:`计划模式`,goal:`目标`};function tY({attachmentsEnabled:e,mode:t,support:n,onSelectMode:r,onUpload:i}){let[a,o]=(0,v.useState)(!1),s=(0,v.useRef)(null),c=$J.filter(e=>n[e.value]);return(0,v.useEffect)(()=>{if(!a)return;let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)},t=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[a]),!e&&c.length===0?null:(0,k.jsxs)(`div`,{ref:s,className:`relative flex min-w-0 items-center gap-1`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-xl text-text-secondary transition hover:bg-muted hover:text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/25`,"aria-expanded":a,"aria-haspopup":`menu`,"aria-label":`添加附件或选择执行模式`,title:`添加附件或选择执行模式`,children:(0,k.jsx)(CN,{className:`h-[19px] w-[19px]`})}),t?(0,k.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:K(`flex h-8 max-w-[8.5rem] items-center gap-1 rounded-xl px-2 text-[12px] transition`,t===`goal`?`bg-neutral-50 text-neutral-700 hover:bg-neutral-100 dark:bg-neutral-950/40 dark:text-neutral-300`:`text-text-secondary hover:bg-muted hover:text-text-primary`),"aria-label":`当前执行模式:${eY[t]}`,children:[(0,k.jsx)(`span`,{className:`truncate`,children:eY[t]}),(0,k.jsx)(cN,{className:`h-3.5 w-3.5 shrink-0`})]}):null,a?(0,k.jsxs)(`div`,{role:`menu`,"aria-label":`附件与执行模式`,className:`absolute bottom-[calc(100%+0.6rem)] left-0 z-40 w-[min(18rem,calc(100vw-2rem))] rounded-xl border border-border/80 bg-popover p-1 shadow-[0_10px_24px_rgba(15,23,42,0.12)]`,style:{backgroundColor:`var(--ksadk-popover, #fff)`,borderColor:`var(--ksadk-border, rgba(15, 23, 42, 0.12))`},children:[e?(0,k.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{i(),o(!1)},className:`flex h-10 w-full items-center gap-2 rounded-lg px-2.5 text-left transition hover:bg-muted/70`,children:[(0,k.jsx)(AN,{className:`h-4 w-4 shrink-0 text-text-muted`}),(0,k.jsx)(`span`,{className:`shrink-0 text-[13px] font-medium text-text-primary`,children:`上传附件`}),(0,k.jsx)(`span`,{className:`ml-auto truncate text-[11px] text-text-muted`,children:`添加文件或图片`})]}):null,c.map(e=>{let n=e.icon,i=t===e.value;return(0,k.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":i,onClick:()=>{r(e.value),o(!1)},className:K(`flex h-10 w-full items-center gap-2 rounded-lg px-2.5 text-left transition`,i?`bg-muted`:`hover:bg-muted/70`),children:[(0,k.jsx)(n,{className:`h-4 w-4 shrink-0 text-text-muted`}),(0,k.jsx)(`span`,{className:`shrink-0 text-[13px] font-medium text-text-primary`,children:e.label}),(0,k.jsx)(`span`,{className:`ml-auto truncate text-[11px] text-text-muted`,children:e.description}),i?(0,k.jsx)(sN,{className:`h-4 w-4 shrink-0 text-text-primary`}):null]},e.value)})]}):null]})}var nY=[{value:`auto`,label:`自动`},{value:`enabled`,label:`开启`},{value:`disabled`,label:`关闭`}],rY={auto:`自动`,enabled:`开启`,disabled:`关闭`};function iY({availableModels:e,selectedModel:t,thinkingEnabled:n,thinkingMode:r,onSelectModel:i,onSelectThinkingMode:a}){let[o,s]=(0,v.useState)(!1),c=(0,v.useRef)(null),l=e.find(e=>e.id===t)?.display_name||t||`选择模型`;return(0,v.useEffect)(()=>{if(!o)return;let e=e=>{c.current&&!c.current.contains(e.target)&&s(!1)},t=e=>{e.key===`Escape`&&s(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[o]),(0,k.jsxs)(`div`,{ref:c,className:`relative`,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:`flex h-8 max-w-[15rem] items-center gap-1.5 rounded-xl px-3 text-[13px] text-text-primary transition hover:brightness-[0.98] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/25`,style:{background:`var(--ksadk-menu-trigger-background, hsl(var(--muted)))`},"aria-expanded":o,"aria-haspopup":`menu`,"aria-label":n?`模型 ${l},推理 ${rY[r]}`:`模型 ${l}`,title:n?`选择模型与推理设置`:`选择模型`,children:[(0,k.jsx)(`span`,{className:`min-w-0 truncate`,children:l}),n?(0,k.jsx)(`span`,{className:`shrink-0 text-text-muted`,children:rY[r]}):null,(0,k.jsx)(cN,{className:K(`h-3.5 w-3.5 shrink-0 text-text-muted transition-transform`,o&&`rotate-180`)})]}),o?(0,k.jsxs)(`div`,{role:`menu`,"aria-label":`选择模型`,className:`absolute bottom-[calc(100%+0.65rem)] right-0 z-40 w-[min(17rem,calc(100vw-2rem))] overflow-hidden rounded-2xl border p-1.5`,style:{background:`var(--ksadk-menu-background, hsl(var(--popover)))`,borderColor:`var(--ksadk-menu-border, hsl(var(--border)))`,boxShadow:`var(--ksadk-menu-shadow, 0 18px 44px rgba(15, 23, 42, 0.16))`},children:[(0,k.jsx)(`div`,{className:`px-2.5 pb-1.5 pt-1 text-[11px] font-medium text-text-muted`,children:`模型`}),(0,k.jsx)(`div`,{className:`max-h-[min(45vh,18rem)] overflow-y-auto`,children:e.map(e=>{let n=e.id===t;return(0,k.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":n,onClick:()=>{i(e.id),s(!1)},className:K(`flex w-full items-center gap-2 rounded-xl px-2.5 py-2 text-left text-[13px] transition-colors`,n?`bg-muted text-text-primary`:`text-text-secondary hover:bg-muted hover:text-text-primary`),children:[(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.display_name||e.id}),n?(0,k.jsx)(sN,{className:`h-4 w-4 shrink-0`,"aria-hidden":`true`}):null]},e.id)})}),n?(0,k.jsx)(`div`,{className:`mt-1 border-t border-border px-1 pt-1.5`,children:(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-1.5 pb-1`,children:[(0,k.jsx)(`span`,{className:`text-[11px] font-medium text-text-muted`,children:`推理`}),(0,k.jsx)(`div`,{className:`flex rounded-lg bg-muted p-0.5`,children:nY.map(e=>(0,k.jsx)(`button`,{type:`button`,onClick:()=>a(e.value),className:K(`rounded-md px-2 py-1 text-[11px] transition-colors`,e.value===r?`bg-card text-text-primary shadow-sm`:`text-text-muted hover:text-text-primary`),children:e.label},e.value))})]})}):null]}):null]})}var aY=[{value:`ask`,label:`请求批准`,description:`Agent 请求授权时确认`,icon:vN},{value:`risk`,label:`风险操作需确认`,description:`仅副作用操作`,icon:DN},{value:`full`,label:`完全访问`,description:`不再确认`,icon:EN}],oY={ask:`请求批准`,risk:`风险确认`,full:`完全访问`};function sY({approvalPolicy:e}){let[t,n]=(0,v.useState)(!1),r=(0,v.useRef)(null),i=de(e=>e.permissionMode),a=de(e=>e.setPermissionMode),o=i===`ask`?vN:i===`full`?EN:DN,s=(0,v.useMemo)(()=>aY.filter(t=>!e||e.Modes.includes(t.value)),[e]);return(0,v.useEffect)(()=>{s.some(e=>e.value===i)||a(e?.DefaultMode||s[0]?.value||`risk`)},[e?.DefaultMode,i,a,s]),(0,v.useEffect)(()=>{if(!t)return;let e=e=>{r.current&&!r.current.contains(e.target)&&n(!1)},i=e=>{e.key===`Escape`&&n(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,i)}},[t]),(0,k.jsxs)(`div`,{ref:r,className:`relative`,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),className:K(`flex h-8 items-center gap-1.5 rounded-xl px-2.5 text-[13px] transition hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/25`,i===`full`?`text-amber-600 dark:text-amber-400`:`text-text-secondary hover:text-text-primary`),"aria-expanded":t,"aria-haspopup":`menu`,title:`设置本次会话的工具审批规则`,children:[(0,k.jsx)(o,{className:`h-3.5 w-3.5`}),(0,k.jsx)(`span`,{children:oY[i]}),(0,k.jsx)(cN,{className:K(`h-3.5 w-3.5 transition-transform`,t&&`rotate-180`)})]}),t?(0,k.jsx)(`div`,{role:`menu`,"aria-label":`工具权限`,className:`absolute bottom-[calc(100%+0.6rem)] left-0 z-30 w-[18rem] rounded-xl border border-border/80 bg-popover p-1 shadow-[0_10px_24px_rgba(15,23,42,0.12)]`,style:{backgroundColor:`var(--ksadk-popover, #fff)`,borderColor:`var(--ksadk-border, rgba(15, 23, 42, 0.12))`},children:s.map(e=>{let t=e.icon,r=e.value===i;return(0,k.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":r,onClick:()=>{a(e.value),n(!1)},className:K(`flex h-10 w-full items-center gap-2 rounded-lg px-2.5 text-left transition-colors`,r?`bg-primary/[0.08]`:`hover:bg-muted/75`),children:[(0,k.jsx)(t,{className:K(`h-4 w-4 shrink-0`,r?`text-primary`:`text-text-muted`)}),(0,k.jsx)(`span`,{className:K(`shrink-0 text-[13px] font-medium`,r?`text-text-primary`:`text-text-secondary`),children:e.label}),(0,k.jsx)(`span`,{className:`ml-auto truncate text-[11px] text-text-muted`,children:e.description}),r?(0,k.jsx)(sN,{className:`h-4 w-4 shrink-0 text-primary`,"aria-hidden":`true`}):null]},e.value)})}):null]})}function cY({headerSlot:e,onCompactContext:t,attachments:n,composerContextIndicator:r,composerMaxHeight:i,fileInputRef:a,input:o,isMobile:s,isStreaming:c,attachmentsEnabled:l=!0,approvalEnabled:u=!1,approvalPolicy:d,thinkingEnabled:f=!1,executionMode:p,executionModeSupport:m,queuedDrafts:h,onAppendAttachments:g,onInputChange:_,onSelectExecutionMode:y,onPaste:b,onRemoveAttachment:x,onStopGeneration:S,onCancelRemote:C,onSubmit:w,textareaRef:T,className:ee}){let[te,E]=(0,v.useState)(!1),ne=t?async()=>{E(!0);try{await t()}finally{E(!1)}}:void 0,re=p===`goal`?`描述需要持续完成的目标…`:p===`plan`?`描述需要先规划的任务…`:s?`发送消息...`:`发送消息…`,ie=C?`保留恢复点并结束本次执行`:`停止生成`,ae=p===`goal`?!!o.trim():!!(o.trim()||n.length>0),oe=Ue(e=>e.availableModels),se=Ue(e=>e.selectedModel),ce=Ue(e=>e.thinkingMode),D=Ue(e=>e.setSelectedModel),O=Ue(e=>e.setThinkingMode),le=e=>e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`;return(0,k.jsx)(`div`,{className:K(`relative z-10 flex-shrink-0 bg-background/95 px-3 py-3 backdrop-blur sm:px-4 sm:py-3`,ee),"data-slot":`composer`,children:(0,k.jsxs)(`div`,{className:`mx-auto w-full max-w-[64rem]`,children:[te&&(0,k.jsxs)(`div`,{role:`status`,className:`mb-3 flex items-center gap-2 px-2 text-sm text-text-muted`,children:[(0,k.jsx)(gN,{size:16,"aria-hidden":`true`}),(0,k.jsx)(`span`,{className:`waiting-thinking-text`,children:`正在压缩上下文`})]}),h.length>0?(0,k.jsxs)(`div`,{className:`mb-2 rounded-2xl border border-neutral-200/80 bg-neutral-50/80 px-3 py-2 text-xs text-neutral-900 shadow-sm dark:border-neutral-900/60 dark:bg-neutral-950/30 dark:text-neutral-100`,children:[(0,k.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between gap-2`,children:[(0,k.jsxs)(`span`,{className:`font-semibold`,children:[`发送队列 · `,h.length]}),(0,k.jsx)(`span`,{className:`text-neutral-700/75 dark:text-neutral-200/75`,children:`当前回复完成后依次发送`})]}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[h.slice(0,3).map((e,t)=>{let n=e.text.trim()||(e.attachments.length>0?`仅附件消息`:`空消息`);return(0,k.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-background/70 px-2 py-1.5`,children:[(0,k.jsx)(`span`,{className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-full bg-neutral-100 font-mono text-[10px] text-neutral-700 dark:bg-neutral-900/50 dark:text-neutral-100`,children:t+1}),(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-text-secondary`,children:n}),e.attachments.length>0?(0,k.jsxs)(`span`,{className:`flex-shrink-0 rounded-full bg-neutral-100 px-2 py-0.5 text-[10px] text-neutral-700 dark:bg-neutral-900/50 dark:text-neutral-100`,children:[e.attachments.length,` 附件`]}):null]},`${t}-${n}-${e.attachments.length}`)}),h.length>3?(0,k.jsxs)(`div`,{className:`px-2 pt-0.5 text-[11px] text-neutral-700/80 dark:text-neutral-200/80`,children:[`还有 `,h.length-3,` 条等待发送`]}):null]})]}):null,(0,k.jsx)(`div`,{"data-slot":`composer-surface`,className:`relative rounded-[var(--chat-composer-radius,28px)] bg-surface shadow-[0_0_0_0.5px_rgba(15,23,42,0.08),0_5px_18px_rgba(15,23,42,0.07)] dark:shadow-[0_0_0_0.5px_rgba(255,255,255,0.06),0_8px_24px_rgba(0,0,0,0.24)]`,children:(0,k.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,k.jsxs)(`form`,{"data-slot":`composer-form`,onSubmit:e=>{if(e.preventDefault(),te)return;if(c){C?C():S();return}let t=o.trim();ae&&w(t,n)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:e=>{e.preventDefault(),e.stopPropagation(),l&&e.dataTransfer.files&&e.dataTransfer.files.length>0&&g(Array.from(e.dataTransfer.files))},className:`relative flex min-h-[116px] min-w-0 flex-1 flex-col rounded-[var(--chat-composer-radius,28px)] border border-border/55 bg-background px-4 pb-3 pt-3 transition-all focus-within:border-primary/40 focus-within:ring-2 focus-within:ring-primary/15 sm:px-5`,children:[e==null?null:(0,k.jsx)(`div`,{"data-slot":`composer-header`,className:`mb-2 min-w-0`,children:e}),n.length>0?(0,k.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-2`,children:n.map((e,t)=>(0,k.jsxs)(`div`,{className:K(`group relative flex items-center gap-2 rounded-xl border border-border bg-background px-3 py-2 text-xs`,s?`max-w-full`:`max-w-[14rem]`),children:[(0,k.jsx)(`span`,{className:`flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-lg bg-muted text-text-muted`,children:(0,k.jsx)(SN,{className:`h-3.5 w-3.5`})}),(0,k.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(`span`,{className:`block truncate font-medium text-text-primary`,children:e.name}),(0,k.jsx)(`span`,{className:`block text-[10px] text-text-muted`,children:le(e.size)})]}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>x(t),className:`absolute -right-1.5 -top-1.5 flex h-4 w-4 items-center justify-center rounded-full border border-border bg-background text-text-muted shadow-sm transition hover:text-rose-500`,"aria-label":`移除附件 ${e.name}`,children:(0,k.jsx)(`span`,{className:`text-[11px] leading-none`,children:`×`})})]},`${e.name}-${e.size}-${t}`))}):null,(0,k.jsx)(`textarea`,{"data-slot":`composer-input`,ref:T,rows:1,value:o,onChange:_,onKeyDown:e=>{if(e.key===`Enter`&&!e.shiftKey){if(e.nativeEvent.isComposing||e.nativeEvent.keyCode===229)return;if(e.preventDefault(),c){!te&&ae&&w(o.trim(),n);return}e.currentTarget.form?.requestSubmit()}},onPaste:b,placeholder:re,className:K(`custom-scrollbar max-h-[176px] min-h-[62px] w-full resize-none overflow-y-auto border-0 bg-transparent px-0 pb-1 pt-1 text-[15px] leading-6 text-text-primary outline-none placeholder:text-text-muted/60`,s?`text-[16px]`:`text-[14px]`),style:{maxHeight:`${i}px`,overflowY:`auto`}}),(0,k.jsxs)(`div`,{"data-slot":`composer-toolbar`,className:`mt-auto flex min-h-8 items-center justify-between gap-2 pt-1.5`,children:[(0,k.jsxs)(`div`,{"data-slot":`composer-toolbar-start`,className:`flex min-w-0 items-center gap-1.5`,children:[(0,k.jsx)(`input`,{ref:a,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&e.target.files.length>0&&(g(Array.from(e.target.files)),e.target.value=``)}}),(0,k.jsx)(tY,{attachmentsEnabled:l,mode:p,support:m,onSelectMode:y,onUpload:()=>a.current?.click()}),u?(0,k.jsx)(sY,{approvalPolicy:d}):null]}),(0,k.jsxs)(`div`,{"data-slot":`composer-toolbar-end`,className:`flex min-w-0 items-center gap-1.5`,children:[r?(0,k.jsx)(ZJ,{indicator:r,onCompact:ne,disabled:c}):null,oe.length>0?(0,k.jsx)(iY,{availableModels:oe,selectedModel:se,thinkingEnabled:f,thinkingMode:ce,onSelectModel:D,onSelectThinkingMode:O}):null,(0,k.jsx)(`button`,{type:`submit`,disabled:te||!c&&!ae,className:K(`flex h-9 w-9 shrink-0 items-center justify-center rounded-full transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30`,c||ae?`bg-[#1f1f1f] text-white hover:opacity-80`:`bg-muted text-text-muted/45`),title:c?ie:`发送消息`,children:c?(0,k.jsx)(Yne,{className:`h-3.5 w-3.5 fill-current`}):(0,k.jsx)(aN,{className:`h-[18px] w-[18px]`})})]})]})]})})})]})})}function lY(e){return[e.name,e.size,e.lastModified,e.type].join(`:`)}function uY(e,t){let n=new Map;for(let t of e)n.set(lY(t),t);for(let e of t)n.set(lY(e),e);return Array.from(n.values())}function dY(e){return Array.from(e.clipboardData.items||[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>!!e)}function fY({draftKey:e,draftStore:t,headerSlot:n,onCompactContext:r,composerMaxHeight:i,submitDraft:a,stopGeneration:o,cancelRemote:s,isMobile:c,attachmentsEnabled:l=!0,approvalEnabled:u=!1,approvalPolicy:d,thinkingEnabled:f=!1,runtimeCapabilityMatrix:p,pendingInteractions:m,onRespondInteraction:h,localCatalog:g,className:_}){let[y,b]=(0,v.useState)(0),[x,S]=(0,v.useState)(),C=_e(e=>e.input),w=_e(e=>e.attachments),T=D(e=>e.currentSessionId),ee=nt(t=>t.isSessionStreaming(T||e)),te=_e(e=>e.queuedDrafts),E=D(e=>e.sessions.find(e=>e.SessionId===T)?.ContextUsage),ne=Ue(e=>e.availableModels),re=Ue(e=>e.selectedModel),ie=Ue(e=>e.setThinkingMode),ae=(0,v.useRef)(null),oe=(0,v.useRef)(null),[se]=(0,v.useState)(()=>new Pk),ce=t||se;(0,v.useLayoutEffect)(()=>{if(!e)return;let t=ce.get(e);return _e.setState({input:t.text,attachments:t.attachments}),_e.subscribe((t,n)=>{(t.input!==n.input||t.attachments!==n.attachments)&&ce.set(e,t.input,t.attachments)})},[e,ce]),(0,v.useEffect)(()=>!e||!t?void 0:ce.subscribe(()=>{if(ce.getConflict(e))return;let t=ce.get(e),n=_e.getState(),r=t.attachments.length===n.attachments.length&&t.attachments.every((e,t)=>e===n.attachments[t]);(t.text!==n.input||!r)&&_e.setState({input:t.text,attachments:t.attachments})}),[e,t,ce]);let O=(0,v.useMemo)(()=>ne.find(e=>e.id===re)||null,[ne,re]),le=(0,v.useMemo)(()=>JJ({selectedModel:O,contextUsage:E}),[O,E]),ue=(0,v.useMemo)(()=>({plan:!!p?.plan?.supported,goal:!!p?.goal?.supported}),[p]),de=x&&ue[x]?x:void 0,fe=(0,v.useCallback)((e,t)=>{!e&&t.length===0||(_e.getState().setInput(``),_e.getState().setAttachments([]),a(e,t,void 0,void 0,de),de===`goal`&&S(void 0))},[de,a]);(0,v.useEffect)(()=>{oe.current&&(oe.current.style.height=`auto`,oe.current.style.height=`${Math.min(oe.current.scrollHeight,i)}px`)},[C,i]);let pe=e=>{_e.getState().setInput(e.target.value),e.target.style.height=`auto`,e.target.style.height=`${Math.min(e.target.scrollHeight,i)}px`},me=e=>{!l||!e.length||_e.getState().setAttachments(t=>uY(t,e))},he=e=>{if(!l)return;let t=dY(e);t.length&&(e.preventDefault(),e.stopPropagation(),me(t))},ge=m||[],ve=Math.min(y,Math.max(ge.length-1,0));return(0,v.useEffect)(()=>{f||ie(`auto`)},[ie,f]),(0,k.jsxs)(`div`,{className:`flex w-full flex-col justify-center`,children:[ge.length>0&&h?(0,k.jsx)(Yq,{interactions:ge,activeIndex:ve,onSelectIndex:b,onRespond:h,localCatalog:g}):null,(0,k.jsx)(cY,{headerSlot:n,onCompactContext:T?r:void 0,attachments:w,composerContextIndicator:le,composerMaxHeight:i,fileInputRef:ae,input:C,isMobile:c,isStreaming:ee,attachmentsEnabled:l,approvalEnabled:u,approvalPolicy:d,thinkingEnabled:f,executionMode:de,executionModeSupport:ue,queuedDrafts:te,onAppendAttachments:me,onInputChange:pe,onSelectExecutionMode:S,onPaste:he,onRemoveAttachment:e=>_e.getState().setAttachments(t=>t.filter((t,n)=>n!==e)),onStopGeneration:o,onCancelRemote:s,onSubmit:fe,textareaRef:oe,className:_})]})}var pY=(0,v.lazy)(()=>J(()=>import(`./NativeTerminalPanel-DYD4i8DH.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function mY({availableModels:e,selectedModel:t,onSelectModel:n,selectedModelLabel:r,modelCatalogLoaded:i,modelSource:a,thinkingEnabled:o,thinkingMode:s,onSelectThinkingMode:c,compact:l=!1}){let u=K(`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,k.jsx)(`select`,{value:t,onChange:e=>n(e.target.value),className:u,children:e.map(e=>(0,k.jsx)(`option`,{value:e.id,children:e.display_name||e.id},e.id))}):r?(0,k.jsx)(`span`,{className:K(u,`inline-flex max-w-full items-center`,l?`justify-start`:``),title:a||r,children:(0,k.jsx)(`span`,{className:`truncate`,children:r})}):(0,k.jsx)(`span`,{className:`text-sm text-slate-400`,children:i?`未配置模型`:`Loading models...`}),f=o?(0,k.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),className:K(u,l?``:`max-w-[9rem]`),title:`控制模型 thinking/reasoning 参数`,children:[(0,k.jsx)(`option`,{value:`auto`,children:`思考自动`}),(0,k.jsx)(`option`,{value:`enabled`,children:`开启思考`}),(0,k.jsx)(`option`,{value:`disabled`,children:`关闭思考`})]}):null;return(0,k.jsxs)(`div`,{className:K(`flex min-w-0 gap-2`,l?`w-full flex-col`:`items-center`),children:[d,f]})}function hY({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:y,nativeManagementLink:b,nativeTerminal:x,nativeLauncherMode:S=!1}){let[C,w]=(0,v.useState)(!1),T=!!x?.Enabled,ee=n?i?(0,k.jsx)(bN,{className:`h-5 w-5`}):(0,k.jsx)(xN,{className:`h-5 w-5`}):r?(0,k.jsx)(bN,{className:`h-5 w-5`}):(0,k.jsx)(xN,{className:`h-5 w-5`});return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`header`,{className:K(`flex flex-shrink-0 items-center justify-between border-b border-black/[0.06] bg-background/95 px-3 py-2 backdrop-blur dark:border-white/[0.08] dark:bg-background/95 sm:px-4`,n?`pt-[calc(var(--safe-area-top)+0.5rem)]`:`h-12`),children:[(0,k.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[S?null:(0,k.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:ee}),(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100 sm:text-base`,children:e}),(0,k.jsx)(`div`,{className:`text-[11px] text-slate-400 dark:text-slate-500`,children:S?`原生运行时入口`:`智能体`})]})]}),n?(0,k.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,k.jsx)(Mne,{className:`h-5 w-5`})}):(0,k.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[b?(0,k.jsxs)(`a`,{href:b.href,target:`_blank`,rel:`noreferrer`,title:b.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,k.jsx)(mN,{className:`h-4 w-4`}),(0,k.jsx)(`span`,{children:b.label})]}):null,_?(0,k.jsxs)(`button`,{type:`button`,onClick:y,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,k.jsx)(_N,{className:`h-4 w-4`}),(0,k.jsx)(`span`,{children:`Workspace`})]}):null,T?(0,k.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,k.jsx)(ON,{className:`h-4 w-4`}),(0,k.jsx)(`span`,{children:`TUI`})]}):null,!S&&n?(0,k.jsx)(mY,{availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m,compact:!0}):null,!S&&t?(0,k.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,k.jsx)(NR,{open:h,onOpenChange:g,children:(0,k.jsxs)(LR,{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,k.jsxs)(RR,{className:`text-left`,children:[(0,k.jsx)(BR,{children:`会话设置`}),(0,k.jsx)(VR,{className:`sr-only`,children:`调整当前会话的模型和 Workspace 操作。`})]}),(0,k.jsxs)(`div`,{className:`mt-6 flex flex-col gap-4`,children:[_?(0,k.jsxs)(`button`,{type:`button`,onClick:()=>{g(!1),y()},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,k.jsx)(_N,{className:`h-4 w-4`}),`工作区文件`]}):null,T?(0,k.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,k.jsx)(ON,{className:`h-4 w-4`}),`原生 TUI`]}):null,b?(0,k.jsxs)(`a`,{href:b.href,target:`_blank`,rel:`noreferrer`,title:b.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,k.jsx)(mN,{className:`h-4 w-4`}),b.label]}):null,S?(0,k.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,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-slate-400 dark:text-slate-500`,children:`模型`}),(0,k.jsx)(mY,{availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m,compact:!0})]}),(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-slate-400 dark:text-slate-500`,children:`当前会话`}),(0,k.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,k.jsx)(`span`,{className:`break-all font-mono`,children:t}):`新对话尚未创建会话 ID`})]})]})]})]})}):null,x&&C?(0,k.jsx)(v.Suspense,{fallback:null,children:(0,k.jsx)(pY,{capability:x,open:C,sessionId:t,onClose:()=>w(!1)})}):null]})}var gY=(0,v.lazy)(()=>J(()=>import(`./NativeTerminalPanel-DYD4i8DH.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function _Y({productLabel:e=`原生运行时`,nativeManagementLink:t,nativeTerminal:n,workspaceEnabled:r,onOpenWorkspace:i}){let a=!!n?.Enabled,[o,s]=(0,v.useState)(!1);return(0,k.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,k.jsx)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col justify-center`,children:(0,k.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,k.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,k.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,k.jsx)(DN,{className:`h-3.5 w-3.5`}),e,` native runtime`]}),(0,k.jsx)(`h1`,{className:`mt-5 text-2xl font-semibold tracking-tight text-slate-950 dark:text-slate-50 sm:text-3xl`,children:`对话请使用原生管理台`}),(0,k.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,k.jsxs)(`div`,{className:`grid gap-4 p-6 md:grid-cols-3 sm:p-8`,children:[(0,k.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,k.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,k.jsx)(Bne,{className:`h-5 w-5`})}),(0,k.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`原生管理台`}),(0,k.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`使用原生管理台处理对话、工具卡片、思考流、审批、中断和运行时历史,避免跨状态机不一致。`}),t?(0,k.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,k.jsx)(mN,{className:`h-4 w-4`}),`打开`,t.label]}):(0,k.jsx)(`div`,{className:`mt-5 rounded-2xl border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm leading-6 text-neutral-800 dark:border-neutral-900/60 dark:bg-neutral-950/30 dark:text-neutral-200`,children:`当前访问模式不开放原生管理入口。需要完整对话体验时,请使用 owner/private 链接或 CLI。`})]}),(0,k.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,k.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,k.jsx)(_N,{className:`h-5 w-5`})}),(0,k.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`Workspace 文件管理`}),(0,k.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`文件浏览、上传、预览仍由 Hosted UI 提供,和原生管理台组合使用覆盖对话与工作区。`}),r?(0,k.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,k.jsx)(_N,{className:`h-4 w-4`}),`打开 Workspace`]}):(0,k.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,k.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,k.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,k.jsx)(ON,{className:`h-5 w-5`})}),(0,k.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`原生 TUI`}),(0,k.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`如果运行时暴露安全的 ks-terminal.v1 通道,可以在这里进入原生终端 UI;share 链接不会开放该入口。`}),a?(0,k.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,k.jsx)(ON,{className:`h-4 w-4`}),`打开 TUI`]}):(0,k.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,k.jsx)(v.Suspense,{fallback:null,children:(0,k.jsx)(gY,{capability:n,open:o,onClose:()=>s(!1)})}):null]})}var vY=[],yY=[];(()=>{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?yY:vY).push(n+=e[t])})();function bY(e){if(e<768)return!1;for(let t=0,n=vY.length;;){let r=t+n>>1;if(e<vY[r])n=r;else if(e>=yY[r])t=r+1;else return!0;if(t==n)return!1}}function xY(e){return e>=127462&&e<=127487}var SY=8205;function CY(e,t,n=!0,r=!0){return(n?wY:TY)(e,t,r)}function wY(e,t,n){if(t==e.length)return t;t&&DY(e.charCodeAt(t))&&OY(e.charCodeAt(t-1))&&t--;let r=EY(e,t);for(t+=kY(r);t<e.length;){let i=EY(e,t);if(r==SY||i==SY||n&&bY(i))t+=kY(i),r=i;else if(xY(i)){let n=0,r=t-2;for(;r>=0&&xY(EY(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function TY(e,t,n){for(;t>0;){let r=wY(e,t-2,n);if(r<t)return r;t--}return 0}function EY(e,t){let n=e.charCodeAt(t);if(!OY(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return DY(r)?(n-55296<<10)+(r-56320)+65536:n}function DY(e){return e>=56320&&e<57344}function OY(e){return e>=55296&&e<56320}function kY(e){return e<65536?1:2}var AY=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]=BY(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),MY.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]=BY(this,e,t);let n=[];return this.decompose(e,t,n,0),MY.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 IY(this),i=new IY(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 IY(this,e)}iterRange(e,t=this.length){return new LY(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 RY(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 jY(t):MY.from(jY.split(t,[]))}},jY=class e extends AY{constructor(e,t=NY(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 zY(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(FY(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=PY(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]=BY(this,t,n);let i=PY(this.text,PY(r.text,FY(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):MY.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
|
|
200
|
+
flex items-center justify-center shadow-lg shadow-blue-500/20`,children:(0,k.jsx)(oN,{className:`h-8 w-8 text-white`})}),(0,k.jsx)(`h2`,{className:`text-xl font-semibold text-slate-900 dark:text-slate-50`,children:`有什么我可以帮您的吗?`}),(0,k.jsxs)(`p`,{className:`mt-2 text-sm text-slate-500`,children:[`我是 `,e,`,由 Ksyun AgentEngine 驱动`]})]})}function DJ(){return(0,k.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[44rem] flex-col gap-5 px-2 py-8`,"aria-label":`正在加载会话历史`,children:[(0,k.jsx)(`div`,{className:`h-4 w-28 animate-pulse rounded bg-slate-200/80 dark:bg-slate-800`}),(0,k.jsx)(`div`,{className:`h-20 w-4/5 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900`}),(0,k.jsx)(`div`,{className:`ml-auto h-12 w-3/5 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900`}),(0,k.jsx)(`div`,{className:`h-16 w-11/12 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900`})]})}function OJ({attachments:e,isMobile:t,onOpenAttachmentPreview:n}){let r=e=>typeof e!=`number`||!Number.isFinite(e)||e<0?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`,i=e=>{let t=e.status===`pending`?`生成中`:e.status===`failed`?`生成失败`:``;return[e.type,r(e.sizeBytes),t,e.runId&&`run ${e.runId.slice(0,12)}`].filter(Boolean).join(` · `)},a=e=>!!(e.artifactId||e.itemId||e.runId||e.sizeBytes!=null);return(0,k.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-3`,children:e.map((e,r)=>e.type.startsWith(`image/`)?e.url?(0,k.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>n(e),className:K(`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,k.jsx)(`img`,{src:e.url,alt:e.name,className:K(`object-cover transition group-hover:scale-[1.02]`,t?`max-h-[16rem] w-full max-w-full`:`max-h-[200px] max-w-[200px]`)})}),a(e)&&(0,k.jsx)(`span`,{className:`max-w-[200px] truncate text-[11px] text-slate-500 dark:text-slate-400`,title:`来源 item ${e.itemId||`未知`} · run ${e.runId||`未知`}`,children:i(e)})]},`${e.name}-${r}`):(0,k.jsx)(`div`,{className:K(`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,k.jsxs)(`div`,{className:K(`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,k.jsx)(SN,{className:`h-4 w-4 flex-shrink-0 text-blue-500`}),e.url?(0,k.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,k.jsx)(`span`,{className:`truncate text-sm text-slate-700 dark:text-slate-300`,title:e.name,children:e.name}),a(e)&&(0,k.jsx)(`span`,{className:`text-[11px] text-slate-500 dark:text-slate-400`,title:`来源 item ${e.itemId||`未知`} · run ${e.runId||`未知`}`,children:i(e)})]},`${e.name}-${r}`))})}function kJ({message:e}){return(0,k.jsx)(`div`,{className:`w-full px-0 py-2 sm:px-4`,children:(0,k.jsxs)(`div`,{className:`mx-auto max-w-3xl rounded-xl border border-neutral-200/70 bg-neutral-50/60 px-4 py-3 text-sm text-neutral-600 dark:border-neutral-800 dark:bg-neutral-900/40 dark:text-neutral-300`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[e.status===`running`?(0,k.jsx)(wN,{className:`h-4 w-4 animate-spin text-neutral-600 dark:text-neutral-300`}):e.status===`failed`?(0,k.jsx)(jne,{className:`h-4 w-4 text-rose-600 dark:text-rose-400`}):(0,k.jsx)(sN,{className:`h-4 w-4 text-emerald-600 dark:text-emerald-400`}),(0,k.jsx)(`span`,{children:e.content})]}),e.compactedUntilSeqId?(0,k.jsxs)(`div`,{className:`mt-1 text-xs text-neutral-700/80 dark:text-neutral-200/80`,children:[`已折叠到会话事件 #`,e.compactedUntilSeqId]}):null,e.summary?(0,k.jsxs)(`details`,{className:`mt-3 rounded-xl border border-neutral-200/80 bg-white/70 px-3 py-2 dark:border-neutral-900/60 dark:bg-slate-950/40`,children:[(0,k.jsx)(`summary`,{className:`cursor-pointer select-none text-xs font-medium text-neutral-800 dark:text-neutral-200`,children:`查看压缩摘要`}),(0,k.jsx)(`div`,{className:`mt-2 text-[13px] leading-relaxed text-slate-700 dark:text-slate-200`,children:(0,k.jsx)(Aq,{content:e.summary})})]}):null]})})}function AJ({label:e,tone:t,value:n}){let[r,i]=(0,v.useState)(`idle`),a=Dne(n);(0,v.useEffect)(()=>{if(r===`idle`)return;let e=window.setTimeout(()=>i(`idle`),1600);return()=>window.clearTimeout(e)},[r]);let o=async()=>{i(await mJ(a)?`copied`:`failed`)};return(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,k.jsx)(`div`,{className:K(`text-xs font-semibold uppercase`,t===`input`?`text-blue-500`:t===`error`?`text-rose-500`:`text-emerald-500`),children:e}),(0,k.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,k.jsx)(sN,{className:`h-3.5 w-3.5 text-emerald-500`}):(0,k.jsx)(dN,{className:`h-3.5 w-3.5`}),r===`copied`?`已复制`:r===`failed`?`复制失败`:`复制`]})]}),(0,k.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 jJ({isLastMessage:e,isStreaming:t,message:n,onDeleteFeedback:r,onSubmitFeedback:i,alwaysVisible:a=!1}){let[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(n.feedback?.comment||``),u=eM(n,t,e),d=!!n.feedback?.pending,f=n.feedback?.rating,p=async()=>{let e=n.content||``;e&&mJ(e)};return u?(0,k.jsxs)(`div`,{className:K(`mt-2 flex flex-col gap-2 transition-opacity duration-150 focus-within:opacity-100`,a?`opacity-100`:`opacity-0 group-hover:opacity-100`),children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-xs text-text-muted`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>{p()},className:`inline-flex items-center gap-1 rounded-full px-2 py-1 font-medium text-text-secondary transition hover:bg-muted hover:text-text-primary`,title:`复制`,children:(0,k.jsx)(dN,{className:`h-3.5 w-3.5`})}),(0,k.jsx)(`span`,{className:`text-text-muted/60`,children:`·`}),(0,k.jsx)(`span`,{className:`font-medium`,children:`本次回复有帮助吗?`}),(0,k.jsxs)(`button`,{type:`button`,disabled:d,onClick:()=>i({message:n,rating:`up`,comment:``}),className:K(`inline-flex items-center gap-1 rounded-full border px-2.5 py-1 font-medium transition disabled:cursor-not-allowed disabled:opacity-60`,f===`up`?`border-primary/30 bg-primary/10 text-primary`:`border-border bg-background text-text-secondary hover:border-primary/30 hover:text-primary`),children:[(0,k.jsx)(Qne,{className:`h-3.5 w-3.5`}),`有帮助`]}),(0,k.jsxs)(`button`,{type:`button`,disabled:d,onClick:()=>{l(n.feedback?.comment||``),s(e=>!e)},className:K(`inline-flex items-center gap-1 rounded-full border px-2.5 py-1 font-medium transition disabled:cursor-not-allowed disabled:opacity-60`,f===`down`?`border-rose-300 bg-rose-50 text-rose-600 dark:border-rose-900/70 dark:bg-rose-950/30 dark:text-rose-300`:`border-border bg-background text-text-secondary hover:border-rose-300 hover:text-rose-600`),children:[(0,k.jsx)(Zne,{className:`h-3.5 w-3.5`}),`需改进`]}),n.feedback?(0,k.jsxs)(`button`,{type:`button`,disabled:d,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,k.jsx)(kN,{className:`h-3.5 w-3.5`}),`删除反馈`]}):null,d?(0,k.jsx)(`span`,{className:`text-slate-400`,children:`提交中…`}):null]}),o?(0,k.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,k.jsx)(`textarea`,{value:c,onChange:e=>l(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,k.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-2`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>s(!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,k.jsx)(`button`,{type:`button`,disabled:d,onClick:()=>{i({message:n,rating:`down`,comment:c}),s(!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:`提交点踩`})]})]}):f===`down`&&n.feedback?.comment?(0,k.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,k.jsx)(`div`,{className:`text-xs text-rose-600 dark:text-rose-300`,children:n.feedback.error}):null]}):null}function MJ({agentName:e,isMobile:t,isStreaming:n,isLastMessage:r,suppressWaitingIndicator:i=!1,showAgentHeader:a,message:o,onDeleteFeedback:s,onOpenAttachmentPreview:c,onRespondToApproval:l,onRespondToAguiApproval:u,onSubmitFeedback:d,onSubmitAguiAction:f,interactionRecords:p}){if(o.role===`user`)return(0,k.jsx)(`div`,{className:`mb-3 flex justify-end`,children:(0,k.jsxs)(`div`,{"data-slot":`user-message`,className:`max-w-[80%] rounded-2xl bg-muted px-3 py-2 text-[14px] leading-relaxed text-foreground`,children:[o.attachments?.length?(0,k.jsx)(OJ,{attachments:o.attachments,isMobile:t,onOpenAttachmentPreview:c}):null,o.content]})});if(o.role===`a2ui`&&o.aguiActivity)return(0,k.jsx)(zq,{surfaceId:o.aguiActivity.surfaceId,messages:o.aguiActivity.messages,onAction:f});let m=n&&r&&!o.content;return(0,k.jsxs)(`div`,{"data-slot":`assistant-message`,className:`group mx-auto mb-3 w-full max-w-[60rem] px-2 sm:px-4`,children:[a?(0,k.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-xs text-text-muted`,children:[(0,k.jsx)(oN,{className:`w-3.5 h-3.5`}),(0,k.jsx)(`span`,{children:e})]}):null,o.attachments?.length?(0,k.jsx)(OJ,{attachments:o.attachments,isMobile:t,onOpenAttachmentPreview:c}):null,o.blocks?.length?(0,k.jsx)(dJ,{message:o,isStreaming:n,onRespondToApproval:l,interactionRecords:p,onRespondToAguiApproval:u}):(0,k.jsxs)(k.Fragment,{children:[o.reasoning?(0,k.jsxs)(`details`,{className:`group/details mb-3 overflow-hidden rounded-md border border-slate-200/80 bg-slate-50/60 text-sm text-slate-600 transition-colors open:bg-white dark:border-slate-700/80 dark:bg-slate-900/40 dark:text-slate-300 dark:open:bg-slate-950/30`,children:[(0,k.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 px-3 py-2 font-medium outline-none marker:hidden`,children:[(0,k.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[m?null:(0,k.jsx)(sN,{className:`h-4 w-4 text-slate-400`}),(0,k.jsx)(`span`,{className:K(`truncate`,m&&`waiting-thinking-text`),"data-testid":m?`legacy-thinking-indicator`:void 0,role:m?`status`:void 0,children:m?`正在思考…`:`思考过程`}),m?null:(0,k.jsx)(`span`,{className:`rounded-full bg-slate-200/70 px-2 py-0.5 text-[11px] font-medium text-slate-600 dark:bg-slate-800 dark:text-slate-300`,children:`已完成`})]}),(0,k.jsx)(cN,{className:`h-4 w-4 flex-shrink-0 text-slate-400 transition-transform group-open/details:rotate-180`})]}),(0,k.jsx)(`div`,{className:`border-t border-slate-200/70 bg-white/70 dark:border-slate-800 dark:bg-slate-950/20`,children:(0,k.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,k.jsx)(Aq,{content:o.reasoning})})})]}):null,o.tools?Object.values(o.tools).map((e,t)=>(0,k.jsxs)(`details`,{open:e.approvalStatus===`pending`||e.status===`paused`?!0:void 0,className:K(`group/details mb-2 overflow-hidden rounded-md border text-sm transition-colors`,e.status===`paused`?`border-neutral-200/80 bg-neutral-50/25 text-slate-700 dark:border-neutral-900/60 dark:bg-neutral-950/10 dark:text-slate-200`:e.status===`error`?`border-rose-200/80 bg-rose-50/25 text-rose-700 dark:border-rose-900/60 dark:bg-rose-950/10 dark:text-rose-200`:`border-slate-200/80 bg-slate-50/40 text-slate-600 dark:border-slate-700/80 dark:bg-slate-900/30 dark:text-slate-300`),children:[(0,k.jsx)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 px-3 py-2 font-medium`,children:(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.status===`running`?(0,k.jsx)(wN,{className:`h-4 w-4 animate-spin text-slate-500`}):e.status===`paused`?(0,k.jsx)(DN,{className:`h-4 w-4 text-neutral-500`}):e.status===`error`?(0,k.jsx)(lN,{className:`h-4 w-4 text-rose-500`}):(0,k.jsx)(sN,{className:`h-4 w-4 text-slate-400`}),(0,k.jsxs)(`span`,{children:[e.approvalStatus===`pending`?`等待审批:`:e.approvalStatus===`approved`?`已批准:`:e.approvalStatus===`rejected`?`已拒绝:`:e.approvalStatus===`cancelled`?`已取消:`:e.status===`error`?`工具调用失败:`:`工具调用:`,e.name]})]})}),(0,k.jsxs)(`div`,{className:K(`flex flex-col gap-3 border-t px-3 py-3 font-mono text-[13px] leading-relaxed`,e.status===`paused`?`border-neutral-200/70 dark:border-neutral-900/60`:e.status===`error`?`border-rose-200/70 dark:border-rose-900/60`:`border-slate-200/70 dark:border-slate-800`),children:[e.approvalRequestId?(0,k.jsxs)(`div`,{className:`font-sans text-sm text-slate-700 dark:text-slate-200`,children:[(0,k.jsx)(`div`,{className:`font-medium`,children:e.approvalStatus===`approved`?`已批准该工具调用。`:e.approvalStatus===`rejected`?`已拒绝该工具调用。`:e.approvalStatus===`cancelled`?`已取消该工具调用。`:e.approvalMessage||`该工具调用需要人工确认后继续。`}),e.approvalLevel?(0,k.jsxs)(`div`,{className:K(`mt-2 inline-flex items-center rounded border px-1.5 py-0.5 text-xs font-medium`,wJ(e.approvalLevel)),children:[`审批级别:`,CJ(e.approvalLevel)]}):null,e.serverLabel?(0,k.jsxs)(`div`,{className:`mt-1 text-xs text-neutral-700/80 dark:text-neutral-200/80`,children:[`MCP Server: `,e.serverLabel]}):null,e.approvalStatus===`pending`?(0,k.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,k.jsxs)(`button`,{type:`button`,disabled:n||e.approvalStatus!==`pending`,onClick:()=>e.approvalProtocol===`ag-ui`?u?.({interruptId:e.approvalRequestId||``,approve:!0}):l({approvalRequestId:e.approvalRequestId||``,approve:!0,previousResponseId:e.previousResponseId}),className:`inline-flex min-h-8 items-center gap-1.5 rounded-md 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,k.jsx)(sN,{className:`h-3.5 w-3.5`}),`批准并继续`]}),(0,k.jsxs)(`button`,{type:`button`,disabled:n||e.approvalStatus!==`pending`,onClick:()=>e.approvalProtocol===`ag-ui`?u?.({interruptId:e.approvalRequestId||``,approve:!1}):l({approvalRequestId:e.approvalRequestId||``,approve:!1,previousResponseId:e.previousResponseId}),className:`inline-flex min-h-8 items-center gap-1.5 rounded-md border border-slate-300 bg-white px-3 py-1.5 text-xs font-semibold text-slate-600 transition hover:border-rose-300 hover:bg-rose-50 hover:text-rose-600 disabled:cursor-not-allowed disabled:opacity-55 dark:border-slate-700 dark:bg-slate-950 dark:text-slate-300 dark:hover:border-rose-800 dark:hover:bg-rose-950/30 dark:hover:text-rose-300`,children:[(0,k.jsx)(lN,{className:`h-3.5 w-3.5`}),`拒绝`]})]}):(0,k.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-1.5 text-xs font-medium text-slate-500 dark:text-slate-400`,children:[e.approvalStatus===`approved`?(0,k.jsx)(sN,{className:`h-3.5 w-3.5 text-emerald-500`}):(0,k.jsx)(lN,{className:`h-3.5 w-3.5 text-rose-500`}),e.approvalStatus===`approved`?`已批准`:e.approvalStatus===`cancelled`?`已取消`:`已拒绝`]})]}):null,e.args?(0,k.jsx)(AJ,{label:`入参 (Args)`,tone:`input`,value:e.args}):null,e.output?(0,k.jsx)(AJ,{label:`输出 (Output)`,tone:e.status===`error`?`error`:`output`,value:e.output}):null]})]},`${e.name}-${t}`)):null,o.tools?Object.values(o.tools).filter(e=>p?.some(t=>t.interactionId===e.approvalRequestId)).map(e=>(0,k.jsx)($q,{interaction:p.find(t=>t.interactionId===e.approvalRequestId)},`anchor-${e.approvalRequestId}`)):null,(0,k.jsx)(`div`,{"data-slot":`assistant-content`,className:`w-full break-words`,children:o.content?(0,k.jsx)(Aq,{content:o.content}):!i&&(n&&r&&!o.reasoning&&!o.tools||o.eventType===`optimistic_assistant_placeholder`)?(0,k.jsx)(`span`,{className:`relative mt-1 inline-flex h-4 w-4 items-center justify-center`,role:`status`,"aria-label":`正在生成`,children:(0,k.jsx)(`span`,{className:`waiting-generation-breathe h-2.5 w-2.5 rounded-full`})}):null})]}),o.aguiActivities?.map(e=>(0,k.jsx)(zq,{surfaceId:e.surfaceId,messages:e.messages,onAction:f},e.surfaceId)),(0,k.jsx)(jJ,{isLastMessage:r,isStreaming:n,message:o,onDeleteFeedback:s,onSubmitFeedback:d})]})}function NJ({agentName:e,emptyState:t,isMobile:n,isStreaming:r,activity:i,contextIndicator:a,messages:o,showWaitingIndicator:s=!1,isLoadingInitialHistory:c=!1,onDeleteFeedback:l,onOpenAttachmentPreview:u,onRespondToApproval:d,onRespondToAguiApproval:f,onSubmitFeedback:p,onSubmitAguiAction:m,onStopGeneration:h,onCancelRemote:g,onScrollToBottom:_,checkpoints:y=[],onResumeCheckpoint:b,interactionRecords:x,scrollRef:S,className:C,revealMessage:w}){let[T,ee]=(0,v.useState)(0),[te,E]=(0,v.useState)(0),[ne,re]=(0,v.useState)(0),[ie,ae]=(0,v.useState)(new Map),oe=(0,v.useRef)(ie);(0,v.useLayoutEffect)(()=>{let e=S.current;if(!e)return;let t=()=>{ee(e.scrollTop),E(e.clientHeight),re(e.scrollHeight)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>t());return n.observe(e),e.firstElementChild instanceof HTMLElement&&n.observe(e.firstElementChild),()=>n.disconnect()},[S]);let se=(0,v.useMemo)(()=>gJ({items:o,scrollTop:T,viewportHeight:te,overscan:SJ,defaultItemHeight:xJ,measuredHeights:ie,getItemKey:(e,t)=>e?.id||String(t)}),[ie,o,T,te]),ce=se.visibleItems;(0,v.useEffect)(()=>{if(!w)return;let e=S.current,t=o.findIndex(e=>e.id===w.id);if(!e||t<0)return;let n=e.style.scrollBehavior;e.style.scrollBehavior=`auto`;let r=0,i=0,a=0,s=-1,c=()=>{let l=o.slice(0,t).reduce((e,t)=>e+(oe.current.get(t.id)||xJ),0);e.scrollTop=Math.max(0,l-24),ee(e.scrollTop),E(e.clientHeight);let u=Array.from(e.querySelectorAll(`[data-message-id]`)).find(e=>e.dataset.messageId===w.id);if(a=u&&Math.abs(s-l)<1?a+1:0,s=l,u&&(a>=3||i>=30)){e.scrollTop+=u.getBoundingClientRect().top-e.getBoundingClientRect().top-24,u.focus({preventScroll:!0}),e.dispatchEvent(new Event(`scroll`)),e.style.scrollBehavior=n;return}++i<30?r=requestAnimationFrame(c):e.style.scrollBehavior=n};return r=requestAnimationFrame(c),()=>{cancelAnimationFrame(r),e.style.scrollBehavior=n}},[w,S]);let D=(0,v.useCallback)((e,t,n)=>{if(!e||!Number.isFinite(t)||t<=0)return;let r=oe.current,i=r.get(e)??xJ;if(i===t)return;let a=new Map(r);a.set(e,t),oe.current=a,ae(a);let o=S.current;o&&n<o.scrollTop&&(o.scrollTop+=t-i,ee(o.scrollTop),re(o.scrollHeight))},[S]),O=_J({scrollHeight:ne,scrollTop:T,clientHeight:te}),le=vJ({scrollHeight:ne,scrollTop:T,clientHeight:te});return(0,k.jsxs)(`div`,{ref:S,onScroll:e=>{ee(e.currentTarget.scrollTop),E(e.currentTarget.clientHeight),re(e.currentTarget.scrollHeight)},className:K(`custom-scrollbar relative min-h-0 flex-1 overflow-y-auto scroll-smooth`,n?`px-3 py-3`:`px-4 py-5`,C),"data-slot":`message-list`,style:{overflowAnchor:`none`},children:[(0,k.jsx)(`div`,{"data-slot":`message-list-content`,className:`mx-auto flex w-full max-w-[64rem] flex-col pb-6 sm:pb-8`,children:o.length===0&&c?(0,k.jsx)(DJ,{}):o.length===0&&!s?t===void 0?(0,k.jsx)(EJ,{agentName:e}):t:(0,k.jsxs)(k.Fragment,{children:[o.length>0&&(0,k.jsx)(`div`,{style:{height:se.totalHeight},className:`relative`,children:ce.map(t=>(0,k.jsx)(TJ,{messageId:t.item.id||String(t.index),highlighted:t.item.id===w?.id,top:t.top,onMeasure:D,children:t.item.role===`system`?(0,k.jsx)(kJ,{message:t.item}):(0,k.jsx)(MJ,{agentName:e,isMobile:n,isStreaming:r,suppressWaitingIndicator:s,isLastMessage:t.index===o.length-1,showAgentHeader:!bJ(o[t.index-1],t.item),message:t.item,onDeleteFeedback:l,onOpenAttachmentPreview:u,onRespondToApproval:d,interactionRecords:x,onRespondToAguiApproval:f,onSubmitFeedback:p,onSubmitAguiAction:m})},t.item.id||t.index))}),s&&(0,k.jsx)(`div`,{className:`mx-auto w-full max-w-[60rem] px-2 sm:px-4`,role:`status`,"data-testid":`waiting-first-token`,children:(0,k.jsx)(`span`,{className:`waiting-thinking-text`,children:`正在思考…`})})]})}),(0,k.jsx)(fJ,{}),le?(0,k.jsx)(`button`,{type:`button`,"aria-label":`回到底部`,"data-distance-from-bottom":Math.round(O),onClick:()=>{if(_){_();return}let e=S.current;e&&e.scrollTo({top:e.scrollHeight,behavior:`auto`})},className:`sticky bottom-4 left-1/2 z-20 mx-auto flex h-9 w-9 -translate-x-1/2 items-center justify-center rounded-full border border-border bg-surface text-text-secondary shadow-[0_8px_24px_rgba(15,23,42,0.12)] transition hover:text-text-primary`,title:`回到底部`,children:r?(0,k.jsx)(`span`,{"aria-hidden":`true`,className:`flex items-center gap-0.5`,"data-scroll-indicator":`streaming`,children:[0,1,2].map(e=>(0,k.jsx)(`span`,{className:`h-1 w-1 animate-bounce rounded-full bg-current motion-reduce:animate-none`,style:{animationDelay:`${e*120}ms`}},e))}):(0,k.jsx)(cN,{"aria-hidden":`true`,className:`h-5 w-5`,"data-scroll-indicator":`idle`})}):null]})}var PJ=CR,FJ=wR,IJ=v.forwardRef(({className:e,...t},n)=>(0,k.jsx)(TR,{ref:n,className:K(`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}));IJ.displayName=TR.displayName;var LJ=v.forwardRef(({className:e,children:t,...n},r)=>(0,k.jsxs)(FJ,{children:[(0,k.jsx)(IJ,{}),(0,k.jsxs)(ER,{ref:r,className:K(`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,k.jsxs)(kR,{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,k.jsx)(jN,{className:`h-4 w-4`}),(0,k.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}));LJ.displayName=ER.displayName;var RJ=({className:e,...t})=>(0,k.jsx)(`div`,{className:K(`flex flex-col space-y-1.5 text-center sm:text-left`,e),...t});RJ.displayName=`DialogHeader`;var zJ=({className:e,...t})=>(0,k.jsx)(`div`,{className:K(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});zJ.displayName=`DialogFooter`;var BJ=v.forwardRef(({className:e,...t},n)=>(0,k.jsx)(DR,{ref:n,className:K(`text-lg font-semibold leading-none tracking-tight`,e),...t}));BJ.displayName=DR.displayName;var VJ=v.forwardRef(({className:e,...t},n)=>(0,k.jsx)(OR,{ref:n,className:K(`text-sm text-muted-foreground`,e),...t}));VJ.displayName=OR.displayName;function HJ(e,t){if(!(!t||e))return{width:`min(${t.width}px, calc(100vw - 5rem))`,height:`min(${t.height}px, calc(100vh - 9rem))`}}function UJ(e,t){if(!(!t||e))return{width:`min(${t.width+32}px, calc(100vw - 3rem))`}}function WJ({attachment:e,isMobile:t,previewImageSize:n,onClose:r,onImageLoad:i}){return(0,k.jsx)(PJ,{open:!!e?.url,onOpenChange:e=>!e&&r(),children:(0,k.jsxs)(LJ,{className:K(`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:UJ(t,n),children:[(0,k.jsx)(`div`,{className:`flex items-center gap-3 border-b border-slate-800 px-4 py-3 pr-16`,children:(0,k.jsx)(BJ,{className:`truncate text-sm font-medium`,children:e?.name||`附件预览`})}),(0,k.jsx)(`div`,{className:K(`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,k.jsx)(`img`,{src:e.url,alt:e.name,className:K(`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:HJ(t,n),onLoad:e=>{let t=e.currentTarget;i({width:t.naturalWidth,height:t.naturalHeight})}}):(0,k.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 GJ(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 KJ(e){return e?GJ(e.context_window_tokens)??GJ(e?.limits?.context_window_tokens):null}function qJ(e){return e?GJ(e.auto_compact_threshold_percentage)??84:84}function JJ({selectedModel:e,contextUsage:t}){let n=t&&(!t.model||t.model===e?.id)?t:null,r=GJ(n?.used_tokens),i=GJ(n?.context_window_tokens),a=i??KJ(e),o={contextWindowTokens:a??void 0,contextWindowSource:a?i?`runtime`:`model`:void 0},s=n?.source===`last_request`?`上次请求输入`:`上下文占用`;if(!r)return{label:`上下文用量暂不可用`,phase:`default`,...o};let c=a?Math.round(r/a*100):void 0;return{label:s,phase:c!==void 0&&c>=qJ(e)?`warning`:`normal`,percent:c,usedTokens:r,...o}}function YJ(e){return e.requestedSessionId===e.activeSessionId&&e.requestToken===e.activeRequestToken}function XJ({agentName:e,emptyState:t,isMobile:n,onDeleteFeedback:r,onSubmitFeedback:i,onRespondToApproval:a,onRespondToAguiApproval:o,onSubmitAguiAction:s,onStopGeneration:c,onCancelRemote:l,checkpointResumeEnabled:u=!1,onResumeCheckpoint:d,onLoadOlderSessionMessages:f,interactionRecords:p,className:m,revealMessage:h}){let g=el(e=>e.messages),_=D(e=>e.currentSessionId),y=D(e=>e.isLoadingSessions),b=nt(e=>e.isSessionStreaming(_)),x=nt(e=>e.getSessionActivity(_)),S=xj(e=>e.getSessionCheckpoints(_)),C=D(e=>_?e.messageHistory[_]:null),w=y||!!C?.isLoadingInitial,T=D(e=>e.sessions.find(e=>e.SessionId===_)?.ContextUsage),ee=Ue(e=>e.availableModels),te=Ue(e=>e.selectedModel),E=_e(e=>e.previewAttachment),ne=_e(e=>e.previewImageSize),re=(0,v.useRef)(null),ie=(0,v.useRef)(!0),ae=(0,v.useRef)(!1),oe=(0,v.useRef)(0),se=(0,v.useRef)(b),ce=(0,v.useRef)(!1),O=(0,v.useRef)(null),le=(0,v.useRef)(!0),ue=(0,v.useRef)(``),de=(0,v.useRef)(h);(0,v.useEffect)(()=>{de.current=h});let fe=(0,v.useMemo)(()=>ee.find(e=>e.id===te)||null,[ee,te]),pe=(0,v.useMemo)(()=>JJ({selectedModel:fe,contextUsage:T}),[fe,T]),me=g.reduce((e,t,n)=>t.role===`user`?n:e,-1),he=b&&!g.slice(me+1).some(e=>!!(e.role===`model`&&(e.content||e.reasoning||e.blocks?.some(e=>e.type===`text`||e.type===`thinking`?e.content:!0)||e.attachments?.length||e.a2ui||e.aguiActivity||e.aguiActivities?.length||Object.keys(e.tools||{}).length))),ge=(0,v.useCallback)(()=>{let e=re.current;if(!e)return;ie.current=!0,ae.current=!1;let t=e.style.scrollBehavior;e.style.scrollBehavior=`auto`;let n=0,r=0,i=-1,a=()=>{if(re.current===e){if(e.scrollTop=e.scrollHeight,oe.current=e.scrollTop,e.dispatchEvent(new Event(`scroll`)),r=e.scrollHeight===i?r+1:0,i=e.scrollHeight,n+=1,r>=3||n>=12){e.style.scrollBehavior=t;return}requestAnimationFrame(a)}};a()},[]);return(0,v.useEffect)(()=>{se.current=b},[b]),(0,v.useEffect)(()=>{le.current=!0,ie.current=!0,ae.current=!1,oe.current=0,ce.current=!1,O.current=null,ue.current=``},[_]),(0,v.useEffect)(()=>{h&&(ie.current=!1,ae.current=!0,le.current=!1)},[h]),(0,v.useEffect)(()=>{let e=g.at(-1),t=ue.current;ue.current=String(e?.id||``),e?.role===`user`&&e.id!==t&&!le.current&&ge()},[g,ge]),(0,v.useEffect)(()=>{let e=re.current;if(!e)return;let t=()=>{let t=e.scrollHeight-e.scrollTop-e.clientHeight,n=e.scrollTop<oe.current-2;if(oe.current=e.scrollTop,!le.current&&n&&e.scrollTop<200&&_&&C?.hasMore&&!C.isLoadingOlder&&!ce.current&&f){let t=e.scrollHeight,n=_,r=Symbol(n);ce.current=!0,O.current=r,f(n).then(()=>{YJ({requestedSessionId:n,activeSessionId:D.getState().currentSessionId,requestToken:r,activeRequestToken:O.current})&&requestAnimationFrame(()=>{if(!YJ({requestedSessionId:n,activeSessionId:D.getState().currentSessionId,requestToken:r,activeRequestToken:O.current}))return;let e=re.current;if(!e)return;let i=e.scrollHeight-t;e.scrollTop+=i,oe.current=e.scrollTop})}).finally(()=>{O.current===r&&(O.current=null,ce.current=!1)})}if(se.current&&n){ae.current=!0,ie.current=!1;return}if(ae.current){let e=t<=12;ae.current=!e,ie.current=e;return}ie.current=t<96};return t(),e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[C,_,f]),(0,v.useEffect)(()=>{let e=re.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{!le.current&&!ie.current||(e.scrollTop=e.scrollHeight,oe.current=e.scrollTop,e.dispatchEvent(new Event(`scroll`)))});return t.observe(e),e.firstElementChild instanceof HTMLElement&&t.observe(e.firstElementChild),()=>t.disconnect()},[_]),(0,v.useEffect)(()=>{let e=re.current;if(e){if(g.length>0&&le.current){let e=de.current,t=D.getState().currentSessionId,n=re.current,r=n?n.style.scrollBehavior:``;n&&(n.style.scrollBehavior=`auto`,n.scrollTop=n.scrollHeight,oe.current=n.scrollTop);let i=0,a=n?.scrollHeight??-1,o=!1,s=0,c=()=>{let e=re.current;e&&(e.scrollTop=e.scrollHeight,oe.current=e.scrollTop,e.dispatchEvent(new Event(`scroll`)))},l=()=>{if(!o){if(o=!0,de.current!==e){n&&(n.style.scrollBehavior=r);return}c(),n&&(n.style.scrollBehavior=r),ie.current=!0,ae.current=!1,le.current=!1}},u=()=>{if(o)return;if(de.current!==e){l();return}if(D.getState().currentSessionId!==t){o=!0;return}let n=re.current;if(n){if(n.scrollHeight!==a)a=n.scrollHeight,c(),i=0;else if(i+=1,i>=3){l();return}s=requestAnimationFrame(u)}},d=window.setTimeout(l,2e3);return s=requestAnimationFrame(u),()=>{if(cancelAnimationFrame(s),window.clearTimeout(d),D.getState().currentSessionId!==t){l();return}n&&(n.style.scrollBehavior=r)}}ie.current&&(e.scrollTop=e.scrollHeight,oe.current=e.scrollTop)}},[g,b,h]),(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(NJ,{revealMessage:h,emptyState:t,agentName:e,isMobile:n,isStreaming:b,activity:x,contextIndicator:pe,messages:g,showWaitingIndicator:he,isLoadingInitialHistory:w,onDeleteFeedback:r,onOpenAttachmentPreview:e=>{_e.getState().setPreviewAttachment(e),_e.getState().setPreviewImageSize(null)},onRespondToApproval:a,onRespondToAguiApproval:o,interactionRecords:p,onScrollToBottom:ge,onSubmitFeedback:i,onSubmitAguiAction:s,onStopGeneration:c,onCancelRemote:l,checkpoints:u?S:[],onResumeCheckpoint:d,scrollRef:re,className:m}),(0,k.jsx)(WJ,{attachment:E,isMobile:n,previewImageSize:ne,onClose:()=>{_e.getState().setPreviewAttachment(null),_e.getState().setPreviewImageSize(null)},onImageLoad:e=>_e.getState().setPreviewImageSize(e)})]})}function ZJ({indicator:e,onCompact:t,disabled:n}){let r=(0,v.useRef)(null),[i,a]=(0,v.useState)(!1),o=(0,v.useRef)(!1);(0,v.useEffect)(()=>{if(!i)return;let e=e=>{e.target instanceof Node&&!r.current?.contains(e.target)&&(o.current=!1,a(!1))},t=e=>{e.key===`Escape`&&(o.current=!1,a(!1),r.current?.querySelector(`button`)?.focus())};return document.addEventListener(`pointerdown`,e,!0),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e,!0),document.removeEventListener(`keydown`,t)}},[i]);let[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(``),d=typeof e.usedTokens==`number`&&Number.isFinite(e.usedTokens)&&e.usedTokens>=0,f=d&&typeof e.percent==`number`&&Number.isFinite(e.percent)?Math.max(0,Math.min(100,e.percent)):void 0,p=async()=>{if(!(!t||s||n)){c(!0),u(``);try{await t(),u(`上下文已压缩`)}catch(e){u(e instanceof Error?e.message:`压缩失败,请重试`)}finally{c(!1)}}};return(0,k.jsxs)(`div`,{ref:r,className:`relative flex h-8 w-8 items-center justify-center`,onPointerEnter:e=>{e.pointerType!==`touch`&&a(!0)},onPointerLeave:()=>{o.current||a(!1)},children:[(0,k.jsx)(`button`,{type:`button`,"aria-label":`上下文用量与压缩`,"aria-expanded":i,onClick:()=>{o.current=!o.current,a(o.current),u(``)},className:K(`flex h-8 w-8 items-center justify-center rounded-full`,e.phase===`warning`?`text-text-primary`:`text-text-muted`),children:(0,k.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,className:s?`animate-pulse`:void 0,style:{display:`block`,flexShrink:0},children:[(0,k.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`,fill:`none`,stroke:`var(--ksadk-menu-border, #b8bcb5)`,strokeWidth:`2`}),f!==void 0&&(0,k.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,pathLength:`100`,strokeDasharray:`${f} 100`,transform:`rotate(-90 8 8)`})]})}),(0,k.jsxs)(`div`,{style:{background:`var(--ksadk-menu-background, hsl(var(--popover)))`,borderColor:`var(--ksadk-menu-border, hsl(var(--border)))`,boxShadow:`var(--ksadk-menu-shadow, 0 18px 44px rgba(15, 23, 42, 0.16))`},role:i?`dialog`:void 0,"aria-label":i?`上下文`:void 0,className:K(`absolute bottom-full right-0 z-30 w-60 rounded-xl border border-border bg-background p-4 text-sm text-foreground shadow-lg`,i?`block`:`hidden`),children:[(0,k.jsx)(`p`,{className:K(`font-medium`,s&&`waiting-thinking-text`),children:s?`正在压缩上下文…`:d?e.label:`上下文用量暂不可用`}),d&&(0,k.jsxs)(`p`,{className:`mt-1 text-text-secondary`,children:[`${QJ(e.usedTokens)} tokens`,e.contextWindowTokens?` / ${QJ(e.contextWindowTokens)}`:``]}),e.contextWindowTokens&&(0,k.jsxs)(`p`,{className:`mt-1 text-text-muted`,children:[`模型窗口:`,QJ(e.contextWindowTokens),` tokens`]}),d&&!e.contextWindowTokens&&(0,k.jsx)(`p`,{className:`mt-1 text-text-muted`,children:`模型窗口大小未报告`}),f!==void 0&&(0,k.jsxs)(`p`,{className:`text-text-muted`,children:[f,`% 已使用`]}),i&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>void p(),disabled:!t||s||n,className:`mt-3 w-full rounded-lg border border-border bg-muted px-3 py-2 disabled:opacity-50`,children:s?`正在压缩…`:`压缩上下文`}),(0,k.jsx)(`p`,{className:`mt-2 text-xs text-text-muted`,children:n?`请等待当前运行结束`:t?`压缩模型上下文,保留聊天记录`:`当前会话尚不支持手动压缩`}),l&&(0,k.jsx)(`p`,{role:`status`,className:`mt-2 text-xs`,children:l})]})]})]})}function QJ(e){return new Intl.NumberFormat(`zh-CN`).format(e)}var $J=[{value:`plan`,label:`计划模式`,description:`先分析并形成可执行计划`,icon:Ine},{value:`goal`,label:`设定目标`,description:`朝可验证的停止条件持续推进`,icon:Xne}],eY={plan:`计划模式`,goal:`目标`};function tY({attachmentsEnabled:e,mode:t,support:n,onSelectMode:r,onUpload:i}){let[a,o]=(0,v.useState)(!1),s=(0,v.useRef)(null),c=$J.filter(e=>n[e.value]);return(0,v.useEffect)(()=>{if(!a)return;let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)},t=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[a]),!e&&c.length===0?null:(0,k.jsxs)(`div`,{ref:s,className:`relative flex min-w-0 items-center gap-1`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-xl text-text-secondary transition hover:bg-muted hover:text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/25`,"aria-expanded":a,"aria-haspopup":`menu`,"aria-label":`添加附件或选择执行模式`,title:`添加附件或选择执行模式`,children:(0,k.jsx)(CN,{className:`h-[19px] w-[19px]`})}),t?(0,k.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:K(`flex h-8 max-w-[8.5rem] items-center gap-1 rounded-xl px-2 text-[12px] transition`,t===`goal`?`bg-neutral-50 text-neutral-700 hover:bg-neutral-100 dark:bg-neutral-950/40 dark:text-neutral-300`:`text-text-secondary hover:bg-muted hover:text-text-primary`),"aria-label":`当前执行模式:${eY[t]}`,children:[(0,k.jsx)(`span`,{className:`truncate`,children:eY[t]}),(0,k.jsx)(cN,{className:`h-3.5 w-3.5 shrink-0`})]}):null,a?(0,k.jsxs)(`div`,{role:`menu`,"aria-label":`附件与执行模式`,className:`absolute bottom-[calc(100%+0.6rem)] left-0 z-40 w-[min(18rem,calc(100vw-2rem))] rounded-xl border border-border/80 bg-popover p-1 shadow-[0_10px_24px_rgba(15,23,42,0.12)]`,style:{backgroundColor:`var(--ksadk-popover, #fff)`,borderColor:`var(--ksadk-border, rgba(15, 23, 42, 0.12))`},children:[e?(0,k.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{i(),o(!1)},className:`flex h-10 w-full items-center gap-2 rounded-lg px-2.5 text-left transition hover:bg-muted/70`,children:[(0,k.jsx)(AN,{className:`h-4 w-4 shrink-0 text-text-muted`}),(0,k.jsx)(`span`,{className:`shrink-0 text-[13px] font-medium text-text-primary`,children:`上传附件`}),(0,k.jsx)(`span`,{className:`ml-auto truncate text-[11px] text-text-muted`,children:`添加文件或图片`})]}):null,c.map(e=>{let n=e.icon,i=t===e.value;return(0,k.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":i,onClick:()=>{r(e.value),o(!1)},className:K(`flex h-10 w-full items-center gap-2 rounded-lg px-2.5 text-left transition`,i?`bg-muted`:`hover:bg-muted/70`),children:[(0,k.jsx)(n,{className:`h-4 w-4 shrink-0 text-text-muted`}),(0,k.jsx)(`span`,{className:`shrink-0 text-[13px] font-medium text-text-primary`,children:e.label}),(0,k.jsx)(`span`,{className:`ml-auto truncate text-[11px] text-text-muted`,children:e.description}),i?(0,k.jsx)(sN,{className:`h-4 w-4 shrink-0 text-text-primary`}):null]},e.value)})]}):null]})}var nY=[{value:`auto`,label:`自动`},{value:`enabled`,label:`开启`},{value:`disabled`,label:`关闭`}],rY={auto:`自动`,enabled:`开启`,disabled:`关闭`};function iY({availableModels:e,selectedModel:t,thinkingEnabled:n,thinkingMode:r,onSelectModel:i,onSelectThinkingMode:a}){let[o,s]=(0,v.useState)(!1),c=(0,v.useRef)(null),l=e.find(e=>e.id===t)?.display_name||t||`选择模型`;return(0,v.useEffect)(()=>{if(!o)return;let e=e=>{c.current&&!c.current.contains(e.target)&&s(!1)},t=e=>{e.key===`Escape`&&s(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[o]),(0,k.jsxs)(`div`,{ref:c,className:`relative`,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:`flex h-8 max-w-[15rem] items-center gap-1.5 rounded-xl px-3 text-[13px] text-text-primary transition hover:brightness-[0.98] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/25`,style:{background:`var(--ksadk-menu-trigger-background, hsl(var(--muted)))`},"aria-expanded":o,"aria-haspopup":`menu`,"aria-label":n?`模型 ${l},推理 ${rY[r]}`:`模型 ${l}`,title:n?`选择模型与推理设置`:`选择模型`,children:[(0,k.jsx)(`span`,{className:`min-w-0 truncate`,children:l}),n?(0,k.jsx)(`span`,{className:`shrink-0 text-text-muted`,children:rY[r]}):null,(0,k.jsx)(cN,{className:K(`h-3.5 w-3.5 shrink-0 text-text-muted transition-transform`,o&&`rotate-180`)})]}),o?(0,k.jsxs)(`div`,{role:`menu`,"aria-label":`选择模型`,className:`absolute bottom-[calc(100%+0.65rem)] right-0 z-40 w-[min(17rem,calc(100vw-2rem))] overflow-hidden rounded-2xl border p-1.5`,style:{background:`var(--ksadk-menu-background, hsl(var(--popover)))`,borderColor:`var(--ksadk-menu-border, hsl(var(--border)))`,boxShadow:`var(--ksadk-menu-shadow, 0 18px 44px rgba(15, 23, 42, 0.16))`},children:[(0,k.jsx)(`div`,{className:`px-2.5 pb-1.5 pt-1 text-[11px] font-medium text-text-muted`,children:`模型`}),(0,k.jsx)(`div`,{className:`max-h-[min(45vh,18rem)] overflow-y-auto`,children:e.map(e=>{let n=e.id===t;return(0,k.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":n,onClick:()=>{i(e.id),s(!1)},className:K(`flex w-full items-center gap-2 rounded-xl px-2.5 py-2 text-left text-[13px] transition-colors`,n?`bg-muted text-text-primary`:`text-text-secondary hover:bg-muted hover:text-text-primary`),children:[(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.display_name||e.id}),n?(0,k.jsx)(sN,{className:`h-4 w-4 shrink-0`,"aria-hidden":`true`}):null]},e.id)})}),n?(0,k.jsx)(`div`,{className:`mt-1 border-t border-border px-1 pt-1.5`,children:(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-1.5 pb-1`,children:[(0,k.jsx)(`span`,{className:`text-[11px] font-medium text-text-muted`,children:`推理`}),(0,k.jsx)(`div`,{className:`flex rounded-lg bg-muted p-0.5`,children:nY.map(e=>(0,k.jsx)(`button`,{type:`button`,onClick:()=>a(e.value),className:K(`rounded-md px-2 py-1 text-[11px] transition-colors`,e.value===r?`bg-card text-text-primary shadow-sm`:`text-text-muted hover:text-text-primary`),children:e.label},e.value))})]})}):null]}):null]})}var aY=[{value:`ask`,label:`请求批准`,description:`Agent 请求授权时确认`,icon:vN},{value:`risk`,label:`风险操作需确认`,description:`仅副作用操作`,icon:DN},{value:`full`,label:`完全访问`,description:`不再确认`,icon:EN}],oY={ask:`请求批准`,risk:`风险确认`,full:`完全访问`};function sY({approvalPolicy:e}){let[t,n]=(0,v.useState)(!1),r=(0,v.useRef)(null),i=de(e=>e.permissionMode),a=de(e=>e.setPermissionMode),o=i===`ask`?vN:i===`full`?EN:DN,s=(0,v.useMemo)(()=>aY.filter(t=>!e||e.Modes.includes(t.value)),[e]);return(0,v.useEffect)(()=>{s.some(e=>e.value===i)||a(e?.DefaultMode||s[0]?.value||`risk`)},[e?.DefaultMode,i,a,s]),(0,v.useEffect)(()=>{if(!t)return;let e=e=>{r.current&&!r.current.contains(e.target)&&n(!1)},i=e=>{e.key===`Escape`&&n(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,i)}},[t]),(0,k.jsxs)(`div`,{ref:r,className:`relative`,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),className:K(`flex h-8 items-center gap-1.5 rounded-xl px-2.5 text-[13px] transition hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/25`,i===`full`?`text-amber-600 dark:text-amber-400`:`text-text-secondary hover:text-text-primary`),"aria-expanded":t,"aria-haspopup":`menu`,title:`设置本次会话的工具审批规则`,children:[(0,k.jsx)(o,{className:`h-3.5 w-3.5`}),(0,k.jsx)(`span`,{children:oY[i]}),(0,k.jsx)(cN,{className:K(`h-3.5 w-3.5 transition-transform`,t&&`rotate-180`)})]}),t?(0,k.jsx)(`div`,{role:`menu`,"aria-label":`工具权限`,className:`absolute bottom-[calc(100%+0.6rem)] left-0 z-30 w-[18rem] rounded-xl border border-border/80 bg-popover p-1 shadow-[0_10px_24px_rgba(15,23,42,0.12)]`,style:{backgroundColor:`var(--ksadk-popover, #fff)`,borderColor:`var(--ksadk-border, rgba(15, 23, 42, 0.12))`},children:s.map(e=>{let t=e.icon,r=e.value===i;return(0,k.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":r,onClick:()=>{a(e.value),n(!1)},className:K(`flex h-10 w-full items-center gap-2 rounded-lg px-2.5 text-left transition-colors`,r?`bg-primary/[0.08]`:`hover:bg-muted/75`),children:[(0,k.jsx)(t,{className:K(`h-4 w-4 shrink-0`,r?`text-primary`:`text-text-muted`)}),(0,k.jsx)(`span`,{className:K(`shrink-0 text-[13px] font-medium`,r?`text-text-primary`:`text-text-secondary`),children:e.label}),(0,k.jsx)(`span`,{className:`ml-auto truncate text-[11px] text-text-muted`,children:e.description}),r?(0,k.jsx)(sN,{className:`h-4 w-4 shrink-0 text-primary`,"aria-hidden":`true`}):null]},e.value)})}):null]})}function cY({headerSlot:e,onCompactContext:t,attachments:n,composerContextIndicator:r,composerMaxHeight:i,fileInputRef:a,input:o,isMobile:s,isStreaming:c,attachmentsEnabled:l=!0,approvalEnabled:u=!1,approvalPolicy:d,thinkingEnabled:f=!1,executionMode:p,executionModeSupport:m,queuedDrafts:h,onAppendAttachments:g,onInputChange:_,onSelectExecutionMode:y,onPaste:b,onRemoveAttachment:x,onStopGeneration:S,onCancelRemote:C,onSubmit:w,textareaRef:T,className:ee}){let[te,E]=(0,v.useState)(!1),ne=t?async()=>{E(!0);try{await t()}finally{E(!1)}}:void 0,re=p===`goal`?`描述需要持续完成的目标…`:p===`plan`?`描述需要先规划的任务…`:s?`发送消息...`:`发送消息…`,ie=C?`保留恢复点并结束本次执行`:`停止生成`,ae=p===`goal`?!!o.trim():!!(o.trim()||n.length>0),oe=Ue(e=>e.availableModels),se=Ue(e=>e.selectedModel),ce=Ue(e=>e.thinkingMode),D=Ue(e=>e.setSelectedModel),O=Ue(e=>e.setThinkingMode),le=e=>e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`;return(0,k.jsx)(`div`,{className:K(`relative z-10 flex-shrink-0 bg-background/95 px-3 py-3 backdrop-blur sm:px-4 sm:py-3`,ee),"data-slot":`composer`,children:(0,k.jsxs)(`div`,{className:`mx-auto w-full max-w-[64rem]`,children:[te&&(0,k.jsxs)(`div`,{role:`status`,className:`mb-3 flex items-center gap-2 px-2 text-sm text-text-muted`,children:[(0,k.jsx)(gN,{size:16,"aria-hidden":`true`}),(0,k.jsx)(`span`,{className:`waiting-thinking-text`,children:`正在压缩上下文`})]}),h.length>0?(0,k.jsxs)(`div`,{className:`mb-2 rounded-2xl border border-neutral-200/80 bg-neutral-50/80 px-3 py-2 text-xs text-neutral-900 shadow-sm dark:border-neutral-900/60 dark:bg-neutral-950/30 dark:text-neutral-100`,children:[(0,k.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between gap-2`,children:[(0,k.jsxs)(`span`,{className:`font-semibold`,children:[`发送队列 · `,h.length]}),(0,k.jsx)(`span`,{className:`text-neutral-700/75 dark:text-neutral-200/75`,children:`当前回复完成后依次发送`})]}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[h.slice(0,3).map((e,t)=>{let n=e.text.trim()||(e.attachments.length>0?`仅附件消息`:`空消息`);return(0,k.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-background/70 px-2 py-1.5`,children:[(0,k.jsx)(`span`,{className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-full bg-neutral-100 font-mono text-[10px] text-neutral-700 dark:bg-neutral-900/50 dark:text-neutral-100`,children:t+1}),(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-text-secondary`,children:n}),e.attachments.length>0?(0,k.jsxs)(`span`,{className:`flex-shrink-0 rounded-full bg-neutral-100 px-2 py-0.5 text-[10px] text-neutral-700 dark:bg-neutral-900/50 dark:text-neutral-100`,children:[e.attachments.length,` 附件`]}):null]},`${t}-${n}-${e.attachments.length}`)}),h.length>3?(0,k.jsxs)(`div`,{className:`px-2 pt-0.5 text-[11px] text-neutral-700/80 dark:text-neutral-200/80`,children:[`还有 `,h.length-3,` 条等待发送`]}):null]})]}):null,(0,k.jsx)(`div`,{"data-slot":`composer-surface`,className:`relative rounded-[var(--chat-composer-radius,28px)] bg-surface shadow-[0_0_0_0.5px_rgba(15,23,42,0.08),0_5px_18px_rgba(15,23,42,0.07)] dark:shadow-[0_0_0_0.5px_rgba(255,255,255,0.06),0_8px_24px_rgba(0,0,0,0.24)]`,children:(0,k.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,k.jsxs)(`form`,{"data-slot":`composer-form`,onSubmit:e=>{if(e.preventDefault(),te)return;if(c){C?C():S();return}let t=o.trim();ae&&w(t,n)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:e=>{e.preventDefault(),e.stopPropagation(),l&&e.dataTransfer.files&&e.dataTransfer.files.length>0&&g(Array.from(e.dataTransfer.files))},className:`relative flex min-h-[116px] min-w-0 flex-1 flex-col rounded-[var(--chat-composer-radius,28px)] border border-border/55 bg-background px-4 pb-3 pt-3 transition-all focus-within:border-primary/40 focus-within:ring-2 focus-within:ring-primary/15 sm:px-5`,children:[e==null?null:(0,k.jsx)(`div`,{"data-slot":`composer-header`,className:`mb-2 min-w-0`,children:e}),n.length>0?(0,k.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-2`,children:n.map((e,t)=>(0,k.jsxs)(`div`,{className:K(`group relative flex items-center gap-2 rounded-xl border border-border bg-background px-3 py-2 text-xs`,s?`max-w-full`:`max-w-[14rem]`),children:[(0,k.jsx)(`span`,{className:`flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-lg bg-muted text-text-muted`,children:(0,k.jsx)(SN,{className:`h-3.5 w-3.5`})}),(0,k.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(`span`,{className:`block truncate font-medium text-text-primary`,children:e.name}),(0,k.jsx)(`span`,{className:`block text-[10px] text-text-muted`,children:le(e.size)})]}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>x(t),className:`absolute -right-1.5 -top-1.5 flex h-4 w-4 items-center justify-center rounded-full border border-border bg-background text-text-muted shadow-sm transition hover:text-rose-500`,"aria-label":`移除附件 ${e.name}`,children:(0,k.jsx)(`span`,{className:`text-[11px] leading-none`,children:`×`})})]},`${e.name}-${e.size}-${t}`))}):null,(0,k.jsx)(`textarea`,{"data-slot":`composer-input`,ref:T,rows:1,value:o,onChange:_,onKeyDown:e=>{if(e.key===`Enter`&&!e.shiftKey){if(e.nativeEvent.isComposing||e.nativeEvent.keyCode===229)return;if(e.preventDefault(),c){!te&&ae&&w(o.trim(),n);return}e.currentTarget.form?.requestSubmit()}},onPaste:b,placeholder:re,className:K(`custom-scrollbar max-h-[176px] min-h-[62px] w-full resize-none overflow-y-auto border-0 bg-transparent px-0 pb-1 pt-1 text-[15px] leading-6 text-text-primary outline-none placeholder:text-text-muted/60`,s?`text-[16px]`:`text-[14px]`),style:{maxHeight:`${i}px`,overflowY:`auto`}}),(0,k.jsxs)(`div`,{"data-slot":`composer-toolbar`,className:`mt-auto flex min-h-8 items-center justify-between gap-2 pt-1.5`,children:[(0,k.jsxs)(`div`,{"data-slot":`composer-toolbar-start`,className:`flex min-w-0 items-center gap-1.5`,children:[(0,k.jsx)(`input`,{ref:a,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&e.target.files.length>0&&(g(Array.from(e.target.files)),e.target.value=``)}}),(0,k.jsx)(tY,{attachmentsEnabled:l,mode:p,support:m,onSelectMode:y,onUpload:()=>a.current?.click()}),u?(0,k.jsx)(sY,{approvalPolicy:d}):null]}),(0,k.jsxs)(`div`,{"data-slot":`composer-toolbar-end`,className:`flex min-w-0 items-center gap-1.5`,children:[r?(0,k.jsx)(ZJ,{indicator:r,onCompact:ne,disabled:c}):null,oe.length>0?(0,k.jsx)(iY,{availableModels:oe,selectedModel:se,thinkingEnabled:f,thinkingMode:ce,onSelectModel:D,onSelectThinkingMode:O}):null,(0,k.jsx)(`button`,{type:`submit`,disabled:te||!c&&!ae,className:K(`flex h-9 w-9 shrink-0 items-center justify-center rounded-full transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30`,c||ae?`bg-[#1f1f1f] text-white hover:opacity-80`:`bg-muted text-text-muted/45`),title:c?ie:`发送消息`,children:c?(0,k.jsx)(Yne,{className:`h-3.5 w-3.5 fill-current`}):(0,k.jsx)(aN,{className:`h-[18px] w-[18px]`})})]})]})]})})})]})})}function lY(e){return[e.name,e.size,e.lastModified,e.type].join(`:`)}function uY(e,t){let n=new Map;for(let t of e)n.set(lY(t),t);for(let e of t)n.set(lY(e),e);return Array.from(n.values())}function dY(e){return Array.from(e.clipboardData.items||[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>!!e)}function fY({draftKey:e,draftStore:t,headerSlot:n,onCompactContext:r,composerMaxHeight:i,submitDraft:a,stopGeneration:o,cancelRemote:s,isMobile:c,attachmentsEnabled:l=!0,approvalEnabled:u=!1,approvalPolicy:d,thinkingEnabled:f=!1,runtimeCapabilityMatrix:p,pendingInteractions:m,onRespondInteraction:h,localCatalog:g,className:_}){let[y,b]=(0,v.useState)(0),[x,S]=(0,v.useState)(),C=_e(e=>e.input),w=_e(e=>e.attachments),T=D(e=>e.currentSessionId),ee=nt(t=>t.isSessionStreaming(T||e)),te=_e(e=>e.queuedDrafts),E=D(e=>e.sessions.find(e=>e.SessionId===T)?.ContextUsage),ne=Ue(e=>e.availableModels),re=Ue(e=>e.selectedModel),ie=Ue(e=>e.setThinkingMode),ae=(0,v.useRef)(null),oe=(0,v.useRef)(null),[se]=(0,v.useState)(()=>new Pk),ce=t||se,O=(0,v.useRef)(void 0);(0,v.useLayoutEffect)(()=>{if(!e)return;let t=O.current!==e;O.current=e;let n=ce.get(e),r=_e.getState().input;if(!(!t&&r.trim()))return _e.setState({input:n.text,attachments:n.attachments}),_e.subscribe((t,n)=>{(t.input!==n.input||t.attachments!==n.attachments)&&ce.set(e,t.input,t.attachments)})},[e,ce]),(0,v.useEffect)(()=>!e||!t?void 0:ce.subscribe(()=>{if(ce.getConflict(e))return;let t=ce.get(e),n=_e.getState(),r=t.attachments.length===n.attachments.length&&t.attachments.every((e,t)=>e===n.attachments[t]);(t.text!==n.input||!r)&&_e.setState({input:t.text,attachments:t.attachments})}),[e,t,ce]);let le=(0,v.useMemo)(()=>ne.find(e=>e.id===re)||null,[ne,re]),ue=(0,v.useMemo)(()=>JJ({selectedModel:le,contextUsage:E}),[le,E]),de=(0,v.useMemo)(()=>({plan:!!p?.plan?.supported,goal:!!p?.goal?.supported}),[p]),fe=x&&de[x]?x:void 0,pe=(0,v.useCallback)((e,t)=>{!e&&t.length===0||(_e.getState().setInput(``),_e.getState().setAttachments([]),a(e,t,void 0,void 0,fe),fe===`goal`&&S(void 0))},[fe,a]);(0,v.useEffect)(()=>{oe.current&&(oe.current.style.height=`auto`,oe.current.style.height=`${Math.min(oe.current.scrollHeight,i)}px`)},[C,i]);let me=e=>{_e.getState().setInput(e.target.value),e.target.style.height=`auto`,e.target.style.height=`${Math.min(e.target.scrollHeight,i)}px`},he=e=>{!l||!e.length||_e.getState().setAttachments(t=>uY(t,e))},ge=e=>{if(!l)return;let t=dY(e);t.length&&(e.preventDefault(),e.stopPropagation(),he(t))},ve=m||[],ye=Math.min(y,Math.max(ve.length-1,0));return(0,v.useEffect)(()=>{f||ie(`auto`)},[ie,f]),(0,k.jsxs)(`div`,{className:`flex w-full flex-col justify-center`,children:[ve.length>0&&h?(0,k.jsx)(Yq,{interactions:ve,activeIndex:ye,onSelectIndex:b,onRespond:h,localCatalog:g}):null,(0,k.jsx)(cY,{headerSlot:n,onCompactContext:T?r:void 0,attachments:w,composerContextIndicator:ue,composerMaxHeight:i,fileInputRef:ae,input:C,isMobile:c,isStreaming:ee,attachmentsEnabled:l,approvalEnabled:u,approvalPolicy:d,thinkingEnabled:f,executionMode:fe,executionModeSupport:de,queuedDrafts:te,onAppendAttachments:he,onInputChange:me,onSelectExecutionMode:S,onPaste:ge,onRemoveAttachment:e=>_e.getState().setAttachments(t=>t.filter((t,n)=>n!==e)),onStopGeneration:o,onCancelRemote:s,onSubmit:pe,textareaRef:oe,className:_})]})}var pY=(0,v.lazy)(()=>J(()=>import(`./NativeTerminalPanel-oJj44_sV.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function mY({availableModels:e,selectedModel:t,onSelectModel:n,selectedModelLabel:r,modelCatalogLoaded:i,modelSource:a,thinkingEnabled:o,thinkingMode:s,onSelectThinkingMode:c,compact:l=!1}){let u=K(`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,k.jsx)(`select`,{value:t,onChange:e=>n(e.target.value),className:u,children:e.map(e=>(0,k.jsx)(`option`,{value:e.id,children:e.display_name||e.id},e.id))}):r?(0,k.jsx)(`span`,{className:K(u,`inline-flex max-w-full items-center`,l?`justify-start`:``),title:a||r,children:(0,k.jsx)(`span`,{className:`truncate`,children:r})}):(0,k.jsx)(`span`,{className:`text-sm text-slate-400`,children:i?`未配置模型`:`Loading models...`}),f=o?(0,k.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),className:K(u,l?``:`max-w-[9rem]`),title:`控制模型 thinking/reasoning 参数`,children:[(0,k.jsx)(`option`,{value:`auto`,children:`思考自动`}),(0,k.jsx)(`option`,{value:`enabled`,children:`开启思考`}),(0,k.jsx)(`option`,{value:`disabled`,children:`关闭思考`})]}):null;return(0,k.jsxs)(`div`,{className:K(`flex min-w-0 gap-2`,l?`w-full flex-col`:`items-center`),children:[d,f]})}function hY({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:y,nativeManagementLink:b,nativeTerminal:x,nativeLauncherMode:S=!1}){let[C,w]=(0,v.useState)(!1),T=!!x?.Enabled,ee=n?i?(0,k.jsx)(bN,{className:`h-5 w-5`}):(0,k.jsx)(xN,{className:`h-5 w-5`}):r?(0,k.jsx)(bN,{className:`h-5 w-5`}):(0,k.jsx)(xN,{className:`h-5 w-5`});return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`header`,{className:K(`flex flex-shrink-0 items-center justify-between border-b border-black/[0.06] bg-background/95 px-3 py-2 backdrop-blur dark:border-white/[0.08] dark:bg-background/95 sm:px-4`,n?`pt-[calc(var(--safe-area-top)+0.5rem)]`:`h-12`),children:[(0,k.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[S?null:(0,k.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:ee}),(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100 sm:text-base`,children:e}),(0,k.jsx)(`div`,{className:`text-[11px] text-slate-400 dark:text-slate-500`,children:S?`原生运行时入口`:`智能体`})]})]}),n?(0,k.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,k.jsx)(Mne,{className:`h-5 w-5`})}):(0,k.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[b?(0,k.jsxs)(`a`,{href:b.href,target:`_blank`,rel:`noreferrer`,title:b.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,k.jsx)(mN,{className:`h-4 w-4`}),(0,k.jsx)(`span`,{children:b.label})]}):null,_?(0,k.jsxs)(`button`,{type:`button`,onClick:y,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,k.jsx)(_N,{className:`h-4 w-4`}),(0,k.jsx)(`span`,{children:`Workspace`})]}):null,T?(0,k.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,k.jsx)(ON,{className:`h-4 w-4`}),(0,k.jsx)(`span`,{children:`TUI`})]}):null,!S&&n?(0,k.jsx)(mY,{availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m,compact:!0}):null,!S&&t?(0,k.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,k.jsx)(NR,{open:h,onOpenChange:g,children:(0,k.jsxs)(LR,{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,k.jsxs)(RR,{className:`text-left`,children:[(0,k.jsx)(BR,{children:`会话设置`}),(0,k.jsx)(VR,{className:`sr-only`,children:`调整当前会话的模型和 Workspace 操作。`})]}),(0,k.jsxs)(`div`,{className:`mt-6 flex flex-col gap-4`,children:[_?(0,k.jsxs)(`button`,{type:`button`,onClick:()=>{g(!1),y()},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,k.jsx)(_N,{className:`h-4 w-4`}),`工作区文件`]}):null,T?(0,k.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,k.jsx)(ON,{className:`h-4 w-4`}),`原生 TUI`]}):null,b?(0,k.jsxs)(`a`,{href:b.href,target:`_blank`,rel:`noreferrer`,title:b.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,k.jsx)(mN,{className:`h-4 w-4`}),b.label]}):null,S?(0,k.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,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-slate-400 dark:text-slate-500`,children:`模型`}),(0,k.jsx)(mY,{availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m,compact:!0})]}),(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-slate-400 dark:text-slate-500`,children:`当前会话`}),(0,k.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,k.jsx)(`span`,{className:`break-all font-mono`,children:t}):`新对话尚未创建会话 ID`})]})]})]})]})}):null,x&&C?(0,k.jsx)(v.Suspense,{fallback:null,children:(0,k.jsx)(pY,{capability:x,open:C,sessionId:t,onClose:()=>w(!1)})}):null]})}var gY=(0,v.lazy)(()=>J(()=>import(`./NativeTerminalPanel-oJj44_sV.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function _Y({productLabel:e=`原生运行时`,nativeManagementLink:t,nativeTerminal:n,workspaceEnabled:r,onOpenWorkspace:i}){let a=!!n?.Enabled,[o,s]=(0,v.useState)(!1);return(0,k.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,k.jsx)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col justify-center`,children:(0,k.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,k.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,k.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,k.jsx)(DN,{className:`h-3.5 w-3.5`}),e,` native runtime`]}),(0,k.jsx)(`h1`,{className:`mt-5 text-2xl font-semibold tracking-tight text-slate-950 dark:text-slate-50 sm:text-3xl`,children:`对话请使用原生管理台`}),(0,k.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,k.jsxs)(`div`,{className:`grid gap-4 p-6 md:grid-cols-3 sm:p-8`,children:[(0,k.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,k.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,k.jsx)(Bne,{className:`h-5 w-5`})}),(0,k.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`原生管理台`}),(0,k.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`使用原生管理台处理对话、工具卡片、思考流、审批、中断和运行时历史,避免跨状态机不一致。`}),t?(0,k.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,k.jsx)(mN,{className:`h-4 w-4`}),`打开`,t.label]}):(0,k.jsx)(`div`,{className:`mt-5 rounded-2xl border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm leading-6 text-neutral-800 dark:border-neutral-900/60 dark:bg-neutral-950/30 dark:text-neutral-200`,children:`当前访问模式不开放原生管理入口。需要完整对话体验时,请使用 owner/private 链接或 CLI。`})]}),(0,k.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,k.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,k.jsx)(_N,{className:`h-5 w-5`})}),(0,k.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`Workspace 文件管理`}),(0,k.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`文件浏览、上传、预览仍由 Hosted UI 提供,和原生管理台组合使用覆盖对话与工作区。`}),r?(0,k.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,k.jsx)(_N,{className:`h-4 w-4`}),`打开 Workspace`]}):(0,k.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,k.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,k.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,k.jsx)(ON,{className:`h-5 w-5`})}),(0,k.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`原生 TUI`}),(0,k.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`如果运行时暴露安全的 ks-terminal.v1 通道,可以在这里进入原生终端 UI;share 链接不会开放该入口。`}),a?(0,k.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,k.jsx)(ON,{className:`h-4 w-4`}),`打开 TUI`]}):(0,k.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,k.jsx)(v.Suspense,{fallback:null,children:(0,k.jsx)(gY,{capability:n,open:o,onClose:()=>s(!1)})}):null]})}var vY=[],yY=[];(()=>{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?yY:vY).push(n+=e[t])})();function bY(e){if(e<768)return!1;for(let t=0,n=vY.length;;){let r=t+n>>1;if(e<vY[r])n=r;else if(e>=yY[r])t=r+1;else return!0;if(t==n)return!1}}function xY(e){return e>=127462&&e<=127487}var SY=8205;function CY(e,t,n=!0,r=!0){return(n?wY:TY)(e,t,r)}function wY(e,t,n){if(t==e.length)return t;t&&DY(e.charCodeAt(t))&&OY(e.charCodeAt(t-1))&&t--;let r=EY(e,t);for(t+=kY(r);t<e.length;){let i=EY(e,t);if(r==SY||i==SY||n&&bY(i))t+=kY(i),r=i;else if(xY(i)){let n=0,r=t-2;for(;r>=0&&xY(EY(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function TY(e,t,n){for(;t>0;){let r=wY(e,t-2,n);if(r<t)return r;t--}return 0}function EY(e,t){let n=e.charCodeAt(t);if(!OY(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return DY(r)?(n-55296<<10)+(r-56320)+65536:n}function DY(e){return e>=56320&&e<57344}function OY(e){return e>=55296&&e<56320}function kY(e){return e<65536?1:2}var AY=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]=BY(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),MY.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]=BY(this,e,t);let n=[];return this.decompose(e,t,n,0),MY.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 IY(this),i=new IY(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 IY(this,e)}iterRange(e,t=this.length){return new LY(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 RY(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 jY(t):MY.from(jY.split(t,[]))}},jY=class e extends AY{constructor(e,t=NY(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 zY(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(FY(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=PY(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]=BY(this,t,n);let i=PY(this.text,PY(r.text,FY(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):MY.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
|
|
201
201
|
`){[e,t]=BY(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}},MY=class e extends AY{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]=BY(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=`
|
|
202
202
|
`){[e,t]=BY(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 jY(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 jY&&c&&(n=u[u.length-1])instanceof jY&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new jY(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)}};AY.empty=new jY([``],0);function NY(e){let t=-1;for(let n of e)t+=n.length+1;return t}function PY(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 FY(e,t,n){return PY(e,[``],t,n)}var IY=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 jY?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 jY?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=`
|
|
203
203
|
`,this;e--}else if(r instanceof jY){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 jY?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)}},LY=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new IY(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!=``}},RY=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`&&(AY.prototype[Symbol.iterator]=function(){return this.iter()},IY.prototype[Symbol.iterator]=LY.prototype[Symbol.iterator]=RY.prototype[Symbol.iterator]=function(){return this});var zY=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 BY(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function VY(e,t,n=!0,r=!0){return CY(e,t,n,r)}function HY(e){return e>=56320&&e<57344}function UY(e){return e>=55296&&e<56320}function WY(e,t){let n=e.charCodeAt(t);if(!UY(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return HY(r)?(n-55296<<10)+(r-56320)+65536:n}function GY(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function KY(e){return e<65536?1:2}var qY=/\r\n?|\n/,JY=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(JY||={}),YY=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){$Y(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:tX(this,e)}mapDesc(e,t=!1){return e.empty?this:eX(this,e,t)}mapPos(e,t=-1,n=JY.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!=JY.Simple&&c>=e&&(n==JY.TrackDel&&r<e&&c>e||n==JY.TrackBefore&&r<e||n==JY.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)}},XY=class e extends YY{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 $Y(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return eX(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(AY.empty);r.push(a?t.slice(i,i+a):AY.empty)}i+=a}return new e(n,r)}compose(e){return this.empty?e:e.empty?this:tX(this,e,!0)}map(e,t=!1){return e.empty?this:eX(this,e,t,!0)}iterChanges(e,t=!1){$Y(this,e,t)}get desc(){return YY.create(this.sections)}filter(t){let n=[],r=[],i=[],a=new nX(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);ZY(i,e,-1);let t=a.ins==-1?-1:a.off==0?a.ins:0;ZY(n,e,t),t>0&&QY(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);ZY(n,e,-1),ZY(i,e,a.ins==-1?-1:a.off==0?a.ins:0),a.forward(e),o+=e}}return{changes:new e(n,r),filtered:YY.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&&ZY(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`?AY.of(l.split(r||qY)):l:AY.empty,d=u.length;if(e==s&&d==0)return;e<o&&c(),e>o&&ZY(i,e-o,-1),ZY(i,s-e,d),QY(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(AY.empty);r[e]=AY.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 ZY(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 QY(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(AY.empty);e.push(n)}}function $Y(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=AY.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 eX(e,t,n,r=!1){let i=[],a=r?[]:null,o=new nX(e),s=new nX(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);ZY(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(ZY(i,s.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(ZY(i,0,o.ins),a&&QY(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;ZY(i,t,e<o.i?o.ins:0),a&&e<o.i&&QY(a,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&s.done)return a?XY.createSet(i,a):YY.create(i);else throw Error(`Mismatched change set lengths`)}function tX(e,t,n=!1){let r=[],i=n?[]:null,a=new nX(e),o=new nX(t);for(let e=!1;;)if(a.done&&o.done)return i?XY.createSet(r,i):YY.create(r);else if(a.ins==0)ZY(r,a.len,0,e),a.next();else if(o.len==0&&!o.done)ZY(r,0,o.ins,e),i&&QY(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;ZY(r,t,n,e),i&&n&&QY(i,r,o.text)}else o.ins==-1?(ZY(r,a.off?0:a.len,t,e),i&&QY(i,r,a.textBit(t))):(ZY(r,a.off?0:a.len,o.off?0:o.ins,e),i&&!o.off&&QY(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 nX=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?AY.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?AY.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)}},rX=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 Y.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return Y.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 Y.range(e.anchor,e.head)}static create(t,n,r){return new e(t,n,r)}},Y=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=>rX.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 rX.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?rX.create(t,e,48|a):rX.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 iX(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var aX=0,oX=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=aX++,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:sX),!!t.static,t.enables)}of(e){return new cX([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new cX(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new cX(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function sX(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var cX=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=aX++}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)||uX(e,c)){let r=t(e);if(a?!lX(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=CX(o,c);if(this.dependencies.every(t=>t instanceof oX?o.facet(t)===e.facet(t):t instanceof pX?o.field(t,!1)==e.field(t,!1):!0)||(a?lX(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 lX(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 uX(e,t){let n=!1;for(let r of t)SX(e,r)&1&&(n=!0);return n}function dX(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=CX(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)SX(e,t);return e.values[o]=s(e),1},update(e,n){if(!uX(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=uX(e,r),c=i.config.facets[t.id],l=i.facet(t);if(c&&!a&&sX(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 fX=oX.define({static:!0}),pX=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(aX++,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(fX).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(fX),i=n.facet(fX),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,fX.of({field:this,create:e})]}get extension(){return this}},mX={lowest:4,low:3,default:2,high:1,highest:0};function hX(e){return t=>new _X(t,e)}var gX={highest:hX(mX.highest),high:hX(mX.high),default:hX(mX.default),low:hX(mX.low),lowest:hX(mX.lowest)},_X=class{constructor(e,t){this.inner=e,this.prec=t}},vX=class e{of(e){return new yX(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},yX=class{constructor(e,t){this.compartment=e,this.inner=t}},bX=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 xX(t,n,o))e instanceof pX?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,sX(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=>dX(e,n,t))}}return new e(t,o,l.map(e=>e(s)),s,c,a)}};function xX(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 yX&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof yX){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 _X)a(e.inner,e.prec);else if(e instanceof pX)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof cX)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,mX.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,mX.default),r.reduce((e,t)=>e.concat(t))}function SX(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 CX(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var wX=oX.define(),TX=oX.define({combine:e=>e.some(e=>e),static:!0}),EX=oX.define({combine:e=>e.length?e[0]:void 0,static:!0}),DX=oX.define(),OX=oX.define(),kX=oX.define(),AX=oX.define({combine:e=>e.length?e[0]:!1}),jX=class{constructor(e,t){this.type=e,this.value=t}static define(){return new MX}},MX=class{of(e){return new jX(this,e)}},NX=class{constructor(e){this.map=e}of(e){return new PX(this,e)}},PX=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 NX(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}};PX.reconfigure=PX.define(),PX.appendConfig=PX.define();var FX=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&&iX(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]==`.`))}};FX.time=jX.define(),FX.userEvent=jX.define(),FX.addToHistory=jX.define(),FX.remote=jX.define();function IX(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 LX(e,t,n){let r,i,a;return n?(r=t.changes,i=XY.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:PX.mapEffects(e.effects,r).concat(PX.mapEffects(t.effects,i)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function RX(e,t,n){let r=t.selection,i=UX(t.annotations);return t.userEvent&&(i=i.concat(FX.userEvent.of(t.userEvent))),{changes:t.changes instanceof XY?t.changes:XY.of(t.changes||[],n,e.facet(EX)),selection:r&&(r instanceof Y?r:Y.single(r.anchor,r.head)),effects:UX(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function zX(e,t,n){let r=RX(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=LX(r,RX(e,t[i],a?r.changes.newLength:e.doc.length),a)}let i=FX.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return VX(n?BX(i):i)}function BX(e){let t=e.startState,n=!0;for(let r of t.facet(DX)){let t=r(e);if(t===!1){n=!1;break}Array.isArray(t)&&(n=n===!0?t:IX(n,t))}if(n!==!0){let r,i;if(n===!1)i=e.changes.invertedDesc,r=XY.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=FX.create(t,r,e.selection&&e.selection.map(i),PX.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(OX);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof FX?i:Array.isArray(i)&&i.length==1&&i[0]instanceof FX?i[0]:zX(t,UX(i),!1)}return e}function VX(e){let t=e.startState,n=t.facet(kX),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=LX(r,RX(t,a,e.changes.newLength),!0))}return r==e?e:FX.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var HX=[];function UX(e){return e==null?HX:Array.isArray(e)?e:[e]}var WX=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(WX||={}),GX=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,KX;try{KX=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function qX(e){if(KX)return KX.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>``&&(n.toUpperCase()!=n.toLowerCase()||GX.test(n)))return!0}return!1}function JX(e){return t=>{if(!/\S/.test(t))return WX.Space;if(qX(t))return WX.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return WX.Word;return WX.Other}}var YX=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++)SX(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 SX(this,n),CX(this,n)}update(...e){return zX(this,e,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let e of t.effects)e.is(vX.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(PX.reconfigure)?(n=null,r=e.value):e.is(PX.appendConfig)&&(n=null,r=UX(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=bX.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(TX)?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:Y.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=UX(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=PX.mapEffects(a,c).concat(PX.mapEffects(UX(o.effects),l))}return{changes:r,selection:Y.create(i,t.mainIndex),effects:a}}changes(t=[]){return t instanceof XY?t:XY.of(t,this.doc.length,this.facet(e.lineSeparator))}toText(t){return AY.of(t.split(this.facet(e.lineSeparator)||qY))}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:(SX(this,t),CX(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 pX&&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:Y.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=bX.resolve(t.extensions||[],new Map),r=t.doc instanceof AY?t.doc:AY.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||qY)),i=t.selection?t.selection instanceof Y?t.selection:Y.single(t.selection.anchor,t.selection.head):Y.single(0);return iX(i,r.length),n.staticFacet(TX)||(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)||`
|
|
@@ -209,7 +209,7 @@ $2`),t=t.replace(/([。;;::\.])\s*-(?!-)\s*/g,`$1
|
|
|
209
209
|
`))};if((WZ.mac||WZ.android)&&u.from==a-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute(`autocorrect`)==`off`&&(u={from:o,to:s,insert:AY.of([n.text.replace(`.`,` `)])}),this.pendingContextChange=u,!e.state.readOnly){let t=this.to-this.from+(u.to-u.from+u.insert.length);W1(e,u,Y.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($Z.mark({attributes:{style:e}}).range(i,a))}}}e.dispatch({effects:g$.of($Z.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=sQ(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])}},k2=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||DQ(e.parent)||document,this.viewState=new i2(this,e.state||YX.create(e)),e.scrollTo&&e.scrollTo.is(h$)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(b$).map(e=>new S$(e));for(let e of this.plugins)e.update(this);this.observer=new w2(this),this.inputState=new X1(this),this.inputState.ensureHandlers(this.plugins),this.docView=new u1(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 FX?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(O0))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,c=k0(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(YX.phrases)!=this.state.facet(YX.phrases))return this.setState(a);i=F$.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 m$(t.empty?t:Y.cursor(t.head,t.head>t.anchor?-1:1),`nearest`,`nearest`,i,r)}for(let e of n.effects)e.is(h$)&&(d=e.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=M2.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(N$)!=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(m2)!=i.state.facet(m2)&&(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(o$))try{e(i)}catch(e){_$(this.state,e,`update listener`)}(c||u)&&Promise.resolve().then(()=>{c&&this.state==c.startState&&this.dispatch(c),u&&!U1(this,u)&&l.force&&EQ(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 i2(this,e),this.plugins=e.facet(b$).map(e=>new S$(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new u1(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(b$),n=e.state.facet(b$);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new S$(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){_$(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(kQ(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 _$(this.state,e),j2}}),l=F$.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]!=j2)try{let t=s[e];t.write&&t.write(c[e],this)}catch(e){_$(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(o$))e(t)}get themeClasses(){return g2+` `+(this.state.facet(h2)?v2:_2)+` `+this.state.facet(m2)}updateAttrs(){let e=N2(this,C$,{class:`cm-editor`+(this.hasFocus?` cm-focused `:` `)+this.themeClasses}),t={spellcheck:`false`,autocorrect:`off`,autocapitalize:`off`,writingsuggestions:`false`,translate:`no`,contenteditable:this.state.facet(v$)?`true`:`false`,class:`cm-content`,style:`${WZ.tabSize}: ${this.state.tabSize}`,role:`textbox`,"aria-multiline":`true`};this.state.readOnly&&(t[`aria-readonly`]=`true`),N2(this,w$,t);let n=this.observer.ignore(()=>{let n=YZ(this.contentDOM,this.contentAttrs,t),r=YZ(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(N$);let t=this.state.facet(e.cspNonce);xZ.mount(this.root,this.styleModules.concat(x2).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 M1(this,e,D1(this,e,t,n))}moveByGroup(e,t){return M1(this,e,D1(this,e,t,t=>O1(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 Y.cursor(i.side(t,r)+e.from,i.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,n=!0){return E1(this,e,t,n)}moveVertically(e,t,n){return M1(this,e,k1(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=P1(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),P1(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[UQ.find(i,e-r.from,-1,t)];return gQ(n,a.dir==NQ.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(d$)||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>A2)return QQ(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||WQ(r.isolates,n=A$(this,e))))return r.order;n||=A$(this,e);let r=ZQ(e.text,t,n);return this.bidiCache.push(new M2(e.from,e.to,t,n,!0,r)),r}get hasFocus(){return(this.dom.ownerDocument.hasFocus()||WZ.safari&&this.inputState?.lastContextMenu>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{CQ(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 h$.of(new m$(typeof e==`number`?Y.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 h$.of(new m$(Y.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 x$.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return x$.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=xZ.newName(),r=[m2.of(n),N$.of(b2(`.${n}`,e))];return t&&t.dark&&r.push(h2.of(!0)),r}static baseTheme(e){return gX.lowest(N$.of(b2(`.`+g2,e,y2)))}static findFromDOM(e){let t=e.querySelector(`.cm-content`);return(t&&L$.get(t)||L$.get(e))?.root?.view||null}};k2.styleModule=N$,k2.inputHandler=s$,k2.clipboardInputFilter=l$,k2.clipboardOutputFilter=u$,k2.scrollHandler=p$,k2.focusChangeEffect=c$,k2.perLineTextDirection=d$,k2.exceptionSink=a$,k2.updateListener=o$,k2.editable=v$,k2.mouseSelectionStyle=i$,k2.dragMovesSelection=r$,k2.clickAddsSelectionRange=n$,k2.decorations=T$,k2.blockWrappers=E$,k2.outerDecorations=D$,k2.atomicRanges=O$,k2.bidiIsolatedRanges=k$,k2.cursorScrollMargin=oX.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}}}),k2.scrollMargins=j$,k2.darkTheme=h2,k2.cspNonce=oX.define({combine:e=>e.length?e[0]:``}),k2.contentAttributes=w$,k2.editorAttributes=C$,k2.lineWrapping=k2.contentAttributes.of({class:`cm-lineWrapping`}),k2.announce=PX.define();var A2=4096,j2={},M2=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:NQ.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 N2(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&&GZ(a,n)}return n}var P2=WZ.mac?`mac`:WZ.windows?`win`:WZ.linux?`linux`:`key`;function F2(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 I2(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 L2=gX.default(k2.domEventHandlers({keydown(e,t){return K2(B2(t.state),e,t,`editor`)}})),R2=oX.define({enables:L2}),z2=new WeakMap;function B2(e){let t=e.facet(R2),n=z2.get(t);return n||z2.set(t,n=W2(t.reduce((e,t)=>e.concat(t),[]))),n}function V2(e,t,n){return K2(B2(e.state),t,e,n)}var H2=null,U2=4e3;function W2(e,t=P2){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=>F2(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=H2={view:t,prefix:n,scope:e};return setTimeout(()=>{H2==r&&(H2=null)},U2),!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,G2))}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 G2=null;function K2(e,t,n,r){G2=t;let i=AZ(t),a=KY(WY(i,0))==i.length&&i!=` `,o=``,s=!1,c=!1,l=!1;H2&&H2.view==n&&H2.scope==r&&(o=H2.prefix+` `,t0.indexOf(t.keyCode)<0&&(c=!0,H2=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+I2(i,t,!a)])?s=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(WZ.windows&&t.ctrlKey&&t.altKey)&&!(WZ.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=wZ[t.keyCode])&&p!=i?(d(f[o+I2(p,t,!0)])||t.shiftKey&&(m=TZ[t.keyCode])!=i&&m!=p&&d(f[o+I2(m,t,!1)]))&&(s=!0):a&&t.shiftKey&&d(f[o+I2(i,t,!0)])&&(s=!0),!s&&d(f._any)&&(s=!0)),c&&(s=!0),s&&l&&t.stopPropagation(),G2=null,s}var q2=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=J2(t);return[new e(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}else return X2(t,n,r)}};function J2(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==NQ.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function Y2(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 X2(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==NQ.LTR,o=e.contentDOM,s=o.getBoundingClientRect(),c=J2(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=T1(e,r,1),m=T1(e,i,-1),h=p.type==QZ.Text?p:null,g=m.type==QZ.Text?m:null;if(h&&(e.lineWrapping||p.widgetLineBreaks)&&(h=Y2(e,r,1,h)),g&&(e.lineWrapping||m.widgetLineBreaks)&&(g=Y2(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==QZ.Text&&(t.bottom=r.top=(t.bottom+r.top)/2),v(t).concat(i).concat(v(r))}function _(e,n,r,i){return new q2(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==NQ.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 Z2(e,t){return e.constructor==t.constructor&&e.eq(t)}var Q2=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($2)!=e.state.facet($2)&&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($2);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)=>!Z2(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,WZ.webkit&&(this.dom.style.display=this.dom.firstChild?``:`none`)}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},$2=oX.define();function e4(e){return[x$.define(t=>new Q2(t,e)),$2.of(e)]}var t4=oX.define({combine(e){return XX(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function n4(e={}){return[t4.of(e),i4,o4,s4,f$.of(!0)]}function r4(e){return e.startState.facet(t4)!=e.state.facet(t4)}var i4=e4({above:!0,markers(e){let{state:t}=e,n=t.facet(t4),r=[];for(let i of t.selection.ranges){let a=i==t.selection.main;if(i.empty||n.drawRangeCursor&&!(a&&WZ.ios&&n.iosSelectionHandles)){let t=a?`cm-cursor cm-cursor-primary`:`cm-cursor cm-cursor-secondary`,n=i.empty?i:Y.cursor(i.head,i.assoc);for(let i of q2.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=r4(e);return n&&a4(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){a4(t.state,e)},class:`cm-cursorLayer`});function a4(e,t){t.style.animationDuration=e.facet(t4).cursorBlinkRate+`ms`}var o4=e4({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 q2.forRange(e,`cm-selectionBackground`,n))t.push(r);if(WZ.ios&&!n.empty&&e.state.facet(t4).iosSelectionHandles){for(let r of q2.forRange(e,`cm-selectionHandle cm-selectionHandle-start`,Y.cursor(n.from,1)))t.push(r);for(let r of q2.forRange(e,`cm-selectionHandle cm-selectionHandle-end`,Y.cursor(n.to,1)))t.push(r)}return t},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||r4(e)},class:`cm-selectionLayer`}),s4=gX.highest(k2.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`}}}})),c4=PX.define({map(e,t){return e==null?null:t.mapPos(e)}}),l4=pX.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((e,t)=>t.is(c4)?t.value:e,e)}}),u4=x$.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(l4);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(l4)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(l4),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(l4)!=e&&this.view.dispatch({effects:c4.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 d4(){return[l4,u4]}/x/.unicode;function f4(){return m4}var p4=$Z.line({class:`cm-activeLine`}),m4=x$.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(p4.range(i.from)),t=i.from)}return $Z.set(n)}},{decorations:e=>e.decorations}),h4=2e3;function g4(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),a=[];if(t.off>h4||n.off>h4||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(Y.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=gZ(n.text,o,e.tabSize,!0);if(r<0)a.push(Y.cursor(n.to));else{let t=gZ(n.text,s,e.tabSize);a.push(Y.range(n.from+r,n.from+t))}}}return a}function _4(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function v4(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>h4?-1:i==r.length?_4(e,t.clientX):hZ(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:a,off:i}}function y4(e,t){let n=v4(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=v4(e,t);if(!o)return r;let s=g4(e.state,n,o);return s.length?a?Y.create(s.concat(r.ranges)):Y.create(s):r}}:null}function b4(e){let t=e?.eventFilter||(e=>e.altKey&&e.button==0);return k2.mouseSelectionStyle.of((e,n)=>t(n)?y4(e,n):null)}var x4={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},S4={style:`cursor: crosshair`};function C4(e={}){let[t,n]=x4[e.key||`Alt`],r=x$.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,k2.contentAttributes.of(e=>e.plugin(r)?.isDown?S4:null)]}var w4=`-10000px`,T4=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 E4(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}var D4=oX.define({combine:e=>({position:WZ.ios?`absolute`:e.find(e=>e.position)?.position||`fixed`,parent:e.find(e=>e.parent)?.parent||null,tooltipSpace:e.find(e=>e.tooltipSpace)?.tooltipSpace||E4})}),O4=new WeakMap,k4=x$.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(D4);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 T4(e,N4,(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(D4);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=w4,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(WZ.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=M$(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(D4).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=w4;continue}let f=s.arrow?c.dom.querySelector(`.cm-tooltip-arrow`):null,p=f?7:0,m=d.right-d.left,h=O4.get(c)??d.bottom-d.top,g=c.offset||M4,_=this.view.textDirection==NQ.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=w4;continue}O4.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`,A4(l,(v-e.parent.left)/r)):(l.style.top=x/i+`px`,A4(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=w4}},{eventObservers:{scroll(){this.maybeMeasure()}}});function A4(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+`px`)}var j4=k2.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`}}}),M4={x:0,y:0},N4=oX.define({enables:[k4,j4]});function P4(e,t){let n=e.plugin(k4);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}var F4=oX.define({combine(e){let t,n;for(let r of e)t||=r.topContainer,n||=r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function I4(e,t){let n=e.plugin(L4),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}var L4=x$.fromClass(class{constructor(e){this.input=e.state.facet(B4),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(F4);this.top=new R4(e,!0,t.topContainer),this.bottom=new R4(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(F4);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new R4(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new R4(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(B4);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=>k2.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})}),R4=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=z4(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=z4(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 z4(e){let t=e.nextSibling;return e.remove(),t}var B4=oX.define({enables:L4});function V4(e,t){let n,r=new Promise(e=>n=e),i=e=>G4(e,t,n);e.state.field(H4,!1)?e.dispatch({effects:U4.of(i)}):e.dispatch({effects:PX.appendConfig.of(H4.init(()=>[i]))});let a=W4.of(i);return{close:a,result:r.then(t=>((e.win.queueMicrotask||(t=>e.win.setTimeout(t,10)))(()=>{e.state.field(H4).indexOf(i)>-1&&e.dispatch({effects:a})}),t))}}var H4=pX.define({create(){return[]},update(e,t){for(let n of t.effects)n.is(U4)?e=[n.value].concat(e):n.is(W4)&&(e=e.filter(e=>e!=n.value));return e},provide:e=>B4.computeN([e],t=>t.field(e))}),U4=PX.define(),W4=PX.define();function G4(e,t,n){let r=t.content?t.content(e,()=>o(null)):null;if(!r){if(r=jZ(`form`),t.input){let e=jZ(`input`,t.input);/^(text|password|number|email|tel|url)$/.test(e.type)&&e.classList.add(`cm-textfield`),e.name||=`input`,r.appendChild(jZ(`label`,(t.label||``)+`: `,e))}else r.appendChild(document.createTextNode(t.label||``));r.appendChild(document.createTextNode(` `)),r.appendChild(jZ(`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=jZ(`div`,r,jZ(`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 K4=class extends ZX{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};K4.prototype.elementClass=``,K4.prototype.toDOM=void 0,K4.prototype.mapMode=JY.TrackBefore,K4.prototype.startSide=K4.prototype.endSide=-1,K4.prototype.point=!0;var q4=oX.define(),J4=oX.define(),Y4={class:``,renderEmptyElements:!1,elementStyle:``,markers:()=>nZ.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:`before`},X4=oX.define();function Z4(e){return[$4(),X4.of({...Y4,...e})]}var Q4=oX.define({combine:e=>e.some(e=>e)});function $4(e){let t=[e3];return e&&e.fixed===!1&&t.push(Q4.of(!0)),t}var e3=x$.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(X4).map(t=>new i3(e,t)),this.fixed=!e.state.facet(Q4);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(Q4)!=!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=nZ.iter(this.view.state.facet(q4),this.view.viewport.from),r=[],i=this.gutters.map(e=>new r3(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==QZ.Text&&t){n3(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==QZ.Text){n3(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(X4),n=e.state.facet(X4),r=e.docChanged||e.heightChanged||e.viewportChanged||!nZ.eq(e.startState.facet(q4),e.state.facet(q4),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 i3(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=>k2.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==NQ.LTR?{left:r,right:i}:{right:r,left:i}})});function t3(e){return Array.isArray(e)?e:[e]}function n3(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}var r3=class{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=nZ.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 a3(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=[];n3(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(J4)){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()}}},i3=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=t3(t.markers(e)),t.initialSpacer&&(this.spacer=new a3(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=t3(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!nZ.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()}},a3=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`:``),o3(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 o3(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 s3=oX.define(),c3=oX.define(),l3=oX.define({combine(e){return XX(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}})}}),u3=class extends K4{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function d3(e,t){return e.state.facet(l3).formatNumber(t,e.state)}var f3=X4.compute([l3],e=>({class:`cm-lineNumbers`,renderEmptyElements:!1,markers(e){return e.state.facet(s3)},lineMarker(e,t,n){return n.some(e=>e.toDOM)?null:new u3(d3(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let r of e.state.facet(c3)){let i=r(e,t,n);if(i)return i}return null},lineMarkerChange:e=>e.startState.facet(l3)!=e.state.facet(l3),initialSpacer(e){return new u3(d3(e,m3(e.state.doc.lines)))},updateSpacer(e,t){let n=d3(t.view,m3(t.view.state.doc.lines));return n==e.number?e:new u3(n)},domEventHandlers:e.facet(l3).domEventHandlers,side:`before`}));function p3(e={}){return[l3.of(e),$4(),f3]}function m3(e){let t=9;for(;t<e;)t=t*10+9;return t}var h3=new class extends K4{constructor(){super(...arguments),this.elementClass=`cm-activeLineGutter`}},g3=q4.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(h3.range(i)))}return nZ.of(t)});function _3(){return g3}var v3=1024,y3=0,b3=class{constructor(e,t){this.from=e,this.to=t}},x3=class{constructor(e={}){this.id=y3++,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=w3.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};x3.closedBy=new x3({deserialize:e=>e.split(` `)}),x3.openedBy=new x3({deserialize:e=>e.split(` `)}),x3.group=new x3({deserialize:e=>e.split(` `)}),x3.isolate=new x3({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),x3.contextHash=new x3({perNode:!0}),x3.lookAhead=new x3({perNode:!0}),x3.mounted=new x3({perNode:!0});var S3=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[x3.mounted.id]}},C3=Object.create(null),w3=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):C3,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(x3.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(x3.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};w3.none=new w3(``,Object.create(null),0,8);var T3=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 w3(e.name,r,e.id,e.flags):e)}return new e(n)}},E3=new WeakMap,D3=new WeakMap,O3;(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`})(O3||={});var k3=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=S3.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 U3(this.topNode,e)}cursorAt(e,t=0,n=0){let r=new U3(E3.get(this)||this.topNode);return r.moveTo(e,t),E3.set(this,r._tree),r}get topNode(){return new F3(this,0,0,null)}resolve(e,t=0){let n=N3(E3.get(this)||this.topNode,e,t,!1);return E3.set(this,n),n}resolveInner(e,t=0){let n=N3(D3.get(this)||this.topNode,e,t,!0);return D3.set(this,n),n}resolveStack(e,t=0){return H3(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,a=e.mode||0,o=(a&O3.IncludeAnonymous)>0;for(let e=this.cursor(a|O3.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:J3(w3.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(w3.none,t,n,r)))}static build(e){return G3(e)}};k3.empty=new k3(w3.none,[],[],0);var A3=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)}},j3=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return w3.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&&!(M3(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 M3(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 N3(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 F3&&e.index<0?null:e.parent;if(!t)return e;e=t}let i=r?0:O3.IgnoreOverlays;if(r)for(let r=e,a=r.parent;a;r=a,a=r.parent)r instanceof F3&&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 P3=class{cursor(e=0){return new U3(this,e)}getChild(e,t=null,n=null){let r=I3(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return I3(this,e,t,n)}resolve(e,t=0){return N3(this,e,t,!1)}resolveInner(e,t=0){return N3(this,e,t,!0)}matchContext(e){return L3(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}},F3=class e extends P3{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&O3.EnterBracketed&&l instanceof k3&&(d=S3.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length)&&!M3(i,r,u,u+l.length))){if(l instanceof j3){if(a&O3.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new z3(new R3(o,l,t,u),null,e)}else if(a&O3.IncludeAnonymous||!l.type.isAnonymous||W3(l)){let s;if(!(a&O3.IgnoreMounts)&&(s=S3.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&O3.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&O3.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&O3.IgnoreOverlays)&&(i=S3.get(this._tree))&&i.overlay){let a=t-this.from,o=r&O3.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 I3(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 L3(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 R3=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},z3=class e extends P3{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&O3.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 k3(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function B3(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 F3&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new V3(i,n)}var V3=class{constructor(e,t){this.heads=e,this.node=t}get next(){return B3(this.heads)}};function H3(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof F3?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=S3.get(e.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new F3(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(N3(o,t,n,!1))}}return i?B3(i):r}var U3=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&~O3.EnterBracketed,e instanceof F3)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 F3?(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&O3.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&O3.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&O3.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&O3.IncludeAnonymous||e instanceof j3||!e.type.isAnonymous||W3(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 z3(this.buffer,t,this.stack[e]);return this.bufferNode=new z3(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 L3(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 L3(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 W3(e){return e.children.some(e=>e instanceof j3||!e.type.isAnonymous||W3(e))}function G3(e){let{buffer:t,nodeSet:n,maxBufferLength:r=v3,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new A3(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,ee=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 te=s[x],E,ne,re=S-e;if(C-S<=r&&(ne=h(o.pos-t,y))){let t=new Uint16Array(ne.size-ne.skip),r=o.pos-ne.size,i=t.length;for(;o.pos>r;)i=g(ne.start,t,i);E=new j3(t,C-ne.start,n),re=ne.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,ee),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,ee),t.reverse(),n.reverse(),i>-1&&s>0){let e=f(te,ee);E=J3(te,t,n,0,t.length,0,C-S,e,e)}else E=m(te,t,n,C-S,T-C,ee)}_.push(E),v.push(re)}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 j3(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 k3){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(x3.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=[x3.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[x3.lookAhead,i];o=o?[e].concat(o):[e]}return new k3(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 k3(s[e.topID],_.reverse(),v.reverse(),y)}var K3=new WeakMap;function q3(e,t){if(!e.isAnonymous||t instanceof j3||t.type!=e)return 1;let n=K3.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof k3)){n=1;break}n+=q3(e,r)}K3.set(t,n)}return n}function J3(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n<i;n++)l+=q3(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=q3(e,t[s]);for(s++;s<i;s++){let n=q3(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(J3(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 Y3=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 z3?this.setBuffer(e.context.buffer,e.index,t):e instanceof F3&&this.map.set(e.tree,t)}get(e){return e instanceof z3?this.getBuffer(e.context.buffer,e.index):e instanceof F3?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)}},X3=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}},Z3=class{startParse(e,t,n){return typeof e==`string`&&(e=new Q3(e)),n=n?n.length?n.map(e=>new b3(e.from,e.to)):[new b3(0,0)]:[new b3(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}}},Q3=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 $3(e){return(t,n,r,i)=>new i6(t,e,n,r,i)}var e6=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 t6(e){if(!e.length||e.some(e=>e.from>=e.to))throw RangeError(`Invalid inner parse ranges given: `+JSON.stringify(e))}var n6=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=[]}},r6=new x3({perNode:!0}),i6=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 k3(e.type,e.children,e.positions,e.length,e.propValues.concat([[r6,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[x3.mounted.id]=new S3(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 l6(this.fragments),t=null,n=null,r=new U3(new F3(this.baseTree,this.ranges[0].from,0,null),O3.IncludeAnonymous|O3.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=a6(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||(s6(r),t&&t.depth++,n&&n.depth++);let a=e.findMounts(r.from,i.parser);if(typeof i.overlay==`function`)t=new n6(i.parser,i.overlay,a,this.inner.length,r.from,!!i.bracketed,r.tree,t);else{let e=u6(this.ranges,i.overlay||(r.from<r.to?[new b3(r.from,r.to)]:[]));e.length&&t6(e),(e.length||!i.overlay)&&this.inner.push(new e6(i.parser,e.length?i.parser.startParse(this.input,f6(a,e),e):i.parser.startParse(``),i.overlay?i.overlay.map(e=>new b3(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 b3(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=u6(this.ranges,t.ranges);e.length&&(t6(e),this.inner.splice(t.index,0,new e6(t.parser,t.parser.startParse(this.input,f6(t.mounts,e),e),t.ranges.map(e=>new b3(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 a6(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 o6(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 s6(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=[];o6(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),o6(o,s[f+3],r,p,m,a),new k3(i,p,m,u)}i.children[a]=l(0,s.length,w3.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 F3(n,r+e.from,t,e._tree))}}var c6=class{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(O3.IncludeAnonymous|O3.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,O3.IgnoreOverlays|O3.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 k3)t=t.children[0];else break}return!1}},l6=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(r6)??t.to,this.inner=new c6(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(r6)??e.to,this.inner=new c6(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(x3.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 u6(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 b3(e.from,o),e.to>s&&n.splice(a+1,0,new b3(s,e.to))):e.to>s?n[a--]=new b3(s,e.to):n.splice(a--,1))}}return r}function d6(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 b3(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 f6(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=d6(t,i.overlay.map(e=>new b3(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 X3(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 X3(s,c,i.tree,-e,a.from>=e||a.openStart,a.to<=o||a.openEnd))}return n}var p6=0,m6=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=p6++}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 h6(e);return e=>e.modified.indexOf(t)>-1?e:h6.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},Kie=0,h6=class e{constructor(e){this.name=e,this.instances=[],this.id=Kie++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&qie(n,e.modified));if(r)return r;let i=[],a=new m6(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=Jie(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 qie(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function Jie(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 g6(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 v6(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return _6.add(t)}var _6=new x3({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 v6(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),v6=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}};v6.empty=new v6([],2,null);function y6(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 Yie(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+` `+e:e)}return n}function Xie(e,t,n,r=0,i=e.length){let a=new Zie(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,``,a.highlighters),a.flush(i)}var Zie=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=Qie(e)||v6.empty,u=Yie(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(x3.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 Qie(e){let t=e.type.prop(_6);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var X=m6.define,b6=X(),x6=X(),S6=X(x6),C6=X(x6),w6=X(),T6=X(w6),E6=X(w6),D6=X(),O6=X(D6),k6=X(),A6=X(),j6=X(),M6=X(j6),N6=X(),Z={comment:b6,lineComment:X(b6),blockComment:X(b6),docComment:X(b6),name:x6,variableName:X(x6),typeName:S6,tagName:X(S6),propertyName:C6,attributeName:X(C6),className:X(x6),labelName:X(x6),namespace:X(x6),macroName:X(x6),literal:w6,string:T6,docString:X(T6),character:X(T6),attributeValue:X(T6),number:E6,integer:X(E6),float:X(E6),bool:X(w6),regexp:X(w6),escape:X(w6),color:X(w6),url:X(w6),keyword:k6,self:X(k6),null:X(k6),atom:X(k6),unit:X(k6),modifier:X(k6),operatorKeyword:X(k6),controlKeyword:X(k6),definitionKeyword:X(k6),moduleKeyword:X(k6),operator:A6,derefOperator:X(A6),arithmeticOperator:X(A6),logicOperator:X(A6),bitwiseOperator:X(A6),compareOperator:X(A6),updateOperator:X(A6),definitionOperator:X(A6),typeOperator:X(A6),controlOperator:X(A6),punctuation:j6,separator:X(j6),bracket:M6,angleBracket:X(M6),squareBracket:X(M6),paren:X(M6),brace:X(M6),content:D6,heading:O6,heading1:X(O6),heading2:X(O6),heading3:X(O6),heading4:X(O6),heading5:X(O6),heading6:X(O6),contentSeparator:X(D6),list:X(D6),quote:X(D6),emphasis:X(D6),strong:X(D6),link:X(D6),monospace:X(D6),strikethrough:X(D6),inserted:X(),deleted:X(),changed:X(),invalid:X(),meta:N6,documentMeta:X(N6),annotation:X(N6),processingInstruction:X(N6),definition:m6.defineModifier(`definition`),constant:m6.defineModifier(`constant`),function:m6.defineModifier(`function`),standard:m6.defineModifier(`standard`),local:m6.defineModifier(`local`),special:m6.defineModifier(`special`)};for(let e in Z){let t=Z[e];t instanceof m6&&(t.name=e)}y6([{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 P6=new x3;function F6(e){return oX.define({combine:e?t=>t.concat(e):void 0})}var I6=new x3,L6=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,YX.prototype.hasOwnProperty(`tree`)||Object.defineProperty(YX.prototype,"tree",{get(){return z6(this)}}),this.parser=t,this.extension=[K6.of(this),YX.languageData.of((e,t,n)=>{let r=R6(e,t,n),i=r.type.prop(P6);if(!i)return[];let a=e.facet(i),o=r.type.prop(I6);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 R6(e,t,n).type.prop(P6)==this.data}findRegions(e){let t=e.facet(K6);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(P6)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(x3.mounted);if(i){if(i.tree.prop(P6)==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 k3&&r(i,e.positions[n]+t)}};return r(z6(e),0),n}get allowsNesting(){return!0}};L6.setState=PX.define();function R6(e,t,n){let r=e.facet(K6),i=z6(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,O3.ExcludeBuffers|O3.EnterBracketed))e.type.isTop&&(i=e);return i}var $ie=class e extends L6{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(t){let n=F6(t.languageData);return new e(n,t.parser.configure({props:[P6.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 z6(e){let t=e.field(L6.state,!1);return t?t.tree:k3.empty}var eae=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)}},B6=null,V6=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,[],k3.empty,0,r,[],null)}startParse(){return this.parser.startParse(new eae(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=k3.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(X3.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(X3.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=B6;B6=this;try{return e()}finally{B6=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=H6(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=X3.applyChanges(r,e),i=k3.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=H6(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 Z3{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=B6;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 k3(w3.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 B6}};function H6(e,t,n){return X3.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var U6=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=V6.create(t.facet(K6).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};L6.state=pX.define({create:U6.init,update(e,t){for(let e of t.effects)if(e.is(L6.setState))return e.value;return t.startState.facet(K6)==t.state.facet(K6)?e.apply(t):U6.init(t.state)}});var W6=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(W6=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var G6=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,tae=x$.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(L6.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(L6.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=W6(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(L6.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!G6?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<r&&n.doc.length>r+1e3,s=i.context.work(()=>G6&&G6()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:L6.setState.of(new U6(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=>_$(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),K6=oX.define({combine(e){return e.length?e[0]:null},enables:e=>[L6.state,tae,k2.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),q6=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}},nae=oX.define(),J6=oX.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 Y6(e){let t=e.facet(J6);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function X6(e,t){let n=``,r=e.tabSize,i=e.facet(J6)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e<t;e++)n+=i;return n}function Z6(e,t){e instanceof YX&&(e=new Q6(e));for(let n of e.state.facet(nae)){let r=n(e,t);if(r!==void 0)return r}let n=z6(e.state);return n.length>=t?rae(e,n,t):null}var Q6=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Y6(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 hZ(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}},$6=new x3;function rae(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 e8(r,e,n)}function e8(e,t,n){for(let r=e;r;r=r.next){let e=aae(r.node);if(e)return e(sae.create(t,n,r))}return 0}function iae(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function aae(e){let t=e.type.prop($6);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(x3.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>t8(e,!0,1,void 0,n&&!iae(e)?t.from:void 0)}return e.parent==null?oae:null}function oae(){return 0}var sae=class e extends Q6{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(cae(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return e8(this.context.next,this.base,this.pos)}};function cae(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function lae(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 uae({closing:e,align:t=!0,units:n=1}){return r=>t8(r,t,n,e)}function t8(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?lae(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}var dae=e=>e.baseIndent;function fae({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var pae=200;function mae(){return YX.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+pae)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=Z6(o,t.from);if(n==null)continue;let r=/^\s*/.exec(t.text)[0],i=X6(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 n8=oX.define(),r8=new x3;function hae(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 gae(e,t,n){let r=z6(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(r8);if(s&&(i.to<r.length-50||r.length==e.doc.length||!_ae(i))){let r=s(i,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(a=r)}}return a}function _ae(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function i8(e,t,n){for(let r of e.facet(n8)){let i=r(e,t,n);if(i)return i}return gae(e,t,n)}function a8(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 o8=PX.define({map:a8}),s8=PX.define({map:a8});function c8(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 l8=pX.define({create(){return $Z.none},update(e,t){t.isUserEvent(`delete`)&&t.changes.iterChangedRanges((t,n)=>e=u8(e,t,n)),e=e.map(t.changes);for(let n of t.effects)if(n.is(o8)&&!vae(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(m8),i=r?$Z.replace({widget:new Cae(r(t.state,n.value))}):_8;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(s8)&&(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=u8(e,t.selection.main.head)),e},provide:e=>k2.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(_8.range(r,i))}return $Z.set(t,!0)}});function u8(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 d8(e,t,n){var r;let i=null;return(r=e.field(l8,!1))==null||r.between(t,n,(e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})}),i}function vae(e,t,n){let r=!1;return e.between(t,t,(e,i)=>{e==t&&i==n&&(r=!0)}),r}function f8(e,t){return e.field(l8,!1)?t:t.concat(PX.appendConfig.of(h8()))}var yae=e=>{for(let t of c8(e)){let n=i8(e.state,t.from,t.to);if(n)return e.dispatch({effects:f8(e.state,[o8.of(n),p8(e,n)])}),!0}return!1},bae=e=>{if(!e.state.field(l8,!1))return!1;let t=[];for(let n of c8(e)){let r=d8(e.state,n.from,n.to);r&&t.push(s8.of(r),p8(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function p8(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return k2.announce.of(`${e.state.phrase(n?`Folded lines`:`Unfolded lines`)} ${r} ${e.state.phrase(`to`)} ${i}.`)}var xae=[{key:`Ctrl-Shift-[`,mac:`Cmd-Alt-[`,run:yae},{key:`Ctrl-Shift-]`,mac:`Cmd-Alt-]`,run:bae},{key:`Ctrl-Alt-[`,run:e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=i8(t,i.from,i.to);a&&n.push(o8.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:f8(e.state,n)}),!!n.length}},{key:`Ctrl-Alt-]`,run:e=>{let t=e.state.field(l8,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(s8.of({from:e,to:t}))}),e.dispatch({effects:n}),!0}}],Sae={placeholderDOM:null,preparePlaceholder:null,placeholderText:`…`},m8=oX.define({combine(e){return XX(e,Sae)}});function h8(e){let t=[l8,Eae];return e&&t.push(m8.of(e)),t}function g8(e,t){let{state:n}=e,r=n.facet(m8),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=d8(e.state,n.from,n.to);r&&e.dispatch({effects:s8.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 _8=$Z.replace({widget:new class extends ZZ{toDOM(e){return g8(e,null)}}}),Cae=class extends ZZ{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return g8(e,this.value)}},wae={openText:`⌄`,closedText:`›`,markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},v8=class extends K4{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 Tae(e={}){let t={...wae,...e},n=new v8(t,!0),r=new v8(t,!1),i=x$.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(K6)!=e.state.facet(K6)||e.startState.field(l8,!1)!=e.state.field(l8,!1)||z6(e.startState)!=z6(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new iZ;for(let i of e.viewportLineBlocks){let a=d8(e.state,i.from,i.to)?r:i8(e.state,i.from,i.to)?n:null;a&&t.add(i.from,i.from,a)}return t.finish()}}),{domEventHandlers:a}=t;return[i,Z4({class:`cm-foldGutter`,markers(e){return e.plugin(i)?.markers||nZ.empty},initialSpacer(){return new v8(t,!1)},domEventHandlers:{...a,click:(e,t,n)=>{if(a.click&&a.click(e,t,n))return!0;let r=d8(e.state,t.from,t.to);if(r)return e.dispatch({effects:s8.of(r)}),!0;let i=i8(e.state,t.from,t.to);return i?(e.dispatch({effects:o8.of(i)}),!0):!1}}}),h8()]}var Eae=k2.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`}}),y8=class e{constructor(e,t){this.specs=e;let n;function r(e){let t=xZ.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 L6?e=>e.prop(P6)==a.data:a?e=>e==a:void 0,this.style=y6(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new xZ(n):null,this.themeType=t.themeType}static define(t,n){return new e(t,n||{})}},b8=oX.define(),x8=oX.define({combine(e){return e.length?[e[0]]:null}});function S8(e){let t=e.facet(b8);return t.length?t:e.facet(x8)}function C8(e,t){let n=[Oae],r;return e instanceof y8&&(e.module&&n.push(k2.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(x8.of(e)):r?n.push(b8.computeN([k2.darkTheme],t=>t.facet(k2.darkTheme)==(r==`dark`)?[e]:[])):n.push(b8.of(e)),n}var Dae=class{constructor(e){this.markCache=Object.create(null),this.tree=z6(e.state),this.decorations=this.buildDeco(e,S8(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=z6(e.state),n=S8(e.state),r=n!=S8(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 $Z.none;let n=new iZ;for(let{from:r,to:i}of e.visibleRanges)Xie(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=$Z.mark({class:r})))},r,i);return n.finish()}},Oae=gX.high(x$.fromClass(Dae,{decorations:e=>e.decorations})),kae=y8.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`}]),Aae=k2.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:`#328c8252`},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bb555544`}}),w8=1e4,T8=`()[]{}`,E8=oX.define({combine(e){return XX(e,{afterCursor:!0,brackets:T8,maxScanDistance:w8,renderMatch:Nae})}}),jae=$Z.mark({class:`cm-matchingBracket`}),Mae=$Z.mark({class:`cm-nonmatchingBracket`});function Nae(e){let t=[],n=e.matched?jae:Mae;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 D8(e){let t=[],n=e.facet(E8);for(let r of e.selection.ranges){if(!r.empty)continue;let i=j8(e,r.head,-1,n)||r.head>0&&j8(e,r.head-1,1,n)||n.afterCursor&&(j8(e,r.head,1,n)||r.head<e.doc.length&&j8(e,r.head+1,-1,n));i&&(t=t.concat(n.renderMatch(i,e)))}return $Z.set(t,!0)}var Pae=[x$.fromClass(class{constructor(e){this.paused=!1,this.decorations=D8(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=D8(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),Aae];function Fae(e={}){return[E8.of(e),Pae]}var O8=new x3;function k8(e,t,n){let r=e.prop(t<0?x3.openedBy:x3.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 A8(e){let t=e.type.prop(O8);return t?t(e.node):e}function j8(e,t,n,r={}){let i=r.maxScanDistance||w8,a=r.brackets||T8,o=z6(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=k8(r.type,n,a);if(i&&r.from<r.to){let o=A8(r);if(o&&(n>0?t>=o.from&&t<o.to:t>o.from&&t<=o.to))return Iae(e,t,n,r,o,i,a)}}return Lae(e,t,n,o,s.type,i,a)}function Iae(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=A8(u);return{start:c,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}else if(k8(u.type,n,o))l++;else if(k8(u.type,-n,o)){if(l==0){let e=A8(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 Lae(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 M8(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 N8=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=M8(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){return this.overrideIndent??M8(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 Rae(e){return{name:e.name||``,token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||zae,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||R8,mergeTokens:e.mergeTokens!==!1}}function zae(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 P8=new WeakMap,Bae=class e extends L6{constructor(e){let t=F6(e.languageData),n=Rae(e),r,i=new class extends Z3{createParse(e,t,n){return new Hae(r,e,t,n)}};super(t,i,[],e.name),this.topNode=Gae(t,this),r=this,this.streamParser=n,this.stateAfter=new x3({perNode:!0}),this.tokenTable=e.tokenTable?new U8(n.tokenTable):Wae}static define(t){return new e(t)}getIndent(e){let t,{overrideIndentation:n}=e.options;n&&(t=P8.get(e.state),t!=null&&t<e.pos-1e4&&(t=void 0));let r=F8(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 N8(t.text,e.state.tabSize,e.unit,i<0?void 0:i);for(;o.pos<r-t.from;)L8(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&&P8.set(e.state,o.from),this.streamParser.indent(a,/^\s*(.*)/.exec(o.text)[1],e)}get allowsNesting(){return!1}};function F8(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 k3&&s<i&&F8(e,o,s,r,i);if(c)return c}return null}function I8(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 k3){if(!(c=I8(e,s,n-o,r-o,i)))break;return i?new k3(t.type,t.children.slice(0,a).concat(c),t.positions.slice(0,a+1),o+c.length):c}}return null}function Vae(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&&F8(e,i.tree,0-i.offset,n,a),s;if(o&&o.pos<=r&&(s=I8(e,i.tree,n+i.offset,o.pos+i.offset,!1)))return{state:o.state,tree:s}}return{state:e.streamParser.startState(i?Y6(i):4),tree:k3.empty}}var Hae=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=V6.get(),a=r[0].from,{state:o,tree:s}=Vae(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(Y6(i.state)),i.skipUntilInView(this.parsedPos,i.viewport.from),this.parsedPos=i.viewport.from),this.moveRangeIndex()}advance(){let e=V6.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==`
|
|
210
210
|
`&&(t=``);else{let e=t.indexOf(`
|
|
211
211
|
`);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 N8(t,e?e.state.tabSize:4,e?Y6(e.state):2);if(a.eol())i.blankLine(this.state,a.indentUnit);else for(;!a.eol();){let e=L8(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=k3.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:Uae,topID:0,maxBufferLength:512,reused:this.chunkReused});e=new k3(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 k3(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function L8(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 R8=Object.create(null),z8=[w3.none],Uae=new T3(z8),B8=[],V8=Object.create(null),H8=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`]])H8[e]=G8(R8,t);var U8=class{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),H8)}resolve(e){return e?this.table[e]||(this.table[e]=G8(this.extra,e)):0}},Wae=new U8(R8);function W8(e,t){B8.indexOf(e)>-1||(B8.push(e),console.warn(t))}function G8(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):W8(n,`Modifier ${n} used at start of tag`):t.length?W8(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:W8(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=V8[i];if(a)return a.id;let o=V8[i]=w3.define({id:z8.length,name:r,props:[g6({[r]:n})]});return z8.push(o),o.id}function Gae(e,t){let n=w3.define({id:z8.length,name:`Document`,props:[P6.add(()=>e),$6.add(()=>e=>t.getIndent(e))],top:!0});return z8.push(n),n}NQ.RTL,NQ.LTR;var Kae=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=q8(e.state,n.from);return r.line?qae(e):r.block?Yae(e):!1};function K8(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 qae=K8(Qae,0),Jae=K8(Y8,0),Yae=K8((e,t)=>Y8(e,t,Zae(t)),0);function q8(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var J8=50;function Xae(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-J8,r),o=e.sliceDoc(i,i+J8),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*J8?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+J8),d=e.sliceDoc(i-J8,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 Zae(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 Y8(e,t,n=t.selection.ranges){let r=n.map(e=>q8(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>Xae(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 Qae(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=q8(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 X8=jX.define(),$ae=jX.define(),eoe=oX.define(),Z8=oX.define({combine(e){return XX(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)})}}),Q8=pX.define({create(){return c5.empty},update(e,t){let n=t.state.facet(Z8),r=t.annotation(X8);if(r){let i=n5.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?r5(o,o.length,n.minDepth,i):o5(o,t.startState.selection),new c5(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation($ae);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(FX.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=n5.fromTransaction(t),o=t.annotation(FX.time),s=t.annotation(FX.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 c5(e.done.map(n5.fromJSON),e.undone.map(n5.fromJSON))}});function toe(e={}){return[Q8,Z8.of(e),k2.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?e5:e.inputType==`historyRedo`?t5:null;return n?(e.preventDefault(),n(t)):!1}})]}function $8(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(Q8,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var e5=$8(0,!1),t5=$8(1,!1),noe=$8(0,!0),roe=$8(1,!0),n5=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&&XY.fromJSON(t.changes),[],t.mapped&&YY.fromJSON(t.mapped),t.startSelection&&Y.fromJSON(t.startSelection),t.selectionsAfter.map(Y.fromJSON))}static fromTransaction(t,n){let r=a5;for(let e of t.startState.facet(eoe)){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,a5)}static selection(t){return new e(void 0,a5,void 0,void 0,t)}};function r5(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 ioe(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 aoe(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function i5(e,t){return e.length?t.length?e.concat(t):e:t}var a5=[],ooe=200;function o5(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-ooe));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),r5(e,e.length-1,1e9,n.setSelAfter(r)))}else return[n5.selection([t])]}function soe(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 s5(e,t){if(!e.length)return e;let n=e.length,r=a5;for(;n;){let i=coe(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?[n5.selection(r)]:a5}function coe(e,t,n){let r=i5(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):a5,n);if(!e.changes)return n5.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new n5(i,PX.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var loe=/^(input\.type|delete)($|\.)/,c5=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||loe.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,ioe(s.changes,t.changes))||r==`input.type.compose`)?r5(o,o.length-1,i.minDepth,new n5(t.changes.compose(s.changes),i5(PX.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,a5)):r5(o,o.length,i.minDepth,t),new e(o,a5,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:a5;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&aoe(a[a.length-1],t)?this:new e(o5(this.done,t),this.undone,n,r)}addMapping(t){return new e(s5(this.done,t),s5(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:X8.of({side:e,rest:soe(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?a5:r.slice(0,r.length-1);return i.mapped&&(n=s5(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:X8.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};c5.empty=new c5(a5,a5);var uoe=[{key:`Mod-z`,run:e5,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:t5,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:t5,preventDefault:!0},{key:`Mod-u`,run:noe,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:roe,preventDefault:!0}];function l5(e,t){return Y.create(e.ranges.map(t),e.mainIndex)}function u5(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function d5({state:e,dispatch:t},n){let r=l5(e.selection,n);return r.eq(e.selection,!0)?!1:(t(u5(e,r)),!0)}function f5(e,t){return Y.cursor(t?e.to:e.from)}function p5(e,t){return d5(e,n=>n.empty?e.moveByChar(n,t):f5(n,t))}function m5(e){return e.textDirectionAt(e.state.selection.main.head)==NQ.LTR}var h5=e=>p5(e,!m5(e)),g5=e=>p5(e,m5(e));function _5(e,t){return d5(e,n=>n.empty?e.moveByGroup(n,t):f5(n,t))}var doe=e=>_5(e,!m5(e)),foe=e=>_5(e,m5(e));typeof Intl<`u`&&Intl.Segmenter;function poe(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 v5(e,t,n){let r=z6(e).resolveInner(t.head),i=n?x3.closedBy:x3.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;poe(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?j8(e,r.from,1):j8(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,Y.cursor(s,n?-1:1)}var moe=e=>d5(e,t=>v5(e.state,t,!m5(e))),hoe=e=>d5(e,t=>v5(e.state,t,m5(e)));function y5(e,t){return d5(e,n=>{if(!n.empty)return f5(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var b5=e=>y5(e,!1),x5=e=>y5(e,!0);function S5(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(k2.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 C5(e,t){let n=S5(e),{state:r}=e,i=l5(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):f5(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=k2.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(u5(r,i),{effects:a}),!0}var w5=e=>C5(e,!1),T5=e=>C5(e,!0);function E5(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=Y.cursor(r.from+n))}return i}var goe=e=>d5(e,t=>E5(e,t,!0)),_oe=e=>d5(e,t=>E5(e,t,!1)),voe=e=>d5(e,t=>E5(e,t,!m5(e))),yoe=e=>d5(e,t=>E5(e,t,m5(e))),boe=e=>d5(e,t=>Y.cursor(e.lineBlockAt(t.head).from,1)),xoe=e=>d5(e,t=>Y.cursor(e.lineBlockAt(t.head).to,-1));function Soe(e,t,n){let r=!1,i=l5(e.selection,t=>{let i=j8(e,t.head,-1)||j8(e,t.head,1)||t.head>0&&j8(e,t.head-1,1)||t.head<e.doc.length&&j8(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?Y.range(t.anchor,a):Y.cursor(a)});return r?(t(u5(e,i)),!0):!1}var Coe=({state:e,dispatch:t})=>Soe(e,t,!1);function D5(e,t){let n=l5(e.state.selection,e=>{let n=t(e);return Y.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(u5(e.state,n)),!0)}function O5(e,t){return D5(e,n=>e.moveByChar(n,t))}var k5=e=>O5(e,!m5(e)),A5=e=>O5(e,m5(e));function j5(e,t){return D5(e,n=>e.moveByGroup(n,t))}var woe=e=>j5(e,!m5(e)),Toe=e=>j5(e,m5(e)),Eoe=e=>D5(e,t=>v5(e.state,t,!m5(e))),Doe=e=>D5(e,t=>v5(e.state,t,m5(e)));function M5(e,t){return D5(e,n=>e.moveVertically(n,t))}var N5=e=>M5(e,!1),P5=e=>M5(e,!0);function F5(e,t){return D5(e,n=>e.moveVertically(n,t,S5(e).height))}var I5=e=>F5(e,!1),L5=e=>F5(e,!0),Ooe=e=>D5(e,t=>E5(e,t,!0)),koe=e=>D5(e,t=>E5(e,t,!1)),Aoe=e=>D5(e,t=>E5(e,t,!m5(e))),joe=e=>D5(e,t=>E5(e,t,m5(e))),Moe=e=>D5(e,t=>Y.cursor(e.lineBlockAt(t.head).from)),Noe=e=>D5(e,t=>Y.cursor(e.lineBlockAt(t.head).to)),R5=({state:e,dispatch:t})=>(t(u5(e,{anchor:0})),!0),z5=({state:e,dispatch:t})=>(t(u5(e,{anchor:e.doc.length})),!0),B5=({state:e,dispatch:t})=>(t(u5(e,{anchor:e.selection.main.anchor,head:0})),!0),V5=({state:e,dispatch:t})=>(t(u5(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Poe=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),Foe=({state:e,dispatch:t})=>{let n=X5(e).map(({from:t,to:n})=>Y.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:Y.create(n),userEvent:`select`})),!0},Ioe=({state:e,dispatch:t})=>{let n=l5(e.selection,t=>{let n=z6(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 Y.range(n.to,n.from)}return t});return n.eq(e.selection)?!1:(t(u5(e,n)),!0)};function H5(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(u5(n,Y.create(i,i.length-1))),!0)}var Loe=e=>H5(e,!1),Roe=e=>H5(e,!0),zoe=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=Y.create([n.main]):n.main.empty||(r=Y.create([Y.cursor(n.main.head)])),r?(t(u5(e,r)),!0):!1};function U5(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=W5(e,o,!1)):o>i&&(n=`delete.forward`,o=W5(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=W5(e,i,!1),a=W5(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:Y.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`?k2.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function W5(e,t,n){if(e instanceof k2)for(let r of e.state.facet(k2.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var G5=(e,t,n)=>U5(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=hZ(s,a.tabSize)%Y6(a)||Y6(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=VY(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=VY(o.text,c-o.from,!1,!1)+o.from);return c}),K5=e=>G5(e,!1,!0),q5=e=>G5(e,!0,!1),J5=(e,t)=>U5(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=VY(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}),Y5=e=>J5(e,!1),Boe=e=>J5(e,!0),Voe=e=>U5(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Hoe=e=>U5(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),Uoe=e=>U5(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Woe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:AY.of([``,``])},range:Y.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},Goe=({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:VY(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:VY(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:Y.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function X5(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 Z5(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of X5(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(Y.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(Y.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:Y.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var Koe=({state:e,dispatch:t})=>Z5(e,t,!1),qoe=({state:e,dispatch:t})=>Z5(e,t,!0);function Q5(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of X5(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 Joe=({state:e,dispatch:t})=>Q5(e,t,!1),Yoe=({state:e,dispatch:t})=>Q5(e,t,!0),Xoe=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(X5(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=l5(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 Zoe(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=z6(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(x3.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 $5=e7(!1),Qoe=e7(!0);function e7(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&&Zoe(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new Q6(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=Z6(s,r);for(c??=hZ(/^\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=[``,X6(t,c)];return o&&l.push(X6(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:AY.of(l)},range:Y.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function t7(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:Y.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var $oe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new Q6(e,{overrideIndentation:e=>n[e]??-1}),i=t7(e,(t,i,a)=>{let o=Z6(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=X6(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},n7=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(t7(e,(t,n)=>{n.push({from:t.from,insert:e.facet(J6)})}),{userEvent:`input.indent`})),!0),r7=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(t7(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=hZ(r,e.tabSize),a=0,o=X6(e,Math.max(0,i-Y6(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),ese=e=>(e.setTabFocusMode(),!0),tse=[{key:`Ctrl-b`,run:h5,shift:k5,preventDefault:!0},{key:`Ctrl-f`,run:g5,shift:A5},{key:`Ctrl-p`,run:b5,shift:N5},{key:`Ctrl-n`,run:x5,shift:P5},{key:`Ctrl-a`,run:boe,shift:Moe},{key:`Ctrl-e`,run:xoe,shift:Noe},{key:`Ctrl-d`,run:q5},{key:`Ctrl-h`,run:K5},{key:`Ctrl-k`,run:Voe},{key:`Ctrl-Alt-h`,run:Y5},{key:`Ctrl-o`,run:Woe},{key:`Ctrl-t`,run:Goe},{key:`Ctrl-v`,run:T5}],nse=[{key:`ArrowLeft`,run:h5,shift:k5,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:doe,shift:woe,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:voe,shift:Aoe,preventDefault:!0},{key:`ArrowRight`,run:g5,shift:A5,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:foe,shift:Toe,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:yoe,shift:joe,preventDefault:!0},{key:`ArrowUp`,run:b5,shift:N5,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:R5,shift:B5},{mac:`Ctrl-ArrowUp`,run:w5,shift:I5},{key:`ArrowDown`,run:x5,shift:P5,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:z5,shift:V5},{mac:`Ctrl-ArrowDown`,run:T5,shift:L5},{key:`PageUp`,run:w5,shift:I5},{key:`PageDown`,run:T5,shift:L5},{key:`Home`,run:_oe,shift:koe,preventDefault:!0},{key:`Mod-Home`,run:R5,shift:B5},{key:`End`,run:goe,shift:Ooe,preventDefault:!0},{key:`Mod-End`,run:z5,shift:V5},{key:`Enter`,run:$5,shift:$5},{key:`Mod-a`,run:Poe},{key:`Backspace`,run:K5,shift:K5,preventDefault:!0},{key:`Delete`,run:q5,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:Y5,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:Boe,preventDefault:!0},{mac:`Mod-Backspace`,run:Hoe,preventDefault:!0},{mac:`Mod-Delete`,run:Uoe,preventDefault:!0}].concat(tse.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),rse=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:moe,shift:Eoe},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:hoe,shift:Doe},{key:`Alt-ArrowUp`,run:Koe},{key:`Shift-Alt-ArrowUp`,run:Joe},{key:`Alt-ArrowDown`,run:qoe},{key:`Shift-Alt-ArrowDown`,run:Yoe},{key:`Mod-Alt-ArrowUp`,run:Loe},{key:`Mod-Alt-ArrowDown`,run:Roe},{key:`Escape`,run:zoe},{key:`Mod-Enter`,run:Qoe},{key:`Alt-l`,mac:`Ctrl-l`,run:Foe},{key:`Mod-i`,run:Ioe,preventDefault:!0},{key:`Mod-[`,run:r7},{key:`Mod-]`,run:n7},{key:`Mod-Alt-\\`,run:$oe},{key:`Shift-Mod-k`,run:Xoe},{key:`Shift-Mod-\\`,run:Coe},{key:`Mod-/`,run:Kae},{key:`Alt-A`,run:Jae},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:ese}].concat(nse),ise={key:`Tab`,run:n7,shift:r7},ase=`#e5c07b`,i7=`#e06c75`,ose=`#56b6c2`,sse=`#ffffff`,a7=`#abb2bf`,o7=`#7d8799`,cse=`#61afef`,lse=`#98c379`,s7=`#d19a66`,use=`#c678dd`,dse=`#21252b`,c7=`#2c313a`,l7=`#282c34`,u7=`#353a42`,fse=`#3E4451`,d7=`#528bff`,f7=[k2.theme({"&":{color:a7,backgroundColor:l7},".cm-content":{caretColor:d7},".cm-cursor, .cm-dropCursor":{borderLeftColor:d7},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:fse},".cm-panels":{backgroundColor:dse,color:a7},".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:l7,color:o7,border:`none`},".cm-activeLineGutter":{backgroundColor:c7},".cm-foldPlaceholder":{backgroundColor:`transparent`,border:`none`,color:`#ddd`},".cm-tooltip":{border:`none`,backgroundColor:u7},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:`transparent`,borderBottomColor:`transparent`},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:u7,borderBottomColor:u7},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:c7,color:a7}}},{dark:!0}),C8(y8.define([{tag:Z.keyword,color:use},{tag:[Z.name,Z.deleted,Z.character,Z.propertyName,Z.macroName],color:i7},{tag:[Z.function(Z.variableName),Z.labelName],color:cse},{tag:[Z.color,Z.constant(Z.name),Z.standard(Z.name)],color:s7},{tag:[Z.definition(Z.name),Z.separator],color:a7},{tag:[Z.typeName,Z.className,Z.number,Z.changed,Z.annotation,Z.modifier,Z.self,Z.namespace],color:ase},{tag:[Z.operator,Z.operatorKeyword,Z.url,Z.escape,Z.regexp,Z.link,Z.special(Z.string)],color:ose},{tag:[Z.meta,Z.comment],color:o7},{tag:Z.strong,fontWeight:`bold`},{tag:Z.emphasis,fontStyle:`italic`},{tag:Z.strikethrough,textDecoration:`line-through`},{tag:Z.link,color:o7,textDecoration:`underline`},{tag:Z.heading,fontWeight:`bold`,color:i7},{tag:[Z.atom,Z.bool,Z.special(Z.variableName)],color:s7},{tag:[Z.processingInstruction,Z.string,Z.inserted],color:lse},{tag:Z.invalid,color:sse}]))],p7=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,m7=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(p7(e)):p7,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 WY(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=GY(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=KY(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`&&(m7.prototype[Symbol.iterator]=function(){return this});var h7={from:-1,to:-1,match:/.*/.exec(``),precise:!0},g7=`gm`+(/x/.unicode==null?``:`u`),_7=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=h7,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new b7(e,t,n,r,i);this.re=new RegExp(t,g7+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter();let a=e.lineAt(r);this.curLineStart=a.from,this.matchPos=x7(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=x7(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}}},v7=new WeakMap,y7=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=v7.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return v7.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)),v7.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},b7=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=h7,this.matchPos=x7(e,r),this.re=new RegExp(t,g7+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=y7.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=x7(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=y7.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(_7.prototype[Symbol.iterator]=b7.prototype[Symbol.iterator]=function(){return this});function pse(e){try{return new RegExp(e,g7),!0}catch{return!1}}function x7(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 mse=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=V4(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=Y.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,k2.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},hse={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},S7=oX.define({combine(e){return XX(e,hse,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function gse(e){let t=[xse,bse];return e&&t.push(S7.of(e)),t}var _se=$Z.mark({class:`cm-selectionMatch`}),vse=$Z.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function C7(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=WX.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=WX.Word)}function yse(e,t,n,r){return e(t.sliceDoc(n,n+1))==WX.Word&&e(t.sliceDoc(r-1,r))==WX.Word}var bse=x$.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(S7),{state:n}=e,r=n.selection;if(r.ranges.length>1)return $Z.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return $Z.none;let e=n.wordAt(i.head);if(!e)return $Z.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 $Z.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(C7(o,n,i.from,i.to)&&yse(o,n,i.from,i.to)))return $Z.none}else if(a=n.sliceDoc(i.from,i.to),!a)return $Z.none}let s=[];for(let r of e.visibleRanges){let e=new m7(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||C7(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(vse.range(r,a)):(r>=i.to||a<=i.from)&&s.push(_se.range(r,a)),s.length>t.maxMatches))return $Z.none}}return $Z.set(s)}},{decorations:e=>e.decorations}),xse=k2.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),Sse=({state:e,dispatch:t})=>{let{selection:n}=e,r=Y.create(n.ranges.map(t=>e.wordAt(t.head)||Y.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function Cse(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 m7(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new m7(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 wse=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return Sse({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=Cse(e,r);return i?(t(e.update({selection:e.selection.addRange(Y.range(i.from,i.to),!1),effects:k2.scrollIntoView(i.to)})),!0):!1},w7=oX.define({combine(e){return XX(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Rse(e),scrollToMatch:e=>k2.scrollIntoView(e)})}}),T7=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||pse(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`?`
|
|
212
|
-
`: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 Ase(this):new Dse(this)}getCursor(e,t=0,n){let r=e.doc?e:YX.create({doc:e});return n??=r.doc.length,this.regexp?O7(this,r,t,n):D7(this,r,t,n)}},E7=class{constructor(e){this.spec=e}};function Tse(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 D7(e,t,n,r){let i;return e.wholeWord&&(i=Ese(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=Tse(e.test,t,i)),new m7(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function Ese(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(k7(i,n-a))!=WX.Word||t(A7(i,n-a))!=WX.Word)&&(t(A7(i,r-a))!=WX.Word||t(k7(i,r-a))!=WX.Word))}var Dse=class extends E7{constructor(e){super(e)}nextMatch(e,t,n){let r=D7(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=D7(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=D7(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=D7(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=D7(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 Ose(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function O7(e,t,n,r){let i;return e.wholeWord&&(i=kse(t.charCategorizer(t.selection.main.head))),e.test&&(i=Ose(e.test,t,i)),new _7(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function k7(e,t){return e.slice(VY(e,t,!1),t)}function A7(e,t){return e.slice(t,VY(e,t))}function kse(e){return(t,n,r)=>!r[0].length||(e(k7(r.input,r.index))!=WX.Word||e(A7(r.input,r.index))!=WX.Word)&&(e(A7(r.input,r.index+r[0].length))!=WX.Word||e(k7(r.input,r.index+r[0].length))!=WX.Word)}var Ase=class extends E7{nextMatch(e,t,n){let r=O7(this.spec,e,n,e.doc.length).next();return r.done&&(r=O7(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=O7(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=O7(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=O7(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)}},j7=PX.define(),M7=PX.define(),N7=pX.define({create(e){return new P7(B7(e).create(),null)},update(e,t){for(let n of t.effects)n.is(j7)?e=new P7(n.value.create(),e.panel):n.is(M7)&&(e=new P7(e.query,n.value?z7:null));return e},provide:e=>B4.from(e,e=>e.panel)}),P7=class{constructor(e,t){this.query=e,this.panel=t}},jse=$Z.mark({class:`cm-searchMatch`}),Mse=$Z.mark({class:`cm-searchMatch cm-searchMatch-selected`}),Nse=x$.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(N7))}update(e){let t=e.state.field(N7);(t!=e.startState.field(N7)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return $Z.none;let{view:n}=this,r=new iZ;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?Mse:jse)})}return r.finish()}},{decorations:e=>e.decorations});function F7(e){return t=>{let n=t.state.field(N7,!1);return n&&n.query.spec.valid?e(t,n):U7(t)}}var I7=F7((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=Y.single(r.from,r.to),a=e.state.facet(w7);return e.dispatch({selection:i,effects:[J7(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),H7(e),!0}),L7=F7((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=Y.single(i.from,i.to),o=e.state.facet(w7);return e.dispatch({selection:a,effects:[J7(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),H7(e),!0}),Pse=F7((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:Y.create(n.map(e=>Y.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),Fse=({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 m7(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(Y.range(t.value.from,t.value.to))}return t(e.update({selection:Y.create(a,o),userEvent:`select.search.matches`})),!0},R7=F7((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(k2.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=Y.single(o.from,o.to).map(d),u.push(J7(e,o)),u.push(n.facet(w7).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),Ise=F7((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:k2.announce.of(r),userEvent:`input.replace.all`}),!0});function z7(e){return e.state.facet(w7).createPanel(e)}function B7(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(w7);return new T7({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 V7(e){let t=I4(e,z7);return t&&t.dom.querySelector(`[main-field]`)}function H7(e){let t=V7(e);t&&t==e.root.activeElement&&t.select()}var U7=e=>{let t=e.state.field(N7,!1);if(t&&t.panel){let n=V7(e);if(n&&n!=e.root.activeElement){let r=B7(e.state,t.query.spec);r.valid&&e.dispatch({effects:j7.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[M7.of(!0),t?j7.of(B7(e.state,t.query.spec)):PX.appendConfig.of(Bse)]});return!0},W7=e=>{let t=e.state.field(N7,!1);if(!t||!t.panel)return!1;let n=I4(e,z7);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:M7.of(!1)}),!0},Lse=[{key:`Mod-f`,run:U7,scope:`editor search-panel`},{key:`F3`,run:I7,shift:L7,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:I7,shift:L7,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:W7,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:Fse},{key:`Mod-Alt-g`,run:mse},{key:`Mod-d`,run:wse,preventDefault:!0}],Rse=class{constructor(e){this.view=e;let t=this.query=e.state.field(N7).query.spec;this.commit=this.commit.bind(this),this.searchField=jZ(`input`,{value:t.search,placeholder:G7(e,`Find`),"aria-label":G7(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=jZ(`input`,{value:t.replace,placeholder:G7(e,`Replace`),"aria-label":G7(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=jZ(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=jZ(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=jZ(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return jZ(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=jZ(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>I7(e),[G7(e,`next`)]),n(`prev`,()=>L7(e),[G7(e,`previous`)]),n(`select`,()=>Pse(e),[G7(e,`all`)]),jZ(`label`,null,[this.caseField,G7(e,`match case`)]),jZ(`label`,null,[this.reField,G7(e,`regexp`)]),jZ(`label`,null,[this.wordField,G7(e,`by word`)]),...e.state.readOnly?[]:[jZ(`br`),this.replaceField,n(`replace`,()=>R7(e),[G7(e,`replace`)]),n(`replaceAll`,()=>Ise(e),[G7(e,`replace all`)])],jZ(`button`,{name:`close`,onclick:()=>W7(e),"aria-label":G7(e,`close`),type:`button`},[`×`])])}commit(){let e=new T7({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:j7.of(e)}))}keydown(e){V2(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?L7:I7)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),R7(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(j7)&&!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(w7).top}};function G7(e,t){return e.state.phrase(t)}var K7=30,q7=/[\s\.,:;?!]/;function J7(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-K7),o=Math.min(i,n+K7),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<K7;e++)if(!q7.test(s[e+1])&&q7.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-K7;e--)if(!q7.test(s[e-1])&&q7.test(s[e])){s=s.slice(0,e);break}}return k2.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var zse=k2.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`}}),Bse=[N7,gX.low(Nse),zse],Y7=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=z6(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(e9(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 X7(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 Vse(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=X7(t)+X7(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function Z7(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:Vse(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function Hse(e,t){return n=>{for(let t=z6(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 Q7=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function $7(e){return e.selection.main.from}function e9(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 t9=jX.define();function Use(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:Y.cursor(s.from+a+c.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var n9=new WeakMap;function Wse(e){if(!Array.isArray(e))return e;let t=n9.get(e);return t||n9.set(e,t=Z7(e)),t}var r9=PX.define(),i9=PX.define(),Gse=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=WY(e,t),r=KY(n);this.chars.push(n);let i=e.slice(t,t+r),a=i.toUpperCase();this.folded.push(WY(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=WY(e,0),i=KY(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=WY(e,i);(a==t[c]||a==n[c])&&(r[c++]=i),i+=KY(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=WY(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=GY(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+=KY(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?KY(WY(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)}},Kse=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)}},a9=oX.define({combine(e){return XX(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:qse,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=>o9(e(n),t(n)),optionClass:(e,t)=>n=>o9(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function o9(e,t){return e?t?e+` `+t:e:t}function qse(e,t,n,r,i,a){let o=e.textDirection==NQ.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 s9=PX.define();function Jse(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 c9(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 Yse=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(a9);this.optionContent=Jse(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=c9(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:s9.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(a9).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:i9.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=c9(r.length,i,e.state.facet(a9).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=c9(t.options.length,t.selected,this.view.state.facet(a9).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=>_$(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&&Zse(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(a9).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 Xse(e,t){return n=>new Yse(n,e,t)}function Zse(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 l9(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+ +!!e.type}function Qse(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(a9);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 Q7(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new Kse(n):new Gse(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 Q7(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):l9(e.completion)>l9(c)&&(s[s.length-1]=e),c=e.completion}return s}var $se=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,u9(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=Qse(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(a9).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,u9(r,c),{pos:t.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:oce,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)}},ece=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e(ice,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(a9),i=(r.override||n.languageDataAt(`autocomplete`,$7(n)).map(Wse)).map(e=>(this.active.find(t=>t.source==e)||new f9(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(m9));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!tce(i,this.active)||o?a=$se.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 f9(e.source,0):e));for(let e of t.effects)e.is(s9)&&(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?nce:rce}};function tce(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 nce={"aria-autocomplete":`list`},rce={};function u9(e,t){let n={"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-controls":e};return t>-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var ice=[];function d9(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(t9);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 f9=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=d9(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(r9))i=new e(i.source,1,n.value);else if(n.is(i9))i=new e(i.source,0);else if(n.is(m9))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($7(e.state))}},p9=class e extends f9{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=$7(t.state);if(o>a||!r||n&2&&($7(t.startState)==this.from||o<this.limit))return new f9(this.source,n&4?1:0);let s=t.changes.mapPos(this.limit);return ace(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 Y7(t.state,o,!1)))?new e(this.source,this.explicit,s,r,r.from,r.to??$7(t.state)):new f9(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 f9(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function ace(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e==`function`?e(i,n,r,t):e9(e,!0).test(i)}var m9=PX.define({map(e,t){return e.map(e=>e.map(t))}}),h9=pX.define({create(){return ece.start()},update(e,t){return e.update(t)},provide:e=>[N4.from(e,e=>e.tooltip),k2.contentAttributes.from(e,e=>e.attrs)]});function g9(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(h9).active.find(e=>e.source==t.source);return r instanceof p9?(typeof n==`string`?e.dispatch({...Use(e.state,n,r.from,r.to),annotations:t9.of(t.completion)}):n(e,t.completion,r.from,r.to),!0):!1}var oce=Xse(h9,g9);function _9(e,t=`option`){return n=>{let r=n.state.field(h9,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(a9).interactionDelay)return!1;let i=1,a;t==`page`&&(a=P4(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:s9.of(s)}),!0}}var sce=e=>{let t=e.state.field(h9,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(a9).interactionDelay?!1:g9(e,t.open.options[t.open.selected])},v9=e=>e.state.field(h9,!1)?(e.dispatch({effects:r9.of(!0)}),!0):!1,cce=e=>{let t=e.state.field(h9,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:i9.of(null)}),!0)},lce=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},uce=50,dce=1e3,fce=x$.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(h9).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(h9),n=e.state.facet(a9);if(!e.selectionSet&&!e.docChanged&&e.startState.field(h9)==t)return;let r=e.transactions.some(e=>{let t=d9(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>uce&&Date.now()-n.time>dce){for(let e of n.context.abortListeners)try{e()}catch(e){_$(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(r9)))&&(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(h9);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(a9).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=new Y7(t,$7(t),e.explicit,this.view),r=new lce(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:i9.of(null)}),_$(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(a9).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(a9),n=this.view.state.field(h9);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=$7(i.updates.length?i.updates[0].startState:this.view.state),r=Math.min(n,i.done.from+ +!i.active.explicit),a=new p9(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 f9(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:m9.of(e)})}},{eventHandlers:{blur(e){let t=this.view.state.field(h9,!1);if(t&&t.tooltip&&this.view.state.facet(a9).closeOnBlur){let n=t.open&&P4(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:i9.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:r9.of(!1)}),20),this.composing=0}}}),pce=typeof navigator==`object`&&/Win/.test(navigator.platform),mce=gX.highest(k2.domEventHandlers({keydown(e,t){let n=t.state.field(h9,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(pce&&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&&g9(t,r),!1}})),y9=k2.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`}}}),hce=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},gce=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(t){let n=t.mapPos(this.from,-1,JY.TrackDel),r=t.mapPos(this.to,1,JY.TrackDel);return n==null||r==null?null:new e(this.field,n,r)}},_ce=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(J6);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 gce(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 hce(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)}},vce=$Z.widget({widget:new class extends ZZ{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),yce=$Z.mark({class:`cm-snippetField`}),b9=class e{constructor(e,t){this.ranges=e,this.active=t,this.deco=$Z.set(e.map(e=>(e.from==e.to?vce:yce).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))}},x9=PX.define({map(e,t){return e&&e.map(t)}}),bce=PX.define(),S9=pX.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(x9))return n.value;if(n.is(bce)&&e)return new b9(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=>k2.decorations.from(e,e=>e?e.deco:$Z.none)});function C9(e,t){return Y.create(e.filter(e=>e.field==t).map(e=>Y.range(e.from,e.to)))}function xce(e){let t=_ce.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:AY.of(a)},scrollIntoView:!0,annotations:n?[t9.of(n),FX.userEvent.of(`input.complete`)]:void 0};if(o.length&&(c.selection=C9(o,0)),o.some(e=>e.field>0)){let t=new b9(o,0),n=c.effects=[x9.of(t)];e.state.field(S9,!1)===void 0&&n.push(PX.appendConfig.of([S9,Cce,Tce,y9]))}e.dispatch(e.state.update(c))}}function w9(e){return({state:t,dispatch:n})=>{let r=t.field(S9,!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:C9(r.ranges,i),effects:x9.of(a?null:new b9(r.ranges,i)),scrollIntoView:!0})),!0}}var Sce=[{key:`Tab`,run:w9(1),shift:w9(-1)},{key:`Escape`,run:({state:e,dispatch:t})=>e.field(S9,!1)?(t(e.update({effects:x9.of(null)})),!0):!1}],T9=oX.define({combine(e){return e.length?e[0]:Sce}}),Cce=gX.highest(R2.compute([T9],e=>e.facet(T9)));function wce(e,t){return{...t,apply:xce(e)}}var Tce=k2.domEventHandlers({mousedown(e,t){let n=t.state.field(S9,!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:C9(n.ranges,i.field),effects:x9.of(n.ranges.some(e=>e.field>i.field)?new b9(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),E9={brackets:[`(`,`[`,`{`,`'`,`"`],before:`)]}:;>`,stringPrefixes:[]},D9=PX.define({map(e,t){return t.mapPos(e,-1,JY.TrackAfter)??void 0}}),O9=new class extends ZX{};O9.startSide=1,O9.endSide=-1;var k9=pX.define({create(){return nZ.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(D9)&&(e=e.update({add:[O9.range(n.value,n.value+1)]}));return e}});function Ece(){return[Oce,k9]}var A9=`()[]{}<>«»»«[]{}`;function j9(e){for(let t=0;t<16;t+=2)if(A9.charCodeAt(t)==e)return A9.charAt(t+1);return GY(e<128?e:e+1)}function M9(e,t){return e.languageDataAt(`closeBrackets`,t)[0]||E9}var Dce=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),Oce=k2.inputHandler.of((e,t,n,r)=>{if((Dce?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&KY(WY(r,0))==1||t!=i.from||n!=i.to)return!1;let a=Ace(e.state,r);return a?(e.dispatch(a),!0):!1}),kce=[{key:`Backspace`,run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=M9(e,e.selection.main.head).brackets||E9.brackets,r=null,i=e.changeByRange(t=>{if(t.empty){let r=jce(e.doc,t.head);for(let i of n)if(i==r&&P9(e.doc,t.head)==j9(WY(i,0)))return{changes:{from:t.head-i.length,to:t.head+i.length},range:Y.cursor(t.head-i.length)}}return{range:r=t}});return r||t(e.update(i,{scrollIntoView:!0,userEvent:`delete.backward`})),!r}}];function Ace(e,t){let n=M9(e,e.selection.main.head),r=n.brackets||E9.brackets;for(let i of r){let a=j9(WY(i,0));if(t==i)return a==i?Pce(e,i,r.indexOf(i+i+i)>-1,n):Mce(e,i,a,n.before||E9.before);if(t==a&&N9(e,e.selection.main.from))return Nce(e,i,a)}return null}function N9(e,t){let n=!1;return e.field(k9).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function P9(e,t){let n=e.sliceString(t,t+2);return n.slice(0,KY(WY(n,0)))}function jce(e,t){let n=e.sliceString(t-2,t);return KY(WY(n,0))==n.length?n:n.slice(1)}function Mce(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:D9.of(a.to+t.length),range:Y.range(a.anchor+t.length,a.head+t.length)};let o=P9(e.doc,a.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:D9.of(a.head+t.length),range:Y.cursor(a.head+t.length)}:{range:i=a}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:`input.type`})}function Nce(e,t,n){let r=null,i=e.changeByRange(t=>t.empty&&P9(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:Y.cursor(t.head+n.length)}:r={range:t});return r?null:e.update(i,{scrollIntoView:!0,userEvent:`input.type`})}function Pce(e,t,n,r){let i=r.stringPrefixes||E9.stringPrefixes,a=null,o=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:D9.of(r.to+t.length),range:Y.range(r.anchor+t.length,r.head+t.length)};let o=r.head,s=P9(e.doc,o),c;if(s==t){if(F9(e,o))return{changes:{insert:t+t,from:o},effects:D9.of(o+t.length),range:Y.cursor(o+t.length)};if(N9(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:Y.cursor(o+r.length)}}}else if(n&&e.sliceDoc(o-2*t.length,o)==t+t&&(c=I9(e,o-2*t.length,i))>-1&&F9(e,c))return{changes:{insert:t+t+t+t,from:o},effects:D9.of(o+t.length),range:Y.cursor(o+t.length)};else if(e.charCategorizer(o)(s)!=WX.Word&&I9(e,o,i)>-1&&!Fce(e,o,t,i))return{changes:{insert:t+t,from:o},effects:D9.of(o+t.length),range:Y.cursor(o+t.length)};return{range:a=r}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:`input.type`})}function F9(e,t){let n=z6(e).resolveInner(t+1);return n.parent&&n.from==t}function Fce(e,t,n,r){let i=z6(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 I9(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=WX.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))!=WX.Word)return n}return-1}function Ice(e={}){return[mce,h9,a9.of(e),fce,Lce,y9]}var L9=[{key:`Ctrl-Space`,run:v9},{mac:"Alt-`",run:v9},{mac:`Alt-i`,run:v9},{key:`Escape`,run:cce},{key:`ArrowDown`,run:_9(!0)},{key:`ArrowUp`,run:_9(!1)},{key:`PageDown`,run:_9(!0,`page`)},{key:`PageUp`,run:_9(!1,`page`)},{key:`Enter`,run:sce}],Lce=gX.highest(R2.computeN([a9],e=>e.facet(a9).defaultKeymap?[L9]:[]));function $(e){return new q6(Bae.define(e))}function R9(e){return J(()=>import(`./dist-2TJ1ZCOL.js`).then(t=>t.sql({dialect:t[e]})),__vite__mapDeps([7,8]),import.meta.url)}var Rce=[Q.of({name:`C`,extensions:[`c`,`h`,`ino`],load(){return J(()=>import(`./dist-DKoNUyW5.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 J(()=>import(`./dist-DKoNUyW5.js`).then(e=>e.cpp()),__vite__mapDeps([9,8]),import.meta.url)}}),Q.of({name:`CQL`,alias:[`cassandra`],extensions:[`cql`],load(){return R9(`Cassandra`)}}),Q.of({name:`CSS`,extensions:[`css`],load(){return J(()=>import(`./dist-DYNUYmYr.js`).then(e=>e.i).then(e=>e.css()),__vite__mapDeps([10,8]),import.meta.url)}}),Q.of({name:`Go`,extensions:[`go`],load(){return J(()=>import(`./dist-ZHG09ibd.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 J(()=>import(`./dist-Bi-CzopW.js`).then(e=>e.html()),__vite__mapDeps([12,10,8,13]),import.meta.url)}}),Q.of({name:`Java`,extensions:[`java`],load(){return J(()=>import(`./dist-DDKMMWtJ.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 J(()=>import(`./dist-a8wIzj7Z.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 J(()=>import(`./dist-C7sM-UN3.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 J(()=>import(`./dist-8jyOcR4w.js`).then(e=>e.json()),__vite__mapDeps([16,8]),import.meta.url)}}),Q.of({name:`JSX`,extensions:[`jsx`],load(){return J(()=>import(`./dist-a8wIzj7Z.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 J(()=>import(`./dist-CZYb4PF9.js`).then(e=>e.less()),__vite__mapDeps([17,10,8]),import.meta.url)}}),Q.of({name:`Liquid`,extensions:[`liquid`],load(){return J(()=>import(`./dist-vvj-wd6e.js`).then(e=>e.liquid()),__vite__mapDeps([18,12,10,8,13]),import.meta.url)}}),Q.of({name:`MariaDB SQL`,load(){return R9(`MariaSQL`)}}),Q.of({name:`Markdown`,extensions:[`md`,`markdown`,`mkd`],load(){return J(()=>import(`./dist-CqqLUjBZ.js`).then(e=>e.markdown()),__vite__mapDeps([19,12,10,8,13]),import.meta.url)}}),Q.of({name:`MS SQL`,load(){return R9(`MSSQL`)}}),Q.of({name:`MySQL`,load(){return R9(`MySQL`)}}),Q.of({name:`PHP`,extensions:[`php`,`php3`,`php4`,`php5`,`php7`,`phtml`],load(){return J(()=>import(`./dist-BEyTkcDY.js`).then(e=>e.php()),__vite__mapDeps([20,12,10,8,13]),import.meta.url)}}),Q.of({name:`PLSQL`,extensions:[`pls`],load(){return R9(`PLSQL`)}}),Q.of({name:`PostgreSQL`,load(){return R9(`PostgreSQL`)}}),Q.of({name:`Python`,extensions:[`BUILD`,`bzl`,`py`,`pyw`],filename:/^(BUCK|BUILD)$/,load(){return J(()=>import(`./dist-smDVDmJ_.js`).then(e=>e.python()),__vite__mapDeps([21,8]),import.meta.url)}}),Q.of({name:`Rust`,extensions:[`rs`],load(){return J(()=>import(`./dist-Dq-1VFQW.js`).then(e=>e.rust()),__vite__mapDeps([22,8]),import.meta.url)}}),Q.of({name:`Sass`,extensions:[`sass`],load(){return J(()=>import(`./dist-n_EDf0JP.js`).then(e=>e.sass({indented:!0})),__vite__mapDeps([23,10,8]),import.meta.url)}}),Q.of({name:`SCSS`,extensions:[`scss`],load(){return J(()=>import(`./dist-n_EDf0JP.js`).then(e=>e.sass()),__vite__mapDeps([23,10,8]),import.meta.url)}}),Q.of({name:`SQL`,extensions:[`sql`],load(){return R9(`StandardSQL`)}}),Q.of({name:`SQLite`,load(){return R9(`SQLite`)}}),Q.of({name:`TSX`,extensions:[`tsx`],load(){return J(()=>import(`./dist-a8wIzj7Z.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 J(()=>import(`./dist-a8wIzj7Z.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 J(()=>import(`./dist-I8jZ1y80.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 J(()=>import(`./dist-D1HTEtve.js`).then(e=>e.xml()),__vite__mapDeps([25,8]),import.meta.url)}}),Q.of({name:`YAML`,alias:[`yml`],extensions:[`yaml`,`yml`],load(){return J(()=>import(`./dist-DHafuXFW.js`).then(e=>e.yaml()),__vite__mapDeps([26,8]),import.meta.url)}}),Q.of({name:`APL`,extensions:[`dyalog`,`apl`],load(){return J(()=>import(`./apl-CnwPGSsG.js`).then(e=>$(e.apl)),[],import.meta.url)}}),Q.of({name:`PGP`,alias:[`asciiarmor`],extensions:[`asc`,`pgp`,`sig`],load(){return J(()=>import(`./asciiarmor-qTkVPQu6.js`).then(e=>$(e.asciiArmor)),[],import.meta.url)}}),Q.of({name:`ASN.1`,extensions:[`asn`,`asn1`],load(){return J(()=>import(`./asn1-Dr8qZg38.js`).then(e=>$(e.asn1({}))),[],import.meta.url)}}),Q.of({name:`Asterisk`,filename:/^extensions\.conf$/i,load(){return J(()=>import(`./asterisk-Bja0s6e1.js`).then(e=>$(e.asterisk)),[],import.meta.url)}}),Q.of({name:`Brainfuck`,extensions:[`b`,`bf`],load(){return J(()=>import(`./brainfuck-D5EjA2JK.js`).then(e=>$(e.brainfuck)),[],import.meta.url)}}),Q.of({name:`Cobol`,extensions:[`cob`,`cpy`],load(){return J(()=>import(`./cobol-B_OZ4V-R.js`).then(e=>$(e.cobol)),[],import.meta.url)}}),Q.of({name:`C#`,alias:[`csharp`,`cs`],extensions:[`cs`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.csharp)),[],import.meta.url)}}),Q.of({name:`Clojure`,extensions:[`clj`,`cljc`,`cljx`],load(){return J(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`ClojureScript`,extensions:[`cljs`],load(){return J(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`Closure Stylesheets (GSS)`,extensions:[`gss`],load(){return J(()=>import(`./css-CYpP4FRV.js`).then(e=>$(e.gss)),[],import.meta.url)}}),Q.of({name:`CMake`,extensions:[`cmake`,`cmake.in`],filename:/^CMakeLists\.txt$/,load(){return J(()=>import(`./cmake-CyVbuzPu.js`).then(e=>$(e.cmake)),[],import.meta.url)}}),Q.of({name:`CoffeeScript`,alias:[`coffee`,`coffee-script`],extensions:[`coffee`],load(){return J(()=>import(`./coffeescript-B2pKbFk8.js`).then(e=>$(e.coffeeScript)),[],import.meta.url)}}),Q.of({name:`Common Lisp`,alias:[`lisp`],extensions:[`cl`,`lisp`,`el`],load(){return J(()=>import(`./commonlisp-CcllspGY.js`).then(e=>$(e.commonLisp)),[],import.meta.url)}}),Q.of({name:`Cypher`,extensions:[`cyp`,`cypher`],load(){return J(()=>import(`./cypher-p9eYesGn.js`).then(e=>$(e.cypher)),[],import.meta.url)}}),Q.of({name:`Cython`,extensions:[`pyx`,`pxd`,`pxi`],load(){return J(()=>import(`./python-BqYw9LYJ.js`).then(e=>$(e.cython)),[],import.meta.url)}}),Q.of({name:`Crystal`,extensions:[`cr`],load(){return J(()=>import(`./crystal-M5-qzICs.js`).then(e=>$(e.crystal)),[],import.meta.url)}}),Q.of({name:`D`,extensions:[`d`],load(){return J(()=>import(`./d-BhMjBjQP.js`).then(e=>$(e.d)),[],import.meta.url)}}),Q.of({name:`Dart`,extensions:[`dart`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.dart)),[],import.meta.url)}}),Q.of({name:`diff`,extensions:[`diff`,`patch`],load(){return J(()=>import(`./diff-ChtP43wD.js`).then(e=>$(e.diff)),[],import.meta.url)}}),Q.of({name:`Dockerfile`,filename:/^Dockerfile$/,load(){return J(()=>import(`./dockerfile-BLkNEvjs.js`).then(e=>$(e.dockerFile)),__vite__mapDeps([27,28]),import.meta.url)}}),Q.of({name:`DTD`,extensions:[`dtd`],load(){return J(()=>import(`./dtd-DTF72YNO.js`).then(e=>$(e.dtd)),[],import.meta.url)}}),Q.of({name:`Dylan`,extensions:[`dylan`,`dyl`,`intr`],load(){return J(()=>import(`./dylan-C6jEEEk-.js`).then(e=>$(e.dylan)),[],import.meta.url)}}),Q.of({name:`EBNF`,load(){return J(()=>import(`./ebnf-D4c0_ac3.js`).then(e=>$(e.ebnf)),[],import.meta.url)}}),Q.of({name:`ECL`,extensions:[`ecl`],load(){return J(()=>import(`./ecl-BSZaIHnp.js`).then(e=>$(e.ecl)),[],import.meta.url)}}),Q.of({name:`edn`,extensions:[`edn`],load(){return J(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`Eiffel`,extensions:[`e`],load(){return J(()=>import(`./eiffel-BEjRio4Q.js`).then(e=>$(e.eiffel)),[],import.meta.url)}}),Q.of({name:`Elm`,extensions:[`elm`],load(){return J(()=>import(`./elm-Cshzl8qu.js`).then(e=>$(e.elm)),[],import.meta.url)}}),Q.of({name:`Erlang`,extensions:[`erl`],load(){return J(()=>import(`./erlang-DaB2Rkuy.js`).then(e=>$(e.erlang)),[],import.meta.url)}}),Q.of({name:`Esper`,load(){return J(()=>import(`./sql-DcCJ9jop.js`).then(e=>$(e.esper)),[],import.meta.url)}}),Q.of({name:`Factor`,extensions:[`factor`],load(){return J(()=>import(`./factor-D7LVTn2l.js`).then(e=>$(e.factor)),__vite__mapDeps([29,28]),import.meta.url)}}),Q.of({name:`FCL`,load(){return J(()=>import(`./fcl-ClOhbFR7.js`).then(e=>$(e.fcl)),[],import.meta.url)}}),Q.of({name:`Forth`,extensions:[`forth`,`fth`,`4th`],load(){return J(()=>import(`./forth-Cezjo90N.js`).then(e=>$(e.forth)),[],import.meta.url)}}),Q.of({name:`Fortran`,extensions:[`f`,`for`,`f77`,`f90`,`f95`],load(){return J(()=>import(`./fortran-Bt6PBEDR.js`).then(e=>$(e.fortran)),[],import.meta.url)}}),Q.of({name:`F#`,alias:[`fsharp`],extensions:[`fs`],load(){return J(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.fSharp)),[],import.meta.url)}}),Q.of({name:`Gas`,extensions:[`s`],load(){return J(()=>import(`./gas-BHEdbvp9.js`).then(e=>$(e.gas)),[],import.meta.url)}}),Q.of({name:`Gherkin`,extensions:[`feature`],load(){return J(()=>import(`./gherkin-oBAE_ms0.js`).then(e=>$(e.gherkin)),[],import.meta.url)}}),Q.of({name:`Groovy`,extensions:[`groovy`,`gradle`],filename:/^Jenkinsfile$/,load(){return J(()=>import(`./groovy-BC3IOsC8.js`).then(e=>$(e.groovy)),[],import.meta.url)}}),Q.of({name:`Haskell`,extensions:[`hs`],load(){return J(()=>import(`./haskell-BRsoo5mP.js`).then(e=>$(e.haskell)),[],import.meta.url)}}),Q.of({name:`Haxe`,extensions:[`hx`],load(){return J(()=>import(`./haxe-DIz0ZZqd.js`).then(e=>$(e.haxe)),[],import.meta.url)}}),Q.of({name:`HXML`,extensions:[`hxml`],load(){return J(()=>import(`./haxe-DIz0ZZqd.js`).then(e=>$(e.hxml)),[],import.meta.url)}}),Q.of({name:`HTTP`,load(){return J(()=>import(`./http-CLVgA2GD.js`).then(e=>$(e.http)),[],import.meta.url)}}),Q.of({name:`IDL`,extensions:[`pro`],load(){return J(()=>import(`./idl-BUZw3wgd.js`).then(e=>$(e.idl)),[],import.meta.url)}}),Q.of({name:`JSON-LD`,alias:[`jsonld`],extensions:[`jsonld`],load(){return J(()=>import(`./javascript-9Tg8ixDm.js`).then(e=>$(e.jsonld)),[],import.meta.url)}}),Q.of({name:`Julia`,extensions:[`jl`],load(){return J(()=>import(`./julia-CQfgDRfP.js`).then(e=>$(e.julia)),[],import.meta.url)}}),Q.of({name:`Kotlin`,extensions:[`kt`,`kts`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.kotlin)),[],import.meta.url)}}),Q.of({name:`LiveScript`,alias:[`ls`],extensions:[`ls`],load(){return J(()=>import(`./livescript-BXxG0Yva.js`).then(e=>$(e.liveScript)),[],import.meta.url)}}),Q.of({name:`Lua`,extensions:[`lua`],load(){return J(()=>import(`./lua-CiA1ziua.js`).then(e=>$(e.lua)),[],import.meta.url)}}),Q.of({name:`mIRC`,extensions:[`mrc`],load(){return J(()=>import(`./mirc-C9zpzAZU.js`).then(e=>$(e.mirc)),[],import.meta.url)}}),Q.of({name:`Mathematica`,extensions:[`m`,`nb`,`wl`,`wls`],load(){return J(()=>import(`./mathematica-u8YMmbU0.js`).then(e=>$(e.mathematica)),[],import.meta.url)}}),Q.of({name:`Modelica`,extensions:[`mo`],load(){return J(()=>import(`./modelica-CqHI_q-D.js`).then(e=>$(e.modelica)),[],import.meta.url)}}),Q.of({name:`MUMPS`,extensions:[`mps`],load(){return J(()=>import(`./mumps-CW_TBmxz.js`).then(e=>$(e.mumps)),[],import.meta.url)}}),Q.of({name:`Mbox`,extensions:[`mbox`],load(){return J(()=>import(`./mbox-BEMVcqjs.js`).then(e=>$(e.mbox)),[],import.meta.url)}}),Q.of({name:`Nginx`,filename:/nginx.*\.conf$/i,load(){return J(()=>import(`./nginx-BMaDbqW3.js`).then(e=>$(e.nginx)),[],import.meta.url)}}),Q.of({name:`NSIS`,extensions:[`nsh`,`nsi`],load(){return J(()=>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 J(()=>import(`./ntriples-d28e9m0E.js`).then(e=>$(e.ntriples)),[],import.meta.url)}}),Q.of({name:`Objective-C`,alias:[`objective-c`,`objc`],extensions:[`m`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.objectiveC)),[],import.meta.url)}}),Q.of({name:`Objective-C++`,alias:[`objective-c++`,`objc++`],extensions:[`mm`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.objectiveCpp)),[],import.meta.url)}}),Q.of({name:`OCaml`,extensions:[`ml`,`mli`,`mll`,`mly`],load(){return J(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.oCaml)),[],import.meta.url)}}),Q.of({name:`Octave`,extensions:[`m`],load(){return J(()=>import(`./octave-D2Q8cUp1.js`).then(e=>$(e.octave)),[],import.meta.url)}}),Q.of({name:`Oz`,extensions:[`oz`],load(){return J(()=>import(`./oz-BwTct_5T.js`).then(e=>$(e.oz)),[],import.meta.url)}}),Q.of({name:`Pascal`,extensions:[`p`,`pas`],load(){return J(()=>import(`./pascal-Dp_KdFgX.js`).then(e=>$(e.pascal)),[],import.meta.url)}}),Q.of({name:`Perl`,extensions:[`pl`,`pm`],load(){return J(()=>import(`./perl-CdEHsPfU.js`).then(e=>$(e.perl)),[],import.meta.url)}}),Q.of({name:`Pig`,extensions:[`pig`],load(){return J(()=>import(`./pig-AF4Hwhju.js`).then(e=>$(e.pig)),[],import.meta.url)}}),Q.of({name:`PowerShell`,extensions:[`ps1`,`psd1`,`psm1`],load(){return J(()=>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 J(()=>import(`./properties-C357ku5U.js`).then(e=>$(e.properties)),[],import.meta.url)}}),Q.of({name:`ProtoBuf`,extensions:[`proto`],load(){return J(()=>import(`./protobuf-D1ij_kNL.js`).then(e=>$(e.protobuf)),[],import.meta.url)}}),Q.of({name:`Pug`,alias:[`jade`],extensions:[`pug`,`jade`],load(){return J(()=>import(`./pug-Bugr-47h.js`).then(e=>$(e.pug)),__vite__mapDeps([31,32]),import.meta.url)}}),Q.of({name:`Puppet`,extensions:[`pp`],load(){return J(()=>import(`./puppet-B4hC2X4m.js`).then(e=>$(e.puppet)),[],import.meta.url)}}),Q.of({name:`Q`,extensions:[`q`],load(){return J(()=>import(`./q-B9NhS7L_.js`).then(e=>$(e.q)),[],import.meta.url)}}),Q.of({name:`R`,alias:[`rscript`],extensions:[`r`,`R`],load(){return J(()=>import(`./r-DADKenSm.js`).then(e=>$(e.r)),[],import.meta.url)}}),Q.of({name:`RPM Changes`,load(){return J(()=>import(`./rpm-gpDK5sbt.js`).then(e=>$(e.rpmChanges)),[],import.meta.url)}}),Q.of({name:`RPM Spec`,extensions:[`spec`],load(){return J(()=>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 J(()=>import(`./ruby-DsYpTuWg.js`).then(e=>$(e.ruby)),[],import.meta.url)}}),Q.of({name:`SAS`,extensions:[`sas`],load(){return J(()=>import(`./sas-C2OyD2Y6.js`).then(e=>$(e.sas)),[],import.meta.url)}}),Q.of({name:`Scala`,extensions:[`scala`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.scala)),[],import.meta.url)}}),Q.of({name:`Scheme`,extensions:[`scm`,`ss`],load(){return J(()=>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 J(()=>import(`./shell-Du5Qg9im.js`).then(e=>$(e.shell)),[],import.meta.url)}}),Q.of({name:`Sieve`,extensions:[`siv`,`sieve`],load(){return J(()=>import(`./sieve-BAxa3IjF.js`).then(e=>$(e.sieve)),[],import.meta.url)}}),Q.of({name:`Smalltalk`,extensions:[`st`],load(){return J(()=>import(`./smalltalk-BLp5-jwC.js`).then(e=>$(e.smalltalk)),[],import.meta.url)}}),Q.of({name:`Solr`,load(){return J(()=>import(`./solr-BBopId9w.js`).then(e=>$(e.solr)),[],import.meta.url)}}),Q.of({name:`SML`,extensions:[`sml`,`sig`,`fun`,`smackspec`],load(){return J(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.sml)),[],import.meta.url)}}),Q.of({name:`SPARQL`,alias:[`sparul`],extensions:[`rq`,`sparql`],load(){return J(()=>import(`./sparql-Dz-mlCAC.js`).then(e=>$(e.sparql)),[],import.meta.url)}}),Q.of({name:`Spreadsheet`,alias:[`excel`,`formula`],load(){return J(()=>import(`./spreadsheet-CTIncYxj.js`).then(e=>$(e.spreadsheet)),[],import.meta.url)}}),Q.of({name:`Squirrel`,extensions:[`nut`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.squirrel)),[],import.meta.url)}}),Q.of({name:`Stylus`,extensions:[`styl`],load(){return J(()=>import(`./stylus-DLLZ8dgm.js`).then(e=>$(e.stylus)),[],import.meta.url)}}),Q.of({name:`Swift`,extensions:[`swift`],load(){return J(()=>import(`./swift-DKB6_1j6.js`).then(e=>$(e.swift)),[],import.meta.url)}}),Q.of({name:`sTeX`,load(){return J(()=>import(`./stex-sDrdk2BW.js`).then(e=>$(e.stex)),[],import.meta.url)}}),Q.of({name:`LaTeX`,alias:[`tex`],extensions:[`text`,`ltx`,`tex`],load(){return J(()=>import(`./stex-sDrdk2BW.js`).then(e=>$(e.stex)),[],import.meta.url)}}),Q.of({name:`SystemVerilog`,extensions:[`v`,`sv`,`svh`],load(){return J(()=>import(`./verilog-D-x6ne0Z.js`).then(e=>$(e.verilog)),[],import.meta.url)}}),Q.of({name:`Tcl`,extensions:[`tcl`],load(){return J(()=>import(`./tcl-BGfruO1u.js`).then(e=>$(e.tcl)),[],import.meta.url)}}),Q.of({name:`Textile`,extensions:[`textile`],load(){return J(()=>import(`./textile-DWBqthVk.js`).then(e=>$(e.textile)),[],import.meta.url)}}),Q.of({name:`TiddlyWiki`,load(){return J(()=>import(`./tiddlywiki-VlUiK86J.js`).then(e=>$(e.tiddlyWiki)),[],import.meta.url)}}),Q.of({name:`Tiki wiki`,load(){return J(()=>import(`./tiki-CxVlf5KZ.js`).then(e=>$(e.tiki)),[],import.meta.url)}}),Q.of({name:`TOML`,extensions:[`toml`],load(){return J(()=>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 J(()=>import(`./troff-C2dAgh7P.js`).then(e=>$(e.troff)),[],import.meta.url)}}),Q.of({name:`TTCN`,extensions:[`ttcn`,`ttcn3`,`ttcnpp`],load(){return J(()=>import(`./ttcn-BePYh-hG.js`).then(e=>$(e.ttcn)),[],import.meta.url)}}),Q.of({name:`TTCN_CFG`,extensions:[`cfg`],load(){return J(()=>import(`./ttcn-cfg-CY0aot7Q.js`).then(e=>$(e.ttcnCfg)),[],import.meta.url)}}),Q.of({name:`Turtle`,extensions:[`ttl`],load(){return J(()=>import(`./turtle-BDLWE2cD.js`).then(e=>$(e.turtle)),[],import.meta.url)}}),Q.of({name:`Web IDL`,extensions:[`webidl`],load(){return J(()=>import(`./webidl-D5jiJvOU.js`).then(e=>$(e.webIDL)),[],import.meta.url)}}),Q.of({name:`VB.NET`,extensions:[`vb`],load(){return J(()=>import(`./vb-BthdM_4N.js`).then(e=>$(e.vb)),[],import.meta.url)}}),Q.of({name:`VBScript`,extensions:[`vbs`],load(){return J(()=>import(`./vbscript-D9f6rSsU.js`).then(e=>$(e.vbScript)),[],import.meta.url)}}),Q.of({name:`Velocity`,extensions:[`vtl`],load(){return J(()=>import(`./velocity-CqftRsjg.js`).then(e=>$(e.velocity)),[],import.meta.url)}}),Q.of({name:`Verilog`,extensions:[`v`],load(){return J(()=>import(`./verilog-D-x6ne0Z.js`).then(e=>$(e.verilog)),[],import.meta.url)}}),Q.of({name:`VHDL`,extensions:[`vhd`,`vhdl`],load(){return J(()=>import(`./vhdl-CMrOq2q1.js`).then(e=>$(e.vhdl)),[],import.meta.url)}}),Q.of({name:`XQuery`,extensions:[`xy`,`xquery`,`xq`,`xqm`,`xqy`],load(){return J(()=>import(`./xquery-fj_R-kMw.js`).then(e=>$(e.xQuery)),[],import.meta.url)}}),Q.of({name:`Yacas`,extensions:[`ys`],load(){return J(()=>import(`./yacas-CXXgtw0p.js`).then(e=>$(e.yacas)),[],import.meta.url)}}),Q.of({name:`Z80`,extensions:[`z80`],load(){return J(()=>import(`./z80-CL1naaMV.js`).then(e=>$(e.z80)),[],import.meta.url)}}),Q.of({name:`MscGen`,extensions:[`mscgen`,`mscin`,`msc`],load(){return J(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.mscgen)),[],import.meta.url)}}),Q.of({name:`Xù`,extensions:[`xu`],load(){return J(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.xu)),[],import.meta.url)}}),Q.of({name:`MsGenny`,extensions:[`msgenny`],load(){return J(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.msgenny)),[],import.meta.url)}}),Q.of({name:`Vue`,extensions:[`vue`],load(){return J(()=>import(`./dist-Cp7irw0l.js`).then(e=>e.vue()),__vite__mapDeps([33,12,10,8,13]),import.meta.url)}}),Q.of({name:`Angular Template`,load(){return J(()=>import(`./dist-A2T1KeTr.js`).then(e=>e.angular()),__vite__mapDeps([34,12,10,8,13]),import.meta.url)}})];function z9(e){let t=String(e||``).split(`/`).pop()||``,n=t.lastIndexOf(`.`);return n>=0?t.slice(n):``}function B9(e){return Q.matchFilename(Rce,`file${e}`)}function V9({content:e,path:t,readOnly:n=!1,onSave:r,onDirtyChange:i,onContentChange:a,getContentRef:o}){let s=(0,v.useRef)(null),c=(0,v.useRef)(null),l=(0,v.useRef)(new vX),u=(0,v.useRef)(new vX),d=(0,v.useRef)(new vX),f=(0,v.useRef)(!1),p=(0,v.useRef)(r),m=(0,v.useRef)(i),h=(0,v.useRef)(a);(0,v.useEffect)(()=>{p.current=r,m.current=i,h.current=a},[r,i,a]);let g=(0,v.useCallback)(e=>{f.current!==e&&(f.current=e,m.current?.(e))},[]);return(0,v.useEffect)(()=>{if(!s.current)return;let r=document.documentElement.classList.contains(`dark`),i=R2.of([{key:`Mod-s`,run:e=>{let t=e.state.doc.toString();return p.current?.(t),g(!1),!0},preventDefault:!0}]),a=new k2({state:YX.create({doc:e,extensions:[p3(),_3(),toe(),Tae(),n4(),d4(),YX.allowMultipleSelections.of(!0),mae(),C8(kae,{fallback:!0}),Fae(),Ece(),Ice(),b4(),C4(),f4(),gse(),R2.of([...kce,...rse,...Lse,...uoe,...xae,...L9,ise]),i,k2.updateListener.of(e=>{e.docChanged&&(g(!0),h.current?.(e.state.doc.toString()))}),d.current.of(YX.readOnly.of(n)),l.current.of([]),u.current.of(r?f7:[]),k2.theme({"&":{height:`100%`},".cm-scroller":{overflow:`auto`}})]}),parent:s.current});c.current=a,o&&(o.current=()=>a.state.doc.toString());let f=B9(z9(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,v.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,v.useEffect)(()=>{let e=c.current;if(!e)return;let n=B9(z9(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,v.useEffect)(()=>{let e=c.current;e&&e.dispatch({effects:d.current.reconfigure(YX.readOnly.of(n))})},[n]),(0,v.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?f7:[])})});return e.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>e.disconnect()},[]),(0,k.jsx)(`div`,{ref:s,className:`h-full w-full overflow-hidden [&_.cm-editor]:h-full [&_.cm-scroller]:auto`})}function H9({content:e,objectUrl:t,kind:n,filename:r,path:i}){return n===`markdown`?(0,k.jsx)(Aq,{content:e||``}):n===`image`&&t?(0,k.jsx)(`div`,{className:`flex items-center justify-center p-4`,children:(0,k.jsx)(`img`,{src:t,alt:r,className:`max-h-[70vh] max-w-full rounded object-contain`})}):n===`pdf`&&t?(0,k.jsx)(`iframe`,{src:t,title:r,className:`h-full w-full border-0`}):(n===`text`||n===`code`)&&e!==null?(0,k.jsx)(V9,{content:e,path:i||r,readOnly:!0,onSave:()=>{},onDirtyChange:()=>{},getContentRef:{current:()=>e||``}}):(0,k.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,k.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 U9(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`)}function zce(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 W9(...e){return Array.from(new Set(e.filter(e=>!!e))).join(` `)}function Bce(e){let t=e?zce(e):void 0,n=W9(`'unsafe-inline'`,`'unsafe-eval'`,`'self'`,`https:`,t),r=W9(`'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 Vce(e){try{let t=new URL(e,window.location.href);return[`http:`,`https:`,`mailto:`].includes(t.protocol)}catch{return!1}}function G9(e,t={}){let{channelId:n,basePath:r}=typeof t==`string`?{channelId:t}:t,i=Bce(r),a=`<script>
|
|
212
|
+
`: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 Ase(this):new Dse(this)}getCursor(e,t=0,n){let r=e.doc?e:YX.create({doc:e});return n??=r.doc.length,this.regexp?O7(this,r,t,n):D7(this,r,t,n)}},E7=class{constructor(e){this.spec=e}};function Tse(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 D7(e,t,n,r){let i;return e.wholeWord&&(i=Ese(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=Tse(e.test,t,i)),new m7(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function Ese(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(k7(i,n-a))!=WX.Word||t(A7(i,n-a))!=WX.Word)&&(t(A7(i,r-a))!=WX.Word||t(k7(i,r-a))!=WX.Word))}var Dse=class extends E7{constructor(e){super(e)}nextMatch(e,t,n){let r=D7(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=D7(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=D7(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=D7(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=D7(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 Ose(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function O7(e,t,n,r){let i;return e.wholeWord&&(i=kse(t.charCategorizer(t.selection.main.head))),e.test&&(i=Ose(e.test,t,i)),new _7(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function k7(e,t){return e.slice(VY(e,t,!1),t)}function A7(e,t){return e.slice(t,VY(e,t))}function kse(e){return(t,n,r)=>!r[0].length||(e(k7(r.input,r.index))!=WX.Word||e(A7(r.input,r.index))!=WX.Word)&&(e(A7(r.input,r.index+r[0].length))!=WX.Word||e(k7(r.input,r.index+r[0].length))!=WX.Word)}var Ase=class extends E7{nextMatch(e,t,n){let r=O7(this.spec,e,n,e.doc.length).next();return r.done&&(r=O7(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=O7(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=O7(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=O7(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)}},j7=PX.define(),M7=PX.define(),N7=pX.define({create(e){return new P7(B7(e).create(),null)},update(e,t){for(let n of t.effects)n.is(j7)?e=new P7(n.value.create(),e.panel):n.is(M7)&&(e=new P7(e.query,n.value?z7:null));return e},provide:e=>B4.from(e,e=>e.panel)}),P7=class{constructor(e,t){this.query=e,this.panel=t}},jse=$Z.mark({class:`cm-searchMatch`}),Mse=$Z.mark({class:`cm-searchMatch cm-searchMatch-selected`}),Nse=x$.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(N7))}update(e){let t=e.state.field(N7);(t!=e.startState.field(N7)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return $Z.none;let{view:n}=this,r=new iZ;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?Mse:jse)})}return r.finish()}},{decorations:e=>e.decorations});function F7(e){return t=>{let n=t.state.field(N7,!1);return n&&n.query.spec.valid?e(t,n):U7(t)}}var I7=F7((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=Y.single(r.from,r.to),a=e.state.facet(w7);return e.dispatch({selection:i,effects:[J7(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),H7(e),!0}),L7=F7((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=Y.single(i.from,i.to),o=e.state.facet(w7);return e.dispatch({selection:a,effects:[J7(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),H7(e),!0}),Pse=F7((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:Y.create(n.map(e=>Y.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),Fse=({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 m7(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(Y.range(t.value.from,t.value.to))}return t(e.update({selection:Y.create(a,o),userEvent:`select.search.matches`})),!0},R7=F7((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(k2.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=Y.single(o.from,o.to).map(d),u.push(J7(e,o)),u.push(n.facet(w7).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),Ise=F7((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:k2.announce.of(r),userEvent:`input.replace.all`}),!0});function z7(e){return e.state.facet(w7).createPanel(e)}function B7(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(w7);return new T7({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 V7(e){let t=I4(e,z7);return t&&t.dom.querySelector(`[main-field]`)}function H7(e){let t=V7(e);t&&t==e.root.activeElement&&t.select()}var U7=e=>{let t=e.state.field(N7,!1);if(t&&t.panel){let n=V7(e);if(n&&n!=e.root.activeElement){let r=B7(e.state,t.query.spec);r.valid&&e.dispatch({effects:j7.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[M7.of(!0),t?j7.of(B7(e.state,t.query.spec)):PX.appendConfig.of(Bse)]});return!0},W7=e=>{let t=e.state.field(N7,!1);if(!t||!t.panel)return!1;let n=I4(e,z7);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:M7.of(!1)}),!0},Lse=[{key:`Mod-f`,run:U7,scope:`editor search-panel`},{key:`F3`,run:I7,shift:L7,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:I7,shift:L7,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:W7,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:Fse},{key:`Mod-Alt-g`,run:mse},{key:`Mod-d`,run:wse,preventDefault:!0}],Rse=class{constructor(e){this.view=e;let t=this.query=e.state.field(N7).query.spec;this.commit=this.commit.bind(this),this.searchField=jZ(`input`,{value:t.search,placeholder:G7(e,`Find`),"aria-label":G7(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=jZ(`input`,{value:t.replace,placeholder:G7(e,`Replace`),"aria-label":G7(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=jZ(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=jZ(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=jZ(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return jZ(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=jZ(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>I7(e),[G7(e,`next`)]),n(`prev`,()=>L7(e),[G7(e,`previous`)]),n(`select`,()=>Pse(e),[G7(e,`all`)]),jZ(`label`,null,[this.caseField,G7(e,`match case`)]),jZ(`label`,null,[this.reField,G7(e,`regexp`)]),jZ(`label`,null,[this.wordField,G7(e,`by word`)]),...e.state.readOnly?[]:[jZ(`br`),this.replaceField,n(`replace`,()=>R7(e),[G7(e,`replace`)]),n(`replaceAll`,()=>Ise(e),[G7(e,`replace all`)])],jZ(`button`,{name:`close`,onclick:()=>W7(e),"aria-label":G7(e,`close`),type:`button`},[`×`])])}commit(){let e=new T7({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:j7.of(e)}))}keydown(e){V2(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?L7:I7)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),R7(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(j7)&&!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(w7).top}};function G7(e,t){return e.state.phrase(t)}var K7=30,q7=/[\s\.,:;?!]/;function J7(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-K7),o=Math.min(i,n+K7),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<K7;e++)if(!q7.test(s[e+1])&&q7.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-K7;e--)if(!q7.test(s[e-1])&&q7.test(s[e])){s=s.slice(0,e);break}}return k2.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var zse=k2.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`}}),Bse=[N7,gX.low(Nse),zse],Y7=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=z6(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(e9(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 X7(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 Vse(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=X7(t)+X7(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function Z7(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:Vse(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function Hse(e,t){return n=>{for(let t=z6(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 Q7=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function $7(e){return e.selection.main.from}function e9(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 t9=jX.define();function Use(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:Y.cursor(s.from+a+c.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var n9=new WeakMap;function Wse(e){if(!Array.isArray(e))return e;let t=n9.get(e);return t||n9.set(e,t=Z7(e)),t}var r9=PX.define(),i9=PX.define(),Gse=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=WY(e,t),r=KY(n);this.chars.push(n);let i=e.slice(t,t+r),a=i.toUpperCase();this.folded.push(WY(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=WY(e,0),i=KY(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=WY(e,i);(a==t[c]||a==n[c])&&(r[c++]=i),i+=KY(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=WY(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=GY(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+=KY(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?KY(WY(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)}},Kse=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)}},a9=oX.define({combine(e){return XX(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:qse,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=>o9(e(n),t(n)),optionClass:(e,t)=>n=>o9(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function o9(e,t){return e?t?e+` `+t:e:t}function qse(e,t,n,r,i,a){let o=e.textDirection==NQ.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 s9=PX.define();function Jse(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 c9(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 Yse=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(a9);this.optionContent=Jse(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=c9(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:s9.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(a9).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:i9.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=c9(r.length,i,e.state.facet(a9).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=c9(t.options.length,t.selected,this.view.state.facet(a9).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=>_$(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&&Zse(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(a9).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 Xse(e,t){return n=>new Yse(n,e,t)}function Zse(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 l9(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+ +!!e.type}function Qse(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(a9);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 Q7(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new Kse(n):new Gse(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 Q7(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):l9(e.completion)>l9(c)&&(s[s.length-1]=e),c=e.completion}return s}var $se=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,u9(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=Qse(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(a9).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,u9(r,c),{pos:t.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:oce,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)}},ece=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e(ice,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(a9),i=(r.override||n.languageDataAt(`autocomplete`,$7(n)).map(Wse)).map(e=>(this.active.find(t=>t.source==e)||new f9(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(m9));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!tce(i,this.active)||o?a=$se.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 f9(e.source,0):e));for(let e of t.effects)e.is(s9)&&(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?nce:rce}};function tce(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 nce={"aria-autocomplete":`list`},rce={};function u9(e,t){let n={"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-controls":e};return t>-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var ice=[];function d9(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(t9);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 f9=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=d9(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(r9))i=new e(i.source,1,n.value);else if(n.is(i9))i=new e(i.source,0);else if(n.is(m9))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($7(e.state))}},p9=class e extends f9{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=$7(t.state);if(o>a||!r||n&2&&($7(t.startState)==this.from||o<this.limit))return new f9(this.source,n&4?1:0);let s=t.changes.mapPos(this.limit);return ace(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 Y7(t.state,o,!1)))?new e(this.source,this.explicit,s,r,r.from,r.to??$7(t.state)):new f9(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 f9(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function ace(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e==`function`?e(i,n,r,t):e9(e,!0).test(i)}var m9=PX.define({map(e,t){return e.map(e=>e.map(t))}}),h9=pX.define({create(){return ece.start()},update(e,t){return e.update(t)},provide:e=>[N4.from(e,e=>e.tooltip),k2.contentAttributes.from(e,e=>e.attrs)]});function g9(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(h9).active.find(e=>e.source==t.source);return r instanceof p9?(typeof n==`string`?e.dispatch({...Use(e.state,n,r.from,r.to),annotations:t9.of(t.completion)}):n(e,t.completion,r.from,r.to),!0):!1}var oce=Xse(h9,g9);function _9(e,t=`option`){return n=>{let r=n.state.field(h9,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(a9).interactionDelay)return!1;let i=1,a;t==`page`&&(a=P4(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:s9.of(s)}),!0}}var sce=e=>{let t=e.state.field(h9,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(a9).interactionDelay?!1:g9(e,t.open.options[t.open.selected])},v9=e=>e.state.field(h9,!1)?(e.dispatch({effects:r9.of(!0)}),!0):!1,cce=e=>{let t=e.state.field(h9,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:i9.of(null)}),!0)},lce=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},uce=50,dce=1e3,fce=x$.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(h9).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(h9),n=e.state.facet(a9);if(!e.selectionSet&&!e.docChanged&&e.startState.field(h9)==t)return;let r=e.transactions.some(e=>{let t=d9(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>uce&&Date.now()-n.time>dce){for(let e of n.context.abortListeners)try{e()}catch(e){_$(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(r9)))&&(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(h9);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(a9).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=new Y7(t,$7(t),e.explicit,this.view),r=new lce(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:i9.of(null)}),_$(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(a9).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(a9),n=this.view.state.field(h9);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=$7(i.updates.length?i.updates[0].startState:this.view.state),r=Math.min(n,i.done.from+ +!i.active.explicit),a=new p9(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 f9(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:m9.of(e)})}},{eventHandlers:{blur(e){let t=this.view.state.field(h9,!1);if(t&&t.tooltip&&this.view.state.facet(a9).closeOnBlur){let n=t.open&&P4(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:i9.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:r9.of(!1)}),20),this.composing=0}}}),pce=typeof navigator==`object`&&/Win/.test(navigator.platform),mce=gX.highest(k2.domEventHandlers({keydown(e,t){let n=t.state.field(h9,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(pce&&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&&g9(t,r),!1}})),y9=k2.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`}}}),hce=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},gce=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(t){let n=t.mapPos(this.from,-1,JY.TrackDel),r=t.mapPos(this.to,1,JY.TrackDel);return n==null||r==null?null:new e(this.field,n,r)}},_ce=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(J6);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 gce(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 hce(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)}},vce=$Z.widget({widget:new class extends ZZ{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),yce=$Z.mark({class:`cm-snippetField`}),b9=class e{constructor(e,t){this.ranges=e,this.active=t,this.deco=$Z.set(e.map(e=>(e.from==e.to?vce:yce).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))}},x9=PX.define({map(e,t){return e&&e.map(t)}}),bce=PX.define(),S9=pX.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(x9))return n.value;if(n.is(bce)&&e)return new b9(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=>k2.decorations.from(e,e=>e?e.deco:$Z.none)});function C9(e,t){return Y.create(e.filter(e=>e.field==t).map(e=>Y.range(e.from,e.to)))}function xce(e){let t=_ce.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:AY.of(a)},scrollIntoView:!0,annotations:n?[t9.of(n),FX.userEvent.of(`input.complete`)]:void 0};if(o.length&&(c.selection=C9(o,0)),o.some(e=>e.field>0)){let t=new b9(o,0),n=c.effects=[x9.of(t)];e.state.field(S9,!1)===void 0&&n.push(PX.appendConfig.of([S9,Cce,Tce,y9]))}e.dispatch(e.state.update(c))}}function w9(e){return({state:t,dispatch:n})=>{let r=t.field(S9,!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:C9(r.ranges,i),effects:x9.of(a?null:new b9(r.ranges,i)),scrollIntoView:!0})),!0}}var Sce=[{key:`Tab`,run:w9(1),shift:w9(-1)},{key:`Escape`,run:({state:e,dispatch:t})=>e.field(S9,!1)?(t(e.update({effects:x9.of(null)})),!0):!1}],T9=oX.define({combine(e){return e.length?e[0]:Sce}}),Cce=gX.highest(R2.compute([T9],e=>e.facet(T9)));function wce(e,t){return{...t,apply:xce(e)}}var Tce=k2.domEventHandlers({mousedown(e,t){let n=t.state.field(S9,!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:C9(n.ranges,i.field),effects:x9.of(n.ranges.some(e=>e.field>i.field)?new b9(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),E9={brackets:[`(`,`[`,`{`,`'`,`"`],before:`)]}:;>`,stringPrefixes:[]},D9=PX.define({map(e,t){return t.mapPos(e,-1,JY.TrackAfter)??void 0}}),O9=new class extends ZX{};O9.startSide=1,O9.endSide=-1;var k9=pX.define({create(){return nZ.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(D9)&&(e=e.update({add:[O9.range(n.value,n.value+1)]}));return e}});function Ece(){return[Oce,k9]}var A9=`()[]{}<>«»»«[]{}`;function j9(e){for(let t=0;t<16;t+=2)if(A9.charCodeAt(t)==e)return A9.charAt(t+1);return GY(e<128?e:e+1)}function M9(e,t){return e.languageDataAt(`closeBrackets`,t)[0]||E9}var Dce=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),Oce=k2.inputHandler.of((e,t,n,r)=>{if((Dce?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&KY(WY(r,0))==1||t!=i.from||n!=i.to)return!1;let a=Ace(e.state,r);return a?(e.dispatch(a),!0):!1}),kce=[{key:`Backspace`,run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=M9(e,e.selection.main.head).brackets||E9.brackets,r=null,i=e.changeByRange(t=>{if(t.empty){let r=jce(e.doc,t.head);for(let i of n)if(i==r&&P9(e.doc,t.head)==j9(WY(i,0)))return{changes:{from:t.head-i.length,to:t.head+i.length},range:Y.cursor(t.head-i.length)}}return{range:r=t}});return r||t(e.update(i,{scrollIntoView:!0,userEvent:`delete.backward`})),!r}}];function Ace(e,t){let n=M9(e,e.selection.main.head),r=n.brackets||E9.brackets;for(let i of r){let a=j9(WY(i,0));if(t==i)return a==i?Pce(e,i,r.indexOf(i+i+i)>-1,n):Mce(e,i,a,n.before||E9.before);if(t==a&&N9(e,e.selection.main.from))return Nce(e,i,a)}return null}function N9(e,t){let n=!1;return e.field(k9).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function P9(e,t){let n=e.sliceString(t,t+2);return n.slice(0,KY(WY(n,0)))}function jce(e,t){let n=e.sliceString(t-2,t);return KY(WY(n,0))==n.length?n:n.slice(1)}function Mce(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:D9.of(a.to+t.length),range:Y.range(a.anchor+t.length,a.head+t.length)};let o=P9(e.doc,a.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:D9.of(a.head+t.length),range:Y.cursor(a.head+t.length)}:{range:i=a}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:`input.type`})}function Nce(e,t,n){let r=null,i=e.changeByRange(t=>t.empty&&P9(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:Y.cursor(t.head+n.length)}:r={range:t});return r?null:e.update(i,{scrollIntoView:!0,userEvent:`input.type`})}function Pce(e,t,n,r){let i=r.stringPrefixes||E9.stringPrefixes,a=null,o=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:D9.of(r.to+t.length),range:Y.range(r.anchor+t.length,r.head+t.length)};let o=r.head,s=P9(e.doc,o),c;if(s==t){if(F9(e,o))return{changes:{insert:t+t,from:o},effects:D9.of(o+t.length),range:Y.cursor(o+t.length)};if(N9(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:Y.cursor(o+r.length)}}}else if(n&&e.sliceDoc(o-2*t.length,o)==t+t&&(c=I9(e,o-2*t.length,i))>-1&&F9(e,c))return{changes:{insert:t+t+t+t,from:o},effects:D9.of(o+t.length),range:Y.cursor(o+t.length)};else if(e.charCategorizer(o)(s)!=WX.Word&&I9(e,o,i)>-1&&!Fce(e,o,t,i))return{changes:{insert:t+t,from:o},effects:D9.of(o+t.length),range:Y.cursor(o+t.length)};return{range:a=r}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:`input.type`})}function F9(e,t){let n=z6(e).resolveInner(t+1);return n.parent&&n.from==t}function Fce(e,t,n,r){let i=z6(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 I9(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=WX.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))!=WX.Word)return n}return-1}function Ice(e={}){return[mce,h9,a9.of(e),fce,Lce,y9]}var L9=[{key:`Ctrl-Space`,run:v9},{mac:"Alt-`",run:v9},{mac:`Alt-i`,run:v9},{key:`Escape`,run:cce},{key:`ArrowDown`,run:_9(!0)},{key:`ArrowUp`,run:_9(!1)},{key:`PageDown`,run:_9(!0,`page`)},{key:`PageUp`,run:_9(!1,`page`)},{key:`Enter`,run:sce}],Lce=gX.highest(R2.computeN([a9],e=>e.facet(a9).defaultKeymap?[L9]:[]));function $(e){return new q6(Bae.define(e))}function R9(e){return J(()=>import(`./dist-BLpRy_Yx.js`).then(t=>t.sql({dialect:t[e]})),__vite__mapDeps([7,8]),import.meta.url)}var Rce=[Q.of({name:`C`,extensions:[`c`,`h`,`ino`],load(){return J(()=>import(`./dist-DNKuMzWc.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 J(()=>import(`./dist-DNKuMzWc.js`).then(e=>e.cpp()),__vite__mapDeps([9,8]),import.meta.url)}}),Q.of({name:`CQL`,alias:[`cassandra`],extensions:[`cql`],load(){return R9(`Cassandra`)}}),Q.of({name:`CSS`,extensions:[`css`],load(){return J(()=>import(`./dist-0X_j2Rcc.js`).then(e=>e.i).then(e=>e.css()),__vite__mapDeps([10,8]),import.meta.url)}}),Q.of({name:`Go`,extensions:[`go`],load(){return J(()=>import(`./dist-BdNFAney.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 J(()=>import(`./dist-t6MzE0jU.js`).then(e=>e.html()),__vite__mapDeps([12,10,8,13]),import.meta.url)}}),Q.of({name:`Java`,extensions:[`java`],load(){return J(()=>import(`./dist-BO_UwatH.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 J(()=>import(`./dist-DWfdmz9s.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 J(()=>import(`./dist-DppE_r-D.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 J(()=>import(`./dist-M-SrdhhZ.js`).then(e=>e.json()),__vite__mapDeps([16,8]),import.meta.url)}}),Q.of({name:`JSX`,extensions:[`jsx`],load(){return J(()=>import(`./dist-DWfdmz9s.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 J(()=>import(`./dist-qe8xjesy.js`).then(e=>e.less()),__vite__mapDeps([17,10,8]),import.meta.url)}}),Q.of({name:`Liquid`,extensions:[`liquid`],load(){return J(()=>import(`./dist-n3n6t_FO.js`).then(e=>e.liquid()),__vite__mapDeps([18,12,10,8,13]),import.meta.url)}}),Q.of({name:`MariaDB SQL`,load(){return R9(`MariaSQL`)}}),Q.of({name:`Markdown`,extensions:[`md`,`markdown`,`mkd`],load(){return J(()=>import(`./dist-D-92S-Fd.js`).then(e=>e.markdown()),__vite__mapDeps([19,12,10,8,13]),import.meta.url)}}),Q.of({name:`MS SQL`,load(){return R9(`MSSQL`)}}),Q.of({name:`MySQL`,load(){return R9(`MySQL`)}}),Q.of({name:`PHP`,extensions:[`php`,`php3`,`php4`,`php5`,`php7`,`phtml`],load(){return J(()=>import(`./dist-DyG6Ya-z.js`).then(e=>e.php()),__vite__mapDeps([20,12,10,8,13]),import.meta.url)}}),Q.of({name:`PLSQL`,extensions:[`pls`],load(){return R9(`PLSQL`)}}),Q.of({name:`PostgreSQL`,load(){return R9(`PostgreSQL`)}}),Q.of({name:`Python`,extensions:[`BUILD`,`bzl`,`py`,`pyw`],filename:/^(BUCK|BUILD)$/,load(){return J(()=>import(`./dist-CPyieXEf.js`).then(e=>e.python()),__vite__mapDeps([21,8]),import.meta.url)}}),Q.of({name:`Rust`,extensions:[`rs`],load(){return J(()=>import(`./dist-2vL2sAdF.js`).then(e=>e.rust()),__vite__mapDeps([22,8]),import.meta.url)}}),Q.of({name:`Sass`,extensions:[`sass`],load(){return J(()=>import(`./dist-B3bA05-e.js`).then(e=>e.sass({indented:!0})),__vite__mapDeps([23,10,8]),import.meta.url)}}),Q.of({name:`SCSS`,extensions:[`scss`],load(){return J(()=>import(`./dist-B3bA05-e.js`).then(e=>e.sass()),__vite__mapDeps([23,10,8]),import.meta.url)}}),Q.of({name:`SQL`,extensions:[`sql`],load(){return R9(`StandardSQL`)}}),Q.of({name:`SQLite`,load(){return R9(`SQLite`)}}),Q.of({name:`TSX`,extensions:[`tsx`],load(){return J(()=>import(`./dist-DWfdmz9s.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 J(()=>import(`./dist-DWfdmz9s.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 J(()=>import(`./dist-1nXCdsej.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 J(()=>import(`./dist-CIRMvUM4.js`).then(e=>e.xml()),__vite__mapDeps([25,8]),import.meta.url)}}),Q.of({name:`YAML`,alias:[`yml`],extensions:[`yaml`,`yml`],load(){return J(()=>import(`./dist-CGt_UGeO.js`).then(e=>e.yaml()),__vite__mapDeps([26,8]),import.meta.url)}}),Q.of({name:`APL`,extensions:[`dyalog`,`apl`],load(){return J(()=>import(`./apl-CnwPGSsG.js`).then(e=>$(e.apl)),[],import.meta.url)}}),Q.of({name:`PGP`,alias:[`asciiarmor`],extensions:[`asc`,`pgp`,`sig`],load(){return J(()=>import(`./asciiarmor-qTkVPQu6.js`).then(e=>$(e.asciiArmor)),[],import.meta.url)}}),Q.of({name:`ASN.1`,extensions:[`asn`,`asn1`],load(){return J(()=>import(`./asn1-Dr8qZg38.js`).then(e=>$(e.asn1({}))),[],import.meta.url)}}),Q.of({name:`Asterisk`,filename:/^extensions\.conf$/i,load(){return J(()=>import(`./asterisk-Bja0s6e1.js`).then(e=>$(e.asterisk)),[],import.meta.url)}}),Q.of({name:`Brainfuck`,extensions:[`b`,`bf`],load(){return J(()=>import(`./brainfuck-D5EjA2JK.js`).then(e=>$(e.brainfuck)),[],import.meta.url)}}),Q.of({name:`Cobol`,extensions:[`cob`,`cpy`],load(){return J(()=>import(`./cobol-B_OZ4V-R.js`).then(e=>$(e.cobol)),[],import.meta.url)}}),Q.of({name:`C#`,alias:[`csharp`,`cs`],extensions:[`cs`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.csharp)),[],import.meta.url)}}),Q.of({name:`Clojure`,extensions:[`clj`,`cljc`,`cljx`],load(){return J(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`ClojureScript`,extensions:[`cljs`],load(){return J(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`Closure Stylesheets (GSS)`,extensions:[`gss`],load(){return J(()=>import(`./css-CYpP4FRV.js`).then(e=>$(e.gss)),[],import.meta.url)}}),Q.of({name:`CMake`,extensions:[`cmake`,`cmake.in`],filename:/^CMakeLists\.txt$/,load(){return J(()=>import(`./cmake-CyVbuzPu.js`).then(e=>$(e.cmake)),[],import.meta.url)}}),Q.of({name:`CoffeeScript`,alias:[`coffee`,`coffee-script`],extensions:[`coffee`],load(){return J(()=>import(`./coffeescript-B2pKbFk8.js`).then(e=>$(e.coffeeScript)),[],import.meta.url)}}),Q.of({name:`Common Lisp`,alias:[`lisp`],extensions:[`cl`,`lisp`,`el`],load(){return J(()=>import(`./commonlisp-CcllspGY.js`).then(e=>$(e.commonLisp)),[],import.meta.url)}}),Q.of({name:`Cypher`,extensions:[`cyp`,`cypher`],load(){return J(()=>import(`./cypher-p9eYesGn.js`).then(e=>$(e.cypher)),[],import.meta.url)}}),Q.of({name:`Cython`,extensions:[`pyx`,`pxd`,`pxi`],load(){return J(()=>import(`./python-BqYw9LYJ.js`).then(e=>$(e.cython)),[],import.meta.url)}}),Q.of({name:`Crystal`,extensions:[`cr`],load(){return J(()=>import(`./crystal-M5-qzICs.js`).then(e=>$(e.crystal)),[],import.meta.url)}}),Q.of({name:`D`,extensions:[`d`],load(){return J(()=>import(`./d-BhMjBjQP.js`).then(e=>$(e.d)),[],import.meta.url)}}),Q.of({name:`Dart`,extensions:[`dart`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.dart)),[],import.meta.url)}}),Q.of({name:`diff`,extensions:[`diff`,`patch`],load(){return J(()=>import(`./diff-ChtP43wD.js`).then(e=>$(e.diff)),[],import.meta.url)}}),Q.of({name:`Dockerfile`,filename:/^Dockerfile$/,load(){return J(()=>import(`./dockerfile-BLkNEvjs.js`).then(e=>$(e.dockerFile)),__vite__mapDeps([27,28]),import.meta.url)}}),Q.of({name:`DTD`,extensions:[`dtd`],load(){return J(()=>import(`./dtd-DTF72YNO.js`).then(e=>$(e.dtd)),[],import.meta.url)}}),Q.of({name:`Dylan`,extensions:[`dylan`,`dyl`,`intr`],load(){return J(()=>import(`./dylan-C6jEEEk-.js`).then(e=>$(e.dylan)),[],import.meta.url)}}),Q.of({name:`EBNF`,load(){return J(()=>import(`./ebnf-D4c0_ac3.js`).then(e=>$(e.ebnf)),[],import.meta.url)}}),Q.of({name:`ECL`,extensions:[`ecl`],load(){return J(()=>import(`./ecl-BSZaIHnp.js`).then(e=>$(e.ecl)),[],import.meta.url)}}),Q.of({name:`edn`,extensions:[`edn`],load(){return J(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`Eiffel`,extensions:[`e`],load(){return J(()=>import(`./eiffel-BEjRio4Q.js`).then(e=>$(e.eiffel)),[],import.meta.url)}}),Q.of({name:`Elm`,extensions:[`elm`],load(){return J(()=>import(`./elm-Cshzl8qu.js`).then(e=>$(e.elm)),[],import.meta.url)}}),Q.of({name:`Erlang`,extensions:[`erl`],load(){return J(()=>import(`./erlang-DaB2Rkuy.js`).then(e=>$(e.erlang)),[],import.meta.url)}}),Q.of({name:`Esper`,load(){return J(()=>import(`./sql-DcCJ9jop.js`).then(e=>$(e.esper)),[],import.meta.url)}}),Q.of({name:`Factor`,extensions:[`factor`],load(){return J(()=>import(`./factor-D7LVTn2l.js`).then(e=>$(e.factor)),__vite__mapDeps([29,28]),import.meta.url)}}),Q.of({name:`FCL`,load(){return J(()=>import(`./fcl-ClOhbFR7.js`).then(e=>$(e.fcl)),[],import.meta.url)}}),Q.of({name:`Forth`,extensions:[`forth`,`fth`,`4th`],load(){return J(()=>import(`./forth-Cezjo90N.js`).then(e=>$(e.forth)),[],import.meta.url)}}),Q.of({name:`Fortran`,extensions:[`f`,`for`,`f77`,`f90`,`f95`],load(){return J(()=>import(`./fortran-Bt6PBEDR.js`).then(e=>$(e.fortran)),[],import.meta.url)}}),Q.of({name:`F#`,alias:[`fsharp`],extensions:[`fs`],load(){return J(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.fSharp)),[],import.meta.url)}}),Q.of({name:`Gas`,extensions:[`s`],load(){return J(()=>import(`./gas-BHEdbvp9.js`).then(e=>$(e.gas)),[],import.meta.url)}}),Q.of({name:`Gherkin`,extensions:[`feature`],load(){return J(()=>import(`./gherkin-oBAE_ms0.js`).then(e=>$(e.gherkin)),[],import.meta.url)}}),Q.of({name:`Groovy`,extensions:[`groovy`,`gradle`],filename:/^Jenkinsfile$/,load(){return J(()=>import(`./groovy-BC3IOsC8.js`).then(e=>$(e.groovy)),[],import.meta.url)}}),Q.of({name:`Haskell`,extensions:[`hs`],load(){return J(()=>import(`./haskell-BRsoo5mP.js`).then(e=>$(e.haskell)),[],import.meta.url)}}),Q.of({name:`Haxe`,extensions:[`hx`],load(){return J(()=>import(`./haxe-DIz0ZZqd.js`).then(e=>$(e.haxe)),[],import.meta.url)}}),Q.of({name:`HXML`,extensions:[`hxml`],load(){return J(()=>import(`./haxe-DIz0ZZqd.js`).then(e=>$(e.hxml)),[],import.meta.url)}}),Q.of({name:`HTTP`,load(){return J(()=>import(`./http-CLVgA2GD.js`).then(e=>$(e.http)),[],import.meta.url)}}),Q.of({name:`IDL`,extensions:[`pro`],load(){return J(()=>import(`./idl-BUZw3wgd.js`).then(e=>$(e.idl)),[],import.meta.url)}}),Q.of({name:`JSON-LD`,alias:[`jsonld`],extensions:[`jsonld`],load(){return J(()=>import(`./javascript-9Tg8ixDm.js`).then(e=>$(e.jsonld)),[],import.meta.url)}}),Q.of({name:`Julia`,extensions:[`jl`],load(){return J(()=>import(`./julia-CQfgDRfP.js`).then(e=>$(e.julia)),[],import.meta.url)}}),Q.of({name:`Kotlin`,extensions:[`kt`,`kts`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.kotlin)),[],import.meta.url)}}),Q.of({name:`LiveScript`,alias:[`ls`],extensions:[`ls`],load(){return J(()=>import(`./livescript-BXxG0Yva.js`).then(e=>$(e.liveScript)),[],import.meta.url)}}),Q.of({name:`Lua`,extensions:[`lua`],load(){return J(()=>import(`./lua-CiA1ziua.js`).then(e=>$(e.lua)),[],import.meta.url)}}),Q.of({name:`mIRC`,extensions:[`mrc`],load(){return J(()=>import(`./mirc-C9zpzAZU.js`).then(e=>$(e.mirc)),[],import.meta.url)}}),Q.of({name:`Mathematica`,extensions:[`m`,`nb`,`wl`,`wls`],load(){return J(()=>import(`./mathematica-u8YMmbU0.js`).then(e=>$(e.mathematica)),[],import.meta.url)}}),Q.of({name:`Modelica`,extensions:[`mo`],load(){return J(()=>import(`./modelica-CqHI_q-D.js`).then(e=>$(e.modelica)),[],import.meta.url)}}),Q.of({name:`MUMPS`,extensions:[`mps`],load(){return J(()=>import(`./mumps-CW_TBmxz.js`).then(e=>$(e.mumps)),[],import.meta.url)}}),Q.of({name:`Mbox`,extensions:[`mbox`],load(){return J(()=>import(`./mbox-BEMVcqjs.js`).then(e=>$(e.mbox)),[],import.meta.url)}}),Q.of({name:`Nginx`,filename:/nginx.*\.conf$/i,load(){return J(()=>import(`./nginx-BMaDbqW3.js`).then(e=>$(e.nginx)),[],import.meta.url)}}),Q.of({name:`NSIS`,extensions:[`nsh`,`nsi`],load(){return J(()=>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 J(()=>import(`./ntriples-d28e9m0E.js`).then(e=>$(e.ntriples)),[],import.meta.url)}}),Q.of({name:`Objective-C`,alias:[`objective-c`,`objc`],extensions:[`m`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.objectiveC)),[],import.meta.url)}}),Q.of({name:`Objective-C++`,alias:[`objective-c++`,`objc++`],extensions:[`mm`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.objectiveCpp)),[],import.meta.url)}}),Q.of({name:`OCaml`,extensions:[`ml`,`mli`,`mll`,`mly`],load(){return J(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.oCaml)),[],import.meta.url)}}),Q.of({name:`Octave`,extensions:[`m`],load(){return J(()=>import(`./octave-D2Q8cUp1.js`).then(e=>$(e.octave)),[],import.meta.url)}}),Q.of({name:`Oz`,extensions:[`oz`],load(){return J(()=>import(`./oz-BwTct_5T.js`).then(e=>$(e.oz)),[],import.meta.url)}}),Q.of({name:`Pascal`,extensions:[`p`,`pas`],load(){return J(()=>import(`./pascal-Dp_KdFgX.js`).then(e=>$(e.pascal)),[],import.meta.url)}}),Q.of({name:`Perl`,extensions:[`pl`,`pm`],load(){return J(()=>import(`./perl-CdEHsPfU.js`).then(e=>$(e.perl)),[],import.meta.url)}}),Q.of({name:`Pig`,extensions:[`pig`],load(){return J(()=>import(`./pig-AF4Hwhju.js`).then(e=>$(e.pig)),[],import.meta.url)}}),Q.of({name:`PowerShell`,extensions:[`ps1`,`psd1`,`psm1`],load(){return J(()=>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 J(()=>import(`./properties-C357ku5U.js`).then(e=>$(e.properties)),[],import.meta.url)}}),Q.of({name:`ProtoBuf`,extensions:[`proto`],load(){return J(()=>import(`./protobuf-D1ij_kNL.js`).then(e=>$(e.protobuf)),[],import.meta.url)}}),Q.of({name:`Pug`,alias:[`jade`],extensions:[`pug`,`jade`],load(){return J(()=>import(`./pug-Bugr-47h.js`).then(e=>$(e.pug)),__vite__mapDeps([31,32]),import.meta.url)}}),Q.of({name:`Puppet`,extensions:[`pp`],load(){return J(()=>import(`./puppet-B4hC2X4m.js`).then(e=>$(e.puppet)),[],import.meta.url)}}),Q.of({name:`Q`,extensions:[`q`],load(){return J(()=>import(`./q-B9NhS7L_.js`).then(e=>$(e.q)),[],import.meta.url)}}),Q.of({name:`R`,alias:[`rscript`],extensions:[`r`,`R`],load(){return J(()=>import(`./r-DADKenSm.js`).then(e=>$(e.r)),[],import.meta.url)}}),Q.of({name:`RPM Changes`,load(){return J(()=>import(`./rpm-gpDK5sbt.js`).then(e=>$(e.rpmChanges)),[],import.meta.url)}}),Q.of({name:`RPM Spec`,extensions:[`spec`],load(){return J(()=>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 J(()=>import(`./ruby-DsYpTuWg.js`).then(e=>$(e.ruby)),[],import.meta.url)}}),Q.of({name:`SAS`,extensions:[`sas`],load(){return J(()=>import(`./sas-C2OyD2Y6.js`).then(e=>$(e.sas)),[],import.meta.url)}}),Q.of({name:`Scala`,extensions:[`scala`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.scala)),[],import.meta.url)}}),Q.of({name:`Scheme`,extensions:[`scm`,`ss`],load(){return J(()=>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 J(()=>import(`./shell-Du5Qg9im.js`).then(e=>$(e.shell)),[],import.meta.url)}}),Q.of({name:`Sieve`,extensions:[`siv`,`sieve`],load(){return J(()=>import(`./sieve-BAxa3IjF.js`).then(e=>$(e.sieve)),[],import.meta.url)}}),Q.of({name:`Smalltalk`,extensions:[`st`],load(){return J(()=>import(`./smalltalk-BLp5-jwC.js`).then(e=>$(e.smalltalk)),[],import.meta.url)}}),Q.of({name:`Solr`,load(){return J(()=>import(`./solr-BBopId9w.js`).then(e=>$(e.solr)),[],import.meta.url)}}),Q.of({name:`SML`,extensions:[`sml`,`sig`,`fun`,`smackspec`],load(){return J(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.sml)),[],import.meta.url)}}),Q.of({name:`SPARQL`,alias:[`sparul`],extensions:[`rq`,`sparql`],load(){return J(()=>import(`./sparql-Dz-mlCAC.js`).then(e=>$(e.sparql)),[],import.meta.url)}}),Q.of({name:`Spreadsheet`,alias:[`excel`,`formula`],load(){return J(()=>import(`./spreadsheet-CTIncYxj.js`).then(e=>$(e.spreadsheet)),[],import.meta.url)}}),Q.of({name:`Squirrel`,extensions:[`nut`],load(){return J(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.squirrel)),[],import.meta.url)}}),Q.of({name:`Stylus`,extensions:[`styl`],load(){return J(()=>import(`./stylus-DLLZ8dgm.js`).then(e=>$(e.stylus)),[],import.meta.url)}}),Q.of({name:`Swift`,extensions:[`swift`],load(){return J(()=>import(`./swift-DKB6_1j6.js`).then(e=>$(e.swift)),[],import.meta.url)}}),Q.of({name:`sTeX`,load(){return J(()=>import(`./stex-sDrdk2BW.js`).then(e=>$(e.stex)),[],import.meta.url)}}),Q.of({name:`LaTeX`,alias:[`tex`],extensions:[`text`,`ltx`,`tex`],load(){return J(()=>import(`./stex-sDrdk2BW.js`).then(e=>$(e.stex)),[],import.meta.url)}}),Q.of({name:`SystemVerilog`,extensions:[`v`,`sv`,`svh`],load(){return J(()=>import(`./verilog-D-x6ne0Z.js`).then(e=>$(e.verilog)),[],import.meta.url)}}),Q.of({name:`Tcl`,extensions:[`tcl`],load(){return J(()=>import(`./tcl-BGfruO1u.js`).then(e=>$(e.tcl)),[],import.meta.url)}}),Q.of({name:`Textile`,extensions:[`textile`],load(){return J(()=>import(`./textile-DWBqthVk.js`).then(e=>$(e.textile)),[],import.meta.url)}}),Q.of({name:`TiddlyWiki`,load(){return J(()=>import(`./tiddlywiki-VlUiK86J.js`).then(e=>$(e.tiddlyWiki)),[],import.meta.url)}}),Q.of({name:`Tiki wiki`,load(){return J(()=>import(`./tiki-CxVlf5KZ.js`).then(e=>$(e.tiki)),[],import.meta.url)}}),Q.of({name:`TOML`,extensions:[`toml`],load(){return J(()=>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 J(()=>import(`./troff-C2dAgh7P.js`).then(e=>$(e.troff)),[],import.meta.url)}}),Q.of({name:`TTCN`,extensions:[`ttcn`,`ttcn3`,`ttcnpp`],load(){return J(()=>import(`./ttcn-BePYh-hG.js`).then(e=>$(e.ttcn)),[],import.meta.url)}}),Q.of({name:`TTCN_CFG`,extensions:[`cfg`],load(){return J(()=>import(`./ttcn-cfg-CY0aot7Q.js`).then(e=>$(e.ttcnCfg)),[],import.meta.url)}}),Q.of({name:`Turtle`,extensions:[`ttl`],load(){return J(()=>import(`./turtle-BDLWE2cD.js`).then(e=>$(e.turtle)),[],import.meta.url)}}),Q.of({name:`Web IDL`,extensions:[`webidl`],load(){return J(()=>import(`./webidl-D5jiJvOU.js`).then(e=>$(e.webIDL)),[],import.meta.url)}}),Q.of({name:`VB.NET`,extensions:[`vb`],load(){return J(()=>import(`./vb-BthdM_4N.js`).then(e=>$(e.vb)),[],import.meta.url)}}),Q.of({name:`VBScript`,extensions:[`vbs`],load(){return J(()=>import(`./vbscript-D9f6rSsU.js`).then(e=>$(e.vbScript)),[],import.meta.url)}}),Q.of({name:`Velocity`,extensions:[`vtl`],load(){return J(()=>import(`./velocity-CqftRsjg.js`).then(e=>$(e.velocity)),[],import.meta.url)}}),Q.of({name:`Verilog`,extensions:[`v`],load(){return J(()=>import(`./verilog-D-x6ne0Z.js`).then(e=>$(e.verilog)),[],import.meta.url)}}),Q.of({name:`VHDL`,extensions:[`vhd`,`vhdl`],load(){return J(()=>import(`./vhdl-CMrOq2q1.js`).then(e=>$(e.vhdl)),[],import.meta.url)}}),Q.of({name:`XQuery`,extensions:[`xy`,`xquery`,`xq`,`xqm`,`xqy`],load(){return J(()=>import(`./xquery-fj_R-kMw.js`).then(e=>$(e.xQuery)),[],import.meta.url)}}),Q.of({name:`Yacas`,extensions:[`ys`],load(){return J(()=>import(`./yacas-CXXgtw0p.js`).then(e=>$(e.yacas)),[],import.meta.url)}}),Q.of({name:`Z80`,extensions:[`z80`],load(){return J(()=>import(`./z80-CL1naaMV.js`).then(e=>$(e.z80)),[],import.meta.url)}}),Q.of({name:`MscGen`,extensions:[`mscgen`,`mscin`,`msc`],load(){return J(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.mscgen)),[],import.meta.url)}}),Q.of({name:`Xù`,extensions:[`xu`],load(){return J(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.xu)),[],import.meta.url)}}),Q.of({name:`MsGenny`,extensions:[`msgenny`],load(){return J(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.msgenny)),[],import.meta.url)}}),Q.of({name:`Vue`,extensions:[`vue`],load(){return J(()=>import(`./dist-mqD5TZup.js`).then(e=>e.vue()),__vite__mapDeps([33,12,10,8,13]),import.meta.url)}}),Q.of({name:`Angular Template`,load(){return J(()=>import(`./dist-C0J5_3qM.js`).then(e=>e.angular()),__vite__mapDeps([34,12,10,8,13]),import.meta.url)}})];function z9(e){let t=String(e||``).split(`/`).pop()||``,n=t.lastIndexOf(`.`);return n>=0?t.slice(n):``}function B9(e){return Q.matchFilename(Rce,`file${e}`)}function V9({content:e,path:t,readOnly:n=!1,onSave:r,onDirtyChange:i,onContentChange:a,getContentRef:o}){let s=(0,v.useRef)(null),c=(0,v.useRef)(null),l=(0,v.useRef)(new vX),u=(0,v.useRef)(new vX),d=(0,v.useRef)(new vX),f=(0,v.useRef)(!1),p=(0,v.useRef)(r),m=(0,v.useRef)(i),h=(0,v.useRef)(a);(0,v.useEffect)(()=>{p.current=r,m.current=i,h.current=a},[r,i,a]);let g=(0,v.useCallback)(e=>{f.current!==e&&(f.current=e,m.current?.(e))},[]);return(0,v.useEffect)(()=>{if(!s.current)return;let r=document.documentElement.classList.contains(`dark`),i=R2.of([{key:`Mod-s`,run:e=>{let t=e.state.doc.toString();return p.current?.(t),g(!1),!0},preventDefault:!0}]),a=new k2({state:YX.create({doc:e,extensions:[p3(),_3(),toe(),Tae(),n4(),d4(),YX.allowMultipleSelections.of(!0),mae(),C8(kae,{fallback:!0}),Fae(),Ece(),Ice(),b4(),C4(),f4(),gse(),R2.of([...kce,...rse,...Lse,...uoe,...xae,...L9,ise]),i,k2.updateListener.of(e=>{e.docChanged&&(g(!0),h.current?.(e.state.doc.toString()))}),d.current.of(YX.readOnly.of(n)),l.current.of([]),u.current.of(r?f7:[]),k2.theme({"&":{height:`100%`},".cm-scroller":{overflow:`auto`}})]}),parent:s.current});c.current=a,o&&(o.current=()=>a.state.doc.toString());let f=B9(z9(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,v.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,v.useEffect)(()=>{let e=c.current;if(!e)return;let n=B9(z9(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,v.useEffect)(()=>{let e=c.current;e&&e.dispatch({effects:d.current.reconfigure(YX.readOnly.of(n))})},[n]),(0,v.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?f7:[])})});return e.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>e.disconnect()},[]),(0,k.jsx)(`div`,{ref:s,className:`h-full w-full overflow-hidden [&_.cm-editor]:h-full [&_.cm-scroller]:auto`})}function H9({content:e,objectUrl:t,kind:n,filename:r,path:i}){return n===`markdown`?(0,k.jsx)(Aq,{content:e||``}):n===`image`&&t?(0,k.jsx)(`div`,{className:`flex items-center justify-center p-4`,children:(0,k.jsx)(`img`,{src:t,alt:r,className:`max-h-[70vh] max-w-full rounded object-contain`})}):n===`pdf`&&t?(0,k.jsx)(`iframe`,{src:t,title:r,className:`h-full w-full border-0`}):(n===`text`||n===`code`)&&e!==null?(0,k.jsx)(V9,{content:e,path:i||r,readOnly:!0,onSave:()=>{},onDirtyChange:()=>{},getContentRef:{current:()=>e||``}}):(0,k.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,k.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 U9(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`)}function zce(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 W9(...e){return Array.from(new Set(e.filter(e=>!!e))).join(` `)}function Bce(e){let t=e?zce(e):void 0,n=W9(`'unsafe-inline'`,`'unsafe-eval'`,`'self'`,`https:`,t),r=W9(`'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 Vce(e){try{let t=new URL(e,window.location.href);return[`http:`,`https:`,`mailto:`].includes(t.protocol)}catch{return!1}}function G9(e,t={}){let{channelId:n,basePath:r}=typeof t==`string`?{channelId:t}:t,i=Bce(r),a=`<script>
|
|
213
213
|
function ksadkScrollToHash(rawHref) {
|
|
214
214
|
if (!rawHref || rawHref === '#') return;
|
|
215
215
|
var rawId = rawHref.slice(1);
|
|
@@ -241,4 +241,4 @@ document.addEventListener('click', function(event) {
|
|
|
241
241
|
}, '*');
|
|
242
242
|
}
|
|
243
243
|
}, true);
|
|
244
|
-
<\/script>`,o=`${`<meta http-equiv="Content-Security-Policy" content="${U9(i)}">`}${r?`<base href="${U9(r)}">`:``}${a}`;return/<head[^>]*>/i.test(e)?e.replace(/<head[^>]*>/i,`$&${o}`):`${o}${e}`}function K9(e,t){let n=(0,v.useRef)(null);(0,v.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&&Vce(r)&&window.open(r,`_blank`,`noopener,noreferrer`)},window.addEventListener(`message`,n.current),()=>{n.current&&window.removeEventListener(`message`,n.current)}),[e,t])}function Hce({content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i,isMobile:a}){let o=(0,v.useRef)(null),s=(0,v.useId)(),[c,l]=(0,v.useState)(`preview`),u=_t(t),d=gt(t),f=(0,v.useCallback)(()=>G9(e,{basePath:u,channelId:s}),[e,u,s]),[p,m]=(0,v.useState)(f());(0,v.useEffect)(()=>{let e=setTimeout(()=>{m(f())},300);return()=>clearTimeout(e)},[f]),K9(o,s);let h=(0,v.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,k.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-slate-200 px-2 py-1.5 dark:border-slate-700`,children:[(0,k.jsxs)(`button`,{onClick:()=>l(`editor`),className:K(`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,k.jsx)(uN,{className:`h-3.5 w-3.5`}),`编辑`]}),(0,k.jsxs)(`button`,{onClick:()=>l(`preview`),className:K(`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,k.jsx)(hN,{className:`h-3.5 w-3.5`}),`预览`]})]}),c===`editor`?(0,k.jsx)(V9,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}):(0,k.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,k.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,k.jsx)(V9,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}),(0,k.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,k.jsx)(hN,{className:`h-3.5 w-3.5`}),`预览`]})]}):(0,k.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,k.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,k.jsxs)(`div`,{className:`absolute right-3 top-3 z-10 flex gap-1.5`,children:[(0,k.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,k.jsx)(mN,{className:`h-3.5 w-3.5`}),`新窗口`]}),(0,k.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,k.jsx)(uN,{className:`h-3.5 w-3.5`}),`编辑`]})]})]})}function q9(e){e.current&&clearTimeout(e.current)}function Uce({content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i,isMobile:a}){let[o,s]=(0,v.useState)(`editor`),[c,l]=(0,v.useState)(e),u=(0,v.useRef)(null);return(0,v.useEffect)(()=>(q9(u),u.current=setTimeout(()=>l(e),300),()=>q9(u)),[e]),a?(0,k.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,k.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,k.jsxs)(`button`,{onClick:()=>s(`editor`),className:K(`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,k.jsx)(uN,{className:`h-3.5 w-3.5`}),`编辑`]}),(0,k.jsxs)(`button`,{onClick:()=>s(`preview`),className:K(`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,k.jsx)(hN,{className:`h-3.5 w-3.5`}),`预览`]})]}),o===`editor`?(0,k.jsx)(V9,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}):(0,k.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:(0,k.jsx)(Aq,{content:c})})]}):o===`editor`?(0,k.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,k.jsx)(V9,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}),(0,k.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,k.jsx)(hN,{className:`h-3.5 w-3.5`}),`预览`]})]}):(0,k.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,k.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:(0,k.jsx)(Aq,{content:c})}),(0,k.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,k.jsx)(uN,{className:`h-3.5 w-3.5`}),`编辑`]})]})}var Wce=`/agentengine/api/v1/GetWorkspaceFileContent`,Gce=4e3;function J9(e){let t=mt(e);if(!t||t===`.`)return`.`;let n=t.split(`/`).filter(Boolean);return n.length<=1?`.`:n.slice(0,-1).join(`/`)}function Kce(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function Y9(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 qce=[{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 Jce(e){return gt(e)}function X9({label:e,showSupportedTypes:t=!1}){return(0,k.jsx)(`div`,{className:`flex h-full min-h-[16rem] flex-col items-center justify-center px-6 text-center`,children:(0,k.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,k.jsx)(`div`,{children:e}),t?(0,k.jsxs)(`div`,{className:`mt-4 text-left`,children:[(0,k.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-[0.12em] text-slate-400`,children:`支持在线预览`}),(0,k.jsx)(`div`,{className:`mt-2 grid gap-2`,children:qce.map(e=>(0,k.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,k.jsx)(`div`,{className:`text-sm font-medium text-slate-700 dark:text-slate-200`,children:e.label}),(0,k.jsx)(`div`,{className:`mt-0.5 font-mono text-[11px] text-slate-400`,children:e.detail})]},e.label))}),(0,k.jsx)(`div`,{className:`mt-3 text-xs leading-5 text-slate-400`,children:`Word、Excel、PPT 当前不支持在线预览,可下载后查看。`})]}):null]})})}function Z9({agentId:e,capability:t,open:n,onClose:r,isFullscreen:i=!1,onToggleFullscreen:a,isMobile:o=!1,api:s}){let c=(0,v.useRef)(null),l=(0,v.useRef)(null),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(`.`),[m,h]=(0,v.useState)([]),[g,_]=(0,v.useState)(!1),[y,b]=(0,v.useState)(!1),[x,S]=(0,v.useState)(!1),[C,w]=(0,v.useState)(``),[T,ee]=(0,v.useState)(null),[te,E]=(0,v.useState)(null),[ne,re]=(0,v.useState)(!1),[ie,ae]=(0,v.useState)(!1),oe=(0,v.useRef)(null),se=(0,v.useRef)(null),ce=(0,v.useRef)(`selection`),D=(0,v.useRef)(Dt()),O=(0,v.useMemo)(()=>m.find(e=>e.Path===T)??null,[m,T]),le=(0,v.useMemo)(()=>O?Tt({path:O.Path,mimeType:O.MimeType}):null,[O]),ue=(0,v.useCallback)(()=>ne?window.confirm(`当前文件有未保存的更改,确定要离开吗?`):!0,[ne]),de=t.ContentPath||Wce,fe=t.RootLabel||`Workspace`,pe=fe?`${fe.charAt(0).toUpperCase()}${fe.slice(1)}`:`Workspace`,me=yt(f),he=(0,v.useCallback)(()=>{l.current&&=(URL.revokeObjectURL(l.current),null)},[]);(0,v.useEffect)(()=>()=>he(),[he]);let ge=(0,v.useCallback)(async(t,n={})=>{let r=!!n.background;r?b(!0):_(!0),r||w(``);try{let n=await s.listWorkspaceFiles(e,t,!1),i=mt(String(n?.Path||t||`.`)),a=Array.isArray(n?.Entries)?n.Entries:[];p(i),h(a),ce.current=r?`background-refresh`:`selection`,ee(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?b(!1):_(!1)}},[e,s]);(0,v.useEffect)(()=>{!n||u||(d(!0),ge(`.`))},[u,ge,n]),(0,v.useEffect)(()=>{if(!n||ne||!u)return;let e=window.setInterval(()=>{ge(f,{background:!0})},Gce);return()=>window.clearInterval(e)},[f,ne,u,ge,n]);let _e=(0,v.useCallback)(async t=>{let n=D.current.next(t.Path),r=Ct({path:t.Path,mimeType:t.MimeType});if(se.current=t.Path,r===`unsupported`){he(),E({path:t.Path,kind:r,status:`ready`,mimeType:t.MimeType??void 0});return}he(),E({path:t.Path,kind:r,status:`loading`,mimeType:t.MimeType??void 0});try{let r=await s.getWorkspaceFileContent(e,t.Path,{asText:!1});if(!D.current.isCurrent(n))return;if(r instanceof Blob){let e=t.MimeType||``,i=Ct({path:t.Path,mimeType:e});if(i===`image`||i===`pdf`){let n=URL.createObjectURL(r);l.current=n,E({path:t.Path,kind:i,status:`ready`,mimeType:e,objectUrl:n});return}let a=await r.text();if(!D.current.isCurrent(n))return;let o=Ct({path:t.Path,mimeType:e});E({path:t.Path,kind:o,status:`ready`,mimeType:e,content:a})}else{let e=t.MimeType||``,n=Ct({path:t.Path,mimeType:e});E({path:t.Path,kind:n,status:`ready`,mimeType:e,content:r})}}catch(e){if(!D.current.isCurrent(n))return;console.error(`Failed to preview workspace file:`,e),E({path:t.Path,kind:r,status:`error`,mimeType:t.MimeType??void 0,error:e instanceof Error?e.message:String(e)})}},[e,s,he]);(0,v.useEffect)(()=>{if(!O||O.Type!==`file`){he(),E(null),re(!1),se.current=null;return}if(ce.current===`background-refresh`&&se.current===O.Path){ce.current=`selection`;return}ce.current=`selection`,_e(O)},[he,_e,O]);let ve=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=vt(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 ge(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)}}},ye=async n=>{if(!t.SupportsDelete)return;let r=mt(n.Path);if(window.confirm(`删除 ${r} ?`)){w(``);try{await s.deleteWorkspaceFile(e,r),T&&mt(T)===r&&(ee(null),re(!1)),await ge(n.Type===`directory`&&(mt(f)===r||mt(f).startsWith(`${r}/`))?J9(r):f)}catch(e){console.error(`Failed to delete workspace file:`,e),w(e instanceof Error?e.message:String(e))}}},be=()=>!O||O.Type!==`file`?(0,k.jsx)(X9,{label:`从左侧选择文件后在这里查看内容预览。`,showSupportedTypes:!0}):!te||te.path!==O.Path||te.status===`loading`?(0,k.jsx)(`div`,{className:`flex h-full min-h-[16rem] items-center justify-center`,children:(0,k.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,k.jsx)(yN,{className:`h-4 w-4 animate-spin`}),`正在加载预览...`]})}):te.status===`error`?(0,k.jsx)(X9,{label:te.error||`文件预览加载失败。`}):te.kind===`markdown`?(0,k.jsx)(Uce,{content:te.content||``,path:O.Path,onSave:xe,onDirtyChange:re,getContentRef:oe,isMobile:o}):te.kind===`image`&&te.objectUrl?(0,k.jsx)(H9,{content:null,objectUrl:te.objectUrl,kind:`image`,filename:O.Name,mimeType:te.mimeType||``}):te.kind===`pdf`&&te.objectUrl?(0,k.jsx)(H9,{content:null,objectUrl:te.objectUrl,kind:`pdf`,filename:O.Name,mimeType:te.mimeType||``}):te.kind===`html`?(0,k.jsx)(Hce,{content:te.content||``,path:O.Path,onSave:xe,onDirtyChange:re,getContentRef:oe,isMobile:o,agentId:e,contentPath:de}):te.kind===`text`||te.kind===`code`?(0,k.jsx)(V9,{content:te.content||``,path:O.Path,onSave:xe,onDirtyChange:re,getContentRef:oe}):(0,k.jsx)(H9,{content:null,kind:`unsupported`,filename:O.Name,mimeType:te.mimeType||``}),xe=async t=>{if(O){ae(!0),w(``);try{let n=new Blob([t],{type:O.MimeType||`text/plain`}),r=new FormData;r.append(`file`,n,O.Name),r.append(`AgentId`,e),r.append(`Path`,O.Path),await s.addWorkspaceFile(r),D.current.invalidate(),re(!1),E(e=>e&&e.path===O.Path?{...e,content:t}:e),se.current=O.Path,await ge(f,{background:!0})}catch(e){console.error(`Failed to save workspace file:`,e),w(e instanceof Error?e.message:String(e))}finally{ae(!1)}}},Se=O?.Type===`file`&&te?.path===O.Path&&te.status===`ready`&&(te.kind===`text`||te.kind===`code`||te.kind===`html`||te.kind===`markdown`),Ce=O?.Type===`file`&&te?.path===O.Path&&te.status===`ready`&&te.kind===`pdf`;return(0,k.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,k.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,k.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,k.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100`,children:pe}),(0,k.jsx)(`div`,{className:`hidden h-4 w-px bg-slate-200/70 dark:bg-slate-800 sm:block`}),(0,k.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,k.jsx)(`span`,{className:`flex-shrink-0 text-xs text-slate-400`,children:`当前目录`}),(0,k.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:`${me},来自 ListWorkspaceFiles 返回的 Data.Path 字段`,children:me})]}),(0,k.jsx)(`div`,{className:`hidden truncate text-[11px] text-slate-400 xl:block`,children:`工作区内相对路径,不是宿主机绝对路径。`})]}),(0,k.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-1.5`,children:[(0,k.jsx)(`input`,{ref:c,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void ve(e.target.files)}),(0,k.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,k.jsx)(AN,{className:`h-3.5 w-3.5`}),x?`上传中`:`上传`]}),(0,k.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,k.jsx)(Hne,{className:`h-3.5 w-3.5`}),`导出`]}),a?(0,k.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,k.jsx)(Vne,{className:`h-4 w-4`}):(0,k.jsx)(Lne,{className:`h-4 w-4`})}):null,r?(0,k.jsx)(`button`,{type:`button`,onClick:()=>{ue()&&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,k.jsx)(jN,{className:`h-4 w-4`})}):null]})]}),(0,k.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col md:flex-row`,children:[(0,k.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,k.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,k.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`div`,{className:`text-xs font-medium text-slate-900 dark:text-slate-100`,children:`文件`}),(0,k.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] text-slate-400`,children:[(0,k.jsxs)(`span`,{children:[m.length,` 项`]}),y?(0,k.jsx)(TN,{className:`h-3 w-3 animate-spin`,"aria-label":`正在同步 Workspace 目录`}):null]})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>{ue()&&ge(J9(f))},disabled:g||vt(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,k.jsx)(aN,{className:`h-4 w-4`})}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>{ue()&&ge(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,k.jsx)(TN,{className:`h-4 w-4 ${g?`animate-spin`:``}`})})]})]}),C?(0,k.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,k.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto px-2 py-2`,children:!u&&!n?(0,k.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`打开面板后加载 workspace 文件。`}):g?(0,k.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`正在加载目录...`}):m.length===0?(0,k.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`当前目录为空。`}):(0,k.jsx)(`div`,{className:`space-y-0.5`,children:m.map(e=>{let n=Ct({path:e.Path,mimeType:e.MimeType}),r=T===e.Path,i=e.Type===`file`?Jce(e.Path):``;return(0,k.jsxs)(`div`,{title:e.Path,className:K(`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,k.jsxs)(`button`,{type:`button`,onClick:()=>{if(e.Type===`directory`){ge(e.Path);return}T!==e.Path&&!ue()||ee(e.Path)},className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,k.jsx)(`div`,{className:K(`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,k.jsx)(_N,{className:`h-3.5 w-3.5`}):n===`image`?(0,k.jsx)(Fne,{className:`h-3.5 w-3.5`}):n===`markdown`||n===`text`||n===`html`?(0,k.jsx)(Nne,{className:`h-3.5 w-3.5`}):(0,k.jsx)(gN,{className:`h-3.5 w-3.5`})}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(`div`,{className:`truncate text-[13px] leading-5`,children:e.Name}),(0,k.jsx)(`div`,{className:K(`truncate text-[11px] leading-4`,r?`text-slate-500 dark:text-slate-400`:`text-slate-400`),children:e.Type===`directory`?`目录`:Y9(e.SizeBytes)})]})]}),(0,k.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-0.5 opacity-0 transition group-hover:opacity-100`,children:[e.Type===`file`?(0,k.jsx)(`a`,{href:i,download:e.Name,className:K(`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,k.jsx)(fN,{className:`h-3.5 w-3.5`})}):null,t.SupportsDelete?(0,k.jsx)(`button`,{type:`button`,onClick:()=>void ye(e),className:K(`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,k.jsx)(kN,{className:`h-3.5 w-3.5`})}):null]})]},e.Path)})})})]}),(0,k.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,k.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:O?(0,k.jsxs)(`div`,{className:`flex w-full items-start justify-between gap-3`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100`,children:O.Name}),(0,k.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-[11px] text-slate-400`,children:O.Path}),(0,k.jsxs)(`div`,{className:`mt-1 text-[11px] text-slate-400`,children:[Y9(O.SizeBytes),O.MimeType?` · ${O.MimeType}`:``,O.ModifiedAt?` · ${Kce(O.ModifiedAt)}`:``]})]}),le===`text`||le===`code`||le===`html`||le===`markdown`?(0,k.jsxs)(`button`,{type:`button`,onClick:()=>{let e=oe.current;e&&xe(e())},disabled:!ne||ie,className:K(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition`,ne&&!ie?`bg-blue-600 text-white hover:bg-blue-700`:`text-slate-400 dark:text-slate-500 cursor-not-allowed`),children:[(0,k.jsx)(Kne,{className:`h-3.5 w-3.5`}),ie?`保存中`:ne?`保存`:`已保存`]}):null]}):(0,k.jsxs)(`div`,{className:`w-full`,children:[(0,k.jsx)(`div`,{className:`text-sm font-semibold text-slate-900 dark:text-slate-100`,children:`文件预览`}),(0,k.jsx)(`div`,{className:`mt-0.5 text-xs text-slate-500 dark:text-slate-400`,children:`选择左侧文件后可在此查看内容。`})]})}),(0,k.jsx)(`div`,{className:K(`custom-scrollbar min-h-0 flex-1`,Ce||Se?`overflow-hidden p-0`:`overflow-y-auto px-4 py-4`),children:be()})]})]})]})}function Yce({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,k.jsxs)(k.Fragment,{children:[f?(0,k.jsxs)(k.Fragment,{children:[n&&!i?(0,k.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,k.jsx)(`aside`,{style:n&&!i?{width:`${r}px`}:void 0,className:K(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,k.jsx)(Z9,{agentId:e,capability:t,open:n,onClose:l,isFullscreen:i,onToggleFullscreen:()=>_e.getState().setWorkspacePanelFullscreen(!i),isMobile:a,api:d}):null})]}):null,p?(0,k.jsx)(NR,{open:n,onOpenChange:e=>{e||_e.getState().setWorkspacePanelFullscreen(!1),_e.getState().setWorkspacePanelOpen(e)},modal:c.modal,children:(0,k.jsxs)(LR,{side:c.side,showOverlay:c.showOverlay,onInteractOutside:e=>{c.preventOutsideClose&&e.preventDefault()},showCloseButton:!1,className:K(`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,k.jsx)(BR,{className:`sr-only`,children:`Workspace 文件`}),(0,k.jsx)(VR,{className:`sr-only`,children:`浏览、上传和预览 Workspace 文件。`}),(0,k.jsx)(Z9,{agentId:e,capability:t,open:n,onClose:l,isMobile:a,api:d})]})}):null]})}var Q9=new Jc,Xce=v.lazy(()=>J(()=>import(`./ArtifactsPanel-KzcO_tZH.js`).then(e=>({default:e.ArtifactsPanel})),[],import.meta.url)),Zce=v.lazy(()=>J(()=>import(`./NativeTerminalPanel-DYD4i8DH.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function Qce(e={}){let t=e.apiAdapter||Q9,[n,r]=(0,v.useState)(null);if((0,v.useEffect)(()=>{let e=new AbortController;return t.getAgentUiBootstrap(void 0,{signal:e.signal}).then(n=>{e.signal.aborted||r({api:t,data:n})}).catch(()=>{e.signal.aborted||r({api:t,data:void 0})}),()=>e.abort()},[t]),!n||n.api!==t)return(0,k.jsx)(me,{});let i=n.data?.AuthorizationScopeKey;return(0,k.jsx)(he,{authorizationScopeKey:e.authorizationScopeKey??(typeof i==`string`&&i?i:void 0),children:(0,k.jsx)($ce,{...e,bootstrapData:n.data})})}function $ce({apiAdapter:e,initialSurface:t=`chat`,routeShell:n,bootstrapData:r}){let i=e||Q9,a=Ve(e=>e.agentId),o=D(e=>e.currentSessionId),s=nt(e=>e.isStreaming),c=_e(e=>e.sidebarOpen),l=_e(e=>e.mobileSidebarOpen),u=_e(e=>e.mobileActionsOpen),d=Ve(e=>e.agentName),f=Ue(e=>e.selectedModel),p=Ue(e=>e.availableModels),m=Ue(e=>e.modelSource),h=Ue(e=>e.modelCatalogLoaded),g=Ue(e=>e.thinkingMode),_=de(e=>e.permissionMode),y=Ve(e=>e.agentFramework),b=Ve(e=>e.workspaceFiles),x=Ve(e=>e.accessMode),S=Ve(e=>e.status),C=Ve(e=>e.errorMessage),w=_e(e=>e.workspacePanelOpen),T=_e(e=>e.workspacePanelWidth),ee=_e(e=>e.workspacePanelFullscreen),te=Ve(e=>e.apiFormats),E=Ve(e=>e.capabilities),ne=rt(e=>e.visible&&!!e.content),re=(0,v.useRef)([]),ie=(0,v.useRef)(null),{isMobile:ae,viewportHeight:oe}=qt(),se=st({isMobile:ae,viewportHeight:oe}),{fetchSessions:ce,loadMoreSessions:O,loadSession:le,followAcceptedInteraction:ue,loadOlderSessionMessages:fe,createNewSession:pe,adoptCreatedSession:me,waitForPendingSessionCreation:he,deleteSession:ge,currentSessionIdRef:ve,agentIdRef:ye,runSubscriptionAbortRef:be}=qM({agentId:a,currentSessionId:o,isMobile:ae,uiCapabilities:E,api:i,resetCompaction:()=>{},disconnectRun:()=>ie.current?.()}),xe=(0,v.useCallback)(e=>{if(!e)return;let t=()=>{D.getState().clearSessionMessageHistory(e),ce(ye.current,e)};queueMicrotask(t),window.setTimeout(t,1800),window.setTimeout(t,5e3)},[ye,ce]),Se=p.find(e=>e.id===f)||null,{submitDraft:Ce,stopGeneration:we,disconnectRun:Te,resumeCheckpoint:Ee,submitAguiAction:De,respondToAguiApproval:Oe}=Xj({agentId:a,currentSessionId:o,agentFramework:y,apiFormats:te,selectedModel:f,selectedModelMetadata:Se,thinkingMode:g,permissionMode:_,uiCapabilities:E,isMobile:ae,api:i,currentSessionIdRef:ve,agentIdRef:ye,queuedDraftRef:re,onRunSettled:xe,onSessionCreated:e=>me(e,!0),waitForPendingSessionCreation:he});(0,v.useEffect)(()=>{ie.current=Te},[Te]);let ke=(0,v.useCallback)(()=>{let e=ve.current;be.current?.abort(),nt.getState().stopActivity(),nt.getState().stopSessionActivity(e),we()},[ve,be,we]),Ae=(0,v.useCallback)(async()=>{let e=ve.current,t=nt.getState(),n=t.getSessionActivity(e)?.runId||t.currentRunId||``;if(e&&n)try{await i.cancelRun(a,e,n),nt.getState().stopSessionActivity(e,`取消请求已发送,后台运行会停在最近 checkpoint。`)}catch(t){console.warn(`[App] cancelRun failed:`,t),nt.getState().updateActivity({sessionId:e,status:`failed`,phase:`取消请求失败`,detail:t instanceof Error?t.message:String(t),countEvent:!1})}xe(e)},[i,a,ve,xe]),{submitResponseFeedback:je,deleteResponseFeedback:Me,respondToApproval:Ne}=sM({agentId:a,currentSessionId:o,isStreaming:s,api:i,submitDraft:Ce}),Pe=(0,v.useRef)(Ne),Fe=(0,v.useRef)(Oe);(0,v.useEffect)(()=>{Pe.current=Ne,Fe.current=Oe},[Ne,Oe]);let{pending:Ie,records:Le,respond:Re,localCatalog:Be}=cM({agentId:a,getAgentId:()=>ye.current,currentSessionId:o,api:i,interactionV1Enabled:!!E.InteractionV1,onAcceptedInteraction:ue,legacyResponsesApproval:(e,t)=>{Pe.current({approvalRequestId:e,approve:t})},legacyAguiResume:(e,t,n)=>Fe.current({interruptId:e,approve:t===`resolved`})});$c({fetchSessions:ce},void 0,i,r),(0,v.useEffect)(()=>{ye.current=a,Pt(a,o)},[a,o,ye]),(0,v.useEffect)(()=>{ae?_e.getState().setWorkspacePanelFullscreen(!1):(_e.getState().setMobileSidebarOpen(!1),_e.getState().setMobileActionsOpen(!1))},[ae]),(0,v.useEffect)(()=>{w||_e.getState().setWorkspacePanelFullscreen(!1)},[w]),(0,v.useEffect)(()=>()=>{be.current?.abort()},[be]);let He=ze(E),We=!!E.Thinking,Ge=Ot({workspaceFiles:b,accessMode:x}),Ke=Et({isMobile:ae}),qe=Vt({capability:E.NativeDashboard,agentFramework:y,accessMode:x,origin:window.location.origin}),Je=!He,Ye=y===`openclaw`?`OpenClaw`:y===`hermes`?`Hermes`:`原生运行时`,Xe=Se?.display_name||f||``,Ze=!ae&&c&&He,Qe=(0,v.useRef)(!1),[$e,et]=(0,v.useState)(t===`tui`),tt=$e&&!!E.NativeTerminal?.Enabled;(0,v.useEffect)(()=>{Qe.current||t!==`workspace`||!Ge||(Qe.current=!0,_e.getState().setWorkspacePanelOpen(!0),_e.getState().setWorkspacePanelFullscreen(!0))},[t,Ge]);let it=()=>{_e.getState().setWorkspacePanelFullscreen(!1),_e.getState().setWorkspacePanelOpen(!1)};if(S!==`ready`){let e=S===`auth-required`,t=(0,k.jsx)(`div`,{className:`ksadk-web`,children:(0,k.jsx)(`div`,{className:`fixed inset-0 flex h-[var(--app-height)] min-h-[var(--app-height)] items-center justify-center bg-slate-50 px-6 font-sans text-slate-800 dark:bg-slate-950 dark:text-slate-100`,children:(0,k.jsxs)(`div`,{className:`w-full max-w-lg rounded-2xl border border-slate-200 bg-white p-8 text-center shadow-sm dark:border-slate-800 dark:bg-slate-900`,children:[(0,k.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-blue-50 text-xl text-blue-600 dark:bg-blue-950/50`,children:S===`loading`?`…`:`↗`}),(0,k.jsx)(`h1`,{className:`text-xl font-semibold`,children:S===`loading`?`正在连接 Agent`:e?`需要有效的访问链接`:`Agent 暂时无法连接`}),S===`loading`?null:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`p`,{className:`mt-3 text-sm leading-6 text-slate-500 dark:text-slate-400`,children:[C,e?` 请从 AgentEngine 控制台重新打开 Dashboard,或使用 agentengine dashboard open 获取临时链接。`:``]}),(0,k.jsx)(`button`,{type:`button`,className:`mt-6 rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white transition hover:bg-blue-500`,onClick:()=>window.location.reload(),children:`重新加载`})]})]})})});return n?(0,k.jsx)(n,{children:t}):t}let at=(0,k.jsx)(`div`,{className:`ksadk-web`,children:(0,k.jsxs)(`div`,{className:`fixed inset-0 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,k.jsx)(UR,{uiCapabilities:E,createNewSession:pe,deleteSession:ge,loadSession:le,loadMoreSessions:O}),(0,k.jsxs)(`main`,{className:`relative flex min-w-0 flex-1 flex-col bg-white dark:bg-slate-900`,children:[(0,k.jsx)(hY,{agentName:d,currentSessionId:o,nativeLauncherMode:Je,isMobile:ae,sidebarOpen:c,mobileSidebarOpen:l,onToggleSidebar:()=>{ae?_e.getState().toggleMobileSidebar():_e.getState().toggleSidebar()},availableModels:p,selectedModel:f,onSelectModel:e=>{Ue.getState().setSelectedModel(e),ae&&_e.getState().setMobileActionsOpen(!1)},selectedModelLabel:Xe,modelCatalogLoaded:h,modelSource:m,thinkingEnabled:We,thinkingMode:g,onSelectThinkingMode:e=>Ue.getState().setThinkingMode(Ut(e)),mobileActionsOpen:u,onMobileActionsOpenChange:e=>_e.getState().setMobileActionsOpen(e),workspaceEnabled:Ge,onOpenWorkspace:()=>_e.getState().setWorkspacePanelOpen(!0),nativeManagementLink:qe,nativeTerminal:E.NativeTerminal}),Je?(0,k.jsx)(_Y,{productLabel:Ye,nativeManagementLink:qe,nativeTerminal:E.NativeTerminal,workspaceEnabled:Ge,onOpenWorkspace:()=>_e.getState().setWorkspacePanelOpen(!0)}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(XJ,{agentName:d,isMobile:ae,onDeleteFeedback:Me,onSubmitFeedback:je,onRespondToApproval:Ne,onRespondToAguiApproval:Oe,onSubmitAguiAction:De,onStopGeneration:ke,onCancelRemote:E.StopRun?Ae:void 0,checkpointResumeEnabled:E.RunLifecycle.Enabled&&E.RunLifecycle.Checkpoints&&E.RunLifecycle.CheckpointResume,onResumeCheckpoint:Ee,onLoadOlderSessionMessages:fe,interactionRecords:Le}),(0,k.jsx)(fY,{onCompactContext:E.ContextCompaction&&i.compactSession?async()=>{if(!(!o||!i.compactSession)){if((await i.compactSession(a,o)).Status!==`completed`)throw Error(`运行时尚未确认压缩完成`);await ce(a,o)}}:void 0,composerMaxHeight:se,submitDraft:Ce,stopGeneration:ke,cancelRemote:E.StopRun?Ae:void 0,isMobile:ae,attachmentsEnabled:E.Attachments!==!1,approvalEnabled:!!E.Approval&&E.ApprovalPolicy?.RuntimeOverride!==!1,approvalPolicy:E.ApprovalPolicy,thinkingEnabled:We,runtimeCapabilityMatrix:E.RuntimeCapabilityMatrix,pendingInteractions:Ie,onRespondInteraction:e=>{Re(e)},localCatalog:Be})]})]}),(0,k.jsx)(Yce,{agentId:a,capability:b,workspacePanelOpen:w,workspacePanelWidth:T,workspacePanelFullscreen:ee,isMobile:ae,workspaceEnabled:Ge,workspaceFiles:b,workspacePanelPresentation:Ke,closeWorkspacePanel:it,handleWorkspacePanelResizeStart:e=>{if(ee||ae)return;e.preventDefault();let t=e.clientX,n=T,r=He&&Ze?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;_e.getState().setWorkspacePanelWidth(Ol(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:i}),ne&&(0,k.jsx)(v.Suspense,{fallback:null,children:(0,k.jsx)(Xce,{})}),tt?(0,k.jsx)(v.Suspense,{fallback:null,children:(0,k.jsx)(Zce,{capability:E.NativeTerminal,open:!0,sessionId:o,onClose:()=>et(!1)})}):null]})});return n?(0,k.jsx)(n,{children:at}):at}function ele(){return(0,k.jsx)(Qce,{})}function tle(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 $9=`agentengine-ui:chunk-reload-attempted`,nle=class extends v.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),tle(e))try{window.sessionStorage.getItem($9)||(window.sessionStorage.setItem($9,String(Date.now())),window.location.reload())}catch{window.location.reload()}}handleReload=()=>{try{window.sessionStorage.removeItem($9)}catch{}this.setState({hasError:!1,error:null}),window.location.reload()};render(){return this.state.hasError?(0,k.jsx)(`div`,{className:`flex h-screen w-screen items-center justify-center bg-slate-50 dark:bg-slate-900`,children:(0,k.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,k.jsx)(`div`,{className:`mb-4 text-4xl`,children:`⚠`}),(0,k.jsx)(`h1`,{className:`mb-2 text-xl font-semibold text-red-600 dark:text-red-400`,children:`页面渲染出错`}),(0,k.jsx)(`p`,{className:`mb-6 text-sm text-slate-600 dark:text-slate-400`,children:this.state.error?.message||`发生了未知错误,请刷新页面重试。`}),(0,k.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 rle(){let e=_e(e=>e.toasts),t=_e(e=>e.dismissToast);return(0,v.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,k.jsx)(`div`,{className:`fixed bottom-4 right-4 z-50 flex flex-col gap-2`,children:e.map(e=>(0,k.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,k.jsx)(`span`,{className:`flex-1`,children:e.message}),(0,k.jsx)(`button`,{onClick:()=>t(e.id),className:`shrink-0 rounded p-0.5 opacity-70 hover:opacity-100`,children:(0,k.jsx)(jN,{size:14})})]},e.id))}):null}y.createRoot(document.getElementById(`root`)).render((0,k.jsxs)(nle,{children:[(0,k.jsx)(ele,{}),(0,k.jsx)(rle,{})]}));export{jH as $,x3 as A,YX as B,I6 as C,pe as Ct,Z as D,l as Dt,g6 as E,s as Et,k3 as F,mq as G,hZ as H,$3 as I,GK as J,uq as K,k2 as L,w3 as M,Y3 as N,v3 as O,Z3 as P,VH as Q,R2 as R,P6 as S,rt as St,m6 as T,o as Tt,mJ as U,gX as V,J as W,VU as X,WW as Y,BH as Z,hae as _,fN as _t,Hse as a,Ez as at,$6 as b,sN as bt,L6 as c,GR as ct,V6 as d,jN as dt,dB as et,O8 as f,kN as ft,dae as g,hN as gt,uae as h,CN as ht,Z7 as i,Tz as it,T3 as j,O3 as k,Q as l,WR as lt,F6 as m,TN as mt,K9 as n,qz as nt,wce as o,wz as ot,fae as p,ON as pt,JK as q,Y7 as r,fre as rt,$ie as s,nz as st,G9 as t,iB as tt,q6 as u,K as ut,r8 as v,dN as vt,z6 as w,p as wt,J6 as x,rN as xt,n8 as y,cN as yt,Y as z};
|
|
244
|
+
<\/script>`,o=`${`<meta http-equiv="Content-Security-Policy" content="${U9(i)}">`}${r?`<base href="${U9(r)}">`:``}${a}`;return/<head[^>]*>/i.test(e)?e.replace(/<head[^>]*>/i,`$&${o}`):`${o}${e}`}function K9(e,t){let n=(0,v.useRef)(null);(0,v.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&&Vce(r)&&window.open(r,`_blank`,`noopener,noreferrer`)},window.addEventListener(`message`,n.current),()=>{n.current&&window.removeEventListener(`message`,n.current)}),[e,t])}function Hce({content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i,isMobile:a}){let o=(0,v.useRef)(null),s=(0,v.useId)(),[c,l]=(0,v.useState)(`preview`),u=_t(t),d=gt(t),f=(0,v.useCallback)(()=>G9(e,{basePath:u,channelId:s}),[e,u,s]),[p,m]=(0,v.useState)(f());(0,v.useEffect)(()=>{let e=setTimeout(()=>{m(f())},300);return()=>clearTimeout(e)},[f]),K9(o,s);let h=(0,v.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,k.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-slate-200 px-2 py-1.5 dark:border-slate-700`,children:[(0,k.jsxs)(`button`,{onClick:()=>l(`editor`),className:K(`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,k.jsx)(uN,{className:`h-3.5 w-3.5`}),`编辑`]}),(0,k.jsxs)(`button`,{onClick:()=>l(`preview`),className:K(`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,k.jsx)(hN,{className:`h-3.5 w-3.5`}),`预览`]})]}),c===`editor`?(0,k.jsx)(V9,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}):(0,k.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,k.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,k.jsx)(V9,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}),(0,k.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,k.jsx)(hN,{className:`h-3.5 w-3.5`}),`预览`]})]}):(0,k.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,k.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,k.jsxs)(`div`,{className:`absolute right-3 top-3 z-10 flex gap-1.5`,children:[(0,k.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,k.jsx)(mN,{className:`h-3.5 w-3.5`}),`新窗口`]}),(0,k.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,k.jsx)(uN,{className:`h-3.5 w-3.5`}),`编辑`]})]})]})}function q9(e){e.current&&clearTimeout(e.current)}function Uce({content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i,isMobile:a}){let[o,s]=(0,v.useState)(`editor`),[c,l]=(0,v.useState)(e),u=(0,v.useRef)(null);return(0,v.useEffect)(()=>(q9(u),u.current=setTimeout(()=>l(e),300),()=>q9(u)),[e]),a?(0,k.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,k.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,k.jsxs)(`button`,{onClick:()=>s(`editor`),className:K(`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,k.jsx)(uN,{className:`h-3.5 w-3.5`}),`编辑`]}),(0,k.jsxs)(`button`,{onClick:()=>s(`preview`),className:K(`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,k.jsx)(hN,{className:`h-3.5 w-3.5`}),`预览`]})]}),o===`editor`?(0,k.jsx)(V9,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}):(0,k.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:(0,k.jsx)(Aq,{content:c})})]}):o===`editor`?(0,k.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,k.jsx)(V9,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}),(0,k.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,k.jsx)(hN,{className:`h-3.5 w-3.5`}),`预览`]})]}):(0,k.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,k.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:(0,k.jsx)(Aq,{content:c})}),(0,k.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,k.jsx)(uN,{className:`h-3.5 w-3.5`}),`编辑`]})]})}var Wce=`/agentengine/api/v1/GetWorkspaceFileContent`,Gce=4e3;function J9(e){let t=mt(e);if(!t||t===`.`)return`.`;let n=t.split(`/`).filter(Boolean);return n.length<=1?`.`:n.slice(0,-1).join(`/`)}function Kce(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function Y9(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 qce=[{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 Jce(e){return gt(e)}function X9({label:e,showSupportedTypes:t=!1}){return(0,k.jsx)(`div`,{className:`flex h-full min-h-[16rem] flex-col items-center justify-center px-6 text-center`,children:(0,k.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,k.jsx)(`div`,{children:e}),t?(0,k.jsxs)(`div`,{className:`mt-4 text-left`,children:[(0,k.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-[0.12em] text-slate-400`,children:`支持在线预览`}),(0,k.jsx)(`div`,{className:`mt-2 grid gap-2`,children:qce.map(e=>(0,k.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,k.jsx)(`div`,{className:`text-sm font-medium text-slate-700 dark:text-slate-200`,children:e.label}),(0,k.jsx)(`div`,{className:`mt-0.5 font-mono text-[11px] text-slate-400`,children:e.detail})]},e.label))}),(0,k.jsx)(`div`,{className:`mt-3 text-xs leading-5 text-slate-400`,children:`Word、Excel、PPT 当前不支持在线预览,可下载后查看。`})]}):null]})})}function Z9({agentId:e,capability:t,open:n,onClose:r,isFullscreen:i=!1,onToggleFullscreen:a,isMobile:o=!1,api:s}){let c=(0,v.useRef)(null),l=(0,v.useRef)(null),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(`.`),[m,h]=(0,v.useState)([]),[g,_]=(0,v.useState)(!1),[y,b]=(0,v.useState)(!1),[x,S]=(0,v.useState)(!1),[C,w]=(0,v.useState)(``),[T,ee]=(0,v.useState)(null),[te,E]=(0,v.useState)(null),[ne,re]=(0,v.useState)(!1),[ie,ae]=(0,v.useState)(!1),oe=(0,v.useRef)(null),se=(0,v.useRef)(null),ce=(0,v.useRef)(`selection`),D=(0,v.useRef)(Dt()),O=(0,v.useMemo)(()=>m.find(e=>e.Path===T)??null,[m,T]),le=(0,v.useMemo)(()=>O?Tt({path:O.Path,mimeType:O.MimeType}):null,[O]),ue=(0,v.useCallback)(()=>ne?window.confirm(`当前文件有未保存的更改,确定要离开吗?`):!0,[ne]),de=t.ContentPath||Wce,fe=t.RootLabel||`Workspace`,pe=fe?`${fe.charAt(0).toUpperCase()}${fe.slice(1)}`:`Workspace`,me=yt(f),he=(0,v.useCallback)(()=>{l.current&&=(URL.revokeObjectURL(l.current),null)},[]);(0,v.useEffect)(()=>()=>he(),[he]);let ge=(0,v.useCallback)(async(t,n={})=>{let r=!!n.background;r?b(!0):_(!0),r||w(``);try{let n=await s.listWorkspaceFiles(e,t,!1),i=mt(String(n?.Path||t||`.`)),a=Array.isArray(n?.Entries)?n.Entries:[];p(i),h(a),ce.current=r?`background-refresh`:`selection`,ee(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?b(!1):_(!1)}},[e,s]);(0,v.useEffect)(()=>{!n||u||(d(!0),ge(`.`))},[u,ge,n]),(0,v.useEffect)(()=>{if(!n||ne||!u)return;let e=window.setInterval(()=>{ge(f,{background:!0})},Gce);return()=>window.clearInterval(e)},[f,ne,u,ge,n]);let _e=(0,v.useCallback)(async t=>{let n=D.current.next(t.Path),r=Ct({path:t.Path,mimeType:t.MimeType});if(se.current=t.Path,r===`unsupported`){he(),E({path:t.Path,kind:r,status:`ready`,mimeType:t.MimeType??void 0});return}he(),E({path:t.Path,kind:r,status:`loading`,mimeType:t.MimeType??void 0});try{let r=await s.getWorkspaceFileContent(e,t.Path,{asText:!1});if(!D.current.isCurrent(n))return;if(r instanceof Blob){let e=t.MimeType||``,i=Ct({path:t.Path,mimeType:e});if(i===`image`||i===`pdf`){let n=URL.createObjectURL(r);l.current=n,E({path:t.Path,kind:i,status:`ready`,mimeType:e,objectUrl:n});return}let a=await r.text();if(!D.current.isCurrent(n))return;let o=Ct({path:t.Path,mimeType:e});E({path:t.Path,kind:o,status:`ready`,mimeType:e,content:a})}else{let e=t.MimeType||``,n=Ct({path:t.Path,mimeType:e});E({path:t.Path,kind:n,status:`ready`,mimeType:e,content:r})}}catch(e){if(!D.current.isCurrent(n))return;console.error(`Failed to preview workspace file:`,e),E({path:t.Path,kind:r,status:`error`,mimeType:t.MimeType??void 0,error:e instanceof Error?e.message:String(e)})}},[e,s,he]);(0,v.useEffect)(()=>{if(!O||O.Type!==`file`){he(),E(null),re(!1),se.current=null;return}if(ce.current===`background-refresh`&&se.current===O.Path){ce.current=`selection`;return}ce.current=`selection`,_e(O)},[he,_e,O]);let ve=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=vt(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 ge(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)}}},ye=async n=>{if(!t.SupportsDelete)return;let r=mt(n.Path);if(window.confirm(`删除 ${r} ?`)){w(``);try{await s.deleteWorkspaceFile(e,r),T&&mt(T)===r&&(ee(null),re(!1)),await ge(n.Type===`directory`&&(mt(f)===r||mt(f).startsWith(`${r}/`))?J9(r):f)}catch(e){console.error(`Failed to delete workspace file:`,e),w(e instanceof Error?e.message:String(e))}}},be=()=>!O||O.Type!==`file`?(0,k.jsx)(X9,{label:`从左侧选择文件后在这里查看内容预览。`,showSupportedTypes:!0}):!te||te.path!==O.Path||te.status===`loading`?(0,k.jsx)(`div`,{className:`flex h-full min-h-[16rem] items-center justify-center`,children:(0,k.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,k.jsx)(yN,{className:`h-4 w-4 animate-spin`}),`正在加载预览...`]})}):te.status===`error`?(0,k.jsx)(X9,{label:te.error||`文件预览加载失败。`}):te.kind===`markdown`?(0,k.jsx)(Uce,{content:te.content||``,path:O.Path,onSave:xe,onDirtyChange:re,getContentRef:oe,isMobile:o}):te.kind===`image`&&te.objectUrl?(0,k.jsx)(H9,{content:null,objectUrl:te.objectUrl,kind:`image`,filename:O.Name,mimeType:te.mimeType||``}):te.kind===`pdf`&&te.objectUrl?(0,k.jsx)(H9,{content:null,objectUrl:te.objectUrl,kind:`pdf`,filename:O.Name,mimeType:te.mimeType||``}):te.kind===`html`?(0,k.jsx)(Hce,{content:te.content||``,path:O.Path,onSave:xe,onDirtyChange:re,getContentRef:oe,isMobile:o,agentId:e,contentPath:de}):te.kind===`text`||te.kind===`code`?(0,k.jsx)(V9,{content:te.content||``,path:O.Path,onSave:xe,onDirtyChange:re,getContentRef:oe}):(0,k.jsx)(H9,{content:null,kind:`unsupported`,filename:O.Name,mimeType:te.mimeType||``}),xe=async t=>{if(O){ae(!0),w(``);try{let n=new Blob([t],{type:O.MimeType||`text/plain`}),r=new FormData;r.append(`file`,n,O.Name),r.append(`AgentId`,e),r.append(`Path`,O.Path),await s.addWorkspaceFile(r),D.current.invalidate(),re(!1),E(e=>e&&e.path===O.Path?{...e,content:t}:e),se.current=O.Path,await ge(f,{background:!0})}catch(e){console.error(`Failed to save workspace file:`,e),w(e instanceof Error?e.message:String(e))}finally{ae(!1)}}},Se=O?.Type===`file`&&te?.path===O.Path&&te.status===`ready`&&(te.kind===`text`||te.kind===`code`||te.kind===`html`||te.kind===`markdown`),Ce=O?.Type===`file`&&te?.path===O.Path&&te.status===`ready`&&te.kind===`pdf`;return(0,k.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,k.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,k.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,k.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100`,children:pe}),(0,k.jsx)(`div`,{className:`hidden h-4 w-px bg-slate-200/70 dark:bg-slate-800 sm:block`}),(0,k.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,k.jsx)(`span`,{className:`flex-shrink-0 text-xs text-slate-400`,children:`当前目录`}),(0,k.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:`${me},来自 ListWorkspaceFiles 返回的 Data.Path 字段`,children:me})]}),(0,k.jsx)(`div`,{className:`hidden truncate text-[11px] text-slate-400 xl:block`,children:`工作区内相对路径,不是宿主机绝对路径。`})]}),(0,k.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-1.5`,children:[(0,k.jsx)(`input`,{ref:c,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void ve(e.target.files)}),(0,k.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,k.jsx)(AN,{className:`h-3.5 w-3.5`}),x?`上传中`:`上传`]}),(0,k.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,k.jsx)(Hne,{className:`h-3.5 w-3.5`}),`导出`]}),a?(0,k.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,k.jsx)(Vne,{className:`h-4 w-4`}):(0,k.jsx)(Lne,{className:`h-4 w-4`})}):null,r?(0,k.jsx)(`button`,{type:`button`,onClick:()=>{ue()&&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,k.jsx)(jN,{className:`h-4 w-4`})}):null]})]}),(0,k.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col md:flex-row`,children:[(0,k.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,k.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,k.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`div`,{className:`text-xs font-medium text-slate-900 dark:text-slate-100`,children:`文件`}),(0,k.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] text-slate-400`,children:[(0,k.jsxs)(`span`,{children:[m.length,` 项`]}),y?(0,k.jsx)(TN,{className:`h-3 w-3 animate-spin`,"aria-label":`正在同步 Workspace 目录`}):null]})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>{ue()&&ge(J9(f))},disabled:g||vt(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,k.jsx)(aN,{className:`h-4 w-4`})}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>{ue()&&ge(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,k.jsx)(TN,{className:`h-4 w-4 ${g?`animate-spin`:``}`})})]})]}),C?(0,k.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,k.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto px-2 py-2`,children:!u&&!n?(0,k.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`打开面板后加载 workspace 文件。`}):g?(0,k.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`正在加载目录...`}):m.length===0?(0,k.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`当前目录为空。`}):(0,k.jsx)(`div`,{className:`space-y-0.5`,children:m.map(e=>{let n=Ct({path:e.Path,mimeType:e.MimeType}),r=T===e.Path,i=e.Type===`file`?Jce(e.Path):``;return(0,k.jsxs)(`div`,{title:e.Path,className:K(`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,k.jsxs)(`button`,{type:`button`,onClick:()=>{if(e.Type===`directory`){ge(e.Path);return}T!==e.Path&&!ue()||ee(e.Path)},className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,k.jsx)(`div`,{className:K(`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,k.jsx)(_N,{className:`h-3.5 w-3.5`}):n===`image`?(0,k.jsx)(Fne,{className:`h-3.5 w-3.5`}):n===`markdown`||n===`text`||n===`html`?(0,k.jsx)(Nne,{className:`h-3.5 w-3.5`}):(0,k.jsx)(gN,{className:`h-3.5 w-3.5`})}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(`div`,{className:`truncate text-[13px] leading-5`,children:e.Name}),(0,k.jsx)(`div`,{className:K(`truncate text-[11px] leading-4`,r?`text-slate-500 dark:text-slate-400`:`text-slate-400`),children:e.Type===`directory`?`目录`:Y9(e.SizeBytes)})]})]}),(0,k.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-0.5 opacity-0 transition group-hover:opacity-100`,children:[e.Type===`file`?(0,k.jsx)(`a`,{href:i,download:e.Name,className:K(`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,k.jsx)(fN,{className:`h-3.5 w-3.5`})}):null,t.SupportsDelete?(0,k.jsx)(`button`,{type:`button`,onClick:()=>void ye(e),className:K(`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,k.jsx)(kN,{className:`h-3.5 w-3.5`})}):null]})]},e.Path)})})})]}),(0,k.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,k.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:O?(0,k.jsxs)(`div`,{className:`flex w-full items-start justify-between gap-3`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100`,children:O.Name}),(0,k.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-[11px] text-slate-400`,children:O.Path}),(0,k.jsxs)(`div`,{className:`mt-1 text-[11px] text-slate-400`,children:[Y9(O.SizeBytes),O.MimeType?` · ${O.MimeType}`:``,O.ModifiedAt?` · ${Kce(O.ModifiedAt)}`:``]})]}),le===`text`||le===`code`||le===`html`||le===`markdown`?(0,k.jsxs)(`button`,{type:`button`,onClick:()=>{let e=oe.current;e&&xe(e())},disabled:!ne||ie,className:K(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition`,ne&&!ie?`bg-blue-600 text-white hover:bg-blue-700`:`text-slate-400 dark:text-slate-500 cursor-not-allowed`),children:[(0,k.jsx)(Kne,{className:`h-3.5 w-3.5`}),ie?`保存中`:ne?`保存`:`已保存`]}):null]}):(0,k.jsxs)(`div`,{className:`w-full`,children:[(0,k.jsx)(`div`,{className:`text-sm font-semibold text-slate-900 dark:text-slate-100`,children:`文件预览`}),(0,k.jsx)(`div`,{className:`mt-0.5 text-xs text-slate-500 dark:text-slate-400`,children:`选择左侧文件后可在此查看内容。`})]})}),(0,k.jsx)(`div`,{className:K(`custom-scrollbar min-h-0 flex-1`,Ce||Se?`overflow-hidden p-0`:`overflow-y-auto px-4 py-4`),children:be()})]})]})]})}function Yce({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,k.jsxs)(k.Fragment,{children:[f?(0,k.jsxs)(k.Fragment,{children:[n&&!i?(0,k.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,k.jsx)(`aside`,{style:n&&!i?{width:`${r}px`}:void 0,className:K(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,k.jsx)(Z9,{agentId:e,capability:t,open:n,onClose:l,isFullscreen:i,onToggleFullscreen:()=>_e.getState().setWorkspacePanelFullscreen(!i),isMobile:a,api:d}):null})]}):null,p?(0,k.jsx)(NR,{open:n,onOpenChange:e=>{e||_e.getState().setWorkspacePanelFullscreen(!1),_e.getState().setWorkspacePanelOpen(e)},modal:c.modal,children:(0,k.jsxs)(LR,{side:c.side,showOverlay:c.showOverlay,onInteractOutside:e=>{c.preventOutsideClose&&e.preventDefault()},showCloseButton:!1,className:K(`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,k.jsx)(BR,{className:`sr-only`,children:`Workspace 文件`}),(0,k.jsx)(VR,{className:`sr-only`,children:`浏览、上传和预览 Workspace 文件。`}),(0,k.jsx)(Z9,{agentId:e,capability:t,open:n,onClose:l,isMobile:a,api:d})]})}):null]})}var Q9=new Jc,Xce=v.lazy(()=>J(()=>import(`./ArtifactsPanel-C1YoaKhx.js`).then(e=>({default:e.ArtifactsPanel})),[],import.meta.url)),Zce=v.lazy(()=>J(()=>import(`./NativeTerminalPanel-oJj44_sV.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function Qce(e={}){let t=e.apiAdapter||Q9,[n,r]=(0,v.useState)(null);if((0,v.useEffect)(()=>{let e=new AbortController;return t.getAgentUiBootstrap(void 0,{signal:e.signal}).then(n=>{e.signal.aborted||r({api:t,data:n})}).catch(()=>{e.signal.aborted||r({api:t,data:void 0})}),()=>e.abort()},[t]),!n||n.api!==t)return(0,k.jsx)(me,{});let i=n.data?.AuthorizationScopeKey;return(0,k.jsx)(he,{authorizationScopeKey:e.authorizationScopeKey??(typeof i==`string`&&i?i:void 0),children:(0,k.jsx)($ce,{...e,bootstrapData:n.data})})}function $ce({apiAdapter:e,initialSurface:t=`chat`,routeShell:n,bootstrapData:r}){let i=e||Q9,a=Ve(e=>e.agentId),o=D(e=>e.currentSessionId),s=nt(e=>e.isStreaming),c=_e(e=>e.sidebarOpen),l=_e(e=>e.mobileSidebarOpen),u=_e(e=>e.mobileActionsOpen),d=Ve(e=>e.agentName),f=Ue(e=>e.selectedModel),p=Ue(e=>e.availableModels),m=Ue(e=>e.modelSource),h=Ue(e=>e.modelCatalogLoaded),g=Ue(e=>e.thinkingMode),_=de(e=>e.permissionMode),y=Ve(e=>e.agentFramework),b=Ve(e=>e.workspaceFiles),x=Ve(e=>e.accessMode),S=Ve(e=>e.status),C=Ve(e=>e.errorMessage),w=_e(e=>e.workspacePanelOpen),T=_e(e=>e.workspacePanelWidth),ee=_e(e=>e.workspacePanelFullscreen),te=Ve(e=>e.apiFormats),E=Ve(e=>e.capabilities),ne=rt(e=>e.visible&&!!e.content),re=(0,v.useRef)([]),ie=(0,v.useRef)(null),{isMobile:ae,viewportHeight:oe}=qt(),se=st({isMobile:ae,viewportHeight:oe}),{fetchSessions:ce,loadMoreSessions:O,loadSession:le,followAcceptedInteraction:ue,loadOlderSessionMessages:fe,createNewSession:pe,adoptCreatedSession:me,waitForPendingSessionCreation:he,deleteSession:ge,currentSessionIdRef:ve,agentIdRef:ye,runSubscriptionAbortRef:be}=qM({agentId:a,currentSessionId:o,isMobile:ae,uiCapabilities:E,api:i,resetCompaction:()=>{},disconnectRun:()=>ie.current?.()}),xe=(0,v.useCallback)(e=>{if(!e)return;let t=()=>{D.getState().clearSessionMessageHistory(e),ce(ye.current,e)};queueMicrotask(t),window.setTimeout(t,1800),window.setTimeout(t,5e3)},[ye,ce]),Se=p.find(e=>e.id===f)||null,{submitDraft:Ce,stopGeneration:we,disconnectRun:Te,resumeCheckpoint:Ee,submitAguiAction:De,respondToAguiApproval:Oe}=Xj({agentId:a,currentSessionId:o,agentFramework:y,apiFormats:te,selectedModel:f,selectedModelMetadata:Se,thinkingMode:g,permissionMode:_,uiCapabilities:E,isMobile:ae,api:i,currentSessionIdRef:ve,agentIdRef:ye,queuedDraftRef:re,onRunSettled:xe,onSessionCreated:e=>me(e,!0),waitForPendingSessionCreation:he});(0,v.useEffect)(()=>{ie.current=Te},[Te]);let ke=(0,v.useCallback)(()=>{let e=ve.current;be.current?.abort(),nt.getState().stopActivity(),nt.getState().stopSessionActivity(e),we()},[ve,be,we]),Ae=(0,v.useCallback)(async()=>{let e=ve.current,t=nt.getState(),n=t.getSessionActivity(e)?.runId||t.currentRunId||``;if(e&&n)try{await i.cancelRun(a,e,n),nt.getState().stopSessionActivity(e,`取消请求已发送,后台运行会停在最近 checkpoint。`)}catch(t){console.warn(`[App] cancelRun failed:`,t),nt.getState().updateActivity({sessionId:e,status:`failed`,phase:`取消请求失败`,detail:t instanceof Error?t.message:String(t),countEvent:!1})}xe(e)},[i,a,ve,xe]),{submitResponseFeedback:je,deleteResponseFeedback:Me,respondToApproval:Ne}=sM({agentId:a,currentSessionId:o,isStreaming:s,api:i,submitDraft:Ce}),Pe=(0,v.useRef)(Ne),Fe=(0,v.useRef)(Oe);(0,v.useEffect)(()=>{Pe.current=Ne,Fe.current=Oe},[Ne,Oe]);let{pending:Ie,records:Le,respond:Re,localCatalog:Be}=cM({agentId:a,getAgentId:()=>ye.current,currentSessionId:o,api:i,interactionV1Enabled:!!E.InteractionV1,onAcceptedInteraction:ue,legacyResponsesApproval:(e,t)=>{Pe.current({approvalRequestId:e,approve:t})},legacyAguiResume:(e,t,n)=>Fe.current({interruptId:e,approve:t===`resolved`})});$c({fetchSessions:ce},void 0,i,r),(0,v.useEffect)(()=>{ye.current=a,Pt(a,o)},[a,o,ye]),(0,v.useEffect)(()=>{ae?_e.getState().setWorkspacePanelFullscreen(!1):(_e.getState().setMobileSidebarOpen(!1),_e.getState().setMobileActionsOpen(!1))},[ae]),(0,v.useEffect)(()=>{w||_e.getState().setWorkspacePanelFullscreen(!1)},[w]),(0,v.useEffect)(()=>()=>{be.current?.abort()},[be]);let He=ze(E),We=!!E.Thinking,Ge=Ot({workspaceFiles:b,accessMode:x}),Ke=Et({isMobile:ae}),qe=Vt({capability:E.NativeDashboard,agentFramework:y,accessMode:x,origin:window.location.origin}),Je=!He,Ye=y===`openclaw`?`OpenClaw`:y===`hermes`?`Hermes`:`原生运行时`,Xe=Se?.display_name||f||``,Ze=!ae&&c&&He,Qe=(0,v.useRef)(!1),[$e,et]=(0,v.useState)(t===`tui`),tt=$e&&!!E.NativeTerminal?.Enabled;(0,v.useEffect)(()=>{Qe.current||t!==`workspace`||!Ge||(Qe.current=!0,_e.getState().setWorkspacePanelOpen(!0),_e.getState().setWorkspacePanelFullscreen(!0))},[t,Ge]);let it=()=>{_e.getState().setWorkspacePanelFullscreen(!1),_e.getState().setWorkspacePanelOpen(!1)};if(S!==`ready`){let e=S===`auth-required`,t=(0,k.jsx)(`div`,{className:`ksadk-web`,children:(0,k.jsx)(`div`,{className:`fixed inset-0 flex h-[var(--app-height)] min-h-[var(--app-height)] items-center justify-center bg-slate-50 px-6 font-sans text-slate-800 dark:bg-slate-950 dark:text-slate-100`,children:(0,k.jsxs)(`div`,{className:`w-full max-w-lg rounded-2xl border border-slate-200 bg-white p-8 text-center shadow-sm dark:border-slate-800 dark:bg-slate-900`,children:[(0,k.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-blue-50 text-xl text-blue-600 dark:bg-blue-950/50`,children:S===`loading`?`…`:`↗`}),(0,k.jsx)(`h1`,{className:`text-xl font-semibold`,children:S===`loading`?`正在连接 Agent`:e?`需要有效的访问链接`:`Agent 暂时无法连接`}),S===`loading`?null:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`p`,{className:`mt-3 text-sm leading-6 text-slate-500 dark:text-slate-400`,children:[C,e?` 请从 AgentEngine 控制台重新打开 Dashboard,或使用 agentengine dashboard open 获取临时链接。`:``]}),(0,k.jsx)(`button`,{type:`button`,className:`mt-6 rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white transition hover:bg-blue-500`,onClick:()=>window.location.reload(),children:`重新加载`})]})]})})});return n?(0,k.jsx)(n,{children:t}):t}let at=(0,k.jsx)(`div`,{className:`ksadk-web`,children:(0,k.jsxs)(`div`,{className:`fixed inset-0 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,k.jsx)(UR,{uiCapabilities:E,createNewSession:pe,deleteSession:ge,loadSession:le,loadMoreSessions:O}),(0,k.jsxs)(`main`,{className:`relative flex min-w-0 flex-1 flex-col bg-white dark:bg-slate-900`,children:[(0,k.jsx)(hY,{agentName:d,currentSessionId:o,nativeLauncherMode:Je,isMobile:ae,sidebarOpen:c,mobileSidebarOpen:l,onToggleSidebar:()=>{ae?_e.getState().toggleMobileSidebar():_e.getState().toggleSidebar()},availableModels:p,selectedModel:f,onSelectModel:e=>{Ue.getState().setSelectedModel(e),ae&&_e.getState().setMobileActionsOpen(!1)},selectedModelLabel:Xe,modelCatalogLoaded:h,modelSource:m,thinkingEnabled:We,thinkingMode:g,onSelectThinkingMode:e=>Ue.getState().setThinkingMode(Ut(e)),mobileActionsOpen:u,onMobileActionsOpenChange:e=>_e.getState().setMobileActionsOpen(e),workspaceEnabled:Ge,onOpenWorkspace:()=>_e.getState().setWorkspacePanelOpen(!0),nativeManagementLink:qe,nativeTerminal:E.NativeTerminal}),Je?(0,k.jsx)(_Y,{productLabel:Ye,nativeManagementLink:qe,nativeTerminal:E.NativeTerminal,workspaceEnabled:Ge,onOpenWorkspace:()=>_e.getState().setWorkspacePanelOpen(!0)}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(XJ,{agentName:d,isMobile:ae,onDeleteFeedback:Me,onSubmitFeedback:je,onRespondToApproval:Ne,onRespondToAguiApproval:Oe,onSubmitAguiAction:De,onStopGeneration:ke,onCancelRemote:E.StopRun?Ae:void 0,checkpointResumeEnabled:E.RunLifecycle.Enabled&&E.RunLifecycle.Checkpoints&&E.RunLifecycle.CheckpointResume,onResumeCheckpoint:Ee,onLoadOlderSessionMessages:fe,interactionRecords:Le}),(0,k.jsx)(fY,{onCompactContext:E.ContextCompaction&&i.compactSession?async()=>{if(!(!o||!i.compactSession)){if((await i.compactSession(a,o)).Status!==`completed`)throw Error(`运行时尚未确认压缩完成`);await ce(a,o)}}:void 0,composerMaxHeight:se,submitDraft:Ce,stopGeneration:ke,cancelRemote:E.StopRun?Ae:void 0,isMobile:ae,attachmentsEnabled:E.Attachments!==!1,approvalEnabled:!!E.Approval&&E.ApprovalPolicy?.RuntimeOverride!==!1,approvalPolicy:E.ApprovalPolicy,thinkingEnabled:We,runtimeCapabilityMatrix:E.RuntimeCapabilityMatrix,pendingInteractions:Ie,onRespondInteraction:e=>{Re(e)},localCatalog:Be})]})]}),(0,k.jsx)(Yce,{agentId:a,capability:b,workspacePanelOpen:w,workspacePanelWidth:T,workspacePanelFullscreen:ee,isMobile:ae,workspaceEnabled:Ge,workspaceFiles:b,workspacePanelPresentation:Ke,closeWorkspacePanel:it,handleWorkspacePanelResizeStart:e=>{if(ee||ae)return;e.preventDefault();let t=e.clientX,n=T,r=He&&Ze?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;_e.getState().setWorkspacePanelWidth(Ol(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:i}),ne&&(0,k.jsx)(v.Suspense,{fallback:null,children:(0,k.jsx)(Xce,{})}),tt?(0,k.jsx)(v.Suspense,{fallback:null,children:(0,k.jsx)(Zce,{capability:E.NativeTerminal,open:!0,sessionId:o,onClose:()=>et(!1)})}):null]})});return n?(0,k.jsx)(n,{children:at}):at}function ele(){return(0,k.jsx)(Qce,{})}function tle(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 $9=`agentengine-ui:chunk-reload-attempted`,nle=class extends v.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),tle(e))try{window.sessionStorage.getItem($9)||(window.sessionStorage.setItem($9,String(Date.now())),window.location.reload())}catch{window.location.reload()}}handleReload=()=>{try{window.sessionStorage.removeItem($9)}catch{}this.setState({hasError:!1,error:null}),window.location.reload()};render(){return this.state.hasError?(0,k.jsx)(`div`,{className:`flex h-screen w-screen items-center justify-center bg-slate-50 dark:bg-slate-900`,children:(0,k.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,k.jsx)(`div`,{className:`mb-4 text-4xl`,children:`⚠`}),(0,k.jsx)(`h1`,{className:`mb-2 text-xl font-semibold text-red-600 dark:text-red-400`,children:`页面渲染出错`}),(0,k.jsx)(`p`,{className:`mb-6 text-sm text-slate-600 dark:text-slate-400`,children:this.state.error?.message||`发生了未知错误,请刷新页面重试。`}),(0,k.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 rle(){let e=_e(e=>e.toasts),t=_e(e=>e.dismissToast);return(0,v.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,k.jsx)(`div`,{className:`fixed bottom-4 right-4 z-50 flex flex-col gap-2`,children:e.map(e=>(0,k.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,k.jsx)(`span`,{className:`flex-1`,children:e.message}),(0,k.jsx)(`button`,{onClick:()=>t(e.id),className:`shrink-0 rounded p-0.5 opacity-70 hover:opacity-100`,children:(0,k.jsx)(jN,{size:14})})]},e.id))}):null}y.createRoot(document.getElementById(`root`)).render((0,k.jsxs)(nle,{children:[(0,k.jsx)(ele,{}),(0,k.jsx)(rle,{})]}));export{jH as $,x3 as A,YX as B,I6 as C,pe as Ct,Z as D,l as Dt,g6 as E,s as Et,k3 as F,mq as G,hZ as H,$3 as I,GK as J,uq as K,k2 as L,w3 as M,Y3 as N,v3 as O,Z3 as P,VH as Q,R2 as R,P6 as S,rt as St,m6 as T,o as Tt,mJ as U,gX as V,J as W,VU as X,WW as Y,BH as Z,hae as _,fN as _t,Hse as a,Ez as at,$6 as b,sN as bt,L6 as c,GR as ct,V6 as d,jN as dt,dB as et,O8 as f,kN as ft,dae as g,hN as gt,uae as h,CN as ht,Z7 as i,Tz as it,T3 as j,O3 as k,Q as l,WR as lt,F6 as m,TN as mt,K9 as n,qz as nt,wce as o,wz as ot,fae as p,ON as pt,JK as q,Y7 as r,fre as rt,$ie as s,nz as st,G9 as t,iB as tt,q6 as u,K as ut,r8 as v,dN as vt,z6 as w,p as wt,J6 as x,rN as xt,n8 as y,cN as yt,Y as z};
|