import{__require as e}from"../is-fullwidth-code-point/index.mjs";import{__require as t}from"../astral-regex/index.mjs";import{__require as r}from"../ansi-styles/index.mjs";var i,s;function o(){if(s)return i;s=1;const o=e(),n=t(),f=r(),u=["",""],c=e=>`${u[0]}[${e}m`,l=(e,t,r)=>{let i=[];e=[...e];for(let r of e){const s=r;r.includes(";")&&(r=r.split(";")[0][0]+"0");const o=f.codes.get(Number.parseInt(r,10));if(o){const r=e.indexOf(o.toString());-1===r?i.push(c(t?o:s)):e.splice(r,1)}else{if(t){i.push(c(0));break}i.push(c(s))}}if(t&&(i=i.filter((e,t)=>i.indexOf(e)===t),void 0!==r)){const e=c(f.codes.get(Number.parseInt(r,10)));i=i.reduce((t,r)=>r===e?[r,...t]:[...t,r],[])}return i.join("")};return i=(e,t,r)=>{const i=[...e],s=[];let f,c="number"==typeof r?r:i.length,d=!1,m=0,p="";for(const[a,x]of i.entries()){let i=!1;if(u.includes(x)){const t=/\d[^m]*/.exec(e.slice(a,a+18));f=t&&t.length>0?t[0]:void 0,m<c&&(d=!0,void 0!==f&&s.push(f))}else d&&"m"===x&&(d=!1,i=!0);if(d||i||m++,!n({exact:!0}).test(x)&&o(x.codePointAt())&&(m++,"number"!=typeof r&&c++),m>t&&m<=c)p+=x;else if(m!==t||d||void 0===f){if(m>=c){p+=l(s,!0,f);break}}else p=l(s)}return p}}export{o as __require};