UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

2 lines • 1.24 kB
import{n as e}from"./rolldown-runtime-8BhlS34s.js";import{Hu as t,Vu as n}from"./control-ui-core-BncvAZjR.js";import{Ct as r,St as i}from"./control-ui-boot-shared-xfDhIVun.js";import{v as a}from"./control-ui-boot-shared-D4XEBdOG.js";function o(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 s(e){return o(e.map(e=>e.type===`text`||e.type===`code_inline`?a(e.content):e.type===`html_inline`?e.content:e.type===`image`?a(s(e.children??[])):e.type===`softbreak`||e.type===`hardbreak`?` `:``).join(``))}function c(e,t=!0){return e.map(e=>{if(e.type===`inline`)return s(e.children??[]);if(e.type===`code_block`||e.type===`fence`)return e.content;if(e.type===`html_block`){let n=o(e.content);return t?c(u.parse(n,{}),!1):n}return``}).filter(Boolean).join(` `)}function l(e){let n=c(u.parse(e,{})).replace(/\s+/gu,` `).trim(),r=t(n,30);return r.length<n.length?`${r}…`:r}var u;function d(){return(d=e((()=>{r(),n(),u=i()})))()}d();export{l as derivePastedTextExcerpt};