openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
2 lines • 1.2 kB
JavaScript
import{n as e}from"./rolldown-runtime-8BhlS34s.js";import{Eu as t,Tu as n}from"./control-ui-core-3P365fbR.js";import{Ir as r,Lr as i,cr as a,sr as o}from"./control-ui-boot-shared-CG9HtEG-.js";function s(e){let t=document.createElement(`template`);return t.innerHTML=e,t.content.querySelectorAll(`script, style, template`).forEach(e=>e.remove()),t.content.querySelectorAll(`p, div, br, hr, li, tr, h1, h2, h3, h4, h5, h6, blockquote, pre`).forEach(e=>e.after(document.createTextNode(`
`))),t.content.textContent??``}function c(e){return s(e.map(e=>e.type===`text`||e.type===`code_inline`?r(e.content):e.type===`html_inline`?e.content:e.type===`image`?r(c(e.children??[])):e.type===`softbreak`||e.type===`hardbreak`?` `:``).join(``))}function l(e,t=!0){return e.map(e=>{if(e.type===`inline`)return c(e.children??[]);if(e.type===`code_block`||e.type===`fence`)return e.content;if(e.type===`html_block`){let n=s(e.content);return t?l(d.parse(n,{}),!1):n}return``}).filter(Boolean).join(` `)}function u(e){let n=l(d.parse(e,{})).replace(/\s+/gu,` `).trim(),r=t(n,30);return r.length<n.length?`${r}…`:r}var d;function f(){return(f=e((()=>{a(),i(),n(),d=o()})))()}f();export{u as derivePastedTextExcerpt};