@marimo-team/frontend 0.23.16-dev51 → 0.23.16-dev52
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-DciB5rbr.js → CellStatus-BT88_2jw.js} +1 -1
- package/dist/assets/{JsonOutput-BM3vve9F.js → JsonOutput-0XYUxjxO.js} +12 -12
- package/dist/assets/{MarimoErrorOutput-Bh0y53Du.js → MarimoErrorOutput-DuwnzR5D.js} +4 -4
- package/dist/assets/{RenderHTML-B9jx7Dsm.js → RenderHTML-BPdXbewN.js} +1 -1
- package/dist/assets/{RunButton-DMtHbFuA.js → RunButton-DJyvIhMO.js} +1 -1
- package/dist/assets/{add-cell-with-ai-BcRYriMM.js → add-cell-with-ai-Dspw1-mO.js} +12 -12
- package/dist/assets/add-connection-dialog-B1fFBVqJ.js +178 -0
- package/dist/assets/{agent-panel-B31W_VwU.js → agent-panel-iPdDqSEd.js} +4 -4
- package/dist/assets/{ai-model-dropdown-B3D05oQh.js → ai-model-dropdown-BC1SNLKb.js} +3 -3
- package/dist/assets/{app-config-button-D_mjovwU.js → app-config-button-CuE-bLFn.js} +1 -1
- package/dist/assets/{blob-BJREJiQp.js → blob-C23KHI9W.js} +1 -1
- package/dist/assets/{cell-editor-BOhZHoLm.js → cell-editor-D8UAfiUa.js} +11 -11
- package/dist/assets/cell-link-Bu5k33_H.js +1 -0
- package/dist/assets/{cells-Jr-5Pc9f.js → cells-C3V6s-g5.js} +53 -53
- package/dist/assets/{chat-display-Djy1Jt6b.js → chat-display-DSMFTDiK.js} +1 -1
- package/dist/assets/{chat-panel-B2nYSE_l.js → chat-panel-DuGaXa17.js} +4 -4
- package/dist/assets/{chat-ui-DlG0En7w.js → chat-ui-TD66NC03.js} +4 -4
- package/dist/assets/{column-preview-BUHlI5va.js → column-preview-Dqt5ygdi.js} +1 -1
- package/dist/assets/{command-palette-rEJmXCZM.js → command-palette-DgyUILpb.js} +1 -1
- package/dist/assets/{common-CZc3fQI4.js → common-CIJsW5yR.js} +1 -1
- package/dist/assets/{components-GAYCj6Mx.js → components-CniQJAsf.js} +1 -1
- package/dist/assets/{datasource-AWkkAeiS.js → datasource-YLl5kKpx.js} +2 -2
- package/dist/assets/{dependency-graph-panel-wcqTPq6b.js → dependency-graph-panel-MPHqARlX.js} +4 -4
- package/dist/assets/{documentation-panel-Eu8MIkoU.js → documentation-panel-DZnNktBv.js} +1 -1
- package/dist/assets/{download-CQ7iZFJL.js → download-CSWknseP.js} +2 -2
- package/dist/assets/{edit-page-Cw7nN6HC.js → edit-page-DVXg8Ibp.js} +6 -6
- package/dist/assets/error-entries-DIjVQBFa.js +8 -0
- package/dist/assets/{error-panel-BZzr0PA1.js → error-panel-CJSBDHOq.js} +1 -1
- package/dist/assets/{file-explorer-panel-C1W7g_Wp.js → file-explorer-panel-sHVZyshk.js} +4 -4
- package/dist/assets/{file-icons-BAqZR08W.js → file-icons-DDUQU--N.js} +1 -1
- package/dist/assets/{file-name-input-0MiZVw5r.js → file-name-input-CQjQP_zG.js} +1 -1
- package/dist/assets/{floating-outline-C6g75zrP.js → floating-outline-D1iQUiR_.js} +1 -1
- package/dist/assets/{focus-C0HXXg3V.js → focus-D_UTw9HF.js} +1 -1
- package/dist/assets/{form-C051zAev.js → form-B6jUSJBp.js} +1 -1
- package/dist/assets/{form-DT44Rmhp.js → form-Bp7lk3pm.js} +1 -1
- package/dist/assets/{home-page-CJz9IHZ2.js → home-page-CX6IV-hM.js} +2 -2
- package/dist/assets/{html-to-image-CfjhKLA4.js → html-to-image-kpOREGyr.js} +2 -2
- package/dist/assets/index-8Nlyq3mV.css +2 -0
- package/dist/assets/{index-CrEgp1mR.js → index-CrJhpWGp.js} +6 -6
- package/dist/assets/{layout-D4bpsgVD.js → layout-DdPE4xZU.js} +5 -5
- package/dist/assets/{logs-panel-CsaY3O1m.js → logs-panel-DnNiJzUQ.js} +1 -1
- package/dist/assets/{markdown-renderer-BgqeO4JR.js → markdown-renderer-CqljiwGm.js} +2 -2
- package/dist/assets/{name-cell-input-DcU8Rfrz.js → name-cell-input-BQzQI3Ja.js} +1 -1
- package/dist/assets/{outline-panel-D-CHPZQM.js → outline-panel-BIgVnAC7.js} +1 -1
- package/dist/assets/{packages-panel-dq7QVZl1.js → packages-panel-_HiSQVV7.js} +1 -1
- package/dist/assets/panels-b-OL36p2.js +4 -0
- package/dist/assets/{process-output-NbwnUu05.js → process-output-CJkR5qgD.js} +1 -1
- package/dist/assets/{radio-group-rhQpGwU-.js → radio-group-Dm-ZV-tP.js} +1 -1
- package/dist/assets/readonly-code-display-BiNt9i32.js +1 -0
- package/dist/assets/{readonly-python-code-Q_1Y3VyZ.js → readonly-python-code-DMKb3G0K.js} +1 -1
- package/dist/assets/{reveal-component-CedpDwM8.js → reveal-component-DN6-mIsb.js} +2 -2
- package/dist/assets/{run-page-CGoux5cj.js → run-page-BKCqJ0uJ.js} +1 -1
- package/dist/assets/scratchpad-panel-DwZEAfW1.js +1 -0
- package/dist/assets/{session-panel-OIot3eyB.js → session-panel-B-9BnZxS.js} +1 -1
- package/dist/assets/{skeleton-BRvjFlRu.js → skeleton-B72xXZAF.js} +1 -1
- package/dist/assets/{snippets-panel-YFyH2hUM.js → snippets-panel-Brc_pmTk.js} +1 -1
- package/dist/assets/{state-bHyw5u3R.js → state-BTAocii6.js} +1 -1
- package/dist/assets/state-D9oG57zx.js +3 -0
- package/dist/assets/{tracing-CDMM1BB2.js → tracing-Cn9cTT65.js} +1 -1
- package/dist/assets/{tracing-panel-BH5Zbvl9.js → tracing-panel-FWoe3_eY.js} +2 -2
- package/dist/assets/{tree-actions-DDveUIHK.js → tree-actions-rPl1v1gM.js} +1 -1
- package/dist/assets/useCellActionButton-Du3JXpNf.js +1 -0
- package/dist/assets/{useDeleteCell-BIopCngo.js → useDeleteCell-DHOwR-CG.js} +1 -1
- package/dist/assets/{useDependencyPanelTab-snM337f9.js → useDependencyPanelTab-B2PCtSi6.js} +1 -1
- package/dist/assets/{useNotebookActions-CsZfWFKy.js → useNotebookActions-DfQAtofT.js} +4 -4
- package/dist/assets/useRunCells-Dg11M4pT.js +1 -0
- package/dist/assets/{useSplitCell-BTmKY1CU.js → useSplitCell-BwWVHida.js} +1 -1
- package/dist/index.html +24 -24
- package/package.json +1 -1
- package/src/__mocks__/requests.ts +1 -0
- package/src/components/editor/connections/__tests__/quick-add-data-sources.test.tsx +113 -0
- package/src/components/editor/connections/add-connection-dialog.tsx +2 -0
- package/src/components/editor/connections/quick-add-data-sources.tsx +106 -0
- package/src/core/datasets/data-source-discovery.ts +5 -0
- package/src/core/datasets/request-registry.ts +11 -0
- package/src/core/islands/bootstrap.ts +1 -0
- package/src/core/islands/bridge.ts +1 -0
- package/src/core/kernel/messages.ts +2 -0
- package/src/core/network/__tests__/requests-lazy.test.ts +15 -0
- package/src/core/network/__tests__/requests-network.test.ts +14 -0
- package/src/core/network/requests-lazy.ts +1 -0
- package/src/core/network/requests-network.ts +8 -0
- package/src/core/network/requests-static.ts +1 -0
- package/src/core/network/requests-toasting.tsx +1 -0
- package/src/core/network/types.ts +2 -0
- package/src/core/wasm/bridge.ts +10 -0
- package/src/core/websocket/useMarimoKernelConnection.tsx +4 -0
- package/src/hooks/__tests__/useDataSourceDiscovery.test.ts +80 -0
- package/src/hooks/useDataSourceDiscovery.ts +18 -0
- package/dist/assets/add-connection-dialog-syjRSNPT.js +0 -178
- package/dist/assets/cell-link-DqNEv3f9.js +0 -1
- package/dist/assets/error-entries-Cr8uVukN.js +0 -8
- package/dist/assets/index-D6Dp_PFj.css +0 -2
- package/dist/assets/panels-DWoniKhE.js +0 -4
- package/dist/assets/readonly-code-display-CVY2f7EZ.js +0 -1
- package/dist/assets/scratchpad-panel-BLuF25yR.js +0 -1
- package/dist/assets/state-DB_fxbhn.js +0 -3
- package/dist/assets/useCellActionButton-D5ix_g2a.js +0 -1
- package/dist/assets/useRunCells-CF_V8X2K.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var fi=Object.defineProperty;var gi=(t,e,a)=>e in t?fi(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a;var L=(t,e,a)=>gi(t,typeof e!="symbol"?e+"":e,a);import{s as Ca,t as yi}from"./chunk-LvLJmgfZ.js";import{f as Lr,i as Zr,l as vi,n as St,o as xi,u as Fr}from"./useEvent-D91BmmQi.js";import{t as bi}from"./react-Bj1aDYRI.js";import{
|
|
1
|
+
var fi=Object.defineProperty;var gi=(t,e,a)=>e in t?fi(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a;var L=(t,e,a)=>gi(t,typeof e!="symbol"?e+"":e,a);import{s as Ca,t as yi}from"./chunk-LvLJmgfZ.js";import{f as Lr,i as Zr,l as vi,n as St,o as xi,u as Fr}from"./useEvent-D91BmmQi.js";import{t as bi}from"./react-Bj1aDYRI.js";import{Bn as _i,E as zr,Er as wi,Gi as ki,Ir as Ci,Li as Ii,Qi as Ti,Qt as Ei,Rr as Si,Si as Ai,Ui as Oi,Un as Ri,Wt as Ur,Zi as qr,cr as Ni,d as Mi,gi as ji,gt as Ia,kt as Pi,rt as Vr,wr as $i,y as qe,zr as Wr}from"./cells-C3V6s-g5.js";import{B as pe,D as Di,E as Br,H as Li,I as at,J as Kr,L as G,M as V,N as Jr,O as Zi,P as O,R as m,S as Fi,T as U,V as K,W as Yr,b as rt,k as w,w as we,x as Bt}from"./zod-H_cgTO0M.js";import{t as At}from"./compiler-runtime-B3qBwwSJ.js";import{T as zi,t as Ui}from"./ai-model-dropdown-BC1SNLKb.js";import{f as qi,g as oe}from"./useEventListener-C0195JsF.js";import{n as Vi}from"./utils-BWBBpCkT.js";import{o as Wi}from"./config-B-Q7J_6d.js";import{t as Ta}from"./cn-DYvqRARy.js";import{t as Bi}from"./jsx-runtime-Blw4afVn.js";import{d as Ki}from"./popover-Bcz1Zikb.js";import{a as Hr,c as Ji,p as Yi,r as Hi,t as Gi}from"./dropdown-menu-dHmZR8bI.js";import{t as Kt}from"./tooltip-4bZlU7jl.js";import{t as Ve}from"./button-DDGiD1NW.js";import{Gt as Qi,Qt as Jt,Tt as Yt,Wt as Xi,Zt as Ht,at as Ea,dt as Gr,en as eo,qt as Qr,st as Xr,ut as es,wt as to}from"./dist-12S8I4CH.js";import{t as ao}from"./createReducer-DGx5Af-C.js";import{h as ro,n as so,o as no,r as io}from"./dist-DYEuVkEX.js";import{i as oo}from"./strings--BknHX9C.js";import{r as lo,t as uo}from"./requests-9-v2bhoi.js";import{t as Sa}from"./createLucideIcon-w-Qo9n0R.js";import{r as co,t as po}from"./fileToBase64-Dgfa7TRQ.js";import{t as ts}from"./x-C-Eq0ag8.js";import{f as mo,n as as}from"./markdown-renderer-CqljiwGm.js";import{t as rs}from"./file-CJH9JNGH.js";import{t as ho}from"./image-5XI2VU-q.js";import{t as fo}from"./spinner-D-V4psAa.js";import{i as go,t as yo}from"./useDeleteCell-DHOwR-CG.js";import{r as vo}from"./input-JxFwu-3G.js";import{t as xo}from"./sparkles-DUCpRFlS.js";import{a as st,c as bo,i as gt,n as _o,o as Ot,s as Rt,t as wo}from"./datasource-YLl5kKpx.js";import{a as ko}from"./dist-DcwTQG1A.js";import{t as Co}from"./uuid-ImXS-885.js";import{t as Aa}from"./use-toast-BwJoaaDM.js";import{a as Io}from"./session-BmukRjSi.js";import{r as To}from"./useTheme-Bxv9B31g.js";import{n as Eo}from"./useRunCells-Dg11M4pT.js";import{n as So}from"./blob-C23KHI9W.js";import{a as Ao}from"./errors-PgHhDa-M.js";import{i as Oa}from"./cell-link-Bu5k33_H.js";import{r as Oo,t as Ro}from"./html-to-image-kpOREGyr.js";import{n as Ra}from"./renderShortcut-Bl8_FVn8.js";import{n as No}from"./icons-CIPE8AIY.js";import{r as Mo,t as jo}from"./esm-B30N1GS0.js";import{t as Po}from"./process-output-CJkR5qgD.js";import{i as $o,r as Do,t as Lo}from"./error-entries-DIjVQBFa.js";var ss=Sa("circle-stop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]),ns=Sa("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"}]]),is=Sa("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"}]]),os="vercel.ai.error",Zo=Symbol.for(os),ls,ds,xe=class ii extends(ds=Error,ls=Zo,ds){constructor({name:e,message:a,cause:r}){super(a),this[ls]=!0,this.name=e,this.cause=r}static isInstance(e){return ii.hasMarker(e,os)}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 us(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:JSON.stringify(t)}var cs="AI_InvalidArgumentError",ps=`vercel.ai.error.${cs}`,Fo=Symbol.for(ps),ms,hs,zo=class extends(hs=xe,ms=Fo,hs){constructor({message:t,cause:e,argument:a}){super({name:cs,message:t,cause:e}),this[ms]=!0,this.argument=a}static isInstance(t){return xe.hasMarker(t,ps)}},fs="AI_JSONParseError",gs=`vercel.ai.error.${fs}`,Uo=Symbol.for(gs),ys,vs,xs=class extends(vs=xe,ys=Uo,vs){constructor({text:t,cause:e}){super({name:fs,message:`JSON parsing failed: Text: ${t}.
|
|
2
2
|
Error message: ${us(e)}`,cause:e}),this[ys]=!0,this.text=t}static isInstance(t){return xe.hasMarker(t,gs)}},bs="AI_TypeValidationError",_s=`vercel.ai.error.${bs}`,qo=Symbol.for(_s),ws,ks,We=class Sr extends(ks=xe,ws=qo,ks){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:bs,message:`${s}: Value: ${JSON.stringify(e)}.
|
|
3
3
|
Error message: ${us(a)}`,cause:a}),this[ws]=!0,this.value=e,this.context=r}static isInstance(e){return xe.hasMarker(e,_s)}static wrap({value:e,cause:a,context:r}){var s,n,o;return Sr.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 Sr({value:e,cause:a,context:r})}},W;(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})(W||(W={}));var Vo;(function(t){t.mergeShapes=(e,a)=>({...e,...a})})(Vo||(Vo={}));const E=W.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Be=t=>{switch(typeof t){case"undefined":return E.undefined;case"string":return E.string;case"number":return Number.isNaN(t)?E.nan:E.number;case"boolean":return E.boolean;case"function":return E.function;case"bigint":return E.bigint;case"symbol":return E.symbol;case"object":return Array.isArray(t)?E.array:t===null?E.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?E.promise:typeof Map<"u"&&t instanceof Map?E.map:typeof Set<"u"&&t instanceof Set?E.set:typeof Date<"u"&&t instanceof Date?E.date:E.object;default:return E.unknown}},x=W.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 Oe=class oi 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 oi))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,W.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()}};Oe.create=t=>new Oe(t);var Nt=(t,e)=>{let a;switch(t.code){case x.invalid_type:a=t.received===E.undefined?"Required":`Expected ${t.expected}, received ${t.received}`;break;case x.invalid_literal:a=`Invalid literal value, expected ${JSON.stringify(t.expected,W.jsonStringifyReplacer)}`;break;case x.unrecognized_keys:a=`Unrecognized key(s) in object: ${W.joinValues(t.keys,", ")}`;break;case x.invalid_union:a="Invalid input";break;case x.invalid_union_discriminator:a=`Invalid discriminator value. Expected ${W.joinValues(t.options)}`;break;case x.invalid_enum_value:a=`Invalid enum value. Expected ${W.joinValues(t.options)}, received '${t.received}'`;break;case x.invalid_arguments:a="Invalid function arguments";break;case x.invalid_return_type:a="Invalid function return type";break;case x.invalid_date:a="Invalid date";break;case x.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}"`:W.assertNever(t.validation):a=t.validation==="regex"?"Invalid":`Invalid ${t.validation}`;break;case x.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 x.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 x.custom:a="Invalid input";break;case x.invalid_intersection_types:a="Intersection results could not be merged";break;case x.not_multiple_of:a=`Number must be a multiple of ${t.multipleOf}`;break;case x.not_finite:a="Number must be finite";break;default:a=e.defaultError,W.assertNever(t)}return{message:a}},Wo=Nt;function Na(){return Wo}const Ma=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 I(t,e){let a=Na(),r=Ma({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,a,a===Nt?void 0:Nt].filter(s=>!!s)});t.common.issues.push(r)}var ge=class li{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 li.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"}),ja=t=>({status:"dirty",value:t}),fe=t=>({status:"valid",value:t}),Cs=t=>t.status==="aborted",Is=t=>t.status==="dirty",yt=t=>t.status==="valid",Gt=t=>typeof Promise<"u"&&t instanceof Promise;var M;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(M||(M={}));var Re=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}},Ts=(t,e)=>{if(yt(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 Oe(t.common.issues)),this._error}}};function F(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 z=class{get description(){return this._def.description}_getType(t){return Be(t.data)}_getOrReturnCtx(t,e){return e||{common:t.parent.common,data:t.data,parsedType:Be(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new ge,ctx:{common:t.parent.common,data:t.data,parsedType:Be(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let e=this._parse(t);if(Gt(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:Be(t)};return Ts(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:Be(t)};if(!this["~standard"].async)try{let s=this._parseSync({data:t,path:[],parent:e});return yt(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=>yt(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:Be(t)},r=this._parse({data:t,path:a.path,parent:a});return Ts(a,await(Gt(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:x.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 $e({schema:this,typeName:_.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 De.create(this,this._def)}nullable(){return it.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return xt.create(this)}promise(){return Mt.create(this,this._def)}or(t){return ta.create([this,t],this._def)}and(t){return aa.create(this,t,this._def)}transform(t){return new $e({...F(this._def),schema:this,typeName:_.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let e=typeof t=="function"?t:()=>t;return new oa({...F(this._def),innerType:this,defaultValue:e,typeName:_.ZodDefault})}brand(){return new Rs({typeName:_.ZodBranded,type:this,...F(this._def)})}catch(t){let e=typeof t=="function"?t:()=>t;return new la({...F(this._def),innerType:this,catchValue:e,typeName:_.ZodCatch})}describe(t){let e=this.constructor;return new e({...this._def,description:t})}pipe(t){return Ns.create(this,t)}readonly(){return da.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Bo=/^c[^\s-]{8,}$/i,Ko=/^[0-9a-z]+$/,Jo=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Yo=/^[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,Ho=/^[a-z0-9_-]{21}$/i,Go=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Qo=/^[-+]?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)?)??$/,Xo=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,el="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Es,tl=/^(?:(?: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])$/,al=/^(?:(?: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])$/,rl=/^(([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]))$/,sl=/^(([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])$/,nl=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,il=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ss="((\\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])))",ol=RegExp(`^${Ss}$`);function As(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 ll(t){return RegExp(`^${As(t)}$`)}function dl(t){let e=`${Ss}T${As(t)}`,a=[];return a.push(t.local?"Z?":"Z"),t.offset&&a.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${a.join("|")})`,RegExp(`^${e}$`)}function ul(t,e){return!!((e==="v4"||!e)&&tl.test(t)||(e==="v6"||!e)&&rl.test(t))}function cl(t,e){if(!Go.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 pl(t,e){return!!((e==="v4"||!e)&&al.test(t)||(e==="v6"||!e)&&sl.test(t))}var Qt=class Wt extends z{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==E.string){let s=this._getOrReturnCtx(e);return I(s,{code:x.invalid_type,expected:E.string,received:s.parsedType}),D}let a=new ge,r;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(r=this._getOrReturnCtx(e,r),I(r,{code:x.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),I(r,{code:x.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?I(r,{code:x.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&I(r,{code:x.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),a.dirty())}else if(s.kind==="email")Xo.test(e.data)||(r=this._getOrReturnCtx(e,r),I(r,{validation:"email",code:x.invalid_string,message:s.message}),a.dirty());else if(s.kind==="emoji")Es||(Es=new RegExp(el,"u")),Es.test(e.data)||(r=this._getOrReturnCtx(e,r),I(r,{validation:"emoji",code:x.invalid_string,message:s.message}),a.dirty());else if(s.kind==="uuid")Yo.test(e.data)||(r=this._getOrReturnCtx(e,r),I(r,{validation:"uuid",code:x.invalid_string,message:s.message}),a.dirty());else if(s.kind==="nanoid")Ho.test(e.data)||(r=this._getOrReturnCtx(e,r),I(r,{validation:"nanoid",code:x.invalid_string,message:s.message}),a.dirty());else if(s.kind==="cuid")Bo.test(e.data)||(r=this._getOrReturnCtx(e,r),I(r,{validation:"cuid",code:x.invalid_string,message:s.message}),a.dirty());else if(s.kind==="cuid2")Ko.test(e.data)||(r=this._getOrReturnCtx(e,r),I(r,{validation:"cuid2",code:x.invalid_string,message:s.message}),a.dirty());else if(s.kind==="ulid")Jo.test(e.data)||(r=this._getOrReturnCtx(e,r),I(r,{validation:"ulid",code:x.invalid_string,message:s.message}),a.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),I(r,{validation:"url",code:x.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),I(r,{validation:"regex",code:x.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),I(r,{code:x.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),I(r,{code:x.invalid_string,validation:{startsWith:s.value},message:s.message}),a.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(r=this._getOrReturnCtx(e,r),I(r,{code:x.invalid_string,validation:{endsWith:s.value},message:s.message}),a.dirty()):s.kind==="datetime"?dl(s).test(e.data)||(r=this._getOrReturnCtx(e,r),I(r,{code:x.invalid_string,validation:"datetime",message:s.message}),a.dirty()):s.kind==="date"?ol.test(e.data)||(r=this._getOrReturnCtx(e,r),I(r,{code:x.invalid_string,validation:"date",message:s.message}),a.dirty()):s.kind==="time"?ll(s).test(e.data)||(r=this._getOrReturnCtx(e,r),I(r,{code:x.invalid_string,validation:"time",message:s.message}),a.dirty()):s.kind==="duration"?Qo.test(e.data)||(r=this._getOrReturnCtx(e,r),I(r,{validation:"duration",code:x.invalid_string,message:s.message}),a.dirty()):s.kind==="ip"?ul(e.data,s.version)||(r=this._getOrReturnCtx(e,r),I(r,{validation:"ip",code:x.invalid_string,message:s.message}),a.dirty()):s.kind==="jwt"?cl(e.data,s.alg)||(r=this._getOrReturnCtx(e,r),I(r,{validation:"jwt",code:x.invalid_string,message:s.message}),a.dirty()):s.kind==="cidr"?pl(e.data,s.version)||(r=this._getOrReturnCtx(e,r),I(r,{validation:"cidr",code:x.invalid_string,message:s.message}),a.dirty()):s.kind==="base64"?nl.test(e.data)||(r=this._getOrReturnCtx(e,r),I(r,{validation:"base64",code:x.invalid_string,message:s.message}),a.dirty()):s.kind==="base64url"?il.test(e.data)||(r=this._getOrReturnCtx(e,r),I(r,{validation:"base64url",code:x.invalid_string,message:s.message}),a.dirty()):W.assertNever(s);return{status:a.value,value:e.data}}_regex(e,a,r){return this.refinement(s=>e.test(s),{validation:a,code:x.invalid_string,...M.errToObj(r)})}_addCheck(e){return new Wt({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...M.errToObj(e)})}url(e){return this._addCheck({kind:"url",...M.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...M.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...M.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...M.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...M.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...M.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...M.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...M.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...M.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...M.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...M.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...M.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,...M.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,...M.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...M.errToObj(e)})}regex(e,a){return this._addCheck({kind:"regex",regex:e,...M.errToObj(a)})}includes(e,a){return this._addCheck({kind:"includes",value:e,position:a==null?void 0:a.position,...M.errToObj(a==null?void 0:a.message)})}startsWith(e,a){return this._addCheck({kind:"startsWith",value:e,...M.errToObj(a)})}endsWith(e,a){return this._addCheck({kind:"endsWith",value:e,...M.errToObj(a)})}min(e,a){return this._addCheck({kind:"min",value:e,...M.errToObj(a)})}max(e,a){return this._addCheck({kind:"max",value:e,...M.errToObj(a)})}length(e,a){return this._addCheck({kind:"length",value:e,...M.errToObj(a)})}nonempty(e){return this.min(1,M.errToObj(e))}trim(){return new Wt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Wt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Wt({...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}};Qt.create=t=>new Qt({checks:[],typeName:_.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...F(t)});function ml(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 Pa=class Ar extends z{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)!==E.number){let s=this._getOrReturnCtx(e);return I(s,{code:x.invalid_type,expected:E.number,received:s.parsedType}),D}let a,r=new ge;for(let s of this._def.checks)s.kind==="int"?W.isInteger(e.data)||(a=this._getOrReturnCtx(e,a),I(a,{code:x.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),I(a,{code:x.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),I(a,{code:x.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),r.dirty()):s.kind==="multipleOf"?ml(e.data,s.value)!==0&&(a=this._getOrReturnCtx(e,a),I(a,{code:x.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(a=this._getOrReturnCtx(e,a),I(a,{code:x.not_finite,message:s.message}),r.dirty()):W.assertNever(s);return{status:r.value,value:e.data}}gte(e,a){return this.setLimit("min",e,!0,M.toString(a))}gt(e,a){return this.setLimit("min",e,!1,M.toString(a))}lte(e,a){return this.setLimit("max",e,!0,M.toString(a))}lt(e,a){return this.setLimit("max",e,!1,M.toString(a))}setLimit(e,a,r,s){return new Ar({...this._def,checks:[...this._def.checks,{kind:e,value:a,inclusive:r,message:M.toString(s)}]})}_addCheck(e){return new Ar({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:M.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:M.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:M.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:M.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:M.toString(e)})}multipleOf(e,a){return this._addCheck({kind:"multipleOf",value:e,message:M.toString(a)})}finite(e){return this._addCheck({kind:"finite",message:M.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:-(2**53-1),message:M.toString(e)})._addCheck({kind:"max",inclusive:!0,value:2**53-1,message:M.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"&&W.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)}};Pa.create=t=>new Pa({checks:[],typeName:_.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...F(t)});var $a=class Or extends z{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)!==E.bigint)return this._getInvalidInput(e);let a,r=new ge;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),I(a,{code:x.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),I(a,{code:x.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),I(a,{code:x.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):W.assertNever(s);return{status:r.value,value:e.data}}_getInvalidInput(e){let a=this._getOrReturnCtx(e);return I(a,{code:x.invalid_type,expected:E.bigint,received:a.parsedType}),D}gte(e,a){return this.setLimit("min",e,!0,M.toString(a))}gt(e,a){return this.setLimit("min",e,!1,M.toString(a))}lte(e,a){return this.setLimit("max",e,!0,M.toString(a))}lt(e,a){return this.setLimit("max",e,!1,M.toString(a))}setLimit(e,a,r,s){return new Or({...this._def,checks:[...this._def.checks,{kind:e,value:a,inclusive:r,message:M.toString(s)}]})}_addCheck(e){return new Or({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:M.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:M.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:M.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:M.toString(e)})}multipleOf(e,a){return this._addCheck({kind:"multipleOf",value:e,message:M.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}};$a.create=t=>new $a({checks:[],typeName:_.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...F(t)});var Da=class extends z{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==E.boolean){let e=this._getOrReturnCtx(t);return I(e,{code:x.invalid_type,expected:E.boolean,received:e.parsedType}),D}return fe(t.data)}};Da.create=t=>new Da({typeName:_.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...F(t)});var La=class di extends z{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==E.date){let s=this._getOrReturnCtx(e);return I(s,{code:x.invalid_type,expected:E.date,received:s.parsedType}),D}if(Number.isNaN(e.data.getTime()))return I(this._getOrReturnCtx(e),{code:x.invalid_date}),D;let a=new ge,r;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(r=this._getOrReturnCtx(e,r),I(r,{code:x.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),I(r,{code:x.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),a.dirty()):W.assertNever(s);return{status:a.value,value:new Date(e.data.getTime())}}_addCheck(e){return new di({...this._def,checks:[...this._def.checks,e]})}min(e,a){return this._addCheck({kind:"min",value:e.getTime(),message:M.toString(a)})}max(e,a){return this._addCheck({kind:"max",value:e.getTime(),message:M.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)}};La.create=t=>new La({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:_.ZodDate,...F(t)});var Za=class extends z{_parse(t){if(this._getType(t)!==E.symbol){let e=this._getOrReturnCtx(t);return I(e,{code:x.invalid_type,expected:E.symbol,received:e.parsedType}),D}return fe(t.data)}};Za.create=t=>new Za({typeName:_.ZodSymbol,...F(t)});var Xt=class extends z{_parse(t){if(this._getType(t)!==E.undefined){let e=this._getOrReturnCtx(t);return I(e,{code:x.invalid_type,expected:E.undefined,received:e.parsedType}),D}return fe(t.data)}};Xt.create=t=>new Xt({typeName:_.ZodUndefined,...F(t)});var ea=class extends z{_parse(t){if(this._getType(t)!==E.null){let e=this._getOrReturnCtx(t);return I(e,{code:x.invalid_type,expected:E.null,received:e.parsedType}),D}return fe(t.data)}};ea.create=t=>new ea({typeName:_.ZodNull,...F(t)});var Fa=class extends z{constructor(){super(...arguments),this._any=!0}_parse(t){return fe(t.data)}};Fa.create=t=>new Fa({typeName:_.ZodAny,...F(t)});var vt=class extends z{constructor(){super(...arguments),this._unknown=!0}_parse(t){return fe(t.data)}};vt.create=t=>new vt({typeName:_.ZodUnknown,...F(t)});var Ke=class extends z{_parse(t){let e=this._getOrReturnCtx(t);return I(e,{code:x.invalid_type,expected:E.never,received:e.parsedType}),D}};Ke.create=t=>new Ke({typeName:_.ZodNever,...F(t)});var za=class extends z{_parse(t){if(this._getType(t)!==E.undefined){let e=this._getOrReturnCtx(t);return I(e,{code:x.invalid_type,expected:E.void,received:e.parsedType}),D}return fe(t.data)}};za.create=t=>new za({typeName:_.ZodVoid,...F(t)});var xt=class xa extends z{_parse(e){let{ctx:a,status:r}=this._processInputParams(e),s=this._def;if(a.parsedType!==E.array)return I(a,{code:x.invalid_type,expected:E.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)&&(I(a,{code:o?x.too_big:x.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&&(I(a,{code:x.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&&(I(a,{code:x.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 Re(a,o,a.path,i)))).then(o=>ge.mergeArray(r,o));let n=[...a.data].map((o,i)=>s.type._parseSync(new Re(a,o,a.path,i)));return ge.mergeArray(r,n)}get element(){return this._def.type}min(e,a){return new xa({...this._def,minLength:{value:e,message:M.toString(a)}})}max(e,a){return new xa({...this._def,maxLength:{value:e,message:M.toString(a)}})}length(e,a){return new xa({...this._def,exactLength:{value:e,message:M.toString(a)}})}nonempty(e){return this.min(1,e)}};xt.create=(t,e)=>new xt({type:t,minLength:null,maxLength:null,exactLength:null,typeName:_.ZodArray,...F(e)});function bt(t){if(t instanceof ke){let e={};for(let a in t.shape){let r=t.shape[a];e[a]=De.create(bt(r))}return new ke({...t._def,shape:()=>e})}else return t instanceof xt?new xt({...t._def,type:bt(t.element)}):t instanceof De?De.create(bt(t.unwrap())):t instanceof it?it.create(bt(t.unwrap())):t instanceof nt?nt.create(t.items.map(e=>bt(e))):t}var ke=class Se extends z{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:W.objectKeys(e)},this._cached}_parse(e){if(this._getType(e)!==E.object){let d=this._getOrReturnCtx(e);return I(d,{code:x.invalid_type,expected:E.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 Ke&&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 Re(r,u,r.path,d)),alwaysSet:d in r.data})}if(this._def.catchall instanceof Ke){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&&(I(r,{code:x.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 Re(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=>ge.mergeObjectSync(a,d)):ge.mergeObjectSync(a,i)}get shape(){return this._def.shape()}strict(e){return M.errToObj,new Se({...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:M.errToObj(e).message??s}:{message:s}}}})}strip(){return new Se({...this._def,unknownKeys:"strip"})}passthrough(){return new Se({...this._def,unknownKeys:"passthrough"})}extend(e){return new Se({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Se({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:_.ZodObject})}setKey(e,a){return this.augment({[e]:a})}catchall(e){return new Se({...this._def,catchall:e})}pick(e){let a={};for(let r of W.objectKeys(e))e[r]&&this.shape[r]&&(a[r]=this.shape[r]);return new Se({...this._def,shape:()=>a})}omit(e){let a={};for(let r of W.objectKeys(this.shape))e[r]||(a[r]=this.shape[r]);return new Se({...this._def,shape:()=>a})}deepPartial(){return bt(this)}partial(e){let a={};for(let r of W.objectKeys(this.shape)){let s=this.shape[r];e&&!e[r]?a[r]=s:a[r]=s.optional()}return new Se({...this._def,shape:()=>a})}required(e){let a={};for(let r of W.objectKeys(this.shape))if(e&&!e[r])a[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof De;)s=s._def.innerType;a[r]=s}return new Se({...this._def,shape:()=>a})}keyof(){return Os(W.objectKeys(this.shape))}};ke.create=(t,e)=>new ke({shape:()=>t,unknownKeys:"strip",catchall:Ke.create(),typeName:_.ZodObject,...F(e)}),ke.strictCreate=(t,e)=>new ke({shape:()=>t,unknownKeys:"strict",catchall:Ke.create(),typeName:_.ZodObject,...F(e)}),ke.lazycreate=(t,e)=>new ke({shape:t,unknownKeys:"strip",catchall:Ke.create(),typeName:_.ZodObject,...F(e)});var ta=class extends z{_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 Oe(o.ctx.common.issues));return I(e,{code:x.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 Oe(i));return I(e,{code:x.invalid_union,unionErrors:o}),D}}get options(){return this._def.options}};ta.create=(t,e)=>new ta({options:t,typeName:_.ZodUnion,...F(e)});var Je=t=>t instanceof ra?Je(t.schema):t instanceof $e?Je(t.innerType()):t instanceof sa?[t.value]:t instanceof na?t.options:t instanceof ia?W.objectValues(t.enum):t instanceof oa?Je(t._def.innerType):t instanceof Xt?[void 0]:t instanceof ea?[null]:t instanceof De?[void 0,...Je(t.unwrap())]:t instanceof it?[null,...Je(t.unwrap())]:t instanceof Rs||t instanceof da?Je(t.unwrap()):t instanceof la?Je(t._def.innerType):[],hl=class ui extends z{_parse(e){let{ctx:a}=this._processInputParams(e);if(a.parsedType!==E.object)return I(a,{code:x.invalid_type,expected:E.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}):(I(a,{code:x.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=Je(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 ui({typeName:_.ZodDiscriminatedUnion,discriminator:e,options:a,optionsMap:s,...F(r)})}};function Ua(t,e){let a=Be(t),r=Be(e);if(t===e)return{valid:!0,data:t};if(a===E.object&&r===E.object){let s=W.objectKeys(e),n=W.objectKeys(t).filter(i=>s.indexOf(i)!==-1),o={...t,...e};for(let i of n){let d=Ua(t[i],e[i]);if(!d.valid)return{valid:!1};o[i]=d.data}return{valid:!0,data:o}}else if(a===E.array&&r===E.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=Ua(o,i);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return a===E.date&&r===E.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var aa=class extends z{_parse(t){let{status:e,ctx:a}=this._processInputParams(t),r=(s,n)=>{if(Cs(s)||Cs(n))return D;let o=Ua(s.value,n.value);return o.valid?((Is(s)||Is(n))&&e.dirty(),{status:e.value,value:o.data}):(I(a,{code:x.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}))}};aa.create=(t,e,a)=>new aa({left:t,right:e,typeName:_.ZodIntersection,...F(a)});var nt=class ci extends z{_parse(e){let{status:a,ctx:r}=this._processInputParams(e);if(r.parsedType!==E.array)return I(r,{code:x.invalid_type,expected:E.array,received:r.parsedType}),D;if(r.data.length<this._def.items.length)return I(r,{code:x.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),D;!this._def.rest&&r.data.length>this._def.items.length&&(I(r,{code:x.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 Re(r,n,r.path,o)):null}).filter(n=>!!n);return r.common.async?Promise.all(s).then(n=>ge.mergeArray(a,n)):ge.mergeArray(a,s)}get items(){return this._def.items}rest(e){return new ci({...this._def,rest:e})}};nt.create=(t,e)=>{if(!Array.isArray(t))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new nt({items:t,typeName:_.ZodTuple,rest:null,...F(e)})};var fl=class Rr extends z{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!==E.object)return I(r,{code:x.invalid_type,expected:E.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 Re(r,i,r.path,i)),value:o._parse(new Re(r,r.data[i],r.path,i)),alwaysSet:i in r.data});return r.common.async?ge.mergeObjectAsync(a,s):ge.mergeObjectSync(a,s)}get element(){return this._def.valueType}static create(e,a,r){return a instanceof z?new Rr({keyType:e,valueType:a,typeName:_.ZodRecord,...F(r)}):new Rr({keyType:Qt.create(),valueType:e,typeName:_.ZodRecord,...F(a)})}},qa=class extends z{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!==E.map)return I(a,{code:x.invalid_type,expected:E.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 Re(a,o,a.path,[d,"key"])),value:s._parse(new Re(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}}}};qa.create=(t,e,a)=>new qa({valueType:e,keyType:t,typeName:_.ZodMap,...F(a)});var Va=class Nr extends z{_parse(e){let{status:a,ctx:r}=this._processInputParams(e);if(r.parsedType!==E.set)return I(r,{code:x.invalid_type,expected:E.set,received:r.parsedType}),D;let s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(I(r,{code:x.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&&(I(r,{code:x.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 Re(r,d,r.path,l)));return r.common.async?Promise.all(i).then(d=>o(d)):o(i)}min(e,a){return new Nr({...this._def,minSize:{value:e,message:M.toString(a)}})}max(e,a){return new Nr({...this._def,maxSize:{value:e,message:M.toString(a)}})}size(e,a){return this.min(e,a).max(e,a)}nonempty(e){return this.min(1,e)}};Va.create=(t,e)=>new Va({valueType:t,minSize:null,maxSize:null,typeName:_.ZodSet,...F(e)});var gl=class ba extends z{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:a}=this._processInputParams(e);if(a.parsedType!==E.function)return I(a,{code:x.invalid_type,expected:E.function,received:a.parsedType}),D;function r(i,d){return Ma({data:i,path:a.path,errorMaps:[a.common.contextualErrorMap,a.schemaErrorMap,Na(),Nt].filter(l=>!!l),issueData:{code:x.invalid_arguments,argumentsError:d}})}function s(i,d){return Ma({data:i,path:a.path,errorMaps:[a.common.contextualErrorMap,a.schemaErrorMap,Na(),Nt].filter(l=>!!l),issueData:{code:x.invalid_return_type,returnTypeError:d}})}let n={errorMap:a.common.contextualErrorMap},o=a.data;if(this._def.returns instanceof Mt){let i=this;return fe(async function(...d){let l=new Oe([]),u=await i._def.args.parseAsync(d,n).catch(h=>{throw l.addIssue(r(d,h)),l}),p=await Reflect.apply(o,this,u);return await i._def.returns._def.type.parseAsync(p,n).catch(h=>{throw l.addIssue(s(p,h)),l})})}else{let i=this;return fe(function(...d){let l=i._def.args.safeParse(d,n);if(!l.success)throw new Oe([r(d,l.error)]);let u=Reflect.apply(o,this,l.data),p=i._def.returns.safeParse(u,n);if(!p.success)throw new Oe([s(u,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ba({...this._def,args:nt.create(e).rest(vt.create())})}returns(e){return new ba({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,a,r){return new ba({args:e||nt.create([]).rest(vt.create()),returns:a||vt.create(),typeName:_.ZodFunction,...F(r)})}},ra=class extends z{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})}};ra.create=(t,e)=>new ra({getter:t,typeName:_.ZodLazy,...F(e)});var sa=class extends z{_parse(t){if(t.data!==this._def.value){let e=this._getOrReturnCtx(t);return I(e,{received:e.data,code:x.invalid_literal,expected:this._def.value}),D}return{status:"valid",value:t.data}}get value(){return this._def.value}};sa.create=(t,e)=>new sa({value:t,typeName:_.ZodLiteral,...F(e)});function Os(t,e){return new na({values:t,typeName:_.ZodEnum,...F(e)})}var na=class Mr extends z{_parse(e){if(typeof e.data!="string"){let a=this._getOrReturnCtx(e),r=this._def.values;return I(a,{expected:W.joinValues(r),received:a.parsedType,code:x.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 I(a,{received:a.data,code:x.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 Mr.create(e,{...this._def,...a})}exclude(e,a=this._def){return Mr.create(this.options.filter(r=>!e.includes(r)),{...this._def,...a})}};na.create=Os;var ia=class extends z{_parse(t){let e=W.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(t);if(a.parsedType!==E.string&&a.parsedType!==E.number){let r=W.objectValues(e);return I(a,{expected:W.joinValues(r),received:a.parsedType,code:x.invalid_type}),D}if(this._cache||(this._cache=new Set(W.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let r=W.objectValues(e);return I(a,{received:a.data,code:x.invalid_enum_value,options:r}),D}return fe(t.data)}get enum(){return this._def.values}};ia.create=(t,e)=>new ia({values:t,typeName:_.ZodNativeEnum,...F(e)});var Mt=class extends z{unwrap(){return this._def.type}_parse(t){let{ctx:e}=this._processInputParams(t);return e.parsedType!==E.promise&&e.common.async===!1?(I(e,{code:x.invalid_type,expected:E.promise,received:e.parsedType}),D):fe((e.parsedType===E.promise?e.data:Promise.resolve(e.data)).then(a=>this._def.type.parseAsync(a,{path:e.path,errorMap:e.common.contextualErrorMap})))}};Mt.create=(t,e)=>new Mt({type:t,typeName:_.ZodPromise,...F(e)});var $e=class extends z{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===_.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=>{I(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"?ja(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"?ja(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(!yt(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=>yt(n)?Promise.resolve(r.transform(n.value,s)).then(o=>({status:e.value,value:o})):D);W.assertNever(r)}};$e.create=(t,e,a)=>new $e({schema:t,typeName:_.ZodEffects,effect:e,...F(a)}),$e.createWithPreprocess=(t,e,a)=>new $e({schema:e,effect:{type:"preprocess",transform:t},typeName:_.ZodEffects,...F(a)});var De=class extends z{_parse(t){return this._getType(t)===E.undefined?fe(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};De.create=(t,e)=>new De({innerType:t,typeName:_.ZodOptional,...F(e)});var it=class extends z{_parse(t){return this._getType(t)===E.null?fe(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};it.create=(t,e)=>new it({innerType:t,typeName:_.ZodNullable,...F(e)});var oa=class extends z{_parse(t){let{ctx:e}=this._processInputParams(t),a=e.data;return e.parsedType===E.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:e.path,parent:e})}removeDefault(){return this._def.innerType}};oa.create=(t,e)=>new oa({innerType:t,typeName:_.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...F(e)});var la=class extends z{_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 Gt(r)?r.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Oe(a.common.issues)},input:a.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new Oe(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}};la.create=(t,e)=>new la({innerType:t,typeName:_.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...F(e)});var Wa=class extends z{_parse(t){if(this._getType(t)!==E.nan){let e=this._getOrReturnCtx(t);return I(e,{code:x.invalid_type,expected:E.nan,received:e.parsedType}),D}return{status:"valid",value:t.data}}};Wa.create=t=>new Wa({typeName:_.ZodNaN,...F(t)});var Rs=class extends z{_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}},Ns=class pi extends z{_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(),ja(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 pi({in:e,out:a,typeName:_.ZodPipeline})}},da=class extends z{_parse(t){let e=this._def.innerType._parse(t),a=r=>(yt(r)&&(r.value=Object.freeze(r.value)),r);return Gt(e)?e.then(r=>a(r)):a(e)}unwrap(){return this._def.innerType}};da.create=(t,e)=>new da({innerType:t,typeName:_.ZodReadonly,...F(e)}),ke.lazycreate;var _;(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"})(_||(_={})),Qt.create,Pa.create,Wa.create,$a.create,Da.create,La.create,Za.create,Xt.create,ea.create,Fa.create,vt.create,Ke.create,za.create,xt.create,ke.create,ke.strictCreate,ta.create,hl.create,aa.create,nt.create,fl.create,qa.create,Va.create,gl.create,ra.create,sa.create,na.create,ia.create,Mt.create,$e.create,De.create,it.create,$e.createWithPreprocess,Ns.create;var Ba=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}},Ms=10,yl=13,ot=32;function Ka(t){}function vl(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=Ka,onError:a=Ka,onRetry:r=Ka,onComment:s,maxBufferSize:n}=t,o=[],i=0,d=!0,l,u="",p=0,h,f=!1;function k(y){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,y.charCodeAt(0)===239&&y.charCodeAt(1)===187&&y.charCodeAt(2)===191&&(y=y.slice(3))),o.length===0){let j=b(y);j!==""&&(o.push(j),i=j.length),c();return}if(y.indexOf(`
|
|
4
4
|
`)===-1&&y.indexOf("\r")===-1){o.push(y),i+=y.length,c();return}o.push(y);let v=o.join("");o.length=0,i=0;let S=b(v);S!==""&&(o.push(S),i=S.length),c()}function c(){n!==void 0&&(i+u.length<=n||(f=!0,o.length=0,i=0,l=void 0,u="",p=0,h=void 0,a(new Ba(`Buffered data exceeded max buffer size of ${n} characters`,{type:"max-buffer-size-exceeded"}))))}function b(y){let v=0;if(y.indexOf("\r")===-1){let S=y.indexOf(`
|
|
@@ -22,22 +22,22 @@ ${n}
|
|
|
22
22
|
|
|
23
23
|
`;return a.outputType==="text"&&a.processedContent?i+=`Output:
|
|
24
24
|
${a.processedContent}`:a.outputType==="media"&&(i+=`Media Output: Contains ${a.output.mimetype} content`,a.imageUrl&&(i+=`
|
|
25
|
-
Image URL: ${a.imageUrl}`)),Ot({type:this.contextType,data:o,details:i})}async getAttachments(e){let a=e[0].data.cellId,r=e[0].data.cellName;return Lu(e.map(s=>s.data.cellOutput),a,r)}};async function Lu(t,e,a){let r=t.filter(n=>n.shouldDownloadImage&&n.outputType==="media");if(r.length===0)return[];let s=r.flatMap(n=>{let o=document.getElementById(
|
|
25
|
+
Image URL: ${a.imageUrl}`)),Ot({type:this.contextType,data:o,details:i})}async getAttachments(e){let a=e[0].data.cellId,r=e[0].data.cellName;return Lu(e.map(s=>s.data.cellOutput),a,r)}};async function Lu(t,e,a){let r=t.filter(n=>n.shouldDownloadImage&&n.outputType==="media");if(r.length===0)return[];let s=r.flatMap(n=>{let o=document.getElementById(Ti.create(e));return o?{cellId:e,cellName:a,mimetype:n.output.mimetype,element:o}:(oe.warn(`Output element not found for cell ${e}`),[])});try{return await Promise.all(s.map(async n=>({type:"file",filename:`${a}-output-screenshot`,mediaType:"image/png",url:await Ro(n.element)})))}catch(n){return oe.error("Error downloading cell output images:",n),[]}}function In(t){if(as(t))return null;let e=t.mimetype,a=$u(e,String(t.data))?"media":"text",r=Po(t),s,n=!1;return a==="media"&&(typeof t.data=="string"&&t.data.startsWith("data:")||typeof t.data=="string"&&t.data.startsWith("http")?s=t.data:n=!0),{processedContent:r,imageUrl:s,shouldDownloadImage:n,outputType:a,output:t}}function Tn(t,e,a){let{includeConsoleOutput:r=!1}=a||{},s=e.cellRuntime[t],n=e.cellData[t],o=e.cellIds.inOrderIds.indexOf(t),i=Pi(n.name,o),d;r&&(d=s.consoleOutputs.map(p=>In(p)).filter(p=>p!==null));let l,u=s.output;return u&&!as(u)&&(l=In(u)??void 0),{cellId:t,cellName:i,cellCode:n.code,cellOutput:l,consoleOutputs:d}}function Zu(t,e){let a=[`Code:
|
|
26
26
|
${t.cellCode}`];if(t.tracebackHtml&&a.push(`Traceback:
|
|
27
|
-
${
|
|
27
|
+
${Vr(t.tracebackHtml)}`),t.errorData.length>0&&a.push(t.errorData.map(r=>Do(r)).join(`
|
|
28
28
|
|
|
29
29
|
`)),t.errorData.some(r=>r.type==="sql-error")){let r=_o(t.cellId,e);r&&a.push(`Database schema:
|
|
30
30
|
${r}`)}return a.join(`
|
|
31
31
|
|
|
32
|
-
`)}function Fu(t,e){return Ot({type:"error",data:{name:t.cellName||`Cell ${t.cellId}`,cellId:t.cellId},details:Zu(t,e)})}function En(t){var e;return t.errorData.length===1?Lo(t.errorData[0]):t.errorData.length>1?`${t.errorData.length} errors`:t.tracebackHtml?((e=
|
|
33
|
-
`).find(a=>a.trim()))==null?void 0:e.trim())||"traceback":"error"}function zu(t){return`Error: ${t.cellName||`Cell ${t.cellId}`}`}var Sn=new
|
|
32
|
+
`)}function Fu(t,e){return Ot({type:"error",data:{name:t.cellName||`Cell ${t.cellId}`,cellId:t.cellId},details:Zu(t,e)})}function En(t){var e;return t.errorData.length===1?Lo(t.errorData[0]):t.errorData.length>1?`${t.errorData.length} errors`:t.tracebackHtml?((e=Vr(t.tracebackHtml).trim().split(`
|
|
33
|
+
`).find(a=>a.trim()))==null?void 0:e.trim())||"traceback":"error"}function zu(t){return`Error: ${t.cellName||`Cell ${t.cellId}`}`}var Sn=new Ni("error","errors"),Uu=class extends Rt{constructor(e){super();L(this,"title","Errors");L(this,"mentionPrefix","@");L(this,"contextType","error");this.store=e}getItems(){let e=$o(this.store);if(e.length===0)return[];let a=[{uri:this.asURI("all"),name:"Errors",type:this.contextType,data:{type:"all-errors",errors:e},description:"All errors in the notebook"}];for(let r of e)a.push({uri:this.asURI(r.cellId),name:zu(r),type:this.contextType,data:{type:"cell-error",error:r},description:En(r)});return a}formatCompletion(e){if(e.data.type==="all-errors"){let a=e.data.errors.length;return{label:"@Errors",displayLabel:"Errors",detail:`${a} ${Sn.pluralize(a)}`,type:"error",apply:"@error://all",section:st.ERROR,info:()=>{let r=document.createElement("div");r.classList.add("mo-cm-tooltip","docs-documentation","min-w-[200px]","flex","flex-col","gap-1","p-2");let s=document.createElement("div");s.classList.add("flex","flex-col","gap-1");let n=document.createElement("div");n.classList.add("font-bold","text-base"),n.textContent="Errors",s.append(n);let o=document.createElement("div");return o.classList.add("text-sm","text-muted-foreground"),o.textContent=`${a} ${Sn.pluralize(a)}`,s.append(o),r.append(s),r}}}if(e.data.type==="cell-error"){let{error:a}=e.data;return{...this.createBasicCompletion(e,{detail:En(a),type:"error"}),section:st.ERROR}}return{label:"Error",displayLabel:"Error",section:st.ERROR}}formatContext(e){return(e.data.type==="all-errors"?e.data.errors:[e.data.error]).map(a=>Fu(a,this.store)).join(`
|
|
34
34
|
|
|
35
|
-
`)}};const An=
|
|
35
|
+
`)}};const An=Ai();var qu={maxDepth:3,maxResults:20,defaultResultsLimit:5,includeDirectories:!1},Vu=class extends Rt{constructor(e,a=qu){super();L(this,"title","Files");L(this,"mentionPrefix","#");L(this,"contextType","file");L(this,"searchFiles",async(e,a={})=>{let{maxDepth:r,maxResults:s,includeDirectories:n}={...this.config,...a};return(await this.apiRequests.sendSearchFiles({query:e,includeFiles:!0,includeDirectories:n,depth:r,limit:s})).files});this.apiRequests=e,this.config=a}createCompletionSource(){return async e=>{let a=e.matchBefore(/#[^\s#]*/);if(!a)return null;let r=a.text;if(!r.startsWith("#"))return null;let s=r.slice(1);if(s.length===0)return this.getDefaultCompletions(a);try{let n=(await this.searchFiles(s)||[]).map(o=>{let i={uri:this.asURI(o.path),name:o.name,type:this.contextType,description:o.isDirectory?"Directory":"File",data:{path:o.path,isDirectory:o.isDirectory}};return this.formatCompletion(i)});return{from:a.from,options:n}}catch(n){return oe.error("Failed to search files:",n),null}}}async getDefaultCompletions(e){try{for(let a of["py","md","csv"])try{let r=await this.searchFiles(a,{maxDepth:1,maxResults:5});if(r&&r.length>0){let s=r.map(n=>{let o={uri:this.asURI(n.path),name:n.name,type:this.contextType,description:n.isDirectory?"Directory":"File",data:{path:n.path,isDirectory:n.isDirectory}};return this.formatCompletion(o)});return{from:e.from,options:s}}}catch(r){oe.error("Failed to get default file completions:",r)}return{from:e.from,options:[]}}catch(a){return oe.error("Failed to get default file completions:",a),null}}getItems(){return[]}formatCompletion(e){let{data:a,name:r}=e,s=a.isDirectory?"\u{1F4C1}":"\u{1F4C4}";return{...this.createBasicCompletion(e),type:"file",section:st.FILE,boost:a.isDirectory?gt.MEDIUM:gt.LOW,detail:a.path,displayLabel:`${s} ${r}`,apply:async(n,o,i,d)=>{var f;let l=(f=n.state.facet(An))==null?void 0:f.addAttachment;if(!l){oe.warn("No addAttachment callback provided");return}let u=await this.apiRequests.sendFileDetails({path:a.path}).catch(k=>(Aa({title:"Failed to get file details",description:k.message}),null));if(!u)return;let p=u.mimeType||"text/plain",h=So({contents:u.contents??"",mimeType:p,isBase64:u.isBase64??!1});l(new File([h],r,{type:p})),n.dispatch({changes:{from:i,to:d,insert:""}}),no(n)},info:()=>{let n=document.createElement("div");n.classList.add("flex","flex-col","gap-1","p-2");let o=document.createElement("div");o.classList.add("font-bold"),o.textContent=r,n.append(o);let i=document.createElement("div");return i.classList.add("text-xs","text-muted-foreground"),i.textContent=a.path,n.append(i),n}}}formatContext(e){let{data:a,name:r}=e;return Ot({type:this.contextType,data:{name:r,path:a.path,isDirectory:a.isDirectory},details:a.isDirectory?"Directory containing files and subdirectories":"File"})}},Wu=class extends Rt{constructor(e){super();L(this,"title","Tables");L(this,"mentionPrefix","@");L(this,"contextType","data");this.tablesMap=e}getItems(){return[...this.tablesMap.entries()].map(([e,a])=>({uri:this.asURI(e),name:e,type:this.contextType,description:a.source==="memory"?"in-memory":a.source,data:a}))}formatContext(e){let{data:a}=e,{columns:r,source:s,num_rows:n,num_columns:o,name:i,variable_name:d}=a,l=[n==null?void 0:`${n} rows`,o==null?void 0:`${o} columns`].filter(Boolean).join(", "),u="";if(l&&(u+=`Shape: ${l}
|
|
36
36
|
`),d&&(u+=`Variable: ${d}
|
|
37
37
|
`),r&&r.length>0){u+=`Columns:
|
|
38
38
|
`;for(let p of r){let h=` ${p.name} (${p.type})`;if(p.sample_values&&p.sample_values.length>0){let f=p.sample_values.slice(0,3).map(k=>k===null?"null":String(k)).join(", ");h+=` - samples: [${f}]`}u+=`${h}
|
|
39
|
-
`}}return Ot({type:this.contextType,data:{name:i,source:s??"unknown"},details:u.trim()})}formatCompletion(e){let a=e.data.name,r=e.data;return{label:`@${a}`,displayLabel:a,detail:r.source==="memory"?"in-memory":r.source,boost:r.source_type==="local"?gt.LOCAL_TABLE:gt.REMOTE_TABLE,type:
|
|
40
|
-
`,r);if(s===-1){let l=t.slice(r+3),u=l.indexOf(" "),p=u===-1?l:l.slice(0,u),h=p==="markdown"?"markdown":p==="sql"?"sql":"python",f=u===-1?"":l.slice(u+1);f.trim()&&e.push({language:h,code:f.trim()});break}let n=t.slice(r+3,s).trim()||"";n=n==="markdown"?"markdown":n==="sql"?"sql":"python";let o=s+1,i=t.indexOf("```",o);if(i===-1){let l=t.slice(o).replace(/\n+$/,"");l.trim()&&e.push({language:n,code:l});break}let d=t.slice(o,i).replace(/\n+$/,"");d.trim()&&e.push({language:n,code:d}),a=i+3,r=t.indexOf("```",a)}return e.length===0&&e.push({language:"python",code:t}),e}var rc=At(),Mn=()=>new Map,{valueAtom:Ut,useActions:jn,createActions:im,reducer:om}=ao(Mn,{addStagedCell:(t,e)=>{let{cellId:a,edit:r}=e;return new Map([...t,[a,r]])},removeStagedCell:(t,e)=>{let a=new Map(t);return a.delete(e),a},clearStagedCells:()=>Mn()});function Pn(t){let e=(0,rc.c)(27),{addStagedCell:a,removeStagedCell:r,clearStagedCells:s}=jn(),{createNewCell:n,updateCellCode:o}=zr(),i=yo(),d=(0,P.useRef)(null),l;e[0]!==a||e[1]!==n?(l=R=>{let y=
|
|
39
|
+
`}}return Ot({type:this.contextType,data:{name:i,source:s??"unknown"},details:u.trim()})}formatCompletion(e){let a=e.data.name,r=e.data;return{label:`@${a}`,displayLabel:a,detail:r.source==="memory"?"in-memory":r.source,boost:r.source_type==="local"?gt.LOCAL_TABLE:gt.REMOTE_TABLE,type:Wr(r),apply:`@${a}`,section:{name:Wr(r)==="dataframe"?"Dataframe":"Table",rank:st.TABLE.rank},info:()=>this.createTableInfoElement(a,r)}}createTableInfoElement(e,a){let r=document.createElement("div");r.classList.add("mo-cm-tooltip","docs-documentation","min-w-[200px]","flex","flex-col","gap-1","p-2");let s=document.createElement("div");s.classList.add("flex","flex-col","gap-1");let n=document.createElement("div");if(n.classList.add("font-bold","text-base"),n.textContent=e,s.append(n),a.source){let i=document.createElement("div");i.classList.add("text-xs","text-muted-foreground"),i.textContent=`Source: ${a.source}`,s.append(i)}r.append(s);let o=[a.num_rows==null?void 0:`${a.num_rows} rows`,a.num_columns==null?void 0:`${a.num_columns} columns`].filter(Boolean).join(", ");if(o){let i=document.createElement("div");i.classList.add("text-xs","bg-muted","px-2","py-1","rounded"),i.textContent=o,r.append(i)}if(a.columns&&a.columns.length>0){let i=document.createElement("div");i.classList.add("overflow-auto","max-h-60");let d=document.createElement("table");d.classList.add("w-full","text-xs","border-collapse");let l=d.insertRow();l.classList.add("bg-muted");let u=l.insertCell();u.classList.add("p-2","font-medium","text-left"),u.textContent="Column";let p=l.insertCell();p.classList.add("p-2","font-medium","text-left"),p.textContent="Type";let h=a.columns.some(k=>this.getItemMetadata(a,k)!==void 0),f;h&&(f=l.insertCell(),f.classList.add("p-2","font-medium","text-left"),f.textContent="Metadata"),a.columns.forEach((k,c)=>{let b=d.insertRow();b.classList.add(c%2==0?"bg-background":"bg-muted/30");let g=b.insertCell();g.classList.add("p-2","font-mono"),g.textContent=k.name;let A=b.insertCell();if(A.classList.add("p-2","text-muted-foreground"),A.textContent=k.type,h){let C=b.insertCell();C.classList.add("p-2");let R=this.getItemMetadata(a,k);R&&C.append(R)}}),i.append(d),r.append(i)}return r}getItemMetadata(e,a){var n,o;let r=(n=e.primary_keys)==null?void 0:n.includes(a.name),s=(o=e.indexes)==null?void 0:o.includes(a.name);if(r||s){let i=document.createElement("span");i.textContent=r?"PK":"IDX";let d=r?"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200":"bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-200";return i.classList.add("text-xs","px-1.5","py-0.5","rounded-full","font-medium",...d.split(" ")),i}}},Bu=class extends Rt{constructor(e,a){super();L(this,"title","Variables");L(this,"mentionPrefix","@");L(this,"contextType","variable");this.variables=e,this.tablesMap=a}getItems(){let e=new Set(this.tablesMap.keys());return Object.entries(this.variables).flatMap(([a,r])=>e.has(a)?[]:[{uri:this.asURI(a),name:a,type:this.contextType,description:r.dataType??"",dataType:r.dataType,data:{variable:r}}])}formatCompletion(e){let{data:a}=e,{variable:r}=a;return{label:`@${r.name}`,displayLabel:r.name,detail:r.dataType??"",type:this.contextType,section:st.VARIABLE,info:()=>Ei(r)}}formatContext(e){let{data:a}=e,{variable:r}=a;return Ot({type:this.contextType,data:{name:r.name,dataType:r.dataType},details:r.value==null?void 0:JSON.stringify(r.value)})}};function Ct(t){let e=t.get(Si),a=t.get(Ci),r=t.get(Ri);return new bo().register(new Wu(a)).register(new Bu(r,a)).register(new Uu(t)).register(new Du(t)).register(new wo(e.connectionsMap,a))}function Ku(){return new Vu(uo())}const Ju="@";function Yu({input:t}){let e="";return t.includes("@")&&(e=ec(t),oe.debug("Included context",e)),{includeOtherCode:Ur(""),context:{plainText:e,schema:[],variables:[]}}}var On={marimo:{source:"context"}};function Hu(t){var e,a;return t.type==="file"&&((a=(e=t.providerMetadata)==null?void 0:e.marimo)==null?void 0:a.source)===On.marimo.source}function Gu(t){var e;return{...t,providerMetadata:{...t.providerMetadata,marimo:{...(e=t.providerMetadata)==null?void 0:e.marimo,...On.marimo}}}}async function Rn(t){if(!t.includes("@"))return{plainText:"",contextIds:[],attachments:[]};let e=Ct(Zr),a=e.parseAllContextIds(t);if(a.length===0)return{plainText:"",contextIds:[],attachments:[]};let r=e.formatContextForAI(a),s=[];try{s=(await e.getAttachmentsForContext(a)).map(Gu)}catch(n){oe.error("Error getting attachments:",n)}return{plainText:r,contextIds:a,attachments:s}}async function Qu(t){let{plainText:e,contextIds:a,attachments:r}=await Rn(t),s=null;return e.trim()&&(s={type:"data-marimo-context",data:{plainText:e,contextIds:a.map(String)}}),{contextPart:s,attachments:r}}async function Xu({input:t}){let{plainText:e,attachments:a}=await Rn(t);return{body:{includeOtherCode:Ur(""),context:{plainText:e,schema:[],variables:[]}},attachments:a}}function ec(t){let e=Ct(Zr),a=e.parseAllContextIds(t);return e.formatContextForAI(a)}function tc(t,e=[]){return a=>{let r=t.map(s=>a.matchBefore(s)).find(Boolean);return!r||r&&r.from===r.to&&!a.explicit?null:{from:r==null?void 0:r.from,options:[...e]}}}function Nn(t){var e;if((e=t.current)!=null&&e.view){let a=t.current.view.state.selection.main.from;t.current.view.dispatch({changes:{from:a,to:a,insert:"@"},selection:{anchor:a+1,head:a+1}}),t.current.view.focus(),ro(t.current.view)}}function ac(t){if(t.trim().length===0)return[];if(!t.includes("```"))return[{language:"python",code:t}];let e=[],a=0,r=t.indexOf("```",a);for(;r!==-1;){let s=t.indexOf(`
|
|
40
|
+
`,r);if(s===-1){let l=t.slice(r+3),u=l.indexOf(" "),p=u===-1?l:l.slice(0,u),h=p==="markdown"?"markdown":p==="sql"?"sql":"python",f=u===-1?"":l.slice(u+1);f.trim()&&e.push({language:h,code:f.trim()});break}let n=t.slice(r+3,s).trim()||"";n=n==="markdown"?"markdown":n==="sql"?"sql":"python";let o=s+1,i=t.indexOf("```",o);if(i===-1){let l=t.slice(o).replace(/\n+$/,"");l.trim()&&e.push({language:n,code:l});break}let d=t.slice(o,i).replace(/\n+$/,"");d.trim()&&e.push({language:n,code:d}),a=i+3,r=t.indexOf("```",a)}return e.length===0&&e.push({language:"python",code:t}),e}var rc=At(),Mn=()=>new Map,{valueAtom:Ut,useActions:jn,createActions:im,reducer:om}=ao(Mn,{addStagedCell:(t,e)=>{let{cellId:a,edit:r}=e;return new Map([...t,[a,r]])},removeStagedCell:(t,e)=>{let a=new Map(t);return a.delete(e),a},clearStagedCells:()=>Mn()});function Pn(t){let e=(0,rc.c)(27),{addStagedCell:a,removeStagedCell:r,clearStagedCells:s}=jn(),{createNewCell:n,updateCellCode:o}=zr(),i=yo(),d=(0,P.useRef)(null),l;e[0]!==a||e[1]!==n?(l=R=>{let y=qr.create();return a({cellId:y,edit:{type:"add_cell"}}),n({cellId:"__end__",code:R,before:!1,newCellId:y}),y},e[0]=a,e[1]=n,e[2]=l):l=e[2];let u=l,p;e[3]!==t||e[4]!==o?(p=R=>{let{cellId:y,code:v}=R;if(!t.get(Ut).has(y)){oe.error("Staged cell not found",{cellId:y});return}let S=Mi(y);S?Ia(S,v):o({cellId:y,code:v,formattingChange:!1})},e[3]=t,e[4]=o,e[5]=p):p=e[5];let h=p,f;e[6]!==i||e[7]!==r?(f=R=>{r(R),i({cellId:R})},e[6]=i,e[7]=r,e[8]=f):f=e[8];let k=f,c;e[9]!==s||e[10]!==i||e[11]!==t?(c=()=>{let R=t.get(Ut);for(let y of R.keys())i({cellId:y});s()},e[9]=s,e[10]=i,e[11]=t,e[12]=c):c=e[12];let b=c,g;e[13]!==a||e[14]!==n||e[15]!==u||e[16]!==h?(g=R=>{e:switch(R.type){case"text-start":d.current=new sc(u,h,a,n);break e;case"text-delta":if(!d.current){oe.error("Cell creation stream not found");return}d.current.stream(R);break e;case"text-end":case"finish":if(!d.current){oe.error("Cell creation stream not found");return}d.current.stop();break e;case"abort":case"error":case"tool-input-error":case"tool-output-error":oe.error("Error",R.type,{chunk:R});break e;case"tool-approval-request":oe.log("Tool approval request",{chunk:R});break e;case"tool-output-denied":oe.error("Tool output denied",{chunk:R});break e;case"start":case"start-step":case"finish-step":case"data-reasoning-signature":break e;case"message-metadata":case"tool-input-available":case"tool-output-available":case"reasoning-start":case"reasoning-delta":case"reasoning-end":case"file":case"source-document":case"source-url":case"tool-input-start":case"tool-input-delta":oe.debug(R.type,{chunk:R});break e;default:if(nc(R)){oe.debug("Data chunk",{chunk:R});break e}oo(R)}},e[13]=a,e[14]=n,e[15]=u,e[16]=h,e[17]=g):g=e[17];let A=g,C;return e[18]!==a||e[19]!==s||e[20]!==u||e[21]!==b||e[22]!==k||e[23]!==A||e[24]!==r||e[25]!==h?(C={createStagedCell:u,updateStagedCell:h,addStagedCell:a,removeStagedCell:r,clearStagedCells:s,deleteStagedCell:k,deleteAllStagedCells:b,onStream:A},e[18]=a,e[19]=s,e[20]=u,e[21]=b,e[22]=k,e[23]=A,e[24]=r,e[25]=h,e[26]=C):C=e[26],C}var sc=class{constructor(t,e,a,r){L(this,"createdCells",[]);L(this,"buffer","");L(this,"hasMarimoImport",!1);this.onCreateCell=t,this.onUpdateCell=e,this.addStagedCell=a,this.createNewCell=r}stream(t){let e=t.delta;this.buffer+=e;let a=ac(this.buffer);for(let[r,s]of a.entries())if(r<this.createdCells.length){this.addMarimoImport(s.language);let n=this.createdCells[r];this.createdCells[r]={...n,cell:s},this.onUpdateCell({cellId:n.cellId,code:s.code,language:s.language})}else{let n=this.onCreateCell(s.code);this.createdCells.push({cellId:n,cell:s})}}addMarimoImport(t){var a;if(this.hasMarimoImport||t==="python")return;let e=Oo({autoInstantiate:!1,createNewCell:this.createNewCell,fromCellId:(a=this.createdCells[0])==null?void 0:a.cellId,before:!0});e&&this.addStagedCell({cellId:e,edit:{type:"add_cell"}}),this.hasMarimoImport=!0}stop(){this.buffer=""}};function nc(t){return t.type.startsWith("data-")}var ic={baseDescription:"Perform editing operations on the current notebook. You should prefer to create new cells unless you need to edit existing cells. Call this tool multiple times to perform multiple edits. Separate code into logical individual cells to take advantage of the notebook's reactive execution model.",prerequisites:["If you are updating existing cells, you need the cellIds. If they are not known, call the lightweight_cell_map_tool to find out."],additionalInfo:`
|
|
41
41
|
Args:
|
|
42
42
|
edit (object): The editing operation to perform with the following structure:
|
|
43
43
|
- type: One of "update_cell", "add_cell", or "delete_cell"
|
|
@@ -61,7 +61,7 @@ ${r}`)}return a.join(`
|
|
|
61
61
|
- SQL cells: use mo.sql(f"""{content}""") function to insert content. If a database engine is specified, use mo.sql(f"""{content}""", engine=engine) instead.
|
|
62
62
|
|
|
63
63
|
Returns:
|
|
64
|
-
- A result object containing standard tool metadata.`},oc=O({edit:O({type:rt(["update_cell","add_cell","delete_cell"]),code:m().optional(),position:O({type:rt(["relative","column_end","notebook_end"]).optional(),cellId:m().optional(),columnIndex:Jr().optional(),before:U().optional()})})}),lc=class{constructor(){L(this,"name","edit_notebook_tool");L(this,"description",ic);L(this,"schema",oc);L(this,"outputSchema",Cn);L(this,"mode",["agent"]);L(this,"handler",async({edit:t},e)=>{let{addStagedCell:a,createNewCell:r,store:s}=e;switch(t.type){case"update_cell":{let{position:n,code:o}=t,i=n.cellId;if(i){if(!o)throw new _e("Code is required for update_cell","CODE_REQUIRED_FOR_UPDATE_CELL",!0,"Provide the new code to update the cell")}else throw new _e("Cell ID is required for update_cell","CELL_ID_REQUIRED_FOR_UPDATE_CELL",!0,"Provide a cell ID to update");let d=s.get(qe);this.validateCellIdExists(i,d);let l=this.getCellEditorView(i,d);Oa(i);let u=s.get(Ut).get(i);if((u==null?void 0:u.type)==="add_cell"){Ia(l,o);break}let p=l.state.doc.toString(),h=(u==null?void 0:u.previousCode)??p;if(o===h)break;a({cellId:i,edit:{type:"update_cell",previousCode:h}}),Ia(l,o);break}case"add_cell":{let{position:n,code:o}=t,i="__end__",d=!1,l=
|
|
64
|
+
- A result object containing standard tool metadata.`},oc=O({edit:O({type:rt(["update_cell","add_cell","delete_cell"]),code:m().optional(),position:O({type:rt(["relative","column_end","notebook_end"]).optional(),cellId:m().optional(),columnIndex:Jr().optional(),before:U().optional()})})}),lc=class{constructor(){L(this,"name","edit_notebook_tool");L(this,"description",ic);L(this,"schema",oc);L(this,"outputSchema",Cn);L(this,"mode",["agent"]);L(this,"handler",async({edit:t},e)=>{let{addStagedCell:a,createNewCell:r,store:s}=e;switch(t.type){case"update_cell":{let{position:n,code:o}=t,i=n.cellId;if(i){if(!o)throw new _e("Code is required for update_cell","CODE_REQUIRED_FOR_UPDATE_CELL",!0,"Provide the new code to update the cell")}else throw new _e("Cell ID is required for update_cell","CELL_ID_REQUIRED_FOR_UPDATE_CELL",!0,"Provide a cell ID to update");let d=s.get(qe);this.validateCellIdExists(i,d);let l=this.getCellEditorView(i,d);Oa(i);let u=s.get(Ut).get(i);if((u==null?void 0:u.type)==="add_cell"){Ia(l,o);break}let p=l.state.doc.toString(),h=(u==null?void 0:u.previousCode)??p;if(o===h)break;a({cellId:i,edit:{type:"update_cell",previousCode:h}}),Ia(l,o);break}case"add_cell":{let{position:n,code:o}=t,i="__end__",d=!1,l=qr.create(),u=s.get(qe);switch(n.type){case"relative":{let p=n.cellId;if(!p)throw new _e("Cell ID is required for add_cell with relative position","TOOL_ERROR",!0,"Provide a cell ID to add the cell before");if(n.before===void 0)throw new _e("Before is required for add_cell with relative position","TOOL_ERROR",!0,`Provide a boolean value for before, true to add before cell ${p}, false to add after the cell`);this.validateCellIdExists(p,u),i=p,d=n.before;break}case"column_end":if(!n.columnIndex)throw new _e("Column index is required for add_cell with column_end position","TOOL_ERROR",!0,"Provide a column index to add the cell at the end of");i={type:"__end__",columnId:this.getColumnId(n.columnIndex,u)};break;case"notebook_end":break}r({cellId:i,before:d,code:o,newCellId:l}),a({cellId:l,edit:{type:"add_cell"}}),Oa(l);break}case"delete_cell":{let{position:n}=t,o=n.cellId;if(!o)throw new _e("Cell ID is required for delete_cell","CELL_ID_REQUIRED_FOR_DELETE_CELL",!0,"Provide a cell ID to delete");let i=s.get(qe);this.validateCellIdExists(o,i),a({cellId:o,edit:{type:"delete_cell",previousCode:this.getCellEditorView(o,i).state.doc.toString()}}),Oa(o);break}}return{status:"success",next_steps:["If you need to perform more edits, call this tool again.","You should use the lint notebook tool to check for errors and lint issues. Fix them by editing the notebook.","You should use the run stale cells tool to run the cells that have been edited or newly added. This allows you to see the output of the cells and fix any errors."]}})}validateCellIdExists(t,e){if(!e.cellIds.getColumns().some(a=>a.idSet.has(t)))throw new _e("Cell not found","CELL_NOT_FOUND",!1,"Check which cells exist in the notebook")}getColumnId(t,e){let a=e.cellIds.getColumns();if(t<0||t>=a.length)throw new _e("Column index is out of range","COLUMN_INDEX_OUT_OF_RANGE",!0,"Choose a column index between 0 and the number of columns in the notebook (0-based)");return a[t].id}getCellEditorView(t,e){let a=e.cellHandles[t].current;if(!(a!=null&&a.editorView))throw new _e("Cell editor not found","CELL_EDITOR_NOT_FOUND",!1,"Internal error, ask the user to report this error");return a.editorView}},dc=200,uc=3e4,$n=2e3,cc=3e3,pc=4e4,mc={baseDescription:"Run cells in the current notebook that are stale. Stale cells are cells that have been edited or newly added. You can run this tool after editing the notebook or when requested. The output of the ran cells will be returned alongside metadata."},Dn=O({type:w("file"),url:m(),mediaType:m()}),hc=class{constructor(t){L(this,"name","run_stale_cells_tool");L(this,"description",mc);L(this,"schema",O({}));L(this,"outputSchema",Cn.extend({cellsToOutput:at(m(),O({consoleOutput:m().optional(),cellOutput:m().optional(),consoleAttachments:we(Dn).optional(),cellAttachments:we(Dn).optional()}).nullable()).optional()}));L(this,"mode",["agent"]);L(this,"handler",async(t,e)=>{let{prepareForRun:a,sendRun:r,store:s}=e,n=s.get(qe),o=ji(n);if(o.length===0)return{status:"success",message:"No stale cells found."};if(await Eo({cellIds:o,sendRun:r,prepareForRun:a,notebook:n}),!await this.waitForCellsToFinish(s,o,uc,this.postExecutionDelay))return{status:"success",message:"No output was returned because some cells have not finished executing"};let i=s.get(qe),d=new Map,l=!1,u=!1,p=0;for(let f of o){let k=Tn(f,i,{includeConsoleOutput:!0}),c=k.cellOutput,b=k.consoleOutputs,g=b&&b.length>0;if((c&&this.outputHasErrors(c)||g&&b.some(R=>this.outputHasErrors(R)))&&(l=!0),!c&&!g){d.set(f,null);continue}if(p>=pc){d.set(f,{cellOutput:"Cell executed (output omitted due to context limits)."});continue}let A,C;c&&(A=this.formatOutputString(c),p+=A.length),g&&(u=!0,C=b.map(R=>this.formatOutputString(R)).join(`
|
|
65
65
|
`),C=this.truncateString(C,$n),p+=C.length),d.set(f,{cellOutput:A,consoleOutput:C})}if(d.size===0)return{status:"success",message:"Stale cells have been run. No output was returned."};let h=["Review the output of the cells. The CellId is the key of the result object.",l?"There are errors in the cells. Please fix them by using the edit notebook tool and the given CellIds.":"You may edit the notebook further with the given CellIds."];return{status:"success",cellsToOutput:Object.fromEntries(d),message:u?"Console output represents the stdout or stderr of the cell (eg. print statements).":void 0,next_steps:h}});this.postExecutionDelay=(t==null?void 0:t.postExecutionDelay)??dc}outputHasErrors(t){return t.output.mimetype==="application/vnd.marimo+error"||t.output.mimetype==="application/vnd.marimo+traceback"}formatOutputString(t){let{outputType:e,processedContent:a,imageUrl:r,output:s}=t;if(e==="media"){let i=`Media Output: Contains ${s.mimetype} content`;return r?`${i}
|
|
66
66
|
Image URL: ${r}`:i}if(s.mimetype==="text/html")return`HTML Output: text/html content (${(typeof s.data=="string"?s.data.length:JSON.stringify(s.data).length).toLocaleString()} chars). Full output visible in notebook UI.`;let n=this.outputHasErrors(t)?cc:$n,o=a;return o||(o=typeof s.data=="string"?s.data:JSON.stringify(s.data)),`Output:
|
|
67
67
|
${this.truncateString(o,n)}`}truncateString(t,e){return t.length<=e?t:`${t.slice(0,e)}
|
|
@@ -85,8 +85,8 @@ ${this.truncateString(o,n)}`}truncateString(t,e){return t.length<=e?t:`${t.slice
|
|
|
85
85
|
- `)}`),t.additionalInfo&&(e+=`
|
|
86
86
|
|
|
87
87
|
## Additional info:
|
|
88
|
-
- ${t.additionalInfo}`),e}var Ln,qt;function gc(t,e,a,r,s){var n={};return Object.keys(r).forEach(function(o){n[o]=r[o]}),n.enumerable=!!n.enumerable,n.configurable=!!n.configurable,("value"in n||n.initializer)&&(n.writable=!0),n=a.slice().reverse().reduce(function(o,i){return i(t,e,o)||o},n),s&&n.initializer!==void 0&&(n.value=n.initializer?n.initializer.call(s):void 0,n.initializer=void 0),n.initializer===void 0?(Object.defineProperty(t,e,n),null):n}const Tr=new(Ln=
|
|
89
|
-
`)}async function kc(t){let e=await Xu({input:wc(t.flatMap(r=>r.parts))});function a(r,s){return s?{...r,parts:[...r.parts,...e.attachments]}:r}return{...e.body,uiMessages:t.map((r,s)=>a(r,s===t.length-1))}}async function zn({invokeAiTool:t,addToolOutput:e,toolCall:a,toolContext:r}){try{if(Tr.has(a.toolName)){let s=await Tr.invoke({toolName:a.toolName,rawArgs:a.input,toolContext:r});e({tool:a.toolName,toolCallId:a.toolCallId,output:s.result||s.error})}else{let s=await t({toolName:a.toolName,arguments:a.input??{}});e({tool:a.toolName,toolCallId:a.toolCallId,output:s.result||s.error})}}catch(s){oe.error("Tool call failed:",s),e({tool:a.toolName,toolCallId:a.toolCallId,output:`Error: ${s instanceof Error?s.message:String(s)}`})}}function Cc(t){let e=t.at(-1);if(!e||e.role!=="assistant")return!1;let a=e.parts.at(-1);return!a||!Ge(a)?!1:tu({messages:t})||eu({messages:t})||a.state==="output-denied"&&!a.providerExecuted}function Ic(t){let e=t.at(-1);return!e||e.role!=="assistant"?!1:e.parts.some(a=>Ge(a)&&Tc(a.state))}function Tc(t){switch(t){case"approval-requested":case"input-streaming":case"input-available":return!0;case"approval-responded":case"output-available":case"output-error":case"output-denied":return!1;default:return t}}function Un(){let t=(0,yc.c)(7),e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0];let[a,r]=(0,P.useState)(e),s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=p=>{if(p.length!==0){if(p.reduce(Ec,0)>xc){Aa({title:"File size exceeded",description:"Attachments must be under 50 MB",variant:"danger"});return}r(h=>[...h,...p])}},t[1]=s):s=t[1];let n=St(s),o;t[2]===Symbol.for("react.memo_cache_sentinel")?(o=()=>r([]),t[2]=o):o=t[2];let i=o,d;t[3]===Symbol.for("react.memo_cache_sentinel")?(d=p=>r(h=>h.filter(f=>f!==p)),t[3]=d):d=t[3];let l=d,u;return t[4]!==n||t[5]!==a?(u={files:a,addFiles:n,clearFiles:i,removeFile:l},t[4]=n,t[5]=a,t[6]=u):u=t[6],u}function Ec(t,e){return t+e.size}function Sc(t){return t.isError?!1:t.isAbort?!0:!t.hasPendingToolCalls&&!t.hasUnresolvedToolCalls}function Ac(){let[t,e]=(0,P.useState)([]),a=(0,P.useRef)([]),r=(0,P.useRef)(!1);return a.current=t,r.current=t.length>0,{messages:t,enqueue:St(s=>{e(n=>{let o=[...n,{id:Co(),parts:s}];return a.current=o,r.current=!0,o})}),flushNext:St(s=>{let n=a.current;if(n.length===0)return;let[o,...i]=n;a.current=i,r.current=i.length>0,e(i),s(o.parts)}),clear:St(()=>{a.current=[],r.current=!1,e([])}),hasQueuedRef:r}}var It=At(),T=Ca(Bi(),1);const Oc=t=>{var o;let e=(0,It.c)(6),{attachment:a}=t;if((o=a.mediaType)!=null&&o.startsWith("image/")){let i=a.filename||"Attachment",d;return e[0]!==a.url||e[1]!==i?(d=(0,T.jsx)("img",{src:a.url,alt:i,className:"max-h-[100px] max-w-[100px] object-contain mb-1.5"}),e[0]=a.url,e[1]=i,e[2]=d):d=e[2],d}let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,T.jsx)(rs,{className:"h-3 w-3 mt-0.5"}),e[3]=r):r=e[3];let s=a.filename||"Attachment",n;return e[4]===s?n=e[5]:(n=(0,T.jsxs)("div",{className:"flex flex-row gap-1 items-center text-xs",children:[r,s]}),e[4]=s,e[5]=n),n},qn=t=>{let e=(0,It.c)(12),{file:a,className:r,onRemove:s}=t,[n,o]=(0,P.useState)(!1),i;e[0]===r?i=e[1]:(i=Ta("py-1 px-1.5 bg-muted rounded-md cursor-pointer flex flex-row gap-1 items-center text-xs",r),e[0]=r,e[1]=i);let d,l;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>o(!0),l=()=>o(!1),e[2]=d,e[3]=l):(d=e[2],l=e[3]);let u;e[4]!==a||e[5]!==n||e[6]!==s?(u=n?(0,T.jsx)(ts,{className:"h-3 w-3 mt-0.5",onClick:s}):Rc(a),e[4]=a,e[5]=n,e[6]=s,e[7]=u):u=e[7];let p;return e[8]!==a.name||e[9]!==i||e[10]!==u?(p=(0,T.jsxs)("div",{className:i,onMouseEnter:d,onMouseLeave:l,children:[u,a.name]}),e[8]=a.name,e[9]=i,e[10]=u,e[11]=p):p=e[11],p},Vn=t=>{let e=(0,It.c)(12),{isLoading:a,onStop:r,onSendClick:s,isEmpty:n,showStopLabel:o}=t,i=o===void 0?!1:o,d;e[0]===i?d=e[1]:(d=i?(0,T.jsxs)("div",{className:"flex flex-row items-center gap-1 px-1.5",children:[(0,T.jsx)("span",{className:"text-xs text-error",children:"Stop"}),(0,T.jsx)(fo,{size:"small"})]}):(0,T.jsx)(ss,{className:"size-4 text-error"}),e[0]=i,e[1]=d);let l=d,u=a?"Stop":"Submit",p=a?r:s,h=a?!1:n,f;e[2]!==a||e[3]!==l?(f=a?l:(0,T.jsx)(is,{className:"h-3.5 w-3.5"}),e[2]=a,e[3]=l,e[4]=f):f=e[4];let k;e[5]!==p||e[6]!==h||e[7]!==f?(k=(0,T.jsx)(Ve,{variant:"text",size:"sm",className:"h-6 min-w-6 p-0 hover:bg-muted/30 cursor-pointer",onClick:p,disabled:h,children:f}),e[5]=p,e[6]=h,e[7]=f,e[8]=k):k=e[8];let c;return e[9]!==u||e[10]!==k?(c=(0,T.jsx)(Kt,{content:u,children:k}),e[9]=u,e[10]=k,e[11]=c):c=e[11],c},Wn=t=>{let e=(0,It.c)(4),{handleAddContext:a,isLoading:r}=t,s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,T.jsx)(co,{className:"h-3.5 w-3.5"}),e[0]=s):s=e[0];let n;return e[1]!==a||e[2]!==r?(n=(0,T.jsx)(Kt,{content:"Add context",children:(0,T.jsx)(Ve,{variant:"text",size:"icon",onClick:a,disabled:r,children:s})}),e[1]=a,e[2]=r,e[3]=n):n=e[3],n},Bn=t=>{let e=(0,It.c)(15),{fileInputRef:a,isLoading:r,onAddFiles:s}=t,n;e[0]===a?n=e[1]:(n=()=>{var h;return(h=a.current)==null?void 0:h.click()},e[0]=a,e[1]=n);let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=(0,T.jsx)(ns,{className:"h-3.5 w-3.5"}),e[2]=o):o=e[2];let i;e[3]!==r||e[4]!==n?(i=(0,T.jsx)(Kt,{content:"Attach a file",children:(0,T.jsx)(Ve,{variant:"text",size:"icon",onClick:n,disabled:r,children:o})}),e[3]=r,e[4]=n,e[5]=i):i=e[5];let d;e[6]===s?d=e[7]:(d=h=>{h.target.files&&s([...h.target.files])},e[6]=s,e[7]=d);let l;e[8]===Symbol.for("react.memo_cache_sentinel")?(l=vc.join(","),e[8]=l):l=e[8];let u;e[9]!==a||e[10]!==d?(u=(0,T.jsx)(vo,{ref:a,type:"file",multiple:!0,hidden:!0,onChange:d,accept:l}),e[9]=a,e[10]=d,e[11]=u):u=e[11];let p;return e[12]!==i||e[13]!==u?(p=(0,T.jsxs)(T.Fragment,{children:[i,u]}),e[12]=i,e[13]=u,e[14]=p):p=e[14],p};function Rc(t){let e="h-3 w-3 mt-0.5";return t.type.startsWith("image/")?(0,T.jsx)(ho,{className:e}):t.type.startsWith("text/")?(0,T.jsx)(_i,{className:e}):(0,T.jsx)(rs,{className:e})}const Nc=t=>{let e=(0,It.c)(15),{icon:a,title:r,subtitle:s,href:n}=t,o;e[0]===r?o=e[1]:(o=(0,T.jsx)("span",{className:"truncate font-medium",children:r}),e[0]=r,e[1]=o);let i;e[2]===s?i=e[3]:(i=s&&(0,T.jsxs)("span",{className:"truncate opacity-70",children:["(",s,")"]}),e[2]=s,e[3]=i);let d;e[4]!==a||e[5]!==o||e[6]!==i?(d=(0,T.jsxs)(T.Fragment,{children:[a,o,i]}),e[4]=a,e[5]=o,e[6]=i,e[7]=d):d=e[7];let l=d;if(n&&Io(n)){let h=s??r,f;return e[8]!==l||e[9]!==n||e[10]!==h?(f=(0,T.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",title:h,className:"inline-flex max-w-full items-center gap-1.5 rounded-md border bg-muted/50 px-2 py-1 my-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground transition-colors",children:l}),e[8]=l,e[9]=n,e[10]=h,e[11]=f):f=e[11],f}let u=s??r,p;return e[12]!==l||e[13]!==u?(p=(0,T.jsx)("div",{className:"inline-flex max-w-full items-center gap-1.5 rounded-md border bg-muted/50 px-2 py-1 my-1 text-xs text-muted-foreground",title:u,children:l}),e[12]=l,e[13]=u,e[14]=p):p=e[14],p},va=Ht.define(),Ee=Jt.define({create(){return new Map},update(t,e){let a=!1,r=t;for(let s of e.effects)if(s.is(va)){a||(a=(r=new Map(t),!0));for(let[n,o]of s.value)r.set(n,o)}return r}}),Mc=Jt.define({create(){return{onResourceClick:void 0,onResourceMouseOver:void 0,onResourceMouseOut:void 0,onPromptSubmit:void 0}},update(t){return t}}),jc=Ht.define();Jt.define({create(){return new Map},update(t,e){let a=!1,r=t;for(let s of e.effects)if(s.is(jc)){a||(a=(r=new Map(t),!0));for(let[n,o]of s.value)r.set(n,o)}return r}});const Pc=(t,e)=>async a=>{let r=a.matchBefore(/@(\w+)?/);if(!r||r.from===r.to&&!a.explicit)return null;let s=await t();if(s.length===0)return null;let n=va.of(new Map(s.map(i=>[i.uri,i])));a.view&&a.view.dispatch({effects:n});let o=s.map(i=>({label:`@${i.name}`,displayLabel:i.name,detail:i.uri,info:i.description||void 0,type:i.mimeType?"constant":"variable",boost:i.description?100:0,...e==null?void 0:e(i),apply:(d,l,u,p)=>{d.dispatch({changes:{from:u,to:p,insert:`@${i.uri} `}})}}));return{from:r.from,options:o}},$c=/@[\w-]+:\/\/(?!\/)[^\s]+/;function Me(t){return t.matchAll(new RegExp($c.source,"g"))}var Dc=class extends Gr{constructor(e,a){super();L(this,"resource");L(this,"view");this.resource=e,this.view=a}eq(e){return e.resource.uri===this.resource.uri}toDOM(){let e=document.createElement("span");e.className="cm-resource-widget",e.textContent=`@${this.resource.name}`;let a=this.view.state.field(Mc,!1),r=a==null?void 0:a.onResourceClick,s=a==null?void 0:a.onResourceMouseOver,n=a==null?void 0:a.onResourceMouseOut;return r&&(e.style.cursor="pointer",e.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation(),r(this.resource)})),s&&e.addEventListener("mouseover",o=>{o.preventDefault(),o.stopPropagation(),s(this.resource)}),n&&e.addEventListener("mouseout",o=>{o.preventDefault(),o.stopPropagation(),n(this.resource)}),e}},Lc=class extends Gr{constructor(e,a){super();L(this,"uri");L(this,"view");this.uri=e,this.view=a}eq(e){return e.uri===this.uri}toDOM(){let e=document.createElement("span");return e.className="cm-not-found-resource-widget",e.textContent=`@${this.uri.split("://")[1]??this.uri}`,e}};function Kn(t){let e=t.state.field(Ee),a=[];for(let{from:r,to:s}of t.visibleRanges){let n=t.state.doc.sliceString(r,s);for(let o of Me(n)){let i=r+o.index,d=o[0].slice(1),l=e.get(d);l?a.push(Ea.replace({widget:new Dc(l,t)}).range(i,i+o[0].length)):a.push(Ea.replace({widget:new Lc(d,t)}).range(i,i+o[0].length))}}return Ea.set(a)}const Zc=es.fromClass(class{constructor(t){L(this,"decorations");this.decorations=Kn(t)}update(t){(t.docChanged||t.viewportChanged||t.transactions.some(e=>e.effects.some(a=>a.is(va))))&&(this.decorations=Kn(t.view))}},{decorations:t=>t.decorations});function Fc(t){let e=document.createElement("div");e.className="cm-tooltip-cursor";let a=document.createElement("div");if(a.className="cm-tooltip-cursor-title",a.textContent=`${t.name} (${t.uri})`,e.appendChild(a),t.description){let r=document.createElement("div");r.className="cm-tooltip-cursor-description",r.textContent=t.description,e.appendChild(r)}if(t.mimeType){let r=document.createElement("div");r.className="cm-tooltip-cursor-mimetype",r.textContent=t.mimeType,e.appendChild(r)}return{dom:e}}function zc(t,e,a,r=0){for(let s of Me(t)){let n=r+s.index,o=n+s[0].length;if(e>=n&&e<=o){let i=s[0].slice(1),d=a.get(i);if(d)return{resource:d,start:n,end:o}}}return null}function Uc(t){return to((e,a)=>{let{from:r,text:s}=e.state.doc.lineAt(a),n=zc(s,a,e.state.field(Ee),r);return n?{pos:n.start,end:n.end,above:!0,create(){return(t.createTooltip??Fc)(n.resource)}}:null})}function qc(t,e){let a=t.field(Ee),r=t.doc,s=r.lineAt(e),n=r.sliceString(s.from,s.to),o=Array.from(Me(n));if(o.length===0)return null;for(let i of o){let d=s.from+i.index,l=d+i[0].length,u=i[0].slice(1);if(e===l&&a.has(u))return{from:d,to:l,uri:u}}return null}function Vc(t,e){let a=t.field(Ee),r=t.doc,s=r.lineAt(e).to,n=r.sliceString(e,s),o=Array.from(Me(n));if(o.length===0)return null;let i=o[0];if(!i||i.index!==0)return null;let d=e,l=e+i[0].length,u=i[0].slice(1);return a.has(u)?{from:d,to:l,uri:u}:null}function Jn(t,e){let a=t.field(Ee),r=t.doc,s=r.lineAt(e),n=r.sliceString(s.from,s.to),o=Array.from(Me(n));for(let i of o){let d=s.from+i.index,l=d+i[0].length,u=i[0].slice(1);if(e>d&&e<l&&a.has(u))return{from:d,to:l,uri:u}}return null}function Wc(t,e){let a=t.field(Ee),r=t.doc,s=r.lineAt(e),n=r.sliceString(s.from,e),o=Array.from(Me(n)),i=null;for(let d of o){let l=s.from+d.index,u=l+d[0].length,p=d[0].slice(1);a.has(p)&&u<=e&&(e>u?i=u:e===u&&(i=l))}return i}function Bc(t,e){let a=t.field(Ee),r=t.doc,s=r.lineAt(e),n=r.sliceString(s.from,s.to),o=Array.from(Me(n));for(let i of o){let d=s.from+i.index,l=d+i[0].length,u=i[0].slice(1);if(a.has(u)&&d>=e){if(e<d)return d;if(e===d)return l}}return null}const Kc=Xi.transactionFilter.of(t=>{var r;let e=t.annotation(eo.userEvent);if(!e)return t;let a=t.startState.selection.main;if(!a.empty)return t;if(e==="input.type"||e.startsWith("input")){if(t.changes.empty)return t;let s=t.startState.field(Ee),n=t.startState.doc,o=!1,i=0,d=[];if(t.changes.iterChanges((l,u,p,h,f)=>{let k=f.toString(),c=l;if(/^\s+$/.test(k)){d.push({from:l,to:u,insert:k});return}let b=n.lineAt(c),g=n.sliceString(b.from,b.to),A=Array.from(Me(g)),C=!1,R=!1;for(let v of A){let S=b.from+v.index,j=S+v[0].length,Z=v[0].slice(1);if(s.has(Z)){if(c===S){let $=c>0?n.sliceString(c-1,c):"";$!==""&&$!==" "&&$!==`
|
|
88
|
+
- ${t.additionalInfo}`),e}var Ln,qt;function gc(t,e,a,r,s){var n={};return Object.keys(r).forEach(function(o){n[o]=r[o]}),n.enumerable=!!n.enumerable,n.configurable=!!n.configurable,("value"in n||n.initializer)&&(n.writable=!0),n=a.slice().reverse().reduce(function(o,i){return i(t,e,o)||o},n),s&&n.initializer!==void 0&&(n.value=n.initializer?n.initializer.call(s):void 0,n.initializer=void 0),n.initializer===void 0?(Object.defineProperty(t,e,n),null):n}const Tr=new(Ln=Oi(),qt=class{constructor(t=[]){L(this,"tools",new Map);this.tools=new Map(t.map(e=>[e.name,e]))}has(t){return this.tools.has(t)}getToolOrThrow(t){let e=this.tools.get(t);if(!e)throw Error(`Tool ${t} not found`);return e}async invoke({toolName:t,rawArgs:e,toolContext:a}){var i;let r=this.getToolOrThrow(t),s=r.handler,n=r.schema,o=r.outputSchema;try{let d=await n.safeParseAsync(e);if(d.error)throw new _e(`Tool ${t} returned invalid input: ${Kr(d.error)}`,"INVALID_ARGUMENTS",!0,"Please check the arguments and try again.");let l=d.data,u=await s(l,a),p=await o.safeParseAsync(u);if(p.error){let h=Kr(p.error);throw Error(`Tool ${t} returned invalid output: ${h}`)}return{tool_name:t,result:p.data,error:null}}catch(d){return d instanceof _e?{tool_name:t,result:null,error:d.toStructuredString()}:{tool_name:t,result:null,error:new _e(d instanceof Error?d.message:String(d),"TOOL_ERROR",!1,"Check the error message and try again with valid arguments.",{args:e,errorType:((i=d==null?void 0:d.constructor)==null?void 0:i.name)??typeof d}).toStructuredString()}}}getToolSchemas(t){return[...this.tools.values()].filter(e=>e.mode.includes(t)).map(e=>({name:e.name,description:fc(e.description),parameters:Yr(e.schema),source:"frontend",mode:e.mode}))}},gc(qt.prototype,"getToolSchemas",[Ln],Object.getOwnPropertyDescriptor(qt.prototype,"getToolSchemas"),qt.prototype),qt)([new lc,new hc]);var yc=At();const Zn=new Set(["openai","google","anthropic"]),vc=["image/*","text/*"];var xc=1024*1024*50;function bc(t){return t.length>50?`${t.slice(0,50)}...`:t}async function Fn(t){return await Promise.all(t.map(async e=>({type:"file",mediaType:e.type,filename:e.name,url:await po(e,"dataUrl")})))}function _c(t){if(t.length===0)return!1;let e=t.at(-1);if(!e||e.role!=="assistant"||!e.parts)return!1;let a=e.parts;return a.length===0?!1:a[a.length-1].type==="reasoning"}function wc(t){return t.map(e=>e.type==="text"?e.text:"").join(`
|
|
89
|
+
`)}async function kc(t){let e=await Xu({input:wc(t.flatMap(r=>r.parts))});function a(r,s){return s?{...r,parts:[...r.parts,...e.attachments]}:r}return{...e.body,uiMessages:t.map((r,s)=>a(r,s===t.length-1))}}async function zn({invokeAiTool:t,addToolOutput:e,toolCall:a,toolContext:r}){try{if(Tr.has(a.toolName)){let s=await Tr.invoke({toolName:a.toolName,rawArgs:a.input,toolContext:r});e({tool:a.toolName,toolCallId:a.toolCallId,output:s.result||s.error})}else{let s=await t({toolName:a.toolName,arguments:a.input??{}});e({tool:a.toolName,toolCallId:a.toolCallId,output:s.result||s.error})}}catch(s){oe.error("Tool call failed:",s),e({tool:a.toolName,toolCallId:a.toolCallId,output:`Error: ${s instanceof Error?s.message:String(s)}`})}}function Cc(t){let e=t.at(-1);if(!e||e.role!=="assistant")return!1;let a=e.parts.at(-1);return!a||!Ge(a)?!1:tu({messages:t})||eu({messages:t})||a.state==="output-denied"&&!a.providerExecuted}function Ic(t){let e=t.at(-1);return!e||e.role!=="assistant"?!1:e.parts.some(a=>Ge(a)&&Tc(a.state))}function Tc(t){switch(t){case"approval-requested":case"input-streaming":case"input-available":return!0;case"approval-responded":case"output-available":case"output-error":case"output-denied":return!1;default:return t}}function Un(){let t=(0,yc.c)(7),e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0];let[a,r]=(0,P.useState)(e),s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=p=>{if(p.length!==0){if(p.reduce(Ec,0)>xc){Aa({title:"File size exceeded",description:"Attachments must be under 50 MB",variant:"danger"});return}r(h=>[...h,...p])}},t[1]=s):s=t[1];let n=St(s),o;t[2]===Symbol.for("react.memo_cache_sentinel")?(o=()=>r([]),t[2]=o):o=t[2];let i=o,d;t[3]===Symbol.for("react.memo_cache_sentinel")?(d=p=>r(h=>h.filter(f=>f!==p)),t[3]=d):d=t[3];let l=d,u;return t[4]!==n||t[5]!==a?(u={files:a,addFiles:n,clearFiles:i,removeFile:l},t[4]=n,t[5]=a,t[6]=u):u=t[6],u}function Ec(t,e){return t+e.size}function Sc(t){return t.isError?!1:t.isAbort?!0:!t.hasPendingToolCalls&&!t.hasUnresolvedToolCalls}function Ac(){let[t,e]=(0,P.useState)([]),a=(0,P.useRef)([]),r=(0,P.useRef)(!1);return a.current=t,r.current=t.length>0,{messages:t,enqueue:St(s=>{e(n=>{let o=[...n,{id:Co(),parts:s}];return a.current=o,r.current=!0,o})}),flushNext:St(s=>{let n=a.current;if(n.length===0)return;let[o,...i]=n;a.current=i,r.current=i.length>0,e(i),s(o.parts)}),clear:St(()=>{a.current=[],r.current=!1,e([])}),hasQueuedRef:r}}var It=At(),T=Ca(Bi(),1);const Oc=t=>{var o;let e=(0,It.c)(6),{attachment:a}=t;if((o=a.mediaType)!=null&&o.startsWith("image/")){let i=a.filename||"Attachment",d;return e[0]!==a.url||e[1]!==i?(d=(0,T.jsx)("img",{src:a.url,alt:i,className:"max-h-[100px] max-w-[100px] object-contain mb-1.5"}),e[0]=a.url,e[1]=i,e[2]=d):d=e[2],d}let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,T.jsx)(rs,{className:"h-3 w-3 mt-0.5"}),e[3]=r):r=e[3];let s=a.filename||"Attachment",n;return e[4]===s?n=e[5]:(n=(0,T.jsxs)("div",{className:"flex flex-row gap-1 items-center text-xs",children:[r,s]}),e[4]=s,e[5]=n),n},qn=t=>{let e=(0,It.c)(12),{file:a,className:r,onRemove:s}=t,[n,o]=(0,P.useState)(!1),i;e[0]===r?i=e[1]:(i=Ta("py-1 px-1.5 bg-muted rounded-md cursor-pointer flex flex-row gap-1 items-center text-xs",r),e[0]=r,e[1]=i);let d,l;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>o(!0),l=()=>o(!1),e[2]=d,e[3]=l):(d=e[2],l=e[3]);let u;e[4]!==a||e[5]!==n||e[6]!==s?(u=n?(0,T.jsx)(ts,{className:"h-3 w-3 mt-0.5",onClick:s}):Rc(a),e[4]=a,e[5]=n,e[6]=s,e[7]=u):u=e[7];let p;return e[8]!==a.name||e[9]!==i||e[10]!==u?(p=(0,T.jsxs)("div",{className:i,onMouseEnter:d,onMouseLeave:l,children:[u,a.name]}),e[8]=a.name,e[9]=i,e[10]=u,e[11]=p):p=e[11],p},Vn=t=>{let e=(0,It.c)(12),{isLoading:a,onStop:r,onSendClick:s,isEmpty:n,showStopLabel:o}=t,i=o===void 0?!1:o,d;e[0]===i?d=e[1]:(d=i?(0,T.jsxs)("div",{className:"flex flex-row items-center gap-1 px-1.5",children:[(0,T.jsx)("span",{className:"text-xs text-error",children:"Stop"}),(0,T.jsx)(fo,{size:"small"})]}):(0,T.jsx)(ss,{className:"size-4 text-error"}),e[0]=i,e[1]=d);let l=d,u=a?"Stop":"Submit",p=a?r:s,h=a?!1:n,f;e[2]!==a||e[3]!==l?(f=a?l:(0,T.jsx)(is,{className:"h-3.5 w-3.5"}),e[2]=a,e[3]=l,e[4]=f):f=e[4];let k;e[5]!==p||e[6]!==h||e[7]!==f?(k=(0,T.jsx)(Ve,{variant:"text",size:"sm",className:"h-6 min-w-6 p-0 hover:bg-muted/30 cursor-pointer",onClick:p,disabled:h,children:f}),e[5]=p,e[6]=h,e[7]=f,e[8]=k):k=e[8];let c;return e[9]!==u||e[10]!==k?(c=(0,T.jsx)(Kt,{content:u,children:k}),e[9]=u,e[10]=k,e[11]=c):c=e[11],c},Wn=t=>{let e=(0,It.c)(4),{handleAddContext:a,isLoading:r}=t,s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,T.jsx)(co,{className:"h-3.5 w-3.5"}),e[0]=s):s=e[0];let n;return e[1]!==a||e[2]!==r?(n=(0,T.jsx)(Kt,{content:"Add context",children:(0,T.jsx)(Ve,{variant:"text",size:"icon",onClick:a,disabled:r,children:s})}),e[1]=a,e[2]=r,e[3]=n):n=e[3],n},Bn=t=>{let e=(0,It.c)(15),{fileInputRef:a,isLoading:r,onAddFiles:s}=t,n;e[0]===a?n=e[1]:(n=()=>{var h;return(h=a.current)==null?void 0:h.click()},e[0]=a,e[1]=n);let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=(0,T.jsx)(ns,{className:"h-3.5 w-3.5"}),e[2]=o):o=e[2];let i;e[3]!==r||e[4]!==n?(i=(0,T.jsx)(Kt,{content:"Attach a file",children:(0,T.jsx)(Ve,{variant:"text",size:"icon",onClick:n,disabled:r,children:o})}),e[3]=r,e[4]=n,e[5]=i):i=e[5];let d;e[6]===s?d=e[7]:(d=h=>{h.target.files&&s([...h.target.files])},e[6]=s,e[7]=d);let l;e[8]===Symbol.for("react.memo_cache_sentinel")?(l=vc.join(","),e[8]=l):l=e[8];let u;e[9]!==a||e[10]!==d?(u=(0,T.jsx)(vo,{ref:a,type:"file",multiple:!0,hidden:!0,onChange:d,accept:l}),e[9]=a,e[10]=d,e[11]=u):u=e[11];let p;return e[12]!==i||e[13]!==u?(p=(0,T.jsxs)(T.Fragment,{children:[i,u]}),e[12]=i,e[13]=u,e[14]=p):p=e[14],p};function Rc(t){let e="h-3 w-3 mt-0.5";return t.type.startsWith("image/")?(0,T.jsx)(ho,{className:e}):t.type.startsWith("text/")?(0,T.jsx)($i,{className:e}):(0,T.jsx)(rs,{className:e})}const Nc=t=>{let e=(0,It.c)(15),{icon:a,title:r,subtitle:s,href:n}=t,o;e[0]===r?o=e[1]:(o=(0,T.jsx)("span",{className:"truncate font-medium",children:r}),e[0]=r,e[1]=o);let i;e[2]===s?i=e[3]:(i=s&&(0,T.jsxs)("span",{className:"truncate opacity-70",children:["(",s,")"]}),e[2]=s,e[3]=i);let d;e[4]!==a||e[5]!==o||e[6]!==i?(d=(0,T.jsxs)(T.Fragment,{children:[a,o,i]}),e[4]=a,e[5]=o,e[6]=i,e[7]=d):d=e[7];let l=d;if(n&&Io(n)){let h=s??r,f;return e[8]!==l||e[9]!==n||e[10]!==h?(f=(0,T.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",title:h,className:"inline-flex max-w-full items-center gap-1.5 rounded-md border bg-muted/50 px-2 py-1 my-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground transition-colors",children:l}),e[8]=l,e[9]=n,e[10]=h,e[11]=f):f=e[11],f}let u=s??r,p;return e[12]!==l||e[13]!==u?(p=(0,T.jsx)("div",{className:"inline-flex max-w-full items-center gap-1.5 rounded-md border bg-muted/50 px-2 py-1 my-1 text-xs text-muted-foreground",title:u,children:l}),e[12]=l,e[13]=u,e[14]=p):p=e[14],p},va=Ht.define(),Ee=Jt.define({create(){return new Map},update(t,e){let a=!1,r=t;for(let s of e.effects)if(s.is(va)){a||(a=(r=new Map(t),!0));for(let[n,o]of s.value)r.set(n,o)}return r}}),Mc=Jt.define({create(){return{onResourceClick:void 0,onResourceMouseOver:void 0,onResourceMouseOut:void 0,onPromptSubmit:void 0}},update(t){return t}}),jc=Ht.define();Jt.define({create(){return new Map},update(t,e){let a=!1,r=t;for(let s of e.effects)if(s.is(jc)){a||(a=(r=new Map(t),!0));for(let[n,o]of s.value)r.set(n,o)}return r}});const Pc=(t,e)=>async a=>{let r=a.matchBefore(/@(\w+)?/);if(!r||r.from===r.to&&!a.explicit)return null;let s=await t();if(s.length===0)return null;let n=va.of(new Map(s.map(i=>[i.uri,i])));a.view&&a.view.dispatch({effects:n});let o=s.map(i=>({label:`@${i.name}`,displayLabel:i.name,detail:i.uri,info:i.description||void 0,type:i.mimeType?"constant":"variable",boost:i.description?100:0,...e==null?void 0:e(i),apply:(d,l,u,p)=>{d.dispatch({changes:{from:u,to:p,insert:`@${i.uri} `}})}}));return{from:r.from,options:o}},$c=/@[\w-]+:\/\/(?!\/)[^\s]+/;function Me(t){return t.matchAll(new RegExp($c.source,"g"))}var Dc=class extends Gr{constructor(e,a){super();L(this,"resource");L(this,"view");this.resource=e,this.view=a}eq(e){return e.resource.uri===this.resource.uri}toDOM(){let e=document.createElement("span");e.className="cm-resource-widget",e.textContent=`@${this.resource.name}`;let a=this.view.state.field(Mc,!1),r=a==null?void 0:a.onResourceClick,s=a==null?void 0:a.onResourceMouseOver,n=a==null?void 0:a.onResourceMouseOut;return r&&(e.style.cursor="pointer",e.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation(),r(this.resource)})),s&&e.addEventListener("mouseover",o=>{o.preventDefault(),o.stopPropagation(),s(this.resource)}),n&&e.addEventListener("mouseout",o=>{o.preventDefault(),o.stopPropagation(),n(this.resource)}),e}},Lc=class extends Gr{constructor(e,a){super();L(this,"uri");L(this,"view");this.uri=e,this.view=a}eq(e){return e.uri===this.uri}toDOM(){let e=document.createElement("span");return e.className="cm-not-found-resource-widget",e.textContent=`@${this.uri.split("://")[1]??this.uri}`,e}};function Kn(t){let e=t.state.field(Ee),a=[];for(let{from:r,to:s}of t.visibleRanges){let n=t.state.doc.sliceString(r,s);for(let o of Me(n)){let i=r+o.index,d=o[0].slice(1),l=e.get(d);l?a.push(Ea.replace({widget:new Dc(l,t)}).range(i,i+o[0].length)):a.push(Ea.replace({widget:new Lc(d,t)}).range(i,i+o[0].length))}}return Ea.set(a)}const Zc=es.fromClass(class{constructor(t){L(this,"decorations");this.decorations=Kn(t)}update(t){(t.docChanged||t.viewportChanged||t.transactions.some(e=>e.effects.some(a=>a.is(va))))&&(this.decorations=Kn(t.view))}},{decorations:t=>t.decorations});function Fc(t){let e=document.createElement("div");e.className="cm-tooltip-cursor";let a=document.createElement("div");if(a.className="cm-tooltip-cursor-title",a.textContent=`${t.name} (${t.uri})`,e.appendChild(a),t.description){let r=document.createElement("div");r.className="cm-tooltip-cursor-description",r.textContent=t.description,e.appendChild(r)}if(t.mimeType){let r=document.createElement("div");r.className="cm-tooltip-cursor-mimetype",r.textContent=t.mimeType,e.appendChild(r)}return{dom:e}}function zc(t,e,a,r=0){for(let s of Me(t)){let n=r+s.index,o=n+s[0].length;if(e>=n&&e<=o){let i=s[0].slice(1),d=a.get(i);if(d)return{resource:d,start:n,end:o}}}return null}function Uc(t){return to((e,a)=>{let{from:r,text:s}=e.state.doc.lineAt(a),n=zc(s,a,e.state.field(Ee),r);return n?{pos:n.start,end:n.end,above:!0,create(){return(t.createTooltip??Fc)(n.resource)}}:null})}function qc(t,e){let a=t.field(Ee),r=t.doc,s=r.lineAt(e),n=r.sliceString(s.from,s.to),o=Array.from(Me(n));if(o.length===0)return null;for(let i of o){let d=s.from+i.index,l=d+i[0].length,u=i[0].slice(1);if(e===l&&a.has(u))return{from:d,to:l,uri:u}}return null}function Vc(t,e){let a=t.field(Ee),r=t.doc,s=r.lineAt(e).to,n=r.sliceString(e,s),o=Array.from(Me(n));if(o.length===0)return null;let i=o[0];if(!i||i.index!==0)return null;let d=e,l=e+i[0].length,u=i[0].slice(1);return a.has(u)?{from:d,to:l,uri:u}:null}function Jn(t,e){let a=t.field(Ee),r=t.doc,s=r.lineAt(e),n=r.sliceString(s.from,s.to),o=Array.from(Me(n));for(let i of o){let d=s.from+i.index,l=d+i[0].length,u=i[0].slice(1);if(e>d&&e<l&&a.has(u))return{from:d,to:l,uri:u}}return null}function Wc(t,e){let a=t.field(Ee),r=t.doc,s=r.lineAt(e),n=r.sliceString(s.from,e),o=Array.from(Me(n)),i=null;for(let d of o){let l=s.from+d.index,u=l+d[0].length,p=d[0].slice(1);a.has(p)&&u<=e&&(e>u?i=u:e===u&&(i=l))}return i}function Bc(t,e){let a=t.field(Ee),r=t.doc,s=r.lineAt(e),n=r.sliceString(s.from,s.to),o=Array.from(Me(n));for(let i of o){let d=s.from+i.index,l=d+i[0].length,u=i[0].slice(1);if(a.has(u)&&d>=e){if(e<d)return d;if(e===d)return l}}return null}const Kc=Xi.transactionFilter.of(t=>{var r;let e=t.annotation(eo.userEvent);if(!e)return t;let a=t.startState.selection.main;if(!a.empty)return t;if(e==="input.type"||e.startsWith("input")){if(t.changes.empty)return t;let s=t.startState.field(Ee),n=t.startState.doc,o=!1,i=0,d=[];if(t.changes.iterChanges((l,u,p,h,f)=>{let k=f.toString(),c=l;if(/^\s+$/.test(k)){d.push({from:l,to:u,insert:k});return}let b=n.lineAt(c),g=n.sliceString(b.from,b.to),A=Array.from(Me(g)),C=!1,R=!1;for(let v of A){let S=b.from+v.index,j=S+v[0].length,Z=v[0].slice(1);if(s.has(Z)){if(c===S){let $=c>0?n.sliceString(c-1,c):"";$!==""&&$!==" "&&$!==`
|
|
90
90
|
`&&$!==" "&&(C=!0)}if(c===j){let $=c<n.length?n.sliceString(c,c+1):"";($===""||$!==" "&&$!==`
|
|
91
91
|
`&&$!==" ")&&(R=!0)}}}let y=k;C&&(y=` ${y}`,i+=1),R&&(y=` ${y}`,i+=1),y!==k&&(o=!0),d.push({from:l,to:u,insert:y})}),o)return[{changes:d,selection:t.selection?{anchor:t.selection.main.anchor+i,head:t.selection.main.head+i}:void 0,scrollIntoView:t.scrollIntoView}]}if(e==="delete.backward"||e==="delete.forward"){let s=null;return e==="delete.backward"?s=qc(t.startState,a.head):e==="delete.forward"&&(s=Vc(t.startState,a.head)),s?[{changes:{from:s.from,to:s.to,insert:""},selection:{anchor:s.from},scrollIntoView:!0}]:t}if((r=t.selection)!=null&&r.main.empty&&a.empty&&!e.startsWith("input")&&e!=="input.type"){let s=a.head,n=t.selection.main.head,o=null;if(n<s){let i=Jn(t.startState,s);o=i&&s>i.from?i.from:Wc(t.startState,s)}else if(n>s){let i=Jn(t.startState,s);o=i&&s<i.to?i.to:Bc(t.startState,s)}if(o!==null&&o!==n)return[{selection:{anchor:o},scrollIntoView:!0}]}return t});var Jc=150;function Yn(t,e){let a=new Set;for(let r of Me(t)){let s=r[0].slice(1);e.has(s)||a.add(s)}return[...a]}function Hn(t){return[...t].sort().join(`
|
|
92
92
|
`)}function Gn(t){return!Me(t).next().done}function Yc(t){let e=[],a=[];return t.changes.iterChanges((r,s,n,o)=>{let i=t.startState.doc.lineAt(r),d=t.startState.doc.lineAt(s===r?r:s-1);e.push(t.startState.doc.sliceString(i.from,d.to));let l=t.state.doc.lineAt(n),u=t.state.doc.lineAt(o===n?n:o-1);a.push(t.state.doc.sliceString(l.from,u.to))}),{before:e.join(`
|
|
@@ -103,5 +103,5 @@ ${this.truncateString(o,n)}`}truncateString(t,e){return t.length<=e?t:`${t.slice
|
|
|
103
103
|
border-(--green-6) border hover:shadow-xs rounded px-3 ${o}`,A;e[24]===i?A=e[25]:(A=i&&(0,T.jsx)(Ra,{className:"ml-1 inline",shortcut:i}),e[24]=i,e[25]=A);let C;return e[26]!==a||e[27]!==r||e[28]!==h||e[29]!==g||e[30]!==A||e[31]!==b?(C=(0,T.jsxs)(Ve,{variant:"text",size:h,disabled:a,onClick:r,className:g,children:[b,A]}),e[26]=a,e[27]=r,e[28]=h,e[29]=g,e[30]=A,e[31]=b,e[32]=C):C=e[32],C},ai=t=>{let e=(0,Er.c)(8),{onDecline:a,multipleCompletions:r,size:s,className:n,declineShortcut:o,borderless:i}=t,d=r===void 0?!1:r,l=s===void 0?"sm":s,u=`h-6 text-(--red-10) bg-(--red-3)/60 hover:bg-(--red-3)
|
|
104
104
|
dark:bg-(--red-4)/80 dark:hover:bg-(--red-3) rounded px-3 font-semibold
|
|
105
105
|
active:bg-(--red-5) dark:active:bg-(--red-4)
|
|
106
|
-
border-(--red-6) border hover:shadow-xs ${(i===void 0?!1:i)&&"border-none rounded-md"} ${n}`,p=d&&" all",h;e[0]===o?h=e[1]:(h=o&&(0,T.jsx)(Ra,{className:"ml-1 inline",shortcut:o}),e[0]=o,e[1]=h);let f;return e[2]!==a||e[3]!==l||e[4]!==u||e[5]!==p||e[6]!==h?(f=(0,T.jsxs)(Ve,{variant:"text",size:l,onClick:a,className:u,children:["Reject",p,h]}),e[2]=a,e[3]=l,e[4]=u,e[5]=p,e[6]=h,e[7]=f):f=e[7],f};var rp=class extends nr{constructor(t,e){super(t),this.onChunkReceived=e}processResponseStream(t){let e=this.onChunkReceived;return super.processResponseStream(t).pipeThrough(new TransformStream({async transform(a,r){e(a),r.enqueue(a)}}))}},sp=At(),np=
|
|
106
|
+
border-(--red-6) border hover:shadow-xs ${(i===void 0?!1:i)&&"border-none rounded-md"} ${n}`,p=d&&" all",h;e[0]===o?h=e[1]:(h=o&&(0,T.jsx)(Ra,{className:"ml-1 inline",shortcut:o}),e[0]=o,e[1]=h);let f;return e[2]!==a||e[3]!==l||e[4]!==u||e[5]!==p||e[6]!==h?(f=(0,T.jsxs)(Ve,{variant:"text",size:l,onClick:a,className:u,children:["Reject",p,h]}),e[2]=a,e[3]=l,e[4]=u,e[5]=p,e[6]=h,e[7]=f):f=e[7],f};var rp=class extends nr{constructor(t,e){super(t),this.onChunkReceived=e}processResponseStream(t){let e=this.onChunkReceived;return super.processResponseStream(t).pipeThrough(new TransformStream({async transform(a,r){e(a),r.enqueue(a)}}))}},sp=At(),np=ki("marimo:ai-language","python",_i),ri="marimo:ai-prompt-history",si=new Ii(we(m()),()=>[]);const ip=({onClose:t})=>{var Xe;let e=Lr(),[a,r]=(0,P.useState)(""),{deleteAllStagedCells:s,clearStagedCells:n,onStream:o,addStagedCell:i}=Pn(e),[d,l]=vi(np),u=Wi(),{invokeAiTool:p,sendRun:h}=lo(),f=Fr(Ut),k=(0,P.useRef)(null),c=(0,P.useRef)(null),{files:b,addFiles:g,removeFile:A}=Un(),C=Fr(Vi),{createNewCell:R,prepareForRun:y}=zr(),v={store:e,addStagedCell:i,createNewCell:R,prepareForRun:y,sendRun:h},{sendMessage:S,stop:j,status:Z,addToolOutput:$}=_n({experimental_throttle:100,transport:new rp({api:u.getAiURL("completion").toString(),headers:()=>u.headers(),prepareSendMessagesRequest:async H=>{let je=await kc(H.messages),_a={...H,...je,code:"",prompt:"",language:d};return{api:u.getAiURL("completion").toString(),body:_a}}},H=>{o(H)}),onToolCall:async({toolCall:H})=>{await zn({invokeAiTool:p,addToolOutput:$,toolCall:{toolName:H.toolName,toolCallId:H.toolCallId,input:H.input},toolContext:v})},onError:H=>{Aa({title:"Generate with AI failed",description:Ao(H)})}}),B=Z==="streaming"||Z==="submitted",se=f.size>0,Y=((Xe=C==null?void 0:C.models)==null?void 0:Xe.edit_model)||"openai/gpt-4o",X=zi.parse(Y).providerId,re=Zn.has(X),ne=async()=>{var H;B||((H=k.current)!=null&&H.view&&kn(k.current.view),s(),S({text:a,files:b?await Fn(b):void 0}))},le=(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(No,{className:"size-4 mr-2"}),"Python"]}),ie=(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(wi,{className:"size-4 mr-2"}),"SQL"]}),ht=(0,T.jsxs)(Gi,{modal:!1,children:[(0,T.jsxs)(Yi,{className:"flex items-center justify-between h-7 text-xs px-2 py-0.5 border rounded-md hover:text-accent-foreground","data-testid":"language-button",children:[d==="python"?le:ie,(0,T.jsx)(mo,{className:"ml-1 h-3.5 w-3.5 text-muted-foreground/70"})]}),(0,T.jsxs)(Hi,{align:"center",children:[(0,T.jsx)("div",{className:"px-2 py-1 text-sm text-muted-foreground",children:"Select language"}),(0,T.jsx)(Ji,{}),(0,T.jsx)(Hr,{onClick:()=>l("python"),children:le}),(0,T.jsx)(Hr,{onClick:()=>l("sql"),children:ie})]})]}),Fe=()=>{n(),t()},ze=()=>{var H,je;s(),(je=(H=k.current)==null?void 0:H.view)==null||je.focus()},Ae=()=>{s(),t()},ft=(0,T.jsxs)("div",{className:"flex items-center px-3",children:[(0,T.jsx)(xo,{className:"size-4 text-(--blue-11) mr-2"}),(0,T.jsx)(ni,{inputRef:k,onClose:Ae,value:a,onChange:H=>{r(H)},onSubmit:ne,onKeyDown:ei({handleAcceptCompletion:Fe,handleDeclineCompletion:ze,isLoading:B,hasCompletion:se})}),(0,T.jsx)(Ve,{variant:"text",size:"sm",className:"mb-0 px-1",onClick:Ae,children:(0,T.jsx)(ts,{className:"size-4"})})]}),Tt=(0,T.jsxs)("div",{className:"px-3 pt-1 flex flex-row items-center justify-between",children:[(0,T.jsxs)("div",{className:"flex items-center gap-2",children:[(0,T.jsx)(Ui,{triggerClassName:"h-7 text-xs max-w-64",iconSize:"small",forRole:"edit",showAddCustomModelDocs:!0}),ht]}),(0,T.jsxs)("div",{className:"flex flex-row items-center",children:[b.length>0&&(0,T.jsx)("div",{className:"flex flex-row gap-1 flex-wrap pr-1",children:b==null?void 0:b.map((H,je)=>(0,T.jsx)(qn,{file:H,onRemove:()=>A(H)},`${H.name}-${je}`))}),(0,T.jsx)(Wn,{handleAddContext:()=>Nn(k),isLoading:B}),re&&(0,T.jsx)(Bn,{fileInputRef:c,isLoading:B,onAddFiles:g}),(0,T.jsx)(Vn,{isLoading:B,onStop:j,onSendClick:ne,isEmpty:!a.trim(),showStopLabel:!0})]})]});return(0,T.jsxs)("div",{className:Ta("flex flex-col w-full py-2"),children:[ft,Tt]})},ni=t=>{let e=(0,sp.c)(35),{value:a,placeholder:r,inputRef:s,className:n,onChange:o,onSubmit:i,onKeyDown:d,onClose:l,onAddFiles:u,additionalCompletions:p,maxHeight:h}=t,f=i,k=l,c=Lr(),{theme:b}=To(),g;e[0]===p?g=e[1]:(g=le=>p?tc([p.triggerCompletionRegex],p.completions)(le):null,e[0]=p,e[1]=g);let A=St(g),C,R,y,v;if(e[2]!==A||e[3]!==u||e[4]!==c){let le=ko();e[9]===Symbol.for("react.memo_cache_sentinel")?(C=io({}),e[9]=C):C=e[9],R=le,y=tp({language:le.language,store:c,onAddFiles:u}),v=le.language.data.of({autocomplete:A}),e[2]=A,e[3]=u,e[4]=c,e[5]=C,e[6]=R,e[7]=y,e[8]=v}else C=e[5],R=e[6],y=e[7],v=e[8];let S;e[10]===Symbol.for("react.memo_cache_sentinel")?(S=Pu({storage:{load:op,save:lp}}),e[10]=S):S=e[10];let j;e[11]===Symbol.for("react.memo_cache_sentinel")?(j=Mo(),e[11]=j):j=e[11];let Z;e[12]===f?Z=e[13]:(Z=Qr.highest(Yt.of([{preventDefault:!0,stopPropagation:!0,any:(le,ie)=>{let ht=ie.metaKey||ie.ctrlKey||ie.shiftKey;if(ie.key==="Enter"&&!ht)return f(ie,le.state.doc.toString()),ie.preventDefault(),ie.stopPropagation(),!0;if(ie.key==="Enter"&&ie.shiftKey){let Fe=le.state.selection.main.from;return le.dispatch({changes:{from:Fe,to:Fe,insert:`
|
|
107
107
|
`},selection:{anchor:Fe+1,head:Fe+1}}),ie.preventDefault(),ie.stopPropagation(),!0}return!1}}])),e[12]=f,e[13]=Z);let $;e[14]===k?$=e[15]:($=Yt.of([{key:"Escape",preventDefault:!0,stopPropagation:!0,run:()=>(k(),!0)}]),e[14]=k,e[15]=$);let B;e[16]!==C||e[17]!==R||e[18]!==y||e[19]!==v||e[20]!==Z||e[21]!==$?(B=[C,R,y,v,S,Xr.lineWrapping,j,Z,$],e[16]=C,e[17]=R,e[18]=y,e[19]=v,e[20]=Z,e[21]=$,e[22]=B):B=e[22];let se=B,Y;e[23]===n?Y=e[24]:(Y=Ta("flex-1 font-sans overflow-auto my-1",n),e[23]=n,e[24]=Y);let X=b==="dark"?"dark":"light",re=r||"Generate with AI, @ to include context",ne;return e[25]!==se||e[26]!==s||e[27]!==h||e[28]!==o||e[29]!==d||e[30]!==Y||e[31]!==X||e[32]!==re||e[33]!==a?(ne=(0,T.jsx)(jo,{ref:s,className:Y,width:"100%",maxHeight:h,value:a,basicSetup:!1,extensions:se,onChange:o,onKeyDown:d,theme:X,placeholder:re}),e[25]=se,e[26]=s,e[27]=h,e[28]=o,e[29]=d,e[30]=Y,e[31]=X,e[32]=re,e[33]=a,e[34]=ne):ne=e[34],ne};function op(){return si.get(ri)}function lp(t){return si.set(ri,t)}export{Hu as A,ar as B,Tr as C,Ju as D,Pn as E,Ou as F,is as H,nr as I,sr as L,Ct as M,kn as N,Nn as O,_n as P,Fd as R,Ac as S,jn as T,ns as U,tr as V,ss as W,Cc as _,ai as a,Sc as b,Bn as c,Vn as d,Nc as f,zn as g,bc as h,ap as i,Qu as j,Yu as k,Oc as l,Fn as m,ni as n,ei as o,Zn as p,ti as r,Wn as s,ip as t,qn as u,Ic as v,Ut as w,Un as x,_c as y,Bd as z};
|