@malloy-publisher/sdk 0.9.1 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{RenderedResult-BRgIgxWh.es.js → RenderedResult-DwB0-9Yx.es.js} +219 -210
- package/dist/RenderedResult-hKjFEqaN.cjs.js +141 -0
- package/dist/{ServerProvider-Boxrv6Ym.es.js → ServerProvider-CcSrGaRN.es.js} +1473 -1326
- package/dist/ServerProvider-Gbf1YPOP.cjs.js +1 -0
- package/dist/builder/index.cjs.js +143 -58
- package/dist/builder/index.es.js +12179 -9318
- package/dist/builder-entry.d.ts +5 -1
- package/dist/client/api.d.ts +247 -56
- package/dist/client/configuration.d.ts +1 -1
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.es.js +94 -88
- package/dist/client-entry.d.ts +2 -0
- package/dist/components/ApiErrorDisplay.d.ts +11 -0
- package/dist/components/AppDialog.d.ts +6 -6
- package/dist/components/Dashboard/Dashboard.d.ts +8 -15
- package/dist/components/Dashboard/DashboardGrid.d.ts +38 -6
- package/dist/components/Dashboard/DashboardTile.d.ts +21 -2
- package/dist/components/Dashboard/DashboardView.d.ts +71 -0
- package/dist/components/Dashboard/TileCard.d.ts +30 -5
- package/dist/components/Dashboard/TileFilterTag.d.ts +12 -0
- package/dist/components/Dashboard/dropValueUrlTags.d.ts +6 -0
- package/dist/components/Dashboard/index.d.ts +5 -1
- package/dist/components/Dashboard/telemetry.d.ts +16 -3
- package/dist/components/Dashboard/textSource.d.ts +19 -0
- package/dist/components/DashboardBuilder/AddTileDialog.d.ts +15 -9
- package/dist/components/DashboardBuilder/BuilderDialogs.d.ts +25 -0
- package/dist/components/DashboardBuilder/BuilderGrid.d.ts +31 -0
- package/dist/components/DashboardBuilder/BuilderHeader.d.ts +17 -0
- package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +23 -15
- package/dist/components/DashboardBuilder/ChartPicker.d.ts +31 -0
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +56 -21
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +44 -5
- package/dist/components/DashboardBuilder/EditorSurface.d.ts +33 -0
- package/dist/components/DashboardBuilder/FilterDialog.d.ts +2 -2
- package/dist/components/DashboardBuilder/FilterStrip.d.ts +8 -4
- package/dist/components/DashboardBuilder/InlineMarkdown.d.ts +18 -0
- package/dist/components/DashboardBuilder/InlineText.d.ts +19 -0
- package/dist/components/DashboardBuilder/NotebookEditor.d.ts +15 -0
- package/dist/components/DashboardBuilder/SourceViewPicker.d.ts +9 -0
- package/dist/components/DashboardBuilder/TextTileBody.d.ts +10 -0
- package/dist/components/DashboardBuilder/TileFrame.d.ts +51 -12
- package/dist/components/DashboardBuilder/TileMenu.d.ts +12 -6
- package/dist/components/DashboardBuilder/annotationText.d.ts +4 -0
- package/dist/components/DashboardBuilder/builderReport.d.ts +13 -0
- package/dist/components/DashboardBuilder/catalog.d.ts +4 -18
- package/dist/components/DashboardBuilder/changedTile.d.ts +7 -0
- package/dist/components/DashboardBuilder/chartLine.d.ts +33 -0
- package/dist/components/DashboardBuilder/controls.d.ts +2 -2
- package/dist/components/DashboardBuilder/document.d.ts +42 -26
- package/dist/components/DashboardBuilder/documentSession.d.ts +100 -0
- package/dist/components/DashboardBuilder/imports.d.ts +19 -0
- package/dist/components/DashboardBuilder/inlineEdit.d.ts +18 -0
- package/dist/components/DashboardBuilder/legacyNotebook.d.ts +73 -0
- package/dist/components/DashboardBuilder/loadMalloy.d.ts +15 -0
- package/dist/components/DashboardBuilder/malloyTree.d.ts +119 -0
- package/dist/components/DashboardBuilder/newDashboard.d.ts +3 -1
- package/dist/components/DashboardBuilder/openDraft.d.ts +10 -0
- package/dist/components/DashboardBuilder/preview.d.ts +24 -4
- package/dist/components/DashboardBuilder/readDocument.d.ts +6 -1
- package/dist/components/DashboardBuilder/readForEditor.d.ts +16 -0
- package/dist/components/DashboardBuilder/sortable.d.ts +16 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +15 -13
- package/dist/components/DashboardBuilder/spliceResult.d.ts +11 -0
- package/dist/components/DashboardBuilder/tagParse.d.ts +24 -0
- package/dist/components/DashboardBuilder/telemetry.d.ts +43 -0
- package/dist/components/DashboardBuilder/testing/fixtures.d.ts +3 -1
- package/dist/components/DashboardBuilder/testing/inline.d.ts +4 -0
- package/dist/components/DashboardBuilder/testing/resize.d.ts +7 -0
- package/dist/components/DashboardBuilder/tileDisplayTitle.d.ts +7 -0
- package/dist/components/DashboardBuilder/useBuilderSelection.d.ts +53 -0
- package/dist/components/DashboardBuilder/useBuilderSession.d.ts +86 -0
- package/dist/components/DashboardBuilder/useBuilderShortcuts.d.ts +9 -6
- package/dist/components/DashboardBuilder/useControlBindings.d.ts +30 -0
- package/dist/components/DashboardBuilder/useConversionConfirm.d.ts +20 -0
- package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +19 -55
- package/dist/components/DashboardBuilder/useDocumentEditor.d.ts +105 -0
- package/dist/components/DashboardBuilder/useDraft.d.ts +3 -1
- package/dist/components/DashboardBuilder/useExitGuard.d.ts +19 -0
- package/dist/components/DashboardBuilder/useFilterForm.d.ts +3 -3
- package/dist/components/DashboardBuilder/useHostCopy.d.ts +26 -0
- package/dist/components/DashboardBuilder/useOpenDraftCommit.d.ts +17 -0
- package/dist/components/DashboardBuilder/useOpenedDocument.d.ts +71 -0
- package/dist/components/DashboardBuilder/useSaveChannel.d.ts +50 -0
- package/dist/components/DashboardBuilder/useTileEditing.d.ts +33 -0
- package/dist/components/DashboardBuilder/useTileResize.d.ts +6 -3
- package/dist/components/DocumentCreate/canRetry.d.ts +6 -0
- package/dist/components/DocumentCreate/createDocument.d.ts +58 -0
- package/dist/components/DocumentCreate/documentPath.d.ts +10 -0
- package/dist/components/DocumentCreate/events.d.ts +10 -0
- package/dist/components/DocumentCreate/exportedSources.d.ts +7 -0
- package/dist/components/DocumentCreate/guards.d.ts +12 -0
- package/dist/components/DocumentCreate/index.d.ts +6 -0
- package/dist/components/DocumentCreate/newNotebook.d.ts +9 -0
- package/dist/components/DocumentCreate/useDocumentChoices.d.ts +32 -0
- package/dist/components/DocumentStorage/DocumentStorage.d.ts +2 -1
- package/dist/components/Loading.d.ts +13 -0
- package/dist/components/NarrowEditGate.d.ts +8 -0
- package/dist/components/Notebook/Notebook.d.ts +1 -1
- package/dist/components/Notebook/NotebookCell.d.ts +1 -5
- package/dist/components/Package/NewDocumentDialog.d.ts +33 -0
- package/dist/components/Package/Package.d.ts +17 -1
- package/dist/components/Package/documentLocation.d.ts +28 -0
- package/dist/components/Package/index.d.ts +5 -1
- package/dist/components/Package/useDocumentLocation.d.ts +12 -0
- package/dist/components/PackageSection.d.ts +2 -2
- package/dist/components/Prose.d.ts +1 -1
- package/dist/components/RenderedResult/RenderedResult.d.ts +2 -0
- package/dist/components/RenderedResult/ResultContainer.d.ts +8 -1
- package/dist/components/RenderedResult/ResultPanel.d.ts +3 -1
- package/dist/components/RenderedResult/loadRenderer.d.ts +7 -0
- package/dist/components/RenderedResult/resultSizing.d.ts +9 -1
- package/dist/components/ServerProvider.d.ts +2 -1
- package/dist/components/UnsavedChangesDialog.d.ts +9 -0
- package/dist/components/given/GivensPanel.d.ts +2 -2
- package/dist/components/given/paramCodec.d.ts +8 -1
- package/dist/components/index.d.ts +3 -2
- package/dist/components/styles.d.ts +4 -4
- package/dist/hooks/givenValue.d.ts +6 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useCompiledDocument.d.ts +23 -0
- package/dist/hooks/useDocumentControls.d.ts +6 -1
- package/dist/hooks/useNarrowScreen.d.ts +4 -0
- package/dist/hooks/useNearViewport.d.ts +16 -0
- package/dist/hooks/useQueryResult.d.ts +2 -0
- package/dist/hooks/useQueryWithApiError.d.ts +7 -2
- package/dist/hooks/useSettled.d.ts +14 -0
- package/dist/hooks/useSuggestOptions.d.ts +9 -2
- package/dist/index.cjs.js +23 -24
- package/dist/index.es.js +9041 -7002
- package/dist/text/index.cjs.js +1 -0
- package/dist/text/index.d.ts +2 -0
- package/dist/text/index.es.js +6 -0
- package/dist/text-entry-BJwltZiy.cjs.js +7 -0
- package/dist/text-entry-CA0LZ1xL.es.js +196 -0
- package/dist/text-entry.d.ts +2 -0
- package/dist/theme/accent.d.ts +29 -0
- package/dist/theme/buildVegaThemeOverride.d.ts +3 -3
- package/dist/theme/index.d.ts +3 -0
- package/dist/theme/keys.d.ts +1 -1
- package/dist/theme/motion.d.ts +31 -0
- package/dist/theme/readChartAnnotations.d.ts +1 -1
- package/dist/theme/resolveTheme.d.ts +4 -4
- package/dist/theme/types.d.ts +33 -5
- package/dist/{Dashboard-H1kJlDFo.es.js → useCompiledDocument-BU6d8FPp.es.js} +17904 -19057
- package/dist/useCompiledDocument-pOg2W-Yt.cjs.js +142 -0
- package/dist/utils/clock.d.ts +2 -0
- package/dist/utils/malloyText.d.ts +104 -0
- package/package.json +20 -11
- package/src/builder-entry.ts +36 -0
- package/src/client-entry.ts +8 -0
- package/src/clientEntry.spec.ts +17 -0
- package/src/components/ApiErrorDisplay.tsx +37 -18
- package/src/components/AppDialog.tsx +8 -7
- package/src/components/Dashboard/Dashboard.spec.tsx +3 -32
- package/src/components/Dashboard/Dashboard.tsx +29 -280
- package/src/components/Dashboard/DashboardGrid.tsx +87 -8
- package/src/components/Dashboard/DashboardTile.spec.tsx +121 -2
- package/src/components/Dashboard/DashboardTile.tsx +121 -30
- package/src/components/Dashboard/DashboardView.spec.tsx +368 -0
- package/src/components/Dashboard/DashboardView.tsx +428 -0
- package/src/components/Dashboard/RowsDialog.tsx +4 -3
- package/src/components/Dashboard/TileCard.tsx +60 -11
- package/src/components/Dashboard/TileFilterTag.spec.tsx +73 -0
- package/src/components/Dashboard/TileFilterTag.tsx +78 -0
- package/src/components/Dashboard/defaultTileSpan.spec.ts +32 -0
- package/src/components/Dashboard/dropValueUrlTags.spec.ts +177 -0
- package/src/components/Dashboard/dropValueUrlTags.ts +108 -0
- package/src/components/Dashboard/index.ts +13 -1
- package/src/components/Dashboard/telemetry.ts +17 -5
- package/src/components/Dashboard/textSource.spec.ts +36 -0
- package/src/components/Dashboard/textSource.ts +39 -0
- package/src/components/DashboardBuilder/AddTileDialog.spec.tsx +88 -0
- package/src/components/DashboardBuilder/AddTileDialog.tsx +124 -138
- package/src/components/DashboardBuilder/BuilderDialogs.tsx +162 -0
- package/src/components/DashboardBuilder/BuilderGrid.tsx +245 -0
- package/src/components/DashboardBuilder/BuilderHeader.tsx +107 -0
- package/src/components/DashboardBuilder/BuilderToolbar.tsx +111 -80
- package/src/components/DashboardBuilder/ChartPicker.render.spec.tsx +25 -0
- package/src/components/DashboardBuilder/ChartPicker.spec.ts +77 -0
- package/src/components/DashboardBuilder/ChartPicker.tsx +156 -0
- package/src/components/DashboardBuilder/DashboardBuilder.charts.spec.tsx +205 -0
- package/src/components/DashboardBuilder/DashboardBuilder.exit.spec.tsx +183 -0
- package/src/components/DashboardBuilder/DashboardBuilder.inline.spec.tsx +373 -0
- package/src/components/DashboardBuilder/DashboardBuilder.notebook.spec.tsx +310 -0
- package/src/components/DashboardBuilder/DashboardBuilder.openDraft.spec.tsx +105 -0
- package/src/components/DashboardBuilder/DashboardBuilder.sources.spec.tsx +117 -0
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +146 -108
- package/src/components/DashboardBuilder/DashboardBuilder.textTiles.spec.tsx +179 -0
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +330 -512
- package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +55 -25
- package/src/components/DashboardBuilder/DashboardEditor.emptyStart.spec.tsx +142 -0
- package/src/components/DashboardBuilder/DashboardEditor.filterTag.spec.tsx +162 -0
- package/src/components/DashboardBuilder/DashboardEditor.notebook.spec.tsx +310 -0
- package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +39 -13
- package/src/components/DashboardBuilder/DashboardEditor.resourceUri.spec.tsx +9 -26
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +102 -25
- package/src/components/DashboardBuilder/DashboardEditor.textSource.spec.tsx +317 -0
- package/src/components/DashboardBuilder/DashboardEditor.tsx +252 -780
- package/src/components/DashboardBuilder/DrillDialog.tsx +2 -2
- package/src/components/DashboardBuilder/EditorSurface.tsx +471 -0
- package/src/components/DashboardBuilder/FilterDialog.tsx +23 -11
- package/src/components/DashboardBuilder/FilterStrip.tsx +130 -70
- package/src/components/DashboardBuilder/InlineMarkdown.tsx +182 -0
- package/src/components/DashboardBuilder/InlineText.tsx +112 -0
- package/src/components/DashboardBuilder/NotebookEditor.tsx +44 -0
- package/src/components/DashboardBuilder/SourceViewPicker.tsx +122 -0
- package/src/components/DashboardBuilder/TextTileBody.tsx +31 -0
- package/src/components/DashboardBuilder/TileFrame.tsx +302 -163
- package/src/components/DashboardBuilder/TileMenu.tsx +125 -97
- package/src/components/DashboardBuilder/annotationText.spec.ts +33 -0
- package/src/components/DashboardBuilder/annotationText.ts +17 -0
- package/src/components/DashboardBuilder/artifactBlock.spec.ts +248 -0
- package/src/components/DashboardBuilder/artifactTagParity.spec.ts +46 -0
- package/src/components/DashboardBuilder/builderReport.ts +74 -0
- package/src/components/DashboardBuilder/catalog.aggregate.spec.ts +49 -0
- package/src/components/DashboardBuilder/catalog.spec.ts +2 -44
- package/src/components/DashboardBuilder/catalog.ts +61 -57
- package/src/components/DashboardBuilder/changedTile.spec.ts +46 -0
- package/src/components/DashboardBuilder/changedTile.ts +28 -0
- package/src/components/DashboardBuilder/chartLine.spec.ts +180 -0
- package/src/components/DashboardBuilder/chartLine.ts +121 -0
- package/src/components/DashboardBuilder/controls.spec.ts +21 -10
- package/src/components/DashboardBuilder/controls.ts +22 -8
- package/src/components/DashboardBuilder/document.ts +53 -5
- package/src/components/DashboardBuilder/documentSession.spec.ts +209 -0
- package/src/components/DashboardBuilder/documentSession.ts +258 -0
- package/src/components/DashboardBuilder/emptyStart.spec.ts +131 -0
- package/src/components/DashboardBuilder/imports.spec.ts +61 -0
- package/src/components/DashboardBuilder/imports.ts +93 -0
- package/src/components/DashboardBuilder/inlineEdit.tsx +78 -0
- package/src/components/DashboardBuilder/invariants.spec.ts +6 -2
- package/src/components/DashboardBuilder/legacyNotebook.chart.spec.ts +77 -0
- package/src/components/DashboardBuilder/legacyNotebook.convert.spec.ts +630 -0
- package/src/components/DashboardBuilder/legacyNotebook.read.spec.ts +338 -0
- package/src/components/DashboardBuilder/legacyNotebook.ts +1117 -0
- package/src/components/DashboardBuilder/loadMalloy.spec.ts +80 -0
- package/src/components/DashboardBuilder/loadMalloy.ts +39 -0
- package/src/components/DashboardBuilder/malloyTree.ts +159 -7
- package/src/components/DashboardBuilder/newDashboard.spec.ts +46 -2
- package/src/components/DashboardBuilder/newDashboard.ts +30 -3
- package/src/components/DashboardBuilder/openDraft.ts +52 -0
- package/src/components/DashboardBuilder/preview.shapes.spec.ts +75 -0
- package/src/components/DashboardBuilder/preview.spec.ts +159 -12
- package/src/components/DashboardBuilder/preview.ts +83 -9
- package/src/components/DashboardBuilder/readDocument.spec.ts +174 -26
- package/src/components/DashboardBuilder/readDocument.ts +137 -45
- package/src/components/DashboardBuilder/readForEditor.spec.ts +80 -0
- package/src/components/DashboardBuilder/readForEditor.ts +52 -0
- package/src/components/DashboardBuilder/scannerShapes.spec.ts +14 -13
- package/src/components/DashboardBuilder/sortable.spec.ts +89 -0
- package/src/components/DashboardBuilder/sortable.tsx +11 -10
- package/src/components/DashboardBuilder/spliceDocument.chart.spec.ts +340 -0
- package/src/components/DashboardBuilder/spliceDocument.imports.spec.ts +167 -0
- package/src/components/DashboardBuilder/spliceDocument.spec.ts +229 -94
- package/src/components/DashboardBuilder/spliceDocument.ts +768 -131
- package/src/components/DashboardBuilder/spliceResult.ts +15 -0
- package/src/components/DashboardBuilder/statementExtent.spec.ts +33 -30
- package/src/components/DashboardBuilder/tagParse.spec.ts +149 -0
- package/src/components/DashboardBuilder/tagParse.ts +103 -0
- package/src/components/DashboardBuilder/telemetry.ts +47 -0
- package/src/components/DashboardBuilder/testing/artifactTagParity.json +253 -0
- package/src/components/DashboardBuilder/testing/documentKindRule.json +40 -0
- package/src/components/DashboardBuilder/testing/fixtures.ts +16 -1
- package/src/components/DashboardBuilder/testing/inline.ts +25 -0
- package/src/components/DashboardBuilder/testing/resize.ts +48 -0
- package/src/components/DashboardBuilder/testing/urlRenderTags.json +62 -0
- package/src/components/DashboardBuilder/textTiles.spec.ts +760 -0
- package/src/components/DashboardBuilder/tileDisplayTitle.ts +13 -0
- package/src/components/DashboardBuilder/useBuilderSelection.ts +121 -0
- package/src/components/DashboardBuilder/useBuilderSession.spec.ts +250 -0
- package/src/components/DashboardBuilder/useBuilderSession.ts +255 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.overlay.spec.tsx +97 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.spec.tsx +60 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.ts +45 -9
- package/src/components/DashboardBuilder/useControlBindings.ts +152 -0
- package/src/components/DashboardBuilder/useConversionConfirm.ts +55 -0
- package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +16 -13
- package/src/components/DashboardBuilder/useDashboardEditor.ts +57 -181
- package/src/components/DashboardBuilder/useDocumentEditor.spec.ts +565 -0
- package/src/components/DashboardBuilder/useDocumentEditor.ts +399 -0
- package/src/components/DashboardBuilder/useDraft.ts +15 -2
- package/src/components/DashboardBuilder/useExitGuard.spec.ts +159 -0
- package/src/components/DashboardBuilder/useExitGuard.ts +89 -0
- package/src/components/DashboardBuilder/useFilterForm.existing.spec.tsx +41 -0
- package/src/components/DashboardBuilder/useFilterForm.spec.tsx +24 -2
- package/src/components/DashboardBuilder/useFilterForm.ts +41 -13
- package/src/components/DashboardBuilder/useHostCopy.ts +104 -0
- package/src/components/DashboardBuilder/useOpenDraftCommit.ts +47 -0
- package/src/components/DashboardBuilder/useOpenedDocument.ts +314 -0
- package/src/components/DashboardBuilder/useSaveChannel.ts +275 -0
- package/src/components/DashboardBuilder/useTileEditing.ts +141 -0
- package/src/components/DashboardBuilder/useTileReorder.spec.tsx +28 -5
- package/src/components/DashboardBuilder/useTileReorder.ts +5 -7
- package/src/components/DashboardBuilder/useTileResize.spec.tsx +30 -5
- package/src/components/DashboardBuilder/useTileResize.ts +31 -8
- package/src/components/DataAppViewer/DataAppViewer.tsx +7 -4
- package/src/components/DocumentCreate/canRetry.spec.ts +32 -0
- package/src/components/DocumentCreate/canRetry.ts +19 -0
- package/src/components/DocumentCreate/createDocument.spec.ts +310 -0
- package/src/components/DocumentCreate/createDocument.ts +159 -0
- package/src/components/DocumentCreate/documentPath.ts +40 -0
- package/src/components/DocumentCreate/events.ts +15 -0
- package/src/components/DocumentCreate/exportedSources.ts +25 -0
- package/src/components/DocumentCreate/guards.ts +45 -0
- package/src/components/DocumentCreate/index.ts +27 -0
- package/src/components/DocumentCreate/newNotebook.spec.ts +156 -0
- package/src/components/DocumentCreate/newNotebook.ts +44 -0
- package/src/components/DocumentCreate/useDocumentChoices.spec.tsx +138 -0
- package/src/components/DocumentCreate/useDocumentChoices.ts +113 -0
- package/src/components/DocumentStorage/DocumentStorage.ts +2 -1
- package/src/components/Environment/Environment.tsx +0 -10
- package/src/components/Loading.tsx +14 -0
- package/src/components/Model/Model.tsx +16 -9
- package/src/components/Model/ModelExplorer.spec.tsx +2 -2
- package/src/components/Model/ModelExplorer.tsx +2 -2
- package/src/components/Model/SourcesExplorer.tsx +2 -4
- package/src/components/NarrowEditGate.spec.tsx +73 -0
- package/src/components/NarrowEditGate.tsx +29 -0
- package/src/components/Notebook/Notebook.layout.spec.tsx +94 -0
- package/src/components/Notebook/Notebook.tsx +72 -29
- package/src/components/Notebook/NotebookCell.tsx +90 -215
- package/src/components/Package/NewDocumentDialog.spec.tsx +749 -0
- package/src/components/Package/NewDocumentDialog.tsx +401 -0
- package/src/components/Package/Package.artifacts.spec.tsx +186 -0
- package/src/components/Package/Package.create.spec.tsx +401 -0
- package/src/components/Package/Package.notebooks.spec.tsx +18 -0
- package/src/components/Package/Package.tsx +396 -177
- package/src/components/Package/documentLocation.spec.ts +81 -0
- package/src/components/Package/documentLocation.ts +55 -0
- package/src/components/Package/index.ts +14 -1
- package/src/components/Package/useDocumentLocation.ts +59 -0
- package/src/components/PackageSection.tsx +2 -2
- package/src/components/Prose.spec.tsx +37 -0
- package/src/components/Prose.tsx +35 -5
- package/src/components/RenderedResult/RenderedResult.tsx +23 -8
- package/src/components/RenderedResult/ResultContainer.tsx +51 -13
- package/src/components/RenderedResult/ResultPanel.tsx +24 -5
- package/src/components/RenderedResult/loadRenderer.ts +42 -0
- package/src/components/RenderedResult/resultSizing.spec.ts +68 -0
- package/src/components/RenderedResult/resultSizing.ts +14 -3
- package/src/components/ServerProvider.tsx +2 -1
- package/src/components/UnsavedChangesDialog.spec.tsx +70 -0
- package/src/components/UnsavedChangesDialog.tsx +49 -0
- package/src/components/given/GivenInput.spec.tsx +5 -5
- package/src/components/given/GivenInput.tsx +46 -38
- package/src/components/given/GivensPanel.spec.tsx +6 -6
- package/src/components/given/GivensPanel.tsx +5 -11
- package/src/components/given/paramCodec.ts +27 -1
- package/src/components/index.ts +3 -2
- package/src/components/styles.ts +4 -5
- package/src/hooks/givenValue.ts +9 -0
- package/src/hooks/index.ts +7 -0
- package/src/hooks/useCompiledDocument.spec.tsx +86 -0
- package/src/hooks/useCompiledDocument.ts +59 -0
- package/src/hooks/useDimensionalFilterRangeData.ts +3 -1
- package/src/hooks/useDocumentControls.ts +13 -1
- package/src/hooks/useNarrowScreen.ts +21 -0
- package/src/hooks/useNearViewport.spec.tsx +150 -0
- package/src/hooks/useNearViewport.ts +102 -0
- package/src/hooks/useQueryResult.ts +23 -1
- package/src/hooks/useQueryWithApiError.ts +10 -3
- package/src/hooks/useRawQueryData.ts +3 -1
- package/src/hooks/useSettled.spec.ts +41 -0
- package/src/hooks/useSettled.ts +27 -0
- package/src/hooks/useSuggestOptions.dom.spec.ts +40 -1
- package/src/hooks/useSuggestOptions.ts +42 -10
- package/src/mainEntry.spec.ts +145 -0
- package/src/text-entry.ts +12 -0
- package/src/textEntry.spec.ts +112 -0
- package/src/theme/accent.spec.ts +116 -0
- package/src/theme/accent.ts +148 -0
- package/src/theme/buildTableCssVars.spec.ts +24 -0
- package/src/theme/buildTableCssVars.ts +1 -2
- package/src/theme/buildVegaThemeOverride.spec.ts +38 -2
- package/src/theme/buildVegaThemeOverride.ts +5 -5
- package/src/theme/defaults.ts +34 -0
- package/src/theme/index.ts +9 -0
- package/src/theme/keys.ts +6 -0
- package/src/theme/motion.ts +44 -0
- package/src/theme/readChartAnnotations.spec.ts +18 -0
- package/src/theme/readChartAnnotations.ts +1 -1
- package/src/theme/resolveTheme.spec.ts +73 -0
- package/src/theme/resolveTheme.ts +61 -20
- package/src/theme/types.ts +30 -5
- package/src/utils/clock.spec.ts +12 -0
- package/src/utils/clock.ts +6 -0
- package/src/{components/DashboardBuilder → utils}/malloyText.spec.ts +48 -0
- package/src/utils/malloyText.ts +368 -0
- package/src/utils/queryClient.ts +8 -0
- package/vite.config.ts +4 -0
- package/dist/Dashboard-ChyylkTD.cjs.js +0 -136
- package/dist/RenderedResult-AJPMUkAD.cjs.js +0 -135
- package/dist/ServerProvider-CXrOKD6g.cjs.js +0 -1
- package/dist/components/Dashboard/DashboardBar.d.ts +0 -21
- package/dist/components/Dashboard/ExploreDialog.d.ts +0 -20
- package/dist/components/DashboardBuilder/DiffDialog.d.ts +0 -15
- package/dist/components/DashboardBuilder/SettingsPopover.d.ts +0 -20
- package/dist/components/DashboardBuilder/diff.d.ts +0 -35
- package/dist/components/DashboardBuilder/malloyText.d.ts +0 -64
- package/dist/components/Package/NewDashboardDialog.d.ts +0 -18
- package/src/components/Dashboard/DashboardBar.tsx +0 -88
- package/src/components/Dashboard/ExploreDialog.tsx +0 -89
- package/src/components/DashboardBuilder/DiffDialog.tsx +0 -122
- package/src/components/DashboardBuilder/SettingsPopover.tsx +0 -168
- package/src/components/DashboardBuilder/diff.spec.ts +0 -44
- package/src/components/DashboardBuilder/diff.ts +0 -93
- package/src/components/DashboardBuilder/malloyText.ts +0 -214
- package/src/components/Package/NewDashboardDialog.spec.tsx +0 -129
- package/src/components/Package/NewDashboardDialog.tsx +0 -265
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
"use strict";var nu=Object.create;var oa=Object.defineProperty;var ru=Object.getOwnPropertyDescriptor;var iu=Object.getOwnPropertyNames;var su=Object.getPrototypeOf,ou=Object.prototype.hasOwnProperty;var au=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of iu(t))!ou.call(e,i)&&i!==n&&oa(e,i,{get:()=>t[i],enumerable:!(r=ru(t,i))||r.enumerable});return e};var aa=(e,t,n)=>(n=e!=null?nu(su(e)):{},au(t||!e||!e.__esModule?oa(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react/jsx-runtime"),S=require("react"),lu=require("react-dom"),k=require("@mui/material"),j=require("../Dashboard-ChyylkTD.cjs.js"),Be=require("../ServerProvider-CXrOKD6g.cjs.js"),cu=require("@tanstack/react-query");var du=Symbol.for("preact-signals");function Pi(){if(vt>1)vt--;else{var e,t=!1;for((function(){var i=ui;for(ui=void 0;i!==void 0;){var s=i.S;if(s.v===i.v)for(var o=s.t;o!==void 0;o=o.x)o.i===i.i&&(o.i=s.i);i=i.o}})();cr!==void 0;){var n=cr;for(cr=void 0,di++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&ll(n))try{n.c()}catch(i){t||(e=i,t=!0)}n=r}}if(di=0,vt--,t)throw e}}function ue(e){if(vt>0)return e();us=++uu,vt++;try{return e()}finally{Pi()}}var lr,ie=void 0;function H(e){var t=ie,n=lr;ie=void 0,lr=void 0;try{return e()}finally{ie=t,lr=n}}var cr=void 0,vt=0,di=0,uu=0,us=0,ui=void 0,fi=0;function al(e){if(ie!==void 0){var t=e.n;if(t===void 0||t.t!==ie)return t={i:0,S:e,p:ie.s,n:void 0,t:ie,e:void 0,x:void 0,r:t},ie.s!==void 0&&(ie.s.n=t),ie.s=t,e.n=t,32&ie.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=ie.s,t.n=void 0,ie.s.n=t,ie.s=t),t}}function Re(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}Re.prototype.brand=du;Re.prototype.h=function(){return!0};Re.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:H(function(){var r;(r=t.W)==null||r.call(t)}))};Re.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&&H(function(){var i;(i=t.Z)==null||i.call(t)}))}};Re.prototype.subscribe=function(e){var t=this;return tt(function(){var n=t.value;H(function(){return e(n)})},{name:"sub"})};Re.prototype.valueOf=function(){return this.value};Re.prototype.toString=function(){return this.value+""};Re.prototype.toJSON=function(){return this.value};Re.prototype.peek=function(){var e=this;return H(function(){return e.value})};Object.defineProperty(Re.prototype,"value",{get:function(){var e=al(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(di>100)throw new Error("Cycle detected");(function(n){vt!==0&&di===0&&n.l!==us&&(n.l=us,ui={S:n,v:n.v,i:n.i,o:ui})})(this),this.v=e,this.i++,fi++,vt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Pi()}}}});function En(e,t){return new Re(e,t)}function ll(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 cl(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 dl(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 Ht(e,t){Re.call(this,void 0,t),this.x=e,this.s=void 0,this.g=fi-1,this.f=4}Ht.prototype=new Re;Ht.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===fi))return!0;if(this.g=fi,this.f|=1,this.i>0&&!ll(this))return this.f&=-2,!0;var e=ie;try{cl(this),ie=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 ie=e,dl(this),this.f&=-2,!0};Ht.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)}Re.prototype.S.call(this,e)};Ht.prototype.U=function(e){if(this.t!==void 0&&(Re.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)}};Ht.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(Ht.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=al(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 Ht(e,t)}function ul(e){var t=e.m;if(e.m=void 0,typeof t=="function"){vt++;var n=ie;ie=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,to(e),r}finally{ie=n,Pi()}}}function to(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,ul(e)}function fu(e){if(ie!==this)throw new Error("Out-of-order effect");dl(this),ie=e,this.f&=-2,8&this.f&&to(this),Pi()}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,lr&&lr.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,ul(this),cl(this),vt++;var e=ie;return ie=this,fu.bind(this,e)};On.prototype.N=function(){2&this.f||(this.f|=2,this.u=cr,cr=this)};On.prototype.d=function(){this.f|=8,1&this.f||to(this)};On.prototype.dispose=function(){this.d()};function tt(e,t){var n=new On(e,t);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var hu=Object.create,no=Object.defineProperty,pu=Object.defineProperties,gu=Object.getOwnPropertyDescriptor,vu=Object.getOwnPropertyDescriptors,ca=Object.getOwnPropertySymbols,mu=Object.prototype.hasOwnProperty,yu=Object.prototype.propertyIsEnumerable,bu=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Tn=e=>{throw TypeError(e)},fs=(e,t,n)=>t in e?no(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xu=(e,t)=>{for(var n in t||(t={}))mu.call(t,n)&&fs(e,n,t[n]);if(ca)for(var n of ca(t))yu.call(t,n)&&fs(e,n,t[n]);return e},wu=(e,t)=>pu(e,vu(t)),da=(e,t)=>no(e,"name",{value:t,configurable:!0}),_u=e=>{var t;return[,,,hu((t=void 0)!=null?t:null)]},fl=["class","method","getter","setter","accessor","field","value","get","set"],qn=e=>e!==void 0&&typeof e!="function"?Tn("Function expected"):e,ku=(e,t,n,r,i)=>({kind:fl[e],name:t,metadata:r,addInitializer:s=>n._?Tn("Already initialized"):i.push(qn(s||null))}),hl=(e,t)=>fs(t,bu("metadata"),e[3]),Mt=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)t&1?s[i].call(n):r=s[i].call(n,r);return r},Dn=(e,t,n,r,i,s)=>{var o,a,l,u,d,c=t&7,h=!!(t&8),f=!!(t&16),v=c>3?e.length+1:c?h?1:2:0,p=fl[c+5],w=c>3&&(e[v-1]=[]),x=e[v]||(e[v]=[]),m=c&&(!f&&!h&&(i=i.prototype),c<5&&(c>3||!f)&&gu(c<4?i:{get[n](){return Qe(this,s)},set[n](b){return kt(this,s,b)}},n));c?f&&c<4&&da(s,(c>2?"set ":c>1?"get ":"")+n):da(i,n);for(var g=r.length-1;g>=0;g--)u=ku(c,n,l={},e[3],x),c&&(u.static=h,u.private=f,d=u.access={has:f?b=>Su(i,b):b=>n in b},c^3&&(d.get=f?b=>(c^1?Qe:$u)(b,i,c^4?s:m.get):b=>b[n]),c>2&&(d.set=f?(b,_)=>kt(b,i,_,c^4?s:m.set):(b,_)=>b[n]=_)),a=(0,r[g])(c?c<4?f?s:m[p]:c>4?void 0:{get:m.get,set:m.set}:i,u),l._=1,c^4||a===void 0?qn(a)&&(c>4?w.unshift(a):c?f?s=a:m[p]=a:i=a):typeof a!="object"||a===null?Tn("Object expected"):(qn(o=a.get)&&(m.get=o),qn(o=a.set)&&(m.set=o),qn(o=a.init)&&w.unshift(o));return c||hl(e,i),m&&no(i,n,m),f?c^4?s:m:i},ro=(e,t,n)=>t.has(e)||Tn("Cannot "+n),Su=(e,t)=>Object(t)!==t?Tn('Cannot use the "in" operator on this value'):e.has(t),Qe=(e,t,n)=>(ro(e,t,"read from private field"),n?n.call(e):t.get(e)),Hn=(e,t,n)=>t.has(e)?Tn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),kt=(e,t,n,r)=>(ro(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),$u=(e,t,n)=>(ro(e,t,"access private method"),n);function hs(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 rt(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,i)=>!rt(r,t[i]));if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:!n.some(s=>!rt(e[s],t[s]))}return!1}function K({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 ge(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=hs(e.bind(this)),n.set(this,r)),r.value}}function Hi(e=!0){return function(t,n){n.addInitializer(function(){const r=n.kind==="field"?this:n.static?this:Object.getPrototypeOf(this),i=Object.getOwnPropertyDescriptor(r,n.name);i&&Object.defineProperty(r,n.name,wu(xu({},i),{enumerable:e}))})}}function $r(...e){const t=e.map(n=>tt(n));return()=>t.forEach(n=>n())}var pl,gl,vl,ml,yl,bl,Ie,io,Ki,ps,gs,Pe,so,Yi,xl,vs,oo,Xi,ms,ys;bl=[K],yl=[K],ml=[K],vl=[Hi()],gl=[Hi()],pl=[Hi()];var Kt=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,Mt(Ie,5,this),Hn(this,Pe),Hn(this,io,Mt(Ie,8,this)),Mt(Ie,11,this),Hn(this,so,Mt(Ie,12,this)),Mt(Ie,15,this),Hn(this,oo,Mt(Ie,16,this)),Mt(Ie,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return Qe(this,Pe,ms)}get initial(){return Qe(this,Pe,ps)}get previous(){return Qe(this,Pe,xl)}set current(e){const t=H(()=>Qe(this,Pe,ms));e&&t&&this.equals(t,e)||ue(()=>{Qe(this,Pe,ps)||kt(this,Pe,e,gs),kt(this,Pe,t,vs),kt(this,Pe,e,ys)})}reset(e=this.defaultValue){ue(()=>{kt(this,Pe,void 0,vs),kt(this,Pe,e,gs),kt(this,Pe,e,ys)})}};Ie=_u();io=new WeakMap;Pe=new WeakSet;so=new WeakMap;oo=new WeakMap;Ki=Dn(Ie,20,"#initial",bl,Pe,io),ps=Ki.get,gs=Ki.set;Yi=Dn(Ie,20,"#previous",yl,Pe,so),xl=Yi.get,vs=Yi.set;Xi=Dn(Ie,20,"#current",ml,Pe,oo),ms=Xi.get,ys=Xi.set;Dn(Ie,2,"current",vl,Kt);Dn(Ie,2,"initial",gl,Kt);Dn(Ie,2,"previous",pl,Kt);hl(Ie,Kt);function Qi(e){return H(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var It,Eu=class{constructor(){Hn(this,It,new WeakMap)}get(e,t){var n;return e?(n=Qe(this,It).get(e))==null?void 0:n.get(t):void 0}set(e,t,n){var r;if(e)return Qe(this,It).has(e)||Qe(this,It).set(e,new Map),(r=Qe(this,It).get(e))==null?void 0:r.set(t,n)}clear(e){var t;return e?(t=Qe(this,It).get(e))==null?void 0:t.clear():void 0}};It=new WeakMap;var Ou=Object.create,wl=Object.defineProperty,Tu=Object.getOwnPropertyDescriptor,ua=Object.getOwnPropertySymbols,Du=Object.prototype.hasOwnProperty,Cu=Object.prototype.propertyIsEnumerable,_l=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Mi=e=>{throw TypeError(e)},fa=Math.pow,bs=(e,t,n)=>t in e?wl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Pu=(e,t)=>{for(var n in t||(t={}))Du.call(t,n)&&bs(e,n,t[n]);if(ua)for(var n of ua(t))Cu.call(t,n)&&bs(e,n,t[n]);return e},Mu=e=>{var t;return[,,,Ou((t=e?.[_l("metadata")])!=null?t:null)]},kl=["class","method","getter","setter","accessor","field","value","get","set"],Sl=e=>e!==void 0&&typeof e!="function"?Mi("Function expected"):e,Iu=(e,t,n,r,i)=>({kind:kl[e],name:t,metadata:r,addInitializer:s=>n._?Mi("Already initialized"):i.push(Sl(s||null))}),ju=(e,t)=>bs(t,_l("metadata"),e[3]),Au=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)s[i].call(n);return r},$l=(e,t,n,r,i,s)=>{for(var o,a,l,u,d=t&7,c=!1,h=!1,f=2,v=kl[d+5],p=e[f]||(e[f]=[]),w=(i=i.prototype,Tu(i,n)),x=r.length-1;x>=0;x--)l=Iu(d,n,a={},e[3],p),l.static=c,l.private=h,u=l.access={has:m=>n in m},u.get=m=>m[n],o=(0,r[x])(w[v],l),a._=1,Sl(o)&&(w[v]=o);return w&&wl(i,n,w),i},El=(e,t,n)=>t.has(e)||Mi("Cannot "+n),Ru=(e,t,n)=>(El(e,t,"read from private field"),t.get(e)),Lu=(e,t,n)=>t.has(e)?Mi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Wu=(e,t,n,r)=>(El(e,t,"write to private field"),t.set(e,n),n),Ze=class xs{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new xs(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 xs(t,n)}},dt=class jt{constructor(t,n,r,i){this.left=t,this.top=n,this.width=r,this.height=i,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:i,width:s,height:o,scale:a}=this,l=new jt(i+t,r+n,s,o);return l.scale=Pu({},a),l}get boundingRectangle(){const{width:t,height:n,left:r,top:i,right:s,bottom:o}=this;return{width:t,height:n,left:r,top:i,right:s,bottom:o}}get center(){const{left:t,top:n,right:r,bottom:i}=this;return new Ze((t+r)/2,(n+i)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof jt))return!1;const{left:n,top:r,width:i,height:s}=this;return n===t.left&&r===t.top&&i===t.width&&s===t.height}containsPoint(t){const{top:n,left:r,bottom:i,right:s}=this;return n<=t.y&&t.y<=i&&r<=t.x&&t.x<=s}intersectionArea(t){return t instanceof jt?zu(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:i}){return new jt(n,t,r,i)}static delta(t,n,r={x:"center",y:"center"}){const i=(s,o)=>{const a=r[o],l=o==="x"?s.left:s.top,u=o==="x"?s.width:s.height;return a=="start"?l:a=="end"?l+u:l+u/2};return Ze.delta({x:i(t,"x"),y:i(t,"y")},{x:i(n,"x"),y:i(n,"y")})}static intersectionRatio(t,n){return jt.from(t).intersectionRatio(jt.from(n))}};function zu(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),s=Math.min(t.top+t.height,e.top+e.height),o=i-r,a=s-n;return r<i&&n<s?o*a:0}var Ol,Tl,ws,Xr,Er,Ii=class extends(ws=Kt,Tl=[ge],Ol=[ge],ws){constructor(t){const n=Ze.from(t);super(n,(r,i)=>Ze.equals(r,i)),Au(Er,5,this),Lu(this,Xr,0),this.velocity={x:0,y:0}}get delta(){return Ze.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=Ze.from(t),i={x:r.x-n.x,y:r.y-n.y},s=Date.now(),o=s-Ru(this,Xr),a=l=>Math.round(l/o*100);ue(()=>{Wu(this,Xr,s),this.velocity={x:a(i.x),y:a(i.y)},super.current=r})}reset(t=this.defaultValue){super.reset(Ze.from(t)),this.velocity={x:0,y:0}}};Er=Mu(ws);Xr=new WeakMap;$l(Er,2,"delta",Tl,Ii);$l(Er,2,"direction",Ol,Ii);ju(Er,Ii);function _s({x:e,y:t},n){const r=Math.abs(e),i=Math.abs(t);return typeof n=="number"?Math.sqrt(fa(r,2)+fa(i,2))>n:"x"in n&&"y"in n?r>n.x&&i>n.y:"x"in n?r>n.x:"y"in n?i>n.y:!1}var Dl=(e=>(e.Horizontal="x",e.Vertical="y",e))(Dl||{}),Cl=Object.values(Dl),Fu=Object.create,ao=Object.defineProperty,Nu=Object.defineProperties,Bu=Object.getOwnPropertyDescriptor,Vu=Object.getOwnPropertyDescriptors,hi=Object.getOwnPropertySymbols,Pl=Object.prototype.hasOwnProperty,Ml=Object.prototype.propertyIsEnumerable,Il=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Cn=e=>{throw TypeError(e)},ks=(e,t,n)=>t in e?ao(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lo=(e,t)=>{for(var n in t||(t={}))Pl.call(t,n)&&ks(e,n,t[n]);if(hi)for(var n of hi(t))Ml.call(t,n)&&ks(e,n,t[n]);return e},co=(e,t)=>Nu(e,Vu(t)),ha=(e,t)=>ao(e,"name",{value:t,configurable:!0}),jl=(e,t)=>{var n={};for(var r in e)Pl.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&hi)for(var r of hi(e))t.indexOf(r)<0&&Ml.call(e,r)&&(n[r]=e[r]);return n},Pn=e=>{var t;return[,,,Fu((t=e?.[Il("metadata")])!=null?t:null)]},Al=["class","method","getter","setter","accessor","field","value","get","set"],Kn=e=>e!==void 0&&typeof e!="function"?Cn("Function expected"):e,Gu=(e,t,n,r,i)=>({kind:Al[e],name:t,metadata:r,addInitializer:s=>n._?Cn("Already initialized"):i.push(Kn(s||null))}),Yt=(e,t)=>ks(t,Il("metadata"),e[3]),N=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)t&1?s[i].call(n):r=s[i].call(n,r);return r},Y=(e,t,n,r,i,s)=>{var o,a,l,u,d,c=t&7,h=!!(t&8),f=!!(t&16),v=c>3?e.length+1:c?h?1:2:0,p=Al[c+5],w=c>3&&(e[v-1]=[]),x=e[v]||(e[v]=[]),m=c&&(!f&&!h&&(i=i.prototype),c<5&&(c>3||!f)&&Bu(c<4?i:{get[n](){return pe(this,s)},set[n](b){return He(this,s,b)}},n));c?f&&c<4&&ha(s,(c>2?"set ":c>1?"get ":"")+n):ha(i,n);for(var g=r.length-1;g>=0;g--)u=Gu(c,n,l={},e[3],x),c&&(u.static=h,u.private=f,d=u.access={has:f?b=>Uu(i,b):b=>n in b},c^3&&(d.get=f?b=>(c^1?pe:Rl)(b,i,c^4?s:m.get):b=>b[n]),c>2&&(d.set=f?(b,_)=>He(b,i,_,c^4?s:m.set):(b,_)=>b[n]=_)),a=(0,r[g])(c?c<4?f?s:m[p]:c>4?void 0:{get:m.get,set:m.set}:i,u),l._=1,c^4||a===void 0?Kn(a)&&(c>4?w.unshift(a):c?f?s=a:m[p]=a:i=a):typeof a!="object"||a===null?Cn("Object expected"):(Kn(o=a.get)&&(m.get=o),Kn(o=a.set)&&(m.set=o),Kn(o=a.init)&&w.unshift(o));return c||Yt(e,i),m&&ao(i,n,m),f?c^4?s:m:i},uo=(e,t,n)=>t.has(e)||Cn("Cannot "+n),Uu=(e,t)=>Object(t)!==t?Cn('Cannot use the "in" operator on this value'):e.has(t),pe=(e,t,n)=>(uo(e,t,"read from private field"),n?n.call(e):t.get(e)),J=(e,t,n)=>t.has(e)?Cn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),He=(e,t,n,r)=>(uo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Rl=(e,t,n)=>(uo(e,t,"access private method"),n);function Ll(e,t){return{plugin:e,options:t}}function Or(e){return t=>Ll(e,t)}function gr(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var Wl,vr,fo,Qr;Wl=[K];var Me=class{constructor(e,t){this.manager=e,this.options=t,J(this,fo,N(vr,8,this,!1)),N(vr,11,this),J(this,Qr,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return H(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=tt(e.bind(this));return pe(this,Qr).add(t),t}destroy(){pe(this,Qr).forEach(e=>e())}static configure(e){return Ll(this,e)}};vr=Pn(null);fo=new WeakMap;Qr=new WeakMap;Y(vr,4,"disabled",Wl,Me,fo);Yt(vr,Me);var Tr=class extends Me{},Zr,Zi=class{constructor(e){this.manager=e,this.instances=new Map,J(this,Zr,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(gr).reduce((r,i)=>{const s=r.find(({plugin:o})=>o===i.plugin);return s?(s.options=i.options,r):[...r,i]},[]),n=t.map(({plugin:r})=>r);for(const r of pe(this,Zr))if(!n.includes(r)){if(r.prototype instanceof Tr)continue;this.unregister(r)}for(const{plugin:r,options:i}of t)this.register(r,i);He(this,Zr,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()}};Zr=new WeakMap;function qu(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var Wr=[],an,ln,Hu=class extends Me{constructor(e){super(e),J(this,an),J(this,ln),this.computeCollisions=this.computeCollisions.bind(this),He(this,ln,En(Wr)),this.destroy=$r(()=>{const t=this.computeCollisions(),n=H(()=>this.manager.dragOperation.position.current);if(t!==Wr){const r=pe(this,an);if(He(this,an,n),r&&n.x==r.x&&n.y==r.y)return}else He(this,an,void 0);pe(this,ln).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){H(()=>{e?pe(this,ln).value=this.computeCollisions():He(this,an,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:i,shape:s,status:o}=r;if(!o.initialized||!s)return Wr;const a=[],l=[];for(const u of e??n.droppables){if(u.disabled||i&&!u.accepts(i))continue;const d=t??u.collisionDetector;if(!d)continue;l.push(u),u.shape;const c=H(()=>d({droppable:u,dragOperation:r}));c&&(u.collisionPriority!=null&&(c.priority=u.collisionPriority),a.push(c))}return l.length===0?Wr:(a.sort(qu),a)}get collisions(){return pe(this,ln).value}};an=new WeakMap;ln=new WeakMap;var zl,Fl,Nl,ho,Bl,it,po,pn,go,vo;Nl=[K],Fl=[K],zl=[K];var yt=class At{constructor(t,n){J(this,po,N(it,8,this)),N(it,11,this),J(this,pn),J(this,go,N(it,12,this)),N(it,15,this),J(this,vo,N(it,16,this)),N(it,19,this);const{effects:r,id:i,data:s={},disabled:o=!1,register:a=!0}=t;let l=i;He(this,pn,En(i)),this.manager=n,this.data=s,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=pe(this,pn).value;return(n=(t=At.pendingIdChanges)==null?void 0:t.get(this))!=null?n:r}set id(t){var n,r;const i=(r=(n=At.pendingIdChanges)==null?void 0:n.get(this))!=null?r:pe(this,pn).peek();t!==i&&(At.pendingIdChanges||(At.pendingIdChanges=new Map,queueMicrotask(()=>{var s;return Rl(s=At,ho,Bl).call(s)})),At.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)}};it=Pn(null);ho=new WeakSet;Bl=function(){const e=yt.pendingIdChanges;yt.pendingIdChanges=null,e&&ue(()=>{for(const[t,n]of e)pe(t,pn).value=n})};po=new WeakMap;pn=new WeakMap;go=new WeakMap;vo=new WeakMap;Y(it,4,"manager",Nl,yt,po);Y(it,4,"data",Fl,yt,go);Y(it,4,"disabled",zl,yt,vo);J(yt,ho);Yt(it,yt);yt.pendingIdChanges=null;var ji=yt,pa=class{constructor(){this.map=En(new Map),this.cleanupFunctions=new WeakMap,this.register=(e,t)=>{const n=this.map.peek(),r=n.get(e),i=()=>this.unregister(e,t);if(r===t)return i;if(r&&r.id===e){const a=this.cleanupFunctions.get(r);a?.(),this.cleanupFunctions.delete(r)}const s=new Map(n);for(const[a,l]of n)if(l===t&&a!==e){s.delete(a);break}s.set(e,t),this.map.value=s;const o=$r(...t.effects());return this.cleanupFunctions.set(t,o),i},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 i=new Map(n);i.delete(e),this.map.value=i}}[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}},Vl,Gl,Ul,ql,Hl,Kl,Ss,je,mo,yo,bo,ut=class extends(Ss=ji,Kl=[K],Hl=[K],ql=[K],Ul=[ge],Gl=[ge],Vl=[ge],Ss){constructor(t,n){var r=t,{modifiers:i,type:s,sensors:o,plugins:a,effects:l}=r,u=jl(r,["modifiers","type","sensors","plugins","effects"]);super(co(lo({},u),{effects:()=>{var d;return[...(d=l?.())!=null?d:[],()=>{const{manager:c,plugins:h}=this;if(!(!c||!h))for(const f of h){const{plugin:v}=gr(f);c.registry.plugins.register(v)}}]}}),n),N(je,5,this),J(this,mo,N(je,8,this)),N(je,11,this),J(this,yo,N(je,12,this)),N(je,15,this),J(this,bo,N(je,16,this,this.isDragSource?"dragging":"idle")),N(je,19,this),this.type=s,this.sensors=o,this.modifiers=i,this.alignment=u.alignment,this.plugins=a}pluginConfig(t){if(this.plugins)for(const n of this.plugins){const r=gr(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}};je=Pn(Ss);mo=new WeakMap;yo=new WeakMap;bo=new WeakMap;Y(je,4,"type",Kl,ut,mo);Y(je,4,"modifiers",Hl,ut,yo);Y(je,4,"status",ql,ut,bo);Y(je,2,"isDropping",Ul,ut);Y(je,2,"isDragging",Gl,ut);Y(je,2,"isDragSource",Vl,ut);Yt(je,ut);var Yl,Xl,Ql,Zl,Jl,ec,$s,xe,xo,wo,_o,ko,So,ft=class extends($s=ji,ec=[K],Jl=[K],Zl=[K],Ql=[K],Xl=[K],Yl=[ge],$s){constructor(t,n){var r=t,{accept:i,collisionDetector:s,collisionPriority:o,type:a}=r,l=jl(r,["accept","collisionDetector","collisionPriority","type"]);super(l,n),N(xe,5,this),J(this,xo,N(xe,8,this)),N(xe,11,this),J(this,wo,N(xe,12,this)),N(xe,15,this),J(this,_o,N(xe,16,this)),N(xe,19,this),J(this,ko,N(xe,20,this)),N(xe,23,this),J(this,So,N(xe,24,this)),N(xe,27,this),this.accept=i,this.collisionDetector=s,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}};xe=Pn($s);xo=new WeakMap;wo=new WeakMap;_o=new WeakMap;ko=new WeakMap;So=new WeakMap;Y(xe,4,"accept",ec,ft,xo);Y(xe,4,"type",Jl,ft,wo);Y(xe,4,"collisionDetector",Zl,ft,_o);Y(xe,4,"collisionPriority",Ql,ft,ko);Y(xe,4,"shape",Xl,ft,So);Y(xe,2,"isDropTarget",Yl,ft);Yt(xe,ft);var Ku=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 i of r)i(...t)}},Yu=class extends Ku{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function Jr(e,t=!0){let n=!1;return co(lo({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var Xu=class extends Tr{constructor(e){super(e);const t=(r,i)=>r.map(({id:s})=>s).join("")===i.map(({id:s})=>s).join("");let n=[];this.destroy=$r(()=>{const{dragOperation:r,collisionObserver:i}=e;r.status.initializing&&(n=[],i.enable())},()=>{const{collisionObserver:r,monitor:i}=e,{collisions:s}=r;if(r.isDisabled()||ji.pendingIdChanges)return;const o=Jr({collisions:s});if(i.dispatch("collision",o),o.defaultPrevented||t(s,n))return;n=s;const[a]=s;H(()=>{var l;a?.id!==((l=e.dragOperation.target)==null?void 0:l.id)&&(r.disable(),e.actions.setDropTarget(a?.id).then(()=>{r.enable()}))})})}},Mn=(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))(Mn||{}),In=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(In||{}),tc,nc,rc,ic,sc,oc,ac,et,$o;ac=[K],oc=[ge],sc=[ge],ic=[ge],rc=[ge],nc=[ge],tc=[ge];var bt=class{constructor(){N(et,5,this),J(this,$o,N(et,8,this,"idle")),N(et,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}};et=Pn(null);$o=new WeakMap;Y(et,4,"value",ac,bt,$o);Y(et,2,"current",oc,bt);Y(et,2,"idle",sc,bt);Y(et,2,"initializing",ic,bt);Y(et,2,"initialized",rc,bt);Y(et,2,"dragging",nc,bt);Y(et,2,"dropped",tc,bt);Yt(et,bt);var Qu=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 H(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=Jr({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return H(()=>{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:i,coordinates:s}=e;ue(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=i??null,t.position.reset(s)});const o=Jr({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"&&ue(()=>{t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:i,operation:t.snapshot(),cancelable:!1})})}),r)})}move(e){return H(()=>{var t,n;const{dragOperation:r}=this.manager,{status:i,controller:s}=r;if(!i.dragging||!s||s.signal.aborted)return;const o=Jr({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 h=(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=h})})}stop(e={}){return H(()=>{var t,n;const{dragOperation:r}=this.manager,{controller:i}=r;if(!i||i.signal.aborted)return;let s;const o=()=>{const l={resume:()=>{},abort:()=>{}};return s=new Promise((u,d)=>{l.resume=u,l.abort=d}),l};i.abort();const a=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const l=H(()=>{var d;return((d=r.source)==null?void 0:d.status)==="dropping"}),u=()=>{r.controller===i&&(r.controller=void 0),r.reset()};if(l){const{source:d}=r,c=tt(()=>{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}),s?s.then(a).catch(()=>r.reset()):a()})}},bn=class extends Me{constructor(e,t){super(e,t),this.manager=e,this.options=t}},Zu=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)}},ei,lc=class{constructor(e){this.options=e,J(this,ei)}set controller(e){He(this,ei,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=pe(this,ei))==null||t.activate(e)}};ei=new WeakMap;var ga=class extends Me{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},Ju=class{constructor(e){this.draggables=new pa,this.droppables=new pa,this.plugins=new Zi(e),this.sensors=new Zi(e),this.modifiers=new Zi(e)}register(e,t){if(e instanceof ut)return this.draggables.register(e.id,e);if(e instanceof ft)return this.droppables.register(e.id,e);if(e.prototype instanceof ga)return this.modifiers.register(e,t);if(e.prototype instanceof bn)return this.sensors.register(e,t);if(e.prototype instanceof Me)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof ji)return e instanceof ut?this.draggables.unregister(e.id,e):e instanceof ft?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof ga)return this.modifiers.unregister(e);if(e.prototype instanceof bn)return this.sensors.unregister(e);if(e.prototype instanceof Me)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()}},cc,dc,uc,fc,hc,pc,gc,vc,mc,Yn,ti,cn,ce,Eo,Oo,To,Do,Co,Xn;mc=[ge],vc=[K],gc=[K],pc=[K],hc=[K],fc=[K],uc=[ge],dc=[ge],cc=[ge];var ot=class{constructor(e){N(ce,5,this),J(this,Yn),J(this,ti),J(this,cn,new Kt(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new bt,J(this,Eo,N(ce,8,this,!1)),N(ce,11,this),J(this,Oo,N(ce,12,this,null)),N(ce,15,this),J(this,To,N(ce,16,this,null)),N(ce,19,this),J(this,Do,N(ce,20,this,null)),N(ce,23,this),J(this,Co,N(ce,24,this,[])),N(ce,27,this),this.position=new Ii({x:0,y:0}),J(this,Xn,{x:0,y:0}),He(this,Yn,e)}get shape(){const{current:e,initial:t,previous:n}=pe(this,cn);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?pe(this,cn).current=e:pe(this,cn).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=pe(this,Yn).registry.draggables.get(t);return n&&He(this,ti,n),(e=n??pe(this,ti))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=pe(this,Yn).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(co(lo({},this.snapshot()),{transform:n}));return He(this,Xn,n),n}snapshot(){return H(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:pe(this,Xn),shape:this.shape?Qi(this.shape):null,position:Qi(this.position),status:Qi(this.status),canceled:this.canceled}))}reset(){ue(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,pe(this,cn).reset(),this.position.reset({x:0,y:0}),He(this,Xn,{x:0,y:0}),this.modifiers=[]})}};ce=Pn(null);Yn=new WeakMap;ti=new WeakMap;cn=new WeakMap;Eo=new WeakMap;Oo=new WeakMap;To=new WeakMap;Do=new WeakMap;Co=new WeakMap;Xn=new WeakMap;Y(ce,2,"shape",mc,ot);Y(ce,4,"canceled",vc,ot,Eo);Y(ce,4,"activatorEvent",gc,ot,Oo);Y(ce,4,"sourceIdentifier",pc,ot,To);Y(ce,4,"targetIdentifier",hc,ot,Do);Y(ce,4,"modifiers",fc,ot,Co);Y(ce,2,"source",uc,ot);Y(ce,2,"target",dc,ot);Y(ce,2,"transform",cc,ot);Yt(ce,ot);var ef={get rendering(){return Promise.resolve()}};function st(e,t){return typeof e=="function"?e(t):e??t}var tf=class{constructor(t){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(h=>h.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var n;const r=t??{},i=st(r.plugins,[]),s=st(r.sensors,[]),o=st(r.modifiers,[]),a=(n=r.renderer)!=null?n:ef,l=new Yu(this),u=new Ju(this);this.registry=u,this.monitor=l,this.renderer=a,this.actions=new Qu(this),this.dragOperation=new ot(this),this.collisionObserver=new Hu(this),this.plugins=[Xu,...i],this.modifiers=o,this.sensors=s;const{destroy:d}=this,c=$r(()=>{var h,f,v;const p=H(()=>this.dragOperation.modifiers),w=this.modifiers;for(const x of p)w.includes(x)||x.destroy();this.dragOperation.modifiers=(v=(f=(h=this.dragOperation.source)==null?void 0:h.modifiers)==null?void 0:f.map(x=>{const{plugin:m,options:g}=gr(x);return new m(this,g)}))!=null?v:w});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}},yc=e=>{throw TypeError(e)},Po=(e,t,n)=>t.has(e)||yc("Cannot "+n),F=(e,t,n)=>(Po(e,t,"read from private field"),t.get(e)),Ne=(e,t,n)=>t.has(e)?yc("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),qe=(e,t,n,r)=>(Po(e,t,"write to private field"),t.set(e,n),n),bc=(e,t,n)=>(Po(e,t,"access private method"),n);function Ai(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function xc(e,t){const n=e.getAnimations();let r=null;for(const i of n){if(i.playState!=="running")continue;const{effect:s}=i,a=(Ai(s)?s.getKeyframes():[]).filter(t);a.length>0&&(r=[a[a.length-1],i])}return r}function Ri(e){const{width:t,height:n,top:r,left:i,bottom:s,right:o}=e.getBoundingClientRect();return{width:t,height:n,top:r,left:i,bottom:s,right:o}}function Mo(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Dr(e){return"nodeType"in e}function Ke(e){var t,n,r;return e?Mo(e)?e:Dr(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 Io(e){const{Document:t}=Ke(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function Tt(e){return!e||Mo(e)?!1:e instanceof Ke(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function wc(e){return e instanceof Ke(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function jn(e){return e?Mo(e)?e.document:Dr(e)?Io(e)?e:Tt(e)||wc(e)?e.ownerDocument:document:document:document}function nf(e){var t,n,r,i;const{documentElement:s}=jn(e),o=Ke(e).visualViewport,a=(t=o?.width)!=null?t:s.clientWidth,l=(n=o?.height)!=null?n:s.clientHeight,u=(r=o?.offsetTop)!=null?r:0,d=(i=o?.offsetLeft)!=null?i:0;return{top:u,left:d,right:d+a,bottom:u+l,width:a,height:l}}function rf(e,t){if(sf(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:i}=getComputedStyle(e);return n==="visible"&&r==="visible"&&i==="visible"}function sf(e){return e.tagName==="DETAILS"}function mr(e,t=e.getBoundingClientRect(),n=0){var r,i,s,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(!rf(c)){const g=c.getBoundingClientRect(),b=n*(g.bottom-g.top),_=n*(g.right-g.left),$=n*(g.bottom-g.top),O=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+$),left:Math.max(l.left,g.left-O),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top}c=c.parentElement}const h=d.visualViewport,f=(i=h?.offsetTop)!=null?i:0,v=(s=h?.offsetLeft)!=null?s:0,p=(o=h?.width)!=null?o:d.innerWidth,w=(a=h?.height)!=null?a:d.innerHeight,x=n*w,m=n*p;return l={top:Math.max(l.top,f-x),right:Math.min(l.right,v+p+m),bottom:Math.min(l.bottom,f+w+x),left:Math.max(l.left,v-m),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 xn(e){return{x:e.clientX,y:e.clientY}}var _c=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Es(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 i=r.contentDocument;i&&!t.has(i)&&n.push(...Es(i,t))}catch{}try{const r=e.defaultView;if(r&&r!==window.top){const i=r.parent;i&&i.document&&i.document!==e&&n.push(...Es(i.document,t))}}catch{}return n}function jo(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function kc(){var e,t;const n=jo()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function Ao(e){return!e||!Dr(e)?!1:e instanceof Ke(e).ShadowRoot}function pi(e){if(e&&Dr(e)){let t=e.getRootNode();if(Ao(t))return t;if(t instanceof Document)return t}return jn(e)}function Ro(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function of(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((s,o)=>{const a=r[o];if(va(s)&&va(a)&&(s.type!=="file"&&(s.value=a.value),s.type==="radio"&&s.name&&(s.name=`Cloned__${s.name}`)),ma(s)&&ma(a)&&a.width>0&&a.height>0){const l=s.getContext("2d");l?.drawImage(a,0,0)}}),n}function va(e){return"value"in e}function ma(e){return e.tagName==="CANVAS"}function Sc(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(af(r)){const{contentDocument:i}=r;if(i){const{left:s,top:o}=r.getBoundingClientRect();return Sc(i,{x:t-s,y:n-o})}}return r}function af(e){return e?.tagName==="IFRAME"}var Os=new WeakMap;function lf(e){return e.closest(`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react/jsx-runtime"),C=require("../useCompiledDocument-pOg2W-Yt.cjs.js"),$=require("@mui/material"),k=require("react"),Ke=require("../ServerProvider-Gbf1YPOP.cjs.js"),me=require("../text-entry-BJwltZiy.cjs.js"),sf=require("react-dom"),of=require("@malloydata/malloy-tag"),af=require("@tanstack/react-query"),lf={line_chart:"Line",bar_chart:"Bar",big_value:"Big value",scatter_chart:"Scatter",shape_map:"Shape map",segment_map:"Segment map"};function cf(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:lf[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=cf(t,e,n),u=k.useId();return x.jsx($.TextField,{select:!0,size:"small",variant:a,label:"Viz type",value:e,disabled:s!==void 0,onChange:c=>{const d=c.target.value;l.find(f=>f.value===d)?.disabled||o(d)},helperText:s,FormHelperTextProps:{id:u},SelectProps:{...i?{onOpen:i}:{},renderValue:c=>l.find(d=>d.value===c)?.label??String(c),MenuProps:{MenuListProps:{disabledItemsFocusable:!0}},SelectDisplayProps:{"aria-label":`Viz type, ${r}`,"aria-labelledby":void 0,...s?{"aria-describedby":u}:{}}},sx:{minWidth:140},children:l.map(c=>x.jsx($.MenuItem,{value:c.value,disabled:c.value==="custom"||c.disabled===!0,children:x.jsx($.ListItemText,{primary:c.label,...c.reason?{secondary:c.reason}:{}})},c.value))})}function df({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($.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 uf({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,c]=k.useState("query"),[d,f]=k.useState(""),[p,h]=k.useState(""),[v,y]=k.useState(""),[w,g]=k.useState("default"),[m,b]=k.useState(Math.ceil(r/2));k.useEffect(()=>{if(!e)return;c("query");const I=T=>l.some(D=>D.name===T&&D.views.length>0);f(t.sources.map(T=>T.base).find(I)??l.find(T=>T.views.length>0)?.name??""),h(""),y(""),g("default"),b(Math.ceil(r/2))},[e,t,l,r]);const _=d!==""&&p!=="",O=[d,p].filter(I=>I!==""&&!me.isBareName(I)).map(I=>`"${I}" is not a plain Malloy name, so a tile cannot be written for it.`)[0],E=l.find(I=>I.name===d)?.views.find(I=>I.name===p);return x.jsx(C.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:u==="query"&&(!_||O!==void 0),onClick:()=>u==="text"?o():i({base:d,modelPath:l.find(I=>I.name===d)?.modelPath??"",view:p,...v.trim()?{label:v.trim()}:{},...w!=="default"?{chart:w,...E?{chartCarried:E.chart?[E.chart]:[]}:{}}:{},colspan:m}),children:u==="text"?"Add text":"Add tile"})]}),children:x.jsxs($.Stack,{sx:{gap:2,pt:1},children:[x.jsxs($.ToggleButtonGroup,{size:"small",exclusive:!0,value:u,"aria-label":"Tile type",onChange:(I,T)=>{T!==null&&c(T)},children:[x.jsx($.ToggleButton,{value:"query",sx:{px:1.5},children:"Query"}),x.jsx($.ToggleButton,{value:"text",sx:{px:1.5},children:"Text"})]}),u==="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(df,{sources:l,source:d,view:p,onSource:I=>{f(I),h("")},onView:I=>{h(I),g("default")}}),O&&x.jsx($.Typography,{variant:"body2",color:"error",children:O}),x.jsx(Ei,{state:w,view:E,cellLabel:"new tile",variant:"outlined",...E?{}:{disabledReason:"Pick a view to choose its chart."},onChange:I=>g(I)}),x.jsx($.Stack,{direction:"row",sx:{gap:1.5},children:x.jsx($.TextField,{size:"small",label:"Title",placeholder:"Uses the view's name",value:v,onChange:I=>y(I.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 ff({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(v=>v.source===n.name);u((n.dimensions??[]).map(v=>{const y=h.find(w=>w.name===v.name);return{name:v.name,expression:v.expression,to:y?.to??[],given:y?.given??""}}))},[e,n,t]);const c=(h,v)=>u(y=>y.map((w,g)=>{if(g!==h)return w;const m={...w};return v(m),m})),d=[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(C.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($.Button,{onClick:i,children:"Cancel"}),x.jsx($.Button,{variant:"contained",onClick:p,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((h,v)=>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:h.name}),x.jsxs($.Typography,{variant:"caption",sx:{color:a.tileTitle,display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:h.expression,children:["is ",h.expression]})]}),x.jsx($.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=>c(v,w=>{const g=y.target.value;w.to=Array.isArray(g)?g:String(g).split(",").filter(Boolean)}),children:d.map(y=>x.jsxs($.MenuItem,{value:y,children:[x.jsx($.Checkbox,{size:"small",checked:h.to.includes(y),sx:{p:0,mr:1}}),x.jsx($.ListItemText,{primary:f(y)})]},y))}),x.jsxs($.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=>c(v,w=>{w.given=y.target.value}),children:[x.jsx($.MenuItem,{value:"",children:x.jsx("em",{children:"Same name as the dimension"})}),r.map(y=>x.jsx($.MenuItem,{value:y,children:y},y))]})]},h.name))})})}function hf(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 pf(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function rs(e,t){const n=pf(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 Da(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 gf(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const mf=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function vf(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 Aa=[{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 bf(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 yf(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 xf(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 wf(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 Bl=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function _f({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,c]=k.useState({kind:"new"}),[d,f]=k.useState(""),[p,h]=k.useState("select"),[v,y]=k.useState(""),[w,g]=k.useState(""),[m,b]=k.useState([]),[_,O]=k.useState(!1),[E,I]=k.useState(!1),T=M=>t.sources.find(U=>U.name===M.source)?.base??M.source;k.useEffect(()=>{if(e)if(I(n!==void 0),n){c({kind:"existing",name:n.name}),f(n.label??"");const M=bf(t,n);b(M);const U=M.filter(ve=>ve.include),de=new Set(U.map(ve=>ve.field));g(de.size===1?U[0].field:n.field??""),O(de.size>1)}else c({kind:"new"}),f(""),h("select"),g(""),y(new Date().toISOString().slice(0,10)),b(t.tiles.map(M=>({include:Ci(M),field:""}))),O(!1)},[e,n,t]);const D=k.useMemo(()=>[...(t.localGivens??[]).map(M=>M.name),...r.map(M=>M.name)],[t,r]),L=k.useMemo(()=>w.trim()?vf(w.trim(),D):"",[w,D]),R=u.kind==="existing"?n??r.find(M=>M.name===u.name):L?{name:L,type:Br({name:L,label:d,kind:p,field:w}).type}:void 0,z=R?.type!==void 0&&!R.type.startsWith("filter<"),K=m.find(M=>M.include)?.op??bs(R?.type),G=(M,U)=>{I(!0),b(de=>de.map((ve,Re)=>Re===M?{...ve,...U}:ve))},X=M=>{I(!0),b(U=>U.map(de=>({...de,op:M})))},Y=M=>{const U=bs(M);b(de=>de.map(({op:ve,...Re})=>U?{...Re,op:U}:Re))},se=M=>{I(!0),c({kind:"existing",name:M.name}),g(M.field??""),Y(M.type)},te=M=>{I(!0),h(M),Y(Br({name:"X",label:d,kind:M,field:w}).type)},A=t.tiles.map(Ci),B=A.filter(Boolean).length,N=m.filter((M,U)=>M.include&&A[U]).length,j=t.tiles.filter((M,U)=>(m[U]?.include??!1)&&A[U]&&xe(M)),q=j.length>0?j:t.tiles.filter((M,U)=>A[U]&&xe(M)),J=k.useMemo(()=>{const M=new Map;let U=!1;for(const de of q){const ve=s?.(de);if(ve){U=!0;for(const Re of ve)M.has(Re.name)||M.set(Re.name,Re)}}return U?[...M.values()]:void 0},[m,t.tiles,s]),ee=(()=>{const M=w.trim();for(const U of j){const de=s?.(U);if(!de||de.some(ve=>ve.name===M))return T(U)}return j[0]?T(j[0]):t.sources[0]?.base})(),H=M=>{I(!0),b(U=>U.map((de,ve)=>({...de,include:M&&A[ve]})))},S=k.useMemo(()=>_?m:m.map(M=>({...M,field:w})),[_,m,w]),P=M=>{for(const U of q){const de=s?.(U)?.find(ve=>ve.name===M.trim());if(de?.type)return de.type}},F=M=>rs(R?.type,M.type),V=(M,U)=>{if(M.trim()==="")return"Pick the field this filter compares.";const de=U?s?.(U):void 0;if(!de)return;const ve=de.find(Re=>Re.name===M.trim());if(!ve)return`Not a field of ${U?T(U):"the tiles' source"}.`;if(ve.type&&!rs(R?.type,ve.type))return`${M.trim()} is ${Da(ve.type)}; this filter compares ${Da(R?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},ie=M=>{if(I(!0),g(M),l||u.kind!=="new")return;const U=P(M),de=Br({name:"X",label:d,kind:p,field:M}).type;U&&!rs(de,U)&&te(gf(U))},Z=M=>{const U=t.tiles[M];return U&&xe(U)?U:void 0},oe=S.map((M,U)=>M.include&&A[U]?V(M.field,Z(U)):void 0),W=oe.every(M=>M===void 0),Q=E?oe:oe.map(()=>{}),ne=E&&!_&&N>0?j.map(M=>V(w,M)).find(Boolean):void 0,re=R!==void 0&&W&&(u.kind==="existing"||w.trim()!==""&&L!==""),ce=()=>{if(!(!R||!re))if(u.kind==="new")i(R.name,S,Br({name:R.name,label:d.trim()||Bl(R.name),kind:p,field:w.trim(),...ee?{source:ee}:{},...v?{dateDefault:v}:{}}));else if(n?.origin==="dashboard"&&n.local){const M=d.trim(),U=M!==(n.local.label??"");i(R.name,S,U?{...n.local,...M?{label:M}:{}}:void 0)}else i(R.name,S)},pe=l&&a.origin==="model";return{editing:l,shown:a,fromModel:pe,source:u,setSource:c,label:d,setLabel:f,kind:p,dateDefault:v,setDateDefault:y,field:w,rows:m,setRows:b,perTile:_,setPerTile:O,newName:L,target:R,valueTyped:z,commonOp:K,setRow:G,setCommonOp:X,pickExisting:se,pickKind:te,bindable:A,bindableCount:B,included:N,commonFields:J,setAll:H,accepts:F,pickField:ie,rowProblems:Q,commonProblem:ne,canApply:re,apply:ce}}function Pa({value:e,onChange:t,fields:n,accepts:r,label:s,ariaLabel:i,error:o,helperText:a,disabled:l,autoFocus:u,placeholder:c,sx:d}){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($.Autocomplete,{freeSolo:!0,size:"small",options:f,inputValue:e,onInputChange:(h,v)=>t(v),value:e,onChange:(h,v)=>t(typeof v=="string"?v:""),disabled:l,disableClearable:!0,renderOption:(h,v)=>k.createElement("li",{...h,key:v},x.jsx($.Typography,{variant:"body2",sx:{flex:1},children:v}),p.get(v)&&x.jsx($.Typography,{variant:"caption",sx:{opacity:.6},children:p.get(v)?.replace(/_type$/,"")})),renderInput:h=>x.jsx($.TextField,{...h,label:s,placeholder:c,autoFocus:u,error:o,helperText:a,inputProps:{...h.inputProps,"aria-label":i}}),sx:d})}const Ma=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 kf({open:e,document:t,control:n,available:r,fieldsFor:s,onClose:i,onApply:o,onRemove:a}){const{theme:l}=Ke.usePublisherTheme(),{editing:u,shown:c,fromModel:d,source:f,setSource:p,label:h,setLabel:v,kind:y,dateDefault:w,setDateDefault:g,field:m,rows:b,setRows:_,perTile:O,setPerTile:E,newName:I,target:T,valueTyped:D,commonOp:L,setRow:R,setCommonOp:z,pickExisting:K,pickKind:G,bindable:X,bindableCount:Y,included:se,commonFields:te,setAll:A,accepts:B,pickField:N,rowProblems:j,commonProblem:q,canApply:J,apply:ee}=_f({open:e,document:t,control:n,available:r,fieldsFor:s,onApply:o}),H=(S,P,F)=>x.jsx($.TextField,{select:!0,size:"small",label:"Compares",value:S??">=",onChange:V=>P(V.target.value),inputProps:{"aria-label":F},sx:{width:130},children:mf.filter(V=>V.op!=="~").map(V=>x.jsx($.MenuItem,{value:V.op,children:V.label},V.op))});return x.jsx(C.AppDialog,{open:e,onClose:i,title:u?c.label??c.name:"Add a filter",description:u?x.jsxs(x.Fragment,{children:[x.jsxs($.Box,{component:"span",sx:{fontFamily:"ui-monospace, monospace"},children:["$",c.name]}),d?" · 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($.Button,{color:"error",startIcon:x.jsx(C.DeleteOutlineIcon,{}),onClick:()=>a(c.name),sx:S=>({mr:"auto",color:C.dangerTextColor(S)}),children:"Remove filter"}),x.jsx($.Button,{onClick:i,children:"Cancel"}),x.jsx($.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($.Button,{variant:"contained",onClick:ee,disabled:!J,children:u?"Apply":"Add filter"})})})]}),children:x.jsxs($.Stack,{sx:{gap:2.5,pt:1},children:[!u&&r.length>0&&x.jsxs($.ToggleButtonGroup,{exclusive:!0,size:"small",value:f.kind,onChange:(S,P)=>{P==="new"?p({kind:"new"}):P==="existing"&&r[0]&&K(r[0])},"aria-label":"Where the filter comes from",children:[x.jsx($.ToggleButton,{value:"new",children:"New in this dashboard"}),x.jsx($.ToggleButton,{value:"existing",children:"From the model"})]}),!u&&f.kind==="existing"?x.jsx($.TextField,{select:!0,size:"small",label:"Filter",value:f.name,onChange:S=>{const P=r.find(F=>F.name===S.target.value);P&&K(P)},children:r.map(S=>x.jsxs($.MenuItem,{value:S.name,children:[S.label??S.name,x.jsxs($.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",S.name]})]},S.name))}):null,x.jsxs($.Stack,{direction:"row",sx:{gap:1.5,flexWrap:"wrap"},children:[!O&&x.jsx(Pa,{value:m,onChange:N,fields:te,accepts:B,label:"Field to filter",ariaLabel:"Field to filter",placeholder:"category",autoFocus:!u,error:q!==void 0,helperText:q??(!u&&I?`Declared as $${I}`:void 0),sx:{flex:1,minWidth:200}}),!d&&x.jsx($.TextField,{size:"small",label:"Label",placeholder:I?Bl(I):"",value:h,onChange:S=>v(S.target.value),inputProps:{"aria-label":"Filter label"},sx:{flex:1,minWidth:160}}),D&&!O&&H(L,z,"Comparison")]}),!u&&f.kind==="new"&&x.jsxs($.Stack,{direction:"row",sx:{gap:1.5},children:[x.jsx($.TextField,{select:!0,size:"small",label:"Filter kind",value:y,onChange:S=>G(S.target.value),inputProps:{"aria-label":"Filter kind"},slotProps:{select:{renderValue:S=>Aa.find(P=>P.kind===S)?.label??String(S)}},sx:{flex:1},children:Aa.map(S=>x.jsxs($.MenuItem,{value:S.kind,children:[S.label,x.jsx($.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:S.hint})]},S.kind))}),y==="date"&&x.jsx($.TextField,{size:"small",type:"date",label:"Starts at",value:w,onChange:S=>g(S.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:Y>0&&se===Y,indeterminate:se>0&&se<Y,disabled:Y===0,onChange:S=>A(S.target.checked),inputProps:{"aria-label":"All tiles"}}),x.jsxs($.Typography,{variant:"subtitle2",sx:{flex:1},children:["Applies to ",se," of ",t.tiles.length," tiles"]}),x.jsx($.Button,{size:"small",onClick:()=>{O||_(S=>S.map(P=>({...P,field:m}))),E(S=>!S)},children:O?"Same field for all":"Adjust per tile"})]}),x.jsx($.Stack,{sx:{gap:O?1:0},children:t.tiles.map((S,P)=>{if(!xe(S))return null;const F=b[P],V=S.label??S.name,ie=O?j[P]:void 0;return x.jsxs($.Stack,{direction:"row",sx:{gap:1,alignItems:O?"flex-start":"center",opacity:X[P]?1:.6},children:[x.jsx($.Checkbox,{size:"small",disabled:!X[P],checked:(F?.include??!1)&&X[P],inputProps:{"aria-label":`Filter ${V}`},onChange:Z=>R(P,{include:Z.target.checked})}),x.jsx($.Typography,{variant:"body2",sx:{flex:1,minWidth:0,pt:O?1:0},noWrap:!0,children:V}),X[P]?O&&x.jsxs(x.Fragment,{children:[D&&H(F?.op,Z=>R(P,{op:Z}),`Comparison for ${V}`),x.jsx(Pa,{value:F?.field??"",onChange:Z=>R(P,{field:Z}),fields:s?.(S),accepts:B,label:"Field",ariaLabel:`Field for ${V}`,disabled:!F?.include,error:ie!==void 0,helperText:ie,sx:{width:220}})]}):x.jsx($.Tooltip,{title:Ma(t.tiles[P]).reason,children:x.jsx($.Typography,{variant:"caption",sx:{color:l.tileTitle},children:Ma(t.tiles[P]).label})})]},`${S.source}.${S.name}`)})}),se===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 Sf=C.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 Gl(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:c=>i(d=>{if(d===void 0)return d;const f=structuredClone(d);return c(f),f}),apply:c=>{if(s===void 0)return;const d=structuredClone(s);c(d),i(d),JSON.stringify(d)!==JSON.stringify(e)&&n(d)},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.`,Tf="This tile's view is declared on its source, so its chart is set in the model.";function Of({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:c,apply:d,close:f,discard:p}=Gl(t,e!==null,r,n),h=c!==void 0&&xe(c)?c:void 0,v=h!==void 0&&h.declaration.kind!=="inherited",y=m=>d(b=>{xe(b)&&m(b)}),w=k.useRef(void 0),g=e!==null;return k.useEffect(()=>{g&&(w.current=t&&xe(t)?t.chart:void 0)},[g]),x.jsx($.Popover,{open:e!==null&&c!==void 0,anchorEl:e,onClose:f,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{width:320,p:2}}},children:c&&x.jsxs($.Stack,{sx:{gap:1.5},children:[x.jsx($.Typography,{variant:"overline",sx:{color:u.tileTitle,lineHeight:1.5},children:h?`${h.source} → ${h.name}`:`Text · ${c.name}`}),h&&v&&x.jsx(x.Fragment,{children:x.jsx(Ei,{state:h.chart??"default",view:a,cellLabel:`${h.source} ${h.name}`,...h.chart==="custom"?{disabledReason:$f(h.chartLines)}:{},onChange:m=>y(b=>{const _=w.current;m===(_??"default")?(_===void 0?delete b.chart:b.chart=_,delete b.chartCarried):(b.chart=m,a?b.chartCarried=a.chart?[a.chart]:[]:delete b.chartCarried)})})}),h&&!v&&x.jsxs(x.Fragment,{children:[x.jsx($.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:Tf,onChange:()=>{}})]}),h?.declaration.kind==="opaque"&&x.jsxs($.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($.Stack,{direction:"row",sx:{justifyContent:"space-between"},children:[v?x.jsx($.Button,{size:"small",startIcon:x.jsx(Sf,{}),"aria-haspopup":"dialog",onClick:()=>{f(),o()},children:"Drill"}):x.jsx("span",{}),x.jsx($.Button,{color:"error",size:"small",startIcon:x.jsx(C.DeleteOutlineIcon,{}),"aria-disabled":i!==void 0||void 0,"aria-describedby":i!==void 0?l:void 0,disableRipple:i!==void 0,sx:m=>({color:C.dangerTextColor(m),...i!==void 0?{opacity:.5,cursor:"default"}:{}}),onClick:()=>{i===void 0&&(p(),s())},children:"Delete"})]}),i!==void 0&&x.jsx($.Typography,{id:l,variant:"caption",sx:{color:u.tileTitle},children:i})]})})}function Ef({editor:e,catalog:t,columns:n,dashboards:r,bindings:s,tiles:i,drillSource:o,setDrillSource:a,confirmConversion:l,exitDialog:u}){const{filterDialog:c,setFilterDialog:d}=s,{menu:f,setMenu:p}=i,h=f===void 0?void 0:e.document.tiles[f.index],v=h&&xe(h)?h:void 0,y=(()=>{if(!v||!t)return;const w=e.document.sources.find(m=>m.name===v.source)?.base??v.source,g=v.declaration.kind==="reference"?v.declaration.from:v.name;return t.sources.find(m=>m.name===w)?.views.find(m=>m.name===g)})();return x.jsxs(x.Fragment,{children:[x.jsx(kf,{open:c!==void 0,document:e.document,...c?.control?{control:c.control}:{},available:s.available,...t?{fieldsFor:s.fieldsFor}:{},onClose:()=>d(void 0),onApply:s.applyFilter,onRemove:s.dropControl}),x.jsx(Of,{anchor:f?.anchor??null,tile:f===void 0?void 0:e.document.tiles[f.index],onClose:()=>p(void 0),onCommit:w=>{const g=f?.index;g!==void 0&&e.update(m=>{m.tiles[g]=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(v?.source)}}),x.jsx(ff,{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(g=>{const b=[...(g.drills??[]).filter(_=>_.source!==o),...w];b.length===0?delete g.drills:g.drills=b})}),x.jsx(C.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($.Button,{onClick:()=>l?.stop(),children:"Cancel"}),x.jsx($.Button,{variant:"contained",onClick:()=>l?.go(),children:"Convert and save"})]}),children:null}),x.jsx(C.UnsavedChangesDialog,{...u}),x.jsx(uf,{open:i.addingTile,document:e.document,catalog:t,columns:n,onClose:i.closeAdd,onAdd:i.addTile,onAddText:i.addText})]})}var Cf=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)&&Kl(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=++If,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,If=0,Ii=0,xs=void 0,ws=0;function ql(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=Cf;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=ql(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 Kl(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 Ul(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 Vl(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&&!Kl(this))return this.f&=-2,!0;var e=we;try{Ul(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,Vl(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=ql(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function ja(e,t){return new Xt(e,t)}function Hl(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,yo(e),r}finally{we=n,zs()}}}function yo(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Hl(e)}function Df(e){if(we!==this)throw new Error("Out-of-order effect");Vl(this),we=e,this.f&=-2,8&this.f&&yo(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,Hl(this),Ul(this),yt++;var e=we;return we=this,Df.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||yo(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 Af=Object.create,xo=Object.defineProperty,Pf=Object.defineProperties,Mf=Object.getOwnPropertyDescriptor,jf=Object.getOwnPropertyDescriptors,Ra=Object.getOwnPropertySymbols,Rf=Object.prototype.hasOwnProperty,Lf=Object.prototype.propertyIsEnumerable,Nf=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),En=e=>{throw TypeError(e)},Di=(e,t,n)=>t in e?xo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ff=(e,t)=>{for(var n in t||(t={}))Rf.call(t,n)&&Di(e,n,t[n]);if(Ra)for(var n of Ra(t))Lf.call(t,n)&&Di(e,n,t[n]);return e},zf=(e,t)=>Pf(e,jf(t)),La=(e,t)=>xo(e,"name",{value:t,configurable:!0}),Wf=e=>{var t;return[,,,Af((t=void 0)!=null?t:null)]},Xl=["class","method","getter","setter","accessor","field","value","get","set"],Kn=e=>e!==void 0&&typeof e!="function"?En("Function expected"):e,Bf=(e,t,n,r,s)=>({kind:Xl[e],name:t,metadata:r,addInitializer:i=>n._?En("Already initialized"):s.push(Kn(i||null))}),Yl=(e,t)=>Di(t,Nf("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,c,d=t&7,f=!!(t&8),p=!!(t&16),h=d>3?e.length+1:d?f?1:2:0,v=Xl[d+5],y=d>3&&(e[h-1]=[]),w=e[h]||(e[h]=[]),g=d&&(!p&&!f&&(s=s.prototype),d<5&&(d>3||!p)&&Mf(d<4?s:{get[n](){return Je(this,i)},set[n](b){return Ot(this,i,b)}},n));d?p&&d<4&&La(i,(d>2?"set ":d>1?"get ":"")+n):La(s,n);for(var m=r.length-1;m>=0;m--)u=Bf(d,n,l={},e[3],w),d&&(u.static=f,u.private=p,c=u.access={has:p?b=>Gf(s,b):b=>n in b},d^3&&(c.get=p?b=>(d^1?Je:qf)(b,s,d^4?i:g.get):b=>b[n]),d>2&&(c.set=p?(b,_)=>Ot(b,s,_,d^4?i:g.set):(b,_)=>b[n]=_)),a=(0,r[m])(d?d<4?p?i:g[v]:d>4?void 0:{get:g.get,set:g.set}:s,u),l._=1,d^4||a===void 0?Kn(a)&&(d>4?y.unshift(a):d?p?i=a:g[v]=a:s=a):typeof a!="object"||a===null?En("Object expected"):(Kn(o=a.get)&&(g.get=o),Kn(o=a.set)&&(g.set=o),Kn(o=a.init)&&y.unshift(o));return d||Yl(e,s),g&&xo(s,n,g),p?d^4?i:g:s},wo=(e,t,n)=>t.has(e)||En("Cannot "+n),Gf=(e,t)=>Object(t)!==t?En('Cannot use the "in" operator on this value'):e.has(t),Je=(e,t,n)=>(wo(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)=>(wo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),qf=(e,t,n)=>(wo(e,t,"access private method"),n);function Ai(e,t){if(t){let n;return ja(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return ja(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,zf(Ff({},s),{enumerable:e}))})}}function Er(...e){const t=e.map(n=>st(n));return()=>t.forEach(n=>n())}var Zl,Ql,Jl,ec,tc,nc,Be,_o,oi,Pi,Mi,ze,ko,ai,rc,ji,So,li,Ri,Li;nc=[fe],tc=[fe],ec=[fe],Jl=[ii()],Ql=[ii()],Zl=[ii()];var Yt=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,jt(Be,5,this),Un(this,ze),Un(this,_o,jt(Be,8,this)),jt(Be,11,this),Un(this,ko,jt(Be,12,this)),jt(Be,15,this),Un(this,So,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,rc)}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=Wf();_o=new WeakMap;ze=new WeakSet;ko=new WeakMap;So=new WeakMap;oi=Cn(Be,20,"#initial",nc,ze,_o),Pi=oi.get,Mi=oi.set;ai=Cn(Be,20,"#previous",tc,ze,ko),rc=ai.get,ji=ai.set;li=Cn(Be,20,"#current",ec,ze,So),Ri=li.get,Li=li.set;Cn(Be,2,"current",Jl,Yt);Cn(Be,2,"initial",Ql,Yt);Cn(Be,2,"previous",Zl,Yt);Yl(Be,Yt);function ci(e){return ue(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var Rt,Kf=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 Uf=Object.create,sc=Object.defineProperty,Vf=Object.getOwnPropertyDescriptor,Na=Object.getOwnPropertySymbols,Hf=Object.prototype.hasOwnProperty,Xf=Object.prototype.propertyIsEnumerable,ic=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ws=e=>{throw TypeError(e)},Fa=Math.pow,Ni=(e,t,n)=>t in e?sc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Yf=(e,t)=>{for(var n in t||(t={}))Hf.call(t,n)&&Ni(e,n,t[n]);if(Na)for(var n of Na(t))Xf.call(t,n)&&Ni(e,n,t[n]);return e},Zf=e=>{var t;return[,,,Uf((t=e?.[ic("metadata")])!=null?t:null)]},oc=["class","method","getter","setter","accessor","field","value","get","set"],ac=e=>e!==void 0&&typeof e!="function"?Ws("Function expected"):e,Qf=(e,t,n,r,s)=>({kind:oc[e],name:t,metadata:r,addInitializer:i=>n._?Ws("Already initialized"):s.push(ac(i||null))}),Jf=(e,t)=>Ni(t,ic("metadata"),e[3]),eh=(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},lc=(e,t,n,r,s,i)=>{for(var o,a,l,u,c=t&7,d=!1,f=!1,p=2,h=oc[c+5],v=e[p]||(e[p]=[]),y=(s=s.prototype,Vf(s,n)),w=r.length-1;w>=0;w--)l=Qf(c,n,a={},e[3],v),l.static=d,l.private=f,u=l.access={has:g=>n in g},u.get=g=>g[n],o=(0,r[w])(y[h],l),a._=1,ac(o)&&(y[h]=o);return y&&sc(s,n,y),s},cc=(e,t,n)=>t.has(e)||Ws("Cannot "+n),th=(e,t,n)=>(cc(e,t,"read from private field"),t.get(e)),nh=(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),rh=(e,t,n,r)=>(cc(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=Yf({},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?sh(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 sh(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 dc,uc,zi,ss,Cr,Bs=class extends(zi=Yt,uc=[Ee],dc=[Ee],zi){constructor(t){const n=et.from(t);super(n,(r,s)=>et.equals(r,s)),eh(Cr,5,this),nh(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-th(this,ss),a=l=>Math.round(l/o*100);Te(()=>{rh(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=Zf(zi);ss=new WeakMap;lc(Cr,2,"delta",uc,Bs);lc(Cr,2,"direction",dc,Bs);Jf(Cr,Bs);function Wi({x:e,y:t},n){const r=Math.abs(e),s=Math.abs(t);return typeof n=="number"?Math.sqrt(Fa(r,2)+Fa(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 fc=(e=>(e.Horizontal="x",e.Vertical="y",e))(fc||{}),hc=Object.values(fc),ih=Object.create,$o=Object.defineProperty,oh=Object.defineProperties,ah=Object.getOwnPropertyDescriptor,lh=Object.getOwnPropertyDescriptors,_s=Object.getOwnPropertySymbols,pc=Object.prototype.hasOwnProperty,gc=Object.prototype.propertyIsEnumerable,mc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),In=e=>{throw TypeError(e)},Bi=(e,t,n)=>t in e?$o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,To=(e,t)=>{for(var n in t||(t={}))pc.call(t,n)&&Bi(e,n,t[n]);if(_s)for(var n of _s(t))gc.call(t,n)&&Bi(e,n,t[n]);return e},Oo=(e,t)=>oh(e,lh(t)),za=(e,t)=>$o(e,"name",{value:t,configurable:!0}),vc=(e,t)=>{var n={};for(var r in e)pc.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&&gc.call(e,r)&&(n[r]=e[r]);return n},Dn=e=>{var t;return[,,,ih((t=e?.[mc("metadata")])!=null?t:null)]},bc=["class","method","getter","setter","accessor","field","value","get","set"],Vn=e=>e!==void 0&&typeof e!="function"?In("Function expected"):e,ch=(e,t,n,r,s)=>({kind:bc[e],name:t,metadata:r,addInitializer:i=>n._?In("Already initialized"):s.push(Vn(i||null))}),Zt=(e,t)=>Bi(t,mc("metadata"),e[3]),le=(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,c,d=t&7,f=!!(t&8),p=!!(t&16),h=d>3?e.length+1:d?f?1:2:0,v=bc[d+5],y=d>3&&(e[h-1]=[]),w=e[h]||(e[h]=[]),g=d&&(!p&&!f&&(s=s.prototype),d<5&&(d>3||!p)&&ah(d<4?s:{get[n](){return Oe(this,i)},set[n](b){return Ze(this,i,b)}},n));d?p&&d<4&&za(i,(d>2?"set ":d>1?"get ":"")+n):za(s,n);for(var m=r.length-1;m>=0;m--)u=ch(d,n,l={},e[3],w),d&&(u.static=f,u.private=p,c=u.access={has:p?b=>dh(s,b):b=>n in b},d^3&&(c.get=p?b=>(d^1?Oe:yc)(b,s,d^4?i:g.get):b=>b[n]),d>2&&(c.set=p?(b,_)=>Ze(b,s,_,d^4?i:g.set):(b,_)=>b[n]=_)),a=(0,r[m])(d?d<4?p?i:g[v]:d>4?void 0:{get:g.get,set:g.set}:s,u),l._=1,d^4||a===void 0?Vn(a)&&(d>4?y.unshift(a):d?p?i=a:g[v]=a:s=a):typeof a!="object"||a===null?In("Object expected"):(Vn(o=a.get)&&(g.get=o),Vn(o=a.set)&&(g.set=o),Vn(o=a.init)&&y.unshift(o));return d||Zt(e,s),g&&$o(s,n,g),p?d^4?i:g:s},Eo=(e,t,n)=>t.has(e)||In("Cannot "+n),dh=(e,t)=>Object(t)!==t?In('Cannot use the "in" operator on this value'):e.has(t),Oe=(e,t,n)=>(Eo(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)=>(Eo(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),yc=(e,t,n)=>(Eo(e,t,"access private method"),n);function xc(e,t){return{plugin:e,options:t}}function Ir(e){return t=>xc(e,t)}function pr(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var wc,gr,Co,is;wc=[fe];var We=class{constructor(e,t){this.manager=e,this.options=t,ge(this,Co,le(gr,8,this,!1)),le(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 xc(this,e)}};gr=Dn(null);Co=new WeakMap;is=new WeakMap;he(gr,4,"disabled",wc,We,Co);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 uh(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,fh=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 c=t??u.collisionDetector;if(!c)continue;l.push(u),u.shape;const d=ue(()=>c({droppable:u,dragOperation:r}));d&&(u.collisionPriority!=null&&(d.priority=u.collisionPriority),a.push(d))}return l.length===0?Gr:(a.sort(uh),a)}get collisions(){return Oe(this,ln).value}};an=new WeakMap;ln=new WeakMap;var _c,kc,Sc,Io,$c,at,Do,pn,Ao,Po;Sc=[fe],kc=[fe],_c=[fe];var wt=class Nt{constructor(t,n){ge(this,Do,le(at,8,this)),le(at,11,this),ge(this,pn),ge(this,Ao,le(at,12,this)),le(at,15,this),ge(this,Po,le(at,16,this)),le(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:c,manager:d}=this;if(c!==l)return l=c,d?.registry.register(this),()=>d?.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 yc(i=Nt,Io,$c).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);Io=new WeakSet;$c=function(){const e=wt.pendingIdChanges;wt.pendingIdChanges=null,e&&Te(()=>{for(const[t,n]of e)Oe(t,pn).value=n})};Do=new WeakMap;pn=new WeakMap;Ao=new WeakMap;Po=new WeakMap;he(at,4,"manager",Sc,wt,Do);he(at,4,"data",kc,wt,Ao);he(at,4,"disabled",_c,wt,Po);ge(wt,Io);Zt(at,wt);wt.pendingIdChanges=null;var Gs=wt,Wa=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}},Tc,Oc,Ec,Cc,Ic,Dc,Gi,Ge,Mo,jo,Ro,ht=class extends(Gi=Gs,Dc=[fe],Ic=[fe],Cc=[fe],Ec=[Ee],Oc=[Ee],Tc=[Ee],Gi){constructor(t,n){var r=t,{modifiers:s,type:i,sensors:o,plugins:a,effects:l}=r,u=vc(r,["modifiers","type","sensors","plugins","effects"]);super(Oo(To({},u),{effects:()=>{var c;return[...(c=l?.())!=null?c:[],()=>{const{manager:d,plugins:f}=this;if(!(!d||!f))for(const p of f){const{plugin:h}=pr(p);d.registry.plugins.register(h)}}]}}),n),le(Ge,5,this),ge(this,Mo,le(Ge,8,this)),le(Ge,11,this),ge(this,jo,le(Ge,12,this)),le(Ge,15,this),ge(this,Ro,le(Ge,16,this,this.isDragSource?"dragging":"idle")),le(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);Mo=new WeakMap;jo=new WeakMap;Ro=new WeakMap;he(Ge,4,"type",Dc,ht,Mo);he(Ge,4,"modifiers",Ic,ht,jo);he(Ge,4,"status",Cc,ht,Ro);he(Ge,2,"isDropping",Ec,ht);he(Ge,2,"isDragging",Oc,ht);he(Ge,2,"isDragSource",Tc,ht);Zt(Ge,ht);var Ac,Pc,Mc,jc,Rc,Lc,qi,Pe,Lo,No,Fo,zo,Wo,pt=class extends(qi=Gs,Lc=[fe],Rc=[fe],jc=[fe],Mc=[fe],Pc=[fe],Ac=[Ee],qi){constructor(t,n){var r=t,{accept:s,collisionDetector:i,collisionPriority:o,type:a}=r,l=vc(r,["accept","collisionDetector","collisionPriority","type"]);super(l,n),le(Pe,5,this),ge(this,Lo,le(Pe,8,this)),le(Pe,11,this),ge(this,No,le(Pe,12,this)),le(Pe,15,this),ge(this,Fo,le(Pe,16,this)),le(Pe,19,this),ge(this,zo,le(Pe,20,this)),le(Pe,23,this),ge(this,Wo,le(Pe,24,this)),le(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);Lo=new WeakMap;No=new WeakMap;Fo=new WeakMap;zo=new WeakMap;Wo=new WeakMap;he(Pe,4,"accept",Lc,pt,Lo);he(Pe,4,"type",Rc,pt,No);he(Pe,4,"collisionDetector",jc,pt,Fo);he(Pe,4,"collisionPriority",Mc,pt,zo);he(Pe,4,"shape",Pc,pt,Wo);he(Pe,2,"isDropTarget",Ac,pt);Zt(Pe,pt);var hh=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)}},ph=class extends hh{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 Oo(To({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var gh=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||{}),Nc,Fc,zc,Wc,Bc,Gc,qc,rt,Bo;qc=[fe],Gc=[Ee],Bc=[Ee],Wc=[Ee],zc=[Ee],Fc=[Ee],Nc=[Ee];var kt=class{constructor(){le(rt,5,this),ge(this,Bo,le(rt,8,this,"idle")),le(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);Bo=new WeakMap;he(rt,4,"value",qc,kt,Bo);he(rt,2,"current",Gc,kt);he(rt,2,"idle",Bc,kt);he(rt,2,"initializing",Wc,kt);he(rt,2,"initialized",zc,kt);he(rt,2,"dragging",Fc,kt);he(rt,2,"dropped",Nc,kt);Zt(rt,kt);var mh=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,c,d;if(o.defaultPrevented)return;const f=(d=e.to)!=null?d:{x:r.position.current.x+((l=(a=e.by)==null?void 0:a.x)!=null?l:0),y:r.position.current.y+((c=(u=e.by)==null?void 0:u.y)!=null?c: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,c)=>{l.resume=u,l.abort=c}),l};s.abort();const a=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const l=ue(()=>{var c;return((c=r.source)==null?void 0:c.status)==="dropping"}),u=()=>{r.controller===s&&(r.controller=void 0),r.reset()};if(l){const{source:c}=r,d=st(()=>{c?.status==="idle"&&(d(),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}},vh=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,Kc=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 Ba=class extends We{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},bh=class{constructor(e){this.draggables=new Wa,this.droppables=new Wa,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 Ba)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 Ba)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()}},Uc,Vc,Hc,Xc,Yc,Zc,Qc,Jc,ed,Hn,cs,cn,$e,Go,qo,Ko,Uo,Vo,Xn;ed=[Ee],Jc=[fe],Qc=[fe],Zc=[fe],Yc=[fe],Xc=[fe],Hc=[Ee],Vc=[Ee],Uc=[Ee];var ct=class{constructor(e){le($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,Go,le($e,8,this,!1)),le($e,11,this),ge(this,qo,le($e,12,this,null)),le($e,15,this),ge(this,Ko,le($e,16,this,null)),le($e,19,this),ge(this,Uo,le($e,20,this,null)),le($e,23,this),ge(this,Vo,le($e,24,this,[])),le($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(Oo(To({},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;Go=new WeakMap;qo=new WeakMap;Ko=new WeakMap;Uo=new WeakMap;Vo=new WeakMap;Xn=new WeakMap;he($e,2,"shape",ed,ct);he($e,4,"canceled",Jc,ct,Go);he($e,4,"activatorEvent",Qc,ct,qo);he($e,4,"sourceIdentifier",Zc,ct,Ko);he($e,4,"targetIdentifier",Yc,ct,Uo);he($e,4,"modifiers",Xc,ct,Vo);he($e,2,"source",Hc,ct);he($e,2,"target",Vc,ct);he($e,2,"transform",Uc,ct);Zt($e,ct);var yh={get rendering(){return Promise.resolve()}};function lt(e,t){return typeof e=="function"?e(t):e??t}var xh=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:yh,l=new ph(this),u=new bh(this);this.registry=u,this.monitor=l,this.renderer=a,this.actions=new mh(this),this.dragOperation=new ct(this),this.collisionObserver=new fh(this),this.plugins=[gh,...s],this.modifiers=o,this.sensors=i;const{destroy:c}=this,d=Er(()=>{var f,p,h;const v=ue(()=>this.dragOperation.modifiers),y=this.modifiers;for(const w of v)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:g,options:m}=pr(w);return new g(this,m)}))!=null?h:y});this.destroy=()=>{d(),c()}}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}},td=e=>{throw TypeError(e)},Ho=(e,t,n)=>t.has(e)||td("Cannot "+n),ae=(e,t,n)=>(Ho(e,t,"read from private field"),t.get(e)),Ve=(e,t,n)=>t.has(e)?td("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ye=(e,t,n,r)=>(Ho(e,t,"write to private field"),t.set(e,n),n),nd=(e,t,n)=>(Ho(e,t,"access private method"),n);function qs(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function rd(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 Xo(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?Xo(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 Yo(e){const{Document:t}=Qe(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function Pt(e){return!e||Xo(e)?!1:e instanceof Qe(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function sd(e){return e instanceof Qe(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function Mn(e){return e?Xo(e)?e.document:Ar(e)?Yo(e)?e:Pt(e)||sd(e)?e.ownerDocument:document:document:document}function wh(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,c=(s=o?.offsetLeft)!=null?s:0;return{top:u,left:c,right:c+a,bottom:u+l,width:a,height:l}}function _h(e,t){if(kh(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:s}=getComputedStyle(e);return n==="visible"&&r==="visible"&&s==="visible"}function kh(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,c=(r=u.defaultView)!=null?r:window;let d=e.parentElement;for(;d&&d!==u.documentElement;){if(!_h(d)){const m=d.getBoundingClientRect(),b=n*(m.bottom-m.top),_=n*(m.right-m.left),O=n*(m.bottom-m.top),E=n*(m.right-m.left);l={top:Math.max(l.top,m.top-b),right:Math.min(l.right,m.right+_),bottom:Math.min(l.bottom,m.bottom+O),left:Math.max(l.left,m.left-E),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top}d=d.parentElement}const f=c.visualViewport,p=(s=f?.offsetTop)!=null?s:0,h=(i=f?.offsetLeft)!=null?i:0,v=(o=f?.width)!=null?o:c.innerWidth,y=(a=f?.height)!=null?a:c.innerHeight,w=n*y,g=n*v;return l={top:Math.max(l.top,p-w),right:Math.min(l.right,h+v+g),bottom:Math.min(l.bottom,p+y+w),left:Math.max(l.left,h-g),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 id=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 Zo(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function od(){var e,t;const n=Zo()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function Qo(e){return!e||!Ar(e)?!1:e instanceof Qe(e).ShadowRoot}function ks(e){if(e&&Ar(e)){let t=e.getRootNode();if(Qo(t))return t;if(t instanceof Document)return t}return Mn(e)}function Jo(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function Sh(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(Ga(i)&&Ga(a)&&(i.type!=="file"&&(i.value=a.value),i.type==="radio"&&i.name&&(i.name=`Cloned__${i.name}`)),qa(i)&&qa(a)&&a.width>0&&a.height>0){const l=i.getContext("2d");l?.drawImage(a,0,0)}}),n}function Ga(e){return"value"in e}function qa(e){return e.tagName==="CANVAS"}function ad(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 ad(s,{x:t-i,y:n-o})}}return r}function $h(e){return e?.tagName==="IFRAME"}var Ui=new WeakMap;function Th(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 $c=class{constructor(){this.entries=new Set,this.clear=()=>{for(const e of this.entries){const[t,{type:n,listener:r,options:i}]=e;t.removeEventListener(n,r,i)}this.entries.clear()}}bind(e,t){const n=Array.isArray(e)?e:[e],r=Array.isArray(t)?t:[t],i=[];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),i.push(c)}const s=this.entries;return function(){for(const a of i){const[l,{type:u,listener:d,options:c}]=a;l.removeEventListener(u,d,c),s.delete(a)}}}};function wn(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function cf(e){const t=new Set;let n=wn(e);for(;n;)t.add(n),n=wn(n);return t}function df(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function Ec(e,t){const n=()=>performance.now();let r,i;return function(...s){const o=this;i?(r?.(),r=df(()=>{e.apply(o,s),i=n()},t-(n()-i))):(e.apply(o,s),i=n())}}function uf(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 ff(e,t=e.getBoundingClientRect()){const{width:n,height:r}=mr(e,t);return n>0&&r>0}var hf=_c?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},ni,pf=class extends hf{constructor(e){super(t=>{if(!F(this,ni)){qe(this,ni,!0);return}e(t,this)}),Ne(this,ni,!1)}};ni=new WeakMap;var ya=Array.from({length:100},(e,t)=>t/100),Oc=75,Rt,gi,wt,Lt,Qn,De,dr,Zn,vi,Tc,Dc,Cc=class{constructor(e,t,n={debug:!1,skipInitial:!1}){this.element=e,this.callback=t,Ne(this,vi),this.disconnect=()=>{var s,o,a;qe(this,dr,!0),(s=F(this,wt))==null||s.disconnect(),(o=F(this,Lt))==null||o.disconnect(),F(this,Qn).disconnect(),(a=F(this,De))==null||a.remove()},Ne(this,Rt,!0),Ne(this,gi),Ne(this,wt),Ne(this,Lt),Ne(this,Qn),Ne(this,De),Ne(this,dr,!1),Ne(this,Zn,Ec(()=>{var s,o,a;const{element:l}=this;if((s=F(this,Lt))==null||s.disconnect(),F(this,dr)||!F(this,Rt)||!l.isConnected)return;const u=(o=l.ownerDocument)!=null?o:document,{innerHeight:d,innerWidth:c}=(a=u.defaultView)!=null?a:window,h=l.getBoundingClientRect(),f=mr(l,h),{top:v,left:p,bottom:w,right:x}=f,m=-Math.floor(v),g=-Math.floor(p),b=-Math.floor(c-x),_=-Math.floor(d-w),$=`${m}px ${b}px ${_}px ${g}px`;this.boundingClientRect=h,qe(this,Lt,new IntersectionObserver(O=>{const[C]=O,{intersectionRect:I}=C;(C.intersectionRatio!==1?C.intersectionRatio:dt.intersectionRatio(I,mr(l)))!==1&&F(this,Zn).call(this)},{threshold:ya,rootMargin:$,root:u})),F(this,Lt).observe(l),bc(this,vi,Tc).call(this)},Oc)),this.boundingClientRect=e.getBoundingClientRect(),qe(this,Rt,ff(e,this.boundingClientRect));let r=!0;this.callback=s=>{r&&(r=!1,n.skipInitial)||t(s)};const i=e.ownerDocument;n?.debug&&(qe(this,De,document.createElement("div")),F(this,De).style.background="rgba(0,0,0,0.15)",F(this,De).style.position="fixed",F(this,De).style.pointerEvents="none",i.body.appendChild(F(this,De))),qe(this,Qn,new IntersectionObserver(s=>{var o,a;const l=s[s.length-1],{boundingClientRect:u,isIntersecting:d}=l,{width:c,height:h}=u,f=F(this,Rt);qe(this,Rt,d),!(!c&&!h)&&(f&&!d?((o=F(this,Lt))==null||o.disconnect(),this.callback(null),(a=F(this,wt))==null||a.disconnect(),qe(this,wt,void 0),F(this,De)&&(F(this,De).style.visibility="hidden")):F(this,Zn).call(this),d&&!F(this,wt)&&(qe(this,wt,new pf(F(this,Zn))),F(this,wt).observe(e)))},{threshold:ya,root:i})),F(this,Rt)&&!n.skipInitial&&this.callback(this.boundingClientRect),F(this,Qn).observe(e)}};Rt=new WeakMap;gi=new WeakMap;wt=new WeakMap;Lt=new WeakMap;Qn=new WeakMap;De=new WeakMap;dr=new WeakMap;Zn=new WeakMap;vi=new WeakSet;Tc=function(){F(this,dr)||(bc(this,vi,Dc).call(this),!uf(this.boundingClientRect,F(this,gi))&&(this.callback(this.boundingClientRect),qe(this,gi,this.boundingClientRect)))};Dc=function(){if(F(this,De)){const{top:e,left:t,width:n,height:r}=mr(this.element);F(this,De).style.overflow="hidden",F(this,De).style.visibility="visible",F(this,De).style.top=`${Math.floor(e)}px`,F(this,De).style.left=`${Math.floor(t)}px`,F(this,De).style.width=`${Math.floor(n)}px`,F(this,De).style.height=`${Math.floor(r)}px`}};var zr=new WeakMap,Fr=new WeakMap;function gf(e,t){let n=zr.get(e);return n||(n={disconnect:new Cc(e,i=>{const s=zr.get(e);s&&s.callbacks.forEach(o=>o(i))},{skipInitial:!0}).disconnect,callbacks:new Set}),n.callbacks.add(t),zr.set(e,n),()=>{n.callbacks.delete(t),n.callbacks.size===0&&(zr.delete(e),n.disconnect())}}function vf(e,t){const n=new Set;for(const r of e){const i=gf(r,t);n.add(i)}return()=>n.forEach(r=>r())}function mf(e,t){var n;const r=e.ownerDocument;if(!Fr.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}),Fr.set(r,{disconnect:()=>o.abort(),listeners:a})}const{listeners:i,disconnect:s}=(n=Fr.get(r))!=null?n:{};return!i||!s?()=>{}:(i.add(t),()=>{i.delete(t),i.size===0&&(s(),Fr.delete(r))})}var Jn,er,ri,Ts,yf=class{constructor(e,t,n){this.callback=t,Ne(this,Jn),Ne(this,er,!1),Ne(this,ri),Ne(this,Ts,Ec(o=>{if(!F(this,er)&&o.target&&"contains"in o.target&&typeof o.target.contains=="function"){for(const a of F(this,ri))if(o.target.contains(a)){this.callback(F(this,Jn).boundingClientRect);break}}},Oc));const r=cf(e),i=vf(r,t),s=mf(e,F(this,Ts));qe(this,ri,r),qe(this,Jn,new Cc(e,t,n)),this.disconnect=()=>{F(this,er)||(qe(this,er,!0),i(),s(),F(this,Jn).disconnect())}}};Jn=new WeakMap;er=new WeakMap;ri=new WeakMap;Ts=new WeakMap;function Ds(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function vn(e){try{Ds(e)&&e.isConnected&&e.hasAttribute("popover")&&!e.matches(":popover-open")&&e.showPopover()}catch{}}function ba(e){return!_c||!e?!1:e===jn(e).scrollingElement}function Pc(e){var t,n;const r=Ke(e),i=ba(e)?nf(e):Ri(e),s=r.visualViewport,o=ba(e)?{height:(t=s?.height)!=null?t:r.innerHeight,width:(n=s?.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:i,position:a,isTop:l,isLeft:u,isBottom:d,isRight:c}}function bf(e,t){const{isTop:n,isBottom:r,isLeft:i,isRight:s,position:o}=Pc(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=!i&&o.current.x+a>0,h=!s&&o.current.x+a<o.max.x;return{top:u,bottom:d,left:c,right:h,x:c||h,y:u||d}}var Lo=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 i of n)i();for(const i of r)i()}}schedule(t){return this.tasks.add(t),this.pending||(this.pending=!0,this.scheduler(this.flush)),new Promise(n=>this.resolvers.add(n))}},mi=new Lo(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),xf=new Lo(e=>setTimeout(e,50)),yi=new Map,wf=yi.clear.bind(yi);function ht(e,t=!1){if(!t)return xa(e);let n=yi.get(e);return n||(n=xa(e),yi.set(e,n),xf.schedule(wf),n)}function xa(e){return Ke(e).getComputedStyle(e)}function _f(e,t=ht(e,!0)){return t.position==="fixed"||t.position==="sticky"}function kf(e,t=ht(e,!0)){const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const s=t[i];return typeof s=="string"?n.test(s):!1})}var Sf={excludeElement:!0,escapeShadowDOM:!0};function Cs(e,t=Sf){const{limit:n,excludeElement:r,escapeShadowDOM:i}=t,s=new Set;function o(a){if(n!=null&&s.size>=n||!a)return s;if(Io(a)&&a.scrollingElement!=null&&!s.has(a.scrollingElement))return s.add(a.scrollingElement),s;if(i&&Ao(a))return o(a.host);if(!Tt(a))return wc(a)?o(a.parentElement):s;if(s.has(a))return s;const l=ht(a,!0);if(r&&a===e||kf(a,l)&&s.add(a),_f(a,l)){const{scrollingElement:u}=a.ownerDocument;return u&&s.add(u),s}return o(a.parentNode)}return e?o(e):s}function _n(e,t=window.frameElement){const n={x:0,y:0,scaleX:1,scaleY:1};if(!e)return n;let r=wn(e);for(;r;){if(r===t)return n;const i=Ri(r),{x:s,y:o}=$f(r,i);n.x=n.x+i.left,n.y=n.y+i.top,n.scaleX=n.scaleX*s,n.scaleY=n.scaleY*o,r=wn(r)}return n}function $f(e,t=Ri(e)){const n=Math.round(t.width),r=Math.round(t.height);if(Tt(e))return{x:n/e.offsetWidth,y:r/e.offsetHeight};const i=ht(e,!0);return{x:(parseFloat(i.width)||n)/n,y:(parseFloat(i.height)||r)/r}}function Ef(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 yr(e){if(!e||e==="none")return null;const[t,n,r="0"]=e.split(" "),i={x:parseFloat(t),y:parseFloat(n),z:parseInt(r,10)};return isNaN(i.x)&&isNaN(i.y)?null:{x:isNaN(i.x)?0:i.x,y:isNaN(i.y)?0:i.y,z:isNaN(i.z)?0:i.z}}function Li(e){var t,n,r,i,s,o,a,l,u;const{scale:d,transform:c,translate:h}=e,f=Ef(d),v=yr(h),p=Of(c);if(!p&&!f&&!v)return null;const w={x:(t=f?.x)!=null?t:1,y:(n=f?.y)!=null?n:1},x={x:(r=v?.x)!=null?r:0,y:(i=v?.y)!=null?i:0},m={x:(s=p?.x)!=null?s:0,y:(o=p?.y)!=null?o:0,scaleX:(a=p?.scaleX)!=null?a:1,scaleY:(l=p?.scaleY)!=null?l:1};return{x:x.x+m.x,y:x.y+m.y,z:(u=v?.z)!=null?u:0,scaleX:w.x*m.scaleX,scaleY:w.y*m.scaleY}}function Of(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 Je=(e=>(e[e.Idle=0]="Idle",e[e.Forward=1]="Forward",e[e.Reverse=-1]="Reverse",e))(Je||{}),Tf={x:.2,y:.2},Df={x:10,y:10};function Cf(e,t,n,r=25,i=Tf,s=Df){const{x:o,y:a}=t,{rect:l,isTop:u,isBottom:d,isLeft:c,isRight:h}=Pc(e),f=_n(e),v=ht(e,!0),p=Li(v),w=p!==null?p?.scaleX<0:!1,x=p!==null?p?.scaleY<0:!1,m=new dt(l.left*f.scaleX+f.x,l.top*f.scaleY+f.y,l.width*f.scaleX,l.height*f.scaleY),g={x:0,y:0},b={x:0,y:0},_={height:m.height*i.y,width:m.width*i.x};return _.height>0&&(!u||x&&!d)&&a<=m.top+_.height&&n?.y!==1&&o>=m.left-s.x&&o<=m.right+s.x?(g.y=x?1:-1,b.y=r*Math.abs((m.top+_.height-a)/_.height)):_.height>0&&(!d||x&&!u)&&a>=m.bottom-_.height&&n?.y!==-1&&o>=m.left-s.x&&o<=m.right+s.x&&(g.y=x?-1:1,b.y=r*Math.abs((m.bottom-_.height-a)/_.height)),_.width>0&&(!h||w&&!c)&&o>=m.right-_.width&&n?.x!==-1&&a>=m.top-s.y&&a<=m.bottom+s.y?(g.x=w?-1:1,b.x=r*Math.abs((m.right-_.width-o)/_.width)):_.width>0&&(!c||w&&!h)&&o<=m.left+_.width&&n?.x!==1&&a>=m.top-s.y&&a<=m.bottom+s.y&&(g.x=w?1:-1,b.x=r*Math.abs((m.left+_.width-o)/_.width)),{direction:g,speed:b}}function Mc(e,{block:t="nearest",inline:n="nearest"}={}){if(!Tt(e))return;const r=Cs(e),i=[];for(const s of r){if(!Tt(s))continue;const{top:o,left:a}=Pf(e,s);let l=o,u=a;for(const d of i)l-=d.scrollTop,u-=d.scrollLeft;if(t!=="none"){const d=l<s.scrollTop,c=l+e.offsetHeight>s.scrollTop+s.clientHeight;d!==c&&(t==="center"?s.scrollTop=l-s.clientHeight/2+e.offsetHeight/2:d?s.scrollTop=l:s.scrollTop=l+e.offsetHeight-s.clientHeight)}if(n!=="none"){const d=u<s.scrollLeft,c=u+e.offsetWidth>s.scrollLeft+s.clientWidth;d!==c&&(n==="center"?s.scrollLeft=u-s.clientWidth/2+e.offsetWidth/2:d?s.scrollLeft=u:s.scrollLeft=u+e.offsetWidth-s.clientWidth)}i.push(s)}}function wa(e){let t=0,n=0,r=e;for(;r;){t+=r.offsetTop,n+=r.offsetLeft;const i=r.offsetParent;if(!Tt(i))break;t+=i.clientTop,n+=i.clientLeft,r=i}return{top:t,left:n}}function Pf(e,t){const n=wa(e),r=wa(t);return{top:n.top-r.top-t.clientTop,left:n.left-r.left-t.clientLeft}}function Mf(e,t,n){const{scaleX:r,scaleY:i,x:s,y:o}=t,a=e.left+s+(1-r)*parseFloat(n),l=e.top+o+(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),u=r?e.width*r:e.width,d=i?e.height*i:e.height;return{width:u,height:d,top:l,right:a+u,bottom:l+d,left:a}}function If(e,t,n){const{scaleX:r,scaleY:i,x:s,y:o}=t,a=e.left-s-(1-r)*parseFloat(n),l=e.top-o-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),u=r?e.width/r:e.width,d=i?e.height/i:e.height;return{width:u,height:d,top:l,right:a+u,bottom:l+d,left:a}}function Ic({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}function _a(e,t=ht(e).translate,n=!0){if(n){const r=xc(e,i=>"translate"in i);if(r){const{translate:i=""}=r[0];if(typeof i=="string"){const s=yr(i);if(s)return s}}}if(t){const r=yr(t);if(r)return r}return{x:0,y:0,z:0}}var jf=new Lo(e=>setTimeout(e,0)),ur=new Map,Af=ur.clear.bind(ur);function Rf(e){const t=e.ownerDocument;let n=ur.get(t);if(n)return n;n=t.getAnimations(),ur.set(t,n),jf.schedule(Af);const r=n.filter(i=>Ai(i.effect)&&i.effect.target===e);return ur.set(e,r),n}function Lf(e,t){const n=Rf(e).filter(r=>{var i,s;if(Ai(r.effect)){const{target:o}=r.effect;if((s=o&&((i=t.isValidTarget)==null?void 0:i.call(t,o)))!=null?s:!0)return r.effect.getKeyframes().some(l=>{for(const u of t.properties)if(l[u])return!0})}}).map(r=>{const{effect:i,currentTime:s}=r,o=i?.getComputedTiming().duration;if(!(r.pending||r.playState==="finished")&&typeof o=="number"&&typeof s=="number"&&s<o)return r.currentTime=o,()=>{r.currentTime=s}});if(n.length>0)return()=>n.forEach(r=>r?.())}var ct=class extends dt{constructor(e,t={}){var n,r,i,s;const{frameTransform:o=_n(e),ignoreTransforms:a,getBoundingClientRect:l=Ri}=t,u=Lf(e,{properties:["transform","translate","scale","width","height"],isValidTarget:_=>(_!==e||jo())&&_.contains(e)}),d=l(e);let{top:c,left:h,width:f,height:v}=d,p;const w=ht(e),x=Li(w),m={x:(n=x?.scaleX)!=null?n:1,y:(r=x?.scaleY)!=null?r:1},g=Wf(e,w);u?.(),x&&(p=If(d,x,w.transformOrigin),(a||g)&&(c=p.top,h=p.left,f=p.width,v=p.height));const b={width:(i=p?.width)!=null?i:f,height:(s=p?.height)!=null?s:v};if(g&&!a&&p){const _=Mf(p,g,w.transformOrigin);c=_.top,h=_.left,f=_.width,v=_.height,m.x=g.scaleX,m.y=g.scaleY}o&&(a||(h*=o.scaleX,f*=o.scaleX,c*=o.scaleY,v*=o.scaleY),h+=o.x,c+=o.y),super(h,c,f,v),this.scale=m,this.intrinsicWidth=b.width,this.intrinsicHeight=b.height}};function Wf(e,t){const n=e.getAnimations();if(!n.length)return null;let r,i,s,o=!1;for(const a of n){if(a.playState!=="running")continue;const l=Ai(a.effect)?a.effect.getKeyframes():[],u=l[l.length-1];if(!u)continue;const{transform:d,translate:c,scale:h}=u;typeof d=="string"&&d&&(r=d,o=!0),typeof c=="string"&&c&&(i=c,o=!0),typeof h=="string"&&h&&(s=h,o=!0)}return o?Li({transform:r??t.transform,translate:i??t.translate,scale:s??t.scale}):null}function fr(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 zf=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=""){const{element:n}=this;if(fr(n))for(const[r,i]of Object.entries(e)){const s=`${t}${r}`;this.initial.has(s)||this.initial.set(s,n.style.getPropertyValue(s)),n.style.setProperty(s,typeof i=="string"?i:`${i}px`)}}remove(e,t=""){const{element:n}=this;if(fr(n))for(const r of e){const i=`${t}${r}`;n.style.removeProperty(i)}}reset(){const{element:e}=this;if(fr(e)){for(const[t,n]of this.initial)e.style.setProperty(t,n);e.getAttribute("style")===""&&e.removeAttribute("style")}}};function Vt(e){return e?e instanceof Ke(e).Element||Dr(e)&&e.nodeType===Node.ELEMENT_NODE:!1}function br(e){if(!e)return!1;const{KeyboardEvent:t}=Ke(e.target);return e instanceof t}function Ff(e){if(!e)return!1;const{PointerEvent:t}=Ke(e.target);return e instanceof t}function Nf(e){if(!Vt(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||Bf(e)}function Bf(e){return e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"}var Ji={};function Ps(e){const t=Ji[e]==null?0:Ji[e]+1;return Ji[e]=t,`${e}-${t}`}var Wo=({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 i=Ze.distance(t.shape.center,n);return{id:r,value:1/i,type:In.PointerIntersection,priority:Mn.High}}return null},Vf=({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:i}=e,s=Ze.distance(t.shape.center,i.current),a=r/(n.current.area+t.shape.area-r)/s;return{id:t.id,value:a,type:In.ShapeIntersection,priority:Mn.Normal}}return null},jc=e=>{var t;return(t=Wo(e))!=null?t:Vf(e)},Gf=e=>{const{dragOperation:t,droppable:n}=e,{shape:r,position:i}=t;if(!n.shape)return null;const s=r?dt.from(r.current.boundingRectangle).corners:void 0,a=dt.from(n.shape.boundingRectangle).corners.reduce((l,u,d)=>{var c;return l+Ze.distance(Ze.from(u),(c=s?.[d])!=null?c:i.current)},0)/4;return{id:n.id,value:1/a,type:In.Collision,priority:Mn.Normal}},Uf=Object.create,zo=Object.defineProperty,qf=Object.defineProperties,Hf=Object.getOwnPropertyDescriptor,Kf=Object.getOwnPropertyDescriptors,bi=Object.getOwnPropertySymbols,Ac=Object.prototype.hasOwnProperty,Rc=Object.prototype.propertyIsEnumerable,Lc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),An=e=>{throw TypeError(e)},Ms=(e,t,n)=>t in e?zo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xr=(e,t)=>{for(var n in t||(t={}))Ac.call(t,n)&&Ms(e,n,t[n]);if(bi)for(var n of bi(t))Rc.call(t,n)&&Ms(e,n,t[n]);return e},Fo=(e,t)=>qf(e,Kf(t)),ka=(e,t)=>zo(e,"name",{value:t,configurable:!0}),Wc=(e,t)=>{var n={};for(var r in e)Ac.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&bi)for(var r of bi(e))t.indexOf(r)<0&&Rc.call(e,r)&&(n[r]=e[r]);return n},Rn=e=>{var t;return[,,,Uf((t=e?.[Lc("metadata")])!=null?t:null)]},zc=["class","method","getter","setter","accessor","field","value","get","set"],tr=e=>e!==void 0&&typeof e!="function"?An("Function expected"):e,Yf=(e,t,n,r,i)=>({kind:zc[e],name:t,metadata:r,addInitializer:s=>n._?An("Already initialized"):i.push(tr(s||null))}),Xt=(e,t)=>Ms(t,Lc("metadata"),e[3]),we=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)t&1?s[i].call(n):r=s[i].call(n,r);return r},nt=(e,t,n,r,i,s)=>{var o,a,l,u,d,c=t&7,h=!!(t&8),f=!!(t&16),v=c>3?e.length+1:c?h?1:2:0,p=zc[c+5],w=c>3&&(e[v-1]=[]),x=e[v]||(e[v]=[]),m=c&&(!f&&!h&&(i=i.prototype),c<5&&(c>3||!f)&&Hf(c<4?i:{get[n](){return re(this,s)},set[n](b){return Ae(this,s,b)}},n));c?f&&c<4&&ka(s,(c>2?"set ":c>1?"get ":"")+n):ka(i,n);for(var g=r.length-1;g>=0;g--)u=Yf(c,n,l={},e[3],x),c&&(u.static=h,u.private=f,d=u.access={has:f?b=>Xf(i,b):b=>n in b},c^3&&(d.get=f?b=>(c^1?re:Gt)(b,i,c^4?s:m.get):b=>b[n]),c>2&&(d.set=f?(b,_)=>Ae(b,i,_,c^4?s:m.set):(b,_)=>b[n]=_)),a=(0,r[g])(c?c<4?f?s:m[p]:c>4?void 0:{get:m.get,set:m.set}:i,u),l._=1,c^4||a===void 0?tr(a)&&(c>4?w.unshift(a):c?f?s=a:m[p]=a:i=a):typeof a!="object"||a===null?An("Object expected"):(tr(o=a.get)&&(m.get=o),tr(o=a.set)&&(m.set=o),tr(o=a.init)&&w.unshift(o));return c||Xt(e,i),m&&zo(i,n,m),f?c^4?s:m:i},No=(e,t,n)=>t.has(e)||An("Cannot "+n),Xf=(e,t)=>Object(t)!==t?An('Cannot use the "in" operator on this value'):e.has(t),re=(e,t,n)=>(No(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),Ae=(e,t,n,r)=>(No(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Gt=(e,t,n)=>(No(e,t,"access private method"),n),Sa={role:"button",roleDescription:"draggable"},Qf="dnd-kit-description",Zf="dnd-kit-announcement",Jf={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."},eh={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 th(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function nh(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function rh(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 ih=["dragover","dragmove"],sh=class extends Me{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=Qf,announcement:i=Zf}={},announcements:s=eh,screenReaderInstructions:o=Jf,debounce:a=500}=t??{},l=n?`${r}-${n}`:Ps(r),u=n?`${i}-${n}`:Ps(i);let d,c,h,f;const v=(_=f)=>{!h||!_||h?.nodeValue!==_&&(h.nodeValue=_)},p=()=>mi.schedule(v),w=oh(p,a),x=Object.entries(s).map(([_,$])=>this.manager.monitor.addEventListener(_,(O,C)=>{const I=h;if(!I)return;const P=$?.(O,C);P&&I.nodeValue!==P&&(f=P,ih.includes(_)?w():(p(),w.cancel()))})),m=()=>{let _=[];d?.isConnected||(d=nh(l,o.draggable),_.push(d)),c?.isConnected||(c=rh(u),h=document.createTextNode(""),c.appendChild(h),_.push(c)),_.length>0&&document.body.append(..._)},g=new Set;function b(){for(const _ of g)_()}this.registerEffect(()=>{var _;g.clear();for(const $ of this.manager.registry.draggables.value){const O=(_=$.handle)!=null?_:$.element;if(O){(!d||!c)&&g.add(m),(!th(O)||jo())&&!O.hasAttribute("tabindex")&&g.add(()=>O.setAttribute("tabindex","0")),!O.hasAttribute("role")&&O.tagName.toLowerCase()!=="button"&&g.add(()=>O.setAttribute("role",Sa.role)),O.hasAttribute("aria-roledescription")||g.add(()=>O.setAttribute("aria-roledescription",Sa.roleDescription)),O.hasAttribute("aria-describedby")||g.add(()=>O.setAttribute("aria-describedby",l));for(const I of["aria-pressed","aria-grabbed"]){const P=String($.isDragging);O.getAttribute(I)!==P&&g.add(()=>O.setAttribute(I,P))}const C=String($.disabled);O.getAttribute("aria-disabled")!==C&&g.add(()=>O.setAttribute("aria-disabled",C))}}g.size>0&&mi.schedule(b)}),this.destroy=()=>{super.destroy(),d?.remove(),c?.remove(),x.forEach(_=>_())}}};function oh(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var xi=new Map,Fc,Nc,Bc,Vc,Is,hr,mt,Bo,kn,Gc,Uc,qc,Hc,Dt=class extends(Is=Tr,Vc=[K],Bc=[ge],Nc=[ge],Fc=[ge],Is){constructor(t,n){super(t,n),we(mt,5,this),ve(this,kn),ve(this,hr,new Set),ve(this,Bo,we(mt,8,this,new Set)),we(mt,11,this),this.registerEffect(Gt(this,kn,Gc))}register(t){return re(this,hr).add(t),()=>{re(this,hr).delete(t)}}addRoot(t){return H(()=>{const n=new Set(this.additionalRoots);n.add(t),this.additionalRoots=n}),()=>{H(()=>{const n=new Set(this.additionalRoots);n.delete(t),this.additionalRoots=n})}}get sourceRoot(){var t;const{source:n}=this.manager.dragOperation;return pi((t=n?.element)!=null?t:null)}get targetRoot(){var t;const{target:n}=this.manager.dragOperation;return pi((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}};mt=Rn(Is);hr=new WeakMap;Bo=new WeakMap;kn=new WeakSet;Gc=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of re(this,hr))t.push(Gt(this,kn,Uc).call(this,n,r));return()=>{for(const n of t)n()}};Uc=function(e,t){let n=xi.get(e);n||(n=new Map,xi.set(e,n));let r=n.get(t);if(!r){const s=Io(e)?Gt(this,kn,qc).call(this,e,n,t):Gt(this,kn,Hc).call(this,e,n,t);if(!s)return()=>{};r=s,n.set(t,r)}r.refCount++;let i=!1;return()=>{i||(i=!0,r.refCount--,r.refCount===0&&r.cleanup())}};qc=function(e,t,n){var r;const i=e.createElement("style"),{nonce:s}=(r=this.options)!=null?r:{};s&&i.setAttribute("nonce",s),i.textContent=n,e.head.prepend(i);const o=new MutationObserver(a=>{for(const l of a)for(const u of Array.from(l.removedNodes))if(u===i){e.head.prepend(i);return}});return o.observe(e.head,{childList:!0}),{refCount:0,cleanup:()=>{o.disconnect(),i.remove(),t.delete(n),t.size===0&&xi.delete(e)}}};Hc=function(e,t,n){"adoptedStyleSheets"in e&&Array.isArray(e.adoptedStyleSheets);const r=e.ownerDocument.defaultView,{CSSStyleSheet:i}=r??{};if(!i)return null;const s=new i;return s.replaceSync(n),e.adoptedStyleSheets.push(s),{refCount:0,cleanup:()=>{var o;if(Ao(e)&&((o=e.host)!=null&&o.isConnected)){const a=e.adoptedStyleSheets.indexOf(s);a!==-1&&e.adoptedStyleSheets.splice(a,1)}t.delete(n),t.size===0&&xi.delete(e)}}};nt(mt,4,"additionalRoots",Vc,Dt,Bo);nt(mt,2,"sourceRoot",Bc,Dt);nt(mt,2,"targetRoot",Nc,Dt);nt(mt,2,"roots",Fc,Dt);Xt(mt,Dt);Dt.configure=Or(Dt);var Wi=Dt,ah=class extends Me{constructor(e,t){super(e,t),this.manager=e;const{cursor:n="grabbing"}=t??{},r=e.registry.plugins.get(Wi),i=r?.register(`* { cursor: ${n} !important; }`);if(i){const s=this.destroy.bind(this);this.destroy=()=>{i(),s()}}}},Cr="data-dnd-",js=`${Cr}dropping`,Te="--dnd-",lt=`${Cr}dragging`,wi=`${Cr}placeholder`,lh=[lt,wi,"popover","aria-pressed","aria-grabbing"],ch=["view-transition-name"],dh=`
|
|
9
|
-
:is(:root,:host) [${
|
|
8
|
+
`)}var ld=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:c}=a,d=[o,a];o.addEventListener(l,u,c),this.entries.add(d),s.push(d)}const i=this.entries;return function(){for(const a of s){const[l,{type:u,listener:c,options:d}]=a;l.removeEventListener(u,c,d),i.delete(a)}}}};function _n(e){const t=e?.ownerDocument.defaultView;if(t&&t.self!==t.parent)return t.frameElement}function Oh(e){const t=new Set;let n=_n(e);for(;n;)t.add(n),n=_n(n);return t}function Eh(e,t){const n=setTimeout(e,t);return()=>clearTimeout(n)}function cd(e,t){const n=()=>performance.now();let r,s;return function(...i){const o=this;s?(r?.(),r=Eh(()=>{e.apply(o,i),s=n()},t-(n()-s))):(e.apply(o,i),s=n())}}function Ch(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 Ih(e,t=e.getBoundingClientRect()){const{width:n,height:r}=mr(e,t);return n>0&&r>0}var Dh=id?ResizeObserver:class{observe(){}unobserve(){}disconnect(){}},ds,Ah=class extends Dh{constructor(e){super(t=>{if(!ae(this,ds)){Ye(this,ds,!0);return}e(t,this)}),Ve(this,ds,!1)}};ds=new WeakMap;var Ka=Array.from({length:100},(e,t)=>t/100),dd=75,Ft,Ss,$t,zt,Yn,Ne,cr,Zn,$s,ud,fd,hd=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=ae(this,$t))==null||i.disconnect(),(o=ae(this,zt))==null||o.disconnect(),ae(this,Yn).disconnect(),(a=ae(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,cd(()=>{var i,o,a;const{element:l}=this;if((i=ae(this,zt))==null||i.disconnect(),ae(this,cr)||!ae(this,Ft)||!l.isConnected)return;const u=(o=l.ownerDocument)!=null?o:document,{innerHeight:c,innerWidth:d}=(a=u.defaultView)!=null?a:window,f=l.getBoundingClientRect(),p=mr(l,f),{top:h,left:v,bottom:y,right:w}=p,g=-Math.floor(h),m=-Math.floor(v),b=-Math.floor(d-w),_=-Math.floor(c-y),O=`${g}px ${b}px ${_}px ${m}px`;this.boundingClientRect=f,Ye(this,zt,new IntersectionObserver(E=>{const[I]=E,{intersectionRect:T}=I;(I.intersectionRatio!==1?I.intersectionRatio:ft.intersectionRatio(T,mr(l)))!==1&&ae(this,Zn).call(this)},{threshold:Ka,rootMargin:O,root:u})),ae(this,zt).observe(l),nd(this,$s,ud).call(this)},dd)),this.boundingClientRect=e.getBoundingClientRect(),Ye(this,Ft,Ih(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")),ae(this,Ne).style.background="rgba(0,0,0,0.15)",ae(this,Ne).style.position="fixed",ae(this,Ne).style.pointerEvents="none",s.body.appendChild(ae(this,Ne))),Ye(this,Yn,new IntersectionObserver(i=>{var o,a;const l=i[i.length-1],{boundingClientRect:u,isIntersecting:c}=l,{width:d,height:f}=u,p=ae(this,Ft);Ye(this,Ft,c),!(!d&&!f)&&(p&&!c?((o=ae(this,zt))==null||o.disconnect(),this.callback(null),(a=ae(this,$t))==null||a.disconnect(),Ye(this,$t,void 0),ae(this,Ne)&&(ae(this,Ne).style.visibility="hidden")):ae(this,Zn).call(this),c&&!ae(this,$t)&&(Ye(this,$t,new Ah(ae(this,Zn))),ae(this,$t).observe(e)))},{threshold:Ka,root:s})),ae(this,Ft)&&!n.skipInitial&&this.callback(this.boundingClientRect),ae(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;ud=function(){ae(this,cr)||(nd(this,$s,fd).call(this),!Ch(this.boundingClientRect,ae(this,Ss))&&(this.callback(this.boundingClientRect),Ye(this,Ss,this.boundingClientRect)))};fd=function(){if(ae(this,Ne)){const{top:e,left:t,width:n,height:r}=mr(this.element);ae(this,Ne).style.overflow="hidden",ae(this,Ne).style.visibility="visible",ae(this,Ne).style.top=`${Math.floor(e)}px`,ae(this,Ne).style.left=`${Math.floor(t)}px`,ae(this,Ne).style.width=`${Math.floor(n)}px`,ae(this,Ne).style.height=`${Math.floor(r)}px`}};var qr=new WeakMap,Kr=new WeakMap;function Ph(e,t){let n=qr.get(e);return n||(n={disconnect:new hd(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 Mh(e,t){const n=new Set;for(const r of e){const s=Ph(r,t);n.add(s)}return()=>n.forEach(r=>r())}function jh(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,Rh=class{constructor(e,t,n){this.callback=t,Ve(this,Qn),Ve(this,Jn,!1),Ve(this,us),Ve(this,Vi,cd(o=>{if(!ae(this,Jn)&&o.target&&"contains"in o.target&&typeof o.target.contains=="function"){for(const a of ae(this,us))if(o.target.contains(a)){this.callback(ae(this,Qn).boundingClientRect);break}}},dd));const r=Oh(e),s=Mh(r,t),i=jh(e,ae(this,Vi));Ye(this,us,r),Ye(this,Qn,new hd(e,t,n)),this.disconnect=()=>{ae(this,Jn)||(Ye(this,Jn,!0),s(),i(),ae(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 Ua(e){return!id||!e?!1:e===Mn(e).scrollingElement}function pd(e){var t,n;const r=Qe(e),s=Ua(e)?wh(e):Ks(e),i=r.visualViewport,o=Ua(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,c=a.current.y>=a.max.y,d=a.current.x>=a.max.x;return{rect:s,position:a,isTop:l,isLeft:u,isBottom:c,isRight:d}}function Lh(e,t){const{isTop:n,isBottom:r,isLeft:s,isRight:i,position:o}=pd(e),{x:a,y:l}=t??{x:0,y:0},u=!n&&o.current.y+l>0,c=!r&&o.current.y+l<o.max.y,d=!s&&o.current.x+a>0,f=!i&&o.current.x+a<o.max.x;return{top:u,bottom:c,left:d,right:f,x:d||f,y:u||c}}var ea=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 ea(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),Nh=new ea(e=>setTimeout(e,50)),Os=new Map,Fh=Os.clear.bind(Os);function gt(e,t=!1){if(!t)return Va(e);let n=Os.get(e);return n||(n=Va(e),Os.set(e,n),Nh.schedule(Fh),n)}function Va(e){return Qe(e).getComputedStyle(e)}function zh(e,t=gt(e,!0)){return t.position==="fixed"||t.position==="sticky"}function Wh(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 Bh={excludeElement:!0,escapeShadowDOM:!0};function Xi(e,t=Bh){const{limit:n,excludeElement:r,escapeShadowDOM:s}=t,i=new Set;function o(a){if(n!=null&&i.size>=n||!a)return i;if(Yo(a)&&a.scrollingElement!=null&&!i.has(a.scrollingElement))return i.add(a.scrollingElement),i;if(s&&Qo(a))return o(a.host);if(!Pt(a))return sd(a)?o(a.parentElement):i;if(i.has(a))return i;const l=gt(a,!0);if(r&&a===e||Wh(a,l)&&i.add(a),zh(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}=Gh(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 Gh(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 qh(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:c,transform:d,translate:f}=e,p=qh(c),h=vr(f),v=Kh(d);if(!v&&!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},g={x:(i=v?.x)!=null?i:0,y:(o=v?.y)!=null?o:0,scaleX:(a=v?.scaleX)!=null?a:1,scaleY:(l=v?.scaleY)!=null?l:1};return{x:w.x+g.x,y:w.y+g.y,z:(u=h?.z)!=null?u:0,scaleX:y.x*g.scaleX,scaleY:y.y*g.scaleY}}function Kh(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||{}),Uh={x:.2,y:.2},Vh={x:10,y:10};function Hh(e,t,n,r=25,s=Uh,i=Vh){const{x:o,y:a}=t,{rect:l,isTop:u,isBottom:c,isLeft:d,isRight:f}=pd(e),p=kn(e),h=gt(e,!0),v=Us(h),y=v!==null?v?.scaleX<0:!1,w=v!==null?v?.scaleY<0:!1,g=new ft(l.left*p.scaleX+p.x,l.top*p.scaleY+p.y,l.width*p.scaleX,l.height*p.scaleY),m={x:0,y:0},b={x:0,y:0},_={height:g.height*s.y,width:g.width*s.x};return _.height>0&&(!u||w&&!c)&&a<=g.top+_.height&&n?.y!==1&&o>=g.left-i.x&&o<=g.right+i.x?(m.y=w?1:-1,b.y=r*Math.abs((g.top+_.height-a)/_.height)):_.height>0&&(!c||w&&!u)&&a>=g.bottom-_.height&&n?.y!==-1&&o>=g.left-i.x&&o<=g.right+i.x&&(m.y=w?-1:1,b.y=r*Math.abs((g.bottom-_.height-a)/_.height)),_.width>0&&(!f||y&&!d)&&o>=g.right-_.width&&n?.x!==-1&&a>=g.top-i.y&&a<=g.bottom+i.y?(m.x=y?-1:1,b.x=r*Math.abs((g.right-_.width-o)/_.width)):_.width>0&&(!d||y&&!f)&&o<=g.left+_.width&&n?.x!==1&&a>=g.top-i.y&&a<=g.bottom+i.y&&(m.x=y?1:-1,b.x=r*Math.abs((g.left+_.width-o)/_.width)),{direction:m,speed:b}}function gd(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}=Xh(e,i);let l=o,u=a;for(const c of s)l-=c.scrollTop,u-=c.scrollLeft;if(t!=="none"){const c=l<i.scrollTop,d=l+e.offsetHeight>i.scrollTop+i.clientHeight;c!==d&&(t==="center"?i.scrollTop=l-i.clientHeight/2+e.offsetHeight/2:c?i.scrollTop=l:i.scrollTop=l+e.offsetHeight-i.clientHeight)}if(n!=="none"){const c=u<i.scrollLeft,d=u+e.offsetWidth>i.scrollLeft+i.clientWidth;c!==d&&(n==="center"?i.scrollLeft=u-i.clientWidth/2+e.offsetWidth/2:c?i.scrollLeft=u:i.scrollLeft=u+e.offsetWidth-i.clientWidth)}s.push(i)}}function Ha(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 Xh(e,t){const n=Ha(e),r=Ha(t);return{top:n.top-r.top-t.clientTop,left:n.left-r.left-t.clientLeft}}function Yh(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,c=s?e.height*s:e.height;return{width:u,height:c,top:l,right:a+u,bottom:l+c,left:a}}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,c=s?e.height/s:e.height;return{width:u,height:c,top:l,right:a+u,bottom:l+c,left:a}}function md({element:e,keyframes:t,options:n}){return e.animate(t,n).finished}function Xa(e,t=gt(e).translate,n=!0){if(n){const r=rd(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 Qh=new ea(e=>setTimeout(e,0)),dr=new Map,Jh=dr.clear.bind(dr);function ep(e){const t=e.ownerDocument;let n=dr.get(t);if(n)return n;n=t.getAnimations(),dr.set(t,n),Qh.schedule(Jh);const r=n.filter(s=>qs(s.effect)&&s.effect.target===e);return dr.set(e,r),n}function tp(e,t){const n=ep(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=tp(e,{properties:["transform","translate","scale","width","height"],isValidTarget:_=>(_!==e||Zo())&&_.contains(e)}),c=l(e);let{top:d,left:f,width:p,height:h}=c,v;const y=gt(e),w=Us(y),g={x:(n=w?.scaleX)!=null?n:1,y:(r=w?.scaleY)!=null?r:1},m=np(e,y);u?.(),w&&(v=Zh(c,w,y.transformOrigin),(a||m)&&(d=v.top,f=v.left,p=v.width,h=v.height));const b={width:(s=v?.width)!=null?s:p,height:(i=v?.height)!=null?i:h};if(m&&!a&&v){const _=Yh(v,m,y.transformOrigin);d=_.top,f=_.left,p=_.width,h=_.height,g.x=m.scaleX,g.y=m.scaleY}o&&(a||(f*=o.scaleX,p*=o.scaleX,d*=o.scaleY,h*=o.scaleY),f+=o.x,d+=o.y),super(f,d,p,h),this.scale=g,this.intrinsicWidth=b.width,this.intrinsicHeight=b.height}};function np(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:c,translate:d,scale:f}=u;typeof c=="string"&&c&&(r=c,o=!0),typeof d=="string"&&d&&(s=d,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 rp=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 sp(e){if(!e)return!1;const{PointerEvent:t}=Qe(e.target);return e instanceof t}function ip(e){if(!Ut(e))return!1;const{tagName:t}=e;return t==="INPUT"||t==="TEXTAREA"||op(e)}function op(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 ta=({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},ap=({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},vd=e=>{var t;return(t=ta(e))!=null?t:ap(e)},lp=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,c)=>{var d;return l+et.distance(et.from(u),(d=i?.[c])!=null?d:s.current)},0)/4;return{id:n.id,value:1/a,type:Pn.Collision,priority:An.Normal}},cp=Object.create,na=Object.defineProperty,dp=Object.defineProperties,up=Object.getOwnPropertyDescriptor,fp=Object.getOwnPropertyDescriptors,Es=Object.getOwnPropertySymbols,bd=Object.prototype.hasOwnProperty,yd=Object.prototype.propertyIsEnumerable,xd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),jn=e=>{throw TypeError(e)},Zi=(e,t,n)=>t in e?na(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yr=(e,t)=>{for(var n in t||(t={}))bd.call(t,n)&&Zi(e,n,t[n]);if(Es)for(var n of Es(t))yd.call(t,n)&&Zi(e,n,t[n]);return e},ra=(e,t)=>dp(e,fp(t)),Ya=(e,t)=>na(e,"name",{value:t,configurable:!0}),wd=(e,t)=>{var n={};for(var r in e)bd.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&&yd.call(e,r)&&(n[r]=e[r]);return n},Rn=e=>{var t;return[,,,cp((t=e?.[xd("metadata")])!=null?t:null)]},_d=["class","method","getter","setter","accessor","field","value","get","set"],er=e=>e!==void 0&&typeof e!="function"?jn("Function expected"):e,hp=(e,t,n,r,s)=>({kind:_d[e],name:t,metadata:r,addInitializer:i=>n._?jn("Already initialized"):s.push(er(i||null))}),Qt=(e,t)=>Zi(t,xd("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,c,d=t&7,f=!!(t&8),p=!!(t&16),h=d>3?e.length+1:d?f?1:2:0,v=_d[d+5],y=d>3&&(e[h-1]=[]),w=e[h]||(e[h]=[]),g=d&&(!p&&!f&&(s=s.prototype),d<5&&(d>3||!p)&&up(d<4?s:{get[n](){return ye(this,i)},set[n](b){return qe(this,i,b)}},n));d?p&&d<4&&Ya(i,(d>2?"set ":d>1?"get ":"")+n):Ya(s,n);for(var m=r.length-1;m>=0;m--)u=hp(d,n,l={},e[3],w),d&&(u.static=f,u.private=p,c=u.access={has:p?b=>pp(s,b):b=>n in b},d^3&&(c.get=p?b=>(d^1?ye:Vt)(b,s,d^4?i:g.get):b=>b[n]),d>2&&(c.set=p?(b,_)=>qe(b,s,_,d^4?i:g.set):(b,_)=>b[n]=_)),a=(0,r[m])(d?d<4?p?i:g[v]:d>4?void 0:{get:g.get,set:g.set}:s,u),l._=1,d^4||a===void 0?er(a)&&(d>4?y.unshift(a):d?p?i=a:g[v]=a:s=a):typeof a!="object"||a===null?jn("Object expected"):(er(o=a.get)&&(g.get=o),er(o=a.set)&&(g.set=o),er(o=a.init)&&y.unshift(o));return d||Qt(e,s),g&&na(s,n,g),p?d^4?i:g:s},sa=(e,t,n)=>t.has(e)||jn("Cannot "+n),pp=(e,t)=>Object(t)!==t?jn('Cannot use the "in" operator on this value'):e.has(t),ye=(e,t,n)=>(sa(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)=>(sa(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Vt=(e,t,n)=>(sa(e,t,"access private method"),n),Za={role:"button",roleDescription:"draggable"},gp="dnd-kit-description",mp="dnd-kit-announcement",vp={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."},bp={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 yp(e){const t=e.tagName.toLowerCase();return["input","select","textarea","a","button"].includes(t)}function xp(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.textContent=t,n}function wp(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 _p=["dragover","dragmove"],kp=class extends We{constructor(e,t){super(e);const{id:n,idPrefix:{description:r=gp,announcement:s=mp}={},announcements:i=bp,screenReaderInstructions:o=vp,debounce:a=500}=t??{},l=n?`${r}-${n}`:Yi(r),u=n?`${s}-${n}`:Yi(s);let c,d,f,p;const h=(_=p)=>{!f||!_||f?.nodeValue!==_&&(f.nodeValue=_)},v=()=>Ts.schedule(h),y=Sp(v,a),w=Object.entries(i).map(([_,O])=>this.manager.monitor.addEventListener(_,(E,I)=>{const T=f;if(!T)return;const D=O?.(E,I);D&&T.nodeValue!==D&&(p=D,_p.includes(_)?y():(v(),y.cancel()))})),g=()=>{let _=[];c?.isConnected||(c=xp(l,o.draggable),_.push(c)),d?.isConnected||(d=wp(u),f=document.createTextNode(""),d.appendChild(f),_.push(d)),_.length>0&&document.body.append(..._)},m=new Set;function b(){for(const _ of m)_()}this.registerEffect(()=>{var _;m.clear();for(const O of this.manager.registry.draggables.value){const E=(_=O.handle)!=null?_:O.element;if(E){(!c||!d)&&m.add(g),(!yp(E)||Zo())&&!E.hasAttribute("tabindex")&&m.add(()=>E.setAttribute("tabindex","0")),!E.hasAttribute("role")&&E.tagName.toLowerCase()!=="button"&&m.add(()=>E.setAttribute("role",Za.role)),E.hasAttribute("aria-roledescription")||m.add(()=>E.setAttribute("aria-roledescription",Za.roleDescription)),E.hasAttribute("aria-describedby")||m.add(()=>E.setAttribute("aria-describedby",l));for(const T of["aria-pressed","aria-grabbed"]){const D=String(O.isDragging);E.getAttribute(T)!==D&&m.add(()=>E.setAttribute(T,D))}const I=String(O.disabled);E.getAttribute("aria-disabled")!==I&&m.add(()=>E.setAttribute("aria-disabled",I))}}m.size>0&&Ts.schedule(b)}),this.destroy=()=>{super.destroy(),c?.remove(),d?.remove(),w.forEach(_=>_())}}};function Sp(e,t){let n;const r=()=>{clearTimeout(n),n=setTimeout(e,t)};return r.cancel=()=>clearTimeout(n),r}var Cs=new Map,kd,Sd,$d,Td,Qi,fr,xt,ia,Sn,Od,Ed,Cd,Id,Mt=class extends(Qi=Dr,Td=[fe],$d=[Ee],Sd=[Ee],kd=[Ee],Qi){constructor(t,n){super(t,n),Me(xt,5,this),Ce(this,Sn),Ce(this,fr,new Set),Ce(this,ia,Me(xt,8,this,new Set)),Me(xt,11,this),this.registerEffect(Vt(this,Sn,Od))}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;ia=new WeakMap;Sn=new WeakSet;Od=function(){const{roots:e}=this,t=[];for(const n of e)for(const r of ye(this,fr))t.push(Vt(this,Sn,Ed).call(this,n,r));return()=>{for(const n of t)n()}};Ed=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=Yo(e)?Vt(this,Sn,Cd).call(this,e,n,t):Vt(this,Sn,Id).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())}};Cd=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)}}};Id=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(Qo(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",Td,Mt,ia);it(xt,2,"sourceRoot",$d,Mt);it(xt,2,"targetRoot",Sd,Mt);it(xt,2,"roots",kd,Mt);Qt(xt,Mt);Mt.configure=Ir(Mt);var Vs=Mt,$p=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`,Tp=[dt,Is,"popover","aria-pressed","aria-grabbing"],Op=["view-transition-name"],Ep=`
|
|
9
|
+
:is(:root,:host) [${dt}] {
|
|
10
10
|
position: fixed !important;
|
|
11
11
|
pointer-events: none !important;
|
|
12
12
|
touch-action: none;
|
|
13
13
|
z-index: calc(infinity);
|
|
14
14
|
will-change: translate;
|
|
15
|
-
top: var(${
|
|
16
|
-
left: var(${
|
|
15
|
+
top: var(${Le}top, 0px) !important;
|
|
16
|
+
left: var(${Le}left, 0px) !important;
|
|
17
17
|
right: unset !important;
|
|
18
18
|
bottom: unset !important;
|
|
19
|
-
width: var(${
|
|
20
|
-
max-width: var(${
|
|
21
|
-
height: var(${
|
|
22
|
-
max-height: var(${
|
|
23
|
-
transform: var(${
|
|
24
|
-
transition: var(${
|
|
19
|
+
width: var(${Le}width, auto);
|
|
20
|
+
max-width: var(${Le}width, auto);
|
|
21
|
+
height: var(${Le}height, auto);
|
|
22
|
+
max-height: var(${Le}height, auto);
|
|
23
|
+
transform: var(${Le}transform, none) !important;
|
|
24
|
+
transition: var(${Le}transition) !important;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
:is(:root,:host) [${
|
|
27
|
+
:is(:root,:host) [${Is}] {
|
|
28
28
|
transition: none;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
:is(:root,:host) [${
|
|
31
|
+
:is(:root,:host) [${Is}='hidden'] {
|
|
32
32
|
visibility: hidden;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
[${
|
|
35
|
+
[${dt}] * {
|
|
36
36
|
pointer-events: none !important;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
[${
|
|
40
|
-
translate: var(${
|
|
39
|
+
[${dt}]:not([${Ji}]) {
|
|
40
|
+
translate: var(${Le}translate) !important;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
[${
|
|
44
|
-
scale: var(${
|
|
45
|
-
transform-origin: var(${
|
|
43
|
+
[${dt}][style*='${Le}scale'] {
|
|
44
|
+
scale: var(${Le}scale) !important;
|
|
45
|
+
transform-origin: var(${Le}transform-origin) !important;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
@layer dnd-kit {
|
|
49
|
-
:where([${
|
|
49
|
+
:where([${dt}][popover]) {
|
|
50
50
|
overflow: visible;
|
|
51
51
|
background: unset;
|
|
52
52
|
border: unset;
|
|
@@ -60,51 +60,136 @@
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
[${
|
|
63
|
+
[${dt}]::backdrop, [${Pr}overlay]:not([${dt}]) {
|
|
64
64
|
display: none;
|
|
65
65
|
visibility: hidden;
|
|
66
66
|
}
|
|
67
|
-
`.replace(/\n+/g," ").replace(/\s+/g," ").trim();function uh(e,t="hidden"){return H(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const i=fh(n,r.registry.droppables),s=[],o=of(n),{remove:a}=o;return hh(i,o,s),ph(o,t),o.remove=()=>{s.forEach(l=>l()),a.call(o)},o})}function fh(e,t){const n=new Map;for(const r of t)if(r.element&&(e===r.element||e.contains(r.element))){const i=`${Cr}${Ps("dom-id")}`;r.element.setAttribute(i,""),n.set(r,i)}return n}function hh(e,t,n){for(const[r,i]of e){if(!r.element)continue;const s=`[${i}]`,o=t.matches(s)?t:t.querySelector(s);if(r.element.removeAttribute(i),!o)continue;const a=r.element;r.proxy=o,o.removeAttribute(i),Os.set(a,o),n.push(()=>{Os.delete(a),r.proxy=void 0})}}function ph(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(wi,t)}function Kc(e,t){return e===t?!0:wn(e)===wn(t)}function $a(e){const{target:t}=e;"newState"in e&&e.newState==="closed"&&Vt(t)&&t.hasAttribute("popover")&&requestAnimationFrame(()=>vn(t))}function As(e){return e.tagName==="TR"}function gh(e,t,n){const r=new MutationObserver(i=>{let s=!1;for(const o of i){if(o.target!==e){s=!0;continue}if(o.type!=="attributes")continue;const a=o.attributeName;if(a.startsWith("aria-")||lh.includes(a))continue;const l=e.getAttribute(a);if(a==="style"){if(fr(e)&&fr(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(ch.includes(d)||d.startsWith(Te))continue;const c=u.getPropertyValue(d);t.style.setProperty(d,c)}}}else l!==null?t.setAttribute(a,l):t.removeAttribute(a)}s&&n&&t.replaceChildren(...e.cloneNode(!0).childNodes)});return r.observe(e,{attributes:!0,subtree:!0,childList:!0}),r}function vh(e,t,n){const r=new MutationObserver(i=>{for(const s of i)if(s.addedNodes.length!==0)for(const o of Array.from(s.addedNodes)){if(o.contains(e)&&e.nextElementSibling!==t){e.insertAdjacentElement("afterend",t),vn(n);return}if(o.contains(t)&&t.previousElementSibling!==e){t.insertAdjacentElement("beforebegin",e),vn(n);return}}e.isConnected&&t.isConnected&&e.nextElementSibling!==t&&(e.insertAdjacentElement("afterend",t),vn(n))});return r.observe(e.ownerDocument.body,{childList:!0,subtree:!0}),r}function mh(e){return new ResizeObserver(()=>{var t,n,r;const i=new ct(e.placeholder,{frameTransform:e.frameTransform,ignoreTransforms:!0}),s=(t=e.transformOrigin)!=null?t:{x:1,y:1},o=(e.width-i.width)*s.x+e.delta.x,a=(e.height-i.height)*s.y+e.delta.y,l=kc();if(e.styles.set({width:i.width-e.widthOffset,height:i.height-e.heightOffset,top:e.top+a+l.y,left:e.left+o+l.x},Te),(n=e.getElementMutationObserver())==null||n.takeRecords(),As(e.element)&&As(e.placeholder)){const p=Array.from(e.element.cells),w=Array.from(e.placeholder.cells);e.getSavedCellWidths()||e.setSavedCellWidths(p.map(x=>x.style.width));for(const[x,m]of p.entries()){const g=w[x];m.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,h=i.width-e.widthOffset,f=i.height-e.heightOffset,v=e.frameTransform;e.dragOperation.shape=new dt(d*v.scaleX+v.x,c*v.scaleY+v.y,h*v.scaleX,f*v.scaleY)})}var yh=250,bh="ease";function xh(e){var t,n,r,i;const{animation:s}=e;if(typeof s=="function"){const m=s({source:e.source,element:e.element,feedbackElement:e.feedbackElement,placeholder:e.placeholder,translate:e.translate,moved:e.moved});Promise.resolve(m).then(()=>{e.cleanup(),requestAnimationFrame(e.restoreFocus)});return}const{duration:o=yh,easing:a=bh}=s??{};vn(e.feedbackElement);const[,l]=(t=xc(e.feedbackElement,m=>"translate"in m))!=null?t:[];l?.pause();const u=(n=e.placeholder)!=null?n:e.element,d={frameTransform:Kc(e.feedbackElement,u)?null:void 0},c=new ct(e.feedbackElement,d),h=(r=yr(ht(e.feedbackElement).translate))!=null?r:e.translate,f=new ct(u,d),v=dt.delta(c,f,e.alignment),p={x:h.x-v.x,y:h.y-v.y},w=Math.round(c.intrinsicHeight)!==Math.round(f.intrinsicHeight)?{minHeight:[`${c.intrinsicHeight}px`,`${f.intrinsicHeight}px`],maxHeight:[`${c.intrinsicHeight}px`,`${f.intrinsicHeight}px`]}:{},x=Math.round(c.intrinsicWidth)!==Math.round(f.intrinsicWidth)?{minWidth:[`${c.intrinsicWidth}px`,`${f.intrinsicWidth}px`],maxWidth:[`${c.intrinsicWidth}px`,`${f.intrinsicWidth}px`]}:{};e.styles.set({transition:e.transition},Te),e.feedbackElement.setAttribute(js,""),(i=e.getElementMutationObserver())==null||i.takeRecords(),Ic({element:e.feedbackElement,keyframes:Fo(xr(xr({},w),x),{translate:[`${h.x}px ${h.y}px 0`,`${p.x}px ${p.y}px 0`]}),options:{duration:Ro(Ke(e.feedbackElement))?0:e.moved||e.feedbackElement!==e.element?o:0,easing:a}}).then(()=>{e.feedbackElement.removeAttribute(js),l?.finish(),e.cleanup(),requestAnimationFrame(e.restoreFocus)})}var Yc,Rs,wr,Vo,ii,Xc,Qc,Sn=class extends(Rs=Me,Yc=[K],Rs){constructor(t,n){super(t,n),ve(this,ii),ve(this,Vo,we(wr,8,this)),we(wr,11,this),this.state={initial:{},current:{}};const r=t.registry.plugins.get(Wi),i=r?.register(dh);if(i){const s=this.destroy.bind(this);this.destroy=()=>{i(),s()}}this.registerEffect(Gt(this,ii,Xc).bind(this,r)),this.registerEffect(Gt(this,ii,Qc))}};wr=Rn(Rs);Vo=new WeakMap;ii=new WeakSet;Xc=function(e){const{overlay:t}=this;if(!t||!e)return;const n=pi(t);if(n)return e.addRoot(n)};Qc=function(){var e,t,n,r,i,s,o;const{state:a,manager:l,options:u}=this,{dragOperation:d}=l,{position:c,source:h,status:f}=d;if(f.idle){a.current={},a.initial={};return}if(!h)return;const{element:v}=h,p=h.pluginConfig(Sn),w=(t=(e=p?.feedback)!=null?e:u?.feedback)!=null?t:"default",x=typeof w=="function"?w(h,l):w;if(!v||x==="none"||!f.initialized||f.initializing)return;const{initial:m}=a,g=(n=this.overlay)!=null?n:v,b=_n(g),_=_n(v),$=!Kc(v,g),O=new ct(v,{frameTransform:$?_:null,ignoreTransforms:!$}),C={x:_.scaleX/b.scaleX,y:_.scaleY/b.scaleY};let{width:I,height:P,top:U,left:W}=O;$&&(I=I/C.x,P=P/C.y);const M=new zf(g),z=ht(v),{transition:V,translate:ee,boxSizing:Se,paddingBlockStart:oe,paddingBlockEnd:Le,paddingInlineStart:Ve,paddingInlineEnd:Ce,borderInlineStartWidth:Ye,borderInlineEndWidth:Ge,borderBlockStartWidth:We,borderBlockEndWidth:Xe}=z,$e=V.split(",").filter(Z=>!/^\s*(transform|translate|scale)\b/.test(Z)).join(","),fe=Li(z),L=z.transform,G=x==="clone",_e=Se==="content-box",X=_e?parseInt(Ve)+parseInt(Ce)+parseInt(Ye)+parseInt(Ge):0,ze=_e?parseInt(oe)+parseInt(Le)+parseInt(We)+parseInt(Xe):0,ne=x!=="move"&&!this.overlay?uh(h,G?"clone":"hidden"):null,at=H(()=>br(l.dragOperation.activatorEvent));if(!m.translate){if(this.overlay&&fe)m.translate={x:fe.x,y:fe.y};else if(ee!=="none"){const Z=yr(ee);Z&&(m.translate=Z)}}if(!m.transformOrigin){const Z=H(()=>c.current),R=W+((r=fe?.x)!=null?r:0),te=U+((i=fe?.y)!=null?i:0);m.transformOrigin={x:(Z.x-R*b.scaleX-b.x)/(I*b.scaleX),y:(Z.y-te*b.scaleY-b.y)/(P*b.scaleY)}}const{transformOrigin:Fe}=m,xt=U*b.scaleY+b.y,T=W*b.scaleX+b.x;if(!m.coordinates&&(m.coordinates={x:T,y:xt},C.x!==1||C.y!==1)){const{scaleX:Z,scaleY:R}=_,{x:te,y:Oe}=Fe;m.coordinates.x+=(I*Z-I)*te,m.coordinates.y+=(P*R-P)*Oe}m.dimensions||(m.dimensions={width:I,height:P}),m.frameTransform||(m.frameTransform=b);const A={x:m.coordinates.x-T,y:m.coordinates.y-xt},q={width:(m.dimensions.width*m.frameTransform.scaleX-I*b.scaleX)*Fe.x,height:(m.dimensions.height*m.frameTransform.scaleY-P*b.scaleY)*Fe.y},E={x:A.x/b.scaleX+q.width,y:A.y/b.scaleY+q.height},D={left:W+E.x,top:U+E.y};g.setAttribute(lt,"true");const B=H(()=>d.transform),Q=(s=m.translate)!=null?s:{x:0,y:0},Ue=B.x*b.scaleX+Q.x,ke=B.y*b.scaleY+Q.y,se=kc();M.set({width:I-X,height:P-ze,top:D.top+se.y,left:D.left+se.x,translate:`${Ue}px ${ke}px 0`,transform:this.overlay?"none":L,transition:$e?`${$e}, translate 0ms linear`:"translate 0ms linear",scale:$?`${C.x} ${C.y}`:"","transform-origin":`${Fe.x*100}% ${Fe.y*100}%`},Te),ne&&(v.insertAdjacentElement("afterend",ne),u?.rootElement&&(typeof u.rootElement=="function"?u.rootElement(h):u.rootElement).appendChild(v)),Ds(g)&&(g.hasAttribute("popover")||g.setAttribute("popover","manual"),vn(g),g.addEventListener("beforetoggle",$a));let Ee,Qt,Ct;const Rr=mh({placeholder:ne,element:v,feedbackElement:g,frameTransform:b,transformOrigin:Fe,width:I,height:P,top:U,left:W,widthOffset:X,heightOffset:ze,delta:E,styles:M,dragOperation:d,getTranslate:()=>a.current.translate,getElementMutationObserver:()=>Ee,getSavedCellWidths:()=>Ct,setSavedCellWidths:Z=>{Ct=Z}}),Pt=new ct(g);H(()=>d.shape=Pt);const Zt=Ke(g),Wn=Z=>{this.manager.actions.stop({event:Z})},ra=Ro(Zt);at&&Zt.addEventListener("resize",Wn),H(()=>h.status)==="idle"&&requestAnimationFrame(()=>h.status="dragging"),ne&&(Rr.observe(ne),Ee=gh(v,ne,G),Qt=vh(v,ne,g));const Lr=(o=l.dragOperation.source)==null?void 0:o.id,zn=()=>{var Z;if(!at||Lr==null)return;const R=l.registry.draggables.get(Lr),te=(Z=R?.handle)!=null?Z:R?.element;Tt(te)&&te.focus()},Fn=()=>{Ee?.disconnect(),Qt?.disconnect(),Rr.disconnect(),Zt.removeEventListener("resize",Wn),Ds(g)&&(g.removeEventListener("beforetoggle",$a),g.removeAttribute("popover")),g.removeAttribute(lt),M.reset();const Z=()=>{var R;if(Ct&&As(v)){const he=Array.from(v.cells);for(const[ae,Jt]of he.entries())Jt.style.width=(R=Ct[ae])!=null?R:""}h.status="idle";const te=a.current.translate!=null,Oe=d.status.dragging;ne&&(!Oe&&te||ne.parentElement!==g.parentElement)&&g.isConnected&&ne.replaceWith(g),ne?.remove()};g===this.overlay?setTimeout(Z,0):Z()},Gi=u?.dropAnimation,Nn=this,Ui=$r(()=>{var Z,R,te;const{transform:Oe,status:he}=d;if(!(!Oe.x&&!Oe.y&&!a.current.translate)&&he.dragging){const ae=(Z=m.translate)!=null?Z:{x:0,y:0},Jt={x:Oe.x/b.scaleX+ae.x,y:Oe.y/b.scaleY+ae.y},ia=a.current.translate,tu=H(()=>d.modifiers),qi=H(()=>{var Vn;return(Vn=d.shape)==null?void 0:Vn.current}),Bn=u?.keyboardTransition,sa=at&&!ra&&Bn!==null?`${(R=Bn?.duration)!=null?R:250}ms ${(te=Bn?.easing)!=null?te:"cubic-bezier(0.25, 1, 0.5, 1)"}`:"0ms linear";if(M.set({transition:$e?`${$e}, translate ${sa}`:`translate ${sa}`,translate:`${Jt.x}px ${Jt.y}px 0`},Te),Ee?.takeRecords(),qi&&qi!==Pt&&ia&&!tu.length){const Vn=Ze.delta(Jt,ia);d.shape=dt.from(qi.boundingRectangle).translate(Vn.x*b.scaleX,Vn.y*b.scaleY)}else d.shape=new ct(g);a.current.translate=Jt}},function(){if(d.status.dropped){this.dispose(),h.status="dropping";const Z=p?.dropAnimation!==void 0?p.dropAnimation:Nn.dropAnimation!==void 0?Nn.dropAnimation:Gi;let R=a.current.translate;const te=R!=null;if(!R&&v!==g&&(R={x:0,y:0}),!R||Z===null){Fn();return}l.renderer.rendering.then(()=>{xh({source:h,element:v,feedbackElement:g,placeholder:ne,translate:R,moved:te,transition:V,alignment:h.alignment,styles:M,animation:Z??void 0,getElementMutationObserver:()=>Ee,cleanup:Fn,restoreFocus:zn})})}});return()=>{Fn(),Ui()}};nt(wr,4,"overlay",Yc,Sn,Vo);Xt(wr,Sn);Sn.configure=Or(Sn);var Go=Sn,Gn=!0,wh=!1,Zc,Jc,ed,td,St,Uo,qo;td=(ed=[K],Je.Forward),Jc=(Zc=[K],Je.Reverse);var _r=class{constructor(){ve(this,Uo,we(St,8,this,Gn)),we(St,11,this),ve(this,qo,we(St,12,this,Gn)),we(St,15,this)}isLocked(e){return e===Je.Idle?!1:e==null?this[Je.Forward]===Gn&&this[Je.Reverse]===Gn:this[e]===Gn}unlock(e){e!==Je.Idle&&(this[e]=wh)}};St=Rn(null);Uo=new WeakMap;qo=new WeakMap;nt(St,4,td,ed,_r,Uo);nt(St,4,Jc,Zc,_r,qo);Xt(St,_r);var _h=[Je.Forward,Je.Reverse],Ea=class{constructor(){this.x=new _r,this.y=new _r}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},kh=class extends Me{constructor(e){super(e);const t=En(new Ea);let n=null;this.signal=t,tt(()=>{const{status:r}=e.dragOperation;if(!r.initialized){n=null,t.value=new Ea;return}const{delta:i}=e.dragOperation.position;if(n){const s={x:Oa(i.x,n.x),y:Oa(i.y,n.y)},o=t.peek();ue(()=>{for(const a of Cl)for(const l of _h)s[a]===l&&o[a].unlock(l);t.value=o})}n=i})}get current(){return this.signal.peek()}};function Oa(e,t){return Math.sign(e-t)}var nd,Ls,kr,Ho,_t,Ws,Pr=class extends(Ls=Tr,nd=[K],Ls){constructor(e){super(e),ve(this,Ho,we(kr,8,this,!1)),we(kr,11,this),ve(this,_t),ve(this,Ws,()=>{if(!re(this,_t))return;const{element:s,by:o}=re(this,_t);o.y&&(s.scrollTop+=o.y),o.x&&(s.scrollLeft+=o.x)}),this.scroll=(s,o)=>{var a;if(this.disabled)return!1;const l=this.getScrollableElements();if(!l)return Ae(this,_t,void 0),!1;const{position:u}=this.manager.dragOperation,d=u?.current;if(d){const{by:c}=s??{},h=c?{x:Ta(c.x),y:Ta(c.y)}:void 0,f=h?void 0:this.scrollIntentTracker.current;if(f?.isLocked())return!1;for(const v of l){const p=bf(v,c);if(p.x||p.y){const{speed:w,direction:x}=Cf(v,d,h,o?.acceleration,o?.threshold);if(f)for(const m of Cl)f[m].isLocked(x[m])&&(w[m]=0,x[m]=0);if(x.x||x.y){const{x:m,y:g}=c??x,b=m*w.x,_=g*w.y;if(b||_){const $=(a=re(this,_t))==null?void 0:a.by;if(this.autoScrolling&&$&&($.x&&!b||$.y&&!_))continue;return Ae(this,_t,{element:v,by:{x:b,y:_}}),mi.schedule(re(this,Ws)),!0}}}}}return Ae(this,_t,void 0),!1};let t=null,n=null;const r=hs(()=>{const{position:s,source:o}=e.dragOperation;if(!s)return null;const a=Sc(pi(o?.element),s.current);return a&&(t=a),a??t}),i=hs(()=>{const s=r.value,{documentElement:o}=jn(s);if(!s||s===o){const{target:a}=e.dragOperation,l=a?.element;if(l){const u=Cs(l,{excludeElement:!1});return n=u,u}}if(s){const a=Cs(s,{excludeElement:!1});return this.autoScrolling&&n&&a.size<n?.size?n:(n=a,a)}return n=null,null},rt);this.getScrollableElements=()=>i.value,this.scrollIntentTracker=new kh(e),this.destroy=e.monitor.addEventListener("dragmove",s=>{this.disabled||s.defaultPrevented||!br(e.dragOperation.activatorEvent)||!s.by||this.scroll({by:s.by})&&s.preventDefault()})}};kr=Rn(Ls);Ho=new WeakMap;_t=new WeakMap;Ws=new WeakMap;nt(kr,4,"autoScrolling",nd,Pr,Ho);Xt(kr,Pr);function Ta(e){return e>0?Je.Forward:e<0?Je.Reverse:Je.Idle}var Sh=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))}},$h=new Sh(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),Eh=10,zs=class extends Me{constructor(t,n){super(t,n);const r=t.registry.plugins.get(Pr);if(!r)throw new Error("AutoScroller plugin depends on Scroller plugin");this.destroy=tt(()=>{var i,s,o;if(this.disabled)return;const{position:a,status:l}=t.dragOperation;if(l.dragging){const u={acceleration:(i=this.options)==null?void 0:i.acceleration,threshold:typeof((s=this.options)==null?void 0:s.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(()=>$h.schedule(()=>r.scroll(void 0,u)),Eh);return()=>{clearInterval(c)}}else r.autoScrolling=!1}})}};zs.configure=Or(zs);var rd=zs,Da={capture:!0,passive:!0},nr,Oh=class extends Tr{constructor(e){super(e),ve(this,nr),this.handleScroll=()=>{re(this,nr)==null&&Ae(this,nr,setTimeout(()=>{this.manager.collisionObserver.forceUpdate(!1),Ae(this,nr,void 0)},50))};const{dragOperation:t}=this.manager;this.destroy=tt(()=>{var n,r,i;if(t.status.dragging){const o=(i=(r=(n=t.source)==null?void 0:n.element)==null?void 0:r.ownerDocument)!=null?i:document;return o.addEventListener("scroll",this.handleScroll,Da),()=>{o.removeEventListener("scroll",this.handleScroll,Da)}}})}};nr=new WeakMap;var Th="* { user-select: none !important; -webkit-user-select: none !important; }",Dh=class extends Me{constructor(e){super(e),this.manager=e;const t=e.registry.plugins.get(Wi),n=t?.register(Th);if(this.destroy=tt(()=>{const{dragOperation:r}=this.manager;if(r.status.initialized)return es(),document.addEventListener("selectionchange",es,{capture:!0}),()=>{document.removeEventListener("selectionchange",es,{capture:!0})}}),n){const r=this.destroy.bind(this);this.destroy=()=>{n(),r()}}}};function es(){var e;(e=document.getSelection())==null||e.removeAllRanges()}var rr=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,_i=class extends bn{constructor(t,n){super(t),this.manager=t,this.options=n,ve(this,dn,[]),this.listeners=new $c,this.handleSourceKeyDown=(r,i,s)=>{if(this.disabled||r.defaultPrevented||!Vt(r.target)||i.disabled)return;const{keyboardCodes:o=rr.keyboardCodes,preventActivation:a=rr.preventActivation}=s??{};o.start.includes(r.code)&&this.manager.dragOperation.status.idle&&(a?.(r,i)||this.handleStart(r,i,s))}}bind(t,n=this.options){return tt(()=>{var i;const s=(i=t.handle)!=null?i:t.element,o=a=>{br(a)&&this.handleSourceKeyDown(a,t,n)};if(s)return s.addEventListener("keydown",o),()=>{s.removeEventListener("keydown",o)}})}handleStart(t,n,r){const{element:i}=n;if(!i)throw new Error("Source draggable does not have an associated element");t.preventDefault(),t.stopImmediatePropagation(),Mc(i);const{center:s}=new ct(i);if(this.manager.actions.start({event:t,coordinates:{x:s.x,y:s.y},source:n}).signal.aborted)return this.cleanup();this.sideEffects();const a=jn(i),l=[this.listeners.bind(a,[{type:"keydown",listener:u=>this.handleKeyDown(u,n,r),options:{capture:!0}}])];re(this,dn).push(...l)}handleKeyDown(t,n,r){const{keyboardCodes:i=rr.keyboardCodes}=r??{};if(en(t,[...i.end,...i.cancel])){t.preventDefault();const s=en(t,i.cancel);this.handleEnd(t,s);return}en(t,i.up)?this.handleMove("up",t):en(t,i.down)&&this.handleMove("down",t),en(t,i.left)?this.handleMove("left",t):en(t,i.right)&&this.handleMove("right",t)}handleEnd(t,n){this.manager.actions.stop({event:t,canceled:n}),this.cleanup()}handleMove(t,n){var r,i;const{shape:s}=this.manager.dragOperation,o=n.shiftKey?5:1;let a={x:0,y:0},l=(i=(r=this.options)==null?void 0:r.offset)!=null?i:rr.offset;if(typeof l=="number"&&(l={x:l,y:l}),!!s){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(rd);t?.disabled===!1&&(t.disable(),re(this,dn).push(()=>{t.enable()}))}cleanup(){re(this,dn).forEach(t=>t()),Ae(this,dn,[])}destroy(){this.cleanup(),this.listeners.clear()}};dn=new WeakMap;_i.configure=Or(_i);_i.defaults=rr;var id=_i;function en(e,t){return t.includes(e.code)}var Wt,Ch=class extends lc{constructor(){super(...arguments),ve(this,Wt)}onEvent(e){switch(e.type){case"pointerdown":Ae(this,Wt,xn(e));break;case"pointermove":if(!re(this,Wt))return;const{x:t,y:n}=xn(e),r={x:t-re(this,Wt).x,y:n-re(this,Wt).y},{tolerance:i}=this.options;if(i&&_s(r,i)){this.abort();return}_s(r,this.options.value)&&this.activate(e);break;case"pointerup":this.abort();break}}abort(){Ae(this,Wt,void 0)}};Wt=new WeakMap;var un,zt,Ph=class extends lc{constructor(){super(...arguments),ve(this,un),ve(this,zt)}onEvent(e){switch(e.type){case"pointerdown":Ae(this,zt,xn(e)),Ae(this,un,setTimeout(()=>this.activate(e),this.options.value));break;case"pointermove":if(!re(this,zt))return;const{x:t,y:n}=xn(e),r={x:t-re(this,zt).x,y:n-re(this,zt).y};_s(r,this.options.tolerance)&&this.abort();break;case"pointerup":this.abort();break}}abort(){re(this,un)&&(clearTimeout(re(this,un)),Ae(this,zt,void 0),Ae(this,un,void 0))}};un=new WeakMap;zt=new WeakMap;var gn=class{};gn.Delay=Ph;gn.Distance=Ch;var Fs=Object.freeze({activationConstraints(e,t){var n;const{pointerType:r,target:i}=e;if(!(r==="mouse"&&Vt(i)&&(t.handle===i||(n=t.handle)!=null&&n.contains(i))))return r==="touch"?[new gn.Delay({value:250,tolerance:5})]:Nf(i)&&!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||!Vt(r)||(n=t.handle)!=null&&n.contains(r))return!1;const i=lf(r);return i===t.element?!1:!!i}}),fn,ki=class extends bn{constructor(t,n){super(t),this.manager=t,this.options=n,ve(this,fn,new Set),this.listeners=new $c,this.latest={event:void 0,coordinates:void 0},this.handleMove=()=>{const{event:r,coordinates:i}=this.latest;!r||!i||this.manager.actions.move({event:r,to:i})},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:i=Fs.activationConstraints}=r??{};return typeof i=="function"?i(t,n):i}bind(t,n=this.options){return tt(()=>{var i;const s=new AbortController,{signal:o}=s,a=u=>{Ff(u)&&this.handlePointerDown(u,t,n)};let l=[(i=t.handle)!=null?i:t.element];n?.activatorElements&&(Array.isArray(n.activatorElements)?l=n.activatorElements:l=n.activatorElements(t));for(const u of l)u&&(jh(u.ownerDocument.defaultView),u.addEventListener("pointerdown",a,{signal:o}));return()=>s.abort()})}handlePointerDown(t,n,r){if(this.disabled||!t.isPrimary||t.button!==0||!Vt(t.target)||n.disabled||Mh(t)||!this.manager.dragOperation.status.idle)return;const{preventActivation:i=Fs.preventActivation}=r??{};if(i?.(t,n))return;const{target:s}=t,o=Tt(s)&&s.draggable&&s.getAttribute("draggable")==="true",a=_n(n.element),{x:l,y:u}=xn(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 Zu(d,p=>this.handleStart(n,p));c.signal.onabort=()=>this.handleCancel(t),c.onEvent(t),this.controller=c;const h=Es(),f=this.listeners.bind(h,[{type:"pointermove",listener:p=>this.handlePointerMove(p,n)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"pointercancel",listener:this.handleCancel},{type:"dragstart",listener:o?this.handleCancel:Nr,options:{capture:!0}}]),v=()=>{f(),this.initialCoordinates=void 0};re(this,fn).add(v)}handlePointerMove(t,n){var r,i;if(((r=this.controller)==null?void 0:r.activated)===!1){(i=this.controller)==null||i.onEvent(t);return}if(this.manager.dragOperation.status.dragging){const s=xn(t),o=_n(n.element);s.x=s.x*o.scaleX+o.x,s.y=s.y*o.scaleY+o.y,t.preventDefault(),t.stopPropagation(),this.latest.event=t,this.latest.coordinates=s,mi.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:i}=this;if(!i||!r.dragOperation.status.idle||n.defaultPrevented)return;if(r.actions.start({coordinates:i,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=Vt(n.target)?[n.target,a]:a,u=this.listeners.bind(l,[{type:"touchmove",listener:Nr,options:{passive:!1}},{type:"click",listener:Nr},{type:"contextmenu",listener:Nr},{type:"keydown",listener:this.handleKeyDown}]);re(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},re(this,fn).forEach(n=>n()),re(this,fn).clear()}destroy(){this.cleanup(),this.listeners.clear()}};fn=new WeakMap;ki.configure=Or(ki);ki.defaults=Fs;var Ns=ki;function Mh(e){return"sensor"in e}function Nr(e){e.preventDefault()}function Ih(){}var Ca=new WeakSet;function jh(e){!e||Ca.has(e)||(e.addEventListener("touchmove",Ih,{capture:!1,passive:!1}),Ca.add(e))}var mn={modifiers:[],plugins:[sh,rd,ah,Go,Dh],sensors:[Ns,id]},sd=class extends tf{constructor(e={}){const t=st(e.plugins,mn.plugins),n=st(e.sensors,mn.sensors),r=st(e.modifiers,mn.modifiers);super(Fo(xr({},e),{plugins:[Oh,Pr,Wi,...t],sensors:n,modifiers:r}))}},od,ad,Bs,$t,Ko,Yo,zi=class extends(Bs=ut,ad=[K],od=[K],Bs){constructor(e,t){var n=e,{element:r,effects:i=()=>[],handle:s}=n,o=Wc(n,["element","effects","handle"]);super(xr({effects:()=>[...i(),()=>{var a,l;const{manager:u}=this;if(!u)return;const c=((l=(a=this.sensors)==null?void 0:a.map(gr))!=null?l:[...u.sensors]).map(h=>{const f=h instanceof bn?h:u.registry.register(h.plugin),v=h instanceof bn?void 0:h.options;return f.bind(this,v)});return function(){c.forEach(f=>f())}}]},o),t),ve(this,Ko,we($t,8,this)),we($t,11,this),ve(this,Yo,we($t,12,this)),we($t,15,this),this.element=r,this.handle=s}};$t=Rn(Bs);Ko=new WeakMap;Yo=new WeakMap;nt($t,4,"handle",ad,zi,Ko);nt($t,4,"element",od,zi,Yo);Xt($t,zi);var ld,cd,Vs,Et,Xo,ts,dd,ud,pr,Qo,Fi=class extends(Vs=ft,cd=[K],ld=[K],Vs){constructor(e,t){var n=e,{element:r,effects:i=()=>[]}=n,s=Wc(n,["element","effects"]);const{collisionDetector:o=jc}=s,a=u=>{const{manager:d,element:c}=this;if(!c||u===null){this.shape=void 0;return}if(!d)return;const h=new ct(c),f=H(()=>this.shape);return h&&f?.equals(h)?f:(this.shape=h,h)},l=En(!1);super(Fo(xr({},s),{collisionDetector:o,effects:()=>[...i(),()=>{const{element:u,manager:d}=this;if(!d)return;const{dragOperation:c}=d,{source:h}=c;l.value=!!(h&&c.status.initialized&&u&&!this.disabled&&this.accepts(h))},()=>{const{element:u}=this;if(l.value&&u){const d=new yf(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),ve(this,pr),ve(this,Xo,we(Et,8,this)),we(Et,11,this),ve(this,Qo,we(Et,12,this)),we(Et,15,this),this.element=r,this.refreshShape=()=>a()}set element(e){Ae(this,pr,e,ud)}get element(){var e;return(e=this.proxy)!=null?e:re(this,pr,dd)}};Et=Rn(Vs);Xo=new WeakMap;pr=new WeakSet;Qo=new WeakMap;ts=nt(Et,20,"#element",cd,pr,Xo),dd=ts.get,ud=ts.set;nt(Et,4,"proxy",ld,Fi,Qo);Xt(Et,Fi);function Ah(e){return e!=null&&typeof e=="object"&&"current"in e}function yn(e){var t;if(e!=null)return Ah(e)?(t=e.current)!=null?t:void 0:e}var Rh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Ln=Rh?S.useLayoutEffect:S.useEffect;function Lh(){const e=S.useState(0)[1];return S.useCallback(()=>{e(t=>t+1)},[e])}function fd(e,t){const n=S.useRef(new Map),r=Lh();return Ln(()=>{if(!e){n.current.clear();return}return tt(()=>{var i;let s=!1,o=!1;for(const a of n.current){const[l]=a,u=H(()=>a[1]),d=e[l];u!==d&&(s=!0,n.current.set(l,d),o=(i=t?.(l,u,d))!=null?i:!1)}s&&(o?queueMicrotask(()=>lu.flushSync(r)):r())})},[e]),S.useMemo(()=>e&&new Proxy(e,{get(i,s){const o=i[s];return n.current.set(s,o),o}}),[e])}function Wh(e,t){e()}function tn(e){const t=S.useRef(e);return Ln(()=>{t.current=e},[e]),t}function le(e,t,n=S.useEffect,r=Object.is){const i=S.useRef(e);n(()=>{const s=i.current;r(e,s)||(i.current=e,t(e,s))},[t,e])}function si(e,t){const n=S.useRef(yn(e));Ln(()=>{const r=yn(e);r!==n.current&&(n.current=r,t(r))})}var zh=Object.defineProperty,Fh=Object.defineProperties,Nh=Object.getOwnPropertyDescriptors,Si=Object.getOwnPropertySymbols,hd=Object.prototype.hasOwnProperty,pd=Object.prototype.propertyIsEnumerable,Pa=(e,t,n)=>t in e?zh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Bh=(e,t)=>{for(var n in t||(t={}))hd.call(t,n)&&Pa(e,n,t[n]);if(Si)for(var n of Si(t))pd.call(t,n)&&Pa(e,n,t[n]);return e},Vh=(e,t)=>Fh(e,Nh(t)),Gh=(e,t)=>{var n={};for(var r in e)hd.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Si)for(var r of Si(e))t.indexOf(r)<0&&pd.call(e,r)&&(n[r]=e[r]);return n},Uh=new sd,gd=S.createContext(Uh),qh=S.memo(S.forwardRef(({children:e},t)=>{const[n,r]=S.useState(0),i=S.useRef(null),s=S.useRef(null),o=S.useMemo(()=>({renderer:{get rendering(){var a;return(a=i.current)!=null?a:Promise.resolve()}},trackRendering(a){i.current||(i.current=new Promise(l=>{s.current=l})),S.startTransition(()=>{a(),r(l=>l+1)})}}),[]);return Ln(()=>{var a;(a=s.current)==null||a.call(s),i.current=null},[e,n]),S.useImperativeHandle(t,()=>o),null})),ns=[void 0,rt];function Hh(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:i,onDragStart:s,onDragMove:o,onDragOver:a,onDragEnd:l}=t,u=Gh(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const d=S.useRef(null),{plugins:c,modifiers:h,sensors:f}=u,v=st(c,mn.plugins),p=st(f,mn.sensors),w=st(h,mn.modifiers),x=tn(i),m=tn(s),g=tn(a),b=tn(o),_=tn(l),$=tn(r),O=Kh(()=>{var C;return(C=u.manager)!=null?C:new sd(u)});return S.useEffect(()=>{if(!d.current)throw new Error("Renderer not found");const{renderer:C,trackRendering:I}=d.current,{monitor:P}=O;O.renderer=C;const U=[P.addEventListener("beforedragstart",W=>{const M=x.current;M&&I(()=>M(W,O))}),P.addEventListener("dragstart",W=>{var M;return(M=m.current)==null?void 0:M.call(m,W,O)}),P.addEventListener("dragover",W=>{const M=g.current;M&&I(()=>M(W,O))}),P.addEventListener("dragmove",W=>{const M=b.current;M&&I(()=>M(W,O))}),P.addEventListener("dragend",W=>{const M=_.current;M&&I(()=>M(W,O))}),P.addEventListener("collision",W=>{var M;return(M=$.current)==null?void 0:M.call($,W,O)})];return()=>U.forEach(W=>W())},[O]),le(v,()=>O&&(O.plugins=v),...ns),le(p,()=>O&&(O.sensors=p),...ns),le(w,()=>O&&(O.modifiers=w),...ns),y.jsxs(gd.Provider,{value:O,children:[y.jsx(qh,{ref:d,children:n}),n]})}function Kh(e){const t=S.useRef(null);return t.current||(t.current=e()),S.useInsertionEffect(()=>()=>{var n;return(n=t.current)==null?void 0:n.destroy()},[]),t.current}function Yh(){return S.useContext(gd)}function vd(e){var t;const n=(t=Yh())!=null?t:void 0,[r]=S.useState(()=>e(n));return r.manager!==n&&(r.manager=n),Ln(r.register,[n,r]),r}var Xh=Object.create,md=Object.defineProperty,Qh=Object.getOwnPropertyDescriptor,yd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ni=e=>{throw TypeError(e)},Zh=(e,t,n)=>t in e?md(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Jh=e=>{var t;return[,,,Xh((t=e?.[yd("metadata")])!=null?t:null)]},bd=["class","method","getter","setter","accessor","field","value","get","set"],xd=e=>e!==void 0&&typeof e!="function"?Ni("Function expected"):e,ep=(e,t,n,r,i)=>({kind:bd[e],name:t,metadata:r,addInitializer:s=>n._?Ni("Already initialized"):i.push(xd(s||null))}),tp=(e,t)=>Zh(t,yd("metadata"),e[3]),np=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)s[i].call(n);return r},wd=(e,t,n,r,i,s)=>{for(var o,a,l,u,d=t&7,c=!1,h=!1,f=2,v=bd[d+5],p=e[f]||(e[f]=[]),w=(i=i.prototype,Qh(i,n)),x=r.length-1;x>=0;x--)l=ep(d,n,a={},e[3],p),l.static=c,l.private=h,u=l.access={has:m=>n in m},u.get=m=>m[n],o=(0,r[x])(w[v],l),a._=1,xd(o)&&(w[v]=o);return w&&md(i,n,w),i},_d=(e,t,n)=>t.has(e)||Ni("Cannot "+n),rp=(e,t,n)=>(_d(e,t,"read from private field"),t.get(e)),ip=(e,t,n)=>t.has(e)?Ni("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),sp=(e,t,n,r)=>(_d(e,t,"write to private field"),t.set(e,n),n),Nt=class Gs{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Gs(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 Gs(t,n)}},kd,Sd,Us,oi,Mr,Zo=class extends(Us=Kt,Sd=[ge],kd=[ge],Us){constructor(e){const t=Nt.from(e);super(t,(n,r)=>Nt.equals(n,r)),np(Mr,5,this),ip(this,oi,0),this.velocity={x:0,y:0}}get delta(){return Nt.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=Nt.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),s=i-rp(this,oi),o=a=>Math.round(a/s*100);ue(()=>{sp(this,oi,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(Nt.from(e)),this.velocity={x:0,y:0}}};Mr=Jh(Us);oi=new WeakMap;wd(Mr,2,"delta",Sd,Zo);wd(Mr,2,"direction",kd,Zo);tp(Mr,Zo);var $d=(e=>(e.Horizontal="x",e.Vertical="y",e))($d||{});Object.values($d);var op=({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 i=Nt.distance(t.shape.center,n);return{id:r,value:1/i,type:In.PointerIntersection,priority:Mn.High}}return null},ap=({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:i}=e,s=Nt.distance(t.shape.center,i.current),a=r/(n.current.area+t.shape.area-r)/s;return{id:t.id,value:a,type:In.ShapeIntersection,priority:Mn.Normal}}return null},lp=e=>{var t;return(t=op(e))!=null?t:ap(e)};function cp(e){const{collisionDetector:t,data:n,disabled:r,element:i,id:s,accept:o,type:a}=e,l=vd(d=>new Fi(Vh(Bh({},e),{register:!1,element:yn(i)}),d)),u=fd(l);return le(s,()=>l.id=s),si(i,d=>l.element=d),le(o,()=>l.accept=o,void 0,rt),le(t,()=>l.collisionDetector=t??lp),le(n,()=>n&&(l.data=n)),le(r,()=>l.disabled=r===!0),le(a,()=>l.type=a),{droppable:u,get isDropTarget(){return u.isDropTarget},ref:S.useCallback(d=>{var c,h;!d&&((c=l.element)!=null&&c.isConnected)&&!((h=l.manager)!=null&&h.dragOperation.status.idle)||(l.element=d??void 0)},[l])}}function dp(e,t=[]){const n=new Map;for(const s of e.tiles)for(const o of s.filters??[])n.set(o.given,(n.get(o.given)??0)+1);const r=[],i=new Set;for(const s of e.localGivens??[])i.add(s.name),r.push({name:s.name,...s.label===void 0?{}:{label:s.label},type:s.type,...s.suggest?{field:s.suggest.dimension}:{},origin:"dashboard",local:s,boundTiles:n.get(s.name)??0});for(const s of t)i.has(s.name)||(i.add(s.name),r.push({...s,origin:"model",boundTiles:n.get(s.name)??0}));for(const[s,o]of n)i.has(s)||r.push({name:s,origin:"model",boundTiles:o});return r}function $i(e){if(!(e===void 0||e.startsWith("filter<")))return e==="string"||e==="boolean"?"=":">="}function up(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function ai(e,t){const n=up(e),r=t?.replace(/_type$/,"");if(!n||!r)return!0;const i=new Set(["date","timestamp"]);return i.has(n)?i.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 fp(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const hp=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function pp(e,t){const r=(e.split(".").at(-1)??"").split(/[^A-Za-z0-9]+/).filter(Boolean).join("_").toUpperCase()||"FILTER",i=/^[A-Z_]/.test(r)?r:`F_${r}`,s=new Set(t);if(!s.has(i))return i;for(let o=2;;o++)if(!s.has(`${i}_${o}`))return`${i}_${o}`}const Ia=[{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:"Since 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.split(".").at(-1)??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 qs=e=>e.declaration.kind!=="inherited"&&e.declaration.kind!=="opaque";function gp(e,t){return e.tiles.map(n=>{const r=(n.filters??[]).find(i=>i.given===t.name);return{include:r!==void 0,field:r?.field??t.field??t.name.toLowerCase(),...r?.op!==void 0?{op:r.op}:$i(t.type)!==void 0?{op:$i(t.type)}:{}}})}function vp(e,t,n){n.forEach((r,i)=>{const s=e.tiles[i];if(!s||!qs(s))return;const o=(s.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?s.filters=a:delete s.filters})}function mp(e,t){const n=(e.localGivens??[]).filter(s=>s.name!==t.name),r=(e.localGivens??[]).findIndex(s=>s.name===t.name),i=[...n];i.splice(r>=0?r:i.length,0,t),e.localGivens=i}function yp(e,t){for(const r of e.tiles){const i=(r.filters??[]).filter(s=>s.given!==t);i.length>0?r.filters=i:delete r.filters}const n=(e.localGivens??[]).filter(r=>r.name!==t);n.length>0?e.localGivens=n:delete e.localGivens}const bp=j.createSvgIcon(y.jsx("path",{d:"M3 17v2h6v-2zM3 5v2h10V5zm10 16v-2h8v-2h-8v-2h-2v6zM7 9v2H3v2h4v2h2V9zm14 4v-2H11v2zm-6-4h2V7h4V5h-4V3h-2z"})),xp=j.createSvgIcon(y.jsx("path",{d:"m14.06 9.02.92.92L5.92 19H5v-.92zM17.66 3c-.25 0-.51.1-.7.29l-1.83 1.83 3.75 3.75 1.83-1.83c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.2-.2-.45-.29-.71-.29m-3.6 3.19L3 17.25V21h3.75L17.81 9.94z"})),wp=j.createSvgIcon(y.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"})),_p=j.createSvgIcon(y.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"})),Hs=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),rs=Hs?"⌘":"Ctrl+",kp=e=>{if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"};function Sp(e){const t=S.useRef(e);S.useEffect(()=>{t.current=e}),S.useEffect(()=>{const n=r=>{const i=t.current,s=Hs?r.metaKey:r.ctrlKey,o=r.key.toLowerCase();if(r.key==="Escape"){i.escape();return}if(!kp(r.target)){if(s&&o==="z"){r.preventDefault(),r.shiftKey?i.redo():i.undo();return}if(!Hs&&s&&o==="y"){r.preventDefault(),i.redo();return}if(s&&o==="s"){r.preventDefault(),i.save?.();return}!s&&!r.altKey&&!r.shiftKey&&(r.key==="ArrowLeft"||r.key==="ArrowRight")&&(r.preventDefault(),i.nudge(r.key==="ArrowRight"?1:-1))}};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[])}function $p({canUndo:e,canRedo:t,onUndo:n,onRedo:r,dirty:i,saving:s,onSave:o,actions:a,onAddTile:l,onSettings:u}){const{theme:d}=Be.usePublisherTheme();return y.jsxs(j.DashboardBar,{left:y.jsx(k.Chip,{size:"medium",variant:"outlined",icon:y.jsx(xp,{sx:{fontSize:20}}),label:"Editing",sx:{height:37,fontSize:"0.875rem",fontWeight:500,border:d.border,color:d.tileTitle,"& .MuiChip-icon":{color:"inherit"},"& .MuiChip-label":{fontSize:"0.875rem"}}}),children:[l&&y.jsx(k.Button,{startIcon:y.jsx(j.AddIcon,{}),onClick:l,"aria-label":"Add tile",children:"Tile"}),y.jsx(k.Button,{startIcon:y.jsx(bp,{}),onClick:c=>u(c.currentTarget),children:"Settings"}),y.jsx(k.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),y.jsx(k.Tooltip,{title:`Undo (${rs}Z)`,children:y.jsx("span",{children:y.jsx(k.IconButton,{"aria-label":"Undo",disabled:!e,onClick:n,sx:{width:37,height:37},children:y.jsx(_p,{fontSize:"small"})})})}),y.jsx(k.Tooltip,{title:`Redo (${rs}⇧Z)`,children:y.jsx("span",{children:y.jsx(k.IconButton,{"aria-label":"Redo",disabled:!t,onClick:r,sx:{width:37,height:37},children:y.jsx(wp,{fontSize:"small"})})})}),o&&y.jsx(y.Fragment,{children:y.jsx(k.Tooltip,{title:i?`Save (${rs}S)`:"",children:y.jsx("span",{children:y.jsx(k.Button,{variant:i?"contained":"outlined",disabled:!i||s,onClick:o,sx:{minWidth:124},children:s?"Saving…":i?"Save changes":"Saved"})})})}),a&&y.jsxs(y.Fragment,{children:[y.jsx(k.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),a]})]})}const Ep=["bar_chart","line_chart","scatter_chart","shape_map","segment_map","big_value","sparkline"];function Vr(e){for(const t of e??[]){const n=/^#\(doc\)\s*(.*)$/s.exec(t.trim());if(n)return n[1].trim()}}function ja(e){for(const t of e??[]){const n=/^#\s*([a-z_]+)/.exec(t.trim())?.[1];if(n&&Ep.includes(n))return n}}const Op=1;function Ed(e,t,n){const r=[];for(const i of e??[]){const s=i.name,o=i.kind;if(typeof s=="string"){if(o==="dimension"||o==="measure"){const a=i.type?.kind;r.push({name:t+s,kind:o,...a?{type:a}:{}})}else if(o==="join"&&n>0){const a=i.schema?.fields;r.push(...Ed(a,`${t}${s}.`,n-1))}}}return r}function Tp(e){const t=new Map;for(const n of e.sourceInfos??[]){let r;try{r=typeof n=="string"?JSON.parse(n):n}catch{continue}const i=r;i?.name&&t.set(i.name,Ed(i.schema?.fields,"",Op))}return t}function Aa(e,t){return!e||t===void 0?void 0:e.sources.find(r=>r.name===t)?.fields.filter(r=>r.kind==="dimension")}const Dp=e=>(e??"").startsWith("dashboards/"),Od=e=>e.modelPath??e.path??"";function Td(e){const t=[],n=new Set;for(const r of e){const i=Od(r);if(Dp(i))continue;const s=Tp(r);for(const o of r.sources??[]){const a=o.name;if(!a||n.has(a))continue;n.add(a);const l=(o.givens??[]).map(u=>u.name).filter(u=>typeof u=="string");t.push({name:a,modelPath:i,...Vr(o.annotations)?{description:Vr(o.annotations)}:{},views:(o.views??[]).filter(u=>typeof u.name=="string").map(u=>({name:u.name,...Vr(u.annotations)?{description:Vr(u.annotations)}:{},...ja(u.annotations)?{chart:ja(u.annotations)}:{}})),givens:l,fields:s.get(a)??[]})}}return{sources:t}}function Cp(e,t,n){const r=new Set;for(const i of t){if(i.kind==="names"){for(const o of i.names)r.add(o);continue}const s=n.find(o=>Od(o)===i.path);if(!s)return e;for(const o of s.sources??[])o.name&&r.add(o.name)}return{...e,sources:e.sources.filter(i=>r.has(i.name))}}const pt=e=>`${e.source}.${e.name}`;function Pp(e,t){if(!t)return[];const n=new Set;for(const r of e.sources)n.add(r.base);for(const r of e.imports)if(r.kind==="names")for(const i of r.names)n.add(i);return t.sources.filter(r=>n.has(r.name))}function Mp({open:e,document:t,catalog:n,columns:r,onClose:i,onAdd:s}){const{theme:o}=Be.usePublisherTheme(),a=S.useMemo(()=>Pp(t,n),[t,n]),[l,u]=S.useState(""),[d,c]=S.useState(""),[h,f]=S.useState(""),[v,p]=S.useState(Math.ceil(r/2));S.useEffect(()=>{e&&(u(t.sources[0]?.base??a[0]?.name??""),c(""),f(""),p(Math.ceil(r/2)))},[e,t,a,r]);const w=a.find(m=>m.name===l),x=l!==""&&d!=="";return y.jsx(j.AppDialog,{open:e,onClose:i,title:"Add a tile",description:"A tile shows one view of one source this dashboard imports.",actions:y.jsxs(y.Fragment,{children:[y.jsx(k.Button,{onClick:i,children:"Cancel"}),y.jsx(k.Button,{variant:"contained",disabled:!x,onClick:()=>s({base:l,view:d,...h.trim()?{label:h.trim()}:{},colspan:v}),children:"Add tile"})]}),children:y.jsx(k.Stack,{sx:{gap:2,pt:1},children:a.length===0?y.jsx(k.Typography,{variant:"body2",sx:{color:o.tileTitle},children:n?"This dashboard imports no source by name, so there is nothing to put a tile on. Import a source in the file first.":"The package's sources are still loading."}):y.jsxs(y.Fragment,{children:[y.jsx(k.TextField,{select:!0,size:"small",label:"Source",value:l,onChange:m=>{u(m.target.value),c("")},inputProps:{"aria-label":"Source"},children:a.map(m=>y.jsxs(k.MenuItem,{value:m.name,children:[m.name,m.description&&y.jsx(k.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:m.description})]},m.name))}),y.jsxs(k.Box,{children:[y.jsx(k.Typography,{variant:"subtitle2",sx:{mb:.5},children:"View"}),y.jsxs(k.List,{dense:!0,disablePadding:!0,"aria-label":"Views",sx:{maxHeight:280,overflowY:"auto",border:o.border,borderRadius:1},children:[(w?.views??[]).map(m=>y.jsxs(k.ListItemButton,{selected:d===m.name,onClick:()=>c(m.name),"aria-label":`View ${m.name}`,children:[y.jsx(k.ListItemText,{primary:m.name,secondary:m.description,primaryTypographyProps:{fontFamily:"ui-monospace, monospace",fontSize:13}}),m.chart&&y.jsx(k.Chip,{size:"small",variant:"outlined",label:m.chart.replace(/_chart$/,"")})]},m.name)),w&&w.views.length===0&&y.jsx(k.Typography,{variant:"body2",sx:{p:1.5,color:o.tileTitle},children:"This source declares no views."})]})]}),y.jsxs(k.Stack,{direction:"row",sx:{gap:1.5},children:[y.jsx(k.TextField,{size:"small",label:"Title",placeholder:"Uses the view's name",value:h,onChange:m=>f(m.target.value),inputProps:{"aria-label":"Tile title"},sx:{flex:1}}),y.jsx(k.TextField,{size:"small",type:"number",label:`Width (of ${r})`,value:v,onChange:m=>p(Math.min(Math.max(Number(m.target.value)||1,1),r)),inputProps:{min:1,max:r,"aria-label":"Tile width"},sx:{width:140}})]})]})})})}const Ra=4e3;function Ip(e,t){const n=e.split(`
|
|
68
|
-
|
|
69
|
-
`);if(n.length>Ra||r.length>Ra)return[...n.map(l=>({kind:"del",text:l})),...r.map(l=>({kind:"add",text:l}))];const i=Array.from({length:n.length+1},()=>new Uint32Array(r.length+1));for(let l=n.length-1;l>=0;l--)for(let u=r.length-1;u>=0;u--)i[l][u]=n[l]===r[u]?i[l+1][u+1]+1:Math.max(i[l+1][u],i[l][u+1]);const s=[];let o=0,a=0;for(;o<n.length&&a<r.length;)n[o]===r[a]?(s.push({kind:"same",text:n[o]}),o++,a++):i[o+1][a]>=i[o][a+1]?s.push({kind:"del",text:n[o++]}):s.push({kind:"add",text:r[a++]});for(;o<n.length;)s.push({kind:"del",text:n[o++]});for(;a<r.length;)s.push({kind:"add",text:r[a++]});return s}function jp(e,t=3){const n=new Array(e.length).fill(!1);e.forEach((s,o)=>{if(s.kind!=="same")for(let a=Math.max(0,o-t);a<=Math.min(e.length-1,o+t);a++)n[a]=!0});const r=[];let i=0;return e.forEach((s,o)=>{n[o]?(i>0&&r.push({kind:"fold",count:i}),i=0,r.push(s)):i++}),i>0&&r.push({kind:"fold",count:i}),r}function Ap({open:e,before:t,after:n,onConfirm:r,onClose:i}){const{theme:s}=Be.usePublisherTheme(),o=S.useMemo(()=>e?jp(Ip(t,n)):[],[e,t,n]),a=o.filter(u=>u.kind==="add").length,l=o.filter(u=>u.kind==="del").length;return y.jsx(j.AppDialog,{open:e,onClose:i,maxWidth:"md",title:"Review the change to the file",description:y.jsxs(y.Fragment,{children:["A tile was added or removed, which moves declarations. Lines the builder does not own — comments, other Malloy — are left where they were; check they still read right."," ",y.jsxs(k.Box,{component:"span",sx:{fontVariantNumeric:"tabular-nums"},children:["+",a," −",l]})]}),actions:y.jsxs(y.Fragment,{children:[y.jsx(k.Button,{onClick:i,children:"Keep editing"}),y.jsx(k.Button,{variant:"contained",onClick:r,children:"Save this"})]}),children:y.jsx(k.Box,{component:"pre","aria-label":"File changes",sx:{m:0,px:2,py:1,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:12,lineHeight:1.6,overflowX:"auto",bgcolor:s.background,color:s.foreground},children:o.map((u,d)=>u.kind==="fold"?y.jsx(k.Box,{component:"span",sx:{display:"block",opacity:.55,py:.25},children:`⋯ ${u.count} unchanged line${u.count===1?"":"s"}`},d):y.jsxs(k.Box,{component:"span",sx:{display:"block",mx:-2,px:2,whiteSpace:"pre",bgcolor:u.kind==="add"?"rgba(46, 125, 91, 0.16)":u.kind==="del"?"rgba(168, 41, 31, 0.14)":"transparent",textDecoration:u.kind==="del"?"line-through":"none",opacity:u.kind==="del"?.8:1},children:[u.kind==="add"?"+ ":u.kind==="del"?"− ":" ",u.text]},d))})})}const is="self";function Rp({open:e,document:t,source:n,givenNames:r,dashboards:i,onClose:s,onApply:o}){const{theme:a}=Be.usePublisherTheme(),[l,u]=S.useState([]);S.useEffect(()=>{if(!e||!n)return;const v=(t.drills??[]).filter(p=>p.source===n.name);u((n.dimensions??[]).map(p=>{const w=v.find(x=>x.name===p.name);return{name:p.name,expression:p.expression,to:w?.to??[],given:w?.given??""}}))},[e,n,t]);const d=(v,p)=>u(w=>w.map((x,m)=>{if(m!==v)return x;const g={...x};return p(g),g})),c=[is,...i.filter(v=>v!==is)],h=v=>v===is?"This dashboard":v,f=()=>{n&&(o(l.filter(v=>v.to.length>0).map(v=>({source:n.name,name:v.name,expression:v.expression,to:v.to,...v.given?{given:v.given}:{}}))),s())};return y.jsx(j.AppDialog,{open:e,onClose:s,title:"Clickable cells",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:y.jsxs(y.Fragment,{children:[y.jsx(k.Button,{onClick:s,children:"Cancel"}),y.jsx(k.Button,{variant:"contained",onClick:f,disabled:l.length===0,children:"Apply"})]}),children:y.jsx(k.Stack,{sx:{gap:2,pt:1},children:l.length===0?y.jsx(k.Typography,{variant:"body2",sx:{color:a.tileTitle},children:n?y.jsxs(y.Fragment,{children:[y.jsx(k.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"," ",y.jsx(k.Box,{component:"code",children:n.name})," and group by it."]}):"This tile's source is not declared in this file."}):l.map((v,p)=>y.jsxs(k.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr)"},gap:1.5,alignItems:"start"},children:[y.jsxs(k.Box,{sx:{minWidth:0,pt:.75},children:[y.jsx(k.Typography,{variant:"body2",sx:{fontFamily:"ui-monospace, monospace",fontSize:13},children:v.name}),y.jsxs(k.Typography,{variant:"caption",sx:{color:a.tileTitle,display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:v.expression,children:["is ",v.expression]})]}),y.jsx(k.TextField,{select:!0,size:"small",label:"Clicks go to",value:v.to,inputProps:{"aria-label":`Where ${v.name} goes`},SelectProps:{multiple:!0,renderValue:w=>w.length===0?"Not clickable":w.map(h).join(", "),displayEmpty:!0},InputLabelProps:{shrink:!0},onChange:w=>d(p,x=>{const m=w.target.value;x.to=Array.isArray(m)?m:String(m).split(",").filter(Boolean)}),children:c.map(w=>y.jsxs(k.MenuItem,{value:w,children:[y.jsx(k.Checkbox,{size:"small",checked:v.to.includes(w),sx:{p:0,mr:1}}),y.jsx(k.ListItemText,{primary:h(w)})]},w))}),y.jsxs(k.TextField,{select:!0,size:"small",label:"Sets the control",value:v.given,disabled:v.to.length===0,inputProps:{"aria-label":`Control ${v.name} sets`},SelectProps:{displayEmpty:!0},InputLabelProps:{shrink:!0},helperText:v.given===""?`Named ${v.name}, like the dimension`:void 0,onChange:w=>d(p,x=>{x.given=w.target.value}),children:[y.jsx(k.MenuItem,{value:"",children:y.jsx("em",{children:"Same name as the dimension"})}),r.map(w=>y.jsx(k.MenuItem,{value:w,children:w},w))]})]},v.name))})})}const Dd=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function Lp({open:e,document:t,control:n,available:r,fieldsFor:i,onApply:s}){const o=S.useRef(n);e&&(o.current=n);const a=e?n:o.current,l=a!==void 0,[u,d]=S.useState({kind:"new"}),[c,h]=S.useState(""),[f,v]=S.useState("select"),[p,w]=S.useState(""),[x,m]=S.useState(""),[g,b]=S.useState([]),[_,$]=S.useState(!1),O=T=>t.sources.find(A=>A.name===T.source)?.base??T.source;S.useEffect(()=>{if(e)if(n){d({kind:"existing",name:n.name}),h(n.label??"");const T=gp(t,n);b(T);const A=T.filter(E=>E.include),q=new Set(A.map(E=>E.field));m(q.size===1?A[0].field:n.field??""),$(q.size>1)}else d({kind:"new"}),h(""),v("select"),m(""),w(new Date().toISOString().slice(0,10)),b(t.tiles.map(T=>({include:qs(T),field:""}))),$(!1)},[e,n,t]);const C=S.useMemo(()=>[...(t.localGivens??[]).map(T=>T.name),...r.map(T=>T.name)],[t,r]),I=S.useMemo(()=>x.trim()?pp(x.trim(),C):"",[x,C]),P=u.kind==="existing"?n??r.find(T=>T.name===u.name):I?{name:I,type:Br({name:I,label:c,kind:f,field:x}).type}:void 0,U=P?.type!==void 0&&!P.type.startsWith("filter<"),W=g.find(T=>T.include)?.op??$i(P?.type),M=(T,A)=>b(q=>q.map((E,D)=>D===T?{...E,...A}:E)),z=T=>b(A=>A.map(q=>({...q,op:T}))),V=T=>{const A=$i(T);b(q=>q.map(({op:E,...D})=>A?{...D,op:A}:D))},ee=T=>{d({kind:"existing",name:T.name}),m(T.field??""),V(T.type)},Se=T=>{v(T),V(Br({name:"X",label:c,kind:T,field:x}).type)},oe=t.tiles.map(qs),Le=oe.filter(Boolean).length,Ve=g.filter((T,A)=>T.include&&oe[A]).length,Ce=t.tiles.filter((T,A)=>(g[A]?.include??!1)&&oe[A]),Ye=Ce.length>0?Ce:t.tiles.filter((T,A)=>oe[A]),Ge=S.useMemo(()=>{const T=new Map;let A=!1;for(const q of Ye){const E=i?.(q);if(E){A=!0;for(const D of E)T.has(D.name)||T.set(D.name,D)}}return A?[...T.values()]:void 0},[g,t.tiles,i]),We=(()=>{const T=x.trim();for(const A of Ce){const q=i?.(A);if(!q||q.some(E=>E.name===T))return O(A)}return Ce[0]?O(Ce[0]):t.sources[0]?.base})(),Xe=T=>b(A=>A.map((q,E)=>({...q,include:T&&oe[E]}))),$e=S.useMemo(()=>_?g:g.map(T=>({...T,field:x})),[_,g,x]),fe=T=>{for(const A of Ye){const q=i?.(A)?.find(E=>E.name===T.trim());if(q?.type)return q.type}},L=T=>ai(P?.type,T.type),G=(T,A)=>{if(T.trim()==="")return"Pick the field this filter compares.";const q=A?i?.(A):void 0;if(!q)return;const E=q.find(D=>D.name===T.trim());if(!E)return`Not a field of ${A?O(A):"the tiles' source"}.`;if(E.type&&!ai(P?.type,E.type))return`${T.trim()} is ${Ma(E.type)}; this filter compares ${Ma(P?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},_e=T=>{if(m(T),l||u.kind!=="new")return;const A=fe(T),q=Br({name:"X",label:c,kind:f,field:T}).type;A&&!ai(q,A)&&Se(fp(A))},X=$e.map((T,A)=>T.include&&oe[A]?G(T.field,t.tiles[A]):void 0),ze=X.every(T=>T===void 0),ne=!_&&Ve>0?Ce.map(T=>G(x,T)).find(Boolean):void 0,at=P!==void 0&&ze&&(u.kind==="existing"||x.trim()!==""&&I!==""),Fe=()=>{if(!(!P||!at))if(u.kind==="new")s(P.name,$e,Br({name:P.name,label:c.trim()||Dd(P.name),kind:f,field:x.trim(),...We?{source:We}:{},...p?{dateDefault:p}:{}}));else if(n?.origin==="dashboard"&&n.local){const T=c.trim(),A=T!==(n.local.label??"");s(P.name,$e,A?{...n.local,...T?{label:T}:{}}:void 0)}else s(P.name,$e)},xt=l&&a.origin==="model";return{editing:l,shown:a,fromModel:xt,source:u,setSource:d,label:c,setLabel:h,kind:f,dateDefault:p,setDateDefault:w,field:x,rows:g,setRows:b,perTile:_,setPerTile:$,newName:I,target:P,valueTyped:U,commonOp:W,setRow:M,setCommonOp:z,pickExisting:ee,pickKind:Se,bindable:oe,bindableCount:Le,included:Ve,commonFields:Ge,setAll:Xe,accepts:L,pickField:_e,rowProblems:X,commonProblem:ne,canApply:at,apply:Fe}}function La({value:e,onChange:t,fields:n,accepts:r,label:i,ariaLabel:s,error:o,helperText:a,disabled:l,autoFocus:u,placeholder:d,sx:c}){const h=S.useMemo(()=>(n??[]).filter(v=>r?.(v)??!0).map(v=>v.name),[n,r]),f=S.useMemo(()=>new Map((n??[]).map(v=>[v.name,v.type])),[n]);return y.jsx(k.Autocomplete,{freeSolo:!0,size:"small",options:h,inputValue:e,onInputChange:(v,p)=>t(p),value:e,onChange:(v,p)=>t(typeof p=="string"?p:""),disabled:l,disableClearable:!0,renderOption:(v,p)=>S.createElement("li",{...v,key:p},y.jsx(k.Typography,{variant:"body2",sx:{flex:1},children:p}),f.get(p)&&y.jsx(k.Typography,{variant:"caption",sx:{opacity:.6},children:f.get(p)?.replace(/_type$/,"")})),renderInput:v=>y.jsx(k.TextField,{...v,label:i,placeholder:d,autoFocus:u,error:o,helperText:a,inputProps:{...v.inputProps,"aria-label":s}}),sx:c})}const Wa=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 Wp({open:e,document:t,control:n,available:r,fieldsFor:i,onClose:s,onApply:o,onRemove:a}){const{theme:l}=Be.usePublisherTheme(),{editing:u,shown:d,fromModel:c,source:h,setSource:f,label:v,setLabel:p,kind:w,dateDefault:x,setDateDefault:m,field:g,rows:b,setRows:_,perTile:$,setPerTile:O,newName:C,target:I,valueTyped:P,commonOp:U,setRow:W,setCommonOp:M,pickExisting:z,pickKind:V,bindable:ee,bindableCount:Se,included:oe,commonFields:Le,setAll:Ve,accepts:Ce,pickField:Ye,rowProblems:Ge,commonProblem:We,canApply:Xe,apply:$e}=Lp({open:e,document:t,control:n,available:r,fieldsFor:i,onApply:o}),fe=(L,G,_e)=>y.jsx(k.TextField,{select:!0,size:"small",label:"Compares",value:L??">=",onChange:X=>G(X.target.value),inputProps:{"aria-label":_e},sx:{width:130},children:hp.filter(X=>X.op!=="~").map(X=>y.jsx(k.MenuItem,{value:X.op,children:X.label},X.op))});return y.jsx(j.AppDialog,{open:e,onClose:s,title:u?d.label??d.name:"Add a filter",description:u?y.jsxs(y.Fragment,{children:[y.jsxs(k.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 control on the page, and the tiles it filters.",actions:y.jsxs(y.Fragment,{children:[u&&y.jsx(k.Button,{color:"error",onClick:()=>a(d.name),"aria-label":`Remove control ${d.name}`,sx:{mr:"auto"},children:"Remove from dashboard"}),y.jsx(k.Button,{onClick:s,children:"Cancel"}),y.jsx(k.Tooltip,{title:Xe||I===void 0?"":"A ticked tile has no field, or names one its source does not have.",children:y.jsx("span",{children:y.jsx(k.Button,{variant:"contained",onClick:$e,disabled:!Xe,children:u?"Apply":"Add filter"})})})]}),children:y.jsxs(k.Stack,{sx:{gap:2.5,pt:1},children:[!u&&r.length>0&&y.jsxs(k.ToggleButtonGroup,{exclusive:!0,size:"small",value:h.kind,onChange:(L,G)=>{G==="new"?f({kind:"new"}):G==="existing"&&r[0]&&z(r[0])},"aria-label":"Where the filter comes from",children:[y.jsx(k.ToggleButton,{value:"new",children:"New in this dashboard"}),y.jsx(k.ToggleButton,{value:"existing",children:"From the model"})]}),!u&&h.kind==="existing"?y.jsx(k.TextField,{select:!0,size:"small",label:"Control",value:h.name,onChange:L=>{const G=r.find(_e=>_e.name===L.target.value);G&&z(G)},children:r.map(L=>y.jsxs(k.MenuItem,{value:L.name,children:[L.label??L.name,y.jsxs(k.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",L.name]})]},L.name))}):null,y.jsxs(k.Stack,{direction:"row",sx:{gap:1.5,flexWrap:"wrap"},children:[!$&&y.jsx(La,{value:g,onChange:Ye,fields:Le,accepts:Ce,label:"Field to filter",ariaLabel:"Field to filter",placeholder:"category",autoFocus:!u,error:We!==void 0,helperText:We??(!u&&C?`Declared as $${C}`:void 0),sx:{flex:1,minWidth:200}}),!c&&y.jsx(k.TextField,{size:"small",label:"Label",placeholder:C?Dd(C):"",value:v,onChange:L=>p(L.target.value),inputProps:{"aria-label":"Control label"},sx:{flex:1,minWidth:160}}),P&&!$&&fe(U,M,"Comparison")]}),!u&&h.kind==="new"&&y.jsxs(k.Stack,{direction:"row",sx:{gap:1.5},children:[y.jsx(k.TextField,{select:!0,size:"small",label:"Control",value:w,onChange:L=>V(L.target.value),inputProps:{"aria-label":"Kind of control"},slotProps:{select:{renderValue:L=>Ia.find(G=>G.kind===L)?.label??String(L)}},sx:{flex:1},children:Ia.map(L=>y.jsxs(k.MenuItem,{value:L.kind,children:[L.label,y.jsx(k.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:L.hint})]},L.kind))}),w==="date"&&y.jsx(k.TextField,{size:"small",type:"date",label:"Starts at",value:x,onChange:L=>m(L.target.value),InputLabelProps:{shrink:!0},sx:{flex:1}})]}),y.jsxs(k.Box,{children:[y.jsxs(k.Stack,{direction:"row",sx:{alignItems:"center",gap:.5},children:[y.jsx(k.Checkbox,{size:"small",checked:Se>0&&oe===Se,indeterminate:oe>0&&oe<Se,disabled:Se===0,onChange:L=>Ve(L.target.checked),inputProps:{"aria-label":"All tiles"}}),y.jsxs(k.Typography,{variant:"subtitle2",sx:{flex:1},children:["Applies to ",oe," of ",t.tiles.length," tiles"]}),y.jsx(k.Button,{size:"small",onClick:()=>{$||_(L=>L.map(G=>({...G,field:g}))),O(L=>!L)},children:$?"Same field for all":"Adjust per tile"})]}),y.jsx(k.Stack,{sx:{gap:$?1:0},children:t.tiles.map((L,G)=>{const _e=b[G],X=L.label??L.name,ze=$?Ge[G]:void 0;return y.jsxs(k.Stack,{direction:"row",sx:{gap:1,alignItems:$?"flex-start":"center",opacity:ee[G]?1:.6},children:[y.jsx(k.Checkbox,{size:"small",disabled:!ee[G],checked:(_e?.include??!1)&&ee[G],inputProps:{"aria-label":`Filter ${X}`},onChange:ne=>W(G,{include:ne.target.checked})}),y.jsx(k.Typography,{variant:"body2",sx:{flex:1,minWidth:0,pt:$?1:0},noWrap:!0,children:X}),ee[G]?$&&y.jsxs(y.Fragment,{children:[P&&fe(_e?.op,ne=>W(G,{op:ne}),`Comparison for ${X}`),y.jsx(La,{value:_e?.field??"",onChange:ne=>W(G,{field:ne}),fields:i?.(L),accepts:Ce,label:"Field",ariaLabel:`Field for ${X}`,disabled:!_e?.include,error:ze!==void 0,helperText:ze,sx:{width:220}})]}):y.jsx(k.Tooltip,{title:Wa(t.tiles[G]).reason,children:y.jsx(k.Typography,{variant:"caption",sx:{color:l.tileTitle},children:Wa(t.tiles[G]).label})})]},`${L.source}.${L.name}`)})}),oe===0&&y.jsx(k.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."})]})]})})}function Cd(e,t,n,r){const[i,s]=S.useState(void 0);return S.useEffect(()=>{t&&e!==void 0&&s(structuredClone(e))},[t,e]),{draft:i,patch:u=>s(d=>{if(d===void 0)return d;const c=structuredClone(d);return u(c),c}),close:()=>{i!==void 0&&e!==void 0&&JSON.stringify(i)!==JSON.stringify(e)&&n(i),r()},discard:()=>s(void 0)}}const zp=e=>({title:e.title,...e.description===void 0?{}:{description:e.description},...e.columns===void 0?{}:{columns:e.columns},...e.autorun===void 0?{}:{autorun:e.autorun}}),ss=[2,3,4,6,8,12,16,24];function Fp({anchor:e,settings:t,onClose:n,onCommit:r}){const{theme:i}=Be.usePublisherTheme(),{draft:s,patch:o,close:a}=Cd(t,e!==null,r,n),l=s?.columns!==void 0&&!ss.includes(s.columns)?[...ss,s.columns].sort((u,d)=>u-d):ss;return y.jsx(k.Popover,{open:e!==null&&s!==void 0,anchorEl:e,onClose:a,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{width:380,p:2}}},children:s&&y.jsxs(k.Stack,{sx:{gap:1.5},children:[y.jsx(k.Typography,{variant:"overline",sx:{color:i.tileTitle,lineHeight:1.5},children:"Dashboard"}),y.jsx(k.TextField,{size:"small",label:"Title",value:s.title,autoFocus:!0,inputProps:{"aria-label":"Dashboard title"},onChange:u=>o(d=>{d.title=u.target.value})}),y.jsx(k.TextField,{size:"small",label:"Description",multiline:!0,minRows:3,maxRows:10,value:s.description??"",helperText:"Markdown. A blank line starts a new paragraph.",inputProps:{"aria-label":"Dashboard description"},onChange:u=>o(d=>{const c=u.target.value;c.trim()===""?delete d.description:d.description=c})}),y.jsxs(k.TextField,{select:!0,size:"small",label:"Grid width",value:s.columns??"",helperText:"Columns across the page. Tiles are placed in these.",inputProps:{"aria-label":"Grid width"},onChange:u=>o(d=>{const c=Number(u.target.value);c?d.columns=c:delete d.columns}),children:[y.jsx(k.MenuItem,{value:"",children:"Default (2)"}),l.map(u=>y.jsx(k.MenuItem,{value:u,children:u},u))]}),y.jsx(k.FormControlLabel,{control:y.jsx(k.Switch,{size:"small",checked:s.autorun!==!1,slotProps:{input:{"aria-label":"Run as controls change"}},onChange:u=>o(d=>{u.target.checked?delete d.autorun:d.autorun=!1})}),label:y.jsxs(k.Typography,{variant:"body2",children:["Run as controls change",y.jsx(k.Typography,{component:"span",variant:"caption",sx:{display:"block",opacity:.7},children:"Off, readers press Apply. For a page whose queries are slow."})]})})]})})}const Np=j.createSvgIcon(y.jsx("path",{d:"M10 18h4v-2h-4zM3 6v2h18V6zm3 7h12v-2H6z"}));function Bp({controls:e,tileCount:t,unknownFieldsOf:n,onEdit:r,onAdd:i,children:s}){const{theme:o}=Be.usePublisherTheme();return y.jsx(y.Fragment,{children:y.jsxs(k.Stack,{sx:{gap:1},children:[y.jsxs(k.Stack,{direction:"row","aria-label":"Filters",sx:{gap:1,alignItems:"center",flexWrap:"wrap",minHeight:32},children:[y.jsx(Np,{sx:{fontSize:18,color:o.tileTitle,opacity:.7}}),y.jsx(k.Typography,{variant:"subtitle2",sx:{color:o.tileTitle,mr:.5},children:"Filters"}),e.length===0&&y.jsx(k.Typography,{variant:"body2",sx:{color:o.tileTitle,opacity:.8},children:"None yet."}),e.map(a=>{const l=n(a.name,a.type);return y.jsx(k.Tooltip,{title:l.length>0?`$${a.name} · cannot filter on: ${l.join(", ")}`:`$${a.name} · ${a.origin==="dashboard"?"declared here":"from the model"} · ${a.boundTiles} of ${t} tiles`,children:y.jsx(k.Chip,{size:"small",label:a.label??a.name,"aria-label":`Edit filter ${a.name}`,color:l.length>0?"warning":"default",variant:a.origin==="dashboard"?"filled":"outlined",onClick:()=>r(a),sx:{opacity:a.boundTiles===0?.6:1,cursor:"pointer",transition:"opacity 120ms"}})},a.name)}),y.jsx(k.Box,{sx:{ml:"auto"},children:y.jsx(j.SecondaryButton,{label:"Filter",icon:y.jsx(j.AddIcon,{}),onClick:()=>i(),ariaLabel:"Add filter",ariaHasPopup:"dialog"})})]}),s]})})}const Vp=(e,t)=>e.map((n,r)=>{const i=t[r]??!1;if(i===(n.break??!1))return n;const s={...n};return i?s.break=!0:delete s.break,s}),Gp=(e,t,n)=>{const r=[...e],[i]=r.splice(t,1);if(!i)return[...e];const s=r[t];i.break&&s&&!s.break&&(r[t]={...s,break:!0});const o={...i};return delete o.break,r.splice(n,0,o),r},Pd=(e,t)=>({kind:"tile",tile:e,index:t,colspan:e.colspan,break:e.break}),Md=e=>`gap.${e}`,Up=(e,t)=>{const n=[];let r=0;e.forEach((s,o)=>{const a=Math.min(s.colspan??1,t),l=o===0||s.break===!0||r+a>t;l&&o>0&&r<t&&n.push({kind:"gap",after:pt(e[o-1]),colspan:t-r}),l&&(r=0),n.push(Pd(s,o)),r+=a});const i=e.at(-1);return i&&r<t&&n.push({kind:"gap",after:pt(i),colspan:t-r}),n};var qp=Object.create,Id=Object.defineProperty,Hp=Object.defineProperties,Kp=Object.getOwnPropertyDescriptor,Yp=Object.getOwnPropertyDescriptors,Ei=Object.getOwnPropertySymbols,jd=Object.prototype.hasOwnProperty,Ad=Object.prototype.propertyIsEnumerable,Xp=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ir=e=>{throw TypeError(e)},Ks=(e,t,n)=>t in e?Id(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,os=(e,t)=>{for(var n in t||(t={}))jd.call(t,n)&&Ks(e,n,t[n]);if(Ei)for(var n of Ei(t))Ad.call(t,n)&&Ks(e,n,t[n]);return e},as=(e,t)=>Hp(e,Yp(t)),Qp=(e,t)=>{var n={};for(var r in e)jd.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ei)for(var r of Ei(e))t.indexOf(r)<0&&Ad.call(e,r)&&(n[r]=e[r]);return n},Zp=e=>{var t;return[,,,qp((t=void 0)!=null?t:null)]},Rd=["class","method","getter","setter","accessor","field","value","get","set"],ir=e=>e!==void 0&&typeof e!="function"?Ir("Function expected"):e,Jp=(e,t,n,r,i)=>({kind:Rd[e],name:t,metadata:r,addInitializer:s=>n._?Ir("Already initialized"):i.push(ir(s||null))}),eg=(e,t)=>Ks(t,Xp("metadata"),e[3]),Gr=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)t&1?s[i].call(n):r=s[i].call(n,r);return r},Ld=(e,t,n,r,i,s)=>{for(var o,a,l,u,d,c=t&7,h=!1,f=!1,v=e.length+1,p=Rd[c+5],w=e[v-1]=[],x=e[v]||(e[v]=[]),m=(i=i.prototype,Kp({get[n](){return sr(this,s)},set[n](b){return Ft(this,s,b)}},n)),g=r.length-1;g>=0;g--)u=Jp(c,n,l={},e[3],x),u.static=h,u.private=f,d=u.access={has:b=>n in b},d.get=b=>b[n],d.set=(b,_)=>b[n]=_,a=(0,r[g])({get:m.get,set:m.set},u),l._=1,a===void 0?ir(a)&&(m[p]=a):typeof a!="object"||a===null?Ir("Object expected"):(ir(o=a.get)&&(m.get=o),ir(o=a.set)&&(m.set=o),ir(o=a.init)&&w.unshift(o));return m&&Id(i,n,m),i},Wd=(e,t,n)=>t.has(e)||Ir("Cannot "+n),sr=(e,t,n)=>(Wd(e,t,"read from private field"),t.get(e)),Un=(e,t,n)=>t.has(e)?Ir("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ft=(e,t,n,r)=>(Wd(e,t,"write to private field"),t.set(e,n),n);function Bt(e){return e instanceof ta||e instanceof Bd}var Ur=10,tg=class extends Me{constructor(e){super(e);const t=tt(()=>{const{dragOperation:r}=e;if(br(r.activatorEvent)&&Bt(r.source)&&r.status.initialized){const i=e.registry.plugins.get(Pr);if(i)return i.disable(),()=>i.enable()}}),n=e.monitor.addEventListener("dragmove",(r,i)=>{queueMicrotask(()=>{if(this.disabled||r.defaultPrevented||!r.nativeEvent)return;const{dragOperation:s}=i;if(!br(r.nativeEvent)||!Bt(s.source)||!s.shape)return;const{actions:o,collisionObserver:a,registry:l}=i,{by:u}=r;if(!u)return;const d=ng(u),{source:c,target:h}=s,{center:f}=s.shape.current,v=[],p=[];ue(()=>{for(const _ of l.droppables){const{id:$}=_;if(!_.accepts(c)||$===h?.id&&Bt(_)||!_.element)continue;let O=_.shape;const C=new ct(_.element,{getBoundingClientRect:I=>mr(I,void 0,.2)});!C.height||!C.width||(d=="down"&&f.y+Ur<C.center.y||d=="up"&&f.y-Ur>C.center.y||d=="left"&&f.x-Ur>C.center.x||d=="right"&&f.x+Ur<C.center.x)&&(v.push(_),_.shape=C,p.push(()=>_.shape=O))}}),r.preventDefault(),a.disable();const w=a.computeCollisions(v,Gf);ue(()=>p.forEach(_=>_()));const[x]=w;if(!x)return;const{id:m}=x,{index:g,group:b}=c.sortable;o.setDropTarget(m).then(()=>{const{source:_,target:$,shape:O}=s;if(!_||!Bt(_)||!O)return;const{index:C,group:I,target:P}=_.sortable,U=g!==C||b!==I,W=U?P:$?.element;if(!W)return;Mc(W);const M=new ct(W);if(!M)return;const z=dt.delta(M,dt.from(O.current.boundingRectangle),_.alignment);o.move({by:z}),U?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 rg=Object.defineProperty,ig=Object.defineProperties,sg=Object.getOwnPropertyDescriptors,za=Object.getOwnPropertySymbols,og=Object.prototype.hasOwnProperty,ag=Object.prototype.propertyIsEnumerable,Fa=(e,t,n)=>t in e?rg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,nn=(e,t)=>{for(var n in t||(t={}))og.call(t,n)&&Fa(e,n,t[n]);if(za)for(var n of za(t))ag.call(t,n)&&Fa(e,n,t[n]);return e},rn=(e,t)=>ig(e,sg(t));function lg(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function qr(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function ls(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function cg(e,t,n){var r,i;const{source:s,target:o,canceled:a}=t.operation;if(!s||!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(_,s.id)),b=e.findIndex(_=>l(_,o.id));if(g===-1||b===-1){if(ls(s)){const _=s.initialIndex,$=s.index;return _===$||_<0||_>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,_,$)}return e}if(!a&&"index"in s&&typeof s.index=="number"){const _=s.index;if(_!==g)return n(e,g,_)}return n(e,g,b)}const u=Object.entries(e);let d=-1,c,h=-1,f;for(const[g,b]of u)if(d===-1&&(d=b.findIndex(_=>l(_,s.id)),d!==-1&&(c=g)),h===-1&&(h=b.findIndex(_=>l(_,o.id)),h!==-1&&(f=g)),d!==-1&&h!==-1)break;if(d===-1&&ls(s)){const g=s.initialGroup==null?void 0:qr(e,s.initialGroup),b=s.initialIndex,_=s.group==null?void 0:qr(e,s.group),$=s.index;if(g==null||_==null||g===_&&b===$)return"preventDefault"in t&&t.preventDefault(),e;if(g===_)return rn(nn({},e),{[g]:n(e[g],b,$)});const O=e[g][b];return rn(nn({},e),{[g]:[...e[g].slice(0,b),...e[g].slice(b+1)],[_]:[...e[_].slice(0,$),O,...e[_].slice($)]})}if(!s.manager)return e;const{dragOperation:v}=s.manager,p=(i=(r=v.shape)==null?void 0:r.current.center)!=null?i:v.position.current;if(f==null){const g=qr(e,o.id);if(g!=null){const b=o.shape&&p.y>o.shape.center.y?e[g].length:0;f=g,h=b}}if(c==null||f==null||c===f&&d===h){if(c!=null&&c===f&&d===h&&ls(s)){const g=s.group==null?void 0:qr(e,s.group),b=s.group!=null&&g!==c,_=s.index!==d;if(b||_){const $=s.group==null?c:g;if($!=null){if(c===$)return rn(nn({},e),{[c]:n(e[c],d,s.index)});const O=e[c][d];return rn(nn({},e),{[c]:[...e[c].slice(0,d),...e[c].slice(d+1)],[$]:[...e[$].slice(0,s.index),O,...e[$].slice(s.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(c===f)return rn(nn({},e),{[c]:n(e[c],d,h)});const x=o.shape&&Math.round(p.y)>Math.round(o.shape.center.y)?1:0,m=e[c][d];return rn(nn({},e),{[c]:[...e[c].slice(0,d),...e[c].slice(d+1)],[f]:[...e[f].slice(0,h+x),m,...e[f].slice(h+x)]})}function dg(e,t){return cg(e,t,lg)}function Na(e){const t=new Map;for(const[,n]of e)for(const r of n)t.set(r.id,r.index);return t}function Ba(e,t,n){var r;for(const[i,s]of t)for(const o of s){const a=e.get(o.id);if(o.index!==a||o.group!==i||!((r=n.get(i))!=null&&r.has(o)))return!0}return!1}var Va="__default__",ug=class extends Me{constructor(e){super(e);const t=()=>{const r=new Map;for(const i of e.registry.droppables)if(i instanceof ta){const{sortable:s}=i,{group:o}=s;let a=r.get(o);a||(a=new Set,r.set(o,a)),a.add(s)}return r},n=[e.monitor.addEventListener("dragover",(r,i)=>{if(this.disabled)return;const{dragOperation:s}=i,{source:o,target:a}=s;if(!Bt(o)||!Bt(a)||o.sortable===a.sortable)return;const l=t(),u=Na(l),d=o.sortable.group===a.sortable.group,c=l.get(o.sortable.group),h=d?c:l.get(a.sortable.group);!c||!h||queueMicrotask(()=>{r.defaultPrevented||i.renderer.rendering.then(()=>{var f,v;const p=t();if(Ba(u,l,p))return;const w=o.sortable.element,x=a.sortable.element;if(!x||!w||!d&&a.id===o.sortable.group)return;const m=Hr(c),g=d?m:Hr(h),b=(f=o.sortable.group)!=null?f:Va,_=(v=a.sortable.group)!=null?v:Va,$={[b]:m,[_]:g},O=dg($,r);if($===O)return;const C=O[_].indexOf(o.sortable),I=O[_].indexOf(a.sortable);i.collisionObserver.disable(),Ga(w,C,x,I),ue(()=>{for(const[P,U]of O[b].entries())U.index=P;if(!d)for(const[P,U]of O[_].entries())U.group=a.sortable.group,U.index=P}),i.actions.setDropTarget(o.id).then(()=>i.collisionObserver.enable())})})}),e.monitor.addEventListener("dragend",(r,i)=>{if(!r.canceled)return;const{dragOperation:s}=i,{source:o}=s;Bt(o)&&(o.sortable.initialIndex===o.sortable.index&&o.sortable.initialGroup===o.sortable.group||queueMicrotask(()=>{const a=t(),l=Na(a),u=a.get(o.sortable.initialGroup);u&&i.renderer.rendering.then(()=>{const d=t();if(Ba(l,a,d))return;const c=Hr(u),h=Hr(u,hg),f=o.sortable.element,v=h.indexOf(o.sortable),p=c[v],w=p?.element;!p||!w||!f||(Ga(f,p.index,w,o.index),ue(()=>{for(const x of a.values()){const m=Array.from(x).values();for(const g of m)g.index=g.initialIndex,g.group=g.initialGroup}}))})}))})];this.destroy=()=>{for(const r of n)r()}}};function Ga(e,t,n,r){const i=r<t?"afterend":"beforebegin";n.insertAdjacentElement(i,e)}function fg(e,t){return e.index-t.index}function hg(e,t){return e.initialIndex-t.initialIndex}function Hr(e,t=fg){return Array.from(e).sort(t)}var Ua=[tg,ug],zd={duration:250,easing:"cubic-bezier(0.25, 1, 0.5, 1)",idle:!1};function qa(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 Kr=new Eu,Fd,Nd,Ot,Jo,or,ar,ea,hn;Nd=[K],Fd=[K];var Bi=class{constructor(e,t){Un(this,Jo,Gr(Ot,8,this)),Gr(Ot,11,this),Un(this,or),Un(this,ar),Un(this,ea,Gr(Ot,12,this)),Gr(Ot,15,this),Un(this,hn),this.register=()=>(ue(()=>{var v,p;(v=this.manager)==null||v.registry.register(this.droppable),(p=this.manager)==null||p.registry.register(this.draggable)}),()=>this.unregister()),this.unregister=()=>{ue(()=>{var v,p;(v=this.manager)==null||v.registry.unregister(this.droppable),(p=this.manager)==null||p.registry.unregister(this.draggable)})},this.destroy=()=>{ue(()=>{this.droppable.destroy(),this.draggable.destroy()})};var n=e,{effects:r=()=>[],disabled:i,group:s,index:o,sensors:a,type:l,transition:u=zd,plugins:d}=n,c=Qp(n,["effects","disabled","group","index","sensors","type","transition","plugins"]);const h=st(d,Ua),f=qa(i);this.droppable=new ta(as(os({},c),{disabled:f.droppable}),t,this),this.draggable=new Bd(as(os({},c),{disabled:f.draggable,plugins:h,effects:()=>[()=>{var v,p,w;const x=(v=this.manager)==null?void 0:v.dragOperation.status;x?.initializing&&this.id===((w=(p=this.manager)==null?void 0:p.dragOperation.source)==null?void 0:w.id)&&Kr.clear(this.manager),x?.dragging&&Kr.set(this.manager,this.id,H(()=>({initialIndex:this.index,initialGroup:this.group})))},()=>{const{index:v,group:p,manager:w}=this,x=sr(this,ar),m=sr(this,or);(v!==x||p!==m)&&(Ft(this,ar,v),Ft(this,or,p),this.animate())},()=>{var v,p;const{target:w}=this,{isDragSource:x}=this.draggable;((p=(v=this.draggable.pluginConfig(Go))==null?void 0:v.feedback)!=null?p:"default")==="move"&&x&&(this.droppable.disabled=!w)},...r()],type:l,sensors:a}),t,this),Ft(this,hn,c.element),this.manager=t,this.index=o,Ft(this,ar,o),this.group=s,Ft(this,or,s),this.type=l,this.transition=u}get initialIndex(){var e,t;return(t=(e=Kr.get(this.manager,this.id))==null?void 0:e.initialIndex)!=null?t:this.index}get initialGroup(){var e,t;return(t=(e=Kr.get(this.manager,this.id))==null?void 0:e.initialGroup)!=null?t:this.group}animate(){H(()=>{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:i}=this;if(!i)return;for(const d of i.getAnimations())"transitionProperty"in d&&(d.transitionProperty==="transform"||d.transitionProperty==="translate"||d.transitionProperty==="scale")&&d.cancel();const s=this.refreshShape();if(!s)return;const o={x:n.boundingRectangle.left-s.boundingRectangle.left,y:n.boundingRectangle.top-s.boundingRectangle.top},{translate:a}=ht(i),l=_a(i,a,!1),u=_a(i,a);if(o.x||o.y){const d=Ro(Ke(i))?as(os({},t),{duration:0}):t;Ic({element:i,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){ue(()=>{this.draggable.manager=e,this.droppable.manager=e})}set element(e){ue(()=>{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),Ft(this,hn,e)})}get element(){var e,t;const n=sr(this,hn);if(n)return(t=(e=Os.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=st(e,Ua)}set disabled(e){const t=qa(e);ue(()=>{this.droppable.disabled=t.droppable,this.draggable.disabled=t.draggable})}set data(e){ue(()=>{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??jc}set alignment(e){this.draggable.alignment=e}get alignment(){return this.draggable.alignment}set type(e){ue(()=>{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)}};Ot=Zp();Jo=new WeakMap;or=new WeakMap;ar=new WeakMap;ea=new WeakMap;hn=new WeakMap;Ld(Ot,4,"index",Nd,Bi,Jo);Ld(Ot,4,"group",Fd,Bi,ea);eg(Ot,Bi);var Bd=class extends zi{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}},ta=class extends Fi{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}get group(){return this.sortable.group}},pg=Object.defineProperty,gg=Object.defineProperties,vg=Object.getOwnPropertyDescriptors,Ha=Object.getOwnPropertySymbols,mg=Object.prototype.hasOwnProperty,yg=Object.prototype.propertyIsEnumerable,Ka=(e,t,n)=>t in e?pg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,cs=(e,t)=>{for(var n in t||(t={}))mg.call(t,n)&&Ka(e,n,t[n]);if(Ha)for(var n of Ha(t))yg.call(t,n)&&Ka(e,n,t[n]);return e},bg=(e,t)=>gg(e,vg(t));function xg(e){const{accept:t,collisionDetector:n,collisionPriority:r,id:i,data:s,element:o,handle:a,index:l,group:u,disabled:d,modifiers:c,sensors:h,target:f,type:v,plugins:p}=e,w=cs(cs({},zd),e.transition),x=vd(g=>new Bi(bg(cs({},e),{transition:w,register:!1,handle:yn(a),element:yn(o),target:yn(f)}),g)),m=fd(x,wg);return le(i,()=>x.id=i),Ln(()=>{ue(()=>{x.group=u,x.index=l})},[x,u,l]),le(v,()=>x.type=v),le(t,()=>x.accept=t,void 0,rt),le(s,()=>s&&(x.data=s)),le(l,()=>{var g;(g=x.manager)!=null&&g.dragOperation.status.idle&&w?.idle&&x.refreshShape()},Wh),si(a,g=>x.handle=g),si(o,g=>x.element=g),si(f,g=>x.target=g),le(d,()=>x.disabled=d??!1,void 0,rt),le(h,()=>x.sensors=h,void 0,rt),le(n,()=>x.collisionDetector=n),le(r,()=>x.collisionPriority=r),le(p,()=>x.plugins=p,void 0,rt),le(w,()=>x.transition=w,void 0,rt),le(c,()=>x.modifiers=c,void 0,rt),le(e.alignment,()=>x.alignment=e.alignment),{sortable:m,get isDragging(){return m.isDragging},get isDropping(){return m.isDropping},get isDragSource(){return m.isDragSource},get isDropTarget(){return m.isDropTarget},handleRef:S.useCallback(g=>{x.handle=g??void 0},[x]),ref:S.useCallback(g=>{var b,_;!g&&((b=x.element)!=null&&b.isConnected)&&!((_=x.manager)!=null&&_.dragOperation.status.idle)||(x.element=g??void 0)},[x]),sourceRef:S.useCallback(g=>{var b,_;!g&&((b=x.source)!=null&&b.isConnected)&&!((_=x.manager)!=null&&_.dragOperation.status.idle)||(x.source=g??void 0)},[x]),targetRef:S.useCallback(g=>{var b,_;!g&&((b=x.target)!=null&&b.isConnected)&&!((_=x.manager)!=null&&_.dragOperation.status.idle)||(x.target=g??void 0)},[x])}}function wg(e,t,n){return!!(e==="isDragSource"&&!n&&t)}const Ys="tile",Vd="gap",_g='[role="separator"]',kg=[Ns.configure({activatorElements:e=>[e.element],preventActivation:(e,t)=>(Ns.defaults.preventActivation?.(e,t)??!1)||e.target instanceof Element&&e.target.closest(_g)!==null}),id],Sg=e=>[...e,Go.configure({feedback:"clone"})];function $g({id:e,index:t,children:n}){const{ref:r,handleRef:i,isDragSource:s}=xg({id:e,index:t,type:Ys,accept:Ys,collisionDetector:Wo,plugins:Sg});return y.jsx(y.Fragment,{children:n({ref:r,handleRef:i,isDragSource:s})})}function Eg({id:e,after:t,children:n}){const{ref:r,isDropTarget:i}=cp({id:e,type:Vd,accept:Ys,collisionDetector:Wo,data:{after:t}});return y.jsx(y.Fragment,{children:n({ref:r,isDropTarget:i})})}const Og=j.createSvgIcon(y.jsx("path",{d:"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2m-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"})),Tg=j.createSvgIcon(y.jsx("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"}));function Dg({tile:e,index:t,selected:n,menuOpen:r,resizeSpan:i,columns:s,onSelect:o,onOpenMenu:a,onResizeStart:l,onResizeMove:u,onResizeEnd:d,children:c}){const{theme:h}=Be.usePublisherTheme();return y.jsx($g,{id:pt(e),index:t,children:({ref:f,handleRef:v,isDragSource:p})=>y.jsxs(k.Box,{ref:f,onClick:o,onPointerDown:w=>{w.button===0&&o()},"aria-label":`Tile ${e.name}`,"aria-current":n,sx:{position:"relative",display:"grid",minWidth:0,cursor:"grab",borderRadius:1,outline:n?`2px solid ${h.drillLink}`:"2px solid transparent",outlineOffset:2,transition:"outline-color 120ms, opacity 120ms, box-shadow 120ms","&&[data-dnd-dragging]":{opacity:1,outline:"none",boxShadow:"0 12px 32px rgba(0, 0, 0, 0.22)"},"&&[data-dnd-placeholder]":{opacity:.45,outline:`2px dashed ${h.drillLink}`,boxShadow:"none"},"&:hover .builder-affordance, &:focus-within .builder-affordance":{opacity:1},"&:hover":{outlineColor:n?h.drillLink:h.cardBorder,boxShadow:"0 2px 10px rgba(0, 0, 0, 0.10)"}},children:[c,y.jsx(k.Box,{ref:v,className:"builder-affordance","aria-label":`Move ${e.label??e.name}`,sx:{position:"absolute",top:"2px",left:"2px",display:"grid",placeItems:"center",width:"22px",height:"22px",borderRadius:"4px",cursor:"grab",touchAction:"none",zIndex:2,color:h.tileTitle,bgcolor:h.tile,opacity:p||n?.9:0,transition:"opacity 120ms","&:hover":{opacity:1},"&:active":{cursor:"grabbing"},"&:focus-visible":{opacity:1,outline:`2px solid ${h.drillLink}`,outlineOffset:1}},children:y.jsx(Og,{sx:{fontSize:16}})}),i===void 0&&y.jsx(k.IconButton,{className:"builder-affordance",size:"small","aria-label":`Settings for ${e.label??e.name}`,onClick:w=>{w.stopPropagation(),a(w.currentTarget)},sx:{position:"absolute",top:"2px",right:"2px",width:22,height:22,zIndex:2,color:h.tileTitle,bgcolor:h.tile,opacity:n||r?.9:0,transition:"opacity 120ms","&:hover":{opacity:1,bgcolor:h.tile}},children:y.jsx(Tg,{sx:{fontSize:16}})}),i!==void 0&&y.jsxs(k.Box,{"aria-hidden":!0,sx:{position:"absolute",top:"6px",right:"6px",px:.75,py:.25,borderRadius:"4px",bgcolor:h.drillLink,color:h.tile,fontSize:11,fontVariantNumeric:"tabular-nums",zIndex:4,pointerEvents:"none"},children:[i," of ",s," ·"," ",Math.round(i/s*100),"%"]}),e.declaration.kind!=="inherited"&&y.jsx(k.Box,{className:"builder-affordance",role:"separator","aria-orientation":"vertical","aria-label":`Resize ${e.label??e.name}`,onPointerDown:l,onPointerMove:u,onPointerUp:d,onPointerCancel:d,sx:{position:"absolute",top:0,bottom:0,right:"-5px",width:"10px",cursor:"col-resize",touchAction:"none",zIndex:1,opacity:i!==void 0||n?1:0,transition:"opacity 120ms","&:hover":{opacity:1},"&::after":{content:'""',position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"4px",height:"28px",borderRadius:"2px",bgcolor:h.drillLink}}})]})})}function Cg({tile:e}){const{theme:t}=Be.usePublisherTheme();return y.jsxs(j.TileCard,{sx:{minHeight:140},children:[y.jsx(j.TileHeading,{title:e.label??e.name,subtitle:e.subtitle}),y.jsxs(k.Typography,{variant:"caption",sx:{display:"block",color:t.tileTitle,opacity:.7},children:[e.source," → ",e.name]})]})}function Pg({after:e}){const{theme:t}=Be.usePublisherTheme();return y.jsx(Eg,{id:Md(e),after:e,children:({ref:n,isDropTarget:r})=>y.jsx(k.Box,{ref:n,"aria-hidden":!0,sx:{minHeight:48,borderRadius:1,border:`1px dashed ${t.drillLink}`,bgcolor:r?`color-mix(in srgb, ${t.drillLink} 12%, transparent)`:"transparent",opacity:r?.95:.4,transition:"opacity 120ms, background-color 120ms"}})})}function Mg({columns:e}){const{theme:t}=Be.usePublisherTheme();return y.jsx(k.Box,{"aria-hidden":!0,sx:{position:"absolute",inset:0,pointerEvents:"none",zIndex:3,display:"grid",gridTemplateColumns:`repeat(${e}, minmax(0, 1fr))`,gap:`${j.GRID_GAP_PX}px`},children:Array.from({length:e},(n,r)=>y.jsx(k.Box,{sx:{borderLeft:`1px dashed ${t.drillLink}`,borderRight:r===e-1?`1px dashed ${t.drillLink}`:"none",opacity:.35}},r))})}var Ig=Object.defineProperty,jg=Object.defineProperties,Ag=Object.getOwnPropertyDescriptors,Ya=Object.getOwnPropertySymbols,Rg=Object.prototype.hasOwnProperty,Lg=Object.prototype.propertyIsEnumerable,Xa=(e,t,n)=>t in e?Ig(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sn=(e,t)=>{for(var n in t||(t={}))Rg.call(t,n)&&Xa(e,n,t[n]);if(Ya)for(var n of Ya(t))Lg.call(t,n)&&Xa(e,n,t[n]);return e},on=(e,t)=>jg(e,Ag(t));function Wg(e,t,n){if(t===n)return e;const r=e.slice();return r.splice(n,0,r.splice(t,1)[0]),r}function Yr(e,t){const n=String(t);return Object.prototype.hasOwnProperty.call(e,n)?n:void 0}function ds(e){return"initialIndex"in e&&typeof e.initialIndex=="number"&&"index"in e&&typeof e.index=="number"}function zg(e,t,n){var r,i;const{source:s,target:o,canceled:a}=t.operation;if(!s||!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(_,s.id)),b=e.findIndex(_=>l(_,o.id));if(g===-1||b===-1){if(ds(s)){const _=s.initialIndex,$=s.index;return _===$||_<0||_>=e.length?("preventDefault"in t&&t.preventDefault(),e):n(e,_,$)}return e}if(!a&&"index"in s&&typeof s.index=="number"){const _=s.index;if(_!==g)return n(e,g,_)}return n(e,g,b)}const u=Object.entries(e);let d=-1,c,h=-1,f;for(const[g,b]of u)if(d===-1&&(d=b.findIndex(_=>l(_,s.id)),d!==-1&&(c=g)),h===-1&&(h=b.findIndex(_=>l(_,o.id)),h!==-1&&(f=g)),d!==-1&&h!==-1)break;if(d===-1&&ds(s)){const g=s.initialGroup==null?void 0:Yr(e,s.initialGroup),b=s.initialIndex,_=s.group==null?void 0:Yr(e,s.group),$=s.index;if(g==null||_==null||g===_&&b===$)return"preventDefault"in t&&t.preventDefault(),e;if(g===_)return on(sn({},e),{[g]:n(e[g],b,$)});const O=e[g][b];return on(sn({},e),{[g]:[...e[g].slice(0,b),...e[g].slice(b+1)],[_]:[...e[_].slice(0,$),O,...e[_].slice($)]})}if(!s.manager)return e;const{dragOperation:v}=s.manager,p=(i=(r=v.shape)==null?void 0:r.current.center)!=null?i:v.position.current;if(f==null){const g=Yr(e,o.id);if(g!=null){const b=o.shape&&p.y>o.shape.center.y?e[g].length:0;f=g,h=b}}if(c==null||f==null||c===f&&d===h){if(c!=null&&c===f&&d===h&&ds(s)){const g=s.group==null?void 0:Yr(e,s.group),b=s.group!=null&&g!==c,_=s.index!==d;if(b||_){const $=s.group==null?c:g;if($!=null){if(c===$)return on(sn({},e),{[c]:n(e[c],d,s.index)});const O=e[c][d];return on(sn({},e),{[c]:[...e[c].slice(0,d),...e[c].slice(d+1)],[$]:[...e[$].slice(0,s.index),O,...e[$].slice(s.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(c===f)return on(sn({},e),{[c]:n(e[c],d,h)});const x=o.shape&&Math.round(p.y)>Math.round(o.shape.center.y)?1:0,m=e[c][d];return on(sn({},e),{[c]:[...e[c].slice(0,d),...e[c].slice(d+1)],[f]:[...e[f].slice(0,h+x),m,...e[f].slice(h+x)]})}function Fg(e,t){return zg(e,t,Wg)}function Ng({tiles:e,commit:t,onLanded:n}){const[r,i]=S.useState(void 0),s=S.useRef(void 0),[o,a]=S.useState(!1);return{dragging:o,preview:r,onDragStart:()=>{a(!0),s.current=e},onDragOver:c=>{const{source:h,target:f}=c.operation;if(!h||!f)return;const v=s.current??e;let p;if(f.type===Vd){const{after:w}=f.data,x=v.findIndex(b=>pt(b)===h.id);if(x<0||w===h.id)return;const g=v.filter((b,_)=>_!==x).findIndex(b=>pt(b)===w)+1;p=Gp(v,x,g)}else{const w=v.map(pt),x=Fg(w,c);if(x.every((g,b)=>g===w[b]))return;const m=new Map(v.map(g=>[pt(g),g]));p=Vp(x.map(g=>m.get(g)),e.map(g=>g.break??!1))}s.current=p,i(p)},onDragEnd:c=>{a(!1);const h=s.current;if(s.current=void 0,i(void 0),c.canceled||!h)return;t(h);const f=h.findIndex(v=>pt(v)===c.operation.source?.id);f>=0&&n(f)}}}const Qa=e=>{const t=window.document.body;t.style.userSelect=e?"none":"",t.style.cursor=e?"grabbing":""};function Bg({tiles:e,columns:t,onStart:n,commit:r}){const[i,s]=S.useState(void 0),o=S.useRef(null);return{resize:i,gridBox:o,startResize:(d,c)=>{const h=o.current?.getBoundingClientRect(),f=d.currentTarget.parentElement?.getBoundingClientRect();!h||!f||(d.stopPropagation(),d.preventDefault(),d.currentTarget.setPointerCapture(d.pointerId),Qa(!0),n(c),s({index:c,span:e[c]?.colspan??1,left:f.left,track:(h.width-j.GRID_GAP_PX*(t-1))/t}))},onResize:d=>{if(!i)return;const c=d.clientX-i.left,h=Math.round((c+j.GRID_GAP_PX)/(i.track+j.GRID_GAP_PX)),f=Math.min(Math.max(h,1),t);f!==i.span&&s({...i,span:f})},endResize:d=>{if(d.currentTarget.hasPointerCapture(d.pointerId)&&d.currentTarget.releasePointerCapture(d.pointerId),Qa(!1),!i)return;const{index:c,span:h}=i;s(void 0),r(c,h)}}}function Vg({anchor:e,tile:t,onClose:n,onCommit:r,onRemove:i,columns:s,onDrills:o}){const{theme:a}=Be.usePublisherTheme(),{draft:l,patch:u,close:d,discard:c}=Cd(t,e!==null,r,n),h=l!==void 0&&l.declaration.kind!=="inherited";return y.jsx(k.Popover,{open:e!==null&&l!==void 0,anchorEl:e,onClose:d,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{width:320,p:2}}},children:l&&y.jsxs(k.Stack,{sx:{gap:1.5},children:[y.jsxs(k.Typography,{variant:"overline",sx:{color:a.tileTitle,lineHeight:1.5},children:[l.source," → ",l.name]}),h?y.jsxs(y.Fragment,{children:[y.jsx(k.TextField,{size:"small",label:"Title",value:l.label??"",autoFocus:!0,inputProps:{"aria-label":"Tile title"},onChange:f=>u(v=>{const p=f.target.value;p===""?delete v.label:v.label=p})}),y.jsx(k.TextField,{size:"small",label:"Subtitle",value:l.subtitle??"",inputProps:{"aria-label":"Tile subtitle"},onChange:f=>u(v=>{const p=f.target.value;p===""?delete v.subtitle:v.subtitle=p})}),y.jsxs(k.Stack,{direction:"row",sx:{gap:.5,alignItems:"center"},children:[y.jsx(k.Typography,{variant:"caption",sx:{color:a.tileTitle,mr:.5},children:"Width"}),[["Full",1],["½",2],["⅓",3],["¼",4]].map(([f,v])=>{const p=Math.max(1,Math.round(s/v)),w=(l.colspan??1)===p;return y.jsx(k.Button,{size:"small",variant:w?"contained":"outlined","aria-label":`Width ${f}`,"aria-pressed":w,onClick:()=>u(x=>{x.colspan=p}),sx:{minWidth:40,px:1},children:f},f)})]})]}):y.jsx(k.Typography,{variant:"body2",sx:{color:a.tileTitle},children:"Declared on its source, so its title and layout are set in the model. It can still be moved."}),l?.declaration.kind==="opaque"&&y.jsxs(k.Typography,{variant:"body2",sx:{color:a.tileTitle},children:["Its body is ",l.declaration.why,", so a filter has no single place to go. Everything else here is editable."]}),y.jsx(k.Divider,{}),y.jsxs(k.Stack,{direction:"row",sx:{justifyContent:"space-between"},children:[h?y.jsx(k.Button,{size:"small",onClick:()=>{d(),o()},children:"Clickable cells…"}):y.jsx("span",{}),y.jsx(k.Button,{color:"error",size:"small",onClick:()=>{c(),i()},children:"Remove tile"})]})]})})}const Gd=e=>e.ok===!1,me=(e,...t)=>t.every(n=>typeof e?.[n]=="function"),Vi=e=>e!==void 0&&e.ruleIndex!==void 0&&(e.childCount??0)>0,de={sourceDefinition:e=>me(e,"sourceNameDef","isDefine","sqExplore"),exploreQueryDef:e=>me(e,"exploreQueryNameDef","isDefine","vExpr"),defExploreQuery:e=>me(e,"VIEW","subQueryDefList"),defDimension:e=>me(e,"defList","DIMENSION"),exploreProperties:e=>me(e,"exploreStatement","OCURLY","CCURLY"),queryProperties:e=>me(e,"queryStatement","OCURLY","CCURLY"),queryStatement:e=>me(e,"whereStatement","aggregateStatement","nestStatement"),whereStatement:e=>me(e,"WHERE","filterClauseList"),givenDef:e=>me(e,"givenNameDef"),givenStatement:e=>me(e,"GIVEN","givenDefList"),importStatement:e=>me(e,"IMPORT","importURL"),vArrow:e=>me(e,"ARROW","vExpr","segExpr"),segRefine:e=>me(e,"PLUS","segExpr"),segOps:e=>me(e,"queryProperties"),segField:e=>me(e,"fieldPath")&&!me(e,"segExpr"),segParen:e=>me(e,"OPAREN","CPAREN","vExpr"),compare:e=>me(e,"fieldExpr","compareOp"),givenRef:e=>me(e,"GIVEN_REF")};function Gg(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 Ug(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
`
|
|
73
|
-
|
|
74
|
-
`)
|
|
75
|
-
|
|
76
|
-
`
|
|
77
|
-
|
|
78
|
-
`})}
|
|
79
|
-
`).
|
|
80
|
-
`),
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
`:"")
|
|
85
|
-
|
|
86
|
-
|
|
67
|
+
`.replace(/\n+/g," ").replace(/\s+/g," ").trim();function Cp(e,t="hidden"){return ue(()=>{const{element:n,manager:r}=e;if(!n||!r)return;const s=Ip(n,r.registry.droppables),i=[],o=Sh(n),{remove:a}=o;return Dp(s,o,i),Ap(o,t),o.remove=()=>{i.forEach(l=>l()),a.call(o)},o})}function Ip(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 Dp(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 Ap(e,t="hidden"){e.setAttribute("inert","true"),e.setAttribute("tab-index","-1"),e.setAttribute("aria-hidden","true"),e.setAttribute(Is,t)}function Dd(e,t){return e===t?!0:_n(e)===_n(t)}function Qa(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 Pp(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-")||Tp.includes(a))continue;const l=e.getAttribute(a);if(a==="style"){if(ur(e)&&ur(t)){const u=e.style;for(const c of Array.from(t.style))u.getPropertyValue(c)===""&&t.style.removeProperty(c);for(const c of Array.from(u)){if(Op.includes(c)||c.startsWith(Le))continue;const d=u.getPropertyValue(c);t.style.setProperty(c,d)}}}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 Mp(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 jp(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=od();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 v=Array.from(e.element.cells),y=Array.from(e.placeholder.cells);e.getSavedCellWidths()||e.setSavedCellWidths(v.map(w=>w.style.width));for(const[w,g]of v.entries()){const m=y[w];g.style.width=`${m.getBoundingClientRect().width}px`}}const u=(r=e.getTranslate())!=null?r:{x:0,y:0},c=e.left+o+l.x+u.x,d=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(c*h.scaleX+h.x,d*h.scaleY+h.y,f*h.scaleX,p*h.scaleY)})}var Rp=250,Lp="ease";function Np(e){var t,n,r,s;const{animation:i}=e;if(typeof i=="function"){const g=i({source:e.source,element:e.element,feedbackElement:e.feedbackElement,placeholder:e.placeholder,translate:e.translate,moved:e.moved});Promise.resolve(g).then(()=>{e.cleanup(),requestAnimationFrame(e.restoreFocus)});return}const{duration:o=Rp,easing:a=Lp}=i??{};mn(e.feedbackElement);const[,l]=(t=rd(e.feedbackElement,g=>"translate"in g))!=null?t:[];l?.pause();const u=(n=e.placeholder)!=null?n:e.element,c={frameTransform:Dd(e.feedbackElement,u)?null:void 0},d=new ut(e.feedbackElement,c),f=(r=vr(gt(e.feedbackElement).translate))!=null?r:e.translate,p=new ut(u,c),h=ft.delta(d,p,e.alignment),v={x:f.x-h.x,y:f.y-h.y},y=Math.round(d.intrinsicHeight)!==Math.round(p.intrinsicHeight)?{minHeight:[`${d.intrinsicHeight}px`,`${p.intrinsicHeight}px`],maxHeight:[`${d.intrinsicHeight}px`,`${p.intrinsicHeight}px`]}:{},w=Math.round(d.intrinsicWidth)!==Math.round(p.intrinsicWidth)?{minWidth:[`${d.intrinsicWidth}px`,`${p.intrinsicWidth}px`],maxWidth:[`${d.intrinsicWidth}px`,`${p.intrinsicWidth}px`]}:{};e.styles.set({transition:e.transition},Le),e.feedbackElement.setAttribute(Ji,""),(s=e.getElementMutationObserver())==null||s.takeRecords(),md({element:e.feedbackElement,keyframes:ra(yr(yr({},y),w),{translate:[`${f.x}px ${f.y}px 0`,`${v.x}px ${v.y}px 0`]}),options:{duration:Jo(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 Ad,to,xr,oa,fs,Pd,Md,$n=class extends(to=We,Ad=[fe],to){constructor(t,n){super(t,n),Ce(this,fs),Ce(this,oa,Me(xr,8,this)),Me(xr,11,this),this.state={initial:{},current:{}};const r=t.registry.plugins.get(Vs),s=r?.register(Ep);if(s){const i=this.destroy.bind(this);this.destroy=()=>{s(),i()}}this.registerEffect(Vt(this,fs,Pd).bind(this,r)),this.registerEffect(Vt(this,fs,Md))}};xr=Rn(to);oa=new WeakMap;fs=new WeakSet;Pd=function(e){const{overlay:t}=this;if(!t||!e)return;const n=ks(t);if(n)return e.addRoot(n)};Md=function(){var e,t,n,r,s,i,o;const{state:a,manager:l,options:u}=this,{dragOperation:c}=l,{position:d,source:f,status:p}=c;if(p.idle){a.current={},a.initial={};return}if(!f)return;const{element:h}=f,v=f.pluginConfig($n),y=(t=(e=v?.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:g}=a,m=(n=this.overlay)!=null?n:h,b=kn(m),_=kn(h),O=!Dd(h,m),E=new ut(h,{frameTransform:O?_:null,ignoreTransforms:!O}),I={x:_.scaleX/b.scaleX,y:_.scaleY/b.scaleY};let{width:T,height:D,top:L,left:R}=E;O&&(T=T/I.x,D=D/I.y);const z=new rp(m),K=gt(h),{transition:G,translate:X,boxSizing:Y,paddingBlockStart:se,paddingBlockEnd:te,paddingInlineStart:A,paddingInlineEnd:B,borderInlineStartWidth:N,borderInlineEndWidth:j,borderBlockStartWidth:q,borderBlockEndWidth:J}=K,ee=G.split(",").filter(be=>!/^\s*(transform|translate|scale)\b/.test(be)).join(","),H=Us(K),S=K.transform,P=w==="clone",F=Y==="content-box",V=F?parseInt(A)+parseInt(B)+parseInt(N)+parseInt(j):0,ie=F?parseInt(se)+parseInt(te)+parseInt(q)+parseInt(J):0,Z=w!=="move"&&!this.overlay?Cp(f,P?"clone":"hidden"):null,oe=ue(()=>br(l.dragOperation.activatorEvent));if(!g.translate){if(this.overlay&&H)g.translate={x:H.x,y:H.y};else if(X!=="none"){const be=vr(X);be&&(g.translate=be)}}if(!g.transformOrigin){const be=ue(()=>d.current),Ie=R+((r=H?.x)!=null?r:0),He=L+((s=H?.y)!=null?s:0);g.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:W}=g,Q=L*b.scaleY+b.y,ne=R*b.scaleX+b.x;if(!g.coordinates&&(g.coordinates={x:ne,y:Q},I.x!==1||I.y!==1)){const{scaleX:be,scaleY:Ie}=_,{x:He,y:St}=W;g.coordinates.x+=(T*be-T)*He,g.coordinates.y+=(D*Ie-D)*St}g.dimensions||(g.dimensions={width:T,height:D}),g.frameTransform||(g.frameTransform=b);const re={x:g.coordinates.x-ne,y:g.coordinates.y-Q},ce={width:(g.dimensions.width*g.frameTransform.scaleX-T*b.scaleX)*W.x,height:(g.dimensions.height*g.frameTransform.scaleY-D*b.scaleY)*W.y},pe={x:re.x/b.scaleX+ce.width,y:re.y/b.scaleY+ce.height},M={left:R+pe.x,top:L+pe.y};m.setAttribute(dt,"true");const U=ue(()=>c.transform),de=(i=g.translate)!=null?i:{x:0,y:0},ve=U.x*b.scaleX+de.x,Re=U.y*b.scaleY+de.y,Nn=od();z.set({width:T-V,height:D-ie,top:M.top+Nn.y,left:M.left+Nn.x,translate:`${ve}px ${Re}px 0`,transform:this.overlay?"none":S,transition:ee?`${ee}, translate 0ms linear`:"translate 0ms linear",scale:O?`${I.x} ${I.y}`:"","transform-origin":`${W.x*100}% ${W.y*100}%`},Le),Z&&(h.insertAdjacentElement("afterend",Z),u?.rootElement&&(typeof u.rootElement=="function"?u.rootElement(f):u.rootElement).appendChild(h)),Hi(m)&&(m.hasAttribute("popover")||m.setAttribute("popover","manual"),mn(m),m.addEventListener("beforetoggle",Qa));let mt,Fn,vt;const Sa=jp({placeholder:Z,element:h,feedbackElement:m,frameTransform:b,transformOrigin:W,width:T,height:D,top:L,left:R,widthOffset:V,heightOffset:ie,delta:pe,styles:z,dragOperation:c,getTranslate:()=>a.current.translate,getElementMutationObserver:()=>mt,getSavedCellWidths:()=>vt,setSavedCellWidths:be=>{vt=be}}),$a=new ut(m);ue(()=>c.shape=$a);const ei=Qe(m),Ta=be=>{this.manager.actions.stop({event:be})},Ju=Jo(ei);oe&&ei.addEventListener("resize",Ta),ue(()=>f.status)==="idle"&&requestAnimationFrame(()=>f.status="dragging"),Z&&(Sa.observe(Z),mt=Pp(h,Z,P),Fn=Mp(h,Z,m));const Oa=(o=l.dragOperation.source)==null?void 0:o.id,ef=()=>{var be;if(!oe||Oa==null)return;const Ie=l.registry.draggables.get(Oa),He=(be=Ie?.handle)!=null?be:Ie?.element;Pt(He)&&He.focus()},ti=()=>{mt?.disconnect(),Fn?.disconnect(),Sa.disconnect(),ei.removeEventListener("resize",Ta),Hi(m)&&(m.removeEventListener("beforetoggle",Qa),m.removeAttribute("popover")),m.removeAttribute(dt),z.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=c.status.dragging;Z&&(!St&&He||Z.parentElement!==m.parentElement)&&m.isConnected&&Z.replaceWith(m),Z?.remove()};m===this.overlay?setTimeout(be,0):be()},tf=u?.dropAnimation,Ea=this,nf=Er(()=>{var be,Ie,He;const{transform:St,status:ni}=c;if(!(!St.x&&!St.y&&!a.current.translate)&&ni.dragging){const zr=(be=g.translate)!=null?be:{x:0,y:0},Jt={x:St.x/b.scaleX+zr.x,y:St.y/b.scaleY+zr.y},Ca=a.current.translate,rf=ue(()=>c.modifiers),ri=ue(()=>{var Wn;return(Wn=c.shape)==null?void 0:Wn.current}),zn=u?.keyboardTransition,Ia=oe&&!Ju&&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(z.set({transition:ee?`${ee}, translate ${Ia}`:`translate ${Ia}`,translate:`${Jt.x}px ${Jt.y}px 0`},Le),mt?.takeRecords(),ri&&ri!==$a&&Ca&&!rf.length){const Wn=et.delta(Jt,Ca);c.shape=ft.from(ri.boundingRectangle).translate(Wn.x*b.scaleX,Wn.y*b.scaleY)}else c.shape=new ut(m);a.current.translate=Jt}},function(){if(c.status.dropped){this.dispose(),f.status="dropping";const be=v?.dropAnimation!==void 0?v.dropAnimation:Ea.dropAnimation!==void 0?Ea.dropAnimation:tf;let Ie=a.current.translate;const He=Ie!=null;if(!Ie&&h!==m&&(Ie={x:0,y:0}),!Ie||be===null){ti();return}l.renderer.rendering.then(()=>{Np({source:f,element:h,feedbackElement:m,placeholder:Z,translate:Ie,moved:He,transition:G,alignment:f.alignment,styles:z,animation:be??void 0,getElementMutationObserver:()=>mt,cleanup:ti,restoreFocus:ef})})}});return()=>{ti(),nf()}};it(xr,4,"overlay",Ad,$n,oa);Qt(xr,$n);$n.configure=Ir($n);var aa=$n,Bn=!0,Fp=!1,jd,Rd,Ld,Nd,Et,la,ca;Nd=(Ld=[fe],tt.Forward),Rd=(jd=[fe],tt.Reverse);var wr=class{constructor(){Ce(this,la,Me(Et,8,this,Bn)),Me(Et,11,this),Ce(this,ca,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]=Fp)}};Et=Rn(null);la=new WeakMap;ca=new WeakMap;it(Et,4,Nd,Ld,wr,la);it(Et,4,Rd,jd,wr,ca);Qt(Et,wr);var zp=[tt.Forward,tt.Reverse],Ja=class{constructor(){this.x=new wr,this.y=new wr}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},Wp=class extends We{constructor(e){super(e);const t=Tn(new Ja);let n=null;this.signal=t,st(()=>{const{status:r}=e.dragOperation;if(!r.initialized){n=null,t.value=new Ja;return}const{delta:s}=e.dragOperation.position;if(n){const i={x:el(s.x,n.x),y:el(s.y,n.y)},o=t.peek();Te(()=>{for(const a of hc)for(const l of zp)i[a]===l&&o[a].unlock(l);t.value=o})}n=s})}get current(){return this.signal.peek()}};function el(e,t){return Math.sign(e-t)}var Fd,no,_r,da,Tt,ro,Mr=class extends(no=Dr,Fd=[fe],no){constructor(e){super(e),Ce(this,da,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,c=u?.current;if(c){const{by:d}=i??{},f=d?{x:tl(d.x),y:tl(d.y)}:void 0,p=f?void 0:this.scrollIntentTracker.current;if(p?.isLocked())return!1;for(const h of l){const v=Lh(h,d);if(v.x||v.y){const{speed:y,direction:w}=Hh(h,c,f,o?.acceleration,o?.threshold);if(p)for(const g of hc)p[g].isLocked(w[g])&&(y[g]=0,w[g]=0);if(w.x||w.y){const{x:g,y:m}=d??w,b=g*y.x,_=m*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=ad(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 Wp(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);da=new WeakMap;Tt=new WeakMap;ro=new WeakMap;it(_r,4,"autoScrolling",Fd,Mr,da);Qt(_r,Mr);function tl(e){return e>0?tt.Forward:e<0?tt.Reverse:tt.Idle}var Bp=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))}},Gp=new Bp(e=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(e):e()}),qp=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 d=setInterval(()=>Gp.schedule(()=>r.scroll(void 0,u)),qp);return()=>{clearInterval(d)}}else r.autoScrolling=!1}})}};so.configure=Ir(so);var zd=so,nl={capture:!0,passive:!0},tr,Kp=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,nl),()=>{o.removeEventListener("scroll",this.handleScroll,nl)}}})}};tr=new WeakMap;var Up="* { user-select: none !important; -webkit-user-select: none !important; }",Vp=class extends We{constructor(e){super(e),this.manager=e;const t=e.registry.plugins.get(Vs),n=t?.register(Up);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 ld,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(),gd(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(zd);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 Wd=Ds;function en(e,t){return t.includes(e.code)}var Wt,Hp=class extends Kc{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,Xp=class extends Kc{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=Xp;gn.Distance=Hp;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})]:ip(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=Th(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 ld,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=>{sp(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&&(Qp(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||Yp(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 c=this.activationConstraints(t,n,r);t.sensor=this;const d=new vh(c,v=>this.handleStart(n,v));d.signal.onabort=()=>this.handleCancel(t),d.onEvent(t),this.controller=d;const f=Ki(),p=this.listeners.bind(f,[{type:"pointermove",listener:v=>this.handlePointerMove(v,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 Yp(e){return"sensor"in e}function Ur(e){e.preventDefault()}function Zp(){}var rl=new WeakSet;function Qp(e){!e||rl.has(e)||(e.addEventListener("touchmove",Zp,{capture:!1,passive:!1}),rl.add(e))}var vn={modifiers:[],plugins:[kp,zd,$p,aa,Vp],sensors:[oo,Wd]},Bd=class extends xh{constructor(e={}){const t=lt(e.plugins,vn.plugins),n=lt(e.sensors,vn.sensors),r=lt(e.modifiers,vn.modifiers);super(ra(yr({},e),{plugins:[Kp,Mr,Vs,...t],sensors:n,modifiers:r}))}},Gd,qd,ao,Ct,ua,fa,Hs=class extends(ao=ht,qd=[fe],Gd=[fe],ao){constructor(e,t){var n=e,{element:r,effects:s=()=>[],handle:i}=n,o=wd(n,["element","effects","handle"]);super(yr({effects:()=>[...s(),()=>{var a,l;const{manager:u}=this;if(!u)return;const d=((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(){d.forEach(p=>p())}}]},o),t),Ce(this,ua,Me(Ct,8,this)),Me(Ct,11,this),Ce(this,fa,Me(Ct,12,this)),Me(Ct,15,this),this.element=r,this.handle=i}};Ct=Rn(ao);ua=new WeakMap;fa=new WeakMap;it(Ct,4,"handle",qd,Hs,ua);it(Ct,4,"element",Gd,Hs,fa);Qt(Ct,Hs);var Kd,Ud,lo,It,ha,hi,Vd,Hd,hr,pa,Xs=class extends(lo=pt,Ud=[fe],Kd=[fe],lo){constructor(e,t){var n=e,{element:r,effects:s=()=>[]}=n,i=wd(n,["element","effects"]);const{collisionDetector:o=vd}=i,a=u=>{const{manager:c,element:d}=this;if(!d||u===null){this.shape=void 0;return}if(!c)return;const f=new ut(d),p=ue(()=>this.shape);return f&&p?.equals(f)?p:(this.shape=f,f)},l=Tn(!1);super(ra(yr({},i),{collisionDetector:o,effects:()=>[...s(),()=>{const{element:u,manager:c}=this;if(!c)return;const{dragOperation:d}=c,{source:f}=d;l.value=!!(f&&d.status.initialized&&u&&!this.disabled&&this.accepts(f))},()=>{const{element:u}=this;if(l.value&&u){const c=new Rh(u,a);return()=>{c.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,ha,Me(It,8,this)),Me(It,11,this),Ce(this,pa,Me(It,12,this)),Me(It,15,this),this.element=r,this.refreshShape=()=>a()}set element(e){qe(this,hr,e,Hd)}get element(){var e;return(e=this.proxy)!=null?e:ye(this,hr,Vd)}};It=Rn(lo);ha=new WeakMap;hr=new WeakSet;pa=new WeakMap;hi=it(It,20,"#element",Ud,hr,ha),Vd=hi.get,Hd=hi.set;it(It,4,"proxy",Kd,Xs,pa);Qt(It,Xs);function Jp(e){return e!=null&&typeof e=="object"&&"current"in e}function bn(e){var t;if(e!=null)return Jp(e)?(t=e.current)!=null?t:void 0:e}var eg=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Ln=eg?k.useLayoutEffect:k.useEffect;function tg(){const e=k.useState(0)[1];return k.useCallback(()=>{e(t=>t+1)},[e])}function Xd(e,t){const n=k.useRef(new Map),r=tg();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]),c=e[l];u!==c&&(i=!0,n.current.set(l,c),o=(s=t?.(l,u,c))!=null?s:!1)}i&&(o?queueMicrotask(()=>sf.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 ng(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 rg=Object.defineProperty,sg=Object.defineProperties,ig=Object.getOwnPropertyDescriptors,Ps=Object.getOwnPropertySymbols,Yd=Object.prototype.hasOwnProperty,Zd=Object.prototype.propertyIsEnumerable,sl=(e,t,n)=>t in e?rg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,og=(e,t)=>{for(var n in t||(t={}))Yd.call(t,n)&&sl(e,n,t[n]);if(Ps)for(var n of Ps(t))Zd.call(t,n)&&sl(e,n,t[n]);return e},ag=(e,t)=>sg(e,ig(t)),lg=(e,t)=>{var n={};for(var r in e)Yd.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&&Zd.call(e,r)&&(n[r]=e[r]);return n},cg=new Bd,Qd=k.createContext(cg),dg=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 ug(e){var t=e,{children:n,onCollision:r,onBeforeDragStart:s,onDragStart:i,onDragMove:o,onDragOver:a,onDragEnd:l}=t,u=lg(t,["children","onCollision","onBeforeDragStart","onDragStart","onDragMove","onDragOver","onDragEnd"]);const c=k.useRef(null),{plugins:d,modifiers:f,sensors:p}=u,h=lt(d,vn.plugins),v=lt(p,vn.sensors),y=lt(f,vn.modifiers),w=tn(s),g=tn(i),m=tn(a),b=tn(o),_=tn(l),O=tn(r),E=fg(()=>{var I;return(I=u.manager)!=null?I:new Bd(u)});return k.useEffect(()=>{if(!c.current)throw new Error("Renderer not found");const{renderer:I,trackRendering:T}=c.current,{monitor:D}=E;E.renderer=I;const L=[D.addEventListener("beforedragstart",R=>{const z=w.current;z&&T(()=>z(R,E))}),D.addEventListener("dragstart",R=>{var z;return(z=g.current)==null?void 0:z.call(g,R,E)}),D.addEventListener("dragover",R=>{const z=m.current;z&&T(()=>z(R,E))}),D.addEventListener("dragmove",R=>{const z=b.current;z&&T(()=>z(R,E))}),D.addEventListener("dragend",R=>{const z=_.current;z&&T(()=>z(R,E))}),D.addEventListener("collision",R=>{var z;return(z=O.current)==null?void 0:z.call(O,R,E)})];return()=>L.forEach(R=>R())},[E]),Se(h,()=>E&&(E.plugins=h),...pi),Se(v,()=>E&&(E.sensors=v),...pi),Se(y,()=>E&&(E.modifiers=y),...pi),x.jsxs(Qd.Provider,{value:E,children:[x.jsx(dg,{ref:c,children:n}),n]})}function fg(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 hg(){return k.useContext(Qd)}function Jd(e){var t;const n=(t=hg())!=null?t:void 0,[r]=k.useState(()=>e(n));return r.manager!==n&&(r.manager=n),Ln(r.register,[n,r]),r}var pg=Object.create,eu=Object.defineProperty,gg=Object.getOwnPropertyDescriptor,tu=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ys=e=>{throw TypeError(e)},mg=(e,t,n)=>t in e?eu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,vg=e=>{var t;return[,,,pg((t=e?.[tu("metadata")])!=null?t:null)]},nu=["class","method","getter","setter","accessor","field","value","get","set"],ru=e=>e!==void 0&&typeof e!="function"?Ys("Function expected"):e,bg=(e,t,n,r,s)=>({kind:nu[e],name:t,metadata:r,addInitializer:i=>n._?Ys("Already initialized"):s.push(ru(i||null))}),yg=(e,t)=>mg(t,tu("metadata"),e[3]),xg=(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},su=(e,t,n,r,s,i)=>{for(var o,a,l,u,c=t&7,d=!1,f=!1,p=2,h=nu[c+5],v=e[p]||(e[p]=[]),y=(s=s.prototype,gg(s,n)),w=r.length-1;w>=0;w--)l=bg(c,n,a={},e[3],v),l.static=d,l.private=f,u=l.access={has:g=>n in g},u.get=g=>g[n],o=(0,r[w])(y[h],l),a._=1,ru(o)&&(y[h]=o);return y&&eu(s,n,y),s},iu=(e,t,n)=>t.has(e)||Ys("Cannot "+n),wg=(e,t,n)=>(iu(e,t,"read from private field"),t.get(e)),_g=(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),kg=(e,t,n,r)=>(iu(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)}},ou,au,uo,ps,jr,ga=class extends(uo=Yt,au=[Ee],ou=[Ee],uo){constructor(e){const t=qt.from(e);super(t,(n,r)=>qt.equals(n,r)),xg(jr,5,this),_g(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-wg(this,ps),o=a=>Math.round(a/i*100);Te(()=>{kg(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=vg(uo);ps=new WeakMap;su(jr,2,"delta",au,ga);su(jr,2,"direction",ou,ga);yg(jr,ga);var lu=(e=>(e.Horizontal="x",e.Vertical="y",e))(lu||{});Object.values(lu);var Sg=({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},$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=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},Tg=e=>{var t;return(t=Sg(e))!=null?t:$g(e)};function Og(e){const{collisionDetector:t,data:n,disabled:r,element:s,id:i,accept:o,type:a}=e,l=Jd(c=>new Xs(ag(og({},e),{register:!1,element:bn(s)}),c)),u=Xd(l);return Se(i,()=>l.id=i),hs(s,c=>l.element=c),Se(o,()=>l.accept=o,void 0,ot),Se(t,()=>l.collisionDetector=t??Tg),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(c=>{var d,f;!c&&((d=l.element)!=null&&d.isConnected)&&!((f=l.manager)!=null&&f.dragOperation.status.idle)||(l.element=c??void 0)},[l])}}const il=`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>')}")`,cu=(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:il,WebkitMaskImage:il,maskSize:"contain",WebkitMaskSize:"contain",maskRepeat:"no-repeat",WebkitMaskRepeat:"no-repeat",opacity:.35,transition:`opacity ${C.MOTION_FAST}`,...C.reducedMotionSx,pointerEvents:"none"},[i]:{opacity:.8},"&:focus-visible":{outline:`2px solid ${e.accent}`,outlineOffset:2}}},du=k.createContext(void 0);function uu(e,t){const n=k.useContext(du),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))};uu(o!==void 0&&o!==e,()=>(u(),!0));const c=()=>{l.current=!1,a(e)};if(o===void 0){const d=e==="",f=d&&s;return x.jsx($.Box,{component:"button",type:"button",className:f?"builder-affordance":void 0,onClick:c,onKeyDown:p=>{p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),c())},sx:[{all:"unset",boxSizing:"border-box",font:"inherit",color:"inherit",display:"inline-block",maxWidth:"100%",...d&&{fontStyle:"italic",opacity:f?0:.6}},cu(i)],children:d?t:e})}return x.jsx($.InputBase,{autoFocus:!0,fullWidth:!0,value:o,placeholder:t,inputProps:{"aria-label":n},onFocus:d=>d.target.select(),onChange:d=>a(d.target.value),onKeyDown:d=>{d.key==="Enter"&&!d.nativeEvent.isComposing?u():d.key==="Escape"&&(l.current=!0,a(void 0))},onBlur:u,sx:{font:"inherit",color:"inherit",p:0,"& input":{p:0}}})}const Eg=(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}),Cg=(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},fu=(e,t)=>({kind:"tile",tile:e,index:t,colspan:e.colspan,break:e.break}),hu=e=>`gap.${e}`,Ig=(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(fu(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 Dg=Object.create,pu=Object.defineProperty,Ag=Object.defineProperties,Pg=Object.getOwnPropertyDescriptor,Mg=Object.getOwnPropertyDescriptors,Ms=Object.getOwnPropertySymbols,gu=Object.prototype.hasOwnProperty,mu=Object.prototype.propertyIsEnumerable,jg=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Rr=e=>{throw TypeError(e)},ho=(e,t,n)=>t in e?pu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,gi=(e,t)=>{for(var n in t||(t={}))gu.call(t,n)&&ho(e,n,t[n]);if(Ms)for(var n of Ms(t))mu.call(t,n)&&ho(e,n,t[n]);return e},mi=(e,t)=>Ag(e,Mg(t)),Rg=(e,t)=>{var n={};for(var r in e)gu.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&&mu.call(e,r)&&(n[r]=e[r]);return n},Lg=e=>{var t;return[,,,Dg((t=void 0)!=null?t:null)]},vu=["class","method","getter","setter","accessor","field","value","get","set"],rr=e=>e!==void 0&&typeof e!="function"?Rr("Function expected"):e,Ng=(e,t,n,r,s)=>({kind:vu[e],name:t,metadata:r,addInitializer:i=>n._?Rr("Already initialized"):s.push(rr(i||null))}),Fg=(e,t)=>ho(t,jg("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},bu=(e,t,n,r,s,i)=>{for(var o,a,l,u,c,d=t&7,f=!1,p=!1,h=e.length+1,v=vu[d+5],y=e[h-1]=[],w=e[h]||(e[h]=[]),g=(s=s.prototype,Pg({get[n](){return sr(this,i)},set[n](b){return Gt(this,i,b)}},n)),m=r.length-1;m>=0;m--)u=Ng(d,n,l={},e[3],w),u.static=f,u.private=p,c=u.access={has:b=>n in b},c.get=b=>b[n],c.set=(b,_)=>b[n]=_,a=(0,r[m])({get:g.get,set:g.set},u),l._=1,a===void 0?rr(a)&&(g[v]=a):typeof a!="object"||a===null?Rr("Object expected"):(rr(o=a.get)&&(g.get=o),rr(o=a.set)&&(g.set=o),rr(o=a.init)&&y.unshift(o));return g&&pu(s,n,g),s},yu=(e,t,n)=>t.has(e)||Rr("Cannot "+n),sr=(e,t,n)=>(yu(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)=>(yu(e,t,"write to private field"),t.set(e,n),n);function Kt(e){return e instanceof ba||e instanceof ku}var Hr=10,zg=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 c=Wg(u),{source:d,target:f}=i,{center:p}=i.shape.current,h=[],v=[];Te(()=>{for(const _ of l.droppables){const{id:O}=_;if(!_.accepts(d)||O===f?.id&&Kt(_)||!_.element)continue;let E=_.shape;const I=new ut(_.element,{getBoundingClientRect:T=>mr(T,void 0,.2)});!I.height||!I.width||(c=="down"&&p.y+Hr<I.center.y||c=="up"&&p.y-Hr>I.center.y||c=="left"&&p.x-Hr>I.center.x||c=="right"&&p.x+Hr<I.center.x)&&(h.push(_),_.shape=I,v.push(()=>_.shape=E))}}),r.preventDefault(),a.disable();const y=a.computeCollisions(h,lp);Te(()=>v.forEach(_=>_()));const[w]=y;if(!w)return;const{id:g}=w,{index:m,group:b}=d.sortable;o.setDropTarget(g).then(()=>{const{source:_,target:O,shape:E}=i;if(!_||!Kt(_)||!E)return;const{index:I,group:T,target:D}=_.sortable,L=m!==I||b!==T,R=L?D:O?.element;if(!R)return;gd(R);const z=new ut(R);if(!z)return;const K=ft.delta(z,ft.from(E.current.boundingRectangle),_.alignment);o.move({by:K}),L?o.setDropTarget(_.id).then(()=>a.enable()):a.enable()})})});this.destroy=()=>{n(),t()}}};function Wg(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 Bg=Object.defineProperty,Gg=Object.defineProperties,qg=Object.getOwnPropertyDescriptors,ol=Object.getOwnPropertySymbols,Kg=Object.prototype.hasOwnProperty,Ug=Object.prototype.propertyIsEnumerable,al=(e,t,n)=>t in e?Bg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,nn=(e,t)=>{for(var n in t||(t={}))Kg.call(t,n)&&al(e,n,t[n]);if(ol)for(var n of ol(t))Ug.call(t,n)&&al(e,n,t[n]);return e},rn=(e,t)=>Gg(e,qg(t));function Vg(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 Hg(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=(m,b)=>m===b||m!==null&&typeof m=="object"&&"id"in m&&m.id===b;if(Array.isArray(e)){const m=e.findIndex(_=>l(_,i.id)),b=e.findIndex(_=>l(_,o.id));if(m===-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(_!==m)return n(e,m,_)}return n(e,m,b)}const u=Object.entries(e);let c=-1,d,f=-1,p;for(const[m,b]of u)if(c===-1&&(c=b.findIndex(_=>l(_,i.id)),c!==-1&&(d=m)),f===-1&&(f=b.findIndex(_=>l(_,o.id)),f!==-1&&(p=m)),c!==-1&&f!==-1)break;if(c===-1&&vi(i)){const m=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(m==null||_==null||m===_&&b===O)return"preventDefault"in t&&t.preventDefault(),e;if(m===_)return rn(nn({},e),{[m]:n(e[m],b,O)});const E=e[m][b];return rn(nn({},e),{[m]:[...e[m].slice(0,b),...e[m].slice(b+1)],[_]:[...e[_].slice(0,O),E,...e[_].slice(O)]})}if(!i.manager)return e;const{dragOperation:h}=i.manager,v=(s=(r=h.shape)==null?void 0:r.current.center)!=null?s:h.position.current;if(p==null){const m=Xr(e,o.id);if(m!=null){const b=o.shape&&v.y>o.shape.center.y?e[m].length:0;p=m,f=b}}if(d==null||p==null||d===p&&c===f){if(d!=null&&d===p&&c===f&&vi(i)){const m=i.group==null?void 0:Xr(e,i.group),b=i.group!=null&&m!==d,_=i.index!==c;if(b||_){const O=i.group==null?d:m;if(O!=null){if(d===O)return rn(nn({},e),{[d]:n(e[d],c,i.index)});const E=e[d][c];return rn(nn({},e),{[d]:[...e[d].slice(0,c),...e[d].slice(c+1)],[O]:[...e[O].slice(0,i.index),E,...e[O].slice(i.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(d===p)return rn(nn({},e),{[d]:n(e[d],c,f)});const w=o.shape&&Math.round(v.y)>Math.round(o.shape.center.y)?1:0,g=e[d][c];return rn(nn({},e),{[d]:[...e[d].slice(0,c),...e[d].slice(c+1)],[p]:[...e[p].slice(0,f+w),g,...e[p].slice(f+w)]})}function Xg(e,t){return Hg(e,t,Vg)}function ll(e){const t=new Map;for(const[,n]of e)for(const r of n)t.set(r.id,r.index);return t}function cl(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 dl="__default__",Yg=class extends We{constructor(e){super(e);const t=()=>{const r=new Map;for(const s of e.registry.droppables)if(s instanceof ba){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=ll(l),c=o.sortable.group===a.sortable.group,d=l.get(o.sortable.group),f=c?d:l.get(a.sortable.group);!d||!f||queueMicrotask(()=>{r.defaultPrevented||s.renderer.rendering.then(()=>{var p,h;const v=t();if(cl(u,l,v))return;const y=o.sortable.element,w=a.sortable.element;if(!w||!y||!c&&a.id===o.sortable.group)return;const g=Yr(d),m=c?g:Yr(f),b=(p=o.sortable.group)!=null?p:dl,_=(h=a.sortable.group)!=null?h:dl,O={[b]:g,[_]:m},E=Xg(O,r);if(O===E)return;const I=E[_].indexOf(o.sortable),T=E[_].indexOf(a.sortable);s.collisionObserver.disable(),ul(y,I,w,T),Te(()=>{for(const[D,L]of E[b].entries())L.index=D;if(!c)for(const[D,L]of E[_].entries())L.group=a.sortable.group,L.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=ll(a),u=a.get(o.sortable.initialGroup);u&&s.renderer.rendering.then(()=>{const c=t();if(cl(l,a,c))return;const d=Yr(u),f=Yr(u,Qg),p=o.sortable.element,h=f.indexOf(o.sortable),v=d[h],y=v?.element;!v||!y||!p||(ul(p,v.index,y,o.index),Te(()=>{for(const w of a.values()){const g=Array.from(w).values();for(const m of g)m.index=m.initialIndex,m.group=m.initialGroup}}))})}))})];this.destroy=()=>{for(const r of n)r()}}};function ul(e,t,n,r){const s=r<t?"afterend":"beforebegin";n.insertAdjacentElement(s,e)}function Zg(e,t){return e.index-t.index}function Qg(e,t){return e.initialIndex-t.initialIndex}function Yr(e,t=Zg){return Array.from(e).sort(t)}var fl=[zg,Yg],xu={duration:250,easing:"cubic-bezier(0.25, 1, 0.5, 1)",idle:!1};function hl(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 Kf,wu,_u,Dt,ma,ir,or,va,hn;_u=[fe],wu=[fe];var Zs=class{constructor(e,t){Gn(this,ma,Vr(Dt,8,this)),Vr(Dt,11,this),Gn(this,ir),Gn(this,or),Gn(this,va,Vr(Dt,12,this)),Vr(Dt,15,this),Gn(this,hn),this.register=()=>(Te(()=>{var h,v;(h=this.manager)==null||h.registry.register(this.droppable),(v=this.manager)==null||v.registry.register(this.draggable)}),()=>this.unregister()),this.unregister=()=>{Te(()=>{var h,v;(h=this.manager)==null||h.registry.unregister(this.droppable),(v=this.manager)==null||v.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=xu,plugins:c}=n,d=Rg(n,["effects","disabled","group","index","sensors","type","transition","plugins"]);const f=lt(c,fl),p=hl(s);this.droppable=new ba(mi(gi({},d),{disabled:p.droppable}),t,this),this.draggable=new ku(mi(gi({},d),{disabled:p.draggable,plugins:f,effects:()=>[()=>{var h,v,y;const w=(h=this.manager)==null?void 0:h.dragOperation.status;w?.initializing&&this.id===((y=(v=this.manager)==null?void 0:v.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:v,manager:y}=this,w=sr(this,or),g=sr(this,ir);(h!==w||v!==g)&&(Gt(this,or,h),Gt(this,ir,v),this.animate())},()=>{var h,v;const{target:y}=this,{isDragSource:w}=this.draggable;((v=(h=this.draggable.pluginConfig(aa))==null?void 0:h.feedback)!=null?v:"default")==="move"&&w&&(this.droppable.disabled=!y)},...r()],type:l,sensors:a}),t,this),Gt(this,hn,d.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 c of s.getAnimations())"transitionProperty"in c&&(c.transitionProperty==="transform"||c.transitionProperty==="translate"||c.transitionProperty==="scale")&&c.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=Xa(s,a,!1),u=Xa(s,a);if(o.x||o.y){const c=Jo(Qe(s))?mi(gi({},t),{duration:0}):t;md({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:c}).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,fl)}set disabled(e){const t=hl(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??vd}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=Lg();ma=new WeakMap;ir=new WeakMap;or=new WeakMap;va=new WeakMap;hn=new WeakMap;bu(Dt,4,"index",_u,Zs,ma);bu(Dt,4,"group",wu,Zs,va);Fg(Dt,Zs);var ku=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}},ba=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}},Jg=Object.defineProperty,em=Object.defineProperties,tm=Object.getOwnPropertyDescriptors,pl=Object.getOwnPropertySymbols,nm=Object.prototype.hasOwnProperty,rm=Object.prototype.propertyIsEnumerable,gl=(e,t,n)=>t in e?Jg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,bi=(e,t)=>{for(var n in t||(t={}))nm.call(t,n)&&gl(e,n,t[n]);if(pl)for(var n of pl(t))rm.call(t,n)&&gl(e,n,t[n]);return e},sm=(e,t)=>em(e,tm(t));function im(e){const{accept:t,collisionDetector:n,collisionPriority:r,id:s,data:i,element:o,handle:a,index:l,group:u,disabled:c,modifiers:d,sensors:f,target:p,type:h,plugins:v}=e,y=bi(bi({},xu),e.transition),w=Jd(m=>new Zs(sm(bi({},e),{transition:y,register:!1,handle:bn(a),element:bn(o),target:bn(p)}),m)),g=Xd(w,om);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 m;(m=w.manager)!=null&&m.dragOperation.status.idle&&y?.idle&&w.refreshShape()},ng),hs(a,m=>w.handle=m),hs(o,m=>w.element=m),hs(p,m=>w.target=m),Se(c,()=>w.disabled=c??!1,void 0,ot),Se(f,()=>w.sensors=f,void 0,ot),Se(n,()=>w.collisionDetector=n),Se(r,()=>w.collisionPriority=r),Se(v,()=>w.plugins=v,void 0,ot),Se(y,()=>w.transition=y,void 0,ot),Se(d,()=>w.modifiers=d,void 0,ot),Se(e.alignment,()=>w.alignment=e.alignment),{sortable:g,get isDragging(){return g.isDragging},get isDropping(){return g.isDropping},get isDragSource(){return g.isDragSource},get isDropTarget(){return g.isDropTarget},handleRef:k.useCallback(m=>{w.handle=m??void 0},[w]),ref:k.useCallback(m=>{var b,_;!m&&((b=w.element)!=null&&b.isConnected)&&!((_=w.manager)!=null&&_.dragOperation.status.idle)||(w.element=m??void 0)},[w]),sourceRef:k.useCallback(m=>{var b,_;!m&&((b=w.source)!=null&&b.isConnected)&&!((_=w.manager)!=null&&_.dragOperation.status.idle)||(w.source=m??void 0)},[w]),targetRef:k.useCallback(m=>{var b,_;!m&&((b=w.target)!=null&&b.isConnected)&&!((_=w.manager)!=null&&_.dragOperation.status.idle)||(w.target=m??void 0)},[w])}}function om(e,t,n){return!!(e==="isDragSource"&&!n&&t)}const po="tile",Su="gap",am=[oo.configure({activatorElements:e=>[e.element],preventActivation:(e,t)=>e.target instanceof Element&&e.target.closest(`[${$u}]`)!==null||(oo.defaults.preventActivation?.(e,t)??!1)}),Wd],$u="data-no-drag",lm=e=>[...e,aa.configure({feedback:"clone"})];function cm({id:e,index:t,children:n}){const{ref:r,handleRef:s,isDragSource:i}=im({id:e,index:t,type:po,accept:po,collisionDetector:ta,plugins:lm});return x.jsx(x.Fragment,{children:n({ref:r,handleRef:s,isDragSource:i})})}function dm({id:e,after:t,children:n}){const{ref:r,isDropTarget:s}=Og({id:e,type:Su,accept:po,collisionDetector:ta,data:{after:t}});return x.jsx(x.Fragment,{children:n({ref:r,isDropTarget:s})})}const Tu=["bar_chart","line_chart","scatter_chart","shape_map","segment_map","big_value","sparkline"],Ou=["line_chart","bar_chart","big_value","scatter_chart","shape_map","segment_map"],Qs=e=>Ou.includes(e),go=new Set([...Tu,"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["#",...Ou.filter(r=>r!==e&&(t===void 0||t.includes(r))).map(r=>`-${r}`),"-viz",...e==="none"?[]:[e]].join(" ")}function um(e){return e.pick!==void 0?Qs(e.pick)?e.pick:"custom":e.negated.includes("viz")?"none":"custom"}function fm(e){if(e.length===0)return"default";if(e.length>1)return"custom";const t=At(e[0]);return t?um(t):"custom"}function hm(e){const t=e.filter(n=>At(n));return e.some(kr)?"custom":t.length===0?void 0:fm(t)}const pm=e=>e.filter(t=>At(t)||kr(t)),Eu=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 gm(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 mm(e){const t=[0];for(let n=0;n<e.length;n++)e[n]===`
|
|
68
|
+
`&&t.push(n+1);return t}class ya{constructor(t){this.text=t,this.map=gm(t),this.lineStarts=mm(t)}map;lineStarts;commentLines=new Set;proseLines=new Set;blocks=[];span(t){if(!Lr(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 Nr(e,t,n=[]){Lr(e)&&t(e)&&n.push(e);for(let r=0;r<(e.childCount??0);r++)Nr(e.getChild(r),t,n);return n}const vm=e=>De(e,"OCURLY","CCURLY");function Sr(e,t){const n=[],r=s=>{if(Lr(s)){if(t(s)){n.push(s);return}if(!vm(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 Ae=(e,t)=>e[t]?.call(e),Ht=(e,t)=>e[t]?.call(e)??[];function bm(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 Cu(e,t){const n=e.positioned(t);if(!n)return;const r=Ae(t,"filterClauseList"),s=[];for(const i of r?Ht(r,"fieldExpr"):[]){const o=e.positioned(i);if(!o)continue;const a=Nr(i,ke.givenRef).map(l=>e.text_(l)).filter(l=>l!==void 0).map(l=>l.replace(/^\$/,""));s.push({...o,givens:a,binding:bm(e,i)})}return{...n,clauses:s}}function mo(e,t){const n=e.span(t);if(!n)return;const r=[],s=[];for(const u of Sr(t,ke.queryStatement)){const c=e.positioned(u);c&&r.push(c);const d=Ae(u,"whereStatement");if(d&&ke.whereStatement(d)){const f=Cu(e,d);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 xa(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 ym(e,t){const n=Ae(t,"segExpr");if(!n)return{kind:"unsupported",why:"an unreadable expression"};const r=ke.vArrow(t);if(ke.segOps(n)){const s=Ae(n,"queryProperties"),i=s&&mo(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=Ht(n,"segExpr"),i=s[0],o=s[s.length-1];let a=i;for(;ke.segRefine(a);){const f=Ht(a,"segExpr");if(f.some(p=>ke.segOps(p)||ke.segParen(p)))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 u=e.text.slice(l.start,l.end),c=Ae(o,"queryProperties"),d=c&&mo(e,c);return d?{kind:"reference",from:u,fromSpan:l,refinement:d}:{kind:"reference",from:u,fromSpan:l}}return{kind:"unsupported",why:"a parenthesized expression"}}function xm(e,t){const n=[];for(const r of Sr(t,ke.defExploreQuery)){const s=e.span(r),i=Ae(r,"subQueryDefList");if(!s||!i)continue;const o=Ht(i,"exploreQueryDef").filter(ke.exploreQueryDef),a=e.terminal(Ae(r,"VIEW"));for(const l of o){const u=e.span(l),c=Ae(l,"exploreQueryNameDef"),d=e.text_(c),f=Ae(l,"vExpr");!u||!d||!f||n.push({name:d,span:u,line:e.line(u.start),statement:s,tags:xa(e,s,a?.start??u.start),siblings:o.length,body:ym(e,f)})}}return n}function wm(e,t){const n=[];for(const r of Sr(t,ke.defDimension)){const s=e.span(r),i=Ae(r,"defList");if(!s||!i)continue;const o=e.terminal(Ae(r,"DIMENSION"));for(const a of Ht(i,"fieldDef")){const l=e.span(a),u=e.text_(Ae(a,"fieldNameDef"))?.trim(),c=e.text_(Ae(a,"fieldExpr"))?.trim();!l||!u||c===void 0||n.push({name:u,expression:c,span:l,line:e.line(l.start),statement:s,tags:xa(e,s,o?.start??l.start)})}}return n}function _m(e,t){const n=[];for(const r of Nr(t,ke.sourceDefinition)){const s=e.span(r),i=e.text_(Ae(r,"sourceNameDef")),o=Ae(r,"sqExplore");if(!s||!i||!o)continue;const a=e.span(o),l=a?e.text.slice(a.start,a.end):"",u=(/^\s*(`[^`]*`|[A-Za-z_][A-Za-z0-9_.]*)/.exec(l)?.[1]??"").trim(),c=Sr(o,ke.exploreProperties)[0],d=c&&mo(e,c),f={start:e.lineStarts[e.line(s.start)],end:s.end},p=[];if(c)for(const h of Sr(c,ke.whereStatement)){const v=Cu(e,h);v&&p.push(v)}n.push({name:i,base:u,span:s,line:e.line(s.start),statement:f,...d?{properties:d}:{},views:c?xm(e,c):[],dimensions:c?wm(e,c):[],wheres:p})}return n}function km(e,t){const n=[];for(const r of Nr(t,ke.givenStatement)){const s=e.terminal(Ae(r,"GIVEN")),i=Ae(r,"givenDefList"),o=s?e.line(s.start):void 0;for(const a of i?Ht(i,"givenDef"):[]){const l=e.span(a),u=e.span(Ae(a,"givenNameDef")),c=u&&e.text.slice(u.start,u.end);if(!l||!u||!c)continue;const d={start:u.start,end:l.end},f=e.line(d.start);n.push({name:c,declaration:e.text.slice(d.start,d.end),span:d,line:f,statement:{start:e.lineStarts[f],end:d.end},tags:xa(e,l,d.start),...o!==void 0&&o!==f?{blockHeader:o}:{}})}}return n}function Sm(e,t){const n=[];for(const r of Nr(t,ke.importStatement)){const s=e.span(r),i=e.text_(Ae(r,"importURL"));if(!s||i===void 0)continue;const o=Ae(r,"importSelect"),a=o?Ht(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 Iu(e){let t;try{t=await Js(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||!Lr(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 ya(e),l=wa(a,i);a.commentLines=l.lines;const u=e.split(`
|
|
70
|
+
`),c=f=>l.lines.has(f);a.proseLines=me.markdownLines(u,c),a.blocks=me.blockSpans(u,c).filter(([f])=>!u[f].trimStart().startsWith("##"));const d=_m(a,s);return d.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:Sm(a,s),sources:d,givens:km(a,s),textBlocks:Tm(a,i),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(p=>p.start>=f.start&&p.start<f.end),blockStart:f=>$m(a,l.lines,f)}}}async function Js(e,t){const{MalloyTranslator:n}=await C.loadMalloy(),r=new n(t,null,{urls:{[t]:e}});return{problems:r.translate().problems??[],parse:r.parseStep?.response?.parse}}function wa(e,t){const n=new Map,r=new Set,s=[],i=t.tokenSource?.vocabulary;for(const c of t.getTokens?.()??[]){const d=i?.getSymbolicName(c.type);if(d!=="COMMENT_TO_EOL"&&d!=="BLOCK_COMMENT")continue;const f=e.utf16(c.startIndex);let p=e.utf16(c.stopIndex+1);if(!(f===void 0||p===void 0||p<f)){for(;p>f&&(e.text[p-1]===`
|
|
71
|
+
`||e.text[p-1]==="\r");)p--;s.push({start:f,end:p})}}const o=[...s].sort((c,d)=>c.start-d.start);let a="",l=0;for(const c of o)a+=e.text.slice(l,Math.max(l,c.start)),a+=e.text.slice(Math.max(l,c.start),Math.max(l,c.end)).replace(/[^\n\r]/g," "),l=Math.max(l,c.end);a+=e.text.slice(l);const u=c=>a.slice(e.lineStarts[c],e.lineStarts[c+1]??a.length);for(const c of s){const d=e.line(c.start),f=e.line(c.end-1);for(let v=d;v<=f;v++)u(v).trim()===""&&r.add(v);const p=a.slice(e.lineStarts[d],c.start).trim(),h=a.slice(c.end,e.lineStarts[f+1]??a.length).trim();p!==""&&h===""&&n.set(f,c)}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 Tm(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=me.textBlockOpener(i(n[a]).replace(/\r?\n$/,""));if(!l)continue;const u=[];let c=a+1;for(;s(n[c]??n[a])==="BLOCK_ANNOTATION_TEXT";c++)u.push(i(n[c]));const d=n[c];if(!d||s(d)!=="BLOCK_ANNOTATION_END")continue;const f=e.line(e.utf16(n[a].startIndex)??0),p=e.utf16(d.stopIndex+1)??e.text.length,h=l.name===void 0&&l.rest?[`${l.rest}
|
|
72
|
+
`]:[];o.push({...l.name===void 0?{}:{name:l.name},route:l.route,body:[...h,...u].join("").replace(/\r\n?/g,`
|
|
73
|
+
`).replace(/\n$/,""),span:{start:e.lineStarts[f],end:p},line:f}),a=c}return o}function Du(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 _a(e){let t=0,n=0;for(let r=0;r<e.length;r++){const s=e[r];if(s==='"')r=Du(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 Om(e,r+i[0].length-1)}}}function Om(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,u=a.trim();u!==""&&n.push({text:u,span:{start:s+l,end:s+l+u.length}})};for(let o=t+1;o<e.length;o++){const a=e[o];if(a==='"')o=Du(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 Em(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
|
+
`)return e.length}return e.length}if(e.startsWith("<<<",t)){let r=t+3;for(;;){const s=e.indexOf(`
|
|
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 Cm(e){const t=/^([ \t]*)f(['"])((?:\\.|(?!\2)[^\\])*)\2/;let n="",r=0;for(;r<e.length;){const s=Em(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 Au(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=Cm(i);return e([o]).log.length===0?o:i}),s=e(r);return{tag:s.tag,errors:s.log.map(i=>i.message)}}const $r=e=>e.ok===!1;function Fr(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 js=e=>e.map(t=>t.text);function ml(e){const t=js(e),n=hm(t);return n===void 0?{}:n==="custom"?{chart:n,chartLines:pm(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:me.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(js(Fr(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 yi(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 Pm=/^"((?:[^"\\]|\\.)+)"$/,Mm=/^([A-Za-z_][A-Za-z0-9_]*)\s*\{/;async function Tr(e,t,n=!1){try{return await jm(e,t,n)}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 jm(e,t,n){const{parseAnnotation:r}=await C.loadMalloyTag(),s=me.splitSourceLines(e),i=await Iu(e);if(Eu(i))return{ok:!1,reason:i.reason,...i.line?{line:i.line}:{}};const o=i.parsed,a=me.descriptionNotes(s).text,l=me.artifactTag(s);if(l===void 0)return{ok:!1,reason:"No `## artifact { … }` tag, so this file is not a composite dashboard."};if(!me.artifactLeads(l.text))return{ok:!1,reason:me.ARTIFACT_NOT_FIRST,line:l.from+1};const{tag:u,errors:c}=Au(r,[me.tagAnnotation(l.text)]),d=u?.tag("artifact"),f=d?.text("kind"),p=d?.has("tiles")===!0||u?.tag("dashboard")!==void 0,h=f==="notebook"||f!=="dashboard"&&(n?!p:t?.startsWith("notebooks/"))?"notebook":void 0,v=_a(l.text);if(v===void 0)return c.length>0?{ok:!1,reason:`The \`## artifact\` tag does not parse: ${c[0]}`}:h==="notebook"?{ok:!1,legacyNotebook:!0,reason:"This notebook is in the cell format, with no `tiles=[…]` list."}:{ok:!1,reason:"The `## artifact` tag has no `tiles=[…]` list the builder can read."};const y=o.imports.map(T=>T.names?{kind:"names",names:T.names,from:T.from}:{kind:"all",from:T.from}),w=[],g=[],m=new Map;for(const T of o.sources){const D={name:T.name,base:T.base};T.dimensions.length>0&&(D.dimensions=T.dimensions.map(R=>({name:R.name,expression:R.expression})));const L=new Set(T.wheres.flatMap(R=>R.clauses.flatMap(z=>z.givens)));L.size>0&&(D.scopedBy=Array.from(L)),w.push(D);for(const R of T.dimensions){const z=r(js(Fr(o,s,R.line).tags)).tag?.tag("drill");if(!z)continue;const K=z.textArray("to")??[z.text("to")??""];g.push({source:T.name,name:R.name,expression:R.expression,to:K.filter(Boolean),...z.text("given")?{given:z.text("given")}:{}})}m.set(T.name,new Map(T.views.map(R=>[R.name,R])))}const b=[];for(const{text:T}of v.entries){const D=Pm.exec(T),L=D?void 0:Mm.exec(T)?.[1];if(L!==void 0){const A=r([`# ${T}`]).tag?.tag(L);if(A?.text("kind")!=="text")return{ok:!1,reason:`The tile \`${T}\` is neither a quoted \`source -> view\` expression nor a \`${L} { kind=text }\` entry, which are the only forms the builder can lay out.`};if(b.some(N=>je(N)&&N.name===L))return{ok:!1,reason:`Two text tiles are named \`${L}\`, so the builder cannot tell them apart.`};const B=yi(A,"colspan");b.push({kind:"text",name:L,markdown:o.textBlocks.find(N=>N.name===L)?.body??"",...B===void 0?{}:{colspan:B},...A.has("break")?{break:!0}:{}});continue}const R=D?.[1]??T,z=D?me.tileSteps(R):void 0;if(!z)return{ok:!1,reason:`The tile \`${R}\` is not a \`source -> view\` expression, which is the only form the builder can lay out.`};const{source:K,view:G}=z,X=m.get(K)?.get(G);if(X===void 0){b.push({name:G,source:K,declaration:{kind:"inherited"}});continue}const Y=r(js(X.tags)).tag,se=X.body.kind==="reference"?{kind:"reference",from:X.body.from}:X.body.kind==="inline"?{kind:"inline"}:void 0;if(se===void 0){b.push({name:G,source:K,declaration:{kind:"opaque",why:X.body.kind==="unsupported"?X.body.why:"unreadable"},...Y?.text("label")?{label:Y.text("label")}:{},...Y?.text("subtitle")?{subtitle:Y.text("subtitle")}:{},...Y?.numeric("colspan")!==void 0?{colspan:Y.numeric("colspan")}:{},...ml(X.tags),...Y?.has("break")?{break:!0}:{},...Y?.has("borderless")?{borderless:!0}:{}});continue}const te=Im(X.body.kind==="reference"?X.body.refinement:X.body.kind==="inline"?X.body.stage:void 0);b.push({name:G,source:K,declaration:se,...te?{filters:te}:{},...Y?.text("label")?{label:Y.text("label")}:{},...Y?.text("subtitle")?{subtitle:Y.text("subtitle")}:{},...Y?.numeric("colspan")!==void 0?{colspan:Y.numeric("colspan")}:{},...ml(X.tags),...Y?.has("break")?{break:!0}:{},...Y?.has("borderless")?{borderless:!0}:{}})}const _=Dm(o,s,r),O={},E=d?.tag("givens");for(const T of Object.keys(E?.dict??{})){const D=E?.text(T);D!==void 0&&(O[T]=D)}const I=u?.tag("dashboard")?.has("columns")?yi(u.tag("dashboard"),"columns"):d?.array("tiles")?yi(d,"dashboard_columns"):void 0;return{ok:!0,document:{...h?{kind:h}:{},title:d?.text("title")??"",...a?{description:a}:{},...I===void 0?{}:{columns:I},...d?.has("autorun")?{autorun:d.isTrue("autorun")}:{},imports:y,sources:w,..._?{localGivens:_}:{},...Object.keys(O).length>0?{startingGivens:O}:{},...g.length>0?{drills:g}:{},tiles:b}}}const Rs=e=>e.ok===!1;async function vl(e){const{problems:t}=await Js(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 Pu(e){return e.replace(/^(?:[ \t]*\r?\n)+/,"").trimEnd()}function Rm(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;for(const r of[...t].sort((s,i)=>i.start-s.start||i.end-s.end))n=n.slice(0,r.start)+r.text+n.slice(r.end);return n}const Mu=e=>e==="none"||Qs(e)?e:void 0;function ju(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=${bt(e.label)}`),e.subtitle!==void 0&&n.push(`# subtitle=${bt(e.subtitle)}`);const r=t?Mu(e.chart):void 0;return r!==void 0&&n.push(yn(r,e.chartCarried)),n}function gs(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"]),Xe=e=>e.kind??"dashboard";function bl(e){const t=[];if(e.label!==void 0&&t.push(`label=${bt(e.label)}`),e.description!==void 0&&t.push(`description=${bt(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=${bt(e.suggest.query)}`:void 0;t.push(`suggest { ${n?`${n} `:""}dimension=${bt(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 yl=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 xl(e){return`# drill { to=${e.to.length===1?e.to[0]:`[${e.to.map(n=>`"${n}"`).join(", ")}]`}${e.given?` given=${e.given}`:""} }`}const Ls=e=>`${e.source}.${e.name}`,bt=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,vo=e=>je(e)?_e(["text",e.name]):_e([e.name,e.source,e.declaration]),nt=vo,wl=e=>_e(e.tiles.map(nt));function Wm(e,t,n){if(Xe(e)!==Xe(t)&&!n)return{ok:!1,reason:"The document's kind is not changed by an ordinary edit; switch it with the explicit kind change."};const r=new Set(e.tiles.map(nt)),s=new Set(t.tiles.map(nt)),i=e.tiles.filter(f=>!s.has(nt(f))),o=t.tiles.filter(f=>!r.has(nt(f))),l=i.length>0||o.length>0||wl(e)!==wl(t);for(const f of o)if(xe(f)&&f.declaration.kind!=="reference")return{ok:!1,reason:`A new tile names a view of a source; \`${f.name}\` is ${f.declaration.kind==="inline"?"an inline query":"not declared here"}, which the builder cannot write.`};const u=new Map(e.sources.map(f=>[f.name,f])),c=new Set(t.imports.flatMap(f=>f.kind==="names"?f.names:[]));for(const f of e.sources)c.add(f.base);const d=t.sources.filter(f=>!u.has(f.name));for(const f of e.sources){const p=t.sources.find(h=>h.name===f.name);if(!p||p.base!==f.base)return{ok:!1,reason:`The source \`${f.name}\` cannot be changed or removed here.`}}for(const f of d){if(!o.some(p=>xe(p)&&p.source===f.name))return{ok:!1,reason:`A new source \`${f.name}\` needs a tile on it.`};if(!c.has(f.base))return{ok:!1,reason:`\`${f.base}\` is not imported by name in this file, so a tile cannot be put on it. Add it as a source first.`}}return{currentKeys:r,nextKeys:s,removedTiles:i,addedTiles:o,newSources:d,currentSources:u,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=Or(e,n);t+="x".repeat(Math.min(r,e.length-1)-n+1),n=r}return t}function kl(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=u=>{const c=u.exec(o);c&&(i=i.slice(0,c.index)+i.slice(c.index+c[0].length),o=o.slice(0,c.index)+o.slice(c.index+c[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,u=new Map(r.tiles.filter(je).map(g=>[g.name,g])),c=s.tiles.filter(je).some(g=>{const m=u.get(g.name);return m!==void 0&&_l(m,g)});if(!i&&!c)return;const d=me.artifactTag(t);if(!d)return{ok:!1,reason:"Could not find the `## artifact` tag to reorder."};const f=d.text,p=_a(f);if(!p)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 dashboard with no tiles is not served, so the last tile cannot be removed. Add another tile first."};const h=new Map;for(const{text:g}of p.entries){const m=/^"((?:[^"\\]|\\.)+)"$/.exec(g);if(m){const _=m[1].split("->").map(O=>O.trim());_.length===2&&h.set(`${_[0]}->${_[1]}`,g);continue}const b=/^([A-Za-z_][A-Za-z0-9_]*)\s*\{/.exec(g)?.[1];b!==void 0&&h.set(`text.${b}`,g)}const v=s.tiles.map(g=>{const m=!o.has(nt(g));if(je(g)){const b=h.get(`text.${g.name}`);return b!==void 0?u.has(g.name)&&!_l(u.get(g.name),g)?b:kl(g,b):m?kl(g):void 0}return h.get(`${g.source}->${g.name}`)??(m?`"${g.source} -> ${g.name}"`:void 0)});if(v.some(g=>g===void 0))return{ok:!1,reason:"A tile in the new order is not one the `## artifact` tag names."};const y=f.slice(0,p.open).search(/tiles\s*=\s*$/),w=`${f.slice(0,y)}tiles=[${qm(f,p,v)}]${f.slice(p.close+1)}`;w!==f&&l.push({...Ru(n,d),text:`${w}
|
|
78
|
+
`})}function Ru(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
|
+
`)),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 Sl(e,t){let n=0,r=0;for(let s=0;s<e.length;s++){const i=e[s];if(i==='"')s=Or(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]==='"'?Or(e,a)+1:a+(/^[^\s}]*/.exec(e.slice(a))?.[0].length??0),u=s-(/\s*$/.exec(e.slice(0,s))?.[0].length??0);return e.slice(0,u)+e.slice(l)}}return e}function Km(e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];if(r==='"')n=Or(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=Or(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 Or(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(Xe(r)!==Xe(s)||r.title!==s.title||r.autorun!==s.autorun||r.columns!==s.columns||_e(r.startingGivens)!==_e(s.startingGivens)){const o=me.artifactTag(t);if(!o)return{ok:!1,reason:"Could not find the `## artifact` tag to change the page's settings."};const a=Ru(n,o),l=i.find(g=>g.start===a.start&&g.end===a.end);let u=l?l.text.replace(/\n$/,""):o.text;Xe(r)!==Xe(s)&&(u=Sl(u,"kind"));const c=u.indexOf("artifact"),d=u.indexOf("{",c);let f=0,p=-1;for(let g=d;g<u.length;g++)if(u[g]==="{")f++;else if(u[g]==="}"&&--f===0){p=g;break}if(d<0||p<0)return{ok:!1,reason:"Could not read the `## artifact { … }` tag."};let h=u.slice(d+1,p);const v=o.block?`
|
|
81
|
+
${/\n([ \t]+)\S/.exec(h)?.[1]??" "}`:" ",y=g=>o.block?`${h.trimEnd()}${v}${g}
|
|
82
|
+
`:`${h.trimEnd()} ${g} `,w=(g,m)=>{const b=new RegExp(`${o.block?"[ \\t]*":"\\s*"}\\b${g}=(?:"(?:[^"\\\\]|\\\\.)*"|[^\\s}]+)`);if(m===void 0){const _=new RegExp(`
|
|
83
|
+
${b.source}[ \\t]*(?=
|
|
84
|
+
)`);h=h.replace(o.block&&_.test(h)?_:b,"")}else b.test(h)?h=h.replace(b,_=>`${o.block?_.slice(0,_.length-_.trimStart().length):" "}${g}=${m}`):h=y(`${g}=${m}`)};if(Xe(r)!==Xe(s)&&Xe(s)==="notebook"?h=y("kind=notebook"):Xe(r)!==Xe(s)&&(e.explicitKind||!e.modelPath?.startsWith("dashboards/"))&&(h=y("kind=dashboard")),r.title!==s.title&&w("title",s.title?bt(s.title):void 0),r.autorun!==s.autorun&&w("autorun",s.autorun===void 0?void 0:String(s.autorun)),_e(r.startingGivens)!==_e(s.startingGivens)){h=h.replace(/\s*\bgivens\s*\{[^}]*\}/,"");const g=Object.entries(s.startingGivens??{});g.length>0&&(h=y(`givens { ${g.map(([m,b])=>`${m}=${bt(b)}`).join(" ")} }`))}o.block?u=`${u.slice(0,d+1)}${h}${u.slice(p)}`:(h=h.replace(/\s{2,}/g," "),u=`${u.slice(0,d+1)}${h.startsWith(" ")?h:` ${h}`}${h.endsWith(" ")?"":" "}${u.slice(p)}`),r.columns!==s.columns&&(u=Sl(u,"dashboard_columns"),u=Km(u),s.columns!==void 0&&(u=`${u.trimEnd()} dashboard { columns=${s.columns} }`)),l?l.text=`${u}
|
|
85
|
+
`:i.push({...a,text:`${u}
|
|
86
|
+
`})}if(r.description!==s.description){const{read:o,blankAbove:a,below:l,belowBlock:u,inBlock:c}=me.descriptionNotes(t);if(c||s.description===void 0&&u)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 d=Pu(s.description??"").split(`
|
|
87
|
+
`).map(v=>v.trim()===""?'##"':`##" ${v.trim()}`).join(`
|
|
88
|
+
`),f=o.length>0&&o[0]<me.artifactLine(t),p=s.description===void 0,h=f?[...o.slice(1),...p?l:[]]:[...o,...a];for(const v of h)i.push({...n(v),text:""});if(f)i.push({...n(o[0]),text:s.description===void 0?"":`${d}
|
|
89
|
+
`});else if(s.description!==void 0){const v=n(me.artifactLine(t)).start;i.push({start:v,end:v,text:`${d}
|
|
90
|
+
`})}}}function Vm(e){const{lines:t,wholeLine:n,indentOf:r,current:s,next:i,edits:o,parsed:a}=e,l=new Map((s.localGivens??[]).map(p=>[p.name,p])),u=new Map((i.localGivens??[]).map(p=>[p.name,p])),c=new Map(a.givens.map(p=>[p.name,p])),d=new Set;for(const[p,h]of l){const v=u.get(p);if(v!==void 0&&_e(v)===_e(h))continue;const y=c.get(p);if(y===void 0)return{ok:!1,reason:`Could not find where the given \`${p}\` is declared.`};const{tags:w,prose:g}=Fr(a,t,y.line),b=[...(v===void 0?w:w.filter(D=>{const L=gs(D.text);return L!==void 0&&Fm.has(L)})).map(D=>D.line),...v===void 0?g:[]];for(const D of b)o.push({...n(D),text:""}),d.add(D);const _=_t(a,y.span.end-1);if(v===void 0){o.push({start:n(y.line).start,end:n(_).end,text:""});for(let G=y.line;G<=_;G++)d.add(G);const D=Math.min(y.line,...b),L=y.blockHeader??D,R=(t[_+1]??"x").trim()==="",z=L===0||t[L-1].trim()==="",K=y.blockHeader===void 0||![...c.values()].some(G=>G.blockHeader===y.blockHeader&&G.line>y.line&&u.has([...c.entries()].find(([,X])=>X===G)?.[0]??""));R&&z&&K&&!d.has(_+1)&&(o.push({...n(_+1),text:""}),d.add(_+1));continue}const O=r(y.line),E=bl(v),T=v.type!==h.type||v.default!==h.default?y.blockHeader===void 0?yl(v):`${v.name} :: ${v.type} is ${v.default}`:t.slice(y.line,_+1).join(`
|
|
91
|
+
`).trim();o.push({start:n(y.line).start,end:n(_).end,text:(E?`${O}${E}
|
|
92
|
+
`:"")+`${O}${T}
|
|
93
|
+
`})}for(const[p,h]of c){if(h.blockHeader===void 0||u.has(p))continue;![...c.values()].some(y=>y.blockHeader===h.blockHeader&&!d.has(y.line))&&!d.has(h.blockHeader)&&(o.push({...n(h.blockHeader),text:""}),d.add(h.blockHeader))}const f=[...u.values()].filter(p=>!l.has(p.name));if(f.length>0){const p=Math.max(-1,...[...c.values()].map(m=>m.line)),h=(()=>{let m=-1;for(let b=0;b<t.length;b++){const _=t[b].trim();(_.startsWith("import ")||m>=0&&/^}\s*from\s/.test(_))&&(m=b)}return m})(),v=p>=0?p:h,y=f.map(m=>{const b=bl(m);return(b?`${b}
|
|
94
|
+
`:"")+`${yl(m)}
|
|
87
95
|
`}).join(`
|
|
88
|
-
`),
|
|
89
|
-
${
|
|
90
|
-
`})}}function
|
|
91
|
-
`});
|
|
92
|
-
`})
|
|
93
|
-
`)}
|
|
94
|
-
`)
|
|
96
|
+
`),w=v>=0?n(v).end:n(0).end;o.push({start:w,end:w,text:`
|
|
97
|
+
${y}`}),t.some(m=>m.trim().startsWith("##! experimental.givens"))||o.push({start:0,end:0,text:`##! experimental.givens
|
|
98
|
+
`})}}const $l=(e,t)=>`import { ${e.join(", ")} } from ${bt(t)}`;function Hm(e){const{parsed:t,current:n,next:r,edits:s,wholeLine:i}=e,o=d=>_e(d.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(d=>d.kind==="names"?[{...d,claimed:!1}]:[]),l=new Set([...r.sources.map(d=>d.base),...r.tiles.filter(xe).map(d=>d.source)]),u=t.imports.map((d,f)=>({statement:d,entry:n.imports[f]}));for(const{statement:d,entry:f}of u){if(!f||f.kind!=="names")continue;const p=a.find(m=>!m.claimed&&m.from===f.from);p&&(p.claimed=!0);const h=p?.names??[],y=f.names.filter(m=>!h.includes(m)).find(m=>l.has(m));if(y!==void 0)return{ok:!1,reason:`\`${y}\` is still read by a tile, so its import cannot be removed.`};if(_e(h)===_e(f.names))continue;const w=h.length===0?ka(t,d.statement):d.statement,g=t.commentIn(w);if(g)return{ok:!1,reason:`Changing this import would also remove the comment inside it (\`${t.text.slice(g.start,g.end).trim()}\`), so nothing was written. Delete it in the file first.`};s.push({...w,text:h.length===0?"":$l(h,f.from)})}const c=a.filter(d=>!d.claimed);if(c.length>0){const d=t.imports.at(-1);if(!d)return{ok:!1,reason:"This file has no `import` to put a source beside. Import its first source in the file."};const f=i(_t(t,d.statement.end-1)).end;s.push({start:f,end:f,text:c.map(p=>`${$l(p.names,p.from)}
|
|
99
|
+
`).join("")})}}function Xm(e){const{lines:t,wholeLine:n,indentOf:r,current:s,next:i,edits:o,parsed:a}=e,l=new Map((s.drills??[]).map(c=>[Ls(c),c])),u=new Map((i.drills??[]).map(c=>[Ls(c),c]));for(const c of new Set([...l.keys(),...u.keys()])){const d=l.get(c),f=u.get(c);if(d&&f&&_e(d)===_e(f))continue;const p=f??d;if(f&&f.to.length===0)return{ok:!1,reason:`The drill on \`${c}\` names no destination.`};const h=a.sources.find(g=>g.name===p.source)?.dimensions.find(g=>g.name===p.name);if(h===void 0)return{ok:!1,reason:`\`${p.name}\` is not a dimension \`${p.source}\` declares in this file, so a drill cannot be put on it here.`};const{tags:v}=Fr(a,t,h.line),y=v.find(g=>/^#\s*drill\b/.test(g.text)),w=r(h.line);if(f===void 0)y&&o.push({...n(y.line),text:""});else if(y)o.push({...n(y.line),text:`${w}${xl(f)}
|
|
100
|
+
`});else{const g=n(h.line).start;o.push({start:g,end:g,text:`${w}${xl(f)}
|
|
101
|
+
`})}}}function Ym(e){const{lines:t,wholeLine:n,removedTiles:r,edits:s,parsed:i}=e;for(const o of r){if(je(o)||o.declaration.kind==="inherited")continue;const a=Lu(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=_t(i,a.statement.start),u=_t(i,a.statement.end-1),c=i.trailingComment(u),d=c&&c.start>=a.statement.end?c.end:a.statement.end;if(i.text.slice(i.lineStarts[l],a.statement.start).trim()!==""||i.text.slice(d,n(u).end).trim()!==""){s.push({...ka(i,a.statement),text:""});continue}s.push({start:i.lineStarts[l],end:n(u).end,text:""});const p=l===0?"":t[l-1].trim();(t[u+1]??"x").trim()===""&&(l===0||p===""||p.endsWith("{"))&&s.push({...n(u+1),text:""})}}function Zm(e){const{sourceText:t,lines:n,wholeLine:r,addedTiles:s,newSources:i,currentSources:o,edits:a,parsed:l}=e,u=new Map;for(const f of s){if(je(f))continue;const p=u.get(f.source)??[];p.push(f),u.set(f.source,p)}const c=(f,p)=>{const h=f.declaration.kind==="reference"?f.declaration.from:f.name,v=(f.filters??[]).map(y=>`where: ${me.malloyPath(y.field)} ${y.op??"~"} $${y.given}`).join(", ");return[...ju(f).map(y=>`${p}${y}`),`${p}view: ${f.name} is ${h}${v?` + { ${v} }`:""}`].join(`
|
|
102
|
+
`)};let d=-1;for(const f of l.sources)d=Math.max(d,_t(l,f.span.end-1));for(const[f,p]of u)if(o.has(f)){const h=l.sources.find(b=>b.name===f);if(!h)return{ok:!1,reason:`Could not find where the source \`${f}\` is declared.`};if(!h.properties)return{ok:!1,reason:`\`${f}\` never opens an \`extend { … }\` block, so a new tile cannot be added inside it.`};const v=h.line,y=_t(l,h.properties.closeStart);let w=" ";for(let b=v+1;b<y;b++){const _=/^(\s+)view:/.exec(n[b]);if(_){w=_[1];break}}const g=r(y).start,m=(n[y-1]??"").trim()==="";a.push({start:g,end:g,text:(m?"":`
|
|
103
|
+
`)+p.map(b=>c(b,w)).join(`
|
|
95
104
|
|
|
96
105
|
`)+`
|
|
97
|
-
`})}else{const
|
|
98
|
-
source: ${
|
|
99
|
-
`+
|
|
106
|
+
`})}else{const h=i.find(m=>m.name===f);if(!h)return{ok:!1,reason:`The tile's source \`${f}\` is not declared.`};const v=`
|
|
107
|
+
source: ${h.name} is ${h.base} extend {
|
|
108
|
+
`+p.map(m=>c(m," ")).join(`
|
|
100
109
|
|
|
101
110
|
`)+`
|
|
102
111
|
}
|
|
103
|
-
`;let
|
|
112
|
+
`;let y=d;if(y<0)for(let m=0;m<n.length;m++){const b=n[m].trim();(/^(import\s|given:|}\s*from\s)/.test(b)||/^[A-Z_]+\s*::/.test(b))&&(y=m)}const w=y>=0?r(y).end:t.length,g=w===t.length&&!t.endsWith(`
|
|
104
113
|
`)?`
|
|
105
|
-
`:"";a.push({start:
|
|
106
|
-
`})}const
|
|
107
|
-
`
|
|
108
|
-
|
|
109
|
-
${
|
|
110
|
-
`),a=lv(e),l=p=>({start:a[p],end:p+1<a.length?a[p+1]:e.length}),u=p=>/^\s*/.exec(o[p])?.[0]??"",d=[],c={...i,sourceText:e,parsed:s.parsed,lines:o,starts:a,wholeLine:l,indentOf:u,current:r,next:t,edits:d};for(const p of[gv,yv,bv,xv,wv,_v,kv]){const w=p(c);if(w)return w}const h=p=>{const{drills:w,localGivens:x,...m}=p,g=p.tiles.map(b=>{if(b.filters?.length)return b;const{filters:_,...$}=b;return $});return{...m,tiles:g,...w?.length?{drills:[...w].sort((b,_)=>Di(b).localeCompare(Di(_)))}:{},...x?.length?{localGivens:x}:{}}};if(d.length===0)return be(h(r))!==be(h(t))?{ok:!1,reason:"No part of this edit was recognized, so nothing was written. Your changes are still here."}:{ok:!0,source:e};const f=cv(e,d);if((await Ja(e)).length===0){const p=await Ja(f);if(p.length>0)return{ok:!1,reason:`The edit would have produced a file Malloy cannot parse, so it was not written (${p[0]}). Your changes are still here.`}}const v=await Ti(f);return Oi(v)?{ok:!1,reason:`The edit produced a file that cannot be read back: ${v.reason}`}:be(h(v.document))!==be(h(t))?{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:f}}function Ov(e){const[t,n]=S.useState({stack:[e.document],index:0}),[r,i]=S.useState(e.source),[s,o]=S.useState(void 0),[a,l]=S.useState(e.document),u=t.stack[t.index],d=S.useCallback(x=>{o(void 0),n(m=>{const g=structuredClone(m.stack[m.index]);if(x(g),JSON.stringify(g)===JSON.stringify(m.stack[m.index]))return m;const _=[...m.stack.slice(0,m.index+1),g].slice(-100);return{stack:_,index:_.length-1}})},[]),c=S.useCallback(()=>{o(void 0),n(x=>x.index>0?{...x,index:x.index-1}:x)},[]),h=S.useCallback(()=>{o(void 0),n(x=>x.index<x.stack.length-1?{...x,index:x.index+1}:x)},[]),f=S.useCallback(async()=>{const x=await eo(r,u);if(Zs(x))return o(x.reason),{ok:!1,reason:x.reason};try{await e.onSave?.(x.source)}catch(m){const g=`Could not save: ${m}`;return o(g),{ok:!1,reason:g}}return i(x.source),l(u),o(void 0),{ok:!0}},[u,e,r]),v=S.useMemo(()=>JSON.stringify(u)!==JSON.stringify(a),[u,a]),p=S.useMemo(()=>{const x=new Set(a.tiles.map(Js)),m=new Set(u.tiles.map(Js));return[...x].some(g=>!m.has(g))||[...m].some(g=>!x.has(g))},[u,a]),w=S.useCallback(async()=>{const x=await eo(r,u);return Zs(x)?{ok:!1,reason:x.reason}:{ok:!0,source:x.source}},[u,r]);return{document:u,source:r,canUndo:t.index>0,canRedo:t.index<t.stack.length-1,dirty:v,...s===void 0?{}:{error:s},update:d,undo:c,redo:h,save:f,preview:w,structural:p}}function eu({source:e,document:t,onSave:n,onChange:r,onDirtyChange:i,renderTile:s,controls:o,givens:a,catalog:l,toolbar:u,dashboards:d,onEvent:c,savesTo:h="package"}){const f=Ov({source:e,document:t,...n?{onSave:n}:{}}),[v,p]=S.useState(void 0),[w,x]=S.useState(!1),m=f.document.columns??j.DEFAULT_COLUMNS,{resize:g,gridBox:b,startResize:_,onResize:$,endResize:O}=Bg({tiles:f.document.tiles,columns:m,onStart:p,commit:(E,D)=>f.update(B=>{B.tiles[E].colspan=D})}),{dragging:C,preview:I,onDragStart:P,onDragOver:U,onDragEnd:W}=Ng({tiles:f.document.tiles,commit:E=>f.update(D=>{D.tiles=E}),onLanded:p}),[M,z]=S.useState(void 0),[V,ee]=S.useState(void 0),[Se,oe]=S.useState(!1),[Le,Ve]=S.useState(void 0),[Ce,Ye]=S.useState(null),[Ge,We]=S.useState(void 0);S.useEffect(()=>{r?.(f.document)},[f.document,r]),S.useEffect(()=>{i?.(f.dirty)},[f.dirty,i]);const Xe=S.useMemo(()=>zp(f.document),[f.document]),$e=S.useMemo(()=>{const E=new Set((t.localGivens??[]).map(D=>D.name));return(a??[]).filter(D=>!E.has(D.name))},[t,a]),fe=S.useMemo(()=>dp(f.document,$e),[f.document,$e]),L=S.useMemo(()=>new Map(f.document.sources.map(E=>[E.name,Aa(l,E.base)])),[l,f.document.sources]),G=S.useCallback(E=>L.get(E.source)??Aa(l,E.source),[L,l]),_e=(E,D)=>{const B=[];for(const Q of f.document.tiles){const Ue=G(Q);if(!Ue)continue;const ke=new Map(Ue.map(se=>[se.name,se.type]));for(const se of Q.filters??[])se.given===E&&(!ke.has(se.field)||!ai(D,ke.get(se.field)))&&B.push(`${se.field} on ${Q.label??Q.name} (${f.document.sources.find(Ee=>Ee.name===Q.source)?.base??Q.source})`)}return B},X=S.useMemo(()=>fe.filter(E=>E.origin==="model"&&E.boundTiles===0),[fe]),ze=S.useCallback(()=>{We(void 0),x(!0);const E=j.now(),{structural:D}=f,B=f.document.tiles.length;f.save().then(Q=>{Q.ok===!0?c?.({type:"dashboard.saved",tiles:B,structural:D,where:h,durationMs:j.now()-E}):c?.({type:"dashboard.save_refused",reason:Q.reason})}).finally(()=>x(!1))},[f,c,h]),ne=S.useCallback(()=>{if(!(!n||!f.dirty||w)){if(!f.structural){ze();return}f.preview().then(E=>{E.ok?We({before:f.source,after:E.source}):ze()})}},[n,f,w,ze]),at=E=>{oe(!1),f.update(D=>{let B=D.sources.find(ke=>ke.base===E.base);if(!B){const ke=new Set(D.sources.map(Ee=>Ee.name));let se=`${E.base}_tiles`;for(let Ee=2;ke.has(se);Ee++)se=`${E.base}_tiles_${Ee}`;B={name:se,base:E.base},D.sources.push(B)}const Q=new Set(D.tiles.filter(ke=>ke.source===B.name).map(ke=>ke.name));let Ue=`${E.view}_tile`;for(let ke=2;Q.has(Ue);ke++)Ue=`${E.view}_tile_${ke}`;D.tiles.push({name:Ue,source:B.name,declaration:{kind:"reference",from:E.view},colspan:E.colspan,...E.label?{label:E.label}:{}})}),p(f.document.tiles.length)},Fe=E=>{ee(void 0),p(void 0),f.update(D=>{D.tiles.splice(E,1)})};Sp(S.useMemo(()=>({undo:f.undo,redo:f.redo,...n?{save:ne}:{},escape:()=>{!V&&!M&&p(void 0)},nudge:E=>{if(v===void 0)return;const D=f.document.tiles[v];if(!D||D.declaration.kind==="inherited")return;const B=Math.min(Math.max((D.colspan??1)+E,1),m);B!==(D.colspan??1)&&f.update(Q=>{Q.tiles[v].colspan=B})}}),[f,n,ne,V,M,v,m]));const xt=(E,D,B)=>{z(void 0),f.update(Q=>{B&&mp(Q,B),vp(Q,E,D)})},T=E=>{z(void 0),f.update(D=>yp(D,E))},A=(()=>{const E=f.document.tiles;return g!==void 0?E.map((D,B)=>B===g.index?{...D,colspan:g.span}:D):I??E})(),q=C?Up(A,m):A.map(Pd);return y.jsxs(k.Stack,{sx:{gap:0},children:[y.jsx($p,{canUndo:f.canUndo,canRedo:f.canRedo,onUndo:f.undo,onRedo:f.redo,dirty:f.dirty,saving:w,...n?{onSave:ne}:{},...u?{actions:u}:{},...l?{onAddTile:()=>oe(!0)}:{},onSettings:Ye}),y.jsxs(k.Stack,{sx:{gap:2,px:"4px",pb:"4px"},children:[y.jsx(j.DashboardProse,{title:f.document.title||"Untitled dashboard",...f.document.description?{description:f.document.description}:{}}),y.jsx(Bp,{controls:fe,tileCount:f.document.tiles.length,unknownFieldsOf:_e,onEdit:E=>z({control:E}),onAdd:()=>z({}),children:o}),f.error&&y.jsx(k.Alert,{severity:"warning",children:f.error}),y.jsx(Hh,{sensors:kg,onDragStart:P,onDragOver:U,onDragEnd:W,children:y.jsxs(k.Box,{ref:b,sx:{position:"relative"},children:[(g!==void 0||C)&&y.jsx(Mg,{columns:m}),y.jsx(j.DashboardGrid,{tiles:q,columns:m,keyOf:E=>E.kind==="gap"?Md(E.after):pt(E.tile),renderTile:E=>{if(E.kind==="gap")return y.jsx(Pg,{after:E.after});const{tile:D,index:B}=E;return y.jsx(Dg,{tile:D,index:B,selected:B===v,menuOpen:V?.index===B,resizeSpan:g?.index===B?g.span:void 0,columns:m,onSelect:()=>p(B),onOpenMenu:Q=>{p(B),ee({anchor:Q,index:B})},onResizeStart:Q=>_(Q,B),onResizeMove:$,onResizeEnd:O,children:s?s(D):y.jsx(Cg,{tile:D})})}})]})}),y.jsx(Wp,{open:M!==void 0,document:f.document,...M?.control?{control:M.control}:{},available:X,...l?{fieldsFor:G}:{},onClose:()=>z(void 0),onApply:xt,onRemove:T}),y.jsx(Vg,{anchor:V?.anchor??null,tile:V===void 0?void 0:f.document.tiles[V.index],onClose:()=>ee(void 0),onCommit:E=>{const D=V?.index;D!==void 0&&f.update(B=>{B.tiles[D]=E})},onRemove:()=>{V!==void 0&&Fe(V.index)},columns:m,onDrills:()=>{V!==void 0&&Ve(f.document.tiles[V.index]?.source)}}),y.jsx(Rp,{open:Le!==void 0,document:f.document,source:f.document.sources.find(E=>E.name===Le),givenNames:fe.map(E=>E.name),dashboards:d??[],onClose:()=>Ve(void 0),onApply:E=>f.update(D=>{const Q=[...(D.drills??[]).filter(Ue=>Ue.source!==Le),...E];Q.length===0?delete D.drills:D.drills=Q})}),y.jsx(Fp,{anchor:Ce,settings:Xe,onClose:()=>Ye(null),onCommit:E=>f.update(D=>{D.title=E.title,E.description===void 0?delete D.description:D.description=E.description,E.columns===void 0?delete D.columns:D.columns=E.columns,E.autorun===void 0?delete D.autorun:D.autorun=E.autorun})}),y.jsx(Mp,{open:Se,document:f.document,catalog:l,columns:m,onClose:()=>oe(!1),onAdd:at}),y.jsx(Ap,{open:Ge!==void 0,before:Ge?.before??"",after:Ge?.after??"",onConfirm:ze,onClose:()=>We(void 0)})]})]})}function Tv(e,t){const n=new Set;for(const s of e.tiles)for(const o of s.filters??[])n.add(o.given);const r=[],i=new Set;for(const s of e.localGivens??[])n.has(s.name)&&(i.add(s.name),r.push(Dv(s)));for(const s of t)s.name===void 0||i.has(s.name)||!n.has(s.name)||(i.add(s.name),r.push(s));return r}function Dv(e){return{name:e.name,type:e.type,default:e.default,...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 Cv(e,t,n,r=new Map){if(t.declaration.kind==="inherited")return{expression:`${t.source} -> ${t.name}`,givenNames:void 0};const i=t.source,s=t.declaration.kind==="reference"?t.declaration.from:t.name,o=new Map((e.localGivens??[]).map(d=>[d.name,d.type])),a=[],l=[];for(const d of t.filters??[]){const c=`where: ${d.field} ${d.op??"~"}`;if(n.has(d.given)){a.push(d.given),l.push(`${c} $${d.given}`);continue}if(!o.has(d.given))continue;const h=j.malloyLiteral(r.get(d.given),o.get(d.given));h!==void 0&&l.push(`${c} ${h}`)}const u=l.join(", ");return{expression:`${i} -> ${s}`+(u?` + { ${u} }`:""),givenNames:a}}async function Pv(e){const t=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return Array.from(new Uint8Array(t),n=>n.toString(16).padStart(2,"0")).join("")}const sl=(e,t,n,r)=>({workspace:e,type:"dashboard",path:`${t}/${n}/${r}`});function Mv(e){const{onExit:t,onEvent:n,onDirtyChange:r}=e,i=(()=>{if("resourceUri"in e)try{return j.parseResourceUri(e.resourceUri)}catch{return}})(),s="resourceUri"in e?i?.environmentName??"":e.environmentName,o="resourceUri"in e?i?.packageName??"":e.packageName,a="resourceUri"in e?e.dashboard:e.dashboardName,l=i?.versionId,u="resourceUri"in e?!!i?.environmentName&&!!i?.packageName:!0,{apiClients:d,mutable:c}=Be.useServer(),h=cu.useQueryClient(),f=S.useRef(j.now()),v=S.useRef(n);v.current=n;const p=S.useRef(r);p.current=r;const w=j.useOptionalDocumentStorage()?.documentStorage,x=`dashboards/${a}.malloy`,m=j.useQueryWithApiError({queryKey:["dashboard-editor-model",s,o,x,l],queryFn:()=>d.models.getModel(s,o,x,l),enabled:u}),g=m.data?.data?.sourceText,[b,_]=S.useState(void 0),[$,O]=S.useState(void 0),[C,I]=S.useState(w===void 0),[P,U]=S.useState(!1),[W,M]=S.useState(void 0);S.useEffect(()=>{if(!w)return;let R=!1;return M(void 0),(async()=>{try{const te=await w.listWorkspaces(!1),Oe=te.find(he=>he.authoritative)??te.find(he=>he.writeable);if(R)return;if(_(Oe),Oe!==void 0){const he=await w.getDocument(sl(Oe.name,s,o,x)).catch(ae=>{if(!j.isDocumentNotFound(ae))throw ae});if(R)return;O(he),U(he!==void 0)}}catch(te){if(R)return;M(ol(te))}R||I(!0)})(),()=>{R=!0}},[w,s,o,x]);const z=b?.authoritative===!0,V=z&&W!==void 0,[ee,Se]=S.useState(void 0),oe=(z||ee===!0)&&$!==void 0,[Le,Ve]=S.useState(void 0),[Ce,Ye]=S.useState(void 0),Ge=S.useRef(void 0),We=S.useRef(void 0),[Xe,$e]=S.useState(void 0),fe=m.dataUpdatedAt,L=S.useRef(fe);L.current=fe;const G=Xe!==void 0&&Xe.onFetch===fe?Xe.text:g,_e=S.useRef(G);_e.current=G;const X=oe?$:G,[ze,ne]=S.useState(!1),[at,Fe]=S.useState(void 0),[xt,T]=S.useState(void 0),A=X!==void 0&&X!==xt,q=Le?.source,E=A&&ze&&q!==void 0&&X!==at,D=E?q:A?X:q??X,B=E?X:void 0,Q=S.useRef(q);Q.current=q;const Ue=S.useRef(X);Ue.current=X;const ke=S.useRef("package");ke.current=oe?z?"record":"draft":"package",S.useEffect(()=>{if(D===void 0||!C||V||D===Q.current)return;let R=!1;const te=_e.current,Oe=Ue.current;return Ti(D).then(he=>{if(!R){if(Oi(he)){const ae=he.line?`${he.reason} (line ${he.line})`:he.reason;Ye(ae),v.current?.({type:"dashboard.open_refused",reason:ae});return}Ye(void 0),Ge.current=void 0,We.current=te,$e(void 0),Fe(void 0),T(Oe),Ve(ae=>({source:D,document:he.document,generation:(ae?.generation??0)+1})),v.current?.({type:"dashboard.opened",from:ke.current,tiles:he.document.tiles.length,durationMs:j.now()-f.current})}}),()=>{R=!0}},[D,C,V]);const se=b===void 0?void 0:sl(b.name,s,o,x),Ee=S.useCallback(async R=>{if(!w||!se)throw new Error("This host keeps no documents, so there is nowhere to save.");await w.saveDocument(se,R),Ve(te=>te&&{...te,source:R}),O(R),(z||ee===!0)&&T(R),z||Se(te=>te??!1)},[w,se,z,ee]),[Qt,Ct]=S.useState(void 0),Rr=S.useCallback(async R=>{const te=We.current,Oe=Ge.current??(te===void 0?void 0:await Pv(te));if(Oe===void 0)throw new Error("The package file is still loading; try again.");let he;try{he=await d.models.updateModelSource(s,o,x,{source:R,expectedHash:Oe})}catch(ae){throw h.invalidateQueries({queryKey:["dashboard-editor-model",s,o,x,l]}),new Error(Av(ae))}if(Ve(ae=>ae&&{...ae,source:R}),$e({text:R,onFetch:L.current}),T(R),Ge.current=he.data.contentHash,Ct(void 0),w&&se)try{await w.deleteDocument(se),O(void 0),U(!1)}catch(ae){j.isDocumentNotFound(ae)?(O(void 0),U(!1)):Ct(ol(ae))}Se(!1),await h.invalidateQueries({queryKey:["dashboard-editor-model",s,o,x,l]});for(const ae of["dashboard-editor-manifest","dashboards","dashboard"])h.invalidateQueries({queryKey:[ae]})},[d,s,o,x,l,w,se,h]),Pt=z?"host":c?"package":"browser",Zt=b?.writeable===!0,Wn=l!==void 0&&Pt==="package",Lr=W===void 0?z?w&&se&&Zt?Ee:void 0:Wn?void 0:c?Rr:w&&se&&Zt?Ee:void 0:void 0,zn=b?.name,Fn=S.useCallback(R=>{v.current?.(R.type==="dashboard.saved"&&R.where!=="package"&&zn!==void 0?{...R,workspace:zn}:R)},[zn]),Gi=S.useCallback(R=>{ne(R),p.current?.(R)},[]),Nn=R=>{f.current=j.now(),Fe(R?$:G),Se(R)},Ui=()=>{f.current=j.now(),Fe(B)};if(!u&&"resourceUri"in e)return y.jsxs(k.Alert,{severity:"error",sx:{m:2},children:["A dashboard resource URI must name an environment and a package. Received: ",e.resourceUri]});if(m.isError)return y.jsx(j.ApiErrorDisplay,{error:m.error,context:"Opening the dashboard"});if(!g||!C)return y.jsxs(k.Stack,{sx:{gap:2},children:[y.jsx(j.DashboardBar,{}),y.jsx(j.Loading,{text:"Opening the dashboard…"})]});if(V)return y.jsxs(k.Alert,{severity:"error",sx:{m:2},children:["This dashboard cannot be opened: ",W]});if(Ce)return y.jsxs(k.Alert,{severity:"error",sx:{m:2},children:["This dashboard cannot be opened in the builder: ",Ce]});const Z=$!==void 0&&$!==g;return y.jsxs(k.Stack,{sx:{gap:2},children:[!z&&P&&Z&&ee===void 0&&y.jsx(k.Alert,{severity:"info",action:y.jsxs(k.Stack,{direction:"row",sx:{gap:1},children:[y.jsx(k.Button,{size:"small",onClick:()=>Nn(!0),children:"Resume"}),y.jsx(k.Button,{size:"small",onClick:()=>Nn(!1),children:"Start from the package"})]}),children:"You have edits to this dashboard saved in this browser that the package does not have."}),B!==void 0&&y.jsx(k.Alert,{severity:"warning",action:y.jsx(k.Button,{size:"small",onClick:Ui,children:"Load it"}),children:Pt==="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.":Pt==="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."}),Qt!==void 0&&y.jsxs(k.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:"," ",Qt]}),Le&&y.jsx(jv,{environmentName:s,packageName:o,modelPath:x,slug:a,...l!==void 0?{versionId:l}:{},opened:Le,onSave:Lr,onDirtyChange:Gi,savesTo:Pt,...n?{onEvent:Fn}:{},toolbar:t&&y.jsx(j.SecondaryButton,{label:"Done editing",icon:y.jsx(j.CheckIcon,{}),onClick:t}),note:Iv({authoritative:z,mutable:c,pinnedPackageSave:Wn,...b?{workspace:b}:{},...W!==void 0?{readFailure:W}:{},...l!==void 0?{versionId:l}:{}})},Le.generation)]})}function Iv({authoritative:e,mutable:t,pinnedPackageSave:n,workspace:r,readFailure:i,versionId:s}){return i!==void 0?`The saved copy could not be read, so Save is off: ${i}`:e&&r?r.writeable?r.description:`${r.description}: you cannot save into it.`:n?`Reading version ${s}: a version is a fixed point in history, so Save is off.`:t?"Save writes the file into the package.":r?`${r.description}: this server does not take writes.`:"This server does not take writes."}function jv({environmentName:e,packageName:t,modelPath:n,slug:r,versionId:i,opened:s,onSave:o,onDirtyChange:a,onEvent:l,savesTo:u,toolbar:d,note:c}){const{apiClients:h}=Be.useServer(),{data:f,isSuccess:v}=j.useQueryWithApiError({queryKey:["dashboard-editor-manifest",e,t,r,i],queryFn:()=>h.dashboards.getDashboard(e,t,r,i)}),p=f?.data,{data:w}=j.useQueryWithApiError({queryKey:["dashboard-editor-dashboards",e,t,i],queryFn:()=>h.dashboards.listDashboards(e,t,i)}),x=S.useMemo(()=>(w?.data??[]).map(M=>M.name).filter(M=>!!M&&M!==r),[w,r]),m=S.useMemo(()=>{const M=n.slice(0,n.lastIndexOf("/")+1);return s.document.imports.map(z=>({...z,path:new URL(z.from,`https://malloy.invalid/${M}`).pathname.slice(1)}))},[s.document.imports,n]),{data:g}=j.useQueryWithApiError({queryKey:["dashboard-editor-catalog",e,t,...m.map(M=>M.path),i],queryFn:async()=>{const M=(await h.models.listModels(e,t,i)).data.filter(ee=>ee.path&&!ee.error),V=(await Promise.allSettled(M.map(ee=>h.models.getModel(e,t,ee.path,i).then(Se=>Se.data)))).flatMap(ee=>ee.status==="fulfilled"?[ee.value]:[]);return Cp(Td(V),m,V)},enabled:m.length>0}),[b,_]=S.useState(s.document);S.useEffect(()=>_(s.document),[s.document]);const $=S.useMemo(()=>p?.givens??[],[p]),O=S.useMemo(()=>new Set($.map(M=>M.name).filter(M=>M!==void 0)),[$]),C=S.useMemo(()=>Tv(b,$),[b,$]),{declaredTypes:I,applied:P,panel:U}=j.useDocumentControls({specs:C,loaded:v,startingValues:p?.startingGivens,documentKey:`${e}/${t}/${i??""}/${r}/edit`,autorun:p?.autorun!==!1,environmentName:e,packageName:t,modelPath:p?.path,versionId:i,documentName:r}),W=S.useMemo(()=>function(z){const V=Cv(b,z,O,P);return y.jsx(j.DashboardTile,{environmentName:e,packageName:t,versionId:i,modelPath:n,tile:V.expression,label:z.label??j.tileTitle(`${z.source} -> ${z.name}`),subtitle:z.subtitle,borderless:z.borderless,givens:P,declaredTypes:I,givenNames:V.givenNames,height:j.TILE_MAX_HEIGHT})},[b,O,e,t,i,n,P,I]);return y.jsxs(k.Stack,{sx:{gap:1},children:[y.jsx(eu,{source:s.source,document:s.document,renderTile:W,givens:C.filter(M=>M.name!==void 0).map(M=>({name:M.name,...M.label?{label:M.label}:{},...M.type?{type:M.type}:{},...M.suggest?.dimension?{field:M.suggest.dimension}:{}})),onChange:_,onDirtyChange:a,...g?{catalog:g}:{},dashboards:x,...l?{onEvent:l}:{},toolbar:d,controls:v?y.jsx(j.GivensPanel,{...U,layout:"bar"}):void 0,...o?{onSave:o}:{},savesTo:u}),y.jsx(k.Box,{sx:{px:.5},children:y.jsx(k.Typography,{variant:"caption",sx:{opacity:.7},children:c})})]})}function ol(e){return e instanceof Error?e.message:String(e)}function Av(e){const t=e.response?.data;return t?.message?t.message:e instanceof Error?e.message:String(e)}typeof globalThis.process>"u"?globalThis.process={env:{}}:globalThis.process.env===void 0&&(globalThis.process.env={});exports.DashboardBuilder=eu;exports.DashboardEditor=Mv;exports.buildCatalog=Td;exports.readDashboardDocument=Ti;exports.readFailed=Oi;exports.spliceDashboardDocument=eo;exports.spliceFailed=Zs;
|
|
114
|
+
`:"";a.push({start:w,end:w,text:g+v}),d=y}}function Qm(e){const{lines:t,starts:n,wholeLine:r,indentOf:s,current:i,next:o,edits:a,parsed:l}=e,u=new Map(i.tiles.map(c=>[nt(c),c]));for(const c of o.tiles){const d=u.get(nt(c));if(d===void 0||je(c)||je(d)||_e(Ns(d))===_e(Ns(c)))continue;if(c.declaration.kind==="inherited")return{ok:!1,reason:`\`${c.source} -> ${c.name}\` is declared on its source, not in this dashboard, so its presentation cannot be changed here.`};const f=zm(l,c.source,c.name);if(f<0)return{ok:!1,reason:`Could not find where \`${c.name}\` is declared inside \`${c.source}\`.`};const{tags:p}=Fr(l,t,f),h=s(f),v=ju(c,!1),y=new Map(v.map(T=>[gs(T)??T,T])),w=new Set,g=Mu(c.chart),m=Tl(d)!==Tl(c);if(m){const T=p.filter(R=>kr(R.text)),D=p.filter(R=>At(R.text)),L=d.chart==="custom"?p.filter(R=>At(R.text)||kr(R.text)):T.length>0?T:D.length>1?D:[];if(L.length>0)return{ok:!1,reason:`\`${c.source} -> ${c.name}\` has a chart line the builder does not model (${L.map(R=>R.text).join(" and ")}), so its chart cannot be changed here.`}}let b=!1;for(const T of p){if(m&&At(T.text)){g===void 0?a.push({...r(T.line),text:""}):T.text!==yn(g,c.chartCarried)&&a.push({...r(T.line),text:`${h}${yn(g,c.chartCarried)}
|
|
115
|
+
`}),b=!0;continue}const D=gs(T.text);if(D===void 0||!Nm.has(D))continue;const L=y.get(D);if(L===void 0){a.push({...r(T.line),text:""});continue}w.add(D),L!==T.text&&a.push({...r(T.line),text:`${h}${L}
|
|
116
|
+
`})}const _=v.filter(T=>!w.has(gs(T)??T));if(m&&g!==void 0&&!b&&_.push(yn(g,c.chartCarried)),_.length>0){const T=n[f];a.push({start:T,end:T,text:_.map(D=>`${h}${D}
|
|
117
|
+
`).join("")})}if(_e(d.filters)===_e(c.filters))continue;const O=Lu(e,c);if(!O)return{ok:!1,reason:`Could not find \`${c.name}\`'s declaration to filter it.`};if(O.body.kind==="reference"){const T=iv(e,c,O);if(T)return T;continue}if(O.body.kind!=="inline")return{ok:!1,reason:`\`${c.name}\`'s body is ${O.body.why}, so there is no single first stage to write its filter into.`};const E=Nu(c.filters,O.body.stage);if(E)return Fu(c.name,E.given);const I=zu(e,c,O.body.stage);if(I)return I}}const Tl=e=>e.chart==="default"?void 0:e.chart,Ns=e=>{const{chartLines:t,chartCarried:n,...r}=e;if(r.chart!=="default")return r;const{chart:s,...i}=r;return i};function Jm(e,t){const n=new Map(e.tiles.map(r=>[nt(r),r]));return{...t,tiles:t.tiles.map(r=>{const s=n.get(nt(r));return xe(r)&&r.chart===void 0&&s&&xe(s)&&s.chart!==void 0?{...r,chart:s.chart}:r})}}function ms(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 ev(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&&!me.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=ms(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 xi=e=>`##|(markdown) ${e.name}
|
|
118
|
+
${e.markdown===""?"":`${e.markdown}
|
|
119
|
+
`}|##
|
|
120
|
+
`;function tv(e){const{sourceText:t,lines:n,wholeLine:r,current:s,next:i,parsed:o,edits:a}=e,l=new Map(s.tiles.filter(je).map(p=>[p.name,p])),u=i.tiles.filter(je),c=p=>o.textBlocks.find(h=>h.name===p),d=new Set(u.map(p=>p.name));for(const p of l.keys()){const h=d.has(p)?void 0:c(p);if(!h)continue;const v=_t(o,h.span.end-1);a.push({...h.span,text:""});const y=r(v+1),w=h.line===0||n[h.line-1].trim()==="";y.end>y.start&&n[v+1].trim()===""&&w?a.push({...y,text:""}):h.line>0&&w&&t.slice(h.span.end).trim()===""&&a.push({...r(h.line-1),text:""})}const f=[];for(const p of u){const h=l.get(p.name),v=c(p.name);if(h===void 0){if(v)return{ok:!1,reason:`A block named \`${p.name}\` is already in this file, so a new text tile cannot take that name.`};f.push(xi(p))}else h.markdown!==p.markdown&&(v?a.push({...v.span,text:xi(p)}):f.push(xi(p)))}if(f.length>0){const p=o.textBlocks.filter(g=>g.name===void 0||d.has(g.name)),h=p[p.length-1],v=o.sources.find(g=>g.name.endsWith("_tiles"));if(h){const g=h.span.end,m=t.slice(g);a.push({start:g,end:g,text:`
|
|
121
|
+
${f.join(`
|
|
122
|
+
`)}${m===""||m.startsWith(`
|
|
123
|
+
`)?"":`
|
|
124
|
+
`}`});return}if(v){const g=e.starts[o.blockStart(v.line)],m=g===0||t.slice(0,g).endsWith(`
|
|
125
|
+
|
|
126
|
+
`);a.push({start:g,end:g,text:`${m?"":`
|
|
127
|
+
`}${f.join(`
|
|
128
|
+
`)}
|
|
129
|
+
`});return}const y=t.length,w=t===""||t.endsWith(`
|
|
130
|
+
|
|
131
|
+
`)?"":t.endsWith(`
|
|
132
|
+
`)?`
|
|
133
|
+
`:`
|
|
134
|
+
|
|
135
|
+
`;a.push({start:y,end:y,text:w+f.join(`
|
|
136
|
+
`)})}}const Qr=(e,t=me.isBareName)=>t(e)?void 0:`The name ${JSON.stringify(e)} cannot be written as a Malloy name.`;function nv(e,t){const n=new Map(e.tiles.map(o=>[nt(o),o]));if(Xe(t)==="notebook"&&t.columns!==void 0&&(Xe(e)!=="notebook"||t.columns!==e.columns))return"A notebook is one column, so its width is not written. Clear the width when switching a dashboard to a notebook.";const r=new Set;for(const o of t.tiles){const a=n.get(nt(o));if(je(o)){const d=ev(o,a&&je(a)?a:void 0,r);if(d)return d;continue}const l=a&&xe(a)?a:void 0;if(a&&!l)continue;const u=o.chart;if(u!==void 0&&u!=="default"&&u!=="none"&&!Qs(u)&&!(u==="custom"&&l?.chart==="custom"))return`"${String(u)}" is not a chart this editor writes.`;const c=new Set(l?.filters?.map(d=>d.field));for(const d of o.filters??[])if(!c.has(d.field)&&/[\r\n]/.test(d.field))return"A filter field is one line.";if(a===void 0){const d=[o.name,o.source];o.declaration.kind==="reference"&&d.push(o.declaration.from);for(const f of d){const p=Qr(f);if(p)return p}}for(const d of["label","subtitle"]){const f=o[d];if(f===void 0||f===l?.[d])continue;const p=C.annotationTextProblem(`tile ${d}`,f);if(p)return p}}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=Qr(a);if(l)return l}if(t.description!==e.description)for(const o of(t.description??"").split(/\r?\n/)){const a=C.annotationTextProblem("description line",o);if(a)return a}if(t.title!==e.title){const o=C.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 u=Qr(o.name,me.isStrictName);if(u)return u}const l=o.suggest?.source;if(l!==void 0&&l!==a?.suggest?.source){const u=Qr(l);if(u)return`The suggest source is not a name. ${u}`}for(const u of["query","dimension"]){const c=o.suggest?.[u];if(c===void 0||c===a?.suggest?.[u])continue;const d=C.annotationTextProblem(`suggest ${u}`,c);if(d)return d}for(const u of["label","description"]){const c=o[u];if(c===void 0||c===i.get(o.name)?.[u])continue;const d=C.annotationTextProblem(`given ${u}`,c);if(d)return d}}for(const[o,a]of Object.entries(t.startingGivens??{})){if(a===e.startingGivens?.[o])continue;const l=C.annotationTextProblem(`starting value for ${o}`,a);if(l)return l}}const _t=(e,t)=>e.lineStarts.findLastIndex(n=>n<=t);function Lu(e,t){return e.parsed.sources.find(n=>n.name===t.source)?.views.find(n=>n.name===t.name)}function Nu(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 Fu(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 vs=e=>`where: ${me.malloyPath(e.field)} ${e.op??"~"} $${e.given}`;function Ol(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 rv(e,t,n){const r=e.commentIn(n);if(r)return r;const s=e.trailingComment(_t(e,t.end-1));return s&&s.start>=t.end&&e.text.slice(t.end,s.start).trim()===""?s:void 0}function sv(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 ka(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 zu(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 p=f.clauses.map((v,y)=>({clause:v,index:y})).filter(({clause:v})=>v.binding!==void 0);if(p.length===0)continue;const h=p.filter(({clause:v})=>i.has(v.binding.given));for(const{clause:v}of p)o.add(v.binding.given);if(h.length===0&&p.length===f.clauses.length){const v=ka(r,f.span),y=rv(r,f.span,v);if(y)return Ol(t.name,r,y);s.push({...v,text:""});continue}h.length>0&&(a=f.span);for(let v=p.length-1;v>=0;v--){const{clause:y,index:w}=p[v],g=i.get(y.binding.given);if(!g){const b=sv(f.clauses,w),_=r.commentIn(b);if(_)return Ol(t.name,r,_);s.push({...b,text:""});continue}const m=vs(g).replace(/^where:\s*/,"");m!==r.text.slice(y.span.start,y.span.end)&&s.push({...y.span,text:m})}}const l=(t.filters??[]).filter(f=>!o.has(f.given));if(l.length===0)return;let u=a?.end??(n.statements.length>0?n.statements[n.statements.length-1].span.end:n.openEnd);if(!n.oneLine){const f=r.trailingComment(_t(r,u));f&&f.start>=u&&(u=f.end)}const c=a!==void 0&&!/,\s*$/.test(r.text.slice(0,u))?", ":" ",d=n.oneLine?`${c}${l.map(vs).join(", ")}`:l.map(f=>`
|
|
138
|
+
${n.indent}${vs(f)}`).join("");s.push({start:u,end:u,text:d})}function iv(e,t,n){if(n.body.kind!=="reference")return;const{edits:r}=e,{fromSpan:s,refinement:i}=n.body,o=Nu(t.filters,i);if(o)return Fu(t.name,o.given);const a=t.filters??[];if(!i){if(a.length===0)return;const c=` + { ${a.map(vs).join(", ")} }`;r.push({start:s.end,end:s.end,text:c});return}const l=i.wheres.some(c=>c.clauses.some(d=>!d.binding)),u=i.statements.some(c=>!i.wheres.some(d=>d.span.start===c.span.start));if(a.length===0&&!l&&!u){const c={start:s.end,end:i.span.end},d=e.parsed.commentIn(c);if(d)return{ok:!1,reason:`Removing the last filter from \`${t.name}\` would also remove the comment beside its refinement (\`${e.parsed.text.slice(d.start,d.end).trim()}\`), so nothing was written. Delete it in the file first, or edit the refinement there.`};r.push({...c,text:""});return}return zu(e,t,i)}async function Wu(e,t,n={}){if(!(e.includes(`\r
|
|
139
|
+
`)&&!/(?<!\r)\n/.test(e)))return El(e,t,n);const s=await El(e.replace(/\r\n/g,`
|
|
140
|
+
`),t,n);return Rs(s)?s:{...s,source:s.source.replace(/\n/g,`\r
|
|
141
|
+
`)}}async function El(e,t,n){const r=await Tr(e,n.modelPath);if($r(r))return{ok:!1,reason:`Cannot edit a file that will not open: ${r.reason}`};const s=r.document,i=Jm(s,t),o=Wm(s,i,n.changeKind===!0);if("reason"in o)return o;const a=nv(s,i);if(a)return{ok:!1,reason:a};const l=await Iu(e);if(Eu(l))return{ok:!1,reason:`Cannot edit a file that will not open: ${l.reason}`};const u=e.split(`
|
|
142
|
+
`),c=Rm(e),d=g=>({start:c[g],end:g+1<c.length?c[g+1]:e.length}),f=g=>/^\s*/.exec(u[g])?.[0]??"",p=[],h={...o,sourceText:e,parsed:l.parsed,lines:u,starts:c,wholeLine:d,indentOf:f,current:s,next:i,edits:p,...n.modelPath!==void 0?{modelPath:n.modelPath}:{},...n.explicitKind?{explicitKind:!0}:{}};for(const g of[Gm,Um,Hm,Vm,Xm,Ym,Zm,Qm,tv]){const m=g(h);if(m)return m}const v=g=>{const{drills:m,localGivens:b,kind:_,description:O,...E}=g,I=g.tiles.map(T=>{if(je(T))return T;if(T.filters?.length)return Ns(T);const{filters:D,...L}=T;return Ns(L)});return{...E,...O===void 0?{}:{description:Pu(O)},..._==="notebook"?{kind:_}:{},tiles:I,...m?.length?{drills:[...m].sort((T,D)=>Ls(T).localeCompare(Ls(D)))}:{},...b?.length?{localGivens:b}:{}}};if(p.length===0)return _e(v(s))!==_e(v(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=Lm(e,p);if((await vl(e)).length===0){const g=await vl(y);if(g.length>0)return{ok:!1,reason:`The edit would have produced a file Malloy cannot parse, so it was not written (${g[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(v(w.document))!==_e(v(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 Bu({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:c,discard:d}=Gl(a,i,m=>n(m.text),()=>o(!1)),f=i&&l!==void 0&&l.text!==e,p=l!==void 0&&l.text!==e?ms(l.text):void 0;uu(f,()=>p!==void 0?!1:(c(),!0));const h=k.useRef(null),v=k.useRef(!1);k.useEffect(()=>{i||(v.current=!1)},[i]);const y=k.useCallback(m=>{!m||v.current||(v.current=!0,m.setSelectionRange(m.value.length,m.value.length))},[]);if(!i||l===void 0){const m=e.trim()?ms(e):void 0;return x.jsxs($.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},cu(s,"prose")],children:[e.trim()?x.jsx(C.Prose,{variant:r,children:e}):x.jsx($.Typography,{variant:"body2",sx:{color:s.tileTitle,opacity:.6,fontStyle:"italic"},children:t}),m&&x.jsx($.Typography,{variant:"caption",color:"error",role:"alert",children:m})]})}const w=l.text!==e?ms(l.text):void 0,g=()=>{w===void 0&&c()};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:y,inputProps:{"aria-label":"Markdown"},onChange:m=>u(b=>{b.text=m.target.value}),onKeyDown:m=>{m.key==="Escape"?g():m.key==="Enter"&&(m.metaKey||m.ctrlKey)&&(m.preventDefault(),g())},onBlur:m=>{m.relatedTarget instanceof Node&&h.current?.contains(m.relatedTarget)||c()}}),x.jsxs($.Stack,{ref:h,direction:"row",spacing:1,children:[x.jsx($.Button,{size:"small",variant:"outlined",disabled:w!==void 0,onClick:g,children:"Done"}),x.jsx($.Button,{size:"small",onMouseDown:m=>m.preventDefault(),onClick:()=>{d(),o(!1)},children:"Cancel"})]})]})}const ov="Write markdown: # heading, **bold**, - list";function av({tile:e,onChange:t,chrome:n="card"}){return x.jsx(C.TileCard,{chrome:n,kind:"text",children:x.jsx(Bu,{markdown:e.markdown,placeholder:ov,onCommit:t})})}const Fs=e=>e.label??C.tileTitle(`${e.source} -> ${e.name}`);function lv({tile:e,index:t,selected:n,flash:r=!1,menuOpen:s,bare:i=!1,onInsertAfter:o,onSelect:a,onOpenMenu:l,resizing:u=!1,width:c,onResizeStart:d,onResizeMove:f,onResizeEnd:p,children:h}){const{theme:v}=Ke.usePublisherTheme();return x.jsx(cm,{id:Fe(e),index:t,children:({ref:y,handleRef:w})=>x.jsxs($.Box,{ref:y,onClick:a,onPointerDown:g=>{g.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",...Gu(v,{selected:n,flash:r,bare:i}),"&&[data-dnd-dragging]":{opacity:1,outline:"none",boxShadow:v.shadow.drag},"&&[data-dnd-placeholder]":{opacity:.45,outline:`2px dashed ${v.accent}`,boxShadow:"none"},"&:hover .builder-affordance, &:focus-within .builder-affordance":{opacity:1},"@media (hover: none)":{"& .builder-affordance":{opacity:1}}},children:[h,x.jsx($.Box,{ref:w,"aria-label":`Move ${Wr(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 ${Wr(e)}`,onClick:g=>{g.stopPropagation(),l(g.currentTarget)},sx:{position:"absolute",top:`${-((i?C.BARE_RING_OFFSET_PX+1:0)+12)}px`,right:i?0:"12px",border:v.cardBorder,borderRadius:1,width:28,height:24,zIndex:2,color:v.tileTitle,bgcolor:v.tile,opacity:n||s?.9:0,transition:`opacity ${C.MOTION_FAST}`,...C.reducedMotionSx,"&:hover":{opacity:1,bgcolor:v.tile}},children:x.jsx(fv,{})}),d&&x.jsx($.Box,{className:"builder-affordance",[$u]:"",role:"separator",tabIndex:c?0:-1,"aria-orientation":"vertical","aria-label":`Width of ${Wr(e)}`,...c?{"aria-valuenow":c.span,"aria-valuemin":1,"aria-valuemax":c.columns,"aria-valuetext":`${c.span} of ${c.columns} columns`}:{},onKeyDown:g=>{if(!c)return;const m=g.key==="ArrowRight"?c.span+1:g.key==="ArrowLeft"?c.span-1:g.key==="Home"?1:g.key==="End"?c.columns:void 0;m!==void 0&&(g.preventDefault(),g.stopPropagation(),c.onStep(Math.min(Math.max(m,1),c.columns)))},onPointerDown:d,onPointerMove:f,onPointerUp:p,onPointerCancel:p,onClick:g=>g.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 ${C.MOTION_FAST}`,...C.reducedMotionSx,"&:hover":{opacity:1},"&:focus-visible":{opacity:1,outline:`2px solid ${v.accent}`,outlineOffset:1,borderRadius:"3px"},"&::after":{content:'""',position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"4px",height:"28px",borderRadius:"2px",bgcolor:v.accent}}}),o&&x.jsx($.IconButton,{className:"builder-affordance",size:"small","aria-label":`Insert tile after ${Wr(e)}`,onClick:g=>{g.stopPropagation(),o()},sx:{position:"absolute",bottom:`-${(i?C.NOTEBOOK_GAP_PX:C.GRID_GAP_PX)/2+12}px`,left:"50%",transform:"translateX(-50%)",width:24,height:24,zIndex:3,color:v.tileTitle,bgcolor:v.tile,border:v.cardBorder,opacity:0,transition:`opacity ${C.MOTION_FAST}`,...C.reducedMotionSx,"&:hover, &:focus-visible":{opacity:1,bgcolor:v.tile}},children:x.jsx(C.AddIcon,{sx:{fontSize:14}})})]})})}const wi=4,Gu=(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 ${C.MOTION_FAST}, border-color ${C.MOTION_FAST}, opacity ${C.MOTION_FAST}, box-shadow ${C.MOTION_FAST}`;return r?{borderRadius:1,"&::before":{content:'""',position:"absolute",inset:`${-C.BARE_RING_OFFSET_PX}px`,borderRadius:1,border:`2px solid ${s}`,pointerEvents:"none",transition:o,...C.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,...C.reducedMotionSx,"&:hover":{outlineColor:i,boxShadow:e.shadow.lift}}};function cv({tile:e,heading:t,note:n,chrome:r="card"}){const{theme:s}=Ke.usePublisherTheme();return x.jsxs(C.TileCard,{chrome:r,children:[x.jsx(C.TileHeading,{title:t?.title??Fs(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}=Ke.usePublisherTheme();return x.jsx(dm,{id:hu(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 ${C.MOTION_FAST}, background-color ${C.MOTION_FAST}`,...C.reducedMotionSx}})})}function uv({columns:e}){const{theme:t}=Ke.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:`${C.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 fv(){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 hv({editor:e,reorder:t,resizing:n,gridBox:r,columns:s,notebook:i,chrome:o,canAdd:a,selected:l,flash:u,menuIndex:c,onSelect:d,onOpenMenu:f,openAdd:p,editTile:h,renderTile:v}){const{dragging:y,preview:w,onDragStart:g,onDragOver:m,onDragEnd:b}=t,{resize:_,startResize:O,onResize:E,endResize:I}=n,T=_!==void 0?e.document.tiles.map((z,K)=>K===_.index?{...z,colspan:_.span}:z):w??e.document.tiles,D=e.document.tiles.length===0,L=y?Ig(T,s):T.map(fu),R=z=>pv(z,Fs(z),h);return x.jsxs(x.Fragment,{children:[x.jsx(ug,{sensors:am,onDragStart:g,onDragOver:m,onDragEnd:b,children:x.jsxs($.Box,{ref:r,sx:{position:"relative"},children:[!i&&(y||_!==void 0)&&x.jsx(uv,{columns:s}),x.jsx(C.DashboardGrid,{tiles:L,columns:s,rowGapPx:o==="none"?C.NOTEBOOK_GAP_PX:C.GRID_GAP_PX,keyOf:z=>z.kind==="gap"?hu(z.after):Fe(z.tile),renderTile:z=>{if(z.kind==="gap")return x.jsx(dv,{after:z.after});const{tile:K,index:G}=z;return x.jsx(lv,{tile:K,index:G,selected:G===l,flash:Fe(K)===u,menuOpen:c===G,bare:o==="none",...i&&a?{onInsertAfter:()=>p(G+1)}:{},...s>1&&gv(K)?{resizing:_?.index===G,width:{span:K.colspan??1,columns:s,onStep:X=>{X!==(K.colspan??1)&&e.update(Y=>{const se=Y.tiles[G];se&&(se.colspan=X)})}},onResizeStart:X=>O(X,G),onResizeMove:E,onResizeEnd:I}:{},onSelect:()=>d(G),onOpenMenu:X=>f(X,G),children:je(K)?x.jsx(av,{tile:K,chrome:o,onChange:X=>h(Fe(K),Y=>{je(Y)&&(Y.markdown=X)})}):v&&!e.pendingOpen?v(K,R(K),o):x.jsx(cv,{tile:K,chrome:o,heading:R(K),...e.pendingOpen?{note:"Preview appears after you Save"}:{}})})}})]})}),i&&a&&!D&&x.jsx($.Button,{size:"small",startIcon:x.jsx(C.AddIcon,{}),"aria-label":"Add tile at the end",onClick:()=>p(),sx:{alignSelf:"center"},children:"Add tile"})]})}const pv=(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")})}},gv=e=>je(e)||e.declaration.kind!=="inherited";function mv({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($.Stack,{direction:"row",sx:{alignItems:"center",gap:2},children:[x.jsx($.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($.Box,{sx:{my:"-4px"},children:s})]}),x.jsx($.Box,{role:"group","aria-label":"Description","aria-current":i,onPointerDown:o,onFocus:o,sx:r==="none"?{my:`${C.BARE_DESCRIPTION_MARGIN_PX}px`}:void 0,children:x.jsx(C.TileCard,{chrome:r,kind:"text",sx:{position:"relative",overflow:"visible",...Gu(a,{selected:i,bare:r==="none"})},children:x.jsx(Bu,{markdown:e.document.description??"",placeholder:"Add a description",onCommit:l=>e.update(u=>{l.trim()===""?delete u.description:u.description=l})})})})]})}const vv=({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})}),bv=C.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"})),yv=C.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+",Cl=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 xv(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(Cl(i.target)||ki(i.target))return;o.escape();return}if(Cl(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 Il={package:"Saves to the package file",browser:"Saves in this browser",host:"Saves to the app this is embedded in"};function wv({canUndo:e,canRedo:t,onUndo:n,onRedo:r,dirty:s,saving:i,onSave:o,savesTo:a="package",saveLabel:l,saveButton:u,actions:c,onAddTile:d,onExit:f}){return x.jsxs($.Stack,{direction:"row","aria-label":"Builder actions",sx:{alignItems:"center",gap:.5,flexShrink:0,"& .MuiButton-root":{whiteSpace:"nowrap"}},children:[d&&x.jsx($.Button,{startIcon:x.jsx(C.AddIcon,{}),onClick:d,"aria-label":"Add tile",children:"Tile"}),d&&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(yv,{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"})})})}),(c||o||f)&&x.jsx($.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5}}),c,o?x.jsx($.Tooltip,{title:s?`Save (${_i}S) · ${l??Il[a]}`:l??Il[a],children:x.jsx("span",{children:x.jsx($.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($.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(C.SecondaryButton,{label:"Close",icon:x.jsx(C.CheckIcon,{}),onClick:f})]})}const _v=C.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"})),kv=C.createSvgIcon(x.jsx("path",{d:"M10 18h4v-2h-4zM3 6v2h18V6zm3 7h12v-2H6z"}));function Sv({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($.Stack,{sx:{gap:1,position:"sticky",top:0,zIndex:C.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(kv,{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(u=>{const c=n(u.name,u.type);return x.jsx($.Tooltip,{title:c.length>0?`$${u.name} · cannot filter on: ${c.join(", ")}`:`$${u.name} · ${u.origin==="dashboard"?"declared here":"from the model"} · ${u.boundTiles} of ${t} tiles`,children:x.jsx($.Chip,{size:"small",label:`${u.label??u.name}${u.boundTiles===0?" · unused":""}`,"aria-label":`Edit filter ${u.name}`,color:c.length>0?"warning":"default",variant:u.origin==="dashboard"?"filled":"outlined",onClick:()=>r(u),onDelete:()=>o(u.name),deleteIcon:x.jsx(_v,{"aria-label":`Remove filter ${u.name}`}),sx:{opacity:u.boundTiles===0?.6:1,cursor:"pointer",transition:`opacity ${C.MOTION_FAST}`,...C.reducedMotionSx}})},u.name)}),x.jsx($.Tooltip,{title:i??"",children:x.jsx("span",{children:x.jsx($.Chip,{component:"button",size:"small",variant:"outlined",icon:x.jsx(C.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 $v(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 Tv({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(v=>r(y=>typeof y=="object"&&y.tile===v?y:{tile:v}),[]),a=k.useCallback(()=>r(v=>v==="description"?v:void 0),[]),l=k.useCallback(()=>r("description"),[]),u=k.useCallback(()=>r(void 0),[]),[c,d]=k.useState(void 0),f=k.useRef(!1),p=k.useRef(e.document);k.useEffect(()=>{const v=p.current;if(p.current=e.document,!f.current)return;f.current=!1;const y=$v(v,e.document);if(y===void 0)return;d(y),Array.from(t.current?.querySelectorAll("[data-tile-key]")??[]).find(g=>g.dataset.tileKey===y)?.scrollIntoView?.({block:"nearest",behavior:C.scrollBehavior()})},[e.document,t]),k.useEffect(()=>{if(c===void 0)return;const v=setTimeout(()=>d(void 0),1500);return()=>clearTimeout(v)},[c]);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:c,stepEditor:h}}function Ov({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 c=k.useRef(s);c.current=s;const d=k.useRef(0),f=k.useCallback(async()=>{const h=++d.current;l(!1),o("saving");try{await u.current()}catch{d.current===h&&o("idle");return}d.current===h&&l(!0)},[]);return k.useEffect(()=>{if(i==="waiting"){if(t)return;e?f():(o("idle"),c.current())}else if(i==="saving"){if(!a||t)return;o("idle"),e||c.current()}},[i,a,t,e,f]),{requestExit:k.useCallback(()=>{i==="idle"&&(e?o("asking"):c.current())},[i,e]),dialog:{open:i==="asking",canSave:n,onKeepEditing:()=>{i==="asking"&&o("idle")},onDiscard:()=>{i==="asking"&&(o("idle"),c.current())},onSaveAndExit:()=>{i==="asking"&&(t?o("waiting"):f())}}}}function Ev({editor:e,onSave:t,onDirtyChange:n,onExit:r,onChange:s,extraDirty:i=!1,report:o,unit:a,prepare:l,shortcuts:u}){const[c,d]=k.useState(!1),[f,p]=k.useState(!1),h=k.useRef(null),v=k.useRef(o);v.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 g=k.useRef(n);g.current=n,k.useEffect(()=>()=>g.current?.(!1),[]);const m=k.useRef(a);m.current=a,k.useEffect(()=>{p(!1)},[e.document]);const b=k.useCallback(()=>{d(!0),p(!1);const G=C.now(),{structural:X}=e,Y=e.pendingOpen??!1,se=v.current.size;return e.save().then(te=>{te.ok===!0?v.current.saved({size:se,structural:X,fromOpen:Y,durationMs:C.now()-G}):v.current.refused(te.reason)}).finally(()=>d(!1))},[e]),_=k.useRef(!1),O=k.useRef(!1);k.useEffect(()=>{!O.current||c||(O.current=!1,h.current?.focus())},[f,c]);const E=k.useCallback(()=>{if(!t||c||_.current||!e.canUndoSave)return;_.current=!0,d(!0);const G=C.now(),X=e.lastSave?.structural??!1,Y=v.current.size;return e.undoSave().then(se=>{se.ok===!0?(O.current=!0,p(!0),v.current.undone({size:Y,structural:X,fromOpen:!1,durationMs:C.now()-G})):v.current.undoRefused(se.reason)}).finally(()=>{_.current=!1,d(!1)})},[t,c,e]),I=k.useCallback(()=>{if(!(!t||!e.dirty||c))return b()},[t,e,c,b]),T=k.useRef(I);T.current=I;const D=k.useCallback(()=>{const G=()=>T.current();return l?l(G):G()},[l]),L=Ov({dirty:w,saving:c,canSave:!!t,save:D,onExit:()=>r?.()});xv(k.useMemo(()=>({...u,undo:e.undo,redo:e.redo,...t?{save:D}:{},paused:L.dialog.open}),[u,e,t,D,L.dialog.open]));const R=!!t&&!c&&e.canUndoSave,z=e.lastSave,K={canUndo:e.canUndo,canRedo:e.canRedo,onUndo:e.undo,onRedo:e.redo,dirty:y,saving:c,saveButton:h,...t?{onSave:D}:{},...r?{onExit:L.requestExit}:{}};return{saving:c,save:D,exitGuard:L,undoSave:E,canUndoSave:R,lastSave:z,toolbarProps:K}}function Jr(e){for(const t of e??[]){const n=/^#\(doc\)\s*(.*)$/s.exec(t.trim());if(n)return n[1].trim()}}function Dl(e){for(const t of e??[]){const n=/^#\s*(?:-[A-Za-z_]+\s+)*([a-z_]+)/.exec(t.trim())?.[1];if(n&&Tu.includes(n))return n}}const Cv=1;function qu(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(...qu(a,`${t}${i}.`,n-1))}}}return r}function Iv(e){const t=new Map;for(const n of Ku(e))t.set(n.name,qu(n.schema?.fields,"",Cv));return t}function Ku(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 Dv=e=>(e.annotations??[]).some(t=>{const n=t.value??"";return n.startsWith("#(malloy)")&&of.parseTag(n.slice(9)).tag?.has("calculation")===!0});function Av(e){const t=new Map;for(const n of Ku(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(Dv)&&r.add(s.name)}t.set(n.name,r)}return t}function Al(e,t){return!e||t===void 0?void 0:e.sources.find(r=>r.name===t)?.fields.filter(r=>r.kind==="dimension")}const Uu=e=>(e??"").startsWith("dashboards/"),Pv=e=>e.modelPath??e.path??"";function Vu(e){const t=[],n=new Set;for(const r of e){const s=Pv(r);if(Uu(s))continue;const i=Iv(r),o=Av(r);for(const a of r.sources??[]){const l=a.name;if(!l||n.has(l))continue;n.add(l);const u=(a.givens??[]).map(c=>c.name).filter(c=>typeof c=="string");t.push({name:l,modelPath:s,...Jr(a.annotations)?{description:Jr(a.annotations)}:{},views:(a.views??[]).filter(c=>typeof c.name=="string").map(c=>({name:c.name,...Jr(c.annotations)?{description:Jr(c.annotations)}:{},...Dl(c.annotations)?{chart:Dl(c.annotations)}:{},...o.get(l)?.has(c.name)?{aggregateOnly:!0}:{}})),givens:u,fields:i.get(l)??[]})}}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(v=>v.name));return(n??[]).filter(v=>!h.has(v.name))},[t,n]),a=k.useMemo(()=>hf(e.document,o),[e.document,o]),l=k.useMemo(()=>new Map(e.document.sources.map(h=>[h.name,Al(r,h.base)])),[r,e.document.sources]),u=k.useCallback(h=>l.get(h.source)??Al(r,h.source),[l,r]),c=(h,v)=>{const y=[];for(const w of e.document.tiles){if(!xe(w))continue;const g=u(w);if(!g)continue;const m=new Map(g.map(b=>[b.name,b.type]));for(const b of w.filters??[])b.given===h&&(!m.has(b.field)||!rs(v,m.get(b.field)))&&y.push(`${b.field} on ${w.label??w.name} (${e.document.sources.find(_=>_.name===w.source)?.base??w.source})`)}return y},d=k.useMemo(()=>a.filter(h=>h.origin==="model"&&h.boundTiles===0),[a]);return{filterDialog:s,setFilterDialog:i,controlList:a,fieldsFor:u,unknownFieldsOf:c,available:d,applyFilter:(h,v,y)=>{i(void 0),e.update(w=>{y&&xf(w,y),yf(w,h,v)})},dropControl:h=>{i(void 0),e.update(v=>wf(v,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),[c,d]=k.useState(void 0),[f,p]=k.useState(e.document),[h,v]=k.useState(i),[y,w]=k.useState(e.replaces),[g,m]=k.useState(!1),b=o.stack[o.index],_=k.useRef(o);_.current=o;const O=k.useRef(!1),[E,I]=k.useState(!1),T=j=>{O.current=j,I(j)},[D,L]=k.useState(void 0),R=k.useCallback(j=>{d(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}})},[]),z=k.useCallback(()=>{d(void 0),a(j=>j.index>0?{...j,index:j.index-1}:j)},[]),K=k.useCallback(()=>{d(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]),X=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:g},q=s?.(f,b)??!1,J=r?.(f,b)??!1;T(!0);try{const ee=await G(l,b);if(Rs(ee))return d(ee.reason),{ok:!1,reason:ee.reason};try{await n?.(ee.source,{purpose:"save",document:b})}catch(S){const P=`Could not save: ${S instanceof Error?S.message:String(S)}`;return d(P),{ok:!1,reason:P}}u(ee.source),p(b),v(!1),w(void 0),m(!1);const H=q?{stack:[b],index:0}:j.history;return a(S=>S===j.history?H:q?{stack:[S.stack[S.index]],index:0}:S),L(n?{before:j,after:H,lastSave:{before:y??l,after:ee.source,structural:J,clearsHistory:q}}:void 0),d(void 0),{ok:!0}}finally{T(!1)}},[b,G,n,l,f,h,y,g,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 d(J),{ok:!1,reason:J}}finally{T(!1)}return u(j.source),p(j.saved),v(j.pendingOpen),w(j.replacing),m(j.unwritten||j.replacing!==void 0),a(q=>q===D.after?j.history:q),L(void 0),d(void 0),{ok:!0}},[n,D]),se=k.useMemo(()=>g||JSON.stringify(b)!==JSON.stringify(f),[b,f,g]),te=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,N=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:se||h,edited:se,pendingOpen:h,...c===void 0?{}:{error:c},update:R,undo:z,redo:K,save:X,preview:N,structural:te,clearsHistory:A,canUndoSave:B&&!E&&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,...s}=e,i=t?.from,o=t?.to,a=k.useCallback((l,u)=>Wu(i!==void 0&&l===i?o:l,u,{changeKind:!0,...n!==void 0?{modelPath:n}:{},...r?{explicitKind:r}:{}}),[i,o,n,r]);return Rv({...s,splice:a,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 Hu="dashboards/document.malloy",Xu=e=>e.slice(0,e.lastIndexOf("/")+1),Yu=(e,t)=>new URL(e,`https://malloy.invalid/${Xu(t)}`).pathname.slice(1);function zv(e,t){const n=Xu(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=Hu){return e.sources.some(s=>s.base===t)?!0:e.imports.some(s=>s.kind==="names"?s.names.includes(t):Yu(s.from,r)===n)}function Bv(e,t,n,r=Hu){const{imports:s}=e;if(Wv(e,t,n,r))return s;const i=s.findIndex(o=>o.kind==="names"&&Yu(o.from,r)===n);return i<0?[...s,{kind:"names",names:[t],from:zv(n,r)}]:s.map((o,a)=>a===i&&o.kind==="names"?{...o,names:[...o.names,t]}:o)}function Gv({editor:e,notebook:t,columns:n,modelPath:r,selectTile:s,deselectTile:i}){const[o,a]=k.useState(void 0),[l,u]=k.useState(!1),[c,d]=k.useState(void 0);return{menu:o,setMenu:a,addingTile:l,openAdd:g=>{d(g),u(!0)},closeAdd:()=>u(!1),addTile:g=>{u(!1),e.update(m=>{g.modelPath&&(m.imports=Bv(m,g.base,g.modelPath,...r?[r]:[]));let b=m.sources.find(E=>E.base===g.base);if(!b){const E=new Set(m.sources.map(T=>T.name));let I=`${g.base}_tiles`;for(let T=2;E.has(I);T++)I=`${g.base}_tiles_${T}`;b={name:I,base:g.base},m.sources.push(b)}const _=new Set(m.tiles.filter(xe).filter(E=>E.source===b.name).map(E=>E.name));let O=`${g.view}_tile`;for(let E=2;_.has(O);E++)O=`${g.view}_tile_${E}`;m.tiles.splice(c??m.tiles.length,0,{name:O,source:b.name,declaration:{kind:"reference",from:g.view},...t?{}:{colspan:g.colspan},...g.label?{label:g.label}:{},...g.chart?{chart:g.chart}:{},...g.chartCarried?{chartCarried:g.chartCarried}:{}})}),s(c??e.document.tiles.length)},addText:()=>{u(!1),e.update(g=>{const m=new Set(g.tiles.filter(je).map(_=>_.name));let b=1;for(;m.has(`text_${b}`);)b++;g.tiles.splice(c??g.tiles.length,0,{kind:"text",name:`text_${b}`,markdown:"",...t?{}:{colspan:n}})}),s(c??e.document.tiles.length)},editTile:(g,m)=>e.update(b=>{const _=b.tiles.find(O=>Fe(O)===g);_&&m(_)}),removeTile:g=>{a(void 0),i(),e.update(m=>{m.tiles.splice(g,1)})}}}var qv=Object.defineProperty,Kv=Object.defineProperties,Uv=Object.getOwnPropertyDescriptors,Pl=Object.getOwnPropertySymbols,Vv=Object.prototype.hasOwnProperty,Hv=Object.prototype.propertyIsEnumerable,Ml=(e,t,n)=>t in e?qv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sn=(e,t)=>{for(var n in t||(t={}))Vv.call(t,n)&&Ml(e,n,t[n]);if(Pl)for(var n of Pl(t))Hv.call(t,n)&&Ml(e,n,t[n]);return e},on=(e,t)=>Kv(e,Uv(t));function Xv(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 Yv(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=(m,b)=>m===b||m!==null&&typeof m=="object"&&"id"in m&&m.id===b;if(Array.isArray(e)){const m=e.findIndex(_=>l(_,i.id)),b=e.findIndex(_=>l(_,o.id));if(m===-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(_!==m)return n(e,m,_)}return n(e,m,b)}const u=Object.entries(e);let c=-1,d,f=-1,p;for(const[m,b]of u)if(c===-1&&(c=b.findIndex(_=>l(_,i.id)),c!==-1&&(d=m)),f===-1&&(f=b.findIndex(_=>l(_,o.id)),f!==-1&&(p=m)),c!==-1&&f!==-1)break;if(c===-1&&Si(i)){const m=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(m==null||_==null||m===_&&b===O)return"preventDefault"in t&&t.preventDefault(),e;if(m===_)return on(sn({},e),{[m]:n(e[m],b,O)});const E=e[m][b];return on(sn({},e),{[m]:[...e[m].slice(0,b),...e[m].slice(b+1)],[_]:[...e[_].slice(0,O),E,...e[_].slice(O)]})}if(!i.manager)return e;const{dragOperation:h}=i.manager,v=(s=(r=h.shape)==null?void 0:r.current.center)!=null?s:h.position.current;if(p==null){const m=es(e,o.id);if(m!=null){const b=o.shape&&v.y>o.shape.center.y?e[m].length:0;p=m,f=b}}if(d==null||p==null||d===p&&c===f){if(d!=null&&d===p&&c===f&&Si(i)){const m=i.group==null?void 0:es(e,i.group),b=i.group!=null&&m!==d,_=i.index!==c;if(b||_){const O=i.group==null?d:m;if(O!=null){if(d===O)return on(sn({},e),{[d]:n(e[d],c,i.index)});const E=e[d][c];return on(sn({},e),{[d]:[...e[d].slice(0,c),...e[d].slice(c+1)],[O]:[...e[O].slice(0,i.index),E,...e[O].slice(i.index)]})}}}return"preventDefault"in t&&t.preventDefault(),e}if(d===p)return on(sn({},e),{[d]:n(e[d],c,f)});const w=o.shape&&Math.round(v.y)>Math.round(o.shape.center.y)?1:0,g=e[d][c];return on(sn({},e),{[d]:[...e[d].slice(0,c),...e[d].slice(c+1)],[p]:[...e[p].slice(0,f+w),g,...e[p].slice(f+w)]})}function Zv(e,t){return Yv(e,t,Xv)}function Qv({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:d=>{const{source:f,target:p}=d.operation;if(!f||!p)return;const h=i.current??e;let v;if(p.type===Su){const{after:y}=p.data,w=h.findIndex(b=>Fe(b)===f.id);if(w<0||y===f.id)return;const m=h.filter((b,_)=>_!==w).findIndex(b=>Fe(b)===y)+1;v=Cg(h,w,m)}else{const y=h.map(Fe),w=Zv(y,d);if(w.every((m,b)=>m===y[b]))return;const g=new Map(h.map(m=>[Fe(m),m]));v=Eg(w.map(m=>g.get(m)),e.map(m=>m.break??!1))}i.current=v,s(v)},onDragEnd:d=>{a(!1);const f=i.current;if(i.current=void 0,s(void 0),d.canceled||!f)return;t(f);const p=f.findIndex(h=>Fe(h)===d.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 Jv({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(),v=f.currentTarget.parentElement?.getBoundingClientRect();if(!h||!v)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:v.left,track:(h.width-C.GRID_GAP_PX*(t-1))/t})},onResize:f=>{const p=a.current;if(!p)return;const h=f.clientX-p.left,v=Math.round((h+C.GRID_GAP_PX)/(p.track+C.GRID_GAP_PX)),y=Math.min(Math.max(v,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:v,from:y}=p;l(void 0),!(f.type==="pointercancel"||v===y)&&s(h,v)}}}function Zu({source:e,document:t,onSave:n,onChange:r,onDirtyChange:s,onExit:i,renderTile:o,controls:a,givens:l,catalog:u,toolbar:c,dashboards:d,onEvent:f,conversion:p,savesTo:h="package",saveLabel:v,replaces:y,modelPath:w,explicitKind:g,addFilterDisabledReason:m}){const b=Nv({source:e,document:t,...n?{onSave:n}:{},...p?{conversion:p}:{},...y!==void 0?{replaces:y}:{},...w!==void 0?{modelPath:w}:{},...g?{explicitKind:g}:{}}),_=k.useRef(null),{selected:O,descriptionSelected:E,selectTile:I,deselectTile:T,selectDescription:D,clearSelection:L,flash:R,stepEditor:z}=Tv({editor:b,gridBox:_}),K=b.document.kind==="notebook",G=K?1:b.document.columns??C.DEFAULT_COLUMNS,X=K?"none":"card",Y=w?.split("/").at(-1)?.replace(/\.malloy$/,""),se=Qv({tiles:b.document.tiles,commit:ce=>b.update(pe=>{pe.tiles=ce}),onLanded:I}),{dragging:te}=se,A=Jv({tiles:b.document.tiles,columns:G,gridBox:_,onStart:I,commit:(ce,pe)=>b.update(M=>{const U=M.tiles[ce];U&&(U.colspan=pe)})}),B=Gv({editor:b,notebook:K,columns:G,modelPath:w,selectTile:I,deselectTile:T}),{menu:N,addingTile:j,openAdd:q}=B,J=Mv({editor:b,opened:t,givens:l,catalog:u}),{filterDialog:ee,setFilterDialog:H}=J,[S,P]=k.useState(void 0),{draftDirty:F,openDraft:V,prepare:ie}=Fv({editorDirty:b.dirty}),{confirmConversion:Z,prepareSave:oe}=jv({pendingOpen:b.pendingOpen,prepare:ie}),W=k.useMemo(()=>({escape:()=>{!N&&!ee&&!j&&S===void 0&&Z===void 0&&L()},nudge:ce=>{if(te||O===void 0||K)return;const pe=b.document.tiles[O];if(!pe||xe(pe)&&pe.declaration.kind==="inherited")return;const M=C.nudgedSpan(pe.colspan??1,ce,G);M!==(pe.colspan??1)&&b.update(U=>{U.tiles[O].colspan=M})}}),[b,N,ee,j,S,Z,L,O,G,K,te]),Q=Ev({editor:z,extraDirty:F,prepare:oe,unit:{name:"tile",count:ce=>ce.tiles.length},onSave:n,onDirtyChange:s,onExit:i,onChange:r,shortcuts:W,report:vv({size:b.document.tiles.length,notebook:K,savesTo:h,onEvent:f})}),ne=b.document.tiles.length===0,re=x.jsx(wv,{...Q.toolbarProps,...c?{actions:c}:{},...u?{onAddTile:()=>q()}:{},savesTo:h,...v?{saveLabel:v}:{}});return x.jsx(du.Provider,{value:V,children:x.jsx($.Stack,{sx:{gap:0,mx:`-${wi}px`},children:x.jsxs($.Stack,{sx:{gap:2,px:`${wi}px`,pb:`${wi}px`},children:[b.pendingOpen&&x.jsx($.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(mv,{editor:b,notebook:K,documentSlug:Y,chrome:X,actions:re,descriptionSelected:E,selectDescription:D}),ne?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.jsxs($.Typography,{variant:"body2",children:["This ",K?"notebook":"dashboard"," is not served until it has a tile."]}),u&&x.jsx($.Button,{size:"small",startIcon:x.jsx(C.AddIcon,{}),onClick:()=>q(),children:"Add tile"})]})}):x.jsx(Sv,{controls:J.controlList,tileCount:b.document.tiles.length,unknownFieldsOf:J.unknownFieldsOf,onEdit:ce=>H({control:ce}),onAdd:()=>H({}),...m?{addDisabledReason:m}:{},onRemove:J.dropControl,children:a}),b.error&&x.jsx($.Alert,{severity:"warning",children:b.error}),x.jsx(hv,{editor:b,reorder:se,resizing:A,gridBox:_,columns:G,notebook:K,chrome:X,canAdd:!!u,selected:O,flash:R,menuIndex:N?.index,onSelect:I,onOpenMenu:(ce,pe)=>{I(pe),B.setMenu({anchor:ce,index:pe})},openAdd:q,editTile:B.editTile,...o?{renderTile:o}:{}}),x.jsx(Ef,{editor:b,catalog:u,columns:G,dashboards:d,bindings:J,tiles:B,drillSource:S,setDrillSource:P,confirmConversion:Z,exitDialog:Q.exitGuard.dialog})]})})})}function eb(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(tb(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 tb(e){return{name:e.name,type:e.type,default:e.default,...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 nb(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 rb(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(v=>[v.name,v.type])),l=e.sources.find(v=>v.name===i)?.scopedBy??[],u=new Set([...l,...s??[]].filter(v=>n.has(v))),c=new Set([...l,...s??[]]),d=[];for(const v of t.filters??[]){const y=`where: ${me.malloyPath(v.field)} ${v.op??"~"}`;if(n.has(v.given)){u.add(v.given),c.add(v.given),d.push(`${y} $${v.given}`);continue}if(!a.has(v.given))continue;c.add(v.given);const w=C.malloyLiteral(r.get(v.given),a.get(v.given));w!==void 0&&d.push(`${y} ${w}`)}const f=d.join(", "),p=t.chart,h=p==="none"||Qs(p)?yn(p,t.chartCarried):p==="custom"&&t.chartLines?.length?t.chartLines.join(`
|
|
143
|
+
`):p==="default"&&nb(t.declaration)?yn("none"):void 0;return{...h?{annotation:h}:{},expression:`${i} -> ${o}`+(f?` + { ${f} }`:""),givenNames:Array.from(u),reads:s||c.size>0?Array.from(c):void 0}}const sb={};function ib({textSource:e,kind:t,modelGivens:n,environmentName:r,packageName:s,modelPath:i,slug:o,versionId:a,opened:l,replaces:u,onSave:c,onDirtyChange:d,onExit:f,onEvent:p,savesTo:h,saveLabel:v,note:y}){const{apiClients:w}=Ke.useServer(),g=t==="notebook",[m,b]=k.useState(l.document.tiles.length>0);k.useEffect(()=>b(l.document.tiles.length>0),[l.generation,l.document]);const{data:_,isSuccess:O,isError:E}=C.useQueryWithApiError({queryKey:["dashboard-editor-manifest",r,s,o,a,t],queryFn:async()=>{if(!g)return(await w.dashboards.getDashboard(r,s,o,a)).data;const W=(await w.notebooks.getNotebook(r,s,i,a)).data;return W.dashboard??{...W.startingGivens?{startingGivens:W.startingGivens}:{},...W.autorun===void 0?{}:{autorun:W.autorun}}},enabled:m&&!e}),I=e?.modelPath??i,T=C.useCompiledDocument({environmentName:r,packageName:s,modelPath:I,source:l.source,...e?.givens?{givens:e.givens}:{}},{enabled:e!==void 0}),D=T.data?.document,L=e?T.isSuccess?D?.manifest??sb:void 0:_,R=e?T.isSuccess:O,z=e?T.isError:E,K=e?C.documentPreamble(D?.cells):void 0,G=(T.data?.result.problems??[]).filter(W=>W.severity==="error"),X=k.useMemo(()=>new Set(e?.hiddenGivens??[]),[e]),Y=e?.givens,se=k.useMemo(()=>new Set((L?.tiles??[]).flatMap(W=>W.restricted&&W.query?[ts(W.query)]:[])),[L]),{data:te}=C.useQueryWithApiError({queryKey:["dashboards",r,s,a],staleTime:6e4,queryFn:()=>w.dashboards.listDashboards(r,s,a),enabled:!g}),A=k.useMemo(()=>(te?.data??[]).map(W=>W.name).filter(W=>!!W&&W!==o),[te,o]),{data:B}=C.useQueryWithApiError({queryKey:["dashboard-editor-catalog",r,s,a],queryFn:async()=>{const W=(await w.models.listModels(r,s,a)).data.filter(re=>re.path&&!re.error&&!Uu(re.path)&&!re.path.startsWith("notebooks/")),ne=(await Promise.allSettled(W.map(re=>w.models.getModel(r,s,re.path,a).then(ce=>ce.data)))).flatMap(re=>re.status==="fulfilled"?[re.value]:[]);return Vu(ne)}}),[N,j]=k.useState(l.document);k.useEffect(()=>j(l.document),[l.document]);const q=k.useMemo(()=>c&&h==="package"?async(W,Q)=>{await c(W),b(Q.document.tiles.length>0)}:c,[c,h]),J=k.useMemo(()=>(L?.givens??(l.conversion?n??[]:[])).filter(W=>!(e&&W.secure===!0)&&!(W.name!==void 0&&X.has(W.name))),[L,l.conversion,n,X,e]),ee=k.useMemo(()=>new Set([...J.map(W=>W.name).filter(W=>W!==void 0),...Object.keys(Y??{})]),[J,Y]),H=k.useMemo(()=>eb(N,J),[N,J]),{declaredTypes:S,applied:P,panel:F}=C.useDocumentControls({specs:H,loaded:R,startingValues:L?.startingGivens,documentKey:`${r}/${s}/${a??""}/${g?"notebook/":""}${o}/edit`,autorun:L?.autorun!==!1,environmentName:r,packageName:s,modelPath:e?I:L?.path,versionId:a,documentName:o,...K!==void 0?{preamble:K}:{},...Y?{hostGivens:Y}:{}}),V=k.useMemo(()=>Object.fromEntries(Object.entries(Y??{}).filter(([W])=>!S.has(W))),[Y,S]),ie=!m||R||z,Z=k.useMemo(()=>new Map((L?.tiles??[]).flatMap(W=>W.kind!=="text"&&W.query&&W.givenNames?[[ts(W.query),W.givenNames]]:[])),[L]),oe=k.useMemo(()=>function(Q,ne,re="card"){if(!ie)return x.jsxs(C.TileCard,{chrome:re,children:[x.jsx(C.TileHeading,{title:ne?.title??Fs(Q),subtitle:ne?ne.subtitle:Q.subtitle}),x.jsx(C.Loading,{text:"Running…"})]});const ce=rb(N,Q,ee,P,Z.get(ts(`${Q.source} -> ${Q.name}`)));return x.jsx(C.DashboardTile,{environmentName:r,packageName:s,versionId:a,modelPath:I,...K!==void 0?{preamble:K}:{},...se.has(ts(`${Q.source} -> ${Q.name}`))?{restricted:!0}:{},tile:ce.expression,...ce.annotation?{annotation:ce.annotation}:{},label:Fs(Q),chrome:re,subtitle:Q.subtitle,...ne?{heading:ne}:{},borderless:Q.borderless,givens:P,hostGivens:V,declaredTypes:S,givenNames:ce.givenNames,ignoredFilters:C.tileIgnoredFilterLabels(ce.reads,H),height:C.TILE_MAX_HEIGHT})},[N,ie,ee,Z,r,s,a,I,K,se,P,V,S,H]);return x.jsxs($.Stack,{sx:{gap:1},children:[e&&G.length>0&&x.jsxs($.Alert,{severity:"error",children:["The server could not compile this document:"," ",G.map(W=>W.message).join("; ")]}),e&&T.isError&&x.jsxs($.Alert,{severity:"error",children:["The server could not compile this document:"," ",T.error?.message]}),x.jsx(Zu,{...e?{addFilterDisabledReason:"This document holds no given: of its own. Bind a filter the model offers from its chip."}:{},source:l.source,document:l.document,renderTile:oe,givens:H.filter(W=>W.name!==void 0).map(W=>({name:W.name,...W.label?{label:W.label}:{},...W.type?{type:W.type}:{},...W.suggest?.dimension?{field:W.suggest.dimension}:{}})),onChange:j,onDirtyChange:d,...f?{onExit:f}:{},...l.conversion?{conversion:l.conversion}:{},...B?{catalog:B}:{},dashboards:A,...p?{onEvent:p}:{},controls:R?x.jsx(C.GivensPanel,{...F,layout:g?"panel":"bar"}):void 0,...q?{onSave:q}:{},savesTo:h,...v?{saveLabel:v}:{},...u!==void 0?{replaces:u}:{},modelPath:i,...e?{explicitKind:!0}:{}}),x.jsx($.Box,{sx:{px:.5},children:x.jsx($.Typography,{variant:"caption",sx:{opacity:.7},children:y})})]})}function ob({storage:e,kind:t,notebook:n,environmentName:r,packageName:s,modelPath:i}){const[o,a]=k.useState(void 0),[l,u]=k.useState(void 0),[c,d]=k.useState(e===void 0),[f,p]=k.useState(!1),[h,v]=k.useState(void 0);return k.useEffect(()=>{if(!e)return;let y=!1;return v(void 0),(async()=>{try{const w=C.chooseWorkspace(await e.listWorkspaces(!1));if(y)return;if(a(w),w!==void 0&&(!n||w.authoritative)){const g=await e.getDocument(C.locatorFor(t,w.name,r,s,i)).catch(m=>{if(!C.isDocumentNotFound(m))throw m});if(y)return;u(g),p(g!==void 0)}}catch(w){if(y)return;v(C.storageErrorMessage(w))}y||d(!0)})(),()=>{y=!0}},[e,t,n,r,s,i]),{workspace:o,draft:l,setDraft:u,draftChecked:c,offered:f,setOffered:p,readFailure:h}}const ab=e=>e.ok===!1,qn=(e,t)=>{const n=e[t];return typeof n=="function"?n.call(e):void 0},lb=[["runStatement","run"],["docAnnotations","notes"],["importStatement","definition"],["defineSourceStatement","definition"],["defineQuery","definition"],["defineGivenStatement","definition"],["defineUserTypeStatement","definition"],["exportStatement","definition"]],cb=/^[A-Za-z_][A-Za-z0-9_]*$/,db="file:///publisher-notebook-builder/notebook.malloy",ns=e=>e.replace(/\r\n?/g,`
|
|
144
|
+
`);async function ub(e){const t=(A,B)=>({ok:!1,refused:`Line ${A+1}: ${B}`,line:A+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 Js(e,db),s=await C.loadMalloy()}catch(A){return t(0,`Malloy could not read this notebook: ${A}`)}const i=r.problems.find(A=>A.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,u=typeof a?.getTokens=="function"?a.getTokens():void 0;if(!o||typeof o.getChild!="function"||!a||!u||typeof l?.getSymbolicName!="function"||u.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 c=A=>l.getSymbolicName(A.type),d=A=>s.routeOf({value:A.trimStart()}),f=A=>s.payloadOf({value:A}),p=A=>A==="markdown"||A==='"'||A==="text",h=A=>ns(f(A)).replace(/\n$/,""),v=(A,B)=>{const N=f(A).trim(),j=d(A)!=='"'&&cb.test(N)?"":N;return ns([j&&`${j}
|
|
146
|
+
`,...B].join("")).replace(/\n$/,"")},y=new ya(e),w=wa(y,a),g=A=>e.slice(y.utf16(A.startIndex),y.utf16(A.stopIndex+1)),m=A=>{const B=A.start?.startIndex,N=A.stop?.stopIndex,j=y.span(A);if(B===void 0||N===void 0||!j)return;let q=j.end;for(;q>j.start&&(e[q-1]===`
|
|
147
|
+
`||e[q-1]==="\r");)q--;return{startCp:B,stopCp:N,...j,startLine:y.line(j.start),endLine:y.line(Math.max(j.start,q-1))}},b=A=>{let B=0,N=u.length;for(;B<N;){const j=B+N>>1;u[j].startIndex<A?B=j+1:N=j}return B},_=(A,B)=>{const N=[],j=[],q={lines:[],insertAt:y.utf16(A)};let J=-2;for(let ee=b(A);ee<u.length;ee++){const H=u[ee];if(H.startIndex>B)break;if(H.channel!==0)continue;const S=c(H);if(S!=="ANNOTATION"&&S!=="BLOCK_ANNOTATION_BEGIN"){q.insertAt=y.lineStarts[y.line(y.utf16(H.startIndex))];break}const P=ns(g(H)),F=[];if(S==="BLOCK_ANNOTATION_BEGIN"){for(;c(u[ee+1]??H)==="BLOCK_ANNOTATION_TEXT";)F.push(g(u[++ee]));c(u[ee+1]??H)==="BLOCK_ANNOTATION_END"&&ee++}if(p(d(P))){const V=y.utf16(H.startIndex),ie=y.lineStarts[y.line(V)],Z=/^[ \t]*$/.test(e.slice(ie,V));j.push({start:Z?ie:V,end:y.utf16(u[ee].stopIndex+1)})}if(S==="ANNOTATION"){const V=P.replace(/\n$/,"");if(At(V)){const ie=y.utf16(H.startIndex),Z=y.lineStarts[y.line(ie)];q.lines.push({span:{start:/^[ \t]*$/.test(e.slice(Z,ie))?Z:ie,end:y.utf16(H.stopIndex+1)},text:V})}else kr(V)&&q.unmodelled===void 0&&(q.unmodelled=V.trim())}if(d(P)!=="markdown")J=-2;else if(S==="BLOCK_ANNOTATION_BEGIN")N.push(v(P,F)),J=-2;else{const V=h(P);H.line===J+1?N[N.length-1]+=`
|
|
148
|
+
${V}`:N.push(V),J=H.line}}return{markdown:N.length>0?N.join(`
|
|
149
|
+
|
|
150
|
+
`):void 0,prose:j,chart:q}},O=[],E=[],I=(A,B,N="remove it, or rewrite it as an import, source:, query:, given:, type: or export statement, a run:, or a `##(markdown)` / `##|(markdown)` prose note.")=>t(A,`${B}, which no notebook cell can hold, so the notebook cannot be edited here. Fix: ${N}`);for(let A=0;A<(o.childCount??0);A++){const B=o.getChild(A);if(!Lr(B)){const H=B?.symbol,S=H?c(H):void 0;if(H&&S==="EOF")continue;if(H&&S==="SEMI"){O.push([H.startIndex,H.stopIndex]);continue}return I((H?.line??1)-1,"a token outside any statement")}const N=m(B);if(!N)return I(0,"a statement with no readable range");const j=lb.find(([H])=>qn(B,H)!==void 0);if(!j&&qn(B,"ignoredObjectAnnotations"))return I(N.startLine,"a # tag that annotates no statement","move the tag directly above its run:, or write trailing prose as a `##(markdown)` note.");if(!j){const H=e.slice(N.start,N.end).split(`
|
|
151
|
+
`)[0];return I(N.startLine,`\`${H.trim()}\` is a statement the notebook reader does not recognize`)}O.push([N.startCp,N.stopCp]);const[q,J]=j;if(J!=="notes"){const{markdown:H,prose:S,chart:P}=_(N.startCp,N.stopCp);E.push({kind:"statement",run:J==="run",...H!==void 0&&{markdown:H},prose:S,chart:P,startLine:N.startLine,endLine:N.endLine});continue}const ee=qn(B,q);for(const H of qn(ee,"docAnnotation")??[]){const S=m(H);if(!S)return I(N.startLine,"a note with no readable range");const P=qn(H,"docBlockAnnotation")!==void 0,F=u.filter(Q=>Q.startIndex>=S.startCp&&Q.stopIndex<=S.stopCp),V=F.filter(Q=>c(Q)==="BLOCK_ANNOTATION_TEXT"),ie=V[V.length-1]??F[0],Z=ns(P&&ie?e.slice(S.start,y.utf16(ie.stopIndex+1)).replace(/\r?\n$/,""):e.slice(S.start,S.end)),oe=d(Z),W=p(oe)?P?v(Z.split(`
|
|
152
|
+
`,1)[0],V.map(g)):h(Z):void 0;E.push({kind:"note",note:{text:Z,route:oe,...W!==void 0&&{body:W},block:P,startLine:S.startLine,endLine:S.endLine}})}}for(const A of u){if(c(A)!=="BLOCK_ANNOTATION_END")continue;const B=g(A).trimStart().replace(/^\|#{1,2}/,"").trim();if(B)return t(A.line-1,`the text after a block's closer (\`${B}\`) 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 A of u){if(A.channel!==0||c(A)==="EOF")continue;for(;T<O.length&&O[T][1]<A.startIndex;)T++;const[B,N]=O[T]??[1/0,-1/0];if(A.startIndex<B||A.stopIndex>N)return I(A.line-1,"a token outside any statement")}const D=E.findIndex(A=>A.kind==="note"&&me.setsArtifactProperty(A.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 { kind=notebook }` after the ##! line.");const L=E.findIndex((A,B)=>B<D&&A.kind==="statement");if(L>=0)return t(E[L].startLine,'a statement sits above the `## artifact` tag, where only `##!` flags, comments and `"` notes may. Fix: move it below the artifact tag.');for(let A=1;A<E.length;A++){const B=E[A-1],N=E[A],j=B.kind==="note"?B.note.endLine:B.endLine,q=N.kind==="note"?N.note.startLine:N.startLine;if(q<=j)return I(q,"a line holding two statements or notes","put each statement and note on its own line.")}const R=A=>y.lineStarts[A+1]??e.length,z=[];let K=-1,G=!0,X;E.forEach((A,B)=>{if(A.kind==="statement"){G=!1,X=void 0,z.push({cell:{kind:A.run?"query":"definition",...A.markdown!==void 0&&{markdown:A.markdown},...A.prose.length>0&&{prose:A.prose},...A.run&&{chart:A.chart},id:""},startLine:A.startLine,endLine:A.endLine});return}const{note:N}=A;if(!(B>D&&N.body!==void 0)){G&&(K=N.endLine),X=void 0;return}if(G=!1,!N.block&&X&&X.endLine+1===N.startLine){X.cell.markdown+=`
|
|
153
|
+
${N.body}`,X.endLine=N.endLine;return}const q={cell:{kind:"markdown",markdown:N.body,id:""},startLine:N.startLine,endLine:N.endLine};z.push(q),X=N.block?void 0:q});const Y={start:0,end:R(K)};let se=K;const te=z.map(({cell:A,startLine:B,endLine:N},j)=>{let q=B;for(;q-1>se&&w.lines.has(q-1);)q--;return se=N,{...A,span:{start:y.lineStarts[q],end:R(N)},id:String(j)}});for(const A of[Y,...te.map(B=>B.span)]){const B=w.all.find(N=>N.start<A.start&&N.end>A.start||N.start<A.end&&N.end>A.end);if(B)return I(y.line(B.start),"a comment that straddles a cell","start the comment on its own line.")}return{ok:!0,source:{text:e,header:Y,cells:te}}}const fb=e=>e.ok===!1,hb=/^[A-Za-z_][A-Za-z0-9_]*$/,jl=/^query\s*:\s*([A-Za-z_][A-Za-z0-9_]*)\s+is\s+/,Rl=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`;function Ti(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 Ll(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 Nl(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 Fl(e,t){const n=t.split(`
|
|
155
|
+
`).map(r=>r.startsWith("|##")?` ${r}`:r).join(`
|
|
156
|
+
`);return`##|(markdown) ${e}
|
|
157
|
+
${n===""?"":`${n}
|
|
158
|
+
`}|##
|
|
159
|
+
`}function pb(e){return e.trim()===""?"":/^\s*(#|\/\/|--|\/\*)/.test(e)?` ${e.trimStart()}`:` ${e}`}function gb(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)&&me.isBareName(r)?r:void 0}async function mb(e){const t=await ub(e);if(ab(t))return{ok:!1,refused:t.refused,line:t.line};const{header:n,cells:r}=t.source,s=(S,P)=>({ok:!1,refused:`Line ${S+1}: ${P}`,line:S+1}),i=e.slice(n.start,n.end).split(`
|
|
160
|
+
`),o=me.artifactTag(i);if(o&&!me.artifactLeads(o.text))return s(o.from,me.ARTIFACT_NOT_FIRST);if(!o||_a(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 Js(e,"file:///publisher-notebook-builder/convert.malloy")).parse?.tokenStream,u=l?.tokenSource?.vocabulary,c=l?.getTokens?.()??[];if(typeof u?.getSymbolicName!="function")return s(0,"Malloy's token stream is not available.");const d=await C.loadMalloy(),{parseAnnotation:f}=await C.loadMalloyTag(),p=S=>u.getSymbolicName(S.type),h=new ya(e),v=wa(h,l),y=S=>e.slice(h.utf16(S.startIndex),h.utf16(S.stopIndex+1)),w=S=>d.routeOf({value:S.trimStart()}),g=S=>d.payloadOf({value:S}),m=S=>S.replace(/\r\n?/g,`
|
|
161
|
+
`),b=new Set(e.match(/[A-Za-z_][A-Za-z0-9_]*/g)),_=S=>{let P=S;for(let F=2;b.has(P);F++)P=`${S}_${F}`;return b.add(P),P},O=S=>{const P=c.filter(Q=>Q.channel===0&&h.utf16(Q.startIndex)>=S.span.start&&h.utf16(Q.stopIndex+1)<=S.span.end),F=[],V=[],ie=[];let Z;for(let Q=0;Q<P.length;Q++){const ne=p(P[Q]);if(ne!=="ANNOTATION"&&ne!=="BLOCK_ANNOTATION_BEGIN"){Z=P[Q];break}let re=Q;const ce=[];if(ne==="BLOCK_ANNOTATION_BEGIN"){for(;p(P[re+1]??P[Q])==="BLOCK_ANNOTATION_TEXT";)ce.push(y(P[++re]));p(P[re+1]??P[Q])==="BLOCK_ANNOTATION_END"&&re++}const pe=m(y(P[Q])),M=w(pe),U=h.utf16(P[Q].startIndex),de=h.lineStarts[h.line(U)],ve={start:/^[ \t]*$/.test(e.slice(de,U))?de:U,end:h.utf16(P[re].stopIndex+1)};M==="markdown"?F.push(ve):M==='"'&&(V.push(ve),ie.push(ne==="ANNOTATION"?m(g(pe)).replace(/\n$/,"").trim():[m(g(pe.split(`
|
|
162
|
+
`,1)[0])),...ce.map(m)].map(Re=>Re.trim()).filter(Boolean).join(" "))),Q=re}if(!Z)return;const oe=h.utf16(Z.startIndex),W=e.slice(S.span.start,S.span.end);return{cell:S,above:Nl(e.slice(S.span.start,oe),S.span.start,(S.kind==="query"?[...F,...V]:F).filter(Q=>Q.end<=oe)),statement:e.slice(oe,S.span.end).trimEnd(),kept:Nl(W,S.span.start,F),...S.kind==="query"&&ie.length>0&&{caption:ie.join(" ")},line:h.line(oe)}},E=new Map,I=new Map;for(const[S,P]of r.entries()){if(P.kind==="markdown")continue;const F=O(P);if(!F)return s(h.line(P.span.start),"a cell with no statement the converter can place.");I.set(S,F);const V=jl.exec(F.statement);P.kind==="definition"&&V&&E.set(V[1],{expression:F.statement.slice(V[0].length).trim(),cell:S})}const T=S=>{const P=/^run\s*:\s*/.exec(S.statement);if(!P)return s(S.line,"a run that is not `run: <query>`.");let F=S.statement.slice(P[0].length).trim();const V=[];for(let Q=0;Q<10;Q++){const ne=Ti(F),re=/^[A-Za-z_][A-Za-z0-9_]*/.exec(ne)?.[0],ce=re?E.get(re):void 0;if(!re||!ce)break;const pe=F.slice(re.length).trim(),M=ne.slice(re.length).trim();if(M!==""&&!M.startsWith("->")&&!M.startsWith("+"))break;if(M.startsWith("+")&&Ll(Ti(ce.expression)).length!==1)return s(S.line,`\`${re} + { … }\` refines a query with more than one stage, which cannot become one view.`);V.push(re);const U=/(\/\/|--)[^\n]*$/.test(ce.expression)?`
|
|
163
|
+
`:" ";F=`${ce.expression}${pe===""?"":`${U}${pe}`}`}const ie=Ti(F);if(E.has(/^[A-Za-z_][A-Za-z0-9_]*/.exec(ie)?.[0]??""))return s(S.line,"this run names a query defined through more than 10 other queries, which the converter does not follow.");const Z=Ll(ie);if(Z.length===0)return s(S.line,"this run is not `source -> view`, so it cannot become a tile. Fix: write it as `run: <source> -> <view>`.");const oe=F.slice(0,Z[0]).trim();if(/\bextend\b/.test(ie.slice(0,Z[0])))return s(S.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(!hb.test(oe)&&!/^`[^`]+`$/.test(oe))return s(S.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 W=F.slice(Z[0]+2).trim();return W===""?s(S.line,"this run has nothing after `->`."):{source:oe,body:W,used:V}},D=new Map,L=[],R=new Set,z=new Map;let K=0,G=0;const X=new Map;for(const S of I.values()){if(S.cell.kind!=="query")continue;const P=T(S);if("ok"in P)return P;for(const F of P.used)X.set(F,(X.get(F)??0)+1)}const Y=S=>X.get(S)===1&&(e.match(new RegExp(`\\b${S}\\b`,"g"))??[]).length===2,se=new Map;for(const[S,P]of r.entries()){if(P.kind==="markdown"){const M=_(`text_${++K}`);L.push(`${M} { kind=text }`);const U=v.all.filter(de=>de.start>=P.span.start&&de.end<=P.span.end).map(de=>`${e.slice(de.start,de.end)}
|
|
164
|
+
`).join("");z.set(S,U+Fl(M,P.markdown??""));continue}const F=I.get(S);let V="";if(P.markdown!==void 0){const M=_(`text_${++K}`);L.push(`${M} { kind=text }`),V=`${Fl(M,P.markdown)}
|
|
165
|
+
`}if(P.kind==="definition"){const M=jl.exec(F.statement)?.[1];if(M&&Y(M)){R.add(S),se.set(M,F.above.split(`
|
|
166
|
+
`).filter(U=>U.trim()!=="")),V&&z.set(S,V.replace(/\n$/,""));continue}z.set(S,`${V}${F.kept}`);continue}const ie=T(F),Z=ie.source.replace(/`/g,"").replace(/[^A-Za-z0-9_]+/g,"_").replace(/^(?=[0-9])/,"_");let oe=D.get(ie.source);oe||(oe={name:_(`${Z}_tiles`),base:ie.source,views:[]},D.set(ie.source,oe));const W=[...ie.used.flatMap(M=>se.get(M)??[]),...F.above.split(`
|
|
167
|
+
`)].filter(M=>M.trim()!==""),Q=W.filter(M=>/^\s*#(?!["(|])/.test(M)),ne=Q.length>0?Au(f,Q).tag:void 0,re=_(gb(ne?.text("label")??F.caption)??`tile_${G+1}`);G++,L.push(`"${oe.name} -> ${re}"`);const ce=W.map(pb);if(F.caption!==void 0){const M=C.annotationTextProblem("caption",F.caption)===void 0;M&&!ne?.has("label")?ce.push(` # label=${Rl(F.caption)}`):M&&!ne?.has("subtitle")?ce.push(` # subtitle=${Rl(F.caption)}`):ce.push(` #" ${F.caption}`)}const pe=ie.body.split(`
|
|
168
|
+
`).map((M,U)=>U===0||M.trim()===""?M:` ${M}`).join(`
|
|
169
|
+
`);oe.views.push([...ce,` view: ${re} is ${pe}`].join(`
|
|
170
|
+
`)),R.add(S),V&&z.set(S,V.replace(/\n$/,""))}const te=(()=>{let S=0;const P=o.text;for(let F=P.indexOf("{");F<P.length;F++)if(P[F]==='"')for(F++;F<P.length&&P[F]!=='"';F++)P[F]==="\\"&&F++;else if(P[F]==="{")S++;else if(P[F]==="}"&&--S===0)return F;return-1})();if(te<0)return s(o.from,"the `## artifact { … }` tag never closes.");const A=L.length===0?`
|
|
171
|
+
tiles=[]
|
|
172
|
+
`:`
|
|
173
|
+
tiles=[
|
|
174
|
+
${L.map(S=>` ${S}`).join(`,
|
|
175
|
+
`)}
|
|
176
|
+
]
|
|
177
|
+
`,B=`${o.text.slice(0,te).trimEnd().replace(/^##(?!\|)/,"##|")}${A}${o.text.slice(te)}`;i.splice(o.from,o.block?o.to-o.from:1,...(o.block?B:`${B}
|
|
178
|
+
|##`).split(`
|
|
179
|
+
`));const N=S=>{const P=S.text.split(`
|
|
180
|
+
`),F=P.pop(),V=[];let ie=0;for(const Z of P){const oe=S.at[ie]??-1,W=v.all.some(Q=>oe>=Q.start&&oe<Q.end);(Z.trim()!==""||V.at(-1)?.trim()!==""||W)&&V.push(Z),ie+=Z.length+1}return V.map(Z=>`${Z}
|
|
181
|
+
`).join("")+F},j={text:"",at:[]},q=(S,P)=>{j.text+=e.slice(S,P);for(let F=S;F<P;F++)j.at.push(F)};let J=i.join(`
|
|
182
|
+
`),ee=n.end;for(const[S,P]of r.entries()){q(ee,P.span.start),ee=P.span.end;const F=z.get(S);F!==void 0&&(J+=N(j)+(F.endsWith(`
|
|
183
|
+
`)?F:`${F}
|
|
184
|
+
`),j.text="",j.at=[])}q(ee,e.length),J=`${J.trimEnd()}
|
|
185
|
+
`+(j.text.trim()===""?"":N(j)),J=`${J.trimEnd()}
|
|
186
|
+
`;const H=[...D.values()].map(S=>`source: ${S.name} is ${S.base} extend {
|
|
187
|
+
${S.views.join(`
|
|
188
|
+
|
|
189
|
+
`)}
|
|
190
|
+
}
|
|
191
|
+
`);return H.length>0&&(J+=`
|
|
192
|
+
${H.join(`
|
|
193
|
+
`)}`),e.includes(`\r
|
|
194
|
+
`)&&(J=J.replace(/\r?\n/g,`\r
|
|
195
|
+
`)),{ok:!0,text:J,tiles:L.length}}const Oi=(e,t)=>t!==void 0&&!/\bline \d+/i.test(e)?`${e} (line ${t})`:e;async function vb(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 mb(e);if(fb(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 zl="a .malloynb notebook is read, not edited. Fix: rewrite it as a `.malloy` notebook under notebooks/ to edit it here.",Wl="the server did not send this notebook's text, so there is nothing here to edit. Fix: edit the file in the package.";function bb({workspace:e,draft:t,draftChecked:n,readFailure:r,packageText:s,fetchedAt:i,packageSettled:o,modelPath:a,notebook:l,noun:u,refusedEvent:c,legacyFormat:d,textHeld:f,startedAt:p,onEventRef:h}){const v=e?.authoritative===!0,y=v&&r!==void 0,[w,g]=k.useState(void 0),m=(v||w===!0)&&t!==void 0,[b,_]=k.useState(void 0),[O,E]=k.useState(d?zl:void 0),I=k.useRef(void 0),T=k.useRef(void 0),[D,L]=k.useState(void 0),R=k.useRef(i);R.current=i;const z=D!==void 0&&D.onFetch===i?D.text:s,K=k.useRef(z);K.current=z;const G=m?t:z,[X,Y]=k.useState(!1),[se,te]=k.useState(void 0),[A,B]=k.useState(void 0),N=G!==void 0&&G!==A,j=b?.source,J=N&&(X||!v&&t!==void 0&&j===t&&t!==z)&&j!==void 0&&G!==se,ee=J?j:N?G:j??G,H=J?G:void 0,S=k.useRef(j);S.current=j;const P=k.useRef(G);P.current=G;const F=k.useRef("package");F.current=m?v?"record":"draft":"package",k.useEffect(()=>{if(ee===void 0||!n||y||ee===S.current)return;let oe=!1;const W=K.current,Q=P.current;return vb(ee,a,f).then(ne=>{if(!oe){if(ne.ok===!1){E(ne.reason),h.current?.({type:c,reason:ne.reason});return}E(void 0),I.current=void 0,T.current=W,L(void 0),te(void 0),B(Q),_(re=>({source:ee,document:ne.document,...ne.conversion?{conversion:ne.conversion}:{},...W!==void 0?{packageText:W}:{},generation:(re?.generation??0)+1})),h.current?.(l||ne.document.kind==="notebook"?{type:"notebook.opened",from:F.current==="package"?"package":"record",cells:ne.document.tiles.length,durationMs:C.now()-p.current}:{type:"dashboard.opened",from:F.current,tiles:ne.document.tiles.length,durationMs:C.now()-p.current})}}).catch(ne=>{if(oe)return;const re=`Could not read the ${u}: ${ne instanceof Error?ne.message:String(ne)}`;E(re),h.current?.({type:c,reason:re})}),()=>{oe=!0}},[ee,a,n,y,l,u,c,f,p,h]),k.useEffect(()=>{d&&h.current?.({type:"notebook.open_refused",reason:zl})},[d,h]),k.useEffect(()=>{!f||!n||b||r!==void 0||(v?t===void 0&&E("the host's storage has no document at this location."):E("a document held as text needs a storage whose workspace is authoritative. Fix: mark the workspace that keeps it `authoritative`."))},[f,n,b,r,v,t]);const V=l&&!f&&!b&&n&&!m&&o&&s===void 0;return k.useEffect(()=>{V&&(E(Wl),h.current?.({type:"notebook.open_refused",reason:Wl}))},[V,h]),{authoritative:v,blockedOnRecord:y,resume:w,setResume:g,fromDraft:m,opened:b,setOpened:_,openError:O,savedHashRef:I,packageBaseRef:T,setWrote:L,fetchedAtRef:R,setDirty:Y,setSeen:B,held:H,choose:oe=>{p.current=C.now(),te(oe?t:z),g(oe)},acceptHeld:()=>{p.current=C.now(),te(H)}}}function yb({storage:e,workspace:t,kind:n,notebook:r,environmentName:s,packageName:i,modelPath:o,versionId:a,apiClients:l,queryClient:u,mutable:c,textHeld:d,readFailure:f,authoritative:p,resume:h,setResume:v,setOpened:y,setDraft:w,setOffered:g,setSeen:m,setWrote:b,savedHashRef:_,packageBaseRef:O,fetchedAtRef:E}){const I=t===void 0?void 0:C.locatorFor(n,t.name,s,i,o),T=k.useCallback(async te=>{if(!e||!I)throw new Error("This host keeps no documents, so there is nowhere to save.");await e.saveDocument(I,te),y(A=>A&&{...A,source:te}),w(te),(p||h===!0)&&m(te),p||v(A=>A??!1)},[e,I,p,h,y,w,m,v]),[D,L]=k.useState(void 0),R=k.useCallback(async te=>{const A=await C.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 C.writePackageFile({apiClients:l,queryClient:u,environmentName:s,packageName:i,modelPath:o,source:te,expectedHash:A,invalidateOnError:[B],afterWrite:async N=>{if(y(j=>j&&{...j,source:te}),b({text:te,onFetch:E.current}),m(te),_.current=N,L(void 0),e&&I)try{await e.deleteDocument(I),w(void 0),g(!1)}catch(j){C.isDocumentNotFound(j)?(w(void 0),g(!1)):L(C.storageErrorMessage(j))}v(!1)},invalidate:[{queryKey:B,wait:!0},{queryKey:C.modelResultsKey({environmentName:s,packageName:i,versionId:a,modelPath:o})},{queryKey:["dashboard-editor-manifest"]},{queryKey:["dashboards"]},{queryKey:["dashboard"]},...r?[{queryKey:[C.encodeResourceUri({environmentName:s,packageName:i,modelPath:o})]}]:[]]})},[l,s,i,o,a,r,e,I,u,_,O,E,y,b,m,w,g,v]),z=t?.writeable===!0,K=c===!0&&!d,{savesTo:G,pinnedPackageSave:X,writer:Y}=C.saveTarget({authoritative:p,mutable:K,...a!==void 0?{versionId:a}:{},canStore:!!e&&!!I&&z&&(!r||p),readFailed:f!==void 0});return{save:Y==="storage"?T:Y==="package"?R:void 0,savesTo:G,writer:Y,pinnedPackageSave:X,takesWrites:K,supersedeFailure:D}}function Qu(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:c,versionId:d,namesBoth:f}=C.resolveEditorTarget(e),p="resourceUri"in e?e.dashboard:e.dashboardName,h=a?"notebook":"dashboard",v=a?"notebook.open_refused":"dashboard.open_refused",{apiClients:y,mutable:w,isLoadingStatus:g}=Ke.useServer(),m=af.useQueryClient(),b=k.useRef(C.now()),_=k.useRef(t);_.current=t;const O=k.useRef(n);O.current=n;const E=C.useOptionalDocumentStorage()?.documentStorage,I=a&&/\.malloynb$/i.test(p),T=i??`${s}s/${p}.malloy`,D=C.useQueryWithApiError({queryKey:["dashboard-editor-model",u,c,T,d,a],queryFn:()=>y.models.getModel(u,c,T,d,a?!0:void 0),enabled:f&&!I&&!l}),L=D.data?.data?.sourceText,{workspace:R,draft:z,setDraft:K,draftChecked:G,offered:X,setOffered:Y,readFailure:se}=ob({storage:E,kind:s,notebook:a,environmentName:u,packageName:c,modelPath:T}),{authoritative:te,blockedOnRecord:A,resume:B,setResume:N,fromDraft:j,opened:q,setOpened:J,openError:ee,savedHashRef:H,packageBaseRef:S,setWrote:P,fetchedAtRef:F,setDirty:V,setSeen:ie,held:Z,choose:oe,acceptHeld:W}=bb({workspace:R,draft:z,draftChecked:G,readFailure:se,packageText:L,fetchedAt:D.dataUpdatedAt,packageSettled:D.isSuccess&&!D.isFetching,modelPath:T,notebook:a,noun:h,refusedEvent:v,legacyFormat:I,textHeld:l,startedAt:b,onEventRef:_}),{save:Q,savesTo:ne,writer:re,pinnedPackageSave:ce,takesWrites:pe,supersedeFailure:M}=yb({storage:E,workspace:R,kind:s,notebook:a,environmentName:u,packageName:c,modelPath:T,versionId:d,apiClients:y,queryClient:m,mutable:w,textHeld:l,readFailure:se,authoritative:te,resume:B,setResume:N,setOpened:J,setDraft:K,setOffered:Y,setSeen:ie,setWrote:P,savedHashRef:H,packageBaseRef:S,fetchedAtRef:F}),U=R?.name,de=k.useCallback(vt=>{_.current?.(C.withWorkspace(vt,U))},[U]),ve=k.useCallback(vt=>{V(vt),O.current?.(vt)},[V]),Re=ne==="host"&&R?.description?R.description:void 0,Nn=!te&&!l&&w===void 0?g?"Checking whether this server takes writes.":"This server did not say whether it takes writes, so Save is off.":C.saveCaption({authoritative:te,mutable:pe,pinnedPackageSave:ce,...R?{workspace:R}:{},...se!==void 0?{readFailure:se}:{},...d!==void 0?{versionId:d}:{}}),mt=Nn===Re?"":Nn;if(!f&&"resourceUri"in e)return x.jsxs($.Alert,{severity:"error",sx:{m:2},children:["A ",h," resource URI must name an environment and a package. Received: ",e.resourceUri]});if(ee)return x.jsxs($.Alert,{severity:"error",sx:{m:2},children:["This ",h," cannot be opened in the builder: ",ee]});if(D.isError&&!q)return x.jsx(C.ApiErrorDisplay,{error:D.error,context:`Opening the ${h}`});if(!q&&(!(l||L)||!G))return x.jsx(C.Loading,{text:`Opening the ${h}…`});if(A)return x.jsxs($.Alert,{severity:"error",sx:{m:2},children:["This ",h," cannot be opened: ",se]});const Fn=z!==void 0&&z!==L;return x.jsxs($.Stack,{sx:{gap:2},children:[D.isError&&x.jsxs($.Alert,{severity:"warning",children:["The ",h," could not be re-read from the server:"," ",D.error?.message,". Your edits are still here."]}),!a&&!te&&X&&Fn&&B===void 0&&x.jsx($.Alert,{severity:"info",action:x.jsxs($.Stack,{direction:"row",sx:{gap:1},children:[x.jsx($.Button,{size:"small",onClick:()=>oe(!0),children:"Resume"}),x.jsx($.Button,{size:"small",onClick:()=>oe(!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($.Alert,{severity:"warning",action:x.jsx($.Button,{size:"small",onClick:W,children:"Load it"}),children:ne==="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.":ne==="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."}),M!==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:"," ",M]}),q&&x.jsx(ib,{kind:s,environmentName:u,packageName:c,modelPath:T,...o?{textSource:o}:{},slug:p,modelGivens:D.data?.data?.givens,...d!==void 0?{versionId:d}:{},opened:q,...j&&re==="package"&&q.packageText!==void 0?{replaces:q.packageText}:{},onSave:Q,onDirtyChange:ve,...r?{onExit:r}:{},savesTo:ne,...Re?{saveLabel:Re}:{},...t?{onEvent:de}:{},note:mt},q.generation)]})}function xb(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(Qu,{...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=C.MAX_SLUG_ATTEMPTS;exports.createDocument=C.createDocument;exports.createRoute=C.createRoute;exports.documentPathFor=C.documentPathFor;exports.documentPathForTitle=C.documentPathForTitle;exports.locatorFor=C.locatorFor;exports.newDashboardSource=C.newDashboardSource;exports.newDocumentProblem=C.newDocumentProblem;exports.newNotebookSource=C.newNotebookSource;exports.slugFor=C.slugFor;exports.slugOrFallback=C.slugOrFallback;exports.useDocumentChoices=C.useDocumentChoices;exports.DashboardBuilder=Zu;exports.DashboardEditor=Qu;exports.NotebookEditor=xb;exports.buildCatalog=Vu;exports.readDashboardDocument=Tr;exports.readFailed=$r;exports.spliceDashboardDocument=Wu;exports.spliceFailed=Rs;
|