@marimo-team/frontend 0.23.14-dev21 → 0.23.14-dev24
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-CSZHI8sz.js → CellStatus-jlsP_GVA.js} +1 -1
- package/dist/assets/{JsonOutput-CYIo9GSP.js → JsonOutput-DWLzjQfH.js} +1 -1
- package/dist/assets/{MarimoErrorOutput-BokuSnpU.js → MarimoErrorOutput-D6bg0PnC.js} +1 -1
- package/dist/assets/{RenderHTML-B9mw7TD1.js → RenderHTML-jHR4F0TB.js} +1 -1
- package/dist/assets/{RunButton-CX_nNY62.js → RunButton-Bv33M3KM.js} +1 -1
- package/dist/assets/{add-cell-with-ai-DwzlK27e.js → add-cell-with-ai-Brj954XD.js} +1 -1
- package/dist/assets/{add-connection-dialog-fmiSisf0.js → add-connection-dialog-WekDpd6a.js} +1 -1
- package/dist/assets/{agent-panel-BDO44WWH.js → agent-panel-Coqctj0N.js} +1 -1
- package/dist/assets/{ai-model-dropdown-BP8gjnOy.js → ai-model-dropdown-9Z73_iYD.js} +1 -1
- package/dist/assets/{app-config-button-CVpG64c2.js → app-config-button-KcmOli5I.js} +1 -1
- package/dist/assets/{cell-editor-Bbir67_U.js → cell-editor-3PkTaSur.js} +1 -1
- package/dist/assets/{cell-link-CBRggkzf.js → cell-link-k224YmrQ.js} +1 -1
- package/dist/assets/{cells-RJTD-euN.js → cells-C3u7zgmc.js} +1 -1
- package/dist/assets/{chat-display-17k5Uy0b.js → chat-display-D4inka1a.js} +1 -1
- package/dist/assets/{chat-panel-CGwZggen.js → chat-panel-CRnd6hUJ.js} +1 -1
- package/dist/assets/{chat-ui-BrSyHh93.js → chat-ui-BFK1PGME.js} +1 -1
- package/dist/assets/{column-preview-dW7xtQ7S.js → column-preview-RcoXaiDg.js} +1 -1
- package/dist/assets/{command-palette-DtKhXIMn.js → command-palette-D2gzhCzl.js} +1 -1
- package/dist/assets/{common-DHzo8K8C.js → common-C7KHHjwR.js} +1 -1
- package/dist/assets/{components-ChBJEsmj.js → components-Cy1B_xUe.js} +1 -1
- package/dist/assets/{datasource-RP7m6Xrh.js → datasource-DdxTABsD.js} +1 -1
- package/dist/assets/{dependency-graph-panel-CjdEazj5.js → dependency-graph-panel-ChEFWEad.js} +1 -1
- package/dist/assets/{documentation-panel-BcUF41gA.js → documentation-panel-CHsrEphc.js} +1 -1
- package/dist/assets/{download-CJ6tdZ-1.js → download-CIPflXYw.js} +1 -1
- package/dist/assets/{edit-page-lo6LC4Ie.js → edit-page-BU3ek7Rt.js} +4 -4
- package/dist/assets/{error-panel-D_1OmgVJ.js → error-panel-BNOa4d8t.js} +1 -1
- package/dist/assets/{file-explorer-panel-CG5na8ox.js → file-explorer-panel-BfW9B_XS.js} +1 -1
- package/dist/assets/{file-icons-CGJ6uWXm.js → file-icons-BgqEa5XP.js} +1 -1
- package/dist/assets/{file-name-input-DC8-M5r1.js → file-name-input-C58hWs3J.js} +1 -1
- package/dist/assets/{floating-outline-BOkj3eC_.js → floating-outline-Dd0YqrNt.js} +1 -1
- package/dist/assets/{focus-BViZMdHR.js → focus-CAC_Hef8.js} +1 -1
- package/dist/assets/{form-BbqpGicG.js → form-DL-na7MW.js} +1 -1
- package/dist/assets/{home-page-CU6li-ts.js → home-page-C_vjONwV.js} +1 -1
- package/dist/assets/{hooks-CPpze3O4.js → hooks-Q3y983ON.js} +1 -1
- package/dist/assets/{html-to-image-B8ja7wwq.js → html-to-image-CtinlkZr.js} +1 -1
- package/dist/assets/{index-BcxGcwkJ.js → index-D3lxLHpx.js} +3 -3
- package/dist/assets/{index-CaelsqOA.css → index-YVIqbajK.css} +1 -1
- package/dist/assets/{kiosk-mode-BP35ALfP.js → kiosk-mode-B1YZ0mzO.js} +1 -1
- package/dist/assets/{layout-BSHt96Sb.js → layout-CoL1gz3N.js} +3 -3
- package/dist/assets/{logs-panel-CbZLi2XS.js → logs-panel-DePmtRvT.js} +1 -1
- package/dist/assets/{markdown-renderer-jghC8PFL.js → markdown-renderer-D9OefDax.js} +1 -1
- package/dist/assets/{name-cell-input-CN4MRZOm.js → name-cell-input-DylPR-WK.js} +1 -1
- package/dist/assets/{outline-panel-CvB3hUJ2.js → outline-panel-RGmU_dF-.js} +1 -1
- package/dist/assets/{packages-panel-BGgZLApn.js → packages-panel-peuk7Xf3.js} +1 -1
- package/dist/assets/{panels-DCWntQim.js → panels-ClMIloyA.js} +1 -1
- package/dist/assets/{process-output-xDK6-i-G.js → process-output-sBsmCqpj.js} +1 -1
- package/dist/assets/{radio-group-DFkF8CeQ.js → radio-group-sAYTFNhO.js} +1 -1
- package/dist/assets/{readonly-code-display-BHx0vyug.js → readonly-code-display-Cp4Jh2O4.js} +1 -1
- package/dist/assets/{readonly-python-code-Cla-uJpn.js → readonly-python-code-DKlDbYmn.js} +1 -1
- package/dist/assets/{reveal-component-Bvxyfpeh.js → reveal-component-BMfGxbyk.js} +1 -1
- package/dist/assets/{run-page-Cxc4jqCp.js → run-page-D_AovSqt.js} +1 -1
- package/dist/assets/{scratchpad-panel-Bp4sg_00.js → scratchpad-panel-BpvYuSq5.js} +1 -1
- package/dist/assets/{session-panel-WkryRIGA.js → session-panel-CO4iIWXU.js} +1 -1
- package/dist/assets/{snippets-panel-BcDwLUNv.js → snippets-panel-DryeY8UE.js} +1 -1
- package/dist/assets/{state-DHqaTLr2.js → state-B_ZdzCIe.js} +1 -1
- package/dist/assets/{state-CXzKtmF5.js → state-IriMIPOR.js} +1 -1
- package/dist/assets/{textarea-B5Bp08T3.js → textarea-DOzBgXd_.js} +1 -1
- package/dist/assets/{tracing-clJBeQm6.js → tracing-CJ-76i4O.js} +1 -1
- package/dist/assets/{tracing-panel-7j9NY9lO.js → tracing-panel-D570Cla1.js} +2 -2
- package/dist/assets/{tree-actions-DLySKXUq.js → tree-actions-2Ixf0GHD.js} +1 -1
- package/dist/assets/{useCellActionButton-CvQRbg1P.js → useCellActionButton-D82Xuv94.js} +1 -1
- package/dist/assets/{useDeleteCell-Sj06CzJn.js → useDeleteCell-DnDf7cie.js} +1 -1
- package/dist/assets/{useDependencyPanelTab-BTgQmu1R.js → useDependencyPanelTab-D1ytSGD0.js} +1 -1
- package/dist/assets/{useNotebookActions-9PPlpXk8.js → useNotebookActions-C2TVewtT.js} +1 -1
- package/dist/assets/{useRunCells-D5aAUcAa.js → useRunCells-B8rJ_Hwq.js} +1 -1
- package/dist/assets/{useSplitCell-CGE6jkuF.js → useSplitCell-DVuFaOkR.js} +1 -1
- package/dist/index.html +23 -23
- package/package.json +1 -1
- package/src/core/codemirror/__tests__/setup.test.ts +33 -1
- package/src/core/codemirror/cells/extensions.ts +1 -4
- package/src/css/app/codemirror.css +14 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as z}from"./chunk-LvLJmgfZ.js";import{l as X}from"./useEvent-D91BmmQi.js";import{t as Z}from"./react-Bj1aDYRI.js";import{Vt as I}from"./cells-RJTD-euN.js";import{t as H}from"./compiler-runtime-B3qBwwSJ.js";import{S as $,c as ee,i as te,l as se,n as le,u as ae}from"./ai-model-dropdown-BP8gjnOy.js";import{E as Q,T as oe,b as ne}from"./utils-Dev6I_Kv.js";import{T as re}from"./config-3clPIEB9.js";import{t as ie}from"./jsx-runtime-PbYoItBR.js";import{o as ce}from"./alert-dialog-CC0gG4Av.js";import{i as de,r as he,t as me}from"./popover-DMNO6Poc.js";import{l as R}from"./select-Cjly7tmx.js";import{t as U}from"./tooltip-CgQpRVyN.js";import{t as xe}from"./button-BF7GSjhW.js";import{s as B}from"./arrays-DWxvyYxP.js";import{r as V}from"./requests-KshNNAOp.js";import{t as pe}from"./createLucideIcon-BTp1tQDO.js";import{t as fe}from"./x-9vLEgLY6.js";import{r as D}from"./input-DB2LiTiQ.js";import{t as Y}from"./settings-1WkYMLdR.js";import{a as M,c as A,d as L,g as ue,i as je,l as E,o as P,p as ve,u as S}from"./textarea-B5Bp08T3.js";import{t as ge}from"./use-toast-kCNiuc-_.js";import{i as be}from"./RSPContexts-VzcTZjG1.js";import{n as we}from"./useDebounce-CpLI2dsc.js";import{c as ye,l as Ne,n as Ce,t as K}from"./dialog-DkJmIrsG.js";import{n as ke}from"./ImperativeModal-B62Q6S9l.js";import{t as O}from"./kbd-UVzWBHfi.js";import{t as _e}from"./links-CCkJpphF.js";import{t as G}from"./Inputs-SmI80aJQ.js";var Se=pe("power-off",[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),Te=H(),s=z(ie(),1);const Me=t=>{let e=(0,Te.c)(15),{description:a,disabled:f,tooltip:r}=t,i=f===void 0?!1:f,u=r===void 0?"Shutdown":r,{openConfirm:b,closeModal:l}=ke(),{sendShutdown:o}=V(),w;e[0]===o?w=e[1]:(w=()=>{o(),setTimeout(Ae,200)},e[0]=o,e[1]=w);let j=w;if(re())return null;let m=i?"disabled":"red",c;e[2]!==l||e[3]!==a||e[4]!==j||e[5]!==b?(c=h=>{h.stopPropagation(),b({title:"Shutdown",description:a,variant:"destructive",confirmAction:(0,s.jsx)(ce,{onClick:()=>{j(),l()},"aria-label":"Confirm Shutdown",children:"Shutdown"})})},e[2]=l,e[3]=a,e[4]=j,e[5]=b,e[6]=c):c=e[6];let n;e[7]===Symbol.for("react.memo_cache_sentinel")?(n=(0,s.jsx)(fe,{strokeWidth:1}),e[7]=n):n=e[7];let d;e[8]!==i||e[9]!==m||e[10]!==c?(d=(0,s.jsx)(G,{"aria-label":"Shutdown","data-testid":"shutdown-button",shape:"circle",size:"small",color:m,className:"h-[27px] w-[27px]",disabled:i,onClick:c,children:n}),e[8]=i,e[9]=m,e[10]=c,e[11]=d):d=e[11];let x;return e[12]!==d||e[13]!==u?(x=(0,s.jsx)(U,{content:u,children:d}),e[12]=d,e[13]=u,e[14]=x):x=e[14],x};function Ae(){window.close()}var J=H(),W=z(Z(),1),Le=100;const Ee=()=>{let t=(0,J.c)(37),[e,a]=ne(),{saveAppConfig:f}=V(),r=(0,W.useId)(),i=(0,W.useId)(),u;t[0]===Symbol.for("react.memo_cache_sentinel")?(u=ve(oe),t[0]=u):u=t[0];let b;t[1]===e?b=t[2]:(b={resolver:u,defaultValues:e},t[1]=e,t[2]=b);let l=ue(b),o;t[3]!==f||t[4]!==a?(o=async p=>{await f({config:p}).then(()=>{a(p)}).catch(()=>{a(p)})},t[3]=f,t[4]=a,t[5]=o):o=t[5];let w=o,j;t[6]===w?j=t[7]:(j=p=>{w(p)},t[6]=w,t[7]=j);let m=we(j,Le),c;t[8]===e.width?c=t[9]:(c=[e.width],t[8]=e.width,t[9]=c),(0,W.useEffect)(Pe,c);let n;t[10]!==m||t[11]!==l?(n=l.handleSubmit(m),t[10]=m,t[11]=l,t[12]=n):n=t[12];let d;t[13]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsxs)("div",{children:[(0,s.jsx)(ae,{children:"Notebook Settings"}),(0,s.jsx)(se,{children:"Configure how your notebook or application looks and behaves."})]}),t[13]=d):d=t[13];let x;t[14]===l.control?x=t[15]:(x=(0,s.jsxs)(F,{title:"Display",children:[(0,s.jsx)(A,{control:l.control,name:"width",render:Fe}),(0,s.jsx)(A,{control:l.control,name:"app_title",render:He})]}),t[14]=l.control,t[15]=x);let h;t[16]===l.control?h=t[17]:(h=(0,s.jsxs)(F,{title:"Custom Files",children:[(0,s.jsx)(A,{control:l.control,name:"css_file",render:De}),(0,s.jsx)(A,{control:l.control,name:"html_head_file",render:Oe})]}),t[16]=l.control,t[17]=h);let y;t[18]===l.control?y=t[19]:(y=(0,s.jsx)(F,{title:"Data",children:(0,s.jsx)(A,{control:l.control,name:"sql_output",render:ze})}),t[18]=l.control,t[19]=y);let N;t[20]!==r||t[21]!==i?(N=p=>{let{field:_}=p;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(E,{className:"flex flex-col gap-2",children:[(0,s.jsx)(M,{children:(0,s.jsxs)("div",{className:"flex gap-4",children:[(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)(I,{id:r,"data-testid":"html-checkbox",checked:_.value.includes("html"),onCheckedChange:()=>{_.onChange(B(_.value,"html"))}}),(0,s.jsx)(S,{htmlFor:r,children:"HTML"})]}),(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)(I,{id:i,"data-testid":"ipynb-checkbox",checked:_.value.includes("ipynb"),onCheckedChange:()=>{_.onChange(B(_.value,"ipynb"))}}),(0,s.jsx)(S,{htmlFor:i,children:"IPYNB"})]})]})}),(0,s.jsx)(L,{})]}),(0,s.jsxs)(P,{children:["When enabled, marimo will periodically save this notebook in your selected formats (HTML, IPYNB) to a folder named"," ",(0,s.jsx)(O,{className:"inline",children:"__marimo__"})," next to your notebook file."]})]})},t[20]=r,t[21]=i,t[22]=N):N=t[22];let v;t[23]!==l.control||t[24]!==N?(v=(0,s.jsx)(F,{title:"Exporting outputs",children:(0,s.jsx)(A,{control:l.control,name:"auto_download",render:N})}),t[23]=l.control,t[24]=N,t[25]=v):v=t[25];let C;t[26]!==v||t[27]!==x||t[28]!==h||t[29]!==y?(C=(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-x-8 gap-y-4",children:[x,h,y,v]}),t[26]=v,t[27]=x,t[28]=h,t[29]=y,t[30]=C):C=t[30];let g;t[31]!==C||t[32]!==n?(g=(0,s.jsxs)("form",{onChange:n,className:"flex flex-col gap-6",children:[d,C]}),t[31]=C,t[32]=n,t[33]=g):g=t[33];let k;return t[34]!==l||t[35]!==g?(k=(0,s.jsx)(je,{...l,children:g}),t[34]=l,t[35]=g,t[36]=k):k=t[36],k};var F=t=>{let e=(0,J.c)(5),{title:a,children:f}=t,r;e[0]===a?r=e[1]:(r=(0,s.jsx)("h3",{className:"text-base font-semibold mb-1",children:a}),e[0]=a,e[1]=r);let i;return e[2]!==f||e[3]!==r?(i=(0,s.jsxs)("div",{className:"flex flex-col gap-y-2",children:[r,f]}),e[2]=f,e[3]=r,e[4]=i):i=e[4],i};function Pe(){window.dispatchEvent(new Event("resize"))}function qe(t){return(0,s.jsx)("option",{value:t,children:t},t)}function Fe(t){let{field:e}=t;return(0,s.jsxs)(E,{className:"flex flex-row items-center space-x-1 space-y-0",children:[(0,s.jsx)(S,{children:"Width"}),(0,s.jsx)(M,{children:(0,s.jsx)(R,{"data-testid":"app-width-select",onChange:a=>e.onChange(a.target.value),value:e.value,disabled:e.disabled,className:"inline-flex mr-2",children:$().map(qe)})}),(0,s.jsx)(L,{})]})}function He(t){let{field:e}=t;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(E,{className:"flex flex-row items-center space-x-1 space-y-0",children:[(0,s.jsx)(S,{children:"App title"}),(0,s.jsx)(M,{children:(0,s.jsx)(D,{...e,value:e.value??"",onChange:a=>{e.onChange(a.target.value),Q.safeParse(a.target.value).success&&(document.title=a.target.value)}})}),(0,s.jsx)(L,{})]}),(0,s.jsx)(P,{children:"The application title is put in the title tag in the HTML code and typically displayed in the title bar of the browser window."})]})}function De(t){let{field:e}=t;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(E,{className:"flex flex-row items-center space-x-1 space-y-0",children:[(0,s.jsx)(S,{className:"shrink-0",children:"Custom CSS"}),(0,s.jsx)(M,{children:(0,s.jsx)(D,{...e,value:e.value??"",placeholder:"custom.css",onChange:a=>{e.onChange(a.target.value),Q.safeParse(a.target.value).success&&(document.title=a.target.value)}})}),(0,s.jsx)(L,{})]}),(0,s.jsx)(P,{children:"A filepath to a custom css file to be injected into the notebook."})]})}function Oe(t){let{field:e}=t;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(E,{className:"flex flex-row items-center space-x-1 space-y-0",children:[(0,s.jsx)(S,{className:"shrink-0",children:"HTML Head"}),(0,s.jsx)(M,{children:(0,s.jsx)(D,{...e,value:e.value??"",placeholder:"head.html",onChange:a=>{e.onChange(a.target.value)}})}),(0,s.jsx)(L,{})]}),(0,s.jsxs)(P,{children:["A filepath to an HTML file to be injected into the"," ",(0,s.jsx)(O,{className:"inline",children:"<head/>"})," section of the notebook. Use this to add analytics, custom fonts, meta tags, or external scripts."]})]})}function We(t){return(0,s.jsx)("option",{value:t.value,children:t.label},t.value)}function ze(t){let{field:e}=t;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(E,{className:"flex flex-row items-center space-x-1 space-y-0",children:[(0,s.jsx)(S,{children:"SQL Output Type"}),(0,s.jsx)(M,{children:(0,s.jsx)(R,{"data-testid":"sql-output-select",onChange:a=>{e.onChange(a.target.value),ge({title:"Kernel Restart Required",description:"This change requires a kernel restart to take effect."})},value:e.value,disabled:e.disabled,className:"inline-flex mr-2",children:ee.map(We)})}),(0,s.jsx)(L,{})]}),(0,s.jsxs)(P,{children:["The Python type returned by a SQL cell. For best performance with large datasets, we recommend using"," ",(0,s.jsx)(O,{className:"inline",children:"native"}),". See the"," ",(0,s.jsx)(_e,{href:"https://docs.marimo.io/guides/working_with_data/sql",children:"SQL guide"})," ","for more information."]})]})}var Ie=H();const Qe=t=>{let e=(0,Ie.c)(32),{showAppConfig:a,disabled:f,tooltip:r}=t,i=a===void 0?!0:a,u=f===void 0?!1:f,b=r===void 0?"Settings":r,[l,o]=X(le),w=u?"disabled":"hint-green",j;e[0]===Symbol.for("react.memo_cache_sentinel")?(j=(0,s.jsx)(Y,{strokeWidth:1.8}),e[0]=j):j=e[0];let m;e[1]===b?m=e[2]:(m=(0,s.jsx)(U,{content:b,children:j}),e[1]=b,e[2]=m);let c;e[3]!==u||e[4]!==w||e[5]!==m?(c=(0,s.jsx)(G,{"aria-label":"Config","data-testid":"app-config-button",shape:"circle",size:"small",className:"h-[27px] w-[27px]",disabled:u,color:w,children:m}),e[3]=u,e[4]=w,e[5]=m,e[6]=c):c=e[6];let n=c,d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsxs)(Ce,{className:"w-[90vw] h-[90vh] overflow-hidden sm:max-w-5xl top-[5vh] p-0",children:[(0,s.jsx)(be,{children:(0,s.jsx)(ye,{children:"User settings"})}),(0,s.jsx)(te,{})]}),e[7]=d):d=e[7];let x=d;if(!i){let T;e[8]===n?T=e[9]:(T=(0,s.jsx)(Ne,{children:n}),e[8]=n,e[9]=T);let q;return e[10]!==o||e[11]!==l||e[12]!==T?(q=(0,s.jsxs)(K,{open:l,onOpenChange:o,children:[T,x]}),e[10]=o,e[11]=l,e[12]=T,e[13]=q):q=e[13],q}let h;e[14]===n?h=e[15]:(h=(0,s.jsx)(de,{asChild:!0,children:n}),e[14]=n,e[15]=h);let y,N;e[16]===Symbol.for("react.memo_cache_sentinel")?(y=(0,s.jsx)(Ee,{}),N=(0,s.jsx)("div",{className:"h-px bg-border my-2"}),e[16]=y,e[17]=N):(y=e[16],N=e[17]);let v;e[18]===o?v=e[19]:(v=()=>o(!0),e[18]=o,e[19]=v);let C;e[20]===Symbol.for("react.memo_cache_sentinel")?(C=(0,s.jsx)(Y,{strokeWidth:1.8,className:"w-4 h-4 mr-2"}),e[20]=C):C=e[20];let g;e[21]===v?g=e[22]:(g=(0,s.jsxs)(he,{className:"w-[650px] overflow-auto max-h-[80vh] max-w-[80vw]",align:"end",side:"bottom",onFocusOutside:Re,children:[y,N,(0,s.jsxs)(xe,{onClick:v,variant:"link",className:"px-0",children:[C,"User settings"]})]}),e[21]=v,e[22]=g);let k;e[23]!==g||e[24]!==h?(k=(0,s.jsxs)(me,{children:[h,g]}),e[23]=g,e[24]=h,e[25]=k):k=e[25];let p;e[26]!==o||e[27]!==l?(p=(0,s.jsx)(K,{open:l,onOpenChange:o,children:x}),e[26]=o,e[27]=l,e[28]=p):p=e[28];let _;return e[29]!==k||e[30]!==p?(_=(0,s.jsxs)(s.Fragment,{children:[k,p]}),e[29]=k,e[30]=p,e[31]=_):_=e[31],_};function Re(t){return t.preventDefault()}export{Me as n,Se as r,Qe as t};
|
|
1
|
+
import{s as z}from"./chunk-LvLJmgfZ.js";import{l as X}from"./useEvent-D91BmmQi.js";import{t as Z}from"./react-Bj1aDYRI.js";import{Vt as I}from"./cells-C3u7zgmc.js";import{t as H}from"./compiler-runtime-B3qBwwSJ.js";import{S as $,c as ee,i as te,l as se,n as le,u as ae}from"./ai-model-dropdown-9Z73_iYD.js";import{E as Q,T as oe,b as ne}from"./utils-Dev6I_Kv.js";import{T as re}from"./config-3clPIEB9.js";import{t as ie}from"./jsx-runtime-PbYoItBR.js";import{o as ce}from"./alert-dialog-CC0gG4Av.js";import{i as de,r as he,t as me}from"./popover-DMNO6Poc.js";import{l as R}from"./select-Cjly7tmx.js";import{t as U}from"./tooltip-CgQpRVyN.js";import{t as xe}from"./button-BF7GSjhW.js";import{s as B}from"./arrays-DWxvyYxP.js";import{r as V}from"./requests-KshNNAOp.js";import{t as pe}from"./createLucideIcon-BTp1tQDO.js";import{t as fe}from"./x-9vLEgLY6.js";import{r as D}from"./input-DB2LiTiQ.js";import{t as Y}from"./settings-1WkYMLdR.js";import{a as M,c as A,d as L,g as ue,i as je,l as E,o as P,p as ve,u as S}from"./textarea-DOzBgXd_.js";import{t as ge}from"./use-toast-kCNiuc-_.js";import{i as be}from"./RSPContexts-VzcTZjG1.js";import{n as we}from"./useDebounce-CpLI2dsc.js";import{c as ye,l as Ne,n as Ce,t as K}from"./dialog-DkJmIrsG.js";import{n as ke}from"./ImperativeModal-B62Q6S9l.js";import{t as O}from"./kbd-UVzWBHfi.js";import{t as _e}from"./links-CCkJpphF.js";import{t as G}from"./Inputs-SmI80aJQ.js";var Se=pe("power-off",[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),Te=H(),s=z(ie(),1);const Me=t=>{let e=(0,Te.c)(15),{description:a,disabled:f,tooltip:r}=t,i=f===void 0?!1:f,u=r===void 0?"Shutdown":r,{openConfirm:b,closeModal:l}=ke(),{sendShutdown:o}=V(),w;e[0]===o?w=e[1]:(w=()=>{o(),setTimeout(Ae,200)},e[0]=o,e[1]=w);let j=w;if(re())return null;let m=i?"disabled":"red",c;e[2]!==l||e[3]!==a||e[4]!==j||e[5]!==b?(c=h=>{h.stopPropagation(),b({title:"Shutdown",description:a,variant:"destructive",confirmAction:(0,s.jsx)(ce,{onClick:()=>{j(),l()},"aria-label":"Confirm Shutdown",children:"Shutdown"})})},e[2]=l,e[3]=a,e[4]=j,e[5]=b,e[6]=c):c=e[6];let n;e[7]===Symbol.for("react.memo_cache_sentinel")?(n=(0,s.jsx)(fe,{strokeWidth:1}),e[7]=n):n=e[7];let d;e[8]!==i||e[9]!==m||e[10]!==c?(d=(0,s.jsx)(G,{"aria-label":"Shutdown","data-testid":"shutdown-button",shape:"circle",size:"small",color:m,className:"h-[27px] w-[27px]",disabled:i,onClick:c,children:n}),e[8]=i,e[9]=m,e[10]=c,e[11]=d):d=e[11];let x;return e[12]!==d||e[13]!==u?(x=(0,s.jsx)(U,{content:u,children:d}),e[12]=d,e[13]=u,e[14]=x):x=e[14],x};function Ae(){window.close()}var J=H(),W=z(Z(),1),Le=100;const Ee=()=>{let t=(0,J.c)(37),[e,a]=ne(),{saveAppConfig:f}=V(),r=(0,W.useId)(),i=(0,W.useId)(),u;t[0]===Symbol.for("react.memo_cache_sentinel")?(u=ve(oe),t[0]=u):u=t[0];let b;t[1]===e?b=t[2]:(b={resolver:u,defaultValues:e},t[1]=e,t[2]=b);let l=ue(b),o;t[3]!==f||t[4]!==a?(o=async p=>{await f({config:p}).then(()=>{a(p)}).catch(()=>{a(p)})},t[3]=f,t[4]=a,t[5]=o):o=t[5];let w=o,j;t[6]===w?j=t[7]:(j=p=>{w(p)},t[6]=w,t[7]=j);let m=we(j,Le),c;t[8]===e.width?c=t[9]:(c=[e.width],t[8]=e.width,t[9]=c),(0,W.useEffect)(Pe,c);let n;t[10]!==m||t[11]!==l?(n=l.handleSubmit(m),t[10]=m,t[11]=l,t[12]=n):n=t[12];let d;t[13]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsxs)("div",{children:[(0,s.jsx)(ae,{children:"Notebook Settings"}),(0,s.jsx)(se,{children:"Configure how your notebook or application looks and behaves."})]}),t[13]=d):d=t[13];let x;t[14]===l.control?x=t[15]:(x=(0,s.jsxs)(F,{title:"Display",children:[(0,s.jsx)(A,{control:l.control,name:"width",render:Fe}),(0,s.jsx)(A,{control:l.control,name:"app_title",render:He})]}),t[14]=l.control,t[15]=x);let h;t[16]===l.control?h=t[17]:(h=(0,s.jsxs)(F,{title:"Custom Files",children:[(0,s.jsx)(A,{control:l.control,name:"css_file",render:De}),(0,s.jsx)(A,{control:l.control,name:"html_head_file",render:Oe})]}),t[16]=l.control,t[17]=h);let y;t[18]===l.control?y=t[19]:(y=(0,s.jsx)(F,{title:"Data",children:(0,s.jsx)(A,{control:l.control,name:"sql_output",render:ze})}),t[18]=l.control,t[19]=y);let N;t[20]!==r||t[21]!==i?(N=p=>{let{field:_}=p;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(E,{className:"flex flex-col gap-2",children:[(0,s.jsx)(M,{children:(0,s.jsxs)("div",{className:"flex gap-4",children:[(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)(I,{id:r,"data-testid":"html-checkbox",checked:_.value.includes("html"),onCheckedChange:()=>{_.onChange(B(_.value,"html"))}}),(0,s.jsx)(S,{htmlFor:r,children:"HTML"})]}),(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)(I,{id:i,"data-testid":"ipynb-checkbox",checked:_.value.includes("ipynb"),onCheckedChange:()=>{_.onChange(B(_.value,"ipynb"))}}),(0,s.jsx)(S,{htmlFor:i,children:"IPYNB"})]})]})}),(0,s.jsx)(L,{})]}),(0,s.jsxs)(P,{children:["When enabled, marimo will periodically save this notebook in your selected formats (HTML, IPYNB) to a folder named"," ",(0,s.jsx)(O,{className:"inline",children:"__marimo__"})," next to your notebook file."]})]})},t[20]=r,t[21]=i,t[22]=N):N=t[22];let v;t[23]!==l.control||t[24]!==N?(v=(0,s.jsx)(F,{title:"Exporting outputs",children:(0,s.jsx)(A,{control:l.control,name:"auto_download",render:N})}),t[23]=l.control,t[24]=N,t[25]=v):v=t[25];let C;t[26]!==v||t[27]!==x||t[28]!==h||t[29]!==y?(C=(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-x-8 gap-y-4",children:[x,h,y,v]}),t[26]=v,t[27]=x,t[28]=h,t[29]=y,t[30]=C):C=t[30];let g;t[31]!==C||t[32]!==n?(g=(0,s.jsxs)("form",{onChange:n,className:"flex flex-col gap-6",children:[d,C]}),t[31]=C,t[32]=n,t[33]=g):g=t[33];let k;return t[34]!==l||t[35]!==g?(k=(0,s.jsx)(je,{...l,children:g}),t[34]=l,t[35]=g,t[36]=k):k=t[36],k};var F=t=>{let e=(0,J.c)(5),{title:a,children:f}=t,r;e[0]===a?r=e[1]:(r=(0,s.jsx)("h3",{className:"text-base font-semibold mb-1",children:a}),e[0]=a,e[1]=r);let i;return e[2]!==f||e[3]!==r?(i=(0,s.jsxs)("div",{className:"flex flex-col gap-y-2",children:[r,f]}),e[2]=f,e[3]=r,e[4]=i):i=e[4],i};function Pe(){window.dispatchEvent(new Event("resize"))}function qe(t){return(0,s.jsx)("option",{value:t,children:t},t)}function Fe(t){let{field:e}=t;return(0,s.jsxs)(E,{className:"flex flex-row items-center space-x-1 space-y-0",children:[(0,s.jsx)(S,{children:"Width"}),(0,s.jsx)(M,{children:(0,s.jsx)(R,{"data-testid":"app-width-select",onChange:a=>e.onChange(a.target.value),value:e.value,disabled:e.disabled,className:"inline-flex mr-2",children:$().map(qe)})}),(0,s.jsx)(L,{})]})}function He(t){let{field:e}=t;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(E,{className:"flex flex-row items-center space-x-1 space-y-0",children:[(0,s.jsx)(S,{children:"App title"}),(0,s.jsx)(M,{children:(0,s.jsx)(D,{...e,value:e.value??"",onChange:a=>{e.onChange(a.target.value),Q.safeParse(a.target.value).success&&(document.title=a.target.value)}})}),(0,s.jsx)(L,{})]}),(0,s.jsx)(P,{children:"The application title is put in the title tag in the HTML code and typically displayed in the title bar of the browser window."})]})}function De(t){let{field:e}=t;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(E,{className:"flex flex-row items-center space-x-1 space-y-0",children:[(0,s.jsx)(S,{className:"shrink-0",children:"Custom CSS"}),(0,s.jsx)(M,{children:(0,s.jsx)(D,{...e,value:e.value??"",placeholder:"custom.css",onChange:a=>{e.onChange(a.target.value),Q.safeParse(a.target.value).success&&(document.title=a.target.value)}})}),(0,s.jsx)(L,{})]}),(0,s.jsx)(P,{children:"A filepath to a custom css file to be injected into the notebook."})]})}function Oe(t){let{field:e}=t;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(E,{className:"flex flex-row items-center space-x-1 space-y-0",children:[(0,s.jsx)(S,{className:"shrink-0",children:"HTML Head"}),(0,s.jsx)(M,{children:(0,s.jsx)(D,{...e,value:e.value??"",placeholder:"head.html",onChange:a=>{e.onChange(a.target.value)}})}),(0,s.jsx)(L,{})]}),(0,s.jsxs)(P,{children:["A filepath to an HTML file to be injected into the"," ",(0,s.jsx)(O,{className:"inline",children:"<head/>"})," section of the notebook. Use this to add analytics, custom fonts, meta tags, or external scripts."]})]})}function We(t){return(0,s.jsx)("option",{value:t.value,children:t.label},t.value)}function ze(t){let{field:e}=t;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(E,{className:"flex flex-row items-center space-x-1 space-y-0",children:[(0,s.jsx)(S,{children:"SQL Output Type"}),(0,s.jsx)(M,{children:(0,s.jsx)(R,{"data-testid":"sql-output-select",onChange:a=>{e.onChange(a.target.value),ge({title:"Kernel Restart Required",description:"This change requires a kernel restart to take effect."})},value:e.value,disabled:e.disabled,className:"inline-flex mr-2",children:ee.map(We)})}),(0,s.jsx)(L,{})]}),(0,s.jsxs)(P,{children:["The Python type returned by a SQL cell. For best performance with large datasets, we recommend using"," ",(0,s.jsx)(O,{className:"inline",children:"native"}),". See the"," ",(0,s.jsx)(_e,{href:"https://docs.marimo.io/guides/working_with_data/sql",children:"SQL guide"})," ","for more information."]})]})}var Ie=H();const Qe=t=>{let e=(0,Ie.c)(32),{showAppConfig:a,disabled:f,tooltip:r}=t,i=a===void 0?!0:a,u=f===void 0?!1:f,b=r===void 0?"Settings":r,[l,o]=X(le),w=u?"disabled":"hint-green",j;e[0]===Symbol.for("react.memo_cache_sentinel")?(j=(0,s.jsx)(Y,{strokeWidth:1.8}),e[0]=j):j=e[0];let m;e[1]===b?m=e[2]:(m=(0,s.jsx)(U,{content:b,children:j}),e[1]=b,e[2]=m);let c;e[3]!==u||e[4]!==w||e[5]!==m?(c=(0,s.jsx)(G,{"aria-label":"Config","data-testid":"app-config-button",shape:"circle",size:"small",className:"h-[27px] w-[27px]",disabled:u,color:w,children:m}),e[3]=u,e[4]=w,e[5]=m,e[6]=c):c=e[6];let n=c,d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsxs)(Ce,{className:"w-[90vw] h-[90vh] overflow-hidden sm:max-w-5xl top-[5vh] p-0",children:[(0,s.jsx)(be,{children:(0,s.jsx)(ye,{children:"User settings"})}),(0,s.jsx)(te,{})]}),e[7]=d):d=e[7];let x=d;if(!i){let T;e[8]===n?T=e[9]:(T=(0,s.jsx)(Ne,{children:n}),e[8]=n,e[9]=T);let q;return e[10]!==o||e[11]!==l||e[12]!==T?(q=(0,s.jsxs)(K,{open:l,onOpenChange:o,children:[T,x]}),e[10]=o,e[11]=l,e[12]=T,e[13]=q):q=e[13],q}let h;e[14]===n?h=e[15]:(h=(0,s.jsx)(de,{asChild:!0,children:n}),e[14]=n,e[15]=h);let y,N;e[16]===Symbol.for("react.memo_cache_sentinel")?(y=(0,s.jsx)(Ee,{}),N=(0,s.jsx)("div",{className:"h-px bg-border my-2"}),e[16]=y,e[17]=N):(y=e[16],N=e[17]);let v;e[18]===o?v=e[19]:(v=()=>o(!0),e[18]=o,e[19]=v);let C;e[20]===Symbol.for("react.memo_cache_sentinel")?(C=(0,s.jsx)(Y,{strokeWidth:1.8,className:"w-4 h-4 mr-2"}),e[20]=C):C=e[20];let g;e[21]===v?g=e[22]:(g=(0,s.jsxs)(he,{className:"w-[650px] overflow-auto max-h-[80vh] max-w-[80vw]",align:"end",side:"bottom",onFocusOutside:Re,children:[y,N,(0,s.jsxs)(xe,{onClick:v,variant:"link",className:"px-0",children:[C,"User settings"]})]}),e[21]=v,e[22]=g);let k;e[23]!==g||e[24]!==h?(k=(0,s.jsxs)(me,{children:[h,g]}),e[23]=g,e[24]=h,e[25]=k):k=e[25];let p;e[26]!==o||e[27]!==l?(p=(0,s.jsx)(K,{open:l,onOpenChange:o,children:x}),e[26]=o,e[27]=l,e[28]=p):p=e[28];let _;return e[29]!==k||e[30]!==p?(_=(0,s.jsxs)(s.Fragment,{children:[k,p]}),e[29]=k,e[30]=p,e[31]=_):_=e[31],_};function Re(t){return t.preventDefault()}export{Me as n,Se as r,Qe as t};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./loro_wasm_bg-B9rbCmxT.js","./loro_wasm_bg-BFCm9sQd.js","./chunk-LvLJmgfZ.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var Ud=Object.defineProperty;var Ka=ee=>{throw TypeError(ee)};var Bd=(ee,H,we)=>H in ee?Ud(ee,H,{enumerable:!0,configurable:!0,writable:!0,value:we}):ee[H]=we;var g=(ee,H,we)=>Bd(ee,typeof H!="symbol"?H+"":H,we),Pd=(ee,H,we)=>H.has(ee)||Ka("Cannot "+we);var Xa=(ee,H,we)=>(Pd(ee,H,"read from private field"),we?we.call(ee):H.get(ee)),Ya=(ee,H,we)=>H.has(ee)?Ka("Cannot add the same private member more than once"):H instanceof WeakSet?H.add(ee):H.set(ee,we);import{s as Za}from"./chunk-LvLJmgfZ.js";import{d as Qa,f as Cr,i as Y,l as In,n as ie,p as Pt,s as An,u as se}from"./useEvent-D91BmmQi.js";import{t as jd}from"./react-Bj1aDYRI.js";import{$r as Md,$t as Sr,At as jt,B as ei,Bn as Rd,Cn as Gd,Ct as Jd,Dn as xr,Dt as Tn,E as Fn,Et as Ir,F as Wd,Gi as Ln,Gn as Vd,H as $d,Hn as Hd,Ht as ti,Ii as qd,K as ni,Kn as zd,Ni as ri,Nt as Kd,Ot as Xd,Pn as Yd,Sn as Zd,Tt as Qd,U as oi,V as On,Vn as ef,Vt as tf,W as ai,Wn as ii,Xn as nf,Xt as Ar,Yn as rf,Yt as of,_n as af,an as sf,at as lf,bn as cf,ci as Tr,di as uf,en as si,er as df,fn as ff,gi as li,hi as mf,ht as pf,i as ci,in as gf,kt as hf,l as ui,ln as Dn,m as wt,mt as Fr,qi as Lr,qn as bf,rn as yf,si as wf,st as vf,tn as di,u as fi,ui as Ef,wn as Nf,wt as kf,xr as Cf,y as ot,__tla as Sf}from"./cells-
|
|
2
|
+
var Ud=Object.defineProperty;var Ka=ee=>{throw TypeError(ee)};var Bd=(ee,H,we)=>H in ee?Ud(ee,H,{enumerable:!0,configurable:!0,writable:!0,value:we}):ee[H]=we;var g=(ee,H,we)=>Bd(ee,typeof H!="symbol"?H+"":H,we),Pd=(ee,H,we)=>H.has(ee)||Ka("Cannot "+we);var Xa=(ee,H,we)=>(Pd(ee,H,"read from private field"),we?we.call(ee):H.get(ee)),Ya=(ee,H,we)=>H.has(ee)?Ka("Cannot add the same private member more than once"):H instanceof WeakSet?H.add(ee):H.set(ee,we);import{s as Za}from"./chunk-LvLJmgfZ.js";import{d as Qa,f as Cr,i as Y,l as In,n as ie,p as Pt,s as An,u as se}from"./useEvent-D91BmmQi.js";import{t as jd}from"./react-Bj1aDYRI.js";import{$r as Md,$t as Sr,At as jt,B as ei,Bn as Rd,Cn as Gd,Ct as Jd,Dn as xr,Dt as Tn,E as Fn,Et as Ir,F as Wd,Gi as Ln,Gn as Vd,H as $d,Hn as Hd,Ht as ti,Ii as qd,K as ni,Kn as zd,Ni as ri,Nt as Kd,Ot as Xd,Pn as Yd,Sn as Zd,Tt as Qd,U as oi,V as On,Vn as ef,Vt as tf,W as ai,Wn as ii,Xn as nf,Xt as Ar,Yn as rf,Yt as of,_n as af,an as sf,at as lf,bn as cf,ci as Tr,di as uf,en as si,er as df,fn as ff,gi as li,hi as mf,ht as pf,i as ci,in as gf,kt as hf,l as ui,ln as Dn,m as wt,mt as Fr,qi as Lr,qn as bf,rn as yf,si as wf,st as vf,tn as di,u as fi,ui as Ef,wn as Nf,wt as kf,xr as Cf,y as ot,__tla as Sf}from"./cells-C3u7zgmc.js";import{B as xf,N as If,P as Or,R as mi,S as Af,T as pi,k as Tf,w as Ff}from"./zod-H_cgTO0M.js";import{t as Ee}from"./compiler-runtime-B3qBwwSJ.js";import{C as Lf,f as Of,m as Df,p as _f,t as Uf,v as Bf,w as Pf}from"./ai-model-dropdown-9Z73_iYD.js";import{_ as He,c as gi,h as Dr,t as jf,v as Mf}from"./useEventListener-BakX-tnw.js";import{t as Mt}from"./invariant-C2E8KCbD.js";import{_ as hi,c as Rf,g as bi,h as yi,l as wi,w as _r}from"./utils-Dev6I_Kv.js";import{S as vi,T as Gf,m as Jf,o as Wf,r as Ei,v as vt,w as Rt}from"./config-3clPIEB9.js";import{n as Vf,t as $f}from"./switch-DvDNxcZP.js";import{n as Hf}from"./globals-Bx8Km3LH.js";import{t as qf}from"./ErrorBoundary-Bo313Z9X.js";import{t as Qe}from"./cn-X2M2usMq.js";import{t as zf}from"./jsx-runtime-PbYoItBR.js";import{l as Kf,r as Xf,t as Yf}from"./popover-DMNO6Poc.js";import{X as Zf,Z as Qf,__tla as em}from"./JsonOutput-DWLzjQfH.js";import{t as Ur}from"./label-CFvCMYuj.js";import{r as tm}from"./download-CIPflXYw.js";import{t as _n}from"./tooltip-CgQpRVyN.js";import{r as Br,t as ut}from"./button-BF7GSjhW.js";import{$t as Gt,E as nm,Et as rm,H as Ni,Ht as Et,I as om,Jt as am,Kt as dt,Lt as Pr,P as im,Pt as sm,St as lm,Tt as ki,Ut as jr,V as Ci,Vt as cm,Wt as Jt,X as l,Xt as he,Zt as Xe,_ as um,a as dm,at as $,bt as fm,dt as Un,ht as mm,kt as pm,lt as gm,m as hm,mt as bm,nn as Bn,ot as ym,st as M,ut as et,w as wm,wt as qe,xt as vm,zt as Pn}from"./dist-Dez1I5M9.js";import{E as Em,P as Nm,S as km,a as Cm,b as Sm,c as xm,n as Mr,r as Im,w as Am,x as Tm}from"./dist-CwfKvuyQ.js";import{o as Si}from"./arrays-DWxvyYxP.js";import{n as Fm}from"./once-CXj_gH7S.js";import{t as Rr}from"./createReducer-3wF4dU7I.js";import{a as Lm,c as Om,f as jn,h as Dm,i as _m,l as Wt,n as xi,o as Um,t as Bm}from"./dist-B0WqBUnf.js";import{t as Pm}from"./main-DmhaVp6Y.js";import{r as Mn,t as jm}from"./requests-KshNNAOp.js";import{t as Mm}from"./createLucideIcon-BTp1tQDO.js";import{r as Ii,t as Rm,__tla as Gm}from"./layout-CoL1gz3N.js";import{t as Jm}from"./x-9vLEgLY6.js";import{t as Wm}from"./circle-check-Q2N68uwG.js";import{A as Vm,E as Ai,L as $m,M as Hm,P as qm,R as zm,T as Km,a as Ti,d as Xm,n as Ym,o as Zm,r as Fi,s as Qm,x as ep}from"./add-cell-with-ai-Brj954XD.js";import{r as tp,t as np}from"./file-icons-BgqEa5XP.js";import{n as rp}from"./spinner-BbI9qk88.js";import{n as Gr,t as Li}from"./useDeleteCell-DnDf7cie.js";import{t as Oi}from"./save-BNNMzGly.js";import{Y as op,Z as Di}from"./input-DB2LiTiQ.js";import{t as ap}from"./sparkles-COaEc8Qn.js";import{t as ip}from"./preload-helper-BW0IMuFq.js";import{a as sp}from"./dist-BtrqKtvn.js";import{t as Nt}from"./use-toast-kCNiuc-_.js";import{n as tt}from"./paths-DhuNSnZ_.js";import{t as lp}from"./session-CsT5Gg9j.js";import{r as cp}from"./useTheme-D_ZbTTJw.js";import{n as _i}from"./copy-D8MtpXgN.js";import{k as up}from"./usePress-BSFUeqnS.js";import{a as dp}from"./useRunCells-B8rJ_Hwq.js";import{c as Ui,i as Bi,n as Pi,r as fp}from"./dialog-DkJmIrsG.js";import{t as ji}from"./useHotkey-CJo8iX8v.js";import{n as Mi}from"./ImperativeModal-B62Q6S9l.js";import{i as mp}from"./errors-9jMmWHd9.js";import{t as K}from"./extends-CeSFM22p.js";import{t as Vt}from"./objectWithoutPropertiesLoose-BkUn3I0-.js";import{t as pp}from"./kbd-UVzWBHfi.js";import{a as Jr}from"./useInstallPackage-C1Dd0aIZ.js";import{i as gp,n as Ri}from"./state-B_ZdzCIe.js";import{a as hp,o as bp}from"./cell-link-k224YmrQ.js";import{r as Gi}from"./html-to-image-CtinlkZr.js";import{a as yp}from"./focus-CAC_Hef8.js";import{n as wp}from"./useAsyncData-DAQcLiyE.js";import{a as vp,o as Ji,r as Ep,s as Wi,t as Np}from"./command-DRHbYHUP.js";import{a as Vi}from"./renderShortcut-LpVarhnQ.js";import{n as kp,t as Cp}from"./icons-avFV3lBF.js";import{n as kt}from"./esm-X3Tr2pur.js";import{t as $i}from"./dist-UghNT0W0.js";import{t as Sp}from"./useSplitCell-DVuFaOkR.js";import{co as xp,do as Wr,fo as Ip,ft as Ap,go as Ct,ho as Hi,lo as Vr,mo as qi,oo as Tp,po as Fp,so as zi,uo as Ki,__tla as Lp}from"./loro_wasm_bg-BFCm9sQd.js";import{t as Op}from"./ws-DSN-Rmiu.js";import{t as Xi}from"./Inputs-SmI80aJQ.js";import{n as Dp}from"./hooks-Q3y983ON.js";let $r,$t,Rn,Gn,Jn,Hr,Ne,Yi,Zi,Qi,es,qr,zr,ft,ts,ns,rs,Ht,Wn,os,_p=Promise.all([(()=>{try{return Sf}catch{}})(),(()=>{try{return em}catch{}})(),(()=>{try{return Gm}catch{}})(),(()=>{try{return Lp}catch{}})()]).then(async()=>{var Cn,Va,Ce,Se,xe,Ie,Ae,Te,Fe,Le,Oe,De,_e,Ue,Be,Pe,je,Me,Re,Ge,Je;var ee=Mm("file-pen",[["path",{d:"M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34",key:"o6klzx"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z",key:"zhnas1"}]]);const H={showInput:"Mod-l",acceptEdit:"Mod-y",rejectEdit:"Mod-u"};var we=300;const xt=Jt.define({combine:e=>Bn(e,{onError:console.error,inputDebounceTime:we,keymaps:H},{onError:(t,n)=>t&&n,inputDebounceTime:(t,n)=>t&&n,keymaps:(t,n)=>t&&n})}),at=he.define(),it=Xe.define({create(){return{show:!1,lineFrom:0,lineTo:0}},update(e,t){for(let n of t.effects)if(n.is(at))return n.value;return e}}),It=he.define(),At=he.define(),Xr=Xe.define({create(){return{shouldFocus:!1,inputValue:""}},update(e,t){let n=e;for(let r of t.effects)r.is(It)&&(n={...n,inputValue:r.value}),r.is(At)&&(n={...n,shouldFocus:r.value});return n}}),qt=he.define(),Tt=Xe.define({create(){return null},update(e,t){for(let n of t.effects)if(n.is(qt))return n.value;return e}}),mt=he.define(),Yr=Xe.define({create(){return!1},update(e,t){for(let n of t.effects)if(n.is(mt))return n.value;return e}});var as=1;const Zr=e=>{let{state:t}=e,n=t.selection.main;if(n.empty)return!1;let r=t.doc,o=r.lineAt(n.from),a=r.lineAt(n.to);if(t.sliceDoc(o.from,a.to).trim().length<as)return!1;let i=Math.max(1,Math.min(o.number,r.lines)),s=Math.max(1,Math.min(a.number,r.lines));return e.dispatch({effects:[at.of({show:!0,lineFrom:i,lineTo:s}),At.of(!0),It.of("")],selection:Et.cursor(o.from)}),!0},Qr=e=>e.state.field(Tt)?(e.dispatch({effects:[qt.of(null),at.of({show:!1,lineFrom:0,lineTo:0}),At.of(!1),It.of(""),mt.of(!1)]}),!0):!1,eo=e=>{let t=e.state.field(Tt);return t?(e.dispatch({changes:{from:t.from,to:t.to,insert:t.oldCode},effects:[qt.of(null),at.of({show:!1,lineFrom:0,lineTo:0}),At.of(!1),It.of(""),mt.of(!1)]}),!0):!1};var Vn={mac:"\u2318",windows:"\u229E Win",default:"Ctrl"};function is(){return navigator.platform.startsWith("Mac")?Vn.mac:navigator.platform.startsWith("Win")?Vn.windows:Vn.default}function $n(e){return e.replace("Mod",is()).replace("-"," ").toUpperCase()}function me(e,t){let n=document.createElement(e);return n.className=t,n}function ss(e,t,n=void 0){let r=()=>{};return(...o)=>(r(),new Promise((a,i)=>{let s=setTimeout(()=>a(e(...o)),t);r=()=>{clearTimeout(s),n!==void 0&&i(n)}}))}var zt=Xe.define({create(){return{suggestion:null}},update(e,t){let n=t.effects.find(r=>r.is(Kt));return!t.docChanged&&!n&&!t.selection?e:n&&t.state.doc===n.value.doc?{suggestion:n.value.text}:{suggestion:null}}}),Kt=he.define();function ls(e,t){let n=e.state.selection.main.head,r=[],o=$.widget({widget:new cs(t),side:1});return r.push(o.range(n)),$.set(r)}var cs=class extends Un{constructor(t){super();g(this,"suggestion");this.suggestion=t}toDOM(){let t=document.createElement("span");return t.style.opacity="0.4",t.className="cm-inline-suggestion",t.textContent=this.suggestion,t.setAttribute("role","suggestion"),t.setAttribute("aria-label",`Suggestion: ${this.suggestion}`),t}get lineBreaks(){return this.suggestion.split(`
|
|
3
3
|
`).length-1}},us=class{constructor(e){g(this,"cache",new Map);g(this,"timeout");this.timeout=e}get(e){let t=this.cache.get(e);return t?Date.now()-t.timestamp>this.timeout?(this.cache.delete(e),null):t.result:null}set(e,t){this.cache.set(e,{result:t,timestamp:Date.now()})}},ds=(e,t)=>et.fromClass(class{constructor(){g(this,"abortController",null);g(this,"cache");this.cache=new us(t.cacheTimeout??1e3)}async update(n){var i,s,u,c,d;if(!n.docChanged||((s=(i=t.events)==null?void 0:i.beforeSuggestionFetch)==null?void 0:s.call(i,n.view))===!1)return;(u=this.abortController)==null||u.abort(),this.abortController=new AbortController;let r=n.state.doc,o=r.toString(),a=this.cache.get(o);if(a){n.view.dispatch({effects:Kt.of({text:a,doc:r})});return}try{let f=await e(n.state,this.abortController.signal,n.view);if(this.abortController.signal.aborted||((d=(c=t.events)==null?void 0:c.shouldShowSuggestion)==null?void 0:d.call(c,n.view,f))===!1)return;this.cache.set(o,f),n.view.dispatch({effects:Kt.of({text:f,doc:r})})}catch(f){f instanceof Error&&f.name!=="AbortError"&&console.error("Suggestion fetch error:",f)}}destroy(){var n;(n=this.abortController)==null||n.abort()}}),fs=et.fromClass(class{constructor(){g(this,"decorations");this.decorations=$.none}update(e){var n;let t=(n=e.state.field(zt))==null?void 0:n.suggestion;if(!t){this.decorations=$.none;return}this.decorations=ls(e.view,t)}},{decorations:e=>e.decorations});function ms(e,t,n,r){return{...e.changeByRange(o=>{if(o===e.selection.main)return{changes:{from:n,to:r,insert:t},range:Et.cursor(n+t.length)};let a=r-n;return!o.empty||a&&e.sliceDoc(o.from-a,o.from)!==e.sliceDoc(n,r)?{range:o}:{changes:{from:o.from-a,to:o.from,insert:t},range:Et.cursor(o.from-a+t.length)}}),userEvent:"input.complete"}}var ps=e=>{var r,o,a;let t=(r=e.state.field(zt))==null?void 0:r.suggestion;if(!t)return!1;let n=e.state.facet(Hn);return e.dispatch({...ms(e.state,t,e.state.selection.main.head,e.state.selection.main.head)}),(a=(o=n.events)==null?void 0:o.onSuggestionAccepted)==null||a.call(o,e,t),!0},to=e=>{var r,o,a;let t=(r=e.state.field(zt))==null?void 0:r.suggestion;if(!t)return!1;let n=e.state.facet(Hn);return e.dispatch({effects:Kt.of({text:null,doc:e.state.doc})}),(a=(o=n.events)==null?void 0:o.onSuggestionRejected)==null||a.call(o,e,t),!0},gs=qe.of([{key:"Tab",run:ps},{key:"Escape",run:to}]),Hn=Jt.define({combine:e=>e.at(-1)});function no(e){let{delay:t=500,includeKeymap:n=!0}=e,r=ss(e.fetchFn,t);return[zt,Hn.of(e),ds(r,e),fs,n?gs:[]]}const hs=M.baseTheme({".cm-ai-input-container":{display:"flex",flexDirection:"column",gap:"4px",width:"min(calc(100% + 7px), 500px)",padding:"5px 5px",margin:"0 -6px",backgroundColor:"light-dark(rgb(241, 243, 245), rgb(40, 40, 40))"},".cm-ai-input":{display:"block",width:"100%",padding:"3px 8px",border:"2px solid rgb(51, 154, 240)",borderRadius:"5px",fontSize:"12px"},".cm-ai-help-info-button":{fontSize:"10px",paddingLeft:"10px",height:"18px",color:"light-dark(rgb(109, 117, 125), rgb(170, 170, 170))",display:"block",marginRight:"auto"},".cm-ai-help-info-button:hover":{color:"light-dark(rgb(89, 97, 105), rgb(190, 190, 190))"},".cm-ai-generate-button":{background:"#0E639C",border:"none",padding:"2px 6px",color:"#ffffff",cursor:"pointer",font:"inherit",borderRadius:"4px","&:hover":{backgroundColor:"#1177bb"}},".cm-line.cm-ai-selection, .cm-line.cm-ai-selection.cm-active-line":{backgroundColor:"light-dark(color-mix(in srgb, rgb(223, 227, 232) 50%, transparent), color-mix(in srgb, rgb(50, 50, 50) 50%, transparent)) !important"},".cm-line:has(.cm-new-code-line)":{backgroundColor:"light-dark(color-mix(in srgb, rgb(183, 235, 143) 50%, transparent), color-mix(in srgb, rgb(40, 100, 40) 50%, transparent)) !important"},".cm-old-code-container":{backgroundColor:"light-dark(rgb(255, 205, 205), rgb(100, 40, 40))",position:"relative",display:"flex",paddingTop:"0",width:"100%",alignItems:"center"},".cm-code-button":{position:"absolute",right:"5px",top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",fontSize:"16px"},".cm-floating-buttons":{fontFamily:"sans-serif",position:"absolute",top:"-20px",left:"5px",display:"flex"},".cm-floating-button":{fontFamily:"sans-serif",padding:"2px 5px",fontSize:"10px",cursor:"pointer",fontWeight:"700"},".cm-floating-accept":{backgroundColor:"light-dark(rgb(55, 125, 34), rgb(40, 80, 25))",borderTopLeftRadius:"5px",borderBottomLeftRadius:"5px",color:"white",filter:"brightness(90%)","&:hover":{filter:"brightness(100%)"}},".cm-floating-reject":{backgroundColor:"light-dark(rgb(220, 53, 69), rgb(180, 40, 50))",color:"white",borderTopRightRadius:"5px",borderBottomRightRadius:"5px",filter:"brightness(90%)","&:hover":{filter:"brightness(100%)"}},".hotkey":{display:"inline-block",padding:"0 4px",borderRadius:"3px",backgroundColor:"rgba(255, 255, 255, 0.1)",fontSize:"90%"},".cm-ai-loading-indicator":{fontStyle:"italic",fontSize:"10px",paddingLeft:"12px",color:"light-dark(rgb(109, 117, 125), rgb(170, 170, 170))",opacity:"0",transition:"opacity 0.3s ease-in-out","&::after":{content:'""',display:"inline-block",animation:"ellipsis-pulse 1.5s steps(4, end) infinite"},"&:not(:empty)":{opacity:"1"}},".cm-ai-input:disabled":{opacity:"0.5"},"@keyframes ellipsis-pulse":{"0%":{content:"'.'"},"25%":{content:"'..'"},"50%":{content:"'...'"},"75%":{content:"''"}},".cm-ai-loading-container":{display:"flex",alignItems:"center",padding:"0 8px"},".cm-ai-cancel-button":{padding:"2px 8px",fontSize:"10px",borderRadius:"4px",color:"light-dark(rgb(109, 117, 125), rgb(170, 170, 170))",cursor:"pointer","&:hover":{background:"light-dark(rgb(223, 227, 232), rgb(50, 50, 50))"}},".hidden":{display:"none"}});function bs(e){var s,u;let t=e.state.facet(xt),n={...H,...t.keymaps},r=e.state.facet(Xt),o=me("div","cm-ai-tooltip").appendChild(me("div","cm-ai-tooltip-button")),a=o.appendChild(document.createElement("span"));a.textContent=`${r.label} `;let i=a.appendChild(document.createElement("span"));return i.className="hotkey",i.textContent=$n(n.showInput),(s=o.querySelector("span"))==null||s.addEventListener("mousedown",c=>{c.stopPropagation(),c.button===0&&c.preventDefault()}),(u=o.querySelector("span"))==null||u.addEventListener("click",c=>{c.preventDefault(),Zr(e)}),o}const Xt=Jt.define({combine(e){return Bn(e,{render:bs,hideOnBlur:!1,label:"Edit with AI"})}}),ys=et.fromClass((Va=class{constructor(e){g(this,"view");g(this,"suppress");g(this,"dom");g(this,"mousedown",()=>{this.suppress=!0});g(this,"mouseup",()=>{this.suppress=!1,this.display(this.view)});g(this,"scroll",()=>{this.display(this.view)});g(this,"windowScroll",()=>{this.display(this.view)});Ya(this,Cn,e=>{var n;let t=e.state.selection.ranges.find(r=>!r.empty);if(t&&!this.suppress){let r=e.coordsAtPos(t.from),o=e.coordsAtPos(t.to);if(!r||!o)return;let a=e.dom.getBoundingClientRect(),i=(n=e.dom.parentElement)==null?void 0:n.getBoundingClientRect(),s=E=>E.top>=a.top&&E.top<=a.bottom&&E.left>=a.left&&E.left<=a.right,u=E=>!i||E.top>=i.top&&E.top<=i.bottom&&E.left>=i.left&&E.left<=i.right,c=s(r)||s(o),d=u(r)||u(o);if(!c||!d){this.dom.style.display="none",this.dom.setAttribute("aria-hidden","true");return}this.dom.style.display="flex",this.dom.setAttribute("aria-hidden","false");let f=this.dom.getBoundingClientRect(),p=s(r)?r:o,m=a.right-f.width,h=Math.min(p.left,m),y=p.top-f.height,w=i?i.y:-1/0;y<w&&(y=o.bottom),this.dom.style.left=`${h}px`,this.dom.style.top=`${y}px`,requestAnimationFrame(()=>{this.dom&&this.dom.setAttribute("aria-hidden","false")})}else this.dom.style.display="none",this.dom.setAttribute("aria-hidden","true")});this.view=e;let t=e.state.facet(Xt);this.suppress=!1,document.addEventListener("mousedown",this.mousedown),document.addEventListener("mouseup",this.mouseup),e.scrollDOM.addEventListener("scroll",this.scroll),window.addEventListener("scroll",this.windowScroll,!0);let n=t.render(e);e.dom.appendChild(n),this.dom=n}update(e){this.display(e.view)}docViewUpdate(e){this.display(e)}display(e){if(e.state.field(it).show){this.dom.style.display="none";return}if(e.state.facet(Xt).hideOnBlur&&!e.hasFocus){this.dom.style.display="none",this.dom.setAttribute("aria-hidden","true");return}e.requestMeasure({read:Xa(this,Cn)})}destroy(){document.removeEventListener("mousedown",this.mousedown),document.removeEventListener("mouseup",this.mouseup),this.view.scrollDOM.removeEventListener("scroll",this.scroll),window.removeEventListener("scroll",this.windowScroll,!0),this.dom.remove()}},Cn=new WeakMap,Va));var ws=M.baseTheme({".cm-ai-tooltip-button":{userSelect:"none",fontFamily:"system-ui, -apple-system, sans-serif",position:"fixed",display:"flex",boxSizing:"border-box",padding:"2px 6px",borderRadius:"4px",fontSize:"12px",backgroundColor:"#0E639C",color:"#ffffff",border:"1px solid transparent",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",zIndex:"999",transition:"opacity 0.5s","&[aria-hidden='true']":{opacity:"0"},"&[aria-hidden='false']":{opacity:"1"},"& > span":{pointerEvents:"auto",cursor:"pointer",display:"inline-block",padding:"2px"},"&:hover":{backgroundColor:"#1177bb"}}});function vs(){return[ys,ws]}var Es=class extends Un{constructor(t){super();g(this,"oldCode");this.oldCode=t}toDOM(t){let n=me("div","cm-old-code-container");n.setAttribute("role","region"),n.setAttribute("aria-label","Previous code version");let r=me("div","cm-old-code cm-line");r.textContent=this.oldCode;let o=me("div","cm-floating-buttons"),a=t.state.facet(xt),i={...H,...a.keymaps},s=me("button","cm-floating-button cm-floating-accept");s.innerHTML=`<span class="hotkey">${$n(i.acceptEdit)}</span> Accept`,s.setAttribute("aria-label","Accept changes"),s.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),t.focus(),Qr(t)});let u=me("button","cm-floating-button cm-floating-reject");return u.innerHTML=`<span class="hotkey">${$n(i.rejectEdit)}</span> Reject`,u.setAttribute("aria-label","Reject changes"),u.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),t.focus(),eo(t)}),o.append(s,u),n.append(r,o),n}updateDOM(t,n){return!0}},Ns=class extends Un{constructor(t){super();g(this,"complete");g(this,"abortController",null);g(this,"dom",null);g(this,"input",null);g(this,"loadingContainer",null);g(this,"helpInfo",null);g(this,"inputContainer",null);g(this,"form",null);g(this,"view",null);g(this,"onKeyDown",async t=>{t.key==="Enter"&&!t.shiftKey?(t.preventDefault(),await this.handleSubmit()):t.key==="Escape"&&this.onCancel()});g(this,"onCancel",()=>{this.cleanup();let t=this.view;t&&(t.dispatch({effects:[at.of({show:!1,lineFrom:0,lineTo:0}),mt.of(!1)]}),t.focus())});g(this,"handleSubmit",async t=>{var h;let n=this.view;if(!n)return;let r=n.state.facet(xt);t==null||t.stopPropagation();let o=n.state.field(it),{input:a}=this;if(!a)return;let i=a.value.trim();if(!o.show||!i)return;let s=n.state.doc.line(o.lineFrom),u=n.state.doc.line(o.lineTo),c=s.from,d=u.to,f=n.state.sliceDoc(c,d),p=n.state.sliceDoc(0,c),m=n.state.sliceDoc(d);this.abortController=new AbortController,n.dispatch({effects:mt.of(!0)}),this.toggleLoading(!0);try{let y=await this.complete({prompt:i,selection:f,codeBefore:p,codeAfter:m,editorView:n,signal:this.abortController.signal});if(!n.state.field(it).show)return;if(!y||typeof y!="string")throw Error("Invalid completion result");n.dispatch({changes:{from:c,to:d,insert:y},effects:[at.of({show:!1,lineFrom:0,lineTo:0}),qt.of({from:c,to:c+y.length,oldCode:f,newCode:y}),mt.of(!1)]})}catch(y){if(y instanceof DOMException&&y.name==="AbortError")return;(h=r.onError)==null||h.call(r,y)}finally{this.cleanup(),this.toggleLoading(!1),n.focus()}});this.complete=t}toDOM(t){if(this.dom)return this.dom;this.view=t;let n=t.state.field(Xr),r=t.state.field(Yr),o=me("div","cm-ai-input-container");this.inputContainer=o,this.dom=o;let a=me("form","cm-ai-input-form");this.form=a,a.setAttribute("role","search"),a.setAttribute("aria-label","AI editing instructions"),a.addEventListener("submit",w=>w.preventDefault());let i=me("input","cm-ai-input");this.input=i,a.append(i),i.placeholder="Editing instructions...",i.setAttribute("aria-label","AI editing instructions"),i.setAttribute("autocomplete","off"),i.setAttribute("spellcheck","true"),i.value=n.inputValue;let s=me("div","cm-ai-loading-container");this.loadingContainer=s;let u=me("div","cm-ai-loading-indicator");u.setAttribute("role","status"),u.setAttribute("aria-live","polite"),u.textContent="Generating";let c=me("button","cm-ai-cancel-button");c.textContent="Cancel",c.setAttribute("aria-label","Cancel code generation"),c.addEventListener("click",this.onCancel),s.append(c,u);let d=me("div","cm-ai-help-info");this.helpInfo=d;let f=d.appendChild(document.createElement("button"));f.className="cm-ai-help-info-button",f.textContent="Esc to close",f.addEventListener("click",this.onCancel);let p=me("button","cm-ai-generate-button");p.textContent="\u23CE Generate",p.setAttribute("aria-label","Generate code"),p.addEventListener("click",this.handleSubmit),this.toggleLoading(r),n.shouldFocus&&requestAnimationFrame(()=>{i.value=n.inputValue,i.focus(),t.dispatch({effects:At.of(!1)})}),m(i.value),i.addEventListener("input",y),i.addEventListener("keydown",this.onKeyDown);function m(w){d.replaceChildren(w?p:f)}let h="";function y(){t.dispatch({effects:It.of(i.value)});let w=i.value.trim();w!==h&&(h=w,m(w))}return o}toggleLoading(t){var n;this.inputContainer&&this.form&&this.loadingContainer&&this.helpInfo&&((n=this.inputContainer)==null||n.replaceChildren(this.form,t?this.loadingContainer:this.helpInfo))}updateDOM(t,n){return this.dom=t,this.input=t.querySelector(".cm-ai-input"),!0}cleanup(){var t,n,r;(t=this.abortController)==null||t.abort(),this.abortController=null,(n=this.dom)==null||n.remove(),(r=this.input)==null||r.remove(),this.dom=null,this.input=null}destroy(){this.cleanup()}};function ks(e){if(!e.prompt)throw Error("prompt function is required");let t={...H,...e.keymaps};return[xt.of(e),it,Xr,Tt,Yr,vs(),hs,qe.of([{key:t.showInput,run:Zr}]),dt.highest([qe.of([{key:t.acceptEdit,run:Qr},{key:t.rejectEdit,run:eo}])]),Cs,Ss,xs,Is]}const Cs=M.updateListener.of(e=>{let t=e.state.field(it);if(!t.show||!e.docChanged)return;let{lineFrom:n,lineTo:r}=t,o=!1;e.changes.iterChanges((a,i,s,u)=>{let c=e.state.doc.lineAt(a).number;if(c<n){let d=e.state.doc.lineAt(u).number-e.state.doc.lineAt(s).number;n+=d,r+=d,o=!0}else if(c<=r){let d=e.state.doc.lineAt(u).number-e.state.doc.lineAt(s).number;r+=d,o=!0}}),o&&e.view.dispatch({effects:[at.of({show:!0,lineFrom:n,lineTo:r})]})}),Ss=M.decorations.of(e=>{let t=e.state.field(Tt);return t?$.set([$.mark({class:"cm-new-code-line"}).range(t.from,t.to)]):$.none}),xs=M.decorations.compute([it],e=>{let t=e.field(it),n=e.facet(xt),r=[];if(t.show){let o=t.lineFrom,a=t.lineTo;for(let i=o;i<=a;i++){let s=e.doc.line(i).from;r.push($.line({class:"cm-ai-selection"}).range(s)),i===o&&r.push($.widget({widget:new Ns(n.prompt),side:-1}).range(s))}}return $.set(r)}),Is=Xe.define({create(e){return $.none},update(e,t){let n=t.state.field(Tt);return n?$.set([$.widget({widget:new Es(n.oldCode),block:!0}).range(n.from)]):$.none},provide:e=>M.decorations.from(e)});var As=Ee(),A=Za(jd(),1),qn=()=>({entries:new Map}),{valueAtom:ro,useActions:oo}=Rr(qn,{submit:(e,t)=>{let{cellIds:n,deleteCell:r,deleteManyCells:o,store:a}=t,i=a.get(ot),s=a.get(Rd),u=new Set(i.cellIds.inOrderIds.filter(f=>i.cellData[f].code.trim()==="")),c=new Map;for(let f of n){if(u.has(f)){c.set(f,{cellId:f,type:"simple"});continue}let p=i.cellRuntime[f],m=new Map;for(let y of Object.values(s)){let w=y.declaredBy.includes(f),E=y.usedBy.some(C=>!u.has(C));w&&E&&m.set(y.name,y.usedBy)}let h;p!=null&&p.runElapsedTimeMs&&p.runElapsedTimeMs>2e3&&(h=p.runElapsedTimeMs),m.size===0&&h===void 0?c.set(f,{cellId:f,type:"simple"}):c.set(f,{cellId:f,type:"expensive",executionDurationMs:h,defs:m})}let d=[...c.values()].every(f=>f.type==="simple");return c.size>0&&d?(c.size===1?r({cellId:[...c.values()][0].cellId}):o({cellIds:[...c.values()].map(f=>f.cellId)}),qn()):{...e,entries:c}},clear:()=>qn()});Rn=function(){let e=Cr(),{submit:t,clear:n}=oo(),{entries:r}=se(ro),o=Li(),a=Gr();return(0,A.useMemo)(()=>({submit:i=>{t({cellIds:i,deleteCell:o,deleteManyCells:a,store:e})},clear:n,get idle(){return r.size===0},get shouldConfirmDelete(){return r.size>1}}),[e,t,n,r,o,a])},os=function(e){let t=(0,As.c)(16),n=se(ro),r=oo(),o=Gr(),a;t[0]!==e||t[1]!==n.entries?(a=n.entries.get(e),t[0]=e,t[1]=n.entries,t[2]=a):a=t[2];let i=a;if(!i){let d;return t[3]===Symbol.for("react.memo_cache_sentinel")?(d={isPending:!1},t[3]=d):d=t[3],d}if(n.entries.size!==1){let d;return t[4]===i?d=t[5]:(d={isPending:!0,shouldConfirmDelete:!1,...i},t[4]=i,t[5]=d),d}let s;t[6]!==r||t[7]!==o||t[8]!==n.entries?(s=()=>{o({cellIds:[...n.entries.values()].map(Ts)}),r.clear()},t[6]=r,t[7]=o,t[8]=n.entries,t[9]=s):s=t[9];let u;t[10]===r?u=t[11]:(u=()=>r.clear(),t[10]=r,t[11]=u);let c;return t[12]!==i||t[13]!==s||t[14]!==u?(c={isPending:!0,...i,shouldConfirmDelete:!0,confirm:s,cancel:u},t[12]=i,t[13]=s,t[14]=u,t[15]=c):c=t[15],c};function Ts(e){return e.cellId}var ao=["python","sql","markdown"];function zn(e,t={}){var c;let{streaming:n=!1}=t,r=((c=e.match(/^\s*/))==null?void 0:c[0])??"",o=e.slice(r.length),a=null,i=!1;for(let d of ao)if(o.startsWith(`\`\`\`${d}`)){i=!0,a=o.slice(3+d.length),a.startsWith(`
|
|
4
4
|
`)&&(a=a.slice(1));break}if(!i&&o.startsWith("```")){let d=o.slice(3);if(n&&Fs(d))return e;i=!0,a=d,a.startsWith(`
|
|
5
5
|
`)&&(a=a.slice(1))}if(!i||a===null)return e;if(n)return a;let s=a.trimEnd(),u=a.slice(s.length);return s.endsWith("\n```")?s.slice(0,-4)+u:s.endsWith("```")?s.slice(0,-3)+u:a}function Fs(e){return e.includes(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as L}from"./chunk-LvLJmgfZ.js";import{d as j,l as P,n as w,u as E}from"./useEvent-D91BmmQi.js";import{E as O,Gi as y,Lt as A,N as S,Ni as _,gn as T,j as $}from"./cells-
|
|
1
|
+
import{s as L}from"./chunk-LvLJmgfZ.js";import{d as j,l as P,n as w,u as E}from"./useEvent-D91BmmQi.js";import{E as O,Gi as y,Lt as A,N as S,Ni as _,gn as T,j as $}from"./cells-C3u7zgmc.js";import{t as b}from"./compiler-runtime-B3qBwwSJ.js";import{_ as D}from"./useEventListener-BakX-tnw.js";import{p as F}from"./utils-Dev6I_Kv.js";import{r as N}from"./constants-B9JJ72XE.js";import{v as q,w as B}from"./config-3clPIEB9.js";import{t as G}from"./cn-X2M2usMq.js";import{t as H}from"./jsx-runtime-PbYoItBR.js";import{r as K}from"./requests-KshNNAOp.js";import{n as M}from"./paths-DhuNSnZ_.js";import{s as R}from"./session-CsT5Gg9j.js";import{n as U}from"./ImperativeModal-B62Q6S9l.js";var V=b();function I(){return E(_)}function z(){let r=(0,V.c)(5),[t]=P(q),e=j(_),{openAlert:s}=U(),{sendRename:o}=K(),a;return r[0]!==t.state||r[1]!==s||r[2]!==o||r[3]!==e?(a=async l=>{let n=F();return t.state===B.OPEN?(R(i=>{l===null?i.delete(N.filePath):i.set(N.filePath,l)}),o({filename:l}).then(()=>(e(l),document.title=n.app_title||M.basename(l)||"Untitled Notebook",l)).catch(i=>(s(i.message),null))):(s("Failed to save notebook: not connected to a kernel."),null)},r[0]=t.state,r[1]=s,r[2]=o,r[3]=e,r[4]=a):a=r[4],w(a)}var p=b(),v=L(H(),1);const h=r=>{let t=(0,p.c)(12),{className:e,cellId:s,variant:o,onClick:a,formatCellName:l,skipScroll:n}=r,i=S()[s]??"",C=$().inOrderIds.indexOf(s),{showCellIfHidden:d}=O(),g=l??W,c;t[0]===e?c=t[1]:(c=G("inline-block cursor-pointer text-link hover:underline",e),t[0]=e,t[1]=c);let m;t[2]!==s||t[3]!==a||t[4]!==d||t[5]!==n||t[6]!==o?(m=k=>{if(s==="__scratch__")return!1;d({cellId:s}),k.stopPropagation(),k.preventDefault(),requestAnimationFrame(()=>{x(s,o,n)&&(a==null||a())})},t[2]=s,t[3]=a,t[4]=d,t[5]=n,t[6]=o,t[7]=m):m=t[7];let f=g(A(i,C)),u;return t[8]!==c||t[9]!==m||t[10]!==f?(u=(0,v.jsx)("div",{className:c,role:"link",tabIndex:-1,onClick:m,children:f}),t[8]=c,t[9]=m,t[10]=f,t[11]=u):u=t[11],u},J=r=>{let t=(0,p.c)(2),e;return t[0]===r?e=t[1]:(e=(0,v.jsx)(h,{...r,variant:"destructive"}),t[0]=r,t[1]=e),e},Q=r=>{let t=(0,p.c)(10),{cellId:e,lineNumber:s}=r,o=I(),a;t[0]!==e||t[1]!==s?(a=()=>T(e,s),t[0]=e,t[1]=s,t[2]=a):a=t[2];let l;t[3]!==e||t[4]!==o?(l=i=>e==="__scratch__"?"scratch":`marimo://${o||"untitled"}#cell=${i}`,t[3]=e,t[4]=o,t[5]=l):l=t[5];let n;return t[6]!==e||t[7]!==a||t[8]!==l?(n=(0,v.jsx)(h,{cellId:e,onClick:a,skipScroll:!0,variant:"destructive",className:"traceback-cell-link",formatCellName:l}),t[6]=e,t[7]=a,t[8]=l,t[9]=n):n=t[9],n};function x(r,t,e){let s=y.create(r),o=document.getElementById(s),a=o==null?void 0:o.classList.contains("has-error");return o===null?(D.error(`Cell ${s} not found on page.`),!1):(e||o.scrollIntoView({behavior:"smooth",block:"center"}),(t==="destructive"||a&&t===void 0)&&(o.classList.add("error-outline"),setTimeout(()=>{o.classList.remove("error-outline")},2e3)),(t==="focus"||!a&&t===void 0)&&(o.classList.add("focus-outline"),setTimeout(()=>{o.classList.remove("focus-outline")},2e3)),!0)}function W(r){return r}export{I as a,x as i,J as n,z as o,Q as r,h as t};
|
|
@@ -92,7 +92,7 @@ mark line col
|
|
|
92
92
|
`&&s8(this.cm6)}else console.log(n+" is not implemented")}setBookmark(n,a){var o=a!=null&&a.insertLeft?1:-1,s=this.indexFromPos(n);return new $3(this,s,o)}addOverlay({query:n}){let a=new d8({regexp:!0,search:n.source,caseSensitive:!/i/.test(n.flags)});if(a.valid){a.forVim=!0,this.cm6Query=a;let o=Zh.of(a);return this.cm6.dispatch({effects:o}),a}}removeOverlay(n){if(!this.cm6Query)return;this.cm6Query.forVim=!1;let a=Zh.of(this.cm6Query);this.cm6.dispatch({effects:a})}getSearchCursor(n,a){var o=this,s=null,c=null,f=!1;a.ch??(a.ch=Number.MAX_VALUE);var d=Ln(o.cm6.state.doc,a),m=n.source.replace(/(\\.|{(?:\d+(?:,\d*)?|,\d+)})|[{}]/g,function(E,T){return T||"\\"+E});function b(E,T=0,P=E.length){return new h8(E,m,{ignoreCase:n.ignoreCase},T,P)}function w(E){var T=o.cm6.state.doc;if(E>T.length)return null;let P=b(T,E).next();return P.done?null:P.value}var x=1e4;function S(E,T){var P=o.cm6.state.doc;for(let z=1;;z++){let B=Math.max(E,T-z*x),V=b(P,B,T),N=null;for(;!V.next().done;)N=V.value;if(N&&(B==E||N.from>B+10))return N;if(B==E)return null}}return{findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(E){var T=o.cm6.state.doc;return s=E?S(0,s?f?s.to-1:s.from:d):w(s?f?s.to+1:s.to:d),c=s&&{from:lr(T,s.from),to:lr(T,s.to),match:s.match},f=s?s.from==s.to:!1,s&&s.match},from:function(){return c==null?void 0:c.from},to:function(){return c==null?void 0:c.to},replace:function(E){s&&(ks(o,{changes:{from:s.from,to:s.to,insert:E}}),s.to=s.from+E.length,c&&(c.to=lr(o.cm6.state.doc,s.to)))},get match(){return c&&c.match}}}findPosV(n,a,o,s){let{cm6:c}=this,f=c.state.doc,d=o=="page"?c.dom.clientHeight:0,m=Ln(f,n),b=$t.cursor(m,1,void 0,s),w=Math.round(Math.abs(a));for(let S=0;S<w;S++)o=="page"?b=c.moveVertically(b,a>0,d):o=="line"&&(b=c.moveVertically(b,a>0));let x=lr(f,b.head);return(a<0&&b.head==0&&s!=0&&n.line==0&&n.ch!=0||a>0&&b.head==f.length&&x.ch!=s&&n.line==x.line)&&(x.hitSide=!0),x}charCoords(n,a){var o=this.cm6.contentDOM.getBoundingClientRect(),s=Ln(this.cm6.state.doc,n),c=this.cm6.coordsAtPos(s),f=-o.top;return{left:((c==null?void 0:c.left)||0)-o.left,top:((c==null?void 0:c.top)||0)+f,bottom:((c==null?void 0:c.bottom)||0)+f}}coordsChar(n,a){var o=this.cm6.contentDOM.getBoundingClientRect(),s=this.cm6.posAtCoords({x:n.left+o.left,y:n.top+o.top})||0;return lr(this.cm6.state.doc,s)}getScrollInfo(){var n=this.cm6.scrollDOM;return{left:n.scrollLeft,top:n.scrollTop,height:n.scrollHeight,width:n.scrollWidth,clientHeight:n.clientHeight,clientWidth:n.clientWidth}}scrollTo(n,a){n!=null&&(this.cm6.scrollDOM.scrollLeft=n),a!=null&&(this.cm6.scrollDOM.scrollTop=a)}scrollIntoView(n,a){if(n){var o=this.indexFromPos(n);this.cm6.dispatch({effects:Et.scrollIntoView(o)})}else this.cm6.dispatch({scrollIntoView:!0,userEvent:"scroll"})}getWrapperElement(){return this.cm6.dom}getMode(){return{name:this.getOption("mode")}}setSize(n,a){this.cm6.dom.style.width=n+4+"px",this.cm6.dom.style.height=a+"px",this.refresh()}refresh(){this.cm6.measure()}destroy(){this.removeOverlay()}getLastEditEnd(){return this.posFromIndex(this.$lastChangeEndOffset)}onChange(n){for(let o in this.$lineHandleChanges&&this.$lineHandleChanges.push(n),this.marks)this.marks[o].update(n.changes);this.virtualSelection&&(this.virtualSelection.ranges=this.virtualSelection.ranges.map(o=>o.map(n.changes)));var a=this.curOp=this.curOp||{};n.changes.iterChanges((o,s,c,f,d)=>{(a.$changeStart==null||a.$changeStart>c)&&(a.$changeStart=c),this.$lastChangeEndOffset=f;var m={text:d.toJSON()};a.lastChange?a.lastChange.next=a.lastChange=m:a.lastChange=a.change=m},!0),a.changeHandlers||(a.changeHandlers=this._handlers.change&&this._handlers.change.slice())}onSelectionChange(){var n=this.curOp=this.curOp||{};n.cursorActivityHandlers||(n.cursorActivityHandlers=this._handlers.cursorActivity&&this._handlers.cursorActivity.slice()),this.curOp.cursorActivity=!0}operation(n,a){this.curOp||(this.curOp={$d:0}),this.curOp.$d++;try{var o=n()}finally{this.curOp&&(this.curOp.$d--,this.curOp.$d||this.onBeforeEndOperation())}return o}onBeforeEndOperation(){var n=this.curOp,a=!1;n&&(n.change&&s1(n.changeHandlers,this,n.change),n&&n.cursorActivity&&(s1(n.cursorActivityHandlers,this,null),n.isVimOp&&(a=!0)),this.curOp=null),a&&this.scrollIntoView()}moveH(n,a){if(a=="char"){var o=this.getCursor();this.setCursor(o.line,o.ch+n)}}setOption(n,a){switch(n){case"keyMap":this.state.keyMap=a;break;case"textwidth":this.state.textwidth=a;break}}getOption(n){switch(n){case"firstLineNumber":return 1;case"tabSize":return this.cm6.state.tabSize||4;case"readOnly":return this.cm6.state.readOnly;case"indentWithTabs":return this.cm6.state.facet(n_)==" ";case"indentUnit":return this.cm6.state.facet(n_).length||2;case"textwidth":return this.state.textwidth;case"keyMap":return this.state.keyMap||"vim"}}toggleOverwrite(n){this.state.overwrite=n}getTokenTypeAt(n){var s,c,f;var a=this.indexFromPos(n),o=((f=(c=(s=l_(this.cm6.state,a))==null?void 0:s.resolve(a))==null?void 0:c.type)==null?void 0:f.name)||"";return/comment/i.test(o)?"comment":/string/i.test(o)?"string":""}overWriteSelection(n){var a=this.cm6.state.doc,o=this.cm6.state.selection,s=o.ranges.map(c=>{if(c.empty){var f=c.to<a.length?a.sliceString(c.from,c.to+1):"";if(f&&!/\n/.test(f))return $t.range(c.from,c.to+1)}return c});this.cm6.dispatch({selection:$t.create(s,o.mainIndex)}),this.replaceSelection(n)}isInMultiSelectMode(){return this.cm6.state.selection.ranges.length>1}virtualSelectionMode(){return!!this.virtualSelection}forEachSelection(n){var a=this.cm6.state.selection;this.virtualSelection=$t.create(a.ranges,a.mainIndex);for(var o=0;o<this.virtualSelection.ranges.length;o++){var s=this.virtualSelection.ranges[o];s&&(this.cm6.dispatch({selection:$t.create([s])}),n(),this.virtualSelection.ranges[o]=this.cm6.state.selection.ranges[0])}this.cm6.dispatch({selection:this.virtualSelection}),this.virtualSelection=null}hardWrap(n){return W3(this,n)}};Ve.isMac=typeof navigator<"u"&&/Mac/.test(navigator.platform),Ve.Pos=Cr,Ve.StringStream=XI,Ve.commands={cursorCharLeft:function(e){f8(e.cm6)},redo:function(e){l1(e,!1)},undo:function(e){l1(e,!0)},newlineAndIndent:function(e){n8({state:e.cm6.state,dispatch:n=>ks(e,n)})},indentAuto:function(e){i8(e.cm6)},newlineAndIndentContinueComment:void 0,save:void 0},Ve.isWordChar=function(e){return bf.test(e)},Ve.keys=D3,Ve.addClass=function(e,n){},Ve.rmClass=function(e,n){},Ve.e_preventDefault=function(e){e.preventDefault()},Ve.e_stop=function(e){var n,a;(n=e==null?void 0:e.stopPropagation)==null||n.call(e),(a=e==null?void 0:e.preventDefault)==null||a.call(e)},Ve.lookupKey=function(e,n,a){var o=Ve.keys[e];!o&&/^Arrow/.test(e)&&(o=Ve.keys[e.slice(5)]),o&&a(o)},Ve.on=a1,Ve.off=i1,Ve.signal=o1,Ve.findMatchingTag=V3,Ve.findEnclosingTag=H3,Ve.keyName=void 0;function c1(e,n,a){var o=document.createElement("div");return o.appendChild(n),o}function u1(e,n){e.state.currentNotificationClose&&e.state.currentNotificationClose(),e.state.currentNotificationClose=n}function j3(e,n,a){u1(e,d);var o=c1(e,n,a&&a.bottom),s=!1,c,f=a&&a.duration!==void 0?a.duration:5e3;function d(){s||(s=!0,clearTimeout(c),o.remove(),f1(e,o))}return o.onclick=function(m){m.preventDefault(),d()},d1(e,o),f&&(c=setTimeout(d,f)),d}function d1(e,n){var a=e.state.dialog;e.state.dialog=n,n.style.flex="1",n&&a!==n&&(a&&a.contains(document.activeElement)&&e.focus(),a&&a.parentElement?a.parentElement.replaceChild(n,a):a&&a.remove(),Ve.signal(e,"dialog"))}function f1(e,n){e.state.dialog==n&&(e.state.dialog=null,Ve.signal(e,"dialog"))}function z3(e,n,a,o){o||(o={}),u1(e,void 0);var s=c1(e,n,o.bottom),c=!1;d1(e,s);function f(m){if(typeof m=="string")d.value=m;else{if(c)return;c=!0,f1(e,s),e.state.dialog||e.focus(),o.onClose&&o.onClose(s)}}var d=s.getElementsByTagName("input")[0];return d&&(o.value&&(d.value=o.value,o.selectValueOnOpen!==!1&&d.select()),o.onInput&&Ve.on(d,"input",function(m){o.onInput(m,d.value,f)}),o.onKeyUp&&Ve.on(d,"keyup",function(m){o.onKeyUp(m,d.value,f)}),Ve.on(d,"keydown",function(m){o&&o.onKeyDown&&o.onKeyDown(m,d.value,f)||(m.keyCode==13&&a&&a(d.value),(m.keyCode==27||o.closeOnEnter!==!1&&m.keyCode==13)&&(d.blur(),Ve.e_stop(m),f()))}),o.closeOnBlur!==!1&&Ve.on(d,"blur",function(){setTimeout(function(){document.activeElement!==d&&f()})}),d.focus()),f}var q3={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<","<":">>",">":"<<"};function F3(e){return e&&e.bracketRegex||/[(){}[\]]/}function B3(e,n,a,o,s){for(var c=s&&s.maxScanLineLength||1e4,f=s&&s.maxScanLines||1e3,d=[],m=F3(s),b=a>0?Math.min(n.line+f,e.lastLine()+1):Math.max(e.firstLine()-1,n.line-f),w=n.line;w!=b;w+=a){var x=e.getLine(w);if(x){var S=a>0?0:x.length-1,E=a>0?x.length:-1;if(!(x.length>c))for(w==n.line&&(S=n.ch-(a<0?1:0));S!=E;S+=a){var T=x.charAt(S);if(m.test(T)){var P=q3[T];if(P&&P.charAt(1)==">"==a>0)d.push(T);else if(d.length)d.pop();else return{pos:new Cr(w,S),ch:T}}}}}return w-a==(a>0?e.lastLine():e.firstLine())?!1:null}function V3(e,n){return null}function H3(e,n){var c,f,d;var a=e.cm6.state,o=e.indexFromPos(n);o<a.doc.length&&a.sliceDoc(o,o+1)=="<"&&o++;for(var s=((c=l_(a,o))==null?void 0:c.resolve(o))||null;s;){if(((f=s.firstChild)==null?void 0:f.type.name)=="OpenTag"&&((d=s.lastChild)==null?void 0:d.type.name)=="CloseTag")return{open:p1(a.doc,s.firstChild),close:p1(a.doc,s.lastChild)};s=s.parent}}function p1(e,n){return{from:lr(e,n.from),to:lr(e,n.to)}}var $3=class{constructor(e,n,a){this.cm=e,this.id=e.$mid++,this.offset=n,this.assoc=a,e.marks[this.id]=this}clear(){delete this.cm.marks[this.id]}find(){return this.offset==null?null:this.cm.posFromIndex(this.offset)}update(e){this.offset!=null&&(this.offset=e.mapPos(this.offset,this.assoc,t_.TrackDel))}};function W3(e,n){var T;for(var a=n.column||e.getOption("textwidth")||80,o=n.allowMerge!=0,s=Math.min(n.from,n.to),c=Math.max(n.from,n.to);s<=c;){var f=e.getLine(s);if(f.length>a){var d=E(f,a,5);if(d){var m=(T=/^\s*/.exec(f))==null?void 0:T[0];e.replaceRange(`
|
|
93
93
|
`+m,new Cr(s,d.start),new Cr(s,d.end))}c++}else if(o&&/\S/.test(f)&&s!=c){var b=e.getLine(s+1);if(b&&/\S/.test(b)){var w=f.replace(/\s+$/,""),x=b.replace(/^\s+/,""),S=w+" "+x,d=E(S,a,5);d&&d.start>w.length||S.length<a?(e.replaceRange(" ",new Cr(s,w.length),new Cr(s+1,b.length-x.length)),s--,c--):w.length<f.length&&e.replaceRange("",new Cr(s,w.length),new Cr(s,f.length))}}s++}return s;function E(P,z,B){if(!(P.length<z)){var V=P.slice(0,z),N=P.slice(z),X=/^(?:(\s+)|(\S+)(\s+))/.exec(N),ce=/(?:(\s+)|(\s+)(\S+))$/.exec(V),A=0,q=0;if(ce&&!ce[2]&&(A=z-ce[1].length,q=z),X&&!X[2]&&(A||(A=z),q=z+X[1].length),A)return{start:A,end:q};if(ce&&ce[2]&&ce.index>B)return{start:ce.index,end:ce.index+ce[2].length};if(X&&X[2])return A=z+X[2].length,{start:A,end:A+X[3].length}}}}var wf=QI||(function(){let e={cursorBlinkRate:1200};return function(){return e}})(),U3=class{constructor(e,n,a,o,s,c,f,d,m,b){this.left=e,this.top=n,this.height=a,this.fontFamily=o,this.fontSize=s,this.fontWeight=c,this.color=f,this.className=d,this.letter=m,this.partial=b}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",e.style.height=this.height+"px",e.style.lineHeight=this.height+"px",e.style.fontFamily=this.fontFamily,e.style.fontSize=this.fontSize,e.style.fontWeight=this.fontWeight,e.style.color=this.partial?"transparent":this.color,e.className=this.className,e.textContent=this.letter}eq(e){return this.left==e.left&&this.top==e.top&&this.height==e.height&&this.fontFamily==e.fontFamily&&this.fontSize==e.fontSize&&this.fontWeight==e.fontWeight&&this.color==e.color&&this.className==e.className&&this.letter==e.letter}},K3=class{constructor(e,n){this.view=e,this.rangePieces=[],this.cursors=[],this.cm=n,this.measureReq={read:this.readPos.bind(this),write:this.drawSel.bind(this)},this.cursorLayer=e.scrollDOM.appendChild(document.createElement("div")),this.cursorLayer.className="cm-cursorLayer cm-vimCursorLayer",this.cursorLayer.setAttribute("aria-hidden","true"),e.requestMeasure(this.measureReq),this.setBlinkRate()}setBlinkRate(){let e=wf(this.cm.cm6.state).cursorBlinkRate;this.cursorLayer.style.animationDuration=e+"ms"}update(e){(e.selectionSet||e.geometryChanged||e.viewportChanged)&&(this.view.requestMeasure(this.measureReq),this.cursorLayer.style.animationName=this.cursorLayer.style.animationName=="cm-blink"?"cm-blink2":"cm-blink"),Q3(e)&&this.setBlinkRate()}scheduleRedraw(){this.view.requestMeasure(this.measureReq)}readPos(){let{state:e}=this.view,n=[];for(let a of e.selection.ranges){let o=a==e.selection.main,s=X3(this.cm,this.view,a,o);s&&n.push(s)}return{cursors:n}}drawSel({cursors:e}){if(e.length!=this.cursors.length||e.some((n,a)=>!n.eq(this.cursors[a]))){let n=this.cursorLayer.children;if(n.length!==e.length){this.cursorLayer.textContent="";for(let a of e)this.cursorLayer.appendChild(a.draw())}else e.forEach((a,o)=>a.adjust(n[o]));this.cursors=e}}destroy(){this.cursorLayer.remove()}};function Q3(e){return wf(e.startState)!=wf(e.state)}var G3=Fu.highest(Et.theme({".cm-vimMode .cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-fat-cursor":{position:"absolute",background:"#ff9696",border:"none",whiteSpace:"pre"},"&:not(.cm-focused) .cm-fat-cursor":{background:"none",outline:"solid 1px #ff9696",color:"transparent !important"}}));function J3(e){let n=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==JI.LTR?n.left:n.right-e.scrollDOM.clientWidth)-e.scrollDOM.scrollLeft*e.scaleX,top:n.top-e.scrollDOM.scrollTop*e.scaleY}}function X3(e,n,a,o){var w,x,S;var s;let c=a.head,f=!1,d=1,m=e.state.vim;if(m&&(!m.insertMode||e.state.overwrite)){if(f=!0,m.visualBlock&&!o)return null;a.anchor<a.head&&(c<n.state.doc.length&&n.state.sliceDoc(c,c+1))!=`
|
|
94
94
|
`&&c--,e.state.overwrite?d=.2:m.status&&(d=.5)}if(f){let E=c<n.state.doc.length&&n.state.sliceDoc(c,c+1);E&&/[\uDC00-\uDFFF]/.test(E)&&c>1&&(c--,E=n.state.sliceDoc(c,c+1));let T=n.coordsAtPos(c,1);if(!T)return null;let P=J3(n),z=n.domAtPos(c),B=z?z.node:n.contentDOM;for(B instanceof Text&&z.offset>=B.data.length&&((w=B.parentElement)==null?void 0:w.nextSibling)&&(B=(x=B.parentElement)==null?void 0:x.nextSibling,z={node:B,offset:0});z&&z.node instanceof HTMLElement;)B=z.node,z={node:z.node.childNodes[z.offset],offset:0};if(!(B instanceof HTMLElement)){if(!B.parentNode)return null;B=B.parentNode}let V=getComputedStyle(B),N=T.left,X=(S=(s=n).coordsForChar)==null?void 0:S.call(s,c);if(X&&(N=X.left),!E||E==`
|
|
95
|
-
`||E=="\r")E="\xA0";else if(E==" "){E="\xA0";var b=n.coordsAtPos(c+1,-1);b&&(N=b.left-(b.left-T.left)/parseInt(V.tabSize))}else/[\uD800-\uDBFF]/.test(E)&&c<n.state.doc.length-1&&(E+=n.state.sliceDoc(c+1,c+2));let ce=T.bottom-T.top;return new U3((N-P.left)/n.scaleX,(T.top-P.top+ce*(1-d))/n.scaleY,ce*d/n.scaleY,V.fontFamily,V.fontSize,V.fontWeight,V.color,o?"cm-fat-cursor cm-cursor-primary":"cm-fat-cursor cm-cursor-secondary",E,d!=1)}else return null}let h1,m1,g1,y1;h1=typeof navigator<"u"&&/linux/i.test(navigator.platform)&&/ Gecko\/\d+/.exec(navigator.userAgent),fa=N3(Ve),m1=250,g1=Et.baseTheme({".cm-vimMode .cm-cursorLayer:not(.cm-vimCursorLayer)":{display:"none"},".cm-vim-panel":{padding:"0px 10px",fontFamily:"monospace",minHeight:"1.3em",display:"flex"},".cm-vim-panel input":{border:"none",outline:"none",backgroundColor:"inherit"},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"}}),y1=Gi.fromClass(class{constructor(e){this.status="",this.query=null,this.decorations=ca.none,this.waitForCopy=!1,this.lastKeydown="",this.useNextTextInput=!1,this.compositionText="",this.view=e;let n=this.cm=new Ve(e);fa.enterVimMode(this.cm),this.view.cm=this.cm,this.cm.state.vimPlugin=this,this.blockCursor=new K3(e,n),this.updateClass(),this.cm.on("vim-command-done",()=>{n.state.vim&&(n.state.vim.status=""),this.blockCursor.scheduleRedraw(),this.updateStatus()}),this.cm.on("vim-mode-change",a=>{n.state.vim&&(n.state.vim.mode=a.mode,a.subMode&&(n.state.vim.mode+=" block"),n.state.vim.status="",this.blockCursor.scheduleRedraw(),this.updateClass(),this.updateStatus())}),this.cm.on("dialog",()=>{this.cm.state.statusbar?this.updateStatus():e.dispatch({effects:v1.of(!!this.cm.state.dialog)})}),this.dom=document.createElement("span"),this.spacer=document.createElement("span"),this.spacer.style.flex="1",this.statusButton=document.createElement("span"),this.statusButton.onclick=a=>{fa.handleKey(this.cm,"<Esc>","user"),this.cm.focus()},this.statusButton.style.cssText="cursor: pointer"}update(e){var n;if((e.viewportChanged||e.docChanged)&&this.query&&this.highlight(this.query),e.docChanged&&this.cm.onChange(e),e.selectionSet&&this.cm.onSelectionChange(),e.viewportChanged,this.cm.curOp&&!this.cm.curOp.isVimOp&&this.cm.onBeforeEndOperation(),e.transactions){for(let a of e.transactions)for(let o of a.effects)if(o.is(Zh))if(!((n=o.value)!=null&&n.forVim))this.highlight(null);else{let s=o.value.create();this.highlight(s)}}this.blockCursor.update(e)}updateClass(){let e=this.cm.state;!e.vim||e.vim.insertMode&&!e.overwrite?this.view.scrollDOM.classList.remove("cm-vimMode"):this.view.scrollDOM.classList.add("cm-vimMode")}updateStatus(){let e=this.cm.state.statusbar,n=this.cm.state.vim;if(!e||!n)return;let a=this.cm.state.dialog;if(a)a.parentElement!=e&&(e.textContent="",e.appendChild(a));else{e.textContent="";var o=(n.mode||"normal").toUpperCase();n.insertModeReturn&&(o+="(C-O)"),this.statusButton.textContent=`--${o}--`,e.appendChild(this.statusButton),e.appendChild(this.spacer)}this.dom.textContent=n.status,e.appendChild(this.dom)}destroy(){fa.leaveVimMode(this.cm),this.updateClass(),this.blockCursor.destroy(),delete this.view.cm}highlight(e){if(this.query=e,!e)return this.decorations=ca.none;let{view:n}=this,a=new r_;for(let o=0,s=n.visibleRanges,c=s.length;o<c;o++){let{from:f,to:d}=s[o];for(;o<c-1&&d>s[o+1].from-2*m1;)d=s[++o].to;e.highlight(n.state,f,d,(m,b)=>{a.add(m,b,Z3)})}return this.decorations=a.finish()}handleKey(e,n){let a=this.cm,o=a.state.vim;if(!o)return;let s=fa.vimKeyFromEvent(e,o);if(Ve.signal(this.cm,"inputEvent",{type:"handleKey",key:s}),!s)return;if(s=="<Esc>"&&!o.insertMode&&!o.visualMode&&this.query){let f=o.searchState_;f&&(a.removeOverlay(f.getOverlay()),f.setOverlay(null))}if(s==="<C-c>"&&!Ve.isMac&&a.somethingSelected())return this.waitForCopy=!0,!0;o.status=(o.status||"")+s;let c=fa.multiSelectHandleKey(a,s,"user");return o=fa.maybeInitVimState_(a),!c&&o.insertMode&&a.state.overwrite&&(e.key&&e.key.length==1&&!/\n/.test(e.key)?(c=!0,a.overWriteSelection(e.key)):e.key=="Backspace"&&(c=!0,Ve.commands.cursorCharLeft(a))),c&&(Ve.signal(this.cm,"vim-keypress",s),e.preventDefault(),e.stopPropagation(),this.blockCursor.scheduleRedraw()),this.updateStatus(),!!c}},{eventHandlers:{copy:function(e,n){this.waitForCopy&&(this.waitForCopy=!1,Promise.resolve().then(()=>{var a=this.cm,o=a.state.vim;o&&(o.insertMode?a.setSelection(a.getCursor(),a.getCursor()):a.operation(()=>{a.curOp&&(a.curOp.isVimOp=!0),fa.handleKey(a,"<Esc>","user")}))}))},compositionstart:function(e,n){this.useNextTextInput=!0,Ve.signal(this.cm,"inputEvent",e)},compositionupdate:function(e,n){Ve.signal(this.cm,"inputEvent",e)},compositionend:function(e,n){Ve.signal(this.cm,"inputEvent",e)},keypress:function(e,n){Ve.signal(this.cm,"inputEvent",e),this.lastKeydown=="Dead"&&this.handleKey(e,n)},keydown:function(e,n){Ve.signal(this.cm,"inputEvent",e),this.lastKeydown=e.key,this.lastKeydown=="Unidentified"||this.lastKeydown=="Process"||this.lastKeydown=="Dead"?this.useNextTextInput=!0:(this.useNextTextInput=!1,this.handleKey(e,n))}},provide:()=>[Et.inputHandler.of((e,n,a,o)=>{var w,x;var s=zl(e);if(!s)return!1;var c=(w=s.state)==null?void 0:w.vim,f=s.state.vimPlugin;if(c&&!c.insertMode&&!((x=s.curOp)!=null&&x.isVimOp)){if(o==="\0\0")return!0;if(Ve.signal(s,"inputEvent",{type:"text",text:o,from:n,to:a}),o.length==1&&f.useNextTextInput){if(c.expectLiteralNext&&e.composing)return f.compositionText=o,!1;if(f.compositionText){var d=f.compositionText;f.compositionText="";var m=e.state.selection.main.head;if(d===e.state.sliceDoc(m-d.length,m)){var b=s.getCursor();s.replaceRange("",s.posFromIndex(m-d.length),b)}}return f.handleKey({key:o,preventDefault:()=>{},stopPropagation:()=>{}}),Y3(e),!0}}return!1})],decorations:e=>e.decorations});function Y3(e){var n=e.scrollDOM.parentElement;if(n){if(h1){e.contentDOM.textContent="\0\0",e.contentDOM.dispatchEvent(new CustomEvent("compositionend"));return}var a=e.scrollDOM.nextSibling,o=window.getSelection(),s=o&&{anchorNode:o.anchorNode,anchorOffset:o.anchorOffset,focusNode:o.focusNode,focusOffset:o.focusOffset};e.scrollDOM.remove(),n.insertBefore(e.scrollDOM,a);try{s&&o&&(o.setPosition(s.anchorNode,s.anchorOffset),s.focusNode&&o.extend(s.focusNode,s.focusOffset))}catch(c){console.error(c)}e.focus(),e.contentDOM.dispatchEvent(new CustomEvent("compositionend"))}}var Z3=ca.mark({class:"cm-searchMatch"}),v1=Mr.define(),eE=Qi.define({create:()=>!1,update(e,n){for(let a of n.effects)a.is(v1)&&(e=a.value);return e},provide:e=>Yh.from(e,n=>n?tE:null)});function tE(e){let n=document.createElement("div");n.className="cm-vim-panel";let a=e.cm;return a.state.dialog&&n.appendChild(a.state.dialog),{top:!1,dom:n}}function nE(e){let n=document.createElement("div");n.className="cm-vim-panel";let a=e.cm;return a.state.statusbar=n,a.state.vimPlugin.updateStatus(),{dom:n}}Qx=function(e={}){return[g1,y1,G3,e.status?Yh.of(nE):eE]},zl=function(e){return e.cm||null},Um=function(e){let n=e.state.selection.main;return n.from===0&&n.to===0},w0=function(e,n=!1){let a=e.state.selection.main,o=e.state.doc.length;return n&&a.from===o-1&&a.to===o-1?!0:a.from===o&&a.to===o},Qm=function(e){e&&e.dispatch({selection:{anchor:e.state.doc.length,head:e.state.doc.length}})},lk=function(e){requestAnimationFrame(()=>{var a;let n=(a=e.current)==null?void 0:a.view;n&&(n.focus(),Qm(n))})},rk=function(e){var n;return((n=zl(e))==null?void 0:n.state.vim)!=null},bk=function(e){var a;let n=(a=zl(e))==null?void 0:a.state.vim;return n?!n.mode&&!n.insertMode&&!n.visualMode?!0:n.mode==="normal":!1},Hx=function(e){e&&e.dispatch({selection:{anchor:0,head:e.state.doc.length}})};function b1(e,n){if(!(n!=null&&n.length))return ca.none;let a=new r_,o=e.facet(da),s=n.filter(c=>c.kind==="cell"&&c.cellId===o).toSorted((c,f)=>c.lineNumber-f.lineNumber);for(let c of s)try{let f=e.doc.line(c.lineNumber),d=ca.line({class:"cm-error-line"});a.add(f.from,f.from,d)}catch(f){_e.debug("Invalid line number in error decoration",{error:f})}return a.finish()}function w1(e,n){if(!(n!=null&&n.length))return;let a=e.state.facet(da),o=n.filter(f=>f.kind==="cell"&&f.cellId===a);if(o.length===0)return;let s=GI(e.state),c=[];for(let f of o)try{let d=e.state.doc.line(f.lineNumber);s.between(d.from,d.to,(m,b)=>{c.push(WI.of({from:m,to:b}))})}catch(d){_e.debug("Invalid line numbers",{error:d})}c.length>0&&e.dispatch({effects:c})}var rE=class{constructor(e,n){let a=n.get();this.decorations=b1(e.state,a),w1(e,a),this.unsubscribe=n.sub(o=>{let s=this.decorations.size;this.decorations=b1(e.state,o),w1(e,o),s!==this.decorations.size&&e.dispatch({userEvent:"marimo.error-decoration-update"})})}update(e){this.decorations=this.decorations.map(e.changes)}destroy(){this.unsubscribe()}};function aE(e){return Gi.define(n=>new rE(n,e),{decorations:n=>n.decorations})}function iE(e){return[aE(e),Et.theme({".cm-error-line":{backgroundColor:"color-mix(in srgb, var(--red-4) 40%, transparent)"},"&.cm-focused .cm-error-line.cm-activeLine":{backgroundColor:"color-mix(in srgb, var(--red-5) 40%, transparent)"}})]}function oE({cellId:e,hotkeys:n}){let a=[];return a.push(...Uw({key:n.getHotkey("cell.run").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(st).onRun(),!0)}),{key:n.getHotkey("cell.runAndNewBelow").key,preventDefault:!0,stopPropagation:!0,run:o=>{let s=o.state.facet(st);return s.onRun(),e==="__scratch__"||(o.contentDOM.blur(),s.moveToNextCell({cellId:e,before:!1})),!0}},...Uw({key:n.getHotkey("cell.runAndNewAbove").key,preventDefault:!0,stopPropagation:!0,run:o=>{let s=o.state.facet(st);return s.onRun(),e==="__scratch__"||(o.contentDOM.blur(),s.moveToNextCell({cellId:e,before:!0})),!0}}),{key:n.getHotkey("cell.aiCompletion").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(st).aiCellCompletion()&&o.contentDOM.focus(),!0)}),e!=="__scratch__"&&a.push({key:n.getHotkey("cell.goToDefinition").key,preventDefault:!0,stopPropagation:!0,run:o=>(k0(o),!0)},{key:n.getHotkey("cell.delete").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.doc.length===0&&o.state.facet(st).deleteCell(),!0)},{key:n.getHotkey("cell.moveUp").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(st).moveCell({cellId:e,before:!0}),!0)},{key:n.getHotkey("cell.moveDown").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(st).moveCell({cellId:e,before:!1}),!0)},{key:n.getHotkey("cell.moveLeft").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(st).moveCell({cellId:e,before:!0,direction:"left"}),!0)},{key:n.getHotkey("cell.moveRight").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(st).moveCell({cellId:e,before:!1,direction:"right"}),!0)},{key:"ArrowUp",run:o=>g_(o.state)?!1:Um(o)?(o.state.facet(st).moveToNextCell({cellId:e,before:!0,noCreate:!0}),!0):!1},{key:"ArrowDown",run:o=>g_(o.state)?!1:w0(o)?(o.state.facet(st).moveToNextCell({cellId:e,before:!1,noCreate:!0}),!0):!1},{key:n.getHotkey("cell.focusDown").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(st).moveToNextCell({cellId:e,before:!1,noCreate:!0}),!0)},{key:n.getHotkey("cell.focusUp").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(st).moveToNextCell({cellId:e,before:!0,noCreate:!0}),!0)},{key:n.getHotkey("cell.sendToBottom").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(st).sendToBottom({cellId:e}),!0)},{key:n.getHotkey("cell.sendToTop").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(st).sendToTop({cellId:e}),!0)},{key:n.getHotkey("cell.createAbove").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.contentDOM.blur(),o.state.facet(st).createNewCell({cellId:e,before:!0}),!0)},{key:n.getHotkey("cell.createBelow").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.contentDOM.blur(),o.state.facet(st).createNewCell({cellId:e,before:!1}),!0)},{key:n.getHotkey("cell.hideCode").key,preventDefault:!0,stopPropagation:!0,run:o=>{var c;let s=o.state.facet(st).toggleHideCode();return y_(o),s?(o.contentDOM.blur(),(c=document.getElementById(En.create(e)))==null||c.focus()):o.contentDOM.focus(),!0}},{key:n.getHotkey("cell.splitCell").key,preventDefault:!0,stopPropagation:!0,run:o=>{let s=o.state.facet(st);return s.splitCell({cellId:e}),s.moveToNextCell&&requestAnimationFrame(()=>{o.contentDOM.blur(),s.moveToNextCell({cellId:e,before:!1})}),!0}}),[Fu.high(Xa.of(a))]}function sE(e){return[Et.updateListener.of(n=>{if(n.docChanged){let a=n.transactions.some(f=>f.effects.some(d=>d.is(_s))),o=wr(n.view),s=n.view.state.facet(st),c=n.view.state.facet(da);s.updateCellCode({cellId:c,code:o,formattingChange:a}),Pe.get(_d).has(c)&&Pe.set(Cm)}}),e3(e)]}var lE=["input","delete","undo","redo"];function cE({docChanged:e,transactions:n,predicate:a=()=>!0,hasFocus:o=!1}){return!e||!a()||n.some(s=>s.effects.some(c=>c.is(_s)))?!1:n.some(s=>s.annotation(ei)===void 0?lE.some(c=>s.isUserEvent(c))||o:!1)}function uE({predicate:e}){return Et.updateListener.of(n=>{cE({docChanged:n.docChanged,transactions:n.transactions,predicate:e,hasFocus:n.view.hasFocus})&&n.view.state.facet(st).onRun()})}Rx=function({cellId:e,hotkeys:n,cellActions:a}){return[st.of(a),da.of(e),oE({cellId:e,hotkeys:n}),sE(n),iE(XS(E5(e),Pe))]};const _f=Mr.define();function dE(e){return{...e,create:n=>{let{dom:a,...o}=e.create(n),s=document.createElement("div");return s.classList.add("mo-cm-tooltip"),s.append(a),{...o,dom:s}}}}const fE=Qi.define({create:()=>null,update(e,n){for(let a of n.effects)if(a.is(_f))return a.value;return!e||n.selection&&!n.docChanged?null:n.docChanged?{...e,pos:n.changes.mapPos(e.pos)}:e},provide:e=>i_.from(e)}),_1=async e=>{var f,d;let n=e.state.doc.sliceString(0,e.pos),a=document.activeElement,o=null;if(a!==null){let m=En.findElement(a);m!==null&&(o=En.parse(m.id))}if(o===null)return _e.error("Failed to find active cell."),null;let s=await Id.request({document:n,cellId:o});if(!s)return(f=e.view)==null||f.dispatch({effects:_f.of(null)}),null;let c=gf.asHoverTooltip({position:e.pos,message:s,limitToType:"tooltip"});return c&&Pe.set(rd,{documentation:c.html??null}),(d=e.view)==null||d.dispatch({effects:_f.of(c?dE(c):null)}),c?null:gf.asCompletionResult(e.pos,s)};function pE(e){return n=>e.predicate(n.state)?e.completion(n):null}var hE=async e=>{let n=e.matchBefore(/:\w*$/);if(!e.explicit&&!n)return null;let a=await mE();return{from:(n==null?void 0:n.from)??e.pos,options:a,validFor:/^[\w:]*$/}},mE=rr(async()=>{let e=await fetch("https://unpkg.com/emojilib@3.0.11/dist/emoji-en-US.json").then(n=>{if(!n.ok)throw Error("Failed to fetch emoji list");return n.json()}).catch(()=>({}));return Object.entries(e).map(([n,a])=>({shortcode:a[0],label:a.map(o=>`:${o}`).join(" "),emoji:n,displayLabel:`${n} ${a[0].replaceAll("_"," ")}`,apply:n,type:"emoji"}))}),gE=async e=>{let n=e.matchBefore(/::[\w-:]*$/);if(!e.explicit&&!n)return null;let a=await yE();return{from:(n==null?void 0:n.from)??e.pos,options:a,validFor:/^[\w-:]*$/}},yE=rr(async()=>{let e=await fetch("https://unpkg.com/lucide-static@0.452.0/tags.json").then(a=>{if(!a.ok)throw Error("Failed to fetch Lucide icon list");return a.json()}).catch(()=>({})),n=a=>`https://cdn.jsdelivr.net/npm/lucide-static@0.452.0/icons/${a}.svg`;return Object.entries(e).map(([a,o])=>({label:`::${a}`,displayLabel:a,type:"lucide-icon",boost:10,apply:`::lucide:${a}::`,detail:o.join(", "),info:()=>{let s=document.createElement("img");return s.src=n(a),s.style.width="24px",s.style.height="24px",s}}))}),vE=e=>{let n=e.matchBefore(/\\\w*$/);return!e.explicit&&!n?null:{from:(n==null?void 0:n.from)??e.pos,options:bE(),validFor:/^[\w\\]*$/}},bE=rr(()=>[["alpha","\u03B1","Greek small letter alpha"],["beta","\u03B2","Greek small letter beta"],["gamma","\u03B3","Greek small letter gamma"],["delta","\u03B4","Greek small letter delta"],["epsilon","\u03B5","Greek small letter epsilon"],["zeta","\u03B6","Greek small letter zeta"],["eta","\u03B7","Greek small letter eta"],["theta","\u03B8","Greek small letter theta"],["iota","\u03B9","Greek small letter iota"],["kappa","\u03BA","Greek small letter kappa"],["lambda","\u03BB","Greek small letter lambda"],["mu","\u03BC","Greek small letter mu"],["nu","\u03BD","Greek small letter nu"],["xi","\u03BE","Greek small letter xi"],["omicron","\u03BF","Greek small letter omicron"],["pi","\u03C0","Greek small letter pi"],["rho","\u03C1","Greek small letter rho"],["sigma","\u03C3","Greek small letter sigma"],["tau","\u03C4","Greek small letter tau"],["upsilon","\u03C5","Greek small letter upsilon"],["phi","\u03C6","Greek small letter phi"],["chi","\u03C7","Greek small letter chi"],["psi","\u03C8","Greek small letter psi"],["omega","\u03C9","Greek small letter omega"],["Gamma","\u0393","Greek capital letter gamma"],["Delta","\u0394","Greek capital letter delta"],["Theta","\u0398","Greek capital letter theta"],["Lambda","\u039B","Greek capital letter lambda"],["Xi","\u039E","Greek capital letter xi"],["Pi","\u03A0","Greek capital letter pi"],["Sigma","\u03A3","Greek capital letter sigma"],["Phi","\u03A6","Greek capital letter phi"],["Psi","\u03A8","Greek capital letter psi"],["Omega","\u03A9","Greek capital letter omega"],["pm","\xB1","Plus-minus sign"],["mp","\u2213","Minus-plus sign"],["times","\xD7","Multiplication sign"],["div","\xF7","Division sign"],["cdot","\u22C5","Dot operator"],["ast","\u2217","Asterisk operator"],["star","\u22C6","Star operator"],["circ","\u2218","Ring operator"],["bullet","\u2022","Bullet"],["cap","\u2229","Intersection"],["cup","\u222A","Union"],["uplus","\u228E","Multiset union"],["sqcap","\u2293","Square cap"],["sqcup","\u2294","Square cup"],["vee","\u2228","Logical or"],["wedge","\u2227","Logical and"],["setminus","\u2216","Set minus"],["oplus","\u2295","Circled plus"],["ominus","\u2296","Circled minus"],["otimes","\u2297","Circled times"],["oslash","\u2298","Circled division slash"],["odot","\u2299","Circled dot operator"],["leq","\u2264","Less than or equal to"],["geq","\u2265","Greater than or equal to"],["equiv","\u2261","Identical to"],["prec","\u227A","Precedes"],["succ","\u227B","Succeeds"],["sim","\u223C","Tilde operator"],["perp","\u22A5","Up tack"],["mid","\u2223","Divides"],["parallel","\u2225","Parallel to"],["subset","\u2282","Subset of"],["supset","\u2283","Superset of"],["subseteq","\u2286","Subset of or equal to"],["supseteq","\u2287","Superset of or equal to"],["cong","\u2245","Approximately equal to"],["approx","\u2248","Almost equal to"],["neq","\u2260","Not equal to"],["ne","\u2260","Not equal to"],["propto","\u221D","Proportional to"],["leftarrow","\u2190","Leftward arrow"],["rightarrow","\u2192","Rightward arrow"],["Leftarrow","\u21D0","Leftward double arrow"],["Rightarrow","\u21D2","Rightward double arrow"],["leftrightarrow","\u2194","Left right arrow"],["Leftrightarrow","\u21D4","Left right double arrow"],["uparrow","\u2191","Upward arrow"],["downarrow","\u2193","Downward arrow"],["Uparrow","\u21D1","Upward double arrow"],["Downarrow","\u21D3","Downward double arrow"],["infty","\u221E","Infinity"],["nabla","\u2207","Nabla"],["partial","\u2202","Partial differential"],["forall","\u2200","For all"],["exists","\u2203","There exists"],["nexists","\u2204","There does not exist"],["emptyset","\u2205","Empty set"],["in","\u2208","Element of"],["notin","\u2209","Not an element of"],["sum","\u2211","N-ary summation"],["prod","\u220F","N-ary product"],["int","\u222B","Integral"],["oint","\u222E","Contour integral"],["sqrt","\u221A","Square root"],["hbar","\u210F","Planck constant over 2pi"],["ldots","\u2026","Horizontal ellipsis"],["cdots","\u22EF","Midline horizontal ellipsis"],["vdots","\u22EE","Vertical ellipsis"],["ddots","\u22F1","Down right diagonal ellipsis"]].map(([e,n,a])=>({label:`\\${e} ${a}`,displayLabel:e,type:"latex-symbol",boost:10,apply:`\\${e}`,info:()=>{let o=document.createElement("div");return o.textContent=`${n} ${a}`,o},detail:n})));const wE=[hE,gE,vE];var _E=100;function uo(e){return!e.state.selection.main.empty}function xf({view:e,selection:n,markup:a}){let o=[],s=!0;for(let c=n.from;c<=n.to;c++)if(!e.state.doc.lineAt(c).text.startsWith(a)){s=!1;break}for(let c=n.from;c<=n.to;){let f=e.state.doc.lineAt(c),d=f.text.startsWith(a);s?o.push({from:f.from,to:f.from+a.length,insert:Ki.of([""])}):(d&&o.push({from:f.from,to:f.from+a.length,insert:Ki.of([""])}),o.push({from:f.from,insert:Ki.of([a])})),c=f.to+1}return o}function kf({view:e,range:n,markupAfter:a,markupBefore:o}){if(n.empty){let b=e.state.wordAt(n.head);b&&(n=b)}let s=e.state.sliceDoc(n.from-o.length,n.from)===o,c=e.state.sliceDoc(n.to,n.to+a.length)===a,f=[];f.push(s?{from:n.from-o.length,to:n.from,insert:Ki.of([""])}:{from:n.from,insert:Ki.of(o.split(`
|
|
95
|
+
`||E=="\r")E="\xA0";else if(E==" "){E="\xA0";var b=n.coordsAtPos(c+1,-1);b&&(N=b.left-(b.left-T.left)/parseInt(V.tabSize))}else/[\uD800-\uDBFF]/.test(E)&&c<n.state.doc.length-1&&(E+=n.state.sliceDoc(c+1,c+2));let ce=T.bottom-T.top;return new U3((N-P.left)/n.scaleX,(T.top-P.top+ce*(1-d))/n.scaleY,ce*d/n.scaleY,V.fontFamily,V.fontSize,V.fontWeight,V.color,o?"cm-fat-cursor cm-cursor-primary":"cm-fat-cursor cm-cursor-secondary",E,d!=1)}else return null}let h1,m1,g1,y1;h1=typeof navigator<"u"&&/linux/i.test(navigator.platform)&&/ Gecko\/\d+/.exec(navigator.userAgent),fa=N3(Ve),m1=250,g1=Et.baseTheme({".cm-vimMode .cm-cursorLayer:not(.cm-vimCursorLayer)":{display:"none"},".cm-vim-panel":{padding:"0px 10px",fontFamily:"monospace",minHeight:"1.3em",display:"flex"},".cm-vim-panel input":{border:"none",outline:"none",backgroundColor:"inherit"},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"}}),y1=Gi.fromClass(class{constructor(e){this.status="",this.query=null,this.decorations=ca.none,this.waitForCopy=!1,this.lastKeydown="",this.useNextTextInput=!1,this.compositionText="",this.view=e;let n=this.cm=new Ve(e);fa.enterVimMode(this.cm),this.view.cm=this.cm,this.cm.state.vimPlugin=this,this.blockCursor=new K3(e,n),this.updateClass(),this.cm.on("vim-command-done",()=>{n.state.vim&&(n.state.vim.status=""),this.blockCursor.scheduleRedraw(),this.updateStatus()}),this.cm.on("vim-mode-change",a=>{n.state.vim&&(n.state.vim.mode=a.mode,a.subMode&&(n.state.vim.mode+=" block"),n.state.vim.status="",this.blockCursor.scheduleRedraw(),this.updateClass(),this.updateStatus())}),this.cm.on("dialog",()=>{this.cm.state.statusbar?this.updateStatus():e.dispatch({effects:v1.of(!!this.cm.state.dialog)})}),this.dom=document.createElement("span"),this.spacer=document.createElement("span"),this.spacer.style.flex="1",this.statusButton=document.createElement("span"),this.statusButton.onclick=a=>{fa.handleKey(this.cm,"<Esc>","user"),this.cm.focus()},this.statusButton.style.cssText="cursor: pointer"}update(e){var n;if((e.viewportChanged||e.docChanged)&&this.query&&this.highlight(this.query),e.docChanged&&this.cm.onChange(e),e.selectionSet&&this.cm.onSelectionChange(),e.viewportChanged,this.cm.curOp&&!this.cm.curOp.isVimOp&&this.cm.onBeforeEndOperation(),e.transactions){for(let a of e.transactions)for(let o of a.effects)if(o.is(Zh))if(!((n=o.value)!=null&&n.forVim))this.highlight(null);else{let s=o.value.create();this.highlight(s)}}this.blockCursor.update(e)}updateClass(){let e=this.cm.state;!e.vim||e.vim.insertMode&&!e.overwrite?this.view.scrollDOM.classList.remove("cm-vimMode"):this.view.scrollDOM.classList.add("cm-vimMode")}updateStatus(){let e=this.cm.state.statusbar,n=this.cm.state.vim;if(!e||!n)return;let a=this.cm.state.dialog;if(a)a.parentElement!=e&&(e.textContent="",e.appendChild(a));else{e.textContent="";var o=(n.mode||"normal").toUpperCase();n.insertModeReturn&&(o+="(C-O)"),this.statusButton.textContent=`--${o}--`,e.appendChild(this.statusButton),e.appendChild(this.spacer)}this.dom.textContent=n.status,e.appendChild(this.dom)}destroy(){fa.leaveVimMode(this.cm),this.updateClass(),this.blockCursor.destroy(),delete this.view.cm}highlight(e){if(this.query=e,!e)return this.decorations=ca.none;let{view:n}=this,a=new r_;for(let o=0,s=n.visibleRanges,c=s.length;o<c;o++){let{from:f,to:d}=s[o];for(;o<c-1&&d>s[o+1].from-2*m1;)d=s[++o].to;e.highlight(n.state,f,d,(m,b)=>{a.add(m,b,Z3)})}return this.decorations=a.finish()}handleKey(e,n){let a=this.cm,o=a.state.vim;if(!o)return;let s=fa.vimKeyFromEvent(e,o);if(Ve.signal(this.cm,"inputEvent",{type:"handleKey",key:s}),!s)return;if(s=="<Esc>"&&!o.insertMode&&!o.visualMode&&this.query){let f=o.searchState_;f&&(a.removeOverlay(f.getOverlay()),f.setOverlay(null))}if(s==="<C-c>"&&!Ve.isMac&&a.somethingSelected())return this.waitForCopy=!0,!0;o.status=(o.status||"")+s;let c=fa.multiSelectHandleKey(a,s,"user");return o=fa.maybeInitVimState_(a),!c&&o.insertMode&&a.state.overwrite&&(e.key&&e.key.length==1&&!/\n/.test(e.key)?(c=!0,a.overWriteSelection(e.key)):e.key=="Backspace"&&(c=!0,Ve.commands.cursorCharLeft(a))),c&&(Ve.signal(this.cm,"vim-keypress",s),e.preventDefault(),e.stopPropagation(),this.blockCursor.scheduleRedraw()),this.updateStatus(),!!c}},{eventHandlers:{copy:function(e,n){this.waitForCopy&&(this.waitForCopy=!1,Promise.resolve().then(()=>{var a=this.cm,o=a.state.vim;o&&(o.insertMode?a.setSelection(a.getCursor(),a.getCursor()):a.operation(()=>{a.curOp&&(a.curOp.isVimOp=!0),fa.handleKey(a,"<Esc>","user")}))}))},compositionstart:function(e,n){this.useNextTextInput=!0,Ve.signal(this.cm,"inputEvent",e)},compositionupdate:function(e,n){Ve.signal(this.cm,"inputEvent",e)},compositionend:function(e,n){Ve.signal(this.cm,"inputEvent",e)},keypress:function(e,n){Ve.signal(this.cm,"inputEvent",e),this.lastKeydown=="Dead"&&this.handleKey(e,n)},keydown:function(e,n){Ve.signal(this.cm,"inputEvent",e),this.lastKeydown=e.key,this.lastKeydown=="Unidentified"||this.lastKeydown=="Process"||this.lastKeydown=="Dead"?this.useNextTextInput=!0:(this.useNextTextInput=!1,this.handleKey(e,n))}},provide:()=>[Et.inputHandler.of((e,n,a,o)=>{var w,x;var s=zl(e);if(!s)return!1;var c=(w=s.state)==null?void 0:w.vim,f=s.state.vimPlugin;if(c&&!c.insertMode&&!((x=s.curOp)!=null&&x.isVimOp)){if(o==="\0\0")return!0;if(Ve.signal(s,"inputEvent",{type:"text",text:o,from:n,to:a}),o.length==1&&f.useNextTextInput){if(c.expectLiteralNext&&e.composing)return f.compositionText=o,!1;if(f.compositionText){var d=f.compositionText;f.compositionText="";var m=e.state.selection.main.head;if(d===e.state.sliceDoc(m-d.length,m)){var b=s.getCursor();s.replaceRange("",s.posFromIndex(m-d.length),b)}}return f.handleKey({key:o,preventDefault:()=>{},stopPropagation:()=>{}}),Y3(e),!0}}return!1})],decorations:e=>e.decorations});function Y3(e){var n=e.scrollDOM.parentElement;if(n){if(h1){e.contentDOM.textContent="\0\0",e.contentDOM.dispatchEvent(new CustomEvent("compositionend"));return}var a=e.scrollDOM.nextSibling,o=window.getSelection(),s=o&&{anchorNode:o.anchorNode,anchorOffset:o.anchorOffset,focusNode:o.focusNode,focusOffset:o.focusOffset};e.scrollDOM.remove(),n.insertBefore(e.scrollDOM,a);try{s&&o&&(o.setPosition(s.anchorNode,s.anchorOffset),s.focusNode&&o.extend(s.focusNode,s.focusOffset))}catch(c){console.error(c)}e.focus(),e.contentDOM.dispatchEvent(new CustomEvent("compositionend"))}}var Z3=ca.mark({class:"cm-searchMatch"}),v1=Mr.define(),eE=Qi.define({create:()=>!1,update(e,n){for(let a of n.effects)a.is(v1)&&(e=a.value);return e},provide:e=>Yh.from(e,n=>n?tE:null)});function tE(e){let n=document.createElement("div");n.className="cm-vim-panel";let a=e.cm;return a.state.dialog&&n.appendChild(a.state.dialog),{top:!1,dom:n}}function nE(e){let n=document.createElement("div");n.className="cm-vim-panel";let a=e.cm;return a.state.statusbar=n,a.state.vimPlugin.updateStatus(),{dom:n}}Qx=function(e={}){return[g1,y1,G3,e.status?Yh.of(nE):eE]},zl=function(e){return e.cm||null},Um=function(e){let n=e.state.selection.main;return n.from===0&&n.to===0},w0=function(e,n=!1){let a=e.state.selection.main,o=e.state.doc.length;return n&&a.from===o-1&&a.to===o-1?!0:a.from===o&&a.to===o},Qm=function(e){e&&e.dispatch({selection:{anchor:e.state.doc.length,head:e.state.doc.length}})},lk=function(e){requestAnimationFrame(()=>{var a;let n=(a=e.current)==null?void 0:a.view;n&&(n.focus(),Qm(n))})},rk=function(e){var n;return((n=zl(e))==null?void 0:n.state.vim)!=null},bk=function(e){var a;let n=(a=zl(e))==null?void 0:a.state.vim;return n?!n.mode&&!n.insertMode&&!n.visualMode?!0:n.mode==="normal":!1},Hx=function(e){e&&e.dispatch({selection:{anchor:0,head:e.state.doc.length}})};function b1(e,n){if(!(n!=null&&n.length))return ca.none;let a=new r_,o=e.facet(da),s=n.filter(c=>c.kind==="cell"&&c.cellId===o).toSorted((c,f)=>c.lineNumber-f.lineNumber);for(let c of s)try{let f=e.doc.line(c.lineNumber),d=ca.line({class:"cm-error-line"});a.add(f.from,f.from,d)}catch(f){_e.debug("Invalid line number in error decoration",{error:f})}return a.finish()}function w1(e,n){if(!(n!=null&&n.length))return;let a=e.state.facet(da),o=n.filter(f=>f.kind==="cell"&&f.cellId===a);if(o.length===0)return;let s=GI(e.state),c=[];for(let f of o)try{let d=e.state.doc.line(f.lineNumber);s.between(d.from,d.to,(m,b)=>{c.push(WI.of({from:m,to:b}))})}catch(d){_e.debug("Invalid line numbers",{error:d})}c.length>0&&e.dispatch({effects:c})}var rE=class{constructor(e,n){let a=n.get();this.decorations=b1(e.state,a),w1(e,a),this.unsubscribe=n.sub(o=>{let s=this.decorations.size;this.decorations=b1(e.state,o),w1(e,o),s!==this.decorations.size&&e.dispatch({userEvent:"marimo.error-decoration-update"})})}update(e){this.decorations=this.decorations.map(e.changes)}destroy(){this.unsubscribe()}};function aE(e){return Gi.define(n=>new rE(n,e),{decorations:n=>n.decorations})}function iE(e){return[aE(e),Et.theme({".cm-error-line":{backgroundColor:"color-mix(in srgb, var(--red-4) 40%, transparent)"},"&.cm-focused .cm-error-line.cm-activeLine":{backgroundColor:"color-mix(in srgb, var(--red-5) 40%, transparent)"}})]}function oE({cellId:e,hotkeys:n}){let a=[];return a.push(...Uw({key:n.getHotkey("cell.run").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(st).onRun(),!0)}),{key:n.getHotkey("cell.runAndNewBelow").key,preventDefault:!0,stopPropagation:!0,run:o=>{let s=o.state.facet(st);return s.onRun(),e==="__scratch__"||(o.contentDOM.blur(),s.moveToNextCell({cellId:e,before:!1})),!0}},...Uw({key:n.getHotkey("cell.runAndNewAbove").key,preventDefault:!0,stopPropagation:!0,run:o=>{let s=o.state.facet(st);return s.onRun(),e==="__scratch__"||(o.contentDOM.blur(),s.moveToNextCell({cellId:e,before:!0})),!0}}),{key:n.getHotkey("cell.aiCompletion").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(st).aiCellCompletion()&&o.contentDOM.focus(),!0)}),e!=="__scratch__"&&a.push({key:n.getHotkey("cell.goToDefinition").key,run:o=>k0(o)},{key:n.getHotkey("cell.delete").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.doc.length===0&&o.state.facet(st).deleteCell(),!0)},{key:n.getHotkey("cell.moveUp").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(st).moveCell({cellId:e,before:!0}),!0)},{key:n.getHotkey("cell.moveDown").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(st).moveCell({cellId:e,before:!1}),!0)},{key:n.getHotkey("cell.moveLeft").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(st).moveCell({cellId:e,before:!0,direction:"left"}),!0)},{key:n.getHotkey("cell.moveRight").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(st).moveCell({cellId:e,before:!1,direction:"right"}),!0)},{key:"ArrowUp",run:o=>g_(o.state)?!1:Um(o)?(o.state.facet(st).moveToNextCell({cellId:e,before:!0,noCreate:!0}),!0):!1},{key:"ArrowDown",run:o=>g_(o.state)?!1:w0(o)?(o.state.facet(st).moveToNextCell({cellId:e,before:!1,noCreate:!0}),!0):!1},{key:n.getHotkey("cell.focusDown").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(st).moveToNextCell({cellId:e,before:!1,noCreate:!0}),!0)},{key:n.getHotkey("cell.focusUp").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(st).moveToNextCell({cellId:e,before:!0,noCreate:!0}),!0)},{key:n.getHotkey("cell.sendToBottom").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(st).sendToBottom({cellId:e}),!0)},{key:n.getHotkey("cell.sendToTop").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.state.facet(st).sendToTop({cellId:e}),!0)},{key:n.getHotkey("cell.createAbove").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.contentDOM.blur(),o.state.facet(st).createNewCell({cellId:e,before:!0}),!0)},{key:n.getHotkey("cell.createBelow").key,preventDefault:!0,stopPropagation:!0,run:o=>(o.contentDOM.blur(),o.state.facet(st).createNewCell({cellId:e,before:!1}),!0)},{key:n.getHotkey("cell.hideCode").key,preventDefault:!0,stopPropagation:!0,run:o=>{var c;let s=o.state.facet(st).toggleHideCode();return y_(o),s?(o.contentDOM.blur(),(c=document.getElementById(En.create(e)))==null||c.focus()):o.contentDOM.focus(),!0}},{key:n.getHotkey("cell.splitCell").key,preventDefault:!0,stopPropagation:!0,run:o=>{let s=o.state.facet(st);return s.splitCell({cellId:e}),s.moveToNextCell&&requestAnimationFrame(()=>{o.contentDOM.blur(),s.moveToNextCell({cellId:e,before:!1})}),!0}}),[Fu.high(Xa.of(a))]}function sE(e){return[Et.updateListener.of(n=>{if(n.docChanged){let a=n.transactions.some(f=>f.effects.some(d=>d.is(_s))),o=wr(n.view),s=n.view.state.facet(st),c=n.view.state.facet(da);s.updateCellCode({cellId:c,code:o,formattingChange:a}),Pe.get(_d).has(c)&&Pe.set(Cm)}}),e3(e)]}var lE=["input","delete","undo","redo"];function cE({docChanged:e,transactions:n,predicate:a=()=>!0,hasFocus:o=!1}){return!e||!a()||n.some(s=>s.effects.some(c=>c.is(_s)))?!1:n.some(s=>s.annotation(ei)===void 0?lE.some(c=>s.isUserEvent(c))||o:!1)}function uE({predicate:e}){return Et.updateListener.of(n=>{cE({docChanged:n.docChanged,transactions:n.transactions,predicate:e,hasFocus:n.view.hasFocus})&&n.view.state.facet(st).onRun()})}Rx=function({cellId:e,hotkeys:n,cellActions:a}){return[st.of(a),da.of(e),oE({cellId:e,hotkeys:n}),sE(n),iE(XS(E5(e),Pe))]};const _f=Mr.define();function dE(e){return{...e,create:n=>{let{dom:a,...o}=e.create(n),s=document.createElement("div");return s.classList.add("mo-cm-tooltip"),s.append(a),{...o,dom:s}}}}const fE=Qi.define({create:()=>null,update(e,n){for(let a of n.effects)if(a.is(_f))return a.value;return!e||n.selection&&!n.docChanged?null:n.docChanged?{...e,pos:n.changes.mapPos(e.pos)}:e},provide:e=>i_.from(e)}),_1=async e=>{var f,d;let n=e.state.doc.sliceString(0,e.pos),a=document.activeElement,o=null;if(a!==null){let m=En.findElement(a);m!==null&&(o=En.parse(m.id))}if(o===null)return _e.error("Failed to find active cell."),null;let s=await Id.request({document:n,cellId:o});if(!s)return(f=e.view)==null||f.dispatch({effects:_f.of(null)}),null;let c=gf.asHoverTooltip({position:e.pos,message:s,limitToType:"tooltip"});return c&&Pe.set(rd,{documentation:c.html??null}),(d=e.view)==null||d.dispatch({effects:_f.of(c?dE(c):null)}),c?null:gf.asCompletionResult(e.pos,s)};function pE(e){return n=>e.predicate(n.state)?e.completion(n):null}var hE=async e=>{let n=e.matchBefore(/:\w*$/);if(!e.explicit&&!n)return null;let a=await mE();return{from:(n==null?void 0:n.from)??e.pos,options:a,validFor:/^[\w:]*$/}},mE=rr(async()=>{let e=await fetch("https://unpkg.com/emojilib@3.0.11/dist/emoji-en-US.json").then(n=>{if(!n.ok)throw Error("Failed to fetch emoji list");return n.json()}).catch(()=>({}));return Object.entries(e).map(([n,a])=>({shortcode:a[0],label:a.map(o=>`:${o}`).join(" "),emoji:n,displayLabel:`${n} ${a[0].replaceAll("_"," ")}`,apply:n,type:"emoji"}))}),gE=async e=>{let n=e.matchBefore(/::[\w-:]*$/);if(!e.explicit&&!n)return null;let a=await yE();return{from:(n==null?void 0:n.from)??e.pos,options:a,validFor:/^[\w-:]*$/}},yE=rr(async()=>{let e=await fetch("https://unpkg.com/lucide-static@0.452.0/tags.json").then(a=>{if(!a.ok)throw Error("Failed to fetch Lucide icon list");return a.json()}).catch(()=>({})),n=a=>`https://cdn.jsdelivr.net/npm/lucide-static@0.452.0/icons/${a}.svg`;return Object.entries(e).map(([a,o])=>({label:`::${a}`,displayLabel:a,type:"lucide-icon",boost:10,apply:`::lucide:${a}::`,detail:o.join(", "),info:()=>{let s=document.createElement("img");return s.src=n(a),s.style.width="24px",s.style.height="24px",s}}))}),vE=e=>{let n=e.matchBefore(/\\\w*$/);return!e.explicit&&!n?null:{from:(n==null?void 0:n.from)??e.pos,options:bE(),validFor:/^[\w\\]*$/}},bE=rr(()=>[["alpha","\u03B1","Greek small letter alpha"],["beta","\u03B2","Greek small letter beta"],["gamma","\u03B3","Greek small letter gamma"],["delta","\u03B4","Greek small letter delta"],["epsilon","\u03B5","Greek small letter epsilon"],["zeta","\u03B6","Greek small letter zeta"],["eta","\u03B7","Greek small letter eta"],["theta","\u03B8","Greek small letter theta"],["iota","\u03B9","Greek small letter iota"],["kappa","\u03BA","Greek small letter kappa"],["lambda","\u03BB","Greek small letter lambda"],["mu","\u03BC","Greek small letter mu"],["nu","\u03BD","Greek small letter nu"],["xi","\u03BE","Greek small letter xi"],["omicron","\u03BF","Greek small letter omicron"],["pi","\u03C0","Greek small letter pi"],["rho","\u03C1","Greek small letter rho"],["sigma","\u03C3","Greek small letter sigma"],["tau","\u03C4","Greek small letter tau"],["upsilon","\u03C5","Greek small letter upsilon"],["phi","\u03C6","Greek small letter phi"],["chi","\u03C7","Greek small letter chi"],["psi","\u03C8","Greek small letter psi"],["omega","\u03C9","Greek small letter omega"],["Gamma","\u0393","Greek capital letter gamma"],["Delta","\u0394","Greek capital letter delta"],["Theta","\u0398","Greek capital letter theta"],["Lambda","\u039B","Greek capital letter lambda"],["Xi","\u039E","Greek capital letter xi"],["Pi","\u03A0","Greek capital letter pi"],["Sigma","\u03A3","Greek capital letter sigma"],["Phi","\u03A6","Greek capital letter phi"],["Psi","\u03A8","Greek capital letter psi"],["Omega","\u03A9","Greek capital letter omega"],["pm","\xB1","Plus-minus sign"],["mp","\u2213","Minus-plus sign"],["times","\xD7","Multiplication sign"],["div","\xF7","Division sign"],["cdot","\u22C5","Dot operator"],["ast","\u2217","Asterisk operator"],["star","\u22C6","Star operator"],["circ","\u2218","Ring operator"],["bullet","\u2022","Bullet"],["cap","\u2229","Intersection"],["cup","\u222A","Union"],["uplus","\u228E","Multiset union"],["sqcap","\u2293","Square cap"],["sqcup","\u2294","Square cup"],["vee","\u2228","Logical or"],["wedge","\u2227","Logical and"],["setminus","\u2216","Set minus"],["oplus","\u2295","Circled plus"],["ominus","\u2296","Circled minus"],["otimes","\u2297","Circled times"],["oslash","\u2298","Circled division slash"],["odot","\u2299","Circled dot operator"],["leq","\u2264","Less than or equal to"],["geq","\u2265","Greater than or equal to"],["equiv","\u2261","Identical to"],["prec","\u227A","Precedes"],["succ","\u227B","Succeeds"],["sim","\u223C","Tilde operator"],["perp","\u22A5","Up tack"],["mid","\u2223","Divides"],["parallel","\u2225","Parallel to"],["subset","\u2282","Subset of"],["supset","\u2283","Superset of"],["subseteq","\u2286","Subset of or equal to"],["supseteq","\u2287","Superset of or equal to"],["cong","\u2245","Approximately equal to"],["approx","\u2248","Almost equal to"],["neq","\u2260","Not equal to"],["ne","\u2260","Not equal to"],["propto","\u221D","Proportional to"],["leftarrow","\u2190","Leftward arrow"],["rightarrow","\u2192","Rightward arrow"],["Leftarrow","\u21D0","Leftward double arrow"],["Rightarrow","\u21D2","Rightward double arrow"],["leftrightarrow","\u2194","Left right arrow"],["Leftrightarrow","\u21D4","Left right double arrow"],["uparrow","\u2191","Upward arrow"],["downarrow","\u2193","Downward arrow"],["Uparrow","\u21D1","Upward double arrow"],["Downarrow","\u21D3","Downward double arrow"],["infty","\u221E","Infinity"],["nabla","\u2207","Nabla"],["partial","\u2202","Partial differential"],["forall","\u2200","For all"],["exists","\u2203","There exists"],["nexists","\u2204","There does not exist"],["emptyset","\u2205","Empty set"],["in","\u2208","Element of"],["notin","\u2209","Not an element of"],["sum","\u2211","N-ary summation"],["prod","\u220F","N-ary product"],["int","\u222B","Integral"],["oint","\u222E","Contour integral"],["sqrt","\u221A","Square root"],["hbar","\u210F","Planck constant over 2pi"],["ldots","\u2026","Horizontal ellipsis"],["cdots","\u22EF","Midline horizontal ellipsis"],["vdots","\u22EE","Vertical ellipsis"],["ddots","\u22F1","Down right diagonal ellipsis"]].map(([e,n,a])=>({label:`\\${e} ${a}`,displayLabel:e,type:"latex-symbol",boost:10,apply:`\\${e}`,info:()=>{let o=document.createElement("div");return o.textContent=`${n} ${a}`,o},detail:n})));const wE=[hE,gE,vE];var _E=100;function uo(e){return!e.state.selection.main.empty}function xf({view:e,selection:n,markup:a}){let o=[],s=!0;for(let c=n.from;c<=n.to;c++)if(!e.state.doc.lineAt(c).text.startsWith(a)){s=!1;break}for(let c=n.from;c<=n.to;){let f=e.state.doc.lineAt(c),d=f.text.startsWith(a);s?o.push({from:f.from,to:f.from+a.length,insert:Ki.of([""])}):(d&&o.push({from:f.from,to:f.from+a.length,insert:Ki.of([""])}),o.push({from:f.from,insert:Ki.of([a])})),c=f.to+1}return o}function kf({view:e,range:n,markupAfter:a,markupBefore:o}){if(n.empty){let b=e.state.wordAt(n.head);b&&(n=b)}let s=e.state.sliceDoc(n.from-o.length,n.from)===o,c=e.state.sliceDoc(n.to,n.to+a.length)===a,f=[];f.push(s?{from:n.from-o.length,to:n.from,insert:Ki.of([""])}:{from:n.from,insert:Ki.of(o.split(`
|
|
96
96
|
`))},c?{from:n.to,to:n.to+a.length,insert:Ki.of([""])}:{from:n.to,insert:Ki.of(a.split(`
|
|
97
97
|
`))});let d=s?-o.length:o.length,m=c?-a.length:a.length;return{changes:f,range:$t.range(n.from+d,n.to+m)}}function xE(e){if(!uo(e))return!1;let n=xf({view:e,selection:e.state.selection.main,markup:"> "});return n.length>0&&e.dispatch(e.state.update({changes:n,scrollIntoView:!0,userEvent:"input"})),e.focus(),!0}function kE(e){if(!uo(e))return!1;let n=e.state.changeByRange(a=>{if(a.empty){let o=e.state.wordAt(a.head);o&&(a=o)}return kf({view:e,range:a,markupBefore:"**",markupAfter:"**"})});return e.dispatch(e.state.update(n,{scrollIntoView:!0,annotations:ss.userEvent.of("input")})),e.focus(),!0}function x1(e){if(!uo(e))return!1;let n=e.state.changeByRange(a=>{if(a.empty){let s=e.state.wordAt(a.head);s&&(a=s)}let o=e.state.doc.lineAt(a.from).number!==e.state.doc.lineAt(a.to).number;return kf({view:e,range:a,markupBefore:o?"```\n":"`",markupAfter:o?"\n```":"`"})});return e.dispatch(e.state.update(n,{scrollIntoView:!0,annotations:ss.userEvent.of("input")})),e.focus(),!0}function CE(e){let n=e.state.changeByRange(a=>{if(a.empty){let o=e.state.wordAt(a.head);o&&(a=o)}return kf({view:e,range:a,markupBefore:"_",markupAfter:"_"})});return e.dispatch(e.state.update(n,{scrollIntoView:!0,annotations:ss.userEvent.of("input")})),e.focus(),!0}function k1(e,n="http://"){if(!uo(e))return!1;let a=e.state.changeByRange(s=>{let c=e.state.sliceDoc(s.from,s.to);return{changes:[{from:s.from,to:s.to,insert:`[${c}](${n})`}],range:s}});e.dispatch(e.state.update(a,{scrollIntoView:!0,annotations:ss.userEvent.of("input")}));let{to:o}=a.selection.main;try{e.dispatch({selection:$t.create([$t.range(o+3,o+3+n.length),$t.cursor(o+3+n.length)])})}catch{}return e.focus(),!0}y0=async function(e,n){var d;let a=new FileReader,o=await new Promise(m=>{a.onload=()=>m(a.result),a.readAsDataURL(n)}),s;try{if(o.startsWith("data:")){let m=prompt("We can save your image as a file. Enter a filename.",n.name),b=n.type.split("/")[1];if(m===null){let w=Math.round(o.length/1024);if(w>_E){Il({title:"Content too large",description:`The content size is ${w} KB, which is too large to paste directly into the document.`});return}}else{m.trim()===""?m=n.name:m.endsWith(`.${b}`)||(m=`${m}.${b}`);let w=Pe.get(ps),x=w?k_.dirname(w):null,S=x?`${x}/public`:"public",E=await br().sendCreateFileOrFolder({path:S,type:"file",name:m,file:n});E.success?(s=(d=E.info)==null?void 0:d.path,s&&x&&s.startsWith(x)&&(s=k_.rest(s,x).replaceAll("\\","/")),Il({title:"Image uploaded successfully",description:`We've uploaded your image at ${s}`})):Il({title:"Failed to upload image. Using raw base64 string."})}}}catch{Il({title:"Failed to upload image. Using raw base64 string."})}let c=e.state.changeByRange(m=>{let b=e.state.sliceDoc(m.from,m.to);return b.trim()===""&&(b="alt"),{changes:[{from:m.from,to:m.to,insert:``}],range:m}});e.dispatch(e.state.update(c,{scrollIntoView:!0,annotations:ss.userEvent.of("input")}));let{to:f}=c.selection.main;try{e.dispatch({selection:$t.create([$t.range(f+4,f+4+o.length),$t.cursor(f+4+o.length)])})}catch{}return e.focus(),!0},n0=async function(e,n){let a=await n.text(),o=e.state.changeByRange(s=>({changes:[{from:s.from,to:s.from,insert:a}],range:s}));return e.dispatch(e.state.update(o,{scrollIntoView:!0,annotations:ss.userEvent.of("input")})),e.focus(),!0};function SE(e){if(!uo(e))return!1;let{changes:n}=e.state.changeByRange(a=>({range:a,changes:xf({view:e,selection:a,markup:e.state.sliceDoc(a.from,a.to+2).startsWith("* ")?"* ":"- "})}));return n.length>0&&e.dispatch(e.state.update({changes:n,scrollIntoView:!0,userEvent:"input"})),e.focus(),!0}function EE(e){if(!uo(e))return!1;let{changes:n}=e.state.changeByRange(a=>({range:a,changes:xf({view:e,selection:a,markup:"1. "})}));return n.length>0&&e.dispatch(e.state.update({changes:n,scrollIntoView:!0,userEvent:"input"})),e.focus(),!0}function TE(e){return[Fu.highest(Xa.of([{key:e.getHotkey("markdown.bold").key,stopPropagation:!0,run:kE},{key:e.getHotkey("markdown.italic").key,stopPropagation:!0,run:CE},{key:e.getHotkey("markdown.link").key,stopPropagation:!0,run:n=>k1(n)},{key:e.getHotkey("markdown.orderedList").key,run:EE},{key:e.getHotkey("markdown.unorderedList").key,run:SE},{key:e.getHotkey("markdown.blockquote").key,run:xE},{key:e.getHotkey("markdown.code").key,run:x1},{key:"`",run:x1}])),Et.domEventHandlers({paste:(n,a)=>{var s;if(a.state.selection.main.empty)return!1;let o=(s=n.clipboardData)==null?void 0:s.getData("text/plain");o!=null&&o.startsWith("http")&&(n.preventDefault(),k1(a,o))}}),Et.domEventHandlers({paste:(n,a)=>{var s;let o=(s=n.clipboardData)==null?void 0:s.files[0];if(!o)return!1;if(o.type.startsWith("image/"))return n.preventDefault(),y0(a,o),!0;if(o.type.startsWith("text/"))return n.preventDefault(),n0(a,o),!0}})]}function IE(e,n,a=3,o=""){return Object.values(e).flatMap(s=>n.has(s.name)?[]:{label:`${o}${s.name}`,displayLabel:s.name,detail:s.dataType??"",boost:a,type:"variable",apply:`${o}${s.name}`,section:"Variable",info:()=>d0(s)})}d0=function(e){let n=document.createElement("div");n.classList.add("mo-cm-tooltip","docs-documentation","min-w-[200px]","flex","flex-col","gap-1","p-2");let a=document.createElement("div");a.classList.add("flex","items-center","gap-2");let o=document.createElement("span");if(o.classList.add("font-bold","text-base"),o.textContent=e.name,a.append(o),e.dataType){let s=document.createElement("span");s.classList.add("text-xs","px-1.5","py-0.5","rounded-full","bg-purple-100","text-purple-800","dark:bg-purple-900","dark:text-purple-200"),s.textContent=e.dataType,a.append(s)}if(n.append(a),e.value){let s=document.createElement("div");s.classList.add("flex","flex-col","gap-1");let c=document.createElement("div");c.classList.add("text-xs","text-muted-foreground"),c.textContent="Value:",s.append(c);let f=document.createElement("div");f.classList.add("text-xs","font-mono","bg-muted","p-2","rounded","overflow-auto","max-h-40"),f.textContent=e.value,s.append(f),n.append(s)}return n};var fo="Python",Cf=123,C1=125,Sf=1,LE={mark:`${fo}Mark`,resolve:fo};function OE(e,n){return{defineNodes:[{name:fo,style:Vu.emphasis},{name:`${fo}Mark`,style:Vu.processingInstruction}],parseInline:[{name:fo,parse(a,o,s){return!n()||o!==Cf&&o!==C1||o===Cf&&a.slice(s-1,s)==="{"?-1:a.addDelimiter(LE,s,s+Sf,o===Cf,o===C1)}}],wrap:u_(a=>{if(!n()||a.type.name!==fo)return null;let o=a.from+Sf,s=a.to-Sf;return o>=s||o<0||s<0?null:{parser:e,overlay:[{from:o,to:s}],extensions:[x_().support]}})}}const AE=e=>{let n=e.state.doc.sliceString(0,e.pos),a=n.lastIndexOf("{");if(n.at(a-1)==="{"||a===-1||n.indexOf("}",a)>a)return null;let o=e.matchBefore(/\w*$/);if(!o)return null;let s=IE(Pe.get(Ya),new Set,99);return{from:o.from,options:s,validFor:/^\w*$/}};var tc="InlineMathDollar",po="InlineMathBracket",nc="BlockMathDollar",ho="BlockMathBracket",ui={[tc]:1,[po]:3,[nc]:2,[ho]:3},pt={DOLLAR:36,BACKSLASH:92,OPEN_PAREN:40,CLOSE_PAREN:41,OPEN_BRACKET:91,CLOSE_BRACKET:93},mo=Object.keys(ui).reduce((e,n)=>(e[n]={mark:`${n}Mark`,resolve:n},e),{});function RE(e){let n=[];return Object.keys(ui).forEach(a=>{n.push({name:a,style:Vu.emphasis},{name:`${a}Mark`,style:Vu.processingInstruction})}),{defineNodes:n,parseInline:[{name:nc,parse(a,o,s){return o!==pt.DOLLAR||a.char(s+1)!==pt.DOLLAR?-1:a.addDelimiter(mo[nc],s,s+ui[nc],!0,!0)}},{name:tc,parse(a,o,s){return o!==pt.DOLLAR||a.char(s+1)===pt.DOLLAR?-1:a.addDelimiter(mo[tc],s,s+ui[tc],!0,!0)}},{name:po,before:"Escape",parse(a,o,s){return o!==pt.BACKSLASH||a.char(s+1)!==pt.BACKSLASH||![pt.OPEN_PAREN,pt.CLOSE_PAREN].includes(a.char(s+2))?-1:a.addDelimiter(mo[po],s,s+ui[po],a.char(s+2)===pt.OPEN_PAREN,a.char(s+2)===pt.CLOSE_PAREN)}},{name:ho,before:"Escape",parse(a,o,s){return o!==pt.BACKSLASH||a.char(s+1)!==pt.BACKSLASH||![pt.OPEN_BRACKET,pt.CLOSE_BRACKET].includes(a.char(s+2))?-1:a.addDelimiter(mo[ho],s,s+ui[ho],a.char(s+2)===pt.OPEN_BRACKET,a.char(s+2)===pt.CLOSE_BRACKET)}},{name:po,before:"Escape",parse(a,o,s){return o!==pt.BACKSLASH||![pt.OPEN_PAREN,pt.CLOSE_PAREN].includes(a.char(s+1))?-1:a.addDelimiter(mo[po],s,s+2,a.char(s+1)===pt.OPEN_PAREN,a.char(s+1)===pt.CLOSE_PAREN)}},{name:ho,before:"Escape",parse(a,o,s){return o!==pt.BACKSLASH||![pt.OPEN_BRACKET,pt.CLOSE_BRACKET].includes(a.char(s+1))?-1:a.addDelimiter(mo[ho],s,s+2,a.char(s+1)===pt.OPEN_BRACKET,a.char(s+1)===pt.CLOSE_BRACKET)}}],wrap:u_(a=>{let o=ui[a.type.name];if(o){let s=a.from+o,c=a.to-o;return s>=c||s<0||c<0?null:{parser:e,overlay:[{from:s,to:c}]}}return null})}}dd=Mr.define(),kd=Mr.define(),Nr=Qi.define({create:()=>({}),update:(e,n)=>{for(let a of n.effects){if(a.is(dd))return a.value;if(a.is(kd))return{...e,...a.value}}return e}}),Ix=!0,nd=class{constructor(){we(this,"parser",new td);we(this,"type","markdown");we(this,"defaultCode",this.parser.defaultCode);we(this,"defaultMetadata",this.parser.defaultMetadata)}static fromMarkdown(e){return td.fromMarkdown(e)}transformIn(e){let n=this.parser.transformIn(e);return[n.code,n.offset,n.metadata]}transformOut(e,n){let a=this.parser.transformOut(e,n);return[a.code,a.offset]}isSupported(e){return this.parser.isSupported(e)}getExtension(e,n,a,o){let s=w_().language.data,c,f=()=>{var m;if(!c)return!0;let d=c==null?void 0:c.state.field(Nr);return d===void 0?!1:((m=d.quotePrefix)==null?void 0:m.includes("f"))??!1};return[Gi.define(d=>(c=d,{})),w_({base:$8,codeLanguages:CS,extensions:[RE(c_.define(K8).parser),OE(im.parser,f)]}),TE(a),wE.map(d=>s.of({autocomplete:d})),x_().language.data.of({autocomplete:pE({completion:_1,predicate:f})}),Hu({defaultKeymap:!1,activateOnTyping:!0}),uE({predicate:()=>!f()})]}};function rc(){var e;return((e=Pe.get(Pl))==null?void 0:e.rootUri)??"file:///"}function ac(){var n;let e=(n=Pe.get(Pl))==null?void 0:n.rootUri;return e?[{uri:e,name:"marimo"}]:[]}function S1(){var e;return((e=Pe.get(Pl))==null?void 0:e.documentUri)??"file:///__marimo_notebook__.py"}function PE(e){return Rr.filter(e,n=>n!==!1&&n!==null)}function E1(e){let n=e.map(PE);return Object.assign({},...n)}var ME=class{constructor(e){we(this,"clients",[]);this.clients=e,this.documentUri=S1()}onNotification(e){let n=[];for(let a of this.clients)n.push(a.onNotification(e));return()=>{for(let a of n)a();return!0}}get clientCapabilities(){return E1(this.clients.map(e=>{if(e.clientCapabilities)return typeof e.clientCapabilities=="function"?e.clientCapabilities({}):e.clientCapabilities}).filter(e=>e!=null))}get ready(){return this.clients.some(e=>e.ready)}set ready(e){this.clients.forEach(n=>{n.ready=e})}get capabilities(){return E1(this.clients.map(e=>e.capabilities).filter(e=>e!==null))}set capabilities(e){this.clients.forEach(n=>{n.capabilities=e})}get initializePromise(){return this.clients[0].initializePromise}set initializePromise(e){this.clients.forEach(n=>{n.initializePromise=e})}firstWithCapability(e){return this.clients.find(n=>{var a;return(a=n.capabilities)==null?void 0:a[e]})}clientsWithCapability(e){return this.clients.filter(n=>{var a;return(a=n.capabilities)==null?void 0:a[e]})}async initialize(){await Promise.all(this.clients.map(e=>e.initialize()))}async close(){await Promise.all(this.clients.map(e=>e.close()))}async textDocumentDidChange(e){return await Promise.all(this.clients.map(n=>n.textDocumentDidChange(e))),e}async completionItemResolve(e){let n=this.firstWithCapability("completionProvider");return n?n.completionItemResolve(e):e}async textDocumentCodeAction(e){let n=this.firstWithCapability("codeActionProvider");return n?n.textDocumentCodeAction(e):null}async textDocumentRename(e){let n=this.firstWithCapability("renameProvider");return n?n.textDocumentRename(e):null}async textDocumentPrepareRename(e){let n=this.firstWithCapability("renameProvider");return n?n.textDocumentPrepareRename(e):null}async textDocumentSignatureHelp(e){let n=this.firstWithCapability("signatureHelpProvider");return n?n.textDocumentSignatureHelp(e):null}async textDocumentCompletion(e){let n=this.clientsWithCapability("completionProvider");return NE(await Promise.allSettled(n.map(a=>a.textDocumentCompletion(e))))}async textDocumentDefinition(e){let n=this.firstWithCapability("definitionProvider");return n?n.textDocumentDefinition(e):null}async textDocumentDidOpen(e){return await Promise.all(this.clients.map(n=>n.textDocumentDidOpen(e))),e}async textDocumentHover(e){var n;for(let a of this.clients){if(!((n=a.capabilities)!=null&&n.hoverProvider))continue;let o=await a.textDocumentHover(e);if(o)return o}return{contents:[]}}};function NE(e){let n=[],a=!1;for(let o of e)if(o.status==="fulfilled"){let s=o.value;if(s==null)continue;Array.isArray(s)&&n.push(...s),"items"in s&&(n.push(...s.items),a||(a=s.isIncomplete))}return{items:n,isIncomplete:a}}function DE(e){let n=__.parse(e),a="";return YI(e,n,BI,(o,s)=>{let c=o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");a+=s?`<span class="${s}">${c}</span>`:c},()=>{a+=`
|
|
98
98
|
`}),a}function jE(){let e=new $u.Renderer,n=e.code.bind(e);return e.code=a=>{let{text:o,lang:s}=a;return o.trim()?s==="python"||s==="py"?`<pre><code class="language-python">${DE(o)}</code></pre>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as D}from"./chunk-LvLJmgfZ.js";import{t as H}from"./react-Bj1aDYRI.js";import{vr as K,wr as Q,yr as U}from"./cells-RJTD-euN.js";import{A as X,C as O,R as E,T as Z}from"./zod-H_cgTO0M.js";import{t as S}from"./compiler-runtime-B3qBwwSJ.js";import{t as ee}from"./isEmpty-CXeoXbuc.js";import{Y as te}from"./ai-model-dropdown-BP8gjnOy.js";import{_ as re}from"./useEventListener-BakX-tnw.js";import{t as k}from"./cn-X2M2usMq.js";import{t as se}from"./jsx-runtime-PbYoItBR.js";import{a as F,i as $,o as J,r as M}from"./config-DMNo9K-z.js";import{t as V}from"./button-BF7GSjhW.js";import{i as T}from"./strings-DvZlHYnD.js";import{t as W}from"./createLucideIcon-BTp1tQDO.js";import{t as ae}from"./ban-CttLZK8l.js";import{t as le}from"./bot-message-square-AslRbAeb.js";import{r as ne}from"./x-9vLEgLY6.js";import{t as G}from"./markdown-renderer-jghC8PFL.js";import{f as I,l as ie}from"./add-cell-with-ai-DwzlK27e.js";import{t as oe}from"./external-link-BktyywYg.js";import{n as ce}from"./spinner-BbI9qk88.js";import{l as de}from"./datasource-RP7m6Xrh.js";import{t as ue}from"./RenderHTML-B9mw7TD1.js";var me=W("circle-slash",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]]),pe=W("shield-question-mark",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),xe=S(),C=D(H(),1),r=D(se(),1);const he=c=>{let e=(0,xe.c)(13),{reasoning:l,index:n,isStreaming:s}=c,i=n===void 0?0:n,t=s===void 0?!1:s,[a,u]=C.useState("");if(!l&&!t)return null;let h=t?"reasoning":a,p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=(0,r.jsx)(le,{className:"h-3 w-3"}),e[0]=p):p=e[0];let v=t?"Thinking":"View reasoning",x=l.length>0&&` (${l.length} chars)`,d;e[1]!==v||e[2]!==x?(d=(0,r.jsx)(J,{className:"text-xs text-muted-foreground hover:bg-muted/50 px-2 py-1 h-auto rounded-sm [&[data-state=open]>svg]:rotate-180",children:(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[p,v,x]})}),e[1]=v,e[2]=x,e[3]=d):d=e[3];let m;e[4]===l?m=e[5]:(m=(0,r.jsx)($,{className:"pb-2 px-2",children:(0,r.jsx)("div",{className:"bg-muted/30 border border-muted/50 rounded-md p-3 italic text-muted-foreground/90 relative",children:(0,r.jsx)("div",{className:"pr-6",children:(0,r.jsx)(G,{content:l})})})}),e[4]=l,e[5]=m);let o;e[6]!==d||e[7]!==m?(o=(0,r.jsxs)(F,{value:"reasoning",className:"border-0",children:[d,m]}),e[6]=d,e[7]=m,e[8]=o):o=e[8];let f;return e[9]!==i||e[10]!==h||e[11]!==o?(f=(0,r.jsx)(M,{type:"single",collapsible:!0,className:"w-full mb-2",value:h,onValueChange:u,children:o},i),e[9]=i,e[10]=h,e[11]=o,e[12]=f):f=e[12],f};function L(c){return c.replace("tool-","")}var fe=S();const q=c=>{let e=(0,fe.c)(9),{input:l,label:n}=c,s=n===void 0?"Tool Request":n;if(l==null)return null;let i;e[0]===s?i=e[1]:(i=(0,r.jsx)("h3",{className:"text-xs font-semibold text-muted-foreground",children:s}),e[0]=s,e[1]=i);let t;e[2]===l?t=e[3]:(t=JSON.stringify(l,null,2),e[2]=l,e[3]=t);let a;e[4]===t?a=e[5]:(a=(0,r.jsx)("pre",{className:"bg-(--slate-2) p-2 text-muted-foreground border border-(--slate-4) rounded text-xs overflow-auto scrollbar-thin max-h-64",children:t}),e[4]=t,e[5]=a);let u;return e[6]!==i||e[7]!==a?(u=(0,r.jsxs)("div",{className:"space-y-2",children:[i,a]}),e[6]=i,e[7]=a,e[8]=u):u=e[8],u};var ve=S();const be=c=>{let e=(0,ve.c)(25),{toolName:l,input:n,approval:s,onApprove:i,className:t}=c,a;e[0]===t?a=e[1]:(a=k("rounded-md border border-(--amber-6) bg-(--amber-2) p-3 space-y-3",t),e[0]=t,e[1]=a);let u=`Approval required for ${L(l)}`,h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=(0,r.jsx)(pe,{className:"h-4 w-4 text-(--amber-11) mt-0.5 shrink-0"}),e[2]=h):h=e[2];let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p=(0,r.jsx)("span",{className:"font-semibold",children:"Approval required:"}),e[3]=p):p=e[3];let v;e[4]===l?v=e[5]:(v=L(l),e[4]=l,e[5]=v);let x;e[6]===v?x=e[7]:(x=(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[h,(0,r.jsxs)("div",{className:"text-xs text-(--amber-11) leading-relaxed",children:[p," ",(0,r.jsx)("code",{className:"font-mono",children:v})]})]}),e[6]=v,e[7]=x);let d;e[8]===n?d=e[9]:(d=(0,r.jsx)(q,{input:n}),e[8]=n,e[9]=d);let m;e[10]!==s.id||e[11]!==i?(m=(0,r.jsx)(V,{size:"xs",variant:"outline",onClick:()=>i({id:s.id,approved:!1}),children:"Deny"}),e[10]=s.id,e[11]=i,e[12]=m):m=e[12];let o;e[13]!==s.id||e[14]!==i?(o=(0,r.jsx)(V,{size:"xs",onClick:()=>i({id:s.id,approved:!0}),children:"Approve"}),e[13]=s.id,e[14]=i,e[15]=o):o=e[15];let f;e[16]!==m||e[17]!==o?(f=(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[m,o]}),e[16]=m,e[17]=o,e[18]=f):f=e[18];let b;return e[19]!==a||e[20]!==f||e[21]!==u||e[22]!==x||e[23]!==d?(b=(0,r.jsxs)("div",{className:a,role:"alertdialog","aria-label":u,children:[x,d,f]}),e[19]=a,e[20]=f,e[21]=u,e[22]=x,e[23]=d,e[24]=b):b=e[24],b};var je=S();const ge=c=>{let e=(0,je.c)(28),{toolName:l,input:n,errorText:s,isLive:i,className:t}=c,[a,u]=C.useState(i),h=C.useRef(i),p,v;e[0]===i?(p=e[1],v=e[2]):(p=()=>{h.current&&!i&&u(!1),h.current=i},v=[i],e[0]=i,e[1]=p,e[2]=v),C.useEffect(p,v);let x;e[3]===t?x=e[4]:(x=k("rounded-md border border-(--red-6) bg-(--red-2)",t),e[3]=t,e[4]=x);let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=()=>u(Ne),e[5]=d):d=e[5];let m;e[6]===Symbol.for("react.memo_cache_sentinel")?(m=(0,r.jsx)(Q,{className:"h-3.5 w-3.5 shrink-0"}),e[6]=m):m=e[6];let o;e[7]===Symbol.for("react.memo_cache_sentinel")?(o=(0,r.jsx)("span",{className:"font-semibold",children:"Failed:"}),e[7]=o):o=e[7];let f;e[8]===l?f=e[9]:(f=L(l),e[8]=l,e[9]=f);let b;e[10]===f?b=e[11]:(b=(0,r.jsxs)("span",{className:"flex-1 text-left",children:[o," ",(0,r.jsx)("code",{className:"font-mono",children:f})]}),e[10]=f,e[11]=b);let _=a&&"rotate-180",j;e[12]===_?j=e[13]:(j=k("h-3.5 w-3.5 shrink-0 transition-transform",_),e[12]=_,e[13]=j);let g;e[14]===j?g=e[15]:(g=(0,r.jsx)(ne,{className:j}),e[14]=j,e[15]=g);let N;e[16]!==a||e[17]!==g||e[18]!==b?(N=(0,r.jsxs)("button",{type:"button",onClick:d,className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-(--red-11) hover:bg-(--red-3) rounded-md transition-colors","aria-expanded":a,children:[m,b,g]}),e[16]=a,e[17]=g,e[18]=b,e[19]=N):N=e[19];let y;e[20]!==s||e[21]!==n||e[22]!==a?(y=a&&(0,r.jsxs)("div",{className:"px-3 pb-3 space-y-3 border-t border-(--red-6)/40 pt-3",children:[(0,r.jsx)(q,{input:n}),s&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-xs font-semibold text-(--red-11) mb-1",children:"Error"}),(0,r.jsx)("pre",{className:"bg-(--red-2) border border-(--red-6) rounded p-2 text-xs text-(--red-11) leading-relaxed overflow-auto scrollbar-thin max-h-64 whitespace-pre-wrap",children:s})]})]}),e[20]=s,e[21]=n,e[22]=a,e[23]=y):y=e[23];let w;return e[24]!==N||e[25]!==y||e[26]!==x?(w=(0,r.jsxs)("div",{className:x,children:[N,y]}),e[24]=N,e[25]=y,e[26]=x,e[27]=w):w=e[27],w};function Ne(c){return!c}var P=S();function ye(c){return c==null?!0:typeof c=="object"?ee(c):!1}var we=X({status:E().default("success"),auth_required:Z().default(!1),action_url:O(),next_steps:O(),meta:O(),message:E().nullish()}),_e=c=>{let e=(0,P.c)(12),{data:l}=c,n;if(e[0]!==l){let{status:s,auth_required:i,action_url:t,meta:a,next_steps:u,message:h,...p}=l,v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=(0,r.jsx)("h3",{className:"text-xs font-semibold text-muted-foreground",children:"Tool Result"}),e[2]=v):v=e[2];let x;e[3]===s?x=e[4]:(x=(0,r.jsx)("span",{className:"text-xs px-2 py-0.5 bg-(--grass-2) text-(--grass-11) rounded-full font-medium capitalize",children:s}),e[3]=s,e[4]=x);let d;e[5]===i?d=e[6]:(d=i&&(0,r.jsx)("span",{className:"text-xs px-2 py-0.5 bg-(--amber-2) text-(--amber-11) rounded-full",children:"Auth Required"}),e[5]=i,e[6]=d);let m;e[7]!==x||e[8]!==d?(m=(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[v,(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[x,d]})]}),e[7]=x,e[8]=d,e[9]=m):m=e[9];let o;e[10]===h?o=e[11]:(o=h&&(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)(K,{className:"h-3 w-3 text-(--blue-11) mt-0.5 shrink-0"}),(0,r.jsx)("div",{className:"text-xs text-foreground",children:h})]}),e[10]=h,e[11]=o),n=(0,r.jsxs)("div",{className:"flex flex-col gap-1.5",children:[m,o,p&&(0,r.jsx)("div",{className:"space-y-3",children:Object.entries(p).map(Ae)})]}),e[0]=l,e[1]=n}else n=e[1];return n};const Se=c=>{let e=(0,P.c)(8),{result:l}=c,n;e[0]===l?n=e[1]:(n=we.safeParse(l),e[0]=l,e[1]=n);let s=n;if(s.success){let a;return e[2]===s.data?a=e[3]:(a=(0,r.jsx)(_e,{data:s.data}),e[2]=s.data,e[3]=a),a}let i;e[4]===l?i=e[5]:(i=typeof l=="string"?l:JSON.stringify(l,null,2),e[4]=l,e[5]=i);let t;return e[6]===i?t=e[7]:(t=(0,r.jsx)("div",{className:"text-xs font-medium text-muted-foreground mb-1 max-h-64 overflow-y-auto scrollbar-thin",children:i}),e[6]=i,e[7]=t),t};function Ae(c){let[e,l]=c;return ye(l)?null:(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:e}),(0,r.jsx)("pre",{className:"bg-(--slate-2) p-2 text-muted-foreground border border-(--slate-4) rounded text-xs overflow-auto scrollbar-thin max-h-64",children:JSON.stringify(l,null,2)})]},e)}var z=S(),ke={"input-streaming":"Generating","input-available":"Running","approval-responded":"Awaiting result","output-available":"Done","output-denied":"Denied"},Te=new Set(["input-streaming","input-available","approval-responded"]),Ce=c=>{let e=(0,z.c)(5),{state:l,interrupted:n}=c;if(n){let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,r.jsx)(me,{className:"h-3 w-3 text-muted-foreground"}),e[0]=s):s=e[0],s}switch(l){case"input-streaming":case"input-available":case"approval-responded":{let s;return e[1]===Symbol.for("react.memo_cache_sentinel")?(s=(0,r.jsx)(ce,{className:"h-3 w-3 animate-spin"}),e[1]=s):s=e[1],s}case"output-available":{let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,r.jsx)(te,{className:"h-3 w-3 text-(--grass-11)"}),e[2]=s):s=e[2],s}case"output-denied":{let s;return e[3]===Symbol.for("react.memo_cache_sentinel")?(s=(0,r.jsx)(ae,{className:"h-3 w-3 text-muted-foreground"}),e[3]=s):s=e[3],s}default:{T(l);let s;return e[4]===Symbol.for("react.memo_cache_sentinel")?(s=(0,r.jsx)(de,{className:"h-3 w-3"}),e[4]=s):s=e[4],s}}};function qe(c){switch(c){case"output-available":return"text-(--grass-11)/80";case"output-denied":return"text-muted-foreground";case"input-streaming":case"input-available":case"approval-responded":return"";default:return T(c),""}}const Y=c=>{let e=(0,z.c)(34),{toolName:l,state:n,input:s,result:i,approval:t,index:a,className:u,isActive:h}=c,p=a===void 0?0:a,v=h===void 0?!0:h,x;e[0]!==v||e[1]!==n?(x=!v&&Te.has(n),e[0]=v,e[1]=n,e[2]=x):x=e[2];let d=x,m=`tool-${p}`,o;e[3]===u?o=e[4]:(o=k("w-full",u),e[3]=u,e[4]=o);let f;e[5]!==d||e[6]!==n?(f=k("h-6 text-xs border-border shadow-none! ring-0! bg-muted/60 hover:bg-muted py-0 px-2 gap-1 rounded-sm [&[data-state=open]>svg]:rotate-180 hover:no-underline",d?"text-muted-foreground":qe(n)),e[5]=d,e[6]=n,e[7]=f):f=e[7];let b;e[8]!==d||e[9]!==n?(b=(0,r.jsx)(Ce,{state:n,interrupted:d}),e[8]=d,e[9]=n,e[10]=b):b=e[10];let _=d?"Interrupted":ke[n],j;e[11]===l?j=e[12]:(j=L(l),e[11]=l,e[12]=j);let g;e[13]===j?g=e[14]:(g=(0,r.jsx)("code",{className:"font-mono text-xs",children:j}),e[13]=j,e[14]=g);let N;e[15]!==g||e[16]!==b||e[17]!==_?(N=(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[b,_,":",g]}),e[15]=g,e[16]=b,e[17]=_,e[18]=N):N=e[18];let y;e[19]!==N||e[20]!==f?(y=(0,r.jsx)(J,{className:f,children:N}),e[19]=N,e[20]=f,e[21]=y):y=e[21];let w;e[22]!==t||e[23]!==s||e[24]!==i||e[25]!==n?(w=(0,r.jsx)($,{className:"py-2 px-2",children:(0,r.jsx)(Re,{state:n,input:s,result:i,approval:t})}),e[22]=t,e[23]=s,e[24]=i,e[25]=n,e[26]=w):w=e[26];let A;e[27]!==y||e[28]!==w?(A=(0,r.jsxs)(F,{value:"tool-call",className:"border-0",children:[y,w]}),e[27]=y,e[28]=w,e[29]=A):A=e[29];let R;return e[30]!==A||e[31]!==m||e[32]!==o?(R=(0,r.jsx)(M,{type:"single",collapsible:!0,className:o,children:A},m),e[30]=A,e[31]=m,e[32]=o,e[33]=R):R=e[33],R};var Re=c=>{let e=(0,z.c)(16),{state:l,input:n,result:s,approval:i}=c;switch(l){case"input-streaming":case"input-available":case"approval-responded":{let t;return e[0]===n?t=e[1]:(t=(0,r.jsx)(q,{input:n}),e[0]=n,e[1]=t),t}case"output-available":{let t;e[2]===n?t=e[3]:(t=(0,r.jsx)(q,{input:n}),e[2]=n,e[3]=t);let a;e[4]===s?a=e[5]:(a=s!=null&&(0,r.jsx)(Se,{result:s}),e[4]=s,e[5]=a);let u;return e[6]!==t||e[7]!==a?(u=(0,r.jsxs)("div",{className:"space-y-3",children:[t,a]}),e[6]=t,e[7]=a,e[8]=u):u=e[8],u}case"output-denied":{let t;e[9]===n?t=e[10]:(t=(0,r.jsx)(q,{input:n}),e[9]=n,e[10]=t);let a=i!=null&&i.reason?`: ${i.reason}`:".",u;e[11]===a?u=e[12]:(u=(0,r.jsxs)("div",{className:"bg-muted/40 border border-border rounded-md p-3 text-xs text-muted-foreground leading-relaxed",children:["Tool execution was denied",a]}),e[11]=a,e[12]=u);let h;return e[13]!==t||e[14]!==u?(h=(0,r.jsxs)("div",{className:"space-y-3",children:[t,u]}),e[13]=t,e[14]=u,e[15]=h):h=e[15],h}default:return T(l),null}},Le=S();const B=c=>{let e=(0,Le.c)(27),{toolName:l,state:n,result:s,errorText:i,input:t,approval:a,onApprove:u,index:h,className:p,isLive:v,isActive:x}=c,d=v===void 0?!0:v,m=x===void 0?!0:x;switch(n){case"approval-requested":{if(a!=null&&u!=null){let f;return e[0]!==a||e[1]!==p||e[2]!==t||e[3]!==u||e[4]!==l?(f=(0,r.jsx)(be,{toolName:l,input:t,approval:a,onApprove:u,className:p}),e[0]=a,e[1]=p,e[2]=t,e[3]=u,e[4]=l,e[5]=f):f=e[5],f}let o;return e[6]!==p||e[7]!==h||e[8]!==t||e[9]!==m||e[10]!==l?(o=(0,r.jsx)(Y,{toolName:l,state:"input-available",input:t,index:h,className:p,isActive:m}),e[6]=p,e[7]=h,e[8]=t,e[9]=m,e[10]=l,e[11]=o):o=e[11],o}case"output-error":{let o;return e[12]!==p||e[13]!==i||e[14]!==t||e[15]!==d||e[16]!==l?(o=(0,r.jsx)(ge,{toolName:l,input:t,errorText:i,isLive:d,className:p}),e[12]=p,e[13]=i,e[14]=t,e[15]=d,e[16]=l,e[17]=o):o=e[17],o}case"input-streaming":case"input-available":case"approval-responded":case"output-available":case"output-denied":{let o;return e[18]!==a||e[19]!==p||e[20]!==h||e[21]!==t||e[22]!==m||e[23]!==s||e[24]!==n||e[25]!==l?(o=(0,r.jsx)(Y,{toolName:l,state:n,input:t,result:s,approval:a,index:h,className:p,isActive:m}),e[18]=a,e[19]=p,e[20]=h,e[21]=t,e[22]=m,e[23]=s,e[24]=n,e[25]=l,e[26]=o):o=e[26],o}default:return T(n),null}},Oe=({message:c,isStreamingReasoning:e,isLast:l,isActive:n,addToolApprovalResponse:s})=>{return(0,r.jsx)(r.Fragment,{children:c.parts.map((t,a)=>i(t,a))});function i(t,a){if(ze(t))return(0,r.jsx)(B,{index:a,toolName:t.type,result:t.output,errorText:t.state==="output-error"?t.errorText:void 0,className:"my-2",state:t.state,input:t.input,approval:t.approval,onApprove:s,isLive:l,isActive:n},a);if(De(t))return re.debug("Found data part",t),null;switch(t.type){case"text":return t.text.includes("<marimo-")?(0,r.jsx)(C.Fragment,{children:ue({html:t.text})},a):(0,r.jsx)(G,{content:t.text},a);case"reasoning":return(0,r.jsx)(he,{reasoning:t.text,index:a,isStreaming:e&&l&&a===(c.parts.length||0)-1},a);case"file":return(0,r.jsx)(ie,{attachment:t},a);case"dynamic-tool":return(0,r.jsx)(B,{toolName:t.toolName,result:t.output,errorText:t.state==="output-error"?t.errorText:void 0,state:t.state,input:t.input,approval:t.approval,onApprove:s,isLive:l,isActive:n},a);case"source-document":return(0,r.jsx)(I,{icon:(0,r.jsx)(U,{className:"h-3 w-3 shrink-0"}),title:t.title,subtitle:t.filename},a);case"source-url":return(0,r.jsx)(I,{icon:(0,r.jsx)(oe,{className:"h-3 w-3 shrink-0"}),title:t.title??t.url,subtitle:t.title?t.url:void 0,href:t.url},a);case"step-start":return null;default:return T(t),null}}};function ze(c){return c.type.startsWith("tool-")}function De(c){return c.type.startsWith("data-")}export{Oe as t};
|
|
1
|
+
import{s as D}from"./chunk-LvLJmgfZ.js";import{t as H}from"./react-Bj1aDYRI.js";import{vr as K,wr as Q,yr as U}from"./cells-C3u7zgmc.js";import{A as X,C as O,R as E,T as Z}from"./zod-H_cgTO0M.js";import{t as S}from"./compiler-runtime-B3qBwwSJ.js";import{t as ee}from"./isEmpty-CXeoXbuc.js";import{Y as te}from"./ai-model-dropdown-9Z73_iYD.js";import{_ as re}from"./useEventListener-BakX-tnw.js";import{t as k}from"./cn-X2M2usMq.js";import{t as se}from"./jsx-runtime-PbYoItBR.js";import{a as F,i as $,o as J,r as M}from"./config-DMNo9K-z.js";import{t as V}from"./button-BF7GSjhW.js";import{i as T}from"./strings-DvZlHYnD.js";import{t as W}from"./createLucideIcon-BTp1tQDO.js";import{t as ae}from"./ban-CttLZK8l.js";import{t as le}from"./bot-message-square-AslRbAeb.js";import{r as ne}from"./x-9vLEgLY6.js";import{t as G}from"./markdown-renderer-D9OefDax.js";import{f as I,l as ie}from"./add-cell-with-ai-Brj954XD.js";import{t as oe}from"./external-link-BktyywYg.js";import{n as ce}from"./spinner-BbI9qk88.js";import{l as de}from"./datasource-DdxTABsD.js";import{t as ue}from"./RenderHTML-jHR4F0TB.js";var me=W("circle-slash",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]]),pe=W("shield-question-mark",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),xe=S(),C=D(H(),1),r=D(se(),1);const he=c=>{let e=(0,xe.c)(13),{reasoning:l,index:n,isStreaming:s}=c,i=n===void 0?0:n,t=s===void 0?!1:s,[a,u]=C.useState("");if(!l&&!t)return null;let h=t?"reasoning":a,p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=(0,r.jsx)(le,{className:"h-3 w-3"}),e[0]=p):p=e[0];let v=t?"Thinking":"View reasoning",x=l.length>0&&` (${l.length} chars)`,d;e[1]!==v||e[2]!==x?(d=(0,r.jsx)(J,{className:"text-xs text-muted-foreground hover:bg-muted/50 px-2 py-1 h-auto rounded-sm [&[data-state=open]>svg]:rotate-180",children:(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[p,v,x]})}),e[1]=v,e[2]=x,e[3]=d):d=e[3];let m;e[4]===l?m=e[5]:(m=(0,r.jsx)($,{className:"pb-2 px-2",children:(0,r.jsx)("div",{className:"bg-muted/30 border border-muted/50 rounded-md p-3 italic text-muted-foreground/90 relative",children:(0,r.jsx)("div",{className:"pr-6",children:(0,r.jsx)(G,{content:l})})})}),e[4]=l,e[5]=m);let o;e[6]!==d||e[7]!==m?(o=(0,r.jsxs)(F,{value:"reasoning",className:"border-0",children:[d,m]}),e[6]=d,e[7]=m,e[8]=o):o=e[8];let f;return e[9]!==i||e[10]!==h||e[11]!==o?(f=(0,r.jsx)(M,{type:"single",collapsible:!0,className:"w-full mb-2",value:h,onValueChange:u,children:o},i),e[9]=i,e[10]=h,e[11]=o,e[12]=f):f=e[12],f};function L(c){return c.replace("tool-","")}var fe=S();const q=c=>{let e=(0,fe.c)(9),{input:l,label:n}=c,s=n===void 0?"Tool Request":n;if(l==null)return null;let i;e[0]===s?i=e[1]:(i=(0,r.jsx)("h3",{className:"text-xs font-semibold text-muted-foreground",children:s}),e[0]=s,e[1]=i);let t;e[2]===l?t=e[3]:(t=JSON.stringify(l,null,2),e[2]=l,e[3]=t);let a;e[4]===t?a=e[5]:(a=(0,r.jsx)("pre",{className:"bg-(--slate-2) p-2 text-muted-foreground border border-(--slate-4) rounded text-xs overflow-auto scrollbar-thin max-h-64",children:t}),e[4]=t,e[5]=a);let u;return e[6]!==i||e[7]!==a?(u=(0,r.jsxs)("div",{className:"space-y-2",children:[i,a]}),e[6]=i,e[7]=a,e[8]=u):u=e[8],u};var ve=S();const be=c=>{let e=(0,ve.c)(25),{toolName:l,input:n,approval:s,onApprove:i,className:t}=c,a;e[0]===t?a=e[1]:(a=k("rounded-md border border-(--amber-6) bg-(--amber-2) p-3 space-y-3",t),e[0]=t,e[1]=a);let u=`Approval required for ${L(l)}`,h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=(0,r.jsx)(pe,{className:"h-4 w-4 text-(--amber-11) mt-0.5 shrink-0"}),e[2]=h):h=e[2];let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p=(0,r.jsx)("span",{className:"font-semibold",children:"Approval required:"}),e[3]=p):p=e[3];let v;e[4]===l?v=e[5]:(v=L(l),e[4]=l,e[5]=v);let x;e[6]===v?x=e[7]:(x=(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[h,(0,r.jsxs)("div",{className:"text-xs text-(--amber-11) leading-relaxed",children:[p," ",(0,r.jsx)("code",{className:"font-mono",children:v})]})]}),e[6]=v,e[7]=x);let d;e[8]===n?d=e[9]:(d=(0,r.jsx)(q,{input:n}),e[8]=n,e[9]=d);let m;e[10]!==s.id||e[11]!==i?(m=(0,r.jsx)(V,{size:"xs",variant:"outline",onClick:()=>i({id:s.id,approved:!1}),children:"Deny"}),e[10]=s.id,e[11]=i,e[12]=m):m=e[12];let o;e[13]!==s.id||e[14]!==i?(o=(0,r.jsx)(V,{size:"xs",onClick:()=>i({id:s.id,approved:!0}),children:"Approve"}),e[13]=s.id,e[14]=i,e[15]=o):o=e[15];let f;e[16]!==m||e[17]!==o?(f=(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[m,o]}),e[16]=m,e[17]=o,e[18]=f):f=e[18];let b;return e[19]!==a||e[20]!==f||e[21]!==u||e[22]!==x||e[23]!==d?(b=(0,r.jsxs)("div",{className:a,role:"alertdialog","aria-label":u,children:[x,d,f]}),e[19]=a,e[20]=f,e[21]=u,e[22]=x,e[23]=d,e[24]=b):b=e[24],b};var je=S();const ge=c=>{let e=(0,je.c)(28),{toolName:l,input:n,errorText:s,isLive:i,className:t}=c,[a,u]=C.useState(i),h=C.useRef(i),p,v;e[0]===i?(p=e[1],v=e[2]):(p=()=>{h.current&&!i&&u(!1),h.current=i},v=[i],e[0]=i,e[1]=p,e[2]=v),C.useEffect(p,v);let x;e[3]===t?x=e[4]:(x=k("rounded-md border border-(--red-6) bg-(--red-2)",t),e[3]=t,e[4]=x);let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=()=>u(Ne),e[5]=d):d=e[5];let m;e[6]===Symbol.for("react.memo_cache_sentinel")?(m=(0,r.jsx)(Q,{className:"h-3.5 w-3.5 shrink-0"}),e[6]=m):m=e[6];let o;e[7]===Symbol.for("react.memo_cache_sentinel")?(o=(0,r.jsx)("span",{className:"font-semibold",children:"Failed:"}),e[7]=o):o=e[7];let f;e[8]===l?f=e[9]:(f=L(l),e[8]=l,e[9]=f);let b;e[10]===f?b=e[11]:(b=(0,r.jsxs)("span",{className:"flex-1 text-left",children:[o," ",(0,r.jsx)("code",{className:"font-mono",children:f})]}),e[10]=f,e[11]=b);let _=a&&"rotate-180",j;e[12]===_?j=e[13]:(j=k("h-3.5 w-3.5 shrink-0 transition-transform",_),e[12]=_,e[13]=j);let g;e[14]===j?g=e[15]:(g=(0,r.jsx)(ne,{className:j}),e[14]=j,e[15]=g);let N;e[16]!==a||e[17]!==g||e[18]!==b?(N=(0,r.jsxs)("button",{type:"button",onClick:d,className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-(--red-11) hover:bg-(--red-3) rounded-md transition-colors","aria-expanded":a,children:[m,b,g]}),e[16]=a,e[17]=g,e[18]=b,e[19]=N):N=e[19];let y;e[20]!==s||e[21]!==n||e[22]!==a?(y=a&&(0,r.jsxs)("div",{className:"px-3 pb-3 space-y-3 border-t border-(--red-6)/40 pt-3",children:[(0,r.jsx)(q,{input:n}),s&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-xs font-semibold text-(--red-11) mb-1",children:"Error"}),(0,r.jsx)("pre",{className:"bg-(--red-2) border border-(--red-6) rounded p-2 text-xs text-(--red-11) leading-relaxed overflow-auto scrollbar-thin max-h-64 whitespace-pre-wrap",children:s})]})]}),e[20]=s,e[21]=n,e[22]=a,e[23]=y):y=e[23];let w;return e[24]!==N||e[25]!==y||e[26]!==x?(w=(0,r.jsxs)("div",{className:x,children:[N,y]}),e[24]=N,e[25]=y,e[26]=x,e[27]=w):w=e[27],w};function Ne(c){return!c}var P=S();function ye(c){return c==null?!0:typeof c=="object"?ee(c):!1}var we=X({status:E().default("success"),auth_required:Z().default(!1),action_url:O(),next_steps:O(),meta:O(),message:E().nullish()}),_e=c=>{let e=(0,P.c)(12),{data:l}=c,n;if(e[0]!==l){let{status:s,auth_required:i,action_url:t,meta:a,next_steps:u,message:h,...p}=l,v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=(0,r.jsx)("h3",{className:"text-xs font-semibold text-muted-foreground",children:"Tool Result"}),e[2]=v):v=e[2];let x;e[3]===s?x=e[4]:(x=(0,r.jsx)("span",{className:"text-xs px-2 py-0.5 bg-(--grass-2) text-(--grass-11) rounded-full font-medium capitalize",children:s}),e[3]=s,e[4]=x);let d;e[5]===i?d=e[6]:(d=i&&(0,r.jsx)("span",{className:"text-xs px-2 py-0.5 bg-(--amber-2) text-(--amber-11) rounded-full",children:"Auth Required"}),e[5]=i,e[6]=d);let m;e[7]!==x||e[8]!==d?(m=(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[v,(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[x,d]})]}),e[7]=x,e[8]=d,e[9]=m):m=e[9];let o;e[10]===h?o=e[11]:(o=h&&(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)(K,{className:"h-3 w-3 text-(--blue-11) mt-0.5 shrink-0"}),(0,r.jsx)("div",{className:"text-xs text-foreground",children:h})]}),e[10]=h,e[11]=o),n=(0,r.jsxs)("div",{className:"flex flex-col gap-1.5",children:[m,o,p&&(0,r.jsx)("div",{className:"space-y-3",children:Object.entries(p).map(Ae)})]}),e[0]=l,e[1]=n}else n=e[1];return n};const Se=c=>{let e=(0,P.c)(8),{result:l}=c,n;e[0]===l?n=e[1]:(n=we.safeParse(l),e[0]=l,e[1]=n);let s=n;if(s.success){let a;return e[2]===s.data?a=e[3]:(a=(0,r.jsx)(_e,{data:s.data}),e[2]=s.data,e[3]=a),a}let i;e[4]===l?i=e[5]:(i=typeof l=="string"?l:JSON.stringify(l,null,2),e[4]=l,e[5]=i);let t;return e[6]===i?t=e[7]:(t=(0,r.jsx)("div",{className:"text-xs font-medium text-muted-foreground mb-1 max-h-64 overflow-y-auto scrollbar-thin",children:i}),e[6]=i,e[7]=t),t};function Ae(c){let[e,l]=c;return ye(l)?null:(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:e}),(0,r.jsx)("pre",{className:"bg-(--slate-2) p-2 text-muted-foreground border border-(--slate-4) rounded text-xs overflow-auto scrollbar-thin max-h-64",children:JSON.stringify(l,null,2)})]},e)}var z=S(),ke={"input-streaming":"Generating","input-available":"Running","approval-responded":"Awaiting result","output-available":"Done","output-denied":"Denied"},Te=new Set(["input-streaming","input-available","approval-responded"]),Ce=c=>{let e=(0,z.c)(5),{state:l,interrupted:n}=c;if(n){let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,r.jsx)(me,{className:"h-3 w-3 text-muted-foreground"}),e[0]=s):s=e[0],s}switch(l){case"input-streaming":case"input-available":case"approval-responded":{let s;return e[1]===Symbol.for("react.memo_cache_sentinel")?(s=(0,r.jsx)(ce,{className:"h-3 w-3 animate-spin"}),e[1]=s):s=e[1],s}case"output-available":{let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,r.jsx)(te,{className:"h-3 w-3 text-(--grass-11)"}),e[2]=s):s=e[2],s}case"output-denied":{let s;return e[3]===Symbol.for("react.memo_cache_sentinel")?(s=(0,r.jsx)(ae,{className:"h-3 w-3 text-muted-foreground"}),e[3]=s):s=e[3],s}default:{T(l);let s;return e[4]===Symbol.for("react.memo_cache_sentinel")?(s=(0,r.jsx)(de,{className:"h-3 w-3"}),e[4]=s):s=e[4],s}}};function qe(c){switch(c){case"output-available":return"text-(--grass-11)/80";case"output-denied":return"text-muted-foreground";case"input-streaming":case"input-available":case"approval-responded":return"";default:return T(c),""}}const Y=c=>{let e=(0,z.c)(34),{toolName:l,state:n,input:s,result:i,approval:t,index:a,className:u,isActive:h}=c,p=a===void 0?0:a,v=h===void 0?!0:h,x;e[0]!==v||e[1]!==n?(x=!v&&Te.has(n),e[0]=v,e[1]=n,e[2]=x):x=e[2];let d=x,m=`tool-${p}`,o;e[3]===u?o=e[4]:(o=k("w-full",u),e[3]=u,e[4]=o);let f;e[5]!==d||e[6]!==n?(f=k("h-6 text-xs border-border shadow-none! ring-0! bg-muted/60 hover:bg-muted py-0 px-2 gap-1 rounded-sm [&[data-state=open]>svg]:rotate-180 hover:no-underline",d?"text-muted-foreground":qe(n)),e[5]=d,e[6]=n,e[7]=f):f=e[7];let b;e[8]!==d||e[9]!==n?(b=(0,r.jsx)(Ce,{state:n,interrupted:d}),e[8]=d,e[9]=n,e[10]=b):b=e[10];let _=d?"Interrupted":ke[n],j;e[11]===l?j=e[12]:(j=L(l),e[11]=l,e[12]=j);let g;e[13]===j?g=e[14]:(g=(0,r.jsx)("code",{className:"font-mono text-xs",children:j}),e[13]=j,e[14]=g);let N;e[15]!==g||e[16]!==b||e[17]!==_?(N=(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[b,_,":",g]}),e[15]=g,e[16]=b,e[17]=_,e[18]=N):N=e[18];let y;e[19]!==N||e[20]!==f?(y=(0,r.jsx)(J,{className:f,children:N}),e[19]=N,e[20]=f,e[21]=y):y=e[21];let w;e[22]!==t||e[23]!==s||e[24]!==i||e[25]!==n?(w=(0,r.jsx)($,{className:"py-2 px-2",children:(0,r.jsx)(Re,{state:n,input:s,result:i,approval:t})}),e[22]=t,e[23]=s,e[24]=i,e[25]=n,e[26]=w):w=e[26];let A;e[27]!==y||e[28]!==w?(A=(0,r.jsxs)(F,{value:"tool-call",className:"border-0",children:[y,w]}),e[27]=y,e[28]=w,e[29]=A):A=e[29];let R;return e[30]!==A||e[31]!==m||e[32]!==o?(R=(0,r.jsx)(M,{type:"single",collapsible:!0,className:o,children:A},m),e[30]=A,e[31]=m,e[32]=o,e[33]=R):R=e[33],R};var Re=c=>{let e=(0,z.c)(16),{state:l,input:n,result:s,approval:i}=c;switch(l){case"input-streaming":case"input-available":case"approval-responded":{let t;return e[0]===n?t=e[1]:(t=(0,r.jsx)(q,{input:n}),e[0]=n,e[1]=t),t}case"output-available":{let t;e[2]===n?t=e[3]:(t=(0,r.jsx)(q,{input:n}),e[2]=n,e[3]=t);let a;e[4]===s?a=e[5]:(a=s!=null&&(0,r.jsx)(Se,{result:s}),e[4]=s,e[5]=a);let u;return e[6]!==t||e[7]!==a?(u=(0,r.jsxs)("div",{className:"space-y-3",children:[t,a]}),e[6]=t,e[7]=a,e[8]=u):u=e[8],u}case"output-denied":{let t;e[9]===n?t=e[10]:(t=(0,r.jsx)(q,{input:n}),e[9]=n,e[10]=t);let a=i!=null&&i.reason?`: ${i.reason}`:".",u;e[11]===a?u=e[12]:(u=(0,r.jsxs)("div",{className:"bg-muted/40 border border-border rounded-md p-3 text-xs text-muted-foreground leading-relaxed",children:["Tool execution was denied",a]}),e[11]=a,e[12]=u);let h;return e[13]!==t||e[14]!==u?(h=(0,r.jsxs)("div",{className:"space-y-3",children:[t,u]}),e[13]=t,e[14]=u,e[15]=h):h=e[15],h}default:return T(l),null}},Le=S();const B=c=>{let e=(0,Le.c)(27),{toolName:l,state:n,result:s,errorText:i,input:t,approval:a,onApprove:u,index:h,className:p,isLive:v,isActive:x}=c,d=v===void 0?!0:v,m=x===void 0?!0:x;switch(n){case"approval-requested":{if(a!=null&&u!=null){let f;return e[0]!==a||e[1]!==p||e[2]!==t||e[3]!==u||e[4]!==l?(f=(0,r.jsx)(be,{toolName:l,input:t,approval:a,onApprove:u,className:p}),e[0]=a,e[1]=p,e[2]=t,e[3]=u,e[4]=l,e[5]=f):f=e[5],f}let o;return e[6]!==p||e[7]!==h||e[8]!==t||e[9]!==m||e[10]!==l?(o=(0,r.jsx)(Y,{toolName:l,state:"input-available",input:t,index:h,className:p,isActive:m}),e[6]=p,e[7]=h,e[8]=t,e[9]=m,e[10]=l,e[11]=o):o=e[11],o}case"output-error":{let o;return e[12]!==p||e[13]!==i||e[14]!==t||e[15]!==d||e[16]!==l?(o=(0,r.jsx)(ge,{toolName:l,input:t,errorText:i,isLive:d,className:p}),e[12]=p,e[13]=i,e[14]=t,e[15]=d,e[16]=l,e[17]=o):o=e[17],o}case"input-streaming":case"input-available":case"approval-responded":case"output-available":case"output-denied":{let o;return e[18]!==a||e[19]!==p||e[20]!==h||e[21]!==t||e[22]!==m||e[23]!==s||e[24]!==n||e[25]!==l?(o=(0,r.jsx)(Y,{toolName:l,state:n,input:t,result:s,approval:a,index:h,className:p,isActive:m}),e[18]=a,e[19]=p,e[20]=h,e[21]=t,e[22]=m,e[23]=s,e[24]=n,e[25]=l,e[26]=o):o=e[26],o}default:return T(n),null}},Oe=({message:c,isStreamingReasoning:e,isLast:l,isActive:n,addToolApprovalResponse:s})=>{return(0,r.jsx)(r.Fragment,{children:c.parts.map((t,a)=>i(t,a))});function i(t,a){if(ze(t))return(0,r.jsx)(B,{index:a,toolName:t.type,result:t.output,errorText:t.state==="output-error"?t.errorText:void 0,className:"my-2",state:t.state,input:t.input,approval:t.approval,onApprove:s,isLive:l,isActive:n},a);if(De(t))return re.debug("Found data part",t),null;switch(t.type){case"text":return t.text.includes("<marimo-")?(0,r.jsx)(C.Fragment,{children:ue({html:t.text})},a):(0,r.jsx)(G,{content:t.text},a);case"reasoning":return(0,r.jsx)(he,{reasoning:t.text,index:a,isStreaming:e&&l&&a===(c.parts.length||0)-1},a);case"file":return(0,r.jsx)(ie,{attachment:t},a);case"dynamic-tool":return(0,r.jsx)(B,{toolName:t.toolName,result:t.output,errorText:t.state==="output-error"?t.errorText:void 0,state:t.state,input:t.input,approval:t.approval,onApprove:s,isLive:l,isActive:n},a);case"source-document":return(0,r.jsx)(I,{icon:(0,r.jsx)(U,{className:"h-3 w-3 shrink-0"}),title:t.title,subtitle:t.filename},a);case"source-url":return(0,r.jsx)(I,{icon:(0,r.jsx)(oe,{className:"h-3 w-3 shrink-0"}),title:t.title??t.url,subtitle:t.title?t.url:void 0,href:t.url},a);case"step-start":return null;default:return T(t),null}}};function ze(c){return c.type.startsWith("tool-")}function De(c){return c.type.startsWith("data-")}export{Oe as t};
|