@malloy-publisher/sdk 0.9.7 → 0.9.8
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/README.md +117 -17
- package/dist/{RenderedResult-qnpbr4tc.cjs.js → RenderedResult-BrvrMDAP.cjs.js} +1 -1
- package/dist/{RenderedResult-CkUS04tl.es.js → RenderedResult-DZj-FnOJ.es.js} +2 -2
- package/dist/{ServerProvider-DnLLeXEX.es.js → ServerProvider-B_bPAsu2.es.js} +583 -398
- package/dist/ServerProvider-DuEOzwPc.cjs.js +1 -0
- package/dist/builder/index.cjs.js +93 -93
- package/dist/builder/index.es.js +4630 -4562
- package/dist/builder-entry.d.ts +13 -12
- package/dist/client/api.d.ts +472 -94
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +105 -95
- package/dist/components/Dashboard/DashboardTile.d.ts +3 -1
- package/dist/components/Dashboard/DashboardView.d.ts +1 -3
- package/dist/components/Dashboard/index.d.ts +0 -2
- package/dist/components/DocumentCreate/createDocument.d.ts +29 -9
- package/dist/components/DocumentCreate/documentPath.d.ts +21 -6
- package/dist/components/DocumentCreate/guards.d.ts +2 -3
- package/dist/components/DocumentCreate/index.d.ts +2 -3
- package/dist/components/DocumentCreate/newNotebook.d.ts +14 -5
- package/dist/components/DocumentStorage/BrowserDocumentStorage.d.ts +6 -0
- package/dist/components/DocumentStorage/DocumentStorage.d.ts +52 -24
- package/dist/components/Loading.d.ts +1 -1
- package/dist/components/Package/DataSchemaDialog.d.ts +26 -0
- package/dist/components/Package/NewDocumentDialog.d.ts +19 -10
- package/dist/components/Package/Package.d.ts +14 -9
- package/dist/components/Package/documentLocation.d.ts +66 -23
- package/dist/components/Package/index.d.ts +3 -2
- package/dist/components/Package/reportQueries.d.ts +8 -0
- package/dist/components/Package/useDocumentLocation.d.ts +36 -6
- package/dist/components/Package/useDraftLayout.d.ts +20 -0
- package/dist/components/Report/CellReport.d.ts +89 -0
- package/dist/components/Report/LinearReport.d.ts +18 -0
- package/dist/components/Report/Report.d.ts +62 -0
- package/dist/components/Report/index.d.ts +2 -0
- package/dist/components/Report/telemetry.d.ts +163 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderDialogs.d.ts +2 -2
- package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderGrid.d.ts +2 -2
- package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderHeader.d.ts +5 -4
- package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderToolbar.d.ts +5 -1
- package/dist/components/{DashboardBuilder → ReportBuilder}/EditorSurface.d.ts +10 -7
- package/dist/components/{DashboardBuilder/DashboardBuilder.d.ts → ReportBuilder/ReportBuilder.d.ts} +17 -8
- package/dist/components/{DashboardBuilder/DashboardEditor.d.ts → ReportBuilder/ReportEditor.d.ts} +41 -14
- package/dist/components/ReportBuilder/builderReport.d.ts +14 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/catalog.d.ts +8 -5
- package/dist/components/{DashboardBuilder → ReportBuilder}/document.d.ts +3 -4
- package/dist/components/{DashboardBuilder → ReportBuilder}/documentSession.d.ts +1 -1
- package/dist/components/{DashboardBuilder → ReportBuilder}/imports.d.ts +5 -1
- package/dist/components/{DashboardBuilder → ReportBuilder}/malloyTree.d.ts +9 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/newDashboard.d.ts +7 -1
- package/dist/components/{DashboardBuilder → ReportBuilder}/readDocument.d.ts +7 -5
- package/dist/components/{DashboardBuilder → ReportBuilder}/readForEditor.d.ts +1 -1
- package/dist/components/ReportBuilder/reportTag.d.ts +52 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/spliceDocument.d.ts +1 -7
- package/dist/components/{DashboardBuilder → ReportBuilder}/useBuilderSelection.d.ts +2 -2
- package/dist/components/{DashboardBuilder → ReportBuilder}/useControlBindings.d.ts +2 -2
- package/dist/components/ReportBuilder/useEditorCatalog.d.ts +25 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/useHostCopy.d.ts +5 -3
- package/dist/components/{DashboardBuilder → ReportBuilder}/useOpenedDocument.d.ts +7 -5
- package/dist/components/{DashboardBuilder/useDashboardEditor.d.ts → ReportBuilder/useReportEditor.d.ts} +3 -7
- package/dist/components/{DashboardBuilder → ReportBuilder}/useSaveChannel.d.ts +6 -4
- package/dist/components/{DashboardBuilder → ReportBuilder}/useTileEditing.d.ts +2 -2
- package/dist/components/ServerProvider.d.ts +2 -1
- package/dist/components/drill/resolveDrill.d.ts +8 -1
- package/dist/components/drill/useDrillSelf.d.ts +4 -2
- package/dist/components/index.d.ts +2 -1
- package/dist/components/{Dashboard → legacy}/Dashboard.d.ts +15 -9
- package/dist/components/legacy/MalloynbCells.d.ts +13 -0
- package/dist/components/legacy/Notebook.d.ts +15 -0
- package/dist/components/{DashboardBuilder → legacy}/NotebookEditor.d.ts +3 -3
- package/dist/components/legacy/builderNames.d.ts +10 -0
- package/dist/components/legacy/index.d.ts +11 -0
- package/dist/components/legacy/kindAdapter.d.ts +11 -0
- package/dist/components/legacy/kindTypedDrafts.d.ts +10 -0
- package/dist/components/legacy/nameAlias.d.ts +44 -0
- package/dist/components/legacy/queryKeys.d.ts +8 -0
- package/dist/index.cjs.js +19 -19
- package/dist/index.es.js +7984 -7452
- package/dist/text/index.es.js +2 -2
- package/dist/{text-entry-CA0LZ1xL.es.js → text-entry-72YFLeNk.es.js} +10 -10
- package/dist/useCompiledDocument-oocN5cGE.cjs.js +141 -0
- package/dist/{useCompiledDocument-Bf72Ob5v.es.js → useCompiledDocument-x0B2RAH3.es.js} +4593 -4395
- package/package.json +2 -2
- package/src/builder-entry.ts +32 -24
- package/src/components/Dashboard/DashboardTile.tsx +17 -0
- package/src/components/Dashboard/DashboardView.spec.tsx +0 -21
- package/src/components/Dashboard/DashboardView.tsx +8 -24
- package/src/components/Dashboard/dropValueUrlTags.spec.ts +1 -4
- package/src/components/Dashboard/index.ts +0 -2
- package/src/components/DocumentCreate/createDocument.spec.ts +346 -53
- package/src/components/DocumentCreate/createDocument.ts +143 -63
- package/src/components/DocumentCreate/documentPath.ts +41 -12
- package/src/components/DocumentCreate/guards.ts +7 -15
- package/src/components/DocumentCreate/index.ts +3 -7
- package/src/components/DocumentCreate/newNotebook.spec.ts +113 -43
- package/src/components/DocumentCreate/newNotebook.ts +32 -10
- package/src/components/DocumentStorage/BrowserDocumentStorage.spec.ts +130 -28
- package/src/components/DocumentStorage/BrowserDocumentStorage.ts +78 -40
- package/src/components/DocumentStorage/DocumentStorage.contract.spec.tsx +426 -0
- package/src/components/DocumentStorage/DocumentStorage.ts +57 -24
- package/src/components/Home/AddEnvironmentDialog.tsx +1 -1
- package/src/components/Home/Home.tsx +1 -1
- package/src/components/Loading.tsx +1 -1
- package/src/components/Model/SourcesExplorer.tsx +1 -1
- package/src/components/Notebook/NotebookCell.tsx +6 -5
- package/src/components/Notebook/cellKind.spec.ts +15 -7
- package/src/components/Package/DataSchemaDialog.spec.tsx +85 -0
- package/src/components/Package/DataSchemaDialog.tsx +367 -0
- package/src/components/Package/NewDocumentDialog.spec.tsx +145 -88
- package/src/components/Package/NewDocumentDialog.tsx +93 -48
- package/src/components/Package/Package.artifacts.spec.tsx +79 -60
- package/src/components/Package/Package.create.spec.tsx +126 -112
- package/src/components/Package/Package.notebooks.spec.tsx +46 -27
- package/src/components/Package/Package.spec.tsx +43 -30
- package/src/components/Package/Package.tsx +173 -292
- package/src/components/Package/documentLocation.spec.ts +145 -50
- package/src/components/Package/documentLocation.ts +118 -39
- package/src/components/Package/index.ts +12 -3
- package/src/components/Package/reportQueries.ts +25 -0
- package/src/components/Package/useDocumentLocation.spec.ts +58 -0
- package/src/components/Package/useDocumentLocation.ts +90 -32
- package/src/components/Package/useDraftLayout.spec.tsx +143 -0
- package/src/components/Package/useDraftLayout.ts +81 -0
- package/src/components/Prose.spec.tsx +3 -3
- package/src/components/RenderedResult/RenderedResult.tsx +1 -1
- package/src/components/Report/CellReport.spec.tsx +155 -0
- package/src/components/{Notebook/Notebook.tsx → Report/CellReport.tsx} +178 -220
- package/src/components/Report/LinearReport.tsx +71 -0
- package/src/components/Report/Report.spec.tsx +238 -0
- package/src/components/Report/Report.telemetry.spec.tsx +292 -0
- package/src/components/Report/Report.tsx +277 -0
- package/src/components/Report/index.ts +12 -0
- package/src/components/Report/telemetry.spec.ts +90 -0
- package/src/components/Report/telemetry.ts +250 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/BuilderDialogs.tsx +5 -5
- package/src/components/{DashboardBuilder → ReportBuilder}/BuilderGrid.tsx +2 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/BuilderHeader.tsx +6 -7
- package/src/components/{DashboardBuilder → ReportBuilder}/BuilderToolbar.tsx +33 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/DrillDialog.tsx +2 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/EditorSurface.tsx +67 -107
- package/src/components/{DashboardBuilder → ReportBuilder}/FilterDialog.tsx +3 -4
- package/src/components/{DashboardBuilder/DashboardBuilder.charts.spec.tsx → ReportBuilder/ReportBuilder.charts.spec.tsx} +4 -4
- package/src/components/{DashboardBuilder/DashboardBuilder.exit.spec.tsx → ReportBuilder/ReportBuilder.exit.spec.tsx} +5 -5
- package/src/components/{DashboardBuilder/DashboardBuilder.inline.spec.tsx → ReportBuilder/ReportBuilder.inline.spec.tsx} +4 -4
- package/src/components/ReportBuilder/ReportBuilder.layoutSwitch.spec.tsx +145 -0
- package/src/components/{DashboardBuilder/DashboardBuilder.notebook.spec.tsx → ReportBuilder/ReportBuilder.notebook.spec.tsx} +22 -21
- package/src/components/{DashboardBuilder/DashboardBuilder.openDraft.spec.tsx → ReportBuilder/ReportBuilder.openDraft.spec.tsx} +3 -3
- package/src/components/{DashboardBuilder/DashboardBuilder.sources.spec.tsx → ReportBuilder/ReportBuilder.sources.spec.tsx} +19 -8
- package/src/components/{DashboardBuilder/DashboardBuilder.spec.tsx → ReportBuilder/ReportBuilder.spec.tsx} +34 -34
- package/src/components/{DashboardBuilder/DashboardBuilder.textTiles.spec.tsx → ReportBuilder/ReportBuilder.textTiles.spec.tsx} +5 -5
- package/src/components/{DashboardBuilder/DashboardBuilder.tsx → ReportBuilder/ReportBuilder.tsx} +46 -21
- package/src/components/{DashboardBuilder/DashboardEditor.authoritative.spec.tsx → ReportBuilder/ReportEditor.authoritative.spec.tsx} +28 -20
- package/src/components/{DashboardBuilder/DashboardEditor.emptyStart.spec.tsx → ReportBuilder/ReportEditor.emptyStart.spec.tsx} +19 -11
- package/src/components/{DashboardBuilder/DashboardEditor.filterTag.spec.tsx → ReportBuilder/ReportEditor.filterTag.spec.tsx} +7 -7
- package/src/components/{DashboardBuilder/DashboardEditor.notebook.spec.tsx → ReportBuilder/ReportEditor.notebook.spec.tsx} +70 -49
- package/src/components/{DashboardBuilder/DashboardEditor.package.spec.tsx → ReportBuilder/ReportEditor.package.spec.tsx} +52 -8
- package/src/components/{DashboardBuilder/DashboardEditor.resourceUri.spec.tsx → ReportBuilder/ReportEditor.resourceUri.spec.tsx} +50 -18
- package/src/components/{DashboardBuilder/DashboardEditor.spec.tsx → ReportBuilder/ReportEditor.spec.tsx} +65 -20
- package/src/components/{DashboardBuilder/DashboardEditor.textSource.spec.tsx → ReportBuilder/ReportEditor.textSource.spec.tsx} +6 -6
- package/src/components/{DashboardBuilder/DashboardEditor.tsx → ReportBuilder/ReportEditor.tsx} +92 -35
- package/src/components/{DashboardBuilder → ReportBuilder}/addTile.compile.spec.ts +1 -3
- package/src/components/{DashboardBuilder → ReportBuilder}/addTileToDocument.spec.ts +1 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/artifactBlock.spec.ts +21 -29
- package/src/components/ReportBuilder/builderReport.ts +53 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/catalog.spec.ts +28 -10
- package/src/components/{DashboardBuilder → ReportBuilder}/catalog.ts +17 -10
- package/src/components/{DashboardBuilder → ReportBuilder}/controls.spec.ts +1 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/document.ts +4 -7
- package/src/components/{DashboardBuilder → ReportBuilder}/documentSession.spec.ts +5 -5
- package/src/components/{DashboardBuilder → ReportBuilder}/documentSession.ts +1 -1
- package/src/components/{DashboardBuilder → ReportBuilder}/imports.spec.ts +6 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/imports.ts +8 -4
- package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.chart.spec.ts +1 -1
- package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.convert.spec.ts +9 -13
- package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.read.spec.ts +15 -15
- package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.ts +7 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/malloyTree.ts +25 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/newDashboard.spec.ts +12 -4
- package/src/components/{DashboardBuilder → ReportBuilder}/newDashboard.ts +11 -24
- package/src/components/{DashboardBuilder → ReportBuilder}/preview.spec.ts +1 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/readDocument.spec.ts +64 -36
- package/src/components/{DashboardBuilder → ReportBuilder}/readDocument.ts +33 -32
- package/src/components/ReportBuilder/readForEditor.spec.ts +96 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/readForEditor.ts +3 -11
- package/src/components/ReportBuilder/reportTag.ts +108 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.imports.spec.ts +28 -1
- package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.spec.ts +32 -3
- package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.ts +37 -60
- package/src/components/{DashboardBuilder → ReportBuilder}/tagParse.spec.ts +3 -3
- package/src/components/{DashboardBuilder → ReportBuilder}/testing/artifactTagParity.json +2 -2
- package/src/components/ReportBuilder/testing/drillResolution.json +279 -0
- package/src/components/ReportBuilder/testing/reportLayoutParity.json +125 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/textTiles.spec.ts +66 -143
- package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderSelection.ts +2 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/useControlBindings.ts +2 -2
- package/src/components/ReportBuilder/useEditorCatalog.spec.tsx +156 -0
- package/src/components/ReportBuilder/useEditorCatalog.ts +119 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/useHostCopy.ts +7 -5
- package/src/components/{DashboardBuilder → ReportBuilder}/useOpenedDocument.ts +56 -35
- package/src/components/{DashboardBuilder/useDashboardEditor.spec.ts → ReportBuilder/useReportEditor.spec.ts} +6 -6
- package/src/components/{DashboardBuilder/useDashboardEditor.ts → ReportBuilder/useReportEditor.ts} +6 -17
- package/src/components/{DashboardBuilder → ReportBuilder}/useSaveChannel.ts +36 -35
- package/src/components/{DashboardBuilder → ReportBuilder}/useTileEditing.ts +2 -2
- package/src/components/ServerProvider.tsx +2 -0
- package/src/components/drill/resolveDrill.ts +9 -2
- package/src/components/drill/useDrill.tsx +1 -0
- package/src/components/drill/useDrillSelf.spec.tsx +60 -7
- package/src/components/drill/useDrillSelf.ts +29 -12
- package/src/components/index.ts +2 -1
- package/src/components/{Dashboard → legacy}/Dashboard.spec.tsx +1 -1
- package/src/components/{Dashboard → legacy}/Dashboard.tsx +40 -28
- package/src/components/legacy/MalloynbCells.tsx +88 -0
- package/src/components/{Notebook → legacy}/Notebook.served.spec.tsx +17 -13
- package/src/components/{Notebook → legacy}/Notebook.spec.tsx +24 -20
- package/src/components/legacy/Notebook.tsx +44 -0
- package/src/components/{DashboardBuilder → legacy}/NotebookEditor.tsx +7 -4
- package/src/components/legacy/builderNames.ts +25 -0
- package/src/components/legacy/index.ts +20 -0
- package/src/components/legacy/kindAdapter.ts +19 -0
- package/src/components/legacy/kindTypedDrafts.ts +34 -0
- package/src/components/legacy/nameAlias.spec.ts +124 -0
- package/src/components/legacy/nameAlias.ts +95 -0
- package/src/components/legacy/queryKeys.ts +26 -0
- package/src/hooks/useGivensState.spec.ts +9 -9
- package/src/mainEntry.spec.ts +1 -1
- package/src/textEntry.spec.ts +9 -9
- package/src/utils/formatting.spec.ts +5 -5
- package/src/utils/parsing.spec.ts +1 -1
- package/src/utils/parsing.ts +1 -1
- package/dist/ServerProvider-Gj-im5VD.cjs.js +0 -1
- package/dist/components/Dashboard/telemetry.d.ts +0 -73
- package/dist/components/DashboardBuilder/builderReport.d.ts +0 -13
- package/dist/components/DashboardBuilder/telemetry.d.ts +0 -43
- package/dist/components/DocumentCreate/events.d.ts +0 -10
- package/dist/components/Notebook/Notebook.d.ts +0 -52
- package/dist/components/Notebook/index.d.ts +0 -1
- package/dist/useCompiledDocument-tBejqZ7s.cjs.js +0 -142
- package/src/components/Dashboard/telemetry.ts +0 -75
- package/src/components/DashboardBuilder/builderReport.ts +0 -74
- package/src/components/DashboardBuilder/readForEditor.spec.ts +0 -80
- package/src/components/DashboardBuilder/telemetry.ts +0 -47
- package/src/components/DashboardBuilder/testing/documentKindRule.json +0 -40
- package/src/components/DocumentCreate/events.ts +0 -15
- package/src/components/Notebook/index.ts +0 -4
- /package/dist/components/{DashboardBuilder → ReportBuilder}/AddTileDialog.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/ChartPicker.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/DrillDialog.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/FilterDialog.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/FilterStrip.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/InlineMarkdown.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/InlineText.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/SourceViewPicker.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/TextTileBody.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/TileFrame.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/TileMenu.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/addTileToDocument.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/annotationText.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/changedTile.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/chartLine.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/controls.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/inlineEdit.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/layout.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/loadMalloy.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/openDraft.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/preview.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/sortable.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/spliceResult.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/tagParse.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/testing/fixtures.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/testing/inline.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/testing/resize.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/tileDisplayTitle.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useBuilderSession.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useConversionConfirm.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useDocumentEditor.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useDraft.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useExitGuard.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useFilterForm.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useOpenDraftCommit.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useTileReorder.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useTileResize.d.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/AddTileDialog.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/AddTileDialog.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/ChartPicker.render.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/ChartPicker.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/ChartPicker.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/FilterStrip.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/InlineMarkdown.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/InlineText.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/SourceViewPicker.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/TextTileBody.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/TileFrame.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/TileMenu.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/__test__/inventory.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/addTileToDocument.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/annotationText.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/annotationText.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/artifactTagParity.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/catalog.aggregate.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/changedTile.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/changedTile.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/chartLine.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/chartLine.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/controls.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/emptyStart.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/inlineEdit.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/invariants.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/keepRowStructure.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/layout.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/loadMalloy.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/loadMalloy.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/malloyTree.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/moveIntoGap.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/openDraft.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/preview.shapes.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/preview.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/scannerShapes.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/sortable.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/sortable.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.chart.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/spliceResult.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/statementExtent.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/tagParse.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/testing/fixtures.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/testing/inline.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/testing/resize.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/testing/urlRenderTags.json +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/tileDisplayTitle.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderSession.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderSession.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.overlay.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useConversionConfirm.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useDocumentEditor.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useDocumentEditor.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useDraft.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useExitGuard.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useExitGuard.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useFilterForm.existing.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useFilterForm.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useFilterForm.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useOpenDraftCommit.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useTileReorder.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useTileReorder.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useTileResize.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useTileResize.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/withGaps.spec.ts +0 -0
- /package/src/components/{Notebook → legacy}/Notebook.layout.spec.tsx +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react/jsx-runtime"),E=require("../useCompiledDocument-tBejqZ7s.cjs.js"),S=require("@mui/material"),k=require("react"),Ke=require("../ServerProvider-Gj-im5VD.cjs.js"),me=require("../text-entry-BJwltZiy.cjs.js"),of=require("react-dom"),af=require("@malloydata/malloy-tag"),lf=require("@tanstack/react-query"),cf={line_chart:"Line",bar_chart:"Bar",big_value:"Big value",scatter_chart:"Scatter",shape_map:"Shape map",segment_map:"Segment map"};function df(e,t,n){const r=e!==void 0?void 0:n==="loading"?"Still loading this view's details":n==="unlisted"?"Not a view the catalog lists, so its shape is unknown":void 0,s=o=>{if(t!==o){if(o==="big_value")return e?.aggregateOnly===!0?void 0:r??"Needs a view with only totals (no group by)";if(o==="shape_map"||o==="segment_map")return e?.chart===o?void 0:r??"Needs a view that already carries a map chart"}};return[{value:"default",label:"From the view"},{value:"none",label:"Table"},...["line_chart","bar_chart","big_value","scatter_chart","shape_map","segment_map"].map(o=>{const a=s(o);return{value:o,label:cf[o],...a?{disabled:!0,reason:a}:{}}}),...t==="custom"?[{value:"custom",label:"As written"}]:[]]}function Ei({state:e,view:t,viewStatus:n,cellLabel:r,disabledReason:s,onOpen:i,onChange:o,variant:a="standard"}){const l=df(t,e,n),u=k.useId();return x.jsx(S.TextField,{select:!0,size:"small",variant:a,label:"Viz type",value:e,disabled:s!==void 0,onChange:d=>{const c=d.target.value;l.find(f=>f.value===c)?.disabled||o(c)},helperText:s,FormHelperTextProps:{id:u},SelectProps:{...i?{onOpen:i}:{},renderValue:d=>l.find(c=>c.value===d)?.label??String(d),MenuProps:{MenuListProps:{disabledItemsFocusable:!0}},SelectDisplayProps:{"aria-label":`Viz type, ${r}`,"aria-labelledby":void 0,...s?{"aria-describedby":u}:{}}},sx:{minWidth:140},children:l.map(d=>x.jsx(S.MenuItem,{value:d.value,disabled:d.value==="custom"||d.disabled===!0,children:x.jsx(S.ListItemText,{primary:d.label,...d.reason?{secondary:d.reason}:{}})},d.value))})}function uf({sources:e,source:t,view:n,onSource:r,onView:s}){const{theme:i}=Ke.usePublisherTheme(),o=e.find(a=>a.name===t);return x.jsxs(x.Fragment,{children:[x.jsx(S.TextField,{select:!0,size:"small",label:"Source",value:t,onChange:a=>r(a.target.value),inputProps:{"aria-label":"Source"},children:e.map(a=>x.jsxs(S.MenuItem,{value:a.name,disabled:a.views.length===0,children:[a.name,a.views.length===0&&x.jsx(S.Typography,{component:"span",variant:"caption",sx:{ml:1},children:"declares no views"}),a.description&&x.jsx(S.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:a.description})]},a.name))}),x.jsxs(S.Box,{children:[x.jsx(S.Typography,{variant:"subtitle2",sx:{mb:.5},children:"View"}),x.jsxs(S.List,{dense:!0,disablePadding:!0,"aria-label":"Views",sx:{maxHeight:"min(280px, 30vh)",overflowY:"auto",border:i.border,borderRadius:1},children:[(o?.views??[]).map(a=>x.jsxs(S.ListItemButton,{selected:n===a.name,onClick:()=>s(a.name),"aria-label":`View ${a.name}`,children:[x.jsx(S.ListItemText,{primary:a.name,secondary:a.description,primaryTypographyProps:{fontFamily:"ui-monospace, monospace",fontSize:13}}),a.chart&&x.jsx(S.Chip,{size:"small",variant:"outlined",label:a.chart.replace(/_chart$/,"")})]},a.name)),o&&o.views.length===0&&x.jsx(S.Typography,{variant:"body2",sx:{p:1.5,color:i.tileTitle},children:"This source declares no views."})]})]})]})}function ff({open:e,document:t,catalog:n,columns:r,onClose:s,onAdd:i,onAddText:o}){const{theme:a}=Ke.usePublisherTheme(),l=k.useMemo(()=>n?.sources??[],[n]),[u,d]=k.useState("query"),[c,f]=k.useState(""),[p,h]=k.useState(""),[m,y]=k.useState(""),[w,v]=k.useState("default"),[g,b]=k.useState(Math.ceil(r/2));k.useEffect(()=>{if(!e)return;d("query");const T=D=>l.some(N=>N.name===D&&N.views.length>0);f(t.sources.map(D=>D.base).find(T)??l.find(D=>D.views.length>0)?.name??""),h(""),y(""),v("default"),b(Math.ceil(r/2))},[e,t,l,r]);const _=c!==""&&p!=="",O=[c,p].filter(T=>T!==""&&!me.isBareName(T)).map(T=>`"${T}" is not a plain Malloy name, so a tile cannot be written for it.`)[0],I=l.find(T=>T.name===c),M=I?.views.find(T=>T.name===p);return x.jsx(E.AppDialog,{open:e,onClose:s,title:"Add a tile",description:"A tile shows one view of a source in this package.",actions:x.jsxs(x.Fragment,{children:[x.jsx(S.Button,{onClick:s,children:"Cancel"}),x.jsx(S.Button,{variant:"contained",disabled:u==="query"&&(!_||O!==void 0),onClick:()=>u==="text"?o():i({base:c,modelPath:I?.modelPath??"",...I?.exporters?{exporters:I.exporters}:{},view:p,...m.trim()?{label:m.trim()}:{},...w!=="default"?{chart:w,...M?{chartCarried:M.chart?[M.chart]:[]}:{}}:{},colspan:g}),children:u==="text"?"Add text":"Add tile"})]}),children:x.jsxs(S.Stack,{sx:{gap:2,pt:1},children:[x.jsxs(S.ToggleButtonGroup,{size:"small",exclusive:!0,value:u,"aria-label":"Tile type",onChange:(T,D)=>{D!==null&&d(D)},children:[x.jsx(S.ToggleButton,{value:"query",sx:{px:1.5},children:"Query"}),x.jsx(S.ToggleButton,{value:"text",sx:{px:1.5},children:"Text"})]}),u==="text"?x.jsx(S.Typography,{variant:"body2",sx:{color:a.tileTitle},children:"A text tile holds markdown: a heading, a paragraph, a list. It is added empty, and written on the tile itself."}):l.length===0?x.jsx(S.Typography,{variant:"body2",sx:{color:a.tileTitle},children:n?"This package publishes no source with a view to put on a tile.":"The package's sources are still loading."}):x.jsxs(x.Fragment,{children:[x.jsx(uf,{sources:l,source:c,view:p,onSource:T=>{f(T),h("")},onView:T=>{h(T),v("default")}}),O&&x.jsx(S.Typography,{variant:"body2",color:"error",children:O}),x.jsx(Ei,{state:w,view:M,cellLabel:"new tile",variant:"outlined",...M?{}:{disabledReason:"Pick a view to choose its chart."},onChange:T=>v(T)}),x.jsx(S.Stack,{direction:"row",sx:{gap:1.5},children:x.jsx(S.TextField,{size:"small",label:"Title",placeholder:"Uses the view's name",value:m,onChange:T=>y(T.target.value),inputProps:{"aria-label":"Tile title"},sx:{flex:1}})})]})]})})}const je=e=>e.kind==="text",xe=e=>e.kind!=="text",Wr=e=>xe(e)?e.label??e.name:e.name,Fe=e=>je(e)?`text.${e.name}`:`${e.source}.${e.name}`,si="self";function hf({open:e,document:t,source:n,givenNames:r,dashboards:s,onClose:i,onApply:o}){const{theme:a}=Ke.usePublisherTheme(),[l,u]=k.useState([]);k.useEffect(()=>{if(!e||!n)return;const h=(t.drills??[]).filter(m=>m.source===n.name);u((n.dimensions??[]).map(m=>{const y=h.find(w=>w.name===m.name);return{name:m.name,expression:m.expression,to:y?.to??[],given:y?.given??""}}))},[e,n,t]);const d=(h,m)=>u(y=>y.map((w,v)=>{if(v!==h)return w;const g={...w};return m(g),g})),c=[si,...s.filter(h=>h!==si)],f=h=>h===si?"This dashboard":h,p=()=>{n&&(o(l.filter(h=>h.to.length>0).map(h=>({source:n.name,name:h.name,expression:h.expression,to:h.to,...h.given?{given:h.given}:{}}))),i())};return x.jsx(E.AppDialog,{open:e,onClose:i,title:"Drill",description:"A cell in a column that groups by one of these dimensions becomes a link. Clicking it writes the value into a control — here, or on the dashboard it opens.",actions:x.jsxs(x.Fragment,{children:[x.jsx(S.Button,{onClick:i,children:"Cancel"}),x.jsx(S.Button,{variant:"contained",onClick:p,disabled:l.length===0,children:"Apply"})]}),children:x.jsx(S.Stack,{sx:{gap:2,pt:1},children:l.length===0?x.jsx(S.Typography,{variant:"body2",sx:{color:a.tileTitle},children:n?x.jsxs(x.Fragment,{children:[x.jsx(S.Box,{component:"code",children:n.name})," declares no dimensions of its own in this file. A drill is a tag on the dimension's declaration, so a dimension the model declares is made clickable in the model; to make one clickable here, declare it in"," ",x.jsx(S.Box,{component:"code",children:n.name})," and group by it."]}):"This tile's source is not declared in this file."}):l.map((h,m)=>x.jsxs(S.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr)"},gap:1.5,alignItems:"start"},children:[x.jsxs(S.Box,{sx:{minWidth:0,pt:.75},children:[x.jsx(S.Typography,{variant:"body2",sx:{fontFamily:"ui-monospace, monospace",fontSize:13},children:h.name}),x.jsxs(S.Typography,{variant:"caption",sx:{color:a.tileTitle,display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:h.expression,children:["is ",h.expression]})]}),x.jsx(S.TextField,{select:!0,size:"small",label:"Clicks go to",value:h.to,inputProps:{"aria-label":`Where ${h.name} goes`},SelectProps:{multiple:!0,renderValue:y=>y.length===0?"Not clickable":y.map(f).join(", "),displayEmpty:!0},InputLabelProps:{shrink:!0},onChange:y=>d(m,w=>{const v=y.target.value;w.to=Array.isArray(v)?v:String(v).split(",").filter(Boolean)}),children:c.map(y=>x.jsxs(S.MenuItem,{value:y,children:[x.jsx(S.Checkbox,{size:"small",checked:h.to.includes(y),sx:{p:0,mr:1}}),x.jsx(S.ListItemText,{primary:f(y)})]},y))}),x.jsxs(S.TextField,{select:!0,size:"small",label:"Sets the filter",value:h.given,disabled:h.to.length===0,inputProps:{"aria-label":`Control ${h.name} sets`},SelectProps:{displayEmpty:!0},InputLabelProps:{shrink:!0},helperText:h.given===""?`Named ${h.name}, like the dimension`:void 0,onChange:y=>d(m,w=>{w.given=y.target.value}),children:[x.jsx(S.MenuItem,{value:"",children:x.jsx("em",{children:"Same name as the dimension"})}),r.map(y=>x.jsx(S.MenuItem,{value:y,children:y},y))]})]},h.name))})})}function pf(e,t=[]){const n=new Map;for(const i of e.tiles)for(const o of xe(i)?i.filters??[]:[])n.set(o.given,(n.get(o.given)??0)+1);const r=[],s=new Set;for(const i of e.localGivens??[])s.add(i.name),r.push({name:i.name,...i.label===void 0?{}:{label:i.label},type:i.type,...i.suggest?{field:i.suggest.dimension}:{},origin:"dashboard",local:i,boundTiles:n.get(i.name)??0});for(const i of t)s.has(i.name)||(s.add(i.name),r.push({...i,origin:"model",boundTiles:n.get(i.name)??0}));for(const[i,o]of n)s.has(i)||r.push({name:i,origin:"model",boundTiles:o});return r}function bs(e){if(!(e===void 0||e.startsWith("filter<")))return e==="string"||e==="boolean"?"=":">="}function gf(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function rs(e,t){const n=gf(e),r=t?.replace(/_type$/,"");if(!n||!r)return!0;const s=new Set(["date","timestamp"]);return s.has(n)?s.has(r):n===r}function Aa(e){switch(e?.replace(/_type$/,"")){case"string":return"text";case"number":return"a number";case"date":return"a date";case"timestamp":return"a timestamp";case"boolean":return"true or false";default:return e??"an unknown type"}}function mf(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const vf=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function bf(e,t){const r=(e.split(".").at(-1)??"").split(/[^A-Za-z0-9]+/).filter(Boolean).join("_").toUpperCase()||"FILTER",s=/^[A-Z_]/.test(r)?r:`F_${r}`,i=me.isStrictName(s)?s:`${s}_FILTER`,o=new Set(t);if(!o.has(i))return i;for(let a=2;;a++)if(!o.has(`${i}_${a}`))return`${i}_${a}`}const Pa=[{kind:"select",label:"Pick one",hint:"A dropdown of the field's values"},{kind:"multiselect",label:"Pick several",hint:"The same, taking more than one"},{kind:"text",label:"Text",hint:"A box taking Malloy filter syntax"},{kind:"number",label:"Number range",hint:"A slider over the field's values"},{kind:"date",label:"On or after a date",hint:"A date picker; tiles keep rows on or after it"}];function Br(e){const t=e.label.trim()||e.name,n=e.field;switch(e.kind){case"select":case"multiselect":return{name:e.name,type:"filter<string>",default:"f''",label:t,control:e.kind,...e.source?{suggest:{source:e.source,dimension:n}}:{}};case"text":return{name:e.name,type:"filter<string>",default:"f''",label:t};case"number":return{name:e.name,type:"filter<number>",default:"f''",label:t,...e.range?{rangeMin:e.range.min,rangeMax:e.range.max}:{}};case"date":return{name:e.name,type:"date",default:`@${e.dateDefault??new Date().toISOString().slice(0,10)}`,label:t}}}const Ci=e=>xe(e)&&e.declaration.kind!=="inherited"&&e.declaration.kind!=="opaque";function yf(e,t){return e.tiles.map(n=>{const r=(xe(n)?n.filters??[]:[]).find(s=>s.given===t.name);return{include:r!==void 0,field:r?.field??t.field??t.name.toLowerCase(),...r?.op!==void 0?{op:r.op}:bs(t.type)!==void 0?{op:bs(t.type)}:{}}})}function xf(e,t,n){n.forEach((r,s)=>{const i=e.tiles[s];if(!i||!Ci(i))return;const o=(i.filters??[]).filter(l=>l.given!==t),a=r.include?[...o,{field:r.field.trim()||t.toLowerCase(),given:t,...r.op&&r.op!=="~"?{op:r.op}:{}}]:o;a.length>0?i.filters=a:delete i.filters})}function wf(e,t){const n=(e.localGivens??[]).filter(i=>i.name!==t.name),r=(e.localGivens??[]).findIndex(i=>i.name===t.name),s=[...n];s.splice(r>=0?r:s.length,0,t),e.localGivens=s}function _f(e,t){for(const r of e.tiles){if(!xe(r))continue;const s=(r.filters??[]).filter(i=>i.given!==t);s.length>0?r.filters=s:delete r.filters}const n=(e.localGivens??[]).filter(r=>r.name!==t);n.length>0?e.localGivens=n:delete e.localGivens}const ql=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function kf({open:e,document:t,control:n,available:r,fieldsFor:s,onApply:i}){const o=k.useRef(n);e&&(o.current=n);const a=e?n:o.current,l=a!==void 0,[u,d]=k.useState({kind:"new"}),[c,f]=k.useState(""),[p,h]=k.useState("select"),[m,y]=k.useState(""),[w,v]=k.useState(""),[g,b]=k.useState([]),[_,O]=k.useState(!1),[I,M]=k.useState(!1),T=C=>t.sources.find(K=>K.name===C.source)?.base??C.source;k.useEffect(()=>{if(e)if(M(n!==void 0),n){d({kind:"existing",name:n.name}),f(n.label??"");const C=yf(t,n);b(C);const K=C.filter(ve=>ve.include),ie=new Set(K.map(ve=>ve.field));v(ie.size===1?K[0].field:n.field??""),O(ie.size>1)}else d({kind:"new"}),f(""),h("select"),v(""),y(new Date().toISOString().slice(0,10)),b(t.tiles.map(C=>({include:Ci(C),field:""}))),O(!1)},[e,n,t]);const D=k.useMemo(()=>[...(t.localGivens??[]).map(C=>C.name),...r.map(C=>C.name)],[t,r]),N=k.useMemo(()=>w.trim()?bf(w.trim(),D):"",[w,D]),R=u.kind==="existing"?n??r.find(C=>C.name===u.name):N?{name:N,type:Br({name:N,label:c,kind:p,field:w}).type}:void 0,W=R?.type!==void 0&&!R.type.startsWith("filter<"),X=g.find(C=>C.include)?.op??bs(R?.type),G=(C,K)=>{M(!0),b(ie=>ie.map((ve,Re)=>Re===C?{...ve,...K}:ve))},U=C=>{M(!0),b(K=>K.map(ie=>({...ie,op:C})))},Y=C=>{const K=bs(C);b(ie=>ie.map(({op:ve,...Re})=>K?{...Re,op:K}:Re))},re=C=>{M(!0),d({kind:"existing",name:C.name}),v(C.field??""),Y(C.type)},ee=C=>{M(!0),h(C),Y(Br({name:"X",label:c,kind:C,field:w}).type)},A=t.tiles.map(Ci),B=A.filter(Boolean).length,z=g.filter((C,K)=>C.include&&A[K]).length,j=t.tiles.filter((C,K)=>(g[K]?.include??!1)&&A[K]&&xe(C)),q=j.length>0?j:t.tiles.filter((C,K)=>A[K]&&xe(C)),J=k.useMemo(()=>{const C=new Map;let K=!1;for(const ie of q){const ve=s?.(ie);if(ve){K=!0;for(const Re of ve)C.has(Re.name)||C.set(Re.name,Re)}}return K?[...C.values()]:void 0},[g,t.tiles,s]),Q=(()=>{const C=w.trim();for(const K of j){const ie=s?.(K);if(!ie||ie.some(ve=>ve.name===C))return T(K)}return j[0]?T(j[0]):t.sources[0]?.base})(),H=C=>{M(!0),b(K=>K.map((ie,ve)=>({...ie,include:C&&A[ve]})))},$=k.useMemo(()=>_?g:g.map(C=>({...C,field:w})),[_,g,w]),P=C=>{for(const K of q){const ie=s?.(K)?.find(ve=>ve.name===C.trim());if(ie?.type)return ie.type}},F=C=>rs(R?.type,C.type),V=(C,K)=>{if(C.trim()==="")return"Pick the field this filter compares.";const ie=K?s?.(K):void 0;if(!ie)return;const ve=ie.find(Re=>Re.name===C.trim());if(!ve)return`Not a field of ${K?T(K):"the tiles' source"}.`;if(ve.type&&!rs(R?.type,ve.type))return`${C.trim()} is ${Aa(ve.type)}; this filter compares ${Aa(R?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},oe=C=>{if(M(!0),v(C),l||u.kind!=="new")return;const K=P(C),ie=Br({name:"X",label:c,kind:p,field:C}).type;K&&!rs(ie,K)&&ee(mf(K))},Z=C=>{const K=t.tiles[C];return K&&xe(K)?K:void 0},ne=$.map((C,K)=>C.include&&A[K]?V(C.field,Z(K)):void 0),de=ne.every(C=>C===void 0),se=I?ne:ne.map(()=>{}),L=I&&!_&&z>0?j.map(C=>V(w,C)).find(Boolean):void 0,te=R!==void 0&&de&&(u.kind==="existing"||w.trim()!==""&&N!==""),pe=()=>{if(!(!R||!te))if(u.kind==="new")i(R.name,$,Br({name:R.name,label:c.trim()||ql(R.name),kind:p,field:w.trim(),...Q?{source:Q}:{},...m?{dateDefault:m}:{}}));else if(n?.origin==="dashboard"&&n.local){const C=c.trim(),K=C!==(n.local.label??"");i(R.name,$,K?{...n.local,...C?{label:C}:{}}:void 0)}else i(R.name,$)},ae=l&&a.origin==="model";return{editing:l,shown:a,fromModel:ae,source:u,setSource:d,label:c,setLabel:f,kind:p,dateDefault:m,setDateDefault:y,field:w,rows:g,setRows:b,perTile:_,setPerTile:O,newName:N,target:R,valueTyped:W,commonOp:X,setRow:G,setCommonOp:U,pickExisting:re,pickKind:ee,bindable:A,bindableCount:B,included:z,commonFields:J,setAll:H,accepts:F,pickField:oe,rowProblems:se,commonProblem:L,canApply:te,apply:pe}}function Ma({value:e,onChange:t,fields:n,accepts:r,label:s,ariaLabel:i,error:o,helperText:a,disabled:l,autoFocus:u,placeholder:d,sx:c}){const f=k.useMemo(()=>(n??[]).filter(h=>r?.(h)??!0).map(h=>h.name),[n,r]),p=k.useMemo(()=>new Map((n??[]).map(h=>[h.name,h.type])),[n]);return x.jsx(S.Autocomplete,{freeSolo:!0,size:"small",options:f,inputValue:e,onInputChange:(h,m)=>t(m),value:e,onChange:(h,m)=>t(typeof m=="string"?m:""),disabled:l,disableClearable:!0,renderOption:(h,m)=>k.createElement("li",{...h,key:m},x.jsx(S.Typography,{variant:"body2",sx:{flex:1},children:m}),p.get(m)&&x.jsx(S.Typography,{variant:"caption",sx:{opacity:.6},children:p.get(m)?.replace(/_type$/,"")})),renderInput:h=>x.jsx(S.TextField,{...h,label:s,placeholder:d,autoFocus:u,error:o,helperText:a,inputProps:{...h.inputProps,"aria-label":i}}),sx:c})}const ja=e=>e&&xe(e)&&e.declaration.kind==="opaque"?{label:"Not bindable",reason:`Its body is ${e.declaration.why}, so a filter has no single place to go.`}:{label:"From the model",reason:"Declared on its source, which this dashboard does not write."};function Sf({open:e,document:t,control:n,available:r,fieldsFor:s,onClose:i,onApply:o,onRemove:a}){const{theme:l}=Ke.usePublisherTheme(),{editing:u,shown:d,fromModel:c,source:f,setSource:p,label:h,setLabel:m,kind:y,dateDefault:w,setDateDefault:v,field:g,rows:b,setRows:_,perTile:O,setPerTile:I,newName:M,target:T,valueTyped:D,commonOp:N,setRow:R,setCommonOp:W,pickExisting:X,pickKind:G,bindable:U,bindableCount:Y,included:re,commonFields:ee,setAll:A,accepts:B,pickField:z,rowProblems:j,commonProblem:q,canApply:J,apply:Q}=kf({open:e,document:t,control:n,available:r,fieldsFor:s,onApply:o}),H=($,P,F)=>x.jsx(S.TextField,{select:!0,size:"small",label:"Compares",value:$??">=",onChange:V=>P(V.target.value),inputProps:{"aria-label":F},sx:{width:130},children:vf.filter(V=>V.op!=="~").map(V=>x.jsx(S.MenuItem,{value:V.op,children:V.label},V.op))});return x.jsx(E.AppDialog,{open:e,onClose:i,title:u?d.label??d.name:"Add a filter",description:u?x.jsxs(x.Fragment,{children:[x.jsxs(S.Box,{component:"span",sx:{fontFamily:"ui-monospace, monospace"},children:["$",d.name]}),c?" · declared in the model, so its label and options are set there":" · declared in this dashboard"]}):"A filter on the page, and the tiles it filters.",actions:x.jsxs(x.Fragment,{children:[u&&x.jsx(S.Button,{color:"error",startIcon:x.jsx(E.DeleteOutlineIcon,{}),onClick:()=>a(d.name),sx:$=>({mr:"auto",color:E.dangerTextColor($)}),children:"Remove filter"}),x.jsx(S.Button,{onClick:i,children:"Cancel"}),x.jsx(S.Tooltip,{title:J||T===void 0?"":"A ticked tile has no field, or names one its source does not have.",children:x.jsx("span",{children:x.jsx(S.Button,{variant:"contained",onClick:Q,disabled:!J,children:u?"Apply":"Add filter"})})})]}),children:x.jsxs(S.Stack,{sx:{gap:2.5,pt:1},children:[!u&&r.length>0&&x.jsxs(S.ToggleButtonGroup,{exclusive:!0,size:"small",value:f.kind,onChange:($,P)=>{P==="new"?p({kind:"new"}):P==="existing"&&r[0]&&X(r[0])},"aria-label":"Where the filter comes from",children:[x.jsx(S.ToggleButton,{value:"new",children:"New in this dashboard"}),x.jsx(S.ToggleButton,{value:"existing",children:"From the model"})]}),!u&&f.kind==="existing"?x.jsx(S.TextField,{select:!0,size:"small",label:"Filter",value:f.name,onChange:$=>{const P=r.find(F=>F.name===$.target.value);P&&X(P)},children:r.map($=>x.jsxs(S.MenuItem,{value:$.name,children:[$.label??$.name,x.jsxs(S.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",$.name]})]},$.name))}):null,x.jsxs(S.Stack,{direction:"row",sx:{gap:1.5,flexWrap:"wrap"},children:[!O&&x.jsx(Ma,{value:g,onChange:z,fields:ee,accepts:B,label:"Field to filter",ariaLabel:"Field to filter",placeholder:"category",autoFocus:!u,error:q!==void 0,helperText:q??(!u&&M?`Declared as $${M}`:void 0),sx:{flex:1,minWidth:200}}),!c&&x.jsx(S.TextField,{size:"small",label:"Label",placeholder:M?ql(M):"",value:h,onChange:$=>m($.target.value),inputProps:{"aria-label":"Filter label"},sx:{flex:1,minWidth:160}}),D&&!O&&H(N,W,"Comparison")]}),!u&&f.kind==="new"&&x.jsxs(S.Stack,{direction:"row",sx:{gap:1.5},children:[x.jsx(S.TextField,{select:!0,size:"small",label:"Filter kind",value:y,onChange:$=>G($.target.value),inputProps:{"aria-label":"Filter kind"},slotProps:{select:{renderValue:$=>Pa.find(P=>P.kind===$)?.label??String($)}},sx:{flex:1},children:Pa.map($=>x.jsxs(S.MenuItem,{value:$.kind,children:[$.label,x.jsx(S.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:$.hint})]},$.kind))}),y==="date"&&x.jsx(S.TextField,{size:"small",type:"date",label:"Starts at",value:w,onChange:$=>v($.target.value),InputLabelProps:{shrink:!0},sx:{flex:1}})]}),x.jsxs(S.Box,{children:[x.jsxs(S.Stack,{direction:"row",sx:{alignItems:"center",gap:.5},children:[x.jsx(S.Checkbox,{size:"small",checked:Y>0&&re===Y,indeterminate:re>0&&re<Y,disabled:Y===0,onChange:$=>A($.target.checked),inputProps:{"aria-label":"All tiles"}}),x.jsxs(S.Typography,{variant:"subtitle2",sx:{flex:1},children:["Applies to ",re," of ",t.tiles.length," tiles"]}),x.jsx(S.Button,{size:"small",onClick:()=>{O||_($=>$.map(P=>({...P,field:g}))),I($=>!$)},children:O?"Same field for all":"Adjust per tile"})]}),x.jsx(S.Stack,{sx:{gap:O?1:0},children:t.tiles.map(($,P)=>{if(!xe($))return null;const F=b[P],V=$.label??$.name,oe=O?j[P]:void 0;return x.jsxs(S.Stack,{direction:"row",sx:{gap:1,alignItems:O?"flex-start":"center",opacity:U[P]?1:.6},children:[x.jsx(S.Checkbox,{size:"small",disabled:!U[P],checked:(F?.include??!1)&&U[P],inputProps:{"aria-label":`Filter ${V}`},onChange:Z=>R(P,{include:Z.target.checked})}),x.jsx(S.Typography,{variant:"body2",sx:{flex:1,minWidth:0,pt:O?1:0},noWrap:!0,children:V}),U[P]?O&&x.jsxs(x.Fragment,{children:[D&&H(F?.op,Z=>R(P,{op:Z}),`Comparison for ${V}`),x.jsx(Ma,{value:F?.field??"",onChange:Z=>R(P,{field:Z}),fields:s?.($),accepts:B,label:"Field",ariaLabel:`Field for ${V}`,disabled:!F?.include,error:oe!==void 0,helperText:oe,sx:{width:220}})]}):x.jsx(S.Tooltip,{title:ja(t.tiles[P]).reason,children:x.jsx(S.Typography,{variant:"caption",sx:{color:l.tileTitle},children:ja(t.tiles[P]).label})})]},`${$.source}.${$.name}`)})}),re===0&&x.jsx(S.Typography,{variant:"caption",sx:{color:"warning.main",display:"block",mt:1},children:"No tile is ticked, so this control will not appear on the dashboard."})]})]})})}const $f=E.createSvgIcon(x.jsx("path",{d:"M11.71 17.99C8.53 17.84 6 15.22 6 12c0-3.31 2.69-6 6-6 3.22 0 5.84 2.53 5.99 5.71l-2.1-.63C15.48 9.31 13.89 8 12 8c-2.21 0-4 1.79-4 4 0 1.89 1.31 3.48 3.08 3.89zM22 12c0 .3-.01.6-.04.9l-1.97-.59c.01-.1.01-.21.01-.31 0-4.42-3.58-8-8-8s-8 3.58-8 8 3.58 8 8 8c.1 0 .21 0 .31-.01l.59 1.97c-.3.03-.6.04-.9.04-5.52 0-10-4.48-10-10S6.48 2 12 2s10 4.48 10 10m-3.77 4.26L22 15l-10-3 3 10 1.26-3.77 4.27 4.27 1.98-1.98z"}));function Kl(e,t,n,r){const[s,i]=k.useState(void 0);return k.useEffect(()=>{t&&e!==void 0&&i(structuredClone(e))},[t,e]),{draft:s,patch:d=>i(c=>{if(c===void 0)return c;const f=structuredClone(c);return d(f),f}),apply:d=>{if(s===void 0)return;const c=structuredClone(s);d(c),i(c),JSON.stringify(c)!==JSON.stringify(e)&&n(c)},close:()=>{s!==void 0&&e!==void 0&&JSON.stringify(s)!==JSON.stringify(e)&&n(s),r()},discard:()=>i(void 0)}}const Tf=e=>e&&e.length===1?`This tile's chart line (${e[0]}) is not one the builder models, so its chart cannot be changed here.`:`This tile has ${e?.length??"several"} chart lines${e?` (${e.join(" and ")})`:""}, so its chart cannot be changed here.`,Of="This tile's view is declared on its source, so its chart is set in the model.";function Ef({anchor:e,tile:t,onClose:n,onCommit:r,onRemove:s,removeBlocked:i,onDrills:o,view:a}){const l=k.useId(),{theme:u}=Ke.usePublisherTheme(),{draft:d,apply:c,close:f,discard:p}=Kl(t,e!==null,r,n),h=d!==void 0&&xe(d)?d:void 0,m=h!==void 0&&h.declaration.kind!=="inherited",y=g=>c(b=>{xe(b)&&g(b)}),w=k.useRef(void 0),v=e!==null;return k.useEffect(()=>{v&&(w.current=t&&xe(t)?t.chart:void 0)},[v]),x.jsx(S.Popover,{open:e!==null&&d!==void 0,anchorEl:e,onClose:f,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{width:320,p:2}}},children:d&&x.jsxs(S.Stack,{sx:{gap:1.5},children:[x.jsx(S.Typography,{variant:"overline",sx:{color:u.tileTitle,lineHeight:1.5},children:h?`${h.source} → ${h.name}`:`Text · ${d.name}`}),h&&m&&x.jsx(x.Fragment,{children:x.jsx(Ei,{state:h.chart??"default",view:a,cellLabel:`${h.source} ${h.name}`,...h.chart==="custom"?{disabledReason:Tf(h.chartLines)}:{},onChange:g=>y(b=>{const _=w.current;g===(_??"default")?(_===void 0?delete b.chart:b.chart=_,delete b.chartCarried):(b.chart=g,a?b.chartCarried=a.chart?[a.chart]:[]:delete b.chartCarried)})})}),h&&!m&&x.jsxs(x.Fragment,{children:[x.jsx(S.Typography,{variant:"body2",sx:{color:u.tileTitle},children:"Declared on its source, so its title and layout are set in the model. It can still be moved."}),x.jsx(Ei,{state:"default",view:a,cellLabel:`${h.source} ${h.name}`,disabledReason:Of,onChange:()=>{}})]}),h?.declaration.kind==="opaque"&&x.jsxs(S.Typography,{variant:"body2",sx:{color:u.tileTitle},children:["Its body is ",h.declaration.why,", so a filter has no single place to go. Everything else here is editable."]}),x.jsxs(S.Stack,{direction:"row",sx:{justifyContent:"space-between"},children:[m?x.jsx(S.Button,{size:"small",startIcon:x.jsx($f,{}),"aria-haspopup":"dialog",onClick:()=>{f(),o()},children:"Drill"}):x.jsx("span",{}),x.jsx(S.Button,{color:"error",size:"small",startIcon:x.jsx(E.DeleteOutlineIcon,{}),"aria-disabled":i!==void 0||void 0,"aria-describedby":i!==void 0?l:void 0,disableRipple:i!==void 0,sx:g=>({color:E.dangerTextColor(g),...i!==void 0?{opacity:.5,cursor:"default"}:{}}),onClick:()=>{i===void 0&&(p(),s())},children:"Delete"})]}),i!==void 0&&x.jsx(S.Typography,{id:l,variant:"caption",sx:{color:u.tileTitle},children:i})]})})}function Cf({editor:e,catalog:t,columns:n,dashboards:r,bindings:s,tiles:i,drillSource:o,setDrillSource:a,confirmConversion:l,exitDialog:u}){const{filterDialog:d,setFilterDialog:c}=s,{menu:f,setMenu:p}=i,h=f===void 0?void 0:e.document.tiles[f.index],m=h&&xe(h)?h:void 0,y=(()=>{if(!m||!t)return;const w=e.document.sources.find(g=>g.name===m.source)?.base??m.source,v=m.declaration.kind==="reference"?m.declaration.from:m.name;return t.sources.find(g=>g.name===w)?.views.find(g=>g.name===v)})();return x.jsxs(x.Fragment,{children:[x.jsx(Sf,{open:d!==void 0,document:e.document,...d?.control?{control:d.control}:{},available:s.available,...t?{fieldsFor:s.fieldsFor}:{},onClose:()=>c(void 0),onApply:s.applyFilter,onRemove:s.dropControl}),x.jsx(Ef,{anchor:f?.anchor??null,tile:f===void 0?void 0:e.document.tiles[f.index],onClose:()=>p(void 0),onCommit:w=>{const v=f?.index;v!==void 0&&e.update(g=>{g.tiles[v]=w})},onRemove:()=>{f!==void 0&&i.removeTile(f.index)},...e.document.tiles.length===1&&e.saved.tiles.length>0?{removeBlocked:"A saved dashboard needs at least one tile."}:{},view:y,onDrills:()=>{a(m?.source)}}),x.jsx(hf,{open:o!==void 0,document:e.document,source:e.document.sources.find(w=>w.name===o),givenNames:s.controlList.map(w=>w.name),dashboards:r??[],onClose:()=>a(void 0),onApply:w=>e.update(v=>{const b=[...(v.drills??[]).filter(_=>_.source!==o),...w];b.length===0?delete v.drills:v.drills=b})}),x.jsx(E.AppDialog,{open:l!==void 0,onClose:()=>l?.stop(),title:"Convert this notebook?",description:"Saving rewrites this notebook in the tile layout. The builder cannot take that back; the file's history in your repository can.",actions:x.jsxs(x.Fragment,{children:[x.jsx(S.Button,{onClick:()=>l?.stop(),children:"Cancel"}),x.jsx(S.Button,{variant:"contained",onClick:()=>l?.go(),children:"Convert and save"})]}),children:null}),x.jsx(E.UnsavedChangesDialog,{...u}),x.jsx(ff,{open:i.addingTile,document:e.document,catalog:t,columns:n,onClose:i.closeAdd,onAdd:i.addTile,onAddText:i.addText})]})}var If=Symbol.for("preact-signals");function zs(){if(yt>1)yt--;else{var e,t=!1;for((function(){var s=xs;for(xs=void 0;s!==void 0;){var i=s.S;if(i.v===s.v)for(var o=i.t;o!==void 0;o=o.x)o.i===s.i&&(o.i=i.i);s=s.o}})();lr!==void 0;){var n=lr;for(lr=void 0,ys++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Vl(n))try{n.c()}catch(s){t||(e=s,t=!0)}n=r}}if(ys=0,yt--,t)throw e}}function Te(e){if(yt>0)return e();Ii=++Df,yt++;try{return e()}finally{zs()}}var ar,we=void 0;function ue(e){var t=we,n=ar;we=void 0,ar=void 0;try{return e()}finally{we=t,ar=n}}var lr=void 0,yt=0,ys=0,Df=0,Ii=0,xs=void 0,ws=0;function Ul(e){if(we!==void 0){var t=e.n;if(t===void 0||t.t!==we)return t={i:0,S:e,p:we.s,n:void 0,t:we,e:void 0,x:void 0,r:t},we.s!==void 0&&(we.s.n=t),we.s=t,e.n=t,32&we.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=we.s,t.n=void 0,we.s.n=t,we.s=t),t}}function Ue(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}Ue.prototype.brand=If;Ue.prototype.h=function(){return!0};Ue.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n!==void 0?n.e=e:ue(function(){var r;(r=t.W)==null||r.call(t)}))};Ue.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&ue(function(){var s;(s=t.Z)==null||s.call(t)}))}};Ue.prototype.subscribe=function(e){var t=this;return st(function(){var n=t.value;ue(function(){return e(n)})},{name:"sub"})};Ue.prototype.valueOf=function(){return this.value};Ue.prototype.toString=function(){return this.value+""};Ue.prototype.toJSON=function(){return this.value};Ue.prototype.peek=function(){var e=this;return ue(function(){return e.value})};Object.defineProperty(Ue.prototype,"value",{get:function(){var e=Ul(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(ys>100)throw new Error("Cycle detected");(function(n){yt!==0&&ys===0&&n.l!==Ii&&(n.l=Ii,xs={S:n,v:n.v,i:n.i,o:xs})})(this),this.v=e,this.i++,ws++,yt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{zs()}}}});function Tn(e,t){return new Ue(e,t)}function Vl(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Hl(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function Xl(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function Xt(e,t){Ue.call(this,void 0,t),this.x=e,this.s=void 0,this.g=ws-1,this.f=4}Xt.prototype=new Ue;Xt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===ws))return!0;if(this.g=ws,this.f|=1,this.i>0&&!Vl(this))return this.f&=-2,!0;var e=we;try{Hl(this),we=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return we=e,Xl(this),this.f&=-2,!0};Xt.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}Ue.prototype.S.call(this,e)};Xt.prototype.U=function(e){if(this.t!==void 0&&(Ue.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};Xt.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(Xt.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Ul(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function Ra(e,t){return new Xt(e,t)}function Yl(e){var t=e.m;if(e.m=void 0,typeof t=="function"){yt++;var n=we;we=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,xo(e),r}finally{we=n,zs()}}}function xo(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Yl(e)}function Af(e){if(we!==this)throw new Error("Out-of-order effect");Xl(this),we=e,this.f&=-2,8&this.f&&xo(this),zs()}function On(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,ar&&ar.push(this)}On.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.m=t)}finally{e()}};On.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Yl(this),Hl(this),yt++;var e=we;return we=this,Af.bind(this,e)};On.prototype.N=function(){2&this.f||(this.f|=2,this.u=lr,lr=this)};On.prototype.d=function(){this.f|=8,1&this.f||xo(this)};On.prototype.dispose=function(){this.d()};function st(e,t){var n=new On(e,t);try{n.c()}catch(s){throw n.d(),s}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Pf=Object.create,wo=Object.defineProperty,Mf=Object.defineProperties,jf=Object.getOwnPropertyDescriptor,Rf=Object.getOwnPropertyDescriptors,La=Object.getOwnPropertySymbols,Lf=Object.prototype.hasOwnProperty,Nf=Object.prototype.propertyIsEnumerable,Ff=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),En=e=>{throw TypeError(e)},Di=(e,t,n)=>t in e?wo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,zf=(e,t)=>{for(var n in t||(t={}))Lf.call(t,n)&&Di(e,n,t[n]);if(La)for(var n of La(t))Nf.call(t,n)&&Di(e,n,t[n]);return e},Wf=(e,t)=>Mf(e,Rf(t)),Na=(e,t)=>wo(e,"name",{value:t,configurable:!0}),Bf=e=>{var t;return[,,,Pf((t=void 0)!=null?t:null)]},Zl=["class","method","getter","setter","accessor","field","value","get","set"],Kn=e=>e!==void 0&&typeof e!="function"?En("Function expected"):e,Gf=(e,t,n,r,s)=>({kind:Zl[e],name:t,metadata:r,addInitializer:i=>n._?En("Already initialized"):s.push(Kn(i||null))}),Ql=(e,t)=>Di(t,Ff("metadata"),e[3]),jt=(e,t,n,r)=>{for(var s=0,i=e[t>>1],o=i&&i.length;s<o;s++)t&1?i[s].call(n):r=i[s].call(n,r);return r},Cn=(e,t,n,r,s,i)=>{var o,a,l,u,d,c=t&7,f=!!(t&8),p=!!(t&16),h=c>3?e.length+1:c?f?1:2:0,m=Zl[c+5],y=c>3&&(e[h-1]=[]),w=e[h]||(e[h]=[]),v=c&&(!p&&!f&&(s=s.prototype),c<5&&(c>3||!p)&&jf(c<4?s:{get[n](){return Je(this,i)},set[n](b){return Ot(this,i,b)}},n));c?p&&c<4&&Na(i,(c>2?"set ":c>1?"get ":"")+n):Na(s,n);for(var g=r.length-1;g>=0;g--)u=Gf(c,n,l={},e[3],w),c&&(u.static=f,u.private=p,d=u.access={has:p?b=>qf(s,b):b=>n in b},c^3&&(d.get=p?b=>(c^1?Je:Kf)(b,s,c^4?i:v.get):b=>b[n]),c>2&&(d.set=p?(b,_)=>Ot(b,s,_,c^4?i:v.set):(b,_)=>b[n]=_)),a=(0,r[g])(c?c<4?p?i:v[m]:c>4?void 0:{get:v.get,set:v.set}:s,u),l._=1,c^4||a===void 0?Kn(a)&&(c>4?y.unshift(a):c?p?i=a:v[m]=a:s=a):typeof a!="object"||a===null?En("Object expected"):(Kn(o=a.get)&&(v.get=o),Kn(o=a.set)&&(v.set=o),Kn(o=a.init)&&y.unshift(o));return c||Ql(e,s),v&&wo(s,n,v),p?c^4?i:v:s},_o=(e,t,n)=>t.has(e)||En("Cannot "+n),qf=(e,t)=>Object(t)!==t?En('Cannot use the "in" operator on this value'):e.has(t),Je=(e,t,n)=>(_o(e,t,"read from private field"),n?n.call(e):t.get(e)),Un=(e,t,n)=>t.has(e)?En("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ot=(e,t,n,r)=>(_o(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Kf=(e,t,n)=>(_o(e,t,"access private method"),n);function Ai(e,t){if(t){let n;return Ra(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return Ra(e)}function ot(e,t){if(Object.is(e,t))return!0;if(e===null||t===null)return!1;if(typeof e=="function"&&typeof t=="function")return e===t;if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:!e.some((r,s)=>!ot(r,t[s]));if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:!n.some(i=>!ot(e[i],t[i]))}return!1}function fe({get:e},t){return{init(n){return Tn(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function Ee(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=Ai(e.bind(this)),n.set(this,r)),r.value}}function ii(e=!0){return function(t,n){n.addInitializer(function(){const r=n.kind==="field"?this:n.static?this:Object.getPrototypeOf(this),s=Object.getOwnPropertyDescriptor(r,n.name);s&&Object.defineProperty(r,n.name,Wf(zf({},s),{enumerable:e}))})}}function Er(...e){const t=e.map(n=>st(n));return()=>t.forEach(n=>n())}var Jl,ec,tc,nc,rc,sc,Be,ko,oi,Pi,Mi,ze,So,ai,ic,ji,$o,li,Ri,Li;sc=[fe],rc=[fe],nc=[fe],tc=[ii()],ec=[ii()],Jl=[ii()];var Yt=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,jt(Be,5,this),Un(this,ze),Un(this,ko,jt(Be,8,this)),jt(Be,11,this),Un(this,So,jt(Be,12,this)),jt(Be,15,this),Un(this,$o,jt(Be,16,this)),jt(Be,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return Je(this,ze,Ri)}get initial(){return Je(this,ze,Pi)}get previous(){return Je(this,ze,ic)}set current(e){const t=ue(()=>Je(this,ze,Ri));e&&t&&this.equals(t,e)||Te(()=>{Je(this,ze,Pi)||Ot(this,ze,e,Mi),Ot(this,ze,t,ji),Ot(this,ze,e,Li)})}reset(e=this.defaultValue){Te(()=>{Ot(this,ze,void 0,ji),Ot(this,ze,e,Mi),Ot(this,ze,e,Li)})}};Be=Bf();ko=new WeakMap;ze=new WeakSet;So=new WeakMap;$o=new WeakMap;oi=Cn(Be,20,"#initial",sc,ze,ko),Pi=oi.get,Mi=oi.set;ai=Cn(Be,20,"#previous",rc,ze,So),ic=ai.get,ji=ai.set;li=Cn(Be,20,"#current",nc,ze,$o),Ri=li.get,Li=li.set;Cn(Be,2,"current",tc,Yt);Cn(Be,2,"initial",ec,Yt);Cn(Be,2,"previous",Jl,Yt);Ql(Be,Yt);function ci(e){return ue(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var Rt,Uf=class{constructor(){Un(this,Rt,new WeakMap)}get(e,t){var n;return e?(n=Je(this,Rt).get(e))==null?void 0:n.get(t):void 0}set(e,t,n){var r;if(e)return Je(this,Rt).has(e)||Je(this,Rt).set(e,new Map),(r=Je(this,Rt).get(e))==null?void 0:r.set(t,n)}clear(e){var t;return e?(t=Je(this,Rt).get(e))==null?void 0:t.clear():void 0}};Rt=new WeakMap;var Vf=Object.create,oc=Object.defineProperty,Hf=Object.getOwnPropertyDescriptor,Fa=Object.getOwnPropertySymbols,Xf=Object.prototype.hasOwnProperty,Yf=Object.prototype.propertyIsEnumerable,ac=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ws=e=>{throw TypeError(e)},za=Math.pow,Ni=(e,t,n)=>t in e?oc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Zf=(e,t)=>{for(var n in t||(t={}))Xf.call(t,n)&&Ni(e,n,t[n]);if(Fa)for(var n of Fa(t))Yf.call(t,n)&&Ni(e,n,t[n]);return e},Qf=e=>{var t;return[,,,Vf((t=e?.[ac("metadata")])!=null?t:null)]},lc=["class","method","getter","setter","accessor","field","value","get","set"],cc=e=>e!==void 0&&typeof e!="function"?Ws("Function expected"):e,Jf=(e,t,n,r,s)=>({kind:lc[e],name:t,metadata:r,addInitializer:i=>n._?Ws("Already initialized"):s.push(cc(i||null))}),eh=(e,t)=>Ni(t,ac("metadata"),e[3]),th=(e,t,n,r)=>{for(var s=0,i=e[t>>1],o=i&&i.length;s<o;s++)i[s].call(n);return r},dc=(e,t,n,r,s,i)=>{for(var o,a,l,u,d=t&7,c=!1,f=!1,p=2,h=lc[d+5],m=e[p]||(e[p]=[]),y=(s=s.prototype,Hf(s,n)),w=r.length-1;w>=0;w--)l=Jf(d,n,a={},e[3],m),l.static=c,l.private=f,u=l.access={has:v=>n in v},u.get=v=>v[n],o=(0,r[w])(y[h],l),a._=1,cc(o)&&(y[h]=o);return y&&oc(s,n,y),s},uc=(e,t,n)=>t.has(e)||Ws("Cannot "+n),nh=(e,t,n)=>(uc(e,t,"read from private field"),t.get(e)),rh=(e,t,n)=>t.has(e)?Ws("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),sh=(e,t,n,r)=>(uc(e,t,"write to private field"),t.set(e,n),n),et=class Fi{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Fi(t.x-n.x,t.y-n.y)}static distance(t,n){return Math.hypot(t.x-n.x,t.y-n.y)}static equals(t,n){return t.x===n.x&&t.y===n.y}static from({x:t,y:n}){return new Fi(t,n)}},ft=class Lt{constructor(t,n,r,s){this.left=t,this.top=n,this.width=r,this.height=s,this.scale={x:1,y:1}}get inverseScale(){return{x:1/this.scale.x,y:1/this.scale.y}}translate(t,n){const{top:r,left:s,width:i,height:o,scale:a}=this,l=new Lt(s+t,r+n,i,o);return l.scale=Zf({},a),l}get boundingRectangle(){const{width:t,height:n,left:r,top:s,right:i,bottom:o}=this;return{width:t,height:n,left:r,top:s,right:i,bottom:o}}get center(){const{left:t,top:n,right:r,bottom:s}=this;return new et((t+r)/2,(n+s)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof Lt))return!1;const{left:n,top:r,width:s,height:i}=this;return n===t.left&&r===t.top&&s===t.width&&i===t.height}containsPoint(t){const{top:n,left:r,bottom:s,right:i}=this;return n<=t.y&&t.y<=s&&r<=t.x&&t.x<=i}intersectionArea(t){return t instanceof Lt?ih(this,t):0}intersectionRatio(t){const{area:n}=this,r=this.intersectionArea(t);return r/(t.area+n-r)}get bottom(){const{top:t,height:n}=this;return t+n}get right(){const{left:t,width:n}=this;return t+n}get aspectRatio(){const{width:t,height:n}=this;return t/n}get corners(){return[{x:this.left,y:this.top},{x:this.right,y:this.top},{x:this.left,y:this.bottom},{x:this.right,y:this.bottom}]}static from({top:t,left:n,width:r,height:s}){return new Lt(n,t,r,s)}static delta(t,n,r={x:"center",y:"center"}){const s=(i,o)=>{const a=r[o],l=o==="x"?i.left:i.top,u=o==="x"?i.width:i.height;return a=="start"?l:a=="end"?l+u:l+u/2};return et.delta({x:s(t,"x"),y:s(t,"y")},{x:s(n,"x"),y:s(n,"y")})}static intersectionRatio(t,n){return Lt.from(t).intersectionRatio(Lt.from(n))}};function ih(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),s=Math.min(t.left+t.width,e.left+e.width),i=Math.min(t.top+t.height,e.top+e.height),o=s-r,a=i-n;return r<s&&n<i?o*a:0}var fc,hc,zi,ss,Cr,Bs=class extends(zi=Yt,hc=[Ee],fc=[Ee],zi){constructor(t){const n=et.from(t);super(n,(r,s)=>et.equals(r,s)),th(Cr,5,this),rh(this,ss,0),this.velocity={x:0,y:0}}get delta(){return et.delta(this.current,this.initial)}get direction(){const{current:t,previous:n}=this;if(!n)return null;const r={x:t.x-n.x,y:t.y-n.y};return!r.x&&!r.y?null:Math.abs(r.x)>Math.abs(r.y)?r.x>0?"right":"left":r.y>0?"down":"up"}get current(){return super.current}set current(t){const{current:n}=this,r=et.from(t),s={x:r.x-n.x,y:r.y-n.y},i=Date.now(),o=i-nh(this,ss),a=l=>Math.round(l/o*100);Te(()=>{sh(this,ss,i),this.velocity={x:a(s.x),y:a(s.y)},super.current=r})}reset(t=this.defaultValue){super.reset(et.from(t)),this.velocity={x:0,y:0}}};Cr=Qf(zi);ss=new WeakMap;dc(Cr,2,"delta",hc,Bs);dc(Cr,2,"direction",fc,Bs);eh(Cr,Bs);function Wi({x:e,y:t},n){const r=Math.abs(e),s=Math.abs(t);return typeof n=="number"?Math.sqrt(za(r,2)+za(s,2))>n:"x"in n&&"y"in n?r>n.x&&s>n.y:"x"in n?r>n.x:"y"in n?s>n.y:!1}var pc=(e=>(e.Horizontal="x",e.Vertical="y",e))(pc||{}),gc=Object.values(pc),oh=Object.create,To=Object.defineProperty,ah=Object.defineProperties,lh=Object.getOwnPropertyDescriptor,ch=Object.getOwnPropertyDescriptors,_s=Object.getOwnPropertySymbols,mc=Object.prototype.hasOwnProperty,vc=Object.prototype.propertyIsEnumerable,bc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),In=e=>{throw TypeError(e)},Bi=(e,t,n)=>t in e?To(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Oo=(e,t)=>{for(var n in t||(t={}))mc.call(t,n)&&Bi(e,n,t[n]);if(_s)for(var n of _s(t))vc.call(t,n)&&Bi(e,n,t[n]);return e},Eo=(e,t)=>ah(e,ch(t)),Wa=(e,t)=>To(e,"name",{value:t,configurable:!0}),yc=(e,t)=>{var n={};for(var r in e)mc.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&_s)for(var r of _s(e))t.indexOf(r)<0&&vc.call(e,r)&&(n[r]=e[r]);return n},Dn=e=>{var t;return[,,,oh((t=e?.[bc("metadata")])!=null?t:null)]},xc=["class","method","getter","setter","accessor","field","value","get","set"],Vn=e=>e!==void 0&&typeof e!="function"?In("Function expected"):e,dh=(e,t,n,r,s)=>({kind:xc[e],name:t,metadata:r,addInitializer:i=>n._?In("Already initialized"):s.push(Vn(i||null))}),Zt=(e,t)=>Bi(t,bc("metadata"),e[3]),ce=(e,t,n,r)=>{for(var s=0,i=e[t>>1],o=i&&i.length;s<o;s++)t&1?i[s].call(n):r=i[s].call(n,r);return r},he=(e,t,n,r,s,i)=>{var o,a,l,u,d,c=t&7,f=!!(t&8),p=!!(t&16),h=c>3?e.length+1:c?f?1:2:0,m=xc[c+5],y=c>3&&(e[h-1]=[]),w=e[h]||(e[h]=[]),v=c&&(!p&&!f&&(s=s.prototype),c<5&&(c>3||!p)&&lh(c<4?s:{get[n](){return Oe(this,i)},set[n](b){return Ze(this,i,b)}},n));c?p&&c<4&&Wa(i,(c>2?"set ":c>1?"get ":"")+n):Wa(s,n);for(var g=r.length-1;g>=0;g--)u=dh(c,n,l={},e[3],w),c&&(u.static=f,u.private=p,d=u.access={has:p?b=>uh(s,b):b=>n in b},c^3&&(d.get=p?b=>(c^1?Oe:wc)(b,s,c^4?i:v.get):b=>b[n]),c>2&&(d.set=p?(b,_)=>Ze(b,s,_,c^4?i:v.set):(b,_)=>b[n]=_)),a=(0,r[g])(c?c<4?p?i:v[m]:c>4?void 0:{get:v.get,set:v.set}:s,u),l._=1,c^4||a===void 0?Vn(a)&&(c>4?y.unshift(a):c?p?i=a:v[m]=a:s=a):typeof a!="object"||a===null?In("Object expected"):(Vn(o=a.get)&&(v.get=o),Vn(o=a.set)&&(v.set=o),Vn(o=a.init)&&y.unshift(o));return c||Zt(e,s),v&&To(s,n,v),p?c^4?i:v:s},Co=(e,t,n)=>t.has(e)||In("Cannot "+n),uh=(e,t)=>Object(t)!==t?In('Cannot use the "in" operator on this value'):e.has(t),Oe=(e,t,n)=>(Co(e,t,"read from private field"),n?n.call(e):t.get(e)),ge=(e,t,n)=>t.has(e)?In("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ze=(e,t,n,r)=>(Co(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),wc=(e,t,n)=>(Co(e,t,"access private method"),n);function _c(e,t){return{plugin:e,options:t}}function Ir(e){return t=>_c(e,t)}function pr(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var kc,gr,Io,is;kc=[fe];var We=class{constructor(e,t){this.manager=e,this.options=t,ge(this,Io,ce(gr,8,this,!1)),ce(gr,11,this),ge(this,is,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return ue(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=st(e.bind(this));return Oe(this,is).add(t),t}destroy(){Oe(this,is).forEach(e=>e())}static configure(e){return _c(this,e)}};gr=Dn(null);Io=new WeakMap;is=new WeakMap;he(gr,4,"disabled",kc,We,Io);Zt(gr,We);var Dr=class extends We{},os,di=class{constructor(e){this.manager=e,this.instances=new Map,ge(this,os,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(pr).reduce((r,s)=>{const i=r.find(({plugin:o})=>o===s.plugin);return i?(i.options=s.options,r):[...r,s]},[]),n=t.map(({plugin:r})=>r);for(const r of Oe(this,os))if(!n.includes(r)){if(r.prototype instanceof Dr)continue;this.unregister(r)}for(const{plugin:r,options:s}of t)this.register(r,s);Ze(this,os,n)}get(e){return this.instances.get(e)}register(e,t){const n=this.instances.get(e);if(n)return n.options!==t&&(n.options=t),n;const r=new e(this.manager,t);return this.instances.set(e,r),r}unregister(e){const t=this.instances.get(e);t&&(t.destroy(),this.instances.delete(e))}destroy(){for(const e of this.instances.values())e.destroy();this.instances.clear()}};os=new WeakMap;function fh(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var Gr=[],an,ln,hh=class extends We{constructor(e){super(e),ge(this,an),ge(this,ln),this.computeCollisions=this.computeCollisions.bind(this),Ze(this,ln,Tn(Gr)),this.destroy=Er(()=>{const t=this.computeCollisions(),n=ue(()=>this.manager.dragOperation.position.current);if(t!==Gr){const r=Oe(this,an);if(Ze(this,an,n),r&&n.x==r.x&&n.y==r.y)return}else Ze(this,an,void 0);Oe(this,ln).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){ue(()=>{e?Oe(this,ln).value=this.computeCollisions():Ze(this,an,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:s,shape:i,status:o}=r;if(!o.initialized||!i)return Gr;const a=[],l=[];for(const u of e??n.droppables){if(u.disabled||s&&!u.accepts(s))continue;const d=t??u.collisionDetector;if(!d)continue;l.push(u),u.shape;const c=ue(()=>d({droppable:u,dragOperation:r}));c&&(u.collisionPriority!=null&&(c.priority=u.collisionPriority),a.push(c))}return l.length===0?Gr:(a.sort(fh),a)}get collisions(){return Oe(this,ln).value}};an=new WeakMap;ln=new WeakMap;var Sc,$c,Tc,Do,Oc,at,Ao,pn,Po,Mo;Tc=[fe],$c=[fe],Sc=[fe];var wt=class Nt{constructor(t,n){ge(this,Ao,ce(at,8,this)),ce(at,11,this),ge(this,pn),ge(this,Po,ce(at,12,this)),ce(at,15,this),ge(this,Mo,ce(at,16,this)),ce(at,19,this);const{effects:r,id:s,data:i={},disabled:o=!1,register:a=!0}=t;let l=s;Ze(this,pn,Tn(s)),this.manager=n,this.data=i,this.disabled=o,this.effects=()=>{var u;return[()=>{const{id:d,manager:c}=this;if(d!==l)return l=d,c?.registry.register(this),()=>c?.registry.unregister(this)},...(u=r?.())!=null?u:[]]},this.register=this.register.bind(this),this.unregister=this.unregister.bind(this),this.destroy=this.destroy.bind(this),n&&a&&queueMicrotask(this.register)}get id(){var t,n;const r=Oe(this,pn).value;return(n=(t=Nt.pendingIdChanges)==null?void 0:t.get(this))!=null?n:r}set id(t){var n,r;const s=(r=(n=Nt.pendingIdChanges)==null?void 0:n.get(this))!=null?r:Oe(this,pn).peek();t!==s&&(Nt.pendingIdChanges||(Nt.pendingIdChanges=new Map,queueMicrotask(()=>{var i;return wc(i=Nt,Do,Oc).call(i)})),Nt.pendingIdChanges.set(this,t))}register(){var t;return(t=this.manager)==null?void 0:t.registry.register(this)}unregister(){var t;(t=this.manager)==null||t.registry.unregister(this)}destroy(){var t;(t=this.manager)==null||t.registry.unregister(this)}};at=Dn(null);Do=new WeakSet;Oc=function(){const e=wt.pendingIdChanges;wt.pendingIdChanges=null,e&&Te(()=>{for(const[t,n]of e)Oe(t,pn).value=n})};Ao=new WeakMap;pn=new WeakMap;Po=new WeakMap;Mo=new WeakMap;he(at,4,"manager",Tc,wt,Ao);he(at,4,"data",$c,wt,Po);he(at,4,"disabled",Sc,wt,Mo);ge(wt,Do);Zt(at,wt);wt.pendingIdChanges=null;var Gs=wt,Ba=class{constructor(){this.map=Tn(new Map),this.cleanupFunctions=new WeakMap,this.register=(e,t)=>{const n=this.map.peek(),r=n.get(e),s=()=>this.unregister(e,t);if(r===t)return s;if(r&&r.id===e){const a=this.cleanupFunctions.get(r);a?.(),this.cleanupFunctions.delete(r)}const i=new Map(n);for(const[a,l]of n)if(l===t&&a!==e){i.delete(a);break}i.set(e,t),this.map.value=i;const o=Er(...t.effects());return this.cleanupFunctions.set(t,o),s},this.unregister=(e,t)=>{const n=this.map.peek();if(n.get(e)!==t)return;const r=this.cleanupFunctions.get(t);r?.(),this.cleanupFunctions.delete(t);const s=new Map(n);s.delete(e),this.map.value=s}}[Symbol.iterator](){return this.map.peek().values()}get value(){return this.map.value.values()}has(e){return this.map.value.has(e)}get(e){return this.map.value.get(e)}destroy(){for(const e of this){const t=this.cleanupFunctions.get(e);t?.(),e.destroy()}this.map.value=new Map}},Ec,Cc,Ic,Dc,Ac,Pc,Gi,Ge,jo,Ro,Lo,ht=class extends(Gi=Gs,Pc=[fe],Ac=[fe],Dc=[fe],Ic=[Ee],Cc=[Ee],Ec=[Ee],Gi){constructor(t,n){var r=t,{modifiers:s,type:i,sensors:o,plugins:a,effects:l}=r,u=yc(r,["modifiers","type","sensors","plugins","effects"]);super(Eo(Oo({},u),{effects:()=>{var d;return[...(d=l?.())!=null?d:[],()=>{const{manager:c,plugins:f}=this;if(!(!c||!f))for(const p of f){const{plugin:h}=pr(p);c.registry.plugins.register(h)}}]}}),n),ce(Ge,5,this),ge(this,jo,ce(Ge,8,this)),ce(Ge,11,this),ge(this,Ro,ce(Ge,12,this)),ce(Ge,15,this),ge(this,Lo,ce(Ge,16,this,this.isDragSource?"dragging":"idle")),ce(Ge,19,this),this.type=i,this.sensors=o,this.modifiers=s,this.alignment=u.alignment,this.plugins=a}pluginConfig(t){if(this.plugins)for(const n of this.plugins){const r=pr(n);if(r.plugin===t)return r.options}}get isDropping(){return this.status==="dropping"&&this.isDragSource}get isDragging(){return this.status==="dragging"&&this.isDragSource}get isDragSource(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.source)==null?void 0:n.id)===this.id}};Ge=Dn(Gi);jo=new WeakMap;Ro=new WeakMap;Lo=new WeakMap;he(Ge,4,"type",Pc,ht,jo);he(Ge,4,"modifiers",Ac,ht,Ro);he(Ge,4,"status",Dc,ht,Lo);he(Ge,2,"isDropping",Ic,ht);he(Ge,2,"isDragging",Cc,ht);he(Ge,2,"isDragSource",Ec,ht);Zt(Ge,ht);var Mc,jc,Rc,Lc,Nc,Fc,qi,Pe,No,Fo,zo,Wo,Bo,pt=class extends(qi=Gs,Fc=[fe],Nc=[fe],Lc=[fe],Rc=[fe],jc=[fe],Mc=[Ee],qi){constructor(t,n){var r=t,{accept:s,collisionDetector:i,collisionPriority:o,type:a}=r,l=yc(r,["accept","collisionDetector","collisionPriority","type"]);super(l,n),ce(Pe,5,this),ge(this,No,ce(Pe,8,this)),ce(Pe,11,this),ge(this,Fo,ce(Pe,12,this)),ce(Pe,15,this),ge(this,zo,ce(Pe,16,this)),ce(Pe,19,this),ge(this,Wo,ce(Pe,20,this)),ce(Pe,23,this),ge(this,Bo,ce(Pe,24,this)),ce(Pe,27,this),this.accept=s,this.collisionDetector=i,this.collisionPriority=o,this.type=a}accepts(t){const{accept:n}=this;return n?typeof n=="function"?n(t):t.type?Array.isArray(n)?n.includes(t.type):t.type===n:!1:!0}get isDropTarget(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.target)==null?void 0:n.id)===this.id}};Pe=Dn(qi);No=new WeakMap;Fo=new WeakMap;zo=new WeakMap;Wo=new WeakMap;Bo=new WeakMap;he(Pe,4,"accept",Fc,pt,No);he(Pe,4,"type",Nc,pt,Fo);he(Pe,4,"collisionDetector",Lc,pt,zo);he(Pe,4,"collisionPriority",Rc,pt,Wo);he(Pe,4,"shape",jc,pt,Bo);he(Pe,2,"isDropTarget",Mc,pt);Zt(Pe,pt);var ph=class{constructor(){this.registry=new Map}addEventListener(e,t){const{registry:n}=this,r=new Set(n.get(e));return r.add(t),n.set(e,r),()=>this.removeEventListener(e,t)}removeEventListener(e,t){const{registry:n}=this,r=new Set(n.get(e));r.delete(t),n.set(e,r)}dispatch(e,...t){const{registry:n}=this,r=n.get(e);if(r)for(const s of r)s(...t)}},gh=class extends ph{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function as(e,t=!0){let n=!1;return Eo(Oo({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var mh=class extends Dr{constructor(e){super(e);const t=(r,s)=>r.map(({id:i})=>i).join("")===s.map(({id:i})=>i).join("");let n=[];this.destroy=Er(()=>{const{dragOperation:r,collisionObserver:s}=e;r.status.initializing&&(n=[],s.enable())},()=>{const{collisionObserver:r,monitor:s}=e,{collisions:i}=r;if(r.isDisabled()||Gs.pendingIdChanges)return;const o=as({collisions:i});if(s.dispatch("collision",o),o.defaultPrevented||t(i,n))return;n=i;const[a]=i;ue(()=>{var l;a?.id!==((l=e.dragOperation.target)==null?void 0:l.id)&&(r.disable(),e.actions.setDropTarget(a?.id).then(()=>{r.enable()}))})})}},An=(e=>(e[e.Lowest=0]="Lowest",e[e.Low=1]="Low",e[e.Normal=2]="Normal",e[e.High=3]="High",e[e.Highest=4]="Highest",e))(An||{}),Pn=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(Pn||{}),zc,Wc,Bc,Gc,qc,Kc,Uc,rt,Go;Uc=[fe],Kc=[Ee],qc=[Ee],Gc=[Ee],Bc=[Ee],Wc=[Ee],zc=[Ee];var kt=class{constructor(){ce(rt,5,this),ge(this,Go,ce(rt,8,this,"idle")),ce(rt,11,this)}get current(){return this.value}get idle(){return this.value==="idle"}get initializing(){return this.value==="initializing"}get initialized(){const{value:e}=this;return e!=="idle"&&e!=="initialization-pending"}get dragging(){return this.value==="dragging"}get dropped(){return this.value==="dropped"}set(e){this.value=e}};rt=Dn(null);Go=new WeakMap;he(rt,4,"value",Uc,kt,Go);he(rt,2,"current",Kc,kt);he(rt,2,"idle",qc,kt);he(rt,2,"initializing",Gc,kt);he(rt,2,"initialized",Bc,kt);he(rt,2,"dragging",Wc,kt);he(rt,2,"dropped",zc,kt);Zt(rt,kt);var vh=class{constructor(e){this.manager=e}setDragSource(e){const{dragOperation:t}=this.manager;t.sourceIdentifier=typeof e=="string"||typeof e=="number"?e:e.id}setDropTarget(e){return ue(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=as({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return ue(()=>{const{dragOperation:t}=this.manager;if(e.source!=null&&this.setDragSource(e.source),!t.source)throw new Error("Cannot start a drag operation without a drag source");if(!t.status.idle)throw new Error("Cannot start a drag operation while another is active");const r=new AbortController,{event:s,coordinates:i}=e;Te(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=s??null,t.position.reset(i)});const o=as({operation:t.snapshot()});return this.manager.monitor.dispatch("beforedragstart",o),o.defaultPrevented?(t.reset(),r.abort(),r):(t.status.set("initializing"),t.controller=r,this.manager.renderer.rendering.then(()=>{if(r.signal.aborted)return;const{status:a}=t;a.current==="initializing"&&Te(()=>{t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:s,operation:t.snapshot(),cancelable:!1})})}),r)})}move(e){return ue(()=>{var t,n;const{dragOperation:r}=this.manager,{status:s,controller:i}=r;if(!s.dragging||!i||i.signal.aborted)return;const o=as({nativeEvent:e.event,operation:r.snapshot(),by:e.by,to:e.to},(t=e.cancelable)!=null?t:!0);((n=e.propagate)==null||n)&&this.manager.monitor.dispatch("dragmove",o),queueMicrotask(()=>{var a,l,u,d,c;if(o.defaultPrevented)return;const f=(c=e.to)!=null?c:{x:r.position.current.x+((l=(a=e.by)==null?void 0:a.x)!=null?l:0),y:r.position.current.y+((d=(u=e.by)==null?void 0:u.y)!=null?d:0)};r.position.current=f})})}stop(e={}){return ue(()=>{var t,n;const{dragOperation:r}=this.manager,{controller:s}=r;if(!s||s.signal.aborted)return;let i;const o=()=>{const l={resume:()=>{},abort:()=>{}};return i=new Promise((u,d)=>{l.resume=u,l.abort=d}),l};s.abort();const a=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const l=ue(()=>{var d;return((d=r.source)==null?void 0:d.status)==="dropping"}),u=()=>{r.controller===s&&(r.controller=void 0),r.reset()};if(l){const{source:d}=r,c=st(()=>{d?.status==="idle"&&(c(),u())})}else this.manager.renderer.rendering.then(u)})};r.canceled=(t=e.canceled)!=null?t:!1,this.manager.monitor.dispatch("dragend",{nativeEvent:e.event,operation:r.snapshot(),canceled:(n=e.canceled)!=null?n:!1,suspend:o}),i?i.then(a).catch(()=>r.reset()):a()})}},xn=class extends We{constructor(e,t){super(e,t),this.manager=e,this.options=t}},bh=class extends AbortController{constructor(e,t){super(),this.constraints=e,this.onActivate=t,this.activated=!1;for(const n of e??[])n.controller=this}onEvent(e){var t;if(!this.activated)if((t=this.constraints)!=null&&t.length)for(const n of this.constraints)n.onEvent(e);else this.activate(e)}activate(e){this.activated||(this.activated=!0,this.onActivate(e))}abort(e){this.activated=!1,super.abort(e)}},ls,Vc=class{constructor(e){this.options=e,ge(this,ls)}set controller(e){Ze(this,ls,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=Oe(this,ls))==null||t.activate(e)}};ls=new WeakMap;var Ga=class extends We{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},yh=class{constructor(e){this.draggables=new Ba,this.droppables=new Ba,this.plugins=new di(e),this.sensors=new di(e),this.modifiers=new di(e)}register(e,t){if(e instanceof ht)return this.draggables.register(e.id,e);if(e instanceof pt)return this.droppables.register(e.id,e);if(e.prototype instanceof Ga)return this.modifiers.register(e,t);if(e.prototype instanceof xn)return this.sensors.register(e,t);if(e.prototype instanceof We)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof Gs)return e instanceof ht?this.draggables.unregister(e.id,e):e instanceof pt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof Ga)return this.modifiers.unregister(e);if(e.prototype instanceof xn)return this.sensors.unregister(e);if(e.prototype instanceof We)return this.plugins.unregister(e);throw new Error("Invalid instance type")}destroy(){this.draggables.destroy(),this.droppables.destroy(),this.plugins.destroy(),this.sensors.destroy(),this.modifiers.destroy()}},Hc,Xc,Yc,Zc,Qc,Jc,ed,td,nd,Hn,cs,cn,$e,qo,Ko,Uo,Vo,Ho,Xn;nd=[Ee],td=[fe],ed=[fe],Jc=[fe],Qc=[fe],Zc=[fe],Yc=[Ee],Xc=[Ee],Hc=[Ee];var ct=class{constructor(e){ce($e,5,this),ge(this,Hn),ge(this,cs),ge(this,cn,new Yt(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new kt,ge(this,qo,ce($e,8,this,!1)),ce($e,11,this),ge(this,Ko,ce($e,12,this,null)),ce($e,15,this),ge(this,Uo,ce($e,16,this,null)),ce($e,19,this),ge(this,Vo,ce($e,20,this,null)),ce($e,23,this),ge(this,Ho,ce($e,24,this,[])),ce($e,27,this),this.position=new Bs({x:0,y:0}),ge(this,Xn,{x:0,y:0}),Ze(this,Hn,e)}get shape(){const{current:e,initial:t,previous:n}=Oe(this,cn);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?Oe(this,cn).current=e:Oe(this,cn).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=Oe(this,Hn).registry.draggables.get(t);return n&&Ze(this,cs,n),(e=n??Oe(this,cs))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=Oe(this,Hn).registry.droppables.get(t))!=null?e:null}get transform(){const{x:e,y:t}=this.position.delta;let n={x:e,y:t};for(const r of this.modifiers)n=r.apply(Eo(Oo({},this.snapshot()),{transform:n}));return Ze(this,Xn,n),n}snapshot(){return ue(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:Oe(this,Xn),shape:this.shape?ci(this.shape):null,position:ci(this.position),status:ci(this.status),canceled:this.canceled}))}reset(){Te(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,Oe(this,cn).reset(),this.position.reset({x:0,y:0}),Ze(this,Xn,{x:0,y:0}),this.modifiers=[]})}};$e=Dn(null);Hn=new WeakMap;cs=new WeakMap;cn=new WeakMap;qo=new WeakMap;Ko=new WeakMap;Uo=new WeakMap;Vo=new WeakMap;Ho=new WeakMap;Xn=new WeakMap;he($e,2,"shape",nd,ct);he($e,4,"canceled",td,ct,qo);he($e,4,"activatorEvent",ed,ct,Ko);he($e,4,"sourceIdentifier",Jc,ct,Uo);he($e,4,"targetIdentifier",Qc,ct,Vo);he($e,4,"modifiers",Zc,ct,Ho);he($e,2,"source",Yc,ct);he($e,2,"target",Xc,ct);he($e,2,"transform",Hc,ct);Zt($e,ct);var xh={get rendering(){return Promise.resolve()}};function lt(e,t){return typeof e=="function"?e(t):e??t}var wh=class{constructor(t){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(f=>f.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var n;const r=t??{},s=lt(r.plugins,[]),i=lt(r.sensors,[]),o=lt(r.modifiers,[]),a=(n=r.renderer)!=null?n:xh,l=new gh(this),u=new yh(this);this.registry=u,this.monitor=l,this.renderer=a,this.actions=new vh(this),this.dragOperation=new ct(this),this.collisionObserver=new hh(this),this.plugins=[mh,...s],this.modifiers=o,this.sensors=i;const{destroy:d}=this,c=Er(()=>{var f,p,h;const m=ue(()=>this.dragOperation.modifiers),y=this.modifiers;for(const w of m)y.includes(w)||w.destroy();this.dragOperation.modifiers=(h=(p=(f=this.dragOperation.source)==null?void 0:f.modifiers)==null?void 0:p.map(w=>{const{plugin:v,options:g}=pr(w);return new v(this,g)}))!=null?h:y});this.destroy=()=>{c(),d()}}get plugins(){return this.registry.plugins.values}set plugins(t){this.registry.plugins.values=t}get modifiers(){return this.registry.modifiers.values}set modifiers(t){this.registry.modifiers.values=t}get sensors(){return this.registry.sensors.values}set sensors(t){this.registry.sensors.values=t}},rd=e=>{throw TypeError(e)},Xo=(e,t,n)=>t.has(e)||rd("Cannot "+n),le=(e,t,n)=>(Xo(e,t,"read from private field"),t.get(e)),Ve=(e,t,n)=>t.has(e)?rd("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ye=(e,t,n,r)=>(Xo(e,t,"write to private field"),t.set(e,n),n),sd=(e,t,n)=>(Xo(e,t,"access private method"),n);function qs(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function id(e,t){const n=e.getAnimations();let r=null;for(const s of n){if(s.playState!=="running")continue;const{effect:i}=s,a=(qs(i)?i.getKeyframes():[]).filter(t);a.length>0&&(r=[a[a.length-1],s])}return r}function Ks(e){const{width:t,height:n,top:r,left:s,bottom:i,right:o}=e.getBoundingClientRect();return{width:t,height:n,top:r,left:s,bottom:i,right:o}}function Yo(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Ar(e){return"nodeType"in e}function Qe(e){var t,n,r;return e?Yo(e)?e:Ar(e)?"defaultView"in e?(t=e.defaultView)!=null?t:window:(r=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?r:window:window:window}function Zo(e){const{Document:t}=Qe(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function Pt(e){return!e||Yo(e)?!1:e instanceof Qe(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function od(e){return e instanceof Qe(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function Mn(e){return e?Yo(e)?e.document:Ar(e)?Zo(e)?e:Pt(e)||od(e)?e.ownerDocument:document:document:document}function _h(e){var t,n,r,s;const{documentElement:i}=Mn(e),o=Qe(e).visualViewport,a=(t=o?.width)!=null?t:i.clientWidth,l=(n=o?.height)!=null?n:i.clientHeight,u=(r=o?.offsetTop)!=null?r:0,d=(s=o?.offsetLeft)!=null?s:0;return{top:u,left:d,right:d+a,bottom:u+l,width:a,height:l}}function kh(e,t){if(Sh(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:s}=getComputedStyle(e);return n==="visible"&&r==="visible"&&s==="visible"}function Sh(e){return e.tagName==="DETAILS"}function mr(e,t=e.getBoundingClientRect(),n=0){var r,s,i,o,a;let l=t;const{ownerDocument:u}=e,d=(r=u.defaultView)!=null?r:window;let c=e.parentElement;for(;c&&c!==u.documentElement;){if(!kh(c)){const g=c.getBoundingClientRect(),b=n*(g.bottom-g.top),_=n*(g.right-g.left),O=n*(g.bottom-g.top),I=n*(g.right-g.left);l={top:Math.max(l.top,g.top-b),right:Math.min(l.right,g.right+_),bottom:Math.min(l.bottom,g.bottom+O),left:Math.max(l.left,g.left-I),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top}c=c.parentElement}const f=d.visualViewport,p=(s=f?.offsetTop)!=null?s:0,h=(i=f?.offsetLeft)!=null?i:0,m=(o=f?.width)!=null?o:d.innerWidth,y=(a=f?.height)!=null?a:d.innerHeight,w=n*y,v=n*m;return l={top:Math.max(l.top,p-w),right:Math.min(l.right,h+m+v),bottom:Math.min(l.bottom,p+y+w),left:Math.max(l.left,h-v),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top,l.width<0&&(l.width=0),l.height<0&&(l.height=0),l}function wn(e){return{x:e.clientX,y:e.clientY}}var ad=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ki(e=document,t=new Set){if(t.has(e))return[];t.add(e);const n=[e];for(const r of Array.from(e.querySelectorAll("iframe, frame")))try{const s=r.contentDocument;s&&!t.has(s)&&n.push(...Ki(s,t))}catch{}try{const r=e.defaultView;if(r&&r!==window.top){const s=r.parent;s&&s.document&&s.document!==e&&n.push(...Ki(s.document,t))}}catch{}return n}function Qo(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function ld(){var e,t;const n=Qo()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function Jo(e){return!e||!Ar(e)?!1:e instanceof Qe(e).ShadowRoot}function ks(e){if(e&&Ar(e)){let t=e.getRootNode();if(Jo(t))return t;if(t instanceof Document)return t}return Mn(e)}function ea(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function $h(e){const t="input, textarea, select, canvas, [contenteditable]",n=e.cloneNode(!0),r=Array.from(e.querySelectorAll(t));return Array.from(n.querySelectorAll(t)).forEach((i,o)=>{const a=r[o];if(qa(i)&&qa(a)&&(i.type!=="file"&&(i.value=a.value),i.type==="radio"&&i.name&&(i.name=`Cloned__${i.name}`)),Ka(i)&&Ka(a)&&a.width>0&&a.height>0){const l=i.getContext("2d");l?.drawImage(a,0,0)}}),n}function qa(e){return"value"in e}function Ka(e){return e.tagName==="CANVAS"}function cd(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(Th(r)){const{contentDocument:s}=r;if(s){const{left:i,top:o}=r.getBoundingClientRect();return cd(s,{x:t-i,y:n-o})}}return r}function Th(e){return e?.tagName==="IFRAME"}var Ui=new WeakMap;function Oh(e){return e.closest(`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react/jsx-runtime"),O=require("../useCompiledDocument-oocN5cGE.cjs.js"),$=require("@mui/material"),k=require("react"),Be=require("../ServerProvider-DuEOzwPc.cjs.js"),ge=require("../text-entry-BJwltZiy.cjs.js"),nf=require("react-dom"),rf=require("@malloydata/malloy-tag"),ql=require("@tanstack/react-query"),sf={line_chart:"Line",bar_chart:"Bar",big_value:"Big value",scatter_chart:"Scatter",shape_map:"Shape map",segment_map:"Segment map"};function of(e,t,n){const r=e!==void 0?void 0:n==="loading"?"Still loading this view's details":n==="unlisted"?"Not a view the catalog lists, so its shape is unknown":void 0,s=o=>{if(t!==o){if(o==="big_value")return e?.aggregateOnly===!0?void 0:r??"Needs a view with only totals (no group by)";if(o==="shape_map"||o==="segment_map")return e?.chart===o?void 0:r??"Needs a view that already carries a map chart"}};return[{value:"default",label:"From the view"},{value:"none",label:"Table"},...["line_chart","bar_chart","big_value","scatter_chart","shape_map","segment_map"].map(o=>{const a=s(o);return{value:o,label:sf[o],...a?{disabled:!0,reason:a}:{}}}),...t==="custom"?[{value:"custom",label:"As written"}]:[]]}function Di({state:e,view:t,viewStatus:n,cellLabel:r,disabledReason:s,onOpen:i,onChange:o,variant:a="standard"}){const l=of(t,e,n),d=k.useId();return x.jsx($.TextField,{select:!0,size:"small",variant:a,label:"Viz type",value:e,disabled:s!==void 0,onChange:u=>{const c=u.target.value;l.find(f=>f.value===c)?.disabled||o(c)},helperText:s,FormHelperTextProps:{id:d},SelectProps:{...i?{onOpen:i}:{},renderValue:u=>l.find(c=>c.value===u)?.label??String(u),MenuProps:{MenuListProps:{disabledItemsFocusable:!0}},SelectDisplayProps:{"aria-label":`Viz type, ${r}`,"aria-labelledby":void 0,...s?{"aria-describedby":d}:{}}},sx:{minWidth:140},children:l.map(u=>x.jsx($.MenuItem,{value:u.value,disabled:u.value==="custom"||u.disabled===!0,children:x.jsx($.ListItemText,{primary:u.label,...u.reason?{secondary:u.reason}:{}})},u.value))})}function af({sources:e,source:t,view:n,onSource:r,onView:s}){const{theme:i}=Be.usePublisherTheme(),o=e.find(a=>a.name===t);return x.jsxs(x.Fragment,{children:[x.jsx($.TextField,{select:!0,size:"small",label:"Source",value:t,onChange:a=>r(a.target.value),inputProps:{"aria-label":"Source"},children:e.map(a=>x.jsxs($.MenuItem,{value:a.name,disabled:a.views.length===0,children:[a.name,a.views.length===0&&x.jsx($.Typography,{component:"span",variant:"caption",sx:{ml:1},children:"declares no views"}),a.description&&x.jsx($.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:a.description})]},a.name))}),x.jsxs($.Box,{children:[x.jsx($.Typography,{variant:"subtitle2",sx:{mb:.5},children:"View"}),x.jsxs($.List,{dense:!0,disablePadding:!0,"aria-label":"Views",sx:{maxHeight:"min(280px, 30vh)",overflowY:"auto",border:i.border,borderRadius:1},children:[(o?.views??[]).map(a=>x.jsxs($.ListItemButton,{selected:n===a.name,onClick:()=>s(a.name),"aria-label":`View ${a.name}`,children:[x.jsx($.ListItemText,{primary:a.name,secondary:a.description,primaryTypographyProps:{fontFamily:"ui-monospace, monospace",fontSize:13}}),a.chart&&x.jsx($.Chip,{size:"small",variant:"outlined",label:a.chart.replace(/_chart$/,"")})]},a.name)),o&&o.views.length===0&&x.jsx($.Typography,{variant:"body2",sx:{p:1.5,color:i.tileTitle},children:"This source declares no views."})]})]})]})}function lf({open:e,document:t,catalog:n,columns:r,onClose:s,onAdd:i,onAddText:o}){const{theme:a}=Be.usePublisherTheme(),l=k.useMemo(()=>n?.sources??[],[n]),[d,u]=k.useState("query"),[c,f]=k.useState(""),[h,p]=k.useState(""),[m,b]=k.useState(""),[w,v]=k.useState("default"),[g,y]=k.useState(Math.ceil(r/2));k.useEffect(()=>{if(!e)return;u("query");const T=D=>l.some(q=>q.name===D&&q.views.length>0);f(t.sources.map(D=>D.base).find(T)??l.find(D=>D.views.length>0)?.name??""),p(""),b(""),v("default"),y(Math.ceil(r/2))},[e,t,l,r]);const _=c!==""&&h!=="",S=[c,h].filter(T=>T!==""&&!ge.isBareName(T)).map(T=>`"${T}" is not a plain Malloy name, so a tile cannot be written for it.`)[0],E=l.find(T=>T.name===c),A=E?.views.find(T=>T.name===h);return x.jsx(O.AppDialog,{open:e,onClose:s,title:"Add a tile",description:"A tile shows one view of a source in this package.",actions:x.jsxs(x.Fragment,{children:[x.jsx($.Button,{onClick:s,children:"Cancel"}),x.jsx($.Button,{variant:"contained",disabled:d==="query"&&(!_||S!==void 0),onClick:()=>d==="text"?o():i({base:c,modelPath:E?.modelPath??"",...E?.exporters?{exporters:E.exporters}:{},view:h,...m.trim()?{label:m.trim()}:{},...w!=="default"?{chart:w,...A?{chartCarried:A.chart?[A.chart]:[]}:{}}:{},colspan:g}),children:d==="text"?"Add text":"Add tile"})]}),children:x.jsxs($.Stack,{sx:{gap:2,pt:1},children:[x.jsxs($.ToggleButtonGroup,{size:"small",exclusive:!0,value:d,"aria-label":"Tile type",onChange:(T,D)=>{D!==null&&u(D)},children:[x.jsx($.ToggleButton,{value:"query",sx:{px:1.5},children:"Query"}),x.jsx($.ToggleButton,{value:"text",sx:{px:1.5},children:"Text"})]}),d==="text"?x.jsx($.Typography,{variant:"body2",sx:{color:a.tileTitle},children:"A text tile holds markdown: a heading, a paragraph, a list. It is added empty, and written on the tile itself."}):l.length===0?x.jsx($.Typography,{variant:"body2",sx:{color:a.tileTitle},children:n?"This package publishes no source with a view to put on a tile.":"The package's sources are still loading."}):x.jsxs(x.Fragment,{children:[x.jsx(af,{sources:l,source:c,view:h,onSource:T=>{f(T),p("")},onView:T=>{p(T),v("default")}}),S&&x.jsx($.Typography,{variant:"body2",color:"error",children:S}),x.jsx(Di,{state:w,view:A,cellLabel:"new tile",variant:"outlined",...A?{}:{disabledReason:"Pick a view to choose its chart."},onChange:T=>v(T)}),x.jsx($.Stack,{direction:"row",sx:{gap:1.5},children:x.jsx($.TextField,{size:"small",label:"Title",placeholder:"Uses the view's name",value:m,onChange:T=>b(T.target.value),inputProps:{"aria-label":"Tile title"},sx:{flex:1}})})]})]})})}const Re=e=>e.kind==="text",xe=e=>e.kind!=="text",Kr=e=>xe(e)?e.label??e.name:e.name,Fe=e=>Re(e)?`text.${e.name}`:`${e.source}.${e.name}`,ai="self";function cf({open:e,document:t,source:n,givenNames:r,dashboards:s,onClose:i,onApply:o}){const{theme:a}=Be.usePublisherTheme(),[l,d]=k.useState([]);k.useEffect(()=>{if(!e||!n)return;const p=(t.drills??[]).filter(m=>m.source===n.name);d((n.dimensions??[]).map(m=>{const b=p.find(w=>w.name===m.name);return{name:m.name,expression:m.expression,to:b?.to??[],given:b?.given??""}}))},[e,n,t]);const u=(p,m)=>d(b=>b.map((w,v)=>{if(v!==p)return w;const g={...w};return m(g),g})),c=[ai,...s.filter(p=>p!==ai)],f=p=>p===ai?"This report":p,h=()=>{n&&(o(l.filter(p=>p.to.length>0).map(p=>({source:n.name,name:p.name,expression:p.expression,to:p.to,...p.given?{given:p.given}:{}}))),i())};return x.jsx(O.AppDialog,{open:e,onClose:i,title:"Drill",description:"A cell in a column that groups by one of these dimensions becomes a link. Clicking it writes the value into a control — here, or on the report it opens.",actions:x.jsxs(x.Fragment,{children:[x.jsx($.Button,{onClick:i,children:"Cancel"}),x.jsx($.Button,{variant:"contained",onClick:h,disabled:l.length===0,children:"Apply"})]}),children:x.jsx($.Stack,{sx:{gap:2,pt:1},children:l.length===0?x.jsx($.Typography,{variant:"body2",sx:{color:a.tileTitle},children:n?x.jsxs(x.Fragment,{children:[x.jsx($.Box,{component:"code",children:n.name})," declares no dimensions of its own in this file. A drill is a tag on the dimension's declaration, so a dimension the model declares is made clickable in the model; to make one clickable here, declare it in"," ",x.jsx($.Box,{component:"code",children:n.name})," and group by it."]}):"This tile's source is not declared in this file."}):l.map((p,m)=>x.jsxs($.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr)"},gap:1.5,alignItems:"start"},children:[x.jsxs($.Box,{sx:{minWidth:0,pt:.75},children:[x.jsx($.Typography,{variant:"body2",sx:{fontFamily:"ui-monospace, monospace",fontSize:13},children:p.name}),x.jsxs($.Typography,{variant:"caption",sx:{color:a.tileTitle,display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:p.expression,children:["is ",p.expression]})]}),x.jsx($.TextField,{select:!0,size:"small",label:"Clicks go to",value:p.to,inputProps:{"aria-label":`Where ${p.name} goes`},SelectProps:{multiple:!0,renderValue:b=>b.length===0?"Not clickable":b.map(f).join(", "),displayEmpty:!0},InputLabelProps:{shrink:!0},onChange:b=>u(m,w=>{const v=b.target.value;w.to=Array.isArray(v)?v:String(v).split(",").filter(Boolean)}),children:c.map(b=>x.jsxs($.MenuItem,{value:b,children:[x.jsx($.Checkbox,{size:"small",checked:p.to.includes(b),sx:{p:0,mr:1}}),x.jsx($.ListItemText,{primary:f(b)})]},b))}),x.jsxs($.TextField,{select:!0,size:"small",label:"Sets the filter",value:p.given,disabled:p.to.length===0,inputProps:{"aria-label":`Control ${p.name} sets`},SelectProps:{displayEmpty:!0},InputLabelProps:{shrink:!0},helperText:p.given===""?`Named ${p.name}, like the dimension`:void 0,onChange:b=>u(m,w=>{w.given=b.target.value}),children:[x.jsx($.MenuItem,{value:"",children:x.jsx("em",{children:"Same name as the dimension"})}),r.map(b=>x.jsx($.MenuItem,{value:b,children:b},b))]})]},p.name))})})}function uf(e,t=[]){const n=new Map;for(const i of e.tiles)for(const o of xe(i)?i.filters??[]:[])n.set(o.given,(n.get(o.given)??0)+1);const r=[],s=new Set;for(const i of e.localGivens??[])s.add(i.name),r.push({name:i.name,...i.label===void 0?{}:{label:i.label},type:i.type,...i.suggest?{field:i.suggest.dimension}:{},origin:"dashboard",local:i,boundTiles:n.get(i.name)??0});for(const i of t)s.has(i.name)||(s.add(i.name),r.push({...i,origin:"model",boundTiles:n.get(i.name)??0}));for(const[i,o]of n)s.has(i)||r.push({name:i,origin:"model",boundTiles:o});return r}function _s(e){if(!(e===void 0||e.startsWith("filter<")))return e==="string"||e==="boolean"?"=":">="}function df(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function as(e,t){const n=df(e),r=t?.replace(/_type$/,"");if(!n||!r)return!0;const s=new Set(["date","timestamp"]);return s.has(n)?s.has(r):n===r}function Ma(e){switch(e?.replace(/_type$/,"")){case"string":return"text";case"number":return"a number";case"date":return"a date";case"timestamp":return"a timestamp";case"boolean":return"true or false";default:return e??"an unknown type"}}function ff(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const hf=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function pf(e,t){const r=(e.split(".").at(-1)??"").split(/[^A-Za-z0-9]+/).filter(Boolean).join("_").toUpperCase()||"FILTER",s=/^[A-Z_]/.test(r)?r:`F_${r}`,i=ge.isStrictName(s)?s:`${s}_FILTER`,o=new Set(t);if(!o.has(i))return i;for(let a=2;;a++)if(!o.has(`${i}_${a}`))return`${i}_${a}`}const Pa=[{kind:"select",label:"Pick one",hint:"A dropdown of the field's values"},{kind:"multiselect",label:"Pick several",hint:"The same, taking more than one"},{kind:"text",label:"Text",hint:"A box taking Malloy filter syntax"},{kind:"number",label:"Number range",hint:"A slider over the field's values"},{kind:"date",label:"On or after a date",hint:"A date picker; tiles keep rows on or after it"}];function Vr(e){const t=e.label.trim()||e.name,n=e.field;switch(e.kind){case"select":case"multiselect":return{name:e.name,type:"filter<string>",default:"f''",label:t,control:e.kind,...e.source?{suggest:{source:e.source,dimension:n}}:{}};case"text":return{name:e.name,type:"filter<string>",default:"f''",label:t};case"number":return{name:e.name,type:"filter<number>",default:"f''",label:t,...e.range?{rangeMin:e.range.min,rangeMax:e.range.max}:{}};case"date":return{name:e.name,type:"date",default:`@${e.dateDefault??new Date().toISOString().slice(0,10)}`,label:t}}}const Ai=e=>xe(e)&&e.declaration.kind!=="inherited"&&e.declaration.kind!=="opaque";function gf(e,t){return e.tiles.map(n=>{const r=(xe(n)?n.filters??[]:[]).find(s=>s.given===t.name);return{include:r!==void 0,field:r?.field??t.field??t.name.toLowerCase(),...r?.op!==void 0?{op:r.op}:_s(t.type)!==void 0?{op:_s(t.type)}:{}}})}function mf(e,t,n){n.forEach((r,s)=>{const i=e.tiles[s];if(!i||!Ai(i))return;const o=(i.filters??[]).filter(l=>l.given!==t),a=r.include?[...o,{field:r.field.trim()||t.toLowerCase(),given:t,...r.op&&r.op!=="~"?{op:r.op}:{}}]:o;a.length>0?i.filters=a:delete i.filters})}function vf(e,t){const n=(e.localGivens??[]).filter(i=>i.name!==t.name),r=(e.localGivens??[]).findIndex(i=>i.name===t.name),s=[...n];s.splice(r>=0?r:s.length,0,t),e.localGivens=s}function yf(e,t){for(const r of e.tiles){if(!xe(r))continue;const s=(r.filters??[]).filter(i=>i.given!==t);s.length>0?r.filters=s:delete r.filters}const n=(e.localGivens??[]).filter(r=>r.name!==t);n.length>0?e.localGivens=n:delete e.localGivens}const Kl=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function bf({open:e,document:t,control:n,available:r,fieldsFor:s,onApply:i}){const o=k.useRef(n);e&&(o.current=n);const a=e?n:o.current,l=a!==void 0,[d,u]=k.useState({kind:"new"}),[c,f]=k.useState(""),[h,p]=k.useState("select"),[m,b]=k.useState(""),[w,v]=k.useState(""),[g,y]=k.useState([]),[_,S]=k.useState(!1),[E,A]=k.useState(!1),T=j=>t.sources.find(F=>F.name===j.source)?.base??j.source;k.useEffect(()=>{if(e)if(A(n!==void 0),n){u({kind:"existing",name:n.name}),f(n.label??"");const j=gf(t,n);y(j);const F=j.filter(ue=>ue.include),re=new Set(F.map(ue=>ue.field));v(re.size===1?F[0].field:n.field??""),S(re.size>1)}else u({kind:"new"}),f(""),p("select"),v(""),b(new Date().toISOString().slice(0,10)),y(t.tiles.map(j=>({include:Ai(j),field:""}))),S(!1)},[e,n,t]);const D=k.useMemo(()=>[...(t.localGivens??[]).map(j=>j.name),...r.map(j=>j.name)],[t,r]),q=k.useMemo(()=>w.trim()?pf(w.trim(),D):"",[w,D]),P=d.kind==="existing"?n??r.find(j=>j.name===d.name):q?{name:q,type:Vr({name:q,label:c,kind:h,field:w}).type}:void 0,z=P?.type!==void 0&&!P.type.startsWith("filter<"),U=g.find(j=>j.include)?.op??_s(P?.type),K=(j,F)=>{A(!0),y(re=>re.map((ue,je)=>je===j?{...ue,...F}:ue))},Z=j=>{A(!0),y(F=>F.map(re=>({...re,op:j})))},J=j=>{const F=_s(j);y(re=>re.map(({op:ue,...je})=>F?{...je,op:F}:je))},ie=j=>{A(!0),u({kind:"existing",name:j.name}),v(j.field??""),J(j.type)},de=j=>{A(!0),p(j),J(Vr({name:"X",label:c,kind:j,field:w}).type)},I=t.tiles.map(Ai),V=I.filter(Boolean).length,B=g.filter((j,F)=>j.include&&I[F]).length,R=t.tiles.filter((j,F)=>(g[F]?.include??!1)&&I[F]&&xe(j)),G=R.length>0?R:t.tiles.filter((j,F)=>I[F]&&xe(j)),ne=k.useMemo(()=>{const j=new Map;let F=!1;for(const re of G){const ue=s?.(re);if(ue){F=!0;for(const je of ue)j.has(je.name)||j.set(je.name,je)}}return F?[...j.values()]:void 0},[g,t.tiles,s]),Y=(()=>{const j=w.trim();for(const F of R){const re=s?.(F);if(!re||re.some(ue=>ue.name===j))return T(F)}return R[0]?T(R[0]):t.sources[0]?.base})(),H=j=>{A(!0),y(F=>F.map((re,ue)=>({...re,include:j&&I[ue]})))},L=k.useMemo(()=>_?g:g.map(j=>({...j,field:w})),[_,g,w]),C=j=>{for(const F of G){const re=s?.(F)?.find(ue=>ue.name===j.trim());if(re?.type)return re.type}},W=j=>as(P?.type,j.type),M=(j,F)=>{if(j.trim()==="")return"Pick the field this filter compares.";const re=F?s?.(F):void 0;if(!re)return;const ue=re.find(je=>je.name===j.trim());if(!ue)return`Not a field of ${F?T(F):"the tiles' source"}.`;if(ue.type&&!as(P?.type,ue.type))return`${j.trim()} is ${Ma(ue.type)}; this filter compares ${Ma(P?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},ee=j=>{if(A(!0),v(j),l||d.kind!=="new")return;const F=C(j),re=Vr({name:"X",label:c,kind:h,field:j}).type;F&&!as(re,F)&&de(ff(F))},X=j=>{const F=t.tiles[j];return F&&xe(F)?F:void 0},le=L.map((j,F)=>j.include&&I[F]?M(j.field,X(F)):void 0),ce=le.every(j=>j===void 0),N=E?le:le.map(()=>{}),Q=E&&!_&&B>0?R.map(j=>M(w,j)).find(Boolean):void 0,me=P!==void 0&&ce&&(d.kind==="existing"||w.trim()!==""&&q!==""),se=()=>{if(!(!P||!me))if(d.kind==="new")i(P.name,L,Vr({name:P.name,label:c.trim()||Kl(P.name),kind:h,field:w.trim(),...Y?{source:Y}:{},...m?{dateDefault:m}:{}}));else if(n?.origin==="dashboard"&&n.local){const j=c.trim(),F=j!==(n.local.label??"");i(P.name,L,F?{...n.local,...j?{label:j}:{}}:void 0)}else i(P.name,L)},te=l&&a.origin==="model";return{editing:l,shown:a,fromModel:te,source:d,setSource:u,label:c,setLabel:f,kind:h,dateDefault:m,setDateDefault:b,field:w,rows:g,setRows:y,perTile:_,setPerTile:S,newName:q,target:P,valueTyped:z,commonOp:U,setRow:K,setCommonOp:Z,pickExisting:ie,pickKind:de,bindable:I,bindableCount:V,included:B,commonFields:ne,setAll:H,accepts:W,pickField:ee,rowProblems:N,commonProblem:Q,canApply:me,apply:se}}function Ra({value:e,onChange:t,fields:n,accepts:r,label:s,ariaLabel:i,error:o,helperText:a,disabled:l,autoFocus:d,placeholder:u,sx:c}){const f=k.useMemo(()=>(n??[]).filter(p=>r?.(p)??!0).map(p=>p.name),[n,r]),h=k.useMemo(()=>new Map((n??[]).map(p=>[p.name,p.type])),[n]);return x.jsx($.Autocomplete,{freeSolo:!0,size:"small",options:f,inputValue:e,onInputChange:(p,m)=>t(m),value:e,onChange:(p,m)=>t(typeof m=="string"?m:""),disabled:l,disableClearable:!0,renderOption:(p,m)=>k.createElement("li",{...p,key:m},x.jsx($.Typography,{variant:"body2",sx:{flex:1},children:m}),h.get(m)&&x.jsx($.Typography,{variant:"caption",sx:{opacity:.6},children:h.get(m)?.replace(/_type$/,"")})),renderInput:p=>x.jsx($.TextField,{...p,label:s,placeholder:u,autoFocus:d,error:o,helperText:a,inputProps:{...p.inputProps,"aria-label":i}}),sx:c})}const ja=e=>e&&xe(e)&&e.declaration.kind==="opaque"?{label:"Not bindable",reason:`Its body is ${e.declaration.why}, so a filter has no single place to go.`}:{label:"From the model",reason:"Declared on its source, which this report does not write."};function xf({open:e,document:t,control:n,available:r,fieldsFor:s,onClose:i,onApply:o,onRemove:a}){const{theme:l}=Be.usePublisherTheme(),{editing:d,shown:u,fromModel:c,source:f,setSource:h,label:p,setLabel:m,kind:b,dateDefault:w,setDateDefault:v,field:g,rows:y,setRows:_,perTile:S,setPerTile:E,newName:A,target:T,valueTyped:D,commonOp:q,setRow:P,setCommonOp:z,pickExisting:U,pickKind:K,bindable:Z,bindableCount:J,included:ie,commonFields:de,setAll:I,accepts:V,pickField:B,rowProblems:R,commonProblem:G,canApply:ne,apply:Y}=bf({open:e,document:t,control:n,available:r,fieldsFor:s,onApply:o}),H=(L,C,W)=>x.jsx($.TextField,{select:!0,size:"small",label:"Compares",value:L??">=",onChange:M=>C(M.target.value),inputProps:{"aria-label":W},sx:{width:130},children:hf.filter(M=>M.op!=="~").map(M=>x.jsx($.MenuItem,{value:M.op,children:M.label},M.op))});return x.jsx(O.AppDialog,{open:e,onClose:i,title:d?u.label??u.name:"Add a filter",description:d?x.jsxs(x.Fragment,{children:[x.jsxs($.Box,{component:"span",sx:{fontFamily:"ui-monospace, monospace"},children:["$",u.name]}),c?" · declared in the model, so its label and options are set there":" · declared in this report"]}):"A filter on the page, and the tiles it filters.",actions:x.jsxs(x.Fragment,{children:[d&&x.jsx($.Button,{color:"error",startIcon:x.jsx(O.DeleteOutlineIcon,{}),onClick:()=>a(u.name),sx:L=>({mr:"auto",color:O.dangerTextColor(L)}),children:"Remove filter"}),x.jsx($.Button,{onClick:i,children:"Cancel"}),x.jsx($.Tooltip,{title:ne||T===void 0?"":"A ticked tile has no field, or names one its source does not have.",children:x.jsx("span",{children:x.jsx($.Button,{variant:"contained",onClick:Y,disabled:!ne,children:d?"Apply":"Add filter"})})})]}),children:x.jsxs($.Stack,{sx:{gap:2.5,pt:1},children:[!d&&r.length>0&&x.jsxs($.ToggleButtonGroup,{exclusive:!0,size:"small",value:f.kind,onChange:(L,C)=>{C==="new"?h({kind:"new"}):C==="existing"&&r[0]&&U(r[0])},"aria-label":"Where the filter comes from",children:[x.jsx($.ToggleButton,{value:"new",children:"New in this report"}),x.jsx($.ToggleButton,{value:"existing",children:"From the model"})]}),!d&&f.kind==="existing"?x.jsx($.TextField,{select:!0,size:"small",label:"Filter",value:f.name,onChange:L=>{const C=r.find(W=>W.name===L.target.value);C&&U(C)},children:r.map(L=>x.jsxs($.MenuItem,{value:L.name,children:[L.label??L.name,x.jsxs($.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",L.name]})]},L.name))}):null,x.jsxs($.Stack,{direction:"row",sx:{gap:1.5,flexWrap:"wrap"},children:[!S&&x.jsx(Ra,{value:g,onChange:B,fields:de,accepts:V,label:"Field to filter",ariaLabel:"Field to filter",placeholder:"category",autoFocus:!d,error:G!==void 0,helperText:G??(!d&&A?`Declared as $${A}`:void 0),sx:{flex:1,minWidth:200}}),!c&&x.jsx($.TextField,{size:"small",label:"Label",placeholder:A?Kl(A):"",value:p,onChange:L=>m(L.target.value),inputProps:{"aria-label":"Filter label"},sx:{flex:1,minWidth:160}}),D&&!S&&H(q,z,"Comparison")]}),!d&&f.kind==="new"&&x.jsxs($.Stack,{direction:"row",sx:{gap:1.5},children:[x.jsx($.TextField,{select:!0,size:"small",label:"Filter kind",value:b,onChange:L=>K(L.target.value),inputProps:{"aria-label":"Filter kind"},slotProps:{select:{renderValue:L=>Pa.find(C=>C.kind===L)?.label??String(L)}},sx:{flex:1},children:Pa.map(L=>x.jsxs($.MenuItem,{value:L.kind,children:[L.label,x.jsx($.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:L.hint})]},L.kind))}),b==="date"&&x.jsx($.TextField,{size:"small",type:"date",label:"Starts at",value:w,onChange:L=>v(L.target.value),InputLabelProps:{shrink:!0},sx:{flex:1}})]}),x.jsxs($.Box,{children:[x.jsxs($.Stack,{direction:"row",sx:{alignItems:"center",gap:.5},children:[x.jsx($.Checkbox,{size:"small",checked:J>0&&ie===J,indeterminate:ie>0&&ie<J,disabled:J===0,onChange:L=>I(L.target.checked),inputProps:{"aria-label":"All tiles"}}),x.jsxs($.Typography,{variant:"subtitle2",sx:{flex:1},children:["Applies to ",ie," of ",t.tiles.length," tiles"]}),x.jsx($.Button,{size:"small",onClick:()=>{S||_(L=>L.map(C=>({...C,field:g}))),E(L=>!L)},children:S?"Same field for all":"Adjust per tile"})]}),x.jsx($.Stack,{sx:{gap:S?1:0},children:t.tiles.map((L,C)=>{if(!xe(L))return null;const W=y[C],M=L.label??L.name,ee=S?R[C]:void 0;return x.jsxs($.Stack,{direction:"row",sx:{gap:1,alignItems:S?"flex-start":"center",opacity:Z[C]?1:.6},children:[x.jsx($.Checkbox,{size:"small",disabled:!Z[C],checked:(W?.include??!1)&&Z[C],inputProps:{"aria-label":`Filter ${M}`},onChange:X=>P(C,{include:X.target.checked})}),x.jsx($.Typography,{variant:"body2",sx:{flex:1,minWidth:0,pt:S?1:0},noWrap:!0,children:M}),Z[C]?S&&x.jsxs(x.Fragment,{children:[D&&H(W?.op,X=>P(C,{op:X}),`Comparison for ${M}`),x.jsx(Ra,{value:W?.field??"",onChange:X=>P(C,{field:X}),fields:s?.(L),accepts:V,label:"Field",ariaLabel:`Field for ${M}`,disabled:!W?.include,error:ee!==void 0,helperText:ee,sx:{width:220}})]}):x.jsx($.Tooltip,{title:ja(t.tiles[C]).reason,children:x.jsx($.Typography,{variant:"caption",sx:{color:l.tileTitle},children:ja(t.tiles[C]).label})})]},`${L.source}.${L.name}`)})}),ie===0&&x.jsx($.Typography,{variant:"caption",sx:{color:"warning.main",display:"block",mt:1},children:"No tile is ticked, so this control will not appear on the dashboard."})]})]})})}const wf=O.createSvgIcon(x.jsx("path",{d:"M11.71 17.99C8.53 17.84 6 15.22 6 12c0-3.31 2.69-6 6-6 3.22 0 5.84 2.53 5.99 5.71l-2.1-.63C15.48 9.31 13.89 8 12 8c-2.21 0-4 1.79-4 4 0 1.89 1.31 3.48 3.08 3.89zM22 12c0 .3-.01.6-.04.9l-1.97-.59c.01-.1.01-.21.01-.31 0-4.42-3.58-8-8-8s-8 3.58-8 8 3.58 8 8 8c.1 0 .21 0 .31-.01l.59 1.97c-.3.03-.6.04-.9.04-5.52 0-10-4.48-10-10S6.48 2 12 2s10 4.48 10 10m-3.77 4.26L22 15l-10-3 3 10 1.26-3.77 4.27 4.27 1.98-1.98z"}));function Vl(e,t,n,r){const[s,i]=k.useState(void 0);return k.useEffect(()=>{t&&e!==void 0&&i(structuredClone(e))},[t,e]),{draft:s,patch:u=>i(c=>{if(c===void 0)return c;const f=structuredClone(c);return u(f),f}),apply:u=>{if(s===void 0)return;const c=structuredClone(s);u(c),i(c),JSON.stringify(c)!==JSON.stringify(e)&&n(c)},close:()=>{s!==void 0&&e!==void 0&&JSON.stringify(s)!==JSON.stringify(e)&&n(s),r()},discard:()=>i(void 0)}}const _f=e=>e&&e.length===1?`This tile's chart line (${e[0]}) is not one the builder models, so its chart cannot be changed here.`:`This tile has ${e?.length??"several"} chart lines${e?` (${e.join(" and ")})`:""}, so its chart cannot be changed here.`,kf="This tile's view is declared on its source, so its chart is set in the model.";function Sf({anchor:e,tile:t,onClose:n,onCommit:r,onRemove:s,removeBlocked:i,onDrills:o,view:a}){const l=k.useId(),{theme:d}=Be.usePublisherTheme(),{draft:u,apply:c,close:f,discard:h}=Vl(t,e!==null,r,n),p=u!==void 0&&xe(u)?u:void 0,m=p!==void 0&&p.declaration.kind!=="inherited",b=g=>c(y=>{xe(y)&&g(y)}),w=k.useRef(void 0),v=e!==null;return k.useEffect(()=>{v&&(w.current=t&&xe(t)?t.chart:void 0)},[v]),x.jsx($.Popover,{open:e!==null&&u!==void 0,anchorEl:e,onClose:f,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{width:320,p:2}}},children:u&&x.jsxs($.Stack,{sx:{gap:1.5},children:[x.jsx($.Typography,{variant:"overline",sx:{color:d.tileTitle,lineHeight:1.5},children:p?`${p.source} → ${p.name}`:`Text · ${u.name}`}),p&&m&&x.jsx(x.Fragment,{children:x.jsx(Di,{state:p.chart??"default",view:a,cellLabel:`${p.source} ${p.name}`,...p.chart==="custom"?{disabledReason:_f(p.chartLines)}:{},onChange:g=>b(y=>{const _=w.current;g===(_??"default")?(_===void 0?delete y.chart:y.chart=_,delete y.chartCarried):(y.chart=g,a?y.chartCarried=a.chart?[a.chart]:[]:delete y.chartCarried)})})}),p&&!m&&x.jsxs(x.Fragment,{children:[x.jsx($.Typography,{variant:"body2",sx:{color:d.tileTitle},children:"Declared on its source, so its title and layout are set in the model. It can still be moved."}),x.jsx(Di,{state:"default",view:a,cellLabel:`${p.source} ${p.name}`,disabledReason:kf,onChange:()=>{}})]}),p?.declaration.kind==="opaque"&&x.jsxs($.Typography,{variant:"body2",sx:{color:d.tileTitle},children:["Its body is ",p.declaration.why,", so a filter has no single place to go. Everything else here is editable."]}),x.jsxs($.Stack,{direction:"row",sx:{justifyContent:"space-between"},children:[m?x.jsx($.Button,{size:"small",startIcon:x.jsx(wf,{}),"aria-haspopup":"dialog",onClick:()=>{f(),o()},children:"Drill"}):x.jsx("span",{}),x.jsx($.Button,{color:"error",size:"small",startIcon:x.jsx(O.DeleteOutlineIcon,{}),"aria-disabled":i!==void 0||void 0,"aria-describedby":i!==void 0?l:void 0,disableRipple:i!==void 0,sx:g=>({color:O.dangerTextColor(g),...i!==void 0?{opacity:.5,cursor:"default"}:{}}),onClick:()=>{i===void 0&&(h(),s())},children:"Delete"})]}),i!==void 0&&x.jsx($.Typography,{id:l,variant:"caption",sx:{color:d.tileTitle},children:i})]})})}function $f({editor:e,catalog:t,columns:n,dashboards:r,bindings:s,tiles:i,drillSource:o,setDrillSource:a,confirmConversion:l,exitDialog:d}){const{filterDialog:u,setFilterDialog:c}=s,{menu:f,setMenu:h}=i,p=f===void 0?void 0:e.document.tiles[f.index],m=p&&xe(p)?p:void 0,b=(()=>{if(!m||!t)return;const w=e.document.sources.find(g=>g.name===m.source)?.base??m.source,v=m.declaration.kind==="reference"?m.declaration.from:m.name;return t.sources.find(g=>g.name===w)?.views.find(g=>g.name===v)})();return x.jsxs(x.Fragment,{children:[x.jsx(xf,{open:u!==void 0,document:e.document,...u?.control?{control:u.control}:{},available:s.available,...t?{fieldsFor:s.fieldsFor}:{},onClose:()=>c(void 0),onApply:s.applyFilter,onRemove:s.dropControl}),x.jsx(Sf,{anchor:f?.anchor??null,tile:f===void 0?void 0:e.document.tiles[f.index],onClose:()=>h(void 0),onCommit:w=>{const v=f?.index;v!==void 0&&e.update(g=>{g.tiles[v]=w})},onRemove:()=>{f!==void 0&&i.removeTile(f.index)},...e.document.tiles.length===1&&e.saved.tiles.length>0?{removeBlocked:"A saved report needs at least one tile."}:{},view:b,onDrills:()=>{a(m?.source)}}),x.jsx(cf,{open:o!==void 0,document:e.document,source:e.document.sources.find(w=>w.name===o),givenNames:s.controlList.map(w=>w.name),dashboards:r??[],onClose:()=>a(void 0),onApply:w=>e.update(v=>{const y=[...(v.drills??[]).filter(_=>_.source!==o),...w];y.length===0?delete v.drills:v.drills=y})}),x.jsx(O.AppDialog,{open:l!==void 0,onClose:()=>l?.stop(),title:"Convert this report?",description:"Saving rewrites this report in the tile layout. The builder cannot take that back; the file's history in your repository can.",actions:x.jsxs(x.Fragment,{children:[x.jsx($.Button,{onClick:()=>l?.stop(),children:"Cancel"}),x.jsx($.Button,{variant:"contained",onClick:()=>l?.go(),children:"Convert and save"})]}),children:null}),x.jsx(O.UnsavedChangesDialog,{...d}),x.jsx(lf,{open:i.addingTile,document:e.document,catalog:t,columns:n,onClose:i.closeAdd,onAdd:i.addTile,onAddText:i.addText})]})}var Tf=Symbol.for("preact-signals");function qs(){if(vt>1)vt--;else{var e,t=!1;for((function(){var s=Ss;for(Ss=void 0;s!==void 0;){var i=s.S;if(i.v===s.v)for(var o=i.t;o!==void 0;o=o.x)o.i===s.i&&(o.i=i.i);s=s.o}})();dr!==void 0;){var n=dr;for(dr=void 0,ks++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Hl(n))try{n.c()}catch(s){t||(e=s,t=!0)}n=r}}if(ks=0,vt--,t)throw e}}function Te(e){if(vt>0)return e();Mi=++Of,vt++;try{return e()}finally{qs()}}var ur,we=void 0;function fe(e){var t=we,n=ur;we=void 0,ur=void 0;try{return e()}finally{we=t,ur=n}}var dr=void 0,vt=0,ks=0,Of=0,Mi=0,Ss=void 0,$s=0;function Ul(e){if(we!==void 0){var t=e.n;if(t===void 0||t.t!==we)return t={i:0,S:e,p:we.s,n:void 0,t:we,e:void 0,x:void 0,r:t},we.s!==void 0&&(we.s.n=t),we.s=t,e.n=t,32&we.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=we.s,t.n=void 0,we.s.n=t,we.s=t),t}}function Ve(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}Ve.prototype.brand=Tf;Ve.prototype.h=function(){return!0};Ve.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n!==void 0?n.e=e:fe(function(){var r;(r=t.W)==null||r.call(t)}))};Ve.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&fe(function(){var s;(s=t.Z)==null||s.call(t)}))}};Ve.prototype.subscribe=function(e){var t=this;return rt(function(){var n=t.value;fe(function(){return e(n)})},{name:"sub"})};Ve.prototype.valueOf=function(){return this.value};Ve.prototype.toString=function(){return this.value+""};Ve.prototype.toJSON=function(){return this.value};Ve.prototype.peek=function(){var e=this;return fe(function(){return e.value})};Object.defineProperty(Ve.prototype,"value",{get:function(){var e=Ul(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(ks>100)throw new Error("Cycle detected");(function(n){vt!==0&&ks===0&&n.l!==Mi&&(n.l=Mi,Ss={S:n,v:n.v,i:n.i,o:Ss})})(this),this.v=e,this.i++,$s++,vt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{qs()}}}});function En(e,t){return new Ve(e,t)}function Hl(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Xl(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function Yl(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function Yt(e,t){Ve.call(this,void 0,t),this.x=e,this.s=void 0,this.g=$s-1,this.f=4}Yt.prototype=new Ve;Yt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===$s))return!0;if(this.g=$s,this.f|=1,this.i>0&&!Hl(this))return this.f&=-2,!0;var e=we;try{Xl(this),we=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return we=e,Yl(this),this.f&=-2,!0};Yt.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}Ve.prototype.S.call(this,e)};Yt.prototype.U=function(e){if(this.t!==void 0&&(Ve.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};Yt.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(Yt.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Ul(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function La(e,t){return new Yt(e,t)}function Zl(e){var t=e.m;if(e.m=void 0,typeof t=="function"){vt++;var n=we;we=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,_o(e),r}finally{we=n,qs()}}}function _o(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Zl(e)}function Ef(e){if(we!==this)throw new Error("Out-of-order effect");Yl(this),we=e,this.f&=-2,8&this.f&&_o(this),qs()}function Cn(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,ur&&ur.push(this)}Cn.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.m=t)}finally{e()}};Cn.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Zl(this),Xl(this),vt++;var e=we;return we=this,Ef.bind(this,e)};Cn.prototype.N=function(){2&this.f||(this.f|=2,this.u=dr,dr=this)};Cn.prototype.d=function(){this.f|=8,1&this.f||_o(this)};Cn.prototype.dispose=function(){this.d()};function rt(e,t){var n=new Cn(e,t);try{n.c()}catch(s){throw n.d(),s}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Cf=Object.create,ko=Object.defineProperty,If=Object.defineProperties,Df=Object.getOwnPropertyDescriptor,Af=Object.getOwnPropertyDescriptors,Na=Object.getOwnPropertySymbols,Mf=Object.prototype.hasOwnProperty,Pf=Object.prototype.propertyIsEnumerable,Rf=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),In=e=>{throw TypeError(e)},Pi=(e,t,n)=>t in e?ko(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jf=(e,t)=>{for(var n in t||(t={}))Mf.call(t,n)&&Pi(e,n,t[n]);if(Na)for(var n of Na(t))Pf.call(t,n)&&Pi(e,n,t[n]);return e},Lf=(e,t)=>If(e,Af(t)),Fa=(e,t)=>ko(e,"name",{value:t,configurable:!0}),Nf=e=>{var t;return[,,,Cf((t=void 0)!=null?t:null)]},Ql=["class","method","getter","setter","accessor","field","value","get","set"],Hn=e=>e!==void 0&&typeof e!="function"?In("Function expected"):e,Ff=(e,t,n,r,s)=>({kind:Ql[e],name:t,metadata:r,addInitializer:i=>n._?In("Already initialized"):s.push(Hn(i||null))}),Jl=(e,t)=>Pi(t,Rf("metadata"),e[3]),Lt=(e,t,n,r)=>{for(var s=0,i=e[t>>1],o=i&&i.length;s<o;s++)t&1?i[s].call(n):r=i[s].call(n,r);return r},Dn=(e,t,n,r,s,i)=>{var o,a,l,d,u,c=t&7,f=!!(t&8),h=!!(t&16),p=c>3?e.length+1:c?f?1:2:0,m=Ql[c+5],b=c>3&&(e[p-1]=[]),w=e[p]||(e[p]=[]),v=c&&(!h&&!f&&(s=s.prototype),c<5&&(c>3||!h)&&Df(c<4?s:{get[n](){return Qe(this,i)},set[n](y){return Tt(this,i,y)}},n));c?h&&c<4&&Fa(i,(c>2?"set ":c>1?"get ":"")+n):Fa(s,n);for(var g=r.length-1;g>=0;g--)d=Ff(c,n,l={},e[3],w),c&&(d.static=f,d.private=h,u=d.access={has:h?y=>zf(s,y):y=>n in y},c^3&&(u.get=h?y=>(c^1?Qe:Wf)(y,s,c^4?i:v.get):y=>y[n]),c>2&&(u.set=h?(y,_)=>Tt(y,s,_,c^4?i:v.set):(y,_)=>y[n]=_)),a=(0,r[g])(c?c<4?h?i:v[m]:c>4?void 0:{get:v.get,set:v.set}:s,d),l._=1,c^4||a===void 0?Hn(a)&&(c>4?b.unshift(a):c?h?i=a:v[m]=a:s=a):typeof a!="object"||a===null?In("Object expected"):(Hn(o=a.get)&&(v.get=o),Hn(o=a.set)&&(v.set=o),Hn(o=a.init)&&b.unshift(o));return c||Jl(e,s),v&&ko(s,n,v),h?c^4?i:v:s},So=(e,t,n)=>t.has(e)||In("Cannot "+n),zf=(e,t)=>Object(t)!==t?In('Cannot use the "in" operator on this value'):e.has(t),Qe=(e,t,n)=>(So(e,t,"read from private field"),n?n.call(e):t.get(e)),Xn=(e,t,n)=>t.has(e)?In("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Tt=(e,t,n,r)=>(So(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Wf=(e,t,n)=>(So(e,t,"access private method"),n);function Ri(e,t){if(t){let n;return La(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return La(e)}function it(e,t){if(Object.is(e,t))return!0;if(e===null||t===null)return!1;if(typeof e=="function"&&typeof t=="function")return e===t;if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:!e.some((r,s)=>!it(r,t[s]));if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:!n.some(i=>!it(e[i],t[i]))}return!1}function he({get:e},t){return{init(n){return En(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function Ee(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=Ri(e.bind(this)),n.set(this,r)),r.value}}function li(e=!0){return function(t,n){n.addInitializer(function(){const r=n.kind==="field"?this:n.static?this:Object.getPrototypeOf(this),s=Object.getOwnPropertyDescriptor(r,n.name);s&&Object.defineProperty(r,n.name,Lf(jf({},s),{enumerable:e}))})}}function Dr(...e){const t=e.map(n=>rt(n));return()=>t.forEach(n=>n())}var ec,tc,nc,rc,sc,ic,Ge,$o,ci,ji,Li,ze,To,ui,oc,Ni,Oo,di,Fi,zi;ic=[he],sc=[he],rc=[he],nc=[li()],tc=[li()],ec=[li()];var Zt=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,Lt(Ge,5,this),Xn(this,ze),Xn(this,$o,Lt(Ge,8,this)),Lt(Ge,11,this),Xn(this,To,Lt(Ge,12,this)),Lt(Ge,15,this),Xn(this,Oo,Lt(Ge,16,this)),Lt(Ge,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return Qe(this,ze,Fi)}get initial(){return Qe(this,ze,ji)}get previous(){return Qe(this,ze,oc)}set current(e){const t=fe(()=>Qe(this,ze,Fi));e&&t&&this.equals(t,e)||Te(()=>{Qe(this,ze,ji)||Tt(this,ze,e,Li),Tt(this,ze,t,Ni),Tt(this,ze,e,zi)})}reset(e=this.defaultValue){Te(()=>{Tt(this,ze,void 0,Ni),Tt(this,ze,e,Li),Tt(this,ze,e,zi)})}};Ge=Nf();$o=new WeakMap;ze=new WeakSet;To=new WeakMap;Oo=new WeakMap;ci=Dn(Ge,20,"#initial",ic,ze,$o),ji=ci.get,Li=ci.set;ui=Dn(Ge,20,"#previous",sc,ze,To),oc=ui.get,Ni=ui.set;di=Dn(Ge,20,"#current",rc,ze,Oo),Fi=di.get,zi=di.set;Dn(Ge,2,"current",nc,Zt);Dn(Ge,2,"initial",tc,Zt);Dn(Ge,2,"previous",ec,Zt);Jl(Ge,Zt);function fi(e){return fe(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var Nt,Bf=class{constructor(){Xn(this,Nt,new WeakMap)}get(e,t){var n;return e?(n=Qe(this,Nt).get(e))==null?void 0:n.get(t):void 0}set(e,t,n){var r;if(e)return Qe(this,Nt).has(e)||Qe(this,Nt).set(e,new Map),(r=Qe(this,Nt).get(e))==null?void 0:r.set(t,n)}clear(e){var t;return e?(t=Qe(this,Nt).get(e))==null?void 0:t.clear():void 0}};Nt=new WeakMap;var Gf=Object.create,ac=Object.defineProperty,qf=Object.getOwnPropertyDescriptor,za=Object.getOwnPropertySymbols,Kf=Object.prototype.hasOwnProperty,Vf=Object.prototype.propertyIsEnumerable,lc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ks=e=>{throw TypeError(e)},Wa=Math.pow,Wi=(e,t,n)=>t in e?ac(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Uf=(e,t)=>{for(var n in t||(t={}))Kf.call(t,n)&&Wi(e,n,t[n]);if(za)for(var n of za(t))Vf.call(t,n)&&Wi(e,n,t[n]);return e},Hf=e=>{var t;return[,,,Gf((t=e?.[lc("metadata")])!=null?t:null)]},cc=["class","method","getter","setter","accessor","field","value","get","set"],uc=e=>e!==void 0&&typeof e!="function"?Ks("Function expected"):e,Xf=(e,t,n,r,s)=>({kind:cc[e],name:t,metadata:r,addInitializer:i=>n._?Ks("Already initialized"):s.push(uc(i||null))}),Yf=(e,t)=>Wi(t,lc("metadata"),e[3]),Zf=(e,t,n,r)=>{for(var s=0,i=e[t>>1],o=i&&i.length;s<o;s++)i[s].call(n);return r},dc=(e,t,n,r,s,i)=>{for(var o,a,l,d,u=t&7,c=!1,f=!1,h=2,p=cc[u+5],m=e[h]||(e[h]=[]),b=(s=s.prototype,qf(s,n)),w=r.length-1;w>=0;w--)l=Xf(u,n,a={},e[3],m),l.static=c,l.private=f,d=l.access={has:v=>n in v},d.get=v=>v[n],o=(0,r[w])(b[p],l),a._=1,uc(o)&&(b[p]=o);return b&&ac(s,n,b),s},fc=(e,t,n)=>t.has(e)||Ks("Cannot "+n),Qf=(e,t,n)=>(fc(e,t,"read from private field"),t.get(e)),Jf=(e,t,n)=>t.has(e)?Ks("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),eh=(e,t,n,r)=>(fc(e,t,"write to private field"),t.set(e,n),n),Je=class Bi{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Bi(t.x-n.x,t.y-n.y)}static distance(t,n){return Math.hypot(t.x-n.x,t.y-n.y)}static equals(t,n){return t.x===n.x&&t.y===n.y}static from({x:t,y:n}){return new Bi(t,n)}},ht=class Ft{constructor(t,n,r,s){this.left=t,this.top=n,this.width=r,this.height=s,this.scale={x:1,y:1}}get inverseScale(){return{x:1/this.scale.x,y:1/this.scale.y}}translate(t,n){const{top:r,left:s,width:i,height:o,scale:a}=this,l=new Ft(s+t,r+n,i,o);return l.scale=Uf({},a),l}get boundingRectangle(){const{width:t,height:n,left:r,top:s,right:i,bottom:o}=this;return{width:t,height:n,left:r,top:s,right:i,bottom:o}}get center(){const{left:t,top:n,right:r,bottom:s}=this;return new Je((t+r)/2,(n+s)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof Ft))return!1;const{left:n,top:r,width:s,height:i}=this;return n===t.left&&r===t.top&&s===t.width&&i===t.height}containsPoint(t){const{top:n,left:r,bottom:s,right:i}=this;return n<=t.y&&t.y<=s&&r<=t.x&&t.x<=i}intersectionArea(t){return t instanceof Ft?th(this,t):0}intersectionRatio(t){const{area:n}=this,r=this.intersectionArea(t);return r/(t.area+n-r)}get bottom(){const{top:t,height:n}=this;return t+n}get right(){const{left:t,width:n}=this;return t+n}get aspectRatio(){const{width:t,height:n}=this;return t/n}get corners(){return[{x:this.left,y:this.top},{x:this.right,y:this.top},{x:this.left,y:this.bottom},{x:this.right,y:this.bottom}]}static from({top:t,left:n,width:r,height:s}){return new Ft(n,t,r,s)}static delta(t,n,r={x:"center",y:"center"}){const s=(i,o)=>{const a=r[o],l=o==="x"?i.left:i.top,d=o==="x"?i.width:i.height;return a=="start"?l:a=="end"?l+d:l+d/2};return Je.delta({x:s(t,"x"),y:s(t,"y")},{x:s(n,"x"),y:s(n,"y")})}static intersectionRatio(t,n){return Ft.from(t).intersectionRatio(Ft.from(n))}};function th(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),s=Math.min(t.left+t.width,e.left+e.width),i=Math.min(t.top+t.height,e.top+e.height),o=s-r,a=i-n;return r<s&&n<i?o*a:0}var hc,pc,Gi,ls,Ar,Vs=class extends(Gi=Zt,pc=[Ee],hc=[Ee],Gi){constructor(t){const n=Je.from(t);super(n,(r,s)=>Je.equals(r,s)),Zf(Ar,5,this),Jf(this,ls,0),this.velocity={x:0,y:0}}get delta(){return Je.delta(this.current,this.initial)}get direction(){const{current:t,previous:n}=this;if(!n)return null;const r={x:t.x-n.x,y:t.y-n.y};return!r.x&&!r.y?null:Math.abs(r.x)>Math.abs(r.y)?r.x>0?"right":"left":r.y>0?"down":"up"}get current(){return super.current}set current(t){const{current:n}=this,r=Je.from(t),s={x:r.x-n.x,y:r.y-n.y},i=Date.now(),o=i-Qf(this,ls),a=l=>Math.round(l/o*100);Te(()=>{eh(this,ls,i),this.velocity={x:a(s.x),y:a(s.y)},super.current=r})}reset(t=this.defaultValue){super.reset(Je.from(t)),this.velocity={x:0,y:0}}};Ar=Hf(Gi);ls=new WeakMap;dc(Ar,2,"delta",pc,Vs);dc(Ar,2,"direction",hc,Vs);Yf(Ar,Vs);function qi({x:e,y:t},n){const r=Math.abs(e),s=Math.abs(t);return typeof n=="number"?Math.sqrt(Wa(r,2)+Wa(s,2))>n:"x"in n&&"y"in n?r>n.x&&s>n.y:"x"in n?r>n.x:"y"in n?s>n.y:!1}var gc=(e=>(e.Horizontal="x",e.Vertical="y",e))(gc||{}),mc=Object.values(gc),nh=Object.create,Eo=Object.defineProperty,rh=Object.defineProperties,sh=Object.getOwnPropertyDescriptor,ih=Object.getOwnPropertyDescriptors,Ts=Object.getOwnPropertySymbols,vc=Object.prototype.hasOwnProperty,yc=Object.prototype.propertyIsEnumerable,bc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),An=e=>{throw TypeError(e)},Ki=(e,t,n)=>t in e?Eo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Co=(e,t)=>{for(var n in t||(t={}))vc.call(t,n)&&Ki(e,n,t[n]);if(Ts)for(var n of Ts(t))yc.call(t,n)&&Ki(e,n,t[n]);return e},Io=(e,t)=>rh(e,ih(t)),Ba=(e,t)=>Eo(e,"name",{value:t,configurable:!0}),xc=(e,t)=>{var n={};for(var r in e)vc.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ts)for(var r of Ts(e))t.indexOf(r)<0&&yc.call(e,r)&&(n[r]=e[r]);return n},Mn=e=>{var t;return[,,,nh((t=e?.[bc("metadata")])!=null?t:null)]},wc=["class","method","getter","setter","accessor","field","value","get","set"],Yn=e=>e!==void 0&&typeof e!="function"?An("Function expected"):e,oh=(e,t,n,r,s)=>({kind:wc[e],name:t,metadata:r,addInitializer:i=>n._?An("Already initialized"):s.push(Yn(i||null))}),Qt=(e,t)=>Ki(t,bc("metadata"),e[3]),ae=(e,t,n,r)=>{for(var s=0,i=e[t>>1],o=i&&i.length;s<o;s++)t&1?i[s].call(n):r=i[s].call(n,r);return r},pe=(e,t,n,r,s,i)=>{var o,a,l,d,u,c=t&7,f=!!(t&8),h=!!(t&16),p=c>3?e.length+1:c?f?1:2:0,m=wc[c+5],b=c>3&&(e[p-1]=[]),w=e[p]||(e[p]=[]),v=c&&(!h&&!f&&(s=s.prototype),c<5&&(c>3||!h)&&sh(c<4?s:{get[n](){return Oe(this,i)},set[n](y){return Ye(this,i,y)}},n));c?h&&c<4&&Ba(i,(c>2?"set ":c>1?"get ":"")+n):Ba(s,n);for(var g=r.length-1;g>=0;g--)d=oh(c,n,l={},e[3],w),c&&(d.static=f,d.private=h,u=d.access={has:h?y=>ah(s,y):y=>n in y},c^3&&(u.get=h?y=>(c^1?Oe:_c)(y,s,c^4?i:v.get):y=>y[n]),c>2&&(u.set=h?(y,_)=>Ye(y,s,_,c^4?i:v.set):(y,_)=>y[n]=_)),a=(0,r[g])(c?c<4?h?i:v[m]:c>4?void 0:{get:v.get,set:v.set}:s,d),l._=1,c^4||a===void 0?Yn(a)&&(c>4?b.unshift(a):c?h?i=a:v[m]=a:s=a):typeof a!="object"||a===null?An("Object expected"):(Yn(o=a.get)&&(v.get=o),Yn(o=a.set)&&(v.set=o),Yn(o=a.init)&&b.unshift(o));return c||Qt(e,s),v&&Eo(s,n,v),h?c^4?i:v:s},Do=(e,t,n)=>t.has(e)||An("Cannot "+n),ah=(e,t)=>Object(t)!==t?An('Cannot use the "in" operator on this value'):e.has(t),Oe=(e,t,n)=>(Do(e,t,"read from private field"),n?n.call(e):t.get(e)),ve=(e,t,n)=>t.has(e)?An("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ye=(e,t,n,r)=>(Do(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),_c=(e,t,n)=>(Do(e,t,"access private method"),n);function kc(e,t){return{plugin:e,options:t}}function Mr(e){return t=>kc(e,t)}function vr(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var Sc,yr,Ao,cs;Sc=[he];var We=class{constructor(e,t){this.manager=e,this.options=t,ve(this,Ao,ae(yr,8,this,!1)),ae(yr,11,this),ve(this,cs,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return fe(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=rt(e.bind(this));return Oe(this,cs).add(t),t}destroy(){Oe(this,cs).forEach(e=>e())}static configure(e){return kc(this,e)}};yr=Mn(null);Ao=new WeakMap;cs=new WeakMap;pe(yr,4,"disabled",Sc,We,Ao);Qt(yr,We);var Pr=class extends We{},us,hi=class{constructor(e){this.manager=e,this.instances=new Map,ve(this,us,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(vr).reduce((r,s)=>{const i=r.find(({plugin:o})=>o===s.plugin);return i?(i.options=s.options,r):[...r,s]},[]),n=t.map(({plugin:r})=>r);for(const r of Oe(this,us))if(!n.includes(r)){if(r.prototype instanceof Pr)continue;this.unregister(r)}for(const{plugin:r,options:s}of t)this.register(r,s);Ye(this,us,n)}get(e){return this.instances.get(e)}register(e,t){const n=this.instances.get(e);if(n)return n.options!==t&&(n.options=t),n;const r=new e(this.manager,t);return this.instances.set(e,r),r}unregister(e){const t=this.instances.get(e);t&&(t.destroy(),this.instances.delete(e))}destroy(){for(const e of this.instances.values())e.destroy();this.instances.clear()}};us=new WeakMap;function lh(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var Ur=[],cn,un,ch=class extends We{constructor(e){super(e),ve(this,cn),ve(this,un),this.computeCollisions=this.computeCollisions.bind(this),Ye(this,un,En(Ur)),this.destroy=Dr(()=>{const t=this.computeCollisions(),n=fe(()=>this.manager.dragOperation.position.current);if(t!==Ur){const r=Oe(this,cn);if(Ye(this,cn,n),r&&n.x==r.x&&n.y==r.y)return}else Ye(this,cn,void 0);Oe(this,un).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){fe(()=>{e?Oe(this,un).value=this.computeCollisions():Ye(this,cn,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:s,shape:i,status:o}=r;if(!o.initialized||!i)return Ur;const a=[],l=[];for(const d of e??n.droppables){if(d.disabled||s&&!d.accepts(s))continue;const u=t??d.collisionDetector;if(!u)continue;l.push(d),d.shape;const c=fe(()=>u({droppable:d,dragOperation:r}));c&&(d.collisionPriority!=null&&(c.priority=d.collisionPriority),a.push(c))}return l.length===0?Ur:(a.sort(lh),a)}get collisions(){return Oe(this,un).value}};cn=new WeakMap;un=new WeakMap;var $c,Tc,Oc,Mo,Ec,ot,Po,mn,Ro,jo;Oc=[he],Tc=[he],$c=[he];var bt=class zt{constructor(t,n){ve(this,Po,ae(ot,8,this)),ae(ot,11,this),ve(this,mn),ve(this,Ro,ae(ot,12,this)),ae(ot,15,this),ve(this,jo,ae(ot,16,this)),ae(ot,19,this);const{effects:r,id:s,data:i={},disabled:o=!1,register:a=!0}=t;let l=s;Ye(this,mn,En(s)),this.manager=n,this.data=i,this.disabled=o,this.effects=()=>{var d;return[()=>{const{id:u,manager:c}=this;if(u!==l)return l=u,c?.registry.register(this),()=>c?.registry.unregister(this)},...(d=r?.())!=null?d:[]]},this.register=this.register.bind(this),this.unregister=this.unregister.bind(this),this.destroy=this.destroy.bind(this),n&&a&&queueMicrotask(this.register)}get id(){var t,n;const r=Oe(this,mn).value;return(n=(t=zt.pendingIdChanges)==null?void 0:t.get(this))!=null?n:r}set id(t){var n,r;const s=(r=(n=zt.pendingIdChanges)==null?void 0:n.get(this))!=null?r:Oe(this,mn).peek();t!==s&&(zt.pendingIdChanges||(zt.pendingIdChanges=new Map,queueMicrotask(()=>{var i;return _c(i=zt,Mo,Ec).call(i)})),zt.pendingIdChanges.set(this,t))}register(){var t;return(t=this.manager)==null?void 0:t.registry.register(this)}unregister(){var t;(t=this.manager)==null||t.registry.unregister(this)}destroy(){var t;(t=this.manager)==null||t.registry.unregister(this)}};ot=Mn(null);Mo=new WeakSet;Ec=function(){const e=bt.pendingIdChanges;bt.pendingIdChanges=null,e&&Te(()=>{for(const[t,n]of e)Oe(t,mn).value=n})};Po=new WeakMap;mn=new WeakMap;Ro=new WeakMap;jo=new WeakMap;pe(ot,4,"manager",Oc,bt,Po);pe(ot,4,"data",Tc,bt,Ro);pe(ot,4,"disabled",$c,bt,jo);ve(bt,Mo);Qt(ot,bt);bt.pendingIdChanges=null;var Us=bt,Ga=class{constructor(){this.map=En(new Map),this.cleanupFunctions=new WeakMap,this.register=(e,t)=>{const n=this.map.peek(),r=n.get(e),s=()=>this.unregister(e,t);if(r===t)return s;if(r&&r.id===e){const a=this.cleanupFunctions.get(r);a?.(),this.cleanupFunctions.delete(r)}const i=new Map(n);for(const[a,l]of n)if(l===t&&a!==e){i.delete(a);break}i.set(e,t),this.map.value=i;const o=Dr(...t.effects());return this.cleanupFunctions.set(t,o),s},this.unregister=(e,t)=>{const n=this.map.peek();if(n.get(e)!==t)return;const r=this.cleanupFunctions.get(t);r?.(),this.cleanupFunctions.delete(t);const s=new Map(n);s.delete(e),this.map.value=s}}[Symbol.iterator](){return this.map.peek().values()}get value(){return this.map.value.values()}has(e){return this.map.value.has(e)}get(e){return this.map.value.get(e)}destroy(){for(const e of this){const t=this.cleanupFunctions.get(e);t?.(),e.destroy()}this.map.value=new Map}},Cc,Ic,Dc,Ac,Mc,Pc,Vi,qe,Lo,No,Fo,pt=class extends(Vi=Us,Pc=[he],Mc=[he],Ac=[he],Dc=[Ee],Ic=[Ee],Cc=[Ee],Vi){constructor(t,n){var r=t,{modifiers:s,type:i,sensors:o,plugins:a,effects:l}=r,d=xc(r,["modifiers","type","sensors","plugins","effects"]);super(Io(Co({},d),{effects:()=>{var u;return[...(u=l?.())!=null?u:[],()=>{const{manager:c,plugins:f}=this;if(!(!c||!f))for(const h of f){const{plugin:p}=vr(h);c.registry.plugins.register(p)}}]}}),n),ae(qe,5,this),ve(this,Lo,ae(qe,8,this)),ae(qe,11,this),ve(this,No,ae(qe,12,this)),ae(qe,15,this),ve(this,Fo,ae(qe,16,this,this.isDragSource?"dragging":"idle")),ae(qe,19,this),this.type=i,this.sensors=o,this.modifiers=s,this.alignment=d.alignment,this.plugins=a}pluginConfig(t){if(this.plugins)for(const n of this.plugins){const r=vr(n);if(r.plugin===t)return r.options}}get isDropping(){return this.status==="dropping"&&this.isDragSource}get isDragging(){return this.status==="dragging"&&this.isDragSource}get isDragSource(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.source)==null?void 0:n.id)===this.id}};qe=Mn(Vi);Lo=new WeakMap;No=new WeakMap;Fo=new WeakMap;pe(qe,4,"type",Pc,pt,Lo);pe(qe,4,"modifiers",Mc,pt,No);pe(qe,4,"status",Ac,pt,Fo);pe(qe,2,"isDropping",Dc,pt);pe(qe,2,"isDragging",Ic,pt);pe(qe,2,"isDragSource",Cc,pt);Qt(qe,pt);var Rc,jc,Lc,Nc,Fc,zc,Ui,Me,zo,Wo,Bo,Go,qo,gt=class extends(Ui=Us,zc=[he],Fc=[he],Nc=[he],Lc=[he],jc=[he],Rc=[Ee],Ui){constructor(t,n){var r=t,{accept:s,collisionDetector:i,collisionPriority:o,type:a}=r,l=xc(r,["accept","collisionDetector","collisionPriority","type"]);super(l,n),ae(Me,5,this),ve(this,zo,ae(Me,8,this)),ae(Me,11,this),ve(this,Wo,ae(Me,12,this)),ae(Me,15,this),ve(this,Bo,ae(Me,16,this)),ae(Me,19,this),ve(this,Go,ae(Me,20,this)),ae(Me,23,this),ve(this,qo,ae(Me,24,this)),ae(Me,27,this),this.accept=s,this.collisionDetector=i,this.collisionPriority=o,this.type=a}accepts(t){const{accept:n}=this;return n?typeof n=="function"?n(t):t.type?Array.isArray(n)?n.includes(t.type):t.type===n:!1:!0}get isDropTarget(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.target)==null?void 0:n.id)===this.id}};Me=Mn(Ui);zo=new WeakMap;Wo=new WeakMap;Bo=new WeakMap;Go=new WeakMap;qo=new WeakMap;pe(Me,4,"accept",zc,gt,zo);pe(Me,4,"type",Fc,gt,Wo);pe(Me,4,"collisionDetector",Nc,gt,Bo);pe(Me,4,"collisionPriority",Lc,gt,Go);pe(Me,4,"shape",jc,gt,qo);pe(Me,2,"isDropTarget",Rc,gt);Qt(Me,gt);var uh=class{constructor(){this.registry=new Map}addEventListener(e,t){const{registry:n}=this,r=new Set(n.get(e));return r.add(t),n.set(e,r),()=>this.removeEventListener(e,t)}removeEventListener(e,t){const{registry:n}=this,r=new Set(n.get(e));r.delete(t),n.set(e,r)}dispatch(e,...t){const{registry:n}=this,r=n.get(e);if(r)for(const s of r)s(...t)}},dh=class extends uh{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function ds(e,t=!0){let n=!1;return Io(Co({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var fh=class extends Pr{constructor(e){super(e);const t=(r,s)=>r.map(({id:i})=>i).join("")===s.map(({id:i})=>i).join("");let n=[];this.destroy=Dr(()=>{const{dragOperation:r,collisionObserver:s}=e;r.status.initializing&&(n=[],s.enable())},()=>{const{collisionObserver:r,monitor:s}=e,{collisions:i}=r;if(r.isDisabled()||Us.pendingIdChanges)return;const o=ds({collisions:i});if(s.dispatch("collision",o),o.defaultPrevented||t(i,n))return;n=i;const[a]=i;fe(()=>{var l;a?.id!==((l=e.dragOperation.target)==null?void 0:l.id)&&(r.disable(),e.actions.setDropTarget(a?.id).then(()=>{r.enable()}))})})}},Pn=(e=>(e[e.Lowest=0]="Lowest",e[e.Low=1]="Low",e[e.Normal=2]="Normal",e[e.High=3]="High",e[e.Highest=4]="Highest",e))(Pn||{}),Rn=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(Rn||{}),Wc,Bc,Gc,qc,Kc,Vc,Uc,nt,Ko;Uc=[he],Vc=[Ee],Kc=[Ee],qc=[Ee],Gc=[Ee],Bc=[Ee],Wc=[Ee];var wt=class{constructor(){ae(nt,5,this),ve(this,Ko,ae(nt,8,this,"idle")),ae(nt,11,this)}get current(){return this.value}get idle(){return this.value==="idle"}get initializing(){return this.value==="initializing"}get initialized(){const{value:e}=this;return e!=="idle"&&e!=="initialization-pending"}get dragging(){return this.value==="dragging"}get dropped(){return this.value==="dropped"}set(e){this.value=e}};nt=Mn(null);Ko=new WeakMap;pe(nt,4,"value",Uc,wt,Ko);pe(nt,2,"current",Vc,wt);pe(nt,2,"idle",Kc,wt);pe(nt,2,"initializing",qc,wt);pe(nt,2,"initialized",Gc,wt);pe(nt,2,"dragging",Bc,wt);pe(nt,2,"dropped",Wc,wt);Qt(nt,wt);var hh=class{constructor(e){this.manager=e}setDragSource(e){const{dragOperation:t}=this.manager;t.sourceIdentifier=typeof e=="string"||typeof e=="number"?e:e.id}setDropTarget(e){return fe(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=ds({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return fe(()=>{const{dragOperation:t}=this.manager;if(e.source!=null&&this.setDragSource(e.source),!t.source)throw new Error("Cannot start a drag operation without a drag source");if(!t.status.idle)throw new Error("Cannot start a drag operation while another is active");const r=new AbortController,{event:s,coordinates:i}=e;Te(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=s??null,t.position.reset(i)});const o=ds({operation:t.snapshot()});return this.manager.monitor.dispatch("beforedragstart",o),o.defaultPrevented?(t.reset(),r.abort(),r):(t.status.set("initializing"),t.controller=r,this.manager.renderer.rendering.then(()=>{if(r.signal.aborted)return;const{status:a}=t;a.current==="initializing"&&Te(()=>{t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:s,operation:t.snapshot(),cancelable:!1})})}),r)})}move(e){return fe(()=>{var t,n;const{dragOperation:r}=this.manager,{status:s,controller:i}=r;if(!s.dragging||!i||i.signal.aborted)return;const o=ds({nativeEvent:e.event,operation:r.snapshot(),by:e.by,to:e.to},(t=e.cancelable)!=null?t:!0);((n=e.propagate)==null||n)&&this.manager.monitor.dispatch("dragmove",o),queueMicrotask(()=>{var a,l,d,u,c;if(o.defaultPrevented)return;const f=(c=e.to)!=null?c:{x:r.position.current.x+((l=(a=e.by)==null?void 0:a.x)!=null?l:0),y:r.position.current.y+((u=(d=e.by)==null?void 0:d.y)!=null?u:0)};r.position.current=f})})}stop(e={}){return fe(()=>{var t,n;const{dragOperation:r}=this.manager,{controller:s}=r;if(!s||s.signal.aborted)return;let i;const o=()=>{const l={resume:()=>{},abort:()=>{}};return i=new Promise((d,u)=>{l.resume=d,l.abort=u}),l};s.abort();const a=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const l=fe(()=>{var u;return((u=r.source)==null?void 0:u.status)==="dropping"}),d=()=>{r.controller===s&&(r.controller=void 0),r.reset()};if(l){const{source:u}=r,c=rt(()=>{u?.status==="idle"&&(c(),d())})}else this.manager.renderer.rendering.then(d)})};r.canceled=(t=e.canceled)!=null?t:!1,this.manager.monitor.dispatch("dragend",{nativeEvent:e.event,operation:r.snapshot(),canceled:(n=e.canceled)!=null?n:!1,suspend:o}),i?i.then(a).catch(()=>r.reset()):a()})}},_n=class extends We{constructor(e,t){super(e,t),this.manager=e,this.options=t}},ph=class extends AbortController{constructor(e,t){super(),this.constraints=e,this.onActivate=t,this.activated=!1;for(const n of e??[])n.controller=this}onEvent(e){var t;if(!this.activated)if((t=this.constraints)!=null&&t.length)for(const n of this.constraints)n.onEvent(e);else this.activate(e)}activate(e){this.activated||(this.activated=!0,this.onActivate(e))}abort(e){this.activated=!1,super.abort(e)}},fs,Hc=class{constructor(e){this.options=e,ve(this,fs)}set controller(e){Ye(this,fs,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=Oe(this,fs))==null||t.activate(e)}};fs=new WeakMap;var qa=class extends We{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},gh=class{constructor(e){this.draggables=new Ga,this.droppables=new Ga,this.plugins=new hi(e),this.sensors=new hi(e),this.modifiers=new hi(e)}register(e,t){if(e instanceof pt)return this.draggables.register(e.id,e);if(e instanceof gt)return this.droppables.register(e.id,e);if(e.prototype instanceof qa)return this.modifiers.register(e,t);if(e.prototype instanceof _n)return this.sensors.register(e,t);if(e.prototype instanceof We)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof Us)return e instanceof pt?this.draggables.unregister(e.id,e):e instanceof gt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof qa)return this.modifiers.unregister(e);if(e.prototype instanceof _n)return this.sensors.unregister(e);if(e.prototype instanceof We)return this.plugins.unregister(e);throw new Error("Invalid instance type")}destroy(){this.draggables.destroy(),this.droppables.destroy(),this.plugins.destroy(),this.sensors.destroy(),this.modifiers.destroy()}},Xc,Yc,Zc,Qc,Jc,eu,tu,nu,ru,Zn,hs,dn,$e,Vo,Uo,Ho,Xo,Yo,Qn;ru=[Ee],nu=[he],tu=[he],eu=[he],Jc=[he],Qc=[he],Zc=[Ee],Yc=[Ee],Xc=[Ee];var ct=class{constructor(e){ae($e,5,this),ve(this,Zn),ve(this,hs),ve(this,dn,new Zt(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new wt,ve(this,Vo,ae($e,8,this,!1)),ae($e,11,this),ve(this,Uo,ae($e,12,this,null)),ae($e,15,this),ve(this,Ho,ae($e,16,this,null)),ae($e,19,this),ve(this,Xo,ae($e,20,this,null)),ae($e,23,this),ve(this,Yo,ae($e,24,this,[])),ae($e,27,this),this.position=new Vs({x:0,y:0}),ve(this,Qn,{x:0,y:0}),Ye(this,Zn,e)}get shape(){const{current:e,initial:t,previous:n}=Oe(this,dn);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?Oe(this,dn).current=e:Oe(this,dn).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=Oe(this,Zn).registry.draggables.get(t);return n&&Ye(this,hs,n),(e=n??Oe(this,hs))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=Oe(this,Zn).registry.droppables.get(t))!=null?e:null}get transform(){const{x:e,y:t}=this.position.delta;let n={x:e,y:t};for(const r of this.modifiers)n=r.apply(Io(Co({},this.snapshot()),{transform:n}));return Ye(this,Qn,n),n}snapshot(){return fe(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:Oe(this,Qn),shape:this.shape?fi(this.shape):null,position:fi(this.position),status:fi(this.status),canceled:this.canceled}))}reset(){Te(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,Oe(this,dn).reset(),this.position.reset({x:0,y:0}),Ye(this,Qn,{x:0,y:0}),this.modifiers=[]})}};$e=Mn(null);Zn=new WeakMap;hs=new WeakMap;dn=new WeakMap;Vo=new WeakMap;Uo=new WeakMap;Ho=new WeakMap;Xo=new WeakMap;Yo=new WeakMap;Qn=new WeakMap;pe($e,2,"shape",ru,ct);pe($e,4,"canceled",nu,ct,Vo);pe($e,4,"activatorEvent",tu,ct,Uo);pe($e,4,"sourceIdentifier",eu,ct,Ho);pe($e,4,"targetIdentifier",Jc,ct,Xo);pe($e,4,"modifiers",Qc,ct,Yo);pe($e,2,"source",Zc,ct);pe($e,2,"target",Yc,ct);pe($e,2,"transform",Xc,ct);Qt($e,ct);var mh={get rendering(){return Promise.resolve()}};function lt(e,t){return typeof e=="function"?e(t):e??t}var vh=class{constructor(t){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(f=>f.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var n;const r=t??{},s=lt(r.plugins,[]),i=lt(r.sensors,[]),o=lt(r.modifiers,[]),a=(n=r.renderer)!=null?n:mh,l=new dh(this),d=new gh(this);this.registry=d,this.monitor=l,this.renderer=a,this.actions=new hh(this),this.dragOperation=new ct(this),this.collisionObserver=new ch(this),this.plugins=[fh,...s],this.modifiers=o,this.sensors=i;const{destroy:u}=this,c=Dr(()=>{var f,h,p;const m=fe(()=>this.dragOperation.modifiers),b=this.modifiers;for(const w of m)b.includes(w)||w.destroy();this.dragOperation.modifiers=(p=(h=(f=this.dragOperation.source)==null?void 0:f.modifiers)==null?void 0:h.map(w=>{const{plugin:v,options:g}=vr(w);return new v(this,g)}))!=null?p:b});this.destroy=()=>{c(),u()}}get plugins(){return this.registry.plugins.values}set plugins(t){this.registry.plugins.values=t}get modifiers(){return this.registry.modifiers.values}set modifiers(t){this.registry.modifiers.values=t}get sensors(){return this.registry.sensors.values}set sensors(t){this.registry.sensors.values=t}},su=e=>{throw TypeError(e)},Zo=(e,t,n)=>t.has(e)||su("Cannot "+n),oe=(e,t,n)=>(Zo(e,t,"read from private field"),t.get(e)),Ue=(e,t,n)=>t.has(e)?su("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Xe=(e,t,n,r)=>(Zo(e,t,"write to private field"),t.set(e,n),n),iu=(e,t,n)=>(Zo(e,t,"access private method"),n);function Hs(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function ou(e,t){const n=e.getAnimations();let r=null;for(const s of n){if(s.playState!=="running")continue;const{effect:i}=s,a=(Hs(i)?i.getKeyframes():[]).filter(t);a.length>0&&(r=[a[a.length-1],s])}return r}function Xs(e){const{width:t,height:n,top:r,left:s,bottom:i,right:o}=e.getBoundingClientRect();return{width:t,height:n,top:r,left:s,bottom:i,right:o}}function Qo(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Rr(e){return"nodeType"in e}function Ze(e){var t,n,r;return e?Qo(e)?e:Rr(e)?"defaultView"in e?(t=e.defaultView)!=null?t:window:(r=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?r:window:window:window}function Jo(e){const{Document:t}=Ze(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function At(e){return!e||Qo(e)?!1:e instanceof Ze(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function au(e){return e instanceof Ze(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function jn(e){return e?Qo(e)?e.document:Rr(e)?Jo(e)?e:At(e)||au(e)?e.ownerDocument:document:document:document}function yh(e){var t,n,r,s;const{documentElement:i}=jn(e),o=Ze(e).visualViewport,a=(t=o?.width)!=null?t:i.clientWidth,l=(n=o?.height)!=null?n:i.clientHeight,d=(r=o?.offsetTop)!=null?r:0,u=(s=o?.offsetLeft)!=null?s:0;return{top:d,left:u,right:u+a,bottom:d+l,width:a,height:l}}function bh(e,t){if(xh(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:s}=getComputedStyle(e);return n==="visible"&&r==="visible"&&s==="visible"}function xh(e){return e.tagName==="DETAILS"}function br(e,t=e.getBoundingClientRect(),n=0){var r,s,i,o,a;let l=t;const{ownerDocument:d}=e,u=(r=d.defaultView)!=null?r:window;let c=e.parentElement;for(;c&&c!==d.documentElement;){if(!bh(c)){const g=c.getBoundingClientRect(),y=n*(g.bottom-g.top),_=n*(g.right-g.left),S=n*(g.bottom-g.top),E=n*(g.right-g.left);l={top:Math.max(l.top,g.top-y),right:Math.min(l.right,g.right+_),bottom:Math.min(l.bottom,g.bottom+S),left:Math.max(l.left,g.left-E),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top}c=c.parentElement}const f=u.visualViewport,h=(s=f?.offsetTop)!=null?s:0,p=(i=f?.offsetLeft)!=null?i:0,m=(o=f?.width)!=null?o:u.innerWidth,b=(a=f?.height)!=null?a:u.innerHeight,w=n*b,v=n*m;return l={top:Math.max(l.top,h-w),right:Math.min(l.right,p+m+v),bottom:Math.min(l.bottom,h+b+w),left:Math.max(l.left,p-v),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top,l.width<0&&(l.width=0),l.height<0&&(l.height=0),l}function kn(e){return{x:e.clientX,y:e.clientY}}var lu=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Hi(e=document,t=new Set){if(t.has(e))return[];t.add(e);const n=[e];for(const r of Array.from(e.querySelectorAll("iframe, frame")))try{const s=r.contentDocument;s&&!t.has(s)&&n.push(...Hi(s,t))}catch{}try{const r=e.defaultView;if(r&&r!==window.top){const s=r.parent;s&&s.document&&s.document!==e&&n.push(...Hi(s.document,t))}}catch{}return n}function ea(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function cu(){var e,t;const n=ea()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function ta(e){return!e||!Rr(e)?!1:e instanceof Ze(e).ShadowRoot}function Os(e){if(e&&Rr(e)){let t=e.getRootNode();if(ta(t))return t;if(t instanceof Document)return t}return jn(e)}function na(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function wh(e){const t="input, textarea, select, canvas, [contenteditable]",n=e.cloneNode(!0),r=Array.from(e.querySelectorAll(t));return Array.from(n.querySelectorAll(t)).forEach((i,o)=>{const a=r[o];if(Ka(i)&&Ka(a)&&(i.type!=="file"&&(i.value=a.value),i.type==="radio"&&i.name&&(i.name=`Cloned__${i.name}`)),Va(i)&&Va(a)&&a.width>0&&a.height>0){const l=i.getContext("2d");l?.drawImage(a,0,0)}}),n}function Ka(e){return"value"in e}function Va(e){return e.tagName==="CANVAS"}function uu(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(_h(r)){const{contentDocument:s}=r;if(s){const{left:i,top:o}=r.getBoundingClientRect();return uu(s,{x:t-i,y:n-o})}}return r}function _h(e){return e?.tagName==="IFRAME"}var Xi=new WeakMap;function kh(e){return e.closest(`
|
|
2
2
|
input:not([disabled]),
|
|
3
3
|
select:not([disabled]),
|
|
4
4
|
textarea:not([disabled]),
|
|
5
5
|
button:not([disabled]),
|
|
6
6
|
a[href],
|
|
7
7
|
[contenteditable]:not([contenteditable="false"])
|
|
8
|
-
`)}var dd=class{constructor(){this.entries=new Set,this.clear=()=>{for(const e of this.entries){const[t,{type:n,listener:r,options:s}]=e;t.removeEventListener(n,r,s)}this.entries.clear()}}bind(e,t){const n=Array.isArray(e)?e:[e],r=Array.isArray(t)?t:[t],s=[];for(const o of n)for(const a of r){const{type:l,listener:u,options:d}=a,c=[o,a];o.addEventListener(l,u,d),this.entries.add(c),s.push(c)}const i=this.entries;return function(){for(const a of s){const[l,{type:u,listener:d,options:c}]=a;l.removeEventListener(u,d,c),i.delete(a)}}}};function _n(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function Eh(e){const t=new Set;let n=_n(e);for(;n;)t.add(n),n=_n(n);return t}function Ch(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function ud(e,t){const n=()=>performance.now();let r,s;return function(...i){const o=this;s?(r?.(),r=Ch(()=>{e.apply(o,i),s=n()},t-(n()-s))):(e.apply(o,i),s=n())}}function Ih(e,t){return e===t?!0:!e||!t?!1:e.top==t.top&&e.left==t.left&&e.right==t.right&&e.bottom==t.bottom}function Dh(e,t=e.getBoundingClientRect()){const{width:n,height:r}=mr(e,t);return n>0&&r>0}var Ah=ad?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},ds,Ph=class extends Ah{constructor(e){super(t=>{if(!le(this,ds)){Ye(this,ds,!0);return}e(t,this)}),Ve(this,ds,!1)}};ds=new WeakMap;var Ua=Array.from({length:100},(e,t)=>t/100),fd=75,Ft,Ss,$t,zt,Yn,Ne,cr,Zn,$s,hd,pd,gd=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,Ve(this,$s),this.disconnect=()=>{var i,o,a;Ye(this,cr,!0),(i=le(this,$t))==null||i.disconnect(),(o=le(this,zt))==null||o.disconnect(),le(this,Yn).disconnect(),(a=le(this,Ne))==null||a.remove()},Ve(this,Ft,!0),Ve(this,Ss),Ve(this,$t),Ve(this,zt),Ve(this,Yn),Ve(this,Ne),Ve(this,cr,!1),Ve(this,Zn,ud(()=>{var i,o,a;const{element:l}=this;if((i=le(this,zt))==null||i.disconnect(),le(this,cr)||!le(this,Ft)||!l.isConnected)return;const u=(o=l.ownerDocument)!=null?o:document,{innerHeight:d,innerWidth:c}=(a=u.defaultView)!=null?a:window,f=l.getBoundingClientRect(),p=mr(l,f),{top:h,left:m,bottom:y,right:w}=p,v=-Math.floor(h),g=-Math.floor(m),b=-Math.floor(c-w),_=-Math.floor(d-y),O=`${v}px ${b}px ${_}px ${g}px`;this.boundingClientRect=f,Ye(this,zt,new IntersectionObserver(I=>{const[M]=I,{intersectionRect:T}=M;(M.intersectionRatio!==1?M.intersectionRatio:ft.intersectionRatio(T,mr(l)))!==1&&le(this,Zn).call(this)},{threshold:Ua,rootMargin:O,root:u})),le(this,zt).observe(l),sd(this,$s,hd).call(this)},fd)),this.boundingClientRect=e.getBoundingClientRect(),Ye(this,Ft,Dh(e,this.boundingClientRect));let r=!0;this.callback=i=>{r&&(r=!1,n.skipInitial)||t(i)};const s=e.ownerDocument;n?.debug&&(Ye(this,Ne,document.createElement("div")),le(this,Ne).style.background="rgba(0,0,0,0.15)",le(this,Ne).style.position="fixed",le(this,Ne).style.pointerEvents="none",s.body.appendChild(le(this,Ne))),Ye(this,Yn,new IntersectionObserver(i=>{var o,a;const l=i[i.length-1],{boundingClientRect:u,isIntersecting:d}=l,{width:c,height:f}=u,p=le(this,Ft);Ye(this,Ft,d),!(!c&&!f)&&(p&&!d?((o=le(this,zt))==null||o.disconnect(),this.callback(null),(a=le(this,$t))==null||a.disconnect(),Ye(this,$t,void 0),le(this,Ne)&&(le(this,Ne).style.visibility="hidden")):le(this,Zn).call(this),d&&!le(this,$t)&&(Ye(this,$t,new Ph(le(this,Zn))),le(this,$t).observe(e)))},{threshold:Ua,root:s})),le(this,Ft)&&!n.skipInitial&&this.callback(this.boundingClientRect),le(this,Yn).observe(e)}};Ft=new WeakMap;Ss=new WeakMap;$t=new WeakMap;zt=new WeakMap;Yn=new WeakMap;Ne=new WeakMap;cr=new WeakMap;Zn=new WeakMap;$s=new WeakSet;hd=function(){le(this,cr)||(sd(this,$s,pd).call(this),!Ih(this.boundingClientRect,le(this,Ss))&&(this.callback(this.boundingClientRect),Ye(this,Ss,this.boundingClientRect)))};pd=function(){if(le(this,Ne)){const{top:e,left:t,width:n,height:r}=mr(this.element);le(this,Ne).style.overflow="hidden",le(this,Ne).style.visibility="visible",le(this,Ne).style.top=`${Math.floor(e)}px`,le(this,Ne).style.left=`${Math.floor(t)}px`,le(this,Ne).style.width=`${Math.floor(n)}px`,le(this,Ne).style.height=`${Math.floor(r)}px`}};var qr=new WeakMap,Kr=new WeakMap;function Mh(e,t){let n=qr.get(e);return n||(n={disconnect:new gd(e,s=>{const i=qr.get(e);i&&i.callbacks.forEach(o=>o(s))},{skipInitial:!0}).disconnect,callbacks:new Set}),n.callbacks.add(t),qr.set(e,n),()=>{n.callbacks.delete(t),n.callbacks.size===0&&(qr.delete(e),n.disconnect())}}function jh(e,t){const n=new Set;for(const r of e){const s=Mh(r,t);n.add(s)}return()=>n.forEach(r=>r())}function Rh(e,t){var n;const r=e.ownerDocument;if(!Kr.has(r)){const o=new AbortController,a=new Set;document.addEventListener("scroll",l=>a.forEach(u=>u(l)),{capture:!0,passive:!0,signal:o.signal}),Kr.set(r,{disconnect:()=>o.abort(),listeners:a})}const{listeners:s,disconnect:i}=(n=Kr.get(r))!=null?n:{};return!s||!i?()=>{}:(s.add(t),()=>{s.delete(t),s.size===0&&(i(),Kr.delete(r))})}var Qn,Jn,us,Vi,Lh=class{constructor(e,t,n){this.callback=t,Ve(this,Qn),Ve(this,Jn,!1),Ve(this,us),Ve(this,Vi,ud(o=>{if(!le(this,Jn)&&o.target&&"contains"in o.target&&typeof o.target.contains=="function"){for(const a of le(this,us))if(o.target.contains(a)){this.callback(le(this,Qn).boundingClientRect);break}}},fd));const r=Eh(e),s=jh(r,t),i=Rh(e,le(this,Vi));Ye(this,us,r),Ye(this,Qn,new gd(e,t,n)),this.disconnect=()=>{le(this,Jn)||(Ye(this,Jn,!0),s(),i(),le(this,Qn).disconnect())}}};Qn=new WeakMap;Jn=new WeakMap;us=new WeakMap;Vi=new WeakMap;function Hi(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function mn(e){try{Hi(e)&&e.isConnected&&e.hasAttribute("popover")&&!e.matches(":popover-open")&&e.showPopover()}catch{}}function Va(e){return!ad||!e?!1:e===Mn(e).scrollingElement}function md(e){var t,n;const r=Qe(e),s=Va(e)?_h(e):Ks(e),i=r.visualViewport,o=Va(e)?{height:(t=i?.height)!=null?t:r.innerHeight,width:(n=i?.width)!=null?n:r.innerWidth}:{height:e.clientHeight,width:e.clientWidth},a={current:{x:e.scrollLeft,y:e.scrollTop},max:{x:e.scrollWidth-o.width,y:e.scrollHeight-o.height}},l=a.current.y<=0,u=a.current.x<=0,d=a.current.y>=a.max.y,c=a.current.x>=a.max.x;return{rect:s,position:a,isTop:l,isLeft:u,isBottom:d,isRight:c}}function Nh(e,t){const{isTop:n,isBottom:r,isLeft:s,isRight:i,position:o}=md(e),{x:a,y:l}=t??{x:0,y:0},u=!n&&o.current.y+l>0,d=!r&&o.current.y+l<o.max.y,c=!s&&o.current.x+a>0,f=!i&&o.current.x+a<o.max.x;return{top:u,bottom:d,left:c,right:f,x:c||f,y:u||d}}var ta=class{constructor(t){this.scheduler=t,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{const{tasks:n,resolvers:r}=this;this.pending=!1,this.tasks=new Set,this.resolvers=new Set;for(const s of n)s();for(const s of r)s()}}schedule(t){return this.tasks.add(t),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(n=>this.resolvers.add(n))}},Ts=new ta(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),Fh=new ta(e=>setTimeout(e,50)),Os=new Map,zh=Os.clear.bind(Os);function gt(e,t=!1){if(!t)return Ha(e);let n=Os.get(e);return n||(n=Ha(e),Os.set(e,n),Fh.schedule(zh),n)}function Ha(e){return Qe(e).getComputedStyle(e)}function Wh(e,t=gt(e,!0)){return t.position==="fixed"||t.position==="sticky"}function Bh(e,t=gt(e,!0)){const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(s=>{const i=t[s];return typeof i=="string"?n.test(i):!1})}var Gh={excludeElement:!0,escapeShadowDOM:!0};function Xi(e,t=Gh){const{limit:n,excludeElement:r,escapeShadowDOM:s}=t,i=new Set;function o(a){if(n!=null&&i.size>=n||!a)return i;if(Zo(a)&&a.scrollingElement!=null&&!i.has(a.scrollingElement))return i.add(a.scrollingElement),i;if(s&&Jo(a))return o(a.host);if(!Pt(a))return od(a)?o(a.parentElement):i;if(i.has(a))return i;const l=gt(a,!0);if(r&&a===e||Bh(a,l)&&i.add(a),Wh(a,l)){const{scrollingElement:u}=a.ownerDocument;return u&&i.add(u),i}return o(a.parentNode)}return e?o(e):i}function kn(e,t=window.frameElement){const n={x:0,y:0,scaleX:1,scaleY:1};if(!e)return n;let r=_n(e);for(;r;){if(r===t)return n;const s=Ks(r),{x:i,y:o}=qh(r,s);n.x=n.x+s.left,n.y=n.y+s.top,n.scaleX=n.scaleX*i,n.scaleY=n.scaleY*o,r=_n(r)}return n}function qh(e,t=Ks(e)){const n=Math.round(t.width),r=Math.round(t.height);if(Pt(e))return{x:n/e.offsetWidth,y:r/e.offsetHeight};const s=gt(e,!0);return{x:(parseFloat(s.width)||n)/n,y:(parseFloat(s.height)||r)/r}}function Kh(e){if(!e||e==="none")return null;const t=e.split(" "),n=parseFloat(t[0]),r=parseFloat(t[1]);return isNaN(n)&&isNaN(r)?null:{x:isNaN(n)?r:n,y:isNaN(r)?n:r}}function vr(e){if(!e||e==="none")return null;const[t,n,r="0"]=e.split(" "),s={x:parseFloat(t),y:parseFloat(n),z:parseInt(r,10)};return isNaN(s.x)&&isNaN(s.y)?null:{x:isNaN(s.x)?0:s.x,y:isNaN(s.y)?0:s.y,z:isNaN(s.z)?0:s.z}}function Us(e){var t,n,r,s,i,o,a,l,u;const{scale:d,transform:c,translate:f}=e,p=Kh(d),h=vr(f),m=Uh(c);if(!m&&!p&&!h)return null;const y={x:(t=p?.x)!=null?t:1,y:(n=p?.y)!=null?n:1},w={x:(r=h?.x)!=null?r:0,y:(s=h?.y)!=null?s:0},v={x:(i=m?.x)!=null?i:0,y:(o=m?.y)!=null?o:0,scaleX:(a=m?.scaleX)!=null?a:1,scaleY:(l=m?.scaleY)!=null?l:1};return{x:w.x+v.x,y:w.y+v.y,z:(u=h?.z)!=null?u:0,scaleX:y.x*v.scaleX,scaleY:y.y*v.scaleY}}function Uh(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}var tt=(e=>(e[e.Idle=0]="Idle",e[e.Forward=1]="Forward",e[e.Reverse=-1]="Reverse",e))(tt||{}),Vh={x:.2,y:.2},Hh={x:10,y:10};function Xh(e,t,n,r=25,s=Vh,i=Hh){const{x:o,y:a}=t,{rect:l,isTop:u,isBottom:d,isLeft:c,isRight:f}=md(e),p=kn(e),h=gt(e,!0),m=Us(h),y=m!==null?m?.scaleX<0:!1,w=m!==null?m?.scaleY<0:!1,v=new ft(l.left*p.scaleX+p.x,l.top*p.scaleY+p.y,l.width*p.scaleX,l.height*p.scaleY),g={x:0,y:0},b={x:0,y:0},_={height:v.height*s.y,width:v.width*s.x};return _.height>0&&(!u||w&&!d)&&a<=v.top+_.height&&n?.y!==1&&o>=v.left-i.x&&o<=v.right+i.x?(g.y=w?1:-1,b.y=r*Math.abs((v.top+_.height-a)/_.height)):_.height>0&&(!d||w&&!u)&&a>=v.bottom-_.height&&n?.y!==-1&&o>=v.left-i.x&&o<=v.right+i.x&&(g.y=w?-1:1,b.y=r*Math.abs((v.bottom-_.height-a)/_.height)),_.width>0&&(!f||y&&!c)&&o>=v.right-_.width&&n?.x!==-1&&a>=v.top-i.y&&a<=v.bottom+i.y?(g.x=y?-1:1,b.x=r*Math.abs((v.right-_.width-o)/_.width)):_.width>0&&(!c||y&&!f)&&o<=v.left+_.width&&n?.x!==1&&a>=v.top-i.y&&a<=v.bottom+i.y&&(g.x=y?1:-1,b.x=r*Math.abs((v.left+_.width-o)/_.width)),{direction:g,speed:b}}function vd(e,{block:t="nearest",inline:n="nearest"}={}){if(!Pt(e))return;const r=Xi(e),s=[];for(const i of r){if(!Pt(i))continue;const{top:o,left:a}=Yh(e,i);let l=o,u=a;for(const d of s)l-=d.scrollTop,u-=d.scrollLeft;if(t!=="none"){const d=l<i.scrollTop,c=l+e.offsetHeight>i.scrollTop+i.clientHeight;d!==c&&(t==="center"?i.scrollTop=l-i.clientHeight/2+e.offsetHeight/2:d?i.scrollTop=l:i.scrollTop=l+e.offsetHeight-i.clientHeight)}if(n!=="none"){const d=u<i.scrollLeft,c=u+e.offsetWidth>i.scrollLeft+i.clientWidth;d!==c&&(n==="center"?i.scrollLeft=u-i.clientWidth/2+e.offsetWidth/2:d?i.scrollLeft=u:i.scrollLeft=u+e.offsetWidth-i.clientWidth)}s.push(i)}}function Xa(e){let t=0,n=0,r=e;for(;r;){t+=r.offsetTop,n+=r.offsetLeft;const s=r.offsetParent;if(!Pt(s))break;t+=s.clientTop,n+=s.clientLeft,r=s}return{top:t,left:n}}function Yh(e,t){const n=Xa(e),r=Xa(t);return{top:n.top-r.top-t.clientTop,left:n.left-r.left-t.clientLeft}}function Zh(e,t,n){const{scaleX:r,scaleY:s,x:i,y:o}=t,a=e.left+i+(1-r)*parseFloat(n),l=e.top+o+(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),u=r?e.width*r:e.width,d=s?e.height*s:e.height;return{width:u,height:d,top:l,right:a+u,bottom:l+d,left:a}}function Qh(e,t,n){const{scaleX:r,scaleY:s,x:i,y:o}=t,a=e.left-i-(1-r)*parseFloat(n),l=e.top-o-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),u=r?e.width/r:e.width,d=s?e.height/s:e.height;return{width:u,height:d,top:l,right:a+u,bottom:l+d,left:a}}function bd({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}function Ya(e,t=gt(e).translate,n=!0){if(n){const r=id(e,s=>"translate"in s);if(r){const{translate:s=""}=r[0];if(typeof s=="string"){const i=vr(s);if(i)return i}}}if(t){const r=vr(t);if(r)return r}return{x:0,y:0,z:0}}var Jh=new ta(e=>setTimeout(e,0)),dr=new Map,ep=dr.clear.bind(dr);function tp(e){const t=e.ownerDocument;let n=dr.get(t);if(n)return n;n=t.getAnimations(),dr.set(t,n),Jh.schedule(ep);const r=n.filter(s=>qs(s.effect)&&s.effect.target===e);return dr.set(e,r),n}function np(e,t){const n=tp(e).filter(r=>{var s,i;if(qs(r.effect)){const{target:o}=r.effect;if((i=o&&((s=t.isValidTarget)==null?void 0:s.call(t,o)))!=null?i:!0)return r.effect.getKeyframes().some(l=>{for(const u of t.properties)if(l[u])return!0})}}).map(r=>{const{effect:s,currentTime:i}=r,o=s?.getComputedTiming().duration;if(!(r.pending||r.playState==="finished")&&typeof o=="number"&&typeof i=="number"&&i<o)return r.currentTime=o,()=>{r.currentTime=i}});if(n.length>0)return()=>n.forEach(r=>r?.())}var ut=class extends ft{constructor(e,t={}){var n,r,s,i;const{frameTransform:o=kn(e),ignoreTransforms:a,getBoundingClientRect:l=Ks}=t,u=np(e,{properties:["transform","translate","scale","width","height"],isValidTarget:_=>(_!==e||Qo())&&_.contains(e)}),d=l(e);let{top:c,left:f,width:p,height:h}=d,m;const y=gt(e),w=Us(y),v={x:(n=w?.scaleX)!=null?n:1,y:(r=w?.scaleY)!=null?r:1},g=rp(e,y);u?.(),w&&(m=Qh(d,w,y.transformOrigin),(a||g)&&(c=m.top,f=m.left,p=m.width,h=m.height));const b={width:(s=m?.width)!=null?s:p,height:(i=m?.height)!=null?i:h};if(g&&!a&&m){const _=Zh(m,g,y.transformOrigin);c=_.top,f=_.left,p=_.width,h=_.height,v.x=g.scaleX,v.y=g.scaleY}o&&(a||(f*=o.scaleX,p*=o.scaleX,c*=o.scaleY,h*=o.scaleY),f+=o.x,c+=o.y),super(f,c,p,h),this.scale=v,this.intrinsicWidth=b.width,this.intrinsicHeight=b.height}};function rp(e,t){const n=e.getAnimations();if(!n.length)return null;let r,s,i,o=!1;for(const a of n){if(a.playState!=="running")continue;const l=qs(a.effect)?a.effect.getKeyframes():[],u=l[l.length-1];if(!u)continue;const{transform:d,translate:c,scale:f}=u;typeof d=="string"&&d&&(r=d,o=!0),typeof c=="string"&&c&&(s=c,o=!0),typeof f=="string"&&f&&(i=f,o=!0)}return o?Us({transform:r??t.transform,translate:s??t.translate,scale:i??t.scale}):null}function ur(e){return"style"in e&&typeof e.style=="object"&&e.style!==null&&"setProperty"in e.style&&"removeProperty"in e.style&&typeof e.style.setProperty=="function"&&typeof e.style.removeProperty=="function"}var sp=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=""){const{element:n}=this;if(ur(n))for(const[r,s]of Object.entries(e)){const i=`${t}${r}`;this.initial.has(i)||this.initial.set(i,n.style.getPropertyValue(i)),n.style.setProperty(i,typeof s=="string"?s:`${s}px`)}}remove(e,t=""){const{element:n}=this;if(ur(n))for(const r of e){const s=`${t}${r}`;n.style.removeProperty(s)}}reset(){const{element:e}=this;if(ur(e)){for(const[t,n]of this.initial)e.style.setProperty(t,n);e.getAttribute("style")===""&&e.removeAttribute("style")}}};function Ut(e){return e?e instanceof Qe(e).Element||Ar(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function br(e){if(!e)return!1;const{KeyboardEvent:t}=Qe(e.target);return e instanceof t}function ip(e){if(!e)return!1;const{PointerEvent:t}=Qe(e.target);return e instanceof t}function op(e){if(!Ut(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||ap(e)}function ap(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var ui={};function Yi(e){const t=ui[e]==null?0:ui[e]+1;return ui[e]=t,`${e}-${t}`}var na=({dragOperation:e,droppable:t})=>{const n=e.position.current;if(!n)return null;const{id:r}=t;if(!t.shape)return null;if(t.shape.containsPoint(n)){const s=et.distance(t.shape.center,n);return{id:r,value:1/s,type:Pn.PointerIntersection,priority:An.High}}return null},lp=({dragOperation:e,droppable:t})=>{const{shape:n}=e;if(!t.shape||!n?.current)return null;const r=n.current.intersectionArea(t.shape);if(r){const{position:s}=e,i=et.distance(t.shape.center,s.current),a=r/(n.current.area+t.shape.area-r)/i;return{id:t.id,value:a,type:Pn.ShapeIntersection,priority:An.Normal}}return null},yd=e=>{var t;return(t=na(e))!=null?t:lp(e)},cp=e=>{const{dragOperation:t,droppable:n}=e,{shape:r,position:s}=t;if(!n.shape)return null;const i=r?ft.from(r.current.boundingRectangle).corners:void 0,a=ft.from(n.shape.boundingRectangle).corners.reduce((l,u,d)=>{var c;return l+et.distance(et.from(u),(c=i?.[d])!=null?c:s.current)},0)/4;return{id:n.id,value:1/a,type:Pn.Collision,priority:An.Normal}},dp=Object.create,ra=Object.defineProperty,up=Object.defineProperties,fp=Object.getOwnPropertyDescriptor,hp=Object.getOwnPropertyDescriptors,Es=Object.getOwnPropertySymbols,xd=Object.prototype.hasOwnProperty,wd=Object.prototype.propertyIsEnumerable,_d=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),jn=e=>{throw TypeError(e)},Zi=(e,t,n)=>t in e?ra(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yr=(e,t)=>{for(var n in t||(t={}))xd.call(t,n)&&Zi(e,n,t[n]);if(Es)for(var n of Es(t))wd.call(t,n)&&Zi(e,n,t[n]);return e},sa=(e,t)=>up(e,hp(t)),Za=(e,t)=>ra(e,"name",{value:t,configurable:!0}),kd=(e,t)=>{var n={};for(var r in e)xd.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Es)for(var r of Es(e))t.indexOf(r)<0&&wd.call(e,r)&&(n[r]=e[r]);return n},Rn=e=>{var t;return[,,,dp((t=e?.[_d("metadata")])!=null?t:null)]},Sd=["class","method","getter","setter","accessor","field","value","get","set"],er=e=>e!==void 0&&typeof e!="function"?jn("Function expected"):e,pp=(e,t,n,r,s)=>({kind:Sd[e],name:t,metadata:r,addInitializer:i=>n._?jn("Already initialized"):s.push(er(i||null))}),Qt=(e,t)=>Zi(t,_d("metadata"),e[3]),Me=(e,t,n,r)=>{for(var s=0,i=e[t>>1],o=i&&i.length;s<o;s++)t&1?i[s].call(n):r=i[s].call(n,r);return r},it=(e,t,n,r,s,i)=>{var o,a,l,u,d,c=t&7,f=!!(t&8),p=!!(t&16),h=c>3?e.length+1:c?f?1:2:0,m=Sd[c+5],y=c>3&&(e[h-1]=[]),w=e[h]||(e[h]=[]),v=c&&(!p&&!f&&(s=s.prototype),c<5&&(c>3||!p)&&fp(c<4?s:{get[n](){return ye(this,i)},set[n](b){return qe(this,i,b)}},n));c?p&&c<4&&Za(i,(c>2?"set ":c>1?"get ":"")+n):Za(s,n);for(var g=r.length-1;g>=0;g--)u=pp(c,n,l={},e[3],w),c&&(u.static=f,u.private=p,d=u.access={has:p?b=>gp(s,b):b=>n in b},c^3&&(d.get=p?b=>(c^1?ye:Vt)(b,s,c^4?i:v.get):b=>b[n]),c>2&&(d.set=p?(b,_)=>qe(b,s,_,c^4?i:v.set):(b,_)=>b[n]=_)),a=(0,r[g])(c?c<4?p?i:v[m]:c>4?void 0:{get:v.get,set:v.set}:s,u),l._=1,c^4||a===void 0?er(a)&&(c>4?y.unshift(a):c?p?i=a:v[m]=a:s=a):typeof a!="object"||a===null?jn("Object expected"):(er(o=a.get)&&(v.get=o),er(o=a.set)&&(v.set=o),er(o=a.init)&&y.unshift(o));return c||Qt(e,s),v&&ra(s,n,v),p?c^4?i:v:s},ia=(e,t,n)=>t.has(e)||jn("Cannot "+n),gp=(e,t)=>Object(t)!==t?jn('Cannot use the "in" operator on this value'):e.has(t),ye=(e,t,n)=>(ia(e,t,"read from private field"),n?n.call(e):t.get(e)),Ce=(e,t,n)=>t.has(e)?jn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),qe=(e,t,n,r)=>(ia(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Vt=(e,t,n)=>(ia(e,t,"access private method"),n),Qa={role:"button",roleDescription:"draggable"},mp="dnd-kit-description",vp="dnd-kit-announcement",bp={draggable:"To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item in a given direction. Press space again to drop the item in its new position, or press escape to cancel."},yp={dragstart({operation:{source:e}}){if(e)return`Picked up draggable item ${e.id}.`},dragover({operation:{source:e,target:t}}){if(!(!e||e.id===t?.id))return t?`Draggable item ${e.id} was moved over droppable target ${t.id}.`:`Draggable item ${e.id} is no longer over a droppable target.`},dragend({operation:{source:e,target:t},canceled:n}){if(e)return n?`Dragging was cancelled. Draggable item ${e.id} was dropped.`:t?`Draggable item ${e.id} was dropped over droppable target ${t.id}`:`Draggable item ${e.id} was dropped.`}};function xp(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function wp(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function _p(e){const t=document.createElement("div");return t.id=e,t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),t.style.setProperty("position","fixed"),t.style.setProperty("width","1px"),t.style.setProperty("height","1px"),t.style.setProperty("margin","-1px"),t.style.setProperty("border","0"),t.style.setProperty("padding","0"),t.style.setProperty("overflow","hidden"),t.style.setProperty("clip","rect(0 0 0 0)"),t.style.setProperty("clip-path","inset(100%)"),t.style.setProperty("white-space","nowrap"),t}var kp=["dragover","dragmove"],Sp=class extends We{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=mp,announcement:s=vp}={},announcements:i=yp,screenReaderInstructions:o=bp,debounce:a=500}=t??{},l=n?`${r}-${n}`:Yi(r),u=n?`${s}-${n}`:Yi(s);let d,c,f,p;const h=(_=p)=>{!f||!_||f?.nodeValue!==_&&(f.nodeValue=_)},m=()=>Ts.schedule(h),y=$p(m,a),w=Object.entries(i).map(([_,O])=>this.manager.monitor.addEventListener(_,(I,M)=>{const T=f;if(!T)return;const D=O?.(I,M);D&&T.nodeValue!==D&&(p=D,kp.includes(_)?y():(m(),y.cancel()))})),v=()=>{let _=[];d?.isConnected||(d=wp(l,o.draggable),_.push(d)),c?.isConnected||(c=_p(u),f=document.createTextNode(""),c.appendChild(f),_.push(c)),_.length>0&&document.body.append(..._)},g=new Set;function b(){for(const _ of g)_()}this.registerEffect(()=>{var _;g.clear();for(const O of this.manager.registry.draggables.value){const I=(_=O.handle)!=null?_:O.element;if(I){(!d||!c)&&g.add(v),(!xp(I)||Qo())&&!I.hasAttribute("tabindex")&&g.add(()=>I.setAttribute("tabindex","0")),!I.hasAttribute("role")&&I.tagName.toLowerCase()!=="button"&&g.add(()=>I.setAttribute("role",Qa.role)),I.hasAttribute("aria-roledescription")||g.add(()=>I.setAttribute("aria-roledescription",Qa.roleDescription)),I.hasAttribute("aria-describedby")||g.add(()=>I.setAttribute("aria-describedby",l));for(const T of["aria-pressed","aria-grabbed"]){const D=String(O.isDragging);I.getAttribute(T)!==D&&g.add(()=>I.setAttribute(T,D))}const M=String(O.disabled);I.getAttribute("aria-disabled")!==M&&g.add(()=>I.setAttribute("aria-disabled",M))}}g.size>0&&Ts.schedule(b)}),this.destroy=()=>{super.destroy(),d?.remove(),c?.remove(),w.forEach(_=>_())}}};function $p(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var Cs=new Map,$d,Td,Od,Ed,Qi,fr,xt,oa,Sn,Cd,Id,Dd,Ad,Mt=class extends(Qi=Dr,Ed=[fe],Od=[Ee],Td=[Ee],$d=[Ee],Qi){constructor(t,n){super(t,n),Me(xt,5,this),Ce(this,Sn),Ce(this,fr,new Set),Ce(this,oa,Me(xt,8,this,new Set)),Me(xt,11,this),this.registerEffect(Vt(this,Sn,Cd))}register(t){return ye(this,fr).add(t),()=>{ye(this,fr).delete(t)}}addRoot(t){return ue(()=>{const n=new Set(this.additionalRoots);n.add(t),this.additionalRoots=n}),()=>{ue(()=>{const n=new Set(this.additionalRoots);n.delete(t),this.additionalRoots=n})}}get sourceRoot(){var t;const{source:n}=this.manager.dragOperation;return ks((t=n?.element)!=null?t:null)}get targetRoot(){var t;const{target:n}=this.manager.dragOperation;return ks((t=n?.element)!=null?t:null)}get roots(){const{status:t}=this.manager.dragOperation;if(t.initializing||t.initialized){const n=[this.sourceRoot,this.targetRoot].filter(r=>r!=null);return new Set([...n,...this.additionalRoots])}return new Set}};xt=Rn(Qi);fr=new WeakMap;oa=new WeakMap;Sn=new WeakSet;Cd=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of ye(this,fr))t.push(Vt(this,Sn,Id).call(this,n,r));return()=>{for(const n of t)n()}};Id=function(e,t){let n=Cs.get(e);n||(n=new Map,Cs.set(e,n));let r=n.get(t);if(!r){const i=Zo(e)?Vt(this,Sn,Dd).call(this,e,n,t):Vt(this,Sn,Ad).call(this,e,n,t);if(!i)return()=>{};r=i,n.set(t,r)}r.refCount++;let s=!1;return()=>{s||(s=!0,r.refCount--,r.refCount===0&&r.cleanup())}};Dd=function(e,t,n){var r;const s=e.createElement("style"),{nonce:i}=(r=this.options)!=null?r:{};i&&s.setAttribute("nonce",i),s.textContent=n,e.head.prepend(s);const o=new MutationObserver(a=>{for(const l of a)for(const u of Array.from(l.removedNodes))if(u===s){e.head.prepend(s);return}});return o.observe(e.head,{childList:!0}),{refCount:0,cleanup:()=>{o.disconnect(),s.remove(),t.delete(n),t.size===0&&Cs.delete(e)}}};Ad=function(e,t,n){"adoptedStyleSheets"in e&&Array.isArray(e.adoptedStyleSheets);const r=e.ownerDocument.defaultView,{CSSStyleSheet:s}=r??{};if(!s)return null;const i=new s;return i.replaceSync(n),e.adoptedStyleSheets.push(i),{refCount:0,cleanup:()=>{var o;if(Jo(e)&&((o=e.host)!=null&&o.isConnected)){const a=e.adoptedStyleSheets.indexOf(i);a!==-1&&e.adoptedStyleSheets.splice(a,1)}t.delete(n),t.size===0&&Cs.delete(e)}}};it(xt,4,"additionalRoots",Ed,Mt,oa);it(xt,2,"sourceRoot",Od,Mt);it(xt,2,"targetRoot",Td,Mt);it(xt,2,"roots",$d,Mt);Qt(xt,Mt);Mt.configure=Ir(Mt);var Vs=Mt,Tp=class extends We{constructor(e,t){super(e,t),this.manager=e;const{cursor:n="grabbing"}=t??{},r=e.registry.plugins.get(Vs),s=r?.register(`* { cursor: ${n} !important; }`);if(s){const i=this.destroy.bind(this);this.destroy=()=>{s(),i()}}}},Pr="data-dnd-",Ji=`${Pr}dropping`,Le="--dnd-",dt=`${Pr}dragging`,Is=`${Pr}placeholder`,Op=[dt,Is,"popover","aria-pressed","aria-grabbing"],Ep=["view-transition-name"],Cp=`
|
|
8
|
+
`)}var du=class{constructor(){this.entries=new Set,this.clear=()=>{for(const e of this.entries){const[t,{type:n,listener:r,options:s}]=e;t.removeEventListener(n,r,s)}this.entries.clear()}}bind(e,t){const n=Array.isArray(e)?e:[e],r=Array.isArray(t)?t:[t],s=[];for(const o of n)for(const a of r){const{type:l,listener:d,options:u}=a,c=[o,a];o.addEventListener(l,d,u),this.entries.add(c),s.push(c)}const i=this.entries;return function(){for(const a of s){const[l,{type:d,listener:u,options:c}]=a;l.removeEventListener(d,u,c),i.delete(a)}}}};function Sn(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function Sh(e){const t=new Set;let n=Sn(e);for(;n;)t.add(n),n=Sn(n);return t}function $h(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function fu(e,t){const n=()=>performance.now();let r,s;return function(...i){const o=this;s?(r?.(),r=$h(()=>{e.apply(o,i),s=n()},t-(n()-s))):(e.apply(o,i),s=n())}}function Th(e,t){return e===t?!0:!e||!t?!1:e.top==t.top&&e.left==t.left&&e.right==t.right&&e.bottom==t.bottom}function Oh(e,t=e.getBoundingClientRect()){const{width:n,height:r}=br(e,t);return n>0&&r>0}var Eh=lu?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},ps,Ch=class extends Eh{constructor(e){super(t=>{if(!oe(this,ps)){Xe(this,ps,!0);return}e(t,this)}),Ue(this,ps,!1)}};ps=new WeakMap;var Ua=Array.from({length:100},(e,t)=>t/100),hu=75,Wt,Es,St,Bt,Jn,Ne,fr,er,Cs,pu,gu,mu=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,Ue(this,Cs),this.disconnect=()=>{var i,o,a;Xe(this,fr,!0),(i=oe(this,St))==null||i.disconnect(),(o=oe(this,Bt))==null||o.disconnect(),oe(this,Jn).disconnect(),(a=oe(this,Ne))==null||a.remove()},Ue(this,Wt,!0),Ue(this,Es),Ue(this,St),Ue(this,Bt),Ue(this,Jn),Ue(this,Ne),Ue(this,fr,!1),Ue(this,er,fu(()=>{var i,o,a;const{element:l}=this;if((i=oe(this,Bt))==null||i.disconnect(),oe(this,fr)||!oe(this,Wt)||!l.isConnected)return;const d=(o=l.ownerDocument)!=null?o:document,{innerHeight:u,innerWidth:c}=(a=d.defaultView)!=null?a:window,f=l.getBoundingClientRect(),h=br(l,f),{top:p,left:m,bottom:b,right:w}=h,v=-Math.floor(p),g=-Math.floor(m),y=-Math.floor(c-w),_=-Math.floor(u-b),S=`${v}px ${y}px ${_}px ${g}px`;this.boundingClientRect=f,Xe(this,Bt,new IntersectionObserver(E=>{const[A]=E,{intersectionRect:T}=A;(A.intersectionRatio!==1?A.intersectionRatio:ht.intersectionRatio(T,br(l)))!==1&&oe(this,er).call(this)},{threshold:Ua,rootMargin:S,root:d})),oe(this,Bt).observe(l),iu(this,Cs,pu).call(this)},hu)),this.boundingClientRect=e.getBoundingClientRect(),Xe(this,Wt,Oh(e,this.boundingClientRect));let r=!0;this.callback=i=>{r&&(r=!1,n.skipInitial)||t(i)};const s=e.ownerDocument;n?.debug&&(Xe(this,Ne,document.createElement("div")),oe(this,Ne).style.background="rgba(0,0,0,0.15)",oe(this,Ne).style.position="fixed",oe(this,Ne).style.pointerEvents="none",s.body.appendChild(oe(this,Ne))),Xe(this,Jn,new IntersectionObserver(i=>{var o,a;const l=i[i.length-1],{boundingClientRect:d,isIntersecting:u}=l,{width:c,height:f}=d,h=oe(this,Wt);Xe(this,Wt,u),!(!c&&!f)&&(h&&!u?((o=oe(this,Bt))==null||o.disconnect(),this.callback(null),(a=oe(this,St))==null||a.disconnect(),Xe(this,St,void 0),oe(this,Ne)&&(oe(this,Ne).style.visibility="hidden")):oe(this,er).call(this),u&&!oe(this,St)&&(Xe(this,St,new Ch(oe(this,er))),oe(this,St).observe(e)))},{threshold:Ua,root:s})),oe(this,Wt)&&!n.skipInitial&&this.callback(this.boundingClientRect),oe(this,Jn).observe(e)}};Wt=new WeakMap;Es=new WeakMap;St=new WeakMap;Bt=new WeakMap;Jn=new WeakMap;Ne=new WeakMap;fr=new WeakMap;er=new WeakMap;Cs=new WeakSet;pu=function(){oe(this,fr)||(iu(this,Cs,gu).call(this),!Th(this.boundingClientRect,oe(this,Es))&&(this.callback(this.boundingClientRect),Xe(this,Es,this.boundingClientRect)))};gu=function(){if(oe(this,Ne)){const{top:e,left:t,width:n,height:r}=br(this.element);oe(this,Ne).style.overflow="hidden",oe(this,Ne).style.visibility="visible",oe(this,Ne).style.top=`${Math.floor(e)}px`,oe(this,Ne).style.left=`${Math.floor(t)}px`,oe(this,Ne).style.width=`${Math.floor(n)}px`,oe(this,Ne).style.height=`${Math.floor(r)}px`}};var Hr=new WeakMap,Xr=new WeakMap;function Ih(e,t){let n=Hr.get(e);return n||(n={disconnect:new mu(e,s=>{const i=Hr.get(e);i&&i.callbacks.forEach(o=>o(s))},{skipInitial:!0}).disconnect,callbacks:new Set}),n.callbacks.add(t),Hr.set(e,n),()=>{n.callbacks.delete(t),n.callbacks.size===0&&(Hr.delete(e),n.disconnect())}}function Dh(e,t){const n=new Set;for(const r of e){const s=Ih(r,t);n.add(s)}return()=>n.forEach(r=>r())}function Ah(e,t){var n;const r=e.ownerDocument;if(!Xr.has(r)){const o=new AbortController,a=new Set;document.addEventListener("scroll",l=>a.forEach(d=>d(l)),{capture:!0,passive:!0,signal:o.signal}),Xr.set(r,{disconnect:()=>o.abort(),listeners:a})}const{listeners:s,disconnect:i}=(n=Xr.get(r))!=null?n:{};return!s||!i?()=>{}:(s.add(t),()=>{s.delete(t),s.size===0&&(i(),Xr.delete(r))})}var tr,nr,gs,Yi,Mh=class{constructor(e,t,n){this.callback=t,Ue(this,tr),Ue(this,nr,!1),Ue(this,gs),Ue(this,Yi,fu(o=>{if(!oe(this,nr)&&o.target&&"contains"in o.target&&typeof o.target.contains=="function"){for(const a of oe(this,gs))if(o.target.contains(a)){this.callback(oe(this,tr).boundingClientRect);break}}},hu));const r=Sh(e),s=Dh(r,t),i=Ah(e,oe(this,Yi));Xe(this,gs,r),Xe(this,tr,new mu(e,t,n)),this.disconnect=()=>{oe(this,nr)||(Xe(this,nr,!0),s(),i(),oe(this,tr).disconnect())}}};tr=new WeakMap;nr=new WeakMap;gs=new WeakMap;Yi=new WeakMap;function Zi(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function yn(e){try{Zi(e)&&e.isConnected&&e.hasAttribute("popover")&&!e.matches(":popover-open")&&e.showPopover()}catch{}}function Ha(e){return!lu||!e?!1:e===jn(e).scrollingElement}function vu(e){var t,n;const r=Ze(e),s=Ha(e)?yh(e):Xs(e),i=r.visualViewport,o=Ha(e)?{height:(t=i?.height)!=null?t:r.innerHeight,width:(n=i?.width)!=null?n:r.innerWidth}:{height:e.clientHeight,width:e.clientWidth},a={current:{x:e.scrollLeft,y:e.scrollTop},max:{x:e.scrollWidth-o.width,y:e.scrollHeight-o.height}},l=a.current.y<=0,d=a.current.x<=0,u=a.current.y>=a.max.y,c=a.current.x>=a.max.x;return{rect:s,position:a,isTop:l,isLeft:d,isBottom:u,isRight:c}}function Ph(e,t){const{isTop:n,isBottom:r,isLeft:s,isRight:i,position:o}=vu(e),{x:a,y:l}=t??{x:0,y:0},d=!n&&o.current.y+l>0,u=!r&&o.current.y+l<o.max.y,c=!s&&o.current.x+a>0,f=!i&&o.current.x+a<o.max.x;return{top:d,bottom:u,left:c,right:f,x:c||f,y:d||u}}var ra=class{constructor(t){this.scheduler=t,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{const{tasks:n,resolvers:r}=this;this.pending=!1,this.tasks=new Set,this.resolvers=new Set;for(const s of n)s();for(const s of r)s()}}schedule(t){return this.tasks.add(t),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(n=>this.resolvers.add(n))}},Is=new ra(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),Rh=new ra(e=>setTimeout(e,50)),Ds=new Map,jh=Ds.clear.bind(Ds);function mt(e,t=!1){if(!t)return Xa(e);let n=Ds.get(e);return n||(n=Xa(e),Ds.set(e,n),Rh.schedule(jh),n)}function Xa(e){return Ze(e).getComputedStyle(e)}function Lh(e,t=mt(e,!0)){return t.position==="fixed"||t.position==="sticky"}function Nh(e,t=mt(e,!0)){const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(s=>{const i=t[s];return typeof i=="string"?n.test(i):!1})}var Fh={excludeElement:!0,escapeShadowDOM:!0};function Qi(e,t=Fh){const{limit:n,excludeElement:r,escapeShadowDOM:s}=t,i=new Set;function o(a){if(n!=null&&i.size>=n||!a)return i;if(Jo(a)&&a.scrollingElement!=null&&!i.has(a.scrollingElement))return i.add(a.scrollingElement),i;if(s&&ta(a))return o(a.host);if(!At(a))return au(a)?o(a.parentElement):i;if(i.has(a))return i;const l=mt(a,!0);if(r&&a===e||Nh(a,l)&&i.add(a),Lh(a,l)){const{scrollingElement:d}=a.ownerDocument;return d&&i.add(d),i}return o(a.parentNode)}return e?o(e):i}function $n(e,t=window.frameElement){const n={x:0,y:0,scaleX:1,scaleY:1};if(!e)return n;let r=Sn(e);for(;r;){if(r===t)return n;const s=Xs(r),{x:i,y:o}=zh(r,s);n.x=n.x+s.left,n.y=n.y+s.top,n.scaleX=n.scaleX*i,n.scaleY=n.scaleY*o,r=Sn(r)}return n}function zh(e,t=Xs(e)){const n=Math.round(t.width),r=Math.round(t.height);if(At(e))return{x:n/e.offsetWidth,y:r/e.offsetHeight};const s=mt(e,!0);return{x:(parseFloat(s.width)||n)/n,y:(parseFloat(s.height)||r)/r}}function Wh(e){if(!e||e==="none")return null;const t=e.split(" "),n=parseFloat(t[0]),r=parseFloat(t[1]);return isNaN(n)&&isNaN(r)?null:{x:isNaN(n)?r:n,y:isNaN(r)?n:r}}function xr(e){if(!e||e==="none")return null;const[t,n,r="0"]=e.split(" "),s={x:parseFloat(t),y:parseFloat(n),z:parseInt(r,10)};return isNaN(s.x)&&isNaN(s.y)?null:{x:isNaN(s.x)?0:s.x,y:isNaN(s.y)?0:s.y,z:isNaN(s.z)?0:s.z}}function Ys(e){var t,n,r,s,i,o,a,l,d;const{scale:u,transform:c,translate:f}=e,h=Wh(u),p=xr(f),m=Bh(c);if(!m&&!h&&!p)return null;const b={x:(t=h?.x)!=null?t:1,y:(n=h?.y)!=null?n:1},w={x:(r=p?.x)!=null?r:0,y:(s=p?.y)!=null?s:0},v={x:(i=m?.x)!=null?i:0,y:(o=m?.y)!=null?o:0,scaleX:(a=m?.scaleX)!=null?a:1,scaleY:(l=m?.scaleY)!=null?l:1};return{x:w.x+v.x,y:w.y+v.y,z:(d=p?.z)!=null?d:0,scaleX:b.x*v.scaleX,scaleY:b.y*v.scaleY}}function Bh(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}var et=(e=>(e[e.Idle=0]="Idle",e[e.Forward=1]="Forward",e[e.Reverse=-1]="Reverse",e))(et||{}),Gh={x:.2,y:.2},qh={x:10,y:10};function Kh(e,t,n,r=25,s=Gh,i=qh){const{x:o,y:a}=t,{rect:l,isTop:d,isBottom:u,isLeft:c,isRight:f}=vu(e),h=$n(e),p=mt(e,!0),m=Ys(p),b=m!==null?m?.scaleX<0:!1,w=m!==null?m?.scaleY<0:!1,v=new ht(l.left*h.scaleX+h.x,l.top*h.scaleY+h.y,l.width*h.scaleX,l.height*h.scaleY),g={x:0,y:0},y={x:0,y:0},_={height:v.height*s.y,width:v.width*s.x};return _.height>0&&(!d||w&&!u)&&a<=v.top+_.height&&n?.y!==1&&o>=v.left-i.x&&o<=v.right+i.x?(g.y=w?1:-1,y.y=r*Math.abs((v.top+_.height-a)/_.height)):_.height>0&&(!u||w&&!d)&&a>=v.bottom-_.height&&n?.y!==-1&&o>=v.left-i.x&&o<=v.right+i.x&&(g.y=w?-1:1,y.y=r*Math.abs((v.bottom-_.height-a)/_.height)),_.width>0&&(!f||b&&!c)&&o>=v.right-_.width&&n?.x!==-1&&a>=v.top-i.y&&a<=v.bottom+i.y?(g.x=b?-1:1,y.x=r*Math.abs((v.right-_.width-o)/_.width)):_.width>0&&(!c||b&&!f)&&o<=v.left+_.width&&n?.x!==1&&a>=v.top-i.y&&a<=v.bottom+i.y&&(g.x=b?1:-1,y.x=r*Math.abs((v.left+_.width-o)/_.width)),{direction:g,speed:y}}function yu(e,{block:t="nearest",inline:n="nearest"}={}){if(!At(e))return;const r=Qi(e),s=[];for(const i of r){if(!At(i))continue;const{top:o,left:a}=Vh(e,i);let l=o,d=a;for(const u of s)l-=u.scrollTop,d-=u.scrollLeft;if(t!=="none"){const u=l<i.scrollTop,c=l+e.offsetHeight>i.scrollTop+i.clientHeight;u!==c&&(t==="center"?i.scrollTop=l-i.clientHeight/2+e.offsetHeight/2:u?i.scrollTop=l:i.scrollTop=l+e.offsetHeight-i.clientHeight)}if(n!=="none"){const u=d<i.scrollLeft,c=d+e.offsetWidth>i.scrollLeft+i.clientWidth;u!==c&&(n==="center"?i.scrollLeft=d-i.clientWidth/2+e.offsetWidth/2:u?i.scrollLeft=d:i.scrollLeft=d+e.offsetWidth-i.clientWidth)}s.push(i)}}function Ya(e){let t=0,n=0,r=e;for(;r;){t+=r.offsetTop,n+=r.offsetLeft;const s=r.offsetParent;if(!At(s))break;t+=s.clientTop,n+=s.clientLeft,r=s}return{top:t,left:n}}function Vh(e,t){const n=Ya(e),r=Ya(t);return{top:n.top-r.top-t.clientTop,left:n.left-r.left-t.clientLeft}}function Uh(e,t,n){const{scaleX:r,scaleY:s,x:i,y:o}=t,a=e.left+i+(1-r)*parseFloat(n),l=e.top+o+(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),d=r?e.width*r:e.width,u=s?e.height*s:e.height;return{width:d,height:u,top:l,right:a+d,bottom:l+u,left:a}}function Hh(e,t,n){const{scaleX:r,scaleY:s,x:i,y:o}=t,a=e.left-i-(1-r)*parseFloat(n),l=e.top-o-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),d=r?e.width/r:e.width,u=s?e.height/s:e.height;return{width:d,height:u,top:l,right:a+d,bottom:l+u,left:a}}function bu({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}function Za(e,t=mt(e).translate,n=!0){if(n){const r=ou(e,s=>"translate"in s);if(r){const{translate:s=""}=r[0];if(typeof s=="string"){const i=xr(s);if(i)return i}}}if(t){const r=xr(t);if(r)return r}return{x:0,y:0,z:0}}var Xh=new ra(e=>setTimeout(e,0)),hr=new Map,Yh=hr.clear.bind(hr);function Zh(e){const t=e.ownerDocument;let n=hr.get(t);if(n)return n;n=t.getAnimations(),hr.set(t,n),Xh.schedule(Yh);const r=n.filter(s=>Hs(s.effect)&&s.effect.target===e);return hr.set(e,r),n}function Qh(e,t){const n=Zh(e).filter(r=>{var s,i;if(Hs(r.effect)){const{target:o}=r.effect;if((i=o&&((s=t.isValidTarget)==null?void 0:s.call(t,o)))!=null?i:!0)return r.effect.getKeyframes().some(l=>{for(const d of t.properties)if(l[d])return!0})}}).map(r=>{const{effect:s,currentTime:i}=r,o=s?.getComputedTiming().duration;if(!(r.pending||r.playState==="finished")&&typeof o=="number"&&typeof i=="number"&&i<o)return r.currentTime=o,()=>{r.currentTime=i}});if(n.length>0)return()=>n.forEach(r=>r?.())}var ft=class extends ht{constructor(e,t={}){var n,r,s,i;const{frameTransform:o=$n(e),ignoreTransforms:a,getBoundingClientRect:l=Xs}=t,d=Qh(e,{properties:["transform","translate","scale","width","height"],isValidTarget:_=>(_!==e||ea())&&_.contains(e)}),u=l(e);let{top:c,left:f,width:h,height:p}=u,m;const b=mt(e),w=Ys(b),v={x:(n=w?.scaleX)!=null?n:1,y:(r=w?.scaleY)!=null?r:1},g=Jh(e,b);d?.(),w&&(m=Hh(u,w,b.transformOrigin),(a||g)&&(c=m.top,f=m.left,h=m.width,p=m.height));const y={width:(s=m?.width)!=null?s:h,height:(i=m?.height)!=null?i:p};if(g&&!a&&m){const _=Uh(m,g,b.transformOrigin);c=_.top,f=_.left,h=_.width,p=_.height,v.x=g.scaleX,v.y=g.scaleY}o&&(a||(f*=o.scaleX,h*=o.scaleX,c*=o.scaleY,p*=o.scaleY),f+=o.x,c+=o.y),super(f,c,h,p),this.scale=v,this.intrinsicWidth=y.width,this.intrinsicHeight=y.height}};function Jh(e,t){const n=e.getAnimations();if(!n.length)return null;let r,s,i,o=!1;for(const a of n){if(a.playState!=="running")continue;const l=Hs(a.effect)?a.effect.getKeyframes():[],d=l[l.length-1];if(!d)continue;const{transform:u,translate:c,scale:f}=d;typeof u=="string"&&u&&(r=u,o=!0),typeof c=="string"&&c&&(s=c,o=!0),typeof f=="string"&&f&&(i=f,o=!0)}return o?Ys({transform:r??t.transform,translate:s??t.translate,scale:i??t.scale}):null}function pr(e){return"style"in e&&typeof e.style=="object"&&e.style!==null&&"setProperty"in e.style&&"removeProperty"in e.style&&typeof e.style.setProperty=="function"&&typeof e.style.removeProperty=="function"}var ep=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=""){const{element:n}=this;if(pr(n))for(const[r,s]of Object.entries(e)){const i=`${t}${r}`;this.initial.has(i)||this.initial.set(i,n.style.getPropertyValue(i)),n.style.setProperty(i,typeof s=="string"?s:`${s}px`)}}remove(e,t=""){const{element:n}=this;if(pr(n))for(const r of e){const s=`${t}${r}`;n.style.removeProperty(s)}}reset(){const{element:e}=this;if(pr(e)){for(const[t,n]of this.initial)e.style.setProperty(t,n);e.getAttribute("style")===""&&e.removeAttribute("style")}}};function Ht(e){return e?e instanceof Ze(e).Element||Rr(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function wr(e){if(!e)return!1;const{KeyboardEvent:t}=Ze(e.target);return e instanceof t}function tp(e){if(!e)return!1;const{PointerEvent:t}=Ze(e.target);return e instanceof t}function np(e){if(!Ht(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||rp(e)}function rp(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var pi={};function Ji(e){const t=pi[e]==null?0:pi[e]+1;return pi[e]=t,`${e}-${t}`}var sa=({dragOperation:e,droppable:t})=>{const n=e.position.current;if(!n)return null;const{id:r}=t;if(!t.shape)return null;if(t.shape.containsPoint(n)){const s=Je.distance(t.shape.center,n);return{id:r,value:1/s,type:Rn.PointerIntersection,priority:Pn.High}}return null},sp=({dragOperation:e,droppable:t})=>{const{shape:n}=e;if(!t.shape||!n?.current)return null;const r=n.current.intersectionArea(t.shape);if(r){const{position:s}=e,i=Je.distance(t.shape.center,s.current),a=r/(n.current.area+t.shape.area-r)/i;return{id:t.id,value:a,type:Rn.ShapeIntersection,priority:Pn.Normal}}return null},xu=e=>{var t;return(t=sa(e))!=null?t:sp(e)},ip=e=>{const{dragOperation:t,droppable:n}=e,{shape:r,position:s}=t;if(!n.shape)return null;const i=r?ht.from(r.current.boundingRectangle).corners:void 0,a=ht.from(n.shape.boundingRectangle).corners.reduce((l,d,u)=>{var c;return l+Je.distance(Je.from(d),(c=i?.[u])!=null?c:s.current)},0)/4;return{id:n.id,value:1/a,type:Rn.Collision,priority:Pn.Normal}},op=Object.create,ia=Object.defineProperty,ap=Object.defineProperties,lp=Object.getOwnPropertyDescriptor,cp=Object.getOwnPropertyDescriptors,As=Object.getOwnPropertySymbols,wu=Object.prototype.hasOwnProperty,_u=Object.prototype.propertyIsEnumerable,ku=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ln=e=>{throw TypeError(e)},eo=(e,t,n)=>t in e?ia(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_r=(e,t)=>{for(var n in t||(t={}))wu.call(t,n)&&eo(e,n,t[n]);if(As)for(var n of As(t))_u.call(t,n)&&eo(e,n,t[n]);return e},oa=(e,t)=>ap(e,cp(t)),Qa=(e,t)=>ia(e,"name",{value:t,configurable:!0}),Su=(e,t)=>{var n={};for(var r in e)wu.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&As)for(var r of As(e))t.indexOf(r)<0&&_u.call(e,r)&&(n[r]=e[r]);return n},Nn=e=>{var t;return[,,,op((t=e?.[ku("metadata")])!=null?t:null)]},$u=["class","method","getter","setter","accessor","field","value","get","set"],rr=e=>e!==void 0&&typeof e!="function"?Ln("Function expected"):e,up=(e,t,n,r,s)=>({kind:$u[e],name:t,metadata:r,addInitializer:i=>n._?Ln("Already initialized"):s.push(rr(i||null))}),Jt=(e,t)=>eo(t,ku("metadata"),e[3]),Pe=(e,t,n,r)=>{for(var s=0,i=e[t>>1],o=i&&i.length;s<o;s++)t&1?i[s].call(n):r=i[s].call(n,r);return r},st=(e,t,n,r,s,i)=>{var o,a,l,d,u,c=t&7,f=!!(t&8),h=!!(t&16),p=c>3?e.length+1:c?f?1:2:0,m=$u[c+5],b=c>3&&(e[p-1]=[]),w=e[p]||(e[p]=[]),v=c&&(!h&&!f&&(s=s.prototype),c<5&&(c>3||!h)&&lp(c<4?s:{get[n](){return be(this,i)},set[n](y){return Ke(this,i,y)}},n));c?h&&c<4&&Qa(i,(c>2?"set ":c>1?"get ":"")+n):Qa(s,n);for(var g=r.length-1;g>=0;g--)d=up(c,n,l={},e[3],w),c&&(d.static=f,d.private=h,u=d.access={has:h?y=>dp(s,y):y=>n in y},c^3&&(u.get=h?y=>(c^1?be:Xt)(y,s,c^4?i:v.get):y=>y[n]),c>2&&(u.set=h?(y,_)=>Ke(y,s,_,c^4?i:v.set):(y,_)=>y[n]=_)),a=(0,r[g])(c?c<4?h?i:v[m]:c>4?void 0:{get:v.get,set:v.set}:s,d),l._=1,c^4||a===void 0?rr(a)&&(c>4?b.unshift(a):c?h?i=a:v[m]=a:s=a):typeof a!="object"||a===null?Ln("Object expected"):(rr(o=a.get)&&(v.get=o),rr(o=a.set)&&(v.set=o),rr(o=a.init)&&b.unshift(o));return c||Jt(e,s),v&&ia(s,n,v),h?c^4?i:v:s},aa=(e,t,n)=>t.has(e)||Ln("Cannot "+n),dp=(e,t)=>Object(t)!==t?Ln('Cannot use the "in" operator on this value'):e.has(t),be=(e,t,n)=>(aa(e,t,"read from private field"),n?n.call(e):t.get(e)),Ie=(e,t,n)=>t.has(e)?Ln("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ke=(e,t,n,r)=>(aa(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Xt=(e,t,n)=>(aa(e,t,"access private method"),n),Ja={role:"button",roleDescription:"draggable"},fp="dnd-kit-description",hp="dnd-kit-announcement",pp={draggable:"To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item in a given direction. Press space again to drop the item in its new position, or press escape to cancel."},gp={dragstart({operation:{source:e}}){if(e)return`Picked up draggable item ${e.id}.`},dragover({operation:{source:e,target:t}}){if(!(!e||e.id===t?.id))return t?`Draggable item ${e.id} was moved over droppable target ${t.id}.`:`Draggable item ${e.id} is no longer over a droppable target.`},dragend({operation:{source:e,target:t},canceled:n}){if(e)return n?`Dragging was cancelled. Draggable item ${e.id} was dropped.`:t?`Draggable item ${e.id} was dropped over droppable target ${t.id}`:`Draggable item ${e.id} was dropped.`}};function mp(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function vp(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function yp(e){const t=document.createElement("div");return t.id=e,t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),t.style.setProperty("position","fixed"),t.style.setProperty("width","1px"),t.style.setProperty("height","1px"),t.style.setProperty("margin","-1px"),t.style.setProperty("border","0"),t.style.setProperty("padding","0"),t.style.setProperty("overflow","hidden"),t.style.setProperty("clip","rect(0 0 0 0)"),t.style.setProperty("clip-path","inset(100%)"),t.style.setProperty("white-space","nowrap"),t}var bp=["dragover","dragmove"],xp=class extends We{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=fp,announcement:s=hp}={},announcements:i=gp,screenReaderInstructions:o=pp,debounce:a=500}=t??{},l=n?`${r}-${n}`:Ji(r),d=n?`${s}-${n}`:Ji(s);let u,c,f,h;const p=(_=h)=>{!f||!_||f?.nodeValue!==_&&(f.nodeValue=_)},m=()=>Is.schedule(p),b=wp(m,a),w=Object.entries(i).map(([_,S])=>this.manager.monitor.addEventListener(_,(E,A)=>{const T=f;if(!T)return;const D=S?.(E,A);D&&T.nodeValue!==D&&(h=D,bp.includes(_)?b():(m(),b.cancel()))})),v=()=>{let _=[];u?.isConnected||(u=vp(l,o.draggable),_.push(u)),c?.isConnected||(c=yp(d),f=document.createTextNode(""),c.appendChild(f),_.push(c)),_.length>0&&document.body.append(..._)},g=new Set;function y(){for(const _ of g)_()}this.registerEffect(()=>{var _;g.clear();for(const S of this.manager.registry.draggables.value){const E=(_=S.handle)!=null?_:S.element;if(E){(!u||!c)&&g.add(v),(!mp(E)||ea())&&!E.hasAttribute("tabindex")&&g.add(()=>E.setAttribute("tabindex","0")),!E.hasAttribute("role")&&E.tagName.toLowerCase()!=="button"&&g.add(()=>E.setAttribute("role",Ja.role)),E.hasAttribute("aria-roledescription")||g.add(()=>E.setAttribute("aria-roledescription",Ja.roleDescription)),E.hasAttribute("aria-describedby")||g.add(()=>E.setAttribute("aria-describedby",l));for(const T of["aria-pressed","aria-grabbed"]){const D=String(S.isDragging);E.getAttribute(T)!==D&&g.add(()=>E.setAttribute(T,D))}const A=String(S.disabled);E.getAttribute("aria-disabled")!==A&&g.add(()=>E.setAttribute("aria-disabled",A))}}g.size>0&&Is.schedule(y)}),this.destroy=()=>{super.destroy(),u?.remove(),c?.remove(),w.forEach(_=>_())}}};function wp(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var Ms=new Map,Tu,Ou,Eu,Cu,to,gr,yt,la,Tn,Iu,Du,Au,Mu,Mt=class extends(to=Pr,Cu=[he],Eu=[Ee],Ou=[Ee],Tu=[Ee],to){constructor(t,n){super(t,n),Pe(yt,5,this),Ie(this,Tn),Ie(this,gr,new Set),Ie(this,la,Pe(yt,8,this,new Set)),Pe(yt,11,this),this.registerEffect(Xt(this,Tn,Iu))}register(t){return be(this,gr).add(t),()=>{be(this,gr).delete(t)}}addRoot(t){return fe(()=>{const n=new Set(this.additionalRoots);n.add(t),this.additionalRoots=n}),()=>{fe(()=>{const n=new Set(this.additionalRoots);n.delete(t),this.additionalRoots=n})}}get sourceRoot(){var t;const{source:n}=this.manager.dragOperation;return Os((t=n?.element)!=null?t:null)}get targetRoot(){var t;const{target:n}=this.manager.dragOperation;return Os((t=n?.element)!=null?t:null)}get roots(){const{status:t}=this.manager.dragOperation;if(t.initializing||t.initialized){const n=[this.sourceRoot,this.targetRoot].filter(r=>r!=null);return new Set([...n,...this.additionalRoots])}return new Set}};yt=Nn(to);gr=new WeakMap;la=new WeakMap;Tn=new WeakSet;Iu=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of be(this,gr))t.push(Xt(this,Tn,Du).call(this,n,r));return()=>{for(const n of t)n()}};Du=function(e,t){let n=Ms.get(e);n||(n=new Map,Ms.set(e,n));let r=n.get(t);if(!r){const i=Jo(e)?Xt(this,Tn,Au).call(this,e,n,t):Xt(this,Tn,Mu).call(this,e,n,t);if(!i)return()=>{};r=i,n.set(t,r)}r.refCount++;let s=!1;return()=>{s||(s=!0,r.refCount--,r.refCount===0&&r.cleanup())}};Au=function(e,t,n){var r;const s=e.createElement("style"),{nonce:i}=(r=this.options)!=null?r:{};i&&s.setAttribute("nonce",i),s.textContent=n,e.head.prepend(s);const o=new MutationObserver(a=>{for(const l of a)for(const d of Array.from(l.removedNodes))if(d===s){e.head.prepend(s);return}});return o.observe(e.head,{childList:!0}),{refCount:0,cleanup:()=>{o.disconnect(),s.remove(),t.delete(n),t.size===0&&Ms.delete(e)}}};Mu=function(e,t,n){"adoptedStyleSheets"in e&&Array.isArray(e.adoptedStyleSheets);const r=e.ownerDocument.defaultView,{CSSStyleSheet:s}=r??{};if(!s)return null;const i=new s;return i.replaceSync(n),e.adoptedStyleSheets.push(i),{refCount:0,cleanup:()=>{var o;if(ta(e)&&((o=e.host)!=null&&o.isConnected)){const a=e.adoptedStyleSheets.indexOf(i);a!==-1&&e.adoptedStyleSheets.splice(a,1)}t.delete(n),t.size===0&&Ms.delete(e)}}};st(yt,4,"additionalRoots",Cu,Mt,la);st(yt,2,"sourceRoot",Eu,Mt);st(yt,2,"targetRoot",Ou,Mt);st(yt,2,"roots",Tu,Mt);Jt(yt,Mt);Mt.configure=Mr(Mt);var Zs=Mt,_p=class extends We{constructor(e,t){super(e,t),this.manager=e;const{cursor:n="grabbing"}=t??{},r=e.registry.plugins.get(Zs),s=r?.register(`* { cursor: ${n} !important; }`);if(s){const i=this.destroy.bind(this);this.destroy=()=>{s(),i()}}}},jr="data-dnd-",no=`${jr}dropping`,Le="--dnd-",dt=`${jr}dragging`,Ps=`${jr}placeholder`,kp=[dt,Ps,"popover","aria-pressed","aria-grabbing"],Sp=["view-transition-name"],$p=`
|
|
9
9
|
:is(:root,:host) [${dt}] {
|
|
10
10
|
position: fixed !important;
|
|
11
11
|
pointer-events: none !important;
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
transition: var(${Le}transition) !important;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
:is(:root,:host) [${
|
|
27
|
+
:is(:root,:host) [${Ps}] {
|
|
28
28
|
transition: none;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
:is(:root,:host) [${
|
|
31
|
+
:is(:root,:host) [${Ps}='hidden'] {
|
|
32
32
|
visibility: hidden;
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
pointer-events: none !important;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
[${dt}]:not([${
|
|
39
|
+
[${dt}]:not([${no}]) {
|
|
40
40
|
translate: var(${Le}translate) !important;
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -60,64 +60,64 @@
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
[${dt}]::backdrop, [${
|
|
63
|
+
[${dt}]::backdrop, [${jr}overlay]:not([${dt}]) {
|
|
64
64
|
display: none;
|
|
65
65
|
visibility: hidden;
|
|
66
66
|
}
|
|
67
|
-
`.replace(/\n+/g," ").replace(/\s+/g," ").trim();function Ip(e,t="hidden"){return ue(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const s=Dp(n,r.registry.droppables),i=[],o=$h(n),{remove:a}=o;return Ap(s,o,i),Pp(o,t),o.remove=()=>{i.forEach(l=>l()),a.call(o)},o})}function Dp(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const s=`${Pr}${Yi("dom-id")}`;r.element.setAttribute(s,""),n.set(r,s)}return n}function Ap(e,t,n){for(const[r,s]of e){if(!r.element)continue;const i=`[${s}]`,o=t.matches(i)?t:t.querySelector(i);if(r.element.removeAttribute(s),!o)continue;const a=r.element;r.proxy=o,o.removeAttribute(s),Ui.set(a,o),n.push(()=>{Ui.delete(a),r.proxy=void 0})}}function Pp(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(Is,t)}function Pd(e,t){return e===t?!0:_n(e)===_n(t)}function Ja(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&Ut(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>mn(t))}function eo(e){return e.tagName==="TR"}function Mp(e,t,n){const r=new MutationObserver(s=>{let i=!1;for(const o of s){if(o.target!==e){i=!0;continue}if(o.type!=="attributes")continue;const a=o.attributeName;if(a.startsWith("aria-")||Op.includes(a))continue;const l=e.getAttribute(a);if(a==="style"){if(ur(e)&&ur(t)){const u=e.style;for(const d of Array.from(t.style))u.getPropertyValue(d)===""&&t.style.removeProperty(d);for(const d of Array.from(u)){if(Ep.includes(d)||d.startsWith(Le))continue;const c=u.getPropertyValue(d);t.style.setProperty(d,c)}}}else l!==null?t.setAttribute(a,l):t.removeAttribute(a)}i&&n&&t.replaceChildren(...e.cloneNode(!0).childNodes)});return r.observe(e,{attributes:!0,subtree:!0,childList:!0}),r}function jp(e,t,n){const r=new MutationObserver(s=>{for(const i of s)if(i.addedNodes.length!==0)for(const o of Array.from(i.addedNodes)){if(o.contains(e)&&e.nextElementSibling!==t){e.insertAdjacentElement("afterend",t),mn(n);return}if(o.contains(t)&&t.previousElementSibling!==e){t.insertAdjacentElement("beforebegin",e),mn(n);return}}e.isConnected&&t.isConnected&&e.nextElementSibling!==t&&(e.insertAdjacentElement("afterend",t),mn(n))});return r.observe(e.ownerDocument.body,{childList:!0,subtree:!0}),r}function Rp(e){return new ResizeObserver(()=>{var t,n,r;const s=new ut(e.placeholder,{frameTransform:e.frameTransform,ignoreTransforms:!0}),i=(t=e.transformOrigin)!=null?t:{x:1,y:1},o=(e.width-s.width)*i.x+e.delta.x,a=(e.height-s.height)*i.y+e.delta.y,l=ld();if(e.styles.set({width:s.width-e.widthOffset,height:s.height-e.heightOffset,top:e.top+a+l.y,left:e.left+o+l.x},Le),(n=e.getElementMutationObserver())==null||n.takeRecords(),eo(e.element)&&eo(e.placeholder)){const m=Array.from(e.element.cells),y=Array.from(e.placeholder.cells);e.getSavedCellWidths()||e.setSavedCellWidths(m.map(w=>w.style.width));for(const[w,v]of m.entries()){const g=y[w];v.style.width=`${g.getBoundingClientRect().width}px`}}const u=(r=e.getTranslate())!=null?r:{x:0,y:0},d=e.left+o+l.x+u.x,c=e.top+a+l.y+u.y,f=s.width-e.widthOffset,p=s.height-e.heightOffset,h=e.frameTransform;e.dragOperation.shape=new ft(d*h.scaleX+h.x,c*h.scaleY+h.y,f*h.scaleX,p*h.scaleY)})}var Lp=250,Np="ease";function Fp(e){var t,n,r,s;const{animation:i}=e;if(typeof i=="function"){const v=i({source:e.source,element:e.element,feedbackElement:e.feedbackElement,placeholder:e.placeholder,translate:e.translate,moved:e.moved});Promise.resolve(v).then(()=>{e.cleanup(),requestAnimationFrame(e.restoreFocus)});return}const{duration:o=Lp,easing:a=Np}=i??{};mn(e.feedbackElement);const[,l]=(t=id(e.feedbackElement,v=>"translate"in v))!=null?t:[];l?.pause();const u=(n=e.placeholder)!=null?n:e.element,d={frameTransform:Pd(e.feedbackElement,u)?null:void 0},c=new ut(e.feedbackElement,d),f=(r=vr(gt(e.feedbackElement).translate))!=null?r:e.translate,p=new ut(u,d),h=ft.delta(c,p,e.alignment),m={x:f.x-h.x,y:f.y-h.y},y=Math.round(c.intrinsicHeight)!==Math.round(p.intrinsicHeight)?{minHeight:[`${c.intrinsicHeight}px`,`${p.intrinsicHeight}px`],maxHeight:[`${c.intrinsicHeight}px`,`${p.intrinsicHeight}px`]}:{},w=Math.round(c.intrinsicWidth)!==Math.round(p.intrinsicWidth)?{minWidth:[`${c.intrinsicWidth}px`,`${p.intrinsicWidth}px`],maxWidth:[`${c.intrinsicWidth}px`,`${p.intrinsicWidth}px`]}:{};e.styles.set({transition:e.transition},Le),e.feedbackElement.setAttribute(Ji,""),(s=e.getElementMutationObserver())==null||s.takeRecords(),bd({element:e.feedbackElement,keyframes:sa(yr(yr({},y),w),{translate:[`${f.x}px ${f.y}px 0`,`${m.x}px ${m.y}px 0`]}),options:{duration:ea(Qe(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?o:0,easing:a}}).then(()=>{e.feedbackElement.removeAttribute(Ji),l?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var Md,to,xr,aa,fs,jd,Rd,$n=class extends(to=We,Md=[fe],to){constructor(t,n){super(t,n),Ce(this,fs),Ce(this,aa,Me(xr,8,this)),Me(xr,11,this),this.state={initial:{},current:{}};const r=t.registry.plugins.get(Vs),s=r?.register(Cp);if(s){const i=this.destroy.bind(this);this.destroy=()=>{s(),i()}}this.registerEffect(Vt(this,fs,jd).bind(this,r)),this.registerEffect(Vt(this,fs,Rd))}};xr=Rn(to);aa=new WeakMap;fs=new WeakSet;jd=function(e){const{overlay:t}=this;if(!t||!e)return;const n=ks(t);if(n)return e.addRoot(n)};Rd=function(){var e,t,n,r,s,i,o;const{state:a,manager:l,options:u}=this,{dragOperation:d}=l,{position:c,source:f,status:p}=d;if(p.idle){a.current={},a.initial={};return}if(!f)return;const{element:h}=f,m=f.pluginConfig($n),y=(t=(e=m?.feedback)!=null?e:u?.feedback)!=null?t:"default",w=typeof y=="function"?y(f,l):y;if(!h||w==="none"||!p.initialized||p.initializing)return;const{initial:v}=a,g=(n=this.overlay)!=null?n:h,b=kn(g),_=kn(h),O=!Pd(h,g),I=new ut(h,{frameTransform:O?_:null,ignoreTransforms:!O}),M={x:_.scaleX/b.scaleX,y:_.scaleY/b.scaleY};let{width:T,height:D,top:N,left:R}=I;O&&(T=T/M.x,D=D/M.y);const W=new sp(g),X=gt(h),{transition:G,translate:U,boxSizing:Y,paddingBlockStart:re,paddingBlockEnd:ee,paddingInlineStart:A,paddingInlineEnd:B,borderInlineStartWidth:z,borderInlineEndWidth:j,borderBlockStartWidth:q,borderBlockEndWidth:J}=X,Q=G.split(",").filter(be=>!/^\s*(transform|translate|scale)\b/.test(be)).join(","),H=Us(X),$=X.transform,P=w==="clone",F=Y==="content-box",V=F?parseInt(A)+parseInt(B)+parseInt(z)+parseInt(j):0,oe=F?parseInt(re)+parseInt(ee)+parseInt(q)+parseInt(J):0,Z=w!=="move"&&!this.overlay?Ip(f,P?"clone":"hidden"):null,ne=ue(()=>br(l.dragOperation.activatorEvent));if(!v.translate){if(this.overlay&&H)v.translate={x:H.x,y:H.y};else if(U!=="none"){const be=vr(U);be&&(v.translate=be)}}if(!v.transformOrigin){const be=ue(()=>c.current),Ie=R+((r=H?.x)!=null?r:0),He=N+((s=H?.y)!=null?s:0);v.transformOrigin={x:(be.x-Ie*b.scaleX-b.x)/(T*b.scaleX),y:(be.y-He*b.scaleY-b.y)/(D*b.scaleY)}}const{transformOrigin:de}=v,se=N*b.scaleY+b.y,L=R*b.scaleX+b.x;if(!v.coordinates&&(v.coordinates={x:L,y:se},M.x!==1||M.y!==1)){const{scaleX:be,scaleY:Ie}=_,{x:He,y:St}=de;v.coordinates.x+=(T*be-T)*He,v.coordinates.y+=(D*Ie-D)*St}v.dimensions||(v.dimensions={width:T,height:D}),v.frameTransform||(v.frameTransform=b);const te={x:v.coordinates.x-L,y:v.coordinates.y-se},pe={width:(v.dimensions.width*v.frameTransform.scaleX-T*b.scaleX)*de.x,height:(v.dimensions.height*v.frameTransform.scaleY-D*b.scaleY)*de.y},ae={x:te.x/b.scaleX+pe.width,y:te.y/b.scaleY+pe.height},C={left:R+ae.x,top:N+ae.y};g.setAttribute(dt,"true");const K=ue(()=>d.transform),ie=(i=v.translate)!=null?i:{x:0,y:0},ve=K.x*b.scaleX+ie.x,Re=K.y*b.scaleY+ie.y,Nn=ld();W.set({width:T-V,height:D-oe,top:C.top+Nn.y,left:C.left+Nn.x,translate:`${ve}px ${Re}px 0`,transform:this.overlay?"none":$,transition:Q?`${Q}, translate 0ms linear`:"translate 0ms linear",scale:O?`${M.x} ${M.y}`:"","transform-origin":`${de.x*100}% ${de.y*100}%`},Le),Z&&(h.insertAdjacentElement("afterend",Z),u?.rootElement&&(typeof u.rootElement=="function"?u.rootElement(f):u.rootElement).appendChild(h)),Hi(g)&&(g.hasAttribute("popover")||g.setAttribute("popover","manual"),mn(g),g.addEventListener("beforetoggle",Ja));let mt,Fn,vt;const $a=Rp({placeholder:Z,element:h,feedbackElement:g,frameTransform:b,transformOrigin:de,width:T,height:D,top:N,left:R,widthOffset:V,heightOffset:oe,delta:ae,styles:W,dragOperation:d,getTranslate:()=>a.current.translate,getElementMutationObserver:()=>mt,getSavedCellWidths:()=>vt,setSavedCellWidths:be=>{vt=be}}),Ta=new ut(g);ue(()=>d.shape=Ta);const ei=Qe(g),Oa=be=>{this.manager.actions.stop({event:be})},ef=ea(ei);ne&&ei.addEventListener("resize",Oa),ue(()=>f.status)==="idle"&&requestAnimationFrame(()=>f.status="dragging"),Z&&($a.observe(Z),mt=Mp(h,Z,P),Fn=jp(h,Z,g));const Ea=(o=l.dragOperation.source)==null?void 0:o.id,tf=()=>{var be;if(!ne||Ea==null)return;const Ie=l.registry.draggables.get(Ea),He=(be=Ie?.handle)!=null?be:Ie?.element;Pt(He)&&He.focus()},ti=()=>{mt?.disconnect(),Fn?.disconnect(),$a.disconnect(),ei.removeEventListener("resize",Oa),Hi(g)&&(g.removeEventListener("beforetoggle",Ja),g.removeAttribute("popover")),g.removeAttribute(dt),W.reset();const be=()=>{var Ie;if(vt&&eo(h)){const ni=Array.from(h.cells);for(const[zr,Jt]of ni.entries())Jt.style.width=(Ie=vt[zr])!=null?Ie:""}f.status="idle";const He=a.current.translate!=null,St=d.status.dragging;Z&&(!St&&He||Z.parentElement!==g.parentElement)&&g.isConnected&&Z.replaceWith(g),Z?.remove()};g===this.overlay?setTimeout(be,0):be()},nf=u?.dropAnimation,Ca=this,rf=Er(()=>{var be,Ie,He;const{transform:St,status:ni}=d;if(!(!St.x&&!St.y&&!a.current.translate)&&ni.dragging){const zr=(be=v.translate)!=null?be:{x:0,y:0},Jt={x:St.x/b.scaleX+zr.x,y:St.y/b.scaleY+zr.y},Ia=a.current.translate,sf=ue(()=>d.modifiers),ri=ue(()=>{var Wn;return(Wn=d.shape)==null?void 0:Wn.current}),zn=u?.keyboardTransition,Da=ne&&!ef&&zn!==null?`${(Ie=zn?.duration)!=null?Ie:250}ms ${(He=zn?.easing)!=null?He:"cubic-bezier(0.25, 1, 0.5, 1)"}`:"0ms linear";if(W.set({transition:Q?`${Q}, translate ${Da}`:`translate ${Da}`,translate:`${Jt.x}px ${Jt.y}px 0`},Le),mt?.takeRecords(),ri&&ri!==Ta&&Ia&&!sf.length){const Wn=et.delta(Jt,Ia);d.shape=ft.from(ri.boundingRectangle).translate(Wn.x*b.scaleX,Wn.y*b.scaleY)}else d.shape=new ut(g);a.current.translate=Jt}},function(){if(d.status.dropped){this.dispose(),f.status="dropping";const be=m?.dropAnimation!==void 0?m.dropAnimation:Ca.dropAnimation!==void 0?Ca.dropAnimation:nf;let Ie=a.current.translate;const He=Ie!=null;if(!Ie&&h!==g&&(Ie={x:0,y:0}),!Ie||be===null){ti();return}l.renderer.rendering.then(()=>{Fp({source:f,element:h,feedbackElement:g,placeholder:Z,translate:Ie,moved:He,transition:G,alignment:f.alignment,styles:W,animation:be??void 0,getElementMutationObserver:()=>mt,cleanup:ti,restoreFocus:tf})})}});return()=>{ti(),rf()}};it(xr,4,"overlay",Md,$n,aa);Qt(xr,$n);$n.configure=Ir($n);var la=$n,Bn=!0,zp=!1,Ld,Nd,Fd,zd,Et,ca,da;zd=(Fd=[fe],tt.Forward),Nd=(Ld=[fe],tt.Reverse);var wr=class{constructor(){Ce(this,ca,Me(Et,8,this,Bn)),Me(Et,11,this),Ce(this,da,Me(Et,12,this,Bn)),Me(Et,15,this)}isLocked(e){return e===tt.Idle?!1:e==null?this[tt.Forward]===Bn&&this[tt.Reverse]===Bn:this[e]===Bn}unlock(e){e!==tt.Idle&&(this[e]=zp)}};Et=Rn(null);ca=new WeakMap;da=new WeakMap;it(Et,4,zd,Fd,wr,ca);it(Et,4,Nd,Ld,wr,da);Qt(Et,wr);var Wp=[tt.Forward,tt.Reverse],el=class{constructor(){this.x=new wr,this.y=new wr}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},Bp=class extends We{constructor(e){super(e);const t=Tn(new el);let n=null;this.signal=t,st(()=>{const{status:r}=e.dragOperation;if(!r.initialized){n=null,t.value=new el;return}const{delta:s}=e.dragOperation.position;if(n){const i={x:tl(s.x,n.x),y:tl(s.y,n.y)},o=t.peek();Te(()=>{for(const a of gc)for(const l of Wp)i[a]===l&&o[a].unlock(l);t.value=o})}n=s})}get current(){return this.signal.peek()}};function tl(e,t){return Math.sign(e-t)}var Wd,no,_r,ua,Tt,ro,Mr=class extends(no=Dr,Wd=[fe],no){constructor(e){super(e),Ce(this,ua,Me(_r,8,this,!1)),Me(_r,11,this),Ce(this,Tt),Ce(this,ro,()=>{if(!ye(this,Tt))return;const{element:i,by:o}=ye(this,Tt);o.y&&(i.scrollTop+=o.y),o.x&&(i.scrollLeft+=o.x)}),this.scroll=(i,o)=>{var a;if(this.disabled)return!1;const l=this.getScrollableElements();if(!l)return qe(this,Tt,void 0),!1;const{position:u}=this.manager.dragOperation,d=u?.current;if(d){const{by:c}=i??{},f=c?{x:nl(c.x),y:nl(c.y)}:void 0,p=f?void 0:this.scrollIntentTracker.current;if(p?.isLocked())return!1;for(const h of l){const m=Nh(h,c);if(m.x||m.y){const{speed:y,direction:w}=Xh(h,d,f,o?.acceleration,o?.threshold);if(p)for(const v of gc)p[v].isLocked(w[v])&&(y[v]=0,w[v]=0);if(w.x||w.y){const{x:v,y:g}=c??w,b=v*y.x,_=g*y.y;if(b||_){const O=(a=ye(this,Tt))==null?void 0:a.by;if(this.autoScrolling&&O&&(O.x&&!b||O.y&&!_))continue;return qe(this,Tt,{element:h,by:{x:b,y:_}}),Ts.schedule(ye(this,ro)),!0}}}}}return qe(this,Tt,void 0),!1};let t=null,n=null;const r=Ai(()=>{const{position:i,source:o}=e.dragOperation;if(!i)return null;const a=cd(ks(o?.element),i.current);return a&&(t=a),a??t}),s=Ai(()=>{const i=r.value,{documentElement:o}=Mn(i);if(!i||i===o){const{target:a}=e.dragOperation,l=a?.element;if(l){const u=Xi(l,{excludeElement:!1});return n=u,u}}if(i){const a=Xi(i,{excludeElement:!1});return this.autoScrolling&&n&&a.size<n?.size?n:(n=a,a)}return n=null,null},ot);this.getScrollableElements=()=>s.value,this.scrollIntentTracker=new Bp(e),this.destroy=e.monitor.addEventListener("dragmove",i=>{this.disabled||i.defaultPrevented||!br(e.dragOperation.activatorEvent)||!i.by||this.scroll({by:i.by})&&i.preventDefault()})}};_r=Rn(no);ua=new WeakMap;Tt=new WeakMap;ro=new WeakMap;it(_r,4,"autoScrolling",Wd,Mr,ua);Qt(_r,Mr);function nl(e){return e>0?tt.Forward:e<0?tt.Reverse:tt.Idle}var Gp=class{constructor(e){this.scheduler=e,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{const{tasks:t,resolvers:n}=this;this.pending=!1,this.tasks=new Set,this.resolvers=new Set;for(const r of t)r();for(const r of n)r()}}schedule(e){return this.tasks.add(e),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(t=>this.resolvers.add(t))}},qp=new Gp(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),Kp=10,so=class extends We{constructor(t,n){super(t,n);const r=t.registry.plugins.get(Mr);if(!r)throw new Error("AutoScroller plugin depends on Scroller plugin");this.destroy=st(()=>{var s,i,o;if(this.disabled)return;const{position:a,status:l}=t.dragOperation;if(l.dragging){const u={acceleration:(s=this.options)==null?void 0:s.acceleration,threshold:typeof((i=this.options)==null?void 0:i.threshold)=="number"?{x:this.options.threshold,y:this.options.threshold}:(o=this.options)==null?void 0:o.threshold};if(r.scroll(void 0,u)){r.autoScrolling=!0;const c=setInterval(()=>qp.schedule(()=>r.scroll(void 0,u)),Kp);return()=>{clearInterval(c)}}else r.autoScrolling=!1}})}};so.configure=Ir(so);var Bd=so,rl={capture:!0,passive:!0},tr,Up=class extends Dr{constructor(e){super(e),Ce(this,tr),this.handleScroll=()=>{ye(this,tr)==null&&qe(this,tr,setTimeout(()=>{this.manager.collisionObserver.forceUpdate(!1),qe(this,tr,void 0)},50))};const{dragOperation:t}=this.manager;this.destroy=st(()=>{var n,r,s;if(t.status.dragging){const o=(s=(r=(n=t.source)==null?void 0:n.element)==null?void 0:r.ownerDocument)!=null?s:document;return o.addEventListener("scroll",this.handleScroll,rl),()=>{o.removeEventListener("scroll",this.handleScroll,rl)}}})}};tr=new WeakMap;var Vp="* { user-select: none !important; -webkit-user-select: none !important; }",Hp=class extends We{constructor(e){super(e),this.manager=e;const t=e.registry.plugins.get(Vs),n=t?.register(Vp);if(this.destroy=st(()=>{const{dragOperation:r}=this.manager;if(r.status.initialized)return fi(),document.addEventListener("selectionchange",fi,{capture:!0}),()=>{document.removeEventListener("selectionchange",fi,{capture:!0})}}),n){const r=this.destroy.bind(this);this.destroy=()=>{n(),r()}}}};function fi(){var e;(e=document.getSelection())==null||e.removeAllRanges()}var nr=Object.freeze({offset:10,keyboardCodes:{start:["Space","Enter"],cancel:["Escape"],end:["Space","Enter","Tab"],up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]},preventActivation(e,t){var n;const r=(n=t.handle)!=null?n:t.element;return e.target!==r}}),dn,Ds=class extends xn{constructor(t,n){super(t),this.manager=t,this.options=n,Ce(this,dn,[]),this.listeners=new dd,this.handleSourceKeyDown=(r,s,i)=>{if(this.disabled||r.defaultPrevented||!Ut(r.target)||s.disabled)return;const{keyboardCodes:o=nr.keyboardCodes,preventActivation:a=nr.preventActivation}=i??{};o.start.includes(r.code)&&this.manager.dragOperation.status.idle&&(a?.(r,s)||this.handleStart(r,s,i))}}bind(t,n=this.options){return st(()=>{var s;const i=(s=t.handle)!=null?s:t.element,o=a=>{br(a)&&this.handleSourceKeyDown(a,t,n)};if(i)return i.addEventListener("keydown",o),()=>{i.removeEventListener("keydown",o)}})}handleStart(t,n,r){const{element:s}=n;if(!s)throw new Error("Source draggable does not have an associated element");t.preventDefault(),t.stopImmediatePropagation(),vd(s);const{center:i}=new ut(s);if(this.manager.actions.start({event:t,coordinates:{x:i.x,y:i.y},source:n}).signal.aborted)return this.cleanup();this.sideEffects();const a=Mn(s),l=[this.listeners.bind(a,[{type:"keydown",listener:u=>this.handleKeyDown(u,n,r),options:{capture:!0}}])];ye(this,dn).push(...l)}handleKeyDown(t,n,r){const{keyboardCodes:s=nr.keyboardCodes}=r??{};if(en(t,[...s.end,...s.cancel])){t.preventDefault();const i=en(t,s.cancel);this.handleEnd(t,i);return}en(t,s.up)?this.handleMove("up",t):en(t,s.down)&&this.handleMove("down",t),en(t,s.left)?this.handleMove("left",t):en(t,s.right)&&this.handleMove("right",t)}handleEnd(t,n){this.manager.actions.stop({event:t,canceled:n}),this.cleanup()}handleMove(t,n){var r,s;const{shape:i}=this.manager.dragOperation,o=n.shiftKey?5:1;let a={x:0,y:0},l=(s=(r=this.options)==null?void 0:r.offset)!=null?s:nr.offset;if(typeof l=="number"&&(l={x:l,y:l}),!!i){switch(t){case"up":a={x:0,y:-l.y*o};break;case"down":a={x:0,y:l.y*o};break;case"left":a={x:-l.x*o,y:0};break;case"right":a={x:l.x*o,y:0};break}(a.x||a.y)&&(n.preventDefault(),this.manager.actions.move({event:n,by:a}))}}sideEffects(){const t=this.manager.registry.plugins.get(Bd);t?.disabled===!1&&(t.disable(),ye(this,dn).push(()=>{t.enable()}))}cleanup(){ye(this,dn).forEach(t=>t()),qe(this,dn,[])}destroy(){this.cleanup(),this.listeners.clear()}};dn=new WeakMap;Ds.configure=Ir(Ds);Ds.defaults=nr;var Gd=Ds;function en(e,t){return t.includes(e.code)}var Wt,Xp=class extends Vc{constructor(){super(...arguments),Ce(this,Wt)}onEvent(e){switch(e.type){case"pointerdown":qe(this,Wt,wn(e));break;case"pointermove":if(!ye(this,Wt))return;const{x:t,y:n}=wn(e),r={x:t-ye(this,Wt).x,y:n-ye(this,Wt).y},{tolerance:s}=this.options;if(s&&Wi(r,s)){this.abort();return}Wi(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort();break}}abort(){qe(this,Wt,void 0)}};Wt=new WeakMap;var un,Bt,Yp=class extends Vc{constructor(){super(...arguments),Ce(this,un),Ce(this,Bt)}onEvent(e){switch(e.type){case"pointerdown":qe(this,Bt,wn(e)),qe(this,un,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!ye(this,Bt))return;const{x:t,y:n}=wn(e),r={x:t-ye(this,Bt).x,y:n-ye(this,Bt).y};Wi(r,this.options.tolerance)&&this.abort();break;case"pointerup":this.abort();break}}abort(){ye(this,un)&&(clearTimeout(ye(this,un)),qe(this,Bt,void 0),qe(this,un,void 0))}};un=new WeakMap;Bt=new WeakMap;var gn=class{};gn.Delay=Yp;gn.Distance=Xp;var io=Object.freeze({activationConstraints(e,t){var n;const{pointerType:r,target:s}=e;if(!(r==="mouse"&&Ut(s)&&(t.handle===s||(n=t.handle)!=null&&n.contains(s))))return r==="touch"?[new gn.Delay({value:250,tolerance:5})]:op(s)&&!e.defaultPrevented?[new gn.Delay({value:200,tolerance:0})]:[new gn.Delay({value:200,tolerance:10}),new gn.Distance({value:5})]},preventActivation(e,t){var n;const{target:r}=e;if(r===t.element||r===t.handle||!Ut(r)||(n=t.handle)!=null&&n.contains(r))return!1;const s=Oh(r);return s===t.element?!1:!!s}}),fn,As=class extends xn{constructor(t,n){super(t),this.manager=t,this.options=n,Ce(this,fn,new Set),this.listeners=new dd,this.latest={event:void 0,coordinates:void 0},this.handleMove=()=>{const{event:r,coordinates:s}=this.latest;!r||!s||this.manager.actions.move({event:r,to:s})},this.handleCancel=this.handleCancel.bind(this),this.handlePointerUp=this.handlePointerUp.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this)}activationConstraints(t,n,r=this.options){const{activationConstraints:s=io.activationConstraints}=r??{};return typeof s=="function"?s(t,n):s}bind(t,n=this.options){return st(()=>{var s;const i=new AbortController,{signal:o}=i,a=u=>{ip(u)&&this.handlePointerDown(u,t,n)};let l=[(s=t.handle)!=null?s:t.element];n?.activatorElements&&(Array.isArray(n.activatorElements)?l=n.activatorElements:l=n.activatorElements(t));for(const u of l)u&&(Jp(u.ownerDocument.defaultView),u.addEventListener("pointerdown",a,{signal:o}));return()=>i.abort()})}handlePointerDown(t,n,r){if(this.disabled||!t.isPrimary||t.button!==0||!Ut(t.target)||n.disabled||Zp(t)||!this.manager.dragOperation.status.idle)return;const{preventActivation:s=io.preventActivation}=r??{};if(s?.(t,n))return;const{target:i}=t,o=Pt(i)&&i.draggable&&i.getAttribute("draggable")==="true",a=kn(n.element),{x:l,y:u}=wn(t);this.initialCoordinates={x:l*a.scaleX+a.x,y:u*a.scaleY+a.y};const d=this.activationConstraints(t,n,r);t.sensor=this;const c=new bh(d,m=>this.handleStart(n,m));c.signal.onabort=()=>this.handleCancel(t),c.onEvent(t),this.controller=c;const f=Ki(),p=this.listeners.bind(f,[{type:"pointermove",listener:m=>this.handlePointerMove(m,n)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:o?this.handleCancel:Ur,options:{capture:!0}}]),h=()=>{p(),this.initialCoordinates=void 0};ye(this,fn).add(h)}handlePointerMove(t,n){var r,s;if(((r=this.controller)==null?void 0:r.activated)===!1){(s=this.controller)==null||s.onEvent(t);return}if(this.manager.dragOperation.status.dragging){const i=wn(t),o=kn(n.element);i.x=i.x*o.scaleX+o.x,i.y=i.y*o.scaleY+o.y,t.preventDefault(),t.stopPropagation(),this.latest.event=t,this.latest.coordinates=i,Ts.schedule(this.handleMove)}}handlePointerUp(t){const{status:n}=this.manager.dragOperation;if(!n.idle){t.preventDefault(),t.stopPropagation();const r=!n.initialized;this.manager.actions.stop({event:t,canceled:r})}this.cleanup()}handleKeyDown(t){t.key==="Escape"&&(t.preventDefault(),this.handleCancel(t))}handleStart(t,n){const{manager:r,initialCoordinates:s}=this;if(!s||!r.dragOperation.status.idle||n.defaultPrevented)return;if(r.actions.start({coordinates:s,event:n,source:t}).signal.aborted)return this.cleanup();n.preventDefault();const a=Mn(n.target).body;try{a.setPointerCapture(n.pointerId)}catch{this.handleCancel(n);return}const l=Ut(n.target)?[n.target,a]:a,u=this.listeners.bind(l,[{type:"touchmove",listener:Ur,options:{passive:!1}},{type:"click",listener:Ur},{type:"contextmenu",listener:Ur},{type:"keydown",listener:this.handleKeyDown}]);ye(this,fn).add(u)}handleCancel(t){const{dragOperation:n}=this.manager;n.status.initialized&&this.manager.actions.stop({event:t,canceled:!0}),this.cleanup()}cleanup(){const{controller:t}=this;this.controller=void 0,t&&!t.signal.aborted&&t.abort(),this.latest={event:void 0,coordinates:void 0},ye(this,fn).forEach(n=>n()),ye(this,fn).clear()}destroy(){this.cleanup(),this.listeners.clear()}};fn=new WeakMap;As.configure=Ir(As);As.defaults=io;var oo=As;function Zp(e){return"sensor"in e}function Ur(e){e.preventDefault()}function Qp(){}var sl=new WeakSet;function Jp(e){!e||sl.has(e)||(e.addEventListener("touchmove",Qp,{capture:!1,passive:!1}),sl.add(e))}var vn={modifiers:[],plugins:[Sp,Bd,Tp,la,Hp],sensors:[oo,Gd]},qd=class extends wh{constructor(e={}){const t=lt(e.plugins,vn.plugins),n=lt(e.sensors,vn.sensors),r=lt(e.modifiers,vn.modifiers);super(sa(yr({},e),{plugins:[Up,Mr,Vs,...t],sensors:n,modifiers:r}))}},Kd,Ud,ao,Ct,fa,ha,Hs=class extends(ao=ht,Ud=[fe],Kd=[fe],ao){constructor(e,t){var n=e,{element:r,effects:s=()=>[],handle:i}=n,o=kd(n,["element","effects","handle"]);super(yr({effects:()=>[...s(),()=>{var a,l;const{manager:u}=this;if(!u)return;const c=((l=(a=this.sensors)==null?void 0:a.map(pr))!=null?l:[...u.sensors]).map(f=>{const p=f instanceof xn?f:u.registry.register(f.plugin),h=f instanceof xn?void 0:f.options;return p.bind(this,h)});return function(){c.forEach(p=>p())}}]},o),t),Ce(this,fa,Me(Ct,8,this)),Me(Ct,11,this),Ce(this,ha,Me(Ct,12,this)),Me(Ct,15,this),this.element=r,this.handle=i}};Ct=Rn(ao);fa=new WeakMap;ha=new WeakMap;it(Ct,4,"handle",Ud,Hs,fa);it(Ct,4,"element",Kd,Hs,ha);Qt(Ct,Hs);var Vd,Hd,lo,It,pa,hi,Xd,Yd,hr,ga,Xs=class extends(lo=pt,Hd=[fe],Vd=[fe],lo){constructor(e,t){var n=e,{element:r,effects:s=()=>[]}=n,i=kd(n,["element","effects"]);const{collisionDetector:o=yd}=i,a=u=>{const{manager:d,element:c}=this;if(!c||u===null){this.shape=void 0;return}if(!d)return;const f=new ut(c),p=ue(()=>this.shape);return f&&p?.equals(f)?p:(this.shape=f,f)},l=Tn(!1);super(sa(yr({},i),{collisionDetector:o,effects:()=>[...s(),()=>{const{element:u,manager:d}=this;if(!d)return;const{dragOperation:c}=d,{source:f}=c;l.value=!!(f&&c.status.initialized&&u&&!this.disabled&&this.accepts(f))},()=>{const{element:u}=this;if(l.value&&u){const d=new Lh(u,a);return()=>{d.disconnect(),this.shape=void 0}}},()=>{var u;if((u=this.manager)!=null&&u.dragOperation.status.initialized)return()=>{this.shape=void 0}}]}),t),Ce(this,hr),Ce(this,pa,Me(It,8,this)),Me(It,11,this),Ce(this,ga,Me(It,12,this)),Me(It,15,this),this.element=r,this.refreshShape=()=>a()}set element(e){qe(this,hr,e,Yd)}get element(){var e;return(e=this.proxy)!=null?e:ye(this,hr,Xd)}};It=Rn(lo);pa=new WeakMap;hr=new WeakSet;ga=new WeakMap;hi=it(It,20,"#element",Hd,hr,pa),Xd=hi.get,Yd=hi.set;it(It,4,"proxy",Vd,Xs,ga);Qt(It,Xs);function eg(e){return e!=null&&typeof e=="object"&&"current"in e}function bn(e){var t;if(e!=null)return eg(e)?(t=e.current)!=null?t:void 0:e}var tg=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Ln=tg?k.useLayoutEffect:k.useEffect;function ng(){const e=k.useState(0)[1];return k.useCallback(()=>{e(t=>t+1)},[e])}function Zd(e,t){const n=k.useRef(new Map),r=ng();return Ln(()=>{if(!e){n.current.clear();return}return st(()=>{var s;let i=!1,o=!1;for(const a of n.current){const[l]=a,u=ue(()=>a[1]),d=e[l];u!==d&&(i=!0,n.current.set(l,d),o=(s=t?.(l,u,d))!=null?s:!1)}i&&(o?queueMicrotask(()=>of.flushSync(r)):r())})},[e]),k.useMemo(()=>e&&new Proxy(e,{get(s,i){const o=s[i];return n.current.set(i,o),o}}),[e])}function rg(e,t){e()}function tn(e){const t=k.useRef(e);return Ln(()=>{t.current=e},[e]),t}function Se(e,t,n=k.useEffect,r=Object.is){const s=k.useRef(e);n(()=>{const i=s.current;r(e,i)||(s.current=e,t(e,i))},[t,e])}function hs(e,t){const n=k.useRef(bn(e));Ln(()=>{const r=bn(e);r!==n.current&&(n.current=r,t(r))})}var sg=Object.defineProperty,ig=Object.defineProperties,og=Object.getOwnPropertyDescriptors,Ps=Object.getOwnPropertySymbols,Qd=Object.prototype.hasOwnProperty,Jd=Object.prototype.propertyIsEnumerable,il=(e,t,n)=>t in e?sg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ag=(e,t)=>{for(var n in t||(t={}))Qd.call(t,n)&&il(e,n,t[n]);if(Ps)for(var n of Ps(t))Jd.call(t,n)&&il(e,n,t[n]);return e},lg=(e,t)=>ig(e,og(t)),cg=(e,t)=>{var n={};for(var r in e)Qd.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ps)for(var r of Ps(e))t.indexOf(r)<0&&Jd.call(e,r)&&(n[r]=e[r]);return n},dg=new qd,eu=k.createContext(dg),ug=k.memo(k.forwardRef(({children:e},t)=>{const[n,r]=k.useState(0),s=k.useRef(null),i=k.useRef(null),o=k.useMemo(()=>({renderer:{get rendering(){var a;return(a=s.current)!=null?a:Promise.resolve()}},trackRendering(a){s.current||(s.current=new Promise(l=>{i.current=l})),k.startTransition(()=>{a(),r(l=>l+1)})}}),[]);return Ln(()=>{var a;(a=i.current)==null||a.call(i),s.current=null},[e,n]),k.useImperativeHandle(t,()=>o),null})),pi=[void 0,ot];function fg(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:s,onDragStart:i,onDragMove:o,onDragOver:a,onDragEnd:l}=t,u=cg(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const d=k.useRef(null),{plugins:c,modifiers:f,sensors:p}=u,h=lt(c,vn.plugins),m=lt(p,vn.sensors),y=lt(f,vn.modifiers),w=tn(s),v=tn(i),g=tn(a),b=tn(o),_=tn(l),O=tn(r),I=hg(()=>{var M;return(M=u.manager)!=null?M:new qd(u)});return k.useEffect(()=>{if(!d.current)throw new Error("Renderer not found");const{renderer:M,trackRendering:T}=d.current,{monitor:D}=I;I.renderer=M;const N=[D.addEventListener("beforedragstart",R=>{const W=w.current;W&&T(()=>W(R,I))}),D.addEventListener("dragstart",R=>{var W;return(W=v.current)==null?void 0:W.call(v,R,I)}),D.addEventListener("dragover",R=>{const W=g.current;W&&T(()=>W(R,I))}),D.addEventListener("dragmove",R=>{const W=b.current;W&&T(()=>W(R,I))}),D.addEventListener("dragend",R=>{const W=_.current;W&&T(()=>W(R,I))}),D.addEventListener("collision",R=>{var W;return(W=O.current)==null?void 0:W.call(O,R,I)})];return()=>N.forEach(R=>R())},[I]),Se(h,()=>I&&(I.plugins=h),...pi),Se(m,()=>I&&(I.sensors=m),...pi),Se(y,()=>I&&(I.modifiers=y),...pi),x.jsxs(eu.Provider,{value:I,children:[x.jsx(ug,{ref:d,children:n}),n]})}function hg(e){const t=k.useRef(null);return t.current||(t.current=e()),k.useInsertionEffect(()=>()=>{var n;return(n=t.current)==null?void 0:n.destroy()},[]),t.current}function pg(){return k.useContext(eu)}function tu(e){var t;const n=(t=pg())!=null?t:void 0,[r]=k.useState(()=>e(n));return r.manager!==n&&(r.manager=n),Ln(r.register,[n,r]),r}var gg=Object.create,nu=Object.defineProperty,mg=Object.getOwnPropertyDescriptor,ru=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ys=e=>{throw TypeError(e)},vg=(e,t,n)=>t in e?nu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,bg=e=>{var t;return[,,,gg((t=e?.[ru("metadata")])!=null?t:null)]},su=["class","method","getter","setter","accessor","field","value","get","set"],iu=e=>e!==void 0&&typeof e!="function"?Ys("Function expected"):e,yg=(e,t,n,r,s)=>({kind:su[e],name:t,metadata:r,addInitializer:i=>n._?Ys("Already initialized"):s.push(iu(i||null))}),xg=(e,t)=>vg(t,ru("metadata"),e[3]),wg=(e,t,n,r)=>{for(var s=0,i=e[t>>1],o=i&&i.length;s<o;s++)i[s].call(n);return r},ou=(e,t,n,r,s,i)=>{for(var o,a,l,u,d=t&7,c=!1,f=!1,p=2,h=su[d+5],m=e[p]||(e[p]=[]),y=(s=s.prototype,mg(s,n)),w=r.length-1;w>=0;w--)l=yg(d,n,a={},e[3],m),l.static=c,l.private=f,u=l.access={has:v=>n in v},u.get=v=>v[n],o=(0,r[w])(y[h],l),a._=1,iu(o)&&(y[h]=o);return y&&nu(s,n,y),s},au=(e,t,n)=>t.has(e)||Ys("Cannot "+n),_g=(e,t,n)=>(au(e,t,"read from private field"),t.get(e)),kg=(e,t,n)=>t.has(e)?Ys("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Sg=(e,t,n,r)=>(au(e,t,"write to private field"),t.set(e,n),n),qt=class co{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new co(t.x-n.x,t.y-n.y)}static distance(t,n){return Math.hypot(t.x-n.x,t.y-n.y)}static equals(t,n){return t.x===n.x&&t.y===n.y}static from({x:t,y:n}){return new co(t,n)}},lu,cu,uo,ps,jr,ma=class extends(uo=Yt,cu=[Ee],lu=[Ee],uo){constructor(e){const t=qt.from(e);super(t,(n,r)=>qt.equals(n,r)),wg(jr,5,this),kg(this,ps,0),this.velocity={x:0,y:0}}get delta(){return qt.delta(this.current,this.initial)}get direction(){const{current:e,previous:t}=this;if(!t)return null;const n={x:e.x-t.x,y:e.y-t.y};return!n.x&&!n.y?null:Math.abs(n.x)>Math.abs(n.y)?n.x>0?"right":"left":n.y>0?"down":"up"}get current(){return super.current}set current(e){const{current:t}=this,n=qt.from(e),r={x:n.x-t.x,y:n.y-t.y},s=Date.now(),i=s-_g(this,ps),o=a=>Math.round(a/i*100);Te(()=>{Sg(this,ps,s),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(qt.from(e)),this.velocity={x:0,y:0}}};jr=bg(uo);ps=new WeakMap;ou(jr,2,"delta",cu,ma);ou(jr,2,"direction",lu,ma);xg(jr,ma);var du=(e=>(e.Horizontal="x",e.Vertical="y",e))(du||{});Object.values(du);var $g=({dragOperation:e,droppable:t})=>{const n=e.position.current;if(!n)return null;const{id:r}=t;if(!t.shape)return null;if(t.shape.containsPoint(n)){const s=qt.distance(t.shape.center,n);return{id:r,value:1/s,type:Pn.PointerIntersection,priority:An.High}}return null},Tg=({dragOperation:e,droppable:t})=>{const{shape:n}=e;if(!t.shape||!n?.current)return null;const r=n.current.intersectionArea(t.shape);if(r){const{position:s}=e,i=qt.distance(t.shape.center,s.current),a=r/(n.current.area+t.shape.area-r)/i;return{id:t.id,value:a,type:Pn.ShapeIntersection,priority:An.Normal}}return null},Og=e=>{var t;return(t=$g(e))!=null?t:Tg(e)};function Eg(e){const{collisionDetector:t,data:n,disabled:r,element:s,id:i,accept:o,type:a}=e,l=tu(d=>new Xs(lg(ag({},e),{register:!1,element:bn(s)}),d)),u=Zd(l);return Se(i,()=>l.id=i),hs(s,d=>l.element=d),Se(o,()=>l.accept=o,void 0,ot),Se(t,()=>l.collisionDetector=t??Og),Se(n,()=>n&&(l.data=n)),Se(r,()=>l.disabled=r===!0),Se(a,()=>l.type=a),{droppable:u,get isDropTarget(){return u.isDropTarget},ref:k.useCallback(d=>{var c,f;!d&&((c=l.element)!=null&&c.isConnected)&&!((f=l.manager)!=null&&f.dragOperation.status.idle)||(l.element=d??void 0)},[l])}}const ol=`url("data:image/svg+xml;utf8,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"/><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"/></svg>')}")`,uu=(e,t="line")=>{const n=[":is(p, h1, h2, h3, h4, h5, h6):first-child::after","> * > span:only-child::after"],r=o=>n.map(a=>`${o} ${a}`).join(", "),s=t==="line"?"&::after":r("&"),i=t==="line"?"&:hover::after, &:focus-visible::after":`${r("&:hover")}, ${r("&:focus-visible")}`;return{cursor:"text",borderRadius:"2px",[s]:{content:'""',display:"inline-block",width:"0.8em",height:"0.8em",ml:"0.4em",verticalAlign:"-0.05em",backgroundColor:"currentColor",maskImage:ol,WebkitMaskImage:ol,maskSize:"contain",WebkitMaskSize:"contain",maskRepeat:"no-repeat",WebkitMaskRepeat:"no-repeat",opacity:.35,transition:`opacity ${E.MOTION_FAST}`,...E.reducedMotionSx,pointerEvents:"none"},[i]:{opacity:.8},"&:focus-visible":{outline:`2px solid ${e.accent}`,outlineOffset:2}}},fu=k.createContext(void 0);function hu(e,t){const n=k.useContext(fu),r=k.useRef(t);r.current=t,k.useEffect(()=>{if(!n||!e)return;const i=()=>r.current();return n.commitRef.current=i,()=>{n.commitRef.current===i&&(n.commitRef.current=void 0)}},[n,e]);const s=k.useRef(!1);k.useLayoutEffect(()=>{!e&&!s.current||(s.current=e,n?.setDirty(e))},[n,e]),k.useLayoutEffect(()=>()=>{s.current&&n?.setDirty(!1)},[n])}function fo({value:e,placeholder:t,ariaLabel:n,onCommit:r,faintWhenEmpty:s=!1}){const{theme:i}=Ke.usePublisherTheme(),[o,a]=k.useState(void 0),l=k.useRef(!1),u=()=>{l.current||o===void 0||(a(void 0),o!==e&&r(o))};hu(o!==void 0&&o!==e,()=>(u(),!0));const d=()=>{l.current=!1,a(e)};if(o===void 0){const c=e==="",f=c&&s;return x.jsx(S.Box,{component:"button",type:"button",className:f?"builder-affordance":void 0,onClick:d,onKeyDown:p=>{p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),d())},sx:[{all:"unset",boxSizing:"border-box",font:"inherit",color:"inherit",display:"inline-block",maxWidth:"100%",...c&&{fontStyle:"italic",opacity:f?0:.6}},uu(i)],children:c?t:e})}return x.jsx(S.InputBase,{autoFocus:!0,fullWidth:!0,value:o,placeholder:t,inputProps:{"aria-label":n},onFocus:c=>c.target.select(),onChange:c=>a(c.target.value),onKeyDown:c=>{c.key==="Enter"&&!c.nativeEvent.isComposing?u():c.key==="Escape"&&(l.current=!0,a(void 0))},onBlur:u,sx:{font:"inherit",color:"inherit",p:0,"& input":{p:0}}})}const Cg=(e,t)=>e.map((n,r)=>{const s=t[r]??!1;if(s===(n.break??!1))return n;const i={...n};return s?i.break=!0:delete i.break,i}),Ig=(e,t,n)=>{const r=[...e],[s]=r.splice(t,1);if(!s)return[...e];const i=r[t];s.break&&i&&!i.break&&(r[t]={...i,break:!0});const o={...s};return delete o.break,r.splice(n,0,o),r},pu=(e,t)=>({kind:"tile",tile:e,index:t,colspan:e.colspan,break:e.break}),gu=e=>`gap.${e}`,Dg=(e,t)=>{const n=[];let r=0;e.forEach((i,o)=>{const a=Math.min(i.colspan??1,t),l=o===0||i.break===!0||r+a>t;l&&o>0&&r<t&&n.push({kind:"gap",after:Fe(e[o-1]),colspan:t-r}),l&&(r=0),n.push(pu(i,o)),r+=a});const s=e.at(-1);return s&&r<t&&n.push({kind:"gap",after:Fe(s),colspan:t-r}),n};var Ag=Object.create,mu=Object.defineProperty,Pg=Object.defineProperties,Mg=Object.getOwnPropertyDescriptor,jg=Object.getOwnPropertyDescriptors,Ms=Object.getOwnPropertySymbols,vu=Object.prototype.hasOwnProperty,bu=Object.prototype.propertyIsEnumerable,Rg=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Rr=e=>{throw TypeError(e)},ho=(e,t,n)=>t in e?mu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,gi=(e,t)=>{for(var n in t||(t={}))vu.call(t,n)&&ho(e,n,t[n]);if(Ms)for(var n of Ms(t))bu.call(t,n)&&ho(e,n,t[n]);return e},mi=(e,t)=>Pg(e,jg(t)),Lg=(e,t)=>{var n={};for(var r in e)vu.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ms)for(var r of Ms(e))t.indexOf(r)<0&&bu.call(e,r)&&(n[r]=e[r]);return n},Ng=e=>{var t;return[,,,Ag((t=void 0)!=null?t:null)]},yu=["class","method","getter","setter","accessor","field","value","get","set"],rr=e=>e!==void 0&&typeof e!="function"?Rr("Function expected"):e,Fg=(e,t,n,r,s)=>({kind:yu[e],name:t,metadata:r,addInitializer:i=>n._?Rr("Already initialized"):s.push(rr(i||null))}),zg=(e,t)=>ho(t,Rg("metadata"),e[3]),Vr=(e,t,n,r)=>{for(var s=0,i=e[t>>1],o=i&&i.length;s<o;s++)t&1?i[s].call(n):r=i[s].call(n,r);return r},xu=(e,t,n,r,s,i)=>{for(var o,a,l,u,d,c=t&7,f=!1,p=!1,h=e.length+1,m=yu[c+5],y=e[h-1]=[],w=e[h]||(e[h]=[]),v=(s=s.prototype,Mg({get[n](){return sr(this,i)},set[n](b){return Gt(this,i,b)}},n)),g=r.length-1;g>=0;g--)u=Fg(c,n,l={},e[3],w),u.static=f,u.private=p,d=u.access={has:b=>n in b},d.get=b=>b[n],d.set=(b,_)=>b[n]=_,a=(0,r[g])({get:v.get,set:v.set},u),l._=1,a===void 0?rr(a)&&(v[m]=a):typeof a!="object"||a===null?Rr("Object expected"):(rr(o=a.get)&&(v.get=o),rr(o=a.set)&&(v.set=o),rr(o=a.init)&&y.unshift(o));return v&&mu(s,n,v),s},wu=(e,t,n)=>t.has(e)||Rr("Cannot "+n),sr=(e,t,n)=>(wu(e,t,"read from private field"),t.get(e)),Gn=(e,t,n)=>t.has(e)?Rr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Gt=(e,t,n,r)=>(wu(e,t,"write to private field"),t.set(e,n),n);function Kt(e){return e instanceof ya||e instanceof $u}var Hr=10,Wg=class extends We{constructor(e){super(e);const t=st(()=>{const{dragOperation:r}=e;if(br(r.activatorEvent)&&Kt(r.source)&&r.status.initialized){const s=e.registry.plugins.get(Mr);if(s)return s.disable(),()=>s.enable()}}),n=e.monitor.addEventListener("dragmove",(r,s)=>{queueMicrotask(()=>{if(this.disabled||r.defaultPrevented||!r.nativeEvent)return;const{dragOperation:i}=s;if(!br(r.nativeEvent)||!Kt(i.source)||!i.shape)return;const{actions:o,collisionObserver:a,registry:l}=s,{by:u}=r;if(!u)return;const d=Bg(u),{source:c,target:f}=i,{center:p}=i.shape.current,h=[],m=[];Te(()=>{for(const _ of l.droppables){const{id:O}=_;if(!_.accepts(c)||O===f?.id&&Kt(_)||!_.element)continue;let I=_.shape;const M=new ut(_.element,{getBoundingClientRect:T=>mr(T,void 0,.2)});!M.height||!M.width||(d=="down"&&p.y+Hr<M.center.y||d=="up"&&p.y-Hr>M.center.y||d=="left"&&p.x-Hr>M.center.x||d=="right"&&p.x+Hr<M.center.x)&&(h.push(_),_.shape=M,m.push(()=>_.shape=I))}}),r.preventDefault(),a.disable();const y=a.computeCollisions(h,cp);Te(()=>m.forEach(_=>_()));const[w]=y;if(!w)return;const{id:v}=w,{index:g,group:b}=c.sortable;o.setDropTarget(v).then(()=>{const{source:_,target:O,shape:I}=i;if(!_||!Kt(_)||!I)return;const{index:M,group:T,target:D}=_.sortable,N=g!==M||b!==T,R=N?D:O?.element;if(!R)return;vd(R);const W=new ut(R);if(!W)return;const X=ft.delta(W,ft.from(I.current.boundingRectangle),_.alignment);o.move({by:X}),N?o.setDropTarget(_.id).then(()=>a.enable()):a.enable()})})});this.destroy=()=>{n(),t()}}};function Bg(e){const{x:t,y:n}=e;if(t>0)return"right";if(t<0)return"left";if(n>0)return"down";if(n<0)return"up"}var Gg=Object.defineProperty,qg=Object.defineProperties,Kg=Object.getOwnPropertyDescriptors,al=Object.getOwnPropertySymbols,Ug=Object.prototype.hasOwnProperty,Vg=Object.prototype.propertyIsEnumerable,ll=(e,t,n)=>t in e?Gg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,nn=(e,t)=>{for(var n in t||(t={}))Ug.call(t,n)&&ll(e,n,t[n]);if(al)for(var n of al(t))Vg.call(t,n)&&ll(e,n,t[n]);return e},rn=(e,t)=>qg(e,Kg(t));function Hg(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function Xr(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function vi(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function Xg(e,t,n){var r,s;const{source:i,target:o,canceled:a}=t.operation;if(!i||!o||a)return"preventDefault"in t&&t.preventDefault(),e;const l=(g,b)=>g===b||g!==null&&typeof g=="object"&&"id"in g&&g.id===b;if(Array.isArray(e)){const g=e.findIndex(_=>l(_,i.id)),b=e.findIndex(_=>l(_,o.id));if(g===-1||b===-1){if(vi(i)){const _=i.initialIndex,O=i.index;return _===O||_<0||_>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,_,O)}return e}if(!a&&"index"in i&&typeof i.index=="number"){const _=i.index;if(_!==g)return n(e,g,_)}return n(e,g,b)}const u=Object.entries(e);let d=-1,c,f=-1,p;for(const[g,b]of u)if(d===-1&&(d=b.findIndex(_=>l(_,i.id)),d!==-1&&(c=g)),f===-1&&(f=b.findIndex(_=>l(_,o.id)),f!==-1&&(p=g)),d!==-1&&f!==-1)break;if(d===-1&&vi(i)){const g=i.initialGroup==null?void 0:Xr(e,i.initialGroup),b=i.initialIndex,_=i.group==null?void 0:Xr(e,i.group),O=i.index;if(g==null||_==null||g===_&&b===O)return"preventDefault"in t&&t.preventDefault(),e;if(g===_)return rn(nn({},e),{[g]:n(e[g],b,O)});const I=e[g][b];return rn(nn({},e),{[g]:[...e[g].slice(0,b),...e[g].slice(b+1)],[_]:[...e[_].slice(0,O),I,...e[_].slice(O)]})}if(!i.manager)return e;const{dragOperation:h}=i.manager,m=(s=(r=h.shape)==null?void 0:r.current.center)!=null?s:h.position.current;if(p==null){const g=Xr(e,o.id);if(g!=null){const b=o.shape&&m.y>o.shape.center.y?e[g].length:0;p=g,f=b}}if(c==null||p==null||c===p&&d===f){if(c!=null&&c===p&&d===f&&vi(i)){const g=i.group==null?void 0:Xr(e,i.group),b=i.group!=null&&g!==c,_=i.index!==d;if(b||_){const O=i.group==null?c:g;if(O!=null){if(c===O)return rn(nn({},e),{[c]:n(e[c],d,i.index)});const I=e[c][d];return rn(nn({},e),{[c]:[...e[c].slice(0,d),...e[c].slice(d+1)],[O]:[...e[O].slice(0,i.index),I,...e[O].slice(i.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(c===p)return rn(nn({},e),{[c]:n(e[c],d,f)});const w=o.shape&&Math.round(m.y)>Math.round(o.shape.center.y)?1:0,v=e[c][d];return rn(nn({},e),{[c]:[...e[c].slice(0,d),...e[c].slice(d+1)],[p]:[...e[p].slice(0,f+w),v,...e[p].slice(f+w)]})}function Yg(e,t){return Xg(e,t,Hg)}function cl(e){const t=new Map;for(const[,n]of e)for(const r of n)t.set(r.id,r.index);return t}function dl(e,t,n){var r;for(const[s,i]of t)for(const o of i){const a=e.get(o.id);if(o.index!==a||o.group!==s||!((r=n.get(s))!=null&&r.has(o)))return!0}return!1}var ul="__default__",Zg=class extends We{constructor(e){super(e);const t=()=>{const r=new Map;for(const s of e.registry.droppables)if(s instanceof ya){const{sortable:i}=s,{group:o}=i;let a=r.get(o);a||(a=new Set,r.set(o,a)),a.add(i)}return r},n=[e.monitor.addEventListener("dragover",(r,s)=>{if(this.disabled)return;const{dragOperation:i}=s,{source:o,target:a}=i;if(!Kt(o)||!Kt(a)||o.sortable===a.sortable)return;const l=t(),u=cl(l),d=o.sortable.group===a.sortable.group,c=l.get(o.sortable.group),f=d?c:l.get(a.sortable.group);!c||!f||queueMicrotask(()=>{r.defaultPrevented||s.renderer.rendering.then(()=>{var p,h;const m=t();if(dl(u,l,m))return;const y=o.sortable.element,w=a.sortable.element;if(!w||!y||!d&&a.id===o.sortable.group)return;const v=Yr(c),g=d?v:Yr(f),b=(p=o.sortable.group)!=null?p:ul,_=(h=a.sortable.group)!=null?h:ul,O={[b]:v,[_]:g},I=Yg(O,r);if(O===I)return;const M=I[_].indexOf(o.sortable),T=I[_].indexOf(a.sortable);s.collisionObserver.disable(),fl(y,M,w,T),Te(()=>{for(const[D,N]of I[b].entries())N.index=D;if(!d)for(const[D,N]of I[_].entries())N.group=a.sortable.group,N.index=D}),s.actions.setDropTarget(o.id).then(()=>s.collisionObserver.enable())})})}),e.monitor.addEventListener("dragend",(r,s)=>{if(!r.canceled)return;const{dragOperation:i}=s,{source:o}=i;Kt(o)&&(o.sortable.initialIndex===o.sortable.index&&o.sortable.initialGroup===o.sortable.group||queueMicrotask(()=>{const a=t(),l=cl(a),u=a.get(o.sortable.initialGroup);u&&s.renderer.rendering.then(()=>{const d=t();if(dl(l,a,d))return;const c=Yr(u),f=Yr(u,Jg),p=o.sortable.element,h=f.indexOf(o.sortable),m=c[h],y=m?.element;!m||!y||!p||(fl(p,m.index,y,o.index),Te(()=>{for(const w of a.values()){const v=Array.from(w).values();for(const g of v)g.index=g.initialIndex,g.group=g.initialGroup}}))})}))})];this.destroy=()=>{for(const r of n)r()}}};function fl(e,t,n,r){const s=r<t?"afterend":"beforebegin";n.insertAdjacentElement(s,e)}function Qg(e,t){return e.index-t.index}function Jg(e,t){return e.initialIndex-t.initialIndex}function Yr(e,t=Qg){return Array.from(e).sort(t)}var hl=[Wg,Zg],_u={duration:250,easing:"cubic-bezier(0.25, 1, 0.5, 1)",idle:!1};function pl(e){var t,n;return typeof e=="boolean"?{draggable:e,droppable:e}:{draggable:(t=e?.draggable)!=null?t:!1,droppable:(n=e?.droppable)!=null?n:!1}}var Zr=new Uf,ku,Su,Dt,va,ir,or,ba,hn;Su=[fe],ku=[fe];var Zs=class{constructor(e,t){Gn(this,va,Vr(Dt,8,this)),Vr(Dt,11,this),Gn(this,ir),Gn(this,or),Gn(this,ba,Vr(Dt,12,this)),Vr(Dt,15,this),Gn(this,hn),this.register=()=>(Te(()=>{var h,m;(h=this.manager)==null||h.registry.register(this.droppable),(m=this.manager)==null||m.registry.register(this.draggable)}),()=>this.unregister()),this.unregister=()=>{Te(()=>{var h,m;(h=this.manager)==null||h.registry.unregister(this.droppable),(m=this.manager)==null||m.registry.unregister(this.draggable)})},this.destroy=()=>{Te(()=>{this.droppable.destroy(),this.draggable.destroy()})};var n=e,{effects:r=()=>[],disabled:s,group:i,index:o,sensors:a,type:l,transition:u=_u,plugins:d}=n,c=Lg(n,["effects","disabled","group","index","sensors","type","transition","plugins"]);const f=lt(d,hl),p=pl(s);this.droppable=new ya(mi(gi({},c),{disabled:p.droppable}),t,this),this.draggable=new $u(mi(gi({},c),{disabled:p.draggable,plugins:f,effects:()=>[()=>{var h,m,y;const w=(h=this.manager)==null?void 0:h.dragOperation.status;w?.initializing&&this.id===((y=(m=this.manager)==null?void 0:m.dragOperation.source)==null?void 0:y.id)&&Zr.clear(this.manager),w?.dragging&&Zr.set(this.manager,this.id,ue(()=>({initialIndex:this.index,initialGroup:this.group})))},()=>{const{index:h,group:m,manager:y}=this,w=sr(this,or),v=sr(this,ir);(h!==w||m!==v)&&(Gt(this,or,h),Gt(this,ir,m),this.animate())},()=>{var h,m;const{target:y}=this,{isDragSource:w}=this.draggable;((m=(h=this.draggable.pluginConfig(la))==null?void 0:h.feedback)!=null?m:"default")==="move"&&w&&(this.droppable.disabled=!y)},...r()],type:l,sensors:a}),t,this),Gt(this,hn,c.element),this.manager=t,this.index=o,Gt(this,or,o),this.group=i,Gt(this,ir,i),this.type=l,this.transition=u}get initialIndex(){var e,t;return(t=(e=Zr.get(this.manager,this.id))==null?void 0:e.initialIndex)!=null?t:this.index}get initialGroup(){var e,t;return(t=(e=Zr.get(this.manager,this.id))==null?void 0:e.initialGroup)!=null?t:this.group}animate(){ue(()=>{const{manager:e,transition:t}=this,{shape:n}=this.droppable;if(!e)return;const{idle:r}=e.dragOperation.status;!n||!t||r&&!t.idle||e.renderer.rendering.then(()=>{const{element:s}=this;if(!s)return;for(const d of s.getAnimations())"transitionProperty"in d&&(d.transitionProperty==="transform"||d.transitionProperty==="translate"||d.transitionProperty==="scale")&&d.cancel();const i=this.refreshShape();if(!i)return;const o={x:n.boundingRectangle.left-i.boundingRectangle.left,y:n.boundingRectangle.top-i.boundingRectangle.top},{translate:a}=gt(s),l=Ya(s,a,!1),u=Ya(s,a);if(o.x||o.y){const d=ea(Qe(s))?mi(gi({},t),{duration:0}):t;bd({element:s,keyframes:{translate:[`${l.x+o.x}px ${l.y+o.y}px ${l.z}`,`${u.x}px ${u.y}px ${u.z}`]},options:d}).then(()=>{e.dragOperation.status.dragging||(this.droppable.shape=void 0)})}})})}get manager(){return this.draggable.manager}set manager(e){Te(()=>{this.draggable.manager=e,this.droppable.manager=e})}set element(e){Te(()=>{const t=sr(this,hn),n=this.droppable.element,r=this.draggable.element;(!n||n===t)&&(this.droppable.element=e),(!r||r===t)&&(this.draggable.element=e),Gt(this,hn,e)})}get element(){var e,t;const n=sr(this,hn);if(n)return(t=(e=Ui.get(n))!=null?e:n)!=null?t:this.droppable.element}set target(e){this.droppable.element=e}get target(){return this.droppable.element}set source(e){this.draggable.element=e}get source(){return this.draggable.element}get disabled(){const{disabled:e}=this.draggable,{disabled:t}=this.droppable;return e===t?e:{draggable:e,droppable:t}}set plugins(e){this.draggable.plugins=lt(e,hl)}set disabled(e){const t=pl(e);Te(()=>{this.droppable.disabled=t.droppable,this.draggable.disabled=t.draggable})}set data(e){Te(()=>{this.droppable.data=e,this.draggable.data=e})}set handle(e){this.draggable.handle=e}set id(e){this.droppable.id=e,this.draggable.id=e}get id(){return this.droppable.id}set sensors(e){this.draggable.sensors=e}set modifiers(e){this.draggable.modifiers=e}set collisionPriority(e){this.droppable.collisionPriority=e}set collisionDetector(e){this.droppable.collisionDetector=e??yd}set alignment(e){this.draggable.alignment=e}get alignment(){return this.draggable.alignment}set type(e){Te(()=>{this.droppable.type=e,this.draggable.type=e})}get type(){return this.draggable.type}set accept(e){this.droppable.accept=e}get accept(){return this.droppable.accept}get isDropTarget(){return this.droppable.isDropTarget}get isDragSource(){return this.draggable.isDragSource}get isDragging(){return this.draggable.isDragging}get isDropping(){return this.draggable.isDropping}get status(){return this.draggable.status}refreshShape(){return this.droppable.refreshShape()}accepts(e){return this.droppable.accepts(e)}};Dt=Ng();va=new WeakMap;ir=new WeakMap;or=new WeakMap;ba=new WeakMap;hn=new WeakMap;xu(Dt,4,"index",Su,Zs,va);xu(Dt,4,"group",ku,Zs,ba);zg(Dt,Zs);var $u=class extends Hs{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}get initialIndex(){return this.sortable.initialIndex}get group(){return this.sortable.group}get initialGroup(){return this.sortable.initialGroup}},ya=class extends Xs{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}get group(){return this.sortable.group}},em=Object.defineProperty,tm=Object.defineProperties,nm=Object.getOwnPropertyDescriptors,gl=Object.getOwnPropertySymbols,rm=Object.prototype.hasOwnProperty,sm=Object.prototype.propertyIsEnumerable,ml=(e,t,n)=>t in e?em(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,bi=(e,t)=>{for(var n in t||(t={}))rm.call(t,n)&&ml(e,n,t[n]);if(gl)for(var n of gl(t))sm.call(t,n)&&ml(e,n,t[n]);return e},im=(e,t)=>tm(e,nm(t));function om(e){const{accept:t,collisionDetector:n,collisionPriority:r,id:s,data:i,element:o,handle:a,index:l,group:u,disabled:d,modifiers:c,sensors:f,target:p,type:h,plugins:m}=e,y=bi(bi({},_u),e.transition),w=tu(g=>new Zs(im(bi({},e),{transition:y,register:!1,handle:bn(a),element:bn(o),target:bn(p)}),g)),v=Zd(w,am);return Se(s,()=>w.id=s),Ln(()=>{Te(()=>{w.group=u,w.index=l})},[w,u,l]),Se(h,()=>w.type=h),Se(t,()=>w.accept=t,void 0,ot),Se(i,()=>i&&(w.data=i)),Se(l,()=>{var g;(g=w.manager)!=null&&g.dragOperation.status.idle&&y?.idle&&w.refreshShape()},rg),hs(a,g=>w.handle=g),hs(o,g=>w.element=g),hs(p,g=>w.target=g),Se(d,()=>w.disabled=d??!1,void 0,ot),Se(f,()=>w.sensors=f,void 0,ot),Se(n,()=>w.collisionDetector=n),Se(r,()=>w.collisionPriority=r),Se(m,()=>w.plugins=m,void 0,ot),Se(y,()=>w.transition=y,void 0,ot),Se(c,()=>w.modifiers=c,void 0,ot),Se(e.alignment,()=>w.alignment=e.alignment),{sortable:v,get isDragging(){return v.isDragging},get isDropping(){return v.isDropping},get isDragSource(){return v.isDragSource},get isDropTarget(){return v.isDropTarget},handleRef:k.useCallback(g=>{w.handle=g??void 0},[w]),ref:k.useCallback(g=>{var b,_;!g&&((b=w.element)!=null&&b.isConnected)&&!((_=w.manager)!=null&&_.dragOperation.status.idle)||(w.element=g??void 0)},[w]),sourceRef:k.useCallback(g=>{var b,_;!g&&((b=w.source)!=null&&b.isConnected)&&!((_=w.manager)!=null&&_.dragOperation.status.idle)||(w.source=g??void 0)},[w]),targetRef:k.useCallback(g=>{var b,_;!g&&((b=w.target)!=null&&b.isConnected)&&!((_=w.manager)!=null&&_.dragOperation.status.idle)||(w.target=g??void 0)},[w])}}function am(e,t,n){return!!(e==="isDragSource"&&!n&&t)}const po="tile",Tu="gap",lm=[oo.configure({activatorElements:e=>[e.element],preventActivation:(e,t)=>e.target instanceof Element&&e.target.closest(`[${Ou}]`)!==null||(oo.defaults.preventActivation?.(e,t)??!1)}),Gd],Ou="data-no-drag",cm=e=>[...e,la.configure({feedback:"clone"})];function dm({id:e,index:t,children:n}){const{ref:r,handleRef:s,isDragSource:i}=om({id:e,index:t,type:po,accept:po,collisionDetector:na,plugins:cm});return x.jsx(x.Fragment,{children:n({ref:r,handleRef:s,isDragSource:i})})}function um({id:e,after:t,children:n}){const{ref:r,isDropTarget:s}=Eg({id:e,type:Tu,accept:po,collisionDetector:na,data:{after:t}});return x.jsx(x.Fragment,{children:n({ref:r,isDropTarget:s})})}const Eu=["bar_chart","line_chart","scatter_chart","shape_map","segment_map","big_value","sparkline"],Cu=["line_chart","bar_chart","big_value","scatter_chart","shape_map","segment_map"],Qs=e=>Cu.includes(e),go=new Set([...Eu,"viz"]);function At(e){const t=e.trim();if(!/^#[ \t]/.test(t)||/[{=]/.test(t))return;const n=t.slice(1).trim().split(/[ \t]+/),r=[];let s;for(const i of n)if(i.startsWith("-")){if(s!==void 0)return;const o=i.slice(1);if(!go.has(o))return;r.push(o)}else{if(s!==void 0||!go.has(i))return;s=i}return{negated:r,...s!==void 0&&{pick:s}}}function kr(e){const t=e.trim();return!/^#[ \t]/.test(t)||At(t)?!1:(t.replace(/"(?:[^"\\]|\\.)*"/g,'""').match(/[A-Za-z_]+/g)??[]).some(r=>go.has(r))}function yn(e,t){return["#",...Cu.filter(r=>r!==e&&(t===void 0||t.includes(r))).map(r=>`-${r}`),"-viz",...e==="none"?[]:[e]].join(" ")}function fm(e){return e.pick!==void 0?Qs(e.pick)?e.pick:"custom":e.negated.includes("viz")?"none":"custom"}function hm(e){if(e.length===0)return"default";if(e.length>1)return"custom";const t=At(e[0]);return t?fm(t):"custom"}function pm(e){const t=e.filter(n=>At(n));return e.some(kr)?"custom":t.length===0?void 0:hm(t)}const gm=e=>e.filter(t=>At(t)||kr(t)),Iu=e=>e.ok===!1,De=(e,...t)=>t.every(n=>typeof e?.[n]=="function"),Lr=e=>e!==void 0&&e.ruleIndex!==void 0&&(e.childCount??0)>0,ke={sourceDefinition:e=>De(e,"sourceNameDef","isDefine","sqExplore"),exploreQueryDef:e=>De(e,"exploreQueryNameDef","isDefine","vExpr"),defExploreQuery:e=>De(e,"VIEW","subQueryDefList"),defDimension:e=>De(e,"defList","DIMENSION"),exploreProperties:e=>De(e,"exploreStatement","OCURLY","CCURLY"),queryProperties:e=>De(e,"queryStatement","OCURLY","CCURLY"),queryStatement:e=>De(e,"whereStatement","aggregateStatement","nestStatement"),whereStatement:e=>De(e,"WHERE","filterClauseList"),givenDef:e=>De(e,"givenNameDef"),givenStatement:e=>De(e,"GIVEN","givenDefList"),importStatement:e=>De(e,"IMPORT","importURL"),vArrow:e=>De(e,"ARROW","vExpr","segExpr"),segRefine:e=>De(e,"PLUS","segExpr"),segOps:e=>De(e,"queryProperties"),segField:e=>De(e,"fieldPath")&&!De(e,"segExpr"),segParen:e=>De(e,"OPAREN","CPAREN","vExpr"),compare:e=>De(e,"fieldExpr","compareOp"),givenRef:e=>De(e,"GIVEN_REF")};function mm(e){const t=new Int32Array([...e].length+1);let n=0;for(let r=0;r<e.length;)t[n++]=r,r+=e.codePointAt(r)>65535?2:1;return t[n]=e.length,t}function vm(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
|
|
68
|
-
`&&t.push(n+1);return t}class
|
|
69
|
-
`),l=r.length?e.indentAt(r[0].span.start):e.indentAt(n.start)+" ";return{span:n,openEnd:i,closeStart:o,statements:r,wheres:s,indent:l,oneLine:a}}function
|
|
70
|
-
`),
|
|
71
|
-
`||e.text[
|
|
72
|
-
`]:[];o.push({...l.name===void 0?{}:{name:l.name},route:l.route,body:[...
|
|
73
|
-
`).replace(/\n$/,""),span:{start:e.lineStarts[f],end:
|
|
67
|
+
`.replace(/\n+/g," ").replace(/\s+/g," ").trim();function Tp(e,t="hidden"){return fe(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const s=Op(n,r.registry.droppables),i=[],o=wh(n),{remove:a}=o;return Ep(s,o,i),Cp(o,t),o.remove=()=>{i.forEach(l=>l()),a.call(o)},o})}function Op(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const s=`${jr}${Ji("dom-id")}`;r.element.setAttribute(s,""),n.set(r,s)}return n}function Ep(e,t,n){for(const[r,s]of e){if(!r.element)continue;const i=`[${s}]`,o=t.matches(i)?t:t.querySelector(i);if(r.element.removeAttribute(s),!o)continue;const a=r.element;r.proxy=o,o.removeAttribute(s),Xi.set(a,o),n.push(()=>{Xi.delete(a),r.proxy=void 0})}}function Cp(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(Ps,t)}function Pu(e,t){return e===t?!0:Sn(e)===Sn(t)}function el(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&Ht(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>yn(t))}function ro(e){return e.tagName==="TR"}function Ip(e,t,n){const r=new MutationObserver(s=>{let i=!1;for(const o of s){if(o.target!==e){i=!0;continue}if(o.type!=="attributes")continue;const a=o.attributeName;if(a.startsWith("aria-")||kp.includes(a))continue;const l=e.getAttribute(a);if(a==="style"){if(pr(e)&&pr(t)){const d=e.style;for(const u of Array.from(t.style))d.getPropertyValue(u)===""&&t.style.removeProperty(u);for(const u of Array.from(d)){if(Sp.includes(u)||u.startsWith(Le))continue;const c=d.getPropertyValue(u);t.style.setProperty(u,c)}}}else l!==null?t.setAttribute(a,l):t.removeAttribute(a)}i&&n&&t.replaceChildren(...e.cloneNode(!0).childNodes)});return r.observe(e,{attributes:!0,subtree:!0,childList:!0}),r}function Dp(e,t,n){const r=new MutationObserver(s=>{for(const i of s)if(i.addedNodes.length!==0)for(const o of Array.from(i.addedNodes)){if(o.contains(e)&&e.nextElementSibling!==t){e.insertAdjacentElement("afterend",t),yn(n);return}if(o.contains(t)&&t.previousElementSibling!==e){t.insertAdjacentElement("beforebegin",e),yn(n);return}}e.isConnected&&t.isConnected&&e.nextElementSibling!==t&&(e.insertAdjacentElement("afterend",t),yn(n))});return r.observe(e.ownerDocument.body,{childList:!0,subtree:!0}),r}function Ap(e){return new ResizeObserver(()=>{var t,n,r;const s=new ft(e.placeholder,{frameTransform:e.frameTransform,ignoreTransforms:!0}),i=(t=e.transformOrigin)!=null?t:{x:1,y:1},o=(e.width-s.width)*i.x+e.delta.x,a=(e.height-s.height)*i.y+e.delta.y,l=cu();if(e.styles.set({width:s.width-e.widthOffset,height:s.height-e.heightOffset,top:e.top+a+l.y,left:e.left+o+l.x},Le),(n=e.getElementMutationObserver())==null||n.takeRecords(),ro(e.element)&&ro(e.placeholder)){const m=Array.from(e.element.cells),b=Array.from(e.placeholder.cells);e.getSavedCellWidths()||e.setSavedCellWidths(m.map(w=>w.style.width));for(const[w,v]of m.entries()){const g=b[w];v.style.width=`${g.getBoundingClientRect().width}px`}}const d=(r=e.getTranslate())!=null?r:{x:0,y:0},u=e.left+o+l.x+d.x,c=e.top+a+l.y+d.y,f=s.width-e.widthOffset,h=s.height-e.heightOffset,p=e.frameTransform;e.dragOperation.shape=new ht(u*p.scaleX+p.x,c*p.scaleY+p.y,f*p.scaleX,h*p.scaleY)})}var Mp=250,Pp="ease";function Rp(e){var t,n,r,s;const{animation:i}=e;if(typeof i=="function"){const v=i({source:e.source,element:e.element,feedbackElement:e.feedbackElement,placeholder:e.placeholder,translate:e.translate,moved:e.moved});Promise.resolve(v).then(()=>{e.cleanup(),requestAnimationFrame(e.restoreFocus)});return}const{duration:o=Mp,easing:a=Pp}=i??{};yn(e.feedbackElement);const[,l]=(t=ou(e.feedbackElement,v=>"translate"in v))!=null?t:[];l?.pause();const d=(n=e.placeholder)!=null?n:e.element,u={frameTransform:Pu(e.feedbackElement,d)?null:void 0},c=new ft(e.feedbackElement,u),f=(r=xr(mt(e.feedbackElement).translate))!=null?r:e.translate,h=new ft(d,u),p=ht.delta(c,h,e.alignment),m={x:f.x-p.x,y:f.y-p.y},b=Math.round(c.intrinsicHeight)!==Math.round(h.intrinsicHeight)?{minHeight:[`${c.intrinsicHeight}px`,`${h.intrinsicHeight}px`],maxHeight:[`${c.intrinsicHeight}px`,`${h.intrinsicHeight}px`]}:{},w=Math.round(c.intrinsicWidth)!==Math.round(h.intrinsicWidth)?{minWidth:[`${c.intrinsicWidth}px`,`${h.intrinsicWidth}px`],maxWidth:[`${c.intrinsicWidth}px`,`${h.intrinsicWidth}px`]}:{};e.styles.set({transition:e.transition},Le),e.feedbackElement.setAttribute(no,""),(s=e.getElementMutationObserver())==null||s.takeRecords(),bu({element:e.feedbackElement,keyframes:oa(_r(_r({},b),w),{translate:[`${f.x}px ${f.y}px 0`,`${m.x}px ${m.y}px 0`]}),options:{duration:na(Ze(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?o:0,easing:a}}).then(()=>{e.feedbackElement.removeAttribute(no),l?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var Ru,so,kr,ca,ms,ju,Lu,On=class extends(so=We,Ru=[he],so){constructor(t,n){super(t,n),Ie(this,ms),Ie(this,ca,Pe(kr,8,this)),Pe(kr,11,this),this.state={initial:{},current:{}};const r=t.registry.plugins.get(Zs),s=r?.register($p);if(s){const i=this.destroy.bind(this);this.destroy=()=>{s(),i()}}this.registerEffect(Xt(this,ms,ju).bind(this,r)),this.registerEffect(Xt(this,ms,Lu))}};kr=Nn(so);ca=new WeakMap;ms=new WeakSet;ju=function(e){const{overlay:t}=this;if(!t||!e)return;const n=Os(t);if(n)return e.addRoot(n)};Lu=function(){var e,t,n,r,s,i,o;const{state:a,manager:l,options:d}=this,{dragOperation:u}=l,{position:c,source:f,status:h}=u;if(h.idle){a.current={},a.initial={};return}if(!f)return;const{element:p}=f,m=f.pluginConfig(On),b=(t=(e=m?.feedback)!=null?e:d?.feedback)!=null?t:"default",w=typeof b=="function"?b(f,l):b;if(!p||w==="none"||!h.initialized||h.initializing)return;const{initial:v}=a,g=(n=this.overlay)!=null?n:p,y=$n(g),_=$n(p),S=!Pu(p,g),E=new ft(p,{frameTransform:S?_:null,ignoreTransforms:!S}),A={x:_.scaleX/y.scaleX,y:_.scaleY/y.scaleY};let{width:T,height:D,top:q,left:P}=E;S&&(T=T/A.x,D=D/A.y);const z=new ep(g),U=mt(p),{transition:K,translate:Z,boxSizing:J,paddingBlockStart:ie,paddingBlockEnd:de,paddingInlineStart:I,paddingInlineEnd:V,borderInlineStartWidth:B,borderInlineEndWidth:R,borderBlockStartWidth:G,borderBlockEndWidth:ne}=U,Y=K.split(",").filter(ye=>!/^\s*(transform|translate|scale)\b/.test(ye)).join(","),H=Ys(U),L=U.transform,C=w==="clone",W=J==="content-box",M=W?parseInt(I)+parseInt(V)+parseInt(B)+parseInt(R):0,ee=W?parseInt(ie)+parseInt(de)+parseInt(G)+parseInt(ne):0,X=w!=="move"&&!this.overlay?Tp(f,C?"clone":"hidden"):null,le=fe(()=>wr(l.dragOperation.activatorEvent));if(!v.translate){if(this.overlay&&H)v.translate={x:H.x,y:H.y};else if(Z!=="none"){const ye=xr(Z);ye&&(v.translate=ye)}}if(!v.transformOrigin){const ye=fe(()=>c.current),De=P+((r=H?.x)!=null?r:0),He=q+((s=H?.y)!=null?s:0);v.transformOrigin={x:(ye.x-De*y.scaleX-y.x)/(T*y.scaleX),y:(ye.y-He*y.scaleY-y.y)/(D*y.scaleY)}}const{transformOrigin:ce}=v,N=q*y.scaleY+y.y,Q=P*y.scaleX+y.x;if(!v.coordinates&&(v.coordinates={x:Q,y:N},A.x!==1||A.y!==1)){const{scaleX:ye,scaleY:De}=_,{x:He,y:kt}=ce;v.coordinates.x+=(T*ye-T)*He,v.coordinates.y+=(D*De-D)*kt}v.dimensions||(v.dimensions={width:T,height:D}),v.frameTransform||(v.frameTransform=y);const me={x:v.coordinates.x-Q,y:v.coordinates.y-N},se={width:(v.dimensions.width*v.frameTransform.scaleX-T*y.scaleX)*ce.x,height:(v.dimensions.height*v.frameTransform.scaleY-D*y.scaleY)*ce.y},te={x:me.x/y.scaleX+se.width,y:me.y/y.scaleY+se.height},j={left:P+te.x,top:q+te.y};g.setAttribute(dt,"true");const F=fe(()=>u.transform),re=(i=v.translate)!=null?i:{x:0,y:0},ue=F.x*y.scaleX+re.x,je=F.y*y.scaleY+re.y,Rt=cu();z.set({width:T-M,height:D-ee,top:j.top+Rt.y,left:j.left+Rt.x,translate:`${ue}px ${je}px 0`,transform:this.overlay?"none":L,transition:Y?`${Y}, translate 0ms linear`:"translate 0ms linear",scale:S?`${A.x} ${A.y}`:"","transform-origin":`${ce.x*100}% ${ce.y*100}%`},Le),X&&(p.insertAdjacentElement("afterend",X),d?.rootElement&&(typeof d.rootElement=="function"?d.rootElement(f):d.rootElement).appendChild(p)),Zi(g)&&(g.hasAttribute("popover")||g.setAttribute("popover","manual"),yn(g),g.addEventListener("beforetoggle",el));let ut,zn,_t;const Wn=Ap({placeholder:X,element:p,feedbackElement:g,frameTransform:y,transformOrigin:ce,width:T,height:D,top:q,left:P,widthOffset:M,heightOffset:ee,delta:te,styles:z,dragOperation:u,getTranslate:()=>a.current.translate,getElementMutationObserver:()=>ut,getSavedCellWidths:()=>_t,setSavedCellWidths:ye=>{_t=ye}}),Gr=new ft(g);fe(()=>u.shape=Gr);const Bn=Ze(g),jt=ye=>{this.manager.actions.stop({event:ye})},Zd=na(Bn);le&&Bn.addEventListener("resize",jt),fe(()=>f.status)==="idle"&&requestAnimationFrame(()=>f.status="dragging"),X&&(Wn.observe(X),ut=Ip(p,X,C),zn=Dp(p,X,g));const Ca=(o=l.dragOperation.source)==null?void 0:o.id,Qd=()=>{var ye;if(!le||Ca==null)return;const De=l.registry.draggables.get(Ca),He=(ye=De?.handle)!=null?ye:De?.element;At(He)&&He.focus()},si=()=>{ut?.disconnect(),zn?.disconnect(),Wn.disconnect(),Bn.removeEventListener("resize",jt),Zi(g)&&(g.removeEventListener("beforetoggle",el),g.removeAttribute("popover")),g.removeAttribute(dt),z.reset();const ye=()=>{var De;if(_t&&ro(p)){const ii=Array.from(p.cells);for(const[qr,tn]of ii.entries())tn.style.width=(De=_t[qr])!=null?De:""}f.status="idle";const He=a.current.translate!=null,kt=u.status.dragging;X&&(!kt&&He||X.parentElement!==g.parentElement)&&g.isConnected&&X.replaceWith(g),X?.remove()};g===this.overlay?setTimeout(ye,0):ye()},Jd=d?.dropAnimation,Ia=this,ef=Dr(()=>{var ye,De,He;const{transform:kt,status:ii}=u;if(!(!kt.x&&!kt.y&&!a.current.translate)&&ii.dragging){const qr=(ye=v.translate)!=null?ye:{x:0,y:0},tn={x:kt.x/y.scaleX+qr.x,y:kt.y/y.scaleY+qr.y},Da=a.current.translate,tf=fe(()=>u.modifiers),oi=fe(()=>{var qn;return(qn=u.shape)==null?void 0:qn.current}),Gn=d?.keyboardTransition,Aa=le&&!Zd&&Gn!==null?`${(De=Gn?.duration)!=null?De:250}ms ${(He=Gn?.easing)!=null?He:"cubic-bezier(0.25, 1, 0.5, 1)"}`:"0ms linear";if(z.set({transition:Y?`${Y}, translate ${Aa}`:`translate ${Aa}`,translate:`${tn.x}px ${tn.y}px 0`},Le),ut?.takeRecords(),oi&&oi!==Gr&&Da&&!tf.length){const qn=Je.delta(tn,Da);u.shape=ht.from(oi.boundingRectangle).translate(qn.x*y.scaleX,qn.y*y.scaleY)}else u.shape=new ft(g);a.current.translate=tn}},function(){if(u.status.dropped){this.dispose(),f.status="dropping";const ye=m?.dropAnimation!==void 0?m.dropAnimation:Ia.dropAnimation!==void 0?Ia.dropAnimation:Jd;let De=a.current.translate;const He=De!=null;if(!De&&p!==g&&(De={x:0,y:0}),!De||ye===null){si();return}l.renderer.rendering.then(()=>{Rp({source:f,element:p,feedbackElement:g,placeholder:X,translate:De,moved:He,transition:K,alignment:f.alignment,styles:z,animation:ye??void 0,getElementMutationObserver:()=>ut,cleanup:si,restoreFocus:Qd})})}});return()=>{si(),ef()}};st(kr,4,"overlay",Ru,On,ca);Jt(kr,On);On.configure=Mr(On);var ua=On,Kn=!0,jp=!1,Nu,Fu,zu,Wu,Ot,da,fa;Wu=(zu=[he],et.Forward),Fu=(Nu=[he],et.Reverse);var Sr=class{constructor(){Ie(this,da,Pe(Ot,8,this,Kn)),Pe(Ot,11,this),Ie(this,fa,Pe(Ot,12,this,Kn)),Pe(Ot,15,this)}isLocked(e){return e===et.Idle?!1:e==null?this[et.Forward]===Kn&&this[et.Reverse]===Kn:this[e]===Kn}unlock(e){e!==et.Idle&&(this[e]=jp)}};Ot=Nn(null);da=new WeakMap;fa=new WeakMap;st(Ot,4,Wu,zu,Sr,da);st(Ot,4,Fu,Nu,Sr,fa);Jt(Ot,Sr);var Lp=[et.Forward,et.Reverse],tl=class{constructor(){this.x=new Sr,this.y=new Sr}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},Np=class extends We{constructor(e){super(e);const t=En(new tl);let n=null;this.signal=t,rt(()=>{const{status:r}=e.dragOperation;if(!r.initialized){n=null,t.value=new tl;return}const{delta:s}=e.dragOperation.position;if(n){const i={x:nl(s.x,n.x),y:nl(s.y,n.y)},o=t.peek();Te(()=>{for(const a of mc)for(const l of Lp)i[a]===l&&o[a].unlock(l);t.value=o})}n=s})}get current(){return this.signal.peek()}};function nl(e,t){return Math.sign(e-t)}var Bu,io,$r,ha,$t,oo,Lr=class extends(io=Pr,Bu=[he],io){constructor(e){super(e),Ie(this,ha,Pe($r,8,this,!1)),Pe($r,11,this),Ie(this,$t),Ie(this,oo,()=>{if(!be(this,$t))return;const{element:i,by:o}=be(this,$t);o.y&&(i.scrollTop+=o.y),o.x&&(i.scrollLeft+=o.x)}),this.scroll=(i,o)=>{var a;if(this.disabled)return!1;const l=this.getScrollableElements();if(!l)return Ke(this,$t,void 0),!1;const{position:d}=this.manager.dragOperation,u=d?.current;if(u){const{by:c}=i??{},f=c?{x:rl(c.x),y:rl(c.y)}:void 0,h=f?void 0:this.scrollIntentTracker.current;if(h?.isLocked())return!1;for(const p of l){const m=Ph(p,c);if(m.x||m.y){const{speed:b,direction:w}=Kh(p,u,f,o?.acceleration,o?.threshold);if(h)for(const v of mc)h[v].isLocked(w[v])&&(b[v]=0,w[v]=0);if(w.x||w.y){const{x:v,y:g}=c??w,y=v*b.x,_=g*b.y;if(y||_){const S=(a=be(this,$t))==null?void 0:a.by;if(this.autoScrolling&&S&&(S.x&&!y||S.y&&!_))continue;return Ke(this,$t,{element:p,by:{x:y,y:_}}),Is.schedule(be(this,oo)),!0}}}}}return Ke(this,$t,void 0),!1};let t=null,n=null;const r=Ri(()=>{const{position:i,source:o}=e.dragOperation;if(!i)return null;const a=uu(Os(o?.element),i.current);return a&&(t=a),a??t}),s=Ri(()=>{const i=r.value,{documentElement:o}=jn(i);if(!i||i===o){const{target:a}=e.dragOperation,l=a?.element;if(l){const d=Qi(l,{excludeElement:!1});return n=d,d}}if(i){const a=Qi(i,{excludeElement:!1});return this.autoScrolling&&n&&a.size<n?.size?n:(n=a,a)}return n=null,null},it);this.getScrollableElements=()=>s.value,this.scrollIntentTracker=new Np(e),this.destroy=e.monitor.addEventListener("dragmove",i=>{this.disabled||i.defaultPrevented||!wr(e.dragOperation.activatorEvent)||!i.by||this.scroll({by:i.by})&&i.preventDefault()})}};$r=Nn(io);ha=new WeakMap;$t=new WeakMap;oo=new WeakMap;st($r,4,"autoScrolling",Bu,Lr,ha);Jt($r,Lr);function rl(e){return e>0?et.Forward:e<0?et.Reverse:et.Idle}var Fp=class{constructor(e){this.scheduler=e,this.pending=!1,this.tasks=new Set,this.resolvers=new Set,this.flush=()=>{const{tasks:t,resolvers:n}=this;this.pending=!1,this.tasks=new Set,this.resolvers=new Set;for(const r of t)r();for(const r of n)r()}}schedule(e){return this.tasks.add(e),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(t=>this.resolvers.add(t))}},zp=new Fp(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),Wp=10,ao=class extends We{constructor(t,n){super(t,n);const r=t.registry.plugins.get(Lr);if(!r)throw new Error("AutoScroller plugin depends on Scroller plugin");this.destroy=rt(()=>{var s,i,o;if(this.disabled)return;const{position:a,status:l}=t.dragOperation;if(l.dragging){const d={acceleration:(s=this.options)==null?void 0:s.acceleration,threshold:typeof((i=this.options)==null?void 0:i.threshold)=="number"?{x:this.options.threshold,y:this.options.threshold}:(o=this.options)==null?void 0:o.threshold};if(r.scroll(void 0,d)){r.autoScrolling=!0;const c=setInterval(()=>zp.schedule(()=>r.scroll(void 0,d)),Wp);return()=>{clearInterval(c)}}else r.autoScrolling=!1}})}};ao.configure=Mr(ao);var Gu=ao,sl={capture:!0,passive:!0},sr,Bp=class extends Pr{constructor(e){super(e),Ie(this,sr),this.handleScroll=()=>{be(this,sr)==null&&Ke(this,sr,setTimeout(()=>{this.manager.collisionObserver.forceUpdate(!1),Ke(this,sr,void 0)},50))};const{dragOperation:t}=this.manager;this.destroy=rt(()=>{var n,r,s;if(t.status.dragging){const o=(s=(r=(n=t.source)==null?void 0:n.element)==null?void 0:r.ownerDocument)!=null?s:document;return o.addEventListener("scroll",this.handleScroll,sl),()=>{o.removeEventListener("scroll",this.handleScroll,sl)}}})}};sr=new WeakMap;var Gp="* { user-select: none !important; -webkit-user-select: none !important; }",qp=class extends We{constructor(e){super(e),this.manager=e;const t=e.registry.plugins.get(Zs),n=t?.register(Gp);if(this.destroy=rt(()=>{const{dragOperation:r}=this.manager;if(r.status.initialized)return gi(),document.addEventListener("selectionchange",gi,{capture:!0}),()=>{document.removeEventListener("selectionchange",gi,{capture:!0})}}),n){const r=this.destroy.bind(this);this.destroy=()=>{n(),r()}}}};function gi(){var e;(e=document.getSelection())==null||e.removeAllRanges()}var ir=Object.freeze({offset:10,keyboardCodes:{start:["Space","Enter"],cancel:["Escape"],end:["Space","Enter","Tab"],up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]},preventActivation(e,t){var n;const r=(n=t.handle)!=null?n:t.element;return e.target!==r}}),fn,Rs=class extends _n{constructor(t,n){super(t),this.manager=t,this.options=n,Ie(this,fn,[]),this.listeners=new du,this.handleSourceKeyDown=(r,s,i)=>{if(this.disabled||r.defaultPrevented||!Ht(r.target)||s.disabled)return;const{keyboardCodes:o=ir.keyboardCodes,preventActivation:a=ir.preventActivation}=i??{};o.start.includes(r.code)&&this.manager.dragOperation.status.idle&&(a?.(r,s)||this.handleStart(r,s,i))}}bind(t,n=this.options){return rt(()=>{var s;const i=(s=t.handle)!=null?s:t.element,o=a=>{wr(a)&&this.handleSourceKeyDown(a,t,n)};if(i)return i.addEventListener("keydown",o),()=>{i.removeEventListener("keydown",o)}})}handleStart(t,n,r){const{element:s}=n;if(!s)throw new Error("Source draggable does not have an associated element");t.preventDefault(),t.stopImmediatePropagation(),yu(s);const{center:i}=new ft(s);if(this.manager.actions.start({event:t,coordinates:{x:i.x,y:i.y},source:n}).signal.aborted)return this.cleanup();this.sideEffects();const a=jn(s),l=[this.listeners.bind(a,[{type:"keydown",listener:d=>this.handleKeyDown(d,n,r),options:{capture:!0}}])];be(this,fn).push(...l)}handleKeyDown(t,n,r){const{keyboardCodes:s=ir.keyboardCodes}=r??{};if(nn(t,[...s.end,...s.cancel])){t.preventDefault();const i=nn(t,s.cancel);this.handleEnd(t,i);return}nn(t,s.up)?this.handleMove("up",t):nn(t,s.down)&&this.handleMove("down",t),nn(t,s.left)?this.handleMove("left",t):nn(t,s.right)&&this.handleMove("right",t)}handleEnd(t,n){this.manager.actions.stop({event:t,canceled:n}),this.cleanup()}handleMove(t,n){var r,s;const{shape:i}=this.manager.dragOperation,o=n.shiftKey?5:1;let a={x:0,y:0},l=(s=(r=this.options)==null?void 0:r.offset)!=null?s:ir.offset;if(typeof l=="number"&&(l={x:l,y:l}),!!i){switch(t){case"up":a={x:0,y:-l.y*o};break;case"down":a={x:0,y:l.y*o};break;case"left":a={x:-l.x*o,y:0};break;case"right":a={x:l.x*o,y:0};break}(a.x||a.y)&&(n.preventDefault(),this.manager.actions.move({event:n,by:a}))}}sideEffects(){const t=this.manager.registry.plugins.get(Gu);t?.disabled===!1&&(t.disable(),be(this,fn).push(()=>{t.enable()}))}cleanup(){be(this,fn).forEach(t=>t()),Ke(this,fn,[])}destroy(){this.cleanup(),this.listeners.clear()}};fn=new WeakMap;Rs.configure=Mr(Rs);Rs.defaults=ir;var qu=Rs;function nn(e,t){return t.includes(e.code)}var Gt,Kp=class extends Hc{constructor(){super(...arguments),Ie(this,Gt)}onEvent(e){switch(e.type){case"pointerdown":Ke(this,Gt,kn(e));break;case"pointermove":if(!be(this,Gt))return;const{x:t,y:n}=kn(e),r={x:t-be(this,Gt).x,y:n-be(this,Gt).y},{tolerance:s}=this.options;if(s&&qi(r,s)){this.abort();return}qi(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort();break}}abort(){Ke(this,Gt,void 0)}};Gt=new WeakMap;var hn,qt,Vp=class extends Hc{constructor(){super(...arguments),Ie(this,hn),Ie(this,qt)}onEvent(e){switch(e.type){case"pointerdown":Ke(this,qt,kn(e)),Ke(this,hn,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!be(this,qt))return;const{x:t,y:n}=kn(e),r={x:t-be(this,qt).x,y:n-be(this,qt).y};qi(r,this.options.tolerance)&&this.abort();break;case"pointerup":this.abort();break}}abort(){be(this,hn)&&(clearTimeout(be(this,hn)),Ke(this,qt,void 0),Ke(this,hn,void 0))}};hn=new WeakMap;qt=new WeakMap;var vn=class{};vn.Delay=Vp;vn.Distance=Kp;var lo=Object.freeze({activationConstraints(e,t){var n;const{pointerType:r,target:s}=e;if(!(r==="mouse"&&Ht(s)&&(t.handle===s||(n=t.handle)!=null&&n.contains(s))))return r==="touch"?[new vn.Delay({value:250,tolerance:5})]:np(s)&&!e.defaultPrevented?[new vn.Delay({value:200,tolerance:0})]:[new vn.Delay({value:200,tolerance:10}),new vn.Distance({value:5})]},preventActivation(e,t){var n;const{target:r}=e;if(r===t.element||r===t.handle||!Ht(r)||(n=t.handle)!=null&&n.contains(r))return!1;const s=kh(r);return s===t.element?!1:!!s}}),pn,js=class extends _n{constructor(t,n){super(t),this.manager=t,this.options=n,Ie(this,pn,new Set),this.listeners=new du,this.latest={event:void 0,coordinates:void 0},this.handleMove=()=>{const{event:r,coordinates:s}=this.latest;!r||!s||this.manager.actions.move({event:r,to:s})},this.handleCancel=this.handleCancel.bind(this),this.handlePointerUp=this.handlePointerUp.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this)}activationConstraints(t,n,r=this.options){const{activationConstraints:s=lo.activationConstraints}=r??{};return typeof s=="function"?s(t,n):s}bind(t,n=this.options){return rt(()=>{var s;const i=new AbortController,{signal:o}=i,a=d=>{tp(d)&&this.handlePointerDown(d,t,n)};let l=[(s=t.handle)!=null?s:t.element];n?.activatorElements&&(Array.isArray(n.activatorElements)?l=n.activatorElements:l=n.activatorElements(t));for(const d of l)d&&(Xp(d.ownerDocument.defaultView),d.addEventListener("pointerdown",a,{signal:o}));return()=>i.abort()})}handlePointerDown(t,n,r){if(this.disabled||!t.isPrimary||t.button!==0||!Ht(t.target)||n.disabled||Up(t)||!this.manager.dragOperation.status.idle)return;const{preventActivation:s=lo.preventActivation}=r??{};if(s?.(t,n))return;const{target:i}=t,o=At(i)&&i.draggable&&i.getAttribute("draggable")==="true",a=$n(n.element),{x:l,y:d}=kn(t);this.initialCoordinates={x:l*a.scaleX+a.x,y:d*a.scaleY+a.y};const u=this.activationConstraints(t,n,r);t.sensor=this;const c=new ph(u,m=>this.handleStart(n,m));c.signal.onabort=()=>this.handleCancel(t),c.onEvent(t),this.controller=c;const f=Hi(),h=this.listeners.bind(f,[{type:"pointermove",listener:m=>this.handlePointerMove(m,n)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:o?this.handleCancel:Yr,options:{capture:!0}}]),p=()=>{h(),this.initialCoordinates=void 0};be(this,pn).add(p)}handlePointerMove(t,n){var r,s;if(((r=this.controller)==null?void 0:r.activated)===!1){(s=this.controller)==null||s.onEvent(t);return}if(this.manager.dragOperation.status.dragging){const i=kn(t),o=$n(n.element);i.x=i.x*o.scaleX+o.x,i.y=i.y*o.scaleY+o.y,t.preventDefault(),t.stopPropagation(),this.latest.event=t,this.latest.coordinates=i,Is.schedule(this.handleMove)}}handlePointerUp(t){const{status:n}=this.manager.dragOperation;if(!n.idle){t.preventDefault(),t.stopPropagation();const r=!n.initialized;this.manager.actions.stop({event:t,canceled:r})}this.cleanup()}handleKeyDown(t){t.key==="Escape"&&(t.preventDefault(),this.handleCancel(t))}handleStart(t,n){const{manager:r,initialCoordinates:s}=this;if(!s||!r.dragOperation.status.idle||n.defaultPrevented)return;if(r.actions.start({coordinates:s,event:n,source:t}).signal.aborted)return this.cleanup();n.preventDefault();const a=jn(n.target).body;try{a.setPointerCapture(n.pointerId)}catch{this.handleCancel(n);return}const l=Ht(n.target)?[n.target,a]:a,d=this.listeners.bind(l,[{type:"touchmove",listener:Yr,options:{passive:!1}},{type:"click",listener:Yr},{type:"contextmenu",listener:Yr},{type:"keydown",listener:this.handleKeyDown}]);be(this,pn).add(d)}handleCancel(t){const{dragOperation:n}=this.manager;n.status.initialized&&this.manager.actions.stop({event:t,canceled:!0}),this.cleanup()}cleanup(){const{controller:t}=this;this.controller=void 0,t&&!t.signal.aborted&&t.abort(),this.latest={event:void 0,coordinates:void 0},be(this,pn).forEach(n=>n()),be(this,pn).clear()}destroy(){this.cleanup(),this.listeners.clear()}};pn=new WeakMap;js.configure=Mr(js);js.defaults=lo;var co=js;function Up(e){return"sensor"in e}function Yr(e){e.preventDefault()}function Hp(){}var il=new WeakSet;function Xp(e){!e||il.has(e)||(e.addEventListener("touchmove",Hp,{capture:!1,passive:!1}),il.add(e))}var bn={modifiers:[],plugins:[xp,Gu,_p,ua,qp],sensors:[co,qu]},Ku=class extends vh{constructor(e={}){const t=lt(e.plugins,bn.plugins),n=lt(e.sensors,bn.sensors),r=lt(e.modifiers,bn.modifiers);super(oa(_r({},e),{plugins:[Bp,Lr,Zs,...t],sensors:n,modifiers:r}))}},Vu,Uu,uo,Et,pa,ga,Qs=class extends(uo=pt,Uu=[he],Vu=[he],uo){constructor(e,t){var n=e,{element:r,effects:s=()=>[],handle:i}=n,o=Su(n,["element","effects","handle"]);super(_r({effects:()=>[...s(),()=>{var a,l;const{manager:d}=this;if(!d)return;const c=((l=(a=this.sensors)==null?void 0:a.map(vr))!=null?l:[...d.sensors]).map(f=>{const h=f instanceof _n?f:d.registry.register(f.plugin),p=f instanceof _n?void 0:f.options;return h.bind(this,p)});return function(){c.forEach(h=>h())}}]},o),t),Ie(this,pa,Pe(Et,8,this)),Pe(Et,11,this),Ie(this,ga,Pe(Et,12,this)),Pe(Et,15,this),this.element=r,this.handle=i}};Et=Nn(uo);pa=new WeakMap;ga=new WeakMap;st(Et,4,"handle",Uu,Qs,pa);st(Et,4,"element",Vu,Qs,ga);Jt(Et,Qs);var Hu,Xu,fo,Ct,ma,mi,Yu,Zu,mr,va,Js=class extends(fo=gt,Xu=[he],Hu=[he],fo){constructor(e,t){var n=e,{element:r,effects:s=()=>[]}=n,i=Su(n,["element","effects"]);const{collisionDetector:o=xu}=i,a=d=>{const{manager:u,element:c}=this;if(!c||d===null){this.shape=void 0;return}if(!u)return;const f=new ft(c),h=fe(()=>this.shape);return f&&h?.equals(f)?h:(this.shape=f,f)},l=En(!1);super(oa(_r({},i),{collisionDetector:o,effects:()=>[...s(),()=>{const{element:d,manager:u}=this;if(!u)return;const{dragOperation:c}=u,{source:f}=c;l.value=!!(f&&c.status.initialized&&d&&!this.disabled&&this.accepts(f))},()=>{const{element:d}=this;if(l.value&&d){const u=new Mh(d,a);return()=>{u.disconnect(),this.shape=void 0}}},()=>{var d;if((d=this.manager)!=null&&d.dragOperation.status.initialized)return()=>{this.shape=void 0}}]}),t),Ie(this,mr),Ie(this,ma,Pe(Ct,8,this)),Pe(Ct,11,this),Ie(this,va,Pe(Ct,12,this)),Pe(Ct,15,this),this.element=r,this.refreshShape=()=>a()}set element(e){Ke(this,mr,e,Zu)}get element(){var e;return(e=this.proxy)!=null?e:be(this,mr,Yu)}};Ct=Nn(fo);ma=new WeakMap;mr=new WeakSet;va=new WeakMap;mi=st(Ct,20,"#element",Xu,mr,ma),Yu=mi.get,Zu=mi.set;st(Ct,4,"proxy",Hu,Js,va);Jt(Ct,Js);function Yp(e){return e!=null&&typeof e=="object"&&"current"in e}function xn(e){var t;if(e!=null)return Yp(e)?(t=e.current)!=null?t:void 0:e}var Zp=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Fn=Zp?k.useLayoutEffect:k.useEffect;function Qp(){const e=k.useState(0)[1];return k.useCallback(()=>{e(t=>t+1)},[e])}function Qu(e,t){const n=k.useRef(new Map),r=Qp();return Fn(()=>{if(!e){n.current.clear();return}return rt(()=>{var s;let i=!1,o=!1;for(const a of n.current){const[l]=a,d=fe(()=>a[1]),u=e[l];d!==u&&(i=!0,n.current.set(l,u),o=(s=t?.(l,d,u))!=null?s:!1)}i&&(o?queueMicrotask(()=>nf.flushSync(r)):r())})},[e]),k.useMemo(()=>e&&new Proxy(e,{get(s,i){const o=s[i];return n.current.set(i,o),o}}),[e])}function Jp(e,t){e()}function rn(e){const t=k.useRef(e);return Fn(()=>{t.current=e},[e]),t}function Se(e,t,n=k.useEffect,r=Object.is){const s=k.useRef(e);n(()=>{const i=s.current;r(e,i)||(s.current=e,t(e,i))},[t,e])}function vs(e,t){const n=k.useRef(xn(e));Fn(()=>{const r=xn(e);r!==n.current&&(n.current=r,t(r))})}var eg=Object.defineProperty,tg=Object.defineProperties,ng=Object.getOwnPropertyDescriptors,Ls=Object.getOwnPropertySymbols,Ju=Object.prototype.hasOwnProperty,ed=Object.prototype.propertyIsEnumerable,ol=(e,t,n)=>t in e?eg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,rg=(e,t)=>{for(var n in t||(t={}))Ju.call(t,n)&&ol(e,n,t[n]);if(Ls)for(var n of Ls(t))ed.call(t,n)&&ol(e,n,t[n]);return e},sg=(e,t)=>tg(e,ng(t)),ig=(e,t)=>{var n={};for(var r in e)Ju.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ls)for(var r of Ls(e))t.indexOf(r)<0&&ed.call(e,r)&&(n[r]=e[r]);return n},og=new Ku,td=k.createContext(og),ag=k.memo(k.forwardRef(({children:e},t)=>{const[n,r]=k.useState(0),s=k.useRef(null),i=k.useRef(null),o=k.useMemo(()=>({renderer:{get rendering(){var a;return(a=s.current)!=null?a:Promise.resolve()}},trackRendering(a){s.current||(s.current=new Promise(l=>{i.current=l})),k.startTransition(()=>{a(),r(l=>l+1)})}}),[]);return Fn(()=>{var a;(a=i.current)==null||a.call(i),s.current=null},[e,n]),k.useImperativeHandle(t,()=>o),null})),vi=[void 0,it];function lg(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:s,onDragStart:i,onDragMove:o,onDragOver:a,onDragEnd:l}=t,d=ig(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const u=k.useRef(null),{plugins:c,modifiers:f,sensors:h}=d,p=lt(c,bn.plugins),m=lt(h,bn.sensors),b=lt(f,bn.modifiers),w=rn(s),v=rn(i),g=rn(a),y=rn(o),_=rn(l),S=rn(r),E=cg(()=>{var A;return(A=d.manager)!=null?A:new Ku(d)});return k.useEffect(()=>{if(!u.current)throw new Error("Renderer not found");const{renderer:A,trackRendering:T}=u.current,{monitor:D}=E;E.renderer=A;const q=[D.addEventListener("beforedragstart",P=>{const z=w.current;z&&T(()=>z(P,E))}),D.addEventListener("dragstart",P=>{var z;return(z=v.current)==null?void 0:z.call(v,P,E)}),D.addEventListener("dragover",P=>{const z=g.current;z&&T(()=>z(P,E))}),D.addEventListener("dragmove",P=>{const z=y.current;z&&T(()=>z(P,E))}),D.addEventListener("dragend",P=>{const z=_.current;z&&T(()=>z(P,E))}),D.addEventListener("collision",P=>{var z;return(z=S.current)==null?void 0:z.call(S,P,E)})];return()=>q.forEach(P=>P())},[E]),Se(p,()=>E&&(E.plugins=p),...vi),Se(m,()=>E&&(E.sensors=m),...vi),Se(b,()=>E&&(E.modifiers=b),...vi),x.jsxs(td.Provider,{value:E,children:[x.jsx(ag,{ref:u,children:n}),n]})}function cg(e){const t=k.useRef(null);return t.current||(t.current=e()),k.useInsertionEffect(()=>()=>{var n;return(n=t.current)==null?void 0:n.destroy()},[]),t.current}function ug(){return k.useContext(td)}function nd(e){var t;const n=(t=ug())!=null?t:void 0,[r]=k.useState(()=>e(n));return r.manager!==n&&(r.manager=n),Fn(r.register,[n,r]),r}var dg=Object.create,rd=Object.defineProperty,fg=Object.getOwnPropertyDescriptor,sd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),ei=e=>{throw TypeError(e)},hg=(e,t,n)=>t in e?rd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,pg=e=>{var t;return[,,,dg((t=e?.[sd("metadata")])!=null?t:null)]},id=["class","method","getter","setter","accessor","field","value","get","set"],od=e=>e!==void 0&&typeof e!="function"?ei("Function expected"):e,gg=(e,t,n,r,s)=>({kind:id[e],name:t,metadata:r,addInitializer:i=>n._?ei("Already initialized"):s.push(od(i||null))}),mg=(e,t)=>hg(t,sd("metadata"),e[3]),vg=(e,t,n,r)=>{for(var s=0,i=e[t>>1],o=i&&i.length;s<o;s++)i[s].call(n);return r},ad=(e,t,n,r,s,i)=>{for(var o,a,l,d,u=t&7,c=!1,f=!1,h=2,p=id[u+5],m=e[h]||(e[h]=[]),b=(s=s.prototype,fg(s,n)),w=r.length-1;w>=0;w--)l=gg(u,n,a={},e[3],m),l.static=c,l.private=f,d=l.access={has:v=>n in v},d.get=v=>v[n],o=(0,r[w])(b[p],l),a._=1,od(o)&&(b[p]=o);return b&&rd(s,n,b),s},ld=(e,t,n)=>t.has(e)||ei("Cannot "+n),yg=(e,t,n)=>(ld(e,t,"read from private field"),t.get(e)),bg=(e,t,n)=>t.has(e)?ei("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),xg=(e,t,n,r)=>(ld(e,t,"write to private field"),t.set(e,n),n),Vt=class ho{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new ho(t.x-n.x,t.y-n.y)}static distance(t,n){return Math.hypot(t.x-n.x,t.y-n.y)}static equals(t,n){return t.x===n.x&&t.y===n.y}static from({x:t,y:n}){return new ho(t,n)}},cd,ud,po,ys,Nr,ya=class extends(po=Zt,ud=[Ee],cd=[Ee],po){constructor(e){const t=Vt.from(e);super(t,(n,r)=>Vt.equals(n,r)),vg(Nr,5,this),bg(this,ys,0),this.velocity={x:0,y:0}}get delta(){return Vt.delta(this.current,this.initial)}get direction(){const{current:e,previous:t}=this;if(!t)return null;const n={x:e.x-t.x,y:e.y-t.y};return!n.x&&!n.y?null:Math.abs(n.x)>Math.abs(n.y)?n.x>0?"right":"left":n.y>0?"down":"up"}get current(){return super.current}set current(e){const{current:t}=this,n=Vt.from(e),r={x:n.x-t.x,y:n.y-t.y},s=Date.now(),i=s-yg(this,ys),o=a=>Math.round(a/i*100);Te(()=>{xg(this,ys,s),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(Vt.from(e)),this.velocity={x:0,y:0}}};Nr=pg(po);ys=new WeakMap;ad(Nr,2,"delta",ud,ya);ad(Nr,2,"direction",cd,ya);mg(Nr,ya);var dd=(e=>(e.Horizontal="x",e.Vertical="y",e))(dd||{});Object.values(dd);var wg=({dragOperation:e,droppable:t})=>{const n=e.position.current;if(!n)return null;const{id:r}=t;if(!t.shape)return null;if(t.shape.containsPoint(n)){const s=Vt.distance(t.shape.center,n);return{id:r,value:1/s,type:Rn.PointerIntersection,priority:Pn.High}}return null},_g=({dragOperation:e,droppable:t})=>{const{shape:n}=e;if(!t.shape||!n?.current)return null;const r=n.current.intersectionArea(t.shape);if(r){const{position:s}=e,i=Vt.distance(t.shape.center,s.current),a=r/(n.current.area+t.shape.area-r)/i;return{id:t.id,value:a,type:Rn.ShapeIntersection,priority:Pn.Normal}}return null},kg=e=>{var t;return(t=wg(e))!=null?t:_g(e)};function Sg(e){const{collisionDetector:t,data:n,disabled:r,element:s,id:i,accept:o,type:a}=e,l=nd(u=>new Js(sg(rg({},e),{register:!1,element:xn(s)}),u)),d=Qu(l);return Se(i,()=>l.id=i),vs(s,u=>l.element=u),Se(o,()=>l.accept=o,void 0,it),Se(t,()=>l.collisionDetector=t??kg),Se(n,()=>n&&(l.data=n)),Se(r,()=>l.disabled=r===!0),Se(a,()=>l.type=a),{droppable:d,get isDropTarget(){return d.isDropTarget},ref:k.useCallback(u=>{var c,f;!u&&((c=l.element)!=null&&c.isConnected)&&!((f=l.manager)!=null&&f.dragOperation.status.idle)||(l.element=u??void 0)},[l])}}const al=`url("data:image/svg+xml;utf8,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"/><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"/></svg>')}")`,fd=(e,t="line")=>{const n=[":is(p, h1, h2, h3, h4, h5, h6):first-child::after","> * > span:only-child::after"],r=o=>n.map(a=>`${o} ${a}`).join(", "),s=t==="line"?"&::after":r("&"),i=t==="line"?"&:hover::after, &:focus-visible::after":`${r("&:hover")}, ${r("&:focus-visible")}`;return{cursor:"text",borderRadius:"2px",[s]:{content:'""',display:"inline-block",width:"0.8em",height:"0.8em",ml:"0.4em",verticalAlign:"-0.05em",backgroundColor:"currentColor",maskImage:al,WebkitMaskImage:al,maskSize:"contain",WebkitMaskSize:"contain",maskRepeat:"no-repeat",WebkitMaskRepeat:"no-repeat",opacity:.35,transition:`opacity ${O.MOTION_FAST}`,...O.reducedMotionSx,pointerEvents:"none"},[i]:{opacity:.8},"&:focus-visible":{outline:`2px solid ${e.accent}`,outlineOffset:2}}},hd=k.createContext(void 0);function pd(e,t){const n=k.useContext(hd),r=k.useRef(t);r.current=t,k.useEffect(()=>{if(!n||!e)return;const i=()=>r.current();return n.commitRef.current=i,()=>{n.commitRef.current===i&&(n.commitRef.current=void 0)}},[n,e]);const s=k.useRef(!1);k.useLayoutEffect(()=>{!e&&!s.current||(s.current=e,n?.setDirty(e))},[n,e]),k.useLayoutEffect(()=>()=>{s.current&&n?.setDirty(!1)},[n])}function go({value:e,placeholder:t,ariaLabel:n,onCommit:r,faintWhenEmpty:s=!1}){const{theme:i}=Be.usePublisherTheme(),[o,a]=k.useState(void 0),l=k.useRef(!1),d=()=>{l.current||o===void 0||(a(void 0),o!==e&&r(o))};pd(o!==void 0&&o!==e,()=>(d(),!0));const u=()=>{l.current=!1,a(e)};if(o===void 0){const c=e==="",f=c&&s;return x.jsx($.Box,{component:"button",type:"button",className:f?"builder-affordance":void 0,onClick:u,onKeyDown:h=>{h.key!=="Enter"&&h.key!==" "||(h.preventDefault(),u())},sx:[{all:"unset",boxSizing:"border-box",font:"inherit",color:"inherit",display:"inline-block",maxWidth:"100%",...c&&{fontStyle:"italic",opacity:f?0:.6}},fd(i)],children:c?t:e})}return x.jsx($.InputBase,{autoFocus:!0,fullWidth:!0,value:o,placeholder:t,inputProps:{"aria-label":n},onFocus:c=>c.target.select(),onChange:c=>a(c.target.value),onKeyDown:c=>{c.key==="Enter"&&!c.nativeEvent.isComposing?d():c.key==="Escape"&&(l.current=!0,a(void 0))},onBlur:d,sx:{font:"inherit",color:"inherit",p:0,"& input":{p:0}}})}const $g=(e,t)=>e.map((n,r)=>{const s=t[r]??!1;if(s===(n.break??!1))return n;const i={...n};return s?i.break=!0:delete i.break,i}),Tg=(e,t,n)=>{const r=[...e],[s]=r.splice(t,1);if(!s)return[...e];const i=r[t];s.break&&i&&!i.break&&(r[t]={...i,break:!0});const o={...s};return delete o.break,r.splice(n,0,o),r},gd=(e,t)=>({kind:"tile",tile:e,index:t,colspan:e.colspan,break:e.break}),md=e=>`gap.${e}`,Og=(e,t)=>{const n=[];let r=0;e.forEach((i,o)=>{const a=Math.min(i.colspan??1,t),l=o===0||i.break===!0||r+a>t;l&&o>0&&r<t&&n.push({kind:"gap",after:Fe(e[o-1]),colspan:t-r}),l&&(r=0),n.push(gd(i,o)),r+=a});const s=e.at(-1);return s&&r<t&&n.push({kind:"gap",after:Fe(s),colspan:t-r}),n};var Eg=Object.create,vd=Object.defineProperty,Cg=Object.defineProperties,Ig=Object.getOwnPropertyDescriptor,Dg=Object.getOwnPropertyDescriptors,Ns=Object.getOwnPropertySymbols,yd=Object.prototype.hasOwnProperty,bd=Object.prototype.propertyIsEnumerable,Ag=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Fr=e=>{throw TypeError(e)},mo=(e,t,n)=>t in e?vd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yi=(e,t)=>{for(var n in t||(t={}))yd.call(t,n)&&mo(e,n,t[n]);if(Ns)for(var n of Ns(t))bd.call(t,n)&&mo(e,n,t[n]);return e},bi=(e,t)=>Cg(e,Dg(t)),Mg=(e,t)=>{var n={};for(var r in e)yd.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ns)for(var r of Ns(e))t.indexOf(r)<0&&bd.call(e,r)&&(n[r]=e[r]);return n},Pg=e=>{var t;return[,,,Eg((t=void 0)!=null?t:null)]},xd=["class","method","getter","setter","accessor","field","value","get","set"],or=e=>e!==void 0&&typeof e!="function"?Fr("Function expected"):e,Rg=(e,t,n,r,s)=>({kind:xd[e],name:t,metadata:r,addInitializer:i=>n._?Fr("Already initialized"):s.push(or(i||null))}),jg=(e,t)=>mo(t,Ag("metadata"),e[3]),Zr=(e,t,n,r)=>{for(var s=0,i=e[t>>1],o=i&&i.length;s<o;s++)t&1?i[s].call(n):r=i[s].call(n,r);return r},wd=(e,t,n,r,s,i)=>{for(var o,a,l,d,u,c=t&7,f=!1,h=!1,p=e.length+1,m=xd[c+5],b=e[p-1]=[],w=e[p]||(e[p]=[]),v=(s=s.prototype,Ig({get[n](){return ar(this,i)},set[n](y){return Kt(this,i,y)}},n)),g=r.length-1;g>=0;g--)d=Rg(c,n,l={},e[3],w),d.static=f,d.private=h,u=d.access={has:y=>n in y},u.get=y=>y[n],u.set=(y,_)=>y[n]=_,a=(0,r[g])({get:v.get,set:v.set},d),l._=1,a===void 0?or(a)&&(v[m]=a):typeof a!="object"||a===null?Fr("Object expected"):(or(o=a.get)&&(v.get=o),or(o=a.set)&&(v.set=o),or(o=a.init)&&b.unshift(o));return v&&vd(s,n,v),s},_d=(e,t,n)=>t.has(e)||Fr("Cannot "+n),ar=(e,t,n)=>(_d(e,t,"read from private field"),t.get(e)),Vn=(e,t,n)=>t.has(e)?Fr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Kt=(e,t,n,r)=>(_d(e,t,"write to private field"),t.set(e,n),n);function Ut(e){return e instanceof wa||e instanceof Td}var Qr=10,Lg=class extends We{constructor(e){super(e);const t=rt(()=>{const{dragOperation:r}=e;if(wr(r.activatorEvent)&&Ut(r.source)&&r.status.initialized){const s=e.registry.plugins.get(Lr);if(s)return s.disable(),()=>s.enable()}}),n=e.monitor.addEventListener("dragmove",(r,s)=>{queueMicrotask(()=>{if(this.disabled||r.defaultPrevented||!r.nativeEvent)return;const{dragOperation:i}=s;if(!wr(r.nativeEvent)||!Ut(i.source)||!i.shape)return;const{actions:o,collisionObserver:a,registry:l}=s,{by:d}=r;if(!d)return;const u=Ng(d),{source:c,target:f}=i,{center:h}=i.shape.current,p=[],m=[];Te(()=>{for(const _ of l.droppables){const{id:S}=_;if(!_.accepts(c)||S===f?.id&&Ut(_)||!_.element)continue;let E=_.shape;const A=new ft(_.element,{getBoundingClientRect:T=>br(T,void 0,.2)});!A.height||!A.width||(u=="down"&&h.y+Qr<A.center.y||u=="up"&&h.y-Qr>A.center.y||u=="left"&&h.x-Qr>A.center.x||u=="right"&&h.x+Qr<A.center.x)&&(p.push(_),_.shape=A,m.push(()=>_.shape=E))}}),r.preventDefault(),a.disable();const b=a.computeCollisions(p,ip);Te(()=>m.forEach(_=>_()));const[w]=b;if(!w)return;const{id:v}=w,{index:g,group:y}=c.sortable;o.setDropTarget(v).then(()=>{const{source:_,target:S,shape:E}=i;if(!_||!Ut(_)||!E)return;const{index:A,group:T,target:D}=_.sortable,q=g!==A||y!==T,P=q?D:S?.element;if(!P)return;yu(P);const z=new ft(P);if(!z)return;const U=ht.delta(z,ht.from(E.current.boundingRectangle),_.alignment);o.move({by:U}),q?o.setDropTarget(_.id).then(()=>a.enable()):a.enable()})})});this.destroy=()=>{n(),t()}}};function Ng(e){const{x:t,y:n}=e;if(t>0)return"right";if(t<0)return"left";if(n>0)return"down";if(n<0)return"up"}var Fg=Object.defineProperty,zg=Object.defineProperties,Wg=Object.getOwnPropertyDescriptors,ll=Object.getOwnPropertySymbols,Bg=Object.prototype.hasOwnProperty,Gg=Object.prototype.propertyIsEnumerable,cl=(e,t,n)=>t in e?Fg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sn=(e,t)=>{for(var n in t||(t={}))Bg.call(t,n)&&cl(e,n,t[n]);if(ll)for(var n of ll(t))Gg.call(t,n)&&cl(e,n,t[n]);return e},on=(e,t)=>zg(e,Wg(t));function qg(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function Jr(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function xi(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function Kg(e,t,n){var r,s;const{source:i,target:o,canceled:a}=t.operation;if(!i||!o||a)return"preventDefault"in t&&t.preventDefault(),e;const l=(g,y)=>g===y||g!==null&&typeof g=="object"&&"id"in g&&g.id===y;if(Array.isArray(e)){const g=e.findIndex(_=>l(_,i.id)),y=e.findIndex(_=>l(_,o.id));if(g===-1||y===-1){if(xi(i)){const _=i.initialIndex,S=i.index;return _===S||_<0||_>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,_,S)}return e}if(!a&&"index"in i&&typeof i.index=="number"){const _=i.index;if(_!==g)return n(e,g,_)}return n(e,g,y)}const d=Object.entries(e);let u=-1,c,f=-1,h;for(const[g,y]of d)if(u===-1&&(u=y.findIndex(_=>l(_,i.id)),u!==-1&&(c=g)),f===-1&&(f=y.findIndex(_=>l(_,o.id)),f!==-1&&(h=g)),u!==-1&&f!==-1)break;if(u===-1&&xi(i)){const g=i.initialGroup==null?void 0:Jr(e,i.initialGroup),y=i.initialIndex,_=i.group==null?void 0:Jr(e,i.group),S=i.index;if(g==null||_==null||g===_&&y===S)return"preventDefault"in t&&t.preventDefault(),e;if(g===_)return on(sn({},e),{[g]:n(e[g],y,S)});const E=e[g][y];return on(sn({},e),{[g]:[...e[g].slice(0,y),...e[g].slice(y+1)],[_]:[...e[_].slice(0,S),E,...e[_].slice(S)]})}if(!i.manager)return e;const{dragOperation:p}=i.manager,m=(s=(r=p.shape)==null?void 0:r.current.center)!=null?s:p.position.current;if(h==null){const g=Jr(e,o.id);if(g!=null){const y=o.shape&&m.y>o.shape.center.y?e[g].length:0;h=g,f=y}}if(c==null||h==null||c===h&&u===f){if(c!=null&&c===h&&u===f&&xi(i)){const g=i.group==null?void 0:Jr(e,i.group),y=i.group!=null&&g!==c,_=i.index!==u;if(y||_){const S=i.group==null?c:g;if(S!=null){if(c===S)return on(sn({},e),{[c]:n(e[c],u,i.index)});const E=e[c][u];return on(sn({},e),{[c]:[...e[c].slice(0,u),...e[c].slice(u+1)],[S]:[...e[S].slice(0,i.index),E,...e[S].slice(i.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(c===h)return on(sn({},e),{[c]:n(e[c],u,f)});const w=o.shape&&Math.round(m.y)>Math.round(o.shape.center.y)?1:0,v=e[c][u];return on(sn({},e),{[c]:[...e[c].slice(0,u),...e[c].slice(u+1)],[h]:[...e[h].slice(0,f+w),v,...e[h].slice(f+w)]})}function Vg(e,t){return Kg(e,t,qg)}function ul(e){const t=new Map;for(const[,n]of e)for(const r of n)t.set(r.id,r.index);return t}function dl(e,t,n){var r;for(const[s,i]of t)for(const o of i){const a=e.get(o.id);if(o.index!==a||o.group!==s||!((r=n.get(s))!=null&&r.has(o)))return!0}return!1}var fl="__default__",Ug=class extends We{constructor(e){super(e);const t=()=>{const r=new Map;for(const s of e.registry.droppables)if(s instanceof wa){const{sortable:i}=s,{group:o}=i;let a=r.get(o);a||(a=new Set,r.set(o,a)),a.add(i)}return r},n=[e.monitor.addEventListener("dragover",(r,s)=>{if(this.disabled)return;const{dragOperation:i}=s,{source:o,target:a}=i;if(!Ut(o)||!Ut(a)||o.sortable===a.sortable)return;const l=t(),d=ul(l),u=o.sortable.group===a.sortable.group,c=l.get(o.sortable.group),f=u?c:l.get(a.sortable.group);!c||!f||queueMicrotask(()=>{r.defaultPrevented||s.renderer.rendering.then(()=>{var h,p;const m=t();if(dl(d,l,m))return;const b=o.sortable.element,w=a.sortable.element;if(!w||!b||!u&&a.id===o.sortable.group)return;const v=es(c),g=u?v:es(f),y=(h=o.sortable.group)!=null?h:fl,_=(p=a.sortable.group)!=null?p:fl,S={[y]:v,[_]:g},E=Vg(S,r);if(S===E)return;const A=E[_].indexOf(o.sortable),T=E[_].indexOf(a.sortable);s.collisionObserver.disable(),hl(b,A,w,T),Te(()=>{for(const[D,q]of E[y].entries())q.index=D;if(!u)for(const[D,q]of E[_].entries())q.group=a.sortable.group,q.index=D}),s.actions.setDropTarget(o.id).then(()=>s.collisionObserver.enable())})})}),e.monitor.addEventListener("dragend",(r,s)=>{if(!r.canceled)return;const{dragOperation:i}=s,{source:o}=i;Ut(o)&&(o.sortable.initialIndex===o.sortable.index&&o.sortable.initialGroup===o.sortable.group||queueMicrotask(()=>{const a=t(),l=ul(a),d=a.get(o.sortable.initialGroup);d&&s.renderer.rendering.then(()=>{const u=t();if(dl(l,a,u))return;const c=es(d),f=es(d,Xg),h=o.sortable.element,p=f.indexOf(o.sortable),m=c[p],b=m?.element;!m||!b||!h||(hl(h,m.index,b,o.index),Te(()=>{for(const w of a.values()){const v=Array.from(w).values();for(const g of v)g.index=g.initialIndex,g.group=g.initialGroup}}))})}))})];this.destroy=()=>{for(const r of n)r()}}};function hl(e,t,n,r){const s=r<t?"afterend":"beforebegin";n.insertAdjacentElement(s,e)}function Hg(e,t){return e.index-t.index}function Xg(e,t){return e.initialIndex-t.initialIndex}function es(e,t=Hg){return Array.from(e).sort(t)}var pl=[Lg,Ug],kd={duration:250,easing:"cubic-bezier(0.25, 1, 0.5, 1)",idle:!1};function gl(e){var t,n;return typeof e=="boolean"?{draggable:e,droppable:e}:{draggable:(t=e?.draggable)!=null?t:!1,droppable:(n=e?.droppable)!=null?n:!1}}var ts=new Bf,Sd,$d,It,ba,lr,cr,xa,gn;$d=[he],Sd=[he];var ti=class{constructor(e,t){Vn(this,ba,Zr(It,8,this)),Zr(It,11,this),Vn(this,lr),Vn(this,cr),Vn(this,xa,Zr(It,12,this)),Zr(It,15,this),Vn(this,gn),this.register=()=>(Te(()=>{var p,m;(p=this.manager)==null||p.registry.register(this.droppable),(m=this.manager)==null||m.registry.register(this.draggable)}),()=>this.unregister()),this.unregister=()=>{Te(()=>{var p,m;(p=this.manager)==null||p.registry.unregister(this.droppable),(m=this.manager)==null||m.registry.unregister(this.draggable)})},this.destroy=()=>{Te(()=>{this.droppable.destroy(),this.draggable.destroy()})};var n=e,{effects:r=()=>[],disabled:s,group:i,index:o,sensors:a,type:l,transition:d=kd,plugins:u}=n,c=Mg(n,["effects","disabled","group","index","sensors","type","transition","plugins"]);const f=lt(u,pl),h=gl(s);this.droppable=new wa(bi(yi({},c),{disabled:h.droppable}),t,this),this.draggable=new Td(bi(yi({},c),{disabled:h.draggable,plugins:f,effects:()=>[()=>{var p,m,b;const w=(p=this.manager)==null?void 0:p.dragOperation.status;w?.initializing&&this.id===((b=(m=this.manager)==null?void 0:m.dragOperation.source)==null?void 0:b.id)&&ts.clear(this.manager),w?.dragging&&ts.set(this.manager,this.id,fe(()=>({initialIndex:this.index,initialGroup:this.group})))},()=>{const{index:p,group:m,manager:b}=this,w=ar(this,cr),v=ar(this,lr);(p!==w||m!==v)&&(Kt(this,cr,p),Kt(this,lr,m),this.animate())},()=>{var p,m;const{target:b}=this,{isDragSource:w}=this.draggable;((m=(p=this.draggable.pluginConfig(ua))==null?void 0:p.feedback)!=null?m:"default")==="move"&&w&&(this.droppable.disabled=!b)},...r()],type:l,sensors:a}),t,this),Kt(this,gn,c.element),this.manager=t,this.index=o,Kt(this,cr,o),this.group=i,Kt(this,lr,i),this.type=l,this.transition=d}get initialIndex(){var e,t;return(t=(e=ts.get(this.manager,this.id))==null?void 0:e.initialIndex)!=null?t:this.index}get initialGroup(){var e,t;return(t=(e=ts.get(this.manager,this.id))==null?void 0:e.initialGroup)!=null?t:this.group}animate(){fe(()=>{const{manager:e,transition:t}=this,{shape:n}=this.droppable;if(!e)return;const{idle:r}=e.dragOperation.status;!n||!t||r&&!t.idle||e.renderer.rendering.then(()=>{const{element:s}=this;if(!s)return;for(const u of s.getAnimations())"transitionProperty"in u&&(u.transitionProperty==="transform"||u.transitionProperty==="translate"||u.transitionProperty==="scale")&&u.cancel();const i=this.refreshShape();if(!i)return;const o={x:n.boundingRectangle.left-i.boundingRectangle.left,y:n.boundingRectangle.top-i.boundingRectangle.top},{translate:a}=mt(s),l=Za(s,a,!1),d=Za(s,a);if(o.x||o.y){const u=na(Ze(s))?bi(yi({},t),{duration:0}):t;bu({element:s,keyframes:{translate:[`${l.x+o.x}px ${l.y+o.y}px ${l.z}`,`${d.x}px ${d.y}px ${d.z}`]},options:u}).then(()=>{e.dragOperation.status.dragging||(this.droppable.shape=void 0)})}})})}get manager(){return this.draggable.manager}set manager(e){Te(()=>{this.draggable.manager=e,this.droppable.manager=e})}set element(e){Te(()=>{const t=ar(this,gn),n=this.droppable.element,r=this.draggable.element;(!n||n===t)&&(this.droppable.element=e),(!r||r===t)&&(this.draggable.element=e),Kt(this,gn,e)})}get element(){var e,t;const n=ar(this,gn);if(n)return(t=(e=Xi.get(n))!=null?e:n)!=null?t:this.droppable.element}set target(e){this.droppable.element=e}get target(){return this.droppable.element}set source(e){this.draggable.element=e}get source(){return this.draggable.element}get disabled(){const{disabled:e}=this.draggable,{disabled:t}=this.droppable;return e===t?e:{draggable:e,droppable:t}}set plugins(e){this.draggable.plugins=lt(e,pl)}set disabled(e){const t=gl(e);Te(()=>{this.droppable.disabled=t.droppable,this.draggable.disabled=t.draggable})}set data(e){Te(()=>{this.droppable.data=e,this.draggable.data=e})}set handle(e){this.draggable.handle=e}set id(e){this.droppable.id=e,this.draggable.id=e}get id(){return this.droppable.id}set sensors(e){this.draggable.sensors=e}set modifiers(e){this.draggable.modifiers=e}set collisionPriority(e){this.droppable.collisionPriority=e}set collisionDetector(e){this.droppable.collisionDetector=e??xu}set alignment(e){this.draggable.alignment=e}get alignment(){return this.draggable.alignment}set type(e){Te(()=>{this.droppable.type=e,this.draggable.type=e})}get type(){return this.draggable.type}set accept(e){this.droppable.accept=e}get accept(){return this.droppable.accept}get isDropTarget(){return this.droppable.isDropTarget}get isDragSource(){return this.draggable.isDragSource}get isDragging(){return this.draggable.isDragging}get isDropping(){return this.draggable.isDropping}get status(){return this.draggable.status}refreshShape(){return this.droppable.refreshShape()}accepts(e){return this.droppable.accepts(e)}};It=Pg();ba=new WeakMap;lr=new WeakMap;cr=new WeakMap;xa=new WeakMap;gn=new WeakMap;wd(It,4,"index",$d,ti,ba);wd(It,4,"group",Sd,ti,xa);jg(It,ti);var Td=class extends Qs{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}get initialIndex(){return this.sortable.initialIndex}get group(){return this.sortable.group}get initialGroup(){return this.sortable.initialGroup}},wa=class extends Js{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}get group(){return this.sortable.group}},Yg=Object.defineProperty,Zg=Object.defineProperties,Qg=Object.getOwnPropertyDescriptors,ml=Object.getOwnPropertySymbols,Jg=Object.prototype.hasOwnProperty,em=Object.prototype.propertyIsEnumerable,vl=(e,t,n)=>t in e?Yg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,wi=(e,t)=>{for(var n in t||(t={}))Jg.call(t,n)&&vl(e,n,t[n]);if(ml)for(var n of ml(t))em.call(t,n)&&vl(e,n,t[n]);return e},tm=(e,t)=>Zg(e,Qg(t));function nm(e){const{accept:t,collisionDetector:n,collisionPriority:r,id:s,data:i,element:o,handle:a,index:l,group:d,disabled:u,modifiers:c,sensors:f,target:h,type:p,plugins:m}=e,b=wi(wi({},kd),e.transition),w=nd(g=>new ti(tm(wi({},e),{transition:b,register:!1,handle:xn(a),element:xn(o),target:xn(h)}),g)),v=Qu(w,rm);return Se(s,()=>w.id=s),Fn(()=>{Te(()=>{w.group=d,w.index=l})},[w,d,l]),Se(p,()=>w.type=p),Se(t,()=>w.accept=t,void 0,it),Se(i,()=>i&&(w.data=i)),Se(l,()=>{var g;(g=w.manager)!=null&&g.dragOperation.status.idle&&b?.idle&&w.refreshShape()},Jp),vs(a,g=>w.handle=g),vs(o,g=>w.element=g),vs(h,g=>w.target=g),Se(u,()=>w.disabled=u??!1,void 0,it),Se(f,()=>w.sensors=f,void 0,it),Se(n,()=>w.collisionDetector=n),Se(r,()=>w.collisionPriority=r),Se(m,()=>w.plugins=m,void 0,it),Se(b,()=>w.transition=b,void 0,it),Se(c,()=>w.modifiers=c,void 0,it),Se(e.alignment,()=>w.alignment=e.alignment),{sortable:v,get isDragging(){return v.isDragging},get isDropping(){return v.isDropping},get isDragSource(){return v.isDragSource},get isDropTarget(){return v.isDropTarget},handleRef:k.useCallback(g=>{w.handle=g??void 0},[w]),ref:k.useCallback(g=>{var y,_;!g&&((y=w.element)!=null&&y.isConnected)&&!((_=w.manager)!=null&&_.dragOperation.status.idle)||(w.element=g??void 0)},[w]),sourceRef:k.useCallback(g=>{var y,_;!g&&((y=w.source)!=null&&y.isConnected)&&!((_=w.manager)!=null&&_.dragOperation.status.idle)||(w.source=g??void 0)},[w]),targetRef:k.useCallback(g=>{var y,_;!g&&((y=w.target)!=null&&y.isConnected)&&!((_=w.manager)!=null&&_.dragOperation.status.idle)||(w.target=g??void 0)},[w])}}function rm(e,t,n){return!!(e==="isDragSource"&&!n&&t)}const vo="tile",Od="gap",sm=[co.configure({activatorElements:e=>[e.element],preventActivation:(e,t)=>e.target instanceof Element&&e.target.closest(`[${Ed}]`)!==null||(co.defaults.preventActivation?.(e,t)??!1)}),qu],Ed="data-no-drag",im=e=>[...e,ua.configure({feedback:"clone"})];function om({id:e,index:t,children:n}){const{ref:r,handleRef:s,isDragSource:i}=nm({id:e,index:t,type:vo,accept:vo,collisionDetector:sa,plugins:im});return x.jsx(x.Fragment,{children:n({ref:r,handleRef:s,isDragSource:i})})}function am({id:e,after:t,children:n}){const{ref:r,isDropTarget:s}=Sg({id:e,type:Od,accept:vo,collisionDetector:sa,data:{after:t}});return x.jsx(x.Fragment,{children:n({ref:r,isDropTarget:s})})}const Cd=["bar_chart","line_chart","scatter_chart","shape_map","segment_map","big_value","sparkline"],Id=["line_chart","bar_chart","big_value","scatter_chart","shape_map","segment_map"],ni=e=>Id.includes(e),yo=new Set([...Cd,"viz"]);function Dt(e){const t=e.trim();if(!/^#[ \t]/.test(t)||/[{=]/.test(t))return;const n=t.slice(1).trim().split(/[ \t]+/),r=[];let s;for(const i of n)if(i.startsWith("-")){if(s!==void 0)return;const o=i.slice(1);if(!yo.has(o))return;r.push(o)}else{if(s!==void 0||!yo.has(i))return;s=i}return{negated:r,...s!==void 0&&{pick:s}}}function Tr(e){const t=e.trim();return!/^#[ \t]/.test(t)||Dt(t)?!1:(t.replace(/"(?:[^"\\]|\\.)*"/g,'""').match(/[A-Za-z_]+/g)??[]).some(r=>yo.has(r))}function wn(e,t){return["#",...Id.filter(r=>r!==e&&(t===void 0||t.includes(r))).map(r=>`-${r}`),"-viz",...e==="none"?[]:[e]].join(" ")}function lm(e){return e.pick!==void 0?ni(e.pick)?e.pick:"custom":e.negated.includes("viz")?"none":"custom"}function cm(e){if(e.length===0)return"default";if(e.length>1)return"custom";const t=Dt(e[0]);return t?lm(t):"custom"}function um(e){const t=e.filter(n=>Dt(n));return e.some(Tr)?"custom":t.length===0?void 0:cm(t)}const dm=e=>e.filter(t=>Dt(t)||Tr(t)),Dd=e=>e.ok===!1,Ae=(e,...t)=>t.every(n=>typeof e?.[n]=="function"),en=e=>e!==void 0&&e.ruleIndex!==void 0&&(e.childCount??0)>0,ke={sourceDefinition:e=>Ae(e,"sourceNameDef","isDefine","sqExplore"),exploreQueryDef:e=>Ae(e,"exploreQueryNameDef","isDefine","vExpr"),defExploreQuery:e=>Ae(e,"VIEW","subQueryDefList"),defDimension:e=>Ae(e,"defList","DIMENSION"),exploreProperties:e=>Ae(e,"exploreStatement","OCURLY","CCURLY"),queryProperties:e=>Ae(e,"queryStatement","OCURLY","CCURLY"),queryStatement:e=>Ae(e,"whereStatement","aggregateStatement","nestStatement"),whereStatement:e=>Ae(e,"WHERE","filterClauseList"),givenDef:e=>Ae(e,"givenNameDef"),givenStatement:e=>Ae(e,"GIVEN","givenDefList"),importStatement:e=>Ae(e,"IMPORT","importURL"),vArrow:e=>Ae(e,"ARROW","vExpr","segExpr"),segRefine:e=>Ae(e,"PLUS","segExpr"),segOps:e=>Ae(e,"queryProperties"),segField:e=>Ae(e,"fieldPath")&&!Ae(e,"segExpr"),segParen:e=>Ae(e,"OPAREN","CPAREN","vExpr"),compare:e=>Ae(e,"fieldExpr","compareOp"),givenRef:e=>Ae(e,"GIVEN_REF")};function fm(e){const t=new Int32Array([...e].length+1);let n=0;for(let r=0;r<e.length;)t[n++]=r,r+=e.codePointAt(r)>65535?2:1;return t[n]=e.length,t}function hm(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
|
|
68
|
+
`&&t.push(n+1);return t}function Ad(e,t){const n=[];for(let r=0;r<(t.childCount??0);r++){const s=t.getChild(r);if(!en(s))continue;const i=Ce(s,"docAnnotations");if(i)for(const o of Pt(i,"docAnnotation")){const a=e.text_(o);a!==void 0&&n.push(a.replace(/\r?\n\|##[^\n]*\n?$/,""))}}return n}class ri{constructor(t){this.text=t,this.map=fm(t),this.lineStarts=hm(t)}map;lineStarts;commentLines=new Set;proseLines=new Set;blocks=[];span(t){if(!en(t))return;const n=t.start,r=t.stop;if(!n||!r)return;const s=this.map[n.startIndex],i=this.map[r.stopIndex+1];if(!(s===void 0||i===void 0||i<s))return{start:s,end:i}}terminal(t){const n=t?.symbol;if(!n)return;const r=this.map[n.startIndex],s=this.map[n.stopIndex+1];if(!(r===void 0||s===void 0||s<r))return{start:r,end:s}}utf16(t){return this.map[t]}text_(t){const n=this.span(t);return n&&this.text.slice(n.start,n.end)}line(t){let n=0,r=this.lineStarts.length-1;for(;n<r;){const s=n+r+1>>1;this.lineStarts[s]<=t?n=s:r=s-1}return n}positioned(t){const n=this.span(t);return n&&{span:n,line:this.line(n.start)}}indentAt(t){const n=this.lineStarts[this.line(t)];return/^[ \t]*/.exec(this.text.slice(n))?.[0]??""}}function zr(e,t,n=[]){en(e)&&t(e)&&n.push(e);for(let r=0;r<(e.childCount??0);r++)zr(e.getChild(r),t,n);return n}const pm=e=>Ae(e,"OCURLY","CCURLY");function Or(e,t){const n=[],r=s=>{if(en(s)){if(t(s)){n.push(s);return}if(!pm(s))for(let i=0;i<(s.childCount??0);i++)r(s.getChild(i))}};for(let s=0;s<(e.childCount??0);s++)r(e.getChild(s));return n}const Ce=(e,t)=>e[t]?.call(e),Pt=(e,t)=>e[t]?.call(e)??[];function gm(e,t){if(!ke.compare(t)||(t.childCount??0)!==3)return;const n=t.getChild(2);if(!ke.givenRef(n))return;const r=e.text_(t.getChild(0)),s=e.text_(t.getChild(1)),i=e.text_(n)??"";if(!(r===void 0||s===void 0))return{field:r,op:s.trim(),given:i.replace(/^\$/,"")}}function Md(e,t){const n=e.positioned(t);if(!n)return;const r=Ce(t,"filterClauseList"),s=[];for(const i of r?Pt(r,"fieldExpr"):[]){const o=e.positioned(i);if(!o)continue;const a=zr(i,ke.givenRef).map(l=>e.text_(l)).filter(l=>l!==void 0).map(l=>l.replace(/^\$/,""));s.push({...o,givens:a,binding:gm(e,i)})}return{...n,clauses:s}}function bo(e,t){const n=e.span(t);if(!n)return;const r=[],s=[];for(const d of Or(t,ke.queryStatement)){const u=e.positioned(d);u&&r.push(u);const c=Ce(d,"whereStatement");if(c&&ke.whereStatement(c)){const f=Md(e,c);f&&s.push(f)}}const i=n.start+1,o=n.end-1,a=!e.text.slice(n.start,n.end).includes(`
|
|
69
|
+
`),l=r.length?e.indentAt(r[0].span.start):e.indentAt(n.start)+" ";return{span:n,openEnd:i,closeStart:o,statements:r,wheres:s,indent:l,oneLine:a}}function _a(e,t,n){const r=[],s=e.line(t.start),i=e.line(n);for(let o=s;o<i;o++){if(e.commentLines.has(o)||e.proseLines.has(o))continue;const a=e.text.slice(e.lineStarts[o],e.lineStarts[o+1]??e.text.length).trim();a.startsWith("#")&&!a.startsWith("##")&&r.push({line:o,text:a})}return r}function mm(e,t){const n=Ce(t,"segExpr");if(!n)return{kind:"unsupported",why:"an unreadable expression"};const r=ke.vArrow(t);if(ke.segOps(n)){const s=Ce(n,"queryProperties"),i=s&&bo(e,s);return i?{kind:"inline",stage:i,...r?{pipeline:!0}:{}}:{kind:"unsupported",why:"an unreadable body"}}if(r)return{kind:"unsupported",why:"a `->` pipeline from a named view"};if(ke.segField(n)){const s=e.span(n);return s?{kind:"reference",from:e.text.slice(s.start,s.end),fromSpan:s}:{kind:"unsupported",why:"an unreadable name"}}if(ke.segRefine(n)){const s=Pt(n,"segExpr"),i=s[0],o=s[s.length-1];let a=i;for(;ke.segRefine(a);){const f=Pt(a,"segExpr");if(f.some(h=>ke.segOps(h)||ke.segParen(h)))return{kind:"unsupported",why:"a chained refinement"};a=f[0]}if(a&&ke.segParen(a))return{kind:"unsupported",why:"a parenthesized expression"};if(!a||!ke.segField(a))return{kind:"unsupported",why:"a `{ … } + { … }` compound refinement"};const l=e.span(i);if(!l||!o)return{kind:"unsupported",why:"an unreadable refinement"};if(!ke.segOps(o)){const f=e.span(n);return f?{kind:"reference",from:e.text.slice(f.start,f.end),fromSpan:f}:{kind:"unsupported",why:"an unreadable refinement"}}const d=e.text.slice(l.start,l.end),u=Ce(o,"queryProperties"),c=u&&bo(e,u);return c?{kind:"reference",from:d,fromSpan:l,refinement:c}:{kind:"reference",from:d,fromSpan:l}}return{kind:"unsupported",why:"a parenthesized expression"}}function vm(e,t){const n=[];for(const r of Or(t,ke.defExploreQuery)){const s=e.span(r),i=Ce(r,"subQueryDefList");if(!s||!i)continue;const o=Pt(i,"exploreQueryDef").filter(ke.exploreQueryDef),a=e.terminal(Ce(r,"VIEW"));for(const l of o){const d=e.span(l),u=Ce(l,"exploreQueryNameDef"),c=e.text_(u),f=Ce(l,"vExpr");!d||!c||!f||n.push({name:c,span:d,line:e.line(d.start),statement:s,tags:_a(e,s,a?.start??d.start),siblings:o.length,body:mm(e,f)})}}return n}function ym(e,t){const n=[];for(const r of Or(t,ke.defDimension)){const s=e.span(r),i=Ce(r,"defList");if(!s||!i)continue;const o=e.terminal(Ce(r,"DIMENSION"));for(const a of Pt(i,"fieldDef")){const l=e.span(a),d=e.text_(Ce(a,"fieldNameDef"))?.trim(),u=e.text_(Ce(a,"fieldExpr"))?.trim();!l||!d||u===void 0||n.push({name:d,expression:u,span:l,line:e.line(l.start),statement:s,tags:_a(e,s,o?.start??l.start)})}}return n}function bm(e,t){const n=[];for(const r of zr(t,ke.sourceDefinition)){const s=e.span(r),i=e.text_(Ce(r,"sourceNameDef")),o=Ce(r,"sqExplore");if(!s||!i||!o)continue;const a=e.span(o),l=a?e.text.slice(a.start,a.end):"",d=(/^\s*(`[^`]*`|[A-Za-z_][A-Za-z0-9_.]*)/.exec(l)?.[1]??"").trim(),u=Or(o,ke.exploreProperties)[0],c=u&&bo(e,u),f={start:e.lineStarts[e.line(s.start)],end:s.end},h=[];if(u)for(const p of Or(u,ke.whereStatement)){const m=Md(e,p);m&&h.push(m)}n.push({name:i,base:d,span:s,line:e.line(s.start),statement:f,...c?{properties:c}:{},views:u?vm(e,u):[],dimensions:u?ym(e,u):[],wheres:h})}return n}function xm(e,t){const n=[];for(const r of zr(t,ke.givenStatement)){const s=e.terminal(Ce(r,"GIVEN")),i=Ce(r,"givenDefList"),o=s?e.line(s.start):void 0;for(const a of i?Pt(i,"givenDef"):[]){const l=e.span(a),d=e.span(Ce(a,"givenNameDef")),u=d&&e.text.slice(d.start,d.end);if(!l||!d||!u)continue;const c={start:d.start,end:l.end},f=e.line(c.start);n.push({name:u,declaration:e.text.slice(c.start,c.end),span:c,line:f,statement:{start:e.lineStarts[f],end:c.end},tags:_a(e,l,c.start),...o!==void 0&&o!==f?{blockHeader:o}:{}})}}return n}function wm(e,t){const n=[];for(const r of zr(t,ke.importStatement)){const s=e.span(r),i=e.text_(Ce(r,"importURL"));if(!s||i===void 0)continue;const o=Ce(r,"importSelect"),a=o?Pt(o,"importItem").map(l=>e.text_(l)).filter(l=>l!==void 0).map(l=>l.trim()):void 0;n.push({from:i.replace(/^['"]|['"]$/g,""),...a&&a.length>0?{names:a}:{},span:s,line:e.line(s.start),statement:s})}return n}async function Pd(e){let t;try{t=await Wr(e,"file://dashboard-builder.malloy")}catch(f){return{ok:!1,reason:`Malloy could not read this file: ${f}`}}const n=t.problems.filter(f=>f.code==="syntax-error");if(n.length>0)return{ok:!1,reason:`This file has a Malloy syntax error, so it cannot be edited here: ${n[0].message??"unknown"}`};const r=t.parse,s=r?.root;if(!s||!en(s)||typeof s.getChild!="function")return{ok:!1,reason:`This build of Malloy does not expose a parse tree the builder can read (malloy ${r?.malloyVersion??"unknown"}), so editing is off.`};const i=r?.tokenStream??{},o=typeof i.getTokens=="function"?i.getTokens():void 0;if(!o||typeof i.tokenSource?.vocabulary?.getSymbolicName!="function"||o.length===0&&e.trim()!=="")return{ok:!1,reason:`This build of Malloy does not expose a token stream the builder can read (malloy ${r?.malloyVersion??"unknown"}), so it cannot tell a comment from code and editing is off.`};const a=new ri(e),l=ka(a,i);a.commentLines=l.lines;const d=e.split(`
|
|
70
|
+
`),u=f=>l.lines.has(f);a.proseLines=ge.markdownLines(d,u),a.blocks=ge.blockSpans(d,u).filter(([f])=>!d[f].trimStart().startsWith("##"));const c=bm(a,s);return c.length===0&&/^\s*source:/m.test(e)?{ok:!1,reason:`The builder could not locate this file's sources in Malloy's parse tree (malloy ${r?.malloyVersion??"unknown"}), so editing is off.`}:{ok:!0,parsed:{text:e,lineStarts:a.lineStarts,imports:wm(a,s),sources:c,givens:xm(a,s),textBlocks:km(a,i),modelNotes:Ad(a,s),trailingComment:f=>l.trailing.get(f),comments:l.all,commentLine:f=>l.lines.has(f),proseLine:f=>a.proseLines.has(f),commentIn:f=>l.all.find(h=>h.start>=f.start&&h.start<f.end),blockStart:f=>_m(a,l.lines,f)}}}async function Wr(e,t){const{MalloyTranslator:n}=await O.loadMalloy(),r=new n(t,null,{urls:{[t]:e}});return{problems:r.translate().problems??[],parse:r.parseStep?.response?.parse}}function ka(e,t){const n=new Map,r=new Set,s=[],i=t.tokenSource?.vocabulary;for(const u of t.getTokens?.()??[]){const c=i?.getSymbolicName(u.type);if(c!=="COMMENT_TO_EOL"&&c!=="BLOCK_COMMENT")continue;const f=e.utf16(u.startIndex);let h=e.utf16(u.stopIndex+1);if(!(f===void 0||h===void 0||h<f)){for(;h>f&&(e.text[h-1]===`
|
|
71
|
+
`||e.text[h-1]==="\r");)h--;s.push({start:f,end:h})}}const o=[...s].sort((u,c)=>u.start-c.start);let a="",l=0;for(const u of o)a+=e.text.slice(l,Math.max(l,u.start)),a+=e.text.slice(Math.max(l,u.start),Math.max(l,u.end)).replace(/[^\n\r]/g," "),l=Math.max(l,u.end);a+=e.text.slice(l);const d=u=>a.slice(e.lineStarts[u],e.lineStarts[u+1]??a.length);for(const u of s){const c=e.line(u.start),f=e.line(u.end-1);for(let m=c;m<=f;m++)d(m).trim()===""&&r.add(m);const h=a.slice(e.lineStarts[c],u.start).trim(),p=a.slice(u.end,e.lineStarts[f+1]??a.length).trim();h!==""&&p===""&&n.set(f,u)}return{trailing:n,lines:r,all:s}}function _m(e,t,n){const r=i=>e.text.slice(e.lineStarts[i],e.lineStarts[i+1]??e.text.length).trim();let s=n;for(let i=n-1;i>=0;i--){const o=r(i),a=e.blocks.find(([,l])=>l===i);if(a){s=i=a[0];continue}if(o===""&&!t.has(i))break;if(o.startsWith("#")||t.has(i))s=i;else break}return s}function km(e,t){const n=t.getTokens?.()??[],r=t.tokenSource?.vocabulary,s=a=>r?.getSymbolicName(a.type),i=a=>e.text.slice(e.utf16(a.startIndex)??0,e.utf16(a.stopIndex+1)??e.text.length),o=[];for(let a=0;a<n.length;a++){if(s(n[a])!=="DOC_BLOCK_ANNOTATION_BEGIN")continue;const l=ge.textBlockOpener(i(n[a]).replace(/\r?\n$/,""));if(!l)continue;const d=[];let u=a+1;for(;s(n[u]??n[a])==="BLOCK_ANNOTATION_TEXT";u++)d.push(i(n[u]));const c=n[u];if(!c||s(c)!=="BLOCK_ANNOTATION_END")continue;const f=e.line(e.utf16(n[a].startIndex)??0),h=e.utf16(c.stopIndex+1)??e.text.length,p=l.name===void 0&&l.rest?[`${l.rest}
|
|
72
|
+
`]:[];o.push({...l.name===void 0?{}:{name:l.name},route:l.route,body:[...p,...d].join("").replace(/\r\n?/g,`
|
|
73
|
+
`).replace(/\n$/,""),span:{start:e.lineStarts[f],end:h},line:f}),a=u}return o}function Rd(e,t){for(let n=t+1;n<e.length;n++)if(e[n]==="\\")n++;else if(e[n]==='"')return n;return e.length}function Sa(e){let t=0,n=0;for(let r=0;r<e.length;r++){const s=e[r];if(s==='"')r=Rd(e,r);else if(s==="{"||s==="[")t++===0&&n++;else if(s==="}"||s==="]")t--;else if(n===1&&t===1&&e.startsWith("tiles",r)&&!/[A-Za-z0-9_]/.test(e[r-1]??" ")){const i=/^tiles\s*=\s*\[/.exec(e.slice(r));if(i)return Sm(e,r+i[0].length-1)}}}function Sm(e,t){const n=[];let r=0,s=t+1;const i=o=>{const a=e.slice(s,o),l=a.length-a.trimStart().length,d=a.trim();d!==""&&n.push({text:d,span:{start:s+l,end:s+l+d.length}})};for(let o=t+1;o<e.length;o++){const a=e[o];if(a==='"')o=Rd(e,o);else if(a==="{"||a==="[")r++;else if(a==="}")r--;else if(a==="]"){if(r===0)return i(o),{open:t,close:o,entries:n};r--}else a===","&&r===0&&(i(o),s=o+1)}}function $m(e,t){const n=e[t];if(n==="`"){for(let r=t+1;r<e.length;r++)if(e[r]==="\\")r++;else{if(e[r]==="`")return r+1;if(e[r]===`
|
|
74
74
|
`)return e.length}return e.length}if(e.startsWith("<<<",t)){let r=t+3;for(;;){const s=e.indexOf(`
|
|
75
75
|
`,r),i=s===-1?e.length:s;if(e.slice(r,i).trim()===">>>")return i;if(s===-1)return e.length;r=s+1}}if(n==='"'||n==="'"){const r=n.repeat(3);if(e.startsWith(r,t)){for(let s=t+3;s<e.length;s++)if(e[s]==="\\")s++;else if(e.startsWith(r,s))return s+3;return e.length}for(let s=t+1;s<e.length;s++)if(e[s]==="\\")s++;else{if(e[s]===n)return s+1;if(e[s]===`
|
|
76
|
-
`)return s}return e.length}return t}function
|
|
77
|
-
`&&t.push(n+1);return t}function
|
|
78
|
-
`})}function
|
|
76
|
+
`)return s}return e.length}return t}function Tm(e){const t=/^([ \t]*)f(['"])((?:\\.|(?!\2)[^\\])*)\2/;let n="",r=0;for(;r<e.length;){const s=$m(e,r);if(s>r){n+=e.slice(r,s),r=s;continue}const i=e[r];if(/[=[,]/.test(i)){const o=t.exec(e.slice(r+1));if(o){const a=o[3].replace(/\\/g,"\\\\").replace(/"/g,'\\"');n+=`${i}${o[1]}"f'${a}'"`,r+=1+o[0].length;continue}}n+=i,r+=1}return n}function $a(e,t){const n=e(t);if(n.log.length===0)return{tag:n.tag,errors:[]};const r=t.map(i=>{if(e([i]).log.length===0)return i;const o=Tm(i);return e([o]).log.length===0?o:i}),s=e(r);return{tag:s.tag,errors:s.log.map(i=>i.message)}}const yl=(e,t)=>{try{return e.text(t)}catch{return}},Om=e=>/^##\|?(?:[ \t\r\n]|$)/.test(e),Em=e=>`\`kind=${e}\` is no longer read, so this file is not a report. Fix: remove \`kind=${e}\` and write \`layout=grid\` or \`layout=linear\`.`;function jd(e,t){const n=e.filter(Om).filter(l=>!l.includes("@env.")).map(ge.tagAnnotation),{tag:r,errors:s}=n.length>0?$a(t,n):{tag:void 0,errors:[]},i=r?.tag("artifact");if(!i)return e.some(ge.setsArtifactProperty)?{status:"unparsed",errors:s}:{status:"none"};const o=yl(i,"kind");if(o!==void 0)return{status:"kind-removed",kind:o};const a=yl(i,"layout");return a==="grid"||a==="linear"?{status:"report",layout:a}:i.has("tiles")||r?.tag("dashboard")!==void 0?{status:"report",layout:"grid"}:{status:"report",layout:"linear"}}async function Cm(e){const{parseAnnotation:t}=await O.loadMalloyTag();let n=[];try{const r=(await Wr(e,"file://report.malloy")).parse?.root;r&&en(r)&&typeof r.getChild=="function"&&(n=Ad(new ri(e),r))}catch{n=[]}return jd(n,t)}const Er=e=>e.ok===!1;function Br(e,t,n){const r=e.blockStart(n),s=[],i=[];for(let o=r;o<n;o++){if(e.commentLine(o))continue;if(e.proseLine(o)){i.push(o);continue}const a=t[o].trim();a.startsWith("#")&&!a.startsWith("##")&&s.push({line:o,text:a})}return{start:r,tags:s,prose:i}}const Fs=e=>e.map(t=>t.text);function bl(e){const t=Fs(e),n=um(t);return n===void 0?{}:n==="custom"?{chart:n,chartLines:dm(t)}:{chart:n}}function Im(e){if(!e)return;const t=[];for(const n of e.wheres)for(const r of n.clauses){if(!r.binding)continue;const{field:s,op:i,given:o}=r.binding;t.push({field:ge.readPath(s),given:o,...i==="~"?{}:{op:i}})}return t.length>0?t:void 0}function Dm(e,t,n){const r=[];for(const s of e.givens){const i=/^([A-Za-z_][A-Za-z0-9_]*)\s*::\s*(\S+)\s+is\s+([\s\S]+)$/.exec(s.declaration);i&&r.push({name:i[1],type:i[2],default:i[3].trim(),...Am(n(Fs(Br(e,t,s.line).tags)).tag)})}return r.length>0?r:void 0}function Am(e){if(!e)return{};const t=e.tag("suggest"),n=t?.text("dimension"),r=e.numeric("range_min"),s=e.numeric("range_max");return{...e.text("label")===void 0?{}:{label:e.text("label")},...e.text("description")===void 0?{}:{description:e.text("description")},...e.text("control")===void 0?{}:{control:e.text("control")},...t&&n?{suggest:{...t.text("source")===void 0?{}:{source:t.text("source")},...t.text("query")===void 0?{}:{query:t.text("query")},dimension:n}}:{},...r===void 0?{}:{rangeMin:r},...s===void 0?{}:{rangeMax:s}}}function _i(e,t){const n=e?.text(t)?.trim();if(n===void 0||!/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/.test(n))return;const r=Number(n);return Number.isInteger(r)&&r>=1?r:void 0}const Mm=/^"((?:[^"\\]|\\.)+)"$/,Pm=/^([A-Za-z_][A-Za-z0-9_]*)\s*\{/;async function Cr(e,t,n=!1){try{return await Rm(e)}catch(r){return{ok:!1,reason:`A value in this file's tags cannot be read (${r instanceof Error?r.message:String(r)}), so it cannot be opened in the builder.`}}}async function Rm(e){const{parseAnnotation:t}=await O.loadMalloyTag(),n=ge.splitSourceLines(e),r=await Pd(e);if(Dd(r))return{ok:!1,reason:r.reason,...r.line?{line:r.line}:{}};const s=r.parsed,i=ge.descriptionNotes(n).text,o=jd(s.modelNotes,t);if(o.status==="none")return{ok:!1,reason:"No `## artifact { … }` tag, so this file is not a report."};if(o.status==="unparsed")return{ok:!1,reason:`The \`## artifact\` tag does not parse${o.errors[0]?`: ${o.errors[0]}`:"."}`};if(o.status==="kind-removed")return{ok:!1,reason:Em(o.kind)};const a=o.layout,l=ge.artifactTag(n);if(l===void 0)return{ok:!1,reason:"No `## artifact { … }` tag, so this file is not a report."};if(!ge.artifactLeads(l.text))return{ok:!1,reason:ge.ARTIFACT_NOT_FIRST,line:l.from+1};const{tag:d,errors:u}=$a(t,[ge.tagAnnotation(l.text)]),c=d?.tag("artifact"),f=Sa(l.text);if(f===void 0)return u.length>0?{ok:!1,reason:`The \`## artifact\` tag does not parse: ${u[0]}`}:a==="linear"?{ok:!1,legacyNotebook:!0,reason:"This report is in the cell format, with no `tiles=[…]` list."}:{ok:!1,reason:"The `## artifact` tag has no `tiles=[…]` list the builder can read."};const h=s.imports.map(S=>S.names?{kind:"names",names:S.names,from:S.from}:{kind:"all",from:S.from}),p=[],m=[],b=new Map;for(const S of s.sources){const E={name:S.name,base:S.base};S.dimensions.length>0&&(E.dimensions=S.dimensions.map(T=>({name:T.name,expression:T.expression})));const A=new Set(S.wheres.flatMap(T=>T.clauses.flatMap(D=>D.givens)));A.size>0&&(E.scopedBy=Array.from(A)),p.push(E);for(const T of S.dimensions){const D=t(Fs(Br(s,n,T.line).tags)).tag?.tag("drill");if(!D)continue;const q=D.textArray("to")??[D.text("to")??""];m.push({source:S.name,name:T.name,expression:T.expression,to:q.filter(Boolean),...D.text("given")?{given:D.text("given")}:{}})}b.set(S.name,new Map(S.views.map(T=>[T.name,T])))}const w=[];for(const{text:S}of f.entries){const E=Mm.exec(S),A=E?void 0:Pm.exec(S)?.[1];if(A!==void 0){const J=t([`# ${S}`]).tag?.tag(A);if(J?.text("kind")!=="text")return{ok:!1,reason:`The tile \`${S}\` is neither a quoted \`source -> view\` expression nor a \`${A} { kind=text }\` entry, which are the only forms the builder can lay out.`};if(w.some(de=>Re(de)&&de.name===A))return{ok:!1,reason:`Two text tiles are named \`${A}\`, so the builder cannot tell them apart.`};const ie=_i(J,"colspan");w.push({kind:"text",name:A,markdown:s.textBlocks.find(de=>de.name===A)?.body??"",...ie===void 0?{}:{colspan:ie},...J.has("break")?{break:!0}:{}});continue}const T=E?.[1]??S,D=E?ge.tileSteps(T):void 0;if(!D)return{ok:!1,reason:`The tile \`${T}\` is not a \`source -> view\` expression, which is the only form the builder can lay out.`};const{source:q,view:P}=D,z=b.get(q)?.get(P);if(z===void 0){w.push({name:P,source:q,declaration:{kind:"inherited"}});continue}const U=t(Fs(z.tags)).tag,K=z.body.kind==="reference"?{kind:"reference",from:z.body.from}:z.body.kind==="inline"?{kind:"inline"}:void 0;if(K===void 0){w.push({name:P,source:q,declaration:{kind:"opaque",why:z.body.kind==="unsupported"?z.body.why:"unreadable"},...U?.text("label")?{label:U.text("label")}:{},...U?.text("subtitle")?{subtitle:U.text("subtitle")}:{},...U?.numeric("colspan")!==void 0?{colspan:U.numeric("colspan")}:{},...bl(z.tags),...U?.has("break")?{break:!0}:{},...U?.has("borderless")?{borderless:!0}:{}});continue}const Z=Im(z.body.kind==="reference"?z.body.refinement:z.body.kind==="inline"?z.body.stage:void 0);w.push({name:P,source:q,declaration:K,...Z?{filters:Z}:{},...U?.text("label")?{label:U.text("label")}:{},...U?.text("subtitle")?{subtitle:U.text("subtitle")}:{},...U?.numeric("colspan")!==void 0?{colspan:U.numeric("colspan")}:{},...bl(z.tags),...U?.has("break")?{break:!0}:{},...U?.has("borderless")?{borderless:!0}:{}})}const v=Dm(s,n,t),g={},y=c?.tag("givens");for(const S of Object.keys(y?.dict??{})){const E=y?.text(S);E!==void 0&&(g[S]=E)}const _=d?.tag("dashboard")?.has("columns")?_i(d.tag("dashboard"),"columns"):c?.array("tiles")?_i(c,"dashboard_columns"):void 0;return{ok:!0,document:{layout:a,title:c?.text("title")??"",...i?{description:i}:{},..._===void 0?{}:{columns:_},...c?.has("autorun")?{autorun:c.isTrue("autorun")}:{},imports:h,sources:p,...v?{localGivens:v}:{},...Object.keys(g).length>0?{startingGivens:g}:{},...m.length>0?{drills:m}:{},tiles:w}}}const zs=e=>e.ok===!1;async function xl(e){const{problems:t}=await Wr(e,"file://splice-check.malloy");return t.filter(n=>n.code==="syntax-error").map(n=>n.message??"").sort()}function _e(e){const t=n=>{if(Array.isArray(n))return n.map(t);if(n&&typeof n=="object"){const r={};for(const s of Object.keys(n).sort())r[s]=t(n[s]);return r}return n};return JSON.stringify(t(e))}function Ld(e){return e.replace(/^(?:[ \t]*\r?\n)+/,"").trimEnd()}function jm(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
|
|
77
|
+
`&&t.push(n+1);return t}function Lm(e,t){let n=e;const r=t.map((s,i)=>({edit:s,index:i}));for(const{edit:s}of r.sort((i,o)=>o.edit.start-i.edit.start||o.edit.end-i.edit.end||o.index-i.index))n=n.slice(0,s.start)+s.text+n.slice(s.end);return n}const Nd=e=>e==="none"||ni(e)?e:void 0;function Fd(e,t=!0){const n=[];e.colspan!==void 0&&n.push(`# colspan=${e.colspan}`),e.break&&n.push("# break"),e.borderless&&n.push("# borderless"),e.label!==void 0&&n.push(`# label=${at(e.label)}`),e.subtitle!==void 0&&n.push(`# subtitle=${at(e.subtitle)}`);const r=t?Nd(e.chart):void 0;return r!==void 0&&n.push(wn(r,e.chartCarried)),n}function bs(e){return/^#\s*([a-z_]+)/.exec(e)?.[1]}const Nm=new Set(["colspan","break","borderless","label","subtitle"]),Fm=new Set(["label","description","control","suggest","range_min","range_max"]);function wl(e){const t=[];if(e.label!==void 0&&t.push(`label=${at(e.label)}`),e.description!==void 0&&t.push(`description=${at(e.description)}`),e.control!==void 0&&t.push(`control=${e.control}`),e.suggest){const n=e.suggest.source!==void 0?`source=${e.suggest.source}`:e.suggest.query!==void 0?`query=${at(e.suggest.query)}`:void 0;t.push(`suggest { ${n?`${n} `:""}dimension=${at(e.suggest.dimension)} }`)}return e.rangeMin!==void 0&&t.push(`range_min=${e.rangeMin}`),e.rangeMax!==void 0&&t.push(`range_max=${e.rangeMax}`),t.length>0?`# ${t.join(" ")}`:void 0}const _l=e=>`given: ${e.name} :: ${e.type} is ${e.default}`;function zm(e,t,n){const r=e.sources.find(s=>s.name===t)?.views.find(s=>s.name===n);return r?r.line:-1}function kl(e){const t=r=>/^[A-Za-z_][A-Za-z0-9_]*$/.test(r)?r:at(r);return`# drill { to=${e.to.length===1?t(e.to[0]):`[${e.to.map(at).join(", ")}]`}${e.given?` given=${e.given}`:""} }`}const Ws=e=>`${e.source}.${e.name}`,at=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,xo=e=>Re(e)?_e(["text",e.name]):_e([e.name,e.source,e.declaration]),tt=xo,Sl=e=>_e(e.tiles.map(tt));function Wm(e,t,n){const r=new Set(e.tiles.map(tt)),s=new Set(t.tiles.map(tt)),i=e.tiles.filter(h=>!s.has(tt(h))),o=t.tiles.filter(h=>!r.has(tt(h))),l=i.length>0||o.length>0||Sl(e)!==Sl(t);for(const h of o)if(xe(h)&&h.declaration.kind!=="reference")return{ok:!1,reason:`A new tile names a view of a source; \`${h.name}\` is ${h.declaration.kind==="inline"?"an inline query":"not declared here"}, which the builder cannot write.`};const d=new Map(e.sources.map(h=>[h.name,h])),u=new Set(t.imports.flatMap(h=>h.kind==="names"?h.names:[]));for(const h of e.sources)u.add(h.base);const c=t.imports.some(h=>h.kind==="all"),f=t.sources.filter(h=>!d.has(h.name));for(const h of e.sources){const p=t.sources.find(m=>m.name===h.name);if(!p||p.base!==h.base)return{ok:!1,reason:`The source \`${h.name}\` cannot be changed or removed here.`}}for(const h of f){if(!o.some(p=>xe(p)&&p.source===h.name))return{ok:!1,reason:`A new source \`${h.name}\` needs a tile on it.`};if(!u.has(h.base)&&!c&&!n?.includes(h.base))return{ok:!1,reason:`\`${h.base}\` is not imported in this file, so a tile cannot be put on it.`}}return{currentKeys:r,nextKeys:s,removedTiles:i,addedTiles:o,newSources:f,currentSources:d,reordered:l}}const $l=(e,t)=>e.colspan!==t.colspan||!!e.break!=!!t.break;function Bm(e){let t="";for(let n=0;n<e.length;n++){if(e[n]!=='"'){t+=e[n];continue}const r=Ir(e,n);t+="x".repeat(Math.min(r,e.length-1)-n+1),n=r}return t}function Tl(e,t){if(t===void 0)return`${e.name} { kind=text${e.colspan===void 0?"":` colspan=${e.colspan}`}${e.break?" break":""} }`;const n=Bm(t),r=n.indexOf("{"),s=n.lastIndexOf("}");let i=t.slice(r+1,s),o=n.slice(r+1,s);const a=d=>{const u=d.exec(o);u&&(i=i.slice(0,u.index)+i.slice(u.index+u[0].length),o=o.slice(0,u.index)+o.slice(u.index+u[0].length))};a(/\s*\bcolspan\s*=\s*[^\s}]+/),a(/\s*\bbreak\b(?!\s*=)/);const l=[i.trim(),e.colspan===void 0?"":`colspan=${e.colspan}`,e.break?"break":""].filter(Boolean);return`${t.slice(0,r)}{ ${l.join(" ")} }${t.slice(s+1)}`}function Gm(e){const{lines:t,wholeLine:n,current:r,next:s,reordered:i,currentKeys:o,nextKeys:a,edits:l}=e,d=new Map(r.tiles.filter(Re).map(v=>[v.name,v])),u=s.tiles.filter(Re).some(v=>{const g=d.get(v.name);return g!==void 0&&$l(g,v)});if(!i&&!u)return;const c=ge.artifactTag(t);if(!c)return{ok:!1,reason:"Could not find the `## artifact` tag to reorder."};const f=c.text,h=Sa(f);if(!h)return{ok:!1,reason:"Could not read the `tiles=[…]` list to rewrite it."};if(a.size===0&&o.size>0)return{ok:!1,reason:"A grid report with no tiles is not served, so the last tile cannot be removed. Add another tile first."};const p=new Map;for(const{text:v}of h.entries){const g=/^"((?:[^"\\]|\\.)+)"$/.exec(v);if(g){const _=g[1].split("->").map(S=>S.trim());_.length===2&&p.set(`${_[0]}->${_[1]}`,v);continue}const y=/^([A-Za-z_][A-Za-z0-9_]*)\s*\{/.exec(v)?.[1];y!==void 0&&p.set(`text.${y}`,v)}const m=s.tiles.map(v=>{const g=!o.has(tt(v));if(Re(v)){const y=p.get(`text.${v.name}`);return y!==void 0?d.has(v.name)&&!$l(d.get(v.name),v)?y:Tl(v,y):g?Tl(v):void 0}return p.get(`${v.source}->${v.name}`)??(g?`"${v.source} -> ${v.name}"`:void 0)});if(m.some(v=>v===void 0))return{ok:!1,reason:"A tile in the new order is not one the `## artifact` tag names."};const b=f.slice(0,h.open).search(/tiles\s*=\s*$/),w=`${f.slice(0,b)}tiles=[${qm(f,h,m)}]${f.slice(h.close+1)}`;w!==f&&l.push({...zd(n,c),text:`${w}
|
|
78
|
+
`})}function zd(e,t){return{start:e(t.from).start,end:e(t.block?t.to-1:t.from).end}}function qm(e,t,n){const r=t.entries[0],s=t.entries[t.entries.length-1];if(!r||!/\n/.test(e.slice(t.open,t.close)))return n.join(", ");const i=e.slice(t.open+1,r.span.start),o=e.slice(s.span.end,t.close),a=i.slice(i.lastIndexOf(`
|
|
79
79
|
`)),l=t.entries.length>1?e.slice(r.span.end,t.entries[1].span.start):`,${a.startsWith(`
|
|
80
|
-
`)?a:" "}`;return`${i}${n.join(l)}${o}`}function
|
|
81
|
-
${/\n([ \t]+)\S/.exec(
|
|
82
|
-
`:`${
|
|
83
|
-
${
|
|
84
|
-
)`);
|
|
85
|
-
`:i.push({...a,text:`${
|
|
86
|
-
`})}if(r.description!==s.description){const{read:o,blankAbove:a,below:l,belowBlock:
|
|
80
|
+
`)?a:" "}`;return`${i}${n.join(l)}${o}`}function Km(e,t){let n=0,r=0;for(let s=0;s<e.length;s++){const i=e[s];if(i==='"')s=Ir(e,s);else if(i==="{"||i==="[")n++===0&&r++;else if(i==="}"||i==="]")n--;else if(r===1&&n===1&&e.startsWith(t,s)&&!/[A-Za-z0-9_]/.test(e[s-1]??" ")){const o=/^\s*=\s*/.exec(e.slice(s+t.length));if(!o)continue;const a=s+t.length+o[0].length,l=e[a]==='"'?Ir(e,a)+1:a+(/^[^\s}]*/.exec(e.slice(a))?.[0].length??0),d=s-(/\s*$/.exec(e.slice(0,s))?.[0].length??0);return e.slice(0,d)+e.slice(l)}}return e}function Vm(e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];if(r==='"')n=Ir(e,n);else if(r==="{"||r==="[")t++;else if(r==="}"||r==="]")t--;else if(t===0&&e.startsWith("dashboard",n)&&!/[A-Za-z0-9_]/.test(e[n-1]??" ")){const s=/^dashboard\s*\{/.exec(e.slice(n));if(!s)continue;let i=1,o=n+s[0].length;for(;o<e.length&&i>0;o++)e[o]==='"'?o=Ir(e,o):e[o]==="{"?i++:e[o]==="}"&&i--;const a=n-(/\s*$/.exec(e.slice(0,n))?.[0].length??0);return e.slice(0,a)+e.slice(o)}}return e}function Ir(e,t){for(let n=t+1;n<e.length;n++)if(e[n]==="\\")n++;else if(e[n]==='"')return n;return e.length}function Um(e){const{lines:t,wholeLine:n,current:r,next:s,edits:i}=e;if(r.layout!==s.layout||r.title!==s.title||r.autorun!==s.autorun||r.columns!==s.columns||_e(r.startingGivens)!==_e(s.startingGivens)){const o=ge.artifactTag(t);if(!o)return{ok:!1,reason:"Could not find the `## artifact` tag to change the page's settings."};const a=zd(n,o),l=i.find(g=>g.start===a.start&&g.end===a.end);let d=l?l.text.replace(/\n$/,""):o.text;const u=r.layout!==s.layout,c=d.indexOf("artifact"),f=d.indexOf("{",c);let h=0,p=-1;for(let g=f;g<d.length;g++)if(d[g]==="{")h++;else if(d[g]==="}"&&--h===0){p=g;break}if(f<0||p<0)return{ok:!1,reason:"Could not read the `## artifact { … }` tag."};let m=d.slice(f+1,p);const b=o.block?`
|
|
81
|
+
${/\n([ \t]+)\S/.exec(m)?.[1]??" "}`:" ",w=g=>o.block?`${m.trimEnd()}${b}${g}
|
|
82
|
+
`:`${m.trimEnd()} ${g} `,v=(g,y)=>{const _=new RegExp(`${o.block?"[ \\t]*":"\\s*"}\\b${g}=(?:"(?:[^"\\\\]|\\\\.)*"|[^\\s}]+)`);if(y===void 0){const S=new RegExp(`
|
|
83
|
+
${_.source}[ \\t]*(?=
|
|
84
|
+
)`);m=m.replace(o.block&&S.test(m)?S:_,"")}else _.test(m)?m=m.replace(_,S=>`${o.block?S.slice(0,S.length-S.trimStart().length):" "}${g}=${y}`):m=w(`${g}=${y}`)};if(u&&v("layout",s.layout),r.title!==s.title&&v("title",s.title?at(s.title):void 0),r.autorun!==s.autorun&&v("autorun",s.autorun===void 0?void 0:String(s.autorun)),_e(r.startingGivens)!==_e(s.startingGivens)){m=m.replace(/\s*\bgivens\s*\{[^}]*\}/,"");const g=Object.entries(s.startingGivens??{});g.length>0&&(m=w(`givens { ${g.map(([y,_])=>`${y}=${at(_)}`).join(" ")} }`))}o.block?d=`${d.slice(0,f+1)}${m}${d.slice(p)}`:(m=m.replace(/\s{2,}/g," "),d=`${d.slice(0,f+1)}${m.startsWith(" ")?m:` ${m}`}${m.endsWith(" ")?"":" "}${d.slice(p)}`),r.columns!==s.columns&&(d=Km(d,"dashboard_columns"),d=Vm(d),s.columns!==void 0&&(d=`${d.trimEnd()} dashboard { columns=${s.columns} }`)),l?l.text=`${d}
|
|
85
|
+
`:i.push({...a,text:`${d}
|
|
86
|
+
`})}if(r.description!==s.description){const{read:o,blankAbove:a,below:l,belowBlock:d,inBlock:u}=ge.descriptionNotes(t);if(u||s.description===void 0&&d)return{ok:!1,reason:"The description is written in a `##|\"` block, which the builder cannot edit in place. Change it in the file's text."};const c=Ld(s.description??"").split(`
|
|
87
87
|
`).map(m=>m.trim()===""?'##"':`##" ${m.trim()}`).join(`
|
|
88
|
-
`),f=o.length>0&&o[0]<
|
|
89
|
-
`});else if(s.description!==void 0){const m=n(
|
|
90
|
-
`})}}}function Hm(e){const{lines:t,wholeLine:n,indentOf:r,current:s,next:i,edits:o,parsed:a}=e,l=new Map((s.localGivens??[]).map(
|
|
91
|
-
`).trim();o.push({start:n(
|
|
92
|
-
`:"")+`${
|
|
93
|
-
`})}for(const[p
|
|
94
|
-
`:"")+`${
|
|
88
|
+
`),f=o.length>0&&o[0]<ge.artifactLine(t),h=s.description===void 0,p=f?[...o.slice(1),...h?l:[]]:[...o,...a];for(const m of p)i.push({...n(m),text:""});if(f)i.push({...n(o[0]),text:s.description===void 0?"":`${c}
|
|
89
|
+
`});else if(s.description!==void 0){const m=n(ge.artifactLine(t)).start;i.push({start:m,end:m,text:`${c}
|
|
90
|
+
`})}}}function Hm(e){const{lines:t,wholeLine:n,indentOf:r,current:s,next:i,edits:o,parsed:a}=e,l=new Map((s.localGivens??[]).map(h=>[h.name,h])),d=new Map((i.localGivens??[]).map(h=>[h.name,h])),u=new Map(a.givens.map(h=>[h.name,h])),c=new Set;for(const[h,p]of l){const m=d.get(h);if(m!==void 0&&_e(m)===_e(p))continue;const b=u.get(h);if(b===void 0)return{ok:!1,reason:`Could not find where the given \`${h}\` is declared.`};const{tags:w,prose:v}=Br(a,t,b.line),y=[...(m===void 0?w:w.filter(D=>{const q=bs(D.text);return q!==void 0&&Fm.has(q)})).map(D=>D.line),...m===void 0?v:[]];for(const D of y)o.push({...n(D),text:""}),c.add(D);const _=xt(a,b.span.end-1);if(m===void 0){o.push({start:n(b.line).start,end:n(_).end,text:""});for(let K=b.line;K<=_;K++)c.add(K);const D=Math.min(b.line,...y),q=b.blockHeader??D,P=(t[_+1]??"x").trim()==="",z=q===0||t[q-1].trim()==="",U=b.blockHeader===void 0||![...u.values()].some(K=>K.blockHeader===b.blockHeader&&K.line>b.line&&d.has([...u.entries()].find(([,Z])=>Z===K)?.[0]??""));P&&z&&U&&!c.has(_+1)&&(o.push({...n(_+1),text:""}),c.add(_+1));continue}const S=r(b.line),E=wl(m),T=m.type!==p.type||m.default!==p.default?b.blockHeader===void 0?_l(m):`${m.name} :: ${m.type} is ${m.default}`:t.slice(b.line,_+1).join(`
|
|
91
|
+
`).trim();o.push({start:n(b.line).start,end:n(_).end,text:(E?`${S}${E}
|
|
92
|
+
`:"")+`${S}${T}
|
|
93
|
+
`})}for(const[h,p]of u){if(p.blockHeader===void 0||d.has(h))continue;![...u.values()].some(b=>b.blockHeader===p.blockHeader&&!c.has(b.line))&&!c.has(p.blockHeader)&&(o.push({...n(p.blockHeader),text:""}),c.add(p.blockHeader))}const f=[...d.values()].filter(h=>!l.has(h.name));if(f.length>0){const h=Math.max(-1,...[...u.values()].map(g=>g.line)),p=(()=>{let g=-1;for(let y=0;y<t.length;y++){const _=t[y].trim();(_.startsWith("import ")||g>=0&&/^}\s*from\s/.test(_))&&(g=y)}return g})(),m=h>=0?h:p,b=f.map(g=>{const y=wl(g);return(y?`${y}
|
|
94
|
+
`:"")+`${_l(g)}
|
|
95
95
|
`}).join(`
|
|
96
96
|
`),w=m>=0?n(m).end:n(0).end;o.push({start:w,end:w,text:`
|
|
97
|
-
${
|
|
98
|
-
`})}}const
|
|
99
|
-
`).join("")})}}function Ym(e){const{lines:t,wholeLine:n,indentOf:r,current:s,next:i,edits:o,parsed:a}=e,l=new Map((s.drills??[]).map(
|
|
100
|
-
`});else{const v=n(
|
|
101
|
-
`})}}}function Zm(e){const{lines:t,wholeLine:n,removedTiles:r,edits:s,parsed:i}=e;for(const o of r){if(
|
|
102
|
-
`)};let c=-1;for(const f of l.sources)c=Math.max(c,
|
|
103
|
-
`)+
|
|
97
|
+
${b}`}),t.some(g=>g.trim().startsWith("##! experimental.givens"))||o.push({start:0,end:0,text:`##! experimental.givens
|
|
98
|
+
`})}}const Ol=(e,t)=>`import { ${e.join(", ")} } from ${at(t)}`;function Xm(e){const{parsed:t,current:n,next:r,edits:s,wholeLine:i}=e,o=c=>_e(c.imports.flatMap(f=>f.kind==="all"?[f.from]:[]).sort());if(o(n)!==o(r))return{ok:!1,reason:"A whole-file `import` cannot be changed here."};if(_e(n.imports)===_e(r.imports))return;const a=r.imports.flatMap(c=>c.kind==="names"?[{...c,claimed:!1}]:[]),l=new Set([...r.sources.map(c=>c.base),...r.tiles.filter(xe).map(c=>c.source)]),d=t.imports.map((c,f)=>({statement:c,entry:n.imports[f]}));for(const{statement:c,entry:f}of d){if(!f||f.kind!=="names")continue;const h=a.find(g=>!g.claimed&&g.from===f.from);h&&(h.claimed=!0);const p=h?.names??[],b=f.names.filter(g=>!p.includes(g)).find(g=>l.has(g));if(b!==void 0)return{ok:!1,reason:`\`${b}\` is still read by a tile, so its import cannot be removed.`};if(_e(p)===_e(f.names))continue;const w=p.length===0?Ta(t,c.statement):c.statement,v=t.commentIn(w);if(v)return{ok:!1,reason:`Changing this import would also remove the comment inside it (\`${t.text.slice(v.start,v.end).trim()}\`), so nothing was written. Delete it in the file first.`};s.push({...w,text:p.length===0?"":Ol(p,f.from)})}const u=a.filter(c=>!c.claimed);if(u.length>0){const c=t.imports.at(-1);if(!c)return{ok:!1,reason:"This file has no `import` to put a source beside. Import its first source in the file."};const f=i(xt(t,c.statement.end-1)).end;s.push({start:f,end:f,text:u.map(h=>`${Ol(h.names,h.from)}
|
|
99
|
+
`).join("")})}}function Ym(e){const{lines:t,wholeLine:n,indentOf:r,current:s,next:i,edits:o,parsed:a}=e,l=new Map((s.drills??[]).map(u=>[Ws(u),u])),d=new Map((i.drills??[]).map(u=>[Ws(u),u]));for(const u of new Set([...l.keys(),...d.keys()])){const c=l.get(u),f=d.get(u);if(c&&f&&_e(c)===_e(f))continue;const h=f??c;if(f&&f.to.length===0)return{ok:!1,reason:`The drill on \`${u}\` names no destination.`};const p=a.sources.find(v=>v.name===h.source)?.dimensions.find(v=>v.name===h.name);if(p===void 0)return{ok:!1,reason:`\`${h.name}\` is not a dimension \`${h.source}\` declares in this file, so a drill cannot be put on it here.`};const{tags:m}=Br(a,t,p.line),b=m.find(v=>/^#\s*drill\b/.test(v.text)),w=r(p.line);if(f===void 0)b&&o.push({...n(b.line),text:""});else if(b)o.push({...n(b.line),text:`${w}${kl(f)}
|
|
100
|
+
`});else{const v=n(p.line).start;o.push({start:v,end:v,text:`${w}${kl(f)}
|
|
101
|
+
`})}}}function Zm(e){const{lines:t,wholeLine:n,removedTiles:r,edits:s,parsed:i}=e;for(const o of r){if(Re(o)||o.declaration.kind==="inherited")continue;const a=Wd(e,o);if(!a)return{ok:!1,reason:`Could not find where \`${o.name}\` is declared.`};if(a.siblings>1)return{ok:!1,reason:`\`${o.name}\` is one of several views declared by a single \`view:\` statement, which the builder does not restructure.`};const l=xt(i,a.statement.start),d=xt(i,a.statement.end-1),u=i.trailingComment(d),c=u&&u.start>=a.statement.end?u.end:a.statement.end;if(i.text.slice(i.lineStarts[l],a.statement.start).trim()!==""||i.text.slice(c,n(d).end).trim()!==""){s.push({...Ta(i,a.statement),text:""});continue}s.push({start:i.lineStarts[l],end:n(d).end,text:""});const h=l===0?"":t[l-1].trim();(t[d+1]??"x").trim()===""&&(l===0||h===""||h.endsWith("{"))&&s.push({...n(d+1),text:""})}}function Qm(e){const{sourceText:t,lines:n,wholeLine:r,addedTiles:s,newSources:i,currentSources:o,edits:a,parsed:l}=e,d=new Map;for(const f of s){if(Re(f))continue;const h=d.get(f.source)??[];h.push(f),d.set(f.source,h)}const u=(f,h)=>{const p=f.declaration.kind==="reference"?f.declaration.from:f.name,m=(f.filters??[]).map(b=>`where: ${ge.malloyPath(b.field)} ${b.op??"~"} $${b.given}`).join(", ");return[...Fd(f).map(b=>`${h}${b}`),`${h}view: ${f.name} is ${p}${m?` + { ${m} }`:""}`].join(`
|
|
102
|
+
`)};let c=-1;for(const f of l.sources)c=Math.max(c,xt(l,f.span.end-1));for(const[f,h]of d)if(o.has(f)){const p=l.sources.find(y=>y.name===f);if(!p)return{ok:!1,reason:`Could not find where the source \`${f}\` is declared.`};if(!p.properties)return{ok:!1,reason:`\`${f}\` never opens an \`extend { … }\` block, so a new tile cannot be added inside it.`};const m=p.line,b=xt(l,p.properties.closeStart);let w=" ";for(let y=m+1;y<b;y++){const _=/^(\s+)view:/.exec(n[y]);if(_){w=_[1];break}}const v=r(b).start,g=(n[b-1]??"").trim()==="";a.push({start:v,end:v,text:(g?"":`
|
|
103
|
+
`)+h.map(y=>u(y,w)).join(`
|
|
104
104
|
|
|
105
105
|
`)+`
|
|
106
|
-
`})}else{const
|
|
107
|
-
source: ${
|
|
108
|
-
`+
|
|
106
|
+
`})}else{const p=i.find(g=>g.name===f);if(!p)return{ok:!1,reason:`The tile's source \`${f}\` is not declared.`};const m=`
|
|
107
|
+
source: ${p.name} is ${p.base} extend {
|
|
108
|
+
`+h.map(g=>u(g," ")).join(`
|
|
109
109
|
|
|
110
110
|
`)+`
|
|
111
111
|
}
|
|
112
|
-
`;let
|
|
112
|
+
`;let b=c;if(b<0)for(let g=0;g<n.length;g++){const y=n[g].trim();(/^(import\s|given:|}\s*from\s)/.test(y)||/^[A-Z_]+\s*::/.test(y))&&(b=g)}const w=b>=0?r(b).end:t.length,v=w===t.length&&!t.endsWith(`
|
|
113
113
|
`)?`
|
|
114
|
-
`:"";a.push({start:w,end:w,text:v+m}),c=
|
|
115
|
-
`}),
|
|
116
|
-
`})}const _=m.filter(T=>!w.has(
|
|
117
|
-
`).join("")})}if(_e(c.filters)===_e(
|
|
114
|
+
`:"";a.push({start:w,end:w,text:v+m}),c=b}}function Jm(e){const{lines:t,starts:n,wholeLine:r,indentOf:s,current:i,next:o,edits:a,parsed:l}=e,d=new Map(i.tiles.map(u=>[tt(u),u]));for(const u of o.tiles){const c=d.get(tt(u));if(c===void 0||Re(u)||Re(c)||_e(Bs(c))===_e(Bs(u)))continue;if(u.declaration.kind==="inherited")return{ok:!1,reason:`\`${u.source} -> ${u.name}\` is declared on its source, not in this report, so its presentation cannot be changed here.`};const f=zm(l,u.source,u.name);if(f<0)return{ok:!1,reason:`Could not find where \`${u.name}\` is declared inside \`${u.source}\`.`};const{tags:h}=Br(l,t,f),p=s(f),m=Fd(u,!1),b=new Map(m.map(T=>[bs(T)??T,T])),w=new Set,v=Nd(u.chart),g=El(c)!==El(u);if(g){const T=h.filter(P=>Tr(P.text)),D=h.filter(P=>Dt(P.text)),q=c.chart==="custom"?h.filter(P=>Dt(P.text)||Tr(P.text)):T.length>0?T:D.length>1?D:[];if(q.length>0)return{ok:!1,reason:`\`${u.source} -> ${u.name}\` has a chart line the builder does not model (${q.map(P=>P.text).join(" and ")}), so its chart cannot be changed here.`}}let y=!1;for(const T of h){if(g&&Dt(T.text)){v===void 0?a.push({...r(T.line),text:""}):T.text!==wn(v,u.chartCarried)&&a.push({...r(T.line),text:`${p}${wn(v,u.chartCarried)}
|
|
115
|
+
`}),y=!0;continue}const D=bs(T.text);if(D===void 0||!Nm.has(D))continue;const q=b.get(D);if(q===void 0){a.push({...r(T.line),text:""});continue}w.add(D),q!==T.text&&a.push({...r(T.line),text:`${p}${q}
|
|
116
|
+
`})}const _=m.filter(T=>!w.has(bs(T)??T));if(g&&v!==void 0&&!y&&_.push(wn(v,u.chartCarried)),_.length>0){const T=n[f];a.push({start:T,end:T,text:_.map(D=>`${p}${D}
|
|
117
|
+
`).join("")})}if(_e(c.filters)===_e(u.filters))continue;const S=Wd(e,u);if(!S)return{ok:!1,reason:`Could not find \`${u.name}\`'s declaration to filter it.`};if(S.body.kind==="reference"){const T=ov(e,u,S);if(T)return T;continue}if(S.body.kind!=="inline")return{ok:!1,reason:`\`${u.name}\`'s body is ${S.body.why}, so there is no single first stage to write its filter into.`};const E=Bd(u.filters,S.body.stage);if(E)return Gd(u.name,E.given);const A=qd(e,u,S.body.stage);if(A)return A}}const El=e=>e.chart==="default"?void 0:e.chart,Bs=e=>{const{chartLines:t,chartCarried:n,...r}=e;if(r.chart!=="default")return r;const{chart:s,...i}=r;return i};function ev(e,t){const n=new Map(e.tiles.map(r=>[tt(r),r]));return{...t,tiles:t.tiles.map(r=>{const s=n.get(tt(r));return xe(r)&&r.chart===void 0&&s&&xe(s)&&s.chart!==void 0?{...r,chart:s.chart}:r})}}function xs(e){if(e.includes("\r"))return"Text uses plain line breaks; a carriage return cannot be written.";if(/^\|##/m.test(e))return"A line starting with `|##` would close the text early. Indent that line or reword it."}function tv(e,t,n){if(n.has(e.name))return`Two text tiles are named \`${e.name}\`, so they could not be told apart.`;if(n.add(e.name),t===void 0&&!ge.isIdentifier(e.name))return`The text tile name ${JSON.stringify(e.name)} must be a bare word.`;if(t===void 0||e.markdown!==t.markdown){const r=xs(e.markdown);if(r)return r}if(e.colspan!==void 0&&e.colspan!==t?.colspan&&!(Number.isInteger(e.colspan)&&e.colspan>=1))return"A text tile's width is a whole number of columns, 1 or more."}const ki=e=>`##|(markdown) ${e.name}
|
|
118
118
|
${e.markdown===""?"":`${e.markdown}
|
|
119
119
|
`}|##
|
|
120
|
-
`;function nv(e){const{sourceText:t,lines:n,wholeLine:r,current:s,next:i,parsed:o,edits:a}=e,l=new Map(s.tiles.filter(
|
|
120
|
+
`;function nv(e){const{sourceText:t,lines:n,wholeLine:r,current:s,next:i,parsed:o,edits:a}=e,l=new Map(s.tiles.filter(Re).map(h=>[h.name,h])),d=i.tiles.filter(Re),u=h=>o.textBlocks.find(p=>p.name===h),c=new Set(d.map(h=>h.name));for(const h of l.keys()){const p=c.has(h)?void 0:u(h);if(!p)continue;const m=xt(o,p.span.end-1);a.push({...p.span,text:""});const b=r(m+1),w=p.line===0||n[p.line-1].trim()==="";b.end>b.start&&n[m+1].trim()===""&&w?a.push({...b,text:""}):p.line>0&&w&&t.slice(p.span.end).trim()===""&&a.push({...r(p.line-1),text:""})}const f=[];for(const h of d){const p=l.get(h.name),m=u(h.name);if(p===void 0){if(m)return{ok:!1,reason:`A block named \`${h.name}\` is already in this file, so a new text tile cannot take that name.`};f.push(ki(h))}else p.markdown!==h.markdown&&(m?a.push({...m.span,text:ki(h)}):f.push(ki(h)))}if(f.length>0){const h=o.textBlocks.filter(v=>v.name===void 0||c.has(v.name)),p=h[h.length-1],m=o.sources.find(v=>v.name.endsWith("_tiles"));if(p){const v=p.span.end,g=t.slice(v);a.push({start:v,end:v,text:`
|
|
121
121
|
${f.join(`
|
|
122
122
|
`)}${g===""||g.startsWith(`
|
|
123
123
|
`)?"":`
|
|
@@ -126,70 +126,70 @@ ${f.join(`
|
|
|
126
126
|
`);a.push({start:v,end:v,text:`${g?"":`
|
|
127
127
|
`}${f.join(`
|
|
128
128
|
`)}
|
|
129
|
-
`});return}const
|
|
129
|
+
`});return}const b=t.length,w=t===""||t.endsWith(`
|
|
130
130
|
|
|
131
131
|
`)?"":t.endsWith(`
|
|
132
132
|
`)?`
|
|
133
133
|
`:`
|
|
134
134
|
|
|
135
|
-
`;a.push({start:
|
|
136
|
-
`)})}}const
|
|
137
|
-
`,t.end),i=e.text.slice(t.end,s<0?void 0:s);if(r.trim()===""&&i.trim()==="")return{start:n,end:s<0?e.text.length:s+1};if(r.trim()===""){const a=/^\s*/.exec(i)?.[0].length??0;return{start:t.start,end:t.end+a}}const o=r.replace(/[\s,]*$/,"");return{start:n+o.length,end:t.end}}function
|
|
138
|
-
${n.indent}${
|
|
139
|
-
`)&&!/(?<!\r)\n/.test(e)))return
|
|
140
|
-
`),t,n);return
|
|
141
|
-
`)}}async function
|
|
142
|
-
`),d=Lm(e),c=v=>({start:d[v],end:v+1<d.length?d[v+1]:e.length}),f=v=>/^\s*/.exec(u[v])?.[0]??"",p=[],h={...o,sourceText:e,parsed:l.parsed,lines:u,starts:d,wholeLine:c,indentOf:f,current:s,next:i,edits:p,...n.modelPath!==void 0?{modelPath:n.modelPath}:{},...n.explicitKind?{explicitKind:!0}:{}};for(const v of[qm,Vm,Xm,Hm,Ym,Zm,Qm,Jm,nv]){const g=v(h);if(g)return g}const m=v=>{const{drills:g,localGivens:b,kind:_,description:O,...I}=v,M=v.tiles.map(T=>{if(je(T))return T;if(T.filters?.length)return Ns(T);const{filters:D,...N}=T;return Ns(N)});return{...I,...O===void 0?{}:{description:ju(O)},..._==="notebook"?{kind:_}:{},tiles:M,...g?.length?{drills:[...g].sort((T,D)=>Ls(T).localeCompare(Ls(D)))}:{},...b?.length?{localGivens:b}:{}}};if(p.length===0)return _e(m(s))!==_e(m(i))?{ok:!1,reason:"No part of this edit was recognized, so nothing was written. Your changes are still here."}:{ok:!0,source:e};const y=Nm(e,p);if((await bl(e)).length===0){const v=await bl(y);if(v.length>0)return{ok:!1,reason:`The edit would have produced a file Malloy cannot parse, so it was not written (${v[0]}). Your changes are still here.`}}const w=await Tr(y,n.modelPath);return $r(w)?{ok:!1,reason:`The edit produced a file that cannot be read back: ${w.reason}`}:_e(m(w.document))!==_e(m(i))?{ok:!1,reason:"What was written did not read back as what was asked for, so it was not written. Your changes are still here."}:{ok:!0,source:y}}function qu({markdown:e,placeholder:t,onCommit:n,variant:r="document"}){const{theme:s}=Ke.usePublisherTheme(),[i,o]=k.useState(!1),a=k.useMemo(()=>i?{text:e}:void 0,[i,e]),{draft:l,patch:u,close:d,discard:c}=Kl(a,i,g=>n(g.text),()=>o(!1)),f=i&&l!==void 0&&l.text!==e,p=l!==void 0&&l.text!==e?ms(l.text):void 0;hu(f,()=>p!==void 0?!1:(d(),!0));const h=k.useRef(null),m=k.useRef(!1);k.useEffect(()=>{i||(m.current=!1)},[i]);const y=k.useCallback(g=>{!g||m.current||(m.current=!0,g.setSelectionRange(g.value.length,g.value.length))},[]);if(!i||l===void 0){const g=e.trim()?ms(e):void 0;return x.jsxs(S.Box,{role:"button",tabIndex:0,onClick:b=>{b.target.closest("a")?b.preventDefault():o(!0)},onKeyDown:b=>{b.target===b.currentTarget&&(b.key!=="Enter"&&b.key!==" "||(b.preventDefault(),o(!0)))},sx:[{minHeight:24},uu(s,"prose")],children:[e.trim()?x.jsx(E.Prose,{variant:r,children:e}):x.jsx(S.Typography,{variant:"body2",sx:{color:s.tileTitle,opacity:.6,fontStyle:"italic"},children:t}),g&&x.jsx(S.Typography,{variant:"caption",color:"error",role:"alert",children:g})]})}const w=l.text!==e?ms(l.text):void 0,v=()=>{w===void 0&&d()};return x.jsxs(S.Stack,{spacing:1,children:[x.jsx(S.TextField,{multiline:!0,autoFocus:!0,minRows:3,maxRows:14,fullWidth:!0,value:l.text,placeholder:t,error:w!==void 0,helperText:w,inputRef:y,inputProps:{"aria-label":"Markdown"},onChange:g=>u(b=>{b.text=g.target.value}),onKeyDown:g=>{g.key==="Escape"?v():g.key==="Enter"&&(g.metaKey||g.ctrlKey)&&(g.preventDefault(),v())},onBlur:g=>{g.relatedTarget instanceof Node&&h.current?.contains(g.relatedTarget)||d()}}),x.jsxs(S.Stack,{ref:h,direction:"row",spacing:1,children:[x.jsx(S.Button,{size:"small",variant:"outlined",disabled:w!==void 0,onClick:v,children:"Done"}),x.jsx(S.Button,{size:"small",onMouseDown:g=>g.preventDefault(),onClick:()=>{c(),o(!1)},children:"Cancel"})]})]})}const av="Write markdown: # heading, **bold**, - list";function lv({tile:e,onChange:t,chrome:n="card"}){return x.jsx(E.TileCard,{chrome:n,kind:"text",children:x.jsx(qu,{markdown:e.markdown,placeholder:av,onCommit:t})})}const Fs=e=>e.label??E.tileTitle(`${e.source} -> ${e.name}`);function cv({tile:e,index:t,selected:n,flash:r=!1,menuOpen:s,bare:i=!1,onInsertAfter:o,onSelect:a,onOpenMenu:l,resizing:u=!1,width:d,onResizeStart:c,onResizeMove:f,onResizeEnd:p,children:h}){const{theme:m}=Ke.usePublisherTheme();return x.jsx(dm,{id:Fe(e),index:t,children:({ref:y,handleRef:w})=>x.jsxs(S.Box,{ref:y,onClick:a,onPointerDown:v=>{v.button===0&&a()},role:"group","aria-label":`Tile ${e.name}`,"aria-current":n,onFocus:a,"data-tile-key":Fe(e),"data-flash":r||void 0,sx:{position:"relative",display:"grid",minWidth:0,cursor:"grab",...Ku(m,{selected:n,flash:r,bare:i}),"&&[data-dnd-dragging]":{opacity:1,outline:"none",boxShadow:m.shadow.drag},"&&[data-dnd-placeholder]":{opacity:.45,outline:`2px dashed ${m.accent}`,boxShadow:"none"},"&:hover .builder-affordance, &:focus-within .builder-affordance":{opacity:1},"@media (hover: none)":{"& .builder-affordance":{opacity:1}}},children:[h,x.jsx(S.Box,{ref:w,"aria-label":`Move ${Wr(e)}`,sx:{position:"absolute",width:"1px",height:"1px",overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"}}),x.jsx(S.IconButton,{className:"builder-affordance",size:"small","aria-label":`Settings for ${Wr(e)}`,onClick:v=>{v.stopPropagation(),l(v.currentTarget)},sx:{position:"absolute",top:`${-((i?E.BARE_RING_OFFSET_PX+1:0)+12)}px`,right:i?0:"12px",border:m.cardBorder,borderRadius:1,width:28,height:24,zIndex:2,color:m.tileTitle,bgcolor:m.tile,opacity:n||s?.9:0,transition:`opacity ${E.MOTION_FAST}`,...E.reducedMotionSx,"&:hover":{opacity:1,bgcolor:m.tile}},children:x.jsx(hv,{})}),c&&x.jsx(S.Box,{className:"builder-affordance",[Ou]:"",role:"separator",tabIndex:d?0:-1,"aria-orientation":"vertical","aria-label":`Width of ${Wr(e)}`,...d?{"aria-valuenow":d.span,"aria-valuemin":1,"aria-valuemax":d.columns,"aria-valuetext":`${d.span} of ${d.columns} columns`}:{},onKeyDown:v=>{if(!d)return;const g=v.key==="ArrowRight"?d.span+1:v.key==="ArrowLeft"?d.span-1:v.key==="Home"?1:v.key==="End"?d.columns:void 0;g!==void 0&&(v.preventDefault(),v.stopPropagation(),d.onStep(Math.min(Math.max(g,1),d.columns)))},onPointerDown:c,onPointerMove:f,onPointerUp:p,onPointerCancel:p,onClick:v=>v.stopPropagation(),sx:{position:"absolute",top:0,bottom:0,right:"-5px",width:"10px",cursor:"col-resize",touchAction:"none",zIndex:2,opacity:u||n?1:0,transition:`opacity ${E.MOTION_FAST}`,...E.reducedMotionSx,"&:hover":{opacity:1},"&:focus-visible":{opacity:1,outline:`2px solid ${m.accent}`,outlineOffset:1,borderRadius:"3px"},"&::after":{content:'""',position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"4px",height:"28px",borderRadius:"2px",bgcolor:m.accent}}}),o&&x.jsx(S.IconButton,{className:"builder-affordance",size:"small","aria-label":`Insert tile after ${Wr(e)}`,onClick:v=>{v.stopPropagation(),o()},sx:{position:"absolute",bottom:`-${(i?E.NOTEBOOK_GAP_PX:E.GRID_GAP_PX)/2+12}px`,left:"50%",transform:"translateX(-50%)",width:24,height:24,zIndex:3,color:m.tileTitle,bgcolor:m.tile,border:m.cardBorder,opacity:0,transition:`opacity ${E.MOTION_FAST}`,...E.reducedMotionSx,"&:hover, &:focus-visible":{opacity:1,bgcolor:m.tile}},children:x.jsx(E.AddIcon,{sx:{fontSize:14}})})]})})}const wi=4,Ku=(e,{selected:t,flash:n=!1,bare:r=!1})=>{const s=t||n?e.accent:"transparent",i=t?e.accent:e.cardBorder.replace(/^1px solid /,""),o=`outline-color ${E.MOTION_FAST}, border-color ${E.MOTION_FAST}, opacity ${E.MOTION_FAST}, box-shadow ${E.MOTION_FAST}`;return r?{borderRadius:1,"&::before":{content:'""',position:"absolute",inset:`${-E.BARE_RING_OFFSET_PX}px`,borderRadius:1,border:`2px solid ${s}`,pointerEvents:"none",transition:o,...E.reducedMotionSx},"&:hover::before":{borderColor:i}}:{borderRadius:1,outline:`2px solid ${s}`,outlineOffset:2,...n&&{boxShadow:`0 0 0 6px color-mix(in srgb, ${e.accent} 25%, transparent)`},transition:o,...E.reducedMotionSx,"&:hover":{outlineColor:i,boxShadow:e.shadow.lift}}};function dv({tile:e,heading:t,note:n,chrome:r="card"}){const{theme:s}=Ke.usePublisherTheme();return x.jsxs(E.TileCard,{chrome:r,children:[x.jsx(E.TileHeading,{title:t?.title??Fs(e),subtitle:t?t.subtitle:e.subtitle}),n&&x.jsx(S.Typography,{variant:"body2",sx:{color:s.tileTitle,py:2},children:n}),x.jsxs(S.Typography,{variant:"caption",sx:{display:"block",color:s.tileTitle,opacity:.7},children:[e.source," → ",e.name]})]})}function uv({after:e}){const{theme:t}=Ke.usePublisherTheme();return x.jsx(um,{id:gu(e),after:e,children:({ref:n,isDropTarget:r})=>x.jsx(S.Box,{ref:n,"aria-hidden":!0,sx:{minHeight:48,borderRadius:1,border:`1px dashed ${t.accent}`,bgcolor:r?`color-mix(in srgb, ${t.accent} 12%, transparent)`:"transparent",opacity:r?.95:.4,transition:`opacity ${E.MOTION_FAST}, background-color ${E.MOTION_FAST}`,...E.reducedMotionSx}})})}function fv({columns:e}){const{theme:t}=Ke.usePublisherTheme();return x.jsx(S.Box,{"aria-hidden":!0,sx:{position:"absolute",inset:0,pointerEvents:"none",zIndex:3,display:"grid",gridTemplateColumns:`repeat(${e}, minmax(0, 1fr))`,gap:`${E.GRID_GAP_PX}px`},children:Array.from({length:e},(n,r)=>x.jsx(S.Box,{sx:{borderLeft:`1px dashed ${t.accent}`,borderRight:r===e-1?`1px dashed ${t.accent}`:"none",opacity:.35}},r))})}function hv(){return x.jsxs(S.SvgIcon,{sx:{fontSize:18},viewBox:"0 0 24 24",children:[x.jsx("circle",{cx:"3.5",cy:"12",r:"2"}),x.jsx("circle",{cx:"12",cy:"12",r:"2"}),x.jsx("circle",{cx:"20.5",cy:"12",r:"2"})]})}function pv({editor:e,reorder:t,resizing:n,gridBox:r,columns:s,notebook:i,chrome:o,canAdd:a,selected:l,flash:u,menuIndex:d,onSelect:c,onOpenMenu:f,openAdd:p,editTile:h,renderTile:m}){const{dragging:y,preview:w,onDragStart:v,onDragOver:g,onDragEnd:b}=t,{resize:_,startResize:O,onResize:I,endResize:M}=n,T=_!==void 0?e.document.tiles.map((W,X)=>X===_.index?{...W,colspan:_.span}:W):w??e.document.tiles,D=e.document.tiles.length===0,N=y?Dg(T,s):T.map(pu),R=W=>gv(W,Fs(W),h);return x.jsxs(x.Fragment,{children:[x.jsx(fg,{sensors:lm,onDragStart:v,onDragOver:g,onDragEnd:b,children:x.jsxs(S.Box,{ref:r,sx:{position:"relative"},children:[!i&&(y||_!==void 0)&&x.jsx(fv,{columns:s}),x.jsx(E.DashboardGrid,{tiles:N,columns:s,rowGapPx:o==="none"?E.NOTEBOOK_GAP_PX:E.GRID_GAP_PX,keyOf:W=>W.kind==="gap"?gu(W.after):Fe(W.tile),renderTile:W=>{if(W.kind==="gap")return x.jsx(uv,{after:W.after});const{tile:X,index:G}=W;return x.jsx(cv,{tile:X,index:G,selected:G===l,flash:Fe(X)===u,menuOpen:d===G,bare:o==="none",...i&&a?{onInsertAfter:()=>p(G+1)}:{},...s>1&&mv(X)?{resizing:_?.index===G,width:{span:X.colspan??1,columns:s,onStep:U=>{U!==(X.colspan??1)&&e.update(Y=>{const re=Y.tiles[G];re&&(re.colspan=U)})}},onResizeStart:U=>O(U,G),onResizeMove:I,onResizeEnd:M}:{},onSelect:()=>c(G),onOpenMenu:U=>f(U,G),children:je(X)?x.jsx(lv,{tile:X,chrome:o,onChange:U=>h(Fe(X),Y=>{je(Y)&&(Y.markdown=U)})}):m&&!e.pendingOpen?m(X,R(X),o):x.jsx(dv,{tile:X,chrome:o,heading:R(X),...e.pendingOpen?{note:"Preview appears after you Save"}:{}})})}})]})}),i&&a&&!D&&x.jsx(S.Button,{size:"small",startIcon:x.jsx(E.AddIcon,{}),"aria-label":"Add tile at the end",onClick:()=>p(),sx:{alignSelf:"center"},children:"Add tile"})]})}const gv=(e,t,n)=>{if(e.declaration.kind==="inherited")return;const r=Fe(e),s=i=>o=>n(r,a=>{xe(a)&&(o===""?delete a[i]:a[i]=o)});return{title:x.jsx(fo,{value:e.label??"",placeholder:t,ariaLabel:"Tile title",onCommit:s("label")}),subtitle:x.jsx(fo,{value:e.subtitle??"",placeholder:"Add a subtitle",ariaLabel:"Tile subtitle",faintWhenEmpty:!0,onCommit:s("subtitle")})}},mv=e=>je(e)||e.declaration.kind!=="inherited";function vv({editor:e,notebook:t,documentSlug:n,chrome:r,actions:s,descriptionSelected:i,selectDescription:o}){const{theme:a}=Ke.usePublisherTheme();return x.jsxs(x.Fragment,{children:[x.jsxs(S.Stack,{direction:"row",sx:{alignItems:"center",gap:2},children:[x.jsx(S.Typography,{variant:"h5",sx:{flex:1,minWidth:0},children:x.jsx(fo,{value:e.document.title,placeholder:n??(t?"Untitled notebook":"Untitled dashboard"),ariaLabel:t?"Notebook title":"Dashboard title",onCommit:l=>e.update(u=>{u.title=l})})}),x.jsx(S.Box,{sx:{my:"-4px"},children:s})]}),x.jsx(S.Box,{role:"group","aria-label":"Description","aria-current":i,onPointerDown:o,onFocus:o,sx:r==="none"?{my:`${E.BARE_DESCRIPTION_MARGIN_PX}px`}:void 0,children:x.jsx(E.TileCard,{chrome:r,kind:"text",sx:{position:"relative",overflow:"visible",...Ku(a,{selected:i,bare:r==="none"})},children:x.jsx(qu,{markdown:e.document.description??"",placeholder:"Add a description",onCommit:l=>e.update(u=>{l.trim()===""?delete u.description:u.description=l})})})})]})}const bv=({size:e,notebook:t,savesTo:n,onEvent:r})=>({size:e,saved:({size:s,structural:i,durationMs:o,fromOpen:a})=>r?.(t?{type:"notebook.saved",cells:s,structural:i,converted:a,where:n,durationMs:o}:{type:"dashboard.saved",tiles:s,structural:i,where:n,durationMs:o}),refused:s=>r?.({type:t?"notebook.save_refused":"dashboard.save_refused",reason:s}),undone:({size:s,structural:i,durationMs:o})=>r?.(t?{type:"notebook.save_undone",cells:s,structural:i,where:n,durationMs:o}:{type:"dashboard.save_undone",tiles:s,structural:i,where:n,durationMs:o}),undoRefused:s=>r?.({type:t?"notebook.save_undo_refused":"dashboard.save_undo_refused",reason:s})}),yv=E.createSvgIcon(x.jsx("path",{d:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7z"})),xv=E.createSvgIcon(x.jsx("path",{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8"})),bo=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),_i=bo?"⌘":"Ctrl+",Il=e=>{if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"},ki=e=>e instanceof Element&&e.closest('[role="dialog"], .MuiPopover-root, .MuiDialog-root')!==null;function wv(e){const t=k.useRef(e);k.useEffect(()=>{t.current=e});const[n,r]=k.useState(!1);k.useEffect(()=>{n&&(r(!1),t.current.save?.())},[n]),k.useEffect(()=>{const s=i=>{const o=t.current;if(o.paused)return;const a=bo?i.metaKey:i.ctrlKey,l=i.key.toLowerCase();if(i.key==="Escape"){if(Il(i.target)||ki(i.target))return;o.escape();return}if(Il(i.target)){if(a&&l==="s"){if(i.preventDefault(),!o.save||ki(i.target))return;i.target.blur(),r(!0)}return}if(ki(i.target)){a&&l==="s"&&i.preventDefault();return}if(a&&l==="z"){i.preventDefault(),i.shiftKey?o.redo():o.undo();return}if(!bo&&a&&l==="y"){i.preventDefault(),o.redo();return}if(a&&l==="s"){i.preventDefault(),o.save?.();return}o.nudge&&!a&&!i.altKey&&!i.shiftKey&&(i.key==="ArrowLeft"||i.key==="ArrowRight")&&(i.preventDefault(),o.nudge(i.key==="ArrowRight"?1:-1))};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[])}const Dl={package:"Saves to the package file",browser:"Saves in this browser",host:"Saves to the app this is embedded in"};function _v({canUndo:e,canRedo:t,onUndo:n,onRedo:r,dirty:s,saving:i,onSave:o,savesTo:a="package",saveLabel:l,saveButton:u,actions:d,onAddTile:c,onExit:f}){return x.jsxs(S.Stack,{direction:"row","aria-label":"Builder actions",sx:{alignItems:"center",gap:.5,flexShrink:0,"& .MuiButton-root":{whiteSpace:"nowrap"}},children:[c&&x.jsx(S.Button,{startIcon:x.jsx(E.AddIcon,{}),onClick:c,"aria-label":"Add tile",children:"Tile"}),c&&x.jsx(S.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),x.jsx(S.Tooltip,{title:`Undo (${_i}Z)`,children:x.jsx("span",{children:x.jsx(S.IconButton,{"aria-label":"Undo",disabled:!e,onClick:n,sx:{width:37,height:37},children:x.jsx(xv,{fontSize:"small"})})})}),x.jsx(S.Tooltip,{title:`Redo (${_i}⇧Z)`,children:x.jsx("span",{children:x.jsx(S.IconButton,{"aria-label":"Redo",disabled:!t,onClick:r,sx:{width:37,height:37},children:x.jsx(yv,{fontSize:"small"})})})}),(d||o||f)&&x.jsx(S.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),d,o?x.jsx(S.Tooltip,{title:s?`Save (${_i}S) · ${l??Dl[a]}`:l??Dl[a],children:x.jsx("span",{children:x.jsx(S.Button,{ref:u,variant:s?"contained":"outlined",disabled:!s||i,onClick:o,sx:{minWidth:124},children:i?"Saving…":s?"Save":"Saved"})})}):null,o&&x.jsx(S.Box,{component:"span","aria-live":"polite",sx:{position:"absolute",width:"1px",height:"1px",overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"},children:i?"Saving":s?"Unsaved changes":"All changes saved"}),f&&x.jsx(E.SecondaryButton,{label:"Close",icon:x.jsx(E.CheckIcon,{}),onClick:f})]})}const kv=E.createSvgIcon(x.jsx("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2m5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12z"})),Sv=E.createSvgIcon(x.jsx("path",{d:"M10 18h4v-2h-4zM3 6v2h18V6zm3 7h12v-2H6z"}));function $v({controls:e,tileCount:t,unknownFieldsOf:n,onEdit:r,onAdd:s,addDisabledReason:i,onRemove:o,children:a}){const{theme:l}=Ke.usePublisherTheme();return x.jsx(x.Fragment,{children:x.jsxs(S.Stack,{sx:{gap:1,position:"sticky",top:0,zIndex:E.STICKY_CONTROLS_Z,bgcolor:"background.default",pb:1},children:[x.jsx(S.Stack,{direction:"row",sx:{gap:2,alignItems:"center",minHeight:32},children:x.jsxs(S.Stack,{direction:"row",role:"group","aria-label":"Filters",sx:{gap:1,alignItems:"center",flexWrap:"wrap",flex:1,minWidth:0},children:[x.jsx(Sv,{sx:{fontSize:18,color:l.tileTitle,opacity:.7}}),x.jsx(S.Typography,{variant:"subtitle2",sx:{color:l.tileTitle,mr:.5},children:"Filters"}),e.length===0&&x.jsx(S.Typography,{variant:"body2",sx:{color:l.tileTitle,opacity:.8},children:"None yet."}),e.map(u=>{const d=n(u.name,u.type);return x.jsx(S.Tooltip,{title:d.length>0?`$${u.name} · cannot filter on: ${d.join(", ")}`:`$${u.name} · ${u.origin==="dashboard"?"declared here":"from the model"} · ${u.boundTiles} of ${t} tiles`,children:x.jsx(S.Chip,{size:"small",label:`${u.label??u.name}${u.boundTiles===0?" · unused":""}`,"aria-label":`Edit filter ${u.name}`,color:d.length>0?"warning":"default",variant:u.origin==="dashboard"?"filled":"outlined",onClick:()=>r(u),onDelete:()=>o(u.name),deleteIcon:x.jsx(kv,{"aria-label":`Remove filter ${u.name}`}),sx:{opacity:u.boundTiles===0?.6:1,cursor:"pointer",transition:`opacity ${E.MOTION_FAST}`,...E.reducedMotionSx}})},u.name)}),x.jsx(S.Tooltip,{title:i??"",children:x.jsx("span",{children:x.jsx(S.Chip,{component:"button",size:"small",variant:"outlined",icon:x.jsx(E.AddIcon,{}),label:"Filter","aria-label":"Add filter","aria-haspopup":"dialog",disabled:i!==void 0,onClick:()=>s(),sx:{cursor:"pointer",color:l.tileTitle,borderStyle:"dashed","& .MuiChip-icon":{color:"inherit",fontSize:16}}})})})]})}),a]})})}function Tv(e,t){const n=new Map(e.tiles.map((r,s)=>[Fe(r),{tile:r,index:s}]));for(const[r,s]of t.tiles.entries()){const i=n.get(Fe(s));if(!i||i.index!==r||JSON.stringify(i.tile)!==JSON.stringify(s))return Fe(s)}}function Ov({editor:e,gridBox:t}){const[n,r]=k.useState(void 0),s=typeof n=="object"?n.tile:void 0,i=n==="description",o=k.useCallback(m=>r(y=>typeof y=="object"&&y.tile===m?y:{tile:m}),[]),a=k.useCallback(()=>r(m=>m==="description"?m:void 0),[]),l=k.useCallback(()=>r("description"),[]),u=k.useCallback(()=>r(void 0),[]),[d,c]=k.useState(void 0),f=k.useRef(!1),p=k.useRef(e.document);k.useEffect(()=>{const m=p.current;if(p.current=e.document,!f.current)return;f.current=!1;const y=Tv(m,e.document);if(y===void 0)return;c(y),Array.from(t.current?.querySelectorAll("[data-tile-key]")??[]).find(v=>v.dataset.tileKey===y)?.scrollIntoView?.({block:"nearest",behavior:E.scrollBehavior()})},[e.document,t]),k.useEffect(()=>{if(d===void 0)return;const m=setTimeout(()=>c(void 0),1500);return()=>clearTimeout(m)},[d]);const h=k.useMemo(()=>({...e,undo:()=>{f.current=!0,e.undo()},redo:()=>{f.current=!0,e.redo()}}),[e]);return{selected:s,descriptionSelected:i,selectTile:o,deselectTile:a,selectDescription:l,clearSelection:u,flash:d,stepEditor:h}}function Ev({dirty:e,saving:t,canSave:n,save:r,onExit:s}){const[i,o]=k.useState("idle"),[a,l]=k.useState(!1),u=k.useRef(r);u.current=r;const d=k.useRef(s);d.current=s;const c=k.useRef(0),f=k.useCallback(async()=>{const h=++c.current;l(!1),o("saving");try{await u.current()}catch{c.current===h&&o("idle");return}c.current===h&&l(!0)},[]);return k.useEffect(()=>{if(i==="waiting"){if(t)return;e?f():(o("idle"),d.current())}else if(i==="saving"){if(!a||t)return;o("idle"),e||d.current()}},[i,a,t,e,f]),{requestExit:k.useCallback(()=>{i==="idle"&&(e?o("asking"):d.current())},[i,e]),dialog:{open:i==="asking",canSave:n,onKeepEditing:()=>{i==="asking"&&o("idle")},onDiscard:()=>{i==="asking"&&(o("idle"),d.current())},onSaveAndExit:()=>{i==="asking"&&(t?o("waiting"):f())}}}}function Cv({editor:e,onSave:t,onDirtyChange:n,onExit:r,onChange:s,extraDirty:i=!1,report:o,unit:a,prepare:l,shortcuts:u}){const[d,c]=k.useState(!1),[f,p]=k.useState(!1),h=k.useRef(null),m=k.useRef(o);m.current=o;const y=e.dirty||i,w=(e.edited??e.dirty)||i;k.useEffect(()=>{s?.(e.document)},[e.document,s]),k.useLayoutEffect(()=>{n?.(w)},[w,n]);const v=k.useRef(n);v.current=n,k.useEffect(()=>()=>v.current?.(!1),[]);const g=k.useRef(a);g.current=a,k.useEffect(()=>{p(!1)},[e.document]);const b=k.useCallback(()=>{c(!0),p(!1);const G=E.now(),{structural:U}=e,Y=e.pendingOpen??!1,re=m.current.size;return e.save().then(ee=>{ee.ok===!0?m.current.saved({size:re,structural:U,fromOpen:Y,durationMs:E.now()-G}):m.current.refused(ee.reason)}).finally(()=>c(!1))},[e]),_=k.useRef(!1),O=k.useRef(!1);k.useEffect(()=>{!O.current||d||(O.current=!1,h.current?.focus())},[f,d]);const I=k.useCallback(()=>{if(!t||d||_.current||!e.canUndoSave)return;_.current=!0,c(!0);const G=E.now(),U=e.lastSave?.structural??!1,Y=m.current.size;return e.undoSave().then(re=>{re.ok===!0?(O.current=!0,p(!0),m.current.undone({size:Y,structural:U,fromOpen:!1,durationMs:E.now()-G})):m.current.undoRefused(re.reason)}).finally(()=>{_.current=!1,c(!1)})},[t,d,e]),M=k.useCallback(()=>{if(!(!t||!e.dirty||d))return b()},[t,e,d,b]),T=k.useRef(M);T.current=M;const D=k.useCallback(()=>{const G=()=>T.current();return l?l(G):G()},[l]),N=Ev({dirty:w,saving:d,canSave:!!t,save:D,onExit:()=>r?.()});wv(k.useMemo(()=>({...u,undo:e.undo,redo:e.redo,...t?{save:D}:{},paused:N.dialog.open}),[u,e,t,D,N.dialog.open]));const R=!!t&&!d&&e.canUndoSave,W=e.lastSave,X={canUndo:e.canUndo,canRedo:e.canRedo,onUndo:e.undo,onRedo:e.redo,dirty:y,saving:d,saveButton:h,...t?{onSave:D}:{},...r?{onExit:N.requestExit}:{}};return{saving:d,save:D,exitGuard:N,undoSave:I,canUndoSave:R,lastSave:W,toolbarProps:X}}function Jr(e){for(const t of e??[]){const n=/^#\(doc\)\s*(.*)$/s.exec(t.trim());if(n)return n[1].trim()}}function Al(e){for(const t of e??[]){const n=/^#\s*(?:-[A-Za-z_]+\s+)*([a-z_]+)/.exec(t.trim())?.[1];if(n&&Eu.includes(n))return n}}const Iv=1;function Uu(e,t,n){const r=[];for(const s of e??[]){const i=s.name,o=s.kind;if(typeof i=="string"){if(o==="dimension"||o==="measure"){const a=s.type?.kind;r.push({name:t+i,kind:o,...a?{type:a}:{}})}else if(o==="join"&&n>0){const a=s.schema?.fields;r.push(...Uu(a,`${t}${i}.`,n-1))}}}return r}function Dv(e){const t=new Map;for(const n of Vu(e))t.set(n.name,Uu(n.schema?.fields,"",Iv));return t}function Vu(e){const t=[];for(const n of e.sourceInfos??[])try{const r=typeof n=="string"?JSON.parse(n):n;r?.name&&t.push(r)}catch{continue}return t}const Av=e=>(e.annotations??[]).some(t=>{const n=t.value??"";return n.startsWith("#(malloy)")&&af.parseTag(n.slice(9)).tag?.has("calculation")===!0});function Pv(e){const t=new Map;for(const n of Vu(e)){const r=new Set;for(const s of n.schema?.fields??[]){if(s.kind!=="view"||typeof s.name!="string")continue;const i=s.schema?.fields;i&&i.length>0&&i.every(Av)&&r.add(s.name)}t.set(n.name,r)}return t}function Pl(e,t){return!e||t===void 0?void 0:e.sources.find(r=>r.name===t)?.fields.filter(r=>r.kind==="dimension")}const yo=e=>(e??"").startsWith("dashboards/"),Ml=e=>e.modelPath??e.path??"";function Hu(e){const t=[],n=new Set,r=new Map,s=new Map,i=new Map;for(const o of e){const a=Ml(o);if(yo(a))continue;const l=E.exportedSources(o.modelInfo);s.set(o,l);for(const{name:u}of o.sources??[])u&&i.set(u,[...i.get(u)??[],a]);for(const u of l)r.set(u,[...r.get(u)??[],a])}for(const o of e){const a=Ml(o);if(yo(a))continue;const l=Dv(o),u=Pv(o);for(const d of o.sources??[]){const c=d.name;if(!c||!s.get(o)?.has(c)||n.has(c))continue;n.add(c);const f=(d.givens??[]).map(p=>p.name).filter(p=>typeof p=="string");t.push({name:c,modelPath:a,exporters:r.get(c)??[a],visibleIn:i.get(c)??[a],...Jr(d.annotations)?{description:Jr(d.annotations)}:{},views:(d.views??[]).filter(p=>typeof p.name=="string").map(p=>({name:p.name,...Jr(p.annotations)?{description:Jr(p.annotations)}:{},...Al(p.annotations)?{chart:Al(p.annotations)}:{},...u.get(c)?.has(p.name)?{aggregateOnly:!0}:{}})),givens:f,fields:l.get(c)??[]})}}return{sources:t}}function Mv({editor:e,opened:t,givens:n,catalog:r}){const[s,i]=k.useState(void 0),o=k.useMemo(()=>{const h=new Set((t.localGivens??[]).map(m=>m.name));return(n??[]).filter(m=>!h.has(m.name))},[t,n]),a=k.useMemo(()=>pf(e.document,o),[e.document,o]),l=k.useMemo(()=>new Map(e.document.sources.map(h=>[h.name,Pl(r,h.base)])),[r,e.document.sources]),u=k.useCallback(h=>l.get(h.source)??Pl(r,h.source),[l,r]),d=(h,m)=>{const y=[];for(const w of e.document.tiles){if(!xe(w))continue;const v=u(w);if(!v)continue;const g=new Map(v.map(b=>[b.name,b.type]));for(const b of w.filters??[])b.given===h&&(!g.has(b.field)||!rs(m,g.get(b.field)))&&y.push(`${b.field} on ${w.label??w.name} (${e.document.sources.find(_=>_.name===w.source)?.base??w.source})`)}return y},c=k.useMemo(()=>a.filter(h=>h.origin==="model"&&h.boundTiles===0),[a]);return{filterDialog:s,setFilterDialog:i,controlList:a,fieldsFor:u,unknownFieldsOf:d,available:c,applyFilter:(h,m,y)=>{i(void 0),e.update(w=>{y&&wf(w,y),xf(w,h,m)})},dropControl:h=>{i(void 0),e.update(m=>_f(m,h))}}}function jv({pendingOpen:e,prepare:t}){const[n,r]=k.useState(void 0),s=k.useRef(e);s.current=e;const i=k.useCallback(o=>s.current?new Promise(a=>r({go:()=>{r(void 0),a(t(o))},stop:()=>{r(void 0),a()}})):t(o),[t]);return{confirmConversion:n,prepareSave:i}}function Rv(e){const{splice:t,onSave:n,structural:r,clearsHistory:s,opensDirty:i=!1}=e,[o,a]=k.useState({stack:[e.document],index:0}),[l,u]=k.useState(e.source),[d,c]=k.useState(void 0),[f,p]=k.useState(e.document),[h,m]=k.useState(i),[y,w]=k.useState(e.replaces),[v,g]=k.useState(!1),b=o.stack[o.index],_=k.useRef(o);_.current=o;const O=k.useRef(!1),[I,M]=k.useState(!1),T=j=>{O.current=j,M(j)},[D,N]=k.useState(void 0),R=k.useCallback(j=>{c(void 0),a(q=>{const J=structuredClone(q.stack[q.index]);if(j(J),JSON.stringify(J)===JSON.stringify(q.stack[q.index]))return q;const H=[...q.stack.slice(0,q.index+1),J].slice(-100);return{stack:H,index:H.length-1}})},[]),W=k.useCallback(()=>{c(void 0),a(j=>j.index>0?{...j,index:j.index-1}:j)},[]),X=k.useCallback(()=>{c(void 0),a(j=>j.index<j.stack.length-1?{...j,index:j.index+1}:j)},[]),G=k.useCallback(async(j,q)=>{try{return await t(j,q)}catch(J){return{ok:!1,reason:`Could not build the file: ${J instanceof Error?J.message:String(J)}`}}},[t]),U=k.useCallback(async()=>{if(O.current)return{ok:!1,reason:"A save is still being written."};const j={source:l,saved:f,history:_.current,pendingOpen:h,replacing:y,unwritten:v},q=s?.(f,b)??!1,J=r?.(f,b)??!1;T(!0);try{const Q=await G(l,b);if(Rs(Q))return c(Q.reason),{ok:!1,reason:Q.reason};try{await n?.(Q.source,{purpose:"save",document:b})}catch($){const P=`Could not save: ${$ instanceof Error?$.message:String($)}`;return c(P),{ok:!1,reason:P}}u(Q.source),p(b),m(!1),w(void 0),g(!1);const H=q?{stack:[b],index:0}:j.history;return a($=>$===j.history?H:q?{stack:[$.stack[$.index]],index:0}:$),N(n?{before:j,after:H,lastSave:{before:y??l,after:Q.source,structural:J,clearsHistory:q}}:void 0),c(void 0),{ok:!0}}finally{T(!1)}},[b,G,n,l,f,h,y,v,s,r]),Y=k.useCallback(async()=>{if(O.current)return{ok:!1,reason:"A save is still being written."};if(!n||D===void 0||D.after!==_.current)return{ok:!1,reason:"There is no save to undo."};const{before:j}=D;T(!0);try{await n(j.replacing??j.source,{purpose:"undo",document:j.saved})}catch(q){const J=`Could not undo the save: ${q instanceof Error?q.message:String(q)}`;return c(J),{ok:!1,reason:J}}finally{T(!1)}return u(j.source),p(j.saved),m(j.pendingOpen),w(j.replacing),g(j.unwritten||j.replacing!==void 0),a(q=>q===D.after?j.history:q),N(void 0),c(void 0),{ok:!0}},[n,D]),re=k.useMemo(()=>v||JSON.stringify(b)!==JSON.stringify(f),[b,f,v]),ee=k.useMemo(()=>r?.(f,b)??!1,[b,f,r]),A=k.useMemo(()=>s?.(f,b)??!1,[b,f,s]),B=D!==void 0&&D.after===o,z=k.useCallback(async()=>{const j=await G(l,b);return Rs(j)?{ok:!1,reason:j.reason}:{ok:!0,source:j.source}},[b,G,l]);return{document:b,saved:f,source:l,canUndo:o.index>0,canRedo:o.index<o.stack.length-1,dirty:re||h,edited:re,pendingOpen:h,...d===void 0?{}:{error:d},update:R,undo:W,redo:X,save:U,preview:z,structural:ee,clearsHistory:A,canUndoSave:B&&!I&&n!==void 0,...B?{lastSave:D.lastSave}:{},undoSave:Y}}const Lv=(e,t)=>{const n=new Set(e.tiles.map(vo)),r=new Set(t.tiles.map(vo));return[...n].some(s=>!r.has(s))||[...r].some(s=>!n.has(s))};function Nv(e){const{conversion:t,modelPath:n,explicitKind:r,visibleSources:s,...i}=e,o=t?.from,a=t?.to,l=k.useCallback((u,d)=>Gu(o!==void 0&&u===o?a:u,d,{changeKind:!0,...n!==void 0?{modelPath:n}:{},...r?{explicitKind:r}:{},...s?{visibleSources:s}:{}}),[o,a,n,r,s]);return Rv({...i,splice:l,structural:Lv,opensDirty:t!==void 0})}function Fv({editorDirty:e}){const[t,n]=k.useState(!1),r=k.useRef(void 0),s=k.useRef(void 0),i=k.useMemo(()=>({setDirty:n,commitRef:r}),[]),o=k.useCallback(a=>{if(!r.current)return a();if(r.current())return new Promise(l=>{s.current=()=>l(a())})},[]);return k.useEffect(()=>{if(t||!s.current)return;const a=s.current;s.current=void 0,a()},[t,e]),{draftDirty:t,openDraft:i,prepare:o}}const Xu="dashboards/document.malloy",Yu=e=>e.slice(0,e.lastIndexOf("/")+1),Zu=(e,t)=>new URL(e,`https://malloy.invalid/${Yu(t)}`).pathname.slice(1);function zv(e,t){const n=Yu(t).split("/").filter(Boolean),r=e.split("/");let s=0;for(;s<n.length&&s<r.length-1&&n[s]===r[s];)s++;const i=n.length-s;return`${i===0?"./":"../".repeat(i)}${r.slice(s).join("/")}`}function Wv(e,t,n,r=Xu,s=[n]){return e.sources.some(i=>i.base===t)?!0:e.imports.some(i=>i.kind==="names"?i.names.includes(t):s.includes(Zu(i.from,r)))}function Bv(e,t,n,r=Xu,s=[n]){const{imports:i}=e;if(Wv(e,t,n,r,s))return i;const o=i.findIndex(a=>a.kind==="names"&&s.includes(Zu(a.from,r)));return o<0?[...i,{kind:"names",names:[t],from:zv(n,r)}]:i.map((a,l)=>l===o&&a.kind==="names"?{...a,names:[...a.names,t]}:a)}function Gv(e,t,{modelPath:n,textHeld:r,notebook:s,insertAt:i}){t.modelPath&&!r&&(e.imports=Bv(e,t.base,t.modelPath,n,t.exporters??[t.modelPath]));let o=e.sources.find(u=>u.base===t.base);if(!o){const u=new Set(e.sources.map(c=>c.name));let d=`${t.base}_tiles`;for(let c=2;u.has(d);c++)d=`${t.base}_tiles_${c}`;o={name:d,base:t.base},e.sources.push(o)}const a=new Set(e.tiles.filter(xe).filter(u=>u.source===o.name).map(u=>u.name));let l=`${t.view}_tile`;for(let u=2;a.has(l);u++)l=`${t.view}_tile_${u}`;e.tiles.splice(i??e.tiles.length,0,{name:l,source:o.name,declaration:{kind:"reference",from:t.view},...s?{}:{colspan:t.colspan},...t.label?{label:t.label}:{},...t.chart?{chart:t.chart}:{},...t.chartCarried?{chartCarried:t.chartCarried}:{}})}function qv({editor:e,notebook:t,columns:n,modelPath:r,textHeld:s,selectTile:i,deselectTile:o}){const[a,l]=k.useState(void 0),[u,d]=k.useState(!1),[c,f]=k.useState(void 0);return{menu:a,setMenu:l,addingTile:u,openAdd:g=>{f(g),d(!0)},closeAdd:()=>d(!1),addTile:g=>{d(!1),e.update(b=>Gv(b,g,{modelPath:r,textHeld:s,notebook:t,insertAt:c})),i(c??e.document.tiles.length)},addText:()=>{d(!1),e.update(g=>{const b=new Set(g.tiles.filter(je).map(O=>O.name));let _=1;for(;b.has(`text_${_}`);)_++;g.tiles.splice(c??g.tiles.length,0,{kind:"text",name:`text_${_}`,markdown:"",...t?{}:{colspan:n}})}),i(c??e.document.tiles.length)},editTile:(g,b)=>e.update(_=>{const O=_.tiles.find(I=>Fe(I)===g);O&&b(O)}),removeTile:g=>{l(void 0),o(),e.update(b=>{b.tiles.splice(g,1)})}}}var Kv=Object.defineProperty,Uv=Object.defineProperties,Vv=Object.getOwnPropertyDescriptors,jl=Object.getOwnPropertySymbols,Hv=Object.prototype.hasOwnProperty,Xv=Object.prototype.propertyIsEnumerable,Rl=(e,t,n)=>t in e?Kv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sn=(e,t)=>{for(var n in t||(t={}))Hv.call(t,n)&&Rl(e,n,t[n]);if(jl)for(var n of jl(t))Xv.call(t,n)&&Rl(e,n,t[n]);return e},on=(e,t)=>Uv(e,Vv(t));function Yv(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function es(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function Si(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function Zv(e,t,n){var r,s;const{source:i,target:o,canceled:a}=t.operation;if(!i||!o||a)return"preventDefault"in t&&t.preventDefault(),e;const l=(g,b)=>g===b||g!==null&&typeof g=="object"&&"id"in g&&g.id===b;if(Array.isArray(e)){const g=e.findIndex(_=>l(_,i.id)),b=e.findIndex(_=>l(_,o.id));if(g===-1||b===-1){if(Si(i)){const _=i.initialIndex,O=i.index;return _===O||_<0||_>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,_,O)}return e}if(!a&&"index"in i&&typeof i.index=="number"){const _=i.index;if(_!==g)return n(e,g,_)}return n(e,g,b)}const u=Object.entries(e);let d=-1,c,f=-1,p;for(const[g,b]of u)if(d===-1&&(d=b.findIndex(_=>l(_,i.id)),d!==-1&&(c=g)),f===-1&&(f=b.findIndex(_=>l(_,o.id)),f!==-1&&(p=g)),d!==-1&&f!==-1)break;if(d===-1&&Si(i)){const g=i.initialGroup==null?void 0:es(e,i.initialGroup),b=i.initialIndex,_=i.group==null?void 0:es(e,i.group),O=i.index;if(g==null||_==null||g===_&&b===O)return"preventDefault"in t&&t.preventDefault(),e;if(g===_)return on(sn({},e),{[g]:n(e[g],b,O)});const I=e[g][b];return on(sn({},e),{[g]:[...e[g].slice(0,b),...e[g].slice(b+1)],[_]:[...e[_].slice(0,O),I,...e[_].slice(O)]})}if(!i.manager)return e;const{dragOperation:h}=i.manager,m=(s=(r=h.shape)==null?void 0:r.current.center)!=null?s:h.position.current;if(p==null){const g=es(e,o.id);if(g!=null){const b=o.shape&&m.y>o.shape.center.y?e[g].length:0;p=g,f=b}}if(c==null||p==null||c===p&&d===f){if(c!=null&&c===p&&d===f&&Si(i)){const g=i.group==null?void 0:es(e,i.group),b=i.group!=null&&g!==c,_=i.index!==d;if(b||_){const O=i.group==null?c:g;if(O!=null){if(c===O)return on(sn({},e),{[c]:n(e[c],d,i.index)});const I=e[c][d];return on(sn({},e),{[c]:[...e[c].slice(0,d),...e[c].slice(d+1)],[O]:[...e[O].slice(0,i.index),I,...e[O].slice(i.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(c===p)return on(sn({},e),{[c]:n(e[c],d,f)});const w=o.shape&&Math.round(m.y)>Math.round(o.shape.center.y)?1:0,v=e[c][d];return on(sn({},e),{[c]:[...e[c].slice(0,d),...e[c].slice(d+1)],[p]:[...e[p].slice(0,f+w),v,...e[p].slice(f+w)]})}function Qv(e,t){return Zv(e,t,Yv)}function Jv({tiles:e,commit:t,onLanded:n}){const[r,s]=k.useState(void 0),i=k.useRef(void 0),[o,a]=k.useState(!1);return{dragging:o,preview:r,onDragStart:()=>{a(!0),i.current=e},onDragOver:c=>{const{source:f,target:p}=c.operation;if(!f||!p)return;const h=i.current??e;let m;if(p.type===Tu){const{after:y}=p.data,w=h.findIndex(b=>Fe(b)===f.id);if(w<0||y===f.id)return;const g=h.filter((b,_)=>_!==w).findIndex(b=>Fe(b)===y)+1;m=Ig(h,w,g)}else{const y=h.map(Fe),w=Qv(y,c);if(w.every((g,b)=>g===y[b]))return;const v=new Map(h.map(g=>[Fe(g),g]));m=Cg(w.map(g=>v.get(g)),e.map(g=>g.break??!1))}i.current=m,s(m)},onDragEnd:c=>{a(!1);const f=i.current;if(i.current=void 0,s(void 0),c.canceled||!f)return;t(f);const p=f.findIndex(h=>Fe(h)===c.operation.source?.id);p>=0&&n(p)}}}const $i=e=>{const t=window.document.body;t.style.userSelect=e?"none":"",t.style.cursor=e?"grabbing":""};function eb({tiles:e,columns:t,gridBox:n,onStart:r,commit:s}){const[i,o]=k.useState(void 0),a=k.useRef(void 0),l=f=>{a.current=f,o(f)};return k.useEffect(()=>()=>$i(!1),[]),{resize:i,startResize:(f,p)=>{const h=n.current?.getBoundingClientRect(),m=f.currentTarget.parentElement?.getBoundingClientRect();if(!h||!m)return;f.stopPropagation(),f.preventDefault(),f.currentTarget.setPointerCapture(f.pointerId),$i(!0),r(p);const y=e[p]?.colspan??1;l({index:p,span:y,from:y,left:m.left,track:(h.width-E.GRID_GAP_PX*(t-1))/t})},onResize:f=>{const p=a.current;if(!p)return;const h=f.clientX-p.left,m=Math.round((h+E.GRID_GAP_PX)/(p.track+E.GRID_GAP_PX)),y=Math.min(Math.max(m,1),t);y!==p.span&&l({...p,span:y})},endResize:f=>{f.currentTarget.hasPointerCapture(f.pointerId)&&f.currentTarget.releasePointerCapture(f.pointerId),$i(!1);const p=a.current;if(!p)return;const{index:h,span:m,from:y}=p;l(void 0),!(f.type==="pointercancel"||m===y)&&s(h,m)}}}function Qu({source:e,document:t,onSave:n,onChange:r,onDirtyChange:s,onExit:i,renderTile:o,controls:a,givens:l,catalog:u,toolbar:d,dashboards:c,onEvent:f,conversion:p,savesTo:h="package",saveLabel:m,replaces:y,modelPath:w,explicitKind:v,visibleSources:g,addFilterDisabledReason:b}){const _=Nv({source:e,document:t,...n?{onSave:n}:{},...p?{conversion:p}:{},...y!==void 0?{replaces:y}:{},...w!==void 0?{modelPath:w}:{},...v?{explicitKind:v}:{},...g?{visibleSources:g}:{}}),O=k.useRef(null),{selected:I,descriptionSelected:M,selectTile:T,deselectTile:D,selectDescription:N,clearSelection:R,flash:W,stepEditor:X}=Ov({editor:_,gridBox:O}),G=_.document.kind==="notebook",U=G?1:_.document.columns??E.DEFAULT_COLUMNS,Y=G?"none":"card",re=w?.split("/").at(-1)?.replace(/\.malloy$/,""),ee=Jv({tiles:_.document.tiles,commit:ae=>_.update(C=>{C.tiles=ae}),onLanded:T}),{dragging:A}=ee,B=eb({tiles:_.document.tiles,columns:U,gridBox:O,onStart:T,commit:(ae,C)=>_.update(K=>{const ie=K.tiles[ae];ie&&(ie.colspan=C)})}),z=qv({editor:_,notebook:G,columns:U,modelPath:w,textHeld:g!==void 0,selectTile:T,deselectTile:D}),{menu:j,addingTile:q,openAdd:J}=z,Q=Mv({editor:_,opened:t,givens:l,catalog:u}),{filterDialog:H,setFilterDialog:$}=Q,[P,F]=k.useState(void 0),{draftDirty:V,openDraft:oe,prepare:Z}=Fv({editorDirty:_.dirty}),{confirmConversion:ne,prepareSave:de}=jv({pendingOpen:_.pendingOpen,prepare:Z}),se=k.useMemo(()=>({escape:()=>{!j&&!H&&!q&&P===void 0&&ne===void 0&&R()},nudge:ae=>{if(A||I===void 0||G)return;const C=_.document.tiles[I];if(!C||xe(C)&&C.declaration.kind==="inherited")return;const K=E.nudgedSpan(C.colspan??1,ae,U);K!==(C.colspan??1)&&_.update(ie=>{ie.tiles[I].colspan=K})}}),[_,j,H,q,P,ne,R,I,U,G,A]),L=Cv({editor:X,extraDirty:V,prepare:de,unit:{name:"tile",count:ae=>ae.tiles.length},onSave:n,onDirtyChange:s,onExit:i,onChange:r,shortcuts:se,report:bv({size:_.document.tiles.length,notebook:G,savesTo:h,onEvent:f})}),te=_.document.tiles.length===0,pe=x.jsx(_v,{...L.toolbarProps,...d?{actions:d}:{},...u?{onAddTile:()=>J()}:{},savesTo:h,...m?{saveLabel:m}:{}});return x.jsx(fu.Provider,{value:oe,children:x.jsx(S.Stack,{sx:{gap:0,mx:`-${wi}px`},children:x.jsxs(S.Stack,{sx:{gap:2,px:`${wi}px`,pb:`${wi}px`},children:[_.pendingOpen&&x.jsx(S.Alert,{severity:"info",children:"This notebook is in the cell format. Saving rewrites it as a layout notebook, and a named query run once becomes that tile's view."}),x.jsx(vv,{editor:_,notebook:G,documentSlug:re,chrome:Y,actions:pe,descriptionSelected:M,selectDescription:N}),te?x.jsx(x.Fragment,{children:x.jsxs(S.Stack,{sx:{alignItems:"flex-start",gap:1,py:3,px:2,border:1,borderStyle:"dashed",borderColor:"divider",borderRadius:1},children:[x.jsxs(S.Typography,{variant:"body2",children:["This ",G?"notebook":"dashboard"," is not served until it has a tile."]}),u&&x.jsx(S.Button,{size:"small",startIcon:x.jsx(E.AddIcon,{}),onClick:()=>J(),children:"Add tile"})]})}):x.jsx($v,{controls:Q.controlList,tileCount:_.document.tiles.length,unknownFieldsOf:Q.unknownFieldsOf,onEdit:ae=>$({control:ae}),onAdd:()=>$({}),...b?{addDisabledReason:b}:{},onRemove:Q.dropControl,children:a}),_.error&&x.jsx(S.Alert,{severity:"warning",children:_.error}),x.jsx(pv,{editor:_,reorder:ee,resizing:B,gridBox:O,columns:U,notebook:G,chrome:Y,canAdd:!!u,selected:I,flash:W,menuIndex:j?.index,onSelect:T,onOpenMenu:(ae,C)=>{T(C),z.setMenu({anchor:ae,index:C})},openAdd:J,editTile:z.editTile,...o?{renderTile:o}:{}}),x.jsx(Cf,{editor:_,catalog:u,columns:U,dashboards:c,bindings:Q,tiles:z,drillSource:P,setDrillSource:F,confirmConversion:ne,exitDialog:L.exitGuard.dialog})]})})})}function tb(e,t){const n=new Set;for(const i of e.tiles)for(const o of xe(i)?i.filters??[]:[])n.add(o.given);const r=[],s=new Set;for(const i of e.localGivens??[])n.has(i.name)&&(s.add(i.name),r.push(nb(i)));for(const i of t)i.name===void 0||s.has(i.name)||!n.has(i.name)||(s.add(i.name),r.push(i));return r}function nb(e){const t=rb(e);return{name:e.name,type:e.type,...t===void 0?{}:{default:t},...e.label===void 0?{}:{label:e.label},...e.description===void 0?{}:{description:e.description},...e.control===void 0?{}:{control:e.control},...e.suggest?{suggest:{...e.suggest.source===void 0?{}:{source:e.suggest.source},...e.suggest.query===void 0?{}:{query:e.suggest.query},dimension:e.suggest.dimension}}:{},...e.rangeMin===void 0?{}:{rangeMin:e.rangeMin},...e.rangeMax===void 0?{}:{rangeMax:e.rangeMax}}}function rb(e){if(!e.type?.startsWith("filter<"))return e.default;const t=e.default?.match(/^f(['"])([\s\S]*)\1$/)?.[2];return t===void 0?e.default:t===""?void 0:t}function sb(e){return e.kind==="inline"?!0:e.kind==="opaque"&&(e.why.includes("compound")||e.why.includes("pipeline"))}function ts(e){return e.split("->").map(t=>t.trim().replace(/\s+/g," ")).join(" -> ").replace(/\s+/g," ")}function ib(e,t,n,r=new Map,s){if(t.declaration.kind==="inherited")return{expression:`${t.source} -> ${t.name}`,givenNames:void 0,reads:s&&[...s]};const i=t.source,o=t.declaration.kind==="reference"?t.declaration.from:t.name,a=new Map((e.localGivens??[]).map(m=>[m.name,m.type])),l=e.sources.find(m=>m.name===i)?.scopedBy??[],u=new Set([...l,...s??[]].filter(m=>n.has(m))),d=new Set([...l,...s??[]]),c=[];for(const m of t.filters??[]){const y=`where: ${me.malloyPath(m.field)} ${m.op??"~"}`;if(n.has(m.given)){u.add(m.given),d.add(m.given),c.push(`${y} $${m.given}`);continue}if(!a.has(m.given))continue;d.add(m.given);const w=E.malloyLiteral(r.get(m.given),a.get(m.given));w!==void 0&&c.push(`${y} ${w}`)}const f=c.join(", "),p=t.chart,h=p==="none"||Qs(p)?yn(p,t.chartCarried):p==="custom"&&t.chartLines?.length?t.chartLines.join(`
|
|
143
|
-
`):
|
|
144
|
-
`);async function
|
|
145
|
-
`).length-1,"a carriage return that is not part of a CRLF line ending, so the cells cannot be located. Fix: save the file with LF or CRLF line endings.");let r,s;try{r=await
|
|
146
|
-
`,...
|
|
147
|
-
`||e[
|
|
148
|
-
${
|
|
135
|
+
`;a.push({start:b,end:b,text:w+f.join(`
|
|
136
|
+
`)})}}const ns=(e,t=ge.isBareName)=>t(e)?void 0:`The name ${JSON.stringify(e)} cannot be written as a Malloy name.`;function rv(e,t){const n=new Map(e.tiles.map(o=>[tt(o),o]));if(t.layout==="linear"&&t.columns!==void 0&&t.columns!==e.columns)return"A linear report is one column, so its width is not written.";const r=new Set;for(const o of t.tiles){const a=n.get(tt(o));if(Re(o)){const c=tv(o,a&&Re(a)?a:void 0,r);if(c)return c;continue}const l=a&&xe(a)?a:void 0;if(a&&!l)continue;const d=o.chart;if(d!==void 0&&d!=="default"&&d!=="none"&&!ni(d)&&!(d==="custom"&&l?.chart==="custom"))return`"${String(d)}" is not a chart this editor writes.`;const u=new Set(l?.filters?.map(c=>c.field));for(const c of o.filters??[])if(!u.has(c.field)&&/[\r\n]/.test(c.field))return"A filter field is one line.";if(a===void 0){const c=[o.name,o.source];o.declaration.kind==="reference"&&c.push(o.declaration.from);for(const f of c){const h=ns(f);if(h)return h}}for(const c of["label","subtitle"]){const f=o[c];if(f===void 0||f===l?.[c])continue;const h=O.annotationTextProblem(`tile ${c}`,f);if(h)return h}}const s=new Set(e.sources.map(o=>o.name));for(const o of t.sources)if(!s.has(o.name))for(const a of[o.name,o.base]){const l=ns(a);if(l)return l}if(t.description!==e.description)for(const o of(t.description??"").split(/\r?\n/)){const a=O.annotationTextProblem("description line",o);if(a)return a}if(t.title!==e.title){const o=O.annotationTextProblem("title",t.title);if(o)return o}const i=new Map((e.localGivens??[]).map(o=>[o.name,o]));for(const o of t.localGivens??[]){const a=i.get(o.name);if(a===void 0){const d=ns(o.name,ge.isStrictName);if(d)return d}const l=o.suggest?.source;if(l!==void 0&&l!==a?.suggest?.source){const d=ns(l);if(d)return`The suggest source is not a name. ${d}`}for(const d of["query","dimension"]){const u=o.suggest?.[d];if(u===void 0||u===a?.suggest?.[d])continue;const c=O.annotationTextProblem(`suggest ${d}`,u);if(c)return c}for(const d of["label","description"]){const u=o[d];if(u===void 0||u===i.get(o.name)?.[d])continue;const c=O.annotationTextProblem(`given ${d}`,u);if(c)return c}}for(const[o,a]of Object.entries(t.startingGivens??{})){if(a===e.startingGivens?.[o])continue;const l=O.annotationTextProblem(`starting value for ${o}`,a);if(l)return l}}const xt=(e,t)=>e.lineStarts.findLastIndex(n=>n<=t);function Wd(e,t){return e.parsed.sources.find(n=>n.name===t.source)?.views.find(n=>n.name===t.name)}function Bd(e,t){if(!t)return;const n=new Set;for(const r of t.wheres)for(const s of r.clauses)if(!s.binding)for(const i of s.givens)n.add(i);return(e??[]).find(r=>n.has(r.given))}function Gd(e,t){return{ok:!1,reason:`\`${e}\` already filters on \`$${t}\` in a \`where:\` the builder does not manage, so binding it again would filter on it twice. Edit that \`where:\` in the file instead.`}}const ws=e=>`where: ${ge.malloyPath(e.field)} ${e.op??"~"} $${e.given}`;function Cl(e,t,n){return{ok:!1,reason:`Removing a filter from \`${e}\` would also remove the comment written beside it (\`${t.text.slice(n.start,n.end).trim()}\`), so nothing was written. Delete it in the file first.`}}function sv(e,t,n){const r=e.commentIn(n);if(r)return r;const s=e.trailingComment(xt(e,t.end-1));return s&&s.start>=t.end&&e.text.slice(t.end,s.start).trim()===""?s:void 0}function iv(e,t){const n=e[t].span;return t+1<e.length?{start:n.start,end:e[t+1].span.start}:t>0?{start:e[t-1].span.end,end:n.end}:n}function Ta(e,t){const n=e.lineStarts[e.lineStarts.findLastIndex(a=>a<=t.start)],r=e.text.slice(n,t.start),s=e.text.indexOf(`
|
|
137
|
+
`,t.end),i=e.text.slice(t.end,s<0?void 0:s);if(r.trim()===""&&i.trim()==="")return{start:n,end:s<0?e.text.length:s+1};if(r.trim()===""){const a=/^\s*/.exec(i)?.[0].length??0;return{start:t.start,end:t.end+a}}const o=r.replace(/[\s,]*$/,"");return{start:n+o.length,end:t.end}}function qd(e,t,n){const{parsed:r,edits:s}=e,i=new Map((t.filters??[]).map(f=>[f.given,f])),o=new Set;let a;for(const f of n.wheres){const h=f.clauses.map((m,b)=>({clause:m,index:b})).filter(({clause:m})=>m.binding!==void 0);if(h.length===0)continue;const p=h.filter(({clause:m})=>i.has(m.binding.given));for(const{clause:m}of h)o.add(m.binding.given);if(p.length===0&&h.length===f.clauses.length){const m=Ta(r,f.span),b=sv(r,f.span,m);if(b)return Cl(t.name,r,b);s.push({...m,text:""});continue}p.length>0&&(a=f.span);for(let m=h.length-1;m>=0;m--){const{clause:b,index:w}=h[m],v=i.get(b.binding.given);if(!v){const y=iv(f.clauses,w),_=r.commentIn(y);if(_)return Cl(t.name,r,_);s.push({...y,text:""});continue}const g=ws(v).replace(/^where:\s*/,"");g!==r.text.slice(b.span.start,b.span.end)&&s.push({...b.span,text:g})}}const l=(t.filters??[]).filter(f=>!o.has(f.given));if(l.length===0)return;let d=a?.end??(n.statements.length>0?n.statements[n.statements.length-1].span.end:n.openEnd);if(!n.oneLine){const f=r.trailingComment(xt(r,d));f&&f.start>=d&&(d=f.end)}const u=a!==void 0&&!/,\s*$/.test(r.text.slice(0,d))?", ":" ",c=n.oneLine?`${u}${l.map(ws).join(", ")}`:l.map(f=>`
|
|
138
|
+
${n.indent}${ws(f)}`).join("");s.push({start:d,end:d,text:c})}function ov(e,t,n){if(n.body.kind!=="reference")return;const{edits:r}=e,{fromSpan:s,refinement:i}=n.body,o=Bd(t.filters,i);if(o)return Gd(t.name,o.given);const a=t.filters??[];if(!i){if(a.length===0)return;const u=` + { ${a.map(ws).join(", ")} }`;r.push({start:s.end,end:s.end,text:u});return}const l=i.wheres.some(u=>u.clauses.some(c=>!c.binding)),d=i.statements.some(u=>!i.wheres.some(c=>c.span.start===u.span.start));if(a.length===0&&!l&&!d){const u={start:s.end,end:i.span.end},c=e.parsed.commentIn(u);if(c)return{ok:!1,reason:`Removing the last filter from \`${t.name}\` would also remove the comment beside its refinement (\`${e.parsed.text.slice(c.start,c.end).trim()}\`), so nothing was written. Delete it in the file first, or edit the refinement there.`};r.push({...u,text:""});return}return qd(e,t,i)}async function Kd(e,t,n={}){if(!(e.includes(`\r
|
|
139
|
+
`)&&!/(?<!\r)\n/.test(e)))return Il(e,t,n);const s=await Il(e.replace(/\r\n/g,`
|
|
140
|
+
`),t,n);return zs(s)?s:{...s,source:s.source.replace(/\n/g,`\r
|
|
141
|
+
`)}}async function Il(e,t,n){const r=await Cr(e);if(Er(r))return{ok:!1,reason:`Cannot edit a file that will not open: ${r.reason}`};const s=r.document,i=ev(s,t),o=Wm(s,i,n.visibleSources);if("reason"in o)return o;const a=rv(s,i);if(a)return{ok:!1,reason:a};const l=await Pd(e);if(Dd(l))return{ok:!1,reason:`Cannot edit a file that will not open: ${l.reason}`};const d=e.split(`
|
|
142
|
+
`),u=jm(e),c=v=>({start:u[v],end:v+1<u.length?u[v+1]:e.length}),f=v=>/^\s*/.exec(d[v])?.[0]??"",h=[],p={...o,sourceText:e,parsed:l.parsed,lines:d,starts:u,wholeLine:c,indentOf:f,current:s,next:i,edits:h};for(const v of[Gm,Um,Xm,Hm,Ym,Zm,Qm,Jm,nv]){const g=v(p);if(g)return g}const m=v=>{const{drills:g,localGivens:y,description:_,...S}=v,E=v.tiles.map(A=>{if(Re(A))return A;if(A.filters?.length)return Bs(A);const{filters:T,...D}=A;return Bs(D)});return{...S,..._===void 0?{}:{description:Ld(_)},tiles:E,...g?.length?{drills:[...g].sort((A,T)=>Ws(A).localeCompare(Ws(T)))}:{},...y?.length?{localGivens:y}:{}}};if(h.length===0)return _e(m(s))!==_e(m(i))?{ok:!1,reason:"No part of this edit was recognized, so nothing was written. Your changes are still here."}:{ok:!0,source:e};const b=Lm(e,h);if((await xl(e)).length===0){const v=await xl(b);if(v.length>0)return{ok:!1,reason:`The edit would have produced a file Malloy cannot parse, so it was not written (${v[0]}). Your changes are still here.`}}const w=await Cr(b);return Er(w)?{ok:!1,reason:`The edit produced a file that cannot be read back: ${w.reason}`}:_e(m(w.document))!==_e(m(i))?{ok:!1,reason:"What was written did not read back as what was asked for, so it was not written. Your changes are still here."}:{ok:!0,source:b}}function Vd({markdown:e,placeholder:t,onCommit:n,variant:r="document"}){const{theme:s}=Be.usePublisherTheme(),[i,o]=k.useState(!1),a=k.useMemo(()=>i?{text:e}:void 0,[i,e]),{draft:l,patch:d,close:u,discard:c}=Vl(a,i,g=>n(g.text),()=>o(!1)),f=i&&l!==void 0&&l.text!==e,h=l!==void 0&&l.text!==e?xs(l.text):void 0;pd(f,()=>h!==void 0?!1:(u(),!0));const p=k.useRef(null),m=k.useRef(!1);k.useEffect(()=>{i||(m.current=!1)},[i]);const b=k.useCallback(g=>{!g||m.current||(m.current=!0,g.setSelectionRange(g.value.length,g.value.length))},[]);if(!i||l===void 0){const g=e.trim()?xs(e):void 0;return x.jsxs($.Box,{role:"button",tabIndex:0,onClick:y=>{y.target.closest("a")?y.preventDefault():o(!0)},onKeyDown:y=>{y.target===y.currentTarget&&(y.key!=="Enter"&&y.key!==" "||(y.preventDefault(),o(!0)))},sx:[{minHeight:24},fd(s,"prose")],children:[e.trim()?x.jsx(O.Prose,{variant:r,children:e}):x.jsx($.Typography,{variant:"body2",sx:{color:s.tileTitle,opacity:.6,fontStyle:"italic"},children:t}),g&&x.jsx($.Typography,{variant:"caption",color:"error",role:"alert",children:g})]})}const w=l.text!==e?xs(l.text):void 0,v=()=>{w===void 0&&u()};return x.jsxs($.Stack,{spacing:1,children:[x.jsx($.TextField,{multiline:!0,autoFocus:!0,minRows:3,maxRows:14,fullWidth:!0,value:l.text,placeholder:t,error:w!==void 0,helperText:w,inputRef:b,inputProps:{"aria-label":"Markdown"},onChange:g=>d(y=>{y.text=g.target.value}),onKeyDown:g=>{g.key==="Escape"?v():g.key==="Enter"&&(g.metaKey||g.ctrlKey)&&(g.preventDefault(),v())},onBlur:g=>{g.relatedTarget instanceof Node&&p.current?.contains(g.relatedTarget)||u()}}),x.jsxs($.Stack,{ref:p,direction:"row",spacing:1,children:[x.jsx($.Button,{size:"small",variant:"outlined",disabled:w!==void 0,onClick:v,children:"Done"}),x.jsx($.Button,{size:"small",onMouseDown:g=>g.preventDefault(),onClick:()=>{c(),o(!1)},children:"Cancel"})]})]})}const av="Write markdown: # heading, **bold**, - list";function lv({tile:e,onChange:t,chrome:n="card"}){return x.jsx(O.TileCard,{chrome:n,kind:"text",children:x.jsx(Vd,{markdown:e.markdown,placeholder:av,onCommit:t})})}const Gs=e=>e.label??O.tileTitle(`${e.source} -> ${e.name}`);function cv({tile:e,index:t,selected:n,flash:r=!1,menuOpen:s,bare:i=!1,onInsertAfter:o,onSelect:a,onOpenMenu:l,resizing:d=!1,width:u,onResizeStart:c,onResizeMove:f,onResizeEnd:h,children:p}){const{theme:m}=Be.usePublisherTheme();return x.jsx(om,{id:Fe(e),index:t,children:({ref:b,handleRef:w})=>x.jsxs($.Box,{ref:b,onClick:a,onPointerDown:v=>{v.button===0&&a()},role:"group","aria-label":`Tile ${e.name}`,"aria-current":n,onFocus:a,"data-tile-key":Fe(e),"data-flash":r||void 0,sx:{position:"relative",display:"grid",minWidth:0,cursor:"grab",...Ud(m,{selected:n,flash:r,bare:i}),"&&[data-dnd-dragging]":{opacity:1,outline:"none",boxShadow:m.shadow.drag},"&&[data-dnd-placeholder]":{opacity:.45,outline:`2px dashed ${m.accent}`,boxShadow:"none"},"&:hover .builder-affordance, &:focus-within .builder-affordance":{opacity:1},"@media (hover: none)":{"& .builder-affordance":{opacity:1}}},children:[p,x.jsx($.Box,{ref:w,"aria-label":`Move ${Kr(e)}`,sx:{position:"absolute",width:"1px",height:"1px",overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"}}),x.jsx($.IconButton,{className:"builder-affordance",size:"small","aria-label":`Settings for ${Kr(e)}`,onClick:v=>{v.stopPropagation(),l(v.currentTarget)},sx:{position:"absolute",top:`${-((i?O.BARE_RING_OFFSET_PX+1:0)+12)}px`,right:i?0:"12px",border:m.cardBorder,borderRadius:1,width:28,height:24,zIndex:2,color:m.tileTitle,bgcolor:m.tile,opacity:n||s?.9:0,transition:`opacity ${O.MOTION_FAST}`,...O.reducedMotionSx,"&:hover":{opacity:1,bgcolor:m.tile}},children:x.jsx(hv,{})}),c&&x.jsx($.Box,{className:"builder-affordance",[Ed]:"",role:"separator",tabIndex:u?0:-1,"aria-orientation":"vertical","aria-label":`Width of ${Kr(e)}`,...u?{"aria-valuenow":u.span,"aria-valuemin":1,"aria-valuemax":u.columns,"aria-valuetext":`${u.span} of ${u.columns} columns`}:{},onKeyDown:v=>{if(!u)return;const g=v.key==="ArrowRight"?u.span+1:v.key==="ArrowLeft"?u.span-1:v.key==="Home"?1:v.key==="End"?u.columns:void 0;g!==void 0&&(v.preventDefault(),v.stopPropagation(),u.onStep(Math.min(Math.max(g,1),u.columns)))},onPointerDown:c,onPointerMove:f,onPointerUp:h,onPointerCancel:h,onClick:v=>v.stopPropagation(),sx:{position:"absolute",top:0,bottom:0,right:"-5px",width:"10px",cursor:"col-resize",touchAction:"none",zIndex:2,opacity:d||n?1:0,transition:`opacity ${O.MOTION_FAST}`,...O.reducedMotionSx,"&:hover":{opacity:1},"&:focus-visible":{opacity:1,outline:`2px solid ${m.accent}`,outlineOffset:1,borderRadius:"3px"},"&::after":{content:'""',position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"4px",height:"28px",borderRadius:"2px",bgcolor:m.accent}}}),o&&x.jsx($.IconButton,{className:"builder-affordance",size:"small","aria-label":`Insert tile after ${Kr(e)}`,onClick:v=>{v.stopPropagation(),o()},sx:{position:"absolute",bottom:`-${(i?O.NOTEBOOK_GAP_PX:O.GRID_GAP_PX)/2+12}px`,left:"50%",transform:"translateX(-50%)",width:24,height:24,zIndex:3,color:m.tileTitle,bgcolor:m.tile,border:m.cardBorder,opacity:0,transition:`opacity ${O.MOTION_FAST}`,...O.reducedMotionSx,"&:hover, &:focus-visible":{opacity:1,bgcolor:m.tile}},children:x.jsx(O.AddIcon,{sx:{fontSize:14}})})]})})}const Si=4,Ud=(e,{selected:t,flash:n=!1,bare:r=!1})=>{const s=t||n?e.accent:"transparent",i=t?e.accent:e.cardBorder.replace(/^1px solid /,""),o=`outline-color ${O.MOTION_FAST}, border-color ${O.MOTION_FAST}, opacity ${O.MOTION_FAST}, box-shadow ${O.MOTION_FAST}`;return r?{borderRadius:1,"&::before":{content:'""',position:"absolute",inset:`${-O.BARE_RING_OFFSET_PX}px`,borderRadius:1,border:`2px solid ${s}`,pointerEvents:"none",transition:o,...O.reducedMotionSx},"&:hover::before":{borderColor:i}}:{borderRadius:1,outline:`2px solid ${s}`,outlineOffset:2,...n&&{boxShadow:`0 0 0 6px color-mix(in srgb, ${e.accent} 25%, transparent)`},transition:o,...O.reducedMotionSx,"&:hover":{outlineColor:i,boxShadow:e.shadow.lift}}};function uv({tile:e,heading:t,note:n,chrome:r="card"}){const{theme:s}=Be.usePublisherTheme();return x.jsxs(O.TileCard,{chrome:r,children:[x.jsx(O.TileHeading,{title:t?.title??Gs(e),subtitle:t?t.subtitle:e.subtitle}),n&&x.jsx($.Typography,{variant:"body2",sx:{color:s.tileTitle,py:2},children:n}),x.jsxs($.Typography,{variant:"caption",sx:{display:"block",color:s.tileTitle,opacity:.7},children:[e.source," → ",e.name]})]})}function dv({after:e}){const{theme:t}=Be.usePublisherTheme();return x.jsx(am,{id:md(e),after:e,children:({ref:n,isDropTarget:r})=>x.jsx($.Box,{ref:n,"aria-hidden":!0,sx:{minHeight:48,borderRadius:1,border:`1px dashed ${t.accent}`,bgcolor:r?`color-mix(in srgb, ${t.accent} 12%, transparent)`:"transparent",opacity:r?.95:.4,transition:`opacity ${O.MOTION_FAST}, background-color ${O.MOTION_FAST}`,...O.reducedMotionSx}})})}function fv({columns:e}){const{theme:t}=Be.usePublisherTheme();return x.jsx($.Box,{"aria-hidden":!0,sx:{position:"absolute",inset:0,pointerEvents:"none",zIndex:3,display:"grid",gridTemplateColumns:`repeat(${e}, minmax(0, 1fr))`,gap:`${O.GRID_GAP_PX}px`},children:Array.from({length:e},(n,r)=>x.jsx($.Box,{sx:{borderLeft:`1px dashed ${t.accent}`,borderRight:r===e-1?`1px dashed ${t.accent}`:"none",opacity:.35}},r))})}function hv(){return x.jsxs($.SvgIcon,{sx:{fontSize:18},viewBox:"0 0 24 24",children:[x.jsx("circle",{cx:"3.5",cy:"12",r:"2"}),x.jsx("circle",{cx:"12",cy:"12",r:"2"}),x.jsx("circle",{cx:"20.5",cy:"12",r:"2"})]})}function pv({editor:e,reorder:t,resizing:n,gridBox:r,columns:s,notebook:i,chrome:o,canAdd:a,selected:l,flash:d,menuIndex:u,onSelect:c,onOpenMenu:f,openAdd:h,editTile:p,renderTile:m}){const{dragging:b,preview:w,onDragStart:v,onDragOver:g,onDragEnd:y}=t,{resize:_,startResize:S,onResize:E,endResize:A}=n,T=_!==void 0?e.document.tiles.map((z,U)=>U===_.index?{...z,colspan:_.span}:z):w??e.document.tiles,D=e.document.tiles.length===0,q=b?Og(T,s):T.map(gd),P=z=>gv(z,Gs(z),p);return x.jsxs(x.Fragment,{children:[x.jsx(lg,{sensors:sm,onDragStart:v,onDragOver:g,onDragEnd:y,children:x.jsxs($.Box,{ref:r,sx:{position:"relative"},children:[!i&&(b||_!==void 0)&&x.jsx(fv,{columns:s}),x.jsx(O.DashboardGrid,{tiles:q,columns:s,rowGapPx:o==="none"?O.NOTEBOOK_GAP_PX:O.GRID_GAP_PX,keyOf:z=>z.kind==="gap"?md(z.after):Fe(z.tile),renderTile:z=>{if(z.kind==="gap")return x.jsx(dv,{after:z.after});const{tile:U,index:K}=z;return x.jsx(cv,{tile:U,index:K,selected:K===l,flash:Fe(U)===d,menuOpen:u===K,bare:o==="none",...i&&a?{onInsertAfter:()=>h(K+1)}:{},...s>1&&mv(U)?{resizing:_?.index===K,width:{span:U.colspan??1,columns:s,onStep:Z=>{Z!==(U.colspan??1)&&e.update(J=>{const ie=J.tiles[K];ie&&(ie.colspan=Z)})}},onResizeStart:Z=>S(Z,K),onResizeMove:E,onResizeEnd:A}:{},onSelect:()=>c(K),onOpenMenu:Z=>f(Z,K),children:Re(U)?x.jsx(lv,{tile:U,chrome:o,onChange:Z=>p(Fe(U),J=>{Re(J)&&(J.markdown=Z)})}):m&&!e.pendingOpen?m(U,P(U),o):x.jsx(uv,{tile:U,chrome:o,heading:P(U),...e.pendingOpen?{note:"Preview appears after you Save"}:{}})})}})]})}),i&&a&&!D&&x.jsx($.Button,{size:"small",startIcon:x.jsx(O.AddIcon,{}),"aria-label":"Add tile at the end",onClick:()=>h(),sx:{alignSelf:"center"},children:"Add tile"})]})}const gv=(e,t,n)=>{if(e.declaration.kind==="inherited")return;const r=Fe(e),s=i=>o=>n(r,a=>{xe(a)&&(o===""?delete a[i]:a[i]=o)});return{title:x.jsx(go,{value:e.label??"",placeholder:t,ariaLabel:"Tile title",onCommit:s("label")}),subtitle:x.jsx(go,{value:e.subtitle??"",placeholder:"Add a subtitle",ariaLabel:"Tile subtitle",faintWhenEmpty:!0,onCommit:s("subtitle")})}},mv=e=>Re(e)||e.declaration.kind!=="inherited";function vv({editor:e,documentSlug:t,chrome:n,actions:r,descriptionSelected:s,selectDescription:i}){const{theme:o}=Be.usePublisherTheme();return x.jsxs(x.Fragment,{children:[x.jsxs($.Stack,{direction:"row",sx:{alignItems:"center",gap:2},children:[x.jsx($.Typography,{variant:"h5",sx:{flex:1,minWidth:0},children:x.jsx(go,{value:e.document.title,placeholder:t??"Untitled report",ariaLabel:"Report title",onCommit:a=>e.update(l=>{l.title=a})})}),x.jsx($.Box,{sx:{my:"-4px"},children:r})]}),x.jsx($.Box,{role:"group","aria-label":"Description","aria-current":s,onPointerDown:i,onFocus:i,sx:n==="none"?{my:`${O.BARE_DESCRIPTION_MARGIN_PX}px`}:void 0,children:x.jsx(O.TileCard,{chrome:n,kind:"text",sx:{position:"relative",overflow:"visible",...Ud(o,{selected:s,bare:n==="none"})},children:x.jsx(Vd,{markdown:e.document.description??"",placeholder:"Add a description",onCommit:a=>e.update(l=>{a.trim()===""?delete l.description:l.description=a})})})})]})}const yv=({size:e,path:t,layout:n,savesTo:r,onEvent:s})=>{const{emit:i}=O.reportEmitter({path:t,layout:n},s);return{size:e,saved:({size:o,structural:a,durationMs:l,fromOpen:d})=>i({type:"report.saved",tiles:o,structural:a,...d?{converted:!0}:{},where:r,durationMs:l}),refused:o=>i({type:"report.save_refused",reason:o}),undone:({size:o,structural:a,durationMs:l})=>i({type:"report.save_undone",tiles:o,structural:a,where:r,durationMs:l}),undoRefused:o=>i({type:"report.save_undo_refused",reason:o})}},bv=O.createSvgIcon(x.jsx("path",{d:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7z"})),xv=O.createSvgIcon(x.jsx("path",{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8"})),wo=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),$i=wo?"⌘":"Ctrl+",Dl=e=>{if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"},Ti=e=>e instanceof Element&&e.closest('[role="dialog"], .MuiPopover-root, .MuiDialog-root')!==null;function wv(e){const t=k.useRef(e);k.useEffect(()=>{t.current=e});const[n,r]=k.useState(!1);k.useEffect(()=>{n&&(r(!1),t.current.save?.())},[n]),k.useEffect(()=>{const s=i=>{const o=t.current;if(o.paused)return;const a=wo?i.metaKey:i.ctrlKey,l=i.key.toLowerCase();if(i.key==="Escape"){if(Dl(i.target)||Ti(i.target))return;o.escape();return}if(Dl(i.target)){if(a&&l==="s"){if(i.preventDefault(),!o.save||Ti(i.target))return;i.target.blur(),r(!0)}return}if(Ti(i.target)){a&&l==="s"&&i.preventDefault();return}if(a&&l==="z"){i.preventDefault(),i.shiftKey?o.redo():o.undo();return}if(!wo&&a&&l==="y"){i.preventDefault(),o.redo();return}if(a&&l==="s"){i.preventDefault(),o.save?.();return}o.nudge&&!a&&!i.altKey&&!i.shiftKey&&(i.key==="ArrowLeft"||i.key==="ArrowRight")&&(i.preventDefault(),o.nudge(i.key==="ArrowRight"?1:-1))};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[])}const Al={package:"Saves to the package file",browser:"Saves in this browser",host:"Saves to the app this is embedded in"};function _v({canUndo:e,canRedo:t,onUndo:n,onRedo:r,dirty:s,saving:i,onSave:o,savesTo:a="package",saveLabel:l,saveButton:d,actions:u,onAddTile:c,onExit:f,layout:h,onLayoutChange:p}){return x.jsxs($.Stack,{direction:"row","aria-label":"Builder actions",sx:{alignItems:"center",gap:.5,flexShrink:0,"& .MuiButton-root":{whiteSpace:"nowrap"}},children:[h&&p&&x.jsxs(x.Fragment,{children:[x.jsx($.Tooltip,{title:"Layout: tiles side by side, or one after another",children:x.jsxs($.ToggleButtonGroup,{size:"small",exclusive:!0,value:h,"aria-label":"Layout",onChange:(m,b)=>{b&&b!==h&&p(b)},sx:{"& .MuiToggleButton-root":{py:.25,px:1}},children:[x.jsx($.ToggleButton,{value:"linear","aria-label":"Linear layout",children:"Linear"}),x.jsx($.ToggleButton,{value:"grid","aria-label":"Grid layout",children:"Grid"})]})}),x.jsx($.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5}})]}),c&&x.jsx($.Button,{startIcon:x.jsx(O.AddIcon,{}),onClick:c,"aria-label":"Add tile",children:"Tile"}),c&&x.jsx($.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),x.jsx($.Tooltip,{title:`Undo (${$i}Z)`,children:x.jsx("span",{children:x.jsx($.IconButton,{"aria-label":"Undo",disabled:!e,onClick:n,sx:{width:37,height:37},children:x.jsx(xv,{fontSize:"small"})})})}),x.jsx($.Tooltip,{title:`Redo (${$i}⇧Z)`,children:x.jsx("span",{children:x.jsx($.IconButton,{"aria-label":"Redo",disabled:!t,onClick:r,sx:{width:37,height:37},children:x.jsx(bv,{fontSize:"small"})})})}),(u||o||f)&&x.jsx($.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),u,o?x.jsx($.Tooltip,{title:s?`Save (${$i}S) · ${l??Al[a]}`:l??Al[a],children:x.jsx("span",{children:x.jsx($.Button,{ref:d,variant:s?"contained":"outlined",disabled:!s||i,onClick:o,sx:{minWidth:124},children:i?"Saving…":s?"Save":"Saved"})})}):null,o&&x.jsx($.Box,{component:"span","aria-live":"polite",sx:{position:"absolute",width:"1px",height:"1px",overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"},children:i?"Saving":s?"Unsaved changes":"All changes saved"}),f&&x.jsx(O.SecondaryButton,{label:"Close",icon:x.jsx(O.CheckIcon,{}),onClick:f})]})}const kv=O.createSvgIcon(x.jsx("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2m5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12z"})),Sv=O.createSvgIcon(x.jsx("path",{d:"M10 18h4v-2h-4zM3 6v2h18V6zm3 7h12v-2H6z"}));function $v({controls:e,tileCount:t,unknownFieldsOf:n,onEdit:r,onAdd:s,addDisabledReason:i,onRemove:o,children:a}){const{theme:l}=Be.usePublisherTheme();return x.jsx(x.Fragment,{children:x.jsxs($.Stack,{sx:{gap:1,position:"sticky",top:0,zIndex:O.STICKY_CONTROLS_Z,bgcolor:"background.default",pb:1},children:[x.jsx($.Stack,{direction:"row",sx:{gap:2,alignItems:"center",minHeight:32},children:x.jsxs($.Stack,{direction:"row",role:"group","aria-label":"Filters",sx:{gap:1,alignItems:"center",flexWrap:"wrap",flex:1,minWidth:0},children:[x.jsx(Sv,{sx:{fontSize:18,color:l.tileTitle,opacity:.7}}),x.jsx($.Typography,{variant:"subtitle2",sx:{color:l.tileTitle,mr:.5},children:"Filters"}),e.length===0&&x.jsx($.Typography,{variant:"body2",sx:{color:l.tileTitle,opacity:.8},children:"None yet."}),e.map(d=>{const u=n(d.name,d.type);return x.jsx($.Tooltip,{title:u.length>0?`$${d.name} · cannot filter on: ${u.join(", ")}`:`$${d.name} · ${d.origin==="dashboard"?"declared here":"from the model"} · ${d.boundTiles} of ${t} tiles`,children:x.jsx($.Chip,{size:"small",label:`${d.label??d.name}${d.boundTiles===0?" · unused":""}`,"aria-label":`Edit filter ${d.name}`,color:u.length>0?"warning":"default",variant:d.origin==="dashboard"?"filled":"outlined",onClick:()=>r(d),onDelete:()=>o(d.name),deleteIcon:x.jsx(kv,{"aria-label":`Remove filter ${d.name}`}),sx:{opacity:d.boundTiles===0?.6:1,cursor:"pointer",transition:`opacity ${O.MOTION_FAST}`,...O.reducedMotionSx}})},d.name)}),x.jsx($.Tooltip,{title:i??"",children:x.jsx("span",{children:x.jsx($.Chip,{component:"button",size:"small",variant:"outlined",icon:x.jsx(O.AddIcon,{}),label:"Filter","aria-label":"Add filter","aria-haspopup":"dialog",disabled:i!==void 0,onClick:()=>s(),sx:{cursor:"pointer",color:l.tileTitle,borderStyle:"dashed","& .MuiChip-icon":{color:"inherit",fontSize:16}}})})})]})}),a]})})}function Tv(e,t){const n=new Map(e.tiles.map((r,s)=>[Fe(r),{tile:r,index:s}]));for(const[r,s]of t.tiles.entries()){const i=n.get(Fe(s));if(!i||i.index!==r||JSON.stringify(i.tile)!==JSON.stringify(s))return Fe(s)}}function Ov({editor:e,gridBox:t}){const[n,r]=k.useState(void 0),s=typeof n=="object"?n.tile:void 0,i=n==="description",o=k.useCallback(m=>r(b=>typeof b=="object"&&b.tile===m?b:{tile:m}),[]),a=k.useCallback(()=>r(m=>m==="description"?m:void 0),[]),l=k.useCallback(()=>r("description"),[]),d=k.useCallback(()=>r(void 0),[]),[u,c]=k.useState(void 0),f=k.useRef(!1),h=k.useRef(e.document);k.useEffect(()=>{const m=h.current;if(h.current=e.document,!f.current)return;f.current=!1;const b=Tv(m,e.document);if(b===void 0)return;c(b),Array.from(t.current?.querySelectorAll("[data-tile-key]")??[]).find(v=>v.dataset.tileKey===b)?.scrollIntoView?.({block:"nearest",behavior:O.scrollBehavior()})},[e.document,t]),k.useEffect(()=>{if(u===void 0)return;const m=setTimeout(()=>c(void 0),1500);return()=>clearTimeout(m)},[u]);const p=k.useMemo(()=>({...e,undo:()=>{f.current=!0,e.undo()},redo:()=>{f.current=!0,e.redo()}}),[e]);return{selected:s,descriptionSelected:i,selectTile:o,deselectTile:a,selectDescription:l,clearSelection:d,flash:u,stepEditor:p}}function Ev({dirty:e,saving:t,canSave:n,save:r,onExit:s}){const[i,o]=k.useState("idle"),[a,l]=k.useState(!1),d=k.useRef(r);d.current=r;const u=k.useRef(s);u.current=s;const c=k.useRef(0),f=k.useCallback(async()=>{const p=++c.current;l(!1),o("saving");try{await d.current()}catch{c.current===p&&o("idle");return}c.current===p&&l(!0)},[]);return k.useEffect(()=>{if(i==="waiting"){if(t)return;e?f():(o("idle"),u.current())}else if(i==="saving"){if(!a||t)return;o("idle"),e||u.current()}},[i,a,t,e,f]),{requestExit:k.useCallback(()=>{i==="idle"&&(e?o("asking"):u.current())},[i,e]),dialog:{open:i==="asking",canSave:n,onKeepEditing:()=>{i==="asking"&&o("idle")},onDiscard:()=>{i==="asking"&&(o("idle"),u.current())},onSaveAndExit:()=>{i==="asking"&&(t?o("waiting"):f())}}}}function Cv({editor:e,onSave:t,onDirtyChange:n,onExit:r,onChange:s,extraDirty:i=!1,report:o,unit:a,prepare:l,shortcuts:d}){const[u,c]=k.useState(!1),[f,h]=k.useState(!1),p=k.useRef(null),m=k.useRef(o);m.current=o;const b=e.dirty||i,w=(e.edited??e.dirty)||i;k.useEffect(()=>{s?.(e.document)},[e.document,s]),k.useLayoutEffect(()=>{n?.(w)},[w,n]);const v=k.useRef(n);v.current=n,k.useEffect(()=>()=>v.current?.(!1),[]);const g=k.useRef(a);g.current=a,k.useEffect(()=>{h(!1)},[e.document]);const y=k.useCallback(()=>{c(!0),h(!1);const K=O.now(),{structural:Z}=e,J=e.pendingOpen??!1,ie=m.current.size;return e.save().then(de=>{de.ok===!0?m.current.saved({size:ie,structural:Z,fromOpen:J,durationMs:O.now()-K}):m.current.refused(de.reason)}).finally(()=>c(!1))},[e]),_=k.useRef(!1),S=k.useRef(!1);k.useEffect(()=>{!S.current||u||(S.current=!1,p.current?.focus())},[f,u]);const E=k.useCallback(()=>{if(!t||u||_.current||!e.canUndoSave)return;_.current=!0,c(!0);const K=O.now(),Z=e.lastSave?.structural??!1,J=m.current.size;return e.undoSave().then(ie=>{ie.ok===!0?(S.current=!0,h(!0),m.current.undone({size:J,structural:Z,fromOpen:!1,durationMs:O.now()-K})):m.current.undoRefused(ie.reason)}).finally(()=>{_.current=!1,c(!1)})},[t,u,e]),A=k.useCallback(()=>{if(!(!t||!e.dirty||u))return y()},[t,e,u,y]),T=k.useRef(A);T.current=A;const D=k.useCallback(()=>{const K=()=>T.current();return l?l(K):K()},[l]),q=Ev({dirty:w,saving:u,canSave:!!t,save:D,onExit:()=>r?.()});wv(k.useMemo(()=>({...d,undo:e.undo,redo:e.redo,...t?{save:D}:{},paused:q.dialog.open}),[d,e,t,D,q.dialog.open]));const P=!!t&&!u&&e.canUndoSave,z=e.lastSave,U={canUndo:e.canUndo,canRedo:e.canRedo,onUndo:e.undo,onRedo:e.redo,dirty:b,saving:u,saveButton:p,...t?{onSave:D}:{},...r?{onExit:q.requestExit}:{}};return{saving:u,save:D,exitGuard:q,undoSave:E,canUndoSave:P,lastSave:z,toolbarProps:U}}function rs(e){for(const t of e??[]){const n=/^#\(doc\)\s*(.*)$/s.exec(t.trim());if(n)return n[1].trim()}}function Ml(e){for(const t of e??[]){const n=/^#\s*(?:-[A-Za-z_]+\s+)*([a-z_]+)/.exec(t.trim())?.[1];if(n&&Cd.includes(n))return n}}const Iv=1;function Hd(e,t,n){const r=[];for(const s of e??[]){const i=s.name,o=s.kind;if(typeof i=="string"){if(o==="dimension"||o==="measure"){const a=s.type?.kind;r.push({name:t+i,kind:o,...a?{type:a}:{}})}else if(o==="join"&&n>0){const a=s.schema?.fields;r.push(...Hd(a,`${t}${i}.`,n-1))}}}return r}function Dv(e){const t=new Map;for(const n of Xd(e))t.set(n.name,Hd(n.schema?.fields,"",Iv));return t}function Xd(e){const t=[];for(const n of e.sourceInfos??[])try{const r=typeof n=="string"?JSON.parse(n):n;r?.name&&t.push(r)}catch{continue}return t}const Av=e=>(e.annotations??[]).some(t=>{const n=t.value??"";return n.startsWith("#(malloy)")&&rf.parseTag(n.slice(9)).tag?.has("calculation")===!0});function Mv(e){const t=new Map;for(const n of Xd(e)){const r=new Set;for(const s of n.schema?.fields??[]){if(s.kind!=="view"||typeof s.name!="string")continue;const i=s.schema?.fields;i&&i.length>0&&i.every(Av)&&r.add(s.name)}t.set(n.name,r)}return t}function Pl(e,t){return!e||t===void 0?void 0:e.sources.find(r=>r.name===t)?.fields.filter(r=>r.kind==="dimension")}const Rl=(e,t)=>e!==void 0&&t.has(e),jl=e=>e.modelPath??e.path??"";function Yd(e,t=new Set){const n=[],r=new Set,s=new Map,i=new Map,o=new Map;for(const a of e){const l=jl(a);if(Rl(l,t))continue;const d=O.exportedSources(a.modelInfo);i.set(a,d);for(const{name:u}of a.sources??[])u&&o.set(u,[...o.get(u)??[],l]);for(const u of d)s.set(u,[...s.get(u)??[],l])}for(const a of e){const l=jl(a);if(Rl(l,t))continue;const d=Dv(a),u=Mv(a);for(const c of a.sources??[]){const f=c.name;if(!f||!i.get(a)?.has(f)||r.has(f))continue;r.add(f);const h=(c.givens??[]).map(p=>p.name).filter(p=>typeof p=="string");n.push({name:f,modelPath:l,exporters:s.get(f)??[l],visibleIn:o.get(f)??[l],...rs(c.annotations)?{description:rs(c.annotations)}:{},views:(c.views??[]).filter(p=>typeof p.name=="string").map(p=>({name:p.name,...rs(p.annotations)?{description:rs(p.annotations)}:{},...Ml(p.annotations)?{chart:Ml(p.annotations)}:{},...u.get(f)?.has(p.name)?{aggregateOnly:!0}:{}})),givens:h,fields:d.get(f)??[]})}}return{sources:n}}function Pv({editor:e,opened:t,givens:n,catalog:r}){const[s,i]=k.useState(void 0),o=k.useMemo(()=>{const p=new Set((t.localGivens??[]).map(m=>m.name));return(n??[]).filter(m=>!p.has(m.name))},[t,n]),a=k.useMemo(()=>uf(e.document,o),[e.document,o]),l=k.useMemo(()=>new Map(e.document.sources.map(p=>[p.name,Pl(r,p.base)])),[r,e.document.sources]),d=k.useCallback(p=>l.get(p.source)??Pl(r,p.source),[l,r]),u=(p,m)=>{const b=[];for(const w of e.document.tiles){if(!xe(w))continue;const v=d(w);if(!v)continue;const g=new Map(v.map(y=>[y.name,y.type]));for(const y of w.filters??[])y.given===p&&(!g.has(y.field)||!as(m,g.get(y.field)))&&b.push(`${y.field} on ${w.label??w.name} (${e.document.sources.find(_=>_.name===w.source)?.base??w.source})`)}return b},c=k.useMemo(()=>a.filter(p=>p.origin==="model"&&p.boundTiles===0),[a]);return{filterDialog:s,setFilterDialog:i,controlList:a,fieldsFor:d,unknownFieldsOf:u,available:c,applyFilter:(p,m,b)=>{i(void 0),e.update(w=>{b&&vf(w,b),mf(w,p,m)})},dropControl:p=>{i(void 0),e.update(m=>yf(m,p))}}}function Rv({pendingOpen:e,prepare:t}){const[n,r]=k.useState(void 0),s=k.useRef(e);s.current=e;const i=k.useCallback(o=>s.current?new Promise(a=>r({go:()=>{r(void 0),a(t(o))},stop:()=>{r(void 0),a()}})):t(o),[t]);return{confirmConversion:n,prepareSave:i}}function jv(e){const{splice:t,onSave:n,structural:r,clearsHistory:s,opensDirty:i=!1}=e,[o,a]=k.useState({stack:[e.document],index:0}),[l,d]=k.useState(e.source),[u,c]=k.useState(void 0),[f,h]=k.useState(e.document),[p,m]=k.useState(i),[b,w]=k.useState(e.replaces),[v,g]=k.useState(!1),y=o.stack[o.index],_=k.useRef(o);_.current=o;const S=k.useRef(!1),[E,A]=k.useState(!1),T=R=>{S.current=R,A(R)},[D,q]=k.useState(void 0),P=k.useCallback(R=>{c(void 0),a(G=>{const ne=structuredClone(G.stack[G.index]);if(R(ne),JSON.stringify(ne)===JSON.stringify(G.stack[G.index]))return G;const H=[...G.stack.slice(0,G.index+1),ne].slice(-100);return{stack:H,index:H.length-1}})},[]),z=k.useCallback(()=>{c(void 0),a(R=>R.index>0?{...R,index:R.index-1}:R)},[]),U=k.useCallback(()=>{c(void 0),a(R=>R.index<R.stack.length-1?{...R,index:R.index+1}:R)},[]),K=k.useCallback(async(R,G)=>{try{return await t(R,G)}catch(ne){return{ok:!1,reason:`Could not build the file: ${ne instanceof Error?ne.message:String(ne)}`}}},[t]),Z=k.useCallback(async()=>{if(S.current)return{ok:!1,reason:"A save is still being written."};const R={source:l,saved:f,history:_.current,pendingOpen:p,replacing:b,unwritten:v},G=s?.(f,y)??!1,ne=r?.(f,y)??!1;T(!0);try{const Y=await K(l,y);if(zs(Y))return c(Y.reason),{ok:!1,reason:Y.reason};try{await n?.(Y.source,{purpose:"save",document:y})}catch(L){const C=`Could not save: ${L instanceof Error?L.message:String(L)}`;return c(C),{ok:!1,reason:C}}d(Y.source),h(y),m(!1),w(void 0),g(!1);const H=G?{stack:[y],index:0}:R.history;return a(L=>L===R.history?H:G?{stack:[L.stack[L.index]],index:0}:L),q(n?{before:R,after:H,lastSave:{before:b??l,after:Y.source,structural:ne,clearsHistory:G}}:void 0),c(void 0),{ok:!0}}finally{T(!1)}},[y,K,n,l,f,p,b,v,s,r]),J=k.useCallback(async()=>{if(S.current)return{ok:!1,reason:"A save is still being written."};if(!n||D===void 0||D.after!==_.current)return{ok:!1,reason:"There is no save to undo."};const{before:R}=D;T(!0);try{await n(R.replacing??R.source,{purpose:"undo",document:R.saved})}catch(G){const ne=`Could not undo the save: ${G instanceof Error?G.message:String(G)}`;return c(ne),{ok:!1,reason:ne}}finally{T(!1)}return d(R.source),h(R.saved),m(R.pendingOpen),w(R.replacing),g(R.unwritten||R.replacing!==void 0),a(G=>G===D.after?R.history:G),q(void 0),c(void 0),{ok:!0}},[n,D]),ie=k.useMemo(()=>v||JSON.stringify(y)!==JSON.stringify(f),[y,f,v]),de=k.useMemo(()=>r?.(f,y)??!1,[y,f,r]),I=k.useMemo(()=>s?.(f,y)??!1,[y,f,s]),V=D!==void 0&&D.after===o,B=k.useCallback(async()=>{const R=await K(l,y);return zs(R)?{ok:!1,reason:R.reason}:{ok:!0,source:R.source}},[y,K,l]);return{document:y,saved:f,source:l,canUndo:o.index>0,canRedo:o.index<o.stack.length-1,dirty:ie||p,edited:ie,pendingOpen:p,...u===void 0?{}:{error:u},update:P,undo:z,redo:U,save:Z,preview:B,structural:de,clearsHistory:I,canUndoSave:V&&!E&&n!==void 0,...V?{lastSave:D.lastSave}:{},undoSave:J}}const Lv=(e,t)=>{const n=new Set(e.tiles.map(xo)),r=new Set(t.tiles.map(xo));return[...n].some(s=>!r.has(s))||[...r].some(s=>!n.has(s))};function Nv(e){const{conversion:t,visibleSources:n,...r}=e,s=t?.from,i=t?.to,o=k.useCallback((a,l)=>Kd(s!==void 0&&a===s?i:a,l,n?{visibleSources:n}:{}),[s,i,n]);return jv({...r,splice:o,structural:Lv,opensDirty:t!==void 0})}function Fv({editorDirty:e}){const[t,n]=k.useState(!1),r=k.useRef(void 0),s=k.useRef(void 0),i=k.useMemo(()=>({setDirty:n,commitRef:r}),[]),o=k.useCallback(a=>{if(!r.current)return a();if(r.current())return new Promise(l=>{s.current=()=>l(a())})},[]);return k.useEffect(()=>{if(t||!s.current)return;const a=s.current;s.current=void 0,a()},[t,e]),{draftDirty:t,openDraft:i,prepare:o}}function zv(e,t,{modelPath:n,textHeld:r,notebook:s,insertAt:i}){t.modelPath&&!r&&(e.imports=O.withSource(e,t.base,t.modelPath,n,t.exporters??[t.modelPath]));let o=e.sources.find(d=>d.base===t.base);if(!o){const d=new Set(e.sources.map(c=>c.name));let u=`${t.base}_tiles`;for(let c=2;d.has(u);c++)u=`${t.base}_tiles_${c}`;o={name:u,base:t.base},e.sources.push(o)}const a=new Set(e.tiles.filter(xe).filter(d=>d.source===o.name).map(d=>d.name));let l=`${t.view}_tile`;for(let d=2;a.has(l);d++)l=`${t.view}_tile_${d}`;e.tiles.splice(i??e.tiles.length,0,{name:l,source:o.name,declaration:{kind:"reference",from:t.view},...s?{}:{colspan:t.colspan},...t.label?{label:t.label}:{},...t.chart?{chart:t.chart}:{},...t.chartCarried?{chartCarried:t.chartCarried}:{}})}function Wv({editor:e,notebook:t,columns:n,modelPath:r,textHeld:s,selectTile:i,deselectTile:o}){const[a,l]=k.useState(void 0),[d,u]=k.useState(!1),[c,f]=k.useState(void 0);return{menu:a,setMenu:l,addingTile:d,openAdd:g=>{f(g),u(!0)},closeAdd:()=>u(!1),addTile:g=>{u(!1),e.update(y=>zv(y,g,{modelPath:r,textHeld:s,notebook:t,insertAt:c})),i(c??e.document.tiles.length)},addText:()=>{u(!1),e.update(g=>{const y=new Set(g.tiles.filter(Re).map(S=>S.name));let _=1;for(;y.has(`text_${_}`);)_++;g.tiles.splice(c??g.tiles.length,0,{kind:"text",name:`text_${_}`,markdown:"",...t?{}:{colspan:n}})}),i(c??e.document.tiles.length)},editTile:(g,y)=>e.update(_=>{const S=_.tiles.find(E=>Fe(E)===g);S&&y(S)}),removeTile:g=>{l(void 0),o(),e.update(y=>{y.tiles.splice(g,1)})}}}var Bv=Object.defineProperty,Gv=Object.defineProperties,qv=Object.getOwnPropertyDescriptors,Ll=Object.getOwnPropertySymbols,Kv=Object.prototype.hasOwnProperty,Vv=Object.prototype.propertyIsEnumerable,Nl=(e,t,n)=>t in e?Bv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,an=(e,t)=>{for(var n in t||(t={}))Kv.call(t,n)&&Nl(e,n,t[n]);if(Ll)for(var n of Ll(t))Vv.call(t,n)&&Nl(e,n,t[n]);return e},ln=(e,t)=>Gv(e,qv(t));function Uv(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function ss(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function Oi(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function Hv(e,t,n){var r,s;const{source:i,target:o,canceled:a}=t.operation;if(!i||!o||a)return"preventDefault"in t&&t.preventDefault(),e;const l=(g,y)=>g===y||g!==null&&typeof g=="object"&&"id"in g&&g.id===y;if(Array.isArray(e)){const g=e.findIndex(_=>l(_,i.id)),y=e.findIndex(_=>l(_,o.id));if(g===-1||y===-1){if(Oi(i)){const _=i.initialIndex,S=i.index;return _===S||_<0||_>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,_,S)}return e}if(!a&&"index"in i&&typeof i.index=="number"){const _=i.index;if(_!==g)return n(e,g,_)}return n(e,g,y)}const d=Object.entries(e);let u=-1,c,f=-1,h;for(const[g,y]of d)if(u===-1&&(u=y.findIndex(_=>l(_,i.id)),u!==-1&&(c=g)),f===-1&&(f=y.findIndex(_=>l(_,o.id)),f!==-1&&(h=g)),u!==-1&&f!==-1)break;if(u===-1&&Oi(i)){const g=i.initialGroup==null?void 0:ss(e,i.initialGroup),y=i.initialIndex,_=i.group==null?void 0:ss(e,i.group),S=i.index;if(g==null||_==null||g===_&&y===S)return"preventDefault"in t&&t.preventDefault(),e;if(g===_)return ln(an({},e),{[g]:n(e[g],y,S)});const E=e[g][y];return ln(an({},e),{[g]:[...e[g].slice(0,y),...e[g].slice(y+1)],[_]:[...e[_].slice(0,S),E,...e[_].slice(S)]})}if(!i.manager)return e;const{dragOperation:p}=i.manager,m=(s=(r=p.shape)==null?void 0:r.current.center)!=null?s:p.position.current;if(h==null){const g=ss(e,o.id);if(g!=null){const y=o.shape&&m.y>o.shape.center.y?e[g].length:0;h=g,f=y}}if(c==null||h==null||c===h&&u===f){if(c!=null&&c===h&&u===f&&Oi(i)){const g=i.group==null?void 0:ss(e,i.group),y=i.group!=null&&g!==c,_=i.index!==u;if(y||_){const S=i.group==null?c:g;if(S!=null){if(c===S)return ln(an({},e),{[c]:n(e[c],u,i.index)});const E=e[c][u];return ln(an({},e),{[c]:[...e[c].slice(0,u),...e[c].slice(u+1)],[S]:[...e[S].slice(0,i.index),E,...e[S].slice(i.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(c===h)return ln(an({},e),{[c]:n(e[c],u,f)});const w=o.shape&&Math.round(m.y)>Math.round(o.shape.center.y)?1:0,v=e[c][u];return ln(an({},e),{[c]:[...e[c].slice(0,u),...e[c].slice(u+1)],[h]:[...e[h].slice(0,f+w),v,...e[h].slice(f+w)]})}function Xv(e,t){return Hv(e,t,Uv)}function Yv({tiles:e,commit:t,onLanded:n}){const[r,s]=k.useState(void 0),i=k.useRef(void 0),[o,a]=k.useState(!1);return{dragging:o,preview:r,onDragStart:()=>{a(!0),i.current=e},onDragOver:c=>{const{source:f,target:h}=c.operation;if(!f||!h)return;const p=i.current??e;let m;if(h.type===Od){const{after:b}=h.data,w=p.findIndex(y=>Fe(y)===f.id);if(w<0||b===f.id)return;const g=p.filter((y,_)=>_!==w).findIndex(y=>Fe(y)===b)+1;m=Tg(p,w,g)}else{const b=p.map(Fe),w=Xv(b,c);if(w.every((g,y)=>g===b[y]))return;const v=new Map(p.map(g=>[Fe(g),g]));m=$g(w.map(g=>v.get(g)),e.map(g=>g.break??!1))}i.current=m,s(m)},onDragEnd:c=>{a(!1);const f=i.current;if(i.current=void 0,s(void 0),c.canceled||!f)return;t(f);const h=f.findIndex(p=>Fe(p)===c.operation.source?.id);h>=0&&n(h)}}}const Ei=e=>{const t=window.document.body;t.style.userSelect=e?"none":"",t.style.cursor=e?"grabbing":""};function Zv({tiles:e,columns:t,gridBox:n,onStart:r,commit:s}){const[i,o]=k.useState(void 0),a=k.useRef(void 0),l=f=>{a.current=f,o(f)};return k.useEffect(()=>()=>Ei(!1),[]),{resize:i,startResize:(f,h)=>{const p=n.current?.getBoundingClientRect(),m=f.currentTarget.parentElement?.getBoundingClientRect();if(!p||!m)return;f.stopPropagation(),f.preventDefault(),f.currentTarget.setPointerCapture(f.pointerId),Ei(!0),r(h);const b=e[h]?.colspan??1;l({index:h,span:b,from:b,left:m.left,track:(p.width-O.GRID_GAP_PX*(t-1))/t})},onResize:f=>{const h=a.current;if(!h)return;const p=f.clientX-h.left,m=Math.round((p+O.GRID_GAP_PX)/(h.track+O.GRID_GAP_PX)),b=Math.min(Math.max(m,1),t);b!==h.span&&l({...h,span:b})},endResize:f=>{f.currentTarget.hasPointerCapture(f.pointerId)&&f.currentTarget.releasePointerCapture(f.pointerId),Ei(!1);const h=a.current;if(!h)return;const{index:p,span:m,from:b}=h;l(void 0),!(f.type==="pointercancel"||m===b)&&s(p,m)}}}function Oa({source:e,document:t,onSave:n,onChange:r,onDirtyChange:s,onExit:i,allowLayoutChange:o=!0,renderTile:a,controls:l,givens:d,catalog:u,toolbar:c,dashboards:f,onEvent:h,conversion:p,savesTo:m="package",saveLabel:b,replaces:w,modelPath:v,visibleSources:g,addFilterDisabledReason:y}){const _=Nv({source:e,document:t,...n?{onSave:n}:{},...p?{conversion:p}:{},...w!==void 0?{replaces:w}:{},...g?{visibleSources:g}:{}}),S=k.useRef(null),{selected:E,descriptionSelected:A,selectTile:T,deselectTile:D,selectDescription:q,clearSelection:P,flash:z,stepEditor:U}=Ov({editor:_,gridBox:S}),K=_.document.layout==="linear",Z=K?1:_.document.columns??O.DEFAULT_COLUMNS,J=K?"none":"card",ie=v?.split("/").at(-1)?.replace(/\.malloy$/,""),de=Yv({tiles:_.document.tiles,commit:te=>_.update(j=>{j.tiles=te}),onLanded:T}),{dragging:I}=de,V=Zv({tiles:_.document.tiles,columns:Z,gridBox:S,onStart:T,commit:(te,j)=>_.update(F=>{const re=F.tiles[te];re&&(re.colspan=j)})}),B=Wv({editor:_,notebook:K,columns:Z,modelPath:v,textHeld:g!==void 0,selectTile:T,deselectTile:D}),{menu:R,addingTile:G,openAdd:ne}=B,Y=Pv({editor:_,opened:t,givens:d,catalog:u}),{filterDialog:H,setFilterDialog:L}=Y,[C,W]=k.useState(void 0),{draftDirty:M,openDraft:ee,prepare:X}=Fv({editorDirty:_.dirty}),{confirmConversion:le,prepareSave:ce}=Rv({pendingOpen:_.pendingOpen,prepare:X}),N=k.useMemo(()=>({escape:()=>{!R&&!H&&!G&&C===void 0&&le===void 0&&P()},nudge:te=>{if(I||E===void 0||K)return;const j=_.document.tiles[E];if(!j||xe(j)&&j.declaration.kind==="inherited")return;const F=O.nudgedSpan(j.colspan??1,te,Z);F!==(j.colspan??1)&&_.update(re=>{re.tiles[E].colspan=F})}}),[_,R,H,G,C,le,P,E,Z,K,I]),Q=Cv({editor:U,extraDirty:M,prepare:ce,unit:{name:"tile",count:te=>te.tiles.length},onSave:n,onDirtyChange:s,onExit:i,onChange:r,shortcuts:N,report:yv({size:_.document.tiles.length,path:v??"",layout:_.document.layout,savesTo:m,onEvent:h})}),me=_.document.tiles.length===0,se=x.jsx(_v,{...Q.toolbarProps,...c?{actions:c}:{},...u?{onAddTile:()=>ne()}:{},savesTo:m,...b?{saveLabel:b}:{},...g===void 0&&o?{layout:_.document.layout,onLayoutChange:te=>{const j=_.document.layout;te!==j&&(_.update(F=>{F.layout=te}),O.reportEmitter({path:v??"",layout:te},h).emit({type:"report.layout_changed",from:j,to:te}))}}:{}});return x.jsx(hd.Provider,{value:ee,children:x.jsx($.Stack,{sx:{gap:0,mx:`-${Si}px`},children:x.jsxs($.Stack,{sx:{gap:2,px:`${Si}px`,pb:`${Si}px`},children:[_.pendingOpen&&x.jsx($.Alert,{severity:"info",children:"This report is in the cell format. Saving rewrites it as a layout notebook, and a named query run once becomes that tile's view."}),x.jsx(vv,{editor:_,notebook:K,documentSlug:ie,chrome:J,actions:se,descriptionSelected:A,selectDescription:q}),me?x.jsx(x.Fragment,{children:x.jsxs($.Stack,{sx:{alignItems:"flex-start",gap:1,py:3,px:2,border:1,borderStyle:"dashed",borderColor:"divider",borderRadius:1},children:[x.jsx($.Typography,{variant:"body2",children:"This report is not served until it has a tile."}),u&&x.jsx($.Button,{size:"small",startIcon:x.jsx(O.AddIcon,{}),onClick:()=>ne(),children:"Add tile"})]})}):x.jsx($v,{controls:Y.controlList,tileCount:_.document.tiles.length,unknownFieldsOf:Y.unknownFieldsOf,onEdit:te=>L({control:te}),onAdd:()=>L({}),...y?{addDisabledReason:y}:{},onRemove:Y.dropControl,children:l}),_.error&&x.jsx($.Alert,{severity:"warning",children:_.error}),x.jsx(pv,{editor:_,reorder:de,resizing:V,gridBox:S,columns:Z,notebook:K,chrome:J,canAdd:!!u,selected:E,flash:z,menuIndex:R?.index,onSelect:T,onOpenMenu:(te,j)=>{T(j),B.setMenu({anchor:te,index:j})},openAdd:ne,editTile:B.editTile,...a?{renderTile:a}:{}}),x.jsx($f,{editor:_,catalog:u,columns:Z,dashboards:f,bindings:Y,tiles:B,drillSource:C,setDrillSource:W,confirmConversion:le,exitDialog:Q.exitGuard.dialog})]})})})}function Qv(e,t){const n=new Set;for(const i of e.tiles)for(const o of xe(i)?i.filters??[]:[])n.add(o.given);const r=[],s=new Set;for(const i of e.localGivens??[])n.has(i.name)&&(s.add(i.name),r.push(Jv(i)));for(const i of t)i.name===void 0||s.has(i.name)||!n.has(i.name)||(s.add(i.name),r.push(i));return r}function Jv(e){const t=ey(e);return{name:e.name,type:e.type,...t===void 0?{}:{default:t},...e.label===void 0?{}:{label:e.label},...e.description===void 0?{}:{description:e.description},...e.control===void 0?{}:{control:e.control},...e.suggest?{suggest:{...e.suggest.source===void 0?{}:{source:e.suggest.source},...e.suggest.query===void 0?{}:{query:e.suggest.query},dimension:e.suggest.dimension}}:{},...e.rangeMin===void 0?{}:{rangeMin:e.rangeMin},...e.rangeMax===void 0?{}:{rangeMax:e.rangeMax}}}function ey(e){if(!e.type?.startsWith("filter<"))return e.default;const t=e.default?.match(/^f(['"])([\s\S]*)\1$/)?.[2];return t===void 0?e.default:t===""?void 0:t}function ty(e){return e.kind==="inline"?!0:e.kind==="opaque"&&(e.why.includes("compound")||e.why.includes("pipeline"))}function is(e){return e.split("->").map(t=>t.trim().replace(/\s+/g," ")).join(" -> ").replace(/\s+/g," ")}function ny(e,t,n,r=new Map,s){if(t.declaration.kind==="inherited")return{expression:`${t.source} -> ${t.name}`,givenNames:void 0,reads:s&&[...s]};const i=t.source,o=t.declaration.kind==="reference"?t.declaration.from:t.name,a=new Map((e.localGivens??[]).map(m=>[m.name,m.type])),l=e.sources.find(m=>m.name===i)?.scopedBy??[],d=new Set([...l,...s??[]].filter(m=>n.has(m))),u=new Set([...l,...s??[]]),c=[];for(const m of t.filters??[]){const b=`where: ${ge.malloyPath(m.field)} ${m.op??"~"}`;if(n.has(m.given)){d.add(m.given),u.add(m.given),c.push(`${b} $${m.given}`);continue}if(!a.has(m.given))continue;u.add(m.given);const w=O.malloyLiteral(r.get(m.given),a.get(m.given));w!==void 0&&c.push(`${b} ${w}`)}const f=c.join(", "),h=t.chart,p=h==="none"||ni(h)?wn(h,t.chartCarried):h==="custom"&&t.chartLines?.length?t.chartLines.join(`
|
|
143
|
+
`):h==="default"&&ty(t.declaration)?wn("none"):void 0;return{...p?{annotation:p}:{},expression:`${i} -> ${o}`+(f?` + { ${f} }`:""),givenNames:Array.from(d),reads:s||u.size>0?Array.from(u):void 0}}function ry({environmentName:e,packageName:t,versionId:n,modelPath:r,reports:s,reportsSettled:i}){const{apiClients:o,server:a}=Be.useServer(),{data:l}=O.useQueryWithApiError({queryKey:["report-editor-models",e,t,n],queryFn:async()=>(await o.models.listModels(e,t,n)).data.flatMap(p=>p.path&&!p.error?[p.path]:[])}),d=k.useMemo(()=>new Set([r,...s.flatMap(p=>p.path?[p.path]:[])]),[s,r]),u=k.useMemo(()=>i?(l??[]).filter(p=>!d.has(p)):[],[l,d,i]),c=ql.useQueries({queries:u.map(p=>({queryKey:["report-editor-model",e,t,p,n,a],queryFn:async()=>(await o.models.getModel(e,t,p,n)).data,retry:!1}))}),f=l!==void 0&&i&&c.every(p=>p.isSuccess||p.isError),h=c.map(p=>p.dataUpdatedAt).join();return k.useMemo(()=>f?Yd(c.flatMap(p=>p.data?[p.data]:[]),d):void 0,[f,u,h,d])}const sy={};function iy({textSource:e,modelGivens:t,environmentName:n,packageName:r,modelPath:s,versionId:i,opened:o,replaces:a,onSave:l,onDirtyChange:d,onExit:u,allowLayoutChange:c,onEvent:f,savesTo:h,saveLabel:p,note:m}){const{apiClients:b}=Be.useServer(),[w,v]=k.useState(o.document.tiles.length>0);k.useEffect(()=>v(o.document.tiles.length>0),[o.generation,o.document]);const{data:g,isSuccess:y,isError:_}=O.useQueryWithApiError({queryKey:["dashboard-editor-manifest",n,r,s,i],queryFn:async()=>{const N=(await b.reports.getReport(n,r,s,i)).data;return N.notebook?{...N.notebook.startingGivens?{startingGivens:N.notebook.startingGivens}:{},...N.notebook.autorun===void 0?{}:{autorun:N.notebook.autorun}}:N},enabled:w&&!e}),S=e?.modelPath??s,E=O.useCompiledDocument({environmentName:n,packageName:r,modelPath:S,source:o.source,...e?.givens?{givens:e.givens}:{}},{enabled:e!==void 0}),A=E.data?.document,T=e?E.isSuccess?A?.manifest??sy:void 0:g,D=e?E.isSuccess:y,q=e?E.isError:_,P=e?O.documentPreamble(A?.cells):void 0,z=(E.data?.result.problems??[]).filter(N=>N.severity==="error"),U=k.useMemo(()=>new Set(e?.hiddenGivens??[]),[e]),K=e?.givens,Z=k.useMemo(()=>new Set((T?.tiles??[]).flatMap(N=>N.restricted&&N.query?[is(N.query)]:[])),[T]),{reports:J,settled:ie}=O.useReportListing(n,r,i),de=k.useMemo(()=>J.map(N=>N.path).filter(N=>!!N&&N!==s&&N.endsWith(".malloy")).map(N=>N.replace(/\.malloy$/,"")),[J,s]),I=ry({environmentName:n,packageName:r,...i!==void 0?{versionId:i}:{},modelPath:s,reports:J,reportsSettled:ie}),V=k.useMemo(()=>e?(I?.sources??[]).filter(N=>(N.visibleIn??N.exporters??[N.modelPath]).includes(S)).map(N=>N.name):void 0,[I,e,S]),B=k.useMemo(()=>I&&V?{sources:I.sources.filter(N=>V.includes(N.name))}:I,[I,V]),[R,G]=k.useState(o.document);k.useEffect(()=>G(o.document),[o.document]);const ne=k.useMemo(()=>l&&(async(N,Q)=>{await l(N,Q.document.layout),h==="package"&&v(Q.document.tiles.length>0)}),[l,h]),Y=k.useMemo(()=>(T?.givens??(o.conversion?t??[]:[])).filter(N=>!(e&&N.secure===!0)&&!(N.name!==void 0&&U.has(N.name))),[T,o.conversion,t,U,e]),H=k.useMemo(()=>new Set([...Y.map(N=>N.name).filter(N=>N!==void 0),...Object.keys(K??{})]),[Y,K]),L=k.useMemo(()=>Qv(R,Y),[R,Y]),{declaredTypes:C,applied:W,panel:M}=O.useDocumentControls({specs:L,loaded:D,startingValues:T?.startingGivens,documentKey:`${n}/${r}/${i??""}/${s}/edit`,autorun:T?.autorun!==!1,environmentName:n,packageName:r,modelPath:e?S:T?.path,versionId:i,documentName:s,...P!==void 0?{preamble:P}:{},...K?{hostGivens:K}:{}}),ee=k.useMemo(()=>Object.fromEntries(Object.entries(K??{}).filter(([N])=>!C.has(N))),[K,C]),X=!w||D||q,le=k.useMemo(()=>new Map((T?.tiles??[]).flatMap(N=>N.kind!=="text"&&N.query&&N.givenNames?[[is(N.query),N.givenNames]]:[])),[T]),ce=k.useMemo(()=>function(Q,me,se="card"){if(!X)return x.jsxs(O.TileCard,{chrome:se,children:[x.jsx(O.TileHeading,{title:me?.title??Gs(Q),subtitle:me?me.subtitle:Q.subtitle}),x.jsx(O.Loading,{text:"Running…"})]});const te=ny(R,Q,H,W,le.get(is(`${Q.source} -> ${Q.name}`)));return x.jsx(O.DashboardTile,{environmentName:n,packageName:r,versionId:i,modelPath:S,...P!==void 0?{preamble:P}:{},...Z.has(is(`${Q.source} -> ${Q.name}`))?{restricted:!0}:{},tile:te.expression,...te.annotation?{annotation:te.annotation}:{},label:Gs(Q),chrome:se,subtitle:Q.subtitle,...me?{heading:me}:{},borderless:Q.borderless,givens:W,hostGivens:ee,declaredTypes:C,givenNames:te.givenNames,ignoredFilters:O.tileIgnoredFilterLabels(te.reads,L),height:O.TILE_MAX_HEIGHT})},[R,X,H,le,n,r,i,S,P,Z,W,ee,C,L]);return x.jsxs($.Stack,{sx:{gap:1},children:[e&&z.length>0&&x.jsxs($.Alert,{severity:"error",children:["The server could not compile this document:"," ",z.map(N=>N.message).join("; ")]}),e&&E.isError&&x.jsxs($.Alert,{severity:"error",children:["The server could not compile this document:"," ",E.error?.message]}),x.jsx(Oa,{...e?{addFilterDisabledReason:"This document holds no given: of its own. Bind a filter the model offers from its chip."}:{},source:o.source,document:o.document,renderTile:ce,givens:L.filter(N=>N.name!==void 0).map(N=>({name:N.name,...N.label?{label:N.label}:{},...N.type?{type:N.type}:{},...N.suggest?.dimension?{field:N.suggest.dimension}:{}})),onChange:G,onDirtyChange:d,...u?{onExit:u}:{},...c!==void 0?{allowLayoutChange:c}:{},...o.conversion?{conversion:o.conversion}:{},...B?{catalog:B}:{},dashboards:de,...f?{onEvent:f}:{},controls:D?x.jsx(O.GivensPanel,{...M,layout:R.layout==="linear"?"panel":"bar"}):void 0,...ne?{onSave:ne}:{},savesTo:h,...p?{saveLabel:p}:{},...a!==void 0?{replaces:a}:{},modelPath:s,...e?{visibleSources:V}:{}}),x.jsx($.Box,{sx:{px:.5},children:x.jsx($.Typography,{variant:"caption",sx:{opacity:.7},children:m})})]})}function oy({storage:e,layout:t,notebook:n,environmentName:r,packageName:s,modelPath:i}){const[o,a]=k.useState(void 0),[l,d]=k.useState(void 0),[u,c]=k.useState(e===void 0),[f,h]=k.useState(!1),[p,m]=k.useState(void 0);return k.useEffect(()=>{if(!e)return;let b=!1;return m(void 0),(async()=>{try{const w=O.chooseWorkspace(await e.listWorkspaces(!1));if(b)return;if(a(w),w!==void 0&&(!n||w.authoritative)){const v=await e.getDocument(O.locatorFor(t,w.name,r,s,i)).catch(g=>{if(!O.isDocumentNotFound(g))throw g});if(b)return;d(v),h(v!==void 0)}}catch(w){if(b)return;m(O.storageErrorMessage(w))}b||c(!0)})(),()=>{b=!0}},[e,t,n,r,s,i]),{workspace:o,draft:l,setDraft:d,draftChecked:u,offered:f,setOffered:h,readFailure:p}}const ay=e=>e.ok===!1,Un=(e,t)=>{const n=e[t];return typeof n=="function"?n.call(e):void 0},ly=[["runStatement","run"],["docAnnotations","notes"],["importStatement","definition"],["defineSourceStatement","definition"],["defineQuery","definition"],["defineGivenStatement","definition"],["defineUserTypeStatement","definition"],["exportStatement","definition"]],cy=/^[A-Za-z_][A-Za-z0-9_]*$/,uy="file:///publisher-notebook-builder/notebook.malloy",os=e=>e.replace(/\r\n?/g,`
|
|
144
|
+
`);async function dy(e){const t=(I,V)=>({ok:!1,refused:`Line ${I+1}: ${V}`,line:I+1}),n=/\r(?!\n)/.exec(e);if(n)return t(e.slice(0,n.index).split(`
|
|
145
|
+
`).length-1,"a carriage return that is not part of a CRLF line ending, so the cells cannot be located. Fix: save the file with LF or CRLF line endings.");let r,s;try{r=await Wr(e,uy),s=await O.loadMalloy()}catch(I){return t(0,`Malloy could not read this notebook: ${I}`)}const i=r.problems.find(I=>I.code==="syntax-error");if(i)return t(i.at?.range?.start?.line??0,`Malloy could not parse this notebook (${i.message??"unknown"}), so it cannot be edited here. Fix: correct the syntax on that line.`);const o=r.parse?.root,a=r.parse?.tokenStream,l=a?.tokenSource?.vocabulary,d=typeof a?.getTokens=="function"?a.getTokens():void 0;if(!o||typeof o.getChild!="function"||!a||!d||typeof l?.getSymbolicName!="function"||d.length===0&&e.trim()!=="")return{ok:!1,refused:"This build of Malloy does not expose a parse tree and token stream the notebook builder can read, so editing is off."};const u=I=>l.getSymbolicName(I.type),c=I=>s.routeOf({value:I.trimStart()}),f=I=>s.payloadOf({value:I}),h=I=>I==="markdown"||I==='"'||I==="text",p=I=>os(f(I)).replace(/\n$/,""),m=(I,V)=>{const B=f(I).trim(),R=c(I)!=='"'&&cy.test(B)?"":B;return os([R&&`${R}
|
|
146
|
+
`,...V].join("")).replace(/\n$/,"")},b=new ri(e),w=ka(b,a),v=I=>e.slice(b.utf16(I.startIndex),b.utf16(I.stopIndex+1)),g=I=>{const V=I.start?.startIndex,B=I.stop?.stopIndex,R=b.span(I);if(V===void 0||B===void 0||!R)return;let G=R.end;for(;G>R.start&&(e[G-1]===`
|
|
147
|
+
`||e[G-1]==="\r");)G--;return{startCp:V,stopCp:B,...R,startLine:b.line(R.start),endLine:b.line(Math.max(R.start,G-1))}},y=I=>{let V=0,B=d.length;for(;V<B;){const R=V+B>>1;d[R].startIndex<I?V=R+1:B=R}return V},_=(I,V)=>{const B=[],R=[],G={lines:[],insertAt:b.utf16(I)};let ne=-2;for(let Y=y(I);Y<d.length;Y++){const H=d[Y];if(H.startIndex>V)break;if(H.channel!==0)continue;const L=u(H);if(L!=="ANNOTATION"&&L!=="BLOCK_ANNOTATION_BEGIN"){G.insertAt=b.lineStarts[b.line(b.utf16(H.startIndex))];break}const C=os(v(H)),W=[];if(L==="BLOCK_ANNOTATION_BEGIN"){for(;u(d[Y+1]??H)==="BLOCK_ANNOTATION_TEXT";)W.push(v(d[++Y]));u(d[Y+1]??H)==="BLOCK_ANNOTATION_END"&&Y++}if(h(c(C))){const M=b.utf16(H.startIndex),ee=b.lineStarts[b.line(M)],X=/^[ \t]*$/.test(e.slice(ee,M));R.push({start:X?ee:M,end:b.utf16(d[Y].stopIndex+1)})}if(L==="ANNOTATION"){const M=C.replace(/\n$/,"");if(Dt(M)){const ee=b.utf16(H.startIndex),X=b.lineStarts[b.line(ee)];G.lines.push({span:{start:/^[ \t]*$/.test(e.slice(X,ee))?X:ee,end:b.utf16(H.stopIndex+1)},text:M})}else Tr(M)&&G.unmodelled===void 0&&(G.unmodelled=M.trim())}if(c(C)!=="markdown")ne=-2;else if(L==="BLOCK_ANNOTATION_BEGIN")B.push(m(C,W)),ne=-2;else{const M=p(C);H.line===ne+1?B[B.length-1]+=`
|
|
148
|
+
${M}`:B.push(M),ne=H.line}}return{markdown:B.length>0?B.join(`
|
|
149
149
|
|
|
150
|
-
`):void 0,prose:
|
|
151
|
-
`)[0];return
|
|
152
|
-
`,1)[0],
|
|
153
|
-
${
|
|
154
|
-
`,n),i=s<0?e.length:s;t+=" ".repeat(i-n),n=i}else if(r==="/*"){const s=e.indexOf("*/",n+2),i=s<0?e.length:s+2;t+=e.slice(n,i).replace(/[^\n]/g," "),n=i}else if(e[n]==="'"||e[n]==='"'||e[n]==="`"){const s=e[n];let i=n+1;for(;i<e.length&&e[i]!==s;)i+=e[i]==="\\"?2:1;const o=Math.min(i,e.length);t+=s+e.slice(n+1,o).replace(/[^\n]/g," "),o<e.length&&(t+=s),n=o+1}else t+=e[n],n++}return t}function
|
|
150
|
+
`):void 0,prose:R,chart:G}},S=[],E=[],A=(I,V,B="remove it, or rewrite it as an import, source:, query:, given:, type: or export statement, a run:, or a `##(markdown)` / `##|(markdown)` prose note.")=>t(I,`${V}, which no notebook cell can hold, so the notebook cannot be edited here. Fix: ${B}`);for(let I=0;I<(o.childCount??0);I++){const V=o.getChild(I);if(!en(V)){const H=V?.symbol,L=H?u(H):void 0;if(H&&L==="EOF")continue;if(H&&L==="SEMI"){S.push([H.startIndex,H.stopIndex]);continue}return A((H?.line??1)-1,"a token outside any statement")}const B=g(V);if(!B)return A(0,"a statement with no readable range");const R=ly.find(([H])=>Un(V,H)!==void 0);if(!R&&Un(V,"ignoredObjectAnnotations"))return A(B.startLine,"a # tag that annotates no statement","move the tag directly above its run:, or write trailing prose as a `##(markdown)` note.");if(!R){const H=e.slice(B.start,B.end).split(`
|
|
151
|
+
`)[0];return A(B.startLine,`\`${H.trim()}\` is a statement the notebook reader does not recognize`)}S.push([B.startCp,B.stopCp]);const[G,ne]=R;if(ne!=="notes"){const{markdown:H,prose:L,chart:C}=_(B.startCp,B.stopCp);E.push({kind:"statement",run:ne==="run",...H!==void 0&&{markdown:H},prose:L,chart:C,startLine:B.startLine,endLine:B.endLine});continue}const Y=Un(V,G);for(const H of Un(Y,"docAnnotation")??[]){const L=g(H);if(!L)return A(B.startLine,"a note with no readable range");const C=Un(H,"docBlockAnnotation")!==void 0,W=d.filter(N=>N.startIndex>=L.startCp&&N.stopIndex<=L.stopCp),M=W.filter(N=>u(N)==="BLOCK_ANNOTATION_TEXT"),ee=M[M.length-1]??W[0],X=os(C&&ee?e.slice(L.start,b.utf16(ee.stopIndex+1)).replace(/\r?\n$/,""):e.slice(L.start,L.end)),le=c(X),ce=h(le)?C?m(X.split(`
|
|
152
|
+
`,1)[0],M.map(v)):p(X):void 0;E.push({kind:"note",note:{text:X,route:le,...ce!==void 0&&{body:ce},block:C,startLine:L.startLine,endLine:L.endLine}})}}for(const I of d){if(u(I)!=="BLOCK_ANNOTATION_END")continue;const V=v(I).trimStart().replace(/^\|#{1,2}/,"").trim();if(V)return t(I.line-1,`the text after a block's closer (\`${V}\`) is not part of any cell, so the notebook cannot be edited here. Fix: put it on its own line, or inside the block.`)}let T=0;for(const I of d){if(I.channel!==0||u(I)==="EOF")continue;for(;T<S.length&&S[T][1]<I.startIndex;)T++;const[V,B]=S[T]??[1/0,-1/0];if(I.startIndex<V||I.stopIndex>B)return A(I.line-1,"a token outside any statement")}const D=E.findIndex(I=>I.kind==="note"&&ge.setsArtifactProperty(I.note.text));if(D<0)return t(0,"this file has no ## artifact note, so it is not a notebook the builder can edit. Fix: add `## artifact { layout=linear }` after the ##! line.");const q=E.findIndex((I,V)=>V<D&&I.kind==="statement");if(q>=0)return t(E[q].startLine,'a statement sits above the `## artifact` tag, where only `##!` flags, comments and `"` notes may. Fix: move it below the artifact tag.');for(let I=1;I<E.length;I++){const V=E[I-1],B=E[I],R=V.kind==="note"?V.note.endLine:V.endLine,G=B.kind==="note"?B.note.startLine:B.startLine;if(G<=R)return A(G,"a line holding two statements or notes","put each statement and note on its own line.")}const P=I=>b.lineStarts[I+1]??e.length,z=[];let U=-1,K=!0,Z;E.forEach((I,V)=>{if(I.kind==="statement"){K=!1,Z=void 0,z.push({cell:{kind:I.run?"query":"definition",...I.markdown!==void 0&&{markdown:I.markdown},...I.prose.length>0&&{prose:I.prose},...I.run&&{chart:I.chart},id:""},startLine:I.startLine,endLine:I.endLine});return}const{note:B}=I;if(!(V>D&&B.body!==void 0)){K&&(U=B.endLine),Z=void 0;return}if(K=!1,!B.block&&Z&&Z.endLine+1===B.startLine){Z.cell.markdown+=`
|
|
153
|
+
${B.body}`,Z.endLine=B.endLine;return}const G={cell:{kind:"markdown",markdown:B.body,id:""},startLine:B.startLine,endLine:B.endLine};z.push(G),Z=B.block?void 0:G});const J={start:0,end:P(U)};let ie=U;const de=z.map(({cell:I,startLine:V,endLine:B},R)=>{let G=V;for(;G-1>ie&&w.lines.has(G-1);)G--;return ie=B,{...I,span:{start:b.lineStarts[G],end:P(B)},id:String(R)}});for(const I of[J,...de.map(V=>V.span)]){const V=w.all.find(B=>B.start<I.start&&B.end>I.start||B.start<I.end&&B.end>I.end);if(V)return A(b.line(V.start),"a comment that straddles a cell","start the comment on its own line.")}return{ok:!0,source:{text:e,header:J,cells:de}}}const fy=e=>e.ok===!1,hy=/^[A-Za-z_][A-Za-z0-9_]*$/,Fl=/^query\s*:\s*([A-Za-z_][A-Za-z0-9_]*)\s+is\s+/,zl=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`;function Ci(e){let t="",n=0;for(;n<e.length;){const r=e.slice(n,n+2);if(r==="//"||r==="--"){const s=e.indexOf(`
|
|
154
|
+
`,n),i=s<0?e.length:s;t+=" ".repeat(i-n),n=i}else if(r==="/*"){const s=e.indexOf("*/",n+2),i=s<0?e.length:s+2;t+=e.slice(n,i).replace(/[^\n]/g," "),n=i}else if(e[n]==="'"||e[n]==='"'||e[n]==="`"){const s=e[n];let i=n+1;for(;i<e.length&&e[i]!==s;)i+=e[i]==="\\"?2:1;const o=Math.min(i,e.length);t+=s+e.slice(n+1,o).replace(/[^\n]/g," "),o<e.length&&(t+=s),n=o+1}else t+=e[n],n++}return t}function Wl(e){const t=[];let n=0;for(let r=0;r<e.length;r++){const s=e[r];s==="{"||s==="("||s==="["?n++:s==="}"||s===")"||s==="]"?n--:n===0&&s==="-"&&e[r+1]===">"&&t.push(r)}return t}function Bl(e,t,n){let r=e;for(const s of[...n].sort((i,o)=>o.start-i.start))r=r.slice(0,s.start-t)+r.slice(s.end-t);return r}function Gl(e,t){const n=t.split(`
|
|
155
155
|
`).map(r=>r.startsWith("|##")?` ${r}`:r).join(`
|
|
156
156
|
`);return`##|(markdown) ${e}
|
|
157
157
|
${n===""?"":`${n}
|
|
158
158
|
`}|##
|
|
159
|
-
`}function
|
|
160
|
-
`),o=
|
|
161
|
-
`),
|
|
162
|
-
`,1)[0])),...
|
|
163
|
-
`:" ";
|
|
164
|
-
`).join("");
|
|
165
|
-
`}if(
|
|
166
|
-
`).filter(
|
|
167
|
-
`)].filter(
|
|
168
|
-
`).map((
|
|
169
|
-
`);
|
|
170
|
-
`)),
|
|
159
|
+
`}function py(e){return e.trim()===""?"":/^\s*(#|\/\/|--|\/\*)/.test(e)?` ${e.trimStart()}`:` ${e}`}function gy(e){const t=(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),n=t.length>40?t.lastIndexOf("_",40):t.length,r=t.slice(0,n>0?n:40);return/^[a-z]/.test(r)&&ge.isBareName(r)?r:void 0}async function my(e){const t=await dy(e);if(ay(t))return{ok:!1,refused:t.refused,line:t.line};const{header:n,cells:r}=t.source,s=(C,W)=>({ok:!1,refused:`Line ${C+1}: ${W}`,line:C+1}),i=e.slice(n.start,n.end).split(`
|
|
160
|
+
`),o=ge.artifactTag(i);if(o&&!ge.artifactLeads(o.text))return s(o.from,ge.ARTIFACT_NOT_FIRST);if(!o||Sa(o.text))return s(Math.max(o?.from??0,0),"this notebook already lists its tiles, so there is nothing to convert.");const l=(await Wr(e,"file:///publisher-notebook-builder/convert.malloy")).parse?.tokenStream,d=l?.tokenSource?.vocabulary,u=l?.getTokens?.()??[];if(typeof d?.getSymbolicName!="function")return s(0,"Malloy's token stream is not available.");const c=await O.loadMalloy(),{parseAnnotation:f}=await O.loadMalloyTag(),h=C=>d.getSymbolicName(C.type),p=new ri(e),m=ka(p,l),b=C=>e.slice(p.utf16(C.startIndex),p.utf16(C.stopIndex+1)),w=C=>c.routeOf({value:C.trimStart()}),v=C=>c.payloadOf({value:C}),g=C=>C.replace(/\r\n?/g,`
|
|
161
|
+
`),y=new Set(e.match(/[A-Za-z_][A-Za-z0-9_]*/g)),_=C=>{let W=C;for(let M=2;y.has(W);M++)W=`${C}_${M}`;return y.add(W),W},S=C=>{const W=u.filter(Q=>Q.channel===0&&p.utf16(Q.startIndex)>=C.span.start&&p.utf16(Q.stopIndex+1)<=C.span.end),M=[],ee=[],X=[];let le;for(let Q=0;Q<W.length;Q++){const me=h(W[Q]);if(me!=="ANNOTATION"&&me!=="BLOCK_ANNOTATION_BEGIN"){le=W[Q];break}let se=Q;const te=[];if(me==="BLOCK_ANNOTATION_BEGIN"){for(;h(W[se+1]??W[Q])==="BLOCK_ANNOTATION_TEXT";)te.push(b(W[++se]));h(W[se+1]??W[Q])==="BLOCK_ANNOTATION_END"&&se++}const j=g(b(W[Q])),F=w(j),re=p.utf16(W[Q].startIndex),ue=p.lineStarts[p.line(re)],je={start:/^[ \t]*$/.test(e.slice(ue,re))?ue:re,end:p.utf16(W[se].stopIndex+1)};F==="markdown"?M.push(je):F==='"'&&(ee.push(je),X.push(me==="ANNOTATION"?g(v(j)).replace(/\n$/,"").trim():[g(v(j.split(`
|
|
162
|
+
`,1)[0])),...te.map(g)].map(Rt=>Rt.trim()).filter(Boolean).join(" "))),Q=se}if(!le)return;const ce=p.utf16(le.startIndex),N=e.slice(C.span.start,C.span.end);return{cell:C,above:Bl(e.slice(C.span.start,ce),C.span.start,(C.kind==="query"?[...M,...ee]:M).filter(Q=>Q.end<=ce)),statement:e.slice(ce,C.span.end).trimEnd(),kept:Bl(N,C.span.start,M),...C.kind==="query"&&X.length>0&&{caption:X.join(" ")},line:p.line(ce)}},E=new Map,A=new Map;for(const[C,W]of r.entries()){if(W.kind==="markdown")continue;const M=S(W);if(!M)return s(p.line(W.span.start),"a cell with no statement the converter can place.");A.set(C,M);const ee=Fl.exec(M.statement);W.kind==="definition"&&ee&&E.set(ee[1],{expression:M.statement.slice(ee[0].length).trim(),cell:C})}const T=C=>{const W=/^run\s*:\s*/.exec(C.statement);if(!W)return s(C.line,"a run that is not `run: <query>`.");let M=C.statement.slice(W[0].length).trim();const ee=[];for(let Q=0;Q<10;Q++){const me=Ci(M),se=/^[A-Za-z_][A-Za-z0-9_]*/.exec(me)?.[0],te=se?E.get(se):void 0;if(!se||!te)break;const j=M.slice(se.length).trim(),F=me.slice(se.length).trim();if(F!==""&&!F.startsWith("->")&&!F.startsWith("+"))break;if(F.startsWith("+")&&Wl(Ci(te.expression)).length!==1)return s(C.line,`\`${se} + { … }\` refines a query with more than one stage, which cannot become one view.`);ee.push(se);const re=/(\/\/|--)[^\n]*$/.test(te.expression)?`
|
|
163
|
+
`:" ";M=`${te.expression}${j===""?"":`${re}${j}`}`}const X=Ci(M);if(E.has(/^[A-Za-z_][A-Za-z0-9_]*/.exec(X)?.[0]??""))return s(C.line,"this run names a query defined through more than 10 other queries, which the converter does not follow.");const le=Wl(X);if(le.length===0)return s(C.line,"this run is not `source -> view`, so it cannot become a tile. Fix: write it as `run: <source> -> <view>`.");const ce=M.slice(0,le[0]).trim();if(/\bextend\b/.test(X.slice(0,le[0])))return s(C.line,"this run extends its source inline before `->`, so it cannot become a tile. Fix: declare the extension with a `source:` statement and run that.");if(!hy.test(ce)&&!/^`[^`]+`$/.test(ce))return s(C.line,"the source of this run is not a name, so it cannot become a tile. Fix: name it with a `source:` statement and run that.");const N=M.slice(le[0]+2).trim();return N===""?s(C.line,"this run has nothing after `->`."):{source:ce,body:N,used:ee}},D=new Map,q=[],P=new Set,z=new Map;let U=0,K=0;const Z=new Map;for(const C of A.values()){if(C.cell.kind!=="query")continue;const W=T(C);if("ok"in W)return W;for(const M of W.used)Z.set(M,(Z.get(M)??0)+1)}const J=C=>Z.get(C)===1&&(e.match(new RegExp(`\\b${C}\\b`,"g"))??[]).length===2,ie=new Map;for(const[C,W]of r.entries()){if(W.kind==="markdown"){const F=_(`text_${++U}`);q.push(`${F} { kind=text }`);const re=m.all.filter(ue=>ue.start>=W.span.start&&ue.end<=W.span.end).map(ue=>`${e.slice(ue.start,ue.end)}
|
|
164
|
+
`).join("");z.set(C,re+Gl(F,W.markdown??""));continue}const M=A.get(C);let ee="";if(W.markdown!==void 0){const F=_(`text_${++U}`);q.push(`${F} { kind=text }`),ee=`${Gl(F,W.markdown)}
|
|
165
|
+
`}if(W.kind==="definition"){const F=Fl.exec(M.statement)?.[1];if(F&&J(F)){P.add(C),ie.set(F,M.above.split(`
|
|
166
|
+
`).filter(re=>re.trim()!=="")),ee&&z.set(C,ee.replace(/\n$/,""));continue}z.set(C,`${ee}${M.kept}`);continue}const X=T(M),le=X.source.replace(/`/g,"").replace(/[^A-Za-z0-9_]+/g,"_").replace(/^(?=[0-9])/,"_");let ce=D.get(X.source);ce||(ce={name:_(`${le}_tiles`),base:X.source,views:[]},D.set(X.source,ce));const N=[...X.used.flatMap(F=>ie.get(F)??[]),...M.above.split(`
|
|
167
|
+
`)].filter(F=>F.trim()!==""),Q=N.filter(F=>/^\s*#(?!["(|])/.test(F)),me=Q.length>0?$a(f,Q).tag:void 0,se=_(gy(me?.text("label")??M.caption)??`tile_${K+1}`);K++,q.push(`"${ce.name} -> ${se}"`);const te=N.map(py);if(M.caption!==void 0){const F=O.annotationTextProblem("caption",M.caption)===void 0;F&&!me?.has("label")?te.push(` # label=${zl(M.caption)}`):F&&!me?.has("subtitle")?te.push(` # subtitle=${zl(M.caption)}`):te.push(` #" ${M.caption}`)}const j=X.body.split(`
|
|
168
|
+
`).map((F,re)=>re===0||F.trim()===""?F:` ${F}`).join(`
|
|
169
|
+
`);ce.views.push([...te,` view: ${se} is ${j}`].join(`
|
|
170
|
+
`)),P.add(C),ee&&z.set(C,ee.replace(/\n$/,""))}const de=(()=>{let C=0;const W=o.text;for(let M=W.indexOf("{");M<W.length;M++)if(W[M]==='"')for(M++;M<W.length&&W[M]!=='"';M++)W[M]==="\\"&&M++;else if(W[M]==="{")C++;else if(W[M]==="}"&&--C===0)return M;return-1})();if(de<0)return s(o.from,"the `## artifact { … }` tag never closes.");const I=q.length===0?`
|
|
171
171
|
tiles=[]
|
|
172
172
|
`:`
|
|
173
173
|
tiles=[
|
|
174
|
-
${
|
|
174
|
+
${q.map(C=>` ${C}`).join(`,
|
|
175
175
|
`)}
|
|
176
176
|
]
|
|
177
|
-
`,B=`${o.text.slice(0,
|
|
177
|
+
`,B=`${o.text.slice(0,de).replace(/[ \t]*\blayout\s*=\s*(?:"(?:[^"\\]|\\.)*"|[^\s}]+)/g,"").replace(/\bartifact\s*\{/,C=>`${C} layout=linear`).trimEnd().replace(/^##(?!\|)/,"##|")}${I}${o.text.slice(de)}`;i.splice(o.from,o.block?o.to-o.from:1,...(o.block?B:`${B}
|
|
178
178
|
|##`).split(`
|
|
179
|
-
`));const
|
|
180
|
-
`),
|
|
181
|
-
`).join("")+
|
|
182
|
-
`),
|
|
183
|
-
`)?
|
|
184
|
-
`),
|
|
185
|
-
`+(
|
|
186
|
-
`;const
|
|
187
|
-
${
|
|
179
|
+
`));const R=C=>{const W=C.text.split(`
|
|
180
|
+
`),M=W.pop(),ee=[];let X=0;for(const le of W){const ce=C.at[X]??-1,N=m.all.some(Q=>ce>=Q.start&&ce<Q.end);(le.trim()!==""||ee.at(-1)?.trim()!==""||N)&&ee.push(le),X+=le.length+1}return ee.map(le=>`${le}
|
|
181
|
+
`).join("")+M},G={text:"",at:[]},ne=(C,W)=>{G.text+=e.slice(C,W);for(let M=C;M<W;M++)G.at.push(M)};let Y=i.join(`
|
|
182
|
+
`),H=n.end;for(const[C,W]of r.entries()){ne(H,W.span.start),H=W.span.end;const M=z.get(C);M!==void 0&&(Y+=R(G)+(M.endsWith(`
|
|
183
|
+
`)?M:`${M}
|
|
184
|
+
`),G.text="",G.at=[])}ne(H,e.length),Y=`${Y.trimEnd()}
|
|
185
|
+
`+(G.text.trim()===""?"":R(G)),Y=`${Y.trimEnd()}
|
|
186
|
+
`;const L=[...D.values()].map(C=>`source: ${C.name} is ${C.base} extend {
|
|
187
|
+
${C.views.join(`
|
|
188
188
|
|
|
189
189
|
`)}
|
|
190
190
|
}
|
|
191
|
-
`);return
|
|
192
|
-
${
|
|
191
|
+
`);return L.length>0&&(Y+=`
|
|
192
|
+
${L.join(`
|
|
193
193
|
`)}`),e.includes(`\r
|
|
194
|
-
`)&&(
|
|
195
|
-
`)),{ok:!0,text:J,tiles:N.length}}const Oi=(e,t)=>t!==void 0&&!/\bline \d+/i.test(e)?`${e} (line ${t})`:e;async function yb(e,t,n=!1){const r=await Tr(e,t,n);if(!$r(r))return{ok:!0,document:r.document};if(!r.legacyNotebook)return{ok:!1,reason:Oi(r.reason,r.line)};const s=await bb(e);if(pb(s))return{ok:!1,reason:Oi(s.refused,s.line)};const i=await Tr(s.text,t,n);return $r(i)?{ok:!1,reason:`The converted notebook cannot be opened: ${Oi(i.reason,i.line)}`}:{ok:!0,document:i.document,conversion:{from:e,to:s.text}}}const Bl="a .malloynb notebook is read, not edited. Fix: rewrite it as a `.malloy` notebook under notebooks/ to edit it here.",Gl="the server did not send this notebook's text, so there is nothing here to edit. Fix: edit the file in the package.";function xb({workspace:e,draft:t,draftChecked:n,readFailure:r,packageText:s,fetchedAt:i,packageSettled:o,modelPath:a,notebook:l,noun:u,refusedEvent:d,legacyFormat:c,textHeld:f,startedAt:p,onEventRef:h}){const m=e?.authoritative===!0,y=m&&r!==void 0,[w,v]=k.useState(void 0),g=(m||w===!0)&&t!==void 0,[b,_]=k.useState(void 0),[O,I]=k.useState(c?Bl:void 0),M=k.useRef(void 0),T=k.useRef(void 0),[D,N]=k.useState(void 0),R=k.useRef(i);R.current=i;const W=D!==void 0&&D.onFetch===i?D.text:s,X=k.useRef(W);X.current=W;const G=g?t:W,[U,Y]=k.useState(!1),[re,ee]=k.useState(void 0),[A,B]=k.useState(void 0),z=G!==void 0&&G!==A,j=b?.source,J=z&&(U||!m&&t!==void 0&&j===t&&t!==W)&&j!==void 0&&G!==re,Q=J?j:z?G:j??G,H=J?G:void 0,$=k.useRef(j);$.current=j;const P=k.useRef(G);P.current=G;const F=k.useRef("package");F.current=g?m?"record":"draft":"package",k.useEffect(()=>{if(Q===void 0||!n||y||Q===$.current)return;let ne=!1;const de=X.current,se=P.current;return yb(Q,a,f).then(L=>{if(!ne){if(L.ok===!1){I(L.reason),h.current?.({type:d,reason:L.reason});return}I(void 0),M.current=void 0,T.current=de,N(void 0),ee(void 0),B(se),_(te=>({source:Q,document:L.document,...L.conversion?{conversion:L.conversion}:{},...de!==void 0?{packageText:de}:{},generation:(te?.generation??0)+1})),h.current?.(l||L.document.kind==="notebook"?{type:"notebook.opened",from:F.current==="package"?"package":"record",cells:L.document.tiles.length,durationMs:E.now()-p.current}:{type:"dashboard.opened",from:F.current,tiles:L.document.tiles.length,durationMs:E.now()-p.current})}}).catch(L=>{if(ne)return;const te=`Could not read the ${u}: ${L instanceof Error?L.message:String(L)}`;I(te),h.current?.({type:d,reason:te})}),()=>{ne=!0}},[Q,a,n,y,l,u,d,f,p,h]),k.useEffect(()=>{c&&h.current?.({type:"notebook.open_refused",reason:Bl})},[c,h]),k.useEffect(()=>{!f||!n||b||r!==void 0||(m?t===void 0&&I("the host's storage has no document at this location."):I("a document held as text needs a storage whose workspace is authoritative. Fix: mark the workspace that keeps it `authoritative`."))},[f,n,b,r,m,t]);const V=l&&!f&&!b&&n&&!g&&o&&s===void 0;return k.useEffect(()=>{V&&(I(Gl),h.current?.({type:"notebook.open_refused",reason:Gl}))},[V,h]),{authoritative:m,blockedOnRecord:y,resume:w,setResume:v,fromDraft:g,opened:b,setOpened:_,openError:O,savedHashRef:M,packageBaseRef:T,setWrote:N,fetchedAtRef:R,setDirty:Y,setSeen:B,held:H,choose:ne=>{p.current=E.now(),ee(ne?t:W),v(ne)},acceptHeld:()=>{p.current=E.now(),ee(H)}}}function wb({storage:e,workspace:t,kind:n,notebook:r,environmentName:s,packageName:i,modelPath:o,versionId:a,apiClients:l,queryClient:u,mutable:d,textHeld:c,readFailure:f,authoritative:p,resume:h,setResume:m,setOpened:y,setDraft:w,setOffered:v,setSeen:g,setWrote:b,savedHashRef:_,packageBaseRef:O,fetchedAtRef:I}){const M=t===void 0?void 0:E.locatorFor(n,t.name,s,i,o),T=k.useCallback(async ee=>{if(!e||!M)throw new Error("This host keeps no documents, so there is nowhere to save.");await e.saveDocument(M,ee),y(A=>A&&{...A,source:ee}),w(ee),(p||h===!0)&&g(ee),p||m(A=>A??!1)},[e,M,p,h,y,w,g,m]),[D,N]=k.useState(void 0),R=k.useCallback(async ee=>{const A=await E.expectedHashFor(_.current,O.current);if(A===void 0)throw new Error("The package file is still loading; try again.");const B=["dashboard-editor-model",s,i,o,a,r];await E.writePackageFile({apiClients:l,queryClient:u,environmentName:s,packageName:i,modelPath:o,source:ee,expectedHash:A,invalidateOnError:[B],afterWrite:async z=>{if(y(j=>j&&{...j,source:ee}),b({text:ee,onFetch:I.current}),g(ee),_.current=z,N(void 0),e&&M)try{await e.deleteDocument(M),w(void 0),v(!1)}catch(j){E.isDocumentNotFound(j)?(w(void 0),v(!1)):N(E.storageErrorMessage(j))}m(!1)},invalidate:[{queryKey:B,wait:!0},{queryKey:E.modelResultsKey({environmentName:s,packageName:i,versionId:a,modelPath:o})},{queryKey:["dashboard-editor-manifest"]},{queryKey:["dashboards"]},{queryKey:["dashboard"]},...r?[{queryKey:[E.encodeResourceUri({environmentName:s,packageName:i,modelPath:o})]}]:[]]})},[l,s,i,o,a,r,e,M,u,_,O,I,y,b,g,w,v,m]),W=t?.writeable===!0,X=d===!0&&!c,{savesTo:G,pinnedPackageSave:U,writer:Y}=E.saveTarget({authoritative:p,mutable:X,...a!==void 0?{versionId:a}:{},canStore:!!e&&!!M&&W&&(!r||p),readFailed:f!==void 0});return{save:Y==="storage"?T:Y==="package"?R:void 0,savesTo:G,writer:Y,pinnedPackageSave:U,takesWrites:X,supersedeFailure:D}}function Ju(e){const{onEvent:t,onDirtyChange:n,onExit:r,kind:s="dashboard",path:i,textSource:o}=e,a=s==="notebook",l=o!==void 0,{environmentName:u,packageName:d,versionId:c,namesBoth:f}=E.resolveEditorTarget(e),p="resourceUri"in e?e.dashboard:e.dashboardName,h=a?"notebook":"dashboard",m=a?"notebook.open_refused":"dashboard.open_refused",{apiClients:y,mutable:w,isLoadingStatus:v}=Ke.useServer(),g=lf.useQueryClient(),b=k.useRef(E.now()),_=k.useRef(t);_.current=t;const O=k.useRef(n);O.current=n;const I=E.useOptionalDocumentStorage()?.documentStorage,M=a&&/\.malloynb$/i.test(p),T=i??`${s}s/${p}.malloy`,D=E.useQueryWithApiError({queryKey:["dashboard-editor-model",u,d,T,c,a],queryFn:()=>y.models.getModel(u,d,T,c,a?!0:void 0),enabled:f&&!M&&!l}),N=D.data?.data?.sourceText,{workspace:R,draft:W,setDraft:X,draftChecked:G,offered:U,setOffered:Y,readFailure:re}=lb({storage:I,kind:s,notebook:a,environmentName:u,packageName:d,modelPath:T}),{authoritative:ee,blockedOnRecord:A,resume:B,setResume:z,fromDraft:j,opened:q,setOpened:J,openError:Q,savedHashRef:H,packageBaseRef:$,setWrote:P,fetchedAtRef:F,setDirty:V,setSeen:oe,held:Z,choose:ne,acceptHeld:de}=xb({workspace:R,draft:W,draftChecked:G,readFailure:re,packageText:N,fetchedAt:D.dataUpdatedAt,packageSettled:D.isSuccess&&!D.isFetching,modelPath:T,notebook:a,noun:h,refusedEvent:m,legacyFormat:M,textHeld:l,startedAt:b,onEventRef:_}),{save:se,savesTo:L,writer:te,pinnedPackageSave:pe,takesWrites:ae,supersedeFailure:C}=wb({storage:I,workspace:R,kind:s,notebook:a,environmentName:u,packageName:d,modelPath:T,versionId:c,apiClients:y,queryClient:g,mutable:w,textHeld:l,readFailure:re,authoritative:ee,resume:B,setResume:z,setOpened:J,setDraft:X,setOffered:Y,setSeen:oe,setWrote:P,savedHashRef:H,packageBaseRef:$,fetchedAtRef:F}),K=R?.name,ie=k.useCallback(vt=>{_.current?.(E.withWorkspace(vt,K))},[K]),ve=k.useCallback(vt=>{V(vt),O.current?.(vt)},[V]),Re=L==="host"&&R?.description?R.description:void 0,Nn=!ee&&!l&&w===void 0?v?"Checking whether this server takes writes.":"This server did not say whether it takes writes, so Save is off.":E.saveCaption({authoritative:ee,mutable:ae,pinnedPackageSave:pe,...R?{workspace:R}:{},...re!==void 0?{readFailure:re}:{},...c!==void 0?{versionId:c}:{}}),mt=Nn===Re?"":Nn;if(!f&&"resourceUri"in e)return x.jsxs(S.Alert,{severity:"error",sx:{m:2},children:["A ",h," resource URI must name an environment and a package. Received: ",e.resourceUri]});if(Q)return x.jsxs(S.Alert,{severity:"error",sx:{m:2},children:["This ",h," cannot be opened in the builder: ",Q]});if(D.isError&&!q)return x.jsx(E.ApiErrorDisplay,{error:D.error,context:`Opening the ${h}`});if(!q&&(!(l||N)||!G))return x.jsx(E.Loading,{text:`Opening the ${h}…`});if(A)return x.jsxs(S.Alert,{severity:"error",sx:{m:2},children:["This ",h," cannot be opened: ",re]});const Fn=W!==void 0&&W!==N;return x.jsxs(S.Stack,{sx:{gap:2},children:[D.isError&&x.jsxs(S.Alert,{severity:"warning",children:["The ",h," could not be re-read from the server:"," ",D.error?.message,". Your edits are still here."]}),!a&&!ee&&U&&Fn&&B===void 0&&x.jsx(S.Alert,{severity:"info",action:x.jsxs(S.Stack,{direction:"row",sx:{gap:1},children:[x.jsx(S.Button,{size:"small",onClick:()=>ne(!0),children:"Resume"}),x.jsx(S.Button,{size:"small",onClick:()=>ne(!1),children:"Start from the package"})]}),children:"You have edits to this dashboard saved in this browser that the package does not have."}),Z!==void 0&&x.jsx(S.Alert,{severity:"warning",action:x.jsx(S.Button,{size:"small",onClick:de,children:"Load it"}),children:L==="package"?"This dashboard changed since you opened it. Your edits are still here; loading the new version replaces them, and until you do, saving is refused.":L==="host"?"This dashboard changed since you opened it. Your edits are still here; loading the new version replaces them, and saving keeps yours and writes over it.":"The package's copy of this dashboard changed since you opened it. Your edits are still here; loading the new version replaces them."}),C!==void 0&&x.jsxs(S.Alert,{severity:"warning",children:["The file was saved into the package, but the copy kept beside it could not be cleared, so it will be offered again:"," ",C]}),q&&x.jsx(ab,{kind:s,environmentName:u,packageName:d,modelPath:T,...o?{textSource:o}:{},slug:p,modelGivens:D.data?.data?.givens,...c!==void 0?{versionId:c}:{},opened:q,...j&&te==="package"&&q.packageText!==void 0?{replaces:q.packageText}:{},onSave:se,onDirtyChange:ve,...r?{onExit:r}:{},savesTo:L,...Re?{saveLabel:Re}:{},...t?{onEvent:ie}:{},note:mt},q.generation)]})}function _b(e){const{onEvent:t,onDirtyChange:n,onExit:r,path:s}=e,i="resourceUri"in e?{resourceUri:e.resourceUri,dashboard:e.notebook}:{environmentName:e.environmentName,packageName:e.packageName,dashboardName:e.notebookName};return x.jsx(Ju,{...i,kind:"notebook",...t?{onEvent:t}:{},...n?{onDirtyChange:n}:{},...r?{onExit:r}:{},...s!==void 0?{path:s}:{}})}typeof globalThis.process>"u"?globalThis.process={env:{}}:globalThis.process.env===void 0&&(globalThis.process.env={});exports.MAX_SLUG_ATTEMPTS=E.MAX_SLUG_ATTEMPTS;exports.createDocument=E.createDocument;exports.createRoute=E.createRoute;exports.documentPathFor=E.documentPathFor;exports.documentPathForTitle=E.documentPathForTitle;exports.locatorFor=E.locatorFor;exports.newDashboardSource=E.newDashboardSource;exports.newDocumentProblem=E.newDocumentProblem;exports.newNotebookSource=E.newNotebookSource;exports.slugFor=E.slugFor;exports.slugOrFallback=E.slugOrFallback;exports.useDocumentChoices=E.useDocumentChoices;exports.DashboardBuilder=Qu;exports.DashboardEditor=Ju;exports.NotebookEditor=_b;exports.buildCatalog=Hu;exports.readDashboardDocument=Tr;exports.readFailed=$r;exports.spliceDashboardDocument=Gu;exports.spliceFailed=Rs;
|
|
194
|
+
`)&&(Y=Y.replace(/\r?\n/g,`\r
|
|
195
|
+
`)),{ok:!0,text:Y,tiles:q.length}}const Ii=(e,t)=>t!==void 0&&!/\bline \d+/i.test(e)?`${e} (line ${t})`:e;async function vy(e){const t=await Cr(e);if(!Er(t))return{ok:!0,document:t.document};if(!t.legacyNotebook)return{ok:!1,reason:Ii(t.reason,t.line)};const n=await my(e);if(fy(n))return{ok:!1,reason:Ii(n.refused,n.line)};const r=await Cr(n.text);return Er(r)?{ok:!1,reason:`The converted notebook cannot be opened: ${Ii(r.reason,r.line)}`}:{ok:!0,document:r.document,conversion:{from:e,to:n.text}}}const yy="a .malloynb notebook is read, not edited. Fix: rewrite it as a `.malloy` report to edit it here.",by="the server did not send this notebook's text, so there is nothing here to edit. Fix: edit the file in the package.";function xy({workspace:e,draft:t,draftChecked:n,readFailure:r,packageText:s,fetchedAt:i,packageSettled:o,modelPath:a,layout:l,notebook:d,noun:u,legacyFormat:c,textHeld:f,startedAt:h,onEventRef:p}){const m=k.useRef({path:a,layout:l});m.current={path:a,layout:l};const b=k.useRef((N,Q)=>{try{p.current?.(O.withReportContext(N,{...m.current,...Q?{layout:Q}:{}}))}catch{}}),w=e?.authoritative===!0,v=w&&r!==void 0,[g,y]=k.useState(void 0),_=(w||g===!0)&&t!==void 0,[S,E]=k.useState(void 0),[A,T]=k.useState(c?yy:void 0),D=k.useRef(void 0),q=k.useRef(void 0),[P,z]=k.useState(void 0),U=k.useRef(i);U.current=i;const K=P!==void 0&&P.onFetch===i?P.text:s,Z=k.useRef(K);Z.current=K;const J=_?t:K,[ie,de]=k.useState(!1),[I,V]=k.useState(void 0),[B,R]=k.useState(void 0),G=J!==void 0&&J!==B,ne=S?.source,H=G&&(ie||!w&&t!==void 0&&ne===t&&t!==K)&&ne!==void 0&&J!==I,L=H?ne:G?J:ne??J,C=H?J:void 0,W=k.useRef(ne);W.current=ne;const M=k.useRef(J);M.current=J;const ee=k.useRef("package");ee.current=_?w?"record":"draft":"package",k.useEffect(()=>{if(L===void 0||!n||v||L===W.current)return;let N=!1;const Q=Z.current,me=M.current;return vy(L).then(se=>{if(!N){if(se.ok===!1){T(se.reason),b.current({type:"report.load_failed",surface:"edit",category:"invalid"});return}T(void 0),D.current=void 0,q.current=Q,z(void 0),V(void 0),R(me),E(te=>({source:L,document:se.document,...se.conversion?{conversion:se.conversion}:{},...Q!==void 0?{packageText:Q}:{},generation:(te?.generation??0)+1})),b.current({type:"report.opened",surface:"edit",from:ee.current,tiles:se.document.tiles.length,durationMs:O.now()-h.current},se.document.layout)}}).catch(se=>{if(N)return;const te=`Could not read the ${u}: ${se instanceof Error?se.message:String(se)}`;T(te),b.current({type:"report.load_failed",surface:"edit",category:O.failureCategory(se)})}),()=>{N=!0}},[L,a,n,v,d,u,f,h]),k.useEffect(()=>{c&&b.current({type:"report.load_failed",surface:"edit",category:"unsupported"})},[c]),k.useEffect(()=>{!f||!n||S||r!==void 0||(w?t===void 0&&T("the host's storage has no document at this location."):T("a document held as text needs a storage whose workspace is authoritative. Fix: mark the workspace that keeps it `authoritative`."))},[f,n,S,r,w,t]);const X=d&&!f&&!S&&n&&!_&&o&&s===void 0;return k.useEffect(()=>{X&&(T(by),b.current({type:"report.load_failed",surface:"edit",category:"forbidden"}))},[X]),{authoritative:w,blockedOnRecord:v,resume:g,setResume:y,fromDraft:_,opened:S,setOpened:E,openError:A,savedHashRef:D,packageBaseRef:q,setWrote:z,fetchedAtRef:U,setDirty:de,setSeen:R,held:C,choose:N=>{h.current=O.now(),V(N?t:K),y(N)},acceptHeld:()=>{h.current=O.now(),V(C)}}}function wy({storage:e,workspace:t,layout:n,notebook:r,environmentName:s,packageName:i,modelPath:o,versionId:a,apiClients:l,queryClient:d,mutable:u,textHeld:c,readFailure:f,authoritative:h,resume:p,setResume:m,setOpened:b,setDraft:w,setOffered:v,setSeen:g,setWrote:y,savedHashRef:_,packageBaseRef:S,fetchedAtRef:E}){const A=k.useCallback(I=>t===void 0?void 0:O.locatorFor(I,t.name,s,i,o),[t,s,i,o]),T=A(n),D=k.useCallback(async(I,V=n)=>{const B=A(V);if(!e||!B)throw new Error("This host keeps no documents, so there is nowhere to save.");await e.saveDocument(B,I),b(R=>R&&{...R,source:I}),w(I),(h||p===!0)&&g(I),h||m(R=>R??!1)},[e,A,n,h,p,b,w,g,m]),[q,P]=k.useState(void 0),z=k.useCallback(async I=>{const V=await O.expectedHashFor(_.current,S.current);if(V===void 0)throw new Error("The package file is still loading; try again.");const B=["dashboard-editor-model",s,i,o,a,r];await O.writePackageFile({apiClients:l,queryClient:d,environmentName:s,packageName:i,modelPath:o,source:I,expectedHash:V,invalidateOnError:[B],afterWrite:async R=>{if(b(G=>G&&{...G,source:I}),y({text:I,onFetch:E.current}),g(I),_.current=R,P(void 0),e&&T)try{await e.deleteDocument(T),w(void 0),v(!1)}catch(G){O.isDocumentNotFound(G)?(w(void 0),v(!1)):P(O.storageErrorMessage(G))}m(!1)},invalidate:[{queryKey:B,wait:!0},{queryKey:O.modelResultsKey({environmentName:s,packageName:i,versionId:a,modelPath:o})},{queryKey:["dashboard-editor-manifest"]}]}),O.invalidateReportQueries(d,s,i,o)},[l,s,i,o,a,r,e,T,d,_,S,E,b,y,g,w,v,m]),U=t?.writeable===!0,K=u===!0&&!c,{savesTo:Z,pinnedPackageSave:J,writer:ie}=O.saveTarget({authoritative:h,mutable:K,...a!==void 0?{versionId:a}:{},canStore:!!e&&!!T&&U&&(!r||h),readFailed:f!==void 0});return{save:ie==="storage"?D:ie==="package"?z:void 0,savesTo:Z,writer:ie,pinnedPackageSave:J,takesWrites:K,supersedeFailure:q}}function Ea(e){const{onEvent:t,onDirtyChange:n,onExit:r,kind:s,path:i,textSource:o,allowLayoutChange:a}=e,l=e.layout??(s?O.layoutOfKind(s):"grid"),d=l==="linear",u=o!==void 0,{environmentName:c,packageName:f,versionId:h,namesBoth:p}=O.resolveEditorTarget(e),b=("resourceUri"in e?e.dashboard:e.dashboardName)??O.documentSlug(i)??"",w="report",{apiClients:v,mutable:g,isLoadingStatus:y}=Be.useServer(),_=ql.useQueryClient(),S=k.useRef(O.now()),E=k.useRef(t);E.current=t;const A=k.useRef(n);A.current=n;const T=O.useOptionalDocumentStorage()?.documentStorage,D=i??O.legacyNamedPath(s??"dashboard",b),q=/\.malloynb$/i.test(D)||d&&/\.malloynb$/i.test(b),P=O.useQueryWithApiError({queryKey:["dashboard-editor-model",c,f,D,h,d],queryFn:()=>v.models.getModel(c,f,D,h,d?!0:void 0),enabled:p&&!q&&!u}),z=P.data?.data?.sourceText,{workspace:U,draft:K,setDraft:Z,draftChecked:J,offered:ie,setOffered:de,readFailure:I}=oy({storage:T,layout:l,notebook:d,environmentName:c,packageName:f,modelPath:D}),{authoritative:V,blockedOnRecord:B,resume:R,setResume:G,fromDraft:ne,opened:Y,setOpened:H,openError:L,savedHashRef:C,packageBaseRef:W,setWrote:M,fetchedAtRef:ee,setDirty:X,setSeen:le,held:ce,choose:N,acceptHeld:Q}=xy({workspace:U,draft:K,draftChecked:J,readFailure:I,packageText:z,fetchedAt:P.dataUpdatedAt,packageSettled:P.isSuccess&&!P.isFetching,modelPath:D,layout:l,notebook:d,noun:w,legacyFormat:q,textHeld:u,startedAt:S,onEventRef:E}),{save:me,savesTo:se,writer:te,pinnedPackageSave:j,takesWrites:F,supersedeFailure:re}=wy({storage:T,workspace:U,layout:l,notebook:d,environmentName:c,packageName:f,modelPath:D,versionId:h,apiClients:v,queryClient:_,mutable:g,textHeld:u,readFailure:I,authoritative:V,resume:R,setResume:G,setOpened:H,setDraft:Z,setOffered:de,setSeen:le,setWrote:M,savedHashRef:C,packageBaseRef:W,fetchedAtRef:ee}),ue=U?.name,je=k.useCallback(jt=>{E.current?.(O.withWorkspace(jt,ue))},[ue]),Rt=P.isError&&!Y,ut=k.useRef(!1);k.useEffect(()=>{!Rt||ut.current||(ut.current=!0,O.reportEmitter({path:D,layout:l},E.current).emit({type:"report.load_failed",surface:"edit",category:O.failureCategory(P.error)}))},[Rt,P.error,D,l]);const zn=k.useCallback(jt=>{X(jt),A.current?.(jt)},[X]),_t=se==="host"&&U?.description?U.description:void 0,Wn=!V&&!u&&g===void 0?y?"Checking whether this server takes writes.":"This server did not say whether it takes writes, so Save is off.":O.saveCaption({authoritative:V,mutable:F,pinnedPackageSave:j,...U?{workspace:U}:{},...I!==void 0?{readFailure:I}:{},...h!==void 0?{versionId:h}:{}}),Gr=Wn===_t?"":Wn;if(!p&&"resourceUri"in e)return x.jsxs($.Alert,{severity:"error",sx:{m:2},children:["A ",w," resource URI must name an environment and a package. Received: ",e.resourceUri]});if(L)return x.jsxs($.Alert,{severity:"error",sx:{m:2},children:["This ",w," cannot be opened in the builder: ",L]});if(P.isError&&!Y)return x.jsx(O.ApiErrorDisplay,{error:P.error,context:`Opening the ${w}`});if(!Y&&(!(u||z)||!J))return x.jsx(O.Loading,{text:`Opening the ${w}…`});if(B)return x.jsxs($.Alert,{severity:"error",sx:{m:2},children:["This ",w," cannot be opened: ",I]});const Bn=K!==void 0&&K!==z;return x.jsxs($.Stack,{sx:{gap:2},children:[P.isError&&x.jsxs($.Alert,{severity:"warning",children:["The ",w," could not be re-read from the server:"," ",P.error?.message,". Your edits are still here."]}),!d&&!V&&ie&&Bn&&R===void 0&&x.jsx($.Alert,{severity:"info",action:x.jsxs($.Stack,{direction:"row",sx:{gap:1},children:[x.jsx($.Button,{size:"small",onClick:()=>N(!0),children:"Resume"}),x.jsx($.Button,{size:"small",onClick:()=>N(!1),children:"Start from the package"})]}),children:"You have edits to this report saved in this browser that the package does not have."}),ce!==void 0&&x.jsx($.Alert,{severity:"warning",action:x.jsx($.Button,{size:"small",onClick:Q,children:"Load it"}),children:se==="package"?"This report changed since you opened it. Your edits are still here; loading the new version replaces them, and until you do, saving is refused.":se==="host"?"This report changed since you opened it. Your edits are still here; loading the new version replaces them, and saving keeps yours and writes over it.":"The package's copy of this report changed since you opened it. Your edits are still here; loading the new version replaces them."}),re!==void 0&&x.jsxs($.Alert,{severity:"warning",children:["The file was saved into the package, but the copy kept beside it could not be cleared, so it will be offered again:"," ",re]}),Y&&x.jsx(iy,{environmentName:c,packageName:f,modelPath:D,...o?{textSource:o}:{},slug:b,modelGivens:P.data?.data?.givens,...h!==void 0?{versionId:h}:{},opened:Y,...ne&&te==="package"&&Y.packageText!==void 0?{replaces:Y.packageText}:{},onSave:me,onDirtyChange:zn,...r?{onExit:r}:{},...a!==void 0?{allowLayoutChange:a}:{},savesTo:se,..._t?{saveLabel:_t}:{},...t?{onEvent:je}:{},note:Gr},Y.generation)]})}const _y=Ea,ky=Oa;function Sy(e){const{onEvent:t,onDirtyChange:n,onExit:r,path:s}=e,i="resourceUri"in e?{resourceUri:e.resourceUri,dashboard:e.notebook}:{environmentName:e.environmentName,packageName:e.packageName,dashboardName:e.notebookName};return x.jsx(Ea,{...i,kind:"notebook",...t?{onEvent:t}:{},...n?{onDirtyChange:n}:{},...r?{onExit:r}:{},...s!==void 0?{path:s}:{}})}typeof globalThis.process>"u"?globalThis.process={env:{}}:globalThis.process.env===void 0&&(globalThis.process.env={});exports.MAX_SLUG_ATTEMPTS=O.MAX_SLUG_ATTEMPTS;exports.createDocument=O.createDocument;exports.createRoute=O.createRoute;exports.locatorFor=O.locatorFor;exports.newDashboardSource=O.newDashboardSource;exports.newDocumentProblem=O.newDocumentProblem;exports.newNotebookSource=O.newNotebookSource;exports.reportPathFor=O.reportPathFor;exports.reportPathForTitle=O.reportPathForTitle;exports.slugFor=O.slugFor;exports.slugOrFallback=O.slugOrFallback;exports.useDocumentChoices=O.useDocumentChoices;exports.DashboardBuilder=ky;exports.DashboardEditor=_y;exports.NotebookEditor=Sy;exports.ReportBuilder=Oa;exports.ReportEditor=Ea;exports.buildCatalog=Yd;exports.readDashboardDocument=Cr;exports.readFailed=Er;exports.readReportTagOfText=Cm;exports.spliceDashboardDocument=Kd;exports.spliceFailed=zs;
|