@jacshuo/onyx 1.3.1 → 1.4.1

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.
Files changed (50) hide show
  1. package/dist/DataDisplay/CodeBlock.cjs +2 -2
  2. package/dist/DataDisplay/CodeBlock.js +2 -2
  3. package/dist/DataDisplay/List.cjs +1 -1
  4. package/dist/DataDisplay/List.js +1 -1
  5. package/dist/DataDisplay/Table.cjs +1 -1
  6. package/dist/DataDisplay/Table.js +1 -1
  7. package/dist/DataDisplay/Tree.cjs +1 -1
  8. package/dist/DataDisplay/Tree.js +1 -1
  9. package/dist/DataDisplay/index.cjs +2 -2
  10. package/dist/DataDisplay/index.js +2 -2
  11. package/dist/Extras/CinePlayer.cjs +1 -1
  12. package/dist/Extras/CinePlayer.js +1 -1
  13. package/dist/Extras/FileExplorer.cjs +9 -2
  14. package/dist/Extras/FileExplorer.js +9 -2
  15. package/dist/Extras/MiniPlayer.cjs +2 -2
  16. package/dist/Extras/MiniPlayer.js +2 -2
  17. package/dist/Extras/index.cjs +11 -4
  18. package/dist/Extras/index.js +11 -4
  19. package/dist/Feedback/Alert.cjs +1 -1
  20. package/dist/Feedback/Alert.js +1 -1
  21. package/dist/Feedback/ProgressBar.cjs +1 -1
  22. package/dist/Feedback/ProgressBar.js +1 -1
  23. package/dist/Feedback/Spin.cjs +1 -1
  24. package/dist/Feedback/Spin.js +1 -1
  25. package/dist/Feedback/index.cjs +2 -2
  26. package/dist/Feedback/index.js +2 -2
  27. package/dist/Forms/Form.cjs +1 -1
  28. package/dist/Forms/Form.js +1 -1
  29. package/dist/Forms/index.cjs +1 -1
  30. package/dist/Forms/index.js +1 -1
  31. package/dist/Navigation/Header.cjs +1 -1
  32. package/dist/Navigation/Header.js +1 -1
  33. package/dist/Navigation/SideNav.cjs +1 -1
  34. package/dist/Navigation/SideNav.js +1 -1
  35. package/dist/Navigation/index.cjs +2 -2
  36. package/dist/Navigation/index.js +2 -2
  37. package/dist/Primitives/TextBox.cjs +1 -1
  38. package/dist/Primitives/TextBox.js +1 -1
  39. package/dist/Primitives/index.cjs +1 -1
  40. package/dist/Primitives/index.js +1 -1
  41. package/dist/_tsup-dts-rollup.d.cts +89 -1
  42. package/dist/_tsup-dts-rollup.d.ts +89 -1
  43. package/dist/index.cjs +12 -5
  44. package/dist/index.js +12 -5
  45. package/dist/styles/Feedback/Spin.css +1 -1
  46. package/dist/styles/base.css +96 -15
  47. package/dist/styles.css +104 -19
  48. package/dist/theme.cjs +1 -1
  49. package/dist/theme.js +1 -1
  50. package/package.json +2 -1
@@ -1,2 +1,2 @@
1
- 'use strict';var react=require('react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),classVarianceAuthority=require('class-variance-authority'),jsxRuntime=require('react/jsx-runtime');function y(...o){return tailwindMerge.twMerge(clsx.clsx(o))}classVarianceAuthority.cva("w-full text-left text-sm",{variants:{intent:{default:"",striped:"[&_tbody_tr:nth-child(even)]:bg-primary-50 dark:[&_tbody_tr:nth-child(even)]:bg-primary-800/30",bordered:"[&_th]:border [&_td]:border [&_th]:border-primary-200 [&_td]:border-primary-200 dark:[&_th]:border-primary-700 dark:[&_td]:border-primary-700"},density:{compact:"[&_th]:px-2 [&_th]:py-1 [&_td]:px-2 [&_td]:py-1",default:"",relaxed:"[&_th]:px-6 [&_th]:py-5 [&_td]:px-6 [&_td]:py-5"}},defaultVariants:{intent:"default",density:"default"}});classVarianceAuthority.cva("text-sm text-primary-700 dark:text-primary-300",{variants:{intent:{default:"space-y-1",bordered:"divide-y divide-primary-200 rounded-lg border border-primary-200 dark:divide-primary-700 dark:border-primary-700 [&>li]:px-4 [&>li]:py-2",hover:"[&>li]:rounded-md [&>li]:px-3 [&>li]:py-2 [&>li]:transition-colors [&>li:hover]:bg-primary-50 dark:[&>li:hover]:bg-primary-800/50"}},defaultVariants:{intent:"default"}});classVarianceAuthority.cva("group flex w-full items-center gap-1.5 text-left [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3 [&_svg]:w-3",md:"py-1.5 text-sm [&_svg]:h-3.5 [&_svg]:w-3.5",lg:"py-2 text-base [&_svg]:h-4 [&_svg]:w-4"}},defaultVariants:{size:"md"}});classVarianceAuthority.cva("flex cursor-pointer items-center gap-1 rounded transition-colors [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",md:"py-1 text-sm [&_svg]:h-4 [&_svg]:w-4",lg:"py-1.5 text-base [&_svg]:h-5 [&_svg]:w-5"}},defaultVariants:{size:"md"}});var f=classVarianceAuthority.cva("overflow-x-auto rounded-lg font-mono [&_pre]:m-0 [&_pre]:p-4 [&_code]:bg-transparent",{variants:{size:{sm:"text-xs",md:"text-sm",lg:"text-base"}},defaultVariants:{size:"md"}});var j={name:"onyx-css-vars",type:"dark",settings:[{settings:{foreground:"var(--color-syntax-plain)",background:"var(--color-syntax-bg)"}},{scope:["comment","punctuation.definition.comment"],settings:{foreground:"var(--color-syntax-comment)",fontStyle:"italic"}},{scope:["keyword","keyword.control","keyword.operator.new","keyword.operator.expression","storage.type","storage.modifier"],settings:{foreground:"var(--color-syntax-keyword)"}},{scope:["string","string.quoted","string.template"],settings:{foreground:"var(--color-syntax-string)"}},{scope:["entity.name.function","support.function","meta.function-call"],settings:{foreground:"var(--color-syntax-function)"}},{scope:["variable","variable.other","variable.parameter","meta.definition.variable"],settings:{foreground:"var(--color-syntax-variable)"}},{scope:["constant.numeric","constant.language"],settings:{foreground:"var(--color-syntax-number)"}},{scope:["keyword.operator","keyword.operator.assignment","keyword.operator.comparison","keyword.operator.arithmetic"],settings:{foreground:"var(--color-syntax-operator)"}},{scope:["entity.name.tag","punctuation.definition.tag","support.class.component"],settings:{foreground:"var(--color-syntax-tag)"}},{scope:["entity.other.attribute-name","meta.tag.attributes"],settings:{foreground:"var(--color-syntax-attr)"}},{scope:["punctuation","meta.brace","punctuation.definition.block","punctuation.separator","punctuation.terminator"],settings:{foreground:"var(--color-syntax-punctuation)"}},{scope:["entity.name.type","support.type","support.class","entity.other.inherited-class"],settings:{foreground:"var(--color-syntax-type)"}}]},D={typescript:()=>import('@shikijs/langs/typescript'),javascript:()=>import('@shikijs/langs/javascript'),tsx:()=>import('@shikijs/langs/tsx'),jsx:()=>import('@shikijs/langs/jsx'),html:()=>import('@shikijs/langs/html'),css:()=>import('@shikijs/langs/css'),json:()=>import('@shikijs/langs/json'),markdown:()=>import('@shikijs/langs/markdown'),python:()=>import('@shikijs/langs/python'),rust:()=>import('@shikijs/langs/rust'),go:()=>import('@shikijs/langs/go'),java:()=>import('@shikijs/langs/java'),c:()=>import('@shikijs/langs/c'),cpp:()=>import('@shikijs/langs/cpp'),csharp:()=>import('@shikijs/langs/csharp'),vue:()=>import('@shikijs/langs/vue'),xml:()=>import('@shikijs/langs/xml'),yaml:()=>import('@shikijs/langs/yaml'),sql:()=>import('@shikijs/langs/sql'),bash:()=>import('@shikijs/langs/bash'),shell:()=>import('@shikijs/langs/shell')},x=null,T=new Set;function q(){return x||(x=Promise.all([import('shiki/core'),import('shiki/engine/javascript')]).then(([{createHighlighterCore:o},{createJavaScriptRegexEngine:r}])=>o({themes:[j],langs:[],engine:r()}))),x}async function F(o,r,i){let l=await q();if(r&&!T.has(r)){let a=D[r];if(a)try{let p=await a();await l.loadLanguage(p.default??p),T.add(r);}catch{r="text";}else r="text";}let n=l.codeToHtml(o,{lang:r||"text",theme:"onyx-css-vars"});if(n=n.replace(/(<pre [^>]*style=")/,"$1line-height:1.7;tab-size:2;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;"),i){let a=0;n=n.replace(/<span class="line">/g,()=>(a++,`<span class="line"><span class="line-number" data-line="${a}"></span>`));}return n}function te({code:o,language:r="text",lineNumbers:i=false,editable:l=false,onCodeChange:n,size:a,className:p,...b}){let[c,V]=react.useState(""),u=react.useRef(null),_=react.useRef(null),g=react.useRef(null);react.useEffect(()=>{let e=false;return F(o,r,l?false:i).then(t=>{e||V(t);}),()=>{e=true;}},[o,r,i,l]);let H=react.useCallback(()=>{let e=_.current,t=g.current?.querySelector("pre"),d=u.current?.querySelector("[data-gutter]");e&&t&&(t.scrollTop=e.scrollTop,t.scrollLeft=e.scrollLeft),e&&d&&(d.scrollTop=e.scrollTop);},[]),M=react.useCallback(e=>{n?.(e.target.value);},[n]),S=react.useCallback(e=>{if(e.key==="Tab"){e.preventDefault();let t=e.currentTarget,d=t.selectionStart,R=t.selectionEnd,z=t.value.substring(0,d)+" "+t.value.substring(R);n?.(z),requestAnimationFrame(()=>{t.selectionStart=t.selectionEnd=d+2;});}},[n]),C=i&&"[&_.line-number]:inline-block [&_.line-number]:w-8 [&_.line-number]:mr-4 [&_.line-number]:text-right [&_.line-number]:text-secondary-400 [&_.line-number]:select-none [&_.line-number]:before:content-[attr(data-line)]",k="ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",w=1.7,E=o.split(`
2
- `).length;return l?jsxRuntime.jsxs("div",{ref:u,className:y(f({size:a}),"flex border border-primary-200 dark:border-primary-700",p),style:{background:"var(--color-syntax-bg)"},...b,children:[i&&jsxRuntime.jsx("div",{"data-gutter":true,"aria-hidden":true,className:"shrink-0 select-none overflow-hidden py-4 pl-3 pr-1 text-right text-secondary-400",style:{fontFamily:k,lineHeight:w,width:"3rem"},children:Array.from({length:E},(e,t)=>jsxRuntime.jsx("div",{children:t+1},t))}),jsxRuntime.jsxs("div",{className:"relative min-w-0 flex-1",children:[jsxRuntime.jsx("textarea",{ref:_,value:o,onChange:M,onScroll:H,onKeyDown:S,spellCheck:false,autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",className:"relative z-2 m-0 block h-full w-full resize-none overflow-auto whitespace-pre border-none bg-transparent p-4 text-transparent caret-primary-600 outline-none dark:caret-primary-400",style:{fontFamily:k,lineHeight:w,tabSize:2,minHeight:"6rem"}}),jsxRuntime.jsx("div",{ref:g,"aria-hidden":true,className:"pointer-events-none absolute inset-0 z-1 overflow-hidden [&_pre]:m-0 [&_pre]:h-full [&_pre]:overflow-hidden [&_pre]:p-4 [&_code]:bg-transparent",dangerouslySetInnerHTML:c?{__html:c}:void 0})]})]}):jsxRuntime.jsx("div",{ref:u,className:y(f({size:a}),"border border-primary-200 dark:border-primary-700",C,p),...b,children:jsxRuntime.jsx("div",{ref:g,className:"[&_pre]:m-0 [&_pre]:p-4",dangerouslySetInnerHTML:c?{__html:c}:void 0,children:c?void 0:jsxRuntime.jsx("pre",{className:"m-0 p-4",style:{background:"var(--color-syntax-bg)"},children:jsxRuntime.jsx("code",{children:o})})})})}exports.CodeBlock=te;
1
+ 'use strict';var react=require('react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),classVarianceAuthority=require('class-variance-authority'),jsxRuntime=require('react/jsx-runtime');function y(...o){return tailwindMerge.twMerge(clsx.clsx(o))}classVarianceAuthority.cva("w-full text-left text-sm",{variants:{intent:{default:"",striped:"[&_tbody_tr:nth-child(even)]:bg-primary-50 dark:[&_tbody_tr:nth-child(even)]:bg-primary-800/30",bordered:"[&_th]:border [&_td]:border [&_th]:border-primary-200 [&_td]:border-primary-200 dark:[&_th]:border-primary-700 dark:[&_td]:border-primary-700"},density:{compact:"[&_th]:px-2 [&_th]:py-1 [&_td]:px-2 [&_td]:py-1",default:"",relaxed:"[&_th]:px-6 [&_th]:py-5 [&_td]:px-6 [&_td]:py-5"}},defaultVariants:{intent:"default",density:"default"}});classVarianceAuthority.cva("text-sm text-primary-700 dark:text-primary-300",{variants:{intent:{default:"space-y-1",bordered:"divide-y divide-primary-200 rounded-lg border border-primary-200 dark:divide-primary-700 dark:border-primary-700 [&>li]:px-4 [&>li]:py-2",hover:"[&>li]:rounded-md [&>li]:px-3 [&>li]:py-2 [&>li]:transition-colors [&>li:hover]:bg-primary-50 dark:[&>li:hover]:bg-primary-800/50"}},defaultVariants:{intent:"default"}});classVarianceAuthority.cva("group flex w-full items-center gap-1.5 text-left [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3 [&_svg]:w-3",md:"py-1.5 text-sm [&_svg]:h-3.5 [&_svg]:w-3.5",lg:"py-2 text-base [&_svg]:h-4 [&_svg]:w-4"}},defaultVariants:{size:"md"}});classVarianceAuthority.cva("flex cursor-pointer items-center gap-1 rounded transition-colors [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",md:"py-1 text-sm [&_svg]:h-4 [&_svg]:w-4",lg:"py-1.5 text-base [&_svg]:h-5 [&_svg]:w-5"}},defaultVariants:{size:"md"}});var f=classVarianceAuthority.cva("overflow-x-auto rounded-lg font-mono [background:var(--color-syntax-bg)] [&_pre]:m-0 [&_pre]:p-4 [&_code]:bg-transparent",{variants:{size:{sm:"text-xs",md:"text-sm",lg:"text-base"}},defaultVariants:{size:"md"}});var j={name:"onyx-css-vars",type:"dark",settings:[{settings:{foreground:"var(--color-syntax-plain)",background:"var(--color-syntax-bg)"}},{scope:["comment","punctuation.definition.comment"],settings:{foreground:"var(--color-syntax-comment)",fontStyle:"italic"}},{scope:["keyword","keyword.control","keyword.operator.new","keyword.operator.expression","storage.type","storage.modifier"],settings:{foreground:"var(--color-syntax-keyword)"}},{scope:["string","string.quoted","string.template"],settings:{foreground:"var(--color-syntax-string)"}},{scope:["entity.name.function","support.function","meta.function-call"],settings:{foreground:"var(--color-syntax-function)"}},{scope:["variable","variable.other","variable.parameter","meta.definition.variable"],settings:{foreground:"var(--color-syntax-variable)"}},{scope:["constant.numeric","constant.language"],settings:{foreground:"var(--color-syntax-number)"}},{scope:["keyword.operator","keyword.operator.assignment","keyword.operator.comparison","keyword.operator.arithmetic"],settings:{foreground:"var(--color-syntax-operator)"}},{scope:["entity.name.tag","punctuation.definition.tag","support.class.component"],settings:{foreground:"var(--color-syntax-tag)"}},{scope:["entity.other.attribute-name","meta.tag.attributes"],settings:{foreground:"var(--color-syntax-attr)"}},{scope:["punctuation","meta.brace","punctuation.definition.block","punctuation.separator","punctuation.terminator"],settings:{foreground:"var(--color-syntax-punctuation)"}},{scope:["entity.name.type","support.type","support.class","entity.other.inherited-class"],settings:{foreground:"var(--color-syntax-type)"}}]},D={typescript:()=>import('@shikijs/langs/typescript'),javascript:()=>import('@shikijs/langs/javascript'),tsx:()=>import('@shikijs/langs/tsx'),jsx:()=>import('@shikijs/langs/jsx'),html:()=>import('@shikijs/langs/html'),css:()=>import('@shikijs/langs/css'),json:()=>import('@shikijs/langs/json'),markdown:()=>import('@shikijs/langs/markdown'),python:()=>import('@shikijs/langs/python'),rust:()=>import('@shikijs/langs/rust'),go:()=>import('@shikijs/langs/go'),java:()=>import('@shikijs/langs/java'),c:()=>import('@shikijs/langs/c'),cpp:()=>import('@shikijs/langs/cpp'),csharp:()=>import('@shikijs/langs/csharp'),vue:()=>import('@shikijs/langs/vue'),xml:()=>import('@shikijs/langs/xml'),yaml:()=>import('@shikijs/langs/yaml'),sql:()=>import('@shikijs/langs/sql'),bash:()=>import('@shikijs/langs/bash'),shell:()=>import('@shikijs/langs/shell')},x=null,T=new Set;function q(){return x||(x=Promise.all([import('shiki/core'),import('shiki/engine/javascript')]).then(([{createHighlighterCore:o},{createJavaScriptRegexEngine:r}])=>o({themes:[j],langs:[],engine:r()}))),x}async function F(o,r,i){let l=await q();if(r&&!T.has(r)){let a=D[r];if(a)try{let p=await a();await l.loadLanguage(p.default??p),T.add(r);}catch{r="text";}else r="text";}let n=l.codeToHtml(o,{lang:r||"text",theme:"onyx-css-vars"});if(n=n.replace(/(<pre [^>]*style=")/,"$1line-height:1.7;tab-size:2;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;"),i){let a=0;n=n.replace(/<span class="line">/g,()=>(a++,`<span class="line"><span class="line-number" data-line="${a}"></span>`));}return n}function te({code:o,language:r="text",lineNumbers:i=false,editable:l=false,onCodeChange:n,size:a,className:p,...b}){let[c,V]=react.useState(""),u=react.useRef(null),_=react.useRef(null),g=react.useRef(null);react.useEffect(()=>{let e=false;return F(o,r,l?false:i).then(t=>{e||V(t);}),()=>{e=true;}},[o,r,i,l]);let H=react.useCallback(()=>{let e=_.current,t=g.current?.querySelector("pre"),d=u.current?.querySelector("[data-gutter]");e&&t&&(t.scrollTop=e.scrollTop,t.scrollLeft=e.scrollLeft),e&&d&&(d.scrollTop=e.scrollTop);},[]),M=react.useCallback(e=>{n?.(e.target.value);},[n]),S=react.useCallback(e=>{if(e.key==="Tab"){e.preventDefault();let t=e.currentTarget,d=t.selectionStart,R=t.selectionEnd,z=t.value.substring(0,d)+" "+t.value.substring(R);n?.(z),requestAnimationFrame(()=>{t.selectionStart=t.selectionEnd=d+2;});}},[n]),C=i&&"[&_.line-number]:inline-block [&_.line-number]:w-8 [&_.line-number]:mr-4 [&_.line-number]:text-right [&_.line-number]:text-secondary-400 [&_.line-number]:select-none [&_.line-number]:before:content-[attr(data-line)]",k="ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",w=1.7,E=o.split(`
2
+ `).length;return l?jsxRuntime.jsxs("div",{ref:u,className:y(f({size:a}),"flex border border-primary-200 dark:border-primary-700",p),style:{background:"var(--color-syntax-bg)"},...b,children:[i&&jsxRuntime.jsx("div",{"data-gutter":true,"aria-hidden":true,className:"shrink-0 select-none overflow-hidden py-4 pl-3 pr-1 text-right text-secondary-400",style:{fontFamily:k,lineHeight:w,width:"3rem"},children:Array.from({length:E},(e,t)=>jsxRuntime.jsx("div",{children:t+1},t))}),jsxRuntime.jsxs("div",{className:"relative min-w-0 flex-1",children:[jsxRuntime.jsx("textarea",{ref:_,value:o,onChange:M,onScroll:H,onKeyDown:S,spellCheck:false,autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",className:"relative z-2 m-0 block h-full w-full resize-none overflow-auto whitespace-pre border-none bg-transparent p-4 text-transparent caret-primary-600 outline-none dark:caret-primary-400",style:{fontFamily:k,lineHeight:w,tabSize:2,minHeight:"6rem"}}),jsxRuntime.jsx("div",{ref:g,"aria-hidden":true,className:"pointer-events-none absolute inset-0 z-1 overflow-hidden [&_pre]:m-0 [&_pre]:h-full [&_pre]:overflow-hidden [&_pre]:p-4 [&_code]:bg-transparent",dangerouslySetInnerHTML:c?{__html:c}:void 0})]})]}):jsxRuntime.jsx("div",{ref:u,className:y(f({size:a}),"border border-primary-200 dark:border-primary-700",C,p),style:{background:"var(--color-syntax-bg)"},...b,children:jsxRuntime.jsx("div",{ref:g,className:"[&_pre]:m-0 [&_pre]:p-4",dangerouslySetInnerHTML:c?{__html:c}:void 0,children:c?void 0:jsxRuntime.jsx("pre",{className:"m-0 p-4",style:{background:"var(--color-syntax-bg)"},children:jsxRuntime.jsx("code",{children:o})})})})}exports.CodeBlock=te;
@@ -1,2 +1,2 @@
1
- import {useState,useRef,useEffect,useCallback}from'react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {cva}from'class-variance-authority';import {jsxs,jsx}from'react/jsx-runtime';function y(...o){return twMerge(clsx(o))}cva("w-full text-left text-sm",{variants:{intent:{default:"",striped:"[&_tbody_tr:nth-child(even)]:bg-primary-50 dark:[&_tbody_tr:nth-child(even)]:bg-primary-800/30",bordered:"[&_th]:border [&_td]:border [&_th]:border-primary-200 [&_td]:border-primary-200 dark:[&_th]:border-primary-700 dark:[&_td]:border-primary-700"},density:{compact:"[&_th]:px-2 [&_th]:py-1 [&_td]:px-2 [&_td]:py-1",default:"",relaxed:"[&_th]:px-6 [&_th]:py-5 [&_td]:px-6 [&_td]:py-5"}},defaultVariants:{intent:"default",density:"default"}});cva("text-sm text-primary-700 dark:text-primary-300",{variants:{intent:{default:"space-y-1",bordered:"divide-y divide-primary-200 rounded-lg border border-primary-200 dark:divide-primary-700 dark:border-primary-700 [&>li]:px-4 [&>li]:py-2",hover:"[&>li]:rounded-md [&>li]:px-3 [&>li]:py-2 [&>li]:transition-colors [&>li:hover]:bg-primary-50 dark:[&>li:hover]:bg-primary-800/50"}},defaultVariants:{intent:"default"}});cva("group flex w-full items-center gap-1.5 text-left [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3 [&_svg]:w-3",md:"py-1.5 text-sm [&_svg]:h-3.5 [&_svg]:w-3.5",lg:"py-2 text-base [&_svg]:h-4 [&_svg]:w-4"}},defaultVariants:{size:"md"}});cva("flex cursor-pointer items-center gap-1 rounded transition-colors [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",md:"py-1 text-sm [&_svg]:h-4 [&_svg]:w-4",lg:"py-1.5 text-base [&_svg]:h-5 [&_svg]:w-5"}},defaultVariants:{size:"md"}});var f=cva("overflow-x-auto rounded-lg font-mono [&_pre]:m-0 [&_pre]:p-4 [&_code]:bg-transparent",{variants:{size:{sm:"text-xs",md:"text-sm",lg:"text-base"}},defaultVariants:{size:"md"}});var j={name:"onyx-css-vars",type:"dark",settings:[{settings:{foreground:"var(--color-syntax-plain)",background:"var(--color-syntax-bg)"}},{scope:["comment","punctuation.definition.comment"],settings:{foreground:"var(--color-syntax-comment)",fontStyle:"italic"}},{scope:["keyword","keyword.control","keyword.operator.new","keyword.operator.expression","storage.type","storage.modifier"],settings:{foreground:"var(--color-syntax-keyword)"}},{scope:["string","string.quoted","string.template"],settings:{foreground:"var(--color-syntax-string)"}},{scope:["entity.name.function","support.function","meta.function-call"],settings:{foreground:"var(--color-syntax-function)"}},{scope:["variable","variable.other","variable.parameter","meta.definition.variable"],settings:{foreground:"var(--color-syntax-variable)"}},{scope:["constant.numeric","constant.language"],settings:{foreground:"var(--color-syntax-number)"}},{scope:["keyword.operator","keyword.operator.assignment","keyword.operator.comparison","keyword.operator.arithmetic"],settings:{foreground:"var(--color-syntax-operator)"}},{scope:["entity.name.tag","punctuation.definition.tag","support.class.component"],settings:{foreground:"var(--color-syntax-tag)"}},{scope:["entity.other.attribute-name","meta.tag.attributes"],settings:{foreground:"var(--color-syntax-attr)"}},{scope:["punctuation","meta.brace","punctuation.definition.block","punctuation.separator","punctuation.terminator"],settings:{foreground:"var(--color-syntax-punctuation)"}},{scope:["entity.name.type","support.type","support.class","entity.other.inherited-class"],settings:{foreground:"var(--color-syntax-type)"}}]},D={typescript:()=>import('@shikijs/langs/typescript'),javascript:()=>import('@shikijs/langs/javascript'),tsx:()=>import('@shikijs/langs/tsx'),jsx:()=>import('@shikijs/langs/jsx'),html:()=>import('@shikijs/langs/html'),css:()=>import('@shikijs/langs/css'),json:()=>import('@shikijs/langs/json'),markdown:()=>import('@shikijs/langs/markdown'),python:()=>import('@shikijs/langs/python'),rust:()=>import('@shikijs/langs/rust'),go:()=>import('@shikijs/langs/go'),java:()=>import('@shikijs/langs/java'),c:()=>import('@shikijs/langs/c'),cpp:()=>import('@shikijs/langs/cpp'),csharp:()=>import('@shikijs/langs/csharp'),vue:()=>import('@shikijs/langs/vue'),xml:()=>import('@shikijs/langs/xml'),yaml:()=>import('@shikijs/langs/yaml'),sql:()=>import('@shikijs/langs/sql'),bash:()=>import('@shikijs/langs/bash'),shell:()=>import('@shikijs/langs/shell')},x=null,T=new Set;function q(){return x||(x=Promise.all([import('shiki/core'),import('shiki/engine/javascript')]).then(([{createHighlighterCore:o},{createJavaScriptRegexEngine:r}])=>o({themes:[j],langs:[],engine:r()}))),x}async function F(o,r,i){let l=await q();if(r&&!T.has(r)){let a=D[r];if(a)try{let p=await a();await l.loadLanguage(p.default??p),T.add(r);}catch{r="text";}else r="text";}let n=l.codeToHtml(o,{lang:r||"text",theme:"onyx-css-vars"});if(n=n.replace(/(<pre [^>]*style=")/,"$1line-height:1.7;tab-size:2;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;"),i){let a=0;n=n.replace(/<span class="line">/g,()=>(a++,`<span class="line"><span class="line-number" data-line="${a}"></span>`));}return n}function te({code:o,language:r="text",lineNumbers:i=false,editable:l=false,onCodeChange:n,size:a,className:p,...b}){let[c,V]=useState(""),u=useRef(null),_=useRef(null),g=useRef(null);useEffect(()=>{let e=false;return F(o,r,l?false:i).then(t=>{e||V(t);}),()=>{e=true;}},[o,r,i,l]);let H=useCallback(()=>{let e=_.current,t=g.current?.querySelector("pre"),d=u.current?.querySelector("[data-gutter]");e&&t&&(t.scrollTop=e.scrollTop,t.scrollLeft=e.scrollLeft),e&&d&&(d.scrollTop=e.scrollTop);},[]),M=useCallback(e=>{n?.(e.target.value);},[n]),S=useCallback(e=>{if(e.key==="Tab"){e.preventDefault();let t=e.currentTarget,d=t.selectionStart,R=t.selectionEnd,z=t.value.substring(0,d)+" "+t.value.substring(R);n?.(z),requestAnimationFrame(()=>{t.selectionStart=t.selectionEnd=d+2;});}},[n]),C=i&&"[&_.line-number]:inline-block [&_.line-number]:w-8 [&_.line-number]:mr-4 [&_.line-number]:text-right [&_.line-number]:text-secondary-400 [&_.line-number]:select-none [&_.line-number]:before:content-[attr(data-line)]",k="ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",w=1.7,E=o.split(`
2
- `).length;return l?jsxs("div",{ref:u,className:y(f({size:a}),"flex border border-primary-200 dark:border-primary-700",p),style:{background:"var(--color-syntax-bg)"},...b,children:[i&&jsx("div",{"data-gutter":true,"aria-hidden":true,className:"shrink-0 select-none overflow-hidden py-4 pl-3 pr-1 text-right text-secondary-400",style:{fontFamily:k,lineHeight:w,width:"3rem"},children:Array.from({length:E},(e,t)=>jsx("div",{children:t+1},t))}),jsxs("div",{className:"relative min-w-0 flex-1",children:[jsx("textarea",{ref:_,value:o,onChange:M,onScroll:H,onKeyDown:S,spellCheck:false,autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",className:"relative z-2 m-0 block h-full w-full resize-none overflow-auto whitespace-pre border-none bg-transparent p-4 text-transparent caret-primary-600 outline-none dark:caret-primary-400",style:{fontFamily:k,lineHeight:w,tabSize:2,minHeight:"6rem"}}),jsx("div",{ref:g,"aria-hidden":true,className:"pointer-events-none absolute inset-0 z-1 overflow-hidden [&_pre]:m-0 [&_pre]:h-full [&_pre]:overflow-hidden [&_pre]:p-4 [&_code]:bg-transparent",dangerouslySetInnerHTML:c?{__html:c}:void 0})]})]}):jsx("div",{ref:u,className:y(f({size:a}),"border border-primary-200 dark:border-primary-700",C,p),...b,children:jsx("div",{ref:g,className:"[&_pre]:m-0 [&_pre]:p-4",dangerouslySetInnerHTML:c?{__html:c}:void 0,children:c?void 0:jsx("pre",{className:"m-0 p-4",style:{background:"var(--color-syntax-bg)"},children:jsx("code",{children:o})})})})}export{te as CodeBlock};
1
+ import {useState,useRef,useEffect,useCallback}from'react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {cva}from'class-variance-authority';import {jsxs,jsx}from'react/jsx-runtime';function y(...o){return twMerge(clsx(o))}cva("w-full text-left text-sm",{variants:{intent:{default:"",striped:"[&_tbody_tr:nth-child(even)]:bg-primary-50 dark:[&_tbody_tr:nth-child(even)]:bg-primary-800/30",bordered:"[&_th]:border [&_td]:border [&_th]:border-primary-200 [&_td]:border-primary-200 dark:[&_th]:border-primary-700 dark:[&_td]:border-primary-700"},density:{compact:"[&_th]:px-2 [&_th]:py-1 [&_td]:px-2 [&_td]:py-1",default:"",relaxed:"[&_th]:px-6 [&_th]:py-5 [&_td]:px-6 [&_td]:py-5"}},defaultVariants:{intent:"default",density:"default"}});cva("text-sm text-primary-700 dark:text-primary-300",{variants:{intent:{default:"space-y-1",bordered:"divide-y divide-primary-200 rounded-lg border border-primary-200 dark:divide-primary-700 dark:border-primary-700 [&>li]:px-4 [&>li]:py-2",hover:"[&>li]:rounded-md [&>li]:px-3 [&>li]:py-2 [&>li]:transition-colors [&>li:hover]:bg-primary-50 dark:[&>li:hover]:bg-primary-800/50"}},defaultVariants:{intent:"default"}});cva("group flex w-full items-center gap-1.5 text-left [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3 [&_svg]:w-3",md:"py-1.5 text-sm [&_svg]:h-3.5 [&_svg]:w-3.5",lg:"py-2 text-base [&_svg]:h-4 [&_svg]:w-4"}},defaultVariants:{size:"md"}});cva("flex cursor-pointer items-center gap-1 rounded transition-colors [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",md:"py-1 text-sm [&_svg]:h-4 [&_svg]:w-4",lg:"py-1.5 text-base [&_svg]:h-5 [&_svg]:w-5"}},defaultVariants:{size:"md"}});var f=cva("overflow-x-auto rounded-lg font-mono [background:var(--color-syntax-bg)] [&_pre]:m-0 [&_pre]:p-4 [&_code]:bg-transparent",{variants:{size:{sm:"text-xs",md:"text-sm",lg:"text-base"}},defaultVariants:{size:"md"}});var j={name:"onyx-css-vars",type:"dark",settings:[{settings:{foreground:"var(--color-syntax-plain)",background:"var(--color-syntax-bg)"}},{scope:["comment","punctuation.definition.comment"],settings:{foreground:"var(--color-syntax-comment)",fontStyle:"italic"}},{scope:["keyword","keyword.control","keyword.operator.new","keyword.operator.expression","storage.type","storage.modifier"],settings:{foreground:"var(--color-syntax-keyword)"}},{scope:["string","string.quoted","string.template"],settings:{foreground:"var(--color-syntax-string)"}},{scope:["entity.name.function","support.function","meta.function-call"],settings:{foreground:"var(--color-syntax-function)"}},{scope:["variable","variable.other","variable.parameter","meta.definition.variable"],settings:{foreground:"var(--color-syntax-variable)"}},{scope:["constant.numeric","constant.language"],settings:{foreground:"var(--color-syntax-number)"}},{scope:["keyword.operator","keyword.operator.assignment","keyword.operator.comparison","keyword.operator.arithmetic"],settings:{foreground:"var(--color-syntax-operator)"}},{scope:["entity.name.tag","punctuation.definition.tag","support.class.component"],settings:{foreground:"var(--color-syntax-tag)"}},{scope:["entity.other.attribute-name","meta.tag.attributes"],settings:{foreground:"var(--color-syntax-attr)"}},{scope:["punctuation","meta.brace","punctuation.definition.block","punctuation.separator","punctuation.terminator"],settings:{foreground:"var(--color-syntax-punctuation)"}},{scope:["entity.name.type","support.type","support.class","entity.other.inherited-class"],settings:{foreground:"var(--color-syntax-type)"}}]},D={typescript:()=>import('@shikijs/langs/typescript'),javascript:()=>import('@shikijs/langs/javascript'),tsx:()=>import('@shikijs/langs/tsx'),jsx:()=>import('@shikijs/langs/jsx'),html:()=>import('@shikijs/langs/html'),css:()=>import('@shikijs/langs/css'),json:()=>import('@shikijs/langs/json'),markdown:()=>import('@shikijs/langs/markdown'),python:()=>import('@shikijs/langs/python'),rust:()=>import('@shikijs/langs/rust'),go:()=>import('@shikijs/langs/go'),java:()=>import('@shikijs/langs/java'),c:()=>import('@shikijs/langs/c'),cpp:()=>import('@shikijs/langs/cpp'),csharp:()=>import('@shikijs/langs/csharp'),vue:()=>import('@shikijs/langs/vue'),xml:()=>import('@shikijs/langs/xml'),yaml:()=>import('@shikijs/langs/yaml'),sql:()=>import('@shikijs/langs/sql'),bash:()=>import('@shikijs/langs/bash'),shell:()=>import('@shikijs/langs/shell')},x=null,T=new Set;function q(){return x||(x=Promise.all([import('shiki/core'),import('shiki/engine/javascript')]).then(([{createHighlighterCore:o},{createJavaScriptRegexEngine:r}])=>o({themes:[j],langs:[],engine:r()}))),x}async function F(o,r,i){let l=await q();if(r&&!T.has(r)){let a=D[r];if(a)try{let p=await a();await l.loadLanguage(p.default??p),T.add(r);}catch{r="text";}else r="text";}let n=l.codeToHtml(o,{lang:r||"text",theme:"onyx-css-vars"});if(n=n.replace(/(<pre [^>]*style=")/,"$1line-height:1.7;tab-size:2;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;"),i){let a=0;n=n.replace(/<span class="line">/g,()=>(a++,`<span class="line"><span class="line-number" data-line="${a}"></span>`));}return n}function te({code:o,language:r="text",lineNumbers:i=false,editable:l=false,onCodeChange:n,size:a,className:p,...b}){let[c,V]=useState(""),u=useRef(null),_=useRef(null),g=useRef(null);useEffect(()=>{let e=false;return F(o,r,l?false:i).then(t=>{e||V(t);}),()=>{e=true;}},[o,r,i,l]);let H=useCallback(()=>{let e=_.current,t=g.current?.querySelector("pre"),d=u.current?.querySelector("[data-gutter]");e&&t&&(t.scrollTop=e.scrollTop,t.scrollLeft=e.scrollLeft),e&&d&&(d.scrollTop=e.scrollTop);},[]),M=useCallback(e=>{n?.(e.target.value);},[n]),S=useCallback(e=>{if(e.key==="Tab"){e.preventDefault();let t=e.currentTarget,d=t.selectionStart,R=t.selectionEnd,z=t.value.substring(0,d)+" "+t.value.substring(R);n?.(z),requestAnimationFrame(()=>{t.selectionStart=t.selectionEnd=d+2;});}},[n]),C=i&&"[&_.line-number]:inline-block [&_.line-number]:w-8 [&_.line-number]:mr-4 [&_.line-number]:text-right [&_.line-number]:text-secondary-400 [&_.line-number]:select-none [&_.line-number]:before:content-[attr(data-line)]",k="ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",w=1.7,E=o.split(`
2
+ `).length;return l?jsxs("div",{ref:u,className:y(f({size:a}),"flex border border-primary-200 dark:border-primary-700",p),style:{background:"var(--color-syntax-bg)"},...b,children:[i&&jsx("div",{"data-gutter":true,"aria-hidden":true,className:"shrink-0 select-none overflow-hidden py-4 pl-3 pr-1 text-right text-secondary-400",style:{fontFamily:k,lineHeight:w,width:"3rem"},children:Array.from({length:E},(e,t)=>jsx("div",{children:t+1},t))}),jsxs("div",{className:"relative min-w-0 flex-1",children:[jsx("textarea",{ref:_,value:o,onChange:M,onScroll:H,onKeyDown:S,spellCheck:false,autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",className:"relative z-2 m-0 block h-full w-full resize-none overflow-auto whitespace-pre border-none bg-transparent p-4 text-transparent caret-primary-600 outline-none dark:caret-primary-400",style:{fontFamily:k,lineHeight:w,tabSize:2,minHeight:"6rem"}}),jsx("div",{ref:g,"aria-hidden":true,className:"pointer-events-none absolute inset-0 z-1 overflow-hidden [&_pre]:m-0 [&_pre]:h-full [&_pre]:overflow-hidden [&_pre]:p-4 [&_code]:bg-transparent",dangerouslySetInnerHTML:c?{__html:c}:void 0})]})]}):jsx("div",{ref:u,className:y(f({size:a}),"border border-primary-200 dark:border-primary-700",C,p),style:{background:"var(--color-syntax-bg)"},...b,children:jsx("div",{ref:g,className:"[&_pre]:m-0 [&_pre]:p-4",dangerouslySetInnerHTML:c?{__html:c}:void 0,children:c?void 0:jsx("pre",{className:"m-0 p-4",style:{background:"var(--color-syntax-bg)"},children:jsx("code",{children:o})})})})}export{te as CodeBlock};
@@ -1 +1 @@
1
- 'use strict';var react=require('react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),classVarianceAuthority=require('class-variance-authority'),jsxRuntime=require('react/jsx-runtime');function o(...t){return tailwindMerge.twMerge(clsx.clsx(t))}classVarianceAuthority.cva("w-full text-left text-sm",{variants:{intent:{default:"",striped:"[&_tbody_tr:nth-child(even)]:bg-primary-50 dark:[&_tbody_tr:nth-child(even)]:bg-primary-800/30",bordered:"[&_th]:border [&_td]:border [&_th]:border-primary-200 [&_td]:border-primary-200 dark:[&_th]:border-primary-700 dark:[&_td]:border-primary-700"},density:{compact:"[&_th]:px-2 [&_th]:py-1 [&_td]:px-2 [&_td]:py-1",default:"",relaxed:"[&_th]:px-6 [&_th]:py-5 [&_td]:px-6 [&_td]:py-5"}},defaultVariants:{intent:"default",density:"default"}});var n=classVarianceAuthority.cva("text-sm text-primary-700 dark:text-primary-300",{variants:{intent:{default:"space-y-1",bordered:"divide-y divide-primary-200 rounded-lg border border-primary-200 dark:divide-primary-700 dark:border-primary-700 [&>li]:px-4 [&>li]:py-2",hover:"[&>li]:rounded-md [&>li]:px-3 [&>li]:py-2 [&>li]:transition-colors [&>li:hover]:bg-primary-50 dark:[&>li:hover]:bg-primary-800/50"}},defaultVariants:{intent:"default"}}),p=classVarianceAuthority.cva("group flex w-full items-center gap-1.5 text-left [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3 [&_svg]:w-3",md:"py-1.5 text-sm [&_svg]:h-3.5 [&_svg]:w-3.5",lg:"py-2 text-base [&_svg]:h-4 [&_svg]:w-4"}},defaultVariants:{size:"md"}});classVarianceAuthority.cva("flex cursor-pointer items-center gap-1 rounded transition-colors [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",md:"py-1 text-sm [&_svg]:h-4 [&_svg]:w-4",lg:"py-1.5 text-base [&_svg]:h-5 [&_svg]:w-5"}},defaultVariants:{size:"md"}});classVarianceAuthority.cva("overflow-x-auto rounded-lg font-mono [&_pre]:m-0 [&_pre]:p-4 [&_code]:bg-transparent",{variants:{size:{sm:"text-xs",md:"text-sm",lg:"text-base"}},defaultVariants:{size:"md"}});var d=react.createContext({size:"md"});function P({intent:t,size:i="md",className:s,...a}){return jsxRuntime.jsx(d.Provider,{value:{size:i},children:jsxRuntime.jsx("ul",{className:o(n({intent:t}),s),...a})})}function I({actions:t,className:i,children:s,...a}){let{size:m}=react.useContext(d);return jsxRuntime.jsxs("li",{className:o(p({size:m}),i),...a,children:[jsxRuntime.jsx("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:s}),t&&jsxRuntime.jsx("span",{className:"ml-auto flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100 [@media(hover:none)]:opacity-100 [@media(hover:none)]:[&>button]:min-h-(--row-action-touch-min) [@media(hover:none)]:[&>button]:min-w-(--row-action-touch-min) [@media(hover:none)]:[&>button]:flex [@media(hover:none)]:[&>button]:items-center [@media(hover:none)]:[&>button]:justify-center",children:t})]})}exports.List=P;exports.ListItem=I;
1
+ 'use strict';var react=require('react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),classVarianceAuthority=require('class-variance-authority'),jsxRuntime=require('react/jsx-runtime');function o(...t){return tailwindMerge.twMerge(clsx.clsx(t))}classVarianceAuthority.cva("w-full text-left text-sm",{variants:{intent:{default:"",striped:"[&_tbody_tr:nth-child(even)]:bg-primary-50 dark:[&_tbody_tr:nth-child(even)]:bg-primary-800/30",bordered:"[&_th]:border [&_td]:border [&_th]:border-primary-200 [&_td]:border-primary-200 dark:[&_th]:border-primary-700 dark:[&_td]:border-primary-700"},density:{compact:"[&_th]:px-2 [&_th]:py-1 [&_td]:px-2 [&_td]:py-1",default:"",relaxed:"[&_th]:px-6 [&_th]:py-5 [&_td]:px-6 [&_td]:py-5"}},defaultVariants:{intent:"default",density:"default"}});var n=classVarianceAuthority.cva("text-sm text-primary-700 dark:text-primary-300",{variants:{intent:{default:"space-y-1",bordered:"divide-y divide-primary-200 rounded-lg border border-primary-200 dark:divide-primary-700 dark:border-primary-700 [&>li]:px-4 [&>li]:py-2",hover:"[&>li]:rounded-md [&>li]:px-3 [&>li]:py-2 [&>li]:transition-colors [&>li:hover]:bg-primary-50 dark:[&>li:hover]:bg-primary-800/50"}},defaultVariants:{intent:"default"}}),d=classVarianceAuthority.cva("group flex w-full items-center gap-1.5 text-left [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3 [&_svg]:w-3",md:"py-1.5 text-sm [&_svg]:h-3.5 [&_svg]:w-3.5",lg:"py-2 text-base [&_svg]:h-4 [&_svg]:w-4"}},defaultVariants:{size:"md"}});classVarianceAuthority.cva("flex cursor-pointer items-center gap-1 rounded transition-colors [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",md:"py-1 text-sm [&_svg]:h-4 [&_svg]:w-4",lg:"py-1.5 text-base [&_svg]:h-5 [&_svg]:w-5"}},defaultVariants:{size:"md"}});classVarianceAuthority.cva("overflow-x-auto rounded-lg font-mono [background:var(--color-syntax-bg)] [&_pre]:m-0 [&_pre]:p-4 [&_code]:bg-transparent",{variants:{size:{sm:"text-xs",md:"text-sm",lg:"text-base"}},defaultVariants:{size:"md"}});var p=react.createContext({size:"md"});function P({intent:t,size:i="md",className:a,...s}){return jsxRuntime.jsx(p.Provider,{value:{size:i},children:jsxRuntime.jsx("ul",{className:o(n({intent:t}),a),...s})})}function I({actions:t,className:i,children:a,...s}){let{size:m}=react.useContext(p);return jsxRuntime.jsxs("li",{className:o(d({size:m}),i),...s,children:[jsxRuntime.jsx("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:a}),t&&jsxRuntime.jsx("span",{className:"ml-auto flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100 [@media(hover:none)]:opacity-100 [@media(hover:none)]:[&>button]:min-h-(--row-action-touch-min) [@media(hover:none)]:[&>button]:min-w-(--row-action-touch-min) [@media(hover:none)]:[&>button]:flex [@media(hover:none)]:[&>button]:items-center [@media(hover:none)]:[&>button]:justify-center",children:t})]})}exports.List=P;exports.ListItem=I;
@@ -1 +1 @@
1
- import {createContext,useContext}from'react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {cva}from'class-variance-authority';import {jsx,jsxs}from'react/jsx-runtime';function o(...t){return twMerge(clsx(t))}cva("w-full text-left text-sm",{variants:{intent:{default:"",striped:"[&_tbody_tr:nth-child(even)]:bg-primary-50 dark:[&_tbody_tr:nth-child(even)]:bg-primary-800/30",bordered:"[&_th]:border [&_td]:border [&_th]:border-primary-200 [&_td]:border-primary-200 dark:[&_th]:border-primary-700 dark:[&_td]:border-primary-700"},density:{compact:"[&_th]:px-2 [&_th]:py-1 [&_td]:px-2 [&_td]:py-1",default:"",relaxed:"[&_th]:px-6 [&_th]:py-5 [&_td]:px-6 [&_td]:py-5"}},defaultVariants:{intent:"default",density:"default"}});var n=cva("text-sm text-primary-700 dark:text-primary-300",{variants:{intent:{default:"space-y-1",bordered:"divide-y divide-primary-200 rounded-lg border border-primary-200 dark:divide-primary-700 dark:border-primary-700 [&>li]:px-4 [&>li]:py-2",hover:"[&>li]:rounded-md [&>li]:px-3 [&>li]:py-2 [&>li]:transition-colors [&>li:hover]:bg-primary-50 dark:[&>li:hover]:bg-primary-800/50"}},defaultVariants:{intent:"default"}}),p=cva("group flex w-full items-center gap-1.5 text-left [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3 [&_svg]:w-3",md:"py-1.5 text-sm [&_svg]:h-3.5 [&_svg]:w-3.5",lg:"py-2 text-base [&_svg]:h-4 [&_svg]:w-4"}},defaultVariants:{size:"md"}});cva("flex cursor-pointer items-center gap-1 rounded transition-colors [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",md:"py-1 text-sm [&_svg]:h-4 [&_svg]:w-4",lg:"py-1.5 text-base [&_svg]:h-5 [&_svg]:w-5"}},defaultVariants:{size:"md"}});cva("overflow-x-auto rounded-lg font-mono [&_pre]:m-0 [&_pre]:p-4 [&_code]:bg-transparent",{variants:{size:{sm:"text-xs",md:"text-sm",lg:"text-base"}},defaultVariants:{size:"md"}});var d=createContext({size:"md"});function P({intent:t,size:i="md",className:s,...a}){return jsx(d.Provider,{value:{size:i},children:jsx("ul",{className:o(n({intent:t}),s),...a})})}function I({actions:t,className:i,children:s,...a}){let{size:m}=useContext(d);return jsxs("li",{className:o(p({size:m}),i),...a,children:[jsx("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:s}),t&&jsx("span",{className:"ml-auto flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100 [@media(hover:none)]:opacity-100 [@media(hover:none)]:[&>button]:min-h-(--row-action-touch-min) [@media(hover:none)]:[&>button]:min-w-(--row-action-touch-min) [@media(hover:none)]:[&>button]:flex [@media(hover:none)]:[&>button]:items-center [@media(hover:none)]:[&>button]:justify-center",children:t})]})}export{P as List,I as ListItem};
1
+ import {createContext,useContext}from'react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {cva}from'class-variance-authority';import {jsx,jsxs}from'react/jsx-runtime';function o(...t){return twMerge(clsx(t))}cva("w-full text-left text-sm",{variants:{intent:{default:"",striped:"[&_tbody_tr:nth-child(even)]:bg-primary-50 dark:[&_tbody_tr:nth-child(even)]:bg-primary-800/30",bordered:"[&_th]:border [&_td]:border [&_th]:border-primary-200 [&_td]:border-primary-200 dark:[&_th]:border-primary-700 dark:[&_td]:border-primary-700"},density:{compact:"[&_th]:px-2 [&_th]:py-1 [&_td]:px-2 [&_td]:py-1",default:"",relaxed:"[&_th]:px-6 [&_th]:py-5 [&_td]:px-6 [&_td]:py-5"}},defaultVariants:{intent:"default",density:"default"}});var n=cva("text-sm text-primary-700 dark:text-primary-300",{variants:{intent:{default:"space-y-1",bordered:"divide-y divide-primary-200 rounded-lg border border-primary-200 dark:divide-primary-700 dark:border-primary-700 [&>li]:px-4 [&>li]:py-2",hover:"[&>li]:rounded-md [&>li]:px-3 [&>li]:py-2 [&>li]:transition-colors [&>li:hover]:bg-primary-50 dark:[&>li:hover]:bg-primary-800/50"}},defaultVariants:{intent:"default"}}),d=cva("group flex w-full items-center gap-1.5 text-left [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3 [&_svg]:w-3",md:"py-1.5 text-sm [&_svg]:h-3.5 [&_svg]:w-3.5",lg:"py-2 text-base [&_svg]:h-4 [&_svg]:w-4"}},defaultVariants:{size:"md"}});cva("flex cursor-pointer items-center gap-1 rounded transition-colors [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",md:"py-1 text-sm [&_svg]:h-4 [&_svg]:w-4",lg:"py-1.5 text-base [&_svg]:h-5 [&_svg]:w-5"}},defaultVariants:{size:"md"}});cva("overflow-x-auto rounded-lg font-mono [background:var(--color-syntax-bg)] [&_pre]:m-0 [&_pre]:p-4 [&_code]:bg-transparent",{variants:{size:{sm:"text-xs",md:"text-sm",lg:"text-base"}},defaultVariants:{size:"md"}});var p=createContext({size:"md"});function P({intent:t,size:i="md",className:a,...s}){return jsx(p.Provider,{value:{size:i},children:jsx("ul",{className:o(n({intent:t}),a),...s})})}function I({actions:t,className:i,children:a,...s}){let{size:m}=useContext(p);return jsxs("li",{className:o(d({size:m}),i),...s,children:[jsx("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:a}),t&&jsx("span",{className:"ml-auto flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100 [@media(hover:none)]:opacity-100 [@media(hover:none)]:[&>button]:min-h-(--row-action-touch-min) [@media(hover:none)]:[&>button]:min-w-(--row-action-touch-min) [@media(hover:none)]:[&>button]:flex [@media(hover:none)]:[&>button]:items-center [@media(hover:none)]:[&>button]:justify-center",children:t})]})}export{P as List,I as ListItem};
@@ -1 +1 @@
1
- 'use strict';var react=require('react'),lucideReact=require('lucide-react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),classVarianceAuthority=require('class-variance-authority'),jsxRuntime=require('react/jsx-runtime');function m(...r){return tailwindMerge.twMerge(clsx.clsx(r))}var O=classVarianceAuthority.cva("w-full text-left text-sm",{variants:{intent:{default:"",striped:"[&_tbody_tr:nth-child(even)]:bg-primary-50 dark:[&_tbody_tr:nth-child(even)]:bg-primary-800/30",bordered:"[&_th]:border [&_td]:border [&_th]:border-primary-200 [&_td]:border-primary-200 dark:[&_th]:border-primary-700 dark:[&_td]:border-primary-700"},density:{compact:"[&_th]:px-2 [&_th]:py-1 [&_td]:px-2 [&_td]:py-1",default:"",relaxed:"[&_th]:px-6 [&_th]:py-5 [&_td]:px-6 [&_td]:py-5"}},defaultVariants:{intent:"default",density:"default"}});classVarianceAuthority.cva("text-sm text-primary-700 dark:text-primary-300",{variants:{intent:{default:"space-y-1",bordered:"divide-y divide-primary-200 rounded-lg border border-primary-200 dark:divide-primary-700 dark:border-primary-700 [&>li]:px-4 [&>li]:py-2",hover:"[&>li]:rounded-md [&>li]:px-3 [&>li]:py-2 [&>li]:transition-colors [&>li:hover]:bg-primary-50 dark:[&>li:hover]:bg-primary-800/50"}},defaultVariants:{intent:"default"}});classVarianceAuthority.cva("group flex w-full items-center gap-1.5 text-left [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3 [&_svg]:w-3",md:"py-1.5 text-sm [&_svg]:h-3.5 [&_svg]:w-3.5",lg:"py-2 text-base [&_svg]:h-4 [&_svg]:w-4"}},defaultVariants:{size:"md"}});classVarianceAuthority.cva("flex cursor-pointer items-center gap-1 rounded transition-colors [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",md:"py-1 text-sm [&_svg]:h-4 [&_svg]:w-4",lg:"py-1.5 text-base [&_svg]:h-5 [&_svg]:w-5"}},defaultVariants:{size:"md"}});classVarianceAuthority.cva("overflow-x-auto rounded-lg font-mono [&_pre]:m-0 [&_pre]:p-4 [&_code]:bg-transparent",{variants:{size:{sm:"text-xs",md:"text-sm",lg:"text-base"}},defaultVariants:{size:"md"}});function W({intent:r,density:a,className:d,...f}){return jsxRuntime.jsx("div",{className:"w-full overflow-auto",children:jsxRuntime.jsx("table",{className:m(O({intent:r,density:a}),d),...f})})}function Y({className:r,...a}){return jsxRuntime.jsx("thead",{className:m("bg-primary-50 text-primary-600 dark:bg-primary-800/50 dark:text-primary-400",r),...a})}function Z({className:r,...a}){return jsxRuntime.jsx("tbody",{className:m("[&_tr:last-child]:border-0",r),...a})}function U({className:r,...a}){return jsxRuntime.jsx("tr",{className:m("border-primary-200 hover:bg-primary-50/50 dark:border-primary-700 dark:hover:bg-primary-800/30 border-b transition-colors",r),...a})}function V({className:r,...a}){return jsxRuntime.jsx("th",{className:m("px-4 py-3 text-left text-xs font-semibold tracking-wider uppercase",r),...a})}function H({className:r,...a}){return jsxRuntime.jsx("td",{className:m("text-primary-700 dark:text-primary-300 px-4 py-3",r),...a})}function ee({icon:r,text:a="No data",className:d}){return jsxRuntime.jsxs("div",{className:m("flex flex-col items-center justify-center gap-3 py-16 text-primary-400 dark:text-primary-500",d),children:[r??jsxRuntime.jsx(lucideReact.Inbox,{className:"h-12 w-12 stroke-[1.2]"}),jsxRuntime.jsx("span",{className:"text-sm",children:a})]})}var Q={sm:"hidden sm:table-cell",md:"hidden md:table-cell",lg:"hidden lg:table-cell"};function Be({columns:r,data:a,sort:d,onSortChange:f,defaultSort:T=null,rowKey:x,rowActions:l,intent:h,density:X,className:C,empty:L}){let[$,A]=react.useState(T),y=d??$,K=react.useCallback(n=>{let g=y?.column===n?y.direction==="asc"?{column:n,direction:"desc"}:null:{column:n,direction:"asc"};f?f(g):A(g);},[y,f]),B=react.useMemo(()=>{if(!y)return a;let n=r.find(P=>P.key===y.column);if(!n)return a;let g=n.compareFn??((P,j)=>{let p=n.cell(P),k=n.cell(j);return p==null&&k==null?0:p==null?-1:k==null?1:typeof p=="number"&&typeof k=="number"?p-k:String(p).localeCompare(String(k))}),u=[...a].sort(g);return y.direction==="desc"?u.reverse():u},[a,y,r]);return jsxRuntime.jsxs(W,{intent:h,density:X,className:C,children:[jsxRuntime.jsx(Y,{children:jsxRuntime.jsxs(U,{children:[r.map(n=>{let g=n.sortable!==false,u=y?.column===n.key;return jsxRuntime.jsx(V,{className:m(g&&"cursor-pointer select-none",n.headerClassName,n.hideBelow&&Q[n.hideBelow]),onClick:g?()=>K(n.key):void 0,"aria-sort":u?y.direction==="asc"?"ascending":"descending":void 0,children:jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.header,g&&jsxRuntime.jsx(te,{active:u,direction:u?y.direction:null})]})},n.key)}),l&&jsxRuntime.jsx(V,{className:"w-20 text-right",children:"Actions"})]})}),jsxRuntime.jsx(Z,{children:B.length===0?jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:r.length+(l?1:0),children:jsxRuntime.jsx(ee,{...L})})}):B.map((n,g)=>jsxRuntime.jsxs(U,{children:[r.map(u=>jsxRuntime.jsx(H,{className:m(u.cellClassName,u.hideBelow&&Q[u.hideBelow]),children:u.cell(n)},u.key)),l&&jsxRuntime.jsx(H,{className:"text-right",children:jsxRuntime.jsx("span",{className:"inline-flex items-center gap-1",children:l(n)})})]},x?x(n,g):g))})]})}function ke({value:r,onCommit:a,onCancel:d}){let[f,T]=react.useState(r),x=react.useRef(null);react.useEffect(()=>{x.current?.focus(),x.current?.select();},[]);let l=()=>a(f);return jsxRuntime.jsxs("span",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("input",{ref:x,type:"text",value:f,onChange:h=>T(h.target.value),onKeyDown:h=>{h.key==="Enter"&&l(),h.key==="Escape"&&d();},"aria-label":"Edit cell",className:"min-w-0 flex-1 rounded border border-primary-400 bg-white px-1.5 py-0.5 text-sm outline-none focus:ring-1 focus:ring-primary-400 dark:border-primary-600 dark:bg-secondary-800"}),jsxRuntime.jsx("button",{type:"button",onClick:l,className:"text-success-600 hover:text-success-700 dark:text-success-400","aria-label":"Confirm",children:jsxRuntime.jsx(lucideReact.Check,{className:"h-3.5 w-3.5"})}),jsxRuntime.jsx("button",{type:"button",onClick:d,className:"text-danger-500 hover:text-danger-600 dark:text-danger-400","aria-label":"Cancel",children:jsxRuntime.jsx(lucideReact.X,{className:"h-3.5 w-3.5"})})]})}function Ie({columns:r,data:a,rowKey:d,sort:f,onSortChange:T,defaultSort:x=null,selectionMode:l="none",selected:h,onSelectionChange:X,editable:C=false,onCellEdit:L,toolbar:$=false,onAdd:A,onDelete:y,rowActions:K,intent:B,density:n,className:g,empty:u}){let[P,j]=react.useState(x),p=f??P,k=react.useCallback(t=>{let s=p?.column===t?p.direction==="asc"?{column:t,direction:"desc"}:null:{column:t,direction:"asc"};T?T(s):j(s);},[p,T]),I=react.useMemo(()=>{if(!p)return a;let t=r.find(v=>v.key===p.column);if(!t)return a;let s=t.compareFn??((v,i)=>{let N=t.cell(v),w=t.cell(i);return N==null&&w==null?0:N==null?-1:w==null?1:typeof N=="number"&&typeof w=="number"?N-w:String(N).localeCompare(String(w))}),o=[...a].sort(s);return p.direction==="desc"?o.reverse():o},[a,p,r]),[re,ae]=react.useState([]),c=h??re,R=X??ae,M=react.useMemo(()=>I.map((t,s)=>d(t,s)),[I,d]),z=l==="multiple"&&M.length>0&&M.every(t=>c.includes(t)),ne=l==="multiple"&&c.length>0&&!z,q=react.useCallback(t=>{l==="single"?R(c.includes(t)?[]:[t]):l==="multiple"&&R(c.includes(t)?c.filter(s=>s!==t):[...c,t]);},[l,c,R]),se=react.useCallback(()=>{R(z?[]:M);},[z,M,R]),[J,F]=react.useState(null),le=react.useCallback((t,s,o)=>{C&&o!==false&&F({rowKey:t,colKey:s});},[C]),oe=react.useCallback((t,s,o)=>{L?.(t,s,o),F(null);},[L]);return jsxRuntime.jsxs("div",{className:"space-y-2",children:[$&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[A&&jsxRuntime.jsxs("button",{type:"button",onClick:A,className:"inline-flex items-center gap-1.5 rounded-md border border-secondary-300 bg-white px-3 py-1.5 text-sm font-medium text-secondary-700 transition-colors hover:bg-secondary-50 dark:border-secondary-600 dark:bg-secondary-800 dark:text-secondary-300 dark:hover:bg-secondary-700",children:[jsxRuntime.jsx(lucideReact.Plus,{className:"h-3.5 w-3.5"})," Add"]}),y&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>y(c),disabled:c.length===0,className:"inline-flex items-center gap-1.5 rounded-md border border-secondary-300 bg-white px-3 py-1.5 text-sm font-medium text-danger-600 transition-colors hover:bg-danger-50 disabled:opacity-40 disabled:pointer-events-none dark:border-secondary-600 dark:bg-secondary-800 dark:text-danger-400 dark:hover:bg-danger-900/20",children:[jsxRuntime.jsx(lucideReact.Trash2,{className:"h-3.5 w-3.5"})," Delete",c.length>0&&` (${c.length})`]}),C&&c.length===1&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{let t=r.find(s=>s.editable!==false);t&&F({rowKey:c[0],colKey:t.key});},className:"inline-flex items-center gap-1.5 rounded-md border border-secondary-300 bg-white px-3 py-1.5 text-sm font-medium text-secondary-700 transition-colors hover:bg-secondary-50 dark:border-secondary-600 dark:bg-secondary-800 dark:text-secondary-300 dark:hover:bg-secondary-700",children:[jsxRuntime.jsx(lucideReact.Pencil,{className:"h-3.5 w-3.5"})," Edit"]}),c.length>0&&jsxRuntime.jsxs("span",{className:"ml-auto text-sm text-secondary-500 dark:text-secondary-400",children:[c.length," row",c.length>1?"s":""," selected"]})]}),jsxRuntime.jsxs(W,{intent:B,density:n,className:g,children:[jsxRuntime.jsx(Y,{children:jsxRuntime.jsxs(U,{children:[l==="multiple"&&jsxRuntime.jsx(V,{className:"w-10",children:jsxRuntime.jsx("input",{type:"checkbox",checked:z,ref:t=>{t&&(t.indeterminate=ne);},onChange:se,className:"h-4 w-4 cursor-pointer rounded border-secondary-300 accent-primary-600","aria-label":"Select all"})}),l==="single"&&jsxRuntime.jsx(V,{className:"w-10"}),r.map(t=>{let s=t.sortable!==false,o=p?.column===t.key;return jsxRuntime.jsx(V,{className:m(s&&"cursor-pointer select-none",t.headerClassName),onClick:s?()=>k(t.key):void 0,"aria-sort":o?p.direction==="asc"?"ascending":"descending":void 0,children:jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.header,s&&jsxRuntime.jsx(te,{active:o,direction:o?p.direction:null})]})},t.key)}),K&&jsxRuntime.jsx(V,{className:"w-20 text-right",children:"Actions"})]})}),jsxRuntime.jsx(Z,{children:I.length===0?jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:r.length+(l!=="none"?1:0)+(K?1:0),children:jsxRuntime.jsx(ee,{...u})})}):I.map((t,s)=>{let o=d(t,s),v=c.includes(o);return jsxRuntime.jsxs(U,{className:m(v&&"bg-primary-50/60 dark:bg-primary-900/20"),onClick:()=>{l!=="none"&&q(o);},children:[l==="multiple"&&jsxRuntime.jsx(H,{className:"w-10",children:jsxRuntime.jsx("input",{type:"checkbox",checked:v,onChange:()=>q(o),onClick:i=>i.stopPropagation(),className:"h-4 w-4 cursor-pointer rounded border-secondary-300 accent-primary-600","aria-label":"Select row"})}),l==="single"&&jsxRuntime.jsx(H,{className:"w-10",children:jsxRuntime.jsx("input",{type:"radio",checked:v,onChange:()=>q(o),onClick:i=>i.stopPropagation(),className:"h-4 w-4 cursor-pointer accent-primary-600","aria-label":"Select row"})}),r.map(i=>{let N=J?.rowKey===o&&J?.colKey===i.key,w=i.editValue?.(t)??(()=>{let S=i.cell(t);return typeof S=="string"||typeof S=="number"?String(S):""})();return jsxRuntime.jsx(H,{className:m(i.cellClassName,C&&i.editable!==false&&"cursor-text"),onDoubleClick:S=>{S.stopPropagation(),le(o,i.key,i.editable);},children:N?jsxRuntime.jsx(ke,{value:w,onCommit:S=>oe(o,i.key,S),onCancel:()=>F(null)}):i.cell(t)},i.key)}),K&&jsxRuntime.jsx(H,{className:"text-right",onClick:i=>i.stopPropagation(),children:jsxRuntime.jsx("span",{className:"inline-flex items-center gap-1",children:K(t)})})]},o)})})]})]})}function te({active:r,direction:a}){let d="h-3.5 w-3.5 shrink-0";return !r||!a?jsxRuntime.jsx(lucideReact.ArrowUpDown,{className:m(d,"opacity-30")}):a==="asc"?jsxRuntime.jsx(lucideReact.ArrowUp,{className:m(d,"opacity-70")}):jsxRuntime.jsx(lucideReact.ArrowDown,{className:m(d,"opacity-70")})}exports.DataTable=Ie;exports.SortableTable=Be;exports.Table=W;exports.TableBody=Z;exports.TableCell=H;exports.TableEmpty=ee;exports.TableHead=V;exports.TableHeader=Y;exports.TableRow=U;
1
+ 'use strict';var react=require('react'),lucideReact=require('lucide-react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),classVarianceAuthority=require('class-variance-authority'),jsxRuntime=require('react/jsx-runtime');function m(...r){return tailwindMerge.twMerge(clsx.clsx(r))}var O=classVarianceAuthority.cva("w-full text-left text-sm",{variants:{intent:{default:"",striped:"[&_tbody_tr:nth-child(even)]:bg-primary-50 dark:[&_tbody_tr:nth-child(even)]:bg-primary-800/30",bordered:"[&_th]:border [&_td]:border [&_th]:border-primary-200 [&_td]:border-primary-200 dark:[&_th]:border-primary-700 dark:[&_td]:border-primary-700"},density:{compact:"[&_th]:px-2 [&_th]:py-1 [&_td]:px-2 [&_td]:py-1",default:"",relaxed:"[&_th]:px-6 [&_th]:py-5 [&_td]:px-6 [&_td]:py-5"}},defaultVariants:{intent:"default",density:"default"}});classVarianceAuthority.cva("text-sm text-primary-700 dark:text-primary-300",{variants:{intent:{default:"space-y-1",bordered:"divide-y divide-primary-200 rounded-lg border border-primary-200 dark:divide-primary-700 dark:border-primary-700 [&>li]:px-4 [&>li]:py-2",hover:"[&>li]:rounded-md [&>li]:px-3 [&>li]:py-2 [&>li]:transition-colors [&>li:hover]:bg-primary-50 dark:[&>li:hover]:bg-primary-800/50"}},defaultVariants:{intent:"default"}});classVarianceAuthority.cva("group flex w-full items-center gap-1.5 text-left [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3 [&_svg]:w-3",md:"py-1.5 text-sm [&_svg]:h-3.5 [&_svg]:w-3.5",lg:"py-2 text-base [&_svg]:h-4 [&_svg]:w-4"}},defaultVariants:{size:"md"}});classVarianceAuthority.cva("flex cursor-pointer items-center gap-1 rounded transition-colors [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",md:"py-1 text-sm [&_svg]:h-4 [&_svg]:w-4",lg:"py-1.5 text-base [&_svg]:h-5 [&_svg]:w-5"}},defaultVariants:{size:"md"}});classVarianceAuthority.cva("overflow-x-auto rounded-lg font-mono [background:var(--color-syntax-bg)] [&_pre]:m-0 [&_pre]:p-4 [&_code]:bg-transparent",{variants:{size:{sm:"text-xs",md:"text-sm",lg:"text-base"}},defaultVariants:{size:"md"}});function W({intent:r,density:a,className:d,...f}){return jsxRuntime.jsx("div",{className:"w-full overflow-auto",children:jsxRuntime.jsx("table",{className:m(O({intent:r,density:a}),d),...f})})}function Y({className:r,...a}){return jsxRuntime.jsx("thead",{className:m("bg-primary-50 text-primary-600 dark:bg-primary-800/50 dark:text-primary-400",r),...a})}function Z({className:r,...a}){return jsxRuntime.jsx("tbody",{className:m("[&_tr:last-child]:border-0",r),...a})}function U({className:r,...a}){return jsxRuntime.jsx("tr",{className:m("border-primary-200 hover:bg-primary-50/50 dark:border-primary-700 dark:hover:bg-primary-800/30 border-b transition-colors",r),...a})}function V({className:r,...a}){return jsxRuntime.jsx("th",{className:m("px-4 py-3 text-left text-xs font-semibold tracking-wider uppercase",r),...a})}function H({className:r,...a}){return jsxRuntime.jsx("td",{className:m("text-primary-700 dark:text-primary-300 px-4 py-3",r),...a})}function ee({icon:r,text:a="No data",className:d}){return jsxRuntime.jsxs("div",{className:m("flex flex-col items-center justify-center gap-3 py-16 text-primary-400 dark:text-primary-500",d),children:[r??jsxRuntime.jsx(lucideReact.Inbox,{className:"h-12 w-12 stroke-[1.2]"}),jsxRuntime.jsx("span",{className:"text-sm",children:a})]})}var Q={sm:"hidden sm:table-cell",md:"hidden md:table-cell",lg:"hidden lg:table-cell"};function Be({columns:r,data:a,sort:d,onSortChange:f,defaultSort:T=null,rowKey:x,rowActions:o,intent:h,density:X,className:C,empty:L}){let[$,A]=react.useState(T),y=d??$,K=react.useCallback(n=>{let g=y?.column===n?y.direction==="asc"?{column:n,direction:"desc"}:null:{column:n,direction:"asc"};f?f(g):A(g);},[y,f]),B=react.useMemo(()=>{if(!y)return a;let n=r.find(P=>P.key===y.column);if(!n)return a;let g=n.compareFn??((P,j)=>{let p=n.cell(P),k=n.cell(j);return p==null&&k==null?0:p==null?-1:k==null?1:typeof p=="number"&&typeof k=="number"?p-k:String(p).localeCompare(String(k))}),u=[...a].sort(g);return y.direction==="desc"?u.reverse():u},[a,y,r]);return jsxRuntime.jsxs(W,{intent:h,density:X,className:C,children:[jsxRuntime.jsx(Y,{children:jsxRuntime.jsxs(U,{children:[r.map(n=>{let g=n.sortable!==false,u=y?.column===n.key;return jsxRuntime.jsx(V,{className:m(g&&"cursor-pointer select-none",n.headerClassName,n.hideBelow&&Q[n.hideBelow]),onClick:g?()=>K(n.key):void 0,"aria-sort":u?y.direction==="asc"?"ascending":"descending":void 0,children:jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.header,g&&jsxRuntime.jsx(te,{active:u,direction:u?y.direction:null})]})},n.key)}),o&&jsxRuntime.jsx(V,{className:"w-20 text-right",children:"Actions"})]})}),jsxRuntime.jsx(Z,{children:B.length===0?jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:r.length+(o?1:0),children:jsxRuntime.jsx(ee,{...L})})}):B.map((n,g)=>jsxRuntime.jsxs(U,{children:[r.map(u=>jsxRuntime.jsx(H,{className:m(u.cellClassName,u.hideBelow&&Q[u.hideBelow]),children:u.cell(n)},u.key)),o&&jsxRuntime.jsx(H,{className:"text-right",children:jsxRuntime.jsx("span",{className:"inline-flex items-center gap-1",children:o(n)})})]},x?x(n,g):g))})]})}function ke({value:r,onCommit:a,onCancel:d}){let[f,T]=react.useState(r),x=react.useRef(null);react.useEffect(()=>{x.current?.focus(),x.current?.select();},[]);let o=()=>a(f);return jsxRuntime.jsxs("span",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("input",{ref:x,type:"text",value:f,onChange:h=>T(h.target.value),onKeyDown:h=>{h.key==="Enter"&&o(),h.key==="Escape"&&d();},"aria-label":"Edit cell",className:"min-w-0 flex-1 rounded border border-primary-400 bg-white px-1.5 py-0.5 text-sm outline-none focus:ring-1 focus:ring-primary-400 dark:border-primary-600 dark:bg-secondary-800"}),jsxRuntime.jsx("button",{type:"button",onClick:o,className:"text-success-600 hover:text-success-700 dark:text-success-400","aria-label":"Confirm",children:jsxRuntime.jsx(lucideReact.Check,{className:"h-3.5 w-3.5"})}),jsxRuntime.jsx("button",{type:"button",onClick:d,className:"text-danger-500 hover:text-danger-600 dark:text-danger-400","aria-label":"Cancel",children:jsxRuntime.jsx(lucideReact.X,{className:"h-3.5 w-3.5"})})]})}function Ie({columns:r,data:a,rowKey:d,sort:f,onSortChange:T,defaultSort:x=null,selectionMode:o="none",selected:h,onSelectionChange:X,editable:C=false,onCellEdit:L,toolbar:$=false,onAdd:A,onDelete:y,rowActions:K,intent:B,density:n,className:g,empty:u}){let[P,j]=react.useState(x),p=f??P,k=react.useCallback(t=>{let s=p?.column===t?p.direction==="asc"?{column:t,direction:"desc"}:null:{column:t,direction:"asc"};T?T(s):j(s);},[p,T]),I=react.useMemo(()=>{if(!p)return a;let t=r.find(v=>v.key===p.column);if(!t)return a;let s=t.compareFn??((v,i)=>{let N=t.cell(v),w=t.cell(i);return N==null&&w==null?0:N==null?-1:w==null?1:typeof N=="number"&&typeof w=="number"?N-w:String(N).localeCompare(String(w))}),l=[...a].sort(s);return p.direction==="desc"?l.reverse():l},[a,p,r]),[re,ae]=react.useState([]),c=h??re,R=X??ae,M=react.useMemo(()=>I.map((t,s)=>d(t,s)),[I,d]),z=o==="multiple"&&M.length>0&&M.every(t=>c.includes(t)),ne=o==="multiple"&&c.length>0&&!z,q=react.useCallback(t=>{o==="single"?R(c.includes(t)?[]:[t]):o==="multiple"&&R(c.includes(t)?c.filter(s=>s!==t):[...c,t]);},[o,c,R]),se=react.useCallback(()=>{R(z?[]:M);},[z,M,R]),[J,F]=react.useState(null),oe=react.useCallback((t,s,l)=>{C&&l!==false&&F({rowKey:t,colKey:s});},[C]),le=react.useCallback((t,s,l)=>{L?.(t,s,l),F(null);},[L]);return jsxRuntime.jsxs("div",{className:"space-y-2",children:[$&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[A&&jsxRuntime.jsxs("button",{type:"button",onClick:A,className:"inline-flex items-center gap-1.5 rounded-md border border-secondary-300 bg-white px-3 py-1.5 text-sm font-medium text-secondary-700 transition-colors hover:bg-secondary-50 dark:border-secondary-600 dark:bg-secondary-800 dark:text-secondary-300 dark:hover:bg-secondary-700",children:[jsxRuntime.jsx(lucideReact.Plus,{className:"h-3.5 w-3.5"})," Add"]}),y&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>y(c),disabled:c.length===0,className:"inline-flex items-center gap-1.5 rounded-md border border-secondary-300 bg-white px-3 py-1.5 text-sm font-medium text-danger-600 transition-colors hover:bg-danger-50 disabled:opacity-40 disabled:pointer-events-none dark:border-secondary-600 dark:bg-secondary-800 dark:text-danger-400 dark:hover:bg-danger-900/20",children:[jsxRuntime.jsx(lucideReact.Trash2,{className:"h-3.5 w-3.5"})," Delete",c.length>0&&` (${c.length})`]}),C&&c.length===1&&jsxRuntime.jsxs("button",{type:"button",onClick:()=>{let t=r.find(s=>s.editable!==false);t&&F({rowKey:c[0],colKey:t.key});},className:"inline-flex items-center gap-1.5 rounded-md border border-secondary-300 bg-white px-3 py-1.5 text-sm font-medium text-secondary-700 transition-colors hover:bg-secondary-50 dark:border-secondary-600 dark:bg-secondary-800 dark:text-secondary-300 dark:hover:bg-secondary-700",children:[jsxRuntime.jsx(lucideReact.Pencil,{className:"h-3.5 w-3.5"})," Edit"]}),c.length>0&&jsxRuntime.jsxs("span",{className:"ml-auto text-sm text-secondary-500 dark:text-secondary-400",children:[c.length," row",c.length>1?"s":""," selected"]})]}),jsxRuntime.jsxs(W,{intent:B,density:n,className:g,children:[jsxRuntime.jsx(Y,{children:jsxRuntime.jsxs(U,{children:[o==="multiple"&&jsxRuntime.jsx(V,{className:"w-10",children:jsxRuntime.jsx("input",{type:"checkbox",checked:z,ref:t=>{t&&(t.indeterminate=ne);},onChange:se,className:"h-4 w-4 cursor-pointer rounded border-secondary-300 accent-primary-600","aria-label":"Select all"})}),o==="single"&&jsxRuntime.jsx(V,{className:"w-10"}),r.map(t=>{let s=t.sortable!==false,l=p?.column===t.key;return jsxRuntime.jsx(V,{className:m(s&&"cursor-pointer select-none",t.headerClassName),onClick:s?()=>k(t.key):void 0,"aria-sort":l?p.direction==="asc"?"ascending":"descending":void 0,children:jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.header,s&&jsxRuntime.jsx(te,{active:l,direction:l?p.direction:null})]})},t.key)}),K&&jsxRuntime.jsx(V,{className:"w-20 text-right",children:"Actions"})]})}),jsxRuntime.jsx(Z,{children:I.length===0?jsxRuntime.jsx("tr",{children:jsxRuntime.jsx("td",{colSpan:r.length+(o!=="none"?1:0)+(K?1:0),children:jsxRuntime.jsx(ee,{...u})})}):I.map((t,s)=>{let l=d(t,s),v=c.includes(l);return jsxRuntime.jsxs(U,{className:m(v&&"bg-primary-50/60 dark:bg-primary-900/20"),onClick:()=>{o!=="none"&&q(l);},children:[o==="multiple"&&jsxRuntime.jsx(H,{className:"w-10",children:jsxRuntime.jsx("input",{type:"checkbox",checked:v,onChange:()=>q(l),onClick:i=>i.stopPropagation(),className:"h-4 w-4 cursor-pointer rounded border-secondary-300 accent-primary-600","aria-label":"Select row"})}),o==="single"&&jsxRuntime.jsx(H,{className:"w-10",children:jsxRuntime.jsx("input",{type:"radio",checked:v,onChange:()=>q(l),onClick:i=>i.stopPropagation(),className:"h-4 w-4 cursor-pointer accent-primary-600","aria-label":"Select row"})}),r.map(i=>{let N=J?.rowKey===l&&J?.colKey===i.key,w=i.editValue?.(t)??(()=>{let S=i.cell(t);return typeof S=="string"||typeof S=="number"?String(S):""})();return jsxRuntime.jsx(H,{className:m(i.cellClassName,C&&i.editable!==false&&"cursor-text"),onDoubleClick:S=>{S.stopPropagation(),oe(l,i.key,i.editable);},children:N?jsxRuntime.jsx(ke,{value:w,onCommit:S=>le(l,i.key,S),onCancel:()=>F(null)}):i.cell(t)},i.key)}),K&&jsxRuntime.jsx(H,{className:"text-right",onClick:i=>i.stopPropagation(),children:jsxRuntime.jsx("span",{className:"inline-flex items-center gap-1",children:K(t)})})]},l)})})]})]})}function te({active:r,direction:a}){let d="h-3.5 w-3.5 shrink-0";return !r||!a?jsxRuntime.jsx(lucideReact.ArrowUpDown,{className:m(d,"opacity-30")}):a==="asc"?jsxRuntime.jsx(lucideReact.ArrowUp,{className:m(d,"opacity-70")}):jsxRuntime.jsx(lucideReact.ArrowDown,{className:m(d,"opacity-70")})}exports.DataTable=Ie;exports.SortableTable=Be;exports.Table=W;exports.TableBody=Z;exports.TableCell=H;exports.TableEmpty=ee;exports.TableHead=V;exports.TableHeader=Y;exports.TableRow=U;
@@ -1 +1 @@
1
- import {useState,useCallback,useMemo,useRef,useEffect}from'react';import {Inbox,Plus,Trash2,Pencil,ArrowUpDown,ArrowUp,ArrowDown,Check,X}from'lucide-react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {cva}from'class-variance-authority';import {jsx,jsxs}from'react/jsx-runtime';function m(...r){return twMerge(clsx(r))}var O=cva("w-full text-left text-sm",{variants:{intent:{default:"",striped:"[&_tbody_tr:nth-child(even)]:bg-primary-50 dark:[&_tbody_tr:nth-child(even)]:bg-primary-800/30",bordered:"[&_th]:border [&_td]:border [&_th]:border-primary-200 [&_td]:border-primary-200 dark:[&_th]:border-primary-700 dark:[&_td]:border-primary-700"},density:{compact:"[&_th]:px-2 [&_th]:py-1 [&_td]:px-2 [&_td]:py-1",default:"",relaxed:"[&_th]:px-6 [&_th]:py-5 [&_td]:px-6 [&_td]:py-5"}},defaultVariants:{intent:"default",density:"default"}});cva("text-sm text-primary-700 dark:text-primary-300",{variants:{intent:{default:"space-y-1",bordered:"divide-y divide-primary-200 rounded-lg border border-primary-200 dark:divide-primary-700 dark:border-primary-700 [&>li]:px-4 [&>li]:py-2",hover:"[&>li]:rounded-md [&>li]:px-3 [&>li]:py-2 [&>li]:transition-colors [&>li:hover]:bg-primary-50 dark:[&>li:hover]:bg-primary-800/50"}},defaultVariants:{intent:"default"}});cva("group flex w-full items-center gap-1.5 text-left [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3 [&_svg]:w-3",md:"py-1.5 text-sm [&_svg]:h-3.5 [&_svg]:w-3.5",lg:"py-2 text-base [&_svg]:h-4 [&_svg]:w-4"}},defaultVariants:{size:"md"}});cva("flex cursor-pointer items-center gap-1 rounded transition-colors [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",md:"py-1 text-sm [&_svg]:h-4 [&_svg]:w-4",lg:"py-1.5 text-base [&_svg]:h-5 [&_svg]:w-5"}},defaultVariants:{size:"md"}});cva("overflow-x-auto rounded-lg font-mono [&_pre]:m-0 [&_pre]:p-4 [&_code]:bg-transparent",{variants:{size:{sm:"text-xs",md:"text-sm",lg:"text-base"}},defaultVariants:{size:"md"}});function W({intent:r,density:a,className:d,...f}){return jsx("div",{className:"w-full overflow-auto",children:jsx("table",{className:m(O({intent:r,density:a}),d),...f})})}function Y({className:r,...a}){return jsx("thead",{className:m("bg-primary-50 text-primary-600 dark:bg-primary-800/50 dark:text-primary-400",r),...a})}function Z({className:r,...a}){return jsx("tbody",{className:m("[&_tr:last-child]:border-0",r),...a})}function U({className:r,...a}){return jsx("tr",{className:m("border-primary-200 hover:bg-primary-50/50 dark:border-primary-700 dark:hover:bg-primary-800/30 border-b transition-colors",r),...a})}function V({className:r,...a}){return jsx("th",{className:m("px-4 py-3 text-left text-xs font-semibold tracking-wider uppercase",r),...a})}function H({className:r,...a}){return jsx("td",{className:m("text-primary-700 dark:text-primary-300 px-4 py-3",r),...a})}function ee({icon:r,text:a="No data",className:d}){return jsxs("div",{className:m("flex flex-col items-center justify-center gap-3 py-16 text-primary-400 dark:text-primary-500",d),children:[r??jsx(Inbox,{className:"h-12 w-12 stroke-[1.2]"}),jsx("span",{className:"text-sm",children:a})]})}var Q={sm:"hidden sm:table-cell",md:"hidden md:table-cell",lg:"hidden lg:table-cell"};function Be({columns:r,data:a,sort:d,onSortChange:f,defaultSort:T=null,rowKey:x,rowActions:l,intent:h,density:X,className:C,empty:L}){let[$,A]=useState(T),y=d??$,K=useCallback(n=>{let g=y?.column===n?y.direction==="asc"?{column:n,direction:"desc"}:null:{column:n,direction:"asc"};f?f(g):A(g);},[y,f]),B=useMemo(()=>{if(!y)return a;let n=r.find(P=>P.key===y.column);if(!n)return a;let g=n.compareFn??((P,j)=>{let p=n.cell(P),k=n.cell(j);return p==null&&k==null?0:p==null?-1:k==null?1:typeof p=="number"&&typeof k=="number"?p-k:String(p).localeCompare(String(k))}),u=[...a].sort(g);return y.direction==="desc"?u.reverse():u},[a,y,r]);return jsxs(W,{intent:h,density:X,className:C,children:[jsx(Y,{children:jsxs(U,{children:[r.map(n=>{let g=n.sortable!==false,u=y?.column===n.key;return jsx(V,{className:m(g&&"cursor-pointer select-none",n.headerClassName,n.hideBelow&&Q[n.hideBelow]),onClick:g?()=>K(n.key):void 0,"aria-sort":u?y.direction==="asc"?"ascending":"descending":void 0,children:jsxs("span",{className:"inline-flex items-center gap-1",children:[n.header,g&&jsx(te,{active:u,direction:u?y.direction:null})]})},n.key)}),l&&jsx(V,{className:"w-20 text-right",children:"Actions"})]})}),jsx(Z,{children:B.length===0?jsx("tr",{children:jsx("td",{colSpan:r.length+(l?1:0),children:jsx(ee,{...L})})}):B.map((n,g)=>jsxs(U,{children:[r.map(u=>jsx(H,{className:m(u.cellClassName,u.hideBelow&&Q[u.hideBelow]),children:u.cell(n)},u.key)),l&&jsx(H,{className:"text-right",children:jsx("span",{className:"inline-flex items-center gap-1",children:l(n)})})]},x?x(n,g):g))})]})}function ke({value:r,onCommit:a,onCancel:d}){let[f,T]=useState(r),x=useRef(null);useEffect(()=>{x.current?.focus(),x.current?.select();},[]);let l=()=>a(f);return jsxs("span",{className:"flex items-center gap-1",children:[jsx("input",{ref:x,type:"text",value:f,onChange:h=>T(h.target.value),onKeyDown:h=>{h.key==="Enter"&&l(),h.key==="Escape"&&d();},"aria-label":"Edit cell",className:"min-w-0 flex-1 rounded border border-primary-400 bg-white px-1.5 py-0.5 text-sm outline-none focus:ring-1 focus:ring-primary-400 dark:border-primary-600 dark:bg-secondary-800"}),jsx("button",{type:"button",onClick:l,className:"text-success-600 hover:text-success-700 dark:text-success-400","aria-label":"Confirm",children:jsx(Check,{className:"h-3.5 w-3.5"})}),jsx("button",{type:"button",onClick:d,className:"text-danger-500 hover:text-danger-600 dark:text-danger-400","aria-label":"Cancel",children:jsx(X,{className:"h-3.5 w-3.5"})})]})}function Ie({columns:r,data:a,rowKey:d,sort:f,onSortChange:T,defaultSort:x=null,selectionMode:l="none",selected:h,onSelectionChange:X,editable:C=false,onCellEdit:L,toolbar:$=false,onAdd:A,onDelete:y,rowActions:K,intent:B,density:n,className:g,empty:u}){let[P,j]=useState(x),p=f??P,k=useCallback(t=>{let s=p?.column===t?p.direction==="asc"?{column:t,direction:"desc"}:null:{column:t,direction:"asc"};T?T(s):j(s);},[p,T]),I=useMemo(()=>{if(!p)return a;let t=r.find(v=>v.key===p.column);if(!t)return a;let s=t.compareFn??((v,i)=>{let N=t.cell(v),w=t.cell(i);return N==null&&w==null?0:N==null?-1:w==null?1:typeof N=="number"&&typeof w=="number"?N-w:String(N).localeCompare(String(w))}),o=[...a].sort(s);return p.direction==="desc"?o.reverse():o},[a,p,r]),[re,ae]=useState([]),c=h??re,R=X??ae,M=useMemo(()=>I.map((t,s)=>d(t,s)),[I,d]),z=l==="multiple"&&M.length>0&&M.every(t=>c.includes(t)),ne=l==="multiple"&&c.length>0&&!z,q=useCallback(t=>{l==="single"?R(c.includes(t)?[]:[t]):l==="multiple"&&R(c.includes(t)?c.filter(s=>s!==t):[...c,t]);},[l,c,R]),se=useCallback(()=>{R(z?[]:M);},[z,M,R]),[J,F]=useState(null),le=useCallback((t,s,o)=>{C&&o!==false&&F({rowKey:t,colKey:s});},[C]),oe=useCallback((t,s,o)=>{L?.(t,s,o),F(null);},[L]);return jsxs("div",{className:"space-y-2",children:[$&&jsxs("div",{className:"flex items-center gap-2",children:[A&&jsxs("button",{type:"button",onClick:A,className:"inline-flex items-center gap-1.5 rounded-md border border-secondary-300 bg-white px-3 py-1.5 text-sm font-medium text-secondary-700 transition-colors hover:bg-secondary-50 dark:border-secondary-600 dark:bg-secondary-800 dark:text-secondary-300 dark:hover:bg-secondary-700",children:[jsx(Plus,{className:"h-3.5 w-3.5"})," Add"]}),y&&jsxs("button",{type:"button",onClick:()=>y(c),disabled:c.length===0,className:"inline-flex items-center gap-1.5 rounded-md border border-secondary-300 bg-white px-3 py-1.5 text-sm font-medium text-danger-600 transition-colors hover:bg-danger-50 disabled:opacity-40 disabled:pointer-events-none dark:border-secondary-600 dark:bg-secondary-800 dark:text-danger-400 dark:hover:bg-danger-900/20",children:[jsx(Trash2,{className:"h-3.5 w-3.5"})," Delete",c.length>0&&` (${c.length})`]}),C&&c.length===1&&jsxs("button",{type:"button",onClick:()=>{let t=r.find(s=>s.editable!==false);t&&F({rowKey:c[0],colKey:t.key});},className:"inline-flex items-center gap-1.5 rounded-md border border-secondary-300 bg-white px-3 py-1.5 text-sm font-medium text-secondary-700 transition-colors hover:bg-secondary-50 dark:border-secondary-600 dark:bg-secondary-800 dark:text-secondary-300 dark:hover:bg-secondary-700",children:[jsx(Pencil,{className:"h-3.5 w-3.5"})," Edit"]}),c.length>0&&jsxs("span",{className:"ml-auto text-sm text-secondary-500 dark:text-secondary-400",children:[c.length," row",c.length>1?"s":""," selected"]})]}),jsxs(W,{intent:B,density:n,className:g,children:[jsx(Y,{children:jsxs(U,{children:[l==="multiple"&&jsx(V,{className:"w-10",children:jsx("input",{type:"checkbox",checked:z,ref:t=>{t&&(t.indeterminate=ne);},onChange:se,className:"h-4 w-4 cursor-pointer rounded border-secondary-300 accent-primary-600","aria-label":"Select all"})}),l==="single"&&jsx(V,{className:"w-10"}),r.map(t=>{let s=t.sortable!==false,o=p?.column===t.key;return jsx(V,{className:m(s&&"cursor-pointer select-none",t.headerClassName),onClick:s?()=>k(t.key):void 0,"aria-sort":o?p.direction==="asc"?"ascending":"descending":void 0,children:jsxs("span",{className:"inline-flex items-center gap-1",children:[t.header,s&&jsx(te,{active:o,direction:o?p.direction:null})]})},t.key)}),K&&jsx(V,{className:"w-20 text-right",children:"Actions"})]})}),jsx(Z,{children:I.length===0?jsx("tr",{children:jsx("td",{colSpan:r.length+(l!=="none"?1:0)+(K?1:0),children:jsx(ee,{...u})})}):I.map((t,s)=>{let o=d(t,s),v=c.includes(o);return jsxs(U,{className:m(v&&"bg-primary-50/60 dark:bg-primary-900/20"),onClick:()=>{l!=="none"&&q(o);},children:[l==="multiple"&&jsx(H,{className:"w-10",children:jsx("input",{type:"checkbox",checked:v,onChange:()=>q(o),onClick:i=>i.stopPropagation(),className:"h-4 w-4 cursor-pointer rounded border-secondary-300 accent-primary-600","aria-label":"Select row"})}),l==="single"&&jsx(H,{className:"w-10",children:jsx("input",{type:"radio",checked:v,onChange:()=>q(o),onClick:i=>i.stopPropagation(),className:"h-4 w-4 cursor-pointer accent-primary-600","aria-label":"Select row"})}),r.map(i=>{let N=J?.rowKey===o&&J?.colKey===i.key,w=i.editValue?.(t)??(()=>{let S=i.cell(t);return typeof S=="string"||typeof S=="number"?String(S):""})();return jsx(H,{className:m(i.cellClassName,C&&i.editable!==false&&"cursor-text"),onDoubleClick:S=>{S.stopPropagation(),le(o,i.key,i.editable);},children:N?jsx(ke,{value:w,onCommit:S=>oe(o,i.key,S),onCancel:()=>F(null)}):i.cell(t)},i.key)}),K&&jsx(H,{className:"text-right",onClick:i=>i.stopPropagation(),children:jsx("span",{className:"inline-flex items-center gap-1",children:K(t)})})]},o)})})]})]})}function te({active:r,direction:a}){let d="h-3.5 w-3.5 shrink-0";return !r||!a?jsx(ArrowUpDown,{className:m(d,"opacity-30")}):a==="asc"?jsx(ArrowUp,{className:m(d,"opacity-70")}):jsx(ArrowDown,{className:m(d,"opacity-70")})}export{Ie as DataTable,Be as SortableTable,W as Table,Z as TableBody,H as TableCell,ee as TableEmpty,V as TableHead,Y as TableHeader,U as TableRow};
1
+ import {useState,useCallback,useMemo,useRef,useEffect}from'react';import {Inbox,Plus,Trash2,Pencil,ArrowUpDown,ArrowUp,ArrowDown,Check,X}from'lucide-react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {cva}from'class-variance-authority';import {jsx,jsxs}from'react/jsx-runtime';function m(...r){return twMerge(clsx(r))}var O=cva("w-full text-left text-sm",{variants:{intent:{default:"",striped:"[&_tbody_tr:nth-child(even)]:bg-primary-50 dark:[&_tbody_tr:nth-child(even)]:bg-primary-800/30",bordered:"[&_th]:border [&_td]:border [&_th]:border-primary-200 [&_td]:border-primary-200 dark:[&_th]:border-primary-700 dark:[&_td]:border-primary-700"},density:{compact:"[&_th]:px-2 [&_th]:py-1 [&_td]:px-2 [&_td]:py-1",default:"",relaxed:"[&_th]:px-6 [&_th]:py-5 [&_td]:px-6 [&_td]:py-5"}},defaultVariants:{intent:"default",density:"default"}});cva("text-sm text-primary-700 dark:text-primary-300",{variants:{intent:{default:"space-y-1",bordered:"divide-y divide-primary-200 rounded-lg border border-primary-200 dark:divide-primary-700 dark:border-primary-700 [&>li]:px-4 [&>li]:py-2",hover:"[&>li]:rounded-md [&>li]:px-3 [&>li]:py-2 [&>li]:transition-colors [&>li:hover]:bg-primary-50 dark:[&>li:hover]:bg-primary-800/50"}},defaultVariants:{intent:"default"}});cva("group flex w-full items-center gap-1.5 text-left [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3 [&_svg]:w-3",md:"py-1.5 text-sm [&_svg]:h-3.5 [&_svg]:w-3.5",lg:"py-2 text-base [&_svg]:h-4 [&_svg]:w-4"}},defaultVariants:{size:"md"}});cva("flex cursor-pointer items-center gap-1 rounded transition-colors [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",md:"py-1 text-sm [&_svg]:h-4 [&_svg]:w-4",lg:"py-1.5 text-base [&_svg]:h-5 [&_svg]:w-5"}},defaultVariants:{size:"md"}});cva("overflow-x-auto rounded-lg font-mono [background:var(--color-syntax-bg)] [&_pre]:m-0 [&_pre]:p-4 [&_code]:bg-transparent",{variants:{size:{sm:"text-xs",md:"text-sm",lg:"text-base"}},defaultVariants:{size:"md"}});function W({intent:r,density:a,className:d,...f}){return jsx("div",{className:"w-full overflow-auto",children:jsx("table",{className:m(O({intent:r,density:a}),d),...f})})}function Y({className:r,...a}){return jsx("thead",{className:m("bg-primary-50 text-primary-600 dark:bg-primary-800/50 dark:text-primary-400",r),...a})}function Z({className:r,...a}){return jsx("tbody",{className:m("[&_tr:last-child]:border-0",r),...a})}function U({className:r,...a}){return jsx("tr",{className:m("border-primary-200 hover:bg-primary-50/50 dark:border-primary-700 dark:hover:bg-primary-800/30 border-b transition-colors",r),...a})}function V({className:r,...a}){return jsx("th",{className:m("px-4 py-3 text-left text-xs font-semibold tracking-wider uppercase",r),...a})}function H({className:r,...a}){return jsx("td",{className:m("text-primary-700 dark:text-primary-300 px-4 py-3",r),...a})}function ee({icon:r,text:a="No data",className:d}){return jsxs("div",{className:m("flex flex-col items-center justify-center gap-3 py-16 text-primary-400 dark:text-primary-500",d),children:[r??jsx(Inbox,{className:"h-12 w-12 stroke-[1.2]"}),jsx("span",{className:"text-sm",children:a})]})}var Q={sm:"hidden sm:table-cell",md:"hidden md:table-cell",lg:"hidden lg:table-cell"};function Be({columns:r,data:a,sort:d,onSortChange:f,defaultSort:T=null,rowKey:x,rowActions:o,intent:h,density:X,className:C,empty:L}){let[$,A]=useState(T),y=d??$,K=useCallback(n=>{let g=y?.column===n?y.direction==="asc"?{column:n,direction:"desc"}:null:{column:n,direction:"asc"};f?f(g):A(g);},[y,f]),B=useMemo(()=>{if(!y)return a;let n=r.find(P=>P.key===y.column);if(!n)return a;let g=n.compareFn??((P,j)=>{let p=n.cell(P),k=n.cell(j);return p==null&&k==null?0:p==null?-1:k==null?1:typeof p=="number"&&typeof k=="number"?p-k:String(p).localeCompare(String(k))}),u=[...a].sort(g);return y.direction==="desc"?u.reverse():u},[a,y,r]);return jsxs(W,{intent:h,density:X,className:C,children:[jsx(Y,{children:jsxs(U,{children:[r.map(n=>{let g=n.sortable!==false,u=y?.column===n.key;return jsx(V,{className:m(g&&"cursor-pointer select-none",n.headerClassName,n.hideBelow&&Q[n.hideBelow]),onClick:g?()=>K(n.key):void 0,"aria-sort":u?y.direction==="asc"?"ascending":"descending":void 0,children:jsxs("span",{className:"inline-flex items-center gap-1",children:[n.header,g&&jsx(te,{active:u,direction:u?y.direction:null})]})},n.key)}),o&&jsx(V,{className:"w-20 text-right",children:"Actions"})]})}),jsx(Z,{children:B.length===0?jsx("tr",{children:jsx("td",{colSpan:r.length+(o?1:0),children:jsx(ee,{...L})})}):B.map((n,g)=>jsxs(U,{children:[r.map(u=>jsx(H,{className:m(u.cellClassName,u.hideBelow&&Q[u.hideBelow]),children:u.cell(n)},u.key)),o&&jsx(H,{className:"text-right",children:jsx("span",{className:"inline-flex items-center gap-1",children:o(n)})})]},x?x(n,g):g))})]})}function ke({value:r,onCommit:a,onCancel:d}){let[f,T]=useState(r),x=useRef(null);useEffect(()=>{x.current?.focus(),x.current?.select();},[]);let o=()=>a(f);return jsxs("span",{className:"flex items-center gap-1",children:[jsx("input",{ref:x,type:"text",value:f,onChange:h=>T(h.target.value),onKeyDown:h=>{h.key==="Enter"&&o(),h.key==="Escape"&&d();},"aria-label":"Edit cell",className:"min-w-0 flex-1 rounded border border-primary-400 bg-white px-1.5 py-0.5 text-sm outline-none focus:ring-1 focus:ring-primary-400 dark:border-primary-600 dark:bg-secondary-800"}),jsx("button",{type:"button",onClick:o,className:"text-success-600 hover:text-success-700 dark:text-success-400","aria-label":"Confirm",children:jsx(Check,{className:"h-3.5 w-3.5"})}),jsx("button",{type:"button",onClick:d,className:"text-danger-500 hover:text-danger-600 dark:text-danger-400","aria-label":"Cancel",children:jsx(X,{className:"h-3.5 w-3.5"})})]})}function Ie({columns:r,data:a,rowKey:d,sort:f,onSortChange:T,defaultSort:x=null,selectionMode:o="none",selected:h,onSelectionChange:X,editable:C=false,onCellEdit:L,toolbar:$=false,onAdd:A,onDelete:y,rowActions:K,intent:B,density:n,className:g,empty:u}){let[P,j]=useState(x),p=f??P,k=useCallback(t=>{let s=p?.column===t?p.direction==="asc"?{column:t,direction:"desc"}:null:{column:t,direction:"asc"};T?T(s):j(s);},[p,T]),I=useMemo(()=>{if(!p)return a;let t=r.find(v=>v.key===p.column);if(!t)return a;let s=t.compareFn??((v,i)=>{let N=t.cell(v),w=t.cell(i);return N==null&&w==null?0:N==null?-1:w==null?1:typeof N=="number"&&typeof w=="number"?N-w:String(N).localeCompare(String(w))}),l=[...a].sort(s);return p.direction==="desc"?l.reverse():l},[a,p,r]),[re,ae]=useState([]),c=h??re,R=X??ae,M=useMemo(()=>I.map((t,s)=>d(t,s)),[I,d]),z=o==="multiple"&&M.length>0&&M.every(t=>c.includes(t)),ne=o==="multiple"&&c.length>0&&!z,q=useCallback(t=>{o==="single"?R(c.includes(t)?[]:[t]):o==="multiple"&&R(c.includes(t)?c.filter(s=>s!==t):[...c,t]);},[o,c,R]),se=useCallback(()=>{R(z?[]:M);},[z,M,R]),[J,F]=useState(null),oe=useCallback((t,s,l)=>{C&&l!==false&&F({rowKey:t,colKey:s});},[C]),le=useCallback((t,s,l)=>{L?.(t,s,l),F(null);},[L]);return jsxs("div",{className:"space-y-2",children:[$&&jsxs("div",{className:"flex items-center gap-2",children:[A&&jsxs("button",{type:"button",onClick:A,className:"inline-flex items-center gap-1.5 rounded-md border border-secondary-300 bg-white px-3 py-1.5 text-sm font-medium text-secondary-700 transition-colors hover:bg-secondary-50 dark:border-secondary-600 dark:bg-secondary-800 dark:text-secondary-300 dark:hover:bg-secondary-700",children:[jsx(Plus,{className:"h-3.5 w-3.5"})," Add"]}),y&&jsxs("button",{type:"button",onClick:()=>y(c),disabled:c.length===0,className:"inline-flex items-center gap-1.5 rounded-md border border-secondary-300 bg-white px-3 py-1.5 text-sm font-medium text-danger-600 transition-colors hover:bg-danger-50 disabled:opacity-40 disabled:pointer-events-none dark:border-secondary-600 dark:bg-secondary-800 dark:text-danger-400 dark:hover:bg-danger-900/20",children:[jsx(Trash2,{className:"h-3.5 w-3.5"})," Delete",c.length>0&&` (${c.length})`]}),C&&c.length===1&&jsxs("button",{type:"button",onClick:()=>{let t=r.find(s=>s.editable!==false);t&&F({rowKey:c[0],colKey:t.key});},className:"inline-flex items-center gap-1.5 rounded-md border border-secondary-300 bg-white px-3 py-1.5 text-sm font-medium text-secondary-700 transition-colors hover:bg-secondary-50 dark:border-secondary-600 dark:bg-secondary-800 dark:text-secondary-300 dark:hover:bg-secondary-700",children:[jsx(Pencil,{className:"h-3.5 w-3.5"})," Edit"]}),c.length>0&&jsxs("span",{className:"ml-auto text-sm text-secondary-500 dark:text-secondary-400",children:[c.length," row",c.length>1?"s":""," selected"]})]}),jsxs(W,{intent:B,density:n,className:g,children:[jsx(Y,{children:jsxs(U,{children:[o==="multiple"&&jsx(V,{className:"w-10",children:jsx("input",{type:"checkbox",checked:z,ref:t=>{t&&(t.indeterminate=ne);},onChange:se,className:"h-4 w-4 cursor-pointer rounded border-secondary-300 accent-primary-600","aria-label":"Select all"})}),o==="single"&&jsx(V,{className:"w-10"}),r.map(t=>{let s=t.sortable!==false,l=p?.column===t.key;return jsx(V,{className:m(s&&"cursor-pointer select-none",t.headerClassName),onClick:s?()=>k(t.key):void 0,"aria-sort":l?p.direction==="asc"?"ascending":"descending":void 0,children:jsxs("span",{className:"inline-flex items-center gap-1",children:[t.header,s&&jsx(te,{active:l,direction:l?p.direction:null})]})},t.key)}),K&&jsx(V,{className:"w-20 text-right",children:"Actions"})]})}),jsx(Z,{children:I.length===0?jsx("tr",{children:jsx("td",{colSpan:r.length+(o!=="none"?1:0)+(K?1:0),children:jsx(ee,{...u})})}):I.map((t,s)=>{let l=d(t,s),v=c.includes(l);return jsxs(U,{className:m(v&&"bg-primary-50/60 dark:bg-primary-900/20"),onClick:()=>{o!=="none"&&q(l);},children:[o==="multiple"&&jsx(H,{className:"w-10",children:jsx("input",{type:"checkbox",checked:v,onChange:()=>q(l),onClick:i=>i.stopPropagation(),className:"h-4 w-4 cursor-pointer rounded border-secondary-300 accent-primary-600","aria-label":"Select row"})}),o==="single"&&jsx(H,{className:"w-10",children:jsx("input",{type:"radio",checked:v,onChange:()=>q(l),onClick:i=>i.stopPropagation(),className:"h-4 w-4 cursor-pointer accent-primary-600","aria-label":"Select row"})}),r.map(i=>{let N=J?.rowKey===l&&J?.colKey===i.key,w=i.editValue?.(t)??(()=>{let S=i.cell(t);return typeof S=="string"||typeof S=="number"?String(S):""})();return jsx(H,{className:m(i.cellClassName,C&&i.editable!==false&&"cursor-text"),onDoubleClick:S=>{S.stopPropagation(),oe(l,i.key,i.editable);},children:N?jsx(ke,{value:w,onCommit:S=>le(l,i.key,S),onCancel:()=>F(null)}):i.cell(t)},i.key)}),K&&jsx(H,{className:"text-right",onClick:i=>i.stopPropagation(),children:jsx("span",{className:"inline-flex items-center gap-1",children:K(t)})})]},l)})})]})]})}function te({active:r,direction:a}){let d="h-3.5 w-3.5 shrink-0";return !r||!a?jsx(ArrowUpDown,{className:m(d,"opacity-30")}):a==="asc"?jsx(ArrowUp,{className:m(d,"opacity-70")}):jsx(ArrowDown,{className:m(d,"opacity-70")})}export{Ie as DataTable,Be as SortableTable,W as Table,Z as TableBody,H as TableCell,ee as TableEmpty,V as TableHead,Y as TableHeader,U as TableRow};
@@ -1 +1 @@
1
- 'use strict';var u=require('react'),lucideReact=require('lucide-react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),classVarianceAuthority=require('class-variance-authority'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var u__default=/*#__PURE__*/_interopDefault(u);function d(...s){return tailwindMerge.twMerge(clsx.clsx(s))}classVarianceAuthority.cva("w-full text-left text-sm",{variants:{intent:{default:"",striped:"[&_tbody_tr:nth-child(even)]:bg-primary-50 dark:[&_tbody_tr:nth-child(even)]:bg-primary-800/30",bordered:"[&_th]:border [&_td]:border [&_th]:border-primary-200 [&_td]:border-primary-200 dark:[&_th]:border-primary-700 dark:[&_td]:border-primary-700"},density:{compact:"[&_th]:px-2 [&_th]:py-1 [&_td]:px-2 [&_td]:py-1",default:"",relaxed:"[&_th]:px-6 [&_th]:py-5 [&_td]:px-6 [&_td]:py-5"}},defaultVariants:{intent:"default",density:"default"}});classVarianceAuthority.cva("text-sm text-primary-700 dark:text-primary-300",{variants:{intent:{default:"space-y-1",bordered:"divide-y divide-primary-200 rounded-lg border border-primary-200 dark:divide-primary-700 dark:border-primary-700 [&>li]:px-4 [&>li]:py-2",hover:"[&>li]:rounded-md [&>li]:px-3 [&>li]:py-2 [&>li]:transition-colors [&>li:hover]:bg-primary-50 dark:[&>li:hover]:bg-primary-800/50"}},defaultVariants:{intent:"default"}});classVarianceAuthority.cva("group flex w-full items-center gap-1.5 text-left [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3 [&_svg]:w-3",md:"py-1.5 text-sm [&_svg]:h-3.5 [&_svg]:w-3.5",lg:"py-2 text-base [&_svg]:h-4 [&_svg]:w-4"}},defaultVariants:{size:"md"}});var R=classVarianceAuthority.cva("flex cursor-pointer items-center gap-1 rounded transition-colors [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",md:"py-1 text-sm [&_svg]:h-4 [&_svg]:w-4",lg:"py-1.5 text-base [&_svg]:h-5 [&_svg]:w-5"}},defaultVariants:{size:"md"}});classVarianceAuthority.cva("overflow-x-auto rounded-lg font-mono [&_pre]:m-0 [&_pre]:p-4 [&_code]:bg-transparent",{variants:{size:{sm:"text-xs",md:"text-sm",lg:"text-base"}},defaultVariants:{size:"md"}});var T=u.createContext({showLines:true,expandedKeys:null,onToggleKey:()=>{},size:"md"});function X({showLines:s=true,showRoot:n=true,expandedKeys:e,defaultExpandedKeys:x="all",onExpandedKeysChange:g,size:f="md",className:p,children:m,...h}){let [y,l]=u.useState(()=>x),_=u.useCallback(o=>{if(e){let t=new Set(e);t.has(o)?t.delete(o):t.add(o),g?.(t);}else l(t=>{if(t==="all")return new Set(["__ALL_MINUS__",o]);let a=new Set(t);return a.has(o)?a.delete(o):a.add(o),a});},[e,g]),b=e??(y==="all"?null:y);return jsxRuntime.jsx(T.Provider,{value:{showLines:s,expandedKeys:b,onToggleKey:_,size:f},children:n?jsxRuntime.jsx("ul",{className:d("text-sm",p),role:"tree",...h,children:m}):jsxRuntime.jsx("ul",{className:d("text-sm",p),role:"tree",...h,children:jsxRuntime.jsx(E,{children:m})})})}function E({children:s}){let n=k(s);return jsxRuntime.jsx(jsxRuntime.Fragment,{children:n.map(e=>u__default.default.isValidElement(e)&&e.props.children?e.props.children:null)})}function k(s){let n=[];return u__default.default.Children.forEach(s,e=>{u__default.default.isValidElement(e)&&e.type===u__default.default.Fragment?n.push(...k(e.props.children)):n.push(e);}),n}function Y({nodeKey:s,label:n,icon:e,actions:x,defaultExpanded:g=false,expanded:f,onToggle:p,children:m,className:h}){let{showLines:y,expandedKeys:l,onToggleKey:w,size:_}=u.useContext(T),[b,o]=u.useState(g),t=u__default.default.Children.count(m)>0,a=s??(typeof n=="string"?n:""),i;f!=null?i=f:l!=null&&a?l.has("__ALL_MINUS__")?i=!l.has(a):i=l.has(a):i=b;let V=()=>{let v=!i;p?p(v):l!=null&&a?w(a):o(v);};return jsxRuntime.jsxs("li",{className:d("select-none",h),role:"treeitem","aria-expanded":t?i:void 0,children:[jsxRuntime.jsxs("div",{className:d("group hover:bg-primary-50 dark:hover:bg-primary-800/50 rounded-md px-1",R({size:_}),t?"cursor-pointer":"cursor-default"),onClick:t?V:void 0,children:[t?jsxRuntime.jsx(lucideReact.ChevronRight,{className:d("text-primary-400 h-4 w-4 shrink-0 transition-transform duration-200",i&&"rotate-90")}):jsxRuntime.jsx("span",{className:"w-4 shrink-0"}),e&&jsxRuntime.jsx("span",{className:"shrink-0",children:e}),jsxRuntime.jsx("span",{className:"text-primary-700 dark:text-primary-300 min-w-0 flex-1 truncate",children:n}),x&&jsxRuntime.jsx("span",{className:"ml-auto flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100 [@media(hover:none)]:opacity-100 [@media(hover:none)]:[&>button]:min-h-(--row-action-touch-min) [@media(hover:none)]:[&>button]:min-w-(--row-action-touch-min) [@media(hover:none)]:[&>button]:flex [@media(hover:none)]:[&>button]:items-center [@media(hover:none)]:[&>button]:justify-center",onClick:v=>v.stopPropagation(),children:x})]}),t&&jsxRuntime.jsx("div",{className:d("grid transition-[grid-template-rows] duration-200 ease-out",i?"grid-rows-[1fr]":"grid-rows-[0fr]"),children:jsxRuntime.jsx("div",{className:"overflow-hidden",children:jsxRuntime.jsx("ul",{className:d("ml-4 pl-2",y&&"border-primary-200 dark:border-primary-700 border-l"),role:"group",children:m})})})]})}exports.Tree=X;exports.TreeItem=Y;
1
+ 'use strict';var u=require('react'),lucideReact=require('lucide-react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),classVarianceAuthority=require('class-variance-authority'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var u__default=/*#__PURE__*/_interopDefault(u);function d(...s){return tailwindMerge.twMerge(clsx.clsx(s))}classVarianceAuthority.cva("w-full text-left text-sm",{variants:{intent:{default:"",striped:"[&_tbody_tr:nth-child(even)]:bg-primary-50 dark:[&_tbody_tr:nth-child(even)]:bg-primary-800/30",bordered:"[&_th]:border [&_td]:border [&_th]:border-primary-200 [&_td]:border-primary-200 dark:[&_th]:border-primary-700 dark:[&_td]:border-primary-700"},density:{compact:"[&_th]:px-2 [&_th]:py-1 [&_td]:px-2 [&_td]:py-1",default:"",relaxed:"[&_th]:px-6 [&_th]:py-5 [&_td]:px-6 [&_td]:py-5"}},defaultVariants:{intent:"default",density:"default"}});classVarianceAuthority.cva("text-sm text-primary-700 dark:text-primary-300",{variants:{intent:{default:"space-y-1",bordered:"divide-y divide-primary-200 rounded-lg border border-primary-200 dark:divide-primary-700 dark:border-primary-700 [&>li]:px-4 [&>li]:py-2",hover:"[&>li]:rounded-md [&>li]:px-3 [&>li]:py-2 [&>li]:transition-colors [&>li:hover]:bg-primary-50 dark:[&>li:hover]:bg-primary-800/50"}},defaultVariants:{intent:"default"}});classVarianceAuthority.cva("group flex w-full items-center gap-1.5 text-left [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3 [&_svg]:w-3",md:"py-1.5 text-sm [&_svg]:h-3.5 [&_svg]:w-3.5",lg:"py-2 text-base [&_svg]:h-4 [&_svg]:w-4"}},defaultVariants:{size:"md"}});var R=classVarianceAuthority.cva("flex cursor-pointer items-center gap-1 rounded transition-colors [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",md:"py-1 text-sm [&_svg]:h-4 [&_svg]:w-4",lg:"py-1.5 text-base [&_svg]:h-5 [&_svg]:w-5"}},defaultVariants:{size:"md"}});classVarianceAuthority.cva("overflow-x-auto rounded-lg font-mono [background:var(--color-syntax-bg)] [&_pre]:m-0 [&_pre]:p-4 [&_code]:bg-transparent",{variants:{size:{sm:"text-xs",md:"text-sm",lg:"text-base"}},defaultVariants:{size:"md"}});var k=u.createContext({showLines:true,expandedKeys:null,onToggleKey:()=>{},size:"md"});function X({showLines:s=true,showRoot:n=true,expandedKeys:e,defaultExpandedKeys:x="all",onExpandedKeysChange:g,size:y="md",className:p,children:m,...f}){let [h,l]=u.useState(()=>x),_=u.useCallback(o=>{if(e){let t=new Set(e);t.has(o)?t.delete(o):t.add(o),g?.(t);}else l(t=>{if(t==="all")return new Set(["__ALL_MINUS__",o]);let a=new Set(t);return a.has(o)?a.delete(o):a.add(o),a});},[e,g]),b=e??(h==="all"?null:h);return jsxRuntime.jsx(k.Provider,{value:{showLines:s,expandedKeys:b,onToggleKey:_,size:y},children:n?jsxRuntime.jsx("ul",{className:d("text-sm",p),role:"tree",...f,children:m}):jsxRuntime.jsx("ul",{className:d("text-sm",p),role:"tree",...f,children:jsxRuntime.jsx(E,{children:m})})})}function E({children:s}){let n=T(s);return jsxRuntime.jsx(jsxRuntime.Fragment,{children:n.map(e=>u__default.default.isValidElement(e)&&e.props.children?e.props.children:null)})}function T(s){let n=[];return u__default.default.Children.forEach(s,e=>{u__default.default.isValidElement(e)&&e.type===u__default.default.Fragment?n.push(...T(e.props.children)):n.push(e);}),n}function Y({nodeKey:s,label:n,icon:e,actions:x,defaultExpanded:g=false,expanded:y,onToggle:p,children:m,className:f}){let{showLines:h,expandedKeys:l,onToggleKey:w,size:_}=u.useContext(k),[b,o]=u.useState(g),t=u__default.default.Children.count(m)>0,a=s??(typeof n=="string"?n:""),i;y!=null?i=y:l!=null&&a?l.has("__ALL_MINUS__")?i=!l.has(a):i=l.has(a):i=b;let V=()=>{let v=!i;p?p(v):l!=null&&a?w(a):o(v);};return jsxRuntime.jsxs("li",{className:d("select-none",f),role:"treeitem","aria-expanded":t?i:void 0,children:[jsxRuntime.jsxs("div",{className:d("group hover:bg-primary-50 dark:hover:bg-primary-800/50 rounded-md px-1",R({size:_}),t?"cursor-pointer":"cursor-default"),onClick:t?V:void 0,children:[t?jsxRuntime.jsx(lucideReact.ChevronRight,{className:d("text-primary-400 h-4 w-4 shrink-0 transition-transform duration-200",i&&"rotate-90")}):jsxRuntime.jsx("span",{className:"w-4 shrink-0"}),e&&jsxRuntime.jsx("span",{className:"shrink-0",children:e}),jsxRuntime.jsx("span",{className:"text-primary-700 dark:text-primary-300 min-w-0 flex-1 truncate",children:n}),x&&jsxRuntime.jsx("span",{className:"ml-auto flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100 [@media(hover:none)]:opacity-100 [@media(hover:none)]:[&>button]:min-h-(--row-action-touch-min) [@media(hover:none)]:[&>button]:min-w-(--row-action-touch-min) [@media(hover:none)]:[&>button]:flex [@media(hover:none)]:[&>button]:items-center [@media(hover:none)]:[&>button]:justify-center",onClick:v=>v.stopPropagation(),children:x})]}),t&&jsxRuntime.jsx("div",{className:d("grid transition-[grid-template-rows] duration-200 ease-out",i?"grid-rows-[1fr]":"grid-rows-[0fr]"),children:jsxRuntime.jsx("div",{className:"overflow-hidden",children:jsxRuntime.jsx("ul",{className:d("ml-4 pl-2",h&&"border-primary-200 dark:border-primary-700 border-l"),role:"group",children:m})})})]})}exports.Tree=X;exports.TreeItem=Y;
@@ -1 +1 @@
1
- import u,{createContext,useState,useCallback,useContext}from'react';import {ChevronRight}from'lucide-react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {cva}from'class-variance-authority';import {jsx,Fragment,jsxs}from'react/jsx-runtime';function d(...s){return twMerge(clsx(s))}cva("w-full text-left text-sm",{variants:{intent:{default:"",striped:"[&_tbody_tr:nth-child(even)]:bg-primary-50 dark:[&_tbody_tr:nth-child(even)]:bg-primary-800/30",bordered:"[&_th]:border [&_td]:border [&_th]:border-primary-200 [&_td]:border-primary-200 dark:[&_th]:border-primary-700 dark:[&_td]:border-primary-700"},density:{compact:"[&_th]:px-2 [&_th]:py-1 [&_td]:px-2 [&_td]:py-1",default:"",relaxed:"[&_th]:px-6 [&_th]:py-5 [&_td]:px-6 [&_td]:py-5"}},defaultVariants:{intent:"default",density:"default"}});cva("text-sm text-primary-700 dark:text-primary-300",{variants:{intent:{default:"space-y-1",bordered:"divide-y divide-primary-200 rounded-lg border border-primary-200 dark:divide-primary-700 dark:border-primary-700 [&>li]:px-4 [&>li]:py-2",hover:"[&>li]:rounded-md [&>li]:px-3 [&>li]:py-2 [&>li]:transition-colors [&>li:hover]:bg-primary-50 dark:[&>li:hover]:bg-primary-800/50"}},defaultVariants:{intent:"default"}});cva("group flex w-full items-center gap-1.5 text-left [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3 [&_svg]:w-3",md:"py-1.5 text-sm [&_svg]:h-3.5 [&_svg]:w-3.5",lg:"py-2 text-base [&_svg]:h-4 [&_svg]:w-4"}},defaultVariants:{size:"md"}});var R=cva("flex cursor-pointer items-center gap-1 rounded transition-colors [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",md:"py-1 text-sm [&_svg]:h-4 [&_svg]:w-4",lg:"py-1.5 text-base [&_svg]:h-5 [&_svg]:w-5"}},defaultVariants:{size:"md"}});cva("overflow-x-auto rounded-lg font-mono [&_pre]:m-0 [&_pre]:p-4 [&_code]:bg-transparent",{variants:{size:{sm:"text-xs",md:"text-sm",lg:"text-base"}},defaultVariants:{size:"md"}});var T=createContext({showLines:true,expandedKeys:null,onToggleKey:()=>{},size:"md"});function X({showLines:s=true,showRoot:n=true,expandedKeys:e,defaultExpandedKeys:x="all",onExpandedKeysChange:g,size:f="md",className:p,children:m,...h}){let [y,l]=useState(()=>x),_=useCallback(o=>{if(e){let t=new Set(e);t.has(o)?t.delete(o):t.add(o),g?.(t);}else l(t=>{if(t==="all")return new Set(["__ALL_MINUS__",o]);let a=new Set(t);return a.has(o)?a.delete(o):a.add(o),a});},[e,g]),b=e??(y==="all"?null:y);return jsx(T.Provider,{value:{showLines:s,expandedKeys:b,onToggleKey:_,size:f},children:n?jsx("ul",{className:d("text-sm",p),role:"tree",...h,children:m}):jsx("ul",{className:d("text-sm",p),role:"tree",...h,children:jsx(E,{children:m})})})}function E({children:s}){let n=k(s);return jsx(Fragment,{children:n.map(e=>u.isValidElement(e)&&e.props.children?e.props.children:null)})}function k(s){let n=[];return u.Children.forEach(s,e=>{u.isValidElement(e)&&e.type===u.Fragment?n.push(...k(e.props.children)):n.push(e);}),n}function Y({nodeKey:s,label:n,icon:e,actions:x,defaultExpanded:g=false,expanded:f,onToggle:p,children:m,className:h}){let{showLines:y,expandedKeys:l,onToggleKey:w,size:_}=useContext(T),[b,o]=useState(g),t=u.Children.count(m)>0,a=s??(typeof n=="string"?n:""),i;f!=null?i=f:l!=null&&a?l.has("__ALL_MINUS__")?i=!l.has(a):i=l.has(a):i=b;let V=()=>{let v=!i;p?p(v):l!=null&&a?w(a):o(v);};return jsxs("li",{className:d("select-none",h),role:"treeitem","aria-expanded":t?i:void 0,children:[jsxs("div",{className:d("group hover:bg-primary-50 dark:hover:bg-primary-800/50 rounded-md px-1",R({size:_}),t?"cursor-pointer":"cursor-default"),onClick:t?V:void 0,children:[t?jsx(ChevronRight,{className:d("text-primary-400 h-4 w-4 shrink-0 transition-transform duration-200",i&&"rotate-90")}):jsx("span",{className:"w-4 shrink-0"}),e&&jsx("span",{className:"shrink-0",children:e}),jsx("span",{className:"text-primary-700 dark:text-primary-300 min-w-0 flex-1 truncate",children:n}),x&&jsx("span",{className:"ml-auto flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100 [@media(hover:none)]:opacity-100 [@media(hover:none)]:[&>button]:min-h-(--row-action-touch-min) [@media(hover:none)]:[&>button]:min-w-(--row-action-touch-min) [@media(hover:none)]:[&>button]:flex [@media(hover:none)]:[&>button]:items-center [@media(hover:none)]:[&>button]:justify-center",onClick:v=>v.stopPropagation(),children:x})]}),t&&jsx("div",{className:d("grid transition-[grid-template-rows] duration-200 ease-out",i?"grid-rows-[1fr]":"grid-rows-[0fr]"),children:jsx("div",{className:"overflow-hidden",children:jsx("ul",{className:d("ml-4 pl-2",y&&"border-primary-200 dark:border-primary-700 border-l"),role:"group",children:m})})})]})}export{X as Tree,Y as TreeItem};
1
+ import u,{createContext,useState,useCallback,useContext}from'react';import {ChevronRight}from'lucide-react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {cva}from'class-variance-authority';import {jsx,Fragment,jsxs}from'react/jsx-runtime';function d(...s){return twMerge(clsx(s))}cva("w-full text-left text-sm",{variants:{intent:{default:"",striped:"[&_tbody_tr:nth-child(even)]:bg-primary-50 dark:[&_tbody_tr:nth-child(even)]:bg-primary-800/30",bordered:"[&_th]:border [&_td]:border [&_th]:border-primary-200 [&_td]:border-primary-200 dark:[&_th]:border-primary-700 dark:[&_td]:border-primary-700"},density:{compact:"[&_th]:px-2 [&_th]:py-1 [&_td]:px-2 [&_td]:py-1",default:"",relaxed:"[&_th]:px-6 [&_th]:py-5 [&_td]:px-6 [&_td]:py-5"}},defaultVariants:{intent:"default",density:"default"}});cva("text-sm text-primary-700 dark:text-primary-300",{variants:{intent:{default:"space-y-1",bordered:"divide-y divide-primary-200 rounded-lg border border-primary-200 dark:divide-primary-700 dark:border-primary-700 [&>li]:px-4 [&>li]:py-2",hover:"[&>li]:rounded-md [&>li]:px-3 [&>li]:py-2 [&>li]:transition-colors [&>li:hover]:bg-primary-50 dark:[&>li:hover]:bg-primary-800/50"}},defaultVariants:{intent:"default"}});cva("group flex w-full items-center gap-1.5 text-left [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3 [&_svg]:w-3",md:"py-1.5 text-sm [&_svg]:h-3.5 [&_svg]:w-3.5",lg:"py-2 text-base [&_svg]:h-4 [&_svg]:w-4"}},defaultVariants:{size:"md"}});var R=cva("flex cursor-pointer items-center gap-1 rounded transition-colors [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",md:"py-1 text-sm [&_svg]:h-4 [&_svg]:w-4",lg:"py-1.5 text-base [&_svg]:h-5 [&_svg]:w-5"}},defaultVariants:{size:"md"}});cva("overflow-x-auto rounded-lg font-mono [background:var(--color-syntax-bg)] [&_pre]:m-0 [&_pre]:p-4 [&_code]:bg-transparent",{variants:{size:{sm:"text-xs",md:"text-sm",lg:"text-base"}},defaultVariants:{size:"md"}});var k=createContext({showLines:true,expandedKeys:null,onToggleKey:()=>{},size:"md"});function X({showLines:s=true,showRoot:n=true,expandedKeys:e,defaultExpandedKeys:x="all",onExpandedKeysChange:g,size:y="md",className:p,children:m,...f}){let [h,l]=useState(()=>x),_=useCallback(o=>{if(e){let t=new Set(e);t.has(o)?t.delete(o):t.add(o),g?.(t);}else l(t=>{if(t==="all")return new Set(["__ALL_MINUS__",o]);let a=new Set(t);return a.has(o)?a.delete(o):a.add(o),a});},[e,g]),b=e??(h==="all"?null:h);return jsx(k.Provider,{value:{showLines:s,expandedKeys:b,onToggleKey:_,size:y},children:n?jsx("ul",{className:d("text-sm",p),role:"tree",...f,children:m}):jsx("ul",{className:d("text-sm",p),role:"tree",...f,children:jsx(E,{children:m})})})}function E({children:s}){let n=T(s);return jsx(Fragment,{children:n.map(e=>u.isValidElement(e)&&e.props.children?e.props.children:null)})}function T(s){let n=[];return u.Children.forEach(s,e=>{u.isValidElement(e)&&e.type===u.Fragment?n.push(...T(e.props.children)):n.push(e);}),n}function Y({nodeKey:s,label:n,icon:e,actions:x,defaultExpanded:g=false,expanded:y,onToggle:p,children:m,className:f}){let{showLines:h,expandedKeys:l,onToggleKey:w,size:_}=useContext(k),[b,o]=useState(g),t=u.Children.count(m)>0,a=s??(typeof n=="string"?n:""),i;y!=null?i=y:l!=null&&a?l.has("__ALL_MINUS__")?i=!l.has(a):i=l.has(a):i=b;let V=()=>{let v=!i;p?p(v):l!=null&&a?w(a):o(v);};return jsxs("li",{className:d("select-none",f),role:"treeitem","aria-expanded":t?i:void 0,children:[jsxs("div",{className:d("group hover:bg-primary-50 dark:hover:bg-primary-800/50 rounded-md px-1",R({size:_}),t?"cursor-pointer":"cursor-default"),onClick:t?V:void 0,children:[t?jsx(ChevronRight,{className:d("text-primary-400 h-4 w-4 shrink-0 transition-transform duration-200",i&&"rotate-90")}):jsx("span",{className:"w-4 shrink-0"}),e&&jsx("span",{className:"shrink-0",children:e}),jsx("span",{className:"text-primary-700 dark:text-primary-300 min-w-0 flex-1 truncate",children:n}),x&&jsx("span",{className:"ml-auto flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100 [@media(hover:none)]:opacity-100 [@media(hover:none)]:[&>button]:min-h-(--row-action-touch-min) [@media(hover:none)]:[&>button]:min-w-(--row-action-touch-min) [@media(hover:none)]:[&>button]:flex [@media(hover:none)]:[&>button]:items-center [@media(hover:none)]:[&>button]:justify-center",onClick:v=>v.stopPropagation(),children:x})]}),t&&jsx("div",{className:d("grid transition-[grid-template-rows] duration-200 ease-out",i?"grid-rows-[1fr]":"grid-rows-[0fr]"),children:jsx("div",{className:"overflow-hidden",children:jsx("ul",{className:d("ml-4 pl-2",h&&"border-primary-200 dark:border-primary-700 border-l"),role:"group",children:m})})})]})}export{X as Tree,Y as TreeItem};
@@ -1,2 +1,2 @@
1
- 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var w=require('react');require('lucide-react');var clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),classVarianceAuthority=require('class-variance-authority'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var w__default=/*#__PURE__*/_interopDefault(w);function s(...e){return tailwindMerge.twMerge(clsx.clsx(e))}var I=classVarianceAuthority.cva("w-full text-left text-sm",{variants:{intent:{default:"",striped:"[&_tbody_tr:nth-child(even)]:bg-primary-50 dark:[&_tbody_tr:nth-child(even)]:bg-primary-800/30",bordered:"[&_th]:border [&_td]:border [&_th]:border-primary-200 [&_td]:border-primary-200 dark:[&_th]:border-primary-700 dark:[&_td]:border-primary-700"},density:{compact:"[&_th]:px-2 [&_th]:py-1 [&_td]:px-2 [&_td]:py-1",default:"",relaxed:"[&_th]:px-6 [&_th]:py-5 [&_td]:px-6 [&_td]:py-5"}},defaultVariants:{intent:"default",density:"default"}}),z=classVarianceAuthority.cva("text-sm text-primary-700 dark:text-primary-300",{variants:{intent:{default:"space-y-1",bordered:"divide-y divide-primary-200 rounded-lg border border-primary-200 dark:divide-primary-700 dark:border-primary-700 [&>li]:px-4 [&>li]:py-2",hover:"[&>li]:rounded-md [&>li]:px-3 [&>li]:py-2 [&>li]:transition-colors [&>li:hover]:bg-primary-50 dark:[&>li:hover]:bg-primary-800/50"}},defaultVariants:{intent:"default"}});classVarianceAuthority.cva("group flex w-full items-center gap-1.5 text-left [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3 [&_svg]:w-3",md:"py-1.5 text-sm [&_svg]:h-3.5 [&_svg]:w-3.5",lg:"py-2 text-base [&_svg]:h-4 [&_svg]:w-4"}},defaultVariants:{size:"md"}});classVarianceAuthority.cva("flex cursor-pointer items-center gap-1 rounded transition-colors [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",md:"py-1 text-sm [&_svg]:h-4 [&_svg]:w-4",lg:"py-1.5 text-base [&_svg]:h-5 [&_svg]:w-5"}},defaultVariants:{size:"md"}});var R=classVarianceAuthority.cva("overflow-x-auto rounded-lg font-mono [&_pre]:m-0 [&_pre]:p-4 [&_code]:bg-transparent",{variants:{size:{sm:"text-xs",md:"text-sm",lg:"text-base"}},defaultVariants:{size:"md"}});function S({intent:e,density:t,className:r,...i}){return jsxRuntime.jsx("div",{className:"w-full overflow-auto",children:jsxRuntime.jsx("table",{className:s(I({intent:e,density:t}),r),...i})})}var Y=w.createContext({size:"md"});function _({intent:e,size:t="md",className:r,...i}){return jsxRuntime.jsx(Y.Provider,{value:{size:t},children:jsxRuntime.jsx("ul",{className:s(z({intent:e}),r),...i})})}var re=w.createContext({showLines:true,expandedKeys:null,onToggleKey:()=>{},size:"md"});function K({showLines:e=true,showRoot:t=true,expandedKeys:r,defaultExpandedKeys:i="all",onExpandedKeysChange:a,size:l="md",className:c,children:f,...u}){let [T,b]=w.useState(()=>i),x=w.useCallback(p=>{if(r){let m=new Set(r);m.has(p)?m.delete(p):m.add(p),a?.(m);}else b(m=>{if(m==="all")return new Set(["__ALL_MINUS__",p]);let g=new Set(m);return g.has(p)?g.delete(p):g.add(p),g});},[r,a]),C=r??(T==="all"?null:T);return jsxRuntime.jsx(re.Provider,{value:{showLines:e,expandedKeys:C,onToggleKey:x,size:l},children:t?jsxRuntime.jsx("ul",{className:s("text-sm",c),role:"tree",...u,children:f}):jsxRuntime.jsx("ul",{className:s("text-sm",c),role:"tree",...u,children:jsxRuntime.jsx(ae,{children:f})})})}function ae({children:e}){let t=j(e);return jsxRuntime.jsx(jsxRuntime.Fragment,{children:t.map(r=>w__default.default.isValidElement(r)&&r.props.children?r.props.children:null)})}function j(e){let t=[];return w__default.default.Children.forEach(e,r=>{w__default.default.isValidElement(r)&&r.type===w__default.default.Fragment?t.push(...j(r.props.children)):t.push(r);}),t}function ie({avatar:e,sender:t}){return e?typeof e=="string"?/^(?:https?|data|blob):/.test(e)?jsxRuntime.jsx("img",{src:e,alt:t,className:"h-8 w-8 shrink-0 rounded-full object-cover",draggable:false}):jsxRuntime.jsx("div",{className:"bg-primary-200 text-primary-600 dark:bg-primary-700 dark:text-primary-300 flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-lg select-none",children:e}):jsxRuntime.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full",children:e}):jsxRuntime.jsx("div",{className:"bg-primary-200 text-primary-600 dark:bg-primary-700 dark:text-primary-300 flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-sm font-semibold select-none",children:t.charAt(0).toUpperCase()})}function le({msg:e,alignRight:t}){return jsxRuntime.jsxs("div",{className:s("flex gap-2.5",t?"flex-row-reverse":"flex-row"),children:[jsxRuntime.jsx(ie,{avatar:e.avatar,sender:e.sender}),jsxRuntime.jsxs("div",{className:s("flex max-w-[75%] flex-col gap-0.5",t?"items-end":"items-start"),children:[jsxRuntime.jsx("span",{className:"text-primary-500 dark:text-primary-400 text-xs",children:e.sender}),jsxRuntime.jsx("div",{className:s("rounded-xl px-3 py-2 text-sm leading-relaxed",t?"rounded-tr-sm bg-primary-500 text-white dark:bg-primary-600":"bg-primary-100 text-primary-800 dark:bg-primary-800 dark:text-primary-200 rounded-tl-sm"),children:e.content}),e.time&&jsxRuntime.jsx("span",{className:"text-primary-400 dark:text-primary-500 text-[10px]",children:e.time})]})]})}function P({messages:e,mode:t="split",autoScroll:r=true,className:i,...a}){let l=w.useRef(null);return w.useEffect(()=>{r&&l.current?.scrollIntoView({behavior:"smooth"});},[e,r]),jsxRuntime.jsxs("div",{className:s("flex flex-col gap-4 overflow-y-auto rounded-lg border p-4","border-primary-200 dark:border-primary-700 dark:bg-primary-900 bg-white",i),...a,children:[e.map(c=>{let f=t==="split"&&!!c.self;return jsxRuntime.jsx(le,{msg:c,alignRight:f},c.id)}),jsxRuntime.jsx("div",{ref:l})]})}var pe={name:"onyx-css-vars",type:"dark",settings:[{settings:{foreground:"var(--color-syntax-plain)",background:"var(--color-syntax-bg)"}},{scope:["comment","punctuation.definition.comment"],settings:{foreground:"var(--color-syntax-comment)",fontStyle:"italic"}},{scope:["keyword","keyword.control","keyword.operator.new","keyword.operator.expression","storage.type","storage.modifier"],settings:{foreground:"var(--color-syntax-keyword)"}},{scope:["string","string.quoted","string.template"],settings:{foreground:"var(--color-syntax-string)"}},{scope:["entity.name.function","support.function","meta.function-call"],settings:{foreground:"var(--color-syntax-function)"}},{scope:["variable","variable.other","variable.parameter","meta.definition.variable"],settings:{foreground:"var(--color-syntax-variable)"}},{scope:["constant.numeric","constant.language"],settings:{foreground:"var(--color-syntax-number)"}},{scope:["keyword.operator","keyword.operator.assignment","keyword.operator.comparison","keyword.operator.arithmetic"],settings:{foreground:"var(--color-syntax-operator)"}},{scope:["entity.name.tag","punctuation.definition.tag","support.class.component"],settings:{foreground:"var(--color-syntax-tag)"}},{scope:["entity.other.attribute-name","meta.tag.attributes"],settings:{foreground:"var(--color-syntax-attr)"}},{scope:["punctuation","meta.brace","punctuation.definition.block","punctuation.separator","punctuation.terminator"],settings:{foreground:"var(--color-syntax-punctuation)"}},{scope:["entity.name.type","support.type","support.class","entity.other.inherited-class"],settings:{foreground:"var(--color-syntax-type)"}}]},me={typescript:()=>import('@shikijs/langs/typescript'),javascript:()=>import('@shikijs/langs/javascript'),tsx:()=>import('@shikijs/langs/tsx'),jsx:()=>import('@shikijs/langs/jsx'),html:()=>import('@shikijs/langs/html'),css:()=>import('@shikijs/langs/css'),json:()=>import('@shikijs/langs/json'),markdown:()=>import('@shikijs/langs/markdown'),python:()=>import('@shikijs/langs/python'),rust:()=>import('@shikijs/langs/rust'),go:()=>import('@shikijs/langs/go'),java:()=>import('@shikijs/langs/java'),c:()=>import('@shikijs/langs/c'),cpp:()=>import('@shikijs/langs/cpp'),csharp:()=>import('@shikijs/langs/csharp'),vue:()=>import('@shikijs/langs/vue'),xml:()=>import('@shikijs/langs/xml'),yaml:()=>import('@shikijs/langs/yaml'),sql:()=>import('@shikijs/langs/sql'),bash:()=>import('@shikijs/langs/bash'),shell:()=>import('@shikijs/langs/shell')},V=null,U=new Set;function ue(){return V||(V=Promise.all([import('shiki/core'),import('shiki/engine/javascript')]).then(([{createHighlighterCore:e},{createJavaScriptRegexEngine:t}])=>e({themes:[pe],langs:[],engine:t()}))),V}async function ye(e,t,r){let i=await ue();if(t&&!U.has(t)){let l=me[t];if(l)try{let c=await l();await i.loadLanguage(c.default??c),U.add(t);}catch{t="text";}else t="text";}let a=i.codeToHtml(e,{lang:t||"text",theme:"onyx-css-vars"});if(a=a.replace(/(<pre [^>]*style=")/,"$1line-height:1.7;tab-size:2;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;"),r){let l=0;a=a.replace(/<span class="line">/g,()=>(l++,`<span class="line"><span class="line-number" data-line="${l}"></span>`));}return a}function M({code:e,language:t="text",lineNumbers:r=false,editable:i=false,onCodeChange:a,size:l,className:c,...f}){let[u,T]=w.useState(""),b=w.useRef(null),N=w.useRef(null),x=w.useRef(null);w.useEffect(()=>{let n=false;return ye(e,t,i?false:r).then(o=>{n||T(o);}),()=>{n=true;}},[e,t,r,i]);let C=w.useCallback(()=>{let n=N.current,o=x.current?.querySelector("pre"),h=b.current?.querySelector("[data-gutter]");n&&o&&(o.scrollTop=n.scrollTop,o.scrollLeft=n.scrollLeft),n&&h&&(h.scrollTop=n.scrollTop);},[]),p=w.useCallback(n=>{a?.(n.target.value);},[a]),m=w.useCallback(n=>{if(n.key==="Tab"){n.preventDefault();let o=n.currentTarget,h=o.selectionStart,$=o.selectionEnd,G=o.value.substring(0,h)+" "+o.value.substring($);a?.(G),requestAnimationFrame(()=>{o.selectionStart=o.selectionEnd=h+2;});}},[a]),g=r&&"[&_.line-number]:inline-block [&_.line-number]:w-8 [&_.line-number]:mr-4 [&_.line-number]:text-right [&_.line-number]:text-secondary-400 [&_.line-number]:select-none [&_.line-number]:before:content-[attr(data-line)]",D="ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",A=1.7,O=e.split(`
2
- `).length;return i?jsxRuntime.jsxs("div",{ref:b,className:s(R({size:l}),"flex border border-primary-200 dark:border-primary-700",c),style:{background:"var(--color-syntax-bg)"},...f,children:[r&&jsxRuntime.jsx("div",{"data-gutter":true,"aria-hidden":true,className:"shrink-0 select-none overflow-hidden py-4 pl-3 pr-1 text-right text-secondary-400",style:{fontFamily:D,lineHeight:A,width:"3rem"},children:Array.from({length:O},(n,o)=>jsxRuntime.jsx("div",{children:o+1},o))}),jsxRuntime.jsxs("div",{className:"relative min-w-0 flex-1",children:[jsxRuntime.jsx("textarea",{ref:N,value:e,onChange:p,onScroll:C,onKeyDown:m,spellCheck:false,autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",className:"relative z-2 m-0 block h-full w-full resize-none overflow-auto whitespace-pre border-none bg-transparent p-4 text-transparent caret-primary-600 outline-none dark:caret-primary-400",style:{fontFamily:D,lineHeight:A,tabSize:2,minHeight:"6rem"}}),jsxRuntime.jsx("div",{ref:x,"aria-hidden":true,className:"pointer-events-none absolute inset-0 z-1 overflow-hidden [&_pre]:m-0 [&_pre]:h-full [&_pre]:overflow-hidden [&_pre]:p-4 [&_code]:bg-transparent",dangerouslySetInnerHTML:u?{__html:u}:void 0})]})]}):jsxRuntime.jsx("div",{ref:b,className:s(R({size:l}),"border border-primary-200 dark:border-primary-700",g,c),...f,children:jsxRuntime.jsx("div",{ref:x,className:"[&_pre]:m-0 [&_pre]:p-4",dangerouslySetInnerHTML:u?{__html:u}:void 0,children:u?void 0:jsxRuntime.jsx("pre",{className:"m-0 p-4",style:{background:"var(--color-syntax-bg)"},children:jsxRuntime.jsx("code",{children:e})})})})}var fe={Table:S,List:_,Tree:K,Chat:P,CodeBlock:M},Tt=fe;exports.Chat=P;exports.CodeBlock=M;exports.DataDisplay=fe;exports.List=_;exports.Table=S;exports.Tree=K;exports.default=Tt;
1
+ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var w=require('react');require('lucide-react');var clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),classVarianceAuthority=require('class-variance-authority'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var w__default=/*#__PURE__*/_interopDefault(w);function s(...e){return tailwindMerge.twMerge(clsx.clsx(e))}var I=classVarianceAuthority.cva("w-full text-left text-sm",{variants:{intent:{default:"",striped:"[&_tbody_tr:nth-child(even)]:bg-primary-50 dark:[&_tbody_tr:nth-child(even)]:bg-primary-800/30",bordered:"[&_th]:border [&_td]:border [&_th]:border-primary-200 [&_td]:border-primary-200 dark:[&_th]:border-primary-700 dark:[&_td]:border-primary-700"},density:{compact:"[&_th]:px-2 [&_th]:py-1 [&_td]:px-2 [&_td]:py-1",default:"",relaxed:"[&_th]:px-6 [&_th]:py-5 [&_td]:px-6 [&_td]:py-5"}},defaultVariants:{intent:"default",density:"default"}}),z=classVarianceAuthority.cva("text-sm text-primary-700 dark:text-primary-300",{variants:{intent:{default:"space-y-1",bordered:"divide-y divide-primary-200 rounded-lg border border-primary-200 dark:divide-primary-700 dark:border-primary-700 [&>li]:px-4 [&>li]:py-2",hover:"[&>li]:rounded-md [&>li]:px-3 [&>li]:py-2 [&>li]:transition-colors [&>li:hover]:bg-primary-50 dark:[&>li:hover]:bg-primary-800/50"}},defaultVariants:{intent:"default"}});classVarianceAuthority.cva("group flex w-full items-center gap-1.5 text-left [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3 [&_svg]:w-3",md:"py-1.5 text-sm [&_svg]:h-3.5 [&_svg]:w-3.5",lg:"py-2 text-base [&_svg]:h-4 [&_svg]:w-4"}},defaultVariants:{size:"md"}});classVarianceAuthority.cva("flex cursor-pointer items-center gap-1 rounded transition-colors [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",md:"py-1 text-sm [&_svg]:h-4 [&_svg]:w-4",lg:"py-1.5 text-base [&_svg]:h-5 [&_svg]:w-5"}},defaultVariants:{size:"md"}});var R=classVarianceAuthority.cva("overflow-x-auto rounded-lg font-mono [background:var(--color-syntax-bg)] [&_pre]:m-0 [&_pre]:p-4 [&_code]:bg-transparent",{variants:{size:{sm:"text-xs",md:"text-sm",lg:"text-base"}},defaultVariants:{size:"md"}});function S({intent:e,density:t,className:r,...i}){return jsxRuntime.jsx("div",{className:"w-full overflow-auto",children:jsxRuntime.jsx("table",{className:s(I({intent:e,density:t}),r),...i})})}var Y=w.createContext({size:"md"});function _({intent:e,size:t="md",className:r,...i}){return jsxRuntime.jsx(Y.Provider,{value:{size:t},children:jsxRuntime.jsx("ul",{className:s(z({intent:e}),r),...i})})}var re=w.createContext({showLines:true,expandedKeys:null,onToggleKey:()=>{},size:"md"});function K({showLines:e=true,showRoot:t=true,expandedKeys:r,defaultExpandedKeys:i="all",onExpandedKeysChange:a,size:l="md",className:c,children:f,...u}){let [T,b]=w.useState(()=>i),x=w.useCallback(p=>{if(r){let m=new Set(r);m.has(p)?m.delete(p):m.add(p),a?.(m);}else b(m=>{if(m==="all")return new Set(["__ALL_MINUS__",p]);let g=new Set(m);return g.has(p)?g.delete(p):g.add(p),g});},[r,a]),C=r??(T==="all"?null:T);return jsxRuntime.jsx(re.Provider,{value:{showLines:e,expandedKeys:C,onToggleKey:x,size:l},children:t?jsxRuntime.jsx("ul",{className:s("text-sm",c),role:"tree",...u,children:f}):jsxRuntime.jsx("ul",{className:s("text-sm",c),role:"tree",...u,children:jsxRuntime.jsx(ae,{children:f})})})}function ae({children:e}){let t=j(e);return jsxRuntime.jsx(jsxRuntime.Fragment,{children:t.map(r=>w__default.default.isValidElement(r)&&r.props.children?r.props.children:null)})}function j(e){let t=[];return w__default.default.Children.forEach(e,r=>{w__default.default.isValidElement(r)&&r.type===w__default.default.Fragment?t.push(...j(r.props.children)):t.push(r);}),t}function ie({avatar:e,sender:t}){return e?typeof e=="string"?/^(?:https?|data|blob):/.test(e)?jsxRuntime.jsx("img",{src:e,alt:t,className:"h-8 w-8 shrink-0 rounded-full object-cover",draggable:false}):jsxRuntime.jsx("div",{className:"bg-primary-200 text-primary-600 dark:bg-primary-700 dark:text-primary-300 flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-lg select-none",children:e}):jsxRuntime.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full",children:e}):jsxRuntime.jsx("div",{className:"bg-primary-200 text-primary-600 dark:bg-primary-700 dark:text-primary-300 flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-sm font-semibold select-none",children:t.charAt(0).toUpperCase()})}function le({msg:e,alignRight:t}){return jsxRuntime.jsxs("div",{className:s("flex gap-2.5",t?"flex-row-reverse":"flex-row"),children:[jsxRuntime.jsx(ie,{avatar:e.avatar,sender:e.sender}),jsxRuntime.jsxs("div",{className:s("flex max-w-[75%] flex-col gap-0.5",t?"items-end":"items-start"),children:[jsxRuntime.jsx("span",{className:"text-primary-500 dark:text-primary-400 text-xs",children:e.sender}),jsxRuntime.jsx("div",{className:s("rounded-xl px-3 py-2 text-sm leading-relaxed",t?"rounded-tr-sm bg-primary-500 text-white dark:bg-primary-600":"bg-primary-100 text-primary-800 dark:bg-primary-800 dark:text-primary-200 rounded-tl-sm"),children:e.content}),e.time&&jsxRuntime.jsx("span",{className:"text-primary-400 dark:text-primary-500 text-[10px]",children:e.time})]})]})}function P({messages:e,mode:t="split",autoScroll:r=true,className:i,...a}){let l=w.useRef(null);return w.useEffect(()=>{r&&l.current?.scrollIntoView({behavior:"smooth"});},[e,r]),jsxRuntime.jsxs("div",{className:s("flex flex-col gap-4 overflow-y-auto rounded-lg border p-4","border-primary-200 dark:border-primary-700 dark:bg-primary-900 bg-white",i),...a,children:[e.map(c=>{let f=t==="split"&&!!c.self;return jsxRuntime.jsx(le,{msg:c,alignRight:f},c.id)}),jsxRuntime.jsx("div",{ref:l})]})}var pe={name:"onyx-css-vars",type:"dark",settings:[{settings:{foreground:"var(--color-syntax-plain)",background:"var(--color-syntax-bg)"}},{scope:["comment","punctuation.definition.comment"],settings:{foreground:"var(--color-syntax-comment)",fontStyle:"italic"}},{scope:["keyword","keyword.control","keyword.operator.new","keyword.operator.expression","storage.type","storage.modifier"],settings:{foreground:"var(--color-syntax-keyword)"}},{scope:["string","string.quoted","string.template"],settings:{foreground:"var(--color-syntax-string)"}},{scope:["entity.name.function","support.function","meta.function-call"],settings:{foreground:"var(--color-syntax-function)"}},{scope:["variable","variable.other","variable.parameter","meta.definition.variable"],settings:{foreground:"var(--color-syntax-variable)"}},{scope:["constant.numeric","constant.language"],settings:{foreground:"var(--color-syntax-number)"}},{scope:["keyword.operator","keyword.operator.assignment","keyword.operator.comparison","keyword.operator.arithmetic"],settings:{foreground:"var(--color-syntax-operator)"}},{scope:["entity.name.tag","punctuation.definition.tag","support.class.component"],settings:{foreground:"var(--color-syntax-tag)"}},{scope:["entity.other.attribute-name","meta.tag.attributes"],settings:{foreground:"var(--color-syntax-attr)"}},{scope:["punctuation","meta.brace","punctuation.definition.block","punctuation.separator","punctuation.terminator"],settings:{foreground:"var(--color-syntax-punctuation)"}},{scope:["entity.name.type","support.type","support.class","entity.other.inherited-class"],settings:{foreground:"var(--color-syntax-type)"}}]},me={typescript:()=>import('@shikijs/langs/typescript'),javascript:()=>import('@shikijs/langs/javascript'),tsx:()=>import('@shikijs/langs/tsx'),jsx:()=>import('@shikijs/langs/jsx'),html:()=>import('@shikijs/langs/html'),css:()=>import('@shikijs/langs/css'),json:()=>import('@shikijs/langs/json'),markdown:()=>import('@shikijs/langs/markdown'),python:()=>import('@shikijs/langs/python'),rust:()=>import('@shikijs/langs/rust'),go:()=>import('@shikijs/langs/go'),java:()=>import('@shikijs/langs/java'),c:()=>import('@shikijs/langs/c'),cpp:()=>import('@shikijs/langs/cpp'),csharp:()=>import('@shikijs/langs/csharp'),vue:()=>import('@shikijs/langs/vue'),xml:()=>import('@shikijs/langs/xml'),yaml:()=>import('@shikijs/langs/yaml'),sql:()=>import('@shikijs/langs/sql'),bash:()=>import('@shikijs/langs/bash'),shell:()=>import('@shikijs/langs/shell')},V=null,U=new Set;function ue(){return V||(V=Promise.all([import('shiki/core'),import('shiki/engine/javascript')]).then(([{createHighlighterCore:e},{createJavaScriptRegexEngine:t}])=>e({themes:[pe],langs:[],engine:t()}))),V}async function ye(e,t,r){let i=await ue();if(t&&!U.has(t)){let l=me[t];if(l)try{let c=await l();await i.loadLanguage(c.default??c),U.add(t);}catch{t="text";}else t="text";}let a=i.codeToHtml(e,{lang:t||"text",theme:"onyx-css-vars"});if(a=a.replace(/(<pre [^>]*style=")/,"$1line-height:1.7;tab-size:2;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;"),r){let l=0;a=a.replace(/<span class="line">/g,()=>(l++,`<span class="line"><span class="line-number" data-line="${l}"></span>`));}return a}function M({code:e,language:t="text",lineNumbers:r=false,editable:i=false,onCodeChange:a,size:l,className:c,...f}){let[u,T]=w.useState(""),b=w.useRef(null),N=w.useRef(null),x=w.useRef(null);w.useEffect(()=>{let n=false;return ye(e,t,i?false:r).then(o=>{n||T(o);}),()=>{n=true;}},[e,t,r,i]);let C=w.useCallback(()=>{let n=N.current,o=x.current?.querySelector("pre"),h=b.current?.querySelector("[data-gutter]");n&&o&&(o.scrollTop=n.scrollTop,o.scrollLeft=n.scrollLeft),n&&h&&(h.scrollTop=n.scrollTop);},[]),p=w.useCallback(n=>{a?.(n.target.value);},[a]),m=w.useCallback(n=>{if(n.key==="Tab"){n.preventDefault();let o=n.currentTarget,h=o.selectionStart,$=o.selectionEnd,G=o.value.substring(0,h)+" "+o.value.substring($);a?.(G),requestAnimationFrame(()=>{o.selectionStart=o.selectionEnd=h+2;});}},[a]),g=r&&"[&_.line-number]:inline-block [&_.line-number]:w-8 [&_.line-number]:mr-4 [&_.line-number]:text-right [&_.line-number]:text-secondary-400 [&_.line-number]:select-none [&_.line-number]:before:content-[attr(data-line)]",D="ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",A=1.7,O=e.split(`
2
+ `).length;return i?jsxRuntime.jsxs("div",{ref:b,className:s(R({size:l}),"flex border border-primary-200 dark:border-primary-700",c),style:{background:"var(--color-syntax-bg)"},...f,children:[r&&jsxRuntime.jsx("div",{"data-gutter":true,"aria-hidden":true,className:"shrink-0 select-none overflow-hidden py-4 pl-3 pr-1 text-right text-secondary-400",style:{fontFamily:D,lineHeight:A,width:"3rem"},children:Array.from({length:O},(n,o)=>jsxRuntime.jsx("div",{children:o+1},o))}),jsxRuntime.jsxs("div",{className:"relative min-w-0 flex-1",children:[jsxRuntime.jsx("textarea",{ref:N,value:e,onChange:p,onScroll:C,onKeyDown:m,spellCheck:false,autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",className:"relative z-2 m-0 block h-full w-full resize-none overflow-auto whitespace-pre border-none bg-transparent p-4 text-transparent caret-primary-600 outline-none dark:caret-primary-400",style:{fontFamily:D,lineHeight:A,tabSize:2,minHeight:"6rem"}}),jsxRuntime.jsx("div",{ref:x,"aria-hidden":true,className:"pointer-events-none absolute inset-0 z-1 overflow-hidden [&_pre]:m-0 [&_pre]:h-full [&_pre]:overflow-hidden [&_pre]:p-4 [&_code]:bg-transparent",dangerouslySetInnerHTML:u?{__html:u}:void 0})]})]}):jsxRuntime.jsx("div",{ref:b,className:s(R({size:l}),"border border-primary-200 dark:border-primary-700",g,c),style:{background:"var(--color-syntax-bg)"},...f,children:jsxRuntime.jsx("div",{ref:x,className:"[&_pre]:m-0 [&_pre]:p-4",dangerouslySetInnerHTML:u?{__html:u}:void 0,children:u?void 0:jsxRuntime.jsx("pre",{className:"m-0 p-4",style:{background:"var(--color-syntax-bg)"},children:jsxRuntime.jsx("code",{children:e})})})})}var fe={Table:S,List:_,Tree:K,Chat:P,CodeBlock:M},Tt=fe;exports.Chat=P;exports.CodeBlock=M;exports.DataDisplay=fe;exports.List=_;exports.Table=S;exports.Tree=K;exports.default=Tt;
@@ -1,2 +1,2 @@
1
- import w,{createContext,useState,useCallback,useRef,useEffect}from'react';import'lucide-react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {cva}from'class-variance-authority';import {jsx,Fragment,jsxs}from'react/jsx-runtime';function s(...e){return twMerge(clsx(e))}var I=cva("w-full text-left text-sm",{variants:{intent:{default:"",striped:"[&_tbody_tr:nth-child(even)]:bg-primary-50 dark:[&_tbody_tr:nth-child(even)]:bg-primary-800/30",bordered:"[&_th]:border [&_td]:border [&_th]:border-primary-200 [&_td]:border-primary-200 dark:[&_th]:border-primary-700 dark:[&_td]:border-primary-700"},density:{compact:"[&_th]:px-2 [&_th]:py-1 [&_td]:px-2 [&_td]:py-1",default:"",relaxed:"[&_th]:px-6 [&_th]:py-5 [&_td]:px-6 [&_td]:py-5"}},defaultVariants:{intent:"default",density:"default"}}),z=cva("text-sm text-primary-700 dark:text-primary-300",{variants:{intent:{default:"space-y-1",bordered:"divide-y divide-primary-200 rounded-lg border border-primary-200 dark:divide-primary-700 dark:border-primary-700 [&>li]:px-4 [&>li]:py-2",hover:"[&>li]:rounded-md [&>li]:px-3 [&>li]:py-2 [&>li]:transition-colors [&>li:hover]:bg-primary-50 dark:[&>li:hover]:bg-primary-800/50"}},defaultVariants:{intent:"default"}});cva("group flex w-full items-center gap-1.5 text-left [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3 [&_svg]:w-3",md:"py-1.5 text-sm [&_svg]:h-3.5 [&_svg]:w-3.5",lg:"py-2 text-base [&_svg]:h-4 [&_svg]:w-4"}},defaultVariants:{size:"md"}});cva("flex cursor-pointer items-center gap-1 rounded transition-colors [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",md:"py-1 text-sm [&_svg]:h-4 [&_svg]:w-4",lg:"py-1.5 text-base [&_svg]:h-5 [&_svg]:w-5"}},defaultVariants:{size:"md"}});var R=cva("overflow-x-auto rounded-lg font-mono [&_pre]:m-0 [&_pre]:p-4 [&_code]:bg-transparent",{variants:{size:{sm:"text-xs",md:"text-sm",lg:"text-base"}},defaultVariants:{size:"md"}});function S({intent:e,density:t,className:r,...i}){return jsx("div",{className:"w-full overflow-auto",children:jsx("table",{className:s(I({intent:e,density:t}),r),...i})})}var Y=createContext({size:"md"});function _({intent:e,size:t="md",className:r,...i}){return jsx(Y.Provider,{value:{size:t},children:jsx("ul",{className:s(z({intent:e}),r),...i})})}var re=createContext({showLines:true,expandedKeys:null,onToggleKey:()=>{},size:"md"});function K({showLines:e=true,showRoot:t=true,expandedKeys:r,defaultExpandedKeys:i="all",onExpandedKeysChange:a,size:l="md",className:c,children:f,...u}){let [T,b]=useState(()=>i),x=useCallback(p=>{if(r){let m=new Set(r);m.has(p)?m.delete(p):m.add(p),a?.(m);}else b(m=>{if(m==="all")return new Set(["__ALL_MINUS__",p]);let g=new Set(m);return g.has(p)?g.delete(p):g.add(p),g});},[r,a]),C=r??(T==="all"?null:T);return jsx(re.Provider,{value:{showLines:e,expandedKeys:C,onToggleKey:x,size:l},children:t?jsx("ul",{className:s("text-sm",c),role:"tree",...u,children:f}):jsx("ul",{className:s("text-sm",c),role:"tree",...u,children:jsx(ae,{children:f})})})}function ae({children:e}){let t=j(e);return jsx(Fragment,{children:t.map(r=>w.isValidElement(r)&&r.props.children?r.props.children:null)})}function j(e){let t=[];return w.Children.forEach(e,r=>{w.isValidElement(r)&&r.type===w.Fragment?t.push(...j(r.props.children)):t.push(r);}),t}function ie({avatar:e,sender:t}){return e?typeof e=="string"?/^(?:https?|data|blob):/.test(e)?jsx("img",{src:e,alt:t,className:"h-8 w-8 shrink-0 rounded-full object-cover",draggable:false}):jsx("div",{className:"bg-primary-200 text-primary-600 dark:bg-primary-700 dark:text-primary-300 flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-lg select-none",children:e}):jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full",children:e}):jsx("div",{className:"bg-primary-200 text-primary-600 dark:bg-primary-700 dark:text-primary-300 flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-sm font-semibold select-none",children:t.charAt(0).toUpperCase()})}function le({msg:e,alignRight:t}){return jsxs("div",{className:s("flex gap-2.5",t?"flex-row-reverse":"flex-row"),children:[jsx(ie,{avatar:e.avatar,sender:e.sender}),jsxs("div",{className:s("flex max-w-[75%] flex-col gap-0.5",t?"items-end":"items-start"),children:[jsx("span",{className:"text-primary-500 dark:text-primary-400 text-xs",children:e.sender}),jsx("div",{className:s("rounded-xl px-3 py-2 text-sm leading-relaxed",t?"rounded-tr-sm bg-primary-500 text-white dark:bg-primary-600":"bg-primary-100 text-primary-800 dark:bg-primary-800 dark:text-primary-200 rounded-tl-sm"),children:e.content}),e.time&&jsx("span",{className:"text-primary-400 dark:text-primary-500 text-[10px]",children:e.time})]})]})}function P({messages:e,mode:t="split",autoScroll:r=true,className:i,...a}){let l=useRef(null);return useEffect(()=>{r&&l.current?.scrollIntoView({behavior:"smooth"});},[e,r]),jsxs("div",{className:s("flex flex-col gap-4 overflow-y-auto rounded-lg border p-4","border-primary-200 dark:border-primary-700 dark:bg-primary-900 bg-white",i),...a,children:[e.map(c=>{let f=t==="split"&&!!c.self;return jsx(le,{msg:c,alignRight:f},c.id)}),jsx("div",{ref:l})]})}var pe={name:"onyx-css-vars",type:"dark",settings:[{settings:{foreground:"var(--color-syntax-plain)",background:"var(--color-syntax-bg)"}},{scope:["comment","punctuation.definition.comment"],settings:{foreground:"var(--color-syntax-comment)",fontStyle:"italic"}},{scope:["keyword","keyword.control","keyword.operator.new","keyword.operator.expression","storage.type","storage.modifier"],settings:{foreground:"var(--color-syntax-keyword)"}},{scope:["string","string.quoted","string.template"],settings:{foreground:"var(--color-syntax-string)"}},{scope:["entity.name.function","support.function","meta.function-call"],settings:{foreground:"var(--color-syntax-function)"}},{scope:["variable","variable.other","variable.parameter","meta.definition.variable"],settings:{foreground:"var(--color-syntax-variable)"}},{scope:["constant.numeric","constant.language"],settings:{foreground:"var(--color-syntax-number)"}},{scope:["keyword.operator","keyword.operator.assignment","keyword.operator.comparison","keyword.operator.arithmetic"],settings:{foreground:"var(--color-syntax-operator)"}},{scope:["entity.name.tag","punctuation.definition.tag","support.class.component"],settings:{foreground:"var(--color-syntax-tag)"}},{scope:["entity.other.attribute-name","meta.tag.attributes"],settings:{foreground:"var(--color-syntax-attr)"}},{scope:["punctuation","meta.brace","punctuation.definition.block","punctuation.separator","punctuation.terminator"],settings:{foreground:"var(--color-syntax-punctuation)"}},{scope:["entity.name.type","support.type","support.class","entity.other.inherited-class"],settings:{foreground:"var(--color-syntax-type)"}}]},me={typescript:()=>import('@shikijs/langs/typescript'),javascript:()=>import('@shikijs/langs/javascript'),tsx:()=>import('@shikijs/langs/tsx'),jsx:()=>import('@shikijs/langs/jsx'),html:()=>import('@shikijs/langs/html'),css:()=>import('@shikijs/langs/css'),json:()=>import('@shikijs/langs/json'),markdown:()=>import('@shikijs/langs/markdown'),python:()=>import('@shikijs/langs/python'),rust:()=>import('@shikijs/langs/rust'),go:()=>import('@shikijs/langs/go'),java:()=>import('@shikijs/langs/java'),c:()=>import('@shikijs/langs/c'),cpp:()=>import('@shikijs/langs/cpp'),csharp:()=>import('@shikijs/langs/csharp'),vue:()=>import('@shikijs/langs/vue'),xml:()=>import('@shikijs/langs/xml'),yaml:()=>import('@shikijs/langs/yaml'),sql:()=>import('@shikijs/langs/sql'),bash:()=>import('@shikijs/langs/bash'),shell:()=>import('@shikijs/langs/shell')},V=null,U=new Set;function ue(){return V||(V=Promise.all([import('shiki/core'),import('shiki/engine/javascript')]).then(([{createHighlighterCore:e},{createJavaScriptRegexEngine:t}])=>e({themes:[pe],langs:[],engine:t()}))),V}async function ye(e,t,r){let i=await ue();if(t&&!U.has(t)){let l=me[t];if(l)try{let c=await l();await i.loadLanguage(c.default??c),U.add(t);}catch{t="text";}else t="text";}let a=i.codeToHtml(e,{lang:t||"text",theme:"onyx-css-vars"});if(a=a.replace(/(<pre [^>]*style=")/,"$1line-height:1.7;tab-size:2;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;"),r){let l=0;a=a.replace(/<span class="line">/g,()=>(l++,`<span class="line"><span class="line-number" data-line="${l}"></span>`));}return a}function M({code:e,language:t="text",lineNumbers:r=false,editable:i=false,onCodeChange:a,size:l,className:c,...f}){let[u,T]=useState(""),b=useRef(null),N=useRef(null),x=useRef(null);useEffect(()=>{let n=false;return ye(e,t,i?false:r).then(o=>{n||T(o);}),()=>{n=true;}},[e,t,r,i]);let C=useCallback(()=>{let n=N.current,o=x.current?.querySelector("pre"),h=b.current?.querySelector("[data-gutter]");n&&o&&(o.scrollTop=n.scrollTop,o.scrollLeft=n.scrollLeft),n&&h&&(h.scrollTop=n.scrollTop);},[]),p=useCallback(n=>{a?.(n.target.value);},[a]),m=useCallback(n=>{if(n.key==="Tab"){n.preventDefault();let o=n.currentTarget,h=o.selectionStart,$=o.selectionEnd,G=o.value.substring(0,h)+" "+o.value.substring($);a?.(G),requestAnimationFrame(()=>{o.selectionStart=o.selectionEnd=h+2;});}},[a]),g=r&&"[&_.line-number]:inline-block [&_.line-number]:w-8 [&_.line-number]:mr-4 [&_.line-number]:text-right [&_.line-number]:text-secondary-400 [&_.line-number]:select-none [&_.line-number]:before:content-[attr(data-line)]",D="ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",A=1.7,O=e.split(`
2
- `).length;return i?jsxs("div",{ref:b,className:s(R({size:l}),"flex border border-primary-200 dark:border-primary-700",c),style:{background:"var(--color-syntax-bg)"},...f,children:[r&&jsx("div",{"data-gutter":true,"aria-hidden":true,className:"shrink-0 select-none overflow-hidden py-4 pl-3 pr-1 text-right text-secondary-400",style:{fontFamily:D,lineHeight:A,width:"3rem"},children:Array.from({length:O},(n,o)=>jsx("div",{children:o+1},o))}),jsxs("div",{className:"relative min-w-0 flex-1",children:[jsx("textarea",{ref:N,value:e,onChange:p,onScroll:C,onKeyDown:m,spellCheck:false,autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",className:"relative z-2 m-0 block h-full w-full resize-none overflow-auto whitespace-pre border-none bg-transparent p-4 text-transparent caret-primary-600 outline-none dark:caret-primary-400",style:{fontFamily:D,lineHeight:A,tabSize:2,minHeight:"6rem"}}),jsx("div",{ref:x,"aria-hidden":true,className:"pointer-events-none absolute inset-0 z-1 overflow-hidden [&_pre]:m-0 [&_pre]:h-full [&_pre]:overflow-hidden [&_pre]:p-4 [&_code]:bg-transparent",dangerouslySetInnerHTML:u?{__html:u}:void 0})]})]}):jsx("div",{ref:b,className:s(R({size:l}),"border border-primary-200 dark:border-primary-700",g,c),...f,children:jsx("div",{ref:x,className:"[&_pre]:m-0 [&_pre]:p-4",dangerouslySetInnerHTML:u?{__html:u}:void 0,children:u?void 0:jsx("pre",{className:"m-0 p-4",style:{background:"var(--color-syntax-bg)"},children:jsx("code",{children:e})})})})}var fe={Table:S,List:_,Tree:K,Chat:P,CodeBlock:M},Tt=fe;export{P as Chat,M as CodeBlock,fe as DataDisplay,_ as List,S as Table,K as Tree,Tt as default};
1
+ import w,{createContext,useState,useCallback,useRef,useEffect}from'react';import'lucide-react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {cva}from'class-variance-authority';import {jsx,Fragment,jsxs}from'react/jsx-runtime';function s(...e){return twMerge(clsx(e))}var I=cva("w-full text-left text-sm",{variants:{intent:{default:"",striped:"[&_tbody_tr:nth-child(even)]:bg-primary-50 dark:[&_tbody_tr:nth-child(even)]:bg-primary-800/30",bordered:"[&_th]:border [&_td]:border [&_th]:border-primary-200 [&_td]:border-primary-200 dark:[&_th]:border-primary-700 dark:[&_td]:border-primary-700"},density:{compact:"[&_th]:px-2 [&_th]:py-1 [&_td]:px-2 [&_td]:py-1",default:"",relaxed:"[&_th]:px-6 [&_th]:py-5 [&_td]:px-6 [&_td]:py-5"}},defaultVariants:{intent:"default",density:"default"}}),z=cva("text-sm text-primary-700 dark:text-primary-300",{variants:{intent:{default:"space-y-1",bordered:"divide-y divide-primary-200 rounded-lg border border-primary-200 dark:divide-primary-700 dark:border-primary-700 [&>li]:px-4 [&>li]:py-2",hover:"[&>li]:rounded-md [&>li]:px-3 [&>li]:py-2 [&>li]:transition-colors [&>li:hover]:bg-primary-50 dark:[&>li:hover]:bg-primary-800/50"}},defaultVariants:{intent:"default"}});cva("group flex w-full items-center gap-1.5 text-left [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3 [&_svg]:w-3",md:"py-1.5 text-sm [&_svg]:h-3.5 [&_svg]:w-3.5",lg:"py-2 text-base [&_svg]:h-4 [&_svg]:w-4"}},defaultVariants:{size:"md"}});cva("flex cursor-pointer items-center gap-1 rounded transition-colors [&_svg]:shrink-0",{variants:{size:{sm:"py-0.5 text-xs [&_svg]:h-3.5 [&_svg]:w-3.5",md:"py-1 text-sm [&_svg]:h-4 [&_svg]:w-4",lg:"py-1.5 text-base [&_svg]:h-5 [&_svg]:w-5"}},defaultVariants:{size:"md"}});var R=cva("overflow-x-auto rounded-lg font-mono [background:var(--color-syntax-bg)] [&_pre]:m-0 [&_pre]:p-4 [&_code]:bg-transparent",{variants:{size:{sm:"text-xs",md:"text-sm",lg:"text-base"}},defaultVariants:{size:"md"}});function S({intent:e,density:t,className:r,...i}){return jsx("div",{className:"w-full overflow-auto",children:jsx("table",{className:s(I({intent:e,density:t}),r),...i})})}var Y=createContext({size:"md"});function _({intent:e,size:t="md",className:r,...i}){return jsx(Y.Provider,{value:{size:t},children:jsx("ul",{className:s(z({intent:e}),r),...i})})}var re=createContext({showLines:true,expandedKeys:null,onToggleKey:()=>{},size:"md"});function K({showLines:e=true,showRoot:t=true,expandedKeys:r,defaultExpandedKeys:i="all",onExpandedKeysChange:a,size:l="md",className:c,children:f,...u}){let [T,b]=useState(()=>i),x=useCallback(p=>{if(r){let m=new Set(r);m.has(p)?m.delete(p):m.add(p),a?.(m);}else b(m=>{if(m==="all")return new Set(["__ALL_MINUS__",p]);let g=new Set(m);return g.has(p)?g.delete(p):g.add(p),g});},[r,a]),C=r??(T==="all"?null:T);return jsx(re.Provider,{value:{showLines:e,expandedKeys:C,onToggleKey:x,size:l},children:t?jsx("ul",{className:s("text-sm",c),role:"tree",...u,children:f}):jsx("ul",{className:s("text-sm",c),role:"tree",...u,children:jsx(ae,{children:f})})})}function ae({children:e}){let t=j(e);return jsx(Fragment,{children:t.map(r=>w.isValidElement(r)&&r.props.children?r.props.children:null)})}function j(e){let t=[];return w.Children.forEach(e,r=>{w.isValidElement(r)&&r.type===w.Fragment?t.push(...j(r.props.children)):t.push(r);}),t}function ie({avatar:e,sender:t}){return e?typeof e=="string"?/^(?:https?|data|blob):/.test(e)?jsx("img",{src:e,alt:t,className:"h-8 w-8 shrink-0 rounded-full object-cover",draggable:false}):jsx("div",{className:"bg-primary-200 text-primary-600 dark:bg-primary-700 dark:text-primary-300 flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-lg select-none",children:e}):jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full",children:e}):jsx("div",{className:"bg-primary-200 text-primary-600 dark:bg-primary-700 dark:text-primary-300 flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-sm font-semibold select-none",children:t.charAt(0).toUpperCase()})}function le({msg:e,alignRight:t}){return jsxs("div",{className:s("flex gap-2.5",t?"flex-row-reverse":"flex-row"),children:[jsx(ie,{avatar:e.avatar,sender:e.sender}),jsxs("div",{className:s("flex max-w-[75%] flex-col gap-0.5",t?"items-end":"items-start"),children:[jsx("span",{className:"text-primary-500 dark:text-primary-400 text-xs",children:e.sender}),jsx("div",{className:s("rounded-xl px-3 py-2 text-sm leading-relaxed",t?"rounded-tr-sm bg-primary-500 text-white dark:bg-primary-600":"bg-primary-100 text-primary-800 dark:bg-primary-800 dark:text-primary-200 rounded-tl-sm"),children:e.content}),e.time&&jsx("span",{className:"text-primary-400 dark:text-primary-500 text-[10px]",children:e.time})]})]})}function P({messages:e,mode:t="split",autoScroll:r=true,className:i,...a}){let l=useRef(null);return useEffect(()=>{r&&l.current?.scrollIntoView({behavior:"smooth"});},[e,r]),jsxs("div",{className:s("flex flex-col gap-4 overflow-y-auto rounded-lg border p-4","border-primary-200 dark:border-primary-700 dark:bg-primary-900 bg-white",i),...a,children:[e.map(c=>{let f=t==="split"&&!!c.self;return jsx(le,{msg:c,alignRight:f},c.id)}),jsx("div",{ref:l})]})}var pe={name:"onyx-css-vars",type:"dark",settings:[{settings:{foreground:"var(--color-syntax-plain)",background:"var(--color-syntax-bg)"}},{scope:["comment","punctuation.definition.comment"],settings:{foreground:"var(--color-syntax-comment)",fontStyle:"italic"}},{scope:["keyword","keyword.control","keyword.operator.new","keyword.operator.expression","storage.type","storage.modifier"],settings:{foreground:"var(--color-syntax-keyword)"}},{scope:["string","string.quoted","string.template"],settings:{foreground:"var(--color-syntax-string)"}},{scope:["entity.name.function","support.function","meta.function-call"],settings:{foreground:"var(--color-syntax-function)"}},{scope:["variable","variable.other","variable.parameter","meta.definition.variable"],settings:{foreground:"var(--color-syntax-variable)"}},{scope:["constant.numeric","constant.language"],settings:{foreground:"var(--color-syntax-number)"}},{scope:["keyword.operator","keyword.operator.assignment","keyword.operator.comparison","keyword.operator.arithmetic"],settings:{foreground:"var(--color-syntax-operator)"}},{scope:["entity.name.tag","punctuation.definition.tag","support.class.component"],settings:{foreground:"var(--color-syntax-tag)"}},{scope:["entity.other.attribute-name","meta.tag.attributes"],settings:{foreground:"var(--color-syntax-attr)"}},{scope:["punctuation","meta.brace","punctuation.definition.block","punctuation.separator","punctuation.terminator"],settings:{foreground:"var(--color-syntax-punctuation)"}},{scope:["entity.name.type","support.type","support.class","entity.other.inherited-class"],settings:{foreground:"var(--color-syntax-type)"}}]},me={typescript:()=>import('@shikijs/langs/typescript'),javascript:()=>import('@shikijs/langs/javascript'),tsx:()=>import('@shikijs/langs/tsx'),jsx:()=>import('@shikijs/langs/jsx'),html:()=>import('@shikijs/langs/html'),css:()=>import('@shikijs/langs/css'),json:()=>import('@shikijs/langs/json'),markdown:()=>import('@shikijs/langs/markdown'),python:()=>import('@shikijs/langs/python'),rust:()=>import('@shikijs/langs/rust'),go:()=>import('@shikijs/langs/go'),java:()=>import('@shikijs/langs/java'),c:()=>import('@shikijs/langs/c'),cpp:()=>import('@shikijs/langs/cpp'),csharp:()=>import('@shikijs/langs/csharp'),vue:()=>import('@shikijs/langs/vue'),xml:()=>import('@shikijs/langs/xml'),yaml:()=>import('@shikijs/langs/yaml'),sql:()=>import('@shikijs/langs/sql'),bash:()=>import('@shikijs/langs/bash'),shell:()=>import('@shikijs/langs/shell')},V=null,U=new Set;function ue(){return V||(V=Promise.all([import('shiki/core'),import('shiki/engine/javascript')]).then(([{createHighlighterCore:e},{createJavaScriptRegexEngine:t}])=>e({themes:[pe],langs:[],engine:t()}))),V}async function ye(e,t,r){let i=await ue();if(t&&!U.has(t)){let l=me[t];if(l)try{let c=await l();await i.loadLanguage(c.default??c),U.add(t);}catch{t="text";}else t="text";}let a=i.codeToHtml(e,{lang:t||"text",theme:"onyx-css-vars"});if(a=a.replace(/(<pre [^>]*style=")/,"$1line-height:1.7;tab-size:2;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;"),r){let l=0;a=a.replace(/<span class="line">/g,()=>(l++,`<span class="line"><span class="line-number" data-line="${l}"></span>`));}return a}function M({code:e,language:t="text",lineNumbers:r=false,editable:i=false,onCodeChange:a,size:l,className:c,...f}){let[u,T]=useState(""),b=useRef(null),N=useRef(null),x=useRef(null);useEffect(()=>{let n=false;return ye(e,t,i?false:r).then(o=>{n||T(o);}),()=>{n=true;}},[e,t,r,i]);let C=useCallback(()=>{let n=N.current,o=x.current?.querySelector("pre"),h=b.current?.querySelector("[data-gutter]");n&&o&&(o.scrollTop=n.scrollTop,o.scrollLeft=n.scrollLeft),n&&h&&(h.scrollTop=n.scrollTop);},[]),p=useCallback(n=>{a?.(n.target.value);},[a]),m=useCallback(n=>{if(n.key==="Tab"){n.preventDefault();let o=n.currentTarget,h=o.selectionStart,$=o.selectionEnd,G=o.value.substring(0,h)+" "+o.value.substring($);a?.(G),requestAnimationFrame(()=>{o.selectionStart=o.selectionEnd=h+2;});}},[a]),g=r&&"[&_.line-number]:inline-block [&_.line-number]:w-8 [&_.line-number]:mr-4 [&_.line-number]:text-right [&_.line-number]:text-secondary-400 [&_.line-number]:select-none [&_.line-number]:before:content-[attr(data-line)]",D="ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",A=1.7,O=e.split(`
2
+ `).length;return i?jsxs("div",{ref:b,className:s(R({size:l}),"flex border border-primary-200 dark:border-primary-700",c),style:{background:"var(--color-syntax-bg)"},...f,children:[r&&jsx("div",{"data-gutter":true,"aria-hidden":true,className:"shrink-0 select-none overflow-hidden py-4 pl-3 pr-1 text-right text-secondary-400",style:{fontFamily:D,lineHeight:A,width:"3rem"},children:Array.from({length:O},(n,o)=>jsx("div",{children:o+1},o))}),jsxs("div",{className:"relative min-w-0 flex-1",children:[jsx("textarea",{ref:N,value:e,onChange:p,onScroll:C,onKeyDown:m,spellCheck:false,autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",className:"relative z-2 m-0 block h-full w-full resize-none overflow-auto whitespace-pre border-none bg-transparent p-4 text-transparent caret-primary-600 outline-none dark:caret-primary-400",style:{fontFamily:D,lineHeight:A,tabSize:2,minHeight:"6rem"}}),jsx("div",{ref:x,"aria-hidden":true,className:"pointer-events-none absolute inset-0 z-1 overflow-hidden [&_pre]:m-0 [&_pre]:h-full [&_pre]:overflow-hidden [&_pre]:p-4 [&_code]:bg-transparent",dangerouslySetInnerHTML:u?{__html:u}:void 0})]})]}):jsx("div",{ref:b,className:s(R({size:l}),"border border-primary-200 dark:border-primary-700",g,c),style:{background:"var(--color-syntax-bg)"},...f,children:jsx("div",{ref:x,className:"[&_pre]:m-0 [&_pre]:p-4",dangerouslySetInnerHTML:u?{__html:u}:void 0,children:u?void 0:jsx("pre",{className:"m-0 p-4",style:{background:"var(--color-syntax-bg)"},children:jsx("code",{children:e})})})})}var fe={Table:S,List:_,Tree:K,Chat:P,CodeBlock:M},Tt=fe;export{P as Chat,M as CodeBlock,fe as DataDisplay,_ as List,S as Table,K as Tree,Tt as default};
@@ -1,4 +1,4 @@
1
- 'use strict';var Pe=require('react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),lucideReact=require('lucide-react'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Pe__default=/*#__PURE__*/_interopDefault(Pe);function i(...r){return tailwindMerge.twMerge(clsx.clsx(r))}function j(r){if(!isFinite(r)||r<0)return "0:00";let p=Math.floor(r/3600),M=Math.floor(r%3600/60),L=Math.floor(r%60);return p>0?`${p}:${M.toString().padStart(2,"0")}:${L.toString().padStart(2,"0")}`:`${M}:${L.toString().padStart(2,"0")}`}var ze={title:(r,p)=>r.title.localeCompare(p.title),type:(r,p)=>(r.type??"").localeCompare(p.type??""),duration:(r,p)=>(r.duration??0)-(p.duration??0)};function Je({playlist:r,initialTrack:p=0,autoPlay:M=false,shuffle:L=false,loop:se=false,onTrackChange:q,onPlayChange:oe,accent:le="#8b5cf6",className:ce}){let[f,ie]=Pe.useState(p),[l,y]=Pe.useState(false),[E,H]=Pe.useState(0),[u,ue]=Pe.useState(0),[de,me]=Pe.useState(0),[S,V]=Pe.useState(.8),[k,G]=Pe.useState(false),[P,pe]=Pe.useState(L),[A,fe]=Pe.useState(se),[J,ve]=Pe.useState(false),[w,be]=Pe.useState("title"),[N,Q]=Pe.useState(true),[v,W]=Pe.useState(false),[he,Y]=Pe.useState(false),[C,xe]=Pe.useState(false),[Z,R]=Pe.useState(true),[K,ee]=Pe.useState(false),[O,te]=Pe.useState(null),d=Pe.useRef(null),z=Pe.useRef(null),x=Pe.useRef(void 0),ne=Pe.useRef(false),c=r[f],ge=Pe__default.default.useMemo(()=>{let e=r.map((n,a)=>({media:n,originalIndex:a}));return e.sort((n,a)=>{let m=ze[w](n.media,a.media);return N?m:-m}),e},[r,w,N]);Pe.useEffect(()=>{let e=d.current;if(!e)return;ee(true),e.src=c.src,c.poster&&(e.poster=c.poster),e.load();let n=()=>{ee(false),l&&e.play().catch(()=>{});};return e.addEventListener("loadeddata",n,{once:true}),()=>e.removeEventListener("loadeddata",n)},[f,c.src]),Pe.useEffect(()=>{if(!M||ne.current)return;let e=d.current;if(!e)return;let n=()=>{ne.current=true,y(true),e.play().catch(()=>{});};return e.addEventListener("canplaythrough",n,{once:true}),()=>e.removeEventListener("canplaythrough",n)},[M]),Pe.useEffect(()=>{let e=d.current;e&&(l?e.play().catch(()=>{}):e.pause(),oe?.(l));},[l]),Pe.useEffect(()=>{let e=d.current;e&&(e.volume=k?0:S);},[S,k]),Pe.useEffect(()=>{let e=d.current;if(!e)return;let n=()=>H(e.currentTime),a=()=>ue(e.duration),m=()=>{e.buffered.length>0&&me(e.buffered.end(e.buffered.length-1));},ae=()=>{A?(e.currentTime=0,e.play().catch(()=>{})):D();};return e.addEventListener("timeupdate",n),e.addEventListener("loadedmetadata",a),e.addEventListener("progress",m),e.addEventListener("ended",ae),()=>{e.removeEventListener("timeupdate",n),e.removeEventListener("loadedmetadata",a),e.removeEventListener("progress",m),e.removeEventListener("ended",ae);}},[f,r.length,A]);let B=Pe.useCallback(()=>{R(true),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{l&&R(false);},3e3);},[l]);Pe.useEffect(()=>{l?B():(R(true),x.current&&clearTimeout(x.current));},[l,B]),Pe.useEffect(()=>()=>{x.current&&clearTimeout(x.current);},[]);let g=Pe.useCallback(e=>{let n=(e%r.length+r.length)%r.length;ie(n),H(0),y(true),q?.(n,r[n]);},[r,q]),D=Pe.useCallback(()=>{if(P){let e;do e=Math.floor(Math.random()*r.length);while(e===f&&r.length>1);g(e);}else g(f+1);},[g,f,P,r.length]),I=Pe.useCallback(()=>{if(P){let e;do e=Math.floor(Math.random()*r.length);while(e===f&&r.length>1);g(e);}else g(f-1);},[g,f,P,r.length]),ye=Pe.useCallback(e=>{let n=e.currentTarget.getBoundingClientRect(),m=Math.max(0,Math.min(1,(e.clientX-n.left)/n.width))*u;d.current&&(d.current.currentTime=m),H(m);},[u]),ke=Pe.useCallback(e=>{let n=e.currentTarget.getBoundingClientRect(),a=Math.max(0,Math.min(1,(e.clientX-n.left)/n.width));te(a*u);},[u]),X=Pe.useCallback(()=>{z.current&&(document.fullscreenElement?document.exitFullscreen():z.current.requestFullscreen());},[]);Pe.useEffect(()=>{let e=()=>xe(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]);let T=Pe.useCallback(()=>{v?(Y(true),setTimeout(()=>{W(false),Y(false);},500)):W(true);},[v]),_=Pe.useCallback(()=>{ve(e=>!e);},[]),we=Pe.useCallback(()=>{let e=["title","type","duration"],n=e.indexOf(w);N?Q(false):(Q(true),be(e[(n+1)%e.length]));},[w,N]);Pe.useEffect(()=>{let e=n=>{if(!(n.target instanceof HTMLInputElement||n.target instanceof HTMLTextAreaElement))switch(n.key){case " ":case "k":n.preventDefault(),y(a=>!a);break;case "f":n.preventDefault(),X();break;case "t":n.preventDefault(),T();break;case "ArrowLeft":n.preventDefault(),d.current&&(d.current.currentTime=Math.max(0,E-5));break;case "ArrowRight":n.preventDefault(),d.current&&(d.current.currentTime=Math.min(u,E+5));break;case "ArrowUp":n.preventDefault(),V(a=>Math.min(1,a+.05));break;case "ArrowDown":n.preventDefault(),V(a=>Math.max(0,a-.05));break;case "Escape":v&&T();break;case "n":n.preventDefault(),D();break;case "p":n.preventDefault(),I();break;case "l":n.preventDefault(),_();break}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[X,T,_,D,I,E,u,v]);let re=u>0?E/u*100:0,Ne=u>0?de/u*100:0,$="text-(--accent)",Ce=jsxRuntime.jsxs("div",{ref:z,className:i("group flex overflow-hidden",C?"h-full w-full":"aspect-video w-full",!C&&"rounded-xl",!C&&l&&"shadow-2xl",!C&&!l&&"animate-[cp-glow-pulse_4s_ease-in-out_infinite] will-change-[box-shadow]",ce),style:{"--accent":le,background:"var(--cp-bg)"},tabIndex:0,children:[jsxRuntime.jsxs("div",{className:i("relative flex-1 min-w-0 h-full overflow-hidden",K&&"animate-[cp-track-transition_0.6s_ease-out]"),onMouseMove:B,onMouseLeave:()=>{l&&R(false);},children:[jsxRuntime.jsx("video",{ref:d,className:"h-full w-full object-contain",poster:c.poster,playsInline:true,preload:"metadata",onClick:()=>y(e=>!e)}),!l&&!K&&jsxRuntime.jsx("div",{className:"absolute inset-0 flex cursor-pointer items-center justify-center",style:{background:"var(--cp-overlay)"},onClick:()=>y(true),children:jsxRuntime.jsx("div",{className:"flex h-20 w-20 items-center justify-center rounded-full backdrop-blur-md transition-transform hover:scale-110 active:scale-95",style:{background:"var(--cp-surface-hover)"},children:jsxRuntime.jsx(lucideReact.Play,{className:"h-10 w-10 translate-x-0.5",fill:"currentColor",style:{color:"var(--cp-text-strong)"}})})}),K&&jsxRuntime.jsx("div",{className:"absolute left-6 top-6 z-20 animate-[fade-in_0.4s_ease-out]",children:jsxRuntime.jsxs("div",{className:"rounded-lg px-4 py-2 backdrop-blur-md",style:{background:"var(--cp-panel-bg)"},children:[jsxRuntime.jsx("div",{className:"text-sm font-semibold",style:{color:"var(--cp-text-strong)"},children:c.title}),c.subtitle&&jsxRuntime.jsx("div",{className:"text-xs",style:{color:"var(--cp-text-muted)"},children:c.subtitle})]})}),jsxRuntime.jsx("div",{className:i("absolute inset-x-0 top-0 z-10 bg-linear-to-b from-black/70 to-transparent px-5 pb-8 pt-4 transition-opacity duration-500",Z?"opacity-100":"pointer-events-none opacity-0"),children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold drop-shadow-md",style:{color:"var(--cp-text-strong)"},children:c.title}),c.subtitle&&jsxRuntime.jsx("p",{className:"text-xs",style:{color:"var(--cp-text-muted)"},children:c.subtitle})]}),c.type&&jsxRuntime.jsx("span",{className:"rounded-full bg-(--accent)/70 px-2.5 py-0.5 text-[10px] font-semibold uppercase tracking-wider backdrop-blur-sm",style:{color:"var(--cp-text-strong)"},children:c.type})]})}),jsxRuntime.jsxs("div",{className:i("absolute inset-x-0 bottom-0 z-10 bg-linear-to-t from-black/80 via-black/40 to-transparent px-4 pb-3 pt-10 transition-all duration-500",Z?"translate-y-0 opacity-100":"pointer-events-none translate-y-2 opacity-0"),children:[jsxRuntime.jsxs("div",{className:"group/seek relative mb-3 h-1 cursor-pointer rounded-full transition-[height] duration-200 hover:h-1.5",style:{background:"var(--cp-seek-track)"},onClick:ye,onMouseMove:ke,onMouseLeave:()=>te(null),children:[jsxRuntime.jsx("div",{className:"absolute inset-y-0 left-0 rounded-full",style:{width:`${Ne}%`,background:"var(--cp-seek-buffer)"}}),jsxRuntime.jsx("div",{className:"absolute inset-y-0 left-0 rounded-full bg-(--accent) transition-[width] duration-100",style:{width:`${re}%`}}),O!==null&&jsxRuntime.jsx("div",{className:"absolute -top-8 -translate-x-1/2 rounded px-2 py-0.5 text-[10px] font-mono",style:{left:`${O/u*100}%`,background:"var(--cp-panel-bg)",color:"var(--cp-text-strong)"},children:j(O)}),jsxRuntime.jsx("div",{className:"absolute top-1/2 h-3.5 w-3.5 -translate-y-1/2 rounded-full border-2 border-(--accent) bg-white opacity-0 shadow-lg transition-opacity group-hover/seek:opacity-100",style:{left:`calc(${re}% - 7px)`}})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{className:"cp-btn",onClick:()=>y(e=>!e),title:l?"Pause (k)":"Play (k)",children:l?jsxRuntime.jsx(lucideReact.Pause,{className:"h-5 w-5",fill:"currentColor"}):jsxRuntime.jsx(lucideReact.Play,{className:"h-5 w-5 translate-x-px",fill:"currentColor"})}),jsxRuntime.jsx("button",{className:"cp-btn",onClick:I,title:"Previous (p)",children:jsxRuntime.jsx(lucideReact.SkipBack,{className:"h-4 w-4",fill:"currentColor"})}),jsxRuntime.jsx("button",{className:"cp-btn",onClick:D,title:"Next (n)",children:jsxRuntime.jsx(lucideReact.SkipForward,{className:"h-4 w-4",fill:"currentColor"})}),jsxRuntime.jsxs("div",{className:"group/vol ml-1 flex items-center",children:[jsxRuntime.jsx("button",{className:"cp-btn",onClick:()=>G(e=>!e),title:k?"Unmute":"Mute",children:k||S===0?jsxRuntime.jsx(lucideReact.VolumeX,{className:"h-4 w-4"}):jsxRuntime.jsx(lucideReact.Volume2,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"flex w-0 items-center overflow-hidden transition-all duration-300 group-hover/vol:w-20",children:jsxRuntime.jsx("input",{type:"range",min:0,max:1,step:.01,value:k?0:S,onChange:e=>{V(Number(e.target.value)),k&&G(false);},className:"h-1 w-full cursor-pointer appearance-none rounded-full accent-(--accent)",style:{background:"var(--cp-seek-track)"}})})]}),jsxRuntime.jsxs("span",{className:"ml-2 min-w-0 shrink-0 font-mono text-xs",style:{color:"var(--cp-text-muted)"},children:[j(E)," / ",j(u)]}),jsxRuntime.jsx("div",{className:"flex-1"}),jsxRuntime.jsx("button",{className:i("cp-btn",P&&$),onClick:()=>pe(e=>!e),title:"Shuffle",children:jsxRuntime.jsx(lucideReact.Shuffle,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{className:i("cp-btn",A&&$),onClick:()=>fe(e=>!e),title:"Loop",children:jsxRuntime.jsx(lucideReact.Repeat1,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{className:i("cp-btn",J&&$),onClick:_,title:"Playlist",children:jsxRuntime.jsx(lucideReact.ListVideo,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{className:i("cp-btn",v&&$),onClick:T,title:"Cinema mode (t)",children:jsxRuntime.jsx(lucideReact.Theater,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{className:"cp-btn",onClick:X,title:"Fullscreen (f)",children:C?jsxRuntime.jsx(lucideReact.Minimize,{className:"h-4 w-4"}):jsxRuntime.jsx(lucideReact.Maximize,{className:"h-4 w-4"})})]})]})]}),jsxRuntime.jsx("div",{className:i("h-full shrink-0 overflow-hidden transition-[width] duration-300 ease-out",J?"w-72":"w-0"),children:jsxRuntime.jsxs("div",{className:"flex h-full w-72 flex-col backdrop-blur-xl",style:{borderLeft:"1px solid var(--cp-border)",background:"var(--cp-panel-bg)"},children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:{borderBottom:"1px solid var(--cp-border)"},children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:"var(--cp-text)"},children:"Playlist"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsxs("button",{className:"flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium transition-colors",style:{color:"var(--cp-text-muted)"},onClick:we,title:`Sort: ${w} ${N?"\u2191":"\u2193"}`,children:[jsxRuntime.jsx(lucideReact.ArrowUpDown,{className:"h-3 w-3"}),w,N?" \u2191":" \u2193"]}),jsxRuntime.jsx("button",{className:"cp-btn p-1!",onClick:_,title:"Close",children:jsxRuntime.jsx(lucideReact.X,{className:"h-3.5 w-3.5"})})]})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto",children:ge.map(({media:e,originalIndex:n})=>{let a=n===f;return jsxRuntime.jsxs("button",{className:i("flex w-full items-center gap-3 px-4 py-2.5 text-left transition-all duration-200",a?"bg-(--accent)/20 text-(--accent)":"hover:text-(--cp-text-strong)"),style:a?void 0:{color:"var(--cp-text)"},onClick:()=>{g(n);},children:[jsxRuntime.jsxs("div",{className:"relative h-10 w-16 shrink-0 overflow-hidden rounded",style:{background:"var(--cp-surface)"},children:[e.poster?jsxRuntime.jsx("img",{src:e.poster,alt:"",className:"h-full w-full object-cover",draggable:false}):jsxRuntime.jsx("div",{className:"flex h-full w-full items-center justify-center",children:jsxRuntime.jsx(lucideReact.Play,{className:"h-4 w-4",style:{color:"var(--cp-seek-track)"}})}),a&&l&&jsxRuntime.jsx("div",{className:"absolute inset-0 flex items-center justify-center",style:{background:"var(--cp-overlay)"},children:jsxRuntime.jsx("div",{className:"flex items-end gap-px",children:[1,2,3,4].map(m=>jsxRuntime.jsx("div",{className:"w-0.5 rounded-full bg-(--accent)",style:{height:`${6+m*3}px`,animation:`mp-eq-bar ${.3+m*.12}s ease-in-out infinite alternate`}},m))})})]}),jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx("div",{className:"truncate text-xs font-medium",children:e.title}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[e.type&&jsxRuntime.jsx("span",{className:"text-[10px] uppercase tracking-wide opacity-50",children:e.type}),e.duration!=null&&jsxRuntime.jsx("span",{className:"font-mono text-[10px] opacity-40",children:j(e.duration)})]})]}),a&&jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-(--accent)"})]},n)})})]})}),jsxRuntime.jsx("style",{children:`
1
+ 'use strict';var Pe=require('react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),lucideReact=require('lucide-react'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Pe__default=/*#__PURE__*/_interopDefault(Pe);function i(...r){return tailwindMerge.twMerge(clsx.clsx(r))}function j(r){if(!isFinite(r)||r<0)return "0:00";let p=Math.floor(r/3600),M=Math.floor(r%3600/60),L=Math.floor(r%60);return p>0?`${p}:${M.toString().padStart(2,"0")}:${L.toString().padStart(2,"0")}`:`${M}:${L.toString().padStart(2,"0")}`}var ze={title:(r,p)=>r.title.localeCompare(p.title),type:(r,p)=>(r.type??"").localeCompare(p.type??""),duration:(r,p)=>(r.duration??0)-(p.duration??0)};function Je({playlist:r,initialTrack:p=0,autoPlay:M=false,shuffle:L=false,loop:se=false,onTrackChange:G,onPlayChange:oe,accent:le="#8b5cf6",className:ce}){let[f,ie]=Pe.useState(p),[l,y]=Pe.useState(false),[E,H]=Pe.useState(0),[u,ue]=Pe.useState(0),[de,me]=Pe.useState(0),[S,V]=Pe.useState(.8),[k,J]=Pe.useState(false),[P,pe]=Pe.useState(L),[A,fe]=Pe.useState(se),[Q,ve]=Pe.useState(false),[w,be]=Pe.useState("title"),[N,W]=Pe.useState(true),[v,Y]=Pe.useState(false),[he,Z]=Pe.useState(false),[C,xe]=Pe.useState(false),[K,R]=Pe.useState(true),[O,ee]=Pe.useState(false),[z,te]=Pe.useState(null),d=Pe.useRef(null),B=Pe.useRef(null),x=Pe.useRef(void 0),ne=Pe.useRef(false),c=r[f],ge=Pe__default.default.useMemo(()=>{let e=r.map((n,a)=>({media:n,originalIndex:a}));return e.sort((n,a)=>{let m=ze[w](n.media,a.media);return N?m:-m}),e},[r,w,N]);Pe.useEffect(()=>{let e=d.current;if(!e)return;ee(true),e.src=c.src,c.poster&&(e.poster=c.poster),e.load();let n=()=>{ee(false),l&&e.play().catch(()=>{});};return e.addEventListener("loadeddata",n,{once:true}),()=>e.removeEventListener("loadeddata",n)},[f,c.src]),Pe.useEffect(()=>{if(!M||ne.current)return;let e=d.current;if(!e)return;let n=()=>{ne.current=true,y(true),e.play().catch(()=>{});};return e.addEventListener("canplaythrough",n,{once:true}),()=>e.removeEventListener("canplaythrough",n)},[M]),Pe.useEffect(()=>{let e=d.current;e&&(l?e.play().catch(()=>{}):e.pause(),oe?.(l));},[l]),Pe.useEffect(()=>{let e=d.current;e&&(e.volume=k?0:S);},[S,k]),Pe.useEffect(()=>{let e=d.current;if(!e)return;let n=()=>H(e.currentTime),a=()=>ue(e.duration),m=()=>{e.buffered.length>0&&me(e.buffered.end(e.buffered.length-1));},ae=()=>{A?(e.currentTime=0,e.play().catch(()=>{})):D();};return e.addEventListener("timeupdate",n),e.addEventListener("loadedmetadata",a),e.addEventListener("progress",m),e.addEventListener("ended",ae),()=>{e.removeEventListener("timeupdate",n),e.removeEventListener("loadedmetadata",a),e.removeEventListener("progress",m),e.removeEventListener("ended",ae);}},[f,r.length,A]);let I=Pe.useCallback(()=>{R(true),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{l&&R(false);},3e3);},[l]);Pe.useEffect(()=>{l?I():(R(true),x.current&&clearTimeout(x.current));},[l,I]),Pe.useEffect(()=>()=>{x.current&&clearTimeout(x.current);},[]);let g=Pe.useCallback(e=>{let n=(e%r.length+r.length)%r.length;ie(n),H(0),y(true),G?.(n,r[n]);},[r,G]),D=Pe.useCallback(()=>{if(P){let e;do e=Math.floor(Math.random()*r.length);while(e===f&&r.length>1);g(e);}else g(f+1);},[g,f,P,r.length]),X=Pe.useCallback(()=>{if(P){let e;do e=Math.floor(Math.random()*r.length);while(e===f&&r.length>1);g(e);}else g(f-1);},[g,f,P,r.length]),ye=Pe.useCallback(e=>{let n=e.currentTarget.getBoundingClientRect(),m=Math.max(0,Math.min(1,(e.clientX-n.left)/n.width))*u;d.current&&(d.current.currentTime=m),H(m);},[u]),ke=Pe.useCallback(e=>{let n=e.currentTarget.getBoundingClientRect(),a=Math.max(0,Math.min(1,(e.clientX-n.left)/n.width));te(a*u);},[u]),U=Pe.useCallback(()=>{B.current&&(document.fullscreenElement?document.exitFullscreen():B.current.requestFullscreen());},[]);Pe.useEffect(()=>{let e=()=>xe(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]);let T=Pe.useCallback(()=>{v?(Z(true),setTimeout(()=>{Y(false),Z(false);},500)):Y(true);},[v]),_=Pe.useCallback(()=>{ve(e=>!e);},[]),we=Pe.useCallback(()=>{let e=["title","type","duration"],n=e.indexOf(w);N?W(false):(W(true),be(e[(n+1)%e.length]));},[w,N]);Pe.useEffect(()=>{let e=n=>{if(!(n.target instanceof HTMLInputElement||n.target instanceof HTMLTextAreaElement))switch(n.key){case " ":case "k":n.preventDefault(),y(a=>!a);break;case "f":n.preventDefault(),U();break;case "t":n.preventDefault(),T();break;case "ArrowLeft":n.preventDefault(),d.current&&(d.current.currentTime=Math.max(0,E-5));break;case "ArrowRight":n.preventDefault(),d.current&&(d.current.currentTime=Math.min(u,E+5));break;case "ArrowUp":n.preventDefault(),V(a=>Math.min(1,a+.05));break;case "ArrowDown":n.preventDefault(),V(a=>Math.max(0,a-.05));break;case "Escape":v&&T();break;case "n":n.preventDefault(),D();break;case "p":n.preventDefault(),X();break;case "l":n.preventDefault(),_();break}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[U,T,_,D,X,E,u,v]);let re=u>0?E/u*100:0,Ne=u>0?de/u*100:0,$="text-(--accent)",Ce=jsxRuntime.jsxs("div",{ref:B,className:i("group flex overflow-hidden",C?"h-full w-full":"aspect-video w-full",!C&&"rounded-xl",!C&&l&&"shadow-2xl",!C&&!l&&"animate-[cp-glow-pulse_4s_ease-in-out_infinite] will-change-[box-shadow]",ce),style:{"--accent":le,background:"var(--cp-bg)"},tabIndex:0,children:[jsxRuntime.jsxs("div",{className:i("relative flex-1 min-w-0 h-full overflow-hidden",O&&"animate-[cp-track-transition_0.6s_ease-out]"),onMouseMove:I,onMouseLeave:()=>{l&&R(false);},children:[jsxRuntime.jsx("video",{ref:d,className:"h-full w-full object-contain",poster:c.poster,playsInline:true,preload:"metadata",onClick:()=>y(e=>!e)}),!l&&!O&&jsxRuntime.jsx("div",{className:"absolute inset-0 flex cursor-pointer items-center justify-center",style:{background:"var(--cp-overlay)"},onClick:()=>y(true),children:jsxRuntime.jsx("div",{className:"flex h-20 w-20 items-center justify-center rounded-full backdrop-blur-md transition-transform hover:scale-110 active:scale-95",style:{background:"var(--cp-surface-hover)"},children:jsxRuntime.jsx(lucideReact.Play,{className:"h-10 w-10 translate-x-0.5",fill:"currentColor",style:{color:"var(--cp-text-strong)"}})})}),O&&!K&&jsxRuntime.jsx("div",{className:"absolute left-6 top-6 z-20 animate-[fade-in_0.4s_ease-out]",children:jsxRuntime.jsxs("div",{className:"rounded-lg px-4 py-2 backdrop-blur-md",style:{background:"var(--cp-panel-bg)"},children:[jsxRuntime.jsx("div",{className:"text-sm font-semibold",style:{color:"var(--cp-text-strong)"},children:c.title}),c.subtitle&&jsxRuntime.jsx("div",{className:"text-xs",style:{color:"var(--cp-text-muted)"},children:c.subtitle})]})}),jsxRuntime.jsx("div",{className:i("absolute inset-x-0 top-0 z-10 bg-linear-to-b from-black/70 to-transparent px-5 pb-8 pt-4 transition-opacity duration-500",K?"opacity-100":"pointer-events-none opacity-0"),children:jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"text-sm font-semibold drop-shadow-md",style:{color:"var(--cp-text-strong)"},children:c.title}),c.subtitle&&jsxRuntime.jsx("p",{className:"text-xs",style:{color:"var(--cp-text-muted)"},children:c.subtitle})]}),c.type&&jsxRuntime.jsx("span",{className:"rounded-full bg-(--accent)/70 px-2.5 py-0.5 text-[10px] font-semibold uppercase tracking-wider backdrop-blur-sm",style:{color:"var(--cp-text-strong)"},children:c.type})]})}),jsxRuntime.jsxs("div",{className:i("absolute inset-x-0 bottom-0 z-10 bg-linear-to-t from-black/80 via-black/40 to-transparent px-4 pb-3 pt-10 transition-all duration-500",K?"translate-y-0 opacity-100":"pointer-events-none translate-y-2 opacity-0"),children:[jsxRuntime.jsxs("div",{className:"group/seek relative mb-3 h-1 cursor-pointer rounded-full transition-[height] duration-200 hover:h-1.5",style:{background:"var(--cp-seek-track)"},onClick:ye,onMouseMove:ke,onMouseLeave:()=>te(null),children:[jsxRuntime.jsx("div",{className:"absolute inset-y-0 left-0 rounded-full",style:{width:`${Ne}%`,background:"var(--cp-seek-buffer)"}}),jsxRuntime.jsx("div",{className:"absolute inset-y-0 left-0 rounded-full bg-(--accent) transition-[width] duration-100",style:{width:`${re}%`}}),z!==null&&jsxRuntime.jsx("div",{className:"absolute -top-8 -translate-x-1/2 rounded px-2 py-0.5 text-[10px] font-mono",style:{left:`${z/u*100}%`,background:"var(--cp-panel-bg)",color:"var(--cp-text-strong)"},children:j(z)}),jsxRuntime.jsx("div",{className:"absolute top-1/2 h-3.5 w-3.5 -translate-y-1/2 rounded-full border-2 border-(--accent) bg-white opacity-0 shadow-lg transition-opacity group-hover/seek:opacity-100",style:{left:`calc(${re}% - 7px)`}})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsx("button",{className:"cp-btn",onClick:()=>y(e=>!e),title:l?"Pause (k)":"Play (k)",children:l?jsxRuntime.jsx(lucideReact.Pause,{className:"h-5 w-5",fill:"currentColor"}):jsxRuntime.jsx(lucideReact.Play,{className:"h-5 w-5 translate-x-px",fill:"currentColor"})}),jsxRuntime.jsx("button",{className:"cp-btn",onClick:X,title:"Previous (p)",children:jsxRuntime.jsx(lucideReact.SkipBack,{className:"h-4 w-4",fill:"currentColor"})}),jsxRuntime.jsx("button",{className:"cp-btn",onClick:D,title:"Next (n)",children:jsxRuntime.jsx(lucideReact.SkipForward,{className:"h-4 w-4",fill:"currentColor"})}),jsxRuntime.jsxs("div",{className:"group/vol ml-1 flex items-center",children:[jsxRuntime.jsx("button",{className:"cp-btn",onClick:()=>J(e=>!e),title:k?"Unmute":"Mute",children:k||S===0?jsxRuntime.jsx(lucideReact.VolumeX,{className:"h-4 w-4"}):jsxRuntime.jsx(lucideReact.Volume2,{className:"h-4 w-4"})}),jsxRuntime.jsx("div",{className:"flex w-0 items-center overflow-hidden transition-all duration-300 group-hover/vol:w-20",children:jsxRuntime.jsx("input",{type:"range",min:0,max:1,step:.01,value:k?0:S,onChange:e=>{V(Number(e.target.value)),k&&J(false);},className:"h-1 w-full cursor-pointer appearance-none rounded-full accent-(--accent)",style:{background:"var(--cp-seek-track)"}})})]}),jsxRuntime.jsxs("span",{className:"ml-2 min-w-0 shrink-0 font-mono text-xs",style:{color:"var(--cp-text-muted)"},children:[j(E)," / ",j(u)]}),jsxRuntime.jsx("div",{className:"flex-1"}),jsxRuntime.jsx("button",{className:i("cp-btn",P&&$),onClick:()=>pe(e=>!e),title:"Shuffle",children:jsxRuntime.jsx(lucideReact.Shuffle,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{className:i("cp-btn",A&&$),onClick:()=>fe(e=>!e),title:"Loop",children:jsxRuntime.jsx(lucideReact.Repeat1,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{className:i("cp-btn",Q&&$),onClick:_,title:"Playlist",children:jsxRuntime.jsx(lucideReact.ListVideo,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{className:i("cp-btn",v&&$),onClick:T,title:"Cinema mode (t)",children:jsxRuntime.jsx(lucideReact.Theater,{className:"h-4 w-4"})}),jsxRuntime.jsx("button",{className:"cp-btn",onClick:U,title:"Fullscreen (f)",children:C?jsxRuntime.jsx(lucideReact.Minimize,{className:"h-4 w-4"}):jsxRuntime.jsx(lucideReact.Maximize,{className:"h-4 w-4"})})]})]})]}),jsxRuntime.jsx("div",{className:i("h-full shrink-0 overflow-hidden transition-[width] duration-300 ease-out",Q?"w-72":"w-0"),children:jsxRuntime.jsxs("div",{className:"flex h-full w-72 flex-col backdrop-blur-xl",style:{borderLeft:"1px solid var(--cp-border)",background:"var(--cp-panel-bg)"},children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:{borderBottom:"1px solid var(--cp-border)"},children:[jsxRuntime.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:"var(--cp-text)"},children:"Playlist"}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[jsxRuntime.jsxs("button",{className:"flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium transition-colors",style:{color:"var(--cp-text-muted)"},onClick:we,title:`Sort: ${w} ${N?"\u2191":"\u2193"}`,children:[jsxRuntime.jsx(lucideReact.ArrowUpDown,{className:"h-3 w-3"}),w,N?" \u2191":" \u2193"]}),jsxRuntime.jsx("button",{className:"cp-btn p-1!",onClick:_,title:"Close",children:jsxRuntime.jsx(lucideReact.X,{className:"h-3.5 w-3.5"})})]})]}),jsxRuntime.jsx("div",{className:"flex-1 overflow-y-auto",children:ge.map(({media:e,originalIndex:n})=>{let a=n===f;return jsxRuntime.jsxs("button",{className:i("flex w-full items-center gap-3 px-4 py-2.5 text-left transition-all duration-200",a?"bg-(--accent)/20 text-(--accent)":"hover:text-(--cp-text-strong)"),style:a?void 0:{color:"var(--cp-text)"},onClick:()=>{g(n);},children:[jsxRuntime.jsxs("div",{className:"relative h-10 w-16 shrink-0 overflow-hidden rounded",style:{background:"var(--cp-surface)"},children:[e.poster?jsxRuntime.jsx("img",{src:e.poster,alt:"",className:"h-full w-full object-cover",draggable:false}):jsxRuntime.jsx("div",{className:"flex h-full w-full items-center justify-center",children:jsxRuntime.jsx(lucideReact.Play,{className:"h-4 w-4",style:{color:"var(--cp-seek-track)"}})}),a&&l&&jsxRuntime.jsx("div",{className:"absolute inset-0 flex items-center justify-center",style:{background:"var(--cp-overlay)"},children:jsxRuntime.jsx("div",{className:"flex items-end gap-px",children:[1,2,3,4].map(m=>jsxRuntime.jsx("div",{className:"w-0.5 rounded-full bg-(--accent)",style:{height:`${6+m*3}px`,animation:`mp-eq-bar ${.3+m*.12}s ease-in-out infinite alternate`}},m))})})]}),jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx("div",{className:"truncate text-xs font-medium",children:e.title}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[e.type&&jsxRuntime.jsx("span",{className:"text-[10px] uppercase tracking-wide opacity-50",children:e.type}),e.duration!=null&&jsxRuntime.jsx("span",{className:"font-mono text-[10px] opacity-40",children:j(e.duration)})]})]}),a&&jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-(--accent)"})]},n)})})]})}),jsxRuntime.jsx("style",{children:`
2
2
  .cp-btn {
3
3
  display: flex;
4
4
  align-items: center;