import{n as e}from"./BNTlsKDJ.js";import{a as t,c as n,l as r,s as i}from"./CI0x_Zvz2.js";var a=e({resolveAnchor:()=>l,serializeAnchor:()=>c});function o(e){if(typeof Buffer<`u`)return Buffer.from(e).toString(`base64`);let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function s(e){if(typeof Buffer<`u`){let t=Buffer.from(e,`base64`);return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function c(e,t,n){let a=i(e,t),s=i(e,n),c=r(a),l=r(s),u=new Uint8Array(2+c.length+l.length),d=c.length;u[0]=d>>8&255,u[1]=d&255,u.set(c,2),u.set(l,2+d);let f=e.toString().slice(t,n).slice(0,256);return{relpos:o(u),quote:f}}function l(e,r,i,a){try{let o=s(i),c=o[0]<<8|o[1],l=o.slice(2,2+c),u=o.slice(2+c),d=n(l),f=n(u),p=t(d,e),m=t(f,e);if(p&&m&&p.type===r&&m.type===r&&p.index<=m.index&&!(p.index===m.index&&a.length>0))if(a.length>0)if(m.index-p.index<Math.max(1,Math.floor(a.length*.5))){let e=r.toString().slice(p.index,m.index);if(a.startsWith(e)||a.endsWith(e))return{from:p.index,to:m.index,orphaned:!1,recovered:!0}}else return{from:p.index,to:m.index,orphaned:!1,recovered:!1};else return{from:p.index,to:m.index,orphaned:!1,recovered:!1}}catch{}if(a.length>0){let e=r.toString(),t=e.indexOf(a);if(t>=0&&e.indexOf(a,t+1)<0)return{from:t,to:t+a.length,orphaned:!1,recovered:!0}}return{from:-1,to:-1,orphaned:!0,recovered:!1}}export{l as n,a as t};