@dudousxd/nestjs-catalog-dashboard 0.7.1 → 0.7.2

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.
@@ -584,7 +584,7 @@ return [{
584
584
  { "tag": "AF93E00073", "risk": "88", "kind": "truck" },
585
585
  { "tag": "AF00D00169", "risk": "12", "kind": "sedan" }
586
586
  ]`;function sLe({result:e,error:t}){return x.jsxs("div",{className:"max-h-64 overflow-auto p-3",children:[t?x.jsx("p",{className:"font-mono text-[11px] leading-relaxed text-red-600",children:t instanceof Error?t.message:"It failed."}):null,e&&x.jsxs(x.Fragment,{children:[e.logs.length>0&&x.jsx("pre",{className:G("mb-2 whitespace-pre-wrap font-mono text-[10px]",wl),children:e.logs.join(`
587
- `)}),e.rows.length===0?x.jsx("p",{className:"text-[11px] text-amber-600",children:"It ran and returned no rows. A connector using this would commit an empty snapshot."}):x.jsx("pre",{className:"whitespace-pre-wrap font-mono text-[11px]",children:JSON.stringify(e.rows,null,2)}),x.jsxs("p",{className:G("mt-2 font-mono text-[10px]",wl),children:[e.rows.length," rows · ",e.elapsedMs,"ms"]})]}),!e&&!t&&x.jsx("p",{className:G("py-4 text-center text-[11px]",wl),children:"Run it to see what it produces."})]})}function aLe({transform:e,nameIsEmpty:t,pending:n,error:r,onSave:i}){return x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("button",{type:"button",onClick:i,disabled:n||t,className:G("rounded-md border px-3 py-1.5 text-xs disabled:opacity-40",Nf,"hover:bg-zinc-50 dark:hover:bg-zinc-800"),children:n?"Saving…":e?"Save changes":"Save transform"}),e&&x.jsxs("span",{className:G("font-mono text-[10px]",wl),children:["saving new code makes this v",e.version+1]}),r?x.jsx("span",{className:"text-[11px] text-red-600",children:r instanceof Error?r.message:"Could not save."}):null]})}function mse({transform:e,languages:t,pythonPackages:n=[],onClose:r,onSaved:i}){const o=br(),[s,a]=A.useState((e==null?void 0:e.name)??""),[l,u]=A.useState((e==null?void 0:e.description)??""),[f,d]=A.useState((e==null?void 0:e.language)??t[0]??"javascript"),[p,m]=A.useState((e==null?void 0:e.code)??sO[(e==null?void 0:e.language)??"javascript"]),[g,b]=A.useState(oLe),v=A.useRef(null),w=Un({mutationFn:()=>{let C;try{const T=JSON.parse(g);C=Array.isArray(T)?T:[T]}catch{throw new Error("The sample is not valid JSON.")}return o.tryTransform({language:f,code:p,records:C})}}),k=Un({mutationFn:()=>o.saveTransform({id:e==null?void 0:e.id,name:s.trim(),language:f,code:p,description:l.trim()||void 0}),onSuccess:i});function E(C){(C.metaKey||C.ctrlKey)&&C.key==="Enter"&&(C.preventDefault(),w.mutate())}return x.jsxs("div",{className:"mt-6 space-y-3",children:[x.jsxs("button",{type:"button",onClick:r,className:G("flex items-center gap-1.5 font-mono text-[11px] uppercase tracking-[0.14em]",wl,"hover:text-zinc-950 dark:hover:text-zinc-50"),children:[x.jsx(YQ,{size:12}),"Transforms"]}),x.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[x.jsx(an,{label:"Name",value:s,onChange:a,placeholder:"Fleet rows"}),x.jsx(an,{label:"Description",value:l,onChange:u,placeholder:"What it does (optional)"}),x.jsx(Fi,{label:"Language",ariaLabel:"Language",value:f,onValueChange:C=>{jn.isTransformLanguage(C)&&(d(C),Object.values(sO).includes(p)&&m(sO[C]))},options:t.map(C=>({value:C,label:C}))})]}),x.jsxs("div",{className:"grid gap-3 lg:grid-cols-2",children:[x.jsxs("div",{className:G("overflow-hidden rounded-lg border",Nf,oO),children:[x.jsxs("div",{className:G("flex items-center justify-between border-b px-3 py-1.5",Nf),children:[x.jsx("span",{className:G("font-mono text-[10px] uppercase tracking-[0.14em]",wl),children:"Code"}),x.jsx("span",{className:G("font-mono text-[10px]",wl),children:f==="python"&&n.length>0?`imports: ${n.join(", ")}`:"⌘↵ to try"})]}),x.jsx(pj,{value:p,onChange:m,onKeyDown:E,language:f==="python"?"python":"tsx",label:"Transform code",textareaRef:v,className:"h-72"})]}),x.jsxs("div",{className:"space-y-3",children:[x.jsxs("div",{className:G("overflow-hidden rounded-lg border",Nf,oO),children:[x.jsx("div",{className:G("border-b px-3 py-1.5",Nf),children:x.jsx("span",{className:G("font-mono text-[10px] uppercase tracking-[0.14em]",wl),children:"Sample records"})}),x.jsx(pj,{value:g,onChange:b,language:"json",label:"Sample records",className:"h-32"})]}),x.jsxs("button",{type:"button",onClick:()=>w.mutate(),disabled:w.isPending,className:"flex items-center gap-1.5 rounded-md bg-zinc-950 px-3 py-1.5 text-xs text-zinc-50 disabled:opacity-40 dark:bg-zinc-100 dark:text-zinc-950",children:[x.jsx(Qb,{size:12}),w.isPending?"Running…":"Try it"]}),x.jsxs("div",{className:G("overflow-hidden rounded-lg border",Nf,oO),children:[x.jsx("div",{className:G("border-b px-3 py-1.5",Nf),children:x.jsx("span",{className:G("font-mono text-[10px] uppercase tracking-[0.14em]",wl),children:"Output"})}),x.jsx(sLe,{result:w.data,error:w.error})]})]})]}),x.jsx(aLe,{transform:e,nameIsEmpty:s.trim().length===0,pending:k.isPending,error:k.error,onSave:()=>k.mutate()})]})}const BV="text-zinc-400 dark:text-zinc-500";function sy(e){return jn.CONNECTOR_KINDS.find(t=>t===e)??"http"}function uk(e){return e==="sql"||e==="s3"}function gse(e){return e==="http"||e==="sql"||e==="s3"}const yse=[{value:"http",label:"HTTP — a JSON endpoint"},{value:"sql",label:"SQL — a database query"},{value:"file",label:"File — CSV, NDJSON or JSON"},{value:"s3",label:"S3 — a bucket prefix"},{value:"inline",label:"Inline — records pasted below"}],VV=[{value:"",label:"Format from the extension"},{value:"csv",label:"CSV"},{value:"ndjson",label:"NDJSON"},{value:"json",label:"JSON"}],Sl="";function bse(e){const t=e??{},n=i=>{const o=t[i];return typeof o=="string"?o:""},r=t.records;return{url:n("url"),path:n("path"),query:n("query"),format:n("format"),records:Array.isArray(r)&&r.length>0?JSON.stringify(r,null,2):"",bucket:n("bucket"),prefix:n("prefix"),suffix:n("suffix"),endpoint:n("endpoint"),region:n("region"),forcePathStyle:t.forcePathStyle===!0,maxObjectsPerRun:typeof t.maxObjectsPerRun=="number"?String(t.maxObjectsPerRun):"",watermarkColumn:n("watermarkColumn")}}function $6(e){const t=e.trim();if(t.length===0)return{ok:!0,records:[]};try{const n=JSON.parse(t);return Array.isArray(n)?{ok:!0,records:n}:{ok:!1,message:"Inline records have to be a JSON array. A single object is one record, so wrap it in [ ]."}}catch(n){return{ok:!1,message:`That is not valid JSON: ${n instanceof Error?n.message:"it could not be parsed"}.`}}}function lLe(e,t){return{...t?{}:{url:e.url},...e.path?{path:e.path}:{}}}function uLe(e,t,n){return{query:e.query,...t||!e.url?{}:{url:e.url},...n&&e.watermarkColumn?{watermarkColumn:e.watermarkColumn}:{}}}function cLe(e){return{path:e.path||e.url,...e.format?{format:e.format}:{}}}function fLe(e,t){return{...t?{}:{bucket:e.bucket,...e.endpoint?{endpoint:e.endpoint}:{},...e.region?{region:e.region}:{},...e.forcePathStyle?{forcePathStyle:!0}:{}},...e.prefix?{prefix:e.prefix}:{},...e.suffix?{suffix:e.suffix}:{},...e.format?{format:e.format}:{},...e.maxObjectsPerRun?{maxObjectsPerRun:Number(e.maxObjectsPerRun)}:{}}}function dLe(e){const t=$6(e.records);return{records:t.ok?t.records:[]}}function vse(e,t,{viaConnection:n,incremental:r}){return e==="http"?lLe(t,n):e==="sql"?uLe(t,n,r):e==="file"?cLe(t):e==="s3"?fLe(t,n):dLe(t)}function hLe(e,t,n){return e==="s3"&&!n?t.bucket.trim().length===0:e==="http"&&!n?t.url.trim().length===0:!1}function pLe(e,t){return t.filter(n=>n.kind===e).map(n=>({value:n.id,label:n.name}))}function xse({kind:e,draft:t,onChange:n,viaConnection:r,disabled:i}){const o=a=>n({...t,...a});if(e==="http")return x.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[!r&&x.jsx(an,{label:"URL",value:t.url,onChange:a=>o({url:a}),placeholder:"https://…",disabled:i}),x.jsx(an,{label:"Path to the array",value:t.path,onChange:a=>o({path:a}),placeholder:"e.g. data",disabled:i})]});if(e==="sql")return x.jsxs("div",{className:"space-y-3",children:[x.jsx(jV,{label:"Query",value:t.query,onChange:a=>o({query:a}),placeholder:"SELECT … FROM …",mono:!0,disabled:i,hint:"Runs inside a read-only transaction, so the database refuses a write whatever the statement parses as."}),!r&&x.jsx(an,{label:"URL (optional)",value:t.url,onChange:a=>o({url:a}),placeholder:"Prefer naming the environment variable below",disabled:i})]});if(e==="file")return x.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[x.jsx(an,{label:"File path or URL",value:t.path,onChange:a=>o({path:a}),placeholder:"/data/drop.csv or https://…",disabled:i}),x.jsx(Fi,{label:"Format",ariaLabel:"Format",value:t.format,onValueChange:a=>o({format:a}),options:VV,disabled:i})]});if(e==="s3")return x.jsxs("div",{className:"space-y-3",children:[!r&&x.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[x.jsx(an,{label:"Bucket",value:t.bucket,onChange:a=>o({bucket:a}),placeholder:"fleet-drops",disabled:i}),x.jsx(an,{label:"Region",value:t.region,onChange:a=>o({region:a}),placeholder:"Blank uses the environment's",disabled:i}),x.jsx(an,{label:"Endpoint",value:t.endpoint,onChange:a=>o({endpoint:a}),placeholder:"MinIO, e.g. http://localhost:9000",disabled:i})]}),x.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[x.jsx(an,{label:"Prefix",value:t.prefix,onChange:a=>o({prefix:a}),placeholder:"drops/mvr/",disabled:i}),x.jsx(an,{label:"Only keys ending in",value:t.suffix,onChange:a=>o({suffix:a}),placeholder:".csv",disabled:i}),x.jsx(an,{label:"Max objects per run",value:t.maxObjectsPerRun,onChange:a=>o({maxObjectsPerRun:a}),inputMode:"numeric",disabled:i})]}),x.jsx(Fi,{label:"Format",ariaLabel:"Format",value:t.format,onValueChange:a=>o({format:a}),options:[{value:"",label:"Format from each key"},...VV.slice(1)],disabled:i}),!r&&x.jsx(z6,{checked:t.forcePathStyle,onCheckedChange:a=>o({forcePathStyle:a}),label:"Path-style addressing",hint:"MinIO needs it; AWS does not."})]});const s=$6(t.records);return x.jsx(jV,{label:"Records",value:t.records,onChange:a=>o({records:a}),placeholder:'[{ "tag": "AF93E00073" }]',mono:!0,rows:5,disabled:i,hint:s.ok?void 0:x.jsx("span",{className:"text-red-600 dark:text-red-400",children:s.message})})}function wse({kind:e,mode:t,onModeChange:n,draft:r,onChange:i,disabled:o}){return uk(e)?x.jsxs(R6,{title:"Read mode",children:[x.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[x.jsx(Fi,{label:"Mode",ariaLabel:"Read mode",value:t,onValueChange:s=>n(s==="incremental"?"incremental":"full"),options:[{value:"full",label:"Full — read everything, every run"},{value:"incremental",label:"Incremental — only what changed"}],disabled:o}),e==="sql"&&t==="incremental"&&x.jsx(an,{label:"Watermark column",value:r.watermarkColumn,onChange:s=>i({...r,watermarkColumn:s}),placeholder:"updated_at",disabled:o})]}),e==="sql"&&t==="incremental"&&x.jsxs("p",{className:G("text-[11px] leading-relaxed",BV),children:["The query is wrapped as"," ",x.jsx("span",{className:"font-mono",children:"SELECT * FROM (your query) WHERE column > ?"})," with the value bound, never pasted in. Two things follow from wrapping: the column has to be in what your query selects, and a query with its own LIMIT or GROUP BY is filtered after that step. Leave the column blank and this reads everything."]}),e==="s3"&&t==="incremental"&&x.jsx("p",{className:G("text-[11px] leading-relaxed",BV),children:"Each run remembers the newest LastModified it read and the keys sitting at exactly that timestamp, so objects written in the same second are neither skipped nor read twice. Objects rewritten in place under a key already read are not picked up again."})]}):null}function Sse({kind:e,value:t,onChange:n,disabled:r}){return x.jsx(an,{label:"Credential env var",value:t,onChange:n,placeholder:e==="sql"?"Env var holding the connection URL":e==="s3"?"accessKeyId:secretAccessKey (optional)":"Optional",disabled:r,hint:"The credential is read from the environment by name at run time. Only the variable name is stored."})}const kse=A.createContext(void 0);function F6(){const e=A.useContext(kse);if(e===void 0)throw new Error(yi(64));return e}let mLe=function(e){return e.activationDirection="data-activation-direction",e.orientation="data-orientation",e}({});const _E={tabActivationDirection:e=>({[mLe.activationDirection]:e})},gLe=A.forwardRef(function(t,n){const{className:r,defaultValue:i=0,onValueChange:o,orientation:s="horizontal",render:a,value:l,style:u,...f}=t,d=t.defaultValue!==void 0,p=A.useRef([]),[m,g]=A.useState(()=>new Map),[b,v]=ak({controlled:l,default:i,name:"Tabs",state:"value"}),w=l!==void 0,[k,E]=A.useState(()=>new Map),C=A.useRef(void 0),T=A.useCallback(Q=>{if(Q===void 0)return null;for(const[oe,ce]of k.entries())if(ce!=null&&Q===(ce.value??ce.index))return oe;return null},[k]),[_,M]=A.useState(()=>({previousValue:b,tabActivationDirection:"none"})),{previousValue:R,tabActivationDirection:N}=_;let P=N,L=!1;R!==b&&(P=qV(R,b,s,k),L=R!=null&&b!=null&&T(b)==null);const B=L?R:b,z=R!==B||N!==P;$e(()=>{z&&M({previousValue:B,tabActivationDirection:P})},[B,z,P]);const j=We((Q,oe)=>{const ce=qV(b,Q,s,k);oe.activationDirection=ce,o==null||o(Q,oe),!oe.isCanceled&&v(Q)}),$=We((Q,oe)=>{o==null||o(Q,Ot(oe,void 0,void 0,{activationDirection:"none"}))}),I=We((Q,oe)=>{g(ce=>{if(ce.get(Q)===oe)return ce;const Z=new Map(ce);return Z.set(Q,oe),Z})}),F=We((Q,oe)=>{g(ce=>{if(!ce.has(Q)||ce.get(Q)!==oe)return ce;const Z=new Map(ce);return Z.delete(Q),Z})}),V=A.useCallback(Q=>m.get(Q),[m]),U=A.useCallback(Q=>{for(const oe of k.values())if(Q===(oe==null?void 0:oe.value))return oe==null?void 0:oe.id},[k]),K=A.useMemo(()=>({getTabElementBySelectedValue:T,getTabIdByPanelValue:U,getTabPanelIdByValue:V,onValueChange:j,orientation:s,registerMountedTabPanel:I,setTabMap:E,unregisterMountedTabPanel:F,tabActivationDirection:P,value:b}),[T,U,V,j,s,I,E,F,P,b]),q=A.useMemo(()=>{for(const Q of k.values())if(Q!=null&&Q.value===b)return Q},[k,b]),W=A.useMemo(()=>{for(const Q of k.values())if(Q!=null&&!Q.disabled)return Q.value},[k]),Y=A.useRef(!d),J=A.useRef(i),ne=A.useRef(d),ie=A.useRef(!1);$e(()=>{var de;if(w)return;function Q(se,me){v(se),M(ke=>ke.previousValue===se&&ke.tabActivationDirection==="none"?ke:{previousValue:se,tabActivationDirection:"none"}),$(se,me),Y.current=!1}if(k.size===0){ie.current&&b!==null&&!((de=C.current)!=null&&de.isConnected)&&Q(null,A7);return}ie.current=!0,C.current=k.keys().next().value;const oe=q==null?void 0:q.disabled,ce=q==null&&b!==null;if(!oe&&b===J.current&&(ne.current=!1),ne.current&&oe&&b===J.current)return;const Z=Y.current;if(oe||ce){const se=W??null;if(b===se){Y.current=!1;return}let me=A7;Z?me=T7:oe&&(me=Ure),Q(se,me);return}Z&&q!=null&&($(b,T7),Y.current=!1)},[W,w,$,q,v,k,b]);const ee=Qn("div",t,{state:{orientation:s,tabActivationDirection:P},ref:n,props:f,stateAttributesMapping:_E});return x.jsx(kse.Provider,{value:K,children:x.jsx(P6,{elementsRef:p,children:ee})})});function qV(e,t,n,r){if(e==null||t==null)return"none";let i=null,o=null;for(const[l,u]of r.entries()){if(u==null)continue;const f=u.value??u.index;if(e===f&&(i=l),t===f&&(o=l),i!=null&&o!=null)break}if(i==null||o==null)return i!==o&&(typeof e=="number"||typeof e=="string")&&typeof e==typeof t?n==="horizontal"?t>e?"right":"left":t>e?"down":"up":"none";const s=i.getBoundingClientRect(),a=o.getBoundingClientRect();if(n==="horizontal"){if(a.left<s.left)return"left";if(a.left>s.left)return"right"}else{if(a.top<s.top)return"up";if(a.top>s.top)return"down"}return"none"}const Ese="data-composite-item-active";function yLe(e={}){const{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=Roe(),{ref:i,index:o}=I6(e),s=n===o,a=A.useRef(null),l=$c(i,a);return{compositeProps:{tabIndex:s?0:-1,onFocus(){r(o)},onMouseMove(){const f=a.current;if(!t||!f)return;const d=f.hasAttribute("disabled")||f.ariaDisabled==="true";!s&&!d&&f.focus()}},compositeRef:l,index:o}}const Cse=A.createContext(void 0);function bLe(){const e=A.useContext(Cse);if(e===void 0)throw new Error(yi(65));return e}const vLe=A.forwardRef(function(t,n){const{className:r,disabled:i=!1,render:o,value:s,id:a,nativeButton:l=!0,style:u,...f}=t,{value:d,getTabPanelIdByValue:p,orientation:m,tabActivationDirection:g}=F6(),{activateOnFocus:b,highlightedTabIndex:v,onTabActivation:w,registerTabResizeObserverElement:k,setHighlightedTabIndex:E,tabsListElement:C}=bLe(),T=Zc(a),_=A.useMemo(()=>({disabled:i,id:T,value:s}),[i,T,s]),{compositeProps:M,compositeRef:R,index:N}=yLe({metadata:_}),P=s===d,L=A.useRef(!1),B=A.useRef(null);$e(()=>{const Y=B.current;if(Y)return k(Y)},[k]),$e(()=>{if(L.current){L.current=!1;return}if(!(P&&N>-1&&v!==N))return;const Y=C;if(Y!=null){const J=Di(Xt(Y));if(J&&ut(Y,J))return}i||E(N)},[P,N,v,E,i,C]);const{getButtonProps:z,buttonRef:j}=yv({disabled:i,native:l,focusableWhenDisabled:!0}),$=p(s),I=A.useRef(!1),F=A.useRef(!1);function V(Y){P||i||w(s,Ot(Gl,Y.nativeEvent,void 0,{activationDirection:"none"}))}function U(Y){P||(N>-1&&!i&&E(N),!i&&b&&(!I.current||I.current&&F.current)&&w(s,Ot(Gl,Y.nativeEvent,void 0,{activationDirection:"none"})))}function K(Y){if(P||i)return;I.current=!0;function J(){I.current=!1,F.current=!1}(!Y.button||Y.button===0)&&(F.current=!0,Xt(Y.currentTarget).addEventListener("pointerup",J,{once:!0}))}return Qn("button",t,{state:{disabled:i,active:P,orientation:m,tabActivationDirection:g},ref:[n,j,R,B],props:[M,{role:"tab","aria-controls":$,"aria-selected":P,id:T,onClick:V,onFocus:U,onPointerDown:K,[Ese]:P?"":void 0,onKeyDownCapture(){L.current=!0}},f,z],stateAttributesMapping:_E})});let xLe=function(e){return e.index="data-index",e.activationDirection="data-activation-direction",e.orientation="data-orientation",e.hidden="data-hidden",e[e.startingStyle=Md.startingStyle]="startingStyle",e[e.endingStyle=Md.endingStyle]="endingStyle",e}({});const wLe={..._E,...Pm},SLe=A.forwardRef(function(t,n){const{className:r,value:i,render:o,keepMounted:s=!1,style:a,...l}=t,{value:u,getTabIdByPanelValue:f,orientation:d,tabActivationDirection:p,registerMountedTabPanel:m,unregisterMountedTabPanel:g}=F6(),b=Zc(),v=A.useMemo(()=>({id:b,value:i}),[b,i]),{ref:w,index:k}=I6({metadata:v}),E=i===u,{mounted:C,transitionStatus:T,setMounted:_}=mE(E),M=!C,R=f(i),N={hidden:M,orientation:d,tabActivationDirection:p,transitionStatus:T},P=A.useRef(null),L=Qn("div",t,{state:N,ref:[n,w,P],props:[{"aria-labelledby":R,hidden:M,id:b,role:"tabpanel",tabIndex:E?0:-1,inert:m6(!E),[xLe.index]:k},l],stateAttributesMapping:wLe});return Gd({open:E,ref:P,onComplete(){E||_(!1)}}),$e(()=>{if(!(M&&!s)&&b!=null)return m(i,b),()=>{g(i,b)}},[M,s,i,b,m,g]),s||C?L:null}),kLe=[];function ELe(e){const{loopFocus:t=!0,orientation:n="both",grid:r,onLoop:i,direction:o,highlightedIndex:s,onHighlightedIndexChange:a,rootRef:l,enableHomeAndEndKeys:u=!1,stopEventPropagation:f=!1,disabledIndices:d,modifierKeys:p=kLe}=e,[m,g]=A.useState(0),b=r!=null,v=A.useRef(null),w=$c(v,l),k=A.useRef([]),E=A.useRef(!1),C=s??m,T=We((P,L=!1)=>{if((a??g)(P),L){const B=k.current[P];OV(v.current,B,o,n)}}),_=We(P=>{if(P.size===0||E.current)return;E.current=!0;const L=Array.from(P.keys()),B=L.find(j=>j==null?void 0:j.hasAttribute(Ese))??null,z=B?L.indexOf(B):-1;if(z!==-1)T(z);else if(WS(L,C,d)){const j=Al(L,{disabledIndices:d});Z0(L,j)||T(j)}OV(v.current,B,o,n)});$e(()=>{if(d==null||s!=null||!E.current)return;const P=k.current;if(WS(P,C,d)){const L=Al(P,{disabledIndices:d});Z0(P,L)||T(L)}},[d,s,C,k,T]);const M=We((P,L,B)=>i?i(P,L,B,k):B),R=We(P=>{const L=u?_6:zoe;if(!L.has(P.key)||CLe(P,p)||!v.current)return;const z=o==="rtl",j=z?ok:sk,$={horizontal:j,vertical:iy,both:j}[n],I=z?sk:ok,F={horizontal:I,vertical:ry,both:I}[n],V=mi(P.nativeEvent);if(V!=null&&_V(V)&&!Koe(V)){const ne=V.selectionStart,ie=V.selectionEnd,te=V.value??"";if(ne==null||P.shiftKey||ne!==ie||P.key!==F&&ne<te.length||P.key!==$&&ne>0)return}let U=C;const K=gw(k,d),q=nj(k,d);r!=null&&(U=r({disabledIndices:d,elementsRef:k,event:P,highlightedIndex:C,loopFocus:t,maxIndex:q,minIndex:K,onLoop:M,orientation:n,rtl:z}));const W={horizontal:[j],vertical:[iy],both:[j,iy]}[n],Y={horizontal:[I],vertical:[ry],both:[I,ry]}[n],J=b?L:{horizontal:u?w6e:Ioe,vertical:u?S6e:Loe,both:L}[n];u&&(P.key===EE?U=K:P.key===CE&&(U=q)),U===C&&(W.includes(P.key)||Y.includes(P.key))&&(t&&U===q&&W.includes(P.key)?(U=K,i&&(U=i(P,C,U,k))):t&&U===K&&Y.includes(P.key)?(U=q,i&&(U=i(P,C,U,k))):U=Al(k.current,{startingIndex:U,decrement:Y.includes(P.key),disabledIndices:d})),U!==C&&!Z0(k.current,U)&&(f&&P.stopPropagation(),J.has(P.key)&&P.preventDefault(),T(U,!0),queueMicrotask(()=>{var ne;(ne=k.current[U])==null||ne.focus()}))});return{props:{ref:w,onFocus(P){const L=v.current,B=mi(P.nativeEvent);!L||B==null||!_V(B)||B.setSelectionRange(0,B.value.length??0)},onKeyDown:R},highlightedIndex:C,onHighlightedIndexChange:T,elementsRef:k,disabledIndices:d,onMapChange:_,relayKeyboardEvent:R}}function CLe(e,t){for(const n of T6e.values())if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function ALe(e){const{render:t,className:n,style:r,refs:i=Bp,props:o=Bp,state:s=ur,stateAttributesMapping:a,highlightedIndex:l,onHighlightedIndexChange:u,orientation:f,grid:d,loopFocus:p,onLoop:m,enableHomeAndEndKeys:g,onMapChange:b,stopEventPropagation:v=!0,rootRef:w,disabledIndices:k,modifierKeys:E,highlightItemOnHover:C=!1,tag:T="div",..._}=e,M=h6(),{props:R,highlightedIndex:N,onHighlightedIndexChange:P,elementsRef:L,onMapChange:B,relayKeyboardEvent:z}=ELe({grid:d,loopFocus:p,onLoop:m,orientation:f,highlightedIndex:l,onHighlightedIndexChange:u,rootRef:w,stopEventPropagation:v,enableHomeAndEndKeys:g,direction:M,disabledIndices:k,modifierKeys:E}),j=Qn(T,e,{state:s,ref:i,props:[R,...o,_],stateAttributesMapping:a}),$=A.useMemo(()=>({highlightedIndex:N,onHighlightedIndexChange:P,highlightItemOnHover:C,relayKeyboardEvent:z}),[N,P,C,z]);return x.jsx(Noe.Provider,{value:$,children:x.jsx(P6,{elementsRef:L,onMapChange:I=>{b==null||b(I),B(I)},children:j})})}const TLe=A.forwardRef(function(t,n){const{activateOnFocus:r=!1,className:i,loopFocus:o=!0,render:s,style:a,...l}=t,{onValueChange:u,orientation:f,value:d,setTabMap:p,tabActivationDirection:m}=F6(),[g,b]=A.useState(0),[v,w]=A.useState(null),k=A.useRef(new Set),E=A.useRef(new Set),C=A.useRef(null);$e(()=>{if(typeof ResizeObserver>"u")return;const L=new ResizeObserver(()=>{k.current.forEach(B=>{B()})});return C.current=L,v&&L.observe(v),E.current.forEach(B=>{L.observe(B)}),()=>{L.disconnect(),C.current=null}},[v]);const T=We(L=>(k.current.add(L),()=>{k.current.delete(L)})),_=We(L=>{var B;return E.current.add(L),(B=C.current)==null||B.observe(L),()=>{var z;E.current.delete(L),(z=C.current)==null||z.unobserve(L)}}),M=We((L,B)=>{L!==d&&u(L,B)}),R={orientation:f,tabActivationDirection:m},N={"aria-orientation":f==="vertical"?"vertical":void 0,role:"tablist"},P=A.useMemo(()=>({activateOnFocus:r,highlightedTabIndex:g,registerIndicatorUpdateListener:T,registerTabResizeObserverElement:_,onTabActivation:M,setHighlightedTabIndex:b,tabsListElement:v}),[r,g,T,_,M,b,v]);return x.jsx(Cse.Provider,{value:P,children:x.jsx(ALe,{render:s,className:i,style:a,state:R,refs:[n,w],props:[N,l],stateAttributesMapping:_E,highlightedIndex:g,enableHomeAndEndKeys:!0,loopFocus:o,orientation:f,onHighlightedIndexChange:b,onMapChange:p,disabledIndices:Bp})})});function Ase({value:e,onValueChange:t,children:n,className:r}){return x.jsx(gLe,{value:e,onValueChange:i=>{typeof i=="string"&&t(i)},className:r,children:n})}function Tse({children:e,className:t,ref:n}){return x.jsx(TLe,{ref:n,className:G("flex gap-1 border-b border-zinc-200 dark:border-zinc-800",t),children:e})}function kw({value:e,children:t,className:n}){return x.jsx(vLe,{value:e,className:G("flex items-center gap-1.5 border-b-2 px-3 py-2 text-sm transition-colors outline-none","border-transparent text-zinc-500","hover:text-zinc-950 dark:hover:text-zinc-50","focus-visible:ring-2 focus-visible:ring-sky-500/30","data-[selected]:border-sky-600 data-[selected]:text-zinc-950","dark:data-[selected]:text-zinc-50",n),children:t})}function Zo({value:e,children:t,className:n}){return x.jsx(SLe,{value:e,className:G("outline-none",n),children:t})}const gr="text-zinc-400 dark:text-zinc-500",ha="border-zinc-200 dark:border-zinc-800",B6="bg-white dark:bg-zinc-900";function _Le({title:e="Connectors",eyebrow:t="Ingestion",intro:n="A source, code that reshapes it, and a snapshot at the end. Running one goes through exactly the same append-and-commit a publisher uses, so there is one way rows arrive rather than two.",canEdit:r=!0}){var l;const i=br(),[o,s]=A.useState("connectors"),{data:a}=Jt({queryKey:Yt.capabilities,queryFn:()=>i.pipelineCapabilities(),staleTime:Number.POSITIVE_INFINITY});return x.jsx(ru,{children:x.jsx("div",{className:"h-full overflow-y-auto",children:x.jsxs("div",{className:"mx-auto max-w-5xl px-8 py-8",children:[x.jsx("p",{className:G("font-mono text-[11px] uppercase tracking-[0.18em]",gr),children:t}),x.jsx("h1",{className:"mt-1 text-2xl font-semibold tracking-tight",children:e}),x.jsx("p",{className:"mt-1 max-w-2xl text-sm text-zinc-500 dark:text-zinc-400",children:n}),x.jsxs(Ase,{value:o,onValueChange:s,className:"mt-6",children:[x.jsxs(Tse,{children:[x.jsxs(kw,{value:"connections",children:[x.jsx(Nm,{size:13}),"Connections"]}),x.jsxs(kw,{value:"connectors",children:[x.jsx(nye,{size:13}),"Connectors"]}),x.jsxs(kw,{value:"transforms",children:[x.jsx(Zb,{size:13}),"Transforms"]}),x.jsx(ht,{content:(l=a==null?void 0:a.pythonPackages)!=null&&l.length?`Python transforms may import ${a.pythonPackages.join(", ")} — provisioned by the image, not by this service.`:"Which languages this deployment can actually execute.",children:x.jsx("span",{className:G("ml-auto cursor-help self-center font-mono text-[10px]",gr),children:a?`runs ${a.languages.join(" · ")}`:"checking…"})})]}),x.jsx(Zo,{value:"connections",children:x.jsx(q4e,{canEdit:r})}),x.jsx(Zo,{value:"connectors",children:x.jsx(OLe,{canEdit:r})}),x.jsx(Zo,{value:"transforms",children:x.jsx($Le,{canEdit:r,languages:(a==null?void 0:a.languages)??["javascript"],pythonPackages:(a==null?void 0:a.pythonPackages)??[]})})]})]})})})}function OLe({canEdit:e}){var f,d;const t=br(),n=ps(),[r,i]=A.useState(null),o=Jt({queryKey:Yt.connectors,queryFn:()=>t.listConnectors()}),{data:s=[]}=Jt({queryKey:Yt.transforms,queryFn:()=>t.listTransforms(),staleTime:3e4}),{data:a=[]}=Jt({queryKey:Yt.connections,queryFn:()=>t.listConnections(),staleTime:3e4}),l=()=>{n.invalidateQueries({queryKey:Yt.connectors}),n.invalidateQueries({queryKey:Yt.runs()}),n.invalidateQueries({queryKey:Yt.snapshot})},u=Un({mutationFn:p=>t.runConnector(p),onSuccess:l});return r?x.jsx(zLe,{connector:r==="new"?void 0:r,transforms:s,connections:a,onClose:()=>i(null),onSaved:()=>{i(null),n.invalidateQueries({queryKey:Yt.connectors})}}):x.jsxs("div",{className:"mt-6 space-y-3",children:[e&&x.jsxs("button",{type:"button",onClick:()=>i("new"),className:G("flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs",ha,"hover:bg-zinc-50 dark:hover:bg-zinc-800"),children:[x.jsx(Jb,{size:12}),"New connector"]}),o.isPending&&x.jsx("p",{className:G("rounded-lg border border-dashed px-4 py-12 text-center text-sm",ha,gr),children:"Reading connectors…"}),o.isError&&x.jsxs("div",{className:"rounded-lg border border-red-200 bg-red-50 px-4 py-6 text-center dark:border-red-900 dark:bg-red-950/40",children:[x.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:o.error instanceof Error?o.error.message:"Could not read the connectors."}),x.jsx("button",{type:"button",onClick:()=>o.refetch(),className:"mt-2 rounded-md border border-red-300 px-3 py-1 text-xs text-red-700 dark:border-red-800 dark:text-red-300",children:"Try again"})]}),((f=o.data)==null?void 0:f.length)===0&&x.jsx("p",{className:G("rounded-lg border border-dashed px-4 py-12 text-center text-sm",ha,gr),children:"No connectors yet."}),(d=o.data)==null?void 0:d.map(p=>x.jsx(jLe,{connector:p,canEdit:e,transform:s.find(m=>m.id===p.transformId),connection:a.find(m=>m.id===p.connectionId),running:u.isPending&&u.variables===p.id,onRun:()=>u.mutate(p.id),onEdit:()=>i(p),onDeleted:l},p.id))]})}function Fl(e,t){const n=e[t];return typeof n=="string"?n:""}function MLe(e,t){if(t)return`${t}${Fl(e,"prefix")||"(whole bucket)"}`;const n=Fl(e,"bucket");return n?`s3://${n}/${Fl(e,"prefix")}`:"no bucket configured"}function NLe(e,t){const n=Fl(e,"watermarkColumn"),r=Fl(e,"query").replace(/\s+/g," ").trim(),i=r.length>70?`${r.slice(0,70)}…`:r;return`${t}${n?`${i} · since ${n}`:i}`}function RLe(e,t){const n=Fl(e,"path");return t?`${t}${n||"/"}`:`${Fl(e,"url")}${n?` · ${n}`:""}`}function DLe(e,t){const n=e.config??{},r=t?`${t.name} · `:"";if(e.kind==="s3")return MLe(n,r);if(e.kind==="sql")return NLe(n,r);if(e.kind==="file")return Fl(n,"path")||Fl(n,"url")||"no path configured";if(e.kind==="inline"){const i=n.records;return`${Array.isArray(i)?i.length:0} pasted records`}return RLe(n,r)}function jLe({connector:e,transform:t,connection:n,canEdit:r,running:i,onRun:o,onEdit:s,onDeleted:a}){const l=br(),[u,f]=A.useState(!1),{data:d=[]}=Jt({queryKey:Yt.runs(e.id),queryFn:()=>l.listRuns(e.id)}),p=Un({mutationFn:()=>l.deleteConnector(e.id),onSuccess:()=>{f(!1),a()}});return x.jsxs("div",{className:G("rounded-lg border p-4",ha,B6),children:[x.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[x.jsxs("div",{className:"min-w-0",children:[x.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[x.jsx("span",{className:"text-sm font-medium",children:e.name}),x.jsx("span",{className:"rounded-sm bg-zinc-100 px-1.5 py-0.5 font-mono text-[10px] uppercase dark:bg-zinc-800",children:e.kind}),x.jsxs("span",{className:G("font-mono text-[10px]",gr),children:["→ ",e.targetType]}),n&&x.jsx(ht,{content:`Reads through the ${n.name} connection, which supplies the address and the credential. Moving that connection moves this connector with it.`,children:x.jsxs("span",{className:G("flex cursor-help items-center gap-1 font-mono text-[10px]",gr),children:[x.jsx(Nm,{size:10}),n.name]})}),e.mode==="incremental"&&x.jsx(ht,{content:"Reads only what changed since the last run, and carries the rest forward.",children:x.jsxs("span",{className:G("flex cursor-help items-center gap-1 font-mono text-[10px]",gr),children:[x.jsx(jI,{size:10}),"incremental"]})}),!e.enabled&&x.jsx("span",{className:"rounded-sm bg-zinc-100 px-1.5 py-0.5 font-mono text-[10px] uppercase text-zinc-500 dark:bg-zinc-800",children:"disabled"})]}),x.jsx("div",{className:G("mt-1 font-mono text-[11px]",gr),children:DLe(e,n)}),e.secretEnvVar&&x.jsx(ht,{content:"The catalog stores the NAME of this variable, never its value. A leaked catalog database gives away the shape of the integration, not the keys to it.",children:x.jsxs("div",{className:G("mt-1 flex w-fit cursor-help items-center gap-1 font-mono text-[10px]",gr),children:[x.jsx(C2,{size:10}),e.secretEnvVar]})})]}),x.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[x.jsxs("button",{type:"button",onClick:o,disabled:i||!e.enabled,className:"flex items-center gap-1.5 rounded-md bg-zinc-950 px-3 py-1.5 text-xs text-zinc-50 disabled:opacity-40 dark:bg-zinc-100 dark:text-zinc-950",children:[i?x.jsx(Rc,{size:12,className:"animate-spin"}):x.jsx(Qb,{size:12}),i?"Running…":"Run now"]}),r&&x.jsx(ht,{content:`Delete ${e.name}`,children:x.jsx("button",{type:"button",onClick:()=>f(!0),"aria-label":`Delete ${e.name}`,className:G("rounded-sm p-1.5 hover:text-red-600",gr),children:x.jsx(eu,{size:12})})})]})]}),t&&x.jsxs("button",{type:"button",onClick:s,className:G("mt-3 flex items-center gap-1.5 text-[11px]",gr,"hover:text-sky-600"),children:[x.jsx(Zb,{size:11}),t.name,x.jsxs("span",{className:"font-mono",children:[t.language," · v",t.version]})]}),d.length>0&&x.jsxs("div",{className:G("mt-3 border-t pt-3",ha),children:[x.jsx("div",{className:G("mb-1.5 font-mono text-[10px] uppercase tracking-[0.14em]",gr),children:"Recent runs"}),x.jsx("div",{className:"space-y-1",children:d.slice(0,4).map(m=>x.jsx(ht,{content:m.error?x.jsx("span",{className:"font-mono text-[11px]",children:m.error}):x.jsx("span",{className:"font-mono text-[11px]",children:m.logs.slice(-3).join(`
587
+ `)}),e.rows.length===0?x.jsx("p",{className:"text-[11px] text-amber-600",children:"It ran and returned no rows. A connector using this would commit an empty snapshot."}):x.jsx("pre",{className:"whitespace-pre-wrap font-mono text-[11px]",children:JSON.stringify(e.rows,null,2)}),x.jsxs("p",{className:G("mt-2 font-mono text-[10px]",wl),children:[e.rows.length," rows · ",e.elapsedMs,"ms"]})]}),!e&&!t&&x.jsx("p",{className:G("py-4 text-center text-[11px]",wl),children:"Run it to see what it produces."})]})}function aLe({transform:e,nameIsEmpty:t,pending:n,error:r,onSave:i}){return x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("button",{type:"button",onClick:i,disabled:n||t,className:G("rounded-md border px-3 py-1.5 text-xs disabled:opacity-40",Nf,"hover:bg-zinc-50 dark:hover:bg-zinc-800"),children:n?"Saving…":e?"Save changes":"Save transform"}),e&&x.jsxs("span",{className:G("font-mono text-[10px]",wl),children:["saving new code makes this v",e.version+1]}),r?x.jsx("span",{className:"text-[11px] text-red-600",children:r instanceof Error?r.message:"Could not save."}):null]})}function mse({transform:e,languages:t,pythonPackages:n=[],onClose:r,onSaved:i}){const o=br(),[s,a]=A.useState((e==null?void 0:e.name)??""),[l,u]=A.useState((e==null?void 0:e.description)??""),[f,d]=A.useState((e==null?void 0:e.language)??t[0]??"javascript"),[p,m]=A.useState((e==null?void 0:e.code)??sO[(e==null?void 0:e.language)??"javascript"]),[g,b]=A.useState(oLe),v=A.useRef(null),w=Un({mutationFn:()=>{let C;try{const T=JSON.parse(g);C=Array.isArray(T)?T:[T]}catch{throw new Error("The sample is not valid JSON.")}return o.tryTransform({language:f,code:p,records:C})}}),k=Un({mutationFn:()=>o.saveTransform({id:e==null?void 0:e.id,name:s.trim(),language:f,code:p,description:l.trim()||void 0}),onSuccess:i});function E(C){(C.metaKey||C.ctrlKey)&&C.key==="Enter"&&(C.preventDefault(),w.mutate())}return x.jsxs("div",{className:"mt-6 space-y-3",children:[x.jsxs("button",{type:"button",onClick:r,className:G("flex items-center gap-1.5 font-mono text-[11px] uppercase tracking-[0.14em]",wl,"hover:text-zinc-950 dark:hover:text-zinc-50"),children:[x.jsx(YQ,{size:12}),"Transforms"]}),x.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[x.jsx(an,{label:"Name",value:s,onChange:a,placeholder:"Fleet rows"}),x.jsx(an,{label:"Description",value:l,onChange:u,placeholder:"What it does (optional)"}),x.jsx(Fi,{label:"Language",ariaLabel:"Language",value:f,onValueChange:C=>{jn.isTransformLanguage(C)&&(d(C),Object.values(sO).includes(p)&&m(sO[C]))},options:t.map(C=>({value:C,label:C}))})]}),x.jsxs("div",{className:"grid gap-3 lg:grid-cols-2",children:[x.jsxs("div",{className:G("overflow-hidden rounded-lg border",Nf,oO),children:[x.jsxs("div",{className:G("flex items-center justify-between border-b px-3 py-1.5",Nf),children:[x.jsx("span",{className:G("font-mono text-[10px] uppercase tracking-[0.14em]",wl),children:"Code"}),x.jsx("span",{className:G("font-mono text-[10px]",wl),children:f==="python"&&n.length>0?`imports: ${n.join(", ")}`:"⌘↵ to try"})]}),x.jsx(pj,{value:p,onChange:m,onKeyDown:E,language:f==="python"?"python":"tsx",label:"Transform code",textareaRef:v,className:"h-72"})]}),x.jsxs("div",{className:"space-y-3",children:[x.jsxs("div",{className:G("overflow-hidden rounded-lg border",Nf,oO),children:[x.jsx("div",{className:G("border-b px-3 py-1.5",Nf),children:x.jsx("span",{className:G("font-mono text-[10px] uppercase tracking-[0.14em]",wl),children:"Sample records"})}),x.jsx(pj,{value:g,onChange:b,language:"json",label:"Sample records",className:"h-32"})]}),x.jsxs("button",{type:"button",onClick:()=>w.mutate(),disabled:w.isPending,className:"flex items-center gap-1.5 rounded-md bg-zinc-950 px-3 py-1.5 text-xs text-zinc-50 disabled:opacity-40 dark:bg-zinc-100 dark:text-zinc-950",children:[x.jsx(Qb,{size:12}),w.isPending?"Running…":"Try it"]}),x.jsxs("div",{className:G("overflow-hidden rounded-lg border",Nf,oO),children:[x.jsx("div",{className:G("border-b px-3 py-1.5",Nf),children:x.jsx("span",{className:G("font-mono text-[10px] uppercase tracking-[0.14em]",wl),children:"Output"})}),x.jsx(sLe,{result:w.data,error:w.error})]})]})]}),x.jsx(aLe,{transform:e,nameIsEmpty:s.trim().length===0,pending:k.isPending,error:k.error,onSave:()=>k.mutate()})]})}const BV="text-zinc-400 dark:text-zinc-500";function sy(e){return jn.CONNECTOR_KINDS.find(t=>t===e)??"http"}function uk(e){return e==="sql"||e==="s3"}function gse(e){return e==="http"||e==="sql"||e==="s3"}const yse=[{value:"http",label:"HTTP — a JSON endpoint"},{value:"sql",label:"SQL — a database query"},{value:"file",label:"File — CSV, NDJSON or JSON"},{value:"s3",label:"S3 — a bucket prefix"},{value:"inline",label:"Inline — records pasted below"}],VV=[{value:"",label:"Format from the extension"},{value:"csv",label:"CSV"},{value:"ndjson",label:"NDJSON"},{value:"json",label:"JSON"}],Sl="";function bse(e){const t=e??{},n=i=>{const o=t[i];return typeof o=="string"?o:""},r=t.records;return{url:n("url"),path:n("path"),query:n("query"),format:n("format"),records:Array.isArray(r)&&r.length>0?JSON.stringify(r,null,2):"",bucket:n("bucket"),prefix:n("prefix"),suffix:n("suffix"),endpoint:n("endpoint"),region:n("region"),forcePathStyle:t.forcePathStyle===!0,maxObjectsPerRun:typeof t.maxObjectsPerRun=="number"?String(t.maxObjectsPerRun):"",watermarkColumn:n("watermarkColumn")}}function $6(e){const t=e.trim();if(t.length===0)return{ok:!0,records:[]};try{const n=JSON.parse(t);return Array.isArray(n)?{ok:!0,records:n}:{ok:!1,message:"Inline records have to be a JSON array. A single object is one record, so wrap it in [ ]."}}catch(n){return{ok:!1,message:`That is not valid JSON: ${n instanceof Error?n.message:"it could not be parsed"}.`}}}function lLe(e,t){return{...t?{}:{url:e.url},...e.path?{path:e.path}:{}}}function uLe(e,t,n){return{query:e.query,...t||!e.url?{}:{url:e.url},...n&&e.watermarkColumn?{watermarkColumn:e.watermarkColumn}:{}}}function cLe(e){return{path:e.path||e.url,...e.format?{format:e.format}:{}}}function fLe(e,t){return{...t?{}:{bucket:e.bucket,...e.endpoint?{endpoint:e.endpoint}:{},...e.region?{region:e.region}:{},...e.forcePathStyle?{forcePathStyle:!0}:{}},...e.prefix?{prefix:e.prefix}:{},...e.suffix?{suffix:e.suffix}:{},...e.format?{format:e.format}:{},...e.maxObjectsPerRun?{maxObjectsPerRun:Number(e.maxObjectsPerRun)}:{}}}function dLe(e){const t=$6(e.records);return{records:t.ok?t.records:[]}}function vse(e,t,{viaConnection:n,incremental:r}){return e==="http"?lLe(t,n):e==="sql"?uLe(t,n,r):e==="file"?cLe(t):e==="s3"?fLe(t,n):dLe(t)}function hLe(e,t,n){return e==="s3"&&!n?t.bucket.trim().length===0:e==="http"&&!n?t.url.trim().length===0:!1}function pLe(e,t){return t.filter(n=>n.kind===e).map(n=>({value:n.id,label:n.name}))}function xse({kind:e,draft:t,onChange:n,viaConnection:r,disabled:i}){const o=a=>n({...t,...a});if(e==="http")return x.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[!r&&x.jsx(an,{label:"URL",value:t.url,onChange:a=>o({url:a}),placeholder:"https://…",disabled:i}),x.jsx(an,{label:"Path to the array",value:t.path,onChange:a=>o({path:a}),placeholder:"e.g. data",disabled:i})]});if(e==="sql")return x.jsxs("div",{className:"space-y-3",children:[x.jsx(jV,{label:"Query",value:t.query,onChange:a=>o({query:a}),placeholder:"SELECT … FROM …",mono:!0,disabled:i,hint:"Runs inside a read-only transaction, so the database refuses a write whatever the statement parses as."}),!r&&x.jsx(an,{label:"URL (optional)",value:t.url,onChange:a=>o({url:a}),placeholder:"Prefer naming the environment variable below",disabled:i})]});if(e==="file")return x.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[x.jsx(an,{label:"File path or URL",value:t.path,onChange:a=>o({path:a}),placeholder:"/data/drop.csv or https://…",disabled:i}),x.jsx(Fi,{label:"Format",ariaLabel:"Format",value:t.format,onValueChange:a=>o({format:a}),options:VV,disabled:i})]});if(e==="s3")return x.jsxs("div",{className:"space-y-3",children:[!r&&x.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[x.jsx(an,{label:"Bucket",value:t.bucket,onChange:a=>o({bucket:a}),placeholder:"fleet-drops",disabled:i}),x.jsx(an,{label:"Region",value:t.region,onChange:a=>o({region:a}),placeholder:"Blank uses the environment's",disabled:i}),x.jsx(an,{label:"Endpoint",value:t.endpoint,onChange:a=>o({endpoint:a}),placeholder:"MinIO, e.g. http://localhost:9000",disabled:i})]}),x.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[x.jsx(an,{label:"Prefix",value:t.prefix,onChange:a=>o({prefix:a}),placeholder:"drops/mvr/",disabled:i}),x.jsx(an,{label:"Only keys ending in",value:t.suffix,onChange:a=>o({suffix:a}),placeholder:".csv",disabled:i}),x.jsx(an,{label:"Max objects per run",value:t.maxObjectsPerRun,onChange:a=>o({maxObjectsPerRun:a}),inputMode:"numeric",disabled:i})]}),x.jsx(Fi,{label:"Format",ariaLabel:"Format",value:t.format,onValueChange:a=>o({format:a}),options:[{value:"",label:"Format from each key"},...VV.slice(1)],disabled:i}),!r&&x.jsx(z6,{checked:t.forcePathStyle,onCheckedChange:a=>o({forcePathStyle:a}),label:"Path-style addressing",hint:"MinIO needs it; AWS does not."})]});const s=$6(t.records);return x.jsx(jV,{label:"Records",value:t.records,onChange:a=>o({records:a}),placeholder:'[{ "tag": "AF93E00073" }]',mono:!0,rows:5,disabled:i,hint:s.ok?void 0:x.jsx("span",{className:"text-red-600 dark:text-red-400",children:s.message})})}function wse({kind:e,mode:t,onModeChange:n,draft:r,onChange:i,disabled:o}){return uk(e)?x.jsxs(R6,{title:"Read mode",children:[x.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[x.jsx(Fi,{label:"Mode",ariaLabel:"Read mode",value:t,onValueChange:s=>n(s==="incremental"?"incremental":"full"),options:[{value:"full",label:"Full — read everything, every run"},{value:"incremental",label:"Incremental — only what changed"}],disabled:o}),e==="sql"&&t==="incremental"&&x.jsx(an,{label:"Watermark column",value:r.watermarkColumn,onChange:s=>i({...r,watermarkColumn:s}),placeholder:"updated_at",disabled:o})]}),e==="sql"&&t==="incremental"&&x.jsxs("p",{className:G("text-[11px] leading-relaxed",BV),children:["The query is wrapped as"," ",x.jsx("span",{className:"font-mono",children:"SELECT * FROM (your query) WHERE column > ?"})," with the value bound, never pasted in. Two things follow from wrapping: the column has to be in what your query selects, and a query with its own LIMIT or GROUP BY is filtered after that step. Leave the column blank and this reads everything."]}),e==="s3"&&t==="incremental"&&x.jsx("p",{className:G("text-[11px] leading-relaxed",BV),children:"Each run remembers the newest LastModified it read and the keys sitting at exactly that timestamp, so objects written in the same second are neither skipped nor read twice. Objects rewritten in place under a key already read are not picked up again."})]}):null}function Sse({kind:e,value:t,onChange:n,disabled:r}){return x.jsx(an,{label:"Credential env var",value:t,onChange:n,placeholder:e==="sql"?"Env var holding the connection URL":e==="s3"?"accessKeyId:secretAccessKey (optional)":"Optional",disabled:r,hint:"The credential is read from the environment by name at run time. Only the variable name is stored."})}const kse=A.createContext(void 0);function F6(){const e=A.useContext(kse);if(e===void 0)throw new Error(yi(64));return e}let mLe=function(e){return e.activationDirection="data-activation-direction",e.orientation="data-orientation",e}({});const _E={tabActivationDirection:e=>({[mLe.activationDirection]:e})},gLe=A.forwardRef(function(t,n){const{className:r,defaultValue:i=0,onValueChange:o,orientation:s="horizontal",render:a,value:l,style:u,...f}=t,d=t.defaultValue!==void 0,p=A.useRef([]),[m,g]=A.useState(()=>new Map),[b,v]=ak({controlled:l,default:i,name:"Tabs",state:"value"}),w=l!==void 0,[k,E]=A.useState(()=>new Map),C=A.useRef(void 0),T=A.useCallback(Q=>{if(Q===void 0)return null;for(const[oe,ce]of k.entries())if(ce!=null&&Q===(ce.value??ce.index))return oe;return null},[k]),[_,M]=A.useState(()=>({previousValue:b,tabActivationDirection:"none"})),{previousValue:R,tabActivationDirection:N}=_;let P=N,L=!1;R!==b&&(P=qV(R,b,s,k),L=R!=null&&b!=null&&T(b)==null);const B=L?R:b,z=R!==B||N!==P;$e(()=>{z&&M({previousValue:B,tabActivationDirection:P})},[B,z,P]);const j=We((Q,oe)=>{const ce=qV(b,Q,s,k);oe.activationDirection=ce,o==null||o(Q,oe),!oe.isCanceled&&v(Q)}),$=We((Q,oe)=>{o==null||o(Q,Ot(oe,void 0,void 0,{activationDirection:"none"}))}),I=We((Q,oe)=>{g(ce=>{if(ce.get(Q)===oe)return ce;const Z=new Map(ce);return Z.set(Q,oe),Z})}),F=We((Q,oe)=>{g(ce=>{if(!ce.has(Q)||ce.get(Q)!==oe)return ce;const Z=new Map(ce);return Z.delete(Q),Z})}),V=A.useCallback(Q=>m.get(Q),[m]),U=A.useCallback(Q=>{for(const oe of k.values())if(Q===(oe==null?void 0:oe.value))return oe==null?void 0:oe.id},[k]),K=A.useMemo(()=>({getTabElementBySelectedValue:T,getTabIdByPanelValue:U,getTabPanelIdByValue:V,onValueChange:j,orientation:s,registerMountedTabPanel:I,setTabMap:E,unregisterMountedTabPanel:F,tabActivationDirection:P,value:b}),[T,U,V,j,s,I,E,F,P,b]),q=A.useMemo(()=>{for(const Q of k.values())if(Q!=null&&Q.value===b)return Q},[k,b]),W=A.useMemo(()=>{for(const Q of k.values())if(Q!=null&&!Q.disabled)return Q.value},[k]),Y=A.useRef(!d),J=A.useRef(i),ne=A.useRef(d),ie=A.useRef(!1);$e(()=>{var de;if(w)return;function Q(se,me){v(se),M(ke=>ke.previousValue===se&&ke.tabActivationDirection==="none"?ke:{previousValue:se,tabActivationDirection:"none"}),$(se,me),Y.current=!1}if(k.size===0){ie.current&&b!==null&&!((de=C.current)!=null&&de.isConnected)&&Q(null,A7);return}ie.current=!0,C.current=k.keys().next().value;const oe=q==null?void 0:q.disabled,ce=q==null&&b!==null;if(!oe&&b===J.current&&(ne.current=!1),ne.current&&oe&&b===J.current)return;const Z=Y.current;if(oe||ce){const se=W??null;if(b===se){Y.current=!1;return}let me=A7;Z?me=T7:oe&&(me=Ure),Q(se,me);return}Z&&q!=null&&($(b,T7),Y.current=!1)},[W,w,$,q,v,k,b]);const ee=Qn("div",t,{state:{orientation:s,tabActivationDirection:P},ref:n,props:f,stateAttributesMapping:_E});return x.jsx(kse.Provider,{value:K,children:x.jsx(P6,{elementsRef:p,children:ee})})});function qV(e,t,n,r){if(e==null||t==null)return"none";let i=null,o=null;for(const[l,u]of r.entries()){if(u==null)continue;const f=u.value??u.index;if(e===f&&(i=l),t===f&&(o=l),i!=null&&o!=null)break}if(i==null||o==null)return i!==o&&(typeof e=="number"||typeof e=="string")&&typeof e==typeof t?n==="horizontal"?t>e?"right":"left":t>e?"down":"up":"none";const s=i.getBoundingClientRect(),a=o.getBoundingClientRect();if(n==="horizontal"){if(a.left<s.left)return"left";if(a.left>s.left)return"right"}else{if(a.top<s.top)return"up";if(a.top>s.top)return"down"}return"none"}const Ese="data-composite-item-active";function yLe(e={}){const{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=Roe(),{ref:i,index:o}=I6(e),s=n===o,a=A.useRef(null),l=$c(i,a);return{compositeProps:{tabIndex:s?0:-1,onFocus(){r(o)},onMouseMove(){const f=a.current;if(!t||!f)return;const d=f.hasAttribute("disabled")||f.ariaDisabled==="true";!s&&!d&&f.focus()}},compositeRef:l,index:o}}const Cse=A.createContext(void 0);function bLe(){const e=A.useContext(Cse);if(e===void 0)throw new Error(yi(65));return e}const vLe=A.forwardRef(function(t,n){const{className:r,disabled:i=!1,render:o,value:s,id:a,nativeButton:l=!0,style:u,...f}=t,{value:d,getTabPanelIdByValue:p,orientation:m,tabActivationDirection:g}=F6(),{activateOnFocus:b,highlightedTabIndex:v,onTabActivation:w,registerTabResizeObserverElement:k,setHighlightedTabIndex:E,tabsListElement:C}=bLe(),T=Zc(a),_=A.useMemo(()=>({disabled:i,id:T,value:s}),[i,T,s]),{compositeProps:M,compositeRef:R,index:N}=yLe({metadata:_}),P=s===d,L=A.useRef(!1),B=A.useRef(null);$e(()=>{const Y=B.current;if(Y)return k(Y)},[k]),$e(()=>{if(L.current){L.current=!1;return}if(!(P&&N>-1&&v!==N))return;const Y=C;if(Y!=null){const J=Di(Xt(Y));if(J&&ut(Y,J))return}i||E(N)},[P,N,v,E,i,C]);const{getButtonProps:z,buttonRef:j}=yv({disabled:i,native:l,focusableWhenDisabled:!0}),$=p(s),I=A.useRef(!1),F=A.useRef(!1);function V(Y){P||i||w(s,Ot(Gl,Y.nativeEvent,void 0,{activationDirection:"none"}))}function U(Y){P||(N>-1&&!i&&E(N),!i&&b&&(!I.current||I.current&&F.current)&&w(s,Ot(Gl,Y.nativeEvent,void 0,{activationDirection:"none"})))}function K(Y){if(P||i)return;I.current=!0;function J(){I.current=!1,F.current=!1}(!Y.button||Y.button===0)&&(F.current=!0,Xt(Y.currentTarget).addEventListener("pointerup",J,{once:!0}))}return Qn("button",t,{state:{disabled:i,active:P,orientation:m,tabActivationDirection:g},ref:[n,j,R,B],props:[M,{role:"tab","aria-controls":$,"aria-selected":P,id:T,onClick:V,onFocus:U,onPointerDown:K,[Ese]:P?"":void 0,onKeyDownCapture(){L.current=!0}},f,z],stateAttributesMapping:_E})});let xLe=function(e){return e.index="data-index",e.activationDirection="data-activation-direction",e.orientation="data-orientation",e.hidden="data-hidden",e[e.startingStyle=Md.startingStyle]="startingStyle",e[e.endingStyle=Md.endingStyle]="endingStyle",e}({});const wLe={..._E,...Pm},SLe=A.forwardRef(function(t,n){const{className:r,value:i,render:o,keepMounted:s=!1,style:a,...l}=t,{value:u,getTabIdByPanelValue:f,orientation:d,tabActivationDirection:p,registerMountedTabPanel:m,unregisterMountedTabPanel:g}=F6(),b=Zc(),v=A.useMemo(()=>({id:b,value:i}),[b,i]),{ref:w,index:k}=I6({metadata:v}),E=i===u,{mounted:C,transitionStatus:T,setMounted:_}=mE(E),M=!C,R=f(i),N={hidden:M,orientation:d,tabActivationDirection:p,transitionStatus:T},P=A.useRef(null),L=Qn("div",t,{state:N,ref:[n,w,P],props:[{"aria-labelledby":R,hidden:M,id:b,role:"tabpanel",tabIndex:E?0:-1,inert:m6(!E),[xLe.index]:k},l],stateAttributesMapping:wLe});return Gd({open:E,ref:P,onComplete(){E||_(!1)}}),$e(()=>{if(!(M&&!s)&&b!=null)return m(i,b),()=>{g(i,b)}},[M,s,i,b,m,g]),s||C?L:null}),kLe=[];function ELe(e){const{loopFocus:t=!0,orientation:n="both",grid:r,onLoop:i,direction:o,highlightedIndex:s,onHighlightedIndexChange:a,rootRef:l,enableHomeAndEndKeys:u=!1,stopEventPropagation:f=!1,disabledIndices:d,modifierKeys:p=kLe}=e,[m,g]=A.useState(0),b=r!=null,v=A.useRef(null),w=$c(v,l),k=A.useRef([]),E=A.useRef(!1),C=s??m,T=We((P,L=!1)=>{if((a??g)(P),L){const B=k.current[P];OV(v.current,B,o,n)}}),_=We(P=>{if(P.size===0||E.current)return;E.current=!0;const L=Array.from(P.keys()),B=L.find(j=>j==null?void 0:j.hasAttribute(Ese))??null,z=B?L.indexOf(B):-1;if(z!==-1)T(z);else if(WS(L,C,d)){const j=Al(L,{disabledIndices:d});Z0(L,j)||T(j)}OV(v.current,B,o,n)});$e(()=>{if(d==null||s!=null||!E.current)return;const P=k.current;if(WS(P,C,d)){const L=Al(P,{disabledIndices:d});Z0(P,L)||T(L)}},[d,s,C,k,T]);const M=We((P,L,B)=>i?i(P,L,B,k):B),R=We(P=>{const L=u?_6:zoe;if(!L.has(P.key)||CLe(P,p)||!v.current)return;const z=o==="rtl",j=z?ok:sk,$={horizontal:j,vertical:iy,both:j}[n],I=z?sk:ok,F={horizontal:I,vertical:ry,both:I}[n],V=mi(P.nativeEvent);if(V!=null&&_V(V)&&!Koe(V)){const ne=V.selectionStart,ie=V.selectionEnd,te=V.value??"";if(ne==null||P.shiftKey||ne!==ie||P.key!==F&&ne<te.length||P.key!==$&&ne>0)return}let U=C;const K=gw(k,d),q=nj(k,d);r!=null&&(U=r({disabledIndices:d,elementsRef:k,event:P,highlightedIndex:C,loopFocus:t,maxIndex:q,minIndex:K,onLoop:M,orientation:n,rtl:z}));const W={horizontal:[j],vertical:[iy],both:[j,iy]}[n],Y={horizontal:[I],vertical:[ry],both:[I,ry]}[n],J=b?L:{horizontal:u?w6e:Ioe,vertical:u?S6e:Loe,both:L}[n];u&&(P.key===EE?U=K:P.key===CE&&(U=q)),U===C&&(W.includes(P.key)||Y.includes(P.key))&&(t&&U===q&&W.includes(P.key)?(U=K,i&&(U=i(P,C,U,k))):t&&U===K&&Y.includes(P.key)?(U=q,i&&(U=i(P,C,U,k))):U=Al(k.current,{startingIndex:U,decrement:Y.includes(P.key),disabledIndices:d})),U!==C&&!Z0(k.current,U)&&(f&&P.stopPropagation(),J.has(P.key)&&P.preventDefault(),T(U,!0),queueMicrotask(()=>{var ne;(ne=k.current[U])==null||ne.focus()}))});return{props:{ref:w,onFocus(P){const L=v.current,B=mi(P.nativeEvent);!L||B==null||!_V(B)||B.setSelectionRange(0,B.value.length??0)},onKeyDown:R},highlightedIndex:C,onHighlightedIndexChange:T,elementsRef:k,disabledIndices:d,onMapChange:_,relayKeyboardEvent:R}}function CLe(e,t){for(const n of T6e.values())if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function ALe(e){const{render:t,className:n,style:r,refs:i=Bp,props:o=Bp,state:s=ur,stateAttributesMapping:a,highlightedIndex:l,onHighlightedIndexChange:u,orientation:f,grid:d,loopFocus:p,onLoop:m,enableHomeAndEndKeys:g,onMapChange:b,stopEventPropagation:v=!0,rootRef:w,disabledIndices:k,modifierKeys:E,highlightItemOnHover:C=!1,tag:T="div",..._}=e,M=h6(),{props:R,highlightedIndex:N,onHighlightedIndexChange:P,elementsRef:L,onMapChange:B,relayKeyboardEvent:z}=ELe({grid:d,loopFocus:p,onLoop:m,orientation:f,highlightedIndex:l,onHighlightedIndexChange:u,rootRef:w,stopEventPropagation:v,enableHomeAndEndKeys:g,direction:M,disabledIndices:k,modifierKeys:E}),j=Qn(T,e,{state:s,ref:i,props:[R,...o,_],stateAttributesMapping:a}),$=A.useMemo(()=>({highlightedIndex:N,onHighlightedIndexChange:P,highlightItemOnHover:C,relayKeyboardEvent:z}),[N,P,C,z]);return x.jsx(Noe.Provider,{value:$,children:x.jsx(P6,{elementsRef:L,onMapChange:I=>{b==null||b(I),B(I)},children:j})})}const TLe=A.forwardRef(function(t,n){const{activateOnFocus:r=!1,className:i,loopFocus:o=!0,render:s,style:a,...l}=t,{onValueChange:u,orientation:f,value:d,setTabMap:p,tabActivationDirection:m}=F6(),[g,b]=A.useState(0),[v,w]=A.useState(null),k=A.useRef(new Set),E=A.useRef(new Set),C=A.useRef(null);$e(()=>{if(typeof ResizeObserver>"u")return;const L=new ResizeObserver(()=>{k.current.forEach(B=>{B()})});return C.current=L,v&&L.observe(v),E.current.forEach(B=>{L.observe(B)}),()=>{L.disconnect(),C.current=null}},[v]);const T=We(L=>(k.current.add(L),()=>{k.current.delete(L)})),_=We(L=>{var B;return E.current.add(L),(B=C.current)==null||B.observe(L),()=>{var z;E.current.delete(L),(z=C.current)==null||z.unobserve(L)}}),M=We((L,B)=>{L!==d&&u(L,B)}),R={orientation:f,tabActivationDirection:m},N={"aria-orientation":f==="vertical"?"vertical":void 0,role:"tablist"},P=A.useMemo(()=>({activateOnFocus:r,highlightedTabIndex:g,registerIndicatorUpdateListener:T,registerTabResizeObserverElement:_,onTabActivation:M,setHighlightedTabIndex:b,tabsListElement:v}),[r,g,T,_,M,b,v]);return x.jsx(Cse.Provider,{value:P,children:x.jsx(ALe,{render:s,className:i,style:a,state:R,refs:[n,w],props:[N,l],stateAttributesMapping:_E,highlightedIndex:g,enableHomeAndEndKeys:!0,loopFocus:o,orientation:f,onHighlightedIndexChange:b,onMapChange:p,disabledIndices:Bp})})});function Ase({value:e,onValueChange:t,children:n,className:r}){return x.jsx(gLe,{value:e,onValueChange:i=>{typeof i=="string"&&t(i)},className:r,children:n})}function Tse({children:e,className:t,ref:n}){return x.jsx(TLe,{ref:n,className:G("flex gap-1 border-b border-zinc-200 dark:border-zinc-800",t),children:e})}function kw({value:e,children:t,className:n,ref:r}){return x.jsx(vLe,{ref:r,value:e,className:G("flex items-center gap-1.5 border-b-2 px-3 py-2 text-sm transition-colors outline-none","border-transparent text-zinc-500","hover:text-zinc-950 dark:hover:text-zinc-50","focus-visible:ring-2 focus-visible:ring-sky-500/30","data-[selected]:border-sky-600 data-[selected]:text-zinc-950","dark:data-[selected]:text-zinc-50",n),children:t})}function Zo({value:e,children:t,className:n}){return x.jsx(SLe,{value:e,className:G("outline-none",n),children:t})}const gr="text-zinc-400 dark:text-zinc-500",ha="border-zinc-200 dark:border-zinc-800",B6="bg-white dark:bg-zinc-900";function _Le({title:e="Connectors",eyebrow:t="Ingestion",intro:n="A source, code that reshapes it, and a snapshot at the end. Running one goes through exactly the same append-and-commit a publisher uses, so there is one way rows arrive rather than two.",canEdit:r=!0}){var l;const i=br(),[o,s]=A.useState("connectors"),{data:a}=Jt({queryKey:Yt.capabilities,queryFn:()=>i.pipelineCapabilities(),staleTime:Number.POSITIVE_INFINITY});return x.jsx(ru,{children:x.jsx("div",{className:"h-full overflow-y-auto",children:x.jsxs("div",{className:"mx-auto max-w-5xl px-8 py-8",children:[x.jsx("p",{className:G("font-mono text-[11px] uppercase tracking-[0.18em]",gr),children:t}),x.jsx("h1",{className:"mt-1 text-2xl font-semibold tracking-tight",children:e}),x.jsx("p",{className:"mt-1 max-w-2xl text-sm text-zinc-500 dark:text-zinc-400",children:n}),x.jsxs(Ase,{value:o,onValueChange:s,className:"mt-6",children:[x.jsxs(Tse,{children:[x.jsxs(kw,{value:"connections",children:[x.jsx(Nm,{size:13}),"Connections"]}),x.jsxs(kw,{value:"connectors",children:[x.jsx(nye,{size:13}),"Connectors"]}),x.jsxs(kw,{value:"transforms",children:[x.jsx(Zb,{size:13}),"Transforms"]}),x.jsx(ht,{content:(l=a==null?void 0:a.pythonPackages)!=null&&l.length?`Python transforms may import ${a.pythonPackages.join(", ")} — provisioned by the image, not by this service.`:"Which languages this deployment can actually execute.",children:x.jsx("span",{className:G("ml-auto cursor-help self-center font-mono text-[10px]",gr),children:a?`runs ${a.languages.join(" · ")}`:"checking…"})})]}),x.jsx(Zo,{value:"connections",children:x.jsx(q4e,{canEdit:r})}),x.jsx(Zo,{value:"connectors",children:x.jsx(OLe,{canEdit:r})}),x.jsx(Zo,{value:"transforms",children:x.jsx($Le,{canEdit:r,languages:(a==null?void 0:a.languages)??["javascript"],pythonPackages:(a==null?void 0:a.pythonPackages)??[]})})]})]})})})}function OLe({canEdit:e}){var f,d;const t=br(),n=ps(),[r,i]=A.useState(null),o=Jt({queryKey:Yt.connectors,queryFn:()=>t.listConnectors()}),{data:s=[]}=Jt({queryKey:Yt.transforms,queryFn:()=>t.listTransforms(),staleTime:3e4}),{data:a=[]}=Jt({queryKey:Yt.connections,queryFn:()=>t.listConnections(),staleTime:3e4}),l=()=>{n.invalidateQueries({queryKey:Yt.connectors}),n.invalidateQueries({queryKey:Yt.runs()}),n.invalidateQueries({queryKey:Yt.snapshot})},u=Un({mutationFn:p=>t.runConnector(p),onSuccess:l});return r?x.jsx(zLe,{connector:r==="new"?void 0:r,transforms:s,connections:a,onClose:()=>i(null),onSaved:()=>{i(null),n.invalidateQueries({queryKey:Yt.connectors})}}):x.jsxs("div",{className:"mt-6 space-y-3",children:[e&&x.jsxs("button",{type:"button",onClick:()=>i("new"),className:G("flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs",ha,"hover:bg-zinc-50 dark:hover:bg-zinc-800"),children:[x.jsx(Jb,{size:12}),"New connector"]}),o.isPending&&x.jsx("p",{className:G("rounded-lg border border-dashed px-4 py-12 text-center text-sm",ha,gr),children:"Reading connectors…"}),o.isError&&x.jsxs("div",{className:"rounded-lg border border-red-200 bg-red-50 px-4 py-6 text-center dark:border-red-900 dark:bg-red-950/40",children:[x.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:o.error instanceof Error?o.error.message:"Could not read the connectors."}),x.jsx("button",{type:"button",onClick:()=>o.refetch(),className:"mt-2 rounded-md border border-red-300 px-3 py-1 text-xs text-red-700 dark:border-red-800 dark:text-red-300",children:"Try again"})]}),((f=o.data)==null?void 0:f.length)===0&&x.jsx("p",{className:G("rounded-lg border border-dashed px-4 py-12 text-center text-sm",ha,gr),children:"No connectors yet."}),(d=o.data)==null?void 0:d.map(p=>x.jsx(jLe,{connector:p,canEdit:e,transform:s.find(m=>m.id===p.transformId),connection:a.find(m=>m.id===p.connectionId),running:u.isPending&&u.variables===p.id,onRun:()=>u.mutate(p.id),onEdit:()=>i(p),onDeleted:l},p.id))]})}function Fl(e,t){const n=e[t];return typeof n=="string"?n:""}function MLe(e,t){if(t)return`${t}${Fl(e,"prefix")||"(whole bucket)"}`;const n=Fl(e,"bucket");return n?`s3://${n}/${Fl(e,"prefix")}`:"no bucket configured"}function NLe(e,t){const n=Fl(e,"watermarkColumn"),r=Fl(e,"query").replace(/\s+/g," ").trim(),i=r.length>70?`${r.slice(0,70)}…`:r;return`${t}${n?`${i} · since ${n}`:i}`}function RLe(e,t){const n=Fl(e,"path");return t?`${t}${n||"/"}`:`${Fl(e,"url")}${n?` · ${n}`:""}`}function DLe(e,t){const n=e.config??{},r=t?`${t.name} · `:"";if(e.kind==="s3")return MLe(n,r);if(e.kind==="sql")return NLe(n,r);if(e.kind==="file")return Fl(n,"path")||Fl(n,"url")||"no path configured";if(e.kind==="inline"){const i=n.records;return`${Array.isArray(i)?i.length:0} pasted records`}return RLe(n,r)}function jLe({connector:e,transform:t,connection:n,canEdit:r,running:i,onRun:o,onEdit:s,onDeleted:a}){const l=br(),[u,f]=A.useState(!1),{data:d=[]}=Jt({queryKey:Yt.runs(e.id),queryFn:()=>l.listRuns(e.id)}),p=Un({mutationFn:()=>l.deleteConnector(e.id),onSuccess:()=>{f(!1),a()}});return x.jsxs("div",{className:G("rounded-lg border p-4",ha,B6),children:[x.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[x.jsxs("div",{className:"min-w-0",children:[x.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[x.jsx("span",{className:"text-sm font-medium",children:e.name}),x.jsx("span",{className:"rounded-sm bg-zinc-100 px-1.5 py-0.5 font-mono text-[10px] uppercase dark:bg-zinc-800",children:e.kind}),x.jsxs("span",{className:G("font-mono text-[10px]",gr),children:["→ ",e.targetType]}),n&&x.jsx(ht,{content:`Reads through the ${n.name} connection, which supplies the address and the credential. Moving that connection moves this connector with it.`,children:x.jsxs("span",{className:G("flex cursor-help items-center gap-1 font-mono text-[10px]",gr),children:[x.jsx(Nm,{size:10}),n.name]})}),e.mode==="incremental"&&x.jsx(ht,{content:"Reads only what changed since the last run, and carries the rest forward.",children:x.jsxs("span",{className:G("flex cursor-help items-center gap-1 font-mono text-[10px]",gr),children:[x.jsx(jI,{size:10}),"incremental"]})}),!e.enabled&&x.jsx("span",{className:"rounded-sm bg-zinc-100 px-1.5 py-0.5 font-mono text-[10px] uppercase text-zinc-500 dark:bg-zinc-800",children:"disabled"})]}),x.jsx("div",{className:G("mt-1 font-mono text-[11px]",gr),children:DLe(e,n)}),e.secretEnvVar&&x.jsx(ht,{content:"The catalog stores the NAME of this variable, never its value. A leaked catalog database gives away the shape of the integration, not the keys to it.",children:x.jsxs("div",{className:G("mt-1 flex w-fit cursor-help items-center gap-1 font-mono text-[10px]",gr),children:[x.jsx(C2,{size:10}),e.secretEnvVar]})})]}),x.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[x.jsxs("button",{type:"button",onClick:o,disabled:i||!e.enabled,className:"flex items-center gap-1.5 rounded-md bg-zinc-950 px-3 py-1.5 text-xs text-zinc-50 disabled:opacity-40 dark:bg-zinc-100 dark:text-zinc-950",children:[i?x.jsx(Rc,{size:12,className:"animate-spin"}):x.jsx(Qb,{size:12}),i?"Running…":"Run now"]}),r&&x.jsx(ht,{content:`Delete ${e.name}`,children:x.jsx("button",{type:"button",onClick:()=>f(!0),"aria-label":`Delete ${e.name}`,className:G("rounded-sm p-1.5 hover:text-red-600",gr),children:x.jsx(eu,{size:12})})})]})]}),t&&x.jsxs("button",{type:"button",onClick:s,className:G("mt-3 flex items-center gap-1.5 text-[11px]",gr,"hover:text-sky-600"),children:[x.jsx(Zb,{size:11}),t.name,x.jsxs("span",{className:"font-mono",children:[t.language," · v",t.version]})]}),d.length>0&&x.jsxs("div",{className:G("mt-3 border-t pt-3",ha),children:[x.jsx("div",{className:G("mb-1.5 font-mono text-[10px] uppercase tracking-[0.14em]",gr),children:"Recent runs"}),x.jsx("div",{className:"space-y-1",children:d.slice(0,4).map(m=>x.jsx(ht,{content:m.error?x.jsx("span",{className:"font-mono text-[11px]",children:m.error}):x.jsx("span",{className:"font-mono text-[11px]",children:m.logs.slice(-3).join(`
588
588
  `)||"No logs."}),children:x.jsxs("div",{className:"flex cursor-help items-center gap-2 text-[11px]",children:[x.jsxs("span",{className:"sr-only",children:[m.status,": "]}),m.status==="succeeded"?x.jsx(Mm,{size:11,"aria-hidden":!0,className:"text-emerald-600"}):m.status==="failed"?x.jsx(RI,{size:11,"aria-hidden":!0,className:"text-red-600"}):x.jsx(Rc,{size:11,"aria-hidden":!0,className:"animate-spin text-sky-600"}),x.jsx("span",{className:"font-mono",children:m.snapshotId}),x.jsxs("span",{className:gr,children:[m.fetched," fetched · ",m.written," written",m.transformVersion?` · code v${m.transformVersion}`:""]}),x.jsx("span",{className:G("ml-auto font-mono text-[10px]",gr),children:new Date(m.startedAt).toLocaleTimeString()})]})},m.id))})]}),x.jsx(AE,{open:u,onOpenChange:f,title:`Delete ${e.name}?`,description:"The snapshots it already wrote stay where they are — this removes the connector, its schedule and its incremental watermark. Recreating it later starts reading from the beginning again.",confirmLabel:p.isPending?"Deleting…":"Delete",pending:p.isPending,onConfirm:()=>p.mutate(),error:p.error?p.error instanceof Error?p.error.message:"Could not delete it.":void 0})]})}function PLe({value:e,options:t,viaConnection:n,onChange:r}){return x.jsx(Fi,{label:"Read through",ariaLabel:"Connection",value:e,onValueChange:r,options:[{value:Sl,label:"Configure the address here",hint:"This connector alone"},...t],hint:ILe(t.length,n)})}function ILe(e,t){if(e===0)return"No connections of this kind yet. One is worth making when a second connector needs the same address.";if(t)return"The connection supplies the address and the credential. What stays below is only what is specific to this load."}function LLe({editing:e,pending:t,incomplete:n,error:r,onClose:i}){return x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("button",{type:"submit",disabled:t||n,className:"rounded-md bg-zinc-950 px-3 py-1.5 text-xs text-zinc-50 disabled:opacity-40 dark:bg-zinc-100 dark:text-zinc-950",children:t?"Saving…":e?"Save changes":"Save connector"}),x.jsx("button",{type:"button",onClick:i,className:G("rounded-md px-3 py-1.5 text-xs",gr),children:"Cancel"})]}),r?x.jsx("p",{className:"text-[11px] text-red-600",children:r instanceof Error?r.message:"Could not save."}):null]})}function zLe({connector:e,transforms:t,connections:n,onClose:r,onSaved:i}){const o=br(),[s,a]=A.useState(sy((e==null?void 0:e.kind)??"http")),[l,u]=A.useState((e==null?void 0:e.connectionId)??Sl),[f,d]=A.useState((e==null?void 0:e.mode)==="incremental"?"incremental":"full"),[p,m]=A.useState((e==null?void 0:e.enabled)??!0),[g,b]=A.useState(()=>bse(e==null?void 0:e.config)),[v,w]=A.useState({name:(e==null?void 0:e.name)??"",targetType:(e==null?void 0:e.targetType)??"",secretEnvVar:(e==null?void 0:e.secretEnvVar)??"",transformId:(e==null?void 0:e.transformId)??""}),k=uk(s)&&f==="incremental",E=iLe(s,n),C=E.some(N=>N.value===l)?l:Sl,T=C!==Sl,_=$6(g.records),M=Un({mutationFn:()=>{if(s==="inline"&&!_.ok)return Promise.reject(new Error(_.message));const N=vse(s,g,{viaConnection:T,incremental:k}),P={id:e==null?void 0:e.id,name:v.name.trim(),kind:s,targetType:v.targetType.trim(),config:N,...T?{connectionId:C}:{},mode:k?"incremental":"full",...T||!v.secretEnvVar.trim()?{}:{secretEnvVar:v.secretEnvVar.trim()},...v.transformId?{transformId:v.transformId}:{},enabled:p};return o.saveConnector(P)},onSuccess:i}),R=v.name.trim().length===0||v.targetType.trim().length===0||hLe(s,g,T);return x.jsxs("form",{className:G("mt-6 space-y-4 rounded-lg border p-4",ha,B6),onSubmit:N=>{N.preventDefault(),M.mutate()},children:[x.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[x.jsx(an,{label:"Name",value:v.name,onChange:N=>w({...v,name:N}),placeholder:"Nightly fleet load"}),x.jsx(an,{label:"Target object type",value:v.targetType,onChange:N=>w({...v,targetType:N}),placeholder:"e.g. Mvr"}),x.jsx(Fi,{label:"Source kind",ariaLabel:"Source kind",value:s,onValueChange:N=>a(sy(N)),options:yse})]}),gse(s)&&x.jsx(PLe,{value:C,options:E,viaConnection:T,onChange:u}),x.jsx(xse,{kind:s,draft:g,onChange:b,viaConnection:T}),x.jsx(wse,{kind:s,mode:f,onModeChange:d,draft:g,onChange:b}),x.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[!T&&x.jsx(Sse,{kind:s,value:v.secretEnvVar,onChange:N=>w({...v,secretEnvVar:N})}),x.jsx(Fi,{label:"Transform",ariaLabel:"Transform",value:v.transformId,onValueChange:N=>w({...v,transformId:N}),options:[{value:"",label:"No transform",hint:"Store records as they arrive"},...t.map(N=>({value:N.id,label:N.name,hint:`${N.language} · v${N.version}`}))]})]}),x.jsx(z6,{checked:p,onCheckedChange:m,label:"Enabled",hint:"A disabled connector keeps its configuration and its watermark, and refuses to run."}),x.jsx(LLe,{editing:e!==void 0,pending:M.isPending,incomplete:R,error:M.error,onClose:r})]})}function $Le({canEdit:e,languages:t,pythonPackages:n}){var d,p;const r=br(),i=ps(),[o,s]=A.useState(null),[a,l]=A.useState(null),u=Jt({queryKey:Yt.transforms,queryFn:()=>r.listTransforms()}),f=Un({mutationFn:m=>r.deleteTransform(m),onSuccess:()=>{l(null),i.invalidateQueries({queryKey:Yt.transforms})}});return o?x.jsx(mse,{transform:o==="new"?void 0:o,languages:t,pythonPackages:n,onClose:()=>s(null),onSaved:()=>{s(null),i.invalidateQueries({queryKey:Yt.transforms})}}):x.jsxs("div",{className:"mt-6 space-y-3",children:[e&&x.jsxs("button",{type:"button",onClick:()=>s("new"),className:G("flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs",ha,"hover:bg-zinc-50 dark:hover:bg-zinc-800"),children:[x.jsx(Jb,{size:12}),"New transform"]}),u.isPending&&x.jsx("p",{className:G("rounded-lg border border-dashed px-4 py-12 text-center text-sm",ha,gr),children:"Reading transforms…"}),u.isError&&x.jsxs("div",{className:"rounded-lg border border-red-200 bg-red-50 px-4 py-6 text-center dark:border-red-900 dark:bg-red-950/40",children:[x.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:u.error instanceof Error?u.error.message:"Could not read the transforms."}),x.jsx("button",{type:"button",onClick:()=>u.refetch(),className:"mt-2 rounded-md border border-red-300 px-3 py-1 text-xs text-red-700 dark:border-red-800 dark:text-red-300",children:"Try again"})]}),((d=u.data)==null?void 0:d.length)===0&&x.jsx("p",{className:G("rounded-lg border border-dashed px-4 py-12 text-center text-sm",ha,gr),children:"No transforms yet. Without one, a connector stores records exactly as they arrive."}),(p=u.data)==null?void 0:p.map(m=>x.jsxs("div",{className:G("flex items-start gap-3 rounded-lg border p-4",ha,B6),children:[x.jsx(Zb,{size:14,className:G("mt-0.5 shrink-0",gr)}),x.jsxs("button",{type:"button",onClick:()=>s(m),className:"min-w-0 flex-1 text-left",children:[x.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[x.jsx("span",{className:"text-sm font-medium",children:m.name}),x.jsx("span",{className:"rounded-sm bg-zinc-100 px-1.5 py-0.5 font-mono text-[10px] dark:bg-zinc-800",children:m.language}),x.jsx(ht,{content:"Bumped only when the code changed, so it stays useful for tracing a surprising load back to what ran.",children:x.jsxs("span",{className:G("cursor-help font-mono text-[10px]",gr),children:["v",m.version]})})]}),m.description&&x.jsx("p",{className:G("mt-0.5 text-[11px]",gr),children:m.description})]}),e&&x.jsx(ht,{content:`Delete ${m.name}`,children:x.jsx("button",{type:"button",onClick:()=>l(m),"aria-label":`Delete ${m.name}`,className:G("rounded-sm p-1 hover:text-red-600",gr),children:x.jsx(eu,{size:12})})})]},m.id)),x.jsx(AE,{open:a!==null,onOpenChange:m=>{m||l(null)},title:a?`Delete ${a.name}?`:"",description:"Any connector pointing at it will store records exactly as they arrive from now on, which is rarely what its target type expects. Every past version goes with it, so a surprising load can no longer be traced to the code that ran.",confirmLabel:f.isPending?"Deleting…":"Delete",pending:f.isPending,onConfirm:()=>{a&&f.mutate(a.id)},error:f.error?f.error instanceof Error?f.error.message:"Could not delete it.":void 0})]})}const Ai="text-zinc-400 dark:text-zinc-500",Bc="border-zinc-200 dark:border-zinc-800",bv="bg-white dark:bg-zinc-900";function FLe({value:e,onChange:t}){return x.jsxs("label",{className:"mt-3 block",children:[x.jsx("span",{className:"sr-only",children:"Search people"}),x.jsx("input",{type:"search",value:e,onChange:n=>t(n.target.value),placeholder:"Search by name or email",className:G("w-full rounded-md border px-3 py-1.5 text-sm",Bc,bv,"placeholder:text-zinc-400 dark:placeholder:text-zinc-600")})]})}function BLe({page:e,onOffset:t,busy:n}){const r=e.people.length,i=e.total===0?0:e.offset+1,o=e.offset+r,s=o<e.total;return x.jsxs("div",{className:G("mt-3 flex items-center justify-between text-xs",Ai),children:[x.jsx("span",{children:e.total===0?"No people":`Showing ${i}–${o} of ${e.total.toLocaleString()}`}),(e.offset>0||s)&&x.jsxs("span",{className:"flex gap-2",children:[x.jsx("button",{type:"button",disabled:e.offset===0||n,onClick:()=>t(Math.max(0,e.offset-e.limit)),className:"disabled:opacity-40",children:"Previous"}),x.jsx("button",{type:"button",disabled:!s||n,onClick:()=>t(e.offset+e.limit),className:"disabled:opacity-40",children:"Next"})]})]})}function VLe({identity:e,onSignOut:t,signOutPending:n,canAddPeople:r,title:i="Access",eyebrow:o="Governance",intro:s="Two kinds of caller reach this catalog. Applications hold keys and act on their own behalf. People sign in and act through an application, and can never do more than both of them may."}){var b,v,w,k;const a=br(),l=Jt({queryKey:Yt.principals,queryFn:()=>a.listPrincipals(),staleTime:3e4}),[u,f]=A.useState(""),[d,p]=A.useState(0),m=Jt({queryKey:[...Yt.people,{search:u,offset:d}],queryFn:()=>a.listPeople({...u?{search:u}:{},offset:d}),staleTime:3e4,placeholderData:E=>E}),g=r??(e==null?void 0:e.scopes.includes("catalog:admin"))??!1;return x.jsx(ru,{children:x.jsxs("div",{className:"mx-auto max-w-5xl px-8 py-8",children:[x.jsx("p",{className:G("font-mono text-[11px] uppercase tracking-[0.18em]",Ai),children:o}),x.jsx("h1",{className:"mt-1 text-2xl font-semibold tracking-tight",children:i}),x.jsx("p",{className:"mt-1 max-w-2xl text-sm text-zinc-500 dark:text-zinc-400",children:s}),e&&x.jsx(qLe,{identity:e,onSignOut:t,signOutPending:n}),x.jsxs(HV,{title:"People",note:"Sign in to the console. Capped by the application they sign in through.",children:[x.jsx(FLe,{value:u,onChange:E=>{f(E),p(0)}}),g&&x.jsx(KLe,{}),m.isPending&&x.jsx(o0,{children:"Reading people…"}),m.isError&&x.jsx(UV,{message:m.error instanceof Error?m.error.message:"Could not read the people list.",onRetry:()=>m.refetch()}),(b=m.data)==null?void 0:b.people.map(E=>x.jsx(HLe,{person:E},E.email)),((v=m.data)==null?void 0:v.people.length)===0&&(u?x.jsxs(o0,{children:["Nobody matches “",u,"”."]}):x.jsx(o0,{children:"Nobody can sign in yet. Seed the first administrator from the environment before anybody can reach this console as a person."})),m.data&&x.jsx(BLe,{page:m.data,onOffset:p,busy:m.isFetching})]}),x.jsxs(HV,{title:"Applications",note:"Provisioned by an operator — a console that could hand grants out is one that stops leaving a trail.",children:[l.isPending&&x.jsx(o0,{children:"Reading applications…"}),l.isError&&x.jsx(UV,{message:l.error instanceof Error?l.error.message:"Could not read the application list.",onRetry:()=>l.refetch()}),(w=l.data)==null?void 0:w.map(E=>x.jsx(YLe,{principal:E},E.id)),((k=l.data)==null?void 0:k.length)===0&&x.jsx(o0,{children:"No applications are provisioned."})]})]})})}function qLe({identity:e,onSignOut:t,signOutPending:n}){const r=e.actor===null;return x.jsxs("div",{className:G("mt-6 rounded-lg border p-4",bv,r?"border-amber-500/40":Bc),children:[x.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[x.jsxs("div",{className:"min-w-0",children:[x.jsx("div",{className:G("font-mono text-[10px] uppercase tracking-[0.14em]",Ai),children:r?"Acting as an application":"Signed in"}),x.jsxs("div",{className:"mt-1 flex items-center gap-2 text-sm font-medium",children:[r?x.jsx(C2,{size:14}):x.jsx(wbe,{size:14}),e.displayName]}),x.jsxs("div",{className:G("mt-1 font-mono text-[11px]",Ai),children:["recorded as ",e.principalId]}),r&&x.jsx("p",{className:"mt-2 max-w-md text-xs text-amber-600",children:"Nothing you do here will name you. This is the application-key path, kept for local development — sign in to be attributable."})]}),x.jsxs("div",{className:"flex items-center gap-4",children:[e.session&&x.jsxs("span",{className:G("font-mono text-[11px]",Ai),children:["expires ",new Date(e.session.expiresAt).toLocaleTimeString()," · idle"," ",e.session.idleMinutes,"m"]}),!r&&t&&x.jsxs("button",{type:"button",onClick:t,disabled:n,className:G("flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs disabled:opacity-40",Bc,"hover:bg-zinc-50 dark:hover:bg-zinc-800"),children:[x.jsx(qye,{size:13}),n?"Signing out…":"Sign out"]})]})]}),x.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:[x.jsx(Co,{label:"Effective scopes",values:e.scopes,tone:"neutral"}),x.jsx(Co,{label:"May write",values:e.writeTypes,tone:"write",emptyNote:"nothing"}),x.jsx(Co,{label:"May read",values:e.readTypes??["every type"],tone:"neutral"}),x.jsx(Co,{label:"May see",values:e.classifications,tone:"classified",emptyNote:"nothing classified"})]})]})}function HLe({person:e}){return x.jsxs("div",{className:G("rounded-lg border p-4",Bc,bv),children:[x.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[x.jsxs("div",{className:"min-w-0",children:[x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("span",{className:"text-sm font-medium",children:e.displayName}),x.jsx("span",{className:"rounded-sm bg-zinc-100 px-1.5 py-0.5 font-mono text-[10px] uppercase text-zinc-500 dark:bg-zinc-800",children:e.role}),!e.active&&x.jsx("span",{className:"rounded-sm bg-red-100 px-1.5 py-0.5 font-mono text-[10px] uppercase text-red-600 dark:bg-red-950",children:"disabled"})]}),x.jsx("div",{className:G("mt-0.5 font-mono text-[11px]",Ai),children:e.principalId})]}),x.jsxs("div",{className:G("flex items-center gap-4 font-mono text-[11px]",Ai),children:[x.jsx(ht,{content:"Sessions currently alive — not expired, not idled out, not revoked.",children:x.jsxs("span",{className:"cursor-help",children:[e.liveSessions," live"]})}),x.jsx("span",{children:e.lastLoginAt?`last in ${new Date(e.lastLoginAt).toLocaleString()}`:"never signed in"})]})]}),x.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:[x.jsx(Co,{label:"Effective scopes",values:e.effective.scopes,tone:"neutral",emptyNote:"nothing"}),x.jsx(Co,{label:"May write",values:e.effective.writeTypes,tone:"write",emptyNote:"nothing"}),x.jsx(Co,{label:"May read",values:e.effective.readTypes??["every type"],tone:"neutral"}),x.jsx(Co,{label:"May see",values:e.effective.classifications,tone:"classified",emptyNote:"nothing classified"})]})]})}const ULe=[{value:"viewer",label:"viewer",hint:"read"},{value:"curator",label:"curator",hint:"read, curate"},{value:"admin",label:"admin",hint:"read, curate, administer"}];function WLe(e){return e==="curator"||e==="admin"?e:"viewer"}function KLe(){const e=br(),t=ps(),[n,r]=A.useState(!1),[i,o]=A.useState(""),[s,a]=A.useState(""),[l,u]=A.useState("viewer"),[f,d]=A.useState(""),p=Un({mutationFn:()=>e.upsertPerson({email:i.trim(),displayName:s.trim()||i.trim(),role:l,password:f}),onSuccess:()=>{o(""),a(""),d(""),r(!1),t.invalidateQueries({queryKey:Yt.people})}});return n?x.jsxs("form",{className:G("rounded-lg border p-4",Bc,bv),onSubmit:m=>{m.preventDefault(),p.mutate()},children:[x.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[x.jsx(an,{label:"Email",type:"email",value:i,onChange:o,placeholder:"someone@example.mil"}),x.jsx(an,{label:"Display name",value:s,onChange:a,placeholder:"Defaults to the email"}),x.jsx(Fi,{label:"Role",ariaLabel:"Role",value:l,onValueChange:m=>u(WLe(m)),options:ULe}),x.jsx(an,{label:"Password",type:"password",value:f,onChange:d,placeholder:"12 characters or more",autoComplete:"new-password"})]}),p.isError&&x.jsx("p",{className:"mt-2 text-xs text-red-600",children:p.error instanceof Error?p.error.message:"Could not save."}),x.jsx("p",{className:G("mt-2 text-xs",Ai),children:"No role carries permission to load a snapshot. Publishing is something an application does from a pipeline, with a retryable snapshot id."}),x.jsxs("div",{className:"mt-3 flex gap-2",children:[x.jsx("button",{type:"submit",disabled:p.isPending||i.trim().length===0||f.length<12,className:"rounded-md bg-zinc-950 px-3 py-1.5 text-xs text-zinc-50 disabled:opacity-40 dark:bg-zinc-100 dark:text-zinc-950",children:p.isPending?"Saving…":"Save"}),x.jsx("button",{type:"button",onClick:()=>r(!1),className:G("rounded-md px-3 py-1.5 text-xs",Ai),children:"Cancel"})]})]}):x.jsx("button",{type:"button",onClick:()=>r(!0),className:G("rounded-lg border border-dashed px-4 py-3 text-left text-sm",Bc,Ai,"hover:text-zinc-600 dark:hover:text-zinc-300"),children:"+ Add someone"})}const GLe={token:{icon:sbe,tone:"text-emerald-600",hint:"Authenticates with an access token — rotation and revocation belong to the identity provider."},key:{icon:C2,tone:"text-amber-600",hint:"Authenticates with a long-lived static key, revoked only by editing its row."},session:{icon:lbe,tone:"text-sky-600",hint:"Holds no credential of its own. Reachable only by a person signing in, and it caps what any of them can do."}};function YLe({principal:e}){const t=GLe[e.authMethod],n=t.icon;return x.jsxs("div",{className:G("rounded-lg border p-4",Bc,bv),children:[x.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[x.jsxs("div",{className:"min-w-0",children:[x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("span",{className:"text-sm font-medium",children:e.displayName}),!e.active&&x.jsx("span",{className:"rounded-sm bg-zinc-100 px-1.5 py-0.5 font-mono text-[10px] uppercase text-zinc-500 dark:bg-zinc-800",children:"disabled"})]}),x.jsx("div",{className:G("mt-0.5 font-mono text-[11px]",Ai),children:e.id})]}),x.jsxs("div",{className:"flex items-center gap-4",children:[x.jsx(ht,{content:t.hint,children:x.jsxs("span",{className:G("flex cursor-help items-center gap-1.5 font-mono text-[10px] uppercase tracking-wider",t.tone),children:[x.jsx(n,{size:13}),e.authMethod]})}),x.jsx("span",{className:G("font-mono text-[11px]",Ai),children:e.lastSeenAt?`seen ${new Date(e.lastSeenAt).toLocaleString()}`:"never seen"})]})]}),x.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:[x.jsx(Co,{label:"Scopes",values:e.scopes,tone:"neutral"}),x.jsx(Co,{label:"May write",values:e.writeTypes,tone:"write",emptyNote:"nothing"}),x.jsx(Co,{label:"May read",values:e.readTypes??["every type"],tone:"neutral"}),x.jsx(Co,{label:"Owns",values:e.ownedTypes,tone:"own",emptyNote:"no types published"})]}),e.classifications.length>0&&x.jsx("div",{className:"mt-3",children:x.jsx(Co,{label:"May see",values:e.classifications,tone:"classified"})})]})}function HV({title:e,note:t,children:n}){return x.jsxs("div",{className:"mt-10",children:[x.jsx("h2",{className:"text-sm font-semibold tracking-tight",children:e}),x.jsx("p",{className:G("mt-0.5 max-w-2xl text-xs",Ai),children:t}),x.jsx("div",{className:"mt-3 flex flex-col gap-3",children:n})]})}function o0({children:e}){return x.jsx("p",{className:G("rounded-lg border border-dashed px-4 py-8 text-center text-sm",Bc,Ai),children:e})}function UV({message:e,onRetry:t}){return x.jsxs("div",{className:"rounded-lg border border-red-200 bg-red-50 px-4 py-6 text-center dark:border-red-900 dark:bg-red-950/40",children:[x.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:e}),x.jsx("button",{type:"button",onClick:t,className:"mt-2 rounded-md border border-red-300 px-3 py-1 text-xs text-red-700 dark:border-red-800 dark:text-red-300",children:"Try again"})]})}const XLe={neutral:"bg-zinc-100 text-zinc-600 dark:bg-zinc-800 dark:text-zinc-300",write:"bg-sky-100 text-sky-700 dark:bg-sky-950 dark:text-sky-300",own:"bg-emerald-100 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300",classified:"bg-amber-100 text-amber-700 dark:bg-amber-950 dark:text-amber-300"};function Co({label:e,values:t,tone:n,emptyNote:r="—"}){return x.jsxs("div",{children:[x.jsx("div",{className:G("font-mono text-[10px] uppercase tracking-[0.14em]",Ai),children:e}),x.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:t.length===0?x.jsx("span",{className:G("text-xs italic",Ai),children:r}):t.map(i=>x.jsx("span",{className:G("rounded-sm px-1.5 py-0.5 font-mono text-[10px]",XLe[n]),children:i},i))})]})}function ZLe(e){return e?e.available?{state:"durable",label:e.engine?`checkpointing: ${e.engine}`:"checkpointing: on",detail:"Every node runs as its own durable step. A ten-node graph that fails at node seven resumes at node seven — the first six are not re-run, and whatever they wrote is not written twice."}:{state:"inline",label:"checkpointing: off",detail:"No durable engine is available here, so the whole graph runs inline in one process. A failure at node seven re-runs the graph from node one, and nothing between nodes is checkpointed."}:{state:"unknown",label:"checkpointing: not reported",detail:'This deployment did not say whether a durable engine is wired up. Assume there is none: a run that fails part-way will start again from the beginning. Treating silence as "resumable" is how a graph gets built that nobody can restart.'}}function QLe(e){const t=typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`,n=`${e}_${t}`;return jn.WORKFLOW_NODE_ID_PATTERN.test(n)?n:`${e.replace(/[^A-Za-z0-9_-]/g,"")}_${t}`.slice(0,64)}function no(e){return typeof e.name=="string"&&e.name.trim().length>0?e.name.trim():e.id}function WV(e){const t=[];for(const n of e){if(n.kind!=="sink")continue;const r=typeof n.targetType=="string"?n.targetType.trim():"";r.length>0&&!t.includes(r)&&t.push(r)}return t}const to={singular:"workflow",plural:"workflows",title:"Workflow",titlePlural:"Workflows"};function JLe(e,t,n){if(e!=="cycle"&&e!=="self-edge"&&e!=="duplicate-edge")return[];const r=new Set(t);return n.filter(i=>r.has(i.from)&&r.has(i.to)).map(i=>hd(i))}function hd(e){return`${e.from}->${e.to}`}function e8e(e,t){const{nodes:n,edges:r}=e,i=[];for(const o of jn.validateWorkflow({nodes:n,edges:r}))i.push({level:"error",code:o.code,message:o.message,nodeIds:o.nodeIds,edgeIds:JLe(o.code,o.nodeIds,r)});for(const o of n){const s=no(o);if(o.kind==="transform"){o.transformId.length>0&&!t.transformIds.has(o.transformId)&&i.push({level:"error",code:"missing-transform",message:`"${s}" points at a transform that no longer exists. It was probably deleted from the Transforms tab.`,nodeIds:[o.id],edgeIds:[]});continue}if(o.kind!=="sink")continue;(typeof o.targetType=="string"?o.targetType.trim():"").length===0&&i.push({level:"error",code:"sink-has-no-type",message:`"${s}" does not say which object type it writes, so there would be nothing for the run to commit into. The type is chosen on the sink because the sink is the node that commits.`,nodeIds:[o.id],edgeIds:[]})}return i}function t8e(e,t,n){if(t===n)return!0;const r=new Map;for(const s of e)r.set(s.from,[...r.get(s.from)??[],s.to]);const i=new Set([n]),o=[n];for(;o.length>0;){const s=o.pop();if(s===void 0)break;for(const a of r.get(s)??[]){if(a===t)return!0;i.has(a)||(i.add(a),o.push(a))}}return!1}function Ew(e,t,n,r){if(n===r)return{ok:!1,reason:"A node cannot feed itself."};const i=e.find(s=>s.id===n),o=e.find(s=>s.id===r);return!i||!o?{ok:!1,reason:"One end of that connection is not a node."}:i.kind==="sink"?{ok:!1,reason:`"${no(i)}" commits its rows. Nothing runs after a sink.`}:o.kind==="source"?{ok:!1,reason:`"${no(o)}" reads from a system, so nothing can feed into it.`}:t.some(s=>s.from===n&&s.to===r)?{ok:!1,reason:`Those two are already wired together, and wiring them twice would send "${no(o)}" the same rows twice.`}:t8e(t,n,r)?{ok:!1,reason:`That would close a loop: "${no(o)}" already feeds "${no(i)}", directly or through other nodes. A ${to.singular} that loops has no order to run in.`}:{ok:!0}}function n8e(e){return e.some(t=>t.level==="error")}function r8e(e){const t=new Map;for(const n of e)for(const r of n.nodeIds){const i=t.get(r)??[];i.push(n),t.set(r,i)}return t}function _se({open:e,onOpenChange:t,title:n,description:r,width:i="narrow",modal:o=!0,children:s}){return x.jsx(qoe,{open:e,onOpenChange:t,modal:o,children:x.jsxs(Boe,{children:[o&&x.jsx(Moe,{className:G("fixed inset-0 z-40 bg-zinc-950/20 dark:bg-zinc-950/50","transition-opacity duration-150","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0")}),x.jsxs($oe,{className:G("fixed inset-y-0 right-0 z-50 flex flex-col border-l shadow-xl outline-none","border-zinc-200 bg-white dark:border-zinc-800 dark:bg-zinc-900",i==="wide"?"w-[min(64rem,calc(100vw-2rem))]":"w-[min(24rem,calc(100vw-2rem))]","transition-transform duration-200 ease-out","data-[starting-style]:translate-x-full data-[ending-style]:translate-x-full"),children:[x.jsxs("div",{className:"flex items-start gap-3 border-b border-zinc-200 px-4 py-3 dark:border-zinc-800",children:[x.jsxs("div",{className:"min-w-0 flex-1",children:[x.jsx(Hoe,{className:"truncate text-sm font-semibold tracking-tight",children:n}),r&&x.jsx(joe,{className:"mt-0.5 text-[11px] leading-relaxed text-zinc-500 dark:text-zinc-400",children:r})]}),x.jsx(ht,{content:"Close (Esc)",children:x.jsx(Doe,{"aria-label":"Close",className:G("rounded-md p-1 text-zinc-400 outline-none","hover:bg-zinc-100 hover:text-zinc-900","focus-visible:ring-2 focus-visible:ring-sky-500/30","dark:hover:bg-zinc-800 dark:hover:text-zinc-100"),children:x.jsx(PI,{size:14})})})]}),x.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-4",children:s})]})]})})}function Pn(e){return function(){return e}}const Ose=Math.cos,ck=Math.sin,Hs=Math.sqrt,fk=Math.PI,OE=2*fk,yj=Math.PI,bj=2*yj,Rf=1e-6,i8e=bj-Rf;function Mse(e){this._+=e[0];for(let t=1,n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function o8e(e){let t=Math.floor(e);if(!(t>=0))throw new Error(`invalid digits: ${e}`);if(t>15)return Mse;const n=10**t;return function(r){this._+=r[0];for(let i=1,o=r.length;i<o;++i)this._+=Math.round(arguments[i]*n)/n+r[i]}}class s8e{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=t==null?Mse:o8e(t)}moveTo(t,n){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,n){this._append`L${this._x1=+t},${this._y1=+n}`}quadraticCurveTo(t,n,r,i){this._append`Q${+t},${+n},${this._x1=+r},${this._y1=+i}`}bezierCurveTo(t,n,r,i,o,s){this._append`C${+t},${+n},${+r},${+i},${this._x1=+o},${this._y1=+s}`}arcTo(t,n,r,i,o){if(t=+t,n=+n,r=+r,i=+i,o=+o,o<0)throw new Error(`negative radius: ${o}`);let s=this._x1,a=this._y1,l=r-t,u=i-n,f=s-t,d=a-n,p=f*f+d*d;if(this._x1===null)this._append`M${this._x1=t},${this._y1=n}`;else if(p>Rf)if(!(Math.abs(d*l-u*f)>Rf)||!o)this._append`L${this._x1=t},${this._y1=n}`;else{let m=r-s,g=i-a,b=l*l+u*u,v=m*m+g*g,w=Math.sqrt(b),k=Math.sqrt(p),E=o*Math.tan((yj-Math.acos((b+p-v)/(2*w*k)))/2),C=E/k,T=E/w;Math.abs(C-1)>Rf&&this._append`L${t+C*f},${n+C*d}`,this._append`A${o},${o},0,0,${+(d*m>f*g)},${this._x1=t+T*l},${this._y1=n+T*u}`}}arc(t,n,r,i,o,s){if(t=+t,n=+n,r=+r,s=!!s,r<0)throw new Error(`negative radius: ${r}`);let a=r*Math.cos(i),l=r*Math.sin(i),u=t+a,f=n+l,d=1^s,p=s?i-o:o-i;this._x1===null?this._append`M${u},${f}`:(Math.abs(this._x1-u)>Rf||Math.abs(this._y1-f)>Rf)&&this._append`L${u},${f}`,r&&(p<0&&(p=p%bj+bj),p>i8e?this._append`A${r},${r},0,1,${d},${t-a},${n-l}A${r},${r},0,1,${d},${this._x1=u},${this._y1=f}`:p>Rf&&this._append`A${r},${r},0,${+(p>=yj)},${d},${this._x1=t+r*Math.cos(o)},${this._y1=n+r*Math.sin(o)}`)}rect(t,n,r,i){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function V6(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{const r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);t=r}return e},()=>new s8e(t)}function q6(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Nse(e){this._context=e}Nse.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function ME(e){return new Nse(e)}function Rse(e){return e[0]}function Dse(e){return e[1]}function NE(e,t){var n=Pn(!0),r=null,i=ME,o=null,s=V6(a);e=typeof e=="function"?e:e===void 0?Rse:Pn(e),t=typeof t=="function"?t:t===void 0?Dse:Pn(t);function a(l){var u,f=(l=q6(l)).length,d,p=!1,m;for(r==null&&(o=i(m=s())),u=0;u<=f;++u)!(u<f&&n(d=l[u],u,l))===p&&((p=!p)?o.lineStart():o.lineEnd()),p&&o.point(+e(d,u,l),+t(d,u,l));if(m)return o=null,m+""||null}return a.x=function(l){return arguments.length?(e=typeof l=="function"?l:Pn(+l),a):e},a.y=function(l){return arguments.length?(t=typeof l=="function"?l:Pn(+l),a):t},a.defined=function(l){return arguments.length?(n=typeof l=="function"?l:Pn(!!l),a):n},a.curve=function(l){return arguments.length?(i=l,r!=null&&(o=i(r)),a):i},a.context=function(l){return arguments.length?(l==null?r=o=null:o=i(r=l),a):r},a}function M0(e,t,n){var r=null,i=Pn(!0),o=null,s=ME,a=null,l=V6(u);e=typeof e=="function"?e:e===void 0?Rse:Pn(+e),t=typeof t=="function"?t:Pn(t===void 0?0:+t),n=typeof n=="function"?n:n===void 0?Dse:Pn(+n);function u(d){var p,m,g,b=(d=q6(d)).length,v,w=!1,k,E=new Array(b),C=new Array(b);for(o==null&&(a=s(k=l())),p=0;p<=b;++p){if(!(p<b&&i(v=d[p],p,d))===w)if(w=!w)m=p,a.areaStart(),a.lineStart();else{for(a.lineEnd(),a.lineStart(),g=p-1;g>=m;--g)a.point(E[g],C[g]);a.lineEnd(),a.areaEnd()}w&&(E[p]=+e(v,p,d),C[p]=+t(v,p,d),a.point(r?+r(v,p,d):E[p],n?+n(v,p,d):C[p]))}if(k)return a=null,k+""||null}function f(){return NE().defined(i).curve(s).context(o)}return u.x=function(d){return arguments.length?(e=typeof d=="function"?d:Pn(+d),r=null,u):e},u.x0=function(d){return arguments.length?(e=typeof d=="function"?d:Pn(+d),u):e},u.x1=function(d){return arguments.length?(r=d==null?null:typeof d=="function"?d:Pn(+d),u):r},u.y=function(d){return arguments.length?(t=typeof d=="function"?d:Pn(+d),n=null,u):t},u.y0=function(d){return arguments.length?(t=typeof d=="function"?d:Pn(+d),u):t},u.y1=function(d){return arguments.length?(n=d==null?null:typeof d=="function"?d:Pn(+d),u):n},u.lineX0=u.lineY0=function(){return f().x(e).y(t)},u.lineY1=function(){return f().x(e).y(n)},u.lineX1=function(){return f().x(r).y(t)},u.defined=function(d){return arguments.length?(i=typeof d=="function"?d:Pn(!!d),u):i},u.curve=function(d){return arguments.length?(s=d,o!=null&&(a=s(o)),u):s},u.context=function(d){return arguments.length?(d==null?o=a=null:a=s(o=d),u):o},u}class jse{constructor(t,n){this._context=t,this._x=n}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(t,n){switch(t=+t,n=+n,this._point){case 0:{this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,n,t,n):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+n)/2,t,this._y0,t,n);break}}this._x0=t,this._y0=n}}function a8e(e){return new jse(e,!0)}function l8e(e){return new jse(e,!1)}const H6={draw(e,t){const n=Hs(t/fk);e.moveTo(n,0),e.arc(0,0,n,0,OE)}},u8e={draw(e,t){const n=Hs(t/5)/2;e.moveTo(-3*n,-n),e.lineTo(-n,-n),e.lineTo(-n,-3*n),e.lineTo(n,-3*n),e.lineTo(n,-n),e.lineTo(3*n,-n),e.lineTo(3*n,n),e.lineTo(n,n),e.lineTo(n,3*n),e.lineTo(-n,3*n),e.lineTo(-n,n),e.lineTo(-3*n,n),e.closePath()}},Pse=Hs(1/3),c8e=Pse*2,f8e={draw(e,t){const n=Hs(t/c8e),r=n*Pse;e.moveTo(0,-n),e.lineTo(r,0),e.lineTo(0,n),e.lineTo(-r,0),e.closePath()}},d8e={draw(e,t){const n=Hs(t),r=-n/2;e.rect(r,r,n,n)}},h8e=.8908130915292852,Ise=ck(fk/10)/ck(7*fk/10),p8e=ck(OE/10)*Ise,m8e=-Ose(OE/10)*Ise,g8e={draw(e,t){const n=Hs(t*h8e),r=p8e*n,i=m8e*n;e.moveTo(0,-n),e.lineTo(r,i);for(let o=1;o<5;++o){const s=OE*o/5,a=Ose(s),l=ck(s);e.lineTo(l*n,-a*n),e.lineTo(a*r-l*i,l*r+a*i)}e.closePath()}},aO=Hs(3),y8e={draw(e,t){const n=-Hs(t/(aO*3));e.moveTo(0,n*2),e.lineTo(-aO*n,-n),e.lineTo(aO*n,-n),e.closePath()}},Ko=-.5,Go=Hs(3)/2,vj=1/Hs(12),b8e=(vj/2+1)*3,v8e={draw(e,t){const n=Hs(t/b8e),r=n/2,i=n*vj,o=r,s=n*vj+n,a=-o,l=s;e.moveTo(r,i),e.lineTo(o,s),e.lineTo(a,l),e.lineTo(Ko*r-Go*i,Go*r+Ko*i),e.lineTo(Ko*o-Go*s,Go*o+Ko*s),e.lineTo(Ko*a-Go*l,Go*a+Ko*l),e.lineTo(Ko*r+Go*i,Ko*i-Go*r),e.lineTo(Ko*o+Go*s,Ko*s-Go*o),e.lineTo(Ko*a+Go*l,Ko*l-Go*a),e.closePath()}};function x8e(e,t){let n=null,r=V6(i);e=typeof e=="function"?e:Pn(e||H6),t=typeof t=="function"?t:Pn(t===void 0?64:+t);function i(){let o;if(n||(n=o=r()),e.apply(this,arguments).draw(n,+t.apply(this,arguments)),o)return n=null,o+""||null}return i.type=function(o){return arguments.length?(e=typeof o=="function"?o:Pn(o),i):e},i.size=function(o){return arguments.length?(t=typeof o=="function"?o:Pn(+o),i):t},i.context=function(o){return arguments.length?(n=o??null,i):n},i}function dk(){}function hk(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function Lse(e){this._context=e}Lse.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:hk(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:hk(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function w8e(e){return new Lse(e)}function zse(e){this._context=e}zse.prototype={areaStart:dk,areaEnd:dk,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:hk(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function S8e(e){return new zse(e)}function $se(e){this._context=e}$se.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+e)/6,r=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:hk(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function k8e(e){return new $se(e)}function Fse(e){this._context=e}Fse.prototype={areaStart:dk,areaEnd:dk,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function E8e(e){return new Fse(e)}function KV(e){return e<0?-1:1}function GV(e,t,n){var r=e._x1-e._x0,i=t-e._x1,o=(e._y1-e._y0)/(r||i<0&&-0),s=(n-e._y1)/(i||r<0&&-0),a=(o*i+s*r)/(r+i);return(KV(o)+KV(s))*Math.min(Math.abs(o),Math.abs(s),.5*Math.abs(a))||0}function YV(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function lO(e,t,n){var r=e._x0,i=e._y0,o=e._x1,s=e._y1,a=(o-r)/3;e._context.bezierCurveTo(r+a,i+a*t,o-a,s-a*n,o,s)}function pk(e){this._context=e}pk.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:lO(this,this._t0,YV(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,lO(this,YV(this,n=GV(this,e,t)),n);break;default:lO(this,this._t0,n=GV(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function Bse(e){this._context=new Vse(e)}(Bse.prototype=Object.create(pk.prototype)).point=function(e,t){pk.prototype.point.call(this,t,e)};function Vse(e){this._context=e}Vse.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,i,o){this._context.bezierCurveTo(t,e,r,n,o,i)}};function U6(e){return new pk(e)}function C8e(e){return new Bse(e)}function qse(e){this._context=e}qse.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,n=e.length;if(n)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),n===2)this._context.lineTo(e[1],t[1]);else for(var r=XV(e),i=XV(t),o=0,s=1;s<n;++o,++s)this._context.bezierCurveTo(r[0][o],i[0][o],r[1][o],i[1][o],e[s],t[s]);(this._line||this._line!==0&&n===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(e,t){this._x.push(+e),this._y.push(+t)}};function XV(e){var t,n=e.length-1,r,i=new Array(n),o=new Array(n),s=new Array(n);for(i[0]=0,o[0]=2,s[0]=e[0]+2*e[1],t=1;t<n-1;++t)i[t]=1,o[t]=4,s[t]=4*e[t]+2*e[t+1];for(i[n-1]=2,o[n-1]=7,s[n-1]=8*e[n-1]+e[n],t=1;t<n;++t)r=i[t]/o[t-1],o[t]-=r,s[t]-=r*s[t-1];for(i[n-1]=s[n-1]/o[n-1],t=n-2;t>=0;--t)i[t]=(s[t]-i[t+1])/o[t];for(o[n-1]=(e[n]+i[n-1])/2,t=0;t<n-1;++t)o[t]=2*e[t+1]-i[t+1];return[i,o]}function Hse(e){return new qse(e)}function RE(e,t){this._context=e,this._t=t}RE.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&this._point===2&&this._context.lineTo(this._x,this._y),(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}break}}this._x=e,this._y=t}};function A8e(e){return new RE(e,.5)}function T8e(e){return new RE(e,0)}function _8e(e){return new RE(e,1)}function Up(e,t){if((s=e.length)>1)for(var n=1,r,i,o=e[t[0]],s,a=o.length;n<s;++n)for(i=o,o=e[t[n]],r=0;r<a;++r)o[r][1]+=o[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function xj(e){for(var t=e.length,n=new Array(t);--t>=0;)n[t]=t;return n}function O8e(e,t){return e[t]}function M8e(e){const t=[];return t.key=e,t}function N8e(){var e=Pn([]),t=xj,n=Up,r=O8e;function i(o){var s=Array.from(e.apply(this,arguments),M8e),a,l=s.length,u=-1,f;for(const d of o)for(a=0,++u;a<l;++a)(s[a][u]=[0,+r(d,s[a].key,u,o)]).data=d;for(a=0,f=q6(t(s));a<l;++a)s[f[a]].index=a;return n(s,f),s}return i.keys=function(o){return arguments.length?(e=typeof o=="function"?o:Pn(Array.from(o)),i):e},i.value=function(o){return arguments.length?(r=typeof o=="function"?o:Pn(+o),i):r},i.order=function(o){return arguments.length?(t=o==null?xj:typeof o=="function"?o:Pn(Array.from(o)),i):t},i.offset=function(o){return arguments.length?(n=o??Up,i):n},i}function R8e(e,t){if((r=e.length)>0){for(var n,r,i=0,o=e[0].length,s;i<o;++i){for(s=n=0;n<r;++n)s+=e[n][i][1]||0;if(s)for(n=0;n<r;++n)e[n][i][1]/=s}Up(e,t)}}function D8e(e,t){if((i=e.length)>0){for(var n=0,r=e[t[0]],i,o=r.length;n<o;++n){for(var s=0,a=0;s<i;++s)a+=e[s][n][1]||0;r[n][1]+=r[n][0]=-a/2}Up(e,t)}}function j8e(e,t){if(!(!((s=e.length)>0)||!((o=(i=e[t[0]]).length)>0))){for(var n=0,r=1,i,o,s;r<o;++r){for(var a=0,l=0,u=0;a<s;++a){for(var f=e[t[a]],d=f[r][1]||0,p=f[r-1][1]||0,m=(d-p)/2,g=0;g<a;++g){var b=e[t[g]],v=b[r][1]||0,w=b[r-1][1]||0;m+=v-w}l+=d,u+=m*d}i[r-1][1]+=i[r-1][0]=n,l&&(n-=u/l)}i[r-1][1]+=i[r-1][0]=n,Up(e,t)}}var uO={exports:{}};/*!
589
589
  Copyright (c) 2018 Jed Watson.
590
590
  Licensed under the MIT License (MIT), see
@@ -778,4 +778,4 @@ Error generating stack: `+S.message+`
778
778
  *
779
779
  * This source code is licensed under the ISC license.
780
780
  * See the LICENSE file in the root directory of this source tree.
781
- */const npt=Lo("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]),i8="catalog.devKey",xQ="catalog.key";function EI(){return localStorage.getItem(xQ)!==null&&localStorage.removeItem(xQ),localStorage.getItem(i8)}function rpt(e){localStorage.setItem(i8,e)}function ipt(){localStorage.removeItem(i8)}class Lpe extends Error{}function opt(e,t){const n=window.__CATALOG_API__??"/api",r=new URL(`${n}${e}`,window.location.origin);for(const[i,o]of Object.entries(t??{}))o!=null&&o!==""&&r.searchParams.set(i,String(o));return r}async function spt(e,t,n){const r=await e.text();let i=`${n} ${t} → ${e.status}`;try{const o=JSON.parse(r);o.message&&(i=Array.isArray(o.message)?o.message.join(", "):o.message)}catch{r&&(i=r)}return new Error(i)}async function Qi(e,t={}){const{params:n,...r}=t,i=opt(e,n),o=EI(),s=await fetch(i,{...r,credentials:"same-origin",headers:{"content-type":"application/json",...o?{"x-catalog-key":o}:{},"x-catalog-environment":Fpe(),...r.headers}});if(s.status===401||s.status===403)throw new Lpe(await s.text());if(!s.ok)throw await spt(s,e,t.method??"GET");const a=await s.text();return a?JSON.parse(a):void 0}const zpe={get:(e,t)=>Qi(e,{params:t}),patch:(e,t)=>Qi(e,{method:"PATCH",body:JSON.stringify(t)}),post:(e,t)=>Qi(e,{method:"POST",body:t===void 0?void 0:JSON.stringify(t)}),delete:e=>Qi(e,{method:"DELETE"})},_m={me:()=>Qi("/auth/me"),login:(e,t)=>Qi("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:t})}),logout:()=>Qi("/auth/logout",{method:"POST"}),principals:()=>Qi("/access/principals"),people:()=>Qi("/access/people"),upsertPerson:e=>Qi("/access/people",{method:"POST",body:JSON.stringify(e)}),snapshots:e=>Qi(`/publish/${e}/snapshots`),aiCapabilities:()=>Qi("/query-ai/capabilities"),generateSql:e=>Qi("/query-ai/generate",{method:"POST",body:JSON.stringify({prompt:e})})},$pe="catalog.environment";function Fpe(){const e=window.localStorage.getItem($pe);return e&&e.length>0?e:"dev"}function apt(e){window.localStorage.setItem($pe,e)}function lpt(){return Qi("/environments")}const E2=["auth","me"];function upt({children:e}){const t=ps(),[n,r]=A.useState(!1),{data:i,isLoading:o,error:s}=Jt({queryKey:E2,queryFn:()=>_m.me(),retry:!1,refetchOnWindowFocus:!0,staleTime:3e4});if(i)return x.jsx(x.Fragment,{children:e});if(o)return x.jsx("div",{className:"flex h-full items-center justify-center bg-zinc-50 dark:bg-zinc-950",children:x.jsx("p",{className:"font-mono text-xs uppercase tracking-[0.18em] text-zinc-400",children:"Checking your session…"})});const a=s instanceof Lpe;return x.jsx("div",{className:"flex h-full items-center justify-center bg-zinc-50 px-6 dark:bg-zinc-950",children:x.jsxs("div",{className:"w-full max-w-sm",children:[x.jsxs("div",{className:"mb-1 flex items-center gap-2 text-zinc-400",children:[x.jsx(Ipe,{size:14}),x.jsx("span",{className:"font-mono text-[11px] uppercase tracking-[0.18em]",children:"Catalog console"})]}),x.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"Sign in"}),x.jsx("p",{className:"mt-1 text-sm text-zinc-500 dark:text-zinc-400",children:"Everything you do here is recorded against your name, through the console’s application. You never see more than both of you may."}),x.jsx(cpt,{onSignedIn:()=>t.invalidateQueries({queryKey:E2})}),!a&&s&&x.jsxs("p",{className:"mt-3 text-xs text-amber-600",children:["Could not reach the catalog: ",String(s)]}),x.jsxs("div",{className:"mt-8 border-t border-zinc-200 pt-4 dark:border-zinc-800",children:[x.jsxs("button",{type:"button",onClick:()=>r(l=>!l),className:"flex items-center gap-1.5 font-mono text-[10px] uppercase tracking-[0.14em] text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-300",children:[x.jsx(Qht,{size:12}),n?"Hide":"Use an application key instead"]}),n&&x.jsx(fpt,{onApplied:()=>window.location.reload()})]})]})})}function cpt({onSignedIn:e}){const[t,n]=A.useState(""),[r,i]=A.useState(""),o=Un({mutationFn:()=>_m.login(t.trim(),r),onSuccess:()=>{i(""),e()}});return x.jsxs("form",{className:"mt-5 space-y-2",onSubmit:s=>{s.preventDefault(),o.mutate()},children:[x.jsx("input",{type:"email",value:t,onChange:s=>n(s.target.value),autoComplete:"username","aria-label":"Email",placeholder:"you@example.com",autoFocus:!0,className:"w-full rounded-md border border-zinc-200 bg-white px-3 py-2 text-sm outline-none focus:border-sky-500 focus:ring-2 focus:ring-sky-500/15 dark:border-zinc-800 dark:bg-zinc-900"}),x.jsx("input",{type:"password",value:r,onChange:s=>i(s.target.value),autoComplete:"current-password","aria-label":"Password",placeholder:"Password",className:"w-full rounded-md border border-zinc-200 bg-white px-3 py-2 text-sm outline-none focus:border-sky-500 focus:ring-2 focus:ring-sky-500/15 dark:border-zinc-800 dark:bg-zinc-900"}),o.isError&&x.jsx("p",{className:"text-xs text-red-600",children:o.error instanceof Error?dpt(o.error):"Those credentials were not accepted."}),x.jsxs("button",{type:"submit",disabled:o.isPending||t.trim().length===0||r.length===0,className:"flex w-full items-center justify-center gap-2 rounded-md bg-zinc-950 px-3 py-2 text-sm text-zinc-50 transition-colors hover:bg-zinc-800 disabled:opacity-40 dark:bg-zinc-100 dark:text-zinc-950",children:[x.jsx(ept,{size:14}),o.isPending?"Signing in…":"Sign in"]})]})}function fpt({onApplied:e}){const[t,n]=A.useState(EI()??"");return x.jsxs("div",{className:"mt-3",children:[x.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-400",children:"For local development. The console will act as that application, and everything you do will be attributed to it rather than to you."}),x.jsx("input",{type:"password",value:t,onChange:r=>n(r.target.value),"aria-label":"Application key",placeholder:"x-catalog-key",className:"mt-2 w-full rounded-md border border-zinc-200 bg-white px-3 py-2 font-mono text-xs outline-none focus:border-amber-500 dark:border-zinc-800 dark:bg-zinc-900"}),x.jsxs("div",{className:"mt-2 flex gap-2",children:[x.jsx("button",{type:"button",disabled:t.trim().length===0,onClick:()=>{rpt(t.trim()),e()},className:"rounded-md border border-amber-500/40 px-3 py-1.5 text-xs text-amber-600 disabled:opacity-40",children:"Use this key"}),EI()&&x.jsx("button",{type:"button",onClick:()=>{ipt(),e()},className:"rounded-md px-3 py-1.5 text-xs text-zinc-500 hover:text-zinc-800 dark:hover:text-zinc-200",children:"Forget it"})]})]})}const G3="Those credentials were not accepted.";function dpt(e){const t=e.message.trim();if(!t.startsWith("{"))return t||G3;try{const n=JSON.parse(t);if(n&&typeof n=="object"&&"message"in n){const r=Reflect.get(n,"message");if(typeof r=="string"&&r.length>0)return r}return G3}catch{return G3}}function hpt({tabs:e,value:t}){const n=A.useRef(null),[r,i]=A.useState({left:!1,right:!1}),o=A.useCallback(()=>{const a=n.current;if(!a)return;const l=a.scrollWidth-a.clientWidth;i({left:a.scrollLeft>1,right:a.scrollLeft<l-1})},[]);A.useEffect(()=>{const a=n.current;if(!a)return;o(),a.addEventListener("scroll",o,{passive:!0});const l=new ResizeObserver(o);l.observe(a);for(const u of a.children)l.observe(u);return()=>{a.removeEventListener("scroll",o),l.disconnect()}},[o]);const s=a=>{const l=n.current;l&&l.scrollBy({left:a*l.clientWidth*.8,behavior:"smooth"})};return x.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[x.jsx(wQ,{show:r.left,direction:"left",onClick:()=>s(-1)}),x.jsx(Tse,{ref:n,className:"min-w-0 flex-1 border-b-0 overflow-x-auto [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:e.map(({id:a,label:l,icon:u})=>x.jsxs(kw,{value:a,className:"py-3",children:[x.jsx(ppt,{active:a===t}),x.jsx(u,{size:14}),l]},a))}),x.jsx(wQ,{show:r.right,direction:"right",onClick:()=>s(1)})]})}function wQ({show:e,direction:t,onClick:n}){const r=t==="left"?Kht:Ght;return x.jsx(FS,{variant:"ghost",size:"icon",onClick:n,"aria-label":`Scroll tabs ${t}`,tabIndex:-1,"aria-hidden":!e,disabled:!e,className:e?"":"invisible",children:x.jsx(r,{size:16})})}function ppt({active:e}){const t=A.useRef(null);return A.useEffect(()=>{var n;e&&((n=t.current)==null||n.scrollIntoView({inline:"nearest",block:"nearest"}))},[e]),x.jsx("span",{ref:t,"aria-hidden":!0,className:"sr-only"})}const mpt=window.__CATALOG_HOST_AUTH__===!0;function gpt({children:e}){return mpt?x.jsx(x.Fragment,{children:e}):x.jsx(upt,{children:e})}const Bpe=[{id:"model",label:"Model",icon:Uht},{id:"objects",label:"Objects",icon:Yht},{id:"query",label:"Query",icon:tpt},{id:"dashboards",label:"Dashboards",icon:Jht},{id:"connectors",label:"Connectors",icon:Wht},{id:"workflows",label:"Workflows",icon:npt},{id:"lineage",label:"Lineage",icon:Xht},{id:"activity",label:"Activity",icon:Zht},{id:"access",label:"Access",icon:Ipe}];function SQ(){const e=window.location.hash.replace("#","").split("?")[0];return Bpe.some(t=>t.id===e)?e:"model"}function kQ(){const e=window.location.hash,t=e.indexOf("?");return new URLSearchParams(t===-1?"":e.slice(t+1))}function ypt(){const e=ps(),{data:t}=Jt({queryKey:E2,queryFn:()=>_m.me(),retry:!1}),n=Un({mutationFn:()=>_m.logout(),onSuccess:()=>e.invalidateQueries({queryKey:E2})});return{identity:t,signOut:n}}function bpt(){const e=Fpe(),{data:t=[]}=Jt({queryKey:["environments"],queryFn:()=>lpt(),staleTime:Number.POSITIVE_INFINITY}),n=t.find(r=>r.id===e);return x.jsxs("label",{className:"ml-auto mr-3 flex items-center gap-1.5 text-[10px]",children:[x.jsx("span",{className:"font-mono uppercase tracking-[0.14em] text-zinc-400",children:"Env"}),x.jsxs("select",{value:e,onChange:r=>{apt(r.target.value),window.location.reload()},"aria-label":"Environment",className:G("rounded-md border px-1.5 py-1 font-mono text-[10px] outline-none","border-zinc-200 bg-white dark:border-zinc-800 dark:bg-zinc-900",(n==null?void 0:n.protected)&&"border-amber-500 text-amber-700 dark:text-amber-400"),children:[t.length===0&&x.jsx("option",{value:e,children:e}),t.map(r=>x.jsxs("option",{value:r.id,children:[r.displayName,r.protected?" (protected)":""]},r.id))]})]})}function vpt(){const{identity:e,signOut:t}=ypt(),[n,r]=A.useState(SQ),[i,o]=A.useState(kQ);return A.useEffect(()=>{const s=()=>{r(SQ()),o(kQ())};return window.addEventListener("hashchange",s),()=>window.removeEventListener("hashchange",s)},[]),x.jsx(yve,{transport:zpe,children:x.jsx(gpt,{children:x.jsxs(Ase,{value:n,onValueChange:s=>{window.location.hash=s,r(s)},className:"flex h-full flex-col bg-zinc-50 dark:bg-zinc-950",children:[x.jsxs("nav",{className:"flex shrink-0 items-center gap-1 border-b border-zinc-200 bg-white px-4 dark:border-zinc-800 dark:bg-zinc-900",children:[x.jsxs("span",{className:"mr-4 flex shrink-0 items-center gap-2 py-3 text-sm font-semibold tracking-tight",children:[x.jsx("span",{className:"text-base",children:"◈"})," Catalog"]}),x.jsx(hpt,{tabs:Bpe,value:n}),x.jsxs("div",{className:"flex shrink-0 items-center gap-1 pl-2",children:[x.jsx(bpt,{}),x.jsx(wpt,{})]})]}),x.jsxs("main",{className:"min-h-0 flex-1 overflow-hidden",children:[x.jsx(Zo,{value:"model",className:"h-full",children:x.jsx(kje,{title:"Model",eyebrow:"Published by your applications",intro:"Every object type published into this catalog. Structure follows the publisher; names, descriptions and units are yours, and survive its next deploy.",explorerHref:s=>`#objects?type=${s}`})}),x.jsx(Zo,{value:"objects",className:"h-full",children:x.jsx(Rje,{type:i.get("type")??void 0,backHref:"#model",backLabel:"Model"})}),x.jsx(Zo,{value:"query",className:"h-full",children:x.jsx(xpt,{})}),x.jsx(Zo,{value:"dashboards",className:"h-full",children:x.jsx(CIe,{})}),x.jsx(Zo,{value:"connectors",className:"h-full overflow-hidden",children:x.jsx(_Le,{})}),x.jsx(Zo,{value:"workflows",className:"h-full",children:x.jsx(kht,{})}),x.jsx(Zo,{value:"lineage",className:"h-full",children:x.jsx(DIe,{})}),x.jsx(Zo,{value:"activity",className:"h-full",children:x.jsx(JIe,{})}),x.jsx(Zo,{value:"access",className:"h-full overflow-y-auto",children:x.jsx(VLe,{identity:e,onSignOut:()=>t.mutate(),signOutPending:t.isPending})})]})]})})})}function xpt(){const{data:e}=Jt({queryKey:["query-ai","capabilities"],queryFn:()=>_m.aiCapabilities(),staleTime:Number.POSITIVE_INFINITY});return x.jsx(f6e,{onGenerate:e!=null&&e.available?async t=>(await _m.generateSql(t)).sql:void 0})}function wpt(){const{data:e}=Jt({queryKey:["catalog","snapshot"],queryFn:()=>zpe.get("/catalog"),staleTime:6e4});return e?x.jsxs("span",{className:"ml-auto font-mono text-[10px] uppercase tracking-[0.14em] text-zinc-400 dark:text-zinc-500",children:[e.stats.types," types · snapshots on"]}):null}boe("shadcn",Est);boe("bklit",oKe);const Spt=new k0e({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:!1}}}),Vpe=document.getElementById("root");if(!Vpe)throw new Error("No #root element to mount the console into.");Ost.createRoot(Vpe).render(x.jsx(A.StrictMode,{children:x.jsx(A0e,{client:Spt,children:x.jsx(vpt,{})})}));
781
+ */const npt=Lo("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]),i8="catalog.devKey",xQ="catalog.key";function EI(){return localStorage.getItem(xQ)!==null&&localStorage.removeItem(xQ),localStorage.getItem(i8)}function rpt(e){localStorage.setItem(i8,e)}function ipt(){localStorage.removeItem(i8)}class Lpe extends Error{}function opt(e,t){const n=window.__CATALOG_API__??"/api",r=new URL(`${n}${e}`,window.location.origin);for(const[i,o]of Object.entries(t??{}))o!=null&&o!==""&&r.searchParams.set(i,String(o));return r}async function spt(e,t,n){const r=await e.text();let i=`${n} ${t} → ${e.status}`;try{const o=JSON.parse(r);o.message&&(i=Array.isArray(o.message)?o.message.join(", "):o.message)}catch{r&&(i=r)}return new Error(i)}async function Qi(e,t={}){const{params:n,...r}=t,i=opt(e,n),o=EI(),s=await fetch(i,{...r,credentials:"same-origin",headers:{"content-type":"application/json",...o?{"x-catalog-key":o}:{},"x-catalog-environment":Fpe(),...r.headers}});if(s.status===401||s.status===403)throw new Lpe(await s.text());if(!s.ok)throw await spt(s,e,t.method??"GET");const a=await s.text();return a?JSON.parse(a):void 0}const zpe={get:(e,t)=>Qi(e,{params:t}),patch:(e,t)=>Qi(e,{method:"PATCH",body:JSON.stringify(t)}),post:(e,t)=>Qi(e,{method:"POST",body:t===void 0?void 0:JSON.stringify(t)}),delete:e=>Qi(e,{method:"DELETE"})},_m={me:()=>Qi("/auth/me"),login:(e,t)=>Qi("/auth/login",{method:"POST",body:JSON.stringify({email:e,password:t})}),logout:()=>Qi("/auth/logout",{method:"POST"}),principals:()=>Qi("/access/principals"),people:()=>Qi("/access/people"),upsertPerson:e=>Qi("/access/people",{method:"POST",body:JSON.stringify(e)}),snapshots:e=>Qi(`/publish/${e}/snapshots`),aiCapabilities:()=>Qi("/query-ai/capabilities"),generateSql:e=>Qi("/query-ai/generate",{method:"POST",body:JSON.stringify({prompt:e})})},$pe="catalog.environment";function Fpe(){const e=window.localStorage.getItem($pe);return e&&e.length>0?e:"dev"}function apt(e){window.localStorage.setItem($pe,e)}function lpt(){return Qi("/environments")}const E2=["auth","me"];function upt({children:e}){const t=ps(),[n,r]=A.useState(!1),{data:i,isLoading:o,error:s}=Jt({queryKey:E2,queryFn:()=>_m.me(),retry:!1,refetchOnWindowFocus:!0,staleTime:3e4});if(i)return x.jsx(x.Fragment,{children:e});if(o)return x.jsx("div",{className:"flex h-full items-center justify-center bg-zinc-50 dark:bg-zinc-950",children:x.jsx("p",{className:"font-mono text-xs uppercase tracking-[0.18em] text-zinc-400",children:"Checking your session…"})});const a=s instanceof Lpe;return x.jsx("div",{className:"flex h-full items-center justify-center bg-zinc-50 px-6 dark:bg-zinc-950",children:x.jsxs("div",{className:"w-full max-w-sm",children:[x.jsxs("div",{className:"mb-1 flex items-center gap-2 text-zinc-400",children:[x.jsx(Ipe,{size:14}),x.jsx("span",{className:"font-mono text-[11px] uppercase tracking-[0.18em]",children:"Catalog console"})]}),x.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"Sign in"}),x.jsx("p",{className:"mt-1 text-sm text-zinc-500 dark:text-zinc-400",children:"Everything you do here is recorded against your name, through the console’s application. You never see more than both of you may."}),x.jsx(cpt,{onSignedIn:()=>t.invalidateQueries({queryKey:E2})}),!a&&s&&x.jsxs("p",{className:"mt-3 text-xs text-amber-600",children:["Could not reach the catalog: ",String(s)]}),x.jsxs("div",{className:"mt-8 border-t border-zinc-200 pt-4 dark:border-zinc-800",children:[x.jsxs("button",{type:"button",onClick:()=>r(l=>!l),className:"flex items-center gap-1.5 font-mono text-[10px] uppercase tracking-[0.14em] text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-300",children:[x.jsx(Qht,{size:12}),n?"Hide":"Use an application key instead"]}),n&&x.jsx(fpt,{onApplied:()=>window.location.reload()})]})]})})}function cpt({onSignedIn:e}){const[t,n]=A.useState(""),[r,i]=A.useState(""),o=Un({mutationFn:()=>_m.login(t.trim(),r),onSuccess:()=>{i(""),e()}});return x.jsxs("form",{className:"mt-5 space-y-2",onSubmit:s=>{s.preventDefault(),o.mutate()},children:[x.jsx("input",{type:"email",value:t,onChange:s=>n(s.target.value),autoComplete:"username","aria-label":"Email",placeholder:"you@example.com",autoFocus:!0,className:"w-full rounded-md border border-zinc-200 bg-white px-3 py-2 text-sm outline-none focus:border-sky-500 focus:ring-2 focus:ring-sky-500/15 dark:border-zinc-800 dark:bg-zinc-900"}),x.jsx("input",{type:"password",value:r,onChange:s=>i(s.target.value),autoComplete:"current-password","aria-label":"Password",placeholder:"Password",className:"w-full rounded-md border border-zinc-200 bg-white px-3 py-2 text-sm outline-none focus:border-sky-500 focus:ring-2 focus:ring-sky-500/15 dark:border-zinc-800 dark:bg-zinc-900"}),o.isError&&x.jsx("p",{className:"text-xs text-red-600",children:o.error instanceof Error?dpt(o.error):"Those credentials were not accepted."}),x.jsxs("button",{type:"submit",disabled:o.isPending||t.trim().length===0||r.length===0,className:"flex w-full items-center justify-center gap-2 rounded-md bg-zinc-950 px-3 py-2 text-sm text-zinc-50 transition-colors hover:bg-zinc-800 disabled:opacity-40 dark:bg-zinc-100 dark:text-zinc-950",children:[x.jsx(ept,{size:14}),o.isPending?"Signing in…":"Sign in"]})]})}function fpt({onApplied:e}){const[t,n]=A.useState(EI()??"");return x.jsxs("div",{className:"mt-3",children:[x.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-400",children:"For local development. The console will act as that application, and everything you do will be attributed to it rather than to you."}),x.jsx("input",{type:"password",value:t,onChange:r=>n(r.target.value),"aria-label":"Application key",placeholder:"x-catalog-key",className:"mt-2 w-full rounded-md border border-zinc-200 bg-white px-3 py-2 font-mono text-xs outline-none focus:border-amber-500 dark:border-zinc-800 dark:bg-zinc-900"}),x.jsxs("div",{className:"mt-2 flex gap-2",children:[x.jsx("button",{type:"button",disabled:t.trim().length===0,onClick:()=>{rpt(t.trim()),e()},className:"rounded-md border border-amber-500/40 px-3 py-1.5 text-xs text-amber-600 disabled:opacity-40",children:"Use this key"}),EI()&&x.jsx("button",{type:"button",onClick:()=>{ipt(),e()},className:"rounded-md px-3 py-1.5 text-xs text-zinc-500 hover:text-zinc-800 dark:hover:text-zinc-200",children:"Forget it"})]})]})}const G3="Those credentials were not accepted.";function dpt(e){const t=e.message.trim();if(!t.startsWith("{"))return t||G3;try{const n=JSON.parse(t);if(n&&typeof n=="object"&&"message"in n){const r=Reflect.get(n,"message");if(typeof r=="string"&&r.length>0)return r}return G3}catch{return G3}}function hpt({tabs:e,value:t}){const n=A.useRef(null),[r,i]=A.useState({left:!1,right:!1}),o=A.useCallback(()=>{const l=n.current;if(!l)return;const u=l.scrollWidth-l.clientWidth;i({left:l.scrollLeft>1,right:l.scrollLeft<u-1})},[]);A.useEffect(()=>{const l=n.current;if(!l)return;o(),l.addEventListener("scroll",o,{passive:!0});const u=new ResizeObserver(o);u.observe(l);for(const f of l.children)u.observe(f);return()=>{l.removeEventListener("scroll",o),u.disconnect()}},[o]);const s=A.useCallback(l=>{l==null||l.scrollIntoView({inline:"nearest",block:"nearest"})},[]),a=l=>{const u=n.current;u&&u.scrollBy({left:l*u.clientWidth*.8,behavior:"smooth"})};return x.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[x.jsx(wQ,{show:r.left,direction:"left",onClick:()=>a(-1)}),x.jsx(Tse,{ref:n,className:"min-w-0 flex-1 border-b-0 overflow-x-auto [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:e.map(({id:l,label:u,icon:f})=>x.jsxs(kw,{value:l,className:"py-3",...l===t?{ref:s}:{},children:[x.jsx(f,{size:14}),u]},l))}),x.jsx(wQ,{show:r.right,direction:"right",onClick:()=>a(1)})]})}function wQ({show:e,direction:t,onClick:n}){const r=t==="left"?Kht:Ght;return x.jsx(FS,{variant:"ghost",size:"icon",onClick:n,"aria-label":`Scroll tabs ${t}`,tabIndex:-1,"aria-hidden":!e,disabled:!e,className:e?"":"invisible",children:x.jsx(r,{size:16})})}const ppt=window.__CATALOG_HOST_AUTH__===!0;function mpt({children:e}){return ppt?x.jsx(x.Fragment,{children:e}):x.jsx(upt,{children:e})}const Bpe=[{id:"model",label:"Model",icon:Uht},{id:"objects",label:"Objects",icon:Yht},{id:"query",label:"Query",icon:tpt},{id:"dashboards",label:"Dashboards",icon:Jht},{id:"connectors",label:"Connectors",icon:Wht},{id:"workflows",label:"Workflows",icon:npt},{id:"lineage",label:"Lineage",icon:Xht},{id:"activity",label:"Activity",icon:Zht},{id:"access",label:"Access",icon:Ipe}];function SQ(){const e=window.location.hash.replace("#","").split("?")[0];return Bpe.some(t=>t.id===e)?e:"model"}function kQ(){const e=window.location.hash,t=e.indexOf("?");return new URLSearchParams(t===-1?"":e.slice(t+1))}function gpt(){const e=ps(),{data:t}=Jt({queryKey:E2,queryFn:()=>_m.me(),retry:!1}),n=Un({mutationFn:()=>_m.logout(),onSuccess:()=>e.invalidateQueries({queryKey:E2})});return{identity:t,signOut:n}}function ypt(){const e=Fpe(),{data:t=[]}=Jt({queryKey:["environments"],queryFn:()=>lpt(),staleTime:Number.POSITIVE_INFINITY}),n=t.find(r=>r.id===e);return x.jsxs("label",{className:"ml-auto mr-3 flex items-center gap-1.5 text-[10px]",children:[x.jsx("span",{className:"font-mono uppercase tracking-[0.14em] text-zinc-400",children:"Env"}),x.jsxs("select",{value:e,onChange:r=>{apt(r.target.value),window.location.reload()},"aria-label":"Environment",className:G("rounded-md border px-1.5 py-1 font-mono text-[10px] outline-none","border-zinc-200 bg-white dark:border-zinc-800 dark:bg-zinc-900",(n==null?void 0:n.protected)&&"border-amber-500 text-amber-700 dark:text-amber-400"),children:[t.length===0&&x.jsx("option",{value:e,children:e}),t.map(r=>x.jsxs("option",{value:r.id,children:[r.displayName,r.protected?" (protected)":""]},r.id))]})]})}function bpt(){const{identity:e,signOut:t}=gpt(),[n,r]=A.useState(SQ),[i,o]=A.useState(kQ);return A.useEffect(()=>{const s=()=>{r(SQ()),o(kQ())};return window.addEventListener("hashchange",s),()=>window.removeEventListener("hashchange",s)},[]),x.jsx(yve,{transport:zpe,children:x.jsx(mpt,{children:x.jsxs(Ase,{value:n,onValueChange:s=>{window.location.hash=s,r(s)},className:"flex h-full flex-col bg-zinc-50 dark:bg-zinc-950",children:[x.jsxs("nav",{className:"flex shrink-0 items-center gap-1 border-b border-zinc-200 bg-white px-4 dark:border-zinc-800 dark:bg-zinc-900",children:[x.jsxs("span",{className:"mr-4 flex shrink-0 items-center gap-2 py-3 text-sm font-semibold tracking-tight",children:[x.jsx("span",{className:"text-base",children:"◈"})," Catalog"]}),x.jsx(hpt,{tabs:Bpe,value:n}),x.jsxs("div",{className:"flex shrink-0 items-center gap-1 pl-2",children:[x.jsx(ypt,{}),x.jsx(xpt,{})]})]}),x.jsxs("main",{className:"min-h-0 flex-1 overflow-hidden",children:[x.jsx(Zo,{value:"model",className:"h-full",children:x.jsx(kje,{title:"Model",eyebrow:"Published by your applications",intro:"Every object type published into this catalog. Structure follows the publisher; names, descriptions and units are yours, and survive its next deploy.",explorerHref:s=>`#objects?type=${s}`})}),x.jsx(Zo,{value:"objects",className:"h-full",children:x.jsx(Rje,{type:i.get("type")??void 0,backHref:"#model",backLabel:"Model"})}),x.jsx(Zo,{value:"query",className:"h-full",children:x.jsx(vpt,{})}),x.jsx(Zo,{value:"dashboards",className:"h-full",children:x.jsx(CIe,{})}),x.jsx(Zo,{value:"connectors",className:"h-full overflow-hidden",children:x.jsx(_Le,{})}),x.jsx(Zo,{value:"workflows",className:"h-full",children:x.jsx(kht,{})}),x.jsx(Zo,{value:"lineage",className:"h-full",children:x.jsx(DIe,{})}),x.jsx(Zo,{value:"activity",className:"h-full",children:x.jsx(JIe,{})}),x.jsx(Zo,{value:"access",className:"h-full overflow-y-auto",children:x.jsx(VLe,{identity:e,onSignOut:()=>t.mutate(),signOutPending:t.isPending})})]})]})})})}function vpt(){const{data:e}=Jt({queryKey:["query-ai","capabilities"],queryFn:()=>_m.aiCapabilities(),staleTime:Number.POSITIVE_INFINITY});return x.jsx(f6e,{onGenerate:e!=null&&e.available?async t=>(await _m.generateSql(t)).sql:void 0})}function xpt(){const{data:e}=Jt({queryKey:["catalog","snapshot"],queryFn:()=>zpe.get("/catalog"),staleTime:6e4});return e?x.jsxs("span",{className:"ml-auto font-mono text-[10px] uppercase tracking-[0.14em] text-zinc-400 dark:text-zinc-500",children:[e.stats.types," types · snapshots on"]}):null}boe("shadcn",Est);boe("bklit",oKe);const wpt=new k0e({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:!1}}}),Vpe=document.getElementById("root");if(!Vpe)throw new Error("No #root element to mount the console into.");Ost.createRoot(Vpe).render(x.jsx(A.StrictMode,{children:x.jsx(A0e,{client:wpt,children:x.jsx(bpt,{})})}));
@@ -15,7 +15,7 @@
15
15
  rel="stylesheet"
16
16
  />
17
17
  <title>catalog · console</title>
18
- <script type="module" crossorigin src="/catalog/assets/index-KYayGnTJ.js"></script>
18
+ <script type="module" crossorigin src="/catalog/assets/index-DzT3XvKC.js"></script>
19
19
  <link rel="stylesheet" crossorigin href="/catalog/assets/index-BrkRcRNu.css">
20
20
  </head>
21
21
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dudousxd/nestjs-catalog-dashboard",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "The catalog console for @dudousxd/nestjs-catalog: model, objects, query, dashboards, connectors, workflows, lineage, activity and access, served as a mountable NestJS module.",
5
5
  "license": "MIT",
6
6
  "author": "Davide Carvalho",
@@ -66,7 +66,7 @@
66
66
  "tailwindcss": "4.2.4",
67
67
  "@tailwindcss/vite": "4.2.4",
68
68
  "tailwindcss-animate": "1.0.7",
69
- "@dudousxd/nestjs-catalog-react": "0.7.1"
69
+ "@dudousxd/nestjs-catalog-react": "0.7.2"
70
70
  },
71
71
  "peerDependenciesMeta": {
72
72
  "react": {