@marimo-team/frontend 0.22.5-dev22 → 0.22.5-dev25
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-BlPM618y.js → CellStatus-CNNGwOIK.js} +1 -1
- package/dist/assets/{JsonOutput-fX_t4kob.js → JsonOutput-9XtRRx5l.js} +2 -2
- package/dist/assets/{MarimoErrorOutput-BWZIVKfh.js → MarimoErrorOutput-Bc9JufDr.js} +1 -1
- package/dist/assets/{RenderHTML-DHi_NcqM.js → RenderHTML-0dk6-mYI.js} +1 -1
- package/dist/assets/{add-cell-with-ai-BFWfrIDT.js → add-cell-with-ai-CLklC7KS.js} +1 -1
- package/dist/assets/{add-connection-dialog-DhD4Nslx.js → add-connection-dialog-ux7eCDRM.js} +1 -1
- package/dist/assets/{agent-panel-Db14RXuw.js → agent-panel-CiMrqUfl.js} +1 -1
- package/dist/assets/{ai-model-dropdown-DK0jvNeC.js → ai-model-dropdown-CRtaHcCu.js} +1 -1
- package/dist/assets/{app-config-button-ChOMoYZB.js → app-config-button-CnX21edo.js} +1 -1
- package/dist/assets/{cell-editor-ByEIKpU_.js → cell-editor-D7IQ3F4W.js} +1 -1
- package/dist/assets/{cell-link-Ci0BxazH.js → cell-link-CcAqXeeg.js} +1 -1
- package/dist/assets/{cells-CmiuS2Us.js → cells-EJo3u4za.js} +2 -2
- package/dist/assets/{chat-display-QHJlAad0.js → chat-display-BxDRpNsl.js} +1 -1
- package/dist/assets/{chat-panel-DdVD5b8J.js → chat-panel-dBoLqgjH.js} +1 -1
- package/dist/assets/{chat-ui-BAYy1pnJ.js → chat-ui-DdZo1L-v.js} +1 -1
- package/dist/assets/{column-preview-BD9FgWWN.js → column-preview-DrU255Z3.js} +1 -1
- package/dist/assets/{command-palette-_LjHuhEv.js → command-palette-n6NnK6GP.js} +1 -1
- package/dist/assets/{common-BTshJ1XI.js → common-Bty2yo-n.js} +1 -1
- package/dist/assets/{components-B6JSwyVJ.js → components-B8TZ_vT_.js} +1 -1
- package/dist/assets/{components-CLTwiWUR.js → components-Dh-L-jYg.js} +1 -1
- package/dist/assets/{datasource-DcKEJh0J.js → datasource-DY0N42ZB.js} +1 -1
- package/dist/assets/{dependency-graph-panel-_c0_a9O1.js → dependency-graph-panel-C23HsAdh.js} +1 -1
- package/dist/assets/{documentation-panel-CJQhh3mV.js → documentation-panel-okcEKCQM.js} +1 -1
- package/dist/assets/{download-CoP6Jndb.js → download-TSo32ofd.js} +1 -1
- package/dist/assets/{edit-page-B-QbMCYD.js → edit-page-RhmoqI7E.js} +3 -3
- package/dist/assets/{error-panel-sqHK1YIQ.js → error-panel-aq2j0jIa.js} +1 -1
- package/dist/assets/{file-explorer-panel-6pc2qA_Z.js → file-explorer-panel-CzYUz358.js} +1 -1
- package/dist/assets/{file-icons-D73064oq.js → file-icons-DBaXCICA.js} +1 -1
- package/dist/assets/{floating-outline-CztoJoAm.js → floating-outline-BTmyhMGv.js} +1 -1
- package/dist/assets/{focus-oWwbhXMU.js → focus-DXeddo75.js} +1 -1
- package/dist/assets/{form-Bfu7g23-.js → form-BiDLPu7R.js} +1 -1
- package/dist/assets/{home-page-qzErWwFK.js → home-page-BntiR5eS.js} +1 -1
- package/dist/assets/{hooks-BcJBkgfh.js → hooks-BgwM3Mb2.js} +1 -1
- package/dist/assets/{html-to-image-DRz7fjt_.js → html-to-image-BJiJlwQY.js} +1 -1
- package/dist/assets/{index-CQ0aAUTn.js → index-CMEhtk8a.js} +4 -4
- package/dist/assets/{kiosk-mode-mgrpFwQ-.js → kiosk-mode-JCcLyeoQ.js} +1 -1
- package/dist/assets/{layout-1KFHhkOF.js → layout-CF-7BNtf.js} +1 -1
- package/dist/assets/{logs-panel-BarTHrDL.js → logs-panel-BzhPrie8.js} +1 -1
- package/dist/assets/{markdown-renderer-BzPN8MW4.js → markdown-renderer-B9RsGqHb.js} +1 -1
- package/dist/assets/{name-cell-input-xHvjjUrD.js → name-cell-input-CYsY4A1G.js} +1 -1
- package/dist/assets/{outline-panel-D56eqBW2.js → outline-panel-BCAWCKi6.js} +1 -1
- package/dist/assets/{packages-panel-CRPKv2g1.js → packages-panel-5axf3DuF.js} +1 -1
- package/dist/assets/{panels-CVuW7WaC.js → panels-7-kbDRzv.js} +1 -1
- package/dist/assets/{process-output-DmjGMo3l.js → process-output-DqiZsqG9.js} +1 -1
- package/dist/assets/{readonly-python-code-CxvXDGBS.js → readonly-python-code-D8ITm60r.js} +1 -1
- package/dist/assets/{run-page-CfCgYWcm.js → run-page-9OQqe8IY.js} +1 -1
- package/dist/assets/{scratchpad-panel-CBMHZjXp.js → scratchpad-panel-DkqxnSH6.js} +1 -1
- package/dist/assets/{session-panel-maUzbOL4.js → session-panel-BuzMiMf3.js} +1 -1
- package/dist/assets/{snippets-panel-C87xXbH3.js → snippets-panel--mh2FUXA.js} +1 -1
- package/dist/assets/{state-DNRh59rT.js → state-6D_2UAw3.js} +1 -1
- package/dist/assets/{state-16EGv7AG.js → state-BDrig0S2.js} +1 -1
- package/dist/assets/{textarea-NrWjAX-x.js → textarea-Cfp3upzK.js} +1 -1
- package/dist/assets/{tracing-CEb8mD1j.js → tracing-BExYhl1z.js} +1 -1
- package/dist/assets/{tracing-panel-DbBjrYZR.js → tracing-panel-Co5DeX-F.js} +2 -2
- package/dist/assets/{useAddCell-DiOrQo7h.js → useAddCell-BaTlDxTu.js} +1 -1
- package/dist/assets/{useCellActionButton-DS91ZXRv.js → useCellActionButton-DftkIqUl.js} +1 -1
- package/dist/assets/{useDeleteCell-BGyrTpcv.js → useDeleteCell-d6yWnL3H.js} +1 -1
- package/dist/assets/{useDependencyPanelTab-Bn1hk2_w.js → useDependencyPanelTab-BaVcOBM4.js} +1 -1
- package/dist/assets/{useNotebookActions-ChawZjnl.js → useNotebookActions-DihtSJ4g.js} +1 -1
- package/dist/assets/{useRunCells-BbUvom42.js → useRunCells-d2edY6Tu.js} +1 -1
- package/dist/assets/{useSplitCell-B3Wpl0ev.js → useSplitCell-DOiFyMgH.js} +1 -1
- package/dist/index.html +22 -22
- package/package.json +1 -1
- package/src/components/editor/Output.tsx +1 -1
- package/src/components/editor/__tests__/Output.test.tsx +36 -1
- package/src/core/cells/__tests__/cells.test.ts +41 -0
- package/src/core/cells/__tests__/collapseConsoleOutputs.test.ts +38 -0
- package/src/core/cells/cells.ts +1 -1
- package/src/core/cells/collapseConsoleOutputs.tsx +3 -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{Lt as I}from"./cells-CmiuS2Us.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-DK0jvNeC.js";import{C as oe,v as ne,w as Q}from"./utils-8btzWeZg.js";import{S as re}from"./config-DoZCLcOb.js";import{t as ie}from"./jsx-runtime-Blw4afVn.js";import{o as ce}from"./alert-dialog-CXspBRlP.js";import{i as de,r as he,t as me}from"./popover-AtoFZ7i4.js";import{l as R}from"./select--zcABebs.js";import{t as U}from"./tooltip-DmqhBBs6.js";import{t as xe}from"./button-BKVLeSTX.js";import{s as B}from"./arrays-DAC2orgH.js";import{r as Y}from"./requests-9-v2bhoi.js";import{t as pe}from"./createLucideIcon-w-Qo9n0R.js";import{t as fe}from"./x-Bv2rCglF.js";import{r as D}from"./input-Bg12i6qY.js";import{t as K}from"./settings-C1bg8A2T.js";import{a as M,c as L,d as A,g as ue,i as je,l as P,o as q,p as ve,u as S}from"./textarea-NrWjAX-x.js";import{t as ge}from"./use-toast-BDYuj3zG.js";import{i as be}from"./RSPContexts-LWFBF00h.js";import{n as we}from"./useDebounce-LVL1r3-M.js";import{c as ye,l as Ne,n as Ce,t as V}from"./dialog-BYjetQgE.js";import{n as ke}from"./ImperativeModal-DoGv2BXV.js";import{t as O}from"./kbd-BUtlbGdu.js";import{t as _e}from"./links-DOybeRem.js";import{t as G}from"./Inputs-6ni2iCdV.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}=Y(),w;e[0]===o?w=e[1]:(w=()=>{o(),setTimeout(Le,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 Le(){window.close()}var J=H(),W=z(Z(),1),Ae=100;const Pe=()=>{let t=(0,J.c)(37),[e,a]=ne(),{saveAppConfig:f}=Y(),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,Ae),c;t[8]===e.width?c=t[9]:(c=[e.width],t[8]=e.width,t[9]=c),(0,W.useEffect)(qe,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)(L,{control:l.control,name:"width",render:Fe}),(0,s.jsx)(L,{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)(L,{control:l.control,name:"css_file",render:De}),(0,s.jsx)(L,{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)(L,{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)(P,{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)(A,{})]}),(0,s.jsxs)(q,{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)(L,{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 qe(){window.dispatchEvent(new Event("resize"))}function Ee(t){return(0,s.jsx)("option",{value:t,children:t},t)}function Fe(t){let{field:e}=t;return(0,s.jsxs)(P,{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(Ee)})}),(0,s.jsx)(A,{})]})}function He(t){let{field:e}=t;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(P,{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)(A,{})]}),(0,s.jsx)(q,{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)(P,{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)(A,{})]}),(0,s.jsx)(q,{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)(P,{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)(A,{})]}),(0,s.jsxs)(q,{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)(P,{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)(A,{})]}),(0,s.jsxs)(q,{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)(K,{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 E;return e[10]!==o||e[11]!==l||e[12]!==T?(E=(0,s.jsxs)(V,{open:l,onOpenChange:o,children:[T,x]}),e[10]=o,e[11]=l,e[12]=T,e[13]=E):E=e[13],E}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)(Pe,{}),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)(K,{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)(V,{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{Lt as I}from"./cells-EJo3u4za.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-CRtaHcCu.js";import{C as oe,v as ne,w as Q}from"./utils-8btzWeZg.js";import{S as re}from"./config-DoZCLcOb.js";import{t as ie}from"./jsx-runtime-Blw4afVn.js";import{o as ce}from"./alert-dialog-CXspBRlP.js";import{i as de,r as he,t as me}from"./popover-AtoFZ7i4.js";import{l as R}from"./select--zcABebs.js";import{t as U}from"./tooltip-DmqhBBs6.js";import{t as xe}from"./button-BKVLeSTX.js";import{s as B}from"./arrays-DAC2orgH.js";import{r as Y}from"./requests-9-v2bhoi.js";import{t as pe}from"./createLucideIcon-w-Qo9n0R.js";import{t as fe}from"./x-Bv2rCglF.js";import{r as D}from"./input-Bg12i6qY.js";import{t as K}from"./settings-C1bg8A2T.js";import{a as M,c as L,d as A,g as ue,i as je,l as P,o as q,p as ve,u as S}from"./textarea-Cfp3upzK.js";import{t as ge}from"./use-toast-BDYuj3zG.js";import{i as be}from"./RSPContexts-LWFBF00h.js";import{n as we}from"./useDebounce-LVL1r3-M.js";import{c as ye,l as Ne,n as Ce,t as V}from"./dialog-BYjetQgE.js";import{n as ke}from"./ImperativeModal-DoGv2BXV.js";import{t as O}from"./kbd-BUtlbGdu.js";import{t as _e}from"./links-DOybeRem.js";import{t as G}from"./Inputs-6ni2iCdV.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}=Y(),w;e[0]===o?w=e[1]:(w=()=>{o(),setTimeout(Le,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 Le(){window.close()}var J=H(),W=z(Z(),1),Ae=100;const Pe=()=>{let t=(0,J.c)(37),[e,a]=ne(),{saveAppConfig:f}=Y(),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,Ae),c;t[8]===e.width?c=t[9]:(c=[e.width],t[8]=e.width,t[9]=c),(0,W.useEffect)(qe,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)(L,{control:l.control,name:"width",render:Fe}),(0,s.jsx)(L,{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)(L,{control:l.control,name:"css_file",render:De}),(0,s.jsx)(L,{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)(L,{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)(P,{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)(A,{})]}),(0,s.jsxs)(q,{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)(L,{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 qe(){window.dispatchEvent(new Event("resize"))}function Ee(t){return(0,s.jsx)("option",{value:t,children:t},t)}function Fe(t){let{field:e}=t;return(0,s.jsxs)(P,{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(Ee)})}),(0,s.jsx)(A,{})]})}function He(t){let{field:e}=t;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(P,{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)(A,{})]}),(0,s.jsx)(q,{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)(P,{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)(A,{})]}),(0,s.jsx)(q,{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)(P,{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)(A,{})]}),(0,s.jsxs)(q,{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)(P,{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)(A,{})]}),(0,s.jsxs)(q,{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)(K,{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 E;return e[10]!==o||e[11]!==l||e[12]!==T?(E=(0,s.jsxs)(V,{open:l,onOpenChange:o,children:[T,x]}),e[10]=o,e[11]=l,e[12]=T,e[13]=E):E=e[13],E}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)(Pe,{}),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)(K,{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)(V,{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-BQvuJIS2.js","./loro_wasm_bg-B_AVgvOe.js","./chunk-LvLJmgfZ.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var nd=Object.defineProperty;var Aa=re=>{throw TypeError(re)};var rd=(re,z,pe)=>z in re?nd(re,z,{enumerable:!0,configurable:!0,writable:!0,value:pe}):re[z]=pe;var p=(re,z,pe)=>rd(re,typeof z!="symbol"?z+"":z,pe),od=(re,z,pe)=>z.has(re)||Aa("Cannot "+pe);var Ta=(re,z,pe)=>(od(re,z,"read from private field"),pe?pe.call(re):z.get(re)),Ia=(re,z,pe)=>z.has(re)?Aa("Cannot add the same private member more than once"):z instanceof WeakSet?z.add(re):z.set(re,pe);import{s as Fa}from"./chunk-LvLJmgfZ.js";import{d as La,f as pr,i as Z,l as yn,n as se,p as Lt,s as wn,u as le}from"./useEvent-D91BmmQi.js";import{t as ad}from"./react-Bj1aDYRI.js";import{$t as id,B as Oa,Bn as sd,Ct as vn,E as En,Et as Ot,F as ld,Fn as cd,G as Da,Gr as ud,Gt as dd,H as _a,Hr as gr,In as fd,Ir as md,Kt as hr,Ln as pd,Lt as gd,Rt as Ua,Sn as br,St as yr,Ti as Nn,Tt as hd,U as Ba,V as bd,Wn as yd,Wr as wd,Xr as ja,Xt as Pa,Yr as vd,Yt as wr,Zt as Ma,_n as Ed,a as Ra,b as Ze,d as Ga,en as Nd,fn as kd,ft as vr,gi as Cd,h as Er,hn as Sd,in as kn,it as xd,kn as Ad,kt as Td,ot as Id,pi as Ja,pt as Fd,sn as Ld,tn as Od,u as Wa,ur as Dd,vn as _d,wt as Ud,xt as Bd,yn as jd,zn as Va,__tla as Pd}from"./cells-
|
|
2
|
+
var nd=Object.defineProperty;var Aa=re=>{throw TypeError(re)};var rd=(re,z,pe)=>z in re?nd(re,z,{enumerable:!0,configurable:!0,writable:!0,value:pe}):re[z]=pe;var p=(re,z,pe)=>rd(re,typeof z!="symbol"?z+"":z,pe),od=(re,z,pe)=>z.has(re)||Aa("Cannot "+pe);var Ta=(re,z,pe)=>(od(re,z,"read from private field"),pe?pe.call(re):z.get(re)),Ia=(re,z,pe)=>z.has(re)?Aa("Cannot add the same private member more than once"):z instanceof WeakSet?z.add(re):z.set(re,pe);import{s as Fa}from"./chunk-LvLJmgfZ.js";import{d as La,f as pr,i as Z,l as yn,n as se,p as Lt,s as wn,u as le}from"./useEvent-D91BmmQi.js";import{t as ad}from"./react-Bj1aDYRI.js";import{$t as id,B as Oa,Bn as sd,Ct as vn,E as En,Et as Ot,F as ld,Fn as cd,G as Da,Gr as ud,Gt as dd,H as _a,Hr as gr,In as fd,Ir as md,Kt as hr,Ln as pd,Lt as gd,Rt as Ua,Sn as br,St as yr,Ti as Nn,Tt as hd,U as Ba,V as bd,Wn as yd,Wr as wd,Xr as ja,Xt as Pa,Yr as vd,Yt as wr,Zt as Ma,_n as Ed,a as Ra,b as Ze,d as Ga,en as Nd,fn as kd,ft as vr,gi as Cd,h as Er,hn as Sd,in as kn,it as xd,kn as Ad,kt as Td,ot as Id,pi as Ja,pt as Fd,sn as Ld,tn as Od,u as Wa,ur as Dd,vn as _d,wt as Ud,xt as Bd,yn as jd,zn as Va,__tla as Pd}from"./cells-EJo3u4za.js";import{P as $a,R as Md,k as Rd,w as Gd}from"./zod-H_cgTO0M.js";import{t as Re}from"./compiler-runtime-B3qBwwSJ.js";import{C as Jd,f as Wd,m as Vd,p as $d,t as Hd,v as qd}from"./ai-model-dropdown-CRtaHcCu.js";import{_ as We,c as Ha,h as Nr,t as zd,v as Kd}from"./useEventListener-DGjKht0c.js";import{t as Dt}from"./invariant-CkiqGLcK.js";import{S as kr,h as qa,m as Yd,o as Xd,p as za,s as Ka}from"./utils-8btzWeZg.js";import{S as Qd,d as Zd,h as pt,o as ef,r as Ya,x as _t,y as Xa}from"./config-DoZCLcOb.js";import{n as tf,t as nf}from"./switch-C6xjg01T.js";import{n as rf}from"./globals-DQM2RvzM.js";import{t as of}from"./ErrorBoundary-dxChUL02.js";import{t as at}from"./cn-DYvqRARy.js";import{t as af}from"./jsx-runtime-Blw4afVn.js";import{l as sf,r as lf,t as cf}from"./popover-AtoFZ7i4.js";import{N as uf,__tla as df}from"./JsonOutput-9XtRRx5l.js";import{t as Cr}from"./label-C89F4v17.js";import{r as ff}from"./download-TSo32ofd.js";import{t as Cn}from"./tooltip-DmqhBBs6.js";import{r as Sr,t as it}from"./button-BKVLeSTX.js";import{Bt as gt,Ct as Qa,Dt as mf,E as pf,Ft as xr,H as Za,Ht as Ut,I as gf,J as l,Jt as fe,Kt as hf,Lt as Sn,Mt as bf,P as yf,St as Ge,V as ei,Vt as Ar,Wt as st,Yt as Ve,Zt as Bt,_ as wf,a as vf,at as P,bt as Ef,ct as ze,en as xn,ft as Nf,it as kf,lt as An,m as Cf,pt as Sf,rt as q,st as xf,vt as Af,w as Tf,wt as If,yt as Ff,zt as Lf}from"./dist-VwkX7yeV.js";import{C as Of,D as Df,_ as _f,a as Uf,c as Bf,n as Tr,r as jf,v as Pf,x as Mf,y as Rf}from"./dist-DZJfxwLb.js";import{o as ti}from"./arrays-DAC2orgH.js";import{n as Gf}from"./once-hq2TLzOp.js";import{t as Ir}from"./createReducer-CYlwteGD.js";import{a as Jf,c as Wf,f as Tn,h as Vf,i as $f,l as jt,n as ni,o as Hf,t as qf}from"./dist-BNTOYRCs.js";import{t as zf}from"./main-BNL5rxQw.js";import{r as In,t as Kf}from"./requests-9-v2bhoi.js";import{t as Yf}from"./createLucideIcon-w-Qo9n0R.js";import{r as ri,t as Xf,__tla as Qf}from"./layout-CF-7BNtf.js";import{t as Zf}from"./x-Bv2rCglF.js";import{t as em}from"./circle-check-DlWaawuO.js";import{A as tm,E as oi,O as nm,T as rm,a as ai,d as om,n as am,o as im,r as ii,s as sm,x as lm}from"./add-cell-with-ai-CLklC7KS.js";import{r as cm,t as um}from"./file-icons-DBaXCICA.js";import{n as dm}from"./spinner-C5wIpWgQ.js";import{t as si}from"./save-bKSHuTCo.js";import{Y as fm,Z as li}from"./input-Bg12i6qY.js";import{t as mm}from"./sparkles-B79Qf6ma.js";import{t as pm}from"./preload-helper-D2MJg03u.js";import{t as ht}from"./use-toast-BDYuj3zG.js";import{n as Ke}from"./paths-BzSgteR-.js";import{t as gm}from"./session-DdnWW30b.js";import{r as hm}from"./useTheme-DCDmxPD0.js";import{n as bm}from"./copy-Bizk-4hH.js";import{k as ym}from"./usePress-BXMIcLWP.js";import{a as wm}from"./useRunCells-d2edY6Tu.js";import{c as ci,i as ui,n as di,r as vm}from"./dialog-BYjetQgE.js";import{t as fi}from"./useHotkey-DALUNe8I.js";import{n as mi}from"./ImperativeModal-DoGv2BXV.js";import{r as Em}from"./errors-CZb6hI2x.js";import{t as X}from"./extends-Co37_JfG.js";import{t as Pt}from"./objectWithoutPropertiesLoose-smPWkHxB.js";import{t as Nm}from"./kbd-BUtlbGdu.js";import{a as Fr}from"./useInstallPackage-CeM6oPsT.js";import{i as km,n as pi}from"./state-BDrig0S2.js";import{a as Cm,o as Sm}from"./cell-link-CcAqXeeg.js";import{n as xm}from"./useAsyncData-aCoWDe-l.js";import{a as Am,o as gi,r as Tm,s as hi,t as Im}from"./command-DvF_4mQa.js";import{r as bi}from"./html-to-image-BJiJlwQY.js";import{a as Fm}from"./focus-DXeddo75.js";import{a as yi}from"./renderShortcut-DrDh2657.js";import{n as Lm,t as Om}from"./icons-DlzgV4KY.js";import{n as bt}from"./esm-BqofWdD5.js";import{t as wi}from"./dist-C80Ed7Y5.js";import{n as Lr,t as vi}from"./useDeleteCell-d6yWnL3H.js";import{t as Dm}from"./useSplitCell-DOiFyMgH.js";import{co as _m,do as Or,fo as Um,ft as Bm,go as yt,ho as Ei,lo as Dr,mo as Ni,oo as jm,po as Pm,so as ki,uo as Ci,__tla as Mm}from"./loro_wasm_bg-B_AVgvOe.js";import{t as Rm}from"./ws-BApgRfsy.js";import{t as Si}from"./Inputs-6ni2iCdV.js";import{n as Gm}from"./hooks-BgwM3Mb2.js";let Fn,_r,xi,Ur,lt,Br,be,Mt,Rt,Ai,Ti,Ii,Fi,Li,Ln,Oi,On,Di,Dn,Jm=Promise.all([(()=>{try{return Pd}catch{}})(),(()=>{try{return df}catch{}})(),(()=>{try{return Qf}catch{}})(),(()=>{try{return Mm}catch{}})()]).then(async()=>{var hn,xa,we,ve,Ee,Ne,ke,Ce,Se,xe,Ae,Te,Ie,Fe,Le,Oe,De,_e,Ue,Be,je;var re=Yf("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 z={showInput:"Mod-l",acceptEdit:"Mod-y",rejectEdit:"Mod-u"};var pe=300;const vt=Ut.define({combine:e=>xn(e,{onError:console.error,inputDebounceTime:pe,keymaps:z},{onError:(t,n)=>t&&n,inputDebounceTime:(t,n)=>t&&n,keymaps:(t,n)=>t&&n})}),et=fe.define(),tt=Ve.define({create(){return{show:!1,lineFrom:0,lineTo:0}},update(e,t){for(let n of t.effects)if(n.is(et))return n.value;return e}}),Et=fe.define(),Nt=fe.define(),Pr=Ve.define({create(){return{shouldFocus:!1,inputValue:""}},update(e,t){let n=e;for(let r of t.effects)r.is(Et)&&(n={...n,inputValue:r.value}),r.is(Nt)&&(n={...n,shouldFocus:r.value});return n}}),Gt=fe.define(),kt=Ve.define({create(){return null},update(e,t){for(let n of t.effects)if(n.is(Gt))return n.value;return e}}),ct=fe.define(),Mr=Ve.define({create(){return!1},update(e,t){for(let n of t.effects)if(n.is(ct))return n.value;return e}});var _i=1;const Rr=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<_i)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:[et.of({show:!0,lineFrom:i,lineTo:s}),Nt.of(!0),Et.of("")],selection:gt.cursor(o.from)}),!0},Gr=e=>e.state.field(kt)?(e.dispatch({effects:[Gt.of(null),et.of({show:!1,lineFrom:0,lineTo:0}),Nt.of(!1),Et.of(""),ct.of(!1)]}),!0):!1,Jr=e=>{let t=e.state.field(kt);return t?(e.dispatch({changes:{from:t.from,to:t.to,insert:t.oldCode},effects:[Gt.of(null),et.of({show:!1,lineFrom:0,lineTo:0}),Nt.of(!1),Et.of(""),ct.of(!1)]}),!0):!1};var _n={mac:"\u2318",windows:"\u229E Win",default:"Ctrl"};function Ui(){return navigator.platform.startsWith("Mac")?_n.mac:navigator.platform.startsWith("Win")?_n.windows:_n.default}function Un(e){return e.replace("Mod",Ui()).replace("-"," ").toUpperCase()}function ue(e,t){let n=document.createElement(e);return n.className=t,n}function Bi(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 Jt=Ve.define({create(){return{suggestion:null}},update(e,t){let n=t.effects.find(r=>r.is(Wt));return!t.docChanged&&!n&&!t.selection?e:n&&t.state.doc===n.value.doc?{suggestion:n.value.text}:{suggestion:null}}}),Wt=fe.define();function ji(e,t){let n=e.state.selection.main.head,r=[],o=q.widget({widget:new Pi(t),side:1});return r.push(o.range(n)),q.set(r)}var Pi=class extends An{constructor(t){super();p(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}},Mi=class{constructor(e){p(this,"cache",new Map);p(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()})}},Ri=(e,t)=>ze.fromClass(class{constructor(){p(this,"abortController",null);p(this,"cache");this.cache=new Mi(t.cacheTimeout??1e3)}async update(n){var i,s,c,u,d;if(!n.docChanged||((s=(i=t.events)==null?void 0:i.beforeSuggestionFetch)==null?void 0:s.call(i,n.view))===!1)return;(c=this.abortController)==null||c.abort(),this.abortController=new AbortController;let r=n.state.doc,o=r.toString(),a=this.cache.get(o);if(a){n.view.dispatch({effects:Wt.of({text:a,doc:r})});return}try{let f=await e(n.state,this.abortController.signal,n.view);if(this.abortController.signal.aborted||((d=(u=t.events)==null?void 0:u.shouldShowSuggestion)==null?void 0:d.call(u,n.view,f))===!1)return;this.cache.set(o,f),n.view.dispatch({effects:Wt.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()}}),Gi=ze.fromClass(class{constructor(){p(this,"decorations");this.decorations=q.none}update(e){var n;let t=(n=e.state.field(Jt))==null?void 0:n.suggestion;if(!t){this.decorations=q.none;return}this.decorations=ji(e.view,t)}},{decorations:e=>e.decorations});function Ji(e,t,n,r){return{...e.changeByRange(o=>{if(o===e.selection.main)return{changes:{from:n,to:r,insert:t},range:gt.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:gt.cursor(o.from-a+t.length)}}),userEvent:"input.complete"}}var Wi=e=>{var r,o,a;let t=(r=e.state.field(Jt))==null?void 0:r.suggestion;if(!t)return!1;let n=e.state.facet(Bn);return e.dispatch({...Ji(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},Wr=e=>{var r,o,a;let t=(r=e.state.field(Jt))==null?void 0:r.suggestion;if(!t)return!1;let n=e.state.facet(Bn);return e.dispatch({effects:Wt.of({text:null,doc:e.state.doc})}),(a=(o=n.events)==null?void 0:o.onSuggestionRejected)==null||a.call(o,e,t),!0},Vi=Ge.of([{key:"Tab",run:Wi},{key:"Escape",run:Wr}]),Bn=Ut.define({combine:e=>e.at(-1)});function Vr(e){let{delay:t=500,includeKeymap:n=!0}=e,r=Bi(e.fetchFn,t);return[Jt,Bn.of(e),Ri(r,e),Gi,n?Vi:[]]}const $i=P.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 Hi(e){var o,a;let t=e.state.facet(vt),n={...z,...t.keymaps},r=ue("div","cm-ai-tooltip").appendChild(ue("div","cm-ai-tooltip-button"));return r.innerHTML=`<span>Edit <span class="hotkey">${Un(n.showInput)}</span></span>`,(o=r.querySelector("span"))==null||o.addEventListener("mousedown",i=>{i.stopPropagation(),i.button===0&&i.preventDefault()}),(a=r.querySelector("span"))==null||a.addEventListener("click",i=>{i.preventDefault(),Rr(e)}),r}const jn=Ut.define({combine(e){return xn(e,{render:Hi,hideOnBlur:!1})}}),qi=ze.fromClass((xa=class{constructor(e){p(this,"view");p(this,"suppress");p(this,"dom");p(this,"mousedown",()=>{this.suppress=!0});p(this,"mouseup",()=>{this.suppress=!1,this.display(this.view)});p(this,"scroll",()=>{this.display(this.view)});p(this,"windowScroll",()=>{this.display(this.view)});Ia(this,hn,e=>{var n;let t=e.state.selection.ranges.find(r=>!r.empty);if(t&&!this.suppress){let r=e.coordsAtPos(t.from);if(!r)return;let o=e.dom.getBoundingClientRect(),a=(n=e.dom.parentElement)==null?void 0:n.getBoundingClientRect(),i=r.top>=o.top&&r.top<=o.bottom&&r.left>=o.left&&r.left<=o.right,s=!a||r.top>=a.top&&r.top<=a.bottom&&r.left>=a.left&&r.left<=a.right;if(!i||!s){this.dom.style.display="none",this.dom.setAttribute("aria-hidden","true");return}this.dom.style.display="flex",this.dom.setAttribute("aria-hidden","false");let c=this.dom.getBoundingClientRect(),u=o.width-c.width,d=Math.min(r.left,u),f=r.top-c.height;f=a?Math.max(a.y,f):f,this.dom.style.left=`${d}px`,this.dom.style.top=`${f}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(jn);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(tt).show){this.dom.style.display="none";return}if(e.state.facet(jn).hideOnBlur&&!e.hasFocus){this.dom.style.display="none",this.dom.setAttribute("aria-hidden","true");return}e.requestMeasure({read:Ta(this,hn)})}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()}},hn=new WeakMap,xa));var zi=P.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 Ki(){return[qi,zi]}var Yi=class extends An{constructor(t){super();p(this,"oldCode");this.oldCode=t}toDOM(t){let n=ue("div","cm-old-code-container");n.setAttribute("role","region"),n.setAttribute("aria-label","Previous code version");let r=ue("div","cm-old-code cm-line");r.textContent=this.oldCode;let o=ue("div","cm-floating-buttons"),a=t.state.facet(vt),i={...z,...a.keymaps},s=ue("button","cm-floating-button cm-floating-accept");s.innerHTML=`<span class="hotkey">${Un(i.acceptEdit)}</span> Accept`,s.setAttribute("aria-label","Accept changes"),s.addEventListener("click",u=>{u.preventDefault(),u.stopPropagation(),t.focus(),Gr(t)});let c=ue("button","cm-floating-button cm-floating-reject");return c.innerHTML=`<span class="hotkey">${Un(i.rejectEdit)}</span> Reject`,c.setAttribute("aria-label","Reject changes"),c.addEventListener("click",u=>{u.preventDefault(),u.stopPropagation(),t.focus(),Jr(t)}),o.append(s,c),n.append(r,o),n}updateDOM(t,n){return!0}},Xi=class extends An{constructor(t){super();p(this,"complete");p(this,"abortController",null);p(this,"dom",null);p(this,"input",null);p(this,"loadingContainer",null);p(this,"helpInfo",null);p(this,"inputContainer",null);p(this,"form",null);p(this,"view",null);p(this,"onKeyDown",async t=>{t.key==="Enter"&&!t.shiftKey?(t.preventDefault(),await this.handleSubmit()):t.key==="Escape"&&this.onCancel()});p(this,"onCancel",()=>{this.cleanup();let t=this.view;t&&(t.dispatch({effects:[et.of({show:!1,lineFrom:0,lineTo:0}),ct.of(!1)]}),t.focus())});p(this,"handleSubmit",async t=>{var h;let n=this.view;if(!n)return;let r=n.state.facet(vt);t==null||t.stopPropagation();let o=n.state.field(tt),{input:a}=this;if(!a)return;let i=a.value.trim();if(!o.show||!i)return;let s=n.state.doc.line(o.lineFrom),c=n.state.doc.line(o.lineTo),u=s.from,d=c.to,f=n.state.sliceDoc(u,d),g=n.state.sliceDoc(0,u),m=n.state.sliceDoc(d);this.abortController=new AbortController,n.dispatch({effects:ct.of(!0)}),this.toggleLoading(!0);try{let w=await this.complete({prompt:i,selection:f,codeBefore:g,codeAfter:m,editorView:n,signal:this.abortController.signal});if(!n.state.field(tt).show)return;if(!w||typeof w!="string")throw Error("Invalid completion result");n.dispatch({changes:{from:u,to:d,insert:w},effects:[et.of({show:!1,lineFrom:0,lineTo:0}),Gt.of({from:u,to:u+w.length,oldCode:f,newCode:w}),ct.of(!1)]})}catch(w){if(w instanceof DOMException&&w.name==="AbortError")return;(h=r.onError)==null||h.call(r,w)}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(Pr),r=t.state.field(Mr),o=ue("div","cm-ai-input-container");this.inputContainer=o,this.dom=o;let a=ue("form","cm-ai-input-form");this.form=a,a.setAttribute("role","search"),a.setAttribute("aria-label","AI editing instructions"),a.addEventListener("submit",y=>y.preventDefault());let i=ue("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=ue("div","cm-ai-loading-container");this.loadingContainer=s;let c=ue("div","cm-ai-loading-indicator");c.setAttribute("role","status"),c.setAttribute("aria-live","polite"),c.textContent="Generating";let u=ue("button","cm-ai-cancel-button");u.textContent="Cancel",u.setAttribute("aria-label","Cancel code generation"),u.addEventListener("click",this.onCancel),s.append(u,c);let d=ue("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 g=ue("button","cm-ai-generate-button");g.textContent="\u23CE Generate",g.setAttribute("aria-label","Generate code"),g.addEventListener("click",this.handleSubmit),this.toggleLoading(r),n.shouldFocus&&requestAnimationFrame(()=>{i.value=n.inputValue,i.focus(),t.dispatch({effects:Nt.of(!1)})}),m(i.value),i.addEventListener("input",w),i.addEventListener("keydown",this.onKeyDown);function m(y){d.replaceChildren(y?g:f)}let h="";function w(){t.dispatch({effects:Et.of(i.value)});let y=i.value.trim();y!==h&&(h=y,m(y))}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 Qi(e){if(!e.prompt)throw Error("prompt function is required");let t={...z,...e.keymaps};return[vt.of(e),tt,Pr,kt,Mr,Ki(),$i,Ge.of([{key:t.showInput,run:Rr}]),st.highest([Ge.of([{key:t.acceptEdit,run:Gr},{key:t.rejectEdit,run:Jr}])]),Zi,es,ts,ns]}const Zi=P.updateListener.of(e=>{let t=e.state.field(tt);if(!t.show||!e.docChanged)return;let{lineFrom:n,lineTo:r}=t,o=!1;e.changes.iterChanges((a,i,s,c)=>{let u=e.state.doc.lineAt(a).number;if(u<n){let d=e.state.doc.lineAt(c).number-e.state.doc.lineAt(s).number;n+=d,r+=d,o=!0}else if(u<=r){let d=e.state.doc.lineAt(c).number-e.state.doc.lineAt(s).number;r+=d,o=!0}}),o&&e.view.dispatch({effects:[et.of({show:!0,lineFrom:n,lineTo:r})]})}),es=P.decorations.of(e=>{let t=e.state.field(kt);return t?q.set([q.mark({class:"cm-new-code-line"}).range(t.from,t.to)]):q.none}),ts=P.decorations.compute([tt],e=>{let t=e.field(tt),n=e.facet(vt),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(q.line({class:"cm-ai-selection"}).range(s)),i===o&&r.push(q.widget({widget:new Xi(n.prompt),side:-1}).range(s))}}return q.set(r)}),ns=Ve.define({create(e){return q.none},update(e,t){let n=t.state.field(kt);return n?q.set([q.widget({widget:new Yi(n.oldCode),block:!0}).range(n.from)]):q.none},provide:e=>P.decorations.from(e)});var rs=Re(),I=Fa(ad(),1),Pn=()=>({entries:new Map}),{valueAtom:$r,useActions:Hr}=Ir(Pn,{submit:(e,t)=>{let{cellIds:n,deleteCell:r,deleteManyCells:o,store:a}=t,i=a.get(Ze),s=a.get(cd),c=new Set(i.cellIds.inOrderIds.filter(f=>i.cellData[f].code.trim()==="")),u=new Map;for(let f of n){if(c.has(f)){u.set(f,{cellId:f,type:"simple"});continue}let g=i.cellRuntime[f],m=new Map;for(let w of Object.values(s)){let y=w.declaredBy.includes(f),E=w.usedBy.some(C=>!c.has(C));y&&E&&m.set(w.name,w.usedBy)}let h;g!=null&&g.runElapsedTimeMs&&g.runElapsedTimeMs>2e3&&(h=g.runElapsedTimeMs),m.size===0&&h===void 0?u.set(f,{cellId:f,type:"simple"}):u.set(f,{cellId:f,type:"expensive",executionDurationMs:h,defs:m})}let d=[...u.values()].every(f=>f.type==="simple");return u.size>0&&d?(u.size===1?r({cellId:[...u.values()][0].cellId}):o({cellIds:[...u.values()].map(f=>f.cellId)}),Pn()):{...e,entries:u}},clear:()=>Pn()});Dn=function(){let e=pr(),{submit:t,clear:n}=Hr(),{entries:r}=le($r),o=vi(),a=Lr();return(0,I.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])},Di=function(e){let t=(0,rs.c)(16),n=le($r),r=Hr(),o=Lr(),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(os)}),r.clear()},t[6]=r,t[7]=o,t[8]=n.entries,t[9]=s):s=t[9];let c;t[10]===r?c=t[11]:(c=()=>r.clear(),t[10]=r,t[11]=c);let u;return t[12]!==i||t[13]!==s||t[14]!==c?(u={isPending:!0,...i,shouldConfirmDelete:!0,confirm:s,cancel:c},t[12]=i,t[13]=s,t[14]=c,t[15]=u):u=t[15],u};function os(e){return e.cellId}async function as(e){var s,c;let t=`
|
|
4
4
|
${e.codeBefore}
|
|
5
5
|
<rewrite_this>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as j}from"./chunk-LvLJmgfZ.js";import{d as E,l as L,n as P,u as O}from"./useEvent-D91BmmQi.js";import{E as T,N as w,Nt as y,Ti as A,dn as S,j as $,pi as _}from"./cells-
|
|
1
|
+
import{s as j}from"./chunk-LvLJmgfZ.js";import{d as E,l as L,n as P,u as O}from"./useEvent-D91BmmQi.js";import{E as T,N as w,Nt as y,Ti as A,dn as S,j as $,pi as _}from"./cells-EJo3u4za.js";import{t as b}from"./compiler-runtime-B3qBwwSJ.js";import{_ as D}from"./useEventListener-DGjKht0c.js";import{d as F}from"./utils-8btzWeZg.js";import{r as N}from"./constants-tOPFFcLZ.js";import{h as q,x as B}from"./config-DoZCLcOb.js";import{t as H}from"./cn-DYvqRARy.js";import{t as M}from"./jsx-runtime-Blw4afVn.js";import{r as R}from"./requests-9-v2bhoi.js";import{n as U}from"./paths-BzSgteR-.js";import{s as V}from"./session-DdnWW30b.js";import{n as z}from"./ImperativeModal-DoGv2BXV.js";var G=b();function x(){return O(_)}function J(){let r=(0,G.c)(5),[t]=L(q),e=E(_),{openAlert:s}=z(),{sendRename:o}=R(),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?(V(i=>{l===null?i.delete(N.filePath):i.set(N.filePath,l)}),o({filename:l}).then(()=>(e(l),document.title=n.app_title||U.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],P(a)}var p=b(),v=j(M(),1);const h=r=>{let t=(0,p.c)(12),{className:e,cellId:s,variant:o,onClick:a,formatCellName:l,skipScroll:n}=r,i=w()[s]??"",C=$().inOrderIds.indexOf(s),{showCellIfHidden:d}=T(),g=l??W,c;t[0]===e?c=t[1]:(c=H("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(()=>{I(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(y(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},K=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=x(),a;t[0]!==e||t[1]!==s?(a=()=>S(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 I(r,t,e){let s=A.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{x as a,I as i,K as n,J as o,Q as r,h as t};
|
|
@@ -125,7 +125,7 @@ mark line col
|
|
|
125
125
|
`)}},ve(pi,"ESCAPE_REGEX",/\u001B\[([0-9;]*)([A-DJKH])/u),pi),N1=class{constructor(){ve(this,"ESC_REGEX",/\u001B(?:\[[0-9;]*[A-Za-z]|\([0-9A-Za-z])/gu)}parse(e){let n=[],a=0;for(let o of e.matchAll(this.ESC_REGEX)){let s=o.index??0;s>a&&n.push({type:"text",value:e.slice(a,s)}),n.push({type:"escape",value:o[0]}),a=s+o[0].length}return a<e.length&&n.push({type:"text",value:e.slice(a)}),n}},Ef=class{constructor(){ve(this,"parser",new N1);ve(this,"buffer",new Sf)}reduce(e){return this.reset(),this.append(e),this.render()}append(e){let n=this.parser.parse(e);if(n.length===1&&n[0].type==="text"){let a=n[0].value;if(!this.hasControlChars(a)){this.buffer.writeString(a);return}}for(let a of n)a.type==="text"?this.processText(a.value):this.buffer.handleEscape(a.value)}reset(){this.buffer=new Sf}render(){return this.buffer.render()}hasControlChars(e){for(let n of e)if(n<" ")return!0;return!1}processText(e){let n=0,a=e.length;for(let o=0;o<a;o++){let s=e[o];if(s===`
|
|
126
126
|
`||s==="\r"||s===" "||s==="\b"||s==="\v"){if(o>n){let c=e.slice(n,o),p=this.filterControlChars(c);p.length>0&&this.buffer.writeString(p)}this.buffer.control(s),n=o+1}else if(s<" "){if(o>n){let c=e.slice(n,o);c.length>0&&this.buffer.writeString(c)}n=o+1}}if(n<a){let o=e.slice(n),s=this.filterControlChars(o);s.length>0&&this.buffer.writeString(s)}}filterControlChars(e){let n=!1;for(let o of e)if(o<" "){n=!0;break}if(!n)return e;let a="";for(let o of e)o>=" "&&(a+=o);return a}},_s=class s0{constructor(n,a,o,s){ve(this,"ansiReducer",new Ef);this.mimetype=n,this.channel=a,this.timestamp=o,this.ansiReducer=s,this._data=this.ansiReducer.render()}get data(){return this._data}static create(n){let a=new Ef;return a.append(n.data),new s0(n.mimetype,n.channel,n.timestamp,a)}appendData(n){return this.ansiReducer.append(n),new s0(this.mimetype,this.channel,this.timestamp,this.ansiReducer)}toJSON(){return{mimetype:this.mimetype,channel:this.channel,timestamp:this.timestamp,data:this.data}}};function X4(e,n=5e3){let a=[...e];if(a.length<2)return D1(a.map(Z4),n);let o=a[a.length-1],s=a[a.length-2];return Y4(o,s)&&(M1(o),M1(s),a[a.length-2]=eT(s,o),a.pop()),D1(a,n)}function Y4(e,n){let a=e.mimetype==="text/plain"&&n.mimetype==="text/plain";if(!a)return!1;let o=e.channel===n.channel,s=e.channel!=="stdin";return a&&o&&s}function Z4(e){return e instanceof _s?e:typeof e.data=="string"?_s.create(e):e}function eT(e,n){return e instanceof _s?e.appendData(n.data):_s.create(e).appendData(n.data)}function M1(e){rn(typeof e.data=="string","expected string output")}function D1(e,n){let a=0,o;for(o=e.length-1;o>=0&&a<n;o--){let d=e[o];d.mimetype==="text/plain"?(rn(typeof d.data=="string","expected string"),a+=d.data.split(`
|
|
127
127
|
`).length):a++}if(a<n)return e;let s=o+1,c={channel:"stderr",mimetype:"text/html",data:`<pre>Streaming output truncated to last ${n} lines.
|
|
128
|
-
</pre>`,timestamp:-1},p=e[s];if(p.mimetype==="text/plain"){rn(typeof p.data=="string","expected string");let d=p.data.split(`
|
|
128
|
+
</pre>`,timestamp:-1},p=e[s];if(p==null)return[c,...e.slice(s+1)];if(p.mimetype==="text/plain"){rn(typeof p.data=="string","expected string");let d=p.data.split(`
|
|
129
129
|
`),m=n-(a-d.length);return[c,{...p,data:d.slice(-m).join(`
|
|
130
130
|
`)},...e.slice(s+1)]}return[c,...e.slice(s+1)]}function tT(e,n){let a={...e};switch(n.status){case"queued":a.interrupted=!1,a.errored=!1,a.runElapsedTimeMs=null,a.debuggerActive=!1;break;case"running":a.interrupted=!1,e.stopped&&(a.output=null),a.status==="queued"&&(a.consoleOutputs=[]),a.stopped=!1,a.runStartTimestamp=n.timestamp,a.lastRunStartTimestamp=n.timestamp;break;case"idle":e.runStartTimestamp&&(a.runElapsedTimeMs=Im.fromSeconds((n.timestamp??0)-e.runStartTimestamp).toMilliseconds(),a.runStartTimestamp=null,a.staleInputs=!1),!e.lastRunStartTimestamp&&n.timestamp&&(a.lastRunStartTimestamp=n.timestamp),a.debuggerActive=!1;break;case null:break;case"disabled-transitively":break;case void 0:break;default:ss(n.status)}a.output=n.output??a.output,a.staleInputs=n.stale_inputs??a.staleInputs,a.status=n.status??a.status,a.serialization=n.serialization;let o=!1;n.output!=null&&n.output.mimetype==="application/vnd.marimo+error"&&((a.status==="queued"||a.status==="running")&&(a.status="idle"),rn(Array.isArray(n.output.data),"Expected error output data to be an array"),n.output.data.some(d=>d.type==="interruption")?(a.interrupted=!0,o=!0):n.output.data.some(d=>d.type.includes("ancestor"))?a.stopped=!0:a.errored=!0);let s=e.consoleOutputs;o&&(a.debuggerActive=!1,s=s.map(d=>d.channel==="stdin"?{...d,response:d.response??""}:d));let c=n.console;c!=null&&(s=X4(Array.isArray(c)?c:[...s,c])),a.consoleOutputs=s,a.outline=km(a.output);let p=[n.console].flat().filter(Boolean).filter(d=>d.channel==="pdb");return p.length>0&&p.some(d=>d.data==="start")&&(a.debuggerActive=!0),a}function nT(e){let n={...e};return e.status!=="disabled-transitively"&&(n.status="queued"),n.interrupted=!1,n.errored=!1,n.runElapsedTimeMs=null,n.debuggerActive=!1,n}qm=function(e){return e==="running"||e==="queued"},Px=function(e,n){let{status:a,output:o,runStartTimestamp:s,interrupted:c,staleInputs:p}=e;if(c)return!1;if(n)return!0;let d=qm(a),m=a==="running"&&o!==null&&s!==null&&(o.timestamp??0)>s;return d&&!m?!0:p},ux=function(){let e=Be.get(Sm);return Vu(e,"internal-error: initial mode not found"),rn(e!=="present","internal-error: initial mode cannot be 'present'"),e},Lx=function(e){return e==="read"||e==="home"||e==="gallery"?e:e==="edit"?"present":"edit"},Y_=Te({mode:bw()?"read":"not-set",cellAnchor:null}),Sm=Te(void 0),Wm=Te(!1);function xs(e,n){if(!e){be.warn("getCell: cellId is undefined");return}let a=n.cellData[e];if(!a){be.warn(`getCell: cell ${e} not found in state`);return}return a}function j1(e,n){let a=n.cellIds.inOrderIds,o=a.indexOf(e);if(o>0)return{after:a[o-1]};if(o===0&&a.length>1)return{before:a[1]}}function z1(e){let n=new Map,a=e.cellIds.getColumns();for(let[o,s]of a.entries())for(let c of s.inOrderIds)n.set(c,o);return n}function mo(e,n){let a=new Set(e.cellIds.inOrderIds),o=[];for(let s of n.cellIds.inOrderIds)if(!a.has(s)){let c=xs(s,n);c&&o.push({type:"create-cell",cellId:c.id,code:c.code,name:c.name,config:c.config,...j1(c.id,n)})}return o}function rT(e,n){let a=new Set(n.cellIds.inOrderIds),o=[];for(let s of e.cellIds.inOrderIds)a.has(s)||o.push({type:"delete-cell",cellId:s});return o}function lc(e,n){let a=z1(e),o=z1(n),s=[];for(let[c,p]of o)a.get(c)!==p&&s.push({type:"set-config",cellId:c,column:p});return s.push({type:"reorder-cells",cellIds:n.cellIds.inOrderIds}),s}function aT(e,n,a){switch(a.type){case"createNewCell":return mo(e,n);case"deleteCell":return[{type:"delete-cell",cellId:a.payload.cellId}];case"moveCell":case"sendToTop":case"sendToBottom":{let{cellId:o}=a.payload;return[{type:"move-cell",cellId:o,...j1(o,n)}]}case"dropCellOverCell":case"dropCellOverColumn":return lc(e,n);case"updateCellCode":{let o=xs(a.payload.cellId,n);return o?[{type:"set-code",cellId:o.id,code:o.code}]:[]}case"updateCellName":{let o=xs(a.payload.cellId,n);return o?[{type:"set-name",cellId:o.id,name:o.name}]:[]}case"updateCellConfig":{let{cellId:o,config:s}=a.payload;return[{type:"set-config",cellId:o,...s.hide_code!=null&&{hideCode:s.hide_code},...s.disabled!=null&&{disabled:s.disabled},...s.column!=null&&{column:s.column}}]}case"dropOverNewColumn":case"moveColumn":case"addColumnBreakpoint":case"deleteColumn":case"mergeAllColumns":case"compactColumns":return lc(e,n);case"addColumn":return[...mo(e,n),...lc(e,n)];case"undoDeleteCell":{let o=mo(e,n),s=lc(e,n);return s.length>1?[...o,...s]:o}case"splitCell":{let{cellId:o}=a.payload,s=xs(o,n);return s?[{type:"set-code",cellId:o,code:s.code},...mo(e,n)]:[]}case"undoSplitCell":{let{cellId:o}=a.payload,s=xs(o,n);return s?[{type:"set-code",cellId:o,code:s.code},...rT(e,n)]:[]}case"moveToNextCell":return mo(e,n);case"addSetupCellIfDoesntExist":return mo(e,n);case"focusCell":case"focusTopCell":case"focusBottomCell":case"scrollToTarget":case"showCellIfHidden":case"markTouched":case"markUntouched":return[];case"prepareForRun":case"handleCellMessage":case"setCellIds":case"setCellCodes":case"setCells":case"setStdinResponse":case"clearSerializedEditorState":case"clearCellOutput":case"clearCellConsoleOutput":case"clearAllCellOutputs":case"clearLogs":return[];case"foldAll":case"unfoldAll":case"collapseCell":case"expandCell":case"collapseAllCells":case"expandAllCells":return[];default:C8(a)}}function iT(e){let n=new Set,a=new Set;for(let o of e)o.type==="create-cell"?n.add(o.cellId):o.type==="delete-cell"&&a.add(o.cellId);return n.intersection(a)}function oT(e,n){var o,s,c;let a=[];for(let p of e)switch(p.type){case"create-cell":{let d="__end__",m=!1;p.after?(d=p.after,m=!1):p.before&&(d=p.before,m=!0),a.push({type:"createNewCell",payload:{cellId:d,before:m,code:p.code,newCellId:p.cellId,autoFocus:!1,hideCode:((o=p.config)==null?void 0:o.hide_code)??!1}}),p.name&&a.push({type:"updateCellName",payload:{cellId:p.cellId,name:p.name}}),(((s=p.config)==null?void 0:s.disabled)!=null||((c=p.config)==null?void 0:c.column)!=null)&&a.push({type:"updateCellConfig",payload:{cellId:p.cellId,config:{...p.config.disabled!=null&&{disabled:p.config.disabled},...p.config.column!=null&&{column:p.config.column}}}});break}case"delete-cell":a.push({type:"deleteCell",payload:{cellId:p.cellId}});break;case"move-cell":{let d=[...n()],m=p.cellId,b=d.indexOf(m);if(b<0)break;if(d.splice(b,1),p.after){let _=d.indexOf(p.after);_>=0?d.splice(_+1,0,m):d.push(m)}else if(p.before){let _=d.indexOf(p.before);_>=0?d.splice(_,0,m):d.unshift(m)}else d.push(m);a.push({type:"setCellIds",payload:{cellIds:d}});break}case"reorder-cells":a.push({type:"setCellIds",payload:{cellIds:p.cellIds}});break;case"set-code":a.push({type:"setCellCodes",payload:{ids:[p.cellId],codes:[p.code],codeIsStale:!0}});break;case"set-name":a.push({type:"updateCellName",payload:{cellId:p.cellId,name:p.name}});break;case"set-config":a.push({type:"updateCellConfig",payload:{cellId:p.cellId,config:{...p.hideCode!=null&&{hide_code:p.hideCode},...p.disabled!=null&&{disabled:p.disabled},...p.column!=null&&{column:p.column}}}});break}return a}var cc=[],sT=Nh(()=>{if(cc.length===0)return;let e=cc;cc=[],br().sendDocumentTransaction({changes:e})},400);function lT(e){return"cellId"in e&&e.cellId==="__scratch__"}function cT(e){Be.get(Wm)||lT(e)||(cc.push(e),sT())}function uT(e,n,a){for(let o of aT(e,n,a))cT(o)}Ex=function(e,n,a){let o=iT(e);for(let s of e)if(!(o.size>0&&"cellId"in s&&o.has(s.cellId)))for(let c of oT([s],a))n[c.type](c.payload)};function dT(e,n){return B8(e*1e3,n==null?void 0:n.in)}var Tf=function(e,n){return Object.defineProperty?Object.defineProperty(e,"raw",{value:n}):e.raw=n,e},ht;(function(e){e[e.EOS=0]="EOS",e[e.Text=1]="Text",e[e.Incomplete=2]="Incomplete",e[e.ESC=3]="ESC",e[e.Unknown=4]="Unknown",e[e.SGR=5]="SGR",e[e.OSCURL=6]="OSCURL"})(ht||(ht={})),$m=class{constructor(){this.VERSION="6.0.6",this.setup_palettes(),this._use_classes=!1,this.bold=!1,this.faint=!1,this.italic=!1,this.underline=!1,this.fg=this.bg=null,this._buffer="",this._url_allowlist={http:1,https:1},this._escape_html=!0,this.boldStyle="font-weight:bold",this.faintStyle="opacity:0.7",this.italicStyle="font-style:italic",this.underlineStyle="text-decoration:underline"}set use_classes(e){this._use_classes=e}get use_classes(){return this._use_classes}set url_allowlist(e){this._url_allowlist=e}get url_allowlist(){return this._url_allowlist}set escape_html(e){this._escape_html=e}get escape_html(){return this._escape_html}set boldStyle(e){this._boldStyle=e}get boldStyle(){return this._boldStyle}set faintStyle(e){this._faintStyle=e}get faintStyle(){return this._faintStyle}set italicStyle(e){this._italicStyle=e}get italicStyle(){return this._italicStyle}set underlineStyle(e){this._underlineStyle=e}get underlineStyle(){return this._underlineStyle}setup_palettes(){this.ansi_colors=[[{rgb:[0,0,0],class_name:"ansi-black"},{rgb:[187,0,0],class_name:"ansi-red"},{rgb:[0,187,0],class_name:"ansi-green"},{rgb:[187,187,0],class_name:"ansi-yellow"},{rgb:[0,0,187],class_name:"ansi-blue"},{rgb:[187,0,187],class_name:"ansi-magenta"},{rgb:[0,187,187],class_name:"ansi-cyan"},{rgb:[255,255,255],class_name:"ansi-white"}],[{rgb:[85,85,85],class_name:"ansi-bright-black"},{rgb:[255,85,85],class_name:"ansi-bright-red"},{rgb:[0,255,0],class_name:"ansi-bright-green"},{rgb:[255,255,85],class_name:"ansi-bright-yellow"},{rgb:[85,85,255],class_name:"ansi-bright-blue"},{rgb:[255,85,255],class_name:"ansi-bright-magenta"},{rgb:[85,255,255],class_name:"ansi-bright-cyan"},{rgb:[255,255,255],class_name:"ansi-bright-white"}]],this.palette_256=[],this.ansi_colors.forEach(a=>{a.forEach(o=>{this.palette_256.push(o)})});let e=[0,95,135,175,215,255];for(let a=0;a<6;++a)for(let o=0;o<6;++o)for(let s=0;s<6;++s){let c={rgb:[e[a],e[o],e[s]],class_name:"truecolor"};this.palette_256.push(c)}let n=8;for(let a=0;a<24;++a,n+=10){let o={rgb:[n,n,n],class_name:"truecolor"};this.palette_256.push(o)}}escape_txt_for_html(e){return this._escape_html?e.replace(/[&<>"']/gm,n=>{if(n==="&")return"&";if(n==="<")return"<";if(n===">")return">";if(n==='"')return""";if(n==="'")return"'"}):e}append_buffer(e){this._buffer+=e}get_next_packet(){var e={kind:ht.EOS,text:"",url:""},n=this._buffer.length;if(n==0)return e;var a=this._buffer.indexOf("\x1B");if(a==-1)return e.kind=ht.Text,e.text=this._buffer,this._buffer="",e;if(a>0)return e.kind=ht.Text,e.text=this._buffer.slice(0,a),this._buffer=this._buffer.slice(a),e;if(a==0){if(n<3)return e.kind=ht.Incomplete,e;var o=this._buffer.charAt(1);if(o!="["&&o!="]"&&o!="(")return e.kind=ht.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e;if(o=="["){this._csi_regex||(this._csi_regex=q1(pT||(pT=Tf([`
|
|
131
131
|
^ # beginning of line
|
|
@@ -226,4 +226,4 @@ mark line col
|
|
|
226
226
|
)
|
|
227
227
|
`]))));let c=this._buffer.match(this._osc_regex);if(c===null)return e.kind=ht.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e;e.kind=ht.OSCURL,e.url=c[1],e.text=c[2];var s=c[0].length;return this._buffer=this._buffer.slice(s),e}else if(o=="(")return e.kind=ht.Unknown,this._buffer=this._buffer.slice(3),e}}ansi_to_html(e){this.append_buffer(e);for(var n=[];;){var a=this.get_next_packet();if(a.kind==ht.EOS||a.kind==ht.Incomplete)break;a.kind==ht.ESC||a.kind==ht.Unknown||(a.kind==ht.Text?n.push(this.transform_to_html(this.with_state(a))):a.kind==ht.SGR?this.process_ansi(a):a.kind==ht.OSCURL&&n.push(this.process_hyperlink(a)))}return n.join("")}with_state(e){return{bold:this.bold,faint:this.faint,italic:this.italic,underline:this.underline,fg:this.fg,bg:this.bg,text:e.text}}process_ansi(e){let n=e.text.split(";");for(;n.length>0;){let a=n.shift(),o=parseInt(a,10);if(isNaN(o)||o===0)this.fg=null,this.bg=null,this.bold=!1,this.faint=!1,this.italic=!1,this.underline=!1;else if(o===1)this.bold=!0;else if(o===2)this.faint=!0;else if(o===3)this.italic=!0;else if(o===4)this.underline=!0;else if(o===21)this.bold=!1;else if(o===22)this.faint=!1,this.bold=!1;else if(o===23)this.italic=!1;else if(o===24)this.underline=!1;else if(o===39)this.fg=null;else if(o===49)this.bg=null;else if(o>=30&&o<38)this.fg=this.ansi_colors[0][o-30];else if(o>=40&&o<48)this.bg=this.ansi_colors[0][o-40];else if(o>=90&&o<98)this.fg=this.ansi_colors[1][o-90];else if(o>=100&&o<108)this.bg=this.ansi_colors[1][o-100];else if((o===38||o===48)&&n.length>0){let s=o===38,c=n.shift();if(c==="5"&&n.length>0){let p=parseInt(n.shift(),10);p>=0&&p<=255&&(s?this.fg=this.palette_256[p]:this.bg=this.palette_256[p])}if(c==="2"&&n.length>2){let p=parseInt(n.shift(),10),d=parseInt(n.shift(),10),m=parseInt(n.shift(),10);if(p>=0&&p<=255&&d>=0&&d<=255&&m>=0&&m<=255){let b={rgb:[p,d,m],class_name:"truecolor"};s?this.fg=b:this.bg=b}}}}}transform_to_html(e){let n=e.text;if(n.length===0||(n=this.escape_txt_for_html(n),!e.bold&&!e.italic&&!e.faint&&!e.underline&&e.fg===null&&e.bg===null))return n;let a=[],o=[],s=e.fg,c=e.bg;e.bold&&a.push(this._boldStyle),e.faint&&a.push(this._faintStyle),e.italic&&a.push(this._italicStyle),e.underline&&a.push(this._underlineStyle),this._use_classes?(s&&(s.class_name==="truecolor"?a.push(`color:rgb(${s.rgb.join(",")})`):o.push(`${s.class_name}-fg`)),c&&(c.class_name==="truecolor"?a.push(`background-color:rgb(${c.rgb.join(",")})`):o.push(`${c.class_name}-bg`))):(s&&a.push(`color:rgb(${s.rgb.join(",")})`),c&&a.push(`background-color:rgb(${c.rgb})`));let p="",d="";return o.length&&(p=` class="${o.join(" ")}"`),a.length&&(d=` style="${a.join(";")}"`),`<span${d}${p}>${n}</span>`}process_hyperlink(e){let n=e.url.split(":");return n.length<1||!this._url_allowlist[n[0]]?"":`<a href="${this.escape_txt_for_html(e.url)}">${this.escape_txt_for_html(e.text)}</a>`}};function q1(e,...n){let a=e.raw[0].replace(/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,"");return new RegExp(a)}function fT(e,...n){let a=e.raw[0].replace(/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,"");return new RegExp(a,"g")}var pT,hT,mT,gT=new $m;vd=function(e){try{let n=document.createElement("div");return n.innerHTML=e,(n.textContent||n.innerText||"").split(`
|
|
228
228
|
`).map(a=>a.trimEnd()).join(`
|
|
229
|
-
`)}catch(n){return be.error("Error parsing HTML content:",n),e}},rx=function(e){if(!e)return"";try{return vd(gT.ansi_to_html(e))}catch(n){return be.error("Error converting ANSI to plain text:",n),e}},Gh=Te(null);let fi;fi=er(),H_=bk,um=_e.forwardRef((e,n)=>{let a=(0,fi.c)(9),o,s;a[0]===e?(o=a[1],s=a[2]):({className:o,...s}=e,a[0]=e,a[1]=o,a[2]=s);let c;a[3]===o?c=a[4]:(c=Pr("fixed top-0 z-100 flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:w-fit md:max-w-[420px]",o),a[3]=o,a[4]=c);let p;return a[5]!==s||a[6]!==n||a[7]!==c?(p=(0,N.jsx)(P0,{ref:n,className:c,...s}),a[5]=s,a[6]=n,a[7]=c,a[8]=p):p=a[8],p}),um.displayName=P0.displayName;let F1;F1=x6("data-[swipe=move]:transition-none group relative pointer-events-auto flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=move]:translate-x-(--radix-toast-swipe-move-x) data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-(--radix-toast-swipe-end-x) data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=open]:slide-in-from-top-full sm:data-[state=open]:slide-in-from-bottom-full data-[state=closed]:slide-out-to-right-full",{variants:{variant:{default:"bg-background border",danger:"group destructive text-error border-destructive bg-(--red-1) shadow-md-solid shadow-error"}},defaultVariants:{variant:"default"}}),Qm=_e.forwardRef((e,n)=>{let a=(0,fi.c)(11),o,s,c;a[0]===e?(o=a[1],s=a[2],c=a[3]):({className:o,variant:c,...s}=e,a[0]=e,a[1]=o,a[2]=s,a[3]=c);let p=c||"default",d;a[4]!==o||a[5]!==p?(d=Pr(F1({variant:p}),"print:hidden",o),a[4]=o,a[5]=p,a[6]=d):d=a[6];let m;return a[7]!==s||a[8]!==n||a[9]!==d?(m=(0,N.jsx)(N0,{ref:n,className:d,...s}),a[7]=s,a[8]=n,a[9]=d,a[10]=m):m=a[10],m}),Qm.displayName=N0.displayName;var B1=_e.forwardRef((e,n)=>{let a=(0,fi.c)(9),o,s;a[0]===e?(o=a[1],s=a[2]):({className:o,...s}=e,a[0]=e,a[1]=o,a[2]=s);let c;a[3]===o?c=a[4]:(c=Pr("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-destructive/30 hover:group-[.destructive]:border-destructive/30 hover:group-[.destructive]:bg-destructive hover:group-[.destructive]:text-destructive-foreground focus:group-[.destructive]:ring-destructive",o),a[3]=o,a[4]=c);let p;return a[5]!==s||a[6]!==n||a[7]!==c?(p=(0,N.jsx)(j0,{ref:n,className:c,...s}),a[5]=s,a[6]=n,a[7]=c,a[8]=p):p=a[8],p});B1.displayName=j0.displayName,im=_e.forwardRef((e,n)=>{let a=(0,fi.c)(10),o,s;a[0]===e?(o=a[1],s=a[2]):({className:o,...s}=e,a[0]=e,a[1]=o,a[2]=s);let c;a[3]===o?c=a[4]:(c=Pr("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-hidden focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 hover:group-[.destructive]:text-red-500 focus:group-[.destructive]:ring-red-400 focus:group-[.destructive]:ring-offset-red-600",o),a[3]=o,a[4]=c);let p;a[5]===Symbol.for("react.memo_cache_sentinel")?(p=(0,N.jsx)(F8,{className:"h-4 w-4"}),a[5]=p):p=a[5];let d;return a[6]!==s||a[7]!==n||a[8]!==c?(d=(0,N.jsx)(z0,{ref:n,className:c,"toast-close":"",...s,children:p}),a[6]=s,a[7]=n,a[8]=c,a[9]=d):d=a[9],d}),im.displayName=z0.displayName,_m=_e.forwardRef((e,n)=>{let a=(0,fi.c)(9),o,s;a[0]===e?(o=a[1],s=a[2]):({className:o,...s}=e,a[0]=e,a[1]=o,a[2]=s);let c;a[3]===o?c=a[4]:(c=Pr("text-sm font-semibold",o),a[3]=o,a[4]=c);let p;return a[5]!==s||a[6]!==n||a[7]!==c?(p=(0,N.jsx)(M0,{ref:n,className:c,...s}),a[5]=s,a[6]=n,a[7]=c,a[8]=p):p=a[8],p}),_m.displayName=M0.displayName,wm=_e.forwardRef((e,n)=>{let a=(0,fi.c)(9),o,s;a[0]===e?(o=a[1],s=a[2]):({className:o,...s}=e,a[0]=e,a[1]=o,a[2]=s);let c;a[3]===o?c=a[4]:(c=Pr("text-sm opacity-90",o),a[3]=o,a[4]=c);let p;return a[5]!==s||a[6]!==n||a[7]!==c?(p=(0,N.jsx)(D0,{ref:n,className:c,...s}),a[5]=s,a[6]=n,a[7]=c,a[8]=p):p=a[8],p}),wm.displayName=D0.displayName;var V1=!1;function yT(e){var o;let n=[],a=[e.console].filter(Boolean).flat();for(let s of a){let c=s.mimetype==="text/plain",p=s.mimetype==="text/html"||s.mimetype==="application/vnd.marimo+traceback";if(c||p){let d=s.channel==="stderr"||s.channel==="marimo-error";switch(s.channel){case"stdout":case"stderr":case"marimo-error":{let m=S8.asString(s.data),b=p?vd(m):m;n.push({timestamp:s.timestamp||Date.now(),level:d?"stderr":"stdout",message:b,cellId:e.cell_id});break}default:break}}}if(n.forEach(H1.log),a.length===0&&hd((o=e.output)==null?void 0:o.mimetype)&&Array.isArray(e.output.data)){e.output.data.forEach(c=>{H1.log({level:"stderr",cellId:e.cell_id,timestamp:e.timestamp??0,message:JSON.stringify(c)})});let s=e.output.data.filter(c=>"type"in c&&c.type==="exception"||c.type==="internal");if(s.length>0&&!V1){V1=!0;let c=s.find(p=>p.traceback);El(c?{title:"An internal error occurred",description:c.msg||"Click 'View' to see traceback",variant:"danger",action:_e.createElement(B1,{altText:"View traceback",onClick:()=>{Be.set(Gh,{traceback:c.traceback,errorMessage:c.msg||"An internal error occurred"})}},"View")}:{title:"An internal error occurred",description:"See console for details.",variant:"danger"})}}return n}var H1={log:e=>{let n=e.level==="stdout"?"gray":e.level==="stderr"?"red":"orange",a=e.level.toUpperCase();console.log(`%c[${a}]`,`color:${n}; padding:2px 0; border-radius:2px; font-weight:bold`,`[${sm(e.timestamp)}]`,`(${e.cellId}) ${e.message}`)}};sm=function(e){try{return dT(e).toLocaleTimeString(void 0,{hour12:!0,hour:"numeric",minute:"numeric",second:"numeric"})}catch{return""}},q_=function(e,n){let a=id(n);a?a.focus():be.warn(`[CellFocusManager] focusCellEditor: element not found: ${n}`)},d_=function(e){let n=document.getElementById(En.create(e));n?If(n):be.warn(`[CellFocusManager] focusCell: element not found: ${e}`)},c_=function(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})},vm=function(){return document.activeElement instanceof HTMLElement&&document.activeElement.classList.contains("marimo-cell")};function If(e){try{e.focus()}catch{be.warn("[CellFocusManager] element may not be focusable",e)}}gm=function(e,n){let{retries:a,delay:o,initialDelay:s=0}=n,c=0,p=()=>{if(c<a){try{if(e())return}catch(d){be.error(`Error executing function on attempt ${c+1}, retrying`,{error:d})}c++,setTimeout(p,o)}};s>0?setTimeout(p,s):p()};function ks({cellId:e,cell:n,isCodeHidden:a,codeFocus:o,variableName:s}){var p;if(!n)return;let c=document.getElementById(En.create(e));if(!c){be.warn("scrollCellIntoView: element not found");return}if(vm()){If(c);return}if(a)If(c);else{let d=(p=n.current)==null?void 0:p.editorView;if(!d){be.warn("scrollCellIntoView: editor not found",e);return}if(d.hasFocus||!document.hasFocus())return;if(gm(()=>(d.focus(),d.hasFocus),{retries:5,delay:20}),o==="top")d.dispatch({selection:{anchor:0,head:0}});else if(o==="bottom"){let m=d.state.doc.line(d.state.doc.lines);d.dispatch({selection:{anchor:m.from,head:m.from}})}else s&&pd(d,s)}c.scrollIntoView({behavior:"smooth",block:"nearest"})}Wx=function(e){let n=document.getElementById(En.create(e));if(!n){be.warn("scrollCellIntoView: element not found");return}n.classList.add("focus-outline"),setTimeout(()=>{n.classList.remove("focus-outline")},2e3),n.scrollIntoView({behavior:"smooth",block:"center"})};function vT(){let e=document.getElementById("App");e==null||e.scrollTo({top:e.scrollHeight,behavior:"smooth"})}function bT(){var e;(e=document.getElementById("App"))==null||e.scrollTo({top:0,behavior:"smooth"})}Yw=function(e){let n=id(e);if(n!=null&&n.hasFocus){by(n,{behavior:"instant"});return}let a=document.getElementById(En.create(e));a?a.scrollIntoView({behavior:"instant",block:"nearest"}):be.warn(`[CellFocusManager] scrollCellIntoView: element not found: ${e}`)},rr=function({id:e,name:n="_",code:a="",lastCodeRun:o=null,lastExecutionTime:s=null,edited:c=!1,config:p,serializedEditorState:d=null}){return{id:e,config:p||{hide_code:!1,disabled:!1,column:null},name:n,code:a,edited:c,lastCodeRun:o,lastExecutionTime:s,serializedEditorState:d}};function wT(e){return{hide_code:!1,disabled:!1,column:null,...e}}ar=function(e){return{outline:null,output:null,consoleOutputs:[],status:"idle",staleInputs:!1,interrupted:!1,errored:!1,stopped:!1,runElapsedTimeMs:null,runStartTimestamp:null,lastRunStartTimestamp:null,debuggerActive:!1,...e}};var uc=er();function $1(e){let n={column:0,hide_code:!1,disabled:!1};return{...e,cellData:{[ls]:rr({id:ls,config:n}),...e.cellData},cellRuntime:{[ls]:ar(),...e.cellRuntime},cellHandles:{[ls]:(0,_e.createRef)(),...e.cellHandles}}}function _T(){return $1({cellIds:Dl.from([]),cellData:{},cellRuntime:{},cellHandles:{},history:[],scrollKey:null,cellLogs:[],untouchedNewCells:new Set})}let xT,W1,kT,U1;({reducer:xT,addMiddleware:W1,createActions:kT,useActions:U1,valueAtom:Ye}=Cl(_T,{createNewCell:(e,n)=>{var L;let{cellId:a,before:o,code:s,lastCodeRun:c=null,lastExecutionTime:p=null,autoFocus:d=!0,skipIfCodeExists:m=!1,hideCode:b=!1}=n,_,k;if(m){for(let P of e.cellIds.inOrderIds)if(((L=e.cellData[P])==null?void 0:L.code)===s)return e}if(a==="__end__"){let P=e.cellIds.atOrThrow(0);_=P.id,k=P.length}else if(typeof a=="string"){let P=e.cellIds.findWithId(a);_=P.id,k=P.topLevelIds.indexOf(a)}else if(a.type==="__end__"){let P=e.cellIds.get(a.columnId)||e.cellIds.atOrThrow(0);_=P.id,k=P.length}else throw Error("Invalid cellId");let S=n.newCellId||Ya.create(),E=o?k:k+1;return{...e,cellIds:e.cellIds.insertId(S,_,E),cellData:{...e.cellData,[S]:rr({id:S,code:s,lastCodeRun:c,config:wT({hide_code:b}),lastExecutionTime:p,edited:!!s&&s!==c})},cellRuntime:{...e.cellRuntime,[S]:ar()},cellHandles:{...e.cellHandles,[S]:(0,_e.createRef)()},scrollKey:d?S:null,untouchedNewCells:b&&!s?new Set([...e.untouchedNewCells,S]):e.untouchedNewCells}},moveCell:(e,n)=>{let{cellId:a,before:o,direction:s}=n;if(o!==void 0&&s!==void 0&&be.warn("Both before and direction specified for moveCell. Ignoring one."),s){let d=e.cellIds.findWithId(a),m=e.cellIds.indexOf(d),b=s==="left"?m-1:m+1,_=e.cellIds.at(b);return _?{...e,cellIds:e.cellIds.moveAcrossColumns(d.id,a,_.id,void 0),scrollKey:a}:e}let c=e.cellIds.findWithId(a),p=c.indexOfOrThrow(a);return o&&p===0?{...e,cellIds:e.cellIds.moveWithinColumn(c.id,p,0),scrollKey:a}:!o&&p===c.length-1?{...e,cellIds:e.cellIds.moveWithinColumn(c.id,p,c.length-1),scrollKey:a}:o?{...e,cellIds:e.cellIds.moveWithinColumn(c.id,p,p-1),scrollKey:a}:{...e,cellIds:e.cellIds.moveWithinColumn(c.id,p,p+1),scrollKey:a}},dropCellOverCell:(e,n)=>{let{cellId:a,overCellId:o}=n,s=e.cellIds.findWithId(a),c=e.cellIds.findWithId(o),p=s.indexOfOrThrow(a),d=c.indexOfOrThrow(o);return s.id===c.id?p===d?e:{...e,cellIds:e.cellIds.moveWithinColumn(s.id,p,d),scrollKey:null}:{...e,cellIds:e.cellIds.moveAcrossColumns(s.id,a,c.id,o),scrollKey:null}},dropCellOverColumn:(e,n)=>{let{cellId:a,columnId:o}=n,s=e.cellIds.findWithId(a);return{...e,cellIds:e.cellIds.moveAcrossColumns(s.id,a,o,void 0)}},dropOverNewColumn:(e,n)=>{let{cellId:a}=n;return{...e,cellIds:e.cellIds.moveToNewColumn(a)}},moveColumn:(e,n)=>n.column===n.overColumn?e:{...e,cellIds:e.cellIds.moveColumn(n.column,n.overColumn)},focusCell:(e,n)=>{let a=e.cellIds.findWithId(n.cellId);if(a.length===0)return e;let{cellId:o,where:s}=n,c=a.indexOfOrThrow(o),p;p=s==="before"?Bh(c-1,0,a.length-1):s==="after"?Bh(c+1,0,a.length-1):c;let d=a.atOrThrow(p);return ks({cellId:d,cell:e.cellHandles[d],isCodeHidden:Cs(e,d),codeFocus:s==="after"?"top":"bottom",variableName:void 0}),e},focusTopCell:e=>{let n=e.cellIds.getColumns().at(0);if(n===void 0||n.length===0)return e;let a=n.first();return ks({cellId:a,cell:e.cellHandles[a],isCodeHidden:Cs(e,a),codeFocus:void 0,variableName:void 0}),bT(),e},focusBottomCell:e=>{let n=e.cellIds.getColumns().at(-1);if(n===void 0||n.length===0)return e;let a=n.last();return ks({cellId:a,cell:e.cellHandles[a],isCodeHidden:Cs(e,a),codeFocus:void 0,variableName:void 0}),vT(),e},sendToTop:(e,n)=>{let a=e.cellIds.findWithId(n.cellId);if(a.length===0)return e;let{cellId:o,scroll:s=!0}=n,c=a.indexOfOrThrow(o);return c===0?e:{...e,cellIds:e.cellIds.moveWithinColumn(a.id,c,0),scrollKey:s?o:null}},sendToBottom:(e,n)=>{let a=e.cellIds.findWithId(n.cellId);if(a.length===0)return e;let{cellId:o,scroll:s=!0}=n,c=a.indexOfOrThrow(o),p=a.length-1;return c===p?e:{...e,cellIds:e.cellIds.moveWithinColumn(a.id,c,p),scrollKey:s?o:null}},addColumn:(e,n)=>{let a=Ya.create();return{...e,cellIds:e.cellIds.addColumn(n.columnId,[a]),cellData:{...e.cellData,[a]:rr({id:a})},cellRuntime:{...e.cellRuntime,[a]:ar()},cellHandles:{...e.cellHandles,[a]:(0,_e.createRef)()},scrollKey:a}},addColumnBreakpoint:(e,n)=>{let{cellId:a}=n;return e.cellIds.getColumns()[0].inOrderIds[0]===a?e:{...e,cellIds:e.cellIds.insertBreakpoint(a)}},deleteColumn:(e,n)=>{let{columnId:a}=n;return{...e,cellIds:e.cellIds.delete(a)}},mergeAllColumns:e=>({...e,cellIds:e.cellIds.mergeAllColumns()}),compactColumns:e=>({...e,cellIds:e.cellIds.compact()}),deleteCell:(e,n)=>{var b,_;let a=n.cellId;if(e.cellIds.hasOnlyOneId())return e;let o;try{o=e.cellIds.findWithId(a)}catch(k){return be.warn("Skipping delete for missing cellId",{cellId:a,error:k}),e}let s=o.indexOfOrThrow(a),c=s===0?1:s-1,p=null;o.length>1&&(p=o.atOrThrow(c));let d=(_=(b=e.cellHandles[a].current)==null?void 0:b.editorView)==null?void 0:_.state.toJSON({history:m8});d&&(d.doc=e.cellData[a].code),ET(a);let m=e.cellData[a];return{...e,cellIds:e.cellIds.deleteById(a),history:[...e.history,{name:m.name,serializedEditorState:d,column:o.id,index:s,isSetupCell:a===Vn,config:m.config}],scrollKey:p}},undoDeleteCell:e=>{if(e.history.length===0)return e;let{name:n,serializedEditorState:a={doc:""},column:o,index:s,isSetupCell:c,config:p}=e.history[e.history.length-1],d=c?Vn:Ya.create(),m=rr({id:d,name:n,code:a.doc,edited:a.doc.trim().length>0,serializedEditorState:a,config:p});return{...e,cellIds:e.cellIds.insertId(d,o,s),cellData:{...e.cellData,[d]:m},cellRuntime:{...e.cellRuntime,[d]:ar()},cellHandles:{...e.cellHandles,[d]:(0,_e.createRef)()},history:e.history.slice(0,-1),scrollKey:d}},clearSerializedEditorState:(e,n)=>{let{cellId:a}=n;return go({state:e,cellId:a,cellReducer:o=>({...o,serializedEditorState:null})})},updateCellCode:(e,n)=>{let{cellId:a,code:o,formattingChange:s}=n;return e.cellData[a]?go({state:e,cellId:a,cellReducer:c=>s?{...c,code:o,lastCodeRun:c.edited?c.lastCodeRun:o}:{...c,code:o,edited:o.trim()!==c.lastCodeRun}}):e},updateCellName:(e,n)=>{let{cellId:a,name:o}=n;return go({state:e,cellId:a,cellReducer:s=>({...s,name:o})})},updateCellConfig:(e,n)=>{let{cellId:a,config:o}=n;return go({state:e,cellId:a,cellReducer:s=>({...s,config:{...s.config,...o}})})},prepareForRun:(e,n)=>go({state:Ss({state:e,cellId:n.cellId,cellReducer:a=>nT(a)}),cellId:n.cellId,cellReducer:a=>({...a,edited:!1,lastCodeRun:a.code.trim()})}),handleCellMessage:(e,n)=>{let a=n.cell_id,o=Ss({state:e,cellId:a,cellReducer:s=>tT(s,n)});return n.status==="queued"&&(o=go({state:o,cellId:a,cellReducer:s=>({...s,lastCodeRun:s.code.trim(),edited:!1})})),{...o,cellLogs:[...o.cellLogs,...yT(n)]}},setCellIds:(e,n)=>{if(h6(e.cellIds.inOrderIds,n.cellIds))return e;let a={...e.cellData},o={...e.cellRuntime},s={...e.cellHandles};for(let c of n.cellIds)c in e.cellData||(a[c]=rr({id:c})),c in e.cellRuntime||(o[c]=ar()),c in e.cellHandles||(s[c]=(0,_e.createRef)());return{...e,cellIds:Dl.fromWithPreviousShape(n.cellIds,e.cellIds),cellData:a,cellRuntime:o,cellHandles:s}},setCellCodes:(e,n)=>{var s,c;rn(n.codes.length===n.ids.length,"Expected codes and ids to have the same length");let a={...e},o=({cell:p,code:d,cellId:m,name:b,config:_})=>{if(!p)return rr({id:m,code:d,name:b,config:_,lastCodeRun:n.codeIsStale?null:d,edited:n.codeIsStale&&d.trim().length>0});let k=n.codeIsStale?p.lastCodeRun:d,S=k?k.trim()!==d.trim():!!d;if(p.code.trim()===d.trim())return{...p,code:d,edited:S,lastCodeRun:k,...b!==void 0&&{name:b},..._!==void 0&&{config:_}};if(!Rm()){let E=a.cellHandles[m].current;E!=null&&E.editorViewOrNull&&Ji(E.editorViewOrNull,d)}return{...p,code:d,edited:S,lastCodeRun:k,...b!==void 0&&{name:b},..._!==void 0&&{config:_}}};for(let p=0;p<n.ids.length;p++){let d=n.ids[p],m=n.codes[p];if(d===void 0||m===void 0)continue;let b=(s=n.names)==null?void 0:s[p],_=(c=n.configs)==null?void 0:c[p];a={...a,cellData:{...a.cellData,[d]:o({cell:a.cellData[d],code:m,cellId:d,name:b,config:_})}}}return a},setStdinResponse:(e,n)=>{let{cellId:a,response:o,outputIndex:s}=n;return Ss({state:e,cellId:a,cellReducer:c=>{let p=[...c.consoleOutputs],d=p[s];return d.channel==="stdin"?(p[s]={channel:"stdin",mimetype:d.mimetype,data:d.data,timestamp:d.timestamp,response:o},{...c,interrupted:!1,consoleOutputs:p}):(be.warn("Expected stdin output"),c)}})},setCells:(e,n)=>{let a=Object.fromEntries(n.map(s=>[s.id,s])),o=Object.fromEntries(n.map(s=>[s.id,ar()]));return $1({...e,cellIds:Dl.fromIdsAndColumns(n.map(s=>[s.id,s.config.column])),cellData:a,cellRuntime:o,cellHandles:Object.fromEntries(n.map(s=>[s.id,(0,_e.createRef)()]))})},moveToNextCell:(e,n)=>{let{cellId:a,before:o,noCreate:s=!1}=n;if(a==="__scratch__")return e;let c=e.cellIds.findWithId(a),p=c.indexOfOrThrow(a),d=o?p-1:p+1,m=d===c.length,b=d===-1;if(m&&!s){let _=Ya.create();return{...e,cellIds:e.cellIds.insertId(_,c.id,d),cellData:{...e.cellData,[_]:rr({id:_})},cellRuntime:{...e.cellRuntime,[_]:ar()},cellHandles:{...e.cellHandles,[_]:(0,_e.createRef)()},scrollKey:_}}if(b&&!s){let _=Ya.create();return{...e,cellIds:e.cellIds.insertId(_,c.id,0),cellData:{...e.cellData,[_]:rr({id:_})},cellRuntime:{...e.cellRuntime,[_]:ar()},cellHandles:{...e.cellHandles,[_]:(0,_e.createRef)()},scrollKey:_}}if((m||b)&&s)return e;if(d>=0&&d<c.length){let _=c.atOrThrow(d);ks({cellId:_,cell:e.cellHandles[_],isCodeHidden:Cs(e,_),codeFocus:o?"bottom":"top",variableName:void 0})}return e},markTouched:(e,n)=>{let{cellId:a}=n;if(e.untouchedNewCells.has(a)){let o=new Set(e.untouchedNewCells);return o.delete(a),{...e,untouchedNewCells:o}}return e},markUntouched:(e,n)=>{let{cellId:a}=n;if(!e.untouchedNewCells.has(a)){let o=new Set(e.untouchedNewCells);return o.add(a),{...e,untouchedNewCells:o}}return e},scrollToTarget:e=>{let n=e.scrollKey;if(n===null)return e;let a=e.cellIds.findWithId(n),o=a.indexOfOrThrow(n),s=o===a.length-1?a.last():a.atOrThrow(o);return ks({cellId:s,cell:e.cellHandles[s],isCodeHidden:Cs(e,s),codeFocus:void 0,variableName:void 0}),{...e,scrollKey:null}},foldAll:e=>(Mk(Object.values(e.cellHandles).map(n=>{var a;return(a=n.current)==null?void 0:a.editorView})),e),unfoldAll:e=>(Dk(Object.values(e.cellHandles).map(n=>{var a;return(a=n.current)==null?void 0:a.editorView})),e),clearLogs:e=>({...e,cellLogs:[]}),collapseCell:(e,n)=>{let{cellId:a}=n,o=e.cellIds.findWithId(a),s=o.topLevelIds.map(d=>e.cellRuntime[d].outline),c=P1(o.indexOfOrThrow(a),s);if(!c)return e;let p=o.atOrThrow(c[1]);return{...e,cellIds:e.cellIds.transformWithCellId(a,d=>d.collapse(a,p)),scrollKey:a}},expandCell:(e,n)=>{let{cellId:a}=n;return{...e,cellIds:e.cellIds.transformWithCellId(a,o=>o.expand(a)),scrollKey:a}},collapseAllCells:e=>({...e,cellIds:e.cellIds.transformAll(n=>{let a=n.topLevelIds.map(m=>e.cellRuntime[m].outline),o=[...n.nodes],s=[],c=[],p=o.length-1;for(;p>=0;){let m=P1(p,a);if(m){let b=p,_=m[1],k=s.find(L=>L.start<=_&&L.end===_);k&&(_=k.start),s.push({start:b,end:_});let S=n.atOrThrow(b),E=n.atOrThrow(_);c.push({id:S,until:E})}else c.push(null);p--}let d=c.toReversed();return n.collapseAll(d)})}),expandAllCells:e=>({...e,cellIds:e.cellIds.transformAll(n=>n.expandAll())}),showCellIfHidden:(e,n)=>{let{cellId:a}=n,o=e.cellIds.findWithId(a),s=o,c=o.findAndExpandDeep(a);return c.equals(s)?e:{...e,cellIds:e.cellIds.transformWithCellId(a,()=>c)}},splitCell:(e,n)=>{var _;let{cellId:a}=n,o=e.cellIds.findWithId(a),s=o.indexOfOrThrow(a),c=e.cellData[a],p=e.cellHandles[a].current;if((p==null?void 0:p.editorView)==null)return e;let{beforeCursorCode:d,afterCursorCode:m}=U4(p.editorView);Ji(p.editorView,d);let b=Ya.create();return{...e,cellIds:e.cellIds.insertId(b,o.id,s+1),cellData:{...e.cellData,[a]:{...c,code:d,edited:!!d&&d.trim()!==((_=c.lastCodeRun)==null?void 0:_.trim())},[b]:rr({id:b,code:m,edited:!!m})},cellRuntime:{...e.cellRuntime,[a]:{...e.cellRuntime[a],output:null,consoleOutputs:[]},[b]:ar()},cellHandles:{...e.cellHandles,[b]:(0,_e.createRef)()},scrollKey:b}},undoSplitCell:(e,n)=>{var p;let{cellId:a,snapshot:o}=n,s=e.cellData[a],c=e.cellHandles[a].current;return(c==null?void 0:c.editorView)==null?e:(Ji(c.editorView,o),{...e,cellIds:e.cellIds.transformWithCellId(a,d=>{let m=d.indexOfOrThrow(a)+1;return d.deleteAtIndex(m)}),cellData:{...e.cellData,[a]:{...s,code:o,edited:!!o&&(o==null?void 0:o.trim())!==((p=s.lastCodeRun)==null?void 0:p.trim())}},cellRuntime:{...e.cellRuntime,[a]:{...e.cellRuntime[a],output:null,consoleOutputs:[]}},cellHandles:{...e.cellHandles}})},clearCellOutput:(e,n)=>{let{cellId:a}=n;return Ss({state:e,cellId:a,cellReducer:o=>({...o,output:null,consoleOutputs:[]})})},clearCellConsoleOutput:(e,n)=>{let{cellId:a}=n;return Ss({state:e,cellId:a,cellReducer:o=>({...o,consoleOutputs:o.consoleOutputs.filter(s=>s.channel==="stdin"&&s.response==null)})})},clearAllCellOutputs:e=>{let n={...e.cellRuntime};for(let a of e.cellIds.inOrderIds)n[a]={...n[a],output:null,consoleOutputs:[]};return{...e,cellRuntime:n}},addSetupCellIfDoesntExist:(e,n)=>{let{code:a}=n;return e.cellIds.setupCellExists()?{...e,scrollKey:Vn}:{...e,cellIds:e.cellIds.insertId(Vn,e.cellIds.atOrThrow(0).id,0),cellData:{...e.cellData,[Vn]:rr({id:Vn,name:Vn,code:a,edited:!!a})},cellRuntime:{...e.cellRuntime,[Vn]:ar()},cellHandles:{...e.cellHandles,[Vn]:(0,_e.createRef)()},scrollKey:Vn}}})),W1(uT);function Cs(e,n){return!!e.cellData[n].config.hide_code&&!e.untouchedNewCells.has(n)}function Ss({state:e,cellId:n,cellReducer:a}){return n in e.cellRuntime?{...e,cellRuntime:{...e.cellRuntime,[n]:a(e.cellRuntime[n])}}:(be.warn(`Cell ${n} not found in state`),e)}function go({state:e,cellId:n,cellReducer:a}){return n in e.cellData?{...e,cellData:{...e.cellData,[n]:a(e.cellData[n])}}:(be.warn(`Cell ${n} not found in state`),e)}Z_=function(e){let n=e.cellData,a={column:null};return e.cellIds.getColumns().length>1?e.cellIds.getColumns().flatMap((o,s)=>o.inOrderIds.map((c,p)=>{let d={...a};return p===0&&(d.column=s),{...n[c].config,...d}})):e.cellIds.getColumns().flatMap(o=>o.inOrderIds.map(s=>({...n[s].config,...a})))},rd=Te(e=>e(Ye).cellIds),Nx=Te(e=>e(rd).hasOnlyOneId()),W_=Te(e=>pm(e(Ye)).length>0),Te(e=>o0(e(Ye)).length>0);let K1;Ox=Te(e=>gC(e(Ye))),$x=Te(e=>hC(e(Ye))),ld=Te(e=>{let{cellIds:n,cellRuntime:a,cellData:o}=e(Ye);return n.inOrderIds.map(s=>{var d;let c=a[s],{name:p}=o[s];if(hd((d=c.output)==null?void 0:d.mimetype)){rn(Array.isArray(c.output.data),"Expected array data");let m=c.output.data.filter(b=>!b.type.includes("ancestor"));if(m.length>0)return{output:{...c.output,data:m},cellId:s,cellName:p}}return null}).filter(Boolean)}),N_=Te(e=>{let{cellIds:n,cellRuntime:a}=e(Ye);return J4(n.inOrderIds.map(o=>a[o].outline))}),Sx=Te(e=>e(ld).length),K1=p6(Te(e=>{let{cellIds:n,cellData:a}=e(Ye);return Rr.fromEntries(n.inOrderIds.map(o=>{var s;return[o,(s=a[o])==null?void 0:s.name]}))}));var CT=Te(e=>e(Ye).scrollKey);l_=()=>Sn(Ye),dx=()=>Sn(rd),x_=()=>Sn(K1),px=()=>Sn(ld),b_=()=>Sn(Ye).cellLogs,h_=()=>Sn(CT),sd=()=>Be.get(Ye),yx=()=>Be.get(Ye).cellIds,xx=()=>{let{cellIds:e,cellData:n}=Be.get(Ye);return e.inOrderIds.map(a=>{var o;return(o=n[a])==null?void 0:o.name}).filter(Boolean)};var ST=Ik(kk(Ye,e=>e.cellIds.inOrderIds.map(n=>e.cellData[n])));T_=()=>fw(ST),bx=Te(e=>e(Ye).cellRuntime),Bx=Te(e=>fC(e(Ye))),D_=Te(e=>{let{cellRuntime:n}=e(Ye);return Object.entries(n).every(([a,o])=>o.status!=="running"||a==="__scratch__")}),n_=Te(e=>pC(e(Ye))),Dx=Te(e=>e(Ye).cellIds.colLength),ix=Te(e=>e(Ye).cellIds.idLength>0),Tx=Te(e=>e(Ye).cellIds.getColumnIds()),md=Nd(e=>Te(n=>n(Ye).cellData[e]));var Lf=Nd(e=>Te(n=>n(Ye).cellRuntime[e]));const Q1=Nd(e=>Te(n=>n(Ye).cellHandles[e]));function ET(e){md.remove(e),Lf.remove(e),Q1.remove(e)}a_=e=>{let n=(0,uc.c)(2),a;return n[0]===e?a=n[1]:(a=md(e),n[0]=e,n[1]=a),Sn(a)},O_=e=>{let n=(0,uc.c)(2),a;return n[0]===e?a=n[1]:(a=Lf(e),n[0]=e,n[1]=a),Sn(a)},Gw=e=>{let n=(0,uc.c)(2),a;return n[0]===e?a=n[1]:(a=Q1(e),n[0]=e,n[1]=a),Sn(a)},t0=()=>{let{cellIds:e,cellHandles:n}=Be.get(Ye);return e.inOrderIds.map(a=>{var o,s;return(s=(o=n[a])==null?void 0:o.current)==null?void 0:s.editorViewOrNull}).filter(Boolean)},id=e=>{var a;let{cellHandles:n}=Be.get(Ye);return(a=n[e].current)==null?void 0:a.editorView},gx=function(e){let{cellIds:n,cellData:a,cellRuntime:o}=e;return n.getColumns().flatMap(s=>s.topLevelIds.map(c=>({...a[c],...o[c]})))},J_=function(e){return Te(n=>n(Ye).untouchedNewCells.has(e))};function TT(e){let n=Lf(e);return Te(a=>{let o=a(n);if(!o||o.status==="queued"||o.status==="running")return;let s=[],c=o.consoleOutputs;if(c&&c.length>0){let d=c.find(m=>m.mimetype==="application/vnd.marimo+traceback");if(d){let m=d.data;s.push(...Zm(m))}}let p=o.output;if((p==null?void 0:p.mimetype)==="application/vnd.marimo+error"){let d=p.data;if(Array.isArray(d))for(let m of d)m.type==="syntax"&&m.lineno!=null&&s.push({kind:"cell",cellId:e,lineNumber:m.lineno}),m.type==="import-star"&&m.lineno!=null&&s.push({kind:"cell",cellId:e,lineNumber:m.lineno})}return s.length>0?s:void 0})}s_=function(e){let n=(0,uc.c)(2),a;return n[0]===e?a=n[1]:(a=e===void 0?{}:e,n[0]=e,n[1]=a),U1(a)}})();export{Gh as $,Jh as $n,Xa as $r,Xh as $t,Gw as A,Yh as Ai,Zh as An,Jw as Ar,Xw as At,Yw as B,Zw as Bn,e_ as Br,t_ as Bt,n_ as C,Ya as Ci,em as Cn,r_ as Cr,Bn as Ct,a_ as D,Vn as Di,i_ as Dn,o_ as Dr,tm as Dt,s_ as E,ls as Ei,Tl as En,Fu as Er,Bu as Et,l_ as F,Vu as Fi,Za as Fn,Ki as Fr,nm as Ft,c_ as G,Hu as Gn,u_ as Gr,rm as Gt,d_ as H,$u as Hn,f_ as Hr,p_ as Ht,h_ as I,Wu as Ii,m_ as In,ot as Ir,am as It,im as J,g_ as Jn,om as Jr,Uu as Jt,sm as K,y_ as Kn,Qi as Kr,v_ as Kt,rr as L,Il as Ln,ua as Lr,Ll as Lt,b_ as M,lm as Mi,Ku as Mn,w_ as Mr,__ as Mt,x_ as N,k_ as Ni,C_ as Nn,S_ as Nr,E_ as Nt,T_ as O,Qu as Oi,I_ as On,L_ as Or,cm as Ot,O_ as P,A_ as Pi,R_ as Pn,da as Pr,P_ as Pt,um as Q,dm as Qn,Ol as Qr,fm as Qt,ar as R,Gu as Rn,pm as Rr,Hn as Rt,N_ as S,hm as Si,Ju as Sn,Gi as Sr,M_ as St,D_ as T,En as Ti,j_ as Tn,z_ as Tr,Xu as Tt,q_ as U,Al as Un,mm as Ur,F_ as Ut,gm as V,Yu as Vn,ym as Vr,B_ as Vt,vm as W,V_ as Wn,Zu as Wr,bm as Wt,H_ as X,$_ as Xn,Rl as Xr,ed as Xt,wm as Y,td as Yn,Pl as Yr,Nr as Yt,_m as Z,Nl as Zn,cs as Zr,nd as Zt,W_ as _,J8 as __tla,Ml as _i,U_ as _n,xm as _r,km as _t,rd as a,Dl as ai,K_ as an,Cm as ar,Sm as at,Ye as b,Q_ as bi,ad as bn,G_ as br,Ji as bt,J_ as c,X_ as ci,fa as cn,Em as cr,Y_ as ct,Z_ as d,ex as di,tx as dn,Tm as dr,Im as dt,nx as ei,Lm as en,Xi as er,rx as et,id as f,ax as fi,Om as fn,Am as fr,Rm as ft,ix as g,ox as gi,od as gn,Pm as gr,Nm as gt,sd as h,mn as hi,sx as hn,Mm as hr,lx as ht,ld as i,ei as ii,cx as in,Dm as ir,ux as it,dx as j,fx as ji,jm as jn,jl as jr,cd as jt,px as k,hx as ki,ud as kn,mx as kr,zm as kt,gx as l,dd as li,zl as ln,fd as lr,qm as lt,yx as m,vx as mi,pd as mn,Fm as mr,hd as mt,md as n,Bm as ni,Vm as nn,Hm as nr,$m as nt,bx as o,wx as oi,_x as on,Yi as or,Wm as ot,xx as p,us as pi,Um as pn,Km as pr,kx as pt,Qm as q,ti as qn,gd as qr,Cx as qt,Sx as r,Gm as ri,Jm as rn,Xm as rr,Ex as rt,Tx as s,Ym as si,Ix as sn,yd as sr,Lx as st,Ox as t,Zm as ti,Ax as tn,e0 as tr,vd as tt,t0 as u,ds as ui,Rx as un,fs as ur,Px as ut,Nx as v,ql as vi,Mx as vn,n0 as vr,r0 as vt,Dx as w,jx as wi,zx as wn,qx as wr,Fx as wt,Bx as x,Vx as xi,a0 as xn,bd as xr,Hx as xt,$x as y,wd as yi,_d as yn,i0 as yr,wr as yt,Wx as z,ni as zn,o0 as zr,xd as zt};
|
|
229
|
+
`)}catch(n){return be.error("Error parsing HTML content:",n),e}},rx=function(e){if(!e)return"";try{return vd(gT.ansi_to_html(e))}catch(n){return be.error("Error converting ANSI to plain text:",n),e}},Gh=Te(null);let fi;fi=er(),H_=bk,um=_e.forwardRef((e,n)=>{let a=(0,fi.c)(9),o,s;a[0]===e?(o=a[1],s=a[2]):({className:o,...s}=e,a[0]=e,a[1]=o,a[2]=s);let c;a[3]===o?c=a[4]:(c=Pr("fixed top-0 z-100 flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:w-fit md:max-w-[420px]",o),a[3]=o,a[4]=c);let p;return a[5]!==s||a[6]!==n||a[7]!==c?(p=(0,N.jsx)(P0,{ref:n,className:c,...s}),a[5]=s,a[6]=n,a[7]=c,a[8]=p):p=a[8],p}),um.displayName=P0.displayName;let F1;F1=x6("data-[swipe=move]:transition-none group relative pointer-events-auto flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=move]:translate-x-(--radix-toast-swipe-move-x) data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-(--radix-toast-swipe-end-x) data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=open]:slide-in-from-top-full sm:data-[state=open]:slide-in-from-bottom-full data-[state=closed]:slide-out-to-right-full",{variants:{variant:{default:"bg-background border",danger:"group destructive text-error border-destructive bg-(--red-1) shadow-md-solid shadow-error"}},defaultVariants:{variant:"default"}}),Qm=_e.forwardRef((e,n)=>{let a=(0,fi.c)(11),o,s,c;a[0]===e?(o=a[1],s=a[2],c=a[3]):({className:o,variant:c,...s}=e,a[0]=e,a[1]=o,a[2]=s,a[3]=c);let p=c||"default",d;a[4]!==o||a[5]!==p?(d=Pr(F1({variant:p}),"print:hidden",o),a[4]=o,a[5]=p,a[6]=d):d=a[6];let m;return a[7]!==s||a[8]!==n||a[9]!==d?(m=(0,N.jsx)(N0,{ref:n,className:d,...s}),a[7]=s,a[8]=n,a[9]=d,a[10]=m):m=a[10],m}),Qm.displayName=N0.displayName;var B1=_e.forwardRef((e,n)=>{let a=(0,fi.c)(9),o,s;a[0]===e?(o=a[1],s=a[2]):({className:o,...s}=e,a[0]=e,a[1]=o,a[2]=s);let c;a[3]===o?c=a[4]:(c=Pr("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-destructive/30 hover:group-[.destructive]:border-destructive/30 hover:group-[.destructive]:bg-destructive hover:group-[.destructive]:text-destructive-foreground focus:group-[.destructive]:ring-destructive",o),a[3]=o,a[4]=c);let p;return a[5]!==s||a[6]!==n||a[7]!==c?(p=(0,N.jsx)(j0,{ref:n,className:c,...s}),a[5]=s,a[6]=n,a[7]=c,a[8]=p):p=a[8],p});B1.displayName=j0.displayName,im=_e.forwardRef((e,n)=>{let a=(0,fi.c)(10),o,s;a[0]===e?(o=a[1],s=a[2]):({className:o,...s}=e,a[0]=e,a[1]=o,a[2]=s);let c;a[3]===o?c=a[4]:(c=Pr("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-hidden focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 hover:group-[.destructive]:text-red-500 focus:group-[.destructive]:ring-red-400 focus:group-[.destructive]:ring-offset-red-600",o),a[3]=o,a[4]=c);let p;a[5]===Symbol.for("react.memo_cache_sentinel")?(p=(0,N.jsx)(F8,{className:"h-4 w-4"}),a[5]=p):p=a[5];let d;return a[6]!==s||a[7]!==n||a[8]!==c?(d=(0,N.jsx)(z0,{ref:n,className:c,"toast-close":"",...s,children:p}),a[6]=s,a[7]=n,a[8]=c,a[9]=d):d=a[9],d}),im.displayName=z0.displayName,_m=_e.forwardRef((e,n)=>{let a=(0,fi.c)(9),o,s;a[0]===e?(o=a[1],s=a[2]):({className:o,...s}=e,a[0]=e,a[1]=o,a[2]=s);let c;a[3]===o?c=a[4]:(c=Pr("text-sm font-semibold",o),a[3]=o,a[4]=c);let p;return a[5]!==s||a[6]!==n||a[7]!==c?(p=(0,N.jsx)(M0,{ref:n,className:c,...s}),a[5]=s,a[6]=n,a[7]=c,a[8]=p):p=a[8],p}),_m.displayName=M0.displayName,wm=_e.forwardRef((e,n)=>{let a=(0,fi.c)(9),o,s;a[0]===e?(o=a[1],s=a[2]):({className:o,...s}=e,a[0]=e,a[1]=o,a[2]=s);let c;a[3]===o?c=a[4]:(c=Pr("text-sm opacity-90",o),a[3]=o,a[4]=c);let p;return a[5]!==s||a[6]!==n||a[7]!==c?(p=(0,N.jsx)(D0,{ref:n,className:c,...s}),a[5]=s,a[6]=n,a[7]=c,a[8]=p):p=a[8],p}),wm.displayName=D0.displayName;var V1=!1;function yT(e){var o;let n=[],a=[e.console].filter(Boolean).flat();for(let s of a){let c=s.mimetype==="text/plain",p=s.mimetype==="text/html"||s.mimetype==="application/vnd.marimo+traceback";if(c||p){let d=s.channel==="stderr"||s.channel==="marimo-error";switch(s.channel){case"stdout":case"stderr":case"marimo-error":{let m=S8.asString(s.data),b=p?vd(m):m;n.push({timestamp:s.timestamp||Date.now(),level:d?"stderr":"stdout",message:b,cellId:e.cell_id});break}default:break}}}if(n.forEach(H1.log),a.length===0&&hd((o=e.output)==null?void 0:o.mimetype)&&Array.isArray(e.output.data)){e.output.data.forEach(c=>{H1.log({level:"stderr",cellId:e.cell_id,timestamp:e.timestamp??0,message:JSON.stringify(c)})});let s=e.output.data.filter(c=>"type"in c&&c.type==="exception"||c.type==="internal");if(s.length>0&&!V1){V1=!0;let c=s.find(p=>p.traceback);El(c?{title:"An internal error occurred",description:c.msg||"Click 'View' to see traceback",variant:"danger",action:_e.createElement(B1,{altText:"View traceback",onClick:()=>{Be.set(Gh,{traceback:c.traceback,errorMessage:c.msg||"An internal error occurred"})}},"View")}:{title:"An internal error occurred",description:"See console for details.",variant:"danger"})}}return n}var H1={log:e=>{let n=e.level==="stdout"?"gray":e.level==="stderr"?"red":"orange",a=e.level.toUpperCase();console.log(`%c[${a}]`,`color:${n}; padding:2px 0; border-radius:2px; font-weight:bold`,`[${sm(e.timestamp)}]`,`(${e.cellId}) ${e.message}`)}};sm=function(e){try{return dT(e).toLocaleTimeString(void 0,{hour12:!0,hour:"numeric",minute:"numeric",second:"numeric"})}catch{return""}},q_=function(e,n){let a=id(n);a?a.focus():be.warn(`[CellFocusManager] focusCellEditor: element not found: ${n}`)},d_=function(e){let n=document.getElementById(En.create(e));n?If(n):be.warn(`[CellFocusManager] focusCell: element not found: ${e}`)},c_=function(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})},vm=function(){return document.activeElement instanceof HTMLElement&&document.activeElement.classList.contains("marimo-cell")};function If(e){try{e.focus()}catch{be.warn("[CellFocusManager] element may not be focusable",e)}}gm=function(e,n){let{retries:a,delay:o,initialDelay:s=0}=n,c=0,p=()=>{if(c<a){try{if(e())return}catch(d){be.error(`Error executing function on attempt ${c+1}, retrying`,{error:d})}c++,setTimeout(p,o)}};s>0?setTimeout(p,s):p()};function ks({cellId:e,cell:n,isCodeHidden:a,codeFocus:o,variableName:s}){var p;if(!n)return;let c=document.getElementById(En.create(e));if(!c){be.warn("scrollCellIntoView: element not found");return}if(vm()){If(c);return}if(a)If(c);else{let d=(p=n.current)==null?void 0:p.editorView;if(!d){be.warn("scrollCellIntoView: editor not found",e);return}if(d.hasFocus||!document.hasFocus())return;if(gm(()=>(d.focus(),d.hasFocus),{retries:5,delay:20}),o==="top")d.dispatch({selection:{anchor:0,head:0}});else if(o==="bottom"){let m=d.state.doc.line(d.state.doc.lines);d.dispatch({selection:{anchor:m.from,head:m.from}})}else s&&pd(d,s)}c.scrollIntoView({behavior:"smooth",block:"nearest"})}Wx=function(e){let n=document.getElementById(En.create(e));if(!n){be.warn("scrollCellIntoView: element not found");return}n.classList.add("focus-outline"),setTimeout(()=>{n.classList.remove("focus-outline")},2e3),n.scrollIntoView({behavior:"smooth",block:"center"})};function vT(){let e=document.getElementById("App");e==null||e.scrollTo({top:e.scrollHeight,behavior:"smooth"})}function bT(){var e;(e=document.getElementById("App"))==null||e.scrollTo({top:0,behavior:"smooth"})}Yw=function(e){let n=id(e);if(n!=null&&n.hasFocus){by(n,{behavior:"instant"});return}let a=document.getElementById(En.create(e));a?a.scrollIntoView({behavior:"instant",block:"nearest"}):be.warn(`[CellFocusManager] scrollCellIntoView: element not found: ${e}`)},rr=function({id:e,name:n="_",code:a="",lastCodeRun:o=null,lastExecutionTime:s=null,edited:c=!1,config:p,serializedEditorState:d=null}){return{id:e,config:p||{hide_code:!1,disabled:!1,column:null},name:n,code:a,edited:c,lastCodeRun:o,lastExecutionTime:s,serializedEditorState:d}};function wT(e){return{hide_code:!1,disabled:!1,column:null,...e}}ar=function(e){return{outline:null,output:null,consoleOutputs:[],status:"idle",staleInputs:!1,interrupted:!1,errored:!1,stopped:!1,runElapsedTimeMs:null,runStartTimestamp:null,lastRunStartTimestamp:null,debuggerActive:!1,...e}};var uc=er();function $1(e){let n={column:0,hide_code:!1,disabled:!1};return{...e,cellData:{[ls]:rr({id:ls,config:n}),...e.cellData},cellRuntime:{[ls]:ar(),...e.cellRuntime},cellHandles:{[ls]:(0,_e.createRef)(),...e.cellHandles}}}function _T(){return $1({cellIds:Dl.from([]),cellData:{},cellRuntime:{},cellHandles:{},history:[],scrollKey:null,cellLogs:[],untouchedNewCells:new Set})}let xT,W1,kT,U1;({reducer:xT,addMiddleware:W1,createActions:kT,useActions:U1,valueAtom:Ye}=Cl(_T,{createNewCell:(e,n)=>{var L;let{cellId:a,before:o,code:s,lastCodeRun:c=null,lastExecutionTime:p=null,autoFocus:d=!0,skipIfCodeExists:m=!1,hideCode:b=!1}=n,_,k;if(m){for(let P of e.cellIds.inOrderIds)if(((L=e.cellData[P])==null?void 0:L.code)===s)return e}if(a==="__end__"){let P=e.cellIds.atOrThrow(0);_=P.id,k=P.length}else if(typeof a=="string"){let P=e.cellIds.findWithId(a);_=P.id,k=P.topLevelIds.indexOf(a)}else if(a.type==="__end__"){let P=e.cellIds.get(a.columnId)||e.cellIds.atOrThrow(0);_=P.id,k=P.length}else throw Error("Invalid cellId");let S=n.newCellId||Ya.create(),E=o?k:k+1;return{...e,cellIds:e.cellIds.insertId(S,_,E),cellData:{...e.cellData,[S]:rr({id:S,code:s,lastCodeRun:c,config:wT({hide_code:b}),lastExecutionTime:p,edited:!!s&&s!==c})},cellRuntime:{...e.cellRuntime,[S]:ar()},cellHandles:{...e.cellHandles,[S]:(0,_e.createRef)()},scrollKey:d?S:null,untouchedNewCells:b&&!s?new Set([...e.untouchedNewCells,S]):e.untouchedNewCells}},moveCell:(e,n)=>{let{cellId:a,before:o,direction:s}=n;if(o!==void 0&&s!==void 0&&be.warn("Both before and direction specified for moveCell. Ignoring one."),s){let d=e.cellIds.findWithId(a),m=e.cellIds.indexOf(d),b=s==="left"?m-1:m+1,_=e.cellIds.at(b);return _?{...e,cellIds:e.cellIds.moveAcrossColumns(d.id,a,_.id,void 0),scrollKey:a}:e}let c=e.cellIds.findWithId(a),p=c.indexOfOrThrow(a);return o&&p===0?{...e,cellIds:e.cellIds.moveWithinColumn(c.id,p,0),scrollKey:a}:!o&&p===c.length-1?{...e,cellIds:e.cellIds.moveWithinColumn(c.id,p,c.length-1),scrollKey:a}:o?{...e,cellIds:e.cellIds.moveWithinColumn(c.id,p,p-1),scrollKey:a}:{...e,cellIds:e.cellIds.moveWithinColumn(c.id,p,p+1),scrollKey:a}},dropCellOverCell:(e,n)=>{let{cellId:a,overCellId:o}=n,s=e.cellIds.findWithId(a),c=e.cellIds.findWithId(o),p=s.indexOfOrThrow(a),d=c.indexOfOrThrow(o);return s.id===c.id?p===d?e:{...e,cellIds:e.cellIds.moveWithinColumn(s.id,p,d),scrollKey:null}:{...e,cellIds:e.cellIds.moveAcrossColumns(s.id,a,c.id,o),scrollKey:null}},dropCellOverColumn:(e,n)=>{let{cellId:a,columnId:o}=n,s=e.cellIds.findWithId(a);return{...e,cellIds:e.cellIds.moveAcrossColumns(s.id,a,o,void 0)}},dropOverNewColumn:(e,n)=>{let{cellId:a}=n;return{...e,cellIds:e.cellIds.moveToNewColumn(a)}},moveColumn:(e,n)=>n.column===n.overColumn?e:{...e,cellIds:e.cellIds.moveColumn(n.column,n.overColumn)},focusCell:(e,n)=>{let a=e.cellIds.findWithId(n.cellId);if(a.length===0)return e;let{cellId:o,where:s}=n,c=a.indexOfOrThrow(o),p;p=s==="before"?Bh(c-1,0,a.length-1):s==="after"?Bh(c+1,0,a.length-1):c;let d=a.atOrThrow(p);return ks({cellId:d,cell:e.cellHandles[d],isCodeHidden:Cs(e,d),codeFocus:s==="after"?"top":"bottom",variableName:void 0}),e},focusTopCell:e=>{let n=e.cellIds.getColumns().at(0);if(n===void 0||n.length===0)return e;let a=n.first();return ks({cellId:a,cell:e.cellHandles[a],isCodeHidden:Cs(e,a),codeFocus:void 0,variableName:void 0}),bT(),e},focusBottomCell:e=>{let n=e.cellIds.getColumns().at(-1);if(n===void 0||n.length===0)return e;let a=n.last();return ks({cellId:a,cell:e.cellHandles[a],isCodeHidden:Cs(e,a),codeFocus:void 0,variableName:void 0}),vT(),e},sendToTop:(e,n)=>{let a=e.cellIds.findWithId(n.cellId);if(a.length===0)return e;let{cellId:o,scroll:s=!0}=n,c=a.indexOfOrThrow(o);return c===0?e:{...e,cellIds:e.cellIds.moveWithinColumn(a.id,c,0),scrollKey:s?o:null}},sendToBottom:(e,n)=>{let a=e.cellIds.findWithId(n.cellId);if(a.length===0)return e;let{cellId:o,scroll:s=!0}=n,c=a.indexOfOrThrow(o),p=a.length-1;return c===p?e:{...e,cellIds:e.cellIds.moveWithinColumn(a.id,c,p),scrollKey:s?o:null}},addColumn:(e,n)=>{let a=Ya.create();return{...e,cellIds:e.cellIds.addColumn(n.columnId,[a]),cellData:{...e.cellData,[a]:rr({id:a})},cellRuntime:{...e.cellRuntime,[a]:ar()},cellHandles:{...e.cellHandles,[a]:(0,_e.createRef)()},scrollKey:a}},addColumnBreakpoint:(e,n)=>{let{cellId:a}=n;return e.cellIds.getColumns()[0].inOrderIds[0]===a?e:{...e,cellIds:e.cellIds.insertBreakpoint(a)}},deleteColumn:(e,n)=>{let{columnId:a}=n;return{...e,cellIds:e.cellIds.delete(a)}},mergeAllColumns:e=>({...e,cellIds:e.cellIds.mergeAllColumns()}),compactColumns:e=>({...e,cellIds:e.cellIds.compact()}),deleteCell:(e,n)=>{var b,_;let a=n.cellId;if(e.cellIds.hasOnlyOneId())return e;let o;try{o=e.cellIds.findWithId(a)}catch(k){return be.warn("Skipping delete for missing cellId",{cellId:a,error:k}),e}let s=o.indexOfOrThrow(a),c=s===0?1:s-1,p=null;o.length>1&&(p=o.atOrThrow(c));let d=(_=(b=e.cellHandles[a].current)==null?void 0:b.editorView)==null?void 0:_.state.toJSON({history:m8});d&&(d.doc=e.cellData[a].code),ET(a);let m=e.cellData[a];return{...e,cellIds:e.cellIds.deleteById(a),history:[...e.history,{name:m.name,serializedEditorState:d,column:o.id,index:s,isSetupCell:a===Vn,config:m.config}],scrollKey:p}},undoDeleteCell:e=>{if(e.history.length===0)return e;let{name:n,serializedEditorState:a={doc:""},column:o,index:s,isSetupCell:c,config:p}=e.history[e.history.length-1],d=c?Vn:Ya.create(),m=rr({id:d,name:n,code:a.doc,edited:a.doc.trim().length>0,serializedEditorState:a,config:p});return{...e,cellIds:e.cellIds.insertId(d,o,s),cellData:{...e.cellData,[d]:m},cellRuntime:{...e.cellRuntime,[d]:ar()},cellHandles:{...e.cellHandles,[d]:(0,_e.createRef)()},history:e.history.slice(0,-1),scrollKey:d}},clearSerializedEditorState:(e,n)=>{let{cellId:a}=n;return go({state:e,cellId:a,cellReducer:o=>({...o,serializedEditorState:null})})},updateCellCode:(e,n)=>{let{cellId:a,code:o,formattingChange:s}=n;return e.cellData[a]?go({state:e,cellId:a,cellReducer:c=>s?{...c,code:o,lastCodeRun:c.edited?c.lastCodeRun:o}:{...c,code:o,edited:o.trim()!==c.lastCodeRun}}):e},updateCellName:(e,n)=>{let{cellId:a,name:o}=n;return go({state:e,cellId:a,cellReducer:s=>({...s,name:o})})},updateCellConfig:(e,n)=>{let{cellId:a,config:o}=n;return go({state:e,cellId:a,cellReducer:s=>({...s,config:{...s.config,...o}})})},prepareForRun:(e,n)=>go({state:Ss({state:e,cellId:n.cellId,cellReducer:a=>nT(a)}),cellId:n.cellId,cellReducer:a=>({...a,edited:!1,lastCodeRun:a.code.trim()})}),handleCellMessage:(e,n)=>{let a=n.cell_id,o=Ss({state:e,cellId:a,cellReducer:s=>tT(s,n)});return n.status==="queued"&&(o=go({state:o,cellId:a,cellReducer:s=>({...s,lastCodeRun:s.code.trim(),edited:!1})})),{...o,cellLogs:[...o.cellLogs,...yT(n)]}},setCellIds:(e,n)=>{if(h6(e.cellIds.inOrderIds,n.cellIds))return e;let a={...e.cellData},o={...e.cellRuntime},s={...e.cellHandles};for(let c of n.cellIds)c in e.cellData||(a[c]=rr({id:c})),c in e.cellRuntime||(o[c]=ar()),c in e.cellHandles||(s[c]=(0,_e.createRef)());return{...e,cellIds:Dl.fromWithPreviousShape(n.cellIds,e.cellIds),cellData:a,cellRuntime:o,cellHandles:s}},setCellCodes:(e,n)=>{var s,c;rn(n.codes.length===n.ids.length,"Expected codes and ids to have the same length");let a={...e},o=({cell:p,code:d,cellId:m,name:b,config:_})=>{if(!p)return rr({id:m,code:d,name:b,config:_,lastCodeRun:n.codeIsStale?null:d,edited:n.codeIsStale&&d.trim().length>0});let k=n.codeIsStale?p.lastCodeRun:d,S=k?k.trim()!==d.trim():!!d;if(p.code.trim()===d.trim())return{...p,code:d,edited:S,lastCodeRun:k,...b!==void 0&&{name:b},..._!==void 0&&{config:_}};if(!Rm()){let E=a.cellHandles[m].current;E!=null&&E.editorViewOrNull&&Ji(E.editorViewOrNull,d)}return{...p,code:d,edited:S,lastCodeRun:k,...b!==void 0&&{name:b},..._!==void 0&&{config:_}}};for(let p=0;p<n.ids.length;p++){let d=n.ids[p],m=n.codes[p];if(d===void 0||m===void 0)continue;let b=(s=n.names)==null?void 0:s[p],_=(c=n.configs)==null?void 0:c[p];a={...a,cellData:{...a.cellData,[d]:o({cell:a.cellData[d],code:m,cellId:d,name:b,config:_})}}}return a},setStdinResponse:(e,n)=>{let{cellId:a,response:o,outputIndex:s}=n;return Ss({state:e,cellId:a,cellReducer:c=>{let p=[...c.consoleOutputs],d=p[s];return d==null||d.channel!=="stdin"?(be.warn("Expected stdin output"),c):(p[s]={channel:"stdin",mimetype:d.mimetype,data:d.data,timestamp:d.timestamp,response:o},{...c,interrupted:!1,consoleOutputs:p})}})},setCells:(e,n)=>{let a=Object.fromEntries(n.map(s=>[s.id,s])),o=Object.fromEntries(n.map(s=>[s.id,ar()]));return $1({...e,cellIds:Dl.fromIdsAndColumns(n.map(s=>[s.id,s.config.column])),cellData:a,cellRuntime:o,cellHandles:Object.fromEntries(n.map(s=>[s.id,(0,_e.createRef)()]))})},moveToNextCell:(e,n)=>{let{cellId:a,before:o,noCreate:s=!1}=n;if(a==="__scratch__")return e;let c=e.cellIds.findWithId(a),p=c.indexOfOrThrow(a),d=o?p-1:p+1,m=d===c.length,b=d===-1;if(m&&!s){let _=Ya.create();return{...e,cellIds:e.cellIds.insertId(_,c.id,d),cellData:{...e.cellData,[_]:rr({id:_})},cellRuntime:{...e.cellRuntime,[_]:ar()},cellHandles:{...e.cellHandles,[_]:(0,_e.createRef)()},scrollKey:_}}if(b&&!s){let _=Ya.create();return{...e,cellIds:e.cellIds.insertId(_,c.id,0),cellData:{...e.cellData,[_]:rr({id:_})},cellRuntime:{...e.cellRuntime,[_]:ar()},cellHandles:{...e.cellHandles,[_]:(0,_e.createRef)()},scrollKey:_}}if((m||b)&&s)return e;if(d>=0&&d<c.length){let _=c.atOrThrow(d);ks({cellId:_,cell:e.cellHandles[_],isCodeHidden:Cs(e,_),codeFocus:o?"bottom":"top",variableName:void 0})}return e},markTouched:(e,n)=>{let{cellId:a}=n;if(e.untouchedNewCells.has(a)){let o=new Set(e.untouchedNewCells);return o.delete(a),{...e,untouchedNewCells:o}}return e},markUntouched:(e,n)=>{let{cellId:a}=n;if(!e.untouchedNewCells.has(a)){let o=new Set(e.untouchedNewCells);return o.add(a),{...e,untouchedNewCells:o}}return e},scrollToTarget:e=>{let n=e.scrollKey;if(n===null)return e;let a=e.cellIds.findWithId(n),o=a.indexOfOrThrow(n),s=o===a.length-1?a.last():a.atOrThrow(o);return ks({cellId:s,cell:e.cellHandles[s],isCodeHidden:Cs(e,s),codeFocus:void 0,variableName:void 0}),{...e,scrollKey:null}},foldAll:e=>(Mk(Object.values(e.cellHandles).map(n=>{var a;return(a=n.current)==null?void 0:a.editorView})),e),unfoldAll:e=>(Dk(Object.values(e.cellHandles).map(n=>{var a;return(a=n.current)==null?void 0:a.editorView})),e),clearLogs:e=>({...e,cellLogs:[]}),collapseCell:(e,n)=>{let{cellId:a}=n,o=e.cellIds.findWithId(a),s=o.topLevelIds.map(d=>e.cellRuntime[d].outline),c=P1(o.indexOfOrThrow(a),s);if(!c)return e;let p=o.atOrThrow(c[1]);return{...e,cellIds:e.cellIds.transformWithCellId(a,d=>d.collapse(a,p)),scrollKey:a}},expandCell:(e,n)=>{let{cellId:a}=n;return{...e,cellIds:e.cellIds.transformWithCellId(a,o=>o.expand(a)),scrollKey:a}},collapseAllCells:e=>({...e,cellIds:e.cellIds.transformAll(n=>{let a=n.topLevelIds.map(m=>e.cellRuntime[m].outline),o=[...n.nodes],s=[],c=[],p=o.length-1;for(;p>=0;){let m=P1(p,a);if(m){let b=p,_=m[1],k=s.find(L=>L.start<=_&&L.end===_);k&&(_=k.start),s.push({start:b,end:_});let S=n.atOrThrow(b),E=n.atOrThrow(_);c.push({id:S,until:E})}else c.push(null);p--}let d=c.toReversed();return n.collapseAll(d)})}),expandAllCells:e=>({...e,cellIds:e.cellIds.transformAll(n=>n.expandAll())}),showCellIfHidden:(e,n)=>{let{cellId:a}=n,o=e.cellIds.findWithId(a),s=o,c=o.findAndExpandDeep(a);return c.equals(s)?e:{...e,cellIds:e.cellIds.transformWithCellId(a,()=>c)}},splitCell:(e,n)=>{var _;let{cellId:a}=n,o=e.cellIds.findWithId(a),s=o.indexOfOrThrow(a),c=e.cellData[a],p=e.cellHandles[a].current;if((p==null?void 0:p.editorView)==null)return e;let{beforeCursorCode:d,afterCursorCode:m}=U4(p.editorView);Ji(p.editorView,d);let b=Ya.create();return{...e,cellIds:e.cellIds.insertId(b,o.id,s+1),cellData:{...e.cellData,[a]:{...c,code:d,edited:!!d&&d.trim()!==((_=c.lastCodeRun)==null?void 0:_.trim())},[b]:rr({id:b,code:m,edited:!!m})},cellRuntime:{...e.cellRuntime,[a]:{...e.cellRuntime[a],output:null,consoleOutputs:[]},[b]:ar()},cellHandles:{...e.cellHandles,[b]:(0,_e.createRef)()},scrollKey:b}},undoSplitCell:(e,n)=>{var p;let{cellId:a,snapshot:o}=n,s=e.cellData[a],c=e.cellHandles[a].current;return(c==null?void 0:c.editorView)==null?e:(Ji(c.editorView,o),{...e,cellIds:e.cellIds.transformWithCellId(a,d=>{let m=d.indexOfOrThrow(a)+1;return d.deleteAtIndex(m)}),cellData:{...e.cellData,[a]:{...s,code:o,edited:!!o&&(o==null?void 0:o.trim())!==((p=s.lastCodeRun)==null?void 0:p.trim())}},cellRuntime:{...e.cellRuntime,[a]:{...e.cellRuntime[a],output:null,consoleOutputs:[]}},cellHandles:{...e.cellHandles}})},clearCellOutput:(e,n)=>{let{cellId:a}=n;return Ss({state:e,cellId:a,cellReducer:o=>({...o,output:null,consoleOutputs:[]})})},clearCellConsoleOutput:(e,n)=>{let{cellId:a}=n;return Ss({state:e,cellId:a,cellReducer:o=>({...o,consoleOutputs:o.consoleOutputs.filter(s=>s.channel==="stdin"&&s.response==null)})})},clearAllCellOutputs:e=>{let n={...e.cellRuntime};for(let a of e.cellIds.inOrderIds)n[a]={...n[a],output:null,consoleOutputs:[]};return{...e,cellRuntime:n}},addSetupCellIfDoesntExist:(e,n)=>{let{code:a}=n;return e.cellIds.setupCellExists()?{...e,scrollKey:Vn}:{...e,cellIds:e.cellIds.insertId(Vn,e.cellIds.atOrThrow(0).id,0),cellData:{...e.cellData,[Vn]:rr({id:Vn,name:Vn,code:a,edited:!!a})},cellRuntime:{...e.cellRuntime,[Vn]:ar()},cellHandles:{...e.cellHandles,[Vn]:(0,_e.createRef)()},scrollKey:Vn}}})),W1(uT);function Cs(e,n){return!!e.cellData[n].config.hide_code&&!e.untouchedNewCells.has(n)}function Ss({state:e,cellId:n,cellReducer:a}){return n in e.cellRuntime?{...e,cellRuntime:{...e.cellRuntime,[n]:a(e.cellRuntime[n])}}:(be.warn(`Cell ${n} not found in state`),e)}function go({state:e,cellId:n,cellReducer:a}){return n in e.cellData?{...e,cellData:{...e.cellData,[n]:a(e.cellData[n])}}:(be.warn(`Cell ${n} not found in state`),e)}Z_=function(e){let n=e.cellData,a={column:null};return e.cellIds.getColumns().length>1?e.cellIds.getColumns().flatMap((o,s)=>o.inOrderIds.map((c,p)=>{let d={...a};return p===0&&(d.column=s),{...n[c].config,...d}})):e.cellIds.getColumns().flatMap(o=>o.inOrderIds.map(s=>({...n[s].config,...a})))},rd=Te(e=>e(Ye).cellIds),Nx=Te(e=>e(rd).hasOnlyOneId()),W_=Te(e=>pm(e(Ye)).length>0),Te(e=>o0(e(Ye)).length>0);let K1;Ox=Te(e=>gC(e(Ye))),$x=Te(e=>hC(e(Ye))),ld=Te(e=>{let{cellIds:n,cellRuntime:a,cellData:o}=e(Ye);return n.inOrderIds.map(s=>{var d;let c=a[s],{name:p}=o[s];if(hd((d=c.output)==null?void 0:d.mimetype)){rn(Array.isArray(c.output.data),"Expected array data");let m=c.output.data.filter(b=>!b.type.includes("ancestor"));if(m.length>0)return{output:{...c.output,data:m},cellId:s,cellName:p}}return null}).filter(Boolean)}),N_=Te(e=>{let{cellIds:n,cellRuntime:a}=e(Ye);return J4(n.inOrderIds.map(o=>a[o].outline))}),Sx=Te(e=>e(ld).length),K1=p6(Te(e=>{let{cellIds:n,cellData:a}=e(Ye);return Rr.fromEntries(n.inOrderIds.map(o=>{var s;return[o,(s=a[o])==null?void 0:s.name]}))}));var CT=Te(e=>e(Ye).scrollKey);l_=()=>Sn(Ye),dx=()=>Sn(rd),x_=()=>Sn(K1),px=()=>Sn(ld),b_=()=>Sn(Ye).cellLogs,h_=()=>Sn(CT),sd=()=>Be.get(Ye),yx=()=>Be.get(Ye).cellIds,xx=()=>{let{cellIds:e,cellData:n}=Be.get(Ye);return e.inOrderIds.map(a=>{var o;return(o=n[a])==null?void 0:o.name}).filter(Boolean)};var ST=Ik(kk(Ye,e=>e.cellIds.inOrderIds.map(n=>e.cellData[n])));T_=()=>fw(ST),bx=Te(e=>e(Ye).cellRuntime),Bx=Te(e=>fC(e(Ye))),D_=Te(e=>{let{cellRuntime:n}=e(Ye);return Object.entries(n).every(([a,o])=>o.status!=="running"||a==="__scratch__")}),n_=Te(e=>pC(e(Ye))),Dx=Te(e=>e(Ye).cellIds.colLength),ix=Te(e=>e(Ye).cellIds.idLength>0),Tx=Te(e=>e(Ye).cellIds.getColumnIds()),md=Nd(e=>Te(n=>n(Ye).cellData[e]));var Lf=Nd(e=>Te(n=>n(Ye).cellRuntime[e]));const Q1=Nd(e=>Te(n=>n(Ye).cellHandles[e]));function ET(e){md.remove(e),Lf.remove(e),Q1.remove(e)}a_=e=>{let n=(0,uc.c)(2),a;return n[0]===e?a=n[1]:(a=md(e),n[0]=e,n[1]=a),Sn(a)},O_=e=>{let n=(0,uc.c)(2),a;return n[0]===e?a=n[1]:(a=Lf(e),n[0]=e,n[1]=a),Sn(a)},Gw=e=>{let n=(0,uc.c)(2),a;return n[0]===e?a=n[1]:(a=Q1(e),n[0]=e,n[1]=a),Sn(a)},t0=()=>{let{cellIds:e,cellHandles:n}=Be.get(Ye);return e.inOrderIds.map(a=>{var o,s;return(s=(o=n[a])==null?void 0:o.current)==null?void 0:s.editorViewOrNull}).filter(Boolean)},id=e=>{var a;let{cellHandles:n}=Be.get(Ye);return(a=n[e].current)==null?void 0:a.editorView},gx=function(e){let{cellIds:n,cellData:a,cellRuntime:o}=e;return n.getColumns().flatMap(s=>s.topLevelIds.map(c=>({...a[c],...o[c]})))},J_=function(e){return Te(n=>n(Ye).untouchedNewCells.has(e))};function TT(e){let n=Lf(e);return Te(a=>{let o=a(n);if(!o||o.status==="queued"||o.status==="running")return;let s=[],c=o.consoleOutputs;if(c&&c.length>0){let d=c.find(m=>m.mimetype==="application/vnd.marimo+traceback");if(d){let m=d.data;s.push(...Zm(m))}}let p=o.output;if((p==null?void 0:p.mimetype)==="application/vnd.marimo+error"){let d=p.data;if(Array.isArray(d))for(let m of d)m.type==="syntax"&&m.lineno!=null&&s.push({kind:"cell",cellId:e,lineNumber:m.lineno}),m.type==="import-star"&&m.lineno!=null&&s.push({kind:"cell",cellId:e,lineNumber:m.lineno})}return s.length>0?s:void 0})}s_=function(e){let n=(0,uc.c)(2),a;return n[0]===e?a=n[1]:(a=e===void 0?{}:e,n[0]=e,n[1]=a),U1(a)}})();export{Gh as $,Jh as $n,Xa as $r,Xh as $t,Gw as A,Yh as Ai,Zh as An,Jw as Ar,Xw as At,Yw as B,Zw as Bn,e_ as Br,t_ as Bt,n_ as C,Ya as Ci,em as Cn,r_ as Cr,Bn as Ct,a_ as D,Vn as Di,i_ as Dn,o_ as Dr,tm as Dt,s_ as E,ls as Ei,Tl as En,Fu as Er,Bu as Et,l_ as F,Vu as Fi,Za as Fn,Ki as Fr,nm as Ft,c_ as G,Hu as Gn,u_ as Gr,rm as Gt,d_ as H,$u as Hn,f_ as Hr,p_ as Ht,h_ as I,Wu as Ii,m_ as In,ot as Ir,am as It,im as J,g_ as Jn,om as Jr,Uu as Jt,sm as K,y_ as Kn,Qi as Kr,v_ as Kt,rr as L,Il as Ln,ua as Lr,Ll as Lt,b_ as M,lm as Mi,Ku as Mn,w_ as Mr,__ as Mt,x_ as N,k_ as Ni,C_ as Nn,S_ as Nr,E_ as Nt,T_ as O,Qu as Oi,I_ as On,L_ as Or,cm as Ot,O_ as P,A_ as Pi,R_ as Pn,da as Pr,P_ as Pt,um as Q,dm as Qn,Ol as Qr,fm as Qt,ar as R,Gu as Rn,pm as Rr,Hn as Rt,N_ as S,hm as Si,Ju as Sn,Gi as Sr,M_ as St,D_ as T,En as Ti,j_ as Tn,z_ as Tr,Xu as Tt,q_ as U,Al as Un,mm as Ur,F_ as Ut,gm as V,Yu as Vn,ym as Vr,B_ as Vt,vm as W,V_ as Wn,Zu as Wr,bm as Wt,H_ as X,$_ as Xn,Rl as Xr,ed as Xt,wm as Y,td as Yn,Pl as Yr,Nr as Yt,_m as Z,Nl as Zn,cs as Zr,nd as Zt,W_ as _,J8 as __tla,Ml as _i,U_ as _n,xm as _r,km as _t,rd as a,Dl as ai,K_ as an,Cm as ar,Sm as at,Ye as b,Q_ as bi,ad as bn,G_ as br,Ji as bt,J_ as c,X_ as ci,fa as cn,Em as cr,Y_ as ct,Z_ as d,ex as di,tx as dn,Tm as dr,Im as dt,nx as ei,Lm as en,Xi as er,rx as et,id as f,ax as fi,Om as fn,Am as fr,Rm as ft,ix as g,ox as gi,od as gn,Pm as gr,Nm as gt,sd as h,mn as hi,sx as hn,Mm as hr,lx as ht,ld as i,ei as ii,cx as in,Dm as ir,ux as it,dx as j,fx as ji,jm as jn,jl as jr,cd as jt,px as k,hx as ki,ud as kn,mx as kr,zm as kt,gx as l,dd as li,zl as ln,fd as lr,qm as lt,yx as m,vx as mi,pd as mn,Fm as mr,hd as mt,md as n,Bm as ni,Vm as nn,Hm as nr,$m as nt,bx as o,wx as oi,_x as on,Yi as or,Wm as ot,xx as p,us as pi,Um as pn,Km as pr,kx as pt,Qm as q,ti as qn,gd as qr,Cx as qt,Sx as r,Gm as ri,Jm as rn,Xm as rr,Ex as rt,Tx as s,Ym as si,Ix as sn,yd as sr,Lx as st,Ox as t,Zm as ti,Ax as tn,e0 as tr,vd as tt,t0 as u,ds as ui,Rx as un,fs as ur,Px as ut,Nx as v,ql as vi,Mx as vn,n0 as vr,r0 as vt,Dx as w,jx as wi,zx as wn,qx as wr,Fx as wt,Bx as x,Vx as xi,a0 as xn,bd as xr,Hx as xt,$x as y,wd as yi,_d as yn,i0 as yr,wr as yt,Wx as z,ni as zn,o0 as zr,xd as zt};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as P}from"./chunk-LvLJmgfZ.js";import{t as U}from"./react-Bj1aDYRI.js";import{pr as Y,sr as $}from"./cells-
|
|
1
|
+
import{s as P}from"./chunk-LvLJmgfZ.js";import{t as U}from"./react-Bj1aDYRI.js";import{pr as Y,sr as $}from"./cells-EJo3u4za.js";import{C as z,P as G,R as E,T as K}from"./zod-H_cgTO0M.js";import{t as J}from"./compiler-runtime-B3qBwwSJ.js";import{t as L}from"./isEmpty-Do0cOI51.js";import{Y as Q}from"./ai-model-dropdown-CRtaHcCu.js";import{_ as W}from"./useEventListener-DGjKht0c.js";import{t as C}from"./cn-DYvqRARy.js";import{t as X}from"./jsx-runtime-Blw4afVn.js";import{a as D,i as I,n as V,r as B}from"./multi-map-MSuUqmbC.js";import{i as Z}from"./strings-pfr2N700.js";import{t as ee}from"./bot-message-square-BbnE8Q1J.js";import{t as H}from"./markdown-renderer-B9RsGqHb.js";import{l as te}from"./add-cell-with-ai-CLklC7KS.js";import{n as se}from"./spinner-C5wIpWgQ.js";import{c as ae}from"./datasource-DY0N42ZB.js";import{t as re}from"./RenderHTML-0dk6-mYI.js";var le=J(),ne=P(U(),1),t=P(X(),1);const oe=n=>{let e=(0,le.c)(13),{reasoning:a,index:l,isStreaming:s}=n,r=l===void 0?0:l,m=s===void 0?!1:s,o=m?"reasoning":void 0,x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=(0,t.jsx)(ee,{className:"h-3 w-3"}),e[0]=x):x=e[0];let p=m?"Thinking":"View reasoning",c;e[1]!==a.length||e[2]!==p?(c=(0,t.jsx)(D,{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,t.jsxs)("span",{className:"flex items-center gap-2",children:[x,p," (",a.length," ","chars)"]})}),e[1]=a.length,e[2]=p,e[3]=c):c=e[3];let i;e[4]===a?i=e[5]:(i=(0,t.jsx)(B,{className:"pb-2 px-2",children:(0,t.jsx)("div",{className:"bg-muted/30 border border-muted/50 rounded-md p-3 italic text-muted-foreground/90 relative",children:(0,t.jsx)("div",{className:"pr-6",children:(0,t.jsx)(H,{content:a})})})}),e[4]=a,e[5]=i);let d;e[6]!==c||e[7]!==i?(d=(0,t.jsxs)(I,{value:"reasoning",className:"border-0",children:[c,i]}),e[6]=c,e[7]=i,e[8]=d):d=e[8];let u;return e[9]!==r||e[10]!==o||e[11]!==d?(u=(0,t.jsx)(V,{type:"single",collapsible:!0,className:"w-full mb-2",value:o,children:d},r),e[9]=r,e[10]=o,e[11]=d,e[12]=u):u=e[12],u};var T=J(),ie=G({status:E().default("success"),auth_required:K().default(!1),action_url:z(),next_steps:z(),meta:z(),message:E().nullish()}).passthrough(),de=n=>{let e=(0,T.c)(12),{data:a}=n,l;if(e[0]!==a){let{status:s,auth_required:r,action_url:m,meta:o,next_steps:x,message:p,...c}=a,i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsx)("h3",{className:"text-xs font-semibold text-muted-foreground",children:"Tool Result"}),e[2]=i):i=e[2];let d;e[3]===s?d=e[4]:(d=(0,t.jsx)("span",{className:"text-xs px-2 py-0.5 bg-[var(--grass-2)] text-[var(--grass-11)] rounded-full font-medium capitalize",children:s}),e[3]=s,e[4]=d);let u;e[5]===r?u=e[6]:(u=r&&(0,t.jsx)("span",{className:"text-xs px-2 py-0.5 bg-[var(--amber-2)] text-[var(--amber-11)] rounded-full",children:"Auth Required"}),e[5]=r,e[6]=u);let h;e[7]!==d||e[8]!==u?(h=(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[i,(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[d,u]})]}),e[7]=d,e[8]=u,e[9]=h):h=e[9];let f;e[10]===p?f=e[11]:(f=p&&(0,t.jsxs)("div",{className:"flex items-start gap-2",children:[(0,t.jsx)($,{className:"h-3 w-3 text-[var(--blue-11)] mt-0.5 flex-shrink-0"}),(0,t.jsx)("div",{className:"text-xs text-foreground",children:p})]}),e[10]=p,e[11]=f),l=(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[h,f,c&&(0,t.jsx)("div",{className:"space-y-3",children:Object.entries(c).map(xe)})]}),e[0]=a,e[1]=l}else l=e[1];return l},ce=n=>{let e=(0,T.c)(8),{result:a}=n,l;e[0]===a?l=e[1]:(l=ie.safeParse(a),e[0]=a,e[1]=l);let s=l;if(s.success){let o;return e[2]===s.data?o=e[3]:(o=(0,t.jsx)(de,{data:s.data}),e[2]=s.data,e[3]=o),o}let r;e[4]===a?r=e[5]:(r=typeof a=="string"?a:JSON.stringify(a,null,2),e[4]=a,e[5]=r);let m;return e[6]===r?m=e[7]:(m=(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground mb-1 max-h-64 overflow-y-auto scrollbar-thin",children:r}),e[6]=r,e[7]=m),m},me=n=>{let e=(0,T.c)(9),{input:a}=n;if(!(a&&a!==null))return null;let l;e[0]===a?l=e[1]:(l=L(a),e[0]=a,e[1]=l);let s=l,r=typeof a=="object"&&!Array.isArray(a)&&Object.keys(a).length>0,m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=(0,t.jsx)("h3",{className:"text-xs font-semibold text-muted-foreground",children:"Tool Request"}),e[2]=m):m=e[2];let o;e[3]!==a||e[4]!==s||e[5]!==r?(o=s?"{}":r?JSON.stringify(a,null,2):String(a),e[3]=a,e[4]=s,e[5]=r,e[6]=o):o=e[6];let x;return e[7]===o?x=e[8]:(x=(0,t.jsxs)("div",{className:"space-y-2",children:[m,(0,t.jsx)("pre",{className:"bg-[var(--slate-2)] p-2 text-muted-foreground border border-[var(--slate-4)] rounded text-xs overflow-auto scrollbar-thin max-h-64",children:o})]}),e[7]=o,e[8]=x),x};const M=n=>{let e=(0,T.c)(38),{toolName:a,result:l,error:s,index:r,state:m,className:o,input:x}=n,p=r===void 0?0:r,c=m==="output-available"&&(l||s),i=s?"error":c?"success":"loading",d;e[0]===i?d=e[1]:(d=()=>{switch(i){case"loading":return(0,t.jsx)(se,{className:"h-3 w-3 animate-spin"});case"error":return(0,t.jsx)(Y,{className:"h-3 w-3 text-[var(--red-11)]"});case"success":return(0,t.jsx)(Q,{className:"h-3 w-3 text-[var(--grass-11)]"});default:return(0,t.jsx)(ae,{className:"h-3 w-3"})}},e[0]=i,e[1]=d);let u=d,h;e[2]!==s||e[3]!==c||e[4]!==i?(h=()=>i==="loading"?"Running":s?"Failed":c?"Done":"Tool call",e[2]=s,e[3]=c,e[4]=i,e[5]=h):h=e[5];let f=h,F=`tool-${p}`,g;e[6]===o?g=e[7]:(g=C("w-full",o),e[6]=o,e[7]=g);let A=i==="error"&&"text-[var(--red-11)]/80",k=i==="success"&&"text-[var(--grass-11)]/80",j;e[8]!==A||e[9]!==k?(j=C("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",A,k),e[8]=A,e[9]=k,e[10]=j):j=e[10];let v;e[11]===u?v=e[12]:(v=u(),e[11]=u,e[12]=v);let q=f(),b;e[13]===a?b=e[14]:(b=ue(a),e[13]=a,e[14]=b);let N;e[15]===b?N=e[16]:(N=(0,t.jsx)("code",{className:"font-mono text-xs",children:b}),e[15]=b,e[16]=N);let y;e[17]!==q||e[18]!==N||e[19]!==v?(y=(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[v,q,":",N]}),e[17]=q,e[18]=N,e[19]=v,e[20]=y):y=e[20];let w;e[21]!==y||e[22]!==j?(w=(0,t.jsx)(D,{className:j,children:y}),e[21]=y,e[22]=j,e[23]=w):w=e[23];let _;e[24]!==s||e[25]!==c||e[26]!==x||e[27]!==l?(_=c&&(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(me,{input:x}),l!=null&&(0,t.jsx)(ce,{result:l}),s&&(0,t.jsxs)("div",{className:"bg-[var(--red-2)] border border-[var(--red-6)] rounded-lg p-3",children:[(0,t.jsxs)("div",{className:"text-xs font-semibold text-[var(--red-11)] mb-2 flex items-center gap-2",children:[(0,t.jsx)("div",{className:"w-1.5 h-1.5 bg-[var(--red-9)] rounded-full"}),"Error"]}),(0,t.jsx)("div",{className:"text-sm text-[var(--red-11)] leading-relaxed",children:s})]})]}),e[24]=s,e[25]=c,e[26]=x,e[27]=l,e[28]=_):_=e[28];let S;e[29]===_?S=e[30]:(S=(0,t.jsx)(B,{className:"py-2 px-2",children:_}),e[29]=_,e[30]=S);let R;e[31]!==w||e[32]!==S?(R=(0,t.jsxs)(I,{value:"tool-call",className:"border-0",children:[w,S]}),e[31]=w,e[32]=S,e[33]=R):R=e[33];let O;return e[34]!==R||e[35]!==F||e[36]!==g?(O=(0,t.jsx)(V,{type:"single",collapsible:!0,className:g,children:R},F),e[34]=R,e[35]=F,e[36]=g,e[37]=O):O=e[37],O};function ue(n){return n.replace("tool-","")}function xe(n){let[e,a]=n;return L(a)?null:(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)("div",{className:"text-xs font-medium text-muted-foreground capitalize flex items-center gap-2",children:[(0,t.jsx)("div",{className:"w-1.5 h-1.5 bg-[var(--blue-9)] rounded-full"}),e]}),(0,t.jsx)("pre",{className:"bg-[var(--slate-2)] p-2 text-muted-foreground border border-[var(--slate-4)] rounded text-xs overflow-auto scrollbar-thin max-h-64",children:JSON.stringify(a,null,2)})]},e)}const pe=({message:n,isStreamingReasoning:e,isLast:a})=>{return(0,t.jsx)(t.Fragment,{children:n.parts.map((s,r)=>l(s,r))});function l(s,r){if(he(s))return(0,t.jsx)(M,{index:r,toolName:s.type,result:s.output,className:"my-2",state:s.state,input:s.input},r);if(fe(s))return W.debug("Found data part",s),null;switch(s.type){case"text":return s.text.includes("<marimo-")?(0,t.jsx)(ne.Fragment,{children:re({html:s.text})},r):(0,t.jsx)(H,{content:s.text},r);case"reasoning":return(0,t.jsx)(oe,{reasoning:s.text,index:r,isStreaming:e&&a&&r===(n.parts.length||0)-1},r);case"file":return(0,t.jsx)(te,{attachment:s},r);case"dynamic-tool":return(0,t.jsx)(M,{toolName:s.toolName,result:s.output,state:s.state,input:s.input},r);case"source-document":case"source-url":case"step-start":return W.debug("Found non-renderable part",s),null;default:return Z(s),null}}};function he(n){return n.type.startsWith("tool-")}function fe(n){return n.type.startsWith("data-")}export{pe as t};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{s as Ke}from"./chunk-LvLJmgfZ.js";import{d as kt,f as Lt,l as It,n as ue,u as We}from"./useEvent-D91BmmQi.js";import{t as Pt}from"./react-Bj1aDYRI.js";import{E as Dt,fr as Mt}from"./cells-CmiuS2Us.js";import"./react-dom-CSu739Rf.js";import{t as Qe}from"./compiler-runtime-B3qBwwSJ.js";import{T as zt,o as Ft,r as Ze,t as Ht,w as Ot}from"./ai-model-dropdown-DK0jvNeC.js";import{_ as _e,o as le}from"./useEventListener-DGjKht0c.js";import{n as et,r as Ut}from"./utils-8btzWeZg.js";import{o as Wt}from"./config-DoZCLcOb.js";import{t as oe}from"./cn-DYvqRARy.js";import{t as Yt}from"./jsx-runtime-Blw4afVn.js";import{C as pe,S as Xt,_ as Te,b as V,h as q,y as Vt}from"./fullscreen-k58KVlT-.js";import{u as qt}from"./menu-items-Dtw5N98_.js";import{i as Bt,r as $t,t as Gt}from"./popover-AtoFZ7i4.js";import{a as Jt,i as Kt,n as Qt,p as Zt,r as er,s as tr,t as rr}from"./select--zcABebs.js";import{i as tt,t as Ye}from"./tooltip-DmqhBBs6.js";import{t as ae}from"./button-BKVLeSTX.js";import"./dist-VwkX7yeV.js";import"./cjs-D5tzp-Y6.js";import"./main-BNL5rxQw.js";import"./useNonce-CbdaHKzX.js";import{r as lr}from"./requests-9-v2bhoi.js";import{t as rt}from"./createLucideIcon-w-Qo9n0R.js";import{t as lt}from"./bot-message-square-BbnE8Q1J.js";import"./markdown-renderer-BzPN8MW4.js";import{O as ot,S as or,T as ar,_ as nr,b as sr,c as ir,d as cr,f as dr,g as ur,h as pr,j as mr,k as hr,l as fr,m as at,n as nt,p as xr,s as vr,u as gr,v as wr,y as br}from"./add-cell-with-ai-BFWfrIDT.js";import{n as yr}from"./spinner-C5wIpWgQ.js";import{t as jr}from"./message-circle-DiHwtSG8.js";import{t as Sr}from"./plus-BYq_Btg-.js";import{dt as Cr,r as Nr}from"./input-Bg12i6qY.js";import{t as Rr}from"./settings-C1bg8A2T.js";import"./dist-BvlMLwcr.js";import"./dist-4lB-oR9j.js";import"./dist-CxquLoAZ.js";import"./dist-Dnlw22ji.js";import"./dist-CgYlATe-.js";import"./session-DdnWW30b.js";import"./purify.es-BFDc-_i_.js";import{i as Ar}from"./dates-stqTIkXD.js";import{t as _r}from"./copy-icon-BGs1Pbai.js";import{t as Tr}from"./context-DGqo1TbK.js";import{r as st,t as Er}from"./state-16EGv7AG.js";import{n as kr}from"./error-banner-bXc_9BBZ.js";import"./chunk-5FQGJX7Z-Cyc7d5AB.js";import"./html-to-image-DRz7fjt_.js";import"./esm-BqofWdD5.js";import{t as Xe}from"./empty-state-BbLVXQU7.js";import{t as Lr}from"./chat-display-QHJlAad0.js";var p=Ke(Pt(),1),o=Ke(Yt(),1);function Ir(e,t){return p.useReducer((r,n)=>t[r][n]??r,e)}var Ve="ScrollArea",[it,po]=Xt(Ve),[Pr,z]=it(Ve),ct=p.forwardRef((e,t)=>{let{__scopeScrollArea:r,type:n="hover",dir:l,scrollHideDelay:a=600,...s}=e,[i,c]=p.useState(null),[u,d]=p.useState(null),[m,h]=p.useState(null),[f,v]=p.useState(null),[j,T]=p.useState(null),[g,N]=p.useState(0),[R,y]=p.useState(0),[S,C]=p.useState(!1),[E,I]=p.useState(!1),w=le(t,k=>c(k)),_=qt(l);return(0,o.jsx)(Pr,{scope:r,type:n,dir:_,scrollHideDelay:a,scrollArea:i,viewport:u,onViewportChange:d,content:m,onContentChange:h,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:S,onScrollbarXEnabledChange:C,scrollbarY:j,onScrollbarYChange:T,scrollbarYEnabled:E,onScrollbarYEnabledChange:I,onCornerWidthChange:N,onCornerHeightChange:y,children:(0,o.jsx)(pe.div,{dir:_,...s,ref:w,style:{position:"relative","--radix-scroll-area-corner-width":g+"px","--radix-scroll-area-corner-height":R+"px",...e.style}})})});ct.displayName=Ve;var dt="ScrollAreaViewport",ut=p.forwardRef((e,t)=>{let{__scopeScrollArea:r,children:n,nonce:l,...a}=e,s=z(dt,r),i=le(t,p.useRef(null),s.onViewportChange);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:l}),(0,o.jsx)(pe.div,{"data-radix-scroll-area-viewport":"",...a,ref:i,style:{overflowX:s.scrollbarXEnabled?"scroll":"hidden",overflowY:s.scrollbarYEnabled?"scroll":"hidden",...e.style},children:(0,o.jsx)("div",{ref:s.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});ut.displayName=dt;var U="ScrollAreaScrollbar",qe=p.forwardRef((e,t)=>{let{forceMount:r,...n}=e,l=z(U,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:s}=l,i=e.orientation==="horizontal";return p.useEffect(()=>(i?a(!0):s(!0),()=>{i?a(!1):s(!1)}),[i,a,s]),l.type==="hover"?(0,o.jsx)(Dr,{...n,ref:t,forceMount:r}):l.type==="scroll"?(0,o.jsx)(Mr,{...n,ref:t,forceMount:r}):l.type==="auto"?(0,o.jsx)(pt,{...n,ref:t,forceMount:r}):l.type==="always"?(0,o.jsx)(Be,{...n,ref:t}):null});qe.displayName=U;var Dr=p.forwardRef((e,t)=>{let{forceMount:r,...n}=e,l=z(U,e.__scopeScrollArea),[a,s]=p.useState(!1);return p.useEffect(()=>{let i=l.scrollArea,c=0;if(i){let u=()=>{window.clearTimeout(c),s(!0)},d=()=>{c=window.setTimeout(()=>s(!1),l.scrollHideDelay)};return i.addEventListener("pointerenter",u),i.addEventListener("pointerleave",d),()=>{window.clearTimeout(c),i.removeEventListener("pointerenter",u),i.removeEventListener("pointerleave",d)}}},[l.scrollArea,l.scrollHideDelay]),(0,o.jsx)(Te,{present:r||a,children:(0,o.jsx)(pt,{"data-state":a?"visible":"hidden",...n,ref:t})})}),Mr=p.forwardRef((e,t)=>{let{forceMount:r,...n}=e,l=z(U,e.__scopeScrollArea),a=e.orientation==="horizontal",s=Ie(()=>c("SCROLL_END"),100),[i,c]=Ir("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return p.useEffect(()=>{if(i==="idle"){let u=window.setTimeout(()=>c("HIDE"),l.scrollHideDelay);return()=>window.clearTimeout(u)}},[i,l.scrollHideDelay,c]),p.useEffect(()=>{let u=l.viewport,d=a?"scrollLeft":"scrollTop";if(u){let m=u[d],h=()=>{let f=u[d];m!==f&&(c("SCROLL"),s()),m=f};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[l.viewport,a,c,s]),(0,o.jsx)(Te,{present:r||i!=="hidden",children:(0,o.jsx)(Be,{"data-state":i==="hidden"?"hidden":"visible",...n,ref:t,onPointerEnter:V(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:V(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),pt=p.forwardRef((e,t)=>{let r=z(U,e.__scopeScrollArea),{forceMount:n,...l}=e,[a,s]=p.useState(!1),i=e.orientation==="horizontal",c=Ie(()=>{if(r.viewport){let u=r.viewport.offsetWidth<r.viewport.scrollWidth,d=r.viewport.offsetHeight<r.viewport.scrollHeight;s(i?u:d)}},10);return ne(r.viewport,c),ne(r.content,c),(0,o.jsx)(Te,{present:n||a,children:(0,o.jsx)(Be,{"data-state":a?"visible":"hidden",...l,ref:t})})}),Be=p.forwardRef((e,t)=>{let{orientation:r="vertical",...n}=e,l=z(U,e.__scopeScrollArea),a=p.useRef(null),s=p.useRef(0),[i,c]=p.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=vt(i.viewport,i.content),d={...n,sizes:i,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:h=>a.current=h,onThumbPointerUp:()=>s.current=0,onThumbPointerDown:h=>s.current=h};function m(h,f){return Wr(h,s.current,i,f)}return r==="horizontal"?(0,o.jsx)(zr,{...d,ref:t,onThumbPositionChange:()=>{if(l.viewport&&a.current){let h=l.viewport.scrollLeft,f=gt(h,i,l.dir);a.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:h=>{l.viewport&&(l.viewport.scrollLeft=h)},onDragScroll:h=>{l.viewport&&(l.viewport.scrollLeft=m(h,l.dir))}}):r==="vertical"?(0,o.jsx)(Fr,{...d,ref:t,onThumbPositionChange:()=>{if(l.viewport&&a.current){let h=l.viewport.scrollTop,f=gt(h,i);a.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:h=>{l.viewport&&(l.viewport.scrollTop=h)},onDragScroll:h=>{l.viewport&&(l.viewport.scrollTop=m(h))}}):null}),zr=p.forwardRef((e,t)=>{let{sizes:r,onSizesChange:n,...l}=e,a=z(U,e.__scopeScrollArea),[s,i]=p.useState(),c=p.useRef(null),u=le(t,c,a.onScrollbarXChange);return p.useEffect(()=>{c.current&&i(getComputedStyle(c.current))},[c]),(0,o.jsx)(ht,{"data-orientation":"horizontal",...l,ref:u,sizes:r,style:{bottom:0,left:a.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:a.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Le(r)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,m)=>{if(a.viewport){let h=a.viewport.scrollLeft+d.deltaX;e.onWheelScroll(h),bt(h,m)&&d.preventDefault()}},onResize:()=>{c.current&&a.viewport&&s&&n({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:ke(s.paddingLeft),paddingEnd:ke(s.paddingRight)}})}})}),Fr=p.forwardRef((e,t)=>{let{sizes:r,onSizesChange:n,...l}=e,a=z(U,e.__scopeScrollArea),[s,i]=p.useState(),c=p.useRef(null),u=le(t,c,a.onScrollbarYChange);return p.useEffect(()=>{c.current&&i(getComputedStyle(c.current))},[c]),(0,o.jsx)(ht,{"data-orientation":"vertical",...l,ref:u,sizes:r,style:{top:0,right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Le(r)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,m)=>{if(a.viewport){let h=a.viewport.scrollTop+d.deltaY;e.onWheelScroll(h),bt(h,m)&&d.preventDefault()}},onResize:()=>{c.current&&a.viewport&&s&&n({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:ke(s.paddingTop),paddingEnd:ke(s.paddingBottom)}})}})}),[Hr,mt]=it(U),ht=p.forwardRef((e,t)=>{let{__scopeScrollArea:r,sizes:n,hasThumb:l,onThumbChange:a,onThumbPointerUp:s,onThumbPointerDown:i,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:d,onResize:m,...h}=e,f=z(U,r),[v,j]=p.useState(null),T=le(t,w=>j(w)),g=p.useRef(null),N=p.useRef(""),R=f.viewport,y=n.content-n.viewport,S=q(d),C=q(c),E=Ie(m,10);function I(w){g.current&&u({x:w.clientX-g.current.left,y:w.clientY-g.current.top})}return p.useEffect(()=>{let w=_=>{let k=_.target;v!=null&&v.contains(k)&&S(_,y)};return document.addEventListener("wheel",w,{passive:!1}),()=>document.removeEventListener("wheel",w,{passive:!1})},[R,v,y,S]),p.useEffect(C,[n,C]),ne(v,E),ne(f.content,E),(0,o.jsx)(Hr,{scope:r,scrollbar:v,hasThumb:l,onThumbChange:q(a),onThumbPointerUp:q(s),onThumbPositionChange:C,onThumbPointerDown:q(i),children:(0,o.jsx)(pe.div,{...h,ref:T,style:{position:"absolute",...h.style},onPointerDown:V(e.onPointerDown,w=>{w.button===0&&(w.target.setPointerCapture(w.pointerId),g.current=v.getBoundingClientRect(),N.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),I(w))}),onPointerMove:V(e.onPointerMove,I),onPointerUp:V(e.onPointerUp,w=>{let _=w.target;_.hasPointerCapture(w.pointerId)&&_.releasePointerCapture(w.pointerId),document.body.style.webkitUserSelect=N.current,f.viewport&&(f.viewport.style.scrollBehavior=""),g.current=null})})})}),Ee="ScrollAreaThumb",ft=p.forwardRef((e,t)=>{let{forceMount:r,...n}=e,l=mt(Ee,e.__scopeScrollArea);return(0,o.jsx)(Te,{present:r||l.hasThumb,children:(0,o.jsx)(Or,{ref:t,...n})})}),Or=p.forwardRef((e,t)=>{let{__scopeScrollArea:r,style:n,...l}=e,a=z(Ee,r),s=mt(Ee,r),{onThumbPositionChange:i}=s,c=le(t,m=>s.onThumbChange(m)),u=p.useRef(void 0),d=Ie(()=>{u.current&&(u.current=(u.current(),void 0))},100);return p.useEffect(()=>{let m=a.viewport;if(m){let h=()=>{d(),u.current||(u.current=Yr(m,i),i())};return i(),m.addEventListener("scroll",h),()=>m.removeEventListener("scroll",h)}},[a.viewport,d,i]),(0,o.jsx)(pe.div,{"data-state":s.hasThumb?"visible":"hidden",...l,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:V(e.onPointerDownCapture,m=>{let h=m.target.getBoundingClientRect(),f=m.clientX-h.left,v=m.clientY-h.top;s.onThumbPointerDown({x:f,y:v})}),onPointerUp:V(e.onPointerUp,s.onThumbPointerUp)})});ft.displayName=Ee;var $e="ScrollAreaCorner",xt=p.forwardRef((e,t)=>{let r=z($e,e.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?(0,o.jsx)(Ur,{...e,ref:t}):null});xt.displayName=$e;var Ur=p.forwardRef((e,t)=>{let{__scopeScrollArea:r,...n}=e,l=z($e,r),[a,s]=p.useState(0),[i,c]=p.useState(0),u=!!(a&&i);return ne(l.scrollbarX,()=>{var m;let d=((m=l.scrollbarX)==null?void 0:m.offsetHeight)||0;l.onCornerHeightChange(d),c(d)}),ne(l.scrollbarY,()=>{var m;let d=((m=l.scrollbarY)==null?void 0:m.offsetWidth)||0;l.onCornerWidthChange(d),s(d)}),u?(0,o.jsx)(pe.div,{...n,ref:t,style:{width:a,height:i,position:"absolute",right:l.dir==="ltr"?0:void 0,left:l.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function ke(e){return e?parseInt(e,10):0}function vt(e,t){let r=e/t;return isNaN(r)?0:r}function Le(e){let t=vt(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,n=(e.scrollbar.size-r)*t;return Math.max(n,18)}function Wr(e,t,r,n="ltr"){let l=Le(r),a=l/2,s=t||a,i=l-s,c=r.scrollbar.paddingStart+s,u=r.scrollbar.size-r.scrollbar.paddingEnd-i,d=r.content-r.viewport,m=n==="ltr"?[0,d]:[d*-1,0];return wt([c,u],m)(e)}function gt(e,t,r="ltr"){let n=Le(t),l=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-l,s=t.content-t.viewport,i=a-n,c=Zt(e,r==="ltr"?[0,s]:[s*-1,0]);return wt([0,s],[0,i])(c)}function wt(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let n=(t[1]-t[0])/(e[1]-e[0]);return t[0]+n*(r-e[0])}}function bt(e,t){return e>0&&e<t}var Yr=(e,t=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},n=0;return(function l(){let a={left:e.scrollLeft,top:e.scrollTop},s=r.left!==a.left,i=r.top!==a.top;(s||i)&&t(),r=a,n=window.requestAnimationFrame(l)})(),()=>window.cancelAnimationFrame(n)};function Ie(e,t){let r=q(e),n=p.useRef(0);return p.useEffect(()=>()=>window.clearTimeout(n.current),[]),p.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,t)},[r,t])}function ne(e,t){let r=q(t);Vt(()=>{let n=0;if(e){let l=new ResizeObserver(()=>{cancelAnimationFrame(n),n=window.requestAnimationFrame(r)});return l.observe(e),()=>{window.cancelAnimationFrame(n),l.unobserve(e)}}},[e,r])}var yt=ct,Xr=ut,Vr=xt,qr=rt("hat-glasses",[["path",{d:"M14 18a2 2 0 0 0-4 0",key:"1v8fkw"}],["path",{d:"m19 11-2.11-6.657a2 2 0 0 0-2.752-1.148l-1.276.61A2 2 0 0 1 12 4H8.5a2 2 0 0 0-1.925 1.456L5 11",key:"1fkr7p"}],["path",{d:"M2 11h20",key:"3eubbj"}],["circle",{cx:"17",cy:"18",r:"3",key:"82mm0e"}],["circle",{cx:"7",cy:"18",r:"3",key:"lvkj7j"}]]),Br=rt("notebook-text",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M9.5 8h5",key:"11mslq"}],["path",{d:"M9.5 12H16",key:"ktog6x"}],["path",{d:"M9.5 16H14",key:"p1seyn"}]]),jt=Qe();const $r=({chatState:e,chatId:t,messages:r})=>{if(!t)return _e.warn("No active chat"),e;let n=e.chats.get(t);if(!n)return _e.warn("No active chat"),e;let l=new Map(e.chats),a=Date.now();return l.set(n.id,{...n,messages:r,updatedAt:a}),{...e,chats:l}};var St=p.forwardRef((e,t)=>{let r=(0,jt.c)(15),n,l,a;r[0]===e?(n=r[1],l=r[2],a=r[3]):({className:l,children:n,...a}=e,r[0]=e,r[1]=n,r[2]=l,r[3]=a);let s;r[4]===l?s=r[5]:(s=oe("relative overflow-hidden",l),r[4]=l,r[5]=s);let i;r[6]===n?i=r[7]:(i=(0,o.jsx)(Xr,{className:"h-full w-full rounded-[inherit]",children:n}),r[6]=n,r[7]=i);let c,u;r[8]===Symbol.for("react.memo_cache_sentinel")?(c=(0,o.jsx)(Ct,{}),u=(0,o.jsx)(Vr,{}),r[8]=c,r[9]=u):(c=r[8],u=r[9]);let d;return r[10]!==a||r[11]!==t||r[12]!==s||r[13]!==i?(d=(0,o.jsxs)(yt,{ref:t,className:s,...a,children:[i,c,u]}),r[10]=a,r[11]=t,r[12]=s,r[13]=i,r[14]=d):d=r[14],d});St.displayName=yt.displayName;var Ct=p.forwardRef((e,t)=>{let r=(0,jt.c)(14),n,l,a;r[0]===e?(n=r[1],l=r[2],a=r[3]):({className:n,orientation:a,...l}=e,r[0]=e,r[1]=n,r[2]=l,r[3]=a);let s=a===void 0?"vertical":a,i=s==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-px",c=s==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-px",u;r[4]!==n||r[5]!==i||r[6]!==c?(u=oe("flex touch-none select-none transition-colors",i,c,n),r[4]=n,r[5]=i,r[6]=c,r[7]=u):u=r[7];let d;r[8]===Symbol.for("react.memo_cache_sentinel")?(d=(0,o.jsx)(ft,{className:"relative flex-1 rounded-full bg-border"}),r[8]=d):d=r[8];let m;return r[9]!==s||r[10]!==l||r[11]!==t||r[12]!==u?(m=(0,o.jsx)(qe,{ref:t,orientation:s,className:u,...l,children:d}),r[9]=s,r[10]=l,r[11]=t,r[12]=u,r[13]=m):m=r[13],m});Ct.displayName=qe.displayName;var Gr=[{label:"Today",days:0},{label:"Yesterday",days:1},{label:"2d ago",days:2},{label:"3d ago",days:3},{label:"This week",days:7},{label:"This month",days:30}];const Jr=e=>{let t=Date.now(),r=Gr.map(a=>({...a,chats:[]})),n={label:"Older",days:1/0,chats:[]},l=a=>{switch(a){case 0:return r[0];case 1:return r[1];case 2:return r[2];case 3:return r[3];default:return a>=4&&a<=7?r[4]:a>=8&&a<=30?r[5]:n}};for(let a of e)l(Math.floor((t-a.updatedAt)/864e5)).chats.push(a);return[...r,n].filter(a=>a.chats.length>0)},Kr=({activeChatId:e,setActiveChat:t})=>{let r=We(st),{locale:n}=Tr(),[l,a]=(0,p.useState)(""),s=(0,p.useMemo)(()=>[...r.chats.values()].toSorted((u,d)=>d.updatedAt-u.updatedAt),[r.chats]),i=(0,p.useMemo)(()=>l.trim()?s.filter(u=>u.title.toLowerCase().includes(l.toLowerCase())):s,[s,l]),c=(0,p.useMemo)(()=>Jr(i),[i]);return(0,o.jsxs)(Gt,{children:[(0,o.jsx)(Ye,{content:"Previous chats",children:(0,o.jsx)(Bt,{asChild:!0,children:(0,o.jsx)(ae,{variant:"text",size:"icon",children:(0,o.jsx)(Mt,{className:"h-4 w-4"})})})}),(0,o.jsxs)($t,{className:"w-[480px] p-0",align:"start",side:"right",children:[(0,o.jsx)("div",{className:"pt-3 px-3 w-full",children:(0,o.jsx)(Nr,{placeholder:"Search chat history...",value:l,onChange:u=>a(u.target.value),className:"text-xs"})}),(0,o.jsx)(St,{className:"h-[450px] p-2",children:(0,o.jsxs)("div",{className:"space-y-3",children:[s.length===0&&(0,o.jsx)(Xe,{title:"No chats yet",description:"Start a new chat to get started",icon:(0,o.jsx)(lt,{})}),i.length===0&&l&&s.length>0&&(0,o.jsx)(Xe,{title:"No chats found",description:`No chats match "${l}"`,icon:(0,o.jsx)(Cr,{})}),c.map((u,d)=>(0,o.jsxs)("div",{className:"space-y-2",children:[(0,o.jsx)("div",{className:"text-xs px-1 text-muted-foreground/60",children:u.label}),(0,o.jsx)("div",{children:u.chats.map(m=>(0,o.jsxs)("button",{className:oe("w-full p-1 rounded-md cursor-pointer text-left flex items-center justify-between",m.id===e&&"bg-accent",m.id!==e&&"hover:bg-muted/20"),onClick:()=>{t(m.id)},type:"button",children:[(0,o.jsx)("div",{className:"flex-1 min-w-0",children:(0,o.jsx)("div",{className:"text-sm truncate",children:m.title})}),(0,o.jsx)("div",{className:"text-xs text-muted-foreground/60 ml-2 flex-shrink-0",children:Ar(m.updatedAt,n)})]},m.id))}),d!==c.length-1&&(0,o.jsx)("hr",{})]},u.label))]})})]})]})};var se=Qe(),Nt="manual",Qr=e=>{let t=(0,se.c)(18),{onNewChat:r,activeChatId:n,setActiveChat:l}=e,{handleClick:a}=Ze(),s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,o.jsx)(Sr,{className:"h-4 w-4"}),t[0]=s):s=t[0];let i;t[1]===r?i=t[2]:(i=(0,o.jsx)(Ye,{content:"New chat",children:(0,o.jsx)(ae,{variant:"text",size:"icon",onClick:r,children:s})}),t[1]=r,t[2]=i);let c;t[3]===Symbol.for("react.memo_cache_sentinel")?(c=(0,o.jsx)(Ft,{}),t[3]=c):c=t[3];let u;t[4]===a?u=t[5]:(u=()=>a("ai"),t[4]=a,t[5]=u);let d;t[6]===Symbol.for("react.memo_cache_sentinel")?(d=(0,o.jsx)(Rr,{className:"h-4 w-4"}),t[6]=d):d=t[6];let m;t[7]===u?m=t[8]:(m=(0,o.jsx)(Ye,{content:"AI Settings",children:(0,o.jsx)(ae,{variant:"text",size:"xs",className:"hover:bg-foreground/10 py-2",onClick:u,children:d})}),t[7]=u,t[8]=m);let h;t[9]!==n||t[10]!==l?(h=(0,o.jsx)(Kr,{activeChatId:n,setActiveChat:l}),t[9]=n,t[10]=l,t[11]=h):h=t[11];let f;t[12]!==m||t[13]!==h?(f=(0,o.jsxs)("div",{className:"flex items-center gap-2",children:[c,m,h]}),t[12]=m,t[13]=h,t[14]=f):f=t[14];let v;return t[15]!==i||t[16]!==f?(v=(0,o.jsxs)("div",{className:"flex border-b px-2 py-1 justify-between shrink-0 items-center",children:[i,f]}),t[15]=i,t[16]=f,t[17]=v):v=t[17],v},Rt=(0,p.memo)(e=>{let t=(0,se.c)(15),{message:r,index:n,onEdit:l,isStreamingReasoning:a,isLast:s}=e,i;t[0]!==n||t[1]!==l?(i=j=>{var N,R,y;let T=(R=(N=j.parts)==null?void 0:N.filter(rl))==null?void 0:R.map(ll).join(`
|
|
1
|
+
import{s as Ke}from"./chunk-LvLJmgfZ.js";import{d as kt,f as Lt,l as It,n as ue,u as We}from"./useEvent-D91BmmQi.js";import{t as Pt}from"./react-Bj1aDYRI.js";import{E as Dt,fr as Mt}from"./cells-EJo3u4za.js";import"./react-dom-CSu739Rf.js";import{t as Qe}from"./compiler-runtime-B3qBwwSJ.js";import{T as zt,o as Ft,r as Ze,t as Ht,w as Ot}from"./ai-model-dropdown-CRtaHcCu.js";import{_ as _e,o as le}from"./useEventListener-DGjKht0c.js";import{n as et,r as Ut}from"./utils-8btzWeZg.js";import{o as Wt}from"./config-DoZCLcOb.js";import{t as oe}from"./cn-DYvqRARy.js";import{t as Yt}from"./jsx-runtime-Blw4afVn.js";import{C as pe,S as Xt,_ as Te,b as V,h as q,y as Vt}from"./fullscreen-k58KVlT-.js";import{u as qt}from"./menu-items-Dtw5N98_.js";import{i as Bt,r as $t,t as Gt}from"./popover-AtoFZ7i4.js";import{a as Jt,i as Kt,n as Qt,p as Zt,r as er,s as tr,t as rr}from"./select--zcABebs.js";import{i as tt,t as Ye}from"./tooltip-DmqhBBs6.js";import{t as ae}from"./button-BKVLeSTX.js";import"./dist-VwkX7yeV.js";import"./cjs-D5tzp-Y6.js";import"./main-BNL5rxQw.js";import"./useNonce-CbdaHKzX.js";import{r as lr}from"./requests-9-v2bhoi.js";import{t as rt}from"./createLucideIcon-w-Qo9n0R.js";import{t as lt}from"./bot-message-square-BbnE8Q1J.js";import"./markdown-renderer-B9RsGqHb.js";import{O as ot,S as or,T as ar,_ as nr,b as sr,c as ir,d as cr,f as dr,g as ur,h as pr,j as mr,k as hr,l as fr,m as at,n as nt,p as xr,s as vr,u as gr,v as wr,y as br}from"./add-cell-with-ai-CLklC7KS.js";import{n as yr}from"./spinner-C5wIpWgQ.js";import{t as jr}from"./message-circle-DiHwtSG8.js";import{t as Sr}from"./plus-BYq_Btg-.js";import{dt as Cr,r as Nr}from"./input-Bg12i6qY.js";import{t as Rr}from"./settings-C1bg8A2T.js";import"./dist-BvlMLwcr.js";import"./dist-4lB-oR9j.js";import"./dist-CxquLoAZ.js";import"./dist-Dnlw22ji.js";import"./dist-CgYlATe-.js";import"./session-DdnWW30b.js";import"./purify.es-BFDc-_i_.js";import{i as Ar}from"./dates-stqTIkXD.js";import{t as _r}from"./copy-icon-BGs1Pbai.js";import{t as Tr}from"./context-DGqo1TbK.js";import{r as st,t as Er}from"./state-BDrig0S2.js";import{n as kr}from"./error-banner-bXc_9BBZ.js";import"./chunk-5FQGJX7Z-Cyc7d5AB.js";import"./html-to-image-BJiJlwQY.js";import"./esm-BqofWdD5.js";import{t as Xe}from"./empty-state-BbLVXQU7.js";import{t as Lr}from"./chat-display-BxDRpNsl.js";var p=Ke(Pt(),1),o=Ke(Yt(),1);function Ir(e,t){return p.useReducer((r,n)=>t[r][n]??r,e)}var Ve="ScrollArea",[it,po]=Xt(Ve),[Pr,z]=it(Ve),ct=p.forwardRef((e,t)=>{let{__scopeScrollArea:r,type:n="hover",dir:l,scrollHideDelay:a=600,...s}=e,[i,c]=p.useState(null),[u,d]=p.useState(null),[m,h]=p.useState(null),[f,v]=p.useState(null),[j,T]=p.useState(null),[g,N]=p.useState(0),[R,y]=p.useState(0),[S,C]=p.useState(!1),[E,I]=p.useState(!1),w=le(t,k=>c(k)),_=qt(l);return(0,o.jsx)(Pr,{scope:r,type:n,dir:_,scrollHideDelay:a,scrollArea:i,viewport:u,onViewportChange:d,content:m,onContentChange:h,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:S,onScrollbarXEnabledChange:C,scrollbarY:j,onScrollbarYChange:T,scrollbarYEnabled:E,onScrollbarYEnabledChange:I,onCornerWidthChange:N,onCornerHeightChange:y,children:(0,o.jsx)(pe.div,{dir:_,...s,ref:w,style:{position:"relative","--radix-scroll-area-corner-width":g+"px","--radix-scroll-area-corner-height":R+"px",...e.style}})})});ct.displayName=Ve;var dt="ScrollAreaViewport",ut=p.forwardRef((e,t)=>{let{__scopeScrollArea:r,children:n,nonce:l,...a}=e,s=z(dt,r),i=le(t,p.useRef(null),s.onViewportChange);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:l}),(0,o.jsx)(pe.div,{"data-radix-scroll-area-viewport":"",...a,ref:i,style:{overflowX:s.scrollbarXEnabled?"scroll":"hidden",overflowY:s.scrollbarYEnabled?"scroll":"hidden",...e.style},children:(0,o.jsx)("div",{ref:s.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});ut.displayName=dt;var U="ScrollAreaScrollbar",qe=p.forwardRef((e,t)=>{let{forceMount:r,...n}=e,l=z(U,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:s}=l,i=e.orientation==="horizontal";return p.useEffect(()=>(i?a(!0):s(!0),()=>{i?a(!1):s(!1)}),[i,a,s]),l.type==="hover"?(0,o.jsx)(Dr,{...n,ref:t,forceMount:r}):l.type==="scroll"?(0,o.jsx)(Mr,{...n,ref:t,forceMount:r}):l.type==="auto"?(0,o.jsx)(pt,{...n,ref:t,forceMount:r}):l.type==="always"?(0,o.jsx)(Be,{...n,ref:t}):null});qe.displayName=U;var Dr=p.forwardRef((e,t)=>{let{forceMount:r,...n}=e,l=z(U,e.__scopeScrollArea),[a,s]=p.useState(!1);return p.useEffect(()=>{let i=l.scrollArea,c=0;if(i){let u=()=>{window.clearTimeout(c),s(!0)},d=()=>{c=window.setTimeout(()=>s(!1),l.scrollHideDelay)};return i.addEventListener("pointerenter",u),i.addEventListener("pointerleave",d),()=>{window.clearTimeout(c),i.removeEventListener("pointerenter",u),i.removeEventListener("pointerleave",d)}}},[l.scrollArea,l.scrollHideDelay]),(0,o.jsx)(Te,{present:r||a,children:(0,o.jsx)(pt,{"data-state":a?"visible":"hidden",...n,ref:t})})}),Mr=p.forwardRef((e,t)=>{let{forceMount:r,...n}=e,l=z(U,e.__scopeScrollArea),a=e.orientation==="horizontal",s=Ie(()=>c("SCROLL_END"),100),[i,c]=Ir("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return p.useEffect(()=>{if(i==="idle"){let u=window.setTimeout(()=>c("HIDE"),l.scrollHideDelay);return()=>window.clearTimeout(u)}},[i,l.scrollHideDelay,c]),p.useEffect(()=>{let u=l.viewport,d=a?"scrollLeft":"scrollTop";if(u){let m=u[d],h=()=>{let f=u[d];m!==f&&(c("SCROLL"),s()),m=f};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[l.viewport,a,c,s]),(0,o.jsx)(Te,{present:r||i!=="hidden",children:(0,o.jsx)(Be,{"data-state":i==="hidden"?"hidden":"visible",...n,ref:t,onPointerEnter:V(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:V(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),pt=p.forwardRef((e,t)=>{let r=z(U,e.__scopeScrollArea),{forceMount:n,...l}=e,[a,s]=p.useState(!1),i=e.orientation==="horizontal",c=Ie(()=>{if(r.viewport){let u=r.viewport.offsetWidth<r.viewport.scrollWidth,d=r.viewport.offsetHeight<r.viewport.scrollHeight;s(i?u:d)}},10);return ne(r.viewport,c),ne(r.content,c),(0,o.jsx)(Te,{present:n||a,children:(0,o.jsx)(Be,{"data-state":a?"visible":"hidden",...l,ref:t})})}),Be=p.forwardRef((e,t)=>{let{orientation:r="vertical",...n}=e,l=z(U,e.__scopeScrollArea),a=p.useRef(null),s=p.useRef(0),[i,c]=p.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=vt(i.viewport,i.content),d={...n,sizes:i,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:h=>a.current=h,onThumbPointerUp:()=>s.current=0,onThumbPointerDown:h=>s.current=h};function m(h,f){return Wr(h,s.current,i,f)}return r==="horizontal"?(0,o.jsx)(zr,{...d,ref:t,onThumbPositionChange:()=>{if(l.viewport&&a.current){let h=l.viewport.scrollLeft,f=gt(h,i,l.dir);a.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:h=>{l.viewport&&(l.viewport.scrollLeft=h)},onDragScroll:h=>{l.viewport&&(l.viewport.scrollLeft=m(h,l.dir))}}):r==="vertical"?(0,o.jsx)(Fr,{...d,ref:t,onThumbPositionChange:()=>{if(l.viewport&&a.current){let h=l.viewport.scrollTop,f=gt(h,i);a.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:h=>{l.viewport&&(l.viewport.scrollTop=h)},onDragScroll:h=>{l.viewport&&(l.viewport.scrollTop=m(h))}}):null}),zr=p.forwardRef((e,t)=>{let{sizes:r,onSizesChange:n,...l}=e,a=z(U,e.__scopeScrollArea),[s,i]=p.useState(),c=p.useRef(null),u=le(t,c,a.onScrollbarXChange);return p.useEffect(()=>{c.current&&i(getComputedStyle(c.current))},[c]),(0,o.jsx)(ht,{"data-orientation":"horizontal",...l,ref:u,sizes:r,style:{bottom:0,left:a.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:a.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Le(r)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,m)=>{if(a.viewport){let h=a.viewport.scrollLeft+d.deltaX;e.onWheelScroll(h),bt(h,m)&&d.preventDefault()}},onResize:()=>{c.current&&a.viewport&&s&&n({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:ke(s.paddingLeft),paddingEnd:ke(s.paddingRight)}})}})}),Fr=p.forwardRef((e,t)=>{let{sizes:r,onSizesChange:n,...l}=e,a=z(U,e.__scopeScrollArea),[s,i]=p.useState(),c=p.useRef(null),u=le(t,c,a.onScrollbarYChange);return p.useEffect(()=>{c.current&&i(getComputedStyle(c.current))},[c]),(0,o.jsx)(ht,{"data-orientation":"vertical",...l,ref:u,sizes:r,style:{top:0,right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Le(r)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,m)=>{if(a.viewport){let h=a.viewport.scrollTop+d.deltaY;e.onWheelScroll(h),bt(h,m)&&d.preventDefault()}},onResize:()=>{c.current&&a.viewport&&s&&n({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:ke(s.paddingTop),paddingEnd:ke(s.paddingBottom)}})}})}),[Hr,mt]=it(U),ht=p.forwardRef((e,t)=>{let{__scopeScrollArea:r,sizes:n,hasThumb:l,onThumbChange:a,onThumbPointerUp:s,onThumbPointerDown:i,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:d,onResize:m,...h}=e,f=z(U,r),[v,j]=p.useState(null),T=le(t,w=>j(w)),g=p.useRef(null),N=p.useRef(""),R=f.viewport,y=n.content-n.viewport,S=q(d),C=q(c),E=Ie(m,10);function I(w){g.current&&u({x:w.clientX-g.current.left,y:w.clientY-g.current.top})}return p.useEffect(()=>{let w=_=>{let k=_.target;v!=null&&v.contains(k)&&S(_,y)};return document.addEventListener("wheel",w,{passive:!1}),()=>document.removeEventListener("wheel",w,{passive:!1})},[R,v,y,S]),p.useEffect(C,[n,C]),ne(v,E),ne(f.content,E),(0,o.jsx)(Hr,{scope:r,scrollbar:v,hasThumb:l,onThumbChange:q(a),onThumbPointerUp:q(s),onThumbPositionChange:C,onThumbPointerDown:q(i),children:(0,o.jsx)(pe.div,{...h,ref:T,style:{position:"absolute",...h.style},onPointerDown:V(e.onPointerDown,w=>{w.button===0&&(w.target.setPointerCapture(w.pointerId),g.current=v.getBoundingClientRect(),N.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),I(w))}),onPointerMove:V(e.onPointerMove,I),onPointerUp:V(e.onPointerUp,w=>{let _=w.target;_.hasPointerCapture(w.pointerId)&&_.releasePointerCapture(w.pointerId),document.body.style.webkitUserSelect=N.current,f.viewport&&(f.viewport.style.scrollBehavior=""),g.current=null})})})}),Ee="ScrollAreaThumb",ft=p.forwardRef((e,t)=>{let{forceMount:r,...n}=e,l=mt(Ee,e.__scopeScrollArea);return(0,o.jsx)(Te,{present:r||l.hasThumb,children:(0,o.jsx)(Or,{ref:t,...n})})}),Or=p.forwardRef((e,t)=>{let{__scopeScrollArea:r,style:n,...l}=e,a=z(Ee,r),s=mt(Ee,r),{onThumbPositionChange:i}=s,c=le(t,m=>s.onThumbChange(m)),u=p.useRef(void 0),d=Ie(()=>{u.current&&(u.current=(u.current(),void 0))},100);return p.useEffect(()=>{let m=a.viewport;if(m){let h=()=>{d(),u.current||(u.current=Yr(m,i),i())};return i(),m.addEventListener("scroll",h),()=>m.removeEventListener("scroll",h)}},[a.viewport,d,i]),(0,o.jsx)(pe.div,{"data-state":s.hasThumb?"visible":"hidden",...l,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:V(e.onPointerDownCapture,m=>{let h=m.target.getBoundingClientRect(),f=m.clientX-h.left,v=m.clientY-h.top;s.onThumbPointerDown({x:f,y:v})}),onPointerUp:V(e.onPointerUp,s.onThumbPointerUp)})});ft.displayName=Ee;var $e="ScrollAreaCorner",xt=p.forwardRef((e,t)=>{let r=z($e,e.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?(0,o.jsx)(Ur,{...e,ref:t}):null});xt.displayName=$e;var Ur=p.forwardRef((e,t)=>{let{__scopeScrollArea:r,...n}=e,l=z($e,r),[a,s]=p.useState(0),[i,c]=p.useState(0),u=!!(a&&i);return ne(l.scrollbarX,()=>{var m;let d=((m=l.scrollbarX)==null?void 0:m.offsetHeight)||0;l.onCornerHeightChange(d),c(d)}),ne(l.scrollbarY,()=>{var m;let d=((m=l.scrollbarY)==null?void 0:m.offsetWidth)||0;l.onCornerWidthChange(d),s(d)}),u?(0,o.jsx)(pe.div,{...n,ref:t,style:{width:a,height:i,position:"absolute",right:l.dir==="ltr"?0:void 0,left:l.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function ke(e){return e?parseInt(e,10):0}function vt(e,t){let r=e/t;return isNaN(r)?0:r}function Le(e){let t=vt(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,n=(e.scrollbar.size-r)*t;return Math.max(n,18)}function Wr(e,t,r,n="ltr"){let l=Le(r),a=l/2,s=t||a,i=l-s,c=r.scrollbar.paddingStart+s,u=r.scrollbar.size-r.scrollbar.paddingEnd-i,d=r.content-r.viewport,m=n==="ltr"?[0,d]:[d*-1,0];return wt([c,u],m)(e)}function gt(e,t,r="ltr"){let n=Le(t),l=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-l,s=t.content-t.viewport,i=a-n,c=Zt(e,r==="ltr"?[0,s]:[s*-1,0]);return wt([0,s],[0,i])(c)}function wt(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let n=(t[1]-t[0])/(e[1]-e[0]);return t[0]+n*(r-e[0])}}function bt(e,t){return e>0&&e<t}var Yr=(e,t=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},n=0;return(function l(){let a={left:e.scrollLeft,top:e.scrollTop},s=r.left!==a.left,i=r.top!==a.top;(s||i)&&t(),r=a,n=window.requestAnimationFrame(l)})(),()=>window.cancelAnimationFrame(n)};function Ie(e,t){let r=q(e),n=p.useRef(0);return p.useEffect(()=>()=>window.clearTimeout(n.current),[]),p.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,t)},[r,t])}function ne(e,t){let r=q(t);Vt(()=>{let n=0;if(e){let l=new ResizeObserver(()=>{cancelAnimationFrame(n),n=window.requestAnimationFrame(r)});return l.observe(e),()=>{window.cancelAnimationFrame(n),l.unobserve(e)}}},[e,r])}var yt=ct,Xr=ut,Vr=xt,qr=rt("hat-glasses",[["path",{d:"M14 18a2 2 0 0 0-4 0",key:"1v8fkw"}],["path",{d:"m19 11-2.11-6.657a2 2 0 0 0-2.752-1.148l-1.276.61A2 2 0 0 1 12 4H8.5a2 2 0 0 0-1.925 1.456L5 11",key:"1fkr7p"}],["path",{d:"M2 11h20",key:"3eubbj"}],["circle",{cx:"17",cy:"18",r:"3",key:"82mm0e"}],["circle",{cx:"7",cy:"18",r:"3",key:"lvkj7j"}]]),Br=rt("notebook-text",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M9.5 8h5",key:"11mslq"}],["path",{d:"M9.5 12H16",key:"ktog6x"}],["path",{d:"M9.5 16H14",key:"p1seyn"}]]),jt=Qe();const $r=({chatState:e,chatId:t,messages:r})=>{if(!t)return _e.warn("No active chat"),e;let n=e.chats.get(t);if(!n)return _e.warn("No active chat"),e;let l=new Map(e.chats),a=Date.now();return l.set(n.id,{...n,messages:r,updatedAt:a}),{...e,chats:l}};var St=p.forwardRef((e,t)=>{let r=(0,jt.c)(15),n,l,a;r[0]===e?(n=r[1],l=r[2],a=r[3]):({className:l,children:n,...a}=e,r[0]=e,r[1]=n,r[2]=l,r[3]=a);let s;r[4]===l?s=r[5]:(s=oe("relative overflow-hidden",l),r[4]=l,r[5]=s);let i;r[6]===n?i=r[7]:(i=(0,o.jsx)(Xr,{className:"h-full w-full rounded-[inherit]",children:n}),r[6]=n,r[7]=i);let c,u;r[8]===Symbol.for("react.memo_cache_sentinel")?(c=(0,o.jsx)(Ct,{}),u=(0,o.jsx)(Vr,{}),r[8]=c,r[9]=u):(c=r[8],u=r[9]);let d;return r[10]!==a||r[11]!==t||r[12]!==s||r[13]!==i?(d=(0,o.jsxs)(yt,{ref:t,className:s,...a,children:[i,c,u]}),r[10]=a,r[11]=t,r[12]=s,r[13]=i,r[14]=d):d=r[14],d});St.displayName=yt.displayName;var Ct=p.forwardRef((e,t)=>{let r=(0,jt.c)(14),n,l,a;r[0]===e?(n=r[1],l=r[2],a=r[3]):({className:n,orientation:a,...l}=e,r[0]=e,r[1]=n,r[2]=l,r[3]=a);let s=a===void 0?"vertical":a,i=s==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-px",c=s==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-px",u;r[4]!==n||r[5]!==i||r[6]!==c?(u=oe("flex touch-none select-none transition-colors",i,c,n),r[4]=n,r[5]=i,r[6]=c,r[7]=u):u=r[7];let d;r[8]===Symbol.for("react.memo_cache_sentinel")?(d=(0,o.jsx)(ft,{className:"relative flex-1 rounded-full bg-border"}),r[8]=d):d=r[8];let m;return r[9]!==s||r[10]!==l||r[11]!==t||r[12]!==u?(m=(0,o.jsx)(qe,{ref:t,orientation:s,className:u,...l,children:d}),r[9]=s,r[10]=l,r[11]=t,r[12]=u,r[13]=m):m=r[13],m});Ct.displayName=qe.displayName;var Gr=[{label:"Today",days:0},{label:"Yesterday",days:1},{label:"2d ago",days:2},{label:"3d ago",days:3},{label:"This week",days:7},{label:"This month",days:30}];const Jr=e=>{let t=Date.now(),r=Gr.map(a=>({...a,chats:[]})),n={label:"Older",days:1/0,chats:[]},l=a=>{switch(a){case 0:return r[0];case 1:return r[1];case 2:return r[2];case 3:return r[3];default:return a>=4&&a<=7?r[4]:a>=8&&a<=30?r[5]:n}};for(let a of e)l(Math.floor((t-a.updatedAt)/864e5)).chats.push(a);return[...r,n].filter(a=>a.chats.length>0)},Kr=({activeChatId:e,setActiveChat:t})=>{let r=We(st),{locale:n}=Tr(),[l,a]=(0,p.useState)(""),s=(0,p.useMemo)(()=>[...r.chats.values()].toSorted((u,d)=>d.updatedAt-u.updatedAt),[r.chats]),i=(0,p.useMemo)(()=>l.trim()?s.filter(u=>u.title.toLowerCase().includes(l.toLowerCase())):s,[s,l]),c=(0,p.useMemo)(()=>Jr(i),[i]);return(0,o.jsxs)(Gt,{children:[(0,o.jsx)(Ye,{content:"Previous chats",children:(0,o.jsx)(Bt,{asChild:!0,children:(0,o.jsx)(ae,{variant:"text",size:"icon",children:(0,o.jsx)(Mt,{className:"h-4 w-4"})})})}),(0,o.jsxs)($t,{className:"w-[480px] p-0",align:"start",side:"right",children:[(0,o.jsx)("div",{className:"pt-3 px-3 w-full",children:(0,o.jsx)(Nr,{placeholder:"Search chat history...",value:l,onChange:u=>a(u.target.value),className:"text-xs"})}),(0,o.jsx)(St,{className:"h-[450px] p-2",children:(0,o.jsxs)("div",{className:"space-y-3",children:[s.length===0&&(0,o.jsx)(Xe,{title:"No chats yet",description:"Start a new chat to get started",icon:(0,o.jsx)(lt,{})}),i.length===0&&l&&s.length>0&&(0,o.jsx)(Xe,{title:"No chats found",description:`No chats match "${l}"`,icon:(0,o.jsx)(Cr,{})}),c.map((u,d)=>(0,o.jsxs)("div",{className:"space-y-2",children:[(0,o.jsx)("div",{className:"text-xs px-1 text-muted-foreground/60",children:u.label}),(0,o.jsx)("div",{children:u.chats.map(m=>(0,o.jsxs)("button",{className:oe("w-full p-1 rounded-md cursor-pointer text-left flex items-center justify-between",m.id===e&&"bg-accent",m.id!==e&&"hover:bg-muted/20"),onClick:()=>{t(m.id)},type:"button",children:[(0,o.jsx)("div",{className:"flex-1 min-w-0",children:(0,o.jsx)("div",{className:"text-sm truncate",children:m.title})}),(0,o.jsx)("div",{className:"text-xs text-muted-foreground/60 ml-2 flex-shrink-0",children:Ar(m.updatedAt,n)})]},m.id))}),d!==c.length-1&&(0,o.jsx)("hr",{})]},u.label))]})})]})]})};var se=Qe(),Nt="manual",Qr=e=>{let t=(0,se.c)(18),{onNewChat:r,activeChatId:n,setActiveChat:l}=e,{handleClick:a}=Ze(),s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,o.jsx)(Sr,{className:"h-4 w-4"}),t[0]=s):s=t[0];let i;t[1]===r?i=t[2]:(i=(0,o.jsx)(Ye,{content:"New chat",children:(0,o.jsx)(ae,{variant:"text",size:"icon",onClick:r,children:s})}),t[1]=r,t[2]=i);let c;t[3]===Symbol.for("react.memo_cache_sentinel")?(c=(0,o.jsx)(Ft,{}),t[3]=c):c=t[3];let u;t[4]===a?u=t[5]:(u=()=>a("ai"),t[4]=a,t[5]=u);let d;t[6]===Symbol.for("react.memo_cache_sentinel")?(d=(0,o.jsx)(Rr,{className:"h-4 w-4"}),t[6]=d):d=t[6];let m;t[7]===u?m=t[8]:(m=(0,o.jsx)(Ye,{content:"AI Settings",children:(0,o.jsx)(ae,{variant:"text",size:"xs",className:"hover:bg-foreground/10 py-2",onClick:u,children:d})}),t[7]=u,t[8]=m);let h;t[9]!==n||t[10]!==l?(h=(0,o.jsx)(Kr,{activeChatId:n,setActiveChat:l}),t[9]=n,t[10]=l,t[11]=h):h=t[11];let f;t[12]!==m||t[13]!==h?(f=(0,o.jsxs)("div",{className:"flex items-center gap-2",children:[c,m,h]}),t[12]=m,t[13]=h,t[14]=f):f=t[14];let v;return t[15]!==i||t[16]!==f?(v=(0,o.jsxs)("div",{className:"flex border-b px-2 py-1 justify-between shrink-0 items-center",children:[i,f]}),t[15]=i,t[16]=f,t[17]=v):v=t[17],v},Rt=(0,p.memo)(e=>{let t=(0,se.c)(15),{message:r,index:n,onEdit:l,isStreamingReasoning:a,isLast:s}=e,i;t[0]!==n||t[1]!==l?(i=j=>{var N,R,y;let T=(R=(N=j.parts)==null?void 0:N.filter(rl))==null?void 0:R.map(ll).join(`
|
|
2
2
|
`),g=(y=j.parts)==null?void 0:y.filter(ol);return(0,o.jsxs)("div",{className:"w-[95%] bg-background border p-1 rounded-sm",children:[g==null?void 0:g.map(al),(0,o.jsx)(nt,{value:T,placeholder:"Type your message...",onChange:nl,onSubmit:(S,C)=>{C.trim()&&l(n,C)},onClose:sl},j.id)]})},t[0]=n,t[1]=l,t[2]=i):i=t[2];let c=i,u;t[3]!==s||t[4]!==a?(u=j=>(0,o.jsxs)("div",{className:"w-[95%] wrap-break-word",children:[(0,o.jsx)("div",{className:"absolute right-1 top-1 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,o.jsx)(_r,{className:"h-3 w-3",value:j.parts.filter(il).map(cl).join(`
|
|
3
3
|
`)||""})}),Lr({message:j,isStreamingReasoning:a,isLast:s})]}),t[3]=s,t[4]=a,t[5]=u):u=t[5];let d=u,m=r.role==="user"?"justify-end":"justify-start",h;t[6]===m?h=t[7]:(h=oe("flex group relative",m),t[6]=m,t[7]=h);let f;t[8]!==r||t[9]!==d||t[10]!==c?(f=r.role==="user"?c(r):d(r),t[8]=r,t[9]=d,t[10]=c,t[11]=f):f=t[11];let v;return t[12]!==h||t[13]!==f?(v=(0,o.jsx)("div",{className:h,children:f}),t[12]=h,t[13]=f,t[14]=v):v=t[14],v});Rt.displayName="ChatMessage";var At=(0,p.memo)(e=>{var D,Y;let t=(0,se.c)(39),{isEmpty:r,onSendClick:n,isLoading:l,onStop:a,fileInputRef:s,onAddFiles:i,onAddContext:c}=e,u=We(et),d=(u==null?void 0:u.mode)||Nt,m=((D=u==null?void 0:u.models)==null?void 0:D.chat_model)||"openai/gpt-4o",h=Ot.parse(m).providerId,{saveModeChange:f}=zt(),v;t[0]===Symbol.for("react.memo_cache_sentinel")?(v=[{value:"manual",label:"Manual",subtitle:"Pure chat, no tool usage",Icon:jr},{value:"ask",label:"Ask",subtitle:"Use AI with access to read-only tools like documentation search",Icon:Br},{value:"agent",label:"Agent (beta)",subtitle:"Use AI with access to read and write tools",Icon:qr}],t[0]=v):v=t[0];let j=v,T=dr.has(h),g=(Y=j.find(me=>me.value===d))==null?void 0:Y.Icon,N;t[1]===g?N=t[2]:(N=g&&(0,o.jsx)(g,{className:"h-3 w-3"}),t[1]=g,t[2]=N);let R;t[3]===d?R=t[4]:(R=(0,o.jsx)("span",{className:"capitalize",children:d}),t[3]=d,t[4]=R);let y;t[5]!==N||t[6]!==R?(y=(0,o.jsxs)(tr,{className:"h-6 text-xs border-border shadow-none! ring-0! bg-muted hover:bg-muted/30 py-0 px-2 gap-1.5",children:[N,R]}),t[5]=N,t[6]=R,t[7]=y):y=t[7];let S;t[8]===Symbol.for("react.memo_cache_sentinel")?(S=(0,o.jsx)(Jt,{className:"text-xs uppercase tracking-wider text-muted-foreground/70 font-medium",children:"AI Mode"}),t[8]=S):S=t[8];let C;t[9]===j?C=t[10]:(C=(0,o.jsx)(Qt,{children:(0,o.jsxs)(er,{children:[S,j.map(dl)]})}),t[9]=j,t[10]=C);let E;t[11]!==d||t[12]!==f||t[13]!==y||t[14]!==C?(E=(0,o.jsxs)(rr,{value:d,onValueChange:f,children:[y,C]}),t[11]=d,t[12]=f,t[13]=y,t[14]=C,t[15]=E):E=t[15];let I;t[16]===Symbol.for("react.memo_cache_sentinel")?(I=(0,o.jsx)(Ht,{placeholder:"Model",triggerClassName:"h-6 text-xs shadow-none! ring-0! bg-muted hover:bg-muted/30 rounded-sm",iconSize:"small",showAddCustomModelDocs:!0,forRole:"chat"}),t[16]=I):I=t[16];let w;t[17]===E?w=t[18]:(w=(0,o.jsxs)("div",{className:"flex items-center gap-2",children:[E,I]}),t[17]=E,t[18]=w);let _;t[19]!==l||t[20]!==c?(_=(0,o.jsx)(vr,{handleAddContext:c,isLoading:l}),t[19]=l,t[20]=c,t[21]=_):_=t[21];let k;t[22]!==s||t[23]!==T||t[24]!==l||t[25]!==i?(k=T&&(0,o.jsx)(ir,{fileInputRef:s,isLoading:l,onAddFiles:i}),t[22]=s,t[23]=T,t[24]=l,t[25]=i,t[26]=k):k=t[26];let F;t[27]!==r||t[28]!==l||t[29]!==n||t[30]!==a?(F=(0,o.jsx)(cr,{isLoading:l,onStop:a,onSendClick:n,isEmpty:r}),t[27]=r,t[28]=l,t[29]=n,t[30]=a,t[31]=F):F=t[31];let H;t[32]!==_||t[33]!==k||t[34]!==F?(H=(0,o.jsxs)("div",{className:"flex flex-row",children:[_,k,F]}),t[32]=_,t[33]=k,t[34]=F,t[35]=H):H=t[35];let A;return t[36]!==H||t[37]!==w?(A=(0,o.jsx)(tt,{children:(0,o.jsxs)("div",{className:"px-3 py-2 border-t border-border/20 flex flex-row flex-wrap items-center justify-between gap-1",children:[w,H]})}),t[36]=H,t[37]=w,t[38]=A):A=t[38],A});At.displayName="ChatInputFooter";var Ge=(0,p.memo)(e=>{let t=(0,se.c)(29),{placeholder:r,input:n,inputClassName:l,setInput:a,onSubmit:s,inputRef:i,isLoading:c,onStop:u,fileInputRef:d,onAddFiles:m,onClose:h}=e,f;t[0]!==n||t[1]!==s?(f=()=>{n.trim()&&s(void 0,n)},t[0]=n,t[1]=s,t[2]=f):f=t[2];let v=ue(f),j;t[3]===l?j=t[4]:(j=oe("px-2 py-3 flex-1",l),t[3]=l,t[4]=j);let T=r||"Type your message...",g;t[5]!==n||t[6]!==i||t[7]!==m||t[8]!==h||t[9]!==s||t[10]!==a||t[11]!==T?(g=(0,o.jsx)(nt,{inputRef:i,value:n,onChange:a,onSubmit:s,onClose:h,onAddFiles:m,placeholder:T}),t[5]=n,t[6]=i,t[7]=m,t[8]=h,t[9]=s,t[10]=a,t[11]=T,t[12]=g):g=t[12];let N;t[13]!==j||t[14]!==g?(N=(0,o.jsx)("div",{className:j,children:g}),t[13]=j,t[14]=g,t[15]=N):N=t[15];let R=!n.trim(),y;t[16]===i?y=t[17]:(y=()=>ar(i),t[16]=i,t[17]=y);let S;t[18]!==d||t[19]!==v||t[20]!==c||t[21]!==m||t[22]!==u||t[23]!==R||t[24]!==y?(S=(0,o.jsx)(At,{isEmpty:R,onAddContext:y,onSendClick:v,isLoading:c,onStop:u,fileInputRef:d,onAddFiles:m}),t[18]=d,t[19]=v,t[20]=c,t[21]=m,t[22]=u,t[23]=R,t[24]=y,t[25]=S):S=t[25];let C;return t[26]!==N||t[27]!==S?(C=(0,o.jsxs)("div",{className:"relative shrink-0 min-h-[80px] flex flex-col border-t",children:[N,S]}),t[26]=N,t[27]=S,t[28]=C):C=t[28],C});Ge.displayName="ChatInput";var Zr=()=>{let e=(0,se.c)(6),t=We(Ut),{handleClick:r}=Ze();if(!t){let l;e[0]===r?l=e[1]:(l=(0,o.jsx)(ae,{variant:"outline",size:"sm",onClick:()=>r("ai","ai-providers"),children:"Edit AI settings"}),e[0]=r,e[1]=l);let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,o.jsx)(lt,{}),e[2]=a):a=e[2];let s;return e[3]===l?s=e[4]:(s=(0,o.jsx)(Xe,{title:"Chat with AI",description:"No AI provider configured or Chat model not selected",action:l,icon:a}),e[3]=l,e[4]=s),s}let n;return e[5]===Symbol.for("react.memo_cache_sentinel")?(n=(0,o.jsx)(el,{}),e[5]=n):n=e[5],n},el=()=>{let e=(0,se.c)(95),t=kt(st),[r,n]=It(Er),[l,a]=(0,p.useState)(""),[s,i]=(0,p.useState)(""),{files:c,addFiles:u,clearFiles:d,removeFile:m}=br(),h=(0,p.useRef)(null),f=(0,p.useRef)(null),v=(0,p.useRef)(null),j=(0,p.useRef)(null),T=(0,p.useRef)(null),g=Wt(),{invokeAiTool:N,sendRun:R}=lr(),y=r==null?void 0:r.id,S=Lt(),{addStagedCell:C}=or(),{createNewCell:E,prepareForRun:I}=Dt(),w;e[0]!==C||e[1]!==E||e[2]!==I||e[3]!==R||e[4]!==S?(w={addStagedCell:C,createNewCell:E,prepareForRun:I,sendRun:R,store:S},e[0]=C,e[1]=E,e[2]=I,e[3]=R,e[4]=S,e[5]=w):w=e[5];let _=w,k;e[6]===(r==null?void 0:r.messages)?k=e[7]:(k=(r==null?void 0:r.messages)||[],e[6]=r==null?void 0:r.messages,e[7]=k);let F;if(e[8]!==g||e[9]!==S){let x;e[11]===g?x=e[12]:(x=()=>g.headers(),e[11]=g,e[12]=x),F=new mr({api:g.getAiURL("chat").toString(),headers:x,prepareSendMessagesRequest:async b=>{var W;let L=await xr(b.messages),O=((W=S.get(et))==null?void 0:W.mode)||Nt,de=sr.getToolSchemas(O);return{api:g.getAiURL("chat").toString(),body:{tools:de,...b,...L}}}}),e[8]=g,e[9]=S,e[10]=F}else F=e[10];let H;e[13]===t?H=e[14]:(H=x=>{let{messages:b}=x;t(L=>$r({chatState:L,chatId:L.activeChatId,messages:b}))},e[13]=t,e[14]=H);let{messages:A,sendMessage:D,error:Y,status:me,regenerate:Pe,stop:X,addToolOutput:_t,id:De}=hr({id:y,sendAutomaticallyWhen:ul,messages:k,transport:F,onFinish:H,onToolCall:async x=>{let{toolCall:b}=x;if(b.dynamic){_e.debug("Skipping dynamic tool call",b);return}await ur({invokeAiTool:N,addToolOutput:Tt,toolCall:{toolName:b.toolName,toolCallId:b.toolCallId,input:b.input},toolContext:_})},onError:pl}),Tt=_t,P=me==="submitted"||me==="streaming",he;e[15]!==P||e[16]!==A?(he=P&&A.length>0&&wr(A),e[15]=P,e[16]=A,e[17]=he):he=e[17];let ie=he,fe;e[18]===Symbol.for("react.memo_cache_sentinel")?(fe=()=>{requestAnimationFrame(()=>{if(v.current){let x=v.current;x.scrollTop=x.scrollHeight}})},e[18]=fe):fe=e[18];let xe;e[19]===y?xe=e[20]:(xe=[y],e[19]=y,e[20]=xe),(0,p.useEffect)(fe,xe);let ve;e[21]!==De||e[22]!==d||e[23]!==D||e[24]!==t?(ve=async(x,b)=>{let L=Date.now(),O={id:De,title:pr(x),messages:[],createdAt:L,updatedAt:L};t(W=>{let Je=new Map(W.chats);return Je.set(O.id,O),{...W,chats:Je,activeChatId:O.id}});let de=b&&b.length>0?await at(b):void 0;D({role:"user",parts:[{type:"text",text:x},...de??[]]}),d(),a("")},e[21]=De,e[22]=d,e[23]=D,e[24]=t,e[25]=ve):ve=e[25];let Me=ve,ge;e[26]!==d||e[27]!==n?(ge=()=>{n(null),a(""),i(""),d()},e[26]=d,e[27]=n,e[28]=ge):ge=e[28];let ze=ue(ge),we;e[29]!==A||e[30]!==D?(we=(x,b)=>{var W;let L=A[x],O=(W=L.parts)==null?void 0:W.filter(ml),de=L.id;D({messageId:de,role:"user",parts:[{type:"text",text:b},...O]})},e[29]=A,e[30]=D,e[31]=we):we=e[31];let ce=ue(we),be;e[32]!==d||e[33]!==c||e[34]!==D?(be=async(x,b)=>{var O;if(!b.trim())return;(O=f.current)!=null&&O.view&&ot(f.current.view);let L=c?await at(c):void 0;x==null||x.preventDefault(),D({text:b,files:L}),a(""),d()},e[32]=d,e[33]=c,e[34]=D,e[35]=be):be=e[35];let Fe=ue(be),ye;e[36]===Pe?ye=e[37]:(ye=()=>{Pe()},e[36]=Pe,e[37]=ye);let He=ye,je;e[38]!==Me||e[39]!==c||e[40]!==s?(je=()=>{var x;s.trim()&&((x=h.current)!=null&&x.view&&ot(h.current.view),Me(s.trim(),c))},e[38]=Me,e[39]=c,e[40]=s,e[41]=je):je=e[41];let Oe=ue(je),Se;e[42]===Symbol.for("react.memo_cache_sentinel")?(Se=()=>{var x,b;return(b=(x=h.current)==null?void 0:x.editor)==null?void 0:b.blur()},e[42]=Se):Se=e[42];let Et=Se,M=A.length===0,Ce;e[43]!==u||e[44]!==Fe||e[45]!==Oe||e[46]!==l||e[47]!==P||e[48]!==M||e[49]!==s||e[50]!==X?(Ce=M?(0,o.jsx)(Ge,{placeholder:"Ask anything, @ to include context about tables or dataframes",input:s,inputRef:h,inputClassName:"px-1 py-0",setInput:i,onSubmit:Oe,isLoading:P,onStop:X,fileInputRef:j,onAddFiles:u,onClose:Et},"new-thread-input"):(0,o.jsx)(Ge,{input:l,setInput:a,onSubmit:Fe,inputRef:f,isLoading:P,onStop:X,onClose:()=>{var x,b;return(b=(x=f.current)==null?void 0:x.editor)==null?void 0:b.blur()},fileInputRef:j,onAddFiles:u}),e[43]=u,e[44]=Fe,e[45]=Oe,e[46]=l,e[47]=P,e[48]=M,e[49]=s,e[50]=X,e[51]=Ce):Ce=e[51];let B=Ce,Ne;e[52]!==c||e[53]!==M||e[54]!==m?(Ne=c&&c.length>0&&(0,o.jsx)("div",{className:oe("flex flex-row gap-1 flex-wrap p-1",M&&"py-2 px-1"),children:c==null?void 0:c.map(x=>(0,o.jsx)(gr,{file:x,onRemove:()=>m(x)},x.name))}),e[52]=c,e[53]=M,e[54]=m,e[55]=Ne):Ne=e[55];let $=Ne,Ue=r==null?void 0:r.id,G;e[56]!==ze||e[57]!==n||e[58]!==Ue?(G=(0,o.jsx)(tt,{children:(0,o.jsx)(Qr,{onNewChat:ze,activeChatId:Ue,setActiveChat:n})}),e[56]=ze,e[57]=n,e[58]=Ue,e[59]=G):G=e[59];let J;e[60]!==B||e[61]!==$||e[62]!==M?(J=M&&(0,o.jsxs)("div",{className:"rounded-md border bg-background",children:[$,B]}),e[60]=B,e[61]=$,e[62]=M,e[63]=J):J=e[63];let K;if(e[64]!==ce||e[65]!==ie||e[66]!==A){let x;e[68]!==ce||e[69]!==ie||e[70]!==A.length?(x=(b,L)=>(0,o.jsx)(Rt,{message:b,index:L,onEdit:ce,isStreamingReasoning:ie,isLast:L===A.length-1},b.id),e[68]=ce,e[69]=ie,e[70]=A.length,e[71]=x):x=e[71],K=A.map(x),e[64]=ce,e[65]=ie,e[66]=A,e[67]=K}else K=e[67];let Q;e[72]===P?Q=e[73]:(Q=P&&(0,o.jsx)("div",{className:"flex justify-center py-4",children:(0,o.jsx)(yr,{className:"h-4 w-4 animate-spin"})}),e[72]=P,e[73]=Q);let Z;e[74]!==Y||e[75]!==He?(Z=Y&&(0,o.jsxs)("div",{className:"flex items-center justify-center space-x-2 mb-4",children:[(0,o.jsx)(kr,{error:Y||Error("Unknown error")}),(0,o.jsx)(ae,{variant:"outline",size:"sm",onClick:He,children:"Retry"})]}),e[74]=Y,e[75]=He,e[76]=Z):Z=e[76];let Re;e[77]===Symbol.for("react.memo_cache_sentinel")?(Re=(0,o.jsx)("div",{ref:T}),e[77]=Re):Re=e[77];let ee;e[78]!==J||e[79]!==K||e[80]!==Q||e[81]!==Z?(ee=(0,o.jsxs)("div",{className:"flex-1 px-3 bg-(--slate-1) gap-4 py-3 flex flex-col overflow-y-auto",ref:v,children:[J,K,Q,Z,Re]}),e[78]=J,e[79]=K,e[80]=Q,e[81]=Z,e[82]=ee):ee=e[82];let te;e[83]!==P||e[84]!==X?(te=P&&(0,o.jsx)("div",{className:"w-full flex justify-center items-center z-20 border-t",children:(0,o.jsx)(ae,{variant:"linkDestructive",size:"sm",onClick:X,children:"Stop"})}),e[83]=P,e[84]=X,e[85]=te):te=e[85];let re;e[86]!==B||e[87]!==$||e[88]!==M?(re=!M&&(0,o.jsxs)(o.Fragment,{children:[$,B]}),e[86]=B,e[87]=$,e[88]=M,e[89]=re):re=e[89];let Ae;return e[90]!==G||e[91]!==ee||e[92]!==te||e[93]!==re?(Ae=(0,o.jsxs)("div",{className:"flex flex-col h-[calc(100%-53px)]",children:[G,ee,te,re]}),e[90]=G,e[91]=ee,e[92]=te,e[93]=re,e[94]=Ae):Ae=e[94],Ae},tl=Zr;function rl(e){return e.type==="text"}function ll(e){return e.text}function ol(e){return e.type==="file"}function al(e,t){return(0,o.jsx)(fr,{attachment:e},t)}function nl(){}function sl(){}function il(e){return e.type==="text"}function cl(e){return e.text}function dl(e){return(0,o.jsx)(Kt,{value:e.value,className:"text-xs py-1",children:(0,o.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,o.jsx)("span",{className:"mt-1 text-muted-foreground",children:(0,o.jsx)(e.Icon,{className:"h-3 w-3"})}),(0,o.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,o.jsx)("span",{className:"font-semibold",children:e.label}),(0,o.jsx)("span",{className:"text-muted-foreground",children:e.subtitle})]})]})},e.value)}function ul(e){let{messages:t}=e;return nr(t)}function pl(e){_e.error("An error occurred:",e)}function ml(e){return e.type==="file"}export{tl as default};
|