import{a as e}from"./XcWejFm_.js";import{T as t}from"./uBgoVlsx.js";function n(n){let{state:r}=n,i=r.selection.main;if(r.selection.ranges.length!==1||!i.empty)return!1;let a=i.head,o=r.doc.lineAt(a);if(o.number===1)return!1;let s=t(r),c=null;for(let e=s.resolveInner(a,1);e;e=e.parent){if(e.name===`ListItem`){c=e;break}if(e.name===`Document`)break}if(!c)return!1;let l=c.parent;if(!l||l.name!==`OrderedList`&&l.name!==`BulletList`)return!1;let u=c.getChild(`ListMark`);if(!u||r.doc.lineAt(u.from).number!==o.number||a>u.from)return!1;let d=u.to;for(;d<o.to&&r.doc.sliceString(d,d+1)===` `;)d++;let f=r.doc.line(o.number-1);return n.dispatch(r.update({changes:{from:f.to,to:d},selection:e.cursor(f.to),userEvent:`delete`,scrollIntoView:!0})),!0}export{n as mergeListItemBackward};