@panphora/clayjs 1.17.0 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/all.js +1 -1
- package/dist/clay-dom.js +1 -1
- package/dist/clay-events.js +1 -1
- package/dist/clay-internals.js +1 -1
- package/dist/clay-options.js +1 -1
- package/dist/clay-router.js +1 -1
- package/dist/clay-ui.js +1 -1
- package/dist/clay-utils.js +1 -1
- package/dist/clay.js +1 -1
- package/dist/clay.standalone.js +72474 -62090
- package/dist/m/attrs/{save-freeze-MYNVXREN.js → save-freeze-LWGF6XUN.js} +1 -1
- package/dist/m/c-2GRUM77Q.js +30 -0
- package/dist/m/c-2KIEGNC4.js +1 -0
- package/dist/m/{c-AMSNPOCX.js → c-2KL3BD52.js} +1 -1
- package/dist/m/c-2ZZBC45O.js +1 -0
- package/dist/m/c-372N6H3B.js +1 -0
- package/dist/m/{c-4WKFKEKF.js → c-3G2DGZUP.js} +1 -1
- package/dist/m/c-3LDGIBMN.js +1 -0
- package/dist/m/c-3O7OBDCM.js +1 -0
- package/dist/m/c-4ASQPRQL.js +1 -0
- package/dist/m/c-4TXNLX4K.js +6 -0
- package/dist/m/c-4YU3BR4D.js +6 -0
- package/dist/m/c-5734MF2P.js +1 -0
- package/dist/m/c-57XDY6HC.js +1 -0
- package/dist/m/{c-KAU6E43D.js → c-5B4YBZXC.js} +1 -1
- package/dist/m/c-5ONTYIUI.js +1 -0
- package/dist/m/c-5OOVFCJM.js +1 -0
- package/dist/m/{c-3XIRD4NU.js → c-5T6NZHNM.js} +1 -1
- package/dist/m/{c-74MGYWZF.js → c-5ZQV7KC4.js} +1 -1
- package/dist/m/{c-7OLLJPWP.js → c-6DB2OLRJ.js} +1 -1
- package/dist/m/c-6DNRCPNM.js +1 -0
- package/dist/m/c-6UGWFMQC.js +2 -0
- package/dist/m/c-7K4SCQB7.js +1 -0
- package/dist/m/c-7MG5RU63.js +1 -0
- package/dist/m/c-7PRJCA3E.js +1 -0
- package/dist/m/c-A6L3FMUS.js +1 -0
- package/dist/m/c-AMU3BPPR.js +4 -0
- package/dist/m/{c-Y5HBBIQ4.js → c-AMYEFA2E.js} +1 -1
- package/dist/m/c-AQYCG7QW.js +1 -0
- package/dist/m/c-ATKAOH23.js +1 -0
- package/dist/m/c-B5CS55WR.js +1 -0
- package/dist/m/c-B5UJQT7W.js +1 -0
- package/dist/m/c-B7J4K2AE.js +3 -0
- package/dist/m/c-BHZYSHW4.js +1 -0
- package/dist/m/{c-VHM5XQHK.js → c-BIJALSRD.js} +1 -1
- package/dist/m/c-BJ7YQ5QZ.js +1 -0
- package/dist/m/{c-KIPQJX4B.js → c-BRLCTNMC.js} +1 -1
- package/dist/m/{c-VE6ZMYMC.js → c-BUAYFEV5.js} +1 -1
- package/dist/m/c-C6IPRG34.js +1 -0
- package/dist/m/{c-KU3ZFADW.js → c-CAS3NND4.js} +1 -1
- package/dist/m/{c-PS5ARVWR.js → c-CCQ25GFY.js} +1 -1
- package/dist/m/c-CJFDLD43.js +1 -0
- package/dist/m/c-COPTL5WB.js +1 -0
- package/dist/m/c-D3E4WJ4M.js +166 -0
- package/dist/m/c-D5IKEKXW.js +7 -0
- package/dist/m/c-DHBRA6DL.js +1 -0
- package/dist/m/c-DKLS74XB.js +72 -0
- package/dist/m/c-DVYGFTSK.js +3 -0
- package/dist/m/c-E3ZXARWA.js +1 -0
- package/dist/m/c-EK63G3CG.js +1 -0
- package/dist/m/c-ERQSNR6K.js +13 -0
- package/dist/m/c-EVYAISP3.js +1 -0
- package/dist/m/c-EXKHPOVC.js +3 -0
- package/dist/m/{c-QJ4OM3G6.js → c-FWKHM4E7.js} +1 -1
- package/dist/m/{c-4Q2XTQ2N.js → c-GBKB5WDL.js} +1 -1
- package/dist/m/c-GNDL3TKB.js +1 -0
- package/dist/m/c-GRWMD6O5.js +1 -0
- package/dist/m/c-GRXHHFPO.js +1 -0
- package/dist/m/c-HG2C77BM.js +4 -0
- package/dist/m/c-HHGJBU4D.js +1 -0
- package/dist/m/c-HMV6P4RX.js +1 -0
- package/dist/m/c-HMYWIHFG.js +1 -0
- package/dist/m/c-HT2DKBV2.js +1 -0
- package/dist/m/c-I2SCCUEW.js +1 -0
- package/dist/m/{c-TJ6WOJL3.js → c-ICJYHABF.js} +2 -2
- package/dist/m/c-IMZCWYHR.js +7 -0
- package/dist/m/c-IVMD3FEM.js +1 -0
- package/dist/m/{c-WDC5GVKU.js → c-IVTRVENZ.js} +1 -1
- package/dist/m/c-JKZJIUIP.js +1 -0
- package/dist/m/{c-UDUUJPFZ.js → c-JNLX3RJB.js} +1 -1
- package/dist/m/c-K3ADYNLU.js +1 -0
- package/dist/m/c-KGHVFRR3.js +1 -0
- package/dist/m/{c-5QWQ7A5L.js → c-KJJPV77R.js} +1 -1
- package/dist/m/{c-CZUSOB7V.js → c-KNPDOMDY.js} +1 -1
- package/dist/m/{c-EZU56NQV.js → c-KP64LT2A.js} +2 -2
- package/dist/m/c-KQ7E3PYY.js +1 -0
- package/dist/m/c-L3F5ZLIV.js +1 -0
- package/dist/m/{c-3RUU4TPX.js → c-L42OLXWM.js} +3 -2
- package/dist/m/c-L5VFATT6.js +1 -0
- package/dist/m/c-L7JL5TL3.js +3 -0
- package/dist/m/c-LKSL4AUJ.js +1 -0
- package/dist/m/c-M6FNQCTQ.js +1 -0
- package/dist/m/c-MCOOHCSG.js +1 -0
- package/dist/m/c-MHI3GYKF.js +1 -0
- package/dist/m/c-MWXFLW4J.js +1 -0
- package/dist/m/{c-5RJFTLSF.js → c-NEL7HQW3.js} +1 -1
- package/dist/m/{c-DCXOXBF3.js → c-NQJRVJ56.js} +1 -1
- package/dist/m/c-NWX3MFT4.js +1 -0
- package/dist/m/{c-HPURYVZS.js → c-OJYM642Q.js} +1 -1
- package/dist/m/c-OKXI52N7.js +1 -0
- package/dist/m/{c-R3L7ZJGB.js → c-OPLUZR3A.js} +1 -1
- package/dist/m/{c-GSFIGKOP.js → c-OTMKN2OO.js} +1 -1
- package/dist/m/{c-6NC5I2TV.js → c-OYRZ7XG2.js} +1 -1
- package/dist/m/{c-EVCQ3BKA.js → c-P3OFYUMA.js} +1 -1
- package/dist/m/c-PLN76GF3.js +6 -0
- package/dist/m/c-PLP4JKFC.js +1 -0
- package/dist/m/c-Q26MME6N.js +1 -0
- package/dist/m/{c-S7H2DRCB.js → c-Q3XOWZEV.js} +1 -1
- package/dist/m/{c-FRLHSY7E.js → c-QIKT6SKM.js} +1 -1
- package/dist/m/c-QIXT3Q7C.js +28 -0
- package/dist/m/c-QO4HNGCQ.js +1 -0
- package/dist/m/{c-JU3NK25H.js → c-R27DWQKX.js} +1 -1
- package/dist/m/{c-RSMOODDU.js → c-R2XUODVY.js} +1 -1
- package/dist/m/{c-QNKREOL6.js → c-R7LBFMF5.js} +1 -1
- package/dist/m/c-RND3G2S2.js +1 -0
- package/dist/m/{c-Q622NS2Y.js → c-S2U6NJU4.js} +1 -1
- package/dist/m/c-SPZPGD3R.js +1 -0
- package/dist/m/c-SW4YEG2D.js +8 -0
- package/dist/m/c-T637T7SN.js +1 -0
- package/dist/m/c-TJAXGIRV.js +1 -0
- package/dist/m/{c-RYUXUUBX.js → c-TNEM3RNM.js} +1 -1
- package/dist/m/c-TTB5EK4S.js +32 -0
- package/dist/m/c-U7SHNWDH.js +1 -0
- package/dist/m/c-UDHIVLYH.js +20 -0
- package/dist/m/{c-BBVGTQG7.js → c-UGNV5MFB.js} +1 -1
- package/dist/m/{c-QICP2YR5.js → c-UORXLSD3.js} +1 -1
- package/dist/m/c-UPD33ZPE.js +1 -0
- package/dist/m/c-URSMSFCB.js +1 -0
- package/dist/m/c-UY4QX42B.js +1 -0
- package/dist/m/c-V44KWI2L.js +4 -0
- package/dist/m/c-VILENZTD.js +1 -0
- package/dist/m/{c-HDDEEL77.js → c-VJYEVRYK.js} +1 -1
- package/dist/m/{c-SMBZG5X4.js → c-VR2BJ4AN.js} +1 -1
- package/dist/m/c-W4JCVLAB.js +1 -0
- package/dist/m/c-W6DQSHXI.js +135 -0
- package/dist/m/c-WBGWGOM7.js +1 -0
- package/dist/m/{c-4L3BTFRK.js → c-WCXLG3MV.js} +1 -1
- package/dist/m/c-WGW764WX.js +1 -0
- package/dist/m/c-WMRJKQ2V.js +5 -0
- package/dist/m/c-WNTYKCDG.js +1 -0
- package/dist/m/c-WQWIRWO3.js +72 -0
- package/dist/m/c-X5LNHET5.js +1 -0
- package/dist/m/{c-I2ZATQCD.js → c-X5TSXZYJ.js} +2 -2
- package/dist/m/c-XGH4GS2T.js +1 -0
- package/dist/m/c-Y6F2FORL.js +1 -0
- package/dist/m/c-YBKHUAK7.js +10 -0
- package/dist/m/c-YBSS55KU.js +20 -0
- package/dist/m/c-YCLU4UNT.js +2 -0
- package/dist/m/c-YVZ2L7CE.js +1 -0
- package/dist/m/c-ZK4GIZH2.js +1 -0
- package/dist/m/c-ZRXJD4G6.js +1 -0
- package/dist/m/c-ZWBI4HYK.js +1 -0
- package/dist/m/core/{admin-attrs-QHOKPJ7W.js → admin-attrs-YY7T5FGU.js} +1 -1
- package/dist/m/core/autosave-S6OMNDCK.js +1 -0
- package/dist/m/core/conflict-notice-IWHMHH43.js +1 -0
- package/dist/m/core/{host-permission-FNXVEFNE.js → host-permission-6EVJGNPL.js} +1 -1
- package/dist/m/core/is-edit-mode-GCX6767E.js +1 -0
- package/dist/m/core/{persist-JFYRHMRJ.js → persist-UKXV5KLA.js} +1 -1
- package/dist/m/core/recovery-DRFZRJED.js +1 -0
- package/dist/m/core/save-LYY7K6U7.js +1 -0
- package/dist/m/core/save-core-MKRPSEEO.js +1 -0
- package/dist/m/core/snapshot-NU3YM6GR.js +1 -0
- package/dist/m/core/unsaved-warning-7QTKEN7Z.js +1 -0
- package/dist/m/internals/{index-PVXGPUDA.js → index-TGLQINN3.js} +1 -1
- package/dist/m/loader-3BBNZZGM.js +1 -0
- package/dist/m/manifest-F449FF98.js +1 -0
- package/dist/m/manifest-edit-4396A009.js +1 -0
- package/dist/m/manifest.json +2111 -1573
- package/dist/m/page/{editor-NNJA4OKD.js → editor-6LRB3GE4.js} +123 -21
- package/dist/m/plugins/ai-edit-UTV7YO2I.js +6 -0
- package/dist/m/plugins/{cms-HP3LSTPN.js → cms-LRAOZHT7.js} +9 -9
- package/dist/m/plugins/{demo-RM5IR6AO.js → demo-OYO5GCAO.js} +1 -1
- package/dist/m/plugins/{derive-UAAA4V4S.js → derive-FRE5JJQE.js} +1 -1
- package/dist/m/plugins/indicator-4VDXWYTD.js +1 -0
- package/dist/m/plugins/live-AD4H6XSL.js +1 -0
- package/dist/m/plugins/menu-M5WW7DBF.js +1 -0
- package/dist/m/plugins/page-MD3T2ZX3.js +2 -0
- package/dist/m/plugins/page-view-PAWVZNFY.js +1 -0
- package/dist/m/plugins/{people-SGPJKANK.js → people-JCHVPF7P.js} +1 -1
- package/dist/m/plugins/quickcrop-BQ5YYFCH.js +26 -0
- package/dist/m/plugins/{richclay-NRQDSWX6.js → richclay-KLGETK77.js} +2 -2
- package/dist/m/plugins/sortable-4S6SQC3D.js +1 -0
- package/dist/m/plugins/source-TJXOIOYY.js +1 -0
- package/dist/m/plugins/undo-NLPGCJQY.js +1 -0
- package/dist/m/plugins/{unsent-HJFLQJ2O.js → unsent-OA4RGBUT.js} +1 -1
- package/dist/m/plugins/upgrade-HSUNDNJD.js +1 -0
- package/dist/m/plugins/{upload-WLYKK6TL.js → upload-NHGJXZK2.js} +1 -1
- package/dist/m/plugins/visitor-drafts-BW43DGY3.js +20 -0
- package/dist/m/plugins/visitor-drafts-owner-7ODQG7JX.js +1 -0
- package/dist/m/plugins/{wire-4N6GYAF6.js → wire-VBWXEXU2.js} +1 -1
- package/dist/m/reader-core-4W2KYEWQ.js +77 -0
- package/dist/m/route/route-62CHXL5B.js +1 -0
- package/dist/m/sync/live-sync-MO5DH33W.js +1 -0
- package/dist/m/ui/index-IVWN2QC4.js +1 -0
- package/dist/m/vendor/sap-core.vendor-RN4ZVY4X.js +6 -0
- package/dist/offline-manifest.json +1367 -930
- package/dist/page/themes/light-1.css +8 -7
- package/dist/server/core.cjs +1440 -288
- package/dist/server/offline-runtime.cjs +63 -63
- package/dist/server/offline-runtime.mjs +63 -63
- package/dist/server/page-compaction-worker.cjs +3710 -0
- package/dist/server/rooms.mjs +5 -0
- package/docs/guide.md +653 -101
- package/entries/sap.js +5 -5
- package/package.json +1 -1
- package/src/core/admin-contenteditable.js +5 -2
- package/src/core/admin-inputs.js +1 -0
- package/src/core/admin-onclick.js +2 -1
- package/src/core/conflict-notice-ui.js +4 -7
- package/src/core/download.js +2 -2
- package/src/core/host-meta.js +38 -0
- package/src/core/is-edit-mode.js +17 -1
- package/src/core/mode-key.js +125 -19
- package/src/core/mode-support.js +5 -0
- package/src/core/mode-transition.js +20 -6
- package/src/core/preserve-authored.js +4 -4
- package/src/core/recovery.js +121 -33
- package/src/core/save-accepted.js +33 -0
- package/src/core/save-core.js +106 -31
- package/src/core/save-job.js +108 -0
- package/src/core/save-prepare.js +53 -0
- package/src/core/save-size-notice.js +3 -1
- package/src/core/save-slices.js +15 -0
- package/src/core/save.js +557 -127
- package/src/core/serialize-steps.js +109 -0
- package/src/core/snapshot.js +170 -39
- package/src/core/source-map.js +83 -38
- package/src/core/stale-host-notice.js +1 -0
- package/src/core/upgrade-run.js +59 -8
- package/src/dom/active-element.js +5 -0
- package/src/lib/assets.js +1 -0
- package/src/lib/slice.js +65 -0
- package/src/lib/uimotion.js +774 -0
- package/src/lib/unsaved-state.js +2 -2
- package/src/live/fast-lane.js +10 -3
- package/src/live/local-lane.js +202 -11
- package/src/live/ops.js +16 -0
- package/src/live/page-compaction.js +162 -0
- package/src/live/server-lane.js +1 -0
- package/src/live/store.js +11 -3
- package/src/loader-logic.js +3 -1
- package/src/loader.js +14 -4
- package/src/page/adopt-boot.js +2 -1
- package/src/page/awareness.js +33 -2
- package/src/page/blocks.js +89 -27
- package/src/page/boot-pack.js +1 -1
- package/src/page/chart-tables.js +21 -3
- package/src/page/chart.js +406 -63
- package/src/page/checklist.js +10 -135
- package/src/page/checkpoint-proof.js +7 -1
- package/src/page/chrome.js +250 -51
- package/src/page/clipboard-shape.js +126 -0
- package/src/page/drag.js +33 -3
- package/src/page/editor.js +136 -25
- package/src/page/export-assets.js +357 -0
- package/src/page/export-html.js +209 -0
- package/src/page/export-markdown.js +361 -0
- package/src/page/features/checklist.js +428 -0
- package/src/page/features/export-html.js +189 -0
- package/src/page/features/export-markdown.js +169 -0
- package/src/page/features/import-markdown.js +349 -0
- package/src/page/features/media.js +61 -5
- package/src/page/features/registry.js +18 -0
- package/src/page/features/table.js +373 -83
- package/src/page/features/title-cover.js +331 -0
- package/src/page/features/title-icon.js +213 -0
- package/src/page/features/toc.js +87 -0
- package/src/page/format-command.js +25 -1
- package/src/page/format-gate.js +68 -18
- package/src/page/format-host.js +17 -0
- package/src/page/format-native-commands.js +21 -5
- package/src/page/image-actions.js +64 -0
- package/src/page/import-markdown.js +262 -0
- package/src/page/items.js +135 -17
- package/src/page/markdown.js +6 -2
- package/src/page/media.js +35 -119
- package/src/page/placeholder.js +14 -1
- package/src/page/projection.js +98 -10
- package/src/page/recover.js +10 -12
- package/src/page/recovery-ui.js +464 -0
- package/src/page/rich/chart.js +63 -7
- package/src/page/save-projection.js +28 -0
- package/src/page/save-states.js +13 -3
- package/src/page/schema.js +19 -3
- package/src/page/table-paste.js +3 -1
- package/src/page/table-style.js +4 -4
- package/src/page/table.js +44 -2
- package/src/page/themes/light-1.css +8 -7
- package/src/page/themes/light-1.source.css +8 -7
- package/src/page/toc-link.js +31 -0
- package/src/page/toc.js +5 -0
- package/src/page/view-hooks.js +38 -12
- package/src/page/view.js +13 -0
- package/src/page/ybind/binding.js +88 -5
- package/src/page/ybind/bridge.js +187 -20
- package/src/page/ybind/containment.js +162 -0
- package/src/page/ybind/doc.js +17 -9
- package/src/page/ybind/file-debt.js +63 -0
- package/src/page/ybind/layout.js +7 -2
- package/src/page/ybind/marks.js +1 -1
- package/src/page/ybind/moves.js +5 -4
- package/src/page/ybind/origins.js +106 -4
- package/src/page/ybind/parts.js +8 -1
- package/src/page/ybind/provider.js +113 -17
- package/src/page/ybind/recovery-proof.js +32 -9
- package/src/page/ybind/recovery-replay.js +558 -15
- package/src/page/ybind/recovery.js +174 -45
- package/src/page/ybind/table.js +67 -11
- package/src/page/ybind/walk-delta.js +258 -0
- package/src/page/ybind/walk.js +54 -29
- package/src/page/ybind/writer.js +1 -1
- package/src/plugins/ai-edit.js +13 -9
- package/src/plugins/indicator-chip.js +91 -0
- package/src/plugins/indicator.js +13 -80
- package/src/plugins/live.js +89 -14
- package/src/plugins/menu/actions.js +196 -0
- package/src/plugins/menu/people.js +279 -0
- package/src/plugins/menu/placement.js +121 -0
- package/src/plugins/menu/preferences.js +9 -0
- package/src/plugins/menu/seo.js +316 -397
- package/src/plugins/menu/style.js +171 -0
- package/src/plugins/menu/variants.js +296 -0
- package/src/plugins/menu.js +186 -183
- package/src/plugins/page-view.js +3 -2
- package/src/plugins/page.js +249 -44
- package/src/plugins/sortable.js +8 -1
- package/src/plugins/source.js +6 -0
- package/src/plugins/upgrade.js +51 -17
- package/src/plugins/upload-ui.js +12 -17
- package/src/plugins/visitor-drafts/bottom-ui.js +12 -4
- package/src/plugins/visitor-drafts/intro-style.js +7 -2
- package/src/plugins/visitor-drafts/intro.js +5 -3
- package/src/plugins/visitor-drafts/owner-chip.js +8 -12
- package/src/plugins/visitor-drafts/prompt.js +11 -9
- package/src/plugins/visitor-drafts/source.js +4 -3
- package/src/plugins/visitor-drafts/store.js +138 -9
- package/src/plugins/visitor-drafts/ui-memory.js +2 -2
- package/src/plugins/visitor-drafts-owner.js +4 -6
- package/src/plugins/visitor-drafts.js +5 -3
- package/src/recovery/store.js +1 -1
- package/src/route/route.js +4 -0
- package/src/server/rooms/index.js +5 -1
- package/src/server/rooms/live-data-rooms.js +302 -50
- package/src/server/rooms/page-compaction-worker.js +12 -0
- package/src/server/rooms/page-compactor.js +92 -0
- package/src/server/rooms/page-room-conformance.js +461 -0
- package/src/source/parse-steps.js +94 -0
- package/src/source/session.js +233 -57
- package/src/sync/editing-sender.js +12 -0
- package/src/sync/live-sync-edit.js +22 -2
- package/src/sync/live-sync.js +150 -23
- package/src/sync/page-relay.js +52 -0
- package/src/sync/presence-store.js +44 -4
- package/src/sync/presence.js +6 -3
- package/src/sync/saved-stream.js +11 -6
- package/src/ui/bevel-controls.js +1 -0
- package/src/ui/bevel-dialog.js +5 -2
- package/src/ui/editor-ui.js +77 -0
- package/src/ui/page-colour.js +281 -0
- package/src/ui/toast.js +16 -7
- package/src/vendor/hyper-html-api-upgrade.vendor.js +2 -2
- package/src/vendor/hyper-undo.vendor.js +1 -1
- package/src/vendor/hypercms.vendor.js +9 -9
- package/src/vendor/parse5.vendor.js +2 -2
- package/src/vendor/sap-core.vendor.js +5 -5
- package/dist/m/c-2SPVQSHC.js +0 -1
- package/dist/m/c-336SGU5W.js +0 -1
- package/dist/m/c-3H6BZDNJ.js +0 -6
- package/dist/m/c-4DFEJ2PO.js +0 -3
- package/dist/m/c-56QRZTZH.js +0 -1
- package/dist/m/c-5J4E7O4Y.js +0 -4
- package/dist/m/c-5LKDWQTL.js +0 -19
- package/dist/m/c-5V3MOVJT.js +0 -1
- package/dist/m/c-6AZOGAPE.js +0 -1
- package/dist/m/c-6CRUUXOX.js +0 -5
- package/dist/m/c-6HMB24EV.js +0 -1
- package/dist/m/c-6KEVEQ7L.js +0 -1
- package/dist/m/c-A3E3NIMC.js +0 -1
- package/dist/m/c-BQ6LOBEE.js +0 -1
- package/dist/m/c-BTDI4Y23.js +0 -1
- package/dist/m/c-CJ3A7ZKE.js +0 -1
- package/dist/m/c-CQHPGKX2.js +0 -1
- package/dist/m/c-DFS4XZJV.js +0 -2
- package/dist/m/c-DNENWY4O.js +0 -1
- package/dist/m/c-E4LIR5X5.js +0 -1
- package/dist/m/c-FDNHHZY5.js +0 -1
- package/dist/m/c-FROJUZMV.js +0 -1
- package/dist/m/c-G2JPKCTP.js +0 -1
- package/dist/m/c-GB6TU7WV.js +0 -1
- package/dist/m/c-GFJJEBTU.js +0 -1
- package/dist/m/c-GJAEGGXY.js +0 -1
- package/dist/m/c-GOWBDM6J.js +0 -1
- package/dist/m/c-HFKUVACH.js +0 -1
- package/dist/m/c-HHDFCNHV.js +0 -1
- package/dist/m/c-IEM4NTCS.js +0 -1
- package/dist/m/c-JDCX26UP.js +0 -25
- package/dist/m/c-KGVGROZT.js +0 -1
- package/dist/m/c-KQ6TYJAP.js +0 -135
- package/dist/m/c-LFPHCXY3.js +0 -1
- package/dist/m/c-LRPUO2MX.js +0 -1
- package/dist/m/c-LWLBHLVC.js +0 -3
- package/dist/m/c-M2L47S2X.js +0 -7
- package/dist/m/c-MFP2ZWD4.js +0 -1
- package/dist/m/c-MKSQ4Y57.js +0 -1
- package/dist/m/c-NUFFJVVJ.js +0 -1
- package/dist/m/c-NUHSPT5P.js +0 -1
- package/dist/m/c-O72HVYSA.js +0 -1
- package/dist/m/c-OIBUTDXI.js +0 -1
- package/dist/m/c-OW5QIGG3.js +0 -1
- package/dist/m/c-PGRCK73F.js +0 -1
- package/dist/m/c-Q7NQD65V.js +0 -1
- package/dist/m/c-QH63LQOS.js +0 -1
- package/dist/m/c-R7IWVINQ.js +0 -1
- package/dist/m/c-RM7J7BV2.js +0 -1
- package/dist/m/c-S4ZEH46B.js +0 -9
- package/dist/m/c-SDAXDM2D.js +0 -1
- package/dist/m/c-SMGU7RT3.js +0 -235
- package/dist/m/c-SPIORRYS.js +0 -1
- package/dist/m/c-SWLRT66R.js +0 -1
- package/dist/m/c-TCJTVAFN.js +0 -1
- package/dist/m/c-TQEMVJCS.js +0 -1
- package/dist/m/c-TYLXX4NF.js +0 -21
- package/dist/m/c-U62OB4BT.js +0 -1
- package/dist/m/c-U6YWUAR3.js +0 -8
- package/dist/m/c-UDCSU5G5.js +0 -2
- package/dist/m/c-VI5RMSVY.js +0 -1
- package/dist/m/c-VRZN56XY.js +0 -1
- package/dist/m/c-W5MCHEGA.js +0 -1
- package/dist/m/c-WNYBLIOZ.js +0 -1
- package/dist/m/c-WWXIDH4O.js +0 -28
- package/dist/m/c-XCNTK76U.js +0 -1
- package/dist/m/c-XMS6DPBR.js +0 -1
- package/dist/m/c-ZUCOKOHT.js +0 -1
- package/dist/m/c-ZVPVXTJF.js +0 -4
- package/dist/m/c-ZVRKXKM7.js +0 -1
- package/dist/m/core/autosave-HRYGUWV6.js +0 -1
- package/dist/m/core/conflict-notice-6MROJN2L.js +0 -1
- package/dist/m/core/is-edit-mode-KTWA3O5N.js +0 -1
- package/dist/m/core/recovery-FLTCC2OC.js +0 -1
- package/dist/m/core/save-HQZ4S667.js +0 -1
- package/dist/m/core/save-core-KGQWFUNH.js +0 -1
- package/dist/m/core/snapshot-EGQZNT45.js +0 -1
- package/dist/m/core/unsaved-warning-IDJLD66H.js +0 -1
- package/dist/m/loader-S4I7GKXR.js +0 -1
- package/dist/m/manifest-4C419D67.js +0 -1
- package/dist/m/manifest-edit-B077F288.js +0 -1
- package/dist/m/plugins/ai-edit-QN4PMMNL.js +0 -6
- package/dist/m/plugins/indicator-URDBBOQO.js +0 -1
- package/dist/m/plugins/live-HFWD4OIH.js +0 -1
- package/dist/m/plugins/menu-3HIEQSI6.js +0 -138
- package/dist/m/plugins/page-JOKB6XPR.js +0 -2
- package/dist/m/plugins/page-view-NXOJHNW6.js +0 -1
- package/dist/m/plugins/quickcrop-QNY3PKLD.js +0 -26
- package/dist/m/plugins/sortable-GWT4PWDV.js +0 -1
- package/dist/m/plugins/source-4ZRSAIYM.js +0 -1
- package/dist/m/plugins/undo-VDA5P7FH.js +0 -1
- package/dist/m/plugins/upgrade-W7FG5VFG.js +0 -1
- package/dist/m/plugins/visitor-drafts-LIDY7NH6.js +0 -21
- package/dist/m/plugins/visitor-drafts-owner-ZXCKBZE7.js +0 -1
- package/dist/m/reader-core-DXYCURFF.js +0 -68
- package/dist/m/route/route-KOCZSEGN.js +0 -1
- package/dist/m/sync/live-sync-J7VMYTKS.js +0 -1
- package/dist/m/ui/index-3JLVI27O.js +0 -1
- package/dist/m/vendor/sap-core.vendor-A7BMUYZT.js +0 -6
- /package/dist/m/{c-FILLTJA7.js → c-QTTJYJMA.js} +0 -0
- /package/dist/m/plugins/{quickcrop-QNY3PKLD.js.LEGAL.txt → quickcrop-BQ5YYFCH.js.LEGAL.txt} +0 -0
- /package/dist/m/plugins/{richclay-NRQDSWX6.js.LEGAL.txt → richclay-KLGETK77.js.LEGAL.txt} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// GENERATED — do not edit. Vendored from sapjs/dist/sap-core.min.js via sapjs
|
|
2
2
|
// `npm run copy-to-clayjs`. Edit the sapjs source and re-run.
|
|
3
|
-
var SapCoreBundle=(()=>{var
|
|
4
|
-
`+(e[0]==="W"?"sap \u26A0 ":"sap \u2717 ")+e+" "+o];return i.push(` at ${
|
|
5
|
-
`)),
|
|
6
|
-
${t}`:`"use strict"; return (${t});`;n={fn:new Function(...
|
|
3
|
+
var SapCoreBundle=(()=>{var At=Object.defineProperty;var rn=Object.getOwnPropertyDescriptor;var on=Object.getOwnPropertyNames;var sn=Object.prototype.hasOwnProperty;var an=(t,e)=>{for(var r in e)At(t,r,{get:e[r],enumerable:!0})},un=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of on(e))!sn.call(t,o)&&o!==r&&At(t,o,{get:()=>e[o],enumerable:!(n=rn(e,o))||n.enumerable});return t};var cn=t=>un(At({},"__esModule",{value:!0}),t);var Jn={};an(Jn,{FULL_SAPJS:()=>Z,Sap:()=>tt,default:()=>Kn,mount:()=>Yn,mountAll:()=>en,needsFullSapjs:()=>Bt,runtime:()=>Gn});function jt(t){let e=!1,r=new Set,n=[];function o(a){a&&(n.push(a),n.length>8&&n.shift())}function s(a,d){if(o(d),a._broken){if(d==="mutation")return;l(a)}r.add(a),!e&&(e=!0,queueMicrotask(i))}function i(){e=!1;let a=[...r];r.clear();for(let d of a)f(d)}function f(a,d=!1){if(!(a._broken||a.halted)){if(a._passes=(a._passes||0)+1,a._passes>50){a._broken=!0,a._breakerRing=n.slice(),t(a,{breaker:!0});return}a._resetArmed||(a._resetArmed=!0,setTimeout(()=>{a._passes=0,a._resetArmed=!1},0)),t(a,d?{full:!0}:{})}}function c(a,d){o(d),a._broken&&l(a),f(a,!0)}function l(a){a._broken=!1,a._passes=0}return{schedule:s,runNow:c,rearm:l,ring:n}}var Et={E01:{slug:"foreign-dialect",behavior:"HALT"},E02:{slug:"moustaches-in-text",behavior:"HALT"},E04:{slug:"duplicate-declaration",behavior:"HALT"},E05:{slug:"reserved-name",behavior:"HALT"},E06:{slug:"global-html-name",behavior:"HALT"},E07:{slug:"calc-cycle",behavior:"ERR"},E08:{slug:"expression-syntax",behavior:"HALT"},E10:{slug:"orphan-item",behavior:"HALT"},E12:{slug:"unknown-state-key",behavior:"ERR"},E15:{slug:"write-to-undeclared-key",behavior:"ERR"},E16:{slug:"write-to-computed-field",behavior:"ERR"},E17:{slug:"unresolvable-action-target",behavior:"HALT"},E18:{slug:"paint-on-form-control",behavior:"HALT"},E20:{slug:"bind-on-non-control",behavior:"HALT"},E22:{slug:"format-type",behavior:"ERR"},E24:{slug:"runtime-expression-throw",behavior:"ERR"},E26:{slug:"circuit-breaker",behavior:"HALT"},E30:{slug:"attr-on-bound-control",behavior:"HALT"},E31:{slug:"password-without-transient",behavior:"HALT"},E32:{slug:"file-bind",behavior:"HALT"},E33:{slug:"dialog-state-open",behavior:"HALT"},E34:{slug:"transient-persist-collision",behavior:"HALT"},E35:{slug:"presence-state-misuse",behavior:"HALT"},E40:{slug:"each-not-array",behavior:"ERR"},E41:{slug:"each-bad-key",behavior:"ERR"},E42:{slug:"each-template",behavior:"ERR"},E43:{slug:"bind-in-each-row",behavior:"ERR"},E50:{slug:"needs-full-sapjs",behavior:"HALT"},W03:{slug:"unknown-colon-attribute",behavior:"WARN"},W04:{slug:"expression-in-when",behavior:"WARN"},W30:{slug:"nonzero-mount-writes",behavior:"WARN"},W31:{slug:"detail-dialog-saved-open",behavior:"WARN"}},z=["disabled","readonly","required","checked","selected","multiple","open","inert","autofocus","novalidate","hidden"],xt=new Set(["title","style","hidden","lang","dir","translate","class","id","nonce","autofocus","tabindex","contenteditable","spellcheck","draggable","role","slot","part","name","value","type","itemscope","itemtype","itemid","itemprop","itemref"]),Ht=new Set(["sap","scope","items","item","template","bind","calc","text","show","attr","set","trigger","move","sort","detail","each","effect","invalid","confirm","transient","default","persist","sortable","editmode"]);function ln(t){if(!t||t.nodeType!==1)return"?";if(t.id)return`${t.tagName.toLowerCase()}#${t.id}`;let e=[],r=t,n=0;for(;r&&r.nodeType===1&&n<4;){let o=r.tagName.toLowerCase();if(r.hasAttribute("sap"))o+="[sap]";else if(r.parentElement){let s=0,i=0;for(let f=r.parentElement.firstElementChild;f;f=f.nextElementSibling)f.tagName===r.tagName&&(s++,f===r&&(i=s));s>1&&(o+=`:nth-of-type(${i})`)}if(e.unshift(o),r.hasAttribute("sap"))break;r=r.parentElement,n++}return e.join(" > ")}var ot=class{constructor(e){this.appName=e,this.errors=[],this.warnings=[],this.halted=!1,this.haltReason=null}block(e,r,n={}){let o=(Et[e]||{}).slug||"error",s={code:e,slug:o,el:ln(r),attr:n.attr||null,expr:n.expr||null,key:n.key||null,problem:n.problem||"",didYouMean:n.didYouMean||null,fix:n.fix||null,phase:n.phase||"runtime"},i=[`
|
|
4
|
+
`+(e[0]==="W"?"sap \u26A0 ":"sap \u2717 ")+e+" "+o];return i.push(` at ${s.el}${s.attr?` \u2014 ${s.attr}="${s.expr??""}"`:""}`),s.problem&&i.push(` problem: ${s.problem}`),s.didYouMean&&i.push(` did you mean: ${s.didYouMean}`),s.fix&&i.push(` fix: ${s.fix}`),(e[0]==="W"?console.warn:console.error)(i.join(`
|
|
5
|
+
`)),s}error(e,r,n={}){let o=this.block(e,r,n);return this.errors.push(o),o}warn(e,r,n={}){let o=this.block(e,r,n);return this.warnings.push(o),o}report(){return{ok:this.errors.length===0&&!this.halted,app:this.appName,halted:this.halted,haltReason:this.haltReason,errors:this.errors.slice(),warnings:this.warnings.slice()}}};function B(t,e){t&&t.getAttribute("sap-error")!==e&&t.setAttribute("sap-error",e)}function zt(t){t&&t.hasAttribute("sap-error")&&t.removeAttribute("sap-error")}function vt(t,e){let r=null,n=3;for(let o of e){let s=fn(t,o);s<n&&(n=s,r=o)}return r}function fn(t,e){let r=t.length,n=e.length,o=Array.from({length:r+1},(s,i)=>[i,...new Array(n).fill(0)]);for(let s=0;s<=n;s++)o[0][s]=s;for(let s=1;s<=r;s++)for(let i=1;i<=n;i++)o[s][i]=Math.min(o[s-1][i]+1,o[s][i-1]+1,o[s-1][i-1]+(t[s-1]===e[i-1]?0:1));return o[r][n]}var dn=new Set(z),pn={readonly:"readOnly",novalidate:"noValidate"},mn=0,Ut=new WeakMap;function qt(t,e="sap"){let r=t.getAttribute("data-id");if(r)return r;if(t.id)return t.id;let n=Ut.get(t);return n||(n=`${e}-${(mn++).toString(36)}`,Ut.set(t,n)),n}function Vt(t){let e=[];for(let r=t.firstElementChild;r;r=r.nextElementSibling)r.hasAttribute("item")&&!r.hasAttribute("template")&&!r.hasAttribute("cms-template")&&e.push(r);return e}function St(t,e){if(!t||!e)return null;let r=[...t.querySelectorAll(`template[items="${e}"]`)].find(o=>o.closest("[sap]")===t),n=r&&r.content.firstElementChild;return n&&n.hasAttribute("item")?n:null}function Yt(t){for(let e=t.firstElementChild;e;e=e.nextElementSibling)if(e.hasAttribute("item")&&e.hasAttribute("template"))return e;return St(t.closest("[sap]"),t.getAttribute("items"))}function it(t){let e=[];if(!t)return e;for(let r of t.trim().split(/\s+/)){if(!r)continue;let n=r,o,s=n.indexOf("=");s>=0&&(o=n.slice(s+1),n=n.slice(0,s));let i=n.split(":"),f=i[0],c="string",l=!1;for(let p of i.slice(1))p==="num"?c="num":p==="bool"?c="bool":p==="presence"?c="presence":p==="transient"&&(l=!0);let a=f,d=a.startsWith("data-")&&a.length>5?a.slice(5).replace(/-([a-z])/g,(p,v)=>v.toUpperCase()):a;e.push({name:d,attr:a,type:c,default:o,transient:l})}return e}function st(t,e){if(e==="num"){if(t==null||t==="")return 0;let r=Number(t);return Number.isNaN(r)?0:r}return e==="bool"?t==="true"||t===""||t==="1":t??""}function Gt(t,e){return e==="bool"?t?"true":"false":t==null?"":String(t)}function kt(t,e){return dn.has(e)&&typeof t[pn[e]||e]=="boolean"}function Nt(t,e){return e.type==="presence"||e.type!=="num"&&kt(t,e.attr||e.name)}function Tt(t){return t.default!=null?t.default:t.type==="num"?"0":t.type==="bool"?"false":""}function Xt(t,e){let r=e.attr||e.name,n=t._sapTransient||(t._sapTransient={});if(!(e.name in n)){let o=t.getAttribute(r);o==null&&(o=Tt(e)),n[e.name]=st(o,e.type)}return t.hasAttribute(r)&&t.removeAttribute(r),n[e.name]}function P(t){if(typeof t=="number")return t;if(t==null||t==="")return 0;let e=Number(typeof t=="string"?t.replace(/[$,%\s]/g,""):t);return Number.isNaN(e)?0:e}function at(t,e){return Array.isArray(t)?e==null?t:t.map(r=>typeof e=="function"?e(r):r?.[e]):[]}function Rt(t,e){return at(t,e).reduce((r,n)=>r+P(n),0)}function Kt(t,e){return Array.isArray(t)?e==null?t.length:t.reduce((r,n)=>r+(e(n)?1:0),0):0}function Jt(t,e){let r=at(t,e);return r.length?Rt(t,e)/r.length:0}function Qt(t,e){let r=at(t,e).filter(n=>n!=null&&n!=="");return r.length?r.every(n=>typeof n=="number"||!Number.isNaN(Number(n)))?Math.min(...r.map(Number)):r.reduce((n,o)=>String(n)<=String(o)?n:o):0}function Zt(t,e){let r=at(t,e).filter(n=>n!=null&&n!=="");return r.length?r.every(n=>typeof n=="number"||!Number.isNaN(Number(n)))?Math.max(...r.map(Number)):r.reduce((n,o)=>String(n)>=String(o)?n:o):0}function te(t,e,r){let n=P(t)===1?e:r??e+"s";return`${t} ${n}`}function ee(t,e){let r=new Date(t),n=new Date(e);return Number.isNaN(+r)||Number.isNaN(+n)?0:Math.round((n-r)/864e5)}function O(t){return typeof t=="number"?t:Number(t)}var U={usd:t=>"$"+O(t).toLocaleString("en-US",{maximumFractionDigits:0}),usd2:t=>"$"+O(t).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}),pct:t=>Math.round(O(t))+"%",pct1:t=>O(t).toFixed(1)+"%",int:t=>Math.round(O(t)).toLocaleString("en-US"),num:t=>O(t).toLocaleString("en-US"),num2:t=>O(t).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}),compact:t=>O(t).toLocaleString("en-US",{notation:"compact"}),date:t=>{let e=new Date(t);return Number.isNaN(+e)?String(t):e.toLocaleDateString("en-US")},clock:t=>{let e=O(t),r=Math.floor(e/100),n=r%10,o=Math.floor(r/10)%60;return`${Math.floor(r/600)}:${String(o).padStart(2,"0")}.${n}`}},hn=new Set(["usd","usd2","pct","pct1","int","num","num2","compact","clock"]);function ne(t,e){if(!t)return e==null?"":String(e);let r=U[t];if(typeof r!="function"){let n=new Error(`unknown format "${t}"`);throw n.sapCode="E22",n}if(hn.has(t)){let n=typeof e=="number"?e:Number(e);if(!Number.isFinite(n)){let o=new Error(`format "${t}" received ${typeof e=="string"?`"${e}"`:e}`);throw o.sapCode="E22",o}}return r(e)}var bn=["state","item","el","root","fmt","num","sum","count","avg","min","max","plural","days"],ut=new Map,re=/\bstate\.([a-z][a-z0-9_]*)/g,oe=/\bitem\.([a-z][a-z0-9_]*)/g;function gn(t){let e=new Set,r=new Set,n;for(re.lastIndex=0;n=re.exec(t);)e.add(n[1]);for(oe.lastIndex=0;n=oe.exec(t);)r.add(n[1]);return{state:e,item:r}}function M(t,e=!1){let r=(e?"!":"")+t,n=ut.get(r);if(n)return n;ut.size>512&&ut.clear();try{let o=e?`"use strict";
|
|
6
|
+
${t}`:`"use strict"; return (${t});`;n={fn:new Function(...bn,o),src:t,statement:e,deps:gn(t),error:null}}catch(o){n={fn:null,src:t,statement:e,deps:{state:new Set,item:new Set},error:o}}return ut.set(r,n),n}function ie(t,e,r,n,o){if(t.error)throw t.error;return t.fn(e,r,n,o,U,P,Rt,Kt,Jt,Qt,Zt,te,ee)}var J={},K=null,ae=!0,lt=!1;function ue(){J={}}function ce(t){let e=lt;return K?fe(K.takeRecords()):ae&&yn(),lt=!!K&&t.getRootNode()===document,e}function le(t){lt=t}function yn(){if(typeof document>"u"||typeof MutationObserver!="function"){ae=!1;return}K=new MutationObserver(fe),K.observe(document,{attributes:!0,childList:!0,subtree:!0})}function fe(t){for(let e of t)if(e.type==="attributes")e.target._sapPlan&&(e.target._sapPlan=null);else for(let r of e.addedNodes)r.nodeType===1&&de(r)}function de(t){t._sapPlan&&(t._sapPlan=null);for(let e=t.firstElementChild;e;e=e.nextElementSibling)de(e)}function ft(t){if(!lt)return se(t);let e=t._sapPlan;return e&&e.gen===J?e:t._sapPlan=se(t)}function se(t){let e={gen:J,inert:t.tagName==="TEMPLATE",template:!1,cms:!1,item:!1,scope:!1,items:!1,detail:!1,each:!1,boundary:null,bind:null,transient:!1,decls:null,calcs:null,paints:null,effects:null,invalids:null};for(let r of t.attributes){let n=r.name,o=r.value,s=n.indexOf(":");if(s<0){switch(n){case"sap-ignore":e.inert=!0;break;case"cms-template":e.inert=!0,e.cms=!0;break;case"template":e.inert=!0,e.template=!0;break;case"item":e.item=!0;break;case"scope":e.scope=!0;break;case"items":e.items=!0;break;case"detail":e.detail=!0;break;case"each":e.each=!0;break;case"bind":e.bind=o;break;case"transient":e.transient=!0;break;case"state":e.decls=it(o);break;case"text":(e.paints||(e.paints=[])).push({kind:"text",fmt:null,entry:M(o)});break;case"show":(e.paints||(e.paints=[])).push({kind:"show",entry:M(o)});break;case"effect":(e.effects||(e.effects=[])).push({entry:M(o,!0)});break;case"invalid":(e.invalids||(e.invalids=[])).push({entry:M(o)});break}continue}let i=n.slice(0,s),f=n.slice(s+1);switch(i){case"calc":(e.calcs||(e.calcs=[])).push({name:f,entry:M(o)});break;case"text":(e.paints||(e.paints=[])).push({kind:"text",fmt:f,entry:M(o)});break;case"attr":(e.paints||(e.paints=[])).push({kind:"attr",arg:f,entry:M(o)});break;case"class":(e.paints||(e.paints=[])).push({kind:"class",arg:f,entry:M(o)});break;case"css":(e.paints||(e.paints=[])).push({kind:"css",arg:f,entry:M(o)});break;case"show-when":case"option":(e.paints||(e.paints=[])).push({kind:"when",match:"show",field:f,values:o.split("|")});break;case"hide-when":(e.paints||(e.paints=[])).push({kind:"when",match:"hide",field:f,values:o.split("|")});break;case"option-not":(e.paints||(e.paints=[])).push({kind:"when",match:"show-not",field:f,values:o.split("|")});break}}return e.boundary=e.scope?"scope":e.items?"items":e.detail?"detail":e.each?"each":null,An(e)?wn():e}var ct=null;function wn(){return(!ct||ct.gen!==J)&&(ct=Object.freeze({gen:J,inert:!1,template:!1,cms:!1,item:!1,scope:!1,items:!1,detail:!1,each:!1,boundary:null,bind:null,transient:!1,decls:null,calcs:null,paints:null,effects:null,invalids:null})),ct}function An(t){return!t.inert&&!t.item&&t.boundary===null&&t.bind===null&&!t.transient&&!t.decls&&!t.calcs&&!t.paints&&!t.effects&&!t.invalids}var F=new WeakMap,j=new WeakMap,q=null,D=!1;function me(){F=new WeakMap,j=new WeakMap}function pe(t){for(let e of t){let r=e.target.nodeType===1?e.target:e.target.parentElement;for(let n=r;n;n=n.parentElement)j.delete(n);if(e.type==="attributes"){F.delete(e.target);continue}for(let n=r;n;n=n.parentElement)F.delete(n);for(let n of e.addedNodes||[])if(n.nodeType===1){F.delete(n),j.delete(n);for(let o of n.querySelectorAll("*"))F.delete(o),j.delete(o)}}}function he(){return D}function be(t){return D?j.get(t):void 0}function ge(t,e){D&&j.set(t,e)}function ye(t){j.delete(t)}function we(t){let e=D;return!q&&typeof MutationObserver=="function"&&(q=new MutationObserver(pe),q.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})),q&&pe(q.takeRecords()),D=!!q&&t.getRootNode()===document,e}function Ae(t){D=t}function Ee(t){let e=F.get(t);return e||F.set(t,e={attrs:new Map,hasText:!1,text:""}),e}function xe(t,e){if(!D)return t.getAttribute(e);let r=Ee(t);return r.attrs.has(e)||r.attrs.set(e,t.getAttribute(e)),r.attrs.get(e)}function ve(t){if(!D)return t.textContent;let e=Ee(t);return e.hasText||(e.text=t.textContent,e.hasText=!0),e.text}function Se(t){return(t.getAttribute("type")||"text").toLowerCase()}function V(t){let e=t.tagName;if(e==="INPUT"){let r=Se(t);r==="checkbox"||r==="radio"?t.checked?t.setAttribute("checked",""):t.removeAttribute("checked"):t.setAttribute("value",t.value);return}if(e==="TEXTAREA"){t.setAttribute("data-value",t.value);return}if(e==="SELECT"){let r=t.options;for(let n=0;n<r.length;n++)r[n].selected?r[n].setAttribute("selected",""):r[n].removeAttribute("selected")}}function ke(t,e=t){let r=t.tagName;if(r==="INPUT"){let n=Se(t);n==="checkbox"||n==="radio"?e.checked?t.hasAttribute("checked")||t.setAttribute("checked",""):t.removeAttribute("checked"):e.value!==(t.getAttribute("value")??"")&&t.setAttribute("value",e.value);return}if(r==="TEXTAREA"){let n=e.value.startsWith(`
|
|
7
7
|
`)?`
|
|
8
|
-
`+e.value:e.value;t.textContent!==n&&(t.textContent=n),t.removeAttribute("data-value");return}if(r==="SELECT"){let n=t.options,o=e.options;for(let a=0;a<n.length;a++)o[a]&&o[a].selected?n[a].hasAttribute("selected")||n[a].setAttribute("selected",""):n[a].removeAttribute("selected")}}function it(t){t.tagName!=="TEXTAREA"||!t.hasAttribute("data-value")||t!==t.ownerDocument.activeElement&&(t.textContent=t.getAttribute("data-value"),t.removeAttribute("data-value"))}function E(t){if(typeof window>"u")return null;let e=window.clay,r=window.hyperclay;return t==="consent"?e?.confirm||r?.consent||null:e?.[t]||r?.[t]||null}function pe(){let t=E("visitorDrafts");return!!(t&&typeof t.restored=="function"&&t.restored()?.restored)}var wt=["clay:mutation-ready","hyperclay:mutation-ready"],un=["clay:sync-applied","hyperclay:livesync-applied"],cn=["clay:ready","hyperclay:ready"],ln=["clay:route"],fn=["clay:modechange"];function Y(t,e,r){let n=null,o=a=>{n!==null&&n!==a.type||(n=a.type,queueMicrotask(()=>{n=null}),r(a))};for(let a of e)t.addEventListener(a,o);return()=>{for(let a of e)t.removeEventListener(a,o)}}function me(t){let e=typeof window<"u"&&window.clay&&window.clay.ready;e&&typeof e.then=="function"?e.then(()=>t(),()=>t()):t()}function st(t){let e=E("region");return!e||typeof e.resolveRegionPolicy!="function"||typeof e.skipForPolicy!="function"?!1:e.skipForPolicy(e.resolveRegionPolicy(t),void 0,["no-save","freeze"])}function he(){return typeof window>"u"?null:window.clay?.modeLifecycle||null}function at(t,{transient:e=!1}={}){if(e)return!0;let r=he();return typeof r?.canWrite!="function"||E("region")?.resolveRegionPolicy?.(t)?.persist==="none"?!0:r.canWrite()}function be(t,e){if(typeof e!="function")throw new Error("Sap.batch(label, fn): fn must be a function");let r=E("undo");r&&r.flush&&r.flush();let n=e();if(n&&typeof n.then=="function")throw new Error("Sap.batch fn must be synchronous (it returned a promise)");return r&&r.commitCaptured&&r.commitCaptured(t),n}function ge(t){if(typeof window>"u"||typeof document>"u")return;let e=()=>{let b=!1;for(let A of t.apps())A.root.isConnected?t.runNow(A,"platform"):b=!0;b&&t.pruneDisconnected(),t.remountIfPresent()},r=E("derived"),n=r&&typeof r.register=="function"?r.register(e):null,o=typeof n=="function"?null:Y(document,un,e),a=Y(document,ln,e),i=null,f=!1,l=()=>{let b=i;i=null,b&&(b[2](),b[3]())},c=()=>{if(f)return!1;let b=E("undo"),A=he()?.state?.generation;if(i&&i[0]===b&&i[1]===A)return!0;if(l(),!b||typeof b.on!="function")return!1;let v=b.on("undo",e);if(typeof v!="function")return!1;let S=b.on("redo",e);return typeof S!="function"?(v(),!1):(i=[b,A,v,S],!0)};c();let u=[wt,cn,fn].map(b=>Y(document,b,c)),d=E("ready");return d&&typeof d.then=="function"&&d.then(c,()=>{}),()=>{f=!0,typeof n=="function"&&n(),o&&o(),a();for(let b of u)b();l()}}function At(t){let e=t.tagName;if(e==="INPUT"){let r=(t.getAttribute("type")||"text").toLowerCase();return r==="checkbox"?"checkbox":r==="radio"?"radio":r==="number"||r==="range"?"number":r==="hidden"?"hidden":"text"}return e==="TEXTAREA"?"text":e==="SELECT"?t.multiple?"select-multiple":"select-one":"leaf"}function dn(t){if(t.validity&&t.validity.badInput)return t.hasAttribute("value")?Number(t.getAttribute("value"))||0:t._sapLastGood??0;if(t.value==="")return 0;let e=Number(t.value);return Number.isNaN(e)?t._sapLastGood??0:(t._sapLastGood=e,e)}function we(t,e){switch(e){case"checkbox":return t.checked;case"radio":return t.checked?t.value:void 0;case"number":return dn(t);case"select-one":return t.value;case"select-multiple":return[...t.selectedOptions].map(r=>r.value);case"hidden":case"text":return t.value;case"leaf":return t.textContent;default:return t.value}}function pn(t,e,r){switch(e){case"checkbox":t.checked=!!r;break;case"radio":t.checked=String(t.value)===String(r);break;case"number":case"text":case"hidden":t.value=r==null?"":String(r);break;case"select-one":t.value=r==null?"":String(r);break;case"select-multiple":{let n=new Set((Array.isArray(r)?r:[r]).map(String));for(let o of t.options)o.selected=n.has(o.value);break}case"leaf":t.textContent=r==null?"":String(r);break;default:t.value=r==null?"":String(r)}}function ye(t){if(t.hasAttribute("transient")){t.removeAttribute("value"),t.removeAttribute("checked"),t.removeAttribute("data-value");return}st(t)||B(t)}function mn(t){t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))}function Ae(t,e){return we(t,e)}function Ee(t){let e=At(t);return{el:t,kind:e,read(){return we(t,e)},write(r,n={}){pn(t,e,r),n.noMirror||ye(t),n.silent||mn(t)},mirror(){ye(t)}}}var C=null,ct=!1,W=null;function xe(t){let e=null;return{kind:"hub",subscribe(r){let n=t.onAnyChange({debounce:0,require:"observed"},r);typeof n=="function"&&(e=n)},suppress(r){t.pause();try{return r()}finally{t.resume()}},teardown(){if(e){try{e()}catch{}e=null}}}}function hn(){let t=null;return{kind:"native",subscribe(e){t=new MutationObserver(n=>e(bn(n)));let r=typeof document<"u"&&document.body||typeof document<"u"&&document.documentElement;r&&t.observe(r,{childList:!0,subtree:!0,attributes:!0,characterData:!0})},suppress(e){let r=E("undo");r&&r.pause&&r.pause();try{return e()}finally{t&&t.takeRecords(),r&&r.resume&&r.resume()}},teardown(){t&&(t.disconnect(),t=null)}}}function bn(t){let e=[];for(let r of t)if(r.type==="attributes"){let n=r.target;n&&n.nodeType===1&&!ut(n)&&e.push({type:"attribute",element:n})}else if(r.type==="characterData"){let n=r.target&&r.target.parentElement;n&&!ut(n)&&e.push({type:"characterData",element:n})}else if(r.type==="childList"){for(let n of r.addedNodes)if(!(n.nodeType!==1||ut(n))&&(e.push({type:"add",element:n}),n.querySelectorAll))for(let o of n.querySelectorAll("*"))ut(o)||e.push({type:"add",element:o});for(let n of r.removedNodes)n.nodeType===1&&e.push({type:"remove",element:n,parent:r.target})}return e}function ut(t){return!!(t.closest&&t.closest("[sap-ignore],[template],[cms-template]"))}function gn(t,e){t.pruneDisconnected();let r=new Set,n=!1;for(let o of e){let a=o.type==="remove"?o.parent:o.element,i=a&&t.appFor(a);i&&r.add(i),o.type==="add"&&o.element&&o.element.nodeType===1&&o.element.hasAttribute&&o.element.hasAttribute("sap")&&!(t.isRegistered&&t.isRegistered(o.element))&&(n=!0)}n&&t.remountIfPresent();for(let o of r)o.root.isConnected&&t.schedule(o,"mutation")}function ve(t){if(C)return C.suppress(t);let e=E("undo");if(e&&e.pause&&e.resume){e.pause();try{return t()}finally{e.resume()}}return t()}function Et(t,e){ct=!0,C=t,t.subscribe(r=>gn(e,r))}function xt(t){if(ct||typeof window>"u"||typeof document>"u")return;let e=E("Mutation");if(e&&typeof e.onAnyChange=="function"){Et(xe(e),t);return}typeof MutationObserver=="function"&&(Et(hn(),t),W=Y(document,wt,function(){let n=E("Mutation");n&&(W(),W=null,C&&C.teardown(),ct=!1,Et(xe(n),t))}))}function vt(){if(C)try{C.teardown()}catch{}W&&typeof document<"u"&&W(),C=null,ct=!1,W=null}var yn=new Set(O),$=[],ke={},Te={};function Ne(t){$.includes(t)||($.push(t),t.boundary&&Object.assign(ke,t.boundary),t.paintKinds&&Object.assign(Te,t.paintKinds))}function lt(t,e={}){if(e.breaker){t.diag.error("E26",t.root,{problem:"recompute loop halted after 50 passes; recent triggers: "+(t._breakerRing||[]).join(", ")}),P(t.root,"loop");return}e.full&&(Zt(),ie());let r=te(t.root);try{ve(()=>wn(t,e))}finally{ee(r)}t._viewsChanged&&(t._viewsChanged=!1,t.root.dispatchEvent(new CustomEvent("sap:views-updated",{bubbles:!0})))}function wn(t,e){let r=t.root,n={},o=[],a=[],i=new Set;t.diag.errors=[];let f={root:n,state:n,item:null,ownerEl:r,projection:!1};function l(s,p,m=!1){let h=p.attr||p.name,y=m?ce(s,h):s.getAttribute(h);return y==null&&(y=gt(p),a.push({el:s,name:p.name,attr:h,value:Bt(Z(y,p.type),p.type)})),Z(y,p.type)}function c(s,p,m,h){let y=p.decls;if(!y)return;let R=!!h.item&&!h.projection&&!h.view;for(let x of y){if(x.transient){m[x.name]=Ft(s,x);continue}if(Wt(s,x)){m[x.name]=s.hasAttribute(x.attr);continue}m[x.name]=l(s,x,R)}}function u(s,p,m){let h=p.bind,y=m.item||m.state,R=At(s);R==="radio"?(h in y||(y[h]=""),s.checked&&(y[h]=s.value)):R==="leaf"&&m.item&&!m.projection&&!m.view?y[h]=le(s):y[h]=Ae(s,R),p.transient&&(s.removeAttribute("value"),s.removeAttribute("checked"))}function d(s,p,m){if(p.paints)for(let h of p.paints)h.kind==="when"&&i.add(h.field),o.push({def:h,el:s,ctx:m});for(let h of $)h.collect&&h.collect(k,s,p,m)}function b(s,p,m){Object.defineProperty(s,"$key",{value:Ot(p,"row"),enumerable:!1}),Object.defineProperty(s,"$index",{value:m,enumerable:!1}),Object.defineProperty(s,"$el",{value:p,enumerable:!1})}function A(s,p,m){let h=ot(s);c(s,h,p,m),s._sapScope=p,!m.projection&&h.bind!=null&&u(s,h,m),d(s,h,m),h.items?H(s,p,m):v(s,p,m)}function v(s,p,m){for(let h=s.firstElementChild;h;h=h.nextElementSibling)S(h,p,m)}function S(s,p,m){let h=ot(s);if(!h.inert){if(h.boundary){h.boundary==="scope"?N(s,p,m):h.boundary==="items"?(d(s,h,m),H(s,p,m)):ke[h.boundary](k,s,h,p,m);return}!m.projection&&!m.view&&h.bind!=null&&u(s,h,m),d(s,h,m);for(let y=s.firstElementChild;y;y=y.nextElementSibling)S(y,p,m)}}function N(s,p,m){let h=s.getAttribute("scope"),y={};p[h]=y;let R={root:m.root,state:y,item:null,ownerEl:s,projection:m.projection};A(s,y,R)}function H(s,p,m){let h=s.getAttribute("items"),y=[];p[h]=y,s._sapList=y;let R=0;for(let x=s.firstElementChild;x;x=x.nextElementSibling){let _t=ot(x);if(!_t.item||_t.template||x.hasAttribute("cms-template"))continue;let K={};b(K,x,R);let ze={root:m.root,state:m.state,item:K,ownerEl:x,projection:m.projection};A(x,K,ze),y.push(K),R++}}let k={app:t,root:r,rootObj:n,paints:o,stats:{calcs:0,lists:0},resolveDefault:l,collectEl:d,walkScope:v};for(let s of $)s.begin&&s.begin(k);let j=e.cacheReads===!1?null:se(r);try{A(r,n,f)}finally{e.cacheReads!==!1&&ae(j)}if(t.halted)return;for(let s of $)s.afterIntake&&s.afterIntake(k);if(a.length&&i.size)for(let s of a)i.has(s.attr)&&s.el.getAttribute(s.attr)==null&&s.el.setAttribute(s.attr,s.value);for(let s of $)s.compute&&s.compute(k);let z=0;for(let s of $)s.reconcile&&(z+=s.reconcile(k));let w=0,g=z;for(let s of o){let p=En(s,t);s.ctx.view?g+=p:w+=p}for(let s of $)s.afterPaint&&s.afterPaint(k);t._state=n,t._stats={fields:Object.keys(n).filter(s=>typeof n[s]!="function").length,calcs:k.stats.calcs,paints:o.length,lists:k.stats.lists,writes:w,viewWrites:g},t._viewsChanged=g>0,t._lastPass={trigger:e.trigger||"refresh",writes:w},t._debug&&console.log(`sap pass \xB7 trigger: ${t._lastPass.trigger} \xB7 writes ${w}/${o.length}`)}function An(t){return t.kind==="text"?t.fmt?"text:"+t.fmt:"text":t.kind==="attr"?"attr:"+t.arg:t.kind==="class"?"class:"+t.arg:t.kind==="css"?"css:"+t.arg:t.kind==="when"?(t.match==="hide"?"hide-when:":t.match==="show-not"?"option-not:":"show-when:")+t.field:t.kind}function St(t,e,r,n){let o=t;for(;o&&o.nodeType===1;){if(o.hasAttribute&&o.hasAttribute(e)){let a=r.includes(o.getAttribute(e));if(n?!a:a)return!0}o=o.parentElement}return!1}function En(t,e){let r=t.def,n=t.el,o=Te[r.kind];if(o)return o(t,e);if(r.kind==="when")return Se(r,n,null);try{let a=Kt(r.entry,t.ctx.state,t.ctx.item,n,t.ctx.root),i=Se(r,n,a);return Pt(n),i}catch(a){return e.diag.error(a.sapCode==="E22"?"E22":"E24",n,{attr:An(r),expr:r.entry&&r.entry.src,problem:String(a.message)}),P(n,a.sapCode||"E24"),0}}function Se(t,e,r){switch(t.kind){case"text":{let n=t.fmt!=null?Yt(t.fmt,r):r==null?"":String(r);return e.textContent!==n?(e.textContent=n,1):0}case"show":{let n=!r;return e.hidden!==n?(e.hidden=n,1):0}case"when":{let n=E("optionVisibility");if(n&&n._started)return e._sapWhen&&e.hidden?(e.hidden=!1,e._sapWhen=!1,1):0;let o;t.match==="hide"?o=!St(e,t.field,t.values,!1):t.match==="show-not"?o=St(e,t.field,t.values,!0):o=St(e,t.field,t.values,!1),e._sapWhen=!0;let a=!o;return e.hidden!==a?(e.hidden=a,1):0}case"attr":{let n=t.arg;if((n==="checked"||n==="selected")&&typeof e[n]=="boolean"&&!e.hasAttribute("bind")&&!e.closest("select[bind]")){let a=0;return e[n]!==!!r&&(e[n]=!!r,a=1),!!r!==e.hasAttribute(n)&&(r?e.setAttribute(n,""):e.removeAttribute(n),a=1),a}if(yn.has(n)){let a=e.hasAttribute(n);return r&&!a?(e.setAttribute(n,""),1):!r&&a?(e.removeAttribute(n),1):0}let o=typeof r=="boolean"?String(r):r==null?"":String(r);return e.getAttribute(n)!==o?(e.setAttribute(n,o),1):0}case"class":{let n=!!r;return e.classList.contains(t.arg)!==n?(e.classList.toggle(t.arg,n),1):0}case"css":{let n=r==null?"":String(r);return e.style.getPropertyValue("--"+t.arg)!==n?(e.style.setProperty("--"+t.arg,n),1):0}default:return 0}}var xn=new Set(O),Re=new Set(["calc","text","attr","class","css","set","move","sort","option","option-not","show-when","hide-when","editmode","viewmode"]),vn=new Set(["show-when","hide-when","option","option-not"]),Sn=/\b(?:state|item|root)\.|===|!==|&&|\|\||[()]|^\s*!/,Le=new Set(["sap","scope","items","item","template","bind","show","effect","invalid","detail","state","transient","confirm","default","persist","sortable","trigger-add","trigger-remove","trigger-reset","sap-ignore","sap-error","no-save","no-watch","no-undo","no-trigger-autosave","freeze","mutations-ignore","save-remove","save-ignore","save-freeze"]),Tt=[];function _e(t){Tt.includes(t)||Tt.push(t)}function kn(t){return t.tagName==="INPUT"||t.tagName==="SELECT"||t.tagName==="TEXTAREA"}function kt(t){return t.hasAttribute("bind")}function Tn(t,e){e(t);for(let n=t.firstElementChild;n;n=n.nextElementSibling)r(n);function r(n){if(!n.hasAttribute("sap-ignore")){if(n.tagName==="TEMPLATE"){if(n.hasAttribute("items"))for(let o=n.content.firstElementChild;o;o=o.nextElementSibling)r(o);return}e(n);for(let o=n.firstElementChild;o;o=o.nextElementSibling)r(o)}}}function Ce(t,e){let r=!1,n=(i,f,l)=>{e.error(i,f,l),r=!0},o=t.ownerDocument.createTreeWalker(t,4),a;for(;a=o.nextNode();)if(/\{\{.*\}\}/.test(a.nodeValue||"")){n("E02",a.parentElement||t,{problem:"moustaches in text content are not a Sap feature",fix:'move the expression onto the element: text="state.x"'});break}return Tn(t,i=>{let f=new Set;for(let c of Tt)c(i,n,u=>f.add(u));let l=i.closest&&i.closest("[detail]");for(let c of[...i.attributes]){let u=c.name;if(f.has(u))continue;if(u.includes(":")){let b=u.slice(0,u.indexOf(":"));if(Re.has(b)){if(vn.has(b)&&Sn.test(c.value)){let A=u.slice(u.indexOf(":")+1);e.warn("W04",i,{attr:u,expr:c.value,problem:`${b}: compares the "${A}" attribute against a literal value, not a JS expression`,fix:`use show="${c.value}" for an expression, or a literal like ${b}:${A}="overview"`})}}else{let A=mt(b,[...Re]);e.warn("W03",i,{attr:u,problem:`unknown "${b}:" attribute`,didYouMean:A?`${A}:`:null})}}else if(!Le.has(u)&&!pt.has(u)&&!xn.has(u)&&!/^(data-|aria-|on)/.test(u)&&!(u in i)){let b=mt(u,[...Le]);b&&e.warn("W03",i,{attr:u,problem:`unknown "${u}" attribute`,didYouMean:b})}u==="attr:hidden"&&e.warn("W03",i,{attr:u,problem:"attr:hidden paints the wrong attribute",fix:'use show="expr"'});let d=kt(i)||u==="attr:selected"&&i.tagName==="OPTION"&&!!i.closest("select[bind]");(u==="attr:value"||u==="attr:checked"||u==="attr:selected")&&d&&n("E30",i,{attr:u,problem:"attr: on a bound control collides with persist ownership",fix:"remove it; bind owns this attribute"}),u==="effect"&&kt(i)&&/\b(value|checked)\s*=[^=]/.test(c.value)&&n("E30",i,{attr:u,expr:c.value,problem:"effect writes value/checked on a bound control (writes a stale value with no synthetic event)",fix:"write through onclick + Sap(this) instead"}),(u==="text"||u.startsWith("text:")||u==="show")&&kn(i)&&(u==="show"||n("E18",i,{attr:u,problem:"paint belongs on output elements, not form controls",fix:"move the paint to an <output> or <span>"}))}if(i.hasAttribute("state")){let c=Q(i.getAttribute("state")),u=new Set;for(let d of c){d.name.includes("-")&&n("E08",i,{attr:"state",problem:`field "${d.name}" is not a valid identifier (the hyphen parses as subtraction)`,fix:`rename to ${d.name.replace(/-/g,"")}`}),u.has(d.name)&&n("E04",i,{attr:"state",problem:`field "${d.name}" is declared twice in one scope`}),u.add(d.name),$t.has(d.attr)&&n("E05",i,{attr:"state",problem:`"${d.name}" is a reserved Sap word`}),pt.has(d.attr)&&n("E06",i,{attr:"state",problem:`"${d.name}" is a global HTML attribute name; pick another field name`}),d.name==="open"&&i.tagName==="DIALOG"&&n("E33",i,{attr:"state",problem:"dialog open is transient",fix:"use showModal() \u2014 declare state= only on <details> or popovers"});let b=bt(i,d.attr);b&&(d.attr==="checked"||d.attr==="selected")&&n("E35",i,{attr:"state",problem:`"${d.attr}" on a form control is the control's own state, not a declared field`,fix:'bind the control instead, e.g. <input type="checkbox" bind="done">'}),b&&d.type==="num"&&n("E35",i,{attr:"state",problem:`"${d.attr}" is an HTML boolean attribute; it cannot hold a number`,fix:`declare it bare: state="${d.attr}"`}),d.transient&&(b||d.type==="presence")&&n("E35",i,{attr:"state",problem:`"${d.name}" is carried by attribute presence, which transient would strip`,fix:"declare a separate name:bool:transient field and paint the attribute from it"})}}if(kt(i)){if(i.hasAttribute("-"),i.tagName==="INPUT"){let c=(i.getAttribute("type")||"text").toLowerCase();c==="file"&&n("E32",i,{attr:"bind",problem:"files never serialize into an HTML file",fix:"use no-save + effect instead of bind"}),c==="password"&&!i.hasAttribute("transient")&&n("E31",i,{attr:"bind",problem:"a password must never serialize into a world-readable file",fix:"add transient to the password input"})}else if(i.tagName!=="SELECT"&&i.tagName!=="TEXTAREA"){let c=i.getAttribute("contenteditable");!(c!=null&&c!=="false")&&i.children.length>0&&n("E20",i,{attr:"bind",problem:"bind on a container element is not a control; a write would overwrite its children",fix:"bind a control (input/select/textarea), a contenteditable, or an empty text leaf"})}}if(i.hasAttribute("transient")&&i.hasAttribute("persist")&&n("E34",i,{problem:"transient and persist are opposite: persist forces the live value into the saved bytes, leaking exactly what transient drops",fix:"remove one \u2014 transient to keep it out of the file, or persist to save it"}),i.tagName==="DIALOG"&&i.hasAttribute("detail")&&!(i.parentElement&&i.parentElement.closest('[clay~="freeze"], [freeze], [save-freeze]'))&&e.warn("W31",i,{attr:"detail",problem:"a detail dialog writes open when it opens, and that attribute would be saved into the file",fix:'wrap the dialog in an element with clay="freeze" (not editor-ui, which removes it from the file), and make its key field transient'}),i.hasAttribute("item")&&!i.hasAttribute("template")&&i.parentNode&&i.parentNode.nodeType===1){let c=i.parentElement;(!c||!c.hasAttribute("items"))&&n("E10",i,{problem:"an [item] must be a direct child of an [items] list",fix:'wrap it in a container with items="name"'})}if(i.hasAttribute("items")&&l&&n("E17",i,{attr:"items",problem:"nested items inside a detail panel is a v1 mount error (nested collections ship in v1.1)"}),i.hasAttribute("items")){let c=t.querySelector(`[trigger-add="${i.getAttribute("items")}"]`);!It(i)&&!ht(t,i.getAttribute("items"))&&Dt(i).length===0&&c&&n("E17",i,{attr:"items",problem:`trigger-add targets items="${i.getAttribute("items")}" but it has no [item template] to clone`})}}),r&&(e.halted=!0,e.haltReason=e.errors[0]?e.errors[0].code:"halt",P(t,e.haltReason)),!r}var $e="sap-styles",Pe="[item][template]{display:none!important}[hidden]{display:none!important}[sap-error]{outline:2px solid #e5484d;outline-offset:1px}",Nt=new WeakSet;function Nn(t){if(Nt.has(t))return;let e=t.defaultView,r=e&&e.CSSStyleSheet;if(r&&"adoptedStyleSheets"in t)try{let n=new r;n.replaceSync(Pe),t.adoptedStyleSheets=[...t.adoptedStyleSheets,n],Nt.add(t);return}catch{}if(!t.getElementById($e)){let n=t.createElement("style");n.id=$e,n.textContent=Pe,(t.head||t.documentElement).appendChild(n)}Nt.add(t)}var Rn=0;function Me(){return typeof performance<"u"&&performance.now?performance.now():0}function Rt(t){let e=t.id||t.getAttribute("sap")||`app-${Rn++}`,r=new J(e),n={root:t,name:e,diag:r,_state:null,_stats:null,_lastPass:null,_passes:0,_broken:!1,_mountMs:0,_mountWrites:0};if(!Ce(t,r))return n.halted=!0,n;Nn(t.ownerDocument);for(let i of t.querySelectorAll("textarea[data-value]"))it(i);let a=Me();return lt(n,{trigger:"mount",full:!0}),n._mountMs=Me()-a,n._mountWrites=n._stats?n._stats.writes:0,n._mountWrites>0&&!pe()&&!E("derived")&&r.warn("W30",t,{problem:`${n._mountWrites} paint(s) ran at mount; the saved file was out of sync with its declared state`,fix:"re-save once so the file mounts clean (a settled file writes nothing)"}),n}var Oe=/^(set:|move:|sort:|trigger-add$|trigger-remove$|trigger-reset$)/;function Ln(t){return`${t.tagName.toLowerCase()}[sap]`}function _n(t){let e=0;for(let r of t.querySelectorAll("*"))for(let n of r.attributes)if(Oe.test(n.name)){e++;break}for(let r of t.attributes)if(Oe.test(r.name)){e++;break}return e}function De(t){function e(f){let l=f._stats||{},c=f.root;return{root:Ln(c),fields:l.fields||0,calcs:l.calcs||0,paints:l.paints||0,actions:_n(c),lists:(c.hasAttribute("items")?1:0)+c.querySelectorAll("[items]").length,rows:c.querySelectorAll("[item]:not([template])").length,warnings:f.diag.warnings.length,errors:f.diag.errors.length,mountWrites:f._mountWrites||0,ms:Math.round((f._mountMs||0)*10)/10,passes:f._passes||0,lastPass:f._lastPass||null,ok:f.diag.errors.length===0&&!f.halted}}function r(){let f=t.apps().map(e);return{ok:f.every(l=>l.ok),apps:f}}function n(f){let l=e(f);return l.ok?`sap \u2713 ${l.root} \xB7 fields ${l.fields} \xB7 calcs ${l.calcs} \xB7 paints ${l.paints} \xB7 actions ${l.actions} \xB7 lists ${l.lists} \xB7 rows ${l.rows} \xB7 warnings ${l.warnings} \xB7 mount writes ${l.mountWrites} \xB7 ${l.ms}ms`:`sap \u2717 ${l.root} \xB7 errors ${l.errors} \xB7 warnings ${l.warnings} \xB7 ${l.ms}ms`}function o(){for(let f of t.apps()){let l=n(f);f.diag.errors.length||f.halted?console.error(l):console.log(l)}}function a(){let f=[],l=[];for(let c of t.apps())f.push(...c.diag.errors),l.push(...c.diag.warnings);return{ok:f.length===0,errors:f,warnings:l,counts:{errors:f.length,warnings:l.length}}}function i(f){let l=f===void 0?!0:!!f;for(let c of t.apps())c._debug=l;return console.log(`sap debug ${l?"on":"off"} \u2014 per-pass headers will ${l?"":"no longer "}log`),l}return{status:r,report:a,debug:i,greenLine:n,printGreenLines:o,REGISTRY:dt}}var Ie="0.6.0";function Be({createAccessor:t,installInput:e,debugExtras:r}){let n=new Map,o=[],a=Ct(lt);function i(g){let s=g;for(;s;){if(s.nodeType===1&&s.hasAttribute&&s.hasAttribute("sap"))return n.get(s)||null;s=s.parentNode&&s.parentNode.host?s.parentNode.host:s.parentElement}return null}function f(){for(let g=o.length-1;g>=0;g--){let s=o[g];s.root.isConnected||(n.delete(s.root),o.splice(g,1))}}function l(g,s){if(g.moveBefore)try{g.moveBefore(s,null);return}catch{}g.appendChild(s)}function c(g,s){let p=s.parentElement;if(p){if(p.moveBefore)try{p.moveBefore(g,s);return}catch{}p.insertBefore(g,s)}}let u={apps:()=>o.slice(),appFor:i,isRegistered:g=>n.has(g),pruneDisconnected:f,schedule:(g,s)=>a.schedule(g,s),runNow:(g,s)=>a.runNow(g,s),moveInto:l,placeBefore:c,remountIfPresent:()=>j()},d=t(u),b=De(u),A=r?r(u,b):{},v=!1,S=!1,N=null;function H(){v||(v=!0,e(u,d,document),N=ge(u))}function k(){let g=E("derived");g&&typeof g.mounted=="function"&&g.mounted()}function j(g=document){if(S)return[];H(),xt(u);let s=g.querySelectorAll("[sap]"),p=[];for(let m of s){if(n.has(m))continue;let h=Rt(m);n.set(m,h),o.push(h),p.push(h)}for(let m of p){let h=b.greenLine(m);m.diag.errors.length||m.halted?console.error(h):console.log(h)}return k(),p}function z(g){if(S)return null;if(H(),xt(u),!g)return j();let s=typeof g=="string"?document.querySelector(g):g;if(!s)return null;if(n.has(s))return n.get(s);let p=Rt(s);n.set(s,p),o.push(p);let m=b.greenLine(p);return p.diag.errors.length||p.halted?console.error(m):console.log(m),p}let w=d.Sap;return w.version=Ie,w.refresh=function(){for(let s of o)s.root.isConnected&&a.runNow(s,"refresh")},w.batch=be,w.status=b.status,w.report=b.report,w.why=A.why,w.debug=b.debug,w.doctor=A.doctor,w.greenLine=b.greenLine,w.formats=D,w.serializeControlToAttributes=B,w.finalizeControlForSave=de,w.rehydrateControlFromAttributes=it,w.mount=z,w.config=function(s={}){return s.formats&&Object.assign(D,s.formats),w},w._registry=n,w._reset=function(){n.clear(),o.length=0,vt()},w.unmount=function(){S=!0,n.clear(),o.length=0,vt(),typeof N=="function"&&N()},{Sap:w,mountAll:j,mount:z,runtime:u}}function We(t){if(typeof document>"u")return;let e=()=>me(()=>t());document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):e()}function Fe(t){let e=[];function r(l){let c=l.target;if(!c||c.nodeType!==1)return;let u=t.appFor(c);if(u){c.hasAttribute("persist")&&!st(c)&&at(c)&&B(c);for(let d of e)if(d(c,u))return;t.schedule(u,l.type+" "+(c.id||c.tagName.toLowerCase()))}}function n(l){let c=l.target,u=t.appFor(c);u&&[...c.querySelectorAll("[bind]")].every(d=>at(d))&&setTimeout(()=>{c.querySelectorAll("[bind]").forEach(d=>{d.dispatchEvent(new Event("input",{bubbles:!0})),d.dispatchEvent(new Event("change",{bubbles:!0}))}),t.schedule(u,"reset")},0)}function o(l){let c=t.appFor(l.target);c&&t.schedule(c,"toggle")}function a(l){let c=l.detail||{};for(let u of[c.from,c.to,l.target]){if(!u||u.nodeType!==1)continue;let d=t.appFor(u);d&&t.schedule(d,"sorted")}}function i(l){if(l.key!=="ArrowUp"&&l.key!=="ArrowDown")return;let c=l.target;if(!c||c.nodeType!==1||c.tagName!=="INPUT"||!c.hasAttribute("bind")||!c.hasAttribute("step"))return;let u=(c.getAttribute("type")||"text").toLowerCase();if(u!=="text"&&u!=="tel"&&u!=="search"||!t.appFor(c)||!at(c))return;l.preventDefault();let b=T(c.getAttribute("step"))||1,A=l.key==="ArrowUp"?1:-1,v=T(c.value)+b*(l.shiftKey?10:1)*A,S=c.getAttribute("min"),N=c.getAttribute("max");S!==null&&S!==""&&v<T(S)&&(v=T(S)),N!==null&&N!==""&&v>T(N)&&(v=T(N)),Ee(c).write(String(Number(v.toFixed(2))))}function f(l=document){l.addEventListener("reset",n),l.addEventListener("toggle",o,!0),l.addEventListener("input",r),l.addEventListener("change",r),l.addEventListener("clay:sorted",a),l.addEventListener("keydown",i)}return{install:f,addRouter:l=>e.push(l)}}var G="https://clayjs.com/v1/sap.js",Cn=/^(calc|set|move|sort):/,$n=new Set(["each","detail","effect","invalid","confirm","trigger-add","trigger-remove","trigger-reset"]);function Lt(t){return Cn.test(t)||$n.has(t)}_e((t,e)=>{for(let r of t.attributes)Lt(r.name)&&e("E50",t,{attr:r.name,expr:r.value,problem:`${r.name} is full sapjs; the sapjs core only paints declared state`,fix:`load ${G}; the markup stays as it is`})});function F(t,e,r){t.app.diag.error("E50",e,{attr:r,problem:`${r} is full sapjs; the sapjs core only paints declared state`,fix:`load ${G}; the markup stays as it is`}),P(e,"E50"),t.app.halted=!0}Ne({name:"core-only",collect(t,e,r){r.calcs&&F(t,e,"calc:"+r.calcs[0].name),r.effects&&F(t,e,"effect"),r.invalids&&F(t,e,"invalid");for(let n of e.attributes)Lt(n.name)&&(n.name.startsWith("calc:")&&r.calcs||n.name==="effect"&&r.effects||n.name==="invalid"&&r.invalids||F(t,e,n.name))},boundary:{each(t,e){F(t,e,"each")},detail(t,e){F(t,e,"detail")}}});function Pn(){return{Sap:function(){throw new Error(`Sap(el) is full sapjs; load ${G}`)}}}var He=t=>()=>(console.warn(`Sap.${t} is full sapjs; load ${G}`),null),{Sap:X,mountAll:je,mount:Mn,runtime:On}=Be({createAccessor:Pn,debugExtras:()=>({why:He("why"),doctor:He("doctor")}),installInput(t,e,r){Fe(t).install(r)}});X.core=!0;var Dn=typeof window<"u"&&window.Sap&&!window.Sap.core;Dn?X.unmount():We(je);typeof window<"u"&&!window.Sap&&(window.Sap=X);var In=X;return Xe(Bn);})();
|
|
8
|
+
`+e.value:e.value;t.textContent!==n&&(t.textContent=n),t.removeAttribute("data-value");return}if(r==="SELECT"){let n=t.options,o=e.options;for(let s=0;s<n.length;s++)o[s]&&o[s].selected?n[s].hasAttribute("selected")||n[s].setAttribute("selected",""):n[s].removeAttribute("selected")}}function dt(t){t.tagName!=="TEXTAREA"||!t.hasAttribute("data-value")||t!==t.ownerDocument.activeElement&&(t.textContent=t.getAttribute("data-value"),t.removeAttribute("data-value"))}function T(t){if(typeof window>"u")return null;let e=window.clay,r=window.hyperclay;return t==="consent"?e?.confirm||r?.consent||null:e?.[t]||r?.[t]||null}function Ne(){let t=T("visitorDrafts");return!!(t&&typeof t.restored=="function"&&t.restored()?.restored)}var Lt=["clay:mutation-ready","hyperclay:mutation-ready"],En=["clay:sync-applied","hyperclay:livesync-applied"],xn=["clay:ready","hyperclay:ready"],vn=["clay:route"],Sn=["clay:modechange"];function Q(t,e,r){let n=null,o=s=>{n!==null&&n!==s.type||(n=s.type,queueMicrotask(()=>{n=null}),r(s))};for(let s of e)t.addEventListener(s,o);return()=>{for(let s of e)t.removeEventListener(s,o)}}function Te(t){let e=typeof window<"u"&&window.clay&&window.clay.ready;e&&typeof e.then=="function"?e.then(()=>t(),()=>t()):t()}function pt(t){let e=T("region");return!e||typeof e.resolveRegionPolicy!="function"||typeof e.skipForPolicy!="function"?!1:e.skipForPolicy(e.resolveRegionPolicy(t),void 0,["no-save","freeze"])}function Re(){return typeof window>"u"?null:window.clay?.modeLifecycle||null}function mt(t,{transient:e=!1}={}){if(e)return!0;let r=Re();return typeof r?.canWrite!="function"||T("region")?.resolveRegionPolicy?.(t)?.persist==="none"?!0:r.canWrite()}function Le(t,e){if(typeof e!="function")throw new Error("Sap.batch(label, fn): fn must be a function");let r=T("undo");r&&r.flush&&r.flush();let n=e();if(n&&typeof n.then=="function")throw new Error("Sap.batch fn must be synchronous (it returned a promise)");return r&&r.commitCaptured&&r.commitCaptured(t),n}function _e(t){if(typeof window>"u"||typeof document>"u")return;let e=()=>{let p=!1;for(let v of t.apps())v.root.isConnected?t.runNow(v,"platform"):p=!0;p&&t.pruneDisconnected(),t.remountIfPresent()},r=T("derived"),n=r&&typeof r.register=="function"?r.register(e):null,o=typeof n=="function"?null:Q(document,En,e),s=Q(document,vn,e),i=null,f=!1,c=()=>{let p=i;i=null,p&&(p[2](),p[3]())},l=()=>{if(f)return!1;let p=T("undo"),v=Re()?.state?.generation;if(i&&i[0]===p&&i[1]===v)return!0;if(c(),!p||typeof p.on!="function")return!1;let R=p.on("undo",e);if(typeof R!="function")return!1;let _=p.on("redo",e);return typeof _!="function"?(R(),!1):(i=[p,v,R,_],!0)};l();let a=[Lt,xn,Sn].map(p=>Q(document,p,l)),d=T("ready");return d&&typeof d.then=="function"&&d.then(l,()=>{}),()=>{f=!0,typeof n=="function"&&n(),o&&o(),s();for(let p of a)p();c()}}function _t(t){let e=t.tagName;if(e==="INPUT"){let r=(t.getAttribute("type")||"text").toLowerCase();return r==="checkbox"?"checkbox":r==="radio"?"radio":r==="number"||r==="range"?"number":r==="hidden"?"hidden":"text"}return e==="TEXTAREA"?"text":e==="SELECT"?t.multiple?"select-multiple":"select-one":"leaf"}function kn(t){if(t.validity&&t.validity.badInput)return t.hasAttribute("value")?Number(t.getAttribute("value"))||0:t._sapLastGood??0;if(t.value==="")return 0;let e=Number(t.value);return Number.isNaN(e)?t._sapLastGood??0:(t._sapLastGood=e,e)}function $e(t,e){switch(e){case"checkbox":return t.checked;case"radio":return t.checked?t.value:void 0;case"number":return kn(t);case"select-one":return t.value;case"select-multiple":return[...t.selectedOptions].map(r=>r.value);case"hidden":case"text":return t.value;case"leaf":return t.textContent;default:return t.value}}function Nn(t,e,r){switch(e){case"checkbox":t.checked=!!r;break;case"radio":t.checked=String(t.value)===String(r);break;case"number":case"text":case"hidden":t.value=r==null?"":String(r);break;case"select-one":t.value=r==null?"":String(r);break;case"select-multiple":{let n=new Set((Array.isArray(r)?r:[r]).map(String));for(let o of t.options)o.selected=n.has(o.value);break}case"leaf":t.textContent=r==null?"":String(r);break;default:t.value=r==null?"":String(r)}}function Ce(t){if(t.hasAttribute("transient")){t.removeAttribute("value"),t.removeAttribute("checked"),t.removeAttribute("data-value");return}pt(t)||V(t)}function Tn(t){t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))}function Pe(t,e){return $e(t,e)}function Me(t){let e=_t(t);return{el:t,kind:e,read(){return $e(t,e)},write(r,n={}){Nn(t,e,r),n.noMirror||Ce(t),n.silent||Tn(t)},mirror(){Ce(t)}}}var I=null,bt=!1,Y=null;function Oe(t){let e=null;return{kind:"hub",subscribe(r){let n=t.onAnyChange({debounce:0,require:"observed"},r);typeof n=="function"&&(e=n)},suppress(r){t.pause();try{return r()}finally{t.resume()}},teardown(){if(e){try{e()}catch{}e=null}}}}function Rn(){let t=null;return{kind:"native",subscribe(e){t=new MutationObserver(n=>e(Ln(n)));let r=typeof document<"u"&&document.body||typeof document<"u"&&document.documentElement;r&&t.observe(r,{childList:!0,subtree:!0,attributes:!0,characterData:!0})},suppress(e){let r=T("undo");r&&r.pause&&r.pause();try{return e()}finally{t&&t.takeRecords(),r&&r.resume&&r.resume()}},teardown(){t&&(t.disconnect(),t=null)}}}function Ln(t){let e=[];for(let r of t)if(r.type==="attributes"){let n=r.target;n&&n.nodeType===1&&!ht(n)&&e.push({type:"attribute",element:n})}else if(r.type==="characterData"){let n=r.target&&r.target.parentElement;n&&!ht(n)&&e.push({type:"characterData",element:n})}else if(r.type==="childList"){for(let n of r.addedNodes)if(!(n.nodeType!==1||ht(n))&&(e.push({type:"add",element:n}),n.querySelectorAll))for(let o of n.querySelectorAll("*"))ht(o)||e.push({type:"add",element:o});for(let n of r.removedNodes)n.nodeType===1&&e.push({type:"remove",element:n,parent:r.target})}return e}function ht(t){return!!(t.closest&&t.closest("[sap-ignore],[template],[cms-template]"))}function _n(t,e){t.pruneDisconnected();let r=new Set,n=!1;for(let o of e){let s=o.type==="remove"?o.parent:o.element,i=s&&t.appFor(s);i&&r.add(i),o.type==="add"&&o.element&&o.element.nodeType===1&&o.element.hasAttribute&&o.element.hasAttribute("sap")&&!(t.isRegistered&&t.isRegistered(o.element))&&(n=!0)}n&&t.remountIfPresent();for(let o of r)o.root.isConnected&&t.schedule(o,"mutation")}function De(t){if(I)return I.suppress(t);let e=T("undo");if(e&&e.pause&&e.resume){e.pause();try{return t()}finally{e.resume()}}return t()}function Ct(t,e){bt=!0,I=t,t.subscribe(r=>_n(e,r))}function $t(t){if(bt||typeof window>"u"||typeof document>"u")return;let e=T("Mutation");if(e&&typeof e.onAnyChange=="function"){Ct(Oe(e),t);return}typeof MutationObserver=="function"&&(Ct(Rn(),t),Y=Q(document,Lt,function(){let n=T("Mutation");n&&(Y(),Y=null,I&&I.teardown(),bt=!1,Ct(Oe(n),t))}))}function Pt(){if(I)try{I.teardown()}catch{}Y&&typeof document<"u"&&Y(),I=null,bt=!1,Y=null}var Cn=new Set(z),gt=Object.freeze([]),W=[],We={},Be={};function Fe(t){W.includes(t)||(W.push(t),t.boundary&&Object.assign(We,t.boundary),t.paintKinds&&Object.assign(Be,t.paintKinds))}function yt(t,e={}){if(e.breaker){t.diag.error("E26",t.root,{problem:"recompute loop halted after 50 passes; recent triggers: "+(t._breakerRing||[]).join(", ")}),B(t.root,"loop");return}e.full&&(ue(),me());let r=ce(t.root);try{De(()=>$n(t,e))}finally{le(r)}t._viewsChanged&&(t._viewsChanged=!1,t.root.dispatchEvent(new CustomEvent("sap:views-updated",{bubbles:!0})))}function $n(t,e){let r=t.root,n={},o=[],s=[],i=new Set;t.diag.errors=[];let f={root:n,state:n,item:null,ownerEl:r,projection:!1},c=null;function l(u,h,b=!1){let m=h.attr||h.name,g=b?xe(u,m):u.getAttribute(m);return g==null&&(g=Tt(h),s.push({el:u,name:h.name,attr:m,value:Gt(st(g,h.type),h.type)})),st(g,h.type)}function a(u,h,b,m){let g=h.decls;if(!g)return;let E=!!m.item&&!m.projection&&!m.view;for(let k of g){if(k.transient){c&&(c.pure=!1),b[k.name]=Xt(u,k);continue}if(Nt(u,k)){b[k.name]=u.hasAttribute(k.attr);continue}b[k.name]=l(u,k,E)}}function d(u,h,b){let m=h.bind,g=b.item||b.state,E=_t(u);c&&(E!=="leaf"||h.transient)&&(c.pure=!1),E==="radio"?(m in g||(g[m]=""),u.checked&&(g[m]=u.value)):E==="leaf"&&b.item&&!b.projection&&!b.view?g[m]=ve(u):g[m]=Pe(u,E),h.transient&&(u.removeAttribute("value"),u.removeAttribute("checked"))}function p(u,h,b){let m=!1;if(h.paints){m=!0;for(let g of h.paints)g.kind==="when"&&i.add(g.field),o.push({def:g,el:u,ctx:b})}for(let g of W)g.collect&&g.collect(A,u,h,b)!==!1&&(m=!0);c&&m&&(h.calcs&&(c.pure=!1),c.collects.push(u,h))}function v(u,h,b){Object.defineProperty(u,"$key",{value:qt(h,"row"),enumerable:!1}),Object.defineProperty(u,"$index",{value:b,enumerable:!1,configurable:!0}),Object.defineProperty(u,"$el",{value:h,enumerable:!1})}function R(u,h,b){let m=ft(u);a(u,m,h,b),u._sapScope=h,!b.projection&&m.bind!=null&&d(u,m,b),p(u,m,b),m.items?nt(u,h,b):_(u,h,b)}function _(u,h,b){for(let m=u.firstElementChild;m;m=m.nextElementSibling)$(m,h,b)}function $(u,h,b){let m=ft(u);if(!m.inert){if(m.boundary){c&&(c.pure=!1),m.boundary==="scope"?et(u,h,b):m.boundary==="items"?(p(u,m,b),nt(u,h,b)):We[m.boundary](A,u,m,h,b);return}!b.projection&&!b.view&&m.bind!=null&&d(u,m,b),p(u,m,b);for(let g=u.firstElementChild;g;g=g.nextElementSibling)$(g,h,b)}}function et(u,h,b){let m=u.getAttribute("scope"),g={};h[m]=g;let E={root:b.root,state:g,item:null,ownerEl:u,projection:b.projection};R(u,g,E)}function nt(u,h,b){c&&(c.pure=!1);let m=u.getAttribute("items"),g=[];h[m]=g,u._sapList=g;let E=!b.projection&&!b.view&&he(),k=0;for(let N=u.firstElementChild;N;N=N.nextElementSibling){let x=ft(N);if(!x.item||x.template||x.cms)continue;let L=E?be(N):void 0;g.push(L&&L.plan===x&&Object.isExtensible(L.obj)&&rt(L,N,k,b)||X(N,x,k,b,E)),k++}}function X(u,h,b,m,g){let E={};v(E,u,b);let k={root:m.root,state:m.state,item:E,ownerEl:u,projection:m.projection};if(!g)return R(u,E,k),E;let N=c,x={plan:h,obj:E,fields:null,presence:gt,pending:gt,collects:[],pure:!0},L=s.length,nn=t.diag.errors.length;c=x;try{R(u,E,k)}finally{c=N}if(!x.pure||t.halted||t.diag.errors.length!==nn)return E;let Ft=[];for(let H of Object.keys(E)){let wt=E[H];if(wt!==null&&typeof wt=="object")return E;Ft.push(H,wt)}if(h.decls)for(let H of h.decls)Nt(u,H)&&(x.presence===gt?x.presence=[]:x.presence).push(H.name,H.attr);return s.length>L&&(x.pending=s.slice(L)),x.collects.length||(x.collects=gt),x.fields=Ft,ge(u,x),E}function rt(u,h,b,m){let g=u.obj;try{g.$index!==b&&Object.defineProperty(g,"$index",{value:b,enumerable:!1,configurable:!0});let N=u.presence;for(let L=0;L<N.length;L+=2)g[N[L]]=h.hasAttribute(N[L+1]);let x=u.fields;for(let L=0;L<x.length;L+=2)g[x[L]]=x[L+1]}catch{return ye(h),null}h._sapScope=g;let E=u.pending;for(let N=0;N<E.length;N++)s.push(E[N]);let k=u.collects;if(k.length){let N={root:m.root,state:m.state,item:g,ownerEl:h,projection:m.projection};for(let x=0;x<k.length;x+=2)p(k[x],k[x+1],N)}return g}let A={app:t,root:r,rootObj:n,paints:o,stats:{calcs:0,lists:0},resolveDefault:l,collectEl:p,walkScope:_};for(let u of W)u.begin&&u.begin(A);let w=e.cacheReads===!1?null:we(r);try{R(r,n,f)}finally{e.cacheReads!==!1&&Ae(w)}if(t.halted)return;for(let u of W)u.afterIntake&&u.afterIntake(A);if(s.length&&i.size)for(let u of s)i.has(u.attr)&&u.el.getAttribute(u.attr)==null&&u.el.setAttribute(u.attr,u.value);for(let u of W)u.compute&&u.compute(A);let y=0;for(let u of W)u.reconcile&&(y+=u.reconcile(A));let S=0,C=y;for(let u of o){let h=Mn(u,t);u.ctx.view?C+=h:S+=h}for(let u of W)u.afterPaint&&u.afterPaint(A);t._state=n,t._stats={fields:Object.keys(n).filter(u=>typeof n[u]!="function").length,calcs:A.stats.calcs,paints:o.length,lists:A.stats.lists,writes:S,viewWrites:C},t._viewsChanged=C>0,t._lastPass={trigger:e.trigger||"refresh",writes:S},t._debug&&console.log(`sap pass \xB7 trigger: ${t._lastPass.trigger} \xB7 writes ${S}/${o.length}`)}function Pn(t){return t.kind==="text"?t.fmt?"text:"+t.fmt:"text":t.kind==="attr"?"attr:"+t.arg:t.kind==="class"?"class:"+t.arg:t.kind==="css"?"css:"+t.arg:t.kind==="when"?(t.match==="hide"?"hide-when:":t.match==="show-not"?"option-not:":"show-when:")+t.field:t.kind}function Mt(t,e,r,n){let o=t;for(;o&&o.nodeType===1;){if(o.hasAttribute&&o.hasAttribute(e)){let s=r.includes(o.getAttribute(e));if(n?!s:s)return!0}o=o.parentElement}return!1}function Mn(t,e){let r=t.def,n=t.el,o=Be[r.kind];if(o)return o(t,e);if(r.kind==="when")return Ie(r,n,null);try{let s=ie(r.entry,t.ctx.state,t.ctx.item,n,t.ctx.root),i=Ie(r,n,s);return zt(n),i}catch(s){return e.diag.error(s.sapCode==="E22"?"E22":"E24",n,{attr:Pn(r),expr:r.entry&&r.entry.src,problem:String(s.message)}),B(n,s.sapCode||"E24"),0}}function Ie(t,e,r){switch(t.kind){case"text":{let n=t.fmt!=null?ne(t.fmt,r):r==null?"":String(r);return e.textContent!==n?(e.textContent=n,1):0}case"show":{let n=!r;return e.hidden!==n?(e.hidden=n,1):0}case"when":{let n=T("optionVisibility");if(n&&n._started)return e._sapWhen&&e.hidden?(e.hidden=!1,e._sapWhen=!1,1):0;let o;t.match==="hide"?o=!Mt(e,t.field,t.values,!1):t.match==="show-not"?o=Mt(e,t.field,t.values,!0):o=Mt(e,t.field,t.values,!1),e._sapWhen=!0;let s=!o;return e.hidden!==s?(e.hidden=s,1):0}case"attr":{let n=t.arg;if((n==="checked"||n==="selected")&&typeof e[n]=="boolean"&&!e.hasAttribute("bind")&&!e.closest("select[bind]")){let s=0;return e[n]!==!!r&&(e[n]=!!r,s=1),!!r!==e.hasAttribute(n)&&(r?e.setAttribute(n,""):e.removeAttribute(n),s=1),s}if(Cn.has(n)){let s=e.hasAttribute(n);return r&&!s?(e.setAttribute(n,""),1):!r&&s?(e.removeAttribute(n),1):0}let o=typeof r=="boolean"?String(r):r==null?"":String(r);return e.getAttribute(n)!==o?(e.setAttribute(n,o),1):0}case"class":{let n=!!r;return e.classList.contains(t.arg)!==n?(e.classList.toggle(t.arg,n),1):0}case"css":{let n=r==null?"":String(r);return e.style.getPropertyValue("--"+t.arg)!==n?(e.style.setProperty("--"+t.arg,n),1):0}default:return 0}}var On=new Set(z),je=new Set(["calc","text","attr","class","css","set","move","sort","option","option-not","show-when","hide-when","editmode","viewmode"]),Dn=new Set(["show-when","hide-when","option","option-not"]),In=/\b(?:state|item|root)\.|===|!==|&&|\|\||[()]|^\s*!/,He=new Set(["sap","scope","items","item","template","bind","show","effect","invalid","detail","state","transient","confirm","default","persist","sortable","trigger-add","trigger-remove","trigger-reset","sap-ignore","sap-error","no-save","no-watch","no-undo","no-trigger-autosave","freeze","mutations-ignore","save-remove","save-ignore","save-freeze"]),Dt=[];function ze(t){Dt.includes(t)||Dt.push(t)}function Wn(t){return t.tagName==="INPUT"||t.tagName==="SELECT"||t.tagName==="TEXTAREA"}function Ot(t){return t.hasAttribute("bind")}function Bn(t,e){e(t);for(let n=t.firstElementChild;n;n=n.nextElementSibling)r(n);function r(n){if(!n.hasAttribute("sap-ignore")){if(n.tagName==="TEMPLATE"){if(n.hasAttribute("items"))for(let o=n.content.firstElementChild;o;o=o.nextElementSibling)r(o);return}e(n);for(let o=n.firstElementChild;o;o=o.nextElementSibling)r(o)}}}function Ue(t,e){let r=!1,n=(i,f,c)=>{e.error(i,f,c),r=!0},o=t.ownerDocument.createTreeWalker(t,4),s;for(;s=o.nextNode();)if(/\{\{.*\}\}/.test(s.nodeValue||"")){n("E02",s.parentElement||t,{problem:"moustaches in text content are not a Sap feature",fix:'move the expression onto the element: text="state.x"'});break}return Bn(t,i=>{let f=new Set;for(let l of Dt)l(i,n,a=>f.add(a));let c=i.closest&&i.closest("[detail]");for(let l of[...i.attributes]){let a=l.name;if(f.has(a))continue;if(a.includes(":")){let p=a.slice(0,a.indexOf(":"));if(je.has(p)){if(Dn.has(p)&&In.test(l.value)){let v=a.slice(a.indexOf(":")+1);e.warn("W04",i,{attr:a,expr:l.value,problem:`${p}: compares the "${v}" attribute against a literal value, not a JS expression`,fix:`use show="${l.value}" for an expression, or a literal like ${p}:${v}="overview"`})}}else{let v=vt(p,[...je]);e.warn("W03",i,{attr:a,problem:`unknown "${p}:" attribute`,didYouMean:v?`${v}:`:null})}}else if(!He.has(a)&&!xt.has(a)&&!On.has(a)&&!/^(data-|aria-|on)/.test(a)&&!(a in i)){let p=vt(a,[...He]);p&&e.warn("W03",i,{attr:a,problem:`unknown "${a}" attribute`,didYouMean:p})}a==="attr:hidden"&&e.warn("W03",i,{attr:a,problem:"attr:hidden paints the wrong attribute",fix:'use show="expr"'});let d=Ot(i)||a==="attr:selected"&&i.tagName==="OPTION"&&!!i.closest("select[bind]");(a==="attr:value"||a==="attr:checked"||a==="attr:selected")&&d&&n("E30",i,{attr:a,problem:"attr: on a bound control collides with persist ownership",fix:"remove it; bind owns this attribute"}),a==="effect"&&Ot(i)&&/\b(value|checked)\s*=[^=]/.test(l.value)&&n("E30",i,{attr:a,expr:l.value,problem:"effect writes value/checked on a bound control (writes a stale value with no synthetic event)",fix:"write through onclick + Sap(this) instead"}),(a==="text"||a.startsWith("text:")||a==="show")&&Wn(i)&&(a==="show"||n("E18",i,{attr:a,problem:"paint belongs on output elements, not form controls",fix:"move the paint to an <output> or <span>"}))}if(i.hasAttribute("state")){let l=it(i.getAttribute("state")),a=new Set;for(let d of l){d.name.includes("-")&&n("E08",i,{attr:"state",problem:`field "${d.name}" is not a valid identifier (the hyphen parses as subtraction)`,fix:`rename to ${d.name.replace(/-/g,"")}`}),a.has(d.name)&&n("E04",i,{attr:"state",problem:`field "${d.name}" is declared twice in one scope`}),a.add(d.name),Ht.has(d.attr)&&n("E05",i,{attr:"state",problem:`"${d.name}" is a reserved Sap word`}),xt.has(d.attr)&&n("E06",i,{attr:"state",problem:`"${d.name}" is a global HTML attribute name; pick another field name`}),d.name==="open"&&i.tagName==="DIALOG"&&n("E33",i,{attr:"state",problem:"dialog open is transient",fix:"use showModal() \u2014 declare state= only on <details> or popovers"});let p=kt(i,d.attr);p&&(d.attr==="checked"||d.attr==="selected")&&n("E35",i,{attr:"state",problem:`"${d.attr}" on a form control is the control's own state, not a declared field`,fix:'bind the control instead, e.g. <input type="checkbox" bind="done">'}),p&&d.type==="num"&&n("E35",i,{attr:"state",problem:`"${d.attr}" is an HTML boolean attribute; it cannot hold a number`,fix:`declare it bare: state="${d.attr}"`}),d.transient&&(p||d.type==="presence")&&n("E35",i,{attr:"state",problem:`"${d.name}" is carried by attribute presence, which transient would strip`,fix:"declare a separate name:bool:transient field and paint the attribute from it"})}}if(Ot(i)){if(i.hasAttribute("-"),i.tagName==="INPUT"){let l=(i.getAttribute("type")||"text").toLowerCase();l==="file"&&n("E32",i,{attr:"bind",problem:"files never serialize into an HTML file",fix:"use no-save + effect instead of bind"}),l==="password"&&!i.hasAttribute("transient")&&n("E31",i,{attr:"bind",problem:"a password must never serialize into a world-readable file",fix:"add transient to the password input"})}else if(i.tagName!=="SELECT"&&i.tagName!=="TEXTAREA"){let l=i.getAttribute("contenteditable");!(l!=null&&l!=="false")&&i.children.length>0&&n("E20",i,{attr:"bind",problem:"bind on a container element is not a control; a write would overwrite its children",fix:"bind a control (input/select/textarea), a contenteditable, or an empty text leaf"})}}if(i.hasAttribute("transient")&&i.hasAttribute("persist")&&n("E34",i,{problem:"transient and persist are opposite: persist forces the live value into the saved bytes, leaking exactly what transient drops",fix:"remove one \u2014 transient to keep it out of the file, or persist to save it"}),i.tagName==="DIALOG"&&i.hasAttribute("detail")&&!(i.parentElement&&i.parentElement.closest('[clay~="freeze"], [freeze], [save-freeze]'))&&e.warn("W31",i,{attr:"detail",problem:"a detail dialog writes open when it opens, and that attribute would be saved into the file",fix:'wrap the dialog in an element with clay="freeze" (not editor-ui, which removes it from the file), and make its key field transient'}),i.hasAttribute("item")&&!i.hasAttribute("template")&&i.parentNode&&i.parentNode.nodeType===1){let l=i.parentElement;(!l||!l.hasAttribute("items"))&&n("E10",i,{problem:"an [item] must be a direct child of an [items] list",fix:'wrap it in a container with items="name"'})}if(i.hasAttribute("items")&&c&&n("E17",i,{attr:"items",problem:"nested items inside a detail panel is a v1 mount error (nested collections ship in v1.1)"}),i.hasAttribute("items")){let l=t.querySelector(`[trigger-add="${i.getAttribute("items")}"]`);!Yt(i)&&!St(t,i.getAttribute("items"))&&Vt(i).length===0&&l&&n("E17",i,{attr:"items",problem:`trigger-add targets items="${i.getAttribute("items")}" but it has no [item template] to clone`})}}),r&&(e.halted=!0,e.haltReason=e.errors[0]?e.errors[0].code:"halt",B(t,e.haltReason)),!r}var qe="sap-styles",Ve="[item][template]{display:none!important}[hidden]{display:none!important}[sap-error]{outline:2px solid #e5484d;outline-offset:1px}",It=new WeakSet;function Fn(t){if(It.has(t))return;let e=t.defaultView,r=e&&e.CSSStyleSheet;if(r&&"adoptedStyleSheets"in t)try{let n=new r;n.replaceSync(Ve),t.adoptedStyleSheets=[...t.adoptedStyleSheets,n],It.add(t);return}catch{}if(!t.getElementById(qe)){let n=t.createElement("style");n.id=qe,n.textContent=Ve,(t.head||t.documentElement).appendChild(n)}It.add(t)}var jn=0;function Ye(){return typeof performance<"u"&&performance.now?performance.now():0}function Wt(t){let e=t.id||t.getAttribute("sap")||`app-${jn++}`,r=new ot(e),n={root:t,name:e,diag:r,_state:null,_stats:null,_lastPass:null,_passes:0,_broken:!1,_mountMs:0,_mountWrites:0};if(!Ue(t,r))return n.halted=!0,n;Fn(t.ownerDocument);for(let i of t.querySelectorAll("textarea[data-value]"))dt(i);let s=Ye();return yt(n,{trigger:"mount",full:!0}),n._mountMs=Ye()-s,n._mountWrites=n._stats?n._stats.writes:0,n._mountWrites>0&&!Ne()&&!T("derived")&&r.warn("W30",t,{problem:`${n._mountWrites} paint(s) ran at mount; the saved file was out of sync with its declared state`,fix:"re-save once so the file mounts clean (a settled file writes nothing)"}),n}var Ge=/^(set:|move:|sort:|trigger-add$|trigger-remove$|trigger-reset$)/;function Hn(t){return`${t.tagName.toLowerCase()}[sap]`}function zn(t){let e=0;for(let r of t.querySelectorAll("*"))for(let n of r.attributes)if(Ge.test(n.name)){e++;break}for(let r of t.attributes)if(Ge.test(r.name)){e++;break}return e}function Xe(t){function e(f){let c=f._stats||{},l=f.root;return{root:Hn(l),fields:c.fields||0,calcs:c.calcs||0,paints:c.paints||0,actions:zn(l),lists:(l.hasAttribute("items")?1:0)+l.querySelectorAll("[items]").length,rows:l.querySelectorAll("[item]:not([template])").length,warnings:f.diag.warnings.length,errors:f.diag.errors.length,mountWrites:f._mountWrites||0,ms:Math.round((f._mountMs||0)*10)/10,passes:f._passes||0,lastPass:f._lastPass||null,ok:f.diag.errors.length===0&&!f.halted}}function r(){let f=t.apps().map(e);return{ok:f.every(c=>c.ok),apps:f}}function n(f){let c=e(f);return c.ok?`sap \u2713 ${c.root} \xB7 fields ${c.fields} \xB7 calcs ${c.calcs} \xB7 paints ${c.paints} \xB7 actions ${c.actions} \xB7 lists ${c.lists} \xB7 rows ${c.rows} \xB7 warnings ${c.warnings} \xB7 mount writes ${c.mountWrites} \xB7 ${c.ms}ms`:`sap \u2717 ${c.root} \xB7 errors ${c.errors} \xB7 warnings ${c.warnings} \xB7 ${c.ms}ms`}function o(){for(let f of t.apps()){let c=n(f);f.diag.errors.length||f.halted?console.error(c):console.log(c)}}function s(){let f=[],c=[];for(let l of t.apps())f.push(...l.diag.errors),c.push(...l.diag.warnings);return{ok:f.length===0,errors:f,warnings:c,counts:{errors:f.length,warnings:c.length}}}function i(f){let c=f===void 0?!0:!!f;for(let l of t.apps())l._debug=c;return console.log(`sap debug ${c?"on":"off"} \u2014 per-pass headers will ${c?"":"no longer "}log`),c}return{status:r,report:s,debug:i,greenLine:n,printGreenLines:o,REGISTRY:Et}}var Ke="0.7.0";function Je({createAccessor:t,installInput:e,debugExtras:r}){let n=new Map,o=[],s=jt(yt);function i(w){let y=w;for(;y;){if(y.nodeType===1&&y.hasAttribute&&y.hasAttribute("sap"))return n.get(y)||null;y=y.parentNode&&y.parentNode.host?y.parentNode.host:y.parentElement}return null}function f(){for(let w=o.length-1;w>=0;w--){let y=o[w];y.root.isConnected||(n.delete(y.root),o.splice(w,1))}}function c(w,y){if(w.moveBefore)try{w.moveBefore(y,null);return}catch{}w.appendChild(y)}function l(w,y){let S=y.parentElement;if(S){if(S.moveBefore)try{S.moveBefore(w,y);return}catch{}S.insertBefore(w,y)}}let a={apps:()=>o.slice(),appFor:i,isRegistered:w=>n.has(w),pruneDisconnected:f,schedule:(w,y)=>s.schedule(w,y),runNow:(w,y)=>s.runNow(w,y),moveInto:c,placeBefore:l,remountIfPresent:()=>X()},d=t(a),p=Xe(a),v=r?r(a,p):{},R=!1,_=!1,$=null;function et(){R||(R=!0,e(a,d,document),$=_e(a))}function nt(){let w=T("derived");w&&typeof w.mounted=="function"&&w.mounted()}function X(w=document){if(_)return[];et(),$t(a);let y=w.querySelectorAll("[sap]"),S=[];for(let C of y){if(n.has(C))continue;let u=Wt(C);n.set(C,u),o.push(u),S.push(u)}for(let C of S){let u=p.greenLine(C);C.diag.errors.length||C.halted?console.error(u):console.log(u)}return nt(),S}function rt(w){if(_)return null;if(et(),$t(a),!w)return X();let y=typeof w=="string"?document.querySelector(w):w;if(!y)return null;if(n.has(y))return n.get(y);let S=Wt(y);n.set(y,S),o.push(S);let C=p.greenLine(S);return S.diag.errors.length||S.halted?console.error(C):console.log(C),S}let A=d.Sap;return A.version=Ke,A.refresh=function(){for(let y of o)y.root.isConnected&&s.runNow(y,"refresh")},A.batch=Le,A.status=p.status,A.report=p.report,A.why=v.why,A.debug=p.debug,A.doctor=v.doctor,A.greenLine=p.greenLine,A.formats=U,A.serializeControlToAttributes=V,A.finalizeControlForSave=ke,A.rehydrateControlFromAttributes=dt,A.mount=rt,A.config=function(y={}){return y.formats&&Object.assign(U,y.formats),A},A._registry=n,A._reset=function(){n.clear(),o.length=0,Pt()},A.unmount=function(){_=!0,n.clear(),o.length=0,Pt(),typeof $=="function"&&$()},{Sap:A,mountAll:X,mount:rt,runtime:a}}function Qe(t){if(typeof document>"u")return;let e=()=>Te(()=>t());document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):e()}function Ze(t){let e=[];function r(c){let l=c.target;if(!l||l.nodeType!==1)return;let a=t.appFor(l);if(a){l.hasAttribute("persist")&&!pt(l)&&mt(l)&&V(l);for(let d of e)if(d(l,a))return;t.schedule(a,c.type+" "+(l.id||l.tagName.toLowerCase()))}}function n(c){let l=c.target,a=t.appFor(l);a&&[...l.querySelectorAll("[bind]")].every(d=>mt(d))&&setTimeout(()=>{l.querySelectorAll("[bind]").forEach(d=>{d.dispatchEvent(new Event("input",{bubbles:!0})),d.dispatchEvent(new Event("change",{bubbles:!0}))}),t.schedule(a,"reset")},0)}function o(c){let l=t.appFor(c.target);l&&t.schedule(l,"toggle")}function s(c){let l=c.detail||{};for(let a of[l.from,l.to,c.target]){if(!a||a.nodeType!==1)continue;let d=t.appFor(a);d&&t.schedule(d,"sorted")}}function i(c){if(c.key!=="ArrowUp"&&c.key!=="ArrowDown")return;let l=c.target;if(!l||l.nodeType!==1||l.tagName!=="INPUT"||!l.hasAttribute("bind")||!l.hasAttribute("step"))return;let a=(l.getAttribute("type")||"text").toLowerCase();if(a!=="text"&&a!=="tel"&&a!=="search"||!t.appFor(l)||!mt(l))return;c.preventDefault();let p=P(l.getAttribute("step"))||1,v=c.key==="ArrowUp"?1:-1,R=P(l.value)+p*(c.shiftKey?10:1)*v,_=l.getAttribute("min"),$=l.getAttribute("max");_!==null&&_!==""&&R<P(_)&&(R=P(_)),$!==null&&$!==""&&R>P($)&&(R=P($)),Me(l).write(String(Number(R.toFixed(2))))}function f(c=document){c.addEventListener("reset",n),c.addEventListener("toggle",o,!0),c.addEventListener("input",r),c.addEventListener("change",r),c.addEventListener("clay:sorted",s),c.addEventListener("keydown",i)}return{install:f,addRouter:c=>e.push(c)}}var Z="https://clayjs.com/v1/sap.js",Un=/^(calc|set|move|sort):/,qn=new Set(["each","detail","effect","invalid","confirm","trigger-add","trigger-remove","trigger-reset"]);function Bt(t){return Un.test(t)||qn.has(t)}ze((t,e)=>{for(let r of t.attributes)Bt(r.name)&&e("E50",t,{attr:r.name,expr:r.value,problem:`${r.name} is full sapjs; the sapjs core only paints declared state`,fix:`load ${Z}; the markup stays as it is`})});function G(t,e,r){t.app.diag.error("E50",e,{attr:r,problem:`${r} is full sapjs; the sapjs core only paints declared state`,fix:`load ${Z}; the markup stays as it is`}),B(e,"E50"),t.app.halted=!0}Fe({name:"core-only",collect(t,e,r){r.calcs&&G(t,e,"calc:"+r.calcs[0].name),r.effects&&G(t,e,"effect"),r.invalids&&G(t,e,"invalid");for(let n of e.attributes)Bt(n.name)&&(n.name.startsWith("calc:")&&r.calcs||n.name==="effect"&&r.effects||n.name==="invalid"&&r.invalids||G(t,e,n.name));return!1},boundary:{each(t,e){G(t,e,"each")},detail(t,e){G(t,e,"detail")}}});function Vn(){return{Sap:function(){throw new Error(`Sap(el) is full sapjs; load ${Z}`)}}}var tn=t=>()=>(console.warn(`Sap.${t} is full sapjs; load ${Z}`),null),{Sap:tt,mountAll:en,mount:Yn,runtime:Gn}=Je({createAccessor:Vn,debugExtras:()=>({why:tn("why"),doctor:tn("doctor")}),installInput(t,e,r){Ze(t).install(r)}});tt.core=!0;var Xn=typeof window<"u"&&window.Sap&&!window.Sap.core;Xn?tt.unmount():Qe(en);typeof window<"u"&&!window.Sap&&(window.Sap=tt);var Kn=tt;return cn(Jn);})();
|
|
9
9
|
export default SapCoreBundle.default;
|
package/dist/m/c-2SPVQSHC.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var n=new Map,u=0;function l({id:e="",isPending:s,flush:t=null}){let o=++u;n.set(o,{id:e,isPending:s,flush:t});let r=!1;return{changed(){r||document.dispatchEvent(new CustomEvent("clay:unsaved-state-changed",{detail:{pending:i()}}))},dispose(){r||(r=!0,n.delete(o))}}}function a(e){try{return!!e.isPending()}catch(s){return console.error(`[clay] unsaved-state check "${e.id}" threw`,s),!0}}function i(){return[...n.values()].filter(a).map(e=>e.id)}function c(){for(let e of n.values())if(a(e))return!0;return!1}async function d(){let e=[...n.values()].filter(t=>typeof t.flush=="function"&&a(t));return{ok:(await Promise.all(e.map(t=>Promise.resolve().then(t.flush).catch(()=>({ok:!1}))))).every(t=>t?.ok!==!1),pending:i()}}typeof window<"u"&&(window.clay=window.clay||{},window.clay.registerUnsavedState=l);export{l as a,i as b,c,d};
|
package/dist/m/c-336SGU5W.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{A as X,B as W,d as S,f as M,g as I,i as O,k as D,l as H,m as b,n as C,o as N,p as $,r as F}from"./c-5J4E7O4Y.js";import{b as R,m as A}from"./c-WWXIDH4O.js";var P=new WeakMap,st=new WeakMap;function rt(s,t){let e=P.get(s)??new Set;return P.set(s,e),e.add(t),()=>e.delete(t)}function at(){return new R.Plugin({view:s=>({update:t=>{for(let e of P.get(t)??[])e.update?.(t)},destroy:()=>{let t=P.get(s);if(t){for(let e of t)e.destroy?.(s);t.clear()}}})})}var Y=new WeakMap;function v(s){let t=Y.get(s);return t||Y.set(s,t=I(s)),t}var _=A.nodes,y=s=>s.type===_.list_item,L=s=>s.type===_.toggle,w=s=>s.attrs.parent??null;function Q(s,t,e){if(e<0)return[null];let n=[],o=s[e].node;L(o)&&o.attrs.open&&!s[e].hidden&&n.unshift(o.attrs.id);for(let r=w(o);r!==null&&!n.includes(r);){let c=s[t.get(r)];if(!c)break;n.unshift(r),r=w(c.node)}let i=[null];for(let r of n){let c=s[t.get(r)];if(!c.node.attrs.open||c.hidden)break;i.push(r)}return i}function K(s,t,e,n){let o=w(s[t].node),i=y(s[t].node)?n.indent-s[t].node.attrs.indent:0;return r=>r.i<t||r.i>e||w(r.node)!==o?null:y(r.node)?{parent:n.parent,indent:r.node.attrs.indent+i}:{parent:n.parent}}function Z(s,t){let e=null;s.doc.forEach((n,o)=>{n.attrs.id===t&&L(n)&&(e={n,off:o})}),e&&!e.n.attrs.open&&s.setNodeMarkup(e.off,null,{...e.n.attrs,open:!0})}function T(s,t,e,n,o,i=null){let r=K(t,e,n,o),c=t[e].at,d=t[n].end,p=i??new C(s.doc.resolve(c),s.doc.resolve(d)),a;if(o.at===c||o.at===d){a=s.tr;for(let l=e;l<=n;l++){let h=r(t[l]);h&&a.setNodeMarkup(t[l].at,null,{...t[l].node.attrs,...h})}a.setSelection(p.map(a.doc,a.mapping)),a.setMeta(M,N(t,e,n,o.at,r))}else a=$(s,t,e,n,o.at,r,p);if(o.open){Z(a,o.open);let l=a.getMeta(M);l&&a.setMeta(M,{...l,attrs:{...l.attrs,[o.open]:{open:!0}}})}return a}function U(s,t,e,n,o){if(o.parent!=null&&t.slice(e,n+1).some(a=>a.node.attrs.id===o.parent))return!1;let i=t[n].end-t[e].at,r=K(t,e,n,o);for(let a=e;a<=n;a++)if(y(t[a].node)&&(r(t[a])?.indent??t[a].node.attrs.indent)>F)return!1;let c=T(s,t,e,n,o),p=o.at===t[e].at||o.at===t[n].end?t[e].at:o.at>t[e].at?o.at-i:o.at;return O(c.doc,s.doc).every(a=>a.at>=p&&a.at<p+i)}function V(s,t,e,n,o){let i=new Map;t.forEach(l=>{L(l.node)&&l.node.attrs.id&&i.set(l.node.attrs.id,l.i)});let r=o<0?s.doc.content.size:t[o].at;if(r>t[e].at&&r<t[n].end)return[];let c=(o<0?t.length:o)-1,d=Q(t,i,c),p=d.indexOf(o<0?null:w(t[o].node)),a=[];for(let l of d.slice(Math.max(0,p))){let h=l===null?0:t[i.get(l)].depth+1,x=c>=0&&y(t[c].node)&&w(t[c].node)===l?t[c].node:null,f=y(t[e].node)&&x?x.attrs.indent+1:0;for(let u=0;u<=f;u++){let m={at:r,parent:l,indent:u,depth:h+(y(t[e].node)?u:0)};U(s,t,e,n,m)&&a.push(m)}}return a}function q(s,t,e,n,o){let i=t[o];if(!i||!L(i.node)||i.node.attrs.open||i.hidden||o>=e&&o<=n||i.at>t[e].at&&i.at<t[n].end)return null;let r=i.node.attrs.id,c={at:t[i.subEnd].end,parent:r,indent:0,depth:i.depth+1,open:r};return U(s,t,e,n,c)?c:null}function z(s,t){let e=null;for(let n of s)(!e||Math.abs(n.depth-t)<Math.abs(e.depth-t))&&(e=n);return e}var tt=4,k=56,j=18;function et(s){for(let t=s.parentElement;t;t=t.parentElement){let e=getComputedStyle(t).overflowY;if((e==="auto"||e==="scroll")&&t.scrollHeight>t.clientHeight)return t}return s.ownerDocument.scrollingElement}var G=new WeakMap;function nt(s,t){let e=G.get(s);if(!e){e=[];for(let n of s){if(n.hidden)continue;let o=t.nodeDOM(n.at);o?.getBoundingClientRect&&e.push({i:n.i,dom:o})}G.set(s,e)}return e}function ot(s,t){let e=0,n=s.length;for(;e<n;){let o=e+n>>1,i=s[o].dom.getBoundingClientRect();t<i.top+i.height/2?n=o:e=o+1}return e<s.length?e:-1}var J=class{constructor(t,e,{index:n,onClick:o}){this.view=t,this.grip=e,this.index=n,this.onClick=o,this.shell=t.dom.parentElement,this.line=document.createElement("div"),this.line.className="page-drop",this.line.hidden=!0,this.line.setAttribute("aria-hidden","true"),this.shell.append(this.line),this.state=null,this.onMove=i=>this.move(i),this.onUp=i=>this.end(i),this.onCancel=i=>{i.pointerId===this.state?.pointer&&this.cancel()},this.onKey=i=>{i.key==="Escape"&&this.state?.active&&(i.preventDefault(),i.stopPropagation(),this.cancel())},e.addEventListener("pointerdown",i=>this.start(i))}start(t){if(t.button!==0||this.state)return;let e=this.view.state,n=v(e.doc),o=e.selection,i=Math.min(this.index(),n.length-1),r=o instanceof C&&n[i].at>=o.from&&n[i].end<=o.to,{lo:c,hi:d}=r?o.span(e.doc):D(n,i,i);this.state={index:i,span:H(n,c,d),touch:t.pointerType==="touch",pointer:t.pointerId,x0:t.clientX,y0:t.clientY,x:t.clientX,y:t.clientY,active:!1,raf:0,gap:void 0,targets:[],target:null},this.grip.setPointerCapture?.(t.pointerId),this.grip.addEventListener("pointermove",this.onMove),this.grip.addEventListener("pointerup",this.onUp),this.grip.addEventListener("pointercancel",this.onCancel),this.grip.addEventListener("lostpointercapture",this.onCancel),t.preventDefault()}move(t){let e=this.state;if(!(!e||t.pointerId!==e.pointer)){if(e.x=t.clientX,e.y=t.clientY,!e.active){if(Math.hypot(e.x-e.x0,e.y-e.y0)<=tt)return;if(e.touch)return this.stop();this.begin()}this.track()}}begin(){let t=this.state;if(!t||t.active)return;let e=this.view.state,n=v(e.doc),o=b(n,t.span);if(!o)return this.cancel();t.active=!0,this.view.dispatch(e.tr.setSelection(W(e.doc,o.lo,o.hi))),this.shell.classList.add("is-dragging");let i=this.shell.appendChild(document.createElement("div"));i.style.cssText="position:absolute;visibility:hidden;width:var(--page-indent)",this.indentPx=i.getBoundingClientRect().width||27,i.remove(),this.scroller=et(this.view.dom),window.addEventListener("keydown",this.onKey,!0),this.loop(),this.track()}track(){let t=this.state,e=this.view,n=e.state;if(!t)return;let o=v(n.doc),i=b(o,t.span);if(!i)return this.cancel();let{lo:r,hi:c}=i,d=nt(o,e),p=ot(d,t.y),a=-1,l=null,h=null,x=p<0?d.length:p+1;for(let E=Math.max(0,x-2);E<x;E++){let g=d[E].dom.getBoundingClientRect();t.y>=g.top+g.height/4&&t.y<=g.bottom-g.height/4&&(h={i:d[E].i,bottom:g.bottom}),l=g.bottom+2}p>=0&&(a=d[p].i,l=d[p].dom.getBoundingClientRect().top-2);let f=r<0?null:h&&q(n,o,r,c,h.i),u=f?`summary:${h.i}`:a;(u!==t.gap||n.doc!==t.doc)&&(t.gap=u,t.doc=n.doc,t.targets=r<0?[]:f?[f]:V(n,o,r,c,a)),f&&(l=h.bottom+2);let m=e.dom.getBoundingClientRect().left;t.target=z(t.targets,(t.x-m)/this.indentPx);let B=this.shell.getBoundingClientRect();if(!t.target||l===null){this.line.hidden=!0,this.shell.dataset.drop="none";return}this.shell.dataset.drop="ok",this.line.hidden=!1,this.line.style.setProperty("--page-drop-y",`${l-B.top}px`),this.line.style.setProperty("--page-drop-x",`${m-B.left+t.target.depth*this.indentPx}px`),this.line.style.setProperty("--page-drop-w",`${e.dom.getBoundingClientRect().right-m-t.target.depth*this.indentPx}px`)}loop(){let t=()=>{let e=this.state;if(!e?.active)return;let n=this.scroller,o=n===n.ownerDocument.scrollingElement?{top:0,bottom:window.innerHeight}:n.getBoundingClientRect(),i=0;e.y<o.top+k?i=-j*Math.min(1,(o.top+k-e.y)/k):e.y>o.bottom-k&&(i=j*Math.min(1,(e.y-(o.bottom-k))/k)),i&&(n.scrollTop+=i,this.track()),e.raf=requestAnimationFrame(t)};this.state.raf=requestAnimationFrame(t)}end(t){let e=this.state;if(!e||t.pointerId!==e.pointer)return;if(!e.active){if(this.stop(),t.type==="pointerup"){let l=v(this.view.state.doc),h=b(l,e.span);h&&this.onClick(h.lo)}return}if(this.track(),this.state!==e)return;let n=e.target,o=this.view.state,i=v(o.doc),r=b(i,e.span);if(this.stop(),!n||!r)return;let{lo:c,hi:d}=r;if(!n.open&&(n.at===i[c].at||n.at===i[d].end)&&n.parent===(i[c].node.attrs.parent??null)&&(i[c].node.type.name!=="list_item"||n.indent===i[c].node.attrs.indent))return;this.view.dispatch(X(T(o,i,c,d,n)).scrollIntoView());let a=d-c+1;S(this.view,`Moved ${a} ${a===1?"block":"blocks"}`),this.view.focus()}cancel(){this.stop(),S(this.view,"Move cancelled")}stop(){let t=this.state;t&&(this.state=null,cancelAnimationFrame(t.raf),this.grip.removeEventListener("pointermove",this.onMove),this.grip.removeEventListener("pointerup",this.onUp),this.grip.removeEventListener("pointercancel",this.onCancel),this.grip.removeEventListener("lostpointercapture",this.onCancel),this.grip.releasePointerCapture?.(t.pointer),window.removeEventListener("keydown",this.onKey,!0),this.shell.classList.remove("is-dragging"),delete this.shell.dataset.drop,this.line.hidden=!0)}destroy(){this.stop(),this.line.remove()}};export{v as a,et as b,J as c,st as d,rt as e,at as f};
|
package/dist/m/c-3H6BZDNJ.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{E as pt,J as Q,M as Ee,q as Me,u as Se,v as dt,w as Te}from"./c-4DFEJ2PO.js";import{A as ut,D as xe,E as we,x as ke}from"./c-6CRUUXOX.js";import{a as ht,c as _e,d as $e}from"./c-336SGU5W.js";import{c as Oe,e as Ae,f as ft,g as ve}from"./c-6KEVEQ7L.js";import{A as k,B as Rt,C as ze,D as Pt,E as He,F as Fe,a as Ce,d as j,e as Ie,g as Z,h as Le,k as De,n as B,q as Bt,s as Be,t as Re,v as Pe,w as Ne,z as x}from"./c-5J4E7O4Y.js";import{C as lt,E as L,F as C,G as D,H as O,I as b,J as ct,K as fe,N as U,S as me,T as at,U as Dt,V as ge,W as ye,X as be,b as E,d as It,f as it,g as ae,h as Lt,j as ue,l as de,la as J,m as g,o as pe,p as he}from"./c-WWXIDH4O.js";import{a as X}from"./c-4L3BTFRK.js";var Ke=new WeakMap;function je(n){let t=Ke.get(n);if(t)return t;t={};for(let[e,o]of O(n.attrs.cols).entries()){let s=[];n.forEach(r=>{e<r.childCount&&s.push(r.child(e).textContent.trim())}),t[o]=ye(n.attrs.cols[o].kind,s)}return Ke.set(n,t),t}var us=Object.freeze({text:"Aa",number:"#",date:"\u{1F4C5}"}),ds=Object.freeze({text:"Text",number:"Number",date:"Date"});var Nt=(n,t,e)=>{let o=n.attrs.get(t.baseId),s={};for(let r of xe(e))s[r]=o&&o.has(r)?o.get(r):we(e,r);return e.name==="board"&&Object.assign(s,Se(n.boardFields,t.baseId)),e.name==="table"&&Object.assign(s,Me(n.tableFields,t.baseId,{cols:s.cols,rows:s.rows})),s},Ve=n=>n===void 0?n:JSON.parse(JSON.stringify(n)),Rn=(n,t)=>{let e={},o=n.attrs.get(t.baseId);return o&&o.forEach((s,r)=>{r!=="pos"&&(e[r]=Ve(s))}),e.t=t.t,e};function ks(n,t){let e=t.visible.map(i=>{if(i.opaque){let u=i.recovered?{...Ve(i.fields??{})}:Rn(n,i);return{b:i,type:g.nodes.opaque_block,fields:u,opaque:!0}}let l=g.nodes[i.t]??g.nodes.paragraph;return{b:i,type:l,fields:{...i.fields??Nt(n,i,l)}}}),o=new Map(e.map(i=>[i.b.id,i])),s=i=>(i.b.recovered?n.gone._map.get(pt(i.b.sourceKey,"parent")):n.attrs.get(i.b.baseId)?._map.get("parent"))?.id??{clock:-1,client:-1};for(let i of o.keys()){let l=new Map,u=[],p=i;for(;o.has(p)&&!l.has(p);)l.set(p,u.length),u.push(p),p=o.get(p).fields.parent;if(!l.has(p))continue;let c=u.slice(l.get(p)).reduce((d,h)=>{let f=s(o.get(d)),m=s(o.get(h));return f.clock<m.clock||f.clock===m.clock&&f.client<m.client?d:h});o.get(c).fields.parent=null}let r=e.map(({b:i,type:l,fields:u,opaque:p})=>{if(p){let d=[];for(let h of i.runs)h.hole||(h.br?d.push(g.nodes.hard_break.create()):d.push(g.text(h.text,h.marks)));return l.create({id:i.id,pos:null,raw:u},d)}let a={id:i.id,pos:null,...u};if(l.name==="table"&&Object.keys(a.rows??{}).length&&Object.keys(a.cols??{}).length)return U(g,i.id,{t:"table",...a});if(!l.isTextblock)return l.create(a);let c=[];for(let d of i.runs)d.hole||(d.br?c.push(g.nodes.hard_break.create()):c.push(g.text(d.text,d.marks)));return l.create(a,c)});return r.length?g.nodes.doc.create(null,r):g.nodes.doc.createAndFill()}var M=n=>({status:"refused",code:n}),mt=n=>JSON.parse(JSON.stringify(n)),Pn=["title","owner","due"],Nn=/^\d{4}-\d{2}-\d{2}$/,gt=(n,t)=>n==="title"?typeof t=="string":n==="due"?t===null||typeof t=="string"&&Nn.test(t):t===null||typeof t=="string"&&t.length>0,zn=n=>n!==null&&typeof n=="object"&&!Array.isArray(n);function qe(n,t){let e=t>0?n[t-1]:null,o=n.slice(t).find(r=>e===null||r>e)??null,s=r=>(e===null||r>e)&&(o===null||r<o);for(let[r,i]of[[e,o],[null,o],[e,null]]){if(r!==null&&!L(r)||i!==null&&!L(i)||r!==null&&i!==null&&r>=i)continue;let l=C(r,i);if(s(l))return l}return`${n.reduce((r,i)=>i>r?i:r,"")}V`}function zt(n,t,e){let o=n.map(t),s=e>0?o[e-1]:null,r=e;for(;s!==null&&r<o.length&&o[r]===s;)r++;if(r===e)return{pos:qe(o,e),rekey:[]};let i=o.slice(r).find(u=>u>s)??null,l=[];for(let u=e,p=s;u<=r;u++)l.push(p=qe(i===null?[p]:[p,i],1));return{pos:l[0],rekey:n.slice(e,r).map((u,p)=>[u,l[p+1]])}}var yt=(n,t,e)=>{let{pos:o,rekey:s}=zt(t,r=>n[r].pos,e);for(let[r,i]of s)n[r]={...n[r],pos:i};return o};function vs({pd:n,um:t=null,origins:e=null,render:o=()=>{}}){let s=a=>{if(typeof a!="string")return null;let c=Ee(n,e).visible.find(h=>h.id===a);if(!c||c.t!=="board")return null;let d=c.fields??Nt(n,c,g.nodes.board);return{columns:mt(d.columns??{}),cards:mt(d.cards??{})}},r=(a,c,d,h)=>{let f=Q(a);return t?.stopCapturing(),n.ydoc.transact(()=>{if(!f)Te(n,a,c,d);else for(let m of["columns","cards"])J(c[m])!==J(d[m])&&n.gone.set(pt(f,m),mt(d[m]))},ke),t?.stopCapturing(),o(),h},i=(a,c,d=null)=>O(Object.fromEntries(Object.entries(a.cards).filter(([h,f])=>f.col===c&&h!==d))),l=(a,c)=>c===void 0?a.length:c===null?0:a.indexOf(c)+1,u=(a,c)=>c!=null&&!a.includes(c),p=(a,c)=>{let d=s(a);return d?c(d,mt(d)):M("missing-board")};return{read:a=>s(a),removed(a){return s(a)?Q(a)?{columns:{},cards:{}}:dt(n.boardFields,a):null},createColumn:(a,{name:c="",afterId:d}={})=>p(a,(h,f)=>{if(typeof c!="string")return M("invalid-value");let m=O(h.columns);if(u(m,d))return M("missing-destination");let y=b("c");return f.columns[y]={pos:yt(f.columns,m,l(m,d)),name:c},r(a,h,f,{status:"created",id:y})}),renameColumn:(a,c,d)=>p(a,(h,f)=>Object.hasOwn(h.columns,c)?typeof d!="string"?M("invalid-value"):h.columns[c].name===d?{status:"unchanged"}:(f.columns[c].name=d,r(a,h,f,{status:"changed"})):M("missing-column")),moveColumn:(a,c,{afterId:d=null}={})=>p(a,(h,f)=>{if(!Object.hasOwn(h.columns,c))return M("missing-column");let m=O(h.columns).filter(A=>A!==c);if(u(m,d))return M("missing-destination");let y=l(m,d),S=O(h.columns);return[...m.slice(0,y),c,...m.slice(y)].every((A,K)=>A===S[K])?{status:"unchanged"}:(f.columns[c].pos=yt(f.columns,m,y),r(a,h,f,{status:"moved"}))}),removeColumn:(a,c)=>p(a,(d,h)=>Object.hasOwn(d.columns,c)?(delete h.columns[c],r(a,d,h,{status:"removed",cards:i(d,c).length})):M("missing-column")),restoreColumn:(a,c)=>p(a,(d,h)=>{if(Object.hasOwn(d.columns,c))return{status:"unchanged"};let f=Q(a)?null:dt(n.boardFields,a).columns[c];return f?(h.columns[c]=f,r(a,d,h,{status:"restored"})):M("missing-column")}),createCard:(a,{columnId:c,title:d="",owner:h=null,due:f=null,afterId:m}={})=>p(a,(y,S)=>{if(!Object.hasOwn(y.columns,c))return M("missing-column");if(!gt("title",d)||!gt("owner",h)||!gt("due",f))return M("invalid-value");let A=i(y,c);if(u(A,m))return M("missing-destination");let K=b("k");return S.cards[K]={pos:yt(S.cards,A,l(A,m)),col:c,title:d,...h!==null?{owner:h}:{},...f!==null?{due:f}:{}},r(a,y,S,{status:"created",id:K})}),editCard:(a,c,d)=>p(a,(h,f)=>{if(!Object.hasOwn(h.cards,c))return M("missing-card");if(!zn(d)||!Object.keys(d).length||Object.keys(d).some(y=>!Pn.includes(y)))return M("invalid-field");if(Object.entries(d).some(([y,S])=>!gt(y,S)))return M("invalid-value");let m={...h.cards[c]};for(let[y,S]of Object.entries(d))S===null?delete m[y]:m[y]=S;return J(m)===J(h.cards[c])?{status:"unchanged"}:(f.cards[c]=m,r(a,h,f,{status:"changed"}))}),moveCard:(a,c,{columnId:d,afterId:h=null}={})=>p(a,(f,m)=>{if(!Object.hasOwn(f.cards,c))return M("missing-card");if(!Object.hasOwn(f.columns,d))return M("missing-column");let y=i(f,d,c);if(u(y,h))return M("missing-destination");let S=l(y,h),A=f.cards[c];if(A.col===d){let K=i(f,d);if([...y.slice(0,S),c,...y.slice(S)].every((rt,Bn)=>rt===K[Bn]))return{status:"unchanged"}}return m.cards[c]={...A,col:d,pos:yt(m.cards,y,S)},r(a,f,m,{status:"moved"})}),removeCard:(a,c)=>p(a,(d,h)=>Object.hasOwn(d.cards,c)?(delete h.cards[c],r(a,d,h,{status:"removed"})):M("missing-card")),restoreCard:(a,c)=>p(a,(d,h)=>{if(Object.hasOwn(d.cards,c))return{status:"unchanged"};let f=Q(a)?null:dt(n.boardFields,a).cards[c];return f?(h.cards[c]=f,r(a,d,h,{status:"restored"})):M("missing-card")})}}var bt="page-history-intent",Hn=500,Fn=(n,t)=>{let e=n.resolve(t);return e.depth?e.node(1).attrs.id:null},Kn=n=>(n.storedMarks??n.selection.$from.marks()).map(t=>`${t.type.name}:${JSON.stringify(t.attrs)}`).sort().join(",");function Ft(n,t,e,o){return{kind:"insert",blockId:Fn(n.doc,t),from:t,end:t+o.length,replaced:t!==e,text:o,marks:Kn(n),at:Date.now()}}function Ls(n,t){return!n||!t||n.kind!==t.kind?!1:t.kind==="compose"?n.id===t.id:n.blockId!==t.blockId||t.at-n.at>Hn?!1:t.kind==="insert"?!t.replaced&&t.from===n.end&&t.marks===n.marks&&!(/\s$/.test(n.text)&&/^\S/.test(t.text)):t.direction===n.direction&&(t.direction<0?t.to===n.from:t.from===n.from)}var jn={deleteContentBackward:-1,deleteContentForward:1},Ht=new WeakMap,Vn=1e3,Kt="page-derived";function qn(n){let t=Ht.get(n)??null;return Ht.delete(n),t}function Wn(n,t){if(!t||n.before!==t.doc||Date.now()-t.at>Vn||n.getMeta(Ie)||n.steps.length!==1)return null;let e=n.steps[0];if(e.slice?.size!==0||e.from===e.to)return null;let o=n.before.resolve(e.from),s=n.before.resolve(e.to);return!o.parent.isTextblock||!o.sameParent(s)?null:{kind:"delete",blockId:o.depth?o.node(1).attrs.id:null,direction:t.direction,from:e.from,to:e.to,at:t.at}}function Ds(n,t=null){let e=t?qn(t):null,o=n.filter(i=>!i.getMeta(Kt));if(o.length!==1)return null;let s=o[0],r=s.getMeta("composition");return r!=null?{kind:"compose",id:r,at:Date.now()}:s.getMeta(bt)??Wn(s,e)}function Bs(){return new E.Plugin({props:{handleTextInput(n,t,e,o,s){return n.dispatch(s().setMeta(bt,Ft(n.state,t,e,o))),!0},handleDOMEvents:{beforeinput(n,t){let e=jn[t.inputType];return e&&Ht.set(n,{direction:e,at:Date.now(),doc:n.state.doc}),!1}}}})}function Un(n,t){if(!n||!/<table[\s>]/i.test(n))return null;let e=t.defaultView?.DOMParser??globalThis.DOMParser;if(!e)return null;let o=new e().parseFromString(n,"text/html").body,s=[...o.querySelectorAll("table")].filter(p=>!p.parentElement.closest("table"));if(s.length!==1)return null;let r=o.cloneNode(!0);for(let p of r.querySelectorAll("table, style, script, template, meta, title"))p.remove();if(r.textContent.trim())return null;let i=s[0];return{grid:[...i.querySelectorAll("tr")].filter(p=>p.closest("table")===i).map(p=>[...p.children].filter(a=>a.tagName==="TD"||a.tagName==="TH").map(a=>ct(Pe.parse(a,{topNode:g.nodes.table_cell.create()})))).filter(p=>p.length),own:!!i.querySelector("td[data-col]")}}function Gn(n){if(!n||!n.includes(" "))return null;let{header:t,rows:e}=at(n.replace(/\r?\n$/,""),{delimiter:" "});return{grid:[t,...e],own:!1}}function We(n,t,e=globalThis.document){let o=null;try{o=Un(n,e)}catch{o=null}if(!o)try{o=Gn(t)}catch{o=null}if(!o||!o.grid.length)return null;let s=Math.max(...o.grid.map(r=>r.length));for(let r of o.grid)for(;r.length<s;)r.push("");return{...o,width:s,height:o.grid.length}}function kt(n,{header:t=n.length>1}={}){let e=Math.max(0,...n.map(c=>c.length));if(!e)return null;let o=t?n[0]:[],s=t?n.slice(1):n,r=Array.from({length:e},()=>b("c")),i=D(null,null,e),l=Object.fromEntries(r.map((c,d)=>[c,{pos:i[d],name:lt(o[d]??"").replace(/\s+/g," ").trim()||`Column ${d+1}`}])),u=s.length?s:[[]],p=D(null,null,u.length),a=Object.fromEntries(u.map((c,d)=>[b("r"),{pos:p[d],cells:Object.fromEntries(r.map((h,f)=>[h,c[f]??""]))}]));return U(g,b(),{t:"table",pos:null,cols:l,rows:a})}var{Plugin:Yn,TextSelection:Jn}=E,jt=g.nodes;var Je=(n,t)=>{let e=null;return n.forEach((o,s)=>{!e&&o.type===jt.table&&o.attrs.id===t&&(e={node:o,pos:s})}),e};function N(n,t){if(!t)return null;let e=Je(n,t.table);if(!e)return null;let o=[];e.node.forEach(h=>o.push(h.attrs.id));let s=O(e.node.attrs.cols),r=[o.indexOf(t.anchor[0]),o.indexOf(t.head[0])],i=[s.indexOf(t.anchor[1]),s.indexOf(t.head[1])];if(r.includes(-1)||i.includes(-1))return null;let l=Math.min(...r),u=Math.max(...r),p=Math.min(...i),a=Math.max(...i),c=[],d=e.pos+1;return e.node.forEach((h,f,m)=>{if(m>=l&&m<=u){let y=[],S=d+1;h.forEach((A,K,rt)=>{rt>=p&&rt<=a&&y.push({cell:A,pos:S}),S+=A.nodeSize}),c.push(y)}d+=h.nodeSize}),{...e,top:l,bottom:u,left:p,right:a,cells:c}}var tt=(n,t)=>{let e=n.resolve(t);for(let o=e.depth;o>0;o--)if(e.node(o).type===jt.table_cell&&o>=3)return{table:e.node(o-2).attrs.id,row:e.node(o-1).attrs.id,col:e.node(o).attrs.col,start:e.start(o)};return null};function xt(n,t,e){let o=tt(n.state.doc,t),s=tt(n.state.doc,e);if(!o||!s||o.table!==s.table)return!1;let r={table:o.table,anchor:[o.row,o.col],head:[s.row,s.col]},i=n.state.tr.setSelection(Jn.create(n.state.doc,s.start)).setMeta(x,r);n.dispatch(i);let l=N(n.state.doc,r),u=l?(l.bottom-l.top+1)*(l.right-l.left+1):0;return j(n,`${u} ${u===1?"cell":"cells"} selected`),!0}function Xs(n,t,e,o){let s=n.state.doc.nodeAt(t);if(s?.type!==jt.table||!s.childCount)return!1;let r=s.childCount-1,i=s.child(0).childCount-1,l=(u,p)=>{let a=t+1;for(let c=0;c<u;c++)a+=s.child(c).nodeSize;a++;for(let c=0;c<p;c++)a+=s.child(u).child(c).nodeSize;return a+1};return e==="row"?xt(n,l(o,0),l(o,i)):xt(n,l(0,o),l(r,o))}var Qn=new Set(["Shift","Control","Alt","Meta","CapsLock"]),Xn=n=>/[\t\n\r"]/.test(n)?`"${n.replace(/"/g,'""')}"`:n;function Zn(n,t){let e=n.cells.map(r=>r.map(({cell:i})=>Xn(lt(ct(i)))).join(" ")).join(`
|
|
2
|
-
`),o=t.createElement("table"),s=o.appendChild(t.createElement("tbody"));for(let r of n.cells){let i=s.appendChild(t.createElement("tr"));for(let{cell:l}of r){let u=i.appendChild(t.createElement("td"));u.dataset.col=l.attrs.col,u.append(Ne.serializeFragment(l.content,{document:t}))}}return{text:e,html:o.outerHTML}}function Ue(n,t){let e=N(n.doc,x.getState(n));if(!e)return!1;if(t){let o=n.tr;for(let s of[...e.cells].reverse())for(let{cell:r,pos:i}of[...s].reverse())r.content.size&&o.delete(i+1,i+r.nodeSize-1);o.setMeta(x,x.getState(n)),t(k(o))}return!0}var Ge=(n,t,e)=>{let{text:o,html:s}=Zn(t,e.dom.ownerDocument);n.clipboardData.setData("text/plain",o),n.clipboardData.setData("text/html",s),n.preventDefault()},to=(n,t)=>(e,o,s)=>{let r=x.getState(e),i=N(e.doc,r);if(!i||!s)return!1;let l=[],u=O(i.node.attrs.cols);i.node.forEach(c=>l.push(c.attrs.id));let p=Math.max(0,Math.min(l.length-1,l.indexOf(r.head[0])+n)),a=Math.max(0,Math.min(u.length-1,u.indexOf(r.head[1])+t));return o&&o(e.tr.setMeta(x,{...r,head:[l[p],u[a]]})),!0},Ye=(n,t)=>{let e=t.target?.closest?.("td");if(!e||!n.dom.contains(e))return null;try{return n.posAtDOM(e,0)}catch{return null}};function Zs(){let n=null;return new Yn({key:x,state:{init:()=>null,apply(t,e,o,s){let r=t.getMeta(x);return r!==void 0?r:!e||t.selectionSet||t.docChanged&&!t.getMeta(ut)?null:N(s.doc,e)?e:null}},props:{attributes:t=>x.getState(t)?{class:"has-cell-rect"}:{},createSelectionBetween:t=>x.getState(t.state)?t.state.selection:null,decorations(t){let e=N(t.doc,x.getState(t));return e?It.DecorationSet.create(t.doc,e.cells.flat().map(({cell:o,pos:s})=>It.Decoration.node(s,s+o.nodeSize,{class:"is-cell-selected"}))):null},handleKeyDown(t,e){let o=t.state;if(!x.getState(o))return!1;if(e.key==="Escape")return t.dispatch(o.tr.setMeta(x,null)),!0;if(e.key==="Backspace"||e.key==="Delete")return Ue(o,t.dispatch);if(e.shiftKey){let s={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]}[e.key];if(s)return to(...s)(o,t.dispatch,t)}return Qn.has(e.key)||(e.metaKey||e.ctrlKey)&&(e.key==="a"||e.key==="c"||e.key==="x"||e.key==="v")||t.dispatch(o.tr.setMeta(x,null)),!1},handleDOMEvents:{mousedown(t,e){if(e.button!==0)return!1;!e.shiftKey&&x.getState(t.state)&&t.dispatch(t.state.tr.setMeta(x,null));let o=Ye(t,e);if(o===null)return!1;if(e.shiftKey){let u=x.getState(t.state),p=(u&&eo(t.state.doc,u))??t.state.selection.$anchor.pos;return tt(t.state.doc,p)?(e.preventDefault(),xt(t,p,o)):!1}let s=t.dom.ownerDocument,r=o,i=u=>{let p=Ye(t,u);if(p===null)return;let a=tt(t.state.doc,r),c=tt(t.state.doc,p);if(!a||!c||a.table!==c.table)return;let d=x.getState(t.state);a.row===c.row&&a.col===c.col&&!d||d&&d.head[0]===c.row&&d.head[1]===c.col||(u.preventDefault(),xt(t,r,p))},l=()=>{s.removeEventListener("mouseover",i),s.removeEventListener("mouseup",l),n=null};return n?.(),n=l,s.addEventListener("mouseover",i),s.addEventListener("mouseup",l),!1},copy(t,e){let o=N(t.state.doc,x.getState(t.state));return!o||!e.clipboardData?!1:(Ge(e,o,t),!0)},cut(t,e){let o=N(t.state.doc,x.getState(t.state));return!o||!e.clipboardData?!1:(Ge(e,o,t),Ue(t.state,t.dispatch),!0)}}},view:()=>({destroy:()=>n?.()})})}function eo(n,t){let e=Je(n,t.table),o=null;return e?.node.forEach((s,r)=>{if(s.attrs.id!==t.anchor[0])return;let i=e.pos+1+r+1;s.forEach(l=>{l.attrs.col===t.anchor[1]&&(o=i+1),i+=l.nodeSize})}),o}var Qe=n=>{let t=N(n.doc,x.getState(n));return t?{row:t.top,cell:t.left,rows:t.bottom-t.top+1,cols:t.right-t.left+1}:null};var Xe=new WeakMap;var{Plugin:no,TextSelection:V}=E,w=g.nodes,qt=256*1024,P=n=>O(n.attrs.cols),Ze=n=>{let t=n.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type===w.table){let o=t.node(e),s=e<t.depth?t.index(e):0,r=e+1<t.depth?t.index(e+1):0;return{table:o,pos:t.before(e),row:s,cell:r}}return null},et=(n,t,e,o)=>{let s=n.nodeAt(t);if(!s||!s.childCount)return null;e=Math.max(0,Math.min(e,s.childCount-1)),o=Math.max(0,Math.min(o,s.child(e).childCount-1));let r=t+1;for(let i=0;i<e;i++)r+=s.child(i).nodeSize;r++;for(let i=0;i<o;i++)r+=s.child(e).child(i).nodeSize;return r+1},wt=(n,t=C())=>w.table_row.create({id:b("r"),pos:t},n.map(e=>w.table_cell.create({col:e}))),v=(n,t,e)=>w.table.create({...n.attrs,...t},e);function _(n,t,e){let o=Ze(n);if(!o)return!1;let s=e(o.table,o);if(!s)return!1;if(t){let{table:r,row:i=o.row,cell:l=o.cell}=s,u=n.tr.replaceWith(o.pos,o.pos+o.table.nodeSize,r),p=et(u.doc,o.pos,i,l);p!==null&&u.setSelection(V.create(u.doc,p)),t(k(u))}return!0}function R(n,t,e,o=null,s=null,r=null){r??=o?n.doc.resolve(o.from).index(0):n.selection.$head.index(0);let i=n.doc.child(r),l=0;for(let d=0;d<r;d++)l+=n.doc.child(d).nodeSize;let u=i.isTextblock&&(i.content.size===0||o?.from===l+1&&o?.to===l+i.nodeSize-1),p=n.doc.maybeChild(r+1),a=u?i.attrs.pos:C(i.attrs.pos,p?.attrs.pos??null),c=e.type.create({...e.attrs,pos:a,parent:i.attrs.parent??null},e.content);if(t){let d=n.tr;o&&d.delete(o.from,o.to);let h=d.mapping.map(l),f=d.doc.child(r),m=u?h:h+f.nodeSize;if(d.replaceWith(m,u?h+f.nodeSize:m,c),s){let y=s.type.create({...s.attrs,pos:C(a,p?.attrs.pos??null),parent:i.attrs.parent??null},s.content);d.insert(m+c.nodeSize,y)}d.setSelection(V.create(d.doc,et(d.doc,m,0,0))),t(k(d).scrollIntoView())}return!0}function tn(n=3,t=3){if(!Number.isInteger(n)||!Number.isInteger(t)||n<1||t<1)return null;let e=Array.from({length:t},()=>b("c")),o=D(null,null,t),s=Object.fromEntries(e.map((l,u)=>[l,{pos:o[u],name:`Column ${u+1}`}])),i=D(null,null,n).map(l=>wt(e,l));return w.table.create({id:b(),cols:s},i)}var Wt=n=>(t,e)=>{let o=Ze(t);if(!o||t.selection.$head.parent.type!==w.table_cell)return!1;let s=o.table.child(o.row).childCount,r=o.row,i=o.cell;return n==="down"?r++:(i+=n,i>=s&&(r++,i=0),i<0&&(r--,i=s-1)),r<0?!0:r>=o.table.childCount?n===-1?!0:oo(t,e,o,i):(e&&e(t.tr.setSelection(V.create(t.doc,et(t.doc,o.pos,r,i))).scrollIntoView()),!0)};function oo(n,t,e,o){let s=[...e.table.content.content];if(s.push(wt(P(e.table),C(s.at(-1).attrs.pos,null))),t){let r=n.tr.replaceWith(e.pos,e.pos+e.table.nodeSize,v(e.table,{sort:null},s));r.setSelection(V.create(r.doc,et(r.doc,e.pos,s.length-1,o))),t(k(r).scrollIntoView())}return!0}var so=Wt(1),ro=Wt(-1),io=Wt("down"),lo=(n=!0)=>(t,e)=>_(t,e,(o,s)=>{let r=[...o.content.content],i=s.row+(n?1:0),l=C(r[i-1]?.attrs.pos??null,r[i]?.attrs.pos??null);return r.splice(i,0,wt(P(o),l)),{table:v(o,{sort:null},r),row:i}}),mr=(n,t)=>_(n,t,(e,o)=>{let s=[...e.content.content];if(s.length===1){let r=s[0];s[0]=w.table_row.create(r.attrs,P(e).map(i=>w.table_cell.create({col:i})))}else s.splice(o.row,1);return{table:v(e,{sort:null},s),row:Math.min(o.row,s.length-1)}}),en=(n,t,e,o,s)=>{let{pos:r,rekey:i}=zt(t,u=>n[u]?.pos??"",e),l={...n,[o]:{...s,pos:r}};for(let[u,p]of i)l[u]={...l[u],pos:p};return l},gr=(n=!0)=>(t,e)=>_(t,e,(o,s)=>{let r=P(o),i=s.cell+(n?1:0),l=b("c"),u=en(o.attrs.cols,r,i,l,{name:`Column ${r.length+1}`}),p=o.content.content.map(a=>{let c=[...a.content.content];return c.splice(i,0,w.table_cell.create({col:l})),w.table_row.create(a.attrs,c)});return{table:v(o,{cols:u},p),cell:i}}),yr=(n,t)=>_(n,t,(e,o)=>{let s=P(e);if(s.length<=1)return null;let r={...e.attrs.cols};delete r[s[o.cell]];let i=e.content.content.map(l=>w.table_row.create(l.attrs,l.content.content.filter((u,p)=>p!==o.cell)));return{table:v(e,{cols:r,sort:e.attrs.sort?.col===s[o.cell]?null:e.attrs.sort},i),cell:Math.min(o.cell,s.length-2)}}),br=n=>(t,e)=>_(t,e,(o,s)=>{let r=s.row+n;if(r<0||r>=o.childCount)return null;let i=[...o.content.content],[l]=i.splice(s.row,1);i.splice(r,0,l);let u=C(i[r-1]?.attrs.pos??null,i[r+1]?.attrs.pos??null);return i[r]=w.table_row.create({...l.attrs,pos:u},l.content),{table:v(o,{sort:null},i),row:r}}),kr=n=>(t,e)=>_(t,e,(o,s)=>{let r=P(o),i=s.cell+n;if(i<0||i>=r.length)return null;let l=[...r],[u]=l.splice(s.cell,1);l.splice(i,0,u);let p=en(o.attrs.cols,l.filter(c=>c!==u),i,u,o.attrs.cols[u]),a=o.content.content.map(c=>{let d=[...c.content.content],[h]=d.splice(s.cell,1);return d.splice(i,0,h),w.table_row.create(c.attrs,d)});return{table:v(o,{cols:p},a),cell:i}}),co=48,ao=1200,xr=160,uo=n=>Number.isFinite(n)&&n>0?Math.round(Math.min(ao,Math.max(co,n))):null,wr=(n,t)=>(e,o)=>_(e,o,s=>{let r=s.attrs.cols[n];if(!r)return null;let i=t===null?null:uo(t);if(t!==null&&i===null||(r.width??null)===i)return null;let{width:l,...u}=r,p={...s.attrs.cols,[n]:i===null?u:{...r,width:i}};return{table:v(s,{cols:p},s.content),cell:P(s).indexOf(n)}}),Mr=(n,t)=>(e,o)=>_(e,o,s=>{if(!s.attrs.cols[n]||!String(t).trim())return null;let r={...s.attrs.cols,[n]:{...s.attrs.cols[n],name:String(t).trim()}};return{table:v(s,{cols:r},s.content)}}),Sr=(n,t)=>(e,o)=>_(e,o,s=>{if(!s.attrs.cols[n]||!(t==="auto"||ge.includes(t)))return null;let{kind:r,...i}=s.attrs.cols[n],l={...s.attrs.cols,[n]:t==="auto"?i:{...s.attrs.cols[n],kind:t}};return{table:v(s,{cols:l,sort:s.attrs.sort?.col===n?null:s.attrs.sort},s.content)}}),Tr=(n,t="asc")=>(e,o)=>_(e,o,s=>{if(!s.attrs.cols[n]||!["asc","desc"].includes(t))return null;let r=P(s).indexOf(n),i=je(s)[n],l=[...s.content.content].map((a,c)=>({row:a,previous:c,text:a.child(r).textContent.trim()}));l.sort((a,c)=>{if(!a.text||!c.text)return!a.text&&!c.text?a.previous-c.previous:a.text?-1:1;let d=i==="number"?Dt(a.text):a.text,h=i==="number"?Dt(c.text):c.text;if(d==null||h==null)return d==null&&h==null?a.previous-c.previous:d==null?1:-1;let f=i==="number"?d-h:i==="date"?d<h?-1:d>h?1:0:d.localeCompare(h,void 0,{numeric:!0,sensitivity:"base"});return f?t==="asc"?f:-f:a.previous-c.previous});let u=D(null,null,l.length),p=l.map(({row:a},c)=>w.table_row.create({...a.attrs,pos:u[c]},a.content));return{table:v(s,{sort:{col:n,dir:t}},p)}}),Vt=(n,t=null)=>(e,o)=>_(e,o,(s,r)=>{let i=P(s),l=t?.row??r.row,u=t?.cell??r.cell,p=[...s.content.content];n.forEach((c,d)=>{let h=l+d;h>=p.length&&p.push(wt(i,C(p.at(-1).attrs.pos,null)));let f=[...p[h].content.content];c.forEach((m,y)=>{u+y<i.length&&(f[u+y]=w.table_cell.create({col:i[u+y]},fe(g,m)))}),p[h]=w.table_row.create(p[h].attrs,f)});let a=Math.max(1,...n.map(c=>c.length));return{table:v(s,{sort:null},p),row:l+n.length-1,cell:Math.min(u+a-1,i.length-1)}}),po=n=>new TextEncoder().encode(JSON.stringify(n.toJSON())).length;function ho(n,t){let e=t.clipboardData;if(!e||e.files?.length)return!1;let o=n.state;if(o.selection.$from.parent.type.spec.code)return!1;let s=Qe(o),r=e.getData("text/plain").replace(/\r?\n$/,""),i=We(e.getData("text/html"),e.getData("text/plain"),n.dom.ownerDocument)??(s&&r&&!/[\r\n]/.test(r)?{grid:[[r]],width:1,height:1,own:!1}:null);if(!i)return!1;if(s&&s.rows*s.cols>1&&i.width*i.height===1)return Vt(Array.from({length:s.rows},()=>Array(s.cols).fill(i.grid[0][0])),{row:s.row,cell:s.cell})(o,n.dispatch);if(s)return Vt(i.grid,{row:s.row,cell:s.cell})(o,n.dispatch);if(o.selection.$head.parent.type===w.table_cell)return i.width*i.height<2?!1:Vt(i.grid)(o,n.dispatch);if(i.width*i.height<2||i.height<2&&!/<table[\s>]/i.test(e.getData("text/html")))return!1;let l=kt(i.grid,{header:!i.own&&i.height>1});if(!l)return!1;if(po(l)>qt)return X("This paste is too large for one table.","error"),!0;let{from:u,to:p,empty:a,$from:c,$to:d}=o.selection;if(!a&&c.index(0)!==d.index(0)){let h=o.tr.deleteSelection();return R(o.apply(h),f=>{for(let m of f.steps)h.step(m);h.setSelection(V.create(h.doc,f.selection.from)),n.dispatch(k(h).scrollIntoView())},l)}return R(o,n.dispatch,l,a?null:{from:u,to:p})}var Er=it.keymap({Tab:so,"Shift-Tab":ro,Enter:io,"Mod-Enter":lo(!0)});function Cr(){return new no({props:{handlePaste:ho,handleClickOn(n,t,e,o,s,r){if(e.type!==w.table_cell||!r||s.button)return!1;let i=n.nodeDOM(o),l=i&&Xe.get(i);return l&&l.openDate(),!1}},appendTransaction(n,t,e){if(!n.some(r=>r.docChanged&&!r.getMeta(ut)))return null;let o=new Map;t.doc.forEach(r=>{r.type===w.table&&o.set(r.attrs.id,r)});let s=e.tr;return e.doc.forEach((r,i)=>{if(r.type!==w.table||!r.attrs.sort)return;let l=o.get(r.attrs.id),u=r.attrs.sort.col;if(!l)return;let p=d=>Object.fromEntries(d.content.content.map(h=>[h.attrs.id,h.content.content.find(f=>f.attrs.col===u)?.textContent])),a=p(l),c=p(r);(Object.keys(a).length!==Object.keys(c).length||Object.keys(a).some(d=>a[d]!==c[d]||!Object.hasOwn(c,d)))&&s.setNodeMarkup(i,null,{...r.attrs,sort:null})}),s.docChanged?s.setMeta(Kt,!0):null}})}function Or(n,t,e){let o=n.state.doc.nodeAt(t);if(o?.type!==w.table_cell)return!1;let s=n.state.tr.replaceWith(t+1,t+o.nodeSize-1,e?g.text(e):[]);return n.dispatch(s.setSelection(V.create(s.doc,t+1+e.length))),!0}function Ar(n,t,e,o){let s=et(n.state.doc,t,e,o);return s===null?!1:(n.dispatch(n.state.tr.setSelection(V.create(n.state.doc,s))),!0)}var{TextSelection:fo}=E,Ut=g.nodes,mo=Object.freeze(["To do","In progress","Done"]),nn=(n,t)=>L(n)&&(t===null||L(t)&&n<t)?C(n,t):null;function Gt(n=mo){let t=D(null,null,n.length),e=Object.fromEntries(n.map((o,s)=>[b("c"),{pos:t[s],name:o}]));return Ut.board.create({id:b(),columns:e,cards:{}})}function on(n,t,e=Gt(),o=null,s=null){let r=n.tr;o&&r.delete(o.from,o.to),s??=r.doc.resolve(r.mapping.map(n.selection.head)).index(0);let i=Z(r.doc),l=r.doc.child(s),u=l.isTextblock&&l.content.size===0,p=u?s:i[s].subEnd,a=u?i[s].at:i[p].end,c=i[p+1]?.node.attrs.pos??null,d=l.attrs.parent??null,h=u?l.attrs.pos:nn(i[p].node.attrs.pos,c),f=Ut.board.create({...e.attrs,pos:h,parent:d}),m=Ut.paragraph.create({id:b(),pos:nn(h,c),parent:d});return r.replaceWith(a,u?i[s].end:a,[f,m]),r.setSelection(fo.create(r.doc,a+f.nodeSize+1)),t&&t(k(r).scrollIntoView()),!0}function sn(n){let t=[];return n.forEach(e=>{e.type===g.nodes.table&&O(e.attrs.cols).length&&t.push(e)}),t}var{TextSelection:Jt}=E,I=g.nodes,z=[{key:"text",label:"Text",description:"Plain writing",icon:"T",type:"paragraph",aliases:["p","paragraph","plain"]},{key:"h1",label:"Heading 1",description:"Big section heading",icon:"H1",type:"heading",attrs:{level:1},hint:"#",aliases:["h1","title"]},{key:"h2",label:"Heading 2",description:"Medium section heading",icon:"H2",type:"heading",attrs:{level:2},hint:"##",aliases:["h2","subtitle"]},{key:"h3",label:"Heading 3",description:"Small section heading",icon:"H3",type:"heading",attrs:{level:3},hint:"###",aliases:["h3"]},{key:"bullet",label:"Bulleted list",description:"A simple list",icon:"\u2022",type:"list_item",attrs:{kind:"bullet"},hint:"-",aliases:["ul","bullet","list","unordered"]},{key:"ordered",label:"Numbered list",description:"A list with numbers",icon:"1.",type:"list_item",attrs:{kind:"ordered"},hint:"1.",aliases:["ol","num","numbered","ordered"]},{key:"check",label:"Checklist",description:"Tasks to tick off",icon:"\u2610",type:"list_item",attrs:{kind:"check"},hint:"[]",aliases:["todo","to-do","task","check","checkbox"]},{key:"toggle",label:"Toggle",description:"Hide details under a line",icon:"\u25B8",type:"toggle",attrs:{open:!0},hint:">",aliases:["collapse","details","fold"]},{key:"callout",label:"Callout",description:"Make a note stand out",icon:"!",type:"callout",aliases:["note","aside","info"]},{key:"quote",label:"Quote",description:"Set text apart as a quotation",icon:"\u201C",type:"quote",hint:'"',aliases:["blockquote","quotation","cite"]},{key:"code",label:"Code",description:"Code with highlighting",icon:"</>",type:"code_block",hint:"```",aliases:["pre","snippet"]}],go=[{key:"divider",label:"Divider",description:"A line between sections",icon:"\u2014",hint:"---",aliases:["hr","line","separator","rule"],insert:"divider"},{key:"image",label:"Image",description:"Upload or paste a picture",icon:"\u25A3",aliases:["img","picture","photo"],insert:"image"},{key:"file",label:"File",description:"Attach any file",icon:"\u2398",aliases:["upload","attachment","pdf"],insert:"file"},{key:"table",label:"Table",description:"Rows and columns, paste from a spreadsheet",icon:"\u25A6",aliases:["grid","spreadsheet"],insert:"table"},{key:"csv",label:"Import CSV\u2026",description:"Turn a CSV file into a table",icon:"\u21E7",aliases:["comma separated","import"],insert:"csv"},{key:"board",label:"Board",description:"Cards in columns, like a kanban",icon:"\u25A5",aliases:["kanban","cards","columns","status"],insert:"board"}],yo={key:"chart",label:"Chart",description:"A bar or line chart from a table",icon:"\u{1F4CA}",aliases:["graph","plot","bar","line"],insert:"chart"},Qt=n=>($e.get(n)?.ensure("chart")??Promise.resolve()).catch(()=>{}).then(()=>import("./c-E4LIR5X5.js")),St=[...z,...go],ln=(n,t=St)=>sn(n.doc).length?[...t,yo]:t;function Tt(n){let t=n.type.name;return z.find(e=>e.type===t&&(!e.attrs||(t==="heading"?e.attrs.level===n.attrs.level:t==="list_item"?e.attrs.kind===n.attrs.kind:!0)))??z[0]}var cn=(n,t)=>{let e=0;for(let o=0;o<t;o++)e+=n.child(o).nodeSize;return e};function q(n,t,e){let o=cn(n.doc,t),s=n.doc.child(t),r={id:s.attrs.id,pos:s.attrs.pos,parent:s.attrs.parent};return s.type===I.list_item&&e.type==="list_item"&&(r.indent=s.attrs.indent),n.setBlockType(o+1,o+s.nodeSize-1,I[e.type],{...r,...e.attrs||{}})}var bo=Object.freeze({status:"refused",code:"unsupported-format"}),ko=he([]).type,xo=n=>{let t=!1;return n.forEach(e=>{!t&&e.marks.some(pe)&&(t=!0)}),t};function nt(n,t){return!n.isTextblock||n.type===I.opaque_block?!1:!xo(n)||I[t.type].allowsMarkType(ko)}function an(n,t,e=n.tr){let o=Z(e.doc),{to:s}=Le(o,t),r=e.doc.child(t);return e.insert(s,I.paragraph.create({parent:r.attrs.parent??null})),e.setSelection(Jt.create(e.doc,s+1))}var Yt=(n,t)=>L(n)&&(t===null||L(t)&&n<t)?C(n,t):null;function Xt(n,t){let e=cn(n.doc,t),o=n.doc.child(t),s=n.doc.maybeChild(t+1),{id:r,pos:i,parent:l}=o.attrs;return n.replaceWith(e,e+o.nodeSize,[I.divider.create({id:r,pos:i,parent:l}),I.paragraph.create({id:b(),pos:Yt(i,s?s.attrs.pos:null),parent:l})]),n.setSelection(Jt.create(n.doc,e+2))}function wo(n,t,e=n.tr){let o=e.doc.child(t);if(o.type===I.paragraph&&o.content.size===0)return Xt(e,t);let s=Z(e.doc),r=s[t].subEnd,i=s[r].end,l=s[r+1]?.node.attrs.pos??null,u=Yt(s[r].node.attrs.pos,l),p=o.attrs.parent??null;return e.insert(i,[I.divider.create({id:b(),pos:u,parent:p}),I.paragraph.create({id:b(),pos:Yt(u,l),parent:p})]),e.setSelection(Jt.create(e.doc,i+2))}function Mo(n,t){if(n.length<2||n.length>32)return 1/0;let e=-1,o=0;for(let s of n){let r=t.indexOf(s,e+1);if(r<0)return 1/0;o+=r-e-1,e=r}return o}function un(n,t){let e=t.trim().toLowerCase();if(!e)return n;let o=s=>{let r=s.label.toLowerCase(),i=[s.key,...s.aliases||[],...s.hint?[s.hint]:[]].map(u=>u.toLowerCase());if(r===e||i.includes(e))return[0,0];if(r.startsWith(e))return[1,0];if([...r.split(/\s+/),...i].some(u=>u.startsWith(e)))return[2,0];if([r,...i].some(u=>u.includes(e)))return[3,0];if(e.length>=3&&s.description&&s.description.toLowerCase().split(/[^a-z0-9]+/).some(u=>u.startsWith(e)))return[4,0];let l=Math.min(...[r,s.key,...s.aliases||[]].map(u=>Mo(e,u.toLowerCase())));return l===1/0?null:[5,l]};return n.map((s,r)=>({it:s,order:r,rank:o(s)})).filter(s=>s.rank).sort((s,r)=>s.rank[0]-r.rank[0]||s.rank[1]-r.rank[1]||s.order-r.order).map(s=>s.it)}function dn(n,t,e,o=null){return t.type!=="quote"?rn(n,t,e,o):import("./c-DFS4XZJV.js").then(({runFormat:s})=>s(n,()=>rn(n,t,e,o)))}function rn(n,t,e,o=null){let s=n.state;if(t.insert==="image"||t.insert==="file")return Ae(n,t.insert==="image"?"image/*":"",Oe(s,e),o);if(t.insert==="csv")return Mt(n,o);if(t.insert==="table")return R(s,n.dispatch,tn(),o,null,e);if(t.insert==="board")return on(s,n.dispatch,Gt(),o,e);if(t.insert==="chart")return Qt(n).then(({chartFromSlash:l})=>l(n,e,o));let r=s.tr;o&&r.delete(o.from,o.to);let i=r.doc.child(e);return i.isTextblock&&i.content.size===0&&!nt(i,t)?bo:(t.insert==="divider"?r=wo(s,e,r):i.isTextblock&&i.content.size===0?r=q(r,e,t):(r=an(s,e,r),r=q(r,r.doc.resolve(r.selection.head).index(0),t)),n.dispatch(k(r).scrollIntoView()),n.focus(),!0)}var{InputRule:ee}=Lt,H=g.nodes,Et=(n,t,e)=>n.doc.rangeHasMark(t,e,g.marks.code)||!!g.marks.code.isInSet(n.storedMarks||n.selection.$from.marks()),G=(n,t,e=["paragraph"],o=!1)=>new ee(n,(s,r,i,l)=>{let u=s.doc.resolve(i);return!s.selection.empty||u.depth!==1||u.parentOffset!==0||!e.includes(u.parent.type.name)||o&&l!==u.end()||Et(s,i,l)?null:k(q(s.tr.delete(i,l),u.index(0),typeof t=="function"?t(r):t))}),So=new ee(/^---$/,(n,t,e,o)=>{let s=n.doc.resolve(e);return!n.selection.empty||s.depth!==1||s.parent.type!==H.paragraph||s.parentOffset!==0||s.parent.content.size!==o-e||Et(n,e,o)?null:k(Xt(n.tr,s.index(0)))}),ne=`\\s\\(\\[\\{'\u2018\u201C"`,To=new RegExp(`[${ne}]`),Zt=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),pn=n=>`([^\\s${n}](?:[\\s\\S]*?[^\\s${n}])?)`,Ct=(n,t)=>!!n?.isComposing||n?.keyCode===229||!!t?.composing,hn=n=>{let t=0;for(let e=n.length-1;e>=0&&n[e]==="\\";e--)t++;return t},Eo=(n,t)=>{let e=n.doc.resolve(t);return!e.parent.inlineContent||hn(e.parent.textBetween(0,e.parentOffset,null,"\uFFFC"))%2?!1:e.parentOffset===0||To.test(e.parent.textBetween(e.parentOffset-1,e.parentOffset))},Co=(n,t,e,o,s)=>{let r=s(t);if(!r||!n.selection.empty||e<0||e>o||o>n.doc.content.size)return null;let i=n.doc.resolve(e),l=n.doc.resolve(o);if(!i.sameParent(l)||!i.parent.inlineContent)return null;let[u,p,a,c]=t;if(Et(n,e,o))return null;let d=u.slice(p.length,u.length-a.length-c.length),h=e+p.length;if(!Eo(n,h)||hn(u.slice(0,u.length-c.length))%2)return null;let f=u.length-(o-e);if(f<0)return null;let m=n.tr;f&&m.insertText(u.slice(-f),o,o);let y=h+d.length,S=y+a.length;return m.delete(S,e+u.length),m.delete(h,y),m.addMark(h,h+a.length,r),m.removeStoredMark(r.type),k(m)},fn=(n,t)=>new ee(n,(e,o,s,r)=>Co(e,o,s,r,t),{inCodeMark:!1}),Y=(n,t,e)=>fn(new RegExp(`(^|[${ne}])${Zt(n)}${pn(Zt(t))}(${Zt(t)})$`),()=>e.create()),Oo=fn(new RegExp(`(^|[${ne}])\\[${pn("\\[\\]")}(\\]\\([^()\\s]*\\))$`),n=>{let t=ue(n[3].slice(2,-1));return t?g.marks.link.create({href:t}):null}),Ao=[Y("**","**",g.marks.strong),Y("__","__",g.marks.strong),Y("*","*",g.marks.em),Y("_","_",g.marks.em),Y("`","`",g.marks.code),Y("~~","~~",g.marks.strike),Oo],te=["paragraph","list_item"],vo=[G(/^(#{1,3})\s$/,n=>({type:"heading",attrs:{level:n[1].length}})),G(/^[-*+]\s$/,{type:"list_item",attrs:{kind:"bullet"}},te),G(/^\d+[.)]\s$/,{type:"list_item",attrs:{kind:"ordered"}},te),G(/^\[( |x|X)?\]\s$/,n=>({type:"list_item",attrs:{kind:"check",checked:!!n[1]&&n[1]!==" "}}),te),G(/^>\s$/,{type:"toggle",attrs:{open:!0}}),G(/^```$/,{type:"code_block"},["paragraph"],!0),So,...Ao];function _o(n,t,e,o,s){if(s!==" "||e!==o)return!1;let r=t.state,i=r.doc.resolve(e),l=i.parent;if(i.depth!==1||l.type!==H.paragraph||i.parentOffset!==1||l.textContent!=='"'||!t.editable||typeof t.runFormatCommand!="function")return!1;let u=()=>{t.isDestroyed||t.dispatch(r.tr.insertText(" ",e,o))},p=i.before(1);return import("./c-DFS4XZJV.js").then(({quoteFromSpace:a})=>a(n,t,{at:p,from:e,to:o},u),u),!0}var ri=()=>{let n=Lt.inputRules({rules:vo}),t=n.props.handleTextInput;return n.props.handleTextInput=(e,o,s,r)=>_o(n,e,o,s,r)||t(e,o,s,r),n},$o=/^\s*\|(.*)\|\s*$/;function Io(n,t){let{$from:e,empty:o}=n.selection;if(!o||e.depth!==1||e.parent.type!==H.paragraph||e.parentOffset!==e.parent.content.size||Et(n,e.start(),e.end()))return!1;let s=$o.exec(e.parent.textContent);if(!s)return!1;let r=s[1].split("|").map(l=>l.trim());if(!r.some(Boolean))return!1;let i=kt([r,r.map(()=>"")],{header:!0});return R(n,t,i,{from:e.start(),to:e.end()})}var ii=()=>it.keymap({Enter:(n,t,e)=>!Ct(null,e)&&Io(n,t)});function li(n,t){let{$from:e,empty:o}=n.selection;if(!o||e.depth!==1||e.parentOffset!==0)return!1;let s=e.parent;return s.type===H.heading||s.type===H.callout||s.type===H.quote||s.type===H.code_block&&s.content.size===0?(t&&t(k(n.tr.setNodeMarkup(e.before(),H.paragraph,{id:s.attrs.id,pos:s.attrs.pos,parent:s.attrs.parent}))),!0):!1}var{Plugin:xn,PluginKey:wn,TextSelection:vt,NodeSelection:Lo}=E,Mn=g.marks,F=g.nodes,At=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?"\u2318":"Ctrl+",Sn=n=>{let t=ht(n.doc),{lo:e,hi:o}=n.selection.span(n.doc);return t.slice(e,o+1).filter(s=>s.up===t[e].up)},Ot=(n,t)=>n.state.doc.child(t).attrs.id,Do=(n,t)=>{let e=0;for(let o=0;o<t;o++)e+=n.child(o).nodeSize;return e},mn=["aria-haspopup","aria-controls","aria-activedescendant"],Bo="That block is no longer available.",ie="This block holds content from a newer version, so it can't be converted here.";function gn(n){let t=n.visualViewport;return t?{left:t.offsetLeft,top:t.offsetTop,width:t.width,height:t.height}:{left:0,top:0,width:n.innerWidth,height:n.innerHeight}}function Ro(n,t,e,o=0){let s=W,r=Math.min(t,Math.max(0,n.width-s*2));return{left:n.left+(n.width-r)/2,top:Math.max(n.top+s,n.top+n.height-e-o-s),width:r}}function Po(n,t=globalThis.location){return`${t.origin}${t.pathname}${t.search}#${encodeURIComponent(n)}`}function No(n){if(!n)return;let t=()=>X("Link copied"),e=()=>X("Could not copy the link.","error");if(!globalThis.navigator?.clipboard?.writeText){e();return}globalThis.navigator.clipboard.writeText(Po(n)).then(t,e)}var Tn=[{key:"up",label:"Move up",icon:"\u2191",hint:`${At}\u21E7\u2191`,run:n=>Bt(-1)(n.state,n.dispatch)},{key:"down",label:"Move down",icon:"\u2193",hint:`${At}\u21E7\u2193`,run:n=>Bt(1)(n.state,n.dispatch)},{key:"indent",label:"Indent",icon:"\u2192",hint:"Tab",run:n=>Be(n.state,n.dispatch)},{key:"outdent",label:"Outdent",icon:"\u2190",hint:"\u21E7Tab",run:n=>Re(n.state,n.dispatch)},{key:"duplicate",label:"Duplicate",icon:"\u29C9",hint:`${At}D`,run:n=>He(n.state,n.dispatch)},{key:"delete",label:"Delete",icon:"\xD7",hint:"Del",run:n=>Pt(n.state,n.dispatch)},{key:"turn",label:"Turn into",icon:"\u21BB",hint:"\u203A",only:"text",run:(n,t)=>t.openMenu("turn",t.plus)},{key:"link",label:"Copy link",icon:"\u{1F517}",run:(n,t,e)=>No(n.state.doc.child(e).attrs.id)},{key:"alt",label:"Alt text\u2026",icon:"Aa",only:"image",focus:!1,run:(n,t,e)=>ve(n,Ot(n,e))},{key:"small",label:"Small",icon:"\u25AB",only:"image",run:(n,t,e)=>ft(n,Ot(n,e),{width:240})},{key:"medium",label:"Medium",icon:"\u25FB",only:"image",run:(n,t,e)=>ft(n,Ot(n,e),{width:480})},{key:"full",label:"Full width",icon:"\u2B1C",only:"image",run:(n,t,e)=>ft(n,Ot(n,e),{width:null})},{key:"chart",label:"Chart this table",icon:"\u{1F4CA}",only:"table",run:(n,t,e)=>{let o=Do(n.state.doc,e);return Qt(n).then(({insertChartAfterTable:s})=>s(n,o))}},{key:"csv",label:"Import CSV\u2026",icon:"\u21E7",only:"table",focus:!1,run:(n,t,e)=>Mt(n,null,n.state.doc.child(e).attrs.id)}],zo=n=>{if(!(n.selection instanceof B))return[];let t=Sn(n),e=t.every(r=>r.node.isTextblock),o=t.length===1&&t[0].node.type===F.image,s=t.length===1&&t[0].node.type===F.table;return Tn.filter(r=>r.only==="text"?e:r.only==="image"?o:r.only==="table"?s:!0)},$=n=>`<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${n}</svg>`,ot={plus:$('<path d="M8 3.5v9M3.5 8h9"/>'),grip:$('<path stroke-width="2.2" d="M6 3.5h.01M10 3.5h.01M6 8h.01M10 8h.01M6 12.5h.01M10 12.5h.01"/>'),strong:$('<path d="M5 3h4a2.5 2.5 0 0 1 0 5H5zM5 8h4.6a2.5 2.5 0 0 1 0 5H5z"/>'),em:$('<path d="M10 3H6.5M9.5 13H6M9 3l-2 10"/>'),strike:$('<path d="M3 8h10M10.8 5.2C10.5 4 9.4 3.2 8 3.2c-1.7 0-2.8.9-2.8 2.1M5.2 10.8c.3 1.2 1.4 2 2.8 2 1.7 0 2.8-.9 2.8-2.1"/>'),code:$('<path d="M6 4.5 2.5 8 6 11.5M10 4.5 13.5 8 10 11.5"/>'),link:$('<path d="M7 9a2.5 2.5 0 0 0 3.5 0l2-2A2.5 2.5 0 0 0 9 3.5l-.7.7M9 7a2.5 2.5 0 0 0-3.5 0l-2 2A2.5 2.5 0 0 0 7 12.5l.7-.7"/>'),bullet:$('<path d="M6.5 4.5h7M6.5 8h7M6.5 11.5h7"/><path stroke-width="2.4" d="M3 4.5h.01M3 8h.01M3 11.5h.01"/>'),ordered:$('<path d="M7 4.5h6.5M7 8h6.5M7 11.5h6.5M2.5 3.5l1-.5v3M2.5 9.3c.2-.5.6-.8 1.1-.8.6 0 1 .4 1 .9 0 .9-2.1 1.4-2.1 2.6h2.1"/>'),check:$('<rect x="2.5" y="2.5" width="11" height="11" rx="2.5"/><path d="M5.5 8.2l1.8 1.8 3.4-4"/>'),more:$('<path stroke-width="2.2" d="M3 8h.01M8 8h.01M13 8h.01"/>')},oe=[["strong","Bold"],["em","Italic"],["strike","Strikethrough"],["link","Link"],["bullet","Bulleted list"],["ordered","Numbered list"],["check","Checklist"],["code","Code"]],En=new Set(["strong","em","link"]),Ho=new Set(["up","down","indent","outdent"]),Fo=204,Ko=52,W=8,Cn=new Set(["bullet","ordered","check"]),jo=new Set(["paragraph","heading","list_item"]),st=n=>{let t=n.selection;if(t instanceof B)return Sn(n).map(l=>l.i);let{$from:e,$to:o,empty:s}=t,r=Math.min(!s&&o.depth===0?o.index(0)-1:o.index(0),n.doc.childCount-1),i=[];for(let l=e.index(0);l<=r;l++)i.push(l);return i},On=n=>st(n).filter(t=>{let e=n.doc.child(t);return e.isTextblock&&e.type!==F.code_block}),An=(n,t)=>n.type===F.list_item&&n.attrs.kind===t,vn=(n,t)=>{let e=On(n);return e.length>0&&e.every(o=>An(n.doc.child(o),t))},Vo=n=>{let t="";return n.forEach(e=>{t+=e.isText?e.text:e.type===F.hard_break?`
|
|
3
|
-
`:""}),t};function qo(n){let{$from:t,$to:e,empty:o}=n.selection;if(o||!(n.selection instanceof vt)||t.depth!==1||e.depth!==1||t.parentOffset!==0||e.parentOffset!==e.parent.content.size)return null;let s=st(n);return s.every(r=>jo.has(n.doc.child(r).type.name))?s:null}function Wo(n,t){let e=n.doc.child(t[0]),o=n.selection.$from.before(1),s=n.selection.$to.after(1),r=t.map(a=>Vo(n.doc.child(a))).join(`
|
|
4
|
-
`),{id:i,pos:l,parent:u}=e.attrs,p=n.tr.replaceWith(o,s,F.code_block.create({id:i,pos:l,parent:u},r?g.text(r):null));return p.setSelection(vt.create(p.doc,o+1,o+1+r.length))}function Uo(n,t){let e=n.tr,o=n.doc.resolve(n.selection.from).before(1),s=0;for(let r of[...t].reverse()){let i=0;for(let d=0;d<r;d++)i+=n.doc.child(d).nodeSize;let l=n.doc.child(r),{id:u,pos:p,parent:a}=l.attrs,c=l.textContent.split(`
|
|
5
|
-
`).map((d,h)=>F.paragraph.create(h===0?{id:u,pos:p,parent:a}:{parent:a},d?g.text(d):null));e.replaceWith(i,i+l.nodeSize,c),s||(s=i+c.reduce((d,h)=>d+h.nodeSize,0))}return s=e.mapping.slice(1).map(s),e.setSelection(vt.create(e.doc,o+1,s-1))}var _n=n=>{let t=st(n);return t.length>0&&t.every(e=>n.doc.child(e).type===F.code_block)?t:null};function yn(n,t){if(Cn.has(t))return vn(n,t);if(t==="code"&&_n(n))return!0;let e=Mn[t],{from:o,to:s,empty:r,$from:i}=n.selection;return r?!!e.isInSet(n.storedMarks||i.marks()):n.doc.rangeHasMark(o,s,e)}function Go(n,t){let e=n.state,o=vn(e,t),s=z.find(l=>l.key===(o?"text":t)),r=On(e).filter(l=>o||!An(e.doc.child(l),t));if(r.some(l=>!nt(e.doc.child(l),s))){j(n,ie);return}let i=e.tr;for(let l of r)q(i,l,s);i.docChanged&&n.dispatch(k(i))}var se=(n,t,e)=>import("./c-DFS4XZJV.js").then(o=>o.nativeMenu(n,e,t.more));function bn(n,t){if(t==="link")return Ce(n);let e=n.state,o=t==="code"?_n(e):null,s=t==="code"&&!o?qo(e):null;Cn.has(t)?Go(n,t):o?n.dispatch(k(Uo(e,o)).scrollIntoView()):s&&s.some(r=>!nt(e.doc.child(r),z.find(i=>i.key==="code")))?j(n,ie):s?n.dispatch(k(Wo(e,s)).scrollIntoView()):ae.toggleMark(Mn[t])(e,n.dispatch),n.focus()}var T=(n,t,e={})=>{let o=document.createElement(n);t&&(o.className=t);for(let[s,r]of Object.entries(e))o.setAttribute(s,r);return o};function kn(n,t){let e=T("button",`page-tool${En.has(n)?" page-tool-primary":" page-tool-desk"}`,{type:"button","data-cmd":n,"aria-label":t,title:t});return e.innerHTML=ot[n],e}var Yo=1600,Jo=0,Qo=new wn("page-chrome"),$n=new WeakMap,_t=new wn("page-slash-range"),Xo={init:()=>null,apply(n,t){let e=t;if(e&&n.docChanged){let s=n.mapping.map(e.from,1),r=n.mapping.map(e.to,-1);e=s<=r&&n.doc.textBetween(s,r)===e.text?{...e,from:s,to:r}:null}let o=n.getMeta(_t);return o!==void 0&&(e=o),e}},Ci=()=>new xn({key:_t,state:Xo}),In=(n,t)=>{let e=t?n.state.doc.textBetween(t.from,t.to):null;n.dispatch(n.state.tr.setMeta(_t,t?{...t,text:e}:null))},Ln=n=>{let t=_t.getState(n);return t?{from:t.from,to:t.to}:null};function Oi(n,t,e){let o=$n.get(n);return o?(o.openMenu("external",t),o.menu.externalItems=e,o.renderMenu(),!0):!1}var re=class{constructor(t,e){this.view=t,this.onAiTool=e,this.shell=t.dom.parentElement,this.menu=null,this.priorAria=null,this.movedTimer=0,this.hover=null,this.pendingHover=null,this.win=t.dom.ownerDocument.defaultView??globalThis,this.frame=null,this.destroyed=!1,this.probe=null,this.roving=null,this.dock=T("div","page-dock",{role:"toolbar","aria-label":"Formatting"}),this.turn=T("button","page-tool page-tool-turn page-tool-desk",{type:"button","aria-haspopup":"menu"}),this.more=T("button","page-tool page-tool-primary page-tool-more",{type:"button","aria-label":"More",title:"More","aria-haspopup":"menu"}),this.more.innerHTML=ot.more,this.dock.append(this.turn,T("span","page-tool-sep page-tool-desk"),...oe.map(([s,r])=>kn(s,r)),this.more),this.plus=T("button","page-plus",{type:"button","aria-label":"Add a block",title:"Add a block"}),this.plus.innerHTML=ot.plus,this.grip=T("button","page-grip",{type:"button","aria-label":"Block actions",title:"Drag to move, click for actions","aria-haspopup":"menu"}),this.grip.innerHTML=ot.grip,this.bubble=T("div","page-bubble",{role:"toolbar","aria-label":"Selection",hidden:""}),this.bubble.append(...oe.map(([s,r])=>kn(s,r))),this.menuId=`page-menu-${++Jo}`,this.menuEl=T("div","page-menu",{role:"menu",id:this.menuId,hidden:""}),this.scrim=T("div","page-scrim",{hidden:""}),this.shell.insertBefore(this.dock,t.dom),this.shell.append(this.plus,this.grip,this.bubble,this.scrim,this.menuEl);let o=s=>s.preventDefault();for(let s of[this.dock,this.plus,this.grip,this.bubble,this.menuEl])s.addEventListener("mousedown",o);for(let s of[this.dock,this.bubble])s.addEventListener("click",r=>{let i=r.target.closest("[data-cmd]");i&&bn(this.view,i.dataset.cmd)});this.turn.addEventListener("click",()=>this.toggleMenu("turn",this.turn)),this.more.addEventListener("click",()=>this.toggleMenu("more",this.more)),this.dock.addEventListener("keydown",s=>this.dockKey(s)),this.plus.addEventListener("click",()=>this.fromPlus()),this.grip.addEventListener("click",s=>{s.detail===0&&this.gripAction(this.gutterIndex())}),this.drag=new _e(t,this.grip,{index:()=>this.gutterIndex(),onClick:s=>this.gripAction(s)}),this.scrim.addEventListener("click",()=>this.closeMenu()),this.menuEl.addEventListener("click",s=>{let r=s.target.closest(".page-menu-item");r&&this.pick(Number(r.dataset.index))}),this.menuEl.addEventListener("keydown",s=>{this.key(s)&&s.preventDefault()}),this.onMove=s=>{this.shell.classList.add("is-moved"),clearTimeout(this.movedTimer),this.movedTimer=setTimeout(()=>this.shell.classList.remove("is-moved"),Yo),this.trackHover(s)},this.onKey=()=>{clearTimeout(this.movedTimer),this.shell.classList.remove("is-moved"),this.pendingHover=null,this.setHover(null)},this.onLeave=()=>{this.pendingHover=null,this.setHover(null)},this.onResize=()=>this.scheduleLayout(),this.onDocDown=s=>{this.menu&&([this.menuEl,this.plus,this.grip,this.turn].some(r=>r.contains(s.target))||this.closeMenu())},document.addEventListener("mousedown",this.onDocDown,!0),this.shell.addEventListener("mousemove",this.onMove),this.shell.addEventListener("mouseleave",this.onLeave),this.shell.addEventListener("keydown",this.onKey),this.win.addEventListener("resize",this.onResize),this.win.addEventListener("scroll",this.onResize,!0),this.win.visualViewport?.addEventListener("resize",this.onResize),this.win.visualViewport?.addEventListener("scroll",this.onResize),this.update(t,null)}blockIndex(){let t=this.view.state,e=t.selection,o=e instanceof B||e instanceof Lo?e.from:e.head;return Math.min(t.doc.resolve(o).index(0),t.doc.childCount-1)}isPhone(){return!!this.win?.matchMedia?.("(max-width: 560px)").matches}gutterIndex(){return this.isPhone()?this.blockIndex():(this.settleHover(),Math.min(this.hover??this.blockIndex(),this.view.state.doc.childCount-1))}dockControls(){let t=[...this.dock.querySelectorAll("button")].filter(e=>this.rendered(e));return this.isPhone()?t.filter(e=>e.classList.contains("page-tool-primary")):t}inRoving(t){return!t||!this.dock.contains(t)||this.isPhone()&&!t.classList.contains("page-tool-primary")?!1:this.rendered(t)}rendered(t){if(t.hidden)return!1;let e=this.win?.getComputedStyle?.(t);return!e||e.display!=="none"}setRoving(t){this.roving=t;let e=new Set(this.dockControls());for(let o of this.dock.querySelectorAll("button"))o.tabIndex=o===t&&e.has(o)?0:-1}leaveToToolbar(){queueMicrotask(()=>{this.view.isDestroyed||this.focusToolbar()})}focusToolbar(){let[t]=this.dockControls();return t?(this.setRoving(t),t.focus(),!0):!1}dockKey(t){if(t.key==="Escape"){t.preventDefault(),this.view.focus();return}if(t.key!=="ArrowRight"&&t.key!=="ArrowLeft")return;let e=this.dockControls(),o=e.indexOf(t.target);if(o<0)return;t.preventDefault();let s=e[(o+(t.key==="ArrowRight"?1:-1)+e.length)%e.length];this.setRoving(s),s.focus()}selectionIds(){let t=this.view.state;return st(t).map(e=>t.doc.child(e).attrs.id)}idIndex(t){let e=-1;return this.view.state.doc.forEach((o,s,r)=>{o.attrs.id===t&&(e=r)}),e}invoker(){let t=this.menu;if(!t||t.slashAt!==null)return this.view.dom;let e=t.anchor;return e&&e!==this.view.dom&&(e.tagName==="BUTTON"||e.hasAttribute("tabindex"))?e:this.view.dom}selectCaretBlock(t=null){let e=this.view.state;if(e.selection instanceof B)return;let o=(t??[]).map(r=>this.idIndex(r)).filter(r=>r>=0),s=o.length?o[0]:this.blockIndex();this.view.dispatch(e.tr.setSelection(Rt(e.doc,s,o.length?o[o.length-1]:s)))}gripAction(t){this.menu?this.closeMenu():this.openActions(this.grip,t)}trackHover(t){this.menu||this.drag.state||[this.plus,this.grip,this.dock,this.bubble].some(e=>e.contains(t.target))||(this.pendingHover={clientY:t.clientY},this.scheduleLayout())}hoverAt(t){let e=this.view,o=e.posAtCoords({left:e.dom.getBoundingClientRect().left+2,top:t});if(!o)return;let s=e.state.doc,r=ht(s),i=Math.min(s.resolve(o.inside>=0?o.inside:o.pos).index(0),r.length-1);for(;i>0&&r[i].hidden;)i--;this.hover=i}setHover(t){t!==this.hover&&(this.hover=t,this.scheduleLayout())}settleHover(){if(!this.pendingHover)return;let{clientY:t}=this.pendingHover;this.pendingHover=null,this.hoverAt(t)}fromPlus(){this.view.focus();let t=this.gutterIndex();this.openMenu("insert",this.plus,null,null,this.view.state.doc.child(t).attrs.id)}toggleMenu(t,e){this.menu?this.closeMenu():this.openMenu(t,e)}openMenu(t,e,o=null,s=null,r=null){this.menu={mode:t,anchor:e,slashAt:o,anchorId:r,ids:s??(t==="insert"?[]:this.selectionIds()),query:"",active:0,items:[]},e.setAttribute("aria-expanded","true"),o!==null?(this.priorAria||(this.priorAria=mn.map(i=>[i,this.view.dom.getAttribute(i)])),this.view.dom.setAttribute("aria-haspopup","listbox")):this.view.dom.setAttribute("aria-haspopup","menu"),this.view.dom.setAttribute("aria-controls",this.menuId),this.renderMenu()}closeMenu(){if(this.menu?.anchor.setAttribute("aria-expanded","false"),this.menu=null,this.menuEl.hidden=!0,this.scrim.hidden=!0,this.priorAria){for(let[t,e]of this.priorAria)e===null?this.view.dom.removeAttribute(t):this.view.dom.setAttribute(t,e);this.priorAria=null}else for(let t of mn)this.view.dom.removeAttribute(t)}moreItems(){let t=oe.filter(([o])=>!En.has(o)).map(([o,s])=>({key:o,label:s,icon:ot[o],run:r=>bn(r,o)})),e=Tn.filter(o=>Ho.has(o.key)).map(o=>({...o,blocks:!0}));return[...t,{key:"underline",label:"Underline",icon:"U",hint:`${At}u`,run:(o,s)=>se(o,s,"underline")},{key:"text_color",label:"Text color",icon:"A",hint:"\u203A",run:(o,s)=>se(o,s,"text_color")},{key:"highlight",label:"Highlight",icon:"\u25A0",hint:"\u203A",run:(o,s)=>se(o,s,"highlight")},{key:"turn",label:"Turn into",icon:"\u21BB",run:(o,s)=>s.openMenu("turn",s.more)},{key:"insert",label:"Insert",icon:"+",run:(o,s)=>s.openMenu("insert",s.more,null,null,o.state.doc.child(s.blockIndex()).attrs.id)},...e]}menuItems(t){if(t.mode==="external")return t.externalItems||[];if(t.mode==="actions")return zo(this.view.state);if(t.mode==="more")return this.moreItems();let e=t.mode==="turn"?z:ln(this.view.state,this.onAiTool?[...St,{key:"ai",label:"Make a tool with AI\u2026",icon:"\u2726",aliases:["tool","generate"],insert:"ai"}]:St);return un(e,t.query)}currentTypes(){let t=this.view.state;return new Set(st(t).map(e=>Tt(t.doc.child(e)).key))}openActions(t=this.plus,e=null){let o=this.view.state,s=ht(o.doc),r=o.selection,i=e!==null&&r instanceof B&&r.span(o.doc).lo<=e&&e<=r.span(o.doc).hi,{lo:l,hi:u}=e===null||i?ze(o,s):De(s,e,e);this.view.dispatch(o.tr.setSelection(Rt(o.doc,l,u,s)));let p=[];for(let a=l;a<=u;a++)p.push(o.doc.child(a).attrs.id);this.openMenu("actions",t,null,p)}renderMenu(){let t=this.menu;t.items=this.menuItems(t),t.active=Math.min(t.active,Math.max(0,t.items.length-1));let e=t.slashAt!==null,o=t.mode==="turn"?this.currentTypes():null;this.menuEl.setAttribute("role",e?"listbox":"menu");let s=[];if(t.mode==="turn"){let r=T("div","page-menu-title");r.textContent=t.query?`Turn into \u201C${t.query}\u201D`:"Turn into",s.push(r)}if(!t.items.length){let r=T("div","page-menu-empty");r.textContent="No matching blocks",s.push(r)}t.items.forEach((r,i)=>{let l=i===t.active,u=o?o.size===1&&r.key===[...o][0]:typeof r.checked=="boolean"?r.checked:null,p=t.mode==="turn"?"menuitemradio":typeof u=="boolean"?"menuitemcheckbox":e?"option":"menuitem",a=T("button",`page-menu-item${l?" is-active":""}`,{type:"button",role:p,tabindex:!e&&l?"0":"-1",id:`${this.menuId}-${i}`,"data-index":String(i),...p==="menuitemradio"?{}:{"aria-selected":l?"true":"false"},...typeof u=="boolean"?{"aria-checked":String(u)}:{}}),c=T("span","page-menu-icon");c.textContent=r.icon||"";let d=T("span","page-menu-label");if(d.textContent=r.label,r.description){let h=T("span","page-menu-text"),f=T("span","page-menu-desc");f.textContent=r.description,h.append(d,f),a.append(c,h)}else a.append(c,d);if(r.hint){let h=T("span","page-menu-hint");h.textContent=r.hint,a.append(h)}s.push(a)}),this.menuEl.replaceChildren(...s),e&&t.items.length?this.view.dom.setAttribute("aria-activedescendant",`${this.menuId}-${t.active}`):this.view.dom.removeAttribute("aria-activedescendant"),this.menuEl.hidden=!1,this.scrim.hidden=!1,this.scheduleLayout(),e||this.menuEl.querySelectorAll("button")[t.active]?.focus()}pick(t){let e=this.menu,o=e?.items[t];if(!o)return;let s=this.view.state,r=e.slashAt!==null&&s.selection.head>=e.slashAt?{from:e.slashAt-1,to:s.selection.head}:null,i=e.mode==="insert"?e.anchorId?[e.anchorId]:[]:e.ids,l=i.some(p=>!p||this.idIndex(p)<0),u=i.length?this.idIndex(i[0]):-1;if(this.closeMenu(),l&&e.mode!=="external"){j(this.view,Bo),this.view.focus();return}if(e.mode==="turn"){if(i.some(a=>!nt(s.doc.child(this.idIndex(a)),o))){j(this.view,ie),this.view.focus();return}let p=()=>{let a=this.view.state.tr;for(let c of i){let d=this.idIndex(c);d>=0&&q(a,d,o)}return a.docChanged&&this.view.dispatch(k(a).scrollIntoView()),!0};if(o.type==="quote"){let a=this.view;import("./c-DFS4XZJV.js").then(c=>c.gateTurn(a,p))}else p();this.view.focus()}else e.mode==="actions"||e.mode==="more"||e.mode==="external"?(o.blocks&&this.selectCaretBlock(i),o.run(this.view,this,u>=0?u:this.blockIndex()),!this.menu&&o.focus!==!1&&this.view.focus()):o.insert==="ai"?this.onAiTool(this.view,r):dn(this.view,o,u>=0?u:this.blockIndex(),r)}key(t){if(Ct(t,this.view))return!1;let e=this.menu;if(!e)return t.key==="Escape"&&!t.metaKey&&!t.ctrlKey&&!t.altKey&&this.view.state.selection instanceof B&&this.leaveToToolbar(),!1;if((t.key==="Backspace"||t.key==="Delete")&&e.mode==="actions"&&this.view.state.selection instanceof B)return this.closeMenu(),this.view.focus(),Pt(this.view.state,this.view.dispatch),!0;if(t.key==="ArrowDown"||t.key==="ArrowUp")return e.items.length&&(e.active=(e.active+(t.key==="ArrowDown"?1:-1)+e.items.length)%e.items.length,this.renderMenu()),!0;if(t.key==="Enter")return e.items.length&&this.pick(e.active),!0;if(t.key==="Escape"){let o=this.invoker();return this.closeMenu(),o===this.view.dom?this.view.focus():o?.focus?.(),!0}return!1}slashQuery(){let t=this.menu;if(!t||t.slashAt===null)return;let{$head:e}=this.view.state.selection,o=e.start();if(e.pos<t.slashAt||t.slashAt<o||this.view.state.doc.textBetween(t.slashAt-1,t.slashAt)!=="/")return this.closeMenu();if(t.query=this.view.state.doc.textBetween(t.slashAt,e.pos),t.active=0,/\s$/.test(t.query)&&!this.menuItems(t).length)return this.closeMenu();this.renderMenu()}scheduleLayout(){this.frame!==null||this.destroyed||(this.frame=this.win.requestAnimationFrame(()=>{if(this.frame=null,this.destroyed)return;let t=this.measureLayout();this.paintLayout(t)}))}safeBottom(){return this.probe||(this.probe=T("div","page-safe-probe"),this.shell.append(this.probe)),parseFloat(this.win.getComputedStyle(this.probe).paddingBottom)||0}menuBox(t){let e=gn(this.win),o=Math.max(0,e.height-W*2),s=Math.min(280,Math.max(0,e.width-W*2)),r=this.menuEl.style.getPropertyValue("--page-pop-max");this.menuEl.style.removeProperty("--page-pop-max");let i=this.menuEl.offsetHeight||0;r&&this.menuEl.style.setProperty("--page-pop-max",r);let l=Math.min(i,o),u=Math.max(e.left+W,Math.min(t.left,e.left+e.width-W-s)),p=t.top-6-l;return p<e.top+W&&(p=Math.min(t.top+t.height+6,e.top+e.height-W-l)),{left:u,top:p,width:s,maxHeight:o}}measureLayout(){let t=this.view,e=t.state;this.settleHover();let o=this.shell.getBoundingClientRect(),s=t.dom.getBoundingClientRect(),r=this.gutterIndex(),i=0;for(let c=0;c<r;c++)i+=e.doc.child(c).nodeSize;let l=t.nodeDOM(i),u={textLeft:s.left-o.left,gutter:null,bubble:null,menu:null,bar:null,desk:!1};if(l&&l.getBoundingClientRect){let c=l.getBoundingClientRect(),d=parseFloat(getComputedStyle(l).lineHeight)||c.height;u.gutter={top:c.top-o.top+Math.min(c.height,d)/2,left:c.left-o.left}}let p=this.isPhone();if(p){let c=gn(this.win),d=this.dock.offsetHeight||Ko;u.bar={...Ro(c,this.dock.offsetWidth||Fo,d,this.safeBottom()),height:d}}else u.desk=!!this.dock.style.left;let a=e.selection;if(!this.bubble.hidden&&!p){let c=t.coordsAtPos(a.from),d=t.coordsAtPos(a.to,-1),h=(Math.min(c.left,d.left)+Math.max(c.right,d.right))/2;u.bubble={x:h-o.left,y:Math.min(c.top,d.top)-o.top}}if(this.menu&&p){let c=this.menuBox(u.bar);u.menu={x:c.left,y:c.top,width:c.width,maxHeight:c.maxHeight}}else if(this.menu){let c=this.menu,d,h;if(c.slashAt!==null){let f=t.coordsAtPos(c.slashAt-1);d=f.left,h=f.bottom+6;let m=this.menuEl.offsetHeight;h+m>this.win.innerHeight-8&&f.top-6-m>=8&&(h=f.top-6-m)}else{let f=c.anchor===this.plus?l?.getBoundingClientRect?.()??s:c.anchor.getBoundingClientRect();d=f.left,h=f.bottom+6}u.menu={x:Math.max(8,Math.min(d-o.left,o.width-280)),y:h-o.top}}return u}paintLayout(t){if(t.bar)this.dock.style.left=`${t.bar.left}px`,this.dock.style.top=`${t.bar.top}px`,this.dock.style.width=`${t.bar.width}px`,this.grip.style.setProperty("--page-grip-lift",`${t.bar.height}px`);else{if(t.desk)for(let e of["left","top","width"])this.dock.style.removeProperty(e);this.grip.style.removeProperty("--page-grip-lift")}if(t.gutter)for(let e of[this.plus,this.grip])e.style.setProperty("--page-plus-top",`${t.gutter.top}px`),e.style.setProperty("--page-plus-left",`${t.gutter.left}px`);this.plus.style.setProperty("--page-text-left",`${t.textLeft}px`),t.bubble&&(this.bubble.style.setProperty("--page-pop-x",`${t.bubble.x}px`),this.bubble.style.setProperty("--page-pop-y",`${t.bubble.y}px`)),t.menu&&(this.menuEl.style.setProperty("--page-pop-x",`${t.menu.x}px`),this.menuEl.style.setProperty("--page-pop-y",`${t.menu.y}px`),t.menu.width!==void 0&&(this.menuEl.style.setProperty("--page-pop-width",`${t.menu.width}px`),this.menuEl.style.setProperty("--page-pop-max",`${t.menu.maxHeight}px`)))}update(t,e){if(this.view=t,this.menu&&this.menu.slashAt===null&&e&&e.doc!==t.state.doc){let i=this.menuEl.contains(document.activeElement);this.closeMenu(),i&&t.focus()}let o=t.state,s=o.doc.child(this.blockIndex());this.turn.textContent=`${Tt(s).label} \u25BE`;for(let i of this.dock.querySelectorAll("[data-cmd]"))i.setAttribute("aria-pressed",String(yn(o,i.dataset.cmd)));let r=!o.selection.empty&&o.selection instanceof vt&&t.hasFocus();if(this.bubble.hidden=!r,r)for(let i of this.bubble.querySelectorAll("[data-cmd]"))i.setAttribute("aria-pressed",String(yn(o,i.dataset.cmd)));this.grip.classList.toggle("is-on",o.selection instanceof B),this.inRoving(this.roving)||this.setRoving(this.dockControls()[0]),this.slashQuery(),this.scheduleLayout()}destroy(){this.destroyed=!0,this.frame!==null&&this.win.cancelAnimationFrame(this.frame),this.frame=null,clearTimeout(this.movedTimer),this.drag.destroy(),this.shell.removeEventListener("mousemove",this.onMove),this.shell.removeEventListener("mouseleave",this.onLeave),this.shell.removeEventListener("keydown",this.onKey),this.win.removeEventListener("resize",this.onResize),this.win.removeEventListener("scroll",this.onResize,!0),this.win.visualViewport?.removeEventListener("resize",this.onResize),this.win.visualViewport?.removeEventListener("scroll",this.onResize),document.removeEventListener("mousedown",this.onDocDown,!0);for(let t of[this.dock,this.plus,this.grip,this.bubble,this.scrim,this.menuEl,this.probe])t?.remove()}};function Ai({onAiTool:n=null}={}){let t=null;return new xn({key:Qo,view(e){return t=new re(e,n),$n.set(e,t),t},props:{handleKeyDown(e,o){return t?o.key==="/"&&(o.metaKey||o.ctrlKey)&&!o.altKey&&!t.menu?(o.preventDefault(),t.openActions(),!0):t.key(o):!1},handleTextInput(e,o,s,r){if(r!=="/"||!t)return!1;let i=Fe(e,r);i&&(o=e.state.selection.from-1);let l=e.state.doc.resolve(o);if(l.depth!==1||!l.parent.isTextblock||l.parent.type.spec.code||l.parentOffset>0&&!/\s/.test(e.state.doc.textBetween(o-1,o,"",`
|
|
6
|
-
`)))return i;i||e.dispatch(e.state.tr.insertText("/",o,s).setMeta(bt,Ft(e.state,o,s,"/")));let u=Math.min(e.state.doc.resolve(o).index(0),e.state.doc.childCount-1);return t.openMenu("insert",t.plus,o+1,null,e.state.doc.child(u).attrs.id),!0},handleDOMEvents:{keydown(e,o){return Ct(o,e)},blur(e){return t&&(t.bubble.hidden=!0),!1}}}})}var{Plugin:Zo}=E,ce=new WeakMap,ts=n=>typeof n.text=="function"?n.text():new Promise((t,e)=>{let o=new FileReader;o.onload=()=>t(o.result),o.onerror=()=>e(o.error),o.readAsText(n)});function $t(n,t){let e=n.dom.ownerDocument,o=n.dom.parentElement.querySelector(".page-csv-error");o||(o=e.createElement("div"),o.className="page-csv-error",o.setAttribute("role","alert"),n.dom.parentElement.append(o)),o.textContent=t}function es(n){let t=0,e=be(n,{maxBytes:qt,newId:()=>b(t++<n.header.length?"c":"r")});if(!Object.keys(e.cols).length)return null;if(!Object.keys(e.rows).length){let o=Object.fromEntries(Object.keys(e.cols).map(s=>[s,""]));e.rows[b("r")]={pos:C(),cells:o}}return{node:U(g,b(),{t:"table",pos:null,cols:e.cols,rows:e.rows}),truncated:e.truncated}}async function ns({kept:n,total:t}){let e=`This file has ${t} rows. The first ${n} fit in a table.`,o=globalThis.clay?.confirm,s=globalThis.clay?.modal;o||(o=(await import("./c-DNENWY4O.js")).consent,s=(await import("./c-RM7J7BV2.js")).default);let r=o(e);s&&(s.yes=`Insert first ${n} rows and attach the file`);try{return await r,!0}catch{return!1}}var os=(n,t)=>{let e=-1;return n.forEach((o,s,r)=>{e<0&&o.type===g.nodes.table&&o.attrs.id===t&&(e=r)}),e},ss=n=>{let t=!0;return n.descendants(e=>(e.isText&&(t=!1),t)),t};function rs(n,t,e,o){let s=n.state,r=os(s.doc,e);if(r<0)return R(s,n.dispatch,t,null,o);let i=0;for(let a=0;a<r;a++)i+=s.doc.child(a).nodeSize;let l=s.doc.child(r);if(!ss(l)||o){let a=s.doc.maybeChild(r+1),c=l.attrs.parent??null,d=C(l.attrs.pos,a?.attrs.pos??null),h=t.type.create({...t.attrs,pos:d,parent:c},t.content),f=i+l.nodeSize,m=s.tr.insert(f,h);return o&&m.insert(f+h.nodeSize,o.type.create({...o.attrs,pos:C(d,a?.attrs.pos??null),parent:c},o.content)),m.setSelection(E.TextSelection.create(m.doc,f+3)),n.dispatch(k(m).scrollIntoView()),!0}let u=t.type.create({...t.attrs,id:l.attrs.id,pos:l.attrs.pos,parent:l.attrs.parent},t.content),p=s.tr.replaceWith(i,i+l.nodeSize,u);return p.setSelection(E.TextSelection.create(p.doc,i+3)),n.dispatch(k(p).scrollIntoView()),!0}async function le(n,t,{upload:e,remove:o=null,table:s=null}={}){try{n.dom.parentElement.querySelector(".page-csv-error")?.remove();let r=at(await ts(t)),i=es(r);if(!i)return $t(n,"Couldn't read this CSV: no columns."),!1;let l=null;if(i.truncated){if(!await ns(i.truncated))return!1;let a=await e?.(t),c=de(a?.uploads?.[0]?.url);if(!a?.ok||!c)return $t(n,"Couldn't attach the original CSV."),!1;l=g.nodes.file.create({id:b(),src:c,name:t.name,size:t.size??null,mime:t.type||"text/csv"})}if(n.isDestroyed)return!1;if(s)return rs(n,i.node,s,l);let u=o?Ln(n.state):null;return o&&!u&&ls(n,o.block),R(n.state,n.dispatch,i.node,u,l)}catch(r){return r instanceof me?$t(n,`Couldn't read this CSV: unclosed quote on line ${r.line}.`):$t(n,"Couldn't read this CSV."),!1}}function Mt(n,t=null,e=null){let o=ce.get(n);return o?(t&&In(n,t),o._remove=t?{...t,block:is(n.state.doc,t.from)}:null,o._table=e,o.click(),!0):!1}var is=(n,t)=>n.child(n.resolve(Math.max(0,Math.min(t,n.content.size))).index(0)).attrs.id;function ls(n,t){let e=n.state,o=null;return e.doc.forEach((s,r)=>{o===null&&s.attrs.id===t&&(o=r)}),o===null?!1:(n.dispatch(e.tr.setSelection(E.TextSelection.near(e.doc.resolve(o)))),!0)}var Dn=n=>[...n].filter(t=>/\.csv$/i.test(t.name||"")||/^(text\/csv|application\/csv)$/i.test(t.type||""));function zi({upload:n}){return new Zo({view(t){let e=t.dom.ownerDocument.createElement("input");return e.type="file",e.accept=".csv,text/csv",e.hidden=!0,e.className="page-csv-input",t.dom.parentElement.append(e),ce.set(t,e),e.addEventListener("change",()=>{let o=e.files?.[0];o&&le(t,o,{upload:n,remove:e._remove,table:e._table}),e._remove=null,e._table=null,e.value=""}),{destroy(){ce.delete(t),e.remove()}}},props:{handlePaste(t,e){let o=Dn(e.clipboardData?.files||[]);return o.length?(e.preventDefault(),le(t,o[0],{upload:n}),!0):!1},handleDrop(t,e,o,s){let r=Dn(e.dataTransfer?.files||[]);if(s||!r.length)return!1;e.preventDefault();let i=t.posAtCoords({left:e.clientX,top:e.clientY});return i&&t.dispatch(t.state.tr.setSelection(E.TextSelection.near(t.state.doc.resolve(i.pos)))),le(t,r[0],{upload:n}),!0}}})}export{ks as a,vs as b,je as c,us as d,ds as e,zi as f,sn as g,Qt as h,Ls as i,Ds as j,Bs as k,Ct as l,ri as m,ii as n,li as o,Ci as p,In as q,Ln as r,Oi as s,Ai as t,Xs as u,Zs as v,Xe as w,lo as x,mr as y,gr as z,yr as A,br as B,kr as C,co as D,ao as E,xr as F,wr as G,Mr as H,Sr as I,Tr as J,Er as K,Cr as L,Or as M,Ar as N};
|