import{isNode as s,isPrimitive as u,isTextNode as a,isTag as o,isCodeNode as l,isVariable as f,isConditionalNode as c,isFunction as p}from"./utils.js";import{readEnvVariable as m}from"./env.js";import{getValueDeep as h}from"./jsUtils.js";function n(r,t={isTrim:!0}){const i=[];for(const e of r){if(u(e))i.push(String(e));else if(s(e))if(e.type==="tr"&&i.push(`
`),a(e)||l(e))i.push(n([d(e,"content")],t));else{if(c(e)&&t.skipConditionals)continue;i.push(n(e.children,t))}else o(e)&&e.name==="code"?i.push(n(e.children,t)):p(e)&&i.push(n(Object.values(e.parameters),t));f(e)&&i.push(n([b(e,t.variables)],t))}return t.isTrim?i.map(e=>e.trim()).join(" ").trim():i.join(" ")}function d(r,t){return r.attributes[t]||null}function b(r,t){if(r?.path?.[0]==="env")return m(r.path[1])??"";const{value:e}=h(t,r.path);return e??""}function N(r,t,i){r.attributes[t]=i}export{n as getInnerText,d as getNodeAttribute,b as getVariable,N as setNodeAttributeValue};
