import{ref as g}from"vue";import{warning as h}from"../../../vc-util/warning.mjs";function d(n,u){const o=g(null);function c(){try{const{selectionStart:e,selectionEnd:r,value:s}=n.value,a=s.substring(0,e),t=s.substring(r);o.value={start:e,end:r,value:s,beforeTxt:a,afterTxt:t}}catch{}}function i(){if(n.value&&o.value&&u.value)try{const{value:e}=n.value,{beforeTxt:r,afterTxt:s,start:a}=o.value;let t=e.length;if(e.endsWith(s))t=e.length-o.value.afterTxt.length;else if(e.startsWith(r))t=r.length;else{const f=r[a-1],l=e.indexOf(f,a-1);l!==-1&&(t=l+1)}n.value.setSelectionRange(t,t)}catch(e){h(!1,`Something warning of cursor restore. Please fire issue about this: ${e.message}`)}}return[c,i]}export{d as default};
