UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

2 lines • 2.85 kB
import{n as e,r as t}from"./rolldown-runtime-CNOWq4Kh.js";import{G as n,W as r}from"./markdown-runtime-DmM7zNej.js";import{n as i,t as a}from"./emoji-catalog-runtime-D5XAN94K.js";var o=t({EmojiTargetResolver:()=>m,emojiForShortcode:()=>l,suggestEmoji:()=>u});function s(e,t,n){if(e.trimStart().startsWith(`/`))return!0;let i=e.slice(0,n),a=i.split(` `).length-1,o=!1,s;p??=new r().disable([`inline`,`linkify`,`replacements`,`smartquotes`,`text_join`]);for(let e of p.parse(i,{}))if(e.map&&(o=e.map[0]<=a&&e.map[1]>a),o){if([`fence`,`code_block`,`html_block`].includes(e.type))return!0;e.type===`inline`&&e.content&&(s=e.content)}if(s===void 0)return!0;let c=0,l=0,u=0,d=``,f=!1,m=!1,h=!1,g=0;for(let e=0;e<s.length;){let t=s[e++];if(c){if(t!=="`")continue;let n=1;for(;s[e]==="`";)n+=1,e+=1;c===n&&(c=0,g=e)}else if(m)h?t===`>`&&(m=!1,g=e):d?t===d&&(d=``):t===`"`||t===`'`?d=t:t===`>`&&(m=!1,g=e);else if(t===`\\`)e+=1;else if(u)f?t===`>`&&(f=!1):d?t===d&&(d=``):(t===`"`||t===`'`)&&/\s/u.test(s[e-2]??``)?d=t:t===`<`&&s[e-2]===`(`?f=!0:t===`(`?u+=1:t===`)`&&--u===0&&(g=e);else if(t==="`")for(c=1;s[e]==="`";)c+=1,e+=1;else if(t===`[`)l+=1;else if(t===`]`&&l>0)--l,s[e]===`(`&&(u=1,e+=1);else if(t===`<`){let t=s.slice(e);h=/^[a-zA-Z][a-zA-Z0-9+.-]*:/u.test(t)||/^[^\s<>]*@/u.test(t),m=h||/^[a-zA-Z!?/]/u.test(t)}}if(c||u||m)return!0;let _=s.length-(n-t),v=_,y=/\s/u;for(;v>g&&!y.test(s[v-1]);)--v;let b=s.slice(v,_);if(b.toLowerCase().includes(`www.`)||/[/?#]/u.test(b))return!0;let x=!1;for(let e=0;e<b.length;e+=1){let t=b.charCodeAt(e);if(t===58&&x&&e+1<b.length)return!0;t>=65&&t<=90||t>=97&&t<=122?x=!0:x&&(t>=48&&t<=57||t===43||t===45||t===46)||(x=!1)}return!1}function c(e){let t=0,n=d.length;for(;t<n;){let r=t+n>>>1;d[r]<e?t=r+1:n=r}return t}function l(e){return Object.hasOwn(a,e)?a[e]:void 0}function u(e){let t=[];for(let n=c(e);n<d.length&&t.length<12;n+=1){let r=d[n];if(!r.startsWith(e))break;t.push(r)}return t}var d,f,p,m;function h(){return(h=e((()=>{n(),i(),d=Object.keys(a).toSorted(),f=d.reduce((e,t)=>Math.max(e,t.length),0),m=class{constructor(){this.context=null,this.snapshot=null}reset(){this.context=null,this.snapshot=null}find(e,t){if(this.snapshot?.value===e&&this.snapshot.caret===t)return this.snapshot.target;let n=this.resolve(e,t);return this.snapshot={value:e,caret:t,target:n},n}resolve(e,t){let n=e.slice(Math.max(0,t-f-1),t),r=/:([a-z0-9_+-]+)$/u.exec(n);if(!r||!d[c(r[1])]?.startsWith(r[1]))return this.context=null,null;let i=t-r[0].length;if(/[\p{L}\p{N}_/:\\]$/u.test(e.slice(Math.max(0,i-2),i)))return null;let a=t;for(;a-i<=f&&/[a-z0-9_+-]/u.test(e[a]??``);)a+=1;if(/[a-z0-9_+-]/u.test(e[a]??``))return null;e[a]===`:`&&(a+=1);let o=e.slice(0,i);return this.context?.prefix!==o&&(this.context={prefix:o,literal:s(e,i,t)}),this.context.literal?null:{start:i,end:a,query:r[1]}}}})))()}export{h as n,o as t};