UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 2.63 kB
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{Ql as t,Ul as n,ml as r,vl as i}from"./control-ui-connection-Bfj9beF_.js";import{n as a}from"./control-ui-boot-shared-DsegYo6K.js";import{a as o,l as s,m as c,o as l}from"./config-form-utils-BqrafwiP.js";import{a as u,n as d,t as f}from"./config-form.array-items-DbVc_YXt.js";function p(e){return!!(e&&(e.text.length>0||e.tags.length>0))}function m(e){let t=new Set,r=e.replace(/(?:^|\s)tag:([^\s]+)/gi,(e,r)=>{let i=n(r);return i&&t.add(i),``});return{text:n(r),tags:[...t]}}function h(e){return[...a(i(e),n).values()]}function g(e,t,n){let r=s(e,n),i=e.findLast(e=>typeof e==`string`)??e.at(-1),a=r?.label??t.title??o(String(i)),c=r?.help??t.description,l=h(t[`x-tags`]??t.tags),u=h(r?.tags);return{label:a,help:c,tags:u.length>0?u:l}}function _(e,t){return n(e).includes(n(t))}function v(e,t){if(e.length===0)return!0;let r=new Set(t.map(e=>n(e)));return e.every(e=>r.has(e))}function y(e){let{schema:t,path:n,hints:r,criteria:i,textMatcher:a=_}=e;if(!p(i))return!0;let{label:o,help:s,tags:c}=g(n,t,r);if(!v(i.tags,c))return!1;if(!i.text)return!0;let l=n.filter(e=>typeof e==`string`).join(`.`),u=t.enum?.map(e=>String(e)).join(` `)??``;return[o,s,t.title,t.description,l,u].some(e=>e!==void 0&&a(e,i.text))}function b(e){let{schema:n,value:r,path:i,hints:a,criteria:o,textMatcher:s=_}=e;if(y({schema:n,path:i,hints:a,criteria:o,textMatcher:s}))return!0;let l=(t,n,r)=>b({...e,schema:t,value:n,path:[...i,r]}),u=c(n);if(u===`object`){let e=r??n.default,i=t(e),a=n.properties??{};if(Object.entries(a).some(([e,t])=>l(t,i[e],e)))return!0;let o=n.additionalProperties;if(o&&typeof o==`object`){let e=new Set(Object.keys(a)),t=Object.entries(i).filter(([t])=>!e.has(t));return t.length===0?l(o,void 0,`*`):t.some(([e,t])=>l(o,t,e))}return!1}if(u!==`array`)return!1;let p=Array.isArray(r)?r:Array.isArray(n.default)?n.default:[],m=Math.max(p.length,d(n).length);for(let e=0;e<m;e+=1){let t=f(n,e);if(t&&l(t,p[e],e))return!0}return!1}function x(e){let t=Object.entries(e.value).filter(([t])=>!e.reservedKeys.has(t)),n=e.searchCriteria,r=p(n),i=n&&r?t.filter(([t,r])=>b({schema:e.schema,value:r,path:[...e.path,t],hints:e.hints,criteria:n})):t;return{visibleEntries:i,visible:!r||i.length>0}}function S(e){if(!e.query)return!0;let t=m(e.query);return t.tags.length===0&&t.text.length>0&&[e.key,e.label,e.description].some(n=>n!==void 0&&(e.textMatcher??_)(n,t.text))||b({schema:e.schema,value:e.value,path:[e.key],hints:e.hints,criteria:t,textMatcher:e.textMatcher})}function C(){return(C=e((()=>{r(),l(),u()})))()}export{y as a,x as c,b as i,C as n,m as o,S as r,g as s,p as t};