@prisma/studio-core 0.0.0-dev.202503281130 → 0.0.0-dev.202503281209

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.
package/dist/ui/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Na=Object.create;var ye=Object.defineProperty;var Ea=Object.getOwnPropertyDescriptor;var Ga=Object.getOwnPropertyNames;var za=Object.getPrototypeOf,Va=Object.prototype.hasOwnProperty;var Wa=(e,a)=>{for(var t in a)ye(e,t,{get:a[t],enumerable:!0})},je=(e,a,t,o)=>{if(a&&typeof a=="object"||typeof a=="function")for(let l of Ga(a))!Va.call(e,l)&&l!==t&&ye(e,l,{get:()=>a[l],enumerable:!(o=Ea(a,l))||o.enumerable});return e};var A=(e,a,t)=>(t=e!=null?Na(za(e)):{},je(a||!e||!e.__esModule?ye(t,"default",{value:e,enumerable:!0}):t,e)),Xa=e=>je(ye({},"__esModule",{value:!0}),e);var St={};Wa(St,{Studio:()=>_e});module.exports=Xa(St);var Au=require("../index-KSZNOSSS.css");var Ha=require("nuqs/adapters/react"),v=A(require("react"),1);var ea=require("@radix-ui/react-slot"),aa=require("nuqs");var $e=require("clsx"),Ye=require("tailwind-merge");function u(...e){return(0,Ye.twMerge)((0,$e.clsx)(e))}var U=require("react/jsx-runtime"),te=()=>{let{setCurrentTable:e,currentTable:a,favoriteTableIds:t,tables:o}=re(),[l,L]=(0,aa.useQueryState)("tableId"),s=async f=>{await L(f);let C=o.find(S=>S.id===f);C&&e(C)};return(0,U.jsxs)("div",{className:"ps-flex ps-flex-col ps-w-64 ps-gap-4 ps-shrink-0",children:[(0,U.jsx)(te.Block,{label:"Tables",children:o.map(f=>(0,U.jsx)(te.Item,{isActive:a?.id===f.id,onClick:C=>{C.preventDefault(),s(f.id)},className:`ps-px-2 ps-py-1 ps-cursor-pointer ps-rounded ${a?.id===f.id?"ps-bg-primary ps-text-white":"ps-hover:ps-bg-gray-100"}`,children:f.name},f.id))}),t.size>0&&(0,U.jsx)(te.Block,{label:"Favourites",children:o.filter(f=>t.has(f.id)).map(f=>(0,U.jsx)(te.Item,{isActive:a?.id===f.id,onClick:C=>{C.preventDefault(),s(f.id)},children:f.name},f.id))})]})},Ka=({className:e,label:a,children:t,...o})=>(0,U.jsxs)("div",{className:u("ps-rounded-lg ps-border ps-bg-card ps-text-card-foreground ps-shadow-xs",e),...o,children:[(0,U.jsx)("div",{className:"ps-pt-4 ps-pb-2 ps-px-4",children:(0,U.jsx)("h2",{className:"ps-text-sm ps-font-medium",children:a})}),(0,U.jsx)("nav",{"aria-label":a,className:"ps-flex ps-flex-col ps-gap-px ps-pb-3",children:t})]}),Za=({className:e,asChild:a=!1,isActive:t,size:o,...l})=>(0,U.jsx)(a?ea.Slot:"button",{"data-sidebar":"menu-button","data-size":o,"data-active":t,className:u("ps-py-1.5 ps-px-4 ps-text-sm ps-font-medium ps-flex ps-gap-2 ps-items-center ps-border ps-border-transparent ps-bg-transparent ps-hover:bg-muted/50",e),...l});te.Block=Ka;te.Item=Za;var ta=te;var ae=require("@dnd-kit/core"),ie=require("@dnd-kit/sortable"),Ba=require("@dnd-kit/utilities"),W=require("@tanstack/react-table"),N=require("react");var X=A(require("react"),1);var z=require("react/jsx-runtime"),qe=X.forwardRef(({className:e,...a},t)=>(0,z.jsx)("div",{className:"ps-relative ps-w-full ps-overflow-auto ps-flex ps-items-start ps-h-full",children:(0,z.jsx)("table",{ref:t,className:u("ps-w-full ps-caption-bottom ps-text-sm table-fixed",e),...a})}));qe.displayName="Table";var Ue=X.forwardRef(({className:e,...a},t)=>(0,z.jsx)("thead",{ref:t,className:u("[&_tr]:ps-border-b",e),...a}));Ue.displayName="TableHeader";var He=X.forwardRef(({className:e,...a},t)=>(0,z.jsx)("tbody",{ref:t,className:u("[&_tr:last-child]:ps-border-0",e),...a}));He.displayName="TableBody";var Ja=X.forwardRef(({className:e,...a},t)=>(0,z.jsx)("tfoot",{ref:t,className:u("ps-border-t ps-bg-muted/50 ps-font-medium [&>tr]:last:ps-border-b-0",e),...a}));Ja.displayName="TableFooter";var ce=X.forwardRef(({className:e,...a},t)=>(0,z.jsx)("tr",{ref:t,className:u("ps-border-b ps-transition-colors hover:ps-bg-muted/50 data-[state=selected]:ps-bg-muted",e),...a}));ce.displayName="TableRow";var De=X.forwardRef(({className:e,...a},t)=>(0,z.jsx)("th",{ref:t,className:u("ps-h-10 ps-px-2 ps-text-left ps-align-middle ps-font-medium ps-text-muted-foreground [&:has([role=checkbox])]:ps-pr-0 [&>[role=checkbox]]:ps-translate-y-[2px]",e),...a}));De.displayName="TableHead";var pe=X.forwardRef(({className:e,...a},t)=>(0,z.jsx)("td",{ref:t,className:u("ps-p-2 ps-align-middle [&:has([role=checkbox])]:ps-pr-0 [&>[role=checkbox]]:ps-translate-y-[2px]",e),...a}));pe.displayName="TableCell";var Qa=X.forwardRef(({className:e,...a},t)=>(0,z.jsx)("caption",{ref:t,className:u("ps-mt-4 ps-text-sm ps-text-muted-foreground",e),...a}));Qa.displayName="TableCaption";var Ae=require("react");var oa=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Te=(...e)=>e.filter((a,t,o)=>!!a&&o.indexOf(a)===t).join(" ");var me=require("react");var la={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var ua=(0,me.forwardRef)(({color:e="currentColor",size:a=24,strokeWidth:t=2,absoluteStrokeWidth:o,className:l="",children:L,iconNode:s,...f},C)=>(0,me.createElement)("svg",{ref:C,...la,width:a,height:a,stroke:e,strokeWidth:o?Number(t)*24/Number(a):t,className:Te("lucide",l),...f},[...s.map(([S,b])=>(0,me.createElement)(S,b)),...Array.isArray(L)?L:[L]]));var m=(e,a)=>{let t=(0,Ae.forwardRef)(({className:o,...l},L)=>(0,Ae.createElement)(ua,{ref:L,iconNode:a,className:Te(`lucide-${oa(e)}`,o),...l}));return t.displayName=`${e}`,t};var $=m("ArrowDownWideNarrow",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h10",key:"1w87gc"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h4",key:"q8tih4"}]]);var Le=m("ArrowUpWideNarrow",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h4",key:"1krc32"}]]);var K=m("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);var se=m("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);var xe=m("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);var Z=m("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);var Ie=m("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);var Ce=m("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);var ge=m("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);var oe=m("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);var he=m("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);var Y=m("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);var Se=m("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);var Pe=m("PinOff",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]);var we=m("Pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);var ke=m("Star",[["polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2",key:"8f66p6"}]]);var be=require("react/jsx-runtime");function da(){let{currentTable:e,favoriteTableIds:a,toggleFavorite:t,isLoaded:o}=re();if(!o||!e)return null;let l=a.has(e.id);return(0,be.jsxs)("button",{type:"button",onClick:()=>t(e.id),className:u("ps-appearance-none",l&&"ps-text-yellow-500"),children:[(0,be.jsx)(ke,{size:12,className:u("ps-transition-colors",l&&"ps-fill-yellow-500")}),(0,be.jsx)("span",{className:"ps-sr-only",children:l?"Remove from favorites":"Add to favorites"})]})}var ma=require("@uiw/codemirror-theme-tokyo-night"),La=A(require("@uiw/react-codemirror"),1);var J=A(require("@radix-ui/react-popover"),1),y=A(require("react"),1);var fe=require("react/jsx-runtime"),ra=y.createContext(null),Oe=({children:e,...a})=>{let[t,o]=y.useState(!1);return(0,fe.jsx)(ra.Provider,{value:{open:t,setOpen:o},children:(0,fe.jsx)(J.Root,{open:t,onOpenChange:o,...a,children:e})})};Oe.displayName="PopoverCell";var Ne=y.forwardRef(({children:e,onDoubleClick:a,className:t,...o},l)=>{let L=y.useContext(ra),[s,f]=y.useState(!1),C=y.useRef(null);return y.useEffect(()=>{let R=ne=>{let O=ne.target;C.current&&!C.current.contains(O)&&(console.log("Outside click - removing focus"),f(!1))};return document.addEventListener("click",R),()=>document.removeEventListener("click",R)},[]),(0,fe.jsx)(J.Trigger,{ref:R=>{typeof l=="function"?l(R):l&&(l.current=R),C.current=R},onClick:R=>{R.preventDefault(),console.log("Click handler - setting focus to true"),f(!0)},onDoubleClick:R=>{R.preventDefault(),L?.setOpen(!0),a?.()},"data-focus":s.toString(),className:u("w-full h-full cursor-pointer",t),...o,children:e})});Ne.displayName="PopoverCellTrigger";var Ee=y.forwardRef(({className:e,align:a="center",sideOffset:t=4,...o},l)=>(0,fe.jsx)(J.Portal,{children:(0,fe.jsx)(J.Content,{ref:l,align:a,sideOffset:t,className:u("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-hidden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...o})}));Ee.displayName=J.Content.displayName;var ia=require("react");var i=A(require("@radix-ui/react-context-menu"),1);var Q=A(require("react"),1);var w=require("react/jsx-runtime"),sa=i.Root,fa=i.Trigger;var _a=Q.forwardRef(({className:e,inset:a,children:t,...o},l)=>(0,w.jsxs)(i.SubTrigger,{ref:l,className:u("ps-flex ps-cursor-default ps-select-none ps-items-center ps-rounded-sm ps-px-2 ps-py-1.5 ps-text-sm ps-outline-none focus:ps-bg-accent focus:ps-text-accent-foreground data-[state=open]:ps-bg-accent data-[state=open]:ps-text-accent-foreground",a&&"ps-pl-8",e),...o,children:[t,(0,w.jsx)(Z,{className:"ps-ml-auto ps-h-4 ps-w-4"})]}));_a.displayName=i.SubTrigger.displayName;var ja=Q.forwardRef(({className:e,...a},t)=>(0,w.jsx)(i.SubContent,{ref:t,className:u("ps-z-50 ps-min-w-[8rem] ps-overflow-hidden ps-rounded-md ps-border ps-bg-popover ps-p-1 ps-text-popover-foreground ps-shadow-lg data-[state=open]:ps-animate-in data-[state=closed]:ps-animate-out data-[state=closed]:ps-fade-out-0 data-[state=open]:ps-fade-in-0 data-[state=closed]:ps-zoom-out-95 data-[state=open]:ps-zoom-in-95 data-[side=bottom]:ps-slide-in-from-top-2 data-[side=left]:ps-slide-in-from-right-2 data-[side=right]:ps-slide-in-from-left-2 data-[side=top]:ps-slide-in-from-bottom-2 ps-origin-[--radix-context-menu-content-transform-origin]",e),...a}));ja.displayName=i.SubContent.displayName;var Ge=Q.forwardRef(({className:e,...a},t)=>(0,w.jsx)(i.Portal,{children:(0,w.jsx)(i.Content,{ref:t,className:u("ps-z-50 ps-max-h-[--radix-context-menu-content-available-height] ps-min-w-[8rem] ps-overflow-y-auto ps-overflow-x-hidden ps-rounded-md ps-border ps-bg-popover ps-p-1 ps-text-popover-foreground ps-shadow-md data-[state=open]:ps-animate-in data-[state=closed]:ps-animate-out data-[state=closed]:ps-fade-out-0 data-[state=open]:ps-fade-in-0 data-[state=closed]:ps-zoom-out-95 data-[state=open]:ps-zoom-in-95 data-[side=bottom]:ps-slide-in-from-top-2 data-[side=left]:ps-slide-in-from-right-2 data-[side=right]:ps-slide-in-from-left-2 data-[side=top]:ps-slide-in-from-bottom-2 ps-origin-[--radix-context-menu-content-transform-origin]",e),...a})}));Ge.displayName=i.Content.displayName;var ze=Q.forwardRef(({className:e,inset:a,...t},o)=>(0,w.jsx)(i.Item,{ref:o,className:u("ps-relative ps-flex ps-cursor-default ps-select-none ps-items-center ps-rounded-sm ps-px-2 ps-py-1.5 ps-text-sm ps-outline-none focus:ps-bg-accent focus:ps-text-accent-foreground data-[disabled]:ps-pointer-events-none data-[disabled]:ps-opacity-50",a&&"ps-pl-8",e),...t}));ze.displayName=i.Item.displayName;var $a=Q.forwardRef(({className:e,children:a,checked:t,...o},l)=>(0,w.jsxs)(i.CheckboxItem,{ref:l,className:u("ps-relative ps-flex ps-cursor-default ps-select-none ps-items-center ps-rounded-sm ps-py-1.5 ps-pl-8 ps-pr-2 ps-text-sm ps-outline-none focus:ps-bg-accent focus:ps-text-accent-foreground data-[disabled]:ps-pointer-events-none data-[disabled]:ps-opacity-50",e),checked:t,...o,children:[(0,w.jsx)("span",{className:"ps-absolute ps-left-2 ps-flex ps-h-3.5 ps-w-3.5 ps-items-center ps-justify-center",children:(0,w.jsx)(i.ItemIndicator,{children:(0,w.jsx)(K,{className:"ps-h-4 ps-w-4"})})}),a]}));$a.displayName=i.CheckboxItem.displayName;var Ya=Q.forwardRef(({className:e,children:a,...t},o)=>(0,w.jsxs)(i.RadioItem,{ref:o,className:u("ps-relative ps-flex ps-cursor-default ps-select-none ps-items-center ps-rounded-sm ps-py-1.5 ps-pl-8 ps-pr-2 ps-text-sm ps-outline-none focus:ps-bg-accent focus:ps-text-accent-foreground data-[disabled]:ps-pointer-events-none data-[disabled]:ps-opacity-50",e),...t,children:[(0,w.jsx)("span",{className:"ps-absolute ps-left-2 ps-flex ps-h-3.5 ps-w-3.5 ps-items-center ps-justify-center",children:(0,w.jsx)(i.ItemIndicator,{children:(0,w.jsx)(oe,{className:"ps-h-4 ps-w-4 ps-fill-current"})})}),a]}));Ya.displayName=i.RadioItem.displayName;var et=Q.forwardRef(({className:e,inset:a,...t},o)=>(0,w.jsx)(i.Label,{ref:o,className:u("ps-px-2 ps-py-1.5 ps-text-sm ps-font-semibold ps-text-foreground",a&&"ps-pl-8",e),...t}));et.displayName=i.Label.displayName;var at=Q.forwardRef(({className:e,...a},t)=>(0,w.jsx)(i.Separator,{ref:t,className:u("ps--mx-1 ps-my-1 ps-h-px ps-bg-border",e),...a}));at.displayName=i.Separator.displayName;var tt=({className:e,...a})=>(0,w.jsx)("span",{className:u("ps-ml-auto ps-text-xs ps-tracking-widest ps-text-muted-foreground",e),...a});tt.displayName="ContextMenuShortcut";var le=require("react/jsx-runtime"),Ve=e=>{if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return String(e);if(e==null)return"";if((0,ia.isValidElement)(e)){let a=e.props;return e.type&&typeof e.type=="function"&&e.type.name==="RevealText"?a.text||"":e.type&&typeof e.type=="function"&&e.type.name==="NullValue"?"NULL":a.children?Ve(a.children):""}return Array.isArray(e)?e.map(Ve).join(""):""},na=({children:e})=>(0,le.jsxs)(sa,{children:[(0,le.jsx)(fa,{className:"ps-block ps-w-full ps-p-[var(--studio-cell-spacing)]",children:e}),(0,le.jsx)(Ge,{children:(0,le.jsxs)(ze,{onClick:()=>{let a=Ve(e);navigator.clipboard.writeText(a).catch(t=>{console.error("Failed to copy to clipboard:",t)})},className:"ps-flex ps-items-center ps-gap-2",children:[(0,le.jsx)(he,{size:12}),"Copy"]})})]});var pa=require("react/jsx-runtime");function ca(){return(0,pa.jsx)("code",{className:"ps-text-gray-500",children:"NULL"})}var _=require("react/jsx-runtime");function xa({cell:e,getPinningStyles:a,dataType:t,isRelational:o,relatesTo:l,relationField:L}){let s=e.getValue(),f=s==null,C=S=>{if(S==null)return"NULL";if(typeof S=="object")try{return JSON.stringify(S,null,2)}catch(b){return console.error("Error stringifying value:",b),String(S)}return String(S)};return(0,_.jsxs)(Oe,{children:[(0,_.jsx)(Ne,{asChild:!0,children:(0,_.jsx)(pe,{...a(e.column),"data-cell-type":"data","data-type":t.toLowerCase(),"data-relational":o?"true":void 0,"data-relates-to":l,"data-relation-field":L,className:u(a(e.column).className,"ps-p-0",e.column.getIsPinned()&&"ps-sticky"),children:(0,_.jsx)(na,{children:f?(0,_.jsx)(ca,{}):C(s)})})}),(0,_.jsx)(Ee,{align:"start",alignOffset:0,sideOffset:0,className:"ps-min-w-(--radix-popover-trigger-width) ps-rounded-none ps-bg-muted ps-p-0",children:(0,_.jsx)(La.default,{value:C(s),theme:ma.tokyoNight,height:"100px",basicSetup:{lineNumbers:!0,foldGutter:!1,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!1},onChange:S=>{console.log("New value:",S)}})})]},e.id)}var Ca=require("react/jsx-runtime");function Ia({cell:e,getPinningStyles:a,dataType:t}){let o={cell:e,getPinningStyles:a},l=e.column.columnDef.meta,L={...o,isRelational:l?.isRelational,relatesTo:l?.relatesTo,relationField:l?.relationField};return(0,Ca.jsx)(xa,{...L,dataType:t||"STRING"})}var ba=require("@tanstack/react-table");var ga=require("@radix-ui/react-slot"),ha=require("class-variance-authority"),Sa=A(require("react"),1);var Pa=require("react/jsx-runtime"),ot=(0,ha.cva)("ps-inline-flex ps-items-center ps-justify-center ps-gap-2 ps-whitespace-nowrap ps-rounded-md ps-text-sm ps-font-medium ps-transition-colors focus-visible:ps-outline-none focus-visible:ps-ring-1 focus-visible:ps-ring-ring disabled:ps-pointer-events-none disabled:ps-opacity-50 [&_svg]:ps-pointer-events-none [&_svg]:ps-size-4 [&_svg]:ps-shrink-0",{variants:{variant:{default:"ps-bg-primary ps-text-primary-foreground ps-shadow hover:ps-bg-primary/90",destructive:"ps-bg-destructive ps-text-destructive-foreground ps-shadow-sm hover:ps-bg-destructive/90",outline:"ps-border ps-border-input ps-bg-background ps-shadow-sm hover:ps-bg-accent hover:ps-text-accent-foreground",secondary:"ps-bg-secondary ps-text-secondary-foreground ps-shadow-sm hover:ps-bg-secondary/80",ghost:"hover:ps-bg-accent hover:ps-text-accent-foreground",link:"ps-text-primary ps-underline-offset-4 hover:ps-underline"},size:{default:"ps-h-9 ps-px-4 ps-py-2",sm:"ps-h-8 ps-rounded-md ps-px-3 ps-text-xs",lg:"ps-h-10 ps-rounded-md ps-px-8",icon:"ps-h-9 ps-w-9"}},defaultVariants:{variant:"default",size:"default"}}),V=Sa.forwardRef(({className:e,variant:a,size:t,asChild:o=!1,...l},L)=>(0,Pa.jsx)(o?ga.Slot:"button",{className:u(ot({variant:a,size:t,className:e})),ref:L,...l}));V.displayName="Button";var n=A(require("@radix-ui/react-dropdown-menu"),1);var j=A(require("react"),1);var k=require("react/jsx-runtime"),wa=n.Root,ka=n.Trigger;var lt=j.forwardRef(({className:e,inset:a,children:t,...o},l)=>(0,k.jsxs)(n.SubTrigger,{ref:l,className:u("ps-flex ps-cursor-default ps-select-none ps-items-center ps-gap-2 ps-rounded-sm ps-px-2 ps-py-1.5 ps-text-sm ps-outline-none focus:ps-bg-accent data-[state=open]:ps-bg-accent [&_svg]:ps-pointer-events-none [&_svg]:ps-size-4 [&_svg]:ps-shrink-0",a&&"ps-pl-8",e),...o,children:[t,(0,k.jsx)(Z,{className:"ps-ml-auto"})]}));lt.displayName=n.SubTrigger.displayName;var ut=j.forwardRef(({className:e,...a},t)=>(0,k.jsx)(n.SubContent,{ref:t,className:u("ps-z-50 ps-min-w-[8rem] ps-overflow-hidden ps-rounded-md ps-border ps-bg-popover ps-p-1 ps-text-popover-foreground ps-shadow-lg data-[state=open]:ps-animate-in data-[state=closed]:ps-animate-out data-[state=closed]:ps-fade-out-0 data-[state=open]:ps-fade-in-0 data-[state=closed]:ps-zoom-out-95 data-[state=open]:ps-zoom-in-95 data-[side=bottom]:ps-slide-in-from-top-2 data-[side=left]:ps-slide-in-from-right-2 data-[side=right]:ps-slide-in-from-left-2 data-[side=top]:ps-slide-in-from-bottom-2 ps-origin-[--radix-dropdown-menu-content-transform-origin]",e),...a}));ut.displayName=n.SubContent.displayName;var We=j.forwardRef(({className:e,sideOffset:a=4,...t},o)=>(0,k.jsx)(n.Portal,{children:(0,k.jsx)(n.Content,{ref:o,sideOffset:a,className:u("ps-z-50 ps-max-h-[var(--radix-dropdown-menu-content-available-height)] ps-min-w-[8rem] ps-overflow-y-auto ps-overflow-x-hidden ps-rounded-md ps-border ps-bg-popover ps-p-1 ps-text-popover-foreground ps-shadow-md","data-[state=open]:ps-animate-in data-[state=closed]:ps-animate-out data-[state=closed]:ps-fade-out-0 data-[state=open]:ps-fade-in-0 data-[state=closed]:ps-zoom-out-95 data-[state=open]:ps-zoom-in-95 data-[side=bottom]:ps-slide-in-from-top-2 data-[side=left]:ps-slide-in-from-right-2 data-[side=right]:ps-slide-in-from-left-2 data-[side=top]:ps-slide-in-from-bottom-2 ps-origin-[--radix-dropdown-menu-content-transform-origin]",e),...t})}));We.displayName=n.Content.displayName;var Be=j.forwardRef(({className:e,inset:a,...t},o)=>(0,k.jsx)(n.Item,{ref:o,className:u("ps-relative ps-flex ps-cursor-default ps-select-none ps-items-center ps-gap-2 ps-rounded-sm ps-px-2 ps-py-1.5 ps-text-sm ps-outline-none ps-transition-colors focus:ps-bg-accent focus:ps-text-accent-foreground data-[disabled]:ps-pointer-events-none data-[disabled]:ps-opacity-50 [&>svg]:ps-size-4 [&>svg]:ps-shrink-0",a&&"ps-pl-8",e),...t}));Be.displayName=n.Item.displayName;var dt=j.forwardRef(({className:e,children:a,checked:t,...o},l)=>(0,k.jsxs)(n.CheckboxItem,{ref:l,className:u("ps-relative ps-flex ps-cursor-default ps-select-none ps-items-center ps-rounded-sm ps-py-1.5 ps-pl-8 ps-pr-2 ps-text-sm ps-outline-none ps-transition-colors focus:ps-bg-accent focus:ps-text-accent-foreground data-[disabled]:ps-pointer-events-none data-[disabled]:ps-opacity-50",e),checked:t,...o,children:[(0,k.jsx)("span",{className:"ps-absolute ps-left-2 ps-flex ps-h-3.5 ps-w-3.5 ps-items-center ps-justify-center",children:(0,k.jsx)(n.ItemIndicator,{children:(0,k.jsx)(K,{className:"ps-h-4 ps-w-4"})})}),a]}));dt.displayName=n.CheckboxItem.displayName;var rt=j.forwardRef(({className:e,children:a,...t},o)=>(0,k.jsxs)(n.RadioItem,{ref:o,className:u("ps-relative ps-flex ps-cursor-default ps-select-none ps-items-center ps-rounded-sm ps-py-1.5 ps-pl-8 ps-pr-2 ps-text-sm ps-outline-none ps-transition-colors focus:ps-bg-accent focus:ps-text-accent-foreground data-[disabled]:ps-pointer-events-none data-[disabled]:ps-opacity-50",e),...t,children:[(0,k.jsx)("span",{className:"ps-absolute ps-left-2 ps-flex ps-h-3.5 ps-w-3.5 ps-items-center ps-justify-center",children:(0,k.jsx)(n.ItemIndicator,{children:(0,k.jsx)(oe,{className:"ps-h-2 ps-w-2 ps-fill-current"})})}),a]}));rt.displayName=n.RadioItem.displayName;var st=j.forwardRef(({className:e,inset:a,...t},o)=>(0,k.jsx)(n.Label,{ref:o,className:u("ps-px-2 ps-py-1.5 ps-text-sm ps-font-semibold",a&&"ps-pl-8",e),...t}));st.displayName=n.Label.displayName;var ft=j.forwardRef(({className:e,...a},t)=>(0,k.jsx)(n.Separator,{ref:t,className:u("ps--mx-1 ps-my-1 ps-h-px ps-bg-muted",e),...a}));ft.displayName=n.Separator.displayName;var it=({className:e,...a})=>(0,k.jsx)("span",{className:u("ps-ml-auto ps-text-xs ps-tracking-widest ps-opacity-60",e),...a});it.displayName="DropdownMenuShortcut";var x=require("react/jsx-runtime");function Xe({header:e}){let a=e.column.columnDef.meta,t=a?.dataType,o=a?.isRelational;return(0,x.jsxs)("div",{className:"ps-flex ps-items-center ps-justify-between ps-w-full ps-h-full",children:[(0,x.jsxs)("div",{className:"ps-flex-1 ps-flex ps-items-center ps-justify-between",children:[o&&(0,x.jsx)(Se,{size:14,className:"text-blue-700"}),(0,x.jsxs)("div",{className:"ps-align-text-bottom ps-leading-none ps-h-[20px]",children:[(0,x.jsx)("span",{className:"ps-inline-block ps-text-foreground ps-font-bold ps-text-sm",children:e.isPlaceholder?null:(0,ba.flexRender)(e.column.columnDef.header,e.getContext())}),t&&t!=="NONE"&&(0,x.jsx)("span",{className:"ps-inline-block ps-ml-2 ps-text-xs ps-font-mono ps-text-muted-foreground/70 ps-lowercase",children:t})]}),(0,x.jsx)("span",{className:"ps-flex ps-items-center ps-gap-1",children:e.column.getCanPin()&&e.column.id!=="select"&&(0,x.jsxs)(wa,{children:[(0,x.jsx)(ka,{asChild:!0,children:(0,x.jsx)(V,{variant:"ghost",size:"icon",children:(0,x.jsx)(Y,{size:16})})}),(0,x.jsxs)(We,{children:[e.column.getCanSort()&&(0,x.jsx)(Be,{onClick:()=>e.column.toggleSorting(e.column.getIsSorted()==="asc"),children:(0,x.jsxs)("span",{className:"ps-flex ps-items-center ps-gap-2",children:[e.column.getIsSorted()==="asc"?(0,x.jsx)($,{size:16}):(0,x.jsx)(Le,{size:16}),e.column.getIsSorted()==="asc"?"Sort descending":"Sort ascending"]})}),(0,x.jsx)(Be,{onClick:()=>e.column.pin(e.column.getIsPinned()?!1:"left"),children:e.column.getIsPinned()?(0,x.jsxs)("span",{className:"ps-flex ps-items-center ps-gap-2",children:[(0,x.jsx)(Pe,{size:16}),"Unpin column"]}):(0,x.jsxs)("span",{className:"ps-flex ps-items-center ps-gap-2",children:[(0,x.jsx)(we,{size:16}),"Pin column"]})})]})]})})]}),e.column.getCanResize()&&(0,x.jsx)("button",{type:"button",tabIndex:0,onMouseDown:l=>{l.stopPropagation(),e.getResizeHandler()(l)},onTouchStart:l=>{l.stopPropagation(),e.getResizeHandler()(l)},onClick:l=>l.stopPropagation(),onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),l.stopPropagation(),e.getResizeHandler()(l))},className:u("ps-absolute ps-right-0 ps-top-0 ps-h-full ps-w-3 ps-cursor-col-resize","ps-select-none ps-touch-none ps-transition-colors ps-group","ps-border-0 ps-bg-transparent",e.column.getIsResizing()&&"ps-bg-gray-300","before:ps-absolute before:ps-right-[3px] before:ps-top-1/2 before:ps--translate-y-1/2","after:ps-absolute after:ps-right-[7px] after:ps-top-1/2 after:ps--translate-y-1/2","before:ps-w-[2px] before:ps-h-0 before:ps-bg-gray-400 before:ps-rounded-full before:ps-opacity-0","after:ps-w-[2px] after:ps-h-0 after:ps-bg-gray-400 after:ps-rounded-full after:ps-opacity-0","before:ps-transition-all before:ps-duration-200","after:ps-transition-all after:ps-duration-200","group-hover:before:ps-opacity-100","group-hover:after:ps-opacity-100","group-hover:before:ps-h-4","group-hover:after:ps-h-4","group-active:ps-bg-transparent group-active:before:ps-bg-white group-active:after:ps-bg-white",e.column.getIsResizing()&&"before:ps-opacity-100"),"aria-label":"Resize column"})]})}var Ra=A(require("react"),1);var Ma=require("react/jsx-runtime"),Ke=Ra.forwardRef(({className:e,type:a,...t},o)=>(0,Ma.jsx)("input",{type:a,className:u("ps-flex ps-h-9 ps-w-full ps-rounded-md ps-border ps-border-input ps-bg-transparent ps-px-3 ps-py-1 ps-text-base ps-shadow-sm ps-transition-colors file:ps-border-0 file:ps-bg-transparent file:ps-text-sm file:ps-font-medium file:ps-text-foreground placeholder:ps-text-muted-foreground focus-visible:ps-outline-none focus-visible:ps-ring-1 focus-visible:ps-ring-ring disabled:ps-cursor-not-allowed disabled:ps-opacity-50 md:ps-text-sm",e),ref:o,...t}));Ke.displayName="Input";var c=A(require("@radix-ui/react-select"),1);var ee=A(require("react"),1);var h=require("react/jsx-runtime"),va=c.Root;var ya=c.Value,Ze=ee.forwardRef(({className:e,children:a,...t},o)=>(0,h.jsxs)(c.Trigger,{ref:o,className:u("ps-flex ps-h-9 ps-w-full ps-items-center ps-justify-between ps-whitespace-nowrap ps-rounded-md ps-border ps-border-input ps-bg-transparent ps-px-3 ps-py-2 ps-text-sm ps-shadow-sm ps-ring-offset-background data-[placeholder]:ps-text-muted-foreground focus:ps-outline-none focus:ps-ring-1 focus:ps-ring-ring disabled:ps-cursor-not-allowed disabled:ps-opacity-50 [&>span]:ps-line-clamp-1",e),...t,children:[a,(0,h.jsx)(c.Icon,{asChild:!0,children:(0,h.jsx)(se,{className:"ps-h-4 ps-w-4 ps-opacity-50"})})]}));Ze.displayName=c.Trigger.displayName;var Da=ee.forwardRef(({className:e,...a},t)=>(0,h.jsx)(c.ScrollUpButton,{ref:t,className:u("ps-flex ps-cursor-default ps-items-center ps-justify-center ps-py-1",e),...a,children:(0,h.jsx)(Ie,{className:"ps-h-4 ps-w-4"})}));Da.displayName=c.ScrollUpButton.displayName;var Ta=ee.forwardRef(({className:e,...a},t)=>(0,h.jsx)(c.ScrollDownButton,{ref:t,className:u("ps-flex ps-cursor-default ps-items-center ps-justify-center ps-py-1",e),...a,children:(0,h.jsx)(se,{className:"ps-h-4 ps-w-4"})}));Ta.displayName=c.ScrollDownButton.displayName;var Je=ee.forwardRef(({className:e,children:a,position:t="popper",...o},l)=>(0,h.jsx)(c.Portal,{children:(0,h.jsxs)(c.Content,{ref:l,className:u("ps-relative ps-z-50 ps-max-h-[--radix-select-content-available-height] ps-min-w-[8rem] ps-overflow-y-auto ps-overflow-x-hidden ps-rounded-md ps-border ps-bg-popover ps-text-popover-foreground ps-shadow-md data-[state=open]:ps-animate-in data-[state=closed]:ps-animate-out data-[state=closed]:ps-fade-out-0 data-[state=open]:ps-fade-in-0 data-[state=closed]:ps-zoom-out-95 data-[state=open]:ps-zoom-in-95 data-[side=bottom]:ps-slide-in-from-top-2 data-[side=left]:ps-slide-in-from-right-2 data-[side=right]:ps-slide-in-from-left-2 data-[side=top]:ps-slide-in-from-bottom-2 ps-origin-[--radix-select-content-transform-origin]",t==="popper"&&"data-[side=bottom]:ps-translate-y-1 data-[side=left]:ps--translate-x-1 data-[side=right]:ps-translate-x-1 data-[side=top]:ps--translate-y-1",e),position:t,...o,children:[(0,h.jsx)(Da,{}),(0,h.jsx)(c.Viewport,{className:u("ps-p-1",t==="popper"&&"ps-h-[var(--radix-select-trigger-height)] ps-w-full ps-min-w-[var(--radix-select-trigger-width)]"),children:a}),(0,h.jsx)(Ta,{})]})}));Je.displayName=c.Content.displayName;var nt=ee.forwardRef(({className:e,...a},t)=>(0,h.jsx)(c.Label,{ref:t,className:u("ps-px-2 ps-py-1.5 ps-text-sm ps-font-semibold",e),...a}));nt.displayName=c.Label.displayName;var Qe=ee.forwardRef(({className:e,children:a,...t},o)=>(0,h.jsxs)(c.Item,{ref:o,className:u("ps-relative ps-flex ps-w-full ps-cursor-default ps-select-none ps-items-center ps-rounded-sm ps-py-1.5 ps-pl-2 ps-pr-8 ps-text-sm ps-outline-none focus:ps-bg-accent focus:ps-text-accent-foreground data-[disabled]:ps-pointer-events-none data-[disabled]:ps-opacity-50",e),...t,children:[(0,h.jsx)("span",{className:"ps-absolute ps-right-2 ps-flex ps-h-3.5 ps-w-3.5 ps-items-center ps-justify-center",children:(0,h.jsx)(c.ItemIndicator,{children:(0,h.jsx)(K,{className:"ps-h-4 ps-w-4"})})}),(0,h.jsx)(c.ItemText,{children:a})]}));Qe.displayName=c.Item.displayName;var ct=ee.forwardRef(({className:e,...a},t)=>(0,h.jsx)(c.Separator,{ref:t,className:u("ps--mx-1 ps-my-1 ps-h-px ps-bg-muted",e),...a}));ct.displayName=c.Separator.displayName;var I=require("react/jsx-runtime"),pt=[10,20,50,100];function Aa({table:e,variant:a="basic",className:t}){let{pageSize:o,pageIndex:l}=e.getState().pagination,L=e.getPageCount();return(0,I.jsx)("div",{className:u("ps-flex ps-items-center ps-justify-between ps-space-x-2 ps-py-4 ps-px-4",t),children:a==="basic"?(0,I.jsxs)("div",{className:"ps-flex ps-items-center ps-space-x-2",children:[(0,I.jsx)(V,{variant:"outline",size:"sm",className:"ps-h-9",onClick:()=>e.previousPage(),disabled:!e.getCanPreviousPage(),children:"Previous"}),(0,I.jsx)(V,{variant:"outline",size:"sm",className:"ps-h-9",onClick:()=>e.nextPage(),disabled:!e.getCanNextPage(),children:"Next"})]}):(0,I.jsxs)("div",{className:"ps-flex ps-items-center ps-space-x-2",children:[(0,I.jsxs)("div",{className:"ps-flex ps-items-center ps-space-x-2",children:[(0,I.jsx)(V,{variant:"outline",onClick:()=>e.setPageIndex(0),disabled:!e.getCanPreviousPage(),children:(0,I.jsx)(Ce,{className:"ps-w-4 ps-h-4"})}),(0,I.jsx)(V,{variant:"outline",onClick:()=>e.previousPage(),disabled:!e.getCanPreviousPage(),children:(0,I.jsx)(xe,{className:"ps-w-4 ps-h-4"})}),(0,I.jsxs)("div",{className:"ps-flex ps-items-center ps-gap-1 ps-text-xs ps-font-medium",children:["Page",(0,I.jsx)(Ke,{type:"number",min:1,max:L,value:l+1,className:"ps-w-12",onChange:s=>{let f=s.target.value?Number(s.target.value)-1:0;e.setPageIndex(f)}}),(0,I.jsxs)("span",{className:"ps-shrink-0 ps-w-max",children:["of ",L]})]}),(0,I.jsx)(V,{variant:"outline",onClick:()=>e.nextPage(),disabled:!e.getCanNextPage(),children:(0,I.jsx)(Z,{className:"ps-w-4 ps-h-4"})}),(0,I.jsx)(V,{variant:"outline",onClick:()=>e.setPageIndex(L-1),disabled:!e.getCanNextPage(),children:(0,I.jsx)(ge,{className:"ps-w-4 ps-h-4"})})]}),(0,I.jsxs)(va,{value:o.toString(),onValueChange:s=>e.setPageSize(Number(s)),children:[(0,I.jsx)(Ze,{children:(0,I.jsx)(ya,{})}),(0,I.jsx)(Je,{children:pt.map(s=>(0,I.jsxs)(Qe,{value:s.toString(),children:[s," per page"]},s))})]})]})})}var Re=e=>{let a=e.getIsPinned(),t=a==="left"&&e.getIsLastColumn("left"),o=a==="right"&&e.getIsFirstColumn("right");return{className:u("ps-overflow-hidden ps-whitespace-nowrap ps-text-ellipsis",a&&["ps-sticky ps-bg-background ps-shadow-[1px_0_0_0_hsl(var(--border))]",a==="left"?"ps-left-0":"ps-right-0","ps-z-20"],!a&&"ps-relative ps-z-10",t&&"ps-shadow-[1px_0_0_0_hsl(var(--border))]",o&&"ps-shadow-[-1px_0_0_0_hsl(var(--border))]"),style:{width:e.getSize(),left:a==="left"?`${e.getStart("left")}px`:void 0,right:a==="right"?`${e.getAfter("right")}px`:void 0}}};var p=require("react/jsx-runtime"),mt=({_table:e})=>{let{currentTable:a,isLoaded:t}=re();return t?(0,p.jsx)("div",{className:"ps-flex ps-items-center ps-justify-between ps-w-full ps-gap-2",children:(0,p.jsx)("div",{className:"ps-flex ps-items-center ps-gap-2",children:(0,p.jsxs)("span",{className:"ps-flex ps-items-center ps-gap-2",children:[(0,p.jsx)(da,{}),(0,p.jsx)("h1",{className:"ps-text-sm ps-font-medium",children:a?.name})]})})}):null},Lt=({header:e,children:a,getPinningStyles:t})=>{let{attributes:o,listeners:l,transform:L,transition:s,setNodeRef:f,isDragging:C,isOver:S}=(0,ie.useSortable)({id:e.id}),b=e.column.columnDef.meta,R={transform:Ba.CSS.Transform.toString(L),transition:s,...t(e.column).style,cursor:"grab",touchAction:"none"};return(0,p.jsxs)(De,{ref:f,...o,...l,style:R,"data-relational":b?.isRelational?"true":void 0,"data-relates-to":b?.relatesTo,"data-relation-field":b?.relationField,className:u("ps-group",t(e.column).className,C&&"ps-opacity-50",S&&"ps-bg-gray-100","ps-select-none ps-touch-none ps-relative",e.column.getIsPinned()&&"ps-sticky"),children:[a,S&&(0,p.jsx)("div",{className:"ps-absolute ps-inset-0 ps-border-2 ps-border-primary ps-rounded-sm ps-pointer-events-none"})]})};function Fa({data:e=[],columns:a}){console.log("Data received in StudioGrid:",e);let[t,o]=(0,N.useState)([]),[l,L]=(0,N.useState)([]),[s,f]=(0,N.useState)({}),[C,S]=(0,N.useState)({left:[],right:[]}),[b,R]=(0,N.useState)([]),[ne,O]=(0,N.useState)("");(0,N.useEffect)(()=>{if(a&&a.length>0){let g=a.map(q=>q.id);if(b.length===0){R(g);return}let d=[...b],P=d.filter(q=>!a.some(G=>G.id===q));P.forEach(q=>{let G=d.indexOf(q);G!==-1&&d.splice(G,1)});let T=g.filter(q=>!d.includes(q));T.length>0&&d.push(...T),(P.length>0||T.length>0)&&R(d)}},[a,b]);let D=(0,ae.useSensor)(ae.MouseSensor,{activationConstraint:{distance:10}}),B=(0,ae.useSensors)(D),F=g=>{let{active:d,over:P}=g;if(P&&d.id!==P.id){let T=M.getColumn(d.id),q=M.getColumn(P.id);if(!T||!q)return;let G=T.getIsPinned(),de=q.getIsPinned();if(G!==de)return;let Me=b.indexOf(d.id),ve=b.indexOf(P.id);if(Me===-1||ve===-1)return;let Fe=[...b];Fe.splice(Me,1),Fe.splice(ve,0,d.id),R(Fe)}},E=(0,N.useMemo)(()=>{if(!a||a.length===0)return console.log("No columns configuration available"),[];let g=(d,P)=>{if(d==null)return"";switch(P){case"TIMESTAMP":return d?new Date(d).toLocaleString():"";case"UUID":case"STRING":return String(d);default:return String(d)}};return a.map(d=>({accessorKey:d.id,header:()=>(0,p.jsx)("div",{className:"ps-font-medium",children:d.id}),cell:({getValue:P})=>g(P(),d.type),meta:{dataType:d.type,isRelational:d.isRelational,relatesTo:d.relatesTo,relationField:d.relationField}}))},[a]),M=(0,W.useReactTable)({data:e||[],defaultColumn:{size:200,minSize:50,maxSize:500},columns:E,getCoreRowModel:(0,W.getCoreRowModel)(),onSortingChange:o,getSortedRowModel:(0,W.getSortedRowModel)(),getPaginationRowModel:(0,W.getPaginationRowModel)(),getFilteredRowModel:(0,W.getFilteredRowModel)(),onColumnFiltersChange:L,enableColumnResizing:!0,columnResizeMode:"onChange",onColumnSizingChange:f,enableColumnPinning:!0,onColumnPinningChange:S,onGlobalFilterChange:O,globalFilterFn:(g,d,P)=>{let T=g.getValue(d);return T==null?!1:String(T).toLowerCase().includes(String(P).toLowerCase())},state:{sorting:t,columnFilters:l,columnSizing:s,columnPinning:C,columnOrder:b,globalFilter:ne}});return!e||e.length===0?(0,p.jsxs)("div",{className:"ps-p-4 ps-border ps-rounded-md ps-w-full",children:[(0,p.jsx)("p",{className:"ps-text-lg ps-font-semibold",children:"No data available."}),(0,p.jsx)("p",{className:"ps-text-sm ps-text-gray-500",children:e?"Data array is empty.":"Data is undefined."})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("div",{className:"ps-bg-studio-header-background ps-flex ps-w-full ps-p-2 ps-py-3 ps-border-b",children:(0,p.jsx)(mt,{_table:M})}),(0,p.jsx)("div",{"data-studio":"content",className:"ps-flex-1 ps-w-0 ps-h-0 ps-min-w-full",children:(0,p.jsxs)("div",{className:"ps-flex ps-flex-col ps-w-full ps-h-full ps-overflow-scroll",children:[(0,p.jsx)(ae.DndContext,{sensors:B,onDragEnd:F,children:(0,p.jsxs)(qe,{children:[(0,p.jsx)(Ue,{children:M.getHeaderGroups().map(g=>(0,p.jsx)(ce,{className:u("ps-relative",M.getLeftLeafHeaders().some(d=>d.column.getIsPinned()==="left")&&`ps-pl-[${M.getLeftLeafHeaders().filter(d=>d.column.getIsPinned()==="left").reduce((d,P)=>d+P.getSize(),0)}px]`),children:(0,p.jsx)(ie.SortableContext,{items:g.headers.map(d=>d.id),strategy:ie.horizontalListSortingStrategy,children:g.headers.map(d=>d.column.id==="select"?(0,p.jsx)(De,{className:u("ps-px-[var(--studio-cell-spacing)]",Re(d.column).className,d.column.getIsPinned()&&"ps-sticky"),style:Re(d.column).style,"data-cell-type":"select",children:(0,p.jsx)(Xe,{header:d})},d.id):(0,p.jsx)(Lt,{header:d,table:M,getPinningStyles:Re,children:(0,p.jsx)(Xe,{header:d})},d.id))})},g.id))}),(0,p.jsx)(He,{children:M.getRowModel().rows?.length?M.getRowModel().rows.map(g=>(0,p.jsx)(ce,{className:u("ps-bg-table-row ps-odd:bg-table-row-odd ps-group"),children:g.getVisibleCells().map(d=>(0,p.jsx)(Ia,{cell:d,getPinningStyles:Re,dataType:a.find(P=>P.id===d.column.id)?.type},d.id))},g.id)):(0,p.jsx)(ce,{children:(0,p.jsx)(pe,{colSpan:a.length,className:"ps-h-24 ps-text-center",children:"No results."})})})]})}),(0,p.jsx)(Aa,{table:M,variant:"numeric"})]})})]})}var ue=require("react"),Ua=require("react/jsx-runtime"),xt={theme:"system",setTheme:()=>null},It=(0,ue.createContext)(xt);function qa({children:e,defaultTheme:a="system",storageKey:t="vite-ui-theme",...o}){let[l,L]=(0,ue.useState)(()=>localStorage.getItem(t)||a);(0,ue.useEffect)(()=>{let f=window.document.documentElement;if(f.classList.remove("light","dark"),l==="system"){let C=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";f.classList.add(C);return}f.classList.add(l)},[l]);let s={theme:l,setTheme:f=>{localStorage.setItem(t,f),L(f)}};return(0,Ua.jsx)(It.Provider,{...o,value:s,children:e})}var H=require("react/jsx-runtime"),Oa=(0,v.createContext)(void 0),re=()=>{let e=(0,v.useContext)(Oa);if(!e)throw new Error("useStudio must be used within a Studio.Provider");return e},Ct={integer:"INTEGER",varchar:"VARCHAR",text:"TEXT",enum:"STRING",boolean:"BOOLEAN"};function gt(e,a){return{id:e,accessorKey:e,header:e.charAt(0).toUpperCase()+e.slice(1),type:Ct[a.dataType.name]||"STRING",nullable:a.nullable,isKey:a.partOfPk}}var ht=({adapter:e})=>{let[a,t]=(0,v.useState)([]),[o,l]=(0,v.useState)(null),[L,s]=(0,v.useState)(!1),[f,C]=(0,v.useState)([]),[S,b]=(0,v.useState)([]),R=v.default.useMemo(()=>new Set(a.filter(O=>O.isFavorite).map(O=>O.id)),[a]),ne=O=>{t(D=>D.map(B=>B.id===O?{...B,isFavorite:!B.isFavorite}:B))};return(0,v.useEffect)(()=>{(async()=>{try{let[D,B]=await e.introspect();if(D||!B?.schemas){console.error("Error fetching schema:",D);return}let F=Object.entries(B.schemas).flatMap(([E,M])=>Object.entries(M.tables).map(([g])=>({id:`${E}.${g}`,name:g.charAt(0).toUpperCase()+g.slice(1),schema:E,isFavorite:!1})));t(F),!o&&F.length>0&&F[0]&&l(F[0])}catch(D){console.error("Error fetching tables:",D)}})()},[e,o]),(0,v.useEffect)(()=>{(async()=>{if(!o?.id){s(!0);return}try{s(!1);let[D,B]=await e.introspect();if(D||!B?.schemas){console.error("Error fetching schema:",D),s(!0);return}let[F,E]=o.id.split(".");if(!F||!E){console.error("Invalid table ID format:",o.id),s(!0);return}let M=B.schemas[F];if(!M){console.error(`Schema ${F} not found`),s(!0);return}let g=M.tables[E];if(!g){console.error(`Table ${E} not found in schema ${F}`),s(!0);return}let d=Object.entries(g.columns).map(([G,de])=>gt(G,de));b(d);let[P,T]=await e.query({schema:F,table:E,filters:[],sortings:[]});if(P||!T){console.error(`Failed to fetch data for table ${E}:`,P),s(!0);return}let q=T.rows.map(G=>{let de={};return Object.entries(G).forEach(([Me,ve])=>{de[Me]=ve.value}),de});C(q),s(!0)}catch(D){console.error("Error fetching table data:",D),s(!0)}})()},[e,o]),e?!L&&a.length===0?(0,H.jsx)("div",{children:"Loading available tables..."}):L&&a.length===0?(0,H.jsx)("div",{children:"No tables found in the database."}):(0,H.jsx)(qa,{children:(0,H.jsx)(Ha.NuqsAdapter,{children:(0,H.jsx)(Oa.Provider,{value:{adapter:e,currentTable:o,isLoaded:L,tables:a,favoriteTableIds:R,setCurrentTable:l,toggleFavorite:ne},children:(0,H.jsxs)("div",{className:"ps-flex ps-gap-4 ps-w-full ps-rounded-sm ps-bg-background ps-p-4 ps-relative",children:[(0,H.jsx)(ta,{}),(0,H.jsx)("div",{className:"ps-flex ps-w-full ps-flex-col ps-border ps-rounded-lg",children:(0,H.jsx)(Fa,{columns:S,data:f})})]})})})}):(console.error("No adapter provided to Studio component"),(0,H.jsx)("div",{children:"Error: No adapter provided"}))},_e=ht;0&&(module.exports={Studio});
1
+ "use strict";var Ua=Object.create;var Re=Object.defineProperty;var Ha=Object.getOwnPropertyDescriptor;var Oa=Object.getOwnPropertyNames;var Na=Object.getPrototypeOf,Ea=Object.prototype.hasOwnProperty;var Ga=(e,a)=>{for(var t in a)Re(e,t,{get:a[t],enumerable:!0})},Qe=(e,a,t,o)=>{if(a&&typeof a=="object"||typeof a=="function")for(let l of Oa(a))!Ea.call(e,l)&&l!==t&&Re(e,l,{get:()=>a[l],enumerable:!(o=Ha(a,l))||o.enumerable});return e};var A=(e,a,t)=>(t=e!=null?Ua(Na(e)):{},Qe(a||!e||!e.__esModule?Re(t,"default",{value:e,enumerable:!0}):t,e)),za=e=>Qe(Re({},"__esModule",{value:!0}),e);var Ct={};Ga(Ct,{Studio:()=>Je});module.exports=za(Ct);var gu=require("../index-KSZNOSSS.css");var Fa=require("nuqs/adapters/react"),v=A(require("react"),1);var $e=require("@radix-ui/react-slot"),Ye=require("nuqs");var _e=require("clsx"),je=require("tailwind-merge");function u(...e){return(0,je.twMerge)((0,_e.clsx)(e))}var U=require("react/jsx-runtime"),te=()=>{let{setCurrentTable:e,currentTable:a,favoriteTableIds:t,tables:o}=Me(),[l,m]=(0,Ye.useQueryState)("tableId"),r=async f=>{await m(f);let C=o.find(S=>S.id===f);C&&e(C)};return(0,U.jsxs)("div",{className:"ps-flex ps-flex-col ps-w-64 ps-gap-4 ps-shrink-0",children:[(0,U.jsx)(te.Block,{label:"Tables",children:o.map(f=>(0,U.jsx)(te.Item,{isActive:a?.id===f.id,onClick:C=>{C.preventDefault(),r(f.id)},className:`ps-px-2 ps-py-1 ps-cursor-pointer ps-rounded ${a?.id===f.id?"ps-bg-primary ps-text-white":"ps-hover:ps-bg-gray-100"}`,children:f.name},f.id))}),t.size>0&&(0,U.jsx)(te.Block,{label:"Favourites",children:o.filter(f=>t.has(f.id)).map(f=>(0,U.jsx)(te.Item,{isActive:a?.id===f.id,onClick:C=>{C.preventDefault(),r(f.id)},children:f.name},f.id))})]})},Va=({className:e,label:a,children:t,...o})=>(0,U.jsxs)("div",{className:u("ps-rounded-lg ps-border ps-bg-card ps-text-card-foreground ps-shadow-xs",e),...o,children:[(0,U.jsx)("div",{className:"ps-pt-4 ps-pb-2 ps-px-4",children:(0,U.jsx)("h2",{className:"ps-text-sm ps-font-medium",children:a})}),(0,U.jsx)("nav",{"aria-label":a,className:"ps-flex ps-flex-col ps-gap-px ps-pb-3",children:t})]}),Wa=({className:e,asChild:a=!1,isActive:t,size:o,...l})=>(0,U.jsx)(a?$e.Slot:"button",{"data-sidebar":"menu-button","data-size":o,"data-active":t,className:u("ps-py-1.5 ps-px-4 ps-text-sm ps-font-medium ps-flex ps-gap-2 ps-items-center ps-border ps-border-transparent ps-bg-transparent ps-hover:bg-muted/50",e),...l});te.Block=Va;te.Item=Wa;var ea=te;var ae=require("@dnd-kit/core"),fe=require("@dnd-kit/sortable"),Da=require("@dnd-kit/utilities"),W=require("@tanstack/react-table"),N=require("react");var X=A(require("react"),1);var z=require("react/jsx-runtime"),Be=X.forwardRef(({className:e,...a},t)=>(0,z.jsx)("div",{className:"ps-relative ps-w-full ps-overflow-auto ps-flex ps-items-start ps-h-full",children:(0,z.jsx)("table",{ref:t,className:u("ps-w-full ps-caption-bottom ps-text-sm table-fixed",e),...a})}));Be.displayName="Table";var Fe=X.forwardRef(({className:e,...a},t)=>(0,z.jsx)("thead",{ref:t,className:u("[&_tr]:ps-border-b",e),...a}));Fe.displayName="TableHeader";var qe=X.forwardRef(({className:e,...a},t)=>(0,z.jsx)("tbody",{ref:t,className:u("[&_tr:last-child]:ps-border-0",e),...a}));qe.displayName="TableBody";var Xa=X.forwardRef(({className:e,...a},t)=>(0,z.jsx)("tfoot",{ref:t,className:u("ps-border-t ps-bg-muted/50 ps-font-medium [&>tr]:last:ps-border-b-0",e),...a}));Xa.displayName="TableFooter";var ne=X.forwardRef(({className:e,...a},t)=>(0,z.jsx)("tr",{ref:t,className:u("ps-border-b ps-transition-colors hover:ps-bg-muted/50 data-[state=selected]:ps-bg-muted",e),...a}));ne.displayName="TableRow";var ve=X.forwardRef(({className:e,...a},t)=>(0,z.jsx)("th",{ref:t,className:u("ps-h-10 ps-px-2 ps-text-left ps-align-middle ps-font-medium ps-text-muted-foreground [&:has([role=checkbox])]:ps-pr-0 [&>[role=checkbox]]:ps-translate-y-[2px]",e),...a}));ve.displayName="TableHead";var ce=X.forwardRef(({className:e,...a},t)=>(0,z.jsx)("td",{ref:t,className:u("ps-p-2 ps-align-middle [&:has([role=checkbox])]:ps-pr-0 [&>[role=checkbox]]:ps-translate-y-[2px]",e),...a}));ce.displayName="TableCell";var Ka=X.forwardRef(({className:e,...a},t)=>(0,z.jsx)("caption",{ref:t,className:u("ps-mt-4 ps-text-sm ps-text-muted-foreground",e),...a}));Ka.displayName="TableCaption";var na=require("@uiw/codemirror-theme-tokyo-night"),ca=A(require("@uiw/react-codemirror"),1);var K=A(require("@radix-ui/react-popover"),1),y=A(require("react"),1);var se=require("react/jsx-runtime"),aa=y.createContext(null),Ue=({children:e,...a})=>{let[t,o]=y.useState(!1);return(0,se.jsx)(aa.Provider,{value:{open:t,setOpen:o},children:(0,se.jsx)(K.Root,{open:t,onOpenChange:o,...a,children:e})})};Ue.displayName="PopoverCell";var He=y.forwardRef(({children:e,onDoubleClick:a,className:t,...o},l)=>{let m=y.useContext(aa),[r,f]=y.useState(!1),C=y.useRef(null);return y.useEffect(()=>{let R=ie=>{let O=ie.target;C.current&&!C.current.contains(O)&&(console.log("Outside click - removing focus"),f(!1))};return document.addEventListener("click",R),()=>document.removeEventListener("click",R)},[]),(0,se.jsx)(K.Trigger,{ref:R=>{typeof l=="function"?l(R):l&&(l.current=R),C.current=R},onClick:R=>{R.preventDefault(),console.log("Click handler - setting focus to true"),f(!0)},onDoubleClick:R=>{R.preventDefault(),m?.setOpen(!0),a?.()},"data-focus":r.toString(),className:u("w-full h-full cursor-pointer",t),...o,children:e})});He.displayName="PopoverCellTrigger";var Oe=y.forwardRef(({className:e,align:a="center",sideOffset:t=4,...o},l)=>(0,se.jsx)(K.Portal,{children:(0,se.jsx)(K.Content,{ref:l,align:a,sideOffset:t,className:u("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-hidden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...o})}));Oe.displayName=K.Content.displayName;var De=require("react");var ta=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ye=(...e)=>e.filter((a,t,o)=>!!a&&o.indexOf(a)===t).join(" ");var pe=require("react");var oa={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var la=(0,pe.forwardRef)(({color:e="currentColor",size:a=24,strokeWidth:t=2,absoluteStrokeWidth:o,className:l="",children:m,iconNode:r,...f},C)=>(0,pe.createElement)("svg",{ref:C,...oa,width:a,height:a,stroke:e,strokeWidth:o?Number(t)*24/Number(a):t,className:ye("lucide",l),...f},[...r.map(([S,b])=>(0,pe.createElement)(S,b)),...Array.isArray(m)?m:[m]]));var L=(e,a)=>{let t=(0,De.forwardRef)(({className:o,...l},m)=>(0,De.createElement)(la,{ref:m,iconNode:a,className:ye(`lucide-${ta(e)}`,o),...l}));return t.displayName=`${e}`,t};var $=L("ArrowDownWideNarrow",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h10",key:"1w87gc"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h4",key:"q8tih4"}]]);var me=L("ArrowUpWideNarrow",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h4",key:"1krc32"}]]);var Z=L("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);var re=L("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);var Le=L("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);var J=L("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);var xe=L("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);var Ie=L("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);var Ce=L("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);var oe=L("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);var ge=L("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);var Y=L("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);var he=L("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);var Se=L("PinOff",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]);var Pe=L("Pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);var sa=require("react");var i=A(require("@radix-ui/react-context-menu"),1);var Q=A(require("react"),1);var w=require("react/jsx-runtime"),ua=i.Root,da=i.Trigger;var Za=Q.forwardRef(({className:e,inset:a,children:t,...o},l)=>(0,w.jsxs)(i.SubTrigger,{ref:l,className:u("ps-flex ps-cursor-default ps-select-none ps-items-center ps-rounded-sm ps-px-2 ps-py-1.5 ps-text-sm ps-outline-none focus:ps-bg-accent focus:ps-text-accent-foreground data-[state=open]:ps-bg-accent data-[state=open]:ps-text-accent-foreground",a&&"ps-pl-8",e),...o,children:[t,(0,w.jsx)(J,{className:"ps-ml-auto ps-h-4 ps-w-4"})]}));Za.displayName=i.SubTrigger.displayName;var Ja=Q.forwardRef(({className:e,...a},t)=>(0,w.jsx)(i.SubContent,{ref:t,className:u("ps-z-50 ps-min-w-[8rem] ps-overflow-hidden ps-rounded-md ps-border ps-bg-popover ps-p-1 ps-text-popover-foreground ps-shadow-lg data-[state=open]:ps-animate-in data-[state=closed]:ps-animate-out data-[state=closed]:ps-fade-out-0 data-[state=open]:ps-fade-in-0 data-[state=closed]:ps-zoom-out-95 data-[state=open]:ps-zoom-in-95 data-[side=bottom]:ps-slide-in-from-top-2 data-[side=left]:ps-slide-in-from-right-2 data-[side=right]:ps-slide-in-from-left-2 data-[side=top]:ps-slide-in-from-bottom-2 ps-origin-[--radix-context-menu-content-transform-origin]",e),...a}));Ja.displayName=i.SubContent.displayName;var Ne=Q.forwardRef(({className:e,...a},t)=>(0,w.jsx)(i.Portal,{children:(0,w.jsx)(i.Content,{ref:t,className:u("ps-z-50 ps-max-h-[--radix-context-menu-content-available-height] ps-min-w-[8rem] ps-overflow-y-auto ps-overflow-x-hidden ps-rounded-md ps-border ps-bg-popover ps-p-1 ps-text-popover-foreground ps-shadow-md data-[state=open]:ps-animate-in data-[state=closed]:ps-animate-out data-[state=closed]:ps-fade-out-0 data-[state=open]:ps-fade-in-0 data-[state=closed]:ps-zoom-out-95 data-[state=open]:ps-zoom-in-95 data-[side=bottom]:ps-slide-in-from-top-2 data-[side=left]:ps-slide-in-from-right-2 data-[side=right]:ps-slide-in-from-left-2 data-[side=top]:ps-slide-in-from-bottom-2 ps-origin-[--radix-context-menu-content-transform-origin]",e),...a})}));Ne.displayName=i.Content.displayName;var Ee=Q.forwardRef(({className:e,inset:a,...t},o)=>(0,w.jsx)(i.Item,{ref:o,className:u("ps-relative ps-flex ps-cursor-default ps-select-none ps-items-center ps-rounded-sm ps-px-2 ps-py-1.5 ps-text-sm ps-outline-none focus:ps-bg-accent focus:ps-text-accent-foreground data-[disabled]:ps-pointer-events-none data-[disabled]:ps-opacity-50",a&&"ps-pl-8",e),...t}));Ee.displayName=i.Item.displayName;var Qa=Q.forwardRef(({className:e,children:a,checked:t,...o},l)=>(0,w.jsxs)(i.CheckboxItem,{ref:l,className:u("ps-relative ps-flex ps-cursor-default ps-select-none ps-items-center ps-rounded-sm ps-py-1.5 ps-pl-8 ps-pr-2 ps-text-sm ps-outline-none focus:ps-bg-accent focus:ps-text-accent-foreground data-[disabled]:ps-pointer-events-none data-[disabled]:ps-opacity-50",e),checked:t,...o,children:[(0,w.jsx)("span",{className:"ps-absolute ps-left-2 ps-flex ps-h-3.5 ps-w-3.5 ps-items-center ps-justify-center",children:(0,w.jsx)(i.ItemIndicator,{children:(0,w.jsx)(Z,{className:"ps-h-4 ps-w-4"})})}),a]}));Qa.displayName=i.CheckboxItem.displayName;var _a=Q.forwardRef(({className:e,children:a,...t},o)=>(0,w.jsxs)(i.RadioItem,{ref:o,className:u("ps-relative ps-flex ps-cursor-default ps-select-none ps-items-center ps-rounded-sm ps-py-1.5 ps-pl-8 ps-pr-2 ps-text-sm ps-outline-none focus:ps-bg-accent focus:ps-text-accent-foreground data-[disabled]:ps-pointer-events-none data-[disabled]:ps-opacity-50",e),...t,children:[(0,w.jsx)("span",{className:"ps-absolute ps-left-2 ps-flex ps-h-3.5 ps-w-3.5 ps-items-center ps-justify-center",children:(0,w.jsx)(i.ItemIndicator,{children:(0,w.jsx)(oe,{className:"ps-h-4 ps-w-4 ps-fill-current"})})}),a]}));_a.displayName=i.RadioItem.displayName;var ja=Q.forwardRef(({className:e,inset:a,...t},o)=>(0,w.jsx)(i.Label,{ref:o,className:u("ps-px-2 ps-py-1.5 ps-text-sm ps-font-semibold ps-text-foreground",a&&"ps-pl-8",e),...t}));ja.displayName=i.Label.displayName;var $a=Q.forwardRef(({className:e,...a},t)=>(0,w.jsx)(i.Separator,{ref:t,className:u("ps--mx-1 ps-my-1 ps-h-px ps-bg-border",e),...a}));$a.displayName=i.Separator.displayName;var Ya=({className:e,...a})=>(0,w.jsx)("span",{className:u("ps-ml-auto ps-text-xs ps-tracking-widest ps-text-muted-foreground",e),...a});Ya.displayName="ContextMenuShortcut";var le=require("react/jsx-runtime"),Ge=e=>{if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return String(e);if(e==null)return"";if((0,sa.isValidElement)(e)){let a=e.props;return e.type&&typeof e.type=="function"&&e.type.name==="RevealText"?a.text||"":e.type&&typeof e.type=="function"&&e.type.name==="NullValue"?"NULL":a.children?Ge(a.children):""}return Array.isArray(e)?e.map(Ge).join(""):""},ra=({children:e})=>(0,le.jsxs)(ua,{children:[(0,le.jsx)(da,{className:"ps-block ps-w-full ps-p-[var(--studio-cell-spacing)]",children:e}),(0,le.jsx)(Ne,{children:(0,le.jsxs)(Ee,{onClick:()=>{let a=Ge(e);navigator.clipboard.writeText(a).catch(t=>{console.error("Failed to copy to clipboard:",t)})},className:"ps-flex ps-items-center ps-gap-2",children:[(0,le.jsx)(ge,{size:12}),"Copy"]})})]});var ia=require("react/jsx-runtime");function fa(){return(0,ia.jsx)("code",{className:"ps-text-gray-500",children:"NULL"})}var _=require("react/jsx-runtime");function pa({cell:e,getPinningStyles:a,dataType:t,isRelational:o,relatesTo:l,relationField:m}){let r=e.getValue(),f=r==null,C=S=>{if(S==null)return"NULL";if(typeof S=="object")try{return JSON.stringify(S,null,2)}catch(b){return console.error("Error stringifying value:",b),String(S)}return String(S)};return(0,_.jsxs)(Ue,{children:[(0,_.jsx)(He,{asChild:!0,children:(0,_.jsx)(ce,{...a(e.column),"data-cell-type":"data","data-type":t.toLowerCase(),"data-relational":o?"true":void 0,"data-relates-to":l,"data-relation-field":m,className:u(a(e.column).className,"ps-p-0",e.column.getIsPinned()&&"ps-sticky"),children:(0,_.jsx)(ra,{children:f?(0,_.jsx)(fa,{}):C(r)})})}),(0,_.jsx)(Oe,{align:"start",alignOffset:0,sideOffset:0,className:"ps-min-w-(--radix-popover-trigger-width) ps-rounded-none ps-bg-muted ps-p-0",children:(0,_.jsx)(ca.default,{value:C(r),theme:na.tokyoNight,height:"100px",basicSetup:{lineNumbers:!0,foldGutter:!1,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!1},onChange:S=>{console.log("New value:",S)}})})]},e.id)}var La=require("react/jsx-runtime");function ma({cell:e,getPinningStyles:a,dataType:t}){let o={cell:e,getPinningStyles:a},l=e.column.columnDef.meta,m={...o,isRelational:l?.isRelational,relatesTo:l?.relatesTo,relationField:l?.relationField};return(0,La.jsx)(pa,{...m,dataType:t||"STRING"})}var Pa=require("@tanstack/react-table");var xa=require("@radix-ui/react-slot"),Ia=require("class-variance-authority"),Ca=A(require("react"),1);var ga=require("react/jsx-runtime"),et=(0,Ia.cva)("ps-inline-flex ps-items-center ps-justify-center ps-gap-2 ps-whitespace-nowrap ps-rounded-md ps-text-sm ps-font-medium ps-transition-colors focus-visible:ps-outline-none focus-visible:ps-ring-1 focus-visible:ps-ring-ring disabled:ps-pointer-events-none disabled:ps-opacity-50 [&_svg]:ps-pointer-events-none [&_svg]:ps-size-4 [&_svg]:ps-shrink-0",{variants:{variant:{default:"ps-bg-primary ps-text-primary-foreground ps-shadow hover:ps-bg-primary/90",destructive:"ps-bg-destructive ps-text-destructive-foreground ps-shadow-sm hover:ps-bg-destructive/90",outline:"ps-border ps-border-input ps-bg-background ps-shadow-sm hover:ps-bg-accent hover:ps-text-accent-foreground",secondary:"ps-bg-secondary ps-text-secondary-foreground ps-shadow-sm hover:ps-bg-secondary/80",ghost:"hover:ps-bg-accent hover:ps-text-accent-foreground",link:"ps-text-primary ps-underline-offset-4 hover:ps-underline"},size:{default:"ps-h-9 ps-px-4 ps-py-2",sm:"ps-h-8 ps-rounded-md ps-px-3 ps-text-xs",lg:"ps-h-10 ps-rounded-md ps-px-8",icon:"ps-h-9 ps-w-9"}},defaultVariants:{variant:"default",size:"default"}}),V=Ca.forwardRef(({className:e,variant:a,size:t,asChild:o=!1,...l},m)=>(0,ga.jsx)(o?xa.Slot:"button",{className:u(et({variant:a,size:t,className:e})),ref:m,...l}));V.displayName="Button";var n=A(require("@radix-ui/react-dropdown-menu"),1);var j=A(require("react"),1);var k=require("react/jsx-runtime"),ha=n.Root,Sa=n.Trigger;var at=j.forwardRef(({className:e,inset:a,children:t,...o},l)=>(0,k.jsxs)(n.SubTrigger,{ref:l,className:u("ps-flex ps-cursor-default ps-select-none ps-items-center ps-gap-2 ps-rounded-sm ps-px-2 ps-py-1.5 ps-text-sm ps-outline-none focus:ps-bg-accent data-[state=open]:ps-bg-accent [&_svg]:ps-pointer-events-none [&_svg]:ps-size-4 [&_svg]:ps-shrink-0",a&&"ps-pl-8",e),...o,children:[t,(0,k.jsx)(J,{className:"ps-ml-auto"})]}));at.displayName=n.SubTrigger.displayName;var tt=j.forwardRef(({className:e,...a},t)=>(0,k.jsx)(n.SubContent,{ref:t,className:u("ps-z-50 ps-min-w-[8rem] ps-overflow-hidden ps-rounded-md ps-border ps-bg-popover ps-p-1 ps-text-popover-foreground ps-shadow-lg data-[state=open]:ps-animate-in data-[state=closed]:ps-animate-out data-[state=closed]:ps-fade-out-0 data-[state=open]:ps-fade-in-0 data-[state=closed]:ps-zoom-out-95 data-[state=open]:ps-zoom-in-95 data-[side=bottom]:ps-slide-in-from-top-2 data-[side=left]:ps-slide-in-from-right-2 data-[side=right]:ps-slide-in-from-left-2 data-[side=top]:ps-slide-in-from-bottom-2 ps-origin-[--radix-dropdown-menu-content-transform-origin]",e),...a}));tt.displayName=n.SubContent.displayName;var ze=j.forwardRef(({className:e,sideOffset:a=4,...t},o)=>(0,k.jsx)(n.Portal,{children:(0,k.jsx)(n.Content,{ref:o,sideOffset:a,className:u("ps-z-50 ps-max-h-[var(--radix-dropdown-menu-content-available-height)] ps-min-w-[8rem] ps-overflow-y-auto ps-overflow-x-hidden ps-rounded-md ps-border ps-bg-popover ps-p-1 ps-text-popover-foreground ps-shadow-md","data-[state=open]:ps-animate-in data-[state=closed]:ps-animate-out data-[state=closed]:ps-fade-out-0 data-[state=open]:ps-fade-in-0 data-[state=closed]:ps-zoom-out-95 data-[state=open]:ps-zoom-in-95 data-[side=bottom]:ps-slide-in-from-top-2 data-[side=left]:ps-slide-in-from-right-2 data-[side=right]:ps-slide-in-from-left-2 data-[side=top]:ps-slide-in-from-bottom-2 ps-origin-[--radix-dropdown-menu-content-transform-origin]",e),...t})}));ze.displayName=n.Content.displayName;var Te=j.forwardRef(({className:e,inset:a,...t},o)=>(0,k.jsx)(n.Item,{ref:o,className:u("ps-relative ps-flex ps-cursor-default ps-select-none ps-items-center ps-gap-2 ps-rounded-sm ps-px-2 ps-py-1.5 ps-text-sm ps-outline-none ps-transition-colors focus:ps-bg-accent focus:ps-text-accent-foreground data-[disabled]:ps-pointer-events-none data-[disabled]:ps-opacity-50 [&>svg]:ps-size-4 [&>svg]:ps-shrink-0",a&&"ps-pl-8",e),...t}));Te.displayName=n.Item.displayName;var ot=j.forwardRef(({className:e,children:a,checked:t,...o},l)=>(0,k.jsxs)(n.CheckboxItem,{ref:l,className:u("ps-relative ps-flex ps-cursor-default ps-select-none ps-items-center ps-rounded-sm ps-py-1.5 ps-pl-8 ps-pr-2 ps-text-sm ps-outline-none ps-transition-colors focus:ps-bg-accent focus:ps-text-accent-foreground data-[disabled]:ps-pointer-events-none data-[disabled]:ps-opacity-50",e),checked:t,...o,children:[(0,k.jsx)("span",{className:"ps-absolute ps-left-2 ps-flex ps-h-3.5 ps-w-3.5 ps-items-center ps-justify-center",children:(0,k.jsx)(n.ItemIndicator,{children:(0,k.jsx)(Z,{className:"ps-h-4 ps-w-4"})})}),a]}));ot.displayName=n.CheckboxItem.displayName;var lt=j.forwardRef(({className:e,children:a,...t},o)=>(0,k.jsxs)(n.RadioItem,{ref:o,className:u("ps-relative ps-flex ps-cursor-default ps-select-none ps-items-center ps-rounded-sm ps-py-1.5 ps-pl-8 ps-pr-2 ps-text-sm ps-outline-none ps-transition-colors focus:ps-bg-accent focus:ps-text-accent-foreground data-[disabled]:ps-pointer-events-none data-[disabled]:ps-opacity-50",e),...t,children:[(0,k.jsx)("span",{className:"ps-absolute ps-left-2 ps-flex ps-h-3.5 ps-w-3.5 ps-items-center ps-justify-center",children:(0,k.jsx)(n.ItemIndicator,{children:(0,k.jsx)(oe,{className:"ps-h-2 ps-w-2 ps-fill-current"})})}),a]}));lt.displayName=n.RadioItem.displayName;var ut=j.forwardRef(({className:e,inset:a,...t},o)=>(0,k.jsx)(n.Label,{ref:o,className:u("ps-px-2 ps-py-1.5 ps-text-sm ps-font-semibold",a&&"ps-pl-8",e),...t}));ut.displayName=n.Label.displayName;var dt=j.forwardRef(({className:e,...a},t)=>(0,k.jsx)(n.Separator,{ref:t,className:u("ps--mx-1 ps-my-1 ps-h-px ps-bg-muted",e),...a}));dt.displayName=n.Separator.displayName;var st=({className:e,...a})=>(0,k.jsx)("span",{className:u("ps-ml-auto ps-text-xs ps-tracking-widest ps-opacity-60",e),...a});st.displayName="DropdownMenuShortcut";var x=require("react/jsx-runtime");function Ve({header:e}){let a=e.column.columnDef.meta,t=a?.dataType,o=a?.isRelational;return(0,x.jsxs)("div",{className:"ps-flex ps-items-center ps-justify-between ps-w-full ps-h-full",children:[(0,x.jsxs)("div",{className:"ps-flex-1 ps-flex ps-items-center ps-justify-between",children:[o&&(0,x.jsx)(he,{size:14,className:"text-blue-700"}),(0,x.jsxs)("div",{className:"ps-align-text-bottom ps-leading-none ps-h-[20px]",children:[(0,x.jsx)("span",{className:"ps-inline-block ps-text-foreground ps-font-bold ps-text-sm",children:e.isPlaceholder?null:(0,Pa.flexRender)(e.column.columnDef.header,e.getContext())}),t&&t!=="NONE"&&(0,x.jsx)("span",{className:"ps-inline-block ps-ml-2 ps-text-xs ps-font-mono ps-text-muted-foreground/70 ps-lowercase",children:t})]}),(0,x.jsx)("span",{className:"ps-flex ps-items-center ps-gap-1",children:e.column.getCanPin()&&e.column.id!=="select"&&(0,x.jsxs)(ha,{children:[(0,x.jsx)(Sa,{asChild:!0,children:(0,x.jsx)(V,{variant:"ghost",size:"icon",children:(0,x.jsx)(Y,{size:16})})}),(0,x.jsxs)(ze,{children:[e.column.getCanSort()&&(0,x.jsx)(Te,{onClick:()=>e.column.toggleSorting(e.column.getIsSorted()==="asc"),children:(0,x.jsxs)("span",{className:"ps-flex ps-items-center ps-gap-2",children:[e.column.getIsSorted()==="asc"?(0,x.jsx)($,{size:16}):(0,x.jsx)(me,{size:16}),e.column.getIsSorted()==="asc"?"Sort descending":"Sort ascending"]})}),(0,x.jsx)(Te,{onClick:()=>e.column.pin(e.column.getIsPinned()?!1:"left"),children:e.column.getIsPinned()?(0,x.jsxs)("span",{className:"ps-flex ps-items-center ps-gap-2",children:[(0,x.jsx)(Se,{size:16}),"Unpin column"]}):(0,x.jsxs)("span",{className:"ps-flex ps-items-center ps-gap-2",children:[(0,x.jsx)(Pe,{size:16}),"Pin column"]})})]})]})})]}),e.column.getCanResize()&&(0,x.jsx)("button",{type:"button",tabIndex:0,onMouseDown:l=>{l.stopPropagation(),e.getResizeHandler()(l)},onTouchStart:l=>{l.stopPropagation(),e.getResizeHandler()(l)},onClick:l=>l.stopPropagation(),onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),l.stopPropagation(),e.getResizeHandler()(l))},className:u("ps-absolute ps-right-0 ps-top-0 ps-h-full ps-w-3 ps-cursor-col-resize","ps-select-none ps-touch-none ps-transition-colors ps-group","ps-border-0 ps-bg-transparent",e.column.getIsResizing()&&"ps-bg-gray-300","before:ps-absolute before:ps-right-[3px] before:ps-top-1/2 before:ps--translate-y-1/2","after:ps-absolute after:ps-right-[7px] after:ps-top-1/2 after:ps--translate-y-1/2","before:ps-w-[2px] before:ps-h-0 before:ps-bg-gray-400 before:ps-rounded-full before:ps-opacity-0","after:ps-w-[2px] after:ps-h-0 after:ps-bg-gray-400 after:ps-rounded-full after:ps-opacity-0","before:ps-transition-all before:ps-duration-200","after:ps-transition-all after:ps-duration-200","group-hover:before:ps-opacity-100","group-hover:after:ps-opacity-100","group-hover:before:ps-h-4","group-hover:after:ps-h-4","group-active:ps-bg-transparent group-active:before:ps-bg-white group-active:after:ps-bg-white",e.column.getIsResizing()&&"before:ps-opacity-100"),"aria-label":"Resize column"})]})}var wa=A(require("react"),1);var ka=require("react/jsx-runtime"),We=wa.forwardRef(({className:e,type:a,...t},o)=>(0,ka.jsx)("input",{type:a,className:u("ps-flex ps-h-9 ps-w-full ps-rounded-md ps-border ps-border-input ps-bg-transparent ps-px-3 ps-py-1 ps-text-base ps-shadow-sm ps-transition-colors file:ps-border-0 file:ps-bg-transparent file:ps-text-sm file:ps-font-medium file:ps-text-foreground placeholder:ps-text-muted-foreground focus-visible:ps-outline-none focus-visible:ps-ring-1 focus-visible:ps-ring-ring disabled:ps-cursor-not-allowed disabled:ps-opacity-50 md:ps-text-sm",e),ref:o,...t}));We.displayName="Input";var c=A(require("@radix-ui/react-select"),1);var ee=A(require("react"),1);var h=require("react/jsx-runtime"),ba=c.Root;var Ra=c.Value,Xe=ee.forwardRef(({className:e,children:a,...t},o)=>(0,h.jsxs)(c.Trigger,{ref:o,className:u("ps-flex ps-h-9 ps-w-full ps-items-center ps-justify-between ps-whitespace-nowrap ps-rounded-md ps-border ps-border-input ps-bg-transparent ps-px-3 ps-py-2 ps-text-sm ps-shadow-sm ps-ring-offset-background data-[placeholder]:ps-text-muted-foreground focus:ps-outline-none focus:ps-ring-1 focus:ps-ring-ring disabled:ps-cursor-not-allowed disabled:ps-opacity-50 [&>span]:ps-line-clamp-1",e),...t,children:[a,(0,h.jsx)(c.Icon,{asChild:!0,children:(0,h.jsx)(re,{className:"ps-h-4 ps-w-4 ps-opacity-50"})})]}));Xe.displayName=c.Trigger.displayName;var Ma=ee.forwardRef(({className:e,...a},t)=>(0,h.jsx)(c.ScrollUpButton,{ref:t,className:u("ps-flex ps-cursor-default ps-items-center ps-justify-center ps-py-1",e),...a,children:(0,h.jsx)(xe,{className:"ps-h-4 ps-w-4"})}));Ma.displayName=c.ScrollUpButton.displayName;var va=ee.forwardRef(({className:e,...a},t)=>(0,h.jsx)(c.ScrollDownButton,{ref:t,className:u("ps-flex ps-cursor-default ps-items-center ps-justify-center ps-py-1",e),...a,children:(0,h.jsx)(re,{className:"ps-h-4 ps-w-4"})}));va.displayName=c.ScrollDownButton.displayName;var Ke=ee.forwardRef(({className:e,children:a,position:t="popper",...o},l)=>(0,h.jsx)(c.Portal,{children:(0,h.jsxs)(c.Content,{ref:l,className:u("ps-relative ps-z-50 ps-max-h-[--radix-select-content-available-height] ps-min-w-[8rem] ps-overflow-y-auto ps-overflow-x-hidden ps-rounded-md ps-border ps-bg-popover ps-text-popover-foreground ps-shadow-md data-[state=open]:ps-animate-in data-[state=closed]:ps-animate-out data-[state=closed]:ps-fade-out-0 data-[state=open]:ps-fade-in-0 data-[state=closed]:ps-zoom-out-95 data-[state=open]:ps-zoom-in-95 data-[side=bottom]:ps-slide-in-from-top-2 data-[side=left]:ps-slide-in-from-right-2 data-[side=right]:ps-slide-in-from-left-2 data-[side=top]:ps-slide-in-from-bottom-2 ps-origin-[--radix-select-content-transform-origin]",t==="popper"&&"data-[side=bottom]:ps-translate-y-1 data-[side=left]:ps--translate-x-1 data-[side=right]:ps-translate-x-1 data-[side=top]:ps--translate-y-1",e),position:t,...o,children:[(0,h.jsx)(Ma,{}),(0,h.jsx)(c.Viewport,{className:u("ps-p-1",t==="popper"&&"ps-h-[var(--radix-select-trigger-height)] ps-w-full ps-min-w-[var(--radix-select-trigger-width)]"),children:a}),(0,h.jsx)(va,{})]})}));Ke.displayName=c.Content.displayName;var rt=ee.forwardRef(({className:e,...a},t)=>(0,h.jsx)(c.Label,{ref:t,className:u("ps-px-2 ps-py-1.5 ps-text-sm ps-font-semibold",e),...a}));rt.displayName=c.Label.displayName;var Ze=ee.forwardRef(({className:e,children:a,...t},o)=>(0,h.jsxs)(c.Item,{ref:o,className:u("ps-relative ps-flex ps-w-full ps-cursor-default ps-select-none ps-items-center ps-rounded-sm ps-py-1.5 ps-pl-2 ps-pr-8 ps-text-sm ps-outline-none focus:ps-bg-accent focus:ps-text-accent-foreground data-[disabled]:ps-pointer-events-none data-[disabled]:ps-opacity-50",e),...t,children:[(0,h.jsx)("span",{className:"ps-absolute ps-right-2 ps-flex ps-h-3.5 ps-w-3.5 ps-items-center ps-justify-center",children:(0,h.jsx)(c.ItemIndicator,{children:(0,h.jsx)(Z,{className:"ps-h-4 ps-w-4"})})}),(0,h.jsx)(c.ItemText,{children:a})]}));Ze.displayName=c.Item.displayName;var ft=ee.forwardRef(({className:e,...a},t)=>(0,h.jsx)(c.Separator,{ref:t,className:u("ps--mx-1 ps-my-1 ps-h-px ps-bg-muted",e),...a}));ft.displayName=c.Separator.displayName;var I=require("react/jsx-runtime"),it=[10,20,50,100];function ya({table:e,variant:a="basic",className:t}){let{pageSize:o,pageIndex:l}=e.getState().pagination,m=e.getPageCount();return(0,I.jsx)("div",{className:u("ps-flex ps-items-center ps-justify-between ps-space-x-2 ps-py-4 ps-px-4",t),children:a==="basic"?(0,I.jsxs)("div",{className:"ps-flex ps-items-center ps-space-x-2",children:[(0,I.jsx)(V,{variant:"outline",size:"sm",className:"ps-h-9",onClick:()=>e.previousPage(),disabled:!e.getCanPreviousPage(),children:"Previous"}),(0,I.jsx)(V,{variant:"outline",size:"sm",className:"ps-h-9",onClick:()=>e.nextPage(),disabled:!e.getCanNextPage(),children:"Next"})]}):(0,I.jsxs)("div",{className:"ps-flex ps-items-center ps-space-x-2",children:[(0,I.jsxs)("div",{className:"ps-flex ps-items-center ps-space-x-2",children:[(0,I.jsx)(V,{variant:"outline",onClick:()=>e.setPageIndex(0),disabled:!e.getCanPreviousPage(),children:(0,I.jsx)(Ie,{className:"ps-w-4 ps-h-4"})}),(0,I.jsx)(V,{variant:"outline",onClick:()=>e.previousPage(),disabled:!e.getCanPreviousPage(),children:(0,I.jsx)(Le,{className:"ps-w-4 ps-h-4"})}),(0,I.jsxs)("div",{className:"ps-flex ps-items-center ps-gap-1 ps-text-xs ps-font-medium",children:["Page",(0,I.jsx)(We,{type:"number",min:1,max:m,value:l+1,className:"ps-w-12",onChange:r=>{let f=r.target.value?Number(r.target.value)-1:0;e.setPageIndex(f)}}),(0,I.jsxs)("span",{className:"ps-shrink-0 ps-w-max",children:["of ",m]})]}),(0,I.jsx)(V,{variant:"outline",onClick:()=>e.nextPage(),disabled:!e.getCanNextPage(),children:(0,I.jsx)(J,{className:"ps-w-4 ps-h-4"})}),(0,I.jsx)(V,{variant:"outline",onClick:()=>e.setPageIndex(m-1),disabled:!e.getCanNextPage(),children:(0,I.jsx)(Ce,{className:"ps-w-4 ps-h-4"})})]}),(0,I.jsxs)(ba,{value:o.toString(),onValueChange:r=>e.setPageSize(Number(r)),children:[(0,I.jsx)(Xe,{children:(0,I.jsx)(Ra,{})}),(0,I.jsx)(Ke,{children:it.map(r=>(0,I.jsxs)(Ze,{value:r.toString(),children:[r," per page"]},r))})]})]})})}var we=e=>{let a=e.getIsPinned(),t=a==="left"&&e.getIsLastColumn("left"),o=a==="right"&&e.getIsFirstColumn("right");return{className:u("ps-overflow-hidden ps-whitespace-nowrap ps-text-ellipsis",a&&["ps-sticky ps-bg-background ps-shadow-[1px_0_0_0_hsl(var(--border))]",a==="left"?"ps-left-0":"ps-right-0","ps-z-20"],!a&&"ps-relative ps-z-10",t&&"ps-shadow-[1px_0_0_0_hsl(var(--border))]",o&&"ps-shadow-[-1px_0_0_0_hsl(var(--border))]"),style:{width:e.getSize(),left:a==="left"?`${e.getStart("left")}px`:void 0,right:a==="right"?`${e.getAfter("right")}px`:void 0}}};var p=require("react/jsx-runtime"),nt=({_table:e})=>{let{currentTable:a,isLoaded:t}=Me();return t?(0,p.jsx)("div",{className:"ps-flex ps-items-center ps-justify-between ps-w-full ps-gap-2",children:(0,p.jsx)("div",{className:"ps-flex ps-items-center ps-gap-2",children:(0,p.jsx)("span",{className:"ps-flex ps-items-center ps-gap-2",children:(0,p.jsx)("h1",{className:"ps-text-sm ps-font-medium",children:a?.name})})})}):null},ct=({header:e,children:a,getPinningStyles:t})=>{let{attributes:o,listeners:l,transform:m,transition:r,setNodeRef:f,isDragging:C,isOver:S}=(0,fe.useSortable)({id:e.id}),b=e.column.columnDef.meta,R={transform:Da.CSS.Transform.toString(m),transition:r,...t(e.column).style,cursor:"grab",touchAction:"none"};return(0,p.jsxs)(ve,{ref:f,...o,...l,style:R,"data-relational":b?.isRelational?"true":void 0,"data-relates-to":b?.relatesTo,"data-relation-field":b?.relationField,className:u("ps-group",t(e.column).className,C&&"ps-opacity-50",S&&"ps-bg-gray-100","ps-select-none ps-touch-none ps-relative",e.column.getIsPinned()&&"ps-sticky"),children:[a,S&&(0,p.jsx)("div",{className:"ps-absolute ps-inset-0 ps-border-2 ps-border-primary ps-rounded-sm ps-pointer-events-none"})]})};function Ta({data:e=[],columns:a}){console.log("Data received in StudioGrid:",e);let[t,o]=(0,N.useState)([]),[l,m]=(0,N.useState)([]),[r,f]=(0,N.useState)({}),[C,S]=(0,N.useState)({left:[],right:[]}),[b,R]=(0,N.useState)([]),[ie,O]=(0,N.useState)("");(0,N.useEffect)(()=>{if(a&&a.length>0){let g=a.map(q=>q.id);if(b.length===0){R(g);return}let d=[...b],P=d.filter(q=>!a.some(G=>G.id===q));P.forEach(q=>{let G=d.indexOf(q);G!==-1&&d.splice(G,1)});let T=g.filter(q=>!d.includes(q));T.length>0&&d.push(...T),(P.length>0||T.length>0)&&R(d)}},[a,b]);let D=(0,ae.useSensor)(ae.MouseSensor,{activationConstraint:{distance:10}}),B=(0,ae.useSensors)(D),F=g=>{let{active:d,over:P}=g;if(P&&d.id!==P.id){let T=M.getColumn(d.id),q=M.getColumn(P.id);if(!T||!q)return;let G=T.getIsPinned(),de=q.getIsPinned();if(G!==de)return;let ke=b.indexOf(d.id),be=b.indexOf(P.id);if(ke===-1||be===-1)return;let Ae=[...b];Ae.splice(ke,1),Ae.splice(be,0,d.id),R(Ae)}},E=(0,N.useMemo)(()=>{if(!a||a.length===0)return console.log("No columns configuration available"),[];let g=(d,P)=>{if(d==null)return"";switch(P){case"TIMESTAMP":return d?new Date(d).toLocaleString():"";case"UUID":case"STRING":return String(d);default:return String(d)}};return a.map(d=>({accessorKey:d.id,header:()=>(0,p.jsx)("div",{className:"ps-font-medium",children:d.id}),cell:({getValue:P})=>g(P(),d.type),meta:{dataType:d.type,isRelational:d.isRelational,relatesTo:d.relatesTo,relationField:d.relationField}}))},[a]),M=(0,W.useReactTable)({data:e||[],defaultColumn:{size:200,minSize:50,maxSize:500},columns:E,getCoreRowModel:(0,W.getCoreRowModel)(),onSortingChange:o,getSortedRowModel:(0,W.getSortedRowModel)(),getPaginationRowModel:(0,W.getPaginationRowModel)(),getFilteredRowModel:(0,W.getFilteredRowModel)(),onColumnFiltersChange:m,enableColumnResizing:!0,columnResizeMode:"onChange",onColumnSizingChange:f,enableColumnPinning:!0,onColumnPinningChange:S,onGlobalFilterChange:O,globalFilterFn:(g,d,P)=>{let T=g.getValue(d);return T==null?!1:String(T).toLowerCase().includes(String(P).toLowerCase())},state:{sorting:t,columnFilters:l,columnSizing:r,columnPinning:C,columnOrder:b,globalFilter:ie}});return!e||e.length===0?(0,p.jsxs)("div",{className:"ps-p-4 ps-border ps-rounded-md ps-w-full",children:[(0,p.jsx)("p",{className:"ps-text-lg ps-font-semibold",children:"No data available."}),(0,p.jsx)("p",{className:"ps-text-sm ps-text-gray-500",children:e?"Data array is empty.":"Data is undefined."})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("div",{className:"ps-bg-studio-header-background ps-flex ps-w-full ps-p-2 ps-py-3 ps-border-b",children:(0,p.jsx)(nt,{_table:M})}),(0,p.jsx)("div",{"data-studio":"content",className:"ps-flex-1 ps-w-0 ps-h-0 ps-min-w-full",children:(0,p.jsxs)("div",{className:"ps-flex ps-flex-col ps-w-full ps-h-full ps-overflow-scroll",children:[(0,p.jsx)(ae.DndContext,{sensors:B,onDragEnd:F,children:(0,p.jsxs)(Be,{children:[(0,p.jsx)(Fe,{children:M.getHeaderGroups().map(g=>(0,p.jsx)(ne,{className:u("ps-relative",M.getLeftLeafHeaders().some(d=>d.column.getIsPinned()==="left")&&`ps-pl-[${M.getLeftLeafHeaders().filter(d=>d.column.getIsPinned()==="left").reduce((d,P)=>d+P.getSize(),0)}px]`),children:(0,p.jsx)(fe.SortableContext,{items:g.headers.map(d=>d.id),strategy:fe.horizontalListSortingStrategy,children:g.headers.map(d=>d.column.id==="select"?(0,p.jsx)(ve,{className:u("ps-px-[var(--studio-cell-spacing)]",we(d.column).className,d.column.getIsPinned()&&"ps-sticky"),style:we(d.column).style,"data-cell-type":"select",children:(0,p.jsx)(Ve,{header:d})},d.id):(0,p.jsx)(ct,{header:d,table:M,getPinningStyles:we,children:(0,p.jsx)(Ve,{header:d})},d.id))})},g.id))}),(0,p.jsx)(qe,{children:M.getRowModel().rows?.length?M.getRowModel().rows.map(g=>(0,p.jsx)(ne,{className:u("ps-bg-table-row ps-odd:bg-table-row-odd ps-group"),children:g.getVisibleCells().map(d=>(0,p.jsx)(ma,{cell:d,getPinningStyles:we,dataType:a.find(P=>P.id===d.column.id)?.type},d.id))},g.id)):(0,p.jsx)(ne,{children:(0,p.jsx)(ce,{colSpan:a.length,className:"ps-h-24 ps-text-center",children:"No results."})})})]})}),(0,p.jsx)(ya,{table:M,variant:"numeric"})]})})]})}var ue=require("react"),Ba=require("react/jsx-runtime"),pt={theme:"system",setTheme:()=>null},mt=(0,ue.createContext)(pt);function Aa({children:e,defaultTheme:a="system",storageKey:t="vite-ui-theme",...o}){let[l,m]=(0,ue.useState)(()=>localStorage.getItem(t)||a);(0,ue.useEffect)(()=>{let f=window.document.documentElement;if(f.classList.remove("light","dark"),l==="system"){let C=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";f.classList.add(C);return}f.classList.add(l)},[l]);let r={theme:l,setTheme:f=>{localStorage.setItem(t,f),m(f)}};return(0,Ba.jsx)(mt.Provider,{...o,value:r,children:e})}var H=require("react/jsx-runtime"),qa=(0,v.createContext)(void 0),Me=()=>{let e=(0,v.useContext)(qa);if(!e)throw new Error("useStudio must be used within a Studio.Provider");return e},Lt={integer:"INTEGER",varchar:"VARCHAR",text:"TEXT",enum:"STRING",boolean:"BOOLEAN"};function xt(e,a){return{id:e,accessorKey:e,header:e.charAt(0).toUpperCase()+e.slice(1),type:Lt[a.dataType.name]||"STRING",nullable:a.nullable,isKey:a.partOfPk}}var It=({adapter:e})=>{let[a,t]=(0,v.useState)([]),[o,l]=(0,v.useState)(null),[m,r]=(0,v.useState)(!1),[f,C]=(0,v.useState)([]),[S,b]=(0,v.useState)([]),R=v.default.useMemo(()=>new Set(a.filter(O=>O.isFavorite).map(O=>O.id)),[a]),ie=O=>{t(D=>D.map(B=>B.id===O?{...B,isFavorite:!B.isFavorite}:B))};return(0,v.useEffect)(()=>{(async()=>{try{let[D,B]=await e.introspect();if(D||!B?.schemas){console.error("Error fetching schema:",D);return}let F=Object.entries(B.schemas).flatMap(([E,M])=>Object.entries(M.tables).map(([g])=>({id:`${E}.${g}`,name:g.charAt(0).toUpperCase()+g.slice(1),schema:E,isFavorite:!1})));t(F),!o&&F.length>0&&F[0]&&l(F[0])}catch(D){console.error("Error fetching tables:",D)}})()},[e,o]),(0,v.useEffect)(()=>{(async()=>{if(!o?.id){r(!0);return}try{r(!1);let[D,B]=await e.introspect();if(D||!B?.schemas){console.error("Error fetching schema:",D),r(!0);return}let[F,E]=o.id.split(".");if(!F||!E){console.error("Invalid table ID format:",o.id),r(!0);return}let M=B.schemas[F];if(!M){console.error(`Schema ${F} not found`),r(!0);return}let g=M.tables[E];if(!g){console.error(`Table ${E} not found in schema ${F}`),r(!0);return}let d=Object.entries(g.columns).map(([G,de])=>xt(G,de));b(d);let[P,T]=await e.query({schema:F,table:E,filters:[],sortings:[]});if(P||!T){console.error(`Failed to fetch data for table ${E}:`,P),r(!0);return}let q=T.rows.map(G=>{let de={};return Object.entries(G).forEach(([ke,be])=>{de[ke]=be.value}),de});C(q),r(!0)}catch(D){console.error("Error fetching table data:",D),r(!0)}})()},[e,o]),e?!m&&a.length===0?(0,H.jsx)("div",{children:"Loading available tables..."}):m&&a.length===0?(0,H.jsx)("div",{children:"No tables found in the database."}):(0,H.jsx)(Aa,{children:(0,H.jsx)(Fa.NuqsAdapter,{children:(0,H.jsx)(qa.Provider,{value:{adapter:e,currentTable:o,isLoaded:m,tables:a,favoriteTableIds:R,setCurrentTable:l,toggleFavorite:ie},children:(0,H.jsxs)("div",{className:"ps-flex ps-gap-4 ps-w-full ps-rounded-sm ps-bg-background ps-p-4 ps-relative",children:[(0,H.jsx)(ea,{}),(0,H.jsx)("div",{className:"ps-flex ps-w-full ps-flex-col ps-border ps-rounded-lg",children:(0,H.jsx)(Ta,{columns:S,data:f})})]})})})}):(console.error("No adapter provided to Studio component"),(0,H.jsx)("div",{children:"Error: No adapter provided"}))},Je=It;0&&(module.exports={Studio});
2
2
  /*! Bundled license information:
3
3
 
4
4
  lucide-react/dist/esm/shared/src/utils.js:
@@ -153,14 +153,6 @@ lucide-react/dist/esm/icons/pin.js:
153
153
  * See the LICENSE file in the root directory of this source tree.
154
154
  *)
155
155
 
156
- lucide-react/dist/esm/icons/star.js:
157
- (**
158
- * @license lucide-react v0.427.0 - ISC
159
- *
160
- * This source code is licensed under the ISC license.
161
- * See the LICENSE file in the root directory of this source tree.
162
- *)
163
-
164
156
  lucide-react/dist/esm/lucide-react.js:
165
157
  (**
166
158
  * @license lucide-react v0.427.0 - ISC
package/dist/ui/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import"../chunk-2FW6TKD6.js";import"../index-KSZNOSSS.css";import{NuqsAdapter as Ft}from"nuqs/adapters/react";import qt,{createContext as Ut,useContext as Ht,useEffect as ha,useState as Se}from"react";import{Slot as ba}from"@radix-ui/react-slot";import{useQueryState as Ra}from"nuqs";import{clsx as wa}from"clsx";import{twMerge as ka}from"tailwind-merge";function l(...e){return ka(wa(e))}import{jsx as K,jsxs as Je}from"react/jsx-runtime";var j=()=>{let{setCurrentTable:e,currentTable:a,favoriteTableIds:t,tables:o}=ae(),[u,m]=Ra("tableId"),s=async f=>{await m(f);let x=o.find(C=>C.id===f);x&&e(x)};return Je("div",{className:"ps-flex ps-flex-col ps-w-64 ps-gap-4 ps-shrink-0",children:[K(j.Block,{label:"Tables",children:o.map(f=>K(j.Item,{isActive:a?.id===f.id,onClick:x=>{x.preventDefault(),s(f.id)},className:`ps-px-2 ps-py-1 ps-cursor-pointer ps-rounded ${a?.id===f.id?"ps-bg-primary ps-text-white":"ps-hover:ps-bg-gray-100"}`,children:f.name},f.id))}),t.size>0&&K(j.Block,{label:"Favourites",children:o.filter(f=>t.has(f.id)).map(f=>K(j.Item,{isActive:a?.id===f.id,onClick:x=>{x.preventDefault(),s(f.id)},children:f.name},f.id))})]})},Ma=({className:e,label:a,children:t,...o})=>Je("div",{className:l("ps-rounded-lg ps-border ps-bg-card ps-text-card-foreground ps-shadow-xs",e),...o,children:[K("div",{className:"ps-pt-4 ps-pb-2 ps-px-4",children:K("h2",{className:"ps-text-sm ps-font-medium",children:a})}),K("nav",{"aria-label":a,className:"ps-flex ps-flex-col ps-gap-px ps-pb-3",children:t})]}),va=({className:e,asChild:a=!1,isActive:t,size:o,...u})=>K(a?ba:"button",{"data-sidebar":"menu-button","data-size":o,"data-active":t,className:l("ps-py-1.5 ps-px-4 ps-text-sm ps-font-medium ps-flex ps-gap-2 ps-items-center ps-border ps-border-transparent ps-bg-transparent ps-hover:bg-muted/50",e),...u});j.Block=Ma;j.Item=va;var Ze=j;import{DndContext as it,MouseSensor as nt,useSensor as ct,useSensors as pt}from"@dnd-kit/core";import{horizontalListSortingStrategy as mt,SortableContext as Lt,useSortable as xt}from"@dnd-kit/sortable";import{CSS as It}from"@dnd-kit/utilities";import{getCoreRowModel as Ct,getFilteredRowModel as gt,getPaginationRowModel as ht,getSortedRowModel as St,useReactTable as Pt}from"@tanstack/react-table";import{useEffect as wt,useMemo as kt,useState as le}from"react";import*as N from"react";import{jsx as O}from"react/jsx-runtime";var ve=N.forwardRef(({className:e,...a},t)=>O("div",{className:"ps-relative ps-w-full ps-overflow-auto ps-flex ps-items-start ps-h-full",children:O("table",{ref:t,className:l("ps-w-full ps-caption-bottom ps-text-sm table-fixed",e),...a})}));ve.displayName="Table";var ye=N.forwardRef(({className:e,...a},t)=>O("thead",{ref:t,className:l("[&_tr]:ps-border-b",e),...a}));ye.displayName="TableHeader";var De=N.forwardRef(({className:e,...a},t)=>O("tbody",{ref:t,className:l("[&_tr:last-child]:ps-border-0",e),...a}));De.displayName="TableBody";var ya=N.forwardRef(({className:e,...a},t)=>O("tfoot",{ref:t,className:l("ps-border-t ps-bg-muted/50 ps-font-medium [&>tr]:last:ps-border-b-0",e),...a}));ya.displayName="TableFooter";var re=N.forwardRef(({className:e,...a},t)=>O("tr",{ref:t,className:l("ps-border-b ps-transition-colors hover:ps-bg-muted/50 data-[state=selected]:ps-bg-muted",e),...a}));re.displayName="TableRow";var ke=N.forwardRef(({className:e,...a},t)=>O("th",{ref:t,className:l("ps-h-10 ps-px-2 ps-text-left ps-align-middle ps-font-medium ps-text-muted-foreground [&:has([role=checkbox])]:ps-pr-0 [&>[role=checkbox]]:ps-translate-y-[2px]",e),...a}));ke.displayName="TableHead";var se=N.forwardRef(({className:e,...a},t)=>O("td",{ref:t,className:l("ps-p-2 ps-align-middle [&:has([role=checkbox])]:ps-pr-0 [&>[role=checkbox]]:ps-translate-y-[2px]",e),...a}));se.displayName="TableCell";var Da=N.forwardRef(({className:e,...a},t)=>O("caption",{ref:t,className:l("ps-mt-4 ps-text-sm ps-text-muted-foreground",e),...a}));Da.displayName="TableCaption";import{forwardRef as Aa,createElement as Ba}from"react";var Qe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),be=(...e)=>e.filter((a,t,o)=>!!a&&o.indexOf(a)===t).join(" ");import{forwardRef as Ta,createElement as je}from"react";var _e={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var $e=Ta(({color:e="currentColor",size:a=24,strokeWidth:t=2,absoluteStrokeWidth:o,className:u="",children:m,iconNode:s,...f},x)=>je("svg",{ref:x,..._e,width:a,height:a,stroke:e,strokeWidth:o?Number(t)*24/Number(a):t,className:be("lucide",u),...f},[...s.map(([C,h])=>je(C,h)),...Array.isArray(m)?m:[m]]));var p=(e,a)=>{let t=Aa(({className:o,...u},m)=>Ba($e,{ref:m,iconNode:a,className:be(`lucide-${Qe(e)}`,o),...u}));return t.displayName=`${e}`,t};var Z=p("ArrowDownWideNarrow",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h10",key:"1w87gc"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h4",key:"q8tih4"}]]);var fe=p("ArrowUpWideNarrow",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h4",key:"1krc32"}]]);var E=p("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);var te=p("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);var ie=p("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);var G=p("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);var ne=p("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);var ce=p("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);var pe=p("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);var $=p("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);var me=p("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);var J=p("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);var Le=p("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);var xe=p("PinOff",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]);var Ie=p("Pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);var Ce=p("Star",[["polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2",key:"8f66p6"}]]);import{jsx as Ye,jsxs as Fa}from"react/jsx-runtime";function ea(){let{currentTable:e,favoriteTableIds:a,toggleFavorite:t,isLoaded:o}=ae();if(!o||!e)return null;let u=a.has(e.id);return Fa("button",{type:"button",onClick:()=>t(e.id),className:l("ps-appearance-none",u&&"ps-text-yellow-500"),children:[Ye(Ce,{size:12,className:l("ps-transition-colors",u&&"ps-fill-yellow-500")}),Ye("span",{className:"ps-sr-only",children:u?"Remove from favorites":"Add to favorites"})]})}import{tokyoNight as Wa}from"@uiw/codemirror-theme-tokyo-night";import Xa from"@uiw/react-codemirror";import*as z from"@radix-ui/react-popover";import*as b from"react";import{jsx as ge}from"react/jsx-runtime";var aa=b.createContext(null),Te=({children:e,...a})=>{let[t,o]=b.useState(!1);return ge(aa.Provider,{value:{open:t,setOpen:o},children:ge(z.Root,{open:t,onOpenChange:o,...a,children:e})})};Te.displayName="PopoverCell";var Ae=b.forwardRef(({children:e,onDoubleClick:a,className:t,...o},u)=>{let m=b.useContext(aa),[s,f]=b.useState(!1),x=b.useRef(null);return b.useEffect(()=>{let S=de=>{let F=de.target;x.current&&!x.current.contains(F)&&(console.log("Outside click - removing focus"),f(!1))};return document.addEventListener("click",S),()=>document.removeEventListener("click",S)},[]),ge(z.Trigger,{ref:S=>{typeof u=="function"?u(S):u&&(u.current=S),x.current=S},onClick:S=>{S.preventDefault(),console.log("Click handler - setting focus to true"),f(!0)},onDoubleClick:S=>{S.preventDefault(),m?.setOpen(!0),a?.()},"data-focus":s.toString(),className:l("w-full h-full cursor-pointer",t),...o,children:e})});Ae.displayName="PopoverCellTrigger";var Be=b.forwardRef(({className:e,align:a="center",sideOffset:t=4,...o},u)=>ge(z.Portal,{children:ge(z.Content,{ref:u,align:a,sideOffset:t,className:l("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-hidden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...o})}));Be.displayName=z.Content.displayName;import{isValidElement as za}from"react";import*as i from"@radix-ui/react-context-menu";import*as V from"react";import{jsx as R,jsxs as Ue}from"react/jsx-runtime";var ta=i.Root,oa=i.Trigger;var qa=V.forwardRef(({className:e,inset:a,children:t,...o},u)=>Ue(i.SubTrigger,{ref:u,className:l("ps-flex ps-cursor-default ps-select-none ps-items-center ps-rounded-sm ps-px-2 ps-py-1.5 ps-text-sm ps-outline-none focus:ps-bg-accent focus:ps-text-accent-foreground data-[state=open]:ps-bg-accent data-[state=open]:ps-text-accent-foreground",a&&"ps-pl-8",e),...o,children:[t,R(G,{className:"ps-ml-auto ps-h-4 ps-w-4"})]}));qa.displayName=i.SubTrigger.displayName;var Ua=V.forwardRef(({className:e,...a},t)=>R(i.SubContent,{ref:t,className:l("ps-z-50 ps-min-w-[8rem] ps-overflow-hidden ps-rounded-md ps-border ps-bg-popover ps-p-1 ps-text-popover-foreground ps-shadow-lg data-[state=open]:ps-animate-in data-[state=closed]:ps-animate-out data-[state=closed]:ps-fade-out-0 data-[state=open]:ps-fade-in-0 data-[state=closed]:ps-zoom-out-95 data-[state=open]:ps-zoom-in-95 data-[side=bottom]:ps-slide-in-from-top-2 data-[side=left]:ps-slide-in-from-right-2 data-[side=right]:ps-slide-in-from-left-2 data-[side=top]:ps-slide-in-from-bottom-2 ps-origin-[--radix-context-menu-content-transform-origin]",e),...a}));Ua.displayName=i.SubContent.displayName;var Fe=V.forwardRef(({className:e,...a},t)=>R(i.Portal,{children:R(i.Content,{ref:t,className:l("ps-z-50 ps-max-h-[--radix-context-menu-content-available-height] ps-min-w-[8rem] ps-overflow-y-auto ps-overflow-x-hidden ps-rounded-md ps-border ps-bg-popover ps-p-1 ps-text-popover-foreground ps-shadow-md data-[state=open]:ps-animate-in data-[state=closed]:ps-animate-out data-[state=closed]:ps-fade-out-0 data-[state=open]:ps-fade-in-0 data-[state=closed]:ps-zoom-out-95 data-[state=open]:ps-zoom-in-95 data-[side=bottom]:ps-slide-in-from-top-2 data-[side=left]:ps-slide-in-from-right-2 data-[side=right]:ps-slide-in-from-left-2 data-[side=top]:ps-slide-in-from-bottom-2 ps-origin-[--radix-context-menu-content-transform-origin]",e),...a})}));Fe.displayName=i.Content.displayName;var qe=V.forwardRef(({className:e,inset:a,...t},o)=>R(i.Item,{ref:o,className:l("ps-relative ps-flex ps-cursor-default ps-select-none ps-items-center ps-rounded-sm ps-px-2 ps-py-1.5 ps-text-sm ps-outline-none focus:ps-bg-accent focus:ps-text-accent-foreground data-[disabled]:ps-pointer-events-none data-[disabled]:ps-opacity-50",a&&"ps-pl-8",e),...t}));qe.displayName=i.Item.displayName;var Ha=V.forwardRef(({className:e,children:a,checked:t,...o},u)=>Ue(i.CheckboxItem,{ref:u,className:l("ps-relative ps-flex ps-cursor-default ps-select-none ps-items-center ps-rounded-sm ps-py-1.5 ps-pl-8 ps-pr-2 ps-text-sm ps-outline-none focus:ps-bg-accent focus:ps-text-accent-foreground data-[disabled]:ps-pointer-events-none data-[disabled]:ps-opacity-50",e),checked:t,...o,children:[R("span",{className:"ps-absolute ps-left-2 ps-flex ps-h-3.5 ps-w-3.5 ps-items-center ps-justify-center",children:R(i.ItemIndicator,{children:R(E,{className:"ps-h-4 ps-w-4"})})}),a]}));Ha.displayName=i.CheckboxItem.displayName;var Oa=V.forwardRef(({className:e,children:a,...t},o)=>Ue(i.RadioItem,{ref:o,className:l("ps-relative ps-flex ps-cursor-default ps-select-none ps-items-center ps-rounded-sm ps-py-1.5 ps-pl-8 ps-pr-2 ps-text-sm ps-outline-none focus:ps-bg-accent focus:ps-text-accent-foreground data-[disabled]:ps-pointer-events-none data-[disabled]:ps-opacity-50",e),...t,children:[R("span",{className:"ps-absolute ps-left-2 ps-flex ps-h-3.5 ps-w-3.5 ps-items-center ps-justify-center",children:R(i.ItemIndicator,{children:R($,{className:"ps-h-4 ps-w-4 ps-fill-current"})})}),a]}));Oa.displayName=i.RadioItem.displayName;var Na=V.forwardRef(({className:e,inset:a,...t},o)=>R(i.Label,{ref:o,className:l("ps-px-2 ps-py-1.5 ps-text-sm ps-font-semibold ps-text-foreground",a&&"ps-pl-8",e),...t}));Na.displayName=i.Label.displayName;var Ea=V.forwardRef(({className:e,...a},t)=>R(i.Separator,{ref:t,className:l("ps--mx-1 ps-my-1 ps-h-px ps-bg-border",e),...a}));Ea.displayName=i.Separator.displayName;var Ga=({className:e,...a})=>R("span",{className:l("ps-ml-auto ps-text-xs ps-tracking-widest ps-text-muted-foreground",e),...a});Ga.displayName="ContextMenuShortcut";import{jsx as He,jsxs as la}from"react/jsx-runtime";var Oe=e=>{if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return String(e);if(e==null)return"";if(za(e)){let a=e.props;return e.type&&typeof e.type=="function"&&e.type.name==="RevealText"?a.text||"":e.type&&typeof e.type=="function"&&e.type.name==="NullValue"?"NULL":a.children?Oe(a.children):""}return Array.isArray(e)?e.map(Oe).join(""):""},ua=({children:e})=>la(ta,{children:[He(oa,{className:"ps-block ps-w-full ps-p-[var(--studio-cell-spacing)]",children:e}),He(Fe,{children:la(qe,{onClick:()=>{let a=Oe(e);navigator.clipboard.writeText(a).catch(t=>{console.error("Failed to copy to clipboard:",t)})},className:"ps-flex ps-items-center ps-gap-2",children:[He(me,{size:12}),"Copy"]})})]});import{jsx as Va}from"react/jsx-runtime";function da(){return Va("code",{className:"ps-text-gray-500",children:"NULL"})}import{jsx as oe,jsxs as Ka}from"react/jsx-runtime";function ra({cell:e,getPinningStyles:a,dataType:t,isRelational:o,relatesTo:u,relationField:m}){let s=e.getValue(),f=s==null,x=C=>{if(C==null)return"NULL";if(typeof C=="object")try{return JSON.stringify(C,null,2)}catch(h){return console.error("Error stringifying value:",h),String(C)}return String(C)};return Ka(Te,{children:[oe(Ae,{asChild:!0,children:oe(se,{...a(e.column),"data-cell-type":"data","data-type":t.toLowerCase(),"data-relational":o?"true":void 0,"data-relates-to":u,"data-relation-field":m,className:l(a(e.column).className,"ps-p-0",e.column.getIsPinned()&&"ps-sticky"),children:oe(ua,{children:f?oe(da,{}):x(s)})})}),oe(Be,{align:"start",alignOffset:0,sideOffset:0,className:"ps-min-w-(--radix-popover-trigger-width) ps-rounded-none ps-bg-muted ps-p-0",children:oe(Xa,{value:x(s),theme:Wa,height:"100px",basicSetup:{lineNumbers:!0,foldGutter:!1,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!1},onChange:C=>{console.log("New value:",C)}})})]},e.id)}import{jsx as Za}from"react/jsx-runtime";function sa({cell:e,getPinningStyles:a,dataType:t}){let o={cell:e,getPinningStyles:a},u=e.column.columnDef.meta,m={...o,isRelational:u?.isRelational,relatesTo:u?.relatesTo,relationField:u?.relationField};return Za(ra,{...m,dataType:t||"STRING"})}import{flexRender as ut}from"@tanstack/react-table";import{Slot as Ja}from"@radix-ui/react-slot";import{cva as Qa}from"class-variance-authority";import*as fa from"react";import{jsx as ja}from"react/jsx-runtime";var _a=Qa("ps-inline-flex ps-items-center ps-justify-center ps-gap-2 ps-whitespace-nowrap ps-rounded-md ps-text-sm ps-font-medium ps-transition-colors focus-visible:ps-outline-none focus-visible:ps-ring-1 focus-visible:ps-ring-ring disabled:ps-pointer-events-none disabled:ps-opacity-50 [&_svg]:ps-pointer-events-none [&_svg]:ps-size-4 [&_svg]:ps-shrink-0",{variants:{variant:{default:"ps-bg-primary ps-text-primary-foreground ps-shadow hover:ps-bg-primary/90",destructive:"ps-bg-destructive ps-text-destructive-foreground ps-shadow-sm hover:ps-bg-destructive/90",outline:"ps-border ps-border-input ps-bg-background ps-shadow-sm hover:ps-bg-accent hover:ps-text-accent-foreground",secondary:"ps-bg-secondary ps-text-secondary-foreground ps-shadow-sm hover:ps-bg-secondary/80",ghost:"hover:ps-bg-accent hover:ps-text-accent-foreground",link:"ps-text-primary ps-underline-offset-4 hover:ps-underline"},size:{default:"ps-h-9 ps-px-4 ps-py-2",sm:"ps-h-8 ps-rounded-md ps-px-3 ps-text-xs",lg:"ps-h-10 ps-rounded-md ps-px-8",icon:"ps-h-9 ps-w-9"}},defaultVariants:{variant:"default",size:"default"}}),H=fa.forwardRef(({className:e,variant:a,size:t,asChild:o=!1,...u},m)=>ja(o?Ja:"button",{className:l(_a({variant:a,size:t,className:e})),ref:m,...u}));H.displayName="Button";import*as n from"@radix-ui/react-dropdown-menu";import*as W from"react";import{jsx as M,jsxs as Ee}from"react/jsx-runtime";var ia=n.Root,na=n.Trigger;var $a=W.forwardRef(({className:e,inset:a,children:t,...o},u)=>Ee(n.SubTrigger,{ref:u,className:l("ps-flex ps-cursor-default ps-select-none ps-items-center ps-gap-2 ps-rounded-sm ps-px-2 ps-py-1.5 ps-text-sm ps-outline-none focus:ps-bg-accent data-[state=open]:ps-bg-accent [&_svg]:ps-pointer-events-none [&_svg]:ps-size-4 [&_svg]:ps-shrink-0",a&&"ps-pl-8",e),...o,children:[t,M(G,{className:"ps-ml-auto"})]}));$a.displayName=n.SubTrigger.displayName;var Ya=W.forwardRef(({className:e,...a},t)=>M(n.SubContent,{ref:t,className:l("ps-z-50 ps-min-w-[8rem] ps-overflow-hidden ps-rounded-md ps-border ps-bg-popover ps-p-1 ps-text-popover-foreground ps-shadow-lg data-[state=open]:ps-animate-in data-[state=closed]:ps-animate-out data-[state=closed]:ps-fade-out-0 data-[state=open]:ps-fade-in-0 data-[state=closed]:ps-zoom-out-95 data-[state=open]:ps-zoom-in-95 data-[side=bottom]:ps-slide-in-from-top-2 data-[side=left]:ps-slide-in-from-right-2 data-[side=right]:ps-slide-in-from-left-2 data-[side=top]:ps-slide-in-from-bottom-2 ps-origin-[--radix-dropdown-menu-content-transform-origin]",e),...a}));Ya.displayName=n.SubContent.displayName;var Ne=W.forwardRef(({className:e,sideOffset:a=4,...t},o)=>M(n.Portal,{children:M(n.Content,{ref:o,sideOffset:a,className:l("ps-z-50 ps-max-h-[var(--radix-dropdown-menu-content-available-height)] ps-min-w-[8rem] ps-overflow-y-auto ps-overflow-x-hidden ps-rounded-md ps-border ps-bg-popover ps-p-1 ps-text-popover-foreground ps-shadow-md","data-[state=open]:ps-animate-in data-[state=closed]:ps-animate-out data-[state=closed]:ps-fade-out-0 data-[state=open]:ps-fade-in-0 data-[state=closed]:ps-zoom-out-95 data-[state=open]:ps-zoom-in-95 data-[side=bottom]:ps-slide-in-from-top-2 data-[side=left]:ps-slide-in-from-right-2 data-[side=right]:ps-slide-in-from-left-2 data-[side=top]:ps-slide-in-from-bottom-2 ps-origin-[--radix-dropdown-menu-content-transform-origin]",e),...t})}));Ne.displayName=n.Content.displayName;var Re=W.forwardRef(({className:e,inset:a,...t},o)=>M(n.Item,{ref:o,className:l("ps-relative ps-flex ps-cursor-default ps-select-none ps-items-center ps-gap-2 ps-rounded-sm ps-px-2 ps-py-1.5 ps-text-sm ps-outline-none ps-transition-colors focus:ps-bg-accent focus:ps-text-accent-foreground data-[disabled]:ps-pointer-events-none data-[disabled]:ps-opacity-50 [&>svg]:ps-size-4 [&>svg]:ps-shrink-0",a&&"ps-pl-8",e),...t}));Re.displayName=n.Item.displayName;var et=W.forwardRef(({className:e,children:a,checked:t,...o},u)=>Ee(n.CheckboxItem,{ref:u,className:l("ps-relative ps-flex ps-cursor-default ps-select-none ps-items-center ps-rounded-sm ps-py-1.5 ps-pl-8 ps-pr-2 ps-text-sm ps-outline-none ps-transition-colors focus:ps-bg-accent focus:ps-text-accent-foreground data-[disabled]:ps-pointer-events-none data-[disabled]:ps-opacity-50",e),checked:t,...o,children:[M("span",{className:"ps-absolute ps-left-2 ps-flex ps-h-3.5 ps-w-3.5 ps-items-center ps-justify-center",children:M(n.ItemIndicator,{children:M(E,{className:"ps-h-4 ps-w-4"})})}),a]}));et.displayName=n.CheckboxItem.displayName;var at=W.forwardRef(({className:e,children:a,...t},o)=>Ee(n.RadioItem,{ref:o,className:l("ps-relative ps-flex ps-cursor-default ps-select-none ps-items-center ps-rounded-sm ps-py-1.5 ps-pl-8 ps-pr-2 ps-text-sm ps-outline-none ps-transition-colors focus:ps-bg-accent focus:ps-text-accent-foreground data-[disabled]:ps-pointer-events-none data-[disabled]:ps-opacity-50",e),...t,children:[M("span",{className:"ps-absolute ps-left-2 ps-flex ps-h-3.5 ps-w-3.5 ps-items-center ps-justify-center",children:M(n.ItemIndicator,{children:M($,{className:"ps-h-2 ps-w-2 ps-fill-current"})})}),a]}));at.displayName=n.RadioItem.displayName;var tt=W.forwardRef(({className:e,inset:a,...t},o)=>M(n.Label,{ref:o,className:l("ps-px-2 ps-py-1.5 ps-text-sm ps-font-semibold",a&&"ps-pl-8",e),...t}));tt.displayName=n.Label.displayName;var ot=W.forwardRef(({className:e,...a},t)=>M(n.Separator,{ref:t,className:l("ps--mx-1 ps-my-1 ps-h-px ps-bg-muted",e),...a}));ot.displayName=n.Separator.displayName;var lt=({className:e,...a})=>M("span",{className:l("ps-ml-auto ps-text-xs ps-tracking-widest ps-opacity-60",e),...a});lt.displayName="DropdownMenuShortcut";import{jsx as v,jsxs as Q}from"react/jsx-runtime";function Ge({header:e}){let a=e.column.columnDef.meta,t=a?.dataType,o=a?.isRelational;return Q("div",{className:"ps-flex ps-items-center ps-justify-between ps-w-full ps-h-full",children:[Q("div",{className:"ps-flex-1 ps-flex ps-items-center ps-justify-between",children:[o&&v(Le,{size:14,className:"text-blue-700"}),Q("div",{className:"ps-align-text-bottom ps-leading-none ps-h-[20px]",children:[v("span",{className:"ps-inline-block ps-text-foreground ps-font-bold ps-text-sm",children:e.isPlaceholder?null:ut(e.column.columnDef.header,e.getContext())}),t&&t!=="NONE"&&v("span",{className:"ps-inline-block ps-ml-2 ps-text-xs ps-font-mono ps-text-muted-foreground/70 ps-lowercase",children:t})]}),v("span",{className:"ps-flex ps-items-center ps-gap-1",children:e.column.getCanPin()&&e.column.id!=="select"&&Q(ia,{children:[v(na,{asChild:!0,children:v(H,{variant:"ghost",size:"icon",children:v(J,{size:16})})}),Q(Ne,{children:[e.column.getCanSort()&&v(Re,{onClick:()=>e.column.toggleSorting(e.column.getIsSorted()==="asc"),children:Q("span",{className:"ps-flex ps-items-center ps-gap-2",children:[e.column.getIsSorted()==="asc"?v(Z,{size:16}):v(fe,{size:16}),e.column.getIsSorted()==="asc"?"Sort descending":"Sort ascending"]})}),v(Re,{onClick:()=>e.column.pin(e.column.getIsPinned()?!1:"left"),children:e.column.getIsPinned()?Q("span",{className:"ps-flex ps-items-center ps-gap-2",children:[v(xe,{size:16}),"Unpin column"]}):Q("span",{className:"ps-flex ps-items-center ps-gap-2",children:[v(Ie,{size:16}),"Pin column"]})})]})]})})]}),e.column.getCanResize()&&v("button",{type:"button",tabIndex:0,onMouseDown:u=>{u.stopPropagation(),e.getResizeHandler()(u)},onTouchStart:u=>{u.stopPropagation(),e.getResizeHandler()(u)},onClick:u=>u.stopPropagation(),onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),u.stopPropagation(),e.getResizeHandler()(u))},className:l("ps-absolute ps-right-0 ps-top-0 ps-h-full ps-w-3 ps-cursor-col-resize","ps-select-none ps-touch-none ps-transition-colors ps-group","ps-border-0 ps-bg-transparent",e.column.getIsResizing()&&"ps-bg-gray-300","before:ps-absolute before:ps-right-[3px] before:ps-top-1/2 before:ps--translate-y-1/2","after:ps-absolute after:ps-right-[7px] after:ps-top-1/2 after:ps--translate-y-1/2","before:ps-w-[2px] before:ps-h-0 before:ps-bg-gray-400 before:ps-rounded-full before:ps-opacity-0","after:ps-w-[2px] after:ps-h-0 after:ps-bg-gray-400 after:ps-rounded-full after:ps-opacity-0","before:ps-transition-all before:ps-duration-200","after:ps-transition-all after:ps-duration-200","group-hover:before:ps-opacity-100","group-hover:after:ps-opacity-100","group-hover:before:ps-h-4","group-hover:after:ps-h-4","group-active:ps-bg-transparent group-active:before:ps-bg-white group-active:after:ps-bg-white",e.column.getIsResizing()&&"before:ps-opacity-100"),"aria-label":"Resize column"})]})}import*as ca from"react";import{jsx as dt}from"react/jsx-runtime";var ze=ca.forwardRef(({className:e,type:a,...t},o)=>dt("input",{type:a,className:l("ps-flex ps-h-9 ps-w-full ps-rounded-md ps-border ps-border-input ps-bg-transparent ps-px-3 ps-py-1 ps-text-base ps-shadow-sm ps-transition-colors file:ps-border-0 file:ps-bg-transparent file:ps-text-sm file:ps-font-medium file:ps-text-foreground placeholder:ps-text-muted-foreground focus-visible:ps-outline-none focus-visible:ps-ring-1 focus-visible:ps-ring-ring disabled:ps-cursor-not-allowed disabled:ps-opacity-50 md:ps-text-sm",e),ref:o,...t}));ze.displayName="Input";import*as c from"@radix-ui/react-select";import*as _ from"react";import{jsx as P,jsxs as Ke}from"react/jsx-runtime";var pa=c.Root;var ma=c.Value,Ve=_.forwardRef(({className:e,children:a,...t},o)=>Ke(c.Trigger,{ref:o,className:l("ps-flex ps-h-9 ps-w-full ps-items-center ps-justify-between ps-whitespace-nowrap ps-rounded-md ps-border ps-border-input ps-bg-transparent ps-px-3 ps-py-2 ps-text-sm ps-shadow-sm ps-ring-offset-background data-[placeholder]:ps-text-muted-foreground focus:ps-outline-none focus:ps-ring-1 focus:ps-ring-ring disabled:ps-cursor-not-allowed disabled:ps-opacity-50 [&>span]:ps-line-clamp-1",e),...t,children:[a,P(c.Icon,{asChild:!0,children:P(te,{className:"ps-h-4 ps-w-4 ps-opacity-50"})})]}));Ve.displayName=c.Trigger.displayName;var La=_.forwardRef(({className:e,...a},t)=>P(c.ScrollUpButton,{ref:t,className:l("ps-flex ps-cursor-default ps-items-center ps-justify-center ps-py-1",e),...a,children:P(ne,{className:"ps-h-4 ps-w-4"})}));La.displayName=c.ScrollUpButton.displayName;var xa=_.forwardRef(({className:e,...a},t)=>P(c.ScrollDownButton,{ref:t,className:l("ps-flex ps-cursor-default ps-items-center ps-justify-center ps-py-1",e),...a,children:P(te,{className:"ps-h-4 ps-w-4"})}));xa.displayName=c.ScrollDownButton.displayName;var We=_.forwardRef(({className:e,children:a,position:t="popper",...o},u)=>P(c.Portal,{children:Ke(c.Content,{ref:u,className:l("ps-relative ps-z-50 ps-max-h-[--radix-select-content-available-height] ps-min-w-[8rem] ps-overflow-y-auto ps-overflow-x-hidden ps-rounded-md ps-border ps-bg-popover ps-text-popover-foreground ps-shadow-md data-[state=open]:ps-animate-in data-[state=closed]:ps-animate-out data-[state=closed]:ps-fade-out-0 data-[state=open]:ps-fade-in-0 data-[state=closed]:ps-zoom-out-95 data-[state=open]:ps-zoom-in-95 data-[side=bottom]:ps-slide-in-from-top-2 data-[side=left]:ps-slide-in-from-right-2 data-[side=right]:ps-slide-in-from-left-2 data-[side=top]:ps-slide-in-from-bottom-2 ps-origin-[--radix-select-content-transform-origin]",t==="popper"&&"data-[side=bottom]:ps-translate-y-1 data-[side=left]:ps--translate-x-1 data-[side=right]:ps-translate-x-1 data-[side=top]:ps--translate-y-1",e),position:t,...o,children:[P(La,{}),P(c.Viewport,{className:l("ps-p-1",t==="popper"&&"ps-h-[var(--radix-select-trigger-height)] ps-w-full ps-min-w-[var(--radix-select-trigger-width)]"),children:a}),P(xa,{})]})}));We.displayName=c.Content.displayName;var rt=_.forwardRef(({className:e,...a},t)=>P(c.Label,{ref:t,className:l("ps-px-2 ps-py-1.5 ps-text-sm ps-font-semibold",e),...a}));rt.displayName=c.Label.displayName;var Xe=_.forwardRef(({className:e,children:a,...t},o)=>Ke(c.Item,{ref:o,className:l("ps-relative ps-flex ps-w-full ps-cursor-default ps-select-none ps-items-center ps-rounded-sm ps-py-1.5 ps-pl-2 ps-pr-8 ps-text-sm ps-outline-none focus:ps-bg-accent focus:ps-text-accent-foreground data-[disabled]:ps-pointer-events-none data-[disabled]:ps-opacity-50",e),...t,children:[P("span",{className:"ps-absolute ps-right-2 ps-flex ps-h-3.5 ps-w-3.5 ps-items-center ps-justify-center",children:P(c.ItemIndicator,{children:P(E,{className:"ps-h-4 ps-w-4"})})}),P(c.ItemText,{children:a})]}));Xe.displayName=c.Item.displayName;var st=_.forwardRef(({className:e,...a},t)=>P(c.Separator,{ref:t,className:l("ps--mx-1 ps-my-1 ps-h-px ps-bg-muted",e),...a}));st.displayName=c.Separator.displayName;import{jsx as k,jsxs as Y}from"react/jsx-runtime";var ft=[10,20,50,100];function Ia({table:e,variant:a="basic",className:t}){let{pageSize:o,pageIndex:u}=e.getState().pagination,m=e.getPageCount();return k("div",{className:l("ps-flex ps-items-center ps-justify-between ps-space-x-2 ps-py-4 ps-px-4",t),children:a==="basic"?Y("div",{className:"ps-flex ps-items-center ps-space-x-2",children:[k(H,{variant:"outline",size:"sm",className:"ps-h-9",onClick:()=>e.previousPage(),disabled:!e.getCanPreviousPage(),children:"Previous"}),k(H,{variant:"outline",size:"sm",className:"ps-h-9",onClick:()=>e.nextPage(),disabled:!e.getCanNextPage(),children:"Next"})]}):Y("div",{className:"ps-flex ps-items-center ps-space-x-2",children:[Y("div",{className:"ps-flex ps-items-center ps-space-x-2",children:[k(H,{variant:"outline",onClick:()=>e.setPageIndex(0),disabled:!e.getCanPreviousPage(),children:k(ce,{className:"ps-w-4 ps-h-4"})}),k(H,{variant:"outline",onClick:()=>e.previousPage(),disabled:!e.getCanPreviousPage(),children:k(ie,{className:"ps-w-4 ps-h-4"})}),Y("div",{className:"ps-flex ps-items-center ps-gap-1 ps-text-xs ps-font-medium",children:["Page",k(ze,{type:"number",min:1,max:m,value:u+1,className:"ps-w-12",onChange:s=>{let f=s.target.value?Number(s.target.value)-1:0;e.setPageIndex(f)}}),Y("span",{className:"ps-shrink-0 ps-w-max",children:["of ",m]})]}),k(H,{variant:"outline",onClick:()=>e.nextPage(),disabled:!e.getCanNextPage(),children:k(G,{className:"ps-w-4 ps-h-4"})}),k(H,{variant:"outline",onClick:()=>e.setPageIndex(m-1),disabled:!e.getCanNextPage(),children:k(pe,{className:"ps-w-4 ps-h-4"})})]}),Y(pa,{value:o.toString(),onValueChange:s=>e.setPageSize(Number(s)),children:[k(Ve,{children:k(ma,{})}),k(We,{children:ft.map(s=>Y(Xe,{value:s.toString(),children:[s," per page"]},s))})]})]})})}var he=e=>{let a=e.getIsPinned(),t=a==="left"&&e.getIsLastColumn("left"),o=a==="right"&&e.getIsFirstColumn("right");return{className:l("ps-overflow-hidden ps-whitespace-nowrap ps-text-ellipsis",a&&["ps-sticky ps-bg-background ps-shadow-[1px_0_0_0_hsl(var(--border))]",a==="left"?"ps-left-0":"ps-right-0","ps-z-20"],!a&&"ps-relative ps-z-10",t&&"ps-shadow-[1px_0_0_0_hsl(var(--border))]",o&&"ps-shadow-[-1px_0_0_0_hsl(var(--border))]"),style:{width:e.getSize(),left:a==="left"?`${e.getStart("left")}px`:void 0,right:a==="right"?`${e.getAfter("right")}px`:void 0}}};import{Fragment as Mt,jsx as L,jsxs as ue}from"react/jsx-runtime";var bt=({_table:e})=>{let{currentTable:a,isLoaded:t}=ae();return t?L("div",{className:"ps-flex ps-items-center ps-justify-between ps-w-full ps-gap-2",children:L("div",{className:"ps-flex ps-items-center ps-gap-2",children:ue("span",{className:"ps-flex ps-items-center ps-gap-2",children:[L(ea,{}),L("h1",{className:"ps-text-sm ps-font-medium",children:a?.name})]})})}):null},Rt=({header:e,children:a,getPinningStyles:t})=>{let{attributes:o,listeners:u,transform:m,transition:s,setNodeRef:f,isDragging:x,isOver:C}=xt({id:e.id}),h=e.column.columnDef.meta,S={transform:It.Transform.toString(m),transition:s,...t(e.column).style,cursor:"grab",touchAction:"none"};return ue(ke,{ref:f,...o,...u,style:S,"data-relational":h?.isRelational?"true":void 0,"data-relates-to":h?.relatesTo,"data-relation-field":h?.relationField,className:l("ps-group",t(e.column).className,x&&"ps-opacity-50",C&&"ps-bg-gray-100","ps-select-none ps-touch-none ps-relative",e.column.getIsPinned()&&"ps-sticky"),children:[a,C&&L("div",{className:"ps-absolute ps-inset-0 ps-border-2 ps-border-primary ps-rounded-sm ps-pointer-events-none"})]})};function Ca({data:e=[],columns:a}){console.log("Data received in StudioGrid:",e);let[t,o]=le([]),[u,m]=le([]),[s,f]=le({}),[x,C]=le({left:[],right:[]}),[h,S]=le([]),[de,F]=le("");wt(()=>{if(a&&a.length>0){let I=a.map(B=>B.id);if(h.length===0){S(I);return}let d=[...h],g=d.filter(B=>!a.some(U=>U.id===B));g.forEach(B=>{let U=d.indexOf(B);U!==-1&&d.splice(U,1)});let D=I.filter(B=>!d.includes(B));D.length>0&&d.push(...D),(g.length>0||D.length>0)&&S(d)}},[a,h]);let y=ct(nt,{activationConstraint:{distance:10}}),T=pt(y),A=I=>{let{active:d,over:g}=I;if(g&&d.id!==g.id){let D=w.getColumn(d.id),B=w.getColumn(g.id);if(!D||!B)return;let U=D.getIsPinned(),ee=B.getIsPinned();if(U!==ee)return;let Pe=h.indexOf(d.id),we=h.indexOf(g.id);if(Pe===-1||we===-1)return;let Me=[...h];Me.splice(Pe,1),Me.splice(we,0,d.id),S(Me)}},q=kt(()=>{if(!a||a.length===0)return console.log("No columns configuration available"),[];let I=(d,g)=>{if(d==null)return"";switch(g){case"TIMESTAMP":return d?new Date(d).toLocaleString():"";case"UUID":case"STRING":return String(d);default:return String(d)}};return a.map(d=>({accessorKey:d.id,header:()=>L("div",{className:"ps-font-medium",children:d.id}),cell:({getValue:g})=>I(g(),d.type),meta:{dataType:d.type,isRelational:d.isRelational,relatesTo:d.relatesTo,relationField:d.relationField}}))},[a]),w=Pt({data:e||[],defaultColumn:{size:200,minSize:50,maxSize:500},columns:q,getCoreRowModel:Ct(),onSortingChange:o,getSortedRowModel:St(),getPaginationRowModel:ht(),getFilteredRowModel:gt(),onColumnFiltersChange:m,enableColumnResizing:!0,columnResizeMode:"onChange",onColumnSizingChange:f,enableColumnPinning:!0,onColumnPinningChange:C,onGlobalFilterChange:F,globalFilterFn:(I,d,g)=>{let D=I.getValue(d);return D==null?!1:String(D).toLowerCase().includes(String(g).toLowerCase())},state:{sorting:t,columnFilters:u,columnSizing:s,columnPinning:x,columnOrder:h,globalFilter:de}});return!e||e.length===0?ue("div",{className:"ps-p-4 ps-border ps-rounded-md ps-w-full",children:[L("p",{className:"ps-text-lg ps-font-semibold",children:"No data available."}),L("p",{className:"ps-text-sm ps-text-gray-500",children:e?"Data array is empty.":"Data is undefined."})]}):ue(Mt,{children:[L("div",{className:"ps-bg-studio-header-background ps-flex ps-w-full ps-p-2 ps-py-3 ps-border-b",children:L(bt,{_table:w})}),L("div",{"data-studio":"content",className:"ps-flex-1 ps-w-0 ps-h-0 ps-min-w-full",children:ue("div",{className:"ps-flex ps-flex-col ps-w-full ps-h-full ps-overflow-scroll",children:[L(it,{sensors:T,onDragEnd:A,children:ue(ve,{children:[L(ye,{children:w.getHeaderGroups().map(I=>L(re,{className:l("ps-relative",w.getLeftLeafHeaders().some(d=>d.column.getIsPinned()==="left")&&`ps-pl-[${w.getLeftLeafHeaders().filter(d=>d.column.getIsPinned()==="left").reduce((d,g)=>d+g.getSize(),0)}px]`),children:L(Lt,{items:I.headers.map(d=>d.id),strategy:mt,children:I.headers.map(d=>d.column.id==="select"?L(ke,{className:l("ps-px-[var(--studio-cell-spacing)]",he(d.column).className,d.column.getIsPinned()&&"ps-sticky"),style:he(d.column).style,"data-cell-type":"select",children:L(Ge,{header:d})},d.id):L(Rt,{header:d,table:w,getPinningStyles:he,children:L(Ge,{header:d})},d.id))})},I.id))}),L(De,{children:w.getRowModel().rows?.length?w.getRowModel().rows.map(I=>L(re,{className:l("ps-bg-table-row ps-odd:bg-table-row-odd ps-group"),children:I.getVisibleCells().map(d=>L(sa,{cell:d,getPinningStyles:he,dataType:a.find(g=>g.id===d.column.id)?.type},d.id))},I.id)):L(re,{children:L(se,{colSpan:a.length,className:"ps-h-24 ps-text-center",children:"No results."})})})]})}),L(Ia,{table:w,variant:"numeric"})]})})]})}import{createContext as vt,useContext as Sd,useEffect as yt,useState as Dt}from"react";import{jsx as Bt}from"react/jsx-runtime";var Tt={theme:"system",setTheme:()=>null},At=vt(Tt);function ga({children:e,defaultTheme:a="system",storageKey:t="vite-ui-theme",...o}){let[u,m]=Dt(()=>localStorage.getItem(t)||a);yt(()=>{let f=window.document.documentElement;if(f.classList.remove("light","dark"),u==="system"){let x=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";f.classList.add(x);return}f.classList.add(u)},[u]);let s={theme:u,setTheme:f=>{localStorage.setItem(t,f),m(f)}};return Bt(At.Provider,{...o,value:s,children:e})}import{jsx as X,jsxs as Gt}from"react/jsx-runtime";var Sa=Ut(void 0),ae=()=>{let e=Ht(Sa);if(!e)throw new Error("useStudio must be used within a Studio.Provider");return e},Ot={integer:"INTEGER",varchar:"VARCHAR",text:"TEXT",enum:"STRING",boolean:"BOOLEAN"};function Nt(e,a){return{id:e,accessorKey:e,header:e.charAt(0).toUpperCase()+e.slice(1),type:Ot[a.dataType.name]||"STRING",nullable:a.nullable,isKey:a.partOfPk}}var Et=({adapter:e})=>{let[a,t]=Se([]),[o,u]=Se(null),[m,s]=Se(!1),[f,x]=Se([]),[C,h]=Se([]),S=qt.useMemo(()=>new Set(a.filter(F=>F.isFavorite).map(F=>F.id)),[a]),de=F=>{t(y=>y.map(T=>T.id===F?{...T,isFavorite:!T.isFavorite}:T))};return ha(()=>{(async()=>{try{let[y,T]=await e.introspect();if(y||!T?.schemas){console.error("Error fetching schema:",y);return}let A=Object.entries(T.schemas).flatMap(([q,w])=>Object.entries(w.tables).map(([I])=>({id:`${q}.${I}`,name:I.charAt(0).toUpperCase()+I.slice(1),schema:q,isFavorite:!1})));t(A),!o&&A.length>0&&A[0]&&u(A[0])}catch(y){console.error("Error fetching tables:",y)}})()},[e,o]),ha(()=>{(async()=>{if(!o?.id){s(!0);return}try{s(!1);let[y,T]=await e.introspect();if(y||!T?.schemas){console.error("Error fetching schema:",y),s(!0);return}let[A,q]=o.id.split(".");if(!A||!q){console.error("Invalid table ID format:",o.id),s(!0);return}let w=T.schemas[A];if(!w){console.error(`Schema ${A} not found`),s(!0);return}let I=w.tables[q];if(!I){console.error(`Table ${q} not found in schema ${A}`),s(!0);return}let d=Object.entries(I.columns).map(([U,ee])=>Nt(U,ee));h(d);let[g,D]=await e.query({schema:A,table:q,filters:[],sortings:[]});if(g||!D){console.error(`Failed to fetch data for table ${q}:`,g),s(!0);return}let B=D.rows.map(U=>{let ee={};return Object.entries(U).forEach(([Pe,we])=>{ee[Pe]=we.value}),ee});x(B),s(!0)}catch(y){console.error("Error fetching table data:",y),s(!0)}})()},[e,o]),e?!m&&a.length===0?X("div",{children:"Loading available tables..."}):m&&a.length===0?X("div",{children:"No tables found in the database."}):X(ga,{children:X(Ft,{children:X(Sa.Provider,{value:{adapter:e,currentTable:o,isLoaded:m,tables:a,favoriteTableIds:S,setCurrentTable:u,toggleFavorite:de},children:Gt("div",{className:"ps-flex ps-gap-4 ps-w-full ps-rounded-sm ps-bg-background ps-p-4 ps-relative",children:[X(Ze,{}),X("div",{className:"ps-flex ps-w-full ps-flex-col ps-border ps-rounded-lg",children:X(Ca,{columns:C,data:f})})]})})})}):(console.error("No adapter provided to Studio component"),X("div",{children:"Error: No adapter provided"}))},Pa=Et;export{Pa as Studio};
1
+ import"../chunk-2FW6TKD6.js";import"../index-KSZNOSSS.css";import{NuqsAdapter as Dt}from"nuqs/adapters/react";import Tt,{createContext as At,useContext as Bt,useEffect as Ia,useState as ge}from"react";import{Slot as Pa}from"@radix-ui/react-slot";import{useQueryState as wa}from"nuqs";import{clsx as ha}from"clsx";import{twMerge as Sa}from"tailwind-merge";function l(...e){return Sa(ha(e))}import{jsx as K,jsxs as Ze}from"react/jsx-runtime";var j=()=>{let{setCurrentTable:e,currentTable:a,favoriteTableIds:t,tables:o}=Pe(),[u,p]=wa("tableId"),r=async f=>{await p(f);let x=o.find(C=>C.id===f);x&&e(x)};return Ze("div",{className:"ps-flex ps-flex-col ps-w-64 ps-gap-4 ps-shrink-0",children:[K(j.Block,{label:"Tables",children:o.map(f=>K(j.Item,{isActive:a?.id===f.id,onClick:x=>{x.preventDefault(),r(f.id)},className:`ps-px-2 ps-py-1 ps-cursor-pointer ps-rounded ${a?.id===f.id?"ps-bg-primary ps-text-white":"ps-hover:ps-bg-gray-100"}`,children:f.name},f.id))}),t.size>0&&K(j.Block,{label:"Favourites",children:o.filter(f=>t.has(f.id)).map(f=>K(j.Item,{isActive:a?.id===f.id,onClick:x=>{x.preventDefault(),r(f.id)},children:f.name},f.id))})]})},ka=({className:e,label:a,children:t,...o})=>Ze("div",{className:l("ps-rounded-lg ps-border ps-bg-card ps-text-card-foreground ps-shadow-xs",e),...o,children:[K("div",{className:"ps-pt-4 ps-pb-2 ps-px-4",children:K("h2",{className:"ps-text-sm ps-font-medium",children:a})}),K("nav",{"aria-label":a,className:"ps-flex ps-flex-col ps-gap-px ps-pb-3",children:t})]}),ba=({className:e,asChild:a=!1,isActive:t,size:o,...u})=>K(a?Pa:"button",{"data-sidebar":"menu-button","data-size":o,"data-active":t,className:l("ps-py-1.5 ps-px-4 ps-text-sm ps-font-medium ps-flex ps-gap-2 ps-items-center ps-border ps-border-transparent ps-bg-transparent ps-hover:bg-muted/50",e),...u});j.Block=ka;j.Item=ba;var Ke=j;import{DndContext as dt,MouseSensor as st,useSensor as rt,useSensors as ft}from"@dnd-kit/core";import{horizontalListSortingStrategy as it,SortableContext as nt,useSortable as ct}from"@dnd-kit/sortable";import{CSS as pt}from"@dnd-kit/utilities";import{getCoreRowModel as mt,getFilteredRowModel as Lt,getPaginationRowModel as xt,getSortedRowModel as It,useReactTable as Ct}from"@tanstack/react-table";import{useEffect as gt,useMemo as ht,useState as oe}from"react";import*as N from"react";import{jsx as O}from"react/jsx-runtime";var Me=N.forwardRef(({className:e,...a},t)=>O("div",{className:"ps-relative ps-w-full ps-overflow-auto ps-flex ps-items-start ps-h-full",children:O("table",{ref:t,className:l("ps-w-full ps-caption-bottom ps-text-sm table-fixed",e),...a})}));Me.displayName="Table";var ve=N.forwardRef(({className:e,...a},t)=>O("thead",{ref:t,className:l("[&_tr]:ps-border-b",e),...a}));ve.displayName="TableHeader";var ye=N.forwardRef(({className:e,...a},t)=>O("tbody",{ref:t,className:l("[&_tr:last-child]:ps-border-0",e),...a}));ye.displayName="TableBody";var Ra=N.forwardRef(({className:e,...a},t)=>O("tfoot",{ref:t,className:l("ps-border-t ps-bg-muted/50 ps-font-medium [&>tr]:last:ps-border-b-0",e),...a}));Ra.displayName="TableFooter";var ue=N.forwardRef(({className:e,...a},t)=>O("tr",{ref:t,className:l("ps-border-b ps-transition-colors hover:ps-bg-muted/50 data-[state=selected]:ps-bg-muted",e),...a}));ue.displayName="TableRow";var we=N.forwardRef(({className:e,...a},t)=>O("th",{ref:t,className:l("ps-h-10 ps-px-2 ps-text-left ps-align-middle ps-font-medium ps-text-muted-foreground [&:has([role=checkbox])]:ps-pr-0 [&>[role=checkbox]]:ps-translate-y-[2px]",e),...a}));we.displayName="TableHead";var de=N.forwardRef(({className:e,...a},t)=>O("td",{ref:t,className:l("ps-p-2 ps-align-middle [&:has([role=checkbox])]:ps-pr-0 [&>[role=checkbox]]:ps-translate-y-[2px]",e),...a}));de.displayName="TableCell";var Ma=N.forwardRef(({className:e,...a},t)=>O("caption",{ref:t,className:l("ps-mt-4 ps-text-sm ps-text-muted-foreground",e),...a}));Ma.displayName="TableCaption";import{tokyoNight as Ea}from"@uiw/codemirror-theme-tokyo-night";import Ga from"@uiw/react-codemirror";import*as E from"@radix-ui/react-popover";import*as b from"react";import{jsx as se}from"react/jsx-runtime";var Je=b.createContext(null),De=({children:e,...a})=>{let[t,o]=b.useState(!1);return se(Je.Provider,{value:{open:t,setOpen:o},children:se(E.Root,{open:t,onOpenChange:o,...a,children:e})})};De.displayName="PopoverCell";var Te=b.forwardRef(({children:e,onDoubleClick:a,className:t,...o},u)=>{let p=b.useContext(Je),[r,f]=b.useState(!1),x=b.useRef(null);return b.useEffect(()=>{let S=le=>{let F=le.target;x.current&&!x.current.contains(F)&&(console.log("Outside click - removing focus"),f(!1))};return document.addEventListener("click",S),()=>document.removeEventListener("click",S)},[]),se(E.Trigger,{ref:S=>{typeof u=="function"?u(S):u&&(u.current=S),x.current=S},onClick:S=>{S.preventDefault(),console.log("Click handler - setting focus to true"),f(!0)},onDoubleClick:S=>{S.preventDefault(),p?.setOpen(!0),a?.()},"data-focus":r.toString(),className:l("w-full h-full cursor-pointer",t),...o,children:e})});Te.displayName="PopoverCellTrigger";var Ae=b.forwardRef(({className:e,align:a="center",sideOffset:t=4,...o},u)=>se(E.Portal,{children:se(E.Content,{ref:u,align:a,sideOffset:t,className:l("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-hidden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...o})}));Ae.displayName=E.Content.displayName;import{forwardRef as ya,createElement as Da}from"react";var Qe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ke=(...e)=>e.filter((a,t,o)=>!!a&&o.indexOf(a)===t).join(" ");import{forwardRef as va,createElement as je}from"react";var _e={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var $e=va(({color:e="currentColor",size:a=24,strokeWidth:t=2,absoluteStrokeWidth:o,className:u="",children:p,iconNode:r,...f},x)=>je("svg",{ref:x,..._e,width:a,height:a,stroke:e,strokeWidth:o?Number(t)*24/Number(a):t,className:ke("lucide",u),...f},[...r.map(([C,h])=>je(C,h)),...Array.isArray(p)?p:[p]]));var m=(e,a)=>{let t=ya(({className:o,...u},p)=>Da($e,{ref:p,iconNode:a,className:ke(`lucide-${Qe(e)}`,o),...u}));return t.displayName=`${e}`,t};var Z=m("ArrowDownWideNarrow",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h10",key:"1w87gc"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h4",key:"q8tih4"}]]);var re=m("ArrowUpWideNarrow",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h4",key:"1krc32"}]]);var G=m("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);var ae=m("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);var fe=m("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);var z=m("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);var ie=m("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);var ne=m("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);var ce=m("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);var $=m("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);var pe=m("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);var J=m("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);var me=m("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);var Le=m("PinOff",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]);var xe=m("Pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);import{isValidElement as Oa}from"react";import*as i from"@radix-ui/react-context-menu";import*as V from"react";import{jsx as R,jsxs as qe}from"react/jsx-runtime";var Ye=i.Root,ea=i.Trigger;var Ta=V.forwardRef(({className:e,inset:a,children:t,...o},u)=>qe(i.SubTrigger,{ref:u,className:l("ps-flex ps-cursor-default ps-select-none ps-items-center ps-rounded-sm ps-px-2 ps-py-1.5 ps-text-sm ps-outline-none focus:ps-bg-accent focus:ps-text-accent-foreground data-[state=open]:ps-bg-accent data-[state=open]:ps-text-accent-foreground",a&&"ps-pl-8",e),...o,children:[t,R(z,{className:"ps-ml-auto ps-h-4 ps-w-4"})]}));Ta.displayName=i.SubTrigger.displayName;var Aa=V.forwardRef(({className:e,...a},t)=>R(i.SubContent,{ref:t,className:l("ps-z-50 ps-min-w-[8rem] ps-overflow-hidden ps-rounded-md ps-border ps-bg-popover ps-p-1 ps-text-popover-foreground ps-shadow-lg data-[state=open]:ps-animate-in data-[state=closed]:ps-animate-out data-[state=closed]:ps-fade-out-0 data-[state=open]:ps-fade-in-0 data-[state=closed]:ps-zoom-out-95 data-[state=open]:ps-zoom-in-95 data-[side=bottom]:ps-slide-in-from-top-2 data-[side=left]:ps-slide-in-from-right-2 data-[side=right]:ps-slide-in-from-left-2 data-[side=top]:ps-slide-in-from-bottom-2 ps-origin-[--radix-context-menu-content-transform-origin]",e),...a}));Aa.displayName=i.SubContent.displayName;var Be=V.forwardRef(({className:e,...a},t)=>R(i.Portal,{children:R(i.Content,{ref:t,className:l("ps-z-50 ps-max-h-[--radix-context-menu-content-available-height] ps-min-w-[8rem] ps-overflow-y-auto ps-overflow-x-hidden ps-rounded-md ps-border ps-bg-popover ps-p-1 ps-text-popover-foreground ps-shadow-md data-[state=open]:ps-animate-in data-[state=closed]:ps-animate-out data-[state=closed]:ps-fade-out-0 data-[state=open]:ps-fade-in-0 data-[state=closed]:ps-zoom-out-95 data-[state=open]:ps-zoom-in-95 data-[side=bottom]:ps-slide-in-from-top-2 data-[side=left]:ps-slide-in-from-right-2 data-[side=right]:ps-slide-in-from-left-2 data-[side=top]:ps-slide-in-from-bottom-2 ps-origin-[--radix-context-menu-content-transform-origin]",e),...a})}));Be.displayName=i.Content.displayName;var Fe=V.forwardRef(({className:e,inset:a,...t},o)=>R(i.Item,{ref:o,className:l("ps-relative ps-flex ps-cursor-default ps-select-none ps-items-center ps-rounded-sm ps-px-2 ps-py-1.5 ps-text-sm ps-outline-none focus:ps-bg-accent focus:ps-text-accent-foreground data-[disabled]:ps-pointer-events-none data-[disabled]:ps-opacity-50",a&&"ps-pl-8",e),...t}));Fe.displayName=i.Item.displayName;var Ba=V.forwardRef(({className:e,children:a,checked:t,...o},u)=>qe(i.CheckboxItem,{ref:u,className:l("ps-relative ps-flex ps-cursor-default ps-select-none ps-items-center ps-rounded-sm ps-py-1.5 ps-pl-8 ps-pr-2 ps-text-sm ps-outline-none focus:ps-bg-accent focus:ps-text-accent-foreground data-[disabled]:ps-pointer-events-none data-[disabled]:ps-opacity-50",e),checked:t,...o,children:[R("span",{className:"ps-absolute ps-left-2 ps-flex ps-h-3.5 ps-w-3.5 ps-items-center ps-justify-center",children:R(i.ItemIndicator,{children:R(G,{className:"ps-h-4 ps-w-4"})})}),a]}));Ba.displayName=i.CheckboxItem.displayName;var Fa=V.forwardRef(({className:e,children:a,...t},o)=>qe(i.RadioItem,{ref:o,className:l("ps-relative ps-flex ps-cursor-default ps-select-none ps-items-center ps-rounded-sm ps-py-1.5 ps-pl-8 ps-pr-2 ps-text-sm ps-outline-none focus:ps-bg-accent focus:ps-text-accent-foreground data-[disabled]:ps-pointer-events-none data-[disabled]:ps-opacity-50",e),...t,children:[R("span",{className:"ps-absolute ps-left-2 ps-flex ps-h-3.5 ps-w-3.5 ps-items-center ps-justify-center",children:R(i.ItemIndicator,{children:R($,{className:"ps-h-4 ps-w-4 ps-fill-current"})})}),a]}));Fa.displayName=i.RadioItem.displayName;var qa=V.forwardRef(({className:e,inset:a,...t},o)=>R(i.Label,{ref:o,className:l("ps-px-2 ps-py-1.5 ps-text-sm ps-font-semibold ps-text-foreground",a&&"ps-pl-8",e),...t}));qa.displayName=i.Label.displayName;var Ua=V.forwardRef(({className:e,...a},t)=>R(i.Separator,{ref:t,className:l("ps--mx-1 ps-my-1 ps-h-px ps-bg-border",e),...a}));Ua.displayName=i.Separator.displayName;var Ha=({className:e,...a})=>R("span",{className:l("ps-ml-auto ps-text-xs ps-tracking-widest ps-text-muted-foreground",e),...a});Ha.displayName="ContextMenuShortcut";import{jsx as Ue,jsxs as aa}from"react/jsx-runtime";var He=e=>{if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return String(e);if(e==null)return"";if(Oa(e)){let a=e.props;return e.type&&typeof e.type=="function"&&e.type.name==="RevealText"?a.text||"":e.type&&typeof e.type=="function"&&e.type.name==="NullValue"?"NULL":a.children?He(a.children):""}return Array.isArray(e)?e.map(He).join(""):""},ta=({children:e})=>aa(Ye,{children:[Ue(ea,{className:"ps-block ps-w-full ps-p-[var(--studio-cell-spacing)]",children:e}),Ue(Be,{children:aa(Fe,{onClick:()=>{let a=He(e);navigator.clipboard.writeText(a).catch(t=>{console.error("Failed to copy to clipboard:",t)})},className:"ps-flex ps-items-center ps-gap-2",children:[Ue(pe,{size:12}),"Copy"]})})]});import{jsx as Na}from"react/jsx-runtime";function oa(){return Na("code",{className:"ps-text-gray-500",children:"NULL"})}import{jsx as te,jsxs as za}from"react/jsx-runtime";function la({cell:e,getPinningStyles:a,dataType:t,isRelational:o,relatesTo:u,relationField:p}){let r=e.getValue(),f=r==null,x=C=>{if(C==null)return"NULL";if(typeof C=="object")try{return JSON.stringify(C,null,2)}catch(h){return console.error("Error stringifying value:",h),String(C)}return String(C)};return za(De,{children:[te(Te,{asChild:!0,children:te(de,{...a(e.column),"data-cell-type":"data","data-type":t.toLowerCase(),"data-relational":o?"true":void 0,"data-relates-to":u,"data-relation-field":p,className:l(a(e.column).className,"ps-p-0",e.column.getIsPinned()&&"ps-sticky"),children:te(ta,{children:f?te(oa,{}):x(r)})})}),te(Ae,{align:"start",alignOffset:0,sideOffset:0,className:"ps-min-w-(--radix-popover-trigger-width) ps-rounded-none ps-bg-muted ps-p-0",children:te(Ga,{value:x(r),theme:Ea,height:"100px",basicSetup:{lineNumbers:!0,foldGutter:!1,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!1},onChange:C=>{console.log("New value:",C)}})})]},e.id)}import{jsx as Va}from"react/jsx-runtime";function ua({cell:e,getPinningStyles:a,dataType:t}){let o={cell:e,getPinningStyles:a},u=e.column.columnDef.meta,p={...o,isRelational:u?.isRelational,relatesTo:u?.relatesTo,relationField:u?.relationField};return Va(la,{...p,dataType:t||"STRING"})}import{flexRender as at}from"@tanstack/react-table";import{Slot as Wa}from"@radix-ui/react-slot";import{cva as Xa}from"class-variance-authority";import*as da from"react";import{jsx as Za}from"react/jsx-runtime";var Ka=Xa("ps-inline-flex ps-items-center ps-justify-center ps-gap-2 ps-whitespace-nowrap ps-rounded-md ps-text-sm ps-font-medium ps-transition-colors focus-visible:ps-outline-none focus-visible:ps-ring-1 focus-visible:ps-ring-ring disabled:ps-pointer-events-none disabled:ps-opacity-50 [&_svg]:ps-pointer-events-none [&_svg]:ps-size-4 [&_svg]:ps-shrink-0",{variants:{variant:{default:"ps-bg-primary ps-text-primary-foreground ps-shadow hover:ps-bg-primary/90",destructive:"ps-bg-destructive ps-text-destructive-foreground ps-shadow-sm hover:ps-bg-destructive/90",outline:"ps-border ps-border-input ps-bg-background ps-shadow-sm hover:ps-bg-accent hover:ps-text-accent-foreground",secondary:"ps-bg-secondary ps-text-secondary-foreground ps-shadow-sm hover:ps-bg-secondary/80",ghost:"hover:ps-bg-accent hover:ps-text-accent-foreground",link:"ps-text-primary ps-underline-offset-4 hover:ps-underline"},size:{default:"ps-h-9 ps-px-4 ps-py-2",sm:"ps-h-8 ps-rounded-md ps-px-3 ps-text-xs",lg:"ps-h-10 ps-rounded-md ps-px-8",icon:"ps-h-9 ps-w-9"}},defaultVariants:{variant:"default",size:"default"}}),H=da.forwardRef(({className:e,variant:a,size:t,asChild:o=!1,...u},p)=>Za(o?Wa:"button",{className:l(Ka({variant:a,size:t,className:e})),ref:p,...u}));H.displayName="Button";import*as n from"@radix-ui/react-dropdown-menu";import*as W from"react";import{jsx as M,jsxs as Ne}from"react/jsx-runtime";var sa=n.Root,ra=n.Trigger;var Ja=W.forwardRef(({className:e,inset:a,children:t,...o},u)=>Ne(n.SubTrigger,{ref:u,className:l("ps-flex ps-cursor-default ps-select-none ps-items-center ps-gap-2 ps-rounded-sm ps-px-2 ps-py-1.5 ps-text-sm ps-outline-none focus:ps-bg-accent data-[state=open]:ps-bg-accent [&_svg]:ps-pointer-events-none [&_svg]:ps-size-4 [&_svg]:ps-shrink-0",a&&"ps-pl-8",e),...o,children:[t,M(z,{className:"ps-ml-auto"})]}));Ja.displayName=n.SubTrigger.displayName;var Qa=W.forwardRef(({className:e,...a},t)=>M(n.SubContent,{ref:t,className:l("ps-z-50 ps-min-w-[8rem] ps-overflow-hidden ps-rounded-md ps-border ps-bg-popover ps-p-1 ps-text-popover-foreground ps-shadow-lg data-[state=open]:ps-animate-in data-[state=closed]:ps-animate-out data-[state=closed]:ps-fade-out-0 data-[state=open]:ps-fade-in-0 data-[state=closed]:ps-zoom-out-95 data-[state=open]:ps-zoom-in-95 data-[side=bottom]:ps-slide-in-from-top-2 data-[side=left]:ps-slide-in-from-right-2 data-[side=right]:ps-slide-in-from-left-2 data-[side=top]:ps-slide-in-from-bottom-2 ps-origin-[--radix-dropdown-menu-content-transform-origin]",e),...a}));Qa.displayName=n.SubContent.displayName;var Oe=W.forwardRef(({className:e,sideOffset:a=4,...t},o)=>M(n.Portal,{children:M(n.Content,{ref:o,sideOffset:a,className:l("ps-z-50 ps-max-h-[var(--radix-dropdown-menu-content-available-height)] ps-min-w-[8rem] ps-overflow-y-auto ps-overflow-x-hidden ps-rounded-md ps-border ps-bg-popover ps-p-1 ps-text-popover-foreground ps-shadow-md","data-[state=open]:ps-animate-in data-[state=closed]:ps-animate-out data-[state=closed]:ps-fade-out-0 data-[state=open]:ps-fade-in-0 data-[state=closed]:ps-zoom-out-95 data-[state=open]:ps-zoom-in-95 data-[side=bottom]:ps-slide-in-from-top-2 data-[side=left]:ps-slide-in-from-right-2 data-[side=right]:ps-slide-in-from-left-2 data-[side=top]:ps-slide-in-from-bottom-2 ps-origin-[--radix-dropdown-menu-content-transform-origin]",e),...t})}));Oe.displayName=n.Content.displayName;var be=W.forwardRef(({className:e,inset:a,...t},o)=>M(n.Item,{ref:o,className:l("ps-relative ps-flex ps-cursor-default ps-select-none ps-items-center ps-gap-2 ps-rounded-sm ps-px-2 ps-py-1.5 ps-text-sm ps-outline-none ps-transition-colors focus:ps-bg-accent focus:ps-text-accent-foreground data-[disabled]:ps-pointer-events-none data-[disabled]:ps-opacity-50 [&>svg]:ps-size-4 [&>svg]:ps-shrink-0",a&&"ps-pl-8",e),...t}));be.displayName=n.Item.displayName;var _a=W.forwardRef(({className:e,children:a,checked:t,...o},u)=>Ne(n.CheckboxItem,{ref:u,className:l("ps-relative ps-flex ps-cursor-default ps-select-none ps-items-center ps-rounded-sm ps-py-1.5 ps-pl-8 ps-pr-2 ps-text-sm ps-outline-none ps-transition-colors focus:ps-bg-accent focus:ps-text-accent-foreground data-[disabled]:ps-pointer-events-none data-[disabled]:ps-opacity-50",e),checked:t,...o,children:[M("span",{className:"ps-absolute ps-left-2 ps-flex ps-h-3.5 ps-w-3.5 ps-items-center ps-justify-center",children:M(n.ItemIndicator,{children:M(G,{className:"ps-h-4 ps-w-4"})})}),a]}));_a.displayName=n.CheckboxItem.displayName;var ja=W.forwardRef(({className:e,children:a,...t},o)=>Ne(n.RadioItem,{ref:o,className:l("ps-relative ps-flex ps-cursor-default ps-select-none ps-items-center ps-rounded-sm ps-py-1.5 ps-pl-8 ps-pr-2 ps-text-sm ps-outline-none ps-transition-colors focus:ps-bg-accent focus:ps-text-accent-foreground data-[disabled]:ps-pointer-events-none data-[disabled]:ps-opacity-50",e),...t,children:[M("span",{className:"ps-absolute ps-left-2 ps-flex ps-h-3.5 ps-w-3.5 ps-items-center ps-justify-center",children:M(n.ItemIndicator,{children:M($,{className:"ps-h-2 ps-w-2 ps-fill-current"})})}),a]}));ja.displayName=n.RadioItem.displayName;var $a=W.forwardRef(({className:e,inset:a,...t},o)=>M(n.Label,{ref:o,className:l("ps-px-2 ps-py-1.5 ps-text-sm ps-font-semibold",a&&"ps-pl-8",e),...t}));$a.displayName=n.Label.displayName;var Ya=W.forwardRef(({className:e,...a},t)=>M(n.Separator,{ref:t,className:l("ps--mx-1 ps-my-1 ps-h-px ps-bg-muted",e),...a}));Ya.displayName=n.Separator.displayName;var et=({className:e,...a})=>M("span",{className:l("ps-ml-auto ps-text-xs ps-tracking-widest ps-opacity-60",e),...a});et.displayName="DropdownMenuShortcut";import{jsx as v,jsxs as Q}from"react/jsx-runtime";function Ee({header:e}){let a=e.column.columnDef.meta,t=a?.dataType,o=a?.isRelational;return Q("div",{className:"ps-flex ps-items-center ps-justify-between ps-w-full ps-h-full",children:[Q("div",{className:"ps-flex-1 ps-flex ps-items-center ps-justify-between",children:[o&&v(me,{size:14,className:"text-blue-700"}),Q("div",{className:"ps-align-text-bottom ps-leading-none ps-h-[20px]",children:[v("span",{className:"ps-inline-block ps-text-foreground ps-font-bold ps-text-sm",children:e.isPlaceholder?null:at(e.column.columnDef.header,e.getContext())}),t&&t!=="NONE"&&v("span",{className:"ps-inline-block ps-ml-2 ps-text-xs ps-font-mono ps-text-muted-foreground/70 ps-lowercase",children:t})]}),v("span",{className:"ps-flex ps-items-center ps-gap-1",children:e.column.getCanPin()&&e.column.id!=="select"&&Q(sa,{children:[v(ra,{asChild:!0,children:v(H,{variant:"ghost",size:"icon",children:v(J,{size:16})})}),Q(Oe,{children:[e.column.getCanSort()&&v(be,{onClick:()=>e.column.toggleSorting(e.column.getIsSorted()==="asc"),children:Q("span",{className:"ps-flex ps-items-center ps-gap-2",children:[e.column.getIsSorted()==="asc"?v(Z,{size:16}):v(re,{size:16}),e.column.getIsSorted()==="asc"?"Sort descending":"Sort ascending"]})}),v(be,{onClick:()=>e.column.pin(e.column.getIsPinned()?!1:"left"),children:e.column.getIsPinned()?Q("span",{className:"ps-flex ps-items-center ps-gap-2",children:[v(Le,{size:16}),"Unpin column"]}):Q("span",{className:"ps-flex ps-items-center ps-gap-2",children:[v(xe,{size:16}),"Pin column"]})})]})]})})]}),e.column.getCanResize()&&v("button",{type:"button",tabIndex:0,onMouseDown:u=>{u.stopPropagation(),e.getResizeHandler()(u)},onTouchStart:u=>{u.stopPropagation(),e.getResizeHandler()(u)},onClick:u=>u.stopPropagation(),onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),u.stopPropagation(),e.getResizeHandler()(u))},className:l("ps-absolute ps-right-0 ps-top-0 ps-h-full ps-w-3 ps-cursor-col-resize","ps-select-none ps-touch-none ps-transition-colors ps-group","ps-border-0 ps-bg-transparent",e.column.getIsResizing()&&"ps-bg-gray-300","before:ps-absolute before:ps-right-[3px] before:ps-top-1/2 before:ps--translate-y-1/2","after:ps-absolute after:ps-right-[7px] after:ps-top-1/2 after:ps--translate-y-1/2","before:ps-w-[2px] before:ps-h-0 before:ps-bg-gray-400 before:ps-rounded-full before:ps-opacity-0","after:ps-w-[2px] after:ps-h-0 after:ps-bg-gray-400 after:ps-rounded-full after:ps-opacity-0","before:ps-transition-all before:ps-duration-200","after:ps-transition-all after:ps-duration-200","group-hover:before:ps-opacity-100","group-hover:after:ps-opacity-100","group-hover:before:ps-h-4","group-hover:after:ps-h-4","group-active:ps-bg-transparent group-active:before:ps-bg-white group-active:after:ps-bg-white",e.column.getIsResizing()&&"before:ps-opacity-100"),"aria-label":"Resize column"})]})}import*as fa from"react";import{jsx as tt}from"react/jsx-runtime";var Ge=fa.forwardRef(({className:e,type:a,...t},o)=>tt("input",{type:a,className:l("ps-flex ps-h-9 ps-w-full ps-rounded-md ps-border ps-border-input ps-bg-transparent ps-px-3 ps-py-1 ps-text-base ps-shadow-sm ps-transition-colors file:ps-border-0 file:ps-bg-transparent file:ps-text-sm file:ps-font-medium file:ps-text-foreground placeholder:ps-text-muted-foreground focus-visible:ps-outline-none focus-visible:ps-ring-1 focus-visible:ps-ring-ring disabled:ps-cursor-not-allowed disabled:ps-opacity-50 md:ps-text-sm",e),ref:o,...t}));Ge.displayName="Input";import*as c from"@radix-ui/react-select";import*as _ from"react";import{jsx as P,jsxs as Xe}from"react/jsx-runtime";var ia=c.Root;var na=c.Value,ze=_.forwardRef(({className:e,children:a,...t},o)=>Xe(c.Trigger,{ref:o,className:l("ps-flex ps-h-9 ps-w-full ps-items-center ps-justify-between ps-whitespace-nowrap ps-rounded-md ps-border ps-border-input ps-bg-transparent ps-px-3 ps-py-2 ps-text-sm ps-shadow-sm ps-ring-offset-background data-[placeholder]:ps-text-muted-foreground focus:ps-outline-none focus:ps-ring-1 focus:ps-ring-ring disabled:ps-cursor-not-allowed disabled:ps-opacity-50 [&>span]:ps-line-clamp-1",e),...t,children:[a,P(c.Icon,{asChild:!0,children:P(ae,{className:"ps-h-4 ps-w-4 ps-opacity-50"})})]}));ze.displayName=c.Trigger.displayName;var ca=_.forwardRef(({className:e,...a},t)=>P(c.ScrollUpButton,{ref:t,className:l("ps-flex ps-cursor-default ps-items-center ps-justify-center ps-py-1",e),...a,children:P(ie,{className:"ps-h-4 ps-w-4"})}));ca.displayName=c.ScrollUpButton.displayName;var pa=_.forwardRef(({className:e,...a},t)=>P(c.ScrollDownButton,{ref:t,className:l("ps-flex ps-cursor-default ps-items-center ps-justify-center ps-py-1",e),...a,children:P(ae,{className:"ps-h-4 ps-w-4"})}));pa.displayName=c.ScrollDownButton.displayName;var Ve=_.forwardRef(({className:e,children:a,position:t="popper",...o},u)=>P(c.Portal,{children:Xe(c.Content,{ref:u,className:l("ps-relative ps-z-50 ps-max-h-[--radix-select-content-available-height] ps-min-w-[8rem] ps-overflow-y-auto ps-overflow-x-hidden ps-rounded-md ps-border ps-bg-popover ps-text-popover-foreground ps-shadow-md data-[state=open]:ps-animate-in data-[state=closed]:ps-animate-out data-[state=closed]:ps-fade-out-0 data-[state=open]:ps-fade-in-0 data-[state=closed]:ps-zoom-out-95 data-[state=open]:ps-zoom-in-95 data-[side=bottom]:ps-slide-in-from-top-2 data-[side=left]:ps-slide-in-from-right-2 data-[side=right]:ps-slide-in-from-left-2 data-[side=top]:ps-slide-in-from-bottom-2 ps-origin-[--radix-select-content-transform-origin]",t==="popper"&&"data-[side=bottom]:ps-translate-y-1 data-[side=left]:ps--translate-x-1 data-[side=right]:ps-translate-x-1 data-[side=top]:ps--translate-y-1",e),position:t,...o,children:[P(ca,{}),P(c.Viewport,{className:l("ps-p-1",t==="popper"&&"ps-h-[var(--radix-select-trigger-height)] ps-w-full ps-min-w-[var(--radix-select-trigger-width)]"),children:a}),P(pa,{})]})}));Ve.displayName=c.Content.displayName;var ot=_.forwardRef(({className:e,...a},t)=>P(c.Label,{ref:t,className:l("ps-px-2 ps-py-1.5 ps-text-sm ps-font-semibold",e),...a}));ot.displayName=c.Label.displayName;var We=_.forwardRef(({className:e,children:a,...t},o)=>Xe(c.Item,{ref:o,className:l("ps-relative ps-flex ps-w-full ps-cursor-default ps-select-none ps-items-center ps-rounded-sm ps-py-1.5 ps-pl-2 ps-pr-8 ps-text-sm ps-outline-none focus:ps-bg-accent focus:ps-text-accent-foreground data-[disabled]:ps-pointer-events-none data-[disabled]:ps-opacity-50",e),...t,children:[P("span",{className:"ps-absolute ps-right-2 ps-flex ps-h-3.5 ps-w-3.5 ps-items-center ps-justify-center",children:P(c.ItemIndicator,{children:P(G,{className:"ps-h-4 ps-w-4"})})}),P(c.ItemText,{children:a})]}));We.displayName=c.Item.displayName;var lt=_.forwardRef(({className:e,...a},t)=>P(c.Separator,{ref:t,className:l("ps--mx-1 ps-my-1 ps-h-px ps-bg-muted",e),...a}));lt.displayName=c.Separator.displayName;import{jsx as k,jsxs as Y}from"react/jsx-runtime";var ut=[10,20,50,100];function ma({table:e,variant:a="basic",className:t}){let{pageSize:o,pageIndex:u}=e.getState().pagination,p=e.getPageCount();return k("div",{className:l("ps-flex ps-items-center ps-justify-between ps-space-x-2 ps-py-4 ps-px-4",t),children:a==="basic"?Y("div",{className:"ps-flex ps-items-center ps-space-x-2",children:[k(H,{variant:"outline",size:"sm",className:"ps-h-9",onClick:()=>e.previousPage(),disabled:!e.getCanPreviousPage(),children:"Previous"}),k(H,{variant:"outline",size:"sm",className:"ps-h-9",onClick:()=>e.nextPage(),disabled:!e.getCanNextPage(),children:"Next"})]}):Y("div",{className:"ps-flex ps-items-center ps-space-x-2",children:[Y("div",{className:"ps-flex ps-items-center ps-space-x-2",children:[k(H,{variant:"outline",onClick:()=>e.setPageIndex(0),disabled:!e.getCanPreviousPage(),children:k(ne,{className:"ps-w-4 ps-h-4"})}),k(H,{variant:"outline",onClick:()=>e.previousPage(),disabled:!e.getCanPreviousPage(),children:k(fe,{className:"ps-w-4 ps-h-4"})}),Y("div",{className:"ps-flex ps-items-center ps-gap-1 ps-text-xs ps-font-medium",children:["Page",k(Ge,{type:"number",min:1,max:p,value:u+1,className:"ps-w-12",onChange:r=>{let f=r.target.value?Number(r.target.value)-1:0;e.setPageIndex(f)}}),Y("span",{className:"ps-shrink-0 ps-w-max",children:["of ",p]})]}),k(H,{variant:"outline",onClick:()=>e.nextPage(),disabled:!e.getCanNextPage(),children:k(z,{className:"ps-w-4 ps-h-4"})}),k(H,{variant:"outline",onClick:()=>e.setPageIndex(p-1),disabled:!e.getCanNextPage(),children:k(ce,{className:"ps-w-4 ps-h-4"})})]}),Y(ia,{value:o.toString(),onValueChange:r=>e.setPageSize(Number(r)),children:[k(ze,{children:k(na,{})}),k(Ve,{children:ut.map(r=>Y(We,{value:r.toString(),children:[r," per page"]},r))})]})]})})}var Ie=e=>{let a=e.getIsPinned(),t=a==="left"&&e.getIsLastColumn("left"),o=a==="right"&&e.getIsFirstColumn("right");return{className:l("ps-overflow-hidden ps-whitespace-nowrap ps-text-ellipsis",a&&["ps-sticky ps-bg-background ps-shadow-[1px_0_0_0_hsl(var(--border))]",a==="left"?"ps-left-0":"ps-right-0","ps-z-20"],!a&&"ps-relative ps-z-10",t&&"ps-shadow-[1px_0_0_0_hsl(var(--border))]",o&&"ps-shadow-[-1px_0_0_0_hsl(var(--border))]"),style:{width:e.getSize(),left:a==="left"?`${e.getStart("left")}px`:void 0,right:a==="right"?`${e.getAfter("right")}px`:void 0}}};import{Fragment as wt,jsx as L,jsxs as Ce}from"react/jsx-runtime";var St=({_table:e})=>{let{currentTable:a,isLoaded:t}=Pe();return t?L("div",{className:"ps-flex ps-items-center ps-justify-between ps-w-full ps-gap-2",children:L("div",{className:"ps-flex ps-items-center ps-gap-2",children:L("span",{className:"ps-flex ps-items-center ps-gap-2",children:L("h1",{className:"ps-text-sm ps-font-medium",children:a?.name})})})}):null},Pt=({header:e,children:a,getPinningStyles:t})=>{let{attributes:o,listeners:u,transform:p,transition:r,setNodeRef:f,isDragging:x,isOver:C}=ct({id:e.id}),h=e.column.columnDef.meta,S={transform:pt.Transform.toString(p),transition:r,...t(e.column).style,cursor:"grab",touchAction:"none"};return Ce(we,{ref:f,...o,...u,style:S,"data-relational":h?.isRelational?"true":void 0,"data-relates-to":h?.relatesTo,"data-relation-field":h?.relationField,className:l("ps-group",t(e.column).className,x&&"ps-opacity-50",C&&"ps-bg-gray-100","ps-select-none ps-touch-none ps-relative",e.column.getIsPinned()&&"ps-sticky"),children:[a,C&&L("div",{className:"ps-absolute ps-inset-0 ps-border-2 ps-border-primary ps-rounded-sm ps-pointer-events-none"})]})};function La({data:e=[],columns:a}){console.log("Data received in StudioGrid:",e);let[t,o]=oe([]),[u,p]=oe([]),[r,f]=oe({}),[x,C]=oe({left:[],right:[]}),[h,S]=oe([]),[le,F]=oe("");gt(()=>{if(a&&a.length>0){let I=a.map(B=>B.id);if(h.length===0){S(I);return}let d=[...h],g=d.filter(B=>!a.some(U=>U.id===B));g.forEach(B=>{let U=d.indexOf(B);U!==-1&&d.splice(U,1)});let D=I.filter(B=>!d.includes(B));D.length>0&&d.push(...D),(g.length>0||D.length>0)&&S(d)}},[a,h]);let y=rt(st,{activationConstraint:{distance:10}}),T=ft(y),A=I=>{let{active:d,over:g}=I;if(g&&d.id!==g.id){let D=w.getColumn(d.id),B=w.getColumn(g.id);if(!D||!B)return;let U=D.getIsPinned(),ee=B.getIsPinned();if(U!==ee)return;let he=h.indexOf(d.id),Se=h.indexOf(g.id);if(he===-1||Se===-1)return;let Re=[...h];Re.splice(he,1),Re.splice(Se,0,d.id),S(Re)}},q=ht(()=>{if(!a||a.length===0)return console.log("No columns configuration available"),[];let I=(d,g)=>{if(d==null)return"";switch(g){case"TIMESTAMP":return d?new Date(d).toLocaleString():"";case"UUID":case"STRING":return String(d);default:return String(d)}};return a.map(d=>({accessorKey:d.id,header:()=>L("div",{className:"ps-font-medium",children:d.id}),cell:({getValue:g})=>I(g(),d.type),meta:{dataType:d.type,isRelational:d.isRelational,relatesTo:d.relatesTo,relationField:d.relationField}}))},[a]),w=Ct({data:e||[],defaultColumn:{size:200,minSize:50,maxSize:500},columns:q,getCoreRowModel:mt(),onSortingChange:o,getSortedRowModel:It(),getPaginationRowModel:xt(),getFilteredRowModel:Lt(),onColumnFiltersChange:p,enableColumnResizing:!0,columnResizeMode:"onChange",onColumnSizingChange:f,enableColumnPinning:!0,onColumnPinningChange:C,onGlobalFilterChange:F,globalFilterFn:(I,d,g)=>{let D=I.getValue(d);return D==null?!1:String(D).toLowerCase().includes(String(g).toLowerCase())},state:{sorting:t,columnFilters:u,columnSizing:r,columnPinning:x,columnOrder:h,globalFilter:le}});return!e||e.length===0?Ce("div",{className:"ps-p-4 ps-border ps-rounded-md ps-w-full",children:[L("p",{className:"ps-text-lg ps-font-semibold",children:"No data available."}),L("p",{className:"ps-text-sm ps-text-gray-500",children:e?"Data array is empty.":"Data is undefined."})]}):Ce(wt,{children:[L("div",{className:"ps-bg-studio-header-background ps-flex ps-w-full ps-p-2 ps-py-3 ps-border-b",children:L(St,{_table:w})}),L("div",{"data-studio":"content",className:"ps-flex-1 ps-w-0 ps-h-0 ps-min-w-full",children:Ce("div",{className:"ps-flex ps-flex-col ps-w-full ps-h-full ps-overflow-scroll",children:[L(dt,{sensors:T,onDragEnd:A,children:Ce(Me,{children:[L(ve,{children:w.getHeaderGroups().map(I=>L(ue,{className:l("ps-relative",w.getLeftLeafHeaders().some(d=>d.column.getIsPinned()==="left")&&`ps-pl-[${w.getLeftLeafHeaders().filter(d=>d.column.getIsPinned()==="left").reduce((d,g)=>d+g.getSize(),0)}px]`),children:L(nt,{items:I.headers.map(d=>d.id),strategy:it,children:I.headers.map(d=>d.column.id==="select"?L(we,{className:l("ps-px-[var(--studio-cell-spacing)]",Ie(d.column).className,d.column.getIsPinned()&&"ps-sticky"),style:Ie(d.column).style,"data-cell-type":"select",children:L(Ee,{header:d})},d.id):L(Pt,{header:d,table:w,getPinningStyles:Ie,children:L(Ee,{header:d})},d.id))})},I.id))}),L(ye,{children:w.getRowModel().rows?.length?w.getRowModel().rows.map(I=>L(ue,{className:l("ps-bg-table-row ps-odd:bg-table-row-odd ps-group"),children:I.getVisibleCells().map(d=>L(ua,{cell:d,getPinningStyles:Ie,dataType:a.find(g=>g.id===d.column.id)?.type},d.id))},I.id)):L(ue,{children:L(de,{colSpan:a.length,className:"ps-h-24 ps-text-center",children:"No results."})})})]})}),L(ma,{table:w,variant:"numeric"})]})})]})}import{createContext as kt,useContext as dd,useEffect as bt,useState as Rt}from"react";import{jsx as yt}from"react/jsx-runtime";var Mt={theme:"system",setTheme:()=>null},vt=kt(Mt);function xa({children:e,defaultTheme:a="system",storageKey:t="vite-ui-theme",...o}){let[u,p]=Rt(()=>localStorage.getItem(t)||a);bt(()=>{let f=window.document.documentElement;if(f.classList.remove("light","dark"),u==="system"){let x=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";f.classList.add(x);return}f.classList.add(u)},[u]);let r={theme:u,setTheme:f=>{localStorage.setItem(t,f),p(f)}};return yt(vt.Provider,{...o,value:r,children:e})}import{jsx as X,jsxs as Ht}from"react/jsx-runtime";var Ca=At(void 0),Pe=()=>{let e=Bt(Ca);if(!e)throw new Error("useStudio must be used within a Studio.Provider");return e},Ft={integer:"INTEGER",varchar:"VARCHAR",text:"TEXT",enum:"STRING",boolean:"BOOLEAN"};function qt(e,a){return{id:e,accessorKey:e,header:e.charAt(0).toUpperCase()+e.slice(1),type:Ft[a.dataType.name]||"STRING",nullable:a.nullable,isKey:a.partOfPk}}var Ut=({adapter:e})=>{let[a,t]=ge([]),[o,u]=ge(null),[p,r]=ge(!1),[f,x]=ge([]),[C,h]=ge([]),S=Tt.useMemo(()=>new Set(a.filter(F=>F.isFavorite).map(F=>F.id)),[a]),le=F=>{t(y=>y.map(T=>T.id===F?{...T,isFavorite:!T.isFavorite}:T))};return Ia(()=>{(async()=>{try{let[y,T]=await e.introspect();if(y||!T?.schemas){console.error("Error fetching schema:",y);return}let A=Object.entries(T.schemas).flatMap(([q,w])=>Object.entries(w.tables).map(([I])=>({id:`${q}.${I}`,name:I.charAt(0).toUpperCase()+I.slice(1),schema:q,isFavorite:!1})));t(A),!o&&A.length>0&&A[0]&&u(A[0])}catch(y){console.error("Error fetching tables:",y)}})()},[e,o]),Ia(()=>{(async()=>{if(!o?.id){r(!0);return}try{r(!1);let[y,T]=await e.introspect();if(y||!T?.schemas){console.error("Error fetching schema:",y),r(!0);return}let[A,q]=o.id.split(".");if(!A||!q){console.error("Invalid table ID format:",o.id),r(!0);return}let w=T.schemas[A];if(!w){console.error(`Schema ${A} not found`),r(!0);return}let I=w.tables[q];if(!I){console.error(`Table ${q} not found in schema ${A}`),r(!0);return}let d=Object.entries(I.columns).map(([U,ee])=>qt(U,ee));h(d);let[g,D]=await e.query({schema:A,table:q,filters:[],sortings:[]});if(g||!D){console.error(`Failed to fetch data for table ${q}:`,g),r(!0);return}let B=D.rows.map(U=>{let ee={};return Object.entries(U).forEach(([he,Se])=>{ee[he]=Se.value}),ee});x(B),r(!0)}catch(y){console.error("Error fetching table data:",y),r(!0)}})()},[e,o]),e?!p&&a.length===0?X("div",{children:"Loading available tables..."}):p&&a.length===0?X("div",{children:"No tables found in the database."}):X(xa,{children:X(Dt,{children:X(Ca.Provider,{value:{adapter:e,currentTable:o,isLoaded:p,tables:a,favoriteTableIds:S,setCurrentTable:u,toggleFavorite:le},children:Ht("div",{className:"ps-flex ps-gap-4 ps-w-full ps-rounded-sm ps-bg-background ps-p-4 ps-relative",children:[X(Ke,{}),X("div",{className:"ps-flex ps-w-full ps-flex-col ps-border ps-rounded-lg",children:X(La,{columns:C,data:f})})]})})})}):(console.error("No adapter provided to Studio component"),X("div",{children:"Error: No adapter provided"}))},ga=Ut;export{ga as Studio};
2
2
  /*! Bundled license information:
3
3
 
4
4
  lucide-react/dist/esm/shared/src/utils.js:
@@ -153,14 +153,6 @@ lucide-react/dist/esm/icons/pin.js:
153
153
  * See the LICENSE file in the root directory of this source tree.
154
154
  *)
155
155
 
156
- lucide-react/dist/esm/icons/star.js:
157
- (**
158
- * @license lucide-react v0.427.0 - ISC
159
- *
160
- * This source code is licensed under the ISC license.
161
- * See the LICENSE file in the root directory of this source tree.
162
- *)
163
-
164
156
  lucide-react/dist/esm/lucide-react.js:
165
157
  (**
166
158
  * @license lucide-react v0.427.0 - ISC
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/studio-core",
3
- "version": "0.0.0-dev.202503281130",
3
+ "version": "0.0.0-dev.202503281209",
4
4
  "description": "Modular Prisma Studio components",
5
5
  "type": "module",
6
6
  "sideEffects": false,