@marimo-team/frontend 0.21.2-dev79 → 0.21.2-dev80

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.
Files changed (79) hide show
  1. package/dist/assets/{CellStatus-BWh3L8zx.js → CellStatus-Z02WbA1T.js} +1 -1
  2. package/dist/assets/{JsonOutput-CQSoWTC4.js → JsonOutput-B_6OsFJA.js} +1 -1
  3. package/dist/assets/{MarimoErrorOutput-3snr3JrQ.js → MarimoErrorOutput-DdkdcLO-.js} +1 -1
  4. package/dist/assets/{RenderHTML-C9ZqxJ8H.js → RenderHTML-D45p-tLD.js} +1 -1
  5. package/dist/assets/{add-cell-with-ai-u_AX7UAd.js → add-cell-with-ai-C75dyXgo.js} +1 -1
  6. package/dist/assets/{add-connection-dialog-COHTxTf9.js → add-connection-dialog-DYxOBpNi.js} +1 -1
  7. package/dist/assets/{agent-panel-CcEQv7FH.js → agent-panel-m4AKS7Ut.js} +1 -1
  8. package/dist/assets/{ai-model-dropdown-Dybmv5gR.js → ai-model-dropdown-Cl-qIUat.js} +1 -1
  9. package/dist/assets/{app-config-button-BldM7HZH.js → app-config-button-I77XP0Ly.js} +1 -1
  10. package/dist/assets/{cell-editor-BExD1h53.js → cell-editor-DtVIjrkw.js} +1 -1
  11. package/dist/assets/{cell-link-DV3G9zVQ.js → cell-link-Bdbjts-L.js} +1 -1
  12. package/dist/assets/{cells-B8rT_yJt.js → cells-Ir3O9-uE.js} +1 -1
  13. package/dist/assets/{chat-display-DSlMdLnv.js → chat-display-TEJB6Bj2.js} +1 -1
  14. package/dist/assets/{chat-panel-BhurwxDK.js → chat-panel-CEqzWKcu.js} +1 -1
  15. package/dist/assets/{chat-ui-BL1vsaOH.js → chat-ui-B2Je9YxV.js} +1 -1
  16. package/dist/assets/{column-preview-BEoyw-go.js → column-preview-CKGwj-13.js} +1 -1
  17. package/dist/assets/{command-DvKBTmQJ.js → command-DccONw-I.js} +1 -1
  18. package/dist/assets/{command-palette-pDgtiL0o.js → command-palette-GUlU_ueE.js} +1 -1
  19. package/dist/assets/{common-MJu6yCEK.js → common-CMtjYJGh.js} +1 -1
  20. package/dist/assets/{components-CWfQv9p5.js → components-C5OBEN0S.js} +1 -1
  21. package/dist/assets/{components-fIfcCZSp.js → components-CI_j--E2.js} +1 -1
  22. package/dist/assets/{context-aware-panel-DJFzC2uh.js → context-aware-panel-5JBNhrcL.js} +2 -2
  23. package/dist/assets/{datasource-xomiPYKd.js → datasource-45Ftm7IO.js} +1 -1
  24. package/dist/assets/{dependency-graph-panel-B24Gr6L4.js → dependency-graph-panel-BzrngGy-.js} +1 -1
  25. package/dist/assets/{documentation-panel-DHLN-LCs.js → documentation-panel-Dk7WIBXq.js} +1 -1
  26. package/dist/assets/{download-CNJtCoWG.js → download-C2P9kUtq.js} +1 -1
  27. package/dist/assets/{edit-page-D0G0qKOk.js → edit-page-DM9TLp3a.js} +7 -7
  28. package/dist/assets/{error-panel-BprMlRWd.js → error-panel-BPQJzaxq.js} +1 -1
  29. package/dist/assets/{file-explorer-panel-DschbL1I.js → file-explorer-panel-D1CcjPTn.js} +1 -1
  30. package/dist/assets/{file-icons-I3TgHXBH.js → file-icons-B3ygedtV.js} +1 -1
  31. package/dist/assets/{floating-outline-BUsBWnrz.js → floating-outline-CdIFyGKb.js} +1 -1
  32. package/dist/assets/{focus-DWfOBGUg.js → focus-DXqWRa5J.js} +1 -1
  33. package/dist/assets/{form-DNvI4VkE.js → form-DIlikbTP.js} +1 -1
  34. package/dist/assets/{globals-B7uZUVXG.js → globals-DuAfXgSM.js} +1 -1
  35. package/dist/assets/{home-page-B1ioyqaQ.js → home-page-CGDApVqX.js} +1 -1
  36. package/dist/assets/{hooks-dmmemJB9.js → hooks-m-Uf6FNW.js} +1 -1
  37. package/dist/assets/{html-to-image-BtnUxAf2.js → html-to-image-B1AmbwBb.js} +1 -1
  38. package/dist/assets/{index-aCOJQiAd.js → index-BFrVG1np.js} +7 -7
  39. package/dist/assets/{kiosk-mode-DvjY7Q8k.js → kiosk-mode-oJ3erP0b.js} +1 -1
  40. package/dist/assets/{layout-BJa4d_WQ.js → layout-C2zfXBrd.js} +1 -1
  41. package/dist/assets/{logs-panel-Iivn5vVF.js → logs-panel-MKEh0IK-.js} +1 -1
  42. package/dist/assets/{markdown-renderer-f7AvSa1a.js → markdown-renderer-DpNwn0oX.js} +1 -1
  43. package/dist/assets/{name-cell-input-CzVNuMqK.js → name-cell-input-BgKW-jS9.js} +1 -1
  44. package/dist/assets/{outline-panel-QyE6tr_2.js → outline-panel-DeY7f680.js} +1 -1
  45. package/dist/assets/{packages-panel-D9pbtgFY.js → packages-panel-DxfrOcti.js} +1 -1
  46. package/dist/assets/{panels-CqWMsuFv.js → panels-DW9-jKgb.js} +1 -1
  47. package/dist/assets/{process-output-5fC8hAfT.js → process-output-xgqvYbVu.js} +1 -1
  48. package/dist/assets/{readonly-python-code-CvuT43MO.js → readonly-python-code-DJ37Vv8J.js} +1 -1
  49. package/dist/assets/{run-page-BtXltq0k.js → run-page-BEDqWbFX.js} +1 -1
  50. package/dist/assets/{scratchpad-panel-i-qE-Pfc.js → scratchpad-panel-Seg2akhp.js} +1 -1
  51. package/dist/assets/{session-panel-CL3OYqfu.js → session-panel-BfBmOygH.js} +1 -1
  52. package/dist/assets/{snippets-panel-Cn-0B9yk.js → snippets-panel-DFpwFaWJ.js} +1 -1
  53. package/dist/assets/{state-DLmIk5GZ.js → state-Cobrzbya.js} +1 -1
  54. package/dist/assets/{switch-CdyDieX7.js → switch-B9gVGTJZ.js} +1 -1
  55. package/dist/assets/{textarea-y9GCP54I.js → textarea-jiqvHbIW.js} +1 -1
  56. package/dist/assets/{tracing-CggYKKpk.js → tracing-4xyeRkef.js} +1 -1
  57. package/dist/assets/{tracing-panel-BYfwYVLg.js → tracing-panel-BDIuiiE0.js} +2 -2
  58. package/dist/assets/{useAddCell-BGHDEB1g.js → useAddCell-CcIU5IMe.js} +1 -1
  59. package/dist/assets/{useCellActionButton-BbGQe83V.js → useCellActionButton-Dm7uUKBA.js} +1 -1
  60. package/dist/assets/{useDeleteCell-DG1VBfwX.js → useDeleteCell-D_w3puRP.js} +1 -1
  61. package/dist/assets/{useDependencyPanelTab-luj9RYTO.js → useDependencyPanelTab-gBdSBaO_.js} +1 -1
  62. package/dist/assets/{useNotebookActions-DN_VG9PO.js → useNotebookActions-CBHB0ad_.js} +1 -1
  63. package/dist/assets/{useRunCells--USKPEQy.js → useRunCells-rq1fmMiQ.js} +1 -1
  64. package/dist/assets/{useSplitCell-DGXfa81A.js → useSplitCell-47X7VRZm.js} +1 -1
  65. package/dist/index.html +25 -25
  66. package/package.json +1 -1
  67. package/src/__mocks__/requests.ts +0 -1
  68. package/src/core/cells/cells.ts +3 -1
  69. package/src/core/edit-app.tsx +0 -5
  70. package/src/core/islands/bridge.ts +0 -1
  71. package/src/core/islands/main.ts +0 -1
  72. package/src/core/network/requests-lazy.ts +0 -1
  73. package/src/core/network/requests-network.ts +0 -9
  74. package/src/core/network/requests-static.ts +0 -1
  75. package/src/core/network/requests-toasting.tsx +0 -1
  76. package/src/core/network/types.ts +0 -2
  77. package/src/core/wasm/bridge.ts +0 -1
  78. package/src/core/websocket/useMarimoKernelConnection.tsx +1 -4
  79. package/src/core/cells/effects.ts +0 -42
@@ -1 +1 @@
1
- import{s as z}from"./chunk-LvLJmgfZ.js";import{l as X}from"./useEvent-O0nX5vok.js";import{t as Z}from"./react-Bj1aDYRI.js";import{jt as D}from"./cells-B8rT_yJt.js";import{t as E}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-Dybmv5gR.js";import{C as oe,v as ne,w as Q}from"./utils-tNbLd14P.js";import{S as re}from"./config-DRN1Q5Ol.js";import{t as ie}from"./jsx-runtime-icT_Ltz2.js";import{t as ce}from"./button-Ej3vmCIF.js";import{l as R}from"./once-CJOnx12W.js";import{r as U}from"./requests-Bgjtqo_1.js";import{t as de}from"./createLucideIcon-Cm-Z7dYr.js";import{t as he}from"./x-CdLP7-v3.js";import{r as I}from"./input-6cciao_l.js";import{t as B}from"./settings-dVFT0AvU.js";import{a as M,c as L,d as A,g as me,i as xe,l as F,o as P,p as pe,u as S}from"./textarea-y9GCP54I.js";import{t as fe}from"./use-toast-BhMe50aT.js";import{l as Y}from"./select-dNVaT2hT.js";import{t as K}from"./tooltip-BCGmr4TU.js";import{o as ue}from"./alert-dialog-BfHy00ko.js";import{c as je,l as ve,n as ge,t as V}from"./dialog-Dr3dl0Mn.js";import{t as be}from"./VisuallyHidden-ClKJEaNK.js";import{i as we,r as ye,t as Ne}from"./popover-C5P0DZBj.js";import{n as Ce}from"./useDebounce-BvOHu0CE.js";import{n as ke}from"./ImperativeModal-DyRrGcKH.js";import{t as O}from"./kbd-DozzbQaK.js";import{t as _e}from"./links-DXQarNcJ.js";import{t as G}from"./Inputs-W60db12_.js";var Se=de("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=E(),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}=U(),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)(ue,{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)(he,{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)(K,{content:u,children:d}),e[12]=d,e[13]=u,e[14]=x):x=e[14],x};function Le(){window.close()}var J=E(),W=z(Z(),1),Ae=100;const Fe=()=>{let t=(0,J.c)(37),[e,a]=ne(),{saveAppConfig:f}=U(),r=(0,W.useId)(),i=(0,W.useId)(),u;t[0]===Symbol.for("react.memo_cache_sentinel")?(u=pe(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=me(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=Ce(j,Ae),c;t[8]===e.width?c=t[9]:(c=[e.width],t[8]=e.width,t[9]=c),(0,W.useEffect)(Pe,c);let n;t[10]!==m||t[11]!==l?(n=l.handleSubmit(m),t[10]=m,t[11]=l,t[12]=n):n=t[12];let d;t[13]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsxs)("div",{children:[(0,s.jsx)(ae,{children:"Notebook Settings"}),(0,s.jsx)(se,{children:"Configure how your notebook or application looks and behaves."})]}),t[13]=d):d=t[13];let x;t[14]===l.control?x=t[15]:(x=(0,s.jsxs)(H,{title:"Display",children:[(0,s.jsx)(L,{control:l.control,name:"width",render:He}),(0,s.jsx)(L,{control:l.control,name:"app_title",render:Ee})]}),t[14]=l.control,t[15]=x);let h;t[16]===l.control?h=t[17]:(h=(0,s.jsxs)(H,{title:"Custom Files",children:[(0,s.jsx)(L,{control:l.control,name:"css_file",render:Ie}),(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)(H,{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)(F,{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)(D,{id:r,"data-testid":"html-checkbox",checked:_.value.includes("html"),onCheckedChange:()=>{_.onChange(R(_.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)(D,{id:i,"data-testid":"ipynb-checkbox",checked:_.value.includes("ipynb"),onCheckedChange:()=>{_.onChange(R(_.value,"ipynb"))}}),(0,s.jsx)(S,{htmlFor:i,children:"IPYNB"})]})]})}),(0,s.jsx)(A,{})]}),(0,s.jsxs)(P,{children:["When enabled, marimo will periodically save this notebook in your selected formats (HTML, IPYNB) to a folder named"," ",(0,s.jsx)(O,{className:"inline",children:"__marimo__"})," next to your notebook file."]})]})},t[20]=r,t[21]=i,t[22]=N):N=t[22];let v;t[23]!==l.control||t[24]!==N?(v=(0,s.jsx)(H,{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)(xe,{...l,children:g}),t[34]=l,t[35]=g,t[36]=k):k=t[36],k};var H=t=>{let e=(0,J.c)(5),{title:a,children:f}=t,r;e[0]===a?r=e[1]:(r=(0,s.jsx)("h3",{className:"text-base font-semibold mb-1",children:a}),e[0]=a,e[1]=r);let i;return e[2]!==f||e[3]!==r?(i=(0,s.jsxs)("div",{className:"flex flex-col gap-y-2",children:[r,f]}),e[2]=f,e[3]=r,e[4]=i):i=e[4],i};function Pe(){window.dispatchEvent(new Event("resize"))}function qe(t){return(0,s.jsx)("option",{value:t,children:t},t)}function He(t){let{field:e}=t;return(0,s.jsxs)(F,{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)(Y,{"data-testid":"app-width-select",onChange:a=>e.onChange(a.target.value),value:e.value,disabled:e.disabled,className:"inline-flex mr-2",children:$().map(qe)})}),(0,s.jsx)(A,{})]})}function Ee(t){let{field:e}=t;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(F,{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)(I,{...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)(P,{children:"The application title is put in the title tag in the HTML code and typically displayed in the title bar of the browser window."})]})}function Ie(t){let{field:e}=t;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(F,{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)(I,{...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)(P,{children:"A filepath to a custom css file to be injected into the notebook."})]})}function Oe(t){let{field:e}=t;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(F,{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)(I,{...e,value:e.value??"",placeholder:"head.html",onChange:a=>{e.onChange(a.target.value)}})}),(0,s.jsx)(A,{})]}),(0,s.jsxs)(P,{children:["A filepath to an HTML file to be injected into the"," ",(0,s.jsx)(O,{className:"inline",children:"<head/>"})," section of the notebook. Use this to add analytics, custom fonts, meta tags, or external scripts."]})]})}function We(t){return(0,s.jsx)("option",{value:t.value,children:t.label},t.value)}function ze(t){let{field:e}=t;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(F,{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)(Y,{"data-testid":"sql-output-select",onChange:a=>{e.onChange(a.target.value),fe({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)(P,{children:["The Python type returned by a SQL cell. For best performance with large datasets, we recommend using"," ",(0,s.jsx)(O,{className:"inline",children:"native"}),". See the"," ",(0,s.jsx)(_e,{href:"https://docs.marimo.io/guides/working_with_data/sql",children:"SQL guide"})," ","for more information."]})]})}var De=E();const Qe=t=>{let e=(0,De.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)(B,{strokeWidth:1.8}),e[0]=j):j=e[0];let m;e[1]===b?m=e[2]:(m=(0,s.jsx)(K,{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)(ge,{className:"w-[90vw] h-[90vh] overflow-hidden sm:max-w-5xl top-[5vh] p-0",children:[(0,s.jsx)(be,{children:(0,s.jsx)(je,{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)(ve,{children:n}),e[8]=n,e[9]=T);let q;return e[10]!==o||e[11]!==l||e[12]!==T?(q=(0,s.jsxs)(V,{open:l,onOpenChange:o,children:[T,x]}),e[10]=o,e[11]=l,e[12]=T,e[13]=q):q=e[13],q}let h;e[14]===n?h=e[15]:(h=(0,s.jsx)(we,{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)(Fe,{}),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)(B,{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)(ye,{className:"w-[650px] overflow-auto max-h-[80vh] max-w-[80vw]",align:"end",side:"bottom",onFocusOutside:Re,children:[y,N,(0,s.jsxs)(ce,{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)(Ne,{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-O0nX5vok.js";import{t as Z}from"./react-Bj1aDYRI.js";import{jt as D}from"./cells-Ir3O9-uE.js";import{t as E}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-Cl-qIUat.js";import{C as oe,v as ne,w as Q}from"./utils-tNbLd14P.js";import{S as re}from"./config-DRN1Q5Ol.js";import{t as ie}from"./jsx-runtime-icT_Ltz2.js";import{t as ce}from"./button-Ej3vmCIF.js";import{l as R}from"./once-CJOnx12W.js";import{r as U}from"./requests-Bgjtqo_1.js";import{t as de}from"./createLucideIcon-Cm-Z7dYr.js";import{t as he}from"./x-CdLP7-v3.js";import{r as I}from"./input-6cciao_l.js";import{t as B}from"./settings-dVFT0AvU.js";import{a as M,c as L,d as A,g as me,i as xe,l as F,o as P,p as pe,u as S}from"./textarea-jiqvHbIW.js";import{t as fe}from"./use-toast-BhMe50aT.js";import{l as Y}from"./select-dNVaT2hT.js";import{t as K}from"./tooltip-BCGmr4TU.js";import{o as ue}from"./alert-dialog-BfHy00ko.js";import{c as je,l as ve,n as ge,t as V}from"./dialog-Dr3dl0Mn.js";import{t as be}from"./VisuallyHidden-ClKJEaNK.js";import{i as we,r as ye,t as Ne}from"./popover-C5P0DZBj.js";import{n as Ce}from"./useDebounce-BvOHu0CE.js";import{n as ke}from"./ImperativeModal-DyRrGcKH.js";import{t as O}from"./kbd-DozzbQaK.js";import{t as _e}from"./links-DXQarNcJ.js";import{t as G}from"./Inputs-W60db12_.js";var Se=de("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=E(),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}=U(),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)(ue,{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)(he,{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)(K,{content:u,children:d}),e[12]=d,e[13]=u,e[14]=x):x=e[14],x};function Le(){window.close()}var J=E(),W=z(Z(),1),Ae=100;const Fe=()=>{let t=(0,J.c)(37),[e,a]=ne(),{saveAppConfig:f}=U(),r=(0,W.useId)(),i=(0,W.useId)(),u;t[0]===Symbol.for("react.memo_cache_sentinel")?(u=pe(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=me(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=Ce(j,Ae),c;t[8]===e.width?c=t[9]:(c=[e.width],t[8]=e.width,t[9]=c),(0,W.useEffect)(Pe,c);let n;t[10]!==m||t[11]!==l?(n=l.handleSubmit(m),t[10]=m,t[11]=l,t[12]=n):n=t[12];let d;t[13]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsxs)("div",{children:[(0,s.jsx)(ae,{children:"Notebook Settings"}),(0,s.jsx)(se,{children:"Configure how your notebook or application looks and behaves."})]}),t[13]=d):d=t[13];let x;t[14]===l.control?x=t[15]:(x=(0,s.jsxs)(H,{title:"Display",children:[(0,s.jsx)(L,{control:l.control,name:"width",render:He}),(0,s.jsx)(L,{control:l.control,name:"app_title",render:Ee})]}),t[14]=l.control,t[15]=x);let h;t[16]===l.control?h=t[17]:(h=(0,s.jsxs)(H,{title:"Custom Files",children:[(0,s.jsx)(L,{control:l.control,name:"css_file",render:Ie}),(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)(H,{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)(F,{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)(D,{id:r,"data-testid":"html-checkbox",checked:_.value.includes("html"),onCheckedChange:()=>{_.onChange(R(_.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)(D,{id:i,"data-testid":"ipynb-checkbox",checked:_.value.includes("ipynb"),onCheckedChange:()=>{_.onChange(R(_.value,"ipynb"))}}),(0,s.jsx)(S,{htmlFor:i,children:"IPYNB"})]})]})}),(0,s.jsx)(A,{})]}),(0,s.jsxs)(P,{children:["When enabled, marimo will periodically save this notebook in your selected formats (HTML, IPYNB) to a folder named"," ",(0,s.jsx)(O,{className:"inline",children:"__marimo__"})," next to your notebook file."]})]})},t[20]=r,t[21]=i,t[22]=N):N=t[22];let v;t[23]!==l.control||t[24]!==N?(v=(0,s.jsx)(H,{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)(xe,{...l,children:g}),t[34]=l,t[35]=g,t[36]=k):k=t[36],k};var H=t=>{let e=(0,J.c)(5),{title:a,children:f}=t,r;e[0]===a?r=e[1]:(r=(0,s.jsx)("h3",{className:"text-base font-semibold mb-1",children:a}),e[0]=a,e[1]=r);let i;return e[2]!==f||e[3]!==r?(i=(0,s.jsxs)("div",{className:"flex flex-col gap-y-2",children:[r,f]}),e[2]=f,e[3]=r,e[4]=i):i=e[4],i};function Pe(){window.dispatchEvent(new Event("resize"))}function qe(t){return(0,s.jsx)("option",{value:t,children:t},t)}function He(t){let{field:e}=t;return(0,s.jsxs)(F,{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)(Y,{"data-testid":"app-width-select",onChange:a=>e.onChange(a.target.value),value:e.value,disabled:e.disabled,className:"inline-flex mr-2",children:$().map(qe)})}),(0,s.jsx)(A,{})]})}function Ee(t){let{field:e}=t;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(F,{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)(I,{...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)(P,{children:"The application title is put in the title tag in the HTML code and typically displayed in the title bar of the browser window."})]})}function Ie(t){let{field:e}=t;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(F,{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)(I,{...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)(P,{children:"A filepath to a custom css file to be injected into the notebook."})]})}function Oe(t){let{field:e}=t;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(F,{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)(I,{...e,value:e.value??"",placeholder:"head.html",onChange:a=>{e.onChange(a.target.value)}})}),(0,s.jsx)(A,{})]}),(0,s.jsxs)(P,{children:["A filepath to an HTML file to be injected into the"," ",(0,s.jsx)(O,{className:"inline",children:"<head/>"})," section of the notebook. Use this to add analytics, custom fonts, meta tags, or external scripts."]})]})}function We(t){return(0,s.jsx)("option",{value:t.value,children:t.label},t.value)}function ze(t){let{field:e}=t;return(0,s.jsxs)("div",{className:"flex flex-col gap-y-1",children:[(0,s.jsxs)(F,{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)(Y,{"data-testid":"sql-output-select",onChange:a=>{e.onChange(a.target.value),fe({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)(P,{children:["The Python type returned by a SQL cell. For best performance with large datasets, we recommend using"," ",(0,s.jsx)(O,{className:"inline",children:"native"}),". See the"," ",(0,s.jsx)(_e,{href:"https://docs.marimo.io/guides/working_with_data/sql",children:"SQL guide"})," ","for more information."]})]})}var De=E();const Qe=t=>{let e=(0,De.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)(B,{strokeWidth:1.8}),e[0]=j):j=e[0];let m;e[1]===b?m=e[2]:(m=(0,s.jsx)(K,{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)(ge,{className:"w-[90vw] h-[90vh] overflow-hidden sm:max-w-5xl top-[5vh] p-0",children:[(0,s.jsx)(be,{children:(0,s.jsx)(je,{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)(ve,{children:n}),e[8]=n,e[9]=T);let q;return e[10]!==o||e[11]!==l||e[12]!==T?(q=(0,s.jsxs)(V,{open:l,onOpenChange:o,children:[T,x]}),e[10]=o,e[11]=l,e[12]=T,e[13]=q):q=e[13],q}let h;e[14]===n?h=e[15]:(h=(0,s.jsx)(we,{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)(Fe,{}),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)(B,{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)(ye,{className:"w-[650px] overflow-auto max-h-[80vh] max-w-[80vw]",align:"end",side:"bottom",onFocusOutside:Re,children:[y,N,(0,s.jsxs)(ce,{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)(Ne,{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-C9dMIWjp.js","./loro_wasm_bg-DbCRx7th.js","./chunk-LvLJmgfZ.js"])))=>i.map(i=>d[i]);
2
- var td=Object.defineProperty;var Aa=re=>{throw TypeError(re)};var nd=(re,z,pe)=>z in re?td(re,z,{enumerable:!0,configurable:!0,writable:!0,value:pe}):re[z]=pe;var p=(re,z,pe)=>nd(re,typeof z!="symbol"?z+"":z,pe),rd=(re,z,pe)=>z.has(re)||Aa("Cannot "+pe);var Ta=(re,z,pe)=>(rd(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-O0nX5vok.js";import{t as od}from"./react-Bj1aDYRI.js";import{An as ad,Ar as id,B as Oa,Bt as gr,Cn as sd,Ct as ld,E as vn,F as cd,G as _a,Gt as Da,H as Ua,Ir as hr,Jt as ud,Mt as Ba,Nn as ja,Pn as dd,Q as fd,Qt as En,Rn as md,Rr as pd,U as Pa,Ur as gd,Ut as br,V as hd,Wr as Ma,Wt as Ra,Yt as bd,_t as Nn,a as Ga,b as Ze,bt as Ot,d as Ja,dn as yd,et as wd,fn as vd,gn as yr,gt as wr,h as vr,ht as Ed,ir as Nd,jn as kd,jt as Cd,kn as Sd,li as xd,ln as Ad,on as Td,ot as Er,pn as Id,qt as Fd,si as Wa,st as Ld,tn as Od,u as Va,vi as kn,vt as _d,yt as Dd,zr as Ud,zt as Bd,__tla as jd}from"./cells-B8rT_yJt.js";import{P as $a,R as Pd,k as Md,w as Rd}from"./zod-H_cgTO0M.js";import{t as Re}from"./compiler-runtime-B3qBwwSJ.js";import{C as Gd,f as Jd,m as Wd,p as Vd,t as $d,v as Hd}from"./ai-model-dropdown-Dybmv5gR.js";import{a as Ha,f as Nr,h as qd,m as We,t as zd}from"./useEventListener-Dy81QR4n.js";import{t as _t}from"./invariant-CQUIhlu2.js";import{S as kr,h as qa,m as Kd,o as Yd,p as za,s as Ka}from"./utils-tNbLd14P.js";import{S as Xd,d as Qd,h as pt,o as Zd,r as Ya,x as Dt,y as Xa}from"./config-DRN1Q5Ol.js";import{a as ef,n as Qa,t as tf}from"./switch-CdyDieX7.js";import{n as nf}from"./globals-B7uZUVXG.js";import{t as rf}from"./ErrorBoundary-Ba0LbbH4.js";import{t as of}from"./jsx-runtime-icT_Ltz2.js";import{r as Cr,t as at}from"./button-Ej3vmCIF.js";import{t as it}from"./cn-BoaCR37F.js";import{Bt as gt,Ct as Za,Dt as af,E as sf,Ft as Sr,H as ei,Ht as Ut,I as lf,J as l,Jt as fe,Kt as cf,Lt as Cn,Mt as uf,P as df,St as Ge,V as ti,Vt as xr,Wt as st,Yt as Ve,Zt as Bt,_ as ff,a as mf,at as P,bt as pf,ct as ze,en as Sn,ft as gf,it as hf,lt as xn,m as bf,pt as yf,rt as q,st as wf,vt as vf,w as Ef,wt as Nf,yt as kf,zt as Cf}from"./dist-B_cxg-E4.js";import{C as Sf,D as xf,_ as Af,a as Tf,c as If,n as Ar,r as Ff,v as Lf,x as Of,y as _f}from"./dist-CtXb4bUU.js";import{C as Df,__tla as Uf}from"./JsonOutput-CQSoWTC4.js";import{c as ni,n as Bf}from"./once-CJOnx12W.js";import{t as Tr}from"./createReducer-Dvh64vBW.js";import{a as jf,c as Pf,f as An,h as Mf,i as Rf,l as jt,n as ri,o as Gf,t as Jf}from"./dist-D0Vj4Kqc.js";import{t as Wf}from"./main-DrBRErTM.js";import{r as Tn,t as Vf}from"./requests-Bgjtqo_1.js";import{t as $f}from"./createLucideIcon-Cm-Z7dYr.js";import{r as oi,t as Hf,__tla as qf}from"./layout-BJa4d_WQ.js";import{t as zf}from"./x-CdLP7-v3.js";import{r as Kf}from"./download-CNJtCoWG.js";import{t as Yf}from"./circle-check-CbaVeozR.js";import{A as Xf,E as ai,O as Qf,T as Zf,a as ii,d as em,n as tm,o as nm,r as si,s as rm,x as om}from"./add-cell-with-ai-u_AX7UAd.js";import{r as am,t as im}from"./file-icons-I3TgHXBH.js";import{n as sm}from"./spinner-C5JoisA7.js";import{t as li}from"./save-BNIs1Xrf.js";import{I as ci,P as lm}from"./input-6cciao_l.js";import{t as cm}from"./sparkles-DWCvxqYL.js";import{t as um}from"./preload-helper-TXkS1QI3.js";import{t as ht}from"./use-toast-BhMe50aT.js";import{n as Ke}from"./paths-bMgYkaP2.js";import{t as dm}from"./session-DKzpcHdK.js";import{r as fm}from"./useTheme-BYu4ZPLV.js";import{t as In}from"./tooltip-BCGmr4TU.js";import{c as ui,i as di,n as fi,r as mm}from"./dialog-Dr3dl0Mn.js";import{k as pm}from"./usePress-_02M8YzR.js";import{a as gm,r as hm,t as bm}from"./popover-C5P0DZBj.js";import{n as mi}from"./ImperativeModal-DyRrGcKH.js";import{r as ym}from"./errors-Bhwg_4_Q.js";import{n as wm}from"./copy-CIPmwSuj.js";import{a as vm}from"./useRunCells--USKPEQy.js";import{t as X}from"./extends-tyH9bzbk.js";import{t as Pt}from"./objectWithoutPropertiesLoose-D67umz3-.js";import{t as Em}from"./kbd-DozzbQaK.js";import{a as Ir}from"./useInstallPackage-DYIBbH-R.js";import{i as Nm,n as pi}from"./state-DLmIk5GZ.js";import{a as km,o as Cm}from"./cell-link-DV3G9zVQ.js";import{n as Sm}from"./useAsyncData-VEt7lMhG.js";import{a as xm,o as gi,r as Am,s as hi,t as Tm}from"./command-DvKBTmQJ.js";import{r as bi}from"./html-to-image-BtnUxAf2.js";import{a as Im}from"./focus-DWfOBGUg.js";import{a as yi}from"./renderShortcut-BcNNtnIV.js";import{t as Fr}from"./label-KlZhD0Wz.js";import{n as Fm,t as Lm}from"./icons-CAcY8GzB.js";import{n as bt}from"./esm-BMWduMhT.js";import{t as wi}from"./dist-SDxzhwJU.js";import{n as Lr,t as vi}from"./useDeleteCell-DG1VBfwX.js";import{t as Om}from"./useSplitCell-DGXfa81A.js";import{co as _m,do as Or,fo as Dm,ft as Um,go as yt,ho as Ei,lo as _r,mo as Ni,oo as Bm,po as jm,so as ki,uo as Ci,__tla as Pm}from"./loro_wasm_bg-DbCRx7th.js";import{t as Mm}from"./ws-BYrDQlXa.js";import{t as Si}from"./Inputs-W60db12_.js";import{n as Rm}from"./hooks-dmmemJB9.js";let Fn,Dr,xi,Ur,lt,Br,be,Mt,Rt,Ai,Ti,Ii,Fi,Li,Ln,Oi,On,_i,_n,Gm=Promise.all([(()=>{try{return jd}catch{}})(),(()=>{try{return Uf}catch{}})(),(()=>{try{return qf}catch{}})(),(()=>{try{return Pm}catch{}})()]).then(async()=>{var hn,xa,we,ve,Ee,Ne,ke,Ce,Se,xe,Ae,Te,Ie,Fe,Le,Oe,_e,De,Ue,Be,je;var re=$f("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=>Sn(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 Di=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<Di)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 Dn={mac:"\u2318",windows:"\u229E Win",default:"Ctrl"};function Ui(){return navigator.platform.startsWith("Mac")?Dn.mac:navigator.platform.startsWith("Win")?Dn.windows:Dn.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 xn{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(`
2
+ var td=Object.defineProperty;var Aa=re=>{throw TypeError(re)};var nd=(re,z,pe)=>z in re?td(re,z,{enumerable:!0,configurable:!0,writable:!0,value:pe}):re[z]=pe;var p=(re,z,pe)=>nd(re,typeof z!="symbol"?z+"":z,pe),rd=(re,z,pe)=>z.has(re)||Aa("Cannot "+pe);var Ta=(re,z,pe)=>(rd(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-O0nX5vok.js";import{t as od}from"./react-Bj1aDYRI.js";import{An as ad,Ar as id,B as Oa,Bt as gr,Cn as sd,Ct as ld,E as vn,F as cd,G as _a,Gt as Da,H as Ua,Ir as hr,Jt as ud,Mt as Ba,Nn as ja,Pn as dd,Q as fd,Qt as En,Rn as md,Rr as pd,U as Pa,Ur as gd,Ut as br,V as hd,Wr as Ma,Wt as Ra,Yt as bd,_t as Nn,a as Ga,b as Ze,bt as Ot,d as Ja,dn as yd,et as wd,fn as vd,gn as yr,gt as wr,h as vr,ht as Ed,ir as Nd,jn as kd,jt as Cd,kn as Sd,li as xd,ln as Ad,on as Td,ot as Er,pn as Id,qt as Fd,si as Wa,st as Ld,tn as Od,u as Va,vi as kn,vt as _d,yt as Dd,zr as Ud,zt as Bd,__tla as jd}from"./cells-Ir3O9-uE.js";import{P as $a,R as Pd,k as Md,w as Rd}from"./zod-H_cgTO0M.js";import{t as Re}from"./compiler-runtime-B3qBwwSJ.js";import{C as Gd,f as Jd,m as Wd,p as Vd,t as $d,v as Hd}from"./ai-model-dropdown-Cl-qIUat.js";import{a as Ha,f as Nr,h as qd,m as We,t as zd}from"./useEventListener-Dy81QR4n.js";import{t as _t}from"./invariant-CQUIhlu2.js";import{S as kr,h as qa,m as Kd,o as Yd,p as za,s as Ka}from"./utils-tNbLd14P.js";import{S as Xd,d as Qd,h as pt,o as Zd,r as Ya,x as Dt,y as Xa}from"./config-DRN1Q5Ol.js";import{a as ef,n as Qa,t as tf}from"./switch-B9gVGTJZ.js";import{n as nf}from"./globals-DuAfXgSM.js";import{t as rf}from"./ErrorBoundary-Ba0LbbH4.js";import{t as of}from"./jsx-runtime-icT_Ltz2.js";import{r as Cr,t as at}from"./button-Ej3vmCIF.js";import{t as it}from"./cn-BoaCR37F.js";import{Bt as gt,Ct as Za,Dt as af,E as sf,Ft as Sr,H as ei,Ht as Ut,I as lf,J as l,Jt as fe,Kt as cf,Lt as Cn,Mt as uf,P as df,St as Ge,V as ti,Vt as xr,Wt as st,Yt as Ve,Zt as Bt,_ as ff,a as mf,at as P,bt as pf,ct as ze,en as Sn,ft as gf,it as hf,lt as xn,m as bf,pt as yf,rt as q,st as wf,vt as vf,w as Ef,wt as Nf,yt as kf,zt as Cf}from"./dist-B_cxg-E4.js";import{C as Sf,D as xf,_ as Af,a as Tf,c as If,n as Ar,r as Ff,v as Lf,x as Of,y as _f}from"./dist-CtXb4bUU.js";import{C as Df,__tla as Uf}from"./JsonOutput-B_6OsFJA.js";import{c as ni,n as Bf}from"./once-CJOnx12W.js";import{t as Tr}from"./createReducer-Dvh64vBW.js";import{a as jf,c as Pf,f as An,h as Mf,i as Rf,l as jt,n as ri,o as Gf,t as Jf}from"./dist-D0Vj4Kqc.js";import{t as Wf}from"./main-DrBRErTM.js";import{r as Tn,t as Vf}from"./requests-Bgjtqo_1.js";import{t as $f}from"./createLucideIcon-Cm-Z7dYr.js";import{r as oi,t as Hf,__tla as qf}from"./layout-C2zfXBrd.js";import{t as zf}from"./x-CdLP7-v3.js";import{r as Kf}from"./download-C2P9kUtq.js";import{t as Yf}from"./circle-check-CbaVeozR.js";import{A as Xf,E as ai,O as Qf,T as Zf,a as ii,d as em,n as tm,o as nm,r as si,s as rm,x as om}from"./add-cell-with-ai-C75dyXgo.js";import{r as am,t as im}from"./file-icons-B3ygedtV.js";import{n as sm}from"./spinner-C5JoisA7.js";import{t as li}from"./save-BNIs1Xrf.js";import{I as ci,P as lm}from"./input-6cciao_l.js";import{t as cm}from"./sparkles-DWCvxqYL.js";import{t as um}from"./preload-helper-TXkS1QI3.js";import{t as ht}from"./use-toast-BhMe50aT.js";import{n as Ke}from"./paths-bMgYkaP2.js";import{t as dm}from"./session-DKzpcHdK.js";import{r as fm}from"./useTheme-BYu4ZPLV.js";import{t as In}from"./tooltip-BCGmr4TU.js";import{c as ui,i as di,n as fi,r as mm}from"./dialog-Dr3dl0Mn.js";import{k as pm}from"./usePress-_02M8YzR.js";import{a as gm,r as hm,t as bm}from"./popover-C5P0DZBj.js";import{n as mi}from"./ImperativeModal-DyRrGcKH.js";import{r as ym}from"./errors-Bhwg_4_Q.js";import{n as wm}from"./copy-CIPmwSuj.js";import{a as vm}from"./useRunCells-rq1fmMiQ.js";import{t as X}from"./extends-tyH9bzbk.js";import{t as Pt}from"./objectWithoutPropertiesLoose-D67umz3-.js";import{t as Em}from"./kbd-DozzbQaK.js";import{a as Ir}from"./useInstallPackage-DYIBbH-R.js";import{i as Nm,n as pi}from"./state-Cobrzbya.js";import{a as km,o as Cm}from"./cell-link-Bdbjts-L.js";import{n as Sm}from"./useAsyncData-VEt7lMhG.js";import{a as xm,o as gi,r as Am,s as hi,t as Tm}from"./command-DccONw-I.js";import{r as bi}from"./html-to-image-B1AmbwBb.js";import{a as Im}from"./focus-DXqWRa5J.js";import{a as yi}from"./renderShortcut-BcNNtnIV.js";import{t as Fr}from"./label-KlZhD0Wz.js";import{n as Fm,t as Lm}from"./icons-CAcY8GzB.js";import{n as bt}from"./esm-BMWduMhT.js";import{t as wi}from"./dist-SDxzhwJU.js";import{n as Lr,t as vi}from"./useDeleteCell-D_w3puRP.js";import{t as Om}from"./useSplitCell-47X7VRZm.js";import{co as _m,do as Or,fo as Dm,ft as Um,go as yt,ho as Ei,lo as _r,mo as Ni,oo as Bm,po as jm,so as ki,uo as Ci,__tla as Pm}from"./loro_wasm_bg-DbCRx7th.js";import{t as Mm}from"./ws-BYrDQlXa.js";import{t as Si}from"./Inputs-W60db12_.js";import{n as Rm}from"./hooks-m-Uf6FNW.js";let Fn,Dr,xi,Ur,lt,Br,be,Mt,Rt,Ai,Ti,Ii,Fi,Li,Ln,Oi,On,_i,_n,Gm=Promise.all([(()=>{try{return jd}catch{}})(),(()=>{try{return Uf}catch{}})(),(()=>{try{return qf}catch{}})(),(()=>{try{return Pm}catch{}})()]).then(async()=>{var hn,xa,we,ve,Ee,Ne,ke,Ce,Se,xe,Ae,Te,Ie,Fe,Le,Oe,_e,De,Ue,Be,je;var re=$f("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=>Sn(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 Di=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<Di)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 Dn={mac:"\u2318",windows:"\u229E Win",default:"Ctrl"};function Ui(){return navigator.platform.startsWith("Mac")?Dn.mac:navigator.platform.startsWith("Win")?Dn.windows:Dn.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 xn{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 Sn(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 xn{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 xn{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(od(),1),Pn=()=>({entries:new Map}),{valueAtom:$r,useActions:Hr}=Tr(Pn,{submit:(e,t)=>{let{cellIds:n,deleteCell:r,deleteManyCells:o,store:a}=t,i=a.get(Ze),s=a.get(Sd),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()});_n=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])},_i=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 y,l as L,n as P,u as E}from"./useEvent-O0nX5vok.js";import{Dt as O,E as w,N as A,an as D,j as S,si as _,vi as T}from"./cells-B8rT_yJt.js";import{t as b}from"./compiler-runtime-B3qBwwSJ.js";import{m as $}from"./useEventListener-Dy81QR4n.js";import{d as F}from"./utils-tNbLd14P.js";import{r as N}from"./constants-Rz_lD4HK.js";import{h as q,x as B}from"./config-DRN1Q5Ol.js";import{t as H}from"./jsx-runtime-icT_Ltz2.js";import{t as M}from"./cn-BoaCR37F.js";import{r as R}from"./requests-Bgjtqo_1.js";import{n as U}from"./paths-bMgYkaP2.js";import{s as V}from"./session-DKzpcHdK.js";import{n as z}from"./ImperativeModal-DyRrGcKH.js";var G=b();function x(){return E(_)}function J(){let r=(0,G.c)(5),[t]=L(q),e=y(_),{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(H(),1);const h=r=>{let t=(0,p.c)(12),{className:e,cellId:s,variant:o,onClick:a,formatCellName:l,skipScroll:n}=r,i=A()[s]??"",C=S().inOrderIds.indexOf(s),{showCellIfHidden:d}=w(),g=l??W,c;t[0]===e?c=t[1]:(c=M("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(O(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=()=>D(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=T.create(r),o=document.getElementById(s),a=o==null?void 0:o.classList.contains("has-error");return o===null?($.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};
1
+ import{s as j}from"./chunk-LvLJmgfZ.js";import{d as y,l as L,n as P,u as E}from"./useEvent-O0nX5vok.js";import{Dt as O,E as w,N as A,an as D,j as S,si as _,vi as T}from"./cells-Ir3O9-uE.js";import{t as b}from"./compiler-runtime-B3qBwwSJ.js";import{m as $}from"./useEventListener-Dy81QR4n.js";import{d as F}from"./utils-tNbLd14P.js";import{r as N}from"./constants-Rz_lD4HK.js";import{h as q,x as B}from"./config-DRN1Q5Ol.js";import{t as H}from"./jsx-runtime-icT_Ltz2.js";import{t as M}from"./cn-BoaCR37F.js";import{r as R}from"./requests-Bgjtqo_1.js";import{n as U}from"./paths-bMgYkaP2.js";import{s as V}from"./session-DKzpcHdK.js";import{n as z}from"./ImperativeModal-DyRrGcKH.js";var G=b();function x(){return E(_)}function J(){let r=(0,G.c)(5),[t]=L(q),e=y(_),{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(H(),1);const h=r=>{let t=(0,p.c)(12),{className:e,cellId:s,variant:o,onClick:a,formatCellName:l,skipScroll:n}=r,i=A()[s]??"",C=S().inOrderIds.indexOf(s),{showCellIfHidden:d}=w(),g=l??W,c;t[0]===e?c=t[1]:(c=M("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(O(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=()=>D(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=T.create(r),o=document.getElementById(s),a=o==null?void 0:o.classList.contains("has-error");return o===null?($.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};
@@ -227,4 +227,4 @@ mark line col
227
227
  `]))));let c=this._buffer.match(this._osc_regex);if(c===null)return e.kind=pt.ESC,e.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),e;e.kind=pt.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=pt.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==pt.EOS||a.kind==pt.Incomplete)break;a.kind==pt.ESC||a.kind==pt.Unknown||(a.kind==pt.Text?n.push(this.transform_to_html(this.with_state(a))):a.kind==pt.SGR?this.process_ansi(a):a.kind==pt.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 h=parseInt(n.shift(),10);h>=0&&h<=255&&(s?this.fg=this.palette_256[h]:this.bg=this.palette_256[h])}if(c==="2"&&n.length>2){let h=parseInt(n.shift(),10),f=parseInt(n.shift(),10),g=parseInt(n.shift(),10);if(h>=0&&h<=255&&f>=0&&f<=255&&g>=0&&g<=255){let b={rgb:[h,f,g],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 h="",f="";return o.length&&(h=` class="${o.join(" ")}"`),a.length&&(f=` style="${a.join(";")}"`),`<span${f}${h}>${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 ny(e,...n){let a=e.raw[0].replace(/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,"");return new RegExp(a)}function i4(e,...n){let a=e.raw[0].replace(/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,"");return new RegExp(a,"g")}var o4,s4,l4,c4=new nm;Uu=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
229
  `)}catch(n){return be.error("Error parsing HTML content:",n),e}},Rw=function(e){if(!e)return"";try{return Uu(c4.ansi_to_html(e))}catch(n){return be.error("Error converting ANSI to plain text:",n),e}},Lm={startCase:e=>{if(!e)return"";if(typeof e!="string")throw be.error(e),TypeError(`Expected string, got ${typeof e}`);return/[A-Za-z]/.test(e)?v5(e):e},htmlEscape:e=>e&&e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;").replaceAll(`
230
- `," "),withTrailingSlash(e){return e.endsWith("/")?e:`${e}/`},withoutTrailingSlash(e){return e.endsWith("/")?e.slice(0,-1):e},withoutLeadingSlash(e){return e.startsWith("/")?e.slice(1):e},asString:e=>{if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}};var ry=!1;function u4(e){var o;let n=[],a=[e.console].filter(Boolean).flat();for(let s of a){let c=s.mimetype==="text/plain",h=s.mimetype==="text/html"||s.mimetype==="application/vnd.marimo+traceback";if(c||h){let f=s.channel==="stderr"||s.channel==="marimo-error";switch(s.channel){case"stdout":case"stderr":case"marimo-error":{let g=Lm.asString(s.data),b=h?Uu(g):g;n.push({timestamp:s.timestamp||Date.now(),level:f?"stderr":"stdout",message:b,cellId:e.cell_id});break}default:break}}}if(n.forEach(ay.log),a.length===0&&Xu((o=e.output)==null?void 0:o.mimetype)&&Array.isArray(e.output.data)){e.output.data.forEach(c=>{ay.log({level:"stderr",cellId:e.cell_id,timestamp:e.timestamp??0,message:JSON.stringify(c)})});let s=e.output.data.some(c=>c.type==="internal");!ry&&s&&(ry=!0,_l({title:"An internal error occurred",description:"See console for details.",className:"text-xs text-background bg-(--red-10) py-2 pl-3 *:flex *:gap-3"}))}return n}var ay={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`,`[${Hh(e.timestamp)}]`,`(${e.cellId}) ${e.message}`)}};Hh=function(e){try{return a4(e).toLocaleTimeString(void 0,{hour12:!0,hour:"numeric",minute:"numeric",second:"numeric"})}catch{return""}},Yw=function(e,n){let a=Yu(n);a?a.focus():be.warn(`[CellFocusManager] focusCellEditor: element not found: ${n}`)},Tw=function(e){let n=document.getElementById(En.create(e));n?ff(n):be.warn(`[CellFocusManager] focusCell: element not found: ${e}`)},Ew=function(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})},tm=function(){return document.activeElement instanceof HTMLElement&&document.activeElement.classList.contains("marimo-cell")};function ff(e){try{e.focus()}catch{be.warn("[CellFocusManager] element may not be focusable",e)}}em=function(e,n){let{retries:a,delay:o,initialDelay:s=0}=n,c=0,h=()=>{if(c<a){try{if(e())return}catch(f){be.error(`Error executing function on attempt ${c+1}, retrying`,{error:f})}c++,setTimeout(h,o)}};s>0?setTimeout(h,s):h()};function vs({cellId:e,cell:n,isCodeHidden:a,codeFocus:o,variableName:s}){var h;if(!n)return;let c=document.getElementById(En.create(e));if(!c){be.warn("scrollCellIntoView: element not found");return}if(tm()){ff(c);return}if(a)ff(c);else{let f=(h=n.current)==null?void 0:h.editorView;if(!f){be.warn("scrollCellIntoView: editor not found",e);return}if(f.hasFocus||!document.hasFocus())return;if(em(()=>(f.focus(),f.hasFocus),{retries:5,delay:20}),o==="top")f.dispatch({selection:{anchor:0,head:0}});else if(o==="bottom"){let g=f.state.doc.line(f.state.doc.lines);f.dispatch({selection:{anchor:g.from,head:g.from}})}else s&&Ju(f,s)}c.scrollIntoView({behavior:"smooth",block:"nearest"})}ex=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 d4(){let e=document.getElementById("App");e==null||e.scrollTo({top:e.scrollHeight,behavior:"smooth"})}function f4(){var e;(e=document.getElementById("App"))==null||e.scrollTo({top:0,behavior:"smooth"})}uw=function(e){let n=Yu(e);if(n!=null&&n.hasFocus){Og(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}`)},er=function({id:e,name:n="_",code:a="",lastCodeRun:o=null,lastExecutionTime:s=null,edited:c=!1,config:h,serializedEditorState:f=null}){return{id:e,config:h||{hide_code:!1,disabled:!1,column:null},name:n,code:a,edited:c,lastCodeRun:o,lastExecutionTime:s,serializedEditorState:f}};function p4(e){return{hide_code:!1,disabled:!1,column:null,...e}}tr=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 rc=gr();function iy(e){let n={column:0,hide_code:!1,disabled:!1};return{...e,cellData:{[ls]:er({id:ls,config:n}),...e.cellData},cellRuntime:{[ls]:tr(),...e.cellRuntime},cellHandles:{[ls]:(0,gt.createRef)(),...e.cellHandles}}}function h4(){return iy({cellIds:xl.from([]),cellData:{},cellRuntime:{},cellHandles:{},history:[],scrollKey:null,cellLogs:[],untouchedNewCells:new Set})}let m4,oy,g4,sy;({reducer:m4,addMiddleware:oy,createActions:g4,useActions:sy,valueAtom:Xe}=bl(h4,{createNewCell:(e,n)=>{var O;let{cellId:a,before:o,code:s,lastCodeRun:c=null,lastExecutionTime:h=null,autoFocus:f=!0,skipIfCodeExists:g=!1,hideCode:b=!1}=n,_,C;if(g){for(let M of e.cellIds.inOrderIds)if(((O=e.cellData[M])==null?void 0:O.code)===s)return e}if(a==="__end__"){let M=e.cellIds.atOrThrow(0);_=M.id,C=M.length}else if(typeof a=="string"){let M=e.cellIds.findWithId(a);_=M.id,C=M.topLevelIds.indexOf(a)}else if(a.type==="__end__"){let M=e.cellIds.get(a.columnId)||e.cellIds.atOrThrow(0);_=M.id,C=M.length}else throw Error("Invalid cellId");let S=n.newCellId||Xa.create(),E=o?C:C+1;return{...e,cellIds:e.cellIds.insertId(S,_,E),cellData:{...e.cellData,[S]:er({id:S,code:s,lastCodeRun:c,config:p4({hide_code:b}),lastExecutionTime:h,edited:!!s&&s!==c})},cellRuntime:{...e.cellRuntime,[S]:tr()},cellHandles:{...e.cellHandles,[S]:(0,gt.createRef)()},scrollKey:f?S:null,untouchedNewCells:b?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 f=e.cellIds.findWithId(a),g=e.cellIds.indexOf(f),b=s==="left"?g-1:g+1,_=e.cellIds.at(b);return _?{...e,cellIds:e.cellIds.moveAcrossColumns(f.id,a,_.id,void 0),scrollKey:a}:e}let c=e.cellIds.findWithId(a),h=c.indexOfOrThrow(a);return o&&h===0?{...e,cellIds:e.cellIds.moveWithinColumn(c.id,h,0),scrollKey:a}:!o&&h===c.length-1?{...e,cellIds:e.cellIds.moveWithinColumn(c.id,h,c.length-1),scrollKey:a}:o?{...e,cellIds:e.cellIds.moveWithinColumn(c.id,h,h-1),scrollKey:a}:{...e,cellIds:e.cellIds.moveWithinColumn(c.id,h,h+1),scrollKey:a}},dropCellOverCell:(e,n)=>{let{cellId:a,overCellId:o}=n,s=e.cellIds.findWithId(a),c=e.cellIds.findWithId(o),h=s.indexOfOrThrow(a),f=c.indexOfOrThrow(o);return s.id===c.id?h===f?e:{...e,cellIds:e.cellIds.moveWithinColumn(s.id,h,f),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),h;h=s==="before"?Sh(c-1,0,a.length-1):s==="after"?Sh(c+1,0,a.length-1):c;let f=a.atOrThrow(h);return vs({cellId:f,cell:e.cellHandles[f],isCodeHidden:bs(e,f),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 vs({cellId:a,cell:e.cellHandles[a],isCodeHidden:bs(e,a),codeFocus:void 0,variableName:void 0}),f4(),e},focusBottomCell:e=>{let n=e.cellIds.getColumns().at(-1);if(n===void 0||n.length===0)return e;let a=n.last();return vs({cellId:a,cell:e.cellHandles[a],isCodeHidden:bs(e,a),codeFocus:void 0,variableName:void 0}),d4(),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),h=a.length-1;return c===h?e:{...e,cellIds:e.cellIds.moveWithinColumn(a.id,c,h),scrollKey:s?o:null}},addColumn:(e,n)=>{let a=Xa.create();return{...e,cellIds:e.cellIds.addColumn(n.columnId,[a]),cellData:{...e.cellData,[a]:er({id:a})},cellRuntime:{...e.cellRuntime,[a]:tr()},cellHandles:{...e.cellHandles,[a]:(0,gt.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=e.cellIds.findWithId(a),s=o.indexOfOrThrow(a),c=s===0?1:s-1,h=null;o.length>1&&(h=o.atOrThrow(c));let f=(_=(b=e.cellHandles[a].current)==null?void 0:b.editorView)==null?void 0:_.state.toJSON({history:eT});f.doc=e.cellData[a].code,b4(a);let g=e.cellData[a];return{...e,cellIds:e.cellIds.deleteById(a),history:[...e.history,{name:g.name,serializedEditorState:f,column:o.id,index:s,isSetupCell:a===Hn,config:g.config}],scrollKey:h}},undoDeleteCell:e=>{if(e.history.length===0)return e;let{name:n,serializedEditorState:a={doc:""},column:o,index:s,isSetupCell:c,config:h}=e.history[e.history.length-1],f=c?Hn:Xa.create(),g=er({id:f,name:n,code:a.doc,edited:a.doc.trim().length>0,serializedEditorState:a,config:h});return{...e,cellIds:e.cellIds.insertId(f,o,s),cellData:{...e.cellData,[f]:g},cellRuntime:{...e.cellRuntime,[f]:tr()},cellHandles:{...e.cellHandles,[f]:(0,gt.createRef)()},history:e.history.slice(0,-1),scrollKey:f}},clearSerializedEditorState:(e,n)=>{let{cellId:a}=n;return fo({state:e,cellId:a,cellReducer:o=>({...o,serializedEditorState:null})})},updateCellCode:(e,n)=>{let{cellId:a,code:o,formattingChange:s}=n;return e.cellData[a]?fo({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 fo({state:e,cellId:a,cellReducer:s=>({...s,name:o})})},updateCellConfig:(e,n)=>{let{cellId:a,config:o}=n;return fo({state:e,cellId:a,cellReducer:s=>({...s,config:{...s.config,...o}})})},prepareForRun:(e,n)=>fo({state:ws({state:e,cellId:n.cellId,cellReducer:a=>JE(a)}),cellId:n.cellId,cellReducer:a=>({...a,edited:!1,lastCodeRun:a.code.trim()})}),handleCellMessage:(e,n)=>{let a=n.cell_id,o=ws({state:e,cellId:a,cellReducer:s=>GE(s,n)});return n.status==="queued"&&(o=fo({state:o,cellId:a,cellReducer:s=>({...s,lastCodeRun:s.code.trim(),edited:!1})})),{...o,cellLogs:[...o.cellLogs,...u4(n)]}},setCellIds:(e,n)=>{if(s5(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]=er({id:c})),c in e.cellRuntime||(o[c]=tr()),c in e.cellHandles||(s[c]=(0,gt.createRef)());return{...e,cellIds:xl.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:h,code:f,cellId:g,name:b,config:_})=>{if(!h)return er({id:g,code:f,name:b,config:_,lastCodeRun:n.codeIsStale?null:f,edited:n.codeIsStale&&f.trim().length>0});let C=n.codeIsStale?h.lastCodeRun:f,S=C?C.trim()!==f.trim():!!f;if(h.code.trim()===f.trim())return{...h,code:f,edited:S,lastCodeRun:C,...b!==void 0&&{name:b},..._!==void 0&&{config:_}};if(!Im()){let E=a.cellHandles[g].current;E!=null&&E.editorViewOrNull&&Qi(E.editorViewOrNull,f)}return{...h,code:f,edited:S,lastCodeRun:C,...b!==void 0&&{name:b},..._!==void 0&&{config:_}}};for(let h=0;h<n.ids.length;h++){let f=n.ids[h],g=n.codes[h];if(f===void 0||g===void 0)continue;let b=(s=n.names)==null?void 0:s[h],_=(c=n.configs)==null?void 0:c[h];a={...a,cellData:{...a.cellData,[f]:o({cell:a.cellData[f],code:g,cellId:f,name:b,config:_})}}}return a},setStdinResponse:(e,n)=>{let{cellId:a,response:o,outputIndex:s}=n;return ws({state:e,cellId:a,cellReducer:c=>{let h=[...c.consoleOutputs],f=h[s];return f.channel==="stdin"?(h[s]={channel:"stdin",mimetype:f.mimetype,data:f.data,timestamp:f.timestamp,response:o},{...c,interrupted:!1,consoleOutputs:h}):(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,tr()]));return iy({...e,cellIds:xl.fromIdsAndColumns(n.map(s=>[s.id,s.config.column])),cellData:a,cellRuntime:o,cellHandles:Object.fromEntries(n.map(s=>[s.id,(0,gt.createRef)()]))})},moveToNextCell:(e,n)=>{let{cellId:a,before:o,noCreate:s=!1}=n;if(a==="__scratch__")return e;let c=e.cellIds.findWithId(a),h=c.indexOfOrThrow(a),f=o?h-1:h+1,g=f===c.length,b=f===-1;if(g&&!s){let _=Xa.create();return{...e,cellIds:e.cellIds.insertId(_,c.id,f),cellData:{...e.cellData,[_]:er({id:_})},cellRuntime:{...e.cellRuntime,[_]:tr()},cellHandles:{...e.cellHandles,[_]:(0,gt.createRef)()},scrollKey:_}}if(b&&!s){let _=Xa.create();return{...e,cellIds:e.cellIds.insertId(_,c.id,0),cellData:{...e.cellData,[_]:er({id:_})},cellRuntime:{...e.cellRuntime,[_]:tr()},cellHandles:{...e.cellHandles,[_]:(0,gt.createRef)()},scrollKey:_}}if((g||b)&&s)return e;if(f>=0&&f<c.length){let _=c.atOrThrow(f);vs({cellId:_,cell:e.cellHandles[_],isCodeHidden:bs(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 vs({cellId:s,cell:e.cellHandles[s],isCodeHidden:bs(e,s),codeFocus:void 0,variableName:void 0}),{...e,scrollKey:null}},foldAll:e=>(Sx(Object.values(e.cellHandles).map(n=>{var a;return(a=n.current)==null?void 0:a.editorView})),e),unfoldAll:e=>(Ex(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(f=>e.cellRuntime[f].outline),c=J1(o.indexOfOrThrow(a),s);if(!c)return e;let h=o.atOrThrow(c[1]);return{...e,cellIds:e.cellIds.transformWithCellId(a,f=>f.collapse(a,h)),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(g=>e.cellRuntime[g].outline),o=[...n.nodes],s=[],c=[],h=o.length-1;for(;h>=0;){let g=J1(h,a);if(g){let b=h,_=g[1],C=s.find(O=>O.start<=_&&O.end===_);C&&(_=C.start),s.push({start:b,end:_});let S=n.atOrThrow(b),E=n.atOrThrow(_);c.push({id:S,until:E})}else c.push(null);h--}let f=c.reverse();return n.collapseAll(f)})}),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],h=e.cellHandles[a].current;if((h==null?void 0:h.editorView)==null)return e;let{beforeCursorCode:f,afterCursorCode:g}=BE(h.editorView);Qi(h.editorView,f);let b=Xa.create();return{...e,cellIds:e.cellIds.insertId(b,o.id,s+1),cellData:{...e.cellData,[a]:{...c,code:f,edited:!!f&&f.trim()!==((_=c.lastCodeRun)==null?void 0:_.trim())},[b]:er({id:b,code:g,edited:!!g})},cellRuntime:{...e.cellRuntime,[a]:{...e.cellRuntime[a],output:null,consoleOutputs:[]},[b]:tr()},cellHandles:{...e.cellHandles,[b]:(0,gt.createRef)()},scrollKey:b}},undoSplitCell:(e,n)=>{var h;let{cellId:a,snapshot:o}=n,s=e.cellData[a],c=e.cellHandles[a].current;return(c==null?void 0:c.editorView)==null?e:(Qi(c.editorView,o),{...e,cellIds:e.cellIds.transformWithCellId(a,f=>{let g=f.indexOfOrThrow(a)+1;return f.deleteAtIndex(g)}),cellData:{...e.cellData,[a]:{...s,code:o,edited:!!o&&(o==null?void 0:o.trim())!==((h=s.lastCodeRun)==null?void 0:h.trim())}},cellRuntime:{...e.cellRuntime,[a]:{...e.cellRuntime[a],output:null,consoleOutputs:[]}},cellHandles:{...e.cellHandles}})},clearCellOutput:(e,n)=>{let{cellId:a}=n;return ws({state:e,cellId:a,cellReducer:o=>({...o,output:null,consoleOutputs:[]})})},clearCellConsoleOutput:(e,n)=>{let{cellId:a}=n;return ws({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:Hn}:{...e,cellIds:e.cellIds.insertId(Hn,e.cellIds.atOrThrow(0).id,0),cellData:{...e.cellData,[Hn]:er({id:Hn,name:Hn,code:a,edited:!!a})},cellRuntime:{...e.cellRuntime,[Hn]:tr()},cellHandles:{...e.cellHandles,[Hn]:(0,gt.createRef)()},scrollKey:Hn}}})),oy(r4);function bs(e,n){return!!e.cellData[n].config.hide_code&&!e.untouchedNewCells.has(n)}function ws({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 fo({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)}c_=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,h)=>{let f={...a};return h===0&&(f.column=s),{...n[c].config,...f}})):e.cellIds.getColumns().flatMap(o=>o.inOrderIds.map(s=>({...n[s].config,...a})))},Ku=Se(e=>e(Xe).cellIds),B_=Se(e=>e(Ku).hasOnlyOneId()),r_=Se(e=>Kh(e(Xe)).length>0),Se(e=>Qh(e(Xe)).length>0);let ly;j_=Se(e=>ok(e(Xe))),X_=Se(e=>ak(e(Xe))),rd=Se(e=>{let{cellIds:n,cellRuntime:a,cellData:o}=e(Xe);return n.inOrderIds.map(s=>{var f;let c=a[s],{name:h}=o[s];if(Xu((f=c.output)==null?void 0:f.mimetype)){rn(Array.isArray(c.output.data),"Expected array data");let g=c.output.data.filter(b=>!b.type.includes("ancestor"));if(g.length>0)return{output:{...c.output,data:g},cellId:s,cellName:h}}return null}).filter(Boolean)}),Kw=Se(e=>{let{cellIds:n,cellRuntime:a}=e(Xe);return $E(n.inOrderIds.map(o=>a[o].outline))}),P_=Se(e=>e(rd).length),ly=o5(Se(e=>{let{cellIds:n,cellData:a}=e(Xe);return Ar.fromEntries(n.inOrderIds.map(o=>{var s;return[o,(s=a[o])==null?void 0:s.name]}))}));var y4=Se(e=>e(Xe).scrollKey);Cw=()=>Sn(Xe),b_=()=>Sn(Ku),Dw=()=>Sn(ly),w_=()=>Sn(rd),Nw=()=>Sn(Xe).cellLogs,Ow=()=>Sn(y4),td=()=>qe.get(Xe),S_=()=>qe.get(Xe).cellIds,R_=()=>{let{cellIds:e,cellData:n}=qe.get(Xe);return e.inOrderIds.map(a=>{var o;return(o=n[a])==null?void 0:o.name}).filter(Boolean)};var v4=vx(px(Xe,e=>e.cellIds.inOrderIds.map(n=>e.cellData[n])));jw=()=>T2(v4),L_=Se(e=>e(Xe).cellRuntime),Q_=Se(e=>nk(e(Xe))),Xw=Se(e=>{let{cellRuntime:n}=e(Xe);return Object.entries(n).every(([a,o])=>o.status!=="running"||a==="__scratch__")}),pw=Se(e=>rk(e(Xe))),$_=Se(e=>e(Xe).cellIds.colLength),h_=Se(e=>e(Xe).cellIds.idLength>0),N_=Se(e=>e(Xe).cellIds.getColumnIds()),id=gd(e=>Se(n=>n(Xe).cellData[e]));var pf=gd(e=>Se(n=>n(Xe).cellRuntime[e]));const cy=gd(e=>Se(n=>n(Xe).cellHandles[e]));function b4(e){id.remove(e),pf.remove(e),cy.remove(e)}mw=e=>{let n=(0,rc.c)(2),a;return n[0]===e?a=n[1]:(a=id(e),n[0]=e,n[1]=a),Sn(a)},Bw=e=>{let n=(0,rc.c)(2),a;return n[0]===e?a=n[1]:(a=pf(e),n[0]=e,n[1]=a),Sn(a)},lw=e=>{let n=(0,rc.c)(2),a;return n[0]===e?a=n[1]:(a=cy(e),n[0]=e,n[1]=a),Sn(a)},jm=()=>{let{cellIds:e,cellHandles:n}=qe.get(Xe);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)},Yu=e=>{var a;let{cellHandles:n}=qe.get(Xe);return(a=n[e].current)==null?void 0:a.editorView},__=function(e){let{cellIds:n,cellData:a,cellRuntime:o}=e;return n.getColumns().flatMap(s=>s.topLevelIds.map(c=>({...a[c],...o[c]})))},l_=function(e){return Se(n=>n(Xe).untouchedNewCells.has(e))};function w4(e){let n=pf(e);return Se(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 f=c.find(g=>g.mimetype==="application/vnd.marimo+traceback");if(f){let g=f.data;s.push(...sm(g))}}let h=o.output;if((h==null?void 0:h.mimetype)==="application/vnd.marimo+error"){let f=h.data;if(Array.isArray(f))for(let g of f)g.type==="syntax"&&g.lineno!=null&&s.push({kind:"cell",cellId:e,lineNumber:g.lineno}),g.type==="import-star"&&g.lineno!=null&&s.push({kind:"cell",cellId:e,lineNumber:g.lineno})}return s.length>0?s:void 0})}ww=function(e){let n=(0,rc.c)(2),a;return n[0]===e?a=n[1]:(a=e===void 0?{}:e,n[0]=e,n[1]=a),sy(a)}})();export{Nh as $,Dh as $n,xl as $r,sw as $t,lw as A,Au as Ai,cw as An,it as Ar,jh as At,uw as B,dw as Bn,Hi as Br,fw as Bt,pw as C,zh as Ci,Ru as Cn,hw as Cr,qh as Ct,mw as D,gw as Di,yw as Dn,vw as Dr,bw as Dt,ww as E,_w as Ei,Mu as En,xw as Er,kw as Et,Cw as F,Pu as Fn,Bh as Fr,Sw as Ft,Ew as G,kl as Gn,as as Gr,Nu as Gt,Tw as H,Iw as Hn,Fh as Hr,Du as Ht,Ow as I,ju as In,Lw as Ir,Aw as It,Rw as J,$i as Jn,Mw as Jr,Vh as Jt,Hh as K,$h as Kn,Cl as Kr,Wh as Kt,er as L,Sl as Ln,Uh as Lr,Pw as Lt,Nw as M,zu as Mn,Kh as Mr,Fn as Mt,Dw as N,Qa as Nn,Qh as Nr,qu as Nt,jw as O,Bu as Oi,zw as On,sa as Or,qw as Ot,Bw as P,Fw as Pn,Vw as Pr,Hw as Pt,$w as Q,Gh as Qn,Ga as Qr,Ww as Qt,tr as R,Uw as Rn,Fu as Rr,Jh as Rt,Kw as S,Qw as Si,Gw as Sn,Jw as Sr,Xh as St,Xw as T,Yh as Ti,Zh as Tn,El as Tr,Vu as Tt,Yw as U,Hu as Un,Tl as Ur,Rr as Ut,em as V,Ja as Vn,$u as Vr,Zw as Vt,tm as W,e_ as Wn,Il as Wr,Wu as Wt,nm as X,rm as Xn,am as Xr,im as Xt,Uu as Y,om as Yn,sm as Yr,t_ as Yt,n_ as Z,lm as Zn,cm as Zr,um as Zt,r_ as _,BT as __tla,a_ as _i,dm as _n,i_ as _r,Vn as _t,Ku as a,o_ as ai,s_ as an,fm as ar,pm as at,Xe as b,Hn as bi,Ol as bn,Qu as br,Gu as bt,l_ as c,mn as ci,Ju as cn,hm as cr,Xu as ct,c_ as d,Ll as di,u_ as dn,mm as dr,gm as dt,d_ as ei,f_ as en,Wi as er,ym as et,Yu as f,Zu as fi,p_ as fn,vm as fr,bm as ft,h_ as g,Xa as gi,ed as gn,Ui as gr,m_ as gt,td as h,wm as hi,_m as hn,nd as hr,g_ as ht,rd as i,is as ii,y_ as in,os as ir,v_ as it,b_ as j,Al as jn,la as jr,Rl as jt,w_ as k,xm as ki,Ya as kn,Ki as kr,km as kt,__ as l,x_ as li,k_ as ln,Cm as lr,C_ as lt,S_ as m,E_ as mi,ad as mn,T_ as mr,Qi as mt,id as n,I_ as ni,ca as nn,Sm as nr,O_ as nt,L_ as o,A_ as oi,Em as on,Tm as or,Im as ot,R_ as p,M_ as pi,od as pn,Om as pr,br as pt,Lm as q,Am as qn,Za as qr,Rm as qt,P_ as r,sd as ri,Ml as rn,ld as rr,Mm as rt,N_ as s,ss as si,Pm as sn,Nm as sr,D_ as st,j_ as t,Dm as ti,z_ as tn,cd as tr,q_ as tt,jm as u,Pl as ui,ud as un,zm as ur,qm as ut,B_ as v,En as vi,F_ as vn,V_ as vr,H_ as vt,$_ as w,W_ as wi,Bm as wn,U_ as wr,K_ as wt,Q_ as x,dd as xi,G_ as xn,J_ as xr,Fm as xt,X_ as y,ls as yi,Y_ as yn,Z_ as yr,fd as yt,ex as z,pd as zn,tx as zr,Vm as zt};
230
+ `," "),withTrailingSlash(e){return e.endsWith("/")?e:`${e}/`},withoutTrailingSlash(e){return e.endsWith("/")?e.slice(0,-1):e},withoutLeadingSlash(e){return e.startsWith("/")?e.slice(1):e},asString:e=>{if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}};var ry=!1;function u4(e){var o;let n=[],a=[e.console].filter(Boolean).flat();for(let s of a){let c=s.mimetype==="text/plain",h=s.mimetype==="text/html"||s.mimetype==="application/vnd.marimo+traceback";if(c||h){let f=s.channel==="stderr"||s.channel==="marimo-error";switch(s.channel){case"stdout":case"stderr":case"marimo-error":{let g=Lm.asString(s.data),b=h?Uu(g):g;n.push({timestamp:s.timestamp||Date.now(),level:f?"stderr":"stdout",message:b,cellId:e.cell_id});break}default:break}}}if(n.forEach(ay.log),a.length===0&&Xu((o=e.output)==null?void 0:o.mimetype)&&Array.isArray(e.output.data)){e.output.data.forEach(c=>{ay.log({level:"stderr",cellId:e.cell_id,timestamp:e.timestamp??0,message:JSON.stringify(c)})});let s=e.output.data.some(c=>c.type==="internal");!ry&&s&&(ry=!0,_l({title:"An internal error occurred",description:"See console for details.",className:"text-xs text-background bg-(--red-10) py-2 pl-3 *:flex *:gap-3"}))}return n}var ay={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`,`[${Hh(e.timestamp)}]`,`(${e.cellId}) ${e.message}`)}};Hh=function(e){try{return a4(e).toLocaleTimeString(void 0,{hour12:!0,hour:"numeric",minute:"numeric",second:"numeric"})}catch{return""}},Yw=function(e,n){let a=Yu(n);a?a.focus():be.warn(`[CellFocusManager] focusCellEditor: element not found: ${n}`)},Tw=function(e){let n=document.getElementById(En.create(e));n?ff(n):be.warn(`[CellFocusManager] focusCell: element not found: ${e}`)},Ew=function(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})},tm=function(){return document.activeElement instanceof HTMLElement&&document.activeElement.classList.contains("marimo-cell")};function ff(e){try{e.focus()}catch{be.warn("[CellFocusManager] element may not be focusable",e)}}em=function(e,n){let{retries:a,delay:o,initialDelay:s=0}=n,c=0,h=()=>{if(c<a){try{if(e())return}catch(f){be.error(`Error executing function on attempt ${c+1}, retrying`,{error:f})}c++,setTimeout(h,o)}};s>0?setTimeout(h,s):h()};function vs({cellId:e,cell:n,isCodeHidden:a,codeFocus:o,variableName:s}){var h;if(!n)return;let c=document.getElementById(En.create(e));if(!c){be.warn("scrollCellIntoView: element not found");return}if(tm()){ff(c);return}if(a)ff(c);else{let f=(h=n.current)==null?void 0:h.editorView;if(!f){be.warn("scrollCellIntoView: editor not found",e);return}if(f.hasFocus||!document.hasFocus())return;if(em(()=>(f.focus(),f.hasFocus),{retries:5,delay:20}),o==="top")f.dispatch({selection:{anchor:0,head:0}});else if(o==="bottom"){let g=f.state.doc.line(f.state.doc.lines);f.dispatch({selection:{anchor:g.from,head:g.from}})}else s&&Ju(f,s)}c.scrollIntoView({behavior:"smooth",block:"nearest"})}ex=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 d4(){let e=document.getElementById("App");e==null||e.scrollTo({top:e.scrollHeight,behavior:"smooth"})}function f4(){var e;(e=document.getElementById("App"))==null||e.scrollTo({top:0,behavior:"smooth"})}uw=function(e){let n=Yu(e);if(n!=null&&n.hasFocus){Og(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}`)},er=function({id:e,name:n="_",code:a="",lastCodeRun:o=null,lastExecutionTime:s=null,edited:c=!1,config:h,serializedEditorState:f=null}){return{id:e,config:h||{hide_code:!1,disabled:!1,column:null},name:n,code:a,edited:c,lastCodeRun:o,lastExecutionTime:s,serializedEditorState:f}};function p4(e){return{hide_code:!1,disabled:!1,column:null,...e}}tr=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 rc=gr();function iy(e){let n={column:0,hide_code:!1,disabled:!1};return{...e,cellData:{[ls]:er({id:ls,config:n}),...e.cellData},cellRuntime:{[ls]:tr(),...e.cellRuntime},cellHandles:{[ls]:(0,gt.createRef)(),...e.cellHandles}}}function h4(){return iy({cellIds:xl.from([]),cellData:{},cellRuntime:{},cellHandles:{},history:[],scrollKey:null,cellLogs:[],untouchedNewCells:new Set})}let m4,oy,g4,sy;({reducer:m4,addMiddleware:oy,createActions:g4,useActions:sy,valueAtom:Xe}=bl(h4,{createNewCell:(e,n)=>{var O;let{cellId:a,before:o,code:s,lastCodeRun:c=null,lastExecutionTime:h=null,autoFocus:f=!0,skipIfCodeExists:g=!1,hideCode:b=!1}=n,_,C;if(g){for(let M of e.cellIds.inOrderIds)if(((O=e.cellData[M])==null?void 0:O.code)===s)return e}if(a==="__end__"){let M=e.cellIds.atOrThrow(0);_=M.id,C=M.length}else if(typeof a=="string"){let M=e.cellIds.findWithId(a);_=M.id,C=M.topLevelIds.indexOf(a)}else if(a.type==="__end__"){let M=e.cellIds.get(a.columnId)||e.cellIds.atOrThrow(0);_=M.id,C=M.length}else throw Error("Invalid cellId");let S=n.newCellId||Xa.create(),E=o?C:C+1;return{...e,cellIds:e.cellIds.insertId(S,_,E),cellData:{...e.cellData,[S]:er({id:S,code:s,lastCodeRun:c,config:p4({hide_code:b}),lastExecutionTime:h,edited:!!s&&s!==c})},cellRuntime:{...e.cellRuntime,[S]:tr()},cellHandles:{...e.cellHandles,[S]:(0,gt.createRef)()},scrollKey:f?S:null,untouchedNewCells:b?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 f=e.cellIds.findWithId(a),g=e.cellIds.indexOf(f),b=s==="left"?g-1:g+1,_=e.cellIds.at(b);return _?{...e,cellIds:e.cellIds.moveAcrossColumns(f.id,a,_.id,void 0),scrollKey:a}:e}let c=e.cellIds.findWithId(a),h=c.indexOfOrThrow(a);return o&&h===0?{...e,cellIds:e.cellIds.moveWithinColumn(c.id,h,0),scrollKey:a}:!o&&h===c.length-1?{...e,cellIds:e.cellIds.moveWithinColumn(c.id,h,c.length-1),scrollKey:a}:o?{...e,cellIds:e.cellIds.moveWithinColumn(c.id,h,h-1),scrollKey:a}:{...e,cellIds:e.cellIds.moveWithinColumn(c.id,h,h+1),scrollKey:a}},dropCellOverCell:(e,n)=>{let{cellId:a,overCellId:o}=n,s=e.cellIds.findWithId(a),c=e.cellIds.findWithId(o),h=s.indexOfOrThrow(a),f=c.indexOfOrThrow(o);return s.id===c.id?h===f?e:{...e,cellIds:e.cellIds.moveWithinColumn(s.id,h,f),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),h;h=s==="before"?Sh(c-1,0,a.length-1):s==="after"?Sh(c+1,0,a.length-1):c;let f=a.atOrThrow(h);return vs({cellId:f,cell:e.cellHandles[f],isCodeHidden:bs(e,f),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 vs({cellId:a,cell:e.cellHandles[a],isCodeHidden:bs(e,a),codeFocus:void 0,variableName:void 0}),f4(),e},focusBottomCell:e=>{let n=e.cellIds.getColumns().at(-1);if(n===void 0||n.length===0)return e;let a=n.last();return vs({cellId:a,cell:e.cellHandles[a],isCodeHidden:bs(e,a),codeFocus:void 0,variableName:void 0}),d4(),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),h=a.length-1;return c===h?e:{...e,cellIds:e.cellIds.moveWithinColumn(a.id,c,h),scrollKey:s?o:null}},addColumn:(e,n)=>{let a=Xa.create();return{...e,cellIds:e.cellIds.addColumn(n.columnId,[a]),cellData:{...e.cellData,[a]:er({id:a})},cellRuntime:{...e.cellRuntime,[a]:tr()},cellHandles:{...e.cellHandles,[a]:(0,gt.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=e.cellIds.findWithId(a),s=o.indexOfOrThrow(a),c=s===0?1:s-1,h=null;o.length>1&&(h=o.atOrThrow(c));let f=(_=(b=e.cellHandles[a].current)==null?void 0:b.editorView)==null?void 0:_.state.toJSON({history:eT});f&&(f.doc=e.cellData[a].code),b4(a);let g=e.cellData[a];return{...e,cellIds:e.cellIds.deleteById(a),history:[...e.history,{name:g.name,serializedEditorState:f,column:o.id,index:s,isSetupCell:a===Hn,config:g.config}],scrollKey:h}},undoDeleteCell:e=>{if(e.history.length===0)return e;let{name:n,serializedEditorState:a={doc:""},column:o,index:s,isSetupCell:c,config:h}=e.history[e.history.length-1],f=c?Hn:Xa.create(),g=er({id:f,name:n,code:a.doc,edited:a.doc.trim().length>0,serializedEditorState:a,config:h});return{...e,cellIds:e.cellIds.insertId(f,o,s),cellData:{...e.cellData,[f]:g},cellRuntime:{...e.cellRuntime,[f]:tr()},cellHandles:{...e.cellHandles,[f]:(0,gt.createRef)()},history:e.history.slice(0,-1),scrollKey:f}},clearSerializedEditorState:(e,n)=>{let{cellId:a}=n;return fo({state:e,cellId:a,cellReducer:o=>({...o,serializedEditorState:null})})},updateCellCode:(e,n)=>{let{cellId:a,code:o,formattingChange:s}=n;return e.cellData[a]?fo({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 fo({state:e,cellId:a,cellReducer:s=>({...s,name:o})})},updateCellConfig:(e,n)=>{let{cellId:a,config:o}=n;return fo({state:e,cellId:a,cellReducer:s=>({...s,config:{...s.config,...o}})})},prepareForRun:(e,n)=>fo({state:ws({state:e,cellId:n.cellId,cellReducer:a=>JE(a)}),cellId:n.cellId,cellReducer:a=>({...a,edited:!1,lastCodeRun:a.code.trim()})}),handleCellMessage:(e,n)=>{let a=n.cell_id,o=ws({state:e,cellId:a,cellReducer:s=>GE(s,n)});return n.status==="queued"&&(o=fo({state:o,cellId:a,cellReducer:s=>({...s,lastCodeRun:s.code.trim(),edited:!1})})),{...o,cellLogs:[...o.cellLogs,...u4(n)]}},setCellIds:(e,n)=>{if(s5(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]=er({id:c})),c in e.cellRuntime||(o[c]=tr()),c in e.cellHandles||(s[c]=(0,gt.createRef)());return{...e,cellIds:xl.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:h,code:f,cellId:g,name:b,config:_})=>{if(!h)return er({id:g,code:f,name:b,config:_,lastCodeRun:n.codeIsStale?null:f,edited:n.codeIsStale&&f.trim().length>0});let C=n.codeIsStale?h.lastCodeRun:f,S=C?C.trim()!==f.trim():!!f;if(h.code.trim()===f.trim())return{...h,code:f,edited:S,lastCodeRun:C,...b!==void 0&&{name:b},..._!==void 0&&{config:_}};if(!Im()){let E=a.cellHandles[g].current;E!=null&&E.editorViewOrNull&&Qi(E.editorViewOrNull,f)}return{...h,code:f,edited:S,lastCodeRun:C,...b!==void 0&&{name:b},..._!==void 0&&{config:_}}};for(let h=0;h<n.ids.length;h++){let f=n.ids[h],g=n.codes[h];if(f===void 0||g===void 0)continue;let b=(s=n.names)==null?void 0:s[h],_=(c=n.configs)==null?void 0:c[h];a={...a,cellData:{...a.cellData,[f]:o({cell:a.cellData[f],code:g,cellId:f,name:b,config:_})}}}return a},setStdinResponse:(e,n)=>{let{cellId:a,response:o,outputIndex:s}=n;return ws({state:e,cellId:a,cellReducer:c=>{let h=[...c.consoleOutputs],f=h[s];return f.channel==="stdin"?(h[s]={channel:"stdin",mimetype:f.mimetype,data:f.data,timestamp:f.timestamp,response:o},{...c,interrupted:!1,consoleOutputs:h}):(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,tr()]));return iy({...e,cellIds:xl.fromIdsAndColumns(n.map(s=>[s.id,s.config.column])),cellData:a,cellRuntime:o,cellHandles:Object.fromEntries(n.map(s=>[s.id,(0,gt.createRef)()]))})},moveToNextCell:(e,n)=>{let{cellId:a,before:o,noCreate:s=!1}=n;if(a==="__scratch__")return e;let c=e.cellIds.findWithId(a),h=c.indexOfOrThrow(a),f=o?h-1:h+1,g=f===c.length,b=f===-1;if(g&&!s){let _=Xa.create();return{...e,cellIds:e.cellIds.insertId(_,c.id,f),cellData:{...e.cellData,[_]:er({id:_})},cellRuntime:{...e.cellRuntime,[_]:tr()},cellHandles:{...e.cellHandles,[_]:(0,gt.createRef)()},scrollKey:_}}if(b&&!s){let _=Xa.create();return{...e,cellIds:e.cellIds.insertId(_,c.id,0),cellData:{...e.cellData,[_]:er({id:_})},cellRuntime:{...e.cellRuntime,[_]:tr()},cellHandles:{...e.cellHandles,[_]:(0,gt.createRef)()},scrollKey:_}}if((g||b)&&s)return e;if(f>=0&&f<c.length){let _=c.atOrThrow(f);vs({cellId:_,cell:e.cellHandles[_],isCodeHidden:bs(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 vs({cellId:s,cell:e.cellHandles[s],isCodeHidden:bs(e,s),codeFocus:void 0,variableName:void 0}),{...e,scrollKey:null}},foldAll:e=>(Sx(Object.values(e.cellHandles).map(n=>{var a;return(a=n.current)==null?void 0:a.editorView})),e),unfoldAll:e=>(Ex(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(f=>e.cellRuntime[f].outline),c=J1(o.indexOfOrThrow(a),s);if(!c)return e;let h=o.atOrThrow(c[1]);return{...e,cellIds:e.cellIds.transformWithCellId(a,f=>f.collapse(a,h)),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(g=>e.cellRuntime[g].outline),o=[...n.nodes],s=[],c=[],h=o.length-1;for(;h>=0;){let g=J1(h,a);if(g){let b=h,_=g[1],C=s.find(O=>O.start<=_&&O.end===_);C&&(_=C.start),s.push({start:b,end:_});let S=n.atOrThrow(b),E=n.atOrThrow(_);c.push({id:S,until:E})}else c.push(null);h--}let f=c.reverse();return n.collapseAll(f)})}),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],h=e.cellHandles[a].current;if((h==null?void 0:h.editorView)==null)return e;let{beforeCursorCode:f,afterCursorCode:g}=BE(h.editorView);Qi(h.editorView,f);let b=Xa.create();return{...e,cellIds:e.cellIds.insertId(b,o.id,s+1),cellData:{...e.cellData,[a]:{...c,code:f,edited:!!f&&f.trim()!==((_=c.lastCodeRun)==null?void 0:_.trim())},[b]:er({id:b,code:g,edited:!!g})},cellRuntime:{...e.cellRuntime,[a]:{...e.cellRuntime[a],output:null,consoleOutputs:[]},[b]:tr()},cellHandles:{...e.cellHandles,[b]:(0,gt.createRef)()},scrollKey:b}},undoSplitCell:(e,n)=>{var h;let{cellId:a,snapshot:o}=n,s=e.cellData[a],c=e.cellHandles[a].current;return(c==null?void 0:c.editorView)==null?e:(Qi(c.editorView,o),{...e,cellIds:e.cellIds.transformWithCellId(a,f=>{let g=f.indexOfOrThrow(a)+1;return f.deleteAtIndex(g)}),cellData:{...e.cellData,[a]:{...s,code:o,edited:!!o&&(o==null?void 0:o.trim())!==((h=s.lastCodeRun)==null?void 0:h.trim())}},cellRuntime:{...e.cellRuntime,[a]:{...e.cellRuntime[a],output:null,consoleOutputs:[]}},cellHandles:{...e.cellHandles}})},clearCellOutput:(e,n)=>{let{cellId:a}=n;return ws({state:e,cellId:a,cellReducer:o=>({...o,output:null,consoleOutputs:[]})})},clearCellConsoleOutput:(e,n)=>{let{cellId:a}=n;return ws({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:Hn}:{...e,cellIds:e.cellIds.insertId(Hn,e.cellIds.atOrThrow(0).id,0),cellData:{...e.cellData,[Hn]:er({id:Hn,name:Hn,code:a,edited:!!a})},cellRuntime:{...e.cellRuntime,[Hn]:tr()},cellHandles:{...e.cellHandles,[Hn]:(0,gt.createRef)()},scrollKey:Hn}}})),oy(r4);function bs(e,n){return!!e.cellData[n].config.hide_code&&!e.untouchedNewCells.has(n)}function ws({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 fo({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)}c_=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,h)=>{let f={...a};return h===0&&(f.column=s),{...n[c].config,...f}})):e.cellIds.getColumns().flatMap(o=>o.inOrderIds.map(s=>({...n[s].config,...a})))},Ku=Se(e=>e(Xe).cellIds),B_=Se(e=>e(Ku).hasOnlyOneId()),r_=Se(e=>Kh(e(Xe)).length>0),Se(e=>Qh(e(Xe)).length>0);let ly;j_=Se(e=>ok(e(Xe))),X_=Se(e=>ak(e(Xe))),rd=Se(e=>{let{cellIds:n,cellRuntime:a,cellData:o}=e(Xe);return n.inOrderIds.map(s=>{var f;let c=a[s],{name:h}=o[s];if(Xu((f=c.output)==null?void 0:f.mimetype)){rn(Array.isArray(c.output.data),"Expected array data");let g=c.output.data.filter(b=>!b.type.includes("ancestor"));if(g.length>0)return{output:{...c.output,data:g},cellId:s,cellName:h}}return null}).filter(Boolean)}),Kw=Se(e=>{let{cellIds:n,cellRuntime:a}=e(Xe);return $E(n.inOrderIds.map(o=>a[o].outline))}),P_=Se(e=>e(rd).length),ly=o5(Se(e=>{let{cellIds:n,cellData:a}=e(Xe);return Ar.fromEntries(n.inOrderIds.map(o=>{var s;return[o,(s=a[o])==null?void 0:s.name]}))}));var y4=Se(e=>e(Xe).scrollKey);Cw=()=>Sn(Xe),b_=()=>Sn(Ku),Dw=()=>Sn(ly),w_=()=>Sn(rd),Nw=()=>Sn(Xe).cellLogs,Ow=()=>Sn(y4),td=()=>qe.get(Xe),S_=()=>qe.get(Xe).cellIds,R_=()=>{let{cellIds:e,cellData:n}=qe.get(Xe);return e.inOrderIds.map(a=>{var o;return(o=n[a])==null?void 0:o.name}).filter(Boolean)};var v4=vx(px(Xe,e=>e.cellIds.inOrderIds.map(n=>e.cellData[n])));jw=()=>T2(v4),L_=Se(e=>e(Xe).cellRuntime),Q_=Se(e=>nk(e(Xe))),Xw=Se(e=>{let{cellRuntime:n}=e(Xe);return Object.entries(n).every(([a,o])=>o.status!=="running"||a==="__scratch__")}),pw=Se(e=>rk(e(Xe))),$_=Se(e=>e(Xe).cellIds.colLength),h_=Se(e=>e(Xe).cellIds.idLength>0),N_=Se(e=>e(Xe).cellIds.getColumnIds()),id=gd(e=>Se(n=>n(Xe).cellData[e]));var pf=gd(e=>Se(n=>n(Xe).cellRuntime[e]));const cy=gd(e=>Se(n=>n(Xe).cellHandles[e]));function b4(e){id.remove(e),pf.remove(e),cy.remove(e)}mw=e=>{let n=(0,rc.c)(2),a;return n[0]===e?a=n[1]:(a=id(e),n[0]=e,n[1]=a),Sn(a)},Bw=e=>{let n=(0,rc.c)(2),a;return n[0]===e?a=n[1]:(a=pf(e),n[0]=e,n[1]=a),Sn(a)},lw=e=>{let n=(0,rc.c)(2),a;return n[0]===e?a=n[1]:(a=cy(e),n[0]=e,n[1]=a),Sn(a)},jm=()=>{let{cellIds:e,cellHandles:n}=qe.get(Xe);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)},Yu=e=>{var a;let{cellHandles:n}=qe.get(Xe);return(a=n[e].current)==null?void 0:a.editorView},__=function(e){let{cellIds:n,cellData:a,cellRuntime:o}=e;return n.getColumns().flatMap(s=>s.topLevelIds.map(c=>({...a[c],...o[c]})))},l_=function(e){return Se(n=>n(Xe).untouchedNewCells.has(e))};function w4(e){let n=pf(e);return Se(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 f=c.find(g=>g.mimetype==="application/vnd.marimo+traceback");if(f){let g=f.data;s.push(...sm(g))}}let h=o.output;if((h==null?void 0:h.mimetype)==="application/vnd.marimo+error"){let f=h.data;if(Array.isArray(f))for(let g of f)g.type==="syntax"&&g.lineno!=null&&s.push({kind:"cell",cellId:e,lineNumber:g.lineno}),g.type==="import-star"&&g.lineno!=null&&s.push({kind:"cell",cellId:e,lineNumber:g.lineno})}return s.length>0?s:void 0})}ww=function(e){let n=(0,rc.c)(2),a;return n[0]===e?a=n[1]:(a=e===void 0?{}:e,n[0]=e,n[1]=a),sy(a)}})();export{Nh as $,Dh as $n,xl as $r,sw as $t,lw as A,Au as Ai,cw as An,it as Ar,jh as At,uw as B,dw as Bn,Hi as Br,fw as Bt,pw as C,zh as Ci,Ru as Cn,hw as Cr,qh as Ct,mw as D,gw as Di,yw as Dn,vw as Dr,bw as Dt,ww as E,_w as Ei,Mu as En,xw as Er,kw as Et,Cw as F,Pu as Fn,Bh as Fr,Sw as Ft,Ew as G,kl as Gn,as as Gr,Nu as Gt,Tw as H,Iw as Hn,Fh as Hr,Du as Ht,Ow as I,ju as In,Lw as Ir,Aw as It,Rw as J,$i as Jn,Mw as Jr,Vh as Jt,Hh as K,$h as Kn,Cl as Kr,Wh as Kt,er as L,Sl as Ln,Uh as Lr,Pw as Lt,Nw as M,zu as Mn,Kh as Mr,Fn as Mt,Dw as N,Qa as Nn,Qh as Nr,qu as Nt,jw as O,Bu as Oi,zw as On,sa as Or,qw as Ot,Bw as P,Fw as Pn,Vw as Pr,Hw as Pt,$w as Q,Gh as Qn,Ga as Qr,Ww as Qt,tr as R,Uw as Rn,Fu as Rr,Jh as Rt,Kw as S,Qw as Si,Gw as Sn,Jw as Sr,Xh as St,Xw as T,Yh as Ti,Zh as Tn,El as Tr,Vu as Tt,Yw as U,Hu as Un,Tl as Ur,Rr as Ut,em as V,Ja as Vn,$u as Vr,Zw as Vt,tm as W,e_ as Wn,Il as Wr,Wu as Wt,nm as X,rm as Xn,am as Xr,im as Xt,Uu as Y,om as Yn,sm as Yr,t_ as Yt,n_ as Z,lm as Zn,cm as Zr,um as Zt,r_ as _,BT as __tla,a_ as _i,dm as _n,i_ as _r,Vn as _t,Ku as a,o_ as ai,s_ as an,fm as ar,pm as at,Xe as b,Hn as bi,Ol as bn,Qu as br,Gu as bt,l_ as c,mn as ci,Ju as cn,hm as cr,Xu as ct,c_ as d,Ll as di,u_ as dn,mm as dr,gm as dt,d_ as ei,f_ as en,Wi as er,ym as et,Yu as f,Zu as fi,p_ as fn,vm as fr,bm as ft,h_ as g,Xa as gi,ed as gn,Ui as gr,m_ as gt,td as h,wm as hi,_m as hn,nd as hr,g_ as ht,rd as i,is as ii,y_ as in,os as ir,v_ as it,b_ as j,Al as jn,la as jr,Rl as jt,w_ as k,xm as ki,Ya as kn,Ki as kr,km as kt,__ as l,x_ as li,k_ as ln,Cm as lr,C_ as lt,S_ as m,E_ as mi,ad as mn,T_ as mr,Qi as mt,id as n,I_ as ni,ca as nn,Sm as nr,O_ as nt,L_ as o,A_ as oi,Em as on,Tm as or,Im as ot,R_ as p,M_ as pi,od as pn,Om as pr,br as pt,Lm as q,Am as qn,Za as qr,Rm as qt,P_ as r,sd as ri,Ml as rn,ld as rr,Mm as rt,N_ as s,ss as si,Pm as sn,Nm as sr,D_ as st,j_ as t,Dm as ti,z_ as tn,cd as tr,q_ as tt,jm as u,Pl as ui,ud as un,zm as ur,qm as ut,B_ as v,En as vi,F_ as vn,V_ as vr,H_ as vt,$_ as w,W_ as wi,Bm as wn,U_ as wr,K_ as wt,Q_ as x,dd as xi,G_ as xn,J_ as xr,Fm as xt,X_ as y,ls as yi,Y_ as yn,Z_ as yr,fd as yt,ex as z,pd as zn,tx as zr,Vm as zt};
@@ -1 +1 @@
1
- import{s as A}from"./chunk-LvLJmgfZ.js";import{t as U}from"./react-Bj1aDYRI.js";import{sr as Y,tr as $}from"./cells-B8rT_yJt.js";import{C as P,P as G,R as E,T as K}from"./zod-H_cgTO0M.js";import{t as J}from"./compiler-runtime-B3qBwwSJ.js";import{n as Q}from"./assertNever-DWSyoPEi.js";import{t as L}from"./isEmpty-CfmnKtgL.js";import{Y as X}from"./ai-model-dropdown-Dybmv5gR.js";import{m as W}from"./useEventListener-Dy81QR4n.js";import{t as Z}from"./jsx-runtime-icT_Ltz2.js";import{t as C}from"./cn-BoaCR37F.js";import{t as ee}from"./bot-message-square-Dw41U6lL.js";import{t as D}from"./markdown-renderer-f7AvSa1a.js";import{l as te}from"./add-cell-with-ai-u_AX7UAd.js";import{n as se}from"./spinner-C5JoisA7.js";import{c as ae}from"./datasource-xomiPYKd.js";import{t as re}from"./RenderHTML-C9ZqxJ8H.js";import{a as I,i as V,n as B,r as H}from"./multi-map-1zWiWMZF.js";var le=J(),ne=A(U(),1),t=A(Z(),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",d;e[1]!==a.length||e[2]!==p?(d=(0,t.jsx)(I,{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]=d):d=e[3];let i;e[4]===a?i=e[5]:(i=(0,t.jsx)(H,{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)(D,{content:a})})})}),e[4]=a,e[5]=i);let c;e[6]!==d||e[7]!==i?(c=(0,t.jsxs)(V,{value:"reasoning",className:"border-0",children:[d,i]}),e[6]=d,e[7]=i,e[8]=c):c=e[8];let u;return e[9]!==r||e[10]!==o||e[11]!==c?(u=(0,t.jsx)(B,{type:"single",collapsible:!0,className:"w-full mb-2",value:o,children:c},r),e[9]=r,e[10]=o,e[11]=c,e[12]=u):u=e[12],u};var T=J(),ie=G({status:E().default("success"),auth_required:K().default(!1),action_url:P(),next_steps:P(),meta:P(),message:E().nullish()}).passthrough(),ce=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,...d}=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 c;e[3]===s?c=e[4]:(c=(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]=c);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]!==c||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:[c,u]})]}),e[7]=c,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,d&&(0,t.jsx)("div",{className:"space-y-3",children:Object.entries(d).map(xe)})]}),e[0]=a,e[1]=l}else l=e[1];return l},de=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)(ce,{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"&&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,d=m==="output-available"&&(l||s),i=s?"error":d?"success":"loading",c;e[0]===i?c=e[1]:(c=()=>{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)(X,{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]=c);let u=c,h;e[2]!==s||e[3]!==d||e[4]!==i?(h=()=>i==="loading"?"Running":s?"Failed":d?"Done":"Tool call",e[2]=s,e[3]=d,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 k=i==="error"&&"text-[var(--red-11)]/80",q=i==="success"&&"text-[var(--grass-11)]/80",j;e[8]!==k||e[9]!==q?(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",k,q),e[8]=k,e[9]=q,e[10]=j):j=e[10];let v;e[11]===u?v=e[12]:(v=u(),e[11]=u,e[12]=v);let z=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]!==z||e[18]!==N||e[19]!==v?(y=(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[v,z,":",N]}),e[17]=z,e[18]=N,e[19]=v,e[20]=y):y=e[20];let w;e[21]!==y||e[22]!==j?(w=(0,t.jsx)(I,{className:j,children:y}),e[21]=y,e[22]=j,e[23]=w):w=e[23];let _;e[24]!==s||e[25]!==d||e[26]!==x||e[27]!==l?(_=d&&(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(me,{input:x}),l!=null&&(0,t.jsx)(de,{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]=d,e[26]=x,e[27]=l,e[28]=_):_=e[28];let S;e[29]===_?S=e[30]:(S=(0,t.jsx)(H,{className:"py-2 px-2",children:_}),e[29]=_,e[30]=S);let R;e[31]!==w||e[32]!==S?(R=(0,t.jsxs)(V,{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)(B,{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)(D,{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 Q(s),null}}};function he(n){return n.type.startsWith("tool-")}function fe(n){return n.type.startsWith("data-")}export{pe as t};
1
+ import{s as A}from"./chunk-LvLJmgfZ.js";import{t as U}from"./react-Bj1aDYRI.js";import{sr as Y,tr as $}from"./cells-Ir3O9-uE.js";import{C as P,P as G,R as E,T as K}from"./zod-H_cgTO0M.js";import{t as J}from"./compiler-runtime-B3qBwwSJ.js";import{n as Q}from"./assertNever-DWSyoPEi.js";import{t as L}from"./isEmpty-CfmnKtgL.js";import{Y as X}from"./ai-model-dropdown-Cl-qIUat.js";import{m as W}from"./useEventListener-Dy81QR4n.js";import{t as Z}from"./jsx-runtime-icT_Ltz2.js";import{t as C}from"./cn-BoaCR37F.js";import{t as ee}from"./bot-message-square-Dw41U6lL.js";import{t as D}from"./markdown-renderer-DpNwn0oX.js";import{l as te}from"./add-cell-with-ai-C75dyXgo.js";import{n as se}from"./spinner-C5JoisA7.js";import{c as ae}from"./datasource-45Ftm7IO.js";import{t as re}from"./RenderHTML-D45p-tLD.js";import{a as I,i as V,n as B,r as H}from"./multi-map-1zWiWMZF.js";var le=J(),ne=A(U(),1),t=A(Z(),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",d;e[1]!==a.length||e[2]!==p?(d=(0,t.jsx)(I,{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]=d):d=e[3];let i;e[4]===a?i=e[5]:(i=(0,t.jsx)(H,{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)(D,{content:a})})})}),e[4]=a,e[5]=i);let c;e[6]!==d||e[7]!==i?(c=(0,t.jsxs)(V,{value:"reasoning",className:"border-0",children:[d,i]}),e[6]=d,e[7]=i,e[8]=c):c=e[8];let u;return e[9]!==r||e[10]!==o||e[11]!==c?(u=(0,t.jsx)(B,{type:"single",collapsible:!0,className:"w-full mb-2",value:o,children:c},r),e[9]=r,e[10]=o,e[11]=c,e[12]=u):u=e[12],u};var T=J(),ie=G({status:E().default("success"),auth_required:K().default(!1),action_url:P(),next_steps:P(),meta:P(),message:E().nullish()}).passthrough(),ce=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,...d}=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 c;e[3]===s?c=e[4]:(c=(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]=c);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]!==c||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:[c,u]})]}),e[7]=c,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,d&&(0,t.jsx)("div",{className:"space-y-3",children:Object.entries(d).map(xe)})]}),e[0]=a,e[1]=l}else l=e[1];return l},de=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)(ce,{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"&&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,d=m==="output-available"&&(l||s),i=s?"error":d?"success":"loading",c;e[0]===i?c=e[1]:(c=()=>{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)(X,{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]=c);let u=c,h;e[2]!==s||e[3]!==d||e[4]!==i?(h=()=>i==="loading"?"Running":s?"Failed":d?"Done":"Tool call",e[2]=s,e[3]=d,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 k=i==="error"&&"text-[var(--red-11)]/80",q=i==="success"&&"text-[var(--grass-11)]/80",j;e[8]!==k||e[9]!==q?(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",k,q),e[8]=k,e[9]=q,e[10]=j):j=e[10];let v;e[11]===u?v=e[12]:(v=u(),e[11]=u,e[12]=v);let z=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]!==z||e[18]!==N||e[19]!==v?(y=(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[v,z,":",N]}),e[17]=z,e[18]=N,e[19]=v,e[20]=y):y=e[20];let w;e[21]!==y||e[22]!==j?(w=(0,t.jsx)(I,{className:j,children:y}),e[21]=y,e[22]=j,e[23]=w):w=e[23];let _;e[24]!==s||e[25]!==d||e[26]!==x||e[27]!==l?(_=d&&(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(me,{input:x}),l!=null&&(0,t.jsx)(de,{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]=d,e[26]=x,e[27]=l,e[28]=_):_=e[28];let S;e[29]===_?S=e[30]:(S=(0,t.jsx)(H,{className:"py-2 px-2",children:_}),e[29]=_,e[30]=S);let R;e[31]!==w||e[32]!==S?(R=(0,t.jsxs)(V,{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)(B,{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)(D,{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 Q(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 Ue}from"./useEvent-O0nX5vok.js";import{t as Pt}from"./react-Bj1aDYRI.js";import{E as Dt,or as zt}from"./cells-B8rT_yJt.js";import"./react-dom-CSu739Rf.js";import{t as Qe}from"./compiler-runtime-B3qBwwSJ.js";import{T as Mt,o as Ft,r as Ze,t as Ht,w as Ot}from"./ai-model-dropdown-Dybmv5gR.js";import{m as Te,r as le}from"./useEventListener-Dy81QR4n.js";import{n as et,r as Wt}from"./utils-tNbLd14P.js";import{o as Ut}from"./config-DRN1Q5Ol.js";import{t as Yt}from"./jsx-runtime-icT_Ltz2.js";import{t as oe}from"./button-Ej3vmCIF.js";import{t as ae}from"./cn-BoaCR37F.js";import"./dist-B_cxg-E4.js";import"./cjs-BU2qXMKx.js";import"./main-DrBRErTM.js";import"./useNonce-BtW-rR_1.js";import{r as Xt}from"./requests-Bgjtqo_1.js";import{t as tt}from"./createLucideIcon-Cm-Z7dYr.js";import{t as rt}from"./bot-message-square-Dw41U6lL.js";import"./markdown-renderer-f7AvSa1a.js";import{O as lt,S as Bt,T as Vt,_ as qt,b as $t,c as Gt,d as Jt,f as Kt,g as Qt,h as Zt,j as er,k as tr,l as rr,m as ot,n as at,p as lr,s as or,u as ar,v as nr,y as sr}from"./add-cell-with-ai-u_AX7UAd.js";import{n as ir}from"./spinner-C5JoisA7.js";import{t as cr}from"./message-circle-BaZF1NX9.js";import{t as dr}from"./plus-D1HlXYzG.js";import{dt as ur,r as mr}from"./input-6cciao_l.js";import{t as pr}from"./settings-dVFT0AvU.js";import"./dist-1ZGGzJka.js";import"./dist-DA4gn7fy.js";import"./dist-Bh-vrbeU.js";import"./dist-4rKUx1vk.js";import"./dist-BXtR56No.js";import"./session-DKzpcHdK.js";import{C as hr,E as fr,_ as me,g as X,w as B,x as Ae}from"./Combination-CXstThSr.js";import{a as xr,i as vr,n as gr,p as wr,r as br,s as yr,t as jr}from"./select-dNVaT2hT.js";import{i as nt,t as Ye}from"./tooltip-BCGmr4TU.js";import{u as Sr}from"./menu-items-DkKu0R5b.js";import"./purify.es-ByGlPBcv.js";import{i as Cr}from"./dates-Bh1ltXGt.js";import{t as Nr}from"./context-BPhh8SWw.js";import{i as Rr,r as _r,t as Tr}from"./popover-C5P0DZBj.js";import{t as Ar}from"./copy-icon-BNQYrUYC.js";import{r as st,t as Er}from"./state-DLmIk5GZ.js";import{n as kr}from"./error-banner-D6woGaqN.js";import"./chunk-5FQGJX7Z-KaqPPQRg.js";import"./html-to-image-BtnUxAf2.js";import"./esm-BMWduMhT.js";import{t as Xe}from"./empty-state-DUEogWxf.js";import{t as Lr}from"./chat-display-DSlMdLnv.js";var Ir=tt("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"}]]),Pr=tt("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"}]]),it=Qe(),m=Ke(Pt(),1);const Dr=({chatState:e,chatId:t,messages:r})=>{if(!t)return Te.warn("No active chat"),e;let n=e.chats.get(t);if(!n)return Te.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 o=Ke(Yt(),1);function zr(e,t){return m.useReducer((r,n)=>t[r][n]??r,e)}var Be="ScrollArea",[ct,mo]=fr(Be),[Mr,M]=ct(Be),dt=m.forwardRef((e,t)=>{let{__scopeScrollArea:r,type:n="hover",dir:l,scrollHideDelay:a=600,...s}=e,[i,c]=m.useState(null),[u,d]=m.useState(null),[p,h]=m.useState(null),[f,v]=m.useState(null),[S,A]=m.useState(null),[w,N]=m.useState(0),[R,y]=m.useState(0),[j,C]=m.useState(!1),[E,I]=m.useState(!1),g=le(t,k=>c(k)),T=Sr(l);return(0,o.jsx)(Mr,{scope:r,type:n,dir:T,scrollHideDelay:a,scrollArea:i,viewport:u,onViewportChange:d,content:p,onContentChange:h,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:j,onScrollbarXEnabledChange:C,scrollbarY:S,onScrollbarYChange:A,scrollbarYEnabled:E,onScrollbarYEnabledChange:I,onCornerWidthChange:N,onCornerHeightChange:y,children:(0,o.jsx)(me.div,{dir:T,...s,ref:g,style:{position:"relative","--radix-scroll-area-corner-width":w+"px","--radix-scroll-area-corner-height":R+"px",...e.style}})})});dt.displayName=Be;var ut="ScrollAreaViewport",mt=m.forwardRef((e,t)=>{let{__scopeScrollArea:r,children:n,nonce:l,...a}=e,s=M(ut,r),i=le(t,m.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)(me.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})})]})});mt.displayName=ut;var W="ScrollAreaScrollbar",Ve=m.forwardRef((e,t)=>{let{forceMount:r,...n}=e,l=M(W,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:s}=l,i=e.orientation==="horizontal";return m.useEffect(()=>(i?a(!0):s(!0),()=>{i?a(!1):s(!1)}),[i,a,s]),l.type==="hover"?(0,o.jsx)(Fr,{...n,ref:t,forceMount:r}):l.type==="scroll"?(0,o.jsx)(Hr,{...n,ref:t,forceMount:r}):l.type==="auto"?(0,o.jsx)(pt,{...n,ref:t,forceMount:r}):l.type==="always"?(0,o.jsx)(qe,{...n,ref:t}):null});Ve.displayName=W;var Fr=m.forwardRef((e,t)=>{let{forceMount:r,...n}=e,l=M(W,e.__scopeScrollArea),[a,s]=m.useState(!1);return m.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)(Ae,{present:r||a,children:(0,o.jsx)(pt,{"data-state":a?"visible":"hidden",...n,ref:t})})}),Hr=m.forwardRef((e,t)=>{let{forceMount:r,...n}=e,l=M(W,e.__scopeScrollArea),a=e.orientation==="horizontal",s=Ie(()=>c("SCROLL_END"),100),[i,c]=zr("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 m.useEffect(()=>{if(i==="idle"){let u=window.setTimeout(()=>c("HIDE"),l.scrollHideDelay);return()=>window.clearTimeout(u)}},[i,l.scrollHideDelay,c]),m.useEffect(()=>{let u=l.viewport,d=a?"scrollLeft":"scrollTop";if(u){let p=u[d],h=()=>{let f=u[d];p!==f&&(c("SCROLL"),s()),p=f};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[l.viewport,a,c,s]),(0,o.jsx)(Ae,{present:r||i!=="hidden",children:(0,o.jsx)(qe,{"data-state":i==="hidden"?"hidden":"visible",...n,ref:t,onPointerEnter:B(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:B(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),pt=m.forwardRef((e,t)=>{let r=M(W,e.__scopeScrollArea),{forceMount:n,...l}=e,[a,s]=m.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)(Ae,{present:n||a,children:(0,o.jsx)(qe,{"data-state":a?"visible":"hidden",...l,ref:t})})}),qe=m.forwardRef((e,t)=>{let{orientation:r="vertical",...n}=e,l=M(W,e.__scopeScrollArea),a=m.useRef(null),s=m.useRef(0),[i,c]=m.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=gt(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 p(h,f){return Br(h,s.current,i,f)}return r==="horizontal"?(0,o.jsx)(Or,{...d,ref:t,onThumbPositionChange:()=>{if(l.viewport&&a.current){let h=l.viewport.scrollLeft,f=wt(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=p(h,l.dir))}}):r==="vertical"?(0,o.jsx)(Wr,{...d,ref:t,onThumbPositionChange:()=>{if(l.viewport&&a.current){let h=l.viewport.scrollTop,f=wt(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=p(h))}}):null}),Or=m.forwardRef((e,t)=>{let{sizes:r,onSizesChange:n,...l}=e,a=M(W,e.__scopeScrollArea),[s,i]=m.useState(),c=m.useRef(null),u=le(t,c,a.onScrollbarXChange);return m.useEffect(()=>{c.current&&i(getComputedStyle(c.current))},[c]),(0,o.jsx)(ft,{"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,p)=>{if(a.viewport){let h=a.viewport.scrollLeft+d.deltaX;e.onWheelScroll(h),yt(h,p)&&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)}})}})}),Wr=m.forwardRef((e,t)=>{let{sizes:r,onSizesChange:n,...l}=e,a=M(W,e.__scopeScrollArea),[s,i]=m.useState(),c=m.useRef(null),u=le(t,c,a.onScrollbarYChange);return m.useEffect(()=>{c.current&&i(getComputedStyle(c.current))},[c]),(0,o.jsx)(ft,{"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,p)=>{if(a.viewport){let h=a.viewport.scrollTop+d.deltaY;e.onWheelScroll(h),yt(h,p)&&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)}})}})}),[Ur,ht]=ct(W),ft=m.forwardRef((e,t)=>{let{__scopeScrollArea:r,sizes:n,hasThumb:l,onThumbChange:a,onThumbPointerUp:s,onThumbPointerDown:i,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:d,onResize:p,...h}=e,f=M(W,r),[v,S]=m.useState(null),A=le(t,g=>S(g)),w=m.useRef(null),N=m.useRef(""),R=f.viewport,y=n.content-n.viewport,j=X(d),C=X(c),E=Ie(p,10);function I(g){w.current&&u({x:g.clientX-w.current.left,y:g.clientY-w.current.top})}return m.useEffect(()=>{let g=T=>{let k=T.target;v!=null&&v.contains(k)&&j(T,y)};return document.addEventListener("wheel",g,{passive:!1}),()=>document.removeEventListener("wheel",g,{passive:!1})},[R,v,y,j]),m.useEffect(C,[n,C]),ne(v,E),ne(f.content,E),(0,o.jsx)(Ur,{scope:r,scrollbar:v,hasThumb:l,onThumbChange:X(a),onThumbPointerUp:X(s),onThumbPositionChange:C,onThumbPointerDown:X(i),children:(0,o.jsx)(me.div,{...h,ref:A,style:{position:"absolute",...h.style},onPointerDown:B(e.onPointerDown,g=>{g.button===0&&(g.target.setPointerCapture(g.pointerId),w.current=v.getBoundingClientRect(),N.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),I(g))}),onPointerMove:B(e.onPointerMove,I),onPointerUp:B(e.onPointerUp,g=>{let T=g.target;T.hasPointerCapture(g.pointerId)&&T.releasePointerCapture(g.pointerId),document.body.style.webkitUserSelect=N.current,f.viewport&&(f.viewport.style.scrollBehavior=""),w.current=null})})})}),Ee="ScrollAreaThumb",xt=m.forwardRef((e,t)=>{let{forceMount:r,...n}=e,l=ht(Ee,e.__scopeScrollArea);return(0,o.jsx)(Ae,{present:r||l.hasThumb,children:(0,o.jsx)(Yr,{ref:t,...n})})}),Yr=m.forwardRef((e,t)=>{let{__scopeScrollArea:r,style:n,...l}=e,a=M(Ee,r),s=ht(Ee,r),{onThumbPositionChange:i}=s,c=le(t,p=>s.onThumbChange(p)),u=m.useRef(void 0),d=Ie(()=>{u.current&&(u.current=(u.current(),void 0))},100);return m.useEffect(()=>{let p=a.viewport;if(p){let h=()=>{d(),u.current||(u.current=Vr(p,i),i())};return i(),p.addEventListener("scroll",h),()=>p.removeEventListener("scroll",h)}},[a.viewport,d,i]),(0,o.jsx)(me.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:B(e.onPointerDownCapture,p=>{let h=p.target.getBoundingClientRect(),f=p.clientX-h.left,v=p.clientY-h.top;s.onThumbPointerDown({x:f,y:v})}),onPointerUp:B(e.onPointerUp,s.onThumbPointerUp)})});xt.displayName=Ee;var $e="ScrollAreaCorner",vt=m.forwardRef((e,t)=>{let r=M($e,e.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?(0,o.jsx)(Xr,{...e,ref:t}):null});vt.displayName=$e;var Xr=m.forwardRef((e,t)=>{let{__scopeScrollArea:r,...n}=e,l=M($e,r),[a,s]=m.useState(0),[i,c]=m.useState(0),u=!!(a&&i);return ne(l.scrollbarX,()=>{var p;let d=((p=l.scrollbarX)==null?void 0:p.offsetHeight)||0;l.onCornerHeightChange(d),c(d)}),ne(l.scrollbarY,()=>{var p;let d=((p=l.scrollbarY)==null?void 0:p.offsetWidth)||0;l.onCornerWidthChange(d),s(d)}),u?(0,o.jsx)(me.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 gt(e,t){let r=e/t;return isNaN(r)?0:r}function Le(e){let t=gt(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,n=(e.scrollbar.size-r)*t;return Math.max(n,18)}function Br(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,p=n==="ltr"?[0,d]:[d*-1,0];return bt([c,u],p)(e)}function wt(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=wr(e,r==="ltr"?[0,s]:[s*-1,0]);return bt([0,s],[0,i])(c)}function bt(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 yt(e,t){return e>0&&e<t}var Vr=(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=X(e),n=m.useRef(0);return m.useEffect(()=>()=>window.clearTimeout(n.current),[]),m.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,t)},[r,t])}function ne(e,t){let r=X(t);hr(()=>{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 jt=dt,qr=mt,$r=vt,St=m.forwardRef((e,t)=>{let r=(0,it.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=ae("relative overflow-hidden",l),r[4]=l,r[5]=s);let i;r[6]===n?i=r[7]:(i=(0,o.jsx)(qr,{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)($r,{}),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)(jt,{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=jt.displayName;var Ct=m.forwardRef((e,t)=>{let r=(0,it.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=ae("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)(xt,{className:"relative flex-1 rounded-full bg-border"}),r[8]=d):d=r[8];let p;return r[9]!==s||r[10]!==l||r[11]!==t||r[12]!==u?(p=(0,o.jsx)(Ve,{ref:t,orientation:s,className:u,...l,children:d}),r[9]=s,r[10]=l,r[11]=t,r[12]=u,r[13]=p):p=r[13],p});Ct.displayName=Ve.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=Ue(st),{locale:n}=Nr(),[l,a]=(0,m.useState)(""),s=(0,m.useMemo)(()=>[...r.chats.values()].sort((u,d)=>d.updatedAt-u.updatedAt),[r.chats]),i=(0,m.useMemo)(()=>l.trim()?s.filter(u=>u.title.toLowerCase().includes(l.toLowerCase())):s,[s,l]),c=(0,m.useMemo)(()=>Jr(i),[i]);return(0,o.jsxs)(Tr,{children:[(0,o.jsx)(Ye,{content:"Previous chats",children:(0,o.jsx)(Rr,{asChild:!0,children:(0,o.jsx)(oe,{variant:"text",size:"icon",children:(0,o.jsx)(zt,{className:"h-4 w-4"})})})}),(0,o.jsxs)(_r,{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)(mr,{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)(rt,{})}),i.length===0&&l&&s.length>0&&(0,o.jsx)(Xe,{title:"No chats found",description:`No chats match "${l}"`,icon:(0,o.jsx)(ur,{})}),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(p=>(0,o.jsxs)("button",{className:ae("w-full p-1 rounded-md cursor-pointer text-left flex items-center justify-between",p.id===e&&"bg-accent",p.id!==e&&"hover:bg-muted/20"),onClick:()=>{t(p.id)},type:"button",children:[(0,o.jsx)("div",{className:"flex-1 min-w-0",children:(0,o.jsx)("div",{className:"text-sm truncate",children:p.title})}),(0,o.jsx)("div",{className:"text-xs text-muted-foreground/60 ml-2 flex-shrink-0",children:Cr(p.updatedAt,n)})]},p.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)(dr,{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)(oe,{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)(pr,{className:"h-4 w-4"}),t[6]=d):d=t[6];let p;t[7]===u?p=t[8]:(p=(0,o.jsx)(Ye,{content:"AI Settings",children:(0,o.jsx)(oe,{variant:"text",size:"xs",className:"hover:bg-foreground/10 py-2",onClick:u,children:d})}),t[7]=u,t[8]=p);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]!==p||t[13]!==h?(f=(0,o.jsxs)("div",{className:"flex items-center gap-2",children:[c,p,h]}),t[12]=p,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,m.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=S=>{var N,R,y;let A=(R=(N=S.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 Ue}from"./useEvent-O0nX5vok.js";import{t as Pt}from"./react-Bj1aDYRI.js";import{E as Dt,or as zt}from"./cells-Ir3O9-uE.js";import"./react-dom-CSu739Rf.js";import{t as Qe}from"./compiler-runtime-B3qBwwSJ.js";import{T as Mt,o as Ft,r as Ze,t as Ht,w as Ot}from"./ai-model-dropdown-Cl-qIUat.js";import{m as Te,r as le}from"./useEventListener-Dy81QR4n.js";import{n as et,r as Wt}from"./utils-tNbLd14P.js";import{o as Ut}from"./config-DRN1Q5Ol.js";import{t as Yt}from"./jsx-runtime-icT_Ltz2.js";import{t as oe}from"./button-Ej3vmCIF.js";import{t as ae}from"./cn-BoaCR37F.js";import"./dist-B_cxg-E4.js";import"./cjs-BU2qXMKx.js";import"./main-DrBRErTM.js";import"./useNonce-BtW-rR_1.js";import{r as Xt}from"./requests-Bgjtqo_1.js";import{t as tt}from"./createLucideIcon-Cm-Z7dYr.js";import{t as rt}from"./bot-message-square-Dw41U6lL.js";import"./markdown-renderer-DpNwn0oX.js";import{O as lt,S as Bt,T as Vt,_ as qt,b as $t,c as Gt,d as Jt,f as Kt,g as Qt,h as Zt,j as er,k as tr,l as rr,m as ot,n as at,p as lr,s as or,u as ar,v as nr,y as sr}from"./add-cell-with-ai-C75dyXgo.js";import{n as ir}from"./spinner-C5JoisA7.js";import{t as cr}from"./message-circle-BaZF1NX9.js";import{t as dr}from"./plus-D1HlXYzG.js";import{dt as ur,r as mr}from"./input-6cciao_l.js";import{t as pr}from"./settings-dVFT0AvU.js";import"./dist-1ZGGzJka.js";import"./dist-DA4gn7fy.js";import"./dist-Bh-vrbeU.js";import"./dist-4rKUx1vk.js";import"./dist-BXtR56No.js";import"./session-DKzpcHdK.js";import{C as hr,E as fr,_ as me,g as X,w as B,x as Ae}from"./Combination-CXstThSr.js";import{a as xr,i as vr,n as gr,p as wr,r as br,s as yr,t as jr}from"./select-dNVaT2hT.js";import{i as nt,t as Ye}from"./tooltip-BCGmr4TU.js";import{u as Sr}from"./menu-items-DkKu0R5b.js";import"./purify.es-ByGlPBcv.js";import{i as Cr}from"./dates-Bh1ltXGt.js";import{t as Nr}from"./context-BPhh8SWw.js";import{i as Rr,r as _r,t as Tr}from"./popover-C5P0DZBj.js";import{t as Ar}from"./copy-icon-BNQYrUYC.js";import{r as st,t as Er}from"./state-Cobrzbya.js";import{n as kr}from"./error-banner-D6woGaqN.js";import"./chunk-5FQGJX7Z-KaqPPQRg.js";import"./html-to-image-B1AmbwBb.js";import"./esm-BMWduMhT.js";import{t as Xe}from"./empty-state-DUEogWxf.js";import{t as Lr}from"./chat-display-TEJB6Bj2.js";var Ir=tt("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"}]]),Pr=tt("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"}]]),it=Qe(),m=Ke(Pt(),1);const Dr=({chatState:e,chatId:t,messages:r})=>{if(!t)return Te.warn("No active chat"),e;let n=e.chats.get(t);if(!n)return Te.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 o=Ke(Yt(),1);function zr(e,t){return m.useReducer((r,n)=>t[r][n]??r,e)}var Be="ScrollArea",[ct,mo]=fr(Be),[Mr,M]=ct(Be),dt=m.forwardRef((e,t)=>{let{__scopeScrollArea:r,type:n="hover",dir:l,scrollHideDelay:a=600,...s}=e,[i,c]=m.useState(null),[u,d]=m.useState(null),[p,h]=m.useState(null),[f,v]=m.useState(null),[S,A]=m.useState(null),[w,N]=m.useState(0),[R,y]=m.useState(0),[j,C]=m.useState(!1),[E,I]=m.useState(!1),g=le(t,k=>c(k)),T=Sr(l);return(0,o.jsx)(Mr,{scope:r,type:n,dir:T,scrollHideDelay:a,scrollArea:i,viewport:u,onViewportChange:d,content:p,onContentChange:h,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:j,onScrollbarXEnabledChange:C,scrollbarY:S,onScrollbarYChange:A,scrollbarYEnabled:E,onScrollbarYEnabledChange:I,onCornerWidthChange:N,onCornerHeightChange:y,children:(0,o.jsx)(me.div,{dir:T,...s,ref:g,style:{position:"relative","--radix-scroll-area-corner-width":w+"px","--radix-scroll-area-corner-height":R+"px",...e.style}})})});dt.displayName=Be;var ut="ScrollAreaViewport",mt=m.forwardRef((e,t)=>{let{__scopeScrollArea:r,children:n,nonce:l,...a}=e,s=M(ut,r),i=le(t,m.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)(me.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})})]})});mt.displayName=ut;var W="ScrollAreaScrollbar",Ve=m.forwardRef((e,t)=>{let{forceMount:r,...n}=e,l=M(W,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:s}=l,i=e.orientation==="horizontal";return m.useEffect(()=>(i?a(!0):s(!0),()=>{i?a(!1):s(!1)}),[i,a,s]),l.type==="hover"?(0,o.jsx)(Fr,{...n,ref:t,forceMount:r}):l.type==="scroll"?(0,o.jsx)(Hr,{...n,ref:t,forceMount:r}):l.type==="auto"?(0,o.jsx)(pt,{...n,ref:t,forceMount:r}):l.type==="always"?(0,o.jsx)(qe,{...n,ref:t}):null});Ve.displayName=W;var Fr=m.forwardRef((e,t)=>{let{forceMount:r,...n}=e,l=M(W,e.__scopeScrollArea),[a,s]=m.useState(!1);return m.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)(Ae,{present:r||a,children:(0,o.jsx)(pt,{"data-state":a?"visible":"hidden",...n,ref:t})})}),Hr=m.forwardRef((e,t)=>{let{forceMount:r,...n}=e,l=M(W,e.__scopeScrollArea),a=e.orientation==="horizontal",s=Ie(()=>c("SCROLL_END"),100),[i,c]=zr("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 m.useEffect(()=>{if(i==="idle"){let u=window.setTimeout(()=>c("HIDE"),l.scrollHideDelay);return()=>window.clearTimeout(u)}},[i,l.scrollHideDelay,c]),m.useEffect(()=>{let u=l.viewport,d=a?"scrollLeft":"scrollTop";if(u){let p=u[d],h=()=>{let f=u[d];p!==f&&(c("SCROLL"),s()),p=f};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[l.viewport,a,c,s]),(0,o.jsx)(Ae,{present:r||i!=="hidden",children:(0,o.jsx)(qe,{"data-state":i==="hidden"?"hidden":"visible",...n,ref:t,onPointerEnter:B(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:B(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),pt=m.forwardRef((e,t)=>{let r=M(W,e.__scopeScrollArea),{forceMount:n,...l}=e,[a,s]=m.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)(Ae,{present:n||a,children:(0,o.jsx)(qe,{"data-state":a?"visible":"hidden",...l,ref:t})})}),qe=m.forwardRef((e,t)=>{let{orientation:r="vertical",...n}=e,l=M(W,e.__scopeScrollArea),a=m.useRef(null),s=m.useRef(0),[i,c]=m.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=gt(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 p(h,f){return Br(h,s.current,i,f)}return r==="horizontal"?(0,o.jsx)(Or,{...d,ref:t,onThumbPositionChange:()=>{if(l.viewport&&a.current){let h=l.viewport.scrollLeft,f=wt(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=p(h,l.dir))}}):r==="vertical"?(0,o.jsx)(Wr,{...d,ref:t,onThumbPositionChange:()=>{if(l.viewport&&a.current){let h=l.viewport.scrollTop,f=wt(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=p(h))}}):null}),Or=m.forwardRef((e,t)=>{let{sizes:r,onSizesChange:n,...l}=e,a=M(W,e.__scopeScrollArea),[s,i]=m.useState(),c=m.useRef(null),u=le(t,c,a.onScrollbarXChange);return m.useEffect(()=>{c.current&&i(getComputedStyle(c.current))},[c]),(0,o.jsx)(ft,{"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,p)=>{if(a.viewport){let h=a.viewport.scrollLeft+d.deltaX;e.onWheelScroll(h),yt(h,p)&&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)}})}})}),Wr=m.forwardRef((e,t)=>{let{sizes:r,onSizesChange:n,...l}=e,a=M(W,e.__scopeScrollArea),[s,i]=m.useState(),c=m.useRef(null),u=le(t,c,a.onScrollbarYChange);return m.useEffect(()=>{c.current&&i(getComputedStyle(c.current))},[c]),(0,o.jsx)(ft,{"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,p)=>{if(a.viewport){let h=a.viewport.scrollTop+d.deltaY;e.onWheelScroll(h),yt(h,p)&&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)}})}})}),[Ur,ht]=ct(W),ft=m.forwardRef((e,t)=>{let{__scopeScrollArea:r,sizes:n,hasThumb:l,onThumbChange:a,onThumbPointerUp:s,onThumbPointerDown:i,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:d,onResize:p,...h}=e,f=M(W,r),[v,S]=m.useState(null),A=le(t,g=>S(g)),w=m.useRef(null),N=m.useRef(""),R=f.viewport,y=n.content-n.viewport,j=X(d),C=X(c),E=Ie(p,10);function I(g){w.current&&u({x:g.clientX-w.current.left,y:g.clientY-w.current.top})}return m.useEffect(()=>{let g=T=>{let k=T.target;v!=null&&v.contains(k)&&j(T,y)};return document.addEventListener("wheel",g,{passive:!1}),()=>document.removeEventListener("wheel",g,{passive:!1})},[R,v,y,j]),m.useEffect(C,[n,C]),ne(v,E),ne(f.content,E),(0,o.jsx)(Ur,{scope:r,scrollbar:v,hasThumb:l,onThumbChange:X(a),onThumbPointerUp:X(s),onThumbPositionChange:C,onThumbPointerDown:X(i),children:(0,o.jsx)(me.div,{...h,ref:A,style:{position:"absolute",...h.style},onPointerDown:B(e.onPointerDown,g=>{g.button===0&&(g.target.setPointerCapture(g.pointerId),w.current=v.getBoundingClientRect(),N.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),I(g))}),onPointerMove:B(e.onPointerMove,I),onPointerUp:B(e.onPointerUp,g=>{let T=g.target;T.hasPointerCapture(g.pointerId)&&T.releasePointerCapture(g.pointerId),document.body.style.webkitUserSelect=N.current,f.viewport&&(f.viewport.style.scrollBehavior=""),w.current=null})})})}),Ee="ScrollAreaThumb",xt=m.forwardRef((e,t)=>{let{forceMount:r,...n}=e,l=ht(Ee,e.__scopeScrollArea);return(0,o.jsx)(Ae,{present:r||l.hasThumb,children:(0,o.jsx)(Yr,{ref:t,...n})})}),Yr=m.forwardRef((e,t)=>{let{__scopeScrollArea:r,style:n,...l}=e,a=M(Ee,r),s=ht(Ee,r),{onThumbPositionChange:i}=s,c=le(t,p=>s.onThumbChange(p)),u=m.useRef(void 0),d=Ie(()=>{u.current&&(u.current=(u.current(),void 0))},100);return m.useEffect(()=>{let p=a.viewport;if(p){let h=()=>{d(),u.current||(u.current=Vr(p,i),i())};return i(),p.addEventListener("scroll",h),()=>p.removeEventListener("scroll",h)}},[a.viewport,d,i]),(0,o.jsx)(me.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:B(e.onPointerDownCapture,p=>{let h=p.target.getBoundingClientRect(),f=p.clientX-h.left,v=p.clientY-h.top;s.onThumbPointerDown({x:f,y:v})}),onPointerUp:B(e.onPointerUp,s.onThumbPointerUp)})});xt.displayName=Ee;var $e="ScrollAreaCorner",vt=m.forwardRef((e,t)=>{let r=M($e,e.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?(0,o.jsx)(Xr,{...e,ref:t}):null});vt.displayName=$e;var Xr=m.forwardRef((e,t)=>{let{__scopeScrollArea:r,...n}=e,l=M($e,r),[a,s]=m.useState(0),[i,c]=m.useState(0),u=!!(a&&i);return ne(l.scrollbarX,()=>{var p;let d=((p=l.scrollbarX)==null?void 0:p.offsetHeight)||0;l.onCornerHeightChange(d),c(d)}),ne(l.scrollbarY,()=>{var p;let d=((p=l.scrollbarY)==null?void 0:p.offsetWidth)||0;l.onCornerWidthChange(d),s(d)}),u?(0,o.jsx)(me.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 gt(e,t){let r=e/t;return isNaN(r)?0:r}function Le(e){let t=gt(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,n=(e.scrollbar.size-r)*t;return Math.max(n,18)}function Br(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,p=n==="ltr"?[0,d]:[d*-1,0];return bt([c,u],p)(e)}function wt(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=wr(e,r==="ltr"?[0,s]:[s*-1,0]);return bt([0,s],[0,i])(c)}function bt(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 yt(e,t){return e>0&&e<t}var Vr=(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=X(e),n=m.useRef(0);return m.useEffect(()=>()=>window.clearTimeout(n.current),[]),m.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,t)},[r,t])}function ne(e,t){let r=X(t);hr(()=>{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 jt=dt,qr=mt,$r=vt,St=m.forwardRef((e,t)=>{let r=(0,it.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=ae("relative overflow-hidden",l),r[4]=l,r[5]=s);let i;r[6]===n?i=r[7]:(i=(0,o.jsx)(qr,{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)($r,{}),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)(jt,{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=jt.displayName;var Ct=m.forwardRef((e,t)=>{let r=(0,it.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=ae("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)(xt,{className:"relative flex-1 rounded-full bg-border"}),r[8]=d):d=r[8];let p;return r[9]!==s||r[10]!==l||r[11]!==t||r[12]!==u?(p=(0,o.jsx)(Ve,{ref:t,orientation:s,className:u,...l,children:d}),r[9]=s,r[10]=l,r[11]=t,r[12]=u,r[13]=p):p=r[13],p});Ct.displayName=Ve.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=Ue(st),{locale:n}=Nr(),[l,a]=(0,m.useState)(""),s=(0,m.useMemo)(()=>[...r.chats.values()].sort((u,d)=>d.updatedAt-u.updatedAt),[r.chats]),i=(0,m.useMemo)(()=>l.trim()?s.filter(u=>u.title.toLowerCase().includes(l.toLowerCase())):s,[s,l]),c=(0,m.useMemo)(()=>Jr(i),[i]);return(0,o.jsxs)(Tr,{children:[(0,o.jsx)(Ye,{content:"Previous chats",children:(0,o.jsx)(Rr,{asChild:!0,children:(0,o.jsx)(oe,{variant:"text",size:"icon",children:(0,o.jsx)(zt,{className:"h-4 w-4"})})})}),(0,o.jsxs)(_r,{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)(mr,{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)(rt,{})}),i.length===0&&l&&s.length>0&&(0,o.jsx)(Xe,{title:"No chats found",description:`No chats match "${l}"`,icon:(0,o.jsx)(ur,{})}),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(p=>(0,o.jsxs)("button",{className:ae("w-full p-1 rounded-md cursor-pointer text-left flex items-center justify-between",p.id===e&&"bg-accent",p.id!==e&&"hover:bg-muted/20"),onClick:()=>{t(p.id)},type:"button",children:[(0,o.jsx)("div",{className:"flex-1 min-w-0",children:(0,o.jsx)("div",{className:"text-sm truncate",children:p.title})}),(0,o.jsx)("div",{className:"text-xs text-muted-foreground/60 ml-2 flex-shrink-0",children:Cr(p.updatedAt,n)})]},p.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)(dr,{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)(oe,{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)(pr,{className:"h-4 w-4"}),t[6]=d):d=t[6];let p;t[7]===u?p=t[8]:(p=(0,o.jsx)(Ye,{content:"AI Settings",children:(0,o.jsx)(oe,{variant:"text",size:"xs",className:"hover:bg-foreground/10 py-2",onClick:u,children:d})}),t[7]=u,t[8]=p);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]!==p||t[13]!==h?(f=(0,o.jsxs)("div",{className:"flex items-center gap-2",children:[c,p,h]}),t[12]=p,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,m.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=S=>{var N,R,y;let A=(R=(N=S.parts)==null?void 0:N.filter(rl))==null?void 0:R.map(ll).join(`
2
2
  `),w=(y=S.parts)==null?void 0:y.filter(ol);return(0,o.jsxs)("div",{className:"w-[95%] bg-background border p-1 rounded-sm",children:[w==null?void 0:w.map(al),(0,o.jsx)(at,{value:A,placeholder:"Type your message...",onChange:nl,onSubmit:(j,C)=>{C.trim()&&l(n,C)},onClose:sl},S.id)]})},t[0]=n,t[1]=l,t[2]=i):i=t[2];let c=i,u;t[3]!==s||t[4]!==a?(u=S=>(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)(Ar,{className:"h-3 w-3",value:S.parts.filter(il).map(cl).join(`
3
3
  `)||""})}),Lr({message:S,isStreamingReasoning:a,isLast:s})]}),t[3]=s,t[4]=a,t[5]=u):u=t[5];let d=u,p=r.role==="user"?"justify-end":"justify-start",h;t[6]===p?h=t[7]:(h=ae("flex group relative",p),t[6]=p,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 _t=(0,m.memo)(e=>{var D,U;let t=(0,se.c)(39),{isEmpty:r,onSendClick:n,isLoading:l,onStop:a,fileInputRef:s,onAddFiles:i,onAddContext:c}=e,u=Ue(et),d=(u==null?void 0:u.mode)||Nt,p=((D=u==null?void 0:u.models)==null?void 0:D.chat_model)||"openai/gpt-4o",h=Ot.parse(p).providerId,{saveModeChange:f}=Mt(),v;t[0]===Symbol.for("react.memo_cache_sentinel")?(v=[{value:"manual",label:"Manual",subtitle:"Pure chat, no tool usage",Icon:cr},{value:"ask",label:"Ask",subtitle:"Use AI with access to read-only tools like documentation search",Icon:Pr},{value:"agent",label:"Agent (beta)",subtitle:"Use AI with access to read and write tools",Icon:Ir}],t[0]=v):v=t[0];let S=v,A=Kt.has(h),w=(U=S.find(pe=>pe.value===d))==null?void 0:U.Icon,N;t[1]===w?N=t[2]:(N=w&&(0,o.jsx)(w,{className:"h-3 w-3"}),t[1]=w,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)(yr,{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 j;t[8]===Symbol.for("react.memo_cache_sentinel")?(j=(0,o.jsx)(xr,{className:"text-xs uppercase tracking-wider text-muted-foreground/70 font-medium",children:"AI Mode"}),t[8]=j):j=t[8];let C;t[9]===S?C=t[10]:(C=(0,o.jsx)(gr,{children:(0,o.jsxs)(br,{children:[j,S.map(dl)]})}),t[9]=S,t[10]=C);let E;t[11]!==d||t[12]!==f||t[13]!==y||t[14]!==C?(E=(0,o.jsxs)(jr,{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 g;t[17]===E?g=t[18]:(g=(0,o.jsxs)("div",{className:"flex items-center gap-2",children:[E,I]}),t[17]=E,t[18]=g);let T;t[19]!==l||t[20]!==c?(T=(0,o.jsx)(or,{handleAddContext:c,isLoading:l}),t[19]=l,t[20]=c,t[21]=T):T=t[21];let k;t[22]!==s||t[23]!==A||t[24]!==l||t[25]!==i?(k=A&&(0,o.jsx)(Gt,{fileInputRef:s,isLoading:l,onAddFiles:i}),t[22]=s,t[23]=A,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)(Jt,{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||t[33]!==k||t[34]!==F?(H=(0,o.jsxs)("div",{className:"flex flex-row",children:[T,k,F]}),t[32]=T,t[33]=k,t[34]=F,t[35]=H):H=t[35];let _;return t[36]!==H||t[37]!==g?(_=(0,o.jsx)(nt,{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:[g,H]})}),t[36]=H,t[37]=g,t[38]=_):_=t[38],_});_t.displayName="ChatInputFooter";var Ge=(0,m.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:p,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),S;t[3]===l?S=t[4]:(S=ae("px-2 py-3 flex-1",l),t[3]=l,t[4]=S);let A=r||"Type your message...",w;t[5]!==n||t[6]!==i||t[7]!==p||t[8]!==h||t[9]!==s||t[10]!==a||t[11]!==A?(w=(0,o.jsx)(at,{inputRef:i,value:n,onChange:a,onSubmit:s,onClose:h,onAddFiles:p,placeholder:A}),t[5]=n,t[6]=i,t[7]=p,t[8]=h,t[9]=s,t[10]=a,t[11]=A,t[12]=w):w=t[12];let N;t[13]!==S||t[14]!==w?(N=(0,o.jsx)("div",{className:S,children:w}),t[13]=S,t[14]=w,t[15]=N):N=t[15];let R=!n.trim(),y;t[16]===i?y=t[17]:(y=()=>Vt(i),t[16]=i,t[17]=y);let j;t[18]!==d||t[19]!==v||t[20]!==c||t[21]!==p||t[22]!==u||t[23]!==R||t[24]!==y?(j=(0,o.jsx)(_t,{isEmpty:R,onAddContext:y,onSendClick:v,isLoading:c,onStop:u,fileInputRef:d,onAddFiles:p}),t[18]=d,t[19]=v,t[20]=c,t[21]=p,t[22]=u,t[23]=R,t[24]=y,t[25]=j):j=t[25];let C;return t[26]!==N||t[27]!==j?(C=(0,o.jsxs)("div",{className:"relative shrink-0 min-h-[80px] flex flex-col border-t",children:[N,j]}),t[26]=N,t[27]=j,t[28]=C):C=t[28],C});Ge.displayName="ChatInput";var Zr=()=>{let e=(0,se.c)(6),t=Ue(Wt),{handleClick:r}=Ze();if(!t){let l;e[0]===r?l=e[1]:(l=(0,o.jsx)(oe,{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)(rt,{}),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,m.useState)(""),[s,i]=(0,m.useState)(""),{files:c,addFiles:u,clearFiles:d,removeFile:p}=sr(),h=(0,m.useRef)(null),f=(0,m.useRef)(null),v=(0,m.useRef)(null),S=(0,m.useRef)(null),A=(0,m.useRef)(null),w=Ut(),{invokeAiTool:N,sendRun:R}=Xt(),y=r==null?void 0:r.id,j=Lt(),{addStagedCell:C}=Bt(),{createNewCell:E,prepareForRun:I}=Dt(),g;e[0]!==C||e[1]!==E||e[2]!==I||e[3]!==R||e[4]!==j?(g={addStagedCell:C,createNewCell:E,prepareForRun:I,sendRun:R,store:j},e[0]=C,e[1]=E,e[2]=I,e[3]=R,e[4]=j,e[5]=g):g=e[5];let T=g,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]!==w||e[9]!==j){let x;e[11]===j?x=e[12]:(x=async b=>{var re;let L=await lr(b.messages),O=((re=j.get(et))==null?void 0:re.mode)||Nt;return{body:{tools:$t.getToolSchemas(O),...b,...L}}},e[11]=j,e[12]=x),F=new er({api:w.getAiURL("chat").toString(),headers:w.headers(),prepareSendMessagesRequest:x}),e[8]=w,e[9]=j,e[10]=F}else F=e[10];let H;e[13]===t?H=e[14]:(H=x=>{let{messages:b}=x;t(L=>Dr({chatState:L,chatId:L.activeChatId,messages:b}))},e[13]=t,e[14]=H);let{messages:_,sendMessage:D,error:U,status:pe,regenerate:Pe,stop:Y,addToolOutput:Tt,id:De}=tr({id:y,sendAutomaticallyWhen:ul,messages:k,transport:F,onFinish:H,onToolCall:async x=>{let{toolCall:b}=x;if(b.dynamic){Te.debug("Skipping dynamic tool call",b);return}await Qt({invokeAiTool:N,addToolOutput:At,toolCall:{toolName:b.toolName,toolCallId:b.toolCallId,input:b.input},toolContext:T})},onError:ml}),At=Tt,P=pe==="submitted"||pe==="streaming",he;e[15]!==P||e[16]!==_?(he=P&&_.length>0&&nr(_),e[15]=P,e[16]=_,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,m.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:Zt(x),messages:[],createdAt:L,updatedAt:L};t(de=>{let Je=new Map(de.chats);return Je.set(O.id,O),{...de,chats:Je,activeChatId:O.id}});let re=b&&b.length>0?await ot(b):void 0;D({role:"user",parts:[{type:"text",text:x},...re??[]]}),d(),a("")},e[21]=De,e[22]=d,e[23]=D,e[24]=t,e[25]=ve):ve=e[25];let ze=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 Me=ue(ge),we;e[29]!==_||e[30]!==D?(we=(x,b)=>{var de;let L=_[x],O=(de=L.parts)==null?void 0:de.filter(pl),re=L.id;D({messageId:re,role:"user",parts:[{type:"text",text:b},...O]})},e[29]=_,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&&lt(f.current.view);let L=c?await ot(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]!==ze||e[39]!==c||e[40]!==s?(je=()=>{var x;s.trim()&&((x=h.current)!=null&&x.view&&lt(h.current.view),ze(s.trim(),c))},e[38]=ze,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,z=_.length===0,Ce;e[43]!==u||e[44]!==Fe||e[45]!==Oe||e[46]!==l||e[47]!==P||e[48]!==z||e[49]!==s||e[50]!==Y?(Ce=z?(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:Y,fileInputRef:S,onAddFiles:u,onClose:Et},"new-thread-input"):(0,o.jsx)(Ge,{input:l,setInput:a,onSubmit:Fe,inputRef:f,isLoading:P,onStop:Y,onClose:()=>{var x,b;return(b=(x=f.current)==null?void 0:x.editor)==null?void 0:b.blur()},fileInputRef:S,onAddFiles:u}),e[43]=u,e[44]=Fe,e[45]=Oe,e[46]=l,e[47]=P,e[48]=z,e[49]=s,e[50]=Y,e[51]=Ce):Ce=e[51];let V=Ce,Ne;e[52]!==c||e[53]!==z||e[54]!==p?(Ne=c&&c.length>0&&(0,o.jsx)("div",{className:ae("flex flex-row gap-1 flex-wrap p-1",z&&"py-2 px-1"),children:c==null?void 0:c.map(x=>(0,o.jsx)(ar,{file:x,onRemove:()=>p(x)},x.name))}),e[52]=c,e[53]=z,e[54]=p,e[55]=Ne):Ne=e[55];let q=Ne,We=r==null?void 0:r.id,$;e[56]!==Me||e[57]!==n||e[58]!==We?($=(0,o.jsx)(nt,{children:(0,o.jsx)(Qr,{onNewChat:Me,activeChatId:We,setActiveChat:n})}),e[56]=Me,e[57]=n,e[58]=We,e[59]=$):$=e[59];let G;e[60]!==V||e[61]!==q||e[62]!==z?(G=z&&(0,o.jsxs)("div",{className:"rounded-md border bg-background",children:[q,V]}),e[60]=V,e[61]=q,e[62]=z,e[63]=G):G=e[63];let J;if(e[64]!==ce||e[65]!==ie||e[66]!==_){let x;e[68]!==ce||e[69]!==ie||e[70]!==_.length?(x=(b,L)=>(0,o.jsx)(Rt,{message:b,index:L,onEdit:ce,isStreamingReasoning:ie,isLast:L===_.length-1},b.id),e[68]=ce,e[69]=ie,e[70]=_.length,e[71]=x):x=e[71],J=_.map(x),e[64]=ce,e[65]=ie,e[66]=_,e[67]=J}else J=e[67];let K;e[72]===P?K=e[73]:(K=P&&(0,o.jsx)("div",{className:"flex justify-center py-4",children:(0,o.jsx)(ir,{className:"h-4 w-4 animate-spin"})}),e[72]=P,e[73]=K);let Q;e[74]!==U||e[75]!==He?(Q=U&&(0,o.jsxs)("div",{className:"flex items-center justify-center space-x-2 mb-4",children:[(0,o.jsx)(kr,{error:U||Error("Unknown error")}),(0,o.jsx)(oe,{variant:"outline",size:"sm",onClick:He,children:"Retry"})]}),e[74]=U,e[75]=He,e[76]=Q):Q=e[76];let Re;e[77]===Symbol.for("react.memo_cache_sentinel")?(Re=(0,o.jsx)("div",{ref:A}),e[77]=Re):Re=e[77];let Z;e[78]!==G||e[79]!==J||e[80]!==K||e[81]!==Q?(Z=(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:[G,J,K,Q,Re]}),e[78]=G,e[79]=J,e[80]=K,e[81]=Q,e[82]=Z):Z=e[82];let ee;e[83]!==P||e[84]!==Y?(ee=P&&(0,o.jsx)("div",{className:"w-full flex justify-center items-center z-20 border-t",children:(0,o.jsx)(oe,{variant:"linkDestructive",size:"sm",onClick:Y,children:"Stop"})}),e[83]=P,e[84]=Y,e[85]=ee):ee=e[85];let te;e[86]!==V||e[87]!==q||e[88]!==z?(te=!z&&(0,o.jsxs)(o.Fragment,{children:[q,V]}),e[86]=V,e[87]=q,e[88]=z,e[89]=te):te=e[89];let _e;return e[90]!==$||e[91]!==Z||e[92]!==ee||e[93]!==te?(_e=(0,o.jsxs)("div",{className:"flex flex-col h-[calc(100%-53px)]",children:[$,Z,ee,te]}),e[90]=$,e[91]=Z,e[92]=ee,e[93]=te,e[94]=_e):_e=e[94],_e},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)(rr,{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)(vr,{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 qt(t)}function ml(e){Te.error("An error occurred:",e)}function pl(e){return e.type==="file"}export{tl as default};
@@ -1,4 +1,4 @@
1
- import{s as X}from"./chunk-LvLJmgfZ.js";import"./useEvent-O0nX5vok.js";import{t as re}from"./react-Bj1aDYRI.js";import{en as ae}from"./cells-B8rT_yJt.js";import"./react-dom-CSu739Rf.js";import{C as ne,P as le,R as oe,T as ie,k as me}from"./zod-H_cgTO0M.js";import{t as ce}from"./compiler-runtime-B3qBwwSJ.js";import{s as de}from"./useLifecycle-DA9DjSPo.js";import{c as pe,m as K,t as ue}from"./useEventListener-Dy81QR4n.js";import{t as he}from"./jsx-runtime-icT_Ltz2.js";import{t as z}from"./button-Ej3vmCIF.js";import{t as Z}from"./cn-BoaCR37F.js";import"./dist-B_cxg-E4.js";import"./cjs-BU2qXMKx.js";import"./main-DrBRErTM.js";import"./useNonce-BtW-rR_1.js";import{t as xe}from"./createLucideIcon-Cm-Z7dYr.js";import{t as fe}from"./bot-message-square-Dw41U6lL.js";import{t as ge}from"./x-CdLP7-v3.js";import"./markdown-renderer-f7AvSa1a.js";import{u as be}from"./toDate-Cfp9W_O9.js";import{M as je,N as ve,P as ye,j as Ne,k as we,m as _e,n as ke}from"./add-cell-with-ai-u_AX7UAd.js";import{a as Ce,p as Se,r as Ae,t as Me}from"./dropdown-menu-CA9akLlF.js";import{t as Re}from"./spinner-C5JoisA7.js";import{o as ze,r as Ee}from"./input-6cciao_l.js";import{t as Ie}from"./settings-dVFT0AvU.js";import{t as qe}from"./trash-2-B7Q-bnsg.js";import"./dist-1ZGGzJka.js";import"./dist-DA4gn7fy.js";import"./dist-Bh-vrbeU.js";import"./dist-4rKUx1vk.js";import"./dist-BXtR56No.js";import"./session-DKzpcHdK.js";import"./Combination-CXstThSr.js";import{t as Y}from"./tooltip-BCGmr4TU.js";import"./purify.es-ByGlPBcv.js";import{a as Fe,i as $e,r as B,t as G}from"./popover-C5P0DZBj.js";import{r as De}from"./react-icons.esm-BJVxNhcA.js";import{t as Oe}from"./copy-icon-BNQYrUYC.js";import{t as Pe}from"./events-GxnDgt0p.js";import{n as He}from"./error-banner-D6woGaqN.js";import{n as Le}from"./useAsyncData-VEt7lMhG.js";import"./chunk-5FQGJX7Z-KaqPPQRg.js";import"./html-to-image-BtnUxAf2.js";import{t as U}from"./label-KlZhD0Wz.js";import"./esm-BMWduMhT.js";import{t as Te}from"./chat-display-DSlMdLnv.js";var Ve=xe("rotate-cw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]),J=ce(),b=X(re(),1),t=X(he(),1),Ke=le({type:me("stream_chunk"),message_id:oe(),content:ne().nullable().transform(s=>s),is_final:ie().optional()});const Ye=s=>{var W;let[e,m]=(0,b.useState)(""),[x,N]=(0,b.useState)(s.config),[_,c]=(0,b.useState)(s.config),[o,f]=(0,b.useState)(void 0),h=(0,b.useRef)(null),g=(0,b.useRef)(null),j=(0,b.useRef)(null),i=(0,b.useRef)(null);Object.keys(s.config).some(r=>s.config[r]!==_[r])&&(N(s.config),c(s.config));let l=(0,b.useRef)(x);l.current=x;let p=(0,b.useRef)({backendMessageId:null,frontendMessageIndex:null}),a=(0,b.useRef)(null),{data:d}=Le(async()=>(await s.get_chat_history({})).messages,[]),n=s.value.length>0?s.value:d,{messages:u,sendMessage:k,setMessages:R,status:A,stop:$,error:C,regenerate:M,clearError:S}=we({transport:new Ne({fetch:async(r,v)=>{var D;if(v===void 0)return fetch(r);let y=JSON.parse(v.body),w=v.signal,L={max_tokens:l.current.max_tokens,temperature:l.current.temperature,top_p:l.current.top_p,top_k:l.current.top_k,frequency_penalty:l.current.frequency_penalty,presence_penalty:l.current.presence_penalty};try{let P=y.messages.map(F=>{var E;return{...F,content:(E=F.parts)==null?void 0:E.map(T=>"text"in T?T.text:"").join(`
1
+ import{s as X}from"./chunk-LvLJmgfZ.js";import"./useEvent-O0nX5vok.js";import{t as re}from"./react-Bj1aDYRI.js";import{en as ae}from"./cells-Ir3O9-uE.js";import"./react-dom-CSu739Rf.js";import{C as ne,P as le,R as oe,T as ie,k as me}from"./zod-H_cgTO0M.js";import{t as ce}from"./compiler-runtime-B3qBwwSJ.js";import{s as de}from"./useLifecycle-DA9DjSPo.js";import{c as pe,m as K,t as ue}from"./useEventListener-Dy81QR4n.js";import{t as he}from"./jsx-runtime-icT_Ltz2.js";import{t as z}from"./button-Ej3vmCIF.js";import{t as Z}from"./cn-BoaCR37F.js";import"./dist-B_cxg-E4.js";import"./cjs-BU2qXMKx.js";import"./main-DrBRErTM.js";import"./useNonce-BtW-rR_1.js";import{t as xe}from"./createLucideIcon-Cm-Z7dYr.js";import{t as fe}from"./bot-message-square-Dw41U6lL.js";import{t as ge}from"./x-CdLP7-v3.js";import"./markdown-renderer-DpNwn0oX.js";import{u as be}from"./toDate-Cfp9W_O9.js";import{M as je,N as ve,P as ye,j as Ne,k as we,m as _e,n as ke}from"./add-cell-with-ai-C75dyXgo.js";import{a as Ce,p as Se,r as Ae,t as Me}from"./dropdown-menu-CA9akLlF.js";import{t as Re}from"./spinner-C5JoisA7.js";import{o as ze,r as Ee}from"./input-6cciao_l.js";import{t as Ie}from"./settings-dVFT0AvU.js";import{t as qe}from"./trash-2-B7Q-bnsg.js";import"./dist-1ZGGzJka.js";import"./dist-DA4gn7fy.js";import"./dist-Bh-vrbeU.js";import"./dist-4rKUx1vk.js";import"./dist-BXtR56No.js";import"./session-DKzpcHdK.js";import"./Combination-CXstThSr.js";import{t as Y}from"./tooltip-BCGmr4TU.js";import"./purify.es-ByGlPBcv.js";import{a as Fe,i as $e,r as B,t as G}from"./popover-C5P0DZBj.js";import{r as De}from"./react-icons.esm-BJVxNhcA.js";import{t as Oe}from"./copy-icon-BNQYrUYC.js";import{t as Pe}from"./events-GxnDgt0p.js";import{n as He}from"./error-banner-D6woGaqN.js";import{n as Le}from"./useAsyncData-VEt7lMhG.js";import"./chunk-5FQGJX7Z-KaqPPQRg.js";import"./html-to-image-B1AmbwBb.js";import{t as U}from"./label-KlZhD0Wz.js";import"./esm-BMWduMhT.js";import{t as Te}from"./chat-display-TEJB6Bj2.js";var Ve=xe("rotate-cw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]),J=ce(),b=X(re(),1),t=X(he(),1),Ke=le({type:me("stream_chunk"),message_id:oe(),content:ne().nullable().transform(s=>s),is_final:ie().optional()});const Ye=s=>{var W;let[e,m]=(0,b.useState)(""),[x,N]=(0,b.useState)(s.config),[_,c]=(0,b.useState)(s.config),[o,f]=(0,b.useState)(void 0),h=(0,b.useRef)(null),g=(0,b.useRef)(null),j=(0,b.useRef)(null),i=(0,b.useRef)(null);Object.keys(s.config).some(r=>s.config[r]!==_[r])&&(N(s.config),c(s.config));let l=(0,b.useRef)(x);l.current=x;let p=(0,b.useRef)({backendMessageId:null,frontendMessageIndex:null}),a=(0,b.useRef)(null),{data:d}=Le(async()=>(await s.get_chat_history({})).messages,[]),n=s.value.length>0?s.value:d,{messages:u,sendMessage:k,setMessages:R,status:A,stop:$,error:C,regenerate:M,clearError:S}=we({transport:new Ne({fetch:async(r,v)=>{var D;if(v===void 0)return fetch(r);let y=JSON.parse(v.body),w=v.signal,L={max_tokens:l.current.max_tokens,temperature:l.current.temperature,top_p:l.current.top_p,top_k:l.current.top_k,frequency_penalty:l.current.frequency_penalty,presence_penalty:l.current.presence_penalty};try{let P=y.messages.map(F=>{var E;return{...F,content:(E=F.parts)==null?void 0:E.map(T=>"text"in T?T.text:"").join(`
2
2
  `)}}),V=new ReadableStream({start(F){a.current=F;let E=()=>{try{F.close()}catch(T){K.debug("Controller may already be closed",{error:T})}a.current=null};return w==null||w.addEventListener("abort",E),()=>{w==null||w.removeEventListener("abort",E)}},cancel(){a.current=null}});return s.send_prompt({messages:P,config:L}).catch(F=>{var E;(E=a.current)==null||E.error(F),a.current=null}),je({stream:V})}catch(P){if(p.current={backendMessageId:null,frontendMessageIndex:null},P instanceof Error&&P.name==="AbortError")return new Response("Aborted",{status:499});let V=(D=P.message)==null?void 0:D.split("failed with exception ").pop();return new Response(V,{status:400})}}}),messages:n,onFinish:r=>{f(void 0),h.current&&(h.current.value=""),K.debug("Finished streaming message:",r),p.current={backendMessageId:null,frontendMessageIndex:null},s.setValue(r.messages)},onError:r=>{K.error("An error occurred:",r),p.current={backendMessageId:null,frontendMessageIndex:null}}});ue(s.host,Pe.TYPE,r=>{let v=Ke.safeParse(r.detail.message);if(!v.success)return;let y=v.data,w=a.current;w&&(y.content&&w.enqueue(y.content),y.is_final&&(w.close(),a.current=null))});let I=A==="submitted"||A==="streaming",O=r=>{let v=u.findIndex(y=>y.id===r);if(v!==-1){let y=u.filter(w=>w.id!==r);s.delete_chat_message({index:v}),R(y),s.setValue(y)}},Q=Array.isArray(s.allowAttachments)&&s.allowAttachments.length>0||s.allowAttachments===!0,ee={triggerCompletionRegex:/^\/(\w+)?/,completions:s.prompts.map(r=>({label:`/${r}`,displayLabel:r,apply:r}))},te=s.prompts.length>0?"Type your message here, / for prompts":"Type your message here...";(0,b.useEffect)(()=>{var r;(r=i.current)==null||r.scrollTo({top:i.current.scrollHeight,behavior:"smooth"})},[u.length,i]);let q=(W=j.current)==null?void 0:W.view,se=()=>{if(q){let r=q.state.doc.length;q.dispatch({changes:{from:0,to:r,insert:""}})}m("")};return(0,t.jsxs)("div",{className:"flex flex-col h-full bg-(--slate-1) rounded-lg shadow border border-(--slate-6) overflow-hidden relative",style:{maxHeight:s.maxHeight},children:[(0,t.jsx)("div",{className:"absolute top-0 right-0 flex justify-end z-10 border border-(--slate-6) bg-inherit rounded-bl-lg",children:(0,t.jsx)(z,{variant:"text",size:"icon",disabled:u.length===0,onClick:()=>{R([]),s.setValue([]),s.delete_chat_history({}),S()},children:(0,t.jsx)(Ve,{className:"h-3 w-3"})})}),(0,t.jsxs)("div",{className:"grow overflow-y-auto gap-4 pt-8 pb-4 px-2 flex flex-col",ref:i,children:[u.length===0&&(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-muted-foreground text-center p-4",children:[(0,t.jsx)(fe,{className:"h-12 w-12 mb-4"}),(0,t.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"No messages yet"}),(0,t.jsx)("p",{className:"text-sm",children:"Start a conversation by typing a message below."})]}),u.map((r,v)=>{var L;let y=(L=r.parts)==null?void 0:L.filter(D=>D.type==="text").map(D=>D.text).join(`
3
3
  `),w=v===u.length-1;return(0,t.jsxs)("div",{className:Z("flex flex-col group gap-2",r.role==="user"?"items-end":"items-start"),children:[(0,t.jsx)("div",{className:`max-w-[80%] p-3 rounded-lg ${r.role==="user"?"bg-(--sky-11) text-(--slate-1) whitespace-pre-wrap":"bg-(--slate-4) text-(--slate-12)"}`,children:Te({message:r,isStreamingReasoning:A==="streaming",isLast:w})}),(0,t.jsxs)("div",{className:"flex justify-end text-xs gap-2 invisible group-hover:visible",children:[(0,t.jsx)(Oe,{value:y,className:"h-3 w-3",buttonClassName:"text-xs text-(--slate-9) hover:text-(--slate-11)"}),(0,t.jsx)("button",{type:"button",onClick:()=>O(r.id),className:"text-xs text-(--slate-9) hover:text-(--slate-11)",children:(0,t.jsx)(qe,{className:"h-3 w-3 text-(--red-9)"})})]})]},`${r.id}-${v}`)}),I&&(0,t.jsxs)("div",{className:"flex items-center justify-center space-x-2 mb-4",children:[(0,t.jsx)(Re,{size:"small"}),(0,t.jsx)(z,{variant:"link",size:"sm",onClick:()=>$(),className:"text-(--red-9) hover:text-(--red-11)",children:"Stop"})]}),C&&(0,t.jsxs)("div",{className:"flex items-center justify-center space-x-2 mb-4",children:[(0,t.jsx)(He,{error:C}),(0,t.jsx)(z,{variant:"outline",size:"sm",onClick:()=>M(),children:"Retry"})]})]}),(0,t.jsxs)("form",{onSubmit:async r=>{if(r.preventDefault(),s.disabled)return;let v=o?await _e(o):void 0;k({role:"user",parts:[{type:"text",text:e},...v??[]]}),se()},ref:g,inert:s.disabled||void 0,className:Z("flex w-full border-t border-(--slate-6) px-2 py-1 items-center",s.disabled&&"opacity-50 cursor-not-allowed"),children:[s.showConfigurationControls&&(0,t.jsx)(Je,{config:x,onChange:N}),s.prompts.length>0&&(0,t.jsx)(We,{prompts:s.prompts,onSelect:r=>{m(r),requestAnimationFrame(()=>{q==null||q.focus(),ae(q)})}}),(0,t.jsx)(ke,{className:"rounded-sm mr-2",placeholder:te,value:e,inputRef:j,maxHeight:s.maxHeight?`${s.maxHeight/2}px`:void 0,onChange:m,onSubmit:(r,v)=>{var y;v.trim()&&((y=g.current)==null||y.requestSubmit())},onClose:()=>{},additionalCompletions:ee}),o&&o.length===1&&(0,t.jsx)("span",{title:o[0].name,className:"text-sm text-(--slate-11) truncate shrink-0 w-fit max-w-24",children:o[0].name}),o&&o.length>1&&(0,t.jsxs)("span",{title:[...o].map(r=>r.name).join(`
4
4
  `),className:"text-sm text-(--slate-11) truncate shrink-0",children:[o.length," files"]}),o&&o.length>0&&(0,t.jsx)(z,{type:"button",variant:"text",size:"sm",onClick:()=>{f(void 0),h.current&&(h.current.value="")},children:(0,t.jsx)(ge,{className:"size-3"})}),Q&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(z,{type:"button",variant:"text",size:"sm",onClick:()=>{var r;return(r=h.current)==null?void 0:r.click()},children:(0,t.jsx)(ye,{className:"h-4"})}),(0,t.jsx)("input",{type:"file",ref:h,className:"hidden",multiple:!0,accept:Array.isArray(s.allowAttachments)?s.allowAttachments.join(","):void 0,onChange:r=>{r.target.files&&f([...r.target.files])}})]}),(0,t.jsx)(z,{type:"submit",disabled:I||!e,variant:"outline",size:"xs",className:"text-(--slate-11)",children:(0,t.jsx)(ve,{className:"h-4 w-4"})})]})]})};var H={max_tokens:{min:1,max:4096,description:"Maximum number of tokens to generate"},temperature:{min:0,max:2,step:.1,description:"Controls randomness (0: deterministic, 2: very random)"},top_p:{min:0,max:1,step:.1,description:"Nucleus sampling: probability mass to consider"},top_k:{min:1,max:100,description:"Top-k sampling: number of highest probability tokens to consider"},frequency_penalty:{min:-2,max:2,description:"Penalizes frequent tokens (-2: favor, 2: avoid)"},presence_penalty:{min:-2,max:2,description:"Penalizes new tokens (-2: favor, 2: avoid)"}},Je=s=>{let e=(0,J.c)(16),{config:m,onChange:x}=s,[N,_]=(0,b.useState)(!1),c;e[0]!==m||e[1]!==x?(c=(a,d)=>{let n=d===null||Number.isNaN(d)?null:d;if(n!==null){let{min:u,max:k}=H[a];n=Math.max(u,Math.min(k,n))}x({...m,[a]:n})},e[0]=m,e[1]=x,e[2]=c):c=e[2];let o=c,f;e[3]===Symbol.for("react.memo_cache_sentinel")?(f=a=>{a.key==="Enter"&&(a.preventDefault(),_(!1))},e[3]=f):f=e[3];let h=f,g;e[4]===Symbol.for("react.memo_cache_sentinel")?(g=(0,t.jsx)(Y,{content:"Configuration",children:(0,t.jsx)($e,{asChild:!0,children:(0,t.jsx)(z,{variant:"outline",size:"sm",className:"border-none shadow-none hover:bg-transparent",children:(0,t.jsx)(Ie,{className:"h-3 w-3"})})})}),e[4]=g):g=e[4];let j;e[5]===Symbol.for("react.memo_cache_sentinel")?(j=(0,t.jsx)("h4",{className:"font-bold leading-none",children:"Configuration"}),e[5]=j):j=e[5];let i;if(e[6]!==m||e[7]!==o){let a;e[9]===o?a=e[10]:(a=d=>{let[n,u]=d;return(0,t.jsxs)("div",{className:"grid grid-cols-3 items-center gap-1",children:[(0,t.jsxs)(U,{htmlFor:n,className:"flex w-full justify-between col-span-3 align-end",children:[de(n),(0,t.jsx)(Y,{delayDuration:200,side:"top",content:(0,t.jsx)("div",{className:"text-xs flex flex-col",children:H[n].description}),children:(0,t.jsx)(be,{className:"h-3 w-3 cursor-help text-muted-foreground hover:text-foreground"})})]}),(0,t.jsx)(ze,{id:n,"aria-label":n,value:u??NaN,placeholder:"null",minValue:H[n].min,maxValue:H[n].max,step:H[n].step??1,onChange:k=>o(n,k),onKeyDown:h,className:"col-span-3"})]},n)},e[9]=o,e[10]=a),i=pe.entries(m).map(a),e[6]=m,e[7]=o,e[8]=i}else i=e[8];let l;e[11]===i?l=e[12]:(l=(0,t.jsx)(B,{className:"w-70 border",children:(0,t.jsxs)("div",{className:"grid gap-3",children:[j,i]})}),e[11]=i,e[12]=l);let p;return e[13]!==N||e[14]!==l?(p=(0,t.jsxs)(G,{open:N,onOpenChange:_,children:[g,l]}),e[13]=N,e[14]=l,e[15]=p):p=e[15],p},We=s=>{let e=(0,J.c)(18),{prompts:m,onSelect:x}=s,[N,_]=(0,b.useState)(!1),[c,o]=(0,b.useState)(""),f;e[0]===x?f=e[1]:(f=d=>{[...d.matchAll(/{{(\w+)}}/g)].length>0?(o(d),_(!0)):x(d)},e[0]=x,e[1]=f);let h=f,g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=(0,t.jsx)(Y,{content:"Select a prompt",children:(0,t.jsx)(Se,{asChild:!0,children:(0,t.jsx)(z,{variant:"outline",size:"sm",className:"border-none shadow-none hover:bg-transparent",children:(0,t.jsx)(De,{className:"h-3 w-3"})})})}),e[2]=g):g=e[2];let j;if(e[3]!==h||e[4]!==m){let d;e[6]===h?d=e[7]:(d=(n,u)=>(0,t.jsx)(Ce,{onSelect:()=>h(n),className:"whitespace-normal text-left",children:n},u),e[6]=h,e[7]=d),j=m.map(d),e[3]=h,e[4]=m,e[5]=j}else j=e[5];let i;e[8]===j?i=e[9]:(i=(0,t.jsx)(Fe,{children:(0,t.jsxs)(Me,{children:[g,(0,t.jsx)(Ae,{side:"right",align:"end",onCloseAutoFocus:Ze,className:"w-64 max-h-96 overflow-y-auto",children:j})]})}),e[8]=j,e[9]=i);let l;e[10]===Symbol.for("react.memo_cache_sentinel")?(l=()=>_(!1),e[10]=l):l=e[10];let p;e[11]!==x||e[12]!==c?(p=(0,t.jsx)(B,{side:"right",align:"end",className:"min-w-80 px-2",children:(0,t.jsx)(Xe,{prompt:c,onClose:l,onSelect:x})}),e[11]=x,e[12]=c,e[13]=p):p=e[13];let a;return e[14]!==N||e[15]!==i||e[16]!==p?(a=(0,t.jsxs)(G,{open:N,onOpenChange:_,children:[i,p]}),e[14]=N,e[15]=i,e[16]=p,e[17]=a):a=e[17],a},Xe=s=>{let e=(0,J.c)(32),{prompt:m,onClose:x,onSelect:N}=s,_;e[0]===Symbol.for("react.memo_cache_sentinel")?(_={},e[0]=_):_=e[0];let[c,o]=(0,b.useState)(_),f,h;e[1]===m?(f=e[2],h=e[3]):(f=()=>{o([...m.matchAll(/{{(\w+)}}/g)].reduce(Be,{}))},h=[m],e[1]=m,e[2]=f,e[3]=h),(0,b.useEffect)(f,h);let g;e[4]===Symbol.for("react.memo_cache_sentinel")?(g=(C,M)=>{o(S=>({...S,[C]:M}))},e[4]=g):g=e[4];let j=g,i;if(e[5]!==m||e[6]!==c){let C;e[8]===Symbol.for("react.memo_cache_sentinel")?(C=/{{(\w+)}}/g,e[8]=C):C=e[8];let M;e[9]===c?M=e[10]:(M=(S,I)=>c[I]||`{{${I}}}`,e[9]=c,e[10]=M),i=m.replaceAll(C,M),e[5]=m,e[6]=c,e[7]=i}else i=e[7];let l=i,p;e[11]===c?p=e[12]:(p=Object.values(c).some(Ge),e[11]=c,e[12]=p);let a=p,d;e[13]!==x||e[14]!==N||e[15]!==l?(d=()=>{N(l),x()},e[13]=x,e[14]=N,e[15]=l,e[16]=d):d=e[16];let n=d,u;e[17]===c?u=e[18]:(u=Object.entries(c),e[17]=c,e[18]=u);let k;e[19]!==n||e[20]!==a||e[21]!==u?(k=u.map((C,M)=>{let[S,I]=C;return(0,t.jsxs)("div",{className:"grid grid-cols-4 items-center gap-2",children:[(0,t.jsx)(U,{htmlFor:S,className:"font-semibold text-base",children:S}),(0,t.jsx)(Ee,{id:S,value:I,onChange:O=>j(S,O.target.value),rootClassName:"col-span-3 w-full",className:"m-0",placeholder:`Enter value for ${S}`,autoFocus:M===0,onKeyDown:O=>{O.key==="Enter"&&!a&&n()}})]},S)}),e[19]=n,e[20]=a,e[21]=u,e[22]=k):k=e[22];let R;e[23]===l?R=e[24]:(R=(0,t.jsx)("div",{className:"grid gap-2 prose dark:prose-invert",children:(0,t.jsx)("blockquote",{className:"text-sm",children:l})}),e[23]=l,e[24]=R);let A;e[25]!==n||e[26]!==a?(A=(0,t.jsx)(z,{onClick:n,size:"xs",disabled:a,children:"Submit"}),e[25]=n,e[26]=a,e[27]=A):A=e[27];let $;return e[28]!==R||e[29]!==A||e[30]!==k?($=(0,t.jsxs)("div",{className:"grid gap-4",children:[k,R,A]}),e[28]=R,e[29]=A,e[30]=k,e[31]=$):$=e[31],$};function Ze(s){return s.preventDefault()}function Be(s,e){return s[e[1]]="",s}function Ge(s){return s==null||s.trim()===""}export{Ye as Chatbot};