@marimo-team/frontend 0.24.1-dev35 → 0.24.1-dev36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{CellStatus-DdKYN88d.js → CellStatus-XBYtudpk.js} +1 -1
- package/dist/assets/{JsonOutput-DJrr9OT1.js → JsonOutput-CbpX5Kgt.js} +8 -8
- package/dist/assets/MarimoErrorOutput-DX8DBZiw.js +11 -0
- package/dist/assets/{RenderHTML-Cu5JtYZJ.js → RenderHTML-DsxkHR2d.js} +1 -1
- package/dist/assets/{RunButton-BOnl_Dk8.js → RunButton-DBtIzlFD.js} +1 -1
- package/dist/assets/{add-cell-with-ai-Chy4ITIT.js → add-cell-with-ai-BrrI8i5Q.js} +1 -1
- package/dist/assets/{add-connection-dialog-ebUK47A-.js → add-connection-dialog-DYkpW2NI.js} +1 -1
- package/dist/assets/{agent-panel-syljN-vd.js → agent-panel-CA8lil4S.js} +5 -5
- package/dist/assets/{ai-model-dropdown-BUCPZ0ND.js → ai-model-dropdown-Divs-dGW.js} +1 -1
- package/dist/assets/{app-config-button-BOxbrv3L.js → app-config-button-BipXNxWD.js} +1 -1
- package/dist/assets/{blob-BVQSODqn.js → blob-DCmp9MuM.js} +1 -1
- package/dist/assets/{cell-editor-Dfh89ttH.js → cell-editor-BfrmXiOh.js} +5 -5
- package/dist/assets/{cell-link-Bx8FWjns.js → cell-link-CvOBew-Z.js} +1 -1
- package/dist/assets/{cells-Biwqg0z6.js → cells-BIt-E5vq.js} +57 -57
- package/dist/assets/{chat-display-B2qUbgnh.js → chat-display-B27UEebd.js} +1 -1
- package/dist/assets/{chat-panel-gxL2S-HQ.js → chat-panel-C4jJ8gOg.js} +1 -1
- package/dist/assets/{chat-ui-BhnwgDpa.js → chat-ui-DJ41RveI.js} +1 -1
- package/dist/assets/{column-preview-wrymhKlT.js → column-preview-BVzFL_8v.js} +1 -1
- package/dist/assets/{command-palette-oY9BI5F9.js → command-palette-SErocd73.js} +1 -1
- package/dist/assets/{common-sBRwGAKy.js → common-BGAfLk4T.js} +1 -1
- package/dist/assets/{components-DsJAWbBR.js → components-DMNnJpT_.js} +1 -1
- package/dist/assets/{data-source-discovery-DCNYJylO.js → data-source-discovery-DdefgaOP.js} +1 -1
- package/dist/assets/{datasource-DxCwZdAq.js → datasource-0Urr2OFR.js} +2 -2
- package/dist/assets/{dependency-graph-panel-CLOQ_RvL.js → dependency-graph-panel-CQSSUBtY.js} +1 -1
- package/dist/assets/{documentation-panel-D9w8PAT9.js → documentation-panel-Mo3B93Dq.js} +1 -1
- package/dist/assets/{download-CfUkZlw7.js → download-DYiwRe8_.js} +1 -1
- package/dist/assets/{edit-page-Do204YE6.js → edit-page-xv_028Km.js} +4 -4
- package/dist/assets/{error-entries-DpvSrZSw.js → error-entries-BTA-sOIB.js} +1 -1
- package/dist/assets/{error-panel-uRl1_l47.js → error-panel-BMpvsfkK.js} +1 -1
- package/dist/assets/{file-explorer-panel-Bc75pRB9.js → file-explorer-panel-BATjfG7j.js} +1 -1
- package/dist/assets/{file-icons-DpREEjwW.js → file-icons-7V36_u0o.js} +1 -1
- package/dist/assets/{file-name-input-C7AQKuoU.js → file-name-input-BCi-JD7l.js} +1 -1
- package/dist/assets/{floating-outline-4I6DvqaR.js → floating-outline-CmgEk2gZ.js} +1 -1
- package/dist/assets/{focus-CeTtpVjV.js → focus-agtnrA0w.js} +1 -1
- package/dist/assets/{form-B10bgcbQ.js → form-DbRAwKK1.js} +1 -1
- package/dist/assets/{form-D9rHu7Cq.js → form-sf0A_nV4.js} +1 -1
- package/dist/assets/{home-page-BNJihtii.js → home-page-DbqvhmFo.js} +1 -1
- package/dist/assets/{html-to-image-ChfBVn8-.js → html-to-image-BvGsu9Nz.js} +1 -1
- package/dist/assets/{index-XtcQuufP.js → index-CSJwPAAg.js} +5 -5
- package/dist/assets/{layout-BGbMrroI.js → layout-BBB9DQha.js} +3 -3
- package/dist/assets/{logs-panel-ClE58_4G.js → logs-panel-CtZ-76hx.js} +1 -1
- package/dist/assets/{markdown-renderer-BOS4jZLt.js → markdown-renderer-CP1Up_3K.js} +1 -1
- package/dist/assets/{name-cell-input-UMsLssMV.js → name-cell-input-7EVAIGJb.js} +1 -1
- package/dist/assets/{outline-panel-DweKocZK.js → outline-panel-BUPKUip_.js} +1 -1
- package/dist/assets/{packages-panel-Cbw5J5QD.js → packages-panel-DMfz7YUA.js} +1 -1
- package/dist/assets/{panel-accordion-state-CgvX-ElJ.js → panel-accordion-state-Rl5fu2O3.js} +1 -1
- package/dist/assets/{panels-CCNbfGX1.js → panels-v1_Bo-9b.js} +1 -1
- package/dist/assets/{process-output-BMxr8Z3g.js → process-output-CwYvnqai.js} +1 -1
- package/dist/assets/{radio-group-YNmbPL7y.js → radio-group-CFoizYY0.js} +1 -1
- package/dist/assets/{readonly-code-display-N9tCXdCz.js → readonly-code-display-evFzJqo3.js} +1 -1
- package/dist/assets/{readonly-python-code-BHrAhtGV.js → readonly-python-code-DeHfRkyx.js} +1 -1
- package/dist/assets/{reveal-component-CkUOqs6t.js → reveal-component-Xpt5ATiU.js} +1 -1
- package/dist/assets/{run-page-DZ9O8xra.js → run-page-CyrHzfTi.js} +1 -1
- package/dist/assets/{scratchpad-panel-SKv1cqWC.js → scratchpad-panel-CwLyjPgK.js} +1 -1
- package/dist/assets/{session-panel-Dn6J9S-p.js → session-panel-wwlutzcx.js} +1 -1
- package/dist/assets/{skeleton-CPbmAcKR.js → skeleton-CqtoHThq.js} +1 -1
- package/dist/assets/{snippets-panel-cYP0GMUf.js → snippets-panel-CmNQL12H.js} +1 -1
- package/dist/assets/{state-DJon00Ew.js → state-D2PXKlv7.js} +1 -1
- package/dist/assets/{state-Dc5AjWPq.js → state-D9aD2R5_.js} +1 -1
- package/dist/assets/{tracing-dGSNt8Nm.js → tracing-D-Pv6KLc.js} +1 -1
- package/dist/assets/{tracing-panel-CQCgx3e4.js → tracing-panel-CE9SGDWn.js} +2 -2
- package/dist/assets/{tree-actions-pW_UgP3m.js → tree-actions-B7cSMuSB.js} +1 -1
- package/dist/assets/{useCellActionButton-De17Z9R3.js → useCellActionButton-CDwMe7L6.js} +1 -1
- package/dist/assets/{useDeleteCell-BgFMPTmg.js → useDeleteCell-C6_GiKMv.js} +1 -1
- package/dist/assets/{useDependencyPanelTab-w8VLtsK3.js → useDependencyPanelTab-DL7ebTCt.js} +1 -1
- package/dist/assets/{useNotebookActions-DaBCZvGq.js → useNotebookActions-DNf7n1OO.js} +1 -1
- package/dist/assets/{useRunCells-CAfRBo7h.js → useRunCells-SSVpCuNe.js} +1 -1
- package/dist/assets/{useSplitCell-N8Ohs-Pp.js → useSplitCell-ChS6iNjW.js} +1 -1
- package/dist/index.html +23 -23
- package/package.json +1 -1
- package/src/utils/__tests__/url-parser.test.ts +26 -0
- package/src/utils/json/__tests__/json-parser.test.ts +33 -0
- package/src/utils/json/json-parser.ts +5 -3
- package/src/utils/url-parser.ts +4 -3
- package/dist/assets/MarimoErrorOutput-Db7coyFA.js +0 -11
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{o as le}from"./chunk-C4rtOYze.js";import{d as ae,f as ie,i as Ue,l as oe,n as Be,p as Oe,u as ce}from"./useEvent-GCVIknuR.js";import{t as Qe}from"./react-C60yClUi.js";import{$n as de,Bn as me,E as Re,Gi as Ve,Ir as He,Ki as pe,Kn as Y,Sa as Ke,aa as Z,it as Ge,jr as Je,y as Xe}from"./cells-BIt-E5vq.js";import{t as A}from"./compiler-runtime-DnimoHo0.js";import{g as Ye,p as Ze}from"./useEventListener-DpNnLPuE.js";import{t as et}from"./invariant-BUdrueMv.js";import{a as tt,i as st,x as rt}from"./utils-C8Yt16Y7.js";import{t as ue}from"./cn-DCUzRj2J.js";import{t as nt}from"./jsx-runtime-3wZU7vFS.js";import{a as lt,i as at,o as it,r as ot,t as ct}from"./config-DjP9S1hr.js";import{a as dt,p as mt,r as pt,t as ut}from"./dropdown-menu-DWGvf_Bw.js";import{t as Q}from"./tooltip-C9LWGQ7Y.js";import{r as xe,t as E}from"./button-W__YVea9.js";import{n as xt}from"./strings-DmKKoXrM.js";import{t as he}from"./createLucideIcon-B8oVfJNp.js";import{t as ht}from"./check-CyyJPf_5.js";import{r as fe}from"./x-4y-nyVDU.js";import{t as ft}from"./chevron-right-C9ZBG6Lx.js";import{t as gt}from"./hat-glasses-xLTnAC_n.js";import{t as jt}from"./package-ROei-DG7.js";import{t as yt}from"./sparkles-DwqcWrJl.js";import{l as ge,r as bt}from"./datasource-0Urr2OFR.js";import{a as vt}from"./dist-Bm9PT5P9.js";import{t as Nt}from"./uuid-e9lSomwA.js";import{t as It}from"./use-toast-DjpWVza6.js";import{t as wt}from"./RenderHTML-DsxkHR2d.js";import{t as je}from"./kbd-PEowR7op.js";import{t as q}from"./links-BeU4kHTI.js";import{r as kt,t as $t}from"./alert-CHWQT4zh.js";import{o as _t,t as At}from"./useInstallPackage-D58nBaNf.js";import{n as Tt,o as Ft}from"./state-D2PXKlv7.js";import{n as $}from"./cell-link-CvOBew-Z.js";var L=he("square-arrow-out-up-right",[["path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6",key:"y09zxi"}],["path",{d:"m21 3-9 9",key:"mpx6sq"}],["path",{d:"M15 3h6v6",key:"1q9fwt"}]]),ye=he("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]),be=String.raw`_cell_([^\W_][\w-]*?)(_\w*)`,ve=String.raw`(?<!_)${be}`;`${be}`;var St=new RegExp(ve),ee=new RegExp(ve,"g");function Ne(t){let e=[];ee.lastIndex=0;let n=0,r=ee.exec(t);for(;r!==null;)r.index>n&&e.push(t.slice(n,r.index)),e.push({cellId:r[1],name:r[2]}),n=r.index+r[0].length,r=ee.exec(t);return n<t.length&&e.push(t.slice(n)),e}function Ct(t){return St.test(t)}function Mt(t){let e=null,n=t.cursor();do n.name==="ExpressionStatement"&&(e=n.node);while(n.next());return e}function Et(t){let e=t.split(`
|
|
2
|
+
`),n=" ",r=Mt(vt.parse(t));if(!r)return["def _():",...te(e,n),`${n}return`,"","","_()"].join(`
|
|
3
|
+
`);let a=t.slice(0,r.from).trim(),l=t.slice(r.from).trim(),o=a.split(`
|
|
4
|
+
`),i=l.split(`
|
|
5
|
+
`);return["def _():",...te(o,n),`${n}return ${i[0]}`,...te(i.slice(1),n),"","","_()"].join(`
|
|
6
|
+
`)}function te(t,e){if(t.length===1&&t[0]==="")return[];let n=[];for(let r of t)r===""?n.push(""):n.push(e+r);return n}function Pt(t,e){var n;if(t.type==="multiple-defs")return[{title:"Fix: Wrap in a function",description:"Make this cell's variables local by wrapping the cell in a function.",fixType:"manual",onFix:async r=>{et(r.editor,"Editor is null");let a=Et(r.editor.state.doc.toString());r.editor.dispatch({changes:{from:0,to:r.editor.state.doc.length,insert:a}})}}];if(t.type==="exception"&&t.exception_type==="NameError"){let r=(n=t.msg.match(/name '(.+)' is not defined/))==null?void 0:n[1];if(!r||!(r in Ie))return[];let a=zt(r);return[{title:`Fix: Add '${a}'`,description:"Add a new cell for the missing import",fixType:"manual",onFix:async l=>{l.addCodeBelow(a)}}]}return t.type==="sql-error"&&e.aiEnabled?[{title:"Fix with AI",description:"Fix the SQL statement",fixType:"ai",onFix:async r=>{var o;let a=bt(r.cellId,Ue),l=`Fix the SQL statement: ${t.msg}.`;a&&(l+=`
|
|
7
|
+
Database schema: ${a}`),(o=r.aiFix)==null||o.setAiCompletionCell({cellId:r.cellId,initialPrompt:l,triggerImmediately:r.aiFix.triggerFix})}}]:[]}function zt(t){let e=Ie[t];return e===t?`import ${e}`:`import ${e} as ${t}`}var Ie={mo:"marimo",alt:"altair",bokeh:"bokeh",dask:"dask",np:"numpy",pd:"pandas",pl:"polars",plotly:"plotly",plt:"matplotlib.pyplot",px:"plotly.express",scipy:"scipy",sk:"sklearn",sns:"seaborn",stats:"scipy.stats",tf:"tensorflow",torch:"torch",xr:"xarray",dt:"datetime",json:"json",math:"math",os:"os",re:"re",sys:"sys"},we=1;const R=Z("marimo:acp:sessions:v1",{sessions:[],activeTabId:null},Y),qt=Oe(t=>{let e=t(R);return e.activeTabId&&e.sessions.find(n=>n.tabId===e.activeTabId)||null},(t,e,n)=>{e(R,r=>({...r,activeTabId:n}))});function Lt(){return`tab_${Nt()}`}function ke(t,e=20){return t.length<=e?t:`${t.slice(0,e-3)}...`}function Wt(t,e){let n=$e(e.agentId),r=Date.now(),a=e.firstMessage?ke(e.firstMessage.trim()):`New ${e.agentId} session`,l=Lt();if(n==="single"){let o=t.sessions.filter(c=>c.agentId===e.agentId),i=t.sessions.filter(c=>c.agentId!==e.agentId);if(o.length>0){let c=o[0],d={agentId:e.agentId,title:a,createdAt:r,lastUsedAt:r,tabId:c.tabId,externalAgentSessionId:null,selectedModel:e.model??c.selectedModel??null};return{...t,sessions:[...i.slice(0,we-1),d],activeTabId:d.tabId}}}return{...t,sessions:[...t.sessions.slice(0,we-1),{agentId:e.agentId,tabId:l,title:a,createdAt:r,lastUsedAt:r,externalAgentSessionId:null,selectedModel:e.model??null}],activeTabId:l}}function Dt(t,e){let n=t.sessions.filter(r=>r.tabId!==e);return{sessions:n,activeTabId:t.activeTabId===e?n.length>0?n[n.length-1].tabId:null:t.activeTabId}}function Ut(t,e){let n=t.activeTabId;return n?{...t,sessions:t.sessions.map(r=>r.tabId===n?{...r,title:ke(e)}:r)}:t}function Bt(t,e){return{...t,sessions:t.sessions.map(n=>n.tabId===e?{...n,lastUsedAt:Date.now()}:n)}}function Ot(t,e){let n=t.activeTabId;return n?{...t,sessions:t.sessions.map(r=>r.tabId===n?{...r,externalAgentSessionId:e,lastUsedAt:Date.now()}:r)}:t}function Qt(){return["claude","gemini","codex","opencode","cursor"]}function Rt(t){return xt(t)}function Vt(t){let e=V[t].port,n=window.location.hostname;return`${window.location.protocol==="https:"?"wss:":"ws:"}//${n}:${e}/message`}var V={claude:{port:3017,command:"npx @zed-industries/claude-code-acp",sessionSupport:"single"},gemini:{port:3019,command:"npx @google/gemini-cli --experimental-acp",sessionSupport:"single"},codex:{port:3021,command:"npx @zed-industries/codex-acp",sessionSupport:"single"},opencode:{port:3023,command:"npx opencode-ai acp",sessionSupport:"single"},cursor:{port:3025,command:"agent acp",sessionSupport:"single"}};function $e(t){return V[t].sessionSupport}function Ht(t){let e=V[t].port,n=V[t].command;return`npx stdio-to-ws "${Ze()?`cmd /c ${n}`:n}" --port ${e}`}var Kt=A();const _e=Z("marimo:chrome:ai-panel-tab","chat",Y);function Ae(){let t=(0,Kt.c)(3),[e,n]=oe(_e),r;return t[0]!==e||t[1]!==n?(r={aiPanelTab:e,setAiPanelTab:n},t[0]=e,t[1]=n,t[2]=r):r=t[2],r}var Gt=A(),Jt="code_mode";function Xt(t,e){return t||(de("external_agents")?e:"chat")}function Te(){let t=(0,Gt.c)(6),{openApplication:e}=me(),{setAiPanelTab:n}=Ae(),{saveModeChange:r}=ct(),a=ae(Ft),l=ie(),o;return t[0]!==e||t[1]!==r||t[2]!==n||t[3]!==a||t[4]!==l?(o=async i=>{let c=Xt(i.panel,l.get(_e)),d=l.get(tt),p=de("external_agents")&&l.get(R).sessions.length>0;if(!(c==="agents"?p:d)){It({title:c==="agents"?"No agent session":"AI not configured",description:c==="agents"?"Start an agent session or switch to the chat panel.":"Configure an AI provider and chat model to fix with AI.",variant:"danger"});return}i.panel&&n(i.panel),c==="chat"&&await r(Jt).catch(Yt),a({prompt:i.prompt,submit:i.submit??!1}),e("ai")},t[0]=e,t[1]=r,t[2]=n,t[3]=a,t[4]=l,t[5]=o):o=t[5],Be(o)}function Yt(){return Ye.error("Failed to save mode change")}var Zt=A(),es=Z("marimo:ai-autofix-mode","autofix",Y);function ts(){let t=(0,Zt.c)(3),[e,n]=oe(es),r;return t[0]!==e||t[1]!==n?(r={fixMode:e,setFixMode:n},t[0]=e,t[1]=n,t[2]=r):r=t[2],r}var se=A(),s=le(nt(),1);function Fe(t,e){if(t!=null)return`@error://${t}
|
|
8
|
+
|
|
9
|
+
Please fix this error.`;let n=e==null?void 0:e.trim();return n?`My code gives the following error. Please fix it:
|
|
10
|
+
|
|
11
|
+
${n}`:"Please fix this error."}const w=t=>{let e=(0,se.c)(25),{errors:n,cellId:r,className:a}=t,l=ie(),{createNewCell:o}=Re(),i=ce(st),c;if(e[0]!==i||e[1]!==n){let v;e[3]===i?v=e[4]:(v=k=>Pt(k,{aiEnabled:i}),e[3]=i,e[4]=v),c=n.flatMap(v),e[0]=i,e[1]=n,e[2]=c}else c=e[2];let d=c,p=ae(Tt),u=Te();if(d.length===0)return null;let m=d[0],x;e[5]!==r||e[6]!==o||e[7]!==m||e[8]!==p||e[9]!==l?(x=v=>{var S;let k=(S=l.get(Xe).cellHandles[r].current)==null?void 0:S.editorView;m.onFix({addCodeBelow:P=>{o({cellId:r,autoFocus:!1,before:!1,code:P})},editor:k,cellId:r,aiFix:{setAiCompletionCell:p,triggerFix:v}}),k==null||k.focus()},e[5]=r,e[6]=o,e[7]=m,e[8]=p,e[9]=l,e[10]=x):x=e[10];let g=x,h;e[11]!==r||e[12]!==u?(h=()=>{u({prompt:Fe(r)})},e[11]=r,e[12]=u,e[13]=h):h=e[13];let y=h,j;e[14]===a?j=e[15]:(j=ue("my-2",a),e[14]=a,e[15]=j);let b;e[16]!==m.description||e[17]!==m.fixType||e[18]!==m.title||e[19]!==g||e[20]!==y?(b=m.fixType==="ai"?(0,s.jsx)(Ce,{tooltip:m.description,openPrompt:()=>g(!1),applyAutofix:()=>g(!0),openChat:y}):(0,s.jsx)(Q,{content:m.description,align:"start",children:(0,s.jsxs)(E,{size:"xs",variant:"outline",className:"font-normal",onClick:()=>g(!1),children:[(0,s.jsx)(ge,{className:"h-3 w-3 mr-2"}),m.title]})}),e[16]=m.description,e[17]=m.fixType,e[18]=m.title,e[19]=g,e[20]=y,e[21]=b):b=e[21];let N;return e[22]!==j||e[23]!==b?(N=(0,s.jsx)("div",{className:j,children:b}),e[22]=j,e[23]=b,e[24]=N):N=e[24],N};var Se={autofix:{Icon:ge,title:"Inline AI Fix",description:"Apply AI fixes inline in the cell"},chat:{Icon:gt,title:"Fix with AI assistant",description:"Open the AI sidebar to fix"},prompt:{Icon:yt,title:"Suggest a prompt",description:"Edit the prompt before applying"}},ss=["autofix","prompt","chat"];const Ce=t=>{let e=(0,se.c)(18),{tooltip:n,openPrompt:r,applyAutofix:a,openChat:l}=t,{fixMode:o,setFixMode:i}=ts(),c=r;o==="chat"?c=l:o==="autofix"&&(c=a);let{Icon:d,title:p}=Se[o],u;e[0]===d?u=e[1]:(u=(0,s.jsx)(d,{className:"h-3 w-3 mr-2 mb-0.5"}),e[0]=d,e[1]=u);let m;e[2]!==c||e[3]!==u||e[4]!==p?(m=(0,s.jsxs)(E,{size:"xs",variant:"outline",className:"font-normal rounded-r-none border-r-0",onClick:c,children:[u,p]}),e[2]=c,e[3]=u,e[4]=p,e[5]=m):m=e[5];let x;e[6]!==m||e[7]!==n?(x=(0,s.jsx)(Q,{content:n,align:"start",children:m}),e[6]=m,e[7]=n,e[8]=x):x=e[8];let g;e[9]===Symbol.for("react.memo_cache_sentinel")?(g=(0,s.jsx)(mt,{asChild:!0,children:(0,s.jsx)(E,{size:"xs",variant:"outline",className:"rounded-l-none px-2","aria-label":"Fix options",children:(0,s.jsx)(fe,{className:"h-3 w-3"})})}),e[9]=g):g=e[9];let h;e[10]!==o||e[11]!==i?(h=ss.map(b=>(0,s.jsx)(dt,{className:"flex items-center gap-2",onClick:()=>i(b),children:(0,s.jsx)(rs,{mode:b,selected:b===o})},b)),e[10]=o,e[11]=i,e[12]=h):h=e[12];let y;e[13]===h?y=e[14]:(y=(0,s.jsxs)(ut,{children:[g,(0,s.jsx)(pt,{align:"end",className:"w-56",children:h})]}),e[13]=h,e[14]=y);let j;return e[15]!==x||e[16]!==y?(j=(0,s.jsxs)("div",{className:"flex",children:[x,y]}),e[15]=x,e[16]=y,e[17]=j):j=e[17],j};var rs=t=>{let e=(0,se.c)(15),{mode:n,selected:r}=t,{Icon:a,title:l,description:o}=Se[n],i;e[0]===a?i=e[1]:(i=(0,s.jsx)(a,{className:"h-4 w-4 shrink-0"}),e[0]=a,e[1]=i);let c;e[2]===l?c=e[3]:(c=(0,s.jsx)("span",{className:"font-medium",children:l}),e[2]=l,e[3]=c);let d;e[4]===o?d=e[5]:(d=(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:o}),e[4]=o,e[5]=d);let p;e[6]!==c||e[7]!==d?(p=(0,s.jsxs)("div",{className:"flex flex-col",children:[c,d]}),e[6]=c,e[7]=d,e[8]=p):p=e[8];let u;e[9]===r?u=e[10]:(u=r&&(0,s.jsx)(ht,{className:"h-4 w-4 ml-auto shrink-0"}),e[9]=r,e[10]=u);let m;return e[11]!==i||e[12]!==p||e[13]!==u?(m=(0,s.jsxs)("div",{className:"flex items-center gap-2 w-full",children:[i,p,u]}),e[11]=i,e[12]=p,e[13]=u,e[14]=m):m=e[14],m},Me=A();const ns=t=>{let e=(0,Me.c)(12),{local:n}=t,r;e[0]===n.name?r=e[1]:(r=(0,s.jsx)("span",{className:"font-code",children:n.name}),e[0]=n.name,e[1]=r);let a;e[2]===n.cellId?a=e[3]:(a=(0,s.jsx)($,{cellId:n.cellId}),e[2]=n.cellId,e[3]=a);let l;e[4]!==r||e[5]!==a?(l=(0,s.jsxs)("div",{className:"max-w-xs",children:["Local variable ",r," in cell"," ",a,"."]}),e[4]=r,e[5]=a,e[6]=l):l=e[6];let o=l,i;e[7]===n.name?i=e[8]:(i=(0,s.jsx)("span",{className:"font-code cursor-help",children:n.name}),e[7]=n.name,e[8]=i);let c;return e[9]!==i||e[10]!==o?(c=(0,s.jsx)(Q,{content:o,children:i}),e[9]=i,e[10]=o,e[11]=c):c=e[11],c},Ee=t=>{let e=(0,Me.c)(4),{segments:n}=t,r;e[0]===n?r=e[1]:(r=n.map(ls),e[0]=n,e[1]=r);let a;return e[2]===r?a=e[3]:(a=(0,s.jsx)(s.Fragment,{children:r}),e[2]=r,e[3]=a),a};function ls(t,e){return typeof t=="string"?(0,s.jsx)("span",{children:t},e):(0,s.jsx)(ns,{local:t},e)}var Pe=A(),W=le(Qe(),1),as=new Ge;const re=t=>{let e=RegExp("\x1B\\[[0-9;]*m","g");return t.replaceAll(e,"")};var ze=/(pip\s+install|uv\s+add|uv\s+pip\s+install)\s+/gi;function is(t){ze.lastIndex=0;let e=ze.exec(t);if(!e)return null;let n=e.index+e[0].length,r=t.slice(n).split(/\s+/),a="",l=0;for(let i of r){let c=i.trim();if(!c)continue;if(c.startsWith("-")){l+=c.length+1;continue}let d=c.match(/^[\w,.[\]-]+/);if(d){a=d[0];break}break}if(!a)return null;let o=n+l+a.length;return{package:a,endIndex:o}}function T(t,e=""){if(!t)return null;if(!/https?:\/\//.test(t))return t;let n=Ke(t);return n.length===1&&n[0].type==="text"?t:(0,s.jsx)(s.Fragment,{children:n.map((r,a)=>{let l=e?`${e}-${a}`:a;if(r.type==="url"){let o=re(r.url);return(0,s.jsx)("a",{href:o,target:"_blank",rel:"noopener noreferrer",onClick:xe.stopPropagation(),className:"text-link hover:underline",children:o},l)}if(r.type==="image"){let o=re(r.url);return(0,s.jsx)("a",{href:o,target:"_blank",rel:"noopener noreferrer",onClick:xe.stopPropagation(),className:"text-link hover:underline",children:o},l)}return(0,s.jsx)(W.Fragment,{children:r.value},l)})})}var os=t=>{let e=(0,Pe.c)(6),{packages:n,children:r}=t,{handleInstallPackages:a}=At(),l;e[0]!==a||e[1]!==n?(l=i=>{a(n),i.preventDefault()},e[0]=a,e[1]=n,e[2]=l):l=e[2];let o;return e[3]!==r||e[4]!==l?(o=(0,s.jsx)("button",{onClick:l,className:"text-link hover:underline",type:"button",children:r}),e[3]=r,e[4]=l,e[5]=o):o=e[5],o};const cs=t=>{if(!(t instanceof pe.Text))return;let e=re(t.data);if(!/(pip\s+install|uv\s+add|uv\s+pip\s+install)/i.test(e))return;let n=[],r=/(pip\s+install|uv\s+add|uv\s+pip\s+install)\s+/gi,a;for(;(a=r.exec(e))!==null;){let i=a.index,c=is(e.slice(i));c&&n.push({match:a,result:c})}if(n.length===0)return;let l=[],o=0;if(n.forEach((i,c)=>{let{match:d,result:p}=i,u=d.index,m=u+p.endIndex;if(o<u){let g=e.slice(o,u);l.push((0,s.jsx)(W.Fragment,{children:T(g,`before-${c}`)},`before-${c}`))}let x=e.slice(u,m);l.push((0,s.jsx)(os,{packages:[p.package],children:x},`install-${c}`)),o=m}),o<e.length){let i=e.slice(o);l.push((0,s.jsx)(W.Fragment,{children:T(i,"after")},"after"))}return(0,s.jsx)(s.Fragment,{children:l})},ds=t=>{if(!(t instanceof pe.Text))return;let e=t.data;if(!/https?:\/\//.test(e))return;let n=T(e);if(typeof n!="string")return(0,s.jsx)(s.Fragment,{children:n})},ms=(...t)=>e=>{for(let n of t){let r=n(e);if(r!==void 0)return r}},ps=(t,e)=>(0,s.jsx)("span",{children:Ve(as.ansi_to_html(t),{replace:n=>e(n)})}),us=t=>{let e=(0,Pe.c)(4),{text:n}=t,r;e[0]===n?r=e[1]:(r=ps(n,ms(cs,ds)),e[0]=n,e[1]=r);let a=r,l;return e[2]===a?l=e[3]:(l=(0,s.jsx)(s.Fragment,{children:a}),e[2]=a,e[3]=l),l};var ne=A(),qe=t=>{let e=(0,ne.c)(16),{traceback:n}=t,[r,a]=(0,W.useState)(!0),l;e[0]===r?l=e[1]:(l=()=>a(!r),e[0]=r,e[1]=l);let o=r?"Collapse traceback":"Expand traceback",i;e[2]===r?i=e[3]:(i=r?(0,s.jsx)(fe,{className:"h-3 w-3"}):(0,s.jsx)(ft,{className:"h-3 w-3"}),e[2]=r,e[3]=i);let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=(0,s.jsx)("span",{className:"text-[0.6875rem] uppercase tracking-wider",children:"Traceback"}),e[4]=c):c=e[4];let d;e[5]!==r||e[6]!==l||e[7]!==o||e[8]!==i?(d=(0,s.jsxs)("button",{type:"button",onClick:l,"aria-expanded":r,"aria-label":o,className:"flex items-center gap-1 text-muted-foreground/70 hover:text-muted-foreground transition-colors",children:[i,c]}),e[5]=r,e[6]=l,e[7]=o,e[8]=i,e[9]=d):d=e[9];let p;e[10]!==r||e[11]!==n?(p=r&&(0,s.jsx)("div",{className:"font-code text-sm mt-1 p-3 bg-muted rounded border overflow-auto max-h-[50vh] cursor-text select-text",children:wt({html:n})}),e[10]=r,e[11]=n,e[12]=p):p=e[12];let u;return e[13]!==d||e[14]!==p?(u=(0,s.jsxs)("div",{className:"mt-2",children:[d,p]}),e[13]=d,e[14]=p,e[15]=u):u=e[15],u},F=t=>{let e=(0,ne.c)(10),n=t.title??"Tip",r;e[0]===n?r=e[1]:(r=(0,s.jsx)(it,{className:"pt-2 pb-0 font-normal",children:n}),e[0]=n,e[1]=r);let a;e[2]===t.children?a=e[3]:(a=(0,s.jsx)(at,{className:"mr-24 text-[0.84375rem]",wrapperClassName:"pt-0 pb-2",children:t.children}),e[2]=t.children,e[3]=a);let l;e[4]!==r||e[5]!==a?(l=(0,s.jsxs)(lt,{value:"item-1",className:"text-muted-foreground",children:[r,a]}),e[4]=r,e[5]=a,e[6]=l):l=e[6];let o;return e[7]!==t.className||e[8]!==l?(o=(0,s.jsx)(ot,{type:"single",collapsible:!0,className:t.className,children:l}),e[7]=t.className,e[8]=l,e[9]=o):o=e[9],o};const xs=t=>{let e=(0,ne.c)(38),{errors:n,cellId:r,className:a}=t,l=me(),o=ce(rt).display.cell_output==="above",i="This cell wasn't run because it has errors",c="destructive",d="text-error",p=null;if(n.some(hs))i="Interrupted";else if(n.some(fs))i="An internal error occurred";else if(n.some(gs))i="Ancestor prevented from running",c="default",d="text-secondary-foreground";else if(n.some(js))i="Ancestor stopped",c="default",d="text-secondary-foreground";else if(n.some(ys))i="SQL error";else if(n.some(bs))i=null,p="Cell not run";else{let N;e[0]===n?N=e[1]:(N=n.find(vs),e[0]=n,e[1]=N);let v=N;v&&"exception_type"in v&&(i=v.exception_type)}let u,m,x,g,h,y;if(e[2]!==c||e[3]!==r||e[4]!==l||e[5]!==a||e[6]!==n||e[7]!==o||e[8]!==p||e[9]!==d||e[10]!==i){let N=n.filter(Ns),v=n.filter(Is),k=n.filter(ws),S=n.filter(ks),P=n.filter($s),D=n.filter(_s),U=n.filter(As),H=n.filter(Ts),K=n.filter(Fs),G=n.filter(Ss),z=n.filter(Cs),J=n.filter(Ms),X=n.filter(Es),B;e[17]===l?B=e[18]:(B=()=>{l.openApplication("scratchpad")},e[17]=l,e[18]=B);let Le=B,We=()=>{let I=[];if(z.length>0||J.length>0){let f=z.some(Ps),_=!f&&z.some(zs);I.push((0,s.jsxs)("div",{children:[z.map(qs),J.map(Ls),f&&(0,s.jsxs)(E,{size:"xs",variant:"outline",className:"mt-2 font-normal",onClick:()=>_t(l),children:[(0,s.jsx)(jt,{className:"h-3.5 w-3.5 mr-1.5 mb-0.5"}),(0,s.jsx)("span",{children:"Open package manager"})]}),_&&(0,s.jsxs)(E,{size:"xs",variant:"outline",className:"mt-2 font-normal",onClick:()=>l.openApplication("terminal"),children:[(0,s.jsx)(ye,{className:"h-3.5 w-3.5 mr-1.5"}),(0,s.jsx)("span",{children:"Open terminal"})]}),r&&(0,s.jsx)(w,{errors:[...z,...J],cellId:r})]},"syntax-unknown"))}if(N.length>0&&I.push((0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-muted-foreground font-medium",children:"The setup cell cannot be run because it has references."}),(0,s.jsx)("ul",{className:"list-disc",children:N.flatMap(Ws)}),r&&(0,s.jsx)(w,{errors:N,cellId:r}),(0,s.jsxs)(F,{title:"Why can't the setup cell have references?",className:"mb-2",children:[(0,s.jsx)("p",{className:"pb-2",children:"The setup cell contains logic that must be run before any other cell runs, including top-level imports used by top-level functions. For this reason, it can't refer to other cells' variables."}),(0,s.jsx)("p",{className:"py-2",children:"Try simplifying the setup cell to only contain only necessary variables."}),(0,s.jsxs)("p",{className:"py-2",children:[(0,s.jsxs)(q,{href:"https://links.marimo.app/errors-setup",children:["Learn more at our docs"," ",(0,s.jsx)(L,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"setup-refs")),v.length>0&&I.push((0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-muted-foreground font-medium",children:"This cell is in a cycle."}),(0,s.jsx)("ul",{className:"list-disc",children:v.flatMap(Ds)}),r&&(0,s.jsx)(w,{errors:v,cellId:r}),(0,s.jsxs)(F,{title:"What are cycles and how do I resolve them?",className:"mb-2",children:[(0,s.jsx)("p",{className:"pb-2",children:"An example of a cycle is if one cell declares a variable 'a' and reads 'b', and another cell declares 'b' and and reads 'a'. Cycles like this make it impossible for marimo to know how to run your cells, and generally suggest that your code has a bug."}),(0,s.jsx)("p",{className:"py-2",children:"Try merging these cells into a single cell to eliminate the cycle."}),(0,s.jsxs)("p",{className:"py-2",children:[(0,s.jsxs)(q,{href:"https://links.marimo.app/errors-cycles",children:["Learn more at our docs"," ",(0,s.jsx)(L,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"cycle")),k.length>0){let f=k[0].name;I.push((0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-muted-foreground font-medium",children:"This cell redefines variables from other cells."}),k.map(Bs),r&&(0,s.jsx)(w,{errors:k,cellId:r}),(0,s.jsxs)(F,{title:"Why can't I redefine variables?",children:[(0,s.jsx)("p",{className:"pb-2",children:"marimo requires that each variable is defined in just one cell. This constraint enables reactive and reproducible execution, arbitrary cell reordering, seamless UI elements, execution as a script, and more."}),(0,s.jsxs)("p",{className:"py-2",children:["Try merging this cell with the mentioned cells or wrapping it in a function. Alternatively, prefix variables with an underscore (e.g., ",(0,s.jsxs)(je,{className:"inline",children:["_",f]}),"). to make them private to this cell."]}),(0,s.jsxs)("p",{className:"py-2",children:[(0,s.jsxs)(q,{href:"https://links.marimo.app/errors-multiple-definitions",children:["Learn more at our docs"," ",(0,s.jsx)(L,{size:"0.75rem",className:"inline"})]}),"."]})]}),(0,s.jsx)(F,{title:"Need a scratchpad?",children:(0,s.jsxs)("div",{className:"flex flex-row gap-2 items-center",children:[(0,s.jsxs)(E,{size:"xs",variant:"link",className:"my-2 font-normal mx-0 px-0",onClick:Le,children:[(0,s.jsx)(Je,{className:"h-3"}),(0,s.jsx)("span",{children:"Try the scratchpad"})]}),(0,s.jsx)("span",{children:"to experiment without restrictions on variable names."})]})})]},"multiple-defs"))}return S.length>0&&I.push((0,s.jsxs)("div",{children:[S.map(Os),r&&(0,s.jsx)(w,{errors:S,cellId:r}),(0,s.jsxs)(F,{title:"Why can't I use `import *`?",children:[(0,s.jsx)("p",{className:"pb-2",children:"Star imports are incompatible with marimo's git-friendly file format and reproducible reactive execution."}),(0,s.jsx)("p",{className:"py-2",children:"marimo's Python file format stores code in functions, so notebooks can be imported as regular Python modules without executing all their code. But Python disallows `import *` everywhere except at the top-level of a module."}),(0,s.jsx)("p",{className:"py-2",children:"Star imports would also silently add names to globals, which would be incompatible with reactive execution."}),(0,s.jsxs)("p",{className:"py-2",children:[(0,s.jsxs)(q,{href:"https://links.marimo.app/errors-import-star",children:["Learn more at our docs"," ",(0,s.jsx)(L,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"import-star")),P.length>0&&I.push((0,s.jsxs)("div",{children:[P.map(Qs),r&&(0,s.jsx)(w,{errors:P,cellId:r})]},"interruption")),D.length>0&&I.push((0,s.jsxs)("ul",{children:[D.map((f,_)=>f.exception_type==="NameError"&&f.msg.startsWith("name 'mo'")?(0,s.jsx)("li",{className:"my-2",children:(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-muted-foreground",children:"name 'mo' is not defined."}),(0,s.jsxs)("p",{className:"text-muted-foreground mt-2",children:["The marimo module (imported as"," ",(0,s.jsx)(je,{className:"inline",children:"mo"}),") is required for Markdown, SQL, and UI elements."]})]})},`exception-${_}`):f.exception_type==="NameError"&&f.msg.startsWith("name '_")?(0,s.jsx)("li",{className:"my-2",children:(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-muted-foreground",children:(0,s.jsx)(Ee,{segments:Ne(f.msg)})}),(0,s.jsxs)("p",{className:"text-muted-foreground mt-2",children:["Variables prefixed with an underscore are local to a cell"," ","(",(0,s.jsxs)(q,{href:"https://links.marimo.app/local-variables",children:["docs"," ",(0,s.jsx)(L,{size:"0.75rem",className:"inline"})]}),")."]}),o&&(0,s.jsx)("div",{className:"text-muted-foreground mt-2",children:"See the console area for a traceback."})]})},`exception-${_}`):(0,s.jsx)("li",{className:"my-2",children:f.raising_cell==null?(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-muted-foreground",children:T(f.msg,`exception-${_}`)}),"traceback"in f&&f.traceback?(0,s.jsx)(qe,{traceback:f.traceback}):o&&(0,s.jsx)("div",{className:"text-muted-foreground mt-2",children:"See the console area for a traceback."})]}):(0,s.jsxs)("div",{children:[T(f.msg,`exception-${_}`),(0,s.jsx)($,{cellId:f.raising_cell}),"traceback"in f&&f.traceback&&(0,s.jsx)(qe,{traceback:f.traceback})]})},`exception-${_}`)),D.some(Rs)&&(0,s.jsx)(F,{children:"Fix the error in the mentioned cells, or handle the exceptions with try/except blocks."}),r&&(0,s.jsx)(w,{errors:D,cellId:r})]},"exception")),U.length>0&&I.push((0,s.jsxs)("ul",{children:[U.map(Vs),r&&(0,s.jsx)(w,{errors:U,cellId:r}),(0,s.jsx)(F,{children:U.some(Hs)?"Ensure that the referenced cells define the required variables, or turn off strict execution.":"Something is wrong with your declarations. Fix any discrepancies, or turn off strict execution."})]},"strict-exception")),H.length>0&&I.push((0,s.jsxs)("div",{children:[H.map(Ks),r&&(0,s.jsx)(w,{errors:H,cellId:r})]},"internal")),K.length>0&&I.push((0,s.jsxs)("div",{children:[K.map(Gs),r&&(0,s.jsx)(w,{errors:K,cellId:r})]},"ancestor-prevented")),G.length>0&&I.push((0,s.jsxs)("div",{children:[G.map(Js),r&&(0,s.jsx)(w,{errors:G,cellId:r})]},"ancestor-stopped")),X.length>0&&I.push((0,s.jsxs)("div",{children:[X.map(Xs),r&&(0,s.jsx)(w,{errors:X,cellId:r,className:"mt-2.5"})]},"sql-errors")),I},C;e[19]===p?C=e[20]:(C=p&&(0,s.jsxs)("div",{className:"flex items-center gap-1 font-code text-[0.6875rem] uppercase tracking-wider text-muted-foreground/70",children:[p,(0,s.jsx)(Q,{content:"marimo didn't run this cell because it detected an error.",delayDuration:200,children:(0,s.jsx)(He,{className:"size-3 cursor-help"})})]}),e[19]=p,e[20]=C);let M;e[21]!==d||e[22]!==i?(M=i&&(0,s.jsx)(kt,{className:`font-code font-medium ${d}`,children:i}),e[21]=d,e[22]=i,e[23]=M):M=e[23];let O;e[24]!==C||e[25]!==M?(O=(0,s.jsxs)("div",{className:"space-y-0.5",children:[C,M]}),e[24]=C,e[25]=M,e[26]=O):O=e[26];let De=O;u=$t,g=c,e[27]===a?h=e[28]:(h=ue("border-none font-code text-sm text-[0.84375rem] p-0 text-muted-foreground normal has-[svg]:pl-0 space-y-2",a),e[27]=a,e[28]=h),y=De,m="flex flex-col gap-4",x=We(),e[2]=c,e[3]=r,e[4]=l,e[5]=a,e[6]=n,e[7]=o,e[8]=p,e[9]=d,e[10]=i,e[11]=u,e[12]=m,e[13]=x,e[14]=g,e[15]=h,e[16]=y}else u=e[11],m=e[12],x=e[13],g=e[14],h=e[15],y=e[16];let j;e[29]!==m||e[30]!==x?(j=(0,s.jsx)("div",{className:m,children:x}),e[29]=m,e[30]=x,e[31]=j):j=e[31];let b;return e[32]!==u||e[33]!==g||e[34]!==h||e[35]!==y||e[36]!==j?(b=(0,s.jsxs)(u,{variant:g,className:h,children:[y,j]}),e[32]=u,e[33]=g,e[34]=h,e[35]=y,e[36]=j,e[37]=b):b=e[37],b};function hs(t){return t.type==="interruption"}function fs(t){return t.type==="internal"}function gs(t){return t.type==="ancestor-prevented"}function js(t){return t.type==="ancestor-stopped"}function ys(t){return t.type==="sql-error"}function bs(t){return t.type==="multiple-defs"||t.type==="cycle"||t.type==="setup-refs"||t.type==="import-star"}function vs(t){return t.type==="exception"}function Ns(t){return t.type==="setup-refs"}function Is(t){return t.type==="cycle"}function ws(t){return t.type==="multiple-defs"}function ks(t){return t.type==="import-star"}function $s(t){return t.type==="interruption"}function _s(t){return t.type==="exception"}function As(t){return t.type==="strict-exception"}function Ts(t){return t.type==="internal"}function Fs(t){return t.type==="ancestor-prevented"}function Ss(t){return t.type==="ancestor-stopped"}function Cs(t){return t.type==="syntax"}function Ms(t){return t.type==="unknown"}function Es(t){return t.type==="sql-error"}function Ps(t){return t.msg.includes("!pip")}function zs(t){return t.msg.includes("use os.subprocess")}function qs(t,e){return(0,s.jsx)("pre",{children:T(t.msg,`syntax-${e}`)},`syntax-${e}`)}function Ls(t,e){return(0,s.jsx)("pre",{children:T(t.msg,`unknown-${e}`)},`unknown-${e}`)}function Ws(t,e){return t.edges_with_vars.map((n,r)=>(0,s.jsxs)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:[(0,s.jsx)($,{cellId:n[0]}),(0,s.jsxs)("span",{className:"text-muted-foreground",children:[": "," ",n[1].length===1?n[1][0]:n[1].join(", ")]})]},`setup-refs-${e}-${r}`))}function Ds(t,e){return t.edges_with_vars.map((n,r)=>(0,s.jsxs)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:[(0,s.jsx)($,{cellId:n[0]}),(0,s.jsxs)("span",{className:"text-muted-foreground",children:[" -> ",n[1].length===1?n[1][0]:n[1].join(", ")," -> "]}),(0,s.jsx)($,{cellId:n[2]})]},`cycle-${e}-${r}`))}function Us(t,e){return(0,s.jsx)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:(0,s.jsx)($,{cellId:t})},`cell-${e}`)}function Bs(t,e){return(0,s.jsxs)(W.Fragment,{children:[(0,s.jsx)("p",{className:"text-muted-foreground mt-2",children:`'${t.name}' was also defined by:`}),(0,s.jsx)("ul",{className:"list-disc",children:t.cells.map(Us)})]},`multiple-defs-${e}`)}function Os(t,e){return(0,s.jsx)("p",{className:"text-muted-foreground",children:t.msg},`import-star-${e}`)}function Qs(t,e){return(0,s.jsx)("p",{children:"This cell was interrupted and needs to be re-run."},`interruption-${e}`)}function Rs(t){return t.raising_cell!=null}function Vs(t,e){return(0,s.jsx)("li",{className:"my-2",children:t.blamed_cell==null?(0,s.jsx)("p",{children:t.msg}):(0,s.jsxs)("div",{children:[t.msg,(0,s.jsx)($,{cellId:t.blamed_cell})]})},`strict-exception-${e}`)}function Hs(t){return t.blamed_cell!=null}function Ks(t,e){return(0,s.jsx)("p",{children:t.msg},`internal-${e}`)}function Gs(t,e){return(0,s.jsxs)("div",{children:[t.msg,t.blamed_cell==null?(0,s.jsxs)("span",{children:["(",(0,s.jsx)($,{cellId:t.raising_cell}),")"]}):(0,s.jsxs)("span",{children:["(",(0,s.jsx)($,{cellId:t.raising_cell}),"\xA0blames\xA0",(0,s.jsx)($,{cellId:t.blamed_cell}),")"]})]},`ancestor-prevented-${e}`)}function Js(t,e){return(0,s.jsxs)("div",{children:[t.msg,(0,s.jsx)($,{cellId:t.raising_cell})]},`ancestor-stopped-${e}`)}function Xs(t,e){return(0,s.jsx)("div",{className:"space-y-2 mt-2",children:(0,s.jsx)("p",{className:"text-muted-foreground whitespace-pre-wrap",children:t.msg})},`sql-error-${e}`)}export{ye as S,Ot as _,Fe as a,Ct as b,Wt as c,Rt as d,$e as f,qt as g,Dt as h,Ce as i,R as l,Qt as m,us as n,Te as o,Vt as p,Ee as r,Ae as s,xs as t,Ht as u,Bt as v,Ne as x,Ut as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as v}from"./chunk-C4rtOYze.js";import{i as E,p as T,u as C}from"./useEvent-GCVIknuR.js";import{t as M}from"./react-C60yClUi.js";import{En as S,Fn as H,Gi as F,Ki as f,mt as I,p as L}from"./cells-
|
|
1
|
+
import{o as v}from"./chunk-C4rtOYze.js";import{i as E,p as T,u as C}from"./useEvent-GCVIknuR.js";import{t as M}from"./react-C60yClUi.js";import{En as S,Fn as H,Gi as F,Ki as f,mt as I,p as L}from"./cells-BIt-E5vq.js";import{t as g}from"./compiler-runtime-DnimoHo0.js";import{g as j}from"./useEventListener-DpNnLPuE.js";import{c as w}from"./utils-C8Yt16Y7.js";import{E as _}from"./config-DFK5eCC3.js";import{t as N}from"./jsx-runtime-3wZU7vFS.js";import{t as V}from"./tooltip-C9LWGQ7Y.js";import{t as $}from"./copy-icon-Cn8LzPNx.js";import{t as A}from"./usePress-Bl6X9B5M.js";import{n as O}from"./useDebounce-BlgD22u_.js";import{t as k}from"./useRunCells-SSVpCuNe.js";var W=g(),m=v(M(),1),l=v(N(),1);const q=e=>{let t=(0,W.c)(16),r,n,i;t[0]===e?(r=t[1],n=t[2],i=t[3]):({href:n,children:r,...i}=e,t[0]=e,t[1]=r,t[2]=n,t[3]=i);let a=(0,m.useRef)(null),o;t[4]===n?o=t[5]:(o=()=>{let h=new URL(globalThis.location.href);h.hash=n,globalThis.history.pushState({},"",h.toString()),globalThis.dispatchEvent(new HashChangeEvent("hashchange"));let R=n.slice(1),x=document.getElementById(R);x&&x.scrollIntoView({behavior:"smooth",block:"start"})},t[4]=n,t[5]=o);let s=o,c;t[6]===s?c=t[7]:(c={onPress:()=>{s()}},t[6]=s,t[7]=c);let{pressProps:d}=A(c),u;t[8]===s?u=t[9]:(u=h=>{h.preventDefault(),s()},t[8]=s,t[9]=u);let b=u,p;return t[10]!==r||t[11]!==b||t[12]!==n||t[13]!==d||t[14]!==i?(p=(0,l.jsx)("a",{ref:a,href:n,...d,onClick:b,...i,children:r}),t[10]=r,t[11]=b,t[12]=n,t[13]=d,t[14]=i,t[15]=p):p=t[15],p};async function z(e){let t=L().inOrderIds.at(0);if(t)try{let r=await S.request({document:e,cellId:t});if(!r||r.options.length===0)return;let n=e.split(".").pop()??e,i=r.options[0],a=r.options.find(o=>o.name===n)??i;a!=null&&a.completion_info&&E.set(H,{documentation:a.completion_info})}catch(r){j.debug(`Doc lookup failed for "${e}"`,r)}}var P=g();const D=e=>{let t=(0,P.c)(8),{qualifiedName:r,children:n}=e,i;t[0]===r?i=t[1]:(i=()=>{z(r)},t[0]=r,t[1]=i);let a=O(i,100),o;t[2]===a?o=t[3]:(o=()=>a.cancel(),t[2]=a,t[3]=o);let s;return t[4]!==n||t[5]!==a||t[6]!==o?(s=(0,l.jsx)("span",{onMouseEnter:a,onMouseLeave:o,children:n}),t[4]=n,t[5]=a,t[6]=o,t[7]=s):s=t[7],s};function B(e){if(typeof e!="object"||!e)return!1;let t=e;return!(t.trusted!==!0||t.notebookCode!==void 0&&typeof t.notebookCode!="string")}function G(){let e=window==null?void 0:window.__MARIMO_EXPORT_CONTEXT__;return B(e)?e:void 0}function y(){var e;return((e=G())==null?void 0:e.trusted)===!0}function K(){if(E.get(k)||y()||E.get(w))return!0;try{if(_()==="read")return!0}catch{}return!1}var U=T(e=>{let t=e(k),r=e(w);if(t||r||y())return!1;let n=!0;try{n=_()==="read"}catch{return!0}return!n});function X(){return C(U)}var J=g(),Y=e=>{if(e instanceof f.Element&&!/^[A-Za-z][\w-]*$/.test(e.name))return m.createElement(m.Fragment)},Z=(e,t)=>{if(t instanceof f.Element&&t.name==="body"){if((0,m.isValidElement)(e)&&"props"in e){let r=e.props.children;return(0,l.jsx)(l.Fragment,{children:r})}return}},Q=(e,t)=>{if(t instanceof f.Element&&t.name==="html"){if((0,m.isValidElement)(e)&&"props"in e){let r=e.props.children;return(0,l.jsx)(l.Fragment,{children:r})}return}},tt=e=>{if(e instanceof f.Element&&e.attribs&&e.name==="iframe"){let t=document.createElement("iframe");return Object.entries(e.attribs).forEach(([r,n])=>{r.startsWith('"')&&r.endsWith('"')&&(r=r.slice(1,-1)),t.setAttribute(r,n)}),(0,l.jsx)("div",{dangerouslySetInnerHTML:{__html:t.outerHTML}})}},et=e=>{if(e instanceof f.Element&&e.name==="script"){let t=e.attribs.src;if(!t)return;if(!K())return j.warn(`[RenderHTML] refusing <script src> in untrusted context: ${t}`),(0,l.jsx)(l.Fragment,{});if(![...document.querySelectorAll("script[src]")].some(r=>r.getAttribute("src")===t)){let r=document.createElement("script");r.src=t,document.head.append(r)}return(0,l.jsx)(l.Fragment,{})}},rt=(e,t)=>{if(t instanceof f.Element&&t.name==="a"){let r=t.attribs.href;if(r!=null&&r.startsWith("#")&&!r.startsWith("#code/")){let n=null;return(0,m.isValidElement)(e)&&"props"in e&&(n=e.props.children),(0,l.jsx)(q,{href:r,...t.attribs,children:n})}}},nt=(e,t,r)=>{var n,i;if(t instanceof f.Element&&t.name==="div"&&((i=(n=t.attribs)==null?void 0:n.class)!=null&&i.includes("codehilite")))return(0,l.jsx)(lt,{children:e},r)},it=(e,t,r)=>{var i;if(!(t instanceof f.Element)||t.name!=="img")return;let n=(i=t.attribs)==null?void 0:i.src;if(!(!n||!(0,m.isValidElement)(e))&&!/^data:/i.test(n))return(0,m.cloneElement)(e,{key:`${n}-${r}`})},at=(e,t,r)=>{var n;if(!(!(t instanceof f.Element)||t.name!=="input")&&((n=t.attribs)==null?void 0:n.type)==="checkbox"&&(0,m.isValidElement)(e))return(0,m.cloneElement)(e,{key:`checkbox-${r}-${"checked"in t.attribs}`})},ot=(e,t)=>{var r;if(t instanceof f.Element&&((r=t.attribs)!=null&&r["data-marimo-doc"])){let n=t.attribs["data-marimo-doc"];return(0,l.jsx)(D,{qualifiedName:n,children:e})}},st=(e,t)=>{var r,n;if(t instanceof f.Element&&((r=t.attribs)!=null&&r["data-tooltip"])){if((((n=t.name)==null?void 0:n.toLowerCase())??"").startsWith("marimo-"))return;let i=t.attribs["data-tooltip"];return(0,l.jsx)(V,{content:i,children:e})}},lt=e=>{let t=(0,J.c)(3),{children:r}=e,n=(0,m.useRef)(null),i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,l.jsx)("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,l.jsx)($,{tooltip:!1,className:"p-1",value:()=>{var s;let o=(s=n.current)==null?void 0:s.firstChild;return o&&o.textContent||""}})}),t[0]=i):i=t[0];let a;return t[1]===r?a=t[2]:(a=(0,l.jsxs)("div",{className:"relative group codehilite-wrapper",ref:n,children:[r,i]}),t[1]=r,t[2]=a),a};const ct=({html:e,additionalReplacements:t=[],alwaysSanitizeHtml:r=!0})=>(0,l.jsx)(mt,{html:e,alwaysSanitizeHtml:r,additionalReplacements:t});var mt=({html:e,additionalReplacements:t=[],alwaysSanitizeHtml:r})=>{let n=X();return ft({html:(0,m.useMemo)(()=>r||n?I(e):e,[e,r,n]),additionalReplacements:t})};function ft({html:e,additionalReplacements:t=[]}){let r=[Y,tt,et,...t],n=[nt,rt,ot,st,Z,Q],i=[it,at];return F(e,{replace:(a,o)=>{for(let s of r){let c=s(a,o);if(c)return c}return a},transform:(a,o,s)=>{let c=a;for(let d of n){let u=d(c,o,s);if(u){c=u;break}}for(let d of i){let u=d(c,o,s);u&&(c=u)}return c}})}export{y as n,ct as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as S}from"./chunk-C4rtOYze.js";import{t as D}from"./react-C60yClUi.js";import{t as x}from"./compiler-runtime-DnimoHo0.js";import{_ as M}from"./useEventListener-DpNnLPuE.js";import{h as w,u as q}from"./config-DFK5eCC3.js";import{n as E,t as T}from"./cn-DCUzRj2J.js";import{t as F}from"./jsx-runtime-3wZU7vFS.js";import{t as O}from"./tooltip-C9LWGQ7Y.js";import{r as W}from"./button-W__YVea9.js";import{r as L}from"./requests-B9zEd_sW.js";import{t as V}from"./createLucideIcon-B8oVfJNp.js";import{i as N}from"./useDeleteCell-
|
|
1
|
+
import{o as S}from"./chunk-C4rtOYze.js";import{t as D}from"./react-C60yClUi.js";import{t as x}from"./compiler-runtime-DnimoHo0.js";import{_ as M}from"./useEventListener-DpNnLPuE.js";import{h as w,u as q}from"./config-DFK5eCC3.js";import{n as E,t as T}from"./cn-DCUzRj2J.js";import{t as F}from"./jsx-runtime-3wZU7vFS.js";import{t as O}from"./tooltip-C9LWGQ7Y.js";import{r as W}from"./button-W__YVea9.js";import{r as L}from"./requests-B9zEd_sW.js";import{t as V}from"./createLucideIcon-B8oVfJNp.js";import{i as N}from"./useDeleteCell-C6_GiKMv.js";import{C as B,O as I,ut as P,w as K}from"./input-BN98e517.js";import{t as U}from"./square-DVd8Y612.js";import{N as H,P as C,V as G,j as _,k as J}from"./usePress-Bl6X9B5M.js";import{l as Q}from"./RSPContexts-oeZyXDWd.js";import{t as X}from"./context-BJMN4ll3.js";import{a as z}from"./renderShortcut-C6HKXhBl.js";var Y=V("hard-drive-download",[["path",{d:"M12 2v8",key:"1q4o3n"}],["path",{d:"m16 6-4 4-4-4",key:"6wukr"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 18h.01",key:"h775k"}]]),y=S(D(),1);function Z(n,e){let{"aria-label":t,"aria-labelledby":a,orientation:r="horizontal"}=n,[o,c]=(0,y.useState)(!1);G(()=>{var i;c(!!(e.current&&((i=e.current.parentElement)!=null&&i.closest('[role="toolbar"]'))))});let{direction:u}=X(),m=u==="rtl"&&r==="horizontal",f=Q(e),l=i=>{if(_(i.currentTarget,C(i))){if(r==="horizontal"&&i.key==="ArrowRight"||r==="vertical"&&i.key==="ArrowDown")m?f.focusPrevious():f.focusNext();else if(r==="horizontal"&&i.key==="ArrowLeft"||r==="vertical"&&i.key==="ArrowUp")m?f.focusNext():f.focusPrevious();else if(i.key==="Tab"){i.stopPropagation(),s.current=H(),i.shiftKey?f.focusFirst():f.focusLast();return}else return;i.stopPropagation(),i.preventDefault()}},s=(0,y.useRef)(null),b=i=>{!_(i.currentTarget,i.relatedTarget)&&!s.current&&(s.current=C(i))},p=i=>{if(s.current&&!_(i.currentTarget,i.relatedTarget)&&_(e.current,C(i))){var h;(h=s.current)==null||h.focus(),s.current=null}};return{toolbarProps:{...P(n,{labelable:!0}),role:o?"group":"toolbar","aria-orientation":r,"aria-label":t,"aria-labelledby":t==null?a:void 0,onKeyDownCapture:o?void 0:l,onFocusCapture:o?void 0:p,onBlurCapture:o?void 0:b}}}var $=(0,y.createContext)({}),ee=(0,y.forwardRef)(function(n,e){[n,e]=B(n,e,$);let{toolbarProps:t}=Z(n,e),a=K({...n,values:{orientation:n.orientation||"horizontal"},defaultClassName:"react-aria-Toolbar"}),r=P(n,{global:!0});return delete r.id,y.createElement(I.div,{...J(r,a,t),ref:e,slot:n.slot||void 0,"data-orientation":n.orientation||"horizontal"},a.children)}),te=x(),re=200;function R(n){let e=(0,te.c)(3),[t,a]=(0,y.useState)(!1),r,o;return e[0]===n?(r=e[1],o=e[2]):(r=()=>{if(!n)return;a(!1);let c=setTimeout(()=>{a(!0)},re);return()=>clearTimeout(c)},o=[n],e[0]=n,e[1]=r,e[2]=o),(0,y.useEffect)(r,o),n&&t}var A=x(),g=S(F(),1),oe=E("rounded-full shadow-xs-solid border p-[5px] transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 [&>svg]:size-3 active:shadow-none bg-background",{variants:{variant:{default:"hover:bg-accent hover:text-accent-foreground",stale:"bg-(--yellow-3) hover:bg-(--yellow-4) text-(--yellow-11)",green:"hover:bg-(--grass-2) hover:text-(--grass-11) hover:border-[var(--grass-7)],",disabled:"opacity-50 cursor-not-allowed",danger:"hover:bg-(--red-3) hover:text-(--red-11)"}},defaultVariants:{variant:"default"}});const k=n=>{let e=(0,A.c)(18),t,a,r,o,c,u,m;if(e[0]!==n){let{children:s,tooltip:b,disabled:p,variant:i,...h}=n;t=s,m=b;let d=p===void 0?!1:p;a=d,r=h,o=v=>{var j;d||((j=h.onClick)==null||j.call(h,v))},c=W.preventFocus,u=T(oe({variant:i}),h.className),e[0]=n,e[1]=t,e[2]=a,e[3]=r,e[4]=o,e[5]=c,e[6]=u,e[7]=m}else t=e[1],a=e[2],r=e[3],o=e[4],c=e[5],u=e[6],m=e[7];let f;e[8]!==t||e[9]!==a||e[10]!==r||e[11]!==o||e[12]!==c||e[13]!==u?(f=(0,g.jsx)("button",{disabled:a,...r,onClick:o,onMouseDown:c,className:u,children:t}),e[8]=t,e[9]=a,e[10]=r,e[11]=o,e[12]=c,e[13]=u,e[14]=f):f=e[14];let l=f;if(m){let s;return e[15]!==l||e[16]!==m?(s=(0,g.jsx)(O,{content:m,side:"top",delayDuration:200,usePortal:!1,children:l}),e[15]=l,e[16]=m,e[17]=s):s=e[17],s}return l},ae=n=>{let e=(0,A.c)(5),{children:t,className:a}=n,r;e[0]===a?r=e[1]:(r=T("flex items-center gap-1 bg-background m-[2px] rounded-full",a),e[0]=a,e[1]=r);let o;return e[2]!==t||e[3]!==r?(o=(0,g.jsx)(ee,{className:r,children:t}),e[2]=t,e[3]=r,e[4]=o):o=e[4],o};var ne=x();const ie=n=>{let e=(0,ne.c)(9),{connectionState:t,status:a}=n,{sendInterrupt:r}=L(),o=R(a==="running"),c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=z("global.interrupt"),e[0]=c):c=e[0];let u;e[1]!==t||e[2]!==o?(u=w(t)||!o,e[1]=t,e[2]=o,e[3]=u):u=e[3];let m=o?r:M.NOOP,f=o?"stale":"disabled",l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=(0,g.jsx)(U,{strokeWidth:1.5}),e[4]=l):l=e[4];let s;return e[5]!==u||e[6]!==m||e[7]!==f?(s=(0,g.jsx)(k,{tooltip:c,disabled:u,onClick:m,variant:f,"data-testid":"run-button",children:l}),e[5]=u,e[6]=m,e[7]=f,e[8]=s):s=e[8],s};var le=x();function se({connectionState:n,needsRun:e,loading:t,inactive:a}){return w(n)?"disabled":e&&!t?"stale":t||a?"disabled":"green"}const de=n=>{let e=(0,le.c)(27),{onClick:t,connectionState:a,needsRun:r,status:o,config:c,edited:u}=n,m=o==="disabled-transitively",f=o==="running"||o==="queued",l,s;e[0]!==m||e[1]!==c.disabled||e[2]!==a||e[3]!==u||e[4]!==f||e[5]!==r?(l=w(a)||f||!c.disabled&&m&&!u,s=se({connectionState:a,needsRun:r,loading:f,inactive:l}),e[0]=m,e[1]=c.disabled,e[2]=a,e[3]=u,e[4]=f,e[5]=r,e[6]=l,e[7]=s):(l=e[6],s=e[7]);let b=s;if(c.disabled){let d;e[8]===Symbol.for("react.memo_cache_sentinel")?(d=(0,g.jsx)(Y,{}),e[8]=d):d=e[8];let v;return e[9]!==l||e[10]!==t||e[11]!==b?(v=(0,g.jsx)(k,{tooltip:"Add code to notebook",disabled:l,onClick:t,variant:b,"data-testid":"run-button",children:d}),e[9]=l,e[10]=t,e[11]=b,e[12]=v):v=e[12],v}if(!c.disabled&&m&&!u){let d;e[13]===Symbol.for("react.memo_cache_sentinel")?(d=(0,g.jsx)(N,{strokeWidth:1.2}),e[13]=d):d=e[13];let v;return e[14]!==l||e[15]!==t||e[16]!==b?(v=(0,g.jsx)(k,{disabled:l,tooltip:"This cell can't be run because it has a disabled ancestor",onClick:t,variant:b,"data-testid":"run-button",children:d}),e[14]=l,e[15]=t,e[16]=b,e[17]=v):v=e[17],v}let p;if(w(a)){let d;e[18]===a?d=e[19]:(d=q(a),e[18]=a,e[19]=d),p=d}else if(o==="queued")p="This cell is already queued to run";else if(o==="running")p="This cell is already running.";else{let d;e[20]===Symbol.for("react.memo_cache_sentinel")?(d=z("cell.run"),e[20]=d):d=e[20],p=d}let i;e[21]===Symbol.for("react.memo_cache_sentinel")?(i=(0,g.jsx)(N,{strokeWidth:1.2}),e[21]=i):i=e[21];let h;return e[22]!==l||e[23]!==t||e[24]!==p||e[25]!==b?(h=(0,g.jsx)(k,{tooltip:p,disabled:l,onClick:t,variant:b,"data-testid":"run-button",children:i}),e[22]=l,e[23]=t,e[24]=p,e[25]=b,e[26]=h):h=e[26],h};export{R as a,k as i,ie as n,ae as r,de as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Si=Object.defineProperty;var Ai=(t,e,a)=>e in t?Si(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a;var F=(t,e,a)=>Ai(t,typeof e!="symbol"?e+"":e,a);import{o as Oa,t as Oi}from"./chunk-C4rtOYze.js";import{f as Kr,i as Jr,l as Mi,n as Mt,o as Ri,u as Yr}from"./useEvent-GCVIknuR.js";import{t as Ni}from"./react-C60yClUi.js";import{$r as Hr,E as Gr,Fi as ji,Kn as Pi,Lr as $i,Qr as Di,Qt as Li,Wt as Qr,Yn as Zi,Yr as Fi,Zi as zi,aa as Ui,d as qi,da as Xr,fa as Vi,gt as Ma,ki as Wi,kt as Bi,ra as Ki,rt as es,y as Je,yr as Ji,zr as Yi}from"./cells-
|
|
1
|
+
var Si=Object.defineProperty;var Ai=(t,e,a)=>e in t?Si(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a;var F=(t,e,a)=>Ai(t,typeof e!="symbol"?e+"":e,a);import{o as Oa,t as Oi}from"./chunk-C4rtOYze.js";import{f as Kr,i as Jr,l as Mi,n as Mt,o as Ri,u as Yr}from"./useEvent-GCVIknuR.js";import{t as Ni}from"./react-C60yClUi.js";import{$r as Hr,E as Gr,Fi as ji,Kn as Pi,Lr as $i,Qr as Di,Qt as Li,Wt as Qr,Yn as Zi,Yr as Fi,Zi as zi,aa as Ui,d as qi,da as Xr,fa as Vi,gt as Ma,ki as Wi,kt as Bi,ra as Ki,rt as es,y as Je,yr as Ji,zr as Yi}from"./cells-BIt-E5vq.js";import{A as G,B as J,D as Ra,E as ts,I as xe,L as m,M as W,N as as,O as Hi,P as E,S as Gi,T as $,U as rs,V as Qi,b as nt,k as b,q as ss,w as Ee,x as it,z as ce}from"./zod-BIDX-mZr.js";import{t as Rt}from"./compiler-runtime-DnimoHo0.js";import{D as Xi,t as eo}from"./ai-model-dropdown-Divs-dGW.js";import{f as to,g as ie}from"./useEventListener-DpNnLPuE.js";import{n as ao}from"./utils-C8Yt16Y7.js";import{o as ro}from"./config-DFK5eCC3.js";import{t as Na}from"./cn-DCUzRj2J.js";import{t as so}from"./jsx-runtime-3wZU7vFS.js";import{d as no}from"./popover-B96fOqfH.js";import{a as ns,c as io,p as oo,r as lo,t as uo}from"./dropdown-menu-DWGvf_Bw.js";import{t as Gt}from"./tooltip-C9LWGQ7Y.js";import{t as Ye}from"./button-W__YVea9.js";import{Gt as co,Qt,Tt as Xt,Wt as po,Zt as ea,at as ja,dt as is,en as mo,qt as os,st as ls,ut as ds,wt as ho}from"./dist-CeF1Em5L.js";import{t as fo}from"./createReducer-C1MhlItJ.js";import{h as go,n as yo,o as vo,r as xo}from"./dist-Di6rD-vJ.js";import{i as bo}from"./strings-DmKKoXrM.js";import{r as _o,t as wo}from"./requests-B9zEd_sW.js";import{t as Pa}from"./createLucideIcon-B8oVfJNp.js";import{r as ko,t as Co}from"./fileToBase64-CBP8Y0AP.js";import{t as us}from"./x-4y-nyVDU.js";import{f as Io,n as cs}from"./markdown-renderer-CP1Up_3K.js";import{t as ps}from"./file-BjlLTeSV.js";import{t as To}from"./image-Dvcyi0uu.js";import{t as Eo}from"./spinner-Cj3eM5bt.js";import{i as So,t as Ao}from"./useDeleteCell-C6_GiKMv.js";import{r as Oo}from"./input-BN98e517.js";import{t as Mo}from"./sparkles-DwqcWrJl.js";import{a as ot,c as Ro,i as bt,n as No,o as Nt,s as jt,t as jo}from"./datasource-0Urr2OFR.js";import{a as Po}from"./dist-BPoMypmC.js";import{t as $o}from"./uuid-e9lSomwA.js";import{t as $a}from"./use-toast-DjpWVza6.js";import{a as Do}from"./session-D-SddyN0.js";import{r as Lo}from"./useTheme-CwCyrmDf.js";import{n as Zo}from"./useRunCells-SSVpCuNe.js";import{n as Fo}from"./blob-DCmp9MuM.js";import{a as zo}from"./errors-D93OkQw8.js";import{i as Da}from"./cell-link-CvOBew-Z.js";import{r as Uo,t as qo}from"./html-to-image-BvGsu9Nz.js";import{n as La}from"./renderShortcut-C6HKXhBl.js";import{n as Vo}from"./icons-BwSNDWAP.js";import{r as Wo,t as Bo}from"./esm-RBKN8Dn2.js";import{t as Ko}from"./process-output-CwYvnqai.js";import{i as Jo,r as Yo,t as Ho}from"./error-entries-BTA-sOIB.js";var ms=Pa("circle-stop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]),hs=Pa("paperclip",[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]]),fs=Pa("send-horizontal",[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]]),gs="vercel.ai.error",Go=Symbol.for(gs),ys,vs,ke=class yi extends(vs=Error,ys=Go,vs){constructor({name:e,message:a,cause:r}){super(a),this[ys]=!0,this.name=e,this.cause=r}static isInstance(e){return yi.hasMarker(e,gs)}static hasMarker(e,a){let r=Symbol.for(a);return typeof e=="object"&&!!e&&r in e&&typeof e[r]=="boolean"&&e[r]===!0}};function xs(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.toString():JSON.stringify(t)}var bs="AI_InvalidArgumentError",_s=`vercel.ai.error.${bs}`,Qo=Symbol.for(_s),ws,ks,Xo=class extends(ks=ke,ws=Qo,ks){constructor({message:t,cause:e,argument:a}){super({name:bs,message:t,cause:e}),this[ws]=!0,this.argument=a}static isInstance(t){return ke.hasMarker(t,_s)}},Cs="AI_JSONParseError",Is=`vercel.ai.error.${Cs}`,el=Symbol.for(Is),Ts,Es,Ss=class extends(Es=ke,Ts=el,Es){constructor({text:t,cause:e}){super({name:Cs,message:`JSON parsing failed: Text: ${t}.
|
|
2
2
|
Error message: ${xs(e)}`,cause:e}),this[Ts]=!0,this.text=t}static isInstance(t){return ke.hasMarker(t,Is)}},As="AI_TypeValidationError",Os=`vercel.ai.error.${As}`,tl=Symbol.for(Os),Ms,Rs,He=class Pr extends(Rs=ke,Ms=tl,Rs){constructor({value:e,cause:a,context:r}){let s="Type validation failed";if(r!=null&&r.field&&(s+=` for ${r.field}`),(r==null?void 0:r.entityName)||(r==null?void 0:r.entityId)){s+=" (";let n=[];r.entityName&&n.push(r.entityName),r.entityId&&n.push(`id: "${r.entityId}"`),s+=n.join(", "),s+=")"}super({name:As,message:`${s}: Value: ${JSON.stringify(e)}.
|
|
3
3
|
Error message: ${xs(a)}`,cause:a}),this[Ms]=!0,this.value=e,this.context=r}static isInstance(e){return ke.hasMarker(e,Os)}static wrap({value:e,cause:a,context:r}){var s,n,o;return Pr.isInstance(a)&&a.value===e&&((s=a.context)==null?void 0:s.field)===(r==null?void 0:r.field)&&((n=a.context)==null?void 0:n.entityName)===(r==null?void 0:r.entityName)&&((o=a.context)==null?void 0:o.entityId)===(r==null?void 0:r.entityId)?a:new Pr({value:e,cause:a,context:r})}},B;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function a(s){throw Error()}t.assertNever=a,t.arrayToEnum=s=>{let n={};for(let o of s)n[o]=o;return n},t.getValidEnumValues=s=>{let n=t.objectKeys(s).filter(i=>typeof s[s[i]]!="number"),o={};for(let i of n)o[i]=s[i];return t.objectValues(o)},t.objectValues=s=>t.objectKeys(s).map(function(n){return s[n]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let n=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&n.push(o);return n},t.find=(s,n)=>{for(let o of s)if(n(o))return o},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,n=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(n)}t.joinValues=r,t.jsonStringifyReplacer=(s,n)=>typeof n=="bigint"?n.toString():n})(B||(B={}));var al;(function(t){t.mergeShapes=(e,a)=>({...e,...a})})(al||(al={}));const M=B.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ge=t=>{switch(typeof t){case"undefined":return M.undefined;case"string":return M.string;case"number":return Number.isNaN(t)?M.nan:M.number;case"boolean":return M.boolean;case"function":return M.function;case"bigint":return M.bigint;case"symbol":return M.symbol;case"object":return Array.isArray(t)?M.array:t===null?M.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?M.promise:typeof Map<"u"&&t instanceof Map?M.map:typeof Set<"u"&&t instanceof Set?M.set:typeof Date<"u"&&t instanceof Date?M.date:M.object;default:return M.unknown}},w=B.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);var Pe=class vi extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let a=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,a):this.__proto__=a,this.name="ZodError",this.issues=e}format(e){let a=e||function(n){return n.message},r={_errors:[]},s=n=>{for(let o of n.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(a(o));else{let i=r,d=0;for(;d<o.path.length;){let l=o.path[d];d===o.path.length-1?(i[l]=i[l]||{_errors:[]},i[l]._errors.push(a(o))):i[l]=i[l]||{_errors:[]},i=i[l],d++}}};return s(this),r}static assert(e){if(!(e instanceof vi))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,B.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=a=>a.message){let a=Object.create(null),r=[];for(let s of this.issues)if(s.path.length>0){let n=s.path[0];a[n]=a[n]||[],a[n].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:a}}get formErrors(){return this.flatten()}};Pe.create=t=>new Pe(t);var Pt=(t,e)=>{let a;switch(t.code){case w.invalid_type:a=t.received===M.undefined?"Required":`Expected ${t.expected}, received ${t.received}`;break;case w.invalid_literal:a=`Invalid literal value, expected ${JSON.stringify(t.expected,B.jsonStringifyReplacer)}`;break;case w.unrecognized_keys:a=`Unrecognized key(s) in object: ${B.joinValues(t.keys,", ")}`;break;case w.invalid_union:a="Invalid input";break;case w.invalid_union_discriminator:a=`Invalid discriminator value. Expected ${B.joinValues(t.options)}`;break;case w.invalid_enum_value:a=`Invalid enum value. Expected ${B.joinValues(t.options)}, received '${t.received}'`;break;case w.invalid_arguments:a="Invalid function arguments";break;case w.invalid_return_type:a="Invalid function return type";break;case w.invalid_date:a="Invalid date";break;case w.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(a=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(a=`${a} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?a=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?a=`Invalid input: must end with "${t.validation.endsWith}"`:B.assertNever(t.validation):a=t.validation==="regex"?"Invalid":`Invalid ${t.validation}`;break;case w.too_small:a=t.type==="array"?`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"||t.type==="bigint"?`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:"Invalid input";break;case w.too_big:a=t.type==="array"?`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:"Invalid input";break;case w.custom:a="Invalid input";break;case w.invalid_intersection_types:a="Intersection results could not be merged";break;case w.not_multiple_of:a=`Number must be a multiple of ${t.multipleOf}`;break;case w.not_finite:a="Number must be finite";break;default:a=e.defaultError,B.assertNever(t)}return{message:a}},rl=Pt;function Za(){return rl}const Fa=t=>{let{data:e,path:a,errorMaps:r,issueData:s}=t,n=[...a,...s.path||[]],o={...s,path:n};if(s.message!==void 0)return{...s,path:n,message:s.message};let i="",d=r.filter(l=>!!l).slice().reverse();for(let l of d)i=l(o,{data:e,defaultError:i}).message;return{...s,path:n,message:i}};function S(t,e){let a=Za(),r=Fa({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,a,a===Pt?void 0:Pt].filter(s=>!!s)});t.common.issues.push(r)}var be=class xi{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,a){let r=[];for(let s of a){if(s.status==="aborted")return D;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,a){let r=[];for(let s of a){let n=await s.key,o=await s.value;r.push({key:n,value:o})}return xi.mergeObjectSync(e,r)}static mergeObjectSync(e,a){let r={};for(let s of a){let{key:n,value:o}=s;if(n.status==="aborted"||o.status==="aborted")return D;n.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),n.value!=="__proto__"&&(o.value!==void 0||s.alwaysSet)&&(r[n.value]=o.value)}return{status:e.value,value:r}}};const D=Object.freeze({status:"aborted"}),za=t=>({status:"dirty",value:t}),fe=t=>({status:"valid",value:t}),Ns=t=>t.status==="aborted",js=t=>t.status==="dirty",_t=t=>t.status==="valid",ta=t=>typeof Promise<"u"&&t instanceof Promise;var N;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(N||(N={}));var $e=class{constructor(t,e,a,r){this._cachedPath=[],this.parent=t,this.data=e,this._path=a,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Ps=(t,e)=>{if(_t(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){return this._error||(this._error=new Pe(t.common.issues)),this._error}}};function z(t){if(!t)return{};let{errorMap:e,invalid_type_error:a,required_error:r,description:s}=t;if(e&&(a||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(n,o)=>{let{message:i}=t;return n.code==="invalid_enum_value"?{message:i??o.defaultError}:o.data===void 0?{message:i??r??o.defaultError}:n.code==="invalid_type"?{message:i??a??o.defaultError}:{message:o.defaultError}},description:s}}var U=class{get description(){return this._def.description}_getType(t){return Ge(t.data)}_getOrReturnCtx(t,e){return e||{common:t.parent.common,data:t.data,parsedType:Ge(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new be,ctx:{common:t.parent.common,data:t.data,parsedType:Ge(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let e=this._parse(t);if(ta(e))throw Error("Synchronous parse encountered promise.");return e}_parseAsync(t){let e=this._parse(t);return Promise.resolve(e)}parse(t,e){let a=this.safeParse(t,e);if(a.success)return a.data;throw a.error}safeParse(t,e){let a={common:{issues:[],async:(e==null?void 0:e.async)??!1,contextualErrorMap:e==null?void 0:e.errorMap},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ge(t)};return Ps(a,this._parseSync({data:t,path:a.path,parent:a}))}"~validate"(t){var a,r;let e={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ge(t)};if(!this["~standard"].async)try{let s=this._parseSync({data:t,path:[],parent:e});return _t(s)?{value:s.value}:{issues:e.common.issues}}catch(s){(r=(a=s==null?void 0:s.message)==null?void 0:a.toLowerCase())!=null&&r.includes("encountered")&&(this["~standard"].async=!0),e.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:e}).then(s=>_t(s)?{value:s.value}:{issues:e.common.issues})}async parseAsync(t,e){let a=await this.safeParseAsync(t,e);if(a.success)return a.data;throw a.error}async safeParseAsync(t,e){let a={common:{issues:[],contextualErrorMap:e==null?void 0:e.errorMap,async:!0},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ge(t)},r=this._parse({data:t,path:a.path,parent:a});return Ps(a,await(ta(r)?r:Promise.resolve(r)))}refine(t,e){let a=r=>typeof e=="string"||e===void 0?{message:e}:typeof e=="function"?e(r):e;return this._refinement((r,s)=>{let n=t(r),o=()=>s.addIssue({code:w.custom,...a(r)});return typeof Promise<"u"&&n instanceof Promise?n.then(i=>i?!0:(o(),!1)):n?!0:(o(),!1)})}refinement(t,e){return this._refinement((a,r)=>t(a)?!0:(r.addIssue(typeof e=="function"?e(a,r):e),!1))}_refinement(t){return new qe({schema:this,typeName:k.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return Ve.create(this,this._def)}nullable(){return dt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return kt.create(this)}promise(){return $t.create(this,this._def)}or(t){return na.create([this,t],this._def)}and(t){return ia.create(this,t,this._def)}transform(t){return new qe({...z(this._def),schema:this,typeName:k.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let e=typeof t=="function"?t:()=>t;return new ca({...z(this._def),innerType:this,defaultValue:e,typeName:k.ZodDefault})}brand(){return new Fs({typeName:k.ZodBranded,type:this,...z(this._def)})}catch(t){let e=typeof t=="function"?t:()=>t;return new pa({...z(this._def),innerType:this,catchValue:e,typeName:k.ZodCatch})}describe(t){let e=this.constructor;return new e({...this._def,description:t})}pipe(t){return zs.create(this,t)}readonly(){return ma.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},sl=/^c[^\s-]{8,}$/i,nl=/^[0-9a-z]+$/,il=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ol=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,ll=/^[a-z0-9_-]{21}$/i,dl=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ul=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,cl=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,pl="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",$s,ml=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,hl=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,fl=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,gl=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,yl=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,vl=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ds="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",xl=RegExp(`^${Ds}$`);function Ls(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision??(e=`${e}(\\.\\d+)?`);let a=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${a}`}function bl(t){return RegExp(`^${Ls(t)}$`)}function _l(t){let e=`${Ds}T${Ls(t)}`,a=[];return a.push(t.local?"Z?":"Z"),t.offset&&a.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${a.join("|")})`,RegExp(`^${e}$`)}function wl(t,e){return!!((e==="v4"||!e)&&ml.test(t)||(e==="v6"||!e)&&fl.test(t))}function kl(t,e){if(!dl.test(t))return!1;try{let[a]=t.split(".");if(!a)return!1;let r=a.replace(/-/g,"+").replace(/_/g,"/").padEnd(a.length+(4-a.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||!s||"typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function Cl(t,e){return!!((e==="v4"||!e)&&hl.test(t)||(e==="v6"||!e)&&gl.test(t))}var aa=class Yt extends U{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==M.string){let s=this._getOrReturnCtx(e);return S(s,{code:w.invalid_type,expected:M.string,received:s.parsedType}),D}let a=new be,r;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(r=this._getOrReturnCtx(e,r),S(r,{code:w.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),a.dirty());else if(s.kind==="max")e.data.length>s.value&&(r=this._getOrReturnCtx(e,r),S(r,{code:w.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),a.dirty());else if(s.kind==="length"){let n=e.data.length>s.value,o=e.data.length<s.value;(n||o)&&(r=this._getOrReturnCtx(e,r),n?S(r,{code:w.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&S(r,{code:w.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),a.dirty())}else if(s.kind==="email")cl.test(e.data)||(r=this._getOrReturnCtx(e,r),S(r,{validation:"email",code:w.invalid_string,message:s.message}),a.dirty());else if(s.kind==="emoji")$s||($s=new RegExp(pl,"u")),$s.test(e.data)||(r=this._getOrReturnCtx(e,r),S(r,{validation:"emoji",code:w.invalid_string,message:s.message}),a.dirty());else if(s.kind==="uuid")ol.test(e.data)||(r=this._getOrReturnCtx(e,r),S(r,{validation:"uuid",code:w.invalid_string,message:s.message}),a.dirty());else if(s.kind==="nanoid")ll.test(e.data)||(r=this._getOrReturnCtx(e,r),S(r,{validation:"nanoid",code:w.invalid_string,message:s.message}),a.dirty());else if(s.kind==="cuid")sl.test(e.data)||(r=this._getOrReturnCtx(e,r),S(r,{validation:"cuid",code:w.invalid_string,message:s.message}),a.dirty());else if(s.kind==="cuid2")nl.test(e.data)||(r=this._getOrReturnCtx(e,r),S(r,{validation:"cuid2",code:w.invalid_string,message:s.message}),a.dirty());else if(s.kind==="ulid")il.test(e.data)||(r=this._getOrReturnCtx(e,r),S(r,{validation:"ulid",code:w.invalid_string,message:s.message}),a.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),S(r,{validation:"url",code:w.invalid_string,message:s.message}),a.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),S(r,{validation:"regex",code:w.invalid_string,message:s.message}),a.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(r=this._getOrReturnCtx(e,r),S(r,{code:w.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),a.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(r=this._getOrReturnCtx(e,r),S(r,{code:w.invalid_string,validation:{startsWith:s.value},message:s.message}),a.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(r=this._getOrReturnCtx(e,r),S(r,{code:w.invalid_string,validation:{endsWith:s.value},message:s.message}),a.dirty()):s.kind==="datetime"?_l(s).test(e.data)||(r=this._getOrReturnCtx(e,r),S(r,{code:w.invalid_string,validation:"datetime",message:s.message}),a.dirty()):s.kind==="date"?xl.test(e.data)||(r=this._getOrReturnCtx(e,r),S(r,{code:w.invalid_string,validation:"date",message:s.message}),a.dirty()):s.kind==="time"?bl(s).test(e.data)||(r=this._getOrReturnCtx(e,r),S(r,{code:w.invalid_string,validation:"time",message:s.message}),a.dirty()):s.kind==="duration"?ul.test(e.data)||(r=this._getOrReturnCtx(e,r),S(r,{validation:"duration",code:w.invalid_string,message:s.message}),a.dirty()):s.kind==="ip"?wl(e.data,s.version)||(r=this._getOrReturnCtx(e,r),S(r,{validation:"ip",code:w.invalid_string,message:s.message}),a.dirty()):s.kind==="jwt"?kl(e.data,s.alg)||(r=this._getOrReturnCtx(e,r),S(r,{validation:"jwt",code:w.invalid_string,message:s.message}),a.dirty()):s.kind==="cidr"?Cl(e.data,s.version)||(r=this._getOrReturnCtx(e,r),S(r,{validation:"cidr",code:w.invalid_string,message:s.message}),a.dirty()):s.kind==="base64"?yl.test(e.data)||(r=this._getOrReturnCtx(e,r),S(r,{validation:"base64",code:w.invalid_string,message:s.message}),a.dirty()):s.kind==="base64url"?vl.test(e.data)||(r=this._getOrReturnCtx(e,r),S(r,{validation:"base64url",code:w.invalid_string,message:s.message}),a.dirty()):B.assertNever(s);return{status:a.value,value:e.data}}_regex(e,a,r){return this.refinement(s=>e.test(s),{validation:a,code:w.invalid_string,...N.errToObj(r)})}_addCheck(e){return new Yt({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...N.errToObj(e)})}url(e){return this._addCheck({kind:"url",...N.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...N.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...N.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...N.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...N.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...N.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...N.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...N.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...N.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...N.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...N.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...N.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:(e==null?void 0:e.precision)===void 0?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...N.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:(e==null?void 0:e.precision)===void 0?null:e==null?void 0:e.precision,...N.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...N.errToObj(e)})}regex(e,a){return this._addCheck({kind:"regex",regex:e,...N.errToObj(a)})}includes(e,a){return this._addCheck({kind:"includes",value:e,position:a==null?void 0:a.position,...N.errToObj(a==null?void 0:a.message)})}startsWith(e,a){return this._addCheck({kind:"startsWith",value:e,...N.errToObj(a)})}endsWith(e,a){return this._addCheck({kind:"endsWith",value:e,...N.errToObj(a)})}min(e,a){return this._addCheck({kind:"min",value:e,...N.errToObj(a)})}max(e,a){return this._addCheck({kind:"max",value:e,...N.errToObj(a)})}length(e,a){return this._addCheck({kind:"length",value:e,...N.errToObj(a)})}nonempty(e){return this.min(1,N.errToObj(e))}trim(){return new Yt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Yt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Yt({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let a of this._def.checks)a.kind==="min"&&(e===null||a.value>e)&&(e=a.value);return e}get maxLength(){let e=null;for(let a of this._def.checks)a.kind==="max"&&(e===null||a.value<e)&&(e=a.value);return e}};aa.create=t=>new aa({checks:[],typeName:k.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...z(t)});function Il(t,e){let a=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=a>r?a:r;return Number.parseInt(t.toFixed(s).replace(".",""))%Number.parseInt(e.toFixed(s).replace(".",""))/10**s}var Ua=class $r extends U{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==M.number){let s=this._getOrReturnCtx(e);return S(s,{code:w.invalid_type,expected:M.number,received:s.parsedType}),D}let a,r=new be;for(let s of this._def.checks)s.kind==="int"?B.isInteger(e.data)||(a=this._getOrReturnCtx(e,a),S(a,{code:w.invalid_type,expected:"integer",received:"float",message:s.message}),r.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(a=this._getOrReturnCtx(e,a),S(a,{code:w.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),r.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(a=this._getOrReturnCtx(e,a),S(a,{code:w.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),r.dirty()):s.kind==="multipleOf"?Il(e.data,s.value)!==0&&(a=this._getOrReturnCtx(e,a),S(a,{code:w.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(a=this._getOrReturnCtx(e,a),S(a,{code:w.not_finite,message:s.message}),r.dirty()):B.assertNever(s);return{status:r.value,value:e.data}}gte(e,a){return this.setLimit("min",e,!0,N.toString(a))}gt(e,a){return this.setLimit("min",e,!1,N.toString(a))}lte(e,a){return this.setLimit("max",e,!0,N.toString(a))}lt(e,a){return this.setLimit("max",e,!1,N.toString(a))}setLimit(e,a,r,s){return new $r({...this._def,checks:[...this._def.checks,{kind:e,value:a,inclusive:r,message:N.toString(s)}]})}_addCheck(e){return new $r({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:N.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:N.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:N.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:N.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:N.toString(e)})}multipleOf(e,a){return this._addCheck({kind:"multipleOf",value:e,message:N.toString(a)})}finite(e){return this._addCheck({kind:"finite",message:N.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:-(2**53-1),message:N.toString(e)})._addCheck({kind:"max",inclusive:!0,value:2**53-1,message:N.toString(e)})}get minValue(){let e=null;for(let a of this._def.checks)a.kind==="min"&&(e===null||a.value>e)&&(e=a.value);return e}get maxValue(){let e=null;for(let a of this._def.checks)a.kind==="max"&&(e===null||a.value<e)&&(e=a.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&B.isInteger(e.value))}get isFinite(){let e=null,a=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(a===null||r.value>a)&&(a=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(a)&&Number.isFinite(e)}};Ua.create=t=>new Ua({checks:[],typeName:k.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...z(t)});var qa=class Dr extends U{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==M.bigint)return this._getInvalidInput(e);let a,r=new be;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(a=this._getOrReturnCtx(e,a),S(a,{code:w.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(a=this._getOrReturnCtx(e,a),S(a,{code:w.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(a=this._getOrReturnCtx(e,a),S(a,{code:w.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):B.assertNever(s);return{status:r.value,value:e.data}}_getInvalidInput(e){let a=this._getOrReturnCtx(e);return S(a,{code:w.invalid_type,expected:M.bigint,received:a.parsedType}),D}gte(e,a){return this.setLimit("min",e,!0,N.toString(a))}gt(e,a){return this.setLimit("min",e,!1,N.toString(a))}lte(e,a){return this.setLimit("max",e,!0,N.toString(a))}lt(e,a){return this.setLimit("max",e,!1,N.toString(a))}setLimit(e,a,r,s){return new Dr({...this._def,checks:[...this._def.checks,{kind:e,value:a,inclusive:r,message:N.toString(s)}]})}_addCheck(e){return new Dr({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:N.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:N.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:N.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:N.toString(e)})}multipleOf(e,a){return this._addCheck({kind:"multipleOf",value:e,message:N.toString(a)})}get minValue(){let e=null;for(let a of this._def.checks)a.kind==="min"&&(e===null||a.value>e)&&(e=a.value);return e}get maxValue(){let e=null;for(let a of this._def.checks)a.kind==="max"&&(e===null||a.value<e)&&(e=a.value);return e}};qa.create=t=>new qa({checks:[],typeName:k.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...z(t)});var Va=class extends U{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==M.boolean){let e=this._getOrReturnCtx(t);return S(e,{code:w.invalid_type,expected:M.boolean,received:e.parsedType}),D}return fe(t.data)}};Va.create=t=>new Va({typeName:k.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...z(t)});var Wa=class bi extends U{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==M.date){let s=this._getOrReturnCtx(e);return S(s,{code:w.invalid_type,expected:M.date,received:s.parsedType}),D}if(Number.isNaN(e.data.getTime()))return S(this._getOrReturnCtx(e),{code:w.invalid_date}),D;let a=new be,r;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(r=this._getOrReturnCtx(e,r),S(r,{code:w.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),a.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(r=this._getOrReturnCtx(e,r),S(r,{code:w.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),a.dirty()):B.assertNever(s);return{status:a.value,value:new Date(e.data.getTime())}}_addCheck(e){return new bi({...this._def,checks:[...this._def.checks,e]})}min(e,a){return this._addCheck({kind:"min",value:e.getTime(),message:N.toString(a)})}max(e,a){return this._addCheck({kind:"max",value:e.getTime(),message:N.toString(a)})}get minDate(){let e=null;for(let a of this._def.checks)a.kind==="min"&&(e===null||a.value>e)&&(e=a.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let a of this._def.checks)a.kind==="max"&&(e===null||a.value<e)&&(e=a.value);return e==null?null:new Date(e)}};Wa.create=t=>new Wa({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:k.ZodDate,...z(t)});var Ba=class extends U{_parse(t){if(this._getType(t)!==M.symbol){let e=this._getOrReturnCtx(t);return S(e,{code:w.invalid_type,expected:M.symbol,received:e.parsedType}),D}return fe(t.data)}};Ba.create=t=>new Ba({typeName:k.ZodSymbol,...z(t)});var ra=class extends U{_parse(t){if(this._getType(t)!==M.undefined){let e=this._getOrReturnCtx(t);return S(e,{code:w.invalid_type,expected:M.undefined,received:e.parsedType}),D}return fe(t.data)}};ra.create=t=>new ra({typeName:k.ZodUndefined,...z(t)});var sa=class extends U{_parse(t){if(this._getType(t)!==M.null){let e=this._getOrReturnCtx(t);return S(e,{code:w.invalid_type,expected:M.null,received:e.parsedType}),D}return fe(t.data)}};sa.create=t=>new sa({typeName:k.ZodNull,...z(t)});var Ka=class extends U{constructor(){super(...arguments),this._any=!0}_parse(t){return fe(t.data)}};Ka.create=t=>new Ka({typeName:k.ZodAny,...z(t)});var wt=class extends U{constructor(){super(...arguments),this._unknown=!0}_parse(t){return fe(t.data)}};wt.create=t=>new wt({typeName:k.ZodUnknown,...z(t)});var Qe=class extends U{_parse(t){let e=this._getOrReturnCtx(t);return S(e,{code:w.invalid_type,expected:M.never,received:e.parsedType}),D}};Qe.create=t=>new Qe({typeName:k.ZodNever,...z(t)});var Ja=class extends U{_parse(t){if(this._getType(t)!==M.undefined){let e=this._getOrReturnCtx(t);return S(e,{code:w.invalid_type,expected:M.void,received:e.parsedType}),D}return fe(t.data)}};Ja.create=t=>new Ja({typeName:k.ZodVoid,...z(t)});var kt=class Ia extends U{_parse(e){let{ctx:a,status:r}=this._processInputParams(e),s=this._def;if(a.parsedType!==M.array)return S(a,{code:w.invalid_type,expected:M.array,received:a.parsedType}),D;if(s.exactLength!==null){let o=a.data.length>s.exactLength.value,i=a.data.length<s.exactLength.value;(o||i)&&(S(a,{code:o?w.too_big:w.too_small,minimum:i?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&a.data.length<s.minLength.value&&(S(a,{code:w.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&a.data.length>s.maxLength.value&&(S(a,{code:w.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),a.common.async)return Promise.all([...a.data].map((o,i)=>s.type._parseAsync(new $e(a,o,a.path,i)))).then(o=>be.mergeArray(r,o));let n=[...a.data].map((o,i)=>s.type._parseSync(new $e(a,o,a.path,i)));return be.mergeArray(r,n)}get element(){return this._def.type}min(e,a){return new Ia({...this._def,minLength:{value:e,message:N.toString(a)}})}max(e,a){return new Ia({...this._def,maxLength:{value:e,message:N.toString(a)}})}length(e,a){return new Ia({...this._def,exactLength:{value:e,message:N.toString(a)}})}nonempty(e){return this.min(1,e)}};kt.create=(t,e)=>new kt({type:t,minLength:null,maxLength:null,exactLength:null,typeName:k.ZodArray,...z(e)});function Ct(t){if(t instanceof Se){let e={};for(let a in t.shape){let r=t.shape[a];e[a]=Ve.create(Ct(r))}return new Se({...t._def,shape:()=>e})}else return t instanceof kt?new kt({...t._def,type:Ct(t.element)}):t instanceof Ve?Ve.create(Ct(t.unwrap())):t instanceof dt?dt.create(Ct(t.unwrap())):t instanceof lt?lt.create(t.items.map(e=>Ct(e))):t}var Se=class Ne extends U{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape();return this._cached={shape:e,keys:B.objectKeys(e)},this._cached}_parse(e){if(this._getType(e)!==M.object){let d=this._getOrReturnCtx(e);return S(d,{code:w.invalid_type,expected:M.object,received:d.parsedType}),D}let{status:a,ctx:r}=this._processInputParams(e),{shape:s,keys:n}=this._getCached(),o=[];if(!(this._def.catchall instanceof Qe&&this._def.unknownKeys==="strip"))for(let d in r.data)n.includes(d)||o.push(d);let i=[];for(let d of n){let l=s[d],u=r.data[d];i.push({key:{status:"valid",value:d},value:l._parse(new $e(r,u,r.path,d)),alwaysSet:d in r.data})}if(this._def.catchall instanceof Qe){let d=this._def.unknownKeys;if(d==="passthrough")for(let l of o)i.push({key:{status:"valid",value:l},value:{status:"valid",value:r.data[l]}});else if(d==="strict")o.length>0&&(S(r,{code:w.unrecognized_keys,keys:o}),a.dirty());else if(d!=="strip")throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let d=this._def.catchall;for(let l of o){let u=r.data[l];i.push({key:{status:"valid",value:l},value:d._parse(new $e(r,u,r.path,l)),alwaysSet:l in r.data})}}return r.common.async?Promise.resolve().then(async()=>{let d=[];for(let l of i){let u=await l.key,p=await l.value;d.push({key:u,value:p,alwaysSet:l.alwaysSet})}return d}).then(d=>be.mergeObjectSync(a,d)):be.mergeObjectSync(a,i)}get shape(){return this._def.shape()}strict(e){return N.errToObj,new Ne({...this._def,unknownKeys:"strict",...e===void 0?{}:{errorMap:(a,r)=>{var n,o;let s=((o=(n=this._def).errorMap)==null?void 0:o.call(n,a,r).message)??r.defaultError;return a.code==="unrecognized_keys"?{message:N.errToObj(e).message??s}:{message:s}}}})}strip(){return new Ne({...this._def,unknownKeys:"strip"})}passthrough(){return new Ne({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ne({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ne({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:k.ZodObject})}setKey(e,a){return this.augment({[e]:a})}catchall(e){return new Ne({...this._def,catchall:e})}pick(e){let a={};for(let r of B.objectKeys(e))e[r]&&this.shape[r]&&(a[r]=this.shape[r]);return new Ne({...this._def,shape:()=>a})}omit(e){let a={};for(let r of B.objectKeys(this.shape))e[r]||(a[r]=this.shape[r]);return new Ne({...this._def,shape:()=>a})}deepPartial(){return Ct(this)}partial(e){let a={};for(let r of B.objectKeys(this.shape)){let s=this.shape[r];e&&!e[r]?a[r]=s:a[r]=s.optional()}return new Ne({...this._def,shape:()=>a})}required(e){let a={};for(let r of B.objectKeys(this.shape))if(e&&!e[r])a[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof Ve;)s=s._def.innerType;a[r]=s}return new Ne({...this._def,shape:()=>a})}keyof(){return Zs(B.objectKeys(this.shape))}};Se.create=(t,e)=>new Se({shape:()=>t,unknownKeys:"strip",catchall:Qe.create(),typeName:k.ZodObject,...z(e)}),Se.strictCreate=(t,e)=>new Se({shape:()=>t,unknownKeys:"strict",catchall:Qe.create(),typeName:k.ZodObject,...z(e)}),Se.lazycreate=(t,e)=>new Se({shape:t,unknownKeys:"strip",catchall:Qe.create(),typeName:k.ZodObject,...z(e)});var na=class extends U{_parse(t){let{ctx:e}=this._processInputParams(t),a=this._def.options;function r(s){for(let o of s)if(o.result.status==="valid")return o.result;for(let o of s)if(o.result.status==="dirty")return e.common.issues.push(...o.ctx.common.issues),o.result;let n=s.map(o=>new Pe(o.ctx.common.issues));return S(e,{code:w.invalid_union,unionErrors:n}),D}if(e.common.async)return Promise.all(a.map(async s=>{let n={...e,common:{...e.common,issues:[]},parent:null};return{result:await s._parseAsync({data:e.data,path:e.path,parent:n}),ctx:n}})).then(r);{let s,n=[];for(let i of a){let d={...e,common:{...e.common,issues:[]},parent:null},l=i._parseSync({data:e.data,path:e.path,parent:d});if(l.status==="valid")return l;l.status==="dirty"&&!s&&(s={result:l,ctx:d}),d.common.issues.length&&n.push(d.common.issues)}if(s)return e.common.issues.push(...s.ctx.common.issues),s.result;let o=n.map(i=>new Pe(i));return S(e,{code:w.invalid_union,unionErrors:o}),D}}get options(){return this._def.options}};na.create=(t,e)=>new na({options:t,typeName:k.ZodUnion,...z(e)});var Xe=t=>t instanceof oa?Xe(t.schema):t instanceof qe?Xe(t.innerType()):t instanceof la?[t.value]:t instanceof da?t.options:t instanceof ua?B.objectValues(t.enum):t instanceof ca?Xe(t._def.innerType):t instanceof ra?[void 0]:t instanceof sa?[null]:t instanceof Ve?[void 0,...Xe(t.unwrap())]:t instanceof dt?[null,...Xe(t.unwrap())]:t instanceof Fs||t instanceof ma?Xe(t.unwrap()):t instanceof pa?Xe(t._def.innerType):[],Tl=class _i extends U{_parse(e){let{ctx:a}=this._processInputParams(e);if(a.parsedType!==M.object)return S(a,{code:w.invalid_type,expected:M.object,received:a.parsedType}),D;let r=this.discriminator,s=a.data[r],n=this.optionsMap.get(s);return n?a.common.async?n._parseAsync({data:a.data,path:a.path,parent:a}):n._parseSync({data:a.data,path:a.path,parent:a}):(S(a,{code:w.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),D)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,a,r){let s=new Map;for(let n of a){let o=Xe(n.shape[e]);if(!o.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let i of o){if(s.has(i))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);s.set(i,n)}}return new _i({typeName:k.ZodDiscriminatedUnion,discriminator:e,options:a,optionsMap:s,...z(r)})}};function Ya(t,e){let a=Ge(t),r=Ge(e);if(t===e)return{valid:!0,data:t};if(a===M.object&&r===M.object){let s=B.objectKeys(e),n=B.objectKeys(t).filter(i=>s.indexOf(i)!==-1),o={...t,...e};for(let i of n){let d=Ya(t[i],e[i]);if(!d.valid)return{valid:!1};o[i]=d.data}return{valid:!0,data:o}}else if(a===M.array&&r===M.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let n=0;n<t.length;n++){let o=t[n],i=e[n],d=Ya(o,i);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return a===M.date&&r===M.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var ia=class extends U{_parse(t){let{status:e,ctx:a}=this._processInputParams(t),r=(s,n)=>{if(Ns(s)||Ns(n))return D;let o=Ya(s.value,n.value);return o.valid?((js(s)||js(n))&&e.dirty(),{status:e.value,value:o.data}):(S(a,{code:w.invalid_intersection_types}),D)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then(([s,n])=>r(s,n)):r(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}};ia.create=(t,e,a)=>new ia({left:t,right:e,typeName:k.ZodIntersection,...z(a)});var lt=class wi extends U{_parse(e){let{status:a,ctx:r}=this._processInputParams(e);if(r.parsedType!==M.array)return S(r,{code:w.invalid_type,expected:M.array,received:r.parsedType}),D;if(r.data.length<this._def.items.length)return S(r,{code:w.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),D;!this._def.rest&&r.data.length>this._def.items.length&&(S(r,{code:w.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),a.dirty());let s=[...r.data].map((n,o)=>{let i=this._def.items[o]||this._def.rest;return i?i._parse(new $e(r,n,r.path,o)):null}).filter(n=>!!n);return r.common.async?Promise.all(s).then(n=>be.mergeArray(a,n)):be.mergeArray(a,s)}get items(){return this._def.items}rest(e){return new wi({...this._def,rest:e})}};lt.create=(t,e)=>{if(!Array.isArray(t))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new lt({items:t,typeName:k.ZodTuple,rest:null,...z(e)})};var El=class Lr extends U{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:a,ctx:r}=this._processInputParams(e);if(r.parsedType!==M.object)return S(r,{code:w.invalid_type,expected:M.object,received:r.parsedType}),D;let s=[],n=this._def.keyType,o=this._def.valueType;for(let i in r.data)s.push({key:n._parse(new $e(r,i,r.path,i)),value:o._parse(new $e(r,r.data[i],r.path,i)),alwaysSet:i in r.data});return r.common.async?be.mergeObjectAsync(a,s):be.mergeObjectSync(a,s)}get element(){return this._def.valueType}static create(e,a,r){return a instanceof U?new Lr({keyType:e,valueType:a,typeName:k.ZodRecord,...z(r)}):new Lr({keyType:aa.create(),valueType:e,typeName:k.ZodRecord,...z(a)})}},Ha=class extends U{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:e,ctx:a}=this._processInputParams(t);if(a.parsedType!==M.map)return S(a,{code:w.invalid_type,expected:M.map,received:a.parsedType}),D;let r=this._def.keyType,s=this._def.valueType,n=[...a.data.entries()].map(([o,i],d)=>({key:r._parse(new $e(a,o,a.path,[d,"key"])),value:s._parse(new $e(a,i,a.path,[d,"value"]))}));if(a.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let i of n){let d=await i.key,l=await i.value;if(d.status==="aborted"||l.status==="aborted")return D;(d.status==="dirty"||l.status==="dirty")&&e.dirty(),o.set(d.value,l.value)}return{status:e.value,value:o}})}else{let o=new Map;for(let i of n){let d=i.key,l=i.value;if(d.status==="aborted"||l.status==="aborted")return D;(d.status==="dirty"||l.status==="dirty")&&e.dirty(),o.set(d.value,l.value)}return{status:e.value,value:o}}}};Ha.create=(t,e,a)=>new Ha({valueType:e,keyType:t,typeName:k.ZodMap,...z(a)});var Ga=class Zr extends U{_parse(e){let{status:a,ctx:r}=this._processInputParams(e);if(r.parsedType!==M.set)return S(r,{code:w.invalid_type,expected:M.set,received:r.parsedType}),D;let s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(S(r,{code:w.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),a.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(S(r,{code:w.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),a.dirty());let n=this._def.valueType;function o(d){let l=new Set;for(let u of d){if(u.status==="aborted")return D;u.status==="dirty"&&a.dirty(),l.add(u.value)}return{status:a.value,value:l}}let i=[...r.data.values()].map((d,l)=>n._parse(new $e(r,d,r.path,l)));return r.common.async?Promise.all(i).then(d=>o(d)):o(i)}min(e,a){return new Zr({...this._def,minSize:{value:e,message:N.toString(a)}})}max(e,a){return new Zr({...this._def,maxSize:{value:e,message:N.toString(a)}})}size(e,a){return this.min(e,a).max(e,a)}nonempty(e){return this.min(1,e)}};Ga.create=(t,e)=>new Ga({valueType:t,minSize:null,maxSize:null,typeName:k.ZodSet,...z(e)});var Sl=class Ta extends U{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:a}=this._processInputParams(e);if(a.parsedType!==M.function)return S(a,{code:w.invalid_type,expected:M.function,received:a.parsedType}),D;function r(i,d){return Fa({data:i,path:a.path,errorMaps:[a.common.contextualErrorMap,a.schemaErrorMap,Za(),Pt].filter(l=>!!l),issueData:{code:w.invalid_arguments,argumentsError:d}})}function s(i,d){return Fa({data:i,path:a.path,errorMaps:[a.common.contextualErrorMap,a.schemaErrorMap,Za(),Pt].filter(l=>!!l),issueData:{code:w.invalid_return_type,returnTypeError:d}})}let n={errorMap:a.common.contextualErrorMap},o=a.data;if(this._def.returns instanceof $t){let i=this;return fe(async function(...d){let l=new Pe([]),u=await i._def.args.parseAsync(d,n).catch(g=>{throw l.addIssue(r(d,g)),l}),p=await Reflect.apply(o,this,u);return await i._def.returns._def.type.parseAsync(p,n).catch(g=>{throw l.addIssue(s(p,g)),l})})}else{let i=this;return fe(function(...d){let l=i._def.args.safeParse(d,n);if(!l.success)throw new Pe([r(d,l.error)]);let u=Reflect.apply(o,this,l.data),p=i._def.returns.safeParse(u,n);if(!p.success)throw new Pe([s(u,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ta({...this._def,args:lt.create(e).rest(wt.create())})}returns(e){return new Ta({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,a,r){return new Ta({args:e||lt.create([]).rest(wt.create()),returns:a||wt.create(),typeName:k.ZodFunction,...z(r)})}},oa=class extends U{get schema(){return this._def.getter()}_parse(t){let{ctx:e}=this._processInputParams(t);return this._def.getter()._parse({data:e.data,path:e.path,parent:e})}};oa.create=(t,e)=>new oa({getter:t,typeName:k.ZodLazy,...z(e)});var la=class extends U{_parse(t){if(t.data!==this._def.value){let e=this._getOrReturnCtx(t);return S(e,{received:e.data,code:w.invalid_literal,expected:this._def.value}),D}return{status:"valid",value:t.data}}get value(){return this._def.value}};la.create=(t,e)=>new la({value:t,typeName:k.ZodLiteral,...z(e)});function Zs(t,e){return new da({values:t,typeName:k.ZodEnum,...z(e)})}var da=class Fr extends U{_parse(e){if(typeof e.data!="string"){let a=this._getOrReturnCtx(e),r=this._def.values;return S(a,{expected:B.joinValues(r),received:a.parsedType,code:w.invalid_type}),D}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let a=this._getOrReturnCtx(e),r=this._def.values;return S(a,{received:a.data,code:w.invalid_enum_value,options:r}),D}return fe(e.data)}get options(){return this._def.values}get enum(){let e={};for(let a of this._def.values)e[a]=a;return e}get Values(){let e={};for(let a of this._def.values)e[a]=a;return e}get Enum(){let e={};for(let a of this._def.values)e[a]=a;return e}extract(e,a=this._def){return Fr.create(e,{...this._def,...a})}exclude(e,a=this._def){return Fr.create(this.options.filter(r=>!e.includes(r)),{...this._def,...a})}};da.create=Zs;var ua=class extends U{_parse(t){let e=B.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(t);if(a.parsedType!==M.string&&a.parsedType!==M.number){let r=B.objectValues(e);return S(a,{expected:B.joinValues(r),received:a.parsedType,code:w.invalid_type}),D}if(this._cache||(this._cache=new Set(B.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let r=B.objectValues(e);return S(a,{received:a.data,code:w.invalid_enum_value,options:r}),D}return fe(t.data)}get enum(){return this._def.values}};ua.create=(t,e)=>new ua({values:t,typeName:k.ZodNativeEnum,...z(e)});var $t=class extends U{unwrap(){return this._def.type}_parse(t){let{ctx:e}=this._processInputParams(t);return e.parsedType!==M.promise&&e.common.async===!1?(S(e,{code:w.invalid_type,expected:M.promise,received:e.parsedType}),D):fe((e.parsedType===M.promise?e.data:Promise.resolve(e.data)).then(a=>this._def.type.parseAsync(a,{path:e.path,errorMap:e.common.contextualErrorMap})))}};$t.create=(t,e)=>new $t({type:t,typeName:k.ZodPromise,...z(e)});var qe=class extends U{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===k.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:e,ctx:a}=this._processInputParams(t),r=this._def.effect||null,s={addIssue:n=>{S(a,n),n.fatal?e.abort():e.dirty()},get path(){return a.path}};if(s.addIssue=s.addIssue.bind(s),r.type==="preprocess"){let n=r.transform(a.data,s);if(a.common.async)return Promise.resolve(n).then(async o=>{if(e.value==="aborted")return D;let i=await this._def.schema._parseAsync({data:o,path:a.path,parent:a});return i.status==="aborted"?D:i.status==="dirty"||e.value==="dirty"?za(i.value):i});{if(e.value==="aborted")return D;let o=this._def.schema._parseSync({data:n,path:a.path,parent:a});return o.status==="aborted"?D:o.status==="dirty"||e.value==="dirty"?za(o.value):o}}if(r.type==="refinement"){let n=o=>{let i=r.refinement(o,s);if(a.common.async)return Promise.resolve(i);if(i instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(a.common.async===!1){let o=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return o.status==="aborted"?D:(o.status==="dirty"&&e.dirty(),n(o.value),{status:e.value,value:o.value})}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(o=>o.status==="aborted"?D:(o.status==="dirty"&&e.dirty(),n(o.value).then(()=>({status:e.value,value:o.value}))))}if(r.type==="transform")if(a.common.async===!1){let n=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!_t(n))return D;let o=r.transform(n.value,s);if(o instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:e.value,value:o}}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(n=>_t(n)?Promise.resolve(r.transform(n.value,s)).then(o=>({status:e.value,value:o})):D);B.assertNever(r)}};qe.create=(t,e,a)=>new qe({schema:t,typeName:k.ZodEffects,effect:e,...z(a)}),qe.createWithPreprocess=(t,e,a)=>new qe({schema:e,effect:{type:"preprocess",transform:t},typeName:k.ZodEffects,...z(a)});var Ve=class extends U{_parse(t){return this._getType(t)===M.undefined?fe(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Ve.create=(t,e)=>new Ve({innerType:t,typeName:k.ZodOptional,...z(e)});var dt=class extends U{_parse(t){return this._getType(t)===M.null?fe(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};dt.create=(t,e)=>new dt({innerType:t,typeName:k.ZodNullable,...z(e)});var ca=class extends U{_parse(t){let{ctx:e}=this._processInputParams(t),a=e.data;return e.parsedType===M.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:e.path,parent:e})}removeDefault(){return this._def.innerType}};ca.create=(t,e)=>new ca({innerType:t,typeName:k.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...z(e)});var pa=class extends U{_parse(t){let{ctx:e}=this._processInputParams(t),a={...e,common:{...e.common,issues:[]}},r=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return ta(r)?r.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Pe(a.common.issues)},input:a.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new Pe(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}};pa.create=(t,e)=>new pa({innerType:t,typeName:k.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...z(e)});var Qa=class extends U{_parse(t){if(this._getType(t)!==M.nan){let e=this._getOrReturnCtx(t);return S(e,{code:w.invalid_type,expected:M.nan,received:e.parsedType}),D}return{status:"valid",value:t.data}}};Qa.create=t=>new Qa({typeName:k.ZodNaN,...z(t)});var Fs=class extends U{_parse(t){let{ctx:e}=this._processInputParams(t),a=e.data;return this._def.type._parse({data:a,path:e.path,parent:e})}unwrap(){return this._def.type}},zs=class ki extends U{_parse(e){let{status:a,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?D:s.status==="dirty"?(a.dirty(),za(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{let s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?D:s.status==="dirty"?(a.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,a){return new ki({in:e,out:a,typeName:k.ZodPipeline})}},ma=class extends U{_parse(t){let e=this._def.innerType._parse(t),a=r=>(_t(r)&&(r.value=Object.freeze(r.value)),r);return ta(e)?e.then(r=>a(r)):a(e)}unwrap(){return this._def.innerType}};ma.create=(t,e)=>new ma({innerType:t,typeName:k.ZodReadonly,...z(e)}),Se.lazycreate;var k;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(k||(k={})),aa.create,Ua.create,Qa.create,qa.create,Va.create,Wa.create,Ba.create,ra.create,sa.create,Ka.create,wt.create,Qe.create,Ja.create,kt.create,Se.create,Se.strictCreate,na.create,Tl.create,ia.create,lt.create,El.create,Ha.create,Ga.create,Sl.create,oa.create,la.create,da.create,ua.create,$t.create,qe.create,Ve.create,dt.create,qe.createWithPreprocess,zs.create;var Xa=class extends Error{constructor(t,e){super(t),this.name="ParseError",this.type=e.type,this.field=e.field,this.value=e.value,this.line=e.line}},Us=10,Al=13,ut=32;function er(t){}function Ol(t){if(typeof t=="function")throw TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:e=er,onError:a=er,onRetry:r=er,onComment:s,maxBufferSize:n}=t,o=[],i=0,d=!0,l,u="",p=0,g,f=!1;function v(h){if(f)throw Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(d&&(d=!1,h.charCodeAt(0)===239&&h.charCodeAt(1)===187&&h.charCodeAt(2)===191&&(h=h.slice(3))),o.length===0){let L=_(h);L!==""&&(o.push(L),i=L.length),x();return}if(h.indexOf(`
|
|
4
4
|
`)===-1&&h.indexOf("\r")===-1){o.push(h),i+=h.length,x();return}o.push(h);let y=o.join("");o.length=0,i=0;let T=_(y);T!==""&&(o.push(T),i=T.length),x()}function x(){n!==void 0&&(i+u.length<=n||(f=!0,o.length=0,i=0,l=void 0,u="",p=0,g=void 0,a(new Xa(`Buffered data exceeded max buffer size of ${n} characters`,{type:"max-buffer-size-exceeded"}))))}function _(h){let y=0;if(h.indexOf("\r")===-1){let T=h.indexOf(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var yt=Object.defineProperty;var _t=(t,e,s)=>e in t?yt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var G=(t,e,s)=>_t(t,typeof e!="symbol"?e+"":e,s);import{o as ce}from"./chunk-C4rtOYze.js";import{u as V}from"./useEvent-GCVIknuR.js";import{t as xt}from"./react-C60yClUi.js";import{Ct as le,E as St,Ir as kt,Zr as wt,ur as y}from"./cells-Biwqg0z6.js";import{D as K,L as u,P as _,T as L,_ as de,i as vt,k as x}from"./zod-BIDX-mZr.js";import{t as U}from"./compiler-runtime-DnimoHo0.js";import{_ as $t}from"./useEventListener-DpNnLPuE.js";import{c as jt}from"./utils-C8Yt16Y7.js";import{t as z}from"./cn-DCUzRj2J.js";import{t as Ct}from"./jsx-runtime-3wZU7vFS.js";import{a as At,c as pe,i as Nt,o as he,r as Rt,s as Tt,t as Lt}from"./popover-B96fOqfH.js";import{c as Dt,i as It,n as Pt,r as qt,s as Ft,t as Et}from"./select-CPo-KTTe.js";import{i as Ot,t as ue}from"./tooltip-C9LWGQ7Y.js";import{t as me}from"./button-W__YVea9.js";import{r as W}from"./strings-DmKKoXrM.js";import{r as Bt,t as Ut}from"./x-4y-nyVDU.js";import{t as Kt}from"./circle-plus-C5gP9LrU.js";import{t as Ht}from"./components-CGGSwziZ.js";import{n as te}from"./DeferredRequestRegistry-6TRSC3VZ.js";import{t as Wt}from"./plus-r1QITpsJ.js";import{t as Mt}from"./sparkles-DwqcWrJl.js";import{a as be,c as ge,i as Gt,n as fe,o as ye,p as Vt,r as _e,s as xe,u as zt}from"./form-B10bgcbQ.js";import{a as Qt,c as Jt,l as Yt,n as Zt,r as Xt,t as es}from"./dialog-WU4x2UpK.js";import{n as Se}from"./ImperativeModal-Dxj31V4A.js";import{t as Q}from"./links-BeU4kHTI.js";import{t as ts}from"./useIframeCapabilities-DBacdN1t.js";import{r as ss}from"./html-to-image-ChfBVn8-.js";import{o as rs}from"./focus-CeTtpVjV.js";import{n as ke}from"./useAsyncData-BcvSvTUt.js";import{a as ns,c as we,i as J,o as Y,s as os,t as as}from"./command-D5LtSvbN.js";import{c as l,o as is,t as cs}from"./form-D9rHu7Cq.js";import{t as ls}from"./request-registry-bUowmAtG.js";import{a as se,c as re,d as ds,f as ps,i as ve,l as $e,n as hs,o as us,r as Z,s as F,t as je,u as Ce}from"./write-secret-modal-DBPF-L6f.js";import{a as ms,i as bs,n as gs,t as fs}from"./data-source-discovery-DCNYJylO.js";import{t as ys}from"./state-BFx9-sFK.js";var D=ce(xt(),1),o=ce(Ct(),1);function _s(t,e){if(!e)return{recommended:[],other:[...t]};let s;try{s=new RegExp(e,"i")}catch{return{recommended:[],other:[...t]}}let n=[],r=[];for(let i of t)s.test(i)?n.push(i):r.push(i);return{recommended:n,other:r}}const Ae=({value:t,onChange:e,placeholder:s,secretsOnly:n=!1,recommendedKeys:r,otherKeys:i,onCreateSecret:c,className:a,searchPlaceholder:d,formatCustomValueLabel:p=f=>`Use "${f}"`,createSecretLabel:h="Create a new secret",allowCustomValue:m,allowCreateSecret:g})=>{let[f,b]=(0,D.useState)(!1),[S,w]=(0,D.useState)(""),k=S.trim(),$=!n&&k.length>0&&k!==t&&((m==null?void 0:m(k))??!0),C=(g==null?void 0:g(k))??!0,j=t?F(t)?us(t):t:null,N=v=>{e(re(v)),b(!1),w("")},P=v=>{e(v),b(!1),w("")},q=()=>{e(""),w(""),b(!1)};return(0,o.jsxs)("div",{className:z("flex w-full min-w-48 mb-1 items-center gap-1",a),children:[(0,o.jsxs)(Lt,{modal:!0,open:f,onOpenChange:v=>{b(v),v||w("")},children:[(0,o.jsx)(Nt,{asChild:!0,children:(0,o.jsxs)("button",{type:"button",className:z("flex h-6 min-w-0 flex-1 shadow-xs-solid items-center justify-between","rounded-sm border border-input bg-background px-1.5 text-sm font-code ring-offset-background placeholder:text-muted-foreground","hover:shadow-sm-solid focus:outline-hidden focus:ring-1 focus:ring-ring focus:border-primary focus:shadow-md-solid",F(t)&&"bg-accent"),"aria-expanded":f,children:[(0,o.jsx)("span",{className:"truncate flex-1 min-w-0 text-left flex items-center gap-1.5",children:j?(0,o.jsxs)(o.Fragment,{children:[F(t)&&(0,o.jsx)(te,{className:"h-3 w-3 shrink-0 opacity-70"}),(0,o.jsx)("span",{className:"truncate",children:j})]}):(0,o.jsx)("span",{className:"text-muted-foreground",children:s})}),(0,o.jsx)(Bt,{className:"ml-1 h-4 w-4 opacity-50 shrink-0"})]})}),(0,o.jsx)(Rt,{className:"w-(--radix-popover-trigger-width) p-0",align:"start",children:(0,o.jsxs)(as,{children:[(0,o.jsx)(ns,{placeholder:d??(n?"Search secrets...":"Type a value or search secrets..."),rootClassName:"px-1 h-8",autoFocus:!0,value:S,onValueChange:w}),(0,o.jsxs)(os,{className:"max-h-60 overscroll-contain",children:[$&&(0,o.jsx)(J,{children:(0,o.jsx)(Y,{value:`use custom value ${k}`,onSelect:()=>P(k),children:p(k)})}),C&&(0,o.jsx)(J,{className:"mt-0",children:(0,o.jsxs)(Y,{value:`create new secret ${k}`,onSelect:()=>{let v=k||void 0;b(!1),w(""),c(v)},children:[(0,o.jsx)(Kt,{className:"mr-2 h-3.5 w-3.5"}),h]})}),r.length>0&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(we,{className:"mt-0"}),(0,o.jsx)(J,{heading:"Recommended",children:r.map(v=>(0,o.jsxs)(Y,{value:v,onSelect:()=>N(v),children:[(0,o.jsx)(te,{className:"mr-2 h-3 w-3 opacity-70"}),v]},v))})]}),i.length>0&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(we,{className:"mt-0"}),(0,o.jsx)(J,{heading:r.length>0?"Other":void 0,children:i.map(v=>(0,o.jsxs)(Y,{value:v,onSelect:()=>N(v),children:[(0,o.jsx)(te,{className:"mr-2 h-3 w-3 opacity-70"}),v]},v))})]})]})]})})]}),t&&(0,o.jsx)("button",{type:"button","aria-label":"Clear",className:z("flex h-6 w-6 shrink-0 items-center justify-center rounded-sm","text-muted-foreground hover:bg-muted hover:text-foreground","focus:outline-hidden focus:ring-1 focus:ring-ring"),onClick:q,children:(0,o.jsx)(Ut,{className:"h-3.5 w-3.5"})})]})};var xs=U(),Ne=(0,D.createContext)({providerNames:[],secretKeys:[],loading:!1,error:void 0,refreshSecrets:$t.NOOP});const Re=()=>(0,D.use)(Ne),Ss=t=>{let e=(0,xs.c)(14),{children:s}=t,n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],e[0]=n):n=e[0];let{data:r,isPending:i,error:c,refetch:a}=ke(Cs,n);r==null||r.secretKeys,r==null||r.providerNames;let d;e[1]===(r==null?void 0:r.secretKeys)?d=e[2]:(d=(r==null?void 0:r.secretKeys)||[],e[1]=r==null?void 0:r.secretKeys,e[2]=d);let p;e[3]===(r==null?void 0:r.providerNames)?p=e[4]:(p=(r==null?void 0:r.providerNames)||[],e[3]=r==null?void 0:r.providerNames,e[4]=p);let h;e[5]!==c||e[6]!==i||e[7]!==a||e[8]!==d||e[9]!==p?(h={secretKeys:d,providerNames:p,loading:i,error:c,refreshSecrets:a},e[5]=c,e[6]=i,e[7]=a,e[8]=d,e[9]=p,e[10]=h):h=e[10];let m=h,g;return e[11]!==s||e[12]!==m?(g=(0,o.jsx)(Ne,{value:m,children:s}),e[11]=s,e[12]=m,e[13]=g):g=e[13],g},ks={isMatch:t=>{if(t instanceof de){let{optionRegex:e}=l.parse(t.description||"");return!!e}return!1},Component:({schema:t,form:e,path:s})=>{let{secretKeys:n,providerNames:r,refreshSecrets:i}=Re(),{openModal:c,closeModal:a}=Se(),{label:d,description:p,placeholder:h,optionRegex:m="",inputType:g}=l.parse(t.description||""),f=g==="password",{recommended:b,other:S}=_s(n,m);return(0,o.jsx)(be,{control:e.control,name:s,render:({field:w})=>(0,o.jsxs)(ye,{children:[(0,o.jsx)(xe,{children:d}),(0,o.jsx)(_e,{children:p}),(0,o.jsx)(fe,{children:(0,o.jsx)(Ae,{value:w.value?String(w.value):"",onChange:w.onChange,placeholder:h,secretsOnly:f,recommendedKeys:b,otherKeys:S,onCreateSecret:k=>{c((0,o.jsx)(je,{providerNames:r,initialValue:k,onSuccess:$=>{i(),w.onChange(re($)),a()},onClose:a}))}})}),(0,o.jsx)(ge,{})]})})}},ws={isMatch:t=>{if(t instanceof de){let{special:e}=l.parse(t.description||"");return e==="secret_textarea"}return!1},Component:({schema:t,form:e,path:s})=>{let{secretKeys:n,providerNames:r,refreshSecrets:i}=Re(),{openModal:c,closeModal:a}=Se(),{label:d,description:p,placeholder:h}=l.parse(t.description||"");return(0,o.jsx)(be,{control:e.control,name:s,render:({field:m})=>{let g=m.value?String(m.value):"",f=Ce(g)?ps(g):g;return(0,o.jsxs)(ye,{children:[(0,o.jsxs)(xe,{className:"flex items-center gap-1",children:[d,(0,o.jsx)(ue,{content:"Enter a path to a file on disk, or create a secret to paste JSON directly.",delayDuration:300,children:(0,o.jsx)("button",{type:"button",className:"inline-flex","aria-label":"Credential input help",children:(0,o.jsx)(kt,{className:"h-3.5 w-3.5"})})})]}),(0,o.jsx)(_e,{children:p}),(0,o.jsx)(fe,{children:(0,o.jsx)(Ae,{value:f,onChange:b=>{m.onChange(!b||F(b)||Ce(b)?b:ds(b))},placeholder:h,searchPlaceholder:"Type a file path or paste JSON",formatCustomValueLabel:b=>`Use "${b}" as a file path`,createSecretLabel:"Paste JSON credentials",allowCustomValue:b=>!ve(b),allowCreateSecret:b=>!b||ve(b),recommendedKeys:[],otherKeys:n,onCreateSecret:b=>{c((0,o.jsx)(je,{providerNames:r,initialValue:b,multiline:!0,onSuccess:S=>{i(),m.onChange(re(S)),a()},onClose:a}))}})}),(0,o.jsx)(ge,{})]})}})}};function vs(t){return t.provider!=="env"}function $s(t){return t.name}function js(t){return t.keys}async function Cs(){let t=await ls.request({}),e=hs(t.secrets).filter(vs).map($s);return{secretKeys:t.secrets.flatMap(js).toSorted(),providerNames:e}}var M=U(),As=[ks,ws];const ne=t=>{let e=(0,M.c)(2),{children:s}=t,n;return e[0]===s?n=e[1]:(n=(0,o.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:s}),e[0]=s,e[1]=n),n},oe=t=>{let e=(0,M.c)(9),{name:s,color:n,icon:r,onSelect:i}=t,c;e[0]===n?c=e[1]:(c={backgroundColor:n},e[0]=n,e[1]=c);let a;e[2]===s?a=e[3]:(a=(0,o.jsx)("span",{className:"text-white font-medium text-lg",children:s}),e[2]=s,e[3]=a);let d;return e[4]!==r||e[5]!==i||e[6]!==c||e[7]!==a?(d=(0,o.jsxs)("button",{type:"button",className:"py-3 flex flex-col items-center justify-center gap-1 transition-all hover:scale-105 hover:brightness-110 rounded shadow-sm-solid hover:shadow-md-solid",style:c,onClick:i,children:[r,a]}),e[4]=r,e[5]=i,e[6]=c,e[7]=a,e[8]=d):d=e[8],d},Ns=t=>{let e=(0,M.c)(25),{onBack:s,isValid:n,libraries:r,preferredLibrary:i,onLibraryChange:c,displayNames:a,libraryLabel:d}=t,p=d===void 0?"Preferred library":d,h;e[0]===s?h=e[1]:(h=(0,o.jsx)(me,{type:"button",variant:"outline",onClick:s,children:"Back"}),e[0]=s,e[1]=h);let m=!n,g;e[2]===m?g=e[3]:(g=(0,o.jsx)(me,{type:"submit",disabled:m,children:"Add"}),e[2]=m,e[3]=g);let f;e[4]!==h||e[5]!==g?(f=(0,o.jsxs)("div",{className:"flex gap-2",children:[h,g]}),e[4]=h,e[5]=g,e[6]=f):f=e[6];let b;e[7]===Symbol.for("react.memo_cache_sentinel")?(b=(0,o.jsx)(Ft,{children:(0,o.jsx)(Dt,{placeholder:"Select a library"})}),e[7]=b):b=e[7];let S;e[8]===p?S=e[9]:(S=(0,o.jsxs)("div",{className:"flex flex-col gap-1 items-end",children:[b,(0,o.jsx)("span",{className:"text-xs text-muted-foreground",children:p})]}),e[8]=p,e[9]=S);let w;if(e[10]!==a||e[11]!==r){let j;e[13]===a?j=e[14]:(j=N=>(0,o.jsx)(It,{value:N,children:a[N]??N},N),e[13]=a,e[14]=j),w=r.map(j),e[10]=a,e[11]=r,e[12]=w}else w=e[12];let k;e[15]===w?k=e[16]:(k=(0,o.jsx)(Pt,{children:(0,o.jsx)(qt,{children:w})}),e[15]=w,e[16]=k);let $;e[17]!==c||e[18]!==i||e[19]!==S||e[20]!==k?($=(0,o.jsx)("div",{children:(0,o.jsxs)(Et,{value:i,onValueChange:c,children:[S,k]})}),e[17]=c,e[18]=i,e[19]=S,e[20]=k,e[21]=$):$=e[21];let C;return e[22]!==$||e[23]!==f?(C=(0,o.jsxs)("div",{className:"flex gap-2 justify-between",children:[f,$]}),e[22]=$,e[23]=f,e[24]=C):C=e[24],C};function Te(){let t=(0,M.c)(4),{createNewCell:e}=St(),s=rs(),n=V(jt),r;return t[0]!==n||t[1]!==e||t[2]!==s?(r=i=>{/\bmo\./.test(i)&&ss({autoInstantiate:n,createNewCell:e,fromCellId:s}),e({code:i,before:!1,cellId:s??"__end__",skipIfCodeExists:!0})},t[0]=n,t[1]=e,t[2]=s,t[3]=r):r=t[3],r}const Le=t=>{let e=(0,M.c)(30),{schema:s,libraries:n,preferredLibrary:r,displayNames:i,libraryLabel:c,generateCode:a,onSubmit:d,onBack:p}=t,h;e[0]===s?h=e[1]:(h=is(s),e[0]=s,e[1]=h);let m=h,g;e[2]===s?g=e[3]:(g=zt(s),e[2]=s,e[3]=g);let f;e[4]!==m||e[5]!==g?(f={defaultValues:m,resolver:g,reValidateMode:"onChange"},e[4]=m,e[5]=g,e[6]=f):f=e[6];let b=Vt(f),[S,w]=D.useState(r),k=Te(),$;e[7]!==a||e[8]!==k||e[9]!==d||e[10]!==S?($=ft=>{k(a(ft,S)),d()},e[7]=a,e[8]=k,e[9]=d,e[10]=S,e[11]=$):$=e[11];let C=$,j;e[12]!==b||e[13]!==C?(j=b.handleSubmit(C),e[12]=b,e[13]=C,e[14]=j):j=e[14];let N;e[15]===Symbol.for("react.memo_cache_sentinel")?(N=(0,o.jsx)(Gt,{}),e[15]=N):N=e[15];let P;e[16]!==b||e[17]!==s?(P=(0,o.jsx)(Ss,{children:(0,o.jsx)(cs,{schema:s,form:b,renderers:As,children:N})}),e[16]=b,e[17]=s,e[18]=P):P=e[18];let q;e[19]!==i||e[20]!==b.formState.isValid||e[21]!==n||e[22]!==c||e[23]!==p||e[24]!==S?(q=(0,o.jsx)(Ns,{onBack:p,isValid:b.formState.isValid,libraries:n,preferredLibrary:S,onLibraryChange:w,displayNames:i,libraryLabel:c}),e[19]=i,e[20]=b.formState.isValid,e[21]=n,e[22]=c,e[23]=p,e[24]=S,e[25]=q):q=e[25];let v;return e[26]!==j||e[27]!==P||e[28]!==q?(v=(0,o.jsxs)("form",{onSubmit:j,className:"space-y-4",children:[P,q]}),e[26]=j,e[27]=P,e[28]=q,e[29]=v):v=e[29],v};function E(){return u().optional().describe(l.of({label:"Password",inputType:"password",optionRegex:"(password|passwd|pgpassword|db.?pass(word)?)"}))}function X(t,e){let s=u();return s=e?s.nonempty():s.optional(),s=s.describe(l.of({label:t||"Token",inputType:"password",optionRegex:"(token|api.?key|access.?token|auth.?token|(^|_)pat(_|$))"})),s}function ee(){return u().optional().describe(l.of({label:"Warehouse Name",optionRegex:"(warehouse|snowflake.?warehouse)"}))}function ae(t,e){let s=u();return s=e?s.nonempty():s.optional(),s.describe(l.of({label:t||"URI",optionRegex:"(uri|url|connection.?string|database.?url|jdbc)"}))}function I(t){return u().nonempty().describe(l.of({label:t||"Host",optionRegex:"^(?!.*(kubernetes|gpg)).*(host(name)?|pghost|db.?host|database.?host|mysql.?host|postgres.?host|server.?host)"}))}function R(){return u().describe(l.of({label:"Database",optionRegex:"(database|db.?name|pgdatabase|^DB$|^DATABASE$)"}))}function Rs(){return u().describe(l.of({label:"Schema",optionRegex:"(^SCHEMA$|db.?schema|postgres.?schema|pg.?schema|_SCHEMA$)"}))}function T(){return u().nonempty().describe(l.of({label:"Username",optionRegex:"(username|pguser|db.?user|^USER$|_USER$)"}))}function O(t){let e=vt().describe(l.of({label:"Port",inputType:"number",placeholder:t==null?void 0:t.toString()})).transform(Number).refine(s=>s>=0&&s<=65535,{message:"Port must be between 0 and 65535"});return t===void 0?e:e.default(t)}function De(){return L().default(!1).describe(l.of({label:"Read Only"}))}const Ie=_({type:x("postgres"),host:I(),port:O(5432).optional(),database:R(),username:T(),password:E(),ssl:L().default(!1).describe(l.of({label:"Use SSL"}))}).describe(l.of({direction:"two-columns"})),Pe=_({type:x("mysql"),host:I(),port:O(3306),database:R(),username:T(),password:E(),ssl:L().default(!1).describe(l.of({label:"Use SSL"}))}).describe(l.of({direction:"two-columns"})),qe=_({type:x("sqlite"),database:R().describe(l.of({label:"Database Path"}))}).describe(l.of({direction:"two-columns"})),Fe=_({type:x("duckdb"),database:R().describe(l.of({label:"Database Path"})),read_only:De()}).describe(l.of({direction:"two-columns"})),Ee=_({type:x("motherduck"),database:R().default("my_db").describe(l.of({label:"Database Name"})),token:X()}).describe(l.of({direction:"two-columns"})),Oe=_({type:x("snowflake"),account:u().nonempty().describe(l.of({label:"Account",optionRegex:"(snowflake.?account|^SNOWFLAKE_ACCOUNT$|account.?id)"})),warehouse:u().optional().describe(l.of({label:"Warehouse",optionRegex:"(snowflake.?warehouse|warehouse)"})),database:R(),schema:u().optional().describe(l.of({label:"Schema",optionRegex:"(snowflake.?schema|^SCHEMA$|_SCHEMA$)"})),role:u().optional().describe(l.of({label:"Role"})),authType:K("type",[_({type:x("Password"),username:T(),password:E(),enable_mfa:L().default(!1).describe(l.of({label:"Enable MFA (Duo Push)"}))}),_({type:x("SSO (Browser)"),username:T()}),_({type:x("Key Pair"),username:T(),private_key_path:u().nonempty().describe(l.of({label:"Private Key Path",placeholder:"/path/to/rsa_key.p8"})),private_key_passphrase:u().optional().describe(l.of({label:"Private Key Passphrase",inputType:"password",optionRegex:"(passphrase|private.?key.?passphrase|key.?passphrase)"}))}),_({type:x("OAuth / PAT"),token:X("Token",!0)})]).default({type:"Password",username:"username",enable_mfa:!1}).describe(l.of({special:"tabs"}))}).describe(l.of({direction:"two-columns"})),Be=_({type:x("bigquery"),project:u().nonempty().describe(l.of({label:"Project ID",optionRegex:"(bigquery.?project|gcp.?project|google.?cloud.?project|project.?id)"})),dataset:u().nonempty().describe(l.of({label:"Dataset",optionRegex:"(bigquery.?dataset|dataset)"})),credentials_json:u().describe(l.of({label:"Credentials JSON",special:"secret_textarea"}))}).describe(l.of({direction:"two-columns"})),Ue=_({type:x("clickhouse_connect"),host:I(),port:O(8123).optional(),username:T(),password:E(),secure:L().default(!1).describe(l.of({label:"Use HTTPs"})),proxy_path:u().optional().describe(l.of({label:"Proxy Path",placeholder:"/clickhouse"}))}).describe(l.of({direction:"two-columns"})),Ke=_({type:x("timeplus"),host:I().default("localhost"),port:O(8123).optional(),username:T().default("default"),password:E().default("")}).describe(l.of({direction:"two-columns"})),He=_({type:x("chdb"),database:R().describe(l.of({label:"Database Path"})),read_only:De()}).describe(l.of({direction:"two-columns"})),We=_({type:x("trino"),host:I(),port:O(8080),database:R(),schema:Rs().optional(),username:T(),password:E(),async_support:L().default(!1).describe(l.of({label:"Async Support"}))}).describe(l.of({direction:"two-columns"})),Me=_({type:x("iceberg"),name:u().describe(l.of({label:"Catalog Name"})),catalog:K("type",[_({type:x("REST"),warehouse:ee(),uri:u().optional().describe(l.of({label:"URI",placeholder:"https://",optionRegex:"(uri|url|connection.?string|database.?url|jdbc)"})),token:X()}),_({type:x("SQL"),warehouse:ee(),uri:u().optional().describe(l.of({label:"URI",placeholder:"jdbc:iceberg://host:port/database",optionRegex:"(uri|url|connection.?string|database.?url|jdbc)"}))}),_({type:x("Hive"),warehouse:ee(),uri:ae()}),_({type:x("Glue"),warehouse:ee(),uri:ae()}),_({type:x("DynamoDB"),"dynamodb.profile-name":u().optional().describe(l.of({label:"Profile Name"})),"dynamodb.region":u().optional().describe(l.of({label:"Region"})),"dynamodb.access-key-id":u().optional().describe(l.of({label:"Access Key ID",inputType:"password",optionRegex:"(access.?key.?id|aws.?access.?key)"})),"dynamodb.secret-access-key":u().optional().describe(l.of({label:"Secret Access Key",inputType:"password",optionRegex:"(secret.?access.?key|aws.?secret)"})),"dynamodb.session-token":u().optional().describe(l.of({label:"Session Token",inputType:"password",optionRegex:"(session.?token|aws.?session)"}))})]).default({type:"REST",token:void 0}).describe(l.of({special:"tabs"}))}),Ge=_({type:x("datafusion"),sessionContext:L().optional().describe(l.of({label:"Use Session Context"}))}),Ve=_({type:x("pyspark"),host:I().optional(),port:O().optional()}),ze=_({type:x("redshift"),host:I(),port:O(5439),connectionType:K("type",[_({type:x("IAM credentials"),region:u().describe(l.of({label:"Region"})),aws_access_key_id:u().nonempty().describe(l.of({label:"AWS Access Key ID",inputType:"password",optionRegex:"(access.?key.?id|aws.?access.?key)"})),aws_secret_access_key:u().nonempty().describe(l.of({label:"AWS Secret Access Key",inputType:"password",optionRegex:"(secret.?access.?key|aws.?secret)"})),aws_session_token:u().optional().describe(l.of({label:"AWS Session Token",inputType:"password",optionRegex:"(session.?token|aws.?session)"}))}),_({type:x("DB credentials"),user:T(),password:E()})]).default({type:"IAM credentials",aws_access_key_id:"",aws_secret_access_key:"",region:""}),database:R()}).describe(l.of({direction:"two-columns"})),Qe=_({type:x("databricks"),access_token:X("Access Token",!0),server_hostname:I("Server Hostname"),http_path:ae("HTTP Path",!0),catalog:u().optional().describe(l.of({label:"Catalog"})),schema:u().optional().describe(l.of({label:"Schema"}))}).describe(l.of({direction:"two-columns"})),Je=_({type:x("supabase"),host:I(),port:O(5432).optional(),database:R(),username:T(),password:E(),disable_client_pooling:L().default(!1).describe(l.of({label:"Disable Client-Side Pooling"}))}).describe(l.of({direction:"two-columns"})),Ts=K("type",[Ie,Pe,qe,Fe,Ee,Oe,Be,Ue,Ke,He,We,Me,Ge,Ve,ze,Qe,Je]),Ye={sqlmodel:"SQLModel",sqlalchemy:"SQLAlchemy",duckdb:"DuckDB",clickhouse_connect:"ClickHouse Connect",chdb:"chDB",pyiceberg:"PyIceberg",ibis:"Ibis",motherduck:"MotherDuck",redshift:"Redshift",databricks:"Databricks"};var A=class{constructor(t,e,s){this.connection=t,this.orm=e,this.secrets=s}get imports(){let t=new Set(this.generateImports());switch(this.orm){case"sqlalchemy":t.add("import sqlalchemy");break;case"sqlmodel":t.add("import sqlmodel");break;case"duckdb":t.add("import duckdb");break;case"ibis":t.add("import ibis");break}return t}},Ls=t=>`_${t}`,Ds=class{constructor(){G(this,"secrets",{})}get imports(){return Object.keys(this.secrets).length===0?new Set:new Set(["import os"])}print(t,e,s){if(t=Ls(t),F(e)){let n=$e(e),r=s?`os.environ.get("${n}", "${s}")`:`os.environ.get("${n}")`;return this.secrets[t]=r,t}if(s!=null){let n=`os.environ.get("${e}", "${s}")`;return this.secrets[t]=n,t}return typeof e=="number"||typeof e=="number"?`${e}`:typeof e=="boolean"?H(e):e?`"${e}"`:""}printInFString(t,e,s){if(e===void 0)return"";if(typeof e=="number")return`${e}`;if(typeof e=="boolean")return H(e);let n=this.print(t,e,s);return n.startsWith('"')&&n.endsWith('"')?n.slice(1,-1):`{${n}}`}printPassword(t,e,s,n){let r=s?this.printInFString.bind(this):this.print.bind(this);return F(t)?r(n||"password",t):r(n||"password",e,t)}getSecrets(){return this.secrets}formatSecrets(){return Object.keys(this.secrets).length===0?"":Object.entries(this.secrets).map(([t,e])=>`${t} = ${e}`).join(`
|
|
1
|
+
var yt=Object.defineProperty;var _t=(t,e,s)=>e in t?yt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var G=(t,e,s)=>_t(t,typeof e!="symbol"?e+"":e,s);import{o as ce}from"./chunk-C4rtOYze.js";import{u as V}from"./useEvent-GCVIknuR.js";import{t as xt}from"./react-C60yClUi.js";import{Ct as le,E as St,Ir as kt,Zr as wt,ur as y}from"./cells-BIt-E5vq.js";import{D as K,L as u,P as _,T as L,_ as de,i as vt,k as x}from"./zod-BIDX-mZr.js";import{t as U}from"./compiler-runtime-DnimoHo0.js";import{_ as $t}from"./useEventListener-DpNnLPuE.js";import{c as jt}from"./utils-C8Yt16Y7.js";import{t as z}from"./cn-DCUzRj2J.js";import{t as Ct}from"./jsx-runtime-3wZU7vFS.js";import{a as At,c as pe,i as Nt,o as he,r as Rt,s as Tt,t as Lt}from"./popover-B96fOqfH.js";import{c as Dt,i as It,n as Pt,r as qt,s as Ft,t as Et}from"./select-CPo-KTTe.js";import{i as Ot,t as ue}from"./tooltip-C9LWGQ7Y.js";import{t as me}from"./button-W__YVea9.js";import{r as W}from"./strings-DmKKoXrM.js";import{r as Bt,t as Ut}from"./x-4y-nyVDU.js";import{t as Kt}from"./circle-plus-C5gP9LrU.js";import{t as Ht}from"./components-CGGSwziZ.js";import{n as te}from"./DeferredRequestRegistry-6TRSC3VZ.js";import{t as Wt}from"./plus-r1QITpsJ.js";import{t as Mt}from"./sparkles-DwqcWrJl.js";import{a as be,c as ge,i as Gt,n as fe,o as ye,p as Vt,r as _e,s as xe,u as zt}from"./form-DbRAwKK1.js";import{a as Qt,c as Jt,l as Yt,n as Zt,r as Xt,t as es}from"./dialog-WU4x2UpK.js";import{n as Se}from"./ImperativeModal-Dxj31V4A.js";import{t as Q}from"./links-BeU4kHTI.js";import{t as ts}from"./useIframeCapabilities-DBacdN1t.js";import{r as ss}from"./html-to-image-BvGsu9Nz.js";import{o as rs}from"./focus-agtnrA0w.js";import{n as ke}from"./useAsyncData-BcvSvTUt.js";import{a as ns,c as we,i as J,o as Y,s as os,t as as}from"./command-D5LtSvbN.js";import{c as l,o as is,t as cs}from"./form-sf0A_nV4.js";import{t as ls}from"./request-registry-bUowmAtG.js";import{a as se,c as re,d as ds,f as ps,i as ve,l as $e,n as hs,o as us,r as Z,s as F,t as je,u as Ce}from"./write-secret-modal-DBPF-L6f.js";import{a as ms,i as bs,n as gs,t as fs}from"./data-source-discovery-DdefgaOP.js";import{t as ys}from"./state-BFx9-sFK.js";var D=ce(xt(),1),o=ce(Ct(),1);function _s(t,e){if(!e)return{recommended:[],other:[...t]};let s;try{s=new RegExp(e,"i")}catch{return{recommended:[],other:[...t]}}let n=[],r=[];for(let i of t)s.test(i)?n.push(i):r.push(i);return{recommended:n,other:r}}const Ae=({value:t,onChange:e,placeholder:s,secretsOnly:n=!1,recommendedKeys:r,otherKeys:i,onCreateSecret:c,className:a,searchPlaceholder:d,formatCustomValueLabel:p=f=>`Use "${f}"`,createSecretLabel:h="Create a new secret",allowCustomValue:m,allowCreateSecret:g})=>{let[f,b]=(0,D.useState)(!1),[S,w]=(0,D.useState)(""),k=S.trim(),$=!n&&k.length>0&&k!==t&&((m==null?void 0:m(k))??!0),C=(g==null?void 0:g(k))??!0,j=t?F(t)?us(t):t:null,N=v=>{e(re(v)),b(!1),w("")},P=v=>{e(v),b(!1),w("")},q=()=>{e(""),w(""),b(!1)};return(0,o.jsxs)("div",{className:z("flex w-full min-w-48 mb-1 items-center gap-1",a),children:[(0,o.jsxs)(Lt,{modal:!0,open:f,onOpenChange:v=>{b(v),v||w("")},children:[(0,o.jsx)(Nt,{asChild:!0,children:(0,o.jsxs)("button",{type:"button",className:z("flex h-6 min-w-0 flex-1 shadow-xs-solid items-center justify-between","rounded-sm border border-input bg-background px-1.5 text-sm font-code ring-offset-background placeholder:text-muted-foreground","hover:shadow-sm-solid focus:outline-hidden focus:ring-1 focus:ring-ring focus:border-primary focus:shadow-md-solid",F(t)&&"bg-accent"),"aria-expanded":f,children:[(0,o.jsx)("span",{className:"truncate flex-1 min-w-0 text-left flex items-center gap-1.5",children:j?(0,o.jsxs)(o.Fragment,{children:[F(t)&&(0,o.jsx)(te,{className:"h-3 w-3 shrink-0 opacity-70"}),(0,o.jsx)("span",{className:"truncate",children:j})]}):(0,o.jsx)("span",{className:"text-muted-foreground",children:s})}),(0,o.jsx)(Bt,{className:"ml-1 h-4 w-4 opacity-50 shrink-0"})]})}),(0,o.jsx)(Rt,{className:"w-(--radix-popover-trigger-width) p-0",align:"start",children:(0,o.jsxs)(as,{children:[(0,o.jsx)(ns,{placeholder:d??(n?"Search secrets...":"Type a value or search secrets..."),rootClassName:"px-1 h-8",autoFocus:!0,value:S,onValueChange:w}),(0,o.jsxs)(os,{className:"max-h-60 overscroll-contain",children:[$&&(0,o.jsx)(J,{children:(0,o.jsx)(Y,{value:`use custom value ${k}`,onSelect:()=>P(k),children:p(k)})}),C&&(0,o.jsx)(J,{className:"mt-0",children:(0,o.jsxs)(Y,{value:`create new secret ${k}`,onSelect:()=>{let v=k||void 0;b(!1),w(""),c(v)},children:[(0,o.jsx)(Kt,{className:"mr-2 h-3.5 w-3.5"}),h]})}),r.length>0&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(we,{className:"mt-0"}),(0,o.jsx)(J,{heading:"Recommended",children:r.map(v=>(0,o.jsxs)(Y,{value:v,onSelect:()=>N(v),children:[(0,o.jsx)(te,{className:"mr-2 h-3 w-3 opacity-70"}),v]},v))})]}),i.length>0&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(we,{className:"mt-0"}),(0,o.jsx)(J,{heading:r.length>0?"Other":void 0,children:i.map(v=>(0,o.jsxs)(Y,{value:v,onSelect:()=>N(v),children:[(0,o.jsx)(te,{className:"mr-2 h-3 w-3 opacity-70"}),v]},v))})]})]})]})})]}),t&&(0,o.jsx)("button",{type:"button","aria-label":"Clear",className:z("flex h-6 w-6 shrink-0 items-center justify-center rounded-sm","text-muted-foreground hover:bg-muted hover:text-foreground","focus:outline-hidden focus:ring-1 focus:ring-ring"),onClick:q,children:(0,o.jsx)(Ut,{className:"h-3.5 w-3.5"})})]})};var xs=U(),Ne=(0,D.createContext)({providerNames:[],secretKeys:[],loading:!1,error:void 0,refreshSecrets:$t.NOOP});const Re=()=>(0,D.use)(Ne),Ss=t=>{let e=(0,xs.c)(14),{children:s}=t,n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],e[0]=n):n=e[0];let{data:r,isPending:i,error:c,refetch:a}=ke(Cs,n);r==null||r.secretKeys,r==null||r.providerNames;let d;e[1]===(r==null?void 0:r.secretKeys)?d=e[2]:(d=(r==null?void 0:r.secretKeys)||[],e[1]=r==null?void 0:r.secretKeys,e[2]=d);let p;e[3]===(r==null?void 0:r.providerNames)?p=e[4]:(p=(r==null?void 0:r.providerNames)||[],e[3]=r==null?void 0:r.providerNames,e[4]=p);let h;e[5]!==c||e[6]!==i||e[7]!==a||e[8]!==d||e[9]!==p?(h={secretKeys:d,providerNames:p,loading:i,error:c,refreshSecrets:a},e[5]=c,e[6]=i,e[7]=a,e[8]=d,e[9]=p,e[10]=h):h=e[10];let m=h,g;return e[11]!==s||e[12]!==m?(g=(0,o.jsx)(Ne,{value:m,children:s}),e[11]=s,e[12]=m,e[13]=g):g=e[13],g},ks={isMatch:t=>{if(t instanceof de){let{optionRegex:e}=l.parse(t.description||"");return!!e}return!1},Component:({schema:t,form:e,path:s})=>{let{secretKeys:n,providerNames:r,refreshSecrets:i}=Re(),{openModal:c,closeModal:a}=Se(),{label:d,description:p,placeholder:h,optionRegex:m="",inputType:g}=l.parse(t.description||""),f=g==="password",{recommended:b,other:S}=_s(n,m);return(0,o.jsx)(be,{control:e.control,name:s,render:({field:w})=>(0,o.jsxs)(ye,{children:[(0,o.jsx)(xe,{children:d}),(0,o.jsx)(_e,{children:p}),(0,o.jsx)(fe,{children:(0,o.jsx)(Ae,{value:w.value?String(w.value):"",onChange:w.onChange,placeholder:h,secretsOnly:f,recommendedKeys:b,otherKeys:S,onCreateSecret:k=>{c((0,o.jsx)(je,{providerNames:r,initialValue:k,onSuccess:$=>{i(),w.onChange(re($)),a()},onClose:a}))}})}),(0,o.jsx)(ge,{})]})})}},ws={isMatch:t=>{if(t instanceof de){let{special:e}=l.parse(t.description||"");return e==="secret_textarea"}return!1},Component:({schema:t,form:e,path:s})=>{let{secretKeys:n,providerNames:r,refreshSecrets:i}=Re(),{openModal:c,closeModal:a}=Se(),{label:d,description:p,placeholder:h}=l.parse(t.description||"");return(0,o.jsx)(be,{control:e.control,name:s,render:({field:m})=>{let g=m.value?String(m.value):"",f=Ce(g)?ps(g):g;return(0,o.jsxs)(ye,{children:[(0,o.jsxs)(xe,{className:"flex items-center gap-1",children:[d,(0,o.jsx)(ue,{content:"Enter a path to a file on disk, or create a secret to paste JSON directly.",delayDuration:300,children:(0,o.jsx)("button",{type:"button",className:"inline-flex","aria-label":"Credential input help",children:(0,o.jsx)(kt,{className:"h-3.5 w-3.5"})})})]}),(0,o.jsx)(_e,{children:p}),(0,o.jsx)(fe,{children:(0,o.jsx)(Ae,{value:f,onChange:b=>{m.onChange(!b||F(b)||Ce(b)?b:ds(b))},placeholder:h,searchPlaceholder:"Type a file path or paste JSON",formatCustomValueLabel:b=>`Use "${b}" as a file path`,createSecretLabel:"Paste JSON credentials",allowCustomValue:b=>!ve(b),allowCreateSecret:b=>!b||ve(b),recommendedKeys:[],otherKeys:n,onCreateSecret:b=>{c((0,o.jsx)(je,{providerNames:r,initialValue:b,multiline:!0,onSuccess:S=>{i(),m.onChange(re(S)),a()},onClose:a}))}})}),(0,o.jsx)(ge,{})]})}})}};function vs(t){return t.provider!=="env"}function $s(t){return t.name}function js(t){return t.keys}async function Cs(){let t=await ls.request({}),e=hs(t.secrets).filter(vs).map($s);return{secretKeys:t.secrets.flatMap(js).toSorted(),providerNames:e}}var M=U(),As=[ks,ws];const ne=t=>{let e=(0,M.c)(2),{children:s}=t,n;return e[0]===s?n=e[1]:(n=(0,o.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:s}),e[0]=s,e[1]=n),n},oe=t=>{let e=(0,M.c)(9),{name:s,color:n,icon:r,onSelect:i}=t,c;e[0]===n?c=e[1]:(c={backgroundColor:n},e[0]=n,e[1]=c);let a;e[2]===s?a=e[3]:(a=(0,o.jsx)("span",{className:"text-white font-medium text-lg",children:s}),e[2]=s,e[3]=a);let d;return e[4]!==r||e[5]!==i||e[6]!==c||e[7]!==a?(d=(0,o.jsxs)("button",{type:"button",className:"py-3 flex flex-col items-center justify-center gap-1 transition-all hover:scale-105 hover:brightness-110 rounded shadow-sm-solid hover:shadow-md-solid",style:c,onClick:i,children:[r,a]}),e[4]=r,e[5]=i,e[6]=c,e[7]=a,e[8]=d):d=e[8],d},Ns=t=>{let e=(0,M.c)(25),{onBack:s,isValid:n,libraries:r,preferredLibrary:i,onLibraryChange:c,displayNames:a,libraryLabel:d}=t,p=d===void 0?"Preferred library":d,h;e[0]===s?h=e[1]:(h=(0,o.jsx)(me,{type:"button",variant:"outline",onClick:s,children:"Back"}),e[0]=s,e[1]=h);let m=!n,g;e[2]===m?g=e[3]:(g=(0,o.jsx)(me,{type:"submit",disabled:m,children:"Add"}),e[2]=m,e[3]=g);let f;e[4]!==h||e[5]!==g?(f=(0,o.jsxs)("div",{className:"flex gap-2",children:[h,g]}),e[4]=h,e[5]=g,e[6]=f):f=e[6];let b;e[7]===Symbol.for("react.memo_cache_sentinel")?(b=(0,o.jsx)(Ft,{children:(0,o.jsx)(Dt,{placeholder:"Select a library"})}),e[7]=b):b=e[7];let S;e[8]===p?S=e[9]:(S=(0,o.jsxs)("div",{className:"flex flex-col gap-1 items-end",children:[b,(0,o.jsx)("span",{className:"text-xs text-muted-foreground",children:p})]}),e[8]=p,e[9]=S);let w;if(e[10]!==a||e[11]!==r){let j;e[13]===a?j=e[14]:(j=N=>(0,o.jsx)(It,{value:N,children:a[N]??N},N),e[13]=a,e[14]=j),w=r.map(j),e[10]=a,e[11]=r,e[12]=w}else w=e[12];let k;e[15]===w?k=e[16]:(k=(0,o.jsx)(Pt,{children:(0,o.jsx)(qt,{children:w})}),e[15]=w,e[16]=k);let $;e[17]!==c||e[18]!==i||e[19]!==S||e[20]!==k?($=(0,o.jsx)("div",{children:(0,o.jsxs)(Et,{value:i,onValueChange:c,children:[S,k]})}),e[17]=c,e[18]=i,e[19]=S,e[20]=k,e[21]=$):$=e[21];let C;return e[22]!==$||e[23]!==f?(C=(0,o.jsxs)("div",{className:"flex gap-2 justify-between",children:[f,$]}),e[22]=$,e[23]=f,e[24]=C):C=e[24],C};function Te(){let t=(0,M.c)(4),{createNewCell:e}=St(),s=rs(),n=V(jt),r;return t[0]!==n||t[1]!==e||t[2]!==s?(r=i=>{/\bmo\./.test(i)&&ss({autoInstantiate:n,createNewCell:e,fromCellId:s}),e({code:i,before:!1,cellId:s??"__end__",skipIfCodeExists:!0})},t[0]=n,t[1]=e,t[2]=s,t[3]=r):r=t[3],r}const Le=t=>{let e=(0,M.c)(30),{schema:s,libraries:n,preferredLibrary:r,displayNames:i,libraryLabel:c,generateCode:a,onSubmit:d,onBack:p}=t,h;e[0]===s?h=e[1]:(h=is(s),e[0]=s,e[1]=h);let m=h,g;e[2]===s?g=e[3]:(g=zt(s),e[2]=s,e[3]=g);let f;e[4]!==m||e[5]!==g?(f={defaultValues:m,resolver:g,reValidateMode:"onChange"},e[4]=m,e[5]=g,e[6]=f):f=e[6];let b=Vt(f),[S,w]=D.useState(r),k=Te(),$;e[7]!==a||e[8]!==k||e[9]!==d||e[10]!==S?($=ft=>{k(a(ft,S)),d()},e[7]=a,e[8]=k,e[9]=d,e[10]=S,e[11]=$):$=e[11];let C=$,j;e[12]!==b||e[13]!==C?(j=b.handleSubmit(C),e[12]=b,e[13]=C,e[14]=j):j=e[14];let N;e[15]===Symbol.for("react.memo_cache_sentinel")?(N=(0,o.jsx)(Gt,{}),e[15]=N):N=e[15];let P;e[16]!==b||e[17]!==s?(P=(0,o.jsx)(Ss,{children:(0,o.jsx)(cs,{schema:s,form:b,renderers:As,children:N})}),e[16]=b,e[17]=s,e[18]=P):P=e[18];let q;e[19]!==i||e[20]!==b.formState.isValid||e[21]!==n||e[22]!==c||e[23]!==p||e[24]!==S?(q=(0,o.jsx)(Ns,{onBack:p,isValid:b.formState.isValid,libraries:n,preferredLibrary:S,onLibraryChange:w,displayNames:i,libraryLabel:c}),e[19]=i,e[20]=b.formState.isValid,e[21]=n,e[22]=c,e[23]=p,e[24]=S,e[25]=q):q=e[25];let v;return e[26]!==j||e[27]!==P||e[28]!==q?(v=(0,o.jsxs)("form",{onSubmit:j,className:"space-y-4",children:[P,q]}),e[26]=j,e[27]=P,e[28]=q,e[29]=v):v=e[29],v};function E(){return u().optional().describe(l.of({label:"Password",inputType:"password",optionRegex:"(password|passwd|pgpassword|db.?pass(word)?)"}))}function X(t,e){let s=u();return s=e?s.nonempty():s.optional(),s=s.describe(l.of({label:t||"Token",inputType:"password",optionRegex:"(token|api.?key|access.?token|auth.?token|(^|_)pat(_|$))"})),s}function ee(){return u().optional().describe(l.of({label:"Warehouse Name",optionRegex:"(warehouse|snowflake.?warehouse)"}))}function ae(t,e){let s=u();return s=e?s.nonempty():s.optional(),s.describe(l.of({label:t||"URI",optionRegex:"(uri|url|connection.?string|database.?url|jdbc)"}))}function I(t){return u().nonempty().describe(l.of({label:t||"Host",optionRegex:"^(?!.*(kubernetes|gpg)).*(host(name)?|pghost|db.?host|database.?host|mysql.?host|postgres.?host|server.?host)"}))}function R(){return u().describe(l.of({label:"Database",optionRegex:"(database|db.?name|pgdatabase|^DB$|^DATABASE$)"}))}function Rs(){return u().describe(l.of({label:"Schema",optionRegex:"(^SCHEMA$|db.?schema|postgres.?schema|pg.?schema|_SCHEMA$)"}))}function T(){return u().nonempty().describe(l.of({label:"Username",optionRegex:"(username|pguser|db.?user|^USER$|_USER$)"}))}function O(t){let e=vt().describe(l.of({label:"Port",inputType:"number",placeholder:t==null?void 0:t.toString()})).transform(Number).refine(s=>s>=0&&s<=65535,{message:"Port must be between 0 and 65535"});return t===void 0?e:e.default(t)}function De(){return L().default(!1).describe(l.of({label:"Read Only"}))}const Ie=_({type:x("postgres"),host:I(),port:O(5432).optional(),database:R(),username:T(),password:E(),ssl:L().default(!1).describe(l.of({label:"Use SSL"}))}).describe(l.of({direction:"two-columns"})),Pe=_({type:x("mysql"),host:I(),port:O(3306),database:R(),username:T(),password:E(),ssl:L().default(!1).describe(l.of({label:"Use SSL"}))}).describe(l.of({direction:"two-columns"})),qe=_({type:x("sqlite"),database:R().describe(l.of({label:"Database Path"}))}).describe(l.of({direction:"two-columns"})),Fe=_({type:x("duckdb"),database:R().describe(l.of({label:"Database Path"})),read_only:De()}).describe(l.of({direction:"two-columns"})),Ee=_({type:x("motherduck"),database:R().default("my_db").describe(l.of({label:"Database Name"})),token:X()}).describe(l.of({direction:"two-columns"})),Oe=_({type:x("snowflake"),account:u().nonempty().describe(l.of({label:"Account",optionRegex:"(snowflake.?account|^SNOWFLAKE_ACCOUNT$|account.?id)"})),warehouse:u().optional().describe(l.of({label:"Warehouse",optionRegex:"(snowflake.?warehouse|warehouse)"})),database:R(),schema:u().optional().describe(l.of({label:"Schema",optionRegex:"(snowflake.?schema|^SCHEMA$|_SCHEMA$)"})),role:u().optional().describe(l.of({label:"Role"})),authType:K("type",[_({type:x("Password"),username:T(),password:E(),enable_mfa:L().default(!1).describe(l.of({label:"Enable MFA (Duo Push)"}))}),_({type:x("SSO (Browser)"),username:T()}),_({type:x("Key Pair"),username:T(),private_key_path:u().nonempty().describe(l.of({label:"Private Key Path",placeholder:"/path/to/rsa_key.p8"})),private_key_passphrase:u().optional().describe(l.of({label:"Private Key Passphrase",inputType:"password",optionRegex:"(passphrase|private.?key.?passphrase|key.?passphrase)"}))}),_({type:x("OAuth / PAT"),token:X("Token",!0)})]).default({type:"Password",username:"username",enable_mfa:!1}).describe(l.of({special:"tabs"}))}).describe(l.of({direction:"two-columns"})),Be=_({type:x("bigquery"),project:u().nonempty().describe(l.of({label:"Project ID",optionRegex:"(bigquery.?project|gcp.?project|google.?cloud.?project|project.?id)"})),dataset:u().nonempty().describe(l.of({label:"Dataset",optionRegex:"(bigquery.?dataset|dataset)"})),credentials_json:u().describe(l.of({label:"Credentials JSON",special:"secret_textarea"}))}).describe(l.of({direction:"two-columns"})),Ue=_({type:x("clickhouse_connect"),host:I(),port:O(8123).optional(),username:T(),password:E(),secure:L().default(!1).describe(l.of({label:"Use HTTPs"})),proxy_path:u().optional().describe(l.of({label:"Proxy Path",placeholder:"/clickhouse"}))}).describe(l.of({direction:"two-columns"})),Ke=_({type:x("timeplus"),host:I().default("localhost"),port:O(8123).optional(),username:T().default("default"),password:E().default("")}).describe(l.of({direction:"two-columns"})),He=_({type:x("chdb"),database:R().describe(l.of({label:"Database Path"})),read_only:De()}).describe(l.of({direction:"two-columns"})),We=_({type:x("trino"),host:I(),port:O(8080),database:R(),schema:Rs().optional(),username:T(),password:E(),async_support:L().default(!1).describe(l.of({label:"Async Support"}))}).describe(l.of({direction:"two-columns"})),Me=_({type:x("iceberg"),name:u().describe(l.of({label:"Catalog Name"})),catalog:K("type",[_({type:x("REST"),warehouse:ee(),uri:u().optional().describe(l.of({label:"URI",placeholder:"https://",optionRegex:"(uri|url|connection.?string|database.?url|jdbc)"})),token:X()}),_({type:x("SQL"),warehouse:ee(),uri:u().optional().describe(l.of({label:"URI",placeholder:"jdbc:iceberg://host:port/database",optionRegex:"(uri|url|connection.?string|database.?url|jdbc)"}))}),_({type:x("Hive"),warehouse:ee(),uri:ae()}),_({type:x("Glue"),warehouse:ee(),uri:ae()}),_({type:x("DynamoDB"),"dynamodb.profile-name":u().optional().describe(l.of({label:"Profile Name"})),"dynamodb.region":u().optional().describe(l.of({label:"Region"})),"dynamodb.access-key-id":u().optional().describe(l.of({label:"Access Key ID",inputType:"password",optionRegex:"(access.?key.?id|aws.?access.?key)"})),"dynamodb.secret-access-key":u().optional().describe(l.of({label:"Secret Access Key",inputType:"password",optionRegex:"(secret.?access.?key|aws.?secret)"})),"dynamodb.session-token":u().optional().describe(l.of({label:"Session Token",inputType:"password",optionRegex:"(session.?token|aws.?session)"}))})]).default({type:"REST",token:void 0}).describe(l.of({special:"tabs"}))}),Ge=_({type:x("datafusion"),sessionContext:L().optional().describe(l.of({label:"Use Session Context"}))}),Ve=_({type:x("pyspark"),host:I().optional(),port:O().optional()}),ze=_({type:x("redshift"),host:I(),port:O(5439),connectionType:K("type",[_({type:x("IAM credentials"),region:u().describe(l.of({label:"Region"})),aws_access_key_id:u().nonempty().describe(l.of({label:"AWS Access Key ID",inputType:"password",optionRegex:"(access.?key.?id|aws.?access.?key)"})),aws_secret_access_key:u().nonempty().describe(l.of({label:"AWS Secret Access Key",inputType:"password",optionRegex:"(secret.?access.?key|aws.?secret)"})),aws_session_token:u().optional().describe(l.of({label:"AWS Session Token",inputType:"password",optionRegex:"(session.?token|aws.?session)"}))}),_({type:x("DB credentials"),user:T(),password:E()})]).default({type:"IAM credentials",aws_access_key_id:"",aws_secret_access_key:"",region:""}),database:R()}).describe(l.of({direction:"two-columns"})),Qe=_({type:x("databricks"),access_token:X("Access Token",!0),server_hostname:I("Server Hostname"),http_path:ae("HTTP Path",!0),catalog:u().optional().describe(l.of({label:"Catalog"})),schema:u().optional().describe(l.of({label:"Schema"}))}).describe(l.of({direction:"two-columns"})),Je=_({type:x("supabase"),host:I(),port:O(5432).optional(),database:R(),username:T(),password:E(),disable_client_pooling:L().default(!1).describe(l.of({label:"Disable Client-Side Pooling"}))}).describe(l.of({direction:"two-columns"})),Ts=K("type",[Ie,Pe,qe,Fe,Ee,Oe,Be,Ue,Ke,He,We,Me,Ge,Ve,ze,Qe,Je]),Ye={sqlmodel:"SQLModel",sqlalchemy:"SQLAlchemy",duckdb:"DuckDB",clickhouse_connect:"ClickHouse Connect",chdb:"chDB",pyiceberg:"PyIceberg",ibis:"Ibis",motherduck:"MotherDuck",redshift:"Redshift",databricks:"Databricks"};var A=class{constructor(t,e,s){this.connection=t,this.orm=e,this.secrets=s}get imports(){let t=new Set(this.generateImports());switch(this.orm){case"sqlalchemy":t.add("import sqlalchemy");break;case"sqlmodel":t.add("import sqlmodel");break;case"duckdb":t.add("import duckdb");break;case"ibis":t.add("import ibis");break}return t}},Ls=t=>`_${t}`,Ds=class{constructor(){G(this,"secrets",{})}get imports(){return Object.keys(this.secrets).length===0?new Set:new Set(["import os"])}print(t,e,s){if(t=Ls(t),F(e)){let n=$e(e),r=s?`os.environ.get("${n}", "${s}")`:`os.environ.get("${n}")`;return this.secrets[t]=r,t}if(s!=null){let n=`os.environ.get("${e}", "${s}")`;return this.secrets[t]=n,t}return typeof e=="number"||typeof e=="number"?`${e}`:typeof e=="boolean"?H(e):e?`"${e}"`:""}printInFString(t,e,s){if(e===void 0)return"";if(typeof e=="number")return`${e}`;if(typeof e=="boolean")return H(e);let n=this.print(t,e,s);return n.startsWith('"')&&n.endsWith('"')?n.slice(1,-1):`{${n}}`}printPassword(t,e,s,n){let r=s?this.printInFString.bind(this):this.print.bind(this);return F(t)?r(n||"password",t):r(n||"password",e,t)}getSecrets(){return this.secrets}formatSecrets(){return Object.keys(this.secrets).length===0?"":Object.entries(this.secrets).map(([t,e])=>`${t} = ${e}`).join(`
|
|
2
2
|
`)}},Is=class extends A{generateImports(){return[]}generateConnectionCode(){let t=this.connection.ssl?", connect_args={'sslmode': 'require'}":"",e=this.secrets.printPassword(this.connection.password,"POSTGRES_PASSWORD",!0);return y(`
|
|
3
3
|
DATABASE_URL = f"postgresql://${this.secrets.printInFString("username",this.connection.username)}:${e}@${this.secrets.printInFString("host",this.connection.host)}:${this.secrets.printInFString("port",this.connection.port)}/${this.secrets.printInFString("database",this.connection.database)}"
|
|
4
4
|
engine = ${this.orm}.create_engine(DATABASE_URL${t})
|