import{n as e}from"./BNTlsKDJ.js";var t=e({wrapSelection:()=>n});function n(e,t,n){let{from:r,to:i}=e.state.selection.main,a=e.state.doc,o=r-t.length,s=i+n.length;if(o>=0&&s<=a.length){let c=a.sliceString(o,r),l=a.sliceString(i,s);if(c===t&&l===n){e.dispatch({changes:[{from:o,to:r,insert:``},{from:i,to:s,insert:``}],selection:{anchor:o,head:i-t.length}});return}}let c=a.sliceString(r,i);if(c.startsWith(t)&&c.endsWith(n)&&c.length>=t.length+n.length){let a=c.slice(t.length,c.length-n.length);e.dispatch({changes:{from:r,to:i,insert:a},selection:{anchor:r,head:r+a.length}});return}e.dispatch({changes:{from:r,to:i,insert:`${t}${c}${n}`},selection:{anchor:r+t.length,head:i+t.length}})}export{n,t};