openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 3.22 kB
JavaScript
import{n as e}from"./rolldown-runtime-8BhlS34s.js";import{di as t,ii as n,ri as r,si as i}from"./control-ui-core-CBJ5efDh.js";import{J as a}from"./control-ui-boot-chat-Ye5j4vAg.js";import{So as o,_a as s,go as c,jo as l}from"./ui-CmSP4d14.js";function u(e){let t=[],n=[e],r=new Set;for(;n.length>0;){let e=n.pop();if(e&&!r.has(e)){r.add(e),t.push(e);for(let t=(e.allOf?.length??0)-1;t>=0;--t){let r=e.allOf?.[t];r&&n.push(r)}}}return t}function d(e){let n=e.find(e=>t(e)!==void 0)??e[0];return!n||e.length===1?n:{...n,allOf:[...n.allOf??[],...e.filter(e=>e!==n)]}}function f(e,t){let n=[];for(let r of u(e))if(Array.isArray(r.items)){let e=r.items[t]??(r.additionalItems&&typeof r.additionalItems==`object`?r.additionalItems:void 0);e&&n.push(e)}else r.items&&n.push(r.items);return d(n)}function p(e){let t=0,n;for(let r of u(e))if(Array.isArray(r.items)){let e=r.additionalItems!==null&&typeof r.additionalItems==`object`;t=Math.max(t,r.items.length+ +!!e),r.additionalItems===!1&&(n=Math.min(n??1/0,r.items.length))}else r.items&&(t=Math.max(t,1));return n!==void 0&&(t=Math.min(t,n)),Array.from({length:t},(e,t)=>t)}function m(){return(m=e((()=>{n()})))()}function h(e){return!!(e&&(e.text.length>0||e.tags.length>0))}function g(e){let t=new Set,n=e.replace(/(?:^|\s)tag:([^\s]+)/gi,(e,n)=>{let r=l(n);return r&&t.add(r),``});return{text:l(n),tags:[...t]}}function _(e){return[...a(o(e),l).values()]}function v(e,t,n){let a=i(e,n),o=e.findLast(e=>typeof e==`string`)??e.at(-1),s=a?.label??t.title??r(String(o)),c=a?.help??t.description,l=_(t[`x-tags`]??t.tags),u=_(a?.tags);return{label:s,help:c,tags:u.length>0?u:l}}function y(e,t){return l(e).includes(l(t))}function b(e,t){if(e.length===0)return!0;let n=new Set(t.map(e=>l(e)));return e.every(e=>n.has(e))}function x(e){let{schema:t,path:n,hints:r,criteria:i,textMatcher:a=y}=e;if(!h(i))return!0;let{label:o,help:s,tags:c}=v(n,t,r);if(!b(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 S(e){let{schema:n,value:r,path:i,hints:a,criteria:o,textMatcher:c=y}=e;if(x({schema:n,path:i,hints:a,criteria:o,textMatcher:c}))return!0;let l=(t,n,r)=>S({...e,schema:t,value:n,path:[...i,r]}),u=t(n);if(u===`object`){let e=r??n.default,t=s(e),i=n.properties??{};if(Object.entries(i).some(([e,n])=>l(n,t[e],e)))return!0;let a=n.additionalProperties;if(a&&typeof a==`object`){let e=new Set(Object.keys(i)),n=Object.entries(t).filter(([t])=>!e.has(t));return n.length===0?l(a,void 0,`*`):n.some(([e,t])=>l(a,t,e))}return!1}if(u!==`array`)return!1;let d=Array.isArray(r)?r:Array.isArray(n.default)?n.default:[],m=Math.max(d.length,p(n).length);for(let e=0;e<m;e+=1){let t=f(n,e);if(t&&l(t,d[e],e))return!0}return!1}function C(e){if(!e.query)return!0;let t=g(e.query);return t.tags.length===0&&t.text.length>0&&[e.key,e.label,e.description].some(n=>n!==void 0&&(e.textMatcher??y)(n,t.text))||S({schema:e.schema,value:e.value,path:[e.key],hints:e.hints,criteria:t,textMatcher:e.textMatcher})}function w(){return(w=e((()=>{c(),n(),m()})))()}export{x as a,f as c,d,m as f,S as i,p as l,w as n,g as o,C as r,v as s,h as t,u};