@kingsoftcloud/ksadk-web 0.3.5 → 0.3.6
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/CHANGELOG.md +9 -0
- package/RELEASE_PROVENANCE.json +2 -2
- package/dist-ksadk/assets/{ArtifactsPanel-9RUQms_7.js → ArtifactsPanel-Ci-uVB1V.js} +1 -1
- package/dist-ksadk/assets/{CodeBlock-iq6mFygx.js → CodeBlock-Bs7KdIr5.js} +1 -1
- package/dist-ksadk/assets/{MathMessageMarkdown-DSd_MMwp.js → MathMessageMarkdown-C4aqRWHc.js} +2 -2
- package/dist-ksadk/assets/{MermaidBlock-B1tXyzN9.js → MermaidBlock-SfTSCYPD.js} +6 -6
- package/dist-ksadk/assets/{NativeTerminalPanel-BTTm24gh.js → NativeTerminalPanel-D4469o8R.js} +1 -1
- package/dist-ksadk/assets/{abnfDiagram-VCTEODGH-CrPuGQ-J.js → abnfDiagram-VCTEODGH-DrkbRVUB.js} +1 -1
- package/dist-ksadk/assets/{arc-LSpozW7f.js → arc--N-SlvcB.js} +1 -1
- package/dist-ksadk/assets/architecture-7GRP2DOG-BqHCyWeg.js +1 -0
- package/dist-ksadk/assets/{architectureDiagram-5GKGNRK7-BiBddfc6.js → architectureDiagram-5GKGNRK7-CVY40LaN.js} +1 -1
- package/dist-ksadk/assets/{blockDiagram-NRAW4CY4-Cfpt59CA.js → blockDiagram-NRAW4CY4-ByT8Mf2K.js} +1 -1
- package/dist-ksadk/assets/{c4Diagram-UCG6FXSJ-TtkMYecK.js → c4Diagram-UCG6FXSJ-CD872g0K.js} +1 -1
- package/dist-ksadk/assets/channel-Coa1sp6C.js +1 -0
- package/dist-ksadk/assets/chunk-2Q5K7J3B-DsFmVSN9.js +1 -0
- package/dist-ksadk/assets/{chunk-5VM5RSS4-QNTrS1KC.js → chunk-5VM5RSS4-DHt45oYW.js} +1 -1
- package/dist-ksadk/assets/{chunk-F27PBJKO-CHsVsbjO.js → chunk-F27PBJKO-DaF_3kAI.js} +1 -1
- package/dist-ksadk/assets/{chunk-G27WJ6UU-BiyNaPce.js → chunk-G27WJ6UU-BA8YNT5P.js} +1 -1
- package/dist-ksadk/assets/{chunk-JWPE2WC7-EjVrwIfj.js → chunk-JWPE2WC7-zNpvDS81.js} +1 -1
- package/dist-ksadk/assets/{chunk-LCL6LL3I-BCXNTVwQ.js → chunk-LCL6LL3I-CEggtrMX.js} +1 -1
- package/dist-ksadk/assets/{chunk-POPQ4Y6H-BNP6opFp.js → chunk-POPQ4Y6H-Cc1cWxmR.js} +1 -1
- package/dist-ksadk/assets/{chunk-RHFEMEQ7-CroPk1q-.js → chunk-RHFEMEQ7-D62WfyW_.js} +1 -1
- package/dist-ksadk/assets/{chunk-SVP7TREG-8eF2thNo.js → chunk-SVP7TREG-D2mcy9Rw.js} +1 -1
- package/dist-ksadk/assets/{chunk-XXDRQBXY-CfKEfSWB.js → chunk-XXDRQBXY-Dx1kmIl_.js} +1 -1
- package/dist-ksadk/assets/classDiagram-DTDB5LWJ-CYwIXL9J.js +1 -0
- package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-CYwIXL9J.js +1 -0
- package/dist-ksadk/assets/{cose-bilkent-JH36ORCC-NYLLr4y3.js → cose-bilkent-JH36ORCC-B5niRPCY.js} +1 -1
- package/dist-ksadk/assets/cynefin-OW5HDTMX-Bnax5hCk.js +1 -0
- package/dist-ksadk/assets/{cynefinDiagram-5FMLGOSQ-1t2bjASn.js → cynefinDiagram-5FMLGOSQ-DFfJ9u8F.js} +1 -1
- package/dist-ksadk/assets/{dagre-3AP2YEHR-CyCcpGXQ.js → dagre-3AP2YEHR-BrPUj5we.js} +1 -1
- package/dist-ksadk/assets/{dagre-DIBkWWe5.js → dagre-J9T9lGqd.js} +1 -1
- package/dist-ksadk/assets/{diagram-S7CK7UJ4-Qnyx09fY.js → diagram-S7CK7UJ4-dw09FBMD.js} +1 -1
- package/dist-ksadk/assets/{diagram-UQ7AKVKN-BBuBi2BK.js → diagram-UQ7AKVKN-BqkIPows.js} +1 -1
- package/dist-ksadk/assets/{diagram-VSXAHHWV-Cu2pi7DX.js → diagram-VSXAHHWV-iO4XlpWi.js} +1 -1
- package/dist-ksadk/assets/{diagram-VX7I27RA-D1hy0wPv.js → diagram-VX7I27RA-DRMax9wk.js} +1 -1
- package/dist-ksadk/assets/{diagram-Z3DM3KII-DG_ukeOg.js → diagram-Z3DM3KII-_JoXBxpU.js} +1 -1
- package/dist-ksadk/assets/{dist-BoDw8sHC.js → dist-B5ACVHAD.js} +1 -1
- package/dist-ksadk/assets/{dist-snMJ4dAH.js → dist-B8Xx9Bcu.js} +1 -1
- package/dist-ksadk/assets/{dist-dLCAHoLT.js → dist-BD6pm3IK.js} +1 -1
- package/dist-ksadk/assets/{dist-Bami3Hbn.js → dist-BZBDMLXX.js} +1 -1
- package/dist-ksadk/assets/{dist-_RQDZ9v3.js → dist-BcF5XYGL.js} +1 -1
- package/dist-ksadk/assets/{dist-Bzd96FWg.js → dist-BcWjNWFB.js} +1 -1
- package/dist-ksadk/assets/{dist-BDYKkv8k.js → dist-BuVggBmt.js} +1 -1
- package/dist-ksadk/assets/{dist-BRFE6wml.js → dist-C5xBbsOZ.js} +1 -1
- package/dist-ksadk/assets/{dist-C6YcRSBB.js → dist-C6T-wP4s.js} +1 -1
- package/dist-ksadk/assets/{dist-39frJg8c.js → dist-CHgoCvLH.js} +1 -1
- package/dist-ksadk/assets/{dist-BbqgJcRm.js → dist-CTRKDU8K.js} +1 -1
- package/dist-ksadk/assets/{dist-32Woo6w8.js → dist-CYNfiHL_.js} +1 -1
- package/dist-ksadk/assets/{dist-vM3yu1Iv.js → dist-D-7_sx4d.js} +1 -1
- package/dist-ksadk/assets/{dist-CsdC51-G.js → dist-D0V4p2BH.js} +1 -1
- package/dist-ksadk/assets/{dist-7mNpnBIq.js → dist-DHWEsppc.js} +1 -1
- package/dist-ksadk/assets/{dist-C8E2u2Gy.js → dist-DLGYftqv.js} +1 -1
- package/dist-ksadk/assets/{dist-D0t-jg0i.js → dist-DTeQCULT.js} +1 -1
- package/dist-ksadk/assets/{dist-Dbb1c9iJ.js → dist-DaJnfr3_.js} +1 -1
- package/dist-ksadk/assets/{dist-CgpyS7Tw.js → dist-Dguio8Hw.js} +1 -1
- package/dist-ksadk/assets/{dist-Bo0uuYGj.js → dist-DiUlU2X0.js} +1 -1
- package/dist-ksadk/assets/{dist-D2l4f5Dh.js → dist-Dys6qb_l.js} +1 -1
- package/dist-ksadk/assets/{dist-mo17RERT.js → dist-EFwlyh-J.js} +1 -1
- package/dist-ksadk/assets/{ebnfDiagram-PWID7BFC-DuBo2W05.js → ebnfDiagram-PWID7BFC-BVLszyE1.js} +1 -1
- package/dist-ksadk/assets/{erDiagram-SSCWMZ5O-ZJrJetMD.js → erDiagram-SSCWMZ5O-NK9zebDC.js} +1 -1
- package/dist-ksadk/assets/eventmodeling-NTZA5JFV-BKRpMRZl.js +1 -0
- package/dist-ksadk/assets/flowDiagram-A5DVABFB-BGRwyiok.js +1 -0
- package/dist-ksadk/assets/{ganttDiagram-EL5Y4UJY-Bwk2yIEM.js → ganttDiagram-EL5Y4UJY-B-NR6rAS.js} +1 -1
- package/dist-ksadk/assets/gitGraph-4MIJSDKK-BceyfApi.js +1 -0
- package/dist-ksadk/assets/{gitGraphDiagram-WWUBYQGX-DWYLIagz.js → gitGraphDiagram-WWUBYQGX-DntUECol.js} +1 -1
- package/dist-ksadk/assets/{index-j3aFdsSv.js → index-CaZ1dIkb.js} +6 -6
- package/dist-ksadk/assets/index-OxfmJAbi.css +2 -0
- package/dist-ksadk/assets/info-A6RAGUB7-DgE9TXs9.js +1 -0
- package/dist-ksadk/assets/{infoDiagram-RXCK75RN-DMPen5_h.js → infoDiagram-RXCK75RN-lraP-4to.js} +1 -1
- package/dist-ksadk/assets/{ishikawaDiagram-5VMMS53U-DsPNKFIz.js → ishikawaDiagram-5VMMS53U-BFUXP6G0.js} +1 -1
- package/dist-ksadk/assets/{journeyDiagram-EYS64GPL-BNbTP-8a.js → journeyDiagram-EYS64GPL-DvJkYxSd.js} +1 -1
- package/dist-ksadk/assets/{kanban-definition-3QL26DDD-BKR6Itkv.js → kanban-definition-3QL26DDD-Bx42a2kj.js} +1 -1
- package/dist-ksadk/assets/{katex-B0oLa8CR.js → katex-T3OysX4v.js} +1 -1
- package/dist-ksadk/assets/{linear-B3_la4oE.js → linear-BX4Gctf_.js} +1 -1
- package/dist-ksadk/assets/{mermaid-parser.core-B6PQSAV-.js → mermaid-parser.core-B-Njf-Rf.js} +2 -2
- package/dist-ksadk/assets/{mindmap-definition-FBJOCRG2-By8qFxGO.js → mindmap-definition-FBJOCRG2-DO4XhxDO.js} +1 -1
- package/dist-ksadk/assets/packet-AYTQ26CC-DQZbTYdS.js +1 -0
- package/dist-ksadk/assets/{pegDiagram-XKGWAZYB-K1kvFBKC.js → pegDiagram-XKGWAZYB-Bhi4hvvi.js} +1 -1
- package/dist-ksadk/assets/pie-WAS4IAKB-ChP3z5PO.js +1 -0
- package/dist-ksadk/assets/{pieDiagram-E7YTZNPT-5XFtDn56.js → pieDiagram-E7YTZNPT-3cwlvdGv.js} +1 -1
- package/dist-ksadk/assets/{quadrantDiagram-AXDQQJYC-DQwy74C1.js → quadrantDiagram-AXDQQJYC-BqCZQkDk.js} +1 -1
- package/dist-ksadk/assets/radar-RG4KPBEZ-BswBIyb7.js +1 -0
- package/dist-ksadk/assets/railroad-74A4TZTK-C4qYmztZ.js +1 -0
- package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-CUxXRHeB.js +1 -0
- package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-CHvnaoXp.js +1 -0
- package/dist-ksadk/assets/railroad-peg-WCYAUIDC-x9Vt3w1A.js +1 -0
- package/dist-ksadk/assets/{railroadDiagram-O6MQD6OU-cozhldnA.js → railroadDiagram-O6MQD6OU-D6Z9xo29.js} +1 -1
- package/dist-ksadk/assets/{requirementDiagram-EFPCY7ZU-CElPZjXR.js → requirementDiagram-EFPCY7ZU-0eqBRCt3.js} +1 -1
- package/dist-ksadk/assets/{sankeyDiagram-P5KCCOFB-y_USXv4y.js → sankeyDiagram-P5KCCOFB-BrJ43vZ_.js} +1 -1
- package/dist-ksadk/assets/{sequenceDiagram-WJ2MYXX4-BJbQk7Za.js → sequenceDiagram-WJ2MYXX4-C-A3Z3yp.js} +1 -1
- package/dist-ksadk/assets/{sizeCapture-X5ZJPWSS-DAaf435S.js → sizeCapture-X5ZJPWSS-BR1hzV_F.js} +1 -1
- package/dist-ksadk/assets/{stateDiagram-HBIQ2CUA-BiLbLu1I.js → stateDiagram-HBIQ2CUA-BfHY88Bq.js} +1 -1
- package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-BLRHkxVu.js +1 -0
- package/dist-ksadk/assets/{swimlanes-XN3QIQJK-DxhmU8aj.js → swimlanes-XN3QIQJK-D_jtIJEW.js} +1 -1
- package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-D6sWlh4I.js +8 -0
- package/dist-ksadk/assets/{timeline-definition-24CTP7MA-D18EWv7u.js → timeline-definition-24CTP7MA-CZGn87oV.js} +1 -1
- package/dist-ksadk/assets/treeView-Q6P3EWNA-DEdJV9Ig.js +1 -0
- package/dist-ksadk/assets/treemap-WGGIJYW6-Bte4RVdK.js +1 -0
- package/dist-ksadk/assets/{vennDiagram-4TSXK5OY-rUBCuIGM.js → vennDiagram-4TSXK5OY-CAtuK-e_.js} +1 -1
- package/dist-ksadk/assets/wardley-WFR3VGLG-DiVBK1MJ.js +1 -0
- package/dist-ksadk/assets/{wardleyDiagram-VM6X3IG4-CDZQ5sZK.js → wardleyDiagram-VM6X3IG4-BWJCCvTJ.js} +1 -1
- package/dist-ksadk/assets/{xychartDiagram-S5SC5T6Z-CH_HdHYk.js → xychartDiagram-S5SC5T6Z-BqG5_bw9.js} +1 -1
- package/dist-ksadk/index.html +2 -2
- package/dist-lib/App.d.ts.map +1 -1
- package/dist-lib/{CodeBlock-D3-ZCOb_.js → CodeBlock-CGejCh33.js} +1 -1
- package/dist-lib/{ConnectedMessageList-BwRiSswQ.js → ConnectedMessageList-B-y-w-dq.js} +7 -7
- package/dist-lib/{MathMessageMarkdown-DwgeFqKs.js → MathMessageMarkdown-DzxSRCoH.js} +7 -7
- package/dist-lib/{WorkspacePanelContainer-C-na8Ns1.js → WorkspacePanelContainer-IBpAs0Ft.js} +1 -1
- package/dist-lib/chat-timeline.js +1 -1
- package/dist-lib/components.js +4 -4
- package/dist-lib/runtime.js +150 -144
- package/dist-lib/styles.css +1 -1
- package/package.json +1 -1
- package/dist-ksadk/assets/architecture-7GRP2DOG-DlLqIl7c.js +0 -1
- package/dist-ksadk/assets/channel-cg7jYcXF.js +0 -1
- package/dist-ksadk/assets/chunk-2Q5K7J3B-C4iMKTWb.js +0 -1
- package/dist-ksadk/assets/classDiagram-DTDB5LWJ-RtbaG_Dz.js +0 -1
- package/dist-ksadk/assets/classDiagram-v2-JRS7N3AN-RtbaG_Dz.js +0 -1
- package/dist-ksadk/assets/cynefin-OW5HDTMX-BRs0UJ32.js +0 -1
- package/dist-ksadk/assets/eventmodeling-NTZA5JFV-DCJzsswd.js +0 -1
- package/dist-ksadk/assets/flowDiagram-A5DVABFB-485rByL2.js +0 -1
- package/dist-ksadk/assets/gitGraph-4MIJSDKK-C5VB4yJL.js +0 -1
- package/dist-ksadk/assets/index-Cp5NEP4y.css +0 -2
- package/dist-ksadk/assets/info-A6RAGUB7-tqDdMmNT.js +0 -1
- package/dist-ksadk/assets/packet-AYTQ26CC-BxA-7Hkq.js +0 -1
- package/dist-ksadk/assets/pie-WAS4IAKB-3Tmx9EyU.js +0 -1
- package/dist-ksadk/assets/radar-RG4KPBEZ-D_bZK5Bu.js +0 -1
- package/dist-ksadk/assets/railroad-74A4TZTK-COy6RdCd.js +0 -1
- package/dist-ksadk/assets/railroad-abnf-HS5TGJTU-CrdA8h6r.js +0 -1
- package/dist-ksadk/assets/railroad-ebnf-LZEXJU2U-BnDti7-r.js +0 -1
- package/dist-ksadk/assets/railroad-peg-WCYAUIDC-DmYdbc7f.js +0 -1
- package/dist-ksadk/assets/stateDiagram-v2-4QOOHH4V-5rxHhPTD.js +0 -1
- package/dist-ksadk/assets/swimlanesDiagram-VK2B7HYN-B3Po2rui.js +0 -8
- package/dist-ksadk/assets/treeView-Q6P3EWNA-6G5wA0pE.js +0 -1
- package/dist-ksadk/assets/treemap-WGGIJYW6-BE9GnPbg.js +0 -1
- package/dist-ksadk/assets/wardley-WFR3VGLG-BYh81kWC.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-C4aqRWHc.js","./CodeBlock-Bs7KdIr5.js","./MermaidBlock-SfTSCYPD.js","./katex-T3OysX4v.js","./MathMessageMarkdown-BorAY7qD.css","./NativeTerminalPanel-D4469o8R.js","./NativeTerminalPanel-CHOd7Rch.css","./dist-DTeQCULT.js","./dist-CYNfiHL_.js","./dist-CTRKDU8K.js","./dist-BZBDMLXX.js","./dist-DLGYftqv.js","./dist-EFwlyh-J.js","./dist-Dys6qb_l.js","./dist-D0V4p2BH.js","./dist-BcF5XYGL.js","./dist-BcWjNWFB.js","./dist-D-7_sx4d.js","./dist-B5ACVHAD.js","./dist-CHgoCvLH.js","./dist-BuVggBmt.js","./dist-DiUlU2X0.js","./dist-B8Xx9Bcu.js","./dist-C6T-wP4s.js","./dist-C5xBbsOZ.js","./dist-DHWEsppc.js","./dist-Dguio8Hw.js","./dockerfile-BLkNEvjs.js","./simple-mode-DRpGK0lJ.js","./factor-D7LVTn2l.js","./nsis-AQ_alPln.js","./pug-Bugr-47h.js","./javascript-9Tg8ixDm.js","./dist-BD6pm3IK.js","./dist-DaJnfr3_.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,ee||(ee=!0,T());else{var t=n(l);t!==null&&ae(x,t.startTime-e)}}var ee=!1,te=-1,S=5,C=-1;function ne(){return g?!0:!(e.unstable_now()-C<S)}function w(){if(g=!1,ee){var t=e.unstable_now();C=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(te),te=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&ne());){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&&ae(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?T():ee=!1}}}var T;if(typeof y==`function`)T=function(){y(w)};else if(typeof MessageChannel<`u`){var re=new MessageChannel,ie=re.port2;re.port1.onmessage=w,T=function(){ie.postMessage(null)}}else T=function(){_(w,0)};function ae(t,n){te=_(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`):S=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(te),te=-1):h=!0,ae(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,ee||(ee=!0,T()))),r},e.unstable_shouldYield=ne,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 ee=Array.isArray;function te(){}var S={H:null,A:null,T:null,S:null},C=Object.prototype.hasOwnProperty;function ne(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function w(e,t){return ne(e.type,t,e.props)}function T(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function re(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var ie=/\/+/g;function ae(e,t){return typeof e==`object`&&e&&e.key!=null?re(``+e.key):t.toString(36)}function oe(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(te,te):(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 se(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,se(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+ae(e,0):a,ee(o)?(i=``,c!=null&&(i=c.replace(ie,`$&/`)+`/`),se(o,r,i,``,function(e){return e})):o!=null&&(T(o)&&(o=w(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(ie,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(ee(e))for(var u=0;u<e.length;u++)a=e[u],s=l+ae(a,u),c+=se(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+ae(a,u++),c+=se(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return se(oe(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 ce(e,t,n){if(e==null)return e;var r=[],i=0;return se(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function le(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 E=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)},D={map:ce,forEach:function(e,t,n){ce(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return ce(e,function(){t++}),t},toArray:function(e){return ce(e,function(e){return e})||[]},only:function(e){if(!T(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=D,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=S,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return S.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)!C.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 ne(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)C.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 ne(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=T,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:le}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=S.T,n={};S.T=n;try{var r=e(),i=S.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(te,E)}catch(e){E(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),S.T=t}},e.unstable_useCacheRefresh=function(){return S.H.useCacheRefresh()},e.use=function(e){return S.H.use(e)},e.useActionState=function(e,t,n){return S.H.useActionState(e,t,n)},e.useCallback=function(e,t){return S.H.useCallback(e,t)},e.useContext=function(e){return S.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return S.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return S.H.useEffect(e,t)},e.useEffectEvent=function(e){return S.H.useEffectEvent(e)},e.useId=function(){return S.H.useId()},e.useImperativeHandle=function(e,t,n){return S.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return S.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return S.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return S.H.useMemo(e,t)},e.useOptimistic=function(e,t){return S.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return S.H.useReducer(e,t,n)},e.useRef=function(e){return S.H.useRef(e)},e.useState=function(e){return S.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return S.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return S.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`),ee=Symbol.for(`react.consumer`),te=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),ne=Symbol.for(`react.suspense_list`),w=Symbol.for(`react.memo`),T=Symbol.for(`react.lazy`),re=Symbol.for(`react.activity`),ie=Symbol.for(`react.memo_cache_sentinel`),ae=Symbol.iterator;function oe(e){return typeof e!=`object`||!e?null:(e=ae&&e[ae]||e[`@@iterator`],typeof e==`function`?e:null)}var se=Symbol.for(`react.client.reference`);function ce(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===se?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 C:return`Suspense`;case ne:return`SuspenseList`;case re:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case te:return e.displayName||`Context`;case ee:return(e._context.displayName||`Context`)+`.Consumer`;case S:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case w:return t=e.displayName||null,t===null?ce(e.type)||`Memo`:t;case T:t=e._payload,e=e._init;try{return ce(e(t))}catch{}}return null}var le=Array.isArray,E=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ue={pending:!1,data:null,method:null,action:null},de=[],fe=-1;function pe(e){return{current:e}}function me(e){0>fe||(e.current=de[fe],de[fe]=null,fe--)}function he(e,t){fe++,de[fe]=e.current,e.current=t}var ge=pe(null),_e=pe(null),ve=pe(null),ye=pe(null);function be(e,t){switch(he(ve,t),he(_e,e),he(ge,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?cf(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=cf(t),e=lf(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}me(ge),he(ge,e)}function xe(){me(ge),me(_e),me(ve)}function Se(e){e.memoizedState!==null&&he(ye,e);var t=ge.current,n=lf(t,e.type);t!==n&&(he(_e,e),he(ge,n))}function Ce(e){_e.current===e&&(me(ge),me(_e)),ye.current===e&&(me(ye),_p._currentValue=ue)}var we,Te;function Ee(e){if(we===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);we=t&&t[1]||``,Te=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+we+e+Te}var De=!1;function Oe(e,t){if(!e||De)return``;De=!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 hq(e){if(!e)return e;let t=String(e).replace(/\r\n/g,`
|
|
195
195
|
`).replace(/\r/g,`
|
|
196
|
-
`).trim();return t=eq(t),t=aq(t),(t.match(/```/g)||[]).length%2==1&&(t=`${t}\n\`\`\``),mq(t.split("```")).join("```").trim()}var gq=`modulepreload`,_q=function(e,t){return new URL(e,t).href},vq={},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=_q(t,n),t in vq)return;vq[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`:gq,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)})},yq=b.lazy(()=>J(()=>import(`./CodeBlock-
|
|
197
|
-
`))return(0,U.jsx)(`code`,{className:`
|
|
196
|
+
`).trim();return t=eq(t),t=aq(t),(t.match(/```/g)||[]).length%2==1&&(t=`${t}\n\`\`\``),mq(t.split("```")).join("```").trim()}var gq=`modulepreload`,_q=function(e,t){return new URL(e,t).href},vq={},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=_q(t,n),t in vq)return;vq[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`:gq,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)})},yq=b.lazy(()=>J(()=>import(`./CodeBlock-Bs7KdIr5.js`).then(e=>({default:e.CodeBlock})),[],import.meta.url)),bq=b.lazy(()=>J(()=>import(`./MermaidBlock-SfTSCYPD.js`).then(e=>({default:e.MermaidBlock})),[],import.meta.url)),xq=b.lazy(()=>J(()=>import(`./MathMessageMarkdown-C4aqRWHc.js`).then(e=>({default:e.MathMessageMarkdown})),__vite__mapDeps([0,1,2,3,4]),import.meta.url));function Sq(e){return/\$[^$]+\$|\$\$[^$]+\$\$/.test(e)}var Cq={h1({children:e}){return(0,U.jsx)(`h1`,{className:`mb-3.5 mt-5 text-[17px] font-semibold text-foreground`,children:e})},h2({children:e}){return(0,U.jsx)(`h2`,{className:`mb-2.5 mt-4.5 text-[15px] font-semibold text-foreground`,children:e})},h3({children:e}){return(0,U.jsx)(`h3`,{className:`mb-2 mt-3.5 text-[14px] font-semibold text-foreground`,children:e})},p({children:e}){return(0,U.jsx)(`p`,{className:`mb-2.5 min-w-0 break-words leading-[1.65] text-foreground`,children:e})},ul({children:e}){return(0,U.jsx)(`ul`,{className:`mb-3 list-disc space-y-1.5 pl-5 text-foreground`,children:e})},ol({children:e}){return(0,U.jsx)(`ol`,{className:`mb-3 list-decimal space-y-1.5 pl-8 text-foreground`,children:e})},li({children:e}){return(0,U.jsx)(`li`,{className:`min-w-0 break-words pl-1 leading-6 text-foreground`,children:e})},strong({children:e}){return(0,U.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e})},blockquote({children:e}){return(0,U.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
|
+
`))return(0,U.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,U.jsx)(b.Suspense,{fallback:(0,U.jsx)(`div`,{className:`h-32 animate-pulse rounded bg-muted`}),children:(0,U.jsx)(bq,{chart:i})}):(0,U.jsx)(b.Suspense,{fallback:(0,U.jsx)(`pre`,{className:`p-4 text-sm`,children:i}),children:(0,U.jsx)(yq,{language:a,value:i})})},table({children:e,...t}){return(0,U.jsx)(`div`,{className:`mb-3 max-w-full overflow-x-auto rounded-lg border border-border`,children:(0,U.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,U.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,U.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}){return(0,U.jsx)(`a`,{href:t,className:`text-primary hover:underline`,target:`_blank`,rel:`noopener noreferrer`,...n,children:e})}},wq=b.memo(({content:e})=>{let t=hq(e);return(0,U.jsx)(`div`,{className:`max-w-none break-words text-[14px] leading-[1.65] [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,children:(0,U.jsx)(KU,{remarkPlugins:[XK,$K],components:Cq,children:t})})}),Tq=b.memo(({content:e})=>Sq(e)?(0,U.jsx)(b.Suspense,{fallback:(0,U.jsx)(wq,{content:e}),children:(0,U.jsx)(xq,{content:e})}):(0,U.jsx)(wq,{content:e})),Eq=/^diff --git "?a\/(.+?)"? "?b\/(.+?)"?$/;function Dq(e){let t=[],n=new Map,r=null;for(let i of e.split(`
|
|
198
198
|
`)){let e=i.match(Eq);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 Oq(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 kq(e){return/^diff --git /m.test(e)}function Aq(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function jq(e){let t=Aq(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=Aq(i),a=String(t?.type||``).toLowerCase(),o=a===`string`||a===`number`||a===`boolean`||a===`array`?a:`unknown`,s=Aq(t?.items),c=Array.isArray(t?.[`x-codex-options`])?t[`x-codex-options`].map(Aq).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 Mq({schema:e,values:t,onChange:n,disabled:r,onSubmit:i,onCancel:a}){let o=jq(e),[s,c]=(0,b.useState)(``);return(0,U.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,U.jsxs)(`div`,{className:`mb-2 block text-xs text-[var(--ksadk-interaction-muted)]`,children:[(0,U.jsxs)(`span`,{className:`mb-1 block font-medium`,children:[e.description||e.title||e.name,e.required?(0,U.jsx)(`span`,{className:`ml-0.5 text-rose-500`,children:`*`}):null]}),e.enumValues&&e.enumValues.length>0?(0,U.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,U.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,U.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,U.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,U.jsx)(`span`,{children:String(i)})]},String(i))}),e.allowOther?(0,U.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,U.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,U.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,U.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,U.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-rose-600`,children:s}):null,(0,U.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,U.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,U.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 Nq({surfaceId:e,serializedMessages:t}){let{processMessages:n}=AO();return(0,b.useEffect)(()=>{n(JSON.parse(t))},[t,n]),(0,U.jsx)(Gte,{surfaceId:e,className:`w-full`,fallback:(0,U.jsx)(`div`,{className:`text-sm text-slate-500 dark:text-slate-400`,children:`界面内容暂不可用`}),loadingFallback:(0,U.jsx)(`div`,{className:`text-sm text-slate-500 dark:text-slate-400`,children:`正在加载界面`})})}function Pq({surfaceId:e,messages:t,onAction:n}){let r=e.startsWith(`input-`)?Qte(t):null;if(r)return(0,U.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,U.jsxs)(`summary`,{className:`cursor-pointer`,children:[`历史提问 · `,r.length,` 个问题`]}),(0,U.jsx)(`ul`,{className:`mt-2 list-disc space-y-1 pl-5`,children:r.map((e,t)=>(0,U.jsx)(`li`,{children:e},t))})]});let i=JSON.stringify(t);return(0,U.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,U.jsx)(Bte,{catalog:NO,onAction:n,children:(0,U.jsx)(Nq,{surfaceId:e,serializedMessages:i})},`${e}:${i}`)})}function Fq({a2ui:e,disabled:t,onSubmit:n,onCancel:r}){return(0,U.jsxs)(`div`,{className:`mt-3`,"data-testid":`interaction-a2ui-surface`,children:[(0,U.jsx)(Pq,{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,U.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 Iq(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 Lq(e){if(!e.expiresAt)return!1;let t=Date.parse(e.expiresAt);return Number.isFinite(t)&&t<=Date.now()}function Rq(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 zq(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Bq(e){let t=zq(e);if(t)return t;if(typeof e!=`string`)return null;try{return zq(JSON.parse(e))}catch{return null}}function Vq(e){return Array.isArray(e)?e.map(String).join(` `):typeof e==`string`?e:``}function Hq(e){let t=Bq(e.extensions.detail),n=Bq(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:Vq(r.command??r.cmd),reason:Vq(r.reason??r.justification),cwd:Vq(r.cwd??r.workdir)}}var Uq={approved:`已同意`,rejected:`已拒绝`,submitted:`已提交`,cancelled:`已取消`,expired:`已过期`};function Wq({interactions:e,activeIndex:t,onSelectIndex:n,onRespond:r,localCatalog:i,className:a}){let[o,s]=(0,b.useState)(``),[c,l]=(0,b.useState)({}),u=e[Math.min(t,Math.max(e.length-1,0))];if(!u)return null;let d=Lq(u),f=Rq(u),p=Hq(u),m=d||u.status===`resolving`,h=pA(u.presentation?.a2ui,i),g=u.requestSchema??Iq(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`,v=_===`json-schema-form`&&g||u.requestSchema,y=(e,t)=>{m||Promise.resolve(r({interactionId:u.interactionId,expectedRevision:u.revision,action:e,response:t,idempotencyKey:qk(u.interactionId,u.revision)})).catch(()=>{})};return(0,U.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,U.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,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs text-[var(--ksadk-interaction-muted)]`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,U.jsx)(jN,{className:`h-3.5 w-3.5 shrink-0`,strokeWidth:1.7,"aria-hidden":`true`}),(0,U.jsx)(`span`,{"data-testid":`interaction-tray-title`,children:u.title}),p.operation?(0,U.jsx)(`span`,{className:`truncate text-[11px] text-[var(--ksadk-interaction-muted)]`,children:p.operation}):null]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[e.length>1?(0,U.jsxs)(U.Fragment,{children:[(0,U.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,U.jsx)(dN,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})}),(0,U.jsxs)(`span`,{"data-testid":`interaction-tray-count`,className:`min-w-10 text-center`,children:[t+1,` of `,e.length]}),(0,U.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,U.jsx)(fN,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})]}):null,(0,U.jsx)(`button`,{type:`button`,"data-testid":`interaction-cancel`,disabled:m,onClick:()=>y(`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,U.jsx)(aP,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})]})]}),u.message===p.command?null:(0,U.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,U.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,U.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,U.jsx)(`p`,{className:`text-[var(--ksadk-interaction-muted)]`,children:p.reason}):null,p.cwd?(0,U.jsx)(`p`,{className:`truncate font-mono text-[11px] text-[var(--ksadk-interaction-muted)]`,title:p.cwd,children:p.cwd}):null]}):null,d?(0,U.jsxs)(`p`,{className:`mt-2 text-xs font-medium text-rose-600 dark:text-rose-400`,"data-testid":`interaction-tray-expired`,children:[`该确认已过期(`,Uq.expired,`),等待运行时继续处理。`]}):null,f?(0,U.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,U.jsx)(Fq,{a2ui:u.presentation.a2ui,disabled:m,onSubmit:e=>y(`submit`,e),onCancel:()=>y(`cancel`,{})}):_===`json-schema-form`&&v?(0,U.jsx)(Mq,{schema:v,values:c,onChange:l,disabled:m,onSubmit:()=>y(`submit`,c),onCancel:()=>y(`cancel`,{})}):u.kind===`approval`?(0,U.jsxs)(`div`,{className:`mt-2 flex flex-col gap-1`,"data-testid":`interaction-tray-basic`,children:[(0,U.jsxs)(`button`,{type:`button`,"data-testid":`interaction-approve`,disabled:m,onClick:()=>y(`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,U.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,U.jsx)(`span`,{className:`min-w-0 flex-1`,children:`批准并继续`}),(0,U.jsx)(oN,{className:`h-3.5 w-3.5 text-[var(--ksadk-interaction-muted)] opacity-0 transition group-hover:opacity-100`,"aria-hidden":`true`})]}),(0,U.jsxs)(`button`,{type:`button`,"data-testid":`interaction-reject`,disabled:m,onClick:()=>y(`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,U.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,U.jsx)(`span`,{className:`min-w-0 flex-1`,children:`拒绝`}),(0,U.jsx)(oN,{className:`h-3.5 w-3.5 text-[var(--ksadk-interaction-muted)] opacity-0 transition group-hover:opacity-100`,"aria-hidden":`true`})]}),(0,U.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,U.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,U.jsx)(zN,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})}),(0,U.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key!==`Enter`||e.nativeEvent.isComposing||!o.trim()||(e.preventDefault(),y(`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,U.jsx)(`button`,{type:`button`,"data-testid":`interaction-feedback-submit`,"aria-label":`提交修改意见`,disabled:m||!o.trim(),onClick:()=>y(`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,U.jsx)(oN,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})]})]}):(0,U.jsxs)(`div`,{className:`mt-2.5`,"data-testid":`interaction-tray-basic`,children:[(0,U.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key!==`Enter`||e.nativeEvent.isComposing||!o.trim()||(e.preventDefault(),y(`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,U.jsx)(`div`,{className:`flex justify-end gap-2`,children:(0,U.jsx)(`button`,{type:`button`,"data-testid":`interaction-submit`,disabled:m,onClick:()=>y(`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,U.jsx)(`p`,{className:`mt-2 text-xs text-[var(--ksadk-interaction-muted)]`,children:`正在提交,请稍候…`}):null]})})}function Gq({outcome:e}){return(0,U.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:Uq[e]||e})}function Kq(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 Jq({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,U.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,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`font-medium text-text-primary`,children:e.title}),(0,U.jsx)(Gq,{outcome:e.outcome||e.status})]}),t?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`mt-1 leading-relaxed`,children:[e.actor?(0,U.jsxs)(`span`,{children:[`操作人:`,e.actor,` · `]}):null,e.resolvedAt?(0,U.jsxs)(`span`,{children:[`决定时间:`,Kq(e.resolvedAt),` · `]}):null,(0,U.jsx)(`span`,{"data-testid":`interaction-history-response-summary`,children:e.responseSummary||`响应内容已脱敏`})]}),(0,U.jsxs)(`details`,{"data-testid":`interaction-history-detail`,className:`mt-1`,children:[(0,U.jsx)(`summary`,{className:`cursor-pointer select-none text-text-muted hover:text-text-primary`,children:`查看确认快照`}),(0,U.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,U.jsxs)(`div`,{children:[`操作者:`,(0,U.jsx)(`span`,{"data-testid":`interaction-history-actor-ref`,children:e.actor||`—`})]}),(0,U.jsxs)(`div`,{children:[`决定时间:`,Kq(e.resolvedAt)||`—`]}),(0,U.jsxs)(`div`,{children:[`关键参数:`,n.length>0?(0,U.jsx)(`span`,{"data-testid":`interaction-history-schema-keys`,children:n.join(`、`)}):(0,U.jsx)(`span`,{children:`无结构化参数`})]})]})]})]}):(0,U.jsxs)(`div`,{className:`mt-1`,children:[`状态:`,e.status===`pending`?`待处理(见输入区确认面板)`:`处理中…`]})]})}function Yq({summary:e,children:t,defaultOpen:n=!1,streaming:r=!1}){let[i,a]=(0,b.useState)(n);return(0,U.jsxs)(`div`,{className:`mb-1.5`,children:[(0,U.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,U.jsx)(kN,{className:`h-3.5 w-3.5 animate-spin text-slate-400`}):(0,U.jsx)(uN,{className:K(`h-3.5 w-3.5 text-slate-400 transition-transform`,i&&`rotate-90`)}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e})]}),i&&(0,U.jsx)(`div`,{className:`mt-1.5 border-l border-slate-200 pl-3.5 dark:border-slate-700/60`,children:t})]})}function Xq({block:e}){let[t,n]=(0,b.useState)(!1),r=e.status===`streaming`,i=e.content.length,a=`${e.id}-thinking-detail`;return(0,U.jsxs)(`div`,{className:`mb-1.5 min-w-0`,children:[(0,U.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,U.jsx)(YN,{className:`h-3.5 w-3.5 shrink-0`}),(0,U.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,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`text-slate-300 dark:text-slate-600`,children:`·`}),(0,U.jsxs)(`span`,{className:`font-mono text-xs text-slate-400 dark:text-slate-500`,children:[i,` 字`]})]}),(0,U.jsx)(uN,{className:K(`h-3.5 w-3.5 shrink-0 transition-transform`,t&&`rotate-180`)})]}),t&&e.content&&(0,U.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,U.jsx)(Tq,{content:e.content})})]})}function Zq({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=u===`cancelled`||u===`rejected`,_=o===`error`&&!g,v=o===`paused`,y=_?`执行失败`:u===`pending`?`等待确认`:u===`rejected`?`已拒绝`:u===`cancelled`?`已取消`:h?u===`approved`?`已授权 · 执行中`:`正在运行`:u===`approved`?`已授权`:v?`已暂停`:`已完成`,b=_?`text-rose-500 dark:text-rose-400`:v?`text-amber-500 dark:text-amber-400`:h?`text-slate-500 dark:text-slate-400`:`text-slate-400 dark:text-slate-500`;return(0,U.jsx)(Yq,{streaming:h&&!s,defaultOpen:u===`pending`||v,summary:(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(iP,{className:K(`h-3.5 w-3.5 shrink-0`,b)}),(0,U.jsx)(`span`,{className:b,children:y}),(0,U.jsx)(`span`,{className:`truncate font-medium text-slate-600 dark:text-slate-300`,children:e.toolName}),h&&s&&(0,U.jsx)(`span`,{className:`ml-0.5 animate-pulse text-slate-400`,children:`…`})]}),children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-2.5 py-1 text-[13px]`,children:[d&&u===`pending`&&!r&&(0,U.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,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--ksadk-approval-foreground)]`,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`shrink-0 font-medium`,children:`需要确认`}),(0,U.jsx)(`span`,{className:`min-w-0 truncate opacity-75`,children:f||`允许后将执行此工具调用。`})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,U.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,U.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,U.jsxs)(`div`,{className:`flex items-center gap-1.5 font-sans text-xs text-slate-500 dark:text-slate-400`,children:[(0,U.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,U.jsxs)(`div`,{className:`flex items-center gap-1.5 font-sans text-xs text-slate-500 dark:text-slate-400`,children:[(0,U.jsx)(`span`,{children:u===`approved`?`已授权`:u===`cancelled`?`已取消`:`已拒绝`}),u===`approved`&&h?(0,U.jsx)(`span`,{children:`· 工具执行中`}):null,u===`approved`&&_?(0,U.jsx)(`span`,{children:`· 工具执行失败`}):null]}),s?(0,U.jsx)(nJ,{label:`入参`,value:s,tone:`input`}):null,c&&!g?Qq(e.toolName,c,_):null]})})}function Qq(e,t,n){if(kq(t))return(0,U.jsx)($q,{output:t});let r=e.toLowerCase();if(r.includes(`web_search`)||r.includes(`search`)){let e=eJ(t);if(e.length>0)return(0,U.jsx)(tJ,{sources:e})}return(0,U.jsx)(nJ,{label:`输出`,value:t,tone:n?`error`:`output`})}function $q({output:e}){let t=Dq(e),[n,r]=(0,b.useState)(!1),i=n?t:t.slice(0,3);return(0,U.jsxs)(`div`,{className:`my-2 overflow-hidden rounded-xl border border-border bg-background`,children:[(0,U.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,U.jsx)(CN,{className:`h-3.5 w-3.5 text-primary`}),(0,U.jsxs)(`span`,{children:[`改动 `,t.length,` 个文件`]})]}),(0,U.jsx)(`div`,{className:`flex flex-col`,children:i.map(e=>{let{added:t,removed:n}=Oq(e);return(0,U.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,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[13px] text-text-primary`,children:e.path}),(0,U.jsxs)(`span`,{className:`flex-shrink-0 text-[11px] font-mono`,children:[(0,U.jsxs)(`span`,{className:`text-emerald-600`,children:[`+`,t]}),` `,(0,U.jsxs)(`span`,{className:`text-rose-500`,children:[`−`,n]})]})]},e.path)})}),t.length>3?(0,U.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 eJ(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=String(t?.title??t?.name??n);return n?{url:n,title:r}:null}).filter(e=>e!==null):[]}catch{return[]}}function tJ({sources:e}){return(0,U.jsx)(`div`,{className:`mt-2 flex min-w-0`,children:(0,U.jsxs)(`span`,{className:`group/web-search-sources relative inline-flex min-w-0`,children:[(0,U.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,U.jsx)(vN,{className:`h-3.5 w-3.5 shrink-0`,strokeWidth:1.7}),(0,U.jsxs)(`span`,{children:[`来源 · `,e.length]})]}),(0,U.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,U.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,U.jsx)(`span`,{className:`flex min-w-0 flex-col gap-1`,children:e.map((e,t)=>(0,U.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,U.jsx)(vN,{className:`h-3.5 w-3.5 shrink-0`,strokeWidth:1.7}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title})]},`${e.url}-${t}`))})})})]})})}function nJ({label:e,tone:t,value:n}){return(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`div`,{className:`mb-1 text-[11px] font-semibold uppercase tracking-wide text-slate-400`,children:e}),(0,U.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:n})]})}function rJ({block:e}){return e.content?(0,U.jsx)(`div`,{className:`w-full break-words py-0.5 text-[14px] leading-[1.65]`,children:(0,U.jsx)(Tq,{content:e.content})}):null}function iJ({message:e,isStreaming:t,onRespondToApproval:n,onRespondToAguiApproval:r,interactionRecords:i,className:a}){let o=e.blocks??[];return(0,U.jsx)(`div`,{className:K(`mb-3 min-w-0`,a),"data-slot":`processing-blocks`,children:o.map(a=>{if(a.type===`thinking`)return(0,U.jsx)(Xq,{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,U.jsxs)(`div`,{children:[(0,U.jsx)(Zq,{block:a,tool:e.tools?.[a.toolName],isStreaming:t,interactionRecord:l,onRespondToApproval:n,onRespondToAguiApproval:r}),l?(0,U.jsx)(Jq,{interaction:l}):null]},a.id)}return(0,U.jsx)(rJ,{block:a},a.id)})})}function aJ({onRetry:e}){let t=O(e=>e.banner);if(!t)return null;let n=t.kind===`rate_limited`?(0,U.jsx)(oJ,{message:t.message,retryAfterSec:t.retryAfterSec},t.createdAt||`${t.sessionId||``}:${t.retryAfterSec||0}`):null,r={rate_limited:{icon:(0,U.jsx)(oP,{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,U.jsx)(kN,{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,U.jsx)(rP,{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,U.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,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:r.label}),t.kind===`error`&&e?(0,U.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,U.jsx)(WN,{className:`h-3 w-3`}),`重试`]}):null]})}function oJ({message:e,retryAfterSec:t}){let[n,r]=(0,b.useState)(t||0);return(0,b.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 sJ(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 cJ(e,t,n){return Math.max(t,Math.min(n,e))}function lJ({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=cJ(g-l,0,e.length),_=cJ(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 uJ({scrollHeight:e,scrollTop:t,clientHeight:n}){return Math.max(0,e-t-n)}function dJ(e){return e.scrollHeight>e.clientHeight+1&&uJ(e)>96}function fJ(e){return String(e?.runId||e?.invocationId||``).trim()}function pJ(e,t){if(e?.role!==`model`||t.role!==`model`)return!1;let n=fJ(e);return!!(n&&n===fJ(t))}var mJ=140,hJ=4;function gJ(e){let t=String(e||``).trim().toLowerCase();return t===`elevated`?`高风险`:t===`always`?`始终确认`:t===`confirm`?`需确认`:e||``}function _J(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 vJ({messageId:e,top:t,onMeasure:n,children:r}){let i=(0,b.useRef)(null);return(0,b.useLayoutEffect)(()=>{let r=i.current;if(!r)return;let a=()=>n(e,r.offsetHeight,t);if(a(),typeof ResizeObserver>`u`)return;let o=new ResizeObserver(a);return o.observe(r),()=>o.disconnect()},[e,n,t]),(0,U.jsx)(`div`,{ref:i,style:{position:`absolute`,top:t,left:0,right:0},children:r})}function yJ({agentName:e}){return(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-[50vh] px-4`,children:[(0,U.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,U.jsx)(cN,{className:`h-8 w-8 text-white`})}),(0,U.jsx)(`h2`,{className:`text-xl font-semibold text-slate-900 dark:text-slate-50`,children:`有什么我可以帮您的吗?`}),(0,U.jsxs)(`p`,{className:`mt-2 text-sm text-slate-500`,children:[`我是 `,e,`,由 Ksyun AgentEngine 驱动`]})]})}function bJ(){return(0,U.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[44rem] flex-col gap-5 px-2 py-8`,"aria-label":`正在加载会话历史`,children:[(0,U.jsx)(`div`,{className:`h-4 w-28 animate-pulse rounded bg-slate-200/80 dark:bg-slate-800`}),(0,U.jsx)(`div`,{className:`h-20 w-4/5 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900`}),(0,U.jsx)(`div`,{className:`ml-auto h-12 w-3/5 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900`}),(0,U.jsx)(`div`,{className:`h-16 w-11/12 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900`})]})}function xJ({attachments:e,isMobile:t,onOpenAttachmentPreview:n}){return(0,U.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-3`,children:e.map((e,r)=>e.type.startsWith(`image/`)?e.url?(0,U.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,U.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]`)})},`${e.name}-${r}`):(0,U.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,U.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,U.jsx)(RN,{className:`h-4 w-4 flex-shrink-0 text-blue-500`}),e.url?(0,U.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,U.jsx)(`span`,{className:`truncate text-sm text-slate-700 dark:text-slate-300`,title:e.name,children:e.name})]},`${e.name}-${r}`))})}function SJ({message:e}){return(0,U.jsx)(`div`,{className:`w-full px-0 py-2 sm:px-4`,children:(0,U.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,U.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[e.status===`running`?(0,U.jsx)(UN,{className:`h-4 w-4 animate-spin text-neutral-600 dark:text-neutral-300`}):e.status===`failed`?(0,U.jsx)(pN,{className:`h-4 w-4 text-rose-600 dark:text-rose-400`}):(0,U.jsx)(lN,{className:`h-4 w-4 text-emerald-600 dark:text-emerald-400`}),(0,U.jsx)(`span`,{children:e.content})]}),e.compactedUntilSeqId?(0,U.jsxs)(`div`,{className:`mt-1 text-xs text-neutral-700/80 dark:text-neutral-200/80`,children:[`已折叠到会话事件 #`,e.compactedUntilSeqId]}):null,e.summary?(0,U.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,U.jsx)(`summary`,{className:`cursor-pointer select-none text-xs font-medium text-neutral-800 dark:text-neutral-200`,children:`查看压缩摘要`}),(0,U.jsx)(`div`,{className:`mt-2 text-[13px] leading-relaxed text-slate-700 dark:text-slate-200`,children:(0,U.jsx)(Tq,{content:e.summary})})]}):null]})})}function CJ({label:e,tone:t,value:n}){let[r,i]=(0,b.useState)(`idle`),a=EA(n);(0,b.useEffect)(()=>{if(r===`idle`)return;let e=window.setTimeout(()=>i(`idle`),1600);return()=>window.clearTimeout(e)},[r]);let o=async()=>{i(await sJ(a)?`copied`:`failed`)};return(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,U.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,U.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,U.jsx)(lN,{className:`h-3.5 w-3.5 text-emerald-500`}):(0,U.jsx)(gN,{className:`h-3.5 w-3.5`}),r===`copied`?`已复制`:r===`failed`?`复制失败`:`复制`]})]}),(0,U.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 wJ({isLastMessage:e,isStreaming:t,message:n,onDeleteFeedback:r,onSubmitFeedback:i,alwaysVisible:a=!1}){let[o,s]=(0,b.useState)(!1),[c,l]=(0,b.useState)(n.feedback?.comment||``),u=iM(n,t,e),d=!!n.feedback?.pending,f=n.feedback?.rating,p=async()=>{let e=n.content||``;e&&sJ(e)};return u?(0,U.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,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-xs text-text-muted`,children:[(0,U.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,U.jsx)(gN,{className:`h-3.5 w-3.5`})}),(0,U.jsx)(`span`,{className:`text-text-muted/60`,children:`·`}),(0,U.jsx)(`span`,{className:`font-medium`,children:`本次回复有帮助吗?`}),(0,U.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,U.jsx)(eP,{className:`h-3.5 w-3.5`}),`有帮助`]}),(0,U.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,U.jsx)($N,{className:`h-3.5 w-3.5`}),`需改进`]}),n.feedback?(0,U.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,U.jsx)(tP,{className:`h-3.5 w-3.5`}),`删除反馈`]}):null,d?(0,U.jsx)(`span`,{className:`text-slate-400`,children:`提交中…`}):null]}),o?(0,U.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,U.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,U.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-2`,children:[(0,U.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,U.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,U.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,U.jsx)(`div`,{className:`text-xs text-rose-600 dark:text-rose-300`,children:n.feedback.error}):null]}):null}function TJ({agentName:e,isMobile:t,isStreaming:n,isLastMessage:r,showAgentHeader:i,message:a,onDeleteFeedback:o,onOpenAttachmentPreview:s,onRespondToApproval:c,onRespondToAguiApproval:l,onSubmitFeedback:u,onSubmitAguiAction:d,interactionRecords:f}){if(a.role===`user`)return(0,U.jsx)(`div`,{className:`mb-3 flex justify-end`,children:(0,U.jsxs)(`div`,{className:`max-w-[80%] rounded-2xl bg-muted px-3 py-2 text-[14px] leading-relaxed text-foreground`,children:[a.attachments?.length?(0,U.jsx)(xJ,{attachments:a.attachments,isMobile:t,onOpenAttachmentPreview:s}):null,a.content]})});if(a.role===`a2ui`&&a.aguiActivity)return(0,U.jsx)(Pq,{surfaceId:a.aguiActivity.surfaceId,messages:a.aguiActivity.messages,onAction:d});let p=n&&r&&!a.content;return(0,U.jsxs)(`div`,{className:`group mx-auto mb-3 w-full max-w-3xl px-6`,children:[i?(0,U.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-xs text-text-muted`,children:[(0,U.jsx)(cN,{className:`w-3.5 h-3.5`}),(0,U.jsx)(`span`,{children:e})]}):null,a.attachments?.length?(0,U.jsx)(xJ,{attachments:a.attachments,isMobile:t,onOpenAttachmentPreview:s}):null,a.blocks?.length?(0,U.jsx)(iJ,{message:a,isStreaming:n,onRespondToApproval:c,interactionRecords:f,onRespondToAguiApproval:l}):(0,U.jsxs)(U.Fragment,{children:[a.reasoning?(0,U.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,U.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,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[p?null:(0,U.jsx)(lN,{className:`h-4 w-4 text-slate-400`}),(0,U.jsx)(`span`,{className:K(`truncate`,p&&`waiting-thinking-text`),"data-testid":p?`legacy-thinking-indicator`:void 0,role:p?`status`:void 0,children:p?`正在思考…`:`思考过程`}),p?null:(0,U.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,U.jsx)(uN,{className:`h-4 w-4 flex-shrink-0 text-slate-400 transition-transform group-open/details:rotate-180`})]}),(0,U.jsx)(`div`,{className:`border-t border-slate-200/70 bg-white/70 dark:border-slate-800 dark:bg-slate-950/20`,children:(0,U.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,U.jsx)(Tq,{content:a.reasoning})})})]}):null,a.tools?Object.values(a.tools).map((e,t)=>(0,U.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,U.jsx)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 px-3 py-2 font-medium`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.status===`running`?(0,U.jsx)(UN,{className:`h-4 w-4 animate-spin text-slate-500`}):e.status===`paused`?(0,U.jsx)(JN,{className:`h-4 w-4 text-neutral-500`}):e.status===`error`?(0,U.jsx)(mN,{className:`h-4 w-4 text-rose-500`}):(0,U.jsx)(lN,{className:`h-4 w-4 text-slate-400`}),(0,U.jsxs)(`span`,{children:[e.approvalStatus===`pending`?`等待审批:`:e.approvalStatus===`approved`?`已批准:`:e.approvalStatus===`rejected`?`已拒绝:`:e.approvalStatus===`cancelled`?`已取消:`:e.status===`error`?`工具调用失败:`:`工具调用:`,e.name]})]})}),(0,U.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,U.jsxs)(`div`,{className:`font-sans text-sm text-slate-700 dark:text-slate-200`,children:[(0,U.jsx)(`div`,{className:`font-medium`,children:e.approvalStatus===`approved`?`已批准该工具调用。`:e.approvalStatus===`rejected`?`已拒绝该工具调用。`:e.approvalStatus===`cancelled`?`已取消该工具调用。`:e.approvalMessage||`该工具调用需要人工确认后继续。`}),e.approvalLevel?(0,U.jsxs)(`div`,{className:K(`mt-2 inline-flex items-center rounded border px-1.5 py-0.5 text-xs font-medium`,_J(e.approvalLevel)),children:[`审批级别:`,gJ(e.approvalLevel)]}):null,e.serverLabel?(0,U.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,U.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,U.jsxs)(`button`,{type:`button`,disabled:n||e.approvalStatus!==`pending`,onClick:()=>e.approvalProtocol===`ag-ui`?l?.({interruptId:e.approvalRequestId||``,approve:!0}):c({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,U.jsx)(lN,{className:`h-3.5 w-3.5`}),`批准并继续`]}),(0,U.jsxs)(`button`,{type:`button`,disabled:n||e.approvalStatus!==`pending`,onClick:()=>e.approvalProtocol===`ag-ui`?l?.({interruptId:e.approvalRequestId||``,approve:!1}):c({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,U.jsx)(mN,{className:`h-3.5 w-3.5`}),`拒绝`]})]}):(0,U.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,U.jsx)(lN,{className:`h-3.5 w-3.5 text-emerald-500`}):(0,U.jsx)(mN,{className:`h-3.5 w-3.5 text-rose-500`}),e.approvalStatus===`approved`?`已批准`:e.approvalStatus===`cancelled`?`已取消`:`已拒绝`]})]}):null,e.args?(0,U.jsx)(CJ,{label:`入参 (Args)`,tone:`input`,value:e.args}):null,e.output?(0,U.jsx)(CJ,{label:`输出 (Output)`,tone:e.status===`error`?`error`:`output`,value:e.output}):null]})]},`${e.name}-${t}`)):null,a.tools?Object.values(a.tools).filter(e=>f?.some(t=>t.interactionId===e.approvalRequestId)).map(e=>(0,U.jsx)(Jq,{interaction:f.find(t=>t.interactionId===e.approvalRequestId)},`anchor-${e.approvalRequestId}`)):null,(0,U.jsx)(`div`,{className:`w-full break-words`,children:a.content?(0,U.jsx)(Tq,{content:a.content}):n&&r&&!a.reasoning&&!a.tools||a.eventType===`optimistic_assistant_placeholder`?(0,U.jsx)(`span`,{className:`relative mt-1 inline-flex h-4 w-4 items-center justify-center`,role:`status`,"aria-label":`正在生成`,children:(0,U.jsx)(`span`,{className:`waiting-generation-breathe h-2.5 w-2.5 rounded-full`})}):null})]}),a.aguiActivities?.map(e=>(0,U.jsx)(Pq,{surfaceId:e.surfaceId,messages:e.messages,onAction:d},e.surfaceId)),(0,U.jsx)(wJ,{isLastMessage:r,isStreaming:n,message:a,onDeleteFeedback:o,onSubmitFeedback:u})]})}function EJ({agentName:e,emptyState:t,isMobile:n,isStreaming:r,activity:i,contextIndicator:a,messages:o,isLoadingInitialHistory:s=!1,onDeleteFeedback:c,onOpenAttachmentPreview:l,onRespondToApproval:u,onRespondToAguiApproval:d,onSubmitFeedback:f,onSubmitAguiAction:p,onStopGeneration:m,onCancelRemote:h,onScrollToBottom:g,checkpoints:_=[],onResumeCheckpoint:v,interactionRecords:y,scrollRef:x,className:ee}){let[te,S]=(0,b.useState)(0),[C,ne]=(0,b.useState)(0),[w,T]=(0,b.useState)(0),[re,ie]=(0,b.useState)(new Map),ae=(0,b.useRef)(re);(0,b.useLayoutEffect)(()=>{let e=x.current;if(!e)return;let t=()=>{S(e.scrollTop),ne(e.clientHeight),T(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()},[x]);let oe=(0,b.useMemo)(()=>lJ({items:o,scrollTop:te,viewportHeight:C,overscan:hJ,defaultItemHeight:mJ,measuredHeights:re,getItemKey:(e,t)=>e?.id||String(t)}),[re,o,te,C]),se=oe.visibleItems,ce=(0,b.useCallback)((e,t,n)=>{if(!e||!Number.isFinite(t)||t<=0)return;let r=ae.current,i=r.get(e)??mJ;if(i===t)return;let a=new Map(r);a.set(e,t),ae.current=a,ie(a);let o=x.current;o&&n<o.scrollTop&&(o.scrollTop+=t-i,S(o.scrollTop),T(o.scrollHeight))},[x]),le=uJ({scrollHeight:w,scrollTop:te,clientHeight:C}),E=dJ({scrollHeight:w,scrollTop:te,clientHeight:C});return(0,U.jsxs)(`div`,{ref:x,onScroll:e=>{S(e.currentTarget.scrollTop),ne(e.currentTarget.clientHeight),T(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`,ee),"data-slot":`message-list`,children:[(0,U.jsx)(`div`,{className:`mx-auto flex w-full max-w-[64rem] flex-col pb-6 sm:pb-8`,children:o.length===0&&s?(0,U.jsx)(bJ,{}):o.length===0?t===void 0?(0,U.jsx)(yJ,{agentName:e}):t:(0,U.jsx)(`div`,{style:{height:oe.totalHeight},className:`relative`,children:se.map(t=>(0,U.jsx)(vJ,{messageId:t.item.id||String(t.index),top:t.top,onMeasure:ce,children:t.item.role===`system`?(0,U.jsx)(SJ,{message:t.item}):(0,U.jsx)(TJ,{agentName:e,isMobile:n,isStreaming:r,isLastMessage:t.index===o.length-1,showAgentHeader:!pJ(o[t.index-1],t.item),message:t.item,onDeleteFeedback:c,onOpenAttachmentPreview:l,onRespondToApproval:u,interactionRecords:y,onRespondToAguiApproval:d,onSubmitFeedback:f,onSubmitAguiAction:p})},t.item.id||t.index))})}),(0,U.jsx)(aJ,{}),E?(0,U.jsx)(`button`,{type:`button`,"aria-label":`回到底部`,"data-distance-from-bottom":Math.round(le),onClick:()=>{if(g){g();return}let e=x.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,U.jsx)(`span`,{"aria-hidden":`true`,className:`flex items-center gap-0.5`,"data-scroll-indicator":`streaming`,children:[0,1,2].map(e=>(0,U.jsx)(`span`,{className:`h-1 w-1 animate-bounce rounded-full bg-current motion-reduce:animate-none`,style:{animationDelay:`${e*120}ms`}},e))}):(0,U.jsx)(uN,{"aria-hidden":`true`,className:`h-5 w-5`,"data-scroll-indicator":`idle`})}):null]})}var DJ=zR,OJ=BR,kJ=b.forwardRef(({className:e,...t},n)=>(0,U.jsx)(VR,{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}));kJ.displayName=VR.displayName;var AJ=b.forwardRef(({className:e,children:t,...n},r)=>(0,U.jsxs)(OJ,{children:[(0,U.jsx)(kJ,{}),(0,U.jsxs)(HR,{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,U.jsxs)(GR,{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,U.jsx)(aP,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}));AJ.displayName=HR.displayName;var jJ=({className:e,...t})=>(0,U.jsx)(`div`,{className:K(`flex flex-col space-y-1.5 text-center sm:text-left`,e),...t});jJ.displayName=`DialogHeader`;var MJ=({className:e,...t})=>(0,U.jsx)(`div`,{className:K(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});MJ.displayName=`DialogFooter`;var NJ=b.forwardRef(({className:e,...t},n)=>(0,U.jsx)(UR,{ref:n,className:K(`text-lg font-semibold leading-none tracking-tight`,e),...t}));NJ.displayName=UR.displayName;var PJ=b.forwardRef(({className:e,...t},n)=>(0,U.jsx)(WR,{ref:n,className:K(`text-sm text-muted-foreground`,e),...t}));PJ.displayName=WR.displayName;function FJ(e,t){if(!(!t||e))return{width:`min(${t.width}px, calc(100vw - 5rem))`,height:`min(${t.height}px, calc(100vh - 9rem))`}}function IJ(e,t){if(!(!t||e))return{width:`min(${t.width+32}px, calc(100vw - 3rem))`}}function LJ({attachment:e,isMobile:t,previewImageSize:n,onClose:r,onImageLoad:i}){return(0,U.jsx)(DJ,{open:!!e?.url,onOpenChange:e=>!e&&r(),children:(0,U.jsxs)(AJ,{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:IJ(t,n),children:[(0,U.jsx)(`div`,{className:`flex items-center gap-3 border-b border-slate-800 px-4 py-3 pr-16`,children:(0,U.jsx)(NJ,{className:`truncate text-sm font-medium`,children:e?.name||`附件预览`})}),(0,U.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,U.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:FJ(t,n),onLoad:e=>{let t=e.currentTarget;i({width:t.naturalWidth,height:t.naturalHeight})}}):(0,U.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 RJ(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 zJ(e){return e?RJ(e.context_window_tokens)??RJ(e?.limits?.context_window_tokens):null}function BJ(e){return e?RJ(e.auto_compact_threshold_percentage)??84:84}function VJ({selectedModel:e,contextUsage:t}){let n=t&&(!t.model||t.model===e?.id)?t:null,r=RJ(n?.used_tokens),i=RJ(n?.context_window_tokens),a=i??zJ(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>=BJ(e)?`warning`:`normal`,percent:c,usedTokens:r,...o}}function HJ(e){return e.requestedSessionId===e.activeSessionId&&e.requestToken===e.activeRequestToken}function UJ({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}){let h=qc(e=>e.messages),g=Ze(e=>e.currentSessionId),_=Ze(e=>e.isLoadingSessions),v=O(e=>!!(e.getSessionActivity(g)&&e.isSessionStreaming(g))),y=O(e=>e.getSessionActivity(g)),x=Ej(e=>e.getSessionCheckpoints(g)),ee=Ze(e=>g?e.messageHistory[g]:null),te=_||!!ee?.isLoadingInitial,S=w(e=>e.input),C=Te(e=>e.availableModels),ne=Te(e=>e.selectedModel),T=w(e=>e.previewAttachment),re=w(e=>e.previewImageSize),ie=(0,b.useRef)(null),ae=(0,b.useRef)(!0),oe=(0,b.useRef)(!1),se=(0,b.useRef)(0),ce=(0,b.useRef)(v),le=(0,b.useRef)(!1),E=(0,b.useRef)(null),D=(0,b.useRef)(!0),ue=(0,b.useRef)(``),de=(0,b.useMemo)(()=>C.find(e=>e.id===ne)||null,[C,ne]),fe=(0,b.useMemo)(()=>VJ({messages:h,draftInput:S,selectedModel:de}),[S,h,de]),pe=(0,b.useCallback)(()=>{let e=ie.current;if(!e)return;ae.current=!0,oe.current=!1;let t=e.style.scrollBehavior;e.style.scrollBehavior=`auto`;let n=0,r=0,i=-1,a=()=>{if(ie.current===e){if(e.scrollTop=e.scrollHeight,se.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,b.useEffect)(()=>{ce.current=v},[v]),(0,b.useEffect)(()=>{D.current=!0,ae.current=!0,oe.current=!1,se.current=0,le.current=!1,E.current=null,ue.current=``},[g]),(0,b.useEffect)(()=>{let e=h.at(-1),t=ue.current;ue.current=String(e?.id||``),e?.role===`user`&&e.id!==t&&!D.current&&pe()},[h,pe]),(0,b.useEffect)(()=>{let e=ie.current;if(!e)return;let t=()=>{let t=e.scrollHeight-e.scrollTop-e.clientHeight,n=e.scrollTop<se.current-2;if(se.current=e.scrollTop,!D.current&&n&&e.scrollTop<200&&g&&ee?.hasMore&&!ee.isLoadingOlder&&!le.current&&f){let t=e.scrollHeight,n=g,r=Symbol(n);le.current=!0,E.current=r,f(n).then(()=>{HJ({requestedSessionId:n,activeSessionId:Ze.getState().currentSessionId,requestToken:r,activeRequestToken:E.current})&&requestAnimationFrame(()=>{if(!HJ({requestedSessionId:n,activeSessionId:Ze.getState().currentSessionId,requestToken:r,activeRequestToken:E.current}))return;let e=ie.current;if(!e)return;let i=e.scrollHeight-t;e.scrollTop+=i,se.current=e.scrollTop})}).finally(()=>{E.current===r&&(E.current=null,le.current=!1)})}if(ce.current&&n){oe.current=!0,ae.current=!1;return}if(oe.current){let e=t<=12;oe.current=!e,ae.current=e;return}ae.current=t<96};return t(),e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[ee,g,f]),(0,b.useEffect)(()=>{let e=ie.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{!D.current&&!ae.current||(e.scrollTop=e.scrollHeight,se.current=e.scrollTop,e.dispatchEvent(new Event(`scroll`)))});return t.observe(e),e.firstElementChild instanceof HTMLElement&&t.observe(e.firstElementChild),()=>t.disconnect()},[g]),(0,b.useEffect)(()=>{let e=ie.current;if(e){if(h.length>0&&D.current){let e=Ze.getState().currentSessionId,t=ie.current,n=t?t.style.scrollBehavior:``;t&&(t.style.scrollBehavior=`auto`,t.scrollTop=t.scrollHeight,se.current=t.scrollTop);let r=0,i=t?.scrollHeight??-1,a=!1,o=0,s=()=>{let e=ie.current;e&&(e.scrollTop=e.scrollHeight,se.current=e.scrollTop,e.dispatchEvent(new Event(`scroll`)))},c=()=>{a||(a=!0,s(),t&&(t.style.scrollBehavior=n),ae.current=!0,oe.current=!1,D.current=!1)},l=()=>{if(a)return;if(Ze.getState().currentSessionId!==e){a=!0;return}let t=ie.current;if(t){if(t.scrollHeight!==i)i=t.scrollHeight,s(),r=0;else if(r+=1,r>=3){c();return}o=requestAnimationFrame(l)}},u=window.setTimeout(c,2e3);return o=requestAnimationFrame(l),()=>{if(cancelAnimationFrame(o),window.clearTimeout(u),Ze.getState().currentSessionId!==e){c();return}t&&(t.style.scrollBehavior=n)}}ae.current&&(e.scrollTop=e.scrollHeight,se.current=e.scrollTop)}},[h,v]),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(EJ,{emptyState:t,agentName:e,isMobile:n,isStreaming:v,activity:y,contextIndicator:fe,messages:h,isLoadingInitialHistory:te,onDeleteFeedback:r,onOpenAttachmentPreview:e=>{w.getState().setPreviewAttachment(e),w.getState().setPreviewImageSize(null)},onRespondToApproval:a,onRespondToAguiApproval:o,interactionRecords:p,onScrollToBottom:pe,onSubmitFeedback:i,onSubmitAguiAction:s,onStopGeneration:c,onCancelRemote:l,checkpoints:u?x:[],onResumeCheckpoint:d,scrollRef:ie,className:m}),(0,U.jsx)(LJ,{attachment:T,isMobile:n,previewImageSize:re,onClose:()=>{w.getState().setPreviewAttachment(null),w.getState().setPreviewImageSize(null)},onImageLoad:e=>w.getState().setPreviewImageSize(e)})]})}function WJ({indicator:e,onCompact:t,disabled:n}){let r=(0,b.useRef)(null),[i,a]=(0,b.useState)(!1),o=(0,b.useRef)(!1);(0,b.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,b.useState)(!1),[l,u]=(0,b.useState)(``),d=Math.max(0,Math.min(100,e.percent??0)),f=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,U.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,U.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,U.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,U.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`,fill:`none`,stroke:`var(--ksadk-menu-border, #b8bcb5)`,strokeWidth:`2`}),e.percent!==void 0&&(0,U.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,pathLength:`100`,strokeDasharray:`${d} 100`,transform:`rotate(-90 8 8)`})]})}),(0,U.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,U.jsx)(`p`,{className:K(`font-medium`,s&&`waiting-thinking-text`),children:s?`正在压缩上下文…`:e.label}),(0,U.jsxs)(`p`,{className:`mt-1 text-text-secondary`,children:[e.usedTokens===void 0?`等待运行时报告用量`:`${GJ(e.usedTokens)} tokens`,e.usedTokens!==void 0&&e.contextWindowTokens?` / ${GJ(e.contextWindowTokens)}`:``]}),e.contextWindowTokens&&(0,U.jsxs)(`p`,{className:`mt-1 text-text-muted`,children:[`模型窗口:`,GJ(e.contextWindowTokens),` tokens`,e.contextWindowSource===`model`?`(模型配置)`:`(运行时报告)`]}),e.usedTokens!==void 0&&!e.contextWindowTokens&&(0,U.jsx)(`p`,{className:`mt-1 text-text-muted`,children:`模型窗口大小未报告`}),e.percent!==void 0&&(0,U.jsxs)(`p`,{className:`text-text-muted`,children:[e.percent,`% 已使用`]}),i&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`button`,{type:`button`,onClick:()=>void f(),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,U.jsx)(`p`,{className:`mt-2 text-xs text-text-muted`,children:n?`请等待当前运行结束`:t?`压缩模型上下文,保留聊天记录`:`当前会话尚不支持手动压缩`}),l&&(0,U.jsx)(`p`,{role:`status`,className:`mt-2 text-xs`,children:l})]})]})]})}function GJ(e){return new Intl.NumberFormat(`zh-CN`).format(e)}var KJ=[{value:`plan`,label:`计划模式`,description:`先分析并形成可执行计划`,icon:ON},{value:`goal`,label:`设定目标`,description:`朝可验证的停止条件持续推进`,icon:QN}],qJ={plan:`计划模式`,goal:`目标`};function JJ({attachmentsEnabled:e,mode:t,support:n,onSelectMode:r,onUpload:i}){let[a,o]=(0,b.useState)(!1),s=(0,b.useRef)(null),c=KJ.filter(e=>n[e.value]);return(0,b.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,U.jsxs)(`div`,{ref:s,className:`relative flex min-w-0 items-center gap-1`,children:[(0,U.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,U.jsx)(HN,{className:`h-[19px] w-[19px]`})}),t?(0,U.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":`当前执行模式:${qJ[t]}`,children:[(0,U.jsx)(`span`,{className:`truncate`,children:qJ[t]}),(0,U.jsx)(uN,{className:`h-3.5 w-3.5 shrink-0`})]}):null,a?(0,U.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,U.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,U.jsx)(nP,{className:`h-4 w-4 shrink-0 text-text-muted`}),(0,U.jsx)(`span`,{className:`shrink-0 text-[13px] font-medium text-text-primary`,children:`上传附件`}),(0,U.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,U.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,U.jsx)(n,{className:`h-4 w-4 shrink-0 text-text-muted`}),(0,U.jsx)(`span`,{className:`shrink-0 text-[13px] font-medium text-text-primary`,children:e.label}),(0,U.jsx)(`span`,{className:`ml-auto truncate text-[11px] text-text-muted`,children:e.description}),i?(0,U.jsx)(lN,{className:`h-4 w-4 shrink-0 text-text-primary`}):null]},e.value)})]}):null]})}var YJ=[{value:`auto`,label:`自动`},{value:`enabled`,label:`开启`},{value:`disabled`,label:`关闭`}],XJ={auto:`自动`,enabled:`开启`,disabled:`关闭`};function ZJ({availableModels:e,selectedModel:t,thinkingEnabled:n,thinkingMode:r,onSelectModel:i,onSelectThinkingMode:a}){let[o,s]=(0,b.useState)(!1),c=(0,b.useRef)(null),l=e.find(e=>e.id===t)?.display_name||t||`选择模型`;return(0,b.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,U.jsxs)(`div`,{ref:c,className:`relative`,children:[(0,U.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},推理 ${XJ[r]}`:`模型 ${l}`,title:n?`选择模型与推理设置`:`选择模型`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:l}),n?(0,U.jsx)(`span`,{className:`shrink-0 text-text-muted`,children:XJ[r]}):null,(0,U.jsx)(uN,{className:K(`h-3.5 w-3.5 shrink-0 text-text-muted transition-transform`,o&&`rotate-180`)})]}),o?(0,U.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,U.jsx)(`div`,{className:`px-2.5 pb-1.5 pt-1 text-[11px] font-medium text-text-muted`,children:`模型`}),(0,U.jsx)(`div`,{className:`max-h-[min(45vh,18rem)] overflow-y-auto`,children:e.map(e=>{let n=e.id===t;return(0,U.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,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.display_name||e.id}),n?(0,U.jsx)(lN,{className:`h-4 w-4 shrink-0`,"aria-hidden":`true`}):null]},e.id)})}),n?(0,U.jsx)(`div`,{className:`mt-1 border-t border-border px-1 pt-1.5`,children:(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-1.5 pb-1`,children:[(0,U.jsx)(`span`,{className:`text-[11px] font-medium text-text-muted`,children:`推理`}),(0,U.jsx)(`div`,{className:`flex rounded-lg bg-muted p-0.5`,children:YJ.map(e=>(0,U.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 QJ=[{value:`ask`,label:`请求批准`,description:`Agent 请求授权时确认`,icon:EN},{value:`risk`,label:`风险操作需确认`,description:`仅副作用操作`,icon:JN},{value:`full`,label:`完全访问`,description:`不再确认`,icon:qN}],$J={ask:`请求批准`,risk:`风险确认`,full:`完全访问`};function eY({approvalPolicy:e}){let[t,n]=(0,b.useState)(!1),r=(0,b.useRef)(null),i=ke(e=>e.permissionMode),a=ke(e=>e.setPermissionMode),o=i===`ask`?EN:i===`full`?qN:JN,s=(0,b.useMemo)(()=>QJ.filter(t=>!e||e.Modes.includes(t.value)),[e]);return(0,b.useEffect)(()=>{s.some(e=>e.value===i)||a(e?.DefaultMode||s[0]?.value||`risk`)},[e?.DefaultMode,i,a,s]),(0,b.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,U.jsxs)(`div`,{ref:r,className:`relative`,children:[(0,U.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,U.jsx)(o,{className:`h-3.5 w-3.5`}),(0,U.jsx)(`span`,{children:$J[i]}),(0,U.jsx)(uN,{className:K(`h-3.5 w-3.5 transition-transform`,t&&`rotate-180`)})]}),t?(0,U.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,U.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,U.jsx)(t,{className:K(`h-4 w-4 shrink-0`,r?`text-primary`:`text-text-muted`)}),(0,U.jsx)(`span`,{className:K(`shrink-0 text-[13px] font-medium`,r?`text-text-primary`:`text-text-secondary`),children:e.label}),(0,U.jsx)(`span`,{className:`ml-auto truncate text-[11px] text-text-muted`,children:e.description}),r?(0,U.jsx)(lN,{className:`h-4 w-4 shrink-0 text-primary`,"aria-hidden":`true`}):null]},e.value)})}):null]})}function tY({onCompactContext:e,attachments:t,composerContextIndicator:n,composerMaxHeight:r,fileInputRef:i,input:a,isMobile:o,isStreaming:s,attachmentsEnabled:c=!0,approvalEnabled:l=!1,approvalPolicy:u,thinkingEnabled:d=!1,executionMode:f,executionModeSupport:p,queuedDrafts:m,onAppendAttachments:h,onInputChange:g,onSelectExecutionMode:_,onPaste:v,onRemoveAttachment:y,onStopGeneration:x,onCancelRemote:ee,onSubmit:te,textareaRef:S,className:C}){let[ne,w]=(0,b.useState)(!1),T=e?async()=>{w(!0);try{await e()}finally{w(!1)}}:void 0,re=f===`goal`?`描述需要持续完成的目标…`:f===`plan`?`描述需要先规划的任务…`:o?`发送消息...`:`发送消息…`,ie=ee?`保留恢复点并结束本次执行`:`停止生成`,ae=f===`goal`?!!a.trim():!!(a.trim()||t.length>0),oe=Te(e=>e.availableModels),se=Te(e=>e.selectedModel),ce=Te(e=>e.thinkingMode),le=Te(e=>e.setSelectedModel),E=Te(e=>e.setThinkingMode),D=e=>e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`;return(0,U.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`,C),"data-slot":`composer`,children:(0,U.jsxs)(`div`,{className:`mx-auto w-full max-w-[64rem]`,children:[ne&&(0,U.jsxs)(`div`,{role:`status`,className:`mb-3 flex items-center gap-2 px-2 text-sm text-text-muted`,children:[(0,U.jsx)(wN,{size:16,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`waiting-thinking-text`,children:`正在压缩上下文`})]}),m.length>0?(0,U.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,U.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between gap-2`,children:[(0,U.jsxs)(`span`,{className:`font-semibold`,children:[`发送队列 · `,m.length]}),(0,U.jsx)(`span`,{className:`text-neutral-700/75 dark:text-neutral-200/75`,children:`当前回复完成后依次发送`})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[m.slice(0,3).map((e,t)=>{let n=e.text.trim()||(e.attachments.length>0?`仅附件消息`:`空消息`);return(0,U.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-background/70 px-2 py-1.5`,children:[(0,U.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,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-text-secondary`,children:n}),e.attachments.length>0?(0,U.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}`)}),m.length>3?(0,U.jsxs)(`div`,{className:`px-2 pt-0.5 text-[11px] text-neutral-700/80 dark:text-neutral-200/80`,children:[`还有 `,m.length-3,` 条等待发送`]}):null]})]}):null,(0,U.jsx)(`div`,{className:`relative rounded-[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,U.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,U.jsxs)(`form`,{onSubmit:e=>{if(e.preventDefault(),ne)return;if(s){ee?ee():x();return}let n=a.trim();ae&&te(n,t)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:e=>{e.preventDefault(),e.stopPropagation(),c&&e.dataTransfer.files&&e.dataTransfer.files.length>0&&h(Array.from(e.dataTransfer.files))},className:`relative flex min-h-[116px] min-w-0 flex-1 flex-col rounded-[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:[t.length>0?(0,U.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-2`,children:t.map((e,t)=>(0,U.jsxs)(`div`,{className:K(`group relative flex items-center gap-2 rounded-xl border border-border bg-background px-3 py-2 text-xs`,o?`max-w-full`:`max-w-[14rem]`),children:[(0,U.jsx)(`span`,{className:`flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-lg bg-muted text-text-muted`,children:(0,U.jsx)(RN,{className:`h-3.5 w-3.5`})}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`block truncate font-medium text-text-primary`,children:e.name}),(0,U.jsx)(`span`,{className:`block text-[10px] text-text-muted`,children:D(e.size)})]}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>y(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,U.jsx)(`span`,{className:`text-[11px] leading-none`,children:`×`})})]},`${e.name}-${e.size}-${t}`))}):null,(0,U.jsx)(`textarea`,{ref:S,rows:1,value:a,onChange:g,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},onPaste:v,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`,o?`text-[16px]`:`text-[14px]`),style:{maxHeight:`${r}px`,overflowY:`auto`}}),(0,U.jsxs)(`div`,{className:`mt-auto flex min-h-8 items-center justify-between gap-2 pt-1.5`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,U.jsx)(`input`,{ref:i,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&e.target.files.length>0&&(h(Array.from(e.target.files)),e.target.value=``)}}),(0,U.jsx)(JJ,{attachmentsEnabled:c,mode:f,support:p,onSelectMode:_,onUpload:()=>i.current?.click()}),l?(0,U.jsx)(eY,{approvalPolicy:u}):null]}),(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[n?(0,U.jsx)(WJ,{indicator:n,onCompact:T,disabled:s}):null,oe.length>0?(0,U.jsx)(ZJ,{availableModels:oe,selectedModel:se,thinkingEnabled:d,thinkingMode:ce,onSelectModel:le,onSelectThinkingMode:E}):null,(0,U.jsx)(`button`,{type:`submit`,disabled:ne||!s&&!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`,s||ae?`bg-[#1f1f1f] text-white hover:opacity-80`:`bg-muted text-text-muted/45`),title:s?ie:`发送消息`,children:s?(0,U.jsx)(ZN,{className:`h-3.5 w-3.5 fill-current`}):(0,U.jsx)(sN,{className:`h-[18px] w-[18px]`})})]})]})]})})})]})})}function nY(e){return[e.name,e.size,e.lastModified,e.type].join(`:`)}function rY(e,t){let n=new Map;for(let t of e)n.set(nY(t),t);for(let e of t)n.set(nY(e),e);return Array.from(n.values())}function iY(e){return Array.from(e.clipboardData.items||[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>!!e)}function aY({onCompactContext:e,composerMaxHeight:t,submitDraft:n,stopGeneration:r,cancelRemote:i,isMobile:a,attachmentsEnabled:o=!0,approvalEnabled:s=!1,approvalPolicy:c,thinkingEnabled:l=!1,runtimeCapabilityMatrix:u,pendingInteractions:d,onRespondInteraction:f,localCatalog:p,className:m}){let[h,g]=(0,b.useState)(0),[_,v]=(0,b.useState)(),y=w(e=>e.input),x=w(e=>e.attachments),ee=Ze(e=>e.currentSessionId),te=O(e=>!!(e.getSessionActivity(ee)&&e.isSessionStreaming(ee))),S=w(e=>e.queuedDrafts),C=qc(e=>e.messages),ne=Ze(e=>e.sessions.find(e=>e.SessionId===ee)?.ContextUsage),T=Te(e=>e.availableModels),re=Te(e=>e.selectedModel),ie=Te(e=>e.setThinkingMode),ae=(0,b.useRef)(null),oe=(0,b.useRef)(null),se=(0,b.useMemo)(()=>T.find(e=>e.id===re)||null,[T,re]),ce=(0,b.useMemo)(()=>VJ({messages:C,draftInput:y,selectedModel:se,contextUsage:ne}),[y,C,se,ne]),le=(0,b.useMemo)(()=>({plan:!!u?.plan?.supported,goal:!!u?.goal?.supported}),[u]),E=_&&le[_]?_:void 0,D=(0,b.useCallback)((e,t)=>{!e&&t.length===0||(w.getState().setInput(``),w.getState().setAttachments([]),n(e,t,void 0,void 0,E),E===`goal`&&v(void 0))},[E,n]);(0,b.useEffect)(()=>{oe.current&&(oe.current.style.height=`auto`,oe.current.style.height=`${Math.min(oe.current.scrollHeight,t)}px`)},[y,t]);let ue=e=>{w.getState().setInput(e.target.value),e.target.style.height=`auto`,e.target.style.height=`${Math.min(e.target.scrollHeight,t)}px`},de=e=>{!o||!e.length||w.getState().setAttachments(t=>rY(t,e))},fe=e=>{if(!o)return;let t=iY(e);t.length&&(e.preventDefault(),e.stopPropagation(),de(t))},pe=d||[],me=Math.min(h,Math.max(pe.length-1,0));return(0,b.useEffect)(()=>{l||ie(`auto`)},[ie,l]),(0,U.jsxs)(`div`,{className:`flex w-full flex-col justify-center`,children:[pe.length>0&&f?(0,U.jsx)(Wq,{interactions:pe,activeIndex:me,onSelectIndex:g,onRespond:f,localCatalog:p}):null,(0,U.jsx)(tY,{onCompactContext:ee?e:void 0,attachments:x,composerContextIndicator:ce,composerMaxHeight:t,fileInputRef:ae,input:y,isMobile:a,isStreaming:te,attachmentsEnabled:o,approvalEnabled:s,approvalPolicy:c,thinkingEnabled:l,executionMode:E,executionModeSupport:le,queuedDrafts:S,onAppendAttachments:de,onInputChange:ue,onSelectExecutionMode:v,onPaste:fe,onRemoveAttachment:e=>w.getState().setAttachments(t=>t.filter((t,n)=>n!==e)),onStopGeneration:r,onCancelRemote:i,onSubmit:D,textareaRef:oe,className:m},ee||`new-session`)]})}var oY=(0,b.lazy)(()=>J(()=>import(`./NativeTerminalPanel-BTTm24gh.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function sY({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,U.jsx)(`select`,{value:t,onChange:e=>n(e.target.value),className:u,children:e.map(e=>(0,U.jsx)(`option`,{value:e.id,children:e.display_name||e.id},e.id))}):r?(0,U.jsx)(`span`,{className:K(u,`inline-flex max-w-full items-center`,l?`justify-start`:``),title:a||r,children:(0,U.jsx)(`span`,{className:`truncate`,children:r})}):(0,U.jsx)(`span`,{className:`text-sm text-slate-400`,children:i?`未配置模型`:`Loading models...`}),f=o?(0,U.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),className:K(u,l?``:`max-w-[9rem]`),title:`控制模型 thinking/reasoning 参数`,children:[(0,U.jsx)(`option`,{value:`auto`,children:`思考自动`}),(0,U.jsx)(`option`,{value:`enabled`,children:`开启思考`}),(0,U.jsx)(`option`,{value:`disabled`,children:`关闭思考`})]}):null;return(0,U.jsxs)(`div`,{className:K(`flex min-w-0 gap-2`,l?`w-full flex-col`:`items-center`),children:[d,f]})}function cY({agentName:e,currentSessionId:t,isMobile:n,sidebarOpen:r,mobileSidebarOpen:i,onToggleSidebar:a,availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m,mobileActionsOpen:h,onMobileActionsOpenChange:g,workspaceEnabled:_,onOpenWorkspace:v,nativeManagementLink:y,nativeTerminal:x,nativeLauncherMode:ee=!1}){let[te,S]=(0,b.useState)(!1),C=!!x?.Enabled,ne=n?i?(0,U.jsx)(IN,{className:`h-5 w-5`}):(0,U.jsx)(LN,{className:`h-5 w-5`}):r?(0,U.jsx)(IN,{className:`h-5 w-5`}):(0,U.jsx)(LN,{className:`h-5 w-5`});return(0,U.jsxs)(U.Fragment,{children:[(0,U.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,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[ee?null:(0,U.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:ne}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100 sm:text-base`,children:e}),(0,U.jsx)(`div`,{className:`text-[11px] text-slate-400 dark:text-slate-500`,children:ee?`原生运行时入口`:`智能体`})]})]}),n?(0,U.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,U.jsx)(yN,{className:`h-5 w-5`})}):(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[y?(0,U.jsxs)(`a`,{href:y.href,target:`_blank`,rel:`noreferrer`,title:y.title,className:`inline-flex flex-shrink-0 items-center gap-1.5 whitespace-nowrap rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm font-medium leading-none text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,U.jsx)(bN,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{children:y.label})]}):null,_?(0,U.jsxs)(`button`,{type:`button`,onClick:v,className:`inline-flex flex-shrink-0 items-center gap-1.5 whitespace-nowrap rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm font-medium leading-none text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,U.jsx)(TN,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{children:`Workspace`})]}):null,C?(0,U.jsxs)(`button`,{type:`button`,onClick:()=>S(!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,U.jsx)(XN,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{children:`TUI`})]}):null,!ee&&n?(0,U.jsx)(sY,{availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m,compact:!0}):null,!ee&&t?(0,U.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,U.jsx)(JR,{open:h,onOpenChange:g,children:(0,U.jsxs)(XR,{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,U.jsxs)(ZR,{className:`text-left`,children:[(0,U.jsx)(QR,{children:`会话设置`}),(0,U.jsx)($R,{className:`sr-only`,children:`调整当前会话的模型和 Workspace 操作。`})]}),(0,U.jsxs)(`div`,{className:`mt-6 flex flex-col gap-4`,children:[_?(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{g(!1),v()},className:`inline-flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm font-medium text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,U.jsx)(TN,{className:`h-4 w-4`}),`工作区文件`]}):null,C?(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{g(!1),S(!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,U.jsx)(XN,{className:`h-4 w-4`}),`原生 TUI`]}):null,y?(0,U.jsxs)(`a`,{href:y.href,target:`_blank`,rel:`noreferrer`,title:y.title,onClick:()=>g(!1),className:`inline-flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm font-medium text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,U.jsx)(bN,{className:`h-4 w-4`}),y.label]}):null,ee?(0,U.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,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-slate-400 dark:text-slate-500`,children:`模型`}),(0,U.jsx)(sY,{availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m,compact:!0})]}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-slate-400 dark:text-slate-500`,children:`当前会话`}),(0,U.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,U.jsx)(`span`,{className:`break-all font-mono`,children:t}):`新对话尚未创建会话 ID`})]})]})]})]})}):null,x&&te?(0,U.jsx)(b.Suspense,{fallback:null,children:(0,U.jsx)(oY,{capability:x,open:te,sessionId:t,onClose:()=>S(!1)})}):null]})}var lY=(0,b.lazy)(()=>J(()=>import(`./NativeTerminalPanel-BTTm24gh.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function uY({productLabel:e=`原生运行时`,nativeManagementLink:t,nativeTerminal:n,workspaceEnabled:r,onOpenWorkspace:i}){let a=!!n?.Enabled,[o,s]=(0,b.useState)(!1);return(0,U.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,U.jsx)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col justify-center`,children:(0,U.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,U.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,U.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,U.jsx)(JN,{className:`h-3.5 w-3.5`}),e,` native runtime`]}),(0,U.jsx)(`h1`,{className:`mt-5 text-2xl font-semibold tracking-tight text-slate-950 dark:text-slate-50 sm:text-3xl`,children:`对话请使用原生管理台`}),(0,U.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,U.jsxs)(`div`,{className:`grid gap-4 p-6 md:grid-cols-3 sm:p-8`,children:[(0,U.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,U.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,U.jsx)(NN,{className:`h-5 w-5`})}),(0,U.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`原生管理台`}),(0,U.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`使用原生管理台处理对话、工具卡片、思考流、审批、中断和运行时历史,避免跨状态机不一致。`}),t?(0,U.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,U.jsx)(bN,{className:`h-4 w-4`}),`打开`,t.label]}):(0,U.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,U.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,U.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,U.jsx)(TN,{className:`h-5 w-5`})}),(0,U.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`Workspace 文件管理`}),(0,U.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`文件浏览、上传、预览仍由 Hosted UI 提供,和原生管理台组合使用覆盖对话与工作区。`}),r?(0,U.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,U.jsx)(TN,{className:`h-4 w-4`}),`打开 Workspace`]}):(0,U.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,U.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,U.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,U.jsx)(XN,{className:`h-5 w-5`})}),(0,U.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`原生 TUI`}),(0,U.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`如果运行时暴露安全的 ks-terminal.v1 通道,可以在这里进入原生终端 UI;share 链接不会开放该入口。`}),a?(0,U.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,U.jsx)(XN,{className:`h-4 w-4`}),`打开 TUI`]}):(0,U.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,U.jsx)(b.Suspense,{fallback:null,children:(0,U.jsx)(lY,{capability:n,open:o,onClose:()=>s(!1)})}):null]})}var dY=[],fY=[];(()=>{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?fY:dY).push(n+=e[t])})();function pY(e){if(e<768)return!1;for(let t=0,n=dY.length;;){let r=t+n>>1;if(e<dY[r])n=r;else if(e>=fY[r])t=r+1;else return!0;if(t==n)return!1}}function mY(e){return e>=127462&&e<=127487}var hY=8205;function gY(e,t,n=!0,r=!0){return(n?_Y:vY)(e,t,r)}function _Y(e,t,n){if(t==e.length)return t;t&&bY(e.charCodeAt(t))&&xY(e.charCodeAt(t-1))&&t--;let r=yY(e,t);for(t+=SY(r);t<e.length;){let i=yY(e,t);if(r==hY||i==hY||n&&pY(i))t+=SY(i),r=i;else if(mY(i)){let n=0,r=t-2;for(;r>=0&&mY(yY(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function vY(e,t,n){for(;t>0;){let r=_Y(e,t-2,n);if(r<t)return r;t--}return 0}function yY(e,t){let n=e.charCodeAt(t);if(!xY(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return bY(r)?(n-55296<<10)+(r-56320)+65536:n}function bY(e){return e>=56320&&e<57344}function xY(e){return e>=55296&&e<56320}function SY(e){return e<65536?1:2}var CY=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]=NY(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),TY.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]=NY(this,e,t);let n=[];return this.decompose(e,t,n,0),TY.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 kY(this),i=new kY(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 kY(this,e)}iterRange(e,t=this.length){return new AY(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 jY(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 wY(t):TY.from(wY.split(t,[]))}},wY=class e extends CY{constructor(e,t=EY(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 MY(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(OY(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=DY(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]=NY(this,t,n);let i=DY(this.text,DY(r.text,OY(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):TY.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,U.jsx)(cN,{className:`h-8 w-8 text-white`})}),(0,U.jsx)(`h2`,{className:`text-xl font-semibold text-slate-900 dark:text-slate-50`,children:`有什么我可以帮您的吗?`}),(0,U.jsxs)(`p`,{className:`mt-2 text-sm text-slate-500`,children:[`我是 `,e,`,由 Ksyun AgentEngine 驱动`]})]})}function bJ(){return(0,U.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[44rem] flex-col gap-5 px-2 py-8`,"aria-label":`正在加载会话历史`,children:[(0,U.jsx)(`div`,{className:`h-4 w-28 animate-pulse rounded bg-slate-200/80 dark:bg-slate-800`}),(0,U.jsx)(`div`,{className:`h-20 w-4/5 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900`}),(0,U.jsx)(`div`,{className:`ml-auto h-12 w-3/5 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900`}),(0,U.jsx)(`div`,{className:`h-16 w-11/12 animate-pulse rounded-lg bg-slate-100 dark:bg-slate-900`})]})}function xJ({attachments:e,isMobile:t,onOpenAttachmentPreview:n}){return(0,U.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-3`,children:e.map((e,r)=>e.type.startsWith(`image/`)?e.url?(0,U.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,U.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]`)})},`${e.name}-${r}`):(0,U.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,U.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,U.jsx)(RN,{className:`h-4 w-4 flex-shrink-0 text-blue-500`}),e.url?(0,U.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,U.jsx)(`span`,{className:`truncate text-sm text-slate-700 dark:text-slate-300`,title:e.name,children:e.name})]},`${e.name}-${r}`))})}function SJ({message:e}){return(0,U.jsx)(`div`,{className:`w-full px-0 py-2 sm:px-4`,children:(0,U.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,U.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[e.status===`running`?(0,U.jsx)(UN,{className:`h-4 w-4 animate-spin text-neutral-600 dark:text-neutral-300`}):e.status===`failed`?(0,U.jsx)(pN,{className:`h-4 w-4 text-rose-600 dark:text-rose-400`}):(0,U.jsx)(lN,{className:`h-4 w-4 text-emerald-600 dark:text-emerald-400`}),(0,U.jsx)(`span`,{children:e.content})]}),e.compactedUntilSeqId?(0,U.jsxs)(`div`,{className:`mt-1 text-xs text-neutral-700/80 dark:text-neutral-200/80`,children:[`已折叠到会话事件 #`,e.compactedUntilSeqId]}):null,e.summary?(0,U.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,U.jsx)(`summary`,{className:`cursor-pointer select-none text-xs font-medium text-neutral-800 dark:text-neutral-200`,children:`查看压缩摘要`}),(0,U.jsx)(`div`,{className:`mt-2 text-[13px] leading-relaxed text-slate-700 dark:text-slate-200`,children:(0,U.jsx)(Tq,{content:e.summary})})]}):null]})})}function CJ({label:e,tone:t,value:n}){let[r,i]=(0,b.useState)(`idle`),a=EA(n);(0,b.useEffect)(()=>{if(r===`idle`)return;let e=window.setTimeout(()=>i(`idle`),1600);return()=>window.clearTimeout(e)},[r]);let o=async()=>{i(await sJ(a)?`copied`:`failed`)};return(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,U.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,U.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,U.jsx)(lN,{className:`h-3.5 w-3.5 text-emerald-500`}):(0,U.jsx)(gN,{className:`h-3.5 w-3.5`}),r===`copied`?`已复制`:r===`failed`?`复制失败`:`复制`]})]}),(0,U.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 wJ({isLastMessage:e,isStreaming:t,message:n,onDeleteFeedback:r,onSubmitFeedback:i,alwaysVisible:a=!1}){let[o,s]=(0,b.useState)(!1),[c,l]=(0,b.useState)(n.feedback?.comment||``),u=iM(n,t,e),d=!!n.feedback?.pending,f=n.feedback?.rating,p=async()=>{let e=n.content||``;e&&sJ(e)};return u?(0,U.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,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-xs text-text-muted`,children:[(0,U.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,U.jsx)(gN,{className:`h-3.5 w-3.5`})}),(0,U.jsx)(`span`,{className:`text-text-muted/60`,children:`·`}),(0,U.jsx)(`span`,{className:`font-medium`,children:`本次回复有帮助吗?`}),(0,U.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,U.jsx)(eP,{className:`h-3.5 w-3.5`}),`有帮助`]}),(0,U.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,U.jsx)($N,{className:`h-3.5 w-3.5`}),`需改进`]}),n.feedback?(0,U.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,U.jsx)(tP,{className:`h-3.5 w-3.5`}),`删除反馈`]}):null,d?(0,U.jsx)(`span`,{className:`text-slate-400`,children:`提交中…`}):null]}),o?(0,U.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,U.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,U.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-2`,children:[(0,U.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,U.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,U.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,U.jsx)(`div`,{className:`text-xs text-rose-600 dark:text-rose-300`,children:n.feedback.error}):null]}):null}function TJ({agentName:e,isMobile:t,isStreaming:n,isLastMessage:r,showAgentHeader:i,message:a,onDeleteFeedback:o,onOpenAttachmentPreview:s,onRespondToApproval:c,onRespondToAguiApproval:l,onSubmitFeedback:u,onSubmitAguiAction:d,interactionRecords:f}){if(a.role===`user`)return(0,U.jsx)(`div`,{className:`mb-3 flex justify-end`,children:(0,U.jsxs)(`div`,{className:`max-w-[80%] rounded-2xl bg-muted px-3 py-2 text-[14px] leading-relaxed text-foreground`,children:[a.attachments?.length?(0,U.jsx)(xJ,{attachments:a.attachments,isMobile:t,onOpenAttachmentPreview:s}):null,a.content]})});if(a.role===`a2ui`&&a.aguiActivity)return(0,U.jsx)(Pq,{surfaceId:a.aguiActivity.surfaceId,messages:a.aguiActivity.messages,onAction:d});let p=n&&r&&!a.content;return(0,U.jsxs)(`div`,{className:`group mx-auto mb-3 w-full max-w-[60rem] px-2 sm:px-4`,children:[i?(0,U.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-xs text-text-muted`,children:[(0,U.jsx)(cN,{className:`w-3.5 h-3.5`}),(0,U.jsx)(`span`,{children:e})]}):null,a.attachments?.length?(0,U.jsx)(xJ,{attachments:a.attachments,isMobile:t,onOpenAttachmentPreview:s}):null,a.blocks?.length?(0,U.jsx)(iJ,{message:a,isStreaming:n,onRespondToApproval:c,interactionRecords:f,onRespondToAguiApproval:l}):(0,U.jsxs)(U.Fragment,{children:[a.reasoning?(0,U.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,U.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,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[p?null:(0,U.jsx)(lN,{className:`h-4 w-4 text-slate-400`}),(0,U.jsx)(`span`,{className:K(`truncate`,p&&`waiting-thinking-text`),"data-testid":p?`legacy-thinking-indicator`:void 0,role:p?`status`:void 0,children:p?`正在思考…`:`思考过程`}),p?null:(0,U.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,U.jsx)(uN,{className:`h-4 w-4 flex-shrink-0 text-slate-400 transition-transform group-open/details:rotate-180`})]}),(0,U.jsx)(`div`,{className:`border-t border-slate-200/70 bg-white/70 dark:border-slate-800 dark:bg-slate-950/20`,children:(0,U.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,U.jsx)(Tq,{content:a.reasoning})})})]}):null,a.tools?Object.values(a.tools).map((e,t)=>(0,U.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,U.jsx)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 px-3 py-2 font-medium`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.status===`running`?(0,U.jsx)(UN,{className:`h-4 w-4 animate-spin text-slate-500`}):e.status===`paused`?(0,U.jsx)(JN,{className:`h-4 w-4 text-neutral-500`}):e.status===`error`?(0,U.jsx)(mN,{className:`h-4 w-4 text-rose-500`}):(0,U.jsx)(lN,{className:`h-4 w-4 text-slate-400`}),(0,U.jsxs)(`span`,{children:[e.approvalStatus===`pending`?`等待审批:`:e.approvalStatus===`approved`?`已批准:`:e.approvalStatus===`rejected`?`已拒绝:`:e.approvalStatus===`cancelled`?`已取消:`:e.status===`error`?`工具调用失败:`:`工具调用:`,e.name]})]})}),(0,U.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,U.jsxs)(`div`,{className:`font-sans text-sm text-slate-700 dark:text-slate-200`,children:[(0,U.jsx)(`div`,{className:`font-medium`,children:e.approvalStatus===`approved`?`已批准该工具调用。`:e.approvalStatus===`rejected`?`已拒绝该工具调用。`:e.approvalStatus===`cancelled`?`已取消该工具调用。`:e.approvalMessage||`该工具调用需要人工确认后继续。`}),e.approvalLevel?(0,U.jsxs)(`div`,{className:K(`mt-2 inline-flex items-center rounded border px-1.5 py-0.5 text-xs font-medium`,_J(e.approvalLevel)),children:[`审批级别:`,gJ(e.approvalLevel)]}):null,e.serverLabel?(0,U.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,U.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,U.jsxs)(`button`,{type:`button`,disabled:n||e.approvalStatus!==`pending`,onClick:()=>e.approvalProtocol===`ag-ui`?l?.({interruptId:e.approvalRequestId||``,approve:!0}):c({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,U.jsx)(lN,{className:`h-3.5 w-3.5`}),`批准并继续`]}),(0,U.jsxs)(`button`,{type:`button`,disabled:n||e.approvalStatus!==`pending`,onClick:()=>e.approvalProtocol===`ag-ui`?l?.({interruptId:e.approvalRequestId||``,approve:!1}):c({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,U.jsx)(mN,{className:`h-3.5 w-3.5`}),`拒绝`]})]}):(0,U.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,U.jsx)(lN,{className:`h-3.5 w-3.5 text-emerald-500`}):(0,U.jsx)(mN,{className:`h-3.5 w-3.5 text-rose-500`}),e.approvalStatus===`approved`?`已批准`:e.approvalStatus===`cancelled`?`已取消`:`已拒绝`]})]}):null,e.args?(0,U.jsx)(CJ,{label:`入参 (Args)`,tone:`input`,value:e.args}):null,e.output?(0,U.jsx)(CJ,{label:`输出 (Output)`,tone:e.status===`error`?`error`:`output`,value:e.output}):null]})]},`${e.name}-${t}`)):null,a.tools?Object.values(a.tools).filter(e=>f?.some(t=>t.interactionId===e.approvalRequestId)).map(e=>(0,U.jsx)(Jq,{interaction:f.find(t=>t.interactionId===e.approvalRequestId)},`anchor-${e.approvalRequestId}`)):null,(0,U.jsx)(`div`,{className:`w-full break-words`,children:a.content?(0,U.jsx)(Tq,{content:a.content}):n&&r&&!a.reasoning&&!a.tools||a.eventType===`optimistic_assistant_placeholder`?(0,U.jsx)(`span`,{className:`relative mt-1 inline-flex h-4 w-4 items-center justify-center`,role:`status`,"aria-label":`正在生成`,children:(0,U.jsx)(`span`,{className:`waiting-generation-breathe h-2.5 w-2.5 rounded-full`})}):null})]}),a.aguiActivities?.map(e=>(0,U.jsx)(Pq,{surfaceId:e.surfaceId,messages:e.messages,onAction:d},e.surfaceId)),(0,U.jsx)(wJ,{isLastMessage:r,isStreaming:n,message:a,onDeleteFeedback:o,onSubmitFeedback:u})]})}function EJ({agentName:e,emptyState:t,isMobile:n,isStreaming:r,activity:i,contextIndicator:a,messages:o,isLoadingInitialHistory:s=!1,onDeleteFeedback:c,onOpenAttachmentPreview:l,onRespondToApproval:u,onRespondToAguiApproval:d,onSubmitFeedback:f,onSubmitAguiAction:p,onStopGeneration:m,onCancelRemote:h,onScrollToBottom:g,checkpoints:_=[],onResumeCheckpoint:v,interactionRecords:y,scrollRef:x,className:ee}){let[te,S]=(0,b.useState)(0),[C,ne]=(0,b.useState)(0),[w,T]=(0,b.useState)(0),[re,ie]=(0,b.useState)(new Map),ae=(0,b.useRef)(re);(0,b.useLayoutEffect)(()=>{let e=x.current;if(!e)return;let t=()=>{S(e.scrollTop),ne(e.clientHeight),T(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()},[x]);let oe=(0,b.useMemo)(()=>lJ({items:o,scrollTop:te,viewportHeight:C,overscan:hJ,defaultItemHeight:mJ,measuredHeights:re,getItemKey:(e,t)=>e?.id||String(t)}),[re,o,te,C]),se=oe.visibleItems,ce=(0,b.useCallback)((e,t,n)=>{if(!e||!Number.isFinite(t)||t<=0)return;let r=ae.current,i=r.get(e)??mJ;if(i===t)return;let a=new Map(r);a.set(e,t),ae.current=a,ie(a);let o=x.current;o&&n<o.scrollTop&&(o.scrollTop+=t-i,S(o.scrollTop),T(o.scrollHeight))},[x]),le=uJ({scrollHeight:w,scrollTop:te,clientHeight:C}),E=dJ({scrollHeight:w,scrollTop:te,clientHeight:C});return(0,U.jsxs)(`div`,{ref:x,onScroll:e=>{S(e.currentTarget.scrollTop),ne(e.currentTarget.clientHeight),T(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`,ee),"data-slot":`message-list`,children:[(0,U.jsx)(`div`,{className:`mx-auto flex w-full max-w-[64rem] flex-col pb-6 sm:pb-8`,children:o.length===0&&s?(0,U.jsx)(bJ,{}):o.length===0?t===void 0?(0,U.jsx)(yJ,{agentName:e}):t:(0,U.jsx)(`div`,{style:{height:oe.totalHeight},className:`relative`,children:se.map(t=>(0,U.jsx)(vJ,{messageId:t.item.id||String(t.index),top:t.top,onMeasure:ce,children:t.item.role===`system`?(0,U.jsx)(SJ,{message:t.item}):(0,U.jsx)(TJ,{agentName:e,isMobile:n,isStreaming:r,isLastMessage:t.index===o.length-1,showAgentHeader:!pJ(o[t.index-1],t.item),message:t.item,onDeleteFeedback:c,onOpenAttachmentPreview:l,onRespondToApproval:u,interactionRecords:y,onRespondToAguiApproval:d,onSubmitFeedback:f,onSubmitAguiAction:p})},t.item.id||t.index))})}),(0,U.jsx)(aJ,{}),E?(0,U.jsx)(`button`,{type:`button`,"aria-label":`回到底部`,"data-distance-from-bottom":Math.round(le),onClick:()=>{if(g){g();return}let e=x.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,U.jsx)(`span`,{"aria-hidden":`true`,className:`flex items-center gap-0.5`,"data-scroll-indicator":`streaming`,children:[0,1,2].map(e=>(0,U.jsx)(`span`,{className:`h-1 w-1 animate-bounce rounded-full bg-current motion-reduce:animate-none`,style:{animationDelay:`${e*120}ms`}},e))}):(0,U.jsx)(uN,{"aria-hidden":`true`,className:`h-5 w-5`,"data-scroll-indicator":`idle`})}):null]})}var DJ=zR,OJ=BR,kJ=b.forwardRef(({className:e,...t},n)=>(0,U.jsx)(VR,{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}));kJ.displayName=VR.displayName;var AJ=b.forwardRef(({className:e,children:t,...n},r)=>(0,U.jsxs)(OJ,{children:[(0,U.jsx)(kJ,{}),(0,U.jsxs)(HR,{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,U.jsxs)(GR,{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,U.jsx)(aP,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}));AJ.displayName=HR.displayName;var jJ=({className:e,...t})=>(0,U.jsx)(`div`,{className:K(`flex flex-col space-y-1.5 text-center sm:text-left`,e),...t});jJ.displayName=`DialogHeader`;var MJ=({className:e,...t})=>(0,U.jsx)(`div`,{className:K(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});MJ.displayName=`DialogFooter`;var NJ=b.forwardRef(({className:e,...t},n)=>(0,U.jsx)(UR,{ref:n,className:K(`text-lg font-semibold leading-none tracking-tight`,e),...t}));NJ.displayName=UR.displayName;var PJ=b.forwardRef(({className:e,...t},n)=>(0,U.jsx)(WR,{ref:n,className:K(`text-sm text-muted-foreground`,e),...t}));PJ.displayName=WR.displayName;function FJ(e,t){if(!(!t||e))return{width:`min(${t.width}px, calc(100vw - 5rem))`,height:`min(${t.height}px, calc(100vh - 9rem))`}}function IJ(e,t){if(!(!t||e))return{width:`min(${t.width+32}px, calc(100vw - 3rem))`}}function LJ({attachment:e,isMobile:t,previewImageSize:n,onClose:r,onImageLoad:i}){return(0,U.jsx)(DJ,{open:!!e?.url,onOpenChange:e=>!e&&r(),children:(0,U.jsxs)(AJ,{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:IJ(t,n),children:[(0,U.jsx)(`div`,{className:`flex items-center gap-3 border-b border-slate-800 px-4 py-3 pr-16`,children:(0,U.jsx)(NJ,{className:`truncate text-sm font-medium`,children:e?.name||`附件预览`})}),(0,U.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,U.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:FJ(t,n),onLoad:e=>{let t=e.currentTarget;i({width:t.naturalWidth,height:t.naturalHeight})}}):(0,U.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 RJ(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 zJ(e){return e?RJ(e.context_window_tokens)??RJ(e?.limits?.context_window_tokens):null}function BJ(e){return e?RJ(e.auto_compact_threshold_percentage)??84:84}function VJ({selectedModel:e,contextUsage:t}){let n=t&&(!t.model||t.model===e?.id)?t:null,r=RJ(n?.used_tokens),i=RJ(n?.context_window_tokens),a=i??zJ(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>=BJ(e)?`warning`:`normal`,percent:c,usedTokens:r,...o}}function HJ(e){return e.requestedSessionId===e.activeSessionId&&e.requestToken===e.activeRequestToken}function UJ({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}){let h=qc(e=>e.messages),g=Ze(e=>e.currentSessionId),_=Ze(e=>e.isLoadingSessions),v=O(e=>!!(e.getSessionActivity(g)&&e.isSessionStreaming(g))),y=O(e=>e.getSessionActivity(g)),x=Ej(e=>e.getSessionCheckpoints(g)),ee=Ze(e=>g?e.messageHistory[g]:null),te=_||!!ee?.isLoadingInitial,S=w(e=>e.input),C=Te(e=>e.availableModels),ne=Te(e=>e.selectedModel),T=w(e=>e.previewAttachment),re=w(e=>e.previewImageSize),ie=(0,b.useRef)(null),ae=(0,b.useRef)(!0),oe=(0,b.useRef)(!1),se=(0,b.useRef)(0),ce=(0,b.useRef)(v),le=(0,b.useRef)(!1),E=(0,b.useRef)(null),D=(0,b.useRef)(!0),ue=(0,b.useRef)(``),de=(0,b.useMemo)(()=>C.find(e=>e.id===ne)||null,[C,ne]),fe=(0,b.useMemo)(()=>VJ({messages:h,draftInput:S,selectedModel:de}),[S,h,de]),pe=(0,b.useCallback)(()=>{let e=ie.current;if(!e)return;ae.current=!0,oe.current=!1;let t=e.style.scrollBehavior;e.style.scrollBehavior=`auto`;let n=0,r=0,i=-1,a=()=>{if(ie.current===e){if(e.scrollTop=e.scrollHeight,se.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,b.useEffect)(()=>{ce.current=v},[v]),(0,b.useEffect)(()=>{D.current=!0,ae.current=!0,oe.current=!1,se.current=0,le.current=!1,E.current=null,ue.current=``},[g]),(0,b.useEffect)(()=>{let e=h.at(-1),t=ue.current;ue.current=String(e?.id||``),e?.role===`user`&&e.id!==t&&!D.current&&pe()},[h,pe]),(0,b.useEffect)(()=>{let e=ie.current;if(!e)return;let t=()=>{let t=e.scrollHeight-e.scrollTop-e.clientHeight,n=e.scrollTop<se.current-2;if(se.current=e.scrollTop,!D.current&&n&&e.scrollTop<200&&g&&ee?.hasMore&&!ee.isLoadingOlder&&!le.current&&f){let t=e.scrollHeight,n=g,r=Symbol(n);le.current=!0,E.current=r,f(n).then(()=>{HJ({requestedSessionId:n,activeSessionId:Ze.getState().currentSessionId,requestToken:r,activeRequestToken:E.current})&&requestAnimationFrame(()=>{if(!HJ({requestedSessionId:n,activeSessionId:Ze.getState().currentSessionId,requestToken:r,activeRequestToken:E.current}))return;let e=ie.current;if(!e)return;let i=e.scrollHeight-t;e.scrollTop+=i,se.current=e.scrollTop})}).finally(()=>{E.current===r&&(E.current=null,le.current=!1)})}if(ce.current&&n){oe.current=!0,ae.current=!1;return}if(oe.current){let e=t<=12;oe.current=!e,ae.current=e;return}ae.current=t<96};return t(),e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[ee,g,f]),(0,b.useEffect)(()=>{let e=ie.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{!D.current&&!ae.current||(e.scrollTop=e.scrollHeight,se.current=e.scrollTop,e.dispatchEvent(new Event(`scroll`)))});return t.observe(e),e.firstElementChild instanceof HTMLElement&&t.observe(e.firstElementChild),()=>t.disconnect()},[g]),(0,b.useEffect)(()=>{let e=ie.current;if(e){if(h.length>0&&D.current){let e=Ze.getState().currentSessionId,t=ie.current,n=t?t.style.scrollBehavior:``;t&&(t.style.scrollBehavior=`auto`,t.scrollTop=t.scrollHeight,se.current=t.scrollTop);let r=0,i=t?.scrollHeight??-1,a=!1,o=0,s=()=>{let e=ie.current;e&&(e.scrollTop=e.scrollHeight,se.current=e.scrollTop,e.dispatchEvent(new Event(`scroll`)))},c=()=>{a||(a=!0,s(),t&&(t.style.scrollBehavior=n),ae.current=!0,oe.current=!1,D.current=!1)},l=()=>{if(a)return;if(Ze.getState().currentSessionId!==e){a=!0;return}let t=ie.current;if(t){if(t.scrollHeight!==i)i=t.scrollHeight,s(),r=0;else if(r+=1,r>=3){c();return}o=requestAnimationFrame(l)}},u=window.setTimeout(c,2e3);return o=requestAnimationFrame(l),()=>{if(cancelAnimationFrame(o),window.clearTimeout(u),Ze.getState().currentSessionId!==e){c();return}t&&(t.style.scrollBehavior=n)}}ae.current&&(e.scrollTop=e.scrollHeight,se.current=e.scrollTop)}},[h,v]),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(EJ,{emptyState:t,agentName:e,isMobile:n,isStreaming:v,activity:y,contextIndicator:fe,messages:h,isLoadingInitialHistory:te,onDeleteFeedback:r,onOpenAttachmentPreview:e=>{w.getState().setPreviewAttachment(e),w.getState().setPreviewImageSize(null)},onRespondToApproval:a,onRespondToAguiApproval:o,interactionRecords:p,onScrollToBottom:pe,onSubmitFeedback:i,onSubmitAguiAction:s,onStopGeneration:c,onCancelRemote:l,checkpoints:u?x:[],onResumeCheckpoint:d,scrollRef:ie,className:m}),(0,U.jsx)(LJ,{attachment:T,isMobile:n,previewImageSize:re,onClose:()=>{w.getState().setPreviewAttachment(null),w.getState().setPreviewImageSize(null)},onImageLoad:e=>w.getState().setPreviewImageSize(e)})]})}function WJ({indicator:e,onCompact:t,disabled:n}){let r=(0,b.useRef)(null),[i,a]=(0,b.useState)(!1),o=(0,b.useRef)(!1);(0,b.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,b.useState)(!1),[l,u]=(0,b.useState)(``),d=Math.max(0,Math.min(100,e.percent??0)),f=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,U.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,U.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,U.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,U.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`,fill:`none`,stroke:`var(--ksadk-menu-border, #b8bcb5)`,strokeWidth:`2`}),e.percent!==void 0&&(0,U.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,pathLength:`100`,strokeDasharray:`${d} 100`,transform:`rotate(-90 8 8)`})]})}),(0,U.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,U.jsx)(`p`,{className:K(`font-medium`,s&&`waiting-thinking-text`),children:s?`正在压缩上下文…`:e.label}),(0,U.jsxs)(`p`,{className:`mt-1 text-text-secondary`,children:[e.usedTokens===void 0?`等待运行时报告用量`:`${GJ(e.usedTokens)} tokens`,e.usedTokens!==void 0&&e.contextWindowTokens?` / ${GJ(e.contextWindowTokens)}`:``]}),e.contextWindowTokens&&(0,U.jsxs)(`p`,{className:`mt-1 text-text-muted`,children:[`模型窗口:`,GJ(e.contextWindowTokens),` tokens`,e.contextWindowSource===`model`?`(模型配置)`:`(运行时报告)`]}),e.usedTokens!==void 0&&!e.contextWindowTokens&&(0,U.jsx)(`p`,{className:`mt-1 text-text-muted`,children:`模型窗口大小未报告`}),e.percent!==void 0&&(0,U.jsxs)(`p`,{className:`text-text-muted`,children:[e.percent,`% 已使用`]}),i&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`button`,{type:`button`,onClick:()=>void f(),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,U.jsx)(`p`,{className:`mt-2 text-xs text-text-muted`,children:n?`请等待当前运行结束`:t?`压缩模型上下文,保留聊天记录`:`当前会话尚不支持手动压缩`}),l&&(0,U.jsx)(`p`,{role:`status`,className:`mt-2 text-xs`,children:l})]})]})]})}function GJ(e){return new Intl.NumberFormat(`zh-CN`).format(e)}var KJ=[{value:`plan`,label:`计划模式`,description:`先分析并形成可执行计划`,icon:ON},{value:`goal`,label:`设定目标`,description:`朝可验证的停止条件持续推进`,icon:QN}],qJ={plan:`计划模式`,goal:`目标`};function JJ({attachmentsEnabled:e,mode:t,support:n,onSelectMode:r,onUpload:i}){let[a,o]=(0,b.useState)(!1),s=(0,b.useRef)(null),c=KJ.filter(e=>n[e.value]);return(0,b.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,U.jsxs)(`div`,{ref:s,className:`relative flex min-w-0 items-center gap-1`,children:[(0,U.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,U.jsx)(HN,{className:`h-[19px] w-[19px]`})}),t?(0,U.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":`当前执行模式:${qJ[t]}`,children:[(0,U.jsx)(`span`,{className:`truncate`,children:qJ[t]}),(0,U.jsx)(uN,{className:`h-3.5 w-3.5 shrink-0`})]}):null,a?(0,U.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,U.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,U.jsx)(nP,{className:`h-4 w-4 shrink-0 text-text-muted`}),(0,U.jsx)(`span`,{className:`shrink-0 text-[13px] font-medium text-text-primary`,children:`上传附件`}),(0,U.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,U.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,U.jsx)(n,{className:`h-4 w-4 shrink-0 text-text-muted`}),(0,U.jsx)(`span`,{className:`shrink-0 text-[13px] font-medium text-text-primary`,children:e.label}),(0,U.jsx)(`span`,{className:`ml-auto truncate text-[11px] text-text-muted`,children:e.description}),i?(0,U.jsx)(lN,{className:`h-4 w-4 shrink-0 text-text-primary`}):null]},e.value)})]}):null]})}var YJ=[{value:`auto`,label:`自动`},{value:`enabled`,label:`开启`},{value:`disabled`,label:`关闭`}],XJ={auto:`自动`,enabled:`开启`,disabled:`关闭`};function ZJ({availableModels:e,selectedModel:t,thinkingEnabled:n,thinkingMode:r,onSelectModel:i,onSelectThinkingMode:a}){let[o,s]=(0,b.useState)(!1),c=(0,b.useRef)(null),l=e.find(e=>e.id===t)?.display_name||t||`选择模型`;return(0,b.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,U.jsxs)(`div`,{ref:c,className:`relative`,children:[(0,U.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},推理 ${XJ[r]}`:`模型 ${l}`,title:n?`选择模型与推理设置`:`选择模型`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:l}),n?(0,U.jsx)(`span`,{className:`shrink-0 text-text-muted`,children:XJ[r]}):null,(0,U.jsx)(uN,{className:K(`h-3.5 w-3.5 shrink-0 text-text-muted transition-transform`,o&&`rotate-180`)})]}),o?(0,U.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,U.jsx)(`div`,{className:`px-2.5 pb-1.5 pt-1 text-[11px] font-medium text-text-muted`,children:`模型`}),(0,U.jsx)(`div`,{className:`max-h-[min(45vh,18rem)] overflow-y-auto`,children:e.map(e=>{let n=e.id===t;return(0,U.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,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.display_name||e.id}),n?(0,U.jsx)(lN,{className:`h-4 w-4 shrink-0`,"aria-hidden":`true`}):null]},e.id)})}),n?(0,U.jsx)(`div`,{className:`mt-1 border-t border-border px-1 pt-1.5`,children:(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-1.5 pb-1`,children:[(0,U.jsx)(`span`,{className:`text-[11px] font-medium text-text-muted`,children:`推理`}),(0,U.jsx)(`div`,{className:`flex rounded-lg bg-muted p-0.5`,children:YJ.map(e=>(0,U.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 QJ=[{value:`ask`,label:`请求批准`,description:`Agent 请求授权时确认`,icon:EN},{value:`risk`,label:`风险操作需确认`,description:`仅副作用操作`,icon:JN},{value:`full`,label:`完全访问`,description:`不再确认`,icon:qN}],$J={ask:`请求批准`,risk:`风险确认`,full:`完全访问`};function eY({approvalPolicy:e}){let[t,n]=(0,b.useState)(!1),r=(0,b.useRef)(null),i=ke(e=>e.permissionMode),a=ke(e=>e.setPermissionMode),o=i===`ask`?EN:i===`full`?qN:JN,s=(0,b.useMemo)(()=>QJ.filter(t=>!e||e.Modes.includes(t.value)),[e]);return(0,b.useEffect)(()=>{s.some(e=>e.value===i)||a(e?.DefaultMode||s[0]?.value||`risk`)},[e?.DefaultMode,i,a,s]),(0,b.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,U.jsxs)(`div`,{ref:r,className:`relative`,children:[(0,U.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,U.jsx)(o,{className:`h-3.5 w-3.5`}),(0,U.jsx)(`span`,{children:$J[i]}),(0,U.jsx)(uN,{className:K(`h-3.5 w-3.5 transition-transform`,t&&`rotate-180`)})]}),t?(0,U.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,U.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,U.jsx)(t,{className:K(`h-4 w-4 shrink-0`,r?`text-primary`:`text-text-muted`)}),(0,U.jsx)(`span`,{className:K(`shrink-0 text-[13px] font-medium`,r?`text-text-primary`:`text-text-secondary`),children:e.label}),(0,U.jsx)(`span`,{className:`ml-auto truncate text-[11px] text-text-muted`,children:e.description}),r?(0,U.jsx)(lN,{className:`h-4 w-4 shrink-0 text-primary`,"aria-hidden":`true`}):null]},e.value)})}):null]})}function tY({onCompactContext:e,attachments:t,composerContextIndicator:n,composerMaxHeight:r,fileInputRef:i,input:a,isMobile:o,isStreaming:s,attachmentsEnabled:c=!0,approvalEnabled:l=!1,approvalPolicy:u,thinkingEnabled:d=!1,executionMode:f,executionModeSupport:p,queuedDrafts:m,onAppendAttachments:h,onInputChange:g,onSelectExecutionMode:_,onPaste:v,onRemoveAttachment:y,onStopGeneration:x,onCancelRemote:ee,onSubmit:te,textareaRef:S,className:C}){let[ne,w]=(0,b.useState)(!1),T=e?async()=>{w(!0);try{await e()}finally{w(!1)}}:void 0,re=f===`goal`?`描述需要持续完成的目标…`:f===`plan`?`描述需要先规划的任务…`:o?`发送消息...`:`发送消息…`,ie=ee?`保留恢复点并结束本次执行`:`停止生成`,ae=f===`goal`?!!a.trim():!!(a.trim()||t.length>0),oe=Te(e=>e.availableModels),se=Te(e=>e.selectedModel),ce=Te(e=>e.thinkingMode),le=Te(e=>e.setSelectedModel),E=Te(e=>e.setThinkingMode),D=e=>e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`;return(0,U.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`,C),"data-slot":`composer`,children:(0,U.jsxs)(`div`,{className:`mx-auto w-full max-w-[64rem]`,children:[ne&&(0,U.jsxs)(`div`,{role:`status`,className:`mb-3 flex items-center gap-2 px-2 text-sm text-text-muted`,children:[(0,U.jsx)(wN,{size:16,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`waiting-thinking-text`,children:`正在压缩上下文`})]}),m.length>0?(0,U.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,U.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between gap-2`,children:[(0,U.jsxs)(`span`,{className:`font-semibold`,children:[`发送队列 · `,m.length]}),(0,U.jsx)(`span`,{className:`text-neutral-700/75 dark:text-neutral-200/75`,children:`当前回复完成后依次发送`})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[m.slice(0,3).map((e,t)=>{let n=e.text.trim()||(e.attachments.length>0?`仅附件消息`:`空消息`);return(0,U.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-background/70 px-2 py-1.5`,children:[(0,U.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,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-text-secondary`,children:n}),e.attachments.length>0?(0,U.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}`)}),m.length>3?(0,U.jsxs)(`div`,{className:`px-2 pt-0.5 text-[11px] text-neutral-700/80 dark:text-neutral-200/80`,children:[`还有 `,m.length-3,` 条等待发送`]}):null]})]}):null,(0,U.jsx)(`div`,{className:`relative rounded-[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,U.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,U.jsxs)(`form`,{onSubmit:e=>{if(e.preventDefault(),ne)return;if(s){ee?ee():x();return}let n=a.trim();ae&&te(n,t)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:e=>{e.preventDefault(),e.stopPropagation(),c&&e.dataTransfer.files&&e.dataTransfer.files.length>0&&h(Array.from(e.dataTransfer.files))},className:`relative flex min-h-[116px] min-w-0 flex-1 flex-col rounded-[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:[t.length>0?(0,U.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-2`,children:t.map((e,t)=>(0,U.jsxs)(`div`,{className:K(`group relative flex items-center gap-2 rounded-xl border border-border bg-background px-3 py-2 text-xs`,o?`max-w-full`:`max-w-[14rem]`),children:[(0,U.jsx)(`span`,{className:`flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-lg bg-muted text-text-muted`,children:(0,U.jsx)(RN,{className:`h-3.5 w-3.5`})}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`block truncate font-medium text-text-primary`,children:e.name}),(0,U.jsx)(`span`,{className:`block text-[10px] text-text-muted`,children:D(e.size)})]}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>y(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,U.jsx)(`span`,{className:`text-[11px] leading-none`,children:`×`})})]},`${e.name}-${e.size}-${t}`))}):null,(0,U.jsx)(`textarea`,{ref:S,rows:1,value:a,onChange:g,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},onPaste:v,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`,o?`text-[16px]`:`text-[14px]`),style:{maxHeight:`${r}px`,overflowY:`auto`}}),(0,U.jsxs)(`div`,{className:`mt-auto flex min-h-8 items-center justify-between gap-2 pt-1.5`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,U.jsx)(`input`,{ref:i,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&e.target.files.length>0&&(h(Array.from(e.target.files)),e.target.value=``)}}),(0,U.jsx)(JJ,{attachmentsEnabled:c,mode:f,support:p,onSelectMode:_,onUpload:()=>i.current?.click()}),l?(0,U.jsx)(eY,{approvalPolicy:u}):null]}),(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[n?(0,U.jsx)(WJ,{indicator:n,onCompact:T,disabled:s}):null,oe.length>0?(0,U.jsx)(ZJ,{availableModels:oe,selectedModel:se,thinkingEnabled:d,thinkingMode:ce,onSelectModel:le,onSelectThinkingMode:E}):null,(0,U.jsx)(`button`,{type:`submit`,disabled:ne||!s&&!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`,s||ae?`bg-[#1f1f1f] text-white hover:opacity-80`:`bg-muted text-text-muted/45`),title:s?ie:`发送消息`,children:s?(0,U.jsx)(ZN,{className:`h-3.5 w-3.5 fill-current`}):(0,U.jsx)(sN,{className:`h-[18px] w-[18px]`})})]})]})]})})})]})})}function nY(e){return[e.name,e.size,e.lastModified,e.type].join(`:`)}function rY(e,t){let n=new Map;for(let t of e)n.set(nY(t),t);for(let e of t)n.set(nY(e),e);return Array.from(n.values())}function iY(e){return Array.from(e.clipboardData.items||[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>!!e)}function aY({onCompactContext:e,composerMaxHeight:t,submitDraft:n,stopGeneration:r,cancelRemote:i,isMobile:a,attachmentsEnabled:o=!0,approvalEnabled:s=!1,approvalPolicy:c,thinkingEnabled:l=!1,runtimeCapabilityMatrix:u,pendingInteractions:d,onRespondInteraction:f,localCatalog:p,className:m}){let[h,g]=(0,b.useState)(0),[_,v]=(0,b.useState)(),y=w(e=>e.input),x=w(e=>e.attachments),ee=Ze(e=>e.currentSessionId),te=O(e=>!!(e.getSessionActivity(ee)&&e.isSessionStreaming(ee))),S=w(e=>e.queuedDrafts),C=qc(e=>e.messages),ne=Ze(e=>e.sessions.find(e=>e.SessionId===ee)?.ContextUsage),T=Te(e=>e.availableModels),re=Te(e=>e.selectedModel),ie=Te(e=>e.setThinkingMode),ae=(0,b.useRef)(null),oe=(0,b.useRef)(null),se=(0,b.useMemo)(()=>T.find(e=>e.id===re)||null,[T,re]),ce=(0,b.useMemo)(()=>VJ({messages:C,draftInput:y,selectedModel:se,contextUsage:ne}),[y,C,se,ne]),le=(0,b.useMemo)(()=>({plan:!!u?.plan?.supported,goal:!!u?.goal?.supported}),[u]),E=_&&le[_]?_:void 0,D=(0,b.useCallback)((e,t)=>{!e&&t.length===0||(w.getState().setInput(``),w.getState().setAttachments([]),n(e,t,void 0,void 0,E),E===`goal`&&v(void 0))},[E,n]);(0,b.useEffect)(()=>{oe.current&&(oe.current.style.height=`auto`,oe.current.style.height=`${Math.min(oe.current.scrollHeight,t)}px`)},[y,t]);let ue=e=>{w.getState().setInput(e.target.value),e.target.style.height=`auto`,e.target.style.height=`${Math.min(e.target.scrollHeight,t)}px`},de=e=>{!o||!e.length||w.getState().setAttachments(t=>rY(t,e))},fe=e=>{if(!o)return;let t=iY(e);t.length&&(e.preventDefault(),e.stopPropagation(),de(t))},pe=d||[],me=Math.min(h,Math.max(pe.length-1,0));return(0,b.useEffect)(()=>{l||ie(`auto`)},[ie,l]),(0,U.jsxs)(`div`,{className:`flex w-full flex-col justify-center`,children:[pe.length>0&&f?(0,U.jsx)(Wq,{interactions:pe,activeIndex:me,onSelectIndex:g,onRespond:f,localCatalog:p}):null,(0,U.jsx)(tY,{onCompactContext:ee?e:void 0,attachments:x,composerContextIndicator:ce,composerMaxHeight:t,fileInputRef:ae,input:y,isMobile:a,isStreaming:te,attachmentsEnabled:o,approvalEnabled:s,approvalPolicy:c,thinkingEnabled:l,executionMode:E,executionModeSupport:le,queuedDrafts:S,onAppendAttachments:de,onInputChange:ue,onSelectExecutionMode:v,onPaste:fe,onRemoveAttachment:e=>w.getState().setAttachments(t=>t.filter((t,n)=>n!==e)),onStopGeneration:r,onCancelRemote:i,onSubmit:D,textareaRef:oe,className:m},ee||`new-session`)]})}var oY=(0,b.lazy)(()=>J(()=>import(`./NativeTerminalPanel-D4469o8R.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function sY({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,U.jsx)(`select`,{value:t,onChange:e=>n(e.target.value),className:u,children:e.map(e=>(0,U.jsx)(`option`,{value:e.id,children:e.display_name||e.id},e.id))}):r?(0,U.jsx)(`span`,{className:K(u,`inline-flex max-w-full items-center`,l?`justify-start`:``),title:a||r,children:(0,U.jsx)(`span`,{className:`truncate`,children:r})}):(0,U.jsx)(`span`,{className:`text-sm text-slate-400`,children:i?`未配置模型`:`Loading models...`}),f=o?(0,U.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),className:K(u,l?``:`max-w-[9rem]`),title:`控制模型 thinking/reasoning 参数`,children:[(0,U.jsx)(`option`,{value:`auto`,children:`思考自动`}),(0,U.jsx)(`option`,{value:`enabled`,children:`开启思考`}),(0,U.jsx)(`option`,{value:`disabled`,children:`关闭思考`})]}):null;return(0,U.jsxs)(`div`,{className:K(`flex min-w-0 gap-2`,l?`w-full flex-col`:`items-center`),children:[d,f]})}function cY({agentName:e,currentSessionId:t,isMobile:n,sidebarOpen:r,mobileSidebarOpen:i,onToggleSidebar:a,availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m,mobileActionsOpen:h,onMobileActionsOpenChange:g,workspaceEnabled:_,onOpenWorkspace:v,nativeManagementLink:y,nativeTerminal:x,nativeLauncherMode:ee=!1}){let[te,S]=(0,b.useState)(!1),C=!!x?.Enabled,ne=n?i?(0,U.jsx)(IN,{className:`h-5 w-5`}):(0,U.jsx)(LN,{className:`h-5 w-5`}):r?(0,U.jsx)(IN,{className:`h-5 w-5`}):(0,U.jsx)(LN,{className:`h-5 w-5`});return(0,U.jsxs)(U.Fragment,{children:[(0,U.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,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[ee?null:(0,U.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:ne}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100 sm:text-base`,children:e}),(0,U.jsx)(`div`,{className:`text-[11px] text-slate-400 dark:text-slate-500`,children:ee?`原生运行时入口`:`智能体`})]})]}),n?(0,U.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,U.jsx)(yN,{className:`h-5 w-5`})}):(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[y?(0,U.jsxs)(`a`,{href:y.href,target:`_blank`,rel:`noreferrer`,title:y.title,className:`inline-flex flex-shrink-0 items-center gap-1.5 whitespace-nowrap rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm font-medium leading-none text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,U.jsx)(bN,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{children:y.label})]}):null,_?(0,U.jsxs)(`button`,{type:`button`,onClick:v,className:`inline-flex flex-shrink-0 items-center gap-1.5 whitespace-nowrap rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm font-medium leading-none text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,U.jsx)(TN,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{children:`Workspace`})]}):null,C?(0,U.jsxs)(`button`,{type:`button`,onClick:()=>S(!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,U.jsx)(XN,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{children:`TUI`})]}):null,!ee&&n?(0,U.jsx)(sY,{availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m,compact:!0}):null,!ee&&t?(0,U.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,U.jsx)(JR,{open:h,onOpenChange:g,children:(0,U.jsxs)(XR,{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,U.jsxs)(ZR,{className:`text-left`,children:[(0,U.jsx)(QR,{children:`会话设置`}),(0,U.jsx)($R,{className:`sr-only`,children:`调整当前会话的模型和 Workspace 操作。`})]}),(0,U.jsxs)(`div`,{className:`mt-6 flex flex-col gap-4`,children:[_?(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{g(!1),v()},className:`inline-flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm font-medium text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,U.jsx)(TN,{className:`h-4 w-4`}),`工作区文件`]}):null,C?(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{g(!1),S(!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,U.jsx)(XN,{className:`h-4 w-4`}),`原生 TUI`]}):null,y?(0,U.jsxs)(`a`,{href:y.href,target:`_blank`,rel:`noreferrer`,title:y.title,onClick:()=>g(!1),className:`inline-flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm font-medium text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,U.jsx)(bN,{className:`h-4 w-4`}),y.label]}):null,ee?(0,U.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,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-slate-400 dark:text-slate-500`,children:`模型`}),(0,U.jsx)(sY,{availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m,compact:!0})]}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-slate-400 dark:text-slate-500`,children:`当前会话`}),(0,U.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,U.jsx)(`span`,{className:`break-all font-mono`,children:t}):`新对话尚未创建会话 ID`})]})]})]})]})}):null,x&&te?(0,U.jsx)(b.Suspense,{fallback:null,children:(0,U.jsx)(oY,{capability:x,open:te,sessionId:t,onClose:()=>S(!1)})}):null]})}var lY=(0,b.lazy)(()=>J(()=>import(`./NativeTerminalPanel-D4469o8R.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function uY({productLabel:e=`原生运行时`,nativeManagementLink:t,nativeTerminal:n,workspaceEnabled:r,onOpenWorkspace:i}){let a=!!n?.Enabled,[o,s]=(0,b.useState)(!1);return(0,U.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,U.jsx)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col justify-center`,children:(0,U.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,U.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,U.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,U.jsx)(JN,{className:`h-3.5 w-3.5`}),e,` native runtime`]}),(0,U.jsx)(`h1`,{className:`mt-5 text-2xl font-semibold tracking-tight text-slate-950 dark:text-slate-50 sm:text-3xl`,children:`对话请使用原生管理台`}),(0,U.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,U.jsxs)(`div`,{className:`grid gap-4 p-6 md:grid-cols-3 sm:p-8`,children:[(0,U.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,U.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,U.jsx)(NN,{className:`h-5 w-5`})}),(0,U.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`原生管理台`}),(0,U.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`使用原生管理台处理对话、工具卡片、思考流、审批、中断和运行时历史,避免跨状态机不一致。`}),t?(0,U.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,U.jsx)(bN,{className:`h-4 w-4`}),`打开`,t.label]}):(0,U.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,U.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,U.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,U.jsx)(TN,{className:`h-5 w-5`})}),(0,U.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`Workspace 文件管理`}),(0,U.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`文件浏览、上传、预览仍由 Hosted UI 提供,和原生管理台组合使用覆盖对话与工作区。`}),r?(0,U.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,U.jsx)(TN,{className:`h-4 w-4`}),`打开 Workspace`]}):(0,U.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,U.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,U.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,U.jsx)(XN,{className:`h-5 w-5`})}),(0,U.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`原生 TUI`}),(0,U.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`如果运行时暴露安全的 ks-terminal.v1 通道,可以在这里进入原生终端 UI;share 链接不会开放该入口。`}),a?(0,U.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,U.jsx)(XN,{className:`h-4 w-4`}),`打开 TUI`]}):(0,U.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,U.jsx)(b.Suspense,{fallback:null,children:(0,U.jsx)(lY,{capability:n,open:o,onClose:()=>s(!1)})}):null]})}var dY=[],fY=[];(()=>{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?fY:dY).push(n+=e[t])})();function pY(e){if(e<768)return!1;for(let t=0,n=dY.length;;){let r=t+n>>1;if(e<dY[r])n=r;else if(e>=fY[r])t=r+1;else return!0;if(t==n)return!1}}function mY(e){return e>=127462&&e<=127487}var hY=8205;function gY(e,t,n=!0,r=!0){return(n?_Y:vY)(e,t,r)}function _Y(e,t,n){if(t==e.length)return t;t&&bY(e.charCodeAt(t))&&xY(e.charCodeAt(t-1))&&t--;let r=yY(e,t);for(t+=SY(r);t<e.length;){let i=yY(e,t);if(r==hY||i==hY||n&&pY(i))t+=SY(i),r=i;else if(mY(i)){let n=0,r=t-2;for(;r>=0&&mY(yY(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function vY(e,t,n){for(;t>0;){let r=_Y(e,t-2,n);if(r<t)return r;t--}return 0}function yY(e,t){let n=e.charCodeAt(t);if(!xY(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return bY(r)?(n-55296<<10)+(r-56320)+65536:n}function bY(e){return e>=56320&&e<57344}function xY(e){return e>=55296&&e<56320}function SY(e){return e<65536?1:2}var CY=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]=NY(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),TY.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]=NY(this,e,t);let n=[];return this.decompose(e,t,n,0),TY.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 kY(this),i=new kY(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 kY(this,e)}iterRange(e,t=this.length){return new AY(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 jY(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 wY(t):TY.from(wY.split(t,[]))}},wY=class e extends CY{constructor(e,t=EY(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 MY(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(OY(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=DY(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]=NY(this,t,n);let i=DY(this.text,DY(r.text,OY(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):TY.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
|
|
201
201
|
`){[e,t]=NY(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}},TY=class e extends CY{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]=NY(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]=NY(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 wY(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 wY&&c&&(n=u[u.length-1])instanceof wY&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new wY(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)}};CY.empty=new wY([``],0);function EY(e){let t=-1;for(let n of e)t+=n.length+1;return t}function DY(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 OY(e,t,n){return DY(e,[``],t,n)}var kY=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 wY?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 wY?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 wY){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 wY?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)}},AY=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new kY(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!=``}},jY=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`&&(CY.prototype[Symbol.iterator]=function(){return this.iter()},kY.prototype[Symbol.iterator]=AY.prototype[Symbol.iterator]=jY.prototype[Symbol.iterator]=function(){return this});var MY=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 NY(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function PY(e,t,n=!0,r=!0){return gY(e,t,n,r)}function FY(e){return e>=56320&&e<57344}function IY(e){return e>=55296&&e<56320}function LY(e,t){let n=e.charCodeAt(t);if(!IY(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return FY(r)?(n-55296<<10)+(r-56320)+65536:n}function RY(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function zY(e){return e<65536?1:2}var BY=/\r\n?|\n/,VY=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(VY||={}),HY=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){KY(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:JY(this,e)}mapDesc(e,t=!1){return e.empty?this:qY(this,e,t)}mapPos(e,t=-1,n=VY.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!=VY.Simple&&c>=e&&(n==VY.TrackDel&&r<e&&c>e||n==VY.TrackBefore&&r<e||n==VY.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)}},UY=class e extends HY{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 KY(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return qY(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(CY.empty);r.push(a?t.slice(i,i+a):CY.empty)}i+=a}return new e(n,r)}compose(e){return this.empty?e:e.empty?this:JY(this,e,!0)}map(e,t=!1){return e.empty?this:qY(this,e,t,!0)}iterChanges(e,t=!1){KY(this,e,t)}get desc(){return HY.create(this.sections)}filter(t){let n=[],r=[],i=[],a=new YY(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);WY(i,e,-1);let t=a.ins==-1?-1:a.off==0?a.ins:0;WY(n,e,t),t>0&&GY(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);WY(n,e,-1),WY(i,e,a.ins==-1?-1:a.off==0?a.ins:0),a.forward(e),o+=e}}return{changes:new e(n,r),filtered:HY.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&&WY(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`?CY.of(l.split(r||BY)):l:CY.empty,d=u.length;if(e==s&&d==0)return;e<o&&c(),e>o&&WY(i,e-o,-1),WY(i,s-e,d),GY(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(CY.empty);r[e]=CY.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 WY(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 GY(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(CY.empty);e.push(n)}}function KY(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=CY.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 qY(e,t,n,r=!1){let i=[],a=r?[]:null,o=new YY(e),s=new YY(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);WY(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(WY(i,s.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(WY(i,0,o.ins),a&&GY(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;WY(i,t,e<o.i?o.ins:0),a&&e<o.i&&GY(a,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&s.done)return a?UY.createSet(i,a):HY.create(i);else throw Error(`Mismatched change set lengths`)}function JY(e,t,n=!1){let r=[],i=n?[]:null,a=new YY(e),o=new YY(t);for(let e=!1;;)if(a.done&&o.done)return i?UY.createSet(r,i):HY.create(r);else if(a.ins==0)WY(r,a.len,0,e),a.next();else if(o.len==0&&!o.done)WY(r,0,o.ins,e),i&&GY(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;WY(r,t,n,e),i&&n&&GY(i,r,o.text)}else o.ins==-1?(WY(r,a.off?0:a.len,t,e),i&&GY(i,r,a.textBit(t))):(WY(r,a.off?0:a.len,o.off?0:o.ins,e),i&&!o.off&&GY(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 YY=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?CY.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?CY.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)}},XY=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=>XY.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 XY.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?XY.create(t,e,48|a):XY.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 ZY(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var QY=0,$Y=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=QY++,this.default=e([]),this.extensions=typeof i==`function`?i(this):i}get reader(){return this}static define(t={}){return new e(t.combine||(e=>e),t.compareInput||((e,t)=>e===t),t.compare||(t.combine?(e,t)=>e===t:eX),!!t.static,t.enables)}of(e){return new tX([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new tX(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new tX(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function eX(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var tX=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=QY++}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)||rX(e,c)){let r=t(e);if(a?!nX(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=gX(o,c);if(this.dependencies.every(t=>t instanceof $Y?o.facet(t)===e.facet(t):t instanceof oX?o.field(t,!1)==e.field(t,!1):!0)||(a?nX(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 nX(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 rX(e,t){let n=!1;for(let r of t)hX(e,r)&1&&(n=!0);return n}function iX(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=gX(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)hX(e,t);return e.values[o]=s(e),1},update(e,n){if(!rX(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=rX(e,r),c=i.config.facets[t.id],l=i.facet(t);if(c&&!a&&eX(n,c))return e.values[o]=l,0;let u=s(e);return t.compare(u,l)?(e.values[o]=l,0):(e.values[o]=u,1)}}}var aX=$Y.define({static:!0}),oX=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(QY++,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(aX).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(aX),i=n.facet(aX),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,aX.of({field:this,create:e})]}get extension(){return this}},sX={lowest:4,low:3,default:2,high:1,highest:0};function cX(e){return t=>new uX(t,e)}var lX={highest:cX(sX.highest),high:cX(sX.high),default:cX(sX.default),low:cX(sX.low),lowest:cX(sX.lowest)},uX=class{constructor(e,t){this.inner=e,this.prec=t}},dX=class e{of(e){return new fX(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},fX=class{constructor(e,t){this.compartment=e,this.inner=t}},pX=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 mX(t,n,o))e instanceof oX?i.push(e):(a[e.facet.id]||(a[e.facet.id]=[])).push(e);let s=Object.create(null),c=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let u=r?.config.facets;for(let e in a){let t=a[e],n=t[0].facet,i=u&&u[e]||[];if(t.every(e=>e.type==0))if(s[n.id]=c.length<<1|1,eX(i,t))c.push(r.facet(n));else{let e=n.combine(t.map(e=>e.value));c.push(r&&n.compare(e,r.facet(n))?r.facet(n):e)}else{for(let e of t)e.type==0?(s[e.id]=c.length<<1|1,c.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[n.id]=l.length<<1,l.push(e=>iX(e,n,t))}}return new e(t,o,l.map(e=>e(s)),s,c,a)}};function mX(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 fX&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof fX){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 uX)a(e.inner,e.prec);else if(e instanceof oX)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof tX)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,sX.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,sX.default),r.reduce((e,t)=>e.concat(t))}function hX(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 gX(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var _X=$Y.define(),vX=$Y.define({combine:e=>e.some(e=>e),static:!0}),yX=$Y.define({combine:e=>e.length?e[0]:void 0,static:!0}),bX=$Y.define(),xX=$Y.define(),SX=$Y.define(),CX=$Y.define({combine:e=>e.length?e[0]:!1}),wX=class{constructor(e,t){this.type=e,this.value=t}static define(){return new TX}},TX=class{of(e){return new wX(this,e)}},EX=class{constructor(e){this.map=e}of(e){return new DX(this,e)}},DX=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 EX(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}};DX.reconfigure=DX.define(),DX.appendConfig=DX.define();var OX=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&&ZY(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]==`.`))}};OX.time=wX.define(),OX.userEvent=wX.define(),OX.addToHistory=wX.define(),OX.remote=wX.define();function kX(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 AX(e,t,n){let r,i,a;return n?(r=t.changes,i=UY.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:DX.mapEffects(e.effects,r).concat(DX.mapEffects(t.effects,i)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function jX(e,t,n){let r=t.selection,i=IX(t.annotations);return t.userEvent&&(i=i.concat(OX.userEvent.of(t.userEvent))),{changes:t.changes instanceof UY?t.changes:UY.of(t.changes||[],n,e.facet(yX)),selection:r&&(r instanceof Y?r:Y.single(r.anchor,r.head)),effects:IX(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function MX(e,t,n){let r=jX(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=AX(r,jX(e,t[i],a?r.changes.newLength:e.doc.length),a)}let i=OX.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return PX(n?NX(i):i)}function NX(e){let t=e.startState,n=!0;for(let r of t.facet(bX)){let t=r(e);if(t===!1){n=!1;break}Array.isArray(t)&&(n=n===!0?t:kX(n,t))}if(n!==!0){let r,i;if(n===!1)i=e.changes.invertedDesc,r=UY.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=OX.create(t,r,e.selection&&e.selection.map(i),DX.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(xX);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof OX?i:Array.isArray(i)&&i.length==1&&i[0]instanceof OX?i[0]:MX(t,IX(i),!1)}return e}function PX(e){let t=e.startState,n=t.facet(SX),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=AX(r,jX(t,a,e.changes.newLength),!0))}return r==e?e:OX.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var FX=[];function IX(e){return e==null?FX:Array.isArray(e)?e:[e]}var LX=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(LX||={}),RX=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,zX;try{zX=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function BX(e){if(zX)return zX.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>``&&(n.toUpperCase()!=n.toLowerCase()||RX.test(n)))return!0}return!1}function VX(e){return t=>{if(!/\S/.test(t))return LX.Space;if(BX(t))return LX.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return LX.Word;return LX.Other}}var HX=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++)hX(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 hX(this,n),gX(this,n)}update(...e){return MX(this,e,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let e of t.effects)e.is(dX.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(DX.reconfigure)?(n=null,r=e.value):e.is(DX.appendConfig)&&(n=null,r=IX(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=pX.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(vX)?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=IX(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=DX.mapEffects(a,c).concat(DX.mapEffects(IX(o.effects),l))}return{changes:r,selection:Y.create(i,t.mainIndex),effects:a}}changes(t=[]){return t instanceof UY?t:UY.of(t,this.doc.length,this.facet(e.lineSeparator))}toText(t){return CY.of(t.split(this.facet(e.lineSeparator)||BY))}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:(hX(this,t),gX(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 oX&&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=pX.resolve(t.extensions||[],new Map),r=t.doc instanceof CY?t.doc:CY.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||BY)),i=t.selection?t.selection instanceof Y?t.selection:Y.single(t.selection.anchor,t.selection.head):Y.single(0);return ZY(i,r.length),n.staticFacet(vX)||(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((LZ.mac||LZ.android)&&u.from==a-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute(`autocorrect`)==`off`&&(u={from:o,to:s,insert:CY.of([n.text.replace(`.`,` `)])}),this.pendingContextChange=u,!e.state.readOnly){let t=this.to-this.from+(u.to-u.from+u.insert.length);L1(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(KZ.mark({attributes:{style:e}}).range(i,a))}}}e.dispatch({effects:l$.of(KZ.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=eQ(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])}},S2=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||bQ(e.parent)||document,this.viewState=new Z0(this,e.state||HX.create(e)),e.scrollTo&&e.scrollTo.is(c$)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(p$).map(e=>new h$(e));for(let e of this.plugins)e.update(this);this.observer=new _2(this),this.inputState=new U1(this),this.inputState.ensureHandlers(this.plugins),this.docView=new r1(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 OX?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(x0))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,c=S0(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(HX.phrases)!=this.state.facet(HX.phrases))return this.setState(a);i=O$.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 s$(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(c$)&&(d=e.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=T2.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(E$)!=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(s2)!=i.state.facet(s2)&&(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($Q))try{e(i)}catch(e){u$(this.state,e,`update listener`)}(c||u)&&Promise.resolve().then(()=>{c&&this.state==c.startState&&this.dispatch(c),u&&!I1(this,u)&&l.force&&yQ(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 Z0(this,e),this.plugins=e.facet(p$).map(e=>new h$(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new r1(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(p$),n=e.state.facet(p$);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new h$(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){u$(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(SQ(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 u$(this.state,e),w2}}),l=O$.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]!=w2)try{let t=s[e];t.write&&t.write(c[e],this)}catch(e){u$(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($Q))e(t)}get themeClasses(){return l2+` `+(this.state.facet(c2)?d2:u2)+` `+this.state.facet(s2)}updateAttrs(){let e=E2(this,g$,{class:`cm-editor`+(this.hasFocus?` cm-focused `:` `)+this.themeClasses}),t={spellcheck:`false`,autocorrect:`off`,autocapitalize:`off`,writingsuggestions:`false`,translate:`no`,contenteditable:this.state.facet(d$)?`true`:`false`,class:`cm-content`,style:`${LZ.tabSize}: ${this.state.tabSize}`,role:`textbox`,"aria-multiline":`true`};this.state.readOnly&&(t[`aria-readonly`]=`true`),E2(this,_$,t);let n=this.observer.ignore(()=>{let n=HZ(this.contentDOM,this.contentAttrs,t),r=HZ(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(E$);let t=this.state.facet(e.cspNonce);mZ.mount(this.root,this.styleModules.concat(m2).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 T1(this,e,b1(this,e,t,n))}moveByGroup(e,t){return T1(this,e,b1(this,e,t,t=>x1(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 y1(this,e,t,n)}moveVertically(e,t,n){return T1(this,e,S1(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=D1(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),D1(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[IQ.find(i,e-r.from,-1,t)];return lQ(n,a.dir==EQ.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(i$)||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>C2)return GQ(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||LQ(r.isolates,n=C$(this,e))))return r.order;n||=C$(this,e);let r=WQ(e.text,t,n);return this.bidiCache.push(new T2(e.from,e.to,t,n,!0,r)),r}get hasFocus(){return(this.dom.ownerDocument.hasFocus()||LZ.safari&&this.inputState?.lastContextMenu>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{gQ(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 c$.of(new s$(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 c$.of(new s$(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 m$.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return m$.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=mZ.newName(),r=[s2.of(n),E$.of(p2(`.${n}`,e))];return t&&t.dark&&r.push(c2.of(!0)),r}static baseTheme(e){return lX.lowest(E$.of(p2(`.`+l2,e,f2)))}static findFromDOM(e){let t=e.querySelector(`.cm-content`);return(t&&A$.get(t)||A$.get(e))?.root?.view||null}};S2.styleModule=E$,S2.inputHandler=e$,S2.clipboardInputFilter=n$,S2.clipboardOutputFilter=r$,S2.scrollHandler=o$,S2.focusChangeEffect=t$,S2.perLineTextDirection=i$,S2.exceptionSink=QQ,S2.updateListener=$Q,S2.editable=d$,S2.mouseSelectionStyle=ZQ,S2.dragMovesSelection=XQ,S2.clickAddsSelectionRange=YQ,S2.decorations=v$,S2.blockWrappers=y$,S2.outerDecorations=b$,S2.atomicRanges=x$,S2.bidiIsolatedRanges=S$,S2.cursorScrollMargin=$Y.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}}}),S2.scrollMargins=w$,S2.darkTheme=c2,S2.cspNonce=$Y.define({combine:e=>e.length?e[0]:``}),S2.contentAttributes=_$,S2.editorAttributes=g$,S2.lineWrapping=S2.contentAttributes.of({class:`cm-lineWrapping`}),S2.announce=DX.define();var C2=4096,w2={},T2=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:EQ.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 E2(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&&RZ(a,n)}return n}var D2=LZ.mac?`mac`:LZ.windows?`win`:LZ.linux?`linux`:`key`;function O2(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 k2(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 A2=lX.default(S2.domEventHandlers({keydown(e,t){return z2(N2(t.state),e,t,`editor`)}})),j2=$Y.define({enables:A2}),M2=new WeakMap;function N2(e){let t=e.facet(j2),n=M2.get(t);return n||M2.set(t,n=L2(t.reduce((e,t)=>e.concat(t),[]))),n}function P2(e,t,n){return z2(N2(e.state),t,e,n)}var F2=null,I2=4e3;function L2(e,t=D2){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=>O2(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=F2={view:t,prefix:n,scope:e};return setTimeout(()=>{F2==r&&(F2=null)},I2),!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,R2))}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 R2=null;function z2(e,t,n,r){R2=t;let i=CZ(t),a=zY(LY(i,0))==i.length&&i!=` `,o=``,s=!1,c=!1,l=!1;F2&&F2.view==n&&F2.scope==r&&(o=F2.prefix+` `,J1.indexOf(t.keyCode)<0&&(c=!0,F2=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+k2(i,t,!a)])?s=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(LZ.windows&&t.ctrlKey&&t.altKey)&&!(LZ.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=_Z[t.keyCode])&&p!=i?(d(f[o+k2(p,t,!0)])||t.shiftKey&&(m=vZ[t.keyCode])!=i&&m!=p&&d(f[o+k2(m,t,!1)]))&&(s=!0):a&&t.shiftKey&&d(f[o+k2(i,t,!0)])&&(s=!0),!s&&d(f._any)&&(s=!0)),c&&(s=!0),s&&l&&t.stopPropagation(),R2=null,s}var B2=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=V2(t);return[new e(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}else return U2(t,n,r)}};function V2(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==EQ.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function H2(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 U2(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==EQ.LTR,o=e.contentDOM,s=o.getBoundingClientRect(),c=V2(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=v1(e,r,1),m=v1(e,i,-1),h=p.type==GZ.Text?p:null,g=m.type==GZ.Text?m:null;if(h&&(e.lineWrapping||p.widgetLineBreaks)&&(h=H2(e,r,1,h)),g&&(e.lineWrapping||m.widgetLineBreaks)&&(g=H2(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==GZ.Text&&(t.bottom=r.top=(t.bottom+r.top)/2),v(t).concat(i).concat(v(r))}function _(e,n,r,i){return new B2(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==EQ.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 W2(e,t){return e.constructor==t.constructor&&e.eq(t)}var G2=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(K2)!=e.state.facet(K2)&&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(K2);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)=>!W2(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,LZ.webkit&&(this.dom.style.display=this.dom.firstChild?``:`none`)}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},K2=$Y.define();function q2(e){return[m$.define(t=>new G2(t,e)),K2.of(e)]}var J2=$Y.define({combine(e){return UX(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function Y2(e={}){return[J2.of(e),Z2,$2,e4,a$.of(!0)]}function X2(e){return e.startState.facet(J2)!=e.state.facet(J2)}var Z2=q2({above:!0,markers(e){let{state:t}=e,n=t.facet(J2),r=[];for(let i of t.selection.ranges){let a=i==t.selection.main;if(i.empty||n.drawRangeCursor&&!(a&&LZ.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 B2.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=X2(e);return n&&Q2(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){Q2(t.state,e)},class:`cm-cursorLayer`});function Q2(e,t){t.style.animationDuration=e.facet(J2).cursorBlinkRate+`ms`}var $2=q2({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 B2.forRange(e,`cm-selectionBackground`,n))t.push(r);if(LZ.ios&&!n.empty&&e.state.facet(J2).iosSelectionHandles){for(let r of B2.forRange(e,`cm-selectionHandle cm-selectionHandle-start`,Y.cursor(n.from,1)))t.push(r);for(let r of B2.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||X2(e)},class:`cm-selectionLayer`}),e4=lX.highest(S2.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`}}}})),t4=DX.define({map(e,t){return e==null?null:t.mapPos(e)}}),n4=oX.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((e,t)=>t.is(t4)?t.value:e,e)}}),r4=m$.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(n4);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(n4)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(n4),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(n4)!=e&&this.view.dispatch({effects:t4.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 i4(){return[n4,r4]}/x/.unicode;function a4(){return s4}var o4=KZ.line({class:`cm-activeLine`}),s4=m$.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(o4.range(i.from)),t=i.from)}return KZ.set(n)}},{decorations:e=>e.decorations}),c4=2e3;function l4(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),a=[];if(t.off>c4||n.off>c4||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=lZ(n.text,o,e.tabSize,!0);if(r<0)a.push(Y.cursor(n.to));else{let t=lZ(n.text,s,e.tabSize);a.push(Y.range(n.from+r,n.from+t))}}}return a}function u4(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function d4(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>c4?-1:i==r.length?u4(e,t.clientX):cZ(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:a,off:i}}function f4(e,t){let n=d4(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=d4(e,t);if(!o)return r;let s=l4(e.state,n,o);return s.length?a?Y.create(s.concat(r.ranges)):Y.create(s):r}}:null}function p4(e){let t=e?.eventFilter||(e=>e.altKey&&e.button==0);return S2.mouseSelectionStyle.of((e,n)=>t(n)?f4(e,n):null)}var m4={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},h4={style:`cursor: crosshair`};function g4(e={}){let[t,n]=m4[e.key||`Alt`],r=m$.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,S2.contentAttributes.of(e=>e.plugin(r)?.isDown?h4:null)]}var _4=`-10000px`,v4=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 y4(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}var b4=$Y.define({combine:e=>({position:LZ.ios?`absolute`:e.find(e=>e.position)?.position||`fixed`,parent:e.find(e=>e.parent)?.parent||null,tooltipSpace:e.find(e=>e.tooltipSpace)?.tooltipSpace||y4})}),x4=new WeakMap,S4=m$.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(b4);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 v4(e,E4,(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(b4);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=_4,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(LZ.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=T$(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(b4).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=_4;continue}let f=s.arrow?c.dom.querySelector(`.cm-tooltip-arrow`):null,p=f?7:0,m=d.right-d.left,h=x4.get(c)??d.bottom-d.top,g=c.offset||T4,_=this.view.textDirection==EQ.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=_4;continue}x4.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,ee=v+m;if(c.overlap!==!0)for(let e of a)e.left<ee&&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`,C4(l,(v-e.parent.left)/r)):(l.style.top=x/i+`px`,C4(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:ee,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=_4}},{eventObservers:{scroll(){this.maybeMeasure()}}});function C4(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+`px`)}var w4=S2.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`}}}),T4={x:0,y:0},E4=$Y.define({enables:[S4,w4]});function D4(e,t){let n=e.plugin(S4);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}var O4=$Y.define({combine(e){let t,n;for(let r of e)t||=r.topContainer,n||=r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function k4(e,t){let n=e.plugin(A4),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}var A4=m$.fromClass(class{constructor(e){this.input=e.state.facet(N4),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(O4);this.top=new j4(e,!0,t.topContainer),this.bottom=new j4(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(O4);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new j4(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new j4(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(N4);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=>S2.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})}),j4=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=M4(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=M4(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 M4(e){let t=e.nextSibling;return e.remove(),t}var N4=$Y.define({enables:A4});function P4(e,t){let n,r=new Promise(e=>n=e),i=e=>R4(e,t,n);e.state.field(F4,!1)?e.dispatch({effects:I4.of(i)}):e.dispatch({effects:DX.appendConfig.of(F4.init(()=>[i]))});let a=L4.of(i);return{close:a,result:r.then(t=>((e.win.queueMicrotask||(t=>e.win.setTimeout(t,10)))(()=>{e.state.field(F4).indexOf(i)>-1&&e.dispatch({effects:a})}),t))}}var F4=oX.define({create(){return[]},update(e,t){for(let n of t.effects)n.is(I4)?e=[n.value].concat(e):n.is(L4)&&(e=e.filter(e=>e!=n.value));return e},provide:e=>N4.computeN([e],t=>t.field(e))}),I4=DX.define(),L4=DX.define();function R4(e,t,n){let r=t.content?t.content(e,()=>o(null)):null;if(!r){if(r=wZ(`form`),t.input){let e=wZ(`input`,t.input);/^(text|password|number|email|tel|url)$/.test(e.type)&&e.classList.add(`cm-textfield`),e.name||=`input`,r.appendChild(wZ(`label`,(t.label||``)+`: `,e))}else r.appendChild(document.createTextNode(t.label||``));r.appendChild(document.createTextNode(` `)),r.appendChild(wZ(`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=wZ(`div`,r,wZ(`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 z4=class extends WX{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};z4.prototype.elementClass=``,z4.prototype.toDOM=void 0,z4.prototype.mapMode=VY.TrackBefore,z4.prototype.startSide=z4.prototype.endSide=-1,z4.prototype.point=!0;var B4=$Y.define(),V4=$Y.define(),H4={class:``,renderEmptyElements:!1,elementStyle:``,markers:()=>YX.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:`before`},U4=$Y.define();function W4(e){return[K4(),U4.of({...H4,...e})]}var G4=$Y.define({combine:e=>e.some(e=>e)});function K4(e){let t=[q4];return e&&e.fixed===!1&&t.push(G4.of(!0)),t}var q4=m$.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(U4).map(t=>new Z4(e,t)),this.fixed=!e.state.facet(G4);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(G4)!=!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=YX.iter(this.view.state.facet(B4),this.view.viewport.from),r=[],i=this.gutters.map(e=>new X4(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==GZ.Text&&t){Y4(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==GZ.Text){Y4(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(U4),n=e.state.facet(U4),r=e.docChanged||e.heightChanged||e.viewportChanged||!YX.eq(e.startState.facet(B4),e.state.facet(B4),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 Z4(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=>S2.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==EQ.LTR?{left:r,right:i}:{right:r,left:i}})});function J4(e){return Array.isArray(e)?e:[e]}function Y4(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}var X4=class{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=YX.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 Q4(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=[];Y4(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(V4)){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()}}},Z4=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=J4(t.markers(e)),t.initialSpacer&&(this.spacer=new Q4(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=J4(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!YX.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()}},Q4=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`:``),$4(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 $4(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 e3=$Y.define(),t3=$Y.define(),n3=$Y.define({combine(e){return UX(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}})}}),r3=class extends z4{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function i3(e,t){return e.state.facet(n3).formatNumber(t,e.state)}var a3=U4.compute([n3],e=>({class:`cm-lineNumbers`,renderEmptyElements:!1,markers(e){return e.state.facet(e3)},lineMarker(e,t,n){return n.some(e=>e.toDOM)?null:new r3(i3(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let r of e.state.facet(t3)){let i=r(e,t,n);if(i)return i}return null},lineMarkerChange:e=>e.startState.facet(n3)!=e.state.facet(n3),initialSpacer(e){return new r3(i3(e,s3(e.state.doc.lines)))},updateSpacer(e,t){let n=i3(t.view,s3(t.view.state.doc.lines));return n==e.number?e:new r3(n)},domEventHandlers:e.facet(n3).domEventHandlers,side:`before`}));function o3(e={}){return[n3.of(e),K4(),a3]}function s3(e){let t=9;for(;t<e;)t=t*10+9;return t}var c3=new class extends z4{constructor(){super(...arguments),this.elementClass=`cm-activeLineGutter`}},l3=B4.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(c3.range(i)))}return YX.of(t)});function u3(){return l3}var d3=1024,f3=0,p3=class{constructor(e,t){this.from=e,this.to=t}},m3=class{constructor(e={}){this.id=f3++,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=_3.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};m3.closedBy=new m3({deserialize:e=>e.split(` `)}),m3.openedBy=new m3({deserialize:e=>e.split(` `)}),m3.group=new m3({deserialize:e=>e.split(` `)}),m3.isolate=new m3({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),m3.contextHash=new m3({perNode:!0}),m3.lookAhead=new m3({perNode:!0}),m3.mounted=new m3({perNode:!0});var h3=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[m3.mounted.id]}},g3=Object.create(null),_3=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):g3,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(m3.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(m3.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};_3.none=new _3(``,Object.create(null),0,8);var v3=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 _3(e.name,r,e.id,e.flags):e)}return new e(n)}},y3=new WeakMap,b3=new WeakMap,x3;(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`})(x3||={});var S3=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=h3.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 I3(this.topNode,e)}cursorAt(e,t=0,n=0){let r=new I3(y3.get(this)||this.topNode);return r.moveTo(e,t),y3.set(this,r._tree),r}get topNode(){return new O3(this,0,0,null)}resolve(e,t=0){let n=E3(y3.get(this)||this.topNode,e,t,!1);return y3.set(this,n),n}resolveInner(e,t=0){let n=E3(b3.get(this)||this.topNode,e,t,!0);return b3.set(this,n),n}resolveStack(e,t=0){return F3(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,a=e.mode||0,o=(a&x3.IncludeAnonymous)>0;for(let e=this.cursor(a|x3.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:V3(_3.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(_3.none,t,n,r)))}static build(e){return R3(e)}};S3.empty=new S3(_3.none,[],[],0);var C3=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)}},w3=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return _3.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&&!(T3(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 T3(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 E3(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 O3&&e.index<0?null:e.parent;if(!t)return e;e=t}let i=r?0:x3.IgnoreOverlays;if(r)for(let r=e,a=r.parent;a;r=a,a=r.parent)r instanceof O3&&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 D3=class{cursor(e=0){return new I3(this,e)}getChild(e,t=null,n=null){let r=k3(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return k3(this,e,t,n)}resolve(e,t=0){return E3(this,e,t,!1)}resolveInner(e,t=0){return E3(this,e,t,!0)}matchContext(e){return A3(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}},O3=class e extends D3{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&x3.EnterBracketed&&l instanceof S3&&(d=h3.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length)&&!T3(i,r,u,u+l.length))){if(l instanceof w3){if(a&x3.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new M3(new j3(o,l,t,u),null,e)}else if(a&x3.IncludeAnonymous||!l.type.isAnonymous||L3(l)){let s;if(!(a&x3.IgnoreMounts)&&(s=h3.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&x3.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&x3.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&x3.IgnoreOverlays)&&(i=h3.get(this._tree))&&i.overlay){let a=t-this.from,o=r&x3.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 k3(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 A3(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 j3=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},M3=class e extends D3{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&x3.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 S3(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function N3(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 O3&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new P3(i,n)}var P3=class{constructor(e,t){this.heads=e,this.node=t}get next(){return N3(this.heads)}};function F3(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof O3?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=h3.get(e.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new O3(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(E3(o,t,n,!1))}}return i?N3(i):r}var I3=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&~x3.EnterBracketed,e instanceof O3)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 O3?(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&x3.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&x3.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&x3.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&x3.IncludeAnonymous||e instanceof w3||!e.type.isAnonymous||L3(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 M3(this.buffer,t,this.stack[e]);return this.bufferNode=new M3(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 A3(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 A3(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 L3(e){return e.children.some(e=>e instanceof w3||!e.type.isAnonymous||L3(e))}function R3(e){let{buffer:t,nodeSet:n,maxBufferLength:r=d3,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new C3(t,t.length):t,s=n.types,c=0,l=0;function u(e,t,_,v,y,b){let{id:x,start:ee,end:te,size:S}=o,C=l,ne=c;if(S<0)if(o.next(),S==-1){let t=i[x];_.push(t),v.push(ee-e);return}else if(S==-3){c=x;return}else if(S==-4){l=x;return}else throw RangeError(`Unrecognized record size: ${S}`);let w=s[x],T,re,ie=ee-e;if(te-ee<=r&&(re=h(o.pos-t,y))){let t=new Uint16Array(re.size-re.skip),r=o.pos-re.size,i=t.length;for(;o.pos>r;)i=g(re.start,t,i);T=new w3(t,te-re.start,n),ie=re.start-e}else{let e=o.pos-S;o.next();let t=[],n=[],i=x>=a?x:-1,s=0,c=te;for(;o.pos>e;)i>=0&&o.id==i&&o.size>=0?(o.end<=c-r&&(p(t,n,ee,s,o.end,c,i,C,ne),s=t.length,c=o.end),o.next()):b>2500?d(ee,e,t,n):u(ee,e,t,n,i,b+1);if(i>=0&&s>0&&s<t.length&&p(t,n,ee,s,ee,c,i,C,ne),t.reverse(),n.reverse(),i>-1&&s>0){let e=f(w,ne);T=V3(w,t,n,0,t.length,0,te-ee,e,e)}else T=m(w,t,n,te-ee,C-te,ne)}_.push(T),v.push(ie)}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 w3(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 S3){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(m3.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=[m3.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[m3.lookAhead,i];o=o?[e].concat(o):[e]}return new S3(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 S3(s[e.topID],_.reverse(),v.reverse(),y)}var z3=new WeakMap;function B3(e,t){if(!e.isAnonymous||t instanceof w3||t.type!=e)return 1;let n=z3.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof S3)){n=1;break}n+=B3(e,r)}z3.set(t,n)}return n}function V3(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n<i;n++)l+=B3(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=B3(e,t[s]);for(s++;s<i;s++){let n=B3(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(V3(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 H3=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 M3?this.setBuffer(e.context.buffer,e.index,t):e instanceof O3&&this.map.set(e.tree,t)}get(e){return e instanceof M3?this.getBuffer(e.context.buffer,e.index):e instanceof O3?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)}},U3=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}},W3=class{startParse(e,t,n){return typeof e==`string`&&(e=new G3(e)),n=n?n.length?n.map(e=>new p3(e.from,e.to)):[new p3(0,0)]:[new p3(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}}},G3=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 K3(e){return(t,n,r,i)=>new Z3(t,e,n,r,i)}var q3=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 J3(e){if(!e.length||e.some(e=>e.from>=e.to))throw RangeError(`Invalid inner parse ranges given: `+JSON.stringify(e))}var Y3=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=[]}},X3=new m3({perNode:!0}),Z3=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 S3(e.type,e.children,e.positions,e.length,e.propValues.concat([[X3,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[m3.mounted.id]=new h3(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 n6(this.fragments),t=null,n=null,r=new I3(new O3(this.baseTree,this.ranges[0].from,0,null),x3.IncludeAnonymous|x3.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=Q3(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||(e6(r),t&&t.depth++,n&&n.depth++);let a=e.findMounts(r.from,i.parser);if(typeof i.overlay==`function`)t=new Y3(i.parser,i.overlay,a,this.inner.length,r.from,!!i.bracketed,r.tree,t);else{let e=r6(this.ranges,i.overlay||(r.from<r.to?[new p3(r.from,r.to)]:[]));e.length&&J3(e),(e.length||!i.overlay)&&this.inner.push(new q3(i.parser,e.length?i.parser.startParse(this.input,a6(a,e),e):i.parser.startParse(``),i.overlay?i.overlay.map(e=>new p3(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 p3(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=r6(this.ranges,t.ranges);e.length&&(J3(e),this.inner.splice(t.index,0,new q3(t.parser,t.parser.startParse(this.input,a6(t.mounts,e),e),t.ranges.map(e=>new p3(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 Q3(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 $3(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 e6(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=[];$3(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),$3(o,s[f+3],r,p,m,a),new S3(i,p,m,u)}i.children[a]=l(0,s.length,_3.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 O3(n,r+e.from,t,e._tree))}}var t6=class{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(x3.IncludeAnonymous|x3.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,x3.IgnoreOverlays|x3.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 S3)t=t.children[0];else break}return!1}},n6=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(X3)??t.to,this.inner=new t6(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(X3)??e.to,this.inner=new t6(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(m3.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 r6(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 p3(e.from,o),e.to>s&&n.splice(a+1,0,new p3(s,e.to))):e.to>s?n[a--]=new p3(s,e.to):n.splice(a--,1))}}return r}function i6(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 p3(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 a6(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=i6(t,i.overlay.map(e=>new p3(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 U3(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 U3(s,c,i.tree,-e,a.from>=e||a.openStart,a.to<=o||a.openEnd))}return n}var o6=0,s6=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=o6++}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 l6(e);return e=>e.modified.indexOf(t)>-1?e:l6.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},c6=0,l6=class e{constructor(e){this.name=e,this.instances=[],this.id=c6++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&u6(n,e.modified));if(r)return r;let i=[],a=new s6(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=d6(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 u6(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function d6(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 f6(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 m6(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return p6.add(t)}var p6=new m3({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 m6(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),m6=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}};m6.empty=new m6([],2,null);function h6(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 g6(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+` `+e:e)}return n}function _6(e,t,n,r=0,i=e.length){let a=new v6(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,``,a.highlighters),a.flush(i)}var v6=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=y6(e)||m6.empty,u=g6(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(m3.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 y6(e){let t=e.type.prop(p6);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var X=s6.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:s6.defineModifier(`definition`),constant:s6.defineModifier(`constant`),function:s6.defineModifier(`function`),standard:s6.defineModifier(`standard`),local:s6.defineModifier(`local`),special:s6.defineModifier(`special`)};for(let e in Z){let t=Z[e];t instanceof s6&&(t.name=e)}h6([{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 m3;function F6(e){return $Y.define({combine:e?t=>t.concat(e):void 0})}var I6=new m3,L6=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,HX.prototype.hasOwnProperty(`tree`)||Object.defineProperty(HX.prototype,"tree",{get(){return z6(this)}}),this.parser=t,this.extension=[K6.of(this),HX.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(m3.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 S3&&r(i,e.positions[n]+t)}};return r(z6(e),0),n}get allowsNesting(){return!0}};L6.setState=DX.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,x3.ExcludeBuffers|x3.EnterBracketed))e.type.isTop&&(i=e);return i}var Mie=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:S3.empty}var Nie=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,[],S3.empty,0,r,[],null)}startParse(){return this.parser.startParse(new Nie(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=S3.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(U3.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(U3.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=U3.applyChanges(r,e),i=S3.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 W3{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 S3(_3.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 U3.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=oX.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,Pie=m$.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=>u$(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=$Y.define({combine(e){return e.length?e[0]:null},enables:e=>[L6.state,Pie,S2.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}},Fie=$Y.define(),J6=$Y.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 HX&&(e=new Q6(e));for(let n of e.state.facet(Fie)){let r=n(e,t);if(r!==void 0)return r}let n=z6(e.state);return n.length>=t?Iie(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 cZ(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 m3;function Iie(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=Rie(r.node);if(e)return e(Bie.create(t,n,r))}return 0}function Lie(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function Rie(e){let t=e.type.prop($6);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(m3.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>t8(e,!0,1,void 0,n&&!Lie(e)?t.from:void 0)}return e.parent==null?zie:null}function zie(){return 0}var Bie=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(Vie(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 Vie(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function Hie(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 Uie({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?Hie(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}var Wie=e=>e.baseIndent;function Gie({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var Kie=200;function qie(){return HX.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+Kie)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=$Y.define(),r8=new m3;function Jie(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 Yie(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||!Xie(i))){let r=s(i,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(a=r)}}return a}function Xie(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 Yie(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=DX.define({map:a8}),s8=DX.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=oX.define({create(){return KZ.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)&&!Zie(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(m8),i=r?KZ.replace({widget:new nae(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=>S2.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 KZ.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 Zie(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(DX.appendConfig.of(h8()))}var Qie=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},$ie=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 S2.announce.of(`${e.state.phrase(n?`Folded lines`:`Unfolded lines`)} ${r} ${e.state.phrase(`to`)} ${i}.`)}var eae=[{key:`Ctrl-Shift-[`,mac:`Cmd-Alt-[`,run:Qie},{key:`Ctrl-Shift-]`,mac:`Cmd-Alt-]`,run:$ie},{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}}],tae={placeholderDOM:null,preparePlaceholder:null,placeholderText:`…`},m8=$Y.define({combine(e){return UX(e,tae)}});function h8(e){let t=[l8,aae];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=KZ.replace({widget:new class extends WZ{toDOM(e){return g8(e,null)}}}),nae=class extends WZ{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return g8(e,this.value)}},rae={openText:`⌄`,closedText:`›`,markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},v8=class extends z4{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 iae(e={}){let t={...rae,...e},n=new v8(t,!0),r=new v8(t,!1),i=m$.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 ZX;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,W4({class:`cm-foldGutter`,markers(e){return e.plugin(i)?.markers||YX.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 aae=S2.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=mZ.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=h6(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new mZ(n):null,this.themeType=t.themeType}static define(t,n){return new e(t,n||{})}},b8=$Y.define(),x8=$Y.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=[sae],r;return e instanceof y8&&(e.module&&n.push(S2.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(x8.of(e)):r?n.push(b8.computeN([S2.darkTheme],t=>t.facet(S2.darkTheme)==(r==`dark`)?[e]:[])):n.push(b8.of(e)),n}var oae=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 KZ.none;let n=new ZX;for(let{from:r,to:i}of e.visibleRanges)_6(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=KZ.mark({class:r})))},r,i);return n.finish()}},sae=lX.high(m$.fromClass(oae,{decorations:e=>e.decorations})),cae=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`}]),lae=S2.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:`#328c8252`},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bb555544`}}),w8=1e4,T8=`()[]{}`,E8=$Y.define({combine(e){return UX(e,{afterCursor:!0,brackets:T8,maxScanDistance:w8,renderMatch:fae})}}),uae=KZ.mark({class:`cm-matchingBracket`}),dae=KZ.mark({class:`cm-nonmatchingBracket`});function fae(e){let t=[],n=e.matched?uae:dae;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 KZ.set(t,!0)}var pae=[m$.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}),lae];function mae(e={}){return[E8.of(e),pae]}var O8=new m3;function k8(e,t,n){let r=e.prop(t<0?m3.openedBy:m3.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 hae(e,t,n,r,o,i,a)}}return gae(e,t,n,o,s.type,i,a)}function hae(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 gae(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 _ae(e){return{name:e.name||``,token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||vae,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||R8,mergeTokens:e.mergeTokens!==!1}}function vae(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,yae=class e extends L6{constructor(e){let t=F6(e.languageData),n=_ae(e),r,i=new class extends W3{createParse(e,t,n){return new xae(r,e,t,n)}};super(t,i,[],e.name),this.topNode=wae(t,this),r=this,this.streamParser=n,this.stateAfter=new m3({perNode:!0}),this.tokenTable=e.tokenTable?new U8(n.tokenTable):Cae}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 S3&&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 S3){if(!(c=I8(e,s,n-o,r-o,i)))break;return i?new S3(t.type,t.children.slice(0,a).concat(c),t.positions.slice(0,a+1),o+c.length):c}}return null}function bae(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:S3.empty}}var xae=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}=bae(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=S3.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:Sae,topID:0,maxBufferLength:512,reused:this.chunkReused});e=new S3(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 S3(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=[_3.none],Sae=new v3(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}},Cae=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]=_3.define({id:z8.length,name:r,props:[f6({[r]:n})]});return z8.push(o),o.id}function wae(e,t){let n=_3.define({id:z8.length,name:`Document`,props:[P6.add(()=>e),$6.add(()=>e=>t.getIndent(e))],top:!0});return z8.push(n),n}EQ.RTL,EQ.LTR;var Tae=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=q8(e.state,n.from);return r.line?Eae(e):r.block?Oae(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 Eae=K8(jae,0),Dae=K8(Y8,0),Oae=K8((e,t)=>Y8(e,t,Aae(t)),0);function q8(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var J8=50;function kae(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 Aae(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)=>kae(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 jae(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=wX.define(),Mae=wX.define(),Nae=$Y.define(),Z8=$Y.define({combine(e){return UX(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=oX.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(Mae);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(OX.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=n5.fromTransaction(t),o=t.annotation(OX.time),s=t.annotation(OX.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 Pae(e={}){return[Q8,Z8.of(e),S2.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),Fae=$8(0,!0),Iae=$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&&UY.fromJSON(t.changes),[],t.mapped&&HY.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(Nae)){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 Lae(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 Rae(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=[],zae=200;function o5(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-zae));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 Bae(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=Vae(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 Vae(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,DX.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var Hae=/^(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||Hae.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,Lae(s.changes,t.changes))||r==`input.type.compose`)?r5(o,o.length-1,i.minDepth,new n5(t.changes.compose(s.changes),i5(DX.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)&&Rae(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:Bae(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 Uae=[{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:Fae,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:Iae,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)==EQ.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 Wae=e=>_5(e,!m5(e)),Gae=e=>_5(e,m5(e));typeof Intl<`u`&&Intl.Segmenter;function Kae(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?m3.closedBy:m3.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;Kae(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 qae=e=>d5(e,t=>v5(e.state,t,!m5(e))),Jae=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(S2.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=S2.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 Yae=e=>d5(e,t=>E5(e,t,!0)),Xae=e=>d5(e,t=>E5(e,t,!1)),Zae=e=>d5(e,t=>E5(e,t,!m5(e))),Qae=e=>d5(e,t=>E5(e,t,m5(e))),$ae=e=>d5(e,t=>Y.cursor(e.lineBlockAt(t.head).from,1)),eoe=e=>d5(e,t=>Y.cursor(e.lineBlockAt(t.head).to,-1));function toe(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 noe=({state:e,dispatch:t})=>toe(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 roe=e=>j5(e,!m5(e)),ioe=e=>j5(e,m5(e)),aoe=e=>D5(e,t=>v5(e.state,t,!m5(e))),ooe=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),soe=e=>D5(e,t=>E5(e,t,!0)),coe=e=>D5(e,t=>E5(e,t,!1)),loe=e=>D5(e,t=>E5(e,t,!m5(e))),uoe=e=>D5(e,t=>E5(e,t,m5(e))),doe=e=>D5(e,t=>Y.cursor(e.lineBlockAt(t.head).from)),foe=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),moe=({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},hoe=({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 goe=e=>H5(e,!1),_oe=e=>H5(e,!0),voe=({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`?S2.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function W5(e,t,n){if(e instanceof S2)for(let r of e.state.facet(S2.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=cZ(s,a.tabSize)%Y6(a)||Y6(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=PY(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=PY(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=PY(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),yoe=e=>J5(e,!0),boe=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)}),xoe=e=>U5(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),Soe=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)}),Coe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:CY.of([``,``])},range:Y.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},woe=({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:PY(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:PY(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 Toe=({state:e,dispatch:t})=>Z5(e,t,!1),Eoe=({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 Doe=({state:e,dispatch:t})=>Q5(e,t,!1),Ooe=({state:e,dispatch:t})=>Q5(e,t,!0),koe=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 Aoe(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(m3.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),joe=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&&Aoe(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??=cZ(/^\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:CY.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 Moe=({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=cZ(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),Noe=e=>(e.setTabFocusMode(),!0),Poe=[{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:$ae,shift:doe},{key:`Ctrl-e`,run:eoe,shift:foe},{key:`Ctrl-d`,run:q5},{key:`Ctrl-h`,run:K5},{key:`Ctrl-k`,run:boe},{key:`Ctrl-Alt-h`,run:Y5},{key:`Ctrl-o`,run:Coe},{key:`Ctrl-t`,run:woe},{key:`Ctrl-v`,run:T5}],Foe=[{key:`ArrowLeft`,run:h5,shift:k5,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:Wae,shift:roe,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:Zae,shift:loe,preventDefault:!0},{key:`ArrowRight`,run:g5,shift:A5,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:Gae,shift:ioe,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:Qae,shift:uoe,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:Xae,shift:coe,preventDefault:!0},{key:`Mod-Home`,run:R5,shift:B5},{key:`End`,run:Yae,shift:soe,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:yoe,preventDefault:!0},{mac:`Mod-Backspace`,run:xoe,preventDefault:!0},{mac:`Mod-Delete`,run:Soe,preventDefault:!0}].concat(Poe.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),Ioe=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:qae,shift:aoe},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:Jae,shift:ooe},{key:`Alt-ArrowUp`,run:Toe},{key:`Shift-Alt-ArrowUp`,run:Doe},{key:`Alt-ArrowDown`,run:Eoe},{key:`Shift-Alt-ArrowDown`,run:Ooe},{key:`Mod-Alt-ArrowUp`,run:goe},{key:`Mod-Alt-ArrowDown`,run:_oe},{key:`Escape`,run:voe},{key:`Mod-Enter`,run:joe},{key:`Alt-l`,mac:`Ctrl-l`,run:moe},{key:`Mod-i`,run:hoe,preventDefault:!0},{key:`Mod-[`,run:r7},{key:`Mod-]`,run:n7},{key:`Mod-Alt-\\`,run:Moe},{key:`Shift-Mod-k`,run:koe},{key:`Shift-Mod-\\`,run:noe},{key:`Mod-/`,run:Tae},{key:`Alt-A`,run:Dae},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:Noe}].concat(Foe),Loe={key:`Tab`,run:n7,shift:r7},Roe=`#e5c07b`,i7=`#e06c75`,zoe=`#56b6c2`,Boe=`#ffffff`,a7=`#abb2bf`,o7=`#7d8799`,Voe=`#61afef`,Hoe=`#98c379`,s7=`#d19a66`,Uoe=`#c678dd`,Woe=`#21252b`,c7=`#2c313a`,l7=`#282c34`,u7=`#353a42`,Goe=`#3E4451`,d7=`#528bff`,f7=[S2.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:Goe},".cm-panels":{backgroundColor:Woe,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:Uoe},{tag:[Z.name,Z.deleted,Z.character,Z.propertyName,Z.macroName],color:i7},{tag:[Z.function(Z.variableName),Z.labelName],color:Voe},{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:Roe},{tag:[Z.operator,Z.operatorKeyword,Z.url,Z.escape,Z.regexp,Z.link,Z.special(Z.string)],color:zoe},{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:Hoe},{tag:Z.invalid,color:Boe}]))],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 LY(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=RY(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=zY(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 Koe(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 qoe=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=P4(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,S2.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},Joe={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},S7=$Y.define({combine(e){return UX(e,Joe,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Yoe(e){let t=[ese,$oe];return e&&t.push(S7.of(e)),t}var Xoe=KZ.mark({class:`cm-selectionMatch`}),Zoe=KZ.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function C7(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=LX.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=LX.Word)}function Qoe(e,t,n,r){return e(t.sliceDoc(n,n+1))==LX.Word&&e(t.sliceDoc(r-1,r))==LX.Word}var $oe=m$.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 KZ.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return KZ.none;let e=n.wordAt(i.head);if(!e)return KZ.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 KZ.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(C7(o,n,i.from,i.to)&&Qoe(o,n,i.from,i.to)))return KZ.none}else if(a=n.sliceDoc(i.from,i.to),!a)return KZ.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(Zoe.range(r,a)):(r>=i.to||a<=i.from)&&s.push(Xoe.range(r,a)),s.length>t.maxMatches))return KZ.none}}return KZ.set(s)}},{decorations:e=>e.decorations}),ese=S2.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),tse=({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 nse(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 rse=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return tse({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=nse(e,r);return i?(t(e.update({selection:e.selection.addRange(Y.range(i.from,i.to),!1),effects:S2.scrollIntoView(i.to)})),!0):!1},w7=$Y.define({combine(e){return UX(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new _se(e),scrollToMatch:e=>S2.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||Koe(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 lse(this):new ose(this)}getCursor(e,t=0,n){let r=e.doc?e:HX.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 ise(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=ase(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=ise(e.test,t,i)),new m7(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function ase(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))!=LX.Word||t(A7(i,n-a))!=LX.Word)&&(t(A7(i,r-a))!=LX.Word||t(k7(i,r-a))!=LX.Word))}var ose=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 sse(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=cse(t.charCategorizer(t.selection.main.head))),e.test&&(i=sse(e.test,t,i)),new _7(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function k7(e,t){return e.slice(PY(e,t,!1),t)}function A7(e,t){return e.slice(t,PY(e,t))}function cse(e){return(t,n,r)=>!r[0].length||(e(k7(r.input,r.index))!=LX.Word||e(A7(r.input,r.index))!=LX.Word)&&(e(A7(r.input,r.index+r[0].length))!=LX.Word||e(k7(r.input,r.index+r[0].length))!=LX.Word)}var lse=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=DX.define(),M7=DX.define(),N7=oX.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=>N4.from(e,e=>e.panel)}),P7=class{constructor(e,t){this.query=e,this.panel=t}},use=KZ.mark({class:`cm-searchMatch`}),dse=KZ.mark({class:`cm-searchMatch cm-searchMatch-selected`}),fse=m$.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 KZ.none;let{view:n}=this,r=new ZX;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?dse:use)})}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)}),mse=({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(S2.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}),hse=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:S2.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=k4(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)):DX.appendConfig.of(yse)]});return!0},W7=e=>{let t=e.state.field(N7,!1);if(!t||!t.panel)return!1;let n=k4(e,z7);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:M7.of(!1)}),!0},gse=[{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:mse},{key:`Mod-Alt-g`,run:qoe},{key:`Mod-d`,run:rse,preventDefault:!0}],_se=class{constructor(e){this.view=e;let t=this.query=e.state.field(N7).query.spec;this.commit=this.commit.bind(this),this.searchField=wZ(`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=wZ(`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=wZ(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=wZ(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=wZ(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return wZ(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=wZ(`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`)]),wZ(`label`,null,[this.caseField,G7(e,`match case`)]),wZ(`label`,null,[this.reField,G7(e,`regexp`)]),wZ(`label`,null,[this.wordField,G7(e,`by word`)]),...e.state.readOnly?[]:[wZ(`br`),this.replaceField,n(`replace`,()=>R7(e),[G7(e,`replace`)]),n(`replaceAll`,()=>hse(e),[G7(e,`replace all`)])],wZ(`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){P2(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 S2.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var vse=S2.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`}}),yse=[N7,lX.low(fse),vse],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 bse(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+$/]:bse(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function xse(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=wX.define();function Sse(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 Cse(e){if(!Array.isArray(e))return e;let t=n9.get(e);return t||n9.set(e,t=Z7(e)),t}var r9=DX.define(),i9=DX.define(),wse=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=LY(e,t),r=zY(n);this.chars.push(n);let i=e.slice(t,t+r),a=i.toUpperCase();this.folded.push(LY(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=LY(e,0),i=zY(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=LY(e,i);(a==t[c]||a==n[c])&&(r[c++]=i),i+=zY(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=LY(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=RY(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+=zY(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?zY(LY(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)}},Tse=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=$Y.define({combine(e){return UX(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:Ese,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 Ese(e,t,n,r,i,a){let o=e.textDirection==EQ.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=DX.define();function Dse(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 Ose=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=Dse(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=>u$(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&&Ase(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 kse(e,t){return n=>new Ose(n,e,t)}function Ase(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 jse(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 Tse(n):new wse(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 Mse=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=jse(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:zse,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)}},Nse=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e(Lse,`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(Cse)).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))||!Pse(i,this.active)||o?a=Mse.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?Fse:Ise}};function Pse(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 Fse={"aria-autocomplete":`list`},Ise={};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 Lse=[];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 Rse(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 Rse(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=DX.define({map(e,t){return e.map(e=>e.map(t))}}),h9=oX.define({create(){return Nse.start()},update(e,t){return e.update(t)},provide:e=>[E4.from(e,e=>e.tooltip),S2.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({...Sse(e.state,n,r.from,r.to),annotations:t9.of(t.completion)}):n(e,t.completion,r.from,r.to),!0):!1}var zse=kse(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=D4(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 Bse=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,Vse=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)},Hse=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},Use=50,Wse=1e3,Gse=m$.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>Use&&Date.now()-n.time>Wse){for(let e of n.context.abortListeners)try{e()}catch(e){u$(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 Hse(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)}),u$(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&&D4(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}}}),Kse=typeof navigator==`object`&&/Win/.test(navigator.platform),qse=lX.highest(S2.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&&!(Kse&&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=S2.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`}}}),Jse=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},Yse=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(t){let n=t.mapPos(this.from,-1,VY.TrackDel),r=t.mapPos(this.to,1,VY.TrackDel);return n==null||r==null?null:new e(this.field,n,r)}},Xse=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 Yse(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 Jse(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)}},Zse=KZ.widget({widget:new class extends WZ{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),Qse=KZ.mark({class:`cm-snippetField`}),b9=class e{constructor(e,t){this.ranges=e,this.active=t,this.deco=KZ.set(e.map(e=>(e.from==e.to?Zse:Qse).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=DX.define({map(e,t){return e&&e.map(t)}}),$se=DX.define(),S9=oX.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(x9))return n.value;if(n.is($se)&&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=>S2.decorations.from(e,e=>e?e.deco:KZ.none)});function C9(e,t){return Y.create(e.filter(e=>e.field==t).map(e=>Y.range(e.from,e.to)))}function ece(e){let t=Xse.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:CY.of(a)},scrollIntoView:!0,annotations:n?[t9.of(n),OX.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(DX.appendConfig.of([S9,nce,ice,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 tce=[{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=$Y.define({combine(e){return e.length?e[0]:tce}}),nce=lX.highest(j2.compute([T9],e=>e.facet(T9)));function rce(e,t){return{...t,apply:ece(e)}}var ice=S2.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=DX.define({map(e,t){return t.mapPos(e,-1,VY.TrackAfter)??void 0}}),O9=new class extends WX{};O9.startSide=1,O9.endSide=-1;var k9=oX.define({create(){return YX.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 ace(){return[sce,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 RY(e<128?e:e+1)}function M9(e,t){return e.languageDataAt(`closeBrackets`,t)[0]||E9}var oce=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),sce=S2.inputHandler.of((e,t,n,r)=>{if((oce?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&zY(LY(r,0))==1||t!=i.from||n!=i.to)return!1;let a=lce(e.state,r);return a?(e.dispatch(a),!0):!1}),cce=[{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=uce(e.doc,t.head);for(let i of n)if(i==r&&P9(e.doc,t.head)==j9(LY(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 lce(e,t){let n=M9(e,e.selection.main.head),r=n.brackets||E9.brackets;for(let i of r){let a=j9(LY(i,0));if(t==i)return a==i?pce(e,i,r.indexOf(i+i+i)>-1,n):dce(e,i,a,n.before||E9.before);if(t==a&&N9(e,e.selection.main.from))return fce(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,zY(LY(n,0)))}function uce(e,t){let n=e.sliceString(t-2,t);return zY(LY(n,0))==n.length?n:n.slice(1)}function dce(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 fce(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)!=LX.Word&&I9(e,o,i)>-1&&!mce(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 mce(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))!=LX.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))!=LX.Word)return n}return-1}function hce(e={}){return[qse,h9,a9.of(e),Gse,gce,y9]}var L9=[{key:`Ctrl-Space`,run:v9},{mac:"Alt-`",run:v9},{mac:`Alt-i`,run:v9},{key:`Escape`,run:Vse},{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:Bse}],gce=lX.highest(j2.computeN([a9],e=>e.facet(a9).defaultKeymap?[L9]:[]));function $(e){return new q6(yae.define(e))}function R9(e){return J(()=>import(`./dist-D0t-jg0i.js`).then(t=>t.sql({dialect:t[e]})),__vite__mapDeps([7,8]),import.meta.url)}var _ce=[Q.of({name:`C`,extensions:[`c`,`h`,`ino`],load(){return J(()=>import(`./dist-BbqgJcRm.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-BbqgJcRm.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-Bami3Hbn.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-C8E2u2Gy.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-mo17RERT.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-CsdC51-G.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-D2l4f5Dh.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-_RQDZ9v3.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-Bzd96FWg.js`).then(e=>e.json()),__vite__mapDeps([16,8]),import.meta.url)}}),Q.of({name:`JSX`,extensions:[`jsx`],load(){return J(()=>import(`./dist-D2l4f5Dh.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-vM3yu1Iv.js`).then(e=>e.less()),__vite__mapDeps([17,10,8]),import.meta.url)}}),Q.of({name:`Liquid`,extensions:[`liquid`],load(){return J(()=>import(`./dist-BoDw8sHC.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-39frJg8c.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-BDYKkv8k.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-Bo0uuYGj.js`).then(e=>e.python()),__vite__mapDeps([21,8]),import.meta.url)}}),Q.of({name:`Rust`,extensions:[`rs`],load(){return J(()=>import(`./dist-snMJ4dAH.js`).then(e=>e.rust()),__vite__mapDeps([22,8]),import.meta.url)}}),Q.of({name:`Sass`,extensions:[`sass`],load(){return J(()=>import(`./dist-C6YcRSBB.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-C6YcRSBB.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-D2l4f5Dh.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-D2l4f5Dh.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-BRFE6wml.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-7mNpnBIq.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-CgpyS7Tw.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-dLCAHoLT.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-Dbb1c9iJ.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(_ce,`file${e}`)}function V9({content:e,path:t,readOnly:n=!1,onSave:r,onDirtyChange:i,onContentChange:a,getContentRef:o}){let s=(0,b.useRef)(null),c=(0,b.useRef)(null),l=(0,b.useRef)(new dX),u=(0,b.useRef)(new dX),d=(0,b.useRef)(new dX),f=(0,b.useRef)(!1),p=(0,b.useRef)(r),m=(0,b.useRef)(i),h=(0,b.useRef)(a);(0,b.useEffect)(()=>{p.current=r,m.current=i,h.current=a},[r,i,a]);let g=(0,b.useCallback)(e=>{f.current!==e&&(f.current=e,m.current?.(e))},[]);return(0,b.useEffect)(()=>{if(!s.current)return;let r=document.documentElement.classList.contains(`dark`),i=j2.of([{key:`Mod-s`,run:e=>{let t=e.state.doc.toString();return p.current?.(t),g(!1),!0},preventDefault:!0}]),a=new S2({state:HX.create({doc:e,extensions:[o3(),u3(),Pae(),iae(),Y2(),i4(),HX.allowMultipleSelections.of(!0),qie(),C8(cae,{fallback:!0}),mae(),ace(),hce(),p4(),g4(),a4(),Yoe(),j2.of([...cce,...Ioe,...gse,...Uae,...eae,...L9,Loe]),i,S2.updateListener.of(e=>{e.docChanged&&(g(!0),h.current?.(e.state.doc.toString()))}),d.current.of(HX.readOnly.of(n)),l.current.of([]),u.current.of(r?f7:[]),S2.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,b.useEffect)(()=>{let t=c.current;if(!t)return;let n=t.state.doc.toString();n!==e&&(t.dispatch({changes:{from:0,to:n.length,insert:e}}),g(!1))},[e,g]),(0,b.useEffect)(()=>{let e=c.current;if(!e)return;let n=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,b.useEffect)(()=>{let e=c.current;e&&e.dispatch({effects:d.current.reconfigure(HX.readOnly.of(n))})},[n]),(0,b.useEffect)(()=>{let e=new MutationObserver(()=>{let e=c.current;if(!e)return;let t=document.documentElement.classList.contains(`dark`);e.dispatch({effects:u.current.reconfigure(t?f7:[])})});return e.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>e.disconnect()},[]),(0,U.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,U.jsx)(Tq,{content:e||``}):n===`image`&&t?(0,U.jsx)(`div`,{className:`flex items-center justify-center p-4`,children:(0,U.jsx)(`img`,{src:t,alt:r,className:`max-h-[70vh] max-w-full rounded object-contain`})}):n===`pdf`&&t?(0,U.jsx)(`iframe`,{src:t,title:r,className:`h-full w-full border-0`}):(n===`text`||n===`code`)&&e!==null?(0,U.jsx)(V9,{content:e,path:i||r,readOnly:!0,onSave:()=>{},onDirtyChange:()=>{},getContentRef:{current:()=>e||``}}):(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,U.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 vce(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 yce(e){let t=e?vce(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 bce(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=yce(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 lse(this):new ose(this)}getCursor(e,t=0,n){let r=e.doc?e:HX.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 ise(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=ase(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=ise(e.test,t,i)),new m7(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function ase(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))!=LX.Word||t(A7(i,n-a))!=LX.Word)&&(t(A7(i,r-a))!=LX.Word||t(k7(i,r-a))!=LX.Word))}var ose=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 sse(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=cse(t.charCategorizer(t.selection.main.head))),e.test&&(i=sse(e.test,t,i)),new _7(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function k7(e,t){return e.slice(PY(e,t,!1),t)}function A7(e,t){return e.slice(t,PY(e,t))}function cse(e){return(t,n,r)=>!r[0].length||(e(k7(r.input,r.index))!=LX.Word||e(A7(r.input,r.index))!=LX.Word)&&(e(A7(r.input,r.index+r[0].length))!=LX.Word||e(k7(r.input,r.index+r[0].length))!=LX.Word)}var lse=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=DX.define(),M7=DX.define(),N7=oX.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=>N4.from(e,e=>e.panel)}),P7=class{constructor(e,t){this.query=e,this.panel=t}},use=KZ.mark({class:`cm-searchMatch`}),dse=KZ.mark({class:`cm-searchMatch cm-searchMatch-selected`}),fse=m$.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 KZ.none;let{view:n}=this,r=new ZX;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?dse:use)})}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)}),mse=({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(S2.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}),hse=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:S2.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=k4(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)):DX.appendConfig.of(yse)]});return!0},W7=e=>{let t=e.state.field(N7,!1);if(!t||!t.panel)return!1;let n=k4(e,z7);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:M7.of(!1)}),!0},gse=[{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:mse},{key:`Mod-Alt-g`,run:qoe},{key:`Mod-d`,run:rse,preventDefault:!0}],_se=class{constructor(e){this.view=e;let t=this.query=e.state.field(N7).query.spec;this.commit=this.commit.bind(this),this.searchField=wZ(`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=wZ(`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=wZ(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=wZ(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=wZ(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return wZ(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=wZ(`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`)]),wZ(`label`,null,[this.caseField,G7(e,`match case`)]),wZ(`label`,null,[this.reField,G7(e,`regexp`)]),wZ(`label`,null,[this.wordField,G7(e,`by word`)]),...e.state.readOnly?[]:[wZ(`br`),this.replaceField,n(`replace`,()=>R7(e),[G7(e,`replace`)]),n(`replaceAll`,()=>hse(e),[G7(e,`replace all`)])],wZ(`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){P2(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 S2.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var vse=S2.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`}}),yse=[N7,lX.low(fse),vse],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 bse(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+$/]:bse(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function xse(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=wX.define();function Sse(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 Cse(e){if(!Array.isArray(e))return e;let t=n9.get(e);return t||n9.set(e,t=Z7(e)),t}var r9=DX.define(),i9=DX.define(),wse=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=LY(e,t),r=zY(n);this.chars.push(n);let i=e.slice(t,t+r),a=i.toUpperCase();this.folded.push(LY(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=LY(e,0),i=zY(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=LY(e,i);(a==t[c]||a==n[c])&&(r[c++]=i),i+=zY(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=LY(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=RY(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+=zY(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?zY(LY(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)}},Tse=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=$Y.define({combine(e){return UX(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:Ese,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 Ese(e,t,n,r,i,a){let o=e.textDirection==EQ.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=DX.define();function Dse(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 Ose=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=Dse(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=>u$(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&&Ase(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 kse(e,t){return n=>new Ose(n,e,t)}function Ase(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 jse(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 Tse(n):new wse(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 Mse=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=jse(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:zse,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)}},Nse=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e(Lse,`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(Cse)).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))||!Pse(i,this.active)||o?a=Mse.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?Fse:Ise}};function Pse(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 Fse={"aria-autocomplete":`list`},Ise={};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 Lse=[];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 Rse(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 Rse(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=DX.define({map(e,t){return e.map(e=>e.map(t))}}),h9=oX.define({create(){return Nse.start()},update(e,t){return e.update(t)},provide:e=>[E4.from(e,e=>e.tooltip),S2.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({...Sse(e.state,n,r.from,r.to),annotations:t9.of(t.completion)}):n(e,t.completion,r.from,r.to),!0):!1}var zse=kse(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=D4(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 Bse=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,Vse=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)},Hse=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},Use=50,Wse=1e3,Gse=m$.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>Use&&Date.now()-n.time>Wse){for(let e of n.context.abortListeners)try{e()}catch(e){u$(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 Hse(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)}),u$(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&&D4(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}}}),Kse=typeof navigator==`object`&&/Win/.test(navigator.platform),qse=lX.highest(S2.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&&!(Kse&&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=S2.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`}}}),Jse=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},Yse=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(t){let n=t.mapPos(this.from,-1,VY.TrackDel),r=t.mapPos(this.to,1,VY.TrackDel);return n==null||r==null?null:new e(this.field,n,r)}},Xse=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 Yse(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 Jse(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)}},Zse=KZ.widget({widget:new class extends WZ{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),Qse=KZ.mark({class:`cm-snippetField`}),b9=class e{constructor(e,t){this.ranges=e,this.active=t,this.deco=KZ.set(e.map(e=>(e.from==e.to?Zse:Qse).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=DX.define({map(e,t){return e&&e.map(t)}}),$se=DX.define(),S9=oX.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(x9))return n.value;if(n.is($se)&&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=>S2.decorations.from(e,e=>e?e.deco:KZ.none)});function C9(e,t){return Y.create(e.filter(e=>e.field==t).map(e=>Y.range(e.from,e.to)))}function ece(e){let t=Xse.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:CY.of(a)},scrollIntoView:!0,annotations:n?[t9.of(n),OX.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(DX.appendConfig.of([S9,nce,ice,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 tce=[{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=$Y.define({combine(e){return e.length?e[0]:tce}}),nce=lX.highest(j2.compute([T9],e=>e.facet(T9)));function rce(e,t){return{...t,apply:ece(e)}}var ice=S2.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=DX.define({map(e,t){return t.mapPos(e,-1,VY.TrackAfter)??void 0}}),O9=new class extends WX{};O9.startSide=1,O9.endSide=-1;var k9=oX.define({create(){return YX.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 ace(){return[sce,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 RY(e<128?e:e+1)}function M9(e,t){return e.languageDataAt(`closeBrackets`,t)[0]||E9}var oce=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),sce=S2.inputHandler.of((e,t,n,r)=>{if((oce?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&zY(LY(r,0))==1||t!=i.from||n!=i.to)return!1;let a=lce(e.state,r);return a?(e.dispatch(a),!0):!1}),cce=[{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=uce(e.doc,t.head);for(let i of n)if(i==r&&P9(e.doc,t.head)==j9(LY(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 lce(e,t){let n=M9(e,e.selection.main.head),r=n.brackets||E9.brackets;for(let i of r){let a=j9(LY(i,0));if(t==i)return a==i?pce(e,i,r.indexOf(i+i+i)>-1,n):dce(e,i,a,n.before||E9.before);if(t==a&&N9(e,e.selection.main.from))return fce(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,zY(LY(n,0)))}function uce(e,t){let n=e.sliceString(t-2,t);return zY(LY(n,0))==n.length?n:n.slice(1)}function dce(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 fce(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)!=LX.Word&&I9(e,o,i)>-1&&!mce(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 mce(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))!=LX.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))!=LX.Word)return n}return-1}function hce(e={}){return[qse,h9,a9.of(e),Gse,gce,y9]}var L9=[{key:`Ctrl-Space`,run:v9},{mac:"Alt-`",run:v9},{mac:`Alt-i`,run:v9},{key:`Escape`,run:Vse},{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:Bse}],gce=lX.highest(j2.computeN([a9],e=>e.facet(a9).defaultKeymap?[L9]:[]));function $(e){return new q6(yae.define(e))}function R9(e){return J(()=>import(`./dist-DTeQCULT.js`).then(t=>t.sql({dialect:t[e]})),__vite__mapDeps([7,8]),import.meta.url)}var _ce=[Q.of({name:`C`,extensions:[`c`,`h`,`ino`],load(){return J(()=>import(`./dist-CTRKDU8K.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-CTRKDU8K.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-BZBDMLXX.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-DLGYftqv.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-EFwlyh-J.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-D0V4p2BH.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-Dys6qb_l.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-BcF5XYGL.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-BcWjNWFB.js`).then(e=>e.json()),__vite__mapDeps([16,8]),import.meta.url)}}),Q.of({name:`JSX`,extensions:[`jsx`],load(){return J(()=>import(`./dist-Dys6qb_l.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-D-7_sx4d.js`).then(e=>e.less()),__vite__mapDeps([17,10,8]),import.meta.url)}}),Q.of({name:`Liquid`,extensions:[`liquid`],load(){return J(()=>import(`./dist-B5ACVHAD.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-CHgoCvLH.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-BuVggBmt.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-DiUlU2X0.js`).then(e=>e.python()),__vite__mapDeps([21,8]),import.meta.url)}}),Q.of({name:`Rust`,extensions:[`rs`],load(){return J(()=>import(`./dist-B8Xx9Bcu.js`).then(e=>e.rust()),__vite__mapDeps([22,8]),import.meta.url)}}),Q.of({name:`Sass`,extensions:[`sass`],load(){return J(()=>import(`./dist-C6T-wP4s.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-C6T-wP4s.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-Dys6qb_l.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-Dys6qb_l.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-C5xBbsOZ.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-DHWEsppc.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-Dguio8Hw.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-BD6pm3IK.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-DaJnfr3_.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(_ce,`file${e}`)}function V9({content:e,path:t,readOnly:n=!1,onSave:r,onDirtyChange:i,onContentChange:a,getContentRef:o}){let s=(0,b.useRef)(null),c=(0,b.useRef)(null),l=(0,b.useRef)(new dX),u=(0,b.useRef)(new dX),d=(0,b.useRef)(new dX),f=(0,b.useRef)(!1),p=(0,b.useRef)(r),m=(0,b.useRef)(i),h=(0,b.useRef)(a);(0,b.useEffect)(()=>{p.current=r,m.current=i,h.current=a},[r,i,a]);let g=(0,b.useCallback)(e=>{f.current!==e&&(f.current=e,m.current?.(e))},[]);return(0,b.useEffect)(()=>{if(!s.current)return;let r=document.documentElement.classList.contains(`dark`),i=j2.of([{key:`Mod-s`,run:e=>{let t=e.state.doc.toString();return p.current?.(t),g(!1),!0},preventDefault:!0}]),a=new S2({state:HX.create({doc:e,extensions:[o3(),u3(),Pae(),iae(),Y2(),i4(),HX.allowMultipleSelections.of(!0),qie(),C8(cae,{fallback:!0}),mae(),ace(),hce(),p4(),g4(),a4(),Yoe(),j2.of([...cce,...Ioe,...gse,...Uae,...eae,...L9,Loe]),i,S2.updateListener.of(e=>{e.docChanged&&(g(!0),h.current?.(e.state.doc.toString()))}),d.current.of(HX.readOnly.of(n)),l.current.of([]),u.current.of(r?f7:[]),S2.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,b.useEffect)(()=>{let t=c.current;if(!t)return;let n=t.state.doc.toString();n!==e&&(t.dispatch({changes:{from:0,to:n.length,insert:e}}),g(!1))},[e,g]),(0,b.useEffect)(()=>{let e=c.current;if(!e)return;let n=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,b.useEffect)(()=>{let e=c.current;e&&e.dispatch({effects:d.current.reconfigure(HX.readOnly.of(n))})},[n]),(0,b.useEffect)(()=>{let e=new MutationObserver(()=>{let e=c.current;if(!e)return;let t=document.documentElement.classList.contains(`dark`);e.dispatch({effects:u.current.reconfigure(t?f7:[])})});return e.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>e.disconnect()},[]),(0,U.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,U.jsx)(Tq,{content:e||``}):n===`image`&&t?(0,U.jsx)(`div`,{className:`flex items-center justify-center p-4`,children:(0,U.jsx)(`img`,{src:t,alt:r,className:`max-h-[70vh] max-w-full rounded object-contain`})}):n===`pdf`&&t?(0,U.jsx)(`iframe`,{src:t,title:r,className:`h-full w-full border-0`}):(n===`text`||n===`code`)&&e!==null?(0,U.jsx)(V9,{content:e,path:i||r,readOnly:!0,onSave:()=>{},onDirtyChange:()=>{},getContentRef:{current:()=>e||``}}):(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,U.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 vce(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 yce(e){let t=e?vce(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 bce(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=yce(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,b.useRef)(null);(0,b.useEffect)(()=>(n.current=n=>{if(n.source!==e.current?.contentWindow||n.data?.type!==`ksadk:linkClick`||t&&n.data?.channelId!==t)return;let r=n.data?.href;typeof r==`string`&&r&&bce(r)&&window.open(r,`_blank`,`noopener,noreferrer`)},window.addEventListener(`message`,n.current),()=>{n.current&&window.removeEventListener(`message`,n.current)}),[e,t])}function xce({content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i,isMobile:a}){let o=(0,b.useRef)(null),s=(0,b.useId)(),[c,l]=(0,b.useState)(`preview`),u=ft(t),d=dt(t),f=(0,b.useCallback)(()=>G9(e,{basePath:u,channelId:s}),[e,u,s]),[p,m]=(0,b.useState)(f());(0,b.useEffect)(()=>{let e=setTimeout(()=>{m(f())},300);return()=>clearTimeout(e)},[f]),K9(o,s);let h=(0,b.useCallback)(()=>{let e=new Blob([p],{type:`text/html;charset=utf-8`}),t=URL.createObjectURL(e),n=window.open(t,`_blank`,`noopener,noreferrer`);window.setTimeout(()=>URL.revokeObjectURL(t),3e4),n||window.open(d,`_blank`,`noopener,noreferrer`)},[d,p]);return a?(0,U.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-slate-200 px-2 py-1.5 dark:border-slate-700`,children:[(0,U.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,U.jsx)(hN,{className:`h-3.5 w-3.5`}),`编辑`]}),(0,U.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,U.jsx)(xN,{className:`h-3.5 w-3.5`}),`预览`]})]}),c===`editor`?(0,U.jsx)(V9,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}):(0,U.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,U.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,U.jsx)(V9,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}),(0,U.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,U.jsx)(xN,{className:`h-3.5 w-3.5`}),`预览`]})]}):(0,U.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,U.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,U.jsxs)(`div`,{className:`absolute right-3 top-3 z-10 flex gap-1.5`,children:[(0,U.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,U.jsx)(bN,{className:`h-3.5 w-3.5`}),`新窗口`]}),(0,U.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,U.jsx)(hN,{className:`h-3.5 w-3.5`}),`编辑`]})]})]})}function q9(e){e.current&&clearTimeout(e.current)}function J9({content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i,isMobile:a}){let[o,s]=(0,b.useState)(`editor`),[c,l]=(0,b.useState)(e),u=(0,b.useRef)(null);return(0,b.useEffect)(()=>(q9(u),u.current=setTimeout(()=>l(e),300),()=>q9(u)),[e]),a?(0,U.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,U.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,U.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,U.jsx)(hN,{className:`h-3.5 w-3.5`}),`编辑`]}),(0,U.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,U.jsx)(xN,{className:`h-3.5 w-3.5`}),`预览`]})]}),o===`editor`?(0,U.jsx)(V9,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}):(0,U.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:(0,U.jsx)(Tq,{content:c})})]}):o===`editor`?(0,U.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,U.jsx)(V9,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}),(0,U.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,U.jsx)(xN,{className:`h-3.5 w-3.5`}),`预览`]})]}):(0,U.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,U.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:(0,U.jsx)(Tq,{content:c})}),(0,U.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,U.jsx)(hN,{className:`h-3.5 w-3.5`}),`编辑`]})]})}var Sce=`/agentengine/api/v1/GetWorkspaceFileContent`,Cce=4e3;function Y9(e){let t=lt(e);if(!t||t===`.`)return`.`;let n=t.split(`/`).filter(Boolean);return n.length<=1?`.`:n.slice(0,-1).join(`/`)}function wce(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function X9(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 Tce=[{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 Ece(e){return dt(e)}function Z9({label:e,showSupportedTypes:t=!1}){return(0,U.jsx)(`div`,{className:`flex h-full min-h-[16rem] flex-col items-center justify-center px-6 text-center`,children:(0,U.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,U.jsx)(`div`,{children:e}),t?(0,U.jsxs)(`div`,{className:`mt-4 text-left`,children:[(0,U.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-[0.12em] text-slate-400`,children:`支持在线预览`}),(0,U.jsx)(`div`,{className:`mt-2 grid gap-2`,children:Tce.map(e=>(0,U.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,U.jsx)(`div`,{className:`text-sm font-medium text-slate-700 dark:text-slate-200`,children:e.label}),(0,U.jsx)(`div`,{className:`mt-0.5 font-mono text-[11px] text-slate-400`,children:e.detail})]},e.label))}),(0,U.jsx)(`div`,{className:`mt-3 text-xs leading-5 text-slate-400`,children:`Word、Excel、PPT 当前不支持在线预览,可下载后查看。`})]}):null]})})}function Q9({agentId:e,capability:t,open:n,onClose:r,isFullscreen:i=!1,onToggleFullscreen:a,isMobile:o=!1,api:s}){let c=(0,b.useRef)(null),l=(0,b.useRef)(null),[u,d]=(0,b.useState)(!1),[f,p]=(0,b.useState)(`.`),[m,h]=(0,b.useState)([]),[g,_]=(0,b.useState)(!1),[v,y]=(0,b.useState)(!1),[x,ee]=(0,b.useState)(!1),[te,S]=(0,b.useState)(``),[C,ne]=(0,b.useState)(null),[w,T]=(0,b.useState)(null),[re,ie]=(0,b.useState)(!1),[ae,oe]=(0,b.useState)(!1),se=(0,b.useRef)(null),ce=(0,b.useRef)(null),le=(0,b.useRef)(`selection`),E=(0,b.useRef)(St()),D=(0,b.useMemo)(()=>m.find(e=>e.Path===C)??null,[m,C]),ue=(0,b.useMemo)(()=>D?bt({path:D.Path,mimeType:D.MimeType}):null,[D]),de=(0,b.useCallback)(()=>re?window.confirm(`当前文件有未保存的更改,确定要离开吗?`):!0,[re]),fe=t.ContentPath||Sce,pe=t.RootLabel||`Workspace`,me=pe?`${pe.charAt(0).toUpperCase()}${pe.slice(1)}`:`Workspace`,he=mt(f),ge=(0,b.useCallback)(()=>{l.current&&=(URL.revokeObjectURL(l.current),null)},[]);(0,b.useEffect)(()=>()=>ge(),[ge]);let _e=(0,b.useCallback)(async(t,n={})=>{let r=!!n.background;r?y(!0):_(!0),r||S(``);try{let n=await s.listWorkspaceFiles(e,t,!1),i=lt(String(n?.Path||t||`.`)),a=Array.isArray(n?.Entries)?n.Entries:[];p(i),h(a),le.current=r?`background-refresh`:`selection`,ne(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||S(e instanceof Error?e.message:String(e))}finally{r?y(!1):_(!1)}},[e,s]);(0,b.useEffect)(()=>{!n||u||(d(!0),_e(`.`))},[u,_e,n]),(0,b.useEffect)(()=>{if(!n||re||!u)return;let e=window.setInterval(()=>{_e(f,{background:!0})},Cce);return()=>window.clearInterval(e)},[f,re,u,_e,n]);let ve=(0,b.useCallback)(async t=>{let n=E.current.next(t.Path),r=vt({path:t.Path,mimeType:t.MimeType});if(ce.current=t.Path,r===`unsupported`){ge(),T({path:t.Path,kind:r,status:`ready`,mimeType:t.MimeType??void 0});return}ge(),T({path:t.Path,kind:r,status:`loading`,mimeType:t.MimeType??void 0});try{let r=await s.getWorkspaceFileContent(e,t.Path,{asText:!1});if(!E.current.isCurrent(n))return;if(r instanceof Blob){let e=t.MimeType||``,i=vt({path:t.Path,mimeType:e});if(i===`image`||i===`pdf`){let n=URL.createObjectURL(r);l.current=n,T({path:t.Path,kind:i,status:`ready`,mimeType:e,objectUrl:n});return}let a=await r.text();if(!E.current.isCurrent(n))return;let o=vt({path:t.Path,mimeType:e});T({path:t.Path,kind:o,status:`ready`,mimeType:e,content:a})}else{let e=t.MimeType||``,n=vt({path:t.Path,mimeType:e});T({path:t.Path,kind:n,status:`ready`,mimeType:e,content:r})}}catch(e){if(!E.current.isCurrent(n))return;console.error(`Failed to preview workspace file:`,e),T({path:t.Path,kind:r,status:`error`,mimeType:t.MimeType??void 0,error:e instanceof Error?e.message:String(e)})}},[e,s,ge]);(0,b.useEffect)(()=>{if(!D||D.Type!==`file`){ge(),T(null),ie(!1),ce.current=null;return}if(le.current===`background-refresh`&&ce.current===D.Path){le.current=`selection`;return}le.current=`selection`,ve(D)},[ge,ve,D]);let ye=async n=>{if(!(!n||n.length===0)){ee(!0),S(``);try{for(let r of Array.from(n)){if(r.size>t.MaxUploadBytes)throw Error(`文件 ${r.name} 超过上传上限`);let n=pt(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 _e(f)}catch(e){console.error(`Failed to upload workspace files:`,e),S(e instanceof Error?e.message:String(e))}finally{c.current&&(c.current.value=``),ee(!1)}}},be=async n=>{if(!t.SupportsDelete)return;let r=lt(n.Path);if(window.confirm(`删除 ${r} ?`)){S(``);try{await s.deleteWorkspaceFile(e,r),C&<(C)===r&&(ne(null),ie(!1)),await _e(n.Type===`directory`&&(lt(f)===r||lt(f).startsWith(`${r}/`))?Y9(r):f)}catch(e){console.error(`Failed to delete workspace file:`,e),S(e instanceof Error?e.message:String(e))}}},xe=()=>!D||D.Type!==`file`?(0,U.jsx)(Z9,{label:`从左侧选择文件后在这里查看内容预览。`,showSupportedTypes:!0}):!w||w.path!==D.Path||w.status===`loading`?(0,U.jsx)(`div`,{className:`flex h-full min-h-[16rem] items-center justify-center`,children:(0,U.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,U.jsx)(kN,{className:`h-4 w-4 animate-spin`}),`正在加载预览...`]})}):w.status===`error`?(0,U.jsx)(Z9,{label:w.error||`文件预览加载失败。`}):w.kind===`markdown`?(0,U.jsx)(J9,{content:w.content||``,path:D.Path,onSave:Se,onDirtyChange:ie,getContentRef:se,isMobile:o}):w.kind===`image`&&w.objectUrl?(0,U.jsx)(H9,{content:null,objectUrl:w.objectUrl,kind:`image`,filename:D.Name,mimeType:w.mimeType||``}):w.kind===`pdf`&&w.objectUrl?(0,U.jsx)(H9,{content:null,objectUrl:w.objectUrl,kind:`pdf`,filename:D.Name,mimeType:w.mimeType||``}):w.kind===`html`?(0,U.jsx)(xce,{content:w.content||``,path:D.Path,onSave:Se,onDirtyChange:ie,getContentRef:se,isMobile:o,agentId:e,contentPath:fe}):w.kind===`text`||w.kind===`code`?(0,U.jsx)(V9,{content:w.content||``,path:D.Path,onSave:Se,onDirtyChange:ie,getContentRef:se}):(0,U.jsx)(H9,{content:null,kind:`unsupported`,filename:D.Name,mimeType:w.mimeType||``}),Se=async t=>{if(D){oe(!0),S(``);try{let n=new Blob([t],{type:D.MimeType||`text/plain`}),r=new FormData;r.append(`file`,n,D.Name),r.append(`AgentId`,e),r.append(`Path`,D.Path),await s.addWorkspaceFile(r),E.current.invalidate(),ie(!1),T(e=>e&&e.path===D.Path?{...e,content:t}:e),ce.current=D.Path,await _e(f,{background:!0})}catch(e){console.error(`Failed to save workspace file:`,e),S(e instanceof Error?e.message:String(e))}finally{oe(!1)}}},Ce=D?.Type===`file`&&w?.path===D.Path&&w.status===`ready`&&(w.kind===`text`||w.kind===`code`||w.kind===`html`||w.kind===`markdown`),we=D?.Type===`file`&&w?.path===D.Path&&w.status===`ready`&&w.kind===`pdf`;return(0,U.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,U.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,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100`,children:me}),(0,U.jsx)(`div`,{className:`hidden h-4 w-px bg-slate-200/70 dark:bg-slate-800 sm:block`}),(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`flex-shrink-0 text-xs text-slate-400`,children:`当前目录`}),(0,U.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:`${he},来自 ListWorkspaceFiles 返回的 Data.Path 字段`,children:he})]}),(0,U.jsx)(`div`,{className:`hidden truncate text-[11px] text-slate-400 xl:block`,children:`工作区内相对路径,不是宿主机绝对路径。`})]}),(0,U.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-1.5`,children:[(0,U.jsx)(`input`,{ref:c,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void ye(e.target.files)}),(0,U.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,U.jsx)(nP,{className:`h-3.5 w-3.5`}),x?`上传中`:`上传`]}),(0,U.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,U.jsx)(FN,{className:`h-3.5 w-3.5`}),`导出`]}),a?(0,U.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,U.jsx)(PN,{className:`h-4 w-4`}):(0,U.jsx)(AN,{className:`h-4 w-4`})}):null,r?(0,U.jsx)(`button`,{type:`button`,onClick:()=>{de()&&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,U.jsx)(aP,{className:`h-4 w-4`})}):null]})]}),(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col md:flex-row`,children:[(0,U.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,U.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,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium text-slate-900 dark:text-slate-100`,children:`文件`}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] text-slate-400`,children:[(0,U.jsxs)(`span`,{children:[m.length,` 项`]}),v?(0,U.jsx)(WN,{className:`h-3 w-3 animate-spin`,"aria-label":`正在同步 Workspace 目录`}):null]})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(`button`,{type:`button`,onClick:()=>{de()&&_e(Y9(f))},disabled:g||pt(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,U.jsx)(sN,{className:`h-4 w-4`})}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>{de()&&_e(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,U.jsx)(WN,{className:`h-4 w-4 ${g?`animate-spin`:``}`})})]})]}),te?(0,U.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:te}):null]}),(0,U.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto px-2 py-2`,children:!u&&!n?(0,U.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`打开面板后加载 workspace 文件。`}):g?(0,U.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`正在加载目录...`}):m.length===0?(0,U.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`当前目录为空。`}):(0,U.jsx)(`div`,{className:`space-y-0.5`,children:m.map(e=>{let n=vt({path:e.Path,mimeType:e.MimeType}),r=C===e.Path,i=e.Type===`file`?Ece(e.Path):``;return(0,U.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,U.jsxs)(`button`,{type:`button`,onClick:()=>{if(e.Type===`directory`){_e(e.Path);return}C!==e.Path&&!de()||ne(e.Path)},className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,U.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,U.jsx)(TN,{className:`h-3.5 w-3.5`}):n===`image`?(0,U.jsx)(DN,{className:`h-3.5 w-3.5`}):n===`markdown`||n===`text`||n===`html`?(0,U.jsx)(SN,{className:`h-3.5 w-3.5`}):(0,U.jsx)(wN,{className:`h-3.5 w-3.5`})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`truncate text-[13px] leading-5`,children:e.Name}),(0,U.jsx)(`div`,{className:K(`truncate text-[11px] leading-4`,r?`text-slate-500 dark:text-slate-400`:`text-slate-400`),children:e.Type===`directory`?`目录`:X9(e.SizeBytes)})]})]}),(0,U.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-0.5 opacity-0 transition group-hover:opacity-100`,children:[e.Type===`file`?(0,U.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,U.jsx)(_N,{className:`h-3.5 w-3.5`})}):null,t.SupportsDelete?(0,U.jsx)(`button`,{type:`button`,onClick:()=>void be(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,U.jsx)(tP,{className:`h-3.5 w-3.5`})}):null]})]},e.Path)})})})]}),(0,U.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,U.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:D?(0,U.jsxs)(`div`,{className:`flex w-full items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100`,children:D.Name}),(0,U.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-[11px] text-slate-400`,children:D.Path}),(0,U.jsxs)(`div`,{className:`mt-1 text-[11px] text-slate-400`,children:[X9(D.SizeBytes),D.MimeType?` · ${D.MimeType}`:``,D.ModifiedAt?` · ${wce(D.ModifiedAt)}`:``]})]}),ue===`text`||ue===`code`||ue===`html`||ue===`markdown`?(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{let e=se.current;e&&Se(e())},disabled:!re||ae,className:K(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition`,re&&!ae?`bg-blue-600 text-white hover:bg-blue-700`:`text-slate-400 dark:text-slate-500 cursor-not-allowed`),children:[(0,U.jsx)(GN,{className:`h-3.5 w-3.5`}),ae?`保存中`:re?`保存`:`已保存`]}):null]}):(0,U.jsxs)(`div`,{className:`w-full`,children:[(0,U.jsx)(`div`,{className:`text-sm font-semibold text-slate-900 dark:text-slate-100`,children:`文件预览`}),(0,U.jsx)(`div`,{className:`mt-0.5 text-xs text-slate-500 dark:text-slate-400`,children:`选择左侧文件后可在此查看内容。`})]})}),(0,U.jsx)(`div`,{className:K(`custom-scrollbar min-h-0 flex-1`,we||Ce?`overflow-hidden p-0`:`overflow-y-auto px-4 py-4`),children:xe()})]})]})]})}function Dce({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,U.jsxs)(U.Fragment,{children:[f?(0,U.jsxs)(U.Fragment,{children:[n&&!i?(0,U.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,U.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,U.jsx)(Q9,{agentId:e,capability:t,open:n,onClose:l,isFullscreen:i,onToggleFullscreen:()=>w.getState().setWorkspacePanelFullscreen(!i),isMobile:a,api:d}):null})]}):null,p?(0,U.jsx)(JR,{open:n,onOpenChange:e=>{e||w.getState().setWorkspacePanelFullscreen(!1),w.getState().setWorkspacePanelOpen(e)},modal:c.modal,children:(0,U.jsxs)(XR,{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,U.jsx)(QR,{className:`sr-only`,children:`Workspace 文件`}),(0,U.jsx)($R,{className:`sr-only`,children:`浏览、上传和预览 Workspace 文件。`}),(0,U.jsx)(Q9,{agentId:e,capability:t,open:n,onClose:l,isMobile:a,api:d})]})}):null]})}var Oce=new Vc,kce=b.lazy(()=>J(()=>import(`./ArtifactsPanel-9RUQms_7.js`).then(e=>({default:e.ArtifactsPanel})),[],import.meta.url)),Ace=b.lazy(()=>J(()=>import(`./NativeTerminalPanel-BTTm24gh.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function jce({apiAdapter:e,initialSurface:t=`chat`,routeShell:n}={}){let r=e||Oce,i=Ce(e=>e.agentId),a=Ze(e=>e.currentSessionId),o=O(e=>e.isStreaming),s=w(e=>e.sidebarOpen),c=w(e=>e.mobileSidebarOpen),l=w(e=>e.mobileActionsOpen),u=Ce(e=>e.agentName),d=Te(e=>e.selectedModel),f=Te(e=>e.availableModels),p=Te(e=>e.modelSource),m=Te(e=>e.modelCatalogLoaded),h=Te(e=>e.thinkingMode),g=ke(e=>e.permissionMode),_=Ce(e=>e.agentFramework),v=Ce(e=>e.workspaceFiles),y=Ce(e=>e.accessMode),x=Ce(e=>e.status),ee=Ce(e=>e.errorMessage),te=w(e=>e.workspacePanelOpen),S=w(e=>e.workspacePanelWidth),C=w(e=>e.workspacePanelFullscreen),ne=Ce(e=>e.apiFormats),T=Ce(e=>e.capabilities),re=Qe(e=>e.visible&&!!e.content),ie=(0,b.useRef)([]),ae=(0,b.useRef)(null),{isMobile:oe,viewportHeight:se}=Ht(),ce=nt({isMobile:oe,viewportHeight:se}),{fetchSessions:le,loadMoreSessions:E,loadSession:D,loadOlderSessionMessages:ue,createNewSession:de,adoptCreatedSession:fe,waitForPendingSessionCreation:pe,deleteSession:me,currentSessionIdRef:he,agentIdRef:ge,runSubscriptionAbortRef:_e}=YM({agentId:i,currentSessionId:a,isMobile:oe,uiCapabilities:T,api:r,resetCompaction:()=>{},disconnectRun:()=>ae.current?.()}),ve=(0,b.useCallback)(e=>{if(!e)return;let t=()=>{Ze.getState().clearSessionMessageHistory(e),le(ge.current,e)};queueMicrotask(t),window.setTimeout(t,1800),window.setTimeout(t,5e3)},[ge,le]),ye=f.find(e=>e.id===d)||null,{submitDraft:be,stopGeneration:Se,disconnectRun:we,resumeCheckpoint:Ee,submitAguiAction:De,respondToAguiApproval:Oe}=eM({agentId:i,currentSessionId:a,agentFramework:_,apiFormats:ne,selectedModel:d,selectedModelMetadata:ye,thinkingMode:h,permissionMode:g,uiCapabilities:T,isMobile:oe,api:r,currentSessionIdRef:he,agentIdRef:ge,queuedDraftRef:ie,onRunSettled:ve,onSessionCreated:e=>fe(e,!0),waitForPendingSessionCreation:pe});(0,b.useEffect)(()=>{ae.current=we},[we]);let Ae=(0,b.useCallback)(()=>{let e=he.current;_e.current?.abort(),O.getState().stopActivity(),O.getState().stopSessionActivity(e),Se()},[he,_e,Se]),je=(0,b.useCallback)(async()=>{let e=he.current,t=O.getState(),n=t.getSessionActivity(e)?.runId||t.currentRunId||``;if(e&&n)try{await r.cancelRun(i,e,n),O.getState().stopSessionActivity(e,`取消请求已发送,后台运行会停在最近 checkpoint。`)}catch(t){console.warn(`[App] cancelRun failed:`,t),O.getState().updateActivity({sessionId:e,status:`failed`,phase:`取消请求失败`,detail:t instanceof Error?t.message:String(t),countEvent:!1})}ve(e)},[r,i,he,ve]),{submitResponseFeedback:Me,deleteResponseFeedback:Ne,respondToApproval:Pe}=dM({agentId:i,currentSessionId:a,isStreaming:o,api:r,submitDraft:be}),Fe=(0,b.useRef)(Pe),Ie=(0,b.useRef)(Oe);(0,b.useEffect)(()=>{Fe.current=Pe,Ie.current=Oe},[Pe,Oe]);let{pending:Le,records:Re,respond:ze,localCatalog:Be}=fM({agentId:i,getAgentId:()=>ge.current,currentSessionId:a,api:r,interactionV1Enabled:!!T.InteractionV1,legacyResponsesApproval:(e,t)=>{Fe.current({approvalRequestId:e,approve:t})},legacyAguiResume:(e,t,n)=>Ie.current({interruptId:e,approve:t===`resolved`})});Kc({fetchSessions:le},void 0,r),(0,b.useEffect)(()=>{ge.current=i,kt(i,a)},[i,a,ge]),(0,b.useEffect)(()=>{oe?w.getState().setWorkspacePanelFullscreen(!1):(w.getState().setMobileSidebarOpen(!1),w.getState().setMobileActionsOpen(!1))},[oe]),(0,b.useEffect)(()=>{te||w.getState().setWorkspacePanelFullscreen(!1)},[te]),(0,b.useEffect)(()=>()=>{_e.current?.abort()},[_e]);let Ve=xe(T),He=!!T.Thinking,Ue=Ct({workspaceFiles:v,accessMode:y}),We=xt({isMobile:oe}),Ge=It({capability:T.NativeDashboard,agentFramework:_,accessMode:y,origin:window.location.origin}),Ke=!Ve,qe=_===`openclaw`?`OpenClaw`:_===`hermes`?`Hermes`:`原生运行时`,Je=ye?.display_name||d||``,Ye=!oe&&s&&Ve,Xe=(0,b.useRef)(!1),[$e,et]=(0,b.useState)(t===`tui`),tt=$e&&!!T.NativeTerminal?.Enabled;(0,b.useEffect)(()=>{Xe.current||t!==`workspace`||!Ue||(Xe.current=!0,w.getState().setWorkspacePanelOpen(!0),w.getState().setWorkspacePanelFullscreen(!0))},[t,Ue]);let rt=()=>{w.getState().setWorkspacePanelFullscreen(!1),w.getState().setWorkspacePanelOpen(!1)};if(x!==`ready`){let e=x===`auth-required`,t=(0,U.jsx)(`div`,{className:`ksadk-web 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,U.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,U.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:x===`loading`?`…`:`↗`}),(0,U.jsx)(`h1`,{className:`text-xl font-semibold`,children:x===`loading`?`正在连接 Agent`:e?`需要有效的访问链接`:`Agent 暂时无法连接`}),x===`loading`?null:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`p`,{className:`mt-3 text-sm leading-6 text-slate-500 dark:text-slate-400`,children:[ee,e?` 请从 AgentEngine 控制台重新打开 Dashboard,或使用 agentengine dashboard open 获取临时链接。`:``]}),(0,U.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,U.jsx)(n,{children:t}):t}let it=(0,U.jsxs)(`div`,{className:`ksadk-web 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,U.jsx)(Rne,{uiCapabilities:T,createNewSession:de,deleteSession:me,loadSession:D,loadMoreSessions:E}),(0,U.jsxs)(`main`,{className:`relative flex min-w-0 flex-1 flex-col bg-white dark:bg-slate-900`,children:[(0,U.jsx)(cY,{agentName:u,currentSessionId:a,nativeLauncherMode:Ke,isMobile:oe,sidebarOpen:s,mobileSidebarOpen:c,onToggleSidebar:()=>{oe?w.getState().toggleMobileSidebar():w.getState().toggleSidebar()},availableModels:f,selectedModel:d,onSelectModel:e=>{Te.getState().setSelectedModel(e),oe&&w.getState().setMobileActionsOpen(!1)},selectedModelLabel:Je,modelCatalogLoaded:m,modelSource:p,thinkingEnabled:He,thinkingMode:h,onSelectThinkingMode:e=>Te.getState().setThinkingMode(Rt(e)),mobileActionsOpen:l,onMobileActionsOpenChange:e=>w.getState().setMobileActionsOpen(e),workspaceEnabled:Ue,onOpenWorkspace:()=>w.getState().setWorkspacePanelOpen(!0),nativeManagementLink:Ge,nativeTerminal:T.NativeTerminal}),Ke?(0,U.jsx)(uY,{productLabel:qe,nativeManagementLink:Ge,nativeTerminal:T.NativeTerminal,workspaceEnabled:Ue,onOpenWorkspace:()=>w.getState().setWorkspacePanelOpen(!0)}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(UJ,{agentName:u,isMobile:oe,onDeleteFeedback:Ne,onSubmitFeedback:Me,onRespondToApproval:Pe,onRespondToAguiApproval:Oe,onSubmitAguiAction:De,onStopGeneration:Ae,onCancelRemote:T.StopRun?je:void 0,checkpointResumeEnabled:T.RunLifecycle.Enabled&&T.RunLifecycle.Checkpoints&&T.RunLifecycle.CheckpointResume,onResumeCheckpoint:Ee,onLoadOlderSessionMessages:ue,interactionRecords:Re}),(0,U.jsx)(aY,{onCompactContext:T.ContextCompaction&&r.compactSession?async()=>{if(!(!a||!r.compactSession)){if((await r.compactSession(i,a)).Status!==`completed`)throw Error(`运行时尚未确认压缩完成`);await le(i,a)}}:void 0,composerMaxHeight:ce,submitDraft:be,stopGeneration:Ae,cancelRemote:T.StopRun?je:void 0,isMobile:oe,attachmentsEnabled:T.Attachments!==!1,approvalEnabled:!!T.Approval&&T.ApprovalPolicy?.RuntimeOverride!==!1,approvalPolicy:T.ApprovalPolicy,thinkingEnabled:He,runtimeCapabilityMatrix:T.RuntimeCapabilityMatrix,pendingInteractions:Le,onRespondInteraction:e=>{ze(e)},localCatalog:Be})]})]}),(0,U.jsx)(Dce,{agentId:i,capability:v,workspacePanelOpen:te,workspacePanelWidth:S,workspacePanelFullscreen:C,isMobile:oe,workspaceEnabled:Ue,workspaceFiles:v,workspacePanelPresentation:We,closeWorkspacePanel:rt,handleWorkspacePanelResizeStart:e=>{if(C||oe)return;e.preventDefault();let t=e.clientX,n=S,r=Ve&&Ye?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;w.getState().setWorkspacePanelWidth(xl(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:r}),re&&(0,U.jsx)(b.Suspense,{fallback:null,children:(0,U.jsx)(kce,{})}),tt?(0,U.jsx)(b.Suspense,{fallback:null,children:(0,U.jsx)(Ace,{capability:T.NativeTerminal,open:!0,sessionId:a,onClose:()=>et(!1)})}):null]});return n?(0,U.jsx)(n,{children:it}):it}function Mce(){return(0,U.jsx)(jce,{})}function Nce(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`,Pce=class extends b.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){if(console.error(`UI 渲染错误:`,e,t),Nce(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,U.jsx)(`div`,{className:`flex h-screen w-screen items-center justify-center bg-slate-50 dark:bg-slate-900`,children:(0,U.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,U.jsx)(`div`,{className:`mb-4 text-4xl`,children:`⚠`}),(0,U.jsx)(`h1`,{className:`mb-2 text-xl font-semibold text-red-600 dark:text-red-400`,children:`页面渲染出错`}),(0,U.jsx)(`p`,{className:`mb-6 text-sm text-slate-600 dark:text-slate-400`,children:this.state.error?.message||`发生了未知错误,请刷新页面重试。`}),(0,U.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 Fce(){let e=w(e=>e.toasts),t=w(e=>e.dismissToast);return(0,b.useEffect)(()=>{if(!e.length)return;let n=e[0],r=3e3-(Date.now()-n.createdAt);if(r<=0){t(n.id);return}let i=setTimeout(()=>t(n.id),r);return()=>clearTimeout(i)},[e,t]),e.length?(0,U.jsx)(`div`,{className:`fixed bottom-4 right-4 z-50 flex flex-col gap-2`,children:e.map(e=>(0,U.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,U.jsx)(`span`,{className:`flex-1`,children:e.message}),(0,U.jsx)(`button`,{onClick:()=>t(e.id),className:`shrink-0 rounded p-0.5 opacity-70 hover:opacity-100`,children:(0,U.jsx)(aP,{size:14})})]},e.id))}):null}C.createRoot(document.getElementById(`root`)).render((0,U.jsxs)(Pce,{children:[(0,U.jsx)(Mce,{}),(0,U.jsx)(Fce,{})]}));export{pB as $,m3 as A,HX as B,I6 as C,o as Ct,Z as D,f6 as E,S3 as F,hq as G,cZ as H,K3 as I,YW as J,$K as K,S2 as L,_3 as M,H3 as N,d3 as O,W3 as P,IH as Q,j2 as R,P6 as S,p as St,s6 as T,l as Tt,sJ as U,lX as V,J as W,GH as X,KU as Y,KH as Z,Jie as _,gN as _t,xse as a,Ez as at,$6 as b,Ww as bt,L6 as c,zne as ct,V6 as d,tP as dt,oB as et,O8 as f,XN as ft,Wie as g,_N as gt,Uie as h,xN as ht,Z7 as i,Oz as it,v3 as j,x3 as k,Q as l,K as lt,F6 as m,HN as mt,K9 as n,tre as nt,rce as o,az as ot,Gie as p,WN as pt,XK as q,Y7 as r,Dz as rt,Mie as s,Bne as st,G9 as t,Yz as tt,q6 as u,aP as ut,r8 as v,lN as vt,z6 as w,s as wt,J6 as x,Qe as xt,n8 as y,aN 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,b.useRef)(null);(0,b.useEffect)(()=>(n.current=n=>{if(n.source!==e.current?.contentWindow||n.data?.type!==`ksadk:linkClick`||t&&n.data?.channelId!==t)return;let r=n.data?.href;typeof r==`string`&&r&&bce(r)&&window.open(r,`_blank`,`noopener,noreferrer`)},window.addEventListener(`message`,n.current),()=>{n.current&&window.removeEventListener(`message`,n.current)}),[e,t])}function xce({content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i,isMobile:a}){let o=(0,b.useRef)(null),s=(0,b.useId)(),[c,l]=(0,b.useState)(`preview`),u=ft(t),d=dt(t),f=(0,b.useCallback)(()=>G9(e,{basePath:u,channelId:s}),[e,u,s]),[p,m]=(0,b.useState)(f());(0,b.useEffect)(()=>{let e=setTimeout(()=>{m(f())},300);return()=>clearTimeout(e)},[f]),K9(o,s);let h=(0,b.useCallback)(()=>{let e=new Blob([p],{type:`text/html;charset=utf-8`}),t=URL.createObjectURL(e),n=window.open(t,`_blank`,`noopener,noreferrer`);window.setTimeout(()=>URL.revokeObjectURL(t),3e4),n||window.open(d,`_blank`,`noopener,noreferrer`)},[d,p]);return a?(0,U.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-slate-200 px-2 py-1.5 dark:border-slate-700`,children:[(0,U.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,U.jsx)(hN,{className:`h-3.5 w-3.5`}),`编辑`]}),(0,U.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,U.jsx)(xN,{className:`h-3.5 w-3.5`}),`预览`]})]}),c===`editor`?(0,U.jsx)(V9,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}):(0,U.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,U.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,U.jsx)(V9,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}),(0,U.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,U.jsx)(xN,{className:`h-3.5 w-3.5`}),`预览`]})]}):(0,U.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,U.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,U.jsxs)(`div`,{className:`absolute right-3 top-3 z-10 flex gap-1.5`,children:[(0,U.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,U.jsx)(bN,{className:`h-3.5 w-3.5`}),`新窗口`]}),(0,U.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,U.jsx)(hN,{className:`h-3.5 w-3.5`}),`编辑`]})]})]})}function q9(e){e.current&&clearTimeout(e.current)}function J9({content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i,isMobile:a}){let[o,s]=(0,b.useState)(`editor`),[c,l]=(0,b.useState)(e),u=(0,b.useRef)(null);return(0,b.useEffect)(()=>(q9(u),u.current=setTimeout(()=>l(e),300),()=>q9(u)),[e]),a?(0,U.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,U.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,U.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,U.jsx)(hN,{className:`h-3.5 w-3.5`}),`编辑`]}),(0,U.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,U.jsx)(xN,{className:`h-3.5 w-3.5`}),`预览`]})]}),o===`editor`?(0,U.jsx)(V9,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}):(0,U.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:(0,U.jsx)(Tq,{content:c})})]}):o===`editor`?(0,U.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,U.jsx)(V9,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}),(0,U.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,U.jsx)(xN,{className:`h-3.5 w-3.5`}),`预览`]})]}):(0,U.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,U.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:(0,U.jsx)(Tq,{content:c})}),(0,U.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,U.jsx)(hN,{className:`h-3.5 w-3.5`}),`编辑`]})]})}var Sce=`/agentengine/api/v1/GetWorkspaceFileContent`,Cce=4e3;function Y9(e){let t=lt(e);if(!t||t===`.`)return`.`;let n=t.split(`/`).filter(Boolean);return n.length<=1?`.`:n.slice(0,-1).join(`/`)}function wce(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function X9(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 Tce=[{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 Ece(e){return dt(e)}function Z9({label:e,showSupportedTypes:t=!1}){return(0,U.jsx)(`div`,{className:`flex h-full min-h-[16rem] flex-col items-center justify-center px-6 text-center`,children:(0,U.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,U.jsx)(`div`,{children:e}),t?(0,U.jsxs)(`div`,{className:`mt-4 text-left`,children:[(0,U.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-[0.12em] text-slate-400`,children:`支持在线预览`}),(0,U.jsx)(`div`,{className:`mt-2 grid gap-2`,children:Tce.map(e=>(0,U.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,U.jsx)(`div`,{className:`text-sm font-medium text-slate-700 dark:text-slate-200`,children:e.label}),(0,U.jsx)(`div`,{className:`mt-0.5 font-mono text-[11px] text-slate-400`,children:e.detail})]},e.label))}),(0,U.jsx)(`div`,{className:`mt-3 text-xs leading-5 text-slate-400`,children:`Word、Excel、PPT 当前不支持在线预览,可下载后查看。`})]}):null]})})}function Q9({agentId:e,capability:t,open:n,onClose:r,isFullscreen:i=!1,onToggleFullscreen:a,isMobile:o=!1,api:s}){let c=(0,b.useRef)(null),l=(0,b.useRef)(null),[u,d]=(0,b.useState)(!1),[f,p]=(0,b.useState)(`.`),[m,h]=(0,b.useState)([]),[g,_]=(0,b.useState)(!1),[v,y]=(0,b.useState)(!1),[x,ee]=(0,b.useState)(!1),[te,S]=(0,b.useState)(``),[C,ne]=(0,b.useState)(null),[w,T]=(0,b.useState)(null),[re,ie]=(0,b.useState)(!1),[ae,oe]=(0,b.useState)(!1),se=(0,b.useRef)(null),ce=(0,b.useRef)(null),le=(0,b.useRef)(`selection`),E=(0,b.useRef)(St()),D=(0,b.useMemo)(()=>m.find(e=>e.Path===C)??null,[m,C]),ue=(0,b.useMemo)(()=>D?bt({path:D.Path,mimeType:D.MimeType}):null,[D]),de=(0,b.useCallback)(()=>re?window.confirm(`当前文件有未保存的更改,确定要离开吗?`):!0,[re]),fe=t.ContentPath||Sce,pe=t.RootLabel||`Workspace`,me=pe?`${pe.charAt(0).toUpperCase()}${pe.slice(1)}`:`Workspace`,he=mt(f),ge=(0,b.useCallback)(()=>{l.current&&=(URL.revokeObjectURL(l.current),null)},[]);(0,b.useEffect)(()=>()=>ge(),[ge]);let _e=(0,b.useCallback)(async(t,n={})=>{let r=!!n.background;r?y(!0):_(!0),r||S(``);try{let n=await s.listWorkspaceFiles(e,t,!1),i=lt(String(n?.Path||t||`.`)),a=Array.isArray(n?.Entries)?n.Entries:[];p(i),h(a),le.current=r?`background-refresh`:`selection`,ne(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||S(e instanceof Error?e.message:String(e))}finally{r?y(!1):_(!1)}},[e,s]);(0,b.useEffect)(()=>{!n||u||(d(!0),_e(`.`))},[u,_e,n]),(0,b.useEffect)(()=>{if(!n||re||!u)return;let e=window.setInterval(()=>{_e(f,{background:!0})},Cce);return()=>window.clearInterval(e)},[f,re,u,_e,n]);let ve=(0,b.useCallback)(async t=>{let n=E.current.next(t.Path),r=vt({path:t.Path,mimeType:t.MimeType});if(ce.current=t.Path,r===`unsupported`){ge(),T({path:t.Path,kind:r,status:`ready`,mimeType:t.MimeType??void 0});return}ge(),T({path:t.Path,kind:r,status:`loading`,mimeType:t.MimeType??void 0});try{let r=await s.getWorkspaceFileContent(e,t.Path,{asText:!1});if(!E.current.isCurrent(n))return;if(r instanceof Blob){let e=t.MimeType||``,i=vt({path:t.Path,mimeType:e});if(i===`image`||i===`pdf`){let n=URL.createObjectURL(r);l.current=n,T({path:t.Path,kind:i,status:`ready`,mimeType:e,objectUrl:n});return}let a=await r.text();if(!E.current.isCurrent(n))return;let o=vt({path:t.Path,mimeType:e});T({path:t.Path,kind:o,status:`ready`,mimeType:e,content:a})}else{let e=t.MimeType||``,n=vt({path:t.Path,mimeType:e});T({path:t.Path,kind:n,status:`ready`,mimeType:e,content:r})}}catch(e){if(!E.current.isCurrent(n))return;console.error(`Failed to preview workspace file:`,e),T({path:t.Path,kind:r,status:`error`,mimeType:t.MimeType??void 0,error:e instanceof Error?e.message:String(e)})}},[e,s,ge]);(0,b.useEffect)(()=>{if(!D||D.Type!==`file`){ge(),T(null),ie(!1),ce.current=null;return}if(le.current===`background-refresh`&&ce.current===D.Path){le.current=`selection`;return}le.current=`selection`,ve(D)},[ge,ve,D]);let ye=async n=>{if(!(!n||n.length===0)){ee(!0),S(``);try{for(let r of Array.from(n)){if(r.size>t.MaxUploadBytes)throw Error(`文件 ${r.name} 超过上传上限`);let n=pt(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 _e(f)}catch(e){console.error(`Failed to upload workspace files:`,e),S(e instanceof Error?e.message:String(e))}finally{c.current&&(c.current.value=``),ee(!1)}}},be=async n=>{if(!t.SupportsDelete)return;let r=lt(n.Path);if(window.confirm(`删除 ${r} ?`)){S(``);try{await s.deleteWorkspaceFile(e,r),C&<(C)===r&&(ne(null),ie(!1)),await _e(n.Type===`directory`&&(lt(f)===r||lt(f).startsWith(`${r}/`))?Y9(r):f)}catch(e){console.error(`Failed to delete workspace file:`,e),S(e instanceof Error?e.message:String(e))}}},xe=()=>!D||D.Type!==`file`?(0,U.jsx)(Z9,{label:`从左侧选择文件后在这里查看内容预览。`,showSupportedTypes:!0}):!w||w.path!==D.Path||w.status===`loading`?(0,U.jsx)(`div`,{className:`flex h-full min-h-[16rem] items-center justify-center`,children:(0,U.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,U.jsx)(kN,{className:`h-4 w-4 animate-spin`}),`正在加载预览...`]})}):w.status===`error`?(0,U.jsx)(Z9,{label:w.error||`文件预览加载失败。`}):w.kind===`markdown`?(0,U.jsx)(J9,{content:w.content||``,path:D.Path,onSave:Se,onDirtyChange:ie,getContentRef:se,isMobile:o}):w.kind===`image`&&w.objectUrl?(0,U.jsx)(H9,{content:null,objectUrl:w.objectUrl,kind:`image`,filename:D.Name,mimeType:w.mimeType||``}):w.kind===`pdf`&&w.objectUrl?(0,U.jsx)(H9,{content:null,objectUrl:w.objectUrl,kind:`pdf`,filename:D.Name,mimeType:w.mimeType||``}):w.kind===`html`?(0,U.jsx)(xce,{content:w.content||``,path:D.Path,onSave:Se,onDirtyChange:ie,getContentRef:se,isMobile:o,agentId:e,contentPath:fe}):w.kind===`text`||w.kind===`code`?(0,U.jsx)(V9,{content:w.content||``,path:D.Path,onSave:Se,onDirtyChange:ie,getContentRef:se}):(0,U.jsx)(H9,{content:null,kind:`unsupported`,filename:D.Name,mimeType:w.mimeType||``}),Se=async t=>{if(D){oe(!0),S(``);try{let n=new Blob([t],{type:D.MimeType||`text/plain`}),r=new FormData;r.append(`file`,n,D.Name),r.append(`AgentId`,e),r.append(`Path`,D.Path),await s.addWorkspaceFile(r),E.current.invalidate(),ie(!1),T(e=>e&&e.path===D.Path?{...e,content:t}:e),ce.current=D.Path,await _e(f,{background:!0})}catch(e){console.error(`Failed to save workspace file:`,e),S(e instanceof Error?e.message:String(e))}finally{oe(!1)}}},Ce=D?.Type===`file`&&w?.path===D.Path&&w.status===`ready`&&(w.kind===`text`||w.kind===`code`||w.kind===`html`||w.kind===`markdown`),we=D?.Type===`file`&&w?.path===D.Path&&w.status===`ready`&&w.kind===`pdf`;return(0,U.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,U.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,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100`,children:me}),(0,U.jsx)(`div`,{className:`hidden h-4 w-px bg-slate-200/70 dark:bg-slate-800 sm:block`}),(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`flex-shrink-0 text-xs text-slate-400`,children:`当前目录`}),(0,U.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:`${he},来自 ListWorkspaceFiles 返回的 Data.Path 字段`,children:he})]}),(0,U.jsx)(`div`,{className:`hidden truncate text-[11px] text-slate-400 xl:block`,children:`工作区内相对路径,不是宿主机绝对路径。`})]}),(0,U.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-1.5`,children:[(0,U.jsx)(`input`,{ref:c,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void ye(e.target.files)}),(0,U.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,U.jsx)(nP,{className:`h-3.5 w-3.5`}),x?`上传中`:`上传`]}),(0,U.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,U.jsx)(FN,{className:`h-3.5 w-3.5`}),`导出`]}),a?(0,U.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,U.jsx)(PN,{className:`h-4 w-4`}):(0,U.jsx)(AN,{className:`h-4 w-4`})}):null,r?(0,U.jsx)(`button`,{type:`button`,onClick:()=>{de()&&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,U.jsx)(aP,{className:`h-4 w-4`})}):null]})]}),(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col md:flex-row`,children:[(0,U.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,U.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,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium text-slate-900 dark:text-slate-100`,children:`文件`}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] text-slate-400`,children:[(0,U.jsxs)(`span`,{children:[m.length,` 项`]}),v?(0,U.jsx)(WN,{className:`h-3 w-3 animate-spin`,"aria-label":`正在同步 Workspace 目录`}):null]})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(`button`,{type:`button`,onClick:()=>{de()&&_e(Y9(f))},disabled:g||pt(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,U.jsx)(sN,{className:`h-4 w-4`})}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>{de()&&_e(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,U.jsx)(WN,{className:`h-4 w-4 ${g?`animate-spin`:``}`})})]})]}),te?(0,U.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:te}):null]}),(0,U.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto px-2 py-2`,children:!u&&!n?(0,U.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`打开面板后加载 workspace 文件。`}):g?(0,U.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`正在加载目录...`}):m.length===0?(0,U.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`当前目录为空。`}):(0,U.jsx)(`div`,{className:`space-y-0.5`,children:m.map(e=>{let n=vt({path:e.Path,mimeType:e.MimeType}),r=C===e.Path,i=e.Type===`file`?Ece(e.Path):``;return(0,U.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,U.jsxs)(`button`,{type:`button`,onClick:()=>{if(e.Type===`directory`){_e(e.Path);return}C!==e.Path&&!de()||ne(e.Path)},className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,U.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,U.jsx)(TN,{className:`h-3.5 w-3.5`}):n===`image`?(0,U.jsx)(DN,{className:`h-3.5 w-3.5`}):n===`markdown`||n===`text`||n===`html`?(0,U.jsx)(SN,{className:`h-3.5 w-3.5`}):(0,U.jsx)(wN,{className:`h-3.5 w-3.5`})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`truncate text-[13px] leading-5`,children:e.Name}),(0,U.jsx)(`div`,{className:K(`truncate text-[11px] leading-4`,r?`text-slate-500 dark:text-slate-400`:`text-slate-400`),children:e.Type===`directory`?`目录`:X9(e.SizeBytes)})]})]}),(0,U.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-0.5 opacity-0 transition group-hover:opacity-100`,children:[e.Type===`file`?(0,U.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,U.jsx)(_N,{className:`h-3.5 w-3.5`})}):null,t.SupportsDelete?(0,U.jsx)(`button`,{type:`button`,onClick:()=>void be(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,U.jsx)(tP,{className:`h-3.5 w-3.5`})}):null]})]},e.Path)})})})]}),(0,U.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,U.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:D?(0,U.jsxs)(`div`,{className:`flex w-full items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100`,children:D.Name}),(0,U.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-[11px] text-slate-400`,children:D.Path}),(0,U.jsxs)(`div`,{className:`mt-1 text-[11px] text-slate-400`,children:[X9(D.SizeBytes),D.MimeType?` · ${D.MimeType}`:``,D.ModifiedAt?` · ${wce(D.ModifiedAt)}`:``]})]}),ue===`text`||ue===`code`||ue===`html`||ue===`markdown`?(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{let e=se.current;e&&Se(e())},disabled:!re||ae,className:K(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition`,re&&!ae?`bg-blue-600 text-white hover:bg-blue-700`:`text-slate-400 dark:text-slate-500 cursor-not-allowed`),children:[(0,U.jsx)(GN,{className:`h-3.5 w-3.5`}),ae?`保存中`:re?`保存`:`已保存`]}):null]}):(0,U.jsxs)(`div`,{className:`w-full`,children:[(0,U.jsx)(`div`,{className:`text-sm font-semibold text-slate-900 dark:text-slate-100`,children:`文件预览`}),(0,U.jsx)(`div`,{className:`mt-0.5 text-xs text-slate-500 dark:text-slate-400`,children:`选择左侧文件后可在此查看内容。`})]})}),(0,U.jsx)(`div`,{className:K(`custom-scrollbar min-h-0 flex-1`,we||Ce?`overflow-hidden p-0`:`overflow-y-auto px-4 py-4`),children:xe()})]})]})]})}function Dce({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,U.jsxs)(U.Fragment,{children:[f?(0,U.jsxs)(U.Fragment,{children:[n&&!i?(0,U.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,U.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,U.jsx)(Q9,{agentId:e,capability:t,open:n,onClose:l,isFullscreen:i,onToggleFullscreen:()=>w.getState().setWorkspacePanelFullscreen(!i),isMobile:a,api:d}):null})]}):null,p?(0,U.jsx)(JR,{open:n,onOpenChange:e=>{e||w.getState().setWorkspacePanelFullscreen(!1),w.getState().setWorkspacePanelOpen(e)},modal:c.modal,children:(0,U.jsxs)(XR,{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,U.jsx)(QR,{className:`sr-only`,children:`Workspace 文件`}),(0,U.jsx)($R,{className:`sr-only`,children:`浏览、上传和预览 Workspace 文件。`}),(0,U.jsx)(Q9,{agentId:e,capability:t,open:n,onClose:l,isMobile:a,api:d})]})}):null]})}var Oce=new Vc,kce=b.lazy(()=>J(()=>import(`./ArtifactsPanel-Ci-uVB1V.js`).then(e=>({default:e.ArtifactsPanel})),[],import.meta.url)),Ace=b.lazy(()=>J(()=>import(`./NativeTerminalPanel-D4469o8R.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function jce({apiAdapter:e,initialSurface:t=`chat`,routeShell:n}={}){let r=e||Oce,i=Ce(e=>e.agentId),a=Ze(e=>e.currentSessionId),o=O(e=>e.isStreaming),s=w(e=>e.sidebarOpen),c=w(e=>e.mobileSidebarOpen),l=w(e=>e.mobileActionsOpen),u=Ce(e=>e.agentName),d=Te(e=>e.selectedModel),f=Te(e=>e.availableModels),p=Te(e=>e.modelSource),m=Te(e=>e.modelCatalogLoaded),h=Te(e=>e.thinkingMode),g=ke(e=>e.permissionMode),_=Ce(e=>e.agentFramework),v=Ce(e=>e.workspaceFiles),y=Ce(e=>e.accessMode),x=Ce(e=>e.status),ee=Ce(e=>e.errorMessage),te=w(e=>e.workspacePanelOpen),S=w(e=>e.workspacePanelWidth),C=w(e=>e.workspacePanelFullscreen),ne=Ce(e=>e.apiFormats),T=Ce(e=>e.capabilities),re=Qe(e=>e.visible&&!!e.content),ie=(0,b.useRef)([]),ae=(0,b.useRef)(null),{isMobile:oe,viewportHeight:se}=Ht(),ce=nt({isMobile:oe,viewportHeight:se}),{fetchSessions:le,loadMoreSessions:E,loadSession:D,loadOlderSessionMessages:ue,createNewSession:de,adoptCreatedSession:fe,waitForPendingSessionCreation:pe,deleteSession:me,currentSessionIdRef:he,agentIdRef:ge,runSubscriptionAbortRef:_e}=YM({agentId:i,currentSessionId:a,isMobile:oe,uiCapabilities:T,api:r,resetCompaction:()=>{},disconnectRun:()=>ae.current?.()}),ve=(0,b.useCallback)(e=>{if(!e)return;let t=()=>{Ze.getState().clearSessionMessageHistory(e),le(ge.current,e)};queueMicrotask(t),window.setTimeout(t,1800),window.setTimeout(t,5e3)},[ge,le]),ye=f.find(e=>e.id===d)||null,{submitDraft:be,stopGeneration:Se,disconnectRun:we,resumeCheckpoint:Ee,submitAguiAction:De,respondToAguiApproval:Oe}=eM({agentId:i,currentSessionId:a,agentFramework:_,apiFormats:ne,selectedModel:d,selectedModelMetadata:ye,thinkingMode:h,permissionMode:g,uiCapabilities:T,isMobile:oe,api:r,currentSessionIdRef:he,agentIdRef:ge,queuedDraftRef:ie,onRunSettled:ve,onSessionCreated:e=>fe(e,!0),waitForPendingSessionCreation:pe});(0,b.useEffect)(()=>{ae.current=we},[we]);let Ae=(0,b.useCallback)(()=>{let e=he.current;_e.current?.abort(),O.getState().stopActivity(),O.getState().stopSessionActivity(e),Se()},[he,_e,Se]),je=(0,b.useCallback)(async()=>{let e=he.current,t=O.getState(),n=t.getSessionActivity(e)?.runId||t.currentRunId||``;if(e&&n)try{await r.cancelRun(i,e,n),O.getState().stopSessionActivity(e,`取消请求已发送,后台运行会停在最近 checkpoint。`)}catch(t){console.warn(`[App] cancelRun failed:`,t),O.getState().updateActivity({sessionId:e,status:`failed`,phase:`取消请求失败`,detail:t instanceof Error?t.message:String(t),countEvent:!1})}ve(e)},[r,i,he,ve]),{submitResponseFeedback:Me,deleteResponseFeedback:Ne,respondToApproval:Pe}=dM({agentId:i,currentSessionId:a,isStreaming:o,api:r,submitDraft:be}),Fe=(0,b.useRef)(Pe),Ie=(0,b.useRef)(Oe);(0,b.useEffect)(()=>{Fe.current=Pe,Ie.current=Oe},[Pe,Oe]);let{pending:Le,records:Re,respond:ze,localCatalog:Be}=fM({agentId:i,getAgentId:()=>ge.current,currentSessionId:a,api:r,interactionV1Enabled:!!T.InteractionV1,legacyResponsesApproval:(e,t)=>{Fe.current({approvalRequestId:e,approve:t})},legacyAguiResume:(e,t,n)=>Ie.current({interruptId:e,approve:t===`resolved`})});Kc({fetchSessions:le},void 0,r),(0,b.useEffect)(()=>{ge.current=i,kt(i,a)},[i,a,ge]),(0,b.useEffect)(()=>{oe?w.getState().setWorkspacePanelFullscreen(!1):(w.getState().setMobileSidebarOpen(!1),w.getState().setMobileActionsOpen(!1))},[oe]),(0,b.useEffect)(()=>{te||w.getState().setWorkspacePanelFullscreen(!1)},[te]),(0,b.useEffect)(()=>()=>{_e.current?.abort()},[_e]);let Ve=xe(T),He=!!T.Thinking,Ue=Ct({workspaceFiles:v,accessMode:y}),We=xt({isMobile:oe}),Ge=It({capability:T.NativeDashboard,agentFramework:_,accessMode:y,origin:window.location.origin}),Ke=!Ve,qe=_===`openclaw`?`OpenClaw`:_===`hermes`?`Hermes`:`原生运行时`,Je=ye?.display_name||d||``,Ye=!oe&&s&&Ve,Xe=(0,b.useRef)(!1),[$e,et]=(0,b.useState)(t===`tui`),tt=$e&&!!T.NativeTerminal?.Enabled;(0,b.useEffect)(()=>{Xe.current||t!==`workspace`||!Ue||(Xe.current=!0,w.getState().setWorkspacePanelOpen(!0),w.getState().setWorkspacePanelFullscreen(!0))},[t,Ue]);let rt=()=>{w.getState().setWorkspacePanelFullscreen(!1),w.getState().setWorkspacePanelOpen(!1)};if(x!==`ready`){let e=x===`auth-required`,t=(0,U.jsx)(`div`,{className:`ksadk-web`,children:(0,U.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,U.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,U.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:x===`loading`?`…`:`↗`}),(0,U.jsx)(`h1`,{className:`text-xl font-semibold`,children:x===`loading`?`正在连接 Agent`:e?`需要有效的访问链接`:`Agent 暂时无法连接`}),x===`loading`?null:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`p`,{className:`mt-3 text-sm leading-6 text-slate-500 dark:text-slate-400`,children:[ee,e?` 请从 AgentEngine 控制台重新打开 Dashboard,或使用 agentengine dashboard open 获取临时链接。`:``]}),(0,U.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,U.jsx)(n,{children:t}):t}let it=(0,U.jsx)(`div`,{className:`ksadk-web`,children:(0,U.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,U.jsx)(Rne,{uiCapabilities:T,createNewSession:de,deleteSession:me,loadSession:D,loadMoreSessions:E}),(0,U.jsxs)(`main`,{className:`relative flex min-w-0 flex-1 flex-col bg-white dark:bg-slate-900`,children:[(0,U.jsx)(cY,{agentName:u,currentSessionId:a,nativeLauncherMode:Ke,isMobile:oe,sidebarOpen:s,mobileSidebarOpen:c,onToggleSidebar:()=>{oe?w.getState().toggleMobileSidebar():w.getState().toggleSidebar()},availableModels:f,selectedModel:d,onSelectModel:e=>{Te.getState().setSelectedModel(e),oe&&w.getState().setMobileActionsOpen(!1)},selectedModelLabel:Je,modelCatalogLoaded:m,modelSource:p,thinkingEnabled:He,thinkingMode:h,onSelectThinkingMode:e=>Te.getState().setThinkingMode(Rt(e)),mobileActionsOpen:l,onMobileActionsOpenChange:e=>w.getState().setMobileActionsOpen(e),workspaceEnabled:Ue,onOpenWorkspace:()=>w.getState().setWorkspacePanelOpen(!0),nativeManagementLink:Ge,nativeTerminal:T.NativeTerminal}),Ke?(0,U.jsx)(uY,{productLabel:qe,nativeManagementLink:Ge,nativeTerminal:T.NativeTerminal,workspaceEnabled:Ue,onOpenWorkspace:()=>w.getState().setWorkspacePanelOpen(!0)}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(UJ,{agentName:u,isMobile:oe,onDeleteFeedback:Ne,onSubmitFeedback:Me,onRespondToApproval:Pe,onRespondToAguiApproval:Oe,onSubmitAguiAction:De,onStopGeneration:Ae,onCancelRemote:T.StopRun?je:void 0,checkpointResumeEnabled:T.RunLifecycle.Enabled&&T.RunLifecycle.Checkpoints&&T.RunLifecycle.CheckpointResume,onResumeCheckpoint:Ee,onLoadOlderSessionMessages:ue,interactionRecords:Re}),(0,U.jsx)(aY,{onCompactContext:T.ContextCompaction&&r.compactSession?async()=>{if(!(!a||!r.compactSession)){if((await r.compactSession(i,a)).Status!==`completed`)throw Error(`运行时尚未确认压缩完成`);await le(i,a)}}:void 0,composerMaxHeight:ce,submitDraft:be,stopGeneration:Ae,cancelRemote:T.StopRun?je:void 0,isMobile:oe,attachmentsEnabled:T.Attachments!==!1,approvalEnabled:!!T.Approval&&T.ApprovalPolicy?.RuntimeOverride!==!1,approvalPolicy:T.ApprovalPolicy,thinkingEnabled:He,runtimeCapabilityMatrix:T.RuntimeCapabilityMatrix,pendingInteractions:Le,onRespondInteraction:e=>{ze(e)},localCatalog:Be})]})]}),(0,U.jsx)(Dce,{agentId:i,capability:v,workspacePanelOpen:te,workspacePanelWidth:S,workspacePanelFullscreen:C,isMobile:oe,workspaceEnabled:Ue,workspaceFiles:v,workspacePanelPresentation:We,closeWorkspacePanel:rt,handleWorkspacePanelResizeStart:e=>{if(C||oe)return;e.preventDefault();let t=e.clientX,n=S,r=Ve&&Ye?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;w.getState().setWorkspacePanelWidth(xl(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:r}),re&&(0,U.jsx)(b.Suspense,{fallback:null,children:(0,U.jsx)(kce,{})}),tt?(0,U.jsx)(b.Suspense,{fallback:null,children:(0,U.jsx)(Ace,{capability:T.NativeTerminal,open:!0,sessionId:a,onClose:()=>et(!1)})}):null]})});return n?(0,U.jsx)(n,{children:it}):it}function Mce(){return(0,U.jsx)(jce,{})}function Nce(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`,Pce=class extends b.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){if(console.error(`UI 渲染错误:`,e,t),Nce(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,U.jsx)(`div`,{className:`flex h-screen w-screen items-center justify-center bg-slate-50 dark:bg-slate-900`,children:(0,U.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,U.jsx)(`div`,{className:`mb-4 text-4xl`,children:`⚠`}),(0,U.jsx)(`h1`,{className:`mb-2 text-xl font-semibold text-red-600 dark:text-red-400`,children:`页面渲染出错`}),(0,U.jsx)(`p`,{className:`mb-6 text-sm text-slate-600 dark:text-slate-400`,children:this.state.error?.message||`发生了未知错误,请刷新页面重试。`}),(0,U.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 Fce(){let e=w(e=>e.toasts),t=w(e=>e.dismissToast);return(0,b.useEffect)(()=>{if(!e.length)return;let n=e[0],r=3e3-(Date.now()-n.createdAt);if(r<=0){t(n.id);return}let i=setTimeout(()=>t(n.id),r);return()=>clearTimeout(i)},[e,t]),e.length?(0,U.jsx)(`div`,{className:`fixed bottom-4 right-4 z-50 flex flex-col gap-2`,children:e.map(e=>(0,U.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,U.jsx)(`span`,{className:`flex-1`,children:e.message}),(0,U.jsx)(`button`,{onClick:()=>t(e.id),className:`shrink-0 rounded p-0.5 opacity-70 hover:opacity-100`,children:(0,U.jsx)(aP,{size:14})})]},e.id))}):null}C.createRoot(document.getElementById(`root`)).render((0,U.jsxs)(Pce,{children:[(0,U.jsx)(Mce,{}),(0,U.jsx)(Fce,{})]}));export{pB as $,m3 as A,HX as B,I6 as C,o as Ct,Z as D,f6 as E,S3 as F,hq as G,cZ as H,K3 as I,YW as J,$K as K,S2 as L,_3 as M,H3 as N,d3 as O,W3 as P,IH as Q,j2 as R,P6 as S,p as St,s6 as T,l as Tt,sJ as U,lX as V,J as W,GH as X,KU as Y,KH as Z,Jie as _,gN as _t,xse as a,Ez as at,$6 as b,Ww as bt,L6 as c,zne as ct,V6 as d,tP as dt,oB as et,O8 as f,XN as ft,Wie as g,_N as gt,Uie as h,xN as ht,Z7 as i,Oz as it,v3 as j,x3 as k,Q as l,K as lt,F6 as m,HN as mt,K9 as n,tre as nt,rce as o,az as ot,Gie as p,WN as pt,XK as q,Y7 as r,Dz as rt,Mie as s,Bne as st,G9 as t,Yz as tt,q6 as u,aP as ut,r8 as v,lN as vt,z6 as w,s as wt,J6 as x,Qe as xt,n8 as y,aN as yt,Y as z};
|