openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 3.33 kB
JavaScript
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{Hy as t,Uy as n}from"./control-ui-boot-shared-DFTSUQQ0.js";import{F as r,P as i,U as a,V as o,ht as s}from"./solid-runtime-C416s-HC.js";import{n as c,t as l}from"./pending-focus-BoBumoUz.js";function u(e,n){i(n,n=>{let r=t(e(),n);return()=>r.dispose()})}function d(){return(d=e((()=>{a(),n()})))()}function f(e){let t=e.getRootNode();return t instanceof ShadowRoot?t.activeElement??document.activeElement:document.activeElement}function p(e){let t=f(e),n=e.getRootNode();return t===document.body||t===document.documentElement||n instanceof ShadowRoot&&t===n.host}function m(){let e;return{attach(t){return e=t,()=>{e===t&&(e=void 0)}},focusActive(t){e?.element(e.active()??null)?.focus(t)},restoreAfterClose(t){if(!e?.root.isConnected||e.element(t))return;let n=e.element(e.active()??null);n&&p(n)&&n.focus({preventScroll:!0})}}}function h(e,t,n,i={}){let a=new Map,c=r(()=>e().active),u=r(()=>t().filter(e=>!e.disabled).map(e=>e.value)),[d,f]=o(e=>{let t=c(),n=u();e.value=e.active===t&&e.value!==void 0&&n.includes(e.value)?e.value:t!=null&&n.includes(t)?t:n[0],e.active=t},{active:null,value:void 0}),m=e=>typeof i.revealActive==`function`?i.revealActive(e):e.scrollIntoView?.({block:`nearest`,inline:`nearest`});if(i.revealActive){let e=r(()=>JSON.stringify([c(),t().map(e=>e.value)]));l(()=>{let t=e(),n=document.activeElement;for(;n instanceof HTMLElement&&n.shadowRoot?.activeElement;)n=n.shadowRoot.activeElement;return{key:t,focused:n}},{requested:()=>!0,focus:({focused:e})=>{queueMicrotask(()=>{let t=a.get(c()??``);n().isConnected&&t&&(m(t),e===t&&p(t)&&t.focus({preventScroll:!0}))})}})}function h(t,n,r){let i=t.dataset.tabValue;i!==void 0&&a.get(i)===t&&u().includes(i)&&(f(e=>{e.active=c(),e.value=i}),!(r&&e().onActivate?.(i,t,n)===!1)&&i!==c()&&e().onSelect?.(i,t,n))}function g(e){let t=e.currentTarget;!e.defaultPrevented&&e.button===0&&t instanceof HTMLElement&&h(t,e,!0)}function _(t){let r=t.currentTarget;if(t.defaultPrevented||!(r instanceof HTMLElement)||a.get(r.dataset.tabValue??``)!==r||!u().includes(r.dataset.tabValue??``)||t.altKey||t.ctrlKey||t.metaKey)return;if(t.key===`Enter`||t.key===` `){t.preventDefault(),t.repeat||h(r,t,!0);return}let i=getComputedStyle(n()).direction===`rtl`,o=i?`ArrowLeft`:`ArrowRight`;if(![o,i?`ArrowRight`:`ArrowLeft`,`Home`,`End`].includes(t.key))return;t.preventDefault();let s=u(),l=s.indexOf(r.dataset.tabValue??``),d=s[t.key===`Home`?0:t.key===`End`?s.length-1:(l+(t.key===o?1:-1)+s.length)%s.length];if(d===void 0)return;let p=a.get(d);p&&(f(e=>{e.active=c(),e.value=d}),e().activation!==`manual`&&h(p,t,!1),p.focus({preventScroll:!0}),m(p))}return{active:c,element:e=>e===null?void 0:a.get(e),tabIndex:e=>d.value===e?0:-1,ref(e){return s(()=>a.delete(e)),t=>{a.set(e,t)}},onClick:g,onKeyDown:_}}function g(){return(g=e((()=>{a(),c()})))()}var _;function v(){return(v=e((()=>{_=`.oc-tabs{min-width:0}:where(.oc-tab){appearance:none;color:inherit;font:inherit;letter-spacing:inherit;text-align:inherit;cursor:var(--cursor-action);background:0 0;border:0;flex:none;margin:0}.oc-tab:disabled{opacity:.5;cursor:not-allowed}button:where(.oc-tab){font-weight:var(--control-ui-font-weight-semibold)}`})))()}function y(){return(y=e((()=>{})))()}export{m as a,u as c,f as i,d as l,v as n,h as o,_ as r,g as s,y as t};