@kabmo-labs/kabmo 0.53.1 → 0.54.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +529 -518
  3. package/dist/client/static/js/{Body-3v975hq3.js → Body-x5grdps8.js} +1 -1
  4. package/dist/client/static/js/{CsvGrid-8xcj58sw.js → CsvGrid-248v9yzf.js} +1 -1
  5. package/dist/client/static/js/{DocxView-fwmfpsg7.js → DocxView-5we92k2h.js} +1 -1
  6. package/dist/client/static/js/{DrawioView-gdtqj2vv.js → DrawioView-c6xmw4qq.js} +1 -1
  7. package/dist/client/static/js/{HtmlPreview-g4bp5mgq.js → HtmlPreview-r3qxgqg6.js} +1 -1
  8. package/dist/client/static/js/{ImageView-5e3vdyc9.js → ImageView-cr4fea18.js} +1 -1
  9. package/dist/client/static/js/{LayoutWrapper-ssxr6q2d.js → LayoutWrapper-j12z0djx.js} +2 -2
  10. package/dist/client/static/js/MergeDiffView-y0we0194.js +1 -0
  11. package/dist/client/static/js/{Modal-px8tcv9m.js → Modal-cqceypcn.js} +11 -11
  12. package/dist/client/static/js/{PdfView-92rx0s88.js → PdfView-xdgn31cm.js} +1 -1
  13. package/dist/client/static/js/{SessionsView-s3d9nceb.js → SessionsView-ms6z44e2.js} +1 -1
  14. package/dist/client/static/js/{SheetView-yeg7gtf9.js → SheetView-peqm9vft.js} +1 -1
  15. package/dist/client/static/js/{SvgPreview-6evr72fg.js → SvgPreview-rdf4wbzr.js} +1 -1
  16. package/dist/client/static/js/{abnfDiagram-O67JEVCF-a6n0cab2.js → abnfDiagram-O67JEVCF-48z2x5vg.js} +1 -1
  17. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-z9k17qfg.js → architectureDiagram-NJMV4G6O-n1pr5s6j.js} +1 -1
  18. package/dist/client/static/js/{blockDiagram-BEXU5L5S-63d683v3.js → blockDiagram-BEXU5L5S-p19shaft.js} +1 -1
  19. package/dist/client/static/js/{c4Diagram-YGBWAQC7-5bk6kv13.js → c4Diagram-YGBWAQC7-qcd46ts2.js} +1 -1
  20. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-s6rmr6vt.js → classDiagram-v2-NBCMYWYE-scyhe133.js} +1 -1
  21. package/dist/client/static/js/{cose-bilkent-JH36ORCC-wd5v7q2m.js → cose-bilkent-JH36ORCC-srnnj3f7.js} +1 -1
  22. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-j71tvbhy.js → cynefinDiagram-VND7K2PF-1zfrnyay.js} +1 -1
  23. package/dist/client/static/js/{dagre-6A5THRUB-q6x3d9xb.js → dagre-6A5THRUB-hepk25pz.js} +1 -1
  24. package/dist/client/static/js/{diagram-22UHCM2B-g6e427jm.js → diagram-22UHCM2B-wy2y0323.js} +1 -1
  25. package/dist/client/static/js/{diagram-3UASUU5V-rg3nty46.js → diagram-3UASUU5V-j904f93p.js} +1 -1
  26. package/dist/client/static/js/{diagram-ATOU4E4O-m82xv6ka.js → diagram-ATOU4E4O-2mmxccm2.js} +2 -2
  27. package/dist/client/static/js/{diagram-CDSNMT55-q3aa8sv0.js → diagram-CDSNMT55-cfhk73ty.js} +3 -3
  28. package/dist/client/static/js/{diagram-MLGK6HIB-nkyd150x.js → diagram-MLGK6HIB-ryf8j6hf.js} +1 -1
  29. package/dist/client/static/js/{diagram-MPIPVDR6-1gchkss2.js → diagram-MPIPVDR6-8k5e36sd.js} +2 -2
  30. package/dist/client/static/js/{dockerfile-f51g7549.js → dockerfile-1e7deann.js} +1 -1
  31. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-4dsm3p06.js → ebnfDiagram-ZINNZB2B-5kkbbbhv.js} +1 -1
  32. package/dist/client/static/js/{elk-276RUBZZ-d8wtwxae.js → elk-276RUBZZ-jqc4mzvc.js} +1 -1
  33. package/dist/client/static/js/{erDiagram-OPXOYQCR-bq865cmc.js → erDiagram-OPXOYQCR-kx15t6f0.js} +1 -1
  34. package/dist/client/static/js/flowDiagram-KWPJA3E3-dpjz82p8.js +1 -0
  35. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-ndnqbbzn.js → ganttDiagram-FUAMR5RP-3hv8pej4.js} +1 -1
  36. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-d9y6fnz0.js → gitGraphDiagram-X574FWY7-a4mq8vwz.js} +2 -2
  37. package/dist/client/static/js/{index-z0vvdpkv.js → index-01rdknec.js} +1 -1
  38. package/dist/client/static/js/{index-0ccj7j87.js → index-0j5ng1qc.js} +1 -1
  39. package/dist/client/static/js/{index-gm9cqsqg.js → index-0z7kerp1.js} +1 -1
  40. package/dist/client/static/js/{index-f7sssx5h.js → index-1ye834yz.js} +1 -1
  41. package/dist/client/static/js/{index-h9p3748x.js → index-317v49ey.js} +2 -2
  42. package/dist/client/static/js/{index-046kc8ft.js → index-3kenmzbe.js} +1 -1
  43. package/dist/client/static/js/{index-k8ks184k.js → index-40fdtqvw.js} +1 -1
  44. package/dist/client/static/js/{index-8k568z0z.js → index-40ydm28n.js} +1 -1
  45. package/dist/client/static/js/{index-0fpc1h6v.js → index-51wzt3ma.js} +1 -1
  46. package/dist/client/static/js/{index-7jr49rd4.js → index-8hnem33f.js} +1 -1
  47. package/dist/client/static/js/{index-6pxh5p8g.js → index-937bn0d2.js} +1 -1
  48. package/dist/client/static/js/{index-049xtm14.js → index-9cr6p86f.js} +1 -1
  49. package/dist/client/static/js/{index-7fkdwm69.js → index-9gddw5qy.js} +1 -1
  50. package/dist/client/static/js/{index-v8fztm3w.js → index-bf54x0w8.js} +1 -1
  51. package/dist/client/static/js/{index-4pwk5cjy.js → index-br27jz2t.js} +1 -1
  52. package/dist/client/static/js/{index-w39c85k3.js → index-demg0p74.js} +1 -1
  53. package/dist/client/static/js/{index-pd4s49n5.js → index-e2y4hkps.js} +1 -1
  54. package/dist/client/static/js/{index-gr5wd7hv.js → index-eb43hnd3.js} +1 -1
  55. package/dist/client/static/js/{index-hav1hhbr.js → index-exyg9sna.js} +1 -1
  56. package/dist/client/static/js/{index-25g1ydkd.js → index-fanhvjk8.js} +1 -1
  57. package/dist/client/static/js/{index-xf662xsf.js → index-g3x4w48f.js} +1 -1
  58. package/dist/client/static/js/{index-8w69r0c4.js → index-jvn2xfpt.js} +135 -135
  59. package/dist/client/static/js/{index-mttf7ej7.js → index-k4kwrze2.js} +1 -1
  60. package/dist/client/static/js/{index-rc8f8gjk.js → index-kevqayd9.js} +1 -1
  61. package/dist/client/static/js/{index-mnadx740.js → index-kvker1ps.js} +1 -1
  62. package/dist/client/static/js/{index-vjk01ja9.js → index-kz5d00m5.js} +1 -1
  63. package/dist/client/static/js/{index-bcns8arc.js → index-m85c740p.js} +1 -1
  64. package/dist/client/static/js/{index-53hrj27y.js → index-n3cts2j1.js} +1 -1
  65. package/dist/client/static/js/{index-hn0brpdf.js → index-n4pm0hrh.js} +4 -4
  66. package/dist/client/static/js/{index-9eddntv4.js → index-n5194pe6.js} +11 -11
  67. package/dist/client/static/js/{index-6775m1pa.js → index-p8bta9ae.js} +1 -1
  68. package/dist/client/static/js/{index-stfccv2r.js → index-pszsxhjr.js} +1 -1
  69. package/dist/client/static/js/{index-79qddnbx.js → index-rtfw07hy.js} +1 -1
  70. package/dist/client/static/js/{index-xakrt0sx.js → index-v90zd3sq.js} +1 -1
  71. package/dist/client/static/js/{index-g46qcgp8.js → index-vxe4e903.js} +1 -1
  72. package/dist/client/static/js/{index-pnjnvdvb.js → index-w4dep7k6.js} +1 -1
  73. package/dist/client/static/js/{index-2jtkrmry.js → index-x5c5yxhj.js} +1 -1
  74. package/dist/client/static/js/{index-5g21qv2b.js → index-xhcbaaga.js} +2 -2
  75. package/dist/client/static/js/{infoDiagram-VRGFBTTK-t52bsrem.js → infoDiagram-VRGFBTTK-wtnqb06v.js} +1 -1
  76. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-vysv38pr.js → ishikawaDiagram-OU5B5YK6-eta0jnvr.js} +1 -1
  77. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-7222yn0y.js → journeyDiagram-ZHPQQLJL-4e572kkp.js} +1 -1
  78. package/dist/client/static/js/{kanban-definition-PNTS6WVX-9cg88rcn.js → kanban-definition-PNTS6WVX-yrtnn4zy.js} +1 -1
  79. package/dist/client/static/js/{mermaid.core-3qc3zvgb.js → mermaid.core-195b0fb6.js} +3 -3
  80. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-hdbsk349.js → mindmap-definition-NLK3R4M7-pphjnkvt.js} +1 -1
  81. package/dist/client/static/js/one-dark-pro-asy2qj2p.js +1 -0
  82. package/dist/client/static/js/one-light-fya1pbbx.js +1 -0
  83. package/dist/client/static/js/{pegDiagram-GJSIUBJH-jtqqcrhq.js → pegDiagram-GJSIUBJH-kgffb9p3.js} +1 -1
  84. package/dist/client/static/js/{pieDiagram-5QR66LMP-2c82jghr.js → pieDiagram-5QR66LMP-efech3mm.js} +2 -2
  85. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-vp2hw2a8.js → quadrantDiagram-O4NWA36T-khf9cv3t.js} +1 -1
  86. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-4168nq4f.js → railroadDiagram-XR7U4H2S-ye68kdx2.js} +1 -1
  87. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-gwqcyxag.js → requirementDiagram-PLB6GJNP-3s4smnme.js} +1 -1
  88. package/dist/client/static/js/{rust-6m8myprw.js → rust-tdrnaxp3.js} +1 -1
  89. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-y5fakn56.js → sankeyDiagram-IPEJSGJF-9pqd25mc.js} +1 -1
  90. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-z140kern.js → sequenceDiagram-PO4LG4MO-rka8ct43.js} +1 -1
  91. package/dist/client/static/js/{sizeCapture-INFHLROL-gfez373x.js → sizeCapture-INFHLROL-g5wkzry8.js} +1 -1
  92. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-1d6h03nr.js → stateDiagram-v2-GCMORJYK-gy1zab2j.js} +1 -1
  93. package/dist/client/static/js/{swimlanes-2SLR337P-75wg3n6d.js → swimlanes-2SLR337P-kr35nmd2.js} +1 -1
  94. package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-18fj17m7.js → swimlanesDiagram-TC7HE7FX-qnhxxmjr.js} +1 -1
  95. package/dist/client/static/js/{timeline-definition-EJHVYXUP-q750z70f.js → timeline-definition-EJHVYXUP-sg151mkc.js} +1 -1
  96. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-9q7tg456.js → usecaseDiagram-POWQR4AR-f91g61p3.js} +1 -1
  97. package/dist/client/static/js/{vennDiagram-UO4OBE2U-010nw1kd.js → vennDiagram-UO4OBE2U-zbhr4eqf.js} +2 -2
  98. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-7n33n10f.js → wardleyDiagram-VNRHLVJA-6302414n.js} +2 -2
  99. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-7q0n5vvd.js → xychartDiagram-PMCCYNJV-0a47th65.js} +2 -2
  100. package/package.json +2 -2
  101. package/src/client/App.tsx +4 -0
  102. package/src/client/bootstrap.d.ts +11 -0
  103. package/src/client/components/workspace/git-panel/index.test.ts +56 -7
  104. package/src/client/components/workspace/git-panel/index.tsx +9 -4
  105. package/src/client/components/workspace/repo-picker/index.test.tsx +29 -2
  106. package/src/client/data/settings/omp-schema.json +11 -1
  107. package/src/client/hooks/shell/last-opened-session.test.ts +166 -0
  108. package/src/client/hooks/shell/last-opened-session.ts +74 -0
  109. package/src/client/hooks/workspace/commit-box.ts +6 -1
  110. package/src/client/lib/router/open-session.test.ts +8 -0
  111. package/src/client/lib/router/open-session.ts +9 -4
  112. package/src/client/main.tsx +7 -0
  113. package/src/server/lib/db/schema.ts +10 -0
  114. package/src/server/lib/fs/fs-write-git.test.ts +17 -0
  115. package/src/server/lib/fs/git-repos.ts +32 -11
  116. package/src/server/lib/sessions/last-opened-client.server.ts +86 -0
  117. package/src/server/lib/sessions/last-opened-client.test.ts +91 -0
  118. package/src/server/lib/sessions/last-opened.server.test.ts +127 -0
  119. package/src/server/lib/sessions/last-opened.server.ts +129 -0
  120. package/src/server/plugins/ssr.ts +40 -17
  121. package/src/server/routes/sessions/index.ts +14 -0
  122. package/src/server/routes/sessions/last-opened.test.ts +139 -0
  123. package/src/server/routes/sessions/last-opened.ts +66 -0
  124. package/src/shared/lib/omp/config/schema-releases.test.ts +15 -0
  125. package/dist/client/static/js/MergeDiffView-6t5t6exc.js +0 -1
  126. package/dist/client/static/js/flowDiagram-KWPJA3E3-z01c78q6.js +0 -1
  127. package/dist/client/static/js/one-dark-pro-3570ra7e.js +0 -1
  128. package/dist/client/static/js/one-light-3v5yk200.js +0 -1
@@ -1,4 +1,4 @@
1
- import{n,o,K,i,u,a,Ze,e,bl,we,nn,Qm,ps,Rm,Lm,lo,ys,jd,W0,K0}from"./index-8w69r0c4.js";import{ke,Ct,x,P,Oe,Ir,An,oe,me,Nn,ge,lt,ma,Hr,Mt,D,Ge,wn,ye,_,ho,Qn,Oi,Zu}from"./index-4kchzh9y.js";import{qA,Xu}from"./index-hav1hhbr.js";var fi=600,hi=150,At=1,St=new Map;function mp(t){if(!t)return;St.get(t)?.()}function Zs({tabKey:t,surface:r,ready:s=!0,slot:l=jd,element:f}){let h=Ze(bl),c=h?.sessionId??null,d=h?.ready??!1,m=i(null),p=i(null),g=i(0),b=i(!1),k=i(0),v=i(!1),w=i(null),B=i(),M=a(()=>{let L=p.current,S=m.current;if(!L||!S)return;if(performance.now()>L.until){p.current=null;return}if(Math.abs(S.scrollTop-L.top)<At){k.current=S.scrollTop;return}b.current=!0,S.scrollTop=L.top,b.current=!1,g.current=S.scrollTop,k.current=S.scrollTop},[]),O=a((L)=>{if(m.current=L,L)M()},[M]),F=a((L)=>{if(!t)return;let S=we(c,l);if((S?.[t]?.[r]??0)===L)return;nn(c,l,K0(S,t,r,L))},[c,l,t,r]),N=a(()=>{let L=m.current;if(!L||!t)return;let S=L.scrollTop;if(p.current){if(b.current)return;let E=Math.abs(S-k.current)>=At;if(k.current=S,E&&!v.current){M();return}if(Math.abs(S-g.current)<At*2)return;p.current=null}k.current=S,v.current=!1,w.current=S,clearTimeout(B.current),B.current=setTimeout(()=>{B.current=void 0;let E=w.current;if(E!==null)F(E)},hi)},[M,F,t]);return o(()=>{if(!f)return;let L=()=>N();return f.addEventListener("scroll",L,{passive:!0}),()=>f.removeEventListener("scroll",L)},[f,N]),o(()=>{let L=f??m.current;if(!L)return;let S=()=>{v.current=!0},E=["wheel","keydown","pointerdown","touchstart"];for(let y of E)L.addEventListener(y,S,{passive:!0});return window.addEventListener("keydown",S,{passive:!0}),()=>{for(let y of E)L.removeEventListener(y,S);window.removeEventListener("keydown",S)}},[f]),K(()=>{p.current=null,w.current=null,v.current=!1;let L=null;if(f!==void 0)m.current=f;let S=m.current;if(s&&d&&t&&S){let E=W0(we(c,l),t,r);p.current={top:E,until:performance.now()+fi},St.set(S,()=>{p.current=null}),M();let y=S.firstElementChild;if(y&&typeof ResizeObserver<"u")L=new ResizeObserver(()=>M()),L.observe(y)}return()=>{if(S)St.delete(S);L?.disconnect(),clearTimeout(B.current),B.current=void 0;let E=w.current;if(w.current=null,E!==null)F(E)}},[s,d,t,r,c,l,M,F,f]),{ref:O,onScroll:N}}var ci=0;class Ye{constructor(t,r){this.from=t,this.to=r}}class Be{constructor(t={}){this.id=ci++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw Error("This node type doesn't define a deserialize function")}),this.combine=t.combine||null}add(t){if(this.perNode)throw RangeError("Can't add per-node props to node types");if(typeof t!="function")t=Y.match(t);return(r)=>{let s=t(r);return s===void 0?null:[this,s]}}}Be.closedBy=new Be({deserialize:(t)=>t.split(" ")});Be.openedBy=new Be({deserialize:(t)=>t.split(" ")});Be.group=new Be({deserialize:(t)=>t.split(" ")});Be.isolate=new Be({deserialize:(t)=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw RangeError("Invalid value for isolate: "+t);return t||"auto"}});Be.contextHash=new Be({perNode:!0});Be.lookAhead=new Be({perNode:!0});Be.mounted=new Be({perNode:!0});class Ee{constructor(t,r,s,l=!1){this.tree=t,this.overlay=r,this.parser=s,this.bracketed=l}static get(t){return t&&t.props&&t.props[Be.mounted.id]}}var ui=Object.create(null);class Y{constructor(t,r,s,l=0){this.name=t,this.props=r,this.id=s,this.flags=l}static define(t){let r=t.props&&t.props.length?Object.create(null):ui,s=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),l=new Y(t.name||"",r,t.id,s);if(t.props)for(let f of t.props){if(!Array.isArray(f))f=f(l);if(f){if(f[0].perNode)throw RangeError("Can't store a per-node prop on a node type");r[f[0].id]=f[1]}}return l}prop(t){return this.props[t.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(t){if(typeof t=="string"){if(this.name==t)return!0;let r=this.prop(Be.group);return r?r.indexOf(t)>-1:!1}return this.id==t}static match(t){let r=Object.create(null);for(let s in t)for(let l of s.split(" "))r[l]=t[s];return(s)=>{for(let l=s.prop(Be.group),f=-1;f<(l?l.length:0);f++){let h=r[f<0?s.name:l[f]];if(h)return h}}}}Y.none=new Y("",Object.create(null),0,8);class tt{constructor(t){this.types=t;for(let r=0;r<t.length;r++)if(t[r].id!=r)throw RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let r=[];for(let s of this.types){let l=null;for(let f of t){let h=f(s);if(h){if(!l)l=Object.assign({},s.props);let c=h[1],d=h[0];if(d.combine&&d.id in l)c=d.combine(l[d.id],c);l[d.id]=c}}r.push(l?new Y(s.name,l,s.id,s.flags):s)}return new tt(r)}}var Xe=new WeakMap,mr=new WeakMap,U;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(U||(U={}));class W{constructor(t,r,s,l,f){if(this.type=t,this.children=r,this.positions=s,this.length=l,this.props=null,f&&f.length){this.props=Object.create(null);for(let[h,c]of f)this.props[typeof h=="number"?h:h.id]=c}}toString(){let t=Ee.get(this);if(t&&!t.overlay)return t.tree.toString();let r="";for(let s of this.children){let l=s.toString();if(l){if(r)r+=",";r+=l}}return!this.type.name?r:(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(r.length?"("+r+")":"")}cursor(t=0){return new et(this.topNode,t)}cursorAt(t,r=0,s=0){let l=Xe.get(this)||this.topNode,f=new et(l);return f.moveTo(t,r),Xe.set(this,f._tree),f}get topNode(){return new Z(this,0,0,null)}resolve(t,r=0){let s=Fe(Xe.get(this)||this.topNode,t,r,!1);return Xe.set(this,s),s}resolveInner(t,r=0){let s=Fe(mr.get(this)||this.topNode,t,r,!0);return mr.set(this,s),s}resolveStack(t,r=0){return di(this,t,r)}iterate(t){let{enter:r,leave:s,from:l=0,to:f=this.length}=t,h=t.mode||0,c=(h&U.IncludeAnonymous)>0;for(let d=this.cursor(h|U.IncludeAnonymous);;){let m=!1;if(d.from<=f&&d.to>=l&&(!c&&d.type.isAnonymous||r(d)!==!1)){if(d.firstChild())continue;m=!0}for(;;){if(m&&s&&(c||!d.type.isAnonymous))s(d);if(d.nextSibling())break;if(!d.parent())return;m=!0}}}prop(t){return!t.perNode?this.type.prop(t):this.props?this.props[t.id]:void 0}get propValues(){let t=[];if(this.props)for(let r in this.props)t.push([+r,this.props[r]]);return t}balance(t={}){return this.children.length<=8?this:Ot(Y.none,this.children,this.positions,0,this.children.length,0,this.length,(r,s,l)=>new W(this.type,r,s,l,this.propValues),t.makeTree||((r,s,l)=>new W(Y.none,r,s,l)))}static build(t){return mi(t)}}W.empty=new W(Y.none,[],[],0);class Bt{constructor(t,r){this.buffer=t,this.index=r}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 Bt(this.buffer,this.index)}}class ce{constructor(t,r,s){this.buffer=t,this.length=r,this.set=s}get type(){return Y.none}toString(){let t=[];for(let r=0;r<this.buffer.length;)t.push(this.childString(r)),r=this.buffer[r+3];return t.join(",")}childString(t){let r=this.buffer[t],s=this.buffer[t+3],l=this.set.types[r],f=l.name;if(/\W/.test(f)&&!l.isError)f=JSON.stringify(f);if(t+=4,s==t)return f;let h=[];while(t<s)h.push(this.childString(t)),t=this.buffer[t+3];return f+"("+h.join(",")+")"}findChild(t,r,s,l,f){let{buffer:h}=this,c=-1;for(let d=t;d!=r;d=h[d+3])if(br(f,l,h[d+1],h[d+2])){if(c=d,s>0)break}return c}slice(t,r,s){let l=this.buffer,f=new Uint16Array(r-t),h=0;for(let c=t,d=0;c<r;){f[d++]=l[c++],f[d++]=l[c++]-s;let m=f[d++]=l[c++]-s;f[d++]=l[c++]-t,h=Math.max(h,m)}return new ce(f,h,this.set)}}function br(t,r,s,l){switch(t){case-2:return s<r;case-1:return l>=r&&s<r;case 0:return s<r&&l>r;case 1:return s<=r&&l>r;case 2:return l>r;case 4:return!0}}function Fe(t,r,s,l){var f;while(t.from==t.to||(s<1?t.from>=r:t.from>r)||(s>-1?t.to<=r:t.to<r)){let c=!l&&t instanceof Z&&t.index<0?null:t.parent;if(!c)return t;t=c}let h=l?0:U.IgnoreOverlays;if(l){for(let c=t,d=c.parent;d;c=d,d=c.parent)if(c instanceof Z&&c.index<0&&((f=d.enter(r,s,h))===null||f===void 0?void 0:f.from)!=c.from)t=d}for(;;){let c=t.enter(r,s,h);if(!c)return t;t=c}}class Et{cursor(t=0){return new et(this,t)}getChild(t,r=null,s=null){let l=pr(this,t,r,s);return l.length?l[0]:null}getChildren(t,r=null,s=null){return pr(this,t,r,s)}resolve(t,r=0){return Fe(this,t,r,!1)}resolveInner(t,r=0){return Fe(this,t,r,!0)}matchContext(t){return Dt(this.parent,t)}enterUnfinishedNodesBefore(t){let r=this.childBefore(t),s=this;while(r){let l=r.lastChild;if(!l||l.to!=r.to)break;if(l.type.isError&&l.from==l.to)s=r,r=l.prevSibling;else r=l}return s}get node(){return this}get next(){return this.parent}}class Z extends Et{constructor(t,r,s,l){super();this._tree=t,this.from=r,this.index=s,this._parent=l}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,r,s,l,f=0){for(let h=this;;){for(let{children:c,positions:d}=h._tree,m=r>0?c.length:-1;t!=m;t+=r){let p=c[t],g=d[t]+h.from,b;if(!(f&U.EnterBracketed&&p instanceof W&&(b=Ee.get(p))&&!b.overlay&&b.bracketed&&s>=g&&s<=g+p.length)&&!br(l,s,g,g+p.length))continue;if(p instanceof ce){if(f&U.ExcludeBuffers)continue;let k=p.findChild(0,p.buffer.length,r,s-g,l);if(k>-1)return new he(new kr(h,p,t,g),null,k)}else if(f&U.IncludeAnonymous||(!p.type.isAnonymous||Lt(p))){let k;if(!(f&U.IgnoreMounts)&&(k=Ee.get(p))&&!k.overlay)return new Z(k.tree,g,t,h);let v=new Z(p,g,t,h);return f&U.IncludeAnonymous||!v.type.isAnonymous?v:v.nextChild(r<0?p.children.length-1:0,r,s,l,f)}}if(f&U.IncludeAnonymous||!h.type.isAnonymous)return null;if(h.index>=0)t=h.index+r;else t=r<0?-1:h._parent._tree.children.length;if(h=h._parent,!h)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(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}prop(t){return this._tree.prop(t)}enter(t,r,s=0){let l;if(!(s&U.IgnoreOverlays)&&(l=Ee.get(this._tree))&&l.overlay){let f=t-this.from,h=s&U.EnterBracketed&&l.bracketed;for(let{from:c,to:d}of l.overlay)if((r>0||h?c<=f:c<f)&&(r<0||h?d>=f:d>f))return new Z(l.tree,l.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,r,s)}nextSignificantParent(){let t=this;while(t.type.isAnonymous&&t._parent)t=t._parent;return t}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 pr(t,r,s,l){let f=t.cursor(),h=[];if(!f.firstChild())return h;if(s!=null){for(let c=!1;!c;)if(c=f.type.is(s),!f.nextSibling())return h}for(;;){if(l!=null&&f.type.is(l))return h;if(f.type.is(r))h.push(f.node);if(!f.nextSibling())return l==null?h:[]}}function Dt(t,r,s=r.length-1){for(let l=t;s>=0;l=l.parent){if(!l)return!1;if(!l.type.isAnonymous){if(r[s]&&r[s]!=l.name)return!1;s--}}return!0}class kr{constructor(t,r,s,l){this.parent=t,this.buffer=r,this.index=s,this.start=l}}class he extends Et{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(t,r,s){super();this.context=t,this._parent=r,this.index=s,this.type=t.buffer.set.types[t.buffer.buffer[s]]}child(t,r,s){let{buffer:l}=this.context,f=l.findChild(this.index+4,l.buffer[this.index+3],t,r-this.context.start,s);return f<0?null:new he(this.context,this,f)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}prop(t){return this.type.prop(t)}enter(t,r,s=0){if(s&U.ExcludeBuffers)return null;let{buffer:l}=this.context,f=l.findChild(this.index+4,l.buffer[this.index+3],r>0?1:-1,t-this.context.start,r);return f<0?null:new he(this.context,this,f)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,r=t.buffer[this.index+3];if(r<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length))return new he(this.context,this._parent,r);return this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,r=this._parent?this._parent.index+4:0;if(this.index==r)return this.externalSibling(-1);return new he(this.context,this._parent,t.findChild(r,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],r=[],{buffer:s}=this.context,l=this.index+4,f=s.buffer[this.index+3];if(f>l){let h=s.buffer[this.index+1];t.push(s.slice(l,f,h)),r.push(0)}return new W(this.type,t,r,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function xr(t){if(!t.length)return null;let r=0,s=t[0];for(let h=1;h<t.length;h++){let c=t[h];if(c.from>s.from||c.to<s.to)s=c,r=h}let l=s instanceof Z&&s.index<0?null:s.parent,f=t.slice();if(l)f[r]=l;else f.splice(r,1);return new vr(f,s)}class vr{constructor(t,r){this.heads=t,this.node=r}get next(){return xr(this.heads)}}function di(t,r,s){let l=t.resolveInner(r,s),f=null;for(let h=l instanceof Z?l:l.context.parent;h;h=h.parent)if(h.index<0){let c=h.parent;(f||(f=[l])).push(c.resolve(r,s)),h=c}else{let c=Ee.get(h.tree);if(c&&c.overlay&&c.overlay[0].from<=r&&c.overlay[c.overlay.length-1].to>=r){let d=new Z(c.tree,c.overlay[0].from+h.from,-1,h);(f||(f=[l])).push(Fe(d,r,s,!1))}}return f?xr(f):l}class et{get name(){return this.type.name}constructor(t,r=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=r&~U.EnterBracketed,t instanceof Z)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let s=t._parent;s;s=s._parent)this.stack.unshift(s.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){if(!t)return!1;return this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0}yieldBuf(t,r){this.index=t;let{start:s,buffer:l}=this.buffer;return this.type=r||l.set.types[l.buffer[t]],this.from=s+l.buffer[t+1],this.to=s+l.buffer[t+2],!0}yield(t){if(!t)return!1;if(t instanceof Z)return this.buffer=null,this.yieldNode(t);return this.buffer=t.context,this.yieldBuf(t.index,t.type)}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,r,s){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,r,s,this.mode));let{buffer:l}=this.buffer,f=l.findChild(this.index+4,l.buffer[this.index+3],t,r-this.buffer.start,s);if(f<0)return!1;return this.stack.push(this.index),this.yieldBuf(f)}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,r,s=this.mode){if(!this.buffer)return this.yield(this._tree.enter(t,r,s));return s&U.ExcludeBuffers?!1:this.enterChild(1,t,r)}parent(){if(!this.buffer)return this.yieldNode(this.mode&U.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&U.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return!this._tree._parent?!1:this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode));let{buffer:r}=this.buffer,s=this.stack.length-1;if(t<0){let l=s<0?0:this.stack[s]+4;if(this.index!=l)return this.yieldBuf(r.findChild(l,this.index,-1,0,4))}else{let l=r.buffer[this.index+3];if(l<(s<0?r.buffer.length:r.buffer[this.stack[s]+3]))return this.yieldBuf(l)}return s<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let r,s,{buffer:l}=this;if(l){if(t>0){if(this.index<l.buffer.buffer.length)return!1}else for(let f=0;f<this.index;f++)if(l.buffer.buffer[f+3]<this.index)return!1;({index:r,parent:s}=l)}else({index:r,_parent:s}=this._tree);for(;s;{index:r,_parent:s}=s)if(r>-1)for(let f=r+t,h=t<0?-1:s._tree.children.length;f!=h;f+=t){let c=s._tree.children[f];if(this.mode&U.IncludeAnonymous||c instanceof ce||!c.type.isAnonymous||Lt(c))return!1}return!0}move(t,r){if(r&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,r=0){while(this.from==this.to||(r<1?this.from>=t:this.from>t)||(r>-1?this.to<=t:this.to<t))if(!this.parent())break;while(this.enterChild(1,t,r));return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,r=null,s=0;if(t&&t.context==this.buffer)e:for(let l=this.index,f=this.stack.length;f>=0;){for(let h=t;h;h=h._parent)if(h.index==l){if(l==this.index)return h;r=h,s=f+1;break e}l=this.stack[--f]}for(let l=s;l<this.stack.length;l++)r=new he(this.buffer,r,this.stack[l]);return this.bufferNode=new he(this.buffer,r,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,r){for(let s=0;;){let l=!1;if(this.type.isAnonymous||t(this)!==!1){if(this.firstChild()){s++;continue}if(!this.type.isAnonymous)l=!0}for(;;){if(l&&r)r(this);if(l=this.type.isAnonymous,!s)return;if(this.nextSibling())break;this.parent(),s--,l=!0}}}matchContext(t){if(!this.buffer)return Dt(this.node.parent,t);let{buffer:r}=this.buffer,{types:s}=r.set;for(let l=t.length-1,f=this.stack.length-1;l>=0;f--){if(f<0)return Dt(this._tree,t,l);let h=s[r.buffer[this.stack[f]]];if(!h.isAnonymous){if(t[l]&&t[l]!=h.name)return!1;l--}}return!0}}function Lt(t){return t.children.some((r)=>r instanceof ce||!r.type.isAnonymous||Lt(r))}function mi(t){var r;let{buffer:s,nodeSet:l,maxBufferLength:f=1024,reused:h=[],minRepeatType:c=l.types.length}=t,d=Array.isArray(s)?new Bt(s,s.length):s,m=l.types,p=0,g=0;function b(S,E,y,I,V,H){let{id:R,start:T,end:z,size:G}=d,J=g,fe=p;if(G<0)if(d.next(),G==-1){let le=h[R];y.push(le),I.push(T-S);return}else if(G==-3){p=R;return}else if(G==-4){g=R;return}else throw RangeError(`Unrecognized record size: ${G}`);let Ne=m[R],Je,be,ur=T-S;if(z-T<=f&&(be=M(d.pos-E,V))){let le=new Uint16Array(be.size-be.skip),Q=d.pos-be.size,re=le.length;while(d.pos>Q)re=O(be.start,le,re);Je=new ce(le,z-be.start,l),ur=be.start-S}else{let le=d.pos-G;d.next();let Q=[],re=[],xe=R>=c?R:-1,De=0,Ke=z,yt=J;while(d.pos>le)if(xe>=0&&d.id==xe&&d.size>=0){if(d.end<=Ke-f)w(Q,re,T,De,d.end,Ke,xe,yt,fe),De=Q.length,Ke=d.end,yt=g;d.next()}else if(H>2500)k(T,le,Q,re);else b(T,le,Q,re,xe,H+1);if(xe>=0&&De>0&&De<Q.length)w(Q,re,T,De,T,Ke,xe,yt,fe);if(Q.reverse(),re.reverse(),xe>-1&&De>0){let dr=v(Ne,fe);Je=Ot(Ne,Q,re,0,Q.length,0,z-T,dr,dr)}else Je=B(Ne,Q,re,z-T,J-z,fe)}y.push(Je),I.push(ur)}function k(S,E,y,I){let V=[],H=0,R=-1;while(d.pos>E){let{id:T,start:z,end:G,size:J}=d;if(J>4)d.next();else if(R>-1&&z<R)break;else{if(R<0)R=G-f;V.push(T,z,G),H++,d.next()}}if(H){let T=new Uint16Array(H*4),z=V[V.length-2];for(let G=V.length-3,J=0;G>=0;G-=3)T[J++]=V[G],T[J++]=V[G+1]-z,T[J++]=V[G+2]-z,T[J++]=J;y.push(new ce(T,V[2]-z,l)),I.push(z-S)}}function v(S,E){return(y,I,V)=>{let H=0,R=y.length-1,T,z;if(R>=0&&(T=y[R])instanceof W){if(!R&&T.type==S&&T.length==V)return T;if(z=T.prop(Be.lookAhead))H=I[R]+T.length+z-V}return B(S,y,I,V,H,E)}}function w(S,E,y,I,V,H,R,T,z){let G=[],J=[];while(S.length>I)G.push(S.pop()),J.push(E.pop()+y-V);S.push(B(l.types[R],G,J,H-V,T-H,z)),E.push(V-y)}function B(S,E,y,I,V,H,R){if(H){let T=[Be.contextHash,H];R=R?[T].concat(R):[T]}if(V>25){let T=[Be.lookAhead,V];R=R?[T].concat(R):[T]}return new W(S,E,y,I,R)}function M(S,E){let y=d.fork(),I=0,V=0,H=0,R=y.end-f,T={size:0,start:0,skip:0};e:for(let z=y.pos-S;y.pos>z;){let G=y.size;if(y.id==E&&G>=0){T.size=I,T.start=V,T.skip=H,H+=4,I+=4,y.next();continue}let J=y.pos-G;if(G<0||J<z||y.start<R)break;let fe=y.id>=c?4:0,Ne=y.start;y.next();while(y.pos>J){if(y.size<0)if(y.size==-3||y.size==-4)fe+=4;else break e;else if(y.id>=c)fe+=4;y.next()}V=Ne,I+=G,H+=fe}if(E<0||I==S)T.size=I,T.start=V,T.skip=H;return T.size>4?T:void 0}function O(S,E,y){let{id:I,start:V,end:H,size:R}=d;if(d.next(),R>=0&&I<c){let T=y;if(R>4){let z=d.pos-(R-4);while(d.pos>z)y=O(S,E,y)}E[--y]=T,E[--y]=H-S,E[--y]=V-S,E[--y]=I}else if(R==-3)p=I;else if(R==-4)g=I;return y}let F=[],N=[];while(d.pos>0)b(t.start||0,t.bufferStart||0,F,N,-1,0);let L=(r=t.length)!==null&&r!==void 0?r:F.length?N[0]+F[0].length:0;return new W(m[t.topID],F.reverse(),N.reverse(),L)}var gr=new WeakMap;function Qe(t,r){if(!t.isAnonymous||r instanceof ce||r.type!=t)return 1;let s=gr.get(r);if(s==null){s=1;for(let l of r.children){if(l.type!=t||!(l instanceof W)){s=1;break}s+=Qe(t,l)}gr.set(r,s)}return s}function Ot(t,r,s,l,f,h,c,d,m){let p=0;for(let w=l;w<f;w++)p+=Qe(t,r[w]);let g=Math.ceil(p*1.5/8),b=[],k=[];function v(w,B,M,O,F){for(let N=M;N<O;){let L=N,S=B[N],E=Qe(t,w[N]);N++;for(;N<O;N++){let y=Qe(t,w[N]);if(E+y>=g)break;E+=y}if(N==L+1){if(E>g){let y=w[L];v(y.children,y.positions,0,y.children.length,B[L]+F);continue}b.push(w[L])}else{let y=B[N-1]+w[N-1].length-S;b.push(Ot(t,w,B,L,N,S,y,null,m))}k.push(S+F-h)}}return v(r,s,l,f,0),(d||m)(b,k,c)}class ue{constructor(t,r,s,l,f=!1,h=!1){this.from=t,this.to=r,this.tree=s,this.offset=l,this.open=(f?1:0)|(h?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,r=[],s=!1){let l=[new ue(0,t.length,t,0,!1,s)];for(let f of r)if(f.to>t.length)l.push(f);return l}static applyChanges(t,r,s=128){if(!r.length)return t;let l=[],f=1,h=t.length?t[0]:null;for(let c=0,d=0,m=0;;c++){let p=c<r.length?r[c]:null,g=p?p.fromA:1e9;if(g-d>=s)while(h&&h.from<g){let b=h;if(d>=b.from||g<=b.to||m){let k=Math.max(b.from,d)-m,v=Math.min(b.to,g)-m;b=k>=v?null:new ue(k,v,b.tree,b.offset+m,c>0,!!p)}if(b)l.push(b);if(h.to>g)break;h=f<t.length?t[f++]:null}if(!p)break;d=p.toA,m=p.toA-p.toB}return l}}class rt{startParse(t,r,s){if(typeof t=="string")t=new wr(t);return s=!s?[new Ye(0,t.length)]:s.length?s.map((l)=>new Ye(l.from,l.to)):[new Ye(0,0)],this.createParse(t,r||[],s)}parse(t,r,s){let l=this.startParse(t,r,s);for(;;){let f=l.advance();if(f)return f}}}class wr{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,r){return this.string.slice(t,r)}}var so=new Be({perNode:!0});var pi=0;class ee{constructor(t,r,s,l){this.name=t,this.set=r,this.base=s,this.modified=l,this.id=pi++}toString(){let{name:t}=this;for(let r of this.modified)if(r.name)t=`${r.name}(${t})`;return t}static define(t,r){let s=typeof t=="string"?t:"?";if(t instanceof ee)r=t;if(r===null||r===void 0?void 0:r.base)throw Error("Can not derive from a modified tag");let l=new ee(s,[],null,[]);if(l.set.push(l),r)for(let f of r.set)l.set.push(f);return l}static defineModifier(t){let r=new ot(t);return(s)=>{if(s.modified.indexOf(r)>-1)return s;return ot.get(s.base||s,s.modified.concat(r).sort((l,f)=>l.id-f.id))}}}var gi=0;class ot{constructor(t){this.name=t,this.instances=[],this.id=gi++}static get(t,r){if(!r.length)return t;let s=r[0].instances.find((c)=>c.base==t&&bi(r,c.modified));if(s)return s;let l=[],f=new ee(t.name,l,t,r);for(let c of r)c.instances.push(f);let h=ki(r);for(let c of t.set)if(!c.modified.length)for(let d of h)l.push(ot.get(c,d));return f}}function bi(t,r){return t.length==r.length&&t.every((s,l)=>s==r[l])}function ki(t){let r=[[]];for(let s=0;s<t.length;s++)for(let l=0,f=r.length;l<f;l++)r.push(r[l].concat(t[s]));return r.sort((s,l)=>l.length-s.length)}function Ar(t){let r=Object.create(null);for(let s in t){let l=t[s];if(!Array.isArray(l))l=[l];for(let f of s.split(" "))if(f){let h=[],c=2,d=f;for(let b=0;;){if(d=="..."&&b>0&&b+3==f.length){c=1;break}let k=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(d);if(!k)throw RangeError("Invalid path: "+f);if(h.push(k[0]=="*"?"":k[0][0]=='"'?JSON.parse(k[0]):k[0]),b+=k[0].length,b==f.length)break;let v=f[b++];if(b==f.length&&v=="!"){c=0;break}if(v!="/")throw RangeError("Invalid path: "+f);d=f.slice(b)}let m=h.length-1,p=h[m];if(!p)throw RangeError("Invalid path: "+f);let g=new Le(l,c,m>0?h.slice(0,m):null);r[p]=g.sort(r[p])}}return Sr.add(r)}var Sr=new Be({combine(t,r){let s,l,f;while(t||r){if(!t||r&&t.depth<=r.depth)f=r,r=r.next;else f=t,t=t.next;if(s&&s.mode==f.mode&&!f.context&&!s.context)continue;let h=new Le(f.tags,f.mode,f.context);if(s)s.next=h;else l=h;s=h}return l}});class Le{constructor(t,r,s,l){this.tags=t,this.mode=r,this.context=s,this.next=l}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(t){if(!t||t.depth<this.depth)return this.next=t,this;return t.next=this.sort(t.next),t}get depth(){return this.context?this.context.length:0}}Le.empty=new Le([],2,null);function Pt(t,r){let s=Object.create(null);for(let h of t)if(!Array.isArray(h.tag))s[h.tag.id]=h.class;else for(let c of h.tag)s[c.id]=h.class;let{scope:l,all:f=null}=r||{};return{style:(h)=>{let c=f;for(let d of h)for(let m of d.set){let p=s[m.id];if(p){c=c?c+" "+p:p;break}}return c},scope:l}}function xi(t,r){let s=null;for(let l of t){let f=l.style(r);if(f)s=s?s+" "+f:f}return s}function Rt(t,r,s,l=0,f=t.length){let h=new Mr(l,Array.isArray(r)?r:[r],s);h.highlightRange(t.cursor(),l,f,"",h.highlighters),h.flush(f)}class Mr{constructor(t,r,s){this.at=t,this.highlighters=r,this.span=s,this.class=""}startSpan(t,r){if(r!=this.class){if(this.flush(t),t>this.at)this.at=t;this.class=r}}flush(t){if(t>this.at&&this.class)this.span(this.at,t,this.class)}highlightRange(t,r,s,l,f){let{type:h,from:c,to:d}=t;if(c>=s||d<=r)return;if(h.isTop)f=this.highlighters.filter((k)=>!k.scope||k.scope(h));let m=l,p=vi(t)||Le.empty,g=xi(f,p.tags);if(g){if(m)m+=" ";if(m+=g,p.mode==1)l+=(l?" ":"")+g}if(this.startSpan(Math.max(r,c),m),p.opaque)return;let b=t.tree&&t.tree.prop(Be.mounted);if(b&&b.overlay){let k=t.node.enter(b.overlay[0].from+c,1),v=this.highlighters.filter((B)=>!B.scope||B.scope(b.tree.type)),w=t.firstChild();for(let B=0,M=c;;B++){let O=B<b.overlay.length?b.overlay[B]:null,F=O?O.from+c:d,N=Math.max(r,M),L=Math.min(s,F);if(N<L&&w){while(t.from<L)if(this.highlightRange(t,N,L,l,f),this.startSpan(Math.min(L,t.to),m),t.to>=F||!t.nextSibling())break}if(!O||F>s)break;if(M=O.to+c,M>r)this.highlightRange(k.cursor(),Math.max(r,O.from+c),Math.min(s,M),"",v),this.startSpan(Math.min(s,M),m)}if(w)t.parent()}else if(t.firstChild()){if(b)l="";do{if(t.to<=r)continue;if(t.from>=s)break;this.highlightRange(t,r,s,l,f),this.startSpan(Math.min(s,t.to),m)}while(t.nextSibling());t.parent()}}}function vi(t){let r=t.type.prop(Sr);while(r&&r.context&&!t.matchContext(r.context))r=r.next;return r||null}var C=ee.define,nt=C(),de=C(),yr=C(de),Cr=C(de),pe=C(),it=C(pe),Tt=C(pe),se=C(),ve=C(se),ne=C(),ie=C(),It=C(),Ve=C(It),st=C(),A={comment:nt,lineComment:C(nt),blockComment:C(nt),docComment:C(nt),name:de,variableName:C(de),typeName:yr,tagName:C(yr),propertyName:Cr,attributeName:C(Cr),className:C(de),labelName:C(de),namespace:C(de),macroName:C(de),literal:pe,string:it,docString:C(it),character:C(it),attributeValue:C(it),number:Tt,integer:C(Tt),float:C(Tt),bool:C(pe),regexp:C(pe),escape:C(pe),color:C(pe),url:C(pe),keyword:ne,self:C(ne),null:C(ne),atom:C(ne),unit:C(ne),modifier:C(ne),operatorKeyword:C(ne),controlKeyword:C(ne),definitionKeyword:C(ne),moduleKeyword:C(ne),operator:ie,derefOperator:C(ie),arithmeticOperator:C(ie),logicOperator:C(ie),bitwiseOperator:C(ie),compareOperator:C(ie),updateOperator:C(ie),definitionOperator:C(ie),typeOperator:C(ie),controlOperator:C(ie),punctuation:It,separator:C(It),bracket:Ve,angleBracket:C(Ve),squareBracket:C(Ve),paren:C(Ve),brace:C(Ve),content:se,heading:ve,heading1:C(ve),heading2:C(ve),heading3:C(ve),heading4:C(ve),heading5:C(ve),heading6:C(ve),contentSeparator:C(se),list:C(se),quote:C(se),emphasis:C(se),strong:C(se),link:C(se),monospace:C(se),strikethrough:C(se),inserted:C(),deleted:C(),changed:C(),invalid:C(),meta:st,documentMeta:C(st),annotation:C(st),processingInstruction:C(st),definition:ee.defineModifier("definition"),constant:ee.defineModifier("constant"),function:ee.defineModifier("function"),standard:ee.defineModifier("standard"),local:ee.defineModifier("local"),special:ee.defineModifier("special")};for(let t in A){let r=A[t];if(r instanceof ee)r.name=t}var fo=Pt([{tag:A.link,class:"tok-link"},{tag:A.heading,class:"tok-heading"},{tag:A.emphasis,class:"tok-emphasis"},{tag:A.strong,class:"tok-strong"},{tag:A.keyword,class:"tok-keyword"},{tag:A.atom,class:"tok-atom"},{tag:A.bool,class:"tok-bool"},{tag:A.url,class:"tok-url"},{tag:A.labelName,class:"tok-labelName"},{tag:A.inserted,class:"tok-inserted"},{tag:A.deleted,class:"tok-deleted"},{tag:A.literal,class:"tok-literal"},{tag:A.string,class:"tok-string"},{tag:A.number,class:"tok-number"},{tag:[A.regexp,A.escape,A.special(A.string)],class:"tok-string2"},{tag:A.variableName,class:"tok-variableName"},{tag:A.local(A.variableName),class:"tok-variableName tok-local"},{tag:A.definition(A.variableName),class:"tok-variableName tok-definition"},{tag:A.special(A.variableName),class:"tok-variableName2"},{tag:A.definition(A.propertyName),class:"tok-propertyName tok-definition"},{tag:A.typeName,class:"tok-typeName"},{tag:A.namespace,class:"tok-namespace"},{tag:A.className,class:"tok-className"},{tag:A.macroName,class:"tok-macroName"},{tag:A.propertyName,class:"tok-propertyName"},{tag:A.operator,class:"tok-operator"},{tag:A.comment,class:"tok-comment"},{tag:A.meta,class:"tok-meta"},{tag:A.invalid,class:"tok-invalid"},{tag:A.punctuation,class:"tok-punctuation"}]);function Dr(t,r,s,l=0,f=0){if(r==null){if(r=t.search(/[^\s\u00a0]/),r==-1)r=t.length}let h=f;for(let c=l;c<r;c++)if(t.charCodeAt(c)==9)h+=s-h%s;else h++;return h}class at{constructor(t,r,s,l){this.string=t,this.tabSize=r,this.indentUnit=s,this.overrideIndent=l,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(t){let r=this.string.charAt(this.pos),s;if(typeof t=="string")s=r==t;else s=r&&(t instanceof RegExp?t.test(r):t(r));if(s)return++this.pos,r}eatWhile(t){let r=this.pos;while(this.eat(t));return this.pos>r}eatSpace(){let t=this.pos;while(/[\s\u00a0]/.test(this.string.charAt(this.pos)))++this.pos;return this.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){let r=this.string.indexOf(t,this.pos);if(r>-1)return this.pos=r,!0}backUp(t){this.pos-=t}column(){if(this.lastColumnPos<this.start)this.lastColumnValue=Dr(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start;return this.lastColumnValue}indentation(){var t;return(t=this.overrideIndent)!==null&&t!==void 0?t:Dr(this.string,null,this.tabSize)}match(t,r,s){if(typeof t=="string"){let l=(h)=>s?h.toLowerCase():h,f=this.string.substr(this.pos,t.length);if(l(f)==l(t)){if(r!==!1)this.pos+=t.length;return!0}else return null}else{let l=this.string.slice(this.pos).match(t);if(l&&l.index>0)return null;if(l&&r!==!1)this.pos+=l[0].length;return l}}current(){return this.string.slice(this.start,this.pos)}}var _t,Te=new Be;function wi(t){return P.define({combine:t?(r)=>r.concat(t):void 0})}var yi=new Be;class te{constructor(t,r,s=[],l=""){if(this.data=t,this.name=l,!me.prototype.hasOwnProperty("tree"))Object.defineProperty(me.prototype,"tree",{get(){return zn(this)}});this.parser=r,this.extension=[Ao.of(this),me.languageData.of((f,h,c)=>{let d=Br(f,h,c),m=d.type.prop(Te);if(!m)return[];let p=f.facet(m),g=d.type.prop(yi);if(g){let b=d.resolve(h-d.from,c);for(let k of g)if(k.test(b,f)){let v=f.facet(k.facet);return k.type=="replace"?v:v.concat(p)}}return p})].concat(s)}isActiveAt(t,r,s=-1){return Br(t,r,s).type.prop(Te)==this.data}findRegions(t){let r=t.facet(Ao);if((r===null||r===void 0?void 0:r.data)==this.data)return[{from:0,to:t.doc.length}];if(!r||!r.allowsNesting)return[];let s=[],l=(f,h)=>{if(f.prop(Te)==this.data){s.push({from:h,to:h+f.length});return}let c=f.prop(Be.mounted);if(c){if(c.tree.prop(Te)==this.data){if(c.overlay)for(let d of c.overlay)s.push({from:d.from+h,to:d.to+h});else s.push({from:h,to:h+f.length});return}else if(c.overlay){let d=s.length;if(l(c.tree,c.overlay[0].from+h),s.length>d)return}}for(let d=0;d<f.children.length;d++){let m=f.children[d];if(m instanceof W)l(m,f.positions[d]+h)}};return l(zn(t),0),s}get allowsNesting(){return!0}}te.setState=oe.define();function Br(t,r,s){let l=t.facet(Ao),f=zn(t).topNode;if(!l||l.allowsNesting){for(let h=f;h;h=h.enter(r,s,U.ExcludeBuffers|U.EnterBracketed))if(h.type.isTop)f=h}return f}function zn(t){let r=t.field(te.state,!1);return r?r.tree:W.empty}class Fr{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,r){let s=this.cursorPos-this.string.length;if(t<s||r>=this.cursorPos)return this.doc.sliceString(t,r);else return this.string.slice(t-s,r-s)}}var ze=null;class Ie{constructor(t,r,s=[],l,f,h,c,d){this.parser=t,this.state=r,this.fragments=s,this.tree=l,this.treeLen=f,this.viewport=h,this.skipped=c,this.scheduleOn=d,this.parse=null,this.tempSkipped=[]}static create(t,r,s){return new Ie(t,r,[],W.empty,0,s,[],null)}startParse(){return this.parser.startParse(new Fr(this.state.doc),this.fragments)}work(t,r){if(r!=null&&r>=this.state.doc.length)r=void 0;if(this.tree!=W.empty&&this.isDone(r!==null&&r!==void 0?r:this.state.doc.length))return this.takeTree(),!0;return this.withContext(()=>{var s;if(typeof t=="number"){let l=Date.now()+t;t=()=>Date.now()>l}if(!this.parse)this.parse=this.startParse();if(r!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>r)&&r<this.state.doc.length)this.parse.stopAt(r);for(;;){let l=this.parse.advance();if(l)if(this.fragments=this.withoutTempSkipped(ue.addTree(l,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(s=this.parse.stoppedAt)!==null&&s!==void 0?s:this.state.doc.length,this.tree=l,this.parse=null,this.treeLen<(r!==null&&r!==void 0?r:this.state.doc.length))this.parse=this.startParse();else return!0;if(t())return!1}})}takeTree(){let t,r;if(this.parse&&(t=this.parse.parsedPos)>=this.treeLen){if(this.parse.stoppedAt==null||this.parse.stoppedAt>t)this.parse.stopAt(t);this.withContext(()=>{while(!(r=this.parse.advance()));}),this.treeLen=t,this.tree=r,this.fragments=this.withoutTempSkipped(ue.addTree(this.tree,this.fragments,!0)),this.parse=null}}withContext(t){let r=ze;ze=this;try{return t()}finally{ze=r}}withoutTempSkipped(t){for(let r;r=this.tempSkipped.pop();)t=Lr(t,r.from,r.to);return t}changes(t,r){let{fragments:s,tree:l,treeLen:f,viewport:h,skipped:c}=this;if(this.takeTree(),!t.empty){let d=[];if(t.iterChangedRanges((m,p,g,b)=>d.push({fromA:m,toA:p,fromB:g,toB:b})),s=ue.applyChanges(s,d),l=W.empty,f=0,h={from:t.mapPos(h.from,-1),to:t.mapPos(h.to,1)},this.skipped.length){c=[];for(let m of this.skipped){let p=t.mapPos(m.from,1),g=t.mapPos(m.to,-1);if(p<g)c.push({from:p,to:g})}}}return new Ie(this.parser,r,s,l,f,h,c,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let r=this.skipped.length;for(let s=0;s<this.skipped.length;s++){let{from:l,to:f}=this.skipped[s];if(l<t.to&&f>t.from)this.fragments=Lr(this.fragments,l,f),this.skipped.splice(s--,1)}if(this.skipped.length>=r)return!1;return this.reset(),!0}reset(){if(this.parse)this.takeTree(),this.parse=null}skipUntilInView(t,r){this.skipped.push({from:t,to:r})}static getSkippingParser(t){return new class extends rt{createParse(r,s,l){let f=l[0].from,h=l[l.length-1].to;return{parsedPos:f,advance(){let d=ze;if(d){for(let m of l)d.tempSkipped.push(m);if(t)d.scheduleOn=d.scheduleOn?Promise.all([d.scheduleOn,t]):t}return this.parsedPos=h,new W(Y.none,[],[],h-f)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let r=this.fragments;return this.treeLen>=t&&r.length&&r[0].from==0&&r[0].to>=t}static get(){return ze}}function Lr(t,r,s){return ue.applyChanges(t,[{fromA:r,toA:s,fromB:r,toB:s}])}class Pe{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let r=this.context.changes(t.changes,t.state),s=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),r.viewport.to);if(!r.work(20,s))r.takeTree();return new Pe(r)}static init(t){let r=Math.min(3000,t.doc.length),s=Ie.create(t.facet(Ao).parser,t,{from:0,to:r});if(!s.work(20,r))s.takeTree();return new Pe(s)}}te.state=Oe.define({create:Pe.init,update(t,r){for(let s of r.effects)if(s.is(te.setState))return s.value;if(r.startState.facet(Ao)!=r.state.facet(Ao))return Pe.init(r.state);return t.apply(r)}});var Vr=(t)=>{let r=setTimeout(()=>t(),500);return()=>clearTimeout(r)};if(typeof requestIdleCallback<"u")Vr=(t)=>{let r=-1,s=setTimeout(()=>{r=requestIdleCallback(t,{timeout:400})},100);return()=>r<0?clearTimeout(s):cancelIdleCallback(r)};var Nt=typeof navigator<"u"&&((_t=navigator.scheduling)===null||_t===void 0?void 0:_t.isInputPending)?()=>navigator.scheduling.isInputPending():null,Ci=ye.fromClass(class{constructor(r){this.view=r,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(r){let s=this.view.state.field(te.state).context;if(s.updateViewport(r.view.viewport)||this.view.viewport.to>s.treeLen)this.scheduleWork();if(r.docChanged||r.selectionSet){if(this.view.hasFocus)this.chunkBudget+=50;this.scheduleWork()}this.checkAsyncSchedule(s)}scheduleWork(){if(this.working)return;let{state:r}=this.view,s=r.field(te.state);if(s.tree!=s.context.tree||!s.context.isDone(r.doc.length))this.working=Vr(this.work)}work(r){this.working=null;let s=Date.now();if(this.chunkEnd<s&&(this.chunkEnd<0||this.view.hasFocus))this.chunkEnd=s+30000,this.chunkBudget=3000;if(this.chunkBudget<=0)return;let{state:l,viewport:{to:f}}=this.view,h=l.field(te.state);if(h.tree==h.context.tree&&h.context.isDone(f+1e5))return;let c=Date.now()+Math.min(this.chunkBudget,100,r&&!Nt?Math.max(25,r.timeRemaining()-5):1e9),d=h.context.treeLen<f&&l.doc.length>f+1000,m=h.context.work(()=>Nt&&Nt()||Date.now()>c,f+(d?0:1e5));if(this.chunkBudget-=Date.now()-s,m||this.chunkBudget<=0)h.context.takeTree(),this.view.dispatch({effects:te.setState.of(new Pe(h.context))});if(this.chunkBudget>0&&!(m&&!d))this.scheduleWork();this.checkAsyncSchedule(h.context)}checkAsyncSchedule(r){if(r.scheduleOn)this.workScheduled++,r.scheduleOn.then(()=>this.scheduleWork()).catch((s)=>wn(this.view.state,s)).then(()=>this.workScheduled--),r.scheduleOn=null}destroy(){if(this.working)this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Ao=P.define({combine(t){return t.length?t[0]:null},enables:(t)=>[te.state,Ci,_.contentAttributes.compute([t],(r)=>{let s=r.facet(t);return s&&s.name?{"data-language":s.name}:{}})]});var fp=P.define(),Pi=P.define({combine:(t)=>{if(!t.length)return" ";let r=t[0];if(!r||/\S/.test(r)||Array.from(r).some((s)=>s!=r[0]))throw Error("Invalid indent unit: "+JSON.stringify(t[0]));return r}});function ri(t){let r=t.facet(Pi);return r.charCodeAt(0)==9?t.tabSize*r.length:r.length}function Xs(t,r){let s="",l=t.tabSize,f=t.facet(Pi)[0];if(f=="\t"){while(r>=l)s+="\t",r-=l;f=" "}for(let h=0;h<r;h++)s+=f;return s}function Ku(t,r){if(t instanceof me)t=new el(t);for(let l of t.state.facet(fp)){let f=l(t,r);if(f!==void 0)return f}let s=zn(t.state);return s.length>=r?Ai(t,s,r):null}class el{constructor(t,r={}){this.state=t,this.options=r,this.unit=ri(t)}lineAt(t,r=1){let s=this.state.doc.lineAt(t),{simulateBreak:l,simulateDoubleBreak:f}=this.options;if(l!=null&&l>=s.from&&l<=s.to)if(f&&l==t)return{text:"",from:t};else if(r<0?l<t:l<=t)return{text:s.text.slice(l-s.from),from:l};else return{text:s.text.slice(0,l-s.from),from:s.from};return s}textAfterPos(t,r=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:s,from:l}=this.lineAt(t,r);return s.slice(t-l,Math.min(s.length,t+100-l))}column(t,r=1){let{text:s,from:l}=this.lineAt(t,r),f=this.countColumn(s,t-l),h=this.options.overrideIndentation?this.options.overrideIndentation(l):-1;if(h>-1)f+=h-this.countColumn(s,s.search(/\S|$/));return f}countColumn(t,r=t.length){return ma(t,this.state.tabSize,r)}lineIndent(t,r=1){let{text:s,from:l}=this.lineAt(t,r),f=this.options.overrideIndentation;if(f){let h=f(l);if(h>-1)return h}return this.countColumn(s,s.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}var zr=new Be;function Ai(t,r,s){let l=r.resolveStack(s),f=r.resolveInner(s,-1).resolve(s,0).enterUnfinishedNodesBefore(s);if(f!=l.node){let h=[];for(let c=f;c&&!(c.from<l.node.from||c.to>l.node.to||c.from==l.node.from&&c.type==l.node.type);c=c.parent)h.push(c);for(let c=h.length-1;c>=0;c--)l={node:h[c],next:l}}return Wr(l,t,s)}function Wr(t,r,s){for(let l=t;l;l=l.next){let f=Mi(l.node);if(f)return f(Ht.create(r,s,l))}return 0}function Si(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function Mi(t){let r=t.type.prop(zr);if(r)return r;let s=t.firstChild,l;if(s&&(l=s.type.prop(Be.closedBy))){let f=t.lastChild,h=f&&l.indexOf(f.name)>-1;return(c)=>Li(c,!0,1,void 0,h&&!Si(c)?f.from:void 0)}return t.parent==null?Di:null}function Di(){return 0}class Ht extends el{constructor(t,r,s){super(t.state,t.options);this.base=t,this.pos=r,this.context=s}get node(){return this.context.node}static create(t,r,s){return new Ht(t,r,s)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let r=this.state.doc.lineAt(t.from);for(;;){let s=t.resolve(r.from);while(s.parent&&s.parent.from==s.from)s=s.parent;if(Bi(s,t))break;r=this.state.doc.lineAt(s.from)}return this.lineIndent(r.from)}continue(){return Wr(this.context.next,this.base,this.pos)}}function Bi(t,r){for(let s=r;s;s=s.parent)if(t==s)return!0;return!1}function Ei(t){let r=t.node,s=r.childAfter(r.from),l=r.lastChild;if(!s)return null;let f=t.options.simulateBreak,h=t.state.doc.lineAt(s.from),c=f==null||f<=h.from?h.to:Math.min(h.to,f);for(let d=s.to;;){let m=r.childAfter(d);if(!m||m==l)return null;if(!m.type.isSkipped){if(m.from>=c)return null;let p=/^ */.exec(h.text.slice(s.to-h.from))[0].length;return{from:s.from,to:s.to+p}}d=m.to}}function Li(t,r,s,l,f){let h=t.textAfter,c=h.match(/^\s*/)[0].length,d=l&&h.slice(c,c+l.length)==l||f==t.pos+c,m=r?Ei(t):null;if(m)return d?t.column(m.from):t.column(m.to);return t.baseIndent+(d?0:t.unit*s)}var Ti=200;function dg(){return me.transactionFilter.of((t)=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let r=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!r.length)return t;let s=t.newDoc,{head:l}=t.newSelection.main,f=s.lineAt(l);if(l>f.from+Ti)return t;let h=s.sliceString(f.from,l);if(!r.some((p)=>p.test(h)))return t;let{state:c}=t,d=-1,m=[];for(let{head:p}of c.selection.ranges){let g=c.doc.lineAt(p);if(g.from==d)continue;d=g.from;let b=Ku(c,g.from);if(b==null)continue;let k=/^\s*/.exec(g.text)[0],v=Xs(c,b);if(k!=v)m.push({from:g.from,to:g.from+k.length,insert:v})}return m.length?[t,{changes:m,sequential:!0}]:t})}var Vu=P.define(),Ii=new Be;function Ri(t,r,s){let l=zn(t);if(l.length<s)return null;let f=l.resolveStack(s,1),h=null;for(let c=f;c;c=c.next){let d=c.node;if(d.to<=s||d.from>s)continue;if(h&&d.from<r)break;let m=d.type.prop(Ii);if(m&&(d.to<l.length-50||l.length==t.doc.length||!_i(d))){let p=m(d,t);if(p&&p.from<=s&&p.from>=r&&p.to>s)h=p}}return h}function _i(t){let r=t.lastChild;return r&&r.to==t.to&&r.type.isError}function ht(t,r,s){for(let l of t.facet(Vu)){let f=l(t,r,s);if(f)return f}return Ri(t,r,s)}function Gr(t,r){let s=r.mapPos(t.from,1),l=r.mapPos(t.to,-1);return s>=l?void 0:{from:s,to:l}}var ut=oe.define({map:Gr}),We=oe.define({map:Gr});function Ur(t){let r=[];for(let{head:s}of t.state.selection.ranges){if(r.some((l)=>l.from<=s&&l.to>=s))continue;r.push(t.lineBlockAt(s))}return r}var Ce=Oe.define({create(){return D.none},update(t,r){if(r.isUserEvent("delete"))r.changes.iterChangedRanges((l,f)=>t=Or(t,l,f));t=t.map(r.changes);let s=[];for(let l of r.effects)if(l.is(ut)&&!Ni(t,l.value.from,l.value.to))s.push(l.value);else if(l.is(We))t=t.update({filter:(f,h)=>l.value.from!=f||l.value.to!=h,filterFrom:l.value.from,filterTo:l.value.to});if(s.length){let{preparePlaceholder:l}=r.state.facet(Wt),f=s.map((h)=>(!l?Tr:D.replace({widget:new Jr(l(r.state,h))})).range(h.from,h.to));t=t.update({add:f})}if(r.selection)t=Or(t,r.selection.main.head);return t},provide:(t)=>_.decorations.from(t),toJSON(t,r){let s=[];return t.between(0,r.doc.length,(l,f)=>{s.push(l,f)}),s},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw RangeError("Invalid JSON for fold state");let r=[];for(let s=0;s<t.length;){let l=t[s++],f=t[s++];if(typeof l!="number"||typeof f!="number")throw RangeError("Invalid JSON for fold state");r.push(Tr.range(l,f))}return D.set(r,!0)}});function Or(t,r,s=r){let l=!1;return t.between(r,s,(f,h)=>{if(f<s&&h>r)l=!0}),!l?t:t.update({filterFrom:r,filterTo:s,filter:(f,h)=>f>=s||h<=r})}function ct(t,r,s){var l;let f=null;return(l=t.field(Ce,!1))===null||l===void 0||l.between(r,s,(h,c)=>{if(!f||f.from>h)f={from:h,to:c}}),f}function Ni(t,r,s){let l=!1;return t.between(r,r,(f,h)=>{if(f==r&&h==s)l=!0}),l}function jr(t,r){return t.field(Ce,!1)?r:r.concat(oe.appendConfig.of(tl()))}var gp=(t)=>{for(let r of Ur(t)){let s=ht(t.state,r.from,r.to);if(s)return t.dispatch({effects:jr(t.state,[ut.of(s),$r(t,s)])}),!0}return!1},Ap=(t)=>{if(!t.state.field(Ce,!1))return!1;let r=[];for(let s of Ur(t)){let l=ct(t.state,s.from,s.to);if(l)r.push(We.of(l),$r(t,l,!1))}if(r.length)t.dispatch({effects:r});return r.length>0};function $r(t,r,s=!0){let l=t.state.doc.lineAt(r.from).number,f=t.state.doc.lineAt(r.to).number;return _.announce.of(`${t.state.phrase(s?"Folded lines":"Unfolded lines")} ${l} ${t.state.phrase("to")} ${f}.`)}var hp=(t)=>{let{state:r}=t,s=[];for(let l=0;l<r.doc.length;){let f=t.lineBlockAt(l),h=ht(r,f.from,f.to);if(h)s.push(ut.of(h));l=(h?t.lineBlockAt(h.to):f).to+1}if(s.length)t.dispatch({effects:jr(t.state,s)});return!!s.length},bp=(t)=>{let r=t.state.field(Ce,!1);if(!r||!r.size)return!1;let s=[];return r.between(0,t.state.doc.length,(l,f)=>{s.push(We.of({from:l,to:f}))}),t.dispatch({effects:s}),!0};var NA=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:gp},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Ap},{key:"Ctrl-Alt-[",run:hp},{key:"Ctrl-Alt-]",run:bp}],Fi={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Wt=P.define({combine(t){return Nn(t,Fi)}});function tl(t){let r=[Ce,zi];if(t)r.push(Wt.of(t));return r}function qr(t,r){let{state:s}=t,l=s.facet(Wt),f=(c)=>{let d=t.lineBlockAt(t.posAtDOM(c.target)),m=ct(t.state,d.from,d.to);if(m)t.dispatch({effects:We.of(m)});c.preventDefault()};if(l.placeholderDOM)return l.placeholderDOM(t,f,r);let h=document.createElement("span");return h.textContent=l.placeholderText,h.setAttribute("aria-label",s.phrase("folded code")),h.title=s.phrase("unfold"),h.className="cm-foldPlaceholder",h.onclick=f,h}var Tr=D.replace({widget:new class extends Mt{toDOM(t){return qr(t,null)}}});class Jr extends Mt{constructor(t){super();this.value=t}eq(t){return this.value==t.value}toDOM(t){return qr(t,this.value)}}var Vi={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class ft extends Qn{constructor(t,r){super();this.config=t,this.open=r}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let r=document.createElement("span");return r.textContent=this.open?this.config.openText:this.config.closedText,r.title=t.state.phrase(this.open?"Fold line":"Unfold line"),r}}function Yu(t={}){let r={...Vi,...t},s=new ft(r,!0),l=new ft(r,!1),f=ye.fromClass(class{constructor(c){this.from=c.viewport.from,this.markers=this.buildMarkers(c)}update(c){if(c.docChanged||c.viewportChanged||c.startState.facet(Ao)!=c.state.facet(Ao)||c.startState.field(Ce,!1)!=c.state.field(Ce,!1)||zn(c.startState)!=zn(c.state)||r.foldingChanged(c))this.markers=this.buildMarkers(c.view)}buildMarkers(c){let d=new lt;for(let m of c.viewportLineBlocks){let p=ct(c.state,m.from,m.to)?l:ht(c.state,m.from,m.to)?s:null;if(p)d.add(m.from,m.from,p)}return d.finish()}}),{domEventHandlers:h}=r;return[f,Oi({class:"cm-foldGutter",markers(c){var d;return((d=c.plugin(f))===null||d===void 0?void 0:d.markers)||ge.empty},initialSpacer(){return new ft(r,!1)},domEventHandlers:{...h,click:(c,d,m)=>{if(h.click&&h.click(c,d,m))return!0;let p=ct(c.state,d.from,d.to);if(p)return c.dispatch({effects:We.of(p)}),!0;let g=ht(c.state,d.from,d.to);if(g)return c.dispatch({effects:ut.of(g)}),!0;return!1}}}),tl()]}var zi=_.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"}});class Gt{constructor(t,r){this.specs=t;let s;function l(c){let d=Hr.newName();return(s||(s=Object.create(null)))["."+d]=c,d}let f=typeof r.all=="string"?r.all:r.all?l(r.all):void 0,h=r.scope;this.scope=h instanceof te?(c)=>c.prop(Te)==h.data:h?(c)=>c==h:void 0,this.style=Pt(t.map((c)=>({tag:c.tag,class:c.class||l(Object.assign({},c,{tag:null}))})),{all:f}).style,this.module=s?new Hr(s):null,this.themeType=r.themeType}static define(t,r){return new Gt(t,r||{})}}var Hi=P.define(),Wi=P.define({combine(t){return t.length?[t[0]]:null}});function Gi(t){let r=t.facet(Hi);return r.length?r:t.facet(Wi)}function QA(t,r,s){let l=Gi(t),f=null;if(l){for(let h of l)if(!h.scope||s&&h.scope(s)){let c=h.style(r);if(c)f=f?f+" "+c:c}}return f}var vo=Gt.define([{tag:A.meta,color:"#404740"},{tag:A.link,textDecoration:"underline"},{tag:A.heading,textDecoration:"underline",fontWeight:"bold"},{tag:A.emphasis,fontStyle:"italic"},{tag:A.strong,fontWeight:"bold"},{tag:A.strikethrough,textDecoration:"line-through"},{tag:A.keyword,color:"#708"},{tag:[A.atom,A.bool,A.url,A.contentSeparator,A.labelName],color:"#219"},{tag:[A.literal,A.inserted],color:"#164"},{tag:[A.string,A.deleted],color:"#a11"},{tag:[A.regexp,A.escape,A.special(A.string)],color:"#e40"},{tag:A.definition(A.variableName),color:"#00f"},{tag:A.local(A.variableName),color:"#30a"},{tag:[A.typeName,A.namespace],color:"#085"},{tag:A.className,color:"#167"},{tag:[A.special(A.variableName),A.macroName],color:"#256"},{tag:A.definition(A.propertyName),color:"#00c"},{tag:A.comment,color:"#940"},{tag:A.invalid,color:"#f00"}]),Ui=_.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Kr=1e4,Xr="()[]{}",Yr=P.define({combine(t){return Nn(t,{afterCursor:!0,brackets:Xr,maxScanDistance:Kr,renderMatch:qi})}}),ji=D.mark({class:"cm-matchingBracket"}),$i=D.mark({class:"cm-nonmatchingBracket"});function qi(t){let r=[],s=t.matched?ji:$i;if(r.push(s.range(t.start.from,t.start.to)),t.end)r.push(s.range(t.end.from,t.end.to));return r}function Pr(t){let r=[],s=t.facet(Yr);for(let l of t.selection.ranges){if(!l.empty)continue;let f=Er(t,l.head,-1,s)||l.head>0&&Er(t,l.head-1,1,s)||s.afterCursor&&(Er(t,l.head,1,s)||l.head<t.doc.length&&Er(t,l.head+1,-1,s));if(f)r=r.concat(s.renderMatch(f,t))}return D.set(r,!0)}var Ji=ye.fromClass(class{constructor(t){this.paused=!1,this.decorations=Pr(t.state)}update(t){if(t.docChanged||t.selectionSet||this.paused)if(t.view.composing)this.decorations=this.decorations.map(t.changes),this.paused=!0;else this.decorations=Pr(t.state),this.paused=!1}},{decorations:(t)=>t.decorations}),Ki=[Ji,Ui];function Ju(t={}){return[Yr.of(t),Ki]}var Xi=new Be;function Vt(t,r,s){let l=t.prop(r<0?Be.openedBy:Be.closedBy);if(l)return l;if(t.name.length==1){let f=s.indexOf(t.name);if(f>-1&&f%2==(r<0?1:0))return[s[f+r]]}return null}function zt(t){let r=t.type.prop(Xi);return r?r(t.node):t}function Er(t,r,s,l={}){let f=l.maxScanDistance||Kr,h=l.brackets||Xr,c=zn(t),d=c.resolveInner(r,s);for(let m=d;m;m=m.parent){let p=Vt(m.type,s,h);if(p&&m.from<m.to){let g=zt(m);if(g&&(s>0?r>=g.from&&r<g.to:r>g.from&&r<=g.to))return Yi(t,r,s,m,g,p,h)}}return Qi(t,r,s,c,d.type,f,h)}function Yi(t,r,s,l,f,h,c){let d=l.parent,m={from:f.from,to:f.to},p=0,g=d===null||d===void 0?void 0:d.cursor();if(g&&(s<0?g.childBefore(l.from):g.childAfter(l.to)))do if(s<0?g.to<=l.from:g.from>=l.to){if(p==0&&h.indexOf(g.type.name)>-1&&g.from<g.to){let b=zt(g);return{start:m,end:b?{from:b.from,to:b.to}:void 0,matched:!0}}else if(Vt(g.type,s,c))p++;else if(Vt(g.type,-s,c)){if(p==0){let b=zt(g);return{start:m,end:b&&b.from<b.to?{from:b.from,to:b.to}:void 0,matched:!1}}p--}}while(s<0?g.prevSibling():g.nextSibling());return{start:m,matched:!1}}function Qi(t,r,s,l,f,h,c){if(s<0?!r:r==t.doc.length)return null;let d=s<0?t.sliceDoc(r-1,r):t.sliceDoc(r,r+1),m=c.indexOf(d);if(m<0||m%2==0!=s>0)return null;let p={from:s<0?r-1:r,to:s>0?r+1:r},g=t.doc.iterRange(r,s>0?t.doc.length:0),b=0;for(let k=0;!g.next().done&&k<=h;){let v=g.value;if(s<0)k+=v.length;let w=r+k*s;for(let B=s>0?0:v.length-1,M=s>0?v.length:-1;B!=M;B+=s){let O=c.indexOf(v[B]);if(O<0||l.resolveInner(w+B,1).type!=f)continue;if(O%2==0==s>0)b++;else if(b==1)return{start:p,end:{from:w+B,to:w+B+1},matched:O>>1==m>>1};else b--}if(s>0)k+=v.length}return g.done?{start:p,matched:!1}:null}function Zi(t){return{name:t.name||"",token:t.token,blankLine:t.blankLine||(()=>{}),startState:t.startState||(()=>!0),copyState:t.copyState||es,indent:t.indent||(()=>null),languageData:t.languageData||{},tokenTable:t.tokenTable||jt,mergeTokens:t.mergeTokens!==!1}}function es(t){if(typeof t!="object")return t;let r={};for(let s in t){let l=t[s];r[s]=l instanceof Array?l.slice():l}return r}var Rr=new WeakMap;class RA extends te{constructor(t){let r=wi(t.languageData),s=Zi(t),l,f=new class extends rt{createParse(h,c,d){return new Zr(l,h,c,d)}};super(r,f,[],t.name);this.topNode=is(r,this),l=this,this.streamParser=s,this.stateAfter=new Be({perNode:!0}),this.tokenTable=t.tokenTable?new $t(s.tokenTable):ns}static define(t){return new RA(t)}getIndent(t){let r=void 0,{overrideIndentation:s}=t.options;if(s){if(r=Rr.get(t.state),r!=null&&r<t.pos-1e4)r=void 0}let l=Ut(this,t.node.tree,t.node.from,t.node.from,r!==null&&r!==void 0?r:t.pos),f,h;if(l)h=l.state,f=l.pos+1;else h=this.streamParser.startState(t.unit),f=t.node.from;if(t.pos-f>1e4)return null;while(f<t.pos){let d=t.state.doc.lineAt(f),m=Math.min(t.pos,d.to);if(d.length){let p=s?s(d.from):-1,g=new at(d.text,t.state.tabSize,t.unit,p<0?void 0:p);while(g.pos<m-d.from)en(this.streamParser.token,g,h)}else this.streamParser.blankLine(h,t.unit);if(m==t.pos)break;f=d.to+1}let c=t.lineAt(t.pos);if(s&&r==null)Rr.set(t.state,c.from);return this.streamParser.indent(h,/^\s*(.*)/.exec(c.text)[1],t)}get allowsNesting(){return!1}}function Ut(t,r,s,l,f){let h=s>=l&&s+r.length<=f&&r.prop(t.stateAfter);if(h)return{state:t.streamParser.copyState(h),pos:s+r.length};for(let c=r.children.length-1;c>=0;c--){let d=r.children[c],m=s+r.positions[c],p=d instanceof W&&m<f&&Ut(t,d,m,l,f);if(p)return p}return null}function Qr(t,r,s,l,f){if(f&&s<=0&&l>=r.length)return r;if(!f&&s==0&&r.type==t.topNode)f=!0;for(let h=r.children.length-1;h>=0;h--){let c=r.positions[h],d=r.children[h],m;if(c<l&&d instanceof W){if(!(m=Qr(t,d,s-c,l-c,f)))break;return!f?m:new W(r.type,r.children.slice(0,h).concat(m),r.positions.slice(0,h+1),c+m.length)}}return null}function ts(t,r,s,l,f){for(let h of r){let c=h.from+(h.openStart?25:0),d=h.to-(h.openEnd?25:0),m=c<=s&&d>s&&Ut(t,h.tree,0-h.offset,s,d),p;if(m&&m.pos<=l&&(p=Qr(t,h.tree,s+h.offset,m.pos+h.offset,!1)))return{state:m.state,tree:p}}return{state:t.streamParser.startState(f?ri(f):4),tree:W.empty}}class Zr{constructor(t,r,s,l){this.lang=t,this.input=r,this.fragments=s,this.ranges=l,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=l[l.length-1].to;let f=Ie.get(),h=l[0].from,{state:c,tree:d}=ts(t,s,h,this.to,f===null||f===void 0?void 0:f.state);this.state=c,this.parsedPos=this.chunkStart=h+d.length;for(let m=0;m<d.children.length;m++)this.chunks.push(d.children[m]),this.chunkPos.push(d.positions[m]);if(f&&this.parsedPos<f.viewport.from-1e5&&l.some((m)=>m.from<=f.viewport.from&&m.to>=f.viewport.from))this.state=this.lang.streamParser.startState(ri(f.state)),f.skipUntilInView(this.parsedPos,f.viewport.from),this.parsedPos=f.viewport.from;this.moveRangeIndex()}advance(){let t=Ie.get(),r=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),s=Math.min(r,this.chunkStart+512);if(t)s=Math.min(s,t.viewport.to);while(this.parsedPos<s)this.parseLine(t);if(this.chunkStart<this.parsedPos)this.finishChunk();if(this.parsedPos>=r)return this.finish();if(t&&this.parsedPos>=t.viewport.to)return t.skipUntilInView(this.parsedPos,r),this.finish();return null}stopAt(t){this.stoppedAt=t}lineAfter(t){let r=this.input.chunk(t);if(!this.input.lineChunks){let s=r.indexOf(`
1
+ import{n,o,K,i,u,a,Ze,e,bl,we,nn,Qm,ps,Rm,Lm,lo,ys,jd,W0,K0}from"./index-jvn2xfpt.js";import{ke,Ct,x,P,Oe,Ir,An,oe,me,Nn,ge,lt,ma,Hr,Mt,D,Ge,wn,ye,_,ho,Qn,Oi,Zu}from"./index-4kchzh9y.js";import{qA,Xu}from"./index-exyg9sna.js";var fi=600,hi=150,At=1,St=new Map;function mp(t){if(!t)return;St.get(t)?.()}function Zs({tabKey:t,surface:r,ready:s=!0,slot:l=jd,element:f}){let h=Ze(bl),c=h?.sessionId??null,d=h?.ready??!1,m=i(null),p=i(null),g=i(0),b=i(!1),k=i(0),v=i(!1),w=i(null),B=i(),M=a(()=>{let L=p.current,S=m.current;if(!L||!S)return;if(performance.now()>L.until){p.current=null;return}if(Math.abs(S.scrollTop-L.top)<At){k.current=S.scrollTop;return}b.current=!0,S.scrollTop=L.top,b.current=!1,g.current=S.scrollTop,k.current=S.scrollTop},[]),O=a((L)=>{if(m.current=L,L)M()},[M]),F=a((L)=>{if(!t)return;let S=we(c,l);if((S?.[t]?.[r]??0)===L)return;nn(c,l,K0(S,t,r,L))},[c,l,t,r]),N=a(()=>{let L=m.current;if(!L||!t)return;let S=L.scrollTop;if(p.current){if(b.current)return;let E=Math.abs(S-k.current)>=At;if(k.current=S,E&&!v.current){M();return}if(Math.abs(S-g.current)<At*2)return;p.current=null}k.current=S,v.current=!1,w.current=S,clearTimeout(B.current),B.current=setTimeout(()=>{B.current=void 0;let E=w.current;if(E!==null)F(E)},hi)},[M,F,t]);return o(()=>{if(!f)return;let L=()=>N();return f.addEventListener("scroll",L,{passive:!0}),()=>f.removeEventListener("scroll",L)},[f,N]),o(()=>{let L=f??m.current;if(!L)return;let S=()=>{v.current=!0},E=["wheel","keydown","pointerdown","touchstart"];for(let y of E)L.addEventListener(y,S,{passive:!0});return window.addEventListener("keydown",S,{passive:!0}),()=>{for(let y of E)L.removeEventListener(y,S);window.removeEventListener("keydown",S)}},[f]),K(()=>{p.current=null,w.current=null,v.current=!1;let L=null;if(f!==void 0)m.current=f;let S=m.current;if(s&&d&&t&&S){let E=W0(we(c,l),t,r);p.current={top:E,until:performance.now()+fi},St.set(S,()=>{p.current=null}),M();let y=S.firstElementChild;if(y&&typeof ResizeObserver<"u")L=new ResizeObserver(()=>M()),L.observe(y)}return()=>{if(S)St.delete(S);L?.disconnect(),clearTimeout(B.current),B.current=void 0;let E=w.current;if(w.current=null,E!==null)F(E)}},[s,d,t,r,c,l,M,F,f]),{ref:O,onScroll:N}}var ci=0;class Ye{constructor(t,r){this.from=t,this.to=r}}class Be{constructor(t={}){this.id=ci++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw Error("This node type doesn't define a deserialize function")}),this.combine=t.combine||null}add(t){if(this.perNode)throw RangeError("Can't add per-node props to node types");if(typeof t!="function")t=Y.match(t);return(r)=>{let s=t(r);return s===void 0?null:[this,s]}}}Be.closedBy=new Be({deserialize:(t)=>t.split(" ")});Be.openedBy=new Be({deserialize:(t)=>t.split(" ")});Be.group=new Be({deserialize:(t)=>t.split(" ")});Be.isolate=new Be({deserialize:(t)=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw RangeError("Invalid value for isolate: "+t);return t||"auto"}});Be.contextHash=new Be({perNode:!0});Be.lookAhead=new Be({perNode:!0});Be.mounted=new Be({perNode:!0});class Ee{constructor(t,r,s,l=!1){this.tree=t,this.overlay=r,this.parser=s,this.bracketed=l}static get(t){return t&&t.props&&t.props[Be.mounted.id]}}var ui=Object.create(null);class Y{constructor(t,r,s,l=0){this.name=t,this.props=r,this.id=s,this.flags=l}static define(t){let r=t.props&&t.props.length?Object.create(null):ui,s=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),l=new Y(t.name||"",r,t.id,s);if(t.props)for(let f of t.props){if(!Array.isArray(f))f=f(l);if(f){if(f[0].perNode)throw RangeError("Can't store a per-node prop on a node type");r[f[0].id]=f[1]}}return l}prop(t){return this.props[t.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(t){if(typeof t=="string"){if(this.name==t)return!0;let r=this.prop(Be.group);return r?r.indexOf(t)>-1:!1}return this.id==t}static match(t){let r=Object.create(null);for(let s in t)for(let l of s.split(" "))r[l]=t[s];return(s)=>{for(let l=s.prop(Be.group),f=-1;f<(l?l.length:0);f++){let h=r[f<0?s.name:l[f]];if(h)return h}}}}Y.none=new Y("",Object.create(null),0,8);class tt{constructor(t){this.types=t;for(let r=0;r<t.length;r++)if(t[r].id!=r)throw RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let r=[];for(let s of this.types){let l=null;for(let f of t){let h=f(s);if(h){if(!l)l=Object.assign({},s.props);let c=h[1],d=h[0];if(d.combine&&d.id in l)c=d.combine(l[d.id],c);l[d.id]=c}}r.push(l?new Y(s.name,l,s.id,s.flags):s)}return new tt(r)}}var Xe=new WeakMap,mr=new WeakMap,U;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(U||(U={}));class W{constructor(t,r,s,l,f){if(this.type=t,this.children=r,this.positions=s,this.length=l,this.props=null,f&&f.length){this.props=Object.create(null);for(let[h,c]of f)this.props[typeof h=="number"?h:h.id]=c}}toString(){let t=Ee.get(this);if(t&&!t.overlay)return t.tree.toString();let r="";for(let s of this.children){let l=s.toString();if(l){if(r)r+=",";r+=l}}return!this.type.name?r:(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(r.length?"("+r+")":"")}cursor(t=0){return new et(this.topNode,t)}cursorAt(t,r=0,s=0){let l=Xe.get(this)||this.topNode,f=new et(l);return f.moveTo(t,r),Xe.set(this,f._tree),f}get topNode(){return new Z(this,0,0,null)}resolve(t,r=0){let s=Fe(Xe.get(this)||this.topNode,t,r,!1);return Xe.set(this,s),s}resolveInner(t,r=0){let s=Fe(mr.get(this)||this.topNode,t,r,!0);return mr.set(this,s),s}resolveStack(t,r=0){return di(this,t,r)}iterate(t){let{enter:r,leave:s,from:l=0,to:f=this.length}=t,h=t.mode||0,c=(h&U.IncludeAnonymous)>0;for(let d=this.cursor(h|U.IncludeAnonymous);;){let m=!1;if(d.from<=f&&d.to>=l&&(!c&&d.type.isAnonymous||r(d)!==!1)){if(d.firstChild())continue;m=!0}for(;;){if(m&&s&&(c||!d.type.isAnonymous))s(d);if(d.nextSibling())break;if(!d.parent())return;m=!0}}}prop(t){return!t.perNode?this.type.prop(t):this.props?this.props[t.id]:void 0}get propValues(){let t=[];if(this.props)for(let r in this.props)t.push([+r,this.props[r]]);return t}balance(t={}){return this.children.length<=8?this:Ot(Y.none,this.children,this.positions,0,this.children.length,0,this.length,(r,s,l)=>new W(this.type,r,s,l,this.propValues),t.makeTree||((r,s,l)=>new W(Y.none,r,s,l)))}static build(t){return mi(t)}}W.empty=new W(Y.none,[],[],0);class Bt{constructor(t,r){this.buffer=t,this.index=r}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 Bt(this.buffer,this.index)}}class ce{constructor(t,r,s){this.buffer=t,this.length=r,this.set=s}get type(){return Y.none}toString(){let t=[];for(let r=0;r<this.buffer.length;)t.push(this.childString(r)),r=this.buffer[r+3];return t.join(",")}childString(t){let r=this.buffer[t],s=this.buffer[t+3],l=this.set.types[r],f=l.name;if(/\W/.test(f)&&!l.isError)f=JSON.stringify(f);if(t+=4,s==t)return f;let h=[];while(t<s)h.push(this.childString(t)),t=this.buffer[t+3];return f+"("+h.join(",")+")"}findChild(t,r,s,l,f){let{buffer:h}=this,c=-1;for(let d=t;d!=r;d=h[d+3])if(br(f,l,h[d+1],h[d+2])){if(c=d,s>0)break}return c}slice(t,r,s){let l=this.buffer,f=new Uint16Array(r-t),h=0;for(let c=t,d=0;c<r;){f[d++]=l[c++],f[d++]=l[c++]-s;let m=f[d++]=l[c++]-s;f[d++]=l[c++]-t,h=Math.max(h,m)}return new ce(f,h,this.set)}}function br(t,r,s,l){switch(t){case-2:return s<r;case-1:return l>=r&&s<r;case 0:return s<r&&l>r;case 1:return s<=r&&l>r;case 2:return l>r;case 4:return!0}}function Fe(t,r,s,l){var f;while(t.from==t.to||(s<1?t.from>=r:t.from>r)||(s>-1?t.to<=r:t.to<r)){let c=!l&&t instanceof Z&&t.index<0?null:t.parent;if(!c)return t;t=c}let h=l?0:U.IgnoreOverlays;if(l){for(let c=t,d=c.parent;d;c=d,d=c.parent)if(c instanceof Z&&c.index<0&&((f=d.enter(r,s,h))===null||f===void 0?void 0:f.from)!=c.from)t=d}for(;;){let c=t.enter(r,s,h);if(!c)return t;t=c}}class Et{cursor(t=0){return new et(this,t)}getChild(t,r=null,s=null){let l=pr(this,t,r,s);return l.length?l[0]:null}getChildren(t,r=null,s=null){return pr(this,t,r,s)}resolve(t,r=0){return Fe(this,t,r,!1)}resolveInner(t,r=0){return Fe(this,t,r,!0)}matchContext(t){return Dt(this.parent,t)}enterUnfinishedNodesBefore(t){let r=this.childBefore(t),s=this;while(r){let l=r.lastChild;if(!l||l.to!=r.to)break;if(l.type.isError&&l.from==l.to)s=r,r=l.prevSibling;else r=l}return s}get node(){return this}get next(){return this.parent}}class Z extends Et{constructor(t,r,s,l){super();this._tree=t,this.from=r,this.index=s,this._parent=l}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,r,s,l,f=0){for(let h=this;;){for(let{children:c,positions:d}=h._tree,m=r>0?c.length:-1;t!=m;t+=r){let p=c[t],g=d[t]+h.from,b;if(!(f&U.EnterBracketed&&p instanceof W&&(b=Ee.get(p))&&!b.overlay&&b.bracketed&&s>=g&&s<=g+p.length)&&!br(l,s,g,g+p.length))continue;if(p instanceof ce){if(f&U.ExcludeBuffers)continue;let k=p.findChild(0,p.buffer.length,r,s-g,l);if(k>-1)return new he(new kr(h,p,t,g),null,k)}else if(f&U.IncludeAnonymous||(!p.type.isAnonymous||Lt(p))){let k;if(!(f&U.IgnoreMounts)&&(k=Ee.get(p))&&!k.overlay)return new Z(k.tree,g,t,h);let v=new Z(p,g,t,h);return f&U.IncludeAnonymous||!v.type.isAnonymous?v:v.nextChild(r<0?p.children.length-1:0,r,s,l,f)}}if(f&U.IncludeAnonymous||!h.type.isAnonymous)return null;if(h.index>=0)t=h.index+r;else t=r<0?-1:h._parent._tree.children.length;if(h=h._parent,!h)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(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}prop(t){return this._tree.prop(t)}enter(t,r,s=0){let l;if(!(s&U.IgnoreOverlays)&&(l=Ee.get(this._tree))&&l.overlay){let f=t-this.from,h=s&U.EnterBracketed&&l.bracketed;for(let{from:c,to:d}of l.overlay)if((r>0||h?c<=f:c<f)&&(r<0||h?d>=f:d>f))return new Z(l.tree,l.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,r,s)}nextSignificantParent(){let t=this;while(t.type.isAnonymous&&t._parent)t=t._parent;return t}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 pr(t,r,s,l){let f=t.cursor(),h=[];if(!f.firstChild())return h;if(s!=null){for(let c=!1;!c;)if(c=f.type.is(s),!f.nextSibling())return h}for(;;){if(l!=null&&f.type.is(l))return h;if(f.type.is(r))h.push(f.node);if(!f.nextSibling())return l==null?h:[]}}function Dt(t,r,s=r.length-1){for(let l=t;s>=0;l=l.parent){if(!l)return!1;if(!l.type.isAnonymous){if(r[s]&&r[s]!=l.name)return!1;s--}}return!0}class kr{constructor(t,r,s,l){this.parent=t,this.buffer=r,this.index=s,this.start=l}}class he extends Et{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(t,r,s){super();this.context=t,this._parent=r,this.index=s,this.type=t.buffer.set.types[t.buffer.buffer[s]]}child(t,r,s){let{buffer:l}=this.context,f=l.findChild(this.index+4,l.buffer[this.index+3],t,r-this.context.start,s);return f<0?null:new he(this.context,this,f)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}prop(t){return this.type.prop(t)}enter(t,r,s=0){if(s&U.ExcludeBuffers)return null;let{buffer:l}=this.context,f=l.findChild(this.index+4,l.buffer[this.index+3],r>0?1:-1,t-this.context.start,r);return f<0?null:new he(this.context,this,f)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,r=t.buffer[this.index+3];if(r<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length))return new he(this.context,this._parent,r);return this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,r=this._parent?this._parent.index+4:0;if(this.index==r)return this.externalSibling(-1);return new he(this.context,this._parent,t.findChild(r,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],r=[],{buffer:s}=this.context,l=this.index+4,f=s.buffer[this.index+3];if(f>l){let h=s.buffer[this.index+1];t.push(s.slice(l,f,h)),r.push(0)}return new W(this.type,t,r,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function xr(t){if(!t.length)return null;let r=0,s=t[0];for(let h=1;h<t.length;h++){let c=t[h];if(c.from>s.from||c.to<s.to)s=c,r=h}let l=s instanceof Z&&s.index<0?null:s.parent,f=t.slice();if(l)f[r]=l;else f.splice(r,1);return new vr(f,s)}class vr{constructor(t,r){this.heads=t,this.node=r}get next(){return xr(this.heads)}}function di(t,r,s){let l=t.resolveInner(r,s),f=null;for(let h=l instanceof Z?l:l.context.parent;h;h=h.parent)if(h.index<0){let c=h.parent;(f||(f=[l])).push(c.resolve(r,s)),h=c}else{let c=Ee.get(h.tree);if(c&&c.overlay&&c.overlay[0].from<=r&&c.overlay[c.overlay.length-1].to>=r){let d=new Z(c.tree,c.overlay[0].from+h.from,-1,h);(f||(f=[l])).push(Fe(d,r,s,!1))}}return f?xr(f):l}class et{get name(){return this.type.name}constructor(t,r=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=r&~U.EnterBracketed,t instanceof Z)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let s=t._parent;s;s=s._parent)this.stack.unshift(s.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){if(!t)return!1;return this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0}yieldBuf(t,r){this.index=t;let{start:s,buffer:l}=this.buffer;return this.type=r||l.set.types[l.buffer[t]],this.from=s+l.buffer[t+1],this.to=s+l.buffer[t+2],!0}yield(t){if(!t)return!1;if(t instanceof Z)return this.buffer=null,this.yieldNode(t);return this.buffer=t.context,this.yieldBuf(t.index,t.type)}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,r,s){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,r,s,this.mode));let{buffer:l}=this.buffer,f=l.findChild(this.index+4,l.buffer[this.index+3],t,r-this.buffer.start,s);if(f<0)return!1;return this.stack.push(this.index),this.yieldBuf(f)}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,r,s=this.mode){if(!this.buffer)return this.yield(this._tree.enter(t,r,s));return s&U.ExcludeBuffers?!1:this.enterChild(1,t,r)}parent(){if(!this.buffer)return this.yieldNode(this.mode&U.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&U.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return!this._tree._parent?!1:this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode));let{buffer:r}=this.buffer,s=this.stack.length-1;if(t<0){let l=s<0?0:this.stack[s]+4;if(this.index!=l)return this.yieldBuf(r.findChild(l,this.index,-1,0,4))}else{let l=r.buffer[this.index+3];if(l<(s<0?r.buffer.length:r.buffer[this.stack[s]+3]))return this.yieldBuf(l)}return s<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let r,s,{buffer:l}=this;if(l){if(t>0){if(this.index<l.buffer.buffer.length)return!1}else for(let f=0;f<this.index;f++)if(l.buffer.buffer[f+3]<this.index)return!1;({index:r,parent:s}=l)}else({index:r,_parent:s}=this._tree);for(;s;{index:r,_parent:s}=s)if(r>-1)for(let f=r+t,h=t<0?-1:s._tree.children.length;f!=h;f+=t){let c=s._tree.children[f];if(this.mode&U.IncludeAnonymous||c instanceof ce||!c.type.isAnonymous||Lt(c))return!1}return!0}move(t,r){if(r&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,r=0){while(this.from==this.to||(r<1?this.from>=t:this.from>t)||(r>-1?this.to<=t:this.to<t))if(!this.parent())break;while(this.enterChild(1,t,r));return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,r=null,s=0;if(t&&t.context==this.buffer)e:for(let l=this.index,f=this.stack.length;f>=0;){for(let h=t;h;h=h._parent)if(h.index==l){if(l==this.index)return h;r=h,s=f+1;break e}l=this.stack[--f]}for(let l=s;l<this.stack.length;l++)r=new he(this.buffer,r,this.stack[l]);return this.bufferNode=new he(this.buffer,r,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,r){for(let s=0;;){let l=!1;if(this.type.isAnonymous||t(this)!==!1){if(this.firstChild()){s++;continue}if(!this.type.isAnonymous)l=!0}for(;;){if(l&&r)r(this);if(l=this.type.isAnonymous,!s)return;if(this.nextSibling())break;this.parent(),s--,l=!0}}}matchContext(t){if(!this.buffer)return Dt(this.node.parent,t);let{buffer:r}=this.buffer,{types:s}=r.set;for(let l=t.length-1,f=this.stack.length-1;l>=0;f--){if(f<0)return Dt(this._tree,t,l);let h=s[r.buffer[this.stack[f]]];if(!h.isAnonymous){if(t[l]&&t[l]!=h.name)return!1;l--}}return!0}}function Lt(t){return t.children.some((r)=>r instanceof ce||!r.type.isAnonymous||Lt(r))}function mi(t){var r;let{buffer:s,nodeSet:l,maxBufferLength:f=1024,reused:h=[],minRepeatType:c=l.types.length}=t,d=Array.isArray(s)?new Bt(s,s.length):s,m=l.types,p=0,g=0;function b(S,E,y,I,V,H){let{id:R,start:T,end:z,size:G}=d,J=g,fe=p;if(G<0)if(d.next(),G==-1){let le=h[R];y.push(le),I.push(T-S);return}else if(G==-3){p=R;return}else if(G==-4){g=R;return}else throw RangeError(`Unrecognized record size: ${G}`);let Ne=m[R],Je,be,ur=T-S;if(z-T<=f&&(be=M(d.pos-E,V))){let le=new Uint16Array(be.size-be.skip),Q=d.pos-be.size,re=le.length;while(d.pos>Q)re=O(be.start,le,re);Je=new ce(le,z-be.start,l),ur=be.start-S}else{let le=d.pos-G;d.next();let Q=[],re=[],xe=R>=c?R:-1,De=0,Ke=z,yt=J;while(d.pos>le)if(xe>=0&&d.id==xe&&d.size>=0){if(d.end<=Ke-f)w(Q,re,T,De,d.end,Ke,xe,yt,fe),De=Q.length,Ke=d.end,yt=g;d.next()}else if(H>2500)k(T,le,Q,re);else b(T,le,Q,re,xe,H+1);if(xe>=0&&De>0&&De<Q.length)w(Q,re,T,De,T,Ke,xe,yt,fe);if(Q.reverse(),re.reverse(),xe>-1&&De>0){let dr=v(Ne,fe);Je=Ot(Ne,Q,re,0,Q.length,0,z-T,dr,dr)}else Je=B(Ne,Q,re,z-T,J-z,fe)}y.push(Je),I.push(ur)}function k(S,E,y,I){let V=[],H=0,R=-1;while(d.pos>E){let{id:T,start:z,end:G,size:J}=d;if(J>4)d.next();else if(R>-1&&z<R)break;else{if(R<0)R=G-f;V.push(T,z,G),H++,d.next()}}if(H){let T=new Uint16Array(H*4),z=V[V.length-2];for(let G=V.length-3,J=0;G>=0;G-=3)T[J++]=V[G],T[J++]=V[G+1]-z,T[J++]=V[G+2]-z,T[J++]=J;y.push(new ce(T,V[2]-z,l)),I.push(z-S)}}function v(S,E){return(y,I,V)=>{let H=0,R=y.length-1,T,z;if(R>=0&&(T=y[R])instanceof W){if(!R&&T.type==S&&T.length==V)return T;if(z=T.prop(Be.lookAhead))H=I[R]+T.length+z-V}return B(S,y,I,V,H,E)}}function w(S,E,y,I,V,H,R,T,z){let G=[],J=[];while(S.length>I)G.push(S.pop()),J.push(E.pop()+y-V);S.push(B(l.types[R],G,J,H-V,T-H,z)),E.push(V-y)}function B(S,E,y,I,V,H,R){if(H){let T=[Be.contextHash,H];R=R?[T].concat(R):[T]}if(V>25){let T=[Be.lookAhead,V];R=R?[T].concat(R):[T]}return new W(S,E,y,I,R)}function M(S,E){let y=d.fork(),I=0,V=0,H=0,R=y.end-f,T={size:0,start:0,skip:0};e:for(let z=y.pos-S;y.pos>z;){let G=y.size;if(y.id==E&&G>=0){T.size=I,T.start=V,T.skip=H,H+=4,I+=4,y.next();continue}let J=y.pos-G;if(G<0||J<z||y.start<R)break;let fe=y.id>=c?4:0,Ne=y.start;y.next();while(y.pos>J){if(y.size<0)if(y.size==-3||y.size==-4)fe+=4;else break e;else if(y.id>=c)fe+=4;y.next()}V=Ne,I+=G,H+=fe}if(E<0||I==S)T.size=I,T.start=V,T.skip=H;return T.size>4?T:void 0}function O(S,E,y){let{id:I,start:V,end:H,size:R}=d;if(d.next(),R>=0&&I<c){let T=y;if(R>4){let z=d.pos-(R-4);while(d.pos>z)y=O(S,E,y)}E[--y]=T,E[--y]=H-S,E[--y]=V-S,E[--y]=I}else if(R==-3)p=I;else if(R==-4)g=I;return y}let F=[],N=[];while(d.pos>0)b(t.start||0,t.bufferStart||0,F,N,-1,0);let L=(r=t.length)!==null&&r!==void 0?r:F.length?N[0]+F[0].length:0;return new W(m[t.topID],F.reverse(),N.reverse(),L)}var gr=new WeakMap;function Qe(t,r){if(!t.isAnonymous||r instanceof ce||r.type!=t)return 1;let s=gr.get(r);if(s==null){s=1;for(let l of r.children){if(l.type!=t||!(l instanceof W)){s=1;break}s+=Qe(t,l)}gr.set(r,s)}return s}function Ot(t,r,s,l,f,h,c,d,m){let p=0;for(let w=l;w<f;w++)p+=Qe(t,r[w]);let g=Math.ceil(p*1.5/8),b=[],k=[];function v(w,B,M,O,F){for(let N=M;N<O;){let L=N,S=B[N],E=Qe(t,w[N]);N++;for(;N<O;N++){let y=Qe(t,w[N]);if(E+y>=g)break;E+=y}if(N==L+1){if(E>g){let y=w[L];v(y.children,y.positions,0,y.children.length,B[L]+F);continue}b.push(w[L])}else{let y=B[N-1]+w[N-1].length-S;b.push(Ot(t,w,B,L,N,S,y,null,m))}k.push(S+F-h)}}return v(r,s,l,f,0),(d||m)(b,k,c)}class ue{constructor(t,r,s,l,f=!1,h=!1){this.from=t,this.to=r,this.tree=s,this.offset=l,this.open=(f?1:0)|(h?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,r=[],s=!1){let l=[new ue(0,t.length,t,0,!1,s)];for(let f of r)if(f.to>t.length)l.push(f);return l}static applyChanges(t,r,s=128){if(!r.length)return t;let l=[],f=1,h=t.length?t[0]:null;for(let c=0,d=0,m=0;;c++){let p=c<r.length?r[c]:null,g=p?p.fromA:1e9;if(g-d>=s)while(h&&h.from<g){let b=h;if(d>=b.from||g<=b.to||m){let k=Math.max(b.from,d)-m,v=Math.min(b.to,g)-m;b=k>=v?null:new ue(k,v,b.tree,b.offset+m,c>0,!!p)}if(b)l.push(b);if(h.to>g)break;h=f<t.length?t[f++]:null}if(!p)break;d=p.toA,m=p.toA-p.toB}return l}}class rt{startParse(t,r,s){if(typeof t=="string")t=new wr(t);return s=!s?[new Ye(0,t.length)]:s.length?s.map((l)=>new Ye(l.from,l.to)):[new Ye(0,0)],this.createParse(t,r||[],s)}parse(t,r,s){let l=this.startParse(t,r,s);for(;;){let f=l.advance();if(f)return f}}}class wr{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,r){return this.string.slice(t,r)}}var so=new Be({perNode:!0});var pi=0;class ee{constructor(t,r,s,l){this.name=t,this.set=r,this.base=s,this.modified=l,this.id=pi++}toString(){let{name:t}=this;for(let r of this.modified)if(r.name)t=`${r.name}(${t})`;return t}static define(t,r){let s=typeof t=="string"?t:"?";if(t instanceof ee)r=t;if(r===null||r===void 0?void 0:r.base)throw Error("Can not derive from a modified tag");let l=new ee(s,[],null,[]);if(l.set.push(l),r)for(let f of r.set)l.set.push(f);return l}static defineModifier(t){let r=new ot(t);return(s)=>{if(s.modified.indexOf(r)>-1)return s;return ot.get(s.base||s,s.modified.concat(r).sort((l,f)=>l.id-f.id))}}}var gi=0;class ot{constructor(t){this.name=t,this.instances=[],this.id=gi++}static get(t,r){if(!r.length)return t;let s=r[0].instances.find((c)=>c.base==t&&bi(r,c.modified));if(s)return s;let l=[],f=new ee(t.name,l,t,r);for(let c of r)c.instances.push(f);let h=ki(r);for(let c of t.set)if(!c.modified.length)for(let d of h)l.push(ot.get(c,d));return f}}function bi(t,r){return t.length==r.length&&t.every((s,l)=>s==r[l])}function ki(t){let r=[[]];for(let s=0;s<t.length;s++)for(let l=0,f=r.length;l<f;l++)r.push(r[l].concat(t[s]));return r.sort((s,l)=>l.length-s.length)}function Ar(t){let r=Object.create(null);for(let s in t){let l=t[s];if(!Array.isArray(l))l=[l];for(let f of s.split(" "))if(f){let h=[],c=2,d=f;for(let b=0;;){if(d=="..."&&b>0&&b+3==f.length){c=1;break}let k=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(d);if(!k)throw RangeError("Invalid path: "+f);if(h.push(k[0]=="*"?"":k[0][0]=='"'?JSON.parse(k[0]):k[0]),b+=k[0].length,b==f.length)break;let v=f[b++];if(b==f.length&&v=="!"){c=0;break}if(v!="/")throw RangeError("Invalid path: "+f);d=f.slice(b)}let m=h.length-1,p=h[m];if(!p)throw RangeError("Invalid path: "+f);let g=new Le(l,c,m>0?h.slice(0,m):null);r[p]=g.sort(r[p])}}return Sr.add(r)}var Sr=new Be({combine(t,r){let s,l,f;while(t||r){if(!t||r&&t.depth<=r.depth)f=r,r=r.next;else f=t,t=t.next;if(s&&s.mode==f.mode&&!f.context&&!s.context)continue;let h=new Le(f.tags,f.mode,f.context);if(s)s.next=h;else l=h;s=h}return l}});class Le{constructor(t,r,s,l){this.tags=t,this.mode=r,this.context=s,this.next=l}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(t){if(!t||t.depth<this.depth)return this.next=t,this;return t.next=this.sort(t.next),t}get depth(){return this.context?this.context.length:0}}Le.empty=new Le([],2,null);function Pt(t,r){let s=Object.create(null);for(let h of t)if(!Array.isArray(h.tag))s[h.tag.id]=h.class;else for(let c of h.tag)s[c.id]=h.class;let{scope:l,all:f=null}=r||{};return{style:(h)=>{let c=f;for(let d of h)for(let m of d.set){let p=s[m.id];if(p){c=c?c+" "+p:p;break}}return c},scope:l}}function xi(t,r){let s=null;for(let l of t){let f=l.style(r);if(f)s=s?s+" "+f:f}return s}function Rt(t,r,s,l=0,f=t.length){let h=new Mr(l,Array.isArray(r)?r:[r],s);h.highlightRange(t.cursor(),l,f,"",h.highlighters),h.flush(f)}class Mr{constructor(t,r,s){this.at=t,this.highlighters=r,this.span=s,this.class=""}startSpan(t,r){if(r!=this.class){if(this.flush(t),t>this.at)this.at=t;this.class=r}}flush(t){if(t>this.at&&this.class)this.span(this.at,t,this.class)}highlightRange(t,r,s,l,f){let{type:h,from:c,to:d}=t;if(c>=s||d<=r)return;if(h.isTop)f=this.highlighters.filter((k)=>!k.scope||k.scope(h));let m=l,p=vi(t)||Le.empty,g=xi(f,p.tags);if(g){if(m)m+=" ";if(m+=g,p.mode==1)l+=(l?" ":"")+g}if(this.startSpan(Math.max(r,c),m),p.opaque)return;let b=t.tree&&t.tree.prop(Be.mounted);if(b&&b.overlay){let k=t.node.enter(b.overlay[0].from+c,1),v=this.highlighters.filter((B)=>!B.scope||B.scope(b.tree.type)),w=t.firstChild();for(let B=0,M=c;;B++){let O=B<b.overlay.length?b.overlay[B]:null,F=O?O.from+c:d,N=Math.max(r,M),L=Math.min(s,F);if(N<L&&w){while(t.from<L)if(this.highlightRange(t,N,L,l,f),this.startSpan(Math.min(L,t.to),m),t.to>=F||!t.nextSibling())break}if(!O||F>s)break;if(M=O.to+c,M>r)this.highlightRange(k.cursor(),Math.max(r,O.from+c),Math.min(s,M),"",v),this.startSpan(Math.min(s,M),m)}if(w)t.parent()}else if(t.firstChild()){if(b)l="";do{if(t.to<=r)continue;if(t.from>=s)break;this.highlightRange(t,r,s,l,f),this.startSpan(Math.min(s,t.to),m)}while(t.nextSibling());t.parent()}}}function vi(t){let r=t.type.prop(Sr);while(r&&r.context&&!t.matchContext(r.context))r=r.next;return r||null}var C=ee.define,nt=C(),de=C(),yr=C(de),Cr=C(de),pe=C(),it=C(pe),Tt=C(pe),se=C(),ve=C(se),ne=C(),ie=C(),It=C(),Ve=C(It),st=C(),A={comment:nt,lineComment:C(nt),blockComment:C(nt),docComment:C(nt),name:de,variableName:C(de),typeName:yr,tagName:C(yr),propertyName:Cr,attributeName:C(Cr),className:C(de),labelName:C(de),namespace:C(de),macroName:C(de),literal:pe,string:it,docString:C(it),character:C(it),attributeValue:C(it),number:Tt,integer:C(Tt),float:C(Tt),bool:C(pe),regexp:C(pe),escape:C(pe),color:C(pe),url:C(pe),keyword:ne,self:C(ne),null:C(ne),atom:C(ne),unit:C(ne),modifier:C(ne),operatorKeyword:C(ne),controlKeyword:C(ne),definitionKeyword:C(ne),moduleKeyword:C(ne),operator:ie,derefOperator:C(ie),arithmeticOperator:C(ie),logicOperator:C(ie),bitwiseOperator:C(ie),compareOperator:C(ie),updateOperator:C(ie),definitionOperator:C(ie),typeOperator:C(ie),controlOperator:C(ie),punctuation:It,separator:C(It),bracket:Ve,angleBracket:C(Ve),squareBracket:C(Ve),paren:C(Ve),brace:C(Ve),content:se,heading:ve,heading1:C(ve),heading2:C(ve),heading3:C(ve),heading4:C(ve),heading5:C(ve),heading6:C(ve),contentSeparator:C(se),list:C(se),quote:C(se),emphasis:C(se),strong:C(se),link:C(se),monospace:C(se),strikethrough:C(se),inserted:C(),deleted:C(),changed:C(),invalid:C(),meta:st,documentMeta:C(st),annotation:C(st),processingInstruction:C(st),definition:ee.defineModifier("definition"),constant:ee.defineModifier("constant"),function:ee.defineModifier("function"),standard:ee.defineModifier("standard"),local:ee.defineModifier("local"),special:ee.defineModifier("special")};for(let t in A){let r=A[t];if(r instanceof ee)r.name=t}var fo=Pt([{tag:A.link,class:"tok-link"},{tag:A.heading,class:"tok-heading"},{tag:A.emphasis,class:"tok-emphasis"},{tag:A.strong,class:"tok-strong"},{tag:A.keyword,class:"tok-keyword"},{tag:A.atom,class:"tok-atom"},{tag:A.bool,class:"tok-bool"},{tag:A.url,class:"tok-url"},{tag:A.labelName,class:"tok-labelName"},{tag:A.inserted,class:"tok-inserted"},{tag:A.deleted,class:"tok-deleted"},{tag:A.literal,class:"tok-literal"},{tag:A.string,class:"tok-string"},{tag:A.number,class:"tok-number"},{tag:[A.regexp,A.escape,A.special(A.string)],class:"tok-string2"},{tag:A.variableName,class:"tok-variableName"},{tag:A.local(A.variableName),class:"tok-variableName tok-local"},{tag:A.definition(A.variableName),class:"tok-variableName tok-definition"},{tag:A.special(A.variableName),class:"tok-variableName2"},{tag:A.definition(A.propertyName),class:"tok-propertyName tok-definition"},{tag:A.typeName,class:"tok-typeName"},{tag:A.namespace,class:"tok-namespace"},{tag:A.className,class:"tok-className"},{tag:A.macroName,class:"tok-macroName"},{tag:A.propertyName,class:"tok-propertyName"},{tag:A.operator,class:"tok-operator"},{tag:A.comment,class:"tok-comment"},{tag:A.meta,class:"tok-meta"},{tag:A.invalid,class:"tok-invalid"},{tag:A.punctuation,class:"tok-punctuation"}]);function Dr(t,r,s,l=0,f=0){if(r==null){if(r=t.search(/[^\s\u00a0]/),r==-1)r=t.length}let h=f;for(let c=l;c<r;c++)if(t.charCodeAt(c)==9)h+=s-h%s;else h++;return h}class at{constructor(t,r,s,l){this.string=t,this.tabSize=r,this.indentUnit=s,this.overrideIndent=l,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(t){let r=this.string.charAt(this.pos),s;if(typeof t=="string")s=r==t;else s=r&&(t instanceof RegExp?t.test(r):t(r));if(s)return++this.pos,r}eatWhile(t){let r=this.pos;while(this.eat(t));return this.pos>r}eatSpace(){let t=this.pos;while(/[\s\u00a0]/.test(this.string.charAt(this.pos)))++this.pos;return this.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){let r=this.string.indexOf(t,this.pos);if(r>-1)return this.pos=r,!0}backUp(t){this.pos-=t}column(){if(this.lastColumnPos<this.start)this.lastColumnValue=Dr(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start;return this.lastColumnValue}indentation(){var t;return(t=this.overrideIndent)!==null&&t!==void 0?t:Dr(this.string,null,this.tabSize)}match(t,r,s){if(typeof t=="string"){let l=(h)=>s?h.toLowerCase():h,f=this.string.substr(this.pos,t.length);if(l(f)==l(t)){if(r!==!1)this.pos+=t.length;return!0}else return null}else{let l=this.string.slice(this.pos).match(t);if(l&&l.index>0)return null;if(l&&r!==!1)this.pos+=l[0].length;return l}}current(){return this.string.slice(this.start,this.pos)}}var _t,Te=new Be;function wi(t){return P.define({combine:t?(r)=>r.concat(t):void 0})}var yi=new Be;class te{constructor(t,r,s=[],l=""){if(this.data=t,this.name=l,!me.prototype.hasOwnProperty("tree"))Object.defineProperty(me.prototype,"tree",{get(){return zn(this)}});this.parser=r,this.extension=[Ao.of(this),me.languageData.of((f,h,c)=>{let d=Br(f,h,c),m=d.type.prop(Te);if(!m)return[];let p=f.facet(m),g=d.type.prop(yi);if(g){let b=d.resolve(h-d.from,c);for(let k of g)if(k.test(b,f)){let v=f.facet(k.facet);return k.type=="replace"?v:v.concat(p)}}return p})].concat(s)}isActiveAt(t,r,s=-1){return Br(t,r,s).type.prop(Te)==this.data}findRegions(t){let r=t.facet(Ao);if((r===null||r===void 0?void 0:r.data)==this.data)return[{from:0,to:t.doc.length}];if(!r||!r.allowsNesting)return[];let s=[],l=(f,h)=>{if(f.prop(Te)==this.data){s.push({from:h,to:h+f.length});return}let c=f.prop(Be.mounted);if(c){if(c.tree.prop(Te)==this.data){if(c.overlay)for(let d of c.overlay)s.push({from:d.from+h,to:d.to+h});else s.push({from:h,to:h+f.length});return}else if(c.overlay){let d=s.length;if(l(c.tree,c.overlay[0].from+h),s.length>d)return}}for(let d=0;d<f.children.length;d++){let m=f.children[d];if(m instanceof W)l(m,f.positions[d]+h)}};return l(zn(t),0),s}get allowsNesting(){return!0}}te.setState=oe.define();function Br(t,r,s){let l=t.facet(Ao),f=zn(t).topNode;if(!l||l.allowsNesting){for(let h=f;h;h=h.enter(r,s,U.ExcludeBuffers|U.EnterBracketed))if(h.type.isTop)f=h}return f}function zn(t){let r=t.field(te.state,!1);return r?r.tree:W.empty}class Fr{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,r){let s=this.cursorPos-this.string.length;if(t<s||r>=this.cursorPos)return this.doc.sliceString(t,r);else return this.string.slice(t-s,r-s)}}var ze=null;class Ie{constructor(t,r,s=[],l,f,h,c,d){this.parser=t,this.state=r,this.fragments=s,this.tree=l,this.treeLen=f,this.viewport=h,this.skipped=c,this.scheduleOn=d,this.parse=null,this.tempSkipped=[]}static create(t,r,s){return new Ie(t,r,[],W.empty,0,s,[],null)}startParse(){return this.parser.startParse(new Fr(this.state.doc),this.fragments)}work(t,r){if(r!=null&&r>=this.state.doc.length)r=void 0;if(this.tree!=W.empty&&this.isDone(r!==null&&r!==void 0?r:this.state.doc.length))return this.takeTree(),!0;return this.withContext(()=>{var s;if(typeof t=="number"){let l=Date.now()+t;t=()=>Date.now()>l}if(!this.parse)this.parse=this.startParse();if(r!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>r)&&r<this.state.doc.length)this.parse.stopAt(r);for(;;){let l=this.parse.advance();if(l)if(this.fragments=this.withoutTempSkipped(ue.addTree(l,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(s=this.parse.stoppedAt)!==null&&s!==void 0?s:this.state.doc.length,this.tree=l,this.parse=null,this.treeLen<(r!==null&&r!==void 0?r:this.state.doc.length))this.parse=this.startParse();else return!0;if(t())return!1}})}takeTree(){let t,r;if(this.parse&&(t=this.parse.parsedPos)>=this.treeLen){if(this.parse.stoppedAt==null||this.parse.stoppedAt>t)this.parse.stopAt(t);this.withContext(()=>{while(!(r=this.parse.advance()));}),this.treeLen=t,this.tree=r,this.fragments=this.withoutTempSkipped(ue.addTree(this.tree,this.fragments,!0)),this.parse=null}}withContext(t){let r=ze;ze=this;try{return t()}finally{ze=r}}withoutTempSkipped(t){for(let r;r=this.tempSkipped.pop();)t=Lr(t,r.from,r.to);return t}changes(t,r){let{fragments:s,tree:l,treeLen:f,viewport:h,skipped:c}=this;if(this.takeTree(),!t.empty){let d=[];if(t.iterChangedRanges((m,p,g,b)=>d.push({fromA:m,toA:p,fromB:g,toB:b})),s=ue.applyChanges(s,d),l=W.empty,f=0,h={from:t.mapPos(h.from,-1),to:t.mapPos(h.to,1)},this.skipped.length){c=[];for(let m of this.skipped){let p=t.mapPos(m.from,1),g=t.mapPos(m.to,-1);if(p<g)c.push({from:p,to:g})}}}return new Ie(this.parser,r,s,l,f,h,c,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let r=this.skipped.length;for(let s=0;s<this.skipped.length;s++){let{from:l,to:f}=this.skipped[s];if(l<t.to&&f>t.from)this.fragments=Lr(this.fragments,l,f),this.skipped.splice(s--,1)}if(this.skipped.length>=r)return!1;return this.reset(),!0}reset(){if(this.parse)this.takeTree(),this.parse=null}skipUntilInView(t,r){this.skipped.push({from:t,to:r})}static getSkippingParser(t){return new class extends rt{createParse(r,s,l){let f=l[0].from,h=l[l.length-1].to;return{parsedPos:f,advance(){let d=ze;if(d){for(let m of l)d.tempSkipped.push(m);if(t)d.scheduleOn=d.scheduleOn?Promise.all([d.scheduleOn,t]):t}return this.parsedPos=h,new W(Y.none,[],[],h-f)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let r=this.fragments;return this.treeLen>=t&&r.length&&r[0].from==0&&r[0].to>=t}static get(){return ze}}function Lr(t,r,s){return ue.applyChanges(t,[{fromA:r,toA:s,fromB:r,toB:s}])}class Pe{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let r=this.context.changes(t.changes,t.state),s=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),r.viewport.to);if(!r.work(20,s))r.takeTree();return new Pe(r)}static init(t){let r=Math.min(3000,t.doc.length),s=Ie.create(t.facet(Ao).parser,t,{from:0,to:r});if(!s.work(20,r))s.takeTree();return new Pe(s)}}te.state=Oe.define({create:Pe.init,update(t,r){for(let s of r.effects)if(s.is(te.setState))return s.value;if(r.startState.facet(Ao)!=r.state.facet(Ao))return Pe.init(r.state);return t.apply(r)}});var Vr=(t)=>{let r=setTimeout(()=>t(),500);return()=>clearTimeout(r)};if(typeof requestIdleCallback<"u")Vr=(t)=>{let r=-1,s=setTimeout(()=>{r=requestIdleCallback(t,{timeout:400})},100);return()=>r<0?clearTimeout(s):cancelIdleCallback(r)};var Nt=typeof navigator<"u"&&((_t=navigator.scheduling)===null||_t===void 0?void 0:_t.isInputPending)?()=>navigator.scheduling.isInputPending():null,Ci=ye.fromClass(class{constructor(r){this.view=r,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(r){let s=this.view.state.field(te.state).context;if(s.updateViewport(r.view.viewport)||this.view.viewport.to>s.treeLen)this.scheduleWork();if(r.docChanged||r.selectionSet){if(this.view.hasFocus)this.chunkBudget+=50;this.scheduleWork()}this.checkAsyncSchedule(s)}scheduleWork(){if(this.working)return;let{state:r}=this.view,s=r.field(te.state);if(s.tree!=s.context.tree||!s.context.isDone(r.doc.length))this.working=Vr(this.work)}work(r){this.working=null;let s=Date.now();if(this.chunkEnd<s&&(this.chunkEnd<0||this.view.hasFocus))this.chunkEnd=s+30000,this.chunkBudget=3000;if(this.chunkBudget<=0)return;let{state:l,viewport:{to:f}}=this.view,h=l.field(te.state);if(h.tree==h.context.tree&&h.context.isDone(f+1e5))return;let c=Date.now()+Math.min(this.chunkBudget,100,r&&!Nt?Math.max(25,r.timeRemaining()-5):1e9),d=h.context.treeLen<f&&l.doc.length>f+1000,m=h.context.work(()=>Nt&&Nt()||Date.now()>c,f+(d?0:1e5));if(this.chunkBudget-=Date.now()-s,m||this.chunkBudget<=0)h.context.takeTree(),this.view.dispatch({effects:te.setState.of(new Pe(h.context))});if(this.chunkBudget>0&&!(m&&!d))this.scheduleWork();this.checkAsyncSchedule(h.context)}checkAsyncSchedule(r){if(r.scheduleOn)this.workScheduled++,r.scheduleOn.then(()=>this.scheduleWork()).catch((s)=>wn(this.view.state,s)).then(()=>this.workScheduled--),r.scheduleOn=null}destroy(){if(this.working)this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Ao=P.define({combine(t){return t.length?t[0]:null},enables:(t)=>[te.state,Ci,_.contentAttributes.compute([t],(r)=>{let s=r.facet(t);return s&&s.name?{"data-language":s.name}:{}})]});var fp=P.define(),Pi=P.define({combine:(t)=>{if(!t.length)return" ";let r=t[0];if(!r||/\S/.test(r)||Array.from(r).some((s)=>s!=r[0]))throw Error("Invalid indent unit: "+JSON.stringify(t[0]));return r}});function ri(t){let r=t.facet(Pi);return r.charCodeAt(0)==9?t.tabSize*r.length:r.length}function Xs(t,r){let s="",l=t.tabSize,f=t.facet(Pi)[0];if(f=="\t"){while(r>=l)s+="\t",r-=l;f=" "}for(let h=0;h<r;h++)s+=f;return s}function Ku(t,r){if(t instanceof me)t=new el(t);for(let l of t.state.facet(fp)){let f=l(t,r);if(f!==void 0)return f}let s=zn(t.state);return s.length>=r?Ai(t,s,r):null}class el{constructor(t,r={}){this.state=t,this.options=r,this.unit=ri(t)}lineAt(t,r=1){let s=this.state.doc.lineAt(t),{simulateBreak:l,simulateDoubleBreak:f}=this.options;if(l!=null&&l>=s.from&&l<=s.to)if(f&&l==t)return{text:"",from:t};else if(r<0?l<t:l<=t)return{text:s.text.slice(l-s.from),from:l};else return{text:s.text.slice(0,l-s.from),from:s.from};return s}textAfterPos(t,r=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:s,from:l}=this.lineAt(t,r);return s.slice(t-l,Math.min(s.length,t+100-l))}column(t,r=1){let{text:s,from:l}=this.lineAt(t,r),f=this.countColumn(s,t-l),h=this.options.overrideIndentation?this.options.overrideIndentation(l):-1;if(h>-1)f+=h-this.countColumn(s,s.search(/\S|$/));return f}countColumn(t,r=t.length){return ma(t,this.state.tabSize,r)}lineIndent(t,r=1){let{text:s,from:l}=this.lineAt(t,r),f=this.options.overrideIndentation;if(f){let h=f(l);if(h>-1)return h}return this.countColumn(s,s.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}var zr=new Be;function Ai(t,r,s){let l=r.resolveStack(s),f=r.resolveInner(s,-1).resolve(s,0).enterUnfinishedNodesBefore(s);if(f!=l.node){let h=[];for(let c=f;c&&!(c.from<l.node.from||c.to>l.node.to||c.from==l.node.from&&c.type==l.node.type);c=c.parent)h.push(c);for(let c=h.length-1;c>=0;c--)l={node:h[c],next:l}}return Wr(l,t,s)}function Wr(t,r,s){for(let l=t;l;l=l.next){let f=Mi(l.node);if(f)return f(Ht.create(r,s,l))}return 0}function Si(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function Mi(t){let r=t.type.prop(zr);if(r)return r;let s=t.firstChild,l;if(s&&(l=s.type.prop(Be.closedBy))){let f=t.lastChild,h=f&&l.indexOf(f.name)>-1;return(c)=>Li(c,!0,1,void 0,h&&!Si(c)?f.from:void 0)}return t.parent==null?Di:null}function Di(){return 0}class Ht extends el{constructor(t,r,s){super(t.state,t.options);this.base=t,this.pos=r,this.context=s}get node(){return this.context.node}static create(t,r,s){return new Ht(t,r,s)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let r=this.state.doc.lineAt(t.from);for(;;){let s=t.resolve(r.from);while(s.parent&&s.parent.from==s.from)s=s.parent;if(Bi(s,t))break;r=this.state.doc.lineAt(s.from)}return this.lineIndent(r.from)}continue(){return Wr(this.context.next,this.base,this.pos)}}function Bi(t,r){for(let s=r;s;s=s.parent)if(t==s)return!0;return!1}function Ei(t){let r=t.node,s=r.childAfter(r.from),l=r.lastChild;if(!s)return null;let f=t.options.simulateBreak,h=t.state.doc.lineAt(s.from),c=f==null||f<=h.from?h.to:Math.min(h.to,f);for(let d=s.to;;){let m=r.childAfter(d);if(!m||m==l)return null;if(!m.type.isSkipped){if(m.from>=c)return null;let p=/^ */.exec(h.text.slice(s.to-h.from))[0].length;return{from:s.from,to:s.to+p}}d=m.to}}function Li(t,r,s,l,f){let h=t.textAfter,c=h.match(/^\s*/)[0].length,d=l&&h.slice(c,c+l.length)==l||f==t.pos+c,m=r?Ei(t):null;if(m)return d?t.column(m.from):t.column(m.to);return t.baseIndent+(d?0:t.unit*s)}var Ti=200;function dg(){return me.transactionFilter.of((t)=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let r=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!r.length)return t;let s=t.newDoc,{head:l}=t.newSelection.main,f=s.lineAt(l);if(l>f.from+Ti)return t;let h=s.sliceString(f.from,l);if(!r.some((p)=>p.test(h)))return t;let{state:c}=t,d=-1,m=[];for(let{head:p}of c.selection.ranges){let g=c.doc.lineAt(p);if(g.from==d)continue;d=g.from;let b=Ku(c,g.from);if(b==null)continue;let k=/^\s*/.exec(g.text)[0],v=Xs(c,b);if(k!=v)m.push({from:g.from,to:g.from+k.length,insert:v})}return m.length?[t,{changes:m,sequential:!0}]:t})}var Vu=P.define(),Ii=new Be;function Ri(t,r,s){let l=zn(t);if(l.length<s)return null;let f=l.resolveStack(s,1),h=null;for(let c=f;c;c=c.next){let d=c.node;if(d.to<=s||d.from>s)continue;if(h&&d.from<r)break;let m=d.type.prop(Ii);if(m&&(d.to<l.length-50||l.length==t.doc.length||!_i(d))){let p=m(d,t);if(p&&p.from<=s&&p.from>=r&&p.to>s)h=p}}return h}function _i(t){let r=t.lastChild;return r&&r.to==t.to&&r.type.isError}function ht(t,r,s){for(let l of t.facet(Vu)){let f=l(t,r,s);if(f)return f}return Ri(t,r,s)}function Gr(t,r){let s=r.mapPos(t.from,1),l=r.mapPos(t.to,-1);return s>=l?void 0:{from:s,to:l}}var ut=oe.define({map:Gr}),We=oe.define({map:Gr});function Ur(t){let r=[];for(let{head:s}of t.state.selection.ranges){if(r.some((l)=>l.from<=s&&l.to>=s))continue;r.push(t.lineBlockAt(s))}return r}var Ce=Oe.define({create(){return D.none},update(t,r){if(r.isUserEvent("delete"))r.changes.iterChangedRanges((l,f)=>t=Or(t,l,f));t=t.map(r.changes);let s=[];for(let l of r.effects)if(l.is(ut)&&!Ni(t,l.value.from,l.value.to))s.push(l.value);else if(l.is(We))t=t.update({filter:(f,h)=>l.value.from!=f||l.value.to!=h,filterFrom:l.value.from,filterTo:l.value.to});if(s.length){let{preparePlaceholder:l}=r.state.facet(Wt),f=s.map((h)=>(!l?Tr:D.replace({widget:new Jr(l(r.state,h))})).range(h.from,h.to));t=t.update({add:f})}if(r.selection)t=Or(t,r.selection.main.head);return t},provide:(t)=>_.decorations.from(t),toJSON(t,r){let s=[];return t.between(0,r.doc.length,(l,f)=>{s.push(l,f)}),s},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw RangeError("Invalid JSON for fold state");let r=[];for(let s=0;s<t.length;){let l=t[s++],f=t[s++];if(typeof l!="number"||typeof f!="number")throw RangeError("Invalid JSON for fold state");r.push(Tr.range(l,f))}return D.set(r,!0)}});function Or(t,r,s=r){let l=!1;return t.between(r,s,(f,h)=>{if(f<s&&h>r)l=!0}),!l?t:t.update({filterFrom:r,filterTo:s,filter:(f,h)=>f>=s||h<=r})}function ct(t,r,s){var l;let f=null;return(l=t.field(Ce,!1))===null||l===void 0||l.between(r,s,(h,c)=>{if(!f||f.from>h)f={from:h,to:c}}),f}function Ni(t,r,s){let l=!1;return t.between(r,r,(f,h)=>{if(f==r&&h==s)l=!0}),l}function jr(t,r){return t.field(Ce,!1)?r:r.concat(oe.appendConfig.of(tl()))}var gp=(t)=>{for(let r of Ur(t)){let s=ht(t.state,r.from,r.to);if(s)return t.dispatch({effects:jr(t.state,[ut.of(s),$r(t,s)])}),!0}return!1},Ap=(t)=>{if(!t.state.field(Ce,!1))return!1;let r=[];for(let s of Ur(t)){let l=ct(t.state,s.from,s.to);if(l)r.push(We.of(l),$r(t,l,!1))}if(r.length)t.dispatch({effects:r});return r.length>0};function $r(t,r,s=!0){let l=t.state.doc.lineAt(r.from).number,f=t.state.doc.lineAt(r.to).number;return _.announce.of(`${t.state.phrase(s?"Folded lines":"Unfolded lines")} ${l} ${t.state.phrase("to")} ${f}.`)}var hp=(t)=>{let{state:r}=t,s=[];for(let l=0;l<r.doc.length;){let f=t.lineBlockAt(l),h=ht(r,f.from,f.to);if(h)s.push(ut.of(h));l=(h?t.lineBlockAt(h.to):f).to+1}if(s.length)t.dispatch({effects:jr(t.state,s)});return!!s.length},bp=(t)=>{let r=t.state.field(Ce,!1);if(!r||!r.size)return!1;let s=[];return r.between(0,t.state.doc.length,(l,f)=>{s.push(We.of({from:l,to:f}))}),t.dispatch({effects:s}),!0};var NA=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:gp},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Ap},{key:"Ctrl-Alt-[",run:hp},{key:"Ctrl-Alt-]",run:bp}],Fi={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Wt=P.define({combine(t){return Nn(t,Fi)}});function tl(t){let r=[Ce,zi];if(t)r.push(Wt.of(t));return r}function qr(t,r){let{state:s}=t,l=s.facet(Wt),f=(c)=>{let d=t.lineBlockAt(t.posAtDOM(c.target)),m=ct(t.state,d.from,d.to);if(m)t.dispatch({effects:We.of(m)});c.preventDefault()};if(l.placeholderDOM)return l.placeholderDOM(t,f,r);let h=document.createElement("span");return h.textContent=l.placeholderText,h.setAttribute("aria-label",s.phrase("folded code")),h.title=s.phrase("unfold"),h.className="cm-foldPlaceholder",h.onclick=f,h}var Tr=D.replace({widget:new class extends Mt{toDOM(t){return qr(t,null)}}});class Jr extends Mt{constructor(t){super();this.value=t}eq(t){return this.value==t.value}toDOM(t){return qr(t,this.value)}}var Vi={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class ft extends Qn{constructor(t,r){super();this.config=t,this.open=r}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let r=document.createElement("span");return r.textContent=this.open?this.config.openText:this.config.closedText,r.title=t.state.phrase(this.open?"Fold line":"Unfold line"),r}}function Yu(t={}){let r={...Vi,...t},s=new ft(r,!0),l=new ft(r,!1),f=ye.fromClass(class{constructor(c){this.from=c.viewport.from,this.markers=this.buildMarkers(c)}update(c){if(c.docChanged||c.viewportChanged||c.startState.facet(Ao)!=c.state.facet(Ao)||c.startState.field(Ce,!1)!=c.state.field(Ce,!1)||zn(c.startState)!=zn(c.state)||r.foldingChanged(c))this.markers=this.buildMarkers(c.view)}buildMarkers(c){let d=new lt;for(let m of c.viewportLineBlocks){let p=ct(c.state,m.from,m.to)?l:ht(c.state,m.from,m.to)?s:null;if(p)d.add(m.from,m.from,p)}return d.finish()}}),{domEventHandlers:h}=r;return[f,Oi({class:"cm-foldGutter",markers(c){var d;return((d=c.plugin(f))===null||d===void 0?void 0:d.markers)||ge.empty},initialSpacer(){return new ft(r,!1)},domEventHandlers:{...h,click:(c,d,m)=>{if(h.click&&h.click(c,d,m))return!0;let p=ct(c.state,d.from,d.to);if(p)return c.dispatch({effects:We.of(p)}),!0;let g=ht(c.state,d.from,d.to);if(g)return c.dispatch({effects:ut.of(g)}),!0;return!1}}}),tl()]}var zi=_.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"}});class Gt{constructor(t,r){this.specs=t;let s;function l(c){let d=Hr.newName();return(s||(s=Object.create(null)))["."+d]=c,d}let f=typeof r.all=="string"?r.all:r.all?l(r.all):void 0,h=r.scope;this.scope=h instanceof te?(c)=>c.prop(Te)==h.data:h?(c)=>c==h:void 0,this.style=Pt(t.map((c)=>({tag:c.tag,class:c.class||l(Object.assign({},c,{tag:null}))})),{all:f}).style,this.module=s?new Hr(s):null,this.themeType=r.themeType}static define(t,r){return new Gt(t,r||{})}}var Hi=P.define(),Wi=P.define({combine(t){return t.length?[t[0]]:null}});function Gi(t){let r=t.facet(Hi);return r.length?r:t.facet(Wi)}function QA(t,r,s){let l=Gi(t),f=null;if(l){for(let h of l)if(!h.scope||s&&h.scope(s)){let c=h.style(r);if(c)f=f?f+" "+c:c}}return f}var vo=Gt.define([{tag:A.meta,color:"#404740"},{tag:A.link,textDecoration:"underline"},{tag:A.heading,textDecoration:"underline",fontWeight:"bold"},{tag:A.emphasis,fontStyle:"italic"},{tag:A.strong,fontWeight:"bold"},{tag:A.strikethrough,textDecoration:"line-through"},{tag:A.keyword,color:"#708"},{tag:[A.atom,A.bool,A.url,A.contentSeparator,A.labelName],color:"#219"},{tag:[A.literal,A.inserted],color:"#164"},{tag:[A.string,A.deleted],color:"#a11"},{tag:[A.regexp,A.escape,A.special(A.string)],color:"#e40"},{tag:A.definition(A.variableName),color:"#00f"},{tag:A.local(A.variableName),color:"#30a"},{tag:[A.typeName,A.namespace],color:"#085"},{tag:A.className,color:"#167"},{tag:[A.special(A.variableName),A.macroName],color:"#256"},{tag:A.definition(A.propertyName),color:"#00c"},{tag:A.comment,color:"#940"},{tag:A.invalid,color:"#f00"}]),Ui=_.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Kr=1e4,Xr="()[]{}",Yr=P.define({combine(t){return Nn(t,{afterCursor:!0,brackets:Xr,maxScanDistance:Kr,renderMatch:qi})}}),ji=D.mark({class:"cm-matchingBracket"}),$i=D.mark({class:"cm-nonmatchingBracket"});function qi(t){let r=[],s=t.matched?ji:$i;if(r.push(s.range(t.start.from,t.start.to)),t.end)r.push(s.range(t.end.from,t.end.to));return r}function Pr(t){let r=[],s=t.facet(Yr);for(let l of t.selection.ranges){if(!l.empty)continue;let f=Er(t,l.head,-1,s)||l.head>0&&Er(t,l.head-1,1,s)||s.afterCursor&&(Er(t,l.head,1,s)||l.head<t.doc.length&&Er(t,l.head+1,-1,s));if(f)r=r.concat(s.renderMatch(f,t))}return D.set(r,!0)}var Ji=ye.fromClass(class{constructor(t){this.paused=!1,this.decorations=Pr(t.state)}update(t){if(t.docChanged||t.selectionSet||this.paused)if(t.view.composing)this.decorations=this.decorations.map(t.changes),this.paused=!0;else this.decorations=Pr(t.state),this.paused=!1}},{decorations:(t)=>t.decorations}),Ki=[Ji,Ui];function Ju(t={}){return[Yr.of(t),Ki]}var Xi=new Be;function Vt(t,r,s){let l=t.prop(r<0?Be.openedBy:Be.closedBy);if(l)return l;if(t.name.length==1){let f=s.indexOf(t.name);if(f>-1&&f%2==(r<0?1:0))return[s[f+r]]}return null}function zt(t){let r=t.type.prop(Xi);return r?r(t.node):t}function Er(t,r,s,l={}){let f=l.maxScanDistance||Kr,h=l.brackets||Xr,c=zn(t),d=c.resolveInner(r,s);for(let m=d;m;m=m.parent){let p=Vt(m.type,s,h);if(p&&m.from<m.to){let g=zt(m);if(g&&(s>0?r>=g.from&&r<g.to:r>g.from&&r<=g.to))return Yi(t,r,s,m,g,p,h)}}return Qi(t,r,s,c,d.type,f,h)}function Yi(t,r,s,l,f,h,c){let d=l.parent,m={from:f.from,to:f.to},p=0,g=d===null||d===void 0?void 0:d.cursor();if(g&&(s<0?g.childBefore(l.from):g.childAfter(l.to)))do if(s<0?g.to<=l.from:g.from>=l.to){if(p==0&&h.indexOf(g.type.name)>-1&&g.from<g.to){let b=zt(g);return{start:m,end:b?{from:b.from,to:b.to}:void 0,matched:!0}}else if(Vt(g.type,s,c))p++;else if(Vt(g.type,-s,c)){if(p==0){let b=zt(g);return{start:m,end:b&&b.from<b.to?{from:b.from,to:b.to}:void 0,matched:!1}}p--}}while(s<0?g.prevSibling():g.nextSibling());return{start:m,matched:!1}}function Qi(t,r,s,l,f,h,c){if(s<0?!r:r==t.doc.length)return null;let d=s<0?t.sliceDoc(r-1,r):t.sliceDoc(r,r+1),m=c.indexOf(d);if(m<0||m%2==0!=s>0)return null;let p={from:s<0?r-1:r,to:s>0?r+1:r},g=t.doc.iterRange(r,s>0?t.doc.length:0),b=0;for(let k=0;!g.next().done&&k<=h;){let v=g.value;if(s<0)k+=v.length;let w=r+k*s;for(let B=s>0?0:v.length-1,M=s>0?v.length:-1;B!=M;B+=s){let O=c.indexOf(v[B]);if(O<0||l.resolveInner(w+B,1).type!=f)continue;if(O%2==0==s>0)b++;else if(b==1)return{start:p,end:{from:w+B,to:w+B+1},matched:O>>1==m>>1};else b--}if(s>0)k+=v.length}return g.done?{start:p,matched:!1}:null}function Zi(t){return{name:t.name||"",token:t.token,blankLine:t.blankLine||(()=>{}),startState:t.startState||(()=>!0),copyState:t.copyState||es,indent:t.indent||(()=>null),languageData:t.languageData||{},tokenTable:t.tokenTable||jt,mergeTokens:t.mergeTokens!==!1}}function es(t){if(typeof t!="object")return t;let r={};for(let s in t){let l=t[s];r[s]=l instanceof Array?l.slice():l}return r}var Rr=new WeakMap;class RA extends te{constructor(t){let r=wi(t.languageData),s=Zi(t),l,f=new class extends rt{createParse(h,c,d){return new Zr(l,h,c,d)}};super(r,f,[],t.name);this.topNode=is(r,this),l=this,this.streamParser=s,this.stateAfter=new Be({perNode:!0}),this.tokenTable=t.tokenTable?new $t(s.tokenTable):ns}static define(t){return new RA(t)}getIndent(t){let r=void 0,{overrideIndentation:s}=t.options;if(s){if(r=Rr.get(t.state),r!=null&&r<t.pos-1e4)r=void 0}let l=Ut(this,t.node.tree,t.node.from,t.node.from,r!==null&&r!==void 0?r:t.pos),f,h;if(l)h=l.state,f=l.pos+1;else h=this.streamParser.startState(t.unit),f=t.node.from;if(t.pos-f>1e4)return null;while(f<t.pos){let d=t.state.doc.lineAt(f),m=Math.min(t.pos,d.to);if(d.length){let p=s?s(d.from):-1,g=new at(d.text,t.state.tabSize,t.unit,p<0?void 0:p);while(g.pos<m-d.from)en(this.streamParser.token,g,h)}else this.streamParser.blankLine(h,t.unit);if(m==t.pos)break;f=d.to+1}let c=t.lineAt(t.pos);if(s&&r==null)Rr.set(t.state,c.from);return this.streamParser.indent(h,/^\s*(.*)/.exec(c.text)[1],t)}get allowsNesting(){return!1}}function Ut(t,r,s,l,f){let h=s>=l&&s+r.length<=f&&r.prop(t.stateAfter);if(h)return{state:t.streamParser.copyState(h),pos:s+r.length};for(let c=r.children.length-1;c>=0;c--){let d=r.children[c],m=s+r.positions[c],p=d instanceof W&&m<f&&Ut(t,d,m,l,f);if(p)return p}return null}function Qr(t,r,s,l,f){if(f&&s<=0&&l>=r.length)return r;if(!f&&s==0&&r.type==t.topNode)f=!0;for(let h=r.children.length-1;h>=0;h--){let c=r.positions[h],d=r.children[h],m;if(c<l&&d instanceof W){if(!(m=Qr(t,d,s-c,l-c,f)))break;return!f?m:new W(r.type,r.children.slice(0,h).concat(m),r.positions.slice(0,h+1),c+m.length)}}return null}function ts(t,r,s,l,f){for(let h of r){let c=h.from+(h.openStart?25:0),d=h.to-(h.openEnd?25:0),m=c<=s&&d>s&&Ut(t,h.tree,0-h.offset,s,d),p;if(m&&m.pos<=l&&(p=Qr(t,h.tree,s+h.offset,m.pos+h.offset,!1)))return{state:m.state,tree:p}}return{state:t.streamParser.startState(f?ri(f):4),tree:W.empty}}class Zr{constructor(t,r,s,l){this.lang=t,this.input=r,this.fragments=s,this.ranges=l,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=l[l.length-1].to;let f=Ie.get(),h=l[0].from,{state:c,tree:d}=ts(t,s,h,this.to,f===null||f===void 0?void 0:f.state);this.state=c,this.parsedPos=this.chunkStart=h+d.length;for(let m=0;m<d.children.length;m++)this.chunks.push(d.children[m]),this.chunkPos.push(d.positions[m]);if(f&&this.parsedPos<f.viewport.from-1e5&&l.some((m)=>m.from<=f.viewport.from&&m.to>=f.viewport.from))this.state=this.lang.streamParser.startState(ri(f.state)),f.skipUntilInView(this.parsedPos,f.viewport.from),this.parsedPos=f.viewport.from;this.moveRangeIndex()}advance(){let t=Ie.get(),r=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),s=Math.min(r,this.chunkStart+512);if(t)s=Math.min(s,t.viewport.to);while(this.parsedPos<s)this.parseLine(t);if(this.chunkStart<this.parsedPos)this.finishChunk();if(this.parsedPos>=r)return this.finish();if(t&&this.parsedPos>=t.viewport.to)return t.skipUntilInView(this.parsedPos,r),this.finish();return null}stopAt(t){this.stoppedAt=t}lineAfter(t){let r=this.input.chunk(t);if(!this.input.lineChunks){let s=r.indexOf(`
2
2
  `);if(s>-1)r=r.slice(0,s)}else if(r==`
3
3
  `)r="";return t+r.length<=this.to?r:r.slice(0,this.to-t)}nextLine(){let t=this.parsedPos,r=this.lineAfter(t),s=t+r.length;for(let l=this.rangeIndex;;){let f=this.ranges[l].to;if(f>=s)break;if(r=r.slice(0,f-(s-r.length)),l++,l==this.ranges.length)break;let h=this.ranges[l].from,c=this.lineAfter(h);r+=c,s=h+c.length}return{line:r,end:s}}skipGapsTo(t,r,s){for(;;){let l=this.ranges[this.rangeIndex].to,f=t+r;if(s>0?l>f:l>=f)break;let h=this.ranges[++this.rangeIndex].from;r+=h-l}return r}moveRangeIndex(){while(this.ranges[this.rangeIndex].to<this.parsedPos)this.rangeIndex++}emitToken(t,r,s,l){let f=4;if(this.ranges.length>1){l=this.skipGapsTo(r,l,1),r+=l;let c=this.chunk.length;l=this.skipGapsTo(s,l,-1),s+=l,f+=this.chunk.length-c}let h=this.chunk.length-4;if(this.lang.streamParser.mergeTokens&&f==4&&h>=0&&this.chunk[h]==t&&this.chunk[h+2]==r)this.chunk[h+2]=s;else this.chunk.push(t,r,s,f);return l}parseLine(t){let{line:r,end:s}=this.nextLine(),l=0,{streamParser:f}=this.lang,h=new at(r,t?t.state.tabSize:4,t?ri(t.state):2);if(h.eol())f.blankLine(this.state,h.indentUnit);else while(!h.eol()){let c=en(f.token,h,this.state);if(c)l=this.emitToken(this.lang.tokenTable.resolve(c),this.parsedPos+h.start,this.parsedPos+h.pos,l);if(h.start>1e4)break}if(this.parsedPos=s,this.moveRangeIndex(),this.parsedPos<this.to)this.parsedPos++}finishChunk(){let t=W.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:rs,topID:0,maxBufferLength:512,reused:this.chunkReused});t=new W(t.type,t.children,t.positions,t.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(t),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new W(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}function en(t,r,s){r.start=r.pos;for(let l=0;l<10;l++){let f=t(r,s);if(r.pos>r.start)return f}throw Error("Stream parser failed to advance stream.")}var jt=Object.create(null),He=[Y.none],rs=new tt(He),_r=[],Nr=Object.create(null),tn=Object.create(null);for(let[t,r]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"]])tn[t]=rn(jt,r);class $t{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),tn)}resolve(t){return!t?0:this.table[t]||(this.table[t]=rn(this.extra,t))}}var ns=new $t(jt);function Ft(t,r){if(_r.indexOf(t)>-1)return;_r.push(t),console.warn(r)}function rn(t,r){let s=[];for(let d of r.split(" ")){let m=[];for(let p of d.split(".")){let g=t[p]||A[p];if(!g)Ft(p,`Unknown highlighting tag ${p}`);else if(typeof g=="function")if(!m.length)Ft(p,`Modifier ${p} used at start of tag`);else m=m.map(g);else if(m.length)Ft(p,`Tag ${p} used as modifier`);else m=Array.isArray(g)?g:[g]}for(let p of m)s.push(p)}if(!s.length)return 0;let l=r.replace(/ /g,"_"),f=l+" "+s.map((d)=>d.id),h=Nr[f];if(h)return h.id;let c=Nr[f]=Y.define({id:He.length,name:l,props:[Ar({[l]:s})]});return He.push(c),c.id}function is(t,r){let s=Y.define({id:He.length,name:"Document",props:[Te.add(()=>t),zr.add(()=>(l)=>r.getIndent(l))],top:!0});return He.push(s),s}var wo={rtl:D.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:Ge.RTL}),ltr:D.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:Ge.LTR}),auto:D.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};class j{constructor(t,r,s,l){this.fromA=t,this.toA=r,this.fromB=s,this.toB=l}offset(t,r=t){return new j(this.fromA+t,this.toA+t,this.fromB+r,this.toB+r)}}function Se(t,r,s,l,f,h){if(t==l)return[];let c=tr(t,r,s,l,f,h),d=rr(t,r+c,s,l,f+c,h);r+=c,s-=d,f+=c,h-=d;let m=s-r,p=h-f;if(!m||!p)return[new j(r,s,f,h)];if(m>p){let b=t.slice(r,s).indexOf(l.slice(f,h));if(b>-1)return[new j(r,r+b,f,f),new j(r+b+p,s,h,h)]}else if(p>m){let b=l.slice(f,h).indexOf(t.slice(r,s));if(b>-1)return[new j(r,r,f,f+b),new j(s,s,f+b+m,h)]}if(m==1||p==1)return[new j(r,s,f,h)];let g=Dn(t,r,s,l,f,h);if(g){let[b,k,v]=g;return Se(t,r,b,l,f,k).concat(Se(t,b+v,s,l,k+v,h))}return ss(t,r,s,l,f,h)}var Ue=1e9,je=0,Zt=!1;function ss(t,r,s,l,f,h){let c=s-r,d=h-f;if(Ue<1e9&&Math.min(c,d)>Ue*16||je>0&&Date.now()>je){if(Math.min(c,d)>Ue*64)return[new j(r,s,f,h)];return sn(t,r,s,l,f,h)}let m=Math.ceil((c+d)/2);qt.reset(m),Jt.reset(m);let p=(v,w)=>t.charCodeAt(r+v)==l.charCodeAt(f+w),g=(v,w)=>t.charCodeAt(s-v-1)==l.charCodeAt(h-w-1),b=(c-d)%2!=0?Jt:null,k=b?null:qt;for(let v=0;v<m;v++){if(v>Ue||je>0&&!(v&63)&&Date.now()>je)return sn(t,r,s,l,f,h);let w=qt.advance(v,c,d,m,b,!1,p)||Jt.advance(v,c,d,m,k,!0,g);if(w)return os(t,r,s,r+w[0],l,f,h,f+w[1])}return[new j(r,s,f,h)]}class er{constructor(){this.vec=[]}reset(t){this.len=t<<1;for(let r=0;r<this.len;r++)this.vec[r]=-1;this.vec[t+1]=0,this.start=this.end=0}advance(t,r,s,l,f,h,c){for(let d=-t+this.start;d<=t-this.end;d+=2){let m=l+d,p=d==-t||d!=t&&this.vec[m-1]<this.vec[m+1]?this.vec[m+1]:this.vec[m-1]+1,g=p-d;while(p<r&&g<s&&c(p,g))p++,g++;if(this.vec[m]=p,p>r)this.end+=2;else if(g>s)this.start+=2;else if(f){let b=l+(r-s)-d;if(b>=0&&b<this.len&&f.vec[b]!=-1)if(!h){let k=r-f.vec[b];if(p>=k)return[p,g]}else{let k=f.vec[b];if(k>=r-p)return[k,l+k-b]}}}return null}}var qt=new er,Jt=new er;function os(t,r,s,l,f,h,c,d){let m=!1;if(!Re(t,l)&&++l==s)m=!0;if(!Re(f,d)&&++d==c)m=!0;if(m)return[new j(r,s,h,c)];return Se(t,r,l,f,h,d).concat(Se(t,l,s,f,d,c))}function Mn(t,r){let s=1,l=Math.min(t,r);while(s<l)s=s<<1;return s}function tr(t,r,s,l,f,h){if(r==s||r==h||t.charCodeAt(r)!=l.charCodeAt(f))return 0;let c=Mn(s-r,h-f);for(let d=r,m=f;;){let p=d+c,g=m+c;if(p>s||g>h||t.slice(d,p)!=l.slice(m,g)){if(c==1)return d-r-(Re(t,d)?0:1);c=c>>1}else if(p==s||g==h)return p-r;else d=p,m=g}}function rr(t,r,s,l,f,h){if(r==s||f==h||t.charCodeAt(s-1)!=l.charCodeAt(h-1))return 0;let c=Mn(s-r,h-f);for(let d=s,m=h;;){let p=d-c,g=m-c;if(p<r||g<f||t.slice(p,d)!=l.slice(g,m)){if(c==1)return s-d-(Re(t,d)?0:1);c=c>>1}else if(p==r||g==f)return s-p;else d=p,m=g}}function Kt(t,r,s,l,f,h,c,d){let m=l.slice(f,h),p=null;for(;;){if(p||c<d)return p;for(let g=r+c;;){if(!Re(t,g))g++;let b=g+c;if(!Re(t,b))b+=b==g+1?1:-1;if(b>=s)break;let k=t.slice(g,b),v=-1;while((v=m.indexOf(k,v+1))!=-1){let w=tr(t,b,s,l,f+v+k.length,h),B=rr(t,r,g,l,f,f+v),M=k.length+w+B;if(!p||p[2]<M)p=[g-B,f+v-B,M]}g=b}if(d<0)return p;c=c>>1}}function Dn(t,r,s,l,f,h){let c=s-r,d=h-f;if(c<d){let m=Dn(l,f,h,t,r,s);return m&&[m[1],m[0],m[2]]}if(c<4||d*2<c)return null;return Kt(t,r,s,l,f,h,Math.floor(c/4),-1)}function sn(t,r,s,l,f,h){Zt=!0;let c=s-r,d=h-f,m;if(c<d){let k=Kt(l,f,h,t,r,s,Math.floor(c/6),50);m=k&&[k[1],k[0],k[2]]}else m=Kt(t,r,s,l,f,h,Math.floor(d/6),50);if(!m)return[new j(r,s,f,h)];let[p,g,b]=m;return Se(t,r,p,l,f,g).concat(Se(t,p+b,s,l,g+b,h))}function Bn(t,r){for(let s=1;s<t.length;s++){let l=t[s-1],f=t[s];if(l.toA>f.fromA-r&&l.toB>f.fromB-r)t[s-1]=new j(l.fromA,f.toA,l.fromB,f.toB),t.splice(s--,1)}}function ls(t,r,s){for(;;){Bn(s,1);let l=!1;for(let f=0;f<s.length;f++){let h=s[f],c,d;if(c=tr(t,h.fromA,h.toA,r,h.fromB,h.toB))h=s[f]=new j(h.fromA+c,h.toA,h.fromB+c,h.toB);if(d=rr(t,h.fromA,h.toA,r,h.fromB,h.toB))h=s[f]=new j(h.fromA,h.toA-d,h.fromB,h.toB-d);let m=h.toA-h.fromA,p=h.toB-h.fromB;if(m&&p)continue;let g=h.fromA-(f?s[f-1].toA:0),b=(f<s.length-1?s[f+1].fromA:t.length)-h.toA;if(!g||!b)continue;let k=m?t.slice(h.fromA,h.toA):r.slice(h.fromB,h.toB);if(g<=k.length&&t.slice(h.fromA-g,h.fromA)==k.slice(k.length-g))s[f]=new j(h.fromA-g,h.toA-g,h.fromB-g,h.toB-g),l=!0;else if(b<=k.length&&t.slice(h.toA,h.toA+b)==k.slice(0,b))s[f]=new j(h.fromA+b,h.toA+b,h.fromB+b,h.toB+b),l=!0}if(!l)break}return s}function as(t,r,s){for(let l=0,f=0;f<t.length;f++){let h=t[f],c=h.toA-h.fromA,d=h.toB-h.fromB;if(c&&d||c>3||d>3){let m=f==t.length-1?r.length:t[f+1].fromA,p=h.fromA-l,g=m-h.toA,b=ln(r,h.fromA,p),k=on(r,h.toA,g),v=h.fromA-b,w=k-h.toA;if((!c||!d)&&v&&w){let B=Math.max(c,d),[M,O,F]=c?[r,h.fromA,h.toA]:[s,h.fromB,h.toB];if(B>v&&r.slice(b,h.fromA)==M.slice(F-v,F))h=t[f]=new j(b,b+c,h.fromB-v,h.toB-v),b=h.fromA,k=on(r,h.toA,m-h.toA);else if(B>w&&r.slice(h.toA,k)==M.slice(O,O+w))h=t[f]=new j(k-c,k,h.fromB+w,h.toB+w),k=h.toA,b=ln(r,h.fromA,h.fromA-l);v=h.fromA-b,w=k-h.toA}if(v||w)h=t[f]=new j(h.fromA-v,h.toA+w,h.fromB-v,h.toB+w);else if(!c){let B=fn(s,h.fromB,h.toB),M,O=B<0?-1:an(s,h.toB,h.fromB);if(B>-1&&(M=B-h.fromB)<=g&&s.slice(h.fromB,B)==s.slice(h.toB,h.toB+M))h=t[f]=h.offset(M);else if(O>-1&&(M=h.toB-O)<=p&&s.slice(h.fromB-M,h.fromB)==s.slice(O,h.toB))h=t[f]=h.offset(-M)}else if(!d){let B=fn(r,h.fromA,h.toA),M,O=B<0?-1:an(r,h.toA,h.fromA);if(B>-1&&(M=B-h.fromA)<=g&&r.slice(h.fromA,B)==r.slice(h.toA,h.toA+M))h=t[f]=h.offset(M);else if(O>-1&&(M=h.toA-O)<=p&&r.slice(h.fromA-M,h.fromA)==r.slice(O,h.toA))h=t[f]=h.offset(-M)}}l=h.toA}return Bn(t,3),t}var Ae;try{Ae=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch(t){}function En(t){return t>48&&t<58||t>64&&t<91||t>96&&t<123}function Ln(t,r){if(r==t.length)return 0;let s=t.charCodeAt(r);if(s<192)return En(s)?1:0;if(!Ae)return 0;if(!In(s)||r==t.length-1)return Ae.test(String.fromCharCode(s))?1:0;return Ae.test(t.slice(r,r+2))?2:0}function On(t,r){if(!r)return 0;let s=t.charCodeAt(r-1);if(s<192)return En(s)?1:0;if(!Ae)return 0;if(!Pn(s)||r==1)return Ae.test(String.fromCharCode(s))?1:0;return Ae.test(t.slice(r-2,r))?2:0}var Tn=8;function on(t,r,s){if(r==t.length||!On(t,r))return r;for(let l=r,f=r+s,h=0;h<Tn;h++){let c=Ln(t,l);if(!c||l+c>f)return l;l+=c}return r}function ln(t,r,s){if(!r||!Ln(t,r))return r;for(let l=r,f=r-s,h=0;h<Tn;h++){let c=On(t,l);if(!c||l-c<f)return l;l-=c}return r}function an(t,r,s){for(;r!=s;r--)if(t.charCodeAt(r-1)==10)return r;return-1}function fn(t,r,s){for(;r!=s;r++)if(t.charCodeAt(r)==10)return r;return-1}var In=(t)=>t>=55296&&t<=56319,Pn=(t)=>t>=56320&&t<=57343;function Re(t,r){return!r||r==t.length||!In(t.charCodeAt(r-1))||!Pn(t.charCodeAt(r))}function nr(t,r,s){var l;let f=s===null||s===void 0?void 0:s.override;if(f)return f(t,r);return Ue=((l=s===null||s===void 0?void 0:s.scanLimit)!==null&&l!==void 0?l:1e9)>>1,je=(s===null||s===void 0?void 0:s.timeout)?Date.now()+s.timeout:0,Zt=!1,ls(t,r,Se(t,0,t.length,r,0,r.length))}function Rn(){return!Zt}function _n(t,r,s){return as(nr(t,r,s),t,r)}var X=P.define({combine:(t)=>t[0]}),Xt=oe.define(),Fn=P.define(),q=Oe.define({create(t){return null},update(t,r){for(let s of r.effects)if(s.is(Xt))t=s.value;for(let s of r.state.facet(Fn))t=s(t,r);return t}});function kt(t){let r=t.field(q,!1);if(!r)return null;let s=t.facet(X);return{chunks:r,side:s?s.side:null}}var Vn=(t)=>({state:r,dispatch:s})=>{let l=r.field(q,!1),f=r.facet(X);if(!l||!l.length||!f)return!1;let{head:h}=r.selection.main,c=0;for(let g=l.length-1;g>=0;g--){let b=l[g],[k,v]=f.side=="b"?[b.fromB,b.toB]:[b.fromA,b.toA];if(v<h){c=g+1;break}if(k<=h){if(l.length==1)return!1;c=g+(t<0?0:1);break}}let d=l[(c+(t<0?l.length-1:0))%l.length],[m,p]=f.side=="b"?[d.fromB,d.toB]:[d.fromA,d.toA];return s(r.update({selection:{anchor:m},userEvent:"select.byChunk",effects:_.scrollIntoView(x.range(p,m))})),!0},Hn=Vn(1),Wn=Vn(-1);class ae{constructor(t,r,s,l,f,h=!0){this.changes=t,this.fromA=r,this.toA=s,this.fromB=l,this.toB=f,this.precise=h}offset(t,r){return t||r?new ae(this.changes,this.fromA+t,this.toA+t,this.fromB+r,this.toB+r,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(t,r,s){let l=_n(t.toString(),r.toString(),s);return Gn(l,t,r,0,0,Rn())}static updateA(t,r,s,l,f){return mn(dn(t,l,!0,s.length),t,r,s,f)}static updateB(t,r,s,l,f){return mn(dn(t,l,!1,r.length),t,r,s,f)}}function hn(t,r,s,l){let f=s.lineAt(t),h=l.lineAt(r);return f.to==t&&h.to==r&&t<s.length&&r<l.length?[t+1,r+1]:[f.from,h.from]}function cn(t,r,s,l){let f=s.lineAt(t),h=l.lineAt(r);return f.from==t&&h.from==r?[t,r]:[f.to+1,h.to+1]}function Gn(t,r,s,l,f,h){let c=[];for(let d=0;d<t.length;d++){let m=t[d],[p,g]=hn(m.fromA+l,m.fromB+f,r,s),[b,k]=cn(m.toA+l,m.toB+f,r,s),v=[m.offset(-p+l,-g+f)];while(d<t.length-1){let w=t[d+1],[B,M]=hn(w.fromA+l,w.fromB+f,r,s);if(B>b+1&&M>k+1)break;v.push(w.offset(-p+l,-g+f)),[b,k]=cn(w.toA+l,w.toB+f,r,s),d++}c.push(new ae(v,p,Math.max(p,b),g,Math.max(g,k),h))}return c}var dt=1000;function un(t,r,s,l){let f=0,h=t.length;for(;;){if(f==h){let g=0,b=0;if(f)({toA:g,toB:b}=t[f-1]);let k=r-(s?g:b);return[g+k,b+k]}let c=f+h>>1,d=t[c],[m,p]=s?[d.fromA,d.toA]:[d.fromB,d.toB];if(m>r)h=c;else if(p<=r)f=c+1;else return l?[d.fromA,d.fromB]:[d.toA,d.toB]}}function dn(t,r,s,l){let f=[];return r.iterChangedRanges((h,c,d,m)=>{let p=0,g=s?r.length:l,b=0,k=s?l:r.length;if(h>dt)[p,b]=un(t,h-dt,s,!0);if(c<r.length-dt)[g,k]=un(t,c+dt,s,!1);let v=m-d-(c-h),w,[B,M]=s?[v,0]:[0,v];if(f.length&&(w=f[f.length-1]).toA>=p)f[f.length-1]={fromA:w.fromA,fromB:w.fromB,toA:g,toB:k,diffA:w.diffA+B,diffB:w.diffB+M};else f.push({fromA:p,toA:g,fromB:b,toB:k,diffA:B,diffB:M})}),f}function mn(t,r,s,l,f){if(!t.length)return r;let h=[];for(let c=0,d=0,m=0,p=0;;c++){let g=c==t.length?null:t[c],b=g?g.fromA+d:s.length,k=g?g.fromB+m:l.length;while(p<r.length){let M=r[p];if(g&&(M.toA+d>b||M.toB+m>k))break;h.push(M.offset(d,m)),p++}if(!g)break;let v=g.toA+d+g.diffA,w=g.toB+m+g.diffB,B=_n(s.sliceString(b,v),l.sliceString(k,w),f);for(let M of Gn(B,s,l,b,k,Rn()))h.push(M);d+=g.diffA,m+=g.diffB;while(p<r.length){let M=r[p];if(M.fromA+d>v&&M.fromB+m>w)break;p++}}return h}var Un={scanLimit:500},xt=ye.fromClass(class{constructor(t){({deco:this.deco,gutter:this.gutter}=bn(t))}update(t){if(t.docChanged||t.viewportChanged||fs(t.startState,t.state)||hs(t.startState,t.state))({deco:this.deco,gutter:this.gutter}=bn(t.view))}},{decorations:(t)=>t.deco}),mt=Ir.low(Oi({class:"cm-changeGutter",markers:(t)=>{var r;return((r=t.plugin(xt))===null||r===void 0?void 0:r.gutter)||ge.empty}}));function fs(t,r){return t.field(q,!1)!=r.field(q,!1)}function hs(t,r){return t.facet(X)!=r.facet(X)}var pn=D.line({class:"cm-changedLine"}),jn=D.mark({class:"cm-changedText"}),cs=D.mark({tagName:"ins",class:"cm-insertedLine"}),us=D.mark({tagName:"del",class:"cm-deletedLine"}),gn=new class extends Qn{constructor(){super(...arguments);this.elementClass="cm-changedLineGutter"}};function ds(t,r,s,l,f,h){let c=s?t.fromA:t.fromB,d=s?t.toA:t.toB,m=0;if(c!=d){if(f.add(c,c,pn),f.add(c,d,s?us:cs),h)h.add(c,c,gn);for(let p=r.iterRange(c,d-1),g=c;!p.next().done;){if(p.lineBreak){if(g++,f.add(g,g,pn),h)h.add(g,g,gn);continue}let b=g+p.value.length;if(l)while(m<t.changes.length){let k=t.changes[m],v=c+(s?k.fromA:k.fromB),w=c+(s?k.toA:k.toB),B=Math.max(g,v),M=Math.min(b,w);if(B<M)f.add(B,M,jn);if(w<b)m++;else break}g=b}}}function bn(t){let r=t.state.field(q),{side:s,highlightChanges:l,markGutter:f,overrideChunk:h}=t.state.facet(X),c=s=="a",d=new lt,m=f?new lt:null,{from:p,to:g}=t.viewport;for(let b of r){if((c?b.fromA:b.fromB)>=g)break;if((c?b.toA:b.toB)>p){if(!h||!h(t.state,b,d,m))ds(b,t.state.doc,c,l,d,m)}}return{deco:d.finish(),gutter:m&&m.finish()}}class $e extends Mt{constructor(t){super();this.height=t}eq(t){return this.height==t.height}toDOM(){let t=document.createElement("div");return t.className="cm-mergeSpacer",t.style.height=this.height+"px",t}updateDOM(t){return t.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}var bt=oe.define({map:(t,r)=>t.map(r)}),qe=Oe.define({create:()=>D.none,update:(t,r)=>{for(let s of r.effects)if(s.is(bt))return s.value;return t.map(r.changes)},provide:(t)=>_.decorations.from(t)}),pt=0.01;function kn(t,r){if(t.size!=r.size)return!1;let s=t.iter(),l=r.iter();while(s.value){if(s.from!=l.from||Math.abs(s.value.spec.widget.height-l.value.spec.widget.height)>1)return!1;s.next(),l.next()}return!0}function ms(t,r,s){let l=new lt,f=new lt,h=t.state.field(qe).iter(),c=r.state.field(qe).iter(),d=0,m=0,p=0,g=0,b=t.viewport,k=r.viewport;for(let M=0;;M++){let O=M<s.length?s[M]:null,F=O?O.fromA:t.state.doc.length,N=O?O.fromB:r.state.doc.length;if(d<F){let L=t.lineBlockAt(d).top+p,S=r.lineBlockAt(m).top+g,E=L-S;if(E<-pt)p-=E,l.add(d,d,D.widget({widget:new $e(-E),block:!0,side:-1}));else if(E>pt)g+=E,f.add(m,m,D.widget({widget:new $e(E),block:!0,side:-1}))}if(F>d+1000&&d<b.from&&F>b.from&&m<k.from&&N>k.from){let L=Math.max(b.from-d,k.from-m);d+=L,m+=L,M--}else if(!O)break;else d=O.toA,m=O.toB;while(h.value&&h.from<d)p-=h.value.spec.widget.height,h.next();while(c.value&&c.from<m)g-=c.value.spec.widget.height,c.next()}while(h.value)p-=h.value.spec.widget.height,h.next();while(c.value)g-=c.value.spec.widget.height,c.next();let v=t.contentHeight+p-(r.contentHeight+g);if(v<pt)l.add(t.state.doc.length,t.state.doc.length,D.widget({widget:new $e(-v),block:!0,side:1}));else if(v>pt)f.add(r.state.doc.length,r.state.doc.length,D.widget({widget:new $e(v),block:!0,side:1}));let w=l.finish(),B=f.finish();if(!kn(w,t.state.field(qe)))t.dispatch({effects:bt.of(w)});if(!kn(B,r.state.field(qe)))r.dispatch({effects:bt.of(B)})}var Yt=oe.define({map:(t,r)=>r.mapPos(t)});class $n extends Mt{constructor(t){super();this.lines=t}eq(t){return this.lines==t.lines}toDOM(t){let r=document.createElement("div");return r.className="cm-collapsedLines",r.textContent=t.state.phrase("$ unchanged lines",this.lines),r.addEventListener("click",(s)=>{let l=t.posAtDOM(s.target);t.dispatch({effects:Yt.of(l)});let{side:f,sibling:h}=t.state.facet(X);if(h)h().dispatch({effects:Yt.of(gs(l,t.state.field(q),f=="a"))})}),r}ignoreEvent(t){return t instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return"collapsed-unchanged-code"}}function gs(t,r,s){let l=0,f=0;for(let h=0;;h++){let c=h<r.length?r[h]:null;if(!c||(s?c.fromA:c.fromB)>=t)return f+(t-l);[l,f]=s?[c.toA,c.toB]:[c.toB,c.toA]}}var bs=Oe.define({create(t){return D.none},update(t,r){t=t.map(r.changes);for(let s of r.effects)if(s.is(Yt))t=t.update({filter:(l)=>l!=s.value});if(t.size&&r.state.field(q)!=r.startState.field(q,!1)){let s=r.state.facet(X).side=="a",l=[];for(let f of r.state.field(q))t.between(s?f.fromA:f.fromB,s?f.toA:f.toB,(h)=>{l.push(h)});if(l.length)t=t.update({filter:(f)=>l.indexOf(f)<0})}return t},provide:(t)=>_.decorations.from(t)});function Qt({margin:t=3,minSize:r=4}){return bs.init((s)=>ks(s,t,r))}function ks(t,r,s){let l=new lt,f=t.facet(X).side=="a",h=t.field(q),c=1;for(let d=0;;d++){let m=d<h.length?h[d]:null,p=d?c+r:1,g=m?t.doc.lineAt(f?m.fromA:m.fromB).number-1-r:t.doc.lines,b=g-p+1;if(b>=s)l.add(t.doc.line(p).from,t.doc.line(g).to,D.replace({widget:new $n(b),block:!0}));if(!m)break;c=t.doc.lineAt(Math.min(t.doc.length,f?m.toA:m.toB)).number}return l.finish()}var xs=_.styleModule.of(new Hr({".cm-mergeView":{overflowY:"auto"},".cm-mergeViewEditors":{display:"flex",alignItems:"stretch"},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:"hidden"},".cm-merge-revert":{width:"1.6em",flexGrow:0,flexShrink:0,position:"relative"},".cm-merge-revert button":{position:"absolute",display:"block",width:"100%",boxSizing:"border-box",textAlign:"center",background:"none",border:"none",font:"inherit",cursor:"pointer"}})),qn=_.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:"auto !important",overflowY:"visible !important"},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:"rgba(160, 128, 100, .08)"},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:"rgba(100, 160, 128, .08)"},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat"},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat"},"&light.cm-merge-b .cm-changedText":{background:"linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat"},"&.cm-merge-b .cm-deletedText":{background:"#ff000033"},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:"none"},".cm-deletedChunk":{paddingLeft:"6px","& .cm-chunkButtons":{position:"absolute",insetInlineEnd:"5px"},"& button":{border:"none",cursor:"pointer",color:"white",margin:"0 2px",borderRadius:"3px","&[name=accept]":{background:"#2a2"},"&[name=reject]":{background:"#d43"}}},".cm-collapsedLines":{padding:"5px 5px 5px 10px",cursor:"pointer","&:before":{content:'"⦚"',marginInlineEnd:"7px"},"&:after":{content:'"⦚"',marginInlineStart:"7px"}},"&light .cm-collapsedLines":{color:"#444",background:"linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)"},"&dark .cm-collapsedLines":{color:"#ddd",background:"linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)"},".cm-changeGutter":{width:"3px",paddingLeft:"1px"},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:"#e43"},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:"#fa9"},"&light.cm-merge-b .cm-changedLineGutter":{background:"#2b2"},"&dark.cm-merge-b .cm-changedLineGutter":{background:"#8f8"},".cm-inlineChangedLineGutter":{background:"#75d"}}),xn=new An,gt=new An;class ir{constructor(t){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=t.diffConfig||Un;let r=[Ir.low(xt),qn,xs,qe,_.updateListener.of((g)=>{if(this.measuring<0&&(g.heightChanged||g.viewportChanged)&&!g.transactions.some((b)=>b.effects.some((k)=>k.is(bt))))this.measure()})],s=[X.of({side:"a",sibling:()=>this.b,highlightChanges:t.highlightChanges!==!1,markGutter:t.gutter!==!1})];if(t.gutter!==!1)s.push(mt);let l=me.create({doc:t.a.doc,selection:t.a.selection,extensions:[t.a.extensions||[],_.editorAttributes.of({class:"cm-merge-a"}),gt.of(s),r]}),f=[X.of({side:"b",sibling:()=>this.a,highlightChanges:t.highlightChanges!==!1,markGutter:t.gutter!==!1})];if(t.gutter!==!1)f.push(mt);let h=me.create({doc:t.b.doc,selection:t.b.selection,extensions:[t.b.extensions||[],_.editorAttributes.of({class:"cm-merge-b"}),gt.of(f),r]});this.chunks=ae.build(l.doc,h.doc,this.diffConf);let c=[q.init(()=>this.chunks),xn.of(t.collapseUnchanged?Qt(t.collapseUnchanged):[])];l=l.update({effects:oe.appendConfig.of(c)}).state,h=h.update({effects:oe.appendConfig.of(c)}).state,this.dom=document.createElement("div"),this.dom.className="cm-mergeView",this.editorDOM=this.dom.appendChild(document.createElement("div")),this.editorDOM.className="cm-mergeViewEditors";let d=t.orientation||"a-b",m=document.createElement("div");m.className="cm-mergeViewEditor";let p=document.createElement("div");if(p.className="cm-mergeViewEditor",this.editorDOM.appendChild(d=="a-b"?m:p),this.editorDOM.appendChild(d=="a-b"?p:m),this.a=new _({state:l,parent:m,root:t.root,dispatchTransactions:(g)=>this.dispatch(g,this.a)}),this.b=new _({state:h,parent:p,root:t.root,dispatchTransactions:(g)=>this.dispatch(g,this.b)}),this.setupRevertControls(!!t.revertControls,t.revertControls=="b-to-a",t.renderRevertControl),t.parent)t.parent.appendChild(this.dom);this.scheduleMeasure()}dispatch(t,r){if(t.some((s)=>s.docChanged)){let s=t[t.length-1],l=t.reduce((h,c)=>h.compose(c.changes),Ct.empty(t[0].startState.doc.length));this.chunks=r==this.a?ae.updateA(this.chunks,s.newDoc,this.b.state.doc,l,this.diffConf):ae.updateB(this.chunks,this.a.state.doc,s.newDoc,l,this.diffConf),r.update([...t,s.state.update({effects:Xt.of(this.chunks)})]);let f=r==this.a?this.b:this.a;f.update([f.state.update({effects:Xt.of(this.chunks)})]),this.scheduleMeasure()}else r.update(t)}reconfigure(t){if("diffConfig"in t)this.diffConf=t.diffConfig;if("orientation"in t){let f=t.orientation!="b-a";if(f!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let h=this.a.dom.parentNode,c=this.b.dom.parentNode;if(h.remove(),c.remove(),this.editorDOM.insertBefore(f?h:c,this.editorDOM.firstChild),this.editorDOM.appendChild(f?c:h),this.revertToLeft=!this.revertToLeft,this.revertDOM)this.revertDOM.textContent=""}}if("revertControls"in t||"renderRevertControl"in t){let f=!!this.revertDOM,h=this.revertToA,c=this.renderRevert;if("revertControls"in t)f=!!t.revertControls,h=t.revertControls=="b-to-a";if("renderRevertControl"in t)c=t.renderRevertControl;this.setupRevertControls(f,h,c)}let r="highlightChanges"in t,s="gutter"in t,l="collapseUnchanged"in t;if(r||s||l){let f=[],h=[];if(r||s){let c=this.a.state.facet(X),d=s?t.gutter!==!1:c.markGutter,m=r?t.highlightChanges!==!1:c.highlightChanges;f.push(gt.reconfigure([X.of({side:"a",sibling:()=>this.b,highlightChanges:m,markGutter:d}),d?mt:[]])),h.push(gt.reconfigure([X.of({side:"b",sibling:()=>this.a,highlightChanges:m,markGutter:d}),d?mt:[]]))}if(l){let c=xn.reconfigure(t.collapseUnchanged?Qt(t.collapseUnchanged):[]);f.push(c),h.push(c)}this.a.dispatch({effects:f}),this.b.dispatch({effects:h})}this.scheduleMeasure()}setupRevertControls(t,r,s){if(this.revertToA=r,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=s,!t&&this.revertDOM)this.revertDOM.remove(),this.revertDOM=null;else if(t&&!this.revertDOM)this.revertDOM=this.editorDOM.insertBefore(document.createElement("div"),this.editorDOM.firstChild.nextSibling),this.revertDOM.addEventListener("mousedown",(l)=>this.revertClicked(l)),this.revertDOM.className="cm-merge-revert";else if(this.revertDOM)this.revertDOM.textContent=""}scheduleMeasure(){if(this.measuring<0){let t=this.dom.ownerDocument.defaultView||window;this.measuring=t.requestAnimationFrame(()=>{this.measuring=-1,this.measure()})}}measure(){if(ms(this.a,this.b,this.chunks),this.revertDOM)this.updateRevertButtons()}updateRevertButtons(){let t=this.revertDOM,r=t.firstChild,s=this.a.viewport,l=this.b.viewport;for(let f=0;f<this.chunks.length;f++){let h=this.chunks[f];if(h.fromA>s.to||h.fromB>l.to)break;if(h.fromA<s.from||h.fromB<l.from)continue;let c=this.a.lineBlockAt(h.fromA).top+"px";while(r&&+r.dataset.chunk<f)r=vn(r);if(r&&r.dataset.chunk==String(f)){if(r.style.top!=c)r.style.top=c;r=r.nextSibling}else t.insertBefore(this.renderRevertButton(c,f),r)}while(r)r=vn(r)}renderRevertButton(t,r){let s;if(this.renderRevert)s=this.renderRevert();else{s=document.createElement("button");let l=this.a.state.phrase("Revert this chunk");s.setAttribute("aria-label",l),s.setAttribute("title",l),s.textContent=this.revertToLeft?"⇜":"⇝"}return s.style.top=t,s.setAttribute("data-chunk",String(r)),s}revertClicked(t){let r=t.target,s;while(r&&r.parentNode!=this.revertDOM)r=r.parentNode;if(r&&(s=this.chunks[r.dataset.chunk])){let[l,f,h,c,d,m]=this.revertToA?[this.b,this.a,s.fromB,s.toB,s.fromA,s.toA]:[this.a,this.b,s.fromA,s.toA,s.fromB,s.toB],p=l.state.sliceDoc(h,Math.max(h,c-1));if(h!=c&&m<=f.state.doc.length)p+=l.state.lineBreak;f.dispatch({changes:{from:d,to:Math.min(f.state.doc.length,m),insert:p},userEvent:"revert"}),t.preventDefault()}}destroy(){if(this.a.destroy(),this.b.destroy(),this.measuring>-1)(this.dom.ownerDocument.defaultView||window).cancelAnimationFrame(this.measuring);this.dom.remove()}}function vn(t){let r=t.nextSibling;return t.remove(),r}var vs=new class extends Qn{constructor(){super(...arguments);this.elementClass="cm-deletedLineGutter"}},ws=Ir.low(Oi({class:"cm-changeGutter",markers:(t)=>{var r;return((r=t.plugin(xt))===null||r===void 0?void 0:r.gutter)||ge.empty},widgetMarker:(t,r)=>r instanceof or?vs:null}));function Jn(t){var r;let s=typeof t.original=="string"?ke.of(t.original.split(/\r?\n/)):t.original,l=t.diffConfig||Un;return[Ir.low(xt),Ms,qn,_.editorAttributes.of({class:"cm-merge-b"}),Fn.of((f,h)=>{let c=h.effects.find((d)=>d.is(sr));if(c)f=ae.updateA(f,c.value.doc,h.startState.doc,c.value.changes,l);if(h.docChanged)f=ae.updateB(f,h.state.field(Me),h.newDoc,h.changes,l);return f}),X.of({highlightChanges:t.highlightChanges!==!1,markGutter:t.gutter!==!1,syntaxHighlightDeletions:t.syntaxHighlightDeletions!==!1,syntaxHighlightDeletionsMaxLength:3000,mergeControls:(r=t.mergeControls)!==null&&r!==void 0?r:!0,overrideChunk:t.allowInlineDiffs?Es:void 0,side:"b"}),Me.init(()=>s),t.gutter!==!1?ws:[],t.collapseUnchanged?Qt(t.collapseUnchanged):[],q.init((f)=>ae.build(s,f.doc,l))]}var sr=oe.define();var Me=Oe.define({create:()=>ke.empty,update(t,r){for(let s of r.effects)if(s.is(sr))t=s.value.doc;return t}});function Kn(t){return t.field(Me)}var yn=new WeakMap;class or extends Mt{constructor(t){super();this.buildDOM=t,this.dom=null}eq(t){return this.dom==t.dom}toDOM(t){return this.dom||(this.dom=this.buildDOM(t))}}function Cs(t,r,s){let l=yn.get(r.changes);if(l)return l;let f=(c)=>{let{highlightChanges:d,syntaxHighlightDeletions:m,syntaxHighlightDeletionsMaxLength:p,mergeControls:g}=t.facet(X),b=document.createElement("div");if(b.className="cm-deletedChunk",g){let L=b.appendChild(document.createElement("div"));L.className="cm-chunkButtons";let S=(y)=>{y.preventDefault(),As(c,c.posAtDOM(b))},E=(y)=>{y.preventDefault(),Ss(c,c.posAtDOM(b))};if(typeof g=="function")L.appendChild(g("accept",S)),L.appendChild(g("reject",E));else{let y=L.appendChild(document.createElement("button"));y.name="accept",y.textContent=t.phrase("Accept"),y.onmousedown=S;let I=L.appendChild(document.createElement("button"));I.name="reject",I.textContent=t.phrase("Reject"),I.onmousedown=E}}if(s||r.fromA>=r.toA)return b;let k=c.state.field(Me).sliceString(r.fromA,r.endA),v=m&&t.facet(Ao),w=F(),B=r.changes,M=0,O=!1;function F(){let L=b.appendChild(document.createElement("div"));return L.className="cm-deletedLine",L.appendChild(document.createElement("del"))}function N(L,S,E){for(let y=L;y<S;){if(k.charAt(y)==`
4
4
  `){if(!w.firstChild)w.appendChild(document.createElement("br"));w=F(),y++;continue}let I=S,V=E+(O?" cm-deletedText":""),H=!1,R=k.indexOf(`
@@ -1 +1 @@
1
- import{n,o,K,i,a,ze,Me,Se,ie,e,s,p,I,E,Xe,bi,ir,h,sr,He,we,T,tt,wi,he,X,mt,Oo,Uo,N0,H0,Of,Jo,Ni,eg,hA}from"./index-8w69r0c4.js";import"./index-hav1hhbr.js";import{Li}from"./index-g46qcgp8.js";import"./index-4kchzh9y.js";import{wA,xu,Fs,wu,Cu,Eu,Bu,Iu,_u,Su,Tu,Du}from"./index-gm9cqsqg.js";var vt={name:"panel-right-close",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]]},be=s(vt);var z=new Set,ae=new Set,ge=new Set;function ve(){ge=new Set(z);for(let t of[...ae])t()}function xe(t){let r=new Set(t);if(r.size===z.size){let l=!0;for(let d of r)if(!z.has(d)){l=!1;break}if(l)return}z.clear();for(let l of r)z.add(l);ve()}function ye(t){let r=new Set(t),l=!1;for(let d of[...z])if(!r.has(d))z.delete(d),l=!0;if(l)ve()}function Ce(t){return z.has(t)}function ke(){return z.size>0}function ht(t){return ae.add(t),()=>{ae.delete(t)}}var xt=ht;function Ee(){return ze(xt,()=>ge)}function Te({x:t,y:r,rows:l,onAction:d,onClose:u}){let x=i(null),[m,c]=n({left:t,top:r});return K(()=>{let b=x.current;if(!b)return;let{width:k,height:g}=b.getBoundingClientRect();c({left:Math.min(t,Math.max(0,window.innerWidth-k-8)),top:Math.min(r,Math.max(0,window.innerHeight-g-8))})},[t,r,l.length]),ie(e("div",{className:"fixed inset-0 z-[70]",onClick:u,onContextMenu:(b)=>{b.preventDefault(),u()},children:e("div",{ref:x,role:"menu","aria-label":"Tab actions",className:"glass-popover absolute w-52 bg-paper border border-ink/15 rounded-md shadow-xl py-1 text-xs text-ink",style:{left:`${m.left}px`,top:`${m.top}px`},onClick:(b)=>b.stopPropagation(),children:l.map((b)=>e("button",{type:"button",role:"menuitem",onClick:()=>{d(b.action),u()},className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 transition-colors cursor-pointer",children:b.label},b.action))})}),document.body)}var ee={rightFileId:null,fraction:0.5};function ne(t,r,l){if(t===null)return!1;if(t===r)return!1;return l.includes(t)}function Ne(t,r){for(let l=r.length-1;l>=0;l-=1){let d=r[l];if(d!==t)return d}return null}function Pe(t,r){if(t.rightFileId===null)return t;if(t.rightFileId!==r)return t;return{...t,rightFileId:null}}function Y(t){if(!Number.isFinite(t))return ee.fraction;return Math.max(0.2,Math.min(0.8,t))}function De(t,r){if(typeof t!=="object"||t===null)return ee;let l=t,d=typeof l.fraction==="number"?Y(l.fraction):ee.fraction,u=typeof l.rightFileId==="string"||typeof l.rightFileId==="number"?l.rightFileId:null;if(u===null||!r.includes(u))return{rightFileId:null,fraction:d};return{rightFileId:u,fraction:d}}function Re({tab:t,openedFiles:r,dirtyIds:l,reopenable:d,activeFileId:u,splitRightFileId:x}){let m=r.filter((g)=>g.id!==t.id),c=r.filter((g)=>!l.has(g.id)),b=r.map((g)=>g.id);return[{action:"split-right",label:"Split right",enabled:ne(t.id,u,b)},{action:"unsplit",label:"Unsplit",enabled:x!==null},{action:"close",label:"Close",enabled:!0},{action:"close-others",label:"Close others",enabled:m.length>0},{action:"close-all",label:"Close all",enabled:r.length>0},{action:"close-saved",label:"Close saved",enabled:c.some((g)=>g.id!==t.id)},{action:"copy-path",label:"Copy path",enabled:Boolean(t.path)},{action:"reveal-in-files",label:"Reveal in Files",enabled:Boolean(t.path)&&!t.isDiff},{action:"reopen-closed",label:"Reopen closed tab",enabled:d>0}].filter((g)=>g.enabled)}function Z({onHide:t}){let r=Jo("toggleEditorPanel","Hide Editor Panel");return e("button",{type:"button",onClick:t,className:"p-1.5 mx-1 rounded transition-colors cursor-pointer text-ink/60 hover:bg-ink/10 hover:text-ink flex-shrink-0",title:r,"aria-label":r,children:e(be,{size:14})})}function Ie({openedFiles:t,activeFileId:r,onSelectFile:l,onCloseFile:d,missingIds:u,onCopyPath:x,onRevealInFiles:m,onReopenClosed:c,reopenableCount:b,onSplitTo:k,onUnsplit:g,splitRightFileId:y=null,onHide:R}){let M=Ee(),P=i(null),L=i(null),[D,O]=n(5),[A,F]=n(!1),[f,Q]=n(null);he(L,()=>F(!1)),o(()=>{let v=new ResizeObserver((w)=>{for(let S of w){let q=S.contentRect.width,H=Math.max(1,Math.floor((q-60)/150));O(H)}});if(P.current)v.observe(P.current);return()=>v.disconnect()},[]);let U=Ne(r,t.map((v)=>v.id)),j=[],G=[];if(t.length<=D)j=t;else{let v=t.findIndex((S)=>S.id===r),w=new Set;if(v!==-1&&r!==null)w.add(r);for(let S=t.length-1;S>=0;S--){if(w.size>=D)break;w.add(t[S].id)}j=t.filter((S)=>w.has(S.id)),G=t.filter((S)=>!w.has(S.id))}return e("div",{className:`${wi.desktop} flex bg-ink/10 w-full relative border-b border-ink/10`,ref:P,children:[e("div",{className:"flex overflow-hidden",children:j.map((v)=>{let w=v.id===r,S=Boolean(v.isDiff),q=S?sr(v.diffStatus||"M",v.diffStaged):null,H=Boolean(u?.has(v.id));return e("div",{onClick:()=>l(v.id),onContextMenu:(_)=>{_.preventDefault(),Q({tab:v,x:_.clientX,y:_.clientY})},className:`flex items-center space-x-1.5 px-3 py-1.5 cursor-pointer border-r border-ink/10 min-w-[120px] max-w-[210px] group ${w?"bg-paper border-t-2 border-t-ink text-ink":"bg-transparent border-t-2 border-t-transparent text-ink/60 hover:bg-paper/50"}`,title:H?`${v.path} — file no longer exists`:v.path,children:[S?e(bi,{size:14,className:w?"text-info flex-shrink-0":"text-info/70 flex-shrink-0"}):e(mt,{name:v.name,size:14,className:`flex-shrink-0${w||H?"":" opacity-60"}${H?" text-error":""}`}),e("span",{className:`text-xs font-mono truncate flex-1${H?" text-error line-through":""}`,children:v.name}),q&&e("span",{className:`px-1 text-[10px] font-mono font-bold rounded ${q.badgeBgClass}`,children:q.charStatus}),e(Oe,{dirty:M.has(v.id),active:w,label:`Close ${v.name}`,onClose:()=>d(v.id)})]},v.id)})}),f?e(Te,{x:f.x,y:f.y,rows:Re({tab:f.tab,openedFiles:t,dirtyIds:M,reopenable:b?.()??0,activeFileId:r,splitRightFileId:y}),onAction:(v)=>{let w=f.tab;switch(v){case"close":d(w.id);return;case"close-others":for(let S of[...t].reverse())if(S.id!==w.id)d(S.id);l(w.id);return;case"close-all":for(let S of[...t].reverse())d(S.id);return;case"close-saved":for(let S of[...t].reverse())if(!M.has(S.id))d(S.id);return;case"copy-path":x?.(w);return;case"reveal-in-files":m?.(w);return;case"reopen-closed":c?.();return;case"split-right":k?.(w.id);return;case"unsplit":g?.();return}},onClose:()=>Q(null)}):null,e("div",{className:"ml-auto flex items-center",children:[e("button",{type:"button",onClick:()=>y!==null?g?.():k?.(U),disabled:y===null&&U===null,"aria-pressed":y!==null,"aria-label":"Split editor",title:y!==null?"Close the split pane (the tab stays open)":U===null?"Open another file to split the editor":"Split the editor and show the newest other file",className:`p-1.5 mx-1 rounded transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-default ${y!==null?"bg-ink/10 text-ink":"text-ink/60 hover:bg-ink/10"}`,children:e(ir,{size:14})}),R&&e(Z,{onHide:R})]}),G.length>0&&e("div",{className:"relative flex items-center bg-ink/10",ref:L,children:[e("button",{className:`p-1.5 mx-1 rounded hover:bg-ink/10 text-ink/60 ${A?"bg-ink/10 text-ink":""}`,onClick:()=>F(!A),title:"More open files",children:e(E,{size:14})}),A&&e("div",{className:"glass-popover absolute right-0 top-full mt-1 w-52 bg-paper border border-ink/10 rounded shadow-lg z-50 py-1",children:[e("div",{className:"px-3 py-1 text-[10px] uppercase font-mono text-ink/40 border-b border-ink/10 mb-1",children:"Older Tabs"}),G.map((v)=>{let w=Boolean(u?.has(v.id));return e("div",{onClick:()=>{l(v.id),F(!1)},className:"flex items-center space-x-2 px-3 py-1.5 hover:bg-ink/5 cursor-pointer group",children:[v.isDiff?e(bi,{size:14,className:"text-info/80"}):e(mt,{name:v.name,size:14,className:w?"text-error":"opacity-60"}),e("span",{className:`text-xs font-mono truncate flex-1 ${w?"text-error line-through":"text-ink/80"}`,children:v.name}),e(Oe,{dirty:M.has(v.id),active:!1,label:`Close ${v.name}`,onClose:()=>{if(d(v.id),G.length===1)F(!1)}})]},v.id)})]})]})]})}function Oe({dirty:t,active:r,label:l,onClose:d}){return e("div",{role:"button",tabIndex:-1,"aria-label":l,title:t?`${l} — unsaved changes`:l,className:`p-0.5 rounded hover:bg-ink/10 touch-visible ${r||t?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:(u)=>{u.stopPropagation(),d()},children:t?e("span",{className:"block w-2 h-2 rounded-full bg-current mx-0.5","data-tab-dirty":"","aria-hidden":"true"}):e(h,{size:12})})}function Ae({pluginId:t,Component:r,sessionId:l,className:d="",onHide:u}){return e("div",{className:`flex flex-col h-full bg-canvas ${d}`,children:[u&&e("div",{className:"flex justify-end flex-shrink-0 border-b border-ink/10",children:e(Z,{onHide:u})}),e(tt,{pluginId:t,children:e(r,{sessionId:l,workspacePath:null})})]})}function Fe({className:t="",onHide:r}){return e("div",{className:`relative flex flex-col h-full bg-canvas items-center justify-center text-muted ${t}`,children:[r&&e("div",{className:"absolute top-0 right-0 flex items-center",children:e(Z,{onHide:r})}),e(mt,{name:"placeholder.txt",size:48,className:"mb-4 opacity-20"}),e("p",{className:"font-mono text-sm",children:"Select a file to open"})]})}function Le({searchReveal:t,revealMatch:r}){let l=i(r);l.current=r;let d=i(null);o(()=>{if(!t||d.current===t.request)return;d.current=t.request,l.current({query:t.request.query,options:t.request.options,line:t.request.line})},[t])}function Be({openedFiles:t,dirtyKeys:r,activeFile:l,previewReady:d,setPreviewMode:u,sessionId:x}){o(()=>{let m=new Set(t.filter((c)=>!c.isDiff&&c.content===void 0).map((c)=>c.id));xe([...r].filter((c)=>m.has(c)))},[r,t]),o(()=>{if(!d)return;let m=l?.id;if(!l||m===void 0||m===null)return;if(!xu(Fs(l.name)))return;let c=we(x,"editor.previewMode");if(c&&c[m]!==void 0)return;u((b)=>b[m]===void 0?{...b,[m]:!0}:b)},[d,l])}function Ke({activeFile:t,externalChange:r,conflict:l,onReload:d,onKeepMine:u}){if(!t)return null;if(l)return e(Su,{diskMtimeMs:l.diskMtimeMs,fileName:t.name,onReload:d,onKeepMine:u});if(r)return e(_u,{fileName:t.name,onReload:d,onKeepMine:u});return null}async function $e(t){let r=t.name.trim();if(!r)return{status:"failed",reason:"Enter a file name."};let l=new FormData;if(l.append("actionType","saveAs"),l.append("path",t.parent),l.append("name",r),l.append("content",t.content),l.append("eol",t.eol),t.root)l.append("root",t.root);if(t.repo&&t.repo!==".")l.append("repo",t.repo);try{let d=await fetch("/api/fs/action",{method:"POST",body:l}),u=await d.json().catch(()=>null),x=typeof u?.error==="string"?u.error:null;if(d.status===409)return{status:"exists",reason:x??`${r} already exists.`};if(d.ok&&u?.success&&typeof u.path==="string")return{status:"written",path:u.path};return{status:"failed",reason:x??"The file could not be written."}}catch{return{status:"failed",reason:"The file could not be written."}}}function Ue(t){let r=t.lastIndexOf(".");if(r<=0)return`${t} copy`;return`${t.slice(0,r)} copy${t.slice(r)}`}function Ge(t){let r=t.trim();if(!r)return!1;if(r==="."||r==="..")return!1;return!r.includes("/")&&!r.includes("\\")}function yt(t){let r=t.lastIndexOf("/");return r===-1?"":t.slice(0,r)}function qe({fileName:t,filePath:r,content:l,eol:d,root:u,repo:x,onSaved:m,onClose:c}){let[b,k]=n(()=>yt(r)),[g,y]=n(()=>Ue(t)),[R,M]=n(!1),[P,L]=n(null),D=i(null);o(()=>{D.current?.focus(),D.current?.select()},[]);let O=Ge(g),A=async()=>{if(!O||R)return;M(!0),L(null);let f=await $e({parent:b,name:g,content:l,eol:d,root:u,repo:x});if(M(!1),f.status==="written"){m({path:f.path});return}L(f.reason)},F=(f)=>{if(f.key==="Enter"){f.preventDefault(),A();return}if(f.key==="Escape")f.preventDefault(),c()};return e(X,{onClose:c,maxWidthClass:"max-w-md",header:e("span",{className:"text-sm font-semibold text-ink",children:"Save as"}),footer:e("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-ink/10",children:[e("button",{type:"button",onClick:c,className:"px-3 py-1.5 rounded border border-ink/20 text-ink/80 hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),e("button",{type:"button",onClick:()=>void A(),disabled:!O||R,className:"flex items-center gap-1.5 px-3 py-1.5 rounded bg-ink text-paper disabled:opacity-40 disabled:cursor-default cursor-pointer",children:[R?e(p,{size:12,className:"animate-spin"}):e(Xe,{size:12}),"Save"]})]}),children:e("div",{className:"px-4 py-3 space-y-2 text-xs",children:[e("label",{className:"block",children:[e("span",{className:"block text-[10px] uppercase tracking-wide text-ink/50 mb-1",children:"Folder"}),e("input",{value:b,onInput:(f)=>k(f.target.value),onKeyDown:F,placeholder:"(workspace root)","aria-label":"Destination folder",className:"w-full bg-paper border border-ink/20 rounded px-2 py-1 font-mono text-ink outline-none focus:border-ink/40"})]}),e("label",{className:"block",children:[e("span",{className:"block text-[10px] uppercase tracking-wide text-ink/50 mb-1",children:"Name"}),e("input",{ref:D,value:g,onInput:(f)=>y(f.target.value),onKeyDown:F,"aria-label":"File name","aria-invalid":!O,className:`w-full bg-paper border rounded px-2 py-1 font-mono text-ink outline-none ${O?"border-ink/20 focus:border-ink/40":"border-error text-error"}`})]}),!O?e("div",{className:"text-[10px] text-error font-mono",children:"Enter a file name without a path separator"}):null,P?e("div",{className:"text-[10px] text-error font-mono",children:P}):null,e("div",{className:"text-[10px] text-ink/40",children:"The original file stays where it is, and its tab stays open."})]})})}function _e(){o(()=>{let t=(r)=>{if(!ke())return;r.preventDefault(),r.returnValue=""};return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[])}function We({fileName:t,onAnswer:r}){return e(X,{onClose:()=>r("cancel"),header:e("div",{className:"flex items-center gap-2",children:[e(I,{size:15,className:"text-warning"}),e("span",{className:"text-sm font-semibold text-ink",children:"Unsaved changes"})]}),footer:e("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-ink/10",children:[e("button",{type:"button",onClick:()=>r("cancel"),className:"px-3 py-1.5 rounded border border-ink/20 text-ink/80 hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),e("button",{type:"button",onClick:()=>r("discard"),className:"px-3 py-1.5 rounded border border-error/40 text-error hover:bg-error/10 transition-colors cursor-pointer",children:"Discard"}),e("button",{type:"button",onClick:()=>r("save"),className:"px-3 py-1.5 rounded bg-ink text-paper hover:bg-ink/90 transition-colors cursor-pointer",children:"Save & close"})]}),children:e("div",{className:"px-4 py-3 text-xs text-ink/80",children:[e("span",{className:"font-mono text-ink",children:t})," has changes that are not on disk.",e("div",{className:"mt-1 text-ink/50",children:"Discarding them cannot be undone."})]})})}function Ve({closeGuard:t,activeFile:r,saveMissingConfirm:l,onCancelSaveMissing:d,onConfirmSaveMissing:u}){if(t.pending)return e(We,{fileName:t.pending.name,onAnswer:t.answer});if(l&&r)return e(Tu,{fileName:r.name,filePath:r.path,onClose:d,onConfirm:u});return null}function Je({className:t="",isMaximized:r,onKeyDownCapture:l,onFocusCapture:d,asSplitPane:u,tabs:x,activeFile:m,editor:c,externalChange:b,conflict:k,onReload:g,onKeepMine:y,body:R,saveAsOpen:M,onSaveAsClose:P,onSavedAs:L,closeGuard:D}){let O=r?"fixed inset-0 z-50 flex flex-col bg-canvas":`flex flex-col h-full bg-canvas ${t}`;return e("div",{className:O,onKeyDownCapture:l,onFocusCapture:d,children:[u?null:x,e(Ke,{activeFile:m,externalChange:b,conflict:k,onReload:g,onKeepMine:y}),R,M&&m?e(qe,{fileName:m.name,filePath:m.path,content:c.content,eol:c.eol,root:m.root,repo:m.repo,onSaved:({path:A})=>L(A),onClose:P}):null,e(Ve,{closeGuard:D,activeFile:m,saveMissingConfirm:c.saveMissingConfirm,onCancelSaveMissing:c.cancelSaveMissing,onConfirmSaveMissing:c.confirmSaveMissing})]})}function Ye({fileName:t,onClose:r,children:l}){return e("div",{className:"flex flex-col h-full min-w-0","data-split-pane":"",children:[e("div",{className:"flex items-center justify-between gap-2 px-3 py-1 border-b border-ink/10 bg-canvas flex-shrink-0",children:[e("span",{className:"text-[11px] font-mono text-ink/60 truncate",title:t,children:t}),e("button",{type:"button",onClick:r,className:"p-0.5 rounded hover:bg-ink/10 text-ink/50 hover:text-ink transition-colors cursor-pointer flex-shrink-0",title:"Close this pane (the tab stays open)","aria-label":"Close split pane",children:e(h,{size:12})})]}),e("div",{className:"flex-1 min-h-0",children:l})]})}function Ze({fraction:t,onFraction:r,rightPaneName:l,onClosePane:d,rightPane:u,children:x}){let m=i(null),c=i(null),b=Of(c),k=(g)=>{let y=g.currentTarget,R=m.current;if(!y||!R)return;y.setPointerCapture(g.pointerId);let M=(L)=>{let D=R.getBoundingClientRect();if(D.width===0)return;r(Y((L.clientX-D.left)/D.width))},P=()=>{y.releasePointerCapture(g.pointerId),y.removeEventListener("pointermove",M),y.removeEventListener("pointerup",P)};y.addEventListener("pointermove",M),y.addEventListener("pointerup",P)};return e("div",{ref:m,className:"flex w-full h-full","data-split-column":"",children:[e("div",{className:"flex flex-col min-w-0 h-full",style:{width:`${Math.round(Y(t)*100)}%`},children:x}),e("div",{ref:c,className:`w-[3px] flex-shrink-0 cursor-col-resize transition-colors active:bg-ink/40 ${b?"bg-ink/40":"bg-ink/10"}`,role:"separator","aria-orientation":"vertical","aria-label":"Resize split panes",onPointerDown:k}),e("div",{className:"flex-1 min-w-0 h-full",children:e(Ye,{fileName:l,onClose:d,children:u})})]})}function Qe({openedFiles:t,activeFileId:r,enabled:l}){let[d,u]=T("editor.split",ee),x=t.map((y)=>y.id),m=Pe(De(d,x),r),c=l&&m.rightFileId!==null?t.find((y)=>y.id===m.rightFileId)??null:null,b=a((y)=>{if(y!==null&&!ne(y,r,x))return;u({...m,rightFileId:y})},[m,u,r,x]),k=a(()=>u({...m,rightFileId:null}),[m,u]),g=a((y)=>u({...m,fraction:Y(y)}),[m,u]);return{rightFile:c,fraction:m.fraction,splitTo:b,close:k,setFraction:g}}function je({find:t,runCommand:r,reopenClosed:l}){let d=i(t);d.current=t;let u=i(r);u.current=r;let x=i(l);return x.current=l,{onKeyDownCapture:a((c)=>{let b=d.current;if(c.key==="Escape"){if(!b.open)return;c.preventDefault(),c.stopPropagation(),b.close();return}if((c.metaKey||c.ctrlKey)&&c.shiftKey&&c.code==="KeyT"){if(x.current?.())c.preventDefault(),c.stopPropagation();return}let k=N0(Ni,c);if(!k||!eg(k))return;c.preventDefault(),c.stopPropagation(),u.current(k)},[])}}function et(t){let r=i(t);r.current=t;let l=i(null);if(!l.current)l.current={saveNow:()=>r.current.saveNow(),runCommand:(u)=>r.current.runCommand(u)};return o(()=>{let u=l.current;if(!u)return;return hA(u)},[]),{onFocusCapture:a(()=>{if(l.current)hA(l.current)},[])}}function nt({openedFiles:t,activeFileId:r,onSelectFile:l,onCloseFile:d,saveNow:u}){let[x,m]=n(null);_e();let c=a((k)=>{let g=t.find((y)=>y.id===k);if(g&&Ce(k)){m(g);return}d(k)},[t,d]),b=a((k)=>{let g=x;if(!g)return;if(k==="cancel"){m(null);return}if(k==="save"){if(g.id!==r)l(g.id);u()}m(null),d(g.id)},[x,r,l,u,d]);return{requestClose:c,pending:x,answer:b}}function ot(){let[t,r]=n(0),[l,d]=n(!1),u=a(()=>r((x)=>x+1),[]);return{goToLineRequest:t,openGoToLine:u,saveAsOpen:l,setSaveAsOpen:d}}var Ct=Se(()=>import("./Body-3v975hq3.js").then((t)=>({default:t.EditorBody})));function rt(t){return e(Me,{fallback:e("div",{className:"h-full w-full"}),children:e(Ct,{...t})})}function kt({className:t="",openedFiles:r,activeFileId:l,onSelectFile:d,onCloseFile:u,onConvertDiffToEditor:x,refreshKey:m=0,onFileSaved:c,onOpenPath:b,onReopenClosed:k,reopenableCount:g,onCopyPath:y,onRevealInFiles:R,rootPath:M=null,repoPath:P=null,activeEditorPanelKey:L=null,forcedActiveFileId:D=null,asSplitPane:O=!1,onHidePanel:A}){let F=O?D:l,f=r.find((C)=>C.id===F),[Q,U,j]=T("editor.previewMode",{}),G=Du(String(F??"")),[v,w]=T("editor.zoomLevel",Oo),[S,q]=n(!1),[H,_]=T("editor.wordWrap",!0),J=ot(),{sessionId:le}=He(),B=Qe({openedFiles:r,activeFileId:F,enabled:!O}),W=i(null),it=Uo(),st=Li(),de=wu(r,m),ue=Boolean(f&&de.has(f.id)),N=Cu(f??null,{reportSaveError:!0,onFileSaved:c,missing:ue}),at=wA({path:f?.path??"",content:N.content,language:N.language}),lt=N.diskChange,pe=nt({openedFiles:r,activeFileId:F,onSelectFile:d,onCloseFile:u,saveNow:N.saveNow}),te=Eu({text:N.content,documentKey:`${f?.id??""}\x00${N.language}`,readSelection:()=>W.current?.getSelection()??null,select:(C,V,se=!0)=>W.current?.select(C,V,se),reveal:(C)=>W.current?.revealOffset(C),applyDocument:(C,V,se)=>W.current?.applyDocument(C,V,se),toggleWordWrap:()=>_((C)=>!C)}),ce=Bu(f?.path??null,N.content,N.loaded&&!N.loadError);Le({searchReveal:ce,revealMatch:te.revealMatch}),Iu({file:f,editor:N,surfaceRef:W,isPreview:f?Q[f.id]===!0:!1,exitPreview:()=>{let C=f?.id;if(C===void 0||C===null)return;U((V)=>({...V,[C]:!1}))}}),o(()=>{if(m>0)N.reset()},[m]),o(()=>{N.retain(r.map((C)=>C.id)),ye(r.map((C)=>C.id))},[r]),Be({openedFiles:r,dirtyKeys:N.dirtyKeys,activeFile:f,previewReady:j,setPreviewMode:U,sessionId:le});let dt=()=>{if(!f)return;U((C)=>({...C,[f.id]:!C[f.id]}))},oe=(C)=>{if(eg(C)){te.runCommand(C);return}if(C==="toggleWordWrap"){_((V)=>!V);return}if(C==="goToLine"){J.openGoToLine();return}W.current?.runCommand(C)},ut=je({find:te,runCommand:oe,reopenClosed:k}),pt=et({saveNow:N.saveNow,runCommand:oe}),re=H0(L);if(re)return e(Ae,{pluginId:re.pluginId,Component:re.Component,sessionId:le,className:t,onHide:A});if(r.length===0)return e(Fe,{className:t,onHide:A});let ct=N.viewerKind,me=f?Q[f.id]:!1,ft={activeFile:f,editor:N,find:te,surfaceRef:W,pluginFileView:at,wordWrap:H,setWordWrap:_,viewerKind:ct,isPreview:Boolean(me),isReviewing:Boolean(me)&&G.active,onToggleReview:G.toggle,isMaximized:S,setIsMaximized:q,zoomLevel:v,setZoomLevel:w,goToLineRequest:J.goToLineRequest,onSaveAs:()=>J.setSaveAsOpen(!0),onOpenPath:b,rootPath:M,repoPath:P,runCommand:oe,editorFontFamily:it,editorTheme:st,togglePreview:dt,revealActive:Boolean(ce),missing:ue,onConvertDiffToEditor:x,onFileSaved:c},bt=(C)=>({openedFiles:r,activeFileId:l,onSelectFile:d,onCloseFile:u,onConvertDiffToEditor:x,refreshKey:m,onFileSaved:c,onOpenPath:b,rootPath:M,repoPath:P,forcedActiveFileId:C,asSplitPane:!0}),gt=e(Ie,{openedFiles:r,activeFileId:l,onSelectFile:d,onCloseFile:pe.requestClose,missingIds:de,onCopyPath:y,onRevealInFiles:R,onReopenClosed:k,reopenableCount:g,onSplitTo:B.splitTo,onUnsplit:B.close,splitRightFileId:B.rightFile?.id??null,onHide:A}),fe=e(Je,{className:t,isMaximized:S,onKeyDownCapture:ut.onKeyDownCapture,onFocusCapture:pt.onFocusCapture,asSplitPane:O,tabs:gt,activeFile:f,editor:N,externalChange:lt,conflict:N.conflict,onReload:N.resolveConflictByReload,onKeepMine:N.keepMineAgainstDisk,body:e(rt,{...ft}),saveAsOpen:J.saveAsOpen,onSaveAsClose:()=>J.setSaveAsOpen(!1),onSavedAs:(C)=>{J.setSaveAsOpen(!1),b?.(C)},closeGuard:pe});if(!B.rightFile)return fe;return e(Ze,{fraction:B.fraction,onFraction:B.setFraction,rightPaneName:B.rightFile.name,onClosePane:B.close,rightPane:e(kt,{...bt(B.rightFile.id)}),children:fe})}export{kt as Editor};
1
+ import{n,o,K,i,a,ze,Me,Se,ie,e,s,p,I,E,Xe,bi,ir,h,sr,He,we,T,tt,wi,he,X,mt,Oo,Uo,N0,H0,Of,Jo,Ni,eg,hA}from"./index-jvn2xfpt.js";import"./index-exyg9sna.js";import{Li}from"./index-vxe4e903.js";import"./index-4kchzh9y.js";import{wA,xu,Fs,wu,Cu,Eu,Bu,Iu,_u,Su,Tu,Du}from"./index-0z7kerp1.js";var vt={name:"panel-right-close",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]]},be=s(vt);var z=new Set,ae=new Set,ge=new Set;function ve(){ge=new Set(z);for(let t of[...ae])t()}function xe(t){let r=new Set(t);if(r.size===z.size){let l=!0;for(let d of r)if(!z.has(d)){l=!1;break}if(l)return}z.clear();for(let l of r)z.add(l);ve()}function ye(t){let r=new Set(t),l=!1;for(let d of[...z])if(!r.has(d))z.delete(d),l=!0;if(l)ve()}function Ce(t){return z.has(t)}function ke(){return z.size>0}function ht(t){return ae.add(t),()=>{ae.delete(t)}}var xt=ht;function Ee(){return ze(xt,()=>ge)}function Te({x:t,y:r,rows:l,onAction:d,onClose:u}){let x=i(null),[m,c]=n({left:t,top:r});return K(()=>{let b=x.current;if(!b)return;let{width:k,height:g}=b.getBoundingClientRect();c({left:Math.min(t,Math.max(0,window.innerWidth-k-8)),top:Math.min(r,Math.max(0,window.innerHeight-g-8))})},[t,r,l.length]),ie(e("div",{className:"fixed inset-0 z-[70]",onClick:u,onContextMenu:(b)=>{b.preventDefault(),u()},children:e("div",{ref:x,role:"menu","aria-label":"Tab actions",className:"glass-popover absolute w-52 bg-paper border border-ink/15 rounded-md shadow-xl py-1 text-xs text-ink",style:{left:`${m.left}px`,top:`${m.top}px`},onClick:(b)=>b.stopPropagation(),children:l.map((b)=>e("button",{type:"button",role:"menuitem",onClick:()=>{d(b.action),u()},className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 transition-colors cursor-pointer",children:b.label},b.action))})}),document.body)}var ee={rightFileId:null,fraction:0.5};function ne(t,r,l){if(t===null)return!1;if(t===r)return!1;return l.includes(t)}function Ne(t,r){for(let l=r.length-1;l>=0;l-=1){let d=r[l];if(d!==t)return d}return null}function Pe(t,r){if(t.rightFileId===null)return t;if(t.rightFileId!==r)return t;return{...t,rightFileId:null}}function Y(t){if(!Number.isFinite(t))return ee.fraction;return Math.max(0.2,Math.min(0.8,t))}function De(t,r){if(typeof t!=="object"||t===null)return ee;let l=t,d=typeof l.fraction==="number"?Y(l.fraction):ee.fraction,u=typeof l.rightFileId==="string"||typeof l.rightFileId==="number"?l.rightFileId:null;if(u===null||!r.includes(u))return{rightFileId:null,fraction:d};return{rightFileId:u,fraction:d}}function Re({tab:t,openedFiles:r,dirtyIds:l,reopenable:d,activeFileId:u,splitRightFileId:x}){let m=r.filter((g)=>g.id!==t.id),c=r.filter((g)=>!l.has(g.id)),b=r.map((g)=>g.id);return[{action:"split-right",label:"Split right",enabled:ne(t.id,u,b)},{action:"unsplit",label:"Unsplit",enabled:x!==null},{action:"close",label:"Close",enabled:!0},{action:"close-others",label:"Close others",enabled:m.length>0},{action:"close-all",label:"Close all",enabled:r.length>0},{action:"close-saved",label:"Close saved",enabled:c.some((g)=>g.id!==t.id)},{action:"copy-path",label:"Copy path",enabled:Boolean(t.path)},{action:"reveal-in-files",label:"Reveal in Files",enabled:Boolean(t.path)&&!t.isDiff},{action:"reopen-closed",label:"Reopen closed tab",enabled:d>0}].filter((g)=>g.enabled)}function Z({onHide:t}){let r=Jo("toggleEditorPanel","Hide Editor Panel");return e("button",{type:"button",onClick:t,className:"p-1.5 mx-1 rounded transition-colors cursor-pointer text-ink/60 hover:bg-ink/10 hover:text-ink flex-shrink-0",title:r,"aria-label":r,children:e(be,{size:14})})}function Ie({openedFiles:t,activeFileId:r,onSelectFile:l,onCloseFile:d,missingIds:u,onCopyPath:x,onRevealInFiles:m,onReopenClosed:c,reopenableCount:b,onSplitTo:k,onUnsplit:g,splitRightFileId:y=null,onHide:R}){let M=Ee(),P=i(null),L=i(null),[D,O]=n(5),[A,F]=n(!1),[f,Q]=n(null);he(L,()=>F(!1)),o(()=>{let v=new ResizeObserver((w)=>{for(let S of w){let q=S.contentRect.width,H=Math.max(1,Math.floor((q-60)/150));O(H)}});if(P.current)v.observe(P.current);return()=>v.disconnect()},[]);let U=Ne(r,t.map((v)=>v.id)),j=[],G=[];if(t.length<=D)j=t;else{let v=t.findIndex((S)=>S.id===r),w=new Set;if(v!==-1&&r!==null)w.add(r);for(let S=t.length-1;S>=0;S--){if(w.size>=D)break;w.add(t[S].id)}j=t.filter((S)=>w.has(S.id)),G=t.filter((S)=>!w.has(S.id))}return e("div",{className:`${wi.desktop} flex bg-ink/10 w-full relative border-b border-ink/10`,ref:P,children:[e("div",{className:"flex overflow-hidden",children:j.map((v)=>{let w=v.id===r,S=Boolean(v.isDiff),q=S?sr(v.diffStatus||"M",v.diffStaged):null,H=Boolean(u?.has(v.id));return e("div",{onClick:()=>l(v.id),onContextMenu:(_)=>{_.preventDefault(),Q({tab:v,x:_.clientX,y:_.clientY})},className:`flex items-center space-x-1.5 px-3 py-1.5 cursor-pointer border-r border-ink/10 min-w-[120px] max-w-[210px] group ${w?"bg-paper border-t-2 border-t-ink text-ink":"bg-transparent border-t-2 border-t-transparent text-ink/60 hover:bg-paper/50"}`,title:H?`${v.path} — file no longer exists`:v.path,children:[S?e(bi,{size:14,className:w?"text-info flex-shrink-0":"text-info/70 flex-shrink-0"}):e(mt,{name:v.name,size:14,className:`flex-shrink-0${w||H?"":" opacity-60"}${H?" text-error":""}`}),e("span",{className:`text-xs font-mono truncate flex-1${H?" text-error line-through":""}`,children:v.name}),q&&e("span",{className:`px-1 text-[10px] font-mono font-bold rounded ${q.badgeBgClass}`,children:q.charStatus}),e(Oe,{dirty:M.has(v.id),active:w,label:`Close ${v.name}`,onClose:()=>d(v.id)})]},v.id)})}),f?e(Te,{x:f.x,y:f.y,rows:Re({tab:f.tab,openedFiles:t,dirtyIds:M,reopenable:b?.()??0,activeFileId:r,splitRightFileId:y}),onAction:(v)=>{let w=f.tab;switch(v){case"close":d(w.id);return;case"close-others":for(let S of[...t].reverse())if(S.id!==w.id)d(S.id);l(w.id);return;case"close-all":for(let S of[...t].reverse())d(S.id);return;case"close-saved":for(let S of[...t].reverse())if(!M.has(S.id))d(S.id);return;case"copy-path":x?.(w);return;case"reveal-in-files":m?.(w);return;case"reopen-closed":c?.();return;case"split-right":k?.(w.id);return;case"unsplit":g?.();return}},onClose:()=>Q(null)}):null,e("div",{className:"ml-auto flex items-center",children:[e("button",{type:"button",onClick:()=>y!==null?g?.():k?.(U),disabled:y===null&&U===null,"aria-pressed":y!==null,"aria-label":"Split editor",title:y!==null?"Close the split pane (the tab stays open)":U===null?"Open another file to split the editor":"Split the editor and show the newest other file",className:`p-1.5 mx-1 rounded transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-default ${y!==null?"bg-ink/10 text-ink":"text-ink/60 hover:bg-ink/10"}`,children:e(ir,{size:14})}),R&&e(Z,{onHide:R})]}),G.length>0&&e("div",{className:"relative flex items-center bg-ink/10",ref:L,children:[e("button",{className:`p-1.5 mx-1 rounded hover:bg-ink/10 text-ink/60 ${A?"bg-ink/10 text-ink":""}`,onClick:()=>F(!A),title:"More open files",children:e(E,{size:14})}),A&&e("div",{className:"glass-popover absolute right-0 top-full mt-1 w-52 bg-paper border border-ink/10 rounded shadow-lg z-50 py-1",children:[e("div",{className:"px-3 py-1 text-[10px] uppercase font-mono text-ink/40 border-b border-ink/10 mb-1",children:"Older Tabs"}),G.map((v)=>{let w=Boolean(u?.has(v.id));return e("div",{onClick:()=>{l(v.id),F(!1)},className:"flex items-center space-x-2 px-3 py-1.5 hover:bg-ink/5 cursor-pointer group",children:[v.isDiff?e(bi,{size:14,className:"text-info/80"}):e(mt,{name:v.name,size:14,className:w?"text-error":"opacity-60"}),e("span",{className:`text-xs font-mono truncate flex-1 ${w?"text-error line-through":"text-ink/80"}`,children:v.name}),e(Oe,{dirty:M.has(v.id),active:!1,label:`Close ${v.name}`,onClose:()=>{if(d(v.id),G.length===1)F(!1)}})]},v.id)})]})]})]})}function Oe({dirty:t,active:r,label:l,onClose:d}){return e("div",{role:"button",tabIndex:-1,"aria-label":l,title:t?`${l} — unsaved changes`:l,className:`p-0.5 rounded hover:bg-ink/10 touch-visible ${r||t?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:(u)=>{u.stopPropagation(),d()},children:t?e("span",{className:"block w-2 h-2 rounded-full bg-current mx-0.5","data-tab-dirty":"","aria-hidden":"true"}):e(h,{size:12})})}function Ae({pluginId:t,Component:r,sessionId:l,className:d="",onHide:u}){return e("div",{className:`flex flex-col h-full bg-canvas ${d}`,children:[u&&e("div",{className:"flex justify-end flex-shrink-0 border-b border-ink/10",children:e(Z,{onHide:u})}),e(tt,{pluginId:t,children:e(r,{sessionId:l,workspacePath:null})})]})}function Fe({className:t="",onHide:r}){return e("div",{className:`relative flex flex-col h-full bg-canvas items-center justify-center text-muted ${t}`,children:[r&&e("div",{className:"absolute top-0 right-0 flex items-center",children:e(Z,{onHide:r})}),e(mt,{name:"placeholder.txt",size:48,className:"mb-4 opacity-20"}),e("p",{className:"font-mono text-sm",children:"Select a file to open"})]})}function Le({searchReveal:t,revealMatch:r}){let l=i(r);l.current=r;let d=i(null);o(()=>{if(!t||d.current===t.request)return;d.current=t.request,l.current({query:t.request.query,options:t.request.options,line:t.request.line})},[t])}function Be({openedFiles:t,dirtyKeys:r,activeFile:l,previewReady:d,setPreviewMode:u,sessionId:x}){o(()=>{let m=new Set(t.filter((c)=>!c.isDiff&&c.content===void 0).map((c)=>c.id));xe([...r].filter((c)=>m.has(c)))},[r,t]),o(()=>{if(!d)return;let m=l?.id;if(!l||m===void 0||m===null)return;if(!xu(Fs(l.name)))return;let c=we(x,"editor.previewMode");if(c&&c[m]!==void 0)return;u((b)=>b[m]===void 0?{...b,[m]:!0}:b)},[d,l])}function Ke({activeFile:t,externalChange:r,conflict:l,onReload:d,onKeepMine:u}){if(!t)return null;if(l)return e(Su,{diskMtimeMs:l.diskMtimeMs,fileName:t.name,onReload:d,onKeepMine:u});if(r)return e(_u,{fileName:t.name,onReload:d,onKeepMine:u});return null}async function $e(t){let r=t.name.trim();if(!r)return{status:"failed",reason:"Enter a file name."};let l=new FormData;if(l.append("actionType","saveAs"),l.append("path",t.parent),l.append("name",r),l.append("content",t.content),l.append("eol",t.eol),t.root)l.append("root",t.root);if(t.repo&&t.repo!==".")l.append("repo",t.repo);try{let d=await fetch("/api/fs/action",{method:"POST",body:l}),u=await d.json().catch(()=>null),x=typeof u?.error==="string"?u.error:null;if(d.status===409)return{status:"exists",reason:x??`${r} already exists.`};if(d.ok&&u?.success&&typeof u.path==="string")return{status:"written",path:u.path};return{status:"failed",reason:x??"The file could not be written."}}catch{return{status:"failed",reason:"The file could not be written."}}}function Ue(t){let r=t.lastIndexOf(".");if(r<=0)return`${t} copy`;return`${t.slice(0,r)} copy${t.slice(r)}`}function Ge(t){let r=t.trim();if(!r)return!1;if(r==="."||r==="..")return!1;return!r.includes("/")&&!r.includes("\\")}function yt(t){let r=t.lastIndexOf("/");return r===-1?"":t.slice(0,r)}function qe({fileName:t,filePath:r,content:l,eol:d,root:u,repo:x,onSaved:m,onClose:c}){let[b,k]=n(()=>yt(r)),[g,y]=n(()=>Ue(t)),[R,M]=n(!1),[P,L]=n(null),D=i(null);o(()=>{D.current?.focus(),D.current?.select()},[]);let O=Ge(g),A=async()=>{if(!O||R)return;M(!0),L(null);let f=await $e({parent:b,name:g,content:l,eol:d,root:u,repo:x});if(M(!1),f.status==="written"){m({path:f.path});return}L(f.reason)},F=(f)=>{if(f.key==="Enter"){f.preventDefault(),A();return}if(f.key==="Escape")f.preventDefault(),c()};return e(X,{onClose:c,maxWidthClass:"max-w-md",header:e("span",{className:"text-sm font-semibold text-ink",children:"Save as"}),footer:e("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-ink/10",children:[e("button",{type:"button",onClick:c,className:"px-3 py-1.5 rounded border border-ink/20 text-ink/80 hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),e("button",{type:"button",onClick:()=>void A(),disabled:!O||R,className:"flex items-center gap-1.5 px-3 py-1.5 rounded bg-ink text-paper disabled:opacity-40 disabled:cursor-default cursor-pointer",children:[R?e(p,{size:12,className:"animate-spin"}):e(Xe,{size:12}),"Save"]})]}),children:e("div",{className:"px-4 py-3 space-y-2 text-xs",children:[e("label",{className:"block",children:[e("span",{className:"block text-[10px] uppercase tracking-wide text-ink/50 mb-1",children:"Folder"}),e("input",{value:b,onInput:(f)=>k(f.target.value),onKeyDown:F,placeholder:"(workspace root)","aria-label":"Destination folder",className:"w-full bg-paper border border-ink/20 rounded px-2 py-1 font-mono text-ink outline-none focus:border-ink/40"})]}),e("label",{className:"block",children:[e("span",{className:"block text-[10px] uppercase tracking-wide text-ink/50 mb-1",children:"Name"}),e("input",{ref:D,value:g,onInput:(f)=>y(f.target.value),onKeyDown:F,"aria-label":"File name","aria-invalid":!O,className:`w-full bg-paper border rounded px-2 py-1 font-mono text-ink outline-none ${O?"border-ink/20 focus:border-ink/40":"border-error text-error"}`})]}),!O?e("div",{className:"text-[10px] text-error font-mono",children:"Enter a file name without a path separator"}):null,P?e("div",{className:"text-[10px] text-error font-mono",children:P}):null,e("div",{className:"text-[10px] text-ink/40",children:"The original file stays where it is, and its tab stays open."})]})})}function _e(){o(()=>{let t=(r)=>{if(!ke())return;r.preventDefault(),r.returnValue=""};return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[])}function We({fileName:t,onAnswer:r}){return e(X,{onClose:()=>r("cancel"),header:e("div",{className:"flex items-center gap-2",children:[e(I,{size:15,className:"text-warning"}),e("span",{className:"text-sm font-semibold text-ink",children:"Unsaved changes"})]}),footer:e("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-ink/10",children:[e("button",{type:"button",onClick:()=>r("cancel"),className:"px-3 py-1.5 rounded border border-ink/20 text-ink/80 hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),e("button",{type:"button",onClick:()=>r("discard"),className:"px-3 py-1.5 rounded border border-error/40 text-error hover:bg-error/10 transition-colors cursor-pointer",children:"Discard"}),e("button",{type:"button",onClick:()=>r("save"),className:"px-3 py-1.5 rounded bg-ink text-paper hover:bg-ink/90 transition-colors cursor-pointer",children:"Save & close"})]}),children:e("div",{className:"px-4 py-3 text-xs text-ink/80",children:[e("span",{className:"font-mono text-ink",children:t})," has changes that are not on disk.",e("div",{className:"mt-1 text-ink/50",children:"Discarding them cannot be undone."})]})})}function Ve({closeGuard:t,activeFile:r,saveMissingConfirm:l,onCancelSaveMissing:d,onConfirmSaveMissing:u}){if(t.pending)return e(We,{fileName:t.pending.name,onAnswer:t.answer});if(l&&r)return e(Tu,{fileName:r.name,filePath:r.path,onClose:d,onConfirm:u});return null}function Je({className:t="",isMaximized:r,onKeyDownCapture:l,onFocusCapture:d,asSplitPane:u,tabs:x,activeFile:m,editor:c,externalChange:b,conflict:k,onReload:g,onKeepMine:y,body:R,saveAsOpen:M,onSaveAsClose:P,onSavedAs:L,closeGuard:D}){let O=r?"fixed inset-0 z-50 flex flex-col bg-canvas":`flex flex-col h-full bg-canvas ${t}`;return e("div",{className:O,onKeyDownCapture:l,onFocusCapture:d,children:[u?null:x,e(Ke,{activeFile:m,externalChange:b,conflict:k,onReload:g,onKeepMine:y}),R,M&&m?e(qe,{fileName:m.name,filePath:m.path,content:c.content,eol:c.eol,root:m.root,repo:m.repo,onSaved:({path:A})=>L(A),onClose:P}):null,e(Ve,{closeGuard:D,activeFile:m,saveMissingConfirm:c.saveMissingConfirm,onCancelSaveMissing:c.cancelSaveMissing,onConfirmSaveMissing:c.confirmSaveMissing})]})}function Ye({fileName:t,onClose:r,children:l}){return e("div",{className:"flex flex-col h-full min-w-0","data-split-pane":"",children:[e("div",{className:"flex items-center justify-between gap-2 px-3 py-1 border-b border-ink/10 bg-canvas flex-shrink-0",children:[e("span",{className:"text-[11px] font-mono text-ink/60 truncate",title:t,children:t}),e("button",{type:"button",onClick:r,className:"p-0.5 rounded hover:bg-ink/10 text-ink/50 hover:text-ink transition-colors cursor-pointer flex-shrink-0",title:"Close this pane (the tab stays open)","aria-label":"Close split pane",children:e(h,{size:12})})]}),e("div",{className:"flex-1 min-h-0",children:l})]})}function Ze({fraction:t,onFraction:r,rightPaneName:l,onClosePane:d,rightPane:u,children:x}){let m=i(null),c=i(null),b=Of(c),k=(g)=>{let y=g.currentTarget,R=m.current;if(!y||!R)return;y.setPointerCapture(g.pointerId);let M=(L)=>{let D=R.getBoundingClientRect();if(D.width===0)return;r(Y((L.clientX-D.left)/D.width))},P=()=>{y.releasePointerCapture(g.pointerId),y.removeEventListener("pointermove",M),y.removeEventListener("pointerup",P)};y.addEventListener("pointermove",M),y.addEventListener("pointerup",P)};return e("div",{ref:m,className:"flex w-full h-full","data-split-column":"",children:[e("div",{className:"flex flex-col min-w-0 h-full",style:{width:`${Math.round(Y(t)*100)}%`},children:x}),e("div",{ref:c,className:`w-[3px] flex-shrink-0 cursor-col-resize transition-colors active:bg-ink/40 ${b?"bg-ink/40":"bg-ink/10"}`,role:"separator","aria-orientation":"vertical","aria-label":"Resize split panes",onPointerDown:k}),e("div",{className:"flex-1 min-w-0 h-full",children:e(Ye,{fileName:l,onClose:d,children:u})})]})}function Qe({openedFiles:t,activeFileId:r,enabled:l}){let[d,u]=T("editor.split",ee),x=t.map((y)=>y.id),m=Pe(De(d,x),r),c=l&&m.rightFileId!==null?t.find((y)=>y.id===m.rightFileId)??null:null,b=a((y)=>{if(y!==null&&!ne(y,r,x))return;u({...m,rightFileId:y})},[m,u,r,x]),k=a(()=>u({...m,rightFileId:null}),[m,u]),g=a((y)=>u({...m,fraction:Y(y)}),[m,u]);return{rightFile:c,fraction:m.fraction,splitTo:b,close:k,setFraction:g}}function je({find:t,runCommand:r,reopenClosed:l}){let d=i(t);d.current=t;let u=i(r);u.current=r;let x=i(l);return x.current=l,{onKeyDownCapture:a((c)=>{let b=d.current;if(c.key==="Escape"){if(!b.open)return;c.preventDefault(),c.stopPropagation(),b.close();return}if((c.metaKey||c.ctrlKey)&&c.shiftKey&&c.code==="KeyT"){if(x.current?.())c.preventDefault(),c.stopPropagation();return}let k=N0(Ni,c);if(!k||!eg(k))return;c.preventDefault(),c.stopPropagation(),u.current(k)},[])}}function et(t){let r=i(t);r.current=t;let l=i(null);if(!l.current)l.current={saveNow:()=>r.current.saveNow(),runCommand:(u)=>r.current.runCommand(u)};return o(()=>{let u=l.current;if(!u)return;return hA(u)},[]),{onFocusCapture:a(()=>{if(l.current)hA(l.current)},[])}}function nt({openedFiles:t,activeFileId:r,onSelectFile:l,onCloseFile:d,saveNow:u}){let[x,m]=n(null);_e();let c=a((k)=>{let g=t.find((y)=>y.id===k);if(g&&Ce(k)){m(g);return}d(k)},[t,d]),b=a((k)=>{let g=x;if(!g)return;if(k==="cancel"){m(null);return}if(k==="save"){if(g.id!==r)l(g.id);u()}m(null),d(g.id)},[x,r,l,u,d]);return{requestClose:c,pending:x,answer:b}}function ot(){let[t,r]=n(0),[l,d]=n(!1),u=a(()=>r((x)=>x+1),[]);return{goToLineRequest:t,openGoToLine:u,saveAsOpen:l,setSaveAsOpen:d}}var Ct=Se(()=>import("./Body-x5grdps8.js").then((t)=>({default:t.EditorBody})));function rt(t){return e(Me,{fallback:e("div",{className:"h-full w-full"}),children:e(Ct,{...t})})}function kt({className:t="",openedFiles:r,activeFileId:l,onSelectFile:d,onCloseFile:u,onConvertDiffToEditor:x,refreshKey:m=0,onFileSaved:c,onOpenPath:b,onReopenClosed:k,reopenableCount:g,onCopyPath:y,onRevealInFiles:R,rootPath:M=null,repoPath:P=null,activeEditorPanelKey:L=null,forcedActiveFileId:D=null,asSplitPane:O=!1,onHidePanel:A}){let F=O?D:l,f=r.find((C)=>C.id===F),[Q,U,j]=T("editor.previewMode",{}),G=Du(String(F??"")),[v,w]=T("editor.zoomLevel",Oo),[S,q]=n(!1),[H,_]=T("editor.wordWrap",!0),J=ot(),{sessionId:le}=He(),B=Qe({openedFiles:r,activeFileId:F,enabled:!O}),W=i(null),it=Uo(),st=Li(),de=wu(r,m),ue=Boolean(f&&de.has(f.id)),N=Cu(f??null,{reportSaveError:!0,onFileSaved:c,missing:ue}),at=wA({path:f?.path??"",content:N.content,language:N.language}),lt=N.diskChange,pe=nt({openedFiles:r,activeFileId:F,onSelectFile:d,onCloseFile:u,saveNow:N.saveNow}),te=Eu({text:N.content,documentKey:`${f?.id??""}\x00${N.language}`,readSelection:()=>W.current?.getSelection()??null,select:(C,V,se=!0)=>W.current?.select(C,V,se),reveal:(C)=>W.current?.revealOffset(C),applyDocument:(C,V,se)=>W.current?.applyDocument(C,V,se),toggleWordWrap:()=>_((C)=>!C)}),ce=Bu(f?.path??null,N.content,N.loaded&&!N.loadError);Le({searchReveal:ce,revealMatch:te.revealMatch}),Iu({file:f,editor:N,surfaceRef:W,isPreview:f?Q[f.id]===!0:!1,exitPreview:()=>{let C=f?.id;if(C===void 0||C===null)return;U((V)=>({...V,[C]:!1}))}}),o(()=>{if(m>0)N.reset()},[m]),o(()=>{N.retain(r.map((C)=>C.id)),ye(r.map((C)=>C.id))},[r]),Be({openedFiles:r,dirtyKeys:N.dirtyKeys,activeFile:f,previewReady:j,setPreviewMode:U,sessionId:le});let dt=()=>{if(!f)return;U((C)=>({...C,[f.id]:!C[f.id]}))},oe=(C)=>{if(eg(C)){te.runCommand(C);return}if(C==="toggleWordWrap"){_((V)=>!V);return}if(C==="goToLine"){J.openGoToLine();return}W.current?.runCommand(C)},ut=je({find:te,runCommand:oe,reopenClosed:k}),pt=et({saveNow:N.saveNow,runCommand:oe}),re=H0(L);if(re)return e(Ae,{pluginId:re.pluginId,Component:re.Component,sessionId:le,className:t,onHide:A});if(r.length===0)return e(Fe,{className:t,onHide:A});let ct=N.viewerKind,me=f?Q[f.id]:!1,ft={activeFile:f,editor:N,find:te,surfaceRef:W,pluginFileView:at,wordWrap:H,setWordWrap:_,viewerKind:ct,isPreview:Boolean(me),isReviewing:Boolean(me)&&G.active,onToggleReview:G.toggle,isMaximized:S,setIsMaximized:q,zoomLevel:v,setZoomLevel:w,goToLineRequest:J.goToLineRequest,onSaveAs:()=>J.setSaveAsOpen(!0),onOpenPath:b,rootPath:M,repoPath:P,runCommand:oe,editorFontFamily:it,editorTheme:st,togglePreview:dt,revealActive:Boolean(ce),missing:ue,onConvertDiffToEditor:x,onFileSaved:c},bt=(C)=>({openedFiles:r,activeFileId:l,onSelectFile:d,onCloseFile:u,onConvertDiffToEditor:x,refreshKey:m,onFileSaved:c,onOpenPath:b,rootPath:M,repoPath:P,forcedActiveFileId:C,asSplitPane:!0}),gt=e(Ie,{openedFiles:r,activeFileId:l,onSelectFile:d,onCloseFile:pe.requestClose,missingIds:de,onCopyPath:y,onRevealInFiles:R,onReopenClosed:k,reopenableCount:g,onSplitTo:B.splitTo,onUnsplit:B.close,splitRightFileId:B.rightFile?.id??null,onHide:A}),fe=e(Je,{className:t,isMaximized:S,onKeyDownCapture:ut.onKeyDownCapture,onFocusCapture:pt.onFocusCapture,asSplitPane:O,tabs:gt,activeFile:f,editor:N,externalChange:lt,conflict:N.conflict,onReload:N.resolveConflictByReload,onKeepMine:N.keepMineAgainstDisk,body:e(rt,{...ft}),saveAsOpen:J.saveAsOpen,onSaveAsClose:()=>J.setSaveAsOpen(!1),onSavedAs:(C)=>{J.setSaveAsOpen(!1),b?.(C)},closeGuard:pe});if(!B.rightFile)return fe;return e(Ze,{fraction:B.fraction,onFraction:B.setFraction,rightPaneName:B.rightFile.name,onClosePane:B.close,rightPane:e(kt,{...bt(B.rightFile.id)}),children:fe})}export{kt as Editor};
@@ -1,2 +1,2 @@
1
- import{d,n,K,i,e,s,f,E,ae,Ie,Ta,Da,kt,Ra,kr,It,Rt}from"./index-8w69r0c4.js";import{Wa,Ka,ai}from"./index-pd4s49n5.js";var Q={name:"square-pen",size:24,node:[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],aliases:["pen-box","edit","pen-square"]},w=s(Q);var Y={name:"laptop",size:24,node:[["path",{d:"M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z",key:"1pdavp"}],["path",{d:"M20.054 15.987H3.946",key:"14rxg9"}]]},O=s(Y);var j={name:"ratio",size:24,node:[["rect",{width:"12",height:"20",x:"6",y:"2",rx:"2",key:"1oxtiu"}],["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]},C=s(j);var ee={name:"tablet",size:24,node:[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]]},N=s(ee);var g=[{id:"responsive",label:"Responsive (100% Fluid)",category:"responsive",icon:Da},{id:"desktop-16-9",label:"Desktop 16:9 (Auto H:W)",category:"responsive",icon:C},{id:"laptop",label:"Laptop (1024 × 768)",category:"responsive",icon:O},{id:"tablet",label:"Tablet (768 × 1024)",category:"mobile",icon:N},{id:"mobile",label:"Mobile Phone (375 × 667)",category:"mobile",icon:kr},{id:"mobile-lg",label:"Mobile Large (414 × 896)",category:"mobile",icon:kr}];function oe(t){switch(t){case"desktop-16-9":return"Desktop 16:9";case"laptop":return"Laptop 1024p";case"tablet":return"Tablet 768p";case"mobile":return"Mobile 375p";case"mobile-lg":return"Mobile Lg 414p";case"responsive":default:return"Responsive"}}function P({viewportMode:t,onChangeViewport:a,zoomLevel:r=100,onSetZoom:l}){let[b,c]=n(null);return e("div",{className:"flex items-center space-x-1.5 flex-shrink-0",children:[e("div",{className:"hidden sm:flex items-center bg-canvas border border-ink/10 rounded-md p-0.5",children:[e("button",{type:"button",onClick:()=>a("responsive"),className:`p-1 rounded text-xs transition-colors cursor-pointer ${t==="responsive"?"bg-ink text-canvas font-medium":"text-ink/50 hover:text-ink"}`,title:"Responsive (100% Fluid)",children:e(Da,{size:12})}),e("button",{type:"button",onClick:()=>a("desktop-16-9"),className:`p-1 rounded text-xs transition-colors cursor-pointer ${t==="desktop-16-9"?"bg-ink text-canvas font-medium":"text-ink/50 hover:text-ink"}`,title:"Desktop 16:9 (Auto Height following Width)",children:e(C,{size:12})}),e("button",{type:"button",onClick:()=>a("tablet"),className:`p-1 rounded text-xs transition-colors cursor-pointer ${t==="tablet"?"bg-ink text-canvas font-medium":"text-ink/50 hover:text-ink"}`,title:"Tablet (768px)",children:e(N,{size:12})}),e("button",{type:"button",onClick:()=>a("mobile"),className:`p-1 rounded text-xs transition-colors cursor-pointer ${t==="mobile"?"bg-ink text-canvas font-medium":"text-ink/50 hover:text-ink"}`,title:"Mobile (375px)",children:e(kr,{size:12})})]}),e("button",{type:"button","aria-haspopup":"menu","aria-expanded":b!==null,onClick:(o)=>c(b?null:It(o.currentTarget)),className:"flex items-center space-x-1 px-2 py-1 rounded bg-canvas border border-ink/15 hover:border-ink/30 text-ink text-[11px] font-mono transition-colors cursor-pointer",title:"Device & Responsive Testing Menu",children:[e("span",{className:"hidden md:inline text-[10px] font-medium",children:oe(t)}),e(E,{size:11,className:"text-ink/60"})]}),e(Rt,{anchor:b,ariaLabel:"Device & Responsive Testing Menu",className:"w-56 bg-paper border border-ink/15 rounded-lg shadow-xl py-1 text-xs font-mono",onClose:()=>c(null),children:[e("div",{className:"px-2.5 py-1 text-[10px] text-ink/40 uppercase tracking-wider font-semibold",children:"Responsive Testing"}),g.filter((o)=>o.category==="responsive").map((o)=>{let m=o.icon,p=t===o.id;return e("button",{type:"button",role:"menuitemradio","aria-checked":p,onClick:()=>{a(o.id),c(null)},className:`w-full px-2.5 py-1.5 flex items-center justify-between text-left hover:bg-ink/5 cursor-pointer ${p?"bg-ink/10 font-semibold text-ink":"text-ink/75"}`,children:[e("div",{className:"flex items-center space-x-2",children:[e(m,{size:13,className:"text-ink/60"}),e("span",{children:o.label})]}),p&&e(f,{size:12,className:"text-success"})]},o.id)}),e("div",{className:"mt-1 pt-1 border-t border-ink/10 px-2.5 py-1 text-[10px] text-ink/40 uppercase tracking-wider font-semibold",children:"Mobile Testing"}),g.filter((o)=>o.category==="mobile").map((o)=>{let m=o.icon,p=t===o.id;return e("button",{type:"button",role:"menuitemradio","aria-checked":p,onClick:()=>{a(o.id),c(null)},className:`w-full px-2.5 py-1.5 flex items-center justify-between text-left hover:bg-ink/5 cursor-pointer ${p?"bg-ink/10 font-semibold text-ink":"text-ink/75"}`,children:[e("div",{className:"flex items-center space-x-2",children:[e(m,{size:13,className:"text-ink/60"}),e("span",{children:o.label})]}),p&&e(f,{size:12,className:"text-success"})]},o.id)}),l&&e(d,{children:[e("div",{className:"mt-1 pt-1 border-t border-ink/10 px-2.5 py-1 text-[10px] text-ink/40 uppercase tracking-wider font-semibold",children:["Zoom Scale (",r,"%)"]}),e("div",{className:"grid grid-cols-3 gap-1 px-2 py-1",children:[50,75,100,125,150,200].map((o)=>e("button",{type:"button",onClick:()=>{l(o),c(null)},className:`px-1.5 py-1 text-center rounded text-[11px] font-mono cursor-pointer transition-colors ${r===o?"bg-ink text-canvas font-semibold":"bg-canvas border border-ink/10 text-ink/75 hover:bg-ink/5"}`,children:[o,"%"]},o))})]})]})]})}function A({zoomLevel:t,onZoomIn:a,onZoomOut:r,onResetZoom:l}){return e("div",{className:"flex items-center bg-canvas border border-ink/10 rounded-md p-0.5 space-x-0.5 text-xs font-mono",children:[e("button",{type:"button",onClick:r,disabled:t<=50,"aria-label":"Perkecil tampilan",title:"Zoom Out (-10%)",className:"p-1 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink cursor-pointer disabled:cursor-not-allowed transition-colors",children:e(Ka,{size:12})}),e("button",{type:"button",onClick:l,className:"px-1 text-[10px] font-medium text-ink/75 hover:text-ink hover:underline cursor-pointer select-none",title:"Reset Zoom (100%)",children:[t,"%"]}),e("button",{type:"button",onClick:a,disabled:t>=200,"aria-label":"Perbesar tampilan",title:"Zoom In (+10%)",className:"p-1 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink cursor-pointer disabled:cursor-not-allowed transition-colors",children:e(Wa,{size:12})})]})}var h="p-1.5 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink transition-colors cursor-pointer disabled:cursor-not-allowed";function B(t){let a=[],{url:r,zoomLevel:l,copied:b,included:c}=t;if(t.viewportMode&&t.onChangeViewport){let{viewportMode:o,onChangeViewport:m,onSetZoom:p}=t;a.push({id:"viewport",actions:g.map((x)=>({label:x.label,icon:x.icon,onSelect:()=>m(x.id),active:o===x.id})),children:e(P,{viewportMode:o,onChangeViewport:m,zoomLevel:l,onSetZoom:p})})}if(a.push({id:"zoom",actions:[{label:"Zoom in (+10%)",icon:Wa,onSelect:t.onZoomIn,disabled:l>=200},{label:"Zoom out (-10%)",icon:Ka,onSelect:t.onZoomOut,disabled:l<=50},{label:"Reset zoom (100%)",icon:kt,onSelect:t.onResetZoom,active:l===100}],children:e(A,{zoomLevel:l,onZoomIn:t.onZoomIn,onZoomOut:t.onZoomOut,onResetZoom:t.onResetZoom})}),a.push({id:"include",actions:[{label:c?"Page context added to the draft":"Include this page in the chat draft",icon:Ta,onSelect:t.onIncludeInChat,disabled:!r}],children:e("button",{type:"button",onClick:t.onIncludeInChat,disabled:!r,"aria-label":"Include this page in the chat draft",title:c?"Page context added to the draft":"Include this page in the chat draft",className:h,children:c?e(f,{size:14,className:"text-success"}):e(Ta,{size:14})})}),t.annotate){let o=t.annotate;a.push({id:"annotate",actions:[{label:o.count>0?`${o.active?"Tutup mode anotasi":"Buka mode anotasi"} (${o.count})`:"Mark a part of the page, then send it to the chat",icon:w,onSelect:o.onToggle,active:o.active,disabled:!r}],children:e("button",{type:"button",onClick:o.onToggle,disabled:!r,"aria-label":"Page annotation mode","aria-pressed":o.active,title:o.active?"Tutup mode anotasi":o.count>0?`Anotasi (${o.count}) — buka lagi`:"Mark a part of the page, then send it to the chat",className:`${h} relative ${o.active?"bg-ink/10 text-ink":""}`,children:[e(w,{size:14}),o.count>0&&e("span",{className:"absolute -top-0.5 -right-0.5 min-w-[13px] h-[13px] px-0.5 rounded-full bg-error text-paper text-[10px] leading-[13px] font-mono text-center",children:o.count})]})})}if(a.push({id:"copy",actions:[{label:b?"Copied URL!":"Copy URL",icon:ae,onSelect:t.onCopy,disabled:!r}],children:e("button",{type:"button",onClick:t.onCopy,disabled:!r,"aria-label":"Salin URL",title:b?"Copied URL!":"Copy URL",className:h,children:b?e(f,{size:14,className:"text-success"}):e(ae,{size:14})})}),t.onReconnect){let o=t.onReconnect;a.push({id:"reconnect",actions:[{label:"Sambungkan ulang live view",icon:Ra,onSelect:o}],children:e("button",{type:"button",onClick:o,"aria-label":"Sambungkan ulang live view",title:"Reconnect live view",className:h,children:e(Ra,{size:14})})})}return a.push({id:"open-external",actions:[{label:t.openExternalLabel,icon:Ie,onSelect:t.onOpenExternal,disabled:!r}],children:e("button",{type:"button",onClick:t.onOpenExternal,disabled:!r,"aria-label":t.openExternalLabel,title:t.openExternalTitle,className:h,children:e(Ie,{size:14})})}),a}var V=108,te=280,ne=18,ie=140,re=36;function rd({url:t,statusDotClass:a,statusLabel:r,viewportMode:l,zoomLevel:b,onChangeViewport:c,onZoomIn:o,onZoomOut:m,onResetZoom:p,onSetZoom:x,annotate:D,onIncludeInChat:_,onOpenExternal:U,onReconnect:W,openExternalLabel:H,openExternalTitle:X,twoRows:k=!1,children:q}){let[F,T]=n(!1),[G,R]=n(!1),y=i(null),[u,I]=n(0),S=B({url:t,zoomLevel:b,copied:F,included:G,viewportMode:l,onChangeViewport:c,annotate:D,onReconnect:W,onIncludeInChat:()=>{_(),R(!0),setTimeout(()=>R(!1),2500)},onCopy:()=>{if(!t)return;navigator.clipboard.writeText(t).then(()=>{T(!0),setTimeout(()=>T(!1),2000)}).catch(()=>{})},onOpenExternal:U,onZoomIn:o,onZoomOut:m,onResetZoom:p,onSetZoom:x,openExternalLabel:H,openExternalTitle:X});K(()=>{let v=y.current;if(!v)return;I(v.clientWidth)}),K(()=>{let v=y.current;if(!v||typeof ResizeObserver>"u")return;let L=new ResizeObserver(()=>I(v.clientWidth));return L.observe(v),()=>L.disconnect()},[]);let M=u===0||u>=te,Z=M?u>0?Math.min(V,u*0.25):V:ne,z=k?u>0?u:void 0:u>0?Math.max(0,u-Z-ie-re):void 0,J=e("div",{className:"flex items-center space-x-1.5 flex-shrink-0 min-w-0",style:{maxWidth:`${Z}px`},title:r,children:[e("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${a}`}),M&&e("span",{className:"text-[10px] font-mono uppercase tracking-wide text-ink/60 truncate",children:r})]});return e("div",{ref:y,"data-browser-toolbar":"",className:`px-2.5 border-b border-ink/10 bg-paper flex flex-col gap-y-1 flex-shrink-0 select-none ${k?"py-1":"h-10 justify-center"}`,children:[e("div",{"data-toolbar-band":"address",className:"flex items-center gap-x-2 min-w-0",children:[J,e("div",{className:"flex flex-1 min-w-0 items-center",children:q}),!k&&e(ai,{clusters:S,available:z})]}),k&&e("div",{"data-toolbar-band":"controls",className:"flex items-center min-w-0",children:e(ai,{clusters:S,available:z})})]})}
1
+ import{d,n,K,i,e,s,f,E,ae,Ie,Ta,Da,kt,Ra,kr,It,Rt}from"./index-jvn2xfpt.js";import{Wa,Ka,ai}from"./index-e2y4hkps.js";var Q={name:"square-pen",size:24,node:[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],aliases:["pen-box","edit","pen-square"]},w=s(Q);var Y={name:"laptop",size:24,node:[["path",{d:"M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z",key:"1pdavp"}],["path",{d:"M20.054 15.987H3.946",key:"14rxg9"}]]},O=s(Y);var j={name:"ratio",size:24,node:[["rect",{width:"12",height:"20",x:"6",y:"2",rx:"2",key:"1oxtiu"}],["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]},C=s(j);var ee={name:"tablet",size:24,node:[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]]},N=s(ee);var g=[{id:"responsive",label:"Responsive (100% Fluid)",category:"responsive",icon:Da},{id:"desktop-16-9",label:"Desktop 16:9 (Auto H:W)",category:"responsive",icon:C},{id:"laptop",label:"Laptop (1024 × 768)",category:"responsive",icon:O},{id:"tablet",label:"Tablet (768 × 1024)",category:"mobile",icon:N},{id:"mobile",label:"Mobile Phone (375 × 667)",category:"mobile",icon:kr},{id:"mobile-lg",label:"Mobile Large (414 × 896)",category:"mobile",icon:kr}];function oe(t){switch(t){case"desktop-16-9":return"Desktop 16:9";case"laptop":return"Laptop 1024p";case"tablet":return"Tablet 768p";case"mobile":return"Mobile 375p";case"mobile-lg":return"Mobile Lg 414p";case"responsive":default:return"Responsive"}}function P({viewportMode:t,onChangeViewport:a,zoomLevel:r=100,onSetZoom:l}){let[b,c]=n(null);return e("div",{className:"flex items-center space-x-1.5 flex-shrink-0",children:[e("div",{className:"hidden sm:flex items-center bg-canvas border border-ink/10 rounded-md p-0.5",children:[e("button",{type:"button",onClick:()=>a("responsive"),className:`p-1 rounded text-xs transition-colors cursor-pointer ${t==="responsive"?"bg-ink text-canvas font-medium":"text-ink/50 hover:text-ink"}`,title:"Responsive (100% Fluid)",children:e(Da,{size:12})}),e("button",{type:"button",onClick:()=>a("desktop-16-9"),className:`p-1 rounded text-xs transition-colors cursor-pointer ${t==="desktop-16-9"?"bg-ink text-canvas font-medium":"text-ink/50 hover:text-ink"}`,title:"Desktop 16:9 (Auto Height following Width)",children:e(C,{size:12})}),e("button",{type:"button",onClick:()=>a("tablet"),className:`p-1 rounded text-xs transition-colors cursor-pointer ${t==="tablet"?"bg-ink text-canvas font-medium":"text-ink/50 hover:text-ink"}`,title:"Tablet (768px)",children:e(N,{size:12})}),e("button",{type:"button",onClick:()=>a("mobile"),className:`p-1 rounded text-xs transition-colors cursor-pointer ${t==="mobile"?"bg-ink text-canvas font-medium":"text-ink/50 hover:text-ink"}`,title:"Mobile (375px)",children:e(kr,{size:12})})]}),e("button",{type:"button","aria-haspopup":"menu","aria-expanded":b!==null,onClick:(o)=>c(b?null:It(o.currentTarget)),className:"flex items-center space-x-1 px-2 py-1 rounded bg-canvas border border-ink/15 hover:border-ink/30 text-ink text-[11px] font-mono transition-colors cursor-pointer",title:"Device & Responsive Testing Menu",children:[e("span",{className:"hidden md:inline text-[10px] font-medium",children:oe(t)}),e(E,{size:11,className:"text-ink/60"})]}),e(Rt,{anchor:b,ariaLabel:"Device & Responsive Testing Menu",className:"w-56 bg-paper border border-ink/15 rounded-lg shadow-xl py-1 text-xs font-mono",onClose:()=>c(null),children:[e("div",{className:"px-2.5 py-1 text-[10px] text-ink/40 uppercase tracking-wider font-semibold",children:"Responsive Testing"}),g.filter((o)=>o.category==="responsive").map((o)=>{let m=o.icon,p=t===o.id;return e("button",{type:"button",role:"menuitemradio","aria-checked":p,onClick:()=>{a(o.id),c(null)},className:`w-full px-2.5 py-1.5 flex items-center justify-between text-left hover:bg-ink/5 cursor-pointer ${p?"bg-ink/10 font-semibold text-ink":"text-ink/75"}`,children:[e("div",{className:"flex items-center space-x-2",children:[e(m,{size:13,className:"text-ink/60"}),e("span",{children:o.label})]}),p&&e(f,{size:12,className:"text-success"})]},o.id)}),e("div",{className:"mt-1 pt-1 border-t border-ink/10 px-2.5 py-1 text-[10px] text-ink/40 uppercase tracking-wider font-semibold",children:"Mobile Testing"}),g.filter((o)=>o.category==="mobile").map((o)=>{let m=o.icon,p=t===o.id;return e("button",{type:"button",role:"menuitemradio","aria-checked":p,onClick:()=>{a(o.id),c(null)},className:`w-full px-2.5 py-1.5 flex items-center justify-between text-left hover:bg-ink/5 cursor-pointer ${p?"bg-ink/10 font-semibold text-ink":"text-ink/75"}`,children:[e("div",{className:"flex items-center space-x-2",children:[e(m,{size:13,className:"text-ink/60"}),e("span",{children:o.label})]}),p&&e(f,{size:12,className:"text-success"})]},o.id)}),l&&e(d,{children:[e("div",{className:"mt-1 pt-1 border-t border-ink/10 px-2.5 py-1 text-[10px] text-ink/40 uppercase tracking-wider font-semibold",children:["Zoom Scale (",r,"%)"]}),e("div",{className:"grid grid-cols-3 gap-1 px-2 py-1",children:[50,75,100,125,150,200].map((o)=>e("button",{type:"button",onClick:()=>{l(o),c(null)},className:`px-1.5 py-1 text-center rounded text-[11px] font-mono cursor-pointer transition-colors ${r===o?"bg-ink text-canvas font-semibold":"bg-canvas border border-ink/10 text-ink/75 hover:bg-ink/5"}`,children:[o,"%"]},o))})]})]})]})}function A({zoomLevel:t,onZoomIn:a,onZoomOut:r,onResetZoom:l}){return e("div",{className:"flex items-center bg-canvas border border-ink/10 rounded-md p-0.5 space-x-0.5 text-xs font-mono",children:[e("button",{type:"button",onClick:r,disabled:t<=50,"aria-label":"Perkecil tampilan",title:"Zoom Out (-10%)",className:"p-1 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink cursor-pointer disabled:cursor-not-allowed transition-colors",children:e(Ka,{size:12})}),e("button",{type:"button",onClick:l,className:"px-1 text-[10px] font-medium text-ink/75 hover:text-ink hover:underline cursor-pointer select-none",title:"Reset Zoom (100%)",children:[t,"%"]}),e("button",{type:"button",onClick:a,disabled:t>=200,"aria-label":"Perbesar tampilan",title:"Zoom In (+10%)",className:"p-1 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink cursor-pointer disabled:cursor-not-allowed transition-colors",children:e(Wa,{size:12})})]})}var h="p-1.5 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink transition-colors cursor-pointer disabled:cursor-not-allowed";function B(t){let a=[],{url:r,zoomLevel:l,copied:b,included:c}=t;if(t.viewportMode&&t.onChangeViewport){let{viewportMode:o,onChangeViewport:m,onSetZoom:p}=t;a.push({id:"viewport",actions:g.map((x)=>({label:x.label,icon:x.icon,onSelect:()=>m(x.id),active:o===x.id})),children:e(P,{viewportMode:o,onChangeViewport:m,zoomLevel:l,onSetZoom:p})})}if(a.push({id:"zoom",actions:[{label:"Zoom in (+10%)",icon:Wa,onSelect:t.onZoomIn,disabled:l>=200},{label:"Zoom out (-10%)",icon:Ka,onSelect:t.onZoomOut,disabled:l<=50},{label:"Reset zoom (100%)",icon:kt,onSelect:t.onResetZoom,active:l===100}],children:e(A,{zoomLevel:l,onZoomIn:t.onZoomIn,onZoomOut:t.onZoomOut,onResetZoom:t.onResetZoom})}),a.push({id:"include",actions:[{label:c?"Page context added to the draft":"Include this page in the chat draft",icon:Ta,onSelect:t.onIncludeInChat,disabled:!r}],children:e("button",{type:"button",onClick:t.onIncludeInChat,disabled:!r,"aria-label":"Include this page in the chat draft",title:c?"Page context added to the draft":"Include this page in the chat draft",className:h,children:c?e(f,{size:14,className:"text-success"}):e(Ta,{size:14})})}),t.annotate){let o=t.annotate;a.push({id:"annotate",actions:[{label:o.count>0?`${o.active?"Tutup mode anotasi":"Buka mode anotasi"} (${o.count})`:"Mark a part of the page, then send it to the chat",icon:w,onSelect:o.onToggle,active:o.active,disabled:!r}],children:e("button",{type:"button",onClick:o.onToggle,disabled:!r,"aria-label":"Page annotation mode","aria-pressed":o.active,title:o.active?"Tutup mode anotasi":o.count>0?`Anotasi (${o.count}) — buka lagi`:"Mark a part of the page, then send it to the chat",className:`${h} relative ${o.active?"bg-ink/10 text-ink":""}`,children:[e(w,{size:14}),o.count>0&&e("span",{className:"absolute -top-0.5 -right-0.5 min-w-[13px] h-[13px] px-0.5 rounded-full bg-error text-paper text-[10px] leading-[13px] font-mono text-center",children:o.count})]})})}if(a.push({id:"copy",actions:[{label:b?"Copied URL!":"Copy URL",icon:ae,onSelect:t.onCopy,disabled:!r}],children:e("button",{type:"button",onClick:t.onCopy,disabled:!r,"aria-label":"Salin URL",title:b?"Copied URL!":"Copy URL",className:h,children:b?e(f,{size:14,className:"text-success"}):e(ae,{size:14})})}),t.onReconnect){let o=t.onReconnect;a.push({id:"reconnect",actions:[{label:"Sambungkan ulang live view",icon:Ra,onSelect:o}],children:e("button",{type:"button",onClick:o,"aria-label":"Sambungkan ulang live view",title:"Reconnect live view",className:h,children:e(Ra,{size:14})})})}return a.push({id:"open-external",actions:[{label:t.openExternalLabel,icon:Ie,onSelect:t.onOpenExternal,disabled:!r}],children:e("button",{type:"button",onClick:t.onOpenExternal,disabled:!r,"aria-label":t.openExternalLabel,title:t.openExternalTitle,className:h,children:e(Ie,{size:14})})}),a}var V=108,te=280,ne=18,ie=140,re=36;function rd({url:t,statusDotClass:a,statusLabel:r,viewportMode:l,zoomLevel:b,onChangeViewport:c,onZoomIn:o,onZoomOut:m,onResetZoom:p,onSetZoom:x,annotate:D,onIncludeInChat:_,onOpenExternal:U,onReconnect:W,openExternalLabel:H,openExternalTitle:X,twoRows:k=!1,children:q}){let[F,T]=n(!1),[G,R]=n(!1),y=i(null),[u,I]=n(0),S=B({url:t,zoomLevel:b,copied:F,included:G,viewportMode:l,onChangeViewport:c,annotate:D,onReconnect:W,onIncludeInChat:()=>{_(),R(!0),setTimeout(()=>R(!1),2500)},onCopy:()=>{if(!t)return;navigator.clipboard.writeText(t).then(()=>{T(!0),setTimeout(()=>T(!1),2000)}).catch(()=>{})},onOpenExternal:U,onZoomIn:o,onZoomOut:m,onResetZoom:p,onSetZoom:x,openExternalLabel:H,openExternalTitle:X});K(()=>{let v=y.current;if(!v)return;I(v.clientWidth)}),K(()=>{let v=y.current;if(!v||typeof ResizeObserver>"u")return;let L=new ResizeObserver(()=>I(v.clientWidth));return L.observe(v),()=>L.disconnect()},[]);let M=u===0||u>=te,Z=M?u>0?Math.min(V,u*0.25):V:ne,z=k?u>0?u:void 0:u>0?Math.max(0,u-Z-ie-re):void 0,J=e("div",{className:"flex items-center space-x-1.5 flex-shrink-0 min-w-0",style:{maxWidth:`${Z}px`},title:r,children:[e("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${a}`}),M&&e("span",{className:"text-[10px] font-mono uppercase tracking-wide text-ink/60 truncate",children:r})]});return e("div",{ref:y,"data-browser-toolbar":"",className:`px-2.5 border-b border-ink/10 bg-paper flex flex-col gap-y-1 flex-shrink-0 select-none ${k?"py-1":"h-10 justify-center"}`,children:[e("div",{"data-toolbar-band":"address",className:"flex items-center gap-x-2 min-w-0",children:[J,e("div",{className:"flex flex-1 min-w-0 items-center",children:q}),!k&&e(ai,{clusters:S,available:z})]}),k&&e("div",{"data-toolbar-band":"controls",className:"flex items-center min-w-0",children:e(ai,{clusters:S,available:z})})]})}
2
2
  export{rd};