@marimo-team/frontend 0.18.5-dev168 → 0.18.5-dev171
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{CellStatus-C5QfWAQj.js → CellStatus-ClrYbUob.js} +1 -1
- package/dist/assets/{ConnectedDataExplorerComponent-B0tKPs5t.js → ConnectedDataExplorerComponent-KlUs_Sz3.js} +1 -1
- package/dist/assets/{ErrorBoundary-BYCO3_zw.js → ErrorBoundary-Drf1manw.js} +1 -1
- package/dist/assets/{ImperativeModal-7Thr73Oo.js → ImperativeModal-q6QlC2aZ.js} +1 -1
- package/dist/assets/{JsonOutput-NOfbbuUx.js → JsonOutput-CkeISXrs.js} +9 -9
- package/dist/assets/{LazyAnyLanguageCodeMirror-DIbHWNF6.js → LazyAnyLanguageCodeMirror-jpEDlD0M.js} +2 -2
- package/dist/assets/{MarimoErrorOutput-usFICLUe.js → MarimoErrorOutput-CO8cm8-0.js} +2 -2
- package/dist/assets/{RenderHTML-LxV1eecf.js → RenderHTML-D6fh5YLC.js} +1 -1
- package/dist/assets/{VisuallyHidden-BLp5kXtE.js → VisuallyHidden-BodIky8L.js} +1 -1
- package/dist/assets/{add-cell-with-ai-CEKGThxQ.js → add-cell-with-ai-B3V6Mgb9.js} +12 -12
- package/dist/assets/{add-database-form-DQyrphh9.js → add-database-form-C-K88iSC.js} +1 -1
- package/dist/assets/{agent-panel-CnTn12AW.js → agent-panel-BvLqBe3U.js} +6 -6
- package/dist/assets/{ai-model-dropdown-CxRols0L.js → ai-model-dropdown-D1nEKS8b.js} +1 -1
- package/dist/assets/{alert-dialog-B3T1GCoD.js → alert-dialog-k5KxevGr.js} +1 -1
- package/dist/assets/any-language-editor-DQu1Tt2N.js +3 -0
- package/dist/assets/{app-config-button-DtMP2_j5.js → app-config-button-BD5l-v4I.js} +1 -1
- package/dist/assets/{button-C9TEIJJh.js → button-DuYGqRtX.js} +1 -1
- package/dist/assets/{cache-panel-C-YLXsti.js → cache-panel-C1So4Zu3.js} +1 -1
- package/dist/assets/{capabilities-h9_pyvFv.js → capabilities-BmAOeMOK.js} +1 -1
- package/dist/assets/{capitalize-D4JsDDXI.js → capitalize-DQeWKRGx.js} +1 -1
- package/dist/assets/{cell-actions-DCZqhhwF.js → cell-actions-CJiaF9Tu.js} +1 -1
- package/dist/assets/cell-link-Hwo1QbqQ.js +1 -0
- package/dist/assets/{cells-DAR6V-0d.js → cells-rr1jjvJk.js} +33 -33
- package/dist/assets/{chat-components-CyY2c7cG.js → chat-components-DXJsXOD8.js} +1 -1
- package/dist/assets/{chat-display-BgCCmGdz.js → chat-display-C08N0rx5.js} +1 -1
- package/dist/assets/{chat-panel-ByuXM3gc.js → chat-panel-CNL6ANh8.js} +2 -2
- package/dist/assets/client-SMzMTiO_.js +4 -0
- package/dist/assets/{column-preview-DBqi4KCj.js → column-preview-BzvHnhPG.js} +1 -1
- package/dist/assets/command-palette-B_md1fzh.js +1 -0
- package/dist/assets/{command-BXWdrTY9.js → command-xU8ykulh.js} +1 -1
- package/dist/assets/{common-D10A9aix.js → common-_RAkDTpe.js} +1 -1
- package/dist/assets/{config-D3ojpe3F.js → config-cCkBQ_ER.js} +1 -1
- package/dist/assets/{copy-Bmkr29w4.js → copy-DRhpWiOq.js} +1 -1
- package/dist/assets/{copy-icon-qVgCqhII.js → copy-icon-B69c-352.js} +1 -1
- package/dist/assets/{createReducer-CaezzNVH.js → createReducer-DDa-hVe3.js} +1 -1
- package/dist/assets/{datasource-CW2RMV2e.js → datasource-DHbNHnua.js} +2 -2
- package/dist/assets/{dates-B2_O0-if.js → dates-CdsE1R40.js} +1 -1
- package/dist/assets/{dependency-graph-panel-CtlDdK0s.js → dependency-graph-panel-BGp5UzmZ.js} +3 -3
- package/dist/assets/{dialog-DIUTtzeB.js → dialog-DUEuLcT2.js} +1 -1
- package/dist/assets/{dist-vrNOUnFF.js → dist-DOFFh6Ii.js} +1 -1
- package/dist/assets/{documentation-panel-Cup0ghBs.js → documentation-panel-CuPlvIjJ.js} +1 -1
- package/dist/assets/{download-D3Uujsn_.js → download-DKRxBkYD.js} +1 -1
- package/dist/assets/edit-page-DAFshpgY.js +13 -0
- package/dist/assets/{error-banner-D2-5vgE4.js → error-banner-DU5Qb8a8.js} +1 -1
- package/dist/assets/{error-panel-DcRvXIwA.js → error-panel-CoYFpNUd.js} +1 -1
- package/dist/assets/{es-DCqUUmrq.js → es-YVwBDiDw.js} +1 -1
- package/dist/assets/{field-D2_0r7wT.js → field-DDKGFzpC.js} +1 -1
- package/dist/assets/{file-explorer-panel-9Bt20tRi.js → file-explorer-panel-BcpntT7Q.js} +1 -1
- package/dist/assets/{floating-outline-BTc4L5BF.js → floating-outline-CHprSkP6.js} +1 -1
- package/dist/assets/{focus-6-St0ai2.js → focus-D3ygI6Sy.js} +1 -1
- package/dist/assets/{form-1WOcPtE8.js → form-B_zRT4QS.js} +2 -2
- package/dist/assets/{formats-nh-sPUUZ.js → formats-B9CrBoaO.js} +1 -1
- package/dist/assets/{glide-data-editor-EdMWe-iv.js → glide-data-editor-Brckuic5.js} +1 -1
- package/dist/assets/{globals-CJb4gcmW.js → globals-D46Vbo5D.js} +1 -1
- package/dist/assets/{home-page-Lqy9A89-.js → home-page-DuPzZzUf.js} +2 -2
- package/dist/assets/hotkeys-uKX61F1_.js +1 -0
- package/dist/assets/{index-CIoUDThG.js → index-CQBtzy-J.js} +9 -9
- package/dist/assets/index-G6ss-VDT.css +2 -0
- package/dist/assets/{input-DP44ewsS.js → input-CaEtLL8p.js} +1 -1
- package/dist/assets/{kiosk-mode-C3lS9kUL.js → kiosk-mode-CTjr_Jn4.js} +1 -1
- package/dist/assets/{label-DJo0Eeb3.js → label-qwandMoh.js} +1 -1
- package/dist/assets/{layout-F63rlsGg.js → layout-CprHgyfx.js} +4 -4
- package/dist/assets/links-Cw9RjHIY.js +1 -0
- package/dist/assets/{logs-panel-fnMYUf4-.js → logs-panel-CFM-1lMP.js} +1 -1
- package/dist/assets/{maps-DELIOfTw.js → maps-s2pQkyf5.js} +1 -1
- package/dist/assets/{markdown-renderer-B9gYLzJX.js → markdown-renderer-DecoaRsV.js} +1 -1
- package/dist/assets/{mermaid-BUMgiGGr.js → mermaid-BPkO79lo.js} +1 -1
- package/dist/assets/{mode-D4GlAyEq.js → mode-BYulXE3t.js} +1 -1
- package/dist/assets/{multi-map-TecGBFLS.js → multi-map-fjX9ImVF.js} +1 -1
- package/dist/assets/{name-cell-input-BMtblyo6.js → name-cell-input-BGJDnv5Z.js} +1 -1
- package/dist/assets/{numbers-Ckcn6C-H.js → numbers-C9_R_vlY.js} +1 -1
- package/dist/assets/outline-panel-C-__7mIh.js +1 -0
- package/dist/assets/{packages-panel-DyC7zUxG.js → packages-panel-B4bQCG8Y.js} +1 -1
- package/dist/assets/{cell-editor-DJ1tY3mU.js → panel-context-Bee798AZ.js} +13 -13
- package/dist/assets/{panels-wYHy1fpG.js → panels-CuLZ4Xjj.js} +1 -1
- package/dist/assets/{process-output-D1GR6Ero.js → process-output-2gz8Uri2.js} +1 -1
- package/dist/assets/{readonly-python-code-CGnOB_RP.js → readonly-python-code-ihKi3Mrq.js} +1 -1
- package/dist/assets/{renderShortcut-CV_tqoEI.js → renderShortcut-D0Pei-OA.js} +1 -1
- package/dist/assets/{run-page-BLnJcKtg.js → run-page-Q1ifcEUY.js} +1 -1
- package/dist/assets/{runs-BbV5uZz6.js → runs-yuOchwkU.js} +1 -1
- package/dist/assets/scratchpad-panel-B75Qsjwz.js +1 -0
- package/dist/assets/{secrets-panel-K7EccfRa.js → secrets-panel-CDWmmmBS.js} +1 -1
- package/dist/assets/{select-BJ18Dxpd.js → select-D0g5GnIs.js} +1 -1
- package/dist/assets/{session-panel-C3rDPyig.js → session-panel-Bn5_JmbT.js} +1 -1
- package/dist/assets/{share-0dWXMs9M.js → share-CXQVxivL.js} +1 -1
- package/dist/assets/{slides-component-CZ76zal6.js → slides-component-DUIqQih1.js} +1 -1
- package/dist/assets/{snippets-panel-s0p4CCoa.js → snippets-panel-CVBBnX9H.js} +1 -1
- package/dist/assets/{spec-D9TFI5I_.js → spec-qp_XZeSS.js} +1 -1
- package/dist/assets/{state-DwSzcmzL.js → state-BHFBtWym.js} +1 -1
- package/dist/assets/{state-CGq6kn1k.js → state-CIznbe1J.js} +1 -1
- package/dist/assets/{state-BK5o1KAL.js → state-DNwec0Uj.js} +1 -1
- package/dist/assets/{switch-C8yab1pC.js → switch-iJj-D3dz.js} +1 -1
- package/dist/assets/{terminal-CA6CqpuO.js → terminal-CRIGvHBN.js} +1 -1
- package/dist/assets/{textarea-DBFtOima.js → textarea-DmNrZcLR.js} +1 -1
- package/dist/assets/{tooltip-BNPhCMFo.js → tooltip-CrRUCOBw.js} +1 -1
- package/dist/assets/tracing-D9h130fg.js +1 -0
- package/dist/assets/{tracing-panel-C-o1Db4W.js → tracing-panel-DaDvGMEN.js} +2 -2
- package/dist/assets/{type-drzC-SxF.js → type-BdyvjzTI.js} +1 -1
- package/dist/assets/{types-Bt3U-XJV.js → types-4-l_7Ws2.js} +1 -1
- package/dist/assets/{useAddCell-CNI3pgez.js → useAddCell-BpMe5DB-.js} +1 -1
- package/dist/assets/{useBoolean-C_vQizET.js → useBoolean-BDG41CyP.js} +1 -1
- package/dist/assets/{useCellActionButton-BbfiHu5s.js → useCellActionButton-Dh4wbVPA.js} +1 -1
- package/dist/assets/{useDeleteCell-B_jFiS1Y.js → useDeleteCell-DBzN8QcP.js} +1 -1
- package/dist/assets/{useIframeCapabilities-ZISlVepl.js → useIframeCapabilities-CU-WWxnz.js} +1 -1
- package/dist/assets/{useInstallPackage-CBvG269f.js → useInstallPackage-RldLPyJs.js} +1 -1
- package/dist/assets/{useLifecycle-BX7GmOQ5.js → useLifecycle-CmDXEyIC.js} +1 -1
- package/dist/assets/{useNotebookActions-BeM5fet2.js → useNotebookActions-DKyQBNlS.js} +1 -1
- package/dist/assets/useRunCells-BGzo-QMk.js +1 -0
- package/dist/assets/{useSplitCell-COPg5dJw.js → useSplitCell-CvKAuKQ_.js} +1 -1
- package/dist/assets/{useTheme-CuOCKnyR.js → useTheme-DfP1CWaW.js} +1 -1
- package/dist/assets/{utilities.esm-B7XtzwiJ.js → utilities.esm-CT3NbLA9.js} +2 -2
- package/dist/assets/{utils-Cxqw03y3.js → utils-CJJIceVn.js} +1 -1
- package/dist/assets/{vega-component-arPQXQS8.js → vega-component-CLrcy81y.js} +1 -1
- package/dist/assets/{write-secret-modal-CIbhcoWF.js → write-secret-modal-CLm48gMe.js} +1 -1
- package/dist/index.html +68 -68
- package/package.json +1 -1
- package/src/components/editor/actions/useNotebookActions.tsx +1 -1
- package/src/components/editor/chrome/panels/panel-context.tsx +34 -0
- package/src/components/editor/chrome/state.ts +30 -15
- package/src/components/editor/chrome/types.ts +67 -77
- package/src/components/editor/chrome/wrapper/app-chrome.tsx +216 -139
- package/src/components/editor/chrome/wrapper/sidebar.tsx +76 -43
- package/src/components/scratchpad/scratchpad.tsx +17 -4
- package/src/components/ui/reorderable-list.tsx +190 -31
- package/src/core/codemirror/cells/extensions.ts +7 -4
- package/src/core/hotkeys/__tests__/shortcuts.test.ts +61 -4
- package/src/core/hotkeys/shortcuts.ts +34 -2
- package/dist/assets/any-language-editor-CTAS1EXW.js +0 -3
- package/dist/assets/cell-link-DjST51KF.js +0 -1
- package/dist/assets/client-BQowSjqE.js +0 -4
- package/dist/assets/command-palette-CjFiCjws.js +0 -1
- package/dist/assets/edit-page-fJ4hHm67.js +0 -13
- package/dist/assets/hotkeys-D3ICc8RW.js +0 -1
- package/dist/assets/index-D-BWugLn.css +0 -2
- package/dist/assets/links-ZVVAwqm7.js +0 -1
- package/dist/assets/outline-panel-Blq76m9b.js +0 -1
- package/dist/assets/scratchpad-panel-CTJDEy90.js +0 -1
- package/dist/assets/tracing-VZVj-gEo.js +0 -1
- package/dist/assets/useRunCells-oeY0TrS1.js +0 -1
- /package/dist/assets/{cell-editor-Iey559K_.css → panel-context-Iey559K_.css} +0 -0
package/dist/assets/{LazyAnyLanguageCodeMirror-DIbHWNF6.js → LazyAnyLanguageCodeMirror-jpEDlD0M.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./any-language-editor-
|
|
2
|
-
import{s as e}from"./chunk-LvLJmgfZ.js";import{t as i}from"./react-BGmjiNul.js";import{t as o}from"./createLucideIcon-CW2xpJ57.js";import{t as m}from"./preload-helper-BW0IMuFq.js";let r,a,s=(async()=>{r=o("between-horizontal-start",[["rect",{width:"13",height:"7",x:"8",y:"3",rx:"1",key:"pkso9a"}],["path",{d:"m2 9 3 3-3 3",key:"1agib5"}],["rect",{width:"13",height:"7",x:"8",y:"14",rx:"1",key:"1q5fc1"}]]),a=(0,e(i(),1).lazy)(()=>m(()=>import("./any-language-editor-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./any-language-editor-DQu1Tt2N.js","./copy-icon-B69c-352.js","./button-DuYGqRtX.js","./hotkeys-uKX61F1_.js","./useEventListener-COkmyg1v.js","./compiler-runtime-DeeZ7FnK.js","./react-BGmjiNul.js","./chunk-LvLJmgfZ.js","./cn-C1rgT0yh.js","./clsx-D0MtrJOx.js","./jsx-runtime-DN_bIXfG.js","./tooltip-CvjcEpZC.js","./Combination-D1TsGrBC.js","./react-dom-C9fstfnp.js","./dist-CBrDuocE.js","./use-toast-Bzf3rpev.js","./copy-DRhpWiOq.js","./check-CrAQug3q.js","./createLucideIcon-CW2xpJ57.js","./copy-gBVL4NN-.js","./error-banner-DU5Qb8a8.js","./alert-dialog-k5KxevGr.js","./zod-Cg4WLWh2.js","./dist-BRZzJw_5.js","./dist-CAcX026F.js","./dist-BVf1IY4_.js","./dist-P7JHert4.js","./dist-DKNOF5xd.js","./dist-CVj-_Iiz.js","./dist-Cq_4nPfh.js","./dist-CoiWxjLF.js","./dist-cVYW_wBR.js","./dist-HGZzCB0y.js","./dist-BAmo7Mv9.js","./dist-RKnr9SNh.js","./dist-3oAtECdQ.js","./dist-D6Pwf0VF.js","./dist-D9HMoxdZ.js","./dist-JtCdI6tY.js","./esm-B3JckBtM.js","./extends-B9D0JO9U.js","./objectWithoutPropertiesLoose-CboCOq4o.js","./dist-CI6_zMIl.js","./esm-CCqLcax5.js","./dist-DrrmBmzm.js","./dist-Cv7ifwsi.js","./dist-ChHsi1N7.js","./dist-BuhT82Xx.js","./dist-Cd0uZhiN.js","./dist-DxRoHFaH.js","./apl-iXnrDoYq.js","./asciiarmor-CK-aFa78.js","./asn1-DWJdxrMP.js","./brainfuck-0bMZHpH_.js","./clike-5SQqmvx2.js","./clojure-B0kIwyv8.js","./cmake-CLXeINvH.js","./cobol-C9SsG--s.js","./coffeescript-UIQG6RnU.js","./commonlisp-BBPumpJY.js","./crystal-CGN1wsuY.js","./css-aQ-Krb7T.js","./cypher-DEE4_Yec.js","./d-CgJ8N-gL.js","./diff-B8e18dKs.js","./dtd-DtwMcoo9.js","./dylan-Be6i1K-V.js","./ecl-D5tlhe8s.js","./eiffel-8SQWO4xP.js","./elm-CtGe_7Jw.js","./erlang-CNwX3Z_M.js","./factor-DgyyQiBQ.js","./simple-mode-CZ1ts7NY.js","./forth-CaVwPSxM.js","./fortran-B28t9xoj.js","./gas-BSiJHAcz.js","./gherkin-1QurHPOF.js","./groovy-DFOLwJLv.js","./haskell-CUN2jxPH.js","./haxe-BYzKptPQ.js","./idl-cdmrQY5J.js","./javascript-l5LYdpfx.js","./julia-DxiTohY8.js","./livescript-BZkzGFkJ.js","./lua-rVV1vLen.js","./mathematica-DktJ0aJB.js","./mbox-Ch6IVA7h.js","./mirc-CdWws4At.js","./mllike-CB0tp4Bz.js","./modelica-DQGg_xsi.js","./mscgen-vDSxnAXy.js","./mumps-BzlVzIzl.js","./nsis-bDE8IZXy.js","./ntriples-BndMB6TK.js","./octave-DhnkL0CH.js","./oz-DbZmNL9y.js","./pascal-DhE1sEjD.js","./perl-BOZHK4Y3.js","./pig-eswHTOE9.js","./powershell-pm9G_Qg5.js","./properties-7VoeFdHR.js","./protobuf-BAsuCsmK.js","./pug-CcL3ml0F.js","./puppet-DUYPK8CV.js","./python-UQl3_T6H.js","./q-CnvA_jxT.js","./r-fM1OLzJB.js","./rpm-D62D_dq6.js","./ruby-DemvBD0m.js","./sas-CZjYQi4h.js","./scheme-nPNaP0Qp.js","./shell-BE2ANxN1.js","./sieve-DXFUN4C7.js","./smalltalk-DwXXlSAY.js","./sparql-CgejAdiJ.js","./stex-0ac7Aukl.js","./stylus-CslB9TS3.js","./swift-5t7SQPo8.js","./tcl-Ddpe8YBc.js","./textile-D_Db33mq.js","./toml-CgkLq_pv.js","./troff-6nX9d05T.js","./ttcn-cfg-ByNDYolW.js","./ttcn-Dd4SMoHT.js","./turtle-LDF8uFGv.js","./vb-DaLxM60T.js","./vbscript-CwitZ57u.js","./velocity-D6bc4mrP.js","./verilog-CIyPdzYJ.js","./vhdl-DfyhlM4K.js","./webidl-C23hA3Le.js","./xquery-BAVQXrAf.js","./yacas-DrybVty2.js","./z80-8KI6AMtY.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{s as e}from"./chunk-LvLJmgfZ.js";import{t as i}from"./react-BGmjiNul.js";import{t as o}from"./createLucideIcon-CW2xpJ57.js";import{t as m}from"./preload-helper-BW0IMuFq.js";let r,a,s=(async()=>{r=o("between-horizontal-start",[["rect",{width:"13",height:"7",x:"8",y:"3",rx:"1",key:"pkso9a"}],["path",{d:"m2 9 3 3-3 3",key:"1agib5"}],["rect",{width:"13",height:"7",x:"8",y:"14",rx:"1",key:"1q5fc1"}]]),a=(0,e(i(),1).lazy)(()=>m(()=>import("./any-language-editor-DQu1Tt2N.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133]),import.meta.url))})();export{s as __tla,r as n,a as t};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{s as
|
|
1
|
+
import{s as J}from"./chunk-LvLJmgfZ.js";import{d as ye,f as ve,l as Ne,u as be}from"./useEvent-DlWF5OMa.js";import{t as we}from"./react-BGmjiNul.js";import{C as ke,Gr as Ie,Nn as $e,Nr as _e,Pr as K,dn as Fe,in as Te,q as Ae,v as Ce}from"./cells-rr1jjvJk.js";import{t as P}from"./compiler-runtime-DeeZ7FnK.js";import{t as Se}from"./invariant-C6yE60hi.js";import{r as Me}from"./utils-CJJIceVn.js";import{t as qe}from"./jsx-runtime-DN_bIXfG.js";import{r as X,t as $}from"./button-DuYGqRtX.js";import{t as Y}from"./cn-C1rgT0yh.js";import{t as H}from"./createLucideIcon-CW2xpJ57.js";import{_ as ze}from"./select-D0g5GnIs.js";import{a as Pe,p as Ee,r as Le,t as We}from"./dropdown-menu-BP4_BZLr.js";import{a as De,n as Ve}from"./state-BHFBtWym.js";import{c as Z,n as Be}from"./datasource-DHbNHnua.js";import{a as Qe}from"./dist-RKnr9SNh.js";import{t as ee}from"./tooltip-CvjcEpZC.js";import{a as Oe,i as He,n as Ue,r as Ge}from"./multi-map-fjX9ImVF.js";import{t as te}from"./kbd-Czc5z_04.js";import{t as T}from"./links-DNmjkr65.js";import{r as Re,t as Je}from"./alert-BEdExd6A.js";import{o as Ke,t as Xe}from"./useInstallPackage-RldLPyJs.js";import{n as b}from"./cell-link-Hwo1QbqQ.js";var Ye=H("package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]),A=H("square-arrow-out-up-right",[["path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6",key:"y09zxi"}],["path",{d:"m21 3-9 9",key:"mpx6sq"}],["path",{d:"M15 3h6v6",key:"1q9fwt"}]]),re=H("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);function Ze(r){let e=null,s=r.cursor();do s.name==="ExpressionStatement"&&(e=s.node);while(s.next());return e}function et(r){let e=r.split(`
|
|
2
2
|
`),s=" ",n=Ze(Qe.parse(r));if(!n)return["def _():",...U(e,s),`${s}return`,"","","_()"].join(`
|
|
3
3
|
`);let i=r.slice(0,n.from).trim(),l=r.slice(n.from).trim(),a=i.split(`
|
|
4
4
|
`),c=l.split(`
|
|
5
5
|
`);return["def _():",...U(a,s),`${s}return ${c[0]}`,...U(c.slice(1),s),"","","_()"].join(`
|
|
6
6
|
`)}function U(r,e){if(r.length===1&&r[0]==="")return[];let s=[];for(let n of r)n===""?s.push(""):s.push(e+n);return s}function tt(r,e){var s;if(r.type==="multiple-defs")return[{title:"Fix: Wrap in a function",description:"Make this cell's variables local by wrapping the cell in a function.",fixType:"manual",onFix:async n=>{Se(n.editor,"Editor is null");let i=et(n.editor.state.doc.toString());n.editor.dispatch({changes:{from:0,to:n.editor.state.doc.length,insert:i}})}}];if(r.type==="exception"&&r.exception_type==="NameError"){let n=(s=r.msg.match(/name '(.+)' is not defined/))==null?void 0:s[1];if(!n||!(n in se))return[];let i=rt(n);return[{title:`Fix: Add '${i}'`,description:"Add a new cell for the missing import",fixType:"manual",onFix:async l=>{l.addCodeBelow(i)}}]}return r.type==="sql-error"&&e.aiEnabled?[{title:"Fix with AI",description:"Fix the SQL statement",fixType:"ai",onFix:async n=>{var a;let i=Be(n.cellId),l=`Fix the SQL statement: ${r.msg}.`;i&&(l+=`
|
|
7
|
-
Database schema: ${i}`),(a=n.aiFix)==null||a.setAiCompletionCell({cellId:n.cellId,initialPrompt:l,triggerImmediately:n.aiFix.triggerFix})}}]:[]}function rt(r){let e=se[r];return e===r?`import ${e}`:`import ${e} as ${r}`}var se={mo:"marimo",alt:"altair",bokeh:"bokeh",dask:"dask",np:"numpy",pd:"pandas",pl:"polars",plotly:"plotly",plt:"matplotlib.pyplot",px:"plotly.express",scipy:"scipy",sk:"sklearn",sns:"seaborn",stats:"scipy.stats",tf:"tensorflow",torch:"torch",xr:"xarray",dt:"datetime",json:"json",math:"math",os:"os",re:"re",sys:"sys"},st=z(),nt=Ie("marimo:ai-autofix-mode","autofix",Fe);function lt(){let r=(0,st.c)(3),[e,s]=Ne(nt),n;return r[0]!==e||r[1]!==s?(n={fixMode:e,setFixMode:s},r[0]=e,r[1]=s,r[2]=n):n=r[2],n}var K=z(),t=G(Pe(),1);const N=r=>{let e=(0,K.c)(21),{errors:s,cellId:n,className:i}=r,l=ve(),{createNewCell:a}=ke(),c=be(Me),o;if(e[0]!==c||e[1]!==s){let x;e[3]===c?x=e[4]:(x=y=>tt(y,{aiEnabled:c}),e[3]=c,e[4]=x),o=s.flatMap(x),e[0]=c,e[1]=s,e[2]=o}else o=e[2];let m=o,p=ye(Ve);if(m.length===0)return null;let d=m[0],f;e[5]!==n||e[6]!==a||e[7]!==d||e[8]!==p||e[9]!==l?(f=x=>{var w;let y=(w=l.get(Ce).cellHandles[n].current)==null?void 0:w.editorView;d.onFix({addCodeBelow:_=>{a({cellId:n,autoFocus:!1,before:!1,code:_})},editor:y,cellId:n,aiFix:{setAiCompletionCell:p,triggerFix:x}}),y==null||y.focus()},e[5]=n,e[6]=a,e[7]=d,e[8]=p,e[9]=l,e[10]=f):f=e[10];let u=f,j;e[11]===i?j=e[12]:(j=Y("my-2",i),e[11]=i,e[12]=j);let h;e[13]!==d.description||e[14]!==d.fixType||e[15]!==d.title||e[16]!==u?(h=d.fixType==="ai"?(0,t.jsx)(oe,{tooltip:d.description,openPrompt:()=>u(!1),applyAutofix:()=>u(!0)}):(0,t.jsx)(ee,{content:d.description,align:"start",children:(0,t.jsxs)($,{size:"xs",variant:"outline",className:"font-normal",onClick:()=>u(!1),children:[(0,t.jsx)(Z,{className:"h-3 w-3 mr-2"}),d.title]})}),e[13]=d.description,e[14]=d.fixType,e[15]=d.title,e[16]=u,e[17]=h):h=e[17];let g;return e[18]!==j||e[19]!==h?(g=(0,t.jsx)("div",{className:j,children:h}),e[18]=j,e[19]=h,e[20]=g):g=e[20],g};var ne=De,le=Z,ie="Suggest a prompt",ae="Fix with AI";const oe=r=>{let e=(0,K.c)(21),{tooltip:s,openPrompt:n,applyAutofix:i}=r,{fixMode:l,setFixMode:a}=lt(),c=l==="prompt"?n:i,o;e[0]===l?o=e[1]:(o=l==="prompt"?(0,t.jsx)(ne,{className:"h-3 w-3 mr-2 mb-0.5"}):(0,t.jsx)(le,{className:"h-3 w-3 mr-2 mb-0.5"}),e[0]=l,e[1]=o);let m=l==="prompt"?ie:ae,p;e[2]!==c||e[3]!==o||e[4]!==m?(p=(0,t.jsxs)($,{size:"xs",variant:"outline",className:"font-normal rounded-r-none border-r-0",onClick:c,children:[o,m]}),e[2]=c,e[3]=o,e[4]=m,e[5]=p):p=e[5];let d;e[6]!==p||e[7]!==s?(d=(0,t.jsx)(ee,{content:s,align:"start",children:p}),e[6]=p,e[7]=s,e[8]=d):d=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=(0,t.jsx)(Ee,{asChild:!0,children:(0,t.jsx)($,{size:"xs",variant:"outline",className:"rounded-l-none px-2","aria-label":"Fix options",children:(0,t.jsx)(qe,{className:"h-3 w-3"})})}),e[9]=f):f=e[9];let u;e[10]!==l||e[11]!==a?(u=()=>{a(l==="prompt"?"autofix":"prompt")},e[10]=l,e[11]=a,e[12]=u):u=e[12];let j=l==="prompt"?"autofix":"prompt",h;e[13]===j?h=e[14]:(h=(0,t.jsx)(it,{mode:j}),e[13]=j,e[14]=h);let g;e[15]!==u||e[16]!==h?(g=(0,t.jsxs)(We,{children:[f,(0,t.jsx)(Le,{align:"end",className:"w-56",children:(0,t.jsx)(ze,{className:"flex items-center gap-2",onClick:u,children:h})})]}),e[15]=u,e[16]=h,e[17]=g):g=e[17];let x;return e[18]!==g||e[19]!==d?(x=(0,t.jsxs)("div",{className:"flex",children:[d,g]}),e[18]=g,e[19]=d,e[20]=x):x=e[20],x};var it=r=>{let e=(0,K.c)(12),{mode:s}=r,n;e[0]===s?n=e[1]:(n=s==="prompt"?(0,t.jsx)(ne,{className:"h-4 w-4"}):(0,t.jsx)(le,{className:"h-4 w-4"}),e[0]=s,e[1]=n);let i=n,l=s==="prompt"?ie:ae,a=s==="prompt"?"Edit the prompt before applying":"Apply AI fixes automatically",c;e[2]===l?c=e[3]:(c=(0,t.jsx)("span",{className:"font-medium",children:l}),e[2]=l,e[3]=c);let o;e[4]===a?o=e[5]:(o=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:a}),e[4]=a,e[5]=o);let m;e[6]!==c||e[7]!==o?(m=(0,t.jsxs)("div",{className:"flex flex-col",children:[c,o]}),e[6]=c,e[7]=o,e[8]=m):m=e[8];let p;return e[9]!==i||e[10]!==m?(p=(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[i,m]}),e[9]=i,e[10]=m,e[11]=p):p=e[11],p},ce=/(https?:\/\/\S+)/,at=/\.(png|jpe?g|gif|webp|svg|ico)(\?.*)?$/i,de=/^data:image\//i,ot=["avatars.githubusercontent.com"];function me(r){return de.test(r)?[{type:"image",url:r}]:r.split(ce).filter(e=>e.trim()!=="").map(e=>ce.test(e)?at.test(e)||de.test(e)||ot.some(s=>e.includes(s))?{type:"image",url:e}:{type:"url",url:e}:{type:"text",value:e})}var pe=z(),E=G(we(),1),ct=new Ae;const R=r=>{let e=RegExp("\x1B\\[[0-9;]*m","g");return r.replaceAll(e,"")};var ue=/(pip\s+install|uv\s+add|uv\s+pip\s+install)\s+/gi;function dt(r){ue.lastIndex=0;let e=ue.exec(r);if(!e)return null;let s=e.index+e[0].length,n=r.slice(s).split(/\s+/),i="",l=0;for(let c of n){let o=c.trim();if(!o)continue;if(o.startsWith("-")){l+=o.length+1;continue}let m=o.match(/^[\w,.[\]-]+/);if(m){i=m[0];break}break}if(!i)return null;let a=s+l+i.length;return{package:i,endIndex:a}}function k(r,e=""){if(!r)return null;if(!/https?:\/\//.test(r))return r;let s=me(r);return s.length===1&&s[0].type==="text"?r:(0,t.jsx)(t.Fragment,{children:s.map((n,i)=>{let l=e?`${e}-${i}`:i;if(n.type==="url"){let a=R(n.url);return(0,t.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:X.stopPropagation(),className:"text-link hover:underline",children:a},l)}if(n.type==="image"){let a=R(n.url);return(0,t.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:X.stopPropagation(),className:"text-link hover:underline",children:a},l)}return(0,t.jsx)(E.Fragment,{children:n.value},l)})})}var mt=r=>{let e=(0,pe.c)(6),{packages:s,children:n}=r,{handleInstallPackages:i}=Xe(),l;e[0]!==i||e[1]!==s?(l=c=>{i(s),c.preventDefault()},e[0]=i,e[1]=s,e[2]=l):l=e[2];let a;return e[3]!==n||e[4]!==l?(a=(0,t.jsx)("button",{onClick:l,className:"text-link hover:underline",type:"button",children:n}),e[3]=n,e[4]=l,e[5]=a):a=e[5],a};const pt=r=>{if(!(r instanceof J.Text))return;let e=R(r.data);if(!/(pip\s+install|uv\s+add|uv\s+pip\s+install)/i.test(e))return;let s=[],n=/(pip\s+install|uv\s+add|uv\s+pip\s+install)\s+/gi,i;for(;(i=n.exec(e))!==null;){let c=i.index,o=dt(e.slice(c));o&&s.push({match:i,result:o})}if(s.length===0)return;let l=[],a=0;if(s.forEach((c,o)=>{let{match:m,result:p}=c,d=m.index,f=d+p.endIndex;if(a<d){let j=e.slice(a,d);l.push((0,t.jsx)(E.Fragment,{children:k(j,`before-${o}`)},`before-${o}`))}let u=e.slice(d,f);l.push((0,t.jsx)(mt,{packages:[p.package],children:u},`install-${o}`)),a=f}),a<e.length){let c=e.slice(a);l.push((0,t.jsx)(E.Fragment,{children:k(c,"after")},"after"))}return(0,t.jsx)(t.Fragment,{children:l})},ut=r=>{if(!(r instanceof J.Text))return;let e=r.data;if(!/https?:\/\//.test(e))return;let s=k(e);if(typeof s!="string")return(0,t.jsx)(t.Fragment,{children:s})},ht=(...r)=>e=>{for(let s of r){let n=s(e);if(n!==void 0)return n}},xt=(r,e)=>(0,t.jsx)("span",{children:_e(ct.ansi_to_html(r),{replace:s=>e(s)})}),ft=r=>{let e=(0,pe.c)(4),{text:s}=r,n;e[0]===s?n=e[1]:(n=xt(s,ht(pt,ut)),e[0]=s,e[1]=n);let i=n,l;return e[2]===i?l=e[3]:(l=(0,t.jsx)(t.Fragment,{children:i}),e[2]=i,e[3]=l),l};var he=z(),I=r=>{let e=(0,he.c)(10),s=r.title??"Tip",n;e[0]===s?n=e[1]:(n=(0,t.jsx)(Oe,{className:"pt-2 pb-2 font-normal",children:s}),e[0]=s,e[1]=n);let i;e[2]===r.children?i=e[3]:(i=(0,t.jsx)(Ke,{className:"mr-24 text-[0.84375rem]",children:r.children}),e[2]=r.children,e[3]=i);let l;e[4]!==n||e[5]!==i?(l=(0,t.jsxs)(He,{value:"item-1",className:"text-muted-foreground",children:[n,i]}),e[4]=n,e[5]=i,e[6]=l):l=e[6];let a;return e[7]!==r.className||e[8]!==l?(a=(0,t.jsx)(Ue,{type:"single",collapsible:!0,className:r.className,children:l}),e[7]=r.className,e[8]=l,e[9]=a):a=e[9],a};const jt=r=>{let e=(0,he.c)(31),{errors:s,cellId:n,className:i}=r,l=Te(),a="This cell wasn't run because it has errors",c="destructive",o="text-error";if(s.some(gt))a="Interrupted";else if(s.some(yt))a="An internal error occurred";else if(s.some(vt))a="Ancestor prevented from running",c="default",o="text-secondary-foreground";else if(s.some(Nt))a="Ancestor stopped",c="default",o="text-secondary-foreground";else if(s.some(bt))a="SQL error";else{let x;e[0]===s?x=e[1]:(x=s.find(wt),e[0]=s,e[1]=x);let y=x;y&&"exception_type"in y&&(a=y.exception_type)}let m,p,d,f,u,j;if(e[2]!==c||e[3]!==n||e[4]!==l||e[5]!==i||e[6]!==s||e[7]!==o||e[8]!==a){let x=s.filter(kt),y=s.filter(It),w=s.filter($t),_=s.filter(_t),L=s.filter(Ft),C=s.filter(Tt),S=s.filter(At),W=s.filter(Ct),D=s.filter(St),V=s.filter(Mt),F=s.filter(Pt),B=s.filter(qt),Q=s.filter(zt),M;e[15]===l?M=e[16]:(M=()=>{l.openDeveloperPanelTab("scratchpad")},e[15]=l,e[16]=M);let xe=M,fe=()=>{let v=[];if(F.length>0||B.length>0){let q=F.some(Et),ge=!q&&F.some(Lt);v.push((0,t.jsxs)("div",{children:[F.map(Wt),B.map(Dt),q&&(0,t.jsxs)($,{size:"xs",variant:"outline",className:"mt-2 font-normal",onClick:()=>Je(l),children:[(0,t.jsx)(Ye,{className:"h-3.5 w-3.5 mr-1.5 mb-0.5"}),(0,t.jsx)("span",{children:"Open package manager"})]}),ge&&(0,t.jsxs)($,{size:"xs",variant:"outline",className:"mt-2 font-normal",onClick:()=>l.openDeveloperPanelTab("terminal"),children:[(0,t.jsx)(re,{className:"h-3.5 w-3.5 mr-1.5"}),(0,t.jsx)("span",{children:"Open terminal"})]}),n&&(0,t.jsx)(N,{errors:[...F,...B],cellId:n})]},"syntax-unknown"))}if(x.length>0&&v.push((0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground font-medium",children:"The setup cell cannot be run because it has references."}),(0,t.jsx)("ul",{className:"list-disc",children:x.flatMap(Vt)}),n&&(0,t.jsx)(N,{errors:x,cellId:n}),(0,t.jsxs)(I,{title:"Why can't the setup cell have references?",className:"mb-2",children:[(0,t.jsx)("p",{className:"pb-2",children:"The setup cell contains logic that must be run before any other cell runs, including top-level imports used by top-level functions. For this reason, it can't refer to other cells' variables."}),(0,t.jsx)("p",{className:"py-2",children:"Try simplifying the setup cell to only contain only necessary variables."}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(T,{href:"https://links.marimo.app/errors-setup",children:["Learn more at our docs"," ",(0,t.jsx)(A,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"setup-refs")),y.length>0&&v.push((0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground font-medium",children:"This cell is in a cycle."}),(0,t.jsx)("ul",{className:"list-disc",children:y.flatMap(Bt)}),n&&(0,t.jsx)(N,{errors:y,cellId:n}),(0,t.jsxs)(I,{title:"What are cycles and how do I resolve them?",className:"mb-2",children:[(0,t.jsx)("p",{className:"pb-2",children:"An example of a cycle is if one cell declares a variable 'a' and reads 'b', and another cell declares 'b' and and reads 'a'. Cycles like this make it impossible for marimo to know how to run your cells, and generally suggest that your code has a bug."}),(0,t.jsx)("p",{className:"py-2",children:"Try merging these cells into a single cell to eliminate the cycle."}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(T,{href:"https://links.marimo.app/errors-cycles",children:["Learn more at our docs"," ",(0,t.jsx)(A,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"cycle")),w.length>0){let q=w[0].name;v.push((0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground font-medium",children:"This cell redefines variables from other cells."}),w.map(Ot),n&&(0,t.jsx)(N,{errors:w,cellId:n}),(0,t.jsxs)(I,{title:"Why can't I redefine variables?",children:[(0,t.jsx)("p",{className:"pb-2",children:"marimo requires that each variable is defined in just one cell. This constraint enables reactive and reproducible execution, arbitrary cell reordering, seamless UI elements, execution as a script, and more."}),(0,t.jsxs)("p",{className:"py-2",children:["Try merging this cell with the mentioned cells or wrapping it in a function. Alternatively, prefix variables with an underscore (e.g., ",(0,t.jsxs)(te,{className:"inline",children:["_",q]}),"). to make them private to this cell."]}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(T,{href:"https://links.marimo.app/errors-multiple-definitions",children:["Learn more at our docs"," ",(0,t.jsx)(A,{size:"0.75rem",className:"inline"})]}),"."]})]}),(0,t.jsx)(I,{title:"Need a scratchpad?",children:(0,t.jsxs)("div",{className:"flex flex-row gap-2 items-center",children:[(0,t.jsxs)($,{size:"xs",variant:"link",className:"my-2 font-normal mx-0 px-0",onClick:xe,children:[(0,t.jsx)($e,{className:"h-3"}),(0,t.jsx)("span",{children:"Try the scratchpad"})]}),(0,t.jsx)("span",{children:"to experiment without restrictions on variable names."})]})})]},"multiple-defs"))}return _.length>0&&v.push((0,t.jsxs)("div",{children:[_.map(Ht),n&&(0,t.jsx)(N,{errors:_,cellId:n}),(0,t.jsxs)(I,{title:"Why can't I use `import *`?",children:[(0,t.jsx)("p",{className:"pb-2",children:"Star imports are incompatible with marimo's git-friendly file format and reproducible reactive execution."}),(0,t.jsx)("p",{className:"py-2",children:"marimo's Python file format stores code in functions, so notebooks can be imported as regular Python modules without executing all their code. But Python disallows `import *` everywhere except at the top-level of a module."}),(0,t.jsx)("p",{className:"py-2",children:"Star imports would also silently add names to globals, which would be incompatible with reactive execution."}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(T,{href:"https://links.marimo.app/errors-import-star",children:["Learn more at our docs"," ",(0,t.jsx)(A,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"import-star")),L.length>0&&v.push((0,t.jsxs)("div",{children:[L.map(Ut),n&&(0,t.jsx)(N,{errors:L,cellId:n})]},"interruption")),C.length>0&&v.push((0,t.jsxs)("ul",{children:[C.map(Kt),C.some(Rt)&&(0,t.jsx)(I,{children:"Fix the error in the mentioned cells, or handle the exceptions with try/except blocks."}),n&&(0,t.jsx)(N,{errors:C,cellId:n})]},"exception")),S.length>0&&v.push((0,t.jsxs)("ul",{children:[S.map(Gt),n&&(0,t.jsx)(N,{errors:S,cellId:n}),(0,t.jsx)(I,{children:S.some(Jt)?"Ensure that the referenced cells define the required variables, or turn off strict execution.":"Something is wrong with your declarations. Fix any discrepancies, or turn off strict execution."})]},"strict-exception")),W.length>0&&v.push((0,t.jsxs)("div",{children:[W.map(Xt),n&&(0,t.jsx)(N,{errors:W,cellId:n})]},"internal")),D.length>0&&v.push((0,t.jsxs)("div",{children:[D.map(Yt),n&&(0,t.jsx)(N,{errors:D,cellId:n})]},"ancestor-prevented")),V.length>0&&v.push((0,t.jsxs)("div",{children:[V.map(Zt),n&&(0,t.jsx)(N,{errors:V,cellId:n})]},"ancestor-stopped")),Q.length>0&&v.push((0,t.jsxs)("div",{children:[Q.map(er),n&&(0,t.jsx)(N,{errors:Q,cellId:n,className:"mt-2.5"})]},"sql-errors")),v},O=`font-code font-medium tracking-wide ${o}`,P;e[17]!==O||e[18]!==a?(P=(0,t.jsx)(Re,{className:O,children:a}),e[17]=O,e[18]=a,e[19]=P):P=e[19];let je=P;m=Ge,f=c,e[20]===i?u=e[21]:(u=Y("border-none font-code text-sm text-[0.84375rem] px-0 text-muted-foreground normal [&:has(svg)]:pl-0 space-y-4",i),e[20]=i,e[21]=u),j=je,p="flex flex-col gap-8",d=fe(),e[2]=c,e[3]=n,e[4]=l,e[5]=i,e[6]=s,e[7]=o,e[8]=a,e[9]=m,e[10]=p,e[11]=d,e[12]=f,e[13]=u,e[14]=j}else m=e[9],p=e[10],d=e[11],f=e[12],u=e[13],j=e[14];let h;e[22]!==p||e[23]!==d?(h=(0,t.jsx)("div",{children:(0,t.jsx)("div",{className:p,children:d})}),e[22]=p,e[23]=d,e[24]=h):h=e[24];let g;return e[25]!==m||e[26]!==f||e[27]!==u||e[28]!==j||e[29]!==h?(g=(0,t.jsxs)(m,{variant:f,className:u,children:[j,h]}),e[25]=m,e[26]=f,e[27]=u,e[28]=j,e[29]=h,e[30]=g):g=e[30],g};function gt(r){return r.type==="interruption"}function yt(r){return r.type==="internal"}function vt(r){return r.type==="ancestor-prevented"}function Nt(r){return r.type==="ancestor-stopped"}function bt(r){return r.type==="sql-error"}function wt(r){return r.type==="exception"}function kt(r){return r.type==="setup-refs"}function It(r){return r.type==="cycle"}function $t(r){return r.type==="multiple-defs"}function _t(r){return r.type==="import-star"}function Ft(r){return r.type==="interruption"}function Tt(r){return r.type==="exception"}function At(r){return r.type==="strict-exception"}function Ct(r){return r.type==="internal"}function St(r){return r.type==="ancestor-prevented"}function Mt(r){return r.type==="ancestor-stopped"}function Pt(r){return r.type==="syntax"}function qt(r){return r.type==="unknown"}function zt(r){return r.type==="sql-error"}function Et(r){return r.msg.includes("!pip")}function Lt(r){return r.msg.includes("use os.subprocess")}function Wt(r,e){return(0,t.jsx)("pre",{children:k(r.msg,`syntax-${e}`)},`syntax-${e}`)}function Dt(r,e){return(0,t.jsx)("pre",{children:k(r.msg,`unknown-${e}`)},`unknown-${e}`)}function Vt(r,e){return r.edges_with_vars.map((s,n)=>(0,t.jsxs)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:[(0,t.jsx)(b,{cellId:s[0]}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[": "," ",s[1].length===1?s[1][0]:s[1].join(", ")]})]},`setup-refs-${e}-${n}`))}function Bt(r,e){return r.edges_with_vars.map((s,n)=>(0,t.jsxs)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:[(0,t.jsx)(b,{cellId:s[0]}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[" -> ",s[1].length===1?s[1][0]:s[1].join(", ")," -> "]}),(0,t.jsx)(b,{cellId:s[2]})]},`cycle-${e}-${n}`))}function Qt(r,e){return(0,t.jsx)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:(0,t.jsx)(b,{cellId:r})},`cell-${e}`)}function Ot(r,e){return(0,t.jsxs)(E.Fragment,{children:[(0,t.jsx)("p",{className:"text-muted-foreground mt-2",children:`'${r.name}' was also defined by:`}),(0,t.jsx)("ul",{className:"list-disc",children:r.cells.map(Qt)})]},`multiple-defs-${e}`)}function Ht(r,e){return(0,t.jsx)("p",{className:"text-muted-foreground",children:r.msg},`import-star-${e}`)}function Ut(r,e){return(0,t.jsx)("p",{children:"This cell was interrupted and needs to be re-run."},`interruption-${e}`)}function Kt(r,e){return r.exception_type==="NameError"&&r.msg.startsWith("name 'mo'")?(0,t.jsx)("li",{className:"my-2",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground",children:"name 'mo' is not defined."}),(0,t.jsxs)("p",{className:"text-muted-foreground mt-2",children:["The marimo module (imported as"," ",(0,t.jsx)(te,{className:"inline",children:"mo"}),") is required for Markdown, SQL, and UI elements."]})]})},`exception-${e}`):r.exception_type==="NameError"&&r.msg.startsWith("name '_")?(0,t.jsx)("li",{className:"my-2",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground",children:r.msg}),(0,t.jsxs)("p",{className:"text-muted-foreground mt-2",children:["Variables prefixed with an underscore are local to a cell"," ","(",(0,t.jsxs)(T,{href:"https://links.marimo.app/local-variables",children:["docs"," ",(0,t.jsx)(A,{size:"0.75rem",className:"inline"})]}),")."]}),(0,t.jsx)("div",{className:"text-muted-foreground mt-2",children:"See the console area for a traceback."})]})},`exception-${e}`):(0,t.jsx)("li",{className:"my-2",children:r.raising_cell==null?(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground",children:k(r.msg,`exception-${e}`)}),(0,t.jsx)("div",{className:"text-muted-foreground mt-2",children:"See the console area for a traceback."})]}):(0,t.jsxs)("div",{children:[k(r.msg,`exception-${e}`),(0,t.jsx)(b,{cellId:r.raising_cell})]})},`exception-${e}`)}function Rt(r){return r.raising_cell!=null}function Gt(r,e){return(0,t.jsx)("li",{className:"my-2",children:r.blamed_cell==null?(0,t.jsx)("p",{children:r.msg}):(0,t.jsxs)("div",{children:[r.msg,(0,t.jsx)(b,{cellId:r.blamed_cell})]})},`strict-exception-${e}`)}function Jt(r){return r.blamed_cell!=null}function Xt(r,e){return(0,t.jsx)("p",{children:r.msg},`internal-${e}`)}function Yt(r,e){return(0,t.jsxs)("div",{children:[r.msg,r.blamed_cell==null?(0,t.jsxs)("span",{children:["(",(0,t.jsx)(b,{cellId:r.raising_cell}),")"]}):(0,t.jsxs)("span",{children:["(",(0,t.jsx)(b,{cellId:r.raising_cell}),"\xA0blames\xA0",(0,t.jsx)(b,{cellId:r.blamed_cell}),")"]})]},`ancestor-prevented-${e}`)}function Zt(r,e){return(0,t.jsxs)("div",{children:[r.msg,(0,t.jsx)(b,{cellId:r.raising_cell})]},`ancestor-stopped-${e}`)}function er(r,e){return(0,t.jsx)("div",{className:"space-y-2 mt-2",children:(0,t.jsx)("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.msg})},`sql-error-${e}`)}export{re as a,oe as i,ft as n,me as r,jt as t};
|
|
7
|
+
Database schema: ${i}`),(a=n.aiFix)==null||a.setAiCompletionCell({cellId:n.cellId,initialPrompt:l,triggerImmediately:n.aiFix.triggerFix})}}]:[]}function rt(r){let e=se[r];return e===r?`import ${e}`:`import ${e} as ${r}`}var se={mo:"marimo",alt:"altair",bokeh:"bokeh",dask:"dask",np:"numpy",pd:"pandas",pl:"polars",plotly:"plotly",plt:"matplotlib.pyplot",px:"plotly.express",scipy:"scipy",sk:"sklearn",sns:"seaborn",stats:"scipy.stats",tf:"tensorflow",torch:"torch",xr:"xarray",dt:"datetime",json:"json",math:"math",os:"os",re:"re",sys:"sys"},st=P(),nt=Ie("marimo:ai-autofix-mode","autofix",Fe);function lt(){let r=(0,st.c)(3),[e,s]=Ne(nt),n;return r[0]!==e||r[1]!==s?(n={fixMode:e,setFixMode:s},r[0]=e,r[1]=s,r[2]=n):n=r[2],n}var G=P(),t=J(qe(),1);const N=r=>{let e=(0,G.c)(21),{errors:s,cellId:n,className:i}=r,l=ve(),{createNewCell:a}=ke(),c=be(Me),o;if(e[0]!==c||e[1]!==s){let x;e[3]===c?x=e[4]:(x=y=>tt(y,{aiEnabled:c}),e[3]=c,e[4]=x),o=s.flatMap(x),e[0]=c,e[1]=s,e[2]=o}else o=e[2];let m=o,p=ye(Ve);if(m.length===0)return null;let d=m[0],f;e[5]!==n||e[6]!==a||e[7]!==d||e[8]!==p||e[9]!==l?(f=x=>{var w;let y=(w=l.get(Ce).cellHandles[n].current)==null?void 0:w.editorView;d.onFix({addCodeBelow:_=>{a({cellId:n,autoFocus:!1,before:!1,code:_})},editor:y,cellId:n,aiFix:{setAiCompletionCell:p,triggerFix:x}}),y==null||y.focus()},e[5]=n,e[6]=a,e[7]=d,e[8]=p,e[9]=l,e[10]=f):f=e[10];let u=f,j;e[11]===i?j=e[12]:(j=Y("my-2",i),e[11]=i,e[12]=j);let h;e[13]!==d.description||e[14]!==d.fixType||e[15]!==d.title||e[16]!==u?(h=d.fixType==="ai"?(0,t.jsx)(oe,{tooltip:d.description,openPrompt:()=>u(!1),applyAutofix:()=>u(!0)}):(0,t.jsx)(ee,{content:d.description,align:"start",children:(0,t.jsxs)($,{size:"xs",variant:"outline",className:"font-normal",onClick:()=>u(!1),children:[(0,t.jsx)(Z,{className:"h-3 w-3 mr-2"}),d.title]})}),e[13]=d.description,e[14]=d.fixType,e[15]=d.title,e[16]=u,e[17]=h):h=e[17];let g;return e[18]!==j||e[19]!==h?(g=(0,t.jsx)("div",{className:j,children:h}),e[18]=j,e[19]=h,e[20]=g):g=e[20],g};var ne=De,le=Z,ie="Suggest a prompt",ae="Fix with AI";const oe=r=>{let e=(0,G.c)(21),{tooltip:s,openPrompt:n,applyAutofix:i}=r,{fixMode:l,setFixMode:a}=lt(),c=l==="prompt"?n:i,o;e[0]===l?o=e[1]:(o=l==="prompt"?(0,t.jsx)(ne,{className:"h-3 w-3 mr-2 mb-0.5"}):(0,t.jsx)(le,{className:"h-3 w-3 mr-2 mb-0.5"}),e[0]=l,e[1]=o);let m=l==="prompt"?ie:ae,p;e[2]!==c||e[3]!==o||e[4]!==m?(p=(0,t.jsxs)($,{size:"xs",variant:"outline",className:"font-normal rounded-r-none border-r-0",onClick:c,children:[o,m]}),e[2]=c,e[3]=o,e[4]=m,e[5]=p):p=e[5];let d;e[6]!==p||e[7]!==s?(d=(0,t.jsx)(ee,{content:s,align:"start",children:p}),e[6]=p,e[7]=s,e[8]=d):d=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=(0,t.jsx)(Ee,{asChild:!0,children:(0,t.jsx)($,{size:"xs",variant:"outline",className:"rounded-l-none px-2","aria-label":"Fix options",children:(0,t.jsx)(ze,{className:"h-3 w-3"})})}),e[9]=f):f=e[9];let u;e[10]!==l||e[11]!==a?(u=()=>{a(l==="prompt"?"autofix":"prompt")},e[10]=l,e[11]=a,e[12]=u):u=e[12];let j=l==="prompt"?"autofix":"prompt",h;e[13]===j?h=e[14]:(h=(0,t.jsx)(it,{mode:j}),e[13]=j,e[14]=h);let g;e[15]!==u||e[16]!==h?(g=(0,t.jsxs)(We,{children:[f,(0,t.jsx)(Le,{align:"end",className:"w-56",children:(0,t.jsx)(Pe,{className:"flex items-center gap-2",onClick:u,children:h})})]}),e[15]=u,e[16]=h,e[17]=g):g=e[17];let x;return e[18]!==g||e[19]!==d?(x=(0,t.jsxs)("div",{className:"flex",children:[d,g]}),e[18]=g,e[19]=d,e[20]=x):x=e[20],x};var it=r=>{let e=(0,G.c)(12),{mode:s}=r,n;e[0]===s?n=e[1]:(n=s==="prompt"?(0,t.jsx)(ne,{className:"h-4 w-4"}):(0,t.jsx)(le,{className:"h-4 w-4"}),e[0]=s,e[1]=n);let i=n,l=s==="prompt"?ie:ae,a=s==="prompt"?"Edit the prompt before applying":"Apply AI fixes automatically",c;e[2]===l?c=e[3]:(c=(0,t.jsx)("span",{className:"font-medium",children:l}),e[2]=l,e[3]=c);let o;e[4]===a?o=e[5]:(o=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:a}),e[4]=a,e[5]=o);let m;e[6]!==c||e[7]!==o?(m=(0,t.jsxs)("div",{className:"flex flex-col",children:[c,o]}),e[6]=c,e[7]=o,e[8]=m):m=e[8];let p;return e[9]!==i||e[10]!==m?(p=(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[i,m]}),e[9]=i,e[10]=m,e[11]=p):p=e[11],p},ce=/(https?:\/\/\S+)/,at=/\.(png|jpe?g|gif|webp|svg|ico)(\?.*)?$/i,de=/^data:image\//i,ot=["avatars.githubusercontent.com"];function me(r){return de.test(r)?[{type:"image",url:r}]:r.split(ce).filter(e=>e.trim()!=="").map(e=>ce.test(e)?at.test(e)||de.test(e)||ot.some(s=>e.includes(s))?{type:"image",url:e}:{type:"url",url:e}:{type:"text",value:e})}var pe=P(),E=J(we(),1),ct=new Ae;const R=r=>{let e=RegExp("\x1B\\[[0-9;]*m","g");return r.replaceAll(e,"")};var ue=/(pip\s+install|uv\s+add|uv\s+pip\s+install)\s+/gi;function dt(r){ue.lastIndex=0;let e=ue.exec(r);if(!e)return null;let s=e.index+e[0].length,n=r.slice(s).split(/\s+/),i="",l=0;for(let c of n){let o=c.trim();if(!o)continue;if(o.startsWith("-")){l+=o.length+1;continue}let m=o.match(/^[\w,.[\]-]+/);if(m){i=m[0];break}break}if(!i)return null;let a=s+l+i.length;return{package:i,endIndex:a}}function k(r,e=""){if(!r)return null;if(!/https?:\/\//.test(r))return r;let s=me(r);return s.length===1&&s[0].type==="text"?r:(0,t.jsx)(t.Fragment,{children:s.map((n,i)=>{let l=e?`${e}-${i}`:i;if(n.type==="url"){let a=R(n.url);return(0,t.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:X.stopPropagation(),className:"text-link hover:underline",children:a},l)}if(n.type==="image"){let a=R(n.url);return(0,t.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",onClick:X.stopPropagation(),className:"text-link hover:underline",children:a},l)}return(0,t.jsx)(E.Fragment,{children:n.value},l)})})}var mt=r=>{let e=(0,pe.c)(6),{packages:s,children:n}=r,{handleInstallPackages:i}=Xe(),l;e[0]!==i||e[1]!==s?(l=c=>{i(s),c.preventDefault()},e[0]=i,e[1]=s,e[2]=l):l=e[2];let a;return e[3]!==n||e[4]!==l?(a=(0,t.jsx)("button",{onClick:l,className:"text-link hover:underline",type:"button",children:n}),e[3]=n,e[4]=l,e[5]=a):a=e[5],a};const pt=r=>{if(!(r instanceof K.Text))return;let e=R(r.data);if(!/(pip\s+install|uv\s+add|uv\s+pip\s+install)/i.test(e))return;let s=[],n=/(pip\s+install|uv\s+add|uv\s+pip\s+install)\s+/gi,i;for(;(i=n.exec(e))!==null;){let c=i.index,o=dt(e.slice(c));o&&s.push({match:i,result:o})}if(s.length===0)return;let l=[],a=0;if(s.forEach((c,o)=>{let{match:m,result:p}=c,d=m.index,f=d+p.endIndex;if(a<d){let j=e.slice(a,d);l.push((0,t.jsx)(E.Fragment,{children:k(j,`before-${o}`)},`before-${o}`))}let u=e.slice(d,f);l.push((0,t.jsx)(mt,{packages:[p.package],children:u},`install-${o}`)),a=f}),a<e.length){let c=e.slice(a);l.push((0,t.jsx)(E.Fragment,{children:k(c,"after")},"after"))}return(0,t.jsx)(t.Fragment,{children:l})},ut=r=>{if(!(r instanceof K.Text))return;let e=r.data;if(!/https?:\/\//.test(e))return;let s=k(e);if(typeof s!="string")return(0,t.jsx)(t.Fragment,{children:s})},ht=(...r)=>e=>{for(let s of r){let n=s(e);if(n!==void 0)return n}},xt=(r,e)=>(0,t.jsx)("span",{children:_e(ct.ansi_to_html(r),{replace:s=>e(s)})}),ft=r=>{let e=(0,pe.c)(4),{text:s}=r,n;e[0]===s?n=e[1]:(n=xt(s,ht(pt,ut)),e[0]=s,e[1]=n);let i=n,l;return e[2]===i?l=e[3]:(l=(0,t.jsx)(t.Fragment,{children:i}),e[2]=i,e[3]=l),l};var he=P(),I=r=>{let e=(0,he.c)(10),s=r.title??"Tip",n;e[0]===s?n=e[1]:(n=(0,t.jsx)(Oe,{className:"pt-2 pb-2 font-normal",children:s}),e[0]=s,e[1]=n);let i;e[2]===r.children?i=e[3]:(i=(0,t.jsx)(Ge,{className:"mr-24 text-[0.84375rem]",children:r.children}),e[2]=r.children,e[3]=i);let l;e[4]!==n||e[5]!==i?(l=(0,t.jsxs)(He,{value:"item-1",className:"text-muted-foreground",children:[n,i]}),e[4]=n,e[5]=i,e[6]=l):l=e[6];let a;return e[7]!==r.className||e[8]!==l?(a=(0,t.jsx)(Ue,{type:"single",collapsible:!0,className:r.className,children:l}),e[7]=r.className,e[8]=l,e[9]=a):a=e[9],a};const jt=r=>{let e=(0,he.c)(31),{errors:s,cellId:n,className:i}=r,l=Te(),a="This cell wasn't run because it has errors",c="destructive",o="text-error";if(s.some(gt))a="Interrupted";else if(s.some(yt))a="An internal error occurred";else if(s.some(vt))a="Ancestor prevented from running",c="default",o="text-secondary-foreground";else if(s.some(Nt))a="Ancestor stopped",c="default",o="text-secondary-foreground";else if(s.some(bt))a="SQL error";else{let x;e[0]===s?x=e[1]:(x=s.find(wt),e[0]=s,e[1]=x);let y=x;y&&"exception_type"in y&&(a=y.exception_type)}let m,p,d,f,u,j;if(e[2]!==c||e[3]!==n||e[4]!==l||e[5]!==i||e[6]!==s||e[7]!==o||e[8]!==a){let x=s.filter(kt),y=s.filter(It),w=s.filter($t),_=s.filter(_t),L=s.filter(Ft),C=s.filter(Tt),S=s.filter(At),W=s.filter(Ct),D=s.filter(St),V=s.filter(Mt),F=s.filter(qt),B=s.filter(zt),Q=s.filter(Pt),M;e[15]===l?M=e[16]:(M=()=>{l.openDeveloperPanelTab("scratchpad")},e[15]=l,e[16]=M);let xe=M,fe=()=>{let v=[];if(F.length>0||B.length>0){let z=F.some(Et),ge=!z&&F.some(Lt);v.push((0,t.jsxs)("div",{children:[F.map(Wt),B.map(Dt),z&&(0,t.jsxs)($,{size:"xs",variant:"outline",className:"mt-2 font-normal",onClick:()=>Ke(l),children:[(0,t.jsx)(Ye,{className:"h-3.5 w-3.5 mr-1.5 mb-0.5"}),(0,t.jsx)("span",{children:"Open package manager"})]}),ge&&(0,t.jsxs)($,{size:"xs",variant:"outline",className:"mt-2 font-normal",onClick:()=>l.openDeveloperPanelTab("terminal"),children:[(0,t.jsx)(re,{className:"h-3.5 w-3.5 mr-1.5"}),(0,t.jsx)("span",{children:"Open terminal"})]}),n&&(0,t.jsx)(N,{errors:[...F,...B],cellId:n})]},"syntax-unknown"))}if(x.length>0&&v.push((0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground font-medium",children:"The setup cell cannot be run because it has references."}),(0,t.jsx)("ul",{className:"list-disc",children:x.flatMap(Vt)}),n&&(0,t.jsx)(N,{errors:x,cellId:n}),(0,t.jsxs)(I,{title:"Why can't the setup cell have references?",className:"mb-2",children:[(0,t.jsx)("p",{className:"pb-2",children:"The setup cell contains logic that must be run before any other cell runs, including top-level imports used by top-level functions. For this reason, it can't refer to other cells' variables."}),(0,t.jsx)("p",{className:"py-2",children:"Try simplifying the setup cell to only contain only necessary variables."}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(T,{href:"https://links.marimo.app/errors-setup",children:["Learn more at our docs"," ",(0,t.jsx)(A,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"setup-refs")),y.length>0&&v.push((0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground font-medium",children:"This cell is in a cycle."}),(0,t.jsx)("ul",{className:"list-disc",children:y.flatMap(Bt)}),n&&(0,t.jsx)(N,{errors:y,cellId:n}),(0,t.jsxs)(I,{title:"What are cycles and how do I resolve them?",className:"mb-2",children:[(0,t.jsx)("p",{className:"pb-2",children:"An example of a cycle is if one cell declares a variable 'a' and reads 'b', and another cell declares 'b' and and reads 'a'. Cycles like this make it impossible for marimo to know how to run your cells, and generally suggest that your code has a bug."}),(0,t.jsx)("p",{className:"py-2",children:"Try merging these cells into a single cell to eliminate the cycle."}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(T,{href:"https://links.marimo.app/errors-cycles",children:["Learn more at our docs"," ",(0,t.jsx)(A,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"cycle")),w.length>0){let z=w[0].name;v.push((0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground font-medium",children:"This cell redefines variables from other cells."}),w.map(Ot),n&&(0,t.jsx)(N,{errors:w,cellId:n}),(0,t.jsxs)(I,{title:"Why can't I redefine variables?",children:[(0,t.jsx)("p",{className:"pb-2",children:"marimo requires that each variable is defined in just one cell. This constraint enables reactive and reproducible execution, arbitrary cell reordering, seamless UI elements, execution as a script, and more."}),(0,t.jsxs)("p",{className:"py-2",children:["Try merging this cell with the mentioned cells or wrapping it in a function. Alternatively, prefix variables with an underscore (e.g., ",(0,t.jsxs)(te,{className:"inline",children:["_",z]}),"). to make them private to this cell."]}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(T,{href:"https://links.marimo.app/errors-multiple-definitions",children:["Learn more at our docs"," ",(0,t.jsx)(A,{size:"0.75rem",className:"inline"})]}),"."]})]}),(0,t.jsx)(I,{title:"Need a scratchpad?",children:(0,t.jsxs)("div",{className:"flex flex-row gap-2 items-center",children:[(0,t.jsxs)($,{size:"xs",variant:"link",className:"my-2 font-normal mx-0 px-0",onClick:xe,children:[(0,t.jsx)($e,{className:"h-3"}),(0,t.jsx)("span",{children:"Try the scratchpad"})]}),(0,t.jsx)("span",{children:"to experiment without restrictions on variable names."})]})})]},"multiple-defs"))}return _.length>0&&v.push((0,t.jsxs)("div",{children:[_.map(Ht),n&&(0,t.jsx)(N,{errors:_,cellId:n}),(0,t.jsxs)(I,{title:"Why can't I use `import *`?",children:[(0,t.jsx)("p",{className:"pb-2",children:"Star imports are incompatible with marimo's git-friendly file format and reproducible reactive execution."}),(0,t.jsx)("p",{className:"py-2",children:"marimo's Python file format stores code in functions, so notebooks can be imported as regular Python modules without executing all their code. But Python disallows `import *` everywhere except at the top-level of a module."}),(0,t.jsx)("p",{className:"py-2",children:"Star imports would also silently add names to globals, which would be incompatible with reactive execution."}),(0,t.jsxs)("p",{className:"py-2",children:[(0,t.jsxs)(T,{href:"https://links.marimo.app/errors-import-star",children:["Learn more at our docs"," ",(0,t.jsx)(A,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"import-star")),L.length>0&&v.push((0,t.jsxs)("div",{children:[L.map(Ut),n&&(0,t.jsx)(N,{errors:L,cellId:n})]},"interruption")),C.length>0&&v.push((0,t.jsxs)("ul",{children:[C.map(Gt),C.some(Rt)&&(0,t.jsx)(I,{children:"Fix the error in the mentioned cells, or handle the exceptions with try/except blocks."}),n&&(0,t.jsx)(N,{errors:C,cellId:n})]},"exception")),S.length>0&&v.push((0,t.jsxs)("ul",{children:[S.map(Jt),n&&(0,t.jsx)(N,{errors:S,cellId:n}),(0,t.jsx)(I,{children:S.some(Kt)?"Ensure that the referenced cells define the required variables, or turn off strict execution.":"Something is wrong with your declarations. Fix any discrepancies, or turn off strict execution."})]},"strict-exception")),W.length>0&&v.push((0,t.jsxs)("div",{children:[W.map(Xt),n&&(0,t.jsx)(N,{errors:W,cellId:n})]},"internal")),D.length>0&&v.push((0,t.jsxs)("div",{children:[D.map(Yt),n&&(0,t.jsx)(N,{errors:D,cellId:n})]},"ancestor-prevented")),V.length>0&&v.push((0,t.jsxs)("div",{children:[V.map(Zt),n&&(0,t.jsx)(N,{errors:V,cellId:n})]},"ancestor-stopped")),Q.length>0&&v.push((0,t.jsxs)("div",{children:[Q.map(er),n&&(0,t.jsx)(N,{errors:Q,cellId:n,className:"mt-2.5"})]},"sql-errors")),v},O=`font-code font-medium tracking-wide ${o}`,q;e[17]!==O||e[18]!==a?(q=(0,t.jsx)(Re,{className:O,children:a}),e[17]=O,e[18]=a,e[19]=q):q=e[19];let je=q;m=Je,f=c,e[20]===i?u=e[21]:(u=Y("border-none font-code text-sm text-[0.84375rem] px-0 text-muted-foreground normal [&:has(svg)]:pl-0 space-y-4",i),e[20]=i,e[21]=u),j=je,p="flex flex-col gap-8",d=fe(),e[2]=c,e[3]=n,e[4]=l,e[5]=i,e[6]=s,e[7]=o,e[8]=a,e[9]=m,e[10]=p,e[11]=d,e[12]=f,e[13]=u,e[14]=j}else m=e[9],p=e[10],d=e[11],f=e[12],u=e[13],j=e[14];let h;e[22]!==p||e[23]!==d?(h=(0,t.jsx)("div",{children:(0,t.jsx)("div",{className:p,children:d})}),e[22]=p,e[23]=d,e[24]=h):h=e[24];let g;return e[25]!==m||e[26]!==f||e[27]!==u||e[28]!==j||e[29]!==h?(g=(0,t.jsxs)(m,{variant:f,className:u,children:[j,h]}),e[25]=m,e[26]=f,e[27]=u,e[28]=j,e[29]=h,e[30]=g):g=e[30],g};function gt(r){return r.type==="interruption"}function yt(r){return r.type==="internal"}function vt(r){return r.type==="ancestor-prevented"}function Nt(r){return r.type==="ancestor-stopped"}function bt(r){return r.type==="sql-error"}function wt(r){return r.type==="exception"}function kt(r){return r.type==="setup-refs"}function It(r){return r.type==="cycle"}function $t(r){return r.type==="multiple-defs"}function _t(r){return r.type==="import-star"}function Ft(r){return r.type==="interruption"}function Tt(r){return r.type==="exception"}function At(r){return r.type==="strict-exception"}function Ct(r){return r.type==="internal"}function St(r){return r.type==="ancestor-prevented"}function Mt(r){return r.type==="ancestor-stopped"}function qt(r){return r.type==="syntax"}function zt(r){return r.type==="unknown"}function Pt(r){return r.type==="sql-error"}function Et(r){return r.msg.includes("!pip")}function Lt(r){return r.msg.includes("use os.subprocess")}function Wt(r,e){return(0,t.jsx)("pre",{children:k(r.msg,`syntax-${e}`)},`syntax-${e}`)}function Dt(r,e){return(0,t.jsx)("pre",{children:k(r.msg,`unknown-${e}`)},`unknown-${e}`)}function Vt(r,e){return r.edges_with_vars.map((s,n)=>(0,t.jsxs)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:[(0,t.jsx)(b,{cellId:s[0]}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[": "," ",s[1].length===1?s[1][0]:s[1].join(", ")]})]},`setup-refs-${e}-${n}`))}function Bt(r,e){return r.edges_with_vars.map((s,n)=>(0,t.jsxs)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:[(0,t.jsx)(b,{cellId:s[0]}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[" -> ",s[1].length===1?s[1][0]:s[1].join(", ")," -> "]}),(0,t.jsx)(b,{cellId:s[2]})]},`cycle-${e}-${n}`))}function Qt(r,e){return(0,t.jsx)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:(0,t.jsx)(b,{cellId:r})},`cell-${e}`)}function Ot(r,e){return(0,t.jsxs)(E.Fragment,{children:[(0,t.jsx)("p",{className:"text-muted-foreground mt-2",children:`'${r.name}' was also defined by:`}),(0,t.jsx)("ul",{className:"list-disc",children:r.cells.map(Qt)})]},`multiple-defs-${e}`)}function Ht(r,e){return(0,t.jsx)("p",{className:"text-muted-foreground",children:r.msg},`import-star-${e}`)}function Ut(r,e){return(0,t.jsx)("p",{children:"This cell was interrupted and needs to be re-run."},`interruption-${e}`)}function Gt(r,e){return r.exception_type==="NameError"&&r.msg.startsWith("name 'mo'")?(0,t.jsx)("li",{className:"my-2",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground",children:"name 'mo' is not defined."}),(0,t.jsxs)("p",{className:"text-muted-foreground mt-2",children:["The marimo module (imported as"," ",(0,t.jsx)(te,{className:"inline",children:"mo"}),") is required for Markdown, SQL, and UI elements."]})]})},`exception-${e}`):r.exception_type==="NameError"&&r.msg.startsWith("name '_")?(0,t.jsx)("li",{className:"my-2",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground",children:r.msg}),(0,t.jsxs)("p",{className:"text-muted-foreground mt-2",children:["Variables prefixed with an underscore are local to a cell"," ","(",(0,t.jsxs)(T,{href:"https://links.marimo.app/local-variables",children:["docs"," ",(0,t.jsx)(A,{size:"0.75rem",className:"inline"})]}),")."]}),(0,t.jsx)("div",{className:"text-muted-foreground mt-2",children:"See the console area for a traceback."})]})},`exception-${e}`):(0,t.jsx)("li",{className:"my-2",children:r.raising_cell==null?(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-muted-foreground",children:k(r.msg,`exception-${e}`)}),(0,t.jsx)("div",{className:"text-muted-foreground mt-2",children:"See the console area for a traceback."})]}):(0,t.jsxs)("div",{children:[k(r.msg,`exception-${e}`),(0,t.jsx)(b,{cellId:r.raising_cell})]})},`exception-${e}`)}function Rt(r){return r.raising_cell!=null}function Jt(r,e){return(0,t.jsx)("li",{className:"my-2",children:r.blamed_cell==null?(0,t.jsx)("p",{children:r.msg}):(0,t.jsxs)("div",{children:[r.msg,(0,t.jsx)(b,{cellId:r.blamed_cell})]})},`strict-exception-${e}`)}function Kt(r){return r.blamed_cell!=null}function Xt(r,e){return(0,t.jsx)("p",{children:r.msg},`internal-${e}`)}function Yt(r,e){return(0,t.jsxs)("div",{children:[r.msg,r.blamed_cell==null?(0,t.jsxs)("span",{children:["(",(0,t.jsx)(b,{cellId:r.raising_cell}),")"]}):(0,t.jsxs)("span",{children:["(",(0,t.jsx)(b,{cellId:r.raising_cell}),"\xA0blames\xA0",(0,t.jsx)(b,{cellId:r.blamed_cell}),")"]})]},`ancestor-prevented-${e}`)}function Zt(r,e){return(0,t.jsxs)("div",{children:[r.msg,(0,t.jsx)(b,{cellId:r.raising_cell})]},`ancestor-stopped-${e}`)}function er(r,e){return(0,t.jsx)("div",{className:"space-y-2 mt-2",children:(0,t.jsx)("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.msg})},`sql-error-${e}`)}export{re as a,oe as i,ft as n,me as r,jt as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as v}from"./chunk-LvLJmgfZ.js";import{p as x,u as j}from"./useEvent-DlWF5OMa.js";import{t as _}from"./react-BGmjiNul.js";import{
|
|
1
|
+
import{s as v}from"./chunk-LvLJmgfZ.js";import{p as x,u as j}from"./useEvent-DlWF5OMa.js";import{t as _}from"./react-BGmjiNul.js";import{Nr as N,Pr as u}from"./cells-rr1jjvJk.js";import{t as y}from"./compiler-runtime-DeeZ7FnK.js";import{o as w}from"./utils-CJJIceVn.js";import{t as R}from"./jsx-runtime-DN_bIXfG.js";import{t as z}from"./mode-BYulXE3t.js";import{t as C}from"./usePress-C2LPFxyv.js";import{t as H}from"./copy-icon-B69c-352.js";import{t as E}from"./purify.es-N-2faAGj.js";import{t as k}from"./useRunCells-BGzo-QMk.js";var F=y(),m=v(_(),1),s=v(R(),1);const M=e=>{let t=(0,F.c)(16),r,a,i;t[0]===e?(r=t[1],a=t[2],i=t[3]):({href:a,children:r,...i}=e,t[0]=e,t[1]=r,t[2]=a,t[3]=i);let o=(0,m.useRef)(null),l;t[4]===a?l=t[5]:(l=()=>{let d=new URL(globalThis.location.href);d.hash=a,globalThis.history.pushState({},"",d.toString()),globalThis.dispatchEvent(new HashChangeEvent("hashchange"));let S=a.slice(1),A=document.getElementById(S);A&&A.scrollIntoView({behavior:"smooth",block:"start"})},t[4]=a,t[5]=l);let n=l,c;t[6]===n?c=t[7]:(c={onPress:()=>{n()}},t[6]=n,t[7]=c);let{pressProps:b}=C(c),f;t[8]===n?f=t[9]:(f=d=>{d.preventDefault(),n()},t[8]=n,t[9]=f);let g=f,h;return t[10]!==r||t[11]!==g||t[12]!==a||t[13]!==b||t[14]!==i?(h=(0,s.jsx)("a",{ref:o,href:a,...b,onClick:g,...i,children:r}),t[10]=r,t[11]=g,t[12]=a,t[13]=b,t[14]=i,t[15]=h):h=t[15],h};var T=x(e=>{let t=e(k),r=e(w);if(t||r)return!1;let a=!0;try{a=z()==="read"}catch{return!0}return!a});function L(){return j(T)}var p="data-temp-href-target";E.addHook("beforeSanitizeAttributes",e=>{e.tagName==="A"&&(e.hasAttribute("target")||e.setAttribute("target","_self"),e.hasAttribute("target")&&e.setAttribute(p,e.getAttribute("target")||""))}),E.addHook("afterSanitizeAttributes",e=>{e.tagName==="A"&&e.hasAttribute(p)&&(e.setAttribute("target",e.getAttribute(p)||""),e.removeAttribute(p),e.getAttribute("target")==="_blank"&&e.setAttribute("rel","noopener noreferrer"))});function O(e){let t={USE_PROFILES:{html:!0,svg:!0,mathMl:!0},FORCE_BODY:!0,CUSTOM_ELEMENT_HANDLING:{tagNameCheck:/^(marimo-[A-Za-z][\w-]*|iconify-icon)$/,attributeNameCheck:/^[A-Za-z][\w-]*$/},SAFE_FOR_XML:!e.includes("marimo-mermaid")};return E.sanitize(e,t)}var I=y(),D=e=>{if(e instanceof u.Element&&!/^[A-Za-z][\w-]*$/.test(e.name))return m.createElement(m.Fragment)},P=(e,t)=>{if(t instanceof u.Element&&t.name==="body"){if((0,m.isValidElement)(e)&&"props"in e){let r=e.props.children;return(0,s.jsx)(s.Fragment,{children:r})}return}},V=(e,t)=>{if(t instanceof u.Element&&t.name==="html"){if((0,m.isValidElement)(e)&&"props"in e){let r=e.props.children;return(0,s.jsx)(s.Fragment,{children:r})}return}},W=e=>{if(e instanceof u.Element&&e.attribs&&e.name==="iframe"){let t=document.createElement("iframe");return Object.entries(e.attribs).forEach(([r,a])=>{r.startsWith('"')&&r.endsWith('"')&&(r=r.slice(1,-1)),t.setAttribute(r,a)}),(0,s.jsx)("div",{dangerouslySetInnerHTML:{__html:t.outerHTML}})}},$=e=>{if(e instanceof u.Element&&e.name==="script"){let t=e.attribs.src;if(!t)return;if(!document.querySelector(`script[src="${t}"]`)){let r=document.createElement("script");r.src=t,document.head.append(r)}return(0,s.jsx)(s.Fragment,{})}},U=(e,t)=>{if(t instanceof u.Element&&t.name==="a"){let r=t.attribs.href;if(r!=null&&r.startsWith("#")&&!r.startsWith("#code/")){let a=null;return(0,m.isValidElement)(e)&&"props"in e&&(a=e.props.children),(0,s.jsx)(M,{href:r,...t.attribs,children:a})}}},Z=(e,t,r)=>{var a,i;if(t instanceof u.Element&&t.name==="div"&&((i=(a=t.attribs)==null?void 0:a.class)!=null&&i.includes("codehilite")))return(0,s.jsx)(B,{children:e},r)},B=e=>{let t=(0,I.c)(3),{children:r}=e,a=(0,m.useRef)(null),i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,s.jsx)("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,s.jsx)(H,{tooltip:!1,className:"p-1",value:()=>{var n;let l=(n=a.current)==null?void 0:n.firstChild;return l&&l.textContent||""}})}),t[0]=i):i=t[0];let o;return t[1]===r?o=t[2]:(o=(0,s.jsxs)("div",{className:"relative group codehilite-wrapper",ref:a,children:[r,i]}),t[1]=r,t[2]=o),o};const q=({html:e,additionalReplacements:t=[],alwaysSanitizeHtml:r=!0})=>(0,s.jsx)(G,{html:e,alwaysSanitizeHtml:r,additionalReplacements:t});var G=({html:e,additionalReplacements:t=[],alwaysSanitizeHtml:r})=>{let a=L();return X({html:(0,m.useMemo)(()=>r||a?O(e):e,[e,r,a]),additionalReplacements:t})};function X({html:e,additionalReplacements:t=[]}){let r=[D,W,$,...t],a=[Z,U,P,V];return N(e,{replace:(i,o)=>{for(let l of r){let n=l(i,o);if(n)return n}return i},transform:(i,o,l)=>{for(let n of a){let c=n(i,o,l);if(c)return c}return i}})}export{q as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as be}from"./chunk-LvLJmgfZ.js";import{t as me}from"./react-BGmjiNul.js";import{L as ve,P as Ee,R as Te}from"./input-DP44ewsS.js";import{A as w,C as ge,M as we,N as v,O as Re,b as J,c as Ce,j as S,k as X,l as ye,w as Se,z as R}from"./usePress-C2LPFxyv.js";import{t as ke}from"./context-BAYdLMF_.js";var f=be(me(),1),_e=(0,f.createContext)(null);(0,f.createContext)(null),(0,f.createContext)(null),(0,f.createContext)(null),(0,f.createContext)(null);var Le=(0,f.createContext)({}),xe=(0,f.createContext)(null);(0,f.createContext)(null);var Fe=class{get currentNode(){return this._currentNode}set currentNode(e){if(!X(this.root,e))throw Error("Cannot set currentNode to a node that is not contained by the root node.");let t=[],r=e,n=e;for(this._currentNode=e;r&&r!==this.root;)if(r.nodeType===Node.DOCUMENT_FRAGMENT_NODE){let i=r,l=this._doc.createTreeWalker(i,this.whatToShow,{acceptNode:this._acceptNode});t.push(l),l.currentNode=n,this._currentSetFor.add(l),r=n=i.host}else r=r.parentNode;let o=this._doc.createTreeWalker(this.root,this.whatToShow,{acceptNode:this._acceptNode});t.push(o),o.currentNode=n,this._currentSetFor.add(o),this._walkerStack=t}get doc(){return this._doc}firstChild(){let e=this.currentNode,t=this.nextNode();return X(e,t)?(t&&(this.currentNode=t),t):(this.currentNode=e,null)}lastChild(){let e=this._walkerStack[0].lastChild();return e&&(this.currentNode=e),e}nextNode(){var t;let e=this._walkerStack[0].nextNode();if(e){if(e.shadowRoot){let r;if(typeof this.filter=="function"?r=this.filter(e):(t=this.filter)!=null&&t.acceptNode&&(r=this.filter.acceptNode(e)),r===NodeFilter.FILTER_ACCEPT)return this.currentNode=e,e;let n=this.nextNode();return n&&(this.currentNode=n),n}return e&&(this.currentNode=e),e}else if(this._walkerStack.length>1){this._walkerStack.shift();let r=this.nextNode();return r&&(this.currentNode=r),r}else return null}previousNode(){var r;let e=this._walkerStack[0];if(e.currentNode===e.root){if(this._currentSetFor.has(e))if(this._currentSetFor.delete(e),this._walkerStack.length>1){this._walkerStack.shift();let n=this.previousNode();return n&&(this.currentNode=n),n}else return null;return null}let t=e.previousNode();if(t){if(t.shadowRoot){let n;if(typeof this.filter=="function"?n=this.filter(t):(r=this.filter)!=null&&r.acceptNode&&(n=this.filter.acceptNode(t)),n===NodeFilter.FILTER_ACCEPT)return t&&(this.currentNode=t),t;let o=this.lastChild();return o&&(this.currentNode=o),o}return t&&(this.currentNode=t),t}else if(this._walkerStack.length>1){this._walkerStack.shift();let n=this.previousNode();return n&&(this.currentNode=n),n}else return null}nextSibling(){return null}previousSibling(){return null}parentNode(){return null}constructor(e,t,r,n){this._walkerStack=[],this._currentSetFor=new Set,this._acceptNode=i=>{var l;if(i.nodeType===Node.ELEMENT_NODE){let s=i.shadowRoot;if(s){let u=this._doc.createTreeWalker(s,this.whatToShow,{acceptNode:this._acceptNode});return this._walkerStack.unshift(u),NodeFilter.FILTER_ACCEPT}else{if(typeof this.filter=="function")return this.filter(i);if((l=this.filter)!=null&&l.acceptNode)return this.filter.acceptNode(i);if(this.filter===null)return NodeFilter.FILTER_ACCEPT}}return NodeFilter.FILTER_SKIP},this._doc=e,this.root=t,this.filter=n??null,this.whatToShow=r??NodeFilter.SHOW_ALL,this._currentNode=t,this._walkerStack.unshift(e.createTreeWalker(t,r,this._acceptNode));let o=t.shadowRoot;if(o){let i=this._doc.createTreeWalker(o,this.whatToShow,{acceptNode:this._acceptNode});this._walkerStack.unshift(i)}}};function Me(e,t,r,n){return we()?new Fe(e,t,r,n):e.createTreeWalker(t,r,n)}function Ie(e,t){let r=(0,f.useRef)(!0),n=(0,f.useRef)(null);(0,f.useEffect)(()=>(r.current=!0,()=>{r.current=!1}),[]),(0,f.useEffect)(()=>{let o=n.current;r.current?r.current=!1:(!o||t.some((i,l)=>!Object.is(i,o[l])))&&e(),n.current=t},t)}function x(e,t){if(!e)return!1;let r=window.getComputedStyle(e),n=/(auto|scroll)/.test(r.overflow+r.overflowX+r.overflowY);return n&&t&&(n=e.scrollHeight!==e.clientHeight||e.scrollWidth!==e.clientWidth),n}function Pe(e,t){let r=e;for(x(r,t)&&(r=r.parentElement);r&&!x(r,t);)r=r.parentElement;return r||document.scrollingElement||document.documentElement}function Ae(e,t){let r=[];for(;e&&e!==document.documentElement;)x(e,t)&&r.push(e),e=e.parentElement;return r}function We(e){return ge()?e.metaKey:e.ctrlKey}var Ke=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function He(e){return e instanceof HTMLInputElement&&!Ke.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}var Oe=0,z=new Map;function De(e){let[t,r]=(0,f.useState)();return R(()=>{if(!e)return;let n=z.get(e);if(n)r(n.element.id);else{let o=`react-aria-description-${Oe++}`;r(o);let i=document.createElement("div");i.id=o,i.style.display="none",i.textContent=e,document.body.appendChild(i),n={refCount:0,element:i},z.set(e,n)}return n.refCount++,()=>{n&&--n.refCount===0&&(n.element.remove(),z.delete(e))}},[e]),{"aria-describedby":e?t:void 0}}function Y(e,t){let r=Q(e,t,"left"),n=Q(e,t,"top"),o=t.offsetWidth,i=t.offsetHeight,l=e.scrollLeft,s=e.scrollTop,{borderTopWidth:u,borderLeftWidth:c,scrollPaddingTop:a,scrollPaddingRight:p,scrollPaddingBottom:d,scrollPaddingLeft:N}=getComputedStyle(e),{scrollMarginTop:m,scrollMarginRight:L,scrollMarginBottom:k,scrollMarginLeft:ce}=getComputedStyle(t),se=l+parseInt(c,10),G=s+parseInt(u,10),M=se+e.clientWidth,I=G+e.clientHeight,P=parseInt(a,10)||0,A=parseInt(d,10)||0,W=parseInt(p,10)||0,K=parseInt(N,10)||0,ae=parseInt(m,10)||0,ue=parseInt(k,10)||0,de=parseInt(L,10)||0,H=r-(parseInt(ce,10)||0),O=r+o+de,D=n-ae,j=n+i+ue,fe=l+parseInt(c,10)+K,pe=M-W,he=s+parseInt(u,10)+P,Ne=I-A;(H>fe||O<pe)&&(H<=l+K?l=H-parseInt(c,10)-K:O>M-W&&(l+=O-M+W)),(D>he||j<Ne)&&(D<=G+P?s=D-parseInt(u,10)-P:j>I-A&&(s+=j-I+A)),e.scrollTo({left:l,top:s})}function Q(e,t,r){let n=r==="left"?"offsetLeft":"offsetTop",o=0;for(;t.offsetParent&&(o+=t[n],t.offsetParent!==e);){if(t.offsetParent.contains(e)){o-=e[n];break}t=t.offsetParent}return o}function je(e,t){if(e&&document.contains(e)){let l=document.scrollingElement||document.documentElement;if(window.getComputedStyle(l).overflow!=="hidden"&&!J()){var r;let{left:s,top:u}=e.getBoundingClientRect();e==null||(r=e.scrollIntoView)==null||r.call(e,{block:"nearest"});let{left:c,top:a}=e.getBoundingClientRect();if(Math.abs(s-c)>1||Math.abs(u-a)>1){var n,o,i;t==null||(o=t.containingElement)==null||(n=o.scrollIntoView)==null||n.call(o,{block:"center",inline:"center"}),(i=e.scrollIntoView)==null||i.call(e,{block:"nearest"})}}else{let s=Ae(e);for(let u of s)Y(u,e)}}}var B=new Map;function ze(e){let{locale:t}=ke(),r=t+(e?Object.entries(e).sort((o,i)=>o[0]<i[0]?-1:1).join():"");if(B.has(r))return B.get(r);let n=new Intl.Collator(t,e);return B.set(r,n),n}var Z=f.createContext(null),q="react-aria-focus-scope-restore",h=null;function Be(e){let{children:t,contain:r,restoreFocus:n,autoFocus:o}=e,i=(0,f.useRef)(null),l=(0,f.useRef)(null),s=(0,f.useRef)([]),{parentNode:u}=(0,f.useContext)(Z)||{},c=(0,f.useMemo)(()=>new $({scopeRef:s}),[s]);R(()=>{let d=u||b.root;if(b.getTreeNode(d.scopeRef)&&h&&!F(h,d.scopeRef)){let N=b.getTreeNode(h);N&&(d=N)}d.addChild(c),b.addNode(c)},[c,u]),R(()=>{let d=b.getTreeNode(s);d&&(d.contain=!!r)},[r]),R(()=>{var L;let d=(L=i.current)==null?void 0:L.nextSibling,N=[],m=k=>k.stopPropagation();for(;d&&d!==l.current;)N.push(d),d.addEventListener(q,m),d=d.nextSibling;return s.current=N,()=>{for(let k of N)k.removeEventListener(q,m)}},[t]),Je(s,n,r),Ve(s,r),Xe(s,n,r),Ge(s,o),(0,f.useEffect)(()=>{let d=w(v(s.current?s.current[0]:void 0)),N=null;if(g(d,s.current)){for(let m of b.traverse())m.scopeRef&&g(d,m.scopeRef.current)&&(N=m);N===b.getTreeNode(s)&&(h=N.scopeRef)}},[s]),R(()=>()=>{var N,m;let d=((m=(N=b.getTreeNode(s))==null?void 0:N.parent)==null?void 0:m.scopeRef)??null;(s===h||F(s,h))&&(!d||b.getTreeNode(d))&&(h=d),b.removeTreeNode(s)},[s]);let a=(0,f.useMemo)(()=>qe(s),[]),p=(0,f.useMemo)(()=>({focusManager:a,parentNode:c}),[c,a]);return f.createElement(Z.Provider,{value:p},f.createElement("span",{"data-focus-scope-start":!0,hidden:!0,ref:i}),t,f.createElement("span",{"data-focus-scope-end":!0,hidden:!0,ref:l}))}function qe(e){return{focusNext(t={}){let r=e.current,{from:n,tabbable:o,wrap:i,accept:l}=t,s=n||w(v(r[0]??void 0)),u=r[0].previousElementSibling,c=T(y(r),{tabbable:o,accept:l},r);c.currentNode=g(s,r)?s:u;let a=c.nextNode();return!a&&i&&(c.currentNode=u,a=c.nextNode()),a&&E(a,!0),a},focusPrevious(t={}){let r=e.current,{from:n,tabbable:o,wrap:i,accept:l}=t,s=n||w(v(r[0]??void 0)),u=r[r.length-1].nextElementSibling,c=T(y(r),{tabbable:o,accept:l},r);c.currentNode=g(s,r)?s:u;let a=c.previousNode();return!a&&i&&(c.currentNode=u,a=c.previousNode()),a&&E(a,!0),a},focusFirst(t={}){let r=e.current,{tabbable:n,accept:o}=t,i=T(y(r),{tabbable:n,accept:o},r);i.currentNode=r[0].previousElementSibling;let l=i.nextNode();return l&&E(l,!0),l},focusLast(t={}){let r=e.current,{tabbable:n,accept:o}=t,i=T(y(r),{tabbable:n,accept:o},r);i.currentNode=r[r.length-1].nextElementSibling;let l=i.previousNode();return l&&E(l,!0),l}}}function y(e){return e[0].parentElement}function _(e){let t=b.getTreeNode(h);for(;t&&t.scopeRef!==e;){if(t.contain)return!1;t=t.parent}return!0}function Ue(e){var r,n;if(e.checked)return!0;let t=[];return t=e.form?[...((n=(r=e.form)==null?void 0:r.elements)==null?void 0:n.namedItem(e.name))??[]]:[...v(e).querySelectorAll(`input[type="radio"][name="${CSS.escape(e.name)}"]`)].filter(o=>!o.form),t?!t.some(o=>o.checked):!1}function Ve(e,t){let r=(0,f.useRef)(void 0),n=(0,f.useRef)(void 0);R(()=>{let o=e.current;if(!t){n.current&&(n.current=(cancelAnimationFrame(n.current),void 0));return}let i=v(o?o[0]:void 0),l=c=>{if(c.key!=="Tab"||c.altKey||c.ctrlKey||c.metaKey||!_(e)||c.isComposing)return;let a=w(i),p=e.current;if(!p||!g(a,p))return;let d=T(y(p),{tabbable:!0},p);if(!a)return;d.currentNode=a;let N=c.shiftKey?d.previousNode():d.nextNode();N||(N=(d.currentNode=c.shiftKey?p[p.length-1].nextElementSibling:p[0].previousElementSibling,c.shiftKey?d.previousNode():d.nextNode())),c.preventDefault(),N&&E(N,!0)},s=c=>{(!h||F(h,e))&&g(S(c),e.current)?(h=e,r.current=S(c)):_(e)&&!C(S(c),e)?r.current?r.current.focus():h&&h.current&&U(h.current):_(e)&&(r.current=S(c))},u=c=>{n.current&&cancelAnimationFrame(n.current),n.current=requestAnimationFrame(()=>{let a=Te(),p=(a==="virtual"||a===null)&&Se()&&J(),d=w(i);if(!p&&d&&_(e)&&!C(d,e)){h=e;let m=S(c);if(m&&m.isConnected){var N;r.current=m,(N=r.current)==null||N.focus()}else h.current&&U(h.current)}})};return i.addEventListener("keydown",l,!1),i.addEventListener("focusin",s,!1),o==null||o.forEach(c=>c.addEventListener("focusin",s,!1)),o==null||o.forEach(c=>c.addEventListener("focusout",u,!1)),()=>{i.removeEventListener("keydown",l,!1),i.removeEventListener("focusin",s,!1),o==null||o.forEach(c=>c.removeEventListener("focusin",s,!1)),o==null||o.forEach(c=>c.removeEventListener("focusout",u,!1))}},[e,t]),R(()=>()=>{n.current&&cancelAnimationFrame(n.current)},[n])}function ee(e){return C(e)}function g(e,t){return!e||!t?!1:t.some(r=>r.contains(e))}function C(e,t=null){if(e instanceof Element&&e.closest("[data-react-aria-top-layer]"))return!0;for(let{scopeRef:r}of b.traverse(b.getTreeNode(t)))if(r&&g(e,r.current))return!0;return!1}function $e(e){return C(e,h)}function F(e,t){var n;let r=(n=b.getTreeNode(t))==null?void 0:n.parent;for(;r;){if(r.scopeRef===e)return!0;r=r.parent}return!1}function E(e,t=!1){if(e!=null&&!t)try{ve(e)}catch{}else if(e!=null)try{e.focus()}catch{}}function te(e,t=!0){let r=e[0].previousElementSibling,n=y(e),o=T(n,{tabbable:t},e);o.currentNode=r;let i=o.nextNode();return t&&!i&&(n=y(e),o=T(n,{tabbable:!1},e),o.currentNode=r,i=o.nextNode()),i}function U(e,t=!0){E(te(e,t))}function Ge(e,t){let r=f.useRef(t);(0,f.useEffect)(()=>{r.current&&(h=e,!g(w(v(e.current?e.current[0]:void 0)),h.current)&&e.current&&U(e.current)),r.current=!1},[e])}function Je(e,t,r){R(()=>{if(t||r)return;let n=e.current,o=v(n?n[0]:void 0),i=l=>{let s=S(l);g(s,e.current)?h=e:ee(s)||(h=null)};return o.addEventListener("focusin",i,!1),n==null||n.forEach(l=>l.addEventListener("focusin",i,!1)),()=>{o.removeEventListener("focusin",i,!1),n==null||n.forEach(l=>l.removeEventListener("focusin",i,!1))}},[e,t,r])}function re(e){let t=b.getTreeNode(h);for(;t&&t.scopeRef!==e;){if(t.nodeToRestore)return!1;t=t.parent}return(t==null?void 0:t.scopeRef)===e}function Xe(e,t,r){let n=(0,f.useRef)(typeof document<"u"?w(v(e.current?e.current[0]:void 0)):null);R(()=>{let o=e.current,i=v(o?o[0]:void 0);if(!t||r)return;let l=()=>{(!h||F(h,e))&&g(w(i),e.current)&&(h=e)};return i.addEventListener("focusin",l,!1),o==null||o.forEach(s=>s.addEventListener("focusin",l,!1)),()=>{i.removeEventListener("focusin",l,!1),o==null||o.forEach(s=>s.removeEventListener("focusin",l,!1))}},[e,r]),R(()=>{let o=v(e.current?e.current[0]:void 0);if(!t)return;let i=l=>{if(l.key!=="Tab"||l.altKey||l.ctrlKey||l.metaKey||!_(e)||l.isComposing)return;let s=o.activeElement;if(!C(s,e)||!re(e))return;let u=b.getTreeNode(e);if(!u)return;let c=u.nodeToRestore,a=T(o.body,{tabbable:!0});a.currentNode=s;let p=l.shiftKey?a.previousNode():a.nextNode();if((!c||!c.isConnected||c===o.body)&&(c=void 0,u.nodeToRestore=void 0),(!p||!C(p,e))&&c){a.currentNode=c;do p=l.shiftKey?a.previousNode():a.nextNode();while(C(p,e));l.preventDefault(),l.stopPropagation(),p?E(p,!0):ee(c)?E(c,!0):s.blur()}};return r||o.addEventListener("keydown",i,!0),()=>{r||o.removeEventListener("keydown",i,!0)}},[e,t,r]),R(()=>{let o=v(e.current?e.current[0]:void 0);if(!t)return;let i=b.getTreeNode(e);if(i)return i.nodeToRestore=n.current??void 0,()=>{let l=b.getTreeNode(e);if(!l)return;let s=l.nodeToRestore,u=w(o);if(t&&s&&(u&&C(u,e)||u===o.body&&re(e))){let c=b.clone();requestAnimationFrame(()=>{if(o.activeElement===o.body){let a=c.getTreeNode(e);for(;a;){if(a.nodeToRestore&&a.nodeToRestore.isConnected){ne(a.nodeToRestore);return}a=a.parent}for(a=c.getTreeNode(e);a;){if(a.scopeRef&&a.scopeRef.current&&b.getTreeNode(a.scopeRef)){ne(te(a.scopeRef.current,!0));return}a=a.parent}}})}}},[e,t])}function ne(e){e.dispatchEvent(new CustomEvent(q,{bubbles:!0,cancelable:!0}))&&E(e)}function T(e,t,r){let n=t!=null&&t.tabbable?ye:Ce,o=v((e==null?void 0:e.nodeType)===Node.ELEMENT_NODE?e:null),i=Me(o,e||o,NodeFilter.SHOW_ELEMENT,{acceptNode(l){var s;return t!=null&&((s=t.from)!=null&&s.contains(l))||t!=null&&t.tabbable&&l.tagName==="INPUT"&&l.getAttribute("type")==="radio"&&(!Ue(l)||i.currentNode.tagName==="INPUT"&&i.currentNode.type==="radio"&&i.currentNode.name===l.name)?NodeFilter.FILTER_REJECT:n(l)&&(!r||g(l,r))&&(!(t!=null&&t.accept)||t.accept(l))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});return t!=null&&t.from&&(i.currentNode=t.from),i}function Ye(e,t={}){return{focusNext(r={}){let n=e.current;if(!n)return null;let{from:o,tabbable:i=t.tabbable,wrap:l=t.wrap,accept:s=t.accept}=r,u=o||w(v(n)),c=T(n,{tabbable:i,accept:s});n.contains(u)&&(c.currentNode=u);let a=c.nextNode();return!a&&l&&(c.currentNode=n,a=c.nextNode()),a&&E(a,!0),a},focusPrevious(r=t){let n=e.current;if(!n)return null;let{from:o,tabbable:i=t.tabbable,wrap:l=t.wrap,accept:s=t.accept}=r,u=o||w(v(n)),c=T(n,{tabbable:i,accept:s});if(n.contains(u))c.currentNode=u;else{let p=V(c);return p&&E(p,!0),p??null}let a=c.previousNode();if(!a&&l){c.currentNode=n;let p=V(c);if(!p)return null;a=p}return a&&E(a,!0),a??null},focusFirst(r=t){let n=e.current;if(!n)return null;let{tabbable:o=t.tabbable,accept:i=t.accept}=r,l=T(n,{tabbable:o,accept:i}).nextNode();return l&&E(l,!0),l},focusLast(r=t){let n=e.current;if(!n)return null;let{tabbable:o=t.tabbable,accept:i=t.accept}=r,l=V(T(n,{tabbable:o,accept:i}));return l&&E(l,!0),l??null}}}function V(e){let t,r;do r=e.lastChild(),r&&(t=r);while(r);return t}var Qe=class le{get size(){return this.fastMap.size}getTreeNode(t){return this.fastMap.get(t)}addTreeNode(t,r,n){let o=this.fastMap.get(r??null);if(!o)return;let i=new $({scopeRef:t});o.addChild(i),i.parent=o,this.fastMap.set(t,i),n&&(i.nodeToRestore=n)}addNode(t){this.fastMap.set(t.scopeRef,t)}removeTreeNode(t){if(t===null)return;let r=this.fastMap.get(t);if(!r)return;let n=r.parent;for(let i of this.traverse())i!==r&&r.nodeToRestore&&i.nodeToRestore&&r.scopeRef&&r.scopeRef.current&&g(i.nodeToRestore,r.scopeRef.current)&&(i.nodeToRestore=r.nodeToRestore);let o=r.children;n&&(n.removeChild(r),o.size>0&&o.forEach(i=>n&&n.addChild(i))),this.fastMap.delete(r.scopeRef)}*traverse(t=this.root){if(t.scopeRef!=null&&(yield t),t.children.size>0)for(let r of t.children)yield*this.traverse(r)}clone(){var r;let t=new le;for(let n of this.traverse())t.addTreeNode(n.scopeRef,((r=n.parent)==null?void 0:r.scopeRef)??null,n.nodeToRestore);return t}constructor(){this.fastMap=new Map,this.root=new $({scopeRef:null}),this.fastMap.set(null,this.root)}},$=class{addChild(e){this.children.add(e),e.parent=this}removeChild(e){this.children.delete(e),e.parent=void 0}constructor(e){this.children=new Set,this.contain=!1,this.scopeRef=e.scopeRef}},b=new Qe,oe={border:0,clip:"rect(0 0 0 0)",clipPath:"inset(50%)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap"};function ie(e={}){let{style:t,isFocusable:r}=e,[n,o]=(0,f.useState)(!1),{focusWithinProps:i}=Ee({isDisabled:!r,onFocusWithinChange:s=>o(s)}),l=(0,f.useMemo)(()=>n?t:t?{...oe,...t}:oe,[n]);return{visuallyHiddenProps:{...i,style:l}}}function Ze(e){let{children:t,elementType:r="div",isFocusable:n,style:o,...i}=e,{visuallyHiddenProps:l}=ie(e);return f.createElement(r,Re(i,l),t)}export{xe as _,T as a,Y as c,We as d,He as f,_e as g,Ie as h,Be as i,je as l,x as m,ie as n,Ye as o,Pe as p,$e as r,ze as s,Ze as t,De as u,Le as v};
|
|
1
|
+
import{s as be}from"./chunk-LvLJmgfZ.js";import{t as me}from"./react-BGmjiNul.js";import{L as ve,P as Ee,R as Te}from"./input-CaEtLL8p.js";import{A as w,C as ge,M as we,N as v,O as Re,b as J,c as Ce,j as S,k as X,l as ye,w as Se,z as R}from"./usePress-C2LPFxyv.js";import{t as ke}from"./context-BAYdLMF_.js";var f=be(me(),1),_e=(0,f.createContext)(null);(0,f.createContext)(null),(0,f.createContext)(null),(0,f.createContext)(null),(0,f.createContext)(null);var Le=(0,f.createContext)({}),xe=(0,f.createContext)(null);(0,f.createContext)(null);var Fe=class{get currentNode(){return this._currentNode}set currentNode(e){if(!X(this.root,e))throw Error("Cannot set currentNode to a node that is not contained by the root node.");let t=[],r=e,n=e;for(this._currentNode=e;r&&r!==this.root;)if(r.nodeType===Node.DOCUMENT_FRAGMENT_NODE){let i=r,l=this._doc.createTreeWalker(i,this.whatToShow,{acceptNode:this._acceptNode});t.push(l),l.currentNode=n,this._currentSetFor.add(l),r=n=i.host}else r=r.parentNode;let o=this._doc.createTreeWalker(this.root,this.whatToShow,{acceptNode:this._acceptNode});t.push(o),o.currentNode=n,this._currentSetFor.add(o),this._walkerStack=t}get doc(){return this._doc}firstChild(){let e=this.currentNode,t=this.nextNode();return X(e,t)?(t&&(this.currentNode=t),t):(this.currentNode=e,null)}lastChild(){let e=this._walkerStack[0].lastChild();return e&&(this.currentNode=e),e}nextNode(){var t;let e=this._walkerStack[0].nextNode();if(e){if(e.shadowRoot){let r;if(typeof this.filter=="function"?r=this.filter(e):(t=this.filter)!=null&&t.acceptNode&&(r=this.filter.acceptNode(e)),r===NodeFilter.FILTER_ACCEPT)return this.currentNode=e,e;let n=this.nextNode();return n&&(this.currentNode=n),n}return e&&(this.currentNode=e),e}else if(this._walkerStack.length>1){this._walkerStack.shift();let r=this.nextNode();return r&&(this.currentNode=r),r}else return null}previousNode(){var r;let e=this._walkerStack[0];if(e.currentNode===e.root){if(this._currentSetFor.has(e))if(this._currentSetFor.delete(e),this._walkerStack.length>1){this._walkerStack.shift();let n=this.previousNode();return n&&(this.currentNode=n),n}else return null;return null}let t=e.previousNode();if(t){if(t.shadowRoot){let n;if(typeof this.filter=="function"?n=this.filter(t):(r=this.filter)!=null&&r.acceptNode&&(n=this.filter.acceptNode(t)),n===NodeFilter.FILTER_ACCEPT)return t&&(this.currentNode=t),t;let o=this.lastChild();return o&&(this.currentNode=o),o}return t&&(this.currentNode=t),t}else if(this._walkerStack.length>1){this._walkerStack.shift();let n=this.previousNode();return n&&(this.currentNode=n),n}else return null}nextSibling(){return null}previousSibling(){return null}parentNode(){return null}constructor(e,t,r,n){this._walkerStack=[],this._currentSetFor=new Set,this._acceptNode=i=>{var l;if(i.nodeType===Node.ELEMENT_NODE){let s=i.shadowRoot;if(s){let u=this._doc.createTreeWalker(s,this.whatToShow,{acceptNode:this._acceptNode});return this._walkerStack.unshift(u),NodeFilter.FILTER_ACCEPT}else{if(typeof this.filter=="function")return this.filter(i);if((l=this.filter)!=null&&l.acceptNode)return this.filter.acceptNode(i);if(this.filter===null)return NodeFilter.FILTER_ACCEPT}}return NodeFilter.FILTER_SKIP},this._doc=e,this.root=t,this.filter=n??null,this.whatToShow=r??NodeFilter.SHOW_ALL,this._currentNode=t,this._walkerStack.unshift(e.createTreeWalker(t,r,this._acceptNode));let o=t.shadowRoot;if(o){let i=this._doc.createTreeWalker(o,this.whatToShow,{acceptNode:this._acceptNode});this._walkerStack.unshift(i)}}};function Me(e,t,r,n){return we()?new Fe(e,t,r,n):e.createTreeWalker(t,r,n)}function Ie(e,t){let r=(0,f.useRef)(!0),n=(0,f.useRef)(null);(0,f.useEffect)(()=>(r.current=!0,()=>{r.current=!1}),[]),(0,f.useEffect)(()=>{let o=n.current;r.current?r.current=!1:(!o||t.some((i,l)=>!Object.is(i,o[l])))&&e(),n.current=t},t)}function x(e,t){if(!e)return!1;let r=window.getComputedStyle(e),n=/(auto|scroll)/.test(r.overflow+r.overflowX+r.overflowY);return n&&t&&(n=e.scrollHeight!==e.clientHeight||e.scrollWidth!==e.clientWidth),n}function Pe(e,t){let r=e;for(x(r,t)&&(r=r.parentElement);r&&!x(r,t);)r=r.parentElement;return r||document.scrollingElement||document.documentElement}function Ae(e,t){let r=[];for(;e&&e!==document.documentElement;)x(e,t)&&r.push(e),e=e.parentElement;return r}function We(e){return ge()?e.metaKey:e.ctrlKey}var Ke=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function He(e){return e instanceof HTMLInputElement&&!Ke.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}var Oe=0,z=new Map;function De(e){let[t,r]=(0,f.useState)();return R(()=>{if(!e)return;let n=z.get(e);if(n)r(n.element.id);else{let o=`react-aria-description-${Oe++}`;r(o);let i=document.createElement("div");i.id=o,i.style.display="none",i.textContent=e,document.body.appendChild(i),n={refCount:0,element:i},z.set(e,n)}return n.refCount++,()=>{n&&--n.refCount===0&&(n.element.remove(),z.delete(e))}},[e]),{"aria-describedby":e?t:void 0}}function Y(e,t){let r=Q(e,t,"left"),n=Q(e,t,"top"),o=t.offsetWidth,i=t.offsetHeight,l=e.scrollLeft,s=e.scrollTop,{borderTopWidth:u,borderLeftWidth:c,scrollPaddingTop:a,scrollPaddingRight:p,scrollPaddingBottom:d,scrollPaddingLeft:N}=getComputedStyle(e),{scrollMarginTop:m,scrollMarginRight:L,scrollMarginBottom:k,scrollMarginLeft:ce}=getComputedStyle(t),se=l+parseInt(c,10),G=s+parseInt(u,10),M=se+e.clientWidth,I=G+e.clientHeight,P=parseInt(a,10)||0,A=parseInt(d,10)||0,W=parseInt(p,10)||0,K=parseInt(N,10)||0,ae=parseInt(m,10)||0,ue=parseInt(k,10)||0,de=parseInt(L,10)||0,H=r-(parseInt(ce,10)||0),O=r+o+de,D=n-ae,j=n+i+ue,fe=l+parseInt(c,10)+K,pe=M-W,he=s+parseInt(u,10)+P,Ne=I-A;(H>fe||O<pe)&&(H<=l+K?l=H-parseInt(c,10)-K:O>M-W&&(l+=O-M+W)),(D>he||j<Ne)&&(D<=G+P?s=D-parseInt(u,10)-P:j>I-A&&(s+=j-I+A)),e.scrollTo({left:l,top:s})}function Q(e,t,r){let n=r==="left"?"offsetLeft":"offsetTop",o=0;for(;t.offsetParent&&(o+=t[n],t.offsetParent!==e);){if(t.offsetParent.contains(e)){o-=e[n];break}t=t.offsetParent}return o}function je(e,t){if(e&&document.contains(e)){let l=document.scrollingElement||document.documentElement;if(window.getComputedStyle(l).overflow!=="hidden"&&!J()){var r;let{left:s,top:u}=e.getBoundingClientRect();e==null||(r=e.scrollIntoView)==null||r.call(e,{block:"nearest"});let{left:c,top:a}=e.getBoundingClientRect();if(Math.abs(s-c)>1||Math.abs(u-a)>1){var n,o,i;t==null||(o=t.containingElement)==null||(n=o.scrollIntoView)==null||n.call(o,{block:"center",inline:"center"}),(i=e.scrollIntoView)==null||i.call(e,{block:"nearest"})}}else{let s=Ae(e);for(let u of s)Y(u,e)}}}var B=new Map;function ze(e){let{locale:t}=ke(),r=t+(e?Object.entries(e).sort((o,i)=>o[0]<i[0]?-1:1).join():"");if(B.has(r))return B.get(r);let n=new Intl.Collator(t,e);return B.set(r,n),n}var Z=f.createContext(null),q="react-aria-focus-scope-restore",h=null;function Be(e){let{children:t,contain:r,restoreFocus:n,autoFocus:o}=e,i=(0,f.useRef)(null),l=(0,f.useRef)(null),s=(0,f.useRef)([]),{parentNode:u}=(0,f.useContext)(Z)||{},c=(0,f.useMemo)(()=>new $({scopeRef:s}),[s]);R(()=>{let d=u||b.root;if(b.getTreeNode(d.scopeRef)&&h&&!F(h,d.scopeRef)){let N=b.getTreeNode(h);N&&(d=N)}d.addChild(c),b.addNode(c)},[c,u]),R(()=>{let d=b.getTreeNode(s);d&&(d.contain=!!r)},[r]),R(()=>{var L;let d=(L=i.current)==null?void 0:L.nextSibling,N=[],m=k=>k.stopPropagation();for(;d&&d!==l.current;)N.push(d),d.addEventListener(q,m),d=d.nextSibling;return s.current=N,()=>{for(let k of N)k.removeEventListener(q,m)}},[t]),Je(s,n,r),Ve(s,r),Xe(s,n,r),Ge(s,o),(0,f.useEffect)(()=>{let d=w(v(s.current?s.current[0]:void 0)),N=null;if(g(d,s.current)){for(let m of b.traverse())m.scopeRef&&g(d,m.scopeRef.current)&&(N=m);N===b.getTreeNode(s)&&(h=N.scopeRef)}},[s]),R(()=>()=>{var N,m;let d=((m=(N=b.getTreeNode(s))==null?void 0:N.parent)==null?void 0:m.scopeRef)??null;(s===h||F(s,h))&&(!d||b.getTreeNode(d))&&(h=d),b.removeTreeNode(s)},[s]);let a=(0,f.useMemo)(()=>qe(s),[]),p=(0,f.useMemo)(()=>({focusManager:a,parentNode:c}),[c,a]);return f.createElement(Z.Provider,{value:p},f.createElement("span",{"data-focus-scope-start":!0,hidden:!0,ref:i}),t,f.createElement("span",{"data-focus-scope-end":!0,hidden:!0,ref:l}))}function qe(e){return{focusNext(t={}){let r=e.current,{from:n,tabbable:o,wrap:i,accept:l}=t,s=n||w(v(r[0]??void 0)),u=r[0].previousElementSibling,c=T(y(r),{tabbable:o,accept:l},r);c.currentNode=g(s,r)?s:u;let a=c.nextNode();return!a&&i&&(c.currentNode=u,a=c.nextNode()),a&&E(a,!0),a},focusPrevious(t={}){let r=e.current,{from:n,tabbable:o,wrap:i,accept:l}=t,s=n||w(v(r[0]??void 0)),u=r[r.length-1].nextElementSibling,c=T(y(r),{tabbable:o,accept:l},r);c.currentNode=g(s,r)?s:u;let a=c.previousNode();return!a&&i&&(c.currentNode=u,a=c.previousNode()),a&&E(a,!0),a},focusFirst(t={}){let r=e.current,{tabbable:n,accept:o}=t,i=T(y(r),{tabbable:n,accept:o},r);i.currentNode=r[0].previousElementSibling;let l=i.nextNode();return l&&E(l,!0),l},focusLast(t={}){let r=e.current,{tabbable:n,accept:o}=t,i=T(y(r),{tabbable:n,accept:o},r);i.currentNode=r[r.length-1].nextElementSibling;let l=i.previousNode();return l&&E(l,!0),l}}}function y(e){return e[0].parentElement}function _(e){let t=b.getTreeNode(h);for(;t&&t.scopeRef!==e;){if(t.contain)return!1;t=t.parent}return!0}function Ue(e){var r,n;if(e.checked)return!0;let t=[];return t=e.form?[...((n=(r=e.form)==null?void 0:r.elements)==null?void 0:n.namedItem(e.name))??[]]:[...v(e).querySelectorAll(`input[type="radio"][name="${CSS.escape(e.name)}"]`)].filter(o=>!o.form),t?!t.some(o=>o.checked):!1}function Ve(e,t){let r=(0,f.useRef)(void 0),n=(0,f.useRef)(void 0);R(()=>{let o=e.current;if(!t){n.current&&(n.current=(cancelAnimationFrame(n.current),void 0));return}let i=v(o?o[0]:void 0),l=c=>{if(c.key!=="Tab"||c.altKey||c.ctrlKey||c.metaKey||!_(e)||c.isComposing)return;let a=w(i),p=e.current;if(!p||!g(a,p))return;let d=T(y(p),{tabbable:!0},p);if(!a)return;d.currentNode=a;let N=c.shiftKey?d.previousNode():d.nextNode();N||(N=(d.currentNode=c.shiftKey?p[p.length-1].nextElementSibling:p[0].previousElementSibling,c.shiftKey?d.previousNode():d.nextNode())),c.preventDefault(),N&&E(N,!0)},s=c=>{(!h||F(h,e))&&g(S(c),e.current)?(h=e,r.current=S(c)):_(e)&&!C(S(c),e)?r.current?r.current.focus():h&&h.current&&U(h.current):_(e)&&(r.current=S(c))},u=c=>{n.current&&cancelAnimationFrame(n.current),n.current=requestAnimationFrame(()=>{let a=Te(),p=(a==="virtual"||a===null)&&Se()&&J(),d=w(i);if(!p&&d&&_(e)&&!C(d,e)){h=e;let m=S(c);if(m&&m.isConnected){var N;r.current=m,(N=r.current)==null||N.focus()}else h.current&&U(h.current)}})};return i.addEventListener("keydown",l,!1),i.addEventListener("focusin",s,!1),o==null||o.forEach(c=>c.addEventListener("focusin",s,!1)),o==null||o.forEach(c=>c.addEventListener("focusout",u,!1)),()=>{i.removeEventListener("keydown",l,!1),i.removeEventListener("focusin",s,!1),o==null||o.forEach(c=>c.removeEventListener("focusin",s,!1)),o==null||o.forEach(c=>c.removeEventListener("focusout",u,!1))}},[e,t]),R(()=>()=>{n.current&&cancelAnimationFrame(n.current)},[n])}function ee(e){return C(e)}function g(e,t){return!e||!t?!1:t.some(r=>r.contains(e))}function C(e,t=null){if(e instanceof Element&&e.closest("[data-react-aria-top-layer]"))return!0;for(let{scopeRef:r}of b.traverse(b.getTreeNode(t)))if(r&&g(e,r.current))return!0;return!1}function $e(e){return C(e,h)}function F(e,t){var n;let r=(n=b.getTreeNode(t))==null?void 0:n.parent;for(;r;){if(r.scopeRef===e)return!0;r=r.parent}return!1}function E(e,t=!1){if(e!=null&&!t)try{ve(e)}catch{}else if(e!=null)try{e.focus()}catch{}}function te(e,t=!0){let r=e[0].previousElementSibling,n=y(e),o=T(n,{tabbable:t},e);o.currentNode=r;let i=o.nextNode();return t&&!i&&(n=y(e),o=T(n,{tabbable:!1},e),o.currentNode=r,i=o.nextNode()),i}function U(e,t=!0){E(te(e,t))}function Ge(e,t){let r=f.useRef(t);(0,f.useEffect)(()=>{r.current&&(h=e,!g(w(v(e.current?e.current[0]:void 0)),h.current)&&e.current&&U(e.current)),r.current=!1},[e])}function Je(e,t,r){R(()=>{if(t||r)return;let n=e.current,o=v(n?n[0]:void 0),i=l=>{let s=S(l);g(s,e.current)?h=e:ee(s)||(h=null)};return o.addEventListener("focusin",i,!1),n==null||n.forEach(l=>l.addEventListener("focusin",i,!1)),()=>{o.removeEventListener("focusin",i,!1),n==null||n.forEach(l=>l.removeEventListener("focusin",i,!1))}},[e,t,r])}function re(e){let t=b.getTreeNode(h);for(;t&&t.scopeRef!==e;){if(t.nodeToRestore)return!1;t=t.parent}return(t==null?void 0:t.scopeRef)===e}function Xe(e,t,r){let n=(0,f.useRef)(typeof document<"u"?w(v(e.current?e.current[0]:void 0)):null);R(()=>{let o=e.current,i=v(o?o[0]:void 0);if(!t||r)return;let l=()=>{(!h||F(h,e))&&g(w(i),e.current)&&(h=e)};return i.addEventListener("focusin",l,!1),o==null||o.forEach(s=>s.addEventListener("focusin",l,!1)),()=>{i.removeEventListener("focusin",l,!1),o==null||o.forEach(s=>s.removeEventListener("focusin",l,!1))}},[e,r]),R(()=>{let o=v(e.current?e.current[0]:void 0);if(!t)return;let i=l=>{if(l.key!=="Tab"||l.altKey||l.ctrlKey||l.metaKey||!_(e)||l.isComposing)return;let s=o.activeElement;if(!C(s,e)||!re(e))return;let u=b.getTreeNode(e);if(!u)return;let c=u.nodeToRestore,a=T(o.body,{tabbable:!0});a.currentNode=s;let p=l.shiftKey?a.previousNode():a.nextNode();if((!c||!c.isConnected||c===o.body)&&(c=void 0,u.nodeToRestore=void 0),(!p||!C(p,e))&&c){a.currentNode=c;do p=l.shiftKey?a.previousNode():a.nextNode();while(C(p,e));l.preventDefault(),l.stopPropagation(),p?E(p,!0):ee(c)?E(c,!0):s.blur()}};return r||o.addEventListener("keydown",i,!0),()=>{r||o.removeEventListener("keydown",i,!0)}},[e,t,r]),R(()=>{let o=v(e.current?e.current[0]:void 0);if(!t)return;let i=b.getTreeNode(e);if(i)return i.nodeToRestore=n.current??void 0,()=>{let l=b.getTreeNode(e);if(!l)return;let s=l.nodeToRestore,u=w(o);if(t&&s&&(u&&C(u,e)||u===o.body&&re(e))){let c=b.clone();requestAnimationFrame(()=>{if(o.activeElement===o.body){let a=c.getTreeNode(e);for(;a;){if(a.nodeToRestore&&a.nodeToRestore.isConnected){ne(a.nodeToRestore);return}a=a.parent}for(a=c.getTreeNode(e);a;){if(a.scopeRef&&a.scopeRef.current&&b.getTreeNode(a.scopeRef)){ne(te(a.scopeRef.current,!0));return}a=a.parent}}})}}},[e,t])}function ne(e){e.dispatchEvent(new CustomEvent(q,{bubbles:!0,cancelable:!0}))&&E(e)}function T(e,t,r){let n=t!=null&&t.tabbable?ye:Ce,o=v((e==null?void 0:e.nodeType)===Node.ELEMENT_NODE?e:null),i=Me(o,e||o,NodeFilter.SHOW_ELEMENT,{acceptNode(l){var s;return t!=null&&((s=t.from)!=null&&s.contains(l))||t!=null&&t.tabbable&&l.tagName==="INPUT"&&l.getAttribute("type")==="radio"&&(!Ue(l)||i.currentNode.tagName==="INPUT"&&i.currentNode.type==="radio"&&i.currentNode.name===l.name)?NodeFilter.FILTER_REJECT:n(l)&&(!r||g(l,r))&&(!(t!=null&&t.accept)||t.accept(l))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});return t!=null&&t.from&&(i.currentNode=t.from),i}function Ye(e,t={}){return{focusNext(r={}){let n=e.current;if(!n)return null;let{from:o,tabbable:i=t.tabbable,wrap:l=t.wrap,accept:s=t.accept}=r,u=o||w(v(n)),c=T(n,{tabbable:i,accept:s});n.contains(u)&&(c.currentNode=u);let a=c.nextNode();return!a&&l&&(c.currentNode=n,a=c.nextNode()),a&&E(a,!0),a},focusPrevious(r=t){let n=e.current;if(!n)return null;let{from:o,tabbable:i=t.tabbable,wrap:l=t.wrap,accept:s=t.accept}=r,u=o||w(v(n)),c=T(n,{tabbable:i,accept:s});if(n.contains(u))c.currentNode=u;else{let p=V(c);return p&&E(p,!0),p??null}let a=c.previousNode();if(!a&&l){c.currentNode=n;let p=V(c);if(!p)return null;a=p}return a&&E(a,!0),a??null},focusFirst(r=t){let n=e.current;if(!n)return null;let{tabbable:o=t.tabbable,accept:i=t.accept}=r,l=T(n,{tabbable:o,accept:i}).nextNode();return l&&E(l,!0),l},focusLast(r=t){let n=e.current;if(!n)return null;let{tabbable:o=t.tabbable,accept:i=t.accept}=r,l=V(T(n,{tabbable:o,accept:i}));return l&&E(l,!0),l??null}}}function V(e){let t,r;do r=e.lastChild(),r&&(t=r);while(r);return t}var Qe=class le{get size(){return this.fastMap.size}getTreeNode(t){return this.fastMap.get(t)}addTreeNode(t,r,n){let o=this.fastMap.get(r??null);if(!o)return;let i=new $({scopeRef:t});o.addChild(i),i.parent=o,this.fastMap.set(t,i),n&&(i.nodeToRestore=n)}addNode(t){this.fastMap.set(t.scopeRef,t)}removeTreeNode(t){if(t===null)return;let r=this.fastMap.get(t);if(!r)return;let n=r.parent;for(let i of this.traverse())i!==r&&r.nodeToRestore&&i.nodeToRestore&&r.scopeRef&&r.scopeRef.current&&g(i.nodeToRestore,r.scopeRef.current)&&(i.nodeToRestore=r.nodeToRestore);let o=r.children;n&&(n.removeChild(r),o.size>0&&o.forEach(i=>n&&n.addChild(i))),this.fastMap.delete(r.scopeRef)}*traverse(t=this.root){if(t.scopeRef!=null&&(yield t),t.children.size>0)for(let r of t.children)yield*this.traverse(r)}clone(){var r;let t=new le;for(let n of this.traverse())t.addTreeNode(n.scopeRef,((r=n.parent)==null?void 0:r.scopeRef)??null,n.nodeToRestore);return t}constructor(){this.fastMap=new Map,this.root=new $({scopeRef:null}),this.fastMap.set(null,this.root)}},$=class{addChild(e){this.children.add(e),e.parent=this}removeChild(e){this.children.delete(e),e.parent=void 0}constructor(e){this.children=new Set,this.contain=!1,this.scopeRef=e.scopeRef}},b=new Qe,oe={border:0,clip:"rect(0 0 0 0)",clipPath:"inset(50%)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap"};function ie(e={}){let{style:t,isFocusable:r}=e,[n,o]=(0,f.useState)(!1),{focusWithinProps:i}=Ee({isDisabled:!r,onFocusWithinChange:s=>o(s)}),l=(0,f.useMemo)(()=>n?t:t?{...oe,...t}:oe,[n]);return{visuallyHiddenProps:{...i,style:l}}}function Ze(e){let{children:t,elementType:r="div",isFocusable:n,style:o,...i}=e,{visuallyHiddenProps:l}=ie(e);return f.createElement(r,Re(i,l),t)}export{xe as _,T as a,Y as c,We as d,He as f,_e as g,Ie as h,Be as i,je as l,x as m,ie as n,Ye as o,Pe as p,$e as r,ze as s,Ze as t,De as u,Le as v};
|