@luzmo/analytics-components-kit 1.0.3-beta.14 → 1.0.3-beta.15
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/components/ai-chat/ai-chat.d.ts +2 -2
- package/components/ai-chat/empty-state/ai-chat-empty-state.d.ts +2 -2
- package/components/ai-chat/index.cjs +1 -1
- package/components/ai-chat/index.js +1 -1
- package/components/ai-chat/stream/chunk-extractors.d.ts +8 -0
- package/components/ai-chat/stream/index.d.ts +1 -1
- package/components/{ai-chat-B0pW6kHf.js → ai-chat-CGz07L1B.js} +41 -37
- package/components/{ai-chat-BMsg63kL.cjs → ai-chat-CuHFdAi3.cjs} +3 -3
- package/components/ai-interaction-textarea/ai-interaction-textarea.d.ts +2 -2
- package/components/ai-interaction-textarea/index.cjs +1 -1
- package/components/ai-interaction-textarea/index.js +1 -1
- package/components/{ai-interaction-textarea-BrIlb9n1.js → ai-interaction-textarea-CXCIZKZB.js} +3 -3
- package/components/{ai-interaction-textarea-BdwiRaLH.cjs → ai-interaction-textarea-P4bhVPEp.cjs} +1 -1
- package/components/{area-chart-options.config-B_Kpww4P.js → area-chart-options.config-BmGSrfMy.js} +1 -1
- package/components/{area-chart-positioning.config-Clvr_Aan.cjs → area-chart-positioning.config-CFiinqXi.cjs} +1 -1
- package/components/{area-chart-positioning.config-CuPvdTc_.js → area-chart-positioning.config-CqCpsNal.js} +1 -1
- package/components/{area-chart-slots.config-D5Yy2L64.js → area-chart-slots.config-CUOp5A9a.js} +1 -1
- package/components/{bar-chart-options.config-CZG7R2xR.js → bar-chart-options.config-BjaTSGsm.js} +1 -1
- package/components/{bar-chart-positioning.config-Crwcy-yr.cjs → bar-chart-positioning.config-Bkfrgifi.cjs} +1 -1
- package/components/{bar-chart-positioning.config-CqOU-wdj.js → bar-chart-positioning.config-D9sQ_mYf.js} +1 -1
- package/components/{bar-chart-slots.config-DuJKoT7z.js → bar-chart-slots.config-8MAWhbrv.js} +1 -1
- package/components/{base-BwKUauGs.js → base-CX5Tgb6T.js} +2 -2
- package/components/{base-ZuhO2UZd.cjs → base-Cm1f8TOT.cjs} +1 -1
- package/components/{box-plot-options.config-DG4Rj5ue.js → box-plot-options.config-ieBJgrhD.js} +1 -1
- package/components/{box-plot-positioning.config-Buxfxl5u.cjs → box-plot-positioning.config-B94XXogz.cjs} +1 -1
- package/components/{box-plot-positioning.config-CJi0zuFg.js → box-plot-positioning.config-BcB9ALH4.js} +1 -1
- package/components/{box-plot-slots.config-D6Q1vjez.js → box-plot-slots.config-CLXaRVQa.js} +1 -1
- package/components/{bubble-chart-options.config-DBD8wGaM.js → bubble-chart-options.config-WOXbF_Mw.js} +1 -1
- package/components/{bubble-chart-positioning.config-3iE4D0XL.js → bubble-chart-positioning.config-BPBcSLi-.js} +1 -1
- package/components/{bubble-chart-positioning.config-DpR9mwIF.cjs → bubble-chart-positioning.config-Dxg-joIj.cjs} +1 -1
- package/components/{bubble-chart-slots.config-CHVjdEV-.js → bubble-chart-slots.config-GsIEnJ61.js} +1 -1
- package/components/{bullet-chart-options.config-Db2RSAw0.js → bullet-chart-options.config-CqnDjLNi.js} +1 -1
- package/components/{bullet-chart-positioning.config-4dG5YGWS.cjs → bullet-chart-positioning.config-DZv7gMV8.cjs} +1 -1
- package/components/{bullet-chart-positioning.config-O7IS72VB.js → bullet-chart-positioning.config-D_elCYj7.js} +1 -1
- package/components/{bullet-chart-slots.config-DI6jnYez.js → bullet-chart-slots.config-BUXnucNE.js} +1 -1
- package/components/{choropleth-map-options.config-CO4ouBHp.js → choropleth-map-options.config-DF6XLxtz.js} +1 -1
- package/components/{choropleth-map-positioning.config-BvKjYfiU.cjs → choropleth-map-positioning.config-CnNcf7z9.cjs} +1 -1
- package/components/{choropleth-map-positioning.config-Dlqf-3-f.js → choropleth-map-positioning.config-DwK8J-Je.js} +1 -1
- package/components/{choropleth-map-slots.config-C0xhs-tv.js → choropleth-map-slots.config-VNTAL_CR.js} +1 -1
- package/components/{circle-pack-chart-options.config-w-zFKkVJ.js → circle-pack-chart-options.config-WHqyojrB.js} +1 -1
- package/components/{circle-pack-chart-positioning.config-DNpMU7Z-.js → circle-pack-chart-positioning.config-Cq7wBSqM.js} +1 -1
- package/components/{circle-pack-chart-positioning.config-B6_Onx6i.cjs → circle-pack-chart-positioning.config-eqkwlBUY.cjs} +1 -1
- package/components/{circle-pack-chart-slots.config-D9R0_7fs.js → circle-pack-chart-slots.config-DSblfiEo.js} +1 -1
- package/components/{circular-gauge-options.config-E3qVXm97.js → circular-gauge-options.config-C3h-c76l.js} +1 -1
- package/components/{circular-gauge-positioning.config-DMHwidbv.js → circular-gauge-positioning.config-CmhmoU56.js} +1 -1
- package/components/{circular-gauge-positioning.config-CX0pSRGc.cjs → circular-gauge-positioning.config-DEWgocNs.cjs} +1 -1
- package/components/{circular-gauge-slots.config-B_tmOIkT.js → circular-gauge-slots.config-DZkUL1hj.js} +1 -1
- package/components/{column-chart-options.config-D_Ttu1dl.js → column-chart-options.config-DRXFBLTp.js} +1 -1
- package/components/{column-chart-positioning.config-5K8NNZ1J.cjs → column-chart-positioning.config-BOWZwiKV.cjs} +1 -1
- package/components/{column-chart-positioning.config-CWqxK8FS.js → column-chart-positioning.config-BiQ2k9e9.js} +1 -1
- package/components/{column-chart-slots.config-D5RWHFCh.js → column-chart-slots.config-Ca-LXHz5.js} +1 -1
- package/components/{combination-chart-options.config-vd2fpx3A.js → combination-chart-options.config-lw01Ryld.js} +1 -1
- package/components/{combination-chart-positioning.config-6Jw9GWdP.js → combination-chart-positioning.config-DM-gkBrV.js} +1 -1
- package/components/{combination-chart-positioning.config-BRU6ecRd.cjs → combination-chart-positioning.config-DZLzhRo8.cjs} +1 -1
- package/components/{combination-chart-slots.config-ClLsPTGA.js → combination-chart-slots.config-_-7WaOiy.js} +1 -1
- package/components/{conditional-number-options.config-CfvfFh2O.js → conditional-number-options.config-mq2cbi-s.js} +1 -1
- package/components/{conditional-number-positioning.config-BpWa0OTR.js → conditional-number-positioning.config-Ch0G4llS.js} +1 -1
- package/components/{conditional-number-positioning.config-BnuBruTt.cjs → conditional-number-positioning.config-Db74phQK.cjs} +1 -1
- package/components/{conditional-number-slots.config-Bq-f8m3m.js → conditional-number-slots.config-6me5BQCD.js} +1 -1
- package/components/data-field/data-field.d.ts +2 -2
- package/components/data-field/index.cjs +1 -1
- package/components/data-field/index.js +1 -1
- package/components/{data-field-hLReNkXW.cjs → data-field-D4dONU0s.cjs} +1 -1
- package/components/{data-field-TXDuIrVY.js → data-field-DC7nDhTm.js} +3 -3
- package/components/data-field-level/data-field-level.d.ts +2 -2
- package/components/data-field-level/index.cjs +1 -1
- package/components/data-field-level/index.js +1 -1
- package/components/{data-field-level-HHH9hMmb.js → data-field-level-CoAKAHyu.js} +3 -3
- package/components/data-field-level-D-HHluCO.cjs +55 -0
- package/components/data-field-panel/data-field-panel.d.ts +2 -2
- package/components/data-field-panel/index.cjs +1 -1
- package/components/data-field-panel/index.js +1 -1
- package/components/{data-field-panel-DyNtkiMX.js → data-field-panel-DmHSUosy.js} +3 -3
- package/components/{data-field-panel-DxbDbMKy.cjs → data-field-panel-DpWz-JTl.cjs} +1 -1
- package/components/data-fields-select/data-fields-select.d.ts +6 -1
- package/components/data-fields-select/index.cjs +1 -1
- package/components/data-fields-select/index.js +1 -1
- package/components/data-fields-select-DSYFUe-z.cjs +41 -0
- package/components/{data-fields-select-CPAUibFD.js → data-fields-select-a26OFHeq.js} +23 -24
- package/components/dataset-icon/dataset-icon.d.ts +2 -2
- package/components/dataset-selector-list/dataset-selector-list.d.ts +2 -2
- package/components/dataset-selector-list/index.cjs +1 -1
- package/components/dataset-selector-list/index.js +1 -1
- package/components/{dataset-selector-list-B3pSpE_Y.js → dataset-selector-list-BeR1bPHQ.js} +1 -1
- package/components/{dataset-selector-list-MO9cYlwk.cjs → dataset-selector-list-C8SXX0rI.cjs} +1 -1
- package/components/dataset-selector-row/dataset-selector-row.d.ts +2 -2
- package/components/dataset-selector-row/index.cjs +1 -1
- package/components/dataset-selector-row/index.js +1 -1
- package/components/{dataset-selector-row-BIuDsjRv.cjs → dataset-selector-row-CRt0tq_9.cjs} +1 -1
- package/components/{dataset-selector-row-Dve-Xb5j.js → dataset-selector-row-DRwOvttW.js} +1 -1
- package/components/{date-comparison-filter-options.config-DQy6LWo_.js → date-comparison-filter-options.config-QLYeJkeI.js} +1 -1
- package/components/{date-comparison-filter-slots.config-CktrdkA7.js → date-comparison-filter-slots.config-Cdl9A6_V.js} +1 -1
- package/components/{date-filter-options.config-DvMJ6WSe.js → date-filter-options.config-BgVavrZM.js} +1 -1
- package/components/{date-filter-slots.config-B_Oa8lH4.js → date-filter-slots.config-Ccs6x2sL.js} +1 -1
- package/components/{de-bxx-Ya_Y.js → de-BzI1E6GH.js} +12 -12
- package/components/de-DVFwD4yk.cjs +20 -0
- package/components/display-settings/display-settings.d.ts +1 -1
- package/components/display-settings/index.cjs +1 -1
- package/components/display-settings/index.js +1 -1
- package/components/{display-settings-BtLYNbeD.js → display-settings-BCQo0pKY.js} +1 -1
- package/components/{display-settings-DNwcbq4m.cjs → display-settings-DmGZoXoW.cjs} +1 -1
- package/components/display-settings-binning/display-settings-binning.d.ts +1 -1
- package/components/display-settings-binning/index.cjs +1 -1
- package/components/display-settings-binning/index.js +1 -1
- package/components/{display-settings-binning-6PvcJnfm.js → display-settings-binning-0Vd1WYlN.js} +2 -2
- package/components/{display-settings-binning-UqBDqKHg.cjs → display-settings-binning-wuV74nub.cjs} +1 -1
- package/components/display-settings-datetime/display-settings-datetime.d.ts +1 -1
- package/components/display-settings-datetime/index.cjs +1 -1
- package/components/display-settings-datetime/index.js +1 -1
- package/components/{display-settings-datetime-D7VTKM4O.js → display-settings-datetime-SiItfP86.js} +2 -2
- package/components/{display-settings-datetime-BHjfhUcN.cjs → display-settings-datetime-ZUfYEhLB.cjs} +1 -1
- package/components/display-settings-grand-totals/display-settings-grand-totals.d.ts +1 -1
- package/components/display-settings-grand-totals/index.cjs +1 -1
- package/components/display-settings-grand-totals/index.js +1 -1
- package/components/{display-settings-grand-totals-N8z2xbbZ.js → display-settings-grand-totals-DMfFkf4E.js} +2 -2
- package/components/{display-settings-grand-totals-Bg1bAe4Y.cjs → display-settings-grand-totals-r6-HbKEO.cjs} +1 -1
- package/components/display-settings-numeric/display-settings-numeric.d.ts +1 -1
- package/components/display-settings-numeric/index.cjs +1 -1
- package/components/display-settings-numeric/index.js +1 -1
- package/components/{display-settings-numeric-BtXC1gPj.js → display-settings-numeric-Dm8Xpcgk.js} +2 -2
- package/components/{display-settings-numeric-D5hQU-sd.cjs → display-settings-numeric-bPjLnWuj.cjs} +1 -1
- package/components/display-settings-period-over-period/display-settings-period-over-period.d.ts +1 -1
- package/components/display-settings-period-over-period/index.cjs +1 -1
- package/components/display-settings-period-over-period/index.js +1 -1
- package/components/{display-settings-period-over-period-DzSsF1nw.cjs → display-settings-period-over-period-B1ElccjQ.cjs} +1 -1
- package/components/{display-settings-period-over-period-CSLfTV7e.js → display-settings-period-over-period-Cjp3o7q7.js} +2 -2
- package/components/{donut-chart-options.config-C2E9YnqT.js → donut-chart-options.config-Cp7xDme8.js} +1 -1
- package/components/{donut-chart-positioning.config-Dx3jt1n_.js → donut-chart-positioning.config-C2nqFPI2.js} +1 -1
- package/components/{donut-chart-positioning.config-BSb68HFR.cjs → donut-chart-positioning.config-DqUprEyG.cjs} +1 -1
- package/components/{donut-chart-slots.config-B_wEHJUU.js → donut-chart-slots.config-CbTjtlVL.js} +1 -1
- package/components/{dropdown-filter-options.config-TdCD9uPT.js → dropdown-filter-options.config-cI-v0Bit.js} +1 -1
- package/components/{dropdown-filter-slots.config-D2g89-3k.js → dropdown-filter-slots.config-DHi5mR4A.js} +1 -1
- package/components/{es-DelFOUQS.js → es-CxdZmvAN.js} +12 -12
- package/components/es-DAH5DlKK.cjs +20 -0
- package/components/{evolution-number-options.config-CiKzbVIu.js → evolution-number-options.config-Dn9zfBD8.js} +1 -1
- package/components/{evolution-number-positioning.config-DQbhwiGv.cjs → evolution-number-positioning.config-B8mg6Vrs.cjs} +1 -1
- package/components/{evolution-number-positioning.config-BA8aL9iJ.js → evolution-number-positioning.config-Dh-S3PmL.js} +1 -1
- package/components/{evolution-number-slots.config-DfsGuiu7.js → evolution-number-slots.config-DHg97NSK.js} +1 -1
- package/components/filter-expression-picker/filter-expression-picker.d.ts +1 -1
- package/components/filter-expression-picker/index.cjs +1 -1
- package/components/filter-expression-picker/index.js +1 -1
- package/components/{filter-expression-picker-Co7iUnwo.cjs → filter-expression-picker-3Z2Ioynq.cjs} +1 -1
- package/components/{filter-expression-picker-BlzebHtT.js → filter-expression-picker-xw1Ni0VT.js} +1 -1
- package/components/filter-item/filter-item.d.ts +1 -1
- package/components/filter-item/index.cjs +1 -1
- package/components/filter-item/index.js +1 -1
- package/components/{filter-item-DiuMzccR.cjs → filter-item-BC11qeis.cjs} +1 -1
- package/components/{filter-item-BIa9Y1TU.js → filter-item-Buum5q89.js} +4 -4
- package/components/filter-parameter-picker/filter-parameter-picker.d.ts +1 -1
- package/components/filter-value-picker/filter-value-picker.d.ts +1 -1
- package/components/filter-value-picker/index.cjs +1 -1
- package/components/filter-value-picker/index.js +1 -1
- package/components/{filter-value-picker-DV4IRVag.js → filter-value-picker-DIy1WNnT.js} +4 -4
- package/components/{filter-value-picker-BdsGUgBl.cjs → filter-value-picker-DzuBMM9j.cjs} +1 -1
- package/components/filter-value-picker-datetime/filter-value-picker-datetime.d.ts +1 -1
- package/components/filter-value-picker-datetime/index.cjs +1 -1
- package/components/filter-value-picker-datetime/index.js +1 -1
- package/components/{filter-value-picker-datetime-DvV2PR3B.cjs → filter-value-picker-datetime-BC28LvQC.cjs} +1 -1
- package/components/{filter-value-picker-datetime-_EDhhzr_.js → filter-value-picker-datetime-CwwWycp2.js} +1 -1
- package/components/filter-value-picker-hierarchy/filter-value-picker-hierarchy.d.ts +1 -1
- package/components/filter-value-picker-hierarchy/index.cjs +1 -1
- package/components/filter-value-picker-hierarchy/index.js +1 -1
- package/components/{filter-value-picker-hierarchy-CqZXOE2D.cjs → filter-value-picker-hierarchy-BhVpdGgz.cjs} +1 -1
- package/components/{filter-value-picker-hierarchy-CgYAWQ-g.js → filter-value-picker-hierarchy-CT_xGGvZ.js} +2 -2
- package/components/filter-value-picker-numeric/filter-value-picker-numeric.d.ts +1 -1
- package/components/filter-value-picker-numeric/index.cjs +1 -1
- package/components/filter-value-picker-numeric/index.js +1 -1
- package/components/{filter-value-picker-numeric-t24bCjgg.cjs → filter-value-picker-numeric-BUk0-rIT.cjs} +1 -1
- package/components/{filter-value-picker-numeric-C4VF0Kot.js → filter-value-picker-numeric-BjpONPzl.js} +1 -1
- package/components/filters/filters.d.ts +1 -1
- package/components/filters/index.cjs +1 -1
- package/components/filters/index.js +1 -1
- package/components/{filters-C10dtogk.cjs → filters-CaIfBmol.cjs} +1 -1
- package/components/{filters-DJ9eq7Xq.js → filters-Cx1jBZnG.js} +2 -2
- package/components/formula/formula.d.ts +2 -2
- package/components/formula/index.cjs +1 -1
- package/components/formula/index.js +1 -1
- package/components/{formula-BgvJ0GQ4.js → formula-C0sJNrbn.js} +2 -2
- package/components/{formula-DHQae3tc.cjs → formula-Cx8qb4mx.cjs} +1 -1
- package/components/formula-codemirror/formula-codemirror.d.ts +2 -2
- package/components/formula-codemirror/pills/formula-aggregation/formula-aggregation.d.ts +2 -2
- package/components/formula-codemirror/pills/formula-empty-argument-pill/formula-empty-argument-pill.d.ts +3 -2
- package/components/formula-codemirror/pills/formula-include-exclude-panel.d.ts +1 -1
- package/components/{formula-codemirror-BZTsmrYL.cjs → formula-codemirror-CDVCsGt-.cjs} +4 -3
- package/components/{formula-codemirror-iySUHkZq.js → formula-codemirror-DHhZIkZu.js} +11 -7
- package/components/formula-display-store-8CZR15VI.cjs +20 -0
- package/components/{formula-display-store-CcBMayNE.js → formula-display-store-B0qdgIWE.js} +16 -16
- package/components/formula-draggable-field/formula-draggable-field.d.ts +2 -2
- package/components/formula-editor/formula-aggregations-list.d.ts +1 -1
- package/components/formula-editor/formula-datasets-list.d.ts +1 -1
- package/components/formula-editor/formula-description.d.ts +1 -1
- package/components/formula-editor/formula-editor.d.ts +2 -2
- package/components/formula-editor/formula-functions-list.d.ts +1 -1
- package/components/formula-editor/index.cjs +1 -1
- package/components/formula-editor/index.js +3 -3
- package/components/{formula-editor-YtSlmUwM.js → formula-editor-Cb09xB7P.js} +12 -10
- package/components/formula-editor-JV3ez2SS.cjs +218 -0
- package/components/formula-field/formula-field.d.ts +2 -2
- package/components/formula-field/index.cjs +1 -1
- package/components/formula-field/index.js +1 -1
- package/components/{formula-field-CpKC6bbr.cjs → formula-field-B8Skucii.cjs} +1 -1
- package/components/{formula-field-DdZ4ll8e.js → formula-field-DErKqBNJ.js} +1 -1
- package/components/{formula-input-base-B18f5b5l.js → formula-input-base-ClsS4Fjo.js} +30 -34
- package/components/{formula-input-base-BlHhsmsp.cjs → formula-input-base-PaKnJFdj.cjs} +1 -1
- package/components/{fr-DjXcKdWm.js → fr-Bz4wSWRM.js} +12 -12
- package/components/fr-DRBLx0jg.cjs +20 -0
- package/components/{funnel-chart-options.config-Bj0ziWXc.js → funnel-chart-options.config-BGOIfaHa.js} +1 -1
- package/components/{funnel-chart-positioning.config-w2JdWOJK.cjs → funnel-chart-positioning.config-C6DQ8-Wj.cjs} +1 -1
- package/components/{funnel-chart-positioning.config-DtUWAc7T.js → funnel-chart-positioning.config-DESJ1ElH.js} +1 -1
- package/components/{funnel-chart-slots.config-DJ6qZQsu.js → funnel-chart-slots.config-DrzUVm5H.js} +1 -1
- package/components/{get-css-variable-DZl6AFiB.js → get-css-variable-BkttUh4n.js} +1 -1
- package/components/get-css-variable-JINwtCGW.cjs +20 -0
- package/components/{get-dataset-name-gEWlDRD5.js → get-dataset-name-DMeWVuPA.js} +1 -1
- package/components/{get-dataset-name-CZU5eeyo.cjs → get-dataset-name-ZDHd9ilw.cjs} +1 -1
- package/components/{groupings-Txqk_wHs.js → groupings-DyM53XCF.js} +1 -1
- package/components/{groupings-n-soRcZA.cjs → groupings-RUCg-wxj.cjs} +1 -1
- package/components/{heat-map-options.config-BBhV91tE.js → heat-map-options.config-DFEm6cG2.js} +1 -1
- package/components/{heat-map-positioning.config-DIQNlbm1.js → heat-map-positioning.config-BzTA3gLP.js} +1 -1
- package/components/{heat-map-positioning.config-BCsBYI1C.cjs → heat-map-positioning.config-CcSZ11Gm.cjs} +1 -1
- package/components/{heat-map-slots.config-CHViaLrX.js → heat-map-slots.config-Ch2gSPx6.js} +1 -1
- package/components/{heat-table-options.config-BWPdiZpT.js → heat-table-options.config-ENgb4nz-.js} +1 -1
- package/components/{heat-table-positioning.config-B6OntYKu.js → heat-table-positioning.config-B_wPE1TM.js} +1 -1
- package/components/{heat-table-positioning.config-DKMu_7fQ.cjs → heat-table-positioning.config-C-HOlTHg.cjs} +1 -1
- package/components/{heat-table-slots.config-r7zJ0gne.js → heat-table-slots.config-D8CoP7E2.js} +1 -1
- package/components/{hexbin-map-options.config-BFX7W2GB.js → hexbin-map-options.config-Ci49anBI.js} +1 -1
- package/components/{hexbin-map-positioning.config-D9jHfncD.js → hexbin-map-positioning.config-BlHK-eZU.js} +1 -1
- package/components/{hexbin-map-positioning.config-BtxDUhio.cjs → hexbin-map-positioning.config-CAprrAqn.cjs} +1 -1
- package/components/{hexbin-map-slots.config-B1I0HYI_.js → hexbin-map-slots.config-CYlRNKEN.js} +1 -1
- package/components/icon-element-DpN-9yaN.cjs +20 -0
- package/components/{icon-element-DYQjN0TG.js → icon-element-_jY440X2.js} +23 -7
- package/components/{image-options.config-rz1AE25q.js → image-options.config-CnjLU9kp.js} +1 -1
- package/components/{image-slots.config-DoY0rzAB.js → image-slots.config-D6SVO5qQ.js} +1 -1
- package/components/index.cjs +1 -1
- package/components/index.js +51 -51
- package/components/item-grid/helpers/grid-item-popover.d.ts +1 -1
- package/components/item-grid/helpers/grid-rendering.d.ts +2 -2
- package/components/item-grid/index.cjs +1 -1
- package/components/item-grid/index.js +1 -1
- package/components/item-grid/item-grid-item-actions-menu.d.ts +1 -1
- package/components/item-grid/item-grid.d.ts +1 -1
- package/components/item-grid/types.d.ts +1 -1
- package/components/{item-grid-Hcahqw8V.cjs → item-grid-B7g1Bfsh.cjs} +1 -1
- package/components/{item-grid-bjpi9sSB.js → item-grid-DmE7yqo7.js} +1 -1
- package/components/item-option/index.cjs +1 -1
- package/components/item-option/index.js +1 -1
- package/components/item-option/item-option.d.ts +1 -1
- package/components/{item-option-CiMdtMdo.cjs → item-option-4Hmsr7SU.cjs} +1 -1
- package/components/{item-option-B7cG4nHM.js → item-option-BK7L91sm.js} +46 -46
- package/components/item-option-action-button-group/index.cjs +1 -1
- package/components/item-option-action-button-group/index.js +1 -1
- package/components/item-option-action-button-group/item-option-action-button-group.d.ts +2 -2
- package/components/{item-option-action-button-group-BtS9Ho3y.cjs → item-option-action-button-group--Ei15-NI.cjs} +1 -1
- package/components/{item-option-action-button-group-CvT79MQj.js → item-option-action-button-group-CXtpEL8n.js} +1 -1
- package/components/item-option-base/item-option-base.d.ts +1 -1
- package/components/{item-option-base-vrkMCFHF.cjs → item-option-base-CsIF7BNJ.cjs} +1 -1
- package/components/{item-option-base-CWK-MoDz.js → item-option-base-D6flLRFy.js} +1 -1
- package/components/item-option-color-palette-picker/index.cjs +1 -1
- package/components/item-option-color-palette-picker/index.js +1 -1
- package/components/item-option-color-palette-picker/item-option-color-palette-picker.d.ts +2 -2
- package/components/{item-option-color-palette-picker-CbtgwN1J.js → item-option-color-palette-picker-Cv7MKtpC.js} +1 -1
- package/components/{item-option-color-palette-picker-BlhO3Kri.cjs → item-option-color-palette-picker-CvqS4AjG.cjs} +1 -1
- package/components/item-option-color-picker/index.cjs +1 -1
- package/components/item-option-color-picker/index.js +1 -1
- package/components/item-option-color-picker/item-option-color-picker.d.ts +1 -1
- package/components/{item-option-color-picker-CccU9Lry.js → item-option-color-picker-CCkP0Z_f.js} +1 -1
- package/components/{item-option-color-picker-C-D1vohW.cjs → item-option-color-picker-D4b7IuoH.cjs} +1 -1
- package/components/item-option-color-range/index.cjs +1 -1
- package/components/item-option-color-range/index.js +1 -1
- package/components/item-option-color-range/item-option-color-range.d.ts +2 -2
- package/components/{item-option-color-range-CbKK4m6t.cjs → item-option-color-range-DFzJKEVS.cjs} +1 -1
- package/components/{item-option-color-range-DwP4zb0q.js → item-option-color-range-DYdo3feh.js} +1 -1
- package/components/item-option-multi-language-field/index.cjs +1 -1
- package/components/item-option-multi-language-field/index.js +1 -1
- package/components/item-option-multi-language-field/item-option-multi-language-field.d.ts +1 -1
- package/components/{item-option-multi-language-field-C71-iMVr.js → item-option-multi-language-field-C6tUqzOr.js} +1 -1
- package/components/{item-option-multi-language-field-CfPtLuVH.cjs → item-option-multi-language-field-Dq_sI_12.cjs} +1 -1
- package/components/item-option-number-field/index.cjs +1 -1
- package/components/item-option-number-field/index.js +1 -1
- package/components/item-option-number-field/item-option-number-field.d.ts +1 -1
- package/components/{item-option-number-field-0XRgAD5B.cjs → item-option-number-field-0ezMJ5L4.cjs} +1 -1
- package/components/{item-option-number-field-CP8SMZMR.js → item-option-number-field-xqVUop38.js} +1 -1
- package/components/item-option-panel/index.cjs +1 -1
- package/components/item-option-panel/index.js +1 -1
- package/components/item-option-panel/item-option-panel.d.ts +2 -2
- package/components/{item-option-panel-BwYSwYSj.js → item-option-panel-BdKvy8O_.js} +2 -2
- package/components/{item-option-panel-JQ26EogB.cjs → item-option-panel-C2J2GlGu.cjs} +1 -1
- package/components/item-option-picker/index.cjs +1 -1
- package/components/item-option-picker/index.js +1 -1
- package/components/item-option-picker/item-option-picker.d.ts +2 -2
- package/components/{item-option-picker-DIWqO_S7.js → item-option-picker-Cf1WXXu8.js} +1 -1
- package/components/{item-option-picker-BJsgcTnE.cjs → item-option-picker-DD9R8iZq.cjs} +1 -1
- package/components/item-option-position-picker/index.cjs +1 -1
- package/components/item-option-position-picker/index.js +1 -1
- package/components/item-option-position-picker/item-option-position-picker.d.ts +1 -1
- package/components/{item-option-position-picker-BdT0UnEB.cjs → item-option-position-picker-BLoq73ei.cjs} +1 -1
- package/components/{item-option-position-picker-DidnyN7_.js → item-option-position-picker-BhNj0UcT.js} +1 -1
- package/components/item-option-positions-number-field/index.cjs +1 -1
- package/components/item-option-positions-number-field/index.js +1 -1
- package/components/item-option-positions-number-field/item-option-positions-number-field.d.ts +1 -1
- package/components/{item-option-positions-number-field-DPMVuUMn.cjs → item-option-positions-number-field-CHrbhZqH.cjs} +1 -1
- package/components/{item-option-positions-number-field-B3ZRQ-GZ.js → item-option-positions-number-field-Cg6doG4A.js} +1 -1
- package/components/item-option-radio-button-group/index.cjs +1 -1
- package/components/item-option-radio-button-group/index.js +1 -1
- package/components/item-option-radio-button-group/item-option-radio-button-group.d.ts +2 -2
- package/components/{item-option-radio-button-group-BpAYKUcc.js → item-option-radio-button-group-CN6hU6RU.js} +1 -1
- package/components/{item-option-radio-button-group-D_tAaLOQ.cjs → item-option-radio-button-group-Dg0CdjxZ.cjs} +1 -1
- package/components/item-option-slider/index.cjs +1 -1
- package/components/item-option-slider/index.js +1 -1
- package/components/item-option-slider/item-option-slider.d.ts +1 -1
- package/components/{item-option-slider-DQx3yabJ.cjs → item-option-slider-B4PTyBMs.cjs} +1 -1
- package/components/{item-option-slider-CQI88p3O.js → item-option-slider-BV31157U.js} +1 -1
- package/components/item-option-switch/index.cjs +1 -1
- package/components/item-option-switch/index.js +1 -1
- package/components/item-option-switch/item-option-switch.d.ts +1 -1
- package/components/{item-option-switch-CZ00Bd-L.js → item-option-switch-B0N1aObO.js} +1 -1
- package/components/{item-option-switch-BZ9JDF_Q.cjs → item-option-switch-l6T8HNxh.cjs} +1 -1
- package/components/item-option-text-field/index.cjs +1 -1
- package/components/item-option-text-field/index.js +1 -1
- package/components/item-option-text-field/item-option-text-field.d.ts +1 -1
- package/components/{item-option-text-field-C8VTaY4N.js → item-option-text-field-CSs97AX4.js} +1 -1
- package/components/{item-option-text-field-BbxPFuHZ.cjs → item-option-text-field-DCsChZRt.cjs} +1 -1
- package/components/item-options-configs.js +45 -45
- package/components/item-slot-drop/index.cjs +1 -1
- package/components/item-slot-drop/index.js +1 -1
- package/components/item-slot-drop/item-slot-drop.d.ts +2 -2
- package/components/item-slot-drop-eT43oyv3.cjs +91 -0
- package/components/item-slot-drop-panel/index.cjs +1 -1
- package/components/item-slot-drop-panel/index.js +1 -1
- package/components/item-slot-drop-panel/item-slot-drop-panel.d.ts +2 -2
- package/components/{item-slot-drop-panel-DF5odPJm.cjs → item-slot-drop-panel-DBrjJ4ze.cjs} +1 -1
- package/components/{item-slot-drop-panel-jKBmZxM0.js → item-slot-drop-panel-QAe0Qrih.js} +40 -40
- package/components/{item-slot-drop-C3R8PW1h.js → item-slot-drop-z8stQQVx.js} +6 -6
- package/components/item-slot-picker/index.cjs +1 -1
- package/components/item-slot-picker/index.js +1 -1
- package/components/item-slot-picker/item-slot-picker.d.ts +2 -2
- package/components/{item-slot-picker-DQJ-lnZM.cjs → item-slot-picker-BSHXUYxt.cjs} +1 -1
- package/components/{item-slot-picker-CPz4v6dj.js → item-slot-picker-BZU8paGF.js} +6 -6
- package/components/item-slot-picker-panel/index.cjs +1 -1
- package/components/item-slot-picker-panel/index.js +1 -1
- package/components/item-slot-picker-panel/item-slot-picker-panel.d.ts +2 -2
- package/components/{item-slot-picker-panel-sdxrlk9Z.cjs → item-slot-picker-panel-B0vUAqMG.cjs} +1 -1
- package/components/{item-slot-picker-panel-CML1pMrC.js → item-slot-picker-panel-H-gdpMm0.js} +4 -4
- package/components/item-slots-configs.js +45 -45
- package/components/{line-chart-options.config-Ca6kHY7o.js → line-chart-options.config-NOwKPnkX.js} +1 -1
- package/components/{line-chart-positioning.config-DyWkf5Op.js → line-chart-positioning.config-Db6d09YF.js} +1 -1
- package/components/{line-chart-positioning.config-CIj2s14W.cjs → line-chart-positioning.config-ndUWO8fd.cjs} +1 -1
- package/components/{line-chart-slots.config-BvCDJoDq.js → line-chart-slots.config-C5HzDHIf.js} +1 -1
- package/components/{localized-mixin-BOaeCN9a.js → localized-mixin-BigLivX9.js} +1 -1
- package/components/{localized-mixin-BPOcHne5.cjs → localized-mixin-C6pW-2E_.cjs} +1 -1
- package/components/{marker-map-options.config-CnNEwDgO.js → marker-map-options.config-D1RdRtsT.js} +1 -1
- package/components/{marker-map-positioning.config-BlaqR84i.js → marker-map-positioning.config-CE1CQ8fi.js} +1 -1
- package/components/{marker-map-positioning.config-DyPBnrcf.cjs → marker-map-positioning.config-CksXPDcY.cjs} +1 -1
- package/components/{marker-map-slots.config-B7nHqX9l.js → marker-map-slots.config-pPgILUnR.js} +1 -1
- package/components/nl-DPGjQjSG.cjs +20 -0
- package/components/{nl-CnJ7GWFR.js → nl-zAf0IWtw.js} +12 -12
- package/components/{ohlc-chart-options.config-DHp9okh1.js → ohlc-chart-options.config-oYK7YUI2.js} +1 -1
- package/components/{ohlc-chart-positioning.config-C1Ib-YRX.js → ohlc-chart-positioning.config-DPlPhiqP.js} +1 -1
- package/components/{ohlc-chart-positioning.config-nhYy7sdP.cjs → ohlc-chart-positioning.config-nF6ZLgMa.cjs} +1 -1
- package/components/{ohlc-chart-slots.config-BuGrqWZO.js → ohlc-chart-slots.config-CC_Md79C.js} +1 -1
- package/components/{parallel-coordinates-plot-options.config-Cd4-eVOM.js → parallel-coordinates-plot-options.config-DUgjqjuC.js} +1 -1
- package/components/{parallel-coordinates-plot-positioning.config-B7iWes6n.cjs → parallel-coordinates-plot-positioning.config-BDG9M-lT.cjs} +1 -1
- package/components/{parallel-coordinates-plot-positioning.config-DzkH_hSg.js → parallel-coordinates-plot-positioning.config-Bq0z9X3u.js} +1 -1
- package/components/{parallel-coordinates-plot-slots.config-Cg6Bf_7v.js → parallel-coordinates-plot-slots.config-BnRdeNTx.js} +1 -1
- package/components/{pivot-table-options.config-DzjA1c1d.js → pivot-table-options.config-C0-0eGdK.js} +1 -1
- package/components/{pivot-table-positioning.config-BAeF1Wr5.cjs → pivot-table-positioning.config-CnwGHiGQ.cjs} +1 -1
- package/components/{pivot-table-positioning.config-QmdQVsVL.js → pivot-table-positioning.config-xtU2xNgG.js} +1 -1
- package/components/{pivot-table-slots.config-DNkWahjt.js → pivot-table-slots.config-oiwuaQjE.js} +1 -1
- package/components/pragmatic-element-adapter-BKHjxyuk.cjs +24 -0
- package/components/{adapter-uhkTBvxc.js → pragmatic-element-adapter-CdZ-VtP0.js} +137 -128
- package/components/{pyramid-chart-options.config-B-lK7so6.js → pyramid-chart-options.config-CxG48tDX.js} +1 -1
- package/components/{pyramid-chart-positioning.config-n6MctfWS.js → pyramid-chart-positioning.config-1Xphd4JH.js} +1 -1
- package/components/{pyramid-chart-positioning.config-Cwme_V9D.cjs → pyramid-chart-positioning.config-8QbGcYvX.cjs} +1 -1
- package/components/{pyramid-chart-slots.config-Cc4uHAA7.js → pyramid-chart-slots.config-BuXoMioS.js} +1 -1
- package/components/{radar-chart-options.config-5pUTkc2q.js → radar-chart-options.config-I0RPG2q1.js} +1 -1
- package/components/{radar-chart-positioning.config-CK4dsAUh.js → radar-chart-positioning.config-4IBTNWIa.js} +1 -1
- package/components/{radar-chart-positioning.config-DKMjOOy9.cjs → radar-chart-positioning.config-C28MYPPY.cjs} +1 -1
- package/components/{radar-chart-slots.config-15nYsk9b.js → radar-chart-slots.config-CLo4WEZ1.js} +1 -1
- package/components/{regular-table-options.config-rpofl157.js → regular-table-options.config-CQa3kJof.js} +1 -1
- package/components/{regular-table-slots.config-Bd3lFCir.js → regular-table-slots.config-IEeB46zO.js} +1 -1
- package/components/{route-map-options.config-D51lA0jk.js → route-map-options.config-Bf8Q6yWs.js} +1 -1
- package/components/{route-map-positioning.config-CwXaSsNt.js → route-map-positioning.config-BkdFZZwZ.js} +1 -1
- package/components/{route-map-positioning.config-VnefcNLZ.cjs → route-map-positioning.config-r11yPOG9.cjs} +1 -1
- package/components/{route-map-slots.config-C2grgzNN.js → route-map-slots.config-Cc4bsDaf.js} +1 -1
- package/components/{sankey-diagram-options.config-Bn9fmYgp.js → sankey-diagram-options.config-ZRqELvXS.js} +1 -1
- package/components/{sankey-diagram-positioning.config-C8r1HXKi.cjs → sankey-diagram-positioning.config-CVLbPwqb.cjs} +1 -1
- package/components/{sankey-diagram-positioning.config-M7BTpPC-.js → sankey-diagram-positioning.config-Dzjle4w0.js} +1 -1
- package/components/{sankey-diagram-slots.config-D2KTJ8Oc.js → sankey-diagram-slots.config-Bq_TcEGJ.js} +1 -1
- package/components/{scatter-plot-options.config-EP012piY.js → scatter-plot-options.config-DfbCmXn5.js} +1 -1
- package/components/{scatter-plot-positioning.config-CGlwev2w.cjs → scatter-plot-positioning.config-C4---Z-D.cjs} +1 -1
- package/components/{scatter-plot-positioning.config-TW95PU_c.js → scatter-plot-positioning.config-CF5FmeIe.js} +1 -1
- package/components/{scatter-plot-slots.config-DEhD9SG5.js → scatter-plot-slots.config-DBpDoFye.js} +1 -1
- package/components/{search-filter-options.config-C1fHQAFh.js → search-filter-options.config-SqxEUwXk.js} +1 -1
- package/components/{search-filter-slots.config-DmHZICqg.js → search-filter-slots.config-B3ACbbFC.js} +1 -1
- package/components/{set-locale-C67nRXJu.cjs → set-locale-CRP8-nL8.cjs} +1 -1
- package/components/{set-locale-DA368j-c.js → set-locale-ew7QqGtp.js} +4 -4
- package/components/{slicer-filter-options.config-B2hLQJrk.js → slicer-filter-options.config-A8wugnEz.js} +1 -1
- package/components/{slicer-filter-positioning.config-SW3t4sXb.js → slicer-filter-positioning.config-BmRI8-dm.js} +1 -1
- package/components/{slicer-filter-positioning.config-B3HV3P5V.cjs → slicer-filter-positioning.config-CLZDenI1.cjs} +1 -1
- package/components/{slicer-filter-slots.config-CzhdAIIr.js → slicer-filter-slots.config-BavJsU-I.js} +1 -1
- package/components/{slider-filter-options.config-CfkVE6rN.js → slider-filter-options.config-CDPWrdVi.js} +1 -1
- package/components/{slider-filter-slots.config-Dz3If02y.js → slider-filter-slots.config-BylyT5PF.js} +1 -1
- package/components/slot-menu/index.cjs +1 -1
- package/components/slot-menu/index.js +1 -1
- package/components/slot-menu/slot-menu.d.ts +1 -1
- package/components/{slot-menu-BX_79i8j.cjs → slot-menu-BpXyIYAR.cjs} +1 -1
- package/components/{slot-menu-D5ZpNhRn.js → slot-menu-OjJrCoCz.js} +3 -3
- package/components/slot-menu-list/index.cjs +1 -1
- package/components/slot-menu-list/index.js +1 -1
- package/components/slot-menu-list/slot-menu-list.d.ts +1 -1
- package/components/slot-menu-list-CWjrIsrM.cjs +38 -0
- package/components/{slot-menu-list--vSUiSqX.js → slot-menu-list-N9-SNgBd.js} +3 -3
- package/components/slots-config-BfQv4FTF.js +77 -0
- package/components/{speedometer-chart-options.config-B_Tf2tVD.js → speedometer-chart-options.config-DFfI42JY.js} +1 -1
- package/components/{speedometer-chart-positioning.config-Cf7VkFvv.js → speedometer-chart-positioning.config-CbN0Gtq0.js} +1 -1
- package/components/{speedometer-chart-positioning.config-CTgIInxK.cjs → speedometer-chart-positioning.config-iKYLkWUe.cjs} +1 -1
- package/components/{speedometer-chart-slots.config-CofgaLuF.js → speedometer-chart-slots.config-BN1fGwjR.js} +1 -1
- package/components/{spike-map-options.config-ZjIYwDiU.js → spike-map-options.config-BZ4NTvxQ.js} +1 -1
- package/components/{spike-map-positioning.config-BDWoRvI1.cjs → spike-map-positioning.config-BJPVpLiE.cjs} +1 -1
- package/components/{spike-map-positioning.config-tMMqD_L6.js → spike-map-positioning.config-BJQO1_tI.js} +1 -1
- package/components/{spike-map-slots.config-DGyGo3Xz.js → spike-map-slots.config-CaR0e2lc.js} +1 -1
- package/components/{strip-plot-options.config-DEDTQZJZ.js → strip-plot-options.config-BOFIn6Ak.js} +1 -1
- package/components/{strip-plot-positioning.config-cyY2RoOQ.js → strip-plot-positioning.config-255kCUHj.js} +1 -1
- package/components/{strip-plot-positioning.config-CflwBF0n.cjs → strip-plot-positioning.config-CFjVaUjb.cjs} +1 -1
- package/components/{strip-plot-slots.config-DChE-zkv.js → strip-plot-slots.config-cmjgdMgG.js} +1 -1
- package/components/{sunburst-chart-options.config-CV2e-xgJ.js → sunburst-chart-options.config-Br7wSnYG.js} +1 -1
- package/components/{sunburst-chart-positioning.config-CXqQ3rZw.js → sunburst-chart-positioning.config-BrbqHZGJ.js} +1 -1
- package/components/{sunburst-chart-positioning.config-BrkN0iSP.cjs → sunburst-chart-positioning.config-CuuUHzHA.cjs} +1 -1
- package/components/{sunburst-chart-slots.config-BX9597vW.js → sunburst-chart-slots.config-DJ2UPHA8.js} +1 -1
- package/components/{symbol-map-options.config-DLD-geyT.js → symbol-map-options.config-CFRuCJay.js} +1 -1
- package/components/{symbol-map-positioning.config-BhZjksQ9.js → symbol-map-positioning.config-CtHhE_eP.js} +1 -1
- package/components/{symbol-map-positioning.config-B4yTOZ45.cjs → symbol-map-positioning.config-Cw6TAL9G.cjs} +1 -1
- package/components/{symbol-map-slots.config-CEjSrzR2.js → symbol-map-slots.config-Db5AgYdd.js} +1 -1
- package/components/{text-options.config-DNTShSV3.js → text-options.config-DTNhvzJf.js} +1 -1
- package/components/{text-slots.config-BJiU8E1x.js → text-slots.config-DBFWpRN7.js} +1 -1
- package/components/{treemap-chart-options.config-BrTLnBOI.js → treemap-chart-options.config-Bi652OxP.js} +1 -1
- package/components/{treemap-chart-positioning.config-Cbu39jHd.cjs → treemap-chart-positioning.config-BdkPfJu-.cjs} +1 -1
- package/components/{treemap-chart-positioning.config-BTOpuIyU.js → treemap-chart-positioning.config-DOlsOpZS.js} +1 -1
- package/components/{treemap-chart-slots.config-CQO0FSsI.js → treemap-chart-slots.config-DdhJ12G_.js} +1 -1
- package/components/utils/base.cjs +1 -1
- package/components/utils/base.js +2 -2
- package/components/utils/store.js +1 -1
- package/components/{utils-CO7Bx0Nw.js → utils-B-N5--zJ.js} +2 -2
- package/components/{utils-Ab_wibuA.cjs → utils-fPI-pquf.cjs} +1 -1
- package/components/utils.cjs +1 -1
- package/components/utils.js +2 -2
- package/components/{venn-diagram-options.config-CdeK65gy.js → venn-diagram-options.config-Bkz2Cvfq.js} +1 -1
- package/components/{venn-diagram-positioning.config-xddK9cxF.js → venn-diagram-positioning.config-4XVne0-o.js} +1 -1
- package/components/{venn-diagram-positioning.config-G91Md8yt.cjs → venn-diagram-positioning.config-Cxq2-xPz.cjs} +1 -1
- package/components/{venn-diagram-slots.config-DMcOPrkK.js → venn-diagram-slots.config-CcXLv-wz.js} +1 -1
- package/components/{video-options.config-D5mS3aJI.js → video-options.config-DglpEbUc.js} +1 -1
- package/components/{video-slots.config-D3OXZQ07.js → video-slots.config-DfYlSjH1.js} +1 -1
- package/components/viz-item-menu/index.cjs +1 -1
- package/components/viz-item-menu/index.js +1 -1
- package/components/viz-item-menu/viz-item-menu.d.ts +2 -2
- package/components/{viz-item-menu-B2pAY_Jv.cjs → viz-item-menu-BwQTNUDs.cjs} +1 -1
- package/components/{viz-item-menu-D09pw6dZ.js → viz-item-menu-Ufv_GxOA.js} +2 -2
- package/components/{wordcloud-chart-options.config-IOrRDdoY.js → wordcloud-chart-options.config-BbK-pihP.js} +1 -1
- package/components/{wordcloud-chart-positioning.config-DjUW_gBa.js → wordcloud-chart-positioning.config-CCG-F2b6.js} +1 -1
- package/components/{wordcloud-chart-positioning.config-DAYAximq.cjs → wordcloud-chart-positioning.config-MTMgLQob.cjs} +1 -1
- package/components/{wordcloud-chart-slots.config-BF_R9ykk.js → wordcloud-chart-slots.config-CrBUvQdb.js} +1 -1
- package/custom-elements.json +26 -0
- package/package.json +1 -1
- package/react/utils/base/base.d.ts +1 -1
- package/react/utils/base/focusable.d.ts +1 -1
- package/react/utils/base/localized-mixin.d.ts +1 -1
- package/react/utils/base/sized-mixin.d.ts +1 -1
- package/react/utils/drag/pragmatic-element-adapter.d.ts +2 -0
- package/react/utils/drag/tests/pragmatic-element-adapter.first-import.test.d.ts +1 -0
- package/react/utils/drag/tests/pragmatic-element-adapter.test.d.ts +1 -0
- package/react/utils/formula/base/formula-base.d.ts +1 -1
- package/react/utils/formula/base/formula-input-base.d.ts +1 -1
- package/react/utils/formula/codemirror/actions.d.ts +13 -1
- package/react/utils/formula/codemirror/tests/actions.test.d.ts +1 -0
- package/react/utils/formula/render-explanation-tooltip.d.ts +1 -1
- package/react/utils/formula/store/formula-display-store.d.ts +9 -0
- package/utils/base/base.d.ts +1 -1
- package/utils/base/focusable.d.ts +1 -1
- package/utils/base/localized-mixin.d.ts +1 -1
- package/utils/base/sized-mixin.d.ts +1 -1
- package/utils/drag/pragmatic-element-adapter.d.ts +2 -0
- package/utils/drag/tests/pragmatic-element-adapter.first-import.test.d.ts +1 -0
- package/utils/drag/tests/pragmatic-element-adapter.test.d.ts +1 -0
- package/utils/formula/base/formula-base.d.ts +1 -1
- package/utils/formula/base/formula-input-base.d.ts +1 -1
- package/utils/formula/codemirror/actions.d.ts +13 -1
- package/utils/formula/codemirror/tests/actions.test.d.ts +1 -0
- package/utils/formula/render-explanation-tooltip.d.ts +1 -1
- package/utils/formula/store/formula-display-store.d.ts +9 -0
- package/components/adapter-BKowFrlw.cjs +0 -24
- package/components/data-field-level-BsmyaMeC.cjs +0 -55
- package/components/data-fields-select-tOKVkjkh.cjs +0 -41
- package/components/de-CFeKdBZ_.cjs +0 -20
- package/components/es-fAEaQEhg.cjs +0 -20
- package/components/formula-display-store-CTXbAK2f.cjs +0 -20
- package/components/formula-editor-L1af23DU.cjs +0 -218
- package/components/fr-5jK3qviC.cjs +0 -20
- package/components/get-css-variable-f6ZYOxm7.cjs +0 -20
- package/components/icon-element-2Qrd4w7o.cjs +0 -20
- package/components/item-slot-drop-BhCP8AHW.cjs +0 -91
- package/components/nl-DWGcdw3F.cjs +0 -20
- package/components/slot-menu-list-Fs6XHhqt.cjs +0 -38
- package/components/slots-config-K2g0-7Uj.js +0 -77
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
18
18
|
* SOFTWARE.
|
|
19
19
|
* */
|
|
20
|
-
const e=require("./base-
|
|
20
|
+
const e=require("./base-Cm1f8TOT.cjs"),t=require("./decorate-DCJt-2rt.cjs"),n=require("./localized-mixin-C6pW-2E_.cjs"),r=require("./calculate-data-field-icon-DenGmW74.cjs"),i=require("./localize-D3i4Epy_.cjs"),a=require("./pragmatic-element-adapter-BKHjxyuk.cjs"),o=require("./formula-display-store-8CZR15VI.cjs"),s=require("./groupings-RUCg-wxj.cjs"),c=require("./resolve-column-presentation-DUETRVCH.cjs"),l=require("./icon-element-DpN-9yaN.cjs");let u=require("@luzmo/icons");require("@luzmo/lucero/overlay"),require("@luzmo/lucero/popover");let d=require("lit"),f=require("lit/decorators.js"),p=require("@lit/localize");require("@luzmo/lucero/icon"),require("@luzmo/lucero/select"),require("@luzmo/lucero/tooltip"),require("@luzmo/lucero/action-button"),require("@luzmo/lucero/field-label"),require("@luzmo/lucero/progress-circle");var m=[],h=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?h:m).push(n+=e[t])})();function g(e){if(e<768)return!1;for(let t=0,n=m.length;;){let r=t+n>>1;if(e<m[r])n=r;else if(e>=h[r])t=r+1;else return!0;if(t==n)return!1}}function _(e){return e>=127462&&e<=127487}var v=8205;function y(e,t,n=!0,r=!0){return(n?ee:b)(e,t,r)}function ee(e,t,n){if(t==e.length)return t;t&&te(e.charCodeAt(t))&&ne(e.charCodeAt(t-1))&&t--;let r=x(e,t);for(t+=re(r);t<e.length;){let i=x(e,t);if(r==v||i==v||n&&g(i))t+=re(i),r=i;else if(_(i)){let n=0,r=t-2;for(;r>=0&&_(x(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function b(e,t,n){for(;t>0;){let r=ee(e,t-2,n);if(r<t)return r;t--}return 0}function x(e,t){let n=e.charCodeAt(t);if(!ne(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return te(r)?(n-55296<<10)+(r-56320)+65536:n}function te(e){return e>=56320&&e<57344}function ne(e){return e>=55296&&e<56320}function re(e){return e<65536?1:2}var S=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=fe(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),ie.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=fe(this,e,t);let n=[];return this.decompose(e,t,n,0),ie.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new ce(this),i=new ce(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new ce(this,e)}iterRange(e,t=this.length){return new le(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new ue(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new C(t):ie.from(C.split(t,[]))}},C=class e extends S{constructor(e,t=ae(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new de(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(se(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=oe(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=fe(this,t,n);let i=oe(this.text,oe(r.text,se(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):ie.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
|
|
21
21
|
`){[e,t]=fe(this,e,t);let r=``;for(let i=0,a=0;i<=t&&a<this.text.length;a++){let o=this.text[a],s=i+o.length;i>e&&a&&(r+=n),e<s&&t>i&&(r+=o.slice(Math.max(0,e-i),t-i)),i=s+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(t,n){let r=[],i=-1;for(let a of t)r.push(a),i+=a.length+1,r.length==32&&(n.push(new e(r,i)),r=[],i=-1);return i>-1&&n.push(new e(r,i)),n}},ie=class e extends S{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.children[i],o=r+a.length,s=n+a.lines-1;if((t?s:o)>=e)return a.lineInner(e,t,n,r);r=o+1,n=s+1}}decompose(e,t,n,r){for(let i=0,a=0;a<=t&&i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(e<=s&&t>=a){let i=r&(a<=e|(s>=t?2:0));a>=e&&s<=t&&!i?n.push(o):o.decompose(e-a,t-a,n,i)}a=s+1}}replace(t,n,r){if([t,n]=fe(this,t,n),r.lines<this.lines)for(let i=0,a=0;i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(t>=a&&n<=s){let c=o.replace(t-a,n-a,r),l=this.lines-o.lines+c.lines;if(c.lines<l>>4&&c.lines>l>>6){let a=this.children.slice();return a[i]=c,new e(a,this.length-(n-t)+r.length)}return super.replace(a,s,c)}a=s+1}return super.replace(t,n,r)}sliceString(e,t=this.length,n=`
|
|
22
22
|
`){[e,t]=fe(this,e,t);let r=``;for(let i=0,a=0;i<this.children.length&&a<=t;i++){let o=this.children[i],s=a+o.length;a>e&&i&&(r+=n),e<s&&t>a&&(r+=o.sliceString(e-a,t-a,n)),a=s+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(t,n){if(!(t instanceof e))return 0;let r=0,[i,a,o,s]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=n,a+=n){if(i==o||a==s)return r;let e=this.children[i],c=t.children[a];if(e!=c)return r+e.scanIdentical(c,n);r+=e.length+1}}static from(t,n=t.reduce((e,t)=>e+t.length+1,-1)){let r=0;for(let e of t)r+=e.lines;if(r<32){let e=[];for(let n of t)n.flatten(e);return new C(e,n)}let i=Math.max(32,r>>5),a=i<<1,o=i>>1,s=[],c=0,l=-1,u=[];function d(t){let n;if(t.lines>a&&t instanceof e)for(let e of t.children)d(e);else t.lines>o&&(c>o||!c)?(f(),s.push(t)):t instanceof C&&c&&(n=u[u.length-1])instanceof C&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new C(n.text.concat(t.text),n.length+1+t.length)):(c+t.lines>i&&f(),c+=t.lines,l+=t.length+1,u.push(t))}function f(){c!=0&&(s.push(u.length==1?u[0]:e.from(u,l)),l=-1,c=u.length=0)}for(let e of t)d(e);return f(),s.length==1?s[0]:new e(s,n)}};S.empty=new C([``],0);function ae(e){let t=-1;for(let n of e)t+=n.length+1;return t}function oe(e,t,n=0,r=1e9){for(let i=0,a=0,o=!0;a<e.length&&i<=r;a++){let s=e[a],c=i+s.length;c>=n&&(c>r&&(s=s.slice(0,r-i)),i<n&&(s=s.slice(n-i)),o?(t[t.length-1]+=s,o=!1):t.push(s)),i=c+1}return t}function se(e,t,n){return oe(e,[``],t,n)}var ce=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value=``,this.nodes=[e],this.offsets=[t>0?1:(e instanceof C?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],a=i>>1,o=r instanceof C?r.text.length:r.children.length;if(a==(t>0?o:0)){if(n==0)return this.done=!0,this.value=``,this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
23
23
|
`,this;e--}else if(r instanceof C){let i=r.text[a+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=e==0?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[a+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof C?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},le=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new ce(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value=``,this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=``}},ue=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value=``,this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value=``,this.afterBreak=!1):t?(this.done=!0,this.value=``):n?this.afterBreak?this.value=``:(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<`u`&&(S.prototype[Symbol.iterator]=function(){return this.iter()},ce.prototype[Symbol.iterator]=le.prototype[Symbol.iterator]=ue.prototype[Symbol.iterator]=function(){return this});var de=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function fe(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function w(e,t,n=!0,r=!0){return y(e,t,n,r)}function pe(e){return e>=56320&&e<57344}function me(e){return e>=55296&&e<56320}function he(e,t){let n=e.charCodeAt(t);if(!me(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return pe(r)?(n-55296<<10)+(r-56320)+65536:n}function ge(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function _e(e){return e<65536?1:2}var ve=/\r\n?|\n/,ye=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(ye||={}),be=class e{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let i=this.sections[t++],a=this.sections[t++];a<0?(e(n,r,i),r+=i):r+=a,n+=i}}iterChangedRanges(e,t=!1){Ce(this,e,t)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let n=this.sections[e++],r=this.sections[e++];r<0?t.push(n,r):t.push(r,n)}return new e(t)}composeDesc(e){return this.empty?e:e.empty?this:Te(this,e)}mapDesc(e,t=!1){return e.empty?this:we(this,e,t)}mapPos(e,t=-1,n=ye.Simple){let r=0,i=0;for(let a=0;a<this.sections.length;){let o=this.sections[a++],s=this.sections[a++],c=r+o;if(s<0){if(c>e)return i+(e-r);i+=o}else{if(n!=ye.Simple&&c>=e&&(n==ye.TrackDel&&r<e&&c>e||n==ye.TrackBefore&&r<e||n==ye.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!o)return e==r||t<0?i:i+s;i+=s}r=c}if(e>r)throw RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let i=this.sections[n++],a=this.sections[n++],o=r+i;if(a>=0&&r<=t&&o>=e)return r<e&&o>t?`cover`:!0;r=o}return!1}toString(){let e=``;for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?` `:``)+n+(r>=0?`:`+r:``)}return e}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!=`number`))throw RangeError(`Invalid JSON representation of ChangeDesc`);return new e(t)}static create(t){return new e(t)}},xe=class e extends be{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw RangeError(`Applying change set to a document with the wrong length`);return Ce(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return we(this,e,t,!0)}invert(t){let n=this.sections.slice(),r=[];for(let e=0,i=0;e<n.length;e+=2){let a=n[e],o=n[e+1];if(o>=0){n[e]=o,n[e+1]=a;let s=e>>1;for(;r.length<s;)r.push(S.empty);r.push(a?t.slice(i,i+a):S.empty)}i+=a}return new e(n,r)}compose(e){return this.empty?e:e.empty?this:Te(this,e,!0)}map(e,t=!1){return e.empty?this:we(this,e,t,!0)}iterChanges(e,t=!1){Ce(this,e,t)}get desc(){return be.create(this.sections)}filter(t){let n=[],r=[],i=[],a=new Ee(this);done:for(let e=0,o=0;;){let s=e==t.length?1e9:t[e++];for(;o<s||o==s&&a.len==0;){if(a.done)break done;let e=Math.min(a.len,s-o);T(i,e,-1);let t=a.ins==-1?-1:a.off==0?a.ins:0;T(n,e,t),t>0&&Se(r,n,a.text),a.forward(e),o+=e}let c=t[e++];for(;o<c;){if(a.done)break done;let e=Math.min(a.len,c-o);T(n,e,-1),T(i,e,a.ins==-1?-1:a.off==0?a.ins:0),a.forward(e),o+=e}}return{changes:new e(n,r),filtered:be.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):r==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(t,n,r){let i=[],a=[],o=0,s=null;function c(t=!1){if(!t&&!i.length)return;o<n&&T(i,n-o,-1);let r=new e(i,a);s=s?s.compose(r.map(s)):r,i=[],a=[],o=0}function l(t){if(Array.isArray(t))for(let e of t)l(e);else if(t instanceof e){if(t.length!=n)throw RangeError(`Mismatched change set length (got ${t.length}, expected ${n})`);c(),s=s?s.compose(t.map(s)):t}else{let{from:e,to:s=e,insert:l}=t;if(e>s||e<0||s>n)throw RangeError(`Invalid change range ${e} to ${s} (in doc of length ${n})`);let u=l?typeof l==`string`?S.of(l.split(r||ve)):l:S.empty,d=u.length;if(e==s&&d==0)return;e<o&&c(),e>o&&T(i,e-o,-1),T(i,s-e,d),Se(a,i,u),o=s}}return l(t),c(!s),s}static empty(t){return new e(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw RangeError(`Invalid JSON representation of ChangeSet`);let n=[],r=[];for(let e=0;e<t.length;e++){let i=t[e];if(typeof i==`number`)n.push(i,-1);else if(!Array.isArray(i)||typeof i[0]!=`number`||i.some((e,t)=>t&&typeof e!=`string`))throw RangeError(`Invalid JSON representation of ChangeSet`);else if(i.length==1)n.push(i[0],0);else{for(;r.length<e;)r.push(S.empty);r[e]=S.of(i.slice(1)),n.push(i[0],r[e].length)}}return new e(n,r)}static createSet(t,n){return new e(t,n)}};function T(e,t,n,r=!1){if(t==0&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&t==0&&e[i]==0?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function Se(e,t,n){if(n.length==0)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(S.empty);e.push(n)}}function Ce(e,t,n){let r=e.inserted;for(let i=0,a=0,o=0;o<e.sections.length;){let s=e.sections[o++],c=e.sections[o++];if(c<0)i+=s,a+=s;else{let l=i,u=a,d=S.empty;for(;l+=s,u+=c,c&&r&&(d=d.append(r[o-2>>1])),!(n||o==e.sections.length||e.sections[o+1]<0);)s=e.sections[o++],c=e.sections[o++];t(i,l,a,u,d),i=l,a=u}}}function we(e,t,n,r=!1){let i=[],a=r?[]:null,o=new Ee(e),s=new Ee(t);for(let e=-1;;)if(o.done&&s.len||s.done&&o.len)throw Error(`Mismatched change set lengths`);else if(o.ins==-1&&s.ins==-1){let e=Math.min(o.len,s.len);T(i,e,-1),o.forward(e),s.forward(e)}else if(s.ins>=0&&(o.ins<0||e==o.i||o.off==0&&(s.len<o.len||s.len==o.len&&!n))){let t=s.len;for(T(i,s.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(T(i,0,o.ins),a&&Se(a,i,o.text),e=o.i),o.forward(n),t-=n}s.next()}else if(o.ins>=0){let t=0,n=o.len;for(;n;)if(s.ins==-1){let e=Math.min(n,s.len);t+=e,n-=e,s.forward(e)}else if(s.ins==0&&s.len<n)n-=s.len,s.next();else break;T(i,t,e<o.i?o.ins:0),a&&e<o.i&&Se(a,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&s.done)return a?xe.createSet(i,a):be.create(i);else throw Error(`Mismatched change set lengths`)}function Te(e,t,n=!1){let r=[],i=n?[]:null,a=new Ee(e),o=new Ee(t);for(let e=!1;;)if(a.done&&o.done)return i?xe.createSet(r,i):be.create(r);else if(a.ins==0)T(r,a.len,0,e),a.next();else if(o.len==0&&!o.done)T(r,0,o.ins,e),i&&Se(i,r,o.text),o.next();else if(a.done||o.done)throw Error(`Mismatched change set lengths`);else{let t=Math.min(a.len2,o.len),n=r.length;if(a.ins==-1){let n=o.ins==-1?-1:o.off?0:o.ins;T(r,t,n,e),i&&n&&Se(i,r,o.text)}else o.ins==-1?(T(r,a.off?0:a.len,t,e),i&&Se(i,r,a.textBit(t))):(T(r,a.off?0:a.len,o.off?0:o.ins,e),i&&!o.off&&Se(i,r,o.text));e=(a.ins>t||o.ins>=0&&o.len>t)&&(e||r.length>n),a.forward2(t),o.forward(t)}}var Ee=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?S.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?S.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},De=class e{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(t,n=-1){let r,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new e(r,i,this.flags)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return E.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return E.range(this.anchor,r,void 0,void 0,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!=`number`||typeof e.head!=`number`)throw RangeError(`Invalid JSON representation for SelectionRange`);return E.range(e.anchor,e.head)}static create(t,n,r){return new e(t,n,r)}},E=class e{constructor(e,t){this.ranges=e,this.mainIndex=t}map(t,n=-1){return t.empty?this:e.create(this.ranges.map(e=>e.map(t,n)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new e([this.main],0)}addRange(t,n=!0){return e.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,e.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!=`number`||t.main>=t.ranges.length)throw RangeError(`Invalid JSON representation for EditorSelection`);return new e(t.ranges.map(e=>De.fromJSON(e)),t.main)}static single(t,n=t){return new e([e.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw RangeError(`A selection needs at least one range`);for(let r=0,i=0;i<t.length;i++){let a=t[i];if(a.empty?a.from<=r:a.from<r)return e.normalized(t.slice(),n);r=a.to}return new e(t,n)}static cursor(e,t=0,n,r){return De.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n))|(r??16777215)<<6)}static range(e,t,n,r,i){let a=(n??16777215)<<6|(r==null?7:Math.min(6,r));return!i&&e!=t&&(i=t<e?1:-1),t<e?De.create(t,e,48|a):De.create(e,t,(i?i<0?8:16:0)|a)}static normalized(t,n=0){let r=t[n];t.sort((e,t)=>e.from-t.from),n=t.indexOf(r);for(let r=1;r<t.length;r++){let i=t[r],a=t[r-1];if(i.empty?i.from<=a.to:i.from<a.to){let o=a.from,s=Math.max(i.to,a.to);r<=n&&n--,t.splice(--r,2,i.anchor>i.head?e.range(s,o):e.range(o,s))}}return new e(t,n)}};function Oe(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var ke=0,D=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=ke++,this.default=e([]),this.extensions=typeof i==`function`?i(this):i}get reader(){return this}static define(t={}){return new e(t.combine||(e=>e),t.compareInput||((e,t)=>e===t),t.compare||(t.combine?(e,t)=>e===t:Ae),!!t.static,t.enables)}of(e){return new je([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new je(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new je(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function Ae(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var je=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=ke++}dynamicSlot(e){let t=this.value,n=this.facet.compareInput,r=this.id,i=e[r]>>1,a=this.type==2,o=!1,s=!1,c=[];for(let t of this.dependencies)t==`doc`?o=!0:t==`selection`?s=!0:(e[t.id]??1)&1||c.push(e[t.id]);return{create(e){return e.values[i]=t(e),1},update(e,r){if(o&&r.docChanged||s&&(r.docChanged||r.selection)||Ne(e,c)){let r=t(e);if(a?!Me(r,e.values[i],n):!n(r,e.values[i]))return e.values[i]=r,1}return 0},reconfigure:(e,o)=>{let s,c=o.config.address[r];if(c!=null){let r=Ke(o,c);if(this.dependencies.every(t=>t instanceof D?o.facet(t)===e.facet(t):t instanceof Ie?o.field(t,!1)==e.field(t,!1):!0)||(a?Me(s=t(e),r,n):n(s=t(e),r)))return e.values[i]=r,0}else s=t(e);return e.values[i]=s,1}}}};function Me(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function Ne(e,t){let n=!1;for(let r of t)Ge(e,r)&1&&(n=!0);return n}function Pe(e,t,n){let r=n.map(t=>e[t.id]),i=n.map(e=>e.type),a=r.filter(e=>!(e&1)),o=e[t.id]>>1;function s(e){let n=[];for(let t=0;t<r.length;t++){let a=Ke(e,r[t]);if(i[t]==2)for(let e of a)n.push(e);else n.push(a)}return t.combine(n)}return{create(e){for(let t of r)Ge(e,t);return e.values[o]=s(e),1},update(e,n){if(!Ne(e,a))return 0;let r=s(e);return t.compare(r,e.values[o])?0:(e.values[o]=r,1)},reconfigure(e,i){let a=Ne(e,r),c=i.config.facets[t.id],l=i.facet(t);if(c&&!a&&Ae(n,c))return e.values[o]=l,0;let u=s(e);return t.compare(u,l)?(e.values[o]=l,0):(e.values[o]=u,1)}}}var Fe=D.define({static:!0}),Ie=class e{constructor(e,t,n,r,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=i,this.provides=void 0}static define(t){let n=new e(ke++,t.create,t.update,t.compare||((e,t)=>e===t),t);return t.provide&&(n.provides=t.provide(n)),n}create(e){return(e.facet(Fe).find(e=>e.field==this)?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r=e.facet(Fe),i=n.facet(Fe),a;return(a=r.find(e=>e.field==this))&&a!=i.find(e=>e.field==this)?(e.values[t]=a.create(e),1):n.config.address[this.id]==null?(e.values[t]=this.create(e),1):(e.values[t]=n.field(this),0)}}}init(e){return[this,Fe.of({field:this,create:e})]}get extension(){return this}},Le={lowest:4,low:3,default:2,high:1,highest:0};function Re(e){return t=>new Be(t,e)}var ze={highest:Re(Le.highest),high:Re(Le.high),default:Re(Le.default),low:Re(Le.low),lowest:Re(Le.lowest)},Be=class{constructor(e,t){this.inner=e,this.prec=t}},Ve=class e{of(e){return new He(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},He=class{constructor(e,t){this.compartment=e,this.inner=t}},Ue=class e{constructor(e,t,n,r,i,a){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(t,n,r){let i=[],a=Object.create(null),o=new Map;for(let e of We(t,n,o))e instanceof Ie?i.push(e):(a[e.facet.id]||(a[e.facet.id]=[])).push(e);let s=Object.create(null),c=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let u=r?.config.facets;for(let e in a){let t=a[e],n=t[0].facet,i=u&&u[e]||[];if(t.every(e=>e.type==0))if(s[n.id]=c.length<<1|1,Ae(i,t))c.push(r.facet(n));else{let e=n.combine(t.map(e=>e.value));c.push(r&&n.compare(e,r.facet(n))?r.facet(n):e)}else{for(let e of t)e.type==0?(s[e.id]=c.length<<1|1,c.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[n.id]=l.length<<1,l.push(e=>Pe(e,n,t))}}return new e(t,o,l.map(e=>e(s)),s,c,a)}};function We(e,t,n){let r=[[],[],[],[],[]],i=new Map;function a(e,o){let s=i.get(e);if(s!=null){if(s<=o)return;let t=r[s].indexOf(e);t>-1&&r[s].splice(t,1),e instanceof He&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof He){if(n.has(e.compartment))throw RangeError(`Duplicate use of compartment in extensions`);let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),a(r,o)}else if(e instanceof Be)a(e.inner,e.prec);else if(e instanceof Ie)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof je)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,Le.default);else{let t=e.extension;if(!t)throw Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(t,o)}}return a(e,Le.default),r.reduce((e,t)=>e.concat(t))}function Ge(e,t){if(t&1)return 2;let n=t>>1,r=e.status[n];if(r==4)throw Error(`Cyclic dependency between fields and/or facets`);if(r&2)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function Ke(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var qe=D.define(),Je=D.define({combine:e=>e.some(e=>e),static:!0}),Ye=D.define({combine:e=>e.length?e[0]:void 0,static:!0}),Xe=D.define(),Ze=D.define(),Qe=D.define(),$e=D.define({combine:e=>e.length?e[0]:!1}),et=class{constructor(e,t){this.type=e,this.value=t}static define(){return new tt}},tt=class{of(e){return new et(this,e)}},nt=class{constructor(e){this.map=e}of(e){return new O(this,e)}},O=class e{constructor(e,t){this.type=e,this.value=t}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new e(this.type,n)}is(e){return this.type==e}static define(e={}){return new nt(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}};O.reconfigure=O.define(),O.appendConfig=O.define();var k=class e{constructor(t,n,r,i,a,o){this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=a,this.scrollIntoView=o,this._doc=null,this._state=null,r&&Oe(r,n.newLength),a.some(t=>t.type==e.time)||(this.annotations=a.concat(e.time.of(Date.now())))}static create(t,n,r,i,a,o){return new e(t,n,r,i,a,o)}get newDoc(){return this._doc||=this.changes.apply(this.startState.doc)}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let n=this.annotation(e.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]==`.`))}};k.time=et.define(),k.userEvent=et.define(),k.addToHistory=et.define(),k.remote=et.define();function rt(e,t){let n=[];for(let r=0,i=0;;){let a,o;if(r<e.length&&(i==t.length||t[i]>=e[r]))a=e[r++],o=e[r++];else if(i<t.length)a=t[i++],o=t[i++];else return n;!n.length||n[n.length-1]<a?n.push(a,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function it(e,t,n){let r,i,a;return n?(r=t.changes,i=xe.empty(t.changes.length),a=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),i=e.changes.mapDesc(t.changes,!0),a=e.changes.compose(r)),{changes:a,selection:t.selection?t.selection.map(i):e.selection?.map(r),effects:O.mapEffects(e.effects,r).concat(O.mapEffects(t.effects,i)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function at(e,t,n){let r=t.selection,i=ut(t.annotations);return t.userEvent&&(i=i.concat(k.userEvent.of(t.userEvent))),{changes:t.changes instanceof xe?t.changes:xe.of(t.changes||[],n,e.facet(Ye)),selection:r&&(r instanceof E?r:E.single(r.anchor,r.head)),effects:ut(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function ot(e,t,n){let r=at(e,t.length?t[0]:{},e.doc.length);t.length&&t[0].filter===!1&&(n=!1);for(let i=1;i<t.length;i++){t[i].filter===!1&&(n=!1);let a=!!t[i].sequential;r=it(r,at(e,t[i],a?r.changes.newLength:e.doc.length),a)}let i=k.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return ct(n?st(i):i)}function st(e){let t=e.startState,n=!0;for(let r of t.facet(Xe)){let t=r(e);if(t===!1){n=!1;break}Array.isArray(t)&&(n=n===!0?t:rt(n,t))}if(n!==!0){let r,i;if(n===!1)i=e.changes.invertedDesc,r=xe.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=k.create(t,r,e.selection&&e.selection.map(i),O.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(Ze);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof k?i:Array.isArray(i)&&i.length==1&&i[0]instanceof k?i[0]:ot(t,ut(i),!1)}return e}function ct(e){let t=e.startState,n=t.facet(Qe),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=it(r,at(t,a,e.changes.newLength),!0))}return r==e?e:k.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var lt=[];function ut(e){return e==null?lt:Array.isArray(e)?e:[e]}var dt=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(dt||={}),ft=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,pt;try{pt=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function mt(e){if(pt)return pt.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>``&&(n.toUpperCase()!=n.toLowerCase()||ft.test(n)))return!0}return!1}function ht(e){return t=>{if(!/\S/.test(t))return dt.Space;if(mt(t))return dt.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return dt.Word;return dt.Other}}var A=class e{constructor(e,t,n,r,i,a){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,a&&(a._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)Ge(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw RangeError(`Field is not present in this state`);return}return Ge(this,n),Ke(this,n)}update(...e){return ot(this,e,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let e of t.effects)e.is(Ve.reconfigure)?(n&&=(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),null),i.set(e.value.compartment,e.value.extension)):e.is(O.reconfigure)?(n=null,r=e.value):e.is(O.appendConfig)&&(n=null,r=ut(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=Ue.resolve(r,i,this),a=new e(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values);let o=t.startState.facet(Je)?t.newSelection:t.newSelection.asSingle();new e(n,t.newDoc,o,a,(e,n)=>n.update(e,t),t)}replaceSelection(e){return typeof e==`string`&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:E.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],a=ut(n.effects);for(let n=1;n<t.ranges.length;n++){let o=e(t.ranges[n]),s=this.changes(o.changes),c=s.map(r);for(let e=0;e<n;e++)i[e]=i[e].map(c);let l=r.mapDesc(s,!0);i.push(o.range.map(l)),r=r.compose(c),a=O.mapEffects(a,c).concat(O.mapEffects(ut(o.effects),l))}return{changes:r,selection:E.create(i,t.mainIndex),effects:a}}changes(t=[]){return t instanceof xe?t:xe.of(t,this.doc.length,this.facet(e.lineSeparator))}toText(t){return S.of(t.split(this.facet(e.lineSeparator)||ve))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Ge(this,t),Ke(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof Ie&&this.config.address[r.id]!=null&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(t,n={},r){if(!t||typeof t.doc!=`string`)throw RangeError(`Invalid JSON representation for EditorState`);let i=[];if(r){for(let e in r)if(Object.prototype.hasOwnProperty.call(t,e)){let n=r[e],a=t[e];i.push(n.init(e=>n.spec.fromJSON(a,e)))}}return e.create({doc:t.doc,selection:E.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=Ue.resolve(t.extensions||[],new Map),r=t.doc instanceof S?t.doc:S.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||ve)),i=t.selection?t.selection instanceof E?t.selection:E.single(t.selection.anchor,t.selection.head):E.single(0);return Oe(i,r.length),n.staticFacet(Je)||(i=i.asSingle()),new e(n,r,i,n.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(e.tabSize)}get lineBreak(){return this.facet(e.lineSeparator)||`
|
|
@@ -26,7 +26,7 @@ const e=require("./base-ZuhO2UZd.cjs"),t=require("./decorate-DCJt-2rt.cjs"),n=re
|
|
|
26
26
|
`;this.styleTag.textContent=e;let n=t.head||t;this.styleTag.parentNode!=n&&n.insertBefore(this.styleTag,n.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute(`nonce`)!=e&&this.styleTag.setAttribute(`nonce`,e)}},Ut={8:`Backspace`,9:`Tab`,10:`Enter`,12:`NumLock`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,44:`PrintScreen`,45:`Insert`,46:`Delete`,59:`;`,61:`=`,91:`Meta`,92:`Meta`,106:`*`,107:`+`,108:`,`,109:`-`,110:`.`,111:`/`,144:`NumLock`,145:`ScrollLock`,160:`Shift`,161:`Shift`,162:`Control`,163:`Control`,164:`Alt`,165:`Alt`,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},Wt={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},Gt=typeof navigator<`u`&&/Mac/.test(navigator.platform),Kt=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),M=0;M<10;M++)Ut[48+M]=Ut[96+M]=String(M);for(var M=1;M<=24;M++)Ut[M+111]=`F`+M;for(var M=65;M<=90;M++)Ut[M]=String.fromCharCode(M+32),Wt[M]=String.fromCharCode(M);for(var qt in Ut)Wt.hasOwnProperty(qt)||(Wt[qt]=Ut[qt]);function Jt(e){var t=!(Gt&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Kt&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?Wt:Ut)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}var N=typeof navigator<`u`?navigator:{userAgent:``,vendor:``,platform:``},Yt=typeof document<`u`?document:{documentElement:{style:{}}},Xt=/Edge\/(\d+)/.exec(N.userAgent),Zt=/MSIE \d/.test(N.userAgent),Qt=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(N.userAgent),$t=!!(Zt||Qt||Xt),en=!$t&&/gecko\/(\d+)/i.test(N.userAgent),tn=!$t&&/Chrome\/(\d+)/.exec(N.userAgent),nn=`webkitFontSmoothing`in Yt.documentElement.style,rn=!$t&&/Apple Computer/.test(N.vendor),an=rn&&(/Mobile\/\w+/.test(N.userAgent)||N.maxTouchPoints>2),P={mac:an||/Mac/.test(N.platform),windows:/Win/.test(N.platform),linux:/Linux|X11/.test(N.platform),ie:$t,ie_version:Zt?Yt.documentMode||6:Qt?+Qt[1]:Xt?+Xt[1]:0,gecko:en,gecko_version:en?+(/Firefox\/(\d+)/.exec(N.userAgent)||[0,0])[1]:0,chrome:!!tn,chrome_version:tn?+tn[1]:0,ios:an,android:/Android\b/.test(N.userAgent),webkit:nn,webkit_version:nn?+(/\bAppleWebKit\/(\d+)/.exec(N.userAgent)||[0,0])[1]:0,safari:rn,safari_version:rn?+(/\bVersion\/(\d+(\.\d+)?)/.exec(N.userAgent)||[0,0])[1]:0,tabSize:Yt.documentElement.style.tabSize==null?`-moz-tab-size`:`tab-size`};function on(e,t){for(let n in e)n==`class`&&t.class?t.class+=` `+e.class:n==`style`&&t.style?t.style+=`;`+e.style:t[n]=e[n];return t}var sn=Object.create(null);function cn(e,t,n){if(e==t)return!0;e||=sn,t||=sn;let r=Object.keys(e),i=Object.keys(t);if(r.length-(n&&r.indexOf(n)>-1?1:0)!=i.length-(n&&i.indexOf(n)>-1?1:0))return!1;for(let a of r)if(a!=n&&(i.indexOf(a)==-1||e[a]!==t[a]))return!1;return!0}function ln(e,t){for(let n=e.attributes.length-1;n>=0;n--){let r=e.attributes[n].name;t[r]??e.removeAttribute(r)}for(let n in t){let r=t[n];n==`style`?e.style.cssText=r:e.getAttribute(n)!=r&&e.setAttribute(n,r)}}function un(e,t,n){let r=!1;if(t)for(let i in t)n&&i in n||(r=!0,i==`style`?e.style.cssText=``:e.removeAttribute(i));if(n)for(let i in n)t&&t[i]==n[i]||(r=!0,i==`style`?e.style.cssText=n[i]:e.setAttribute(i,n[i]));return r}function dn(e){let t=Object.create(null);for(let n=0;n<e.attributes.length;n++){let r=e.attributes[n];t[r.name]=r.value}return t}var fn=class{eq(e){return!1}updateDOM(e,t,n){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}},F=(function(e){return e[e.Text=0]=`Text`,e[e.WidgetBefore=1]=`WidgetBefore`,e[e.WidgetAfter=2]=`WidgetAfter`,e[e.WidgetRange=3]=`WidgetRange`,e})(F||={}),I=class extends _t{constructor(e,t,n,r){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=r}get heightRelevant(){return!1}static mark(e){return new pn(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new hn(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,r;if(e.isBlockGap)n=-5e8,r=4e8;else{let{start:i,end:a}=gn(e,t);n=(i?t?-3e8:-1:5e8)-1,r=(a?t?2e8:1:-6e8)+1}return new hn(e,n,r,t,e.widget||null,!0)}static line(e){return new mn(e)}static set(e,t=!1){return j.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};I.none=j.empty;var pn=class e extends I{constructor(e){let{start:t,end:n}=gn(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||`span`,this.attrs=e.class&&e.attributes?on(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||sn}eq(t){return this==t||t instanceof e&&this.tagName==t.tagName&&cn(this.attrs,t.attrs)}range(e,t=e){if(e>=t)throw RangeError(`Mark decorations may not be empty`);return super.range(e,t)}};pn.prototype.point=!1;var mn=class e extends I{constructor(e){super(-2e8,-2e8,null,e)}eq(t){return t instanceof e&&this.spec.class==t.spec.class&&cn(this.spec.attributes,t.spec.attributes)}range(e,t=e){if(t!=e)throw RangeError(`Line decoration ranges must be zero-length`);return super.range(e,t)}};mn.prototype.mapMode=ye.TrackBefore,mn.prototype.point=!0;var hn=class e extends I{constructor(e,t,n,r,i,a){super(t,n,i,e),this.block=r,this.isReplace=a,this.mapMode=r?t<=0?ye.TrackBefore:ye.TrackAfter:ye.TrackDel}get type(){return this.startSide==this.endSide?this.startSide<=0?F.WidgetBefore:F.WidgetAfter:F.WidgetRange}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof e&&_n(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw RangeError(`Invalid range for replacement decoration`);if(!this.isReplace&&t!=e)throw RangeError(`Widget decorations can only have zero-length ranges`);return super.range(e,t)}};hn.prototype.point=!0;function gn(e,t=!1){let{inclusiveStart:n,inclusiveEnd:r}=e;return n??=e.inclusive,r??=e.inclusive,{start:n??t,end:r??t}}function _n(e,t){return e==t||!!(e&&t&&e.compare(t))}function vn(e,t,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=e?n[i]=Math.max(n[i],t):n.push(e,t)}var yn=class e extends _t{constructor(e,t,n){super(),this.tagName=e,this.attributes=t,this.rank=n}eq(t){return t==this||t instanceof e&&this.tagName==t.tagName&&cn(this.attributes,t.attributes)}static create(t){return new e(t.tagName,t.attributes||sn,t.rank==null?50:Math.max(0,Math.min(t.rank,100)))}static set(e,t=!1){return j.of(e,t)}};yn.prototype.startSide=yn.prototype.endSide=-1;function bn(e){let t;return t=e.nodeType==11?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function xn(e,t){return t?e==t||e.contains(t.nodeType==1?t:t.parentNode):!1}function Sn(e,t){if(!t.anchorNode)return!1;try{return xn(e,t.anchorNode)}catch{return!1}}function Cn(e){return e.nodeType==3?Rn(e,0,e.nodeValue.length).getClientRects():e.nodeType==1?e.getClientRects():[]}function wn(e,t,n,r){return n?Dn(e,t,n,r,-1)||Dn(e,t,n,r,1):!1}function Tn(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t}function En(e){return e.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function Dn(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:On(e))){if(e.nodeName==`DIV`)return!1;let n=e.parentNode;if(!n||n.nodeType!=1)return!1;t=Tn(e)+(i<0?0:1),e=n}else if(e.nodeType==1){if(e=e.childNodes[t+(i<0?-1:0)],e.nodeType==1&&e.contentEditable==`false`)return!1;t=i<0?On(e):0}else return!1}}function On(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function kn(e,t){let n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function An(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function jn(e,t){let n=t.width/e.offsetWidth,r=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(t.height-e.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function Mn(e,t,n,r,i,a,o,s){let c=e.ownerDocument,l=c.defaultView||window;for(let u=e,d=!1;u&&!d;)if(u.nodeType==1){let e,f=u==c.body,p=1,m=1;if(f)e=An(l);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(d=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let t=u.getBoundingClientRect();({scaleX:p,scaleY:m}=jn(u,t)),e={left:t.left,right:t.left+u.clientWidth*p,top:t.top,bottom:t.top+u.clientHeight*m}}let h=0,g=0;if(i==`nearest`)t.top<e.top+o?(g=t.top-(e.top+o),n>0&&t.bottom>e.bottom+g&&(g=t.bottom-e.bottom+o)):t.bottom>e.bottom-o&&(g=t.bottom-e.bottom+o,n<0&&t.top-g<e.top&&(g=t.top-(e.top+o)));else{let r=t.bottom-t.top,a=e.bottom-e.top;g=(i==`center`&&r<=a?t.top+r/2-a/2:i==`start`||i==`center`&&n<0?t.top-o:t.bottom-a+o)-e.top}if(r==`nearest`?t.left<e.left+a?(h=t.left-(e.left+a),n>0&&t.right>e.right+h&&(h=t.right-e.right+a)):t.right>e.right-a&&(h=t.right-e.right+a,n<0&&t.left<e.left+h&&(h=t.left-(e.left+a))):h=(r==`center`?t.left+(t.right-t.left)/2-(e.right-e.left)/2:r==`start`==s?t.left-a:t.right-(e.right-e.left)+a)-e.left,h||g)if(f)l.scrollBy(h,g);else{let e=0,n=0;if(g){let e=u.scrollTop;u.scrollTop+=g/m,n=(u.scrollTop-e)*m}if(h){let t=u.scrollLeft;u.scrollLeft+=h/p,e=(u.scrollLeft-t)*p}t={left:t.left-e,top:t.top-n,right:t.right-e,bottom:t.bottom-n},e&&Math.abs(e-h)<1&&(r=`nearest`),n&&Math.abs(n-g)<1&&(i=`nearest`)}if(f)break;(t.top<e.top||t.bottom>e.bottom||t.left<e.left||t.right>e.right)&&(t={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}),u=u.assignedSlot||u.parentNode}else if(u.nodeType==11)u=u.host;else break}function Nn(e,t=!0){let n=e.ownerDocument,r=null,i=null;for(let a=e.parentNode;a&&!(a==n.body||(!t||r)&&i);)if(a.nodeType==1)!i&&a.scrollHeight>a.clientHeight&&(i=a),t&&!r&&a.scrollWidth>a.clientWidth&&(r=a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;return{x:r,y:i}}var Pn=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?On(t):0),n,Math.min(e.focusOffset,n?On(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}},Fn=null;P.safari&&P.safari_version>=26&&(Fn=!1);function In(e){if(e.setActive)return e.setActive();if(Fn)return e.focus(Fn);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(Fn==null?{get preventScroll(){return Fn={preventScroll:!0},!0}}:void 0),!Fn){Fn=!1;for(let e=0;e<t.length;){let n=t[e++],r=t[e++],i=t[e++];n.scrollTop!=r&&(n.scrollTop=r),n.scrollLeft!=i&&(n.scrollLeft=i)}}}var Ln;function Rn(e,t,n=t){let r=Ln||=document.createRange();return r.setEnd(e,n),r.setStart(e,t),r}function zn(e,t,n,r){let i={key:t,code:t,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let a=new KeyboardEvent(`keydown`,i);a.synthetic=!0,e.dispatchEvent(a);let o=new KeyboardEvent(`keyup`,i);return o.synthetic=!0,e.dispatchEvent(o),a.defaultPrevented||o.defaultPrevented}function Bn(e){for(;e;){if(e&&(e.nodeType==9||e.nodeType==11&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}function Vn(e,t){let n=t.focusNode,r=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=r)return!1;for(r=Math.min(r,On(n));;)if(r){if(n.nodeType!=1)return!1;let e=n.childNodes[r-1];e.contentEditable==`false`?r--:(n=e,r=On(n))}else if(n==e)return!0;else r=Tn(n),n=n.parentNode}function Hn(e){return e instanceof Window?e.pageYOffset>Math.max(0,e.document.documentElement.scrollHeight-e.innerHeight-4):e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function Un(e,t){for(let n=e,r=t;;)if(n.nodeType==3&&r>0)return{node:n,offset:r};else if(n.nodeType==1&&r>0){if(n.contentEditable==`false`)return null;n=n.childNodes[r-1],r=On(n)}else if(n.parentNode&&!En(n))r=Tn(n),n=n.parentNode;else return null}function Wn(e,t){for(let n=e,r=t;;)if(n.nodeType==3&&r<n.nodeValue.length)return{node:n,offset:r};else if(n.nodeType==1&&r<n.childNodes.length){if(n.contentEditable==`false`)return null;n=n.childNodes[r],r=0}else if(n.parentNode&&!En(n))r=Tn(n)+1,n=n.parentNode;else return null}var Gn=class e{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(t,n){return new e(t.parentNode,Tn(t),n)}static after(t,n){return new e(t.parentNode,Tn(t)+1,n)}},L=(function(e){return e[e.LTR=0]=`LTR`,e[e.RTL=1]=`RTL`,e})(L||={}),Kn=L.LTR,qn=L.RTL;function Jn(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<e[n]);return t}var Yn=Jn(`88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008`),Xn=Jn(`4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333`),Zn=Object.create(null),Qn=[];for(let e of[`()`,`[]`,`{}`]){let t=e.charCodeAt(0),n=e.charCodeAt(1);Zn[t]=n,Zn[n]=-t}function $n(e){return e<=247?Yn[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?Xn[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}var er=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,tr=class{get dir(){return this.level%2?qn:Kn}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,r){let i=-1;for(let a=0;a<e.length;a++){let o=e[a];if(o.from<=t&&o.to>=t){if(o.level==n)return a;(i<0||(r==0?e[i].level>o.level:r<0?o.from<t:o.to>t))&&(i=a)}}if(i<0)throw RangeError(`Index out of range`);return i}};function nr(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.direction!=i.direction||!nr(r.inner,i.inner))return!1}return!0}var R=[];function rr(e,t,n,r,i){for(let a=0;a<=r.length;a++){let o=a?r[a-1].to:t,s=a<r.length?r[a].from:n,c=a?256:i;for(let t=o,n=c,r=c;t<s;t++){let i=$n(e.charCodeAt(t));i==512?i=n:i==8&&r==4&&(i=16),R[t]=i==4?2:i,i&7&&(r=i),n=i}for(let e=o,t=c,r=c;e<s;e++){let i=R[e];if(i==128)e<s-1&&t==R[e+1]&&t&24?i=R[e]=t:R[e]=256;else if(i==64){let i=e+1;for(;i<s&&R[i]==64;)i++;let a=e&&t==8||i<n&&R[i]==8?r==1?1:8:256;for(let t=e;t<i;t++)R[t]=a;e=i-1}else i==8&&r==1&&(R[e]=1);t=i,i&7&&(r=i)}}}function ir(e,t,n,r,i){let a=i==1?2:1;for(let o=0,s=0,c=0;o<=r.length;o++){let l=o?r[o-1].to:t,u=o<r.length?r[o].from:n;for(let t=l,n,r,o;t<u;t++)if(r=Zn[n=e.charCodeAt(t)])if(r<0){for(let e=s-3;e>=0;e-=3)if(Qn[e+1]==-r){let n=Qn[e+2],r=n&2?i:n&4?n&1?a:i:0;r&&(R[t]=R[Qn[e]]=r),s=e;break}}else if(Qn.length==189)break;else Qn[s++]=t,Qn[s++]=n,Qn[s++]=c;else if((o=R[t])==2||o==1){let e=o==i;c=+!e;for(let t=s-3;t>=0;t-=3){let n=Qn[t+2];if(n&2)break;if(e)Qn[t+2]|=2;else{if(n&4)break;Qn[t+2]|=4}}}}}function ar(e,t,n,r){for(let i=0,a=r;i<=n.length;i++){let o=i?n[i-1].to:e,s=i<n.length?n[i].from:t;for(let c=o;c<s;){let o=R[c];if(o==256){let o=c+1;for(;;)if(o==s){if(i==n.length)break;o=n[i++].to,s=i<n.length?n[i].from:t}else if(R[o]==256)o++;else break;let l=a==1,u=l==((o<t?R[o]:r)==1)?l?1:2:r;for(let t=o,r=i,a=r?n[r-1].to:e;t>c;)t==a&&(t=n[--r].from,a=r?n[r-1].to:e),R[--t]=u;c=o}else a=o,c++}}}function or(e,t,n,r,i,a,o){let s=r%2?2:1;if(r%2==i%2)for(let c=t,l=0;c<n;){let t=!0,u=!1;if(l==a.length||c<a[l].from){let e=R[c];e!=s&&(t=!1,u=e==16)}let d=!t&&s==1?[]:null,f=t?r:r+1,p=c;run:for(;;)if(l<a.length&&p==a[l].from){if(u)break run;let m=a[l];if(!t)for(let e=m.to,t=l+1;;){if(e==n)break run;if(t<a.length&&a[t].from==e)e=a[t++].to;else if(R[e]==s)break run;else break}l++,d?d.push(m):(m.from>c&&o.push(new tr(c,m.from,f)),sr(e,m.direction==Kn==!(f%2)?r:r+1,i,m.inner,m.from,m.to,o),c=m.to),p=m.to}else if(p==n||(t?R[p]!=s:R[p]==s))break;else p++;d?or(e,c,p,r+1,i,d,o):c<p&&o.push(new tr(c,p,f)),c=p}else for(let c=n,l=a.length;c>t;){let n=!0,u=!1;if(!l||c>a[l-1].to){let e=R[c-1];e!=s&&(n=!1,u=e==16)}let d=!n&&s==1?[]:null,f=n?r:r+1,p=c;run:for(;;)if(l&&p==a[l-1].to){if(u)break run;let m=a[--l];if(!n)for(let e=m.from,n=l;;){if(e==t)break run;if(n&&a[n-1].to==e)e=a[--n].from;else if(R[e-1]==s)break run;else break}d?d.push(m):(m.to<c&&o.push(new tr(m.to,c,f)),sr(e,m.direction==Kn==!(f%2)?r:r+1,i,m.inner,m.from,m.to,o),c=m.from),p=m.from}else if(p==t||(n?R[p-1]!=s:R[p-1]==s))break;else p--;d?or(e,p,c,r+1,i,d,o):p<c&&o.push(new tr(p,c,f)),c=p}}function sr(e,t,n,r,i,a,o){let s=t%2?2:1;rr(e,i,a,r,s),ir(e,i,a,r,s),ar(i,a,r,s),or(e,i,a,t,n,r,o)}function cr(e,t,n){if(!e)return[new tr(0,0,+(t==qn))];if(t==Kn&&!n.length&&!er.test(e))return lr(e.length);if(n.length)for(;e.length>R.length;)R[R.length]=256;let r=[],i=t==Kn?0:1;return sr(e,i,i,n,0,e.length,r),r}function lr(e){return[new tr(0,e,0)]}var ur=``;function dr(e,t,n,r,i){let a=r.head-e.from,o=tr.find(t,a,r.bidiLevel??-1,r.assoc),s=t[o],c=s.side(i,n);if(a==c){let e=o+=i?1:-1;if(e<0||e>=t.length)return null;s=t[o=e],a=s.side(!i,n),c=s.side(i,n)}let l=w(e.text,a,s.forward(i,n));(l<s.from||l>s.to)&&(l=c),ur=e.text.slice(Math.min(a,l),Math.max(a,l));let u=o==(i?t.length-1:0)?null:t[o+(i?1:-1)];return u&&l==c&&u.level+ +!i<s.level?E.cursor(u.side(!i,n)+e.from,u.forward(i,n)?1:-1,u.level):E.cursor(l+e.from,s.forward(i,n)?-1:1,s.level)}function fr(e,t,n){for(let r=t;r<n;r++){let t=$n(e.charCodeAt(r));if(t==1)return Kn;if(t==2||t==4)return qn}return Kn}var pr=D.define(),mr=D.define(),hr=D.define(),gr=D.define(),_r=D.define(),vr=D.define(),yr=D.define(),br=D.define(),xr=D.define(),Sr=D.define({combine:e=>e.some(e=>e)}),Cr=D.define({combine:e=>e.some(e=>e)}),wr=D.define(),Tr=class e{constructor(e,t,n,r,i,a=!1){this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=i,this.isSnapshot=a}map(t){return t.empty?this:new e(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new e(E.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},Er=O.define({map:(e,t)=>e.map(t)}),Dr=O.define();function z(e,t,n){let r=e.facet(gr);r.length?r[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)||(n?console.error(n+`:`,t):console.error(t))}var Or=D.define({combine:e=>e.length?e[0]:!0}),kr=0,Ar=D.define({combine(e){return e.filter((t,n)=>{for(let r=0;r<n;r++)if(e[r].plugin==t.plugin)return!1;return!0})}}),jr=class e{constructor(e,t,n,r,i){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=r,this.baseExtensions=i(this),this.extension=this.baseExtensions.concat(Ar.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(Ar.of({plugin:this,arg:e}))}static define(t,n){let{eventHandlers:r,eventObservers:i,provide:a,decorations:o}=n||{};return new e(kr++,t,r,i,e=>{let t=[];return o&&t.push(Fr.of(t=>{let n=t.plugin(e);return n?o(n):I.none})),a&&t.push(a(e)),t})}static fromClass(t,n){return e.define((e,n)=>new t(e,n),n)}},Mr=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(!this.value){if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){z(e.state,t,`CodeMirror plugin crashed`),this.deactivate()}}else if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(z(e.state,t,`CodeMirror plugin crashed`),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}return this}destroy(e){if(this.value?.destroy)try{this.value.destroy()}catch(t){z(e.state,t,`CodeMirror plugin crashed`)}}deactivate(){this.spec=this.value=null}},Nr=D.define(),Pr=D.define(),Fr=D.define(),Ir=D.define(),Lr=D.define(),Rr=D.define(),zr=D.define();function Br(e,t){let n=e.state.facet(zr);if(!n.length)return n;let r=n.map(t=>t instanceof Function?t(e):t),i=[];return j.spans(r,t.from,t.to,{point(){},span(e,n,r,a){let o=e-t.from,s=n-t.from,c=i;for(let e=r.length-1;e>=0;e--,a--){let n=r[e].spec.bidiIsolate,i;if(n??=fr(t.text,o,s),a>0&&c.length&&(i=c[c.length-1]).to==o&&i.direction==n)i.to=s,c=i.inner;else{let e={from:o,to:s,direction:n,inner:[]};c.push(e),c=e.inner}}}}),i}var Vr=D.define();function Hr(e){let t=0,n=0,r=0,i=0;for(let a of e.state.facet(Vr)){let o=a(e);o&&(o.left!=null&&(t=Math.max(t,o.left)),o.right!=null&&(n=Math.max(n,o.right)),o.top!=null&&(r=Math.max(r,o.top)),o.bottom!=null&&(i=Math.max(i,o.bottom)))}return{left:t,right:n,top:r,bottom:i}}var Ur=D.define(),Wr=class e{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}join(t){return new e(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>n.toA)){if(r.toA<n.fromA)break;n=n.join(r),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(t,n){if(n.length==0)return t;let r=[];for(let i=0,a=0,o=0;;){let s=i<t.length?t[i].fromB:1e9,c=a<n.length?n[a]:1e9,l=Math.min(s,c);if(l==1e9)break;let u=l+o,d=l,f=u;for(;;)if(a<n.length&&n[a]<=d){let e=n[a+1];a+=2,d=Math.max(d,e);for(let e=i;e<t.length&&t[e].fromB<=d;e++)o=t[e].toA-t[e].toB;f=Math.max(f,e+o)}else if(i<t.length&&t[i].fromB<=d){let e=t[i++];d=Math.max(d,e.toB),f=Math.max(f,e.toA),o=e.toA-e.toB}else break;r.push(new e(u,f,l,d))}return r}},Gr=class e{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=xe.empty(this.startState.doc.length);for(let e of n)this.changes=this.changes.compose(e.changes);let r=[];this.changes.iterChangedRanges((e,t,n,i)=>r.push(new Wr(e,t,n,i))),this.changedRanges=r}static create(t,n,r){return new e(t,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},Kr=[],B=class{constructor(e,t,n=0){this.dom=e,this.length=t,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return Kr}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let e=this.domAttrs;e&&ln(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:``)+(this.breakAfter?`#`:``)}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let n=t;for(let t of this.children){if(t==e)return n;n+=t.length+t.breakAfter}throw RangeError(`Invalid child in posBefore`)}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t){return null}domPosFor(e,t){let n=Tn(this.dom),r=this.length?e>0:t>0;return new Gn(this.parent.dom,n+ +!!r,e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof Yr)return e;return null}static get(e){return e.cmTile}},qr=class extends B{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,n=null,r,i=e?.node==t?e:null,a=0;for(let o of this.children){if(o.sync(e),a+=o.length+o.breakAfter,r=n?n.nextSibling:t.firstChild,i&&r!=o.dom&&(i.written=!0),o.dom.parentNode==t)for(;r&&r!=o.dom;)r=Jr(r);else t.insertBefore(o.dom,r);n=o.dom}for(r=n?n.nextSibling:t.firstChild,i&&r&&(i.written=!0);r;)r=Jr(r);this.length=a}};function Jr(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var Yr=class extends qr{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=B.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,r=0,i=0;;)if(r==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&i++,r=t.pop()}else{let a=n.children[r++];if(a instanceof Xr)t.push(r),n=a,r=0;else{let t=i+a.length,n=e(a,i);if(n!==void 0)return n;i=t+a.breakAfter}}}resolveBlock(e,t){let n,r=-1,i,a=-1;if(this.blockTiles((o,s)=>{let c=s+o.length;if(e>=s&&e<=c){if(o.isWidget()&&t>=-1&&t<=1){if(o.flags&32)return!0;o.flags&16&&(n=void 0)}(s<e||e==c&&(t<-1?o.length:o.covers(1)))&&(!n||!o.isWidget()&&n.isWidget())&&(n=o,r=e-s),(c>e||e==s&&(t>1?o.length:o.covers(-1)))&&(!i||!o.isWidget()&&i.isWidget())&&(i=o,a=e-s)}}),!n&&!i)throw Error(`No tile at position `+e);return n&&t<0||!i?{tile:n,offset:r}:{tile:i,offset:a}}},Xr=class e extends qr{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(t,n){let r=new e(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},Zr=class e extends qr{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(t,n,r){let i=new e(n||document.createElement(`div`),t);return(!n||!r)&&(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,t,n){let r=null,i=-1,a=null,o=-1;function s(e,c){for(let l=0,u=0;l<e.children.length&&u<=c;l++){let d=e.children[l],f=u+d.length;f>=c&&(d.isComposite()?s(d,c-u):(!a||a.isHidden&&(t>0||n&&$r(a,d)))&&(f>c||d.flags&32)?(a=d,o=c-u):(u<c||d.flags&16&&!d.isHidden)&&(r=d,i=c-u)),u=f}}s(this,e);let c=(t<0?r:a)||r||a;return c?{tile:c,offset:c==r?i:o}:null}coordsIn(e,t){let n=this.resolveInline(e,t,!0);return n?n.tile.coordsIn(Math.max(0,n.offset),t):Qr(this)}domIn(e,t){let n=this.resolveInline(e,t);if(n){let{tile:e,offset:r}=n;if(this.dom.contains(e.dom))return e.isText()?new Gn(e.dom,Math.min(e.dom.nodeValue.length,r)):e.domPosFor(r,e.flags&16?1:e.flags&32?-1:t);let i=n.tile.parent,a=!1;for(let e of i.children){if(a)return new Gn(e.dom,0);e==n.tile&&(a=!0)}}return new Gn(this.dom,0)}};function Qr(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=Cn(t);return n[n.length-1]||null}function $r(e,t){let n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.top<n.bottom}var V=class e extends qr{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(t,n){let r=new e(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},ei=class e extends B{constructor(e,t){super(e,t.length),this.text=t}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t){let n=this.dom.nodeValue.length;e>n&&(e=n);let r=e,i=e,a=0;e==0&&t<0||e==n&&t>=0?P.chrome||P.gecko||(e?(r--,a=1):i<n&&(i++,a=-1)):t<0?r--:i<n&&i++;let o=Rn(this.dom,r,i).getClientRects();if(!o.length)return null;let s=o[(a?a<0:t>=0)?0:o.length-1];return P.safari&&!a&&s.width==0&&(s=Array.prototype.find.call(o,e=>e.width)||s),a?kn(s,a<0):s||null}static of(t,n){let r=new e(n||document.createTextNode(t),t);return n||(r.flags|=2),r}},ti=class e extends B{constructor(e,t,n,r){super(e,t,r),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,n){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(n)return kn(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let t=this.dom.getClientRects(),n=null;if(!t.length)return null;let r=this.flags&16?!0:this.flags&32?!1:e>0;for(let i=r?t.length-1:0;n=t[i],!(e>0?i==0:i==t.length-1||n.top<n.bottom);i+=r?-1:1);return kn(n,!r)}}get overrideDOMText(){if(!this.length)return S.empty;let{root:e}=this;if(!e)return S.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(t,n,r,i,a){return a||(a=t.toDOM(n),t.editable||(a.contentEditable=`false`)),new e(a,r,t,i)}},ni=class extends B{constructor(e){let t=document.createElement(`img`);t.className=`cm-widgetBuffer`,t.setAttribute(`aria-hidden`,`true`),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return S.empty}coordsIn(e){return this.dom.getBoundingClientRect()}},ri=class{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:r,index:i,beforeBreak:a,parents:o}=this;for(;e||t>0;)if(!r.isComposite())if(i==r.length)a=!!r.breakAfter,{tile:r,index:i}=o.pop(),i++;else if(e){let t=Math.min(e,r.length-i);n&&n.skip(r,i,i+t),e-=t,i+=t}else break;else if(a){if(!e)break;n&&n.break(),e--,a=!1}else if(i==r.children.length){if(!e&&!o.length)break;n&&n.leave(r),a=!!r.breakAfter,{tile:r,index:i}=o.pop(),i++}else{let s=r.children[i],c=s.breakAfter;(t>0?s.length<=e:s.length<e)&&(!n||n.skip(s,0,s.length)!==!1||!s.isComposite)?(a=!!c,i++,e-=s.length):(o.push({tile:r,index:i}),r=s,i=0,n&&s.isComposite()&&n.enter(s))}return this.tile=r,this.index=i,this.beforeBreak=a,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}},ii=class{constructor(e,t,n,r){this.from=e,this.to=t,this.wrapper=n,this.rank=r}},ai=class{constructor(e,t,n){this.cache=e,this.root=t,this.blockWrappers=n,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,n,r){this.flushBuffer();let i=this.ensureMarks(t,n),a=i.lastChild;if(a&&a.isText()&&!(a.flags&8)&&a.length+e.length<512){this.cache.reused.set(a,2);let t=i.children[i.children.length-1]=new ei(a.dom,a.text+e);t.parent=i}else i.append(r||ei.of(e,this.cache.find(ei)?.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let n=this.curLine;n.dom!=t.line.dom&&(n.setDOM(this.cache.reused.has(t.line)?hi(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let r=n;for(let e=t.marks.length-1;e>=0;e--){let n=t.marks[e],i=r.lastChild;if(i instanceof V&&i.mark.eq(n.mark))i.dom!=n.dom&&i.setDOM(hi(n.dom)),r=i;else{if(this.cache.reused.get(n)){let e=B.get(n.dom);e&&e.setDOM(hi(n.dom))}let e=V.of(n.mark,n.dom);r.append(e),r=e}this.cache.reused.set(n,2)}let i=B.get(e.text);i&&this.cache.reused.set(i,2);let a=new ei(e.text,e.text.nodeValue);a.flags|=8,this.pos=e.range.toB,r.append(a)}addInlineWidget(e,t,n){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let i=this.ensureMarks(t,n);!r&&!(e.flags&16)&&i.append(this.getBuffer(1)),i.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){e||=fi;let n=Zr.start(e,t||this.cache.find(Zr)?.dom,!!t);this.getBlockPos().append(this.lastBlock=this.curLine=n)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){let n=this.curLine;for(let r=e.length-1;r>=0;r--){let i=e[r],a;if(t>0&&(a=n.lastChild)&&a instanceof V&&a.mark.eq(i))n=a,t--;else{let e=V.of(i,this.cache.find(V,e=>e.mark.eq(i))?.dom);n.append(e),n=e,t=0}}return n}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!ui(this.curLine,!1)||e.dom.nodeName!=`BR`&&e.isWidget()&&!(P.ios&&ui(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(_i,0,32)||new ti(_i.toDOM(),0,_i,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=e.rank*102+e.value.rank,n=new ii(e.from,e.to,e.value,t),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-n.rank||this.wrappers[r-1].to-n.to)<0;)r--;this.wrappers.splice(r,0,n)}this.wrapperPos=this.pos}getBlockPos(){this.updateBlockWrappers();let e=this.root;for(let t of this.wrappers){let n=e.lastChild;if(t.from<this.pos&&n instanceof Xr&&n.wrapper.eq(t.wrapper))e=n;else{let n=Xr.of(t.wrapper,this.cache.find(Xr,e=>e.wrapper.eq(t.wrapper))?.dom);e.append(n),e=n}}return e}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),n=this.cache.find(ni,void 0,1);return n&&(n.flags=t),n||new ni(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},oi=class{constructor(e){this.skipCount=0,this.text=``,this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text=``,this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:t,lineBreak:n,done:r}=this.cursor.next(this.skipCount);if(this.skipCount=0,r)throw Error(`Ran out of text content when drawing inline views`);this.text=t;let i=this.textOff=Math.min(e,t.length);return n?null:t.slice(0,i)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}},si=[ti,Zr,ei,V,ni,Xr,Yr];for(let e=0;e<si.length;e++)si[e].bucket=e;var ci=class{constructor(e){this.view=e,this.buckets=si.map(()=>[]),this.index=si.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,n=2){let r=e.bucket,i=this.buckets[r],a=this.index[r];for(let e=i.length-1;e>=0;e--){let o=(e+a)%i.length,s=i[o];if((!t||t(s))&&!this.reused.has(s))return i.splice(o,1),o<a&&this.index[r]--,this.reused.set(s,n),s}return null}findWidget(e,t,n){let r=this.buckets[0];if(r.length)for(let i=0,a=0;;i++){if(i==r.length){if(a)return null;a=1,i=0}let o=r[i];if(!this.reused.has(o)&&(a==0?o.widget.compare(e):o.widget.constructor==e.constructor&&e.updateDOM(o.dom,this.view,o.widget)))return r.splice(i,1),i<this.index[0]&&this.index[0]--,o.widget==e&&o.length==t&&(o.flags&497)==n?(this.reused.set(o,1),o):(this.reused.set(o,2),new ti(o.dom,t,e,o.flags&-498|n))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}},li=class{constructor(e,t,n,r,i){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=i,this.openWidget=!1,this.openMarks=0,this.cache=new ci(e),this.text=new oi(e.state.doc),this.builder=new ai(this.cache,new Yr(e,e.contentDOM),j.iter(n)),this.cache.reused.set(t,2),this.old=new ri(t),this.reuseWalker={skip:(e,t,n)=>{if(this.cache.add(e),e.isComposite())return!1},enter:e=>this.cache.add(e),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let r=0,i=0,a=0;;){let o=a<e.length?e[a++]:null,s=o?o.fromA:this.old.root.length;if(s>r){let e=s-r;this.preserve(e,!a,!o),r=s,i+=e}if(!o)break;t&&o.fromA<=t.range.fromA&&o.toA>=t.range.toA?(this.forward(o.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(i,t.range.fromB),this.builder.flushBuffer(),this.cache.clear(),this.builder.addComposition(t,n),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,o.toA),this.emit(t.range.toB,o.toB)):(this.forward(o.fromA,o.toA),this.emit(i,o.toB)),i=o.toB,r=o.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,n){let r=mi(this.old),i=this.openMarks;this.old.advance(e,n?1:-1,{skip:(e,t,n)=>{if(e.isWidget())if(this.openWidget)this.builder.continueWidget(n-t);else{let a=n>0||t<e.length?ti.of(e.widget,this.view,n-t,e.flags&496,this.cache.maybeReuse(e)):this.cache.reuse(e);a.flags&256?(a.flags&=-2,this.builder.addBlockWidget(a)):(this.builder.ensureLine(null),this.builder.addInlineWidget(a,r,i),i=r.length)}else if(e.isText())this.builder.ensureLine(null),!t&&n==e.length&&!this.cache.reused.has(e)?this.builder.addText(e.text,r,i,this.cache.reuse(e)):(this.cache.add(e),this.builder.addText(e.text.slice(t,n),r,i)),i=r.length;else if(e.isLine())e.flags&=-2,this.cache.reused.set(e,1),this.builder.addLine(e);else if(e instanceof ni)this.cache.add(e);else if(e instanceof V)this.builder.ensureLine(null),this.builder.addMark(e,r,i),this.cache.reused.set(e,1),i=r.length;else return!1;this.openWidget=!1},enter:e=>{e.isLine()?this.builder.addLineStart(e.attrs,this.cache.maybeReuse(e)):(this.cache.add(e),e instanceof V&&r.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?r.length&&=i=0:e instanceof V&&(r.shift(),i=Math.min(i,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,r=this.builder,i=0,a=j.spans(this.decorations,e,t,{point:(e,t,a,o,s,c)=>{if(a instanceof hn){if(this.disallowBlockEffectsFor[c]){if(a.block)throw RangeError(`Block decorations may not be specified via plugins`);if(t>this.view.state.doc.lineAt(e).to)throw RangeError(`Decorations that replace line breaks may not be specified via plugins`)}if(i=o.length,s>o.length)r.continueWidget(t-e);else{let i=a.widget||(a.block?gi.block:gi.inline),c=di(a),l=this.cache.findWidget(i,t-e,c)||ti.of(i,this.view,t-e,c);a.block?(a.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(l)):(r.ensureLine(n),r.addInlineWidget(l,o,s))}n=null}else n=pi(n,a);t>e&&this.text.skip(t-e)},span:(e,t,i,a)=>{for(let o=e;o<t;){let s=this.text.next(Math.min(512,t-o));s==null?(r.addLineStartIfNotCovered(n),r.addBreak(),o++):(r.ensureLine(n),r.addText(s,i,o==e?a:i.length),o+=s.length),n=null}}});r.addLineStartIfNotCovered(n),this.openWidget=a>i,this.openMarks=a}forward(e,t,n=1){t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let t=[],n=null;for(let r=e.parentNode;;r=r.parentNode){let e=B.get(r);if(r==this.view.contentDOM)break;e instanceof V?t.push(e):e?.isLine()?n=e:e instanceof Xr||(r.nodeName==`DIV`&&!n&&r!=this.view.contentDOM?n=new Zr(r,fi):n||t.push(V.of(new pn({tagName:r.nodeName.toLowerCase(),attributes:dn(r)}),r)))}return{line:n,marks:t}}};function ui(e,t){let n=e=>{for(let r of e.children)if((t?r.isText():r.length)||n(r))return!0;return!1};return n(e)}function di(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;return e.block&&(t|=256),t}var fi={class:`cm-line`};function pi(e,t){let n=t.spec.attributes,r=t.spec.class;return!n&&!r?e:(e||={class:`cm-line`},n&&on(n,e),r&&(e.class+=` `+r),e)}function mi(e){let t=[];for(let n=e.parents.length;n>1;n--){let r=n==e.parents.length?e.tile:e.parents[n].tile;r instanceof V&&t.push(r.mark)}return t}function hi(e){let t=B.get(e);return t&&t.setDOM(e.cloneNode()),e}var gi=class extends fn{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}};gi.inline=new gi(`span`),gi.block=new gi(`div`);var _i=new class extends fn{toDOM(){return document.createElement(`br`)}get isHidden(){return!0}get editable(){return!0}},vi=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=I.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Yr(e,e.contentDOM),this.updateInner([new Wr(0,0,0,e.state.doc.length)],null)}update(e){let t=e.changedRanges;this.minWidth>0&&t.length&&(t.every(({fromA:e,toA:t})=>t<this.minWidthFrom||e>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(this.domChanged?.newSel?n=this.domChanged.newSel.head:!ki(e.changes,this.hasComposition)&&!e.selectionSet&&(n=e.state.selection.main.head));let r=n>-1?Si(this.view,e.changes,n):null;if(this.domChanged=null,this.hasComposition){let{from:n,to:r}=this.hasComposition;t=new Wr(n,r,e.changes.mapPos(n,-1),e.changes.mapPos(r,1)).addToSet(t.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(P.ie||P.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let i=this.decorations,a=this.blockWrappers;this.updateDeco();let o=Ti(i,this.decorations,e.changes);o.length&&(t=Wr.extendWithRanges(t,o));let s=Di(a,this.blockWrappers,e.changes);return s.length&&(t=Wr.extendWithRanges(t,s)),r&&!t.some(e=>e.fromA<=r.range.fromA&&e.toA>=r.range.toA)&&(t=r.range.addToSet(t.slice())),this.tile.flags&2&&t.length==0?!1:(this.updateInner(t,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let n=this.tile,r=new li(this.view,n,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&B.get(t.text)&&r.cache.reused.set(B.get(t.text),2),this.tile=r.run(e,t),yi(n,r.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+`px`,this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+`px`:``;let r=P.chrome||P.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||n.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=``});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let e of this.tile.children)e.isWidget()&&e.widget instanceof Ai&&r.push(e.dom);n.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let e of t.effects)e.is(Dr)&&(this.editContextFormatting=e.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:n}=this.tile,r=this.view.root.activeElement,i=r==n,a=!i&&!(this.view.state.facet(Or)||n.tabIndex>-1)&&Sn(n,this.view.observer.selectionRange)&&!(r&&n.contains(r));if(!(i||t||a))return;let o=this.forceSelection;this.forceSelection=!1;let s=this.view.state.selection.main,c,l;if(s.empty?l=c=this.inlineDOMNearPos(s.anchor,s.assoc||1):(l=this.inlineDOMNearPos(s.head,s.head==s.from?1:-1),c=this.inlineDOMNearPos(s.anchor,s.anchor==s.from?1:-1)),P.gecko&&s.empty&&!this.hasComposition&&bi(c)){let e=document.createTextNode(``);this.view.observer.ignore(()=>c.node.insertBefore(e,c.node.childNodes[c.offset]||null)),c=l=new Gn(e,0),o=!0}let u=this.view.observer.selectionRange;(o||!u.focusNode||(!wn(c.node,c.offset,u.anchorNode,u.anchorOffset)||!wn(l.node,l.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,s))&&(this.view.observer.ignore(()=>{P.android&&P.chrome&&n.contains(u.focusNode)&&Oi(u.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let e=bn(this.view.root);if(e)if(s.empty){if(P.gecko){let e=Ci(c.node,c.offset);if(e&&e!=3){let t=(e==1?Un:Wn)(c.node,c.offset);t&&(c=new Gn(t.node,t.offset))}}e.collapse(c.node,c.offset),s.bidiLevel!=null&&e.caretBidiLevel!==void 0&&(e.caretBidiLevel=s.bidiLevel)}else if(e.extend){e.collapse(c.node,c.offset);try{e.extend(l.node,l.offset)}catch{}}else{let t=document.createRange();s.anchor>s.head&&([c,l]=[l,c]),t.setEnd(l.node,l.offset),t.setStart(c.node,c.offset),e.removeAllRanges(),e.addRange(t)}a&&this.view.root.activeElement==n&&(n.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(c,l)),this.impreciseAnchor=c.precise?null:new Gn(u.anchorNode,u.anchorOffset),this.impreciseHead=l.precise?null:new Gn(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&wn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=bn(e.root),{anchorNode:r,anchorOffset:i}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let a=this.lineAt(t.head,t.assoc);if(!a)return;let o=a.posAtStart;if(t.head==o||t.head==o+a.length)return;let s=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!s||!c||s.bottom>c.top)return;let l=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(l.node,l.offset),n.modify(`move`,t.assoc<0?`forward`:`backward`,`lineboundary`),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&n.collapse(r,i)}posFromDOM(e,t){let n=this.tile.nearest(e);if(!n)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=n.posAtStart;if(n.isComposite()){let i;if(e==n.dom)i=n.dom.childNodes[t];else{let r=On(e)==0?0:t==0?-1:1;for(;;){let t=e.parentNode;if(t==n.dom)break;r==0&&t.firstChild!=t.lastChild&&(r=e==t.firstChild?-1:1),e=t}i=r<0?e:e.nextSibling}if(i==n.dom.firstChild)return r;for(;i&&!B.get(i);)i=i.nextSibling;if(!i)return r+n.length;for(let e=0,t=r;;e++){let r=n.children[e];if(r.dom==i)return t;t+=r.length+r.breakAfter}}else if(n.isText())return e==n.dom?r+t:r+(t?n.length:0);else return r}domAtPos(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.domPosFor(e,t):n.domIn(r,t)}inlineDOMNearPos(e,t){let n,r=-1,i=!1,a,o=-1,s=!1;return this.tile.blockTiles((t,c)=>{if(t.isWidget()){if(t.flags&32&&c>=e)return!0;t.flags&16&&(i=!0)}else{let l=c+t.length;if(c<=e&&(n=t,r=e-c,i=l<e),l>=e&&!a&&(a=t,o=e-c,s=c>e),c>e&&a)return!0}}),!n&&!a?this.domAtPos(e,t):(i&&a?n=null:s&&n&&(a=null),n&&t<0||!a?n.domIn(r,t):a.domIn(o,t))}coordsAt(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.widget instanceof Ai?null:n.coordsInWidget(r,t,!0):n.coordsIn(r,t)}lineAt(e,t){let{tile:n}=this.tile.resolveBlock(e,t);return n.isLine()?n:null}coordsForChar(e){let{tile:t,offset:n}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function r(e,t){if(e.isComposite())for(let n of e.children){if(n.length>=t){let e=r(n,t);if(e)return e}if(t-=n.length,t<0)break}else if(e.isText()&&t<e.length){let n=w(e.text,t);if(n==t)return null;let r=Rn(e.dom,t,n).getClientRects();for(let e=0;e<r.length;e++){let t=r[e];if(e==r.length-1||t.top<t.bottom&&t.left<t.right)return t}}return null}return r(t,n)}measureVisibleLineHeights(e){let t=[],{from:n,to:r}=e,i=this.view.contentDOM.clientWidth,a=i>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,s=this.view.textDirection==L.LTR,c=0,l=(e,u,d)=>{for(let f=0;f<e.children.length&&!(u>r);f++){let r=e.children[f],p=u+r.length,m=r.dom.getBoundingClientRect(),{height:h}=m;if(d&&!f&&(c+=m.top-d.top),r instanceof Xr)p>n&&l(r,u,m);else if(u>=n&&(c>0&&t.push(-c),t.push(h+c),c=0,a)){let e=r.dom.lastChild,t=e?Cn(e):[];if(t.length){let e=t[t.length-1],n=s?e.right-m.left:m.right-e.left;n>o&&(o=n,this.minWidth=i,this.minWidthFrom=u,this.minWidthTo=p)}}d&&f==e.children.length-1&&(c+=d.bottom-m.bottom),u=p+r.breakAfter}};return l(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction==`rtl`?L.RTL:L.LTR}measureTextSize(){let e=this.tile.blockTiles(e=>{if(e.isLine()&&e.children.length&&e.length<=20){let t=0,n;for(let r of e.children){if(!r.isText()||/[^ -~]/.test(r.text))return;let e=Cn(r.dom);if(e.length!=1)return;t+=e[0].width,n=e[0].height}if(t)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:t/e.length,textHeight:n}}});if(e)return e;let t=document.createElement(`div`),n,r,i;return t.className=`cm-line`,t.style.width=`99999px`,t.style.position=`absolute`,t.textContent=`abc def ghi jkl mno pqr stu`,this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let e=Cn(t.firstChild)[0];n=t.getBoundingClientRect().height,r=e&&e.width?e.width/27:7,i=e&&e.height?e.height:n,t.remove()}),{lineHeight:n,charWidth:r,textHeight:i}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let i=r==t.viewports.length?null:t.viewports[r],a=i?i.from-1:this.view.state.doc.length;if(a>n){let r=(t.lineBlockAt(a).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(I.replace({widget:new Ai(r),block:!0,inclusive:!0,isBlockGap:!0}).range(n,a))}if(!i)break;n=i.to+1}return I.set(e)}updateDeco(){let e=1,t=this.view.state.facet(Fr).map(t=>(this.dynamicDecorationMap[e++]=typeof t==`function`)?t(this.view):t),n=!1,r=this.view.state.facet(Lr).map((e,t)=>{let r=typeof e==`function`;return r&&(n=!0),r?e(this.view):e});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push(j.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(Ir).map(e=>typeof e==`function`?e(this.view):e)}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=t.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let t of this.view.state.facet(wr))try{if(t(this.view,e.range,e))return!0}catch(e){z(this.view.state,e,`scroll handler`)}let{range:t}=e,n=this.coordsAt(t.head,t.assoc??(t.empty?0:t.head>t.anchor?-1:1)),r;if(!n)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,r.left),top:Math.min(n.top,r.top),right:Math.max(n.right,r.right),bottom:Math.max(n.bottom,r.bottom)});let i=Hr(this.view),a={left:n.left-i.left,top:n.top-i.top,right:n.right+i.right,bottom:n.bottom+i.bottom},{offsetWidth:o,offsetHeight:s}=this.view.scrollDOM;if(Mn(this.view.scrollDOM,a,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,o),-o),Math.max(Math.min(e.yMargin,s),-s),this.view.textDirection==L.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(n.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||n.bottom<window.pageYOffset+window.visualViewport.offsetTop)){let e=this.view.docView.lineAt(t.head,1);e&&e.dom.scrollIntoView({block:`nearest`})}}lineHasWidget(e){let t=e=>e.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){yi(this.tile)}};function yi(e,t){let n=t?.get(e);if(n!=1){n??e.destroy();for(let n of e.children)yi(n,t)}}function bi(e){return e.node.nodeType==1&&e.node.firstChild&&(e.offset==0||e.node.childNodes[e.offset-1].contentEditable==`false`)&&(e.offset==e.node.childNodes.length||e.node.childNodes[e.offset].contentEditable==`false`)}function xi(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let r=Un(n.focusNode,n.focusOffset),i=Wn(n.focusNode,n.focusOffset),a=r||i;if(i&&r&&i.node!=r.node){let t=B.get(i.node);if(!t||t.isText()&&t.text!=i.node.nodeValue)a=i;else if(e.docView.lastCompositionAfterCursor){let e=B.get(r.node);!e||e.isText()&&e.text!=r.node.nodeValue||(a=i)}}if(e.docView.lastCompositionAfterCursor=a!=r,!a)return null;let o=t-a.offset;return{from:o,to:o+a.node.nodeValue.length,node:a.node}}function Si(e,t,n){let r=xi(e,n);if(!r)return null;let{node:i,from:a,to:o}=r,s=i.nodeValue;if(/[\n\r]/.test(s)||e.state.doc.sliceString(r.from,r.to)!=s)return null;let c=t.invertedDesc;return{range:new Wr(c.mapPos(a),c.mapPos(o),a,o),text:i}}function Ci(e,t){return e.nodeType==1?(t&&e.childNodes[t-1].contentEditable==`false`?1:0)|(t<e.childNodes.length&&e.childNodes[t].contentEditable==`false`?2:0):0}var wi=class{constructor(){this.changes=[]}compareRange(e,t){vn(e,t,this.changes)}comparePoint(e,t){vn(e,t,this.changes)}boundChange(e){vn(e,e,this.changes)}};function Ti(e,t,n){let r=new wi;return j.compare(e,t,n,r),r.changes}var Ei=class{constructor(){this.changes=[]}compareRange(e,t){vn(e,t,this.changes)}comparePoint(){}boundChange(e){vn(e,e,this.changes)}};function Di(e,t,n){let r=new Ei;return j.compare(e,t,n,r),r.changes}function Oi(e,t){for(let n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(n.nodeType==1&&n.contentEditable==`false`)return!0;return!1}function ki(e,t){let n=!1;return t&&e.iterChangedRanges((e,r)=>{e<t.to&&r>t.from&&(n=!0)}),n}var Ai=class extends fn{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement(`div`);return e.className=`cm-gap`,this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+`px`,!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}};function ji(e,t,n=1){let r=e.charCategorizer(t),i=e.doc.lineAt(t),a=t-i.from;if(i.length==0)return E.cursor(t);a==0?n=1:a==i.length&&(n=-1);let o=a,s=a;n<0?o=w(i.text,a,!1):s=w(i.text,a);let c=r(i.text.slice(o,s));for(;o>0;){let e=w(i.text,o,!1);if(r(i.text.slice(e,o))!=c)break;o=e}for(;s<i.length;){let e=w(i.text,s);if(r(i.text.slice(s,e))!=c)break;s=e}return E.range(o+i.from,s+i.from)}function Mi(e,t,n,r,i){let a=Math.round((r-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&n.height>e.defaultLineHeight*1.5){let t=e.viewState.heightOracle.textHeight,r=Math.floor((i-n.top-(e.defaultLineHeight-t)*.5)/t);a+=r*e.viewState.heightOracle.lineLength}let o=e.state.sliceDoc(n.from,n.to);return n.from+Ft(o,a,e.state.tabSize)}function Ni(e,t,n){let r=e.lineBlockAt(t);if(Array.isArray(r.type)){let e;for(let i of r.type){if(i.from>t)break;if(!(i.to<t)){if(i.from<t&&i.to>t)return i;(!e||i.type==F.Text&&(e.type!=i.type||(n<0?i.from<t:i.to>t)))&&(e=i)}}return e||r}return r}function Pi(e,t,n,r){let i=Ni(e,t.head,t.assoc||-1),a=!r||i.type!=F.Text||!(e.lineWrapping||i.widgetLineBreaks)?null:e.coordsAtPos(t.assoc<0&&t.head>i.from?t.head-1:t.head);if(a){let t=e.dom.getBoundingClientRect(),r=e.textDirectionAt(i.from),o=e.posAtCoords({x:n==(r==L.LTR)?t.right-1:t.left+1,y:(a.top+a.bottom)/2});if(o!=null)return E.cursor(o,n?-1:1)}return E.cursor(n?i.to:i.from,n?-1:1)}function Fi(e,t,n,r){let i=e.state.doc.lineAt(t.head),a=e.bidiSpans(i),o=e.textDirectionAt(i.from);for(let s=t,c=null;;){let t=dr(i,a,o,s,n),l=ur;if(!t){if(i.number==(n?e.state.doc.lines:1))return s;l=`
|
|
27
27
|
`,i=e.state.doc.line(i.number+(n?1:-1)),a=e.bidiSpans(i),t=e.visualLineSide(i,!n)}if(!c){if(!r)return t;c=r(l)}else if(!c(l))return s;s=t}}function Ii(e,t,n){let r=e.state.charCategorizer(t),i=r(n);return e=>{let t=r(e);return i==dt.Space&&(i=t),i==t}}function Li(e,t,n,r){let i=t.head,a=n?1:-1;if(i==(n?e.state.doc.length:0))return E.cursor(i,t.assoc);let o=t.goalColumn,s,c=e.contentDOM.getBoundingClientRect(),l=e.coordsAtPos(i,t.assoc||((t.empty?n:t.head==t.from)?1:-1)),u=e.documentTop;if(l)o??=l.left-c.left,s=a<0?l.top:l.bottom;else{let t=e.viewState.lineBlockAt(i);o??=Math.min(c.right-c.left,e.defaultCharacterWidth*(i-t.from)),s=(a<0?t.top:t.bottom)+u}let d=c.left+o,f=e.viewState.heightOracle.textHeight>>1,p=r??f;for(let t=0;;t+=f){let r=s+(p+t)*a,i=Hi(e,{x:d,y:r},!1,a);if(n?r>c.bottom:r<c.top)return E.cursor(i.pos,i.assoc);let l=e.coordsAtPos(i.pos,i.assoc),u=l?(l.top+l.bottom)/2:0;if(!l||(n?u>s:u<s))return E.cursor(i.pos,i.assoc,void 0,o)}}function Ri(e,t,n){for(;;){let r=0;for(let i of e)i.between(t-1,t+1,(e,i,a)=>{if(t>e&&t<i){let a=r||n||(t-e<i-t?-1:1);t=a<0?e:i,r=a}});if(!r)return t}}function zi(e,t){let n=null;for(let r=0;r<t.ranges.length;r++){let i=t.ranges[r],a=null;if(i.empty){let t=Ri(e,i.from,0);t!=i.from&&(a=E.cursor(t,-1))}else{let t=Ri(e,i.from,-1),n=Ri(e,i.to,1);(t!=i.from||n!=i.to)&&(a=E.range(i.from==i.anchor?t:n,i.from==i.head?t:n))}a&&(n||=t.ranges.slice(),n[r]=a)}return n?E.create(n,t.mainIndex):t}function Bi(e,t,n){let r=Ri(e.state.facet(Rr).map(t=>t(e)),n.from,t.head>n.from?-1:1);return r==n.from?n:E.cursor(r,r<n.from?1:-1)}var Vi=class{constructor(e,t){this.pos=e,this.assoc=t}};function Hi(e,t,n,r){let i=e.contentDOM.getBoundingClientRect(),a=i.top+e.viewState.paddingTop,{x:o,y:s}=t,c=s-a,l;for(;;){if(c<0)return new Vi(0,1);if(c>e.viewState.docHeight)return new Vi(e.state.doc.length,-1);if(l=e.elementAtHeight(c),r==null)break;if(l.type==F.Text){if(r<0?l.to<e.viewport.from:l.from>e.viewport.to)break;let t=e.docView.coordsAt(r<0?l.from:l.to,r>0?-1:1);if(t&&(r<0?t.top<=c+a:t.bottom>=c+a))break}let t=e.viewState.heightOracle.textHeight/2;c=r>0?l.bottom+t:l.top-t}if(e.viewport.from>=l.to||e.viewport.to<=l.from){if(n)return null;if(l.type==F.Text){let t=Mi(e,i,l,o,s);return new Vi(t,t==l.from?1:-1)}}if(l.type!=F.Text)return c<(l.top+l.bottom)/2?new Vi(l.from,1):new Vi(l.to,-1);let u=e.docView.lineAt(l.from,2);return(!u||u.length!=l.length)&&(u=e.docView.lineAt(l.from,-2)),new Ui(e,o,s,e.textDirectionAt(l.from)).scanTile(u,l.from)}var Ui=class{constructor(e,t,n,r){this.view=e,this.x=t,this.y=n,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[tr.find(r,e-n.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[tr.find(r,e-n.from,-1,t)].dir}bidiIn(e,t){let{spans:n,line:r}=this.bidiSpansAt(e);return n.length>1||n.length&&(n[0].level!=this.baseDir||n[0].to+r.from<t)}scan(e,t,n=!1){let r=0,i=e.length-1,a=new Set,o=this.bidiIn(e[0],e[i]),s,c,l=-1,u=1e9,d;search:for(;r<i;){let n=i-r,f=r+i>>1;adjust:if(a.has(f)){let e=r+Math.floor(Math.random()*n);for(let t=0;t<n;t++){if(!a.has(e)){f=e;break adjust}e++,e==i&&(e=r)}break search}a.add(f);let p=t(f);if(p)for(let t=0;t<p.length;t++){let n=p[t],a=0;if(!(n.width==0&&p.length>1)){if(n.bottom<this.y)(!s||s.bottom<n.bottom)&&(s=n),a=1;else if(n.top>this.y)(!c||c.top>n.top)&&(c=n),a=-1;else{let e=n.left>this.x?this.x-n.left:n.right<this.x?this.x-n.right:0,t=Math.abs(e);t<u&&(l=f,u=t,d=n),e&&(a=e<0==(this.baseDir==L.LTR)?-1:1)}a==-1&&(!o||this.baseDirAt(e[f],1))?i=f:a==1&&(!o||this.baseDirAt(e[f+1],-1))&&(r=f+1)}}}if(!d){if(!c&&!s)return{i:e[0],after:!1};let n=s&&(!c||this.y-s.bottom<c.top-this.y)?s:c;return this.y=(n.top+n.bottom)/2,this.scan(e,t,!0)}if(u&&!n){let{top:n,bottom:r}=d;if(s&&s.bottom>(n+n+r)/3)return this.y=s.bottom-1,this.scan(e,t,!0);if(c&&c.top<(n+r+r)/3)return this.y=c.top+1,this.scan(e,t,!0)}let f=(o?this.dirAt(e[l],1):this.baseDir)==L.LTR;return{i:l,after:this.x>(d.left+d.right)/2==f}}scanText(e,t){let n=[];for(let r=0;r<e.length;r=w(e.text,r))n.push(t+r);n.push(t+e.length);let r=this.scan(n,r=>{let i=n[r]-t,a=n[r+1]-t;return Rn(e.dom,i,a).getClientRects()});return r.after?new Vi(n[r.i+1],-1):new Vi(n[r.i],1)}scanTile(e,t){if(!e.length)return new Vi(t,1);if(e.children.length==1){let n=e.children[0];if(n.isText())return this.scanText(n,t);if(n.isComposite())return this.scanTile(n,t)}let n=[t];for(let r=0,i=t;r<e.children.length;r++)n.push(i+=e.children[r].length);let r=this.scan(n,t=>{let n=e.children[t];return n.flags&48?null:(n.dom.nodeType==1?n.dom:Rn(n.dom,0,n.length)).getClientRects()}),i=e.children[r.i],a=n[r.i];return i.isText()?this.scanText(i,a):i.isComposite()?this.scanTile(i,a):r.after?new Vi(n[r.i+1],-1):new Vi(a,1)}},Wi=``,Gi=class{constructor(e,t){this.points=e,this.view=t,this.text=``,this.lineSeparator=t.state.facet(A.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Wi}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let r=e;;){this.findPointBefore(n,r);let e=this.text.length;this.readNode(r);let i=B.get(r),a=r.nextSibling;if(a==t){i?.breakAfter&&!a&&n!=this.view.contentDOM&&this.lineBreak();break}let o=B.get(a);(i&&o?i.breakAfter:(i?i.breakAfter:En(r))||En(a)&&(r.nodeName!=`BR`||i?.isWidget())&&this.text.length>e)&&!qi(a,t)&&this.lineBreak(),r=a}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let i=-1,a=1,o;if(this.lineSeparator?(i=t.indexOf(this.lineSeparator,n),a=this.lineSeparator.length):(o=r.exec(t))&&(i=o.index,a=o[0].length),this.append(t.slice(n,i<0?t.length:i)),i<0)break;if(this.lineBreak(),a>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=a-1);n=i+a}}readNode(e){let t=B.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName==`BR`?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(Ki(e,n.node,n.offset)?t:0))}};function Ki(e,t,n){for(;;){if(!t||n<On(t))return!1;if(t==e)return!0;n=Tn(t)+1,t=t.parentNode}}function qi(e,t){let n;for(;!(e==t||!e);e=e.nextSibling){let t=B.get(e);if(!t?.isWidget())return!1;t&&(n||=[]).push(t)}if(n){for(let e of n)if(e.overrideDOMText?.length)return!1}return!0}var Ji=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},Yi=class{constructor(e,t,n,r){this.typeOver=r,this.bounds=null,this.text=``,this.domChanged=t>-1;let{impreciseHead:i,impreciseAnchor:a}=e.docView,o=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=Xi(e.docView.tile,t,n,0))){let t=i||a?[]:ta(e),n=new Gi(t,e);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=na(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=i&&i.node==t.focusNode&&i.offset==t.focusOffset||!xn(e.contentDOM,t.focusNode)?o.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),r=a&&a.node==t.anchorNode&&a.offset==t.anchorOffset||!xn(e.contentDOM,t.anchorNode)?o.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),s=e.viewport;if((P.ios||P.chrome)&&o.main.empty&&n!=r&&(s.from>0||s.to<e.state.doc.length)){let t=Math.min(n,r),i=Math.max(n,r),a=s.from-t,o=s.to-i;(a==0||a==1||t==0)&&(o==0||o==-1||i==e.state.doc.length)&&(n=0,r=e.state.doc.length)}if(e.inputState.composing>-1&&o.ranges.length>1)this.newSel=o.replaceRange(E.range(r,n));else if(e.lineWrapping&&r==n&&!(o.main.empty&&o.main.head==n)&&e.inputState.lastTouchTime>Date.now()-100){let t=e.coordsAtPos(n,-1),r=0;t&&(r=e.inputState.lastTouchY<=t.bottom?-1:1),this.newSel=E.create([E.cursor(n,r)])}else this.newSel=E.single(r,n)}}};function Xi(e,t,n,r){if(e.isComposite()){let i=-1,a=-1,o=-1,s=-1;for(let c=0,l=r,u=r;c<e.children.length;c++){let r=e.children[c],d=l+r.length;if(l<t&&d>n)return Xi(r,t,n,l);if(d>=t&&i==-1&&(i=c,a=l),l>n&&r.dom.parentNode==e.dom){o=c,s=u;break}u=d,l=d+r.breakAfter}return{from:a,to:s<0?r+e.length:s,startDOM:(i?e.children[i-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:o<e.children.length&&o>=0?e.children[o].dom:null}}else if(e.isText())return{from:r,to:r+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling};else return null}function Zi(e,t){let n,{newSel:r}=t,{state:i}=e,a=i.selection.main,o=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:e,to:r}=t.bounds,s=a.from,c=null;(o===8||P.android&&t.text.length<r-e)&&(s=a.to,c=`end`);let l=i.doc.sliceString(e,r,Wi),u,d;!a.empty&&a.from>=e&&a.to<=r&&(t.typeOver||l!=t.text)&&l.slice(0,a.from-e)==t.text.slice(0,a.from-e)&&l.slice(a.to-e)==t.text.slice(u=t.text.length-(l.length-(a.to-e)))?n={from:a.from,to:a.to,insert:S.of(t.text.slice(a.from-e,u).split(Wi))}:(d=ea(l,t.text,s-e,c))&&(P.chrome&&o==13&&d.toB==d.from+2&&t.text.slice(d.from,d.toB)==``&&d.toB--,n={from:e+d.from,to:e+d.toA,insert:S.of(t.text.slice(d.from,d.toB).split(Wi))})}else r&&(!e.hasFocus&&i.facet(Or)||ra(r,a))&&(r=null);if(!n&&!r)return!1;if((P.mac||P.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&e.contentDOM.getAttribute(`autocorrect`)==`off`?(r&&n.insert.length==2&&(r=E.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:S.of([n.insert.toString().replace(`.`,` `)])}):i.doc.lineAt(a.from).to<a.to&&e.docView.lineHasWidget(a.to)&&e.inputState.insertingTextAt>Date.now()-50?n={from:a.from,to:a.to,insert:i.toText(e.inputState.insertingText)}:P.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==`
|
|
28
28
|
`&&e.lineWrapping&&(r&&=E.single(r.main.anchor-1,r.main.head-1),n={from:a.from,to:a.to,insert:S.of([` `])}),n)return Qi(e,n,r,o);if(r&&!ra(r,a)){let t=!1,n=`select`;return e.inputState.lastSelectionTime>Date.now()-50&&(e.inputState.lastSelectionOrigin==`select`&&(t=!0),n=e.inputState.lastSelectionOrigin,n==`select.pointer`&&(r=zi(i.facet(Rr).map(t=>t(e)),r))),e.dispatch({selection:r,scrollIntoView:t,userEvent:n}),!0}else return!1}function Qi(e,t,n,r=-1){if(P.ios&&e.inputState.flushIOSKey(t))return!0;let i=e.state.selection.main;if(P.android&&(t.to==i.to&&(t.from==i.from||t.from==i.from-1&&e.state.sliceDoc(t.from,i.from)==` `)&&t.insert.length==1&&t.insert.lines==2&&zn(e.contentDOM,`Enter`,13)||(t.from==i.from-1&&t.to==i.to&&t.insert.length==0||r==8&&t.insert.length<t.to-t.from&&t.to>i.head)&&zn(e.contentDOM,`Backspace`,8)||t.from==i.from&&t.to==i.to+1&&t.insert.length==0&&zn(e.contentDOM,`Delete`,46)))return!0;let a=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let o,s=()=>o||=$i(e,t,n);return e.state.facet(vr).some(n=>n(e,t.from,t.to,a,s))||e.dispatch(s()),!0}function $i(e,t,n){let r,i=e.state,a=i.selection.main,o=-1;if(t.from==t.to&&t.from<a.from||t.from>a.to){let n=t.from<a.from?-1:1,r=n<0?a.from:a.to,s=Ri(i.facet(Rr).map(t=>t(e)),r,n);t.from==s&&(o=s)}if(o>-1)r={changes:t,selection:E.cursor(t.from+t.insert.length,-1)};else if(t.from>=a.from&&t.to<=a.to&&t.to-t.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=a.from<t.from?i.sliceDoc(a.from,t.from):``,o=a.to>t.to?i.sliceDoc(t.to,a.to):``;r=i.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+o))}else{let o=i.changes(t),s=n&&n.main.to<=o.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=a.to+10&&t.to>=a.to-10){let c=e.state.sliceDoc(t.from,t.to),l,u=n&&xi(e,n.main.head);if(u){let e=t.insert.length-(t.to-t.from);l={from:u.from,to:u.to-e}}else l=e.state.doc.lineAt(a.head);let d=a.to-t.to;r=i.changeByRange(n=>{if(n.from==a.from&&n.to==a.to)return{changes:o,range:s||n.map(o)};let r=n.to-d,u=r-c.length;if(e.state.sliceDoc(u,r)!=c||r>=l.from&&u<=l.to)return{range:n};let f=i.changes({from:u,to:r,insert:t.insert}),p=n.to-a.to;return{changes:f,range:s?E.range(Math.max(0,s.anchor+p),Math.max(0,s.head+p)):n.map(f)}})}else r={changes:o,selection:s&&i.selection.replaceRange(s)}}let s=`input.type`;return(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,s+=`.compose`,e.inputState.compositionFirstChange&&(s+=`.start`,e.inputState.compositionFirstChange=!1)),i.update(r,{userEvent:s,scrollIntoView:!0})}function ea(e,t,n,r){let i=Math.min(e.length,t.length),a=0;for(;a<i&&e.charCodeAt(a)==t.charCodeAt(a);)a++;if(a==i&&e.length==t.length)return null;let o=e.length,s=t.length;for(;o>0&&s>0&&e.charCodeAt(o-1)==t.charCodeAt(s-1);)o--,s--;if(r==`end`){let e=Math.max(0,a-Math.min(o,s));n-=o+e-a}if(o<a&&e.length<t.length){let e=n<=a&&n>=o?a-n:0;a-=e,s=a+(s-o),o=a}else if(s<a){let e=n<=a&&n>=s?a-n:0;a-=e,o=a+(o-s),s=a}return{from:a,toA:o,toB:s}}function ta(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}=e.observer.selectionRange;return n&&(t.push(new Ji(n,r)),(i!=n||a!=r)&&t.push(new Ji(i,a))),t}function na(e,t){if(e.length==0)return null;let n=e[0].pos,r=e.length==2?e[1].pos:n;return n>-1&&r>-1?E.single(n+t,r+t):null}function ra(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}var ia=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText=``,this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,P.safari&&e.contentDOM.addEventListener(`input`,()=>null),P.gecko&&za(e.contentDOM.ownerDocument)}handleEvent(e){!_a(this.view,e)||this.ignoreDuringComposition(e)||e.type==`keydown`&&this.keydown(e)||(this.view.updateState==0?this.runHandlers(e.type,e):Promise.resolve().then(()=>this.runHandlers(e.type,e)))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let e of n.observers)e(this.view,t);for(let e of n.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=oa(e),n=this.handlers,r=this.view.contentDOM;for(let e in t)if(e!=`scroll`){let i=!t[e].handlers.length,a=n[e];a&&i!=!a.handlers.length&&(r.removeEventListener(e,this.handleEvent),a=null),a||r.addEventListener(e,this.handleEvent,{passive:i})}for(let e in n)e!=`scroll`&&!t[e]&&r.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&la.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),P.android&&P.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return P.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&!e.shiftKey&&((t=sa.find(t=>t.keyCode==e.keyCode))&&!e.ctrlKey||ca.indexOf(e.key)>-1&&e.ctrlKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key==`Enter`&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,zn(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:P.safari&&!P.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function aa(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(e){z(n.state,e)}}}function oa(e){let t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec,r=e&&e.plugin.domEventHandlers,i=e&&e.plugin.domEventObservers;if(r)for(let e in r){let i=r[e];i&&n(e).handlers.push(aa(t.value,i))}if(i)for(let e in i){let r=i[e];r&&n(e).observers.push(aa(t.value,r))}}for(let e in va)n(e).handlers.push(va[e]);for(let e in H)n(e).observers.push(H[e]);return t}var sa=[{key:`Backspace`,keyCode:8,inputType:`deleteContentBackward`},{key:`Enter`,keyCode:13,inputType:`insertParagraph`},{key:`Enter`,keyCode:13,inputType:`insertLineBreak`},{key:`Delete`,keyCode:46,inputType:`deleteContentForward`}],ca=`dthko`,la=[16,17,18,20,91,92,224,225],ua=6;function da(e){return Math.max(0,e)*.7+8}function fa(e,t){return Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))}var pa=class{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=Nn(e.contentDOM),this.atoms=e.state.facet(Rr).map(t=>t(e));let i=e.contentDOM.ownerDocument;i.addEventListener(`mousemove`,this.move=this.move.bind(this)),i.addEventListener(`mouseup`,this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(A.allowMultipleSelections)&&ma(e,t),this.dragging=ga(e,t)&&Oa(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&fa(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,r=0,i=0,a=this.view.win.innerWidth,o=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:i,bottom:o}=this.scrollParents.y.getBoundingClientRect());let s=Hr(this.view);e.clientX-s.left<=r+ua?t=-da(r-e.clientX):e.clientX+s.right>=a-ua&&(t=da(e.clientX-a)),e.clientY-s.top<=i+ua?n=-da(i-e.clientY):e.clientY+s.bottom>=o-ua&&(n=da(e.clientY-o)),this.setScrollSpeed(t,n)}up(e){this.dragging??this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener(`mousemove`,this.move),e.removeEventListener(`mouseup`,this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=zi(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:`select.pointer`}),this.mustSelect=!1}update(e){e.transactions.some(e=>e.isUserEvent(`input.type`))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function ma(e,t){let n=e.state.facet(pr);return n.length?n[0](t):P.mac?t.metaKey:t.ctrlKey}function ha(e,t){let n=e.state.facet(mr);return n.length?n[0](t):P.mac?!t.altKey:!t.ctrlKey}function ga(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let r=bn(e.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let e=0;e<i.length;e++){let n=i[e];if(n.left<=t.clientX&&n.right>=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}function _a(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target,r;n!=e.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=B.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(t))return!1;return!0}var va=Object.create(null),H=Object.create(null),ya=P.ie&&P.ie_version<15||P.ios&&P.webkit_version<604;function ba(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement(`textarea`));n.style.cssText=`position: fixed; left: -10000px; top: 10px`,n.focus(),setTimeout(()=>{e.focus(),n.remove(),Sa(e,n.value)},50)}function xa(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function Sa(e,t){t=xa(e.state,br,t);let{state:n}=e,r,i=1,a=n.toText(t),o=a.lines==n.selection.ranges.length;if(Pa!=null&&n.selection.ranges.every(e=>e.empty)&&Pa==a.toString()){let e=-1;r=n.changeByRange(r=>{let s=n.doc.lineAt(r.from);if(s.from==e)return{range:r};e=s.from;let c=n.toText((o?a.line(i++).text:t)+n.lineBreak);return{changes:{from:s.from,insert:c},range:E.cursor(r.from+c.length)}})}else r=o?n.changeByRange(e=>{let t=a.line(i++);return{changes:{from:e.from,to:e.to,insert:t.text},range:E.cursor(e.from+t.length)}}):n.replaceSelection(a);e.dispatch(r,{userEvent:`input.paste`,scrollIntoView:!0})}H.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},H.wheel=H.mousewheel=e=>{e.inputState.lastWheelEvent=Date.now()},va.keydown=(e,t)=>(e.inputState.setSelectionOrigin(`select`),t.keyCode==27&&e.inputState.tabFocusMode!=0&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),H.touchstart=(e,t)=>{let n=e.inputState,r=t.targetTouches[0];n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin(`select.pointer`)},H.touchmove=e=>{e.inputState.setSelectionOrigin(`select.pointer`)},va.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of e.state.facet(hr))if(n=r(e,t),n)break;if(!n&&t.button==0&&(n=ka(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new pa(e,t,n,r)),r&&e.observer.ignore(()=>{In(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let i=e.inputState.mouseSelection;if(i)return i.start(t),i.dragging===!1}else e.inputState.setSelectionOrigin(`select.pointer`);return!1};function Ca(e,t,n,r){if(r==1)return E.cursor(t,n);if(r==2)return ji(e.state,t,n);{let r=e.docView.lineAt(t,n),i=e.state.doc.lineAt(r?r.posAtEnd:t),a=r?r.posAtStart:i.from,o=r?r.posAtEnd:i.to;return o<e.state.doc.length&&o==i.to&&o++,E.range(a,o)}}var wa=P.ie&&P.ie_version<=11,Ta=null,Ea=0,Da=0;function Oa(e){if(!wa)return e.detail;let t=Ta,n=Da;return Ta=e,Da=Date.now(),Ea=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(Ea+1)%3:1}function ka(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=Oa(t),i=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),i=i.map(e.changes))},get(t,a,o){let s=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),c,l=Ca(e,s.pos,s.assoc,r);if(n.pos!=s.pos&&!a){let t=Ca(e,n.pos,n.assoc,r),i=Math.min(t.from,l.from),a=Math.max(t.to,l.to);l=i<l.from?E.range(i,a,l.assoc):E.range(a,i,l.assoc)}return a?i.replaceRange(i.main.extend(l.from,l.to,l.assoc)):o&&r==1&&i.ranges.length>1&&(c=Aa(i,s.pos))?c:o?i.addRange(l):E.create([l])}}}function Aa(e,t){for(let n=0;n<e.ranges.length;n++){let{from:r,to:i}=e.ranges[n];if(r<=t&&i>=t)return E.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-+(e.mainIndex>n))}return null}va.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let r=e.docView.tile.nearest(t.target);if(r&&r.isWidget()){let e=r.posAtStart,t=e+r.length;(e>=n.to||t<=n.from)&&(n=E.range(e,t))}}let{inputState:r}=e;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData(`Text`,xa(e.state,xr,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed=`copyMove`),!1},va.dragend=e=>(e.inputState.draggedContent=null,!1);function ja(e,t,n,r){if(n=xa(e.state,br,n),!n)return;let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:a}=e.inputState,o=r&&a&&ha(e,t)?{from:a.from,to:a.to}:null,s={from:i,insert:n},c=e.state.changes(o?[o,s]:s);e.focus(),e.dispatch({changes:c,selection:{anchor:c.mapPos(i,-1),head:c.mapPos(i,1)},userEvent:o?`move.drop`:`input.drop`}),e.inputState.draggedContent=null}va.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,a=()=>{++i==n.length&&ja(e,t,r.filter(e=>e!=null).join(e.state.lineBreak),!1)};for(let e=0;e<n.length;e++){let t=new FileReader;t.onerror=a,t.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(r[e]=t.result),a()},t.readAsText(n[e])}return!0}else{let n=t.dataTransfer.getData(`Text`);if(n)return ja(e,t,n,!0),!0}return!1},va.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=ya?null:t.clipboardData;return n?(Sa(e,n.getData(`text/plain`)||n.getData(`text/uri-list`)),!0):(ba(e),!1)};function Ma(e,t){let n=e.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement(`textarea`));r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.value=t,r.focus(),r.selectionEnd=t.length,r.selectionStart=0,setTimeout(()=>{r.remove(),e.focus()},50)}function Na(e){let t=[],n=[],r=!1;for(let r of e.selection.ranges)r.empty||(t.push(e.sliceDoc(r.from,r.to)),n.push(r));if(!t.length){let i=-1;for(let{from:r}of e.selection.ranges){let a=e.doc.lineAt(r);a.number>i&&(t.push(a.text),n.push({from:a.from,to:Math.min(e.doc.length,a.to+1)})),i=a.number}r=!0}return{text:xa(e,xr,t.join(e.lineBreak)),ranges:n,linewise:r}}var Pa=null;va.copy=va.cut=(e,t)=>{if(!Sn(e.contentDOM,e.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=Na(e.state);if(!n&&!i)return!1;Pa=i?n:null,t.type==`cut`&&!e.state.readOnly&&e.dispatch({changes:r,scrollIntoView:!0,userEvent:`delete.cut`});let a=ya?null:t.clipboardData;return a?(a.clearData(),a.setData(`text/plain`,n),!0):(Ma(e,n),!1)};var Fa=et.define();function Ia(e,t){let n=[];for(let r of e.facet(yr)){let i=r(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:Fa.of(!0)}):null}function La(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=Ia(e.state,t);n?e.dispatch(n):e.update([])}},10)}H.focus=e=>{e.inputState.lastFocusTime=Date.now(),!e.scrollDOM.scrollTop&&(e.inputState.lastScrollTop||e.inputState.lastScrollLeft)&&(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),La(e)},H.blur=e=>{e.observer.clearSelectionRange(),La(e)},H.compositionstart=H.compositionupdate=e=>{e.observer.editContext||(e.inputState.compositionFirstChange??(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},H.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,P.chrome&&P.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},H.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},va.beforeinput=(e,t)=>{if((t.inputType==`insertText`||t.inputType==`insertCompositionText`)&&(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),t.inputType==`insertReplacementText`&&e.observer.editContext){let n=t.dataTransfer?.getData(`text/plain`),r=t.getTargetRanges();if(n&&r.length){let t=r[0];return Qi(e,{from:e.posAtDOM(t.startContainer,t.startOffset),to:e.posAtDOM(t.endContainer,t.endOffset),insert:e.state.toText(n)},null),!0}}let n;if(P.chrome&&P.android&&(n=sa.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(n.key,n.keyCode),n.key==`Backspace`||n.key==`Delete`)){let t=window.visualViewport?.height||0;setTimeout(()=>{(window.visualViewport?.height||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return P.ios&&t.inputType==`deleteContentForward`&&e.observer.flushSoon(),P.safari&&t.inputType==`insertText`&&e.inputState.composing>=0&&setTimeout(()=>H.compositionend(e,t),20),!1};var Ra=new Set;function za(e){Ra.has(e)||(Ra.add(e),e.addEventListener(`copy`,()=>{}),e.addEventListener(`cut`,()=>{}))}var Ba=[`pre-wrap`,`normal`,`pre-line`,`break-spaces`],Va=!1;function Ha(){Va=!1}var Ua=class{constructor(e){this.lineWrapping=e,this.doc=S.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Ba.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];r<0?n++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,n,r,i,a){let o=Ba.indexOf(e)>-1,s=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=i,s){this.heightSamples={};for(let e=0;e<a.length;e++){let t=a[e];t<0?e++:this.heightSamples[Math.floor(t*10)]=!0}}return s}},Wa=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},Ga=class e{constructor(e,t,n,r,i){this.from=e,this.length=t,this.top=n,this.height=r,this._content=i}get type(){return typeof this._content==`number`?F.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof hn?this._content.widget:null}get widgetLineBreaks(){return typeof this._content==`number`?this._content:0}join(t){let n=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new e(this.from,this.length+t.length,this.top,this.height+t.height,n)}},U=(function(e){return e[e.ByPos=0]=`ByPos`,e[e.ByHeight=1]=`ByHeight`,e[e.ByPosNoHeight=2]=`ByPosNoHeight`,e})(U||={}),Ka=.001,qa=class e{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Ka&&(Va=!0),this.height=e)}replace(t,n,r){return e.of(r)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,r){let i=this,a=n.doc;for(let o=r.length-1;o>=0;o--){let{fromA:s,toA:c,fromB:l,toB:u}=r[o],d=i.lineAt(s,U.ByPosNoHeight,n.setDoc(t),0,0),f=d.to>=c?d:i.lineAt(c,U.ByPosNoHeight,n,0,0);for(u+=f.to-c,c=f.to;o>0&&d.from<=r[o-1].toA;)s=r[o-1].fromA,l=r[o-1].fromB,o--,s<d.from&&(d=i.lineAt(s,U.ByPosNoHeight,n,0,0));l+=d.from-s,s=d.from;let p=no.build(n.setDoc(a),e,l,u);i=Ja(i,i.replace(s,c,p))}return i.updateHeight(n,0)}static empty(){return new Za(0,0,0)}static of(t){if(t.length==1)return t[0];let n=0,r=t.length,i=0,a=0;for(;;)if(n==r)if(i>a*2){let e=t[n-1];e.break?t.splice(--n,1,e.left,null,e.right):t.splice(--n,1,e.left,e.right),r+=1+e.break,i-=e.size}else if(a>i*2){let e=t[r];e.break?t.splice(r,1,e.left,null,e.right):t.splice(r,1,e.left,e.right),r+=2+e.break,a-=e.size}else break;else if(i<a){let e=t[n++];e&&(i+=e.size)}else{let e=t[--r];e&&(a+=e.size)}let o=0;return t[n-1]==null?(o=1,n--):t[n]??(o=1,r++),new $a(e.of(t.slice(0,n)),o,e.of(t.slice(r)))}};function Ja(e,t){return e==t?e:(e.constructor!=t.constructor&&(Va=!0),t)}qa.prototype.size=1;var Ya=I.replace({}),Xa=class extends qa{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new Ga(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,n,r){return this.spaceAbove&&e<n+this.spaceAbove?new Ga(r,0,n,this.spaceAbove,Ya):this.mainBlock(n,r)}lineAt(e,t,n,r,i){let a=this.mainBlock(r,i);return this.spaceAbove?this.blockAt(0,n,r,i).join(a):a}forEachLine(e,t,n,r,i,a){e<=i+this.length&&t>=i&&a(this.lineAt(0,U.ByPos,n,r,i))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}},Za=class e extends Xa{constructor(e,t,n){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,t){return new Ga(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(t,n,r){let i=r[0];return r.length==1&&(i instanceof e||i instanceof Qa&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof Qa?i=new e(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):qa.of(r)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(n||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:``}${this.widgetHeight?`:`+this.widgetHeight:``})`}},Qa=class e extends qa{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,i=r-n+1,a,o=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*i);a=t/i,this.length>i+1&&(o=(this.height-t)/(this.length-i-1))}else a=this.height/i;return{firstLine:n,lastLine:r,perLine:a,perChar:o}}blockAt(e,t,n,r){let{firstLine:i,lastLine:a,perLine:o,perChar:s}=this.heightMetrics(t,r);if(t.lineWrapping){let i=r+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),a=t.doc.lineAt(i),c=o+a.length*s,l=Math.max(n,e-c/2);return new Ga(a.from,a.length,l,c,0)}else{let r=Math.max(0,Math.min(a-i,Math.floor((e-n)/o))),{from:s,length:c}=t.doc.line(i+r);return new Ga(s,c,n+o*r,o,0)}}lineAt(e,t,n,r,i){if(t==U.ByHeight)return this.blockAt(e,n,r,i);if(t==U.ByPosNoHeight){let{from:t,to:r}=n.doc.lineAt(e);return new Ga(t,r-t,0,0,0)}let{firstLine:a,perLine:o,perChar:s}=this.heightMetrics(n,i),c=n.doc.lineAt(e),l=o+c.length*s,u=c.number-a,d=r+o*u+s*(c.from-i-u);return new Ga(c.from,c.length,Math.max(r,Math.min(d,r+this.height-l)),l,0)}forEachLine(e,t,n,r,i,a){e=Math.max(e,i),t=Math.min(t,i+this.length);let{firstLine:o,perLine:s,perChar:c}=this.heightMetrics(n,i);for(let l=e,u=r;l<=t;){let t=n.doc.lineAt(l);if(l==e){let n=t.number-o;u+=s*n+c*(e-i-n)}let r=s+c*t.length;a(new Ga(t.from,t.length,u,r,0)),u+=r,l=t.to+1}}replace(t,n,r){let i=this.length-n;if(i>0){let t=r[r.length-1];t instanceof e?r[r.length-1]=new e(t.length+i):r.push(null,new e(i-1))}if(t>0){let n=r[0];n instanceof e?r[0]=new e(t+n.length):r.unshift(new e(t-1),null)}return qa.of(r)}decomposeLeft(t,n){n.push(new e(t-1),null)}decomposeRight(t,n){n.push(null,new e(this.length-t-1))}updateHeight(t,n=0,r=!1,i){let a=n+this.length;if(i&&i.from<=n+this.length&&i.more){let r=[],o=Math.max(n,i.from),s=-1;for(i.from>n&&r.push(new e(i.from-n-1).updateHeight(t,n));o<=a&&i.more;){let e=t.doc.lineAt(o).length;r.length&&r.push(null);let n=i.heights[i.index++],a=0;n<0&&(a=-n,n=i.heights[i.index++]),s==-1?s=n:Math.abs(n-s)>=Ka&&(s=-2);let c=new Za(e,n,a);c.outdated=!1,r.push(c),o+=e+1}o<=a&&r.push(null,new e(a-o).updateHeight(t,o));let c=qa.of(r);return(s<0||Math.abs(c.height-this.height)>=Ka||Math.abs(s-this.heightMetrics(t,n).perLine)>=Ka)&&(Va=!0),Ja(this,c)}else (r||this.outdated)&&(this.setHeight(t.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},$a=class extends qa{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,r){let i=n+this.left.height;return e<i?this.left.blockAt(e,t,n,r):this.right.blockAt(e,t,i,r+this.left.length+this.break)}lineAt(e,t,n,r,i){let a=r+this.left.height,o=i+this.left.length+this.break,s=t==U.ByHeight?e<a:e<o,c=s?this.left.lineAt(e,t,n,r,i):this.right.lineAt(e,t,n,a,o);if(this.break||(s?c.to<o:c.from>o))return c;let l=t==U.ByPosNoHeight?U.ByPosNoHeight:U.ByPos;return s?c.join(this.right.lineAt(o,l,n,a,o)):this.left.lineAt(o,l,n,r,i).join(c)}forEachLine(e,t,n,r,i,a){let o=r+this.left.height,s=i+this.left.length+this.break;if(this.break)e<s&&this.left.forEachLine(e,t,n,r,i,a),t>=s&&this.right.forEachLine(e,t,n,o,s,a);else{let c=this.lineAt(s,U.ByPos,n,r,i);e<c.from&&this.left.forEachLine(e,c.from-1,n,r,i,a),c.to>=e&&c.from<=t&&a(c),t>c.to&&this.right.forEachLine(c.to+1,t,n,o,s,a)}}replace(e,t,n){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));let i=[];e>0&&this.decomposeLeft(e,i);let a=i.length;for(let e of n)i.push(e);if(e>0&&eo(i,a-1),t<this.length){let e=i.length;this.decomposeRight(t,i),eo(i,e)}return qa.of(i)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?qa.of(this.break?[e,null,t]:[e,t]):(this.left=Ja(this.left,e),this.right=Ja(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,r){let{left:i,right:a}=this,o=t+i.length+this.break,s=null;return r&&r.from<=t+i.length&&r.more?s=i=i.updateHeight(e,t,n,r):i.updateHeight(e,t,n),r&&r.from<=o+a.length&&r.more?s=a=a.updateHeight(e,o,n,r):a.updateHeight(e,o,n),s?this.balanced(i,a):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?` `:`-`)+this.right}};function eo(e,t){let n,r;e[t]==null&&(n=e[t-1])instanceof Qa&&(r=e[t+1])instanceof Qa&&e.splice(t-1,3,new Qa(n.length+1+r.length))}var to=5,no=class e{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof Za?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new Za(e-this.pos,-1,0)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let r=n.widget?n.widget.estimatedHeight:0,i=n.widget?n.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let a=t-e;n.block?this.addBlock(new Xa(a,r,n)):(a||i||r>=to)&&this.addLineDeco(r,i,a)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new Za(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new Qa(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Za)return e;let t=new Za(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos+=e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos+=n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Za)&&!this.isCovered?this.nodes.push(new Za(0,-1,0)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let e of this.nodes)e instanceof Za&&e.updateHeight(this.oracle,n),n+=e?e.length:1;return this.nodes}static build(t,n,r,i){let a=new e(r,t);return j.spans(n,r,i,a,0),a.finish(r)}};function ro(e,t,n){let r=new io;return j.compare(e,t,n,r,0),r.changes}var io=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&vn(e,t,this.changes,5)}};function ao(e,t){let n=e.getBoundingClientRect(),r=e.ownerDocument,i=r.defaultView||window,a=Math.max(0,n.left),o=Math.min(i.innerWidth,n.right),s=Math.max(0,n.top),c=Math.min(i.innerHeight,n.bottom);for(let t=e.parentNode;t&&t!=r.body;)if(t.nodeType==1){let n=t,r=window.getComputedStyle(n);if((n.scrollHeight>n.clientHeight||n.scrollWidth>n.clientWidth)&&r.overflow!=`visible`){let r=n.getBoundingClientRect();a=Math.max(a,r.left),o=Math.min(o,r.right),s=Math.max(s,r.top),c=Math.min(t==e.parentNode?i.innerHeight:c,r.bottom)}t=r.position==`absolute`||r.position==`fixed`?n.offsetParent:n.parentNode}else if(t.nodeType==11)t=t.host;else break;return{left:a-n.left,right:Math.max(a,o)-n.left,top:s-(n.top+t),bottom:Math.max(s,c)-(n.top+t)}}function oo(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left<n.innerWidth&&t.right>0&&t.top<n.innerHeight&&t.bottom>0}function so(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}var co=class{constructor(e,t,n,r){this.from=e,this.to=t,this.size=n,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.size!=i.size)return!1}return!0}draw(e,t){return I.replace({widget:new lo(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},lo=class extends fn{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement(`div`);return this.vertical?e.style.height=this.size+`px`:(e.style.width=this.size+`px`,e.style.height=`2px`,e.style.display=`inline-block`),e}get estimatedHeight(){return this.vertical?this.size:-1}},uo=class{constructor(e,t){this.view=e,this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=_o,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=L.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=t.facet(Pr).some(e=>typeof e!=`function`&&e.class==`cm-lineWrapping`);this.heightOracle=new Ua(n),this.stateDeco=vo(t),this.heightMap=qa.empty().applyChanges(this.stateDeco,S.empty,this.heightOracle.setDoc(t.doc),[new Wr(0,0,0,t.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=I.set(this.lineGaps.map(e=>e.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let r=n?t.head:t.anchor;if(!e.some(({from:e,to:t})=>r>=e&&r<=t)){let{from:t,to:n}=this.lineBlockAt(r);e.push(new fo(t,n))}}return this.viewports=e.sort((e,t)=>e.from-t.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?_o:new yo(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(bo(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=vo(this.state);let r=e.changedRanges,i=Wr.extendWithRanges(r,ro(n,this.stateDeco,e?e.changes:xe.empty(this.state.doc.length))),a=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);Ha(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=a||Va)&&(e.flags|=2),o?(this.scrollAnchorPos=e.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=a);let s=i.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<s.from||t.range.head>s.to)||!this.viewportIsAppropriate(s))&&(s=this.getViewport(0,t));let c=s.from!=this.viewport.from||s.to!=this.viewport.to;this.viewport=s,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Cr)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,i=n.whiteSpace;this.defaultTextDirection=n.direction==`rtl`?L.RTL:L.LTR;let a=this.heightOracle.mustRefreshForWrapping(i)||this.mustMeasureContent===`refresh`,o=t.getBoundingClientRect(),s=a||this.mustMeasureContent||this.contentDOMHeight!=o.height;this.contentDOMHeight=o.height,this.mustMeasureContent=!1;let c=0,l=0;if(o.width&&o.height){let{scaleX:e,scaleY:n}=jn(t,o);(e>.005&&Math.abs(this.scaleX-e)>.005||n>.005&&Math.abs(this.scaleY-n)>.005)&&(this.scaleX=e,this.scaleY=n,c|=16,a=s=!0)}let u=(parseInt(n.paddingTop)||0)*this.scaleY,d=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=d)&&(this.paddingTop=u,this.paddingBottom=d,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(s=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let f=Nn(this.view.contentDOM,!1).y;f!=this.scrollParent&&(this.scrollParent=f,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=Hn(this.scrollParent||e.win);let m=(this.printing?so:ao)(t,this.paddingTop),h=m.top-this.pixelViewport.top,g=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let _=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(_!=this.inView&&(this.inView=_,_&&(s=!0)),!this.inView&&!this.scrollTarget&&!oo(e.dom))return 0;let v=o.width;if((this.contentDOMWidth!=v||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=o.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),s){let t=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(t)&&(a=!0),a||r.lineWrapping&&Math.abs(v-this.contentDOMWidth)>r.charWidth){let{lineHeight:n,charWidth:o,textHeight:s}=e.docView.measureTextSize();a=n>0&&r.refresh(i,n,o,s,Math.max(5,v/o),t),a&&(e.docView.minWidth=0,c|=16)}h>0&&g>0?l=Math.max(h,g):h<0&&g<0&&(l=Math.min(h,g)),Ha();for(let n of this.viewports){let i=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(a?qa.empty().applyChanges(this.stateDeco,S.empty,this.heightOracle,[new Wr(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,a,new Wa(n.from,i))}Va&&(c|=2)}let y=!this.viewportIsAppropriate(this.viewport,l)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return y&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(l,this.scrollTarget),c|=this.updateForViewport()),(c&2||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,i=this.heightOracle,{visibleTop:a,visibleBottom:o}=this,s=new fo(r.lineAt(a-n*1e3,U.ByHeight,i,0,0).from,r.lineAt(o+(1-n)*1e3,U.ByHeight,i,0,0).to);if(t){let{head:e}=t.range;if(e<s.from||e>s.to){let n=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),a=r.lineAt(e,U.ByPos,i,0,0),o;o=t.y==`center`?(a.top+a.bottom)/2-n/2:t.y==`start`||t.y==`nearest`&&e<s.from?a.top:a.bottom-n,s=new fo(r.lineAt(o-1e3/2,U.ByHeight,i,0,0).from,r.lineAt(o+n+1e3/2,U.ByHeight,i,0,0).to)}}return s}mapViewport(e,t){let n=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new fo(this.heightMap.lineAt(n,U.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,U.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,U.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(t,U.ByPos,this.heightOracle,0,0),{visibleTop:a,visibleBottom:o}=this;return(e==0||r<=a-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||i>=o+Math.max(10,Math.min(n,250)))&&r>a-2*1e3&&i<o+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let r of e)t.touchesRange(r.from,r.to)||n.push(new co(t.mapPos(r.from),t.mapPos(r.to),r.size,r.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,r=n?1e4:2e3,i=r>>1,a=r<<1;if(this.defaultTextDirection!=L.LTR&&!n)return[];let o=[],s=(r,a,c,l)=>{if(a-r<i)return;let u=this.state.selection.main,d=[u.from];u.empty||d.push(u.to);for(let e of d)if(e>r&&e<a){s(r,e-10,c,l),s(e+10,a,c,l);return}let f=go(e,e=>e.from>=c.from&&e.to<=c.to&&Math.abs(e.from-r)<i&&Math.abs(e.to-a)<i&&!d.some(t=>e.from<t&&e.to>t));if(!f){if(a<c.to&&t&&n&&t.visibleRanges.some(e=>e.from<=a&&e.to>=a)){let e=t.moveToLineBoundary(E.cursor(a),!1,!0).head;e>r&&(a=e)}let e=this.gapSize(c,r,a,l);f=new co(r,a,e,n||e<2e6?e:2e6)}o.push(f)},c=t=>{if(t.length<a||t.type!=F.Text)return;let i=po(t.from,t.to,this.stateDeco);if(i.total<a)return;let o=this.scrollTarget?this.scrollTarget.range.head:null,c,l;if(n){let e=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,n,a;if(o!=null){let r=ho(i,o),s=((this.visibleBottom-this.visibleTop)/2+e)/t.height;n=r-s,a=r+s}else n=(this.visibleTop-t.top-e)/t.height,a=(this.visibleBottom-t.top+e)/t.height;c=mo(i,n),l=mo(i,a)}else{let n=i.total*this.heightOracle.charWidth,a=r*this.heightOracle.charWidth,s=0;if(n>2e6)for(let n of e)n.from>=t.from&&n.from<t.to&&n.size!=n.displaySize&&n.from*this.heightOracle.charWidth+s<this.pixelViewport.left&&(s=n.size-n.displaySize);let u=this.pixelViewport.left+s,d=this.pixelViewport.right+s,f,p;if(o!=null){let e=ho(i,o),t=((d-u)/2+a)/n;f=e-t,p=e+t}else f=(u-a)/n,p=(d+a)/n;c=mo(i,f),l=mo(i,p)}c>t.from&&s(t.from,c,t,i),l<t.to&&s(l,t.to,t,i)};for(let e of this.viewportLines)Array.isArray(e.type)?e.type.forEach(c):c(e);return o}gapSize(e,t,n,r){let i=ho(r,n)-ho(r,t);return this.heightOracle.lineWrapping?e.height*i:r.total*this.heightOracle.charWidth*i}updateLineGaps(e){co.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=I.set(e.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];j.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let r=0;if(n.length!=this.visibleRanges.length)r=12;else for(let t=0;t<n.length&&!(r&8);t++){let i=this.visibleRanges[t],a=n[t];(i.from!=a.from||i.to!=a.to)&&(r|=4,e&&e.mapPos(i.from,-1)==a.from&&e.mapPos(i.to,1)==a.to||(r|=8))}return this.visibleRanges=n,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||bo(this.heightMap.lineAt(e,U.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||bo(this.heightMap.lineAt(this.scaler.fromDOM(e),U.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return bo(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},fo=class{constructor(e,t){this.from=e,this.to=t}};function po(e,t,n){let r=[],i=e,a=0;return j.spans(n,e,t,{span(){},point(e,t){e>i&&(r.push({from:i,to:e}),a+=e-i),i=t}},20),i<t&&(r.push({from:i,to:t}),a+=t-i),{total:a,ranges:r}}function mo({total:e,ranges:t},n){if(n<=0)return t[0].from;if(n>=1)return t[t.length-1].to;let r=Math.floor(e*n);for(let e=0;;e++){let{from:n,to:i}=t[e],a=i-n;if(r<=a)return n+r;r-=a}}function ho(e,t){let n=0;for(let{from:r,to:i}of e.ranges){if(t<=i){n+=t-r;break}n+=i-r}return n/e.total}function go(e,t){for(let n of e)if(t(n))return n}var _o={toDOM(e){return e},fromDOM(e){return e},scale:1,eq(e){return e==this}};function vo(e){let t=e.facet(Fr).filter(e=>typeof e!=`function`),n=e.facet(Lr).filter(e=>typeof e!=`function`);return n.length&&t.push(j.join(n)),t}var yo=class e{constructor(e,t,n){let r=0,i=0,a=0;this.viewports=n.map(({from:n,to:i})=>{let a=t.lineAt(n,U.ByPos,e,0,0).top,o=t.lineAt(i,U.ByPos,e,0,0).bottom;return r+=o-a,{from:n,to:i,top:a,bottom:o,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let e of this.viewports)e.domTop=a+(e.top-i)*this.scale,a=e.domBottom=e.domTop+(e.bottom-e.top),i=e.bottom}toDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.top)return r+(e-n)*this.scale;if(e<=i.bottom)return i.domTop+(e-i.top);n=i.bottom,r=i.domBottom}}fromDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.domTop)return n+(e-r)/this.scale;if(e<=i.domBottom)return i.top+(e-i.domTop);n=i.bottom,r=i.domBottom}}eq(t){return t instanceof e?this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every((e,n)=>e.from==t.viewports[n].from&&e.to==t.viewports[n].to):!1}};function bo(e,t){if(t.scale==1)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new Ga(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(e=>bo(e,t)):e._content)}var xo=D.define({combine:e=>e.join(` `)}),So=D.define({combine:e=>e.indexOf(!0)>-1}),Co=Bt.newName(),wo=Bt.newName(),To=Bt.newName(),Eo={"&light":`.`+wo,"&dark":`.`+To};function Do(e,t,n){return new Bt(t,{finish(t){return/&/.test(t)?t.replace(/&\w*/,t=>{if(t==`&`)return e;if(!n||!n[t])throw RangeError(`Unsupported selector: ${t}`);return n[t]}):e+` `+t}})}var Oo=Do(`.`+Co,{"&":{position:`relative !important`,boxSizing:`border-box`,"&.cm-focused":{outline:`1px dotted #212121`},display:`flex !important`,flexDirection:`column`},".cm-scroller":{display:`flex !important`,alignItems:`flex-start !important`,fontFamily:`monospace`,lineHeight:1.4,height:`100%`,overflowX:`auto`,position:`relative`,zIndex:0,overflowAnchor:`none`},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:`block`,whiteSpace:`pre`,wordWrap:`normal`,boxSizing:`border-box`,minHeight:`100%`,padding:`4px 0`,outline:`none`,"&[contenteditable=true]":{WebkitUserModify:`read-write-plaintext-only`}},".cm-lineWrapping":{whiteSpace_fallback:`pre-wrap`,whiteSpace:`break-spaces`,wordBreak:`break-word`,overflowWrap:`anywhere`,flexShrink:1},"&light .cm-content":{caretColor:`black`},"&dark .cm-content":{caretColor:`white`},".cm-line":{display:`block`,padding:`0 2px 0 6px`},".cm-layer":{userSelect:`none`,position:`absolute`,left:0,top:0,contain:`size style`,"& > *":{position:`absolute`}},"&light .cm-selectionBackground":{background:`#d9d9d9`},"&dark .cm-selectionBackground":{background:`#222`},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:`#d7d4f0`},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:`#233`},".cm-cursorLayer":{pointerEvents:`none`},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:`steps(1) cm-blink 1.2s infinite`},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:`1.2px solid black`,marginLeft:`-0.6px`,pointerEvents:`none`},".cm-cursor":{display:`none`},"&dark .cm-cursor":{borderLeftColor:`#ddd`},".cm-selectionHandle":{backgroundColor:`currentColor`,width:`1.5px`},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:`""`,backgroundColor:`inherit`,borderRadius:`50%`,width:`8px`,height:`8px`,position:`absolute`,left:`-3.25px`},".cm-selectionHandle-start::before":{top:`-8px`},".cm-selectionHandle-end::before":{bottom:`-8px`},".cm-dropCursor":{position:`absolute`},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:`block`},".cm-iso":{unicodeBidi:`isolate`},".cm-announced":{position:`fixed`,top:`-10000px`},"@media print":{".cm-announced":{display:`none`}},"&light .cm-activeLine":{backgroundColor:`#cceeff44`},"&dark .cm-activeLine":{backgroundColor:`#99eeff33`},"&light .cm-specialChar":{color:`red`},"&dark .cm-specialChar":{color:`#f78`},".cm-gutters":{flexShrink:0,display:`flex`,height:`100%`,boxSizing:`border-box`,zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:`#f5f5f5`,color:`#6c6c6c`,border:`0px solid #ddd`,"&.cm-gutters-before":{borderRightWidth:`1px`},"&.cm-gutters-after":{borderLeftWidth:`1px`}},"&dark .cm-gutters":{backgroundColor:`#333338`,color:`#ccc`},".cm-gutter":{display:`flex !important`,flexDirection:`column`,flexShrink:0,boxSizing:`border-box`,minHeight:`100%`,overflow:`hidden`},".cm-gutterElement":{boxSizing:`border-box`},".cm-lineNumbers .cm-gutterElement":{padding:`0 3px 0 5px`,minWidth:`20px`,textAlign:`right`,whiteSpace:`nowrap`},"&light .cm-activeLineGutter":{backgroundColor:`#e2f2ff`},"&dark .cm-activeLineGutter":{backgroundColor:`#222227`},".cm-panels":{boxSizing:`border-box`,position:`sticky`,left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:`#f5f5f5`,color:`black`},"&light .cm-panels-top":{borderBottom:`1px solid #ddd`},"&light .cm-panels-bottom":{borderTop:`1px solid #ddd`},"&dark .cm-panels":{backgroundColor:`#333338`,color:`white`},".cm-dialog":{padding:`2px 19px 4px 6px`,position:`relative`,"& label":{fontSize:`80%`}},".cm-dialog-close":{position:`absolute`,top:`3px`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,fontSize:`14px`,padding:`0`},".cm-tab":{display:`inline-block`,overflow:`hidden`,verticalAlign:`bottom`},".cm-widgetBuffer":{verticalAlign:`text-top`,height:`1em`,width:0,display:`inline`},".cm-placeholder":{color:`#888`,display:`inline-block`,verticalAlign:`top`,userSelect:`none`},".cm-highlightSpace":{backgroundImage:`radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)`,backgroundPosition:`center`},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:`auto 100%`,backgroundPosition:`right 90%`,backgroundRepeat:`no-repeat`},".cm-trailingSpace":{backgroundColor:`#ff332255`},".cm-button":{verticalAlign:`middle`,color:`inherit`,fontSize:`70%`,padding:`.2em 1em`,borderRadius:`1px`},"&light .cm-button":{backgroundImage:`linear-gradient(#eff1f5, #d9d9df)`,border:`1px solid #888`,"&:active":{backgroundImage:`linear-gradient(#b4b4b4, #d0d3d6)`}},"&dark .cm-button":{backgroundImage:`linear-gradient(#393939, #111)`,border:`1px solid #888`,"&:active":{backgroundImage:`linear-gradient(#111, #333)`}},".cm-textfield":{verticalAlign:`middle`,color:`inherit`,fontSize:`70%`,border:`1px solid silver`,padding:`.2em .5em`},"&light .cm-textfield":{backgroundColor:`white`},"&dark .cm-textfield":{border:`1px solid #555`,backgroundColor:`inherit`}},Eo),ko={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Ao=P.ie&&P.ie_version<=11,jo=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Pn,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let e of t)this.queue.push(e);(P.ie&&P.ie_version<=11||P.ios&&e.composing)&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&P.android&&e.constructor.EDIT_CONTEXT!==!1&&!(P.chrome&&P.chrome_version<126)&&(this.editContext=new Fo(e),e.state.facet(Or)&&(e.contentDOM.editContext=this.editContext.editContext)),Ao&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia(`print`)),typeof ResizeObserver==`function`&&(this.resizeScroll=new ResizeObserver(()=>{this.view.docView?.lastUpdate<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver==`function`&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent(`Event`)))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent(`Event`))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers(`scroll`,e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type==`change`||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,r=this.selectionRange;if(n.state.facet(Or)?n.root.activeElement!=this.dom:!Sn(this.dom,r))return;let i=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);if(i&&i.isWidget()&&i.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(P.ie&&P.ie_version<=11||P.android&&P.chrome)&&!n.state.selection.main.empty&&r.focusNode&&wn(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=bn(e.root);if(!t)return!1;let n=P.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&Po(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=Sn(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&Vn(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(n.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||=this.scrollTargets.slice(0,e),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let e of this.scrollTargets)e.removeEventListener(`scroll`,this.onScroll);for(let e of this.scrollTargets=t)e.addEventListener(`scroll`,this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||=(this.observer.observe(this.dom,ko),Ao&&this.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Ao&&this.dom.removeEventListener(`DOMCharacterDataModified`,this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){if(!this.delayedAndroidKey){let e=()=>{let e=this.delayedAndroidKey;e&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&zn(this.dom,e.key,e.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}(!this.delayedAndroidKey||e==`Enter`)&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!this.delayedAndroidKey?.force})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,r=!1;for(let i of e){let e=this.readMutation(i);e&&(e.typeOver&&(r=!0),t==-1?{from:t,to:n}=e:(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&Sn(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let i=new Yi(this.view,e,t,n);return this.view.docView.domChanged={newSel:i.newSel?i.newSel.main:null},i}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,r=Zi(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!ra(this.view.state.selection,t.newSel.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type==`attributes`),e.type==`childList`){let n=Mo(t,e.previousSibling||e.target.previousSibling,-1),r=Mo(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else if(e.type==`characterData`)return{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue};else return null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener(`resize`,this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener(`change`,this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener(`beforeprint`,this.onPrint),e.addEventListener(`scroll`,this.onScroll),e.document.addEventListener(`selectionchange`,this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener(`scroll`,this.onScroll),e.removeEventListener(`resize`,this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener(`change`,this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener(`beforeprint`,this.onPrint),e.document.removeEventListener(`selectionchange`,this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Or)!=e.state.facet(Or)&&(e.view.contentDOM.editContext=e.state.facet(Or)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),(e=this.intersection)==null||e.disconnect(),(t=this.gapIntersection)==null||t.disconnect(),(n=this.resizeScroll)==null||n.disconnect();for(let e of this.scrollTargets)e.removeEventListener(`scroll`,this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function Mo(e,t,n){for(;t;){let r=B.get(t);if(r&&r.parent==e)return r;let i=t.parentNode;t=i==e.dom?n>0?t.nextSibling:t.previousSibling:i}return null}function No(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.docView.domAtPos(e.state.selection.main.anchor,1);return wn(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function Po(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return No(e,n)}let n=null;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener(`beforeinput`,r,!0),e.dom.ownerDocument.execCommand(`indent`),e.contentDOM.removeEventListener(`beforeinput`,r,!0),n?No(e,n):null}var Fo=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let r=e.state.selection.main,{anchor:i,head:a}=r,o=this.toEditorPos(n.updateRangeStart),s=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:o,drifted:!1});let c=s-o>n.text.length;o==this.from&&i<this.from?o=i:s==this.to&&i>this.to&&(s=i);let l=ea(e.state.sliceDoc(o,s),n.text,(c?r.from:r.to)-o,c?`end`:null);if(!l){let t=E.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));ra(t,r)||e.dispatch({selection:t,userEvent:`select`});return}let u={from:l.from+o,to:l.toA+o,insert:S.of(n.text.slice(l.from,l.toB).split(`
|
|
29
|
-
`))};if((P.mac||P.android)&&u.from==a-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute(`autocorrect`)==`off`&&(u={from:o,to:s,insert:S.of([n.text.replace(`.`,` `)])}),this.pendingContextChange=u,!e.state.readOnly){let t=this.to-this.from+(u.to-u.from+u.insert.length);Qi(e,u,E.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from<u.to&&!u.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],i=null;for(let t=this.toEditorPos(n.rangeStart),a=this.toEditorPos(n.rangeEnd);t<a;t++){let n=e.coordsForChar(t);i=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||i||new DOMRect,r.push(i)}t.updateCharacterBounds(n.rangeStart,r)},this.handlers.textformatupdate=t=>{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,r=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(r)){let i=this.toEditorPos(e.rangeStart),a=this.toEditorPos(e.rangeEnd);if(i<a){let e=`text-decoration: underline ${/^[a-z]/.test(t)?t+` `:t==`Dashed`?`dashed `:t==`Squiggle`?`wavy `:``}${/thin/i.test(r)?1:2}px`;n.push(I.mark({attributes:{style:e}}).range(i,a))}}}e.dispatch({effects:Dr.of(I.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=bn(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((i,a,o,s,c)=>{if(n)return;let l=c.length-(a-i);if(r&&a>=r.to)if(r.from==i&&r.to==a&&r.insert.eq(c)){r=this.pendingContextChange=null,t+=l,this.to+=l;return}else r=null,this.revertPending(e.state);if(i+=t,a+=t,a<=this.from)this.from+=l,this.to+=l;else if(i<this.to){if(i<this.from||a>this.to||this.to-this.from+c.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(i),this.toContextPos(a),c.toString()),this.to+=l}t+=l}),r&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(e=>!e.isUserEvent(`input.type`)&&e.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(n,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},W=class e{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement(`div`),this.scrollDOM=document.createElement(`div`),this.scrollDOM.tabIndex=-1,this.scrollDOM.className=`cm-scroller`,this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement(`div`),this.announceDOM.className=`cm-announced`,this.announceDOM.setAttribute(`aria-live`,`polite`),this.dom=document.createElement(`div`),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(e=>e.forEach(e=>t(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Bn(e.parent)||document,this.viewState=new uo(this,e.state||A.create(e)),e.scrollTo&&e.scrollTo.is(Er)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ar).map(e=>new Mr(e));for(let e of this.plugins)e.update(this);this.observer=new jo(this),this.inputState=new ia(this),this.inputState.ensureHandlers(this.plugins),this.docView=new vi(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),document.fonts?.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent=`refresh`,this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof k?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(t){if(this.updateState!=0)throw Error(`Calls to EditorView.update are not allowed while an update is in progress`);let n=!1,r=!1,i,a=this.state;for(let e of t){if(e.startState!=a)throw RangeError(`Trying to update state with a transaction that doesn't start from the previous state.`);a=e.state}if(this.destroyed){this.viewState.state=a;return}let o=this.hasFocus,s=0,c=null;t.some(e=>e.annotation(Fa))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,c=Ia(a,o),c||(s=1));let l=this.observer.delayedAndroidKey,u=null;if(l?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(u=null)):this.observer.clear(),a.facet(A.phrases)!=this.state.facet(A.phrases))return this.setState(a);i=Gr.create(this,a,t),i.flags|=s;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let n of t){if(d&&=d.map(n.changes),n.scrollIntoView){let{main:t}=n.state.selection,{x:r,y:i}=this.state.facet(e.cursorScrollMargin);d=new Tr(t.empty?t:E.cursor(t.head,t.head>t.anchor?-1:1),`nearest`,`nearest`,i,r)}for(let e of n.effects)e.is(Er)&&(d=e.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=Ro.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(Ur)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(e=>e.isUserEvent(`select.pointer`)))}finally{this.updateState=0}if(i.startState.facet(xo)!=i.state.facet(xo)&&(this.viewState.mustMeasureContent=!0),(n||r||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let e of this.state.facet(_r))try{e(i)}catch(e){z(this.state,e,`update listener`)}(c||u)&&Promise.resolve().then(()=>{c&&this.state==c.startState&&this.dispatch(c),u&&!Zi(this,u)&&l.force&&zn(this.contentDOM,l.key,l.keyCode)})}setState(e){if(this.updateState!=0)throw Error(`Calls to EditorView.setState are not allowed while an update is in progress`);if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new uo(this,e),this.plugins=e.facet(Ar).map(e=>new Mr(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new vi(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Ar),n=e.state.facet(Ar);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new Mr(i));else{let t=this.plugins[n];t.mustUpdate=e,r.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(e){z(this.state,e,`doc view update listener`)}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:i,scrollAnchorHeight:a}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(a<0)if(Hn(n||this.win))i=-1,a=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(r);i=e.from,a=e.top}this.updateState=1;let o=this.viewState.measure();if(!o&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(e>5){console.warn(this.measureRequests.length?`Measure loop restarted more than 5 times`:`Viewport failed to stabilize`);break}let s=[];o&4||([this.measureRequests,s]=[s,this.measureRequests]);let c=s.map(e=>{try{return e.read(this)}catch(e){return z(this.state,e),Lo}}),l=Gr.create(this,this.state,[]),u=!1;l.flags|=o,t?t.flags|=o:t=l,this.updateState=2,l.empty||(this.updatePlugins(l),this.inputState.update(l),this.updateAttrs(),u=this.docView.update(l),u&&this.docViewUpdate());for(let e=0;e<s.length;e++)if(c[e]!=Lo)try{let t=s[e];t.write&&t.write(c[e],this)}catch(e){z(this.state,e)}if(u&&this.docView.updateSelection(!0),!l.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,a=-1;continue}else{let e=((i<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(i).top)-a)/this.scaleY;if((e>1||e<-1)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r+=e,n?n.scrollTop+=e:this.win.scrollBy(0,e),a=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(_r))e(t)}get themeClasses(){return Co+` `+(this.state.facet(So)?To:wo)+` `+this.state.facet(xo)}updateAttrs(){let e=zo(this,Nr,{class:`cm-editor`+(this.hasFocus?` cm-focused `:` `)+this.themeClasses}),t={spellcheck:`false`,autocorrect:`off`,autocapitalize:`off`,writingsuggestions:`false`,translate:`no`,contenteditable:this.state.facet(Or)?`true`:`false`,class:`cm-content`,style:`${P.tabSize}: ${this.state.tabSize}`,role:`textbox`,"aria-multiline":`true`};this.state.readOnly&&(t[`aria-readonly`]=`true`),zo(this,Pr,t);let n=this.observer.ignore(()=>{let n=un(this.contentDOM,this.contentAttrs,t),r=un(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(t){let n=!0;for(let r of t)for(let t of r.effects)if(t.is(e.announce)){n&&(this.announceDOM.textContent=``),n=!1;let e=this.announceDOM.appendChild(document.createElement(`div`));e.textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(Ur);let t=this.state.facet(e.cspNonce);Bt.mount(this.root,this.styleModules.concat(Oo).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw Error(`Reading the editor layout isn't allowed during an update`);this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(t=>t.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return Bi(this,e,Fi(this,e,t,n))}moveByGroup(e,t){return Bi(this,e,Fi(this,e,t,t=>Ii(this,e.head,t)))}visualLineSide(e,t){let n=this.bidiSpans(e),r=this.textDirectionAt(e.from),i=n[t?n.length-1:0];return E.cursor(i.side(t,r)+e.from,i.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,n=!0){return Pi(this,e,t,n)}moveVertically(e,t,n){return Bi(this,e,Li(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=Hi(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),Hi(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let r=this.state.doc.lineAt(e),i=this.bidiSpans(r),a=i[tr.find(i,e-r.from,-1,t)];return kn(n,a.dir==L.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(Sr)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Io)return lr(e.length);let t=this.textDirectionAt(e.from),n;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||nr(r.isolates,n=Br(this,e))))return r.order;n||=Br(this,e);let r=cr(e.text,t,n);return this.bidiCache.push(new Ro(e.from,e.to,t,n,!0,r)),r}get hasFocus(){return(this.dom.ownerDocument.hasFocus()||P.safari&&this.inputState?.lastContextMenu>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{In(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Er.of(new Tr(typeof e==`number`?E.cursor(e):e,t.y??`nearest`,t.x??`nearest`,t.yMargin??5,t.xMargin??5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return Er.of(new Tr(E.cursor(n.from),`start`,`start`,n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e==`boolean`?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return jr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return jr.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=Bt.newName(),r=[xo.of(n),Ur.of(Do(`.${n}`,e))];return t&&t.dark&&r.push(So.of(!0)),r}static baseTheme(e){return ze.lowest(Ur.of(Do(`.`+Co,e,Eo)))}static findFromDOM(e){let t=e.querySelector(`.cm-content`);return(t&&B.get(t)||B.get(e))?.root?.view||null}};W.styleModule=Ur,W.inputHandler=vr,W.clipboardInputFilter=br,W.clipboardOutputFilter=xr,W.scrollHandler=wr,W.focusChangeEffect=yr,W.perLineTextDirection=Sr,W.exceptionSink=gr,W.updateListener=_r,W.editable=Or,W.mouseSelectionStyle=hr,W.dragMovesSelection=mr,W.clickAddsSelectionRange=pr,W.decorations=Fr,W.blockWrappers=Ir,W.outerDecorations=Lr,W.atomicRanges=Rr,W.bidiIsolatedRanges=zr,W.cursorScrollMargin=D.define({combine:e=>{let t=5,n=5;for(let r of e)typeof r==`number`?t=n=r:{x:t,y:n}=r;return{x:t,y:n}}}),W.scrollMargins=Vr,W.darkTheme=So,W.cspNonce=D.define({combine:e=>e.length?e[0]:``}),W.contentAttributes=Pr,W.editorAttributes=Nr,W.lineWrapping=W.contentAttributes.of({class:`cm-lineWrapping`}),W.announce=O.define();var Io=4096,Lo={},Ro=class e{constructor(e,t,n,r,i,a){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=i,this.order=a}static update(t,n){if(n.empty&&!t.some(e=>e.fresh))return t;let r=[],i=t.length?t[t.length-1].dir:L.LTR;for(let a=Math.max(0,t.length-10);a<t.length;a++){let o=t[a];o.dir==i&&!n.touchesRange(o.from,o.to)&&r.push(new e(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}};function zo(e,t,n){for(let r=e.state.facet(t),i=r.length-1;i>=0;i--){let t=r[i],a=typeof t==`function`?t(e):t;a&&on(a,n)}return n}var Bo=P.mac?`mac`:P.windows?`win`:P.linux?`linux`:`key`;function Vo(e,t){let n=e.split(/-(?!$)/),r=n[n.length-1];r==`Space`&&(r=` `);let i,a,o,s;for(let e=0;e<n.length-1;++e){let r=n[e];if(/^(cmd|meta|m)$/i.test(r))s=!0;else if(/^a(lt)?$/i.test(r))i=!0;else if(/^(c|ctrl|control)$/i.test(r))a=!0;else if(/^s(hift)?$/i.test(r))o=!0;else if(/^mod$/i.test(r))t==`mac`?s=!0:a=!0;else throw Error(`Unrecognized modifier name: `+r)}return i&&(r=`Alt-`+r),a&&(r=`Ctrl-`+r),s&&(r=`Meta-`+r),o&&(r=`Shift-`+r),r}function Ho(e,t,n){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n!==!1&&t.shiftKey&&(e=`Shift-`+e),e}var Uo=ze.default(W.domEventHandlers({keydown(e,t){return Zo(Ko(t.state),e,t,`editor`)}})),Wo=D.define({enables:Uo}),Go=new WeakMap;function Ko(e){let t=e.facet(Wo),n=Go.get(t);return n||Go.set(t,n=Yo(t.reduce((e,t)=>e.concat(t),[]))),n}var qo=null,Jo=4e3;function Yo(e,t=Bo){let n=Object.create(null),r=Object.create(null),i=(e,t)=>{let n=r[e];if(n==null)r[e]=t;else if(n!=t)throw Error(`Key binding `+e+` is used both as a regular binding and as a multi-stroke prefix`)},a=(e,r,a,o,s)=>{let c=n[e]||(n[e]=Object.create(null)),l=r.split(/ (?!$)/).map(e=>Vo(e,t));for(let t=1;t<l.length;t++){let n=l.slice(0,t).join(` `);i(n,!0),c[n]||(c[n]={preventDefault:!0,stopPropagation:!1,run:[t=>{let r=qo={view:t,prefix:n,scope:e};return setTimeout(()=>{qo==r&&(qo=null)},Jo),!0}]})}let u=l.join(` `);i(u,!1);let d=c[u]||(c[u]={preventDefault:!1,stopPropagation:!1,run:(c._any?.run)?.slice()||[]});a&&d.run.push(a),o&&(d.preventDefault=!0),s&&(d.stopPropagation=!0)};for(let r of e){let e=r.scope?r.scope.split(` `):[`editor`];if(r.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||={preventDefault:!1,stopPropagation:!1,run:[]};let{any:i}=r;for(let t in e)e[t].run.push(e=>i(e,Xo))}let i=r[t]||r.key;if(i)for(let t of e)a(t,i,r.run,r.preventDefault,r.stopPropagation),r.shift&&a(t,`Shift-`+i,r.shift,r.preventDefault,r.stopPropagation)}return n}var Xo=null;function Zo(e,t,n,r){Xo=t;let i=Jt(t),a=_e(he(i,0))==i.length&&i!=` `,o=``,s=!1,c=!1,l=!1;qo&&qo.view==n&&qo.scope==r&&(o=qo.prefix+` `,la.indexOf(t.keyCode)<0&&(c=!0,qo=null));let u=new Set,d=e=>{if(e){for(let t of e.run)if(!u.has(t)&&(u.add(t),t(n)))return e.stopPropagation&&(l=!0),!0;e.preventDefault&&(e.stopPropagation&&(l=!0),c=!0)}return!1},f=e[r],p,m;return f&&(d(f[o+Ho(i,t,!a)])?s=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(P.windows&&t.ctrlKey&&t.altKey)&&!(P.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=Ut[t.keyCode])&&p!=i?(d(f[o+Ho(p,t,!0)])||t.shiftKey&&(m=Wt[t.keyCode])!=i&&m!=p&&d(f[o+Ho(m,t,!1)]))&&(s=!0):a&&t.shiftKey&&d(f[o+Ho(i,t,!0)])&&(s=!0),!s&&d(f._any)&&(s=!0)),c&&(s=!0),s&&l&&t.stopPropagation(),Xo=null,s}var Qo=class e{constructor(e,t,n,r,i){this.className=e,this.left=t,this.top=n,this.width=r,this.height=i}draw(){let e=document.createElement(`div`);return e.className=this.className,this.adjust(e),e}update(e,t){return t.className==this.className?(this.adjust(e),!0):!1}adjust(e){e.style.left=this.left+`px`,e.style.top=this.top+`px`,this.width!=null&&(e.style.width=this.width+`px`),e.style.height=this.height+`px`}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(t,n,r){if(r.empty){let i=t.coordsAtPos(r.head,r.assoc||1);if(!i)return[];let a=$o(t);return[new e(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}else return ts(t,n,r)}};function $o(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==L.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function es(e,t,n,r){let i=e.coordsAtPos(t,n*2);if(!i)return r;let a=e.dom.getBoundingClientRect(),o=(i.top+i.bottom)/2,s=e.posAtCoords({x:a.left+1,y:o}),c=e.posAtCoords({x:a.right-1,y:o});return s==null||c==null?r:{from:Math.max(r.from,Math.min(s,c)),to:Math.min(r.to,Math.max(s,c))}}function ts(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let r=Math.max(n.from,e.viewport.from),i=Math.min(n.to,e.viewport.to),a=e.textDirection==L.LTR,o=e.contentDOM,s=o.getBoundingClientRect(),c=$o(e),l=o.querySelector(`.cm-line`),u=l&&window.getComputedStyle(l),d=s.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),f=s.right-(u?parseInt(u.paddingRight):0),p=Ni(e,r,1),m=Ni(e,i,-1),h=p.type==F.Text?p:null,g=m.type==F.Text?m:null;if(h&&(e.lineWrapping||p.widgetLineBreaks)&&(h=es(e,r,1,h)),g&&(e.lineWrapping||m.widgetLineBreaks)&&(g=es(e,i,-1,g)),h&&g&&h.from==g.from&&h.to==g.to)return v(y(n.from,n.to,h));{let t=h?y(n.from,null,h):ee(p,!1),r=g?y(null,n.to,g):ee(m,!0),i=[];return(h||p).to<(g||m).from-(h&&g?1:0)||p.widgetLineBreaks>1&&t.bottom+e.defaultLineHeight/2<r.top?i.push(_(d,t.bottom,f,r.top)):t.bottom<r.top&&e.elementAtHeight((t.bottom+r.top)/2).type==F.Text&&(t.bottom=r.top=(t.bottom+r.top)/2),v(t).concat(i).concat(v(r))}function _(e,n,r,i){return new Qo(t,e-c.left,n-c.top,Math.max(0,r-e),i-n)}function v({top:e,bottom:t,horizontal:n}){let r=[];for(let i=0;i<n.length;i+=2)r.push(_(n[i],e,n[i+1],t));return r}function y(t,n,r){let i=1e9,o=-1e9,s=[];function c(t,n,c,l,u){let p=e.coordsAtPos(t,t==r.to?-2:2),m=e.coordsAtPos(c,c==r.from?2:-2);!p||!m||(i=Math.min(p.top,m.top,i),o=Math.max(p.bottom,m.bottom,o),u==L.LTR?s.push(a&&n?d:p.left,a&&l?f:m.right):s.push(!a&&l?d:m.left,!a&&n?f:p.right))}let l=t??r.from,u=n??r.to;for(let r of e.visibleRanges)if(r.to>l&&r.from<u)for(let i=Math.max(r.from,l),a=Math.min(r.to,u);;){let r=e.state.doc.lineAt(i);for(let o of e.bidiSpans(r)){let e=o.from+r.from,s=o.to+r.from;if(e>=a)break;s>i&&c(Math.max(e,i),t==null&&e<=l,Math.min(s,a),n==null&&s>=u,o.dir)}if(i=r.to+1,i>=a)break}return s.length==0&&c(l,t==null,u,n==null,e.textDirection),{top:i,bottom:o,horizontal:s}}function ee(e,t){let n=s.top+(t?e.top:e.bottom);return{top:n,bottom:n,horizontal:[]}}}function ns(e,t){return e.constructor==t.constructor&&e.eq(t)}var rs=class{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement(`div`)),this.dom.classList.add(`cm-layer`),t.above&&this.dom.classList.add(`cm-layer-above`),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute(`aria-hidden`,`true`),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(is)!=e.state.facet(is)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(is);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((e,t)=>!ns(e,this.drawn[t]))){let t=this.dom.firstChild,n=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[n].constructor&&r.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(r.draw(),t);for(;t;){let e=t.nextSibling;t.remove(),t=e}this.drawn=e,P.webkit&&(this.dom.style.display=this.dom.firstChild?``:`none`)}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},is=D.define();function as(e){return[jr.define(t=>new rs(t,e)),is.of(e)]}var os=D.define({combine(e){return gt(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function ss(e={}){return[os.of(e),ls,ds,fs,Cr.of(!0)]}function cs(e){return e.startState.facet(os)!=e.state.facet(os)}var ls=as({above:!0,markers(e){let{state:t}=e,n=t.facet(os),r=[];for(let i of t.selection.ranges){let a=i==t.selection.main;if(i.empty||n.drawRangeCursor&&!(a&&P.ios&&n.iosSelectionHandles)){let t=a?`cm-cursor cm-cursor-primary`:`cm-cursor cm-cursor-secondary`,n=i.empty?i:E.cursor(i.head,i.assoc);for(let i of Qo.forRange(e,t,n))r.push(i)}}return r},update(e,t){e.transactions.some(e=>e.selection)&&(t.style.animationName=t.style.animationName==`cm-blink`?`cm-blink2`:`cm-blink`);let n=cs(e);return n&&us(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){us(t.state,e)},class:`cm-cursorLayer`});function us(e,t){t.style.animationDuration=e.facet(os).cursorBlinkRate+`ms`}var ds=as({above:!1,markers(e){let t=[],{main:n,ranges:r}=e.state.selection;for(let n of r)if(!n.empty)for(let r of Qo.forRange(e,`cm-selectionBackground`,n))t.push(r);if(P.ios&&!n.empty&&e.state.facet(os).iosSelectionHandles){for(let r of Qo.forRange(e,`cm-selectionHandle cm-selectionHandle-start`,E.cursor(n.from,1)))t.push(r);for(let r of Qo.forRange(e,`cm-selectionHandle cm-selectionHandle-end`,E.cursor(n.to,1)))t.push(r)}return t},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||cs(e)},class:`cm-selectionLayer`}),fs=ze.highest(W.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`transparent !important`},caretColor:`transparent !important`},".cm-content":{caretColor:`transparent !important`,"& :focus":{caretColor:`initial !important`,"&::selection, & ::selection":{backgroundColor:`Highlight !important`}}}}));/x/.unicode;var ps=class extends fn{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement(`span`);return t.className=`cm-placeholder`,t.style.pointerEvents=`none`,t.appendChild(typeof this.content==`string`?document.createTextNode(this.content):typeof this.content==`function`?this.content(e):this.content.cloneNode(!0)),t.setAttribute(`aria-hidden`,`true`),t}coordsAt(e){let t=e.firstChild?Cn(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),r=kn(t[0],n.direction!=`rtl`),i=parseInt(n.lineHeight);return r.bottom-r.top>i*1.5?{left:r.left,right:r.right,top:r.top,bottom:r.top+i}:r}ignoreEvent(){return!1}};function ms(e){let t=jr.fromClass(class{constructor(t){this.view=t,this.placeholder=e?I.set([I.widget({widget:new ps(e),side:1}).range(0)]):I.none}get decorations(){return this.view.state.doc.length?I.none:this.placeholder}},{decorations:e=>e.decorations});return typeof e==`string`?[t,W.contentAttributes.of({"aria-placeholder":e})]:t}var hs=`-10000px`,gs=class{constructor(e,t,n,r){this.facet=t,this.createTooltipView=n,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let i=null;this.tooltipViews=this.tooltips.map(e=>i=n(e,i))}update(e,t){var n;let r=e.state.facet(this.facet),i=r.filter(e=>e);if(r===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let a=[],o=t?[]:null;for(let n=0;n<i.length;n++){let r=i[n],s=-1;if(r){for(let e=0;e<this.tooltips.length;e++){let t=this.tooltips[e];t&&t.create==r.create&&(s=e)}if(s<0)a[n]=this.createTooltipView(r,n?a[n-1]:null),o&&(o[n]=!!r.above);else{let r=a[n]=this.tooltipViews[s];o&&(o[n]=t[s]),r.update&&r.update(e)}}}for(let e of this.tooltipViews)a.indexOf(e)<0&&(this.removeTooltipView(e),(n=e.destroy)==null||n.call(e));return t&&(o.forEach((e,n)=>t[n]=e),t.length=o.length),this.input=r,this.tooltips=i,this.tooltipViews=a,!0}};function _s(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}var vs=D.define({combine:e=>({position:P.ios?`absolute`:e.find(e=>e.position)?.position||`fixed`,parent:e.find(e=>e.parent)?.parent||null,tooltipSpace:e.find(e=>e.tooltipSpace)?.tooltipSpace||_s})}),ys=new WeakMap,bs=jr.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(vs);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver==`function`?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new gs(e,ws,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver=typeof IntersectionObserver==`function`?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.win.addEventListener(`resize`,this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement(`div`),this.container.style.position=`relative`,this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,r=e.state.facet(vs);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let e of this.manager.tooltipViews)e.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let e of this.manager.tooltipViews)this.container.appendChild(e.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add(`cm-tooltip`),e.arrow&&!n.dom.querySelector(`.cm-tooltip > .cm-tooltip-arrow`)){let e=document.createElement(`div`);e.className=`cm-tooltip-arrow`,n.dom.appendChild(e)}return n.dom.style.position=this.position,n.dom.style.top=hs,n.dom.style.left=`0px`,this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener(`resize`,this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),(e=t.destroy)==null||e.call(t);this.parent&&this.container.remove(),(t=this.resizeObserver)==null||t.disconnect(),(n=this.intersectionObserver)==null||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if(this.position==`fixed`&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(P.safari){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}else n=!!e.offsetParent&&e.offsetParent!=this.container.ownerDocument.body}if(n||this.position==`absolute`)if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else ({scaleX:e,scaleY:t}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=Hr(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((e,t)=>{let n=this.manager.tooltipViews[t];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(vs).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){if(e.makeAbsolute){this.madeAbsolute=!0,this.position=`absolute`;for(let e of this.manager.tooltipViews)e.dom.style.position=`absolute`}let{visible:t,space:n,scaleX:r,scaleY:i}=e,a=[];for(let o=0;o<this.manager.tooltips.length;o++){let s=this.manager.tooltips[o],c=this.manager.tooltipViews[o],{dom:l}=c,u=e.pos[o],d=e.size[o];if(!u||s.clip!==!1&&(u.bottom<=Math.max(t.top,n.top)||u.top>=Math.min(t.bottom,n.bottom)||u.right<Math.max(t.left,n.left)-.1||u.left>Math.min(t.right,n.right)+.1)){l.style.top=hs;continue}let f=s.arrow?c.dom.querySelector(`.cm-tooltip-arrow`):null,p=f?7:0,m=d.right-d.left,h=ys.get(c)??d.bottom-d.top,g=c.offset||Cs,_=this.view.textDirection==L.LTR,v=d.width>n.right-n.left?_?n.left:n.right-d.width:_?Math.max(n.left,Math.min(u.left-(f?14:0)+g.x,n.right-m)):Math.min(Math.max(n.left,u.left-m+(f?14:0)-g.x),n.right-m),y=this.above[o];!s.strictSide&&(y?u.top-h-p-g.y<n.top:u.bottom+h+p+g.y>n.bottom)&&y==n.bottom-u.bottom>u.top-n.top&&(y=this.above[o]=!y);let ee=(y?u.top-n.top:n.bottom-u.bottom)-p;if(ee<h&&c.resize!==!1){if(ee<this.view.defaultLineHeight){l.style.top=hs;continue}ys.set(c,h),l.style.height=(h=ee)/i+`px`}else l.style.height&&(l.style.height=``);let b=y?u.top-h-p-g.y:u.bottom+p+g.y,x=v+m;if(c.overlap!==!0)for(let e of a)e.left<x&&e.right>v&&e.top<b+h&&e.bottom>b&&(b=y?e.top-h-2-p:e.bottom+p+2);if(this.position==`absolute`?(l.style.top=(b-e.parent.top)/i+`px`,xs(l,(v-e.parent.left)/r)):(l.style.top=b/i+`px`,xs(l,v/r)),f){let e=u.left+(_?g.x:-g.x)-(v+14-7);f.style.left=e/r+`px`}c.overlap!==!0&&a.push({left:v,top:b,right:x,bottom:b+h}),l.classList.toggle(`cm-tooltip-above`,y),l.classList.toggle(`cm-tooltip-below`,!y),c.positioned&&c.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=hs}},{eventObservers:{scroll(){this.maybeMeasure()}}});function xs(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+`px`)}var Ss=W.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:`border-box`},"&light .cm-tooltip":{border:`1px solid #bbb`,backgroundColor:`#f5f5f5`},"&light .cm-tooltip-section:not(:first-child)":{borderTop:`1px solid #bbb`},"&dark .cm-tooltip":{backgroundColor:`#333338`,color:`white`},".cm-tooltip-arrow":{height:`7px`,width:`14px`,position:`absolute`,zIndex:-1,overflow:`hidden`,"&:before, &:after":{content:`''`,position:`absolute`,width:0,height:0,borderLeft:`7px solid transparent`,borderRight:`7px solid transparent`},".cm-tooltip-above &":{bottom:`-7px`,"&:before":{borderTop:`7px solid #bbb`},"&:after":{borderTop:`7px solid #f5f5f5`,bottom:`1px`}},".cm-tooltip-below &":{top:`-7px`,"&:before":{borderBottom:`7px solid #bbb`},"&:after":{borderBottom:`7px solid #f5f5f5`,top:`1px`}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:`#333338`,borderBottomColor:`#333338`},"&:after":{borderTopColor:`transparent`,borderBottomColor:`transparent`}}}),Cs={x:0,y:0},ws=D.define({enables:[bs,Ss]});function Ts(e,t){let n=e.plugin(bs);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}var Es=class extends _t{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};Es.prototype.elementClass=``,Es.prototype.toDOM=void 0,Es.prototype.mapMode=ye.TrackBefore,Es.prototype.startSide=Es.prototype.endSide=-1,Es.prototype.point=!0;var Ds=1024,Os=0,ks=class{constructor(e,t){this.from=e,this.to=t}},G=class{constructor(e={}){this.id=Os++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error(`This node type doesn't define a deserialize function`)}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError(`Can't add per-node props to node types`);return typeof e!=`function`&&(e=Ms.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};G.closedBy=new G({deserialize:e=>e.split(` `)}),G.openedBy=new G({deserialize:e=>e.split(` `)}),G.group=new G({deserialize:e=>e.split(` `)}),G.isolate=new G({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),G.contextHash=new G({perNode:!0}),G.lookAhead=new G({perNode:!0}),G.mounted=new G({perNode:!0});var As=class{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[G.mounted.id]}},js=Object.create(null),Ms=class e{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(t){let n=t.props&&t.props.length?Object.create(null):js,r=!!t.top|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new e(t.name||``,n,t.id,r);if(t.props){for(let e of t.props)if(Array.isArray(e)||(e=e(i)),e){if(e[0].perNode)throw RangeError(`Can't store a per-node prop on a node type`);n[e[0].id]=e[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e==`string`){if(this.name==e)return!0;let t=this.prop(G.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(` `))t[r]=e[n];return e=>{for(let n=e.prop(G.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};Ms.none=new Ms(``,Object.create(null),0,8);var Ns=new WeakMap,Ps=new WeakMap,K;(function(e){e[e.ExcludeBuffers=1]=`ExcludeBuffers`,e[e.IncludeAnonymous=2]=`IncludeAnonymous`,e[e.IgnoreMounts=4]=`IgnoreMounts`,e[e.IgnoreOverlays=8]=`IgnoreOverlays`,e[e.EnterBracketed=16]=`EnterBracketed`})(K||={});var q=class e{constructor(e,t,n,r,i){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props[typeof e==`number`?e:e.id]=t}}toString(){let e=As.get(this);if(e&&!e.overlay)return e.tree.toString();let t=``;for(let e of this.children){let n=e.toString();n&&(t&&(t+=`,`),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?`(`+t+`)`:``):t}cursor(e=0){return new Js(this.topNode,e)}cursorAt(e,t=0,n=0){let r=new Js(Ns.get(this)||this.topNode);return r.moveTo(e,t),Ns.set(this,r._tree),r}get topNode(){return new Bs(this,0,0,null)}resolve(e,t=0){let n=Rs(Ns.get(this)||this.topNode,e,t,!1);return Ns.set(this,n),n}resolveInner(e,t=0){let n=Rs(Ps.get(this)||this.topNode,e,t,!0);return Ps.set(this,n),n}resolveStack(e,t=0){return qs(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,a=e.mode||0,o=(a&K.IncludeAnonymous)>0;for(let e=this.cursor(a|K.IncludeAnonymous);;){let a=!1;if(e.from<=i&&e.to>=r&&(!o&&e.type.isAnonymous||t(e)!==!1)){if(e.firstChild())continue;a=!0}for(;a&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;a=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(t={}){return this.children.length<=8?this:$s(Ms.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new e(this.type,t,n,r,this.propValues),t.makeTree||((t,n,r)=>new e(Ms.none,t,n,r)))}static build(e){return Xs(e)}};q.empty=new q(Ms.none,[],[],0);var Fs=class e{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new e(this.buffer,this.index)}},Is=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return Ms.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(`,`)}childString(e){let t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),e+=4,n==e)return i;let a=[];for(;e<n;)a.push(this.childString(e)),e=this.buffer[e+3];return i+`(`+a.join(`,`)+`)`}findChild(e,t,n,r,i){let{buffer:a}=this,o=-1;for(let s=e;s!=t&&!(Ls(i,r,a[s+1],a[s+2])&&(o=s,n>0));s=a[s+3]);return o}slice(t,n,r){let i=this.buffer,a=new Uint16Array(n-t),o=0;for(let e=t,s=0;e<n;){a[s++]=i[e++],a[s++]=i[e++]-r;let n=a[s++]=i[e++]-r;a[s++]=i[e++]-t,o=Math.max(o,n)}return new e(a,o,this.set)}};function Ls(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function Rs(e,t,n,r){for(;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!r&&e instanceof Bs&&e.index<0?null:e.parent;if(!t)return e;e=t}let i=r?0:K.IgnoreOverlays;if(r)for(let r=e,a=r.parent;a;r=a,a=r.parent)r instanceof Bs&&r.index<0&&a.enter(t,n,i)?.from!=r.from&&(e=a);for(;;){let r=e.enter(t,n,i);if(!r)return e;e=r}}var zs=class{cursor(e=0){return new Js(this,e)}getChild(e,t=null,n=null){let r=Vs(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return Vs(this,e,t,n)}resolve(e,t=0){return Rs(this,e,t,!1)}resolveInner(e,t=0){return Rs(this,e,t,!0)}matchContext(e){return Hs(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}},Bs=class e extends zs{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,n,r,i,a=0){for(let o=this;;){for(let{children:s,positions:c}=o._tree,l=n>0?s.length:-1;t!=l;t+=n){let l=s[t],u=c[t]+o.from,d;if(!(!(a&K.EnterBracketed&&l instanceof q&&(d=As.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length)&&!Ls(i,r,u,u+l.length))){if(l instanceof Is){if(a&K.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new Ws(new Us(o,l,t,u),null,e)}else if(a&K.IncludeAnonymous||!l.type.isAnonymous||Ys(l)){let s;if(!(a&K.IgnoreMounts)&&(s=As.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&K.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&K.IncludeAnonymous||!o.type.isAnonymous||(t=o.index>=0?o.index+n:n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(t,n,r=0){let i;if(!(r&K.IgnoreOverlays)&&(i=As.get(this._tree))&&i.overlay){let a=t-this.from,o=r&K.EnterBracketed&&i.bracketed;for(let{from:t,to:r}of i.overlay)if((n>0||o?t<=a:t<a)&&(n<0||o?r>=a:r>a))return new e(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function Vs(e,t,n,r){let i=e.cursor(),a=[];if(!i.firstChild())return a;if(n!=null){for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return a}for(;;){if(r!=null&&i.type.is(r))return a;if(i.type.is(t)&&a.push(i.node),!i.nextSibling())return r==null?a:[]}}function Hs(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}var Us=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},Ws=class e extends zs{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(t,n,r){let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return a<0?null:new e(this.context,this,a)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(t,n,r=0){if(r&K.ExcludeBuffers)return null;let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return a<0?null:new e(this.context,this,a)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new e(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new e(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let a=n.buffer[this.index+1];e.push(n.slice(r,i,a)),t.push(0)}return new q(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function Gs(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;r<e.length;r++){let i=e[r];(i.from>n.from||i.to<n.to)&&(n=i,t=r)}let r=n instanceof Bs&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new Ks(i,n)}var Ks=class{constructor(e,t){this.heads=e,this.node=t}get next(){return Gs(this.heads)}};function qs(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof Bs?r:r.context.parent;e;e=e.parent)if(e.index<0){let a=e.parent;(i||=[r]).push(a.resolve(t,n)),e=a}else{let a=As.get(e.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new Bs(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(Rs(o,t,n,!1))}}return i?Gs(i):r}var Js=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~K.EnterBracketed,e instanceof Bs)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof Bs?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&K.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&K.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&K.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(r.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=r)}else ({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&K.IncludeAnonymous||e instanceof Is||!e.type.isAnonymous||Ys(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)scan:for(let r=this.index,i=this.stack.length;i>=0;){for(let a=e;a;a=a._parent)if(a.index==r){if(r==this.index)return a;t=a,n=i+1;break scan}r=this.stack[--i]}for(let e=n;e<this.stack.length;e++)t=new Ws(this.buffer,t,this.stack[e]);return this.bufferNode=new Ws(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return Hs(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return Hs(this._tree,e,r);let a=n[t.buffer[this.stack[i]]];if(!a.isAnonymous){if(e[r]&&e[r]!=a.name)return!1;r--}}return!0}};function Ys(e){return e.children.some(e=>e instanceof Is||!e.type.isAnonymous||Ys(e))}function Xs(e){let{buffer:t,nodeSet:n,maxBufferLength:r=Ds,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new Fs(t,t.length):t,s=n.types,c=0,l=0;function u(e,t,_,v,y,ee){let{id:b,start:x,end:te,size:ne}=o,re=l,S=c;if(ne<0)if(o.next(),ne==-1){let t=i[b];_.push(t),v.push(x-e);return}else if(ne==-3){c=b;return}else if(ne==-4){l=b;return}else throw RangeError(`Unrecognized record size: ${ne}`);let C=s[b],ie,ae,oe=x-e;if(te-x<=r&&(ae=h(o.pos-t,y))){let t=new Uint16Array(ae.size-ae.skip),r=o.pos-ae.size,i=t.length;for(;o.pos>r;)i=g(ae.start,t,i);ie=new Is(t,te-ae.start,n),oe=ae.start-e}else{let e=o.pos-ne;o.next();let t=[],n=[],i=b>=a?b:-1,s=0,c=te;for(;o.pos>e;)i>=0&&o.id==i&&o.size>=0?(o.end<=c-r&&(p(t,n,x,s,o.end,c,i,re,S),s=t.length,c=o.end),o.next()):ee>2500?d(x,e,t,n):u(x,e,t,n,i,ee+1);if(i>=0&&s>0&&s<t.length&&p(t,n,x,s,x,c,i,re,S),t.reverse(),n.reverse(),i>-1&&s>0){let e=f(C,S);ie=$s(C,t,n,0,t.length,0,te-x,e,e)}else ie=m(C,t,n,te-x,re-te,S)}_.push(ie),v.push(oe)}function d(e,t,i,a){let s=[],c=0,l=-1;for(;o.pos>t;){let{id:e,start:t,end:n,size:i}=o;if(i>4)o.next();else if(l>-1&&t<l)break;else l<0&&(l=n-r),s.push(e,t,n),c++,o.next()}if(c){let t=new Uint16Array(c*4),r=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;i.push(new Is(t,s[2]-r,n)),a.push(r-e)}}function f(e,t){return(n,r,i)=>{let a=0,o=n.length-1,s,c;if(o>=0&&(s=n[o])instanceof q){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(G.lookAhead))&&(a=r[o]+s.length+c)}return m(e,n,r,i,a,t)}}function p(e,t,r,i,a,o,s,c,l){let u=[],d=[];for(;e.length>i;)u.push(e.pop()),d.push(t.pop()+r-a);e.push(m(n.types[s],u,d,o-a,c-o,l)),t.push(a-r)}function m(e,t,n,r,i,a,o){if(a){let e=[G.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[G.lookAhead,i];o=o?[e].concat(o):[e]}return new q(e,t,n,r,o)}function h(e,t){let n=o.fork(),i=0,s=0,c=0,l=n.end-r,u={size:0,start:0,skip:0};scan:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){u.size=i,u.start=s,u.skip=c,c+=4,i+=4,n.next();continue}let o=n.pos-e;if(e<0||o<r||n.start<l)break;let d=n.id>=a?4:0,f=n.start;for(n.next();n.pos>o;){if(n.size<0)if(n.size==-3||n.size==-4)d+=4;else break scan;else n.id>=a&&(d+=4);n.next()}s=f,i+=e,c+=d}return(t<0||i==e)&&(u.size=i,u.start=s,u.skip=c),u.size>4?u:void 0}function g(e,t,n){let{id:r,start:i,end:s,size:u}=o;if(o.next(),u>=0&&r<a){let a=n;if(u>4){let r=o.pos-(u-4);for(;o.pos>r;)n=g(e,t,n)}t[--n]=a,t[--n]=s-e,t[--n]=i-e,t[--n]=r}else u==-3?c=r:u==-4&&(l=r);return n}let _=[],v=[];for(;o.pos>0;)u(e.start||0,e.bufferStart||0,_,v,-1,0);let y=e.length??(_.length?v[0]+_[0].length:0);return new q(s[e.topID],_.reverse(),v.reverse(),y)}var Zs=new WeakMap;function Qs(e,t){if(!e.isAnonymous||t instanceof Is||t.type!=e)return 1;let n=Zs.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof q)){n=1;break}n+=Qs(e,r)}Zs.set(t,n)}return n}function $s(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n<i;n++)l+=Qs(e,t[n]);let u=Math.ceil(l*1.5/8),d=[],f=[];function p(t,n,r,i,o){for(let s=r;s<i;){let r=s,l=n[s],m=Qs(e,t[s]);for(s++;s<i;s++){let n=Qs(e,t[s]);if(m+n>=u)break;m+=n}if(s==r+1){if(m>u){let e=t[r];p(e.children,e.positions,0,e.children.length,n[r]+o);continue}d.push(t[r])}else{let i=n[s-1]+t[s-1].length-l;d.push($s(e,t,n,r,s,l,i,null,c))}f.push(l+o-a)}}return p(t,n,r,i,0),(s||c)(d,f,o)}var ec=class e{constructor(e,t,n,r,i=!1,a=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=!!i|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new e(0,t.length,t,0,!1,r)];for(let e of n)e.to>t.length&&i.push(e);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],a=1,o=t.length?t[0]:null;for(let s=0,c=0,l=0;;s++){let u=s<n.length?n[s]:null,d=u?u.fromA:1e9;if(d-c>=r)for(;o&&o.from<d;){let n=o;if(c>=n.from||d<=n.to||l){let t=Math.max(n.from,c)-l,r=Math.min(n.to,d)-l;n=t>=r?null:new e(t,r,n.tree,n.offset+l,s>0,!!u)}if(n&&i.push(n),o.to>d)break;o=a<t.length?t[a++]:null}if(!u)break;c=u.toA,l=u.toA-u.toB}return i}},tc=class{startParse(e,t,n){return typeof e==`string`&&(e=new nc(e)),n=n?n.length?n.map(e=>new ks(e.from,e.to)):[new ks(0,0)]:[new ks(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}},nc=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};new G({perNode:!0});var rc=0,ic=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=rc++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(t,n){let r=typeof t==`string`?t:`?`;if(t instanceof e&&(n=t),n?.base)throw Error(`Can not derive from a modified tag`);let i=new e(r,[],null,[]);if(i.set.push(i),n)for(let e of n.set)i.set.push(e);return i}static defineModifier(e){let t=new oc(e);return e=>e.modified.indexOf(t)>-1?e:oc.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},ac=0,oc=class e{constructor(e){this.name=e,this.instances=[],this.id=ac++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&sc(n,e.modified));if(r)return r;let i=[],a=new ic(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=cc(n);for(let n of t.set)if(!n.modified.length)for(let t of o)i.push(e.get(n,t));return a}};function sc(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function cc(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}function lc(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(` `))if(e){let n=[],i=2,a=e;for(let t=0;;){if(a==`...`&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!r)throw RangeError(`Invalid path: `+e);if(n.push(r[0]==`*`?``:r[0][0]==`"`?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&o==`!`){i=0;break}if(o!=`/`)throw RangeError(`Invalid path: `+e);a=e.slice(t)}let o=n.length-1,s=n[o];if(!s)throw RangeError(`Invalid path: `+e);t[s]=new dc(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return uc.add(t)}var uc=new G({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth>=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let a=new dc(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),dc=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};dc.empty=new dc([],2,null);function fc(e,t){let n=Object.create(null);for(let t of e)if(!Array.isArray(t.tag))n[t.tag.id]=t.class;else for(let e of t.tag)n[e.id]=t.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+` `+r:r;break}}return t},scope:r}}var J=ic.define,pc=J(),mc=J(),hc=J(mc),gc=J(mc),_c=J(),vc=J(_c),yc=J(_c),bc=J(),xc=J(bc),Sc=J(),Cc=J(),wc=J(),Tc=J(wc),Ec=J(),Y={comment:pc,lineComment:J(pc),blockComment:J(pc),docComment:J(pc),name:mc,variableName:J(mc),typeName:hc,tagName:J(hc),propertyName:gc,attributeName:J(gc),className:J(mc),labelName:J(mc),namespace:J(mc),macroName:J(mc),literal:_c,string:vc,docString:J(vc),character:J(vc),attributeValue:J(vc),number:yc,integer:J(yc),float:J(yc),bool:J(_c),regexp:J(_c),escape:J(_c),color:J(_c),url:J(_c),keyword:Sc,self:J(Sc),null:J(Sc),atom:J(Sc),unit:J(Sc),modifier:J(Sc),operatorKeyword:J(Sc),controlKeyword:J(Sc),definitionKeyword:J(Sc),moduleKeyword:J(Sc),operator:Cc,derefOperator:J(Cc),arithmeticOperator:J(Cc),logicOperator:J(Cc),bitwiseOperator:J(Cc),compareOperator:J(Cc),updateOperator:J(Cc),definitionOperator:J(Cc),typeOperator:J(Cc),controlOperator:J(Cc),punctuation:wc,separator:J(wc),bracket:Tc,angleBracket:J(Tc),squareBracket:J(Tc),paren:J(Tc),brace:J(Tc),content:bc,heading:xc,heading1:J(xc),heading2:J(xc),heading3:J(xc),heading4:J(xc),heading5:J(xc),heading6:J(xc),contentSeparator:J(bc),list:J(bc),quote:J(bc),emphasis:J(bc),strong:J(bc),link:J(bc),monospace:J(bc),strikethrough:J(bc),inserted:J(),deleted:J(),changed:J(),invalid:J(),meta:Ec,documentMeta:J(Ec),annotation:J(Ec),processingInstruction:J(Ec),definition:ic.defineModifier(`definition`),constant:ic.defineModifier(`constant`),function:ic.defineModifier(`function`),standard:ic.defineModifier(`standard`),local:ic.defineModifier(`local`),special:ic.defineModifier(`special`)};for(let e in Y){let t=Y[e];t instanceof ic&&(t.name=e)}fc([{tag:Y.link,class:`tok-link`},{tag:Y.heading,class:`tok-heading`},{tag:Y.emphasis,class:`tok-emphasis`},{tag:Y.strong,class:`tok-strong`},{tag:Y.keyword,class:`tok-keyword`},{tag:Y.atom,class:`tok-atom`},{tag:Y.bool,class:`tok-bool`},{tag:Y.url,class:`tok-url`},{tag:Y.labelName,class:`tok-labelName`},{tag:Y.inserted,class:`tok-inserted`},{tag:Y.deleted,class:`tok-deleted`},{tag:Y.literal,class:`tok-literal`},{tag:Y.string,class:`tok-string`},{tag:Y.number,class:`tok-number`},{tag:[Y.regexp,Y.escape,Y.special(Y.string)],class:`tok-string2`},{tag:Y.variableName,class:`tok-variableName`},{tag:Y.local(Y.variableName),class:`tok-variableName tok-local`},{tag:Y.definition(Y.variableName),class:`tok-variableName tok-definition`},{tag:Y.special(Y.variableName),class:`tok-variableName2`},{tag:Y.definition(Y.propertyName),class:`tok-propertyName tok-definition`},{tag:Y.typeName,class:`tok-typeName`},{tag:Y.namespace,class:`tok-namespace`},{tag:Y.className,class:`tok-className`},{tag:Y.macroName,class:`tok-macroName`},{tag:Y.propertyName,class:`tok-propertyName`},{tag:Y.operator,class:`tok-operator`},{tag:Y.comment,class:`tok-comment`},{tag:Y.meta,class:`tok-meta`},{tag:Y.invalid,class:`tok-invalid`},{tag:Y.punctuation,class:`tok-punctuation`}]);var Dc=new G,Oc=new G,kc=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,A.prototype.hasOwnProperty(`tree`)||Object.defineProperty(A.prototype,"tree",{get(){return jc(this)}}),this.parser=t,this.extension=[Bc.of(this),A.languageData.of((e,t,n)=>{let r=Ac(e,t,n),i=r.type.prop(Dc);if(!i)return[];let a=e.facet(i),o=r.type.prop(Oc);if(o){let i=r.resolve(t-r.from,n);for(let t of o)if(t.test(i,e)){let n=e.facet(t.facet);return t.type==`replace`?n:n.concat(a)}}return a})].concat(n)}isActiveAt(e,t,n=-1){return Ac(e,t,n).type.prop(Dc)==this.data}findRegions(e){let t=e.facet(Bc);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(Dc)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(G.mounted);if(i){if(i.tree.prop(Dc)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}else if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let i=e.children[n];i instanceof q&&r(i,e.positions[n]+t)}};return r(jc(e),0),n}get allowsNesting(){return!0}};kc.setState=O.define();function Ac(e,t,n){let r=e.facet(Bc),i=jc(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,K.ExcludeBuffers|K.EnterBracketed))e.type.isTop&&(i=e);return i}function jc(e){let t=e.field(kc.state,!1);return t?t.tree:q.empty}var Mc=class{constructor(e){this.doc=e,this.cursorPos=0,this.string=``,this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},Nc=null,Pc=class e{constructor(e,t,n=[],r,i,a,o,s){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=a,this.skipped=o,this.scheduleOn=s,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new e(t,n,[],q.empty,0,r,[],null)}startParse(){return this.parser.startParse(new Mc(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=q.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{if(typeof e==`number`){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||=this.startParse(),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let n=this.parse.advance();if(n)if(this.fragments=this.withoutTempSkipped(ec.addTree(n,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=this.parse.stoppedAt??this.state.doc.length,this.tree=n,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(ec.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Nc;Nc=this;try{return e()}finally{Nc=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Fc(e,t.from,t.to);return e}changes(t,n){let{fragments:r,tree:i,treeLen:a,viewport:o,skipped:s}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,n,r,i)=>e.push({fromA:t,toA:n,fromB:r,toB:i})),r=ec.applyChanges(r,e),i=q.empty,a=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){s=[];for(let e of this.skipped){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);n<r&&s.push({from:n,to:r})}}}return new e(this.parser,n,r,i,a,o,s,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:r}=this.skipped[t];n<e.to&&r>e.from&&(this.fragments=Fc(this.fragments,n,r),this.skipped.splice(t--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&=(this.takeTree(),null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends tc{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=Nc;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=a,new q(Ms.none,[],[],a-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Nc}};function Fc(e,t,n){return ec.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var Ic=class e{constructor(e){this.context=e,this.tree=e.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new e(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=Pc.create(t.facet(Bc).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};kc.state=Ie.define({create:Ic.init,update(e,t){for(let e of t.effects)if(e.is(kc.setState))return e.value;return t.startState.facet(Bc)==t.state.facet(Bc)?e.apply(t):Ic.init(t.state)}});var Lc=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(Lc=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var Rc=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,zc=jr.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(kc.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(kc.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Lc(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,i=n.field(kc.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!Rc?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<r&&n.doc.length>r+1e3,s=i.context.work(()=>Rc&&Rc()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:kc.setState.of(new Ic(i.context))})),this.chunkBudget>0&&!(s&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&=(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>z(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Bc=D.define({combine(e){return e.length?e[0]:null},enables:e=>[kc.state,zc,W.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),Vc=D.define(),Hc=D.define({combine:e=>{if(!e.length)return` `;let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw Error(`Invalid indent unit: `+JSON.stringify(e[0]));return t}});function Uc(e){let t=e.facet(Hc);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function Wc(e,t){let n=``,r=e.tabSize,i=e.facet(Hc)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e<t;e++)n+=i;return n}function Gc(e,t){e instanceof A&&(e=new Kc(e));for(let n of e.state.facet(Vc)){let r=n(e,t);if(r!==void 0)return r}let n=jc(e.state);return n.length>=t?Jc(e,n,t):null}var Kc=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Uc(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=n.from&&r<=n.to?i&&r==e?{text:``,from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return``;let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),a=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return a>-1&&(i+=a-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return Pt(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},qc=new G;function Jc(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t&&!(t.from<r.node.from||t.to>r.node.to||t.from==r.node.from&&t.type==r.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return Yc(r,e,n)}function Yc(e,t,n){for(let r=e;r;r=r.next){let e=Zc(r.node);if(e)return e($c.create(t,n,r))}return 0}function Xc(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function Zc(e){let t=e.type.prop(qc);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(G.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>nl(e,!0,1,void 0,n&&!Xc(e)?t.from:void 0)}return e.parent==null?Qc:null}function Qc(){return 0}var $c=class e extends Kc{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(t,n,r){return new e(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(el(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return Yc(this.context.next,this.base,this.pos)}};function el(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function tl(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,a=e.state.doc.lineAt(n.from),o=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==r)return null;if(!i.type.isSkipped){if(i.from>=o)return null;let e=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}function nl(e,t,n,r,i){let a=e.textAfter,o=a.match(/^\s*/)[0].length,s=r&&a.slice(o,o+r.length)==r||i==e.pos+o,c=t?tl(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}Y.meta,Y.link,Y.heading,Y.emphasis,Y.strong,Y.strikethrough,Y.keyword,Y.atom,Y.bool,Y.url,Y.contentSeparator,Y.labelName,Y.literal,Y.inserted,Y.string,Y.deleted,Y.regexp,Y.escape,Y.string,Y.variableName,Y.variableName,Y.typeName,Y.namespace,Y.className,Y.variableName,Y.macroName,Y.propertyName,Y.comment,Y.invalid;var rl=1e4,il=`()[]{}`,al=new G;function ol(e,t,n){let r=e.prop(t<0?G.openedBy:G.closedBy);if(r)return r;if(e.name.length==1){let r=n.indexOf(e.name);if(r>-1&&r%2==+(t<0))return[n[r+t]]}return null}function sl(e){let t=e.type.prop(al);return t?t(e.node):e}function cl(e,t,n,r={}){let i=r.maxScanDistance||rl,a=r.brackets||il,o=jc(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=ol(r.type,n,a);if(i&&r.from<r.to){let o=sl(r);if(o&&(n>0?t>=o.from&&t<o.to:t>o.from&&t<=o.to))return ll(e,t,n,r,o,i,a)}}return ul(e,t,n,o,s.type,i,a)}function ll(e,t,n,r,i,a,o){let s=r.parent,c={from:i.from,to:i.to},l=0,u=s?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(l==0&&a.indexOf(u.type.name)>-1&&u.from<u.to){let e=sl(u);return{start:c,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}else if(ol(u.type,n,o))l++;else if(ol(u.type,-n,o)){if(l==0){let e=sl(u);return{start:c,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}l--}}while(n<0?u.prevSibling():u.nextSibling());return{start:c,matched:!1}}function ul(e,t,n,r,i,a,o){if(n<0?!t:t==e.doc.length)return null;let s=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),c=o.indexOf(s);if(c<0||c%2==0!=n>0)return null;let l={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let e=0;!u.next().done&&e<=a;){let a=u.value;n<0&&(e+=a.length);let s=t+e*n;for(let e=n>0?0:a.length-1,t=n>0?a.length:-1;e!=t;e+=n){let t=o.indexOf(a[e]);if(!(t<0||r.resolveInner(s+e,1).type!=i))if(t%2==0==n>0)d++;else if(d==1)return{start:l,end:{from:s+e,to:s+e+1},matched:t>>1==c>>1};else d--}n>0&&(e+=a.length)}return u.done?{start:l,matched:!1}:null}var dl=Object.create(null),fl=[Ms.none],pl=[],ml=Object.create(null),hl=Object.create(null);for(let[e,t]of[[`variable`,`variableName`],[`variable-2`,`variableName.special`],[`string-2`,`string.special`],[`def`,`variableName.definition`],[`tag`,`tagName`],[`attribute`,`attributeName`],[`type`,`typeName`],[`builtin`,`variableName.standard`],[`qualifier`,`modifier`],[`error`,`invalid`],[`header`,`heading`],[`property`,`propertyName`]])hl[e]=_l(dl,t);function gl(e,t){pl.indexOf(e)>-1||(pl.push(e),console.warn(t))}function _l(e,t){let n=[];for(let r of t.split(` `)){let t=[];for(let n of r.split(`.`)){let r=e[n]||Y[n];r?typeof r==`function`?t.length?t=t.map(r):gl(n,`Modifier ${n} used at start of tag`):t.length?gl(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:gl(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,`_`),i=r+` `+n.map(e=>e.id),a=ml[i];if(a)return a.id;let o=ml[i]=Ms.define({id:fl.length,name:r,props:[lc({[r]:n})]});return fl.push(o),o.id}L.RTL,L.LTR;var vl=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=jc(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(wl(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e==`abort`&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function yl(e){let t=Object.keys(e).join(``),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,``)),`[${n?`\\w`:``}${t.replace(/[^\w\s]/g,`\\$&`)}]`}function bl(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=yl(t)+yl(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function xl(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:bl(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}var Sl=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function Cl(e){return e.selection.main.from}function wl(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}var Tl=et.define();function El(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return{...e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let c=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:c},range:E.cursor(s.from+a+c.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var Dl=new WeakMap;function Ol(e){if(!Array.isArray(e))return e;let t=Dl.get(e);return t||Dl.set(e,t=xl(e)),t}var kl=O.define(),Al=O.define(),jl=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=he(e,t),r=_e(n);this.chars.push(n);let i=e.slice(t,t+r),a=i.toUpperCase();this.folded.push(he(a==i?i.toLowerCase():a,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:r,precise:i,byWord:a}=this;if(t.length==1){let r=he(e,0),i=_e(r),a=i==e.length?0:-100;if(r!=t[0])if(r==n[0])a+=-200;else return null;return this.ret(a,[0,i])}let o=e.indexOf(this.pattern);if(o==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let s=t.length,c=0;if(o<0){for(let i=0,a=Math.min(e.length,200);i<a&&c<s;){let a=he(e,i);(a==t[c]||a==n[c])&&(r[c++]=i),i+=_e(a)}if(c<s)return null}let l=0,u=0,d=!1,f=0,p=-1,m=-1,h=/[a-z]/.test(e),g=!0;for(let r=0,c=Math.min(e.length,200),_=0;r<c&&u<s;){let c=he(e,r);o<0&&(l<s&&c==t[l]&&(i[l++]=r),f<s&&(c==t[f]||c==n[f]?(f==0&&(p=r),m=r+1,f++):f=0));let v,y=c<255?c>=48&&c<=57||c>=97&&c<=122?2:+(c>=65&&c<=90):(v=ge(c))==v.toLowerCase()?v==v.toUpperCase()?0:2:1;(!r||y==1&&h||_==0&&y!=0)&&(t[u]==c||n[u]==c&&(d=!0)?a[u++]=r:a.length&&(g=!1)),_=y,r+=_e(c)}return u==s&&a[0]==0&&g?this.result(-100+(d?-200:0),a,e):f==s&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):f==s?this.ret(-900-e.length,[p,m]):u==s?this.result(-100+(d?-200:0)+-700+(g?0:-1100),a,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,n){let r=[],i=0;for(let e of t){let t=e+(this.astral?_e(he(n,e)):1);i&&r[i-1]==e?r[i-1]=t:(r[i++]=e,r[i++]=t)}return this.ret(e-n.length,r)}},Ml=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}},X=D.define({combine(e){return gt(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>``,optionClass:()=>``,aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Pl,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>Nl(e(n),t(n)),optionClass:(e,t)=>n=>Nl(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function Nl(e,t){return e?t?e+` `+t:e:t}function Pl(e,t,n,r,i,a){let o=e.textDirection==L.RTL,s=o,c=!1,l=`top`,u,d,f=t.left-i.left,p=i.right-t.right,m=r.right-r.left,h=r.bottom-r.top;if(s&&f<Math.min(m,p)?s=!1:!s&&p<Math.min(m,f)&&(s=!0),m<=(s?f:p))u=Math.max(i.top,Math.min(n.top,i.bottom-h))-t.top,d=Math.min(400,s?f:p);else{c=!0,d=Math.min(400,(o?t.right:i.right-t.left)-30);let e=i.bottom-t.bottom;e>=h||e>t.top?u=n.bottom-t.top:(l=`bottom`,u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,_=(t.right-t.left)/a.offsetWidth;return{style:`${l}: ${u/g}px; max-width: ${d/_}px`,class:`cm-completionInfo-`+(c?o?`left-narrow`:`right-narrow`:s?`left`:`right`)}}var Fl=O.define();function Il(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement(`div`);return t.classList.add(`cm-completionIcon`),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>`cm-completionIcon-`+e)),t.setAttribute(`aria-hidden`,`true`),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement(`span`);i.className=`cm-completionLabel`;let a=e.displayLabel||e.label,o=0;for(let e=0;e<r.length;){let t=r[e++],n=r[e++];t>o&&i.appendChild(document.createTextNode(a.slice(o,t)));let s=i.appendChild(document.createElement(`span`));s.appendChild(document.createTextNode(a.slice(t,n))),s.className=`cm-completionMatchedText`,o=n}return o<a.length&&i.appendChild(document.createTextNode(a.slice(o))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement(`span`);return t.className=`cm-completionDetail`,t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}function Ll(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.ceil((e-t)/n);return{from:e-r*n,to:e-(r-1)*n}}var Rl=class{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass=``;let r=e.state.field(t),{options:i,selected:a}=r.open,o=e.state.facet(X);this.optionContent=Il(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=Ll(i.length,a,o.maxRenderedOptions),this.dom=document.createElement(`div`),this.dom.className=`cm-tooltip-autocomplete`,this.updateTooltipClass(e.state),this.dom.addEventListener(`mousedown`,n=>{let{options:r}=e.state.field(t).open;for(let t=n.target,i;t&&t!=this.dom;t=t.parentNode)if(t.nodeName==`LI`&&(i=/-(\d+)$/.exec(t.id))&&+i[1]<r.length){this.applyCompletion(e,r[+i[1]]),n.preventDefault();return}if(n.target==this.list){let t=this.list.classList.contains(`cm-completionListIncompleteTop`)&&n.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains(`cm-completionListIncompleteBottom`)&&n.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;t!=null&&(e.dispatch({effects:Fl.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(X).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:Al.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener(`scroll`,()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){let t=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),t!=n){let{options:r,selected:i,disabled:a}=t.open;(!n.open||n.open.options!=r)&&(this.range=Ll(r.length,i,e.state.facet(X).maxRenderedOptions),this.showOptions(r,t.id)),this.updateSel(),a!=n.open?.disabled&&this.dom.classList.toggle(`cm-tooltip-autocomplete-disabled`,!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(` `))e&&this.dom.classList.remove(e);for(let e of t.split(` `))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=Ll(t.options.length,t.selected,this.view.state.facet(X).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let a=typeof i==`string`?document.createTextNode(i):i(r);if(!a)return;`then`in a?a.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,r)}).catch(e=>z(this.view.state,e,`completion info`)):(this.addInfoPane(a,r),n.setAttribute(`aria-describedby`,this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement(`div`);if(n.className=`cm-tooltip cm-completionInfo`,n.id=`cm-completionInfo-`+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!=`LI`||!n.id?r--:r==e?n.hasAttribute(`aria-selected`)||(n.setAttribute(`aria-selected`,`true`),t=n):n.hasAttribute(`aria-selected`)&&(n.removeAttribute(`aria-selected`),n.removeAttribute(`aria-describedby`));return t&&Bl(this.list,t),t}measureInfo(){let e=this.dom.querySelector(`[aria-selected]`);if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(X).positionInfo(this.view,t,r,n,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className=`cm-tooltip cm-completionInfo `+(e.class||``)):this.info.style.cssText=`top: -1e6px`)}createListBox(e,t,n){let r=document.createElement(`ul`);r.id=t,r.setAttribute(`role`,`listbox`),r.setAttribute(`aria-expanded`,`true`),r.setAttribute(`aria-label`,this.view.state.phrase(`Completions`)),r.addEventListener(`mousedown`,e=>{e.target==r&&e.preventDefault()});let i=null;for(let a=n.from;a<n.to;a++){let{completion:o,match:s}=e[a],{section:c}=o;if(c){let e=typeof c==`string`?c:c.name;if(e!=i&&(a>n.from||n.from==0))if(i=e,typeof c!=`string`&&c.header)r.appendChild(c.header(c));else{let t=r.appendChild(document.createElement(`completion-section`));t.textContent=e}}let l=r.appendChild(document.createElement(`li`));l.id=t+`-`+a,l.setAttribute(`role`,`option`);let u=this.optionClass(o);u&&(l.className=u);for(let e of this.optionContent){let t=e(o,this.view.state,this.view,s);t&&l.appendChild(t)}}return n.from&&r.classList.add(`cm-completionListIncompleteTop`),n.to<e.length&&r.classList.add(`cm-completionListIncompleteBottom`),r}destroyInfo(){this.info&&=(this.infoDestroy&&this.infoDestroy(),this.info.remove(),null)}destroy(){this.destroyInfo()}};function zl(e,t){return n=>new Rl(n,e,t)}function Bl(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function Vl(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+ +!!e.type}function Hl(e,t){let n=[],r=null,i=null,a=e=>{n.push(e);let{section:t}=e.completion;if(t){r||=[];let e=typeof t==`string`?t:t.name;r.some(t=>t.name==e)||r.push(typeof t==`string`?{name:e}:t)}},o=t.facet(X);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(r.result.filter===!1)for(let t of r.result.options)a(new Sl(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new Ml(n):new jl(n);for(let t of r.result.options)if(s=c.match(t.label)){let n=t.displayLabel?e?e(t,s.matched):[]:s.matched,o=s.score+(t.boost||0);if(a(new Sl(t,r.source,n,o)),typeof t.section==`object`&&t.section.rank===`dynamic`){let{name:e}=t.section;i||=Object.create(null),i[e]=Math.max(o,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,a=(e,t)=>(e.rank===`dynamic`&&t.rank===`dynamic`?i[t.name]-i[e.name]:0)||(typeof e.rank==`number`?e.rank:1e9)-(typeof t.rank==`number`?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of r.sort(a))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e[typeof n==`string`?n:n.name])}}let s=[],c=null,l=o.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||l(e.completion,t.completion))){let t=e.completion;!c||c.label!=t.label||c.detail!=t.detail||c.type!=null&&t.type!=null&&c.type!=t.type||c.apply!=t.apply||c.boost!=t.boost?s.push(e):Vl(e.completion)>Vl(c)&&(s[s.length-1]=e),c=e.completion}return s}var Ul=class e{constructor(e,t,n,r,i,a){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new e(this.options,Jl(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(e=>e.isPending))return i.setDisabled();let s=Hl(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(X).selectOnOpen?0:-1;if(i&&i.selected!=c&&i.selected!=-1){let e=i.options[i.selected].completion;for(let t=0;t<s.length;t++)if(s[t].completion==e){c=t;break}}return new e(s,Jl(r,c),{pos:t.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:nu,above:a.aboveCursor},i?i.timestamp:Date.now(),c,!1)}map(t){return new e(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new e(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},Wl=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e(Yl,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(X),i=(r.override||n.languageDataAt(`autocomplete`,Cl(n)).map(Ol)).map(e=>(this.active.find(t=>t.source==e)||new Zl(e,+!!this.active.some(e=>e.state!=0))).update(t,r));i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let a=this.open,o=t.effects.some(e=>e.is(eu));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!Gl(i,this.active)||o?a=Ul.build(i,n,this.id,a,r,o):a&&a.disabled&&!i.some(e=>e.isPending)&&(a=null),!a&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new Zl(e.source,0):e));for(let e of t.effects)e.is(Fl)&&(a&&=a.setSelected(e.value,this.id));return i==this.active&&a==this.open?this:new e(i,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Kl:ql}};function Gl(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}var Kl={"aria-autocomplete":`list`},ql={};function Jl(e,t){let n={"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-controls":e};return t>-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var Yl=[];function Xl(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(Tl);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent(`input.type`);return n&&t.activateOnTyping?5:n?1:e.isUserEvent(`delete.backward`)?2:e.selection?8:e.docChanged?16:0}var Zl=class e{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=Xl(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new e(i.source,0)),r&4&&i.state==0&&(i=new e(this.source,1)),i=i.updateFor(t,r);for(let n of t.effects)if(n.is(kl))i=new e(i.source,1,n.value);else if(n.is(Al))i=new e(i.source,0);else if(n.is(eu))for(let e of n.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Cl(e.state))}},Ql=class e extends Zl{constructor(e,t,n,r,i,a){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=a}hasResult(){return!0}updateFor(t,n){if(!(n&3))return this.map(t.changes);let r=this.result;r.map&&!t.changes.empty&&(r=r.map(r,t.changes));let i=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=Cl(t.state);if(o>a||!r||n&2&&(Cl(t.startState)==this.from||o<this.limit))return new Zl(this.source,n&4?1:0);let s=t.changes.mapPos(this.limit);return $l(r.validFor,t.state,i,a)?new e(this.source,this.explicit,s,r,i,a):r.update&&(r=r.update(r,i,a,new vl(t.state,o,!1)))?new e(this.source,this.explicit,s,r,r.from,r.to??Cl(t.state)):new Zl(this.source,1,this.explicit)}map(t){if(t.empty)return this;let n=this.result.map?this.result.map(this.result,t):this.result;return n?new e(this.source,this.explicit,t.mapPos(this.limit),n,t.mapPos(this.from),t.mapPos(this.to,1)):new Zl(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function $l(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e==`function`?e(i,n,r,t):wl(e,!0).test(i)}var eu=O.define({map(e,t){return e.map(e=>e.map(t))}}),Z=Ie.define({create(){return Wl.start()},update(e,t){return e.update(t)},provide:e=>[ws.from(e,e=>e.tooltip),W.contentAttributes.from(e,e=>e.attrs)]});function tu(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(Z).active.find(e=>e.source==t.source);return r instanceof Ql?(typeof n==`string`?e.dispatch({...El(e.state,n,r.from,r.to),annotations:Tl.of(t.completion)}):n(e,t.completion,r.from,r.to),!0):!1}var nu=zl(Z,tu);function ru(e,t=`option`){return n=>{let r=n.state.field(Z,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(X).interactionDelay)return!1;let i=1,a;t==`page`&&(a=Ts(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector(`li`).offsetHeight)-1));let{length:o}=r.open.options,s=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:o-1;return s<0?s=t==`page`?0:o-1:s>=o&&(s=t==`page`?o-1:0),n.dispatch({effects:Fl.of(s)}),!0}}var iu=e=>{let t=e.state.field(Z,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(X).interactionDelay?!1:tu(e,t.open.options[t.open.selected])},au=e=>e.state.field(Z,!1)?(e.dispatch({effects:kl.of(!0)}),!0):!1,ou=e=>{let t=e.state.field(Z,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:Al.of(null)}),!0)},su=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},cu=50,lu=1e3,uu=jr.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(Z).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Z),n=e.state.facet(X);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Z)==t)return;let r=e.transactions.some(e=>{let t=Xl(e,n);return t&8||(e.selection||e.docChanged)&&!(t&3)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(r||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>cu&&Date.now()-n.time>lu){for(let e of n.context.abortListeners)try{e()}catch(e){z(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(kl)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let t of e.transactions)t.isUserEvent(`input.type`)?this.composing=2:this.composing==2&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(Z);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(X).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=new vl(t,Cl(t),e.explicit,this.view),r=new su(e,n);this.running.push(r),Promise.resolve(e.source(n)).then(e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:Al.of(null)}),z(this.view.state,e)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(X).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(X),n=this.view.state.field(Z);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(i.done===void 0)continue;if(this.running.splice(r--,1),i.done){let n=Cl(i.updates.length?i.updates[0].startState:this.view.state),r=Math.min(n,i.done.from+ +!i.active.explicit),a=new Ql(i.active.source,i.active.explicit,r,i.done,i.done.from,i.done.to??n);for(let e of i.updates)a=a.update(e,t);if(a.hasResult()){e.push(a);continue}}let a=n.active.find(e=>e.source==i.active.source);if(a&&a.isPending)if(i.done==null){let n=new Zl(i.active.source,0);for(let e of i.updates)n=n.update(e,t);n.isPending||e.push(n)}else this.startQuery(a)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:eu.of(e)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Z,!1);if(t&&t.tooltip&&this.view.state.facet(X).closeOnBlur){let n=t.open&&Ts(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Al.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:kl.of(!1)}),20),this.composing=0}}}),du=typeof navigator==`object`&&/Win/.test(navigator.platform),fu=ze.highest(W.domEventHandlers({keydown(e,t){let n=t.state.field(Z,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(du&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&tu(t,r),!1}})),pu=W.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:`monospace`,whiteSpace:`nowrap`,overflow:`hidden auto`,maxWidth_fallback:`700px`,maxWidth:`min(700px, 95vw)`,minWidth:`250px`,maxHeight:`10em`,height:`100%`,listStyle:`none`,margin:0,padding:0,"& > li, & > completion-section":{padding:`1px 3px`,lineHeight:1.2},"& > li":{overflowX:`hidden`,textOverflow:`ellipsis`,cursor:`pointer`},"& > completion-section":{display:`list-item`,borderBottom:`1px solid silver`,paddingLeft:`0.5em`,opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#17c`,color:`white`},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#777`},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#347`,color:`white`},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#444`},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:`"···"`,opacity:.5,display:`block`,textAlign:`center`,cursor:`pointer`},".cm-tooltip.cm-completionInfo":{position:`absolute`,padding:`3px 9px`,width:`max-content`,maxWidth:`400px`,boxSizing:`border-box`,whiteSpace:`pre-line`},".cm-completionInfo.cm-completionInfo-left":{right:`100%`},".cm-completionInfo.cm-completionInfo-right":{left:`100%`},".cm-completionInfo.cm-completionInfo-left-narrow":{right:`30px`},".cm-completionInfo.cm-completionInfo-right-narrow":{left:`30px`},"&light .cm-snippetField":{backgroundColor:`#00000022`},"&dark .cm-snippetField":{backgroundColor:`#ffffff22`},".cm-snippetFieldPosition":{verticalAlign:`text-top`,width:0,height:`1.15em`,display:`inline-block`,margin:`0 -0.7px -.7em`,borderLeft:`1.4px dotted #888`},".cm-completionMatchedText":{textDecoration:`underline`},".cm-completionDetail":{marginLeft:`0.5em`,fontStyle:`italic`},".cm-completionIcon":{fontSize:`90%`,width:`.8em`,display:`inline-block`,textAlign:`center`,paddingRight:`.6em`,opacity:`0.6`,boxSizing:`content-box`},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:`'ƒ'`}},".cm-completionIcon-class":{"&:after":{content:`'○'`}},".cm-completionIcon-interface":{"&:after":{content:`'◌'`}},".cm-completionIcon-variable":{"&:after":{content:`'𝑥'`}},".cm-completionIcon-constant":{"&:after":{content:`'𝐶'`}},".cm-completionIcon-type":{"&:after":{content:`'𝑡'`}},".cm-completionIcon-enum":{"&:after":{content:`'∪'`}},".cm-completionIcon-property":{"&:after":{content:`'□'`}},".cm-completionIcon-keyword":{"&:after":{content:`'🔑︎'`}},".cm-completionIcon-namespace":{"&:after":{content:`'▢'`}},".cm-completionIcon-text":{"&:after":{content:`'abc'`,fontSize:`50%`,verticalAlign:`middle`}}}),mu=new class extends _t{};mu.startSide=1,mu.endSide=-1,typeof navigator==`object`&&navigator.userAgent;function hu(e={}){return[fu,Z,X.of(e),uu,_u,pu]}var gu=[{key:`Ctrl-Space`,run:au},{mac:"Alt-`",run:au},{mac:`Alt-i`,run:au},{key:`Escape`,run:ou},{key:`ArrowDown`,run:ru(!0)},{key:`ArrowUp`,run:ru(!1)},{key:`PageDown`,run:ru(!0,`page`)},{key:`PageUp`,run:ru(!1,`page`)},{key:`Enter`,run:iu}],_u=ze.highest(Wo.computeN([X],e=>e.facet(X).defaultKeymap?[gu]:[])),vu=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=Cu(e.state,n.from);return r.line?bu(e):r.block?Su(e):!1};function yu(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var bu=yu(Ou,0),xu=yu(Du,0),Su=yu((e,t)=>Du(e,t,Eu(t)),0);function Cu(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var wu=50;function Tu(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-wu,r),o=e.sliceDoc(i,i+wu),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=2*wu?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+wu),d=e.sliceDoc(i-wu,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function Eu(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function Du(e,t,n=t.selection.ranges){let r=n.map(e=>Cu(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>Tu(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function Ou(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=Cu(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}else if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var ku=et.define(),Au=et.define(),ju=D.define(),Mu=D.define({combine(e){return gt(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),Nu=Ie.define({create(){return Qu.empty},update(e,t){let n=t.state.facet(Mu),r=t.annotation(ku);if(r){let i=Bu.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?Vu(o,o.length,n.minDepth,i):qu(o,t.startState.selection),new Qu(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(Au);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(k.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=Bu.fromTransaction(t),o=t.annotation(k.time),s=t.annotation(k.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new Qu(e.done.map(Bu.fromJSON),e.undone.map(Bu.fromJSON))}});function Pu(e={}){return[Nu,Mu.of(e),W.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?Iu:e.inputType==`historyRedo`?Lu:null;return n?(e.preventDefault(),n(t)):!1}})]}function Fu(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(Nu,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var Iu=Fu(0,!1),Lu=Fu(1,!1),Ru=Fu(0,!0),zu=Fu(1,!0),Bu=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&xe.fromJSON(t.changes),[],t.mapped&&be.fromJSON(t.mapped),t.startSelection&&E.fromJSON(t.startSelection),t.selectionsAfter.map(E.fromJSON))}static fromTransaction(t,n){let r=Gu;for(let e of t.startState.facet(ju)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,Gu)}static selection(t){return new e(void 0,Gu,void 0,void 0,t)}};function Vu(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function Hu(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function Uu(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function Wu(e,t){return e.length?t.length?e.concat(t):e:t}var Gu=[],Ku=200;function qu(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Ku));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),Vu(e,e.length-1,1e9,n.setSelAfter(r)))}else return[Bu.selection([t])]}function Ju(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function Yu(e,t){if(!e.length)return e;let n=e.length,r=Gu;for(;n;){let i=Xu(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[Bu.selection(r)]:Gu}function Xu(e,t,n){let r=Wu(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):Gu,n);if(!e.changes)return Bu.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new Bu(i,O.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var Zu=/^(input\.type|delete)($|\.)/,Qu=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||Zu.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,Hu(s.changes,t.changes))||r==`input.type.compose`)?Vu(o,o.length-1,i.minDepth,new Bu(t.changes.compose(s.changes),Wu(O.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,Gu)):Vu(o,o.length,i.minDepth,t),new e(o,Gu,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:Gu;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&Uu(a[a.length-1],t)?this:new e(qu(this.done,t),this.undone,n,r)}addMapping(t){return new e(Yu(this.done,t),Yu(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:ku.of({side:e,rest:Ju(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?Gu:r.slice(0,r.length-1);return i.mapped&&(n=Yu(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:ku.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};Qu.empty=new Qu(Gu,Gu);var $u=[{key:`Mod-z`,run:Iu,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:Lu,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:Lu,preventDefault:!0},{key:`Mod-u`,run:Ru,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:zu,preventDefault:!0}];function ed(e,t){return E.create(e.ranges.map(t),e.mainIndex)}function td(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function nd({state:e,dispatch:t},n){let r=ed(e.selection,n);return r.eq(e.selection,!0)?!1:(t(td(e,r)),!0)}function rd(e,t){return E.cursor(t?e.to:e.from)}function id(e,t){return nd(e,n=>n.empty?e.moveByChar(n,t):rd(n,t))}function Q(e){return e.textDirectionAt(e.state.selection.main.head)==L.LTR}var ad=e=>id(e,!Q(e)),od=e=>id(e,Q(e));function sd(e,t){return nd(e,n=>n.empty?e.moveByGroup(n,t):rd(n,t))}var cd=e=>sd(e,!Q(e)),ld=e=>sd(e,Q(e));typeof Intl<`u`&&Intl.Segmenter;function ud(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function dd(e,t,n){let r=jc(e).resolveInner(t.head),i=n?G.closedBy:G.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;ud(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?cl(e,r.from,1):cl(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,E.cursor(s,n?-1:1)}var fd=e=>nd(e,t=>dd(e.state,t,!Q(e))),pd=e=>nd(e,t=>dd(e.state,t,Q(e)));function md(e,t){return nd(e,n=>{if(!n.empty)return rd(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var hd=e=>md(e,!1),gd=e=>md(e,!0);function _d(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(W.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function vd(e,t){let n=_d(e),{state:r}=e,i=ed(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):rd(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=W.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(td(r,i),{effects:a}),!0}var yd=e=>vd(e,!1),bd=e=>vd(e,!0);function xd(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=E.cursor(r.from+n))}return i}var Sd=e=>nd(e,t=>xd(e,t,!0)),Cd=e=>nd(e,t=>xd(e,t,!1)),wd=e=>nd(e,t=>xd(e,t,!Q(e))),Td=e=>nd(e,t=>xd(e,t,Q(e))),Ed=e=>nd(e,t=>E.cursor(e.lineBlockAt(t.head).from,1)),Dd=e=>nd(e,t=>E.cursor(e.lineBlockAt(t.head).to,-1));function Od(e,t,n){let r=!1,i=ed(e.selection,t=>{let i=cl(e,t.head,-1)||cl(e,t.head,1)||t.head>0&&cl(e,t.head-1,1)||t.head<e.doc.length&&cl(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?E.range(t.anchor,a):E.cursor(a)});return r?(t(td(e,i)),!0):!1}var kd=({state:e,dispatch:t})=>Od(e,t,!1);function Ad(e,t){let n=ed(e.state.selection,e=>{let n=t(e);return E.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(td(e.state,n)),!0)}function jd(e,t){return Ad(e,n=>e.moveByChar(n,t))}var Md=e=>jd(e,!Q(e)),Nd=e=>jd(e,Q(e));function Pd(e,t){return Ad(e,n=>e.moveByGroup(n,t))}var Fd=e=>Pd(e,!Q(e)),Id=e=>Pd(e,Q(e)),Ld=e=>Ad(e,t=>dd(e.state,t,!Q(e))),Rd=e=>Ad(e,t=>dd(e.state,t,Q(e)));function zd(e,t){return Ad(e,n=>e.moveVertically(n,t))}var Bd=e=>zd(e,!1),Vd=e=>zd(e,!0);function Hd(e,t){return Ad(e,n=>e.moveVertically(n,t,_d(e).height))}var Ud=e=>Hd(e,!1),Wd=e=>Hd(e,!0),Gd=e=>Ad(e,t=>xd(e,t,!0)),Kd=e=>Ad(e,t=>xd(e,t,!1)),qd=e=>Ad(e,t=>xd(e,t,!Q(e))),Jd=e=>Ad(e,t=>xd(e,t,Q(e))),Yd=e=>Ad(e,t=>E.cursor(e.lineBlockAt(t.head).from)),Xd=e=>Ad(e,t=>E.cursor(e.lineBlockAt(t.head).to)),Zd=({state:e,dispatch:t})=>(t(td(e,{anchor:0})),!0),Qd=({state:e,dispatch:t})=>(t(td(e,{anchor:e.doc.length})),!0),$d=({state:e,dispatch:t})=>(t(td(e,{anchor:e.selection.main.anchor,head:0})),!0),ef=({state:e,dispatch:t})=>(t(td(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),tf=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),nf=({state:e,dispatch:t})=>{let n=Sf(e).map(({from:t,to:n})=>E.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:E.create(n),userEvent:`select`})),!0},rf=({state:e,dispatch:t})=>{let n=ed(e.selection,t=>{let n=jc(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return E.range(n.to,n.from)}return t});return n.eq(e.selection)?!1:(t(td(e,n)),!0)};function af(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}else if(r.head==n.head)break;else n=r}}return i.length==r.ranges.length?!1:(e.dispatch(td(n,E.create(i,i.length-1))),!0)}var of=e=>af(e,!1),sf=e=>af(e,!0),cf=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=E.create([n.main]):n.main.empty||(r=E.create([E.cursor(n.main.head)])),r?(t(td(e,r)),!0):!1};function lf(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=uf(e,o,!1)):o>i&&(n=`delete.forward`,o=uf(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=uf(e,i,!1),a=uf(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:E.cursor(i,i<r.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?W.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function uf(e,t,n){if(e instanceof W)for(let r of e.state.facet(W.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var df=(e,t,n)=>lf(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=Pt(s,a.tabSize)%Uc(a)||Uc(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=w(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=w(o.text,c-o.from,!1,!1)+o.from);return c}),ff=e=>df(e,!1,!0),pf=e=>df(e,!0,!1),mf=(e,t)=>lf(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=w(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),hf=e=>mf(e,!1),gf=e=>mf(e,!0),_f=e=>lf(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),vf=e=>lf(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),yf=e=>lf(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),bf=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:S.of([``,``])},range:E.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},xf=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:w(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:w(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:E.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function Sf(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function Cf(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of Sf(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(E.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(E.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:E.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var wf=({state:e,dispatch:t})=>Cf(e,t,!1),Tf=({state:e,dispatch:t})=>Cf(e,t,!0);function Ef(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of Sf(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var Df=({state:e,dispatch:t})=>Ef(e,t,!1),Of=({state:e,dispatch:t})=>Ef(e,t,!0),kf=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Sf(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=ed(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function Af(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=jc(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(G.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var jf=Nf(!1),Mf=Nf(!0);function Nf(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&Af(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new Kc(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=Gc(s,r);for(c??=Pt(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,Wc(t,c)];return o&&l.push(Wc(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:S.of(l)},range:E.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function Pf(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:E.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var Ff=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new Kc(e,{overrideIndentation:e=>n[e]??-1}),i=Pf(e,(t,i,a)=>{let o=Gc(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=Wc(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},If=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Pf(e,(t,n)=>{n.push({from:t.from,insert:e.facet(Hc)})}),{userEvent:`input.indent`})),!0),Lf=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Pf(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=Pt(r,e.tabSize),a=0,o=Wc(e,Math.max(0,i-Uc(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),Rf=e=>(e.setTabFocusMode(),!0),zf=[{key:`Ctrl-b`,run:ad,shift:Md,preventDefault:!0},{key:`Ctrl-f`,run:od,shift:Nd},{key:`Ctrl-p`,run:hd,shift:Bd},{key:`Ctrl-n`,run:gd,shift:Vd},{key:`Ctrl-a`,run:Ed,shift:Yd},{key:`Ctrl-e`,run:Dd,shift:Xd},{key:`Ctrl-d`,run:pf},{key:`Ctrl-h`,run:ff},{key:`Ctrl-k`,run:_f},{key:`Ctrl-Alt-h`,run:hf},{key:`Ctrl-o`,run:bf},{key:`Ctrl-t`,run:xf},{key:`Ctrl-v`,run:bd}],Bf=[{key:`ArrowLeft`,run:ad,shift:Md,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:cd,shift:Fd,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:wd,shift:qd,preventDefault:!0},{key:`ArrowRight`,run:od,shift:Nd,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:ld,shift:Id,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:Td,shift:Jd,preventDefault:!0},{key:`ArrowUp`,run:hd,shift:Bd,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:Zd,shift:$d},{mac:`Ctrl-ArrowUp`,run:yd,shift:Ud},{key:`ArrowDown`,run:gd,shift:Vd,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:Qd,shift:ef},{mac:`Ctrl-ArrowDown`,run:bd,shift:Wd},{key:`PageUp`,run:yd,shift:Ud},{key:`PageDown`,run:bd,shift:Wd},{key:`Home`,run:Cd,shift:Kd,preventDefault:!0},{key:`Mod-Home`,run:Zd,shift:$d},{key:`End`,run:Sd,shift:Gd,preventDefault:!0},{key:`Mod-End`,run:Qd,shift:ef},{key:`Enter`,run:jf,shift:jf},{key:`Mod-a`,run:tf},{key:`Backspace`,run:ff,shift:ff,preventDefault:!0},{key:`Delete`,run:pf,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:hf,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:gf,preventDefault:!0},{mac:`Mod-Backspace`,run:vf,preventDefault:!0},{mac:`Mod-Delete`,run:yf,preventDefault:!0}].concat(zf.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),Vf=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:fd,shift:Ld},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:pd,shift:Rd},{key:`Alt-ArrowUp`,run:wf},{key:`Shift-Alt-ArrowUp`,run:Df},{key:`Alt-ArrowDown`,run:Tf},{key:`Shift-Alt-ArrowDown`,run:Of},{key:`Mod-Alt-ArrowUp`,run:of},{key:`Mod-Alt-ArrowDown`,run:sf},{key:`Escape`,run:cf},{key:`Mod-Enter`,run:Mf},{key:`Alt-l`,mac:`Ctrl-l`,run:nf},{key:`Mod-i`,run:rf,preventDefault:!0},{key:`Mod-[`,run:Lf},{key:`Mod-]`,run:If},{key:`Mod-Alt-\\`,run:Ff},{key:`Shift-Mod-k`,run:kf},{key:`Shift-Mod-\\`,run:kd},{key:`Mod-/`,run:vu},{key:`Alt-A`,run:xu},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:Rf}].concat(Bf),Hf=O.define(),Uf=Ie.define({create(){return null},update(e,t){for(let n of t.effects)n.is(Hf)&&(e=n.value);return e}}),Wf=jr.fromClass(class{constructor(e){this.view=e,this.caret=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCaret.bind(this)}}update(e){let t=e.state.field(Uf);if(t==null){this.caret&&=(this.caret.remove(),null);return}this.caret||(this.caret=this.view.scrollDOM.appendChild(document.createElement(`div`)),this.caret.className=`cm-dropCursor`),(e.startState.field(Uf)!==t||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq)}readPos(){let e=this.view.state.field(Uf),t=e==null?null:this.view.coordsAtPos(e);if(!t)return null;let n=this.view.scrollDOM.getBoundingClientRect();return{left:t.left-n.left+this.view.scrollDOM.scrollLeft*this.view.scaleX,top:t.top-n.top+this.view.scrollDOM.scrollTop*this.view.scaleY,height:t.bottom-t.top}}drawCaret(e){if(!this.caret)return;let{scaleX:t,scaleY:n}=this.view;e?(this.caret.style.left=`${e.left/t}px`,this.caret.style.top=`${e.top/n}px`,this.caret.style.height=`${e.height/n}px`):this.caret.style.left=`-100000px`}destroy(){this.caret?.remove()}});function Gf(){return[Uf,Wf]}function Kf(e,t){let n=e.posAtCoords(t)??e.state.doc.length,r=Math.max(0,Math.min(n,e.state.doc.length));e.state.field(Uf,!1)!==r&&e.dispatch({effects:Hf.of(r)})}function qf(e){e.state.field(Uf,!1)!=null&&e.dispatch({effects:Hf.of(null)})}var Jf=class extends fn{constructor(e,t){super(),this.config=e,this.store=t}toDOM(){if(this._element)return this._element;switch(this.config.widgetType){case`column`:this._element=Yf(this.config.data);break;case`emptyArgument`:{let e=document.createElement(`luzmo-formula-empty-argument-pill`);e.emptyArgumentId=this.config.data.emptyArgumentId,e.parentAggregationWidgetId=this.config.data.parentAggregationWidgetId,e.store=this.store,this._element=e;break}case`aggregation`:{let e=document.createElement(`luzmo-formula-aggregation`);e.config=this.config.data,e.store=this.store,this._element=e;break}}return this._element}eq(e){if(e.config.widgetType!==this.config.widgetType)return!1;switch(this.config.widgetType){case`column`:return e.config.widgetType===`column`&&e.config.data.columnId===this.config.data.columnId&&e.config.data.text===this.config.data.text&&e.config.data.type===this.config.data.type&&e.config.data.subtype===this.config.data.subtype&&e.config.data.lowestLevel===this.config.data.lowestLevel&&e.config.data.pending===this.config.data.pending;case`emptyArgument`:return e.config.widgetType===`emptyArgument`&&e.config.data.emptyArgumentId===this.config.data.emptyArgumentId;case`aggregation`:return e.config.widgetType===`aggregation`&&e.config.data.aggregationWidgetId===this.config.data.aggregationWidgetId}return!1}ignoreEvent(){return!0}};function Yf(e){let t=document.createElement(`span`);t.className=`column-pill-wrapper`;let n=document.createElement(`span`);if(n.className=`column-pill`,t.appendChild(n),e.pending){let e=(0,p.msg)(`Loading column`,{desc:`Accessible label for a column pill whose label is still loading`});n.title=e;let r=document.createElement(`span`);r.className=`column-pill-loading`;let i=document.createElement(`luzmo-progress-circle`);return i.setAttribute(`indeterminate`,``),i.setAttribute(`size`,`s`),i.label=e,r.appendChild(i),n.appendChild(r),t}n.title=e.text;let r=document.createElement(`span`);r.className=`column-pill-icon`,r.appendChild(l.t(e.icon));let i=document.createElement(`span`);return i.className=`column-pill-label`,i.textContent=e.text,n.append(r,i),t}function Xf(e,t){let{store:n,datasets:r,contentLanguage:i,parentAggregationWidgetId:a,multiStageAggregation:s}=t,l=[],u=s?o.h:o.m;u.lastIndex=0;let d;for(;(d=u.exec(e))!==null;){d.index===u.lastIndex&&u.lastIndex++;let e=d.index,t=e+d[0].length,o=d[1],s=d[2],f=d[3];if(f)l.push(I.replace({widget:new Jf({widgetType:`aggregation`,data:{aggregationWidgetId:f,linkedDatasets:r,contentLanguage:i,parentAggregationWidgetId:a}},n)}).range(e,t));else if(o)l.push(I.replace({widget:new Jf({widgetType:`emptyArgument`,data:{emptyArgumentId:o,parentAggregationWidgetId:a}},n)}).range(e,t));else if(s){let[a,o]=s.split(`:`),u=r.find(e=>e.id===a)?.columns.find(e=>e.columnId===o),{icon:d,label:f}=c.t(u,i,o);l.push(I.replace({widget:new Jf({widgetType:`column`,data:{columnId:o,datasetId:a,type:u?.type??`hierarchy`,subtype:u?.subtype,lowestLevel:u?.lowestLevel,text:f,icon:d,pending:n.loading&&!u}},n)}).range(e,t))}}return l}var Zf=`var(--luzmo-background-color)`,Qf=`var(--luzmo-font-color)`,$f=`var(--luzmo-border-color, rgba(0, 0, 0, 0.1))`,ep=`var(--luzmo-primary)`,tp=`var(--luzmo-negative-color, #ca221c)`,np=`rgba(var(--luzmo-primary-rgb), 0.18)`,rp={"&":{backgroundColor:Zf,color:Qf},".cm-scroller":{fontFamily:`var(--luzmo-font-family)`,fontSize:`var(--luzmo-formula-font-size, var(--luzmo-font-size))`,lineHeight:`1.5`,overflow:`auto`},".cm-content":{caretColor:Qf,padding:`var(--luzmo-spacing-3) var(--luzmo-spacing-4)`},".cm-line":{padding:0},".cm-activeLine":{backgroundColor:`transparent`},".cm-selectionBackground, ::selection":{backgroundColor:np},"&.cm-focused":{outline:`none`},"&.cm-focused .cm-selectionBackground, & .cm-selectionBackground, & ::selection":{backgroundColor:np},".cm-cursor, .cm-dropCursor":{borderLeftColor:Qf},".cm-placeholder":{color:`var(--luzmo-font-color-extra-dimmed)`},".cm-tooltip":{border:`1px solid ${$f}`,backgroundColor:Zf,color:Qf,borderRadius:`var(--luzmo-border-radius-s)`}},ip=`var(--luzmo-formula-font-size, var(--luzmo-font-size))`,ap={".cm-tooltip.cm-tooltip-autocomplete":{border:`1px solid ${$f}`,borderRadius:`var(--luzmo-border-radius)`,backgroundColor:Zf,color:Qf,boxShadow:`0 6px 16px rgba(0, 0, 0, 0.12)`,fontFamily:`var(--luzmo-font-family)`,"& > ul":{fontFamily:`var(--luzmo-font-family)`,fontSize:ip,maxHeight:`16rem`,padding:`var(--luzmo-spacing-1)`},"& > ul > li":{display:`flex`,alignItems:`center`,gap:`var(--luzmo-spacing-2)`,padding:`var(--luzmo-spacing-2) var(--luzmo-spacing-3)`,borderRadius:`var(--luzmo-border-radius-s)`,color:Qf,lineHeight:`1.4`},"& > ul > li[aria-selected]":{backgroundColor:`var(--luzmo-background-color-hover)`,color:Qf}},".cm-completionIcon":{boxSizing:`content-box`,width:`1.2em`,minWidth:`1.2em`,padding:`0`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,color:Qf,opacity:`1`},".cm-completionIcon svg":{width:`1em`,height:`1em`},".cm-completionLabel":{flex:`1 1 auto`},".cm-completionMatchedText":{color:`var(--luzmo-primary)`,fontWeight:`var(--luzmo-font-weight-bold)`,textDecoration:`none`},".cm-completionDetail":{color:`var(--luzmo-font-color-extra-dimmed)`,fontStyle:`normal`},".cm-tooltip.cm-completionInfo":{margin:`0 var(--luzmo-spacing-2)`,border:`1px solid ${$f}`,borderRadius:`var(--luzmo-border-radius)`,backgroundColor:Zf,color:Qf,boxShadow:`0 6px 16px rgba(0, 0, 0, 0.12)`,padding:`var(--luzmo-spacing-3) var(--luzmo-spacing-4)`,fontFamily:`var(--luzmo-font-family)`,fontSize:ip,lineHeight:`1.5`,maxWidth:`18rem`},".cm-completion-info-example":{display:`block`,marginBottom:`var(--luzmo-spacing-2)`,color:Qf,fontFamily:`var(--luzmo-font-family)`,fontWeight:`var(--luzmo-font-weight-bold)`,whiteSpace:`normal`},".cm-completion-info-icon":{display:`inline-flex`,alignItems:`center`,verticalAlign:`-0.15em`,margin:`0 0.15em`},".cm-completion-info-icon svg":{width:`1em`,height:`1em`},".cm-completion-info-desc":{color:`var(--luzmo-font-color-extra-dimmed)`}},op=1.5;function sp(e){return`calc(${e} * ${op} * var(--luzmo-formula-font-size, var(--luzmo-font-size)) + 2 * var(--luzmo-spacing-3) + 2px)`}function cp(e){let{rows:t,maxRows:n,grows:r=!0,editorHeight:i,hasError:a=!1,singleLine:o=!1}=e;if(o)return{"&":{height:`100%`,minHeight:`auto`,border:`none`,borderRadius:`0`,backgroundColor:`transparent`},".cm-content":{padding:`0 2px`},".cm-scroller":{alignItems:`center`,lineHeight:`1.2`,overflow:`visible`}};let s={border:`1px solid ${a?tp:$f}`,borderTopLeftRadius:`var(--luzmo-border-radius)`,borderTopRightRadius:`var(--luzmo-border-radius)`,borderBottomLeftRadius:`var(--luzmo-formula-field-bottom-radius, var(--luzmo-border-radius))`,borderBottomRightRadius:`var(--luzmo-formula-field-bottom-radius, var(--luzmo-border-radius))`},c=i??(t==null?void 0:sp(t));return r?(s.minHeight=c??`auto`,n!=null&&(s.maxHeight=sp(n))):s.height=c??`auto`,{"&":s,"&.cm-focused":{borderColor:a?tp:ep}}}var lp=`:host{vertical-align:middle;font-family:var(--luzmo-font-family);display:inline-flex}.empty-argument-pill{min-width:1.25rem;min-height:1.1em;padding:0 var(--luzmo-spacing-2);border:1px dashed var(--luzmo-border-color-full);border-radius:var(--luzmo-border-radius-s);background-color:var(--luzmo-formula-empty-argument-pill-background,transparent);color:var(--luzmo-font-color);cursor:text;outline:none;justify-content:center;align-items:center;font-size:.85em;line-height:1.5;display:inline-flex}:host([accept-drag]) .empty-argument-pill,.empty-argument-pill.accept-drag{border-style:solid;border-color:var(--luzmo-primary);background-color:rgba(var(--luzmo-primary-rgb), .18)}`,up=class extends n.t(e.i){constructor(...e){super(...e),this.emptyArgumentId=``,this.parentAggregationWidgetId=null}static{this.styles=(0,d.unsafeCSS)(lp)}connectedCallback(){super.connectedCallback(),this._attachDroppable()}disconnectedCallback(){super.disconnectedCallback(),this._cleanupDroppable?.(),this._cleanupDroppable=void 0}firstUpdated(e){this._attachDroppable()}_attachDroppable(){this._cleanupDroppable||!this.isConnected||(this._cleanupDroppable=a.n({element:this,getDropEffect:()=>`move`,canDrop:({source:e})=>this._canDrop(e.element?.tagName,e.data),onDragEnter:()=>this.setAttribute(`accept-drag`,``),onDragLeave:()=>this.removeAttribute(`accept-drag`),onDrop:({source:e})=>{this.removeAttribute(`accept-drag`),this._handleDrop(e.element?.tagName,e.data)}}))}_canDrop(e,t){return e===`LUZMO-DATA-FIELD`||e===`LUZMO-DATA-FIELD-LEVEL`?!0:t?.kind===`aggregation`&&this.parentAggregationWidgetId!==null&&!this.store?.nestedAggregation?!1:t?.kind===`function`||t?.kind===`aggregation`}_handleDrop(e,t){if(!this.store)return;if(e===`LUZMO-DATA-FIELD`||e===`LUZMO-DATA-FIELD-LEVEL`){let e=t;this.store.onExtendExpression({type:`column`,id:e.columnId??null,datasetId:e.datasetId,aggregationWidgetId:this.parentAggregationWidgetId,isEmptyArgument:!0,targetEmptyArgumentId:this.emptyArgumentId});return}let n=t;(n?.kind===`function`||n?.kind===`aggregation`)&&this.store.onExtendExpression({type:n.kind,id:n.value,aggregationWidgetId:this.parentAggregationWidgetId,isEmptyArgument:!0,targetEmptyArgumentId:this.emptyArgumentId})}_handleInput(e){let t=e.target.textContent??``;!this.store||t.trim().length===0||this.store.onExtendExpression({type:`text`,id:null,aggregationWidgetId:this.parentAggregationWidgetId,isEmptyArgument:!0,targetEmptyArgumentId:this.emptyArgumentId,textContent:t})}render(){return d.html`
|
|
29
|
+
`))};if((P.mac||P.android)&&u.from==a-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute(`autocorrect`)==`off`&&(u={from:o,to:s,insert:S.of([n.text.replace(`.`,` `)])}),this.pendingContextChange=u,!e.state.readOnly){let t=this.to-this.from+(u.to-u.from+u.insert.length);Qi(e,u,E.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from<u.to&&!u.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],i=null;for(let t=this.toEditorPos(n.rangeStart),a=this.toEditorPos(n.rangeEnd);t<a;t++){let n=e.coordsForChar(t);i=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||i||new DOMRect,r.push(i)}t.updateCharacterBounds(n.rangeStart,r)},this.handlers.textformatupdate=t=>{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,r=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(r)){let i=this.toEditorPos(e.rangeStart),a=this.toEditorPos(e.rangeEnd);if(i<a){let e=`text-decoration: underline ${/^[a-z]/.test(t)?t+` `:t==`Dashed`?`dashed `:t==`Squiggle`?`wavy `:``}${/thin/i.test(r)?1:2}px`;n.push(I.mark({attributes:{style:e}}).range(i,a))}}}e.dispatch({effects:Dr.of(I.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=bn(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((i,a,o,s,c)=>{if(n)return;let l=c.length-(a-i);if(r&&a>=r.to)if(r.from==i&&r.to==a&&r.insert.eq(c)){r=this.pendingContextChange=null,t+=l,this.to+=l;return}else r=null,this.revertPending(e.state);if(i+=t,a+=t,a<=this.from)this.from+=l,this.to+=l;else if(i<this.to){if(i<this.from||a>this.to||this.to-this.from+c.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(i),this.toContextPos(a),c.toString()),this.to+=l}t+=l}),r&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(e=>!e.isUserEvent(`input.type`)&&e.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(n,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},W=class e{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement(`div`),this.scrollDOM=document.createElement(`div`),this.scrollDOM.tabIndex=-1,this.scrollDOM.className=`cm-scroller`,this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement(`div`),this.announceDOM.className=`cm-announced`,this.announceDOM.setAttribute(`aria-live`,`polite`),this.dom=document.createElement(`div`),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(e=>e.forEach(e=>t(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Bn(e.parent)||document,this.viewState=new uo(this,e.state||A.create(e)),e.scrollTo&&e.scrollTo.is(Er)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ar).map(e=>new Mr(e));for(let e of this.plugins)e.update(this);this.observer=new jo(this),this.inputState=new ia(this),this.inputState.ensureHandlers(this.plugins),this.docView=new vi(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),document.fonts?.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent=`refresh`,this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof k?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(t){if(this.updateState!=0)throw Error(`Calls to EditorView.update are not allowed while an update is in progress`);let n=!1,r=!1,i,a=this.state;for(let e of t){if(e.startState!=a)throw RangeError(`Trying to update state with a transaction that doesn't start from the previous state.`);a=e.state}if(this.destroyed){this.viewState.state=a;return}let o=this.hasFocus,s=0,c=null;t.some(e=>e.annotation(Fa))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,c=Ia(a,o),c||(s=1));let l=this.observer.delayedAndroidKey,u=null;if(l?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(u=null)):this.observer.clear(),a.facet(A.phrases)!=this.state.facet(A.phrases))return this.setState(a);i=Gr.create(this,a,t),i.flags|=s;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let n of t){if(d&&=d.map(n.changes),n.scrollIntoView){let{main:t}=n.state.selection,{x:r,y:i}=this.state.facet(e.cursorScrollMargin);d=new Tr(t.empty?t:E.cursor(t.head,t.head>t.anchor?-1:1),`nearest`,`nearest`,i,r)}for(let e of n.effects)e.is(Er)&&(d=e.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=Ro.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(Ur)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(e=>e.isUserEvent(`select.pointer`)))}finally{this.updateState=0}if(i.startState.facet(xo)!=i.state.facet(xo)&&(this.viewState.mustMeasureContent=!0),(n||r||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let e of this.state.facet(_r))try{e(i)}catch(e){z(this.state,e,`update listener`)}(c||u)&&Promise.resolve().then(()=>{c&&this.state==c.startState&&this.dispatch(c),u&&!Zi(this,u)&&l.force&&zn(this.contentDOM,l.key,l.keyCode)})}setState(e){if(this.updateState!=0)throw Error(`Calls to EditorView.setState are not allowed while an update is in progress`);if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new uo(this,e),this.plugins=e.facet(Ar).map(e=>new Mr(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new vi(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Ar),n=e.state.facet(Ar);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new Mr(i));else{let t=this.plugins[n];t.mustUpdate=e,r.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(e){z(this.state,e,`doc view update listener`)}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:i,scrollAnchorHeight:a}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(a<0)if(Hn(n||this.win))i=-1,a=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(r);i=e.from,a=e.top}this.updateState=1;let o=this.viewState.measure();if(!o&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(e>5){console.warn(this.measureRequests.length?`Measure loop restarted more than 5 times`:`Viewport failed to stabilize`);break}let s=[];o&4||([this.measureRequests,s]=[s,this.measureRequests]);let c=s.map(e=>{try{return e.read(this)}catch(e){return z(this.state,e),Lo}}),l=Gr.create(this,this.state,[]),u=!1;l.flags|=o,t?t.flags|=o:t=l,this.updateState=2,l.empty||(this.updatePlugins(l),this.inputState.update(l),this.updateAttrs(),u=this.docView.update(l),u&&this.docViewUpdate());for(let e=0;e<s.length;e++)if(c[e]!=Lo)try{let t=s[e];t.write&&t.write(c[e],this)}catch(e){z(this.state,e)}if(u&&this.docView.updateSelection(!0),!l.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,a=-1;continue}else{let e=((i<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(i).top)-a)/this.scaleY;if((e>1||e<-1)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r+=e,n?n.scrollTop+=e:this.win.scrollBy(0,e),a=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(_r))e(t)}get themeClasses(){return Co+` `+(this.state.facet(So)?To:wo)+` `+this.state.facet(xo)}updateAttrs(){let e=zo(this,Nr,{class:`cm-editor`+(this.hasFocus?` cm-focused `:` `)+this.themeClasses}),t={spellcheck:`false`,autocorrect:`off`,autocapitalize:`off`,writingsuggestions:`false`,translate:`no`,contenteditable:this.state.facet(Or)?`true`:`false`,class:`cm-content`,style:`${P.tabSize}: ${this.state.tabSize}`,role:`textbox`,"aria-multiline":`true`};this.state.readOnly&&(t[`aria-readonly`]=`true`),zo(this,Pr,t);let n=this.observer.ignore(()=>{let n=un(this.contentDOM,this.contentAttrs,t),r=un(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(t){let n=!0;for(let r of t)for(let t of r.effects)if(t.is(e.announce)){n&&(this.announceDOM.textContent=``),n=!1;let e=this.announceDOM.appendChild(document.createElement(`div`));e.textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(Ur);let t=this.state.facet(e.cspNonce);Bt.mount(this.root,this.styleModules.concat(Oo).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw Error(`Reading the editor layout isn't allowed during an update`);this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(t=>t.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return Bi(this,e,Fi(this,e,t,n))}moveByGroup(e,t){return Bi(this,e,Fi(this,e,t,t=>Ii(this,e.head,t)))}visualLineSide(e,t){let n=this.bidiSpans(e),r=this.textDirectionAt(e.from),i=n[t?n.length-1:0];return E.cursor(i.side(t,r)+e.from,i.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,n=!0){return Pi(this,e,t,n)}moveVertically(e,t,n){return Bi(this,e,Li(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=Hi(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),Hi(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let r=this.state.doc.lineAt(e),i=this.bidiSpans(r),a=i[tr.find(i,e-r.from,-1,t)];return kn(n,a.dir==L.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(Sr)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Io)return lr(e.length);let t=this.textDirectionAt(e.from),n;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||nr(r.isolates,n=Br(this,e))))return r.order;n||=Br(this,e);let r=cr(e.text,t,n);return this.bidiCache.push(new Ro(e.from,e.to,t,n,!0,r)),r}get hasFocus(){return(this.dom.ownerDocument.hasFocus()||P.safari&&this.inputState?.lastContextMenu>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{In(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Er.of(new Tr(typeof e==`number`?E.cursor(e):e,t.y??`nearest`,t.x??`nearest`,t.yMargin??5,t.xMargin??5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return Er.of(new Tr(E.cursor(n.from),`start`,`start`,n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e==`boolean`?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return jr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return jr.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=Bt.newName(),r=[xo.of(n),Ur.of(Do(`.${n}`,e))];return t&&t.dark&&r.push(So.of(!0)),r}static baseTheme(e){return ze.lowest(Ur.of(Do(`.`+Co,e,Eo)))}static findFromDOM(e){let t=e.querySelector(`.cm-content`);return(t&&B.get(t)||B.get(e))?.root?.view||null}};W.styleModule=Ur,W.inputHandler=vr,W.clipboardInputFilter=br,W.clipboardOutputFilter=xr,W.scrollHandler=wr,W.focusChangeEffect=yr,W.perLineTextDirection=Sr,W.exceptionSink=gr,W.updateListener=_r,W.editable=Or,W.mouseSelectionStyle=hr,W.dragMovesSelection=mr,W.clickAddsSelectionRange=pr,W.decorations=Fr,W.blockWrappers=Ir,W.outerDecorations=Lr,W.atomicRanges=Rr,W.bidiIsolatedRanges=zr,W.cursorScrollMargin=D.define({combine:e=>{let t=5,n=5;for(let r of e)typeof r==`number`?t=n=r:{x:t,y:n}=r;return{x:t,y:n}}}),W.scrollMargins=Vr,W.darkTheme=So,W.cspNonce=D.define({combine:e=>e.length?e[0]:``}),W.contentAttributes=Pr,W.editorAttributes=Nr,W.lineWrapping=W.contentAttributes.of({class:`cm-lineWrapping`}),W.announce=O.define();var Io=4096,Lo={},Ro=class e{constructor(e,t,n,r,i,a){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=i,this.order=a}static update(t,n){if(n.empty&&!t.some(e=>e.fresh))return t;let r=[],i=t.length?t[t.length-1].dir:L.LTR;for(let a=Math.max(0,t.length-10);a<t.length;a++){let o=t[a];o.dir==i&&!n.touchesRange(o.from,o.to)&&r.push(new e(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}};function zo(e,t,n){for(let r=e.state.facet(t),i=r.length-1;i>=0;i--){let t=r[i],a=typeof t==`function`?t(e):t;a&&on(a,n)}return n}var Bo=P.mac?`mac`:P.windows?`win`:P.linux?`linux`:`key`;function Vo(e,t){let n=e.split(/-(?!$)/),r=n[n.length-1];r==`Space`&&(r=` `);let i,a,o,s;for(let e=0;e<n.length-1;++e){let r=n[e];if(/^(cmd|meta|m)$/i.test(r))s=!0;else if(/^a(lt)?$/i.test(r))i=!0;else if(/^(c|ctrl|control)$/i.test(r))a=!0;else if(/^s(hift)?$/i.test(r))o=!0;else if(/^mod$/i.test(r))t==`mac`?s=!0:a=!0;else throw Error(`Unrecognized modifier name: `+r)}return i&&(r=`Alt-`+r),a&&(r=`Ctrl-`+r),s&&(r=`Meta-`+r),o&&(r=`Shift-`+r),r}function Ho(e,t,n){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n!==!1&&t.shiftKey&&(e=`Shift-`+e),e}var Uo=ze.default(W.domEventHandlers({keydown(e,t){return Zo(Ko(t.state),e,t,`editor`)}})),Wo=D.define({enables:Uo}),Go=new WeakMap;function Ko(e){let t=e.facet(Wo),n=Go.get(t);return n||Go.set(t,n=Yo(t.reduce((e,t)=>e.concat(t),[]))),n}var qo=null,Jo=4e3;function Yo(e,t=Bo){let n=Object.create(null),r=Object.create(null),i=(e,t)=>{let n=r[e];if(n==null)r[e]=t;else if(n!=t)throw Error(`Key binding `+e+` is used both as a regular binding and as a multi-stroke prefix`)},a=(e,r,a,o,s)=>{let c=n[e]||(n[e]=Object.create(null)),l=r.split(/ (?!$)/).map(e=>Vo(e,t));for(let t=1;t<l.length;t++){let n=l.slice(0,t).join(` `);i(n,!0),c[n]||(c[n]={preventDefault:!0,stopPropagation:!1,run:[t=>{let r=qo={view:t,prefix:n,scope:e};return setTimeout(()=>{qo==r&&(qo=null)},Jo),!0}]})}let u=l.join(` `);i(u,!1);let d=c[u]||(c[u]={preventDefault:!1,stopPropagation:!1,run:(c._any?.run)?.slice()||[]});a&&d.run.push(a),o&&(d.preventDefault=!0),s&&(d.stopPropagation=!0)};for(let r of e){let e=r.scope?r.scope.split(` `):[`editor`];if(r.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||={preventDefault:!1,stopPropagation:!1,run:[]};let{any:i}=r;for(let t in e)e[t].run.push(e=>i(e,Xo))}let i=r[t]||r.key;if(i)for(let t of e)a(t,i,r.run,r.preventDefault,r.stopPropagation),r.shift&&a(t,`Shift-`+i,r.shift,r.preventDefault,r.stopPropagation)}return n}var Xo=null;function Zo(e,t,n,r){Xo=t;let i=Jt(t),a=_e(he(i,0))==i.length&&i!=` `,o=``,s=!1,c=!1,l=!1;qo&&qo.view==n&&qo.scope==r&&(o=qo.prefix+` `,la.indexOf(t.keyCode)<0&&(c=!0,qo=null));let u=new Set,d=e=>{if(e){for(let t of e.run)if(!u.has(t)&&(u.add(t),t(n)))return e.stopPropagation&&(l=!0),!0;e.preventDefault&&(e.stopPropagation&&(l=!0),c=!0)}return!1},f=e[r],p,m;return f&&(d(f[o+Ho(i,t,!a)])?s=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(P.windows&&t.ctrlKey&&t.altKey)&&!(P.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=Ut[t.keyCode])&&p!=i?(d(f[o+Ho(p,t,!0)])||t.shiftKey&&(m=Wt[t.keyCode])!=i&&m!=p&&d(f[o+Ho(m,t,!1)]))&&(s=!0):a&&t.shiftKey&&d(f[o+Ho(i,t,!0)])&&(s=!0),!s&&d(f._any)&&(s=!0)),c&&(s=!0),s&&l&&t.stopPropagation(),Xo=null,s}var Qo=class e{constructor(e,t,n,r,i){this.className=e,this.left=t,this.top=n,this.width=r,this.height=i}draw(){let e=document.createElement(`div`);return e.className=this.className,this.adjust(e),e}update(e,t){return t.className==this.className?(this.adjust(e),!0):!1}adjust(e){e.style.left=this.left+`px`,e.style.top=this.top+`px`,this.width!=null&&(e.style.width=this.width+`px`),e.style.height=this.height+`px`}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(t,n,r){if(r.empty){let i=t.coordsAtPos(r.head,r.assoc||1);if(!i)return[];let a=$o(t);return[new e(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}else return ts(t,n,r)}};function $o(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==L.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function es(e,t,n,r){let i=e.coordsAtPos(t,n*2);if(!i)return r;let a=e.dom.getBoundingClientRect(),o=(i.top+i.bottom)/2,s=e.posAtCoords({x:a.left+1,y:o}),c=e.posAtCoords({x:a.right-1,y:o});return s==null||c==null?r:{from:Math.max(r.from,Math.min(s,c)),to:Math.min(r.to,Math.max(s,c))}}function ts(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let r=Math.max(n.from,e.viewport.from),i=Math.min(n.to,e.viewport.to),a=e.textDirection==L.LTR,o=e.contentDOM,s=o.getBoundingClientRect(),c=$o(e),l=o.querySelector(`.cm-line`),u=l&&window.getComputedStyle(l),d=s.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),f=s.right-(u?parseInt(u.paddingRight):0),p=Ni(e,r,1),m=Ni(e,i,-1),h=p.type==F.Text?p:null,g=m.type==F.Text?m:null;if(h&&(e.lineWrapping||p.widgetLineBreaks)&&(h=es(e,r,1,h)),g&&(e.lineWrapping||m.widgetLineBreaks)&&(g=es(e,i,-1,g)),h&&g&&h.from==g.from&&h.to==g.to)return v(y(n.from,n.to,h));{let t=h?y(n.from,null,h):ee(p,!1),r=g?y(null,n.to,g):ee(m,!0),i=[];return(h||p).to<(g||m).from-(h&&g?1:0)||p.widgetLineBreaks>1&&t.bottom+e.defaultLineHeight/2<r.top?i.push(_(d,t.bottom,f,r.top)):t.bottom<r.top&&e.elementAtHeight((t.bottom+r.top)/2).type==F.Text&&(t.bottom=r.top=(t.bottom+r.top)/2),v(t).concat(i).concat(v(r))}function _(e,n,r,i){return new Qo(t,e-c.left,n-c.top,Math.max(0,r-e),i-n)}function v({top:e,bottom:t,horizontal:n}){let r=[];for(let i=0;i<n.length;i+=2)r.push(_(n[i],e,n[i+1],t));return r}function y(t,n,r){let i=1e9,o=-1e9,s=[];function c(t,n,c,l,u){let p=e.coordsAtPos(t,t==r.to?-2:2),m=e.coordsAtPos(c,c==r.from?2:-2);!p||!m||(i=Math.min(p.top,m.top,i),o=Math.max(p.bottom,m.bottom,o),u==L.LTR?s.push(a&&n?d:p.left,a&&l?f:m.right):s.push(!a&&l?d:m.left,!a&&n?f:p.right))}let l=t??r.from,u=n??r.to;for(let r of e.visibleRanges)if(r.to>l&&r.from<u)for(let i=Math.max(r.from,l),a=Math.min(r.to,u);;){let r=e.state.doc.lineAt(i);for(let o of e.bidiSpans(r)){let e=o.from+r.from,s=o.to+r.from;if(e>=a)break;s>i&&c(Math.max(e,i),t==null&&e<=l,Math.min(s,a),n==null&&s>=u,o.dir)}if(i=r.to+1,i>=a)break}return s.length==0&&c(l,t==null,u,n==null,e.textDirection),{top:i,bottom:o,horizontal:s}}function ee(e,t){let n=s.top+(t?e.top:e.bottom);return{top:n,bottom:n,horizontal:[]}}}function ns(e,t){return e.constructor==t.constructor&&e.eq(t)}var rs=class{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement(`div`)),this.dom.classList.add(`cm-layer`),t.above&&this.dom.classList.add(`cm-layer-above`),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute(`aria-hidden`,`true`),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(is)!=e.state.facet(is)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(is);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((e,t)=>!ns(e,this.drawn[t]))){let t=this.dom.firstChild,n=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[n].constructor&&r.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(r.draw(),t);for(;t;){let e=t.nextSibling;t.remove(),t=e}this.drawn=e,P.webkit&&(this.dom.style.display=this.dom.firstChild?``:`none`)}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},is=D.define();function as(e){return[jr.define(t=>new rs(t,e)),is.of(e)]}var os=D.define({combine(e){return gt(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function ss(e={}){return[os.of(e),ls,ds,fs,Cr.of(!0)]}function cs(e){return e.startState.facet(os)!=e.state.facet(os)}var ls=as({above:!0,markers(e){let{state:t}=e,n=t.facet(os),r=[];for(let i of t.selection.ranges){let a=i==t.selection.main;if(i.empty||n.drawRangeCursor&&!(a&&P.ios&&n.iosSelectionHandles)){let t=a?`cm-cursor cm-cursor-primary`:`cm-cursor cm-cursor-secondary`,n=i.empty?i:E.cursor(i.head,i.assoc);for(let i of Qo.forRange(e,t,n))r.push(i)}}return r},update(e,t){e.transactions.some(e=>e.selection)&&(t.style.animationName=t.style.animationName==`cm-blink`?`cm-blink2`:`cm-blink`);let n=cs(e);return n&&us(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){us(t.state,e)},class:`cm-cursorLayer`});function us(e,t){t.style.animationDuration=e.facet(os).cursorBlinkRate+`ms`}var ds=as({above:!1,markers(e){let t=[],{main:n,ranges:r}=e.state.selection;for(let n of r)if(!n.empty)for(let r of Qo.forRange(e,`cm-selectionBackground`,n))t.push(r);if(P.ios&&!n.empty&&e.state.facet(os).iosSelectionHandles){for(let r of Qo.forRange(e,`cm-selectionHandle cm-selectionHandle-start`,E.cursor(n.from,1)))t.push(r);for(let r of Qo.forRange(e,`cm-selectionHandle cm-selectionHandle-end`,E.cursor(n.to,1)))t.push(r)}return t},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||cs(e)},class:`cm-selectionLayer`}),fs=ze.highest(W.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`transparent !important`},caretColor:`transparent !important`},".cm-content":{caretColor:`transparent !important`,"& :focus":{caretColor:`initial !important`,"&::selection, & ::selection":{backgroundColor:`Highlight !important`}}}}));/x/.unicode;var ps=class extends fn{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement(`span`);return t.className=`cm-placeholder`,t.style.pointerEvents=`none`,t.appendChild(typeof this.content==`string`?document.createTextNode(this.content):typeof this.content==`function`?this.content(e):this.content.cloneNode(!0)),t.setAttribute(`aria-hidden`,`true`),t}coordsAt(e){let t=e.firstChild?Cn(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),r=kn(t[0],n.direction!=`rtl`),i=parseInt(n.lineHeight);return r.bottom-r.top>i*1.5?{left:r.left,right:r.right,top:r.top,bottom:r.top+i}:r}ignoreEvent(){return!1}};function ms(e){let t=jr.fromClass(class{constructor(t){this.view=t,this.placeholder=e?I.set([I.widget({widget:new ps(e),side:1}).range(0)]):I.none}get decorations(){return this.view.state.doc.length?I.none:this.placeholder}},{decorations:e=>e.decorations});return typeof e==`string`?[t,W.contentAttributes.of({"aria-placeholder":e})]:t}var hs=`-10000px`,gs=class{constructor(e,t,n,r){this.facet=t,this.createTooltipView=n,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let i=null;this.tooltipViews=this.tooltips.map(e=>i=n(e,i))}update(e,t){var n;let r=e.state.facet(this.facet),i=r.filter(e=>e);if(r===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let a=[],o=t?[]:null;for(let n=0;n<i.length;n++){let r=i[n],s=-1;if(r){for(let e=0;e<this.tooltips.length;e++){let t=this.tooltips[e];t&&t.create==r.create&&(s=e)}if(s<0)a[n]=this.createTooltipView(r,n?a[n-1]:null),o&&(o[n]=!!r.above);else{let r=a[n]=this.tooltipViews[s];o&&(o[n]=t[s]),r.update&&r.update(e)}}}for(let e of this.tooltipViews)a.indexOf(e)<0&&(this.removeTooltipView(e),(n=e.destroy)==null||n.call(e));return t&&(o.forEach((e,n)=>t[n]=e),t.length=o.length),this.input=r,this.tooltips=i,this.tooltipViews=a,!0}};function _s(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}var vs=D.define({combine:e=>({position:P.ios?`absolute`:e.find(e=>e.position)?.position||`fixed`,parent:e.find(e=>e.parent)?.parent||null,tooltipSpace:e.find(e=>e.tooltipSpace)?.tooltipSpace||_s})}),ys=new WeakMap,bs=jr.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(vs);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver==`function`?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new gs(e,ws,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver=typeof IntersectionObserver==`function`?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.win.addEventListener(`resize`,this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement(`div`),this.container.style.position=`relative`,this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,r=e.state.facet(vs);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let e of this.manager.tooltipViews)e.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let e of this.manager.tooltipViews)this.container.appendChild(e.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add(`cm-tooltip`),e.arrow&&!n.dom.querySelector(`.cm-tooltip > .cm-tooltip-arrow`)){let e=document.createElement(`div`);e.className=`cm-tooltip-arrow`,n.dom.appendChild(e)}return n.dom.style.position=this.position,n.dom.style.top=hs,n.dom.style.left=`0px`,this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener(`resize`,this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),(e=t.destroy)==null||e.call(t);this.parent&&this.container.remove(),(t=this.resizeObserver)==null||t.disconnect(),(n=this.intersectionObserver)==null||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if(this.position==`fixed`&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(P.safari){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}else n=!!e.offsetParent&&e.offsetParent!=this.container.ownerDocument.body}if(n||this.position==`absolute`)if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else ({scaleX:e,scaleY:t}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=Hr(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((e,t)=>{let n=this.manager.tooltipViews[t];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(vs).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){if(e.makeAbsolute){this.madeAbsolute=!0,this.position=`absolute`;for(let e of this.manager.tooltipViews)e.dom.style.position=`absolute`}let{visible:t,space:n,scaleX:r,scaleY:i}=e,a=[];for(let o=0;o<this.manager.tooltips.length;o++){let s=this.manager.tooltips[o],c=this.manager.tooltipViews[o],{dom:l}=c,u=e.pos[o],d=e.size[o];if(!u||s.clip!==!1&&(u.bottom<=Math.max(t.top,n.top)||u.top>=Math.min(t.bottom,n.bottom)||u.right<Math.max(t.left,n.left)-.1||u.left>Math.min(t.right,n.right)+.1)){l.style.top=hs;continue}let f=s.arrow?c.dom.querySelector(`.cm-tooltip-arrow`):null,p=f?7:0,m=d.right-d.left,h=ys.get(c)??d.bottom-d.top,g=c.offset||Cs,_=this.view.textDirection==L.LTR,v=d.width>n.right-n.left?_?n.left:n.right-d.width:_?Math.max(n.left,Math.min(u.left-(f?14:0)+g.x,n.right-m)):Math.min(Math.max(n.left,u.left-m+(f?14:0)-g.x),n.right-m),y=this.above[o];!s.strictSide&&(y?u.top-h-p-g.y<n.top:u.bottom+h+p+g.y>n.bottom)&&y==n.bottom-u.bottom>u.top-n.top&&(y=this.above[o]=!y);let ee=(y?u.top-n.top:n.bottom-u.bottom)-p;if(ee<h&&c.resize!==!1){if(ee<this.view.defaultLineHeight){l.style.top=hs;continue}ys.set(c,h),l.style.height=(h=ee)/i+`px`}else l.style.height&&(l.style.height=``);let b=y?u.top-h-p-g.y:u.bottom+p+g.y,x=v+m;if(c.overlap!==!0)for(let e of a)e.left<x&&e.right>v&&e.top<b+h&&e.bottom>b&&(b=y?e.top-h-2-p:e.bottom+p+2);if(this.position==`absolute`?(l.style.top=(b-e.parent.top)/i+`px`,xs(l,(v-e.parent.left)/r)):(l.style.top=b/i+`px`,xs(l,v/r)),f){let e=u.left+(_?g.x:-g.x)-(v+14-7);f.style.left=e/r+`px`}c.overlap!==!0&&a.push({left:v,top:b,right:x,bottom:b+h}),l.classList.toggle(`cm-tooltip-above`,y),l.classList.toggle(`cm-tooltip-below`,!y),c.positioned&&c.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=hs}},{eventObservers:{scroll(){this.maybeMeasure()}}});function xs(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+`px`)}var Ss=W.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:`border-box`},"&light .cm-tooltip":{border:`1px solid #bbb`,backgroundColor:`#f5f5f5`},"&light .cm-tooltip-section:not(:first-child)":{borderTop:`1px solid #bbb`},"&dark .cm-tooltip":{backgroundColor:`#333338`,color:`white`},".cm-tooltip-arrow":{height:`7px`,width:`14px`,position:`absolute`,zIndex:-1,overflow:`hidden`,"&:before, &:after":{content:`''`,position:`absolute`,width:0,height:0,borderLeft:`7px solid transparent`,borderRight:`7px solid transparent`},".cm-tooltip-above &":{bottom:`-7px`,"&:before":{borderTop:`7px solid #bbb`},"&:after":{borderTop:`7px solid #f5f5f5`,bottom:`1px`}},".cm-tooltip-below &":{top:`-7px`,"&:before":{borderBottom:`7px solid #bbb`},"&:after":{borderBottom:`7px solid #f5f5f5`,top:`1px`}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:`#333338`,borderBottomColor:`#333338`},"&:after":{borderTopColor:`transparent`,borderBottomColor:`transparent`}}}),Cs={x:0,y:0},ws=D.define({enables:[bs,Ss]});function Ts(e,t){let n=e.plugin(bs);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}var Es=class extends _t{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};Es.prototype.elementClass=``,Es.prototype.toDOM=void 0,Es.prototype.mapMode=ye.TrackBefore,Es.prototype.startSide=Es.prototype.endSide=-1,Es.prototype.point=!0;var Ds=1024,Os=0,ks=class{constructor(e,t){this.from=e,this.to=t}},G=class{constructor(e={}){this.id=Os++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error(`This node type doesn't define a deserialize function`)}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError(`Can't add per-node props to node types`);return typeof e!=`function`&&(e=Ms.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};G.closedBy=new G({deserialize:e=>e.split(` `)}),G.openedBy=new G({deserialize:e=>e.split(` `)}),G.group=new G({deserialize:e=>e.split(` `)}),G.isolate=new G({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),G.contextHash=new G({perNode:!0}),G.lookAhead=new G({perNode:!0}),G.mounted=new G({perNode:!0});var As=class{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[G.mounted.id]}},js=Object.create(null),Ms=class e{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(t){let n=t.props&&t.props.length?Object.create(null):js,r=!!t.top|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new e(t.name||``,n,t.id,r);if(t.props){for(let e of t.props)if(Array.isArray(e)||(e=e(i)),e){if(e[0].perNode)throw RangeError(`Can't store a per-node prop on a node type`);n[e[0].id]=e[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e==`string`){if(this.name==e)return!0;let t=this.prop(G.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(` `))t[r]=e[n];return e=>{for(let n=e.prop(G.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};Ms.none=new Ms(``,Object.create(null),0,8);var Ns=new WeakMap,Ps=new WeakMap,K;(function(e){e[e.ExcludeBuffers=1]=`ExcludeBuffers`,e[e.IncludeAnonymous=2]=`IncludeAnonymous`,e[e.IgnoreMounts=4]=`IgnoreMounts`,e[e.IgnoreOverlays=8]=`IgnoreOverlays`,e[e.EnterBracketed=16]=`EnterBracketed`})(K||={});var q=class e{constructor(e,t,n,r,i){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props[typeof e==`number`?e:e.id]=t}}toString(){let e=As.get(this);if(e&&!e.overlay)return e.tree.toString();let t=``;for(let e of this.children){let n=e.toString();n&&(t&&(t+=`,`),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?`(`+t+`)`:``):t}cursor(e=0){return new Js(this.topNode,e)}cursorAt(e,t=0,n=0){let r=new Js(Ns.get(this)||this.topNode);return r.moveTo(e,t),Ns.set(this,r._tree),r}get topNode(){return new Bs(this,0,0,null)}resolve(e,t=0){let n=Rs(Ns.get(this)||this.topNode,e,t,!1);return Ns.set(this,n),n}resolveInner(e,t=0){let n=Rs(Ps.get(this)||this.topNode,e,t,!0);return Ps.set(this,n),n}resolveStack(e,t=0){return qs(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,a=e.mode||0,o=(a&K.IncludeAnonymous)>0;for(let e=this.cursor(a|K.IncludeAnonymous);;){let a=!1;if(e.from<=i&&e.to>=r&&(!o&&e.type.isAnonymous||t(e)!==!1)){if(e.firstChild())continue;a=!0}for(;a&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;a=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(t={}){return this.children.length<=8?this:$s(Ms.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new e(this.type,t,n,r,this.propValues),t.makeTree||((t,n,r)=>new e(Ms.none,t,n,r)))}static build(e){return Xs(e)}};q.empty=new q(Ms.none,[],[],0);var Fs=class e{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new e(this.buffer,this.index)}},Is=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return Ms.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(`,`)}childString(e){let t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),e+=4,n==e)return i;let a=[];for(;e<n;)a.push(this.childString(e)),e=this.buffer[e+3];return i+`(`+a.join(`,`)+`)`}findChild(e,t,n,r,i){let{buffer:a}=this,o=-1;for(let s=e;s!=t&&!(Ls(i,r,a[s+1],a[s+2])&&(o=s,n>0));s=a[s+3]);return o}slice(t,n,r){let i=this.buffer,a=new Uint16Array(n-t),o=0;for(let e=t,s=0;e<n;){a[s++]=i[e++],a[s++]=i[e++]-r;let n=a[s++]=i[e++]-r;a[s++]=i[e++]-t,o=Math.max(o,n)}return new e(a,o,this.set)}};function Ls(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function Rs(e,t,n,r){for(;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!r&&e instanceof Bs&&e.index<0?null:e.parent;if(!t)return e;e=t}let i=r?0:K.IgnoreOverlays;if(r)for(let r=e,a=r.parent;a;r=a,a=r.parent)r instanceof Bs&&r.index<0&&a.enter(t,n,i)?.from!=r.from&&(e=a);for(;;){let r=e.enter(t,n,i);if(!r)return e;e=r}}var zs=class{cursor(e=0){return new Js(this,e)}getChild(e,t=null,n=null){let r=Vs(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return Vs(this,e,t,n)}resolve(e,t=0){return Rs(this,e,t,!1)}resolveInner(e,t=0){return Rs(this,e,t,!0)}matchContext(e){return Hs(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}},Bs=class e extends zs{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,n,r,i,a=0){for(let o=this;;){for(let{children:s,positions:c}=o._tree,l=n>0?s.length:-1;t!=l;t+=n){let l=s[t],u=c[t]+o.from,d;if(!(!(a&K.EnterBracketed&&l instanceof q&&(d=As.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length)&&!Ls(i,r,u,u+l.length))){if(l instanceof Is){if(a&K.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new Ws(new Us(o,l,t,u),null,e)}else if(a&K.IncludeAnonymous||!l.type.isAnonymous||Ys(l)){let s;if(!(a&K.IgnoreMounts)&&(s=As.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&K.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&K.IncludeAnonymous||!o.type.isAnonymous||(t=o.index>=0?o.index+n:n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(t,n,r=0){let i;if(!(r&K.IgnoreOverlays)&&(i=As.get(this._tree))&&i.overlay){let a=t-this.from,o=r&K.EnterBracketed&&i.bracketed;for(let{from:t,to:r}of i.overlay)if((n>0||o?t<=a:t<a)&&(n<0||o?r>=a:r>a))return new e(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function Vs(e,t,n,r){let i=e.cursor(),a=[];if(!i.firstChild())return a;if(n!=null){for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return a}for(;;){if(r!=null&&i.type.is(r))return a;if(i.type.is(t)&&a.push(i.node),!i.nextSibling())return r==null?a:[]}}function Hs(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}var Us=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},Ws=class e extends zs{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(t,n,r){let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return a<0?null:new e(this.context,this,a)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(t,n,r=0){if(r&K.ExcludeBuffers)return null;let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return a<0?null:new e(this.context,this,a)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new e(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new e(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let a=n.buffer[this.index+1];e.push(n.slice(r,i,a)),t.push(0)}return new q(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function Gs(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;r<e.length;r++){let i=e[r];(i.from>n.from||i.to<n.to)&&(n=i,t=r)}let r=n instanceof Bs&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new Ks(i,n)}var Ks=class{constructor(e,t){this.heads=e,this.node=t}get next(){return Gs(this.heads)}};function qs(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof Bs?r:r.context.parent;e;e=e.parent)if(e.index<0){let a=e.parent;(i||=[r]).push(a.resolve(t,n)),e=a}else{let a=As.get(e.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new Bs(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(Rs(o,t,n,!1))}}return i?Gs(i):r}var Js=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~K.EnterBracketed,e instanceof Bs)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof Bs?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&K.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&K.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&K.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(r.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=r)}else ({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&K.IncludeAnonymous||e instanceof Is||!e.type.isAnonymous||Ys(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)scan:for(let r=this.index,i=this.stack.length;i>=0;){for(let a=e;a;a=a._parent)if(a.index==r){if(r==this.index)return a;t=a,n=i+1;break scan}r=this.stack[--i]}for(let e=n;e<this.stack.length;e++)t=new Ws(this.buffer,t,this.stack[e]);return this.bufferNode=new Ws(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return Hs(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return Hs(this._tree,e,r);let a=n[t.buffer[this.stack[i]]];if(!a.isAnonymous){if(e[r]&&e[r]!=a.name)return!1;r--}}return!0}};function Ys(e){return e.children.some(e=>e instanceof Is||!e.type.isAnonymous||Ys(e))}function Xs(e){let{buffer:t,nodeSet:n,maxBufferLength:r=Ds,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new Fs(t,t.length):t,s=n.types,c=0,l=0;function u(e,t,_,v,y,ee){let{id:b,start:x,end:te,size:ne}=o,re=l,S=c;if(ne<0)if(o.next(),ne==-1){let t=i[b];_.push(t),v.push(x-e);return}else if(ne==-3){c=b;return}else if(ne==-4){l=b;return}else throw RangeError(`Unrecognized record size: ${ne}`);let C=s[b],ie,ae,oe=x-e;if(te-x<=r&&(ae=h(o.pos-t,y))){let t=new Uint16Array(ae.size-ae.skip),r=o.pos-ae.size,i=t.length;for(;o.pos>r;)i=g(ae.start,t,i);ie=new Is(t,te-ae.start,n),oe=ae.start-e}else{let e=o.pos-ne;o.next();let t=[],n=[],i=b>=a?b:-1,s=0,c=te;for(;o.pos>e;)i>=0&&o.id==i&&o.size>=0?(o.end<=c-r&&(p(t,n,x,s,o.end,c,i,re,S),s=t.length,c=o.end),o.next()):ee>2500?d(x,e,t,n):u(x,e,t,n,i,ee+1);if(i>=0&&s>0&&s<t.length&&p(t,n,x,s,x,c,i,re,S),t.reverse(),n.reverse(),i>-1&&s>0){let e=f(C,S);ie=$s(C,t,n,0,t.length,0,te-x,e,e)}else ie=m(C,t,n,te-x,re-te,S)}_.push(ie),v.push(oe)}function d(e,t,i,a){let s=[],c=0,l=-1;for(;o.pos>t;){let{id:e,start:t,end:n,size:i}=o;if(i>4)o.next();else if(l>-1&&t<l)break;else l<0&&(l=n-r),s.push(e,t,n),c++,o.next()}if(c){let t=new Uint16Array(c*4),r=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;i.push(new Is(t,s[2]-r,n)),a.push(r-e)}}function f(e,t){return(n,r,i)=>{let a=0,o=n.length-1,s,c;if(o>=0&&(s=n[o])instanceof q){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(G.lookAhead))&&(a=r[o]+s.length+c)}return m(e,n,r,i,a,t)}}function p(e,t,r,i,a,o,s,c,l){let u=[],d=[];for(;e.length>i;)u.push(e.pop()),d.push(t.pop()+r-a);e.push(m(n.types[s],u,d,o-a,c-o,l)),t.push(a-r)}function m(e,t,n,r,i,a,o){if(a){let e=[G.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[G.lookAhead,i];o=o?[e].concat(o):[e]}return new q(e,t,n,r,o)}function h(e,t){let n=o.fork(),i=0,s=0,c=0,l=n.end-r,u={size:0,start:0,skip:0};scan:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){u.size=i,u.start=s,u.skip=c,c+=4,i+=4,n.next();continue}let o=n.pos-e;if(e<0||o<r||n.start<l)break;let d=n.id>=a?4:0,f=n.start;for(n.next();n.pos>o;){if(n.size<0)if(n.size==-3||n.size==-4)d+=4;else break scan;else n.id>=a&&(d+=4);n.next()}s=f,i+=e,c+=d}return(t<0||i==e)&&(u.size=i,u.start=s,u.skip=c),u.size>4?u:void 0}function g(e,t,n){let{id:r,start:i,end:s,size:u}=o;if(o.next(),u>=0&&r<a){let a=n;if(u>4){let r=o.pos-(u-4);for(;o.pos>r;)n=g(e,t,n)}t[--n]=a,t[--n]=s-e,t[--n]=i-e,t[--n]=r}else u==-3?c=r:u==-4&&(l=r);return n}let _=[],v=[];for(;o.pos>0;)u(e.start||0,e.bufferStart||0,_,v,-1,0);let y=e.length??(_.length?v[0]+_[0].length:0);return new q(s[e.topID],_.reverse(),v.reverse(),y)}var Zs=new WeakMap;function Qs(e,t){if(!e.isAnonymous||t instanceof Is||t.type!=e)return 1;let n=Zs.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof q)){n=1;break}n+=Qs(e,r)}Zs.set(t,n)}return n}function $s(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n<i;n++)l+=Qs(e,t[n]);let u=Math.ceil(l*1.5/8),d=[],f=[];function p(t,n,r,i,o){for(let s=r;s<i;){let r=s,l=n[s],m=Qs(e,t[s]);for(s++;s<i;s++){let n=Qs(e,t[s]);if(m+n>=u)break;m+=n}if(s==r+1){if(m>u){let e=t[r];p(e.children,e.positions,0,e.children.length,n[r]+o);continue}d.push(t[r])}else{let i=n[s-1]+t[s-1].length-l;d.push($s(e,t,n,r,s,l,i,null,c))}f.push(l+o-a)}}return p(t,n,r,i,0),(s||c)(d,f,o)}var ec=class e{constructor(e,t,n,r,i=!1,a=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=!!i|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new e(0,t.length,t,0,!1,r)];for(let e of n)e.to>t.length&&i.push(e);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],a=1,o=t.length?t[0]:null;for(let s=0,c=0,l=0;;s++){let u=s<n.length?n[s]:null,d=u?u.fromA:1e9;if(d-c>=r)for(;o&&o.from<d;){let n=o;if(c>=n.from||d<=n.to||l){let t=Math.max(n.from,c)-l,r=Math.min(n.to,d)-l;n=t>=r?null:new e(t,r,n.tree,n.offset+l,s>0,!!u)}if(n&&i.push(n),o.to>d)break;o=a<t.length?t[a++]:null}if(!u)break;c=u.toA,l=u.toA-u.toB}return i}},tc=class{startParse(e,t,n){return typeof e==`string`&&(e=new nc(e)),n=n?n.length?n.map(e=>new ks(e.from,e.to)):[new ks(0,0)]:[new ks(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}},nc=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};new G({perNode:!0});var rc=0,ic=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=rc++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(t,n){let r=typeof t==`string`?t:`?`;if(t instanceof e&&(n=t),n?.base)throw Error(`Can not derive from a modified tag`);let i=new e(r,[],null,[]);if(i.set.push(i),n)for(let e of n.set)i.set.push(e);return i}static defineModifier(e){let t=new oc(e);return e=>e.modified.indexOf(t)>-1?e:oc.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},ac=0,oc=class e{constructor(e){this.name=e,this.instances=[],this.id=ac++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&sc(n,e.modified));if(r)return r;let i=[],a=new ic(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=cc(n);for(let n of t.set)if(!n.modified.length)for(let t of o)i.push(e.get(n,t));return a}};function sc(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function cc(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}function lc(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(` `))if(e){let n=[],i=2,a=e;for(let t=0;;){if(a==`...`&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!r)throw RangeError(`Invalid path: `+e);if(n.push(r[0]==`*`?``:r[0][0]==`"`?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&o==`!`){i=0;break}if(o!=`/`)throw RangeError(`Invalid path: `+e);a=e.slice(t)}let o=n.length-1,s=n[o];if(!s)throw RangeError(`Invalid path: `+e);t[s]=new dc(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return uc.add(t)}var uc=new G({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth>=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let a=new dc(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),dc=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};dc.empty=new dc([],2,null);function fc(e,t){let n=Object.create(null);for(let t of e)if(!Array.isArray(t.tag))n[t.tag.id]=t.class;else for(let e of t.tag)n[e.id]=t.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+` `+r:r;break}}return t},scope:r}}var J=ic.define,pc=J(),mc=J(),hc=J(mc),gc=J(mc),_c=J(),vc=J(_c),yc=J(_c),bc=J(),xc=J(bc),Sc=J(),Cc=J(),wc=J(),Tc=J(wc),Ec=J(),Y={comment:pc,lineComment:J(pc),blockComment:J(pc),docComment:J(pc),name:mc,variableName:J(mc),typeName:hc,tagName:J(hc),propertyName:gc,attributeName:J(gc),className:J(mc),labelName:J(mc),namespace:J(mc),macroName:J(mc),literal:_c,string:vc,docString:J(vc),character:J(vc),attributeValue:J(vc),number:yc,integer:J(yc),float:J(yc),bool:J(_c),regexp:J(_c),escape:J(_c),color:J(_c),url:J(_c),keyword:Sc,self:J(Sc),null:J(Sc),atom:J(Sc),unit:J(Sc),modifier:J(Sc),operatorKeyword:J(Sc),controlKeyword:J(Sc),definitionKeyword:J(Sc),moduleKeyword:J(Sc),operator:Cc,derefOperator:J(Cc),arithmeticOperator:J(Cc),logicOperator:J(Cc),bitwiseOperator:J(Cc),compareOperator:J(Cc),updateOperator:J(Cc),definitionOperator:J(Cc),typeOperator:J(Cc),controlOperator:J(Cc),punctuation:wc,separator:J(wc),bracket:Tc,angleBracket:J(Tc),squareBracket:J(Tc),paren:J(Tc),brace:J(Tc),content:bc,heading:xc,heading1:J(xc),heading2:J(xc),heading3:J(xc),heading4:J(xc),heading5:J(xc),heading6:J(xc),contentSeparator:J(bc),list:J(bc),quote:J(bc),emphasis:J(bc),strong:J(bc),link:J(bc),monospace:J(bc),strikethrough:J(bc),inserted:J(),deleted:J(),changed:J(),invalid:J(),meta:Ec,documentMeta:J(Ec),annotation:J(Ec),processingInstruction:J(Ec),definition:ic.defineModifier(`definition`),constant:ic.defineModifier(`constant`),function:ic.defineModifier(`function`),standard:ic.defineModifier(`standard`),local:ic.defineModifier(`local`),special:ic.defineModifier(`special`)};for(let e in Y){let t=Y[e];t instanceof ic&&(t.name=e)}fc([{tag:Y.link,class:`tok-link`},{tag:Y.heading,class:`tok-heading`},{tag:Y.emphasis,class:`tok-emphasis`},{tag:Y.strong,class:`tok-strong`},{tag:Y.keyword,class:`tok-keyword`},{tag:Y.atom,class:`tok-atom`},{tag:Y.bool,class:`tok-bool`},{tag:Y.url,class:`tok-url`},{tag:Y.labelName,class:`tok-labelName`},{tag:Y.inserted,class:`tok-inserted`},{tag:Y.deleted,class:`tok-deleted`},{tag:Y.literal,class:`tok-literal`},{tag:Y.string,class:`tok-string`},{tag:Y.number,class:`tok-number`},{tag:[Y.regexp,Y.escape,Y.special(Y.string)],class:`tok-string2`},{tag:Y.variableName,class:`tok-variableName`},{tag:Y.local(Y.variableName),class:`tok-variableName tok-local`},{tag:Y.definition(Y.variableName),class:`tok-variableName tok-definition`},{tag:Y.special(Y.variableName),class:`tok-variableName2`},{tag:Y.definition(Y.propertyName),class:`tok-propertyName tok-definition`},{tag:Y.typeName,class:`tok-typeName`},{tag:Y.namespace,class:`tok-namespace`},{tag:Y.className,class:`tok-className`},{tag:Y.macroName,class:`tok-macroName`},{tag:Y.propertyName,class:`tok-propertyName`},{tag:Y.operator,class:`tok-operator`},{tag:Y.comment,class:`tok-comment`},{tag:Y.meta,class:`tok-meta`},{tag:Y.invalid,class:`tok-invalid`},{tag:Y.punctuation,class:`tok-punctuation`}]);var Dc=new G,Oc=new G,kc=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,A.prototype.hasOwnProperty(`tree`)||Object.defineProperty(A.prototype,"tree",{get(){return jc(this)}}),this.parser=t,this.extension=[Bc.of(this),A.languageData.of((e,t,n)=>{let r=Ac(e,t,n),i=r.type.prop(Dc);if(!i)return[];let a=e.facet(i),o=r.type.prop(Oc);if(o){let i=r.resolve(t-r.from,n);for(let t of o)if(t.test(i,e)){let n=e.facet(t.facet);return t.type==`replace`?n:n.concat(a)}}return a})].concat(n)}isActiveAt(e,t,n=-1){return Ac(e,t,n).type.prop(Dc)==this.data}findRegions(e){let t=e.facet(Bc);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(Dc)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(G.mounted);if(i){if(i.tree.prop(Dc)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}else if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let i=e.children[n];i instanceof q&&r(i,e.positions[n]+t)}};return r(jc(e),0),n}get allowsNesting(){return!0}};kc.setState=O.define();function Ac(e,t,n){let r=e.facet(Bc),i=jc(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,K.ExcludeBuffers|K.EnterBracketed))e.type.isTop&&(i=e);return i}function jc(e){let t=e.field(kc.state,!1);return t?t.tree:q.empty}var Mc=class{constructor(e){this.doc=e,this.cursorPos=0,this.string=``,this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},Nc=null,Pc=class e{constructor(e,t,n=[],r,i,a,o,s){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=a,this.skipped=o,this.scheduleOn=s,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new e(t,n,[],q.empty,0,r,[],null)}startParse(){return this.parser.startParse(new Mc(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=q.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{if(typeof e==`number`){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||=this.startParse(),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let n=this.parse.advance();if(n)if(this.fragments=this.withoutTempSkipped(ec.addTree(n,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=this.parse.stoppedAt??this.state.doc.length,this.tree=n,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(ec.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Nc;Nc=this;try{return e()}finally{Nc=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Fc(e,t.from,t.to);return e}changes(t,n){let{fragments:r,tree:i,treeLen:a,viewport:o,skipped:s}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,n,r,i)=>e.push({fromA:t,toA:n,fromB:r,toB:i})),r=ec.applyChanges(r,e),i=q.empty,a=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){s=[];for(let e of this.skipped){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);n<r&&s.push({from:n,to:r})}}}return new e(this.parser,n,r,i,a,o,s,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:r}=this.skipped[t];n<e.to&&r>e.from&&(this.fragments=Fc(this.fragments,n,r),this.skipped.splice(t--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&=(this.takeTree(),null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends tc{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=Nc;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=a,new q(Ms.none,[],[],a-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Nc}};function Fc(e,t,n){return ec.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var Ic=class e{constructor(e){this.context=e,this.tree=e.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new e(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=Pc.create(t.facet(Bc).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};kc.state=Ie.define({create:Ic.init,update(e,t){for(let e of t.effects)if(e.is(kc.setState))return e.value;return t.startState.facet(Bc)==t.state.facet(Bc)?e.apply(t):Ic.init(t.state)}});var Lc=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(Lc=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var Rc=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,zc=jr.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(kc.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(kc.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Lc(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,i=n.field(kc.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!Rc?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<r&&n.doc.length>r+1e3,s=i.context.work(()=>Rc&&Rc()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:kc.setState.of(new Ic(i.context))})),this.chunkBudget>0&&!(s&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&=(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>z(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Bc=D.define({combine(e){return e.length?e[0]:null},enables:e=>[kc.state,zc,W.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),Vc=D.define(),Hc=D.define({combine:e=>{if(!e.length)return` `;let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw Error(`Invalid indent unit: `+JSON.stringify(e[0]));return t}});function Uc(e){let t=e.facet(Hc);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function Wc(e,t){let n=``,r=e.tabSize,i=e.facet(Hc)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e<t;e++)n+=i;return n}function Gc(e,t){e instanceof A&&(e=new Kc(e));for(let n of e.state.facet(Vc)){let r=n(e,t);if(r!==void 0)return r}let n=jc(e.state);return n.length>=t?Jc(e,n,t):null}var Kc=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Uc(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=n.from&&r<=n.to?i&&r==e?{text:``,from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return``;let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),a=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return a>-1&&(i+=a-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return Pt(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},qc=new G;function Jc(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t&&!(t.from<r.node.from||t.to>r.node.to||t.from==r.node.from&&t.type==r.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return Yc(r,e,n)}function Yc(e,t,n){for(let r=e;r;r=r.next){let e=Zc(r.node);if(e)return e($c.create(t,n,r))}return 0}function Xc(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function Zc(e){let t=e.type.prop(qc);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(G.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>nl(e,!0,1,void 0,n&&!Xc(e)?t.from:void 0)}return e.parent==null?Qc:null}function Qc(){return 0}var $c=class e extends Kc{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(t,n,r){return new e(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(el(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return Yc(this.context.next,this.base,this.pos)}};function el(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function tl(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,a=e.state.doc.lineAt(n.from),o=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==r)return null;if(!i.type.isSkipped){if(i.from>=o)return null;let e=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}function nl(e,t,n,r,i){let a=e.textAfter,o=a.match(/^\s*/)[0].length,s=r&&a.slice(o,o+r.length)==r||i==e.pos+o,c=t?tl(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}Y.meta,Y.link,Y.heading,Y.emphasis,Y.strong,Y.strikethrough,Y.keyword,Y.atom,Y.bool,Y.url,Y.contentSeparator,Y.labelName,Y.literal,Y.inserted,Y.string,Y.deleted,Y.regexp,Y.escape,Y.string,Y.variableName,Y.variableName,Y.typeName,Y.namespace,Y.className,Y.variableName,Y.macroName,Y.propertyName,Y.comment,Y.invalid;var rl=1e4,il=`()[]{}`,al=new G;function ol(e,t,n){let r=e.prop(t<0?G.openedBy:G.closedBy);if(r)return r;if(e.name.length==1){let r=n.indexOf(e.name);if(r>-1&&r%2==+(t<0))return[n[r+t]]}return null}function sl(e){let t=e.type.prop(al);return t?t(e.node):e}function cl(e,t,n,r={}){let i=r.maxScanDistance||rl,a=r.brackets||il,o=jc(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=ol(r.type,n,a);if(i&&r.from<r.to){let o=sl(r);if(o&&(n>0?t>=o.from&&t<o.to:t>o.from&&t<=o.to))return ll(e,t,n,r,o,i,a)}}return ul(e,t,n,o,s.type,i,a)}function ll(e,t,n,r,i,a,o){let s=r.parent,c={from:i.from,to:i.to},l=0,u=s?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(l==0&&a.indexOf(u.type.name)>-1&&u.from<u.to){let e=sl(u);return{start:c,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}else if(ol(u.type,n,o))l++;else if(ol(u.type,-n,o)){if(l==0){let e=sl(u);return{start:c,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}l--}}while(n<0?u.prevSibling():u.nextSibling());return{start:c,matched:!1}}function ul(e,t,n,r,i,a,o){if(n<0?!t:t==e.doc.length)return null;let s=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),c=o.indexOf(s);if(c<0||c%2==0!=n>0)return null;let l={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let e=0;!u.next().done&&e<=a;){let a=u.value;n<0&&(e+=a.length);let s=t+e*n;for(let e=n>0?0:a.length-1,t=n>0?a.length:-1;e!=t;e+=n){let t=o.indexOf(a[e]);if(!(t<0||r.resolveInner(s+e,1).type!=i))if(t%2==0==n>0)d++;else if(d==1)return{start:l,end:{from:s+e,to:s+e+1},matched:t>>1==c>>1};else d--}n>0&&(e+=a.length)}return u.done?{start:l,matched:!1}:null}var dl=Object.create(null),fl=[Ms.none],pl=[],ml=Object.create(null),hl=Object.create(null);for(let[e,t]of[[`variable`,`variableName`],[`variable-2`,`variableName.special`],[`string-2`,`string.special`],[`def`,`variableName.definition`],[`tag`,`tagName`],[`attribute`,`attributeName`],[`type`,`typeName`],[`builtin`,`variableName.standard`],[`qualifier`,`modifier`],[`error`,`invalid`],[`header`,`heading`],[`property`,`propertyName`]])hl[e]=_l(dl,t);function gl(e,t){pl.indexOf(e)>-1||(pl.push(e),console.warn(t))}function _l(e,t){let n=[];for(let r of t.split(` `)){let t=[];for(let n of r.split(`.`)){let r=e[n]||Y[n];r?typeof r==`function`?t.length?t=t.map(r):gl(n,`Modifier ${n} used at start of tag`):t.length?gl(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:gl(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,`_`),i=r+` `+n.map(e=>e.id),a=ml[i];if(a)return a.id;let o=ml[i]=Ms.define({id:fl.length,name:r,props:[lc({[r]:n})]});return fl.push(o),o.id}L.RTL,L.LTR;var vl=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=jc(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(wl(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e==`abort`&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function yl(e){let t=Object.keys(e).join(``),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,``)),`[${n?`\\w`:``}${t.replace(/[^\w\s]/g,`\\$&`)}]`}function bl(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=yl(t)+yl(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function xl(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:bl(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}var Sl=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function Cl(e){return e.selection.main.from}function wl(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}var Tl=et.define();function El(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return{...e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let c=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:c},range:E.cursor(s.from+a+c.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var Dl=new WeakMap;function Ol(e){if(!Array.isArray(e))return e;let t=Dl.get(e);return t||Dl.set(e,t=xl(e)),t}var kl=O.define(),Al=O.define(),jl=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=he(e,t),r=_e(n);this.chars.push(n);let i=e.slice(t,t+r),a=i.toUpperCase();this.folded.push(he(a==i?i.toLowerCase():a,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:r,precise:i,byWord:a}=this;if(t.length==1){let r=he(e,0),i=_e(r),a=i==e.length?0:-100;if(r!=t[0])if(r==n[0])a+=-200;else return null;return this.ret(a,[0,i])}let o=e.indexOf(this.pattern);if(o==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let s=t.length,c=0;if(o<0){for(let i=0,a=Math.min(e.length,200);i<a&&c<s;){let a=he(e,i);(a==t[c]||a==n[c])&&(r[c++]=i),i+=_e(a)}if(c<s)return null}let l=0,u=0,d=!1,f=0,p=-1,m=-1,h=/[a-z]/.test(e),g=!0;for(let r=0,c=Math.min(e.length,200),_=0;r<c&&u<s;){let c=he(e,r);o<0&&(l<s&&c==t[l]&&(i[l++]=r),f<s&&(c==t[f]||c==n[f]?(f==0&&(p=r),m=r+1,f++):f=0));let v,y=c<255?c>=48&&c<=57||c>=97&&c<=122?2:+(c>=65&&c<=90):(v=ge(c))==v.toLowerCase()?v==v.toUpperCase()?0:2:1;(!r||y==1&&h||_==0&&y!=0)&&(t[u]==c||n[u]==c&&(d=!0)?a[u++]=r:a.length&&(g=!1)),_=y,r+=_e(c)}return u==s&&a[0]==0&&g?this.result(-100+(d?-200:0),a,e):f==s&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):f==s?this.ret(-900-e.length,[p,m]):u==s?this.result(-100+(d?-200:0)+-700+(g?0:-1100),a,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,n){let r=[],i=0;for(let e of t){let t=e+(this.astral?_e(he(n,e)):1);i&&r[i-1]==e?r[i-1]=t:(r[i++]=e,r[i++]=t)}return this.ret(e-n.length,r)}},Ml=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}},X=D.define({combine(e){return gt(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>``,optionClass:()=>``,aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Pl,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>Nl(e(n),t(n)),optionClass:(e,t)=>n=>Nl(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function Nl(e,t){return e?t?e+` `+t:e:t}function Pl(e,t,n,r,i,a){let o=e.textDirection==L.RTL,s=o,c=!1,l=`top`,u,d,f=t.left-i.left,p=i.right-t.right,m=r.right-r.left,h=r.bottom-r.top;if(s&&f<Math.min(m,p)?s=!1:!s&&p<Math.min(m,f)&&(s=!0),m<=(s?f:p))u=Math.max(i.top,Math.min(n.top,i.bottom-h))-t.top,d=Math.min(400,s?f:p);else{c=!0,d=Math.min(400,(o?t.right:i.right-t.left)-30);let e=i.bottom-t.bottom;e>=h||e>t.top?u=n.bottom-t.top:(l=`bottom`,u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,_=(t.right-t.left)/a.offsetWidth;return{style:`${l}: ${u/g}px; max-width: ${d/_}px`,class:`cm-completionInfo-`+(c?o?`left-narrow`:`right-narrow`:s?`left`:`right`)}}var Fl=O.define();function Il(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement(`div`);return t.classList.add(`cm-completionIcon`),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>`cm-completionIcon-`+e)),t.setAttribute(`aria-hidden`,`true`),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement(`span`);i.className=`cm-completionLabel`;let a=e.displayLabel||e.label,o=0;for(let e=0;e<r.length;){let t=r[e++],n=r[e++];t>o&&i.appendChild(document.createTextNode(a.slice(o,t)));let s=i.appendChild(document.createElement(`span`));s.appendChild(document.createTextNode(a.slice(t,n))),s.className=`cm-completionMatchedText`,o=n}return o<a.length&&i.appendChild(document.createTextNode(a.slice(o))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement(`span`);return t.className=`cm-completionDetail`,t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}function Ll(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.ceil((e-t)/n);return{from:e-r*n,to:e-(r-1)*n}}var Rl=class{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass=``;let r=e.state.field(t),{options:i,selected:a}=r.open,o=e.state.facet(X);this.optionContent=Il(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=Ll(i.length,a,o.maxRenderedOptions),this.dom=document.createElement(`div`),this.dom.className=`cm-tooltip-autocomplete`,this.updateTooltipClass(e.state),this.dom.addEventListener(`mousedown`,n=>{let{options:r}=e.state.field(t).open;for(let t=n.target,i;t&&t!=this.dom;t=t.parentNode)if(t.nodeName==`LI`&&(i=/-(\d+)$/.exec(t.id))&&+i[1]<r.length){this.applyCompletion(e,r[+i[1]]),n.preventDefault();return}if(n.target==this.list){let t=this.list.classList.contains(`cm-completionListIncompleteTop`)&&n.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains(`cm-completionListIncompleteBottom`)&&n.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;t!=null&&(e.dispatch({effects:Fl.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(X).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:Al.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener(`scroll`,()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){let t=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),t!=n){let{options:r,selected:i,disabled:a}=t.open;(!n.open||n.open.options!=r)&&(this.range=Ll(r.length,i,e.state.facet(X).maxRenderedOptions),this.showOptions(r,t.id)),this.updateSel(),a!=n.open?.disabled&&this.dom.classList.toggle(`cm-tooltip-autocomplete-disabled`,!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(` `))e&&this.dom.classList.remove(e);for(let e of t.split(` `))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=Ll(t.options.length,t.selected,this.view.state.facet(X).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let a=typeof i==`string`?document.createTextNode(i):i(r);if(!a)return;`then`in a?a.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,r)}).catch(e=>z(this.view.state,e,`completion info`)):(this.addInfoPane(a,r),n.setAttribute(`aria-describedby`,this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement(`div`);if(n.className=`cm-tooltip cm-completionInfo`,n.id=`cm-completionInfo-`+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!=`LI`||!n.id?r--:r==e?n.hasAttribute(`aria-selected`)||(n.setAttribute(`aria-selected`,`true`),t=n):n.hasAttribute(`aria-selected`)&&(n.removeAttribute(`aria-selected`),n.removeAttribute(`aria-describedby`));return t&&Bl(this.list,t),t}measureInfo(){let e=this.dom.querySelector(`[aria-selected]`);if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(X).positionInfo(this.view,t,r,n,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className=`cm-tooltip cm-completionInfo `+(e.class||``)):this.info.style.cssText=`top: -1e6px`)}createListBox(e,t,n){let r=document.createElement(`ul`);r.id=t,r.setAttribute(`role`,`listbox`),r.setAttribute(`aria-expanded`,`true`),r.setAttribute(`aria-label`,this.view.state.phrase(`Completions`)),r.addEventListener(`mousedown`,e=>{e.target==r&&e.preventDefault()});let i=null;for(let a=n.from;a<n.to;a++){let{completion:o,match:s}=e[a],{section:c}=o;if(c){let e=typeof c==`string`?c:c.name;if(e!=i&&(a>n.from||n.from==0))if(i=e,typeof c!=`string`&&c.header)r.appendChild(c.header(c));else{let t=r.appendChild(document.createElement(`completion-section`));t.textContent=e}}let l=r.appendChild(document.createElement(`li`));l.id=t+`-`+a,l.setAttribute(`role`,`option`);let u=this.optionClass(o);u&&(l.className=u);for(let e of this.optionContent){let t=e(o,this.view.state,this.view,s);t&&l.appendChild(t)}}return n.from&&r.classList.add(`cm-completionListIncompleteTop`),n.to<e.length&&r.classList.add(`cm-completionListIncompleteBottom`),r}destroyInfo(){this.info&&=(this.infoDestroy&&this.infoDestroy(),this.info.remove(),null)}destroy(){this.destroyInfo()}};function zl(e,t){return n=>new Rl(n,e,t)}function Bl(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function Vl(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+ +!!e.type}function Hl(e,t){let n=[],r=null,i=null,a=e=>{n.push(e);let{section:t}=e.completion;if(t){r||=[];let e=typeof t==`string`?t:t.name;r.some(t=>t.name==e)||r.push(typeof t==`string`?{name:e}:t)}},o=t.facet(X);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(r.result.filter===!1)for(let t of r.result.options)a(new Sl(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new Ml(n):new jl(n);for(let t of r.result.options)if(s=c.match(t.label)){let n=t.displayLabel?e?e(t,s.matched):[]:s.matched,o=s.score+(t.boost||0);if(a(new Sl(t,r.source,n,o)),typeof t.section==`object`&&t.section.rank===`dynamic`){let{name:e}=t.section;i||=Object.create(null),i[e]=Math.max(o,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,a=(e,t)=>(e.rank===`dynamic`&&t.rank===`dynamic`?i[t.name]-i[e.name]:0)||(typeof e.rank==`number`?e.rank:1e9)-(typeof t.rank==`number`?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of r.sort(a))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e[typeof n==`string`?n:n.name])}}let s=[],c=null,l=o.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||l(e.completion,t.completion))){let t=e.completion;!c||c.label!=t.label||c.detail!=t.detail||c.type!=null&&t.type!=null&&c.type!=t.type||c.apply!=t.apply||c.boost!=t.boost?s.push(e):Vl(e.completion)>Vl(c)&&(s[s.length-1]=e),c=e.completion}return s}var Ul=class e{constructor(e,t,n,r,i,a){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new e(this.options,Jl(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(e=>e.isPending))return i.setDisabled();let s=Hl(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(X).selectOnOpen?0:-1;if(i&&i.selected!=c&&i.selected!=-1){let e=i.options[i.selected].completion;for(let t=0;t<s.length;t++)if(s[t].completion==e){c=t;break}}return new e(s,Jl(r,c),{pos:t.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:nu,above:a.aboveCursor},i?i.timestamp:Date.now(),c,!1)}map(t){return new e(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new e(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},Wl=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e(Yl,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(X),i=(r.override||n.languageDataAt(`autocomplete`,Cl(n)).map(Ol)).map(e=>(this.active.find(t=>t.source==e)||new Zl(e,+!!this.active.some(e=>e.state!=0))).update(t,r));i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let a=this.open,o=t.effects.some(e=>e.is(eu));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!Gl(i,this.active)||o?a=Ul.build(i,n,this.id,a,r,o):a&&a.disabled&&!i.some(e=>e.isPending)&&(a=null),!a&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new Zl(e.source,0):e));for(let e of t.effects)e.is(Fl)&&(a&&=a.setSelected(e.value,this.id));return i==this.active&&a==this.open?this:new e(i,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Kl:ql}};function Gl(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}var Kl={"aria-autocomplete":`list`},ql={};function Jl(e,t){let n={"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-controls":e};return t>-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var Yl=[];function Xl(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(Tl);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent(`input.type`);return n&&t.activateOnTyping?5:n?1:e.isUserEvent(`delete.backward`)?2:e.selection?8:e.docChanged?16:0}var Zl=class e{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=Xl(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new e(i.source,0)),r&4&&i.state==0&&(i=new e(this.source,1)),i=i.updateFor(t,r);for(let n of t.effects)if(n.is(kl))i=new e(i.source,1,n.value);else if(n.is(Al))i=new e(i.source,0);else if(n.is(eu))for(let e of n.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Cl(e.state))}},Ql=class e extends Zl{constructor(e,t,n,r,i,a){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=a}hasResult(){return!0}updateFor(t,n){if(!(n&3))return this.map(t.changes);let r=this.result;r.map&&!t.changes.empty&&(r=r.map(r,t.changes));let i=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=Cl(t.state);if(o>a||!r||n&2&&(Cl(t.startState)==this.from||o<this.limit))return new Zl(this.source,n&4?1:0);let s=t.changes.mapPos(this.limit);return $l(r.validFor,t.state,i,a)?new e(this.source,this.explicit,s,r,i,a):r.update&&(r=r.update(r,i,a,new vl(t.state,o,!1)))?new e(this.source,this.explicit,s,r,r.from,r.to??Cl(t.state)):new Zl(this.source,1,this.explicit)}map(t){if(t.empty)return this;let n=this.result.map?this.result.map(this.result,t):this.result;return n?new e(this.source,this.explicit,t.mapPos(this.limit),n,t.mapPos(this.from),t.mapPos(this.to,1)):new Zl(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function $l(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e==`function`?e(i,n,r,t):wl(e,!0).test(i)}var eu=O.define({map(e,t){return e.map(e=>e.map(t))}}),Z=Ie.define({create(){return Wl.start()},update(e,t){return e.update(t)},provide:e=>[ws.from(e,e=>e.tooltip),W.contentAttributes.from(e,e=>e.attrs)]});function tu(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(Z).active.find(e=>e.source==t.source);return r instanceof Ql?(typeof n==`string`?e.dispatch({...El(e.state,n,r.from,r.to),annotations:Tl.of(t.completion)}):n(e,t.completion,r.from,r.to),!0):!1}var nu=zl(Z,tu);function ru(e,t=`option`){return n=>{let r=n.state.field(Z,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(X).interactionDelay)return!1;let i=1,a;t==`page`&&(a=Ts(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector(`li`).offsetHeight)-1));let{length:o}=r.open.options,s=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:o-1;return s<0?s=t==`page`?0:o-1:s>=o&&(s=t==`page`?o-1:0),n.dispatch({effects:Fl.of(s)}),!0}}var iu=e=>{let t=e.state.field(Z,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(X).interactionDelay?!1:tu(e,t.open.options[t.open.selected])},au=e=>e.state.field(Z,!1)?(e.dispatch({effects:kl.of(!0)}),!0):!1,ou=e=>{let t=e.state.field(Z,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:Al.of(null)}),!0)},su=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},cu=50,lu=1e3,uu=jr.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(Z).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Z),n=e.state.facet(X);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Z)==t)return;let r=e.transactions.some(e=>{let t=Xl(e,n);return t&8||(e.selection||e.docChanged)&&!(t&3)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(r||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>cu&&Date.now()-n.time>lu){for(let e of n.context.abortListeners)try{e()}catch(e){z(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(kl)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let t of e.transactions)t.isUserEvent(`input.type`)?this.composing=2:this.composing==2&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(Z);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(X).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=new vl(t,Cl(t),e.explicit,this.view),r=new su(e,n);this.running.push(r),Promise.resolve(e.source(n)).then(e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:Al.of(null)}),z(this.view.state,e)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(X).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(X),n=this.view.state.field(Z);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(i.done===void 0)continue;if(this.running.splice(r--,1),i.done){let n=Cl(i.updates.length?i.updates[0].startState:this.view.state),r=Math.min(n,i.done.from+ +!i.active.explicit),a=new Ql(i.active.source,i.active.explicit,r,i.done,i.done.from,i.done.to??n);for(let e of i.updates)a=a.update(e,t);if(a.hasResult()){e.push(a);continue}}let a=n.active.find(e=>e.source==i.active.source);if(a&&a.isPending)if(i.done==null){let n=new Zl(i.active.source,0);for(let e of i.updates)n=n.update(e,t);n.isPending||e.push(n)}else this.startQuery(a)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:eu.of(e)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Z,!1);if(t&&t.tooltip&&this.view.state.facet(X).closeOnBlur){let n=t.open&&Ts(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Al.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:kl.of(!1)}),20),this.composing=0}}}),du=typeof navigator==`object`&&/Win/.test(navigator.platform),fu=ze.highest(W.domEventHandlers({keydown(e,t){let n=t.state.field(Z,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(du&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&tu(t,r),!1}})),pu=W.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:`monospace`,whiteSpace:`nowrap`,overflow:`hidden auto`,maxWidth_fallback:`700px`,maxWidth:`min(700px, 95vw)`,minWidth:`250px`,maxHeight:`10em`,height:`100%`,listStyle:`none`,margin:0,padding:0,"& > li, & > completion-section":{padding:`1px 3px`,lineHeight:1.2},"& > li":{overflowX:`hidden`,textOverflow:`ellipsis`,cursor:`pointer`},"& > completion-section":{display:`list-item`,borderBottom:`1px solid silver`,paddingLeft:`0.5em`,opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#17c`,color:`white`},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#777`},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#347`,color:`white`},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#444`},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:`"···"`,opacity:.5,display:`block`,textAlign:`center`,cursor:`pointer`},".cm-tooltip.cm-completionInfo":{position:`absolute`,padding:`3px 9px`,width:`max-content`,maxWidth:`400px`,boxSizing:`border-box`,whiteSpace:`pre-line`},".cm-completionInfo.cm-completionInfo-left":{right:`100%`},".cm-completionInfo.cm-completionInfo-right":{left:`100%`},".cm-completionInfo.cm-completionInfo-left-narrow":{right:`30px`},".cm-completionInfo.cm-completionInfo-right-narrow":{left:`30px`},"&light .cm-snippetField":{backgroundColor:`#00000022`},"&dark .cm-snippetField":{backgroundColor:`#ffffff22`},".cm-snippetFieldPosition":{verticalAlign:`text-top`,width:0,height:`1.15em`,display:`inline-block`,margin:`0 -0.7px -.7em`,borderLeft:`1.4px dotted #888`},".cm-completionMatchedText":{textDecoration:`underline`},".cm-completionDetail":{marginLeft:`0.5em`,fontStyle:`italic`},".cm-completionIcon":{fontSize:`90%`,width:`.8em`,display:`inline-block`,textAlign:`center`,paddingRight:`.6em`,opacity:`0.6`,boxSizing:`content-box`},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:`'ƒ'`}},".cm-completionIcon-class":{"&:after":{content:`'○'`}},".cm-completionIcon-interface":{"&:after":{content:`'◌'`}},".cm-completionIcon-variable":{"&:after":{content:`'𝑥'`}},".cm-completionIcon-constant":{"&:after":{content:`'𝐶'`}},".cm-completionIcon-type":{"&:after":{content:`'𝑡'`}},".cm-completionIcon-enum":{"&:after":{content:`'∪'`}},".cm-completionIcon-property":{"&:after":{content:`'□'`}},".cm-completionIcon-keyword":{"&:after":{content:`'🔑︎'`}},".cm-completionIcon-namespace":{"&:after":{content:`'▢'`}},".cm-completionIcon-text":{"&:after":{content:`'abc'`,fontSize:`50%`,verticalAlign:`middle`}}}),mu=new class extends _t{};mu.startSide=1,mu.endSide=-1,typeof navigator==`object`&&navigator.userAgent;function hu(e={}){return[fu,Z,X.of(e),uu,_u,pu]}var gu=[{key:`Ctrl-Space`,run:au},{mac:"Alt-`",run:au},{mac:`Alt-i`,run:au},{key:`Escape`,run:ou},{key:`ArrowDown`,run:ru(!0)},{key:`ArrowUp`,run:ru(!1)},{key:`PageDown`,run:ru(!0,`page`)},{key:`PageUp`,run:ru(!1,`page`)},{key:`Enter`,run:iu}],_u=ze.highest(Wo.computeN([X],e=>e.facet(X).defaultKeymap?[gu]:[])),vu=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=Cu(e.state,n.from);return r.line?bu(e):r.block?Su(e):!1};function yu(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var bu=yu(Ou,0),xu=yu(Du,0),Su=yu((e,t)=>Du(e,t,Eu(t)),0);function Cu(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var wu=50;function Tu(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-wu,r),o=e.sliceDoc(i,i+wu),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=2*wu?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+wu),d=e.sliceDoc(i-wu,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function Eu(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function Du(e,t,n=t.selection.ranges){let r=n.map(e=>Cu(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>Tu(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function Ou(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=Cu(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}else if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var ku=et.define(),Au=et.define(),ju=D.define(),Mu=D.define({combine(e){return gt(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),Nu=Ie.define({create(){return Qu.empty},update(e,t){let n=t.state.facet(Mu),r=t.annotation(ku);if(r){let i=Bu.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?Vu(o,o.length,n.minDepth,i):qu(o,t.startState.selection),new Qu(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(Au);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(k.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=Bu.fromTransaction(t),o=t.annotation(k.time),s=t.annotation(k.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new Qu(e.done.map(Bu.fromJSON),e.undone.map(Bu.fromJSON))}});function Pu(e={}){return[Nu,Mu.of(e),W.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?Iu:e.inputType==`historyRedo`?Lu:null;return n?(e.preventDefault(),n(t)):!1}})]}function Fu(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(Nu,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var Iu=Fu(0,!1),Lu=Fu(1,!1),Ru=Fu(0,!0),zu=Fu(1,!0),Bu=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&xe.fromJSON(t.changes),[],t.mapped&&be.fromJSON(t.mapped),t.startSelection&&E.fromJSON(t.startSelection),t.selectionsAfter.map(E.fromJSON))}static fromTransaction(t,n){let r=Gu;for(let e of t.startState.facet(ju)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,Gu)}static selection(t){return new e(void 0,Gu,void 0,void 0,t)}};function Vu(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function Hu(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function Uu(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function Wu(e,t){return e.length?t.length?e.concat(t):e:t}var Gu=[],Ku=200;function qu(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Ku));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),Vu(e,e.length-1,1e9,n.setSelAfter(r)))}else return[Bu.selection([t])]}function Ju(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function Yu(e,t){if(!e.length)return e;let n=e.length,r=Gu;for(;n;){let i=Xu(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[Bu.selection(r)]:Gu}function Xu(e,t,n){let r=Wu(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):Gu,n);if(!e.changes)return Bu.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new Bu(i,O.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var Zu=/^(input\.type|delete)($|\.)/,Qu=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||Zu.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,Hu(s.changes,t.changes))||r==`input.type.compose`)?Vu(o,o.length-1,i.minDepth,new Bu(t.changes.compose(s.changes),Wu(O.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,Gu)):Vu(o,o.length,i.minDepth,t),new e(o,Gu,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:Gu;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&Uu(a[a.length-1],t)?this:new e(qu(this.done,t),this.undone,n,r)}addMapping(t){return new e(Yu(this.done,t),Yu(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:ku.of({side:e,rest:Ju(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?Gu:r.slice(0,r.length-1);return i.mapped&&(n=Yu(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:ku.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};Qu.empty=new Qu(Gu,Gu);var $u=[{key:`Mod-z`,run:Iu,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:Lu,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:Lu,preventDefault:!0},{key:`Mod-u`,run:Ru,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:zu,preventDefault:!0}];function ed(e,t){return E.create(e.ranges.map(t),e.mainIndex)}function td(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function nd({state:e,dispatch:t},n){let r=ed(e.selection,n);return r.eq(e.selection,!0)?!1:(t(td(e,r)),!0)}function rd(e,t){return E.cursor(t?e.to:e.from)}function id(e,t){return nd(e,n=>n.empty?e.moveByChar(n,t):rd(n,t))}function Q(e){return e.textDirectionAt(e.state.selection.main.head)==L.LTR}var ad=e=>id(e,!Q(e)),od=e=>id(e,Q(e));function sd(e,t){return nd(e,n=>n.empty?e.moveByGroup(n,t):rd(n,t))}var cd=e=>sd(e,!Q(e)),ld=e=>sd(e,Q(e));typeof Intl<`u`&&Intl.Segmenter;function ud(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function dd(e,t,n){let r=jc(e).resolveInner(t.head),i=n?G.closedBy:G.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;ud(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?cl(e,r.from,1):cl(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,E.cursor(s,n?-1:1)}var fd=e=>nd(e,t=>dd(e.state,t,!Q(e))),pd=e=>nd(e,t=>dd(e.state,t,Q(e)));function md(e,t){return nd(e,n=>{if(!n.empty)return rd(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var hd=e=>md(e,!1),gd=e=>md(e,!0);function _d(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(W.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function vd(e,t){let n=_d(e),{state:r}=e,i=ed(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):rd(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=W.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(td(r,i),{effects:a}),!0}var yd=e=>vd(e,!1),bd=e=>vd(e,!0);function xd(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=E.cursor(r.from+n))}return i}var Sd=e=>nd(e,t=>xd(e,t,!0)),Cd=e=>nd(e,t=>xd(e,t,!1)),wd=e=>nd(e,t=>xd(e,t,!Q(e))),Td=e=>nd(e,t=>xd(e,t,Q(e))),Ed=e=>nd(e,t=>E.cursor(e.lineBlockAt(t.head).from,1)),Dd=e=>nd(e,t=>E.cursor(e.lineBlockAt(t.head).to,-1));function Od(e,t,n){let r=!1,i=ed(e.selection,t=>{let i=cl(e,t.head,-1)||cl(e,t.head,1)||t.head>0&&cl(e,t.head-1,1)||t.head<e.doc.length&&cl(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?E.range(t.anchor,a):E.cursor(a)});return r?(t(td(e,i)),!0):!1}var kd=({state:e,dispatch:t})=>Od(e,t,!1);function Ad(e,t){let n=ed(e.state.selection,e=>{let n=t(e);return E.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(td(e.state,n)),!0)}function jd(e,t){return Ad(e,n=>e.moveByChar(n,t))}var Md=e=>jd(e,!Q(e)),Nd=e=>jd(e,Q(e));function Pd(e,t){return Ad(e,n=>e.moveByGroup(n,t))}var Fd=e=>Pd(e,!Q(e)),Id=e=>Pd(e,Q(e)),Ld=e=>Ad(e,t=>dd(e.state,t,!Q(e))),Rd=e=>Ad(e,t=>dd(e.state,t,Q(e)));function zd(e,t){return Ad(e,n=>e.moveVertically(n,t))}var Bd=e=>zd(e,!1),Vd=e=>zd(e,!0);function Hd(e,t){return Ad(e,n=>e.moveVertically(n,t,_d(e).height))}var Ud=e=>Hd(e,!1),Wd=e=>Hd(e,!0),Gd=e=>Ad(e,t=>xd(e,t,!0)),Kd=e=>Ad(e,t=>xd(e,t,!1)),qd=e=>Ad(e,t=>xd(e,t,!Q(e))),Jd=e=>Ad(e,t=>xd(e,t,Q(e))),Yd=e=>Ad(e,t=>E.cursor(e.lineBlockAt(t.head).from)),Xd=e=>Ad(e,t=>E.cursor(e.lineBlockAt(t.head).to)),Zd=({state:e,dispatch:t})=>(t(td(e,{anchor:0})),!0),Qd=({state:e,dispatch:t})=>(t(td(e,{anchor:e.doc.length})),!0),$d=({state:e,dispatch:t})=>(t(td(e,{anchor:e.selection.main.anchor,head:0})),!0),ef=({state:e,dispatch:t})=>(t(td(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),tf=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),nf=({state:e,dispatch:t})=>{let n=Sf(e).map(({from:t,to:n})=>E.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:E.create(n),userEvent:`select`})),!0},rf=({state:e,dispatch:t})=>{let n=ed(e.selection,t=>{let n=jc(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return E.range(n.to,n.from)}return t});return n.eq(e.selection)?!1:(t(td(e,n)),!0)};function af(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}else if(r.head==n.head)break;else n=r}}return i.length==r.ranges.length?!1:(e.dispatch(td(n,E.create(i,i.length-1))),!0)}var of=e=>af(e,!1),sf=e=>af(e,!0),cf=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=E.create([n.main]):n.main.empty||(r=E.create([E.cursor(n.main.head)])),r?(t(td(e,r)),!0):!1};function lf(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=uf(e,o,!1)):o>i&&(n=`delete.forward`,o=uf(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=uf(e,i,!1),a=uf(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:E.cursor(i,i<r.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?W.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function uf(e,t,n){if(e instanceof W)for(let r of e.state.facet(W.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var df=(e,t,n)=>lf(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=Pt(s,a.tabSize)%Uc(a)||Uc(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=w(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=w(o.text,c-o.from,!1,!1)+o.from);return c}),ff=e=>df(e,!1,!0),pf=e=>df(e,!0,!1),mf=(e,t)=>lf(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=w(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),hf=e=>mf(e,!1),gf=e=>mf(e,!0),_f=e=>lf(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),vf=e=>lf(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),yf=e=>lf(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),bf=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:S.of([``,``])},range:E.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},xf=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:w(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:w(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:E.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function Sf(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function Cf(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of Sf(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(E.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(E.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:E.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var wf=({state:e,dispatch:t})=>Cf(e,t,!1),Tf=({state:e,dispatch:t})=>Cf(e,t,!0);function Ef(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of Sf(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var Df=({state:e,dispatch:t})=>Ef(e,t,!1),Of=({state:e,dispatch:t})=>Ef(e,t,!0),kf=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Sf(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=ed(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function Af(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=jc(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(G.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var jf=Nf(!1),Mf=Nf(!0);function Nf(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&Af(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new Kc(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=Gc(s,r);for(c??=Pt(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,Wc(t,c)];return o&&l.push(Wc(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:S.of(l)},range:E.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function Pf(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:E.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var Ff=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new Kc(e,{overrideIndentation:e=>n[e]??-1}),i=Pf(e,(t,i,a)=>{let o=Gc(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=Wc(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},If=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Pf(e,(t,n)=>{n.push({from:t.from,insert:e.facet(Hc)})}),{userEvent:`input.indent`})),!0),Lf=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Pf(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=Pt(r,e.tabSize),a=0,o=Wc(e,Math.max(0,i-Uc(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),Rf=e=>(e.setTabFocusMode(),!0),zf=[{key:`Ctrl-b`,run:ad,shift:Md,preventDefault:!0},{key:`Ctrl-f`,run:od,shift:Nd},{key:`Ctrl-p`,run:hd,shift:Bd},{key:`Ctrl-n`,run:gd,shift:Vd},{key:`Ctrl-a`,run:Ed,shift:Yd},{key:`Ctrl-e`,run:Dd,shift:Xd},{key:`Ctrl-d`,run:pf},{key:`Ctrl-h`,run:ff},{key:`Ctrl-k`,run:_f},{key:`Ctrl-Alt-h`,run:hf},{key:`Ctrl-o`,run:bf},{key:`Ctrl-t`,run:xf},{key:`Ctrl-v`,run:bd}],Bf=[{key:`ArrowLeft`,run:ad,shift:Md,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:cd,shift:Fd,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:wd,shift:qd,preventDefault:!0},{key:`ArrowRight`,run:od,shift:Nd,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:ld,shift:Id,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:Td,shift:Jd,preventDefault:!0},{key:`ArrowUp`,run:hd,shift:Bd,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:Zd,shift:$d},{mac:`Ctrl-ArrowUp`,run:yd,shift:Ud},{key:`ArrowDown`,run:gd,shift:Vd,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:Qd,shift:ef},{mac:`Ctrl-ArrowDown`,run:bd,shift:Wd},{key:`PageUp`,run:yd,shift:Ud},{key:`PageDown`,run:bd,shift:Wd},{key:`Home`,run:Cd,shift:Kd,preventDefault:!0},{key:`Mod-Home`,run:Zd,shift:$d},{key:`End`,run:Sd,shift:Gd,preventDefault:!0},{key:`Mod-End`,run:Qd,shift:ef},{key:`Enter`,run:jf,shift:jf},{key:`Mod-a`,run:tf},{key:`Backspace`,run:ff,shift:ff,preventDefault:!0},{key:`Delete`,run:pf,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:hf,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:gf,preventDefault:!0},{mac:`Mod-Backspace`,run:vf,preventDefault:!0},{mac:`Mod-Delete`,run:yf,preventDefault:!0}].concat(zf.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),Vf=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:fd,shift:Ld},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:pd,shift:Rd},{key:`Alt-ArrowUp`,run:wf},{key:`Shift-Alt-ArrowUp`,run:Df},{key:`Alt-ArrowDown`,run:Tf},{key:`Shift-Alt-ArrowDown`,run:Of},{key:`Mod-Alt-ArrowUp`,run:of},{key:`Mod-Alt-ArrowDown`,run:sf},{key:`Escape`,run:cf},{key:`Mod-Enter`,run:Mf},{key:`Alt-l`,mac:`Ctrl-l`,run:nf},{key:`Mod-i`,run:rf,preventDefault:!0},{key:`Mod-[`,run:Lf},{key:`Mod-]`,run:If},{key:`Mod-Alt-\\`,run:Ff},{key:`Shift-Mod-k`,run:kf},{key:`Shift-Mod-\\`,run:kd},{key:`Mod-/`,run:vu},{key:`Alt-A`,run:xu},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:Rf}].concat(Bf),Hf=O.define(),Uf=Ie.define({create(){return null},update(e,t){for(let n of t.effects)n.is(Hf)&&(e=n.value);return e}}),Wf=jr.fromClass(class{constructor(e){this.view=e,this.caret=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCaret.bind(this)}}update(e){let t=e.state.field(Uf);if(t==null){this.caret&&=(this.caret.remove(),null);return}this.caret||(this.caret=this.view.scrollDOM.appendChild(document.createElement(`div`)),this.caret.className=`cm-dropCursor`),(e.startState.field(Uf)!==t||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq)}readPos(){let e=this.view.state.field(Uf),t=e==null?null:this.view.coordsAtPos(e);if(!t)return null;let n=this.view.scrollDOM.getBoundingClientRect();return{left:t.left-n.left+this.view.scrollDOM.scrollLeft*this.view.scaleX,top:t.top-n.top+this.view.scrollDOM.scrollTop*this.view.scaleY,height:t.bottom-t.top}}drawCaret(e){if(!this.caret)return;let{scaleX:t,scaleY:n}=this.view;e?(this.caret.style.left=`${e.left/t}px`,this.caret.style.top=`${e.top/n}px`,this.caret.style.height=`${e.height/n}px`):this.caret.style.left=`-100000px`}destroy(){this.caret?.remove()}});function Gf(){return[Uf,Wf]}function Kf(e,t){let n=e.posAtCoords(t)??e.state.doc.length,r=Math.max(0,Math.min(n,e.state.doc.length));e.state.field(Uf,!1)!==r&&e.dispatch({effects:Hf.of(r)})}function qf(e){e.state.field(Uf,!1)!=null&&e.dispatch({effects:Hf.of(null)})}var Jf=class extends fn{constructor(e,t){super(),this.config=e,this.store=t}toDOM(){if(this._element)return this._element;switch(this.config.widgetType){case`column`:this._element=Yf(this.config.data);break;case`emptyArgument`:{let e=document.createElement(`luzmo-formula-empty-argument-pill`);e.emptyArgumentId=this.config.data.emptyArgumentId,e.parentAggregationWidgetId=this.config.data.parentAggregationWidgetId,e.store=this.store,this._element=e;break}case`aggregation`:{let e=document.createElement(`luzmo-formula-aggregation`);e.config=this.config.data,e.store=this.store,this._element=e;break}}return this._element}eq(e){if(e.config.widgetType!==this.config.widgetType)return!1;switch(this.config.widgetType){case`column`:return e.config.widgetType===`column`&&e.config.data.columnId===this.config.data.columnId&&e.config.data.text===this.config.data.text&&e.config.data.type===this.config.data.type&&e.config.data.subtype===this.config.data.subtype&&e.config.data.lowestLevel===this.config.data.lowestLevel&&e.config.data.pending===this.config.data.pending;case`emptyArgument`:return e.config.widgetType===`emptyArgument`&&e.config.data.emptyArgumentId===this.config.data.emptyArgumentId;case`aggregation`:return e.config.widgetType===`aggregation`&&e.config.data.aggregationWidgetId===this.config.data.aggregationWidgetId}return!1}ignoreEvent(){return!0}};function Yf(e){let t=document.createElement(`span`);t.className=`column-pill-wrapper`;let n=document.createElement(`span`);if(n.className=`column-pill`,t.appendChild(n),e.pending){let e=(0,p.msg)(`Loading column`,{desc:`Accessible label for a column pill whose label is still loading`});n.title=e;let r=document.createElement(`span`);r.className=`column-pill-loading`;let i=document.createElement(`luzmo-progress-circle`);return i.setAttribute(`indeterminate`,``),i.setAttribute(`size`,`s`),i.label=e,r.appendChild(i),n.appendChild(r),t}n.title=e.text;let r=document.createElement(`span`);r.className=`column-pill-icon`,r.appendChild(l.t(e.icon));let i=document.createElement(`span`);return i.className=`column-pill-label`,i.textContent=e.text,n.append(r,i),t}function Xf(e,t){let{store:n,datasets:r,contentLanguage:i,parentAggregationWidgetId:a,multiStageAggregation:s}=t,l=[],u=s?o.h:o.m;u.lastIndex=0;let d;for(;(d=u.exec(e))!==null;){d.index===u.lastIndex&&u.lastIndex++;let e=d.index,t=e+d[0].length,o=d[1],s=d[2],f=d[3];if(f)l.push(I.replace({widget:new Jf({widgetType:`aggregation`,data:{aggregationWidgetId:f,linkedDatasets:r,contentLanguage:i,parentAggregationWidgetId:a}},n)}).range(e,t));else if(o)l.push(I.replace({widget:new Jf({widgetType:`emptyArgument`,data:{emptyArgumentId:o,parentAggregationWidgetId:a}},n)}).range(e,t));else if(s){let[a,o]=s.split(`:`),u=r.find(e=>e.id===a)?.columns.find(e=>e.columnId===o),{icon:d,label:f}=c.t(u,i,o);l.push(I.replace({widget:new Jf({widgetType:`column`,data:{columnId:o,datasetId:a,type:u?.type??`hierarchy`,subtype:u?.subtype,lowestLevel:u?.lowestLevel,text:f,icon:d,pending:n.loading&&!u}},n)}).range(e,t))}}return l}var Zf=`var(--luzmo-background-color)`,Qf=`var(--luzmo-font-color)`,$f=`var(--luzmo-border-color, rgba(0, 0, 0, 0.1))`,ep=`var(--luzmo-primary)`,tp=`var(--luzmo-negative-color, #ca221c)`,np=`rgba(var(--luzmo-primary-rgb), 0.18)`,rp={"&":{backgroundColor:Zf,color:Qf},".cm-scroller":{fontFamily:`var(--luzmo-font-family)`,fontSize:`var(--luzmo-formula-font-size, var(--luzmo-font-size))`,lineHeight:`1.5`,overflow:`auto`},".cm-content":{caretColor:Qf,padding:`var(--luzmo-spacing-3) var(--luzmo-spacing-4)`},".cm-line":{padding:0},".cm-activeLine":{backgroundColor:`transparent`},".cm-selectionBackground, ::selection":{backgroundColor:np},"&.cm-focused":{outline:`none`},"&.cm-focused .cm-selectionBackground, & .cm-selectionBackground, & ::selection":{backgroundColor:np},".cm-cursor, .cm-dropCursor":{borderLeftColor:Qf},".cm-placeholder":{color:`var(--luzmo-font-color-extra-dimmed)`},".cm-tooltip":{border:`1px solid ${$f}`,backgroundColor:Zf,color:Qf,borderRadius:`var(--luzmo-border-radius-s)`}},ip=`var(--luzmo-formula-font-size, var(--luzmo-font-size))`,ap={".cm-tooltip.cm-tooltip-autocomplete":{border:`1px solid ${$f}`,borderRadius:`var(--luzmo-border-radius)`,backgroundColor:Zf,color:Qf,boxShadow:`0 6px 16px rgba(0, 0, 0, 0.12)`,fontFamily:`var(--luzmo-font-family)`,"& > ul":{fontFamily:`var(--luzmo-font-family)`,fontSize:ip,maxHeight:`16rem`,padding:`var(--luzmo-spacing-1)`},"& > ul > li":{display:`flex`,alignItems:`center`,gap:`var(--luzmo-spacing-2)`,padding:`var(--luzmo-spacing-2) var(--luzmo-spacing-3)`,borderRadius:`var(--luzmo-border-radius-s)`,color:Qf,lineHeight:`1.4`},"& > ul > li[aria-selected]":{backgroundColor:`var(--luzmo-background-color-hover)`,color:Qf}},".cm-completionIcon":{boxSizing:`content-box`,width:`1.2em`,minWidth:`1.2em`,padding:`0`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,color:Qf,opacity:`1`},".cm-completionIcon svg":{width:`1em`,height:`1em`},".cm-completionLabel":{flex:`1 1 auto`},".cm-completionMatchedText":{color:`var(--luzmo-primary)`,fontWeight:`var(--luzmo-font-weight-bold)`,textDecoration:`none`},".cm-completionDetail":{color:`var(--luzmo-font-color-extra-dimmed)`,fontStyle:`normal`},".cm-tooltip.cm-completionInfo":{margin:`0 var(--luzmo-spacing-2)`,border:`1px solid ${$f}`,borderRadius:`var(--luzmo-border-radius)`,backgroundColor:Zf,color:Qf,boxShadow:`0 6px 16px rgba(0, 0, 0, 0.12)`,padding:`var(--luzmo-spacing-3) var(--luzmo-spacing-4)`,fontFamily:`var(--luzmo-font-family)`,fontSize:ip,lineHeight:`1.5`,maxWidth:`18rem`},".cm-completion-info-example":{display:`block`,marginBottom:`var(--luzmo-spacing-2)`,color:Qf,fontFamily:`var(--luzmo-font-family)`,fontWeight:`var(--luzmo-font-weight-bold)`,whiteSpace:`normal`},".cm-completion-info-icon":{display:`inline-flex`,alignItems:`center`,verticalAlign:`-0.15em`,margin:`0 0.15em`},".cm-completion-info-icon svg":{width:`1em`,height:`1em`},".cm-completion-info-desc":{color:`var(--luzmo-font-color-extra-dimmed)`}},op=1.5;function sp(e){return`calc(${e} * ${op} * var(--luzmo-formula-font-size, var(--luzmo-font-size)) + 2 * var(--luzmo-spacing-3) + 2px)`}function cp(e){let{rows:t,maxRows:n,grows:r=!0,editorHeight:i,hasError:a=!1,singleLine:o=!1}=e;if(o)return{"&":{height:`100%`,minHeight:`auto`,border:`none`,borderRadius:`0`,backgroundColor:`transparent`},".cm-content":{padding:`0 2px`},".cm-scroller":{alignItems:`center`,lineHeight:`1.2`,overflow:`visible`}};let s={border:`1px solid ${a?tp:$f}`,borderTopLeftRadius:`var(--luzmo-border-radius)`,borderTopRightRadius:`var(--luzmo-border-radius)`,borderBottomLeftRadius:`var(--luzmo-formula-field-bottom-radius, var(--luzmo-border-radius))`,borderBottomRightRadius:`var(--luzmo-formula-field-bottom-radius, var(--luzmo-border-radius))`},c=i??(t==null?void 0:sp(t));return r?(s.minHeight=c??`auto`,n!=null&&(s.maxHeight=sp(n))):s.height=c??`auto`,{"&":s,"&.cm-focused":{borderColor:a?tp:ep}}}var lp=`:host{vertical-align:middle;font-family:var(--luzmo-font-family);display:inline-flex}.empty-argument-pill{min-width:1.25rem;min-height:1.1em;padding:0 var(--luzmo-spacing-2);border:1px dashed var(--luzmo-border-color-full);border-radius:var(--luzmo-border-radius-s);background-color:var(--luzmo-formula-empty-argument-pill-background,transparent);color:var(--luzmo-font-color);cursor:text;outline:none;justify-content:center;align-items:center;font-size:.85em;line-height:1.5;display:inline-flex}:host([accept-drag]) .empty-argument-pill,.empty-argument-pill.accept-drag{border-style:solid;border-color:var(--luzmo-primary);background-color:rgba(var(--luzmo-primary-rgb), .18)}`,up=class extends n.t(e.i){constructor(...e){super(...e),this.emptyArgumentId=``,this.parentAggregationWidgetId=null}static{this.styles=(0,d.unsafeCSS)(lp)}connectedCallback(){super.connectedCallback(),this._attachDroppable()}disconnectedCallback(){super.disconnectedCallback(),this._cleanupDroppable?.(),this._cleanupDroppable=void 0}firstUpdated(e){this._attachDroppable()}_attachDroppable(){this._cleanupDroppable||!this.isConnected||(this._cleanupDroppable=a.n({element:this,getDropEffect:()=>`move`,canDrop:({source:e})=>this._canDrop(e.element?.tagName,e.data),onDragEnter:()=>this.setAttribute(`accept-drag`,``),onDragLeave:()=>this.removeAttribute(`accept-drag`),onDrop:({source:e})=>{this.removeAttribute(`accept-drag`),this._handleDrop(e.element?.tagName,e.data)}}))}_canDrop(e,t){return e===`LUZMO-DATA-FIELD`||e===`LUZMO-DATA-FIELD-LEVEL`?!0:t?.kind===`aggregation`&&this.parentAggregationWidgetId!==null&&!this.store?.nestedAggregation?!1:t?.kind===`function`||t?.kind===`aggregation`}_handleDrop(e,t){if(!this.store)return;if(e===`LUZMO-DATA-FIELD`||e===`LUZMO-DATA-FIELD-LEVEL`){let e=t;this.store.onExtendExpression({type:`column`,id:e.columnId??null,datasetId:e.datasetId,aggregationWidgetId:this.parentAggregationWidgetId,isEmptyArgument:!0,targetEmptyArgumentId:this.emptyArgumentId});return}let n=t;(n?.kind===`function`||n?.kind===`aggregation`)&&this.store.onExtendExpression({type:n.kind,id:n.value,aggregationWidgetId:this.parentAggregationWidgetId,isEmptyArgument:!0,targetEmptyArgumentId:this.emptyArgumentId})}_handleFocus(){this.store&&(this.store.lastFocusedEmptyArgumentId=this.emptyArgumentId,this.store.lastFocusedAggregationWidgetId=this.parentAggregationWidgetId)}_handleInput(e){let t=e.target.textContent??``;!this.store||t.trim().length===0||this.store.onExtendExpression({type:`text`,id:null,aggregationWidgetId:this.parentAggregationWidgetId,isEmptyArgument:!0,targetEmptyArgumentId:this.emptyArgumentId,textContent:t})}render(){return d.html`
|
|
30
30
|
<span
|
|
31
31
|
class="empty-argument-pill"
|
|
32
32
|
contenteditable="true"
|
|
@@ -34,6 +34,7 @@ const e=require("./base-ZuhO2UZd.cjs"),t=require("./decorate-DCJt-2rt.cjs"),n=re
|
|
|
34
34
|
role="textbox"
|
|
35
35
|
aria-multiline="false"
|
|
36
36
|
aria-label=${(0,p.msg)(`Empty argument. Type a value, or drop a column, function or aggregation.`,{desc:`Accessible label for an empty formula argument that accepts typed values or dropped items`})}
|
|
37
|
+
@focus=${this._handleFocus}
|
|
37
38
|
@input=${this._handleInput}
|
|
38
39
|
></span>
|
|
39
40
|
`}};t.t([(0,f.property)({type:String})],up.prototype,`emptyArgumentId`,void 0),t.t([(0,f.property)({type:String,attribute:`parent-aggregation-widget-id`})],up.prototype,`parentAggregationWidgetId`,void 0),t.t([(0,f.property)({attribute:!1})],up.prototype,`store`,void 0),up=t.t([(0,p.localized)()],up),customElements.get(`luzmo-formula-empty-argument-pill`)||customElements.define(`luzmo-formula-empty-argument-pill`,up);function dp(e){return e??`m`}function fp(e){return{s:`xs`,m:`s`,l:`m`,xl:`l`}[dp(e)]??`s`}function pp(e){return e.flatMap(e=>e.columns.filter(e=>!!e.columnId).map(t=>({reference:`${e.id}:${t.columnId}`,column:t})))}function mp(e,t,n){let r=pp(e).find(e=>e.reference===n);return r?i.t(r.column.name,t):n}function hp(e,t,n,a){let o=new Set(a);return pp(e).filter(e=>!o.has(e.reference)).map(e=>({value:e.reference,label:i.t(e.column.name,t),icon:r.t(e.column,dp(n))}))}function gp(e,t,n,r){let{datasets:i,contentLanguage:a,readonly:o=!1,includedColumns:s,excludedColumns:c,onChange:l}=e;if(n.length===0)return d.html`<p class="empty" part="empty">${(0,p.msg)(`No columns selected yet`,{desc:`Formula include/exclude empty group hint`})}</p>`;let f=t===`included`?u.luzmoArrowDown:u.luzmoArrowUp,m=(0,p.msg)(`Remove column`,{desc:`Formula include/exclude remove column action`}),h=fp(e.size),g=`font-size: var(--luzmo-font-size-${h})`,_=(e,n)=>{e.preventDefault(),!o&&(t===`included`?l(s.filter(e=>e!==n),c):l(s,c.filter(e=>e!==n)))},v=(e,n)=>{e.preventDefault(),e.stopPropagation(),!o&&(t===`included`?l(s.filter(e=>e!==n),[...c.filter(e=>e!==n),n]):l([...s.filter(e=>e!==n),n],c.filter(e=>e!==n)))};return d.html`
|
|
@@ -209,6 +210,6 @@ const e=require("./base-ZuhO2UZd.cjs"),t=require("./decorate-DCJt-2rt.cjs"),n=re
|
|
|
209
210
|
</luzmo-overlay>`}
|
|
210
211
|
</span>
|
|
211
212
|
</span>
|
|
212
|
-
`}};t.t([(0,f.property)({attribute:!1})],bp.prototype,`config`,void 0),t.t([(0,f.property)({attribute:!1})],bp.prototype,`store`,void 0),t.t([(0,f.query)(`luzmo-formula-codemirror`)],bp.prototype,`_nestedCodeMirror`,void 0),t.t([(0,f.query)(`.grouping-overlay`)],bp.prototype,`_groupingOverlay`,void 0),t.t([(0,f.query)(`.function-select`)],bp.prototype,`_functionSelect`,void 0),t.t([(0,f.state)()],bp.prototype,`_groupingPageOverride`,void 0),t.t([(0,f.state)()],bp.prototype,`_autoCompletionList`,void 0),t.t([(0,f.state)()],bp.prototype,`_codeMirrorLoaded`,void 0),t.t([(0,f.state)()],bp.prototype,`_functionKeyboardFocus`,void 0),bp=t.t([(0,p.localized)()],bp),customElements.get(`luzmo-formula-aggregation`)||customElements.define(`luzmo-formula-aggregation`,bp);var xp=`:host{font-family:var(--luzmo-font-family);display:block}.editor{width:100%}.cm-editor.cm-focused{outline:none}.cm-editor{transition:background-color .12s}:host([cm-ready]) .cm-editor{transition:background-color .12s,border-color .12s}:host([dragover]) .cm-editor{background-color:var(--luzmo-background-color-hover)}:host([single-line]){vertical-align:middle;align-items:center;height:100%;display:inline-flex}:host([single-line]) .editor{align-items:center;width:auto;height:100%;min-height:0;display:flex}:host([single-line]) .cm-editor{width:100%}:host([single-line]) .cm-editor .cm-content{flex-direction:column;justify-content:center;padding:0 2px;line-height:1.2;display:flex}:host([single-line]) .cm-editor .cm-scroller{align-items:center;line-height:1.2;overflow:visible}.column-pill-wrapper{vertical-align:middle;padding-inline-end:var(--luzmo-formula-column-pill-trailing-space,var(--luzmo-spacing-1));display:inline-flex}.column-pill{justify-content:center;align-items:center;gap:var(--luzmo-spacing-2);box-sizing:border-box;max-width:16rem;min-height:var(--luzmo-formula-control-height,1.375rem);padding:0 var(--luzmo-formula-column-pill-padding-inline,calc(var(--luzmo-spacing-2) + var(--luzmo-spacing-1)));border-radius:var(--luzmo-border-radius-s);background-color:var(--luzmo-formula-column-pill-background,var(--luzmo-background-color-highlight));color:var(--luzmo-font-color);white-space:nowrap;font-size:.85em;line-height:1.2;display:inline-flex}.column-pill-icon{flex:none;display:inline-flex}.column-pill-icon svg{width:1em;height:1em}.column-pill-label{text-overflow:ellipsis;overflow:hidden}.column-pill-loading{--luzmo-progress-circle-size:1em;align-items:center;display:inline-flex}`;function Sp(e){let t=document.createElement(`span`);return t.className=`cm-completionIcon`,t.setAttribute(`aria-hidden`,`true`),t.appendChild(l.t(e)),t}var Cp=et.define(),$=class extends n.t(e.i){constructor(...e){super(...e),this.aggregationWidgetId=null,this.datasets=[],this.contentLanguage=`en`,this.placeholder=``,this.readonly=!1,this.singleLine=!1,this.hasError=!1,this.rows=3,this.grows=!0,this.autoCompletionList=[],this._pendingContent=``,this._themeCompartment=new Ve,this._readonlyCompartment=new Ve,this._handleStoreRefresh=()=>{this.refresh()}}static{this.styles=(0,d.unsafeCSS)(xp)}get content(){return this._view?.state.doc.toString()??this._pendingContent}setContent(e){this._pendingContent=e,this._view&&this._view.state.doc.toString()!==e&&l.i(this._view,e)}focusEditor(){this._view?.focus()}refresh(){this._view?.dispatch({annotations:Cp.of(!0)})}disconnectedCallback(){super.disconnectedCallback(),this.store?.unregisterEditor(this.aggregationWidgetId),this.store?.removeEventListener(`refresh-decorations`,this._handleStoreRefresh),this._cleanupDroppable?.(),this._cleanupDroppable=void 0,this._view?.destroy(),this._view=void 0}firstUpdated(e){let t=this.renderRoot.querySelector(`.editor`);t&&(this._view=new W({state:A.create({doc:this._pendingContent,extensions:this._buildExtensions()}),parent:t}),this.store?.registerEditor(this.aggregationWidgetId,this._view),this.store?.addEventListener(`refresh-decorations`,this._handleStoreRefresh),this._attachDroppable(),requestAnimationFrame(()=>{this.isConnected&&this.setAttribute(`cm-ready`,``)}))}updated(e){(e.has(`hasError`)||e.has(`editorHeight`)||e.has(`singleLine`)||e.has(`rows`)||e.has(`maxRows`)||e.has(`grows`))&&this._view?.dispatch({effects:this._themeCompartment.reconfigure(W.theme(this._buildDynamicTheme()))}),(e.has(`datasets`)||e.has(`contentLanguage`))&&this.refresh(),e.has(`readonly`)&&(this._view?.dispatch({effects:this._readonlyCompartment.reconfigure(this._readonlyExtensions())}),this.readonly?(this._cleanupDroppable?.(),this._cleanupDroppable=void 0,this.removeAttribute(`dragover`)):this._attachDroppable())}_readonlyExtensions(){return this.readonly?[A.readOnly.of(!0),W.editable.of(!1)]:[]}_buildDynamicTheme(){return cp({rows:this.rows,maxRows:this.maxRows,grows:this.grows,editorHeight:this.editorHeight,hasError:this.hasError,singleLine:this.singleLine})}_buildExtensions(){let e=e=>this._buildDecorations(e),t=jr.fromClass(class{constructor(t){this.decorations=I.set(e(t.state.doc.toString()))}update(t){(t.docChanged||t.viewportChanged||t.transactions.some(e=>e.annotation(Cp)))&&(this.decorations=I.set(e(t.state.doc.toString())))}},{decorations:e=>e.decorations,provide:e=>W.atomicRanges.of(t=>{let n=t.plugin(e);return n?n.decorations:I.none})}),n=[Pu(),Wo.of([...Vf,...$u]),ss(),Gf(),W.lineWrapping,W.clipboardOutputFilter.of(e=>this.store?.multiStageAggregation?this.store.transformToAggregationFunctionSyntax(e):e),W.clipboardInputFilter.of(e=>this.store?.multiStageAggregation?this.store.transformToAggregationWidgetSyntax(e):e),W.contentAttributes.of({"aria-label":this.placeholder||(0,p.msg)(`Formula expression`,{desc:`Accessible name for the formula editor input`})}),W.baseTheme(rp),W.theme(ap),this._themeCompartment.of(W.theme(this._buildDynamicTheme())),this._readonlyCompartment.of(this._readonlyExtensions()),t,ms(this.placeholder),hu({override:[this._autoComplete.bind(this)],icons:!1,addToOptions:[{render:e=>{let t=e.iconDef;return t?Sp(t):null},position:20}]}),W.updateListener.of(e=>{e.docChanged&&this.dispatchEvent(new CustomEvent(`luzmo-input-content-changed`,{bubbles:!0,composed:!0,detail:{content:e.state.doc.toString()}}))}),W.focusChangeEffect.of((e,t)=>(t&&(this.store&&(this.store.lastFocusedAggregationWidgetId=this.aggregationWidgetId),this.dispatchEvent(new CustomEvent(`luzmo-input-focused`,{bubbles:!0,composed:!0}))),null))];return this.singleLine&&n.push(A.transactionFilter.of(e=>e.newDoc.lines>1?[]:e)),n}_buildDecorations(e){return this.store?Xf(e,{store:this.store,datasets:this.datasets,contentLanguage:this.contentLanguage,parentAggregationWidgetId:this.aggregationWidgetId,multiStageAggregation:this.store.multiStageAggregation}):[]}_autoComplete(e){let t=e.matchBefore(/\w*/);return t?.from===t?.to&&!e.explicit?null:{from:t?.from??e.pos,options:this.autoCompletionList}}_attachDroppable(){this._cleanupDroppable||this.readonly||(this._cleanupDroppable=a.n({element:this,getDropEffect:()=>`move`,canDrop:({source:e})=>this._canDrop(e.element?.tagName,e.data),onDragEnter:()=>{this.toggleAttribute(`dragover`,!0)},onDrag:({location:e})=>{this._view&&Kf(this._view,{x:e.current.input.clientX,y:e.current.input.clientY})},onDragLeave:()=>{this.toggleAttribute(`dragover`,!1),this._view&&qf(this._view)},onDrop:({source:e,location:t})=>{this.toggleAttribute(`dragover`,!1),this._view&&(qf(this._view),l.r(this._view,{x:t.current.input.clientX,y:t.current.input.clientY})),this._handleDrop(e.element?.tagName,e.data)}}))}_canDrop(e,t){return e===`LUZMO-DATA-FIELD`||e===`LUZMO-DATA-FIELD-LEVEL`?!0:t?.kind===`aggregation`&&this.aggregationWidgetId!==null&&!this.store?.nestedAggregation?!1:t?.kind===`function`||t?.kind===`aggregation`}_handleDrop(e,t){if(!this.store)return;if(e===`LUZMO-DATA-FIELD`||e===`LUZMO-DATA-FIELD-LEVEL`){let e=t;this.store.onExtendExpression({type:`column`,id:e.columnId??null,datasetId:e.datasetId,aggregationWidgetId:this.aggregationWidgetId});return}let n=t;(n?.kind===`function`||n?.kind===`aggregation`)&&this.store.onExtendExpression({type:n.kind,id:n.value,aggregationWidgetId:this.aggregationWidgetId})}render(){return d.html`
|
|
213
|
+
`}};t.t([(0,f.property)({attribute:!1})],bp.prototype,`config`,void 0),t.t([(0,f.property)({attribute:!1})],bp.prototype,`store`,void 0),t.t([(0,f.query)(`luzmo-formula-codemirror`)],bp.prototype,`_nestedCodeMirror`,void 0),t.t([(0,f.query)(`.grouping-overlay`)],bp.prototype,`_groupingOverlay`,void 0),t.t([(0,f.query)(`.function-select`)],bp.prototype,`_functionSelect`,void 0),t.t([(0,f.state)()],bp.prototype,`_groupingPageOverride`,void 0),t.t([(0,f.state)()],bp.prototype,`_autoCompletionList`,void 0),t.t([(0,f.state)()],bp.prototype,`_codeMirrorLoaded`,void 0),t.t([(0,f.state)()],bp.prototype,`_functionKeyboardFocus`,void 0),bp=t.t([(0,p.localized)()],bp),customElements.get(`luzmo-formula-aggregation`)||customElements.define(`luzmo-formula-aggregation`,bp);var xp=`:host{font-family:var(--luzmo-font-family);display:block}.editor{width:100%}.cm-editor.cm-focused{outline:none}.cm-editor{transition:background-color .12s}:host([cm-ready]) .cm-editor{transition:background-color .12s,border-color .12s}:host([dragover]) .cm-editor{background-color:var(--luzmo-background-color-hover)}:host([single-line]){vertical-align:middle;align-items:center;height:100%;display:inline-flex}:host([single-line]) .editor{align-items:center;width:auto;height:100%;min-height:0;display:flex}:host([single-line]) .cm-editor{width:100%}:host([single-line]) .cm-editor .cm-content{flex-direction:column;justify-content:center;padding:0 2px;line-height:1.2;display:flex}:host([single-line]) .cm-editor .cm-scroller{align-items:center;line-height:1.2;overflow:visible}.column-pill-wrapper{vertical-align:middle;padding-inline-end:var(--luzmo-formula-column-pill-trailing-space,var(--luzmo-spacing-1));display:inline-flex}.column-pill{justify-content:center;align-items:center;gap:var(--luzmo-spacing-2);box-sizing:border-box;max-width:16rem;min-height:var(--luzmo-formula-control-height,1.375rem);padding:0 var(--luzmo-formula-column-pill-padding-inline,calc(var(--luzmo-spacing-2) + var(--luzmo-spacing-1)));border-radius:var(--luzmo-border-radius-s);background-color:var(--luzmo-formula-column-pill-background,var(--luzmo-background-color-highlight));color:var(--luzmo-font-color);white-space:nowrap;font-size:.85em;line-height:1.2;display:inline-flex}.column-pill-icon{flex:none;display:inline-flex}.column-pill-icon svg{width:1em;height:1em}.column-pill-label{text-overflow:ellipsis;overflow:hidden}.column-pill-loading{--luzmo-progress-circle-size:1em;align-items:center;display:inline-flex}`;function Sp(e){let t=document.createElement(`span`);return t.className=`cm-completionIcon`,t.setAttribute(`aria-hidden`,`true`),t.appendChild(l.t(e)),t}var Cp=et.define(),$=class extends n.t(e.i){constructor(...e){super(...e),this.aggregationWidgetId=null,this.datasets=[],this.contentLanguage=`en`,this.placeholder=``,this.readonly=!1,this.singleLine=!1,this.hasError=!1,this.rows=3,this.grows=!0,this.autoCompletionList=[],this._pendingContent=``,this._themeCompartment=new Ve,this._readonlyCompartment=new Ve,this._handleStoreRefresh=()=>{this.refresh()}}static{this.styles=(0,d.unsafeCSS)(xp)}get content(){return this._view?.state.doc.toString()??this._pendingContent}setContent(e){this._pendingContent=e,this._view&&this._view.state.doc.toString()!==e&&l.i(this._view,e)}focusEditor(){this._view?.focus()}refresh(){this._view?.dispatch({annotations:Cp.of(!0)})}disconnectedCallback(){super.disconnectedCallback(),this.store?.unregisterEditor(this.aggregationWidgetId),this.store?.removeEventListener(`refresh-decorations`,this._handleStoreRefresh),this._cleanupDroppable?.(),this._cleanupDroppable=void 0,this._view?.destroy(),this._view=void 0}firstUpdated(e){let t=this.renderRoot.querySelector(`.editor`);t&&(this._view=new W({state:A.create({doc:this._pendingContent,extensions:this._buildExtensions()}),parent:t}),this.store?.registerEditor(this.aggregationWidgetId,this._view),this.store?.addEventListener(`refresh-decorations`,this._handleStoreRefresh),this._attachDroppable(),requestAnimationFrame(()=>{this.isConnected&&this.setAttribute(`cm-ready`,``)}))}updated(e){(e.has(`hasError`)||e.has(`editorHeight`)||e.has(`singleLine`)||e.has(`rows`)||e.has(`maxRows`)||e.has(`grows`))&&this._view?.dispatch({effects:this._themeCompartment.reconfigure(W.theme(this._buildDynamicTheme()))}),(e.has(`datasets`)||e.has(`contentLanguage`))&&this.refresh(),e.has(`readonly`)&&(this._view?.dispatch({effects:this._readonlyCompartment.reconfigure(this._readonlyExtensions())}),this.readonly?(this._cleanupDroppable?.(),this._cleanupDroppable=void 0,this.removeAttribute(`dragover`)):this._attachDroppable())}_readonlyExtensions(){return this.readonly?[A.readOnly.of(!0),W.editable.of(!1)]:[]}_buildDynamicTheme(){return cp({rows:this.rows,maxRows:this.maxRows,grows:this.grows,editorHeight:this.editorHeight,hasError:this.hasError,singleLine:this.singleLine})}_buildExtensions(){let e=e=>this._buildDecorations(e),t=jr.fromClass(class{constructor(t){this.decorations=I.set(e(t.state.doc.toString()))}update(t){(t.docChanged||t.viewportChanged||t.transactions.some(e=>e.annotation(Cp)))&&(this.decorations=I.set(e(t.state.doc.toString())))}},{decorations:e=>e.decorations,provide:e=>W.atomicRanges.of(t=>{let n=t.plugin(e);return n?n.decorations:I.none})}),n=[Pu(),Wo.of([...Vf,...$u]),ss(),Gf(),W.lineWrapping,W.clipboardOutputFilter.of(e=>this.store?.multiStageAggregation?this.store.transformToAggregationFunctionSyntax(e):e),W.clipboardInputFilter.of(e=>this.store?.multiStageAggregation?this.store.transformToAggregationWidgetSyntax(e):e),W.contentAttributes.of({"aria-label":this.placeholder||(0,p.msg)(`Formula expression`,{desc:`Accessible name for the formula editor input`})}),W.baseTheme(rp),W.theme(ap),this._themeCompartment.of(W.theme(this._buildDynamicTheme())),this._readonlyCompartment.of(this._readonlyExtensions()),t,ms(this.placeholder),hu({override:[this._autoComplete.bind(this)],icons:!1,addToOptions:[{render:e=>{let t=e.iconDef;return t?Sp(t):null},position:20}]}),W.updateListener.of(e=>{e.docChanged&&this.dispatchEvent(new CustomEvent(`luzmo-input-content-changed`,{bubbles:!0,composed:!0,detail:{content:e.state.doc.toString()}}))}),W.focusChangeEffect.of((e,t)=>(t&&(this.store&&(this.store.lastFocusedAggregationWidgetId=this.aggregationWidgetId,this.store.lastFocusedEmptyArgumentId=null),this.dispatchEvent(new CustomEvent(`luzmo-input-focused`,{bubbles:!0,composed:!0}))),null))];return this.singleLine&&n.push(A.transactionFilter.of(e=>e.newDoc.lines>1?[]:e)),n}_buildDecorations(e){return this.store?Xf(e,{store:this.store,datasets:this.datasets,contentLanguage:this.contentLanguage,parentAggregationWidgetId:this.aggregationWidgetId,multiStageAggregation:this.store.multiStageAggregation}):[]}_autoComplete(e){let t=e.matchBefore(/\w*/);return t?.from===t?.to&&!e.explicit?null:{from:t?.from??e.pos,options:this.autoCompletionList}}_attachDroppable(){this._cleanupDroppable||this.readonly||(this._cleanupDroppable=a.n({element:this,getDropEffect:()=>`move`,canDrop:({source:e})=>this._canDrop(e.element?.tagName,e.data),onDragEnter:()=>{this.toggleAttribute(`dragover`,!0)},onDrag:({location:e})=>{this._view&&Kf(this._view,{x:e.current.input.clientX,y:e.current.input.clientY})},onDragLeave:()=>{this.toggleAttribute(`dragover`,!1),this._view&&qf(this._view)},onDrop:({source:e,location:t})=>{this.toggleAttribute(`dragover`,!1),this._view&&(qf(this._view),l.r(this._view,{x:t.current.input.clientX,y:t.current.input.clientY})),this._handleDrop(e.element?.tagName,e.data)}}))}_canDrop(e,t){return e===`LUZMO-DATA-FIELD`||e===`LUZMO-DATA-FIELD-LEVEL`?!0:t?.kind===`aggregation`&&this.aggregationWidgetId!==null&&!this.store?.nestedAggregation?!1:t?.kind===`function`||t?.kind===`aggregation`}_handleDrop(e,t){if(!this.store)return;if(e===`LUZMO-DATA-FIELD`||e===`LUZMO-DATA-FIELD-LEVEL`){let e=t;this.store.onExtendExpression({type:`column`,id:e.columnId??null,datasetId:e.datasetId,aggregationWidgetId:this.aggregationWidgetId});return}let n=t;(n?.kind===`function`||n?.kind===`aggregation`)&&this.store.onExtendExpression({type:n.kind,id:n.value,aggregationWidgetId:this.aggregationWidgetId})}render(){return d.html`
|
|
213
214
|
<div class="editor"></div>
|
|
214
215
|
`}};t.t([(0,f.property)({attribute:!1})],$.prototype,`store`,void 0),t.t([(0,f.property)({type:String,attribute:`aggregation-widget-id`})],$.prototype,`aggregationWidgetId`,void 0),t.t([(0,f.property)({attribute:!1})],$.prototype,`datasets`,void 0),t.t([(0,f.property)({type:String,attribute:`content-language`})],$.prototype,`contentLanguage`,void 0),t.t([(0,f.property)({type:String})],$.prototype,`placeholder`,void 0),t.t([(0,f.property)({type:Boolean,reflect:!0})],$.prototype,`readonly`,void 0),t.t([(0,f.property)({type:Boolean,reflect:!0,attribute:`single-line`})],$.prototype,`singleLine`,void 0),t.t([(0,f.property)({type:Boolean,reflect:!0,attribute:`has-error`})],$.prototype,`hasError`,void 0),t.t([(0,f.property)({type:String,attribute:`editor-height`})],$.prototype,`editorHeight`,void 0),t.t([(0,f.property)({type:Number})],$.prototype,`rows`,void 0),t.t([(0,f.property)({type:Number,attribute:`max-rows`})],$.prototype,`maxRows`,void 0),t.t([(0,f.property)({type:Boolean})],$.prototype,`grows`,void 0),t.t([(0,f.property)({attribute:!1})],$.prototype,`autoCompletionList`,void 0),$=t.t([(0,p.localized)()],$),customElements.get(`luzmo-formula-codemirror`)||customElements.define(`luzmo-formula-codemirror`,$),customElements.get(`luzmo-formula-codemirror`)||customElements.define(`luzmo-formula-codemirror`,$),Object.defineProperty(exports,"LuzmoFormulaCodeMirror",{enumerable:!0,get:function(){return $}});
|