@askdb/studio 0.2.0-beta.37 → 0.2.0-beta.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -46,7 +46,7 @@ Error generating stack: `+e.message+`
46
46
  `},Nc=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},Pc=function(){M.useEffect(function(){return document.body.setAttribute(jc,(Nc()+1).toString()),function(){var e=Nc()-1;e<=0?document.body.removeAttribute(jc):document.body.setAttribute(jc,e.toString())}},[])},Fc=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;Pc();var a=M.useMemo(function(){return kc(i)},[i]);return M.createElement(Ac,{styles:Mc(a,!t,i,n?``:`!important`)})},Ic=!1;if(typeof window<`u`)try{var Lc=Object.defineProperty({},"passive",{get:function(){return Ic=!0,!0}});window.addEventListener(`test`,Lc,Lc),window.removeEventListener(`test`,Lc,Lc)}catch{Ic=!1}var Rc=Ic?{passive:!1}:!1,zc=function(e){return e.tagName===`TEXTAREA`},Bc=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!zc(e)&&n[t]===`visible`)},Vc=function(e){return Bc(e,`overflowY`)},Hc=function(e){return Bc(e,`overflowX`)},Uc=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),Kc(e,r)){var i=qc(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Wc=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},Gc=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},Kc=function(e,t){return e===`v`?Vc(t):Hc(t)},qc=function(e,t){return e===`v`?Wc(t):Gc(t)},Jc=function(e,t){return e===`h`&&t===`rtl`?-1:1},Yc=function(e,t,n,r,i){var a=Jc(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=qc(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&Kc(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},Xc=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Zc=function(e){return[e.deltaX,e.deltaY]},Qc=function(e){return e&&`current`in e?e.current:e},$c=function(e,t){return e[0]===t[0]&&e[1]===t[1]},el=function(e){return`
47
47
  .block-interactivity-${e} {pointer-events: none;}
48
48
  .allow-interactivity-${e} {pointer-events: all;}
49
- `},tl=0,nl=[];function rl(e){var t=M.useRef([]),n=M.useRef([0,0]),r=M.useRef(),i=M.useState(tl++)[0],a=M.useState(Tc)[0],o=M.useRef(e);M.useEffect(function(){o.current=e},[e]),M.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=tc([e.lockRef.current],(e.shards||[]).map(Qc),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=M.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=Xc(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=Uc(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Uc(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return Yc(h,t,e,h===`h`?s:c,!0)},[]),c=M.useCallback(function(e){var n=e;if(nl.length&&nl[nl.length-1]===a){var r=`deltaY`in n?Zc(n):Xc(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&$c(e.delta,r)})[0];if(i&&i.should)n.cancelable&&n.preventDefault();else if(!i){var c=(o.current.shards||[]).map(Qc).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=M.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:il(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=M.useCallback(function(e){n.current=Xc(e),r.current=void 0},[]),d=M.useCallback(function(t){l(t.type,Zc(t),t.target,s(t,e.lockRef.current))},[]),f=M.useCallback(function(t){l(t.type,Xc(t),t.target,s(t,e.lockRef.current))},[]);M.useEffect(function(){return nl.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Rc),document.addEventListener(`touchmove`,c,Rc),document.addEventListener(`touchstart`,u,Rc),function(){nl=nl.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Rc),document.removeEventListener(`touchmove`,c,Rc),document.removeEventListener(`touchstart`,u,Rc)}},[]);var p=e.removeScrollBar,m=e.inert;return M.createElement(M.Fragment,null,m?M.createElement(a,{styles:el(i)}):null,p?M.createElement(Fc,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function il(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var al=hc(gc,rl),ol=M.forwardRef(function(e,t){return M.createElement(vc,$s({},e,{ref:t,sideCar:al}))});ol.classNames=vc.classNames;var sl=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},cl=new WeakMap,ll=new WeakMap,ul={},dl=0,fl=function(e){return e&&(e.host||fl(e.parentNode))},pl=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=fl(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},ml=function(e,t,n,r){var i=pl(t,Array.isArray(e)?e:[e]);ul[n]||(ul[n]=new WeakMap);var a=ul[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(cl.get(e)||0)+1,l=(a.get(e)||0)+1;cl.set(e,c),a.set(e,l),o.push(e),c===1&&i&&ll.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),dl++,function(){o.forEach(function(e){var t=cl.get(e)-1,i=a.get(e)-1;cl.set(e,t),a.set(e,i),t||(ll.has(e)||e.removeAttribute(r),ll.delete(e)),i||e.removeAttribute(n)}),dl--,dl||(cl=new WeakMap,cl=new WeakMap,ll=new WeakMap,ul={})}},hl=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||sl(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),ml(r,i,n,`aria-hidden`)):function(){return null}},gl=Object.defineProperty,_l=(e,t)=>gl(e,`name`,{value:t,configurable:!0}),vl=`Dialog`,[yl,bl]=so(vl),[xl,Sl]=yl(vl),Cl=_l(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=M.useRef(null),c=M.useRef(null),{nodes:l,registry:u}=js(),[d,f]=Do({prop:r,defaultProp:i??!1,onChange:a,caller:vl}),[p,m]=M.useState(0),[h,g]=M.useState(0);return(0,R.jsx)(xl,{scope:t,triggerRef:s,contentRef:c,contentId:Wo(),titleId:Wo(),descriptionId:Wo(),titlePresent:p>0,descriptionPresent:h>0,setTitleCount:m,setDescriptionCount:g,open:d,onOpenChange:f,onOpenToggle:M.useCallback(()=>f(e=>!e),[f]),modal:o,branchNodes:l,branchRegistry:u,children:n})},`Dialog`),wl=`DialogPortal`,[Tl,El]=yl(wl,{forceMount:void 0}),Dl=_l(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=Sl(wl,t);return(0,R.jsx)(Tl,{scope:t,forceMount:n,children:M.Children.map(r,e=>(0,R.jsx)(Fo,{present:n||a.open,children:(0,R.jsx)(Gs,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),Ol=`DialogOverlay`,kl=M.forwardRef(_l(function(e,t){let n=El(Ol,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Sl(Ol,e.__scopeDialog);return a.modal?(0,R.jsx)(Fo,{present:r||a.open,children:(0,R.jsx)(jl,{...i,ref:t})}):null},`DialogOverlay`)),Al=Na(`DialogOverlay.RemoveScroll`),jl=M.forwardRef(_l(function(e,t){let{__scopeDialog:n,...r}=e,i=Sl(Ol,n),a=V(t,_s());return(0,R.jsx)(ol,{as:Al,allowPinchZoom:!0,shards:M.useMemo(()=>[i.contentRef,...i.branchNodes.map(e=>({current:e}))],[i.contentRef,i.branchNodes]),children:(0,R.jsx)(Qa.div,{"data-state":Hl(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),Ml=`DialogContent`,Nl=M.forwardRef(_l(function(e,t){let n=El(Ml,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Sl(Ml,e.__scopeDialog);return(0,R.jsx)(Fo,{present:r||a.open,children:a.modal?(0,R.jsx)(Pl,{...i,ref:t}):(0,R.jsx)(Fl,{...i,ref:t})})},`DialogContent`)),Pl=M.forwardRef(_l(function(e,t){let n=Sl(Ml,e.__scopeDialog),r=M.useRef(null),i=V(t,n.contentRef,r);return M.useEffect(()=>{let e=r.current;if(e)return hl(e)},[]),(0,R.jsx)(Il,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:mo(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:mo(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:mo(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),Fl=M.forwardRef(_l(function(e,t){let n=Sl(Ml,e.__scopeDialog),r=M.useRef(!1),i=M.useRef(!1);return(0,R.jsx)(Il,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),Il=M.forwardRef(_l(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,"aria-describedby":o,children:s,...c}=e,l=Sl(Ml,n);return Zs(),(0,R.jsx)(As,{registry:l.branchRegistry,children:(0,R.jsx)(Os,{asChild:!0,loop:!0,trapped:r,branches:l.branchNodes,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,R.jsx)(gs,{role:`dialog`,id:l.contentId,"aria-labelledby":l.titlePresent?l.titleId:void 0,"aria-describedby":l.descriptionPresent?Vl(o,l.descriptionId):o,"data-state":Hl(l.open),...c,ref:t,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1),children:s})})})},`DialogContentImpl`)),Ll=M.forwardRef(_l(function(e,t){let{__scopeDialog:n,...r}=e,i=Sl(`DialogTitle`,n),{setTitleCount:a}=i;return lo(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,R.jsx)(Qa.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),Rl=M.forwardRef(_l(function(e,t){let{__scopeDialog:n,...r}=e,i=Sl(`DialogDescription`,n),{setDescriptionCount:a}=i;return lo(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,R.jsx)(Qa.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),zl=`DialogClose`,Bl=M.forwardRef(_l(function(e,t){let{__scopeDialog:n,...r}=e,i=Sl(zl,n);return(0,R.jsx)(Qa.button,{type:`button`,...r,ref:t,onClick:mo(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function Vl(...e){let t=new Set;for(let n of e)if(typeof n==`string`)for(let e of String(n).trim().split(/\s+/))e&&t.add(e);return t.size>0?Array.from(t).join(` `):void 0}_l(Vl,`concatAriaDescribedby`);function Hl(e){return e?`open`:`closed`}_l(Hl,`getState`);var Ul=Object.defineProperty,Wl=(e,t)=>Ul(e,`name`,{value:t,configurable:!0});function Gl(e){let[t,n]=M.useState(void 0);return lo(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=0,r=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;let i=r[0];window.cancelAnimationFrame(t),t=window.requestAnimationFrame(()=>{let t,r;if(`borderBoxSize`in i){let e=i.borderBoxSize,n=Array.isArray(e)?e[0]:e;t=n.inlineSize,r=n.blockSize}else t=e.offsetWidth,r=e.offsetHeight;n({width:t,height:r})})});return r.observe(e,{box:`border-box`}),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}n(void 0)},[e]),t}Wl(Gl,`useSize`);var Kl=[`top`,`right`,`bottom`,`left`],ql=Math.min,Jl=Math.max,Yl=Math.round,Xl=Math.floor,Zl=e=>({x:e,y:e}),Ql={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function $l(e,t,n){return Jl(e,ql(t,n))}function eu(e,t){return typeof e==`function`?e(t):e}function tu(e){return e.split(`-`)[0]}function nu(e){return e.split(`-`)[1]}function ru(e){return e===`x`?`y`:`x`}function iu(e){return e===`y`?`height`:`width`}function au(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function ou(e){return ru(au(e))}function su(e,t,n){n===void 0&&(n=!1);let r=nu(e),i=ou(e),a=iu(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=gu(o)),[o,gu(o)]}function cu(e){let t=gu(e);return[lu(e),t,lu(t)]}function lu(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var uu=[`left`,`right`],du=[`right`,`left`],fu=[`top`,`bottom`],pu=[`bottom`,`top`];function mu(e,t,n){switch(e){case`top`:case`bottom`:return n?t?du:uu:t?uu:du;case`left`:case`right`:return t?fu:pu;default:return[]}}function hu(e,t,n,r){let i=nu(e),a=mu(tu(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(lu)))),a}function gu(e){let t=tu(e);return Ql[t]+e.slice(t.length)}function _u(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function vu(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:_u(e)}function yu(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function bu(e,t,n){let{reference:r,floating:i}=e,a=au(t),o=ou(t),s=iu(o),c=tu(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=nu(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function xu(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=eu(t,e),p=vu(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=yu(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=yu(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var Su=50,Cu=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:xu},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=bu(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<Su&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=bu(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},wu=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=eu(e,t)||{};if(l==null)return{};let d=vu(u),f={x:n,y:r},p=ou(i),m=iu(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;C&&await(o.isElement==null?void 0:o.isElement(S))||(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=ql(d[_],T),D=ql(d[v],T),O=C-h[m]-D,k=C/2-h[m]/2+w,A=$l(E,k,O),j=!c.arrow&&nu(i)!=null&&k!==A&&a.reference[m]/2-(k<E?E:D)-h[m]/2<0,M=j?k<E?k-E:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),Tu=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=eu(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=tu(r),_=au(o),v=tu(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[gu(o)]:cu(o)),x=p!==`none`;!d&&x&&b.push(...hu(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=su(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===au(t)||T.every(e=>au(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=au(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function Eu(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Du(e){return Kl.some(t=>e[t]>=0)}var Ou=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=eu(e,t);switch(i){case`referenceHidden`:{let e=Eu(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Du(e)}}}case`escaped`:{let e=Eu(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Du(e)}}}default:return{}}}}},ku=new Set([`left`,`top`]);async function Au(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=tu(n),s=nu(n),c=au(n)===`y`,l=ku.has(o)?-1:1,u=a&&c?-1:1,d=eu(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var ju=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await Au(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},Mu=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=eu(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=au(i),p=ru(f),m=u[p],h=u[f],g=(e,t)=>$l(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},Nu=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=eu(e,t),u={x:n,y:r},d=au(i),f=ru(d),p=u[f],m=u[d],h=eu(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=ku.has(tu(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},Pu=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=eu(e,t),c=await i.detectOverflow(t,s),l=tu(n),u=nu(n),d=au(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=ql(p-c[m],g),y=ql(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*Jl(c.left,c.right):S=p-2*Jl(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function Fu(){return typeof window<`u`}function Iu(e){return zu(e)?(e.nodeName||``).toLowerCase():`#document`}function Lu(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ru(e){return((zu(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function zu(e){return Fu()?e instanceof Node||e instanceof Lu(e).Node:!1}function Bu(e){return Fu()?e instanceof Element||e instanceof Lu(e).Element:!1}function Vu(e){return Fu()?e instanceof HTMLElement||e instanceof Lu(e).HTMLElement:!1}function Hu(e){return!Fu()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof Lu(e).ShadowRoot}function Uu(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=ed(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Wu(e){return/^(table|td|th)$/.test(Iu(e))}function Gu(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Ku=/transform|translate|scale|rotate|perspective|filter/,qu=/paint|layout|strict|content/,Ju=e=>!!e&&e!==`none`,Yu;function Xu(e){let t=Bu(e)?ed(e):e;return Ju(t.transform)||Ju(t.translate)||Ju(t.scale)||Ju(t.rotate)||Ju(t.perspective)||!Qu()&&(Ju(t.backdropFilter)||Ju(t.filter))||Ku.test(t.willChange||``)||qu.test(t.contain||``)}function Zu(e){let t=nd(e);for(;Vu(t)&&!$u(t);){if(Xu(t))return t;if(Gu(t))return null;t=nd(t)}return null}function Qu(){return Yu??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Yu}function $u(e){return/^(html|body|#document)$/.test(Iu(e))}function ed(e){return Lu(e).getComputedStyle(e)}function td(e){return Bu(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function nd(e){if(Iu(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Hu(e)&&e.host||Ru(e);return Hu(t)?t.host:t}function U(e){let t=nd(e);return $u(t)?(e.ownerDocument||e).body:Vu(t)&&Uu(t)?t:U(t)}function W(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=U(e),i=r===e.ownerDocument?.body,a=Lu(r);if(i){let e=G(a);return t.concat(a,a.visualViewport||[],Uu(r)?r:[],e&&n?W(e):[])}return t.concat(r,W(r,[],n))}function G(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function K(e){let t=ed(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Vu(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Yl(n)!==a||Yl(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function q(e){return Bu(e)?e:e.contextElement}function rd(e){let t=q(e);if(!Vu(t))return Zl(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=K(t),o=(a?Yl(n.width):n.width)/r,s=(a?Yl(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var id=Zl(0);function ad(e){let t=Lu(e);return!Qu()||!t.visualViewport?id:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function od(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Lu(e)}function sd(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=q(e),o=Zl(1);t&&(r?Bu(r)&&(o=rd(r)):o=rd(e));let s=od(a,n,r)?ad(a):Zl(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=Lu(a),t=Bu(r)?Lu(r):r,n=e,i=G(n);for(;i&&t!==n;){let e=rd(i),t=i.getBoundingClientRect(),r=ed(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=Lu(i),i=G(n)}}return yu({width:u,height:d,x:c,y:l})}function cd(e,t){let n=td(e).scrollLeft;return t?t.left+n:sd(Ru(e)).left+n}function ld(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-cd(e,n),y:n.top+t.scrollTop}}function ud(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Ru(r),s=t?Gu(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Zl(1),u=Zl(0),d=Vu(r);if((d||!a)&&((Iu(r)!==`body`||Uu(o))&&(c=td(r)),d)){let e=sd(r);l=rd(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?ld(o,c):Zl(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function dd(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function fd(e){let t=td(e),n=e.ownerDocument.body,r=Jl(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Jl(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+cd(e),o=-t.scrollTop;return ed(n).direction===`rtl`&&(a+=Jl(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var pd=25;function md(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=Lu(e),a=Ru(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Qu()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(cd(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=pd&&(s-=o)}return{width:s,height:c,x:l,y:u}}function hd(e,t){let n=sd(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=rd(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function gd(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=md(e,n,t);else if(t===`document`)r=fd(Ru(e));else if(Bu(t))r=hd(t,n);else{let n=ad(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return yu(r)}function _d(e,t){let n=t.get(e);if(n)return n;let r=W(e,[],!1).filter(e=>Bu(e)&&Iu(e)!==`body`),i=null,a=ed(e).position===`fixed`,o=a?nd(e):e;for(;Bu(o)&&!$u(o);){let e=ed(o),t=Xu(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=nd(o)}return t.set(e,r),r}function vd(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Gu(t)?[]:_d(t,this._c):[].concat(n),r],o=gd(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=gd(t,a[e],i);s=Jl(n.top,s),c=ql(n.right,c),l=ql(n.bottom,l),u=Jl(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function yd(e){let{width:t,height:n}=K(e);return{width:t,height:n}}function bd(e,t,n){let r=Vu(t),i=Ru(t),a=n===`fixed`,o=sd(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=Zl(0);if((r||!a)&&((Iu(t)!==`body`||Uu(i))&&(s=td(t)),r)){let e=sd(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=cd(i));let l=i&&!r&&!a?ld(i,s):Zl(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function xd(e){return ed(e).position===`static`}function Sd(e,t){if(!Vu(e)||ed(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Ru(e)===n&&(n=n.ownerDocument.body),n}function Cd(e,t){let n=Lu(e);if(Gu(e))return n;if(!Vu(e)){let t=nd(e);for(;t&&!$u(t);){if(Bu(t)&&!xd(t))return t;t=nd(t)}return n}let r=Sd(e,t);for(;r&&Wu(r)&&xd(r);)r=Sd(r,t);return r&&$u(r)&&xd(r)&&!Xu(r)?n:r||Zu(e)||n}var wd=async function(e){let t=this.getOffsetParent||Cd,n=this.getDimensions,r=await n(e.floating);return{reference:bd(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Td(e){return ed(e).direction===`rtl`}var Ed={convertOffsetParentRelativeRectToViewportRelativeRect:ud,getDocumentElement:Ru,getClippingRect:vd,getOffsetParent:Cd,getElementRects:wd,getClientRects:dd,getDimensions:yd,getScale:rd,isElement:Bu,isRTL:Td};function Dd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Od(e,t,n){let r=null,i,a=Ru(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=Xl(d),h=Xl(a.clientWidth-(u+f)),g=Xl(a.clientHeight-(d+p)),_=Xl(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Jl(0,ql(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!Dd(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=Lu(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function kd(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=q(e),u=i||a?[...l?W(l):[],...t?W(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?Od(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?sd(e):null;c&&g();function g(){let t=sd(e);h&&!Dd(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var Ad=ju,jd=Mu,Md=Tu,Nd=Pu,Pd=Ou,Fd=wu,Id=Nu,Ld=(e,t,n)=>{let r=new Map,i=n??{},a={...Ed,...i.platform,_c:r};return Cu(e,t,{...i,platform:a})},Rd=typeof document<`u`?M.useLayoutEffect:function(){};function zd(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!zd(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!zd(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Bd(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Vd(e,t){let n=Bd(e);return Math.round(t*n)/n}function Hd(e){let t=M.useRef(e);return Rd(()=>{t.current=e}),t}function Ud(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=M.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=M.useState(r);zd(f,r)||p(r);let[m,h]=M.useState(null),[g,_]=M.useState(null),v=M.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=M.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=M.useRef(null),C=M.useRef(null),w=M.useRef(u),T=c!=null,E=Hd(c),D=Hd(i),O=Hd(l),k=M.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),Ld(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!zd(w.current,t)&&(w.current=t,Ya.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);Rd(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=M.useRef(!1);Rd(()=>(A.current=!0,()=>{A.current=!1}),[]),Rd(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=M.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),N=M.useMemo(()=>({reference:b,floating:x}),[b,x]),ee=M.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=Vd(N.floating,u.x),r=Vd(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Bd(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return M.useMemo(()=>({...u,update:k,refs:j,elements:N,floatingStyles:ee}),[u,k,j,N,ee])}var Wd=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:Fd({element:r.current,padding:i}).fn(n):r?Fd({element:r,padding:i}).fn(n):{}}}},Gd=(e,t)=>{let n=Ad(e);return{name:n.name,fn:n.fn,options:[e,t]}},Kd=(e,t)=>{let n=jd(e);return{name:n.name,fn:n.fn,options:[e,t]}},qd=(e,t)=>({fn:Id(e).fn,options:[e,t]}),Jd=(e,t)=>{let n=Md(e);return{name:n.name,fn:n.fn,options:[e,t]}},Yd=(e,t)=>{let n=Nd(e);return{name:n.name,fn:n.fn,options:[e,t]}},Xd=(e,t)=>{let n=Pd(e);return{name:n.name,fn:n.fn,options:[e,t]}},Zd=(e,t)=>{let n=Wd(e);return{name:n.name,fn:n.fn,options:[e,t]}},Qd=Object.defineProperty,$d=M.forwardRef(((e,t)=>Qd(e,`name`,{value:t,configurable:!0}))(function(e,t){let{children:n,width:r=10,height:i=5,...a}=e;return(0,R.jsx)(Qa.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,R.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})},`Arrow`)),ef=Object.defineProperty,tf=(e,t)=>ef(e,`name`,{value:t,configurable:!0}),nf={Partial:`partial`,Always:`always`},rf={Optimized:`optimized`,Always:`always`},af=`Popper`,[of,sf]=so(af),[cf,lf]=of(af),uf=tf(e=>{let{__scopePopper:t,children:n}=e,[r,i]=M.useState(null),[a,o]=M.useState(void 0);return(0,R.jsx)(cf,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),df=`PopperAnchor`,ff=M.forwardRef(tf(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=lf(df,n),o=M.useRef(null),s=a.onAnchorChange,c=V(t,M.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=M.useRef(null);M.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&Sf(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,R.jsx)(Qa.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})},`PopperAnchor`)),pf=`PopperContent`,[mf,hf]=of(pf),gf=M.forwardRef(tf(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=nf.Partial,hideWhenDetached:f=!1,updatePositionStrategy:p=rf.Optimized,onPlaced:m,...h}=e,g=lf(pf,n),[_,v]=M.useState(null),y=V(t,v),[b,x]=M.useState(null),S=Gl(b),C=S?.width??0,w=S?.height??0,T=r+(a===`center`?``:`-`+a),E=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(l)?l:[l],O=D.length>0,k={padding:E,boundary:D.filter(bf),altBoundary:O},{refs:A,floatingStyles:j,placement:N,isPositioned:ee,middlewareData:te}=Ud({strategy:`fixed`,placement:T,whileElementsMounted:tf((...e)=>kd(...e,{animationFrame:p===rf.Always}),`whileElementsMounted`),elements:{reference:g.anchor},middleware:[Gd({mainAxis:i+w,alignmentAxis:o}),c&&Kd({mainAxis:!0,crossAxis:!1,...d===nf.Partial?{limiter:qd()}:{},...k}),c&&Jd({...k}),Yd({...k,apply:tf(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),b&&Zd({element:b,padding:s}),xf({arrowWidth:C,arrowHeight:w}),f&&Xd(O?{strategy:`referenceHidden`,...k}:{strategy:`referenceHidden`,padding:k.padding,altBoundary:k.altBoundary})]}),P=g.setPlacementState;lo(()=>(P(N),()=>{P(void 0)}),[N,P]);let[ne,re]=Sf(N),ie=cs(m);lo(()=>{ee&&ie?.()},[ee,ie]);let ae=te.arrow?.x,oe=te.arrow?.y,se=te.arrow?.centerOffset!==0,[ce,le]=M.useState();return lo(()=>{_&&le(window.getComputedStyle(_).zIndex)},[_]),(0,R.jsx)(`div`,{ref:A.setFloating,"data-radix-popper-content-wrapper":``,style:{...j,transform:ee?j.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ce,"--radix-popper-transform-origin":[te.transformOrigin?.x,te.transformOrigin?.y].join(` `),...te.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,R.jsx)(mf,{scope:n,placedSide:ne,placedAlign:re,onArrowChange:x,arrowX:ae,arrowY:oe,shouldHideArrow:se,children:(0,R.jsx)(Qa.div,{"data-side":ne,"data-align":re,...h,ref:y,style:{...h.style,animation:ee?h.style?.animation:`none`}})})})},`PopperContent`)),_f=`PopperArrow`,vf={top:`bottom`,right:`left`,bottom:`top`,left:`right`},yf=M.forwardRef(tf(function(e,t){let{__scopePopper:n,...r}=e,i=hf(_f,n),a=vf[i.placedSide];return(0,R.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,R.jsx)($d,{...r,ref:t,style:{...r.style,display:`block`}})})},`PopperArrow`));function bf(e){return e!==null}tf(bf,`isNotNull`);var xf=tf(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Sf(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function Sf(e){let[t,n=`center`]=e.split(`-`);return[t,n]}tf(Sf,`getSideAndAlignFromPlacement`);var Cf=Object.defineProperty,wf=(e,t)=>Cf(e,`name`,{value:t,configurable:!0}),Tf={Horizontal:`horizontal`,Vertical:`vertical`},Ef=Tf.Horizontal,Df=Object.values(Tf),Of=M.forwardRef(wf(function(e,t){let{decorative:n,orientation:r=Ef,...i}=e,a=kf(r)?r:Ef,o=a===Tf.Vertical?a:void 0,s=n?{role:`none`}:{"aria-orientation":o,role:`separator`};return(0,R.jsx)(Qa.div,{"data-orientation":a,...s,...i,ref:t})},`Separator`));function kf(e){return Df.includes(e)}wf(kf,`isValidOrientation`);var Af=Object.defineProperty,jf=(e,t)=>Af(e,`name`,{value:t,configurable:!0}),[Mf,Nf]=so(`Tooltip`,[sf]),Pf=sf(),Ff=`TooltipProvider`,If=700,Lf=`tooltip.open`,[Rf,zf]=Mf(Ff),Bf=jf(e=>{let{__scopeTooltip:t,delayDuration:n=If,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=M.useRef(!0),s=M.useRef(!1),c=M.useRef(0);return M.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,R.jsx)(Rf,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:M.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:M.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:M.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})},`TooltipProvider`),Vf=`Tooltip`,[Hf,Uf]=Mf(Vf),Wf=jf(e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=zf(Vf,e.__scopeTooltip),l=Pf(t),[u,d]=M.useState(null),[f,p]=M.useState(void 0),m=Wo(),h=M.useRef(0),g=o??c.disableHoverableContent,_=s??c.delayDuration,v=M.useRef(!1),[y,b]=Do({prop:r,defaultProp:i??!1,onChange:jf(e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(Lf))):c.onClose(),a?.(e)},`onChange`),caller:Vf}),x=M.useMemo(()=>y?v.current?`delayed-open`:`instant-open`:`closed`,[y]),S=M.useCallback(()=>{window.clearTimeout(h.current),h.current=0,v.current=!1,b(!0)},[b]),C=M.useCallback(()=>{window.clearTimeout(h.current),h.current=0,b(!1)},[b]),w=M.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{v.current=!0,b(!0),h.current=0},_)},[_,b]);M.useEffect(()=>()=>{h.current&&=(window.clearTimeout(h.current),0)},[]);let T=f??m;return(0,R.jsx)(uf,{...l,children:(0,R.jsx)(Hf,{scope:t,contentId:T,setContentId:p,open:y,stateAttribute:x,trigger:u,onTriggerChange:d,onTriggerEnter:M.useCallback(()=>{c.isOpenDelayedRef.current?w():S()},[c.isOpenDelayedRef,w,S]),onTriggerLeave:M.useCallback(()=>{g?C():(window.clearTimeout(h.current),h.current=0)},[C,g]),onOpen:S,onClose:C,disableHoverableContent:g,children:n})})},`Tooltip`),Gf=`TooltipTrigger`,J=M.forwardRef(jf(function(e,t){let{__scopeTooltip:n,"aria-describedby":r,...i}=e,a=Uf(Gf,n),o=zf(Gf,n),s=Pf(n),c=V(t,M.useRef(null),a.onTriggerChange),l=M.useRef(!1),u=M.useRef(!1),d=M.useCallback(()=>l.current=!1,[]);return M.useEffect(()=>()=>document.removeEventListener(`pointerup`,d),[d]),(0,R.jsx)(ff,{asChild:!0,...s,children:(0,R.jsx)(Qa.button,{"aria-describedby":a.open?cp(r,a.contentId):r,"data-state":a.stateAttribute,...i,ref:c,onPointerMove:mo(e.onPointerMove,e=>{e.pointerType!==`touch`&&!u.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),u.current=!0)}),onPointerLeave:mo(e.onPointerLeave,()=>{a.onTriggerLeave(),u.current=!1}),onPointerDown:mo(e.onPointerDown,()=>{a.open&&a.onClose(),l.current=!0,document.addEventListener(`pointerup`,d,{once:!0})}),onFocus:mo(e.onFocus,()=>{l.current||a.onOpen()}),onBlur:mo(e.onBlur,a.onClose),onClick:mo(e.onClick,a.onClose)})})},`TooltipTrigger`)),Kf=`TooltipPortal`,[qf,Jf]=Mf(Kf,{forceMount:void 0}),Yf=jf(e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=Uf(Kf,t);return(0,R.jsx)(qf,{scope:t,forceMount:n,children:(0,R.jsx)(Fo,{present:n||a.open,children:(0,R.jsx)(Gs,{asChild:!0,container:i,children:r})})})},`TooltipPortal`),Xf=`TooltipContent`,Zf=M.forwardRef(jf(function(e,t){let n=Jf(Xf,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=Uf(Xf,e.__scopeTooltip);return(0,R.jsx)(Fo,{present:r||o.open,children:o.disableHoverableContent?(0,R.jsx)(ep,{side:i,...a,ref:t}):(0,R.jsx)(Qf,{side:i,...a,ref:t})})},`TooltipContent`)),Qf=M.forwardRef(jf(function(e,t){let n=Uf(Xf,e.__scopeTooltip),r=zf(Xf,e.__scopeTooltip),i=M.useRef(null),a=V(t,i),[o,s]=M.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=M.useCallback(()=>{s(null),d(!1)},[d]),p=M.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=rp(r,np(r,n.getBoundingClientRect())),a=ip(t.getBoundingClientRect()),o=op([...i,...a]);s(o),d(!0)},[d]);return M.useEffect(()=>()=>f(),[f]),M.useEffect(()=>{if(c&&u){let e=jf(e=>p(e,u),`handleTriggerLeave`),t=jf(e=>p(e,c),`handleContentLeave`);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),M.useEffect(()=>{if(o){let e=jf(e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!ap(n,o);r?f():i&&(f(),l())},`handleTrackPointerGrace`);return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,R.jsx)(ep,{...e,ref:a})},`TooltipContentHoverable`)),$f=Ia(`TooltipContent`),ep=M.forwardRef(jf(function(e,t){let{__scopeTooltip:n,children:r,"aria-label":i,id:a,onEscapeKeyDown:o,onPointerDownOutside:s,...c}=e,l=Uf(Xf,n),u=Pf(n),{onClose:d}=l,[f,p]=M.useState(null),m=V(t,p);Ms(f),M.useEffect(()=>(document.addEventListener(Lf,d),()=>document.removeEventListener(Lf,d)),[d]),M.useEffect(()=>{if(l.trigger){let e=jf(e=>{e.target instanceof Node&&e.target.contains(l.trigger)&&d()},`handleScroll`);return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[l.trigger,d]);let{setContentId:h}=l;return lo(()=>(h(a),()=>{h(void 0)}),[a,h]),(0,R.jsx)(gs,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:d,children:(0,R.jsxs)(gf,{"data-state":l.stateAttribute,role:i?void 0:`tooltip`,id:i?void 0:l.contentId,...u,...c,ref:m,style:{...c.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,R.jsx)($f,{children:r}),i?(0,R.jsx)(ro,{id:l.contentId,role:`tooltip`,children:i}):null]})})},`TooltipContentImpl`)),tp=M.forwardRef(jf(function(e,t){let{__scopeTooltip:n,...r}=e,i=Pf(n);return(0,R.jsx)(yf,{...i,...r,ref:t})},`TooltipArrow`));function np(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}jf(np,`getExitSideFromRect`);function rp(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}jf(rp,`getPaddedExitPoints`);function ip(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}jf(ip,`getPointsFromRect`);function ap(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}jf(ap,`isPointInPolygon`);function op(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),sp(t)}jf(op,`getHull`);function sp(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}jf(sp,`getHullPresorted`);function cp(...e){let t=new Set;for(let n of e)if(typeof n==`string`)for(let e of String(n).trim().split(/\s+/))e&&t.add(e);return t.size>0?Array.from(t).join(` `):void 0}jf(cp,`concatAriaDescribedby`);var lp=768;function up(){let[e,t]=M.useState(()=>typeof window<`u`?window.innerWidth<lp:void 0);return M.useEffect(()=>{let e=window.matchMedia(`(max-width: 767px)`),n=()=>{t(window.innerWidth<lp)};return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),!!e}var dp=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},fp=(e,t)=>({classGroupId:e,validator:t}),pp=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),mp=`-`,hp=[],gp=`arbitrary..`,_p=e=>{let t=bp(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return yp(e);let n=e.split(mp);return vp(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?dp(i,t):t:i||hp}return n[e]||hp}}},vp=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=vp(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(mp):e.slice(t).join(mp),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},yp=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?gp+r:void 0})(),bp=e=>{let{theme:t,classGroups:n}=e;return xp(n,t)},xp=(e,t)=>{let n=pp();for(let r in e){let i=e[r];Sp(i,n,r,t)}return n},Sp=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];Cp(i,t,n,r)}},Cp=(e,t,n,r)=>{typeof e==`string`?wp(e,t,n):typeof e==`function`?Tp(e,t,n,r):Ep(e,t,n,r)},wp=(e,t,n)=>{let r=e===``?t:Dp(t,e);r.classGroupId=n},Tp=(e,t,n,r)=>{Op(e)?Sp(e(r),t,n,r):(t.validators===null&&(t.validators=[]),t.validators.push(fp(n,e)))},Ep=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];Sp(o,Dp(t,a),n,r)}},Dp=(e,t)=>{let n=e,r=t.split(mp),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=pp(),n.nextPart.set(t,i)),n=i}return n},Op=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,kp=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},Ap=`!`,jp=`:`,Mp=[],Np=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),Pp=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===jp){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(Ap)?(c=s.slice(0,-1),l=!0):s.startsWith(Ap)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return Np(t,l,c,u)};if(t){let e=t+jp,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):Np(Mp,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},Fp=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},Ip=e=>({cache:kp(e.cacheSize),parseClassName:Pp(e),sortModifiers:Fp(e),postfixLookupClassGroupIds:Lp(e),..._p(e)}),Lp=e=>{let t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let e=0;e<n.length;e++)t[n[e]]=!0;return t},Rp=/\s+/,zp=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a,postfixLookupClassGroupIds:o}=t,s=[],c=e.trim().split(Rp),l=``;for(let e=c.length-1;e>=0;--e){let t=c[e],{isExternal:u,modifiers:d,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:m}=n(t);if(u){l=t+(l.length>0?` `+l:l);continue}let h=!!m,g;if(h){g=r(p.substring(0,m));let e=g&&o[g]?r(p):void 0;e&&e!==g&&(g=e,h=!1)}else g=r(p);if(!g){if(!h||(g=r(p),!g)){l=t+(l.length>0?` `+l:l);continue}h=!1}let _=d.length===0?``:d.length===1?d[0]:a(d).join(`:`),v=f?_+Ap:_,y=v+g;if(s.indexOf(y)>-1)continue;s.push(y);let b=i(g,h);for(let e=0;e<b.length;++e){let t=b[e];s.push(v+t)}l=t+(l.length>0?` `+l:l)}return l},Bp=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=Vp(n))&&(i&&(i+=` `),i+=r);return i},Vp=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=Vp(e[r]))&&(n&&(n+=` `),n+=t);return n},Hp=(e,...t)=>{let n,r,i,a,o=o=>(n=Ip(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=zp(e,n);return i(e,a),a};return a=o,(...e)=>a(Bp(...e))},Up=[],Wp=e=>{let t=t=>t[e]||Up;return t.isThemeGetter=!0,t.themeKey=e,t},Gp=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Kp=/^\((?:(\w[\w-]*):)?(.+)\)$/i,qp=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Jp=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Yp=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Xp=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,Zp=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Qp=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,$p=e=>qp.test(e),Y=e=>!!e&&!Number.isNaN(Number(e)),em=e=>!!e&&Number.isInteger(Number(e)),tm=e=>e.endsWith(`%`)&&Y(e.slice(0,-1)),nm=e=>Jp.test(e),rm=()=>!0,im=e=>Yp.test(e)&&!Xp.test(e),am=()=>!1,om=e=>Zp.test(e),sm=e=>Qp.test(e),cm=e=>!X(e)&&!Z(e),lm=e=>e.startsWith(`@container`)&&(e[10]===`/`&&e[11]!==void 0||e[11]===`s`&&e[16]!==void 0&&e.startsWith(`-size/`,10)||e[11]===`n`&&e[18]!==void 0&&e.startsWith(`-normal/`,10)),um=e=>Tm(e,km,am),X=e=>Gp.test(e),dm=e=>Tm(e,Am,im),fm=e=>Tm(e,jm,Y),pm=e=>Tm(e,Nm,rm),mm=e=>Tm(e,Mm,am),hm=e=>Tm(e,Dm,am),gm=e=>Tm(e,Om,sm),_m=e=>Tm(e,Pm,om),Z=e=>Kp.test(e),vm=e=>Em(e,Am),ym=e=>Em(e,Mm),bm=e=>Em(e,Dm),xm=e=>Em(e,km),Sm=e=>Em(e,Om),Cm=e=>Em(e,Pm,!0),wm=e=>Em(e,Nm,!0),Tm=(e,t,n)=>{let r=Gp.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Em=(e,t,n=!1)=>{let r=Kp.exec(e);return r?r[1]?t(r[1]):n:!1},Dm=e=>e===`position`||e===`percentage`,Om=e=>e===`image`||e===`url`,km=e=>e===`length`||e===`size`||e===`bg-size`,Am=e=>e===`length`,jm=e=>e===`number`,Mm=e=>e===`family-name`,Nm=e=>e===`number`||e===`weight`,Pm=e=>e===`shadow`,Fm=Hp(()=>{let e=Wp(`color`),t=Wp(`font`),n=Wp(`text`),r=Wp(`font-weight`),i=Wp(`tracking`),a=Wp(`leading`),o=Wp(`breakpoint`),s=Wp(`container`),c=Wp(`spacing`),l=Wp(`radius`),u=Wp(`shadow`),d=Wp(`inset-shadow`),f=Wp(`text-shadow`),p=Wp(`drop-shadow`),m=Wp(`blur`),h=Wp(`perspective`),g=Wp(`aspect`),_=Wp(`ease`),v=Wp(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),Z,X],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[Z,X,c],T=()=>[$p,`full`,`auto`,...w()],E=()=>[em,`none`,`subgrid`,Z,X],D=()=>[`auto`,{span:[`full`,em,Z,X]},em,Z,X],O=()=>[em,`auto`,Z,X],k=()=>[`auto`,`min`,`max`,`fr`,Z,X],A=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],j=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],M=()=>[`auto`,...w()],N=()=>[$p,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],ee=()=>[s,$p,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...w()],te=()=>[$p,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...w()],P=()=>[e,Z,X],ne=()=>[...b(),bm,hm,{position:[Z,X]}],re=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],ie=()=>[`auto`,`cover`,`contain`,xm,um,{size:[Z,X]}],ae=()=>[tm,vm,dm],oe=()=>[``,`none`,`full`,l,Z,X],se=()=>[``,Y,vm,dm],ce=()=>[`solid`,`dashed`,`dotted`,`double`],le=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],ue=()=>[Y,tm,bm,hm],de=()=>[``,`none`,m,Z,X],fe=()=>[`none`,Y,Z,X],pe=()=>[`none`,Y,Z,X],me=()=>[Y,Z,X],he=()=>[$p,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[nm],breakpoint:[nm],color:[rm],container:[nm],"drop-shadow":[nm],ease:[`in`,`out`,`in-out`],font:[cm],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[nm],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[nm],shadow:[nm],spacing:[`px`,Y],text:[nm],"text-shadow":[nm],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,$p,X,Z,g]}],container:[`container`],"container-type":[{"@container":[``,`normal`,`size`,Z,X]}],"container-named":[lm],columns:[{columns:[Y,`auto`,X,Z,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{"inset-s":T(),start:T()}],end:[{"inset-e":T(),end:T()}],"inset-bs":[{"inset-bs":T()}],"inset-be":[{"inset-be":T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[em,`auto`,Z,X]}],basis:[{basis:[$p,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[Y,$p,`auto`,`initial`,`none`,X]}],grow:[{grow:[``,Y,Z,X]}],shrink:[{shrink:[``,Y,Z,X]}],order:[{order:[em,`first`,`last`,`none`,Z,X]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":k()}],"auto-rows":[{"auto-rows":k()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...A(),`normal`]}],"justify-items":[{"justify-items":[...j(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...j()]}],"align-content":[{content:[`normal`,...A()]}],"align-items":[{items:[...j(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...j(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":A()}],"place-items":[{"place-items":[...j(),`baseline`]}],"place-self":[{"place-self":[`auto`,...j()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pbs:[{pbs:w()}],pbe:[{pbe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:M()}],mx:[{mx:M()}],my:[{my:M()}],ms:[{ms:M()}],me:[{me:M()}],mbs:[{mbs:M()}],mbe:[{mbe:M()}],mt:[{mt:M()}],mr:[{mr:M()}],mb:[{mb:M()}],ml:[{ml:M()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:N()}],"inline-size":[{inline:[`auto`,...ee()]}],"min-inline-size":[{"min-inline":[`auto`,...ee()]}],"max-inline-size":[{"max-inline":[`none`,...ee()]}],"block-size":[{block:[`auto`,...te()]}],"min-block-size":[{"min-block":[`auto`,...te()]}],"max-block-size":[{"max-block":[`none`,...te()]}],w:[{w:[s,`screen`,...N()]}],"min-w":[{"min-w":[s,`screen`,`none`,...N()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...N()]}],h:[{h:[`screen`,`lh`,...N()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...N()]}],"max-h":[{"max-h":[`screen`,`lh`,`none`,...N()]}],"font-size":[{text:[`base`,n,vm,dm]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,wm,pm]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,tm,X]}],"font-family":[{font:[ym,mm,t]}],"font-features":[{"font-features":[X]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,Z,X]}],"line-clamp":[{"line-clamp":[Y,`none`,Z,fm]}],leading:[{leading:[`none`,a,...w()]}],"list-image":[{"list-image":[`none`,Z,X]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,Z,X]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:P()}],"text-color":[{text:P()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...ce(),`wavy`]}],"text-decoration-thickness":[{decoration:[Y,`from-font`,`auto`,Z,dm]}],"text-decoration-color":[{decoration:P()}],"underline-offset":[{"underline-offset":[Y,`auto`,Z,X]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:w()}],"tab-size":[{tab:[em,Z,X]}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,Z,X]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,Z,X]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:ne()}],"bg-repeat":[{bg:re()}],"bg-size":[{bg:ie()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},em,Z,X],radial:[``,Z,X],conic:[``,em,Z,X]},Sm,gm]}],"bg-color":[{bg:P()}],"gradient-from-pos":[{from:ae()}],"gradient-via-pos":[{via:ae()}],"gradient-to-pos":[{to:ae()}],"gradient-from":[{from:P()}],"gradient-via":[{via:P()}],"gradient-to":[{to:P()}],rounded:[{rounded:oe()}],"rounded-s":[{"rounded-s":oe()}],"rounded-e":[{"rounded-e":oe()}],"rounded-t":[{"rounded-t":oe()}],"rounded-r":[{"rounded-r":oe()}],"rounded-b":[{"rounded-b":oe()}],"rounded-l":[{"rounded-l":oe()}],"rounded-ss":[{"rounded-ss":oe()}],"rounded-se":[{"rounded-se":oe()}],"rounded-ee":[{"rounded-ee":oe()}],"rounded-es":[{"rounded-es":oe()}],"rounded-tl":[{"rounded-tl":oe()}],"rounded-tr":[{"rounded-tr":oe()}],"rounded-br":[{"rounded-br":oe()}],"rounded-bl":[{"rounded-bl":oe()}],"border-w":[{border:se()}],"border-w-x":[{"border-x":se()}],"border-w-y":[{"border-y":se()}],"border-w-s":[{"border-s":se()}],"border-w-e":[{"border-e":se()}],"border-w-bs":[{"border-bs":se()}],"border-w-be":[{"border-be":se()}],"border-w-t":[{"border-t":se()}],"border-w-r":[{"border-r":se()}],"border-w-b":[{"border-b":se()}],"border-w-l":[{"border-l":se()}],"divide-x":[{"divide-x":se()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":se()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...ce(),`hidden`,`none`]}],"divide-style":[{divide:[...ce(),`hidden`,`none`]}],"border-color":[{border:P()}],"border-color-x":[{"border-x":P()}],"border-color-y":[{"border-y":P()}],"border-color-s":[{"border-s":P()}],"border-color-e":[{"border-e":P()}],"border-color-bs":[{"border-bs":P()}],"border-color-be":[{"border-be":P()}],"border-color-t":[{"border-t":P()}],"border-color-r":[{"border-r":P()}],"border-color-b":[{"border-b":P()}],"border-color-l":[{"border-l":P()}],"divide-color":[{divide:P()}],"outline-style":[{outline:[...ce(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[Y,Z,X]}],"outline-w":[{outline:[``,Y,vm,dm]}],"outline-color":[{outline:P()}],shadow:[{shadow:[``,`inner`,`none`,u,Cm,_m]}],"shadow-color":[{shadow:P()}],"inset-shadow":[{"inset-shadow":[`none`,d,Cm,_m]}],"inset-shadow-color":[{"inset-shadow":P()}],"ring-w":[{ring:se()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:P()}],"ring-offset-w":[{"ring-offset":[Y,dm]}],"ring-offset-color":[{"ring-offset":P()}],"inset-ring-w":[{"inset-ring":se()}],"inset-ring-color":[{"inset-ring":P()}],"text-shadow":[{"text-shadow":[`none`,f,Cm,_m]}],"text-shadow-color":[{"text-shadow":P()}],opacity:[{opacity:[Y,Z,X]}],"mix-blend":[{"mix-blend":[...le(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":le()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[Y]}],"mask-image-linear-from-pos":[{"mask-linear-from":ue()}],"mask-image-linear-to-pos":[{"mask-linear-to":ue()}],"mask-image-linear-from-color":[{"mask-linear-from":P()}],"mask-image-linear-to-color":[{"mask-linear-to":P()}],"mask-image-t-from-pos":[{"mask-t-from":ue()}],"mask-image-t-to-pos":[{"mask-t-to":ue()}],"mask-image-t-from-color":[{"mask-t-from":P()}],"mask-image-t-to-color":[{"mask-t-to":P()}],"mask-image-r-from-pos":[{"mask-r-from":ue()}],"mask-image-r-to-pos":[{"mask-r-to":ue()}],"mask-image-r-from-color":[{"mask-r-from":P()}],"mask-image-r-to-color":[{"mask-r-to":P()}],"mask-image-b-from-pos":[{"mask-b-from":ue()}],"mask-image-b-to-pos":[{"mask-b-to":ue()}],"mask-image-b-from-color":[{"mask-b-from":P()}],"mask-image-b-to-color":[{"mask-b-to":P()}],"mask-image-l-from-pos":[{"mask-l-from":ue()}],"mask-image-l-to-pos":[{"mask-l-to":ue()}],"mask-image-l-from-color":[{"mask-l-from":P()}],"mask-image-l-to-color":[{"mask-l-to":P()}],"mask-image-x-from-pos":[{"mask-x-from":ue()}],"mask-image-x-to-pos":[{"mask-x-to":ue()}],"mask-image-x-from-color":[{"mask-x-from":P()}],"mask-image-x-to-color":[{"mask-x-to":P()}],"mask-image-y-from-pos":[{"mask-y-from":ue()}],"mask-image-y-to-pos":[{"mask-y-to":ue()}],"mask-image-y-from-color":[{"mask-y-from":P()}],"mask-image-y-to-color":[{"mask-y-to":P()}],"mask-image-radial":[{"mask-radial":[Z,X]}],"mask-image-radial-from-pos":[{"mask-radial-from":ue()}],"mask-image-radial-to-pos":[{"mask-radial-to":ue()}],"mask-image-radial-from-color":[{"mask-radial-from":P()}],"mask-image-radial-to-color":[{"mask-radial-to":P()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[Y]}],"mask-image-conic-from-pos":[{"mask-conic-from":ue()}],"mask-image-conic-to-pos":[{"mask-conic-to":ue()}],"mask-image-conic-from-color":[{"mask-conic-from":P()}],"mask-image-conic-to-color":[{"mask-conic-to":P()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:ne()}],"mask-repeat":[{mask:re()}],"mask-size":[{mask:ie()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,Z,X]}],filter:[{filter:[``,`none`,Z,X]}],blur:[{blur:de()}],brightness:[{brightness:[Y,Z,X]}],contrast:[{contrast:[Y,Z,X]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,Cm,_m]}],"drop-shadow-color":[{"drop-shadow":P()}],grayscale:[{grayscale:[``,Y,Z,X]}],"hue-rotate":[{"hue-rotate":[Y,Z,X]}],invert:[{invert:[``,Y,Z,X]}],saturate:[{saturate:[Y,Z,X]}],sepia:[{sepia:[``,Y,Z,X]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,Z,X]}],"backdrop-blur":[{"backdrop-blur":de()}],"backdrop-brightness":[{"backdrop-brightness":[Y,Z,X]}],"backdrop-contrast":[{"backdrop-contrast":[Y,Z,X]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,Y,Z,X]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Y,Z,X]}],"backdrop-invert":[{"backdrop-invert":[``,Y,Z,X]}],"backdrop-opacity":[{"backdrop-opacity":[Y,Z,X]}],"backdrop-saturate":[{"backdrop-saturate":[Y,Z,X]}],"backdrop-sepia":[{"backdrop-sepia":[``,Y,Z,X]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,Z,X]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[Y,`initial`,Z,X]}],ease:[{ease:[`linear`,`initial`,_,Z,X]}],delay:[{delay:[Y,Z,X]}],animate:[{animate:[`none`,v,Z,X]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,Z,X]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:fe()}],"rotate-x":[{"rotate-x":fe()}],"rotate-y":[{"rotate-y":fe()}],"rotate-z":[{"rotate-z":fe()}],scale:[{scale:pe()}],"scale-x":[{"scale-x":pe()}],"scale-y":[{"scale-y":pe()}],"scale-z":[{"scale-z":pe()}],"scale-3d":[`scale-3d`],skew:[{skew:me()}],"skew-x":[{"skew-x":me()}],"skew-y":[{"skew-y":me()}],transform:[{transform:[Z,X,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:he()}],"translate-x":[{"translate-x":he()}],"translate-y":[{"translate-y":he()}],"translate-z":[{"translate-z":he()}],"translate-none":[`translate-none`],zoom:[{zoom:[em,Z,X]}],accent:[{accent:P()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:P()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,Z,X]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scrollbar-thumb-color":[{"scrollbar-thumb":P()}],"scrollbar-track-color":[{"scrollbar-track":P()}],"scrollbar-gutter":[{"scrollbar-gutter":[`auto`,`stable`,`both`]}],"scrollbar-w":[{scrollbar:[`auto`,`thin`,`none`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mbs":[{"scroll-mbs":w()}],"scroll-mbe":[{"scroll-mbe":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pbs":[{"scroll-pbs":w()}],"scroll-pbe":[{"scroll-pbe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,Z,X]}],fill:[{fill:[`none`,...P()]}],"stroke-w":[{stroke:[Y,vm,dm,fm]}],stroke:[{stroke:[`none`,...P()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{"container-named":[`container-type`],overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`inset-bs`,`inset-be`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`start`,`end`,`right`,`left`],"inset-y":[`inset-bs`,`inset-be`,`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pbs`,`pbe`,`pt`,`pr`,`pb`,`pl`],px:[`ps`,`pe`,`pr`,`pl`],py:[`pbs`,`pbe`,`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mbs`,`mbe`,`mt`,`mr`,`mb`,`ml`],mx:[`ms`,`me`,`mr`,`ml`],my:[`mbs`,`mbe`,`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-s`,`border-w-e`,`border-w-r`,`border-w-l`],"border-w-y":[`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-s`,`border-color-e`,`border-color-r`,`border-color-l`],"border-color-y":[`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-ms`,`scroll-me`,`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-ps`,`scroll-pe`,`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},postfixLookupClassGroups:[`container-type`],orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function Q(...e){return Fm(qr(e))}var Im=Xr(`inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[1.5px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/90`,destructive:`bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40`,outline:`border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-9 px-4 py-2 has-[>svg]:px-3`,xs:`h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5`,lg:`h-10 rounded-md px-6 has-[>svg]:px-4`,icon:`size-9`,"icon-xs":`size-6 rounded-md [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-8`,"icon-lg":`size-10`}},defaultVariants:{variant:`default`,size:`default`}});function Lm({className:e,variant:t=`default`,size:n=`default`,asChild:r=!1,...i}){let a=r?Pa:`button`;return(0,R.jsx)(a,{"data-slot":`button`,"data-variant":t,"data-size":n,className:Q(Im({variant:t,size:n,className:e})),...i})}function Rm({className:e,type:t,...n}){return(0,R.jsx)(`input`,{type:t,"data-slot":`input`,className:Q(`h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none selection:bg-primary selection:text-primary-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:bg-input/30`,`focus-visible:border-ring focus-visible:ring-[1.5px] focus-visible:ring-ring/50`,`aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40`,e),...n})}function zm({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,R.jsx)(Of,{"data-slot":`separator`,decorative:n,orientation:t,className:Q(`shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px`,e),...r})}function Bm({...e}){return(0,R.jsx)(Cl,{"data-slot":`sheet`,...e})}function Vm({...e}){return(0,R.jsx)(Dl,{"data-slot":`sheet-portal`,...e})}function Hm({className:e,...t}){return(0,R.jsx)(kl,{"data-slot":`sheet-overlay`,className:Q(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function Um({className:e,children:t,side:n=`right`,showCloseButton:r=!0,...i}){return(0,R.jsxs)(Vm,{children:[(0,R.jsx)(Hm,{}),(0,R.jsxs)(Nl,{"data-slot":`sheet-content`,className:Q(`fixed z-50 flex flex-col gap-4 bg-background shadow-lg transition ease-in-out data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:animate-in data-[state=open]:duration-500`,n===`right`&&`inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm`,n===`left`&&`inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm`,n===`top`&&`inset-x-0 top-0 h-auto border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top`,n===`bottom`&&`inset-x-0 bottom-0 h-auto border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom`,e),...i,children:[t,r&&(0,R.jsxs)(Bl,{className:`absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-secondary`,children:[(0,R.jsx)(wa,{className:`size-4`}),(0,R.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function Wm({className:e,...t}){return(0,R.jsx)(`div`,{"data-slot":`sheet-header`,className:Q(`flex flex-col gap-1.5 p-4`,e),...t})}function Gm({className:e,...t}){return(0,R.jsx)(Ll,{"data-slot":`sheet-title`,className:Q(`font-semibold text-foreground`,e),...t})}function Km({className:e,...t}){return(0,R.jsx)(Rl,{"data-slot":`sheet-description`,className:Q(`text-sm text-muted-foreground`,e),...t})}function qm({delayDuration:e=0,...t}){return(0,R.jsx)(Bf,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Jm({...e}){return(0,R.jsx)(Wf,{"data-slot":`tooltip`,...e})}function Ym({...e}){return(0,R.jsx)(J,{"data-slot":`tooltip-trigger`,...e})}function Xm({className:e,sideOffset:t=0,children:n,...r}){return(0,R.jsx)(Yf,{children:(0,R.jsxs)(Zf,{"data-slot":`tooltip-content`,sideOffset:t,className:Q(`z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-foreground px-3 py-1.5 text-xs text-balance text-background fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95`,e),...r,children:[n,(0,R.jsx)(tp,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground`})]})})}var Zm=`sidebar_state`,Qm=604800,$m=`16rem`,eh=`18rem`,th=`3rem`,nh=`b`,rh=M.createContext(null);function ih(){let e=M.use(rh);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function ah({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:a,...o}){let s=up(),[c,l]=M.useState(!1),[u,d]=M.useState(e),f=t??u,p=M.useCallback(e=>{let t=typeof e==`function`?e(f):e;n?n(t):d(t),document.cookie=`${Zm}=${t}; path=/; max-age=${Qm}`},[n,f]),m=M.useCallback(()=>s?l(e=>!e):p(e=>!e),[s,p,l]);M.useEffect(()=>{let e=e=>{e.key===nh&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),m())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[m]);let h=f?`expanded`:`collapsed`,g=M.useMemo(()=>({state:h,open:f,setOpen:p,isMobile:s,openMobile:c,setOpenMobile:l,toggleSidebar:m}),[h,f,p,s,c,l,m]);return(0,R.jsx)(rh.Provider,{value:g,children:(0,R.jsx)(qm,{delayDuration:0,children:(0,R.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:{"--sidebar-width":$m,"--sidebar-width-icon":th,...i},className:Q(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),...o,children:a})})})}function oh({side:e=`left`,variant:t=`sidebar`,collapsible:n=`offcanvas`,className:r,children:i,...a}){let{isMobile:o,state:s,openMobile:c,setOpenMobile:l}=ih();return n===`none`?(0,R.jsx)(`div`,{"data-slot":`sidebar`,className:Q(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,r),...a,children:i}):o?(0,R.jsx)(Bm,{open:c,onOpenChange:l,...a,children:(0,R.jsxs)(Um,{"data-sidebar":`sidebar`,"data-slot":`sidebar`,"data-mobile":`true`,className:`w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden`,style:{"--sidebar-width":eh},side:e,children:[(0,R.jsxs)(Wm,{className:`sr-only`,children:[(0,R.jsx)(Gm,{children:`Sidebar`}),(0,R.jsx)(Km,{children:`Displays the mobile sidebar.`})]}),(0,R.jsx)(`div`,{className:`flex h-full w-full flex-col`,children:i})]})}):(0,R.jsxs)(`div`,{className:`group peer hidden text-sidebar-foreground md:block`,"data-state":s,"data-collapsible":s===`collapsed`?n:``,"data-variant":t,"data-side":e,"data-slot":`sidebar`,children:[(0,R.jsx)(`div`,{"data-slot":`sidebar-gap`,className:Q(`relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear`,`group-data-[collapsible=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,t===`floating`||t===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`)}),(0,R.jsx)(`div`,{"data-slot":`sidebar-container`,className:Q(`fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex`,e===`left`?`left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]`:`right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]`,t===`floating`||t===`inset`?`p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l`,r),...a,children:(0,R.jsx)(`div`,{"data-sidebar":`sidebar`,"data-slot":`sidebar-inner`,className:`flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow-sm`,children:i})})]})}function sh({className:e,onClick:t,...n}){let{toggleSidebar:r}=ih();return(0,R.jsxs)(Lm,{"data-sidebar":`trigger`,"data-slot":`sidebar-trigger`,variant:`ghost`,size:`icon`,className:Q(`size-7`,e),onClick:e=>{t?.(e),r()},...n,children:[(0,R.jsx)(qi,{}),(0,R.jsx)(`span`,{className:`sr-only`,children:`Toggle Sidebar`})]})}function ch({className:e,...t}){return(0,R.jsx)(`main`,{"data-slot":`sidebar-inset`,className:Q(`relative flex w-full flex-1 flex-col bg-background`,`md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2`,e),...t})}function lh({className:e,...t}){return(0,R.jsx)(`div`,{"data-slot":`sidebar-header`,"data-sidebar":`header`,className:Q(`flex flex-col gap-2 p-2`,e),...t})}function uh({className:e,...t}){return(0,R.jsx)(`div`,{"data-slot":`sidebar-footer`,"data-sidebar":`footer`,className:Q(`flex flex-col gap-2 p-2`,e),...t})}function dh({className:e,...t}){return(0,R.jsx)(zm,{"data-slot":`sidebar-separator`,"data-sidebar":`separator`,className:Q(`mx-2 w-auto bg-sidebar-border`,e),...t})}function fh({className:e,...t}){return(0,R.jsx)(`div`,{"data-slot":`sidebar-content`,"data-sidebar":`content`,className:Q(`flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden`,e),...t})}function ph({className:e,...t}){return(0,R.jsx)(`div`,{"data-slot":`sidebar-group`,"data-sidebar":`group`,className:Q(`relative flex w-full min-w-0 flex-col p-2`,e),...t})}function mh({className:e,...t}){return(0,R.jsx)(`div`,{"data-slot":`sidebar-group-content`,"data-sidebar":`group-content`,className:Q(`w-full text-sm`,e),...t})}function hh({className:e,...t}){return(0,R.jsx)(`ul`,{"data-slot":`sidebar-menu`,"data-sidebar":`menu`,className:Q(`flex w-full min-w-0 flex-col gap-1`,e),...t})}function gh({className:e,...t}){return(0,R.jsx)(`li`,{"data-slot":`sidebar-menu-item`,"data-sidebar":`menu-item`,className:Q(`group/menu-item relative`,e),...t})}var _h=Xr(`peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0`,{variants:{variant:{default:`hover:bg-sidebar-accent hover:text-sidebar-accent-foreground`,outline:`bg-background shadow-[0_0_0_1px_var(--sidebar-border)] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_var(--sidebar-accent)]`},size:{default:`h-8 text-sm`,sm:`h-7 text-xs`,lg:`h-12 text-sm group-data-[collapsible=icon]:p-0!`}},defaultVariants:{variant:`default`,size:`default`}});function vh({asChild:e=!1,isActive:t=!1,variant:n=`default`,size:r=`default`,tooltip:i,className:a,...o}){let s=e?Pa:`button`,{isMobile:c,state:l}=ih(),u=(0,R.jsx)(s,{"data-slot":`sidebar-menu-button`,"data-sidebar":`menu-button`,"data-size":r,"data-active":t,className:Q(_h({variant:n,size:r}),a),...o});return i?(typeof i==`string`&&(i={children:i}),(0,R.jsxs)(Jm,{children:[(0,R.jsx)(Ym,{asChild:!0,children:u}),(0,R.jsx)(Xm,{side:`right`,align:`center`,hidden:l!==`collapsed`||c,...i})]})):u}function yh({className:e,...t}){return(0,R.jsx)(`div`,{"data-slot":`sidebar-menu-badge`,"data-sidebar":`menu-badge`,className:Q(`pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium text-sidebar-foreground tabular-nums select-none`,`peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground`,`peer-data-[size=sm]/menu-button:top-1`,`peer-data-[size=default]/menu-button:top-1.5`,`peer-data-[size=lg]/menu-button:top-2.5`,`group-data-[collapsible=icon]:hidden`,e),...t})}function bh(){let e=pt(),{workspace:t,dirty:n}=vr(),{ragStatus:r}=jr(),i=xh(e.pathname),a=r?.hasIndex&&!r.stale;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`crumbs`,children:[i.map((e,t)=>(0,R.jsxs)(`span`,{children:[t>0&&(0,R.jsx)(`span`,{className:`sep`,style:{marginRight:8},children:`/`}),(0,R.jsx)(`span`,{className:t===i.length-1?`crumb cur`:`crumb`,children:e})]},e)),n&&(0,R.jsxs)(`span`,{className:`pill warn`,style:{marginLeft:8},children:[(0,R.jsx)(`span`,{style:{width:6,height:6,borderRadius:`50%`,background:`var(--amber-500)`}}),`Unsaved changes`]}),!n&&t&&i.some(e=>e===`Enrichment`||e===`Schema`)&&(0,R.jsxs)(`span`,{className:`pill ok`,style:{marginLeft:8},children:[(0,R.jsx)(pi,{size:10}),`Saved`]})]}),(0,R.jsxs)(`div`,{className:`right`,children:[(0,R.jsxs)(`div`,{className:`cmd-palette`,children:[(0,R.jsx)(ca,{size:13}),(0,R.jsx)(`span`,{style:{flex:1},children:`Search tables, concepts, queries…`}),(0,R.jsx)(`span`,{className:`kbd`,children:`⌘K`})]}),r&&(0,R.jsxs)(`span`,{className:`pill ${a?`ok`:`warn`}`,children:[(0,R.jsx)(`span`,{style:{width:6,height:6,borderRadius:`50%`,background:a?`var(--green-500)`:`var(--amber-500)`}}),a?`Index fresh`:r.hasIndex?`Index stale`:`No index`]})]})]})}function xh(e){let t=e.split(`/`).filter(Boolean);if(t.length===0)return[`Overview`];let n=t[0],r=[];switch(n){case`overview`:r.push(`Overview`);break;case`tables`:r.push(`Tables`),t[1]&&r.push(t[1]),t[2]&&r.push(t[2]),t[3]&&r.push(Sh(t[3]));break;case`concepts`:r.push(`Concepts`);break;case`tenancy`:r.push(`Tenancy`),t[1]&&r.push(Sh(t[1]));break;case`rag-index`:r.push(`RAG Index`),t[1]&&r.push(Sh(t[1]));break;case`playground`:r.push(`Playground`),t[1]&&r.push(`Query`);break;case`settings`:r.push(`Settings`);break;default:r.push(Sh(n))}return r}function Sh(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Ch=[{to:`/overview`,label:`Overview`,icon:zi},{to:`/tables`,label:`Tables`,icon:va,badgeKey:`tables`},{to:`/concepts`,label:`Concepts`,icon:Li,badgeKey:`concepts`},{to:`/tenancy`,label:`Tenancy`,icon:fa},{to:`/rag-index`,label:`RAG Index`,icon:ma},{to:`/playground`,label:`Playground`,icon:Zi}];function wh(){let{workspace:e}=vr(),{theme:t,toggleTheme:n}=Hn();function r(t){if(e&&t){if(t===`tables`)return String(e.tables.length);if(t===`concepts`)return String(e.concepts.length)}}return(0,R.jsxs)(oh,{collapsible:`icon`,className:`border-r`,children:[(0,R.jsx)(lh,{className:`px-2 py-2`,children:(0,R.jsx)(hh,{children:(0,R.jsx)(gh,{children:(0,R.jsx)(vh,{size:`lg`,asChild:!0,tooltip:`AskDB Studio`,children:(0,R.jsxs)(`a`,{href:`/`,className:`no-underline`,children:[(0,R.jsx)(`div`,{className:`flex aspect-square size-8 items-center justify-center shrink-0`,children:(0,R.jsx)(`img`,{src:t===`dark`?`/assets/brand/dark-icon.png`:`/assets/brand/light-icon.png`,alt:`AskDB`,className:`size-7`})}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-0.5 leading-none`,children:[(0,R.jsx)(`span`,{className:`font-semibold`,children:`AskDB`}),(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Studio`})]})]})})})})}),(0,R.jsx)(fh,{children:(0,R.jsx)(ph,{children:(0,R.jsx)(mh,{children:(0,R.jsx)(hh,{children:Ch.map(e=>{let t=e.icon,n=r(e.badgeKey);return(0,R.jsxs)(gh,{children:[(0,R.jsx)(vh,{asChild:!0,tooltip:e.label,children:(0,R.jsxs)(Dn,{to:e.to,children:[(0,R.jsx)(t,{}),(0,R.jsx)(`span`,{children:e.label})]})}),n&&(0,R.jsx)(yh,{children:n})]},e.to)})})})})}),(0,R.jsxs)(uh,{children:[(0,R.jsxs)(hh,{children:[(0,R.jsx)(gh,{children:(0,R.jsx)(vh,{asChild:!0,tooltip:`Settings`,children:(0,R.jsxs)(Dn,{to:`/settings`,children:[(0,R.jsx)(ua,{}),(0,R.jsx)(`span`,{children:`Settings`})]})})}),(0,R.jsx)(gh,{children:(0,R.jsxs)(vh,{tooltip:t===`light`?`Dark mode`:`Light mode`,onClick:n,children:[t===`light`?(0,R.jsx)(Gi,{}):(0,R.jsx)(ga,{}),(0,R.jsx)(`span`,{children:t===`light`?`Dark mode`:`Light mode`})]})})]}),(0,R.jsx)(dh,{}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 text-xs text-muted-foreground group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:px-0`,children:[(0,R.jsx)(ki,{size:14,className:`shrink-0`}),(0,R.jsx)(`span`,{className:`truncate font-mono group-data-[collapsible=icon]:hidden`,children:e?`${e.aiProvider||`postgres`} · ${e.schemaId.split(`/`).pop()||e.schemaId}`:`connecting…`})]})]})]})}function Th({dialog:e,onApply:t,onClose:n}){return(0,R.jsx)(`div`,{className:`dialog-overlay`,onClick:n,"aria-hidden":`true`,children:(0,R.jsxs)(`div`,{className:`dialog`,onClick:e=>e.stopPropagation(),children:[(0,R.jsxs)(`div`,{className:`dialog-hd`,children:[(0,R.jsxs)(`h3`,{children:[`Suggestions for `,e.label]}),(0,R.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:n,"aria-label":`Close`,children:(0,R.jsx)(wa,{size:14})})]}),(0,R.jsx)(`div`,{className:`dialog-bd`,children:e.candidates.map(e=>(0,R.jsxs)(`article`,{className:`candidate`,children:[(0,R.jsx)(`p`,{children:e.text}),(0,R.jsx)(`div`,{className:`candidate-actions`,children:(0,R.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:()=>t(e.text),children:`Use`})})]},e.text))})]})})}function Eh({status:e}){return(0,R.jsxs)(`div`,{className:`status-banner ${e.kind}`,children:[e.kind===`loading`&&(0,R.jsx)(Vi,{size:14,className:`animate-spin`}),e.kind===`success`&&(0,R.jsx)(pi,{size:14}),e.kind===`error`&&(0,R.jsx)(Ci,{size:14}),(0,R.jsx)(`span`,{children:e.text})]})}function Dh({status:e}){return(0,R.jsxs)(`div`,{className:`inline-status ${e.kind}`,children:[e.kind===`loading`&&(0,R.jsx)(Vi,{size:12,className:`animate-spin`}),e.kind===`success`&&(0,R.jsx)(pi,{size:12}),e.kind===`error`&&(0,R.jsx)(Ci,{size:12}),(0,R.jsx)(`span`,{children:e.text})]})}function Oh(){let e=ht(),{workspace:t,tables:n,load:r}=vr(),{ragStatus:i,refreshRagStatus:a}=jr(),{historyEntries:o}=Rr(),[s,c]=(0,M.useState)(!1),[l,u]=(0,M.useState)(null),d=(0,M.useCallback)(async()=>{c(!0),u({kind:`loading`,text:`Re-introspecting…`});try{let e=await cr();await r(),a(),u({kind:`success`,text:`Re-introspected ${e.tables} table${e.tables===1?``:`s`} from ${e.engine} — enrichment preserved.`})}catch(e){u({kind:`error`,text:e instanceof Error?e.message:String(e)})}finally{c(!1)}},[r,a]),f=(0,M.useEffectEvent)(()=>u(null));if((0,M.useEffect)(()=>{if(l?.kind===`success`){let e=setTimeout(()=>f(),4e3);return()=>clearTimeout(e)}},[l]),!t)return null;let p=n.filter(e=>{let t=e.draft,n=t.description||t.aliases&&t.aliases.length>0,r=Object.values(t.columns??{}).every(e=>e.description);return n&&r}).length,m=n.filter(e=>{let t=e.draft,n=t.description||t.aliases&&t.aliases.length>0,r=Object.values(t.columns??{}).every(e=>e.description);return n&&!r}).length,h=!!t.tenantPolicy;return(0,R.jsxs)(`main`,{className:`main-pane`,children:[(0,R.jsxs)(`div`,{className:`main-hd`,children:[(0,R.jsxs)(`div`,{className:`main-title`,children:[(0,R.jsx)(`h1`,{children:`Overview`}),(0,R.jsxs)(`div`,{className:`main-sub`,children:[t.aiProvider||`postgres`,` · `,t.schemaId]})]}),(0,R.jsxs)(`div`,{className:`main-actions`,children:[(0,R.jsxs)(`button`,{type:`button`,className:`btn`,disabled:s,title:`Re-run introspection with the connection from askdb.config.ts. Your enrichment is preserved.`,onClick:()=>void d(),children:[s?(0,R.jsx)(Vi,{size:14,className:`animate-spin`}):(0,R.jsx)(ta,{size:14}),` Resync schema`]}),(0,R.jsxs)(`button`,{type:`button`,className:`btn primary`,onClick:()=>e(`/tables`),children:[(0,R.jsx)(ma,{size:14}),` Draft enrichment`]})]})]}),(0,R.jsx)(`div`,{className:`main-body`,children:(0,R.jsxs)(`div`,{className:`stack`,children:[l&&(0,R.jsx)(Dh,{status:l}),(0,R.jsxs)(`div`,{className:`grid-4`,children:[(0,R.jsxs)(`div`,{className:`card stat-card`,children:[(0,R.jsx)(`div`,{className:`stat-label`,children:`Tables`}),(0,R.jsx)(`div`,{className:`stat-num`,children:n.length}),(0,R.jsxs)(`div`,{className:`stat-hint`,children:[p,` enriched · `,m,` partial`]})]}),(0,R.jsxs)(`div`,{className:`card stat-card`,children:[(0,R.jsx)(`div`,{className:`stat-label`,children:`Concepts`}),(0,R.jsx)(`div`,{className:`stat-num`,children:t.concepts.length}),t.concepts.length>0&&(0,R.jsxs)(`div`,{className:`stat-hint`,children:[t.concepts.length,` defined`]})]}),(0,R.jsxs)(`div`,{className:`card stat-card`,children:[(0,R.jsx)(`div`,{className:`stat-label`,children:`Index health`}),(0,R.jsx)(`div`,{className:`stat-num`,children:i?.hasIndex?i.stale?`Stale`:`Fresh`:`None`}),i&&(0,R.jsxs)(`div`,{className:`stat-hint`,children:[i.chunksTotal,` chunks`,i.dimensions===null?``:` · ${i.dimensions}d`]})]}),(0,R.jsxs)(`div`,{className:`card stat-card`,children:[(0,R.jsx)(`div`,{className:`stat-label`,children:`Sensitivity coverage`}),(0,R.jsx)(`div`,{className:`stat-num`,children:i?`${Math.round((i.sensitiveExcluded+i.sensitiveIncluded)/Math.max(i.chunksTotal,1)*100)}%`:`—`})]})]}),(0,R.jsxs)(`div`,{className:`grid-2`,children:[(0,R.jsxs)(`div`,{className:`card`,children:[(0,R.jsxs)(`div`,{className:`card-hd`,children:[(0,R.jsxs)(`h3`,{children:[(0,R.jsx)(ma,{size:14}),` Pending enrichment`]}),(0,R.jsxs)(`span`,{className:`card-meta`,children:[n.length-p,` tables to go`]})]}),(0,R.jsx)(`div`,{className:`card-bd tight`,children:(0,R.jsxs)(`table`,{className:`tbl`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{children:`Table`}),(0,R.jsx)(`th`,{children:`Cols`}),(0,R.jsx)(`th`,{children:`Status`}),(0,R.jsx)(`th`,{"aria-label":`Actions`})]})}),(0,R.jsx)(`tbody`,{children:n.filter(e=>{let t=e.draft,n=Object.values(t.columns??{}).every(e=>e.description);return!(t.description&&n)}).slice(0,6).map(t=>{let n=t.draft.description||t.draft.aliases&&t.draft.aliases.length>0?`partial`:`none`;return(0,R.jsxs)(`tr`,{style:{cursor:`default`},onClick:()=>e(`/tables/${t.physical.schema}/${t.physical.name}/enrichment`),children:[(0,R.jsx)(`td`,{children:(0,R.jsxs)(`span`,{className:`mono`,children:[t.physical.schema,`.`,t.physical.name]})}),(0,R.jsx)(`td`,{className:`muted`,children:t.physical.columns.length}),(0,R.jsxs)(`td`,{children:[(0,R.jsx)(`span`,{className:`enrich-dot ${n}`}),(0,R.jsx)(`span`,{className:`muted tiny`,style:{marginLeft:6},children:n})]}),(0,R.jsx)(`td`,{style:{textAlign:`right`},children:(0,R.jsxs)(`span`,{className:`suggest-link`,children:[(0,R.jsx)(ma,{size:12}),` Draft`]})})]},t.physical.id)})})]})})]}),(0,R.jsxs)(`div`,{className:`card`,children:[(0,R.jsxs)(`div`,{className:`card-hd`,children:[(0,R.jsxs)(`h3`,{children:[(0,R.jsx)(ra,{size:14}),` Recent playground queries`]}),(0,R.jsxs)(`span`,{className:`card-meta`,children:[`last `,o.length,` queries`]})]}),(0,R.jsx)(`div`,{className:`card-bd tight`,children:(0,R.jsxs)(`table`,{className:`tbl`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{children:`Question`}),(0,R.jsx)(`th`,{children:`Mode`}),(0,R.jsx)(`th`,{children:`Time`})]})}),(0,R.jsxs)(`tbody`,{children:[o.slice(0,5).map(e=>(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`td`,{style:{maxWidth:300,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.question}),(0,R.jsx)(`td`,{children:(0,R.jsx)(`span`,{className:`chip ${e.mode===`rag`?`red`:``}`,children:e.mode})}),(0,R.jsx)(`td`,{className:`muted tiny`,children:new Date(e.timestamp).toLocaleString()})]},e.id)),o.length===0&&(0,R.jsx)(`tr`,{children:(0,R.jsx)(`td`,{colSpan:3,className:`muted tiny`,style:{textAlign:`center`,padding:16},children:`No queries yet`})})]})]})})]})]}),(0,R.jsxs)(`div`,{className:`grid-3`,children:[(0,R.jsxs)(`div`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsxs)(`h3`,{children:[(0,R.jsx)(ma,{size:14}),` RAG index`]})}),(0,R.jsx)(`div`,{className:`card-bd`,children:i?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`grid-2`,style:{gap:10},children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`muted tiny`,children:`Chunks`}),(0,R.jsx)(`div`,{style:{fontSize:18,fontWeight:600},children:hr(i.chunksTotal)})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`muted tiny`,children:`Indexed`}),(0,R.jsx)(`div`,{style:{fontSize:18,fontWeight:600},children:hr(i.chunksIndexed)})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`muted tiny`,children:`Dimensions`}),(0,R.jsx)(`div`,{className:`mono`,style:{fontSize:13},children:i.dimensions===null?`model default`:hr(i.dimensions)})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`muted tiny`,children:`Model`}),(0,R.jsx)(`div`,{className:`mono`,style:{fontSize:12},children:i.embedder.label})]})]}),(0,R.jsx)(`div`,{className:`bar`,style:{marginTop:14},children:(0,R.jsx)(`i`,{style:{width:i.chunksTotal>0?`${Math.round(i.chunksIndexed/i.chunksTotal*100)}%`:`0%`}})}),(0,R.jsxs)(`div`,{className:`tiny muted`,style:{marginTop:6},children:[`Updated: `,i.updatedAt??`never`]})]}):(0,R.jsx)(`div`,{className:`muted tiny`,children:`RAG status unavailable`})})]}),(0,R.jsxs)(`div`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsxs)(`h3`,{children:[(0,R.jsx)(fa,{size:14}),` Tenancy`]})}),(0,R.jsxs)(`div`,{className:`card-bd`,children:[(0,R.jsx)(`div`,{className:`row-h`,style:{marginBottom:10},children:(0,R.jsxs)(`span`,{className:`chip ${h?`green`:`amber`}`,children:[(0,R.jsx)(Ea,{size:11}),h?`Configured`:`Not configured`]})}),(0,R.jsx)(`div`,{className:`tiny muted`,style:{lineHeight:1.6},children:h?`${t.tenantPolicy.roots.length} root(s) configured, ${t.tenantPolicy.enforcement} mode.`:`Multi-tenant scoping isn't set. Generated SQL won't enforce row-level isolation.`}),!h&&(0,R.jsxs)(`button`,{type:`button`,className:`btn sm primary`,style:{marginTop:12},onClick:()=>e(`/tenancy`),children:[(0,R.jsx)(ma,{size:12}),` Draft tenant policy`]})]})]}),(0,R.jsxs)(`div`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsxs)(`h3`,{children:[(0,R.jsx)(Ea,{size:14}),` Suggested next actions`]})}),(0,R.jsxs)(`div`,{className:`card-bd`,style:{display:`flex`,flexDirection:`column`,gap:8},children:[n.filter(e=>!e.draft.description).length>0&&(0,R.jsxs)(`div`,{className:`row-h`,children:[(0,R.jsx)(`span`,{style:{width:8,height:8,borderRadius:`50%`,background:`var(--red-600)`,flexShrink:0}}),(0,R.jsxs)(`span`,{style:{fontSize:12.5},children:[`Add description to`,` `,(0,R.jsx)(`span`,{className:`mono`,children:n.find(e=>!e.draft.description)?.physical.name})]})]}),!i?.hasIndex&&(0,R.jsxs)(`div`,{className:`row-h`,children:[(0,R.jsx)(`span`,{style:{width:8,height:8,borderRadius:`50%`,background:`var(--amber-500)`,flexShrink:0}}),(0,R.jsx)(`span`,{style:{fontSize:12.5},children:`Build RAG index for retrieval-augmented queries`})]}),i?.stale&&(0,R.jsxs)(`div`,{className:`row-h`,children:[(0,R.jsx)(`span`,{style:{width:8,height:8,borderRadius:`50%`,background:`var(--ink-400)`,flexShrink:0}}),(0,R.jsx)(`span`,{style:{fontSize:12.5},children:`Rebuild index — tables changed since last build`})]}),n.length>0&&p===0&&(0,R.jsxs)(`div`,{className:`row-h`,children:[(0,R.jsx)(`span`,{style:{width:8,height:8,borderRadius:`50%`,background:`var(--amber-500)`,flexShrink:0}}),(0,R.jsx)(`span`,{style:{fontSize:12.5},children:`Start enriching tables to improve SQL generation quality`})]})]})]})]})]})})]})}var kh=e=>(0,R.jsx)(es,{"data-slot":`collapsible-trigger`,...e}),Ah=e=>(0,R.jsx)(ns,{"data-slot":`collapsible-content`,...e}),jh=e=>(0,R.jsx)(Qo,{"data-slot":`collapsible`,...e}),Mh={enriched:`Complete`,partial:`Partial`,none:`Not started`};function Nh(){let e=ht(),t=yt(),{filteredTables:n,tables:r,selectedTable:i,setSelectedTableId:a,tableSearch:o,setTableSearch:s,drafts:c}=vr(),[l,u]=(0,M.useState)(null),[d,f]=(0,M.useState)(null),p=(0,M.useCallback)(e=>{let t=c[e.physical.id]??e.draft,n=t.description||t.aliases&&t.aliases.length>0,r=Object.values(t.columns??{}).every(e=>e.description);return n&&r?`enriched`:n?`partial`:`none`},[c]),m=(0,M.useCallback)(e=>(c[e.physical.id]??e.draft).tracked!==!1,[c]),h=(0,M.useMemo)(()=>{let e={enriched:0,partial:0,none:0};for(let t of r)e[p(t)]++;return e},[r,p]),g=(0,M.useMemo)(()=>r.filter(e=>!m(e)).length,[r,m]),_=(0,M.useMemo)(()=>{let e=n;return l&&(e=e.filter(e=>l.has(p(e)))),d===`tracked`?e=e.filter(e=>m(e)):d===`untracked`&&(e=e.filter(e=>!m(e))),e},[n,l,d,p,m]),v=(0,M.useMemo)(()=>{let e=new Map;for(let t of _){let n=t.physical.schema;e.has(n)||e.set(n,[]),e.get(n).push(t)}return Array.from(e.entries()).sort(([e],[t])=>e.localeCompare(t))},[_]),y=(0,M.useMemo)(()=>v.map(([e])=>e),[v]),[b,x]=(0,M.useState)(new Set),S=(0,M.useMemo)(()=>new Set(y.filter(e=>!b.has(e))),[y,b]),C=b.size===0,w=()=>x(new Set(y)),T=()=>x(new Set);(0,M.useEffect)(()=>{o&&x(new Set)},[o]),(0,M.useEffect)(()=>{if(t.schema&&t.name){let e=`table:${t.schema}.${t.name}`;a(e)}else if(r.length>0&&!t.schema){let t=r[0];e(`/tables/${t.physical.schema}/${t.physical.name}/enrichment`,{replace:!0})}},[t.schema,t.name,r,e,a]);function E(e){u(t=>{if(!t)return new Set([e]);let n=new Set(t);return n.has(e)?(n.delete(e),n.size===0?null:n):(n.add(e),n.size===3?null:n)})}let D=!!(t.schema&&t.name);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`sub-rail`,children:[(0,R.jsxs)(`div`,{className:`sub-rail-hd`,children:[(0,R.jsx)(`h2`,{children:`Tables`}),(0,R.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6},children:[(0,R.jsxs)(`span`,{className:`muted tiny`,children:[r.length,` tables`]}),v.length>1&&(0,R.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:C?T:w,title:C?`Collapse all`:`Expand all`,style:{padding:2,height:20,width:20},children:C?(0,R.jsx)(yi,{size:13}):(0,R.jsx)(xi,{size:13})})]})]}),(0,R.jsxs)(`div`,{className:`sub-rail-search`,children:[(0,R.jsx)(ca,{size:13}),(0,R.jsx)(`input`,{type:`text`,"aria-label":`Search tables`,placeholder:`Search tables…`,value:o,onChange:e=>s(e.target.value)})]}),(0,R.jsxs)(`div`,{className:`enrich-filter-bar`,children:[[`enriched`,`partial`,`none`].map(e=>{let t=!l||l.has(e);return(0,R.jsxs)(`button`,{type:`button`,className:`enrich-filter-chip ${e} ${t?`active`:``}`,onClick:()=>E(e),title:`${t?`Hide`:`Show`} ${Mh[e].toLowerCase()} tables`,children:[(0,R.jsx)(`span`,{className:`enrich-dot ${e}`}),(0,R.jsx)(`span`,{className:`enrich-filter-label`,children:Mh[e]}),(0,R.jsx)(`span`,{className:`enrich-filter-count`,children:h[e]})]},e)}),g>0&&(0,R.jsxs)(`button`,{type:`button`,className:`enrich-filter-chip untracked ${d===`untracked`?`active`:``}`,onClick:()=>f(e=>e===`untracked`?null:`untracked`),title:d===`untracked`?`Show all tables`:`Show ${g} untracked table${g===1?``:`s`}`,children:[(0,R.jsx)(ji,{size:11}),(0,R.jsx)(`span`,{className:`enrich-filter-label`,children:`Untracked`}),(0,R.jsx)(`span`,{className:`enrich-filter-count`,children:g})]})]}),(0,R.jsxs)(`div`,{className:`sub-rail-list`,children:[v.map(([t,n])=>(0,R.jsx)(jh,{open:S.has(t),onOpenChange:e=>{x(n=>{let r=new Set(n);return e?r.delete(t):r.add(t),r})},children:(0,R.jsxs)(`div`,{className:`schema-group`,children:[(0,R.jsx)(kh,{asChild:!0,children:(0,R.jsxs)(`button`,{type:`button`,className:`schema-group-hd`,children:[(0,R.jsx)(_i,{size:12,className:`schema-chevron`,style:{transform:S.has(t)?`rotate(90deg)`:void 0}}),(0,R.jsx)(Fi,{size:13,className:`schema-icon`}),(0,R.jsx)(`span`,{className:`schema-name`,children:t}),(0,R.jsx)(`span`,{className:`schema-count`,children:n.length})]})}),(0,R.jsx)(Ah,{children:(0,R.jsx)(`div`,{className:`schema-group-bd`,children:n.map(t=>{let n=p(t),r=m(t),a=i?.physical.id===t.physical.id;return(0,R.jsxs)(`button`,{type:`button`,className:`sub-rail-row table-leaf ${a?`active`:``}${r?``:` untracked`}`,onClick:()=>e(`/tables/${t.physical.schema}/${t.physical.name}/enrichment`),title:r?void 0:`Untracked — excluded from LLM context`,children:[r?(0,R.jsx)(`span`,{className:`enrich-dot ${n}`}):(0,R.jsx)(ji,{size:10,style:{color:`var(--amber-500)`,flex:`none`}}),(0,R.jsx)(`span`,{className:`row-name mono`,children:t.physical.name}),(0,R.jsxs)(`span`,{className:`row-meta`,children:[t.physical.columns.length,` cols`]})]},t.physical.id)})})})]})},t)),_.length===0&&(0,R.jsx)(`div`,{className:`muted tiny`,style:{padding:`16px`,textAlign:`center`},children:d===`untracked`?`No untracked tables`:l?`No tables match this filter`:`No tables match your search`})]})]}),D?(0,R.jsx)(sn,{}):(0,R.jsx)(`main`,{className:`main-pane`,children:(0,R.jsx)(`div`,{className:`main-body`,style:{display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,R.jsxs)(`div`,{style:{textAlign:`center`,color:`var(--ink-400)`},children:[(0,R.jsx)(ma,{size:24,style:{margin:`0 auto 8px`}}),(0,R.jsx)(`p`,{style:{fontSize:13},children:`Select a table to start enriching`})]})})})]})}function Ph(){let{selectedTable:e,selectedDraft:t,dirty:n,saveStatus:r,saveSelectedTable:i,resetSelectedDraft:a,busy:o}=vr(),{refreshRagStatus:s}=jr();if(!e||!t)return null;async function c(){await i(),s()}let l=e,u=t.description||t.aliases&&t.aliases.length>0,d=Object.values(t.columns??{}).every(e=>e.description);return(0,R.jsxs)(`main`,{className:`main-pane`,children:[(0,R.jsxs)(`div`,{className:`main-hd`,children:[(0,R.jsxs)(`div`,{className:`main-title`,children:[(0,R.jsxs)(`h1`,{children:[(0,R.jsx)(`span`,{className:`enrich-dot ${u&&d?`enriched`:u?`partial`:`none`}`,style:{marginRight:8}}),l.physical.schema,`.`,l.physical.name]}),(0,R.jsxs)(`div`,{className:`main-sub`,children:[l.physical.columns.length,` columns`,l.physical.relationships&&l.physical.relationships.length>0?` · ${l.physical.relationships.length} relationships`:``,l.missingColumnIds.length>0?` · ${l.missingColumnIds.length} missing`:``]})]}),(0,R.jsxs)(`div`,{className:`main-actions`,children:[(0,R.jsxs)(`button`,{type:`button`,className:`btn`,onClick:a,disabled:!n||o.has(`save`),children:[(0,R.jsx)(B,{size:14}),` Revert`]}),(0,R.jsxs)(`button`,{type:`button`,className:`btn primary`,onClick:()=>void c(),disabled:!n||o.has(`save`),children:[o.has(`save`)?(0,R.jsx)(Vi,{size:14,className:`animate-spin`}):(0,R.jsx)(oa,{size:14}),`Save`]})]})]}),r&&(0,R.jsx)(Eh,{status:r}),(0,R.jsxs)(`div`,{className:`sub-tabs`,children:[(0,R.jsx)(Dn,{to:`enrichment`,className:({isActive:e})=>`sub-tab ${e?`active`:``}`,children:`Enrichment`}),(0,R.jsx)(Dn,{to:`schema`,className:({isActive:e})=>`sub-tab ${e?`active`:``}`,children:`Schema`}),(0,R.jsx)(Dn,{to:`sensitivity`,className:({isActive:e})=>`sub-tab ${e?`active`:``}`,children:`Sensitivity`})]}),(0,R.jsx)(`div`,{className:`main-body`,children:(0,R.jsx)(sn,{})})]})}var Fh=Xr(`inline-flex min-h-6 max-w-full items-center rounded-md px-2 py-0.5 text-xs font-medium`,{variants:{variant:{default:`bg-primary text-primary-foreground`,secondary:`bg-secondary text-secondary-foreground`,warning:`bg-warning text-warning-foreground dark:bg-amber-500/15 dark:text-amber-400`,danger:`bg-destructive text-destructive-foreground`,outline:`border border-border bg-background text-muted-foreground`}},defaultVariants:{variant:`default`}});function Ih({className:e,variant:t,...n}){return(0,R.jsx)(`span`,{className:Q(Fh({variant:t}),e),...n})}function $({label:e,description:t,children:n,className:r}){return(0,R.jsxs)(`label`,{className:Q(`grid gap-1.5`,r),children:[(0,R.jsx)(`span`,{className:`text-xs font-semibold text-muted-foreground`,children:e}),n,t?(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t}):null]})}function Lh(e){return e?.join(`, `)??``}function Rh({value:e,onChange:t}){let[n,r]=(0,M.useState)(null),i=n??Lh(e);return(0,R.jsx)(Rm,{value:i,onChange:e=>r(e.target.value),onFocus:()=>r(Lh(e)),onBlur:()=>{t(pr(n??Lh(e))),r(null)}})}function zh({className:e,...t}){return(0,R.jsx)(`textarea`,{"data-slot":`textarea`,className:Q(`min-h-24 w-full rounded-md border border-input bg-background px-3 py-2 text-sm outline-none transition-colors placeholder:text-muted-foreground focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`,e),...t})}var Bh={forced:!0,effective:!0};function Vh(e,t){let{physical:n}=e,r=new Set(e.escalatedByOtherFiles),i=n.sensitive===!0,a=i||t.sensitive===!0,o={};for(let e of n.columns){let n=e.sensitive===!0||a||r.has(e.id);o[e.id]={forced:n,effective:n||t.columns[e.id]?.sensitive===!0}}return{forced:i,effective:a,columns:o}}function Hh(){let{workspace:e,selectedTable:t,selectedDraft:n,updateTableDraft:r,updateColumnDraft:i,requestSuggestion:a,suggestingKey:o}=vr();if(!t||!n||!e)return null;let s=e.aiConfigured,c=t,l=n,u=c.physical.id,d=Vh(c,l);return(0,R.jsxs)(`div`,{className:`stack`,style:{padding:`var(--pad-y) var(--pad-x)`},children:[(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Table Enrichment`})}),(0,R.jsx)(`div`,{className:`card-bd`,children:(0,R.jsxs)(`div`,{style:{display:`grid`,gap:16},children:[(0,R.jsx)(Uh,{aiConfigured:s,label:`Description`,onSuggest:()=>a({scope:`table`,tableId:u,field:`description`},`table description`),suggesting:o===`table:${u}:description`,children:(0,R.jsx)(zh,{value:l.description,onChange:e=>r(u,t=>({...t,description:e.target.value}))})}),(0,R.jsxs)(`div`,{style:{display:`grid`,gap:16,gridTemplateColumns:`1fr 1fr`},children:[(0,R.jsx)(Uh,{aiConfigured:s,label:`Aliases`,onSuggest:()=>a({scope:`table`,tableId:u,field:`aliases`},`table aliases`),suggesting:o===`table:${u}:aliases`,children:(0,R.jsx)(Rh,{value:l.aliases,onChange:e=>r(u,t=>({...t,aliases:e}))})}),(0,R.jsx)(Uh,{aiConfigured:s,label:`Primary entity`,onSuggest:()=>a({scope:`table`,tableId:u,field:`primaryEntity`},`primary entity`),suggesting:o===`table:${u}:primaryEntity`,children:(0,R.jsx)(Rm,{value:l.primaryEntity??``,onChange:e=>r(u,t=>({...t,primaryEntity:e.target.value.trim()||void 0}))})})]}),(0,R.jsxs)(`div`,{style:{display:`grid`,gap:16,gridTemplateColumns:`1fr 220px`},children:[(0,R.jsx)($,{label:`Tags`,description:`Comma-separated labels used for browsing and filtering.`,children:(0,R.jsx)(Rh,{value:l.tags,onChange:e=>r(u,t=>({...t,tags:e}))})}),(0,R.jsx)(Wh,{label:`Table sensitivity override`,value:l.sensitive,forced:d.forced,onChange:e=>r(u,t=>({...t,sensitive:e}))})]})]})})]}),(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Common Query Language`})}),(0,R.jsx)(`div`,{className:`card-bd`,children:(0,R.jsx)(Uh,{aiConfigured:s,label:`Business vocabulary`,onSuggest:()=>a({scope:`table`,tableId:u,field:`commonQueryLanguage`},`common query language`),suggesting:o===`table:${u}:commonQueryLanguage`,children:(0,R.jsx)(zh,{className:`min-h-36`,value:l.commonQueryLanguage??``,onChange:e=>r(u,t=>({...t,commonQueryLanguage:e.target.value}))})})})]}),(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Example Questions`})}),(0,R.jsx)(`div`,{className:`card-bd`,children:(0,R.jsx)($,{label:`Questions`,children:(0,R.jsx)(zh,{className:`min-h-32`,value:l.exampleQuestions??``,onChange:e=>r(u,t=>({...t,exampleQuestions:e.target.value}))})})})]}),(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsxs)(`div`,{className:`card-hd`,children:[(0,R.jsx)(`h3`,{children:`Columns`}),c.missingColumnIds.length>0&&(0,R.jsxs)(Ih,{variant:c.missingColumnIds.length>0?`warning`:`secondary`,children:[c.missingColumnIds.length,` missing`]})]}),(0,R.jsx)(`div`,{className:`card-bd`,children:(0,R.jsx)(`div`,{style:{display:`grid`,gap:12},children:c.physical.columns.map(e=>{let t=l.columns[e.id]??{},n=d.columns[e.id]??Bh;return(0,R.jsxs)(`section`,{className:`column-row`,children:[(0,R.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,justifyContent:`space-between`,gap:8},children:(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:8},children:[(0,R.jsx)(`h4`,{style:{fontSize:13,fontWeight:600},children:e.name}),(0,R.jsx)(Ih,{variant:`outline`,children:e.type}),e.primaryKey&&(0,R.jsx)(Ih,{variant:`secondary`,children:`PK`}),e.nullable&&(0,R.jsx)(Ih,{variant:`outline`,children:`nullable`}),n.effective&&(0,R.jsx)(Ih,{variant:`danger`,children:`sensitive`})]}),(0,R.jsx)(`p`,{className:`muted tiny`,style:{marginTop:4,wordBreak:`break-all`},children:e.id})]})}),(0,R.jsxs)(`div`,{style:{marginTop:12,display:`grid`,gap:12},children:[(0,R.jsx)(Uh,{aiConfigured:s,label:`Description`,onSuggest:()=>a({scope:`column`,tableId:u,columnId:e.id,field:`description`},`${e.name} description`),suggesting:o===`column:${u}:${e.id}:description`,children:(0,R.jsx)(zh,{value:t.description??``,onChange:t=>i(u,e.id,e=>({...e,description:t.target.value}))})}),(0,R.jsxs)(`div`,{style:{display:`grid`,gap:12,gridTemplateColumns:`1fr 1fr 1fr`},children:[(0,R.jsx)(Uh,{aiConfigured:s,label:`Aliases`,onSuggest:()=>a({scope:`column`,tableId:u,columnId:e.id,field:`aliases`},`${e.name} aliases`),suggesting:o===`column:${u}:${e.id}:aliases`,children:(0,R.jsx)(Rh,{value:t.aliases,onChange:t=>i(u,e.id,e=>({...e,aliases:t}))})}),(0,R.jsx)($,{label:`Enum notes`,children:(0,R.jsx)(Rh,{value:t.enum,onChange:t=>i(u,e.id,e=>({...e,enum:t}))})}),(0,R.jsx)(Wh,{label:`Sensitivity override`,value:t.sensitive,forced:n.forced,onChange:t=>i(u,e.id,e=>({...e,sensitive:t}))})]})]})]},e.id)})})})]}),(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Relationships`})}),(0,R.jsx)(`div`,{className:`card-bd`,children:c.physical.relationships&&c.physical.relationships.length>0?(0,R.jsx)(`div`,{style:{display:`grid`,gap:8},children:c.physical.relationships.map((e,t)=>(0,R.jsxs)(`div`,{className:`relationship-row`,children:[(0,R.jsx)(`span`,{style:{wordBreak:`break-all`},children:e.from}),(0,R.jsx)(_i,{size:14,style:{color:`var(--ink-400)`,flexShrink:0}}),(0,R.jsx)(`span`,{style:{wordBreak:`break-all`},children:e.to})]},`${e.from}-${e.to}-${t}`))}):(0,R.jsx)(`p`,{className:`muted`,style:{fontSize:13},children:`No relationships recorded for this table.`})})]})]})}function Uh({aiConfigured:e,children:t,label:n,onSuggest:r,suggesting:i}){return(0,R.jsxs)(`div`,{style:{display:`grid`,gap:6},children:[(0,R.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:8},children:[(0,R.jsx)(`span`,{className:`muted`,style:{fontSize:12,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.04em`},children:n}),(0,R.jsxs)(`button`,{type:`button`,className:`suggest-link`,disabled:!e||i,onClick:()=>void r(),title:e?`Suggest with configured AI model`:`Configure an AI key to enable suggestions`,children:[i?(0,R.jsx)(Vi,{size:12,className:`animate-spin`}):(0,R.jsx)(ma,{size:12}),`Suggest`]})]}),t]})}function Wh({forced:e,label:t,onChange:n,value:r}){return(0,R.jsxs)(`label`,{style:{display:`grid`,gap:6},children:[(0,R.jsx)(`span`,{className:`muted`,style:{fontSize:12,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.04em`},children:t}),(0,R.jsxs)(`select`,{className:`h-9 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring`,value:r===void 0?`inherit`:r?`true`:`false`,onChange:e=>{e.target.value===`inherit`?n(void 0):n(e.target.value===`true`)},children:[(0,R.jsx)(`option`,{value:`inherit`,children:`Inherit physical metadata`}),(0,R.jsx)(`option`,{value:`true`,children:`Sensitive`}),(0,R.jsx)(`option`,{value:`false`,disabled:e,children:`Not sensitive`})]})]})}function Gh(){let{selectedTable:e}=vr();if(!e)return null;let t=e;return(0,R.jsxs)(`div`,{className:`stack`,style:{padding:`var(--pad-y) var(--pad-x)`},children:[(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Column Details`})}),(0,R.jsx)(`div`,{className:`card-bd tight`,children:(0,R.jsxs)(`table`,{className:`tbl`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{children:`Name`}),(0,R.jsx)(`th`,{children:`Type`}),(0,R.jsx)(`th`,{children:`Nullable`}),(0,R.jsx)(`th`,{children:`PK`}),(0,R.jsx)(`th`,{children:`Sensitive`})]})}),(0,R.jsx)(`tbody`,{children:t.physical.columns.map(e=>(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`td`,{children:(0,R.jsx)(`span`,{className:`mono`,children:e.name})}),(0,R.jsx)(`td`,{children:(0,R.jsx)(Ih,{variant:`outline`,children:e.type})}),(0,R.jsx)(`td`,{children:e.nullable?`Yes`:`No`}),(0,R.jsx)(`td`,{children:e.primaryKey?(0,R.jsx)(Ih,{variant:`secondary`,children:`PK`}):`—`}),(0,R.jsx)(`td`,{children:e.sensitive?(0,R.jsx)(Ih,{variant:`danger`,children:`sensitive`}):`—`})]},e.id))})]})})]}),t.physical.relationships&&t.physical.relationships.length>0&&(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Relationships`})}),(0,R.jsx)(`div`,{className:`card-bd`,children:(0,R.jsx)(`div`,{style:{display:`grid`,gap:8},children:t.physical.relationships.map((e,t)=>(0,R.jsxs)(`div`,{className:`relationship-row`,children:[(0,R.jsx)(`span`,{style:{wordBreak:`break-all`},children:e.from}),(0,R.jsx)(_i,{size:14,style:{color:`var(--ink-400)`,flexShrink:0}}),(0,R.jsx)(`span`,{style:{wordBreak:`break-all`},children:e.to})]},`${e.from}-${e.to}-${t}`))})})]})]})}function Kh(){let{selectedTable:e,selectedDraft:t,updateColumnDraft:n,updateTableDraft:r}=vr();if(!e||!t)return null;let i=e,a=t,o=i.physical.id,s=Vh(i,a);return(0,R.jsxs)(`div`,{className:`stack`,style:{padding:`var(--pad-y) var(--pad-x)`},children:[(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`LLM tracking`})}),(0,R.jsxs)(`div`,{className:`card-bd`,children:[(0,R.jsx)(`p`,{className:`muted`,style:{fontSize:12,marginBottom:10},children:`Untracked tables are excluded from LLM prompts and RAG indexing. They remain in the schema and are still visible here.`}),(0,R.jsxs)(`label`,{style:{display:`grid`,gap:6},children:[(0,R.jsx)(`span`,{className:`muted`,style:{fontSize:12,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.04em`},children:`Status`}),(0,R.jsxs)(`select`,{className:`h-9 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring`,value:a.tracked===!1?`false`:`true`,onChange:e=>{let t=e.target.value!==`false`&&void 0;r(o,e=>({...e,tracked:t}))},children:[(0,R.jsx)(`option`,{value:`true`,children:`Tracked — included in LLM context`}),(0,R.jsx)(`option`,{value:`false`,children:`Untracked — excluded from LLM context`})]})]})]})]}),(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Table-level sensitivity`})}),(0,R.jsxs)(`div`,{className:`card-bd`,children:[(0,R.jsx)(`p`,{className:`muted`,style:{fontSize:12,marginBottom:10},children:`Overrides can only escalate: marking a table or column sensitive takes effect on top of the physical metadata, but "Not sensitive" cannot un-mark something schema.json already marks sensitive. A sensitive table makes all of its columns sensitive.`}),(0,R.jsxs)(`label`,{style:{display:`grid`,gap:6},children:[(0,R.jsx)(`span`,{className:`muted`,style:{fontSize:12,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.04em`},children:`Override`}),(0,R.jsxs)(`select`,{className:`h-9 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring`,value:a.sensitive===void 0?`inherit`:a.sensitive?`true`:`false`,onChange:e=>{let t=e.target.value===`inherit`?void 0:e.target.value===`true`;r(o,e=>({...e,sensitive:t}))},children:[(0,R.jsx)(`option`,{value:`inherit`,children:`Inherit physical metadata`}),(0,R.jsx)(`option`,{value:`true`,children:`Sensitive`}),(0,R.jsx)(`option`,{value:`false`,disabled:s.forced,children:`Not sensitive`})]})]}),(0,R.jsxs)(`p`,{className:`muted`,style:{fontSize:12,marginTop:8},children:[`Effective: `,s.effective?(0,R.jsx)(Ih,{variant:`danger`,children:`sensitive`}):`not sensitive`]})]})]}),(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Column sensitivity`})}),(0,R.jsx)(`div`,{className:`card-bd tight`,children:(0,R.jsxs)(`table`,{className:`tbl`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{children:`Column`}),(0,R.jsx)(`th`,{children:`Physical`}),(0,R.jsx)(`th`,{children:`Override`}),(0,R.jsx)(`th`,{children:`Effective`})]})}),(0,R.jsx)(`tbody`,{children:i.physical.columns.map(e=>{let t=a.columns[e.id]??{},{forced:r,effective:i}=s.columns[e.id]??Bh;return(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`td`,{children:(0,R.jsx)(`span`,{className:`mono`,children:e.name})}),(0,R.jsx)(`td`,{children:e.sensitive?(0,R.jsx)(Ih,{variant:`danger`,children:`sensitive`}):(0,R.jsx)(`span`,{className:`muted`,children:`—`})}),(0,R.jsx)(`td`,{children:(0,R.jsxs)(`select`,{style:{fontSize:12,padding:`2px 6px`,borderRadius:4,border:`1px solid var(--border)`},value:t.sensitive===void 0?`inherit`:t.sensitive?`true`:`false`,onChange:t=>{let r=t.target.value===`inherit`?void 0:t.target.value===`true`;n(o,e.id,e=>({...e,sensitive:r}))},children:[(0,R.jsx)(`option`,{value:`inherit`,children:`Inherit`}),(0,R.jsx)(`option`,{value:`true`,children:`Sensitive`}),(0,R.jsx)(`option`,{value:`false`,disabled:r,children:`Not sensitive`})]})}),(0,R.jsx)(`td`,{children:i?(0,R.jsx)(Ih,{variant:`danger`,children:`sensitive`}):(0,R.jsx)(`span`,{className:`muted`,children:`—`})})]},e.id)})})]})})]})]})}var qh=`concept:`;function Jh(e){return e.startsWith(qh)?e.slice(8):e}function Yh(e){let t=e.trim();return t?t.startsWith(qh)?t:qh+t:``}function Xh(e){return structuredClone(e)}function Zh(){let{workspace:e,tables:t,handleSaveConcepts:n,saveStatus:r,busy:i}=vr(),{refreshRagStatus:a}=jr(),o=(0,M.useCallback)(async e=>{await n(e),a()},[n,a]),s=(0,M.useMemo)(()=>{if(!t.length)return[];let e=[];for(let n of t){e.push({id:n.physical.id,label:`${n.physical.schema}.${n.physical.name}`,kind:`table`});for(let t of n.physical.columns)e.push({id:t.id,label:`${n.physical.schema}.${n.physical.name} → ${t.name}`,kind:`column`})}return e},[t]);if(!e)return null;let c=e.concepts.map(e=>e.id).join(`,`);return(0,R.jsx)(`main`,{className:`main-pane`,children:(0,R.jsx)($h,{concepts:e.concepts,linkOptions:s,onSave:o,saveStatus:r,busy:i},c)})}function Qh(e,t){switch(t.type){case`set_selectedIndex`:return{...e,selectedIndex:t.payload};case`set_conceptSearch`:return{...e,conceptSearch:t.payload};case`merge_addDraft`:return{...e,addDraft:{...e.addDraft,...t.payload}};case`update_concept`:return{...e,draft:e.draft.map((e,n)=>n===t.index?t.updater(Xh(e)):e)};case`remove_concept`:{let n=e.draft.filter((e,n)=>n!==t.index),r=e.selectedIndex;return e.selectedIndex===t.index?r=null:e.selectedIndex!==null&&e.selectedIndex>t.index&&(r=e.selectedIndex-1),{...e,draft:n,selectedIndex:r}}case`commit_add`:return{...e,draft:[...e.draft,t.concept],selectedIndex:t.newIndex,addDraft:{},addOpen:!1};case`open_add_form`:return{...e,addOpen:!0,selectedIndex:null};case`select_concept`:return{...e,selectedIndex:t.index,addOpen:!1};case`cancel_add`:return{...e,addOpen:!1,addDraft:{}};case`revert`:return{...e,draft:Xh(t.concepts),selectedIndex:null,addOpen:!1}}}function $h({concepts:e,linkOptions:t,onSave:n,saveStatus:r,busy:i}){let[a,o]=(0,M.useReducer)(Qh,null,()=>({draft:Xh(e),selectedIndex:null,addOpen:!1,addDraft:{},conceptSearch:``})),{draft:s,selectedIndex:c,addOpen:l,addDraft:u,conceptSearch:d}=a,f=JSON.stringify(s)!==JSON.stringify(e),p=(0,M.useMemo)(()=>{if(!d)return s.map((e,t)=>({concept:e,index:t}));let e=d.toLowerCase();return s.flatMap((t,n)=>t.label.toLowerCase().includes(e)||t.id.toLowerCase().includes(e)||t.synonyms?.some(t=>t.toLowerCase().includes(e))?[{concept:t,index:n}]:[])},[s,d]),m=c===null?null:s[c];function h(e,t){o({type:`update_concept`,index:e,updater:t})}function g(e){o({type:`remove_concept`,index:e})}function _(){let e=Yh(u.id??``);if(!e||!u.label?.trim())return;let t={id:e,label:u.label.trim(),...u.synonyms?.length?{synonyms:u.synonyms}:{},...u.links?.length?{links:u.links}:{},...u.description?.trim()?{description:u.description.trim()}:{}};o({type:`commit_add`,concept:t,newIndex:s.length})}return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`main-hd`,children:[(0,R.jsxs)(`div`,{className:`main-title`,children:[(0,R.jsxs)(`h1`,{children:[(0,R.jsx)(Li,{size:18,style:{display:`inline`,marginRight:8}}),`Concepts`]}),(0,R.jsx)(`div`,{className:`main-sub`,children:`Cross-table domain vocabulary for NL→SQL grounding`})]}),(0,R.jsxs)(`div`,{className:`main-actions`,children:[(0,R.jsxs)(`button`,{type:`button`,className:`btn`,onClick:()=>o({type:`revert`,concepts:e}),disabled:!f||i.has(`save-concepts`),children:[(0,R.jsx)(B,{size:14}),` Revert`]}),(0,R.jsxs)(`button`,{type:`button`,className:`btn primary`,onClick:()=>void n(s),disabled:!f||i.has(`save-concepts`),children:[i.has(`save-concepts`)?(0,R.jsx)(Vi,{size:14,className:`animate-spin`}):(0,R.jsx)(oa,{size:14}),`Save`]})]})]}),r&&(0,R.jsx)(Eh,{status:r}),(0,R.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`280px 1fr`,flex:1,minHeight:0,overflow:`hidden`},children:[(0,R.jsxs)(`div`,{className:`sub-rail`,style:{borderRight:`1px solid var(--border)`},children:[(0,R.jsxs)(`div`,{className:`sub-rail-hd`,children:[(0,R.jsx)(`h2`,{children:`Concepts`}),(0,R.jsx)(`span`,{className:`muted tiny`,children:s.length})]}),(0,R.jsxs)(`div`,{className:`sub-rail-search`,children:[(0,R.jsx)(ca,{size:13}),(0,R.jsx)(`input`,{type:`text`,"aria-label":`Search concepts`,placeholder:`Search concepts…`,value:d,onChange:e=>o({type:`set_conceptSearch`,payload:e.target.value})})]}),(0,R.jsx)(`div`,{style:{padding:`6px 8px`,borderBottom:`1px solid var(--border)`},children:(0,R.jsxs)(`button`,{type:`button`,className:`btn sm`,style:{width:`100%`,justifyContent:`center`},onClick:()=>o({type:`open_add_form`}),children:[(0,R.jsx)($i,{size:12}),` Add concept`]})}),(0,R.jsxs)(`div`,{className:`sub-rail-list`,children:[p.map(({concept:e,index:t})=>(0,R.jsxs)(`button`,{type:`button`,className:`sub-rail-row ${c===t?`active`:``}`,onClick:()=>o({type:`select_concept`,index:t}),children:[(0,R.jsx)(Li,{size:12,style:{flexShrink:0,color:`var(--ink-400)`}}),(0,R.jsx)(`span`,{className:`row-name`,children:e.label}),(0,R.jsxs)(`span`,{className:`row-meta`,children:[e.links?.length??0,` links`]})]},e.id)),p.length===0&&(0,R.jsx)(`div`,{className:`muted tiny`,style:{padding:`16px`,textAlign:`center`},children:d?`No concepts match your search`:`No concepts yet`})]})]}),(0,R.jsx)(`div`,{style:{overflow:`auto`,padding:`var(--pad-y) var(--pad-x)`},children:l?(0,R.jsx)(`div`,{className:`stack`,children:(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`New Concept`})}),(0,R.jsx)(`div`,{className:`card-bd`,children:(0,R.jsxs)(`div`,{style:{display:`grid`,gap:12},children:[(0,R.jsxs)(`div`,{style:{display:`grid`,gap:12,gridTemplateColumns:`1fr 1fr`},children:[(0,R.jsx)($,{label:`ID`,description:`Unique slug (concept: prefix added automatically)`,children:(0,R.jsx)(tg,{value:u.id??``,onChange:e=>o({type:`merge_addDraft`,payload:{id:e}}),placeholder:`revenue`})}),(0,R.jsx)($,{label:`Label`,description:`Human-readable name, e.g. "Revenue"`,children:(0,R.jsx)(Rm,{value:u.label??``,placeholder:`Revenue`,onChange:e=>o({type:`merge_addDraft`,payload:{label:e.target.value}})})})]}),(0,R.jsx)($,{label:`Synonyms`,description:`Comma-separated terms users might say`,children:(0,R.jsx)(Rh,{value:u.synonyms,onChange:e=>o({type:`merge_addDraft`,payload:{synonyms:e}})})}),(0,R.jsx)($,{label:`Links`,description:`Tables or columns this concept maps to`,children:(0,R.jsx)(ng,{value:u.links??[],onChange:e=>o({type:`merge_addDraft`,payload:{links:e}}),options:t})}),(0,R.jsx)($,{label:`Description`,description:`How this concept is computed or what it means`,children:(0,R.jsx)(zh,{value:u.description??``,placeholder:`Sum of orders.total_amount where status = 'paid', expressed in cents.`,onChange:e=>o({type:`merge_addDraft`,payload:{description:e.target.value}})})}),(0,R.jsxs)(`div`,{style:{display:`flex`,gap:8,justifyContent:`flex-end`},children:[(0,R.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>o({type:`cancel_add`}),children:`Cancel`}),(0,R.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:_,disabled:!u.id?.trim()||!u.label?.trim(),children:`Add concept`})]})]})})]})}):m&&c!==null?(0,R.jsx)(eg,{concept:m,linkOptions:t,onChange:e=>h(c,e),onRemove:()=>g(c)}):(0,R.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`center`,height:`100%`},children:(0,R.jsxs)(`div`,{style:{textAlign:`center`,color:`var(--ink-400)`},children:[(0,R.jsx)(Li,{size:24,style:{margin:`0 auto 8px`}}),(0,R.jsx)(`p`,{style:{fontSize:13},children:s.length===0?`Click "Add concept" to create your first one`:`Select a concept to edit`})]})})})]})]})}function eg({concept:e,linkOptions:t,onChange:n,onRemove:r}){return(0,R.jsx)(`div`,{className:`stack`,children:(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsxs)(`div`,{className:`card-hd`,children:[(0,R.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:8},children:[(0,R.jsx)(`h3`,{children:e.label}),(0,R.jsx)(Ih,{variant:`outline`,children:e.id})]}),(0,R.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:r,title:`Remove concept`,style:{color:`var(--red-600)`},children:`Remove`})]}),(0,R.jsx)(`div`,{className:`card-bd`,children:(0,R.jsxs)(`div`,{style:{display:`grid`,gap:12},children:[(0,R.jsxs)(`div`,{style:{display:`grid`,gap:12,gridTemplateColumns:`1fr 1fr`},children:[(0,R.jsx)($,{label:`ID`,description:`Unique slug (concept: prefix added automatically)`,children:(0,R.jsx)(tg,{value:e.id,onChange:e=>n(t=>({...t,id:e}))})}),(0,R.jsx)($,{label:`Label`,description:`Human-readable name`,children:(0,R.jsx)(Rm,{value:e.label,onChange:e=>n(t=>({...t,label:e.target.value}))})})]}),(0,R.jsx)($,{label:`Synonyms`,description:`Comma-separated alternative terms`,children:(0,R.jsx)(Rh,{value:e.synonyms,onChange:e=>n(t=>({...t,synonyms:e.length?e:void 0}))})}),(0,R.jsx)($,{label:`Links`,description:`Tables or columns this concept maps to`,children:(0,R.jsx)(ng,{value:e.links??[],onChange:e=>n(t=>({...t,links:e.length?e:void 0})),options:t})}),(0,R.jsx)($,{label:`Description`,description:`How this concept is computed or what it means`,children:(0,R.jsx)(zh,{value:e.description??``,onChange:e=>n(t=>({...t,description:e.target.value||void 0}))})})]})})]})})}function tg({value:e,onChange:t,placeholder:n}){let r=Jh(e);return(0,R.jsxs)(`div`,{className:`concept-id-input`,children:[(0,R.jsx)(`span`,{className:`concept-id-prefix`,children:`concept:`}),(0,R.jsx)(`input`,{type:`text`,"aria-label":`Concept ID`,className:`concept-id-slug`,value:r,placeholder:n??`my-concept`,onChange:e=>{t(Yh(e.target.value.replace(/\s+/g,`-`).toLowerCase()))}})]})}function ng({value:e,onChange:t,options:n}){let[r,i]=(0,M.useState)(``),[a,o]=(0,M.useState)(!1),[s,c]=(0,M.useState)(0),l=(0,M.useRef)(null),u=(0,M.useRef)(null),d=(0,M.useRef)(null);(0,M.useEffect)(()=>{function e(e){l.current&&!l.current.contains(e.target)&&o(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let f=(0,M.useMemo)(()=>new Set(e),[e]),p=(0,M.useMemo)(()=>{if(!r)return n.filter(e=>!f.has(e.id));let e=r.toLowerCase();return n.filter(t=>!f.has(t.id)&&(t.label.toLowerCase().includes(e)||t.id.toLowerCase().includes(e)))},[n,r,f]),m=p.slice(0,30),h=(0,M.useCallback)(n=>{t([...e,n]),i(``),u.current?.focus()},[e,t]),g=(0,M.useCallback)(n=>{t(e.filter(e=>e!==n))},[e,t]);(0,M.useEffect)(()=>{a&&d.current&&d.current.querySelectorAll(`[data-link-item]`)[s]?.scrollIntoView({block:`nearest`})},[s,a]);function _(e){if(!a)(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(o(!0),e.preventDefault());else switch(e.key){case`ArrowDown`:e.preventDefault(),c(e=>Math.min(e+1,m.length-1));break;case`ArrowUp`:e.preventDefault(),c(e=>Math.max(e-1,0));break;case`Enter`:e.preventDefault(),m[s]&&h(m[s].id);break;case`Escape`:e.preventDefault(),o(!1)}}function v(e){return n.find(t=>t.id===e)?.label??e}function y(e){return n.find(t=>t.id===e)?.kind??(e.includes(`#`)?`column`:`table`)}return(0,R.jsxs)(`div`,{className:`links-input`,ref:l,children:[e.length>0&&(0,R.jsx)(`div`,{className:`links-chips`,children:e.map(e=>(0,R.jsxs)(`span`,{className:`links-chip ${y(e)}`,title:e,children:[(0,R.jsx)(va,{size:10}),(0,R.jsx)(`span`,{className:`links-chip-label`,children:v(e)}),(0,R.jsx)(`button`,{type:`button`,className:`links-chip-remove`,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),g(e)},title:`Remove`,children:(0,R.jsx)(wa,{size:10})})]},e))}),(0,R.jsxs)(`div`,{className:`links-search`,children:[(0,R.jsx)(ca,{size:12}),(0,R.jsx)(`input`,{ref:u,type:`text`,"aria-label":`Search tables or columns`,className:`links-search-input`,placeholder:e.length?`Add another…`:`Search tables or columns…`,value:r,onChange:e=>{i(e.target.value),c(0)},onFocus:()=>o(!0),onKeyDown:_})]}),a&&m.length>0&&(0,R.jsxs)(`div`,{className:`links-dropdown`,ref:d,role:`listbox`,children:[m.map((e,t)=>(0,R.jsxs)(`button`,{type:`button`,"data-link-item":!0,role:`option`,"aria-selected":t===s,className:`links-dropdown-item ${t===s?`highlighted`:``}`,onMouseDown:t=>{t.preventDefault(),h(e.id)},onMouseEnter:()=>c(t),children:[(0,R.jsx)(`span`,{className:`links-kind-badge ${e.kind}`,children:e.kind===`table`?`T`:`C`}),(0,R.jsx)(`span`,{className:`links-dropdown-label`,children:e.label})]},e.id)),p.length>30&&(0,R.jsxs)(`div`,{className:`links-dropdown-more`,children:[p.length-30,` more — type to narrow`]})]})]})}function rg(){let{workspace:e,tables:t,handleSaveTenantPolicy:n,handleSuggestTenantPolicy:r,saveStatus:i,busy:a}=vr(),{refreshRagStatus:o}=jr(),[s,c]=(0,M.useState)(!1),l=(0,M.useCallback)(async(e,t)=>{let r=await n(e,t);return r&&o(),r},[n,o]);if(!e)return null;let u=e.tenantPolicy??null;return u?s?(0,R.jsx)(`main`,{className:`main-pane`,children:(0,R.jsx)(ag,{tenantPolicy:u,tables:t,busy:a,saveStatus:i,onSave:async(e,t)=>{let n=await l(e,t);return n&&c(!1),n},onCancel:()=>c(!1)},u.schemaId)}):(0,R.jsx)(`main`,{className:`main-pane`,children:(0,R.jsx)(ig,{tenantPolicy:u,onEdit:()=>c(!0)})}):(0,R.jsx)(`main`,{className:`main-pane`,children:(0,R.jsx)(cg,{tables:t,schemaId:e.schemaId,aiConfigured:e.aiConfigured,busy:a,onSave:l,onSuggest:r,saveStatus:i})})}function ig({tenantPolicy:e,onEdit:t}){let n=e.coverage.reduce((e,t)=>(e[t.classification]=(e[t.classification]??0)+1,e),{}),r=e.coverage.length,i=r-(n.unknown??0),a=r>0?Math.round(i/r*100):0;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`main-hd`,children:[(0,R.jsxs)(`div`,{className:`main-title`,children:[(0,R.jsxs)(`h1`,{children:[(0,R.jsx)(fa,{size:18,style:{display:`inline`,marginRight:8}}),`Multi-Tenancy`]}),(0,R.jsxs)(`div`,{className:`main-sub`,children:[`Schema: `,e.schemaId,` · `,a,`% table coverage (`,i,`/`,r,`)`,(0,R.jsx)(Ih,{variant:e.enforcement===`strict`?`danger`:`warning`,style:{marginLeft:8},children:e.enforcement})]})]}),(0,R.jsx)(`div`,{className:`main-actions`,children:(0,R.jsxs)(`button`,{type:`button`,className:`btn`,onClick:t,children:[(0,R.jsx)(Yi,{size:14}),` Edit`]})})]}),(0,R.jsx)(`div`,{className:`main-body`,children:(0,R.jsxs)(`div`,{className:`stack`,style:{padding:`var(--pad-y) var(--pad-x)`},children:[(0,R.jsx)(ug,{title:`Coverage`,children:(0,R.jsxs)(`div`,{className:`grid-4`,children:[(0,R.jsx)(dg,{label:`Root`,count:n.root??0,variant:`primary`}),(0,R.jsx)(dg,{label:`Scoped`,count:n.scoped??0,variant:`primary`}),(0,R.jsx)(dg,{label:`Global`,count:n.global??0,variant:`secondary`}),(0,R.jsx)(dg,{label:`Unknown`,count:n.unknown??0,variant:`warning`})]})}),(0,R.jsx)(ug,{title:`Tenant Roots`,count:e.roots.length,children:(0,R.jsx)(`div`,{style:{display:`grid`,gap:8},children:e.roots.map(e=>(0,R.jsxs)(`div`,{className:`card`,style:{padding:12},children:[(0,R.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:8},children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`mono`,style:{fontWeight:600,fontSize:13},children:e.id}),(0,R.jsx)(`span`,{className:`muted`,style:{marginLeft:8,fontSize:12},children:e.label})]}),(0,R.jsxs)(Ih,{variant:`outline`,children:[`col: `,e.tenantIdColumn]})]}),e.parent&&(0,R.jsxs)(`p`,{className:`muted tiny`,style:{marginTop:4},children:[`Parent: `,(0,R.jsx)(`code`,{children:e.parent.root}),` via `,(0,R.jsx)(`code`,{children:e.parent.foreignKey})]})]},e.id))})}),e.hierarchy.length>0&&(0,R.jsx)(ug,{title:`Hierarchy Edges`,count:e.hierarchy.length,children:(0,R.jsx)(`div`,{style:{display:`grid`,gap:8},children:e.hierarchy.map(e=>(0,R.jsxs)(`div`,{className:`card`,style:{padding:12,fontSize:13},children:[(0,R.jsx)(`code`,{children:e.parent}),(0,R.jsx)(`span`,{className:`muted`,style:{margin:`0 8px`},children:`→`}),(0,R.jsx)(`code`,{children:e.child}),(0,R.jsxs)(`div`,{className:`muted tiny`,style:{marginTop:4},children:[`FK: `,e.foreignKey]})]},`${e.parent}-${e.child}`))})}),e.scopedTables.length>0&&(0,R.jsx)(ug,{title:`Scoped Tables`,count:e.scopedTables.length,defaultOpen:!1,children:(0,R.jsx)(`div`,{style:{display:`grid`,gap:8},children:e.scopedTables.map(e=>(0,R.jsxs)(`div`,{className:`card`,style:{padding:12},children:[(0,R.jsx)(`span`,{className:`mono`,style:{fontWeight:600,fontSize:13},children:e.id}),(0,R.jsx)(`div`,{style:{marginTop:4,display:`grid`,gap:4},children:e.scopeThrough.map((e,t)=>(0,R.jsxs)(`p`,{className:`muted tiny`,children:[`via `,(0,R.jsx)(Ih,{variant:`outline`,children:e.root}),` `,`column`in e?(0,R.jsxs)(`span`,{children:[`column `,(0,R.jsx)(`code`,{children:e.column})]}):(0,R.jsxs)(`span`,{children:[`join `,e.join.map(e=>`${e.from} -> ${e.to}`).join(`, `)]})]},t))})]},e.id))})}),e.polymorphicTables.length>0&&(0,R.jsx)(ug,{title:`Polymorphic Tables`,count:e.polymorphicTables.length,defaultOpen:!1,children:(0,R.jsx)(`div`,{style:{display:`grid`,gap:8},children:e.polymorphicTables.map(e=>(0,R.jsxs)(`div`,{className:`card`,style:{padding:12},children:[(0,R.jsx)(`span`,{className:`mono`,style:{fontWeight:600,fontSize:13},children:e.id}),(0,R.jsxs)(`p`,{className:`muted tiny`,style:{marginTop:4},children:[`Type: `,(0,R.jsx)(`code`,{children:e.typeColumn}),` · ID: `,(0,R.jsx)(`code`,{children:e.idColumn})]}),(0,R.jsx)(`div`,{style:{marginTop:4,display:`flex`,flexWrap:`wrap`,gap:4},children:Object.entries(e.mapping).map(([e,t])=>(0,R.jsxs)(Ih,{variant:`outline`,children:[e,` → `,t]},e))})]},e.id))})}),e.globalTables.length>0&&(0,R.jsx)(ug,{title:`Global Tables`,count:e.globalTables.length,defaultOpen:!1,children:(0,R.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8},children:e.globalTables.map(e=>(0,R.jsx)(Ih,{variant:`secondary`,children:e},e))})}),(0,R.jsx)(ug,{title:`Table Coverage`,count:e.coverage.length,defaultOpen:!1,children:(0,R.jsx)(`div`,{className:`card`,children:(0,R.jsx)(`div`,{className:`card-bd tight`,children:(0,R.jsxs)(`table`,{className:`tbl`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{children:`Table`}),(0,R.jsx)(`th`,{children:`Classification`}),(0,R.jsx)(`th`,{children:`Scope Roots`})]})}),(0,R.jsx)(`tbody`,{children:e.coverage.map(e=>(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`td`,{children:(0,R.jsx)(`span`,{className:`mono`,children:e.tableId})}),(0,R.jsx)(`td`,{children:(0,R.jsx)(Ih,{variant:e.classification===`unknown`?`warning`:e.classification===`global`?`secondary`:`outline`,children:e.classification})}),(0,R.jsx)(`td`,{className:`muted tiny`,children:e.scopeRoots?.join(`, `)??`—`})]},e.tableId))})]})})})}),e.warnings.length>0&&(0,R.jsx)(ug,{title:`Policy Warnings`,count:e.warnings.length,children:(0,R.jsx)(`div`,{style:{display:`grid`,gap:8},children:e.warnings.map(e=>(0,R.jsx)(`pre`,{className:`warning-block`,children:fg(e)},String(e)))})})]})})]})}function ag({tenantPolicy:e,tables:t,busy:n,saveStatus:r,onSave:i,onCancel:a}){let[o,s]=(0,M.useState)(()=>pg(e)),[c,l]=(0,M.useState)(()=>e.body);return(0,R.jsx)(lg,{tables:t,frontmatter:o,body:c,busy:n,saveStatus:r,onFrontmatterChange:s,onBodyChange:l,onConfirm:()=>void i(o,c||void 0),onBack:a,title:`Edit Tenant Policy`,backLabel:`Cancel`,confirmLabel:`Save Changes`,badgeLabel:`Saved`})}function og(e,t){switch(t.type){case`set_mode`:return{...e,mode:t.payload};case`set_draftStatus`:return{...e,draftStatus:t.payload};case`set_draftFrontmatter`:return{...e,draftFrontmatter:t.payload};case`set_draftBody`:return{...e,draftBody:t.payload};case`set_enforcement`:return{...e,enforcement:t.payload};case`set_rootTenantIdColumn`:return{...e,rootTenantIdColumn:t.payload};case`set_rootLabel`:return{...e,rootLabel:t.payload};case`select_root_table`:return{...e,rootTableId:t.tableId,rootLabel:t.label,rootTenantIdColumn:``};case`toggle_global_table`:return{...e,globalTableIds:t.checked?[...e.globalTableIds,t.tableId]:e.globalTableIds.filter(e=>e!==t.tableId)};case`ai_draft_complete`:return{...e,draftFrontmatter:t.frontmatter,draftBody:t.body,mode:`review`,draftStatus:{kind:`success`,text:`AI draft ready for review.`}};case`manual_to_review`:return{...e,draftFrontmatter:t.frontmatter,draftBody:t.body,mode:`review`}}}var sg={mode:`choose`,draftStatus:null,draftFrontmatter:null,draftBody:``,enforcement:`strict`,rootTableId:``,rootTenantIdColumn:``,rootLabel:``,globalTableIds:[]};function cg({tables:e,schemaId:t,aiConfigured:n,busy:r,onSave:i,onSuggest:a,saveStatus:o}){let[s,c]=(0,M.useReducer)(og,sg),{mode:l,draftStatus:u,draftFrontmatter:d,draftBody:f,enforcement:p,rootTableId:m,rootTenantIdColumn:h,rootLabel:g,globalTableIds:_}=s,v=e.find(e=>e.physical.id===m)?.physical.columns??[];async function y(){c({type:`set_draftStatus`,payload:{kind:`loading`,text:`Analyzing schema and drafting tenant policy...`}});try{let e=await a();c({type:`ai_draft_complete`,frontmatter:e.frontmatter,body:e.body})}catch(e){c({type:`set_draftStatus`,payload:{kind:`error`,text:e instanceof Error?e.message:String(e)}})}}function b(){if(!m||!h||!g.trim())return;let e={schemaId:t,enforcement:p,roots:[{id:m,tenantIdColumn:h,label:g.trim()}],..._.length>0?{globalTables:_}:{}};c({type:`manual_to_review`,frontmatter:e,body:`# Tenant Policy
49
+ `},tl=0,nl=[];function rl(e){var t=M.useRef([]),n=M.useRef([0,0]),r=M.useRef(),i=M.useState(tl++)[0],a=M.useState(Tc)[0],o=M.useRef(e);M.useEffect(function(){o.current=e},[e]),M.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=tc([e.lockRef.current],(e.shards||[]).map(Qc),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=M.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=Xc(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=Uc(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Uc(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return Yc(h,t,e,h===`h`?s:c,!0)},[]),c=M.useCallback(function(e){var n=e;if(nl.length&&nl[nl.length-1]===a){var r=`deltaY`in n?Zc(n):Xc(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&$c(e.delta,r)})[0];if(i&&i.should)n.cancelable&&n.preventDefault();else if(!i){var c=(o.current.shards||[]).map(Qc).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=M.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:il(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=M.useCallback(function(e){n.current=Xc(e),r.current=void 0},[]),d=M.useCallback(function(t){l(t.type,Zc(t),t.target,s(t,e.lockRef.current))},[]),f=M.useCallback(function(t){l(t.type,Xc(t),t.target,s(t,e.lockRef.current))},[]);M.useEffect(function(){return nl.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Rc),document.addEventListener(`touchmove`,c,Rc),document.addEventListener(`touchstart`,u,Rc),function(){nl=nl.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Rc),document.removeEventListener(`touchmove`,c,Rc),document.removeEventListener(`touchstart`,u,Rc)}},[]);var p=e.removeScrollBar,m=e.inert;return M.createElement(M.Fragment,null,m?M.createElement(a,{styles:el(i)}):null,p?M.createElement(Fc,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function il(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var al=hc(gc,rl),ol=M.forwardRef(function(e,t){return M.createElement(vc,$s({},e,{ref:t,sideCar:al}))});ol.classNames=vc.classNames;var sl=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},cl=new WeakMap,ll=new WeakMap,ul={},dl=0,fl=function(e){return e&&(e.host||fl(e.parentNode))},pl=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=fl(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},ml=function(e,t,n,r){var i=pl(t,Array.isArray(e)?e:[e]);ul[n]||(ul[n]=new WeakMap);var a=ul[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(cl.get(e)||0)+1,l=(a.get(e)||0)+1;cl.set(e,c),a.set(e,l),o.push(e),c===1&&i&&ll.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),dl++,function(){o.forEach(function(e){var t=cl.get(e)-1,i=a.get(e)-1;cl.set(e,t),a.set(e,i),t||(ll.has(e)||e.removeAttribute(r),ll.delete(e)),i||e.removeAttribute(n)}),dl--,dl||(cl=new WeakMap,cl=new WeakMap,ll=new WeakMap,ul={})}},hl=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||sl(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),ml(r,i,n,`aria-hidden`)):function(){return null}},gl=Object.defineProperty,_l=(e,t)=>gl(e,`name`,{value:t,configurable:!0}),vl=`Dialog`,[yl,bl]=so(vl),[xl,Sl]=yl(vl),Cl=_l(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=M.useRef(null),c=M.useRef(null),{nodes:l,registry:u}=js(),[d,f]=Do({prop:r,defaultProp:i??!1,onChange:a,caller:vl}),[p,m]=M.useState(0),[h,g]=M.useState(0);return(0,R.jsx)(xl,{scope:t,triggerRef:s,contentRef:c,contentId:Wo(),titleId:Wo(),descriptionId:Wo(),titlePresent:p>0,descriptionPresent:h>0,setTitleCount:m,setDescriptionCount:g,open:d,onOpenChange:f,onOpenToggle:M.useCallback(()=>f(e=>!e),[f]),modal:o,branchNodes:l,branchRegistry:u,children:n})},`Dialog`),wl=`DialogPortal`,[Tl,El]=yl(wl,{forceMount:void 0}),Dl=_l(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=Sl(wl,t);return(0,R.jsx)(Tl,{scope:t,forceMount:n,children:M.Children.map(r,e=>(0,R.jsx)(Fo,{present:n||a.open,children:(0,R.jsx)(Gs,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),Ol=`DialogOverlay`,kl=M.forwardRef(_l(function(e,t){let n=El(Ol,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Sl(Ol,e.__scopeDialog);return a.modal?(0,R.jsx)(Fo,{present:r||a.open,children:(0,R.jsx)(jl,{...i,ref:t})}):null},`DialogOverlay`)),Al=Na(`DialogOverlay.RemoveScroll`),jl=M.forwardRef(_l(function(e,t){let{__scopeDialog:n,...r}=e,i=Sl(Ol,n),a=V(t,_s());return(0,R.jsx)(ol,{as:Al,allowPinchZoom:!0,shards:M.useMemo(()=>[i.contentRef,...i.branchNodes.map(e=>({current:e}))],[i.contentRef,i.branchNodes]),children:(0,R.jsx)(Qa.div,{"data-state":Hl(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),Ml=`DialogContent`,Nl=M.forwardRef(_l(function(e,t){let n=El(Ml,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Sl(Ml,e.__scopeDialog);return(0,R.jsx)(Fo,{present:r||a.open,children:a.modal?(0,R.jsx)(Pl,{...i,ref:t}):(0,R.jsx)(Fl,{...i,ref:t})})},`DialogContent`)),Pl=M.forwardRef(_l(function(e,t){let n=Sl(Ml,e.__scopeDialog),r=M.useRef(null),i=V(t,n.contentRef,r);return M.useEffect(()=>{let e=r.current;if(e)return hl(e)},[]),(0,R.jsx)(Il,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:mo(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:mo(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:mo(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),Fl=M.forwardRef(_l(function(e,t){let n=Sl(Ml,e.__scopeDialog),r=M.useRef(!1),i=M.useRef(!1);return(0,R.jsx)(Il,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),Il=M.forwardRef(_l(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,"aria-describedby":o,children:s,...c}=e,l=Sl(Ml,n);return Zs(),(0,R.jsx)(As,{registry:l.branchRegistry,children:(0,R.jsx)(Os,{asChild:!0,loop:!0,trapped:r,branches:l.branchNodes,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,R.jsx)(gs,{role:`dialog`,id:l.contentId,"aria-labelledby":l.titlePresent?l.titleId:void 0,"aria-describedby":l.descriptionPresent?Vl(o,l.descriptionId):o,"data-state":Hl(l.open),...c,ref:t,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1),children:s})})})},`DialogContentImpl`)),Ll=M.forwardRef(_l(function(e,t){let{__scopeDialog:n,...r}=e,i=Sl(`DialogTitle`,n),{setTitleCount:a}=i;return lo(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,R.jsx)(Qa.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),Rl=M.forwardRef(_l(function(e,t){let{__scopeDialog:n,...r}=e,i=Sl(`DialogDescription`,n),{setDescriptionCount:a}=i;return lo(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,R.jsx)(Qa.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),zl=`DialogClose`,Bl=M.forwardRef(_l(function(e,t){let{__scopeDialog:n,...r}=e,i=Sl(zl,n);return(0,R.jsx)(Qa.button,{type:`button`,...r,ref:t,onClick:mo(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function Vl(...e){let t=new Set;for(let n of e)if(typeof n==`string`)for(let e of String(n).trim().split(/\s+/))e&&t.add(e);return t.size>0?Array.from(t).join(` `):void 0}_l(Vl,`concatAriaDescribedby`);function Hl(e){return e?`open`:`closed`}_l(Hl,`getState`);var Ul=Object.defineProperty,Wl=(e,t)=>Ul(e,`name`,{value:t,configurable:!0});function Gl(e){let[t,n]=M.useState(void 0);return lo(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=0,r=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;let i=r[0];window.cancelAnimationFrame(t),t=window.requestAnimationFrame(()=>{let t,r;if(`borderBoxSize`in i){let e=i.borderBoxSize,n=Array.isArray(e)?e[0]:e;t=n.inlineSize,r=n.blockSize}else t=e.offsetWidth,r=e.offsetHeight;n({width:t,height:r})})});return r.observe(e,{box:`border-box`}),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}n(void 0)},[e]),t}Wl(Gl,`useSize`);var Kl=[`top`,`right`,`bottom`,`left`],ql=Math.min,Jl=Math.max,Yl=Math.round,Xl=Math.floor,Zl=e=>({x:e,y:e}),Ql={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function $l(e,t,n){return Jl(e,ql(t,n))}function eu(e,t){return typeof e==`function`?e(t):e}function tu(e){return e.split(`-`)[0]}function nu(e){return e.split(`-`)[1]}function ru(e){return e===`x`?`y`:`x`}function iu(e){return e===`y`?`height`:`width`}function au(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function ou(e){return ru(au(e))}function su(e,t,n){n===void 0&&(n=!1);let r=nu(e),i=ou(e),a=iu(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=gu(o)),[o,gu(o)]}function cu(e){let t=gu(e);return[lu(e),t,lu(t)]}function lu(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var uu=[`left`,`right`],du=[`right`,`left`],fu=[`top`,`bottom`],pu=[`bottom`,`top`];function mu(e,t,n){switch(e){case`top`:case`bottom`:return n?t?du:uu:t?uu:du;case`left`:case`right`:return t?fu:pu;default:return[]}}function hu(e,t,n,r){let i=nu(e),a=mu(tu(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(lu)))),a}function gu(e){let t=tu(e);return Ql[t]+e.slice(t.length)}function _u(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function vu(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:_u(e)}function yu(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function bu(e,t,n){let{reference:r,floating:i}=e,a=au(t),o=ou(t),s=iu(o),c=tu(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=nu(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function xu(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=eu(t,e),p=vu(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=yu(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=yu(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var Su=50,Cu=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:xu},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=bu(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<Su&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=bu(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},wu=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=eu(e,t)||{};if(l==null)return{};let d=vu(u),f={x:n,y:r},p=ou(i),m=iu(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;C&&await(o.isElement==null?void 0:o.isElement(S))||(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=ql(d[_],T),D=ql(d[v],T),O=C-h[m]-D,k=C/2-h[m]/2+w,A=$l(E,k,O),j=!c.arrow&&nu(i)!=null&&k!==A&&a.reference[m]/2-(k<E?E:D)-h[m]/2<0,M=j?k<E?k-E:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),Tu=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=eu(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=tu(r),_=au(o),v=tu(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[gu(o)]:cu(o)),x=p!==`none`;!d&&x&&b.push(...hu(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=su(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===au(t)||T.every(e=>au(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=au(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function Eu(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Du(e){return Kl.some(t=>e[t]>=0)}var Ou=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=eu(e,t);switch(i){case`referenceHidden`:{let e=Eu(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Du(e)}}}case`escaped`:{let e=Eu(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Du(e)}}}default:return{}}}}},ku=new Set([`left`,`top`]);async function Au(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=tu(n),s=nu(n),c=au(n)===`y`,l=ku.has(o)?-1:1,u=a&&c?-1:1,d=eu(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var ju=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await Au(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},Mu=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=eu(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=au(i),p=ru(f),m=u[p],h=u[f],g=(e,t)=>$l(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},Nu=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=eu(e,t),u={x:n,y:r},d=au(i),f=ru(d),p=u[f],m=u[d],h=eu(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=ku.has(tu(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},Pu=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=eu(e,t),c=await i.detectOverflow(t,s),l=tu(n),u=nu(n),d=au(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=ql(p-c[m],g),y=ql(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*Jl(c.left,c.right):S=p-2*Jl(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function Fu(){return typeof window<`u`}function Iu(e){return zu(e)?(e.nodeName||``).toLowerCase():`#document`}function Lu(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ru(e){return((zu(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function zu(e){return Fu()?e instanceof Node||e instanceof Lu(e).Node:!1}function Bu(e){return Fu()?e instanceof Element||e instanceof Lu(e).Element:!1}function Vu(e){return Fu()?e instanceof HTMLElement||e instanceof Lu(e).HTMLElement:!1}function Hu(e){return!Fu()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof Lu(e).ShadowRoot}function Uu(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=ed(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Wu(e){return/^(table|td|th)$/.test(Iu(e))}function Gu(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Ku=/transform|translate|scale|rotate|perspective|filter/,qu=/paint|layout|strict|content/,Ju=e=>!!e&&e!==`none`,Yu;function Xu(e){let t=Bu(e)?ed(e):e;return Ju(t.transform)||Ju(t.translate)||Ju(t.scale)||Ju(t.rotate)||Ju(t.perspective)||!Qu()&&(Ju(t.backdropFilter)||Ju(t.filter))||Ku.test(t.willChange||``)||qu.test(t.contain||``)}function Zu(e){let t=nd(e);for(;Vu(t)&&!$u(t);){if(Xu(t))return t;if(Gu(t))return null;t=nd(t)}return null}function Qu(){return Yu??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Yu}function $u(e){return/^(html|body|#document)$/.test(Iu(e))}function ed(e){return Lu(e).getComputedStyle(e)}function td(e){return Bu(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function nd(e){if(Iu(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Hu(e)&&e.host||Ru(e);return Hu(t)?t.host:t}function U(e){let t=nd(e);return $u(t)?(e.ownerDocument||e).body:Vu(t)&&Uu(t)?t:U(t)}function W(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=U(e),i=r===e.ownerDocument?.body,a=Lu(r);if(i){let e=G(a);return t.concat(a,a.visualViewport||[],Uu(r)?r:[],e&&n?W(e):[])}return t.concat(r,W(r,[],n))}function G(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function K(e){let t=ed(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Vu(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Yl(n)!==a||Yl(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function q(e){return Bu(e)?e:e.contextElement}function rd(e){let t=q(e);if(!Vu(t))return Zl(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=K(t),o=(a?Yl(n.width):n.width)/r,s=(a?Yl(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var id=Zl(0);function ad(e){let t=Lu(e);return!Qu()||!t.visualViewport?id:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function od(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Lu(e)}function sd(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=q(e),o=Zl(1);t&&(r?Bu(r)&&(o=rd(r)):o=rd(e));let s=od(a,n,r)?ad(a):Zl(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=Lu(a),t=Bu(r)?Lu(r):r,n=e,i=G(n);for(;i&&t!==n;){let e=rd(i),t=i.getBoundingClientRect(),r=ed(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=Lu(i),i=G(n)}}return yu({width:u,height:d,x:c,y:l})}function cd(e,t){let n=td(e).scrollLeft;return t?t.left+n:sd(Ru(e)).left+n}function ld(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-cd(e,n),y:n.top+t.scrollTop}}function ud(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Ru(r),s=t?Gu(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Zl(1),u=Zl(0),d=Vu(r);if((d||!a)&&((Iu(r)!==`body`||Uu(o))&&(c=td(r)),d)){let e=sd(r);l=rd(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?ld(o,c):Zl(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function dd(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function fd(e){let t=td(e),n=e.ownerDocument.body,r=Jl(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Jl(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+cd(e),o=-t.scrollTop;return ed(n).direction===`rtl`&&(a+=Jl(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var pd=25;function md(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=Lu(e),a=Ru(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Qu()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(cd(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=pd&&(s-=o)}return{width:s,height:c,x:l,y:u}}function hd(e,t){let n=sd(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=rd(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function gd(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=md(e,n,t);else if(t===`document`)r=fd(Ru(e));else if(Bu(t))r=hd(t,n);else{let n=ad(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return yu(r)}function _d(e,t){let n=t.get(e);if(n)return n;let r=W(e,[],!1).filter(e=>Bu(e)&&Iu(e)!==`body`),i=null,a=ed(e).position===`fixed`,o=a?nd(e):e;for(;Bu(o)&&!$u(o);){let e=ed(o),t=Xu(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=nd(o)}return t.set(e,r),r}function vd(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Gu(t)?[]:_d(t,this._c):[].concat(n),r],o=gd(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=gd(t,a[e],i);s=Jl(n.top,s),c=ql(n.right,c),l=ql(n.bottom,l),u=Jl(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function yd(e){let{width:t,height:n}=K(e);return{width:t,height:n}}function bd(e,t,n){let r=Vu(t),i=Ru(t),a=n===`fixed`,o=sd(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=Zl(0);if((r||!a)&&((Iu(t)!==`body`||Uu(i))&&(s=td(t)),r)){let e=sd(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=cd(i));let l=i&&!r&&!a?ld(i,s):Zl(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function xd(e){return ed(e).position===`static`}function Sd(e,t){if(!Vu(e)||ed(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Ru(e)===n&&(n=n.ownerDocument.body),n}function Cd(e,t){let n=Lu(e);if(Gu(e))return n;if(!Vu(e)){let t=nd(e);for(;t&&!$u(t);){if(Bu(t)&&!xd(t))return t;t=nd(t)}return n}let r=Sd(e,t);for(;r&&Wu(r)&&xd(r);)r=Sd(r,t);return r&&$u(r)&&xd(r)&&!Xu(r)?n:r||Zu(e)||n}var wd=async function(e){let t=this.getOffsetParent||Cd,n=this.getDimensions,r=await n(e.floating);return{reference:bd(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Td(e){return ed(e).direction===`rtl`}var Ed={convertOffsetParentRelativeRectToViewportRelativeRect:ud,getDocumentElement:Ru,getClippingRect:vd,getOffsetParent:Cd,getElementRects:wd,getClientRects:dd,getDimensions:yd,getScale:rd,isElement:Bu,isRTL:Td};function Dd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Od(e,t,n){let r=null,i,a=Ru(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=Xl(d),h=Xl(a.clientWidth-(u+f)),g=Xl(a.clientHeight-(d+p)),_=Xl(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Jl(0,ql(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!Dd(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=Lu(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function kd(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=q(e),u=i||a?[...l?W(l):[],...t?W(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?Od(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?sd(e):null;c&&g();function g(){let t=sd(e);h&&!Dd(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var Ad=ju,jd=Mu,Md=Tu,Nd=Pu,Pd=Ou,Fd=wu,Id=Nu,Ld=(e,t,n)=>{let r=new Map,i=n??{},a={...Ed,...i.platform,_c:r};return Cu(e,t,{...i,platform:a})},Rd=typeof document<`u`?M.useLayoutEffect:function(){};function zd(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!zd(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!zd(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Bd(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Vd(e,t){let n=Bd(e);return Math.round(t*n)/n}function Hd(e){let t=M.useRef(e);return Rd(()=>{t.current=e}),t}function Ud(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=M.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=M.useState(r);zd(f,r)||p(r);let[m,h]=M.useState(null),[g,_]=M.useState(null),v=M.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=M.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=M.useRef(null),C=M.useRef(null),w=M.useRef(u),T=c!=null,E=Hd(c),D=Hd(i),O=Hd(l),k=M.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),Ld(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!zd(w.current,t)&&(w.current=t,Ya.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);Rd(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=M.useRef(!1);Rd(()=>(A.current=!0,()=>{A.current=!1}),[]),Rd(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=M.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),N=M.useMemo(()=>({reference:b,floating:x}),[b,x]),ee=M.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=Vd(N.floating,u.x),r=Vd(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Bd(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return M.useMemo(()=>({...u,update:k,refs:j,elements:N,floatingStyles:ee}),[u,k,j,N,ee])}var Wd=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:Fd({element:r.current,padding:i}).fn(n):r?Fd({element:r,padding:i}).fn(n):{}}}},Gd=(e,t)=>{let n=Ad(e);return{name:n.name,fn:n.fn,options:[e,t]}},Kd=(e,t)=>{let n=jd(e);return{name:n.name,fn:n.fn,options:[e,t]}},qd=(e,t)=>({fn:Id(e).fn,options:[e,t]}),Jd=(e,t)=>{let n=Md(e);return{name:n.name,fn:n.fn,options:[e,t]}},Yd=(e,t)=>{let n=Nd(e);return{name:n.name,fn:n.fn,options:[e,t]}},Xd=(e,t)=>{let n=Pd(e);return{name:n.name,fn:n.fn,options:[e,t]}},Zd=(e,t)=>{let n=Wd(e);return{name:n.name,fn:n.fn,options:[e,t]}},Qd=Object.defineProperty,$d=M.forwardRef(((e,t)=>Qd(e,`name`,{value:t,configurable:!0}))(function(e,t){let{children:n,width:r=10,height:i=5,...a}=e;return(0,R.jsx)(Qa.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,R.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})},`Arrow`)),ef=Object.defineProperty,tf=(e,t)=>ef(e,`name`,{value:t,configurable:!0}),nf={Partial:`partial`,Always:`always`},rf={Optimized:`optimized`,Always:`always`},af=`Popper`,[of,sf]=so(af),[cf,lf]=of(af),uf=tf(e=>{let{__scopePopper:t,children:n}=e,[r,i]=M.useState(null),[a,o]=M.useState(void 0);return(0,R.jsx)(cf,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),df=`PopperAnchor`,ff=M.forwardRef(tf(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=lf(df,n),o=M.useRef(null),s=a.onAnchorChange,c=V(t,M.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=M.useRef(null);M.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&Sf(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,R.jsx)(Qa.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})},`PopperAnchor`)),pf=`PopperContent`,[mf,hf]=of(pf),gf=M.forwardRef(tf(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=nf.Partial,hideWhenDetached:f=!1,updatePositionStrategy:p=rf.Optimized,onPlaced:m,...h}=e,g=lf(pf,n),[_,v]=M.useState(null),y=V(t,v),[b,x]=M.useState(null),S=Gl(b),C=S?.width??0,w=S?.height??0,T=r+(a===`center`?``:`-`+a),E=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(l)?l:[l],O=D.length>0,k={padding:E,boundary:D.filter(bf),altBoundary:O},{refs:A,floatingStyles:j,placement:N,isPositioned:ee,middlewareData:te}=Ud({strategy:`fixed`,placement:T,whileElementsMounted:tf((...e)=>kd(...e,{animationFrame:p===rf.Always}),`whileElementsMounted`),elements:{reference:g.anchor},middleware:[Gd({mainAxis:i+w,alignmentAxis:o}),c&&Kd({mainAxis:!0,crossAxis:!1,...d===nf.Partial?{limiter:qd()}:{},...k}),c&&Jd({...k}),Yd({...k,apply:tf(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),b&&Zd({element:b,padding:s}),xf({arrowWidth:C,arrowHeight:w}),f&&Xd(O?{strategy:`referenceHidden`,...k}:{strategy:`referenceHidden`,padding:k.padding,altBoundary:k.altBoundary})]}),P=g.setPlacementState;lo(()=>(P(N),()=>{P(void 0)}),[N,P]);let[ne,re]=Sf(N),ie=cs(m);lo(()=>{ee&&ie?.()},[ee,ie]);let ae=te.arrow?.x,oe=te.arrow?.y,se=te.arrow?.centerOffset!==0,[ce,le]=M.useState();return lo(()=>{_&&le(window.getComputedStyle(_).zIndex)},[_]),(0,R.jsx)(`div`,{ref:A.setFloating,"data-radix-popper-content-wrapper":``,style:{...j,transform:ee?j.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ce,"--radix-popper-transform-origin":[te.transformOrigin?.x,te.transformOrigin?.y].join(` `),...te.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,R.jsx)(mf,{scope:n,placedSide:ne,placedAlign:re,onArrowChange:x,arrowX:ae,arrowY:oe,shouldHideArrow:se,children:(0,R.jsx)(Qa.div,{"data-side":ne,"data-align":re,...h,ref:y,style:{...h.style,animation:ee?h.style?.animation:`none`}})})})},`PopperContent`)),_f=`PopperArrow`,vf={top:`bottom`,right:`left`,bottom:`top`,left:`right`},yf=M.forwardRef(tf(function(e,t){let{__scopePopper:n,...r}=e,i=hf(_f,n),a=vf[i.placedSide];return(0,R.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,R.jsx)($d,{...r,ref:t,style:{...r.style,display:`block`}})})},`PopperArrow`));function bf(e){return e!==null}tf(bf,`isNotNull`);var xf=tf(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Sf(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function Sf(e){let[t,n=`center`]=e.split(`-`);return[t,n]}tf(Sf,`getSideAndAlignFromPlacement`);var Cf=Object.defineProperty,wf=(e,t)=>Cf(e,`name`,{value:t,configurable:!0}),Tf={Horizontal:`horizontal`,Vertical:`vertical`},Ef=Tf.Horizontal,Df=Object.values(Tf),Of=M.forwardRef(wf(function(e,t){let{decorative:n,orientation:r=Ef,...i}=e,a=kf(r)?r:Ef,o=a===Tf.Vertical?a:void 0,s=n?{role:`none`}:{"aria-orientation":o,role:`separator`};return(0,R.jsx)(Qa.div,{"data-orientation":a,...s,...i,ref:t})},`Separator`));function kf(e){return Df.includes(e)}wf(kf,`isValidOrientation`);var Af=Object.defineProperty,jf=(e,t)=>Af(e,`name`,{value:t,configurable:!0}),[Mf,Nf]=so(`Tooltip`,[sf]),Pf=sf(),Ff=`TooltipProvider`,If=700,Lf=`tooltip.open`,[Rf,zf]=Mf(Ff),Bf=jf(e=>{let{__scopeTooltip:t,delayDuration:n=If,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=M.useRef(!0),s=M.useRef(!1),c=M.useRef(0);return M.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,R.jsx)(Rf,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:M.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:M.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:M.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})},`TooltipProvider`),Vf=`Tooltip`,[Hf,Uf]=Mf(Vf),Wf=jf(e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=zf(Vf,e.__scopeTooltip),l=Pf(t),[u,d]=M.useState(null),[f,p]=M.useState(void 0),m=Wo(),h=M.useRef(0),g=o??c.disableHoverableContent,_=s??c.delayDuration,v=M.useRef(!1),[y,b]=Do({prop:r,defaultProp:i??!1,onChange:jf(e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(Lf))):c.onClose(),a?.(e)},`onChange`),caller:Vf}),x=M.useMemo(()=>y?v.current?`delayed-open`:`instant-open`:`closed`,[y]),S=M.useCallback(()=>{window.clearTimeout(h.current),h.current=0,v.current=!1,b(!0)},[b]),C=M.useCallback(()=>{window.clearTimeout(h.current),h.current=0,b(!1)},[b]),w=M.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{v.current=!0,b(!0),h.current=0},_)},[_,b]);M.useEffect(()=>()=>{h.current&&=(window.clearTimeout(h.current),0)},[]);let T=f??m;return(0,R.jsx)(uf,{...l,children:(0,R.jsx)(Hf,{scope:t,contentId:T,setContentId:p,open:y,stateAttribute:x,trigger:u,onTriggerChange:d,onTriggerEnter:M.useCallback(()=>{c.isOpenDelayedRef.current?w():S()},[c.isOpenDelayedRef,w,S]),onTriggerLeave:M.useCallback(()=>{g?C():(window.clearTimeout(h.current),h.current=0)},[C,g]),onOpen:S,onClose:C,disableHoverableContent:g,children:n})})},`Tooltip`),Gf=`TooltipTrigger`,J=M.forwardRef(jf(function(e,t){let{__scopeTooltip:n,"aria-describedby":r,...i}=e,a=Uf(Gf,n),o=zf(Gf,n),s=Pf(n),c=V(t,M.useRef(null),a.onTriggerChange),l=M.useRef(!1),u=M.useRef(!1),d=M.useCallback(()=>l.current=!1,[]);return M.useEffect(()=>()=>document.removeEventListener(`pointerup`,d),[d]),(0,R.jsx)(ff,{asChild:!0,...s,children:(0,R.jsx)(Qa.button,{"aria-describedby":a.open?cp(r,a.contentId):r,"data-state":a.stateAttribute,...i,ref:c,onPointerMove:mo(e.onPointerMove,e=>{e.pointerType!==`touch`&&!u.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),u.current=!0)}),onPointerLeave:mo(e.onPointerLeave,()=>{a.onTriggerLeave(),u.current=!1}),onPointerDown:mo(e.onPointerDown,()=>{a.open&&a.onClose(),l.current=!0,document.addEventListener(`pointerup`,d,{once:!0})}),onFocus:mo(e.onFocus,()=>{l.current||a.onOpen()}),onBlur:mo(e.onBlur,a.onClose),onClick:mo(e.onClick,a.onClose)})})},`TooltipTrigger`)),Kf=`TooltipPortal`,[qf,Jf]=Mf(Kf,{forceMount:void 0}),Yf=jf(e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=Uf(Kf,t);return(0,R.jsx)(qf,{scope:t,forceMount:n,children:(0,R.jsx)(Fo,{present:n||a.open,children:(0,R.jsx)(Gs,{asChild:!0,container:i,children:r})})})},`TooltipPortal`),Xf=`TooltipContent`,Zf=M.forwardRef(jf(function(e,t){let n=Jf(Xf,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=Uf(Xf,e.__scopeTooltip);return(0,R.jsx)(Fo,{present:r||o.open,children:o.disableHoverableContent?(0,R.jsx)(ep,{side:i,...a,ref:t}):(0,R.jsx)(Qf,{side:i,...a,ref:t})})},`TooltipContent`)),Qf=M.forwardRef(jf(function(e,t){let n=Uf(Xf,e.__scopeTooltip),r=zf(Xf,e.__scopeTooltip),i=M.useRef(null),a=V(t,i),[o,s]=M.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=M.useCallback(()=>{s(null),d(!1)},[d]),p=M.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=rp(r,np(r,n.getBoundingClientRect())),a=ip(t.getBoundingClientRect()),o=op([...i,...a]);s(o),d(!0)},[d]);return M.useEffect(()=>()=>f(),[f]),M.useEffect(()=>{if(c&&u){let e=jf(e=>p(e,u),`handleTriggerLeave`),t=jf(e=>p(e,c),`handleContentLeave`);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),M.useEffect(()=>{if(o){let e=jf(e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!ap(n,o);r?f():i&&(f(),l())},`handleTrackPointerGrace`);return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,R.jsx)(ep,{...e,ref:a})},`TooltipContentHoverable`)),$f=Ia(`TooltipContent`),ep=M.forwardRef(jf(function(e,t){let{__scopeTooltip:n,children:r,"aria-label":i,id:a,onEscapeKeyDown:o,onPointerDownOutside:s,...c}=e,l=Uf(Xf,n),u=Pf(n),{onClose:d}=l,[f,p]=M.useState(null),m=V(t,p);Ms(f),M.useEffect(()=>(document.addEventListener(Lf,d),()=>document.removeEventListener(Lf,d)),[d]),M.useEffect(()=>{if(l.trigger){let e=jf(e=>{e.target instanceof Node&&e.target.contains(l.trigger)&&d()},`handleScroll`);return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[l.trigger,d]);let{setContentId:h}=l;return lo(()=>(h(a),()=>{h(void 0)}),[a,h]),(0,R.jsx)(gs,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:d,children:(0,R.jsxs)(gf,{"data-state":l.stateAttribute,role:i?void 0:`tooltip`,id:i?void 0:l.contentId,...u,...c,ref:m,style:{...c.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,R.jsx)($f,{children:r}),i?(0,R.jsx)(ro,{id:l.contentId,role:`tooltip`,children:i}):null]})})},`TooltipContentImpl`)),tp=M.forwardRef(jf(function(e,t){let{__scopeTooltip:n,...r}=e,i=Pf(n);return(0,R.jsx)(yf,{...i,...r,ref:t})},`TooltipArrow`));function np(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}jf(np,`getExitSideFromRect`);function rp(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}jf(rp,`getPaddedExitPoints`);function ip(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}jf(ip,`getPointsFromRect`);function ap(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}jf(ap,`isPointInPolygon`);function op(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),sp(t)}jf(op,`getHull`);function sp(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}jf(sp,`getHullPresorted`);function cp(...e){let t=new Set;for(let n of e)if(typeof n==`string`)for(let e of String(n).trim().split(/\s+/))e&&t.add(e);return t.size>0?Array.from(t).join(` `):void 0}jf(cp,`concatAriaDescribedby`);var lp=768;function up(){let[e,t]=M.useState(()=>typeof window<`u`?window.innerWidth<lp:void 0);return M.useEffect(()=>{let e=window.matchMedia(`(max-width: 767px)`),n=()=>{t(window.innerWidth<lp)};return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),!!e}var dp=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},fp=(e,t)=>({classGroupId:e,validator:t}),pp=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),mp=`-`,hp=[],gp=`arbitrary..`,_p=e=>{let t=bp(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return yp(e);let n=e.split(mp);return vp(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?dp(i,t):t:i||hp}return n[e]||hp}}},vp=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=vp(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(mp):e.slice(t).join(mp),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},yp=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?gp+r:void 0})(),bp=e=>{let{theme:t,classGroups:n}=e;return xp(n,t)},xp=(e,t)=>{let n=pp();for(let r in e){let i=e[r];Sp(i,n,r,t)}return n},Sp=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];Cp(i,t,n,r)}},Cp=(e,t,n,r)=>{typeof e==`string`?wp(e,t,n):typeof e==`function`?Tp(e,t,n,r):Ep(e,t,n,r)},wp=(e,t,n)=>{let r=e===``?t:Dp(t,e);r.classGroupId=n},Tp=(e,t,n,r)=>{Op(e)?Sp(e(r),t,n,r):(t.validators===null&&(t.validators=[]),t.validators.push(fp(n,e)))},Ep=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];Sp(o,Dp(t,a),n,r)}},Dp=(e,t)=>{let n=e,r=t.split(mp),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=pp(),n.nextPart.set(t,i)),n=i}return n},Op=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,kp=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},Ap=`!`,jp=`:`,Mp=[],Np=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),Pp=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===jp){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(Ap)?(c=s.slice(0,-1),l=!0):s.startsWith(Ap)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return Np(t,l,c,u)};if(t){let e=t+jp,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):Np(Mp,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},Fp=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},Ip=e=>({cache:kp(e.cacheSize),parseClassName:Pp(e),sortModifiers:Fp(e),postfixLookupClassGroupIds:Lp(e),..._p(e)}),Lp=e=>{let t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let e=0;e<n.length;e++)t[n[e]]=!0;return t},Rp=/\s+/,zp=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a,postfixLookupClassGroupIds:o}=t,s=[],c=e.trim().split(Rp),l=``;for(let e=c.length-1;e>=0;--e){let t=c[e],{isExternal:u,modifiers:d,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:m}=n(t);if(u){l=t+(l.length>0?` `+l:l);continue}let h=!!m,g;if(h){g=r(p.substring(0,m));let e=g&&o[g]?r(p):void 0;e&&e!==g&&(g=e,h=!1)}else g=r(p);if(!g){if(!h||(g=r(p),!g)){l=t+(l.length>0?` `+l:l);continue}h=!1}let _=d.length===0?``:d.length===1?d[0]:a(d).join(`:`),v=f?_+Ap:_,y=v+g;if(s.indexOf(y)>-1)continue;s.push(y);let b=i(g,h);for(let e=0;e<b.length;++e){let t=b[e];s.push(v+t)}l=t+(l.length>0?` `+l:l)}return l},Bp=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=Vp(n))&&(i&&(i+=` `),i+=r);return i},Vp=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=Vp(e[r]))&&(n&&(n+=` `),n+=t);return n},Hp=(e,...t)=>{let n,r,i,a,o=o=>(n=Ip(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=zp(e,n);return i(e,a),a};return a=o,(...e)=>a(Bp(...e))},Up=[],Wp=e=>{let t=t=>t[e]||Up;return t.isThemeGetter=!0,t.themeKey=e,t},Gp=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Kp=/^\((?:(\w[\w-]*):)?(.+)\)$/i,qp=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Jp=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Yp=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Xp=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,Zp=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Qp=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,$p=e=>qp.test(e),Y=e=>!!e&&!Number.isNaN(Number(e)),em=e=>!!e&&Number.isInteger(Number(e)),tm=e=>e.endsWith(`%`)&&Y(e.slice(0,-1)),nm=e=>Jp.test(e),rm=()=>!0,im=e=>Yp.test(e)&&!Xp.test(e),am=()=>!1,om=e=>Zp.test(e),sm=e=>Qp.test(e),cm=e=>!X(e)&&!Z(e),lm=e=>e.startsWith(`@container`)&&(e[10]===`/`&&e[11]!==void 0||e[11]===`s`&&e[16]!==void 0&&e.startsWith(`-size/`,10)||e[11]===`n`&&e[18]!==void 0&&e.startsWith(`-normal/`,10)),um=e=>Tm(e,km,am),X=e=>Gp.test(e),dm=e=>Tm(e,Am,im),fm=e=>Tm(e,jm,Y),pm=e=>Tm(e,Nm,rm),mm=e=>Tm(e,Mm,am),hm=e=>Tm(e,Dm,am),gm=e=>Tm(e,Om,sm),_m=e=>Tm(e,Pm,om),Z=e=>Kp.test(e),vm=e=>Em(e,Am),ym=e=>Em(e,Mm),bm=e=>Em(e,Dm),xm=e=>Em(e,km),Sm=e=>Em(e,Om),Cm=e=>Em(e,Pm,!0),wm=e=>Em(e,Nm,!0),Tm=(e,t,n)=>{let r=Gp.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Em=(e,t,n=!1)=>{let r=Kp.exec(e);return r?r[1]?t(r[1]):n:!1},Dm=e=>e===`position`||e===`percentage`,Om=e=>e===`image`||e===`url`,km=e=>e===`length`||e===`size`||e===`bg-size`,Am=e=>e===`length`,jm=e=>e===`number`,Mm=e=>e===`family-name`,Nm=e=>e===`number`||e===`weight`,Pm=e=>e===`shadow`,Fm=Hp(()=>{let e=Wp(`color`),t=Wp(`font`),n=Wp(`text`),r=Wp(`font-weight`),i=Wp(`tracking`),a=Wp(`leading`),o=Wp(`breakpoint`),s=Wp(`container`),c=Wp(`spacing`),l=Wp(`radius`),u=Wp(`shadow`),d=Wp(`inset-shadow`),f=Wp(`text-shadow`),p=Wp(`drop-shadow`),m=Wp(`blur`),h=Wp(`perspective`),g=Wp(`aspect`),_=Wp(`ease`),v=Wp(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),Z,X],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[Z,X,c],T=()=>[$p,`full`,`auto`,...w()],E=()=>[em,`none`,`subgrid`,Z,X],D=()=>[`auto`,{span:[`full`,em,Z,X]},em,Z,X],O=()=>[em,`auto`,Z,X],k=()=>[`auto`,`min`,`max`,`fr`,Z,X],A=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],j=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],M=()=>[`auto`,...w()],N=()=>[$p,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],ee=()=>[s,$p,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...w()],te=()=>[$p,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...w()],P=()=>[e,Z,X],ne=()=>[...b(),bm,hm,{position:[Z,X]}],re=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],ie=()=>[`auto`,`cover`,`contain`,xm,um,{size:[Z,X]}],ae=()=>[tm,vm,dm],oe=()=>[``,`none`,`full`,l,Z,X],se=()=>[``,Y,vm,dm],ce=()=>[`solid`,`dashed`,`dotted`,`double`],le=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],ue=()=>[Y,tm,bm,hm],de=()=>[``,`none`,m,Z,X],fe=()=>[`none`,Y,Z,X],pe=()=>[`none`,Y,Z,X],me=()=>[Y,Z,X],he=()=>[$p,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[nm],breakpoint:[nm],color:[rm],container:[nm],"drop-shadow":[nm],ease:[`in`,`out`,`in-out`],font:[cm],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[nm],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[nm],shadow:[nm],spacing:[`px`,Y],text:[nm],"text-shadow":[nm],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,$p,X,Z,g]}],container:[`container`],"container-type":[{"@container":[``,`normal`,`size`,Z,X]}],"container-named":[lm],columns:[{columns:[Y,`auto`,X,Z,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{"inset-s":T(),start:T()}],end:[{"inset-e":T(),end:T()}],"inset-bs":[{"inset-bs":T()}],"inset-be":[{"inset-be":T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[em,`auto`,Z,X]}],basis:[{basis:[$p,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[Y,$p,`auto`,`initial`,`none`,X]}],grow:[{grow:[``,Y,Z,X]}],shrink:[{shrink:[``,Y,Z,X]}],order:[{order:[em,`first`,`last`,`none`,Z,X]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":k()}],"auto-rows":[{"auto-rows":k()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...A(),`normal`]}],"justify-items":[{"justify-items":[...j(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...j()]}],"align-content":[{content:[`normal`,...A()]}],"align-items":[{items:[...j(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...j(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":A()}],"place-items":[{"place-items":[...j(),`baseline`]}],"place-self":[{"place-self":[`auto`,...j()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pbs:[{pbs:w()}],pbe:[{pbe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:M()}],mx:[{mx:M()}],my:[{my:M()}],ms:[{ms:M()}],me:[{me:M()}],mbs:[{mbs:M()}],mbe:[{mbe:M()}],mt:[{mt:M()}],mr:[{mr:M()}],mb:[{mb:M()}],ml:[{ml:M()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:N()}],"inline-size":[{inline:[`auto`,...ee()]}],"min-inline-size":[{"min-inline":[`auto`,...ee()]}],"max-inline-size":[{"max-inline":[`none`,...ee()]}],"block-size":[{block:[`auto`,...te()]}],"min-block-size":[{"min-block":[`auto`,...te()]}],"max-block-size":[{"max-block":[`none`,...te()]}],w:[{w:[s,`screen`,...N()]}],"min-w":[{"min-w":[s,`screen`,`none`,...N()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...N()]}],h:[{h:[`screen`,`lh`,...N()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...N()]}],"max-h":[{"max-h":[`screen`,`lh`,`none`,...N()]}],"font-size":[{text:[`base`,n,vm,dm]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,wm,pm]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,tm,X]}],"font-family":[{font:[ym,mm,t]}],"font-features":[{"font-features":[X]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,Z,X]}],"line-clamp":[{"line-clamp":[Y,`none`,Z,fm]}],leading:[{leading:[`none`,a,...w()]}],"list-image":[{"list-image":[`none`,Z,X]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,Z,X]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:P()}],"text-color":[{text:P()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...ce(),`wavy`]}],"text-decoration-thickness":[{decoration:[Y,`from-font`,`auto`,Z,dm]}],"text-decoration-color":[{decoration:P()}],"underline-offset":[{"underline-offset":[Y,`auto`,Z,X]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:w()}],"tab-size":[{tab:[em,Z,X]}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,Z,X]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,Z,X]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:ne()}],"bg-repeat":[{bg:re()}],"bg-size":[{bg:ie()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},em,Z,X],radial:[``,Z,X],conic:[``,em,Z,X]},Sm,gm]}],"bg-color":[{bg:P()}],"gradient-from-pos":[{from:ae()}],"gradient-via-pos":[{via:ae()}],"gradient-to-pos":[{to:ae()}],"gradient-from":[{from:P()}],"gradient-via":[{via:P()}],"gradient-to":[{to:P()}],rounded:[{rounded:oe()}],"rounded-s":[{"rounded-s":oe()}],"rounded-e":[{"rounded-e":oe()}],"rounded-t":[{"rounded-t":oe()}],"rounded-r":[{"rounded-r":oe()}],"rounded-b":[{"rounded-b":oe()}],"rounded-l":[{"rounded-l":oe()}],"rounded-ss":[{"rounded-ss":oe()}],"rounded-se":[{"rounded-se":oe()}],"rounded-ee":[{"rounded-ee":oe()}],"rounded-es":[{"rounded-es":oe()}],"rounded-tl":[{"rounded-tl":oe()}],"rounded-tr":[{"rounded-tr":oe()}],"rounded-br":[{"rounded-br":oe()}],"rounded-bl":[{"rounded-bl":oe()}],"border-w":[{border:se()}],"border-w-x":[{"border-x":se()}],"border-w-y":[{"border-y":se()}],"border-w-s":[{"border-s":se()}],"border-w-e":[{"border-e":se()}],"border-w-bs":[{"border-bs":se()}],"border-w-be":[{"border-be":se()}],"border-w-t":[{"border-t":se()}],"border-w-r":[{"border-r":se()}],"border-w-b":[{"border-b":se()}],"border-w-l":[{"border-l":se()}],"divide-x":[{"divide-x":se()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":se()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...ce(),`hidden`,`none`]}],"divide-style":[{divide:[...ce(),`hidden`,`none`]}],"border-color":[{border:P()}],"border-color-x":[{"border-x":P()}],"border-color-y":[{"border-y":P()}],"border-color-s":[{"border-s":P()}],"border-color-e":[{"border-e":P()}],"border-color-bs":[{"border-bs":P()}],"border-color-be":[{"border-be":P()}],"border-color-t":[{"border-t":P()}],"border-color-r":[{"border-r":P()}],"border-color-b":[{"border-b":P()}],"border-color-l":[{"border-l":P()}],"divide-color":[{divide:P()}],"outline-style":[{outline:[...ce(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[Y,Z,X]}],"outline-w":[{outline:[``,Y,vm,dm]}],"outline-color":[{outline:P()}],shadow:[{shadow:[``,`inner`,`none`,u,Cm,_m]}],"shadow-color":[{shadow:P()}],"inset-shadow":[{"inset-shadow":[`none`,d,Cm,_m]}],"inset-shadow-color":[{"inset-shadow":P()}],"ring-w":[{ring:se()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:P()}],"ring-offset-w":[{"ring-offset":[Y,dm]}],"ring-offset-color":[{"ring-offset":P()}],"inset-ring-w":[{"inset-ring":se()}],"inset-ring-color":[{"inset-ring":P()}],"text-shadow":[{"text-shadow":[`none`,f,Cm,_m]}],"text-shadow-color":[{"text-shadow":P()}],opacity:[{opacity:[Y,Z,X]}],"mix-blend":[{"mix-blend":[...le(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":le()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[Y]}],"mask-image-linear-from-pos":[{"mask-linear-from":ue()}],"mask-image-linear-to-pos":[{"mask-linear-to":ue()}],"mask-image-linear-from-color":[{"mask-linear-from":P()}],"mask-image-linear-to-color":[{"mask-linear-to":P()}],"mask-image-t-from-pos":[{"mask-t-from":ue()}],"mask-image-t-to-pos":[{"mask-t-to":ue()}],"mask-image-t-from-color":[{"mask-t-from":P()}],"mask-image-t-to-color":[{"mask-t-to":P()}],"mask-image-r-from-pos":[{"mask-r-from":ue()}],"mask-image-r-to-pos":[{"mask-r-to":ue()}],"mask-image-r-from-color":[{"mask-r-from":P()}],"mask-image-r-to-color":[{"mask-r-to":P()}],"mask-image-b-from-pos":[{"mask-b-from":ue()}],"mask-image-b-to-pos":[{"mask-b-to":ue()}],"mask-image-b-from-color":[{"mask-b-from":P()}],"mask-image-b-to-color":[{"mask-b-to":P()}],"mask-image-l-from-pos":[{"mask-l-from":ue()}],"mask-image-l-to-pos":[{"mask-l-to":ue()}],"mask-image-l-from-color":[{"mask-l-from":P()}],"mask-image-l-to-color":[{"mask-l-to":P()}],"mask-image-x-from-pos":[{"mask-x-from":ue()}],"mask-image-x-to-pos":[{"mask-x-to":ue()}],"mask-image-x-from-color":[{"mask-x-from":P()}],"mask-image-x-to-color":[{"mask-x-to":P()}],"mask-image-y-from-pos":[{"mask-y-from":ue()}],"mask-image-y-to-pos":[{"mask-y-to":ue()}],"mask-image-y-from-color":[{"mask-y-from":P()}],"mask-image-y-to-color":[{"mask-y-to":P()}],"mask-image-radial":[{"mask-radial":[Z,X]}],"mask-image-radial-from-pos":[{"mask-radial-from":ue()}],"mask-image-radial-to-pos":[{"mask-radial-to":ue()}],"mask-image-radial-from-color":[{"mask-radial-from":P()}],"mask-image-radial-to-color":[{"mask-radial-to":P()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[Y]}],"mask-image-conic-from-pos":[{"mask-conic-from":ue()}],"mask-image-conic-to-pos":[{"mask-conic-to":ue()}],"mask-image-conic-from-color":[{"mask-conic-from":P()}],"mask-image-conic-to-color":[{"mask-conic-to":P()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:ne()}],"mask-repeat":[{mask:re()}],"mask-size":[{mask:ie()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,Z,X]}],filter:[{filter:[``,`none`,Z,X]}],blur:[{blur:de()}],brightness:[{brightness:[Y,Z,X]}],contrast:[{contrast:[Y,Z,X]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,Cm,_m]}],"drop-shadow-color":[{"drop-shadow":P()}],grayscale:[{grayscale:[``,Y,Z,X]}],"hue-rotate":[{"hue-rotate":[Y,Z,X]}],invert:[{invert:[``,Y,Z,X]}],saturate:[{saturate:[Y,Z,X]}],sepia:[{sepia:[``,Y,Z,X]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,Z,X]}],"backdrop-blur":[{"backdrop-blur":de()}],"backdrop-brightness":[{"backdrop-brightness":[Y,Z,X]}],"backdrop-contrast":[{"backdrop-contrast":[Y,Z,X]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,Y,Z,X]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Y,Z,X]}],"backdrop-invert":[{"backdrop-invert":[``,Y,Z,X]}],"backdrop-opacity":[{"backdrop-opacity":[Y,Z,X]}],"backdrop-saturate":[{"backdrop-saturate":[Y,Z,X]}],"backdrop-sepia":[{"backdrop-sepia":[``,Y,Z,X]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,Z,X]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[Y,`initial`,Z,X]}],ease:[{ease:[`linear`,`initial`,_,Z,X]}],delay:[{delay:[Y,Z,X]}],animate:[{animate:[`none`,v,Z,X]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,Z,X]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:fe()}],"rotate-x":[{"rotate-x":fe()}],"rotate-y":[{"rotate-y":fe()}],"rotate-z":[{"rotate-z":fe()}],scale:[{scale:pe()}],"scale-x":[{"scale-x":pe()}],"scale-y":[{"scale-y":pe()}],"scale-z":[{"scale-z":pe()}],"scale-3d":[`scale-3d`],skew:[{skew:me()}],"skew-x":[{"skew-x":me()}],"skew-y":[{"skew-y":me()}],transform:[{transform:[Z,X,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:he()}],"translate-x":[{"translate-x":he()}],"translate-y":[{"translate-y":he()}],"translate-z":[{"translate-z":he()}],"translate-none":[`translate-none`],zoom:[{zoom:[em,Z,X]}],accent:[{accent:P()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:P()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,Z,X]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scrollbar-thumb-color":[{"scrollbar-thumb":P()}],"scrollbar-track-color":[{"scrollbar-track":P()}],"scrollbar-gutter":[{"scrollbar-gutter":[`auto`,`stable`,`both`]}],"scrollbar-w":[{scrollbar:[`auto`,`thin`,`none`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mbs":[{"scroll-mbs":w()}],"scroll-mbe":[{"scroll-mbe":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pbs":[{"scroll-pbs":w()}],"scroll-pbe":[{"scroll-pbe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,Z,X]}],fill:[{fill:[`none`,...P()]}],"stroke-w":[{stroke:[Y,vm,dm,fm]}],stroke:[{stroke:[`none`,...P()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{"container-named":[`container-type`],overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`inset-bs`,`inset-be`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`start`,`end`,`right`,`left`],"inset-y":[`inset-bs`,`inset-be`,`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pbs`,`pbe`,`pt`,`pr`,`pb`,`pl`],px:[`ps`,`pe`,`pr`,`pl`],py:[`pbs`,`pbe`,`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mbs`,`mbe`,`mt`,`mr`,`mb`,`ml`],mx:[`ms`,`me`,`mr`,`ml`],my:[`mbs`,`mbe`,`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-s`,`border-w-e`,`border-w-r`,`border-w-l`],"border-w-y":[`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-s`,`border-color-e`,`border-color-r`,`border-color-l`],"border-color-y":[`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-ms`,`scroll-me`,`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-ps`,`scroll-pe`,`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},postfixLookupClassGroups:[`container-type`],orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function Q(...e){return Fm(qr(e))}var Im=Xr(`inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[1.5px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/90`,destructive:`bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40`,outline:`border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-9 px-4 py-2 has-[>svg]:px-3`,xs:`h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5`,lg:`h-10 rounded-md px-6 has-[>svg]:px-4`,icon:`size-9`,"icon-xs":`size-6 rounded-md [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-8`,"icon-lg":`size-10`}},defaultVariants:{variant:`default`,size:`default`}});function Lm({className:e,variant:t=`default`,size:n=`default`,asChild:r=!1,...i}){let a=r?Pa:`button`;return(0,R.jsx)(a,{"data-slot":`button`,"data-variant":t,"data-size":n,className:Q(Im({variant:t,size:n,className:e})),...i})}function Rm({className:e,type:t,...n}){return(0,R.jsx)(`input`,{type:t,"data-slot":`input`,className:Q(`h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none selection:bg-primary selection:text-primary-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:bg-input/30`,`focus-visible:border-ring focus-visible:ring-[1.5px] focus-visible:ring-ring/50`,`aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40`,e),...n})}function zm({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,R.jsx)(Of,{"data-slot":`separator`,decorative:n,orientation:t,className:Q(`shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px`,e),...r})}function Bm({...e}){return(0,R.jsx)(Cl,{"data-slot":`sheet`,...e})}function Vm({...e}){return(0,R.jsx)(Dl,{"data-slot":`sheet-portal`,...e})}function Hm({className:e,...t}){return(0,R.jsx)(kl,{"data-slot":`sheet-overlay`,className:Q(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function Um({className:e,children:t,side:n=`right`,showCloseButton:r=!0,...i}){return(0,R.jsxs)(Vm,{children:[(0,R.jsx)(Hm,{}),(0,R.jsxs)(Nl,{"data-slot":`sheet-content`,className:Q(`fixed z-50 flex flex-col gap-4 bg-background shadow-lg transition ease-in-out data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:animate-in data-[state=open]:duration-500`,n===`right`&&`inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm`,n===`left`&&`inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm`,n===`top`&&`inset-x-0 top-0 h-auto border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top`,n===`bottom`&&`inset-x-0 bottom-0 h-auto border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom`,e),...i,children:[t,r&&(0,R.jsxs)(Bl,{className:`absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-secondary`,children:[(0,R.jsx)(wa,{className:`size-4`}),(0,R.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function Wm({className:e,...t}){return(0,R.jsx)(`div`,{"data-slot":`sheet-header`,className:Q(`flex flex-col gap-1.5 p-4`,e),...t})}function Gm({className:e,...t}){return(0,R.jsx)(Ll,{"data-slot":`sheet-title`,className:Q(`font-semibold text-foreground`,e),...t})}function Km({className:e,...t}){return(0,R.jsx)(Rl,{"data-slot":`sheet-description`,className:Q(`text-sm text-muted-foreground`,e),...t})}function qm({delayDuration:e=0,...t}){return(0,R.jsx)(Bf,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Jm({...e}){return(0,R.jsx)(Wf,{"data-slot":`tooltip`,...e})}function Ym({...e}){return(0,R.jsx)(J,{"data-slot":`tooltip-trigger`,...e})}function Xm({className:e,sideOffset:t=0,children:n,...r}){return(0,R.jsx)(Yf,{children:(0,R.jsxs)(Zf,{"data-slot":`tooltip-content`,sideOffset:t,className:Q(`z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-foreground px-3 py-1.5 text-xs text-balance text-background fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95`,e),...r,children:[n,(0,R.jsx)(tp,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground`})]})})}var Zm=`sidebar_state`,Qm=604800,$m=`16rem`,eh=`18rem`,th=`3rem`,nh=`b`,rh=M.createContext(null);function ih(){let e=M.use(rh);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function ah({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:a,...o}){let s=up(),[c,l]=M.useState(!1),[u,d]=M.useState(e),f=t??u,p=M.useCallback(e=>{let t=typeof e==`function`?e(f):e;n?n(t):d(t),document.cookie=`${Zm}=${t}; path=/; max-age=${Qm}`},[n,f]),m=M.useCallback(()=>s?l(e=>!e):p(e=>!e),[s,p,l]);M.useEffect(()=>{let e=e=>{e.key===nh&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),m())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[m]);let h=f?`expanded`:`collapsed`,g=M.useMemo(()=>({state:h,open:f,setOpen:p,isMobile:s,openMobile:c,setOpenMobile:l,toggleSidebar:m}),[h,f,p,s,c,l,m]);return(0,R.jsx)(rh.Provider,{value:g,children:(0,R.jsx)(qm,{delayDuration:0,children:(0,R.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:{"--sidebar-width":$m,"--sidebar-width-icon":th,...i},className:Q(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),...o,children:a})})})}function oh({side:e=`left`,variant:t=`sidebar`,collapsible:n=`offcanvas`,className:r,children:i,...a}){let{isMobile:o,state:s,openMobile:c,setOpenMobile:l}=ih();return n===`none`?(0,R.jsx)(`div`,{"data-slot":`sidebar`,className:Q(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,r),...a,children:i}):o?(0,R.jsx)(Bm,{open:c,onOpenChange:l,...a,children:(0,R.jsxs)(Um,{"data-sidebar":`sidebar`,"data-slot":`sidebar`,"data-mobile":`true`,className:`w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden`,style:{"--sidebar-width":eh},side:e,children:[(0,R.jsxs)(Wm,{className:`sr-only`,children:[(0,R.jsx)(Gm,{children:`Sidebar`}),(0,R.jsx)(Km,{children:`Displays the mobile sidebar.`})]}),(0,R.jsx)(`div`,{className:`flex h-full w-full flex-col`,children:i})]})}):(0,R.jsxs)(`div`,{className:`group peer hidden text-sidebar-foreground md:block`,"data-state":s,"data-collapsible":s===`collapsed`?n:``,"data-variant":t,"data-side":e,"data-slot":`sidebar`,children:[(0,R.jsx)(`div`,{"data-slot":`sidebar-gap`,className:Q(`relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear`,`group-data-[collapsible=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,t===`floating`||t===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`)}),(0,R.jsx)(`div`,{"data-slot":`sidebar-container`,className:Q(`fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex`,e===`left`?`left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]`:`right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]`,t===`floating`||t===`inset`?`p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l`,r),...a,children:(0,R.jsx)(`div`,{"data-sidebar":`sidebar`,"data-slot":`sidebar-inner`,className:`flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow-sm`,children:i})})]})}function sh({className:e,onClick:t,...n}){let{toggleSidebar:r}=ih();return(0,R.jsxs)(Lm,{"data-sidebar":`trigger`,"data-slot":`sidebar-trigger`,variant:`ghost`,size:`icon`,className:Q(`size-7`,e),onClick:e=>{t?.(e),r()},...n,children:[(0,R.jsx)(qi,{}),(0,R.jsx)(`span`,{className:`sr-only`,children:`Toggle Sidebar`})]})}function ch({className:e,...t}){return(0,R.jsx)(`main`,{"data-slot":`sidebar-inset`,className:Q(`relative flex w-full flex-1 flex-col bg-background`,`md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2`,e),...t})}function lh({className:e,...t}){return(0,R.jsx)(`div`,{"data-slot":`sidebar-header`,"data-sidebar":`header`,className:Q(`flex flex-col gap-2 p-2`,e),...t})}function uh({className:e,...t}){return(0,R.jsx)(`div`,{"data-slot":`sidebar-footer`,"data-sidebar":`footer`,className:Q(`flex flex-col gap-2 p-2`,e),...t})}function dh({className:e,...t}){return(0,R.jsx)(zm,{"data-slot":`sidebar-separator`,"data-sidebar":`separator`,className:Q(`mx-2 w-auto bg-sidebar-border`,e),...t})}function fh({className:e,...t}){return(0,R.jsx)(`div`,{"data-slot":`sidebar-content`,"data-sidebar":`content`,className:Q(`flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden`,e),...t})}function ph({className:e,...t}){return(0,R.jsx)(`div`,{"data-slot":`sidebar-group`,"data-sidebar":`group`,className:Q(`relative flex w-full min-w-0 flex-col p-2`,e),...t})}function mh({className:e,...t}){return(0,R.jsx)(`div`,{"data-slot":`sidebar-group-content`,"data-sidebar":`group-content`,className:Q(`w-full text-sm`,e),...t})}function hh({className:e,...t}){return(0,R.jsx)(`ul`,{"data-slot":`sidebar-menu`,"data-sidebar":`menu`,className:Q(`flex w-full min-w-0 flex-col gap-1`,e),...t})}function gh({className:e,...t}){return(0,R.jsx)(`li`,{"data-slot":`sidebar-menu-item`,"data-sidebar":`menu-item`,className:Q(`group/menu-item relative`,e),...t})}var _h=Xr(`peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0`,{variants:{variant:{default:`hover:bg-sidebar-accent hover:text-sidebar-accent-foreground`,outline:`bg-background shadow-[0_0_0_1px_var(--sidebar-border)] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_var(--sidebar-accent)]`},size:{default:`h-8 text-sm`,sm:`h-7 text-xs`,lg:`h-12 text-sm group-data-[collapsible=icon]:p-0!`}},defaultVariants:{variant:`default`,size:`default`}});function vh({asChild:e=!1,isActive:t=!1,variant:n=`default`,size:r=`default`,tooltip:i,className:a,...o}){let s=e?Pa:`button`,{isMobile:c,state:l}=ih(),u=(0,R.jsx)(s,{"data-slot":`sidebar-menu-button`,"data-sidebar":`menu-button`,"data-size":r,"data-active":t,className:Q(_h({variant:n,size:r}),a),...o});return i?(typeof i==`string`&&(i={children:i}),(0,R.jsxs)(Jm,{children:[(0,R.jsx)(Ym,{asChild:!0,children:u}),(0,R.jsx)(Xm,{side:`right`,align:`center`,hidden:l!==`collapsed`||c,...i})]})):u}function yh({className:e,...t}){return(0,R.jsx)(`div`,{"data-slot":`sidebar-menu-badge`,"data-sidebar":`menu-badge`,className:Q(`pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium text-sidebar-foreground tabular-nums select-none`,`peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground`,`peer-data-[size=sm]/menu-button:top-1`,`peer-data-[size=default]/menu-button:top-1.5`,`peer-data-[size=lg]/menu-button:top-2.5`,`group-data-[collapsible=icon]:hidden`,e),...t})}function bh(){let e=pt(),{workspace:t,dirty:n}=vr(),{ragStatus:r}=jr(),i=xh(e.pathname),a=r?.hasIndex&&!r.stale;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`crumbs`,children:[i.map((e,t)=>(0,R.jsxs)(`span`,{children:[t>0&&(0,R.jsx)(`span`,{className:`sep`,style:{marginRight:8},children:`/`}),(0,R.jsx)(`span`,{className:t===i.length-1?`crumb cur`:`crumb`,children:e})]},e)),n&&(0,R.jsxs)(`span`,{className:`pill warn`,style:{marginLeft:8},children:[(0,R.jsx)(`span`,{style:{width:6,height:6,borderRadius:`50%`,background:`var(--amber-500)`}}),`Unsaved changes`]}),!n&&t&&i.some(e=>e===`Enrichment`||e===`Schema`)&&(0,R.jsxs)(`span`,{className:`pill ok`,style:{marginLeft:8},children:[(0,R.jsx)(pi,{size:10}),`Saved`]})]}),(0,R.jsxs)(`div`,{className:`right`,children:[(0,R.jsxs)(`div`,{className:`cmd-palette`,children:[(0,R.jsx)(ca,{size:13}),(0,R.jsx)(`span`,{style:{flex:1},children:`Search tables, concepts, queries…`}),(0,R.jsx)(`span`,{className:`kbd`,children:`⌘K`})]}),r&&(0,R.jsxs)(`span`,{className:`pill ${a?`ok`:`warn`}`,children:[(0,R.jsx)(`span`,{style:{width:6,height:6,borderRadius:`50%`,background:a?`var(--green-500)`:`var(--amber-500)`}}),a?`Index fresh`:r.hasIndex?`Index stale`:`No index`]})]})]})}function xh(e){let t=e.split(`/`).filter(Boolean);if(t.length===0)return[`Overview`];let n=t[0],r=[];switch(n){case`overview`:r.push(`Overview`);break;case`tables`:r.push(`Tables`),t[1]&&r.push(t[1]),t[2]&&r.push(t[2]),t[3]&&r.push(Sh(t[3]));break;case`concepts`:r.push(`Concepts`);break;case`tenancy`:r.push(`Tenancy`),t[1]&&r.push(Sh(t[1]));break;case`rag-index`:r.push(`RAG Index`),t[1]&&r.push(Sh(t[1]));break;case`playground`:r.push(`Playground`),t[1]&&r.push(`Query`);break;case`settings`:r.push(`Settings`);break;default:r.push(Sh(n))}return r}function Sh(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Ch=[{to:`/overview`,label:`Overview`,icon:zi},{to:`/tables`,label:`Tables`,icon:va,badgeKey:`tables`},{to:`/concepts`,label:`Concepts`,icon:Li,badgeKey:`concepts`},{to:`/tenancy`,label:`Tenancy`,icon:fa},{to:`/rag-index`,label:`RAG Index`,icon:ma},{to:`/playground`,label:`Playground`,icon:Zi}];function wh(){let{workspace:e}=vr(),{theme:t,toggleTheme:n}=Hn();function r(t){if(e&&t){if(t===`tables`)return String(e.tables.length);if(t===`concepts`)return String(e.concepts.length)}}return(0,R.jsxs)(oh,{collapsible:`icon`,className:`border-r`,children:[(0,R.jsx)(lh,{className:`px-2 py-2`,children:(0,R.jsx)(hh,{children:(0,R.jsx)(gh,{children:(0,R.jsx)(vh,{size:`lg`,asChild:!0,tooltip:`AskDB Studio`,children:(0,R.jsxs)(`a`,{href:`/`,className:`no-underline`,children:[(0,R.jsx)(`div`,{className:`flex aspect-square size-8 items-center justify-center shrink-0`,children:(0,R.jsx)(`img`,{src:t===`dark`?`/assets/brand/dark-icon.png`:`/assets/brand/light-icon.png`,alt:`AskDB`,className:`size-7`})}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-0.5 leading-none`,children:[(0,R.jsx)(`span`,{className:`font-semibold`,children:`AskDB`}),(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Studio`})]})]})})})})}),(0,R.jsx)(fh,{children:(0,R.jsx)(ph,{children:(0,R.jsx)(mh,{children:(0,R.jsx)(hh,{children:Ch.map(e=>{let t=e.icon,n=r(e.badgeKey);return(0,R.jsxs)(gh,{children:[(0,R.jsx)(vh,{asChild:!0,tooltip:e.label,children:(0,R.jsxs)(Dn,{to:e.to,children:[(0,R.jsx)(t,{}),(0,R.jsx)(`span`,{children:e.label})]})}),n&&(0,R.jsx)(yh,{children:n})]},e.to)})})})})}),(0,R.jsxs)(uh,{children:[(0,R.jsxs)(hh,{children:[(0,R.jsx)(gh,{children:(0,R.jsx)(vh,{asChild:!0,tooltip:`Settings`,children:(0,R.jsxs)(Dn,{to:`/settings`,children:[(0,R.jsx)(ua,{}),(0,R.jsx)(`span`,{children:`Settings`})]})})}),(0,R.jsx)(gh,{children:(0,R.jsxs)(vh,{tooltip:t===`light`?`Dark mode`:`Light mode`,onClick:n,children:[t===`light`?(0,R.jsx)(Gi,{}):(0,R.jsx)(ga,{}),(0,R.jsx)(`span`,{children:t===`light`?`Dark mode`:`Light mode`})]})})]}),(0,R.jsx)(dh,{}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 text-xs text-muted-foreground group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:px-0`,children:[(0,R.jsx)(ki,{size:14,className:`shrink-0`}),(0,R.jsx)(`span`,{className:`truncate font-mono group-data-[collapsible=icon]:hidden`,children:e?`${e.aiProvider||`postgres`} · ${e.schemaId.split(`/`).pop()||e.schemaId}`:`connecting…`})]})]})]})}function Th({dialog:e,onApply:t,onClose:n}){return(0,R.jsx)(`div`,{className:`dialog-overlay`,onClick:n,"aria-hidden":`true`,children:(0,R.jsxs)(`div`,{className:`dialog`,onClick:e=>e.stopPropagation(),children:[(0,R.jsxs)(`div`,{className:`dialog-hd`,children:[(0,R.jsxs)(`h3`,{children:[`Suggestions for `,e.label]}),(0,R.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:n,"aria-label":`Close`,children:(0,R.jsx)(wa,{size:14})})]}),(0,R.jsx)(`div`,{className:`dialog-bd`,children:e.candidates.map(e=>(0,R.jsxs)(`article`,{className:`candidate`,children:[(0,R.jsx)(`p`,{children:e.text}),(0,R.jsx)(`div`,{className:`candidate-actions`,children:(0,R.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:()=>t(e.text),children:`Use`})})]},e.text))})]})})}function Eh({status:e}){return(0,R.jsxs)(`div`,{className:`status-banner ${e.kind}`,children:[e.kind===`loading`&&(0,R.jsx)(Vi,{size:14,className:`animate-spin`}),e.kind===`success`&&(0,R.jsx)(pi,{size:14}),e.kind===`error`&&(0,R.jsx)(Ci,{size:14}),(0,R.jsx)(`span`,{children:e.text})]})}function Dh({status:e}){return(0,R.jsxs)(`div`,{className:`inline-status ${e.kind}`,children:[e.kind===`loading`&&(0,R.jsx)(Vi,{size:12,className:`animate-spin`}),e.kind===`success`&&(0,R.jsx)(pi,{size:12}),e.kind===`error`&&(0,R.jsx)(Ci,{size:12}),(0,R.jsx)(`span`,{children:e.text})]})}function Oh(){let e=ht(),{workspace:t,tables:n,load:r}=vr(),{ragStatus:i,refreshRagStatus:a}=jr(),{historyEntries:o}=Rr(),[s,c]=(0,M.useState)(!1),[l,u]=(0,M.useState)(null),d=(0,M.useCallback)(async()=>{c(!0),u({kind:`loading`,text:`Re-introspecting…`});try{let e=await cr();await r(),a(),u({kind:`success`,text:`Re-introspected ${e.tables} table${e.tables===1?``:`s`} from ${e.engine} — enrichment preserved.`})}catch(e){u({kind:`error`,text:e instanceof Error?e.message:String(e)})}finally{c(!1)}},[r,a]),f=(0,M.useEffectEvent)(()=>u(null));if((0,M.useEffect)(()=>{if(l?.kind===`success`){let e=setTimeout(()=>f(),4e3);return()=>clearTimeout(e)}},[l]),!t)return null;let p=n.filter(e=>{let t=e.draft,n=t.description||t.aliases&&t.aliases.length>0,r=Object.values(t.columns??{}).every(e=>e.description);return n&&r}).length,m=n.filter(e=>{let t=e.draft,n=t.description||t.aliases&&t.aliases.length>0,r=Object.values(t.columns??{}).every(e=>e.description);return n&&!r}).length,h=!!t.tenantPolicy;return(0,R.jsxs)(`main`,{className:`main-pane`,children:[(0,R.jsxs)(`div`,{className:`main-hd`,children:[(0,R.jsxs)(`div`,{className:`main-title`,children:[(0,R.jsx)(`h1`,{children:`Overview`}),(0,R.jsxs)(`div`,{className:`main-sub`,children:[t.aiProvider||`postgres`,` · `,t.schemaId]})]}),(0,R.jsxs)(`div`,{className:`main-actions`,children:[(0,R.jsxs)(`button`,{type:`button`,className:`btn`,disabled:s,title:`Re-run introspection with the connection from askdb.config.ts. Your enrichment is preserved.`,onClick:()=>void d(),children:[s?(0,R.jsx)(Vi,{size:14,className:`animate-spin`}):(0,R.jsx)(ta,{size:14}),` Resync schema`]}),(0,R.jsxs)(`button`,{type:`button`,className:`btn primary`,onClick:()=>e(`/tables`),children:[(0,R.jsx)(ma,{size:14}),` Draft enrichment`]})]})]}),(0,R.jsx)(`div`,{className:`main-body`,children:(0,R.jsxs)(`div`,{className:`stack`,children:[l&&(0,R.jsx)(Dh,{status:l}),(0,R.jsxs)(`div`,{className:`grid-4`,children:[(0,R.jsxs)(`div`,{className:`card stat-card`,children:[(0,R.jsx)(`div`,{className:`stat-label`,children:`Tables`}),(0,R.jsx)(`div`,{className:`stat-num`,children:n.length}),(0,R.jsxs)(`div`,{className:`stat-hint`,children:[p,` enriched · `,m,` partial`]})]}),(0,R.jsxs)(`div`,{className:`card stat-card`,children:[(0,R.jsx)(`div`,{className:`stat-label`,children:`Concepts`}),(0,R.jsx)(`div`,{className:`stat-num`,children:t.concepts.length}),t.concepts.length>0&&(0,R.jsxs)(`div`,{className:`stat-hint`,children:[t.concepts.length,` defined`]})]}),(0,R.jsxs)(`div`,{className:`card stat-card`,children:[(0,R.jsx)(`div`,{className:`stat-label`,children:`Index health`}),(0,R.jsx)(`div`,{className:`stat-num`,children:i?.hasIndex?i.stale?`Stale`:`Fresh`:`None`}),i&&(0,R.jsxs)(`div`,{className:`stat-hint`,children:[i.chunksTotal,` chunks`,i.dimensions===null?``:` · ${i.dimensions}d`]})]}),(0,R.jsxs)(`div`,{className:`card stat-card`,children:[(0,R.jsx)(`div`,{className:`stat-label`,children:`Sensitivity coverage`}),(0,R.jsx)(`div`,{className:`stat-num`,children:i?`${Math.round((i.sensitiveExcluded+i.sensitiveIncluded)/Math.max(i.chunksTotal,1)*100)}%`:`—`})]})]}),(0,R.jsxs)(`div`,{className:`grid-2`,children:[(0,R.jsxs)(`div`,{className:`card`,children:[(0,R.jsxs)(`div`,{className:`card-hd`,children:[(0,R.jsxs)(`h3`,{children:[(0,R.jsx)(ma,{size:14}),` Pending enrichment`]}),(0,R.jsxs)(`span`,{className:`card-meta`,children:[n.length-p,` tables to go`]})]}),(0,R.jsx)(`div`,{className:`card-bd tight`,children:(0,R.jsxs)(`table`,{className:`tbl`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{children:`Table`}),(0,R.jsx)(`th`,{children:`Cols`}),(0,R.jsx)(`th`,{children:`Status`}),(0,R.jsx)(`th`,{"aria-label":`Actions`})]})}),(0,R.jsx)(`tbody`,{children:n.filter(e=>{let t=e.draft,n=Object.values(t.columns??{}).every(e=>e.description);return!(t.description&&n)}).slice(0,6).map(t=>{let n=t.draft.description||t.draft.aliases&&t.draft.aliases.length>0?`partial`:`none`;return(0,R.jsxs)(`tr`,{style:{cursor:`default`},onClick:()=>e(`/tables/${t.physical.schema}/${t.physical.name}/enrichment`),children:[(0,R.jsx)(`td`,{children:(0,R.jsxs)(`span`,{className:`mono`,children:[t.physical.schema,`.`,t.physical.name]})}),(0,R.jsx)(`td`,{className:`muted`,children:t.physical.columns.length}),(0,R.jsxs)(`td`,{children:[(0,R.jsx)(`span`,{className:`enrich-dot ${n}`}),(0,R.jsx)(`span`,{className:`muted tiny`,style:{marginLeft:6},children:n})]}),(0,R.jsx)(`td`,{style:{textAlign:`right`},children:(0,R.jsxs)(`span`,{className:`suggest-link`,children:[(0,R.jsx)(ma,{size:12}),` Draft`]})})]},t.physical.id)})})]})})]}),(0,R.jsxs)(`div`,{className:`card`,children:[(0,R.jsxs)(`div`,{className:`card-hd`,children:[(0,R.jsxs)(`h3`,{children:[(0,R.jsx)(ra,{size:14}),` Recent playground queries`]}),(0,R.jsxs)(`span`,{className:`card-meta`,children:[`last `,o.length,` queries`]})]}),(0,R.jsx)(`div`,{className:`card-bd tight`,children:(0,R.jsxs)(`table`,{className:`tbl`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{children:`Question`}),(0,R.jsx)(`th`,{children:`Mode`}),(0,R.jsx)(`th`,{children:`Time`})]})}),(0,R.jsxs)(`tbody`,{children:[o.slice(0,5).map(e=>(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`td`,{style:{maxWidth:300,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.question}),(0,R.jsx)(`td`,{children:(0,R.jsx)(`span`,{className:`chip ${e.mode===`rag`?`red`:``}`,children:e.mode})}),(0,R.jsx)(`td`,{className:`muted tiny`,children:new Date(e.timestamp).toLocaleString()})]},e.id)),o.length===0&&(0,R.jsx)(`tr`,{children:(0,R.jsx)(`td`,{colSpan:3,className:`muted tiny`,style:{textAlign:`center`,padding:16},children:`No queries yet`})})]})]})})]})]}),(0,R.jsxs)(`div`,{className:`grid-3`,children:[(0,R.jsxs)(`div`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsxs)(`h3`,{children:[(0,R.jsx)(ma,{size:14}),` RAG index`]})}),(0,R.jsx)(`div`,{className:`card-bd`,children:i?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`grid-2`,style:{gap:10},children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`muted tiny`,children:`Chunks`}),(0,R.jsx)(`div`,{style:{fontSize:18,fontWeight:600},children:hr(i.chunksTotal)})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`muted tiny`,children:`Indexed`}),(0,R.jsx)(`div`,{style:{fontSize:18,fontWeight:600},children:hr(i.chunksIndexed)})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`muted tiny`,children:`Dimensions`}),(0,R.jsx)(`div`,{className:`mono`,style:{fontSize:13},children:i.dimensions===null?`model default`:hr(i.dimensions)})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`muted tiny`,children:`Model`}),(0,R.jsx)(`div`,{className:`mono`,style:{fontSize:12},children:i.embedder.label})]})]}),(0,R.jsx)(`div`,{className:`bar`,style:{marginTop:14},children:(0,R.jsx)(`i`,{style:{width:i.chunksTotal>0?`${Math.round(i.chunksIndexed/i.chunksTotal*100)}%`:`0%`}})}),(0,R.jsxs)(`div`,{className:`tiny muted`,style:{marginTop:6},children:[`Updated: `,i.updatedAt??`never`]})]}):(0,R.jsx)(`div`,{className:`muted tiny`,children:`RAG status unavailable`})})]}),(0,R.jsxs)(`div`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsxs)(`h3`,{children:[(0,R.jsx)(fa,{size:14}),` Tenancy`]})}),(0,R.jsxs)(`div`,{className:`card-bd`,children:[(0,R.jsx)(`div`,{className:`row-h`,style:{marginBottom:10},children:(0,R.jsxs)(`span`,{className:`chip ${h?`green`:`amber`}`,children:[(0,R.jsx)(Ea,{size:11}),h?`Configured`:`Not configured`]})}),(0,R.jsx)(`div`,{className:`tiny muted`,style:{lineHeight:1.6},children:h?`${t.tenantPolicy.roots.length} root(s) configured, ${t.tenantPolicy.enforcement} mode.`:`Multi-tenant scoping isn't set. Generated SQL won't enforce row-level isolation.`}),!h&&(0,R.jsxs)(`button`,{type:`button`,className:`btn sm primary`,style:{marginTop:12},onClick:()=>e(`/tenancy`),children:[(0,R.jsx)(ma,{size:12}),` Draft tenant policy`]})]})]}),(0,R.jsxs)(`div`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsxs)(`h3`,{children:[(0,R.jsx)(Ea,{size:14}),` Suggested next actions`]})}),(0,R.jsxs)(`div`,{className:`card-bd`,style:{display:`flex`,flexDirection:`column`,gap:8},children:[n.filter(e=>!e.draft.description).length>0&&(0,R.jsxs)(`div`,{className:`row-h`,children:[(0,R.jsx)(`span`,{style:{width:8,height:8,borderRadius:`50%`,background:`var(--red-600)`,flexShrink:0}}),(0,R.jsxs)(`span`,{style:{fontSize:12.5},children:[`Add description to`,` `,(0,R.jsx)(`span`,{className:`mono`,children:n.find(e=>!e.draft.description)?.physical.name})]})]}),!i?.hasIndex&&(0,R.jsxs)(`div`,{className:`row-h`,children:[(0,R.jsx)(`span`,{style:{width:8,height:8,borderRadius:`50%`,background:`var(--amber-500)`,flexShrink:0}}),(0,R.jsx)(`span`,{style:{fontSize:12.5},children:`Build RAG index for retrieval-augmented queries`})]}),i?.stale&&(0,R.jsxs)(`div`,{className:`row-h`,children:[(0,R.jsx)(`span`,{style:{width:8,height:8,borderRadius:`50%`,background:`var(--ink-400)`,flexShrink:0}}),(0,R.jsx)(`span`,{style:{fontSize:12.5},children:`Rebuild index — tables changed since last build`})]}),n.length>0&&p===0&&(0,R.jsxs)(`div`,{className:`row-h`,children:[(0,R.jsx)(`span`,{style:{width:8,height:8,borderRadius:`50%`,background:`var(--amber-500)`,flexShrink:0}}),(0,R.jsx)(`span`,{style:{fontSize:12.5},children:`Start enriching tables to improve SQL generation quality`})]})]})]})]})]})})]})}var kh=e=>(0,R.jsx)(es,{"data-slot":`collapsible-trigger`,...e}),Ah=e=>(0,R.jsx)(ns,{"data-slot":`collapsible-content`,...e}),jh=e=>(0,R.jsx)(Qo,{"data-slot":`collapsible`,...e}),Mh={enriched:`Complete`,partial:`Partial`,none:`Not started`};function Nh(){let e=ht(),t=yt(),{filteredTables:n,tables:r,selectedTable:i,setSelectedTableId:a,tableSearch:o,setTableSearch:s,drafts:c}=vr(),[l,u]=(0,M.useState)(null),[d,f]=(0,M.useState)(null),p=(0,M.useCallback)(e=>{let t=c[e.physical.id]??e.draft,n=t.description||t.aliases&&t.aliases.length>0,r=Object.values(t.columns??{}).every(e=>e.description);return n&&r?`enriched`:n?`partial`:`none`},[c]),m=(0,M.useCallback)(e=>(c[e.physical.id]??e.draft).tracked!==!1,[c]),h=(0,M.useMemo)(()=>{let e={enriched:0,partial:0,none:0};for(let t of r)e[p(t)]++;return e},[r,p]),g=(0,M.useMemo)(()=>r.filter(e=>!m(e)).length,[r,m]),_=(0,M.useMemo)(()=>{let e=n;return l&&(e=e.filter(e=>l.has(p(e)))),d===`tracked`?e=e.filter(e=>m(e)):d===`untracked`&&(e=e.filter(e=>!m(e))),e},[n,l,d,p,m]),v=(0,M.useMemo)(()=>{let e=new Map;for(let t of _){let n=t.physical.schema;e.has(n)||e.set(n,[]),e.get(n).push(t)}return Array.from(e.entries()).sort(([e],[t])=>e.localeCompare(t))},[_]),y=(0,M.useMemo)(()=>v.map(([e])=>e),[v]),[b,x]=(0,M.useState)(new Set),S=(0,M.useMemo)(()=>new Set(y.filter(e=>!b.has(e))),[y,b]),C=b.size===0,w=()=>x(new Set(y)),T=()=>x(new Set);(0,M.useEffect)(()=>{o&&x(new Set)},[o]),(0,M.useEffect)(()=>{if(t.schema&&t.name){let e=`table:${t.schema}.${t.name}`;a(e)}else if(r.length>0&&!t.schema){let t=r[0];e(`/tables/${t.physical.schema}/${t.physical.name}/enrichment`,{replace:!0})}},[t.schema,t.name,r,e,a]);function E(e){u(t=>{if(!t)return new Set([e]);let n=new Set(t);return n.has(e)?(n.delete(e),n.size===0?null:n):(n.add(e),n.size===3?null:n)})}let D=!!(t.schema&&t.name);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`sub-rail`,children:[(0,R.jsxs)(`div`,{className:`sub-rail-hd`,children:[(0,R.jsx)(`h2`,{children:`Tables`}),(0,R.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6},children:[(0,R.jsxs)(`span`,{className:`muted tiny`,children:[r.length,` tables`]}),v.length>1&&(0,R.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:C?T:w,title:C?`Collapse all`:`Expand all`,style:{padding:2,height:20,width:20},children:C?(0,R.jsx)(yi,{size:13}):(0,R.jsx)(xi,{size:13})})]})]}),(0,R.jsxs)(`div`,{className:`sub-rail-search`,children:[(0,R.jsx)(ca,{size:13}),(0,R.jsx)(`input`,{type:`text`,"aria-label":`Search tables`,placeholder:`Search tables…`,value:o,onChange:e=>s(e.target.value)})]}),(0,R.jsxs)(`div`,{className:`enrich-filter-bar`,children:[[`enriched`,`partial`,`none`].map(e=>{let t=!l||l.has(e);return(0,R.jsxs)(`button`,{type:`button`,className:`enrich-filter-chip ${e} ${t?`active`:``}`,onClick:()=>E(e),title:`${t?`Hide`:`Show`} ${Mh[e].toLowerCase()} tables`,children:[(0,R.jsx)(`span`,{className:`enrich-dot ${e}`}),(0,R.jsx)(`span`,{className:`enrich-filter-label`,children:Mh[e]}),(0,R.jsx)(`span`,{className:`enrich-filter-count`,children:h[e]})]},e)}),g>0&&(0,R.jsxs)(`button`,{type:`button`,className:`enrich-filter-chip untracked ${d===`untracked`?`active`:``}`,onClick:()=>f(e=>e===`untracked`?null:`untracked`),title:d===`untracked`?`Show all tables`:`Show ${g} untracked table${g===1?``:`s`}`,children:[(0,R.jsx)(ji,{size:11}),(0,R.jsx)(`span`,{className:`enrich-filter-label`,children:`Untracked`}),(0,R.jsx)(`span`,{className:`enrich-filter-count`,children:g})]})]}),(0,R.jsxs)(`div`,{className:`sub-rail-list`,children:[v.map(([t,n])=>(0,R.jsx)(jh,{open:S.has(t),onOpenChange:e=>{x(n=>{let r=new Set(n);return e?r.delete(t):r.add(t),r})},children:(0,R.jsxs)(`div`,{className:`schema-group`,children:[(0,R.jsx)(kh,{asChild:!0,children:(0,R.jsxs)(`button`,{type:`button`,className:`schema-group-hd`,children:[(0,R.jsx)(_i,{size:12,className:`schema-chevron`,style:{transform:S.has(t)?`rotate(90deg)`:void 0}}),(0,R.jsx)(Fi,{size:13,className:`schema-icon`}),(0,R.jsx)(`span`,{className:`schema-name`,children:t}),(0,R.jsx)(`span`,{className:`schema-count`,children:n.length})]})}),(0,R.jsx)(Ah,{children:(0,R.jsx)(`div`,{className:`schema-group-bd`,children:n.map(t=>{let n=p(t),r=m(t),a=i?.physical.id===t.physical.id;return(0,R.jsxs)(`button`,{type:`button`,className:`sub-rail-row table-leaf ${a?`active`:``}${r?``:` untracked`}`,onClick:()=>e(`/tables/${t.physical.schema}/${t.physical.name}/enrichment`),title:r?void 0:`Untracked — excluded from LLM context`,children:[r?(0,R.jsx)(`span`,{className:`enrich-dot ${n}`}):(0,R.jsx)(ji,{size:10,style:{color:`var(--amber-500)`,flex:`none`}}),(0,R.jsx)(`span`,{className:`row-name mono`,children:t.physical.name}),(0,R.jsxs)(`span`,{className:`row-meta`,children:[t.physical.columns.length,` cols`]})]},t.physical.id)})})})]})},t)),_.length===0&&(0,R.jsx)(`div`,{className:`muted tiny`,style:{padding:`16px`,textAlign:`center`},children:d===`untracked`?`No untracked tables`:l?`No tables match this filter`:`No tables match your search`})]})]}),D?(0,R.jsx)(sn,{}):(0,R.jsx)(`main`,{className:`main-pane`,children:(0,R.jsx)(`div`,{className:`main-body`,style:{display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,R.jsxs)(`div`,{style:{textAlign:`center`,color:`var(--ink-400)`},children:[(0,R.jsx)(ma,{size:24,style:{margin:`0 auto 8px`}}),(0,R.jsx)(`p`,{style:{fontSize:13},children:`Select a table to start enriching`})]})})})]})}function Ph(){let{selectedTable:e,selectedDraft:t,dirty:n,saveStatus:r,saveSelectedTable:i,resetSelectedDraft:a,busy:o}=vr(),{refreshRagStatus:s}=jr();if(!e||!t)return null;async function c(){await i(),s()}let l=e,u=t.description||t.aliases&&t.aliases.length>0,d=Object.values(t.columns??{}).every(e=>e.description);return(0,R.jsxs)(`main`,{className:`main-pane`,children:[(0,R.jsxs)(`div`,{className:`main-hd`,children:[(0,R.jsxs)(`div`,{className:`main-title`,children:[(0,R.jsxs)(`h1`,{children:[(0,R.jsx)(`span`,{className:`enrich-dot ${u&&d?`enriched`:u?`partial`:`none`}`,style:{marginRight:8}}),l.physical.schema,`.`,l.physical.name]}),(0,R.jsxs)(`div`,{className:`main-sub`,children:[l.physical.columns.length,` columns`,l.physical.relationships&&l.physical.relationships.length>0?` · ${l.physical.relationships.length} relationships`:``,l.missingColumnIds.length>0?` · ${l.missingColumnIds.length} missing`:``]})]}),(0,R.jsxs)(`div`,{className:`main-actions`,children:[(0,R.jsxs)(`button`,{type:`button`,className:`btn`,onClick:a,disabled:!n||o.has(`save`),children:[(0,R.jsx)(B,{size:14}),` Revert`]}),(0,R.jsxs)(`button`,{type:`button`,className:`btn primary`,onClick:()=>void c(),disabled:!n||o.has(`save`),children:[o.has(`save`)?(0,R.jsx)(Vi,{size:14,className:`animate-spin`}):(0,R.jsx)(oa,{size:14}),`Save`]})]})]}),r&&(0,R.jsx)(Eh,{status:r}),(0,R.jsxs)(`div`,{className:`sub-tabs`,children:[(0,R.jsx)(Dn,{to:`enrichment`,className:({isActive:e})=>`sub-tab ${e?`active`:``}`,children:`Enrichment`}),(0,R.jsx)(Dn,{to:`schema`,className:({isActive:e})=>`sub-tab ${e?`active`:``}`,children:`Schema`}),(0,R.jsx)(Dn,{to:`sensitivity`,className:({isActive:e})=>`sub-tab ${e?`active`:``}`,children:`Sensitivity`})]}),(0,R.jsx)(`div`,{className:`main-body`,children:(0,R.jsx)(sn,{})})]})}var Fh=Xr(`inline-flex min-h-6 max-w-full items-center rounded-md px-2 py-0.5 text-xs font-medium`,{variants:{variant:{default:`bg-primary text-primary-foreground`,secondary:`bg-secondary text-secondary-foreground`,warning:`bg-warning text-warning-foreground dark:bg-amber-500/15 dark:text-amber-400`,danger:`bg-destructive text-destructive-foreground`,outline:`border border-border bg-background text-muted-foreground`}},defaultVariants:{variant:`default`}});function Ih({className:e,variant:t,...n}){return(0,R.jsx)(`span`,{className:Q(Fh({variant:t}),e),...n})}function $({label:e,description:t,children:n,className:r}){return(0,R.jsxs)(`label`,{className:Q(`grid gap-1.5`,r),children:[(0,R.jsx)(`span`,{className:`text-xs font-semibold text-muted-foreground`,children:e}),n,t?(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t}):null]})}function Lh(e){return e?.join(`, `)??``}function Rh({value:e,onChange:t}){let[n,r]=(0,M.useState)(null),i=n??Lh(e);return(0,R.jsx)(Rm,{value:i,onChange:e=>r(e.target.value),onFocus:()=>r(Lh(e)),onBlur:()=>{t(pr(n??Lh(e))),r(null)}})}function zh({className:e,...t}){return(0,R.jsx)(`textarea`,{"data-slot":`textarea`,className:Q(`min-h-24 w-full rounded-md border border-input bg-background px-3 py-2 text-sm outline-none transition-colors placeholder:text-muted-foreground focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`,e),...t})}var Bh={forced:!0,effective:!0};function Vh(e,t){let{physical:n}=e,r=new Set(e.escalatedByOtherFiles),i=n.sensitive===!0,a=i||t.sensitive===!0,o={};for(let e of n.columns){let n=e.sensitive===!0||a||r.has(e.id);o[e.id]={forced:n,effective:n||t.columns[e.id]?.sensitive===!0}}return{forced:i,effective:a,columns:o}}function Hh(){let{workspace:e,selectedTable:t,selectedDraft:n,updateTableDraft:r,updateColumnDraft:i,requestSuggestion:a,suggestingKey:o}=vr();if(!t||!n||!e)return null;let s=e.aiConfigured,c=t,l=n,u=c.physical.id,d=Vh(c,l);return(0,R.jsxs)(`div`,{className:`stack`,style:{padding:`var(--pad-y) var(--pad-x)`},children:[(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Table Enrichment`})}),(0,R.jsx)(`div`,{className:`card-bd`,children:(0,R.jsxs)(`div`,{style:{display:`grid`,gap:16},children:[(0,R.jsx)(Uh,{aiConfigured:s,label:`Description`,onSuggest:()=>a({scope:`table`,tableId:u,field:`description`},`table description`),suggesting:o===`table:${u}:description`,children:(0,R.jsx)(zh,{value:l.description,onChange:e=>r(u,t=>({...t,description:e.target.value}))})}),(0,R.jsxs)(`div`,{style:{display:`grid`,gap:16,gridTemplateColumns:`1fr 1fr`},children:[(0,R.jsx)(Uh,{aiConfigured:s,label:`Aliases`,onSuggest:()=>a({scope:`table`,tableId:u,field:`aliases`},`table aliases`),suggesting:o===`table:${u}:aliases`,children:(0,R.jsx)(Rh,{value:l.aliases,onChange:e=>r(u,t=>({...t,aliases:e}))})}),(0,R.jsx)(Uh,{aiConfigured:s,label:`Primary entity`,onSuggest:()=>a({scope:`table`,tableId:u,field:`primaryEntity`},`primary entity`),suggesting:o===`table:${u}:primaryEntity`,children:(0,R.jsx)(Rm,{value:l.primaryEntity??``,onChange:e=>r(u,t=>({...t,primaryEntity:e.target.value.trim()||void 0}))})})]}),(0,R.jsxs)(`div`,{style:{display:`grid`,gap:16,gridTemplateColumns:`1fr 220px`},children:[(0,R.jsx)($,{label:`Tags`,description:`Comma-separated labels used for browsing and filtering.`,children:(0,R.jsx)(Rh,{value:l.tags,onChange:e=>r(u,t=>({...t,tags:e}))})}),(0,R.jsx)(Wh,{label:`Table sensitivity override`,value:l.sensitive,forced:d.forced,onChange:e=>r(u,t=>({...t,sensitive:e}))})]})]})})]}),(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Common Query Language`})}),(0,R.jsx)(`div`,{className:`card-bd`,children:(0,R.jsx)(Uh,{aiConfigured:s,label:`Business vocabulary`,onSuggest:()=>a({scope:`table`,tableId:u,field:`commonQueryLanguage`},`common query language`),suggesting:o===`table:${u}:commonQueryLanguage`,children:(0,R.jsx)(zh,{className:`min-h-36`,value:l.commonQueryLanguage??``,onChange:e=>r(u,t=>({...t,commonQueryLanguage:e.target.value}))})})})]}),(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Example Questions`})}),(0,R.jsx)(`div`,{className:`card-bd`,children:(0,R.jsx)($,{label:`Questions`,children:(0,R.jsx)(zh,{className:`min-h-32`,value:l.exampleQuestions??``,onChange:e=>r(u,t=>({...t,exampleQuestions:e.target.value}))})})})]}),(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsxs)(`div`,{className:`card-hd`,children:[(0,R.jsx)(`h3`,{children:`Columns`}),c.missingColumnIds.length>0&&(0,R.jsxs)(Ih,{variant:c.missingColumnIds.length>0?`warning`:`secondary`,children:[c.missingColumnIds.length,` missing`]})]}),(0,R.jsx)(`div`,{className:`card-bd`,children:(0,R.jsx)(`div`,{style:{display:`grid`,gap:12},children:c.physical.columns.map(e=>{let t=l.columns[e.id]??{},n=d.columns[e.id]??Bh;return(0,R.jsxs)(`section`,{className:`column-row`,children:[(0,R.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,justifyContent:`space-between`,gap:8},children:(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:8},children:[(0,R.jsx)(`h4`,{style:{fontSize:13,fontWeight:600},children:e.name}),(0,R.jsx)(Ih,{variant:`outline`,children:e.type}),e.primaryKey&&(0,R.jsx)(Ih,{variant:`secondary`,children:`PK`}),e.nullable&&(0,R.jsx)(Ih,{variant:`outline`,children:`nullable`}),n.effective&&(0,R.jsx)(Ih,{variant:`danger`,children:`sensitive`})]}),(0,R.jsx)(`p`,{className:`muted tiny`,style:{marginTop:4,wordBreak:`break-all`},children:e.id})]})}),(0,R.jsxs)(`div`,{style:{marginTop:12,display:`grid`,gap:12},children:[(0,R.jsx)(Uh,{aiConfigured:s,label:`Description`,onSuggest:()=>a({scope:`column`,tableId:u,columnId:e.id,field:`description`},`${e.name} description`),suggesting:o===`column:${u}:${e.id}:description`,children:(0,R.jsx)(zh,{value:t.description??``,onChange:t=>i(u,e.id,e=>({...e,description:t.target.value}))})}),(0,R.jsxs)(`div`,{style:{display:`grid`,gap:12,gridTemplateColumns:`1fr 1fr 1fr`},children:[(0,R.jsx)(Uh,{aiConfigured:s,label:`Aliases`,onSuggest:()=>a({scope:`column`,tableId:u,columnId:e.id,field:`aliases`},`${e.name} aliases`),suggesting:o===`column:${u}:${e.id}:aliases`,children:(0,R.jsx)(Rh,{value:t.aliases,onChange:t=>i(u,e.id,e=>({...e,aliases:t}))})}),(0,R.jsx)($,{label:`Enum notes`,children:(0,R.jsx)(Rh,{value:t.enum,onChange:t=>i(u,e.id,e=>({...e,enum:t}))})}),(0,R.jsx)(Wh,{label:`Sensitivity override`,value:t.sensitive,forced:n.forced,onChange:t=>i(u,e.id,e=>({...e,sensitive:t}))})]})]})]},e.id)})})})]}),(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Relationships`})}),(0,R.jsx)(`div`,{className:`card-bd`,children:c.physical.relationships&&c.physical.relationships.length>0?(0,R.jsx)(`div`,{style:{display:`grid`,gap:8},children:c.physical.relationships.map((e,t)=>(0,R.jsxs)(`div`,{className:`relationship-row`,children:[(0,R.jsx)(`span`,{style:{wordBreak:`break-all`},children:e.from}),(0,R.jsx)(_i,{size:14,style:{color:`var(--ink-400)`,flexShrink:0}}),(0,R.jsx)(`span`,{style:{wordBreak:`break-all`},children:e.to})]},`${e.from}-${e.to}-${t}`))}):(0,R.jsx)(`p`,{className:`muted`,style:{fontSize:13},children:`No relationships recorded for this table.`})})]})]})}function Uh({aiConfigured:e,children:t,label:n,onSuggest:r,suggesting:i}){return(0,R.jsxs)(`div`,{style:{display:`grid`,gap:6},children:[(0,R.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:8},children:[(0,R.jsx)(`span`,{className:`muted`,style:{fontSize:12,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.04em`},children:n}),(0,R.jsxs)(`button`,{type:`button`,className:`suggest-link`,disabled:!e||i,onClick:()=>void r(),title:e?`Suggest with configured AI model`:`Configure an AI key to enable suggestions`,children:[i?(0,R.jsx)(Vi,{size:12,className:`animate-spin`}):(0,R.jsx)(ma,{size:12}),`Suggest`]})]}),t]})}function Wh({forced:e,label:t,onChange:n,value:r}){return(0,R.jsxs)(`label`,{style:{display:`grid`,gap:6},children:[(0,R.jsx)(`span`,{className:`muted`,style:{fontSize:12,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.04em`},children:t}),(0,R.jsxs)(`select`,{className:`h-9 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring`,value:r===void 0?`inherit`:r?`true`:`false`,onChange:e=>{e.target.value===`inherit`?n(void 0):n(e.target.value===`true`)},children:[(0,R.jsx)(`option`,{value:`inherit`,children:`Inherit physical metadata`}),(0,R.jsx)(`option`,{value:`true`,children:`Sensitive`}),(0,R.jsx)(`option`,{value:`false`,disabled:e,children:`Not sensitive`})]})]})}function Gh(){let{selectedTable:e}=vr();if(!e)return null;let t=e;return(0,R.jsxs)(`div`,{className:`stack`,style:{padding:`var(--pad-y) var(--pad-x)`},children:[(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Column Details`})}),(0,R.jsx)(`div`,{className:`card-bd tight`,children:(0,R.jsxs)(`table`,{className:`tbl`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{children:`Name`}),(0,R.jsx)(`th`,{children:`Type`}),(0,R.jsx)(`th`,{children:`Nullable`}),(0,R.jsx)(`th`,{children:`PK`}),(0,R.jsx)(`th`,{children:`Sensitive`})]})}),(0,R.jsx)(`tbody`,{children:t.physical.columns.map(e=>(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`td`,{children:(0,R.jsx)(`span`,{className:`mono`,children:e.name})}),(0,R.jsx)(`td`,{children:(0,R.jsx)(Ih,{variant:`outline`,children:e.type})}),(0,R.jsx)(`td`,{children:e.nullable?`Yes`:`No`}),(0,R.jsx)(`td`,{children:e.primaryKey?(0,R.jsx)(Ih,{variant:`secondary`,children:`PK`}):`—`}),(0,R.jsx)(`td`,{children:e.sensitive?(0,R.jsx)(Ih,{variant:`danger`,children:`sensitive`}):`—`})]},e.id))})]})})]}),t.physical.relationships&&t.physical.relationships.length>0&&(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Relationships`})}),(0,R.jsx)(`div`,{className:`card-bd`,children:(0,R.jsx)(`div`,{style:{display:`grid`,gap:8},children:t.physical.relationships.map((e,t)=>(0,R.jsxs)(`div`,{className:`relationship-row`,children:[(0,R.jsx)(`span`,{style:{wordBreak:`break-all`},children:e.from}),(0,R.jsx)(_i,{size:14,style:{color:`var(--ink-400)`,flexShrink:0}}),(0,R.jsx)(`span`,{style:{wordBreak:`break-all`},children:e.to})]},`${e.from}-${e.to}-${t}`))})})]})]})}function Kh(){let{selectedTable:e,selectedDraft:t,updateColumnDraft:n,updateTableDraft:r}=vr();if(!e||!t)return null;let i=e,a=t,o=i.physical.id,s=Vh(i,a);return(0,R.jsxs)(`div`,{className:`stack`,style:{padding:`var(--pad-y) var(--pad-x)`},children:[(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`LLM tracking`})}),(0,R.jsxs)(`div`,{className:`card-bd`,children:[(0,R.jsx)(`p`,{className:`muted`,style:{fontSize:12,marginBottom:10},children:`Untracked tables are excluded from LLM prompts and RAG indexing. They remain in the schema and are still visible here.`}),(0,R.jsxs)(`label`,{style:{display:`grid`,gap:6},children:[(0,R.jsx)(`span`,{className:`muted`,style:{fontSize:12,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.04em`},children:`Status`}),(0,R.jsxs)(`select`,{className:`h-9 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring`,value:a.tracked===!1?`false`:`true`,onChange:e=>{let t=e.target.value!==`false`&&void 0;r(o,e=>({...e,tracked:t}))},children:[(0,R.jsx)(`option`,{value:`true`,children:`Tracked — included in LLM context`}),(0,R.jsx)(`option`,{value:`false`,children:`Untracked — excluded from LLM context`})]})]})]})]}),(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Table-level sensitivity`})}),(0,R.jsxs)(`div`,{className:`card-bd`,children:[(0,R.jsx)(`p`,{className:`muted`,style:{fontSize:12,marginBottom:10},children:`Overrides can only escalate: marking a table or column sensitive takes effect on top of the physical metadata, but "Not sensitive" cannot un-mark something schema.json already marks sensitive. A sensitive table makes all of its columns sensitive.`}),(0,R.jsxs)(`label`,{style:{display:`grid`,gap:6},children:[(0,R.jsx)(`span`,{className:`muted`,style:{fontSize:12,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.04em`},children:`Override`}),(0,R.jsxs)(`select`,{className:`h-9 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring`,value:a.sensitive===void 0?`inherit`:a.sensitive?`true`:`false`,onChange:e=>{let t=e.target.value===`inherit`?void 0:e.target.value===`true`;r(o,e=>({...e,sensitive:t}))},children:[(0,R.jsx)(`option`,{value:`inherit`,children:`Inherit physical metadata`}),(0,R.jsx)(`option`,{value:`true`,children:`Sensitive`}),(0,R.jsx)(`option`,{value:`false`,disabled:s.forced,children:`Not sensitive`})]})]}),(0,R.jsxs)(`p`,{className:`muted`,style:{fontSize:12,marginTop:8},children:[`Effective: `,s.effective?(0,R.jsx)(Ih,{variant:`danger`,children:`sensitive`}):`not sensitive`]})]})]}),(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Column sensitivity`})}),(0,R.jsx)(`div`,{className:`card-bd tight`,children:(0,R.jsxs)(`table`,{className:`tbl`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{children:`Column`}),(0,R.jsx)(`th`,{children:`Physical`}),(0,R.jsx)(`th`,{children:`Override`}),(0,R.jsx)(`th`,{children:`Effective`})]})}),(0,R.jsx)(`tbody`,{children:i.physical.columns.map(e=>{let t=a.columns[e.id]??{},{forced:r,effective:i}=s.columns[e.id]??Bh;return(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`td`,{children:(0,R.jsx)(`span`,{className:`mono`,children:e.name})}),(0,R.jsx)(`td`,{children:e.sensitive?(0,R.jsx)(Ih,{variant:`danger`,children:`sensitive`}):(0,R.jsx)(`span`,{className:`muted`,children:`—`})}),(0,R.jsx)(`td`,{children:(0,R.jsxs)(`select`,{style:{fontSize:12,padding:`2px 6px`,borderRadius:4,border:`1px solid var(--border)`},value:t.sensitive===void 0?`inherit`:t.sensitive?`true`:`false`,onChange:t=>{let r=t.target.value===`inherit`?void 0:t.target.value===`true`;n(o,e.id,e=>({...e,sensitive:r}))},children:[(0,R.jsx)(`option`,{value:`inherit`,children:`Inherit`}),(0,R.jsx)(`option`,{value:`true`,children:`Sensitive`}),(0,R.jsx)(`option`,{value:`false`,disabled:r,children:`Not sensitive`})]})}),(0,R.jsx)(`td`,{children:i?(0,R.jsx)(Ih,{variant:`danger`,children:`sensitive`}):(0,R.jsx)(`span`,{className:`muted`,children:`—`})})]},e.id)})})]})})]})]})}var qh=`concept:`;function Jh(e){return e.startsWith(qh)?e.slice(8):e}function Yh(e){let t=e.trim();return t?t.startsWith(qh)?t:qh+t:``}function Xh(e){return structuredClone(e)}function Zh(){let{workspace:e,tables:t,handleSaveConcepts:n,saveStatus:r,busy:i}=vr(),{refreshRagStatus:a}=jr(),o=(0,M.useCallback)(async e=>{await n(e),a()},[n,a]),s=(0,M.useMemo)(()=>{if(!t.length)return[];let e=[];for(let n of t){e.push({id:n.physical.id,label:`${n.physical.schema}.${n.physical.name}`,kind:`table`});for(let t of n.physical.columns)e.push({id:t.id,label:`${n.physical.schema}.${n.physical.name} → ${t.name}`,kind:`column`})}return e},[t]);if(!e)return null;let c=e.concepts.map(e=>e.id).join(`,`);return(0,R.jsx)(`main`,{className:`main-pane`,children:(0,R.jsx)($h,{concepts:e.concepts,linkOptions:s,onSave:o,saveStatus:r,busy:i},c)})}function Qh(e,t){switch(t.type){case`set_selectedIndex`:return{...e,selectedIndex:t.payload};case`set_conceptSearch`:return{...e,conceptSearch:t.payload};case`merge_addDraft`:return{...e,addDraft:{...e.addDraft,...t.payload}};case`update_concept`:return{...e,draft:e.draft.map((e,n)=>n===t.index?t.updater(Xh(e)):e)};case`remove_concept`:{let n=e.draft.filter((e,n)=>n!==t.index),r=e.selectedIndex;return e.selectedIndex===t.index?r=null:e.selectedIndex!==null&&e.selectedIndex>t.index&&(r=e.selectedIndex-1),{...e,draft:n,selectedIndex:r}}case`commit_add`:return{...e,draft:[...e.draft,t.concept],selectedIndex:t.newIndex,addDraft:{},addOpen:!1};case`open_add_form`:return{...e,addOpen:!0,selectedIndex:null};case`select_concept`:return{...e,selectedIndex:t.index,addOpen:!1};case`cancel_add`:return{...e,addOpen:!1,addDraft:{}};case`revert`:return{...e,draft:Xh(t.concepts),selectedIndex:null,addOpen:!1}}}function $h({concepts:e,linkOptions:t,onSave:n,saveStatus:r,busy:i}){let[a,o]=(0,M.useReducer)(Qh,null,()=>({draft:Xh(e),selectedIndex:null,addOpen:!1,addDraft:{},conceptSearch:``})),{draft:s,selectedIndex:c,addOpen:l,addDraft:u,conceptSearch:d}=a,f=JSON.stringify(s)!==JSON.stringify(e),p=(0,M.useMemo)(()=>{if(!d)return s.map((e,t)=>({concept:e,index:t}));let e=d.toLowerCase();return s.flatMap((t,n)=>t.label.toLowerCase().includes(e)||t.id.toLowerCase().includes(e)||t.synonyms?.some(t=>t.toLowerCase().includes(e))?[{concept:t,index:n}]:[])},[s,d]),m=c===null?null:s[c];function h(e,t){o({type:`update_concept`,index:e,updater:t})}function g(e){o({type:`remove_concept`,index:e})}function _(){let e=Yh(u.id??``);if(!e||!u.label?.trim())return;let t={id:e,label:u.label.trim(),...u.synonyms?.length?{synonyms:u.synonyms}:{},...u.links?.length?{links:u.links}:{},...u.description?.trim()?{description:u.description.trim()}:{}};o({type:`commit_add`,concept:t,newIndex:s.length})}return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`main-hd`,children:[(0,R.jsxs)(`div`,{className:`main-title`,children:[(0,R.jsxs)(`h1`,{children:[(0,R.jsx)(Li,{size:18,style:{display:`inline`,marginRight:8}}),`Concepts`]}),(0,R.jsx)(`div`,{className:`main-sub`,children:`Cross-table domain vocabulary for NL→SQL grounding`})]}),(0,R.jsxs)(`div`,{className:`main-actions`,children:[(0,R.jsxs)(`button`,{type:`button`,className:`btn`,onClick:()=>o({type:`revert`,concepts:e}),disabled:!f||i.has(`save-concepts`),children:[(0,R.jsx)(B,{size:14}),` Revert`]}),(0,R.jsxs)(`button`,{type:`button`,className:`btn primary`,onClick:()=>void n(s),disabled:!f||i.has(`save-concepts`),children:[i.has(`save-concepts`)?(0,R.jsx)(Vi,{size:14,className:`animate-spin`}):(0,R.jsx)(oa,{size:14}),`Save`]})]})]}),r&&(0,R.jsx)(Eh,{status:r}),(0,R.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`280px 1fr`,flex:1,minHeight:0,overflow:`hidden`},children:[(0,R.jsxs)(`div`,{className:`sub-rail`,style:{borderRight:`1px solid var(--border)`},children:[(0,R.jsxs)(`div`,{className:`sub-rail-hd`,children:[(0,R.jsx)(`h2`,{children:`Concepts`}),(0,R.jsx)(`span`,{className:`muted tiny`,children:s.length})]}),(0,R.jsxs)(`div`,{className:`sub-rail-search`,children:[(0,R.jsx)(ca,{size:13}),(0,R.jsx)(`input`,{type:`text`,"aria-label":`Search concepts`,placeholder:`Search concepts…`,value:d,onChange:e=>o({type:`set_conceptSearch`,payload:e.target.value})})]}),(0,R.jsx)(`div`,{style:{padding:`6px 8px`,borderBottom:`1px solid var(--border)`},children:(0,R.jsxs)(`button`,{type:`button`,className:`btn sm`,style:{width:`100%`,justifyContent:`center`},onClick:()=>o({type:`open_add_form`}),children:[(0,R.jsx)($i,{size:12}),` Add concept`]})}),(0,R.jsxs)(`div`,{className:`sub-rail-list`,children:[p.map(({concept:e,index:t})=>(0,R.jsxs)(`button`,{type:`button`,className:`sub-rail-row ${c===t?`active`:``}`,onClick:()=>o({type:`select_concept`,index:t}),children:[(0,R.jsx)(Li,{size:12,style:{flexShrink:0,color:`var(--ink-400)`}}),(0,R.jsx)(`span`,{className:`row-name`,children:e.label}),(0,R.jsxs)(`span`,{className:`row-meta`,children:[e.links?.length??0,` links`]})]},e.id)),p.length===0&&(0,R.jsx)(`div`,{className:`muted tiny`,style:{padding:`16px`,textAlign:`center`},children:d?`No concepts match your search`:`No concepts yet`})]})]}),(0,R.jsx)(`div`,{style:{overflow:`auto`,padding:`var(--pad-y) var(--pad-x)`},children:l?(0,R.jsx)(`div`,{className:`stack`,children:(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`New Concept`})}),(0,R.jsx)(`div`,{className:`card-bd`,children:(0,R.jsxs)(`div`,{style:{display:`grid`,gap:12},children:[(0,R.jsxs)(`div`,{style:{display:`grid`,gap:12,gridTemplateColumns:`1fr 1fr`},children:[(0,R.jsx)($,{label:`ID`,description:`Unique slug (concept: prefix added automatically)`,children:(0,R.jsx)(tg,{value:u.id??``,onChange:e=>o({type:`merge_addDraft`,payload:{id:e}}),placeholder:`revenue`})}),(0,R.jsx)($,{label:`Label`,description:`Human-readable name, e.g. "Revenue"`,children:(0,R.jsx)(Rm,{value:u.label??``,placeholder:`Revenue`,onChange:e=>o({type:`merge_addDraft`,payload:{label:e.target.value}})})})]}),(0,R.jsx)($,{label:`Synonyms`,description:`Comma-separated terms users might say`,children:(0,R.jsx)(Rh,{value:u.synonyms,onChange:e=>o({type:`merge_addDraft`,payload:{synonyms:e}})})}),(0,R.jsx)($,{label:`Links`,description:`Tables or columns this concept maps to`,children:(0,R.jsx)(ng,{value:u.links??[],onChange:e=>o({type:`merge_addDraft`,payload:{links:e}}),options:t})}),(0,R.jsx)($,{label:`Description`,description:`How this concept is computed or what it means`,children:(0,R.jsx)(zh,{value:u.description??``,placeholder:`Sum of orders.total_amount where status = 'paid', expressed in cents.`,onChange:e=>o({type:`merge_addDraft`,payload:{description:e.target.value}})})}),(0,R.jsxs)(`div`,{style:{display:`flex`,gap:8,justifyContent:`flex-end`},children:[(0,R.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>o({type:`cancel_add`}),children:`Cancel`}),(0,R.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:_,disabled:!u.id?.trim()||!u.label?.trim(),children:`Add concept`})]})]})})]})}):m&&c!==null?(0,R.jsx)(eg,{concept:m,linkOptions:t,onChange:e=>h(c,e),onRemove:()=>g(c)}):(0,R.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`center`,height:`100%`},children:(0,R.jsxs)(`div`,{style:{textAlign:`center`,color:`var(--ink-400)`},children:[(0,R.jsx)(Li,{size:24,style:{margin:`0 auto 8px`}}),(0,R.jsx)(`p`,{style:{fontSize:13},children:s.length===0?`Click "Add concept" to create your first one`:`Select a concept to edit`})]})})})]})]})}function eg({concept:e,linkOptions:t,onChange:n,onRemove:r}){return(0,R.jsx)(`div`,{className:`stack`,children:(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsxs)(`div`,{className:`card-hd`,children:[(0,R.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:8},children:[(0,R.jsx)(`h3`,{children:e.label}),(0,R.jsx)(Ih,{variant:`outline`,children:e.id})]}),(0,R.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:r,title:`Remove concept`,style:{color:`var(--red-600)`},children:`Remove`})]}),(0,R.jsx)(`div`,{className:`card-bd`,children:(0,R.jsxs)(`div`,{style:{display:`grid`,gap:12},children:[(0,R.jsxs)(`div`,{style:{display:`grid`,gap:12,gridTemplateColumns:`1fr 1fr`},children:[(0,R.jsx)($,{label:`ID`,description:`Unique slug (concept: prefix added automatically)`,children:(0,R.jsx)(tg,{value:e.id,onChange:e=>n(t=>({...t,id:e}))})}),(0,R.jsx)($,{label:`Label`,description:`Human-readable name`,children:(0,R.jsx)(Rm,{value:e.label,onChange:e=>n(t=>({...t,label:e.target.value}))})})]}),(0,R.jsx)($,{label:`Synonyms`,description:`Comma-separated alternative terms`,children:(0,R.jsx)(Rh,{value:e.synonyms,onChange:e=>n(t=>({...t,synonyms:e.length?e:void 0}))})}),(0,R.jsx)($,{label:`Links`,description:`Tables or columns this concept maps to`,children:(0,R.jsx)(ng,{value:e.links??[],onChange:e=>n(t=>({...t,links:e.length?e:void 0})),options:t})}),(0,R.jsx)($,{label:`Description`,description:`How this concept is computed or what it means`,children:(0,R.jsx)(zh,{value:e.description??``,onChange:e=>n(t=>({...t,description:e.target.value||void 0}))})})]})})]})})}function tg({value:e,onChange:t,placeholder:n}){let r=Jh(e);return(0,R.jsxs)(`div`,{className:`concept-id-input`,children:[(0,R.jsx)(`span`,{className:`concept-id-prefix`,children:`concept:`}),(0,R.jsx)(`input`,{type:`text`,"aria-label":`Concept ID`,className:`concept-id-slug`,value:r,placeholder:n??`my-concept`,onChange:e=>{t(Yh(e.target.value.replace(/\s+/g,`-`).toLowerCase()))}})]})}function ng({value:e,onChange:t,options:n}){let[r,i]=(0,M.useState)(``),[a,o]=(0,M.useState)(!1),[s,c]=(0,M.useState)(0),l=(0,M.useRef)(null),u=(0,M.useRef)(null),d=(0,M.useRef)(null);(0,M.useEffect)(()=>{function e(e){l.current&&!l.current.contains(e.target)&&o(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let f=(0,M.useMemo)(()=>new Set(e),[e]),p=(0,M.useMemo)(()=>{if(!r)return n.filter(e=>!f.has(e.id));let e=r.toLowerCase();return n.filter(t=>!f.has(t.id)&&(t.label.toLowerCase().includes(e)||t.id.toLowerCase().includes(e)))},[n,r,f]),m=p.slice(0,30),h=(0,M.useCallback)(n=>{t([...e,n]),i(``),u.current?.focus()},[e,t]),g=(0,M.useCallback)(n=>{t(e.filter(e=>e!==n))},[e,t]);(0,M.useEffect)(()=>{a&&d.current&&d.current.querySelectorAll(`[data-link-item]`)[s]?.scrollIntoView({block:`nearest`})},[s,a]);function _(e){if(!a)(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(o(!0),e.preventDefault());else switch(e.key){case`ArrowDown`:e.preventDefault(),c(e=>Math.min(e+1,m.length-1));break;case`ArrowUp`:e.preventDefault(),c(e=>Math.max(e-1,0));break;case`Enter`:e.preventDefault(),m[s]&&h(m[s].id);break;case`Escape`:e.preventDefault(),o(!1)}}function v(e){return n.find(t=>t.id===e)?.label??e}function y(e){return n.find(t=>t.id===e)?.kind??(e.includes(`#`)?`column`:`table`)}return(0,R.jsxs)(`div`,{className:`links-input`,ref:l,children:[e.length>0&&(0,R.jsx)(`div`,{className:`links-chips`,children:e.map(e=>(0,R.jsxs)(`span`,{className:`links-chip ${y(e)}`,title:e,children:[(0,R.jsx)(va,{size:10}),(0,R.jsx)(`span`,{className:`links-chip-label`,children:v(e)}),(0,R.jsx)(`button`,{type:`button`,className:`links-chip-remove`,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),g(e)},title:`Remove`,children:(0,R.jsx)(wa,{size:10})})]},e))}),(0,R.jsxs)(`div`,{className:`links-search`,children:[(0,R.jsx)(ca,{size:12}),(0,R.jsx)(`input`,{ref:u,type:`text`,"aria-label":`Search tables or columns`,className:`links-search-input`,placeholder:e.length?`Add another…`:`Search tables or columns…`,value:r,onChange:e=>{i(e.target.value),c(0)},onFocus:()=>o(!0),onKeyDown:_})]}),a&&m.length>0&&(0,R.jsxs)(`div`,{className:`links-dropdown`,ref:d,role:`listbox`,children:[m.map((e,t)=>(0,R.jsxs)(`button`,{type:`button`,"data-link-item":!0,role:`option`,"aria-selected":t===s,className:`links-dropdown-item ${t===s?`highlighted`:``}`,onMouseDown:t=>{t.preventDefault(),h(e.id)},onMouseEnter:()=>c(t),children:[(0,R.jsx)(`span`,{className:`links-kind-badge ${e.kind}`,children:e.kind===`table`?`T`:`C`}),(0,R.jsx)(`span`,{className:`links-dropdown-label`,children:e.label})]},e.id)),p.length>30&&(0,R.jsxs)(`div`,{className:`links-dropdown-more`,children:[p.length-30,` more — type to narrow`]})]})]})}function rg(){let{workspace:e,tables:t,handleSaveTenantPolicy:n,handleSuggestTenantPolicy:r,saveStatus:i,busy:a}=vr(),{refreshRagStatus:o}=jr(),[s,c]=(0,M.useState)(!1),l=(0,M.useCallback)(async(e,t)=>{let r=await n(e,t);return r&&o(),r},[n,o]);if(!e)return null;let u=e.tenantPolicy??null;return u?s?(0,R.jsx)(`main`,{className:`main-pane`,children:(0,R.jsx)(ag,{tenantPolicy:u,tables:t,busy:a,saveStatus:i,onSave:async(e,t)=>{let n=await l(e,t);return n&&c(!1),n},onCancel:()=>c(!1)},u.schemaId)}):(0,R.jsx)(`main`,{className:`main-pane`,children:(0,R.jsx)(ig,{tenantPolicy:u,onEdit:()=>c(!0)})}):(0,R.jsx)(`main`,{className:`main-pane`,children:(0,R.jsx)(cg,{tables:t,schemaId:e.schemaId,aiConfigured:e.aiConfigured,busy:a,onSave:l,onSuggest:r,saveStatus:i})})}function ig({tenantPolicy:e,onEdit:t}){let n=e.coverage.reduce((e,t)=>(e[t.classification]=(e[t.classification]??0)+1,e),{}),r=e.coverage.length,i=r-(n.unknown??0),a=r>0?Math.round(i/r*100):0;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`main-hd`,children:[(0,R.jsxs)(`div`,{className:`main-title`,children:[(0,R.jsxs)(`h1`,{children:[(0,R.jsx)(fa,{size:18,style:{display:`inline`,marginRight:8}}),`Multi-Tenancy`]}),(0,R.jsxs)(`div`,{className:`main-sub`,children:[`Schema: `,e.schemaId,` · `,a,`% table coverage (`,i,`/`,r,`)`,(0,R.jsx)(Ih,{variant:e.enforcement===`strict`?`danger`:`warning`,style:{marginLeft:8},children:e.enforcement})]})]}),(0,R.jsx)(`div`,{className:`main-actions`,children:(0,R.jsxs)(`button`,{type:`button`,className:`btn`,onClick:t,children:[(0,R.jsx)(Yi,{size:14}),` Edit`]})})]}),(0,R.jsx)(`div`,{className:`main-body`,children:(0,R.jsxs)(`div`,{className:`stack`,style:{padding:`var(--pad-y) var(--pad-x)`},children:[(0,R.jsx)(ug,{title:`Coverage`,children:(0,R.jsxs)(`div`,{className:`grid-4`,children:[(0,R.jsx)(dg,{label:`Root`,count:n.root??0,variant:`primary`}),(0,R.jsx)(dg,{label:`Scoped`,count:n.scoped??0,variant:`primary`}),(0,R.jsx)(dg,{label:`Global`,count:n.global??0,variant:`secondary`}),(0,R.jsx)(dg,{label:`Unknown`,count:n.unknown??0,variant:`warning`})]})}),(0,R.jsx)(ug,{title:`Tenant Roots`,count:e.roots.length,children:(0,R.jsx)(`div`,{style:{display:`grid`,gap:8},children:e.roots.map(e=>(0,R.jsxs)(`div`,{className:`card`,style:{padding:12},children:[(0,R.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:8},children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`mono`,style:{fontWeight:600,fontSize:13},children:e.id}),(0,R.jsx)(`span`,{className:`muted`,style:{marginLeft:8,fontSize:12},children:e.label})]}),(0,R.jsxs)(Ih,{variant:`outline`,children:[`col: `,e.tenantIdColumn]})]}),e.parent&&(0,R.jsxs)(`p`,{className:`muted tiny`,style:{marginTop:4},children:[`Parent: `,(0,R.jsx)(`code`,{children:e.parent.root}),` via `,(0,R.jsx)(`code`,{children:e.parent.foreignKey})]})]},e.id))})}),e.hierarchy.length>0&&(0,R.jsx)(ug,{title:`Hierarchy Edges`,count:e.hierarchy.length,children:(0,R.jsx)(`div`,{style:{display:`grid`,gap:8},children:e.hierarchy.map(e=>(0,R.jsxs)(`div`,{className:`card`,style:{padding:12,fontSize:13},children:[(0,R.jsx)(`code`,{children:e.parent}),(0,R.jsx)(`span`,{className:`muted`,style:{margin:`0 8px`},children:`→`}),(0,R.jsx)(`code`,{children:e.child}),(0,R.jsxs)(`div`,{className:`muted tiny`,style:{marginTop:4},children:[`FK: `,e.foreignKey]})]},`${e.parent}-${e.child}`))})}),e.scopedTables.length>0&&(0,R.jsx)(ug,{title:`Scoped Tables`,count:e.scopedTables.length,defaultOpen:!1,children:(0,R.jsx)(`div`,{style:{display:`grid`,gap:8},children:e.scopedTables.map(e=>(0,R.jsxs)(`div`,{className:`card`,style:{padding:12},children:[(0,R.jsx)(`span`,{className:`mono`,style:{fontWeight:600,fontSize:13},children:e.id}),(0,R.jsx)(`div`,{style:{marginTop:4,display:`grid`,gap:4},children:e.scopeThrough.map((e,t)=>(0,R.jsxs)(`p`,{className:`muted tiny`,children:[`via `,(0,R.jsx)(Ih,{variant:`outline`,children:e.root}),` `,`column`in e?(0,R.jsxs)(`span`,{children:[`column `,(0,R.jsx)(`code`,{children:e.column})]}):(0,R.jsxs)(`span`,{children:[`join `,e.join.map(e=>`${e.from} -> ${e.to}`).join(`, `)]})]},t))})]},e.id))})}),e.polymorphicTables.length>0&&(0,R.jsx)(ug,{title:`Polymorphic Tables`,count:e.polymorphicTables.length,defaultOpen:!1,children:(0,R.jsx)(`div`,{style:{display:`grid`,gap:8},children:e.polymorphicTables.map(e=>(0,R.jsxs)(`div`,{className:`card`,style:{padding:12},children:[(0,R.jsx)(`span`,{className:`mono`,style:{fontWeight:600,fontSize:13},children:e.id}),(0,R.jsxs)(`p`,{className:`muted tiny`,style:{marginTop:4},children:[`Type: `,(0,R.jsx)(`code`,{children:e.typeColumn}),` · ID: `,(0,R.jsx)(`code`,{children:e.idColumn})]}),(0,R.jsx)(`div`,{style:{marginTop:4,display:`flex`,flexWrap:`wrap`,gap:4},children:Object.entries(e.mapping).map(([e,t])=>(0,R.jsxs)(Ih,{variant:`outline`,children:[e,` → `,t]},e))})]},e.id))})}),e.globalTables.length>0&&(0,R.jsx)(ug,{title:`Global Tables`,count:e.globalTables.length,defaultOpen:!1,children:(0,R.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8},children:e.globalTables.map(e=>(0,R.jsx)(Ih,{variant:`secondary`,children:e},e))})}),(0,R.jsx)(ug,{title:`Table Coverage`,count:e.coverage.length,defaultOpen:!1,children:(0,R.jsx)(`div`,{className:`card`,children:(0,R.jsx)(`div`,{className:`card-bd tight`,children:(0,R.jsxs)(`table`,{className:`tbl`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{children:`Table`}),(0,R.jsx)(`th`,{children:`Classification`}),(0,R.jsx)(`th`,{children:`Scope Roots`})]})}),(0,R.jsx)(`tbody`,{children:e.coverage.map(e=>(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`td`,{children:(0,R.jsx)(`span`,{className:`mono`,children:e.tableId})}),(0,R.jsx)(`td`,{children:(0,R.jsx)(Ih,{variant:e.classification===`unknown`?`warning`:e.classification===`global`?`secondary`:`outline`,children:e.classification})}),(0,R.jsx)(`td`,{className:`muted tiny`,children:e.scopeRoots?.join(`, `)??`—`})]},e.tableId))})]})})})}),e.warnings.length>0&&(0,R.jsx)(ug,{title:`Policy Warnings`,count:e.warnings.length,children:(0,R.jsx)(`div`,{style:{display:`grid`,gap:8},children:e.warnings.map(e=>(0,R.jsx)(`pre`,{className:`warning-block`,children:fg(e)},String(e)))})})]})})]})}function ag({tenantPolicy:e,tables:t,busy:n,saveStatus:r,onSave:i,onCancel:a}){let[o,s]=(0,M.useState)(()=>pg(e)),[c,l]=(0,M.useState)(()=>e.body);return(0,R.jsx)(lg,{tables:t,frontmatter:o,body:c,busy:n,saveStatus:r,onFrontmatterChange:s,onBodyChange:l,onConfirm:()=>void i(o,c||void 0),onBack:a,title:`Edit Tenant Policy`,backLabel:`Cancel`,confirmLabel:`Save Changes`,badgeLabel:`Saved`})}function og(e,t){switch(t.type){case`set_mode`:return{...e,mode:t.payload};case`set_draftStatus`:return{...e,draftStatus:t.payload};case`set_draftFrontmatter`:return{...e,draftFrontmatter:t.payload};case`set_draftBody`:return{...e,draftBody:t.payload};case`set_enforcement`:return{...e,enforcement:t.payload};case`set_rootTenantIdColumn`:return{...e,rootTenantIdColumn:t.payload};case`set_rootLabel`:return{...e,rootLabel:t.payload};case`select_root_table`:return{...e,rootTableId:t.tableId,rootLabel:t.label,rootTenantIdColumn:``};case`toggle_global_table`:return{...e,globalTableIds:t.checked?[...e.globalTableIds,t.tableId]:e.globalTableIds.filter(e=>e!==t.tableId)};case`ai_draft_complete`:return{...e,draftFrontmatter:t.frontmatter,draftBody:t.body,draftWarnings:t.warnings,mode:`review`,draftStatus:{kind:`success`,text:`AI draft ready for review.`}};case`manual_to_review`:return{...e,draftFrontmatter:t.frontmatter,draftBody:t.body,draftWarnings:[],mode:`review`}}}var sg={mode:`choose`,draftStatus:null,draftFrontmatter:null,draftBody:``,draftWarnings:[],enforcement:`strict`,rootTableId:``,rootTenantIdColumn:``,rootLabel:``,globalTableIds:[]};function cg({tables:e,schemaId:t,aiConfigured:n,busy:r,onSave:i,onSuggest:a,saveStatus:o}){let[s,c]=(0,M.useReducer)(og,sg),{mode:l,draftStatus:u,draftFrontmatter:d,draftBody:f,draftWarnings:p,enforcement:m,rootTableId:h,rootTenantIdColumn:g,rootLabel:_,globalTableIds:v}=s,y=e.find(e=>e.physical.id===h)?.physical.columns??[];async function b(){c({type:`set_draftStatus`,payload:{kind:`loading`,text:`Analyzing schema and drafting tenant policy...`}});try{let e=await a();c({type:`ai_draft_complete`,frontmatter:e.frontmatter,body:e.body,warnings:e.warnings})}catch(e){c({type:`set_draftStatus`,payload:{kind:`error`,text:e instanceof Error?e.message:String(e)}})}}function x(){if(!h||!g||!_.trim())return;let e={schemaId:t,enforcement:m,roots:[{id:h,tenantIdColumn:g,label:_.trim()}],...v.length>0?{globalTables:v}:{}};c({type:`manual_to_review`,frontmatter:e,body:`# Tenant Policy
50
50
 
51
51
 
52
52
 
@@ -60,7 +60,7 @@ Error generating stack: `+e.message+`
60
60
 
61
61
  ## Sensitive Interactions
62
62
 
63
- `})}function x(){d&&i(d,f||void 0)}let S=m&&h&&g.trim();return l===`choose`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`main-hd`,children:(0,R.jsxs)(`div`,{className:`main-title`,children:[(0,R.jsxs)(`h1`,{children:[(0,R.jsx)(fa,{size:18,style:{display:`inline`,marginRight:8}}),`Enable Multi-Tenancy`]}),(0,R.jsx)(`div`,{className:`main-sub`,children:`Configure tenant isolation for your schema`})]})}),u&&(0,R.jsx)(Eh,{status:u}),(0,R.jsx)(`div`,{className:`main-body`,children:(0,R.jsx)(`div`,{className:`stack`,style:{padding:`var(--pad-y) var(--pad-x)`},children:(0,R.jsxs)(`div`,{className:`grid-2`,children:[(0,R.jsx)(`button`,{type:`button`,className:`card`,style:{cursor:`pointer`,textAlign:`left`,border:`2px dashed var(--border)`},disabled:!n||u?.kind===`loading`,onClick:()=>void y(),children:(0,R.jsxs)(`div`,{className:`card-bd`,children:[(0,R.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:12},children:[u?.kind===`loading`?(0,R.jsx)(Vi,{size:20,className:`animate-spin`,style:{color:`var(--red-600)`}}):(0,R.jsx)(ma,{size:20,style:{color:`var(--red-600)`}}),(0,R.jsx)(`h3`,{style:{fontWeight:600},children:`Draft with AI`})]}),(0,R.jsx)(`p`,{className:`muted`,style:{fontSize:13},children:u?.kind===`loading`?`Analyzing your schema...`:`Let AI analyze your schema and propose a complete tenant policy. You will review before saving.`}),!n&&(0,R.jsx)(`p`,{style:{marginTop:8,fontSize:12,color:`var(--red-600)`},children:`Configure an AI provider to use this option.`})]})}),(0,R.jsx)(`button`,{type:`button`,className:`card`,style:{cursor:`pointer`,textAlign:`left`,border:`2px dashed var(--border)`},onClick:()=>c({type:`set_mode`,payload:`manual`}),children:(0,R.jsxs)(`div`,{className:`card-bd`,children:[(0,R.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:12},children:[(0,R.jsx)(ua,{size:20,style:{color:`var(--ink-400)`}}),(0,R.jsx)(`h3`,{style:{fontWeight:600},children:`Configure manually`})]}),(0,R.jsx)(`p`,{className:`muted`,style:{fontSize:13},children:`Pick the tenant root table and column yourself, then review before saving.`})]})})]})})})]}):l===`manual`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`main-hd`,children:[(0,R.jsxs)(`div`,{className:`main-title`,children:[(0,R.jsxs)(`h1`,{children:[(0,R.jsx)(fa,{size:18,style:{display:`inline`,marginRight:8}}),`Manual Configuration`]}),(0,R.jsx)(`div`,{className:`main-sub`,children:`Configure the basics, then review before saving`})]}),(0,R.jsx)(`div`,{className:`main-actions`,children:(0,R.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>c({type:`set_mode`,payload:`choose`}),children:`Back`})})]}),(0,R.jsx)(`div`,{className:`main-body`,children:(0,R.jsxs)(`div`,{className:`stack`,style:{padding:`var(--pad-y) var(--pad-x)`},children:[(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Tenant Root`})}),(0,R.jsx)(`div`,{className:`card-bd`,children:(0,R.jsxs)(`div`,{style:{display:`grid`,gap:16},children:[(0,R.jsx)($,{label:`Root table`,description:`The table whose rows represent tenants.`,children:(0,R.jsxs)(`select`,{className:`h-9 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring`,value:m,onChange:t=>{let n=t.target.value,r=e.find(e=>e.physical.id===n);c({type:`select_root_table`,tableId:n,label:r?.physical.name??``})},children:[(0,R.jsx)(`option`,{value:``,children:`Select a table...`}),e.map(e=>(0,R.jsxs)(`option`,{value:e.physical.id,children:[e.physical.schema,`.`,e.physical.name]},e.physical.id))]})}),m&&(0,R.jsx)($,{label:`Tenant ID column`,description:`The column that uniquely identifies a tenant.`,children:(0,R.jsxs)(`select`,{className:`h-9 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring`,value:h,onChange:e=>c({type:`set_rootTenantIdColumn`,payload:e.target.value}),children:[(0,R.jsx)(`option`,{value:``,children:`Select a column...`}),v.map(e=>(0,R.jsxs)(`option`,{value:e.name,children:[e.name,` (`,e.type,e.primaryKey?`, PK`:``,`)`]},e.id))]})}),(0,R.jsx)($,{label:`Label`,description:`e.g. "Organization" or "Company"`,children:(0,R.jsx)(Rm,{value:g,placeholder:`e.g. Organization`,onChange:e=>c({type:`set_rootLabel`,payload:e.target.value})})})]})})]}),(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Enforcement Mode`})}),(0,R.jsxs)(`div`,{className:`card-bd`,children:[(0,R.jsxs)(`fieldset`,{className:`toggle-seg`,children:[(0,R.jsx)(`button`,{type:`button`,className:p===`strict`?`active`:``,onClick:()=>c({type:`set_enforcement`,payload:`strict`}),children:`Strict`}),(0,R.jsx)(`button`,{type:`button`,className:p===`warn`?`active`:``,onClick:()=>c({type:`set_enforcement`,payload:`warn`}),children:`Warn`})]}),(0,R.jsx)(`p`,{className:`muted tiny`,style:{marginTop:8},children:p===`strict`?`Queries touching unknown (unscoped) tables will be rejected.`:`Queries touching unknown tables will succeed but emit warnings.`})]})]}),(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Global Tables (optional)`})}),(0,R.jsxs)(`div`,{className:`card-bd`,children:[(0,R.jsx)(`p`,{className:`muted`,style:{fontSize:13,marginBottom:8},children:`Global tables are shared across all tenants and never filtered.`}),(0,R.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8},children:e.map(e=>{if(e.physical.id===m)return null;let t=_.includes(e.physical.id);return(0,R.jsxs)(`label`,{className:`chunk-toggle`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:t,onChange:t=>c({type:`toggle_global_table`,tableId:e.physical.id,checked:t.target.checked})}),e.physical.schema,`.`,e.physical.name]},e.physical.id)})})]})]}),(0,R.jsx)(`div`,{style:{display:`flex`,justifyContent:`flex-end`},children:(0,R.jsxs)(`button`,{type:`button`,className:`btn primary`,onClick:b,disabled:!S,children:[(0,R.jsx)(_i,{size:14}),` Review & Confirm`]})})]})})]}):(0,R.jsx)(lg,{tables:e,frontmatter:d,body:f,busy:r,saveStatus:o,onFrontmatterChange:e=>c({type:`set_draftFrontmatter`,payload:e}),onBodyChange:e=>c({type:`set_draftBody`,payload:e}),onConfirm:x,onBack:()=>c({type:`set_mode`,payload:`choose`})})}function lg({tables:e,frontmatter:t,body:n,busy:r,saveStatus:i,onFrontmatterChange:a,onBodyChange:o,onConfirm:s,onBack:c,title:l=`Review Tenant Policy`,backLabel:u=`Start Over`,confirmLabel:d=`Confirm & Save`,badgeLabel:f=`Draft`}){function p(e){a({...t,enforcement:e})}function m(e,n){let r=[...t.roots];r[e]={...r[e],label:n},a({...t,roots:r})}function h(e){let n=t.roots.filter((t,n)=>n!==e);n.length!==0&&a({...t,roots:n})}function g(e){let n=(t.hierarchy??[]).filter((t,n)=>n!==e);a({...t,hierarchy:n.length>0?n:void 0})}function _(e){let n=(t.scopedTables??[]).filter((t,n)=>n!==e);a({...t,scopedTables:n.length>0?n:void 0})}function v(e){let n=(t.polymorphicTables??[]).filter((t,n)=>n!==e);a({...t,polymorphicTables:n.length>0?n:void 0})}function y(e){let n=t.globalTables??[],r=n.includes(e)?n.filter(t=>t!==e):[...n,e];a({...t,globalTables:r.length>0?r:void 0})}let b=new Set(t.roots.map(e=>e.id)),x=new Set((t.scopedTables??[]).map(e=>e.id)),S=new Set((t.polymorphicTables??[]).map(e=>e.id)),C=new Set(t.globalTables??[]);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`main-hd`,children:[(0,R.jsxs)(`div`,{className:`main-title`,children:[(0,R.jsxs)(`h1`,{children:[(0,R.jsx)(fa,{size:18,style:{display:`inline`,marginRight:8}}),l]}),(0,R.jsx)(`div`,{className:`main-sub`,children:(0,R.jsx)(Ih,{variant:`warning`,children:f})})]}),(0,R.jsxs)(`div`,{className:`main-actions`,children:[(0,R.jsxs)(`button`,{type:`button`,className:`btn`,onClick:c,children:[(0,R.jsx)(B,{size:14}),` `,u]}),(0,R.jsxs)(`button`,{type:`button`,className:`btn primary`,onClick:s,disabled:r.has(`save-tenant-policy`)||t.roots.length===0,children:[r.has(`save-tenant-policy`)?(0,R.jsx)(Vi,{size:14,className:`animate-spin`}):(0,R.jsx)(oa,{size:14}),d]})]})]}),i&&(0,R.jsx)(Eh,{status:i}),(0,R.jsx)(`div`,{className:`main-body`,children:(0,R.jsxs)(`div`,{className:`stack`,style:{padding:`var(--pad-y) var(--pad-x)`},children:[(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Enforcement Mode`})}),(0,R.jsxs)(`div`,{className:`card-bd`,children:[(0,R.jsxs)(`fieldset`,{className:`toggle-seg`,children:[(0,R.jsx)(`button`,{type:`button`,className:t.enforcement===`strict`?`active`:``,onClick:()=>p(`strict`),children:`Strict`}),(0,R.jsx)(`button`,{type:`button`,className:t.enforcement===`warn`?`active`:``,onClick:()=>p(`warn`),children:`Warn`})]}),(0,R.jsx)(`p`,{className:`muted tiny`,style:{marginTop:8},children:t.enforcement===`strict`?`Queries touching unknown (unscoped) tables will be rejected.`:`Queries touching unknown tables will succeed but emit warnings.`})]})]}),(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsxs)(`h3`,{children:[`Tenant Roots (`,t.roots.length,`)`]})}),(0,R.jsx)(`div`,{className:`card-bd`,children:(0,R.jsx)(`div`,{style:{display:`grid`,gap:12},children:t.roots.map((e,n)=>(0,R.jsxs)(`div`,{style:{border:`1px solid var(--border)`,borderRadius:`var(--radius)`,padding:12},children:[(0,R.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:8},children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`mono`,style:{fontWeight:600,fontSize:13},children:e.id}),(0,R.jsxs)(`div`,{style:{marginTop:4,display:`flex`,flexWrap:`wrap`,gap:4},children:[(0,R.jsxs)(Ih,{variant:`outline`,children:[`col: `,e.tenantIdColumn]}),e.parent&&(0,R.jsxs)(Ih,{variant:`outline`,children:[`parent: `,e.parent.root,` via `,e.parent.foreignKey]})]})]}),t.roots.length>1&&(0,R.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>h(n),title:`Remove root`,children:`×`})]}),(0,R.jsx)(`div`,{style:{marginTop:8},children:(0,R.jsx)($,{label:`Label`,description:`Human-readable name for this tenant root.`,children:(0,R.jsx)(Rm,{value:e.label,onChange:e=>m(n,e.target.value)})})})]},e.id))})})]}),(t.hierarchy??[]).length>0&&(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsxs)(`h3`,{children:[`Hierarchy Edges (`,t.hierarchy.length,`)`]})}),(0,R.jsx)(`div`,{className:`card-bd`,children:(0,R.jsx)(`div`,{style:{display:`grid`,gap:8},children:t.hierarchy.map((e,t)=>(0,R.jsxs)(`div`,{className:`policy-edge-card`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`code`,{children:e.parent}),(0,R.jsx)(`span`,{className:`muted`,style:{margin:`0 8px`},children:`→`}),(0,R.jsx)(`code`,{children:e.child}),(0,R.jsxs)(`div`,{className:`muted tiny`,style:{marginTop:4},children:[`FK: `,e.foreignKey]})]}),(0,R.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>g(t),title:`Remove`,children:`×`})]},`${e.parent}-${e.child}`))})})]}),(t.scopedTables??[]).length>0&&(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsxs)(`h3`,{children:[`Scoped Tables (`,t.scopedTables.length,`)`]})}),(0,R.jsx)(`div`,{className:`card-bd`,children:(0,R.jsx)(`div`,{style:{display:`grid`,gap:8},children:t.scopedTables.map((e,t)=>(0,R.jsxs)(`div`,{style:{display:`flex`,alignItems:`start`,justifyContent:`space-between`,gap:8,border:`1px solid var(--border)`,borderRadius:`var(--radius)`,padding:12},children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`mono`,style:{fontWeight:600,fontSize:13},children:e.id}),(0,R.jsx)(`div`,{style:{marginTop:4,display:`grid`,gap:4},children:e.scopeThrough.map((e,t)=>(0,R.jsxs)(`p`,{className:`muted tiny`,children:[`via `,(0,R.jsx)(Ih,{variant:`outline`,children:e.root}),` `,`column`in e?(0,R.jsxs)(`span`,{children:[`column `,(0,R.jsx)(`code`,{children:e.column})]}):(0,R.jsxs)(`span`,{children:[`join `,e.join.map(e=>`${e.from} -> ${e.to}`).join(`, `)]})]},t))})]}),(0,R.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>_(t),title:`Remove`,children:`×`})]},e.id))})})]}),(t.polymorphicTables??[]).length>0&&(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsxs)(`h3`,{children:[`Polymorphic Tables (`,t.polymorphicTables.length,`)`]})}),(0,R.jsx)(`div`,{className:`card-bd`,children:(0,R.jsx)(`div`,{style:{display:`grid`,gap:8},children:t.polymorphicTables.map((e,t)=>(0,R.jsxs)(`div`,{style:{display:`flex`,alignItems:`start`,justifyContent:`space-between`,gap:8,border:`1px solid var(--border)`,borderRadius:`var(--radius)`,padding:12},children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`mono`,style:{fontWeight:600,fontSize:13},children:e.id}),(0,R.jsxs)(`p`,{className:`muted tiny`,style:{marginTop:4},children:[`Type: `,(0,R.jsx)(`code`,{children:e.typeColumn}),` · ID: `,(0,R.jsx)(`code`,{children:e.idColumn})]}),(0,R.jsx)(`div`,{style:{marginTop:4,display:`flex`,flexWrap:`wrap`,gap:4},children:Object.entries(e.mapping).map(([e,t])=>(0,R.jsxs)(Ih,{variant:`outline`,children:[e,` → `,t]},e))})]}),(0,R.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>v(t),title:`Remove`,children:`×`})]},e.id))})})]}),(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Global Tables`})}),(0,R.jsxs)(`div`,{className:`card-bd`,children:[(0,R.jsx)(`p`,{className:`muted`,style:{fontSize:13,marginBottom:8},children:`Global tables are shared across all tenants and never filtered.`}),(0,R.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8},children:e.map(e=>b.has(e.physical.id)||x.has(e.physical.id)||S.has(e.physical.id)?null:(0,R.jsxs)(`label`,{className:`chunk-toggle`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:C.has(e.physical.id),onChange:()=>y(e.physical.id)}),e.physical.schema,`.`,e.physical.name]},e.physical.id))})]})]}),(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Documentation (body)`})}),(0,R.jsxs)(`div`,{className:`card-bd`,children:[(0,R.jsx)(`p`,{className:`muted`,style:{fontSize:13,marginBottom:8},children:`Optional markdown body explaining the tenant policy.`}),(0,R.jsx)(zh,{className:`min-h-48 font-mono text-xs`,value:n,onChange:e=>o(e.target.value)})]})]}),(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Frontmatter Preview`})}),(0,R.jsx)(`div`,{className:`card-bd`,children:(0,R.jsx)(`pre`,{className:`plain-block`,style:{fontSize:12},children:JSON.stringify(t,null,2)})})]})]})})]})}function ug({title:e,count:t,children:n,defaultOpen:r=!0}){let[i,a]=(0,M.useState)(r);return(0,R.jsxs)(`section`,{children:[(0,R.jsxs)(`button`,{type:`button`,className:`collapsible-btn`,onClick:()=>a(!i),children:[i?(0,R.jsx)(hi,{size:14}):(0,R.jsx)(_i,{size:14}),e,t==null?``:` (${t})`]}),i&&n]})}function dg({label:e,count:t,variant:n}){return(0,R.jsxs)(`div`,{className:`card`,style:{textAlign:`center`,padding:12,background:n===`primary`?`var(--red-50)`:n===`secondary`?`var(--surface-2)`:`#fef3c7`},children:[(0,R.jsx)(`div`,{style:{fontSize:24,fontWeight:700},children:t}),(0,R.jsx)(`div`,{className:`muted tiny`,children:e})]})}function fg(e){return typeof e==`string`?e:JSON.stringify(e,null,2)}function pg(e){return{schemaId:e.schemaId,enforcement:e.enforcement,roots:mg(e.roots),...e.hierarchy.length>0?{hierarchy:mg(e.hierarchy)}:{},...e.scopedTables.length>0?{scopedTables:mg(e.scopedTables)}:{},...e.polymorphicTables.length>0?{polymorphicTables:mg(e.polymorphicTables)}:{},...e.globalTables.length>0?{globalTables:[...e.globalTables]}:{}}}function mg(e){return structuredClone(e)}function hg({text:e}){return(0,R.jsx)(`p`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-sm text-muted-foreground`,children:e})}var gg=new Intl.NumberFormat;function _g(e){return gg.format(e)}function vg({label:e,value:t}){return t===null?null:(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`dt`,{children:e}),(0,R.jsx)(`dd`,{children:_g(t)})]})}function yg({title:e,usage:t}){return t?(0,R.jsxs)(`section`,{className:`usage-summary`,"aria-label":e,children:[(0,R.jsx)(`h3`,{children:e}),(0,R.jsxs)(`dl`,{className:`usage-grid`,children:[(0,R.jsx)(vg,{label:`Prompt`,value:t.promptTokens}),(0,R.jsx)(vg,{label:`Completion`,value:t.completionTokens}),(0,R.jsx)(vg,{label:`Embeddings`,value:t.embeddingTokens}),t.totalTokens!==null&&(0,R.jsxs)(`div`,{className:`usage-total`,children:[(0,R.jsx)(`dt`,{children:`Total`}),(0,R.jsx)(`dd`,{children:_g(t.totalTokens)})]})]})]}):null}function bg(){let{workspace:e}=vr(),{ragStatus:t,ragMessage:n,ragQuestion:r,setRagQuestion:i,ragK:a,setRagK:o,ragTypes:s,setRagTypes:c,ragResults:l,ragIndexUsage:u,busy:d,allChunkTypes:f,refreshRagStatus:p,handleBuildRag:m,handleQueryRag:h}=jr();if(!e)return null;let g=!t?.hasIndex||t.stale||d.has(`rag-query`);return(0,R.jsxs)(`main`,{className:`main-pane`,children:[(0,R.jsxs)(`div`,{className:`main-hd`,children:[(0,R.jsxs)(`div`,{className:`main-title`,children:[(0,R.jsxs)(`h1`,{children:[(0,R.jsx)(ma,{size:18,style:{display:`inline`,marginRight:8}}),`RAG Index`]}),(0,R.jsx)(`div`,{className:`main-sub`,children:`Retrieval-augmented generation index and query debugger`})]}),(0,R.jsxs)(`div`,{className:`main-actions`,children:[(0,R.jsxs)(`button`,{type:`button`,className:`btn`,onClick:()=>void p(),children:[(0,R.jsx)(ta,{size:14}),` Refresh`]}),(0,R.jsxs)(`button`,{type:`button`,className:`btn primary`,onClick:()=>void m(),disabled:d.has(`rag-build`),children:[d.has(`rag-build`)?(0,R.jsx)(Vi,{size:14,className:`animate-spin`}):(0,R.jsx)(di,{size:14}),`Build Index`]})]})]}),(0,R.jsx)(`div`,{className:`main-body`,children:(0,R.jsxs)(`div`,{className:`stack`,style:{padding:`var(--pad-y) var(--pad-x)`},children:[n&&(0,R.jsx)(Dh,{status:n}),t?(0,R.jsxs)(`div`,{className:`grid-4`,children:[(0,R.jsxs)(`div`,{className:`card stat-card`,children:[(0,R.jsx)(`div`,{className:`stat-label`,children:`Chunks`}),(0,R.jsx)(`div`,{className:`stat-num`,children:hr(t.chunksTotal)})]}),(0,R.jsxs)(`div`,{className:`card stat-card`,children:[(0,R.jsx)(`div`,{className:`stat-label`,children:`Indexed`}),(0,R.jsx)(`div`,{className:`stat-num`,children:hr(t.chunksIndexed)})]}),(0,R.jsxs)(`div`,{className:`card stat-card`,children:[(0,R.jsx)(`div`,{className:`stat-label`,children:`Sensitive excluded`}),(0,R.jsx)(`div`,{className:`stat-num`,children:t.sensitiveExcluded})]}),(0,R.jsxs)(`div`,{className:`card stat-card`,children:[(0,R.jsx)(`div`,{className:`stat-label`,children:`Sensitive included`}),(0,R.jsx)(`div`,{className:`stat-num`,children:t.sensitiveIncluded})]})]}):(0,R.jsx)(hg,{text:`RAG status is unavailable.`}),t&&(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Index Details`})}),(0,R.jsxs)(`div`,{className:`card-bd`,children:[(0,R.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8,marginBottom:12},children:[(0,R.jsx)(Ih,{variant:t.hasIndex?`secondary`:`warning`,children:t.hasIndex?`Index present`:`No index`}),(0,R.jsx)(Ih,{variant:t.stale?`warning`:`secondary`,children:t.stale?`Stale`:`Fresh`}),(0,R.jsx)(Ih,{variant:t.embedder.configured?`secondary`:`warning`,children:t.embedder.label})]}),(0,R.jsxs)(`div`,{style:{display:`grid`,gap:4,fontSize:12,color:`var(--ink-400)`},children:[(0,R.jsxs)(`span`,{children:[`Expected: `,t.expectedEmbedderId]}),(0,R.jsxs)(`span`,{children:[`Indexed: `,t.embedder.indexedId??`none`]}),(0,R.jsxs)(`span`,{children:[`Dimensions: `,t.dimensions??`model default`,` / expected `,t.expectedDimensions??`model default`]}),(0,R.jsxs)(`span`,{children:[`Updated: `,t.updatedAt??`never`]}),(0,R.jsxs)(`span`,{children:[`Store: `,t.store.kind]})]}),(0,R.jsx)(`div`,{className:`bar`,style:{marginTop:14},children:(0,R.jsx)(`i`,{style:{width:t.chunksTotal>0?`${Math.round(t.chunksIndexed/t.chunksTotal*100)}%`:`0%`}})})]})]}),(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Query Debugger`})}),(0,R.jsx)(`div`,{className:`card-bd`,children:(0,R.jsxs)(`div`,{style:{display:`grid`,gap:12},children:[(0,R.jsx)($,{label:`Question`,children:(0,R.jsx)(zh,{value:r,onChange:e=>i(e.target.value),placeholder:`Which customers placed orders last month?`})}),(0,R.jsxs)(`div`,{style:{display:`grid`,gap:12,gridTemplateColumns:`120px 1fr`},children:[(0,R.jsx)($,{label:`Top K`,children:(0,R.jsx)(Rm,{min:1,max:25,type:`number`,value:a,onChange:e=>o(Number(e.target.value))})}),(0,R.jsxs)(`div`,{style:{display:`grid`,gap:6},children:[(0,R.jsx)(`span`,{className:`muted`,style:{fontSize:12,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.04em`},children:`Chunk types`}),(0,R.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8},children:f.map(e=>(0,R.jsxs)(`label`,{className:`chunk-toggle`,children:[(0,R.jsx)(`input`,{checked:s.includes(e),type:`checkbox`,onChange:t=>{t.target.checked?c([...s,e]):c(s.filter(t=>t!==e))}}),e]},e))})]})]}),(0,R.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:g,onClick:()=>void h(),children:[d.has(`rag-query`)?(0,R.jsx)(Vi,{size:14,className:`animate-spin`}):(0,R.jsx)(ca,{size:14}),`Query RAG`]}),(0,R.jsx)(yg,{title:`Last Index Usage`,usage:u}),(0,R.jsx)(yg,{title:`Last Query Usage`,usage:l?.usage??null})]})})]}),(0,R.jsx)(xg,{chunks:l?.results??[],emptyText:`No chunks retrieved yet.`})]})})]})}function xg({chunks:e,emptyText:t}){return(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Retrieved Chunks`})}),(0,R.jsx)(`div`,{className:`card-bd`,children:e.length>0?(0,R.jsx)(`div`,{style:{display:`grid`,gap:12},children:e.map(e=>(0,R.jsxs)(`article`,{className:`chunk-card`,children:[(0,R.jsxs)(`div`,{style:{display:`flex`,alignItems:`start`,justifyContent:`space-between`,gap:12},children:[(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:8},children:[(0,R.jsx)(`h4`,{style:{fontSize:13,fontWeight:600,wordBreak:`break-all`},children:e.id}),(0,R.jsx)(Ih,{variant:`outline`,children:e.type}),e.sensitive&&(0,R.jsx)(Ih,{variant:`danger`,children:`sensitive`})]}),(0,R.jsxs)(`p`,{className:`muted tiny`,style:{marginTop:4,wordBreak:`break-all`},children:[`refs: `,e.refs.length>0?e.refs.join(`, `):`none`]})]}),(0,R.jsx)(Ih,{variant:`secondary`,children:e.score.toFixed(3)})]}),(0,R.jsx)(`pre`,{className:`chunk-text`,children:e.text})]},e.id))}):(0,R.jsx)(hg,{text:t})})]})}function Sg({value:e}){let[t,n]=(0,M.useState)(!1),r=(0,M.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})},[e]);return(0,R.jsxs)(Lm,{variant:`ghost`,size:`sm`,onClick:r,children:[t?(0,R.jsx)(pi,{className:`h-3.5 w-3.5 text-green-500`}):(0,R.jsx)(Di,{className:`h-3.5 w-3.5`}),t?`Copied`:`Copy`]})}function Cg(e,t){return`npm install ${[...new Set([...e===`client`?[`@askdb/client`,`@askdb/core`,`@askdb/config`,`ai`]:[`@askdb/core`,`ai`],t])].join(` `)}`}var wg={border:0,padding:0,margin:0},Tg={openai:{sdkPackage:`@ai-sdk/openai`,sdkImport:`openai`,sdkModel:e=>`openai(${JSON.stringify(e)})`},anthropic:{sdkPackage:`@ai-sdk/anthropic`,sdkImport:`anthropic`,sdkModel:e=>`anthropic(${JSON.stringify(e)})`},google:{sdkPackage:`@ai-sdk/google`,sdkImport:`google`,sdkModel:e=>`google(${JSON.stringify(e)})`},azure:{sdkPackage:`@ai-sdk/azure`,sdkImport:`azure`,sdkModel:e=>`azure(${JSON.stringify(e)}) // your deployment name`},gateway:{sdkPackage:`ai`,sdkImport:`gateway`,sdkModel:e=>`gateway(${JSON.stringify(e)})`}};function Eg(e){return e in Tg?Tg[e]:e===`foundry`||e===`azure-openai`?Tg.azure:Tg.openai}function Dg(){let{workspace:e}=vr(),{askQuestion:t,askTenantEnabled:n,generatedTenantScopeJson:r,askTenantSqlMode:i}=Rr(),[a,o]=(0,M.useState)(`client`),s=(0,M.useMemo)(()=>{if(!e)return``;let o=t.trim()||`Which customers signed up last week?`,s=Eg(e.aiProvider),c=e.schemaPathRelative,l=n&&r?r:null;if(a===`client`){let e=l?`, {\n tenantScope: ${Og(l,2)},\n tenantSqlMode: ${JSON.stringify(i)},\n}`:``,t=s.sdkPackage===`ai`?"the AI Gateway provider ships with `ai`":`${s.sdkPackage} is loaded on first use`;return`// ${Cg(`client`,s.sdkPackage)}
63
+ `})}function S(){d&&i(d,f||void 0)}let C=h&&g&&_.trim();return l===`choose`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`main-hd`,children:(0,R.jsxs)(`div`,{className:`main-title`,children:[(0,R.jsxs)(`h1`,{children:[(0,R.jsx)(fa,{size:18,style:{display:`inline`,marginRight:8}}),`Enable Multi-Tenancy`]}),(0,R.jsx)(`div`,{className:`main-sub`,children:`Configure tenant isolation for your schema`})]})}),u&&(0,R.jsx)(Eh,{status:u}),(0,R.jsx)(`div`,{className:`main-body`,children:(0,R.jsx)(`div`,{className:`stack`,style:{padding:`var(--pad-y) var(--pad-x)`},children:(0,R.jsxs)(`div`,{className:`grid-2`,children:[(0,R.jsx)(`button`,{type:`button`,className:`card`,style:{cursor:`pointer`,textAlign:`left`,border:`2px dashed var(--border)`},disabled:!n||u?.kind===`loading`,onClick:()=>void b(),children:(0,R.jsxs)(`div`,{className:`card-bd`,children:[(0,R.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:12},children:[u?.kind===`loading`?(0,R.jsx)(Vi,{size:20,className:`animate-spin`,style:{color:`var(--red-600)`}}):(0,R.jsx)(ma,{size:20,style:{color:`var(--red-600)`}}),(0,R.jsx)(`h3`,{style:{fontWeight:600},children:`Draft with AI`})]}),(0,R.jsx)(`p`,{className:`muted`,style:{fontSize:13},children:u?.kind===`loading`?`Analyzing your schema...`:`Let AI analyze your schema and propose a complete tenant policy. You will review before saving.`}),!n&&(0,R.jsx)(`p`,{style:{marginTop:8,fontSize:12,color:`var(--red-600)`},children:`Configure an AI provider to use this option.`})]})}),(0,R.jsx)(`button`,{type:`button`,className:`card`,style:{cursor:`pointer`,textAlign:`left`,border:`2px dashed var(--border)`},onClick:()=>c({type:`set_mode`,payload:`manual`}),children:(0,R.jsxs)(`div`,{className:`card-bd`,children:[(0,R.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:12},children:[(0,R.jsx)(ua,{size:20,style:{color:`var(--ink-400)`}}),(0,R.jsx)(`h3`,{style:{fontWeight:600},children:`Configure manually`})]}),(0,R.jsx)(`p`,{className:`muted`,style:{fontSize:13},children:`Pick the tenant root table and column yourself, then review before saving.`})]})})]})})})]}):l===`manual`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`main-hd`,children:[(0,R.jsxs)(`div`,{className:`main-title`,children:[(0,R.jsxs)(`h1`,{children:[(0,R.jsx)(fa,{size:18,style:{display:`inline`,marginRight:8}}),`Manual Configuration`]}),(0,R.jsx)(`div`,{className:`main-sub`,children:`Configure the basics, then review before saving`})]}),(0,R.jsx)(`div`,{className:`main-actions`,children:(0,R.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>c({type:`set_mode`,payload:`choose`}),children:`Back`})})]}),(0,R.jsx)(`div`,{className:`main-body`,children:(0,R.jsxs)(`div`,{className:`stack`,style:{padding:`var(--pad-y) var(--pad-x)`},children:[(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Tenant Root`})}),(0,R.jsx)(`div`,{className:`card-bd`,children:(0,R.jsxs)(`div`,{style:{display:`grid`,gap:16},children:[(0,R.jsx)($,{label:`Root table`,description:`The table whose rows represent tenants.`,children:(0,R.jsxs)(`select`,{className:`h-9 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring`,value:h,onChange:t=>{let n=t.target.value,r=e.find(e=>e.physical.id===n);c({type:`select_root_table`,tableId:n,label:r?.physical.name??``})},children:[(0,R.jsx)(`option`,{value:``,children:`Select a table...`}),e.map(e=>(0,R.jsxs)(`option`,{value:e.physical.id,children:[e.physical.schema,`.`,e.physical.name]},e.physical.id))]})}),h&&(0,R.jsx)($,{label:`Tenant ID column`,description:`The column that uniquely identifies a tenant.`,children:(0,R.jsxs)(`select`,{className:`h-9 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring`,value:g,onChange:e=>c({type:`set_rootTenantIdColumn`,payload:e.target.value}),children:[(0,R.jsx)(`option`,{value:``,children:`Select a column...`}),y.map(e=>(0,R.jsxs)(`option`,{value:e.name,children:[e.name,` (`,e.type,e.primaryKey?`, PK`:``,`)`]},e.id))]})}),(0,R.jsx)($,{label:`Label`,description:`e.g. "Organization" or "Company"`,children:(0,R.jsx)(Rm,{value:_,placeholder:`e.g. Organization`,onChange:e=>c({type:`set_rootLabel`,payload:e.target.value})})})]})})]}),(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Enforcement Mode`})}),(0,R.jsxs)(`div`,{className:`card-bd`,children:[(0,R.jsxs)(`fieldset`,{className:`toggle-seg`,children:[(0,R.jsx)(`button`,{type:`button`,className:m===`strict`?`active`:``,onClick:()=>c({type:`set_enforcement`,payload:`strict`}),children:`Strict`}),(0,R.jsx)(`button`,{type:`button`,className:m===`warn`?`active`:``,onClick:()=>c({type:`set_enforcement`,payload:`warn`}),children:`Warn`})]}),(0,R.jsx)(`p`,{className:`muted tiny`,style:{marginTop:8},children:m===`strict`?`Queries touching unknown (unscoped) tables will be rejected.`:`Queries touching unknown tables will succeed but emit warnings.`})]})]}),(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Global Tables (optional)`})}),(0,R.jsxs)(`div`,{className:`card-bd`,children:[(0,R.jsx)(`p`,{className:`muted`,style:{fontSize:13,marginBottom:8},children:`Global tables are shared across all tenants and never filtered.`}),(0,R.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8},children:e.map(e=>{if(e.physical.id===h)return null;let t=v.includes(e.physical.id);return(0,R.jsxs)(`label`,{className:`chunk-toggle`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:t,onChange:t=>c({type:`toggle_global_table`,tableId:e.physical.id,checked:t.target.checked})}),e.physical.schema,`.`,e.physical.name]},e.physical.id)})})]})]}),(0,R.jsx)(`div`,{style:{display:`flex`,justifyContent:`flex-end`},children:(0,R.jsxs)(`button`,{type:`button`,className:`btn primary`,onClick:x,disabled:!C,children:[(0,R.jsx)(_i,{size:14}),` Review & Confirm`]})})]})})]}):(0,R.jsx)(lg,{tables:e,frontmatter:d,body:f,warnings:p,busy:r,saveStatus:o,onFrontmatterChange:e=>c({type:`set_draftFrontmatter`,payload:e}),onBodyChange:e=>c({type:`set_draftBody`,payload:e}),onConfirm:S,onBack:()=>c({type:`set_mode`,payload:`choose`})})}function lg({tables:e,frontmatter:t,body:n,warnings:r=[],busy:i,saveStatus:a,onFrontmatterChange:o,onBodyChange:s,onConfirm:c,onBack:l,title:u=`Review Tenant Policy`,backLabel:d=`Start Over`,confirmLabel:f=`Confirm & Save`,badgeLabel:p=`Draft`}){function m(e){o({...t,enforcement:e})}function h(e,n){let r=[...t.roots];r[e]={...r[e],label:n},o({...t,roots:r})}function g(e){let n=t.roots.filter((t,n)=>n!==e);n.length!==0&&o({...t,roots:n})}function _(e){let n=(t.hierarchy??[]).filter((t,n)=>n!==e);o({...t,hierarchy:n.length>0?n:void 0})}function v(e){let n=(t.scopedTables??[]).filter((t,n)=>n!==e);o({...t,scopedTables:n.length>0?n:void 0})}function y(e){let n=(t.polymorphicTables??[]).filter((t,n)=>n!==e);o({...t,polymorphicTables:n.length>0?n:void 0})}function b(e){let n=t.globalTables??[],r=n.includes(e)?n.filter(t=>t!==e):[...n,e];o({...t,globalTables:r.length>0?r:void 0})}let x=new Set(t.roots.map(e=>e.id)),S=new Set((t.scopedTables??[]).map(e=>e.id)),C=new Set((t.polymorphicTables??[]).map(e=>e.id)),w=new Set(t.globalTables??[]);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`main-hd`,children:[(0,R.jsxs)(`div`,{className:`main-title`,children:[(0,R.jsxs)(`h1`,{children:[(0,R.jsx)(fa,{size:18,style:{display:`inline`,marginRight:8}}),u]}),(0,R.jsx)(`div`,{className:`main-sub`,children:(0,R.jsx)(Ih,{variant:`warning`,children:p})})]}),(0,R.jsxs)(`div`,{className:`main-actions`,children:[(0,R.jsxs)(`button`,{type:`button`,className:`btn`,onClick:l,children:[(0,R.jsx)(B,{size:14}),` `,d]}),(0,R.jsxs)(`button`,{type:`button`,className:`btn primary`,onClick:c,disabled:i.has(`save-tenant-policy`)||t.roots.length===0,children:[i.has(`save-tenant-policy`)?(0,R.jsx)(Vi,{size:14,className:`animate-spin`}):(0,R.jsx)(oa,{size:14}),f]})]})]}),a&&(0,R.jsx)(Eh,{status:a}),(0,R.jsx)(`div`,{className:`main-body`,children:(0,R.jsxs)(`div`,{className:`stack`,style:{padding:`var(--pad-y) var(--pad-x)`},children:[r.length>0&&(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Withheld from the model`})}),(0,R.jsx)(`div`,{className:`card-bd`,style:{display:`grid`,gap:8},children:r.map(e=>(0,R.jsx)(`pre`,{className:`warning-block`,children:e},e))})]}),(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Enforcement Mode`})}),(0,R.jsxs)(`div`,{className:`card-bd`,children:[(0,R.jsxs)(`fieldset`,{className:`toggle-seg`,children:[(0,R.jsx)(`button`,{type:`button`,className:t.enforcement===`strict`?`active`:``,onClick:()=>m(`strict`),children:`Strict`}),(0,R.jsx)(`button`,{type:`button`,className:t.enforcement===`warn`?`active`:``,onClick:()=>m(`warn`),children:`Warn`})]}),(0,R.jsx)(`p`,{className:`muted tiny`,style:{marginTop:8},children:t.enforcement===`strict`?`Queries touching unknown (unscoped) tables will be rejected.`:`Queries touching unknown tables will succeed but emit warnings.`})]})]}),(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsxs)(`h3`,{children:[`Tenant Roots (`,t.roots.length,`)`]})}),(0,R.jsx)(`div`,{className:`card-bd`,children:(0,R.jsx)(`div`,{style:{display:`grid`,gap:12},children:t.roots.map((e,n)=>(0,R.jsxs)(`div`,{style:{border:`1px solid var(--border)`,borderRadius:`var(--radius)`,padding:12},children:[(0,R.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:8},children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`mono`,style:{fontWeight:600,fontSize:13},children:e.id}),(0,R.jsxs)(`div`,{style:{marginTop:4,display:`flex`,flexWrap:`wrap`,gap:4},children:[(0,R.jsxs)(Ih,{variant:`outline`,children:[`col: `,e.tenantIdColumn]}),e.parent&&(0,R.jsxs)(Ih,{variant:`outline`,children:[`parent: `,e.parent.root,` via `,e.parent.foreignKey]})]})]}),t.roots.length>1&&(0,R.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>g(n),title:`Remove root`,children:`×`})]}),(0,R.jsx)(`div`,{style:{marginTop:8},children:(0,R.jsx)($,{label:`Label`,description:`Human-readable name for this tenant root.`,children:(0,R.jsx)(Rm,{value:e.label,onChange:e=>h(n,e.target.value)})})})]},e.id))})})]}),(t.hierarchy??[]).length>0&&(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsxs)(`h3`,{children:[`Hierarchy Edges (`,t.hierarchy.length,`)`]})}),(0,R.jsx)(`div`,{className:`card-bd`,children:(0,R.jsx)(`div`,{style:{display:`grid`,gap:8},children:t.hierarchy.map((e,t)=>(0,R.jsxs)(`div`,{className:`policy-edge-card`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`code`,{children:e.parent}),(0,R.jsx)(`span`,{className:`muted`,style:{margin:`0 8px`},children:`→`}),(0,R.jsx)(`code`,{children:e.child}),(0,R.jsxs)(`div`,{className:`muted tiny`,style:{marginTop:4},children:[`FK: `,e.foreignKey]})]}),(0,R.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>_(t),title:`Remove`,children:`×`})]},`${e.parent}-${e.child}`))})})]}),(t.scopedTables??[]).length>0&&(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsxs)(`h3`,{children:[`Scoped Tables (`,t.scopedTables.length,`)`]})}),(0,R.jsx)(`div`,{className:`card-bd`,children:(0,R.jsx)(`div`,{style:{display:`grid`,gap:8},children:t.scopedTables.map((e,t)=>(0,R.jsxs)(`div`,{style:{display:`flex`,alignItems:`start`,justifyContent:`space-between`,gap:8,border:`1px solid var(--border)`,borderRadius:`var(--radius)`,padding:12},children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`mono`,style:{fontWeight:600,fontSize:13},children:e.id}),(0,R.jsx)(`div`,{style:{marginTop:4,display:`grid`,gap:4},children:e.scopeThrough.map((e,t)=>(0,R.jsxs)(`p`,{className:`muted tiny`,children:[`via `,(0,R.jsx)(Ih,{variant:`outline`,children:e.root}),` `,`column`in e?(0,R.jsxs)(`span`,{children:[`column `,(0,R.jsx)(`code`,{children:e.column})]}):(0,R.jsxs)(`span`,{children:[`join `,e.join.map(e=>`${e.from} -> ${e.to}`).join(`, `)]})]},t))})]}),(0,R.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>v(t),title:`Remove`,children:`×`})]},e.id))})})]}),(t.polymorphicTables??[]).length>0&&(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsxs)(`h3`,{children:[`Polymorphic Tables (`,t.polymorphicTables.length,`)`]})}),(0,R.jsx)(`div`,{className:`card-bd`,children:(0,R.jsx)(`div`,{style:{display:`grid`,gap:8},children:t.polymorphicTables.map((e,t)=>(0,R.jsxs)(`div`,{style:{display:`flex`,alignItems:`start`,justifyContent:`space-between`,gap:8,border:`1px solid var(--border)`,borderRadius:`var(--radius)`,padding:12},children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`mono`,style:{fontWeight:600,fontSize:13},children:e.id}),(0,R.jsxs)(`p`,{className:`muted tiny`,style:{marginTop:4},children:[`Type: `,(0,R.jsx)(`code`,{children:e.typeColumn}),` · ID: `,(0,R.jsx)(`code`,{children:e.idColumn})]}),(0,R.jsx)(`div`,{style:{marginTop:4,display:`flex`,flexWrap:`wrap`,gap:4},children:Object.entries(e.mapping).map(([e,t])=>(0,R.jsxs)(Ih,{variant:`outline`,children:[e,` → `,t]},e))})]}),(0,R.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>y(t),title:`Remove`,children:`×`})]},e.id))})})]}),(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Global Tables`})}),(0,R.jsxs)(`div`,{className:`card-bd`,children:[(0,R.jsx)(`p`,{className:`muted`,style:{fontSize:13,marginBottom:8},children:`Global tables are shared across all tenants and never filtered.`}),(0,R.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8},children:e.map(e=>x.has(e.physical.id)||S.has(e.physical.id)||C.has(e.physical.id)?null:(0,R.jsxs)(`label`,{className:`chunk-toggle`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:w.has(e.physical.id),onChange:()=>b(e.physical.id)}),e.physical.schema,`.`,e.physical.name]},e.physical.id))})]})]}),(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Documentation (body)`})}),(0,R.jsxs)(`div`,{className:`card-bd`,children:[(0,R.jsx)(`p`,{className:`muted`,style:{fontSize:13,marginBottom:8},children:`Optional markdown body explaining the tenant policy.`}),(0,R.jsx)(zh,{className:`min-h-48 font-mono text-xs`,value:n,onChange:e=>s(e.target.value)})]})]}),(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Frontmatter Preview`})}),(0,R.jsx)(`div`,{className:`card-bd`,children:(0,R.jsx)(`pre`,{className:`plain-block`,style:{fontSize:12},children:JSON.stringify(t,null,2)})})]})]})})]})}function ug({title:e,count:t,children:n,defaultOpen:r=!0}){let[i,a]=(0,M.useState)(r);return(0,R.jsxs)(`section`,{children:[(0,R.jsxs)(`button`,{type:`button`,className:`collapsible-btn`,onClick:()=>a(!i),children:[i?(0,R.jsx)(hi,{size:14}):(0,R.jsx)(_i,{size:14}),e,t==null?``:` (${t})`]}),i&&n]})}function dg({label:e,count:t,variant:n}){return(0,R.jsxs)(`div`,{className:`card`,style:{textAlign:`center`,padding:12,background:n===`primary`?`var(--red-50)`:n===`secondary`?`var(--surface-2)`:`#fef3c7`},children:[(0,R.jsx)(`div`,{style:{fontSize:24,fontWeight:700},children:t}),(0,R.jsx)(`div`,{className:`muted tiny`,children:e})]})}function fg(e){return typeof e==`string`?e:JSON.stringify(e,null,2)}function pg(e){return{schemaId:e.schemaId,enforcement:e.enforcement,roots:mg(e.roots),...e.hierarchy.length>0?{hierarchy:mg(e.hierarchy)}:{},...e.scopedTables.length>0?{scopedTables:mg(e.scopedTables)}:{},...e.polymorphicTables.length>0?{polymorphicTables:mg(e.polymorphicTables)}:{},...e.globalTables.length>0?{globalTables:[...e.globalTables]}:{}}}function mg(e){return structuredClone(e)}function hg({text:e}){return(0,R.jsx)(`p`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-sm text-muted-foreground`,children:e})}var gg=new Intl.NumberFormat;function _g(e){return gg.format(e)}function vg({label:e,value:t}){return t===null?null:(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`dt`,{children:e}),(0,R.jsx)(`dd`,{children:_g(t)})]})}function yg({title:e,usage:t}){return t?(0,R.jsxs)(`section`,{className:`usage-summary`,"aria-label":e,children:[(0,R.jsx)(`h3`,{children:e}),(0,R.jsxs)(`dl`,{className:`usage-grid`,children:[(0,R.jsx)(vg,{label:`Prompt`,value:t.promptTokens}),(0,R.jsx)(vg,{label:`Completion`,value:t.completionTokens}),(0,R.jsx)(vg,{label:`Embeddings`,value:t.embeddingTokens}),t.totalTokens!==null&&(0,R.jsxs)(`div`,{className:`usage-total`,children:[(0,R.jsx)(`dt`,{children:`Total`}),(0,R.jsx)(`dd`,{children:_g(t.totalTokens)})]})]})]}):null}function bg(){let{workspace:e}=vr(),{ragStatus:t,ragMessage:n,ragQuestion:r,setRagQuestion:i,ragK:a,setRagK:o,ragTypes:s,setRagTypes:c,ragResults:l,ragIndexUsage:u,busy:d,allChunkTypes:f,refreshRagStatus:p,handleBuildRag:m,handleQueryRag:h}=jr();if(!e)return null;let g=!t?.hasIndex||t.stale||d.has(`rag-query`);return(0,R.jsxs)(`main`,{className:`main-pane`,children:[(0,R.jsxs)(`div`,{className:`main-hd`,children:[(0,R.jsxs)(`div`,{className:`main-title`,children:[(0,R.jsxs)(`h1`,{children:[(0,R.jsx)(ma,{size:18,style:{display:`inline`,marginRight:8}}),`RAG Index`]}),(0,R.jsx)(`div`,{className:`main-sub`,children:`Retrieval-augmented generation index and query debugger`})]}),(0,R.jsxs)(`div`,{className:`main-actions`,children:[(0,R.jsxs)(`button`,{type:`button`,className:`btn`,onClick:()=>void p(),children:[(0,R.jsx)(ta,{size:14}),` Refresh`]}),(0,R.jsxs)(`button`,{type:`button`,className:`btn primary`,onClick:()=>void m(),disabled:d.has(`rag-build`),children:[d.has(`rag-build`)?(0,R.jsx)(Vi,{size:14,className:`animate-spin`}):(0,R.jsx)(di,{size:14}),`Build Index`]})]})]}),(0,R.jsx)(`div`,{className:`main-body`,children:(0,R.jsxs)(`div`,{className:`stack`,style:{padding:`var(--pad-y) var(--pad-x)`},children:[n&&(0,R.jsx)(Dh,{status:n}),t?(0,R.jsxs)(`div`,{className:`grid-4`,children:[(0,R.jsxs)(`div`,{className:`card stat-card`,children:[(0,R.jsx)(`div`,{className:`stat-label`,children:`Chunks`}),(0,R.jsx)(`div`,{className:`stat-num`,children:hr(t.chunksTotal)})]}),(0,R.jsxs)(`div`,{className:`card stat-card`,children:[(0,R.jsx)(`div`,{className:`stat-label`,children:`Indexed`}),(0,R.jsx)(`div`,{className:`stat-num`,children:hr(t.chunksIndexed)})]}),(0,R.jsxs)(`div`,{className:`card stat-card`,children:[(0,R.jsx)(`div`,{className:`stat-label`,children:`Sensitive excluded`}),(0,R.jsx)(`div`,{className:`stat-num`,children:t.sensitiveExcluded})]}),(0,R.jsxs)(`div`,{className:`card stat-card`,children:[(0,R.jsx)(`div`,{className:`stat-label`,children:`Sensitive included`}),(0,R.jsx)(`div`,{className:`stat-num`,children:t.sensitiveIncluded})]})]}):(0,R.jsx)(hg,{text:`RAG status is unavailable.`}),t&&(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Index Details`})}),(0,R.jsxs)(`div`,{className:`card-bd`,children:[(0,R.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8,marginBottom:12},children:[(0,R.jsx)(Ih,{variant:t.hasIndex?`secondary`:`warning`,children:t.hasIndex?`Index present`:`No index`}),(0,R.jsx)(Ih,{variant:t.stale?`warning`:`secondary`,children:t.stale?`Stale`:`Fresh`}),(0,R.jsx)(Ih,{variant:t.embedder.configured?`secondary`:`warning`,children:t.embedder.label})]}),(0,R.jsxs)(`div`,{style:{display:`grid`,gap:4,fontSize:12,color:`var(--ink-400)`},children:[(0,R.jsxs)(`span`,{children:[`Expected: `,t.expectedEmbedderId]}),(0,R.jsxs)(`span`,{children:[`Indexed: `,t.embedder.indexedId??`none`]}),(0,R.jsxs)(`span`,{children:[`Dimensions: `,t.dimensions??`model default`,` / expected `,t.expectedDimensions??`model default`]}),(0,R.jsxs)(`span`,{children:[`Updated: `,t.updatedAt??`never`]}),(0,R.jsxs)(`span`,{children:[`Store: `,t.store.kind]})]}),(0,R.jsx)(`div`,{className:`bar`,style:{marginTop:14},children:(0,R.jsx)(`i`,{style:{width:t.chunksTotal>0?`${Math.round(t.chunksIndexed/t.chunksTotal*100)}%`:`0%`}})})]})]}),(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Query Debugger`})}),(0,R.jsx)(`div`,{className:`card-bd`,children:(0,R.jsxs)(`div`,{style:{display:`grid`,gap:12},children:[(0,R.jsx)($,{label:`Question`,children:(0,R.jsx)(zh,{value:r,onChange:e=>i(e.target.value),placeholder:`Which customers placed orders last month?`})}),(0,R.jsxs)(`div`,{style:{display:`grid`,gap:12,gridTemplateColumns:`120px 1fr`},children:[(0,R.jsx)($,{label:`Top K`,children:(0,R.jsx)(Rm,{min:1,max:25,type:`number`,value:a,onChange:e=>o(Number(e.target.value))})}),(0,R.jsxs)(`div`,{style:{display:`grid`,gap:6},children:[(0,R.jsx)(`span`,{className:`muted`,style:{fontSize:12,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.04em`},children:`Chunk types`}),(0,R.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8},children:f.map(e=>(0,R.jsxs)(`label`,{className:`chunk-toggle`,children:[(0,R.jsx)(`input`,{checked:s.includes(e),type:`checkbox`,onChange:t=>{t.target.checked?c([...s,e]):c(s.filter(t=>t!==e))}}),e]},e))})]})]}),(0,R.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:g,onClick:()=>void h(),children:[d.has(`rag-query`)?(0,R.jsx)(Vi,{size:14,className:`animate-spin`}):(0,R.jsx)(ca,{size:14}),`Query RAG`]}),(0,R.jsx)(yg,{title:`Last Index Usage`,usage:u}),(0,R.jsx)(yg,{title:`Last Query Usage`,usage:l?.usage??null})]})})]}),(0,R.jsx)(xg,{chunks:l?.results??[],emptyText:`No chunks retrieved yet.`})]})})]})}function xg({chunks:e,emptyText:t}){return(0,R.jsxs)(`section`,{className:`card`,children:[(0,R.jsx)(`div`,{className:`card-hd`,children:(0,R.jsx)(`h3`,{children:`Retrieved Chunks`})}),(0,R.jsx)(`div`,{className:`card-bd`,children:e.length>0?(0,R.jsx)(`div`,{style:{display:`grid`,gap:12},children:e.map(e=>(0,R.jsxs)(`article`,{className:`chunk-card`,children:[(0,R.jsxs)(`div`,{style:{display:`flex`,alignItems:`start`,justifyContent:`space-between`,gap:12},children:[(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:8},children:[(0,R.jsx)(`h4`,{style:{fontSize:13,fontWeight:600,wordBreak:`break-all`},children:e.id}),(0,R.jsx)(Ih,{variant:`outline`,children:e.type}),e.sensitive&&(0,R.jsx)(Ih,{variant:`danger`,children:`sensitive`})]}),(0,R.jsxs)(`p`,{className:`muted tiny`,style:{marginTop:4,wordBreak:`break-all`},children:[`refs: `,e.refs.length>0?e.refs.join(`, `):`none`]})]}),(0,R.jsx)(Ih,{variant:`secondary`,children:e.score.toFixed(3)})]}),(0,R.jsx)(`pre`,{className:`chunk-text`,children:e.text})]},e.id))}):(0,R.jsx)(hg,{text:t})})]})}function Sg({value:e}){let[t,n]=(0,M.useState)(!1),r=(0,M.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})},[e]);return(0,R.jsxs)(Lm,{variant:`ghost`,size:`sm`,onClick:r,children:[t?(0,R.jsx)(pi,{className:`h-3.5 w-3.5 text-green-500`}):(0,R.jsx)(Di,{className:`h-3.5 w-3.5`}),t?`Copied`:`Copy`]})}function Cg(e,t){return`npm install ${[...new Set([...e===`client`?[`@askdb/client`,`@askdb/core`,`@askdb/config`,`ai`]:[`@askdb/core`,`ai`],t])].join(` `)}`}var wg={border:0,padding:0,margin:0},Tg={openai:{sdkPackage:`@ai-sdk/openai`,sdkImport:`openai`,sdkModel:e=>`openai(${JSON.stringify(e)})`},anthropic:{sdkPackage:`@ai-sdk/anthropic`,sdkImport:`anthropic`,sdkModel:e=>`anthropic(${JSON.stringify(e)})`},google:{sdkPackage:`@ai-sdk/google`,sdkImport:`google`,sdkModel:e=>`google(${JSON.stringify(e)})`},azure:{sdkPackage:`@ai-sdk/azure`,sdkImport:`azure`,sdkModel:e=>`azure(${JSON.stringify(e)}) // your deployment name`},gateway:{sdkPackage:`ai`,sdkImport:`gateway`,sdkModel:e=>`gateway(${JSON.stringify(e)})`}};function Eg(e){return e in Tg?Tg[e]:e===`foundry`||e===`azure-openai`?Tg.azure:Tg.openai}function Dg(){let{workspace:e}=vr(),{askQuestion:t,askTenantEnabled:n,generatedTenantScopeJson:r,askTenantSqlMode:i}=Rr(),[a,o]=(0,M.useState)(`client`),s=(0,M.useMemo)(()=>{if(!e)return``;let o=t.trim()||`Which customers signed up last week?`,s=Eg(e.aiProvider),c=e.schemaPathRelative,l=n&&r?r:null;if(a===`client`){let e=l?`, {\n tenantScope: ${Og(l,2)},\n tenantSqlMode: ${JSON.stringify(i)},\n}`:``,t=s.sdkPackage===`ai`?"the AI Gateway provider ships with `ai`":`${s.sdkPackage} is loaded on first use`;return`// ${Cg(`client`,s.sdkPackage)}
64
64
  import { createAskDb } from "@askdb/client";
65
65
  import { bootstrapAskDbEnv, getAskDbRuntimeConfig } from "@askdb/config";
66
66