const y=["p","h1","h2","h3","h4","h5","h6","li"];function f(r,i){return r.type===i||typeof r.type=="object"&&r.type.tag===i||r.tag===i}function u(r){return f(r,"text")||f(r,Symbol.for("v-txt"))}function l(r){return Array.isArray(r.children)||typeof r.children=="string"?r.children:typeof r.children?.default=="function"?r.children.default():[]}function n(r){if(!r)return"";if(Array.isArray(r))return r.map(n).join("");if(u(r))return r.value||r.children||"";const i=l(r);return Array.isArray(i)?i.map(n).filter(Boolean).join(""):""}function h(r,i=[]){if(Array.isArray(r))return r.flatMap(e=>h(e,i));let t=r;return i.some(e=>e==="*"||f(r,e))&&(t=l(r)||r,!Array.isArray(t)&&y.some(e=>f(r,e))&&(t=[t])),t}function p(r,i=[]){return r=Array.isArray(r)?r:[r],i.length?r.flatMap(t=>p(h(t,[i[0]]),i.slice(1))).filter(t=>!(u(t)&&n(t).trim()==="")):r}function a(r,i=[]){return typeof i=="string"&&(i=i.split(/[,\s]/).map(t=>t.trim()).filter(Boolean)),i.length?p(r,i).reduce((t,e)=>(u(e)?typeof t[t.length-1]=="string"?t[t.length-1]+=e.children:t.push(e.children):t.push(e),t),[]):r}export{a as f,n};
