| 180 | `,backgroundSize:"100% 50%, 100% 50%",backgroundPosition:"0 0, 0 100%",backgroundRepeat:"no-repeat"};break;case"solid":S={backgroundColor:s||"#3b82f6"};break;case"gradient":t&&a?S={backgroundImage:a}:S={backgroundImage:"linear-gradient(135deg, rgba(255, 255, 196, 1.000) 0.000%, rgba(255, 97, 100, 1.000) 50.000%, rgba(176, 0, 18, 1.000) 100.000%)"};break;case"none":S={};break}return Ft.default.createElement("button",{key:b,onClick:()=>{if(c(b),b==="none")A("");else if(b==="solid"&&t)r(null),A(s);else if(b==="gradient"&&!t){let T={type:"linear",direction:"90deg",values:[{id:(0,R0.uniqueId)(),color:s||"#000000",position:0},{id:(0,R0.uniqueId)(),color:"#ffffff",position:100}]};r(T),i(T.values[0].id||null);let D=Zq(T);o(D),A(D)}},className:`mk-color-mode-button ${y?"active":""}`,style:S},b==="none"&&Ft.default.createElement("div",{className:"mk-color-none-icon"},Ft.default.createElement("svg",{width:"100%",height:"100%",viewBox:"0 0 20 20"},Ft.default.createElement("line",{x1:"2",y1:"2",x2:"18",y2:"18",stroke:"#ef4444",strokeWidth:"2"}))))})),u==="gradient"&&t&&Ft.default.createElement("div",{className:"mk-gradient-editor"},Ft.default.createElement("div",{className:"mk-gradient-controls-row",style:{marginBottom:"12px",display:"flex",alignItems:"center",gap:"12px"}},Ft.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},Ft.default.createElement(Gmt,{angle:parseInt(t.direction?.replace("deg","")||"90"),onChange:b=>{let y={...t};y.direction=`${b}deg`,r(y),g(y)},size:40})),Ft.default.createElement("div",{style:{display:"flex",gap:"4px",marginLeft:"auto"}},Ft.default.createElement("button",{onClick:()=>{let b={...t};b.values.push({id:(0,R0.uniqueId)(),color:s||"#ffffff",position:50}),b.values.sort((y,S)=>y.position-S.position),r(b),g(b)},style:{width:`${e$}px`,height:`${e$}px`,padding:"0",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"var(--mk-ui-background)",border:"1px solid var(--mk-ui-border)",borderRadius:"4px",cursor:"pointer",color:"var(--mk-ui-text-primary)"},title:"Add gradient stop"},Ft.default.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2"},Ft.default.createElement("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),Ft.default.createElement("line",{x1:"5",y1:"12",x2:"19",y2:"12"}))))),Ft.default.createElement("div",{className:"mk-gradient-preview",style:{background:`linear-gradient(to right, ${t.values.sort((b,y)=>b.position-y.position).map(b=>`${b.color} ${b.position}%`).join(", ")})`,position:"relative",height:"40px",borderRadius:"4px",margin:"8px 0",cursor:"pointer"},onClick:b=>{let y=b.currentTarget.getBoundingClientRect(),T=(b.clientX-y.left)/y.width*100,D=b.target.classList.contains("mk-gradient-stop"),k=10,M=t.values.some(E=>Math.abs(E.position-T)<=k);if(!D&&!M){let E={...t};E.values.push({id:(0,R0.uniqueId)(),color:"#ffffff",position:Math.max(0,Math.min(100,T))}),E.values.sort((O,P)=>O.position-P.position),r(E),g(E)}}},t.values.map((b,y)=>Ft.default.createElement("div",{key:`line-${b.id||y}`,style:{position:"absolute",left:`${b.position}%`,top:"0",bottom:"0",width:"1px",backgroundColor:"rgba(255, 255, 255, 0.5)",pointerEvents:"none",zIndex:1}})),t.values.map((b,y)=>Ft.default.createElement(Vmt,{key:b.id||y,stop:b,isSelected:n===b.id,onSelect:()=>b.id&&i(b.id),onMove:S=>{let T={...t},D=T.values.findIndex(k=>k.id===b.id);D>=0&&(T.values[D].position=S),r(T),g(T)}})))),(u==="solid"||u==="gradient")&&Ft.default.createElement("div",{className:"mk-color-canvas-section"},Ft.default.createElement("div",{className:"mk-color-canvas-wrapper"},Ft.default.createElement(Qmt,{hue:f,saturation:p,lightness:m,onChange:(b,y)=>{h(b),v(y);let T=`#${Qte(f/360,b/100,y/100).map(D=>Math.round(D).toString(16).padStart(2,"0")).join("")}`;x(T)},size:200})),Ft.default.createElement("div",{style:{display:"flex",justifyContent:"center",width:"100%"}},Ft.default.createElement(Wmt,{hue:f,onChange:b=>{d(b);let S=`#${Qte(b/360,p/100,m/100).map(T=>Math.round(T).toString(16).padStart(2,"0")).join("")}`;x(S)},width:200,height:20})),Ft.default.createElement("div",{className:"mk-color-current",style:{display:"flex",alignItems:"center",gap:"8px",width:"100%"}},Ft.default.createElement(LMe,{color:s,size:"large",onClick:()=>{}}),Ft.default.createElement("input",{type:"text",value:s,onChange:b=>{/^#[0-9A-F]{6}$/i.test(b.target.value)&&x(b.target.value)},className:"mk-color-hex-input",placeholder:"#000000",style:{flex:1,minWidth:0}})),u==="gradient"&&t&&n&&Ft.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px",width:"100%",marginTop:"8px"}},Ft.default.createElement("input",{type:"number",value:t.values.find(b=>b.id===n)?.position||0,onChange:b=>{let y=parseFloat(b.target.value);if(!isNaN(y)&&y>=0&&y<=100){let S={...t},T=S.values.findIndex(D=>D.id===n);T>=0&&(S.values[T].position=y,S.values.sort((D,k)=>D.position-k.position),r(S),g(S))}},min:"0",max:"100",step:"1",style:{flex:1,padding:"4px 8px",border:"1px solid var(--background-modifier-border)",borderRadius:"4px",fontSize:"12px",fontFamily:"monospace",minWidth:0},placeholder:"0",title:N.menu.stopPosition}),Ft.default.createElement("span",{style:{fontSize:"12px",color:"var(--text-muted)"}},"%"),Ft.default.createElement("button",{onClick:()=>{let b={...t};b.values=b.values.filter(y=>y.id!==n),b.values.length>0&&i(b.values[0].id),r(b),g(b)},disabled:t.values.length<=2,style:{width:`${e$}px`,height:`${e$}px`,padding:"0",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"var(--mk-ui-background)",border:"1px solid var(--mk-ui-border)",borderRadius:"4px",cursor:t.values.length<=2?"not-allowed":"pointer",color:t.values.length<=2?"var(--mk-ui-text-tertiary)":"var(--mk-ui-text-primary)",opacity:t.values.length<=2?.5:1},title:N.menu.removeSelectedGradientStop},Ft.default.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2"},Ft.default.createElement("line",{x1:"5",y1:"12",x2:"19",y2:"12"}))))),!e.hidePaletteSelector&&(u==="palettes"||u==="none")&&Ft.default.createElement(Ymt,{superstate:e.superstate,onColorSelect:b=>{b.startsWith("linear-gradient")||b.startsWith("radial-gradient")||b.startsWith("conic-gradient")?(o(b),A(b)):x(b)}}),!e.hidePaletteSelector&&u==="none"&&Ft.default.createElement("div",{className:"mk-color-none-display"},Ft.default.createElement("div",{className:"mk-color-none-text"},N.menu.noColor),Ft.default.createElement("div",{className:"mk-color-none-desc"},N.menu.thisElementWillHaveNoColorApplied)))},yo=(e,t,r,n,i,a,o,s)=>e.ui.openCustomMenu(t,Ft.default.createElement(Xmt,{superstate:e,color:n,saveValue:i,stayOpen:a,hidePaletteSelector:s}),{},r,"bottom");var Aa=(e,t,r,n,i,a,o,s)=>{let l=[...r.allSpaces(!0,s)].filter(u=>(i||u.type!="default")&&(!o||u.type=="tag")).map(u=>({name:u.name,value:u.path,icon:r.pathsIndex.get(u.path)?.label?.sticker,section:u.type=="tag"?"tag":u.type=="folder"?"folder":"",description:u.type=="tag"?u.name:(u.type=="folder",u.path)}));return r.ui.openMenu(e,{ui:r.ui,multi:!1,editable:a,addKeyword:"Create",value:[],options:l,sections:o?[]:[{name:N.buttons.tag,value:"tag"},{name:N.menu.folder,value:"folder"}],saveOptions:(u,c,f,d)=>{n(c[0],f,d)},placeholder:N.labels.spaceSelectPlaceholder,detail:!0,searchable:!0,showSections:!o,showAll:!0},t,"bottom")};var n$=ge(Me());var RMe=ge(Me());var qMe=(e,t,r)=>{let n=e.spacesIndex.get(t);hu(e,n.space,{...n.metadata,contexts:r})},Kmt=(e,t,r,n,i)=>{let a=t.spacesIndex.get(r),o=t.spaceManager.readTags(),s=async l=>{let u=Rm(l);qMe(t,a.path,[...a.metadata.contexts.filter(c=>c!=u),u])};return t.ui.openMenu(e,{ui:t.ui,multi:!1,editable:!0,value:[],options:o.map(l=>({name:l,value:l})),saveOptions:(l,u)=>s(u[0]),placeholder:N.labels.contextItemSelectPlaceholder,searchable:!0,showAll:!0},n,null,i)},Jmt=(e,t,r,n,i)=>{let a=[];a.push({name:N.buttons.addContext,icon:"ui//plus",type:6,onSubmenu:(s,l)=>Kmt(s,r,t,n,l)}),a.push(tr);let o=r.spacesIndex.get(t);return o.contexts.forEach(s=>{a.push({name:s,icon:"ui//tags",onClick:l=>{r.ui.openPath(ii(s))},onMoreOptions:l=>{let u=l.target.getBoundingClientRect(),c=[];return c.push({name:N.menu.deleteContext,icon:"ui//trash",onClick:f=>{qMe(r,o.path,o.contexts.filter(d=>d!=s))}}),r.ui.openMenu(u,{ui:r.ui,multi:!1,editable:!1,value:[],options:c,placeholder:N.labels.contextItemSelectPlaceholder,searchable:!1,showAll:!0},n)}})}),r.ui.openMenu(e,{ui:r.ui,multi:!1,editable:!1,value:[],options:a,placeholder:N.labels.contextItemSelectPlaceholder,searchable:!1,showAll:!0},n,null,i)},t$=(e,t,r,n)=>{let i=[{name:"Apply Tags",icon:"ui//tags",value:"apply-tags",onSubmenu:(a,o)=>Jmt(a,r.path,t,n,o)},{name:N.menu.setDefaultSticker,icon:"ui//sticker",value:"apply-all-sticker",onClick:()=>{t.ui.openPalette(RMe.default.createElement(Ea,{ui:t.ui,selectedSticker:a=>hu(t,r.space,{...r.metadata,defaultSticker:a})}),n)}}];return t.ui.openMenu(e,_t(t.ui,i),n)};var $Me=ge(On()),Z3=ge(Me());var Au=(e,t,r,n,i)=>{let a=[...r.pathsIndex.values()].filter(s=>!s.hidden).map(s=>({name:s.label.name,value:s.path,description:s.path,icon:s.label?.sticker,section:s.type})),o=Array.from(new Set(a.map(s=>s.section))).map(s=>({name:s,value:s}));return r.ui.openMenu(e,{ui:r.ui,multi:i?.multi,editable:!0,value:i?.value??[],options:a,saveOptions:(s,l)=>{i?.multi?n(l):n(l[0])},placeholder:N.labels.linkItemSelectPlaceholder,detail:!0,searchable:!0,showAll:!0,sections:o,showSections:!0,...i??{}},t)};var zMe=e=>{e.ui.openModal(N.labels.createSection,Z3.default.createElement(ga,{saveLabel:N.buttons.createFolder,value:"",saveValue:t=>{P0(e,e.pathsIndex.get(e.ui.activePath)).then(r=>{let n=e.pathsIndex.get(r?.path);n||(n=e.pathsIndex.get("/"));let i=t.replace(/\//g,""),a=n?.subtype=="folder"?n.path:n.parent?n.parent:"/",o=!a||a=="/"?i:a+"/"+i;if(i.length==0){e.ui.notify(N.notice.newSpaceName);return}if(e.spacesIndex.has(o)){e.ui.notify(N.notice.duplicateSpaceName);return}Uf(e,o,{})})}}),window)},dC=async(e,t,r,n)=>{let i=t;if(i?.path==Qv){e.ui.openModal("New Tag",Z3.default.createElement(ga,{value:"",saveLabel:N.labels.saveView,saveValue:a=>F3(e,a)}),r);return}if((!i||i.type=="tag")&&(i=await P0(e,e.pathsIndex.get(e.ui.activePath))),i?.metadata.template?.length>0){_3(e,i,i.metadata.template,n);return}else Xa(e,i,"md",null,!1,null,n)},r$=(e,t,r,n,i,a)=>{let o=[];if(n.type=="default")o.push({name:"New Tag",icon:"ui//tags",onClick:s=>{e.ui.openModal("New Tag",Z3.default.createElement(ga,{value:"",saveLabel:N.labels.saveView,saveValue:l=>F3(e,l)}),je(s.view.document))}});else if(o.push({name:N.labels.createNote,icon:"ui//edit",onClick:s=>{Xa(e,n,"md",e.settings.newNotePlaceholder,i)}}),o.push({name:N.buttons.createCanvas,icon:"ui//layout-dashboard",onClick:s=>{Xa(e,n,"canvas",null,i)}}),o.push({name:N.labels.createSection,icon:"ui//folder-plus",onClick:s=>{e.ui.openModal(N.labels.createSection,Z3.default.createElement(ga,{saveLabel:N.buttons.createFolder,value:"",saveValue:l=>{let u=e.pathsIndex.get(n?.path);u||(u=e.pathsIndex.get("/"));let c=l.replace(/\//g,""),f=u?.subtype=="folder"?u.path:u.parent?u.parent:"/",d=!f||f=="/"?c:f+"/"+c;if(c.length==0){e.ui.notify(N.notice.newSpaceName);return}if(e.spacesIndex.has(d)){e.ui.notify(N.notice.duplicateSpaceName);return}Uf(e,d,{})}}),je(s.view.document))}}),n.type=="folder"&&o.push({name:N.buttons.addIntoSpace,icon:"ui//pin",onClick:s=>{let l=s.target.getBoundingClientRect();Au(l,je(s.view.document),e,u=>{(0,$Me.isString)(u)&&Ng(e,n,u)}),s.stopPropagation()}}),n.templates.length>0){o.push(tr);for(let s of n.templates)o.push({name:s,icon:"ui//clipboard-pen",onClick:l=>{_3(e,n,s)}})}return e.ui.openMenu(t,_t(e.ui,o),r,"right")};var eM=(e,t,r,n,i,a)=>{let o=e.spacesIndex.get(t.path);if(!o)return;let s=[];s.push({name:N.menu.openFilePane,icon:"ui//go-to-file",onClick:()=>{e.ui.openPath(t.path,!0)}}),s.push(tr),s.push({name:N.menu.new,type:6,onSubmenu:u=>r$(e,u,n,o,!1,!0),icon:"ui//plus"}),s.push(tr),e.settings.spacesStickers&&(s.push({name:N.menu.changeColor,icon:"ui//palette",type:6,onSubmenu:u=>yo(e,u,n,"",c=>iy(e,o.path,c),!1,!0)}),s.push({name:N.buttons.changeIcon,icon:"ui//sticker",onClick:u=>{e.ui.openPalette(n$.default.createElement(Ea,{ui:e.ui,selectedSticker:c=>ch(e,o.path,c)}),n)}}),s.push({name:N.buttons.removeIcon,icon:"ui//file-minus",onClick:u=>{fC(e,o.path)}})),o.metadata?.sort&&(s.push(tr),s.push({name:N.menu.sortBy,icon:"ui//sort-desc",type:6,onSubmenu:u=>{let c=[];c.push({name:N.menu.groupSpaces,icon:"ui//arrow-up-down",value:o.metadata.sort.group==!0,type:3,onClick:y=>{Hf(e,o.path,{field:o.metadata.sort.field,asc:o.metadata.sort.asc,group:!o.metadata.sort.group,recursive:o.metadata.sort.recursive})}}),c.push(tr),c.push({name:N.menu.recursiveSort,icon:"ui//arrow-up-down",value:o.metadata.sort.recursive==!0,type:3,onClick:y=>{Hf(e,o.path,{field:o.metadata.sort.field,asc:o.metadata.sort.asc,group:o.metadata.sort.group,recursive:!o.metadata.sort.recursive})}}),c.push(tr);let f={field:"rank",asc:!0,group:o.metadata.sort.group,recursive:o.metadata.sort.recursive};c.push({name:N.menu.customSort,icon:"ui//arrow-up-down",value:o.metadata.sort.field==f.field&&o.metadata.sort.asc==f.asc,type:3,onClick:y=>{Hf(e,o.path,f)}}),c.push(tr);let d={field:"name",asc:!0,group:o.metadata.sort.group,recursive:o.metadata.sort.recursive};c.push({name:N.menu.fileNameSortAlphaAsc,icon:"ui//arrow-up-down",value:o.metadata.sort.field==d.field&&o.metadata.sort.asc==d.asc,type:3,onClick:y=>{Hf(e,o.path,d)}});let p={field:"name",asc:!1,group:o.metadata.sort.group,recursive:o.metadata.sort.recursive};c.push({name:N.menu.fileNameSortAlphaDesc,icon:"ui//arrow-up-down",value:o.metadata.sort.field==p.field&&o.metadata.sort.asc==p.asc,type:3,onClick:y=>{Hf(e,o.path,p)}}),c.push(tr);let h={field:"number",asc:!0,group:o.metadata.sort.group,recursive:o.metadata.sort.recursive};c.push({name:N.menu.fileNameSortNumericalAsc,icon:"ui//arrow-up-down",value:o.metadata.sort.field==h.field&&o.metadata.sort.asc==h.asc,type:3,onClick:y=>{Hf(e,o.path,h)}});let m={field:"number",asc:!1,group:o.metadata.sort.group,recursive:o.metadata.sort.recursive};c.push({name:N.menu.fileNameSortNumericalDesc,icon:"ui//arrow-up-down",value:o.metadata.sort.field==m.field&&o.metadata.sort.asc==m.asc,type:3,onClick:y=>{Hf(e,o.path,m)}}),c.push(tr);let v={field:"ctime",asc:!1,group:o.metadata.sort.group,recursive:o.metadata.sort.recursive};c.push({name:N.menu.createdTimeSortAsc,icon:"ui//arrow-up-down",value:o.metadata.sort.field==v.field&&o.metadata.sort.asc==v.asc,type:3,onClick:y=>{Hf(e,o.path,v)}});let A={field:"ctime",asc:!0,group:o.metadata.sort.group,recursive:o.metadata.sort.recursive};c.push({name:N.menu.createdTimeSortDesc,icon:"ui//arrow-up-down",value:o.metadata.sort.field==A.field&&o.metadata.sort.asc==A.asc,type:3,onClick:y=>{Hf(e,o.path,A)}}),c.push(tr);let x={field:"mtime",asc:!1,group:o.metadata.sort.group,recursive:o.metadata.sort.recursive};c.push({name:N.menu.modifiedTimeSortAsc,icon:"ui//arrow-up-down",value:o.metadata.sort.field==x.field&&o.metadata.sort.asc==x.asc,type:3,onClick:y=>{Hf(e,o.path,x)}});let g={field:"mtime",asc:!0,group:o.metadata.sort.group,recursive:o.metadata.sort.recursive};c.push({name:N.menu.modifiedTimeSortDesc,icon:"ui//arrow-up-down",value:o.metadata.sort.field==g.field&&o.metadata.sort.asc==g.asc,type:3,onClick:y=>{Hf(e,o.path,g)}}),c.push(tr);let w={field:"size",asc:!1,group:o.metadata.sort.group,recursive:o.metadata.sort.recursive};c.push({name:N.menu.sizeSortAsc,icon:"ui//arrow-up-down",value:o.metadata.sort.field==w.field&&o.metadata.sort.asc==w.asc,type:3,onClick:y=>{Hf(e,o.path,w)}});let b={field:"size",asc:!0,group:o.metadata.sort.group,recursive:o.metadata.sort.recursive};return c.push({name:N.menu.sizeSortDesc,icon:"ui//arrow-up-down",value:o.metadata.sort.field==b.field&&o.metadata.sort.asc==b.asc,type:3,onClick:y=>{Hf(e,o.path,b)}}),e.ui.openMenu(u,_t(e.ui,c),n)}})),s.push({name:N.menu.applyItems,icon:"ui//apply-items",value:"apply-all",type:6,onSubmenu:u=>t$(u,e,o,n)}),o.type!="default"&&(s.push(tr),s.push({name:N.menu.rename,icon:"ui//edit",onClick:u=>{e.ui.openModal(N.labels.rename,n$.default.createElement(ga,{saveLabel:N.buttons.rename,value:o.type=="tag"?au(o.name):o.name,saveValue:c=>ZS(e,o.path,c)}),n)}}));let l=e.spacesIndex.get(i);if(o.type=="folder"&&s.push({name:N.buttons.addToSpace,icon:"ui//pin",onClick:u=>{let c=u.target.getBoundingClientRect();Aa(c,n,e,f=>{let d=e.spacesIndex.get(f);d&&Y1(e,d,o.path,-1)},!0)}}),o.type=="folder"&&s.push({name:N.menu.moveFile,icon:"ui//paper-plane",onClick:u=>{let c=u.target.getBoundingClientRect();Aa(c,n,e,f=>{e.spaceManager.renameSpace(o.path,Jh(o.path,f))})}}),s.push({name:N.menu.duplicate,icon:"ui//documents",onClick:u=>{e.spaceManager.copyPath(t.path,`${t.parent}`)}}),l&&(l.type=="folder"||l.type=="vault")&&s.push({name:N.buttons.saveTemplate,icon:"ui//clipboard-add",onClick:u=>{X1(e,o.path,i)}}),e.ui.hasNativePathMenu(o.path)&&s.push({name:N.menu.openNativeMenu,icon:"ui//options",onClick:u=>{e.ui.nativePathMenu(u,o.path)}}),s.push(tr),Or(e.ui)||s.push({name:e.ui.getOS()=="mac"?N.menu.revealInDefault:N.menu.revealInExplorer,icon:"ui//arrow-up-right",onClick:u=>{e.ui.openPath(o.space.folderPath,"system")}}),s.push(tr),l&&(l.type=="folder"||l.type=="vault")&&i!=t.parent){let u=e.spacesIndex.get(i);u&&s.push({name:N.menu.removeFromSpace.replace("${1}",u.name),icon:"ui//pin-off",onClick:c=>{K1(e,u.path,[o.path])}})}return a&&s.push({name:N.menu.closeSpace,icon:"ui//close",onClick:u=>{a()}}),o.type=="folder"&&s.push({name:N.menu.hide,icon:"ui//eye-off",onClick:u=>{pP(e,o.path)}}),(o.type=="folder"||o.type=="tag")&&s.push({name:N.menu.delete,icon:"ui//trash",onClick:u=>{e.ui.openModal(N.labels.deleteSpace,n$.default.createElement(B0,{confirmAction:()=>wq(e,o.path),confirmLabel:N.buttons.delete,message:N.descriptions.deleteSpace}),n)}}),e.ui.openMenu(r,_t(e.ui,s),n),!1};var UMe=(e,t,r)=>{let n=t.map(a=>a.item.path),i=[];return i.push({name:N.menu.openFilePane,icon:"ui//go-to-file",onClick:a=>{n.forEach(o=>e.ui.openPath(o,!0))}}),e.settings.spacesStickers&&(i.push(tr),i.push({name:N.menu.changeColor,icon:"ui//palette",type:6,onSubmenu:a=>yo(e,a,je(r.view.document),"",o=>PMe(e,n,o),!1,!0)}),i.push({name:N.buttons.changeIcon,icon:"ui//sticker",onClick:a=>{e.ui.openPalette(tM.default.createElement(Ea,{ui:e.ui,selectedSticker:o=>jMe(e,n,o)}),je(a.view.document))}}),i.push({name:N.buttons.removeIcon,icon:"ui//file-minus",onClick:a=>{Jq(e,n)}})),i.push(tr),i.push({name:N.menu.moveFile,icon:"ui//paper-plane",onClick:a=>{let o=a.target.getBoundingClientRect();Aa(o,je(a.view.document),e,s=>{n.forEach(l=>{vde(e,l,s)})})}}),i.push({name:N.buttons.addToSpace,icon:"ui//pin",onClick:a=>{let o=a.target.getBoundingClientRect();Aa(o,je(a.view.document),e,s=>{cC(e,t.map(l=>l.path),s,-1,"link")},!0)}}),i.push(tr),i.push({name:N.menu.hide,icon:"ui//eye-off",onClick:a=>{Ade(e,n)}}),i.push({name:N.menu.delete,icon:"ui//trash",onClick:a=>{e.ui.openModal(N.labels.deleteFiles,tM.default.createElement(B0,{confirmAction:()=>{n.forEach(o=>{Zb(e,o)})},confirmLabel:N.buttons.delete,message:N.descriptions.deleteFiles.replace("${1}",n.length.toString())}),je(a.view.document))}}),e.ui.openMenu(r.target.getBoundingClientRect(),_t(e.ui,i),je(r.view.document)),!1},dh=(e,t,r,n,i,a,o)=>{let s=e.pathsIndex.get(t);if(s.type=="space"){eM(e,s,n,i,r,o);return}if(!s)return;let l=[];if(l.push({name:N.menu.openFilePane,icon:"ui//go-to-file",onClick:u=>{e.ui.openPath(t,!0)}}),l.push(tr),e.settings.spacesStickers&&(l.push(tr),l.push({name:N.menu.changeColor,icon:"ui//palette",type:6,onSubmenu:u=>yo(e,u,i,"",c=>iy(e,t,c),!1,!0)}),l.push({name:N.buttons.changeIcon,icon:"ui//sticker",onClick:u=>{e.ui.openPalette(tM.default.createElement(Ea,{ui:e.ui,selectedSticker:c=>fw(e,t,c)}),je(u.view.document))}}),l.push({name:N.buttons.removeIcon,icon:"ui//file-minus",onClick:u=>{fC(e,t)}})),l.push(tr),s.type=="file"&&s.subtype=="md"&&l.push({name:N.menu.changeToFolderNote,icon:"ui//file-plus-2",onClick:u=>{mP(e,t,!1)}}),l.push({name:N.menu.rename,icon:"ui//edit",onClick:u=>{e.ui.openModal(N.labels.rename,tM.default.createElement(ga,{saveLabel:N.buttons.rename,value:s.name,saveValue:c=>ZS(e,t,c)}),je(u.view.document))}}),l.push({name:N.buttons.addToSpace,icon:"ui//pin",onClick:u=>{let c=u.target.getBoundingClientRect();Aa(c,je(u.view.document),e,f=>{cC(e,[t],f,-1,"link")},!0)}}),l.push({name:N.menu.moveFile,icon:"ui//paper-plane",onClick:u=>{let c=u.target.getBoundingClientRect();Aa(c,je(u.view.document),e,f=>{let d=e.pathsIndex.get(t);e.spaceManager.renamePath(t,Jh(t,f))})}}),l.push({name:N.menu.duplicate,icon:"ui//documents",onClick:u=>{e.spaceManager.copyPath(t,`${s.parent}`,`${s.name}`)}}),l.push({name:N.buttons.saveTemplate,icon:"ui//clipboard-add",onClick:u=>{X1(e,t,r)}}),e.ui.hasNativePathMenu(t)&&l.push({name:N.menu.openNativeMenu,icon:"ui//options",onClick:u=>{e.ui.nativePathMenu(u,t)}}),l.push(tr),Or(e.ui)||(l.push({name:e.ui.getOS()=="mac"?N.menu.revealInDefault:N.menu.revealInExplorer,icon:"ui//arrow-up-right",onClick:u=>{e.ui.openPath(t,"system")}}),l.push(tr)),o&&l.push({name:N.menu.closeSpace,icon:"ui//close",onClick:u=>{o()}}),r&&r!=s.parent){let u=e.spacesIndex.get(r);u&&l.push({name:N.menu.removeFromSpace.replace("${1}",u.name),icon:"ui//pin-off",onClick:c=>{K1(e,u.path,[t])}})}return l.push({name:N.menu.hide,icon:"ui//eye-off",onClick:u=>{pP(e,t)}}),l.push({name:N.menu.delete,icon:"ui//trash",onClick:u=>{Zb(e,t)}}),e.ui.openMenu(n,_t(e.ui,l),i,a),!1};var Zmt={freq:{label:N.labels.frequency,type:"option",value:{required:!0,options:[{name:N.labels.yearly,value:"YEARLY"},{name:N.labels.monthly,value:"MONTHLY"},{name:N.labels.weekly,value:"WEEKLY"},{name:N.labels.daily,value:"DAILY"},{name:N.labels.hourly,value:"HOURLY"},{name:N.labels.minutely,value:"MINUTELY"},{name:N.labels.secondly,value:"SECONDLY"}]}},until:{label:N.labels.until,type:"date",value:{required:!0}},interval:{label:N.labels.interval,type:"number"},count:{label:N.aggregates.count,type:"number"},wkst:{label:"Week Start",type:"option",value:{options:[{name:N.labels.monday,value:"MO"},{name:N.labels.tuesday,value:"TU"},{name:N.labels.wednesday,value:"WE"},{name:N.labels.thursday,value:"TH"},{name:N.labels.friday,value:"FR"},{name:N.labels.saturday,value:"SA"},{name:N.labels.sunday,value:"SU"}]}},byweekday:{label:"By Weekday",type:"option-multi",value:{alias:"Repeat Event",options:[{name:N.labels.monday,value:"MO"},{name:N.labels.tuesday,value:"TU"},{name:N.labels.wednesday,value:"WE"},{name:N.labels.thursday,value:"TH"},{name:N.labels.friday,value:"FR"},{name:N.labels.saturday,value:"SA"},{name:N.labels.sunday,value:"SU"}]}}},pC={name:N.labels.repeat,type:"object",value:JSON.stringify({typeName:N.labels.repeat,type:Zmt})};var HMe=(e,t)=>{let r={};for(let n of t){let i=e.pathsIndex.get(n)?.metadata?.property;i&&Object.keys(i).forEach(a=>{r[a]=[...r[a]??[],JA(i[a],a)]})}return Object.keys(r).reduce((n,i)=>[...n,{name:i,type:r[i][0]}],[])};var Fn=ge(Me());var eht=0,rM=class{constructor(t,r){this.from=t,this.to=r}},Zn=class{constructor(t={}){this.id=eht++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=t.combine||null}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof t!="function"&&(t=vu.match(t)),r=>{let n=t(r);return n===void 0?null:[this,n]}}};Zn.closedBy=new Zn({deserialize:e=>e.split(" ")});Zn.openedBy=new Zn({deserialize:e=>e.split(" ")});Zn.group=new Zn({deserialize:e=>e.split(" ")});Zn.isolate=new Zn({deserialize:e=>{if(e&&e!="rtl"&&e!="ltr"&&e!="auto")throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}});Zn.contextHash=new Zn({perNode:!0});Zn.lookAhead=new Zn({perNode:!0});Zn.mounted=new Zn({perNode:!0});var pw=class{constructor(t,r,n,i=!1){this.tree=t,this.overlay=r,this.parser=n,this.bracketed=i}static get(t){return t&&t.props&&t.props[Zn.mounted.id]}},tht=Object.create(null),vu=class{constructor(t,r,n,i=0){this.name=t,this.props=r,this.id=n,this.flags=i}static define(t){let r=t.props&&t.props.length?Object.create(null):tht,n=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new vu(t.name||"",r,t.id,n);if(t.props){for(let a of t.props)if(Array.isArray(a)||(a=a(i)),a){if(a[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");r[a[0].id]=a[1]}}return i}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(Zn.group);return r?r.indexOf(t)>-1:!1}return this.id==t}static match(t){let r=Object.create(null);for(let n in t)for(let i of n.split(" "))r[i]=t[n];return n=>{for(let i=n.prop(Zn.group),a=-1;a<(i?i.length:0);a++){let o=r[a<0?n.name:i[a]];if(o)return o}}}};vu.none=new vu("",Object.create(null),0,8);var mC=class{constructor(t){this.types=t;for(let r=0;r<t.length;r++)if(t[r].id!=r)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let r=[];for(let n of this.types){let i=null;for(let a of t){let o=a(n);if(o){i||(i=Object.assign({},n.props));let s=o[1],l=o[0];l.combine&&l.id in i&&(s=l.combine(i[l.id],s)),i[l.id]=s}}r.push(i?new vu(n.name,i,n.id,n.flags):n)}return new mC(r)}},i$=new WeakMap,VMe=new WeakMap,es;(function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays",e[e.EnterBracketed=16]="EnterBracketed"})(es||(es={}));var ja=class{constructor(t,r,n,i,a){if(this.type=t,this.children=r,this.positions=n,this.length=i,this.props=null,a&&a.length){this.props=Object.create(null);for(let[o,s]of a)this.props[typeof o=="number"?o:o.id]=s}}toString(){let t=pw.get(this);if(t&&!t.overlay)return t.tree.toString();let r="";for(let n of this.children){let i=n.toString();i&&(r&&(r+=","),r+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(r.length?"("+r+")":""):r}cursor(t=0){return new aM(this.topNode,t)}cursorAt(t,r=0,n=0){let i=i$.get(this)||this.topNode,a=new aM(i);return a.moveTo(t,r),i$.set(this,a._tree),a}get topNode(){return new Qf(this,0,0,null)}resolve(t,r=0){let n=iM(i$.get(this)||this.topNode,t,r,!1);return i$.set(this,n),n}resolveInner(t,r=0){let n=iM(VMe.get(this)||this.topNode,t,r,!0);return VMe.set(this,n),n}resolveStack(t,r=0){return rht(this,t,r)}iterate(t){let{enter:r,leave:n,from:i=0,to:a=this.length}=t,o=t.mode||0,s=(o&es.IncludeAnonymous)>0;for(let l=this.cursor(o|es.IncludeAnonymous);;){let u=!1;if(l.from<=a&&l.to>=i&&(!s&&l.type.isAnonymous||r(l)!==!1)){if(l.firstChild())continue;u=!0}for(;u&&n&&(s||!l.type.isAnonymous)&&n(l),!l.nextSibling();){if(!l.parent())return;u=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}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:ere(vu.none,this.children,this.positions,0,this.children.length,0,this.length,(r,n,i)=>new ja(this.type,r,n,i,this.propValues),t.makeTree||((r,n,i)=>new ja(vu.none,r,n,i)))}static build(t){return nht(t)}};ja.empty=new ja(vu.none,[],[],0);var nM=class{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 nM(this.buffer,this.index)}},_g=class{constructor(t,r,n){this.buffer=t,this.length=r,this.set=n}get type(){return vu.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],n=this.buffer[t+3],i=this.set.types[r],a=i.name;if(/\W/.test(a)&&!i.isError&&(a=JSON.stringify(a)),t+=4,n==t)return a;let o=[];for(;t<n;)o.push(this.childString(t)),t=this.buffer[t+3];return a+"("+o.join(",")+")"}findChild(t,r,n,i,a){let{buffer:o}=this,s=-1;for(let l=t;l!=r&&!(QMe(a,i,o[l+1],o[l+2])&&(s=l,n>0));l=o[l+3]);return s}slice(t,r,n){let i=this.buffer,a=new Uint16Array(r-t),o=0;for(let s=t,l=0;s<r;){a[l++]=i[s++],a[l++]=i[s++]-n;let u=a[l++]=i[s++]-n;a[l++]=i[s++]-t,o=Math.max(o,u)}return new _g(a,o,this.set)}};function QMe(e,t,r,n){switch(e){case-2:return r<t;case-1:return n>=t&&r<t;case 0:return r<t&&n>t;case 1:return r<=t&&n>t;case 2:return n>t;case 4:return!0}}function iM(e,t,r,n){for(var i;e.from==e.to||(r<1?e.from>=t:e.from>t)||(r>-1?e.to<=t:e.to<t);){let o=!n&&e instanceof Qf&&e.index<0?null:e.parent;if(!o)return e;e=o}let a=n?0:es.IgnoreOverlays;if(n)for(let o=e,s=o.parent;s;o=s,s=o.parent)o instanceof Qf&&o.index<0&&((i=s.enter(t,r,a))===null||i===void 0?void 0:i.from)!=o.from&&(e=s);for(;;){let o=e.enter(t,r,a);if(!o)return e;e=o}}var o$=class{cursor(t=0){return new aM(this,t)}getChild(t,r=null,n=null){let i=GMe(this,t,r,n);return i.length?i[0]:null}getChildren(t,r=null,n=null){return GMe(this,t,r,n)}resolve(t,r=0){return iM(this,t,r,!1)}resolveInner(t,r=0){return iM(this,t,r,!0)}matchContext(t){return Yte(this.parent,t)}enterUnfinishedNodesBefore(t){let r=this.childBefore(t),n=this;for(;r;){let i=r.lastChild;if(!i||i.to!=r.to)break;i.type.isError&&i.from==i.to?(n=r,r=i.prevSibling):r=i}return n}get node(){return this}get next(){return this.parent}},Qf=class extends o${constructor(t,r,n,i){super(),this._tree=t,this.from=r,this.index=n,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,r,n,i,a=0){var o;for(let s=this;;){for(let{children:l,positions:u}=s._tree,c=r>0?l.length:-1;t!=c;t+=r){let f=l[t],d=u[t]+s.from;if(!(!(a&es.EnterBracketed&&f instanceof ja&&((o=pw.get(f))===null||o===void 0?void 0:o.overlay)===null&&(d>=n||d+f.length<=n))&&!QMe(i,n,d,d+f.length))){if(f instanceof _g){if(a&es.ExcludeBuffers)continue;let p=f.findChild(0,f.buffer.length,r,n-d,i);if(p>-1)return new Pg(new Xte(s,f,t,d),null,p)}else if(a&es.IncludeAnonymous||!f.type.isAnonymous||Zte(f)){let p;if(!(a&es.IgnoreMounts)&&(p=pw.get(f))&&!p.overlay)return new Qf(p.tree,d,t,s);let h=new Qf(f,d,t,s);return a&es.IncludeAnonymous||!h.type.isAnonymous?h:h.nextChild(r<0?f.children.length-1:0,r,n,i,a)}}}if(a&es.IncludeAnonymous||!s.type.isAnonymous||(s.index>=0?t=s.index+r:t=r<0?-1:s._parent._tree.children.length,s=s._parent,!s))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,n=0){let i;if(!(n&es.IgnoreOverlays)&&(i=pw.get(this._tree))&&i.overlay){let a=t-this.from,o=n&es.EnterBracketed&&i.bracketed;for(let{from:s,to:l}of i.overlay)if((r>0||o?s<=a:s<a)&&(r<0||o?l>=a:l>a))return new Qf(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,r,n)}nextSignificantParent(){let t=this;for(;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 GMe(e,t,r,n){let i=e.cursor(),a=[];if(!i.firstChild())return a;if(r!=null){for(let o=!1;!o;)if(o=i.type.is(r),!i.nextSibling())return a}for(;;){if(n!=null&&i.type.is(n))return a;if(i.type.is(t)&&a.push(i.node),!i.nextSibling())return n==null?a:[]}}function Yte(e,t,r=t.length-1){for(let n=e;r>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(t[r]&&t[r]!=n.name)return!1;r--}}return!0}var Xte=class{constructor(t,r,n,i){this.parent=t,this.buffer=r,this.index=n,this.start=i}},Pg=class extends o${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,n){super(),this.context=t,this._parent=r,this.index=n,this.type=t.buffer.set.types[t.buffer.buffer[n]]}child(t,r,n){let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],t,r-this.context.start,n);return a<0?null:new Pg(this.context,this,a)}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,n=0){if(n&es.ExcludeBuffers)return null;let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],r>0?1:-1,t-this.context.start,r);return a<0?null:new Pg(this.context,this,a)}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];return r<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new Pg(this.context,this._parent,r):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,r=this._parent?this._parent.index+4:0;return this.index==r?this.externalSibling(-1):new Pg(this.context,this._parent,t.findChild(r,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],r=[],{buffer:n}=this.context,i=this.index+4,a=n.buffer[this.index+3];if(a>i){let o=n.buffer[this.index+1];t.push(n.slice(i,a,o)),r.push(0)}return new ja(this.type,t,r,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function YMe(e){if(!e.length)return null;let t=0,r=e[0];for(let a=1;a<e.length;a++){let o=e[a];(o.from>r.from||o.to<r.to)&&(r=o,t=a)}let n=r instanceof Qf&&r.index<0?null:r.parent,i=e.slice();return n?i[t]=n:i.splice(t,1),new Kte(i,r)}var Kte=class{constructor(t,r){this.heads=t,this.node=r}get next(){return YMe(this.heads)}};function rht(e,t,r){let n=e.resolveInner(t,r),i=null;for(let a=n instanceof Qf?n:n.context.parent;a;a=a.parent)if(a.index<0){let o=a.parent;(i||(i=[n])).push(o.resolve(t,r)),a=o}else{let o=pw.get(a.tree);if(o&&o.overlay&&o.overlay[0].from<=t&&o.overlay[o.overlay.length-1].to>=t){let s=new Qf(o.tree,o.overlay[0].from+a.from,-1,a);(i||(i=[n])).push(iM(s,t,r,!1))}}return i?YMe(i):n}var aM=class{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&~es.EnterBracketed,t instanceof Qf)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let n=t._parent;n;n=n._parent)this.stack.unshift(n.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return t?(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0):!1}yieldBuf(t,r){this.index=t;let{start:n,buffer:i}=this.buffer;return this.type=r||i.set.types[i.buffer[t]],this.from=n+i.buffer[t+1],this.to=n+i.buffer[t+2],!0}yield(t){return t?t instanceof Qf?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,r,n){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,r,n,this.mode));let{buffer:i}=this.buffer,a=i.findChild(this.index+4,i.buffer[this.index+3],t,r-this.buffer.start,n);return a<0?!1:(this.stack.push(this.index),this.yieldBuf(a))}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,n=this.mode){return this.buffer?n&es.ExcludeBuffers?!1:this.enterChild(1,t,r):this.yield(this._tree.enter(t,r,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&es.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&es.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode)):!1;let{buffer:r}=this.buffer,n=this.stack.length-1;if(t<0){let i=n<0?0:this.stack[n]+4;if(this.index!=i)return this.yieldBuf(r.findChild(i,this.index,-1,0,4))}else{let i=r.buffer[this.index+3];if(i<(n<0?r.buffer.length:r.buffer[this.stack[n]+3]))return this.yieldBuf(i)}return n<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,n,{buffer:i}=this;if(i){if(t>0){if(this.index<i.buffer.buffer.length)return!1}else for(let a=0;a<this.index;a++)if(i.buffer.buffer[a+3]<this.index)return!1;({index:r,parent:n}=i)}else({index:r,_parent:n}=this._tree);for(;n;{index:r,_parent:n}=n)if(r>-1)for(let a=r+t,o=t<0?-1:n._tree.children.length;a!=o;a+=t){let s=n._tree.children[a];if(this.mode&es.IncludeAnonymous||s instanceof _g||!s.type.isAnonymous||Zte(s))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){for(;(this.from==this.to||(r<1?this.from>=t:this.from>t)||(r>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,r););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,r=null,n=0;if(t&&t.context==this.buffer){e:for(let i=this.index,a=this.stack.length;a>=0;){for(let o=t;o;o=o._parent)if(o.index==i){if(i==this.index)return o;r=o,n=a+1;break e}i=this.stack[--a]}}for(let i=n;i<this.stack.length;i++)r=new Pg(this.buffer,r,this.stack[i]);return this.bufferNode=new Pg(this.buffer,r,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,r){for(let n=0;;){let i=!1;if(this.type.isAnonymous||t(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&r&&r(this),i=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,i=!0}}}matchContext(t){if(!this.buffer)return Yte(this.node.parent,t);let{buffer:r}=this.buffer,{types:n}=r.set;for(let i=t.length-1,a=this.stack.length-1;i>=0;a--){if(a<0)return Yte(this._tree,t,i);let o=n[r.buffer[this.stack[a]]];if(!o.isAnonymous){if(t[i]&&t[i]!=o.name)return!1;i--}}return!0}};function Zte(e){return e.children.some(t=>t instanceof _g||!t.type.isAnonymous||Zte(t))}function nht(e){var t;let{buffer:r,nodeSet:n,maxBufferLength:i=1024,reused:a=[],minRepeatType:o=n.types.length}=e,s=Array.isArray(r)?new nM(r,r.length):r,l=n.types,u=0,c=0;function f(b,y,S,T,D,k){let{id:M,start:E,end:O,size:P}=s,_=c,B=u;if(P<0)if(s.next(),P==-1){let J=a[M];S.push(J),T.push(E-b);return}else if(P==-3){u=M;return}else if(P==-4){c=M;return}else throw new RangeError(`Unrecognized record size: ${P}`);let F=l[M],L,I,R=E-b;if(O-E<=i&&(I=v(s.pos-y,D))){let J=new Uint16Array(I.size-I.skip),Q=s.pos-I.size,q=J.length;for(;s.pos>Q;)q=A(I.start,J,q);L=new _g(J,O-I.start,n),R=I.start-b}else{let J=s.pos-P;s.next();let Q=[],q=[],ie=M>=o?M:-1,Ae=0,le=O;for(;s.pos>J;)ie>=0&&s.id==ie&&s.size>=0?(s.end<=le-i&&(h(Q,q,E,Ae,s.end,le,ie,_,B),Ae=Q.length,le=s.end),s.next()):k>2500?d(E,J,Q,q):f(E,J,Q,q,ie,k+1);if(ie>=0&&Ae>0&&Ae<Q.length&&h(Q,q,E,Ae,E,le,ie,_,B),Q.reverse(),q.reverse(),ie>-1&&Ae>0){let pe=p(F,B);L=ere(F,Q,q,0,Q.length,0,O-E,pe,pe)}else L=m(F,Q,q,O-E,_-O,B)}S.push(L),T.push(R)}function d(b,y,S,T){let D=[],k=0,M=-1;for(;s.pos>y;){let{id:E,start:O,end:P,size:_}=s;if(_>4)s.next();else{if(M>-1&&O<M)break;M<0&&(M=P-i),D.push(E,O,P),k++,s.next()}}if(k){let E=new Uint16Array(k*4),O=D[D.length-2];for(let P=D.length-3,_=0;P>=0;P-=3)E[_++]=D[P],E[_++]=D[P+1]-O,E[_++]=D[P+2]-O,E[_++]=_;S.push(new _g(E,D[2]-O,n)),T.push(O-b)}}function p(b,y){return(S,T,D)=>{let k=0,M=S.length-1,E,O;if(M>=0&&(E=S[M])instanceof ja){if(!M&&E.type==b&&E.length==D)return E;(O=E.prop(Zn.lookAhead))&&(k=T[M]+E.length+O)}return m(b,S,T,D,k,y)}}function h(b,y,S,T,D,k,M,E,O){let P=[],_=[];for(;b.length>T;)P.push(b.pop()),_.push(y.pop()+S-D);b.push(m(n.types[M],P,_,k-D,E-k,O)),y.push(D-S)}function m(b,y,S,T,D,k,M){if(k){let E=[Zn.contextHash,k];M=M?[E].concat(M):[E]}if(D>25){let E=[Zn.lookAhead,D];M=M?[E].concat(M):[E]}return new ja(b,y,S,T,M)}function v(b,y){let S=s.fork(),T=0,D=0,k=0,M=S.end-i,E={size:0,start:0,skip:0};e:for(let O=S.pos-b;S.pos>O;){let P=S.size;if(S.id==y&&P>=0){E.size=T,E.start=D,E.skip=k,k+=4,T+=4,S.next();continue}let _=S.pos-P;if(P<0||_<O||S.start<M)break;let B=S.id>=o?4:0,F=S.start;for(S.next();S.pos>_;){if(S.size<0)if(S.size==-3||S.size==-4)B+=4;else break e;else S.id>=o&&(B+=4);S.next()}D=F,T+=P,k+=B}return(y<0||T==b)&&(E.size=T,E.start=D,E.skip=k),E.size>4?E:void 0}function A(b,y,S){let{id:T,start:D,end:k,size:M}=s;if(s.next(),M>=0&&T<o){let E=S;if(M>4){let O=s.pos-(M-4);for(;s.pos>O;)S=A(b,y,S)}y[--S]=E,y[--S]=k-b,y[--S]=D-b,y[--S]=T}else M==-3?u=T:M==-4&&(c=T);return S}let x=[],g=[];for(;s.pos>0;)f(e.start||0,e.bufferStart||0,x,g,-1,0);let w=(t=e.length)!==null&&t!==void 0?t:x.length?g[0]+x[0].length:0;return new ja(l[e.topID],x.reverse(),g.reverse(),w)}var WMe=new WeakMap;function a$(e,t){if(!e.isAnonymous||t instanceof _g||t.type!=e)return 1;let r=WMe.get(t);if(r==null){r=1;for(let n of t.children){if(n.type!=e||!(n instanceof ja)){r=1;break}r+=a$(e,n)}WMe.set(t,r)}return r}function ere(e,t,r,n,i,a,o,s,l){let u=0;for(let h=n;h<i;h++)u+=a$(e,t[h]);let c=Math.ceil(u*1.5/8),f=[],d=[];function p(h,m,v,A,x){for(let g=v;g<A;){let w=g,b=m[g],y=a$(e,h[g]);for(g++;g<A;g++){let S=a$(e,h[g]);if(y+S>=c)break;y+=S}if(g==w+1){if(y>c){let S=h[w];p(S.children,S.positions,0,S.children.length,m[w]+x);continue}f.push(h[w])}else{let S=m[g-1]+h[g-1].length-b;f.push(ere(e,h,m,w,g,b,S,null,l))}d.push(b+x-a)}}return p(t,r,n,i,0),(s||l)(f,d,o)}var Ig=class{constructor(t,r,n,i,a=!1,o=!1){this.from=t,this.to=r,this.tree=n,this.offset=i,this.open=(a?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,r=[],n=!1){let i=[new Ig(0,t.length,t,0,!1,n)];for(let a of r)a.to>t.length&&i.push(a);return i}static applyChanges(t,r,n=128){if(!r.length)return t;let i=[],a=1,o=t.length?t[0]:null;for(let s=0,l=0,u=0;;s++){let c=s<r.length?r[s]:null,f=c?c.fromA:1e9;if(f-l>=n)for(;o&&o.from<f;){let d=o;if(l>=d.from||f<=d.to||u){let p=Math.max(d.from,l)-u,h=Math.min(d.to,f)-u;d=p>=h?null:new Ig(p,h,d.tree,d.offset+u,s>0,!!c)}if(d&&i.push(d),o.to>f)break;o=a<t.length?t[a++]:null}if(!c)break;l=c.toA,u=c.toA-c.toB}return i}},oM=class{startParse(t,r,n){return typeof t=="string"&&(t=new Jte(t)),n=n?n.length?n.map(i=>new rM(i.from,i.to)):[new rM(0,0)]:[new rM(0,t.length)],this.createParse(t,r||[],n)}parse(t,r,n){let i=this.startParse(t,r,n);for(;;){let a=i.advance();if(a)return a}}},Jte=class{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 aNr=new Zn({perNode:!0});var ei=require("@codemirror/state"),_n=require("@codemirror/view");var iht=0,Yf=class{constructor(t,r,n,i){this.name=t,this.set=r,this.base=n,this.modified=i,this.id=iht++}toString(){let{name:t}=this;for(let r of this.modified)r.name&&(t=`${r.name}(${t})`);return t}static define(t,r){let n=typeof t=="string"?t:"?";if(t instanceof Yf&&(r=t),r?.base)throw new Error("Can not derive from a modified tag");let i=new Yf(n,[],null,[]);if(i.set.push(i),r)for(let a of r.set)i.set.push(a);return i}static defineModifier(t){let r=new hC(t);return n=>n.modified.indexOf(r)>-1?n:hC.get(n.base||n,n.modified.concat(r).sort((i,a)=>i.id-a.id))}},aht=0,hC=class{constructor(t){this.name=t,this.instances=[],this.id=aht++}static get(t,r){if(!r.length)return t;let n=r[0].instances.find(s=>s.base==t&&oht(r,s.modified));if(n)return n;let i=[],a=new Yf(t.name,i,t,r);for(let s of r)s.instances.push(a);let o=sht(r);for(let s of t.set)if(!s.modified.length)for(let l of o)i.push(hC.get(s,l));return a}};function oht(e,t){return e.length==t.length&&e.every((r,n)=>r==t[n])}function sht(e){let t=[[]];for(let r=0;r<e.length;r++)for(let n=0,i=t.length;n<i;n++)t.push(t[n].concat(e[r]));return t.sort((r,n)=>n.length-r.length)}function JMe(e){let t=Object.create(null);for(let r in e){let n=e[r];Array.isArray(n)||(n=[n]);for(let i of r.split(" "))if(i){let a=[],o=2,s=i;for(let f=0;;){if(s=="..."&&f>0&&f+3==i.length){o=1;break}let d=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!d)throw new RangeError("Invalid path: "+i);if(a.push(d[0]=="*"?"":d[0][0]=='"'?JSON.parse(d[0]):d[0]),f+=d[0].length,f==i.length)break;let p=i[f++];if(f==i.length&&p=="!"){o=0;break}if(p!="/")throw new RangeError("Invalid path: "+i);s=i.slice(f)}let l=a.length-1,u=a[l];if(!u)throw new RangeError("Invalid path: "+i);let c=new hw(n,o,l>0?a.slice(0,l):null);t[u]=c.sort(t[u])}}return ZMe.add(t)}var ZMe=new Zn({combine(e,t){let r,n,i;for(;e||t;){if(!e||t&&e.depth>=t.depth?(i=t,t=t.next):(i=e,e=e.next),r&&r.mode==i.mode&&!i.context&&!r.context)continue;let a=new hw(i.tags,i.mode,i.context);r?r.next=a:n=a,r=a}return n}}),hw=class{constructor(t,r,n,i){this.tags=t,this.mode=r,this.context=n,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}};hw.empty=new hw([],2,null);function ire(e,t){let r=Object.create(null);for(let a of e)if(!Array.isArray(a.tag))r[a.tag.id]=a.class;else for(let o of a.tag)r[o.id]=a.class;let{scope:n,all:i=null}=t||{};return{style:a=>{let o=i;for(let s of a)for(let l of s.set){let u=r[l.id];if(u){o=o?o+" "+u:u;break}}return o},scope:n}}function lht(e,t){let r=null;for(let n of e){let i=n.style(t);i&&(r=r?r+" "+i:i)}return r}function eOe(e,t,r,n=0,i=e.length){let a=new rre(n,Array.isArray(t)?t:[t],r);a.highlightRange(e.cursor(),n,i,"",a.highlighters),a.flush(i)}var rre=class{constructor(t,r,n){this.at=t,this.highlighters=r,this.span=n,this.class=""}startSpan(t,r){r!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=r)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,r,n,i,a){let{type:o,from:s,to:l}=t;if(s>=n||l<=r)return;o.isTop&&(a=this.highlighters.filter(p=>!p.scope||p.scope(o)));let u=i,c=uht(t)||hw.empty,f=lht(a,c.tags);if(f&&(u&&(u+=" "),u+=f,c.mode==1&&(i+=(i?" ":"")+f)),this.startSpan(Math.max(r,s),u),c.opaque)return;let d=t.tree&&t.tree.prop(Zn.mounted);if(d&&d.overlay){let p=t.node.enter(d.overlay[0].from+s,1),h=this.highlighters.filter(v=>!v.scope||v.scope(d.tree.type)),m=t.firstChild();for(let v=0,A=s;;v++){let x=v<d.overlay.length?d.overlay[v]:null,g=x?x.from+s:l,w=Math.max(r,A),b=Math.min(n,g);if(w<b&&m)for(;t.from<b&&(this.highlightRange(t,w,b,i,a),this.startSpan(Math.min(b,t.to),u),!(t.to>=g||!t.nextSibling())););if(!x||g>n)break;A=x.to+s,A>r&&(this.highlightRange(p.cursor(),Math.max(r,x.from+s),Math.min(n,A),"",h),this.startSpan(Math.min(n,A),u))}m&&t.parent()}else if(t.firstChild()){d&&(i="");do if(!(t.to<=r)){if(t.from>=n)break;this.highlightRange(t,r,n,i,a),this.startSpan(Math.min(n,t.to),u)}while(t.nextSibling());t.parent()}}};function uht(e){let t=e.type.prop(ZMe);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var Ht=Yf.define,s$=Ht(),oy=Ht(),XMe=Ht(oy),KMe=Ht(oy),sy=Ht(),l$=Ht(sy),tre=Ht(sy),Rg=Ht(),mw=Ht(Rg),Bg=Ht(),Lg=Ht(),nre=Ht(),sM=Ht(nre),u$=Ht(),He={comment:s$,lineComment:Ht(s$),blockComment:Ht(s$),docComment:Ht(s$),name:oy,variableName:Ht(oy),typeName:XMe,tagName:Ht(XMe),propertyName:KMe,attributeName:Ht(KMe),className:Ht(oy),labelName:Ht(oy),namespace:Ht(oy),macroName:Ht(oy),literal:sy,string:l$,docString:Ht(l$),character:Ht(l$),attributeValue:Ht(l$),number:tre,integer:Ht(tre),float:Ht(tre),bool:Ht(sy),regexp:Ht(sy),escape:Ht(sy),color:Ht(sy),url:Ht(sy),keyword:Bg,self:Ht(Bg),null:Ht(Bg),atom:Ht(Bg),unit:Ht(Bg),modifier:Ht(Bg),operatorKeyword:Ht(Bg),controlKeyword:Ht(Bg),definitionKeyword:Ht(Bg),moduleKeyword:Ht(Bg),operator:Lg,derefOperator:Ht(Lg),arithmeticOperator:Ht(Lg),logicOperator:Ht(Lg),bitwiseOperator:Ht(Lg),compareOperator:Ht(Lg),updateOperator:Ht(Lg),definitionOperator:Ht(Lg),typeOperator:Ht(Lg),controlOperator:Ht(Lg),punctuation:nre,separator:Ht(nre),bracket:sM,angleBracket:Ht(sM),squareBracket:Ht(sM),paren:Ht(sM),brace:Ht(sM),content:Rg,heading:mw,heading1:Ht(mw),heading2:Ht(mw),heading3:Ht(mw),heading4:Ht(mw),heading5:Ht(mw),heading6:Ht(mw),contentSeparator:Ht(Rg),list:Ht(Rg),quote:Ht(Rg),emphasis:Ht(Rg),strong:Ht(Rg),link:Ht(Rg),monospace:Ht(Rg),strikethrough:Ht(Rg),inserted:Ht(),deleted:Ht(),changed:Ht(),invalid:Ht(),meta:u$,documentMeta:Ht(u$),annotation:Ht(u$),processingInstruction:Ht(u$),definition:Yf.defineModifier("definition"),constant:Yf.defineModifier("constant"),function:Yf.defineModifier("function"),standard:Yf.defineModifier("standard"),local:Yf.defineModifier("local"),special:Yf.defineModifier("special")};for(let e in He){let t=He[e];t instanceof Yf&&(t.name=e)}var lNr=ire([{tag:He.link,class:"tok-link"},{tag:He.heading,class:"tok-heading"},{tag:He.emphasis,class:"tok-emphasis"},{tag:He.strong,class:"tok-strong"},{tag:He.keyword,class:"tok-keyword"},{tag:He.atom,class:"tok-atom"},{tag:He.bool,class:"tok-bool"},{tag:He.url,class:"tok-url"},{tag:He.labelName,class:"tok-labelName"},{tag:He.inserted,class:"tok-inserted"},{tag:He.deleted,class:"tok-deleted"},{tag:He.literal,class:"tok-literal"},{tag:He.string,class:"tok-string"},{tag:He.number,class:"tok-number"},{tag:[He.regexp,He.escape,He.special(He.string)],class:"tok-string2"},{tag:He.variableName,class:"tok-variableName"},{tag:He.local(He.variableName),class:"tok-variableName tok-local"},{tag:He.definition(He.variableName),class:"tok-variableName tok-definition"},{tag:He.special(He.variableName),class:"tok-variableName2"},{tag:He.definition(He.propertyName),class:"tok-propertyName tok-definition"},{tag:He.typeName,class:"tok-typeName"},{tag:He.namespace,class:"tok-namespace"},{tag:He.className,class:"tok-className"},{tag:He.macroName,class:"tok-macroName"},{tag:He.propertyName,class:"tok-propertyName"},{tag:He.operator,class:"tok-operator"},{tag:He.comment,class:"tok-comment"},{tag:He.meta,class:"tok-meta"},{tag:He.invalid,class:"tok-invalid"},{tag:He.punctuation,class:"tok-punctuation"}]);var are="\u037C",tOe=typeof Symbol>"u"?"__"+are:Symbol.for(are),ore=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),rOe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{},ph=class{constructor(t,r){this.rules=[];let{finish:n}=r||{};function i(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function a(o,s,l,u){let c=[],f=/^@(\w+)\b/.exec(o[0]),d=f&&f[1]=="keyframes";if(f&&s==null)return l.push(o[0]+";");for(let p in s){let h=s[p];if(/&/.test(p))a(p.split(/,\s*/).map(m=>o.map(v=>m.replace(/&/,v))).reduce((m,v)=>m.concat(v)),h,l);else if(h&&typeof h=="object"){if(!f)throw new RangeError("The value of a property ("+p+") should be a primitive value.");a(i(p),h,c,d)}else h!=null&&c.push(p.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+h+";")}(c.length||d)&&l.push((n&&!f&&!u?o.map(n):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in t)a(i(o),t[o],this.rules)}getRules(){return this.rules.join(` |
| 182 | `;this.styleTag.textContent=o;let s=r.head||r;this.styleTag.parentNode!=s&&s.insertBefore(this.styleTag,s.firstChild)}}setNonce(t){this.styleTag&&this.styleTag.getAttribute("nonce")!=t&&this.styleTag.setAttribute("nonce",t)}};var lre,gC=new Zn;function cht(e){return ei.Facet.define({combine:e?t=>t.concat(e):void 0})}var fht=new Zn,Yd=class{constructor(t,r,n=[],i=""){this.data=t,this.name=i,ei.EditorState.prototype.hasOwnProperty("tree")||Object.defineProperty(ei.EditorState.prototype,"tree",{get(){return yu(this)}}),this.parser=r,this.extension=[cy.of(this),ei.EditorState.languageData.of((a,o,s)=>{let l=iOe(a,o,s),u=l.type.prop(gC);if(!u)return[];let c=a.facet(u),f=l.type.prop(fht);if(f){let d=l.resolve(o-l.from,s);for(let p of f)if(p.test(d,a)){let h=a.facet(p.facet);return p.type=="replace"?h:h.concat(c)}}return c})].concat(n)}isActiveAt(t,r,n=-1){return iOe(t,r,n).type.prop(gC)==this.data}findRegions(t){let r=t.facet(cy);if(r?.data==this.data)return[{from:0,to:t.doc.length}];if(!r||!r.allowsNesting)return[];let n=[],i=(a,o)=>{if(a.prop(gC)==this.data){n.push({from:o,to:o+a.length});return}let s=a.prop(Zn.mounted);if(s){if(s.tree.prop(gC)==this.data){if(s.overlay)for(let l of s.overlay)n.push({from:l.from+o,to:l.to+o});else n.push({from:o,to:o+a.length});return}else if(s.overlay){let l=n.length;if(i(s.tree,s.overlay[0].from+o),n.length>l)return}}for(let l=0;l<a.children.length;l++){let u=a.children[l];u instanceof ja&&i(u,a.positions[l]+o)}};return i(yu(t),0),n}get allowsNesting(){return!0}};Yd.setState=ei.StateEffect.define();function iOe(e,t,r){let n=e.facet(cy),i=yu(e).topNode;if(!n||n.allowsNesting)for(let a=i;a;a=a.enter(t,r,es.ExcludeBuffers|es.EnterBracketed))a.type.isTop&&(i=a);return i}function yu(e){let t=e.field(Yd.state,!1);return t?t.tree:ja.empty}var dre=class{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 n=this.cursorPos-this.string.length;return t<n||r>=this.cursorPos?this.doc.sliceString(t,r):this.string.slice(t-n,r-n)}},lM=null,ly=class{constructor(t,r,n=[],i,a,o,s,l){this.parser=t,this.state=r,this.fragments=n,this.tree=i,this.treeLen=a,this.viewport=o,this.skipped=s,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,r,n){return new ly(t,r,[],ja.empty,0,n,[],null)}startParse(){return this.parser.startParse(new dre(this.state.doc),this.fragments)}work(t,r){return r!=null&&r>=this.state.doc.length&&(r=void 0),this.tree!=ja.empty&&this.isDone(r??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof t=="number"){let i=Date.now()+t;t=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),r!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>r)&&r<this.state.doc.length&&this.parse.stopAt(r);;){let i=this.parse.advance();if(i)if(this.fragments=this.withoutTempSkipped(Ig.addTree(i,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(n=this.parse.stoppedAt)!==null&&n!==void 0?n:this.state.doc.length,this.tree=i,this.parse=null,this.treeLen<(r??this.state.doc.length))this.parse=this.startParse();else return!0;if(t())return!1}})}takeTree(){let t,r;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(r=this.parse.advance()););}),this.treeLen=t,this.tree=r,this.fragments=this.withoutTempSkipped(Ig.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let r=lM;lM=this;try{return t()}finally{lM=r}}withoutTempSkipped(t){for(let r;r=this.tempSkipped.pop();)t=aOe(t,r.from,r.to);return t}changes(t,r){let{fragments:n,tree:i,treeLen:a,viewport:o,skipped:s}=this;if(this.takeTree(),!t.empty){let l=[];if(t.iterChangedRanges((u,c,f,d)=>l.push({fromA:u,toA:c,fromB:f,toB:d})),n=Ig.applyChanges(n,l),i=ja.empty,a=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){s=[];for(let u of this.skipped){let c=t.mapPos(u.from,1),f=t.mapPos(u.to,-1);c<f&&s.push({from:c,to:f})}}}return new ly(this.parser,r,n,i,a,o,s,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 n=0;n<this.skipped.length;n++){let{from:i,to:a}=this.skipped[n];i<t.to&&a>t.from&&(this.fragments=aOe(this.fragments,i,a),this.skipped.splice(n--,1))}return this.skipped.length>=r?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,r){this.skipped.push({from:t,to:r})}static getSkippingParser(t){return new class extends oM{createParse(r,n,i){let a=i[0].from,o=i[i.length-1].to;return{parsedPos:a,advance(){let l=lM;if(l){for(let u of i)l.tempSkipped.push(u);t&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,t]):t)}return this.parsedPos=o,new ja(vu.none,[],[],o-a)},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 lM}};function aOe(e,t,r){return Ig.applyChanges(e,[{fromA:t,toA:r,fromB:t,toB:r}])}var uy=class{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),n=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),r.viewport.to);return r.work(20,n)||r.takeTree(),new uy(r)}static init(t){let r=Math.min(3e3,t.doc.length),n=ly.create(t.facet(cy).parser,t,{from:0,to:r});return n.work(20,r)||n.takeTree(),new uy(n)}};Yd.state=ei.StateField.define({create:uy.init,update(e,t){for(let r of t.effects)if(r.is(Yd.setState))return r.value;return t.startState.facet(cy)!=t.state.facet(cy)?uy.init(t.state):e.apply(t)}});var dOe=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(dOe=e=>{let t=-1,r=setTimeout(()=>{t=requestIdleCallback(e,{timeout:500-100})},100);return()=>t<0?clearTimeout(r):cancelIdleCallback(t)});var ure=typeof navigator<"u"&&((lre=navigator.scheduling)===null||lre===void 0?void 0:lre.isInputPending)?()=>navigator.scheduling.isInputPending():null,dht=_n.ViewPlugin.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let r=this.view.state.field(Yd.state).context;(r.updateViewport(t.view.viewport)||this.view.viewport.to>r.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(r)}scheduleWork(){if(this.working)return;let{state:t}=this.view,r=t.field(Yd.state);(r.tree!=r.context.tree||!r.context.isDone(t.doc.length))&&(this.working=dOe(this.work))}work(t){this.working=null;let r=Date.now();if(this.chunkEnd<r&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=r+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:i}}=this.view,a=n.field(Yd.state);if(a.tree==a.context.tree&&a.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!ure?Math.max(25,t.timeRemaining()-5):1e9),s=a.context.treeLen<i&&n.doc.length>i+1e3,l=a.context.work(()=>ure&&ure()||Date.now()>o,i+(s?0:1e5));this.chunkBudget-=Date.now()-r,(l||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:Yd.setState.of(new uy(a.context))})),this.chunkBudget>0&&!(l&&!s)&&this.scheduleWork(),this.checkAsyncSchedule(a.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(r=>(0,_n.logException)(this.view.state,r)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),cy=ei.Facet.define({combine(e){return e.length?e[0]:null},enables:e=>[Yd.state,dht,_n.EditorView.contentAttributes.compute([e],t=>{let r=t.facet(e);return r&&r.name?{"data-language":r.name}:{}})]});var pht=ei.Facet.define(),dM=ei.Facet.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(r=>r!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function f$(e){let t=e.facet(dM);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function mht(e,t){let r="",n=e.tabSize,i=e.facet(dM)[0];if(i==" "){for(;t>=n;)r+=" ",t-=n;i=" "}for(let a=0;a<t;a++)r+=i;return r}function hht(e,t){e instanceof ei.EditorState&&(e=new d$(e));for(let n of e.state.facet(pht)){let i=n(e,t);if(i!==void 0)return i}let r=yu(e.state);return r.length>=t?ght(e,r,t):null}var d$=class{constructor(t,r={}){this.state=t,this.options=r,this.unit=f$(t)}lineAt(t,r=1){let n=this.state.doc.lineAt(t),{simulateBreak:i,simulateDoubleBreak:a}=this.options;return i!=null&&i>=n.from&&i<=n.to?a&&i==t?{text:"",from:t}:(r<0?i<t:i<=t)?{text:n.text.slice(i-n.from),from:i}:{text:n.text.slice(0,i-n.from),from:n.from}:n}textAfterPos(t,r=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:n,from:i}=this.lineAt(t,r);return n.slice(t-i,Math.min(n.length,t+100-i))}column(t,r=1){let{text:n,from:i}=this.lineAt(t,r),a=this.countColumn(n,t-i),o=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return o>-1&&(a+=o-this.countColumn(n,n.search(/\S|$/))),a}countColumn(t,r=t.length){return(0,ei.countColumn)(t,this.state.tabSize,r)}lineIndent(t,r=1){let{text:n,from:i}=this.lineAt(t,r),a=this.options.overrideIndentation;if(a){let o=a(i);if(o>-1)return o}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},pOe=new Zn;function ght(e,t,r){let n=t.resolveStack(r),i=t.resolveInner(r,-1).resolve(r,0).enterUnfinishedNodesBefore(r);if(i!=n.node){let a=[];for(let o=i;o&&!(o.from<n.node.from||o.to>n.node.to||o.from==n.node.from&&o.type==n.node.type);o=o.parent)a.push(o);for(let o=a.length-1;o>=0;o--)n={node:a[o],next:n}}return mOe(n,e,r)}function mOe(e,t,r){for(let n=e;n;n=n.next){let i=vht(n.node);if(i)return i(cM.create(t,r,n))}return 0}function Aht(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function vht(e){let t=e.type.prop(pOe);if(t)return t;let r=e.firstChild,n;if(r&&(n=r.type.prop(Zn.closedBy))){let i=e.lastChild,a=i&&n.indexOf(i.name)>-1;return o=>wht(o,!0,1,void 0,a&&!Aht(o)?i.from:void 0)}return e.parent==null?yht:null}function yht(){return 0}var cM=class extends d${constructor(t,r,n){super(t.state,t.options),this.base=t,this.pos=r,this.context=n}get node(){return this.context.node}static create(t,r,n){return new cM(t,r,n)}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 n=t.resolve(r.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(bht(n,t))break;r=this.state.doc.lineAt(n.from)}return this.lineIndent(r.from)}continue(){return mOe(this.context.next,this.base,this.pos)}};function bht(e,t){for(let r=t;r;r=r.parent)if(e==r)return!0;return!1}function xht(e){let t=e.node,r=t.childAfter(t.from),n=t.lastChild;if(!r)return null;let i=e.options.simulateBreak,a=e.state.doc.lineAt(r.from),o=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let s=r.to;;){let l=t.childAfter(s);if(!l||l==n)return null;if(!l.type.isSkipped){if(l.from>=o)return null;let u=/^ */.exec(a.text.slice(r.to-a.from))[0].length;return{from:r.from,to:r.to+u}}s=l.to}}function wht(e,t,r,n,i){let a=e.textAfter,o=a.match(/^\s*/)[0].length,s=n&&a.slice(o,o+n.length)==n||i==e.pos+o,l=t?xht(e):null;return l?s?e.column(l.from):e.column(l.to):e.baseIndent+(s?0:e.unit*r)}var Sht=200;function hOe(){return ei.EditorState.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let r=e.newDoc,{head:n}=e.newSelection.main,i=r.lineAt(n);if(n>i.from+Sht)return e;let a=r.sliceString(i.from,n);if(!t.some(u=>u.test(a)))return e;let{state:o}=e,s=-1,l=[];for(let{head:u}of o.selection.ranges){let c=o.doc.lineAt(u);if(c.from==s)continue;s=c.from;let f=hht(o,c.from);if(f==null)continue;let d=/^\s*/.exec(c.text)[0],p=mht(o,f);d!=p&&l.push({from:c.from,to:c.from+d.length,insert:p})}return l.length?[e,{changes:l,sequential:!0}]:e})}var Eht=ei.Facet.define(),kht=new Zn;function Cht(e,t,r){let n=yu(e);if(n.length<r)return null;let i=n.resolveStack(r,1),a=null;for(let o=i;o;o=o.next){let s=o.node;if(s.to<=r||s.from>r)continue;if(a&&s.from<t)break;let l=s.type.prop(kht);if(l&&(s.to<n.length-50||n.length==e.doc.length||!Dht(s))){let u=l(s,e);u&&u.from<=r&&u.from>=t&&u.to>r&&(a=u)}}return a}function Dht(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function p$(e,t,r){for(let n of e.facet(Eht)){let i=n(e,t,r);if(i)return i}return Cht(e,t,r)}function gOe(e,t){let r=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);return r>=n?void 0:{from:r,to:n}}var A$=ei.StateEffect.define({map:gOe}),pM=ei.StateEffect.define({map:gOe});function AOe(e){let t=[];for(let{head:r}of e.state.selection.ranges)t.some(n=>n.from<=r&&n.to>=r)||t.push(e.lineBlockAt(r));return t}var gw=ei.StateField.define({create(){return _n.Decoration.none},update(e,t){t.isUserEvent("delete")&&t.changes.iterChangedRanges((r,n)=>e=oOe(e,r,n)),e=e.map(t.changes);for(let r of t.effects)if(r.is(A$)&&!Tht(e,r.value.from,r.value.to)){let{preparePlaceholder:n}=t.state.facet(yre),i=n?_n.Decoration.replace({widget:new pre(n(t.state,r.value))}):sOe;e=e.update({add:[i.range(r.value.from,r.value.to)]})}else r.is(pM)&&(e=e.update({filter:(n,i)=>r.value.from!=n||r.value.to!=i,filterFrom:r.value.from,filterTo:r.value.to}));return t.selection&&(e=oOe(e,t.selection.main.head)),e},provide:e=>_n.EditorView.decorations.from(e),toJSON(e,t){let r=[];return e.between(0,t.doc.length,(n,i)=>{r.push(n,i)}),r},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let r=0;r<e.length;){let n=e[r++],i=e[r++];if(typeof n!="number"||typeof i!="number")throw new RangeError("Invalid JSON for fold state");t.push(sOe.range(n,i))}return _n.Decoration.set(t,!0)}});function oOe(e,t,r=t){let n=!1;return e.between(t,r,(i,a)=>{i<r&&a>t&&(n=!0)}),n?e.update({filterFrom:t,filterTo:r,filter:(i,a)=>i>=r||a<=t}):e}function m$(e,t,r){var n;let i=null;return(n=e.field(gw,!1))===null||n===void 0||n.between(t,r,(a,o)=>{(!i||i.from>a)&&(i={from:a,to:o})}),i}function Tht(e,t,r){let n=!1;return e.between(t,t,(i,a)=>{i==t&&a==r&&(n=!0)}),n}function vOe(e,t){return e.field(gw,!1)?t:t.concat(ei.StateEffect.appendConfig.of(xOe()))}var Nht=e=>{for(let t of AOe(e)){let r=p$(e.state,t.from,t.to);if(r)return e.dispatch({effects:vOe(e.state,[A$.of(r),yOe(e,r)])}),!0}return!1},Mht=e=>{if(!e.state.field(gw,!1))return!1;let t=[];for(let r of AOe(e)){let n=m$(e.state,r.from,r.to);n&&t.push(pM.of(n),yOe(e,n,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function yOe(e,t,r=!0){let n=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return _n.EditorView.announce.of(`${e.state.phrase(r?"Folded lines":"Unfolded lines")} ${n} ${e.state.phrase("to")} ${i}.`)}var Oht=e=>{let{state:t}=e,r=[];for(let n=0;n<t.doc.length;){let i=e.lineBlockAt(n),a=p$(t,i.from,i.to);a&&r.push(A$.of(a)),n=(a?e.lineBlockAt(a.to):i).to+1}return r.length&&e.dispatch({effects:vOe(e.state,r)}),!!r.length},Fht=e=>{let t=e.state.field(gw,!1);if(!t||!t.size)return!1;let r=[];return t.between(0,e.state.doc.length,(n,i)=>{r.push(pM.of({from:n,to:i}))}),e.dispatch({effects:r}),!0};var bOe=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Nht},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Mht},{key:"Ctrl-Alt-[",run:Oht},{key:"Ctrl-Alt-]",run:Fht}],jht={placeholderDOM:null,preparePlaceholder:null,placeholderText:"\u2026"},yre=ei.Facet.define({combine(e){return(0,ei.combineConfig)(e,jht)}});function xOe(e){let t=[gw,_ht];return e&&t.push(yre.of(e)),t}function wOe(e,t){let{state:r}=e,n=r.facet(yre),i=o=>{let s=e.lineBlockAt(e.posAtDOM(o.target)),l=m$(e.state,s.from,s.to);l&&e.dispatch({effects:pM.of(l)}),o.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(e,i,t);let a=document.createElement("span");return a.textContent=n.placeholderText,a.setAttribute("aria-label",r.phrase("folded code")),a.title=r.phrase("unfold"),a.className="cm-foldPlaceholder",a.onclick=i,a}var sOe=_n.Decoration.replace({widget:new class extends _n.WidgetType{toDOM(e){return wOe(e,null)}}}),pre=class extends _n.WidgetType{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return wOe(t,this.value)}},Pht={openText:"\u2304",closedText:"\u203A",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},uM=class extends _n.GutterMarker{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 SOe(e={}){let t={...Pht,...e},r=new uM(t,!0),n=new uM(t,!1),i=_n.ViewPlugin.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(cy)!=o.state.facet(cy)||o.startState.field(gw,!1)!=o.state.field(gw,!1)||yu(o.startState)!=yu(o.state)||t.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let s=new ei.RangeSetBuilder;for(let l of o.viewportLineBlocks){let u=m$(o.state,l.from,l.to)?n:p$(o.state,l.from,l.to)?r:null;u&&s.add(l.from,l.from,u)}return s.finish()}}),{domEventHandlers:a}=t;return[i,(0,_n.gutter)({class:"cm-foldGutter",markers(o){var s;return((s=o.plugin(i))===null||s===void 0?void 0:s.markers)||ei.RangeSet.empty},initialSpacer(){return new uM(t,!1)},domEventHandlers:{...a,click:(o,s,l)=>{if(a.click&&a.click(o,s,l))return!0;let u=m$(o.state,s.from,s.to);if(u)return o.dispatch({effects:pM.of(u)}),!0;let c=p$(o.state,s.from,s.to);return c?(o.dispatch({effects:A$.of(c)}),!0):!1}}}),xOe()]}var _ht=_n.EditorView.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"}}),qg=class{constructor(t,r){this.specs=t;let n;function i(s){let l=ph.newName();return(n||(n=Object.create(null)))["."+l]=s,l}let a=typeof r.all=="string"?r.all:r.all?i(r.all):void 0,o=r.scope;this.scope=o instanceof Yd?s=>s.prop(gC)==o.data:o?s=>s==o:void 0,this.style=ire(t.map(s=>({tag:s.tag,class:s.class||i(Object.assign({},s,{tag:null}))})),{all:a}).style,this.module=n?new ph(n):null,this.themeType=r.themeType}static define(t,r){return new qg(t,r||{})}},mre=ei.Facet.define(),EOe=ei.Facet.define({combine(e){return e.length?[e[0]]:null}});function cre(e){let t=e.facet(mre);return t.length?t:e.facet(EOe)}function Aw(e,t){let r=[Iht],n;return e instanceof qg&&(e.module&&r.push(_n.EditorView.styleModule.of(e.module)),n=e.themeType),t?.fallback?r.push(EOe.of(e)):n?r.push(mre.computeN([_n.EditorView.darkTheme],i=>i.facet(_n.EditorView.darkTheme)==(n=="dark")?[e]:[])):r.push(mre.of(e)),r}var hre=class{constructor(t){this.markCache=Object.create(null),this.tree=yu(t.state),this.decorations=this.buildDeco(t,cre(t.state)),this.decoratedTo=t.viewport.to}update(t){let r=yu(t.state),n=cre(t.state),i=n!=cre(t.startState),{viewport:a}=t.view,o=t.changes.mapPos(this.decoratedTo,1);r.length<a.to&&!i&&r.type==this.tree.type&&o>=a.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=o):(r!=this.tree||t.viewportChanged||i)&&(this.tree=r,this.decorations=this.buildDeco(t.view,n),this.decoratedTo=a.to)}buildDeco(t,r){if(!r||!this.tree.length)return _n.Decoration.none;let n=new ei.RangeSetBuilder;for(let{from:i,to:a}of t.visibleRanges)eOe(this.tree,r,(o,s,l)=>{n.add(o,s,this.markCache[l]||(this.markCache[l]=_n.Decoration.mark({class:l})))},i,a);return n.finish()}},Iht=ei.Prec.high(_n.ViewPlugin.fromClass(hre,{decorations:e=>e.decorations})),bre=qg.define([{tag:He.meta,color:"#404740"},{tag:He.link,textDecoration:"underline"},{tag:He.heading,textDecoration:"underline",fontWeight:"bold"},{tag:He.emphasis,fontStyle:"italic"},{tag:He.strong,fontWeight:"bold"},{tag:He.strikethrough,textDecoration:"line-through"},{tag:He.keyword,color:"#708"},{tag:[He.atom,He.bool,He.url,He.contentSeparator,He.labelName],color:"#219"},{tag:[He.literal,He.inserted],color:"#164"},{tag:[He.string,He.deleted],color:"#a11"},{tag:[He.regexp,He.escape,He.special(He.string)],color:"#e40"},{tag:He.definition(He.variableName),color:"#00f"},{tag:He.local(He.variableName),color:"#30a"},{tag:[He.typeName,He.namespace],color:"#085"},{tag:He.className,color:"#167"},{tag:[He.special(He.variableName),He.macroName],color:"#256"},{tag:He.definition(He.propertyName),color:"#00c"},{tag:He.comment,color:"#940"},{tag:He.invalid,color:"#f00"}]),Bht=_n.EditorView.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),kOe=1e4,COe="()[]{}",DOe=ei.Facet.define({combine(e){return(0,ei.combineConfig)(e,{afterCursor:!0,brackets:COe,maxScanDistance:kOe,renderMatch:qht})}}),Lht=_n.Decoration.mark({class:"cm-matchingBracket"}),Rht=_n.Decoration.mark({class:"cm-nonmatchingBracket"});function qht(e){let t=[],r=e.matched?Lht:Rht;return t.push(r.range(e.start.from,e.start.to)),e.end&&t.push(r.range(e.end.from,e.end.to)),t}var $ht=ei.StateField.define({create(){return _n.Decoration.none},update(e,t){if(!t.docChanged&&!t.selection)return e;let r=[],n=t.state.facet(DOe);for(let i of t.state.selection.ranges){if(!i.empty)continue;let a=c$(t.state,i.head,-1,n)||i.head>0&&c$(t.state,i.head-1,1,n)||n.afterCursor&&(c$(t.state,i.head,1,n)||i.head<t.state.doc.length&&c$(t.state,i.head+1,-1,n));a&&(r=r.concat(n.renderMatch(a,t.state)))}return _n.Decoration.set(r,!0)},provide:e=>_n.EditorView.decorations.from(e)}),zht=[$ht,Bht];function TOe(e={}){return[DOe.of(e),zht]}var Uht=new Zn;function gre(e,t,r){let n=e.prop(t<0?Zn.openedBy:Zn.closedBy);if(n)return n;if(e.name.length==1){let i=r.indexOf(e.name);if(i>-1&&i%2==(t<0?1:0))return[r[i+t]]}return null}function Are(e){let t=e.type.prop(Uht);return t?t(e.node):e}function c$(e,t,r,n={}){let i=n.maxScanDistance||kOe,a=n.brackets||COe,o=yu(e),s=o.resolveInner(t,r);for(let l=s;l;l=l.parent){let u=gre(l.type,r,a);if(u&&l.from<l.to){let c=Are(l);if(c&&(r>0?t>=c.from&&t<c.to:t>c.from&&t<=c.to))return Hht(e,t,r,l,c,u,a)}}return Vht(e,t,r,o,s.type,i,a)}function Hht(e,t,r,n,i,a,o){let s=n.parent,l={from:i.from,to:i.to},u=0,c=s?.cursor();if(c&&(r<0?c.childBefore(n.from):c.childAfter(n.to)))do if(r<0?c.to<=n.from:c.from>=n.to){if(u==0&&a.indexOf(c.type.name)>-1&&c.from<c.to){let f=Are(c);return{start:l,end:f?{from:f.from,to:f.to}:void 0,matched:!0}}else if(gre(c.type,r,o))u++;else if(gre(c.type,-r,o)){if(u==0){let f=Are(c);return{start:l,end:f&&f.from<f.to?{from:f.from,to:f.to}:void 0,matched:!1}}u--}}while(r<0?c.prevSibling():c.nextSibling());return{start:l,matched:!1}}function Vht(e,t,r,n,i,a,o){let s=r<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),l=o.indexOf(s);if(l<0||l%2==0!=r>0)return null;let u={from:r<0?t-1:t,to:r>0?t+1:t},c=e.doc.iterRange(t,r>0?e.doc.length:0),f=0;for(let d=0;!c.next().done&&d<=a;){let p=c.value;r<0&&(d+=p.length);let h=t+d*r;for(let m=r>0?0:p.length-1,v=r>0?p.length:-1;m!=v;m+=r){let A=o.indexOf(p[m]);if(!(A<0||n.resolveInner(h+m,1).type!=i))if(A%2==0==r>0)f++;else{if(f==1)return{start:u,end:{from:h+m,to:h+m+1},matched:A>>1==l>>1};f--}}r>0&&(d+=p.length)}return c.done?{start:u,matched:!1}:null}function lOe(e,t,r,n=0,i=0){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));let a=i;for(let o=n;o<t;o++)e.charCodeAt(o)==9?a+=r-a%r:a++;return a}var h$=class{constructor(t,r,n,i){this.string=t,this.tabSize=r,this.indentUnit=n,this.overrideIndent=i,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),n;if(typeof t=="string"?n=r==t:n=r&&(t instanceof RegExp?t.test(r):t(r)),n)return++this.pos,r}eatWhile(t){let r=this.pos;for(;this.eat(t););return this.pos>r}eatSpace(){let t=this.pos;for(;/[\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(){return this.lastColumnPos<this.start&&(this.lastColumnValue=lOe(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var t;return(t=this.overrideIndent)!==null&&t!==void 0?t:lOe(this.string,null,this.tabSize)}match(t,r,n){if(typeof t=="string"){let i=o=>n?o.toLowerCase():o,a=this.string.substr(this.pos,t.length);return i(a)==i(t)?(r!==!1&&(this.pos+=t.length),!0):null}else{let i=this.string.slice(this.pos).match(t);return i&&i.index>0?null:(i&&r!==!1&&(this.pos+=i[0].length),i)}}current(){return this.string.slice(this.start,this.pos)}};function Ght(e){return{name:e.name||"",token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||Wht,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||wre,mergeTokens:e.mergeTokens!==!1}}function Wht(e){if(typeof e!="object")return e;let t={};for(let r in e){let n=e[r];t[r]=n instanceof Array?n.slice():n}return t}var uOe=new WeakMap,AC=class extends Yd{constructor(t){let r=cht(t.languageData),n=Ght(t),i,a=new class extends oM{createParse(o,s,l){return new vre(i,o,s,l)}};super(r,a,[],t.name),this.topNode=Kht(r,this),i=this,this.streamParser=n,this.stateAfter=new Zn({perNode:!0}),this.tokenTable=t.tokenTable?new g$(n.tokenTable):Xht}static define(t){return new AC(t)}getIndent(t){let r,{overrideIndentation:n}=t.options;n&&(r=uOe.get(t.state),r!=null&&r<t.pos-1e4&&(r=void 0));let i=xre(this,t.node.tree,t.node.from,t.node.from,r??t.pos),a,o;if(i?(o=i.state,a=i.pos+1):(o=this.streamParser.startState(t.unit),a=t.node.from),t.pos-a>1e4)return null;for(;a<t.pos;){let l=t.state.doc.lineAt(a),u=Math.min(t.pos,l.to);if(l.length){let c=n?n(l.from):-1,f=new h$(l.text,t.state.tabSize,t.unit,c<0?void 0:c);for(;f.pos<u-l.from;)MOe(this.streamParser.token,f,o)}else this.streamParser.blankLine(o,t.unit);if(u==t.pos)break;a=l.to+1}let s=t.lineAt(t.pos);return n&&r==null&&uOe.set(t.state,s.from),this.streamParser.indent(o,/^\s*(.*)/.exec(s.text)[1],t)}get allowsNesting(){return!1}};function xre(e,t,r,n,i){let a=r>=n&&r+t.length<=i&&t.prop(e.stateAfter);if(a)return{state:e.streamParser.copyState(a),pos:r+t.length};for(let o=t.children.length-1;o>=0;o--){let s=t.children[o],l=r+t.positions[o],u=s instanceof ja&&l<i&&xre(e,s,l,n,i);if(u)return u}return null}function NOe(e,t,r,n,i){if(i&&r<=0&&n>=t.length)return t;!i&&r==0&&t.type==e.topNode&&(i=!0);for(let a=t.children.length-1;a>=0;a--){let o=t.positions[a],s=t.children[a],l;if(o<n&&s instanceof ja){if(!(l=NOe(e,s,r-o,n-o,i)))break;return i?new ja(t.type,t.children.slice(0,a).concat(l),t.positions.slice(0,a+1),o+l.length):l}}return null}function Qht(e,t,r,n,i){for(let a of t){let o=a.from+(a.openStart?25:0),s=a.to-(a.openEnd?25:0),l=o<=r&&s>r&&xre(e,a.tree,0-a.offset,r,s),u;if(l&&l.pos<=n&&(u=NOe(e,a.tree,r+a.offset,l.pos+a.offset,!1)))return{state:l.state,tree:u}}return{state:e.streamParser.startState(i?f$(i):4),tree:ja.empty}}var vre=class{constructor(t,r,n,i){this.lang=t,this.input=r,this.fragments=n,this.ranges=i,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=i[i.length-1].to;let a=ly.get(),o=i[0].from,{state:s,tree:l}=Qht(t,n,o,this.to,a?.state);this.state=s,this.parsedPos=this.chunkStart=o+l.length;for(let u=0;u<l.children.length;u++)this.chunks.push(l.children[u]),this.chunkPos.push(l.positions[u]);a&&this.parsedPos<a.viewport.from-1e5&&i.some(u=>u.from<=a.viewport.from&&u.to>=a.viewport.from)&&(this.state=this.lang.streamParser.startState(f$(a.state)),a.skipUntilInView(this.parsedPos,a.viewport.from),this.parsedPos=a.viewport.from),this.moveRangeIndex()}advance(){let t=ly.get(),r=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),n=Math.min(r,this.chunkStart+512);for(t&&(n=Math.min(n,t.viewport.to));this.parsedPos<n;)this.parseLine(t);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=r?this.finish():t&&this.parsedPos>=t.viewport.to?(t.skipUntilInView(this.parsedPos,r),this.finish()):null}stopAt(t){this.stoppedAt=t}lineAfter(t){let r=this.input.chunk(t);if(this.input.lineChunks)r==` |