@bendyline/gezel-service 1.0.7 → 1.1.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/bin/gezeld.js +6253 -3616
- package/dist/handboek-content/whats-new/1.26224.md +1 -0
- package/dist/handboek-content/whats-new/1.26226.md +1 -0
- package/dist/handboek-content/whats-new/1.26231.md +1 -0
- package/dist/handboek-content/whats-new/1.26234.md +1 -0
- package/dist/handboek-content/whats-new/1.26237.md +1 -0
- package/dist/handboek-content/whats-new/1.26244.md +2 -1
- package/dist/handboek-content/whats-new/1.26247.md +88 -0
- package/dist/handboek-content/whats-new/whats-new-index.md +1 -0
- package/dist/index-store/static-index-worker.js +17 -1
- package/dist/index.d.ts +473 -209
- package/dist/index.js +6251 -3614
- package/dist/memory/embed-worker.js +58 -2
- package/dist/memory/image-embed-worker.js +8 -0
- package/dist/providers/llama-cpp/gguf-metadata-worker.js +2 -0
- package/dist/providers/mlx/python/gezel_mlx_server.py +18 -18
- package/dist/ui/assets/AmbientDashboardCard-Cf5fi_fY.js +1 -0
- package/dist/ui/assets/{AudioEngineSettings-BDrNIGGm.js → AudioEngineSettings-D3L7HOHe.js} +1 -1
- package/dist/ui/assets/{BenchmarksView-CHyujjs8.js → BenchmarksView-B68hrLCl.js} +1 -1
- package/dist/ui/assets/CatalogBrowser-DEM9t7Es.js +1 -0
- package/dist/ui/assets/{ChannelsSettings-Be_W1mr8.js → ChannelsSettings-DtK_k0Ul.js} +1 -1
- package/dist/ui/assets/ChatTimelineView-CQ4Sf4Ip.js +7 -0
- package/dist/ui/assets/ConfirmDialog-Dt1ed4Fh.js +1 -0
- package/dist/ui/assets/ConnectedAppsPanel-Cl8LEkrt.js +1 -0
- package/dist/ui/assets/CraftbookEditor-DEQRlQ2p.js +1 -0
- package/dist/ui/assets/{CraftbookScriptEditorView-DXIZYZT3.js → CraftbookScriptEditorView-DhXkkIdK.js} +1 -1
- package/dist/ui/assets/{CraftbookTabContent-Bm7t_b37.js → CraftbookTabContent-_oIdpQTG.js} +1 -1
- package/dist/ui/assets/{CraftbookToolsetSetup-DTEA-3K3.js → CraftbookToolsetSetup-BKg136L1.js} +1 -1
- package/dist/ui/assets/{CraftbooksView-C4X99TTe.js → CraftbooksView-Dm2zH-nW.js} +2 -2
- package/dist/ui/assets/{DiffpackReviewView-ClcNxtmF.js → DiffpackReviewView-EFLGJnwr.js} +1 -1
- package/dist/ui/assets/DocumentDetail-ClDRj2N-.js +1 -0
- package/dist/ui/assets/DocumentsView-ny9oieg2.js +1 -0
- package/dist/ui/assets/DropdownMenu-S4d9-3j3.js +1 -0
- package/dist/ui/assets/Ds4Settings-CeWlm5Vf.js +1 -0
- package/dist/ui/assets/EmbeddedChat-Hjrrgpao.js +1 -0
- package/dist/ui/assets/{FaceRecognitionCard-D3hdc7uU.js → FaceRecognitionCard-D7ufKqjI.js} +1 -1
- package/dist/ui/assets/FileMapView-DRjf59RH.js +1 -0
- package/dist/ui/assets/{FoldersSettings-BcNzl4vT.js → FoldersSettings-DDUhaFio.js} +1 -1
- package/dist/ui/assets/GezelDetail-Cph6pVGb.js +1 -0
- package/dist/ui/assets/{GezelJsonEditor-fOvYclu9.js → GezelJsonEditor-7vDGyBib.js} +1 -1
- package/dist/ui/assets/{GezellenView-BTzhHrxi.js → GezellenView-DQhcO1CP.js} +1 -1
- package/dist/ui/assets/{GildeUpdatesCard-Bq6XEpLP.js → GildeUpdatesCard-UKKNm_U8.js} +1 -1
- package/dist/ui/assets/{GithubSignInChip-CnlTCG8G.js → GithubSignInChip-DjM3qZsL.js} +1 -1
- package/dist/ui/assets/{HandboekMediaProvider-BfQW8_Nr.js → HandboekMediaProvider-DixaXTAH.js} +1 -1
- package/dist/ui/assets/HandboekView-BeNQqho9.js +1 -0
- package/dist/ui/assets/HistoryView-E2szGNGS.js +1 -0
- package/dist/ui/assets/{HomeView-CB_5TJIp.css → HomeView-CNeqCFPc.css} +1 -1
- package/dist/ui/assets/HomeView-CkiS3DXy.js +1 -0
- package/dist/ui/assets/{ImageEngineSettings-BpMfQy4f.js → ImageEngineSettings-BCKT7Gvi.js} +1 -1
- package/dist/ui/assets/{ImageRecognitionSettings-Ct-7-Oas.js → ImageRecognitionSettings-DD6syFez.js} +1 -1
- package/dist/ui/assets/IncompleteDownloads-BiPaaahS.js +1 -0
- package/dist/ui/assets/InstallProgressRow-DyKOI4MU.js +1 -0
- package/dist/ui/assets/KnowledgeCatalogsCard-B132vzRa.js +1 -0
- package/dist/ui/assets/KnowledgeView-CtPuIlN4.js +1 -0
- package/dist/ui/assets/LlamaCppSettings-D6zHcu4W.js +1 -0
- package/dist/ui/assets/{MarkdownField-D-0Zw7gM.js → MarkdownField-CK8K3fzj.js} +1 -1
- package/dist/ui/assets/MemoriesTree-DzjXzIrM.js +1 -0
- package/dist/ui/assets/{MicrophoneSettings-BIaFxyY_.js → MicrophoneSettings-1FH83SCq.js} +1 -1
- package/dist/ui/assets/MlxSettings-BYxUqFnJ.js +1 -0
- package/dist/ui/assets/ModelPicker-DoXPfQkQ.js +1 -0
- package/dist/ui/assets/{NewScriptDialog-D-gkY8TS.js → NewScriptDialog-C5X-7PMt.js} +1 -1
- package/dist/ui/assets/NewTaskDialog-Cyqtmigv.js +2 -0
- package/dist/ui/assets/{OllamaSettings-oIE2Mech.js → OllamaSettings-DkjmA-sB.js} +1 -1
- package/dist/ui/assets/ProjectChat-YEqUME6k.js +5 -0
- package/dist/ui/assets/{ProjectConnectionsTab-BZqp-oKI.js → ProjectConnectionsTab-dFCJpW93.js} +1 -1
- package/dist/ui/assets/ProjectGitStatusBar-CjZxG54t.js +1 -0
- package/dist/ui/assets/{ProjectGithubView-w8suLCsA.js → ProjectGithubView-CQ4-tmPx.js} +1 -1
- package/dist/ui/assets/{ProjectMailTab-DGo7eyB8.js → ProjectMailTab-NaScsZJf.js} +1 -1
- package/dist/ui/assets/ProjectOverviewView-ChjxbQas.js +1 -0
- package/dist/ui/assets/{ProjectTimeline-DRe3D9qY.js → ProjectTimeline-BZpdCisR.js} +1 -1
- package/dist/ui/assets/ProjectsView-J77ECk6V.js +7 -0
- package/dist/ui/assets/{RecommendedBadge-BKiDixnB.js → RecommendedBadge-D0m68PAu.js} +1 -1
- package/dist/ui/assets/{RemoteServersPanel-DGyl6-Rg.js → RemoteServersPanel-BdLOoORu.js} +1 -1
- package/dist/ui/assets/ScriptEditorTabs-BFvIiDFZ.js +2 -0
- package/dist/ui/assets/ScriptEditorView-B09rm1vz.js +5 -0
- package/dist/ui/assets/{ScriptsView-WQc28TmQ.js → ScriptsView-BvNAJXpo.js} +1 -1
- package/dist/ui/assets/{SecurityComplianceSettings-DsMEA4J3.js → SecurityComplianceSettings-DzGOnptO.js} +1 -1
- package/dist/ui/assets/SessionSwitcher-6okzcxT7.js +1 -0
- package/dist/ui/assets/SettingsView-Dur4dLhW.js +3 -0
- package/dist/ui/assets/SquisqIntegration-6v3yNOIP.js +2 -0
- package/dist/ui/assets/{StorageCleanupDialog-DHqwyMZZ.js → StorageCleanupDialog-OQlomMJD.js} +1 -1
- package/dist/ui/assets/{StorageUsageCard-CdT6SU51.js → StorageUsageCard-f6c6qTbM.js} +1 -1
- package/dist/ui/assets/Tabs-jE0Z5Tzd.js +1 -0
- package/dist/ui/assets/TaskTabContent-0w3kAUWR.js +1 -0
- package/dist/ui/assets/TasksView-BVMT4BAY.js +1 -0
- package/dist/ui/assets/{TerminalCodeEditor-77pBm6f3.js → TerminalCodeEditor-DO7zLKy-.js} +2 -2
- package/dist/ui/assets/ToolsetsEditor-Bb1wD5mV.js +8 -0
- package/dist/ui/assets/TransformToolbarButton-BWYkEB0d.js +5 -0
- package/dist/ui/assets/UnrecognizedModels-HtdMZUqK.js +1 -0
- package/dist/ui/assets/{VideoEngineSettings-DzMeINuv.js → VideoEngineSettings-Dq8Nw_tK.js} +1 -1
- package/dist/ui/assets/{WorkspaceIndexPane-DU4yd4Ai.js → WorkspaceIndexPane-fpDz4MwZ.js} +1 -1
- package/dist/ui/assets/{api-BX5xXiFs.js → api-BPraLwsh.js} +1 -1
- package/dist/ui/assets/chat-thread-memory-Be48zsyG.js +1 -0
- package/dist/ui/assets/chunk-6ECMNUIP-DDVjPyfK.js +15 -0
- package/dist/ui/assets/{chunk-6N2J7C2B-B5QIrD9m.js → chunk-6N2J7C2B-CsppiLVr.js} +1 -1
- package/dist/ui/assets/{chunk-A6N6IN3I-DXok09eC.js → chunk-A6N6IN3I-ofeM4l8g.js} +1 -1
- package/dist/ui/assets/chunk-B7GEAZBI-Divd2h1k.js +1 -0
- package/dist/ui/assets/chunk-DXYWKZ52-BXcAlClu.js +1 -0
- package/dist/ui/assets/chunk-FLR2ARKC-D7wrvQgT.js +2 -0
- package/dist/ui/assets/chunk-IIQYS2YH-DKZhWMpn.js +1 -0
- package/dist/ui/assets/{chunk-ILCJ3WFD-WRukZ7R1.js → chunk-ILCJ3WFD-CLZxw4Ge.js} +3 -3
- package/dist/ui/assets/chunk-OBADJV7C-CDVOcmYt.js +1 -0
- package/dist/ui/assets/chunk-Q77KNJIN-BIDRf0aP.js +6 -0
- package/dist/ui/assets/chunk-S5PCVMKU-Df5XzhSE.js +6 -0
- package/dist/ui/assets/chunk-UBFT2CDQ-FexGDigd.js +31 -0
- package/dist/ui/assets/{chunk-USU6HTKB-D5FmDzJU.js → chunk-USU6HTKB-B_p-YcDp.js} +1 -1
- package/dist/ui/assets/chunk-VKXOZTYP-BoVvWSBR.js +5 -0
- package/dist/ui/assets/{chunk-6RQOV3B3-CwvKotJw.js → chunk-VPWPEMZJ-DRKoa_j0.js} +1 -1
- package/dist/ui/assets/{chunk-WATAOG4Y-DXg2lov5.js → chunk-WATAOG4Y-C1EXVPmG.js} +1 -1
- package/dist/ui/assets/{container-B7jJtK5V.js → container-Ce94efbg.js} +1 -1
- package/dist/ui/assets/csv-62UGQMzZ.js +1 -0
- package/dist/ui/assets/data-B2kHjlc5.js +1 -0
- package/dist/ui/assets/dist-B9-VrAP8.js +2 -0
- package/dist/ui/assets/dist-BaHut5iX.js +2 -0
- package/dist/ui/assets/dist-BqGwkOe5.js +225 -0
- package/dist/ui/assets/dist-ZnIgkoEi.js +4 -0
- package/dist/ui/assets/{dist-BHl1ZAVG.js → dist-l6uUFZMV.js} +2 -2
- package/dist/ui/assets/dist-pLLFUPO-.js +1 -0
- package/dist/ui/assets/{doc-s6H7T0IO.js → doc-Dr5K49bx.js} +28 -28
- package/dist/ui/assets/document-companion-BQk2kS0F.js +1 -0
- package/dist/ui/assets/document-import-QoM9UxJr.js +1 -0
- package/dist/ui/assets/docx-sXa1Rf41.js +2 -0
- package/dist/ui/assets/{epub-B98SgHBz.js → epub-RopMP0ec.js} +4 -4
- package/dist/ui/assets/{export-options-Bu-tI6og.js → export-options-f7PKjEBb.js} +1 -1
- package/dist/ui/assets/extract-UTAOG7LV-4WDRw1o4.js +1 -0
- package/dist/ui/assets/file-browser-c2tf4MIb.js +5 -0
- package/dist/ui/assets/html-BGVOMhkv.js +253 -0
- package/dist/ui/assets/icons-DWaUNQbT.js +1 -0
- package/dist/ui/assets/images-JLBFCDD4-6JitW0hD.js +1 -0
- package/dist/ui/assets/index-B8NcxqcR.css +1 -0
- package/dist/ui/assets/index-C0DYtvfg.js +34 -0
- package/dist/ui/assets/index-J8TOMdvV.js +2 -0
- package/dist/ui/assets/{infer-kCLH1C8z.js → infer-LEGOsu64.js} +2 -2
- package/dist/ui/assets/ironcalc-BAi5gOlE.js +3 -0
- package/dist/ui/assets/layouts-2A7QNF6Y-CVwP7noP.js +1 -0
- package/dist/ui/assets/{mail-link-CI6YD6k2.js → mail-link-DXkmCd5b.js} +1 -1
- package/dist/ui/assets/markdown-baseline-9B52XlX2.js +1 -0
- package/dist/ui/assets/{markdown-Bi9b5f5Y.js → markdown-ryKA_OmY.js} +1 -1
- package/dist/ui/assets/materialize-A34OZGEU-xNNKzytx.js +1 -0
- package/dist/ui/assets/model-inventory-ykSm_IT5.js +1 -0
- package/dist/ui/assets/{model-quantization-BDzrELN_.js → model-quantization-CLO7XLoF.js} +1 -1
- package/dist/ui/assets/{monaco-base-BiVSa1J-.js → monaco-base-B1H1U1Sw.js} +1 -1
- package/dist/ui/assets/{monaco-setup-UeltVkg_.js → monaco-setup-DjhrGQui.js} +1 -1
- package/dist/ui/assets/{new-project-meta-0xhggGA_.js → new-project-meta-_f9sfcRX.js} +1 -1
- package/dist/ui/assets/outside-in-D73N1g_b.js +3 -0
- package/dist/ui/assets/{pdf-DgTjy3rN.js → pdf-BOjVDlCK.js} +3 -3
- package/dist/ui/assets/{pending-drafts-YVW6X55O.js → pending-drafts-B11MKQ9R.js} +1 -1
- package/dist/ui/assets/{poppetje-Ce-02Aqi.js → poppetje-DLB8uevw.js} +2 -2
- package/dist/ui/assets/pptx-BuxyNxQh.js +6 -0
- package/dist/ui/assets/primitives-CWrGZpPI.js +41 -0
- package/dist/ui/assets/run-export-ChaMXrKS.js +23 -0
- package/dist/ui/assets/squisq-formats-aAdypXoy.js +1 -0
- package/dist/ui/assets/standalone-source-q_Zzd1bd.js +11 -0
- package/dist/ui/assets/storage-D8pE2zg0.js +1 -0
- package/dist/ui/assets/styles-BhnF3s2q.css +1 -0
- package/dist/ui/assets/styles-CKVKwqoQ.js +550 -0
- package/dist/ui/assets/table-fcouR4db.js +1 -0
- package/dist/ui/assets/{terminal-monaco-setup-DNoK2tN4.js → terminal-monaco-setup-BAzrVzeR.js} +1 -1
- package/dist/ui/assets/{useCompactLayout-BarJPYcv.js → useCompactLayout-Dtolvzye.js} +0 -0
- package/dist/ui/assets/{useCopilotAvailability-BH1nLXQI.js → useCopilotAvailability-3xZvKgTF.js} +1 -1
- package/dist/ui/assets/{useDiffpacks-CK8W_OD_.js → useDiffpacks-Dsnr0wtX.js} +1 -1
- package/dist/ui/assets/{useGitSync-DWxX5-7K.js → useGitSync-BCTptQsp.js} +1 -1
- package/dist/ui/assets/{useShowWorkInProgressFeatures-DwwviLRO.js → useShowWorkInProgressFeatures-BhDNuQiU.js} +1 -1
- package/dist/ui/assets/{useTotalRamBytes-WoN_mi-V.js → useTotalRamBytes-DIx-_pf8.js} +1 -1
- package/dist/ui/assets/wasm-DdxEDD2H.js +1 -0
- package/dist/ui/assets/wasm_bg-DW9Xt_vt.wasm +0 -0
- package/dist/ui/assets/xlsx-DyBGuAO1.js +4 -0
- package/dist/ui/index.html +19 -18
- package/package.json +11 -11
- package/dist/ui/assets/AmbientDashboardCard-C1Ee-FKZ.js +0 -1
- package/dist/ui/assets/CatalogBrowser-Bz8ZtxPn.js +0 -1
- package/dist/ui/assets/ChatTimelineView-Do9EryEH.js +0 -7
- package/dist/ui/assets/ConfirmDialog-BHFs6vmJ.js +0 -1
- package/dist/ui/assets/ConnectedAppsPanel-BtMayq0R.js +0 -1
- package/dist/ui/assets/CraftbookEditor-D5jTzWwF.js +0 -1
- package/dist/ui/assets/DocumentDetail-CPU51d04.js +0 -1
- package/dist/ui/assets/DocumentsView-B6OyjvJ0.js +0 -1
- package/dist/ui/assets/DropdownMenu-D5fCzIrh.js +0 -1
- package/dist/ui/assets/Ds4Settings-CrUM_KGP.js +0 -1
- package/dist/ui/assets/EmbeddedChat-ue9ia-WY.js +0 -1
- package/dist/ui/assets/FileMapView-CxvfDLGA.js +0 -1
- package/dist/ui/assets/GezelDetail-DHuqBK55.js +0 -1
- package/dist/ui/assets/HandboekView-CPnnyj29.js +0 -1
- package/dist/ui/assets/HistoryView-B4VAfEMe.js +0 -1
- package/dist/ui/assets/HomeView-ccH60J6f.js +0 -1
- package/dist/ui/assets/KnowledgeCatalogsCard-Bi5Rx9Iz.js +0 -1
- package/dist/ui/assets/KnowledgeView-DAwjwLZo.js +0 -1
- package/dist/ui/assets/LlamaCppSettings-Ceyk9pDP.js +0 -1
- package/dist/ui/assets/MemoriesTree-BKZEPJpm.js +0 -1
- package/dist/ui/assets/MlxSettings-CG3wfuc3.js +0 -1
- package/dist/ui/assets/ModelPicker-CCBVjLMS.js +0 -1
- package/dist/ui/assets/NewPathDialog-D4jnNBfP.js +0 -1
- package/dist/ui/assets/NewTaskDialog-Ox9D612Z.js +0 -2
- package/dist/ui/assets/ProjectChat-DMwKnkW-.js +0 -5
- package/dist/ui/assets/ProjectGitStatusBar-C6bkCSby.js +0 -1
- package/dist/ui/assets/ProjectOverviewView-NNwXd_QQ.js +0 -1
- package/dist/ui/assets/ProjectsView-SBPgYOq8.js +0 -7
- package/dist/ui/assets/ScriptEditorTabs-paocQ6dj.js +0 -2
- package/dist/ui/assets/ScriptEditorView-N9zSLqqi.js +0 -5
- package/dist/ui/assets/SessionSwitcher-C8te7YSe.js +0 -1
- package/dist/ui/assets/SettingsView-Brl4JQkW.js +0 -3
- package/dist/ui/assets/Tabs-BAY1Q79B.js +0 -1
- package/dist/ui/assets/TaskTabContent-CNPJ4DQj.js +0 -1
- package/dist/ui/assets/TasksView-DuMjFS8S.js +0 -1
- package/dist/ui/assets/ToolsetsEditor-BdxHnIBj.js +0 -8
- package/dist/ui/assets/TransformToolbarButton-CVg5nz36.js +0 -5
- package/dist/ui/assets/UnrecognizedModels-Cw9Ku_bW.js +0 -1
- package/dist/ui/assets/chat-thread-memory-CZGcwgGo.js +0 -1
- package/dist/ui/assets/chunk-6ECMNUIP-C1kohb1U.js +0 -15
- package/dist/ui/assets/chunk-AONELFLA-Cv2nS9ga.js +0 -1
- package/dist/ui/assets/chunk-IIQYS2YH-Dxg6MAfT.js +0 -1
- package/dist/ui/assets/chunk-MIKKUKOD-XIkmalSN.js +0 -31
- package/dist/ui/assets/chunk-NNJLSQPW-DJA6camf.js +0 -5
- package/dist/ui/assets/chunk-S5PCVMKU-DbCZ5AUH.js +0 -6
- package/dist/ui/assets/csv-xmd1_Aqd.js +0 -4
- package/dist/ui/assets/dist-BPx-FyRH.js +0 -222
- package/dist/ui/assets/dist-Bvo52IGx.js +0 -1
- package/dist/ui/assets/dist-D5aoNQwk.js +0 -2
- package/dist/ui/assets/docx-Cj4A9MhC.js +0 -2
- package/dist/ui/assets/extract-UTAOG7LV-C4b7ycaL.js +0 -1
- package/dist/ui/assets/file-browser-80qWoVju.js +0 -5
- package/dist/ui/assets/html-C9TlzI57.js +0 -253
- package/dist/ui/assets/icons-C9dD-bDi.js +0 -1
- package/dist/ui/assets/images-ESPQKVTW-D7SgdVJ_.js +0 -1
- package/dist/ui/assets/index-D1m4Wx8V.css +0 -1
- package/dist/ui/assets/index-DXWR4qW1.js +0 -34
- package/dist/ui/assets/layouts-2A7QNF6Y-De2t-YXl.js +0 -1
- package/dist/ui/assets/markdown-baseline-HMqF2ChK.js +0 -1
- package/dist/ui/assets/outside-in-BFVUUcLa.js +0 -3
- package/dist/ui/assets/pptx-6ChgUEf4.js +0 -6
- package/dist/ui/assets/primitives-DEsn1shf.js +0 -41
- package/dist/ui/assets/run-export-BrYhHj1O.js +0 -23
- package/dist/ui/assets/standalone-source-D6mbpa3h.js +0 -11
- package/dist/ui/assets/storage-fn4FCEVK.js +0 -1
- package/dist/ui/assets/styles-C0EoNJbk.css +0 -1
- package/dist/ui/assets/styles-CKr_yrbn.js +0 -541
- package/dist/ui/assets/xlsx-DH7sTb3W.js +0 -4
|
@@ -0,0 +1,550 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-DeTXJU-n.js","assets/rolldown-runtime-aKtaBQYM.js","assets/preload-helper-Czpn1I53.js","assets/chunk-V4NBQF5C-D9I4DV9v.js","assets/iconLabel-uMn49Ame.js","assets/iconLabel-Bdh_-Hrb.css","assets/codiconStyles-104B1IQ5.js","assets/codiconStyles-Bp1tMeMk.css","assets/editor.api-DShZZcgD.js","assets/editor-BOOlEWca.css","assets/monaco-Cvm179Eb.css","assets/infer-LEGOsu64.js","assets/chunk-7AWFHP5U-MiVVPFTx.js","assets/jszip.min-DhiFe-R7.js","assets/chunk-S5PCVMKU-Df5XzhSE.js","assets/chunk-WATAOG4Y-C1EXVPmG.js","assets/chunk-2JJ5RFDZ-B2-BFNXu.js","assets/chunk-GAZKTT4R-BkP6-w3z.js","assets/chunk-BAOV476U-CEOFYt8X.js","assets/chunk-4VOD55SX-BFSSw0c8.js","assets/schemas-JY4jmLbC.js","assets/chunk-KXOZMWBS-BwD4KMLI.js","assets/docx-sXa1Rf41.js","assets/doc-Dr5K49bx.js","assets/chunk-O7JILDEF-CqcO1qaI.js","assets/chunk-UBFT2CDQ-FexGDigd.js","assets/chunk-XRW6P7IF-BeQQgMVK.js","assets/chunk-7ZAAICW4-BsCpYJH6.js","assets/markdown-ryKA_OmY.js","assets/chunk-JU2RHXUB-ClblWDJZ.js","assets/chunk-A6N6IN3I-ofeM4l8g.js","assets/chunk-B7GEAZBI-Divd2h1k.js","assets/chunk-ILCJ3WFD-CLZxw4Ge.js","assets/chunk-BXWNU4T5-CFA9w1DZ.js","assets/chunk-IIQYS2YH-DKZhWMpn.js","assets/index-C0DYtvfg.js","assets/jsx-runtime-CEpd2cAX.js","assets/react-dom-OL4w_gzs.js","assets/dist-BqGwkOe5.js","assets/dist-BaHut5iX.js","assets/api-BPraLwsh.js","assets/primitives-CWrGZpPI.js","assets/Tabs-jE0Z5Tzd.js","assets/document-companion-BQk2kS0F.js","assets/DropdownMenu-S4d9-3j3.js","assets/dist-pLLFUPO-.js","assets/relative-time-B2kBaekd.js","assets/FileTypeIcon-Cwzl1GkZ.js","assets/model-context-DBqdK0PS.js","assets/model-memory-copy-CeuXAj-T.js","assets/StorageCleanupDialog-OQlomMJD.js","assets/poppetje-DLB8uevw.js","assets/safe-svg-image-NbuPaBIv.js","assets/ConfirmDialog-Dt1ed4Fh.js","assets/model-inventory-ykSm_IT5.js","assets/chunk-6ECMNUIP-DDVjPyfK.js","assets/inlineIconMarker-BQI2HLeD.js","assets/chunk-TT6ENR6T-CaYjVwjm.js","assets/chunk-DAMIRKTO-CGniCSiM.js","assets/new-project-meta-_f9sfcRX.js","assets/chunk-AE3IUKMM-mZjzzO8Z.js","assets/index-B8NcxqcR.css","assets/storage-D8pE2zg0.js","assets/chunk-USU6HTKB-B_p-YcDp.js","assets/icons-DWaUNQbT.js","assets/mermaid.core-CJfks21t.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-UMNXGZaF.js","assets/chunk-I66GZJ75-LdZkBIbB.js","assets/chunk-NSK5VX7P-52z7Dk2L.js","assets/dist-qx0Iv9vM.js","assets/chunk-3NCLNEKW-lEIanHax.js","assets/chunk-4I5QYGJK-CM-bp6pS.js","assets/chunk-WRU74C26-DepDkkds.js","assets/chunk-7BUUIJ7U-Bb538aSH.js","assets/chunk-UBXNYLIW-BndvwrJT.js","assets/chunk-W5SLKNZC-DYPZQgVw.js","assets/chunk-QR6OTTB3-BCXb4Qaf.js","assets/rough.esm-CSKSodPl.js","assets/chunk-7Z6QIM7H-BQaDNVzL.js","assets/line-CFHPqps4.js","assets/path-BWPyau1x.js","assets/array-BifhSqXX.js","assets/chunk-J7OUQ5F2-CYJFmXpz.js","assets/chunk-ZIRB5QZD-C6fEPe3t.js","assets/data-B2kHjlc5.js","assets/chunk-DXYWKZ52-BXcAlClu.js","assets/chunk-Q77KNJIN-BIDRf0aP.js","assets/chunk-OBADJV7C-CDVOcmYt.js","assets/chunk-FLR2ARKC-D7wrvQgT.js","assets/table-fcouR4db.js","assets/csv-62UGQMzZ.js","assets/xlsx-DyBGuAO1.js","assets/dist-ZnIgkoEi.js","assets/html-BGVOMhkv.js","assets/chunk-VPWPEMZJ-DRKoa_j0.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e,t}from"./rolldown-runtime-aKtaBQYM.js";import{n,t as r}from"./jsx-runtime-CEpd2cAX.js";import{t as i}from"./react-dom-OL4w_gzs.js";import{A as a,At as o,B as s,Bt as c,C as l,Ct as u,D as d,Dt as f,E as p,Et as m,Ft as h,G as g,H as _,Ht as v,I as y,It as b,J as x,K as S,M as C,Mt as w,N as T,Nt as E,O as D,Ot as O,Pt as k,Rt as A,St as j,Tt as M,U as N,V as P,Vt as F,W as I,X as L,Y as ee,Z as te,_t as R,a as ne,at as re,b as z,bt as ie,c as ae,ct as oe,dt as se,et as ce,f as le,ft as B,g as ue,h as V,ht as de,i as fe,it as H,j as pe,jt as me,k as U,kt as he,l as ge,lt as _e,m as W,mt as ve,n as ye,nt as be,o as xe,ot as Se,pt as Ce,q as we,r as Te,rt as Ee,s as De,st as Oe,tt as ke,ut as Ae,v as je,wt as Me,x as Ne,xt as Pe,y as Fe,yt as Ie,z as Le,zt as Re}from"./doc-Dr5K49bx.js";import{a as ze,c as Be,i as Ve,l as He,t as Ue,u as We}from"./chunk-O7JILDEF-CqcO1qaI.js";import{n as Ge,o as Ke}from"./chunk-BAOV476U-CEOFYt8X.js";import{a as qe}from"./chunk-4VOD55SX-BFSSw0c8.js";import{D as Je,O as Ye,a as Xe,b as Ze,c as Qe,d as $e,i as et,j as tt,k as nt,l as rt,n as it,o as at,r as ot,s as st,u as ct,v as lt,x as ut}from"./chunk-GAZKTT4R-BkP6-w3z.js";import{A as dt,B as ft,C as pt,I as mt,M as ht,N as gt,O as _t,P as vt,R as yt,_ as bt,b as xt,g as St,i as Ct,k as wt,n as Tt,r as Et,v as Dt,w as Ot,x as kt,y as At,z as jt}from"./chunk-UBFT2CDQ-FexGDigd.js";import{a as Mt,d as Nt,l as Pt,n as Ft,o as It,r as Lt,s as Rt,u as zt}from"./markdown-ryKA_OmY.js";import{n as Bt,r as Vt,t as Ht}from"./schemas-JY4jmLbC.js";import{t as Ut}from"./preload-helper-Czpn1I53.js";import{A as Wt,B as Gt,C as Kt,D as qt,E as Jt,F as Yt,G as Xt,H as Zt,I as Qt,J as $t,K as en,L as tn,M as nn,N as rn,O as an,P as on,R as sn,S as cn,U as ln,V as un,W as dn,X as fn,Y as pn,_ as mn,a as hn,b as gn,c as _n,d as vn,f as yn,h as bn,i as xn,j as Sn,k as Cn,l as wn,m as Tn,n as En,o as Dn,p as On,q as kn,r as An,s as jn,t as Mn,u as Nn,w as Pn,x as Fn,z as In}from"./chunk-6ECMNUIP-DDVjPyfK.js";import{t as Ln}from"./chunk-TT6ENR6T-CaYjVwjm.js";import{a as Rn,i as zn,n as Bn,o as Vn,r as Hn,s as Un,t as Wn}from"./chunk-VKXOZTYP-BoVvWSBR.js";import{c as Gn,r as Kn,s as qn}from"./chunk-AE3IUKMM-mZjzzO8Z.js";import{Bt as Jn,I as Yn,V as Xn,z as Zn}from"./index-C0DYtvfg.js";import{n as Qn,r as $n,t as er}from"./chunk-V4NBQF5C-D9I4DV9v.js";import"./storage-D8pE2zg0.js";import{a as tr,i as nr,t as rr}from"./table-fcouR4db.js";import"./icons-DWaUNQbT.js";import"./transform-CmAXy0Ck.js";import{A as ir,C as ar,D as or,E as sr,F as cr,I as lr,L as ur,M as dr,N as fr,O as pr,P as mr,S as hr,T as gr,_ as _r,a as vr,b as yr,c as br,d as xr,f as Sr,g as Cr,h as wr,i as Tr,j as Er,k as Dr,l as Or,m as kr,n as Ar,o as jr,p as Mr,r as Nr,s as Pr,t as Fr,u as Ir,v as Lr,w as Rr,x as zr,y as Br}from"./dist-l6uUFZMV.js";var G=e(n(),1),Vr=[`a[href]`,`button:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex="-1"])`].join(`,`);function Hr(e){let t=[],n=e;for(;n?.parentElement;){for(let e of n.parentElement.children)e===n||!(e instanceof HTMLElement)||(t.push({element:e,inert:e.inert===!0,ariaHidden:e.getAttribute(`aria-hidden`)}),e.inert=!0,e.setAttribute(`aria-hidden`,`true`));if(n=n.parentElement,n===document.body)break}return t}function Ur({rootRef:e,dialogRef:t,initialFocusRef:n,returnFocusRef:r,closeOnEscape:i=!0,onClose:a}){let o=(0,G.useRef)(a);o.current=a,(0,G.useEffect)(()=>{let a=e.current,s=t.current;if(!a||!s)return;let c=r?.current??(document.activeElement instanceof HTMLElement?document.activeElement:null),l=Hr(a),u=document.activeElement instanceof HTMLElement&&s.contains(document.activeElement)?document.activeElement:null,d=n?.current??u??s.querySelector(Vr)??s;d.focus(),(d instanceof HTMLInputElement||d instanceof HTMLTextAreaElement)&&d.select();let f=e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),i&&o.current();return}if(e.key!==`Tab`)return;let t=[...s.querySelectorAll(Vr)].filter(e=>!e.hidden&&e.getAttribute(`aria-hidden`)!==`true`&&e.getAttribute(`aria-disabled`)!==`true`);if(t.length===0){e.preventDefault(),s.focus();return}let n=t[0],r=t[t.length-1];e.shiftKey&&(document.activeElement===n||!s.contains(document.activeElement))?(e.preventDefault(),r.focus()):!e.shiftKey&&(document.activeElement===r||!s.contains(document.activeElement))&&(e.preventDefault(),n.focus())};return document.addEventListener(`keydown`,f,!0),()=>{document.removeEventListener(`keydown`,f,!0);for(let e of l)e.element.inert=e.inert,e.ariaHidden===null?e.element.removeAttribute(`aria-hidden`):e.element.setAttribute(`aria-hidden`,e.ariaHidden);c?.isConnected&&c.focus()}},[i,t,n,r,e])}var Wr=e(i(),1),Gr=e(Jn(),1),K=r();function q({icon:e,className:t,style:n}){return(0,K.jsx)(`i`,{className:t?`${e} ${t}`:e,style:n,"aria-hidden":`true`})}var Kr=.1,qr=16,Jr=1.25;function Yr({src:e,alt:t=``,className:n,theme:r=`light`}){let i=(0,G.useRef)(null),a=(0,G.useRef)(null),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(1),[u,d]=(0,G.useState)({mode:`fit`}),[f,p]=(0,G.useState)({x:0,y:0}),[m,h]=(0,G.useState)(null);(0,G.useEffect)(()=>{s(null),d({mode:`fit`}),p({x:0,y:0}),h(null)},[e]);let g=(0,G.useCallback)(()=>{let e=a.current;if(!e||!o)return;let{clientWidth:t,clientHeight:n}=e;if(t===0||n===0)return;let r=Math.min(t/o.w,n/o.h,1);l(r>0?r:1)},[o]);(0,G.useEffect)(()=>{if(g(),typeof ResizeObserver>`u`)return;let e=a.current;if(!e)return;let t=new ResizeObserver(()=>g());return t.observe(e),()=>t.disconnect()},[g]);let _=(0,G.useCallback)(()=>{let e=i.current;e&&s({w:e.naturalWidth,h:e.naturalHeight})},[]),v=(0,G.useCallback)(()=>{h(`Failed to load image`)},[]),y=u.mode===`fit`?c:u.zoom,b=(0,G.useCallback)(e=>{d({mode:`manual`,zoom:Math.max(Kr,Math.min(qr,e))})},[]),x=(0,G.useCallback)(()=>{d({mode:`fit`}),p({x:0,y:0})},[]),S=(0,G.useCallback)(()=>{b(1),p({x:0,y:0})},[b]),C=(0,G.useCallback)(()=>b(y*Jr),[y,b]),w=(0,G.useCallback)(()=>b(y/Jr),[y,b]),T=(0,G.useRef)(null),E=(0,G.useCallback)(e=>{y<=c||(T.current={startX:e.clientX,startY:e.clientY,panX:f.x,panY:f.y},e.preventDefault())},[y,c,f.x,f.y]);(0,G.useEffect)(()=>{let e=e=>{let t=T.current;t&&p({x:t.panX+(e.clientX-t.startX),y:t.panY+(e.clientY-t.startY)})},t=()=>{T.current=null};return window.addEventListener(`mousemove`,e),window.addEventListener(`mouseup`,t),()=>{window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,t)}},[]);let D=y>c+1e-6,O=o?{width:`${o.w*y}px`,height:`${o.h*y}px`,transform:`translate(${f.x}px, ${f.y}px)`}:{maxWidth:`100%`,maxHeight:`100%`};return(0,K.jsxs)(`div`,{className:[`squisq-image-viewer`,`squisq-image-viewer--${r}`,n].filter(Boolean).join(` `),"data-testid":`image-viewer`,children:[(0,K.jsxs)(`div`,{ref:a,className:`squisq-image-viewer-stage`,onMouseDown:E,style:{cursor:D?T.current?`grabbing`:`grab`:`default`},children:[m?(0,K.jsx)(`div`,{className:`squisq-image-viewer-error`,children:m}):(0,K.jsx)(`img`,{ref:i,src:e,alt:t,className:`squisq-image-viewer-img`,style:O,onLoad:_,onError:v,draggable:!1}),(0,K.jsxs)(`div`,{className:`squisq-image-viewer-toolbar`,children:[(0,K.jsx)(`button`,{type:`button`,className:`squisq-image-viewer-btn`,onClick:w,"aria-label":`Zoom out`,title:`Zoom out`,children:`−`}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-image-viewer-btn`,onClick:x,"aria-pressed":u.mode===`fit`,title:`Fit to viewport`,children:`Fit`}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-image-viewer-btn`,onClick:S,title:`Actual size (100%)`,children:`100%`}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-image-viewer-btn`,onClick:C,"aria-label":`Zoom in`,title:`Zoom in`,children:`+`})]})]}),(0,K.jsx)(`div`,{className:`squisq-image-viewer-status`,children:o?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{children:[o.w,` × `,o.h]}),(0,K.jsxs)(`span`,{children:[Math.round(y*100),`%`]})]}):(0,K.jsx)(`span`,{children:`Loading…`})})]})}function Xr(e){return{doc:e,selectedLayerId:null,tool:`select`,shapeKind:`rectangle`,dirty:!1}}function Zr(e,t){switch(t.type){case`load`:return{doc:t.doc,selectedLayerId:null,tool:`select`,shapeKind:e.shapeKind,dirty:!1};case`mark-clean`:return e.dirty?{...e,dirty:!1}:e;case`set-tool`:return e.tool===t.tool?e:{...e,tool:t.tool};case`set-shape-kind`:return e.shapeKind===t.kind?e:{...e,shapeKind:t.kind};case`select`:return e.selectedLayerId===t.layerId?e:{...e,selectedLayerId:t.layerId};case`set-canvas`:{let n=Nn(e.doc,t.canvas);return n===e.doc?e:{...e,doc:n,dirty:!0}}case`add-layer`:{let n=xn(e.doc,t.layer),r=n.layers[n.layers.length-1].id;return{...e,doc:n,dirty:!0,selectedLayerId:t.select===!1?e.selectedLayerId:r}}case`remove-layer`:{let n=_n(e.doc,t.layerId);return n===e.doc?e:{...e,doc:n,dirty:!0,selectedLayerId:e.selectedLayerId===t.layerId?null:e.selectedLayerId}}case`update-layer`:{let n=yn(e.doc,t.layerId,t.patch);return n===e.doc?e:{...e,doc:n,dirty:!0}}case`reorder-layer`:{let n=wn(e.doc,t.layerId,t.toIndex);return n===e.doc?e:{...e,doc:n,dirty:!0}}case`crop`:{let{rect:n}=t,r={...e.doc.canvas,width:Math.max(1,Math.round(n.width)),height:Math.max(1,Math.round(n.height))},i=e.doc.layers.map(e=>{let{position:t}=e,r=typeof t.x==`number`?t.x-n.x:t.x,i=typeof t.y==`number`?t.y-n.y:t.y;return{...e,position:{...t,x:r,y:i}}}),a=vn({...e.doc,canvas:r,layers:i});return{...e,doc:a,dirty:!0}}}}function Qr(e){let{container:t,initialSrc:n,resourcePolicy:r=Ft,stateFilename:i=En,allowVersioning:a=!1,versioningAutoSaveIdleMs:o=5e3,persistDebounceMs:s=500}=e,[c,l]=(0,G.useReducer)((e,t)=>e===null?t.type===`load`?Xr(t.doc):null:Zr(e,t),null),[u,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(null),m=(0,G.useRef)(!1);(0,G.useEffect)(()=>{let e=!1,a=new AbortController;return d(!1),p(null),(async()=>{try{let o=await jn(t,i);if(e)return;if(o){l({type:`load`,doc:o}),d(!0);return}let s=await $r(t,n,r,a.signal);if(e||(await On(t,s,i),e))return;l({type:`load`,doc:s}),d(!0),m.current=!0}catch(t){if(e)return;p(t instanceof Error?t:Error(String(t))),d(!0)}})(),()=>{e=!0,a.abort()}},[t,i,n,r]);let h=(0,G.useRef)(null),g=(0,G.useRef)(null),_=(0,G.useRef)(!1),v=(0,G.useRef)(0),y=(0,G.useRef)(null),b=c?.doc??null;b!==y.current&&(y.current=b,v.current+=1),g.current=b,_.current=c?.dirty??!1;let x=(0,G.useRef)(Promise.resolve()),S=(0,G.useRef)({container:t,stateFilename:i});S.current={container:t,stateFilename:i};let C=(0,G.useCallback)((e,n,r)=>{let a=x.current.catch(()=>void 0).then(()=>On(t,e,i));return x.current=a.catch(()=>void 0),a.then(()=>{r&&n===v.current&&g.current===e&&l({type:`mark-clean`})})},[t,i]);(0,G.useEffect)(()=>{if(c?.dirty)return h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{let e=c.doc;if(!e)return;let t=v.current;C(e,t,!0).catch(e=>{console.warn(`[squisq-editor] image-edit state persist failed:`,e instanceof Error?e.message:e)})},s),()=>{h.current&&clearTimeout(h.current)}},[c?.dirty,c?.doc,s,C]);let w=(0,G.useCallback)(async()=>{let e=g.current;e&&(h.current&&=(clearTimeout(h.current),null),await C(e,v.current,!0))},[C]);(0,G.useEffect)(()=>()=>{h.current&&clearTimeout(h.current);let e=g.current;if(!_.current||!e)return;let t=S.current,n=x.current.catch(()=>void 0).then(()=>On(t.container,e,t.stateFilename));x.current=n.catch(e=>{console.warn(`[squisq-editor] image-edit final persist failed:`,e instanceof Error?e.message:e)})},[]);let T=(0,G.useMemo)(()=>a?new An(t,{stateFilename:i}):null,[a,t,i]);(0,G.useEffect)(()=>{T&&u&&m.current&&(m.current=!1,T.saveVersion({force:!0}).catch(e=>{console.warn(`[squisq-editor] image-edit initial snapshot failed:`,e instanceof Error?e.message:e)}))},[T,u]),(0,G.useEffect)(()=>{if(!T||o<=0||!c?.doc)return;let e=setTimeout(()=>{T.saveVersion({doc:g.current??void 0}).catch(e=>{console.warn(`[squisq-editor] image-edit auto-save version failed:`,e instanceof Error?e.message:e)})},o);return()=>clearTimeout(e)},[T,o,c?.doc]);let E=(0,G.useRef)(new Map),D=(0,G.useRef)(0),O=(0,G.useCallback)(async e=>{let n=E.current,r=D.current,i=n.get(e);if(i)return i;let a=await t.readFile(e);if(r!==D.current)throw Error(`useImageEditor: asset resolution cancelled`);if(!a)throw Error(`useImageEditor: missing asset "${e}"`);let o=(await t.listFiles(e)).find(t=>t.path===e)?.mimeType??`application/octet-stream`,s=URL.createObjectURL(new Blob([a],{type:o}));if(r!==D.current)throw URL.revokeObjectURL(s),Error(`useImageEditor: asset resolution cancelled`);return n.set(e,s),s},[t]);return(0,G.useEffect)(()=>{let e=E.current;return()=>{D.current+=1;for(let t of e.values())URL.revokeObjectURL(t);e.clear()}},[t]),{state:c,dispatch:l,flush:w,resolveAssetUrl:O,uploadAsset:(0,G.useCallback)(async(e,n)=>{let r=ti(e.type)??ni(n)??`bin`,i=`${Mn}${ri()}.${r}`,a=await e.arrayBuffer();return await t.writeFile(i,a,e.type||void 0),i},[t]),versioning:T,ready:u,error:f}}async function $r(e,t,n,r){if(!t)return hn(800,600);let i=await Rt(t,{policy:n,signal:r,contentTypePrefixes:[`image/`,`application/octet-stream`]}),a=i.contentType||`application/octet-stream`,o=new Blob([i.bytes.slice().buffer],{type:a}),s=`${Mn}source.${ti(a)??ni(i.finalUrl)??`png`}`;await e.writeFile(s,i.bytes,a||void 0);let c=URL.createObjectURL(o),l=await ei(c);URL.revokeObjectURL(c);let u=l?.width??800,d=l?.height??600;if(u*d>1e8)throw Error(`useImageEditor: source image exceeds the 100-megapixel safety limit`);return{version:1,canvas:{width:u,height:d,background:`transparent`},layers:[{id:`base`,type:`image`,name:`Background`,position:{x:0,y:0,width:u,height:d},content:{src:s,alt:``,fit:`fill`}}],meta:{sourcePath:s,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}}}function ei(e){return new Promise(t=>{let n=new Image;n.onload=()=>t({width:n.naturalWidth,height:n.naturalHeight}),n.onerror=()=>t(null),n.src=e})}function ti(e){return e?e.includes(`png`)?`png`:e.includes(`jpeg`)||e.includes(`jpg`)?`jpg`:e.includes(`webp`)?`webp`:e.includes(`gif`)?`gif`:e.includes(`svg`)?`svg`:null:null}function ni(e){if(!e)return null;let t=e.lastIndexOf(`.`);return t>=0?e.slice(t+1).toLowerCase():null}function ri(){return Math.random().toString(36).slice(2,10)}function ii({layer:e,canvas:t,resolveAssetUrl:n}){let[r,i]=(0,G.useState)(null),a=e.content.src;if((0,G.useEffect)(()=>{let e=!1;return n(a).then(t=>{e||i(t)}).catch(()=>{e||i(null)}),()=>{e=!0}},[a,n]),!r)return null;let o=e.position,s=typeof o.x==`number`?o.x:0,c=typeof o.y==`number`?o.y:0,l=typeof o.width==`number`?o.width:t.width,u=typeof o.height==`number`?o.height:t.height,d=e.content.fit??`fill`;return(0,K.jsx)(`image`,{href:r,x:s,y:c,width:l,height:u,preserveAspectRatio:d===`cover`?`xMidYMid slice`:d===`contain`?`xMidYMid meet`:`none`})}function ai({layer:e,canvas:t}){let n=e.position,r=typeof n.x==`number`?n.x:0,i=typeof n.y==`number`?n.y:0,{text:a,style:o}=e.content,s=o.lineHeight??1.4,c=o.fontSize*s,l=(a??``).split(`
|
|
3
|
+
`),u=o.textAlign===`center`?`middle`:o.textAlign===`right`?`end`:`start`;return(0,K.jsx)(`text`,{x:r,y:i+o.fontSize,fontFamily:o.fontFamily??`sans-serif`,fontSize:o.fontSize,fontWeight:o.fontWeight??`normal`,fill:o.color,textAnchor:u,children:l.map((e,t)=>(0,K.jsx)(`tspan`,{x:r,dy:t===0?0:c,children:e||`\xA0`},t))})}function oi({layer:e,canvas:t}){let n=e.position,r=typeof n.x==`number`?n.x:0,i=typeof n.y==`number`?n.y:0,a=typeof n.width==`number`?n.width:100,o=typeof n.height==`number`?n.height:100,s=e.content,c=s.fill??`none`,l=s.stroke,u=s.strokeWidth;return s.shape===`rect`?(0,K.jsx)(`rect`,{x:r,y:i,width:a,height:o,rx:s.borderRadius,ry:s.borderRadius,fill:c,stroke:l,strokeWidth:u}):s.shape===`circle`?(0,K.jsx)(`circle`,{cx:r+a/2,cy:i+o/2,r:Math.min(a,o)/2,fill:c,stroke:l,strokeWidth:u}):(0,K.jsx)(`line`,{x1:r,y1:i,x2:r+a,y2:i+o,stroke:l??`#000`,strokeWidth:u??1})}var si=10;function ci({box:e,onHandlePointerDown:t}){let n=si/2,r=e.x+e.width/2,i=e.y+e.height/2,a=[{id:`nw`,x:e.x,y:e.y,cursor:`nwse-resize`},{id:`n`,x:r,y:e.y,cursor:`ns-resize`},{id:`ne`,x:e.x+e.width,y:e.y,cursor:`nesw-resize`},{id:`e`,x:e.x+e.width,y:i,cursor:`ew-resize`},{id:`se`,x:e.x+e.width,y:e.y+e.height,cursor:`nwse-resize`},{id:`s`,x:r,y:e.y+e.height,cursor:`ns-resize`},{id:`sw`,x:e.x,y:e.y+e.height,cursor:`nesw-resize`},{id:`w`,x:e.x,y:i,cursor:`ew-resize`}];return(0,K.jsxs)(`g`,{className:`squisq-image-editor-selection-handles`,pointerEvents:`none`,children:[(0,K.jsx)(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,fill:`none`,stroke:`#ffffff`,strokeOpacity:.9,strokeWidth:4,vectorEffect:`non-scaling-stroke`}),(0,K.jsx)(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,fill:`none`,stroke:`#39f`,strokeWidth:2,strokeDasharray:`6 4`,vectorEffect:`non-scaling-stroke`}),a.map(e=>(0,K.jsx)(`rect`,{x:e.x-n,y:e.y-n,width:si,height:si,fill:`#fff`,stroke:`#39f`,strokeWidth:2,vectorEffect:`non-scaling-stroke`,style:{cursor:e.cursor,pointerEvents:`all`},onPointerDown:n=>t(n,e.id)},e.id))]})}function li({doc:e,selectedLayerId:t,tool:n,resolveAssetUrl:r,dispatch:i,onCreateTextAt:a,onCreateShapeAt:o,onCreateShapeFromPoints:s,shapeDragDraw:c,workspaceBackground:l,zoom:u=1,onSetZoom:d,surfaceRef:f,requestEditLayerId:p}){let m=`squisq-image-editor-checker-${(0,G.useId)().replace(/:/g,``)}`,h=(0,G.useRef)(null),g=(0,G.useRef)(null),[,_]=(0,G.useState)(0),[v,y]=(0,G.useState)(null),[b,x]=(0,G.useState)(null),S=(0,G.useRef)(null),C=(0,G.useRef)(null),[w,T]=(0,G.useState)(null),[E,D]=(0,G.useState)(null),O=(0,G.useRef)(null),k=(0,G.useCallback)((t,n)=>{let r=h.current;if(!r)return{x:0,y:0};let i=r.getBoundingClientRect();return{x:(t-i.left)/i.width*e.canvas.width,y:(n-i.top)/i.height*e.canvas.height}},[e.canvas.width,e.canvas.height]);(0,G.useLayoutEffect)(()=>{let e=C.current;e&&S.current&&(C.current=null,S.current.scrollLeft=e.left,S.current.scrollTop=e.top)},[u]);let A=(0,G.useCallback)(e=>{S.current=e,f&&(f.current=e)},[f]);(0,G.useEffect)(()=>{p&&D(p)},[p]),(0,G.useEffect)(()=>{E&&t!==E&&D(null)},[t,E]),(0,G.useLayoutEffect)(()=>{E&&O.current&&(O.current.focus(),O.current.select())},[E]);let j=(0,G.useCallback)((t,r)=>{if(n!==`select`||r.locked)return;t.stopPropagation();let a=k(t.clientX,t.clientY);i({type:`select`,layerId:r.id});let o=ui(r,e);g.current={layerId:r.id,startCanvasX:a.x,startCanvasY:a.y,startBox:o,handle:`move`},t.target.setPointerCapture?.(t.pointerId)},[n,i,k,e]),M=(0,G.useCallback)((n,r)=>{if(!t)return;let i=e.layers.find(e=>e.id===t);if(!i||i.locked)return;n.stopPropagation();let a=k(n.clientX,n.clientY),o=ui(i,e);g.current={layerId:i.id,startCanvasX:a.x,startCanvasY:a.y,startBox:o,handle:r},n.target.setPointerCapture?.(n.pointerId)},[t,e,k]),N=(0,G.useCallback)(e=>{let t=k(e.clientX,e.clientY);if(n===`select`){i({type:`select`,layerId:null}),D(null);return}if(n===`zoom-rect`){e.preventDefault(),T({startCanvasX:t.x,startCanvasY:t.y,currentX:t.x,currentY:t.y}),e.target.setPointerCapture?.(e.pointerId);return}if(n===`crop`){e.preventDefault(),y({startCanvasX:t.x,startCanvasY:t.y,currentX:t.x,currentY:t.y}),e.target.setPointerCapture?.(e.pointerId);return}if(n===`text`){a?.(t.x,t.y);return}n===`shape`&&(c?(e.preventDefault(),x({startX:t.x,startY:t.y,currentX:t.x,currentY:t.y}),e.target.setPointerCapture?.(e.pointerId)):o?.(t.x,t.y))},[n,i,k,a,o,c]);(0,G.useEffect)(()=>{function e(e){let t=g.current;if(t){let n=k(e.clientX,e.clientY),r=n.x-t.startCanvasX,a=n.y-t.startCanvasY,o=fi(t.startBox,t.handle,r,a);i({type:`update-layer`,layerId:t.layerId,patch:{position:{x:Math.round(o.x),y:Math.round(o.y),width:Math.round(o.width),height:Math.round(o.height)}}});return}if(b){let t=k(e.clientX,e.clientY);x(e=>e&&{...e,currentX:t.x,currentY:t.y});return}if(w){let t=k(e.clientX,e.clientY);T(e=>e&&{...e,currentX:t.x,currentY:t.y});return}if(v){let t=k(e.clientX,e.clientY);y(e=>e&&{...e,currentX:t.x,currentY:t.y})}}function t(){if(g.current&&(g.current=null,_(e=>e+1)),b&&(Math.hypot(b.currentX-b.startX,b.currentY-b.startY)>=4&&s?s(b.startX,b.startY,b.currentX,b.currentY):o?.(b.startX,b.startY),x(null)),w){let e=Math.abs(w.currentX-w.startCanvasX),t=Math.abs(w.currentY-w.startCanvasY);if(e>=10&&t>=10&&d&&S.current){let n=S.current,r=n.clientWidth-32,a=n.clientHeight-32,o=Math.max(.0625,Math.min(16,Math.min(r/e,a/t))),s=Math.min(w.startCanvasX,w.currentX)+e/2,c=Math.min(w.startCanvasY,w.currentY)+t/2;C.current={left:s*o-n.clientWidth/2+16,top:c*o-n.clientHeight/2+16},d(o),i({type:`set-tool`,tool:`select`})}T(null)}if(v){let e=pi(v);e.width>=8&&e.height>=8&&(i({type:`crop`,rect:e}),i({type:`set-tool`,tool:`select`})),y(null)}}return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},[k,i,v,b,w,d,s,o]);let P=t?e.layers.find(e=>e.id===t)??null:null,F=P?ui(P,e):null,I=P&&P.type===`text`?gi(P,F):F,L=(()=>{if(!I||!P)return null;let t=(P.type===`shape`||P.type===`path`?P.content.strokeWidth??0:0)/2,n=Math.max(e.canvas.width,e.canvas.height)*.007,r=Math.ceil(t+n);return{x:I.x-r,y:I.y-r,width:I.width+r*2,height:I.height+r*2}})();return(0,K.jsx)(`div`,{ref:A,className:`squisq-image-editor-surface`,style:{background:l??`#1f1f24`},children:(0,K.jsx)(`div`,{className:`squisq-image-editor-canvas-wrap`,children:(0,K.jsxs)(`svg`,{ref:h,viewBox:`0 0 ${e.canvas.width} ${e.canvas.height}`,width:Math.round(e.canvas.width*u),height:Math.round(e.canvas.height*u),className:`squisq-image-editor-canvas squisq-image-editor-canvas--tool-${n}`,onPointerDown:N,children:[(0,K.jsx)(`rect`,{x:0,y:0,width:e.canvas.width,height:e.canvas.height,fill:e.canvas.background&&e.canvas.background!==`transparent`?e.canvas.background:`url(#${m})`}),(0,K.jsx)(`defs`,{children:(0,K.jsxs)(`pattern`,{id:m,width:`16`,height:`16`,patternUnits:`userSpaceOnUse`,children:[(0,K.jsx)(`rect`,{width:`16`,height:`16`,fill:`#f0f0f0`}),(0,K.jsx)(`rect`,{width:`8`,height:`8`,fill:`#d0d0d0`}),(0,K.jsx)(`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,fill:`#d0d0d0`})]})}),e.layers.map(t=>{if(t.visible===!1)return null;let a=e=>j(e,t),o=t.type===`text`?e=>{e.stopPropagation(),i({type:`select`,layerId:t.id}),D(t.id)}:void 0,s=t.opacity??1,c=E===t.id;return(0,K.jsxs)(`g`,{"data-layer-id":t.id,opacity:s,visibility:c?`hidden`:void 0,pointerEvents:c?`none`:void 0,style:{cursor:n===`select`&&!t.locked?`move`:void 0},onPointerDown:c?void 0:a,onDoubleClick:o,children:[t.type===`image`&&(0,K.jsx)(ii,{layer:t,canvas:e.canvas,resolveAssetUrl:r}),t.type===`text`&&(0,K.jsx)(ai,{layer:t,canvas:e.canvas}),t.type===`shape`&&(0,K.jsx)(oi,{layer:t,canvas:e.canvas}),t.type===`path`&&(0,K.jsx)(dn,{layer:t,viewport:e.canvas,blockTime:0})]},t.id)}),P&&L&&n===`select`&&!P.locked&&E!==P.id&&(0,K.jsx)(ci,{box:L,onHandlePointerDown:M}),E&&(()=>{let t=e.layers.find(e=>e.id===E);if(!t||t.type!==`text`)return null;let n=ui(t,e),r=t,a=r.content,o=gi(r,n);return(0,K.jsx)(`foreignObject`,{x:o.x,y:o.y,width:o.width,height:o.height,style:{overflow:`visible`},children:(0,K.jsx)(`textarea`,{ref:O,value:a.text,onChange:e=>{i({type:`update-layer`,layerId:E,patch:{content:{...a,text:e.target.value}}})},onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),D(null))},onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),wrap:`off`,style:{display:`block`,width:`100%`,height:`100%`,padding:0,margin:0,border:`none`,outline:`2px dashed rgba(59,130,246,0.8)`,outlineOffset:`2px`,resize:`none`,background:`transparent`,fontFamily:a.style.fontFamily??`sans-serif`,fontSize:`${a.style.fontSize}px`,fontWeight:a.style.fontWeight??`normal`,color:a.style.color,textAlign:a.style.textAlign??`left`,lineHeight:a.style.lineHeight??1.4,caretColor:a.style.color,overflow:`hidden`,boxSizing:`border-box`}})},`inline-edit-${E}`)})(),b&&(0,K.jsx)(`line`,{x1:b.startX,y1:b.startY,x2:b.currentX,y2:b.currentY,stroke:`#39f`,strokeWidth:2,strokeDasharray:`6 4`,pointerEvents:`none`}),w&&(()=>{let e=pi(w);return(0,K.jsx)(`g`,{pointerEvents:`none`,children:(0,K.jsx)(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,fill:`rgba(255,200,0,0.08)`,stroke:`#f90`,strokeWidth:2,strokeDasharray:`6 4`,vectorEffect:`non-scaling-stroke`})})})(),v&&(()=>{let e=pi(v);return(0,K.jsx)(`g`,{pointerEvents:`none`,children:(0,K.jsx)(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,fill:`rgba(255,255,255,0.05)`,stroke:`#39f`,strokeWidth:2,strokeDasharray:`6 4`})})})()]})})})}function ui(e,t){let n=e.position;return{x:typeof n.x==`number`?n.x:0,y:typeof n.y==`number`?n.y:0,width:typeof n.width==`number`?n.width:t.canvas.width,height:typeof n.height==`number`?n.height:t.canvas.height}}var di=4;function fi(e,t,n,r){if(t===`move`)return{...e,x:e.x+n,y:e.y+r};let{x:i,y:a,width:o,height:s}=e;if(t.includes(`w`)){let e=Math.max(di,o-n);i+=o-e,o=e}else t.includes(`e`)&&(o=Math.max(di,o+n));if(t.includes(`n`)){let e=Math.max(di,s-r);a+=s-e,s=e}else t.includes(`s`)&&(s=Math.max(di,s+r));return{x:i,y:a,width:o,height:s}}function pi(e){return{x:Math.min(e.startCanvasX,e.currentX),y:Math.min(e.startCanvasY,e.currentY),width:Math.abs(e.currentX-e.startCanvasX),height:Math.abs(e.currentY-e.startCanvasY)}}var mi;function hi(){if(mi!==void 0)return mi;if(typeof document>`u`)return mi=null,null;try{mi=document.createElement(`canvas`).getContext(`2d`)}catch{mi=null}return mi??null}function gi(e,t){let n=hi();if(!n)return t;let{text:r,style:i}=e.content,a=i.fontSize;n.font=`${i.fontWeight??`normal`} ${a}px ${i.fontFamily??`sans-serif`}`;let o=(r??``).split(`
|
|
4
|
+
`),s=0;for(let e of o){let t=n.measureText(e||` `).width;t>s&&(s=t)}let c=a*(i.lineHeight??1.4),l=Math.max(1,o.length)*c,u=i.textAlign===`center`?`middle`:i.textAlign===`right`?`end`:`start`;return{x:u===`middle`?t.x-s/2:u===`end`?t.x-s:t.x,y:t.y,width:Math.max(di,Math.ceil(s)),height:Math.max(di,Math.ceil(l))}}var _i=96;function vi({versioning:e,container:t,onRevert:n,refreshKey:r}){let[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)([]),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(null),[f,p]=(0,G.useState)({}),m=(0,G.useRef)(null),h=(0,G.useRef)(null),g=(0,G.useRef)(new Set);(0,G.useEffect)(()=>{if(!i)return;let t=!1;return l(!0),e.listVersions().then(e=>{if(t)return;let n=[...e].sort((e,t)=>t.timestamp.getTime()-e.timestamp.getTime());s(n)}).catch(()=>{t||s([])}).finally(()=>{t||l(!1)}),()=>{t=!0}},[i,e,r]),(0,G.useEffect)(()=>{if(!i||o.length===0)return;let n=!1;return(async()=>{for(let r of o){if(n)return;if(!f[r.path])try{let i=await e.readVersion(r);if(n)return;if(!i){p(e=>({...e,[r.path]:{doc:wi(),thumbUrl:null}}));continue}let a=null;try{let e=await Dn(i,t,{format:`png`,scale:yi(i.canvas.width,i.canvas.height)});if(n)return;a=URL.createObjectURL(e),g.current.add(a)}catch{a=null}p(e=>({...e,[r.path]:{doc:i,thumbUrl:a}}))}catch{}}})(),()=>{n=!0}},[i,o,e,t,f]),(0,G.useEffect)(()=>{let e=g.current;return()=>{for(let t of e)URL.revokeObjectURL(t);e.clear()}},[]),(0,G.useEffect)(()=>{for(let e of g.current)URL.revokeObjectURL(e);g.current.clear(),p({})},[r]),(0,G.useEffect)(()=>{if(!i)return;function e(e){let t=e.target;t&&(m.current?.contains(t)||h.current?.contains(t)||a(!1))}function t(e){e.key===`Escape`&&a(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]);let _=(0,G.useCallback)(async e=>{d(e.timestamp.getTime());try{await n(e),a(!1)}catch(e){console.warn(`[squisq-editor] image-edit revert failed:`,e instanceof Error?e.message:e)}finally{d(null)}},[n]);return(0,K.jsxs)(`div`,{className:`squisq-image-editor-version-dropdown`,children:[(0,K.jsxs)(`button`,{ref:h,type:`button`,className:`squisq-image-editor-tool-button squisq-image-editor-tool-button--with-label`,onClick:()=>a(e=>!e),"aria-expanded":i,"aria-haspopup":`menu`,title:`Version history`,"data-testid":`image-editor-history-trigger`,children:[(0,K.jsx)(`span`,{children:`History`}),(0,K.jsx)(`span`,{"aria-hidden":`true`,style:{fontSize:`0.8em`},children:`▾`})]}),i&&(0,K.jsxs)(`div`,{ref:m,className:`squisq-image-editor-version-popover`,role:`menu`,"data-testid":`image-editor-history-popover`,children:[(0,K.jsx)(`div`,{className:`squisq-image-editor-version-popover__title`,children:`Version history`}),c&&(0,K.jsx)(`div`,{className:`squisq-image-editor-version-popover__empty`,children:`Loading…`}),!c&&o.length===0&&(0,K.jsx)(`div`,{className:`squisq-image-editor-version-popover__empty`,children:`No snapshots yet`}),!c&&o.length>0&&(0,K.jsx)(`ul`,{className:`squisq-image-editor-version-popover__list`,children:o.map((e,t)=>{let n=e.timestamp.getTime(),r=f[e.path],i=t===0,a=t+1>=o.length,s=t+1<o.length?f[o[t+1].path]:void 0,c=a?`Original`:r&&s?xi(s.doc,r.doc):``;return(0,K.jsxs)(`li`,{className:`squisq-image-editor-version-popover__row`+(i?` squisq-image-editor-version-popover__row--current`:``),children:[(0,K.jsx)(`div`,{className:`squisq-image-editor-version-popover__thumb`,children:r?.thumbUrl?(0,K.jsx)(`img`,{src:r.thumbUrl,alt:``,className:`squisq-image-editor-version-popover__thumb-img`}):(0,K.jsx)(`div`,{className:`squisq-image-editor-version-popover__thumb-placeholder`,"aria-hidden":`true`})}),(0,K.jsxs)(`div`,{className:`squisq-image-editor-version-popover__info`,children:[(0,K.jsxs)(`div`,{className:`squisq-image-editor-version-popover__when`,children:[i&&(0,K.jsx)(`span`,{className:`squisq-image-editor-version-popover__badge`,children:`Current`}),bi(e.timestamp)]}),(0,K.jsx)(`div`,{className:`squisq-image-editor-version-popover__summary`,title:c,children:c||(r?``:`Loading…`)})]}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-image-editor-tool-button`,onClick:()=>_(e),disabled:i||u===n,title:i?`This is the current version`:`Revert to this version`,children:u===n?`Loading…`:`Revert`})]},n)})})]})]})}function yi(e,t){let n=Math.max(e,t);return n<=_i?1:_i/n}function bi(e){return Number.isNaN(e.getTime())?String(e):e.toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,second:`2-digit`})}function xi(e,t){let n=[];e.canvas.width!==t.canvas.width||e.canvas.height!==t.canvas.height?n.push(`Resized ${e.canvas.width}\xD7${e.canvas.height} \u2192 ${t.canvas.width}\xD7${t.canvas.height}`):e.canvas.background!==t.canvas.background&&n.push(`Changed background`);let r=new Set(e.layers.map(e=>e.id)),i=new Set(t.layers.map(e=>e.id)),a=t.layers.filter(e=>!r.has(e.id)),o=e.layers.filter(e=>!i.has(e.id));for(let e of a)n.push(`Added ${Si(e)}`);for(let e of o)n.push(`Removed ${Si(e)}`);for(let r of t.layers){let t=e.layers.find(e=>e.id===r.id);if(!t)continue;let i=Ci(t,r);i&&n.push(i)}return n.length===0?`No changes`:n.slice(0,3).join(` · `)+(n.length>3?` (+${n.length-3})`:``)}function Si(e){let t=e.name?.trim();return t&&t.length>0?`\u201C${t}\u201D`:e.type}function Ci(e,t){let n=Si(t),r=e.position.x!==t.position.x||e.position.y!==t.position.y||e.position.width!==t.position.width||e.position.height!==t.position.height,i=e.position.width!==t.position.width||e.position.height!==t.position.height,a=JSON.stringify(e.content)!==JSON.stringify(t.content);return i&&!a?`Resized ${n}`:r&&!a?`Moved ${n}`:a?`Edited ${n}`:null}function wi(){return{version:1,canvas:{width:0,height:0,background:`transparent`},layers:[]}}function Ti(e){return(0,K.jsx)(q,{icon:`fa-solid fa-eye`,...e})}function Ei(e){return(0,K.jsx)(q,{icon:`fa-solid fa-eye-slash`,...e})}function Di(e){return(0,K.jsx)(q,{icon:`fa-solid fa-lock`,...e})}function Oi(e){return(0,K.jsx)(q,{icon:`fa-solid fa-lock-open`,...e})}function ki(e){return(0,K.jsx)(q,{icon:`fa-solid fa-chevron-up`,...e})}function Ai(e){return(0,K.jsx)(q,{icon:`fa-solid fa-chevron-down`,...e})}function ji(e){return(0,K.jsx)(q,{icon:`fa-solid fa-xmark`,...e})}function Mi(e){return(0,K.jsx)(q,{icon:`fa-solid fa-arrow-pointer`,...e})}function Ni(e){return(0,K.jsx)(q,{icon:`fa-solid fa-font`,...e})}function Pi(e){return(0,K.jsx)(q,{icon:`fa-solid fa-shapes`,...e})}function Fi(e){return(0,K.jsx)(q,{icon:`fa-solid fa-crop-simple`,...e})}function Ii(e){return(0,K.jsx)(q,{icon:`fa-solid fa-plus`,...e})}function Li(e){return(0,K.jsx)(q,{icon:`fa-solid fa-image`,...e})}function Ri(e){return(0,K.jsx)(q,{icon:`fa-solid fa-ban`,...e})}var zi=[{kind:`text`,label:`Text layer`,icon:(0,K.jsx)(Ni,{})},{kind:`shape`,label:`Shape layer`,icon:(0,K.jsx)(Pi,{})},{kind:`image`,label:`Image layer…`,icon:(0,K.jsx)(Li,{})}];function Bi({doc:e,selectedLayerId:t,dispatch:n,onAddLayer:r}){let[i,a]=(0,G.useState)(!1),o=(0,G.useRef)(null);(0,G.useEffect)(()=>{if(!i)return;let e=e=>{o.current?.contains(e.target)||a(!1)},t=e=>{e.key===`Escape`&&a(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]);let s=e.layers.slice().reverse();return(0,K.jsxs)(`div`,{className:`squisq-image-editor-layers`,"data-testid":`image-editor-layers`,children:[(0,K.jsxs)(`div`,{className:`squisq-image-editor-panel-header squisq-image-editor-layers-header`,children:[(0,K.jsx)(`span`,{children:`Layers`}),(0,K.jsxs)(`span`,{ref:o,className:`squisq-image-editor-layer-add`,children:[(0,K.jsx)(`button`,{type:`button`,className:`squisq-image-editor-layer-add-button`,onClick:()=>a(e=>!e),"aria-label":`Add layer`,title:`Add layer`,"aria-haspopup":`menu`,"aria-expanded":i,children:(0,K.jsx)(Ii,{})}),i&&(0,K.jsx)(`div`,{className:`squisq-image-editor-layer-add-menu`,role:`menu`,children:zi.map(({kind:e,label:t,icon:n})=>(0,K.jsxs)(`button`,{type:`button`,className:`squisq-image-editor-layer-add-menu-item`,role:`menuitem`,onClick:()=>{a(!1),r(e)},children:[n,(0,K.jsx)(`span`,{children:t})]},e))})]})]}),(0,K.jsxs)(`ul`,{className:`squisq-image-editor-layer-list`,children:[s.length===0&&(0,K.jsx)(`li`,{className:`squisq-image-editor-layer-empty`,children:`No layers yet`}),s.map(r=>{let i=r.visible!==!1,a=!!r.locked,o=e.layers.findIndex(e=>e.id===r.id),s=o<e.layers.length-1,c=o>0,l=t===r.id,u=r.name??Vi(r);return(0,K.jsxs)(`li`,{className:[`squisq-image-editor-layer-item`,l?`is-selected`:``,i?``:`is-hidden`].filter(Boolean).join(` `),children:[(0,K.jsx)(`button`,{type:`button`,className:`squisq-image-editor-layer-toggle`,onClick:()=>n({type:`update-layer`,layerId:r.id,patch:{visible:!i}}),"aria-label":i?`Hide layer`:`Show layer`,title:i?`Hide layer`:`Show layer`,children:i?(0,K.jsx)(Ti,{}):(0,K.jsx)(Ei,{})}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-image-editor-layer-toggle`,onClick:()=>n({type:`update-layer`,layerId:r.id,patch:{locked:!a}}),"aria-label":a?`Unlock layer`:`Lock layer`,title:a?`Unlock layer`:`Lock layer`,children:a?(0,K.jsx)(Di,{}):(0,K.jsx)(Oi,{})}),(0,K.jsxs)(`button`,{type:`button`,className:`squisq-image-editor-layer-name`,onClick:()=>n({type:`select`,layerId:r.id}),title:u,children:[(0,K.jsx)(`span`,{className:`squisq-image-editor-layer-name-text`,children:u}),(0,K.jsx)(`span`,{className:`squisq-image-editor-layer-kind`,children:r.type})]}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-image-editor-layer-toggle`,disabled:!s,onClick:()=>n({type:`reorder-layer`,layerId:r.id,toIndex:o+1}),"aria-label":`Move layer up`,title:`Move layer up`,children:(0,K.jsx)(ki,{})}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-image-editor-layer-toggle`,disabled:!c,onClick:()=>n({type:`reorder-layer`,layerId:r.id,toIndex:o-1}),"aria-label":`Move layer down`,title:`Move layer down`,children:(0,K.jsx)(Ai,{})}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-image-editor-layer-toggle`,onClick:()=>n({type:`remove-layer`,layerId:r.id}),"aria-label":`Delete layer`,title:`Delete layer`,children:(0,K.jsx)(ji,{})})]},r.id)})]})]})}function Vi(e){if(e.type===`text`)return e.content?.text?.split(`
|
|
5
|
+
`)[0]?.slice(0,24)||`Text`;if(e.type===`image`)return`Image`;if(e.type===`shape`){let t=e.content;return t?.shape?t.shape[0].toUpperCase()+t.shape.slice(1):`Shape`}return e.type}function Hi({doc:e,selectedLayerId:t,dispatch:n}){let r=t?e.layers.find(e=>e.id===t)??null:null;return(0,K.jsxs)(`div`,{className:`squisq-image-editor-properties`,"data-testid":`image-editor-properties`,children:[(0,K.jsx)(`div`,{className:`squisq-image-editor-panel-header`,children:`Properties`}),(0,K.jsx)(Ui,{doc:e,dispatch:n}),r?(0,K.jsx)(Wi,{layer:r,dispatch:n},r.id):(0,K.jsx)(`div`,{className:`squisq-image-editor-properties-empty`,children:`No layer selected`})]})}function Ui({doc:e,dispatch:t}){let n=n=>{t({type:`set-canvas`,canvas:{...e.canvas,...n}})};return(0,K.jsxs)(`fieldset`,{className:`squisq-image-editor-fieldset`,children:[(0,K.jsx)(`legend`,{children:`Canvas`}),(0,K.jsx)(Xi,{label:`Width`,value:e.canvas.width,min:1,onChange:e=>n({width:Math.round(e)})}),(0,K.jsx)(Xi,{label:`Height`,value:e.canvas.height,min:1,onChange:e=>n({height:Math.round(e)})}),(0,K.jsx)(ea,{label:`Background`,value:e.canvas.background??`transparent`,allowTransparent:!0,onChange:e=>n({background:e})})]})}function Wi({layer:e,dispatch:t}){let n=n=>t({type:`update-layer`,layerId:e.id,patch:n});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`fieldset`,{className:`squisq-image-editor-fieldset`,children:[(0,K.jsx)(`legend`,{children:`Layer`}),(0,K.jsx)(Zi,{label:`Name`,value:e.name??``,onChange:e=>n({name:e})}),(0,K.jsx)(Xi,{label:`Opacity`,value:e.opacity??1,min:0,max:1,step:.05,onChange:e=>n({opacity:e})})]}),(0,K.jsx)(Gi,{layer:e,update:n}),e.type===`image`&&(0,K.jsx)(Ki,{layer:e,update:n}),e.type===`text`&&(0,K.jsx)(qi,{layer:e,update:n}),e.type===`shape`&&(0,K.jsx)(Ji,{layer:e,update:n}),e.type===`path`&&(0,K.jsx)(Yi,{layer:e,update:n})]})}function Gi({layer:e,update:t}){let n=e.position,r=e=>t({position:{...n,...e}});return(0,K.jsxs)(`fieldset`,{className:`squisq-image-editor-fieldset`,children:[(0,K.jsx)(`legend`,{children:`Position`}),(0,K.jsx)(Xi,{label:`X`,value:typeof n.x==`number`?n.x:0,onChange:e=>r({x:Math.round(e)})}),(0,K.jsx)(Xi,{label:`Y`,value:typeof n.y==`number`?n.y:0,onChange:e=>r({y:Math.round(e)})}),(0,K.jsx)(Xi,{label:`Width`,value:typeof n.width==`number`?n.width:0,onChange:e=>r({width:Math.round(e)})}),(0,K.jsx)(Xi,{label:`Height`,value:typeof n.height==`number`?n.height:0,onChange:e=>r({height:Math.round(e)})})]})}function Ki({layer:e,update:t}){let n=e.content,r=e=>t({content:{...n,...e}});return(0,K.jsxs)(`fieldset`,{className:`squisq-image-editor-fieldset`,children:[(0,K.jsx)(`legend`,{children:`Image`}),(0,K.jsx)(Zi,{label:`Alt`,value:n.alt??``,onChange:e=>r({alt:e})}),(0,K.jsx)($i,{label:`Fit`,value:n.fit??`fill`,options:[[`fill`,`Fill`],[`contain`,`Contain`],[`cover`,`Cover`]],onChange:e=>r({fit:e})})]})}function qi({layer:e,update:t}){let n=e.content,r=e=>t({content:{...n,...e}}),i=e=>r({style:{...n.style,...e}});return(0,K.jsxs)(`fieldset`,{className:`squisq-image-editor-fieldset`,children:[(0,K.jsx)(`legend`,{children:`Text`}),(0,K.jsx)(Qi,{label:`Text`,value:n.text,onChange:e=>r({text:e})}),(0,K.jsx)(Xi,{label:`Font size`,value:n.style.fontSize,min:1,onChange:e=>i({fontSize:Math.round(e)})}),(0,K.jsx)(ea,{label:`Color`,value:n.style.color,onChange:e=>i({color:e})}),(0,K.jsx)($i,{label:`Weight`,value:n.style.fontWeight??`normal`,options:[[`normal`,`Normal`],[`bold`,`Bold`]],onChange:e=>i({fontWeight:e})}),(0,K.jsx)($i,{label:`Align`,value:n.style.textAlign??`left`,options:[[`left`,`Left`],[`center`,`Center`],[`right`,`Right`]],onChange:e=>i({textAlign:e})})]})}function Ji({layer:e,update:t}){let n=e.content,r=e=>t({content:{...n,...e}});return(0,K.jsxs)(`fieldset`,{className:`squisq-image-editor-fieldset`,children:[(0,K.jsx)(`legend`,{children:`Shape`}),(0,K.jsx)($i,{label:`Shape`,value:n.shape,options:[[`rect`,`Rectangle`],[`circle`,`Circle`],[`line`,`Line`]],onChange:e=>r({shape:e})}),(0,K.jsx)(ea,{label:`Fill`,value:n.fill??`#000000`,allowTransparent:!0,onChange:e=>r({fill:e})}),(0,K.jsx)(ea,{label:`Stroke`,value:n.stroke??`#000000`,allowTransparent:!0,onChange:e=>r({stroke:e})}),(0,K.jsx)(Xi,{label:`Stroke width`,value:n.strokeWidth??0,min:0,onChange:e=>r({strokeWidth:e})}),n.shape===`rect`&&(0,K.jsx)(Xi,{label:`Corner radius`,value:n.borderRadius??0,min:0,onChange:e=>r({borderRadius:Math.round(e)})})]})}function Yi({layer:e,update:t}){let n=e.content,r=e=>t({content:{...n,...e}}),i=n.shapeKind?n.shapeKind.replace(/-/g,` `):n.endMarker||n.startMarker?`arrow`:`path`;return(0,K.jsxs)(`fieldset`,{className:`squisq-image-editor-fieldset`,children:[(0,K.jsx)(`legend`,{children:`Shape`}),(0,K.jsxs)(`div`,{className:`squisq-image-editor-field`,children:[(0,K.jsx)(`span`,{children:`Kind`}),(0,K.jsx)(`span`,{className:`squisq-image-editor-readonly-value`,children:i})]}),(0,K.jsx)(ea,{label:`Fill`,value:n.fill??`none`,allowTransparent:!0,onChange:e=>r({fill:e})}),(0,K.jsx)(ea,{label:`Stroke`,value:n.stroke??`#000000`,allowTransparent:!0,onChange:e=>r({stroke:e})}),(0,K.jsx)(Xi,{label:`Stroke width`,value:n.strokeWidth??0,min:0,onChange:e=>r({strokeWidth:e})})]})}function Xi({label:e,value:t,min:n,max:r,step:i,onChange:a}){return(0,K.jsxs)(`label`,{className:`squisq-image-editor-field`,children:[(0,K.jsx)(`span`,{children:e}),(0,K.jsx)(`input`,{type:`number`,value:Number.isFinite(t)?t:0,min:n,max:r,step:i??1,onChange:e=>{let t=Number(e.target.value);Number.isFinite(t)&&a(t)}})]})}function Zi({label:e,value:t,onChange:n}){return(0,K.jsxs)(`label`,{className:`squisq-image-editor-field`,children:[(0,K.jsx)(`span`,{children:e}),(0,K.jsx)(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value)})]})}function Qi({label:e,value:t,onChange:n}){return(0,K.jsxs)(`label`,{className:`squisq-image-editor-field squisq-image-editor-field--multiline`,children:[(0,K.jsx)(`span`,{children:e}),(0,K.jsx)(`textarea`,{rows:3,value:t,onChange:e=>n(e.target.value)})]})}function $i({label:e,value:t,options:n,onChange:r}){return(0,K.jsxs)(`label`,{className:`squisq-image-editor-field`,children:[(0,K.jsx)(`span`,{children:e}),(0,K.jsx)(`select`,{value:t,onChange:e=>r(e.target.value),children:n.map(([e,t])=>(0,K.jsx)(`option`,{value:e,children:t},e))})]})}function ea({label:e,value:t,allowTransparent:n,onChange:r}){return(0,K.jsxs)(`label`,{className:`squisq-image-editor-field`,children:[(0,K.jsx)(`span`,{children:e}),(0,K.jsxs)(`span`,{className:`squisq-image-editor-color-row`,children:[(0,K.jsx)(`input`,{type:`color`,value:t===`transparent`||t===`none`?`#000000`:ta(t),onChange:e=>r(e.target.value)}),(0,K.jsx)(`input`,{type:`text`,value:t,onChange:e=>r(e.target.value),spellCheck:!1}),n&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>r(`transparent`),title:`Set transparent`,"aria-label":`Set transparent`,className:`squisq-image-editor-color-clear`,children:(0,K.jsx)(Ri,{})})]})]})}function ta(e){return/^#[0-9a-f]{6}$/i.test(e)?e:/^#[0-9a-f]{3}$/i.test(e)?`#`+e.slice(1).split(``).map(e=>e+e).join(``):`#000000`}var na=[{category:`Lines`,items:[{kind:`line`,label:`Line`},{kind:`arrow`,label:`Line Arrow`},{kind:`text`,label:`Text`}]},{category:`Basic Shapes`,items:[{kind:`rectangle`,label:`Rectangle`},{kind:`circle`,label:`Ellipse`},{kind:`triangle`,label:`Triangle`},{kind:`right-triangle`,label:`Right Triangle`},{kind:`diamond`,label:`Diamond`},{kind:`pentagon`,label:`Pentagon`},{kind:`hexagon`,label:`Hexagon`},{kind:`octagon`,label:`Octagon`},{kind:`parallelogram`,label:`Parallelogram`},{kind:`trapezoid`,label:`Trapezoid`},{kind:`plus`,label:`Cross`},{kind:`chevron`,label:`Chevron`},{kind:`cylinder`,label:`Cylinder`},{kind:`callout`,label:`Speech Bubble`},{kind:`cloud`,label:`Cloud`},{kind:`heart`,label:`Heart`},{kind:`lightning`,label:`Lightning`}]},{category:`Stars`,items:[{kind:`star`,label:`5-Point Star`},{kind:`star4`,label:`4-Point Star`},{kind:`star6`,label:`6-Point Star`}]},{category:`Block Arrows`,items:[{kind:`arrow-right`,label:`Arrow Right`},{kind:`arrow-left`,label:`Arrow Left`},{kind:`arrow-up`,label:`Arrow Up`},{kind:`arrow-down`,label:`Arrow Down`},{kind:`double-arrow`,label:`Double Arrow`}]}];function ra({onPick:e,onClose:t,ignoreOutsideSelector:n=`.squisq-scene-block-toolbar`}){let[r,i]=(0,G.useState)(``),a=(0,G.useRef)(null);(0,G.useEffect)(()=>{let e=e=>{let r=e.target;n&&r?.closest?.(n)||a.current&&!a.current.contains(e.target)&&t()},r=e=>{e.key===`Escape`&&t()};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,r),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,r)}},[t,n]);let o=(0,G.useMemo)(()=>{let e=r.trim().toLowerCase();return e?na.map(t=>({category:t.category,items:t.items.filter(t=>t.label.toLowerCase().includes(e)||t.kind.includes(e))})).filter(e=>e.items.length>0):na},[r]);return(0,K.jsxs)(`div`,{className:`squisq-shape-palette`,ref:a,role:`dialog`,"aria-label":`Shapes`,children:[(0,K.jsx)(`input`,{className:`squisq-shape-palette-search`,type:`text`,placeholder:`Search shapes…`,value:r,autoFocus:!0,onChange:e=>i(e.target.value)}),(0,K.jsx)(`div`,{className:`squisq-shape-palette-scroll`,children:o.map(t=>(0,K.jsxs)(`div`,{className:`squisq-shape-palette-section`,children:[(0,K.jsx)(`div`,{className:`squisq-shape-palette-heading`,children:t.category}),(0,K.jsx)(`div`,{className:`squisq-shape-palette-grid`,children:t.items.map(t=>(0,K.jsx)(`button`,{type:`button`,className:`squisq-shape-palette-item`,title:t.label,"aria-label":t.label,onClick:()=>e(t.kind),children:(0,K.jsx)(ia,{kind:t.kind})},t.kind))})]},t.category))})]})}function ia({kind:e}){let t=F(e,4,4,40,30),n=`squisq-shape-thumb-arrow-${(0,G.useId)().replace(/:/g,``)}`;return(0,K.jsxs)(`svg`,{viewBox:`0 0 48 38`,width:36,height:28,"aria-hidden":`true`,children:[e===`arrow`?(0,K.jsx)(`defs`,{children:(0,K.jsx)(`marker`,{id:n,viewBox:`0 0 10 10`,refX:9,refY:5,markerWidth:4,markerHeight:4,children:(0,K.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,className:`squisq-shape-thumb-line`})})}):null,t?(0,K.jsx)(`path`,{d:t,className:`squisq-shape-thumb`}):e===`circle`?(0,K.jsx)(`ellipse`,{cx:24,cy:19,rx:20,ry:15,className:`squisq-shape-thumb`}):e===`line`?(0,K.jsx)(`line`,{x1:4,y1:34,x2:44,y2:4,className:`squisq-shape-thumb-line`}):e===`arrow`?(0,K.jsx)(`line`,{x1:4,y1:34,x2:44,y2:4,className:`squisq-shape-thumb-line`,markerEnd:`url(#${n})`}):e===`text`?(0,K.jsx)(`text`,{x:24,y:26,textAnchor:`middle`,className:`squisq-shape-thumb-text`,children:`T`}):(0,K.jsx)(`rect`,{x:4,y:6,width:40,height:26,rx:3,className:`squisq-shape-thumb`})]})}function aa(){return(0,K.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 15 15`,fill:`none`,"aria-hidden":`true`,children:[(0,K.jsx)(`line`,{x1:`3`,y1:`12`,x2:`12`,y2:`3`,stroke:`#cc0000`,strokeWidth:`1.8`,strokeLinecap:`round`}),(0,K.jsx)(`polyline`,{points:`7,3 12,3 12,8`,stroke:`#cc0000`,strokeWidth:`1.8`,strokeLinejoin:`round`,strokeLinecap:`round`,fill:`none`})]})}function oa(){return(0,K.jsx)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 15 15`,fill:`none`,"aria-hidden":`true`,children:(0,K.jsx)(`rect`,{x:`1.5`,y:`3`,width:`12`,height:`9`,stroke:`#cc0000`,strokeWidth:`1.8`,rx:`0.5`})})}function sa(){return(0,K.jsx)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 15 15`,"aria-hidden":`true`,children:(0,K.jsx)(`text`,{x:`1.5`,y:`13`,fill:`#cc0000`,fontSize:`13`,fontFamily:`sans-serif`,fontWeight:`bold`,children:`A`})})}function ca(){return(0,K.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 15 15`,fill:`none`,"aria-hidden":`true`,children:[(0,K.jsx)(`circle`,{cx:`6`,cy:`6`,r:`4.5`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,K.jsx)(`line`,{x1:`9.5`,y1:`9.5`,x2:`13.5`,y2:`13.5`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`}),(0,K.jsx)(`line`,{x1:`4`,y1:`6`,x2:`8`,y2:`6`,stroke:`currentColor`,strokeWidth:`1.2`,strokeLinecap:`round`}),(0,K.jsx)(`line`,{x1:`6`,y1:`4`,x2:`6`,y2:`8`,stroke:`currentColor`,strokeWidth:`1.2`,strokeLinecap:`round`})]})}var la=[{kind:`redline-arrow`,icon:(0,K.jsx)(aa,{}),title:`Redline arrow`},{kind:`redline-rect`,icon:(0,K.jsx)(oa,{}),title:`Redline rectangle`},{kind:`redline-text`,icon:(0,K.jsx)(sa,{}),title:`Redline text`}],ua=[{id:`select`,icon:(0,K.jsx)(Mi,{}),title:`Select / move (V)`},{id:`text`,icon:(0,K.jsx)(Ni,{}),title:`Add text (T)`},{id:`shape`,icon:(0,K.jsx)(Pi,{}),title:`Add shape (S)`},{id:`crop`,icon:(0,K.jsx)(Fi,{}),title:`Crop (C)`},{id:`zoom-rect`,icon:(0,K.jsx)(ca,{}),title:`Zoom to rectangle (Z)`}];function da({doc:e,tool:t,shapeKind:n,dispatch:r,uploadAsset:i,imageInputRef:a,onExport:o,onSave:s,saveLabel:c=`Save`,saveTitle:l=`Save state.json`,extraTools:u,zoom:d,onZoomIn:f,onZoomOut:p,onZoomSet:m,onZoomFit:h,onZoom1to1:g}){let _=(0,G.useRef)(null),v=a??_,[y,b]=(0,G.useState)(!1),x=async t=>{try{let n=await i(t,t.name),a=await pa(t),o=Math.min(a.width,e.canvas.width),s=Math.min(a.height,e.canvas.height);r({type:`add-layer`,layer:{type:`image`,name:t.name,position:{x:Math.round((e.canvas.width-o)/2),y:Math.round((e.canvas.height-s)/2),width:o,height:s},content:{src:n,alt:t.name,fit:`fill`}}})}catch(e){console.warn(`[squisq-editor] image upload failed:`,e instanceof Error?e.message:e)}};return(0,K.jsxs)(`div`,{className:`squisq-image-editor-toolbar`,"data-testid":`image-editor-toolbar`,children:[(0,K.jsx)(`div`,{className:`squisq-image-editor-tool-group`,role:`radiogroup`,"aria-label":`Tools`,children:ua.map(e=>{let n=(0,K.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":t===e.id,className:[`squisq-image-editor-tool-button`,t===e.id?`is-active`:``].filter(Boolean).join(` `),onClick:()=>{if(e.id===`shape`){r({type:`set-tool`,tool:`shape`}),b(e=>!e);return}b(!1),r({type:`set-tool`,tool:e.id})},title:e.title,"aria-label":e.title,"aria-haspopup":e.id===`shape`?`dialog`:void 0,"aria-expanded":e.id===`shape`?y:void 0,children:e.icon},e.id);return e.id===`shape`?(0,K.jsxs)(`span`,{className:`squisq-image-editor-shape-trigger`,children:[n,y&&(0,K.jsx)(ra,{ignoreOutsideSelector:`.squisq-image-editor-toolbar`,onPick:e=>{r({type:`set-shape-kind`,kind:e}),r({type:`set-tool`,tool:`shape`}),b(!1)},onClose:()=>b(!1)})]},e.id):n})}),(0,K.jsx)(`div`,{className:`squisq-image-editor-tool-group`,role:`group`,"aria-label":`Redline shortcuts`,children:la.map(e=>{let i=t===`shape`&&n===e.kind;return(0,K.jsx)(`button`,{type:`button`,className:[`squisq-image-editor-tool-button`,i?`is-active`:``].filter(Boolean).join(` `),onClick:()=>{r({type:`set-shape-kind`,kind:e.kind}),r({type:`set-tool`,tool:`shape`}),b(!1)},title:e.title,"aria-label":e.title,"aria-pressed":i,children:e.icon},e.kind)})}),(0,K.jsxs)(`div`,{className:`squisq-image-editor-tool-group`,children:[(0,K.jsxs)(`button`,{type:`button`,className:`squisq-image-editor-tool-button squisq-image-editor-tool-button--with-label`,onClick:()=>v.current?.click(),title:`Import image as new layer`,"aria-label":`Import image as new layer`,children:[(0,K.jsx)(Ii,{}),(0,K.jsx)(`span`,{children:`Image`})]}),(0,K.jsx)(`input`,{ref:v,type:`file`,accept:`image/*`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&x(t),e.target.value=``}})]}),(f||p)&&(0,K.jsxs)(`div`,{className:`squisq-image-editor-tool-group squisq-image-editor-tool-group--zoom`,children:[(0,K.jsx)(`button`,{type:`button`,className:`squisq-image-editor-tool-button`,onClick:p,title:`Zoom out`,"aria-label":`Zoom out`,children:`−`}),(0,K.jsx)(`input`,{type:`number`,className:`squisq-image-editor-zoom-input`,value:Math.round((d??1)*100),min:6,max:1600,step:1,onChange:e=>{let t=parseInt(e.target.value,10);!isNaN(t)&&t>0&&m?.(t/100)},"aria-label":`Zoom percentage`,title:`Zoom %`}),(0,K.jsx)(`span`,{className:`squisq-image-editor-zoom-label`,children:`%`}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-image-editor-tool-button`,onClick:f,title:`Zoom in`,"aria-label":`Zoom in`,children:`+`}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-image-editor-tool-button squisq-image-editor-tool-button--with-label`,onClick:g,title:`1:1 pixels`,children:`1:1`}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-image-editor-tool-button squisq-image-editor-tool-button--with-label`,onClick:h,title:`Fit to window`,children:`Fit`})]}),(0,K.jsxs)(`div`,{className:`squisq-image-editor-tool-group squisq-image-editor-tool-group--right`,children:[u,s&&(0,K.jsx)(`button`,{type:`button`,className:`squisq-image-editor-tool-button`,onClick:s,title:l,children:c}),(0,K.jsx)(fa,{onExport:o})]})]})}function fa({onExport:e}){let[t,n]=(0,G.useState)(!1),r=(0,G.useRef)(null),i=(0,G.useRef)(null);(0,G.useEffect)(()=>{if(!t)return;function e(e){let t=e.target;t&&(r.current?.contains(t)||n(!1))}function i(e){e.key===`Escape`&&n(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,i)}},[t]);let a=t=>{n(!1),e(t)};return(0,K.jsxs)(`span`,{ref:r,className:`squisq-image-editor-version-dropdown`,children:[(0,K.jsxs)(`button`,{ref:i,type:`button`,className:`squisq-image-editor-tool-button squisq-image-editor-tool-button--with-label`,onClick:()=>n(e=>!e),"aria-haspopup":`menu`,"aria-expanded":t,title:`Export image`,children:[(0,K.jsx)(`span`,{children:`Export`}),(0,K.jsx)(`span`,{"aria-hidden":`true`,style:{fontSize:`0.8em`},children:`▾`})]}),t&&(0,K.jsx)(`div`,{className:`squisq-image-editor-version-popover`,role:`menu`,style:{minWidth:160},children:(0,K.jsx)(`ul`,{className:`squisq-image-editor-version-popover__list`,style:{maxHeight:`none`},children:[{f:`png`,label:`PNG`},{f:`jpeg`,label:`JPEG`},{f:`webp`,label:`WebP`}].map(({f:e,label:t})=>(0,K.jsx)(`li`,{className:`squisq-image-editor-version-popover__row`,children:(0,K.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`squisq-image-editor-tool-button squisq-image-editor-tool-button--menu`,onClick:()=>a(e),children:[`Export as `,t]})},e))})})]})}function pa(e){return new Promise(t=>{let n=URL.createObjectURL(e),r=new Image;r.onload=()=>{URL.revokeObjectURL(n),t({width:r.naturalWidth,height:r.naturalHeight})},r.onerror=()=>{URL.revokeObjectURL(n),t({width:200,height:200})},r.src=n})}function ma(e,t){let n=Ln(t===`auto`),r=t===`auto`?n:t??void 0;return(0,G.useMemo)(()=>{let t=e??at,n=r?$e(t,r):t,i=n.colors.background,a=n.colors.text,o=n.colors.textMuted,s=n.colors.primary;return{style:{"--squisq-image-editor-bg":i,"--squisq-image-editor-panel-bg":`color-mix(in srgb, ${i} 92%, ${a} 8%)`,"--squisq-image-editor-panel-border":`color-mix(in srgb, ${i} 80%, ${a} 20%)`,"--squisq-image-editor-text":a,"--squisq-image-editor-text-muted":o,"--squisq-image-editor-accent":s,"--squisq-image-editor-control-bg":`color-mix(in srgb, ${i} 86%, ${a} 14%)`,"--squisq-image-editor-control-border":`color-mix(in srgb, ${i} 72%, ${a} 28%)`,"--squisq-image-editor-workspace-bg":`color-mix(in srgb, ${i} 95%, ${a} 5%)`,"--squisq-image-editor-body-font":Ye(n.typography.bodyFont,`system-ui, -apple-system, sans-serif`)},theme:n}},[e,r])}var ha=120,ga=80,_a=`#3399ff`,va=`#1a4d80`,ya=2,ba=`#cc0000`,xa=15,Sa=new Set([`line`,`arrow`,`redline-arrow`,`redline-rect`]);function Ca(e){return Sa.has(e)}var wa={rectangle:`rect`,circle:`circle`,line:`line`};function Ta(e,t,n){let r=ha,i=ga,a=Math.round(t-r/2),o=Math.round(n-i/2),s={x:a,y:o,width:r,height:i},c=Da(e);if(e===`text`)return{type:`text`,name:`Text`,position:{x:Math.round(t),y:Math.round(n),width:240,height:48},content:{text:`New text`,style:{fontSize:32,color:`#111111`,fontFamily:`sans-serif`}}};if(e===`redline-arrow`)return{type:`path`,name:`Redline Arrow`,position:s,content:{d:`M ${a} ${o} L ${a+r} ${o+i}`,stroke:ba,strokeWidth:xa,fill:`none`,endMarker:`arrow`}};if(e===`redline-rect`)return{type:`shape`,name:`Redline Rectangle`,position:s,content:{shape:`rect`,fill:`none`,stroke:ba,strokeWidth:xa,borderRadius:0}};if(e===`redline-text`)return{type:`text`,name:`Redline Text`,position:{x:Math.round(t),y:Math.round(n),width:240,height:48},content:{text:`Annotation`,style:{fontSize:24,color:ba,fontFamily:`sans-serif`,fontWeight:`bold`}}};let l=wa[e];return l===`rect`?{type:`shape`,name:c,position:s,content:{shape:`rect`,fill:_a,stroke:va,strokeWidth:ya,borderRadius:8}}:l===`circle`?{type:`shape`,name:c,position:s,content:{shape:`circle`,fill:_a,stroke:va,strokeWidth:ya}}:l===`line`?{type:`shape`,name:c,position:s,content:{shape:`line`,stroke:va,strokeWidth:ya}}:e===`arrow`?{type:`path`,name:`Arrow`,position:s,content:{d:`M ${a} ${o} L ${a+r} ${o+i}`,stroke:va,strokeWidth:ya,fill:`none`,endMarker:`arrow`}}:{type:`path`,name:c,position:s,content:{d:F(e,a,o,r,i)??`M ${a} ${o} L ${a+r} ${o+i}`,shapeKind:e,fill:_a,stroke:va,strokeWidth:ya}}}function Ea(e,t,n,r,i){let a=Math.round(t),o=Math.round(n),s=Math.round(r),c=Math.round(i),l={x:Math.min(a,s),y:Math.min(o,c),width:Math.max(Math.abs(s-a),4),height:Math.max(Math.abs(c-o),4)};return e===`line`?{type:`shape`,name:`Line`,position:{x:a,y:o,width:s-a,height:c-o},content:{shape:`line`,stroke:va,strokeWidth:ya}}:e===`arrow`?{type:`path`,name:`Arrow`,position:l,content:{d:`M ${a} ${o} L ${s} ${c}`,stroke:va,strokeWidth:ya,fill:`none`,endMarker:`arrow`}}:e===`redline-arrow`?{type:`path`,name:`Redline Arrow`,position:l,content:{d:`M ${a} ${o} L ${s} ${c}`,stroke:ba,strokeWidth:xa,fill:`none`,endMarker:`arrow`}}:e===`redline-rect`?{type:`shape`,name:`Redline Rectangle`,position:{x:Math.min(a,s),y:Math.min(o,c),width:Math.max(Math.abs(s-a),4),height:Math.max(Math.abs(c-o),4)},content:{shape:`rect`,fill:`none`,stroke:ba,strokeWidth:xa,borderRadius:0}}:Ta(e,(t+r)/2,(n+i)/2)}function Da(e){return e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}var Oa=[.0625,.083,.125,.167,.25,.333,.5,.667,1,1.5,2,3,4,8,16];function J(e){let{filesContainer:t,initialSrc:n,stateFilename:r,allowVersioning:i,versioningAutoSaveIdleMs:a,onExport:o,saveBehavior:s=`flush`,saveFormat:c=`png`,saveLabel:l,saveTitle:u,theme:d,surface:f,className:p}=e,m=ma(d,f),{state:h,dispatch:g,flush:_,resolveAssetUrl:v,uploadAsset:y,versioning:b,ready:x,error:S}=Qr({container:t,initialSrc:n,stateFilename:r,allowVersioning:i,versioningAutoSaveIdleMs:a}),[C,w]=(0,G.useState)(0),T=(0,G.useRef)(null),E=(0,G.useRef)(null),[D,O]=(0,G.useState)(1),k=(0,G.useCallback)(()=>{O(e=>Oa.find(t=>t>e+.001)??16)},[]),A=(0,G.useCallback)(()=>{O(e=>[...Oa].reverse().find(t=>t<e-.001)??.0625)},[]),j=(0,G.useCallback)(e=>{O(Math.max(.0625,Math.min(16,e)))},[]),M=(0,G.useCallback)(()=>O(1),[]),N=(0,G.useCallback)(()=>{if(!h||!T.current)return;let{clientWidth:e,clientHeight:t}=T.current,n=Math.min((e-32)/h.doc.canvas.width,(t-32)/h.doc.canvas.height);O(Math.max(.0625,Math.min(16,n)))},[h]),[P,F]=(0,G.useState)(null),I=(0,G.useCallback)(async e=>{if(h)try{let n=await Dn(h.doc,t,{format:e});if(o)o(n,e);else{let t=URL.createObjectURL(n),r=document.createElement(`a`);r.href=t,r.download=`image.${e===`jpeg`?`jpg`:e}`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(t)}}catch(e){console.warn(`[squisq-editor] image export failed:`,e instanceof Error?e.message:e)}},[h,t,o]),L=(0,G.useCallback)(async()=>{try{if(await _(),b)try{await b.saveVersion(),w(e=>e+1)}catch(e){console.warn(`[squisq-editor] image-edit save-version failed:`,e instanceof Error?e.message:e)}await I(c)}catch(e){console.warn(`[squisq-editor] image-edit save-and-close failed:`,e instanceof Error?e.message:e)}},[_,b,I,c]),ee=(0,G.useCallback)(async e=>{if(!b)return;try{await _()}catch{}if(!(await b.revertToVersion(e)).reverted)return;let t=await b.readVersion(e);t&&(g({type:`load`,doc:t}),w(e=>e+1))},[g,_,b]),te=(0,G.useCallback)((e,t)=>{let n=`layer-${Math.random().toString(36).slice(2,10)}`;g({type:`add-layer`,layer:{id:n,type:`text`,name:`Text`,position:{x:Math.round(e),y:Math.round(t),width:240,height:48},content:{text:`New text`,style:{fontSize:32,color:`#111111`,fontFamily:`sans-serif`}}}}),g({type:`set-tool`,tool:`select`}),F(n)},[g]),R=h?.shapeKind??`rectangle`,ne=Ca(R),re=(0,G.useCallback)((e,t)=>{let n=Ta(R,e,t),r=`layer-${Math.random().toString(36).slice(2,10)}`;g({type:`add-layer`,layer:{...n,id:r}}),g({type:`set-tool`,tool:`select`}),n.type===`text`&&F(r)},[g,R]),z=(0,G.useCallback)((e,t,n,r)=>{g({type:`add-layer`,layer:Ea(R,e,t,n,r)}),g({type:`set-tool`,tool:`select`})},[g,R]),ie=(0,G.useCallback)(e=>{if(!h)return;if(e===`image`){E.current?.click();return}let{width:t,height:n}=h.doc.canvas;if(e===`text`){te(Math.max(0,(t-240)/2),Math.max(0,(n-48)/2));return}re(t/2,n/2)},[re,te,h]);return S?(0,K.jsx)(`div`,{className:[`squisq-image-editor`,p].filter(Boolean).join(` `),style:m.style,children:(0,K.jsxs)(`div`,{className:`squisq-image-editor-error`,children:[`Failed to load image editor: `,S.message]})}):!x||!h?(0,K.jsx)(`div`,{className:[`squisq-image-editor`,p].filter(Boolean).join(` `),style:m.style,children:(0,K.jsx)(`div`,{className:`squisq-image-editor-loading`,children:`Loading image editor…`})}):(0,K.jsxs)(`div`,{className:[`squisq-image-editor`,p].filter(Boolean).join(` `),style:m.style,"data-testid":`image-editor`,children:[(0,K.jsx)(da,{doc:h.doc,tool:h.tool,shapeKind:h.shapeKind,dispatch:g,uploadAsset:y,imageInputRef:E,onExport:I,onSave:s===`export`?L:_,saveLabel:l??(s===`export`?`Save and close`:`Save`),saveTitle:u??(s===`export`?`Rasterize and save as ${c.toUpperCase()}`:`Save state.json`),extraTools:b?(0,K.jsx)(vi,{versioning:b,container:t,onRevert:ee,refreshKey:C}):null,zoom:D,onZoomIn:k,onZoomOut:A,onZoomSet:j,onZoomFit:N,onZoom1to1:M}),(0,K.jsxs)(`div`,{className:`squisq-image-editor-body`,children:[(0,K.jsx)(`div`,{className:`squisq-image-editor-center`,children:(0,K.jsx)(li,{doc:h.doc,selectedLayerId:h.selectedLayerId,tool:h.tool,resolveAssetUrl:v,dispatch:g,onCreateTextAt:te,onCreateShapeAt:re,onCreateShapeFromPoints:z,shapeDragDraw:ne,zoom:D,onSetZoom:j,surfaceRef:T,requestEditLayerId:P})}),(0,K.jsxs)(`div`,{className:`squisq-image-editor-side`,children:[(0,K.jsx)(Bi,{doc:h.doc,selectedLayerId:h.selectedLayerId,dispatch:g,onAddLayer:ie}),(0,K.jsx)(Hi,{doc:h.doc,selectedLayerId:h.selectedLayerId,dispatch:g})]})]})]})}var ka=[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4;codecs=mp4a.40.2`,`audio/mp4`,`audio/ogg;codecs=opus`],Aa=[`video/webm;codecs=vp9,opus`,`video/webm;codecs=vp8,opus`,`video/webm`,`video/mp4;codecs=avc1.42E01E,mp4a.40.2`,`video/mp4`];function ja(e){let t=e.toLowerCase();return t.startsWith(`audio/webm`)?`.webm`:t.startsWith(`audio/ogg`)?`.ogg`:t.startsWith(`audio/mp4`)?`.m4a`:t.startsWith(`audio/mpeg`)?`.mp3`:t.startsWith(`audio/wav`)?`.wav`:t.startsWith(`video/webm`)?`.webm`:t.startsWith(`video/mp4`)?`.mp4`:`.bin`}function Ma(e){if(typeof MediaRecorder>`u`)return null;for(let t of e)try{if(MediaRecorder.isTypeSupported(t))return t}catch{}return null}function Na(e,t){let n=e===`audio`?ka:Aa,r=(t&&Ma([t]))??Ma(n)??``,i=e===`audio`?`audio`:`video`;return{mimeType:r,extension:r?ja(r):`.webm`,directory:i}}function Pa(){return typeof MediaRecorder<`u`}function Fa(){return typeof navigator<`u`&&navigator.mediaDevices!==void 0&&typeof navigator.mediaDevices.getUserMedia==`function`}function Ia(){return typeof navigator<`u`&&navigator.mediaDevices!==void 0&&typeof navigator.mediaDevices.getDisplayMedia==`function`}function La(){if(!Ia())return!1;let e=navigator,t=e.userAgentData;if(t?.mobile===!0)return!1;if(t?.brands?.length)return t.brands.some(({brand:e})=>/chromium/i.test(e));let n=e.userAgent??``;return!/Android|Mobile|iPhone|iPad|iPod/i.test(n)&&/(?:Chrome|Chromium|Edg|OPR)\//.test(n)}function Ra(e,t,n,r){let i=n?n.trim().replace(/[\\/:*?"<>|]+/g,`-`).replace(/\s+/g,`-`):``;if(i)return`${i}${t}`;let a=new Date,o=a.getFullYear().toString().padStart(4,`0`)+(a.getMonth()+1).toString().padStart(2,`0`)+a.getDate().toString().padStart(2,`0`)+`-`+a.getHours().toString().padStart(2,`0`)+a.getMinutes().toString().padStart(2,`0`)+a.getSeconds().toString().padStart(2,`0`);return`${r??(e===`audio`?`narration`:`recording`)}-${o}${t}`}async function za(e){if(!Fa())throw Error(`navigator.mediaDevices.getUserMedia is not available in this environment.`);return navigator.mediaDevices.getUserMedia({audio:e??!0,video:!1})}async function Ba(e){if(!Fa())throw Error(`navigator.mediaDevices.getUserMedia is not available in this environment.`);let t=e?.video??!0,n=e?.audio??!0;return navigator.mediaDevices.getUserMedia({video:t,audio:n})}function Va(e,t){(0,G.useEffect)(()=>{let n=e.current;if(n)return n.muted=!0,n.playsInline=!0,n.srcObject=t,t&&n.play().catch(()=>{}),()=>{n.srcObject===t&&(n.srcObject=null)}},[e,t])}function Ha(e,t){return{sourceText:e??``,duration:Number.isFinite(t)&&t>=0?t:0,bookmarks:[]}}function Ua(e){let t=JSON.stringify(e,null,2);return new TextEncoder().encode(t)}function Wa(e){return new TextEncoder().encode(JSON.stringify(e,null,2))}function Ga(e){return`${e}.timing.json`}var Ka=`squisq-pcm-tap`,qa=`
|
|
6
|
+
class SquisqPcmTap extends AudioWorkletProcessor {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
this._buf = new Float32Array(1024);
|
|
10
|
+
this._len = 0;
|
|
11
|
+
}
|
|
12
|
+
process(inputs) {
|
|
13
|
+
const channel = inputs[0] && inputs[0][0];
|
|
14
|
+
if (channel && channel.length > 0) {
|
|
15
|
+
let i = 0;
|
|
16
|
+
while (i < channel.length) {
|
|
17
|
+
const n = Math.min(channel.length - i, this._buf.length - this._len);
|
|
18
|
+
this._buf.set(channel.subarray(i, i + n), this._len);
|
|
19
|
+
this._len += n;
|
|
20
|
+
i += n;
|
|
21
|
+
if (this._len === this._buf.length) {
|
|
22
|
+
const out = this._buf;
|
|
23
|
+
this._buf = new Float32Array(1024);
|
|
24
|
+
this._len = 0;
|
|
25
|
+
// Clone, don't transfer: Chrome recycles buffers transferred out
|
|
26
|
+
// of the worklet scope once the receiving handler returns, so a
|
|
27
|
+
// transferred hop reads as zeros if anything retains it. A 4 KB
|
|
28
|
+
// structured clone at ~47 Hz is negligible.
|
|
29
|
+
this.port.postMessage({ pcm: out, audioTime: currentTime });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
registerProcessor('${Ka}', SquisqPcmTap);
|
|
37
|
+
`;async function Ja(e){let t=URL.createObjectURL(new Blob([qa],{type:`text/javascript`}));try{await e.audioWorklet.addModule(t)}finally{URL.revokeObjectURL(t)}}function Ya(e){let[t,n]=(0,G.useState)(`idle`),[r,i]=(0,G.useState)(null),[a,o]=(0,G.useState)([]),[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(null),d=(0,G.useRef)(null),f=(0,G.useRef)(e);f.current=e;let p=JSON.stringify(e??{}),m=(0,G.useRef)(p),h=(0,G.useRef)(null),g=(0,G.useRef)(new Set),_=(0,G.useRef)(0),v=(0,G.useCallback)(async()=>{try{let e=await navigator.mediaDevices.enumerateDevices();o(e.filter(e=>e.kind===`audioinput`))}catch{}},[]);(0,G.useEffect)(()=>{if(typeof navigator>`u`||!navigator.mediaDevices?.addEventListener)return;let e=()=>void v();return navigator.mediaDevices.addEventListener(`devicechange`,e),()=>navigator.mediaDevices.removeEventListener(`devicechange`,e)},[v]);let y=(0,G.useCallback)(()=>{let e=d.current;if(d.current=null,e){try{`port`in e.node?e.node.port.onmessage=null:e.node.onaudioprocess=null,e.node.disconnect(),e.source.disconnect(),e.sink?.disconnect()}catch{}for(let t of e.stream.getTracks())t.stop();e.context.close().catch(()=>void 0)}},[]),b=(0,G.useCallback)(()=>{_.current+=1,y(),c(null),u(null),n(`idle`),i(null)},[y]),x=(0,G.useCallback)(async e=>{let t=++_.current;h.current=e,y(),n(`starting`),i(null);try{let r=f.current,i=await za({...r??{},...e?{deviceId:{exact:e}}:{}});if(t!==_.current){for(let e of i.getTracks())e.stop();return null}let a=new AudioContext;a.state===`suspended`&&await a.resume().catch(()=>void 0);let o=a.createMediaStreamSource(i),s=(e,t)=>{for(let n of g.current)n(e,t)},l=null,p=null;if(a.audioWorklet&&typeof AudioWorkletNode<`u`)try{await Ja(a);let e=new AudioWorkletNode(a,Ka,{numberOfInputs:1,numberOfOutputs:1,channelCount:1,channelCountMode:`explicit`});e.port.onmessage=e=>{let t=e.data;t&&t.pcm instanceof Float32Array&&s(t.pcm,typeof t.audioTime==`number`?t.audioTime:0)},o.connect(e),p=a.createGain(),p.gain.value=0,e.connect(p),p.connect(a.destination),l=e}catch{l=null}if(l===null){let e=a.createScriptProcessor(1024,1,1);e.onaudioprocess=e=>{let t=e.inputBuffer.getChannelData(0);s(new Float32Array(t),e.playbackTime)},p=a.createGain(),p.gain.value=0,o.connect(e),e.connect(p),p.connect(a.destination),l=e}if(t!==_.current){for(let e of i.getTracks())e.stop();return a.close().catch(()=>void 0),null}return d.current={stream:i,context:a,source:o,node:l,sink:p},c(i),u(a.sampleRate),n(`live`),v(),i}catch(e){return t===_.current?(i(e instanceof Error?e:Error(String(e))),n(`error`),null):null}},[v,y]),S=(0,G.useCallback)(e=>(g.current.add(e),()=>{g.current.delete(e)}),[]);return(0,G.useEffect)(()=>{m.current!==p&&(m.current=p,d.current&&x(h.current))},[p,x]),(0,G.useEffect)(()=>()=>{_.current+=1,y()},[y]),{status:t,error:r,stream:s,sampleRate:l,devices:a,start:x,stop:b,subscribeHop:S}}var Xa=Object.freeze({fontSizePx:48,mirrored:!1,baseWpm:150,voiceTracking:!0,vadSensitivity:.5,countdownSec:3,lineGuide:!0,micDeviceId:null}),Za=Object.freeze({fontSizePx:{min:28,max:96},baseWpm:{min:80,max:260},vadSensitivity:{min:0,max:1},micDeviceIdMaxLength:1024}),Qa=new Set([0,3,5,10]);function $a(e){return typeof e==`number`&&Qa.has(e)}function eo(e,t,n,r){return typeof e==`number`&&Number.isFinite(e)?Math.min(n,Math.max(t,e)):r}function to(e,t){return typeof e==`boolean`?e:t}function no(e,t=Xa){let n=typeof e==`object`&&e&&!Array.isArray(e)?e:{},r=n.countdownSec,i=n.micDeviceId;return{fontSizePx:eo(n.fontSizePx,Za.fontSizePx.min,Za.fontSizePx.max,t.fontSizePx),mirrored:to(n.mirrored,t.mirrored),baseWpm:eo(n.baseWpm,Za.baseWpm.min,Za.baseWpm.max,t.baseWpm),voiceTracking:to(n.voiceTracking,t.voiceTracking),vadSensitivity:eo(n.vadSensitivity,Za.vadSensitivity.min,Za.vadSensitivity.max,t.vadSensitivity),countdownSec:$a(r)?r:t.countdownSec,lineGuide:to(n.lineGuide,t.lineGuide),micDeviceId:i===null||typeof i==`string`&&i.length>0&&i.length<=Za.micDeviceIdMaxLength?i:i===``?null:t.micDeviceId}}var ro=`squisq:teleprompter-prefs`,io=66;function ao(){try{let e=globalThis.localStorage?.getItem(ro);return e?no(JSON.parse(e)):{...Xa}}catch{return{...Xa}}}function oo(e){try{globalThis.localStorage?.setItem(ro,JSON.stringify(e))}catch{}}function so(e){let t=1.5-Math.min(1,Math.max(0,e)),n=Math.min(5,Math.max(2.6,Cn.enterRatio*t));return{enterRatio:n,exitRatio:Math.max(2,n*(Cn.exitRatio/Cn.enterRatio))}}function co(e,t,n){let r=e.tokens,i=Math.sign(n);if(r.length===0||i===0)return t;let a=Math.min(Math.max(Math.floor(t),0),r.length);if(a<r.length){for(;a>=0&&r[a]?.spoken===!1;)--a;a<0&&(a=r.findIndex(e=>e.spoken!==!1))}if(a<0)return t;let o=Math.abs(Math.trunc(n));for(;o>0;){let e=a+i;for(;e>=0&&e<r.length&&r[e]?.spoken===!1;)e+=i;if(e<0)return 0;if(e>=r.length)return r.length;a=e,--o}return a}function lo(e){let{doc:t}=e,n=(0,G.useMemo)(()=>t&&t.blocks.length>0?I(t):null,[t]),[r,i]=(0,G.useState)(ao),[a,o]=(0,G.useState)(`stopped`),[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)({wordPos:0,micLevel:0,voiceActive:!1}),d=Ya(e.micConstraints),f=(0,G.useRef)(n),p=(0,G.useRef)(r),m=(0,G.useRef)(a),h=(0,G.useRef)(0),g=(0,G.useRef)(null),_=(0,G.useRef)(``),v=(0,G.useRef)(0),y=(0,G.useRef)(new Set),b=(0,G.useRef)(0),x=(0,G.useRef)(!1),S=(0,G.useRef)(null);f.current=n,p.current=r,m.current=a,(0,G.useEffect)(()=>{h.current=Math.min(h.current,n?.tokens.length??0),g.current=null,u(e=>({...e,wordPos:h.current}))},[n]);let C=(0,G.useCallback)((e=!1)=>{let t=performance.now();!e&&t-v.current<io||(v.current=t,u({wordPos:h.current,micLevel:b.current,voiceActive:x.current}))},[u]),w=(0,G.useCallback)(()=>{for(let e of y.current)e(h.current)},[]),T=(0,G.useCallback)(()=>{S.current!==null&&(clearInterval(S.current),S.current=null),c(null)},[]),E=(0,G.useCallback)(()=>{o(`finished`),m.current=`finished`},[]);(0,G.useEffect)(()=>d.subscribeHop(e=>{let t=f.current,n=d.sampleRate;if(!t||!n)return;let r=p.current,i=`${n}:${t.tokens.length}:${t.sourceText.length}`,a=g.current;!a||_.current!==i?(a=Qt(on(n,t,{vad:so(r.vadSensitivity),pacing:{baseWpm:r.baseWpm}}),h.current),_.current=i):a={...a,config:{...a.config,vad:so(r.vadSensitivity),pacing:{baseWpm:r.baseWpm}}},a=Yt(a,e),b.current=a.lastFrame?Math.min(1,a.lastFrame.rms*6):0,x.current=a.vad.speaking,m.current===`rolling`&&p.current.voiceTracking?(h.current=a.pacing.wordPos,h.current>=t.tokens.length&&E()):a=Qt(a,h.current),g.current=a,w(),C()}),[d,E,w,C]),(0,G.useEffect)(()=>{if(a!==`rolling`)return;let e=0,t=performance.now(),n=r=>{let i=Math.min(.25,(r-t)/1e3);t=r;let a=f.current,o=!p.current.voiceTracking||d.status!==`live`;if(a&&o){if(h.current=Math.min(a.tokens.length,h.current+p.current.baseWpm/60*i),h.current>=a.tokens.length){E(),C(!0);return}w()}C(),e=requestAnimationFrame(n)};return e=requestAnimationFrame(n),()=>cancelAnimationFrame(e)},[a,d.status,E,w,C]);let D=(0,G.useCallback)(()=>{T(),g.current&&=Qt(g.current,h.current),o(`rolling`),m.current=`rolling`},[T]),O=(0,G.useCallback)(()=>{if(m.current===`rolling`||m.current===`countdown`)return;m.current===`finished`&&(h.current=0,C(!0)),p.current.voiceTracking&&d.status===`idle`&&d.start(p.current.micDeviceId);let e=p.current.countdownSec;if(e>0){o(`countdown`),m.current=`countdown`,c(e);let t=e;S.current=setInterval(()=>{--t,t<=0?D():c(t)},1e3)}else D()},[D,d,C]),k=(0,G.useCallback)(()=>{if(m.current===`countdown`){T(),o(`stopped`),m.current=`stopped`;return}m.current===`rolling`&&(o(`paused`),m.current=`paused`)},[T]),A=(0,G.useCallback)(()=>{T(),h.current=0,g.current&&=Qt(g.current,0),o(`stopped`),m.current=`stopped`,C(!0)},[T,C]),j=(0,G.useCallback)(e=>{let t=f.current;t&&(h.current=Math.min(Math.max(0,e),t.tokens.length),g.current&&=Qt(g.current,h.current),m.current===`finished`&&(o(`paused`),m.current=`paused`),w(),C(!0))},[w,C]),M=(0,G.useCallback)(e=>{let t=f.current;t&&j(co(t,h.current,e))},[j]),N=(0,G.useCallback)(e=>{i(t=>{let n=no({...t,...e},t);return oo(n),n.micDeviceId!==t.micDeviceId&&d.status===`live`&&d.start(n.micDeviceId),n})},[d]),P=(0,G.useCallback)(e=>(y.current.add(e),()=>{y.current.delete(e)}),[]),F=(0,G.useCallback)(e=>{if(e.defaultPrevented)return;let t=e.target;if(!t?.closest(`input, textarea, select, [contenteditable="true"]`)&&!(e.key.startsWith(`Arrow`)&&t?.closest(`[role="tab"], [role="menuitem"], [role="option"], [role="slider"], [role="spinbutton"], [role="treeitem"]`)))switch(e.key){case`ArrowLeft`:if(e.preventDefault(),e.repeat)break;M(-1);break;case`ArrowRight`:if(e.preventDefault(),e.repeat)break;M(1);break;case`ArrowUp`:if(e.preventDefault(),e.repeat)break;O();break;case`ArrowDown`:if(e.preventDefault(),e.repeat)break;k();break;case`[`:e.preventDefault(),N({baseWpm:Math.max(Za.baseWpm.min,p.current.baseWpm-10)});break;case`]`:e.preventDefault(),N({baseWpm:Math.min(Za.baseWpm.max,p.current.baseWpm+10)});break;case`m`:case`M`:e.preventDefault(),N({mirrored:!p.current.mirrored});break;case`Escape`:(m.current===`countdown`||m.current===`rolling`)&&(e.preventDefault(),k());break;default:break}},[M,k,O,N]);return(0,G.useEffect)(()=>T,[T]),{script:n,transport:a,countdownRemaining:s,wordPos:l.wordPos,micLevel:l.micLevel,voiceActive:l.voiceActive,mic:d,prefs:r,setPrefs:N,play:O,pause:k,restart:A,nudge:M,seekToToken:j,subscribeTick:P,handleKeyDown:F}}function uo(){let e=[];if(typeof window<`u`&&typeof document<`u`){window.documentPictureInPicture&&e.push(`document-pip`);let t=document.createElement(`video`),n=document.pictureInPictureEnabled===!0&&typeof t.requestPictureInPicture==`function`,r=typeof t.webkitSetPresentationMode==`function`&&(t.webkitSupportsPresentationMode?.(`picture-in-picture`)??!0),i=typeof HTMLCanvasElement<`u`&&typeof HTMLCanvasElement.prototype.captureStream==`function`;(n||r)&&i&&e.push(`video-pip`),typeof window.open==`function`&&e.push(`popup`)}return e.push(`docked`),e}function fo(e){let t=null,n=0,r=!1,i={closed:new Set,tierchange:new Set},a=(e,t)=>{for(let n of i[e])n(t)},o=()=>{if(!t)return;let e=t;t=null,e.dispose(),a(`tierchange`,`docked`),a(`closed`,`docked`)},s=()=>f.close();typeof window<`u`&&window.addEventListener(`pagehide`,s);let c=(t,n)=>{t.title=n;let r=t.createElement(`style`);r.textContent=`${e.styleCss}
|
|
38
|
+
html,body{margin:0;height:100%;}#squisq-float-root{height:100%;display:flex;}`,t.head.appendChild(r);let i=t.createElement(`div`);return i.id=`squisq-float-root`,t.body.appendChild(i),i},l=async e=>{let t=window.documentPictureInPicture;if(!t)throw Error(`Document PiP unavailable`);let n=await t.requestWindow({width:e.width,height:e.height});for(let e of Array.from(document.styleSheets))try{let t=Array.from(e.cssRules).map(e=>e.cssText).join(`
|
|
39
|
+
`),r=n.document.createElement(`style`);r.textContent=t,n.document.head.appendChild(r)}catch{if(e.href){let t=n.document.createElement(`link`);t.rel=`stylesheet`,t.href=e.href,n.document.head.appendChild(t)}}let r=c(n.document,e.title);return n.addEventListener(`pagehide`,o),{tier:`document-pip`,portalTarget:r,canvasSink:null,dispose:()=>{n.removeEventListener(`pagehide`,o);try{n.close()}catch{}}}},u=async e=>{let t=document.createElement(`canvas`);t.width=Math.round(e.width*(window.devicePixelRatio||1)),t.height=Math.round(e.height*(window.devicePixelRatio||1));let n=t.getContext(`2d`);if(!n||typeof t.captureStream!=`function`)throw Error(`canvas.captureStream unavailable`);n.fillStyle=`#101014`,n.fillRect(0,0,t.width,t.height);let r,i;try{r=t.captureStream(0);let e=r.getVideoTracks()[0];if(typeof e.requestFrame==`function`){let t=e.requestFrame.bind(e);i=()=>t()}else r=t.captureStream(30),i=()=>void 0}catch{r=t.captureStream(30),i=()=>void 0}let a=document.createElement(`video`);a.muted=!0,a.playsInline=!0,a.style.position=`fixed`,a.style.left=`-10000px`,a.style.width=`${e.width}px`,a.srcObject=r,document.body.appendChild(a);let s=()=>{a.pause(),a.srcObject=null,a.remove();for(let e of r.getTracks())e.stop()};try{if(await a.play(),i(),typeof a.requestPictureInPicture==`function`&&document.pictureInPictureEnabled)await a.requestPictureInPicture(),a.addEventListener(`leavepictureinpicture`,o);else if(typeof a.webkitSetPresentationMode==`function`)a.webkitSetPresentationMode(`picture-in-picture`),a.addEventListener(`webkitpresentationmodechanged`,()=>{a.webkitPresentationMode===`inline`&&o()});else throw Error(`No video PiP API`)}catch(e){throw s(),e instanceof Error?e:Error(String(e))}return{tier:`video-pip`,portalTarget:null,canvasSink:{canvas:t,width:t.width,height:t.height,requestFrame:i},dispose:()=>{a.removeEventListener(`leavepictureinpicture`,o),document.pictureInPictureElement===a?document.exitPictureInPicture().catch(()=>void 0):typeof a.webkitSetPresentationMode==`function`&&a.webkitPresentationMode===`picture-in-picture`&&a.webkitSetPresentationMode(`inline`),s()}}},d=e=>{let t=window.open(``,`squisq-teleprompter`,`popup=yes,width=${e.width},height=${e.height}`);if(!t)throw Error(`Popup blocked`);let n=c(t.document,e.title);return t.addEventListener(`pagehide`,o),t.focus(),{tier:`popup`,portalTarget:n,canvasSink:null,dispose:()=>{t.removeEventListener(`pagehide`,o);try{t.close()}catch{}}}},f={get tier(){return t?.tier??`docked`},get isOpen(){return t!==null},async open(e){if(f.close(),r)return`docked`;let i=++n,o=()=>n!==i||r,s=uo(),c=e.preferredTier&&s.includes(e.preferredTier)?[e.preferredTier,...s.filter(t=>t!==e.preferredTier)]:s;for(let n of c){if(n===`docked`)break;if(o())return`docked`;let r=null;try{n===`document-pip`?r=await l(e):n===`video-pip`?r=await u(e):n===`popup`&&(r=d(e))}catch{r=null}if(r)return o()?(r.dispose(),`docked`):(t=r,a(`tierchange`,t.tier),t.tier)}return o()||a(`tierchange`,`docked`),`docked`},close(){if(n++,!t)return;let e=t;t=null,e.dispose(),a(`tierchange`,`docked`),a(`closed`,`docked`)},getPortalTarget(){return t?.portalTarget??null},getCanvasSink(){return t?.canvasSink??null},on(e,t){return i[e].add(t),()=>{i[e].delete(t)}},dispose(){f.close(),r=!0,typeof window<`u`&&window.removeEventListener(`pagehide`,s),i.closed.clear(),i.tierchange.clear()}};return f}var po=380,mo=540;function ho(e){let t=(0,G.useRef)(null);t.current===null&&(t.current=fo({styleCss:e}));let n=t.current,[r,i]=(0,G.useState)(`docked`),a=(0,G.useMemo)(()=>uo().filter(e=>e!==`docked`),[]);(0,G.useEffect)(()=>{let e=n.on(`tierchange`,i),t=n.on(`closed`,i);return()=>{e(),t(),n.dispose()}},[n]);let o=(0,G.useCallback)(async e=>{await n.open({width:po,height:mo,title:`Squisq Teleprompter`,...e===void 0?{}:{preferredTier:e}})},[n]),s=(0,G.useCallback)(()=>n.close(),[n]);return{tier:r,isOpen:n.isOpen,supportedTiers:a,portalTarget:n.getPortalTarget(),canvasSink:n.getCanvasSink(),open:o,close:s}}function go(e){let t=e.colors;return{"--squisq-prompter-bg":t.background,"--squisq-prompter-text":t.text,"--squisq-prompter-muted":t.textMuted??t.text,"--squisq-prompter-accent":t.primary,"--squisq-prompter-font":Ye(e.typography?.bodyFont,`system-ui, sans-serif`)}}var _o=`data-squisq-teleprompter`;function vo(e){if(e.querySelector(`style[${_o}]`))return;let t=e.createElement(`style`);t.setAttribute(_o,``),t.textContent=yo,e.head.appendChild(t)}var yo=`
|
|
40
|
+
.squisq-teleprompter-root {
|
|
41
|
+
display: flex;
|
|
42
|
+
flex-direction: column;
|
|
43
|
+
width: 100%;
|
|
44
|
+
height: 100%;
|
|
45
|
+
min-height: 0;
|
|
46
|
+
background: var(--squisq-bg, #f5f5f5);
|
|
47
|
+
outline: none;
|
|
48
|
+
}
|
|
49
|
+
.squisq-teleprompter-stage {
|
|
50
|
+
position: relative;
|
|
51
|
+
flex: 1;
|
|
52
|
+
min-height: 0;
|
|
53
|
+
display: flex;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.squisq-teleprompter-surface {
|
|
57
|
+
position: relative;
|
|
58
|
+
flex: 1;
|
|
59
|
+
min-height: 0;
|
|
60
|
+
overflow: hidden;
|
|
61
|
+
background: var(--squisq-prompter-bg, #101014);
|
|
62
|
+
color: var(--squisq-prompter-text, #f5f5f2);
|
|
63
|
+
font-family: var(--squisq-prompter-font, system-ui, sans-serif);
|
|
64
|
+
user-select: none;
|
|
65
|
+
}
|
|
66
|
+
.squisq-teleprompter-flip {
|
|
67
|
+
position: absolute;
|
|
68
|
+
inset: 0;
|
|
69
|
+
}
|
|
70
|
+
.squisq-teleprompter-surface--mirrored .squisq-teleprompter-flip {
|
|
71
|
+
transform: scaleX(-1);
|
|
72
|
+
}
|
|
73
|
+
.squisq-teleprompter-scroll {
|
|
74
|
+
position: absolute;
|
|
75
|
+
left: 0;
|
|
76
|
+
right: 0;
|
|
77
|
+
top: 0;
|
|
78
|
+
will-change: transform;
|
|
79
|
+
padding: 40vh 8% 60vh;
|
|
80
|
+
box-sizing: border-box;
|
|
81
|
+
}
|
|
82
|
+
.squisq-teleprompter-line-guide {
|
|
83
|
+
position: absolute;
|
|
84
|
+
left: 0;
|
|
85
|
+
right: 0;
|
|
86
|
+
pointer-events: none;
|
|
87
|
+
z-index: 2;
|
|
88
|
+
}
|
|
89
|
+
.squisq-teleprompter-line-guide::before,
|
|
90
|
+
.squisq-teleprompter-line-guide::after {
|
|
91
|
+
content: '';
|
|
92
|
+
position: absolute;
|
|
93
|
+
top: 50%;
|
|
94
|
+
border: 9px solid transparent;
|
|
95
|
+
transform: translateY(-50%);
|
|
96
|
+
}
|
|
97
|
+
.squisq-teleprompter-line-guide::before {
|
|
98
|
+
left: 6px;
|
|
99
|
+
border-left-color: var(--squisq-prompter-accent, #e8b64c);
|
|
100
|
+
}
|
|
101
|
+
.squisq-teleprompter-line-guide::after {
|
|
102
|
+
right: 6px;
|
|
103
|
+
border-right-color: var(--squisq-prompter-accent, #e8b64c);
|
|
104
|
+
}
|
|
105
|
+
.squisq-teleprompter-guide-band {
|
|
106
|
+
position: absolute;
|
|
107
|
+
left: 0;
|
|
108
|
+
right: 0;
|
|
109
|
+
background: color-mix(in srgb, var(--squisq-prompter-accent, #e8b64c) 9%, transparent);
|
|
110
|
+
pointer-events: none;
|
|
111
|
+
z-index: 1;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.squisq-teleprompter-block-marker {
|
|
115
|
+
display: block;
|
|
116
|
+
margin: 1.1em 0 0.35em;
|
|
117
|
+
font-size: 0.38em;
|
|
118
|
+
font-weight: 600;
|
|
119
|
+
letter-spacing: 0.14em;
|
|
120
|
+
text-transform: uppercase;
|
|
121
|
+
color: var(--squisq-prompter-muted, #9a9aa0);
|
|
122
|
+
border-top: 1px solid color-mix(in srgb, var(--squisq-prompter-muted, #9a9aa0) 35%, transparent);
|
|
123
|
+
padding-top: 0.6em;
|
|
124
|
+
}
|
|
125
|
+
.squisq-teleprompter-para {
|
|
126
|
+
margin: 0 0 0.55em;
|
|
127
|
+
line-height: 1.4;
|
|
128
|
+
font-weight: 500;
|
|
129
|
+
}
|
|
130
|
+
.squisq-teleprompter-word {
|
|
131
|
+
opacity: 0.45;
|
|
132
|
+
transition: color 0.1s linear, opacity 0.1s linear;
|
|
133
|
+
}
|
|
134
|
+
.squisq-teleprompter-word--read {
|
|
135
|
+
opacity: 0.9;
|
|
136
|
+
}
|
|
137
|
+
.squisq-teleprompter-word--active {
|
|
138
|
+
opacity: 1;
|
|
139
|
+
font-weight: 800;
|
|
140
|
+
color: var(--squisq-prompter-accent, #e8b64c);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.squisq-teleprompter-countdown {
|
|
144
|
+
position: absolute;
|
|
145
|
+
inset: 0;
|
|
146
|
+
display: flex;
|
|
147
|
+
align-items: center;
|
|
148
|
+
justify-content: center;
|
|
149
|
+
z-index: 3;
|
|
150
|
+
background: color-mix(in srgb, var(--squisq-prompter-bg, #101014) 72%, transparent);
|
|
151
|
+
}
|
|
152
|
+
.squisq-teleprompter-countdown-digit {
|
|
153
|
+
font-size: 18vmin;
|
|
154
|
+
font-weight: 800;
|
|
155
|
+
color: var(--squisq-prompter-accent, #e8b64c);
|
|
156
|
+
animation: squisq-prompter-pulse 1s ease-in-out infinite;
|
|
157
|
+
}
|
|
158
|
+
.squisq-teleprompter-recdot {
|
|
159
|
+
position: absolute;
|
|
160
|
+
top: 14px;
|
|
161
|
+
right: 16px;
|
|
162
|
+
z-index: 4;
|
|
163
|
+
width: 14px;
|
|
164
|
+
height: 14px;
|
|
165
|
+
border-radius: 50%;
|
|
166
|
+
background: #e5484d;
|
|
167
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, #e5484d 30%, transparent);
|
|
168
|
+
animation: squisq-prompter-pulse 1.4s ease-in-out infinite;
|
|
169
|
+
}
|
|
170
|
+
/* Counter-flip overlays so they stay readable in mirror mode. */
|
|
171
|
+
.squisq-teleprompter-surface--mirrored .squisq-teleprompter-countdown,
|
|
172
|
+
.squisq-teleprompter-surface--mirrored .squisq-teleprompter-recdot {
|
|
173
|
+
transform: scaleX(-1);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.squisq-teleprompter-selfview {
|
|
177
|
+
position: absolute;
|
|
178
|
+
right: 14px;
|
|
179
|
+
bottom: 14px;
|
|
180
|
+
width: 160px;
|
|
181
|
+
border-radius: 8px;
|
|
182
|
+
border: 2px solid color-mix(in srgb, #e5484d 60%, transparent);
|
|
183
|
+
z-index: 5;
|
|
184
|
+
background: #000;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.squisq-teleprompter-review {
|
|
188
|
+
display: flex;
|
|
189
|
+
align-items: center;
|
|
190
|
+
flex-wrap: wrap;
|
|
191
|
+
gap: 10px;
|
|
192
|
+
padding: 8px 12px;
|
|
193
|
+
border-top: 1px solid var(--squisq-border, #e5e7eb);
|
|
194
|
+
background: var(--squisq-surface, var(--squisq-bg, #fff));
|
|
195
|
+
color: var(--squisq-text, #111827);
|
|
196
|
+
font-size: 12.5px;
|
|
197
|
+
}
|
|
198
|
+
.squisq-teleprompter-review audio {
|
|
199
|
+
height: 28px;
|
|
200
|
+
max-width: 260px;
|
|
201
|
+
}
|
|
202
|
+
.squisq-teleprompter-review button {
|
|
203
|
+
font: inherit;
|
|
204
|
+
color: inherit;
|
|
205
|
+
background: var(--squisq-input-bg, #fff);
|
|
206
|
+
border: 1px solid var(--squisq-border, #d1d5db);
|
|
207
|
+
border-radius: 6px;
|
|
208
|
+
padding: 4px 10px;
|
|
209
|
+
cursor: pointer;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.squisq-teleprompter-float-note {
|
|
213
|
+
flex: 1;
|
|
214
|
+
display: flex;
|
|
215
|
+
flex-direction: column;
|
|
216
|
+
align-items: center;
|
|
217
|
+
justify-content: center;
|
|
218
|
+
gap: 12px;
|
|
219
|
+
color: var(--squisq-text-muted, #4b5563);
|
|
220
|
+
font-size: 14px;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.squisq-teleprompter-controls {
|
|
224
|
+
display: flex;
|
|
225
|
+
align-items: center;
|
|
226
|
+
flex-wrap: wrap;
|
|
227
|
+
gap: 10px;
|
|
228
|
+
padding: 8px 12px;
|
|
229
|
+
border-top: 1px solid var(--squisq-border, #e5e7eb);
|
|
230
|
+
background: var(--squisq-surface, var(--squisq-bg, #fff));
|
|
231
|
+
color: var(--squisq-text, #111827);
|
|
232
|
+
font-size: 12.5px;
|
|
233
|
+
}
|
|
234
|
+
.squisq-teleprompter-controls .squisq-teleprompter-group {
|
|
235
|
+
display: inline-flex;
|
|
236
|
+
align-items: center;
|
|
237
|
+
gap: 6px;
|
|
238
|
+
white-space: nowrap;
|
|
239
|
+
}
|
|
240
|
+
.squisq-teleprompter-controls button {
|
|
241
|
+
font: inherit;
|
|
242
|
+
color: inherit;
|
|
243
|
+
background: var(--squisq-input-bg, #fff);
|
|
244
|
+
border: 1px solid var(--squisq-border, #d1d5db);
|
|
245
|
+
border-radius: 6px;
|
|
246
|
+
padding: 4px 10px;
|
|
247
|
+
cursor: pointer;
|
|
248
|
+
}
|
|
249
|
+
.squisq-teleprompter-controls button:hover {
|
|
250
|
+
background: var(--squisq-surface-hover, #f3f4f6);
|
|
251
|
+
}
|
|
252
|
+
.squisq-teleprompter-controls button[aria-pressed='true'] {
|
|
253
|
+
background: var(--squisq-text, #111827);
|
|
254
|
+
color: var(--squisq-bg, #fff);
|
|
255
|
+
border-color: var(--squisq-text, #111827);
|
|
256
|
+
}
|
|
257
|
+
.squisq-teleprompter-controls select,
|
|
258
|
+
.squisq-teleprompter-controls input[type='range'] {
|
|
259
|
+
font: inherit;
|
|
260
|
+
color: inherit;
|
|
261
|
+
background: var(--squisq-input-bg, #fff);
|
|
262
|
+
border: 1px solid var(--squisq-border, #d1d5db);
|
|
263
|
+
border-radius: 6px;
|
|
264
|
+
max-width: 170px;
|
|
265
|
+
}
|
|
266
|
+
.squisq-teleprompter-controls input[type='range'] {
|
|
267
|
+
border: none;
|
|
268
|
+
background: transparent;
|
|
269
|
+
width: 110px;
|
|
270
|
+
}
|
|
271
|
+
.squisq-teleprompter-meter {
|
|
272
|
+
position: relative;
|
|
273
|
+
width: 64px;
|
|
274
|
+
height: 8px;
|
|
275
|
+
border-radius: 4px;
|
|
276
|
+
overflow: hidden;
|
|
277
|
+
background: var(--squisq-border, #e5e7eb);
|
|
278
|
+
}
|
|
279
|
+
.squisq-teleprompter-meter-fill {
|
|
280
|
+
position: absolute;
|
|
281
|
+
inset: 0 auto 0 0;
|
|
282
|
+
background: #9ca3af;
|
|
283
|
+
transition: width 0.08s linear;
|
|
284
|
+
}
|
|
285
|
+
.squisq-teleprompter-meter--voice .squisq-teleprompter-meter-fill {
|
|
286
|
+
background: #30a46c;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
@keyframes squisq-prompter-pulse {
|
|
290
|
+
0%, 100% { opacity: 1; }
|
|
291
|
+
50% { opacity: 0.45; }
|
|
292
|
+
}
|
|
293
|
+
@media (prefers-reduced-motion: reduce) {
|
|
294
|
+
.squisq-teleprompter-countdown-digit,
|
|
295
|
+
.squisq-teleprompter-recdot {
|
|
296
|
+
animation: none;
|
|
297
|
+
}
|
|
298
|
+
.squisq-teleprompter-word {
|
|
299
|
+
transition: none;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
`,bo=250;function xo(e){let t=e.numberOfChannels;if(t===1)return e.getChannelData(0).slice();let n=new Float32Array(e.length);for(let r=0;r<t;r++){let i=e.getChannelData(r);for(let e=0;e<n.length;e++)n[e]+=i[e]/t}return n}var So=class extends Error{constructor(){super(`Narration start aborted`),this.name=`StartAborted`}};function Co(e){return e.state===`inactive`?Promise.resolve():new Promise(t=>{let n=()=>t();e.addEventListener(`stop`,n,{once:!0});try{e.stop()}catch{e.removeEventListener(`stop`,n),t()}})}function wo(e){let[t,n]=(0,G.useState)(`idle`),[r,i]=(0,G.useState)(null),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(null),d=(0,G.useRef)(null),f=(0,G.useRef)(!1),p=(0,G.useRef)(null),m=(0,G.useRef)(!1),h=(0,G.useRef)(0),g=(0,G.useRef)(!1),_=(0,G.useRef)(e);_.current=e;let v=(0,G.useCallback)(()=>{h.current++},[]),y=(0,G.useCallback)(e=>{p.current=e,u(e)},[]),b=(0,G.useCallback)(()=>{v();let e=d.current;if(d.current=null,e){if(e.traceTimer!==null&&clearInterval(e.traceTimer),e.audioRecorder.state!==`inactive`)try{e.audioRecorder.stop()}catch{}if(e.cameraRecorder&&e.cameraRecorder.state!==`inactive`)try{e.cameraRecorder.stop()}catch{}for(let t of e.cameraStream?.getTracks()??[])t.stop();c(null)}},[v]),x=(0,G.useCallback)(async()=>{if(d.current||g.current)return;let e=_.current,t=++h.current,r=()=>h.current!==t;g.current=!0,i(null),y(null),n(`starting`);let o=null,s=null,l=null,u=null,f=()=>{u!==null&&clearInterval(u);for(let e of[s,l])if(e&&e.state!==`inactive`)try{e.stop()}catch{}for(let e of o?.getTracks()??[])e.stop()};try{let t=e.mic.status===`live`&&e.mic.stream?e.mic.stream:await e.mic.start(e.getMicDeviceId());if(r())throw new So;if(!t)throw e.mic.error??Error(`Microphone unavailable`);let i=Na(`audio`,e.audioRecorderOptions?.mimeType),f={...e.audioRecorderOptions};i.mimeType?f.mimeType=i.mimeType:delete f.mimeType,s=new MediaRecorder(t,Object.keys(f).length>0?f:void 0);let p=null,m=null;if(a){if(o=await Ba({video:e.cameraConstraints??!0,audio:!1}),r())throw new So;let t=Na(`video`,e.cameraRecorderOptions?.mimeType),n={...e.cameraRecorderOptions};n.videoKeyFrameIntervalDuration!==void 0&&n.videoKeyFrameIntervalCount!==void 0&&delete n.videoKeyFrameIntervalCount,t.mimeType?n.mimeType=t.mimeType:delete n.mimeType,l=new MediaRecorder(o,Object.keys(n).length>0?n:void 0),p=t.mimeType,m=t.extension}let h={audioRecorder:s,audioChunks:[],audioMime:i.mimeType,audioExt:i.extension,cameraRecorder:l,cameraChunks:[],cameraMime:p,cameraExt:m,cameraStream:o,traceSamples:[],traceTimer:null,startedAtMs:performance.now(),audioStartMs:null,cameraStartMs:null};if(s.ondataavailable=e=>{e.data.size>0&&h.audioChunks.push(e.data)},s.onstart=()=>{h.audioStartMs=performance.now()},l&&(l.ondataavailable=e=>{e.data.size>0&&h.cameraChunks.push(e.data)},l.onstart=()=>{h.cameraStartMs=performance.now()}),r())throw new So;s.start(1e3),l?.start(1e3),u=setInterval(()=>{let e=h.audioStartMs??h.startedAtMs;h.traceSamples.push({tMs:performance.now()-e,wordPos:_.current.getWordPos()})},bo),h.traceTimer=u,d.current=h,c(o),n(`recording`),e.onRecordingStart?.()}catch(e){f(),b(),c(null),e instanceof So?n(`idle`):(i(e instanceof Error?e:Error(String(e))),n(`error`))}finally{g.current=!1}},[y,b,a]),S=(0,G.useCallback)(async()=>{let e=d.current;if(!e){g.current&&(v(),n(`idle`));return}d.current=null,e.traceTimer!==null&&clearInterval(e.traceTimer),_.current.onRecordingStop?.(),f.current=!0,n(`processing`),await Co(e.audioRecorder),e.cameraRecorder&&await Co(e.cameraRecorder);for(let t of e.cameraStream?.getTracks()??[])t.stop();c(null);let t=e.audioRecorder.mimeType||e.audioMime,r=new Blob(e.audioChunks,{type:t}),i=e.cameraRecorder&&e.cameraChunks.length>0?new Blob(e.cameraChunks,{type:e.cameraRecorder.mimeType||e.cameraMime||`video/webm`}):null,a=(performance.now()-(e.audioStartMs??e.startedAtMs))/1e3,o=_.current.getScript(),s={samples:e.traceSamples},l=null,u=a;if(o)try{let e=new AudioContext;try{let t=await e.decodeAudioData(await r.arrayBuffer());u=t.duration,l=nn({pcm:xo(t),sampleRate:t.sampleRate,script:o,trace:s})}finally{e.close().catch(()=>void 0)}}catch{l=null}if(f.current=!1,m.current){console.warn(`[squisq-editor] Narration take discarded: the teleprompter was closed while the ${a.toFixed(1)}s recording was still being aligned. The audio was not saved.`);return}y({audioBlob:r,audioMime:t,audioExt:e.audioExt,cameraBlob:i,cameraMime:i?e.cameraMime??`video/webm`:null,cameraExt:i?e.cameraExt:null,durationSec:u,cameraOffsetSec:e.cameraStartMs!==null&&e.audioStartMs!==null?(e.cameraStartMs-e.audioStartMs)/1e3:void 0,trace:s,alignment:l,script:o??{sourceText:``,tokens:[],blocks:[],totalSyllables:0,cumulativeSyllables:[0]}}),n(`review`)},[y,v]),C=(0,G.useCallback)(()=>{b(),y(null),i(null),n(`idle`)},[y,b]),w=(0,G.useCallback)(()=>{b(),y(null),i(null),n(`idle`)},[y,b]),T=(0,G.useCallback)(()=>n(`saving`),[]),E=(0,G.useCallback)((e,t)=>{e?(y(null),i(null),n(`idle`)):(i(t??Error(`Save failed`)),n(`review`))},[y]);return(0,G.useEffect)(()=>(m.current=!1,()=>{m.current=!0,f.current?console.warn(`[squisq-editor] Narration take discarded: the teleprompter was closed while a recording was still being aligned. The audio was not saved.`):p.current&&console.warn(`[squisq-editor] Unsaved narration take discarded: the teleprompter was closed before the take was saved.`),b()}),[b]),{state:t,error:r,withCamera:a,setWithCamera:o,cameraStream:s,take:l,start:x,stop:S,retake:C,discard:w,beginSave:T,finishSave:E}}var To=/^\{\[audio\s[^\]]*\]\}\s*$/,Eo=/\banchor=(?:"document"|'document'|document)(?:\s|\]|$)/,Do=/^<video\s[^>]*src="[^"]*"[^>]*><\/video>\s*$/;function Oo(e){return To.test(e)&&Eo.test(e)}function ko(e){return/[\s"']/.test(e)?`"${e.replace(/"/g,`\\"`)}"`:e}function Ao(e){return`{[audio src=${ko(e)} anchor=document]}`}function jo(e){return`<video src="${e}" controls width="240"></video>`}function Mo(e,t,n){let r=e.split(`
|
|
303
|
+
`),i=0;if(r[0]?.trim()===`---`){for(let e=1;e<r.length;e++)if(r[e].trim()===`---`){i=e+1;break}}let a=i;for(;a<r.length&&r[a].trim()===``;)a++;if(a<r.length&&Oo(r[a])){let e=a+1;for(;e<r.length&&r[e].trim()===``;)e++;e<r.length&&Do.test(r[e])&&e++,e<r.length&&r[e].trim()===``&&e++,r.splice(i,e-i)}let o=[Ao(t)];n&&o.push(``,jo(n));let s=r.slice(0,i),c=r.slice(i);return s.length>0&&s[s.length-1].trim()!==``&&s.push(``),c.length>0&&c[0].trim()!==``&&o.push(``),[...s,...o,...c].join(`
|
|
304
|
+
`)}function No(e){let t=e.alignment?g(e.script,e.alignment,e.durationSec,{baseWpm:e.baseWpm,...e.cameraOffsetSec===void 0?{}:{cameraOffsetSec:e.cameraOffsetSec}}):{version:3,sourceText:e.script.sourceText,duration:e.durationSec,bookmarks:[],blocks:[],generator:{name:`squisq-teleprompter`,method:`dsp-align`,baseWpm:e.baseWpm}};return{audioRelativeName:`audio/${Ra(`audio`,e.audioExt,e.audioBasename)}`,cameraRelativeName:e.cameraExt?`video/${Ra(`video`,e.cameraExt,`narration-cam`)}`:null,sidecarPayload:t,sidecarPathFor:e=>Ga(e),nextMarkdown:(e,t,n)=>Mo(e,t,n)}}async function Po(e,t,n,r={}){let i=r.audioPath??await n.mediaProvider.addMedia(e.audioRelativeName,t.audioBlob,t.audioMime);r.audioPath=i;let a=r.sidecarPath??e.sidecarPathFor(i);if(r.sidecarPath===void 0){let t=Ua(e.sidecarPayload);if(n.container)await n.container.writeFile(a,t,`application/json`);else{let e=await n.mediaProvider.addMedia(a,t,`application/json`);e!==a&&console.warn(`Narration timing sidecar stored at "${e}" instead of "${a}"; narration timing will not be discovered until it sits next to the audio file.`)}r.sidecarPath=a}let o=r.cameraPath??null;return r.cameraPath===void 0&&(e.cameraRelativeName&&t.cameraBlob&&t.cameraMime&&(o=await n.mediaProvider.addMedia(e.cameraRelativeName,t.cameraBlob,t.cameraMime)),r.cameraPath=o),n.setMarkdownSource(e.nextMarkdown(n.getMarkdownSource(),i,o)),n.bumpMediaRevision(),{audioPath:i,cameraPath:o,sidecarPath:a}}async function Fo(e,t){let n=[e.audioPath,e.cameraPath??void 0].filter(e=>typeof e==`string`);for(let e of n)try{await t.mediaProvider.removeMedia(e)}catch(t){console.warn(`Could not remove orphaned narration media "${e}": `+(t instanceof Error?t.message:String(t)))}if(e.sidecarPath!==void 0&&t.container)try{await t.container.removeFile(e.sidecarPath)}catch(t){console.warn(`Could not remove orphaned narration sidecar "${e.sidecarPath}": `+(t instanceof Error?t.message:String(t)))}delete e.audioPath,delete e.cameraPath,delete e.sidecarPath}function Io(e){let{doc:t,recording:n=null,getAudioBasename:r}=e,i=lo({doc:t,micConstraints:e.micConstraints}),a=ho(yo),o=(0,G.useRef)(i);o.current=i;let[s,c]=(0,G.useState)(null),l=wo({mic:i.mic,getScript:()=>o.current.script,getWordPos:()=>o.current.wordPos,getMicDeviceId:()=>o.current.prefs.micDeviceId,cameraConstraints:e.cameraConstraints,audioRecorderOptions:e.audioRecorderOptions,cameraRecorderOptions:e.cameraRecorderOptions,onRecordingStart:()=>o.current.play(),onRecordingStop:()=>o.current.pause()}),u=(0,G.useRef)(l);u.current=l;let d=(0,G.useRef)(n);d.current=n;let f=(0,G.useRef)(r);f.current=r;let p=(0,G.useRef)(null),m=(0,G.useCallback)(e=>{let t=p.current;if(t&&t.take===e)return t.progress;let n={take:e,progress:{}};return p.current=n,n.progress},[]),h=(0,G.useCallback)(()=>{let e=p.current;p.current=null;let t=d.current;!e||!t||e.progress.audioPath===void 0&&e.progress.sidecarPath===void 0||Fo(e.progress,{mediaProvider:t.mediaProvider,container:t.container})},[]),g=(0,G.useCallback)(()=>{h(),u.current.retake()},[h]),_=(0,G.useCallback)(()=>{h(),u.current.discard()},[h]),v=(0,G.useMemo)(()=>l.take?URL.createObjectURL(l.take.audioBlob):null,[l.take]);(0,G.useEffect)(()=>()=>{v&&URL.revokeObjectURL(v)},[v]);let y=(0,G.useCallback)(e=>{let t=u.current.take?.alignment;!t||t.words.length===0||o.current.seekToToken(R(t.words,e.currentTarget.currentTime))},[]),b=(0,G.useCallback)(async()=>{let e=u.current.take;if(!(!e||!n)){u.current.beginSave();try{let t=f.current?.(),r=await Po(No({script:e.script,alignment:e.alignment,durationSec:e.durationSec,audioExt:e.audioExt,cameraExt:e.cameraExt,baseWpm:o.current.prefs.baseWpm,...e.cameraOffsetSec===void 0?{}:{cameraOffsetSec:e.cameraOffsetSec},...t?{audioBasename:t}:{}}),e,{mediaProvider:n.mediaProvider,container:n.container,getMarkdownSource:()=>d.current?.markdownSource??``,setMarkdownSource:n.setMarkdownSource,bumpMediaRevision:n.bumpMediaRevision},m(e));p.current=null,u.current.finishSave(!0),c(`Saved ${r.audioPath}${e.alignment?` — blocks re-timed to your voice`:``}`)}catch(e){u.current.finishSave(!1,e instanceof Error?e:Error(String(e)))}}},[n,m]);return{controller:i,float:a,recorder:l,recording:n,saveNotice:s,dismissSaveNotice:(0,G.useCallback)(()=>c(null),[]),handleSave:b,handleRetake:g,handleDiscard:_,reviewAudioUrl:v,handleReviewTimeUpdate:y}}var Lo=.35,Ro=2600;function zo(e){let t=e.querySelectorAll(`[data-token-idx]`),n=Array(t.length),r=Array(t.length),i=e.getBoundingClientRect();return t.forEach(e=>{let t=Number(e.dataset.tokenIdx);if(!Number.isFinite(t))return;let a=e.getBoundingClientRect();n[t]=a.top-i.top,r[t]=a.height}),{tokenTops:n,tokenHeights:r}}function Bo(e,t,n,r=Lo){let i=t.tokenTops.length;if(i===0)return 0;let a=Math.min(Math.max(e,0),i-1),o=Math.floor(a),s=a-o,c=t.tokenTops[o]??0,l=c+((t.tokenTops[Math.min(o+1,i-1)]??c)-c)*s,u=t.tokenHeights[o]??0;return Math.max(0,l+u/2-n*r)}function Vo(e,t,n,r=Ro){let i=Math.min(Math.max(n,0),250)/1e3;if(i===0)return e;let a=1-Math.exp(-i/.18),o=e+(t-e)*a,s=r*i;return o-e>s?o=e+s:e-o>s&&(o=e-s),Math.abs(o-t)<.25?t:o}var Ho=60;function Uo(e){return e.blocks.map(t=>{let n=[],r=[];for(let i=t.tokenStart;i<t.tokenEnd;i++)r.push(i),e.tokens[i].pauseAfter>=2&&i<t.tokenEnd-1&&(n.push({key:`${t.blockId}-${n.length}`,tokenIndexes:r}),r=[]);r.length>0&&n.push({key:`${t.blockId}-${n.length}`,tokenIndexes:r});let i={blockId:t.blockId,paragraphs:n};return t.heading!==void 0&&(i.heading=t.heading),i})}var Wo=(0,G.memo)(function({script:e,compact:t}){return(0,K.jsx)(K.Fragment,{children:(0,G.useMemo)(()=>Uo(e),[e]).map(n=>(0,K.jsxs)(`section`,{"data-block-id":n.blockId,children:[!t&&n.heading?(0,K.jsx)(`span`,{className:`squisq-teleprompter-block-marker`,children:n.heading}):null,n.paragraphs.map(t=>(0,K.jsx)(`p`,{className:`squisq-teleprompter-para`,children:t.tokenIndexes.map(t=>(0,K.jsxs)(`span`,{className:`squisq-teleprompter-word`,"data-token-idx":t,children:[e.tokens[t].text,` `]},t))},t.key))]},n.blockId))})});function Go({script:e,wordPos:t,fontSizePx:n,mirrored:r,lineGuide:i,countdownRemaining:a,recordingIndicator:o,theme:s,compact:c=!1,onSeekToken:l,onNudge:u,onToggleAutoAdvance:d}){let f=(0,G.useRef)(null),p=(0,G.useRef)(null),m=(0,G.useRef)(t);m.current=t;let h=(0,G.useMemo)(()=>go(s),[s]);(0,G.useEffect)(()=>{let e=f.current?.ownerDocument;e&&vo(e)},[]),(0,G.useEffect)(()=>{let e=f.current;if(!e||!u)return;let t=-1/0,n=0,r=e=>{if(e.ctrlKey||e.metaKey||e.altKey||e.deltaY===0)return;let r=Math.sign(e.deltaY);e.preventDefault(),!(r===n&&e.timeStamp-t<Ho)&&(u(r),t=e.timeStamp,n=r)};return e.addEventListener(`wheel`,r,{passive:!1}),()=>e.removeEventListener(`wheel`,r)},[u]),(0,G.useEffect)(()=>{let t=f.current,n=p.current;if(!t||!n)return;let r=t.ownerDocument.defaultView??window,i=null,a=[],o=-1,s=0,c=performance.now(),l=0,u=e.tokens,d=new Int32Array(u.length),h=-1;for(let e=0;e<u.length;e++)u[e].spoken&&(h=e),d[e]=h;let g=-1;for(let e=0;e<u.length;e++)if(u[e].spoken){g=e;break}for(let e=0;e<u.length&&d[e]===-1;e++)d[e]=g;let _=()=>{i=zo(n),a=Array.from(n.querySelectorAll(`[data-token-idx]`))};_();let v=e=>{if(e===o)return;let t=Math.min(o,e),n=Math.max(o,e);for(let r=Math.max(0,t);r<=n&&r<a.length;r++){let t=a[r];t&&(t.classList.toggle(`squisq-teleprompter-word--active`,r===e),t.classList.toggle(`squisq-teleprompter-word--read`,r<e))}o=e},y=e=>{let o=e-c;c=e;let u=m.current,f=Math.min(Math.max(Math.floor(u),0),a.length-1),p=f<d.length&&d[f]>=0?d[f]:f;if(a.length>0&&v(p),i){let e=Bo(u,i,t.clientHeight);s=Vo(s,e,o),n.style.transform=`translateY(${-s}px)`}l=r.requestAnimationFrame(y)};l=r.requestAnimationFrame(y);let b=typeof ResizeObserver<`u`?new ResizeObserver(_):null;return b?.observe(t),()=>{r.cancelAnimationFrame(l),b?.disconnect()}},[e,n,c]);let g=l?e=>{let t=e.target?.closest(`[data-token-idx]`);if(!t)return;let n=Number(t.dataset.tokenIdx);Number.isFinite(n)&&l(n)}:void 0,_=d?e=>{e.button===1&&(e.preventDefault(),d())}:void 0,v=d?e=>{e.button===1&&e.preventDefault()}:void 0;return(0,K.jsxs)(`div`,{ref:f,className:`squisq-teleprompter-surface${r?` squisq-teleprompter-surface--mirrored`:``}`,style:{...h,fontSize:`${n}px`},"data-testid":`teleprompter-surface`,tabIndex:0,"aria-label":`Teleprompter script; left and right arrows or the mouse wheel adjust the word position; up starts automatic advancement; down stops it; press the mouse wheel to toggle it; double-click a word to jump`,onMouseDown:_,onAuxClick:v,children:[(0,K.jsx)(`div`,{className:`squisq-teleprompter-flip`,children:(0,K.jsx)(`div`,{ref:p,className:`squisq-teleprompter-scroll`,style:c?{padding:`30vh 5% 60vh`}:void 0,onDoubleClick:g,children:(0,K.jsx)(Wo,{script:e,compact:c})})}),i?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`squisq-teleprompter-guide-band`,style:{top:`calc(${Lo*100}% - 0.75em)`,height:`1.5em`}}),(0,K.jsx)(`div`,{className:`squisq-teleprompter-line-guide`,style:{top:`calc(${Lo*100}% - 0.75em)`,height:`1.5em`}})]}):null,a===null?null:(0,K.jsx)(`div`,{className:`squisq-teleprompter-countdown`,children:(0,K.jsx)(`span`,{className:`squisq-teleprompter-countdown-digit`,children:a})}),o?(0,K.jsx)(`div`,{className:`squisq-teleprompter-recdot`}):null]})}var Ko={"document-pip":`Floating window (always on top)`,"video-pip":`Picture-in-picture (read-only)`,popup:`Popup window`,docked:`Docked`};function qo({controller:e,float:t,recordSlot:n,showPlayPause:r=!0}){let{transport:i,prefs:a,setPrefs:o,mic:s}=e,c=i===`rolling`||i===`countdown`,l=a.voiceTracking&&s.status===`live`;return(0,K.jsxs)(`div`,{className:`squisq-teleprompter-controls`,"data-testid":`teleprompter-controls`,"data-mic-status":s.status,"data-transport":i,"data-voice-live":l||void 0,children:[(0,K.jsxs)(`span`,{className:`squisq-teleprompter-group`,children:[r?(0,K.jsx)(`button`,{type:`button`,onClick:()=>c?e.pause():e.play(),"aria-label":c?`Pause prompter`:`Start prompter`,children:c?`⏸ Pause`:i===`paused`?`▶ Resume`:`▶ Start`}):null,(0,K.jsx)(`button`,{type:`button`,onClick:e.restart,"aria-label":`Restart prompter`,children:`⟲ Restart`})]}),(0,K.jsxs)(`span`,{className:`squisq-teleprompter-group`,children:[(0,K.jsx)(`label`,{htmlFor:`squisq-prompter-countdown`,children:`Countdown`}),(0,K.jsxs)(`select`,{id:`squisq-prompter-countdown`,value:a.countdownSec,onChange:e=>o({countdownSec:Number(e.target.value)}),children:[(0,K.jsx)(`option`,{value:0,children:`Off`}),(0,K.jsx)(`option`,{value:3,children:`3s`}),(0,K.jsx)(`option`,{value:5,children:`5s`}),(0,K.jsx)(`option`,{value:10,children:`10s`})]})]}),(0,K.jsxs)(`span`,{className:`squisq-teleprompter-group`,children:[(0,K.jsx)(`label`,{htmlFor:`squisq-prompter-wpm`,children:`Speed`}),(0,K.jsx)(`input`,{id:`squisq-prompter-wpm`,type:`range`,min:Za.baseWpm.min,max:Za.baseWpm.max,step:5,value:a.baseWpm,onChange:e=>o({baseWpm:Number(e.target.value)})}),(0,K.jsxs)(`span`,{"aria-live":`off`,children:[a.baseWpm,` wpm`]})]}),(0,K.jsxs)(`span`,{className:`squisq-teleprompter-group`,children:[(0,K.jsx)(`button`,{type:`button`,"aria-pressed":a.voiceTracking,onClick:()=>{let e=!a.voiceTracking;o({voiceTracking:e}),e&&s.status===`idle`&&s.start(a.micDeviceId),!e&&s.status!==`idle`&&s.stop()},title:`Match the prompter speed to your voice (halts when you stop speaking)`,children:`🎙 Voice pace`}),a.voiceTracking?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`label`,{htmlFor:`squisq-prompter-sensitivity`,title:`Voice detection sensitivity`,children:`Sens.`}),(0,K.jsx)(`input`,{id:`squisq-prompter-sensitivity`,type:`range`,min:Za.vadSensitivity.min,max:Za.vadSensitivity.max,step:.05,value:a.vadSensitivity,onChange:e=>o({vadSensitivity:Number(e.target.value)}),style:{width:70}}),(0,K.jsxs)(`select`,{"aria-label":`Microphone`,value:a.micDeviceId??``,onChange:e=>o({micDeviceId:e.target.value||null}),children:[(0,K.jsx)(`option`,{value:``,children:`Default mic`}),s.devices.map(e=>(0,K.jsx)(`option`,{value:e.deviceId,children:e.label||`Mic ${e.deviceId.slice(0,6)}`},e.deviceId))]}),(0,K.jsx)(`span`,{className:`squisq-teleprompter-meter${e.voiceActive?` squisq-teleprompter-meter--voice`:``}`,role:`meter`,"aria-label":`Mic level`,"aria-valuemin":0,"aria-valuemax":1,"aria-valuenow":Math.round(e.micLevel*100)/100,children:(0,K.jsx)(`span`,{className:`squisq-teleprompter-meter-fill`,style:{width:`${Math.round(e.micLevel*100)}%`}})}),s.status===`error`?(0,K.jsx)(`span`,{title:s.error?.message??`Microphone unavailable`,children:`⚠ mic unavailable — constant speed`}):null]}):null]}),(0,K.jsxs)(`span`,{className:`squisq-teleprompter-group`,children:[(0,K.jsx)(`label`,{htmlFor:`squisq-prompter-fontsize`,children:`Aa`}),(0,K.jsx)(`input`,{id:`squisq-prompter-fontsize`,type:`range`,min:Za.fontSizePx.min,max:Za.fontSizePx.max,step:2,value:a.fontSizePx,onChange:e=>o({fontSizePx:Number(e.target.value)}),style:{width:80},"aria-label":`Prompter font size`}),(0,K.jsx)(`button`,{type:`button`,"aria-pressed":a.mirrored,onClick:()=>o({mirrored:!a.mirrored}),title:`Mirror for beam-splitter teleprompter rigs (M)`,children:`⇋ Mirror`}),(0,K.jsx)(`button`,{type:`button`,"aria-pressed":a.lineGuide,onClick:()=>o({lineGuide:!a.lineGuide}),title:`Eye-line guide`,children:`▸ Guide`})]}),n,t.supportedTiers.length>0?(0,K.jsx)(`span`,{className:`squisq-teleprompter-group`,style:{marginLeft:`auto`},children:t.isOpen?(0,K.jsx)(`button`,{type:`button`,onClick:t.close,children:`⇤ Bring back`}):(0,K.jsxs)(K.Fragment,{children:[t.supportedTiers.length>1?(0,K.jsx)(`select`,{"aria-label":`Float mode`,"data-testid":`teleprompter-float-tier`,defaultValue:t.supportedTiers[0],id:`squisq-prompter-float-tier`,children:t.supportedTiers.map(e=>(0,K.jsx)(`option`,{value:e,children:Ko[e]},e))}):null,(0,K.jsx)(`button`,{type:`button`,onClick:()=>{let e=document.getElementById(`squisq-prompter-float-tier`)?.value??void 0;t.open(e)},title:`Pop the prompter out so it can sit next to your camera`,children:`⇱ Pop out`})]})}):null]})}function Jo({stream:e}){let t=(0,G.useRef)(null);return Va(t,e),e?(0,K.jsx)(`video`,{ref:t,className:`squisq-teleprompter-selfview`,muted:!0,playsInline:!0,autoPlay:!0,"data-testid":`teleprompter-selfview`}):null}var Yo=null;function Xo(e,t){for(let n=t;n>=0;n--)if(e[n].spoken)return n;for(let n=t+1;n<e.length;n++)if(e[n].spoken)return n;return t}function Zo(e,t,n,r){let i=`${t.tokens.length}:${t.sourceText.length}:${n}:${r}`;if(Yo&&Yo.key===i)return Yo;let a=e.measureText(` `).width,o=Array(t.tokens.length),s=[],c=[],l=0;for(let n=0;n<t.tokens.length;n++){let i=t.tokens[n],u=e.measureText(i.text).width,d=n===0||t.tokens[n-1].blockIndex!==i.blockIndex,f=n>0&&t.tokens[n-1].pauseAfter>=2;c.length>0&&(l+u>r||d||f)&&(s.push(c),c=[],l=0),o[n]=s.length,c.push(n),l+=u+a}return c.length>0&&s.push(c),Yo={key:i,tokenLine:o,lines:s},Yo}function Qo(e,t){let n=e.getContext(`2d`);if(!n)return;let{width:r,height:i}=e,a=Math.round(t.fontSizePx*.72),o=Math.round(a*1.4),s=Math.round(r*.06);n.save(),n.fillStyle=t.colors.bg,n.fillRect(0,0,r,i),t.mirrored&&(n.translate(r,0),n.scale(-1,1)),n.font=`500 ${a}px system-ui, sans-serif`,n.textBaseline=`top`;let c=Zo(n,t.script,a,r-s*2),l=t.script.tokens.length;if(l>0){let e=Math.min(Math.max(Math.floor(t.wordPos),0),l-1),r=Math.min(Math.max(t.wordPos-e,0),1),u=Xo(t.script.tokens,e),d=c.tokenLine[u]??0,f=i*.38,p=n.measureText(` `).width,m=(d+r)*o-f,h=Math.max(0,Math.floor(m/o)-1),g=Math.min(c.lines.length-1,Math.ceil((m+i)/o)+1);for(let e=h;e<=g;e++){let r=e*o-m,i=s;for(let o of c.lines[e]){let e=t.script.tokens[o];o===u?(n.fillStyle=t.colors.accent,n.font=`800 ${a}px system-ui, sans-serif`):(n.fillStyle=t.colors.text,n.font=`500 ${a}px system-ui, sans-serif`,n.globalAlpha=o<u?.9:.45),n.fillText(e.text,i,r),n.globalAlpha=1,i+=n.measureText(e.text).width+p}}n.fillStyle=t.colors.accent,n.beginPath(),n.moveTo(4,f+o*.2),n.lineTo(14,f+o*.5),n.lineTo(4,f+o*.8),n.closePath(),n.fill()}n.restore(),t.countdownRemaining!==null&&(n.save(),n.fillStyle=`${t.colors.bg}cc`,n.fillRect(0,0,r,i),n.fillStyle=t.colors.accent,n.font=`800 ${Math.round(i*.4)}px system-ui, sans-serif`,n.textAlign=`center`,n.textBaseline=`middle`,n.fillText(String(t.countdownRemaining),r/2,i/2),n.restore()),t.recording&&(n.save(),n.fillStyle=`#e5484d`,n.beginPath(),n.arc(r-20,20,8,0,Math.PI*2),n.fill(),n.restore())}function $o(e){let{stage:t,theme:n,presentationTarget:r=null,showSelfView:i=!0,showCameraToggleInRecordSlot:a=!0,showRecordSlot:o=!0,showTransportPlay:s=!0,showReviewActions:c=!0}=e,{controller:l,float:u,recorder:d,recording:f}=t,p=(0,G.useRef)(null),m=(0,G.useRef)(l);m.current=l;let h=(0,G.useCallback)(()=>{let e=m.current;e.transport===`rolling`||e.transport===`countdown`?e.pause():e.play()},[]);(0,G.useEffect)(()=>{let e=p.current?.ownerDocument;e&&vo(e)},[]),(0,G.useEffect)(()=>{r&&vo(r.ownerDocument)},[r]),(0,G.useEffect)(()=>{if(!l.script)return;let e=new Set,t=p.current?.ownerDocument;t&&e.add(t),u.portalTarget&&e.add(u.portalTarget.ownerDocument),r&&e.add(r.ownerDocument);let n=e=>{m.current.handleKeyDown(e)};for(let t of e)t.addEventListener(`keydown`,n);return()=>{for(let t of e)t.removeEventListener(`keydown`,n)}},[l.script,u.portalTarget,r]);let g=(0,G.useRef)(null);g.current=l.script?{script:l.script,fontSizePx:l.prefs.fontSizePx,mirrored:l.prefs.mirrored,colors:{bg:n.colors.background,text:n.colors.text,accent:n.colors.primary,muted:n.colors.textMuted??n.colors.text},countdownRemaining:l.countdownRemaining,recording:d.state===`recording`}:null,(0,G.useEffect)(()=>{let e=u.canvasSink;if(u.tier!==`video-pip`||!e)return;let t=t=>{let n=g.current;n&&(Qo(e.canvas,{...n,wordPos:t}),e.requestFrame())};t(m.current.wordPos);let n=m.current.subscribeTick(t),r=setInterval(()=>t(m.current.wordPos),200);return()=>{n(),clearInterval(r)}},[u.tier,u.canvasSink]);let _=(0,G.useMemo)(()=>({wordPos:l.wordPos,fontSizePx:l.prefs.fontSizePx,mirrored:l.prefs.mirrored,lineGuide:l.prefs.lineGuide,countdownRemaining:l.countdownRemaining,recordingIndicator:d.state===`recording`,theme:n,onSeekToken:l.seekToToken,onNudge:l.nudge,onToggleAutoAdvance:h}),[l.wordPos,l.prefs.fontSizePx,l.prefs.mirrored,l.prefs.lineGuide,l.countdownRemaining,l.seekToToken,l.nudge,h,d.state,n]);if(!l.script)return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{ref:p,className:`squisq-teleprompter-root`,"data-testid":`teleprompter-view`,children:(0,K.jsx)(`div`,{className:`squisq-teleprompter-float-note`,children:(0,K.jsx)(`p`,{children:`Nothing to narrate yet — add some content to the document.`})})}),r?(0,Wr.createPortal)((0,K.jsx)(`div`,{className:`squisq-presentation-teleprompter`,"aria-label":`Audience presentation`,children:(0,K.jsx)(`div`,{className:`squisq-teleprompter-float-note`,children:(0,K.jsx)(`p`,{children:`Nothing to narrate yet — add some content to the document.`})})}),r):null]});let v=l.script,y=u.portalTarget!==null,b=d.state===`recording`||d.state===`starting`,x=f&&o?(0,K.jsx)(`span`,{className:`squisq-teleprompter-group`,"data-testid":`teleprompter-record`,children:d.state===`idle`||d.state===`error`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>void d.start(),title:`Record narration while you read`,children:`⏺ Record`}),a?(0,K.jsxs)(`label`,{title:`Also capture your camera as a separate video file`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:d.withCamera,onChange:e=>d.setWithCamera(e.target.checked)}),`camera`]}):null,d.state===`error`?(0,K.jsxs)(`span`,{title:d.error?.message,children:[`⚠ `,d.error?.message]}):null]}):b?(0,K.jsx)(`button`,{type:`button`,onClick:()=>void d.stop(),children:`⏹ Stop`}):d.state===`processing`?(0,K.jsx)(`span`,{children:`Aligning take…`}):d.state===`saving`?(0,K.jsx)(`span`,{children:`Saving…`}):null}):null;return(0,K.jsxs)(`div`,{ref:p,className:`squisq-teleprompter-root`,"data-testid":`teleprompter-view`,children:[(0,K.jsxs)(`div`,{className:`squisq-teleprompter-stage`,children:[y?(0,K.jsxs)(`div`,{className:`squisq-teleprompter-float-note`,children:[(0,K.jsx)(`p`,{children:`The prompter is floating in its own window.`}),(0,K.jsx)(`button`,{type:`button`,onClick:u.close,children:`⇤ Bring it back`})]}):(0,K.jsx)(Go,{script:v,..._},`docked`),y&&u.portalTarget?(0,Wr.createPortal)((0,K.jsx)(Go,{script:v,..._,compact:!0},`float-${u.tier}`),u.portalTarget):null,r?(0,Wr.createPortal)((0,K.jsx)(`div`,{className:`squisq-presentation-teleprompter`,"aria-label":`Audience presentation`,children:(0,K.jsx)(Go,{script:v,..._},`presentation-audience`)}),r):null,i?(0,K.jsx)(Jo,{stream:d.cameraStream}):null]}),d.state===`review`&&d.take?(0,K.jsxs)(`div`,{className:`squisq-teleprompter-review`,"data-testid":`teleprompter-review`,children:[(0,K.jsxs)(`span`,{children:[`Take: `,d.take.durationSec.toFixed(1),`s`,d.take.alignment?` \xB7 ${d.take.alignment.detectedSyllables} syllables aligned`:` · timing unavailable (saved without re-timing)`]}),t.reviewAudioUrl?(0,K.jsx)(`audio`,{controls:!0,src:t.reviewAudioUrl,onTimeUpdate:t.handleReviewTimeUpdate}):null,c?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>void t.handleSave(),children:`✓ Save narration`}),(0,K.jsx)(`button`,{type:`button`,onClick:t.handleRetake,children:`↺ Retake`}),(0,K.jsx)(`button`,{type:`button`,onClick:t.handleDiscard,children:`✕ Discard`})]}):null,d.error?(0,K.jsxs)(`span`,{children:[`⚠ `,d.error.message]}):null]}):null,t.saveNotice?(0,K.jsxs)(`div`,{className:`squisq-teleprompter-review`,"data-testid":`teleprompter-save-notice`,children:[(0,K.jsx)(`span`,{children:t.saveNotice}),(0,K.jsx)(`button`,{type:`button`,onClick:t.dismissSaveNotice,children:`Dismiss`})]}):null,(0,K.jsx)(qo,{controller:l,float:u,recordSlot:x,showPlayPause:s})]})}function es(e){let t=e.map(e=>e.getAudioTracks()).flat().filter(e=>e.readyState===`live`);if(t.length===0)return null;let n=window.AudioContext;if(n===void 0)return null;let r=new n,i=r.createMediaStreamDestination();for(let e of t)r.createMediaStreamSource(new MediaStream([e])).connect(i);let[a]=i.stream.getAudioTracks();return a?{track:a,context:r}:null}async function ts(e){if(!Ia())throw Error(`navigator.mediaDevices.getDisplayMedia is not available in this environment.`);let t=e?.video??!0,n=e?.systemAudio??!1,r=e?.includeMicrophone??!1,i=await navigator.mediaDevices.getDisplayMedia({video:t,audio:n?e?.systemAudioConstraints??!0:!1});if(!r||!Fa())return{stream:i,dispose:()=>{}};let a=null;try{a=await navigator.mediaDevices.getUserMedia({audio:e?.microphoneConstraints??!0,video:!1})}catch(e){throw i.getTracks().forEach(e=>e.stop()),e}let o=es([i,a]);if(!o)return a.getTracks().forEach(e=>e.stop()),{stream:i,dispose:()=>{}};let[s]=i.getVideoTracks(),c=new MediaStream;s&&c.addTrack(s),c.addTrack(o.track);let l=i.getAudioTracks(),u=!1;return{stream:c,dispose:()=>{u||(u=!0,a?.getTracks().forEach(e=>e.stop()),a=null,l.forEach(e=>e.stop()),o.context.close().catch(()=>{}))}}}async function ns(e){if(!Ia())throw Error(`navigator.mediaDevices.getDisplayMedia is not available in this environment.`);let t=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:e??!0});t.getVideoTracks().forEach(e=>e.stop());let n=t.getAudioTracks();return n.length===0?null:new MediaStream(n)}function rs(e,t){let n=window.AudioContext;if(n===void 0)return console.warn(`[squisq-recorder] AudioContext unavailable — system audio could not be mixed into the recording.`),t.getTracks().forEach(e=>e.stop()),{stream:e,dispose:()=>{}};let r=new n,i=r.createMediaStreamDestination(),a=e.getAudioTracks(),o=[...a,...t.getAudioTracks()].filter(e=>e.readyState===`live`);for(let e of o)r.createMediaStreamSource(new MediaStream([e])).connect(i);let[s]=i.stream.getAudioTracks(),c=new MediaStream;e.getVideoTracks().forEach(e=>c.addTrack(e)),s?c.addTrack(s):a.forEach(e=>c.addTrack(e));let l=!1;return{stream:c,dispose:()=>{l||(l=!0,a.forEach(e=>e.stop()),t.getTracks().forEach(e=>e.stop()),r.close().catch(()=>{}))}}}async function is(e,t){switch(e){case`mic`:{let e=typeof t.audioConstraints==`object`?t.audioConstraints:void 0;if(t.systemAudio){let n=await ns(t.screenAudioConstraints),r;try{r=await za(e)}catch(e){throw n?.getTracks().forEach(e=>e.stop()),e}return n?rs(r,n):{stream:r,dispose:()=>{}}}return{stream:await za(e),dispose:()=>{}}}case`camera`:{let e=t.videoConstraints??!0,n=t.includeMicrophone===!1?!1:t.audioConstraints??!0;if(t.systemAudio){let r=await ns(t.screenAudioConstraints),i;try{i=await Ba({video:e,audio:n})}catch(e){throw r?.getTracks().forEach(e=>e.stop()),e}return r?rs(i,r):{stream:i,dispose:()=>{}}}return{stream:await Ba({video:e,audio:n}),dispose:()=>{}}}case`screen`:case`screen+mic`:{let n=await ts({video:t.screenVideoConstraints??t.videoConstraints??!0,systemAudio:t.systemAudio??!1,systemAudioConstraints:t.screenAudioConstraints,includeMicrophone:e===`screen+mic`,microphoneConstraints:typeof t.audioConstraints==`object`?t.audioConstraints:void 0});return{stream:n.stream,dispose:n.dispose}}}}async function as(e,t){let n=await ts({video:e.screenVideoConstraints??e.videoConstraints??!0,systemAudio:e.systemAudio??!1,systemAudioConstraints:e.screenAudioConstraints,includeMicrophone:!1}),r=()=>{n.stream.getTracks().forEach(e=>e.stop()),n.dispose()};if(t())return r(),null;let i;try{i=await Ba({video:e.videoConstraints??!0,audio:e.includeMicrophone===!1?!1:e.audioConstraints??!0})}catch(e){throw r(),e}return t()?(r(),i.getTracks().forEach(e=>e.stop()),null):{screen:n,camera:i}}function os(e){return e===`mic`?`audio`:`video`}function ss(e={}){let[t,n]=(0,G.useState)(`idle`),[r,i]=(0,G.useState)(null),[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(0),[d,f]=(0,G.useState)(null),[p,m]=(0,G.useState)(null),[h,g]=(0,G.useState)(null),_=(0,G.useRef)(null),v=(0,G.useRef)([]),y=(0,G.useRef)(null),b=(0,G.useRef)(null),x=(0,G.useRef)(null),S=(0,G.useRef)([]),C=(0,G.useRef)(null),w=(0,G.useRef)(null),T=(0,G.useRef)(0),E=(0,G.useRef)(null),D=(0,G.useRef)(0),O=(0,G.useRef)(null),k=(0,G.useRef)(null),A=(0,G.useRef)(`idle`),j=(0,G.useRef)(null),M=(0,G.useRef)(null),N=(0,G.useCallback)(e=>{A.current=e,n(e)},[]),P=(0,G.useRef)(e);P.current=e;let F=(0,G.useCallback)(()=>{x.current!==null&&(clearInterval(x.current),x.current=null)},[]),I=(0,G.useCallback)(()=>{_.current?.stream.getTracks().forEach(e=>e.stop()),E.current?.stream.getTracks().forEach(e=>e.stop()),y.current?.(),y.current=null},[]),L=(0,G.useCallback)(()=>{let e=_.current?.stream;e&&e.getTracks().forEach(e=>e.stop()),i(e=>(e?.getTracks().forEach(e=>e.stop()),null)),y.current?.(),y.current=null},[]),ee=(0,G.useCallback)(()=>{let e=E.current;if(E.current=null,e){if(e.recorder.state!==`inactive`)try{e.recorder.ondataavailable=null,e.recorder.onstart=null,e.recorder.onstop=null,e.recorder.onerror=null,e.recorder.stop()}catch{}e.stream.getTracks().forEach(e=>e.stop())}D.current=0,O.current=null,k.current=null,m(null),g(null)},[]),te=(0,G.useCallback)(()=>{o(null),u(0),f(null),v.current=[],b.current=null,F(),m(e=>e?{...e,blob:null}:null),g(null);let e=_.current,t=!E.current||E.current.stream.active;e&&e.state===`inactive`&&e.stream.active&&t?N(`ready`):M.current?.()},[F,N]),R=(0,G.useCallback)(()=>{T.current+=1;let e=_.current;if(e&&e.state!==`inactive`)try{e.ondataavailable=null,e.onstart=null,e.onstop=null,e.onerror=null,e.stop()}catch{}_.current=null,L(),ee(),F(),v.current=[],b.current=null,S.current.splice(0).forEach(e=>e(null)),C.current=null,w.current=null,o(null),u(0),f(null),N(`idle`)},[F,L,ee,N]),ne=(0,G.useCallback)(async()=>{if(w.current)return w.current;if(_.current?.stream.active)return;if(!Pa()){let e=Error(`MediaRecorder is not supported in this environment.`);throw f(e),N(`error`),e}let e=++T.current,t=(async()=>{f(null),N(`requesting`);let t=null,n=null;try{let r=P.current.source??`mic`,a=Na(os(r),P.current.mimeType),s={};if(a.mimeType&&(s.mimeType=a.mimeType),P.current.bitsPerSecond&&(s.bitsPerSecond=P.current.bitsPerSecond),P.current.audioBitsPerSecond&&(s.audioBitsPerSecond=P.current.audioBitsPerSecond),P.current.videoBitsPerSecond&&(s.videoBitsPerSecond=P.current.videoBitsPerSecond),P.current.audioBitrateMode&&(s.audioBitrateMode=P.current.audioBitrateMode),P.current.videoKeyFrameIntervalDuration?s.videoKeyFrameIntervalDuration=P.current.videoKeyFrameIntervalDuration:P.current.videoKeyFrameIntervalCount&&(s.videoKeyFrameIntervalCount=P.current.videoKeyFrameIntervalCount),r===`screen+camera`){if(n=await as(P.current,()=>e!==T.current),!n)return;let{screen:t,camera:r}=n,l=new MediaRecorder(t.stream,s),d=new MediaRecorder(r,s),p=()=>{let e=l.mimeType||a.mimeType||`application/octet-stream`,t=new Blob(v.current,{type:e});v.current=[],o(t);let n=E.current;if(n){let e=n.recorder.mimeType||a.mimeType||`application/octet-stream`,t=new Blob(n.chunks,{type:e});n.chunks=[],m({stream:n.stream,blob:t,mimeType:a.mimeType||null,extension:a.extension})}let r=O.current,i=k.current;g(r!=null&&i!=null?(i-r)/1e3:null),I(),N(`stopped`),F(),S.current.splice(0).forEach(e=>e(t)),C.current=null},h=t=>{e===T.current&&(_.current!==t&&E.current?.recorder!==t||D.current!==0&&(--D.current,!(D.current>0)&&p()))},b=(t,n)=>{if(e!==T.current)return;let r=_.current===t,i=E.current?.recorder===t;if(!r&&!i)return;let a=r?E.current?.recorder:l;if(a&&a.state!==`inactive`)try{a.ondataavailable=null,a.onstart=null,a.onstop=null,a.onerror=null,a.stop()}catch{}let o=n.error,s=o instanceof Error?o:Error(`Recorder error`);f(s),I(),N(`error`),F(),D.current=0,S.current.splice(0).forEach(e=>e(null)),C.current=null};l.ondataavailable=e=>{e.data&&e.data.size>0&&v.current.push(e.data)},l.onstart=()=>{O.current=performance.now()},l.onstop=()=>h(l),l.onerror=e=>b(l,e),d.ondataavailable=e=>{e.data&&e.data.size>0&&E.current?.chunks.push(e.data)},d.onstart=()=>{k.current=performance.now()},d.onstop=()=>h(d),d.onerror=e=>b(d,e),_.current=l,y.current=t.dispose,E.current={recorder:d,chunks:[],stream:r,format:a};let[x]=t.stream.getVideoTracks();x&&(x.onended=()=>{e===T.current&&(A.current===`recording`?j.current?.():A.current===`ready`&&M.current?.())}),i(t.stream),m({stream:r,blob:null,mimeType:a.mimeType||null,extension:a.extension}),c(a),o(null),u(0),g(null),N(`ready`),n=null;return}t=await is(r,P.current);let{stream:l,dispose:d}=t;if(e!==T.current){l.getTracks().forEach(e=>e.stop()),d();return}let p=new MediaRecorder(l,s);p.ondataavailable=e=>{e.data&&e.data.size>0&&v.current.push(e.data)},p.onstop=()=>{if(_.current!==p||e!==T.current||D.current===0||(--D.current,D.current>0))return;let t=p.mimeType||a.mimeType||`application/octet-stream`,n=new Blob(v.current,{type:t});v.current=[],o(n),I(),N(`stopped`),F(),S.current.splice(0).forEach(e=>e(n)),C.current=null},p.onerror=t=>{if(_.current!==p||e!==T.current)return;let n=t.error,r=n instanceof Error?n:Error(`Recorder error`);f(r),I(),N(`error`),F(),D.current=0,S.current.splice(0).forEach(e=>e(null)),C.current=null},_.current=p,y.current=d,i(l),c(a),o(null),u(0),N(`ready`),t=null}catch(r){t&&(t.stream.getTracks().forEach(e=>e.stop()),t.dispose()),n&&(n.screen.stream.getTracks().forEach(e=>e.stop()),n.screen.dispose(),n.camera.getTracks().forEach(e=>e.stop()));let i=r instanceof Error?r:Error(`Stream acquisition failed`);throw e===T.current&&(f(i),N(`error`)),i}finally{e===T.current&&(w.current=null)}})();return w.current=t,t},[F,I,N]),re=(0,G.useCallback)(()=>{let e=_.current;if(!e){f(Error(`Recorder is not ready. Call request() first.`)),N(`error`);return}if(e.state===`recording`)return;v.current=[],E.current&&(E.current.chunks=[]),o(null),u(0),m(e=>e?{...e,blob:null}:null),g(null),O.current=null,k.current=null,b.current=Date.now();try{e.start(1e3)}catch(e){f(e instanceof Error?e:Error(`Failed to start recorder`)),I(),N(`error`);return}let t=E.current;if(t)try{t.recorder.start(1e3)}catch(t){try{e.stop()}catch{}f(t instanceof Error?t:Error(`Failed to start camera recorder`)),I(),N(`error`);return}N(`recording`),F(),x.current=setInterval(()=>{b.current!==null&&u(Date.now()-b.current)},100)},[F,I,N]),z=(0,G.useCallback)(()=>{if(A.current!==`recording`)return null;let e=b.current;return e===null?null:Math.max(0,Date.now()-e)},[]),ie=(0,G.useCallback)(()=>{if(C.current)return C.current;let e=_.current;if(!e||e.state===`inactive`)return Promise.resolve(a);N(`stopping`);let t=E.current,n=t!=null&&t.recorder.state!==`inactive`;D.current=n?2:1;let r=new Promise(r=>{S.current.push(r);try{e.stop()}catch(e){let t=e instanceof Error?e:Error(`Failed to stop recorder`);f(t),I(),N(`error`),F(),D.current=0,S.current.splice(0).forEach(e=>e(null));return}if(n)try{t.recorder.stop()}catch{D.current=Math.max(0,D.current-1)}});return C.current=r,r.finally(()=>{C.current===r&&(C.current=null)}),r},[a,F,I,N]);return(0,G.useEffect)(()=>{j.current=ie,M.current=R}),(0,G.useEffect)(()=>{let e=S.current;return()=>{T.current+=1,w.current=null;let t=_.current;if(t&&t.state!==`inactive`)try{t.ondataavailable=null,t.onstart=null,t.onstop=null,t.onerror=null,t.stop()}catch{}L(),ee(),F(),e.splice(0).forEach(e=>e(null)),C.current=null}},[L,ee,F]),{state:t,stream:r,blob:a,mimeType:s?.mimeType??null,extension:s?.extension??null,directory:s?.directory??null,durationMs:l,getElapsedMs:z,error:d,camera:p,cameraOffsetSec:h,request:ne,start:re,stop:ie,cancel:R,reset:te}}var cs=new Set([`default`,`communications`]);function ls(e,t,n,r=``){let i=[];for(let a of e)a.kind===t&&(!(r!==``&&a.deviceId===r)&&(!a.deviceId||cs.has(a.deviceId))||i.push({deviceId:a.deviceId,label:a.label||`${n} ${i.length+1}`,groupId:a.groupId||``}));return i}function us(e){return e.length>1}function ds(e){let t=new Map;for(let[n,r]of e.entries())!r.groupId||t.has(r.groupId)||t.set(r.groupId,r.label||`Device group ${n+1}`);return[...t].map(([e,t])=>({id:e,label:t}))}function fs(){let[e,t]=(0,G.useState)([]),[n,r]=(0,G.useState)(null),i=(0,G.useCallback)(()=>{let e=typeof navigator>`u`?void 0:navigator.mediaDevices;e&&(typeof e.getSupportedConstraints==`function`&&r(e.getSupportedConstraints()),typeof e.enumerateDevices==`function`&&e.enumerateDevices().then(t).catch(()=>{}))},[]);return(0,G.useEffect)(()=>{i();let e=typeof navigator>`u`?void 0:navigator.mediaDevices;if(!e?.addEventListener)return;let t=()=>i();return e.addEventListener(`devicechange`,t),()=>e.removeEventListener(`devicechange`,t)},[i]),{devices:e,supported:n,refresh:i}}var ps={border:`1px solid var(--squisq-recorder-border)`,marginBottom:12},ms={cursor:`pointer`,padding:`8px 10px`,fontSize:13,fontWeight:600,color:`var(--squisq-recorder-text)`,background:`var(--squisq-recorder-surface-muted)`},hs={padding:`4px 10px 10px`},gs={border:0,borderTop:`1px solid var(--squisq-recorder-border)`,margin:`10px 0 0`,padding:`10px 0 0`},_s={padding:`0 6px 0 0`,fontSize:12,fontWeight:700,color:`var(--squisq-recorder-text)`},vs={display:`grid`,gridTemplateColumns:`repeat(2, minmax(0, 1fr))`,gap:`8px 10px`},ys={display:`flex`,flexDirection:`column`,gap:3,minWidth:0,fontSize:12,color:`var(--squisq-recorder-muted)`},bs={width:`100%`,minWidth:0,boxSizing:`border-box`,padding:`5px 6px`,font:`inherit`,color:`var(--squisq-recorder-text)`,background:`var(--squisq-recorder-input)`,border:`1px solid var(--squisq-recorder-border)`},xs={margin:`8px 0 0`,fontSize:11,lineHeight:1.4,color:`var(--squisq-recorder-muted)`},Ss={margin:`6px 0 0`,padding:6,overflowX:`auto`,fontSize:10,lineHeight:1.35,color:`var(--squisq-recorder-muted)`,background:`var(--squisq-recorder-surface-muted)`},Cs=[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/ogg;codecs=opus`],ws=[`video/webm;codecs=vp9,opus`,`video/webm;codecs=vp8,opus`,`video/webm`,`video/mp4`];function Ts(e){if(e.trim()===``)return;let t=Number(e);return Number.isFinite(t)&&t>0?t:void 0}function Es(e){return e===void 0?`default`:e?`true`:`false`}function Ds(e){return e==="default"?void 0:e===`true`}function Os(e){if(!e||typeof e.getSettings!=`function`)return null;try{return e.getSettings()}catch{return null}}function ks({label:e,value:t,onChange:n,disabled:r,min:i,step:a}){return(0,K.jsxs)(`label`,{style:ys,children:[e,(0,K.jsx)(`input`,{type:`number`,min:i??0,step:a??1,value:t??``,disabled:r,style:bs,onChange:e=>n(Ts(e.target.value))})]})}function As({label:e,value:t,onChange:n,disabled:r}){return(0,K.jsxs)(`label`,{style:ys,children:[e,(0,K.jsxs)(`select`,{value:Es(t),disabled:r,style:bs,onChange:e=>n(Ds(e.target.value)),children:[(0,K.jsx)(`option`,{value:`default`,children:`Browser default`}),(0,K.jsx)(`option`,{value:`true`,children:`On`}),(0,K.jsx)(`option`,{value:`false`,children:`Off`})]})]})}function js({value:e,onChange:t,disabled:n=!1,microphoneEnabled:r,cameraEnabled:i,screenEnabled:a,systemAudioEnabled:o=!1,separateAudioRecorder:s=!1,primaryStream:c=null,cameraStream:l=null}){let u=(0,G.useId)(),d=(0,G.useId)(),{devices:f,supported:p,refresh:m}=fs();(0,G.useEffect)(()=>{(c||l)&&m()},[l,c,m]);let h=e=>p===null||p[e]===!0,g=r||o,_=s||r&&!i&&!a,v=ls(f,`audioinput`,`Microphone`,e.audio.deviceId),y=ls(f,`videoinput`,`Camera`,e.camera.deviceId),b=ds(v),x=ds(y),S=n=>t({...e,audio:{...e.audio,...n}}),C=n=>t({...e,camera:{...e.camera,...n}}),w=n=>t({...e,screen:{...e.screen,...n}}),T=n=>t({...e,screenAudio:{...e.screenAudio,...n}}),E=n=>t({...e,encoding:{...e.encoding,...n}}),D=Os(c?.getAudioTracks()[0]),O=Os(c?.getVideoTracks()[0]),k=Os(l?.getVideoTracks()[0]),A={...D?{audio:D}:{},...O?{[a?`screen`:`camera`]:O}:{},...k?{camera:k}:{}};return(0,K.jsxs)(`details`,{style:ps,"data-testid":`recorder-device-settings`,children:[(0,K.jsx)(`summary`,{style:ms,children:`Advanced device settings`}),(0,K.jsxs)(`div`,{style:hs,children:[(0,K.jsxs)(`label`,{style:ys,children:[`Constraint strength`,(0,K.jsxs)(`select`,{value:e.constraintMode,disabled:n,style:bs,onChange:n=>t({...e,constraintMode:n.target.value===`exact`?`exact`:`ideal`}),children:[(0,K.jsx)(`option`,{value:`ideal`,children:`Preferred (use closest available)`}),(0,K.jsx)(`option`,{value:`exact`,children:`Required (fail when unavailable)`})]})]}),r&&(0,K.jsxs)(`fieldset`,{style:gs,disabled:n,children:[(0,K.jsx)(`legend`,{style:_s,children:`Microphone`}),(0,K.jsxs)(`div`,{style:vs,children:[(0,K.jsxs)(`label`,{style:{...ys,gridColumn:`1 / -1`},children:[`Input device`,(0,K.jsxs)(`select`,{"aria-label":`Recording microphone`,value:e.audio.deviceId,style:bs,onChange:e=>S({deviceId:e.target.value}),children:[(0,K.jsx)(`option`,{value:``,children:`System default`}),v.map(e=>(0,K.jsx)(`option`,{value:e.deviceId,children:e.label},e.deviceId))]})]}),h(`groupId`)&&b.length>0&&(0,K.jsxs)(`label`,{style:{...ys,gridColumn:`1 / -1`},children:[`Device group`,(0,K.jsxs)(`select`,{value:e.audio.groupId??``,style:bs,onChange:e=>S({groupId:e.target.value||void 0}),children:[(0,K.jsx)(`option`,{value:``,children:`Any group`}),b.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]}),h(`sampleRate`)&&(0,K.jsx)(ks,{label:`Sample rate (Hz)`,value:e.audio.sampleRate,onChange:e=>S({sampleRate:e}),disabled:n}),h(`sampleSize`)&&(0,K.jsx)(ks,{label:`Sample size (bits)`,value:e.audio.sampleSize,onChange:e=>S({sampleSize:e}),disabled:n}),h(`channelCount`)&&(0,K.jsx)(ks,{label:`Channel count`,value:e.audio.channelCount,onChange:e=>S({channelCount:e}),disabled:n}),h(`latency`)&&(0,K.jsx)(ks,{label:`Latency (seconds)`,value:e.audio.latency,onChange:e=>S({latency:e}),disabled:n,step:.001}),h(`echoCancellation`)&&(0,K.jsx)(As,{label:`Echo cancellation`,value:e.audio.echoCancellation,onChange:e=>S({echoCancellation:e}),disabled:n}),h(`noiseSuppression`)&&(0,K.jsx)(As,{label:`Noise suppression`,value:e.audio.noiseSuppression,onChange:e=>S({noiseSuppression:e}),disabled:n}),h(`autoGainControl`)&&(0,K.jsx)(As,{label:`Automatic gain control`,value:e.audio.autoGainControl,onChange:e=>S({autoGainControl:e}),disabled:n})]})]}),i&&(0,K.jsxs)(`fieldset`,{style:gs,disabled:n,children:[(0,K.jsx)(`legend`,{style:_s,children:`Camera`}),(0,K.jsxs)(`div`,{style:vs,children:[(0,K.jsxs)(`label`,{style:{...ys,gridColumn:`1 / -1`},children:[`Video input`,(0,K.jsxs)(`select`,{"aria-label":`Recording camera`,value:e.camera.deviceId,style:bs,onChange:e=>C({deviceId:e.target.value}),children:[(0,K.jsx)(`option`,{value:``,children:`System default`}),y.map(e=>(0,K.jsx)(`option`,{value:e.deviceId,children:e.label},e.deviceId))]})]}),h(`groupId`)&&x.length>0&&(0,K.jsxs)(`label`,{style:{...ys,gridColumn:`1 / -1`},children:[`Device group`,(0,K.jsxs)(`select`,{value:e.camera.groupId??``,style:bs,onChange:e=>C({groupId:e.target.value||void 0}),children:[(0,K.jsx)(`option`,{value:``,children:`Any group`}),x.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]}),h(`width`)&&(0,K.jsx)(ks,{label:`Width (px)`,value:e.camera.width,onChange:e=>C({width:e}),disabled:n}),h(`height`)&&(0,K.jsx)(ks,{label:`Height (px)`,value:e.camera.height,onChange:e=>C({height:e}),disabled:n}),h(`aspectRatio`)&&(0,K.jsx)(ks,{label:`Aspect ratio (width / height)`,value:e.camera.aspectRatio,onChange:e=>C({aspectRatio:e}),disabled:n,step:.01}),h(`frameRate`)&&(0,K.jsx)(ks,{label:`Frame rate (fps)`,value:e.camera.frameRate,onChange:e=>C({frameRate:e}),disabled:n,step:.01}),h(`facingMode`)&&(0,K.jsxs)(`label`,{style:ys,children:[`Facing mode`,(0,K.jsxs)(`select`,{value:e.camera.facingMode??``,disabled:n,style:bs,onChange:e=>C({facingMode:e.target.value||void 0}),children:[(0,K.jsx)(`option`,{value:``,children:`Browser default`}),(0,K.jsx)(`option`,{value:`user`,children:`User/front`}),(0,K.jsx)(`option`,{value:`environment`,children:`Environment/rear`}),(0,K.jsx)(`option`,{value:`left`,children:`Left`}),(0,K.jsx)(`option`,{value:`right`,children:`Right`})]})]}),h(`resizeMode`)&&(0,K.jsxs)(`label`,{style:ys,children:[`Resize mode`,(0,K.jsxs)(`select`,{value:e.camera.resizeMode??``,disabled:n,style:bs,onChange:e=>C({resizeMode:e.target.value||void 0}),children:[(0,K.jsx)(`option`,{value:``,children:`Browser default`}),(0,K.jsx)(`option`,{value:`none`,children:`None`}),(0,K.jsx)(`option`,{value:`crop-and-scale`,children:`Crop and scale`})]})]}),h(`backgroundBlur`)&&(0,K.jsx)(As,{label:`Background blur`,value:e.camera.backgroundBlur,onChange:e=>C({backgroundBlur:e}),disabled:n})]})]}),(a||o)&&(0,K.jsxs)(`fieldset`,{style:gs,disabled:n,children:[(0,K.jsx)(`legend`,{style:_s,children:a?`Screen capture`:`System audio capture`}),(0,K.jsxs)(`div`,{style:vs,children:[a&&(0,K.jsxs)(K.Fragment,{children:[h(`displaySurface`)&&(0,K.jsxs)(`label`,{style:{...ys,gridColumn:`1 / -1`},children:[`Preferred surface`,(0,K.jsxs)(`select`,{value:e.screen.displaySurface??``,disabled:n,style:bs,onChange:e=>w({displaySurface:e.target.value||void 0}),children:[(0,K.jsx)(`option`,{value:``,children:`Browser picker default`}),(0,K.jsx)(`option`,{value:`monitor`,children:`Entire monitor`}),(0,K.jsx)(`option`,{value:`window`,children:`Application window`}),(0,K.jsx)(`option`,{value:`browser`,children:`Browser tab`})]})]}),h(`cursor`)&&(0,K.jsxs)(`label`,{style:ys,children:[`Mouse cursor`,(0,K.jsxs)(`select`,{value:e.screen.cursor??``,disabled:n,style:bs,onChange:e=>w({cursor:e.target.value||void 0}),children:[(0,K.jsx)(`option`,{value:``,children:`Browser default`}),(0,K.jsx)(`option`,{value:`always`,children:`Always`}),(0,K.jsx)(`option`,{value:`motion`,children:`While moving`}),(0,K.jsx)(`option`,{value:`never`,children:`Never`})]})]}),h(`logicalSurface`)&&(0,K.jsx)(As,{label:`Logical surface`,value:e.screen.logicalSurface,onChange:e=>w({logicalSurface:e}),disabled:n}),h(`resizeMode`)&&(0,K.jsxs)(`label`,{style:ys,children:[`Resize mode`,(0,K.jsxs)(`select`,{value:e.screen.resizeMode??``,disabled:n,style:bs,onChange:e=>w({resizeMode:e.target.value||void 0}),children:[(0,K.jsx)(`option`,{value:``,children:`Browser default`}),(0,K.jsx)(`option`,{value:`none`,children:`Full detail`}),(0,K.jsx)(`option`,{value:`crop-and-scale`,children:`Downscale`})]})]}),h(`width`)&&(0,K.jsx)(ks,{label:`Width (px)`,value:e.screen.width,onChange:e=>w({width:e}),disabled:n}),h(`height`)&&(0,K.jsx)(ks,{label:`Height (px)`,value:e.screen.height,onChange:e=>w({height:e}),disabled:n}),h(`aspectRatio`)&&(0,K.jsx)(ks,{label:`Aspect ratio (width / height)`,value:e.screen.aspectRatio,onChange:e=>w({aspectRatio:e}),disabled:n,step:.01}),h(`frameRate`)&&(0,K.jsx)(ks,{label:`Frame rate (fps)`,value:e.screen.frameRate,onChange:e=>w({frameRate:e}),disabled:n,step:.01})]}),o&&h(`restrictOwnAudio`)&&(0,K.jsx)(As,{label:`Remove this tab's audio`,value:e.screenAudio.restrictOwnAudio,onChange:e=>T({restrictOwnAudio:e}),disabled:n}),o&&h(`suppressLocalAudioPlayback`)&&(0,K.jsx)(As,{label:`Mute captured tab locally`,value:e.screenAudio.suppressLocalAudioPlayback,onChange:e=>T({suppressLocalAudioPlayback:e}),disabled:n})]}),(0,K.jsx)(`p`,{style:xs,children:`The browser still shows its own surface picker and may limit which display constraints it honors.`})]}),(0,K.jsxs)(`fieldset`,{style:gs,disabled:n,children:[(0,K.jsx)(`legend`,{style:_s,children:`Encoding`}),(0,K.jsxs)(`div`,{style:vs,children:[_&&(0,K.jsxs)(`label`,{style:{...ys,gridColumn:`1 / -1`},children:[`Audio MIME type / codecs`,(0,K.jsx)(`input`,{type:`text`,list:u,value:e.encoding.audioMimeType,style:bs,placeholder:`Automatic`,onChange:e=>E({audioMimeType:e.target.value})}),(0,K.jsx)(`datalist`,{id:u,children:Cs.map(e=>(0,K.jsx)(`option`,{value:e},e))})]}),g&&(0,K.jsx)(K.Fragment,{children:(0,K.jsx)(ks,{label:`Audio bitrate (kbps)`,value:e.encoding.audioBitsPerSecond,onChange:e=>E({audioBitsPerSecond:e}),disabled:n})}),(i||a)&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`label`,{style:{...ys,gridColumn:`1 / -1`},children:[`Video MIME type / codecs`,(0,K.jsx)(`input`,{type:`text`,list:d,value:e.encoding.videoMimeType,style:bs,placeholder:`Automatic`,onChange:e=>E({videoMimeType:e.target.value})}),(0,K.jsx)(`datalist`,{id:d,children:ws.map(e=>(0,K.jsx)(`option`,{value:e},e))})]}),(0,K.jsx)(ks,{label:`Video bitrate (kbps)`,value:e.encoding.videoBitsPerSecond,onChange:e=>E({videoBitsPerSecond:e}),disabled:n})]}),(0,K.jsx)(ks,{label:`Total bitrate (kbps)`,value:e.encoding.bitsPerSecond,onChange:e=>E({bitsPerSecond:e}),disabled:n}),g&&(0,K.jsxs)(`label`,{style:ys,children:[`Audio bitrate mode`,(0,K.jsxs)(`select`,{value:e.encoding.audioBitrateMode??``,disabled:n,style:bs,onChange:e=>E({audioBitrateMode:e.target.value===`constant`||e.target.value===`variable`?e.target.value:void 0}),children:[(0,K.jsx)(`option`,{value:``,children:`Browser default`}),(0,K.jsx)(`option`,{value:`variable`,children:`Variable`}),(0,K.jsx)(`option`,{value:`constant`,children:`Constant`})]})]}),(i||a)&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ks,{label:`Keyframe interval (ms)`,value:e.encoding.videoKeyFrameIntervalDuration,onChange:e=>E({videoKeyFrameIntervalDuration:e,videoKeyFrameIntervalCount:void 0}),disabled:n}),(0,K.jsx)(ks,{label:`Keyframe interval (frames)`,value:e.encoding.videoKeyFrameIntervalCount,onChange:e=>E({videoKeyFrameIntervalCount:e,videoKeyFrameIntervalDuration:void 0}),disabled:n})]})]}),(0,K.jsx)(`p`,{style:xs,children:`MIME and bitrate values are hints. Unsupported MIME choices fall back to the recorder's automatic format selection. A total bitrate overrides separate audio/video bitrate hints.`})]}),Object.keys(A).length>0&&(0,K.jsxs)(`fieldset`,{style:gs,children:[(0,K.jsx)(`legend`,{style:_s,children:`Active track settings`}),(0,K.jsx)(`pre`,{style:Ss,children:JSON.stringify(A,null,2)})]}),(0,K.jsx)(`p`,{style:xs,children:`Only constraints advertised by this browser are shown. Device names may appear only after microphone or camera permission is granted.`})]})]})}var Ms={display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(190px, 1fr))`,gap:`8px 10px`,marginBottom:12},Ns={display:`flex`,flexDirection:`column`,gap:3,minWidth:0,fontSize:12,color:`var(--squisq-recorder-muted)`},Ps={width:`100%`,minWidth:0,boxSizing:`border-box`,padding:`5px 6px`,font:`inherit`,color:`var(--squisq-recorder-text)`,background:`var(--squisq-recorder-input)`,border:`1px solid var(--squisq-recorder-border)`};function Fs({label:e,testId:t,options:n,value:r,onChange:i,disabled:a}){return(0,K.jsxs)(`label`,{style:Ns,children:[e,(0,K.jsxs)(`select`,{"data-testid":t,value:r,disabled:a,style:Ps,onChange:e=>i(e.target.value),children:[(0,K.jsx)(`option`,{value:``,children:`System default`}),n.map(e=>(0,K.jsx)(`option`,{value:e.deviceId,children:e.label},e.deviceId))]})]})}function Is({devices:e,microphoneEnabled:t,cameraEnabled:n,audioDeviceId:r,cameraDeviceId:i,onAudioDeviceChange:a,onCameraDeviceChange:o,disabled:s=!1}){let c=ls(e,`audioinput`,`Microphone`,r),l=ls(e,`videoinput`,`Camera`,i),u=t&&us(c),d=n&&us(l);return!u&&!d?null:(0,K.jsxs)(`div`,{style:Ms,"data-testid":`recorder-device-quick-picks`,children:[u&&(0,K.jsx)(Fs,{label:`Microphone`,testId:`recorder-quick-pick-microphone`,options:c,value:r,onChange:a,disabled:s}),d&&(0,K.jsx)(Fs,{label:`Camera`,testId:`recorder-quick-pick-camera`,options:l,value:i,onChange:o,disabled:s})]})}var Ls={constraintMode:`ideal`,audio:{deviceId:``},camera:{deviceId:``},screen:{},screenAudio:{},encoding:{audioMimeType:``,videoMimeType:``}};function Rs(e,t){if(!(e===void 0||!Number.isFinite(e)||e<=0))return{[t]:e}}function zs(e,t){if(!(e===void 0||!Number.isFinite(e)||e<=0))return{[t]:Math.round(e)}}function Bs(e,t){let n=e?.trim();return n?{[t]:n}:void 0}function Vs(e){let{audio:t,constraintMode:n}=e,r={};t.deviceId&&(r.deviceId={exact:t.deviceId});let i=Bs(t.groupId,n);i&&(r.groupId=i),t.autoGainControl!==void 0&&(r.autoGainControl=t.autoGainControl),t.echoCancellation!==void 0&&(r.echoCancellation=t.echoCancellation),t.noiseSuppression!==void 0&&(r.noiseSuppression=t.noiseSuppression);let a=zs(t.channelCount,n),o=Rs(t.latency,n),s=zs(t.sampleRate,n),c=zs(t.sampleSize,n);return a&&(r.channelCount=a),o&&(r.latency=o),s&&(r.sampleRate=s),c&&(r.sampleSize=c),r}function Hs(e){let{camera:t,constraintMode:n}=e,r={};t.deviceId&&(r.deviceId={exact:t.deviceId});let i=Bs(t.groupId,n);i&&(r.groupId=i),t.backgroundBlur!==void 0&&(r.backgroundBlur=t.backgroundBlur);let a=Rs(t.aspectRatio,n),o=Bs(t.facingMode,n),s=Rs(t.frameRate,n),c=zs(t.height,n),l=Bs(t.resizeMode,n),u=zs(t.width,n);return a&&(r.aspectRatio=a),o&&(r.facingMode=o),s&&(r.frameRate=s),c&&(r.height=c),l&&(r.resizeMode=l),u&&(r.width=u),r}function Us(e){let{screen:t}=e,n={},r=Rs(t.aspectRatio,`ideal`),i=Bs(t.cursor,`ideal`),a=Bs(t.displaySurface,`ideal`),o=Rs(t.frameRate,`ideal`),s=zs(t.height,`ideal`),c=Bs(t.resizeMode,`ideal`),l=zs(t.width,`ideal`);return t.logicalSurface!==void 0&&(n.logicalSurface=t.logicalSurface),r&&(n.aspectRatio=r),i&&(n.cursor=i),a&&(n.displaySurface=a),o&&(n.frameRate=o),s&&(n.height=s),c&&(n.resizeMode=c),l&&(n.width=l),n}function Ws(e){let t={};return e.screenAudio.restrictOwnAudio!==void 0&&(t.restrictOwnAudio=e.screenAudio.restrictOwnAudio),e.screenAudio.suppressLocalAudioPlayback!==void 0&&(t.suppressLocalAudioPlayback=e.screenAudio.suppressLocalAudioPlayback),t}function Gs(e){if(!(e===void 0||!Number.isFinite(e)||e<=0))return Math.round(e*1e3)}function Ks(e,t,n){return t?t.getVideoTracks().length>0?`video`:`audio`:n?.toLowerCase().startsWith(`audio/`)||e===`mic`?`audio`:`video`}function qs(e){return e!==`none`}function Js(e,t,n){return n?t:e===t?`none`:e}function Ys(e,t){return t<=0||!Number.isFinite(e)?0:Math.min(t-1,Math.max(0,Math.floor(e)))}function Xs(e){switch(e){case`ArrowRight`:case`ArrowDown`:case`PageDown`:case` `:case`Spacebar`:return 1;case`ArrowLeft`:case`ArrowUp`:case`PageUp`:return-1;default:return 0}}function Zs(e){return e.slidesOn&&e.captureTimings&&e.recorderState===`stopped`&&e.hasBlob}function Qs(e,t){return t<=0||e<=0?null:`${t} of ${e} ${t===1?`slide was`:`slides were`} never shown \u2014 they'll be skipped during playback.`}function $s(e,t,n,r){try{let i=le({...e,blocks:[t]}).blocks[0];if(!i)return null;let{layers:a}=Ce(i,{blockIndex:0,totalBlocks:1,theme:n,viewport:r,customTemplates:e.customTemplates});return{...i,layers:a}}catch{return null}}function ec(e,t,n){let r=Oe(e.blocks);if(r.length===0)return[];let i;try{let t=le(e,{interleaveImages:!1});i=new Map(t.blocks.map(e=>[e.id,e]))}catch{i=new Map}return r.map((a,o)=>{let s=a.title?.trim()||`Slide ${o+1}`,c=``;try{c=_e(a)}catch{c=``}return{blockId:a.id,heading:s,bodyText:c,visual:tc(e,a,i.get(a.id),t,n,o,r.length)}})}function tc(e,t,n,r,i,a,o){if(n)try{let{layers:t}=Ce(n,{blockIndex:a,totalBlocks:o,theme:r,viewport:i,customTemplates:e.customTemplates});return{...n,layers:t}}catch{}return $s(e,t,r,i)}var nc=(0,G.memo)(function({visual:e,viewport:t=Ge.landscape,basePath:n=`/`,mediaProvider:r=null}){return(0,K.jsx)(pn.Provider,{value:r,children:(0,K.jsx)(sn,{block:e,blockTime:0,basePath:n,viewport:t})})}),rc={flex:`1 1 auto`,minHeight:0,minWidth:0,display:`flex`,flexDirection:`column`,outline:`none`,color:`var(--squisq-recorder-text)`},ic={flex:`0 0 auto`,display:`flex`,alignItems:`center`,gap:12,padding:`8px 10px`,borderBottom:`1px solid var(--squisq-recorder-border)`},ac={fontSize:13,fontWeight:600,whiteSpace:`nowrap`},oc={flex:`1 1 auto`,minWidth:0,display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:3},sc={padding:`4px 10px`,fontSize:13,fontFamily:`inherit`,cursor:`pointer`,background:`var(--squisq-recorder-input)`,color:`var(--squisq-recorder-text)`,border:`1px solid var(--squisq-recorder-border)`,borderRadius:0},cc={flex:`1 1 auto`,minHeight:0,overflow:`hidden`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:8,background:`var(--squisq-recorder-surface-muted)`},lc={flex:`0 0 auto`,maxHeight:`32%`,minHeight:0,overflowY:`auto`,padding:`10px 12px`,borderTop:`1px solid var(--squisq-recorder-border)`,fontSize:14,lineHeight:1.5,whiteSpace:`pre-wrap`},uc={margin:0,fontSize:12,color:`var(--squisq-recorder-muted)`},dc={margin:`0 0 6px 0`,fontSize:13,fontWeight:600},fc=/^(BUTTON|INPUT|TEXTAREA|SELECT|A)$/;function pc({slides:e,index:t,onIndexChange:n,viewport:r,basePath:i=`/`,mediaProvider:a=null,recording:o=!1,shownBlockIds:s}){let c=e.length,l=e[Ys(t,c)],u=(0,G.useCallback)(e=>n(Ys(t+e,c)),[t,c,n]),d=(0,G.useCallback)(e=>{let t=Xs(e.key);if(t===0)return;let n=e.target;n!==e.currentTarget&&fc.test(n.tagName)||(e.preventDefault(),u(t))},[u]);return c===0||!l?(0,K.jsx)(`div`,{style:{...rc,alignItems:`center`,justifyContent:`center`,padding:24},children:(0,K.jsx)(`p`,{style:uc,children:`This document has no slides yet.`})}):(0,K.jsxs)(`div`,{style:rc,tabIndex:0,onKeyDown:d,"data-testid":`recorder-slides-panel`,"aria-label":`Slides`,children:[(0,K.jsxs)(`div`,{style:ic,children:[(0,K.jsxs)(`span`,{style:ac,role:`status`,children:[`Slide `,t+1,` of `,c]}),(0,K.jsx)(`span`,{style:oc,"aria-hidden":`true`,children:e.map((e,n)=>(0,K.jsx)(`span`,{style:{width:6,height:6,borderRadius:`50%`,background:n===t?`var(--squisq-recorder-accent)`:s?.has(e.blockId)?`var(--squisq-recorder-text)`:`var(--squisq-recorder-border)`}},e.blockId))}),(0,K.jsx)(`button`,{type:`button`,style:sc,onClick:()=>u(-1),disabled:t<=0,"aria-label":`Previous slide`,children:(0,K.jsx)(q,{icon:`fa-solid fa-chevron-left`})}),(0,K.jsx)(`button`,{type:`button`,style:sc,onClick:()=>u(1),disabled:t>=c-1,"aria-label":`Next slide`,children:(0,K.jsx)(q,{icon:`fa-solid fa-chevron-right`})})]}),(0,K.jsx)(`div`,{style:cc,children:(0,K.jsx)(`div`,{style:{width:`100%`,maxHeight:`100%`,aspectRatio:`${r.width} / ${r.height}`,overflow:`hidden`,background:`#000`},children:l.visual?(0,K.jsx)(nc,{visual:l.visual,viewport:r,basePath:i,mediaProvider:a}):(0,K.jsxs)(`div`,{style:{width:`100%`,height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:16,textAlign:`center`,background:`var(--squisq-recorder-input)`,color:`var(--squisq-recorder-muted)`,fontSize:13},children:[l.heading,` — no slide rendition`]})})}),(0,K.jsxs)(`div`,{style:lc,"data-testid":`recorder-slide-notes`,children:[(0,K.jsx)(`p`,{style:dc,children:l.heading}),l.bodyText?(0,K.jsx)(`div`,{children:l.bodyText}):(0,K.jsx)(`p`,{style:uc,children:`No additional narrative for this slide.`}),(0,K.jsx)(`p`,{style:{...uc,marginTop:8},children:o?`Recording — each slide is timed from when you first show it.`:`Use the arrow keys or the buttons to move through the deck.`})]})]})}function mc(e){return e===`idle`||e===`error`}function hc(e,t,n){return e===`recording`||e===`requesting`||e===`stopping`||e===`stopped`&&t||!mc(n)}function gc(e,t,n){return e?n===`rolling`||n===`countdown`?!1:mc(t):!0}function _c(e,t,n){return e?t===`review`?n:!mc(t):!1}function vc(e){return e?`Narration: microphone + camera video, timed to your reading.`:`Narration: microphone audio, timed to your reading.`}var yc={position:`fixed`,inset:0,background:`rgba(0, 0, 0, 0.5)`,display:`flex`,alignItems:`center`,justifyContent:`center`,zIndex:1e4};function bc(e){return{colorScheme:e,"--squisq-recorder-surface":`var(--squisq-bg)`,"--squisq-recorder-surface-muted":`var(--squisq-surface-sunken)`,"--squisq-recorder-input":`var(--squisq-input-bg)`,"--squisq-recorder-border":`var(--squisq-border)`,"--squisq-recorder-text":`var(--squisq-text)`,"--squisq-recorder-muted":`var(--squisq-text-muted)`,"--squisq-recorder-accent":`var(--squisq-accent)`,"--squisq-recorder-accent-text":`var(--squisq-text-on-accent)`,"--squisq-recorder-danger":`var(--squisq-danger)`,"--squisq-recorder-danger-border":`var(--squisq-danger-border)`,"--squisq-recorder-error-bg":`var(--squisq-danger-soft)`,"--squisq-recorder-error-border":`var(--squisq-danger-border)`,"--squisq-recorder-error-text":`var(--squisq-danger-strong)`}}var xc={background:`var(--squisq-recorder-surface)`,border:`1px solid var(--squisq-recorder-border)`,borderRadius:0,padding:`24px 28px`,width:`min(560px, calc(100vw - 48px))`,maxHeight:`calc(100vh - 48px)`,overflowY:`auto`,boxShadow:`0 8px 32px rgba(0,0,0,0.18)`,fontFamily:`system-ui, -apple-system, sans-serif`,color:`var(--squisq-recorder-text)`},Sc={margin:`0 0 16px 0`,fontSize:18,fontWeight:600,color:`var(--squisq-recorder-text)`},Cc={display:`block`,fontSize:13,fontWeight:500,marginBottom:4,color:`var(--squisq-recorder-text)`},wc={width:`100%`,padding:`6px 8px`,fontSize:13,fontFamily:`inherit`,border:`1px solid var(--squisq-recorder-border)`,borderRadius:0,background:`var(--squisq-recorder-input)`,color:`var(--squisq-recorder-text)`,marginBottom:12,boxSizing:`border-box`},Tc={...wc,resize:`vertical`,minHeight:72},Ec={padding:`8px 20px`,fontSize:14,fontFamily:`inherit`,fontWeight:500,cursor:`pointer`,background:`var(--squisq-recorder-accent)`,color:`var(--squisq-recorder-accent-text)`,border:`1px solid var(--squisq-recorder-accent)`,borderRadius:0},Dc={padding:`8px 20px`,fontSize:14,fontFamily:`inherit`,fontWeight:500,cursor:`pointer`,background:`var(--squisq-recorder-input)`,color:`var(--squisq-recorder-text)`,border:`1px solid var(--squisq-recorder-border)`,borderRadius:0},Oc={...Ec,background:`var(--squisq-recorder-danger)`,borderColor:`var(--squisq-recorder-danger-border)`},kc={...Ec,display:`inline-flex`,alignItems:`center`,gap:8},Ac={display:`inline-flex`,alignItems:`center`,justifyContent:`center`,flex:`0 0 auto`,padding:2,border:`1px solid #9ca3af`,borderRadius:`50%`,background:`#000`},jc={display:`block`,width:9,height:9,borderRadius:`50%`,background:`var(--squisq-recorder-danger)`},Y={display:`flex`,gap:8,marginBottom:16,flexWrap:`wrap`,alignItems:`center`},Mc={display:`flex`,gap:8},Nc={alignSelf:`stretch`,width:1,background:`var(--squisq-recorder-border)`,margin:`0 4px`},Pc={padding:`6px 14px`,fontSize:13,fontFamily:`inherit`,cursor:`pointer`,background:`transparent`,color:`var(--squisq-recorder-text)`,border:`1px solid var(--squisq-recorder-border)`,borderRadius:999},Fc={...Pc,color:`var(--squisq-recorder-accent-text)`,fontWeight:600,background:`var(--squisq-recorder-accent)`,borderColor:`var(--squisq-recorder-accent)`},Ic={width:`100%`,background:`#000`,borderRadius:0,marginBottom:12,overflow:`hidden`,aspectRatio:`16 / 9`,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`#888`,fontSize:13},Lc={position:`absolute`,top:8,right:8,padding:`3px 7px`,background:`rgba(0, 0, 0, 0.72)`,color:`#fff`,fontSize:12,fontVariantNumeric:`tabular-nums`,lineHeight:1.4,pointerEvents:`none`},Rc={width:`100%`,height:56,background:`var(--squisq-recorder-input)`,border:`1px solid var(--squisq-recorder-border)`,marginBottom:12,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`var(--squisq-recorder-muted)`,fontSize:13,fontVariantNumeric:`tabular-nums`},zc={background:`var(--squisq-recorder-error-bg)`,border:`1px solid var(--squisq-recorder-error-border)`,color:`var(--squisq-recorder-error-text)`,padding:`8px 10px`,fontSize:13,marginBottom:12},Bc={display:`flex`,gap:8,justifyContent:`flex-end`,marginTop:8},Vc={margin:`0 0 12px 0`,fontSize:12,color:`var(--squisq-recorder-muted)`},Hc={fontSize:13,fontVariantNumeric:`tabular-nums`,marginBottom:12,color:`var(--squisq-recorder-accent)`,fontWeight:600},Uc={...xc,width:`calc(100vw - 48px)`,height:`calc(100vh - 48px)`,maxHeight:`none`,overflowY:`hidden`,display:`flex`,flexDirection:`column`},Wc={display:`flex`,gap:24,flex:`1 1 auto`,minHeight:0},Gc={flex:`0 0 min(420px, 38vw)`,overflowY:`auto`,minHeight:0,paddingRight:4},Kc={flex:`1 1 auto`,minWidth:0,minHeight:0,display:`flex`,flexDirection:`column`,border:`1px solid var(--squisq-recorder-border)`},qc={display:`flex`,alignItems:`center`,gap:6,marginBottom:12,fontSize:13},Jc={position:`absolute`,left:0,top:0,bottom:0,background:`var(--squisq-recorder-accent)`,opacity:.25,transition:`width 80ms linear`};function Yc(e){let t=Math.floor(e/1e3);return`${Math.floor(t/60)}:${(t%60).toString().padStart(2,`0`)}`}function Xc({micOn:e,cameraOn:t,screenOn:n}){return t&&n?`screen+camera`:t?`camera`:n?e?`screen+mic`:`screen`:e?`mic`:null}function Zc(e){switch(e){case`mic`:return{micOn:!0,cameraOn:!1,screenOn:!1};case`camera`:return{micOn:!0,cameraOn:!0,screenOn:!1};case`screen`:return{micOn:!1,cameraOn:!1,screenOn:!0};case`screen+mic`:return{micOn:!0,cameraOn:!1,screenOn:!0};case`screen+camera`:return{micOn:!0,cameraOn:!0,screenOn:!0}}}var Qc=[{label:`Voice and camera`,toggles:[{key:`mic`,label:`Microphone`},{key:`camera`,label:`Camera`}]},{label:`Screen capture`,toggles:[{key:`systemAudio`,label:`System audio`},{key:`screen`,label:`Screen`}]}];function $c(e,t,n,r){let i=` Your computer’s audio is mixed in — you’ll pick a screen or tab to share it.`,a=r&&!n&&(e||t);if(t&&n)return e?`Screen capture plus your camera as picture-in-picture; microphone on the camera clip, system audio on the screen clip when available. Saved as two video clips.`:`Screen capture plus your camera as picture-in-picture (no microphone). Saved as two video clips.`;if(t){let t=e?`Camera video with your microphone. Saved as a video clip.`:`Camera video only (no microphone). Saved as a video clip.`;return a?`${t}${i}`:t}return n?e?`Screen capture with your microphone mixed in. System audio when available.`:`Screen capture (no microphone). System audio when available.`:e?r?`Voice plus your computer\u2019s audio.${i} Saved as an audio clip.`:`Voice-only audio. Pairs with a written script for auto-mapping to blocks.`:`Pick at least one source to record.`}function el(e,t,n){if(e===`mic`)return`audio`;let r=t?t.getAudioTracks().length>0:n;return e===`camera`?r?`camera-audio`:`camera`:r?`screen-audio`:`screen`}function tl(e,t,n,r){let i=e?e.getAudioTracks().length>0:n,a=t?t.getAudioTracks().length>0:r;return{screen:i?`screen-audio`:`screen`,camera:a?`camera-audio`:`camera`}}function nl({mediaProvider:e,container:t=null,initialMode:n=`mic`,colorScheme:r=`light`,onClose:i,onSave:a,narration:o=null,slides:s=null,title:c=`Record media`}){let l=Zc(n),[u,d]=(0,G.useState)(l.micOn),[f,p]=(0,G.useState)(l.cameraOn),[m,h]=(0,G.useState)(l.screenOn),[g,_]=(0,G.useState)(``),[v,y]=(0,G.useState)(``),[b,x]=(0,G.useState)(!1),[S,C]=(0,G.useState)(!1),[w,T]=(0,G.useState)(null),[E,D]=(0,G.useState)(null),[O,k]=(0,G.useState)(null),[A,j]=(0,G.useState)(0),[M,N]=(0,G.useState)(`none`),P=M===`narration`,F=M===`slides`,I=qs(M),[L,ee]=(0,G.useState)(!1),[te,R]=(0,G.useState)(null),[ne,re]=(0,G.useState)(()=>({...Ls,audio:{...Ls.audio},camera:{...Ls.camera},screen:{...Ls.screen},screenAudio:{...Ls.screenAudio},encoding:{...Ls.encoding}})),z=(0,G.useRef)(null),ie=(0,G.useRef)(null),ae=(0,G.useId)(),oe=(0,G.useRef)(null),se=(0,G.useRef)(null),ce=Xc({micOn:u,cameraOn:f,screenOn:m}),le=ce!==null,B=ce??`mic`,ue=B===`screen+camera`,V=La(),de=(0,G.useMemo)(()=>Vs(ne),[ne]),fe=(0,G.useMemo)(()=>Hs(ne),[ne]),H=(0,G.useMemo)(()=>Us(ne),[ne]),pe=(0,G.useMemo)(()=>Ws(ne),[ne]),me=ne.encoding,U=ss({source:B,includeMicrophone:f?u:void 0,audioConstraints:de,videoConstraints:fe,screenVideoConstraints:H,screenAudioConstraints:pe,mimeType:(B===`mic`?me.audioMimeType:me.videoMimeType).trim()||void 0,bitsPerSecond:Gs(me.bitsPerSecond),audioBitsPerSecond:Gs(me.audioBitsPerSecond),videoBitsPerSecond:Gs(me.videoBitsPerSecond),audioBitrateMode:me.audioBitrateMode,videoKeyFrameIntervalDuration:me.videoKeyFrameIntervalDuration,videoKeyFrameIntervalCount:me.videoKeyFrameIntervalCount,systemAudio:V?b:!1}),he=el(B,U.stream,u||b),ge=!!(o&&o.recording),_e=(0,G.useRef)(v);_e.current=v;let W=Io({doc:o?.doc??null,recording:o?.recording??null,getAudioBasename:()=>_e.current.trim()||void 0,micConstraints:de,cameraConstraints:fe,audioRecorderOptions:{mimeType:me.audioMimeType.trim()||void 0,bitsPerSecond:Gs(me.bitsPerSecond),audioBitsPerSecond:Gs(me.audioBitsPerSecond),audioBitrateMode:me.audioBitrateMode},cameraRecorderOptions:{mimeType:me.videoMimeType.trim()||void 0,bitsPerSecond:Gs(me.bitsPerSecond),videoBitsPerSecond:Gs(me.videoBitsPerSecond),videoKeyFrameIntervalDuration:me.videoKeyFrameIntervalDuration,videoKeyFrameIntervalCount:me.videoKeyFrameIntervalCount}}),ve=(0,G.useRef)(W);ve.current=W;let ye=s?.viewport??Ge.landscape,be=(0,G.useMemo)(()=>s?.doc?ec(s.doc,s.theme,ye):[],[s?.doc,s?.theme,ye]),xe=be.length>0,Se=!!(s?.captureTimings&&s?.doc),[Ce,we]=(0,G.useState)(0),[Te,Ee]=(0,G.useState)(Wt),[De,Oe]=(0,G.useState)(!0),ke=(0,G.useRef)(Ce);ke.current=Ce;let Ae=(0,G.useRef)(Te);Ae.current=Te;let je=(0,G.useRef)(be);je.current=be;let Me=(0,G.useMemo)(()=>new Set(Te.map(e=>e.blockId)),[Te]),Ne=(0,G.useCallback)(e=>{let t=Ys(e,je.current.length);we(t);let n=U.getElapsedMs(),r=je.current[t]?.blockId;n===null||!r||Ee(e=>tn(e,r,n))},[U]);(0,G.useEffect)(()=>{Ee(Wt),we(0)},[M,be.map(e=>e.blockId).join(`\0`)]);let Pe=(0,G.useCallback)(e=>{re(e),P&&ve.current.controller.setPrefs({micDeviceId:e.audio.deviceId||null})},[P]),Fe=W.controller.prefs.micDeviceId??``;(0,G.useEffect)(()=>{P&&re(e=>e.audio.deviceId===Fe?e:{...e,audio:{...e.audio,deviceId:Fe}})},[Fe,P]);let Ie=(0,G.useRef)(P);(0,G.useEffect)(()=>{let e=Ie.current;if(Ie.current=P,e!==P)if(P)U.cancel();else{let e=ve.current;e.controller.pause(),(e.controller.mic.status===`live`||e.controller.mic.status===`starting`)&&e.controller.mic.stop(),e.float.isOpen&&e.float.close()}},[P,U]),(0,G.useEffect)(()=>{if(!P)return;let e=e=>{if(e.key!==`Escape`)return;let t=ve.current.controller;(t.transport===`rolling`||t.transport===`countdown`)&&t.pause()};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[P]);let Le=W.controller.mic.status===`live`,Re=P&&W.recorder.withCamera&&Le&&W.recorder.cameraStream===null&&W.recorder.state!==`processing`&&W.recorder.state!==`review`&&W.recorder.state!==`saving`,ze=(0,G.useRef)(null);(0,G.useEffect)(()=>{let e=ze.current;if(e){for(let t of e.getTracks())t.stop();ze.current=null,R(null)}if(!Re)return;let t=!1,n=null;return(async()=>{try{let e=await Ba({video:fe,audio:!1});if(n=e,t){for(let t of e.getTracks())t.stop();return}ze.current=e,R(e)}catch{}})(),()=>{if(t=!0,n&&ze.current===n){for(let e of n.getTracks())e.stop();ze.current=null,R(null)}}},[fe,Re]);let Be=(0,G.useCallback)(async()=>{ee(!0);try{let e=ve.current.controller;await e.mic.start(e.prefs.micDeviceId)}finally{ee(!1)}},[]),Ve=(0,G.useCallback)(()=>{ve.current.recorder.start()},[]),He=P?W.recorder.cameraStream??te:null,Ue=P?W.controller.mic.stream:U.stream,We=P?He:U.camera?.stream??null,{devices:Ke,refresh:qe}=fs();(0,G.useEffect)(()=>{(Ue||We)&&qe()},[We,Ue,qe]),Va(oe,P?He:U.state===`stopped`?null:U.stream),Va(se,!P&&ue&&U.state!==`stopped`?U.camera?.stream??null:null),(0,G.useEffect)(()=>{if(j(0),!U.blob){D(null);return}let e=URL.createObjectURL(U.blob);return D(e),()=>{URL.revokeObjectURL(e)}},[U.blob]);let Je=U.camera?.blob??null;(0,G.useEffect)(()=>{if(!Je){k(null);return}let e=URL.createObjectURL(Je);return k(e),()=>{URL.revokeObjectURL(e)}},[Je]);let Ye=`${B}:${f?u:``}:${b}:${JSON.stringify(ne)}`,Xe=(0,G.useRef)(Ye),Ze=(0,G.useRef)({});(0,G.useEffect)(()=>{Xe.current!==Ye&&(Xe.current=Ye,Ze.current={},Ee(Wt),U.cancel())},[Ye,U]);let Qe=(0,G.useCallback)(()=>{let e=ve.current;if(_c(P,e.recorder.state,e.recorder.take!==null)){if(!window.confirm(`Discard the current narration take?`))return;e.handleDiscard()}P&&(e.controller.pause(),(e.controller.mic.status===`live`||e.controller.mic.status===`starting`)&&e.controller.mic.stop()),U.cancel(),i()},[P,U,i]);Ur({rootRef:z,dialogRef:ie,onClose:Qe,closeOnEscape:gc(P,W.recorder.state,W.controller.transport)});let $e=(0,G.useCallback)(async()=>{T(null);try{await U.request()}catch{}},[U]),et=(0,G.useCallback)(()=>{T(null),Ze.current={},U.start();let e=je.current[ke.current]?.blockId;Ee(e?tn(Wt,e,0):Wt)},[U]),tt=(0,G.useCallback)(async()=>{T(null),await U.stop()},[U]),nt=(0,G.useCallback)(async(n,r)=>{let i=s?.doc;if(!F||!Se||!De||!i)return null;let a=Ae.current;if(a.length===0)return null;let o=rn(i,a,r),c=Wa(o),l=Ga(n);if(t)await t.writeFile(l,c,`application/json`);else{let t=await e.addMedia(l,c,`application/json`);if(t!==l)return console.warn(`[squisq-recorder] block timings were saved as "${t}" instead of "${l}" \u2014 they will not be applied.`),null}let u=Sn(i,a);return{sidecarPath:l,blockCount:u.total,unshownCount:u.unshown,durationSec:o.duration}},[F,Se,De,s?.doc,t,e]),rt=(0,G.useCallback)(async()=>{if(!U.blob||!U.mimeType||!U.extension||!U.directory){T(`Nothing to save yet — record something first.`);return}if(ue){let t=U.camera;if(!t?.blob||!t.mimeType||!t.extension){T(`Nothing to save yet — record something first.`);return}C(!0),T(null);try{let n=tl(U.stream,t.stream,m&&b,u),r=v.trim(),i=Ra(`video`,U.extension,r?`${r}-screen`:void 0,n.screen),o=Ra(`video`,t.extension,r?`${r}-camera`:void 0,n.camera),s=Ze.current,c=s.screenPath??await e.addMedia(`${U.directory}/${i}`,U.blob,U.mimeType);s.screenPath=c;let l=s.cameraPath??await e.addMedia(`${U.directory}/${o}`,t.blob,t.mimeType);s.cameraPath=l;let d=U.durationMs/1e3,f=s.slideTiming??await nt(c,d);s.slideTiming=f;let p=U.cameraOffsetSec??0,h={relativePath:c,filename:i,source:B,mediaKind:`video`,mimeType:U.mimeType,duration:d,hasTimingSidecar:f!==null,...f?{slideTiming:f}:{},camera:{relativePath:l,filename:o,mimeType:t.mimeType,duration:Math.max(0,d-p),offsetSec:p}};Ze.current={},a?.(h),Qe()}catch(e){T(e instanceof Error?e.message:`Failed to save recording`)}finally{C(!1)}return}C(!0),T(null);try{let n=Ks(B,U.stream,U.mimeType),r=Ra(n,U.extension,v,he),i=`${n===`audio`?`audio`:U.directory}/${r}`,o=await e.addMedia(i,U.blob,U.mimeType),s=U.durationMs/1e3,c=await nt(o,s),l=c!==null;if(!c&&B===`mic`){let n=Ua(Ha(g,s)),r=Ga(o);if(t)await t.writeFile(r,n,`application/json`),l=!0;else{let t=await e.addMedia(r,n,`application/json`);l=t===r,l||console.warn(`[squisq-recorder] timing.json was saved as "${t}" instead of "${r}" \u2014 auto-mapping may not pick it up.`)}}let u={relativePath:o,filename:r,source:B,mediaKind:n,mimeType:U.mimeType,duration:s,hasTimingSidecar:l};c&&(u.slideTiming=c),B===`mic`&&(u.sourceText=c?void 0:g),a?.(u),Qe()}catch(e){T(e instanceof Error?e.message:`Failed to save recording`)}finally{C(!1)}},[U,B,ue,u,m,b,v,he,g,e,t,a,Qe,nt]),it=(0,G.useCallback)(()=>{Ze.current={},Ee(Wt),U.reset()},[U]),at=(0,G.useCallback)(e=>{let t=Number.isFinite(e.currentTime)?e.currentTime*1e3:0;j(Math.min(U.durationMs,Math.max(0,t)))},[U.durationMs]),ot=Ks(B,U.stream,U.mimeType)===`audio`,st=U.state!==`idle`&&U.state!==`error`,ct=U.state===`ready`,lt=U.state===`recording`,ut=U.state===`stopped`&&U.blob!==null,dt=U.state===`requesting`||U.state===`stopping`||S,ft=F&&Se,pt=Zs({slidesOn:F,captureTimings:Se,recorderState:U.state,hasBlob:U.blob!==null}),mt=(0,G.useMemo)(()=>s?.doc&&pt?Sn(s.doc,Te):null,[s?.doc,pt,Te]),ht=mt?Qs(mt.total,mt.unshown):null,gt=U.state===`recording`||U.state===`requesting`||ut,_t=ut?`Save or discard this recording before changing sources`:void 0,vt=u||f||m,yt=e=>{let t=e===`mic`?u:e===`camera`?f:e===`screen`?m:b;return e===`systemAudio`?{active:t,disabled:gt||!vt,title:gt?_t:vt?m?`Capture your computer’s audio with the screen recording`:`Capture your computer’s audio — you’ll pick a screen or tab to share it`:`Turn on Microphone, Camera, or Screen to add system audio`,onClick:()=>x(e=>!e)}:{active:t,disabled:gt,title:_t,onClick:()=>{e===`mic`?d(e=>!e):e===`camera`?p(e=>!e):h(e=>!e)}}},bt=mc(W.recorder.state),xt=W.recorder.state===`processing`||W.recorder.state===`review`||W.recorder.state===`saving`,St=hc(U.state,U.blob!==null||U.camera?.blob!=null,W.recorder.state),Ct=P?!bt:gt,wt=P?!0:u,Tt=P?W.recorder.withCamera:f,Et=e=>{switch(e){case`mic`:return{active:!0,disabled:!0,title:`Narration always records your microphone`,onClick:()=>{}};case`camera`:return{active:W.recorder.withCamera,disabled:!bt,title:`Also capture your camera as a separate video file`,onClick:()=>W.recorder.setWithCamera(!W.recorder.withCamera)};case`screen`:return{active:!1,disabled:!0,title:`Screen capture isn't available in narration mode — uncheck Show narration mode`,onClick:()=>{}};case`systemAudio`:return{active:!1,disabled:!0,title:`System audio isn't available in narration mode`,onClick:()=>{}}}};return(0,K.jsx)(`div`,{ref:z,className:`squisq-editor-shell squisq-recorder-overlay`,"data-theme":r,style:{...yc,...bc(r)},children:(0,K.jsxs)(`div`,{ref:ie,className:`squisq-editor-shell`,"data-theme":r,"data-narration":P?`true`:void 0,"data-slides":F?`true`:void 0,"data-panel-mode":M,style:{...I?Uc:xc,...bc(r)},onClick:e=>e.stopPropagation(),role:`dialog`,"aria-modal":`true`,"aria-labelledby":ae,tabIndex:-1,children:[(0,K.jsx)(`h2`,{id:ae,style:Sc,children:c}),(0,K.jsxs)(`div`,{style:I?Wc:void 0,children:[(0,K.jsxs)(`div`,{style:I?Gc:void 0,children:[(0,K.jsx)(`div`,{style:Y,role:`group`,"aria-label":`Capture sources`,children:Qc.map((e,t)=>(0,K.jsxs)(G.Fragment,{children:[t>0&&(0,K.jsx)(`div`,{"aria-hidden":`true`,style:Nc}),(0,K.jsx)(`div`,{style:Mc,children:e.toggles.map(e=>{if(e.key===`systemAudio`&&!V)return null;let t=P?Et(e.key):yt(e.key);return(0,K.jsx)(`button`,{type:`button`,"aria-pressed":t.active,style:t.active?Fc:Pc,onClick:t.onClick,disabled:t.disabled,title:t.title,children:e.label},e.key)})})]},e.label))}),(0,K.jsx)(`p`,{style:Vc,children:P?vc(W.recorder.withCamera):$c(u,f,m,b)}),ge&&(0,K.jsxs)(`label`,{style:qc,children:[(0,K.jsx)(`input`,{type:`checkbox`,style:{accentColor:`var(--squisq-recorder-accent)`},checked:P,onChange:e=>N(Js(M,`narration`,e.target.checked)),disabled:St,title:St?P?`Finish or discard the narration take first`:`Save or discard this recording before switching modes`:void 0}),`Show narration mode`]}),xe&&(0,K.jsxs)(`label`,{style:qc,children:[(0,K.jsx)(`input`,{type:`checkbox`,style:{accentColor:`var(--squisq-recorder-accent)`},checked:F,onChange:e=>N(Js(M,`slides`,e.target.checked)),disabled:St,title:St?`Save or discard this recording before switching modes`:void 0}),`Show slides mode`]}),(0,K.jsx)(Is,{devices:Ke,microphoneEnabled:wt,cameraEnabled:Tt,audioDeviceId:ne.audio.deviceId,cameraDeviceId:ne.camera.deviceId,onAudioDeviceChange:e=>Pe({...ne,audio:{...ne.audio,deviceId:e}}),onCameraDeviceChange:e=>Pe({...ne,camera:{...ne.camera,deviceId:e}}),disabled:Ct}),(0,K.jsx)(js,{value:ne,onChange:Pe,disabled:Ct,microphoneEnabled:wt,cameraEnabled:Tt,screenEnabled:!P&&m,systemAudioEnabled:!P&&b,separateAudioRecorder:P,primaryStream:Ue,cameraStream:We}),!P&&U.error&&(0,K.jsx)(`div`,{style:zc,children:U.error.message}),!P&&w&&(0,K.jsx)(`div`,{style:zc,children:w}),P&&(W.recorder.error??W.controller.mic.error)&&(0,K.jsx)(`div`,{style:zc,children:(W.recorder.error??W.controller.mic.error)?.message}),P&&He&&(0,K.jsx)(`div`,{style:Ic,children:(0,K.jsx)(`video`,{ref:oe,autoPlay:!0,muted:!0,playsInline:!0,style:{width:`100%`,height:`100%`,objectFit:`contain`}})}),P&&!He&&xt&&(0,K.jsx)(`div`,{style:Rc,children:W.recorder.take?`\u2713 Recorded ${Yc(W.recorder.take.durationSec*1e3)}`:`● Processing take…`}),P&&!He&&!xt&&W.recorder.withCamera&&(0,K.jsx)(`div`,{style:Ic,children:(0,K.jsx)(`span`,{children:Re?`Camera starting…`:`Click Start preview to turn on your camera.`})}),P&&!He&&!xt&&!W.recorder.withCamera&&(0,K.jsxs)(`div`,{style:{...Rc,position:`relative`,overflow:`hidden`},children:[(0,K.jsx)(`div`,{"aria-hidden":`true`,style:{...Jc,width:`${Math.round(Math.min(1,Math.max(0,W.controller.micLevel))*100)}%`}}),(0,K.jsx)(`span`,{style:{position:`relative`},children:W.recorder.state===`recording`?`● Recording narration`:Le?W.controller.voiceActive?`Voice detected`:`Microphone ready`:`Click Start preview to check your mic.`})]}),!P&&!st&&(0,K.jsx)(`div`,{style:Ic,children:(0,K.jsx)(`span`,{children:`Click Start Preview to start a recording.`})}),!P&&st&&U.state!==`stopped`&&!ot&&(0,K.jsxs)(`div`,{style:ue?{...Ic,position:`relative`}:Ic,children:[(0,K.jsx)(`video`,{ref:oe,autoPlay:!0,muted:!0,playsInline:!0,style:{width:`100%`,height:`100%`,objectFit:`contain`}}),ue&&(0,K.jsx)(`video`,{ref:se,autoPlay:!0,muted:!0,playsInline:!0,"aria-label":`Camera preview`,style:{position:`absolute`,right:`3%`,bottom:`6%`,width:`22%`,aspectRatio:`16 / 9`,objectFit:`cover`,background:`#000`,border:`1px solid rgba(255,255,255,0.6)`}})]}),!P&&st&&U.state!==`stopped`&&ot&&(0,K.jsx)(`div`,{style:Rc,children:U.state===`recording`?(0,K.jsxs)(K.Fragment,{children:[`● Recording `,Yc(U.durationMs)]}):(0,K.jsx)(K.Fragment,{children:`Microphone ready`})}),!P&&U.state===`stopped`&&E&&!ot&&(0,K.jsxs)(`div`,{style:{...Ic,position:`relative`},children:[(0,K.jsx)(`video`,{src:E,controls:!0,playsInline:!0,onTimeUpdate:e=>at(e.currentTarget),onSeeking:e=>at(e.currentTarget),onEnded:()=>j(U.durationMs),style:{width:`100%`,height:`100%`,objectFit:`contain`}}),(0,K.jsxs)(`div`,{role:`timer`,"aria-label":`Playback time: ${Yc(A)} of ${Yc(U.durationMs)}`,style:Lc,children:[Yc(A),` / `,Yc(U.durationMs)]})]}),!P&&U.state===`stopped`&&ue&&O&&(0,K.jsxs)(`div`,{style:{marginBottom:12},children:[(0,K.jsx)(`div`,{style:Vc,children:`Camera (picture-in-picture)`}),(0,K.jsx)(`video`,{src:O,controls:!0,playsInline:!0,"aria-label":`Camera recording`,style:{width:`48%`,display:`block`,marginLeft:`auto`,background:`#000`}})]}),!P&&U.state===`stopped`&&E&&ot&&(0,K.jsxs)(`div`,{style:{marginBottom:12},children:[(0,K.jsxs)(`div`,{style:{...Rc,marginBottom:8},children:[`✓ Recorded `,Yc(U.durationMs)]}),(0,K.jsx)(`audio`,{src:E,controls:!0,style:{width:`100%`}})]}),!P&&!ft&&B===`mic`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`label`,{style:Cc,htmlFor:`recorder-source-text`,children:`Script (used to auto-match this narration to a block)`}),(0,K.jsx)(`textarea`,{id:`recorder-source-text`,style:Tc,placeholder:`Type the text you're going to read aloud.`,value:g,onChange:e=>_(e.target.value),disabled:U.state===`recording`})]}),(0,K.jsx)(`label`,{style:Cc,htmlFor:`recorder-basename`,children:`Filename (optional)`}),(0,K.jsx)(`input`,{id:`recorder-basename`,type:`text`,style:wc,placeholder:P?`narration`:ue?`screen + camera`:he,value:v,onChange:e=>y(e.target.value),disabled:P?!bt:U.state===`recording`}),!P&&U.state===`recording`&&!ot&&(0,K.jsxs)(`div`,{style:Hc,children:[`● Recording `,Yc(U.durationMs)]}),pt&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`label`,{style:qc,children:[(0,K.jsx)(`input`,{type:`checkbox`,style:{accentColor:`var(--squisq-recorder-accent)`},checked:De,onChange:e=>Oe(e.target.checked),disabled:S}),`Update block timings when I save this narration`]}),De&&ht&&(0,K.jsx)(`p`,{style:Vc,children:ht})]}),(0,K.jsxs)(`div`,{style:Bc,children:[(0,K.jsx)(`button`,{type:`button`,style:Dc,onClick:Qe,disabled:!P&&dt,children:`Close`}),P&&(0,K.jsxs)(K.Fragment,{children:[bt&&!Le&&(0,K.jsx)(`button`,{type:`button`,style:Ec,onClick:()=>void Be(),disabled:L,children:L?`Requesting…`:`Start preview`}),bt&&Le&&(0,K.jsxs)(`button`,{type:`button`,style:kc,onClick:Ve,children:[(0,K.jsx)(`span`,{className:`squisq-recorder-record-dot`,style:Ac,"aria-hidden":`true`,children:(0,K.jsx)(`span`,{className:`squisq-recorder-record-dot-center`,style:jc})}),`Record`]}),(W.recorder.state===`recording`||W.recorder.state===`starting`)&&(0,K.jsx)(`button`,{type:`button`,style:Oc,onClick:()=>void W.recorder.stop(),children:`Stop`}),W.recorder.state===`processing`&&(0,K.jsx)(`span`,{style:Hc,children:`Aligning take…`}),W.recorder.state===`saving`&&(0,K.jsx)(`span`,{style:Hc,children:`Saving…`}),W.recorder.state===`review`&&W.recorder.take&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{type:`button`,style:Dc,onClick:W.handleRetake,children:`Discard & re-record`}),(0,K.jsx)(`button`,{type:`button`,style:Ec,onClick:()=>void W.handleSave(),children:`Save to document`})]})]}),!P&&(0,K.jsxs)(K.Fragment,{children:[(U.state===`idle`||U.state===`error`||U.state===`requesting`)&&(0,K.jsx)(`button`,{type:`button`,style:Ec,onClick:$e,disabled:dt||!le,children:U.state===`requesting`?`Requesting…`:`Start preview`}),ct&&(0,K.jsxs)(`button`,{type:`button`,style:kc,onClick:et,disabled:dt,children:[(0,K.jsx)(`span`,{className:`squisq-recorder-record-dot`,style:Ac,"aria-hidden":`true`,children:(0,K.jsx)(`span`,{className:`squisq-recorder-record-dot-center`,style:jc})}),`Record`]}),lt&&(0,K.jsx)(`button`,{type:`button`,style:Oc,onClick:tt,disabled:dt,children:`Stop`}),ut&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{type:`button`,style:Dc,onClick:it,disabled:dt,children:`Discard & re-record`}),(0,K.jsx)(`button`,{type:`button`,style:Ec,onClick:rt,disabled:dt,children:S?`Saving…`:`Save to document`})]})]})]})]}),P&&o&&(0,K.jsx)(`div`,{style:Kc,children:(0,K.jsx)($o,{stage:W,theme:o.theme,showSelfView:!1,showCameraToggleInRecordSlot:!1,showRecordSlot:!1,showTransportPlay:!1,showReviewActions:!1})}),F&&(0,K.jsx)(`div`,{style:Kc,children:(0,K.jsx)(pc,{slides:be,index:Ce,onIndexChange:Ne,viewport:ye,basePath:s?.basePath,mediaProvider:s?.mediaProvider??e,recording:U.state===`recording`,shownBlockIds:Me})})]})]})})}function rl({mediaProvider:e,container:t=null,initialMode:n=`mic`,colorScheme:r=`light`,onSave:i,narration:a=null,slides:o=null,tooltip:s=`Record media`,title:c,className:l,open:u,onOpenChange:d,showTrigger:f=!0}){let[p,m]=(0,G.useState)(!1),h=u??p,g=(0,G.useCallback)(e=>{u===void 0&&m(e),d?.(e)},[u,d]),_=(0,G.useCallback)(()=>g(!1),[g]);return(0,K.jsxs)(K.Fragment,{children:[f&&(0,K.jsx)(`button`,{type:`button`,className:l,"data-tooltip":s,"aria-label":s,"aria-expanded":h,onClick:()=>g(!h),children:(0,K.jsx)(q,{icon:`fa-solid fa-microphone`})}),h&&typeof document<`u`&&(0,Wr.createPortal)((0,K.jsx)(nl,{mediaProvider:e,container:t,initialMode:n,colorScheme:r,narration:a,slides:o,...c===void 0?{}:{title:c},onClose:_,onSave:e=>{i?.(e)}}),document.body)]})}function il(e){let{doc:t,theme:n,presentationTarget:r=null,recording:i=null}=e;return(0,K.jsx)($o,{stage:Io({doc:t,recording:i}),theme:n,presentationTarget:r})}var al={png:{extension:`png`,mime:`image/png`,label:`PNG — lossless`},jpeg:{extension:`jpg`,mime:`image/jpeg`,label:`JPEG — smaller file`},webp:{extension:`webp`,mime:`image/webp`,label:`WebP — compact`}};function ol(e,t,n){let r=al[n].extension;return`${e?.replace(/\.[^.]+$/,``).replace(/[<>:"/\\|?*]/g,`-`).split(``).map(e=>e.charCodeAt(0)<32?`-`:e).join(``).trim().replace(/[. ]+$/g,``)||`document`}-${t}.${r}`}function sl(e,t,n){return new Promise((r,i)=>{e.toBlob(e=>{e?r(e):i(Error(`The browser could not encode the image.`))},al[t].mime,t===`png`?void 0:n)})}async function cl(e,t){let n=window.showSaveFilePicker;if(!n)return;let r=al[t];try{return await n.call(window,{suggestedName:e,types:[{description:`${r.label.split(` —`)[0]} image`,accept:{[r.mime]:[`.${r.extension}`]}}]})}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return null;throw e}}function ll(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),r.remove(),window.setTimeout(()=>URL.revokeObjectURL(n),0)}var ul=e(t(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self,n.html2canvas=r())})(e,(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if(typeof n!=`function`&&n!==null)throw TypeError(`Class extends value `+String(n)+` is not a constructor or null`);e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)};function r(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function i(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(o){if(r)throw TypeError(`Generator is already executing.`);for(;n;)try{if(r=1,i&&(a=o[0]&2?i.return:o[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,o[1])).done)return a;switch(i=0,a&&(o=[o[0]&2,a.value]),o[0]){case 0:case 1:a=o;break;case 4:return n.label++,{value:o[1],done:!1};case 5:n.label++,i=o[1],o=[0];continue;case 7:o=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(o[0]===6||o[0]===2)){n=0;continue}if(o[0]===3&&(!a||o[1]>a[0]&&o[1]<a[3])){n.label=o[1];break}if(o[0]===6&&n.label<a[1]){n.label=a[1],a=o;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(o);break}a[2]&&n.ops.pop(),n.trys.pop();continue}o=t.call(e,n)}catch(e){o=[6,e],i=0}finally{r=a=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}}function a(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||t)}for(var o=function(){function e(e,t,n,r){this.left=e,this.top=t,this.width=n,this.height=r}return e.prototype.add=function(t,n,r,i){return new e(this.left+t,this.top+n,this.width+r,this.height+i)},e.fromClientRect=function(t,n){return new e(n.left+t.windowBounds.left,n.top+t.windowBounds.top,n.width,n.height)},e.fromDOMRectList=function(t,n){var r=Array.from(n).find(function(e){return e.width!==0});return r?new e(r.left+t.windowBounds.left,r.top+t.windowBounds.top,r.width,r.height):e.EMPTY},e.EMPTY=new e(0,0,0,0),e}(),s=function(e,t){return o.fromClientRect(e,t.getBoundingClientRect())},c=function(e){var t=e.body,n=e.documentElement;if(!t||!n)throw Error(`Unable to get document size`);return new o(0,0,Math.max(Math.max(t.scrollWidth,n.scrollWidth),Math.max(t.offsetWidth,n.offsetWidth),Math.max(t.clientWidth,n.clientWidth)),Math.max(Math.max(t.scrollHeight,n.scrollHeight),Math.max(t.offsetHeight,n.offsetHeight),Math.max(t.clientHeight,n.clientHeight)))},l=function(e){for(var t=[],n=0,r=e.length;n<r;){var i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<r){var a=e.charCodeAt(n++);(a&64512)==56320?t.push(((i&1023)<<10)+(a&1023)+65536):(t.push(i),n--)}else t.push(i)}return t},u=function(){var e=[...arguments];if(String.fromCodePoint)return String.fromCodePoint.apply(String,e);var t=e.length;if(!t)return``;for(var n=[],r=-1,i=``;++r<t;){var a=e[r];a<=65535?n.push(a):(a-=65536,n.push((a>>10)+55296,a%1024+56320)),(r+1===t||n.length>16384)&&(i+=String.fromCharCode.apply(String,n),n.length=0)}return i},d=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,f=typeof Uint8Array>`u`?[]:new Uint8Array(256),p=0;p<d.length;p++)f[d.charCodeAt(p)]=p;for(var m=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,h=typeof Uint8Array>`u`?[]:new Uint8Array(256),g=0;g<m.length;g++)h[m.charCodeAt(g)]=g;for(var _=function(e){var t=e.length*.75,n=e.length,r,i=0,a,o,s,c;e[e.length-1]===`=`&&(t--,e[e.length-2]===`=`&&t--);var l=typeof ArrayBuffer<`u`&&typeof Uint8Array<`u`&&Uint8Array.prototype.slice!==void 0?new ArrayBuffer(t):Array(t),u=Array.isArray(l)?l:new Uint8Array(l);for(r=0;r<n;r+=4)a=h[e.charCodeAt(r)],o=h[e.charCodeAt(r+1)],s=h[e.charCodeAt(r+2)],c=h[e.charCodeAt(r+3)],u[i++]=a<<2|o>>4,u[i++]=(o&15)<<4|s>>2,u[i++]=(s&3)<<6|c&63;return l},v=function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n.push(e[r+1]<<8|e[r]);return n},y=function(e){for(var t=e.length,n=[],r=0;r<t;r+=4)n.push(e[r+3]<<24|e[r+2]<<16|e[r+1]<<8|e[r]);return n},b=5,x=11,S=2,C=x-b,w=65536>>b,T=(1<<b)-1,E=w+(1024>>b)+32,D=65536>>x,O=(1<<C)-1,k=function(e,t,n){return e.slice?e.slice(t,n):new Uint16Array(Array.prototype.slice.call(e,t,n))},A=function(e,t,n){return e.slice?e.slice(t,n):new Uint32Array(Array.prototype.slice.call(e,t,n))},j=function(e,t){var n=_(e),r=Array.isArray(n)?y(n):new Uint32Array(n),i=Array.isArray(n)?v(n):new Uint16Array(n),a=24,o=k(i,a/2,r[4]/2),s=r[5]===2?k(i,(a+r[4])/2):A(r,Math.ceil((a+r[4])/4));return new M(r[0],r[1],r[2],r[3],o,s)},M=function(){function e(e,t,n,r,i,a){this.initialValue=e,this.errorValue=t,this.highStart=n,this.highValueIndex=r,this.index=i,this.data=a}return e.prototype.get=function(e){var t;if(e>=0){if(e<55296||e>56319&&e<=65535)return t=this.index[e>>b],t=(t<<S)+(e&T),this.data[t];if(e<=65535)return t=this.index[w+(e-55296>>b)],t=(t<<S)+(e&T),this.data[t];if(e<this.highStart)return t=E-D+(e>>x),t=this.index[t],t+=e>>b&O,t=this.index[t],t=(t<<S)+(e&T),this.data[t];if(e<=1114111)return this.data[this.highValueIndex]}return this.errorValue},e}(),N=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,P=typeof Uint8Array>`u`?[]:new Uint8Array(256),F=0;F<N.length;F++)P[N.charCodeAt(F)]=F;var I=`KwAAAAAAAAAACA4AUD0AADAgAAACAAAAAAAIABAAGABAAEgAUABYAGAAaABgAGgAYgBqAF8AZwBgAGgAcQB5AHUAfQCFAI0AlQCdAKIAqgCyALoAYABoAGAAaABgAGgAwgDKAGAAaADGAM4A0wDbAOEA6QDxAPkAAQEJAQ8BFwF1AH0AHAEkASwBNAE6AUIBQQFJAVEBWQFhAWgBcAF4ATAAgAGGAY4BlQGXAZ8BpwGvAbUBvQHFAc0B0wHbAeMB6wHxAfkBAQIJAvEBEQIZAiECKQIxAjgCQAJGAk4CVgJeAmQCbAJ0AnwCgQKJApECmQKgAqgCsAK4ArwCxAIwAMwC0wLbAjAA4wLrAvMC+AIAAwcDDwMwABcDHQMlAy0DNQN1AD0DQQNJA0kDSQNRA1EDVwNZA1kDdQB1AGEDdQBpA20DdQN1AHsDdQCBA4kDkQN1AHUAmQOhA3UAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AKYDrgN1AHUAtgO+A8YDzgPWAxcD3gPjA+sD8wN1AHUA+wMDBAkEdQANBBUEHQQlBCoEFwMyBDgEYABABBcDSARQBFgEYARoBDAAcAQzAXgEgASIBJAEdQCXBHUAnwSnBK4EtgS6BMIEyAR1AHUAdQB1AHUAdQCVANAEYABgAGAAYABgAGAAYABgANgEYADcBOQEYADsBPQE/AQEBQwFFAUcBSQFLAU0BWQEPAVEBUsFUwVbBWAAYgVgAGoFcgV6BYIFigWRBWAAmQWfBaYFYABgAGAAYABgAKoFYACxBbAFuQW6BcEFwQXHBcEFwQXPBdMF2wXjBeoF8gX6BQIGCgYSBhoGIgYqBjIGOgZgAD4GRgZMBmAAUwZaBmAAYABgAGAAYABgAGAAYABgAGAAYABgAGIGYABpBnAGYABgAGAAYABgAGAAYABgAGAAYAB4Bn8GhQZgAGAAYAB1AHcDFQSLBmAAYABgAJMGdQA9A3UAmwajBqsGqwaVALMGuwbDBjAAywbSBtIG1QbSBtIG0gbSBtIG0gbdBuMG6wbzBvsGAwcLBxMHAwcbByMHJwcsBywHMQcsB9IGOAdAB0gHTgfSBkgHVgfSBtIG0gbSBtIG0gbSBtIG0gbSBiwHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAdgAGAALAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAdbB2MHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsB2kH0gZwB64EdQB1AHUAdQB1AHUAdQB1AHUHfQdgAIUHjQd1AHUAlQedB2AAYAClB6sHYACzB7YHvgfGB3UAzgfWBzMB3gfmB1EB7gf1B/0HlQENAQUIDQh1ABUIHQglCBcDLQg1CD0IRQhNCEEDUwh1AHUAdQBbCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIcAh3CHoIMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIgggwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAALAcsBywHLAcsBywHLAcsBywHLAcsB4oILAcsB44I0gaWCJ4Ipgh1AHUAqgiyCHUAdQB1AHUAdQB1AHUAdQB1AHUAtwh8AXUAvwh1AMUIyQjRCNkI4AjoCHUAdQB1AO4I9gj+CAYJDgkTCS0HGwkjCYIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiAAIAAAAFAAYABgAGIAXwBgAHEAdQBFAJUAogCyAKAAYABgAEIA4ABGANMA4QDxAMEBDwE1AFwBLAE6AQEBUQF4QkhCmEKoQrhCgAHIQsAB0MLAAcABwAHAAeDC6ABoAHDCwMMAAcABwAHAAdDDGMMAAcAB6MM4wwjDWMNow3jDaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAEjDqABWw6bDqABpg6gAaABoAHcDvwOPA+gAaABfA/8DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DpcPAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcAB9cPKwkyCToJMAB1AHUAdQBCCUoJTQl1AFUJXAljCWcJawkwADAAMAAwAHMJdQB2CX4JdQCECYoJjgmWCXUAngkwAGAAYABxAHUApgn3A64JtAl1ALkJdQDACTAAMAAwADAAdQB1AHUAdQB1AHUAdQB1AHUAowYNBMUIMAAwADAAMADICcsJ0wnZCRUE4QkwAOkJ8An4CTAAMAB1AAAKvwh1AAgKDwoXCh8KdQAwACcKLgp1ADYKqAmICT4KRgowADAAdQB1AE4KMAB1AFYKdQBeCnUAZQowADAAMAAwADAAMAAwADAAMAAVBHUAbQowADAAdQC5CXUKMAAwAHwBxAijBogEMgF9CoQKiASMCpQKmgqIBKIKqgquCogEDQG2Cr4KxgrLCjAAMADTCtsKCgHjCusK8Qr5CgELMAAwADAAMAB1AIsECQsRC3UANAEZCzAAMAAwADAAMAB1ACELKQswAHUANAExCzkLdQBBC0kLMABRC1kLMAAwADAAMAAwADAAdQBhCzAAMAAwAGAAYABpC3ELdwt/CzAAMACHC4sLkwubC58Lpwt1AK4Ltgt1APsDMAAwADAAMAAwADAAMAAwAL4LwwvLC9IL1wvdCzAAMADlC+kL8Qv5C/8LSQswADAAMAAwADAAMAAwADAAMAAHDDAAMAAwADAAMAAODBYMHgx1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1ACYMMAAwADAAdQB1AHUALgx1AHUAdQB1AHUAdQA2DDAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AD4MdQBGDHUAdQB1AHUAdQB1AEkMdQB1AHUAdQB1AFAMMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQBYDHUAdQB1AF8MMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUA+wMVBGcMMAAwAHwBbwx1AHcMfwyHDI8MMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAYABgAJcMMAAwADAAdQB1AJ8MlQClDDAAMACtDCwHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsB7UMLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AA0EMAC9DDAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAsBywHLAcsBywHLAcsBywHLQcwAMEMyAwsBywHLAcsBywHLAcsBywHLAcsBywHzAwwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAHUAdQB1ANQM2QzhDDAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMABgAGAAYABgAGAAYABgAOkMYADxDGAA+AwADQYNYABhCWAAYAAODTAAMAAwADAAFg1gAGAAHg37AzAAMAAwADAAYABgACYNYAAsDTQNPA1gAEMNPg1LDWAAYABgAGAAYABgAGAAYABgAGAAUg1aDYsGVglhDV0NcQBnDW0NdQ15DWAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAlQCBDZUAiA2PDZcNMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAnw2nDTAAMAAwADAAMAAwAHUArw23DTAAMAAwADAAMAAwADAAMAAwADAAMAB1AL8NMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAB1AHUAdQB1AHUAdQDHDTAAYABgAM8NMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAA1w11ANwNMAAwAD0B5A0wADAAMAAwADAAMADsDfQN/A0EDgwOFA4wABsOMAAwADAAMAAwADAAMAAwANIG0gbSBtIG0gbSBtIG0gYjDigOwQUuDsEFMw7SBjoO0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIGQg5KDlIOVg7SBtIGXg5lDm0OdQ7SBtIGfQ6EDooOjQ6UDtIGmg6hDtIG0gaoDqwO0ga0DrwO0gZgAGAAYADEDmAAYAAkBtIGzA5gANIOYADaDokO0gbSBt8O5w7SBu8O0gb1DvwO0gZgAGAAxA7SBtIG0gbSBtIGYABgAGAAYAAED2AAsAUMD9IG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIGFA8sBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAccD9IGLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHJA8sBywHLAcsBywHLAccDywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywPLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAc0D9IG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIGLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAccD9IG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIGFA8sBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHPA/SBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gbSBtIG0gYUD0QPlQCVAJUAMAAwADAAMACVAJUAlQCVAJUAlQCVAEwPMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAA//8EAAQABAAEAAQABAAEAAQABAANAAMAAQABAAIABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQACgATABcAHgAbABoAHgAXABYAEgAeABsAGAAPABgAHABLAEsASwBLAEsASwBLAEsASwBLABgAGAAeAB4AHgATAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQABYAGwASAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAWAA0AEQAeAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAAFAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAJABYAGgAbABsAGwAeAB0AHQAeAE8AFwAeAA0AHgAeABoAGwBPAE8ADgBQAB0AHQAdAE8ATwAXAE8ATwBPABYAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAFAAUABQAFAAUABQAFAAUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAB4AHgAeAFAATwBAAE8ATwBPAEAATwBQAFAATwBQAB4AHgAeAB4AHgAeAB0AHQAdAB0AHgAdAB4ADgBQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgBQAB4AUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAJAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAkACQAJAAkACQAJAAkABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgAeAFAAHgAeAB4AKwArAFAAUABQAFAAGABQACsAKwArACsAHgAeAFAAHgBQAFAAUAArAFAAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAEAAQABAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAUAAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAYAA0AKwArAB4AHgAbACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQADQAEAB4ABAAEAB4ABAAEABMABAArACsAKwArACsAKwArACsAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAKwArACsAKwBWAFYAVgBWAB4AHgArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AGgAaABoAGAAYAB4AHgAEAAQABAAEAAQABAAEAAQABAAEAAQAEwAEACsAEwATAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABLAEsASwBLAEsASwBLAEsASwBLABoAGQAZAB4AUABQAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQABMAUAAEAAQABAAEAAQABAAEAB4AHgAEAAQABAAEAAQABABQAFAABAAEAB4ABAAEAAQABABQAFAASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUAAeAB4AUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAFAABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQAUABQAB4AHgAYABMAUAArACsABAAbABsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAFAABAAEAAQABAAEAFAABAAEAAQAUAAEAAQABAAEAAQAKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAArACsAHgArAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAB4ABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAUAAEAAQABAAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAABAAEAA0ADQBLAEsASwBLAEsASwBLAEsASwBLAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAArAFAAUABQAFAAUABQAFAAUAArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUAArACsAKwBQAFAAUABQACsAKwAEAFAABAAEAAQABAAEAAQABAArACsABAAEACsAKwAEAAQABABQACsAKwArACsAKwArACsAKwAEACsAKwArACsAUABQACsAUABQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAFAAUAAaABoAUABQAFAAUABQAEwAHgAbAFAAHgAEACsAKwAEAAQABAArAFAAUABQAFAAUABQACsAKwArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQACsAUABQACsAKwAEACsABAAEAAQABAAEACsAKwArACsABAAEACsAKwAEAAQABAArACsAKwAEACsAKwArACsAKwArACsAUABQAFAAUAArAFAAKwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLAAQABABQAFAAUAAEAB4AKwArACsAKwArACsAKwArACsAKwAEAAQABAArAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQAFAAUABQACsAKwAEAFAABAAEAAQABAAEAAQABAAEACsABAAEAAQAKwAEAAQABAArACsAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAB4AGwArACsAKwArACsAKwArAFAABAAEAAQABAAEAAQAKwAEAAQABAArAFAAUABQAFAAUABQAFAAUAArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAArACsABAAEACsAKwAEAAQABAArACsAKwArACsAKwArAAQABAAEACsAKwArACsAUABQACsAUABQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAB4AUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArAAQAUAArAFAAUABQAFAAUABQACsAKwArAFAAUABQACsAUABQAFAAUAArACsAKwBQAFAAKwBQACsAUABQACsAKwArAFAAUAArACsAKwBQAFAAUAArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArAAQABAAEAAQABAArACsAKwAEAAQABAArAAQABAAEAAQAKwArAFAAKwArACsAKwArACsABAArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAHgAeAB4AHgAeAB4AGwAeACsAKwArACsAKwAEAAQABAAEAAQAUABQAFAAUABQAFAAUABQACsAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAUAAEAAQABAAEAAQABAAEACsABAAEAAQAKwAEAAQABAAEACsAKwArACsAKwArACsABAAEACsAUABQAFAAKwArACsAKwArAFAAUAAEAAQAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAKwAOAFAAUABQAFAAUABQAFAAHgBQAAQABAAEAA4AUABQAFAAUABQAFAAUABQACsAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAKwArAAQAUAAEAAQABAAEAAQABAAEACsABAAEAAQAKwAEAAQABAAEACsAKwArACsAKwArACsABAAEACsAKwArACsAKwArACsAUAArAFAAUAAEAAQAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwBQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAFAABAAEAAQABAAEAAQABAArAAQABAAEACsABAAEAAQABABQAB4AKwArACsAKwBQAFAAUAAEAFAAUABQAFAAUABQAFAAUABQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAFAAUABQAFAAUABQAFAAUABQABoAUABQAFAAUABQAFAAKwAEAAQABAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQACsAUAArACsAUABQAFAAUABQAFAAUAArACsAKwAEACsAKwArACsABAAEAAQABAAEAAQAKwAEACsABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArAAQABAAeACsAKwArACsAKwArACsAKwArACsAKwArAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAAqAFwAXAAqACoAKgAqACoAKgAqACsAKwArACsAGwBcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAeAEsASwBLAEsASwBLAEsASwBLAEsADQANACsAKwArACsAKwBcAFwAKwBcACsAXABcAFwAXABcACsAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACsAXAArAFwAXABcAFwAXABcAFwAXABcAFwAKgBcAFwAKgAqACoAKgAqACoAKgAqACoAXAArACsAXABcAFwAXABcACsAXAArACoAKgAqACoAKgAqACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwBcAFwAXABcAFAADgAOAA4ADgAeAA4ADgAJAA4ADgANAAkAEwATABMAEwATAAkAHgATAB4AHgAeAAQABAAeAB4AHgAeAB4AHgBLAEsASwBLAEsASwBLAEsASwBLAFAAUABQAFAAUABQAFAAUABQAFAADQAEAB4ABAAeAAQAFgARABYAEQAEAAQAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQADQAEAAQABAAEAAQADQAEAAQAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArAA0ADQAeAB4AHgAeAB4AHgAEAB4AHgAeAB4AHgAeACsAHgAeAA4ADgANAA4AHgAeAB4AHgAeAAkACQArACsAKwArACsAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgBcAEsASwBLAEsASwBLAEsASwBLAEsADQANAB4AHgAeAB4AXABcAFwAXABcAFwAKgAqACoAKgBcAFwAXABcACoAKgAqAFwAKgAqACoAXABcACoAKgAqACoAKgAqACoAXABcAFwAKgAqACoAKgBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAqACoAKgAqAFwAKgBLAEsASwBLAEsASwBLAEsASwBLACoAKgAqACoAKgAqAFAAUABQAFAAUABQACsAUAArACsAKwArACsAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgBQAFAAUABQAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUAArACsAUABQAFAAUABQAFAAUAArAFAAKwBQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAKwBQACsAUABQAFAAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsABAAEAAQAHgANAB4AHgAeAB4AHgAeAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUAArACsADQBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAANAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAWABEAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAA0ADQANAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAANAA0AKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUAArAAQABAArACsAKwArACsAKwArACsAKwArACsAKwBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqAA0ADQAVAFwADQAeAA0AGwBcACoAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwAeAB4AEwATAA0ADQAOAB4AEwATAB4ABAAEAAQACQArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUAAEAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAHgArACsAKwATABMASwBLAEsASwBLAEsASwBLAEsASwBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAArACsAXABcAFwAXABcACsAKwArACsAKwArACsAKwArACsAKwBcAFwAXABcAFwAXABcAFwAXABcAFwAXAArACsAKwArAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAXAArACsAKwAqACoAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAArACsAHgAeAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAqACoAKwAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKwArAAQASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArACoAKgAqACoAKgAqACoAXAAqACoAKgAqACoAKgArACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsABAAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABABQAFAAUABQAFAAUABQACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwANAA0AHgANAA0ADQANAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAEAAQABAAEAAQAHgAeAB4AHgAeAB4AHgAeAB4AKwArACsABAAEAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwAeAB4AHgAeAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArAA0ADQANAA0ADQBLAEsASwBLAEsASwBLAEsASwBLACsAKwArAFAAUABQAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAA0ADQBQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUAAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArAAQABAAEAB4ABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAAQAUABQAFAAUABQAFAABABQAFAABAAEAAQAUAArACsAKwArACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsABAAEAAQABAAEAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAKwBQACsAUAArAFAAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAB4AHgAeAB4AHgAeAB4AHgBQAB4AHgAeAFAAUABQACsAHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAUABQACsAKwAeAB4AHgAeAB4AHgArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArAFAAUABQACsAHgAeAB4AHgAeAB4AHgAOAB4AKwANAA0ADQANAA0ADQANAAkADQANAA0ACAAEAAsABAAEAA0ACQANAA0ADAAdAB0AHgAXABcAFgAXABcAFwAWABcAHQAdAB4AHgAUABQAFAANAAEAAQAEAAQABAAEAAQACQAaABoAGgAaABoAGgAaABoAHgAXABcAHQAVABUAHgAeAB4AHgAeAB4AGAAWABEAFQAVABUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ADQAeAA0ADQANAA0AHgANAA0ADQAHAB4AHgAeAB4AKwAEAAQABAAEAAQABAAEAAQABAAEAFAAUAArACsATwBQAFAAUABQAFAAHgAeAB4AFgARAE8AUABPAE8ATwBPAFAAUABQAFAAUAAeAB4AHgAWABEAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArABsAGwAbABsAGwAbABsAGgAbABsAGwAbABsAGwAbABsAGwAbABsAGwAbABsAGgAbABsAGwAbABoAGwAbABoAGwAbABsAGwAbABsAGwAbABsAGwAbABsAGwAbABsAGwAbAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAHgAeAFAAGgAeAB0AHgBQAB4AGgAeAB4AHgAeAB4AHgAeAB4AHgBPAB4AUAAbAB4AHgBQAFAAUABQAFAAHgAeAB4AHQAdAB4AUAAeAFAAHgBQAB4AUABPAFAAUAAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAHgBQAFAAUABQAE8ATwBQAFAAUABQAFAATwBQAFAATwBQAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAFAAUABQAFAATwBPAE8ATwBPAE8ATwBPAE8ATwBQAFAAUABQAFAAUABQAFAAUAAeAB4AUABQAFAAUABPAB4AHgArACsAKwArAB0AHQAdAB0AHQAdAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB4AHQAdAB4AHgAeAB0AHQAeAB4AHQAeAB4AHgAdAB4AHQAbABsAHgAdAB4AHgAeAB4AHQAeAB4AHQAdAB0AHQAeAB4AHQAeAB0AHgAdAB0AHQAdAB0AHQAeAB0AHgAeAB4AHgAeAB0AHQAdAB0AHgAeAB4AHgAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB4AHgAeAB0AHgAeAB4AHgAeAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHgAeAB0AHQAdAB0AHgAeAB0AHQAeAB4AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHQAeAB4AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAeAB4AHgAdAB4AHgAeAB4AHgAeAB4AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AFAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeABYAEQAWABEAHgAeAB4AHgAeAB4AHQAeAB4AHgAeAB4AHgAeACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAWABEAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAFAAHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHgAeAB4AHgAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAeAB4AHQAdAB0AHQAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHQAeAB0AHQAdAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB0AHQAeAB4AHQAdAB4AHgAeAB4AHQAdAB4AHgAeAB4AHQAdAB0AHgAeAB0AHgAeAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlAB4AHQAdAB4AHgAdAB4AHgAeAB4AHQAdAB4AHgAeAB4AJQAlAB0AHQAlAB4AJQAlACUAIAAlACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAeAB4AHgAeAB0AHgAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHgAdAB0AHQAeAB0AJQAdAB0AHgAdAB0AHgAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHQAdAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACUAJQAlACUAJQAdAB0AHQAdACUAHgAlACUAJQAdACUAJQAdAB0AHQAlACUAHQAdACUAHQAdACUAJQAlAB4AHQAeAB4AHgAeAB0AHQAlAB0AHQAdAB0AHQAdACUAJQAlACUAJQAdACUAJQAgACUAHQAdACUAJQAlACUAJQAlACUAJQAeAB4AHgAlACUAIAAgACAAIAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB0AHgAeAB4AFwAXABcAFwAXABcAHgATABMAJQAeAB4AHgAWABEAFgARABYAEQAWABEAFgARABYAEQAWABEATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeABYAEQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAWABEAFgARABYAEQAWABEAFgARAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AFgARABYAEQAWABEAFgARABYAEQAWABEAFgARABYAEQAWABEAFgARABYAEQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAWABEAFgARAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AFgARAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAdAB0AHQAdAB0AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AUABQAFAAUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAEAAQABAAeAB4AKwArACsAKwArABMADQANAA0AUAATAA0AUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAUAANACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAA0ADQANAA0ADQANAA0ADQAeAA0AFgANAB4AHgAXABcAHgAeABcAFwAWABEAFgARABYAEQAWABEADQANAA0ADQATAFAADQANAB4ADQANAB4AHgAeAB4AHgAMAAwADQANAA0AHgANAA0AFgANAA0ADQANAA0ADQANAA0AHgANAB4ADQANAB4AHgAeACsAKwArACsAKwArACsAKwArACsAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAKwArACsAKwArACsAKwArACsAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAlACUAJQAlACUAJQAlACUAJQAlACUAJQArACsAKwArAA0AEQARACUAJQBHAFcAVwAWABEAFgARABYAEQAWABEAFgARACUAJQAWABEAFgARABYAEQAWABEAFQAWABEAEQAlAFcAVwBXAFcAVwBXAFcAVwBXAAQABAAEAAQABAAEACUAVwBXAFcAVwA2ACUAJQBXAFcAVwBHAEcAJQAlACUAKwBRAFcAUQBXAFEAVwBRAFcAUQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFEAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBRAFcAUQBXAFEAVwBXAFcAVwBXAFcAUQBXAFcAVwBXAFcAVwBRAFEAKwArAAQABAAVABUARwBHAFcAFQBRAFcAUQBXAFEAVwBRAFcAUQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFEAVwBRAFcAUQBXAFcAVwBXAFcAVwBRAFcAVwBXAFcAVwBXAFEAUQBXAFcAVwBXABUAUQBHAEcAVwArACsAKwArACsAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwAlACUAVwBXAFcAVwAlACUAJQAlACUAJQAlACUAJQAlACsAKwArACsAKwArACsAKwArACsAKwArAFEAUQBRAFEAUQBRAFEAUQBRAFEAUQBRAFEAUQBRAFEAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQArAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQBPAE8ATwBPAE8ATwBPAE8AJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQAlAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAEcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAADQATAA0AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABLAEsASwBLAEsASwBLAEsASwBLAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAABAAEAAQABAAeAAQABAAEAAQABAAEAAQABAAEAAQAHgBQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AUABQAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAeAA0ADQANAA0ADQArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAB4AHgAeAB4AHgAeAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAHgAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAeAB4AUABQAFAAUABQAFAAUABQAFAAUABQAAQAUABQAFAABABQAFAAUABQAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAeAB4AHgAeAAQAKwArACsAUABQAFAAUABQAFAAHgAeABoAHgArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAADgAOABMAEwArACsAKwArACsAKwArACsABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwANAA0ASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAFAAUAAeAB4AHgBQAA4AUABQAAQAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAA0ADQBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArACsAKwArACsAKwArAB4AWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYACsAKwArAAQAHgAeAB4AHgAeAB4ADQANAA0AHgAeAB4AHgArAFAASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArAB4AHgBcAFwAXABcAFwAKgBcAFwAXABcAFwAXABcAFwAXABcAEsASwBLAEsASwBLAEsASwBLAEsAXABcAFwAXABcACsAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArAFAAUABQAAQAUABQAFAAUABQAFAAUABQAAQABAArACsASwBLAEsASwBLAEsASwBLAEsASwArACsAHgANAA0ADQBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKgAqACoAXAAqACoAKgBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAAqAFwAKgAqACoAXABcACoAKgBcAFwAXABcAFwAKgAqAFwAKgBcACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFwAXABcACoAKgBQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAA0ADQBQAFAAUAAEAAQAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUAArACsAUABQAFAAUABQAFAAKwArAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQADQAEAAQAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAVABVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBUAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVACsAKwArACsAKwArACsAKwArACsAKwArAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAKwArACsAKwBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAKwArACsAKwAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAKwArACsAKwArAFYABABWAFYAVgBWAFYAVgBWAFYAVgBWAB4AVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgArAFYAVgBWAFYAVgArAFYAKwBWAFYAKwBWAFYAKwBWAFYAVgBWAFYAVgBWAFYAVgBWAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAEQAWAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUAAaAB4AKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAGAARABEAGAAYABMAEwAWABEAFAArACsAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACUAJQAlACUAJQAWABEAFgARABYAEQAWABEAFgARABYAEQAlACUAFgARACUAJQAlACUAJQAlACUAEQAlABEAKwAVABUAEwATACUAFgARABYAEQAWABEAJQAlACUAJQAlACUAJQAlACsAJQAbABoAJQArACsAKwArAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAcAKwATACUAJQAbABoAJQAlABYAEQAlACUAEQAlABEAJQBXAFcAVwBXAFcAVwBXAFcAVwBXABUAFQAlACUAJQATACUAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXABYAJQARACUAJQAlAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwAWACUAEQAlABYAEQARABYAEQARABUAVwBRAFEAUQBRAFEAUQBRAFEAUQBRAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAEcARwArACsAVwBXAFcAVwBXAFcAKwArAFcAVwBXAFcAVwBXACsAKwBXAFcAVwBXAFcAVwArACsAVwBXAFcAKwArACsAGgAbACUAJQAlABsAGwArAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwAEAAQABAAQAB0AKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsADQANAA0AKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAB4AHgAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAAQAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAA0AUABQAFAAUAArACsAKwArAFAAUABQAFAAUABQAFAAUAANAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwAeACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAKwArAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUAArACsAKwBQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwANAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAB4AUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAA0AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAUABQAFAAUABQAAQABAAEACsABAAEACsAKwArACsAKwAEAAQABAAEAFAAUABQAFAAKwBQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAQABAAEACsAKwArACsABABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAA0ADQANAA0ADQANAA0ADQAeACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAFAAUABQAFAAUABQAFAAUAAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAArACsAKwArAFAAUABQAFAAUAANAA0ADQANAA0ADQAUACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsADQANAA0ADQANAA0ADQBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAAQABAAEAAQAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUAArAAQABAANACsAKwBQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAB4AHgAeAB4AHgArACsAKwArACsAKwAEAAQABAAEAAQABAAEAA0ADQAeAB4AHgAeAB4AKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgANAA0ADQANACsAKwArACsAKwArACsAKwArACsAKwAeACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsASwBLAEsASwBLAEsASwBLAEsASwANAA0ADQANAFAABAAEAFAAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAeAA4AUAArACsAKwArACsAKwArACsAKwAEAFAAUABQAFAADQANAB4ADQAEAAQABAAEAB4ABAAEAEsASwBLAEsASwBLAEsASwBLAEsAUAAOAFAADQANAA0AKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAANAA0AHgANAA0AHgAEACsAUABQAFAAUABQAFAAUAArAFAAKwBQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAA0AKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsABAAEAAQABAArAFAAUABQAFAAUABQAFAAUAArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQAFAAUABQACsABAAEAFAABAAEAAQABAAEAAQABAArACsABAAEACsAKwAEAAQABAArACsAUAArACsAKwArACsAKwAEACsAKwArACsAKwBQAFAAUABQAFAABAAEACsAKwAEAAQABAAEAAQABAAEACsAKwArAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwArACsABAAEAAQABAAEAAQABABQAFAAUABQAA0ADQANAA0AHgBLAEsASwBLAEsASwBLAEsASwBLAA0ADQArAB4ABABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAAQABAAEAFAAUAAeAFAAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAArACsABAAEAAQABAAEAAQABAAEAAQADgANAA0AEwATAB4AHgAeAA0ADQANAA0ADQANAA0ADQANAA0ADQANAA0ADQANAFAAUABQAFAABAAEACsAKwAEAA0ADQAeAFAAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAFAAKwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKwArACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwBcAFwADQANAA0AKgBQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAKwArAFAAKwArAFAAUABQAFAAUABQAFAAUAArAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQAKwAEAAQAKwArAAQABAAEAAQAUAAEAFAABAAEAA0ADQANACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAArACsABAAEAAQABAAEAAQABABQAA4AUAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAFAABAAEAAQABAAOAB4ADQANAA0ADQAOAB4ABAArACsAKwArACsAKwArACsAUAAEAAQABAAEAAQABAAEAAQABAAEAAQAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAA0ADQANAFAADgAOAA4ADQANACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEACsABAAEAAQABAAEAAQABAAEAFAADQANAA0ADQANACsAKwArACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwAOABMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAArACsAKwAEACsABAAEACsABAAEAAQABAAEAAQABABQAAQAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAKwBQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQAKwAEAAQAKwAEAAQABAAEAAQAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAaABoAGgAaAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwArAA0AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsADQANAA0ADQANACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAASABIAEgAQwBDAEMAUABQAFAAUABDAFAAUABQAEgAQwBIAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAASABDAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwAJAAkACQAJAAkACQAJABYAEQArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABIAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwANAA0AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAQABAAEAAQABAANACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAA0ADQANAB4AHgAeAB4AHgAeAFAAUABQAFAADQAeACsAKwArACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAANAA0AHgAeACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwAEAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArACsAKwAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAARwBHABUARwAJACsAKwArACsAKwArACsAKwArACsAKwAEAAQAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACsAKwArACsAKwArACsAKwBXAFcAVwBXAFcAVwBXAFcAVwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUQBRAFEAKwArACsAKwArACsAKwArACsAKwArACsAKwBRAFEAUQBRACsAKwArACsAKwArACsAKwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUAArACsAHgAEAAQADQAEAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArAB4AHgAeAB4AHgAeAB4AKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAAQABAAEAAQABAAeAB4AHgAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAB4AHgAEAAQABAAEAAQABAAEAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQAHgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwBQAFAAKwArAFAAKwArAFAAUAArACsAUABQAFAAUAArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAUAArAFAAUABQAFAAUABQAFAAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwBQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAHgAeAFAAUABQAFAAUAArAFAAKwArACsAUABQAFAAUABQAFAAUAArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeACsAKwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAEsASwBLAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgAeAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgAeAB4AHgAeAB4ABAAeAB4AHgAeAB4AHgAeAB4AHgAeAAQAHgAeAA0ADQANAA0AHgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAAQABAAEAAQAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAAEAAQAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArAAQABAAEAAQABAAEAAQAKwAEAAQAKwAEAAQABAAEAAQAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwAEAAQABAAEAAQABAAEAFAAUABQAFAAUABQAFAAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwBQAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArABsAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArAB4AHgAeAB4ABAAEAAQABAAEAAQABABQACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArABYAFgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAGgBQAFAAUAAaAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAKwBQACsAKwBQACsAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAKwBQACsAUAArACsAKwArACsAKwBQACsAKwArACsAUAArAFAAKwBQACsAUABQAFAAKwBQAFAAKwBQACsAKwBQACsAUAArAFAAKwBQACsAUAArAFAAUAArAFAAKwArAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQAFAAUAArAFAAUABQAFAAKwBQACsAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAUABQAFAAKwBQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8AJQAlACUAHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHgAeAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB4AHgAeACUAJQAlAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAJQAlACUAJQAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAB4AHgAlACUAJQAlACUAHgAlACUAJQAlACUAIAAgACAAJQAlACAAJQAlACAAIAAgACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACEAIQAhACEAIQAlACUAIAAgACUAJQAgACAAIAAgACAAIAAgACAAIAAgACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAJQAlACUAIAAlACUAJQAlACAAIAAgACUAIAAgACAAJQAlACUAJQAlACUAJQAgACUAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAlAB4AJQAeACUAJQAlACUAJQAgACUAJQAlACUAHgAlAB4AHgAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAlACUAJQAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAJQAlACUAJQAgACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACAAIAAgACUAJQAlACAAIAAgACAAIAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeABcAFwAXABUAFQAVAB4AHgAeAB4AJQAlACUAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAgACUAJQAlACUAJQAlACUAJQAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlACUAJQAeAB4AHgAeAB4AHgAeAB4AHgAeACUAJQAlACUAJQAlAB4AHgAeAB4AHgAeAB4AHgAlACUAJQAlACUAJQAlACUAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAgACUAJQAgACUAJQAlACUAJQAlACUAJQAgACAAIAAgACAAIAAgACAAJQAlACUAJQAlACUAIAAlACUAJQAlACUAJQAlACUAJQAgACAAIAAgACAAIAAgACAAIAAgACUAJQAgACAAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAgACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAlACAAIAAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAgACAAIAAlACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAJQAlAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAKwArAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwAlACUAJQAlACUAJQAlACUAJQAlACUAVwBXACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAKwAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAA==`,L=50,ee=1,te=2,R=3,ne=4,re=5,z=7,ie=8,ae=9,oe=10,se=11,ce=12,le=13,B=14,ue=15,V=16,de=17,fe=18,H=19,pe=20,me=21,U=22,he=23,ge=24,_e=25,W=26,ve=27,ye=28,be=29,xe=30,Se=31,Ce=32,we=33,Te=34,Ee=35,De=36,Oe=37,ke=38,Ae=39,je=40,Me=41,Ne=42,Pe=43,Fe=[9001,65288],Ie=`!`,Le=`×`,Re=`÷`,ze=j(I),Be=[xe,De],Ve=[ee,te,R,re],He=[oe,ie],Ue=[ve,W],We=Ve.concat(He),Ge=[ke,Ae,je,Te,Ee],Ke=[ue,le],qe=function(e,t){t===void 0&&(t=`strict`);var n=[],r=[],i=[];return e.forEach(function(e,a){var o=ze.get(e);if(o>L?(i.push(!0),o-=L):i.push(!1),[`normal`,`auto`,`loose`].indexOf(t)!==-1&&[8208,8211,12316,12448].indexOf(e)!==-1)return r.push(a),n.push(V);if(o===ne||o===se){if(a===0)return r.push(a),n.push(xe);var s=n[a-1];return We.indexOf(s)===-1?(r.push(r[a-1]),n.push(s)):(r.push(a),n.push(xe))}if(r.push(a),o===Se)return n.push(t===`strict`?me:Oe);if(o===Ne||o===be)return n.push(xe);if(o===Pe)return e>=131072&&e<=196605||e>=196608&&e<=262141?n.push(Oe):n.push(xe);n.push(o)}),[r,n,i]},Je=function(e,t,n,r){var i=r[n];if(Array.isArray(e)?e.indexOf(i)!==-1:e===i)for(var a=n;a<=r.length;){a++;var o=r[a];if(o===t)return!0;if(o!==oe)break}if(i===oe)for(var a=n;a>0;){a--;var s=r[a];if(Array.isArray(e)?e.indexOf(s)!==-1:e===s)for(var c=n;c<=r.length;){c++;var o=r[c];if(o===t)return!0;if(o!==oe)break}if(s!==oe)break}return!1},Ye=function(e,t){for(var n=e;n>=0;){var r=t[n];if(r===oe)n--;else return r}return 0},Xe=function(e,t,n,r,i){if(n[r]===0)return Le;var a=r-1;if(Array.isArray(i)&&i[a]===!0)return Le;var o=a-1,s=a+1,c=t[a],l=o>=0?t[o]:0,u=t[s];if(c===te&&u===R)return Le;if(Ve.indexOf(c)!==-1)return Ie;if(Ve.indexOf(u)!==-1||He.indexOf(u)!==-1)return Le;if(Ye(a,t)===ie)return Re;if(ze.get(e[a])===se||(c===Ce||c===we)&&ze.get(e[s])===se||c===z||u===z||c===ae||[oe,le,ue].indexOf(c)===-1&&u===ae||[de,fe,H,ge,ye].indexOf(u)!==-1||Ye(a,t)===U||Je(he,U,a,t)||Je([de,fe],me,a,t)||Je(ce,ce,a,t))return Le;if(c===oe)return Re;if(c===he||u===he)return Le;if(u===V||c===V)return Re;if([le,ue,me].indexOf(u)!==-1||c===B||l===De&&Ke.indexOf(c)!==-1||c===ye&&u===De||u===pe||Be.indexOf(u)!==-1&&c===_e||Be.indexOf(c)!==-1&&u===_e||c===ve&&[Oe,Ce,we].indexOf(u)!==-1||[Oe,Ce,we].indexOf(c)!==-1&&u===W||Be.indexOf(c)!==-1&&Ue.indexOf(u)!==-1||Ue.indexOf(c)!==-1&&Be.indexOf(u)!==-1||[ve,W].indexOf(c)!==-1&&(u===_e||[U,ue].indexOf(u)!==-1&&t[s+1]===_e)||[U,ue].indexOf(c)!==-1&&u===_e||c===_e&&[_e,ye,ge].indexOf(u)!==-1)return Le;if([_e,ye,ge,de,fe].indexOf(u)!==-1)for(var d=a;d>=0;){var f=t[d];if(f===_e)return Le;if([ye,ge].indexOf(f)!==-1)d--;else break}if([ve,W].indexOf(u)!==-1)for(var d=[de,fe].indexOf(c)===-1?a:o;d>=0;){var f=t[d];if(f===_e)return Le;if([ye,ge].indexOf(f)!==-1)d--;else break}if(ke===c&&[ke,Ae,Te,Ee].indexOf(u)!==-1||[Ae,Te].indexOf(c)!==-1&&[Ae,je].indexOf(u)!==-1||[je,Ee].indexOf(c)!==-1&&u===je||Ge.indexOf(c)!==-1&&[pe,W].indexOf(u)!==-1||Ge.indexOf(u)!==-1&&c===ve||Be.indexOf(c)!==-1&&Be.indexOf(u)!==-1||c===ge&&Be.indexOf(u)!==-1||Be.concat(_e).indexOf(c)!==-1&&u===U&&Fe.indexOf(e[s])===-1||Be.concat(_e).indexOf(u)!==-1&&c===fe)return Le;if(c===Me&&u===Me){for(var p=n[a],m=1;p>0&&(p--,t[p]===Me);)m++;if(m%2!=0)return Le}return c===Ce&&u===we?Le:Re},Ze=function(e,t){t||={lineBreak:`normal`,wordBreak:`normal`};var n=qe(e,t.lineBreak),r=n[0],i=n[1],a=n[2];(t.wordBreak===`break-all`||t.wordBreak===`break-word`)&&(i=i.map(function(e){return[_e,xe,Ne].indexOf(e)===-1?e:Oe}));var o=t.wordBreak===`keep-all`?a.map(function(t,n){return t&&e[n]>=19968&&e[n]<=40959}):void 0;return[r,i,o]},Qe=function(){function e(e,t,n,r){this.codePoints=e,this.required=t===Ie,this.start=n,this.end=r}return e.prototype.slice=function(){return u.apply(void 0,this.codePoints.slice(this.start,this.end))},e}(),$e=function(e,t){var n=l(e),r=Ze(n,t),i=r[0],a=r[1],o=r[2],s=n.length,c=0,u=0;return{next:function(){if(u>=s)return{done:!0,value:null};for(var e=Le;u<s&&(e=Xe(n,a,i,++u,o))===Le;);if(e!==Le||u===s){var t=new Qe(n,e,c,u);return c=u,{value:t,done:!1}}return{done:!0,value:null}}}},et=1,tt=2,nt=4,rt=8,it=10,at=47,ot=92,st=9,ct=32,lt=34,ut=61,dt=35,ft=36,pt=37,mt=39,ht=40,gt=41,_t=95,vt=45,yt=33,bt=60,xt=62,St=64,Ct=91,wt=93,Tt=61,Et=123,Dt=63,Ot=125,kt=124,At=126,jt=128,Mt=65533,Nt=42,Pt=43,Ft=44,It=58,Lt=59,Rt=46,zt=0,Bt=8,Vt=11,Ht=14,Ut=31,Wt=127,Gt=-1,Kt=48,qt=97,Jt=101,Yt=102,Xt=117,Zt=122,Qt=65,$t=69,en=70,tn=85,nn=90,rn=function(e){return e>=Kt&&e<=57},an=function(e){return e>=55296&&e<=57343},on=function(e){return rn(e)||e>=Qt&&e<=en||e>=qt&&e<=Yt},sn=function(e){return e>=qt&&e<=Zt},cn=function(e){return e>=Qt&&e<=nn},ln=function(e){return sn(e)||cn(e)},un=function(e){return e>=jt},dn=function(e){return e===it||e===st||e===ct},fn=function(e){return ln(e)||un(e)||e===_t},pn=function(e){return fn(e)||rn(e)||e===vt},mn=function(e){return e>=zt&&e<=Bt||e===Vt||e>=Ht&&e<=Ut||e===Wt},hn=function(e,t){return e===ot&&t!==it},gn=function(e,t,n){return e===vt?fn(t)||hn(t,n):fn(e)?!0:!!(e===ot&&hn(e,t))},_n=function(e,t,n){return e===Pt||e===vt?rn(t)?!0:t===Rt&&rn(n):rn(e===Rt?t:e)},vn=function(e){var t=0,n=1;(e[t]===Pt||e[t]===vt)&&(e[t]===vt&&(n=-1),t++);for(var r=[];rn(e[t]);)r.push(e[t++]);var i=r.length?parseInt(u.apply(void 0,r),10):0;e[t]===Rt&&t++;for(var a=[];rn(e[t]);)a.push(e[t++]);var o=a.length,s=o?parseInt(u.apply(void 0,a),10):0;(e[t]===$t||e[t]===Jt)&&t++;var c=1;(e[t]===Pt||e[t]===vt)&&(e[t]===vt&&(c=-1),t++);for(var l=[];rn(e[t]);)l.push(e[t++]);var d=l.length?parseInt(u.apply(void 0,l),10):0;return n*(i+s*10**-o)*10**(c*d)},yn={type:2},bn={type:3},xn={type:4},Sn={type:13},Cn={type:8},wn={type:21},Tn={type:9},En={type:10},Dn={type:11},On={type:12},kn={type:14},An={type:23},jn={type:1},Mn={type:25},Nn={type:24},Pn={type:26},Fn={type:27},In={type:28},Ln={type:29},Rn={type:31},zn={type:32},Bn=function(){function e(){this._value=[]}return e.prototype.write=function(e){this._value=this._value.concat(l(e))},e.prototype.read=function(){for(var e=[],t=this.consumeToken();t!==zn;)e.push(t),t=this.consumeToken();return e},e.prototype.consumeToken=function(){var e=this.consumeCodePoint();switch(e){case lt:return this.consumeStringToken(lt);case dt:var t=this.peekCodePoint(0),n=this.peekCodePoint(1),r=this.peekCodePoint(2);if(pn(t)||hn(n,r)){var i=gn(t,n,r)?tt:et,a=this.consumeName();return{type:5,value:a,flags:i}}break;case ft:if(this.peekCodePoint(0)===ut)return this.consumeCodePoint(),Sn;break;case mt:return this.consumeStringToken(mt);case ht:return yn;case gt:return bn;case Nt:if(this.peekCodePoint(0)===ut)return this.consumeCodePoint(),kn;break;case Pt:if(_n(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case Ft:return xn;case vt:var o=e,s=this.peekCodePoint(0),c=this.peekCodePoint(1);if(_n(o,s,c))return this.reconsumeCodePoint(e),this.consumeNumericToken();if(gn(o,s,c))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();if(s===vt&&c===xt)return this.consumeCodePoint(),this.consumeCodePoint(),Nn;break;case Rt:if(_n(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case at:if(this.peekCodePoint(0)===Nt)for(this.consumeCodePoint();;){var l=this.consumeCodePoint();if(l===Nt&&(l=this.consumeCodePoint(),l===at)||l===Gt)return this.consumeToken()}break;case It:return Pn;case Lt:return Fn;case bt:if(this.peekCodePoint(0)===yt&&this.peekCodePoint(1)===vt&&this.peekCodePoint(2)===vt)return this.consumeCodePoint(),this.consumeCodePoint(),Mn;break;case St:if(gn(this.peekCodePoint(0),this.peekCodePoint(1),this.peekCodePoint(2))){var a=this.consumeName();return{type:7,value:a}}break;case Ct:return In;case ot:if(hn(e,this.peekCodePoint(0)))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();break;case wt:return Ln;case Tt:if(this.peekCodePoint(0)===ut)return this.consumeCodePoint(),Cn;break;case Et:return Dn;case Ot:return On;case Xt:case tn:var d=this.peekCodePoint(0),f=this.peekCodePoint(1);return d===Pt&&(on(f)||f===Dt)&&(this.consumeCodePoint(),this.consumeUnicodeRangeToken()),this.reconsumeCodePoint(e),this.consumeIdentLikeToken();case kt:if(this.peekCodePoint(0)===ut)return this.consumeCodePoint(),Tn;if(this.peekCodePoint(0)===kt)return this.consumeCodePoint(),wn;break;case At:if(this.peekCodePoint(0)===ut)return this.consumeCodePoint(),En;break;case Gt:return zn}return dn(e)?(this.consumeWhiteSpace(),Rn):rn(e)?(this.reconsumeCodePoint(e),this.consumeNumericToken()):fn(e)?(this.reconsumeCodePoint(e),this.consumeIdentLikeToken()):{type:6,value:u(e)}},e.prototype.consumeCodePoint=function(){var e=this._value.shift();return e===void 0?-1:e},e.prototype.reconsumeCodePoint=function(e){this._value.unshift(e)},e.prototype.peekCodePoint=function(e){return e>=this._value.length?-1:this._value[e]},e.prototype.consumeUnicodeRangeToken=function(){for(var e=[],t=this.consumeCodePoint();on(t)&&e.length<6;)e.push(t),t=this.consumeCodePoint();for(var n=!1;t===Dt&&e.length<6;)e.push(t),t=this.consumeCodePoint(),n=!0;if(n){var r=parseInt(u.apply(void 0,e.map(function(e){return e===Dt?Kt:e})),16),i=parseInt(u.apply(void 0,e.map(function(e){return e===Dt?en:e})),16);return{type:30,start:r,end:i}}var a=parseInt(u.apply(void 0,e),16);if(this.peekCodePoint(0)===vt&&on(this.peekCodePoint(1))){this.consumeCodePoint(),t=this.consumeCodePoint();for(var o=[];on(t)&&o.length<6;)o.push(t),t=this.consumeCodePoint();var i=parseInt(u.apply(void 0,o),16);return{type:30,start:a,end:i}}else return{type:30,start:a,end:a}},e.prototype.consumeIdentLikeToken=function(){var e=this.consumeName();return e.toLowerCase()===`url`&&this.peekCodePoint(0)===ht?(this.consumeCodePoint(),this.consumeUrlToken()):this.peekCodePoint(0)===ht?(this.consumeCodePoint(),{type:19,value:e}):{type:20,value:e}},e.prototype.consumeUrlToken=function(){var e=[];if(this.consumeWhiteSpace(),this.peekCodePoint(0)===Gt)return{type:22,value:``};var t=this.peekCodePoint(0);if(t===mt||t===lt){var n=this.consumeStringToken(this.consumeCodePoint());return n.type===0&&(this.consumeWhiteSpace(),this.peekCodePoint(0)===Gt||this.peekCodePoint(0)===gt)?(this.consumeCodePoint(),{type:22,value:n.value}):(this.consumeBadUrlRemnants(),An)}for(;;){var r=this.consumeCodePoint();if(r===Gt||r===gt)return{type:22,value:u.apply(void 0,e)};if(dn(r))return this.consumeWhiteSpace(),this.peekCodePoint(0)===Gt||this.peekCodePoint(0)===gt?(this.consumeCodePoint(),{type:22,value:u.apply(void 0,e)}):(this.consumeBadUrlRemnants(),An);if(r===lt||r===mt||r===ht||mn(r))return this.consumeBadUrlRemnants(),An;if(r===ot)if(hn(r,this.peekCodePoint(0)))e.push(this.consumeEscapedCodePoint());else return this.consumeBadUrlRemnants(),An;else e.push(r)}},e.prototype.consumeWhiteSpace=function(){for(;dn(this.peekCodePoint(0));)this.consumeCodePoint()},e.prototype.consumeBadUrlRemnants=function(){for(;;){var e=this.consumeCodePoint();if(e===gt||e===Gt)return;hn(e,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}},e.prototype.consumeStringSlice=function(e){for(var t=5e4,n=``;e>0;){var r=Math.min(t,e);n+=u.apply(void 0,this._value.splice(0,r)),e-=r}return this._value.shift(),n},e.prototype.consumeStringToken=function(e){var t=``,n=0;do{var r=this._value[n];if(r===Gt||r===void 0||r===e)return t+=this.consumeStringSlice(n),{type:0,value:t};if(r===it)return this._value.splice(0,n),jn;if(r===ot){var i=this._value[n+1];i!==Gt&&i!==void 0&&(i===it?(t+=this.consumeStringSlice(n),n=-1,this._value.shift()):hn(r,i)&&(t+=this.consumeStringSlice(n),t+=u(this.consumeEscapedCodePoint()),n=-1))}n++}while(!0)},e.prototype.consumeNumber=function(){var e=[],t=nt,n=this.peekCodePoint(0);for((n===Pt||n===vt)&&e.push(this.consumeCodePoint());rn(this.peekCodePoint(0));)e.push(this.consumeCodePoint());n=this.peekCodePoint(0);var r=this.peekCodePoint(1);if(n===Rt&&rn(r))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=rt;rn(this.peekCodePoint(0));)e.push(this.consumeCodePoint());n=this.peekCodePoint(0),r=this.peekCodePoint(1);var i=this.peekCodePoint(2);if((n===$t||n===Jt)&&((r===Pt||r===vt)&&rn(i)||rn(r)))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=rt;rn(this.peekCodePoint(0));)e.push(this.consumeCodePoint());return[vn(e),t]},e.prototype.consumeNumericToken=function(){var e=this.consumeNumber(),t=e[0],n=e[1],r=this.peekCodePoint(0);return gn(r,this.peekCodePoint(1),this.peekCodePoint(2))?{type:15,number:t,flags:n,unit:this.consumeName()}:r===pt?(this.consumeCodePoint(),{type:16,number:t,flags:n}):{type:17,number:t,flags:n}},e.prototype.consumeEscapedCodePoint=function(){var e=this.consumeCodePoint();if(on(e)){for(var t=u(e);on(this.peekCodePoint(0))&&t.length<6;)t+=u(this.consumeCodePoint());dn(this.peekCodePoint(0))&&this.consumeCodePoint();var n=parseInt(t,16);return n===0||an(n)||n>1114111?Mt:n}return e===Gt?Mt:e},e.prototype.consumeName=function(){for(var e=``;;){var t=this.consumeCodePoint();if(pn(t))e+=u(t);else if(hn(t,this.peekCodePoint(0)))e+=u(this.consumeEscapedCodePoint());else return this.reconsumeCodePoint(t),e}},e}(),Vn=function(){function e(e){this._tokens=e}return e.create=function(t){var n=new Bn;return n.write(t),new e(n.read())},e.parseValue=function(t){return e.create(t).parseComponentValue()},e.parseValues=function(t){return e.create(t).parseComponentValues()},e.prototype.parseComponentValue=function(){for(var e=this.consumeToken();e.type===31;)e=this.consumeToken();if(e.type===32)throw SyntaxError(`Error parsing CSS component value, unexpected EOF`);this.reconsumeToken(e);var t=this.consumeComponentValue();do e=this.consumeToken();while(e.type===31);if(e.type===32)return t;throw SyntaxError(`Error parsing CSS component value, multiple values found when expecting only one`)},e.prototype.parseComponentValues=function(){for(var e=[];;){var t=this.consumeComponentValue();if(t.type===32)return e;e.push(t),e.push()}},e.prototype.consumeComponentValue=function(){var e=this.consumeToken();switch(e.type){case 11:case 28:case 2:return this.consumeSimpleBlock(e.type);case 19:return this.consumeFunction(e)}return e},e.prototype.consumeSimpleBlock=function(e){for(var t={type:e,values:[]},n=this.consumeToken();;){if(n.type===32||Xn(n,e))return t;this.reconsumeToken(n),t.values.push(this.consumeComponentValue()),n=this.consumeToken()}},e.prototype.consumeFunction=function(e){for(var t={name:e.value,values:[],type:18};;){var n=this.consumeToken();if(n.type===32||n.type===3)return t;this.reconsumeToken(n),t.values.push(this.consumeComponentValue())}},e.prototype.consumeToken=function(){var e=this._tokens.shift();return e===void 0?zn:e},e.prototype.reconsumeToken=function(e){this._tokens.unshift(e)},e}(),Hn=function(e){return e.type===15},Un=function(e){return e.type===17},Wn=function(e){return e.type===20},Gn=function(e){return e.type===0},Kn=function(e,t){return Wn(e)&&e.value===t},qn=function(e){return e.type!==31},Jn=function(e){return e.type!==31&&e.type!==4},Yn=function(e){var t=[],n=[];return e.forEach(function(e){if(e.type===4){if(n.length===0)throw Error(`Error parsing function args, zero tokens for arg`);t.push(n),n=[];return}e.type!==31&&n.push(e)}),n.length&&t.push(n),t},Xn=function(e,t){return t===11&&e.type===12||t===28&&e.type===29||t===2&&e.type===3},Zn=function(e){return e.type===17||e.type===15},Qn=function(e){return e.type===16||Zn(e)},$n=function(e){return e.length>1?[e[0],e[1]]:[e[0]]},er={type:17,number:0,flags:nt},tr={type:16,number:50,flags:nt},nr={type:16,number:100,flags:nt},rr=function(e,t,n){var r=e[0],i=e[1];return[ir(r,t),ir(i===void 0?r:i,n)]},ir=function(e,t){if(e.type===16)return e.number/100*t;if(Hn(e))switch(e.unit){case`rem`:case`em`:return 16*e.number;default:return e.number}return e.number},ar=`deg`,or=`grad`,sr=`rad`,cr=`turn`,lr={name:`angle`,parse:function(e,t){if(t.type===15)switch(t.unit){case ar:return Math.PI*t.number/180;case or:return Math.PI/200*t.number;case sr:return t.number;case cr:return Math.PI*2*t.number}throw Error(`Unsupported angle type`)}},ur=function(e){return e.type===15&&(e.unit===ar||e.unit===or||e.unit===sr||e.unit===cr)},dr=function(e){switch(e.filter(Wn).map(function(e){return e.value}).join(` `)){case`to bottom right`:case`to right bottom`:case`left top`:case`top left`:return[er,er];case`to top`:case`bottom`:return fr(0);case`to bottom left`:case`to left bottom`:case`right top`:case`top right`:return[er,nr];case`to right`:case`left`:return fr(90);case`to top left`:case`to left top`:case`right bottom`:case`bottom right`:return[nr,nr];case`to bottom`:case`top`:return fr(180);case`to top right`:case`to right top`:case`left bottom`:case`bottom left`:return[nr,er];case`to left`:case`right`:return fr(270)}return 0},fr=function(e){return Math.PI*e/180},pr={name:`color`,parse:function(e,t){if(t.type===18){var n=xr[t.name];if(n===void 0)throw Error(`Attempting to parse an unsupported color function "`+t.name+`"`);return n(e,t.values)}if(t.type===5){if(t.value.length===3){var r=t.value.substring(0,1),i=t.value.substring(1,2),a=t.value.substring(2,3);return gr(parseInt(r+r,16),parseInt(i+i,16),parseInt(a+a,16),1)}if(t.value.length===4){var r=t.value.substring(0,1),i=t.value.substring(1,2),a=t.value.substring(2,3),o=t.value.substring(3,4);return gr(parseInt(r+r,16),parseInt(i+i,16),parseInt(a+a,16),parseInt(o+o,16)/255)}if(t.value.length===6){var r=t.value.substring(0,2),i=t.value.substring(2,4),a=t.value.substring(4,6);return gr(parseInt(r,16),parseInt(i,16),parseInt(a,16),1)}if(t.value.length===8){var r=t.value.substring(0,2),i=t.value.substring(2,4),a=t.value.substring(4,6),o=t.value.substring(6,8);return gr(parseInt(r,16),parseInt(i,16),parseInt(a,16),parseInt(o,16)/255)}}if(t.type===20){var s=Cr[t.value.toUpperCase()];if(s!==void 0)return s}return Cr.TRANSPARENT}},mr=function(e){return(255&e)==0},hr=function(e){var t=255&e,n=255&e>>8,r=255&e>>16,i=255&e>>24;return t<255?`rgba(`+i+`,`+r+`,`+n+`,`+t/255+`)`:`rgb(`+i+`,`+r+`,`+n+`)`},gr=function(e,t,n,r){return(e<<24|t<<16|n<<8|Math.round(r*255)<<0)>>>0},_r=function(e,t){if(e.type===17)return e.number;if(e.type===16){var n=t===3?1:255;return t===3?e.number/100*n:Math.round(e.number/100*n)}return 0},vr=function(e,t){var n=t.filter(Jn);if(n.length===3){var r=n.map(_r),i=r[0],a=r[1],o=r[2];return gr(i,a,o,1)}if(n.length===4){var s=n.map(_r),i=s[0],a=s[1],o=s[2],c=s[3];return gr(i,a,o,c)}return 0};function yr(e,t,n){return n<0&&(n+=1),n>=1&&--n,n<1/6?(t-e)*n*6+e:n<1/2?t:n<2/3?(t-e)*6*(2/3-n)+e:e}var br=function(e,t){var n=t.filter(Jn),r=n[0],i=n[1],a=n[2],o=n[3],s=(r.type===17?fr(r.number):lr.parse(e,r))/(Math.PI*2),c=Qn(i)?i.number/100:0,l=Qn(a)?a.number/100:0,u=o!==void 0&&Qn(o)?ir(o,1):1;if(c===0)return gr(l*255,l*255,l*255,1);var d=l<=.5?l*(c+1):l+c-l*c,f=l*2-d,p=yr(f,d,s+1/3),m=yr(f,d,s),h=yr(f,d,s-1/3);return gr(p*255,m*255,h*255,u)},xr={hsl:br,hsla:br,rgb:vr,rgba:vr},Sr=function(e,t){return pr.parse(e,Vn.create(t).parseComponentValue())},Cr={ALICEBLUE:4042850303,ANTIQUEWHITE:4209760255,AQUA:16777215,AQUAMARINE:2147472639,AZURE:4043309055,BEIGE:4126530815,BISQUE:4293182719,BLACK:255,BLANCHEDALMOND:4293643775,BLUE:65535,BLUEVIOLET:2318131967,BROWN:2771004159,BURLYWOOD:3736635391,CADETBLUE:1604231423,CHARTREUSE:2147418367,CHOCOLATE:3530104575,CORAL:4286533887,CORNFLOWERBLUE:1687547391,CORNSILK:4294499583,CRIMSON:3692313855,CYAN:16777215,DARKBLUE:35839,DARKCYAN:9145343,DARKGOLDENROD:3095837695,DARKGRAY:2846468607,DARKGREEN:6553855,DARKGREY:2846468607,DARKKHAKI:3182914559,DARKMAGENTA:2332068863,DARKOLIVEGREEN:1433087999,DARKORANGE:4287365375,DARKORCHID:2570243327,DARKRED:2332033279,DARKSALMON:3918953215,DARKSEAGREEN:2411499519,DARKSLATEBLUE:1211993087,DARKSLATEGRAY:793726975,DARKSLATEGREY:793726975,DARKTURQUOISE:13554175,DARKVIOLET:2483082239,DEEPPINK:4279538687,DEEPSKYBLUE:12582911,DIMGRAY:1768516095,DIMGREY:1768516095,DODGERBLUE:512819199,FIREBRICK:2988581631,FLORALWHITE:4294635775,FORESTGREEN:579543807,FUCHSIA:4278255615,GAINSBORO:3705462015,GHOSTWHITE:4177068031,GOLD:4292280575,GOLDENROD:3668254975,GRAY:2155905279,GREEN:8388863,GREENYELLOW:2919182335,GREY:2155905279,HONEYDEW:4043305215,HOTPINK:4285117695,INDIANRED:3445382399,INDIGO:1258324735,IVORY:4294963455,KHAKI:4041641215,LAVENDER:3873897215,LAVENDERBLUSH:4293981695,LAWNGREEN:2096890111,LEMONCHIFFON:4294626815,LIGHTBLUE:2916673279,LIGHTCORAL:4034953471,LIGHTCYAN:3774873599,LIGHTGOLDENRODYELLOW:4210742015,LIGHTGRAY:3553874943,LIGHTGREEN:2431553791,LIGHTGREY:3553874943,LIGHTPINK:4290167295,LIGHTSALMON:4288707327,LIGHTSEAGREEN:548580095,LIGHTSKYBLUE:2278488831,LIGHTSLATEGRAY:2005441023,LIGHTSLATEGREY:2005441023,LIGHTSTEELBLUE:2965692159,LIGHTYELLOW:4294959359,LIME:16711935,LIMEGREEN:852308735,LINEN:4210091775,MAGENTA:4278255615,MAROON:2147483903,MEDIUMAQUAMARINE:1724754687,MEDIUMBLUE:52735,MEDIUMORCHID:3126187007,MEDIUMPURPLE:2473647103,MEDIUMSEAGREEN:1018393087,MEDIUMSLATEBLUE:2070474495,MEDIUMSPRINGGREEN:16423679,MEDIUMTURQUOISE:1221709055,MEDIUMVIOLETRED:3340076543,MIDNIGHTBLUE:421097727,MINTCREAM:4127193855,MISTYROSE:4293190143,MOCCASIN:4293178879,NAVAJOWHITE:4292783615,NAVY:33023,OLDLACE:4260751103,OLIVE:2155872511,OLIVEDRAB:1804477439,ORANGE:4289003775,ORANGERED:4282712319,ORCHID:3664828159,PALEGOLDENROD:4008225535,PALEGREEN:2566625535,PALETURQUOISE:2951671551,PALEVIOLETRED:3681588223,PAPAYAWHIP:4293907967,PEACHPUFF:4292524543,PERU:3448061951,PINK:4290825215,PLUM:3718307327,POWDERBLUE:2967529215,PURPLE:2147516671,REBECCAPURPLE:1714657791,RED:4278190335,ROSYBROWN:3163525119,ROYALBLUE:1097458175,SADDLEBROWN:2336560127,SALMON:4202722047,SANDYBROWN:4104413439,SEAGREEN:780883967,SEASHELL:4294307583,SIENNA:2689740287,SILVER:3233857791,SKYBLUE:2278484991,SLATEBLUE:1784335871,SLATEGRAY:1887473919,SLATEGREY:1887473919,SNOW:4294638335,SPRINGGREEN:16744447,STEELBLUE:1182971135,TAN:3535047935,TEAL:8421631,THISTLE:3636451583,TOMATO:4284696575,TRANSPARENT:0,TURQUOISE:1088475391,VIOLET:4001558271,WHEAT:4125012991,WHITE:4294967295,WHITESMOKE:4126537215,YELLOW:4294902015,YELLOWGREEN:2597139199},wr={name:`background-clip`,initialValue:`border-box`,prefix:!1,type:1,parse:function(e,t){return t.map(function(e){if(Wn(e))switch(e.value){case`padding-box`:return 1;case`content-box`:return 2}return 0})}},Tr={name:`background-color`,initialValue:`transparent`,prefix:!1,type:3,format:`color`},Er=function(e,t){var n=pr.parse(e,t[0]),r=t[1];return r&&Qn(r)?{color:n,stop:r}:{color:n,stop:null}},Dr=function(e,t){var n=e[0],r=e[e.length-1];n.stop===null&&(n.stop=er),r.stop===null&&(r.stop=nr);for(var i=[],a=0,o=0;o<e.length;o++){var s=e[o].stop;if(s!==null){var c=ir(s,t);c>a?i.push(c):i.push(a),a=c}else i.push(null)}for(var l=null,o=0;o<i.length;o++){var u=i[o];if(u===null)l===null&&(l=o);else if(l!==null){for(var d=o-l,f=(u-i[l-1])/(d+1),p=1;p<=d;p++)i[l+p-1]=f*p;l=null}}return e.map(function(e,n){return{color:e.color,stop:Math.max(Math.min(1,i[n]/t),0)}})},Or=function(e,t,n){var r=t/2,i=n/2,a=ir(e[0],t)-r,o=i-ir(e[1],n);return(Math.atan2(o,a)+Math.PI*2)%(Math.PI*2)},kr=function(e,t,n){var r=typeof e==`number`?e:Or(e,t,n),i=Math.abs(t*Math.sin(r))+Math.abs(n*Math.cos(r)),a=t/2,o=n/2,s=i/2,c=Math.sin(r-Math.PI/2)*s,l=Math.cos(r-Math.PI/2)*s;return[i,a-l,a+l,o-c,o+c]},Ar=function(e,t){return Math.sqrt(e*e+t*t)},jr=function(e,t,n,r,i){return[[0,0],[0,t],[e,0],[e,t]].reduce(function(e,t){var a=t[0],o=t[1],s=Ar(n-a,r-o);return(i?s<e.optimumDistance:s>e.optimumDistance)?{optimumCorner:t,optimumDistance:s}:e},{optimumDistance:i?1/0:-1/0,optimumCorner:null}).optimumCorner},Mr=function(e,t,n,r,i){var a=0,o=0;switch(e.size){case 0:e.shape===0?a=o=Math.min(Math.abs(t),Math.abs(t-r),Math.abs(n),Math.abs(n-i)):e.shape===1&&(a=Math.min(Math.abs(t),Math.abs(t-r)),o=Math.min(Math.abs(n),Math.abs(n-i)));break;case 2:if(e.shape===0)a=o=Math.min(Ar(t,n),Ar(t,n-i),Ar(t-r,n),Ar(t-r,n-i));else if(e.shape===1){var s=Math.min(Math.abs(n),Math.abs(n-i))/Math.min(Math.abs(t),Math.abs(t-r)),c=jr(r,i,t,n,!0),l=c[0],u=c[1];a=Ar(l-t,(u-n)/s),o=s*a}break;case 1:e.shape===0?a=o=Math.max(Math.abs(t),Math.abs(t-r),Math.abs(n),Math.abs(n-i)):e.shape===1&&(a=Math.max(Math.abs(t),Math.abs(t-r)),o=Math.max(Math.abs(n),Math.abs(n-i)));break;case 3:if(e.shape===0)a=o=Math.max(Ar(t,n),Ar(t,n-i),Ar(t-r,n),Ar(t-r,n-i));else if(e.shape===1){var s=Math.max(Math.abs(n),Math.abs(n-i))/Math.max(Math.abs(t),Math.abs(t-r)),d=jr(r,i,t,n,!1),l=d[0],u=d[1];a=Ar(l-t,(u-n)/s),o=s*a}break}return Array.isArray(e.size)&&(a=ir(e.size[0],r),o=e.size.length===2?ir(e.size[1],i):a),[a,o]},Nr=function(e,t){var n=fr(180),r=[];return Yn(t).forEach(function(t,i){if(i===0){var a=t[0];if(a.type===20&&a.value===`to`){n=dr(t);return}else if(ur(a)){n=lr.parse(e,a);return}}var o=Er(e,t);r.push(o)}),{angle:n,stops:r,type:1}},Pr=function(e,t){var n=fr(180),r=[];return Yn(t).forEach(function(t,i){if(i===0){var a=t[0];if(a.type===20&&[`top`,`left`,`right`,`bottom`].indexOf(a.value)!==-1){n=dr(t);return}else if(ur(a)){n=(lr.parse(e,a)+fr(270))%fr(360);return}}var o=Er(e,t);r.push(o)}),{angle:n,stops:r,type:1}},Fr=function(e,t){var n=fr(180),r=[],i=1;return Yn(t).forEach(function(t,n){var a=t[0];if(n===0){if(Wn(a)&&a.value===`linear`){i=1;return}else if(Wn(a)&&a.value===`radial`){i=2;return}}if(a.type===18){if(a.name===`from`){var o=pr.parse(e,a.values[0]);r.push({stop:er,color:o})}else if(a.name===`to`){var o=pr.parse(e,a.values[0]);r.push({stop:nr,color:o})}else if(a.name===`color-stop`){var s=a.values.filter(Jn);if(s.length===2){var o=pr.parse(e,s[1]),c=s[0];Un(c)&&r.push({stop:{type:16,number:c.number*100,flags:c.flags},color:o})}}}}),i===1?{angle:(n+fr(180))%fr(360),stops:r,type:i}:{size:3,shape:0,stops:r,position:[],type:i}},Ir=`closest-side`,Lr=`farthest-side`,Rr=`closest-corner`,zr=`farthest-corner`,Br=`circle`,G=`ellipse`,Vr=`cover`,Hr=`contain`,Ur=function(e,t){var n=0,r=3,i=[],a=[];return Yn(t).forEach(function(t,o){var s=!0;if(o===0){var c=!1;s=t.reduce(function(e,t){if(c)if(Wn(t))switch(t.value){case`center`:return a.push(tr),e;case`top`:case`left`:return a.push(er),e;case`right`:case`bottom`:return a.push(nr),e}else(Qn(t)||Zn(t))&&a.push(t);else if(Wn(t))switch(t.value){case Br:return n=0,!1;case G:return n=1,!1;case`at`:return c=!0,!1;case Ir:return r=0,!1;case Vr:case Lr:return r=1,!1;case Hr:case Rr:return r=2,!1;case zr:return r=3,!1}else if(Zn(t)||Qn(t))return Array.isArray(r)||(r=[]),r.push(t),!1;return e},s)}if(s){var l=Er(e,t);i.push(l)}}),{size:r,shape:n,stops:i,position:a,type:2}},Wr=function(e,t){var n=0,r=3,i=[],a=[];return Yn(t).forEach(function(t,o){var s=!0;if(o===0?s=t.reduce(function(e,t){if(Wn(t))switch(t.value){case`center`:return a.push(tr),!1;case`top`:case`left`:return a.push(er),!1;case`right`:case`bottom`:return a.push(nr),!1}else if(Qn(t)||Zn(t))return a.push(t),!1;return e},s):o===1&&(s=t.reduce(function(e,t){if(Wn(t))switch(t.value){case Br:return n=0,!1;case G:return n=1,!1;case Hr:case Ir:return r=0,!1;case Lr:return r=1,!1;case Rr:return r=2,!1;case Vr:case zr:return r=3,!1}else if(Zn(t)||Qn(t))return Array.isArray(r)||(r=[]),r.push(t),!1;return e},s)),s){var c=Er(e,t);i.push(c)}}),{size:r,shape:n,stops:i,position:a,type:2}},Gr=function(e){return e.type===1},K=function(e){return e.type===2},q={name:`image`,parse:function(e,t){if(t.type===22){var n={url:t.value,type:0};return e.cache.addImage(t.value),n}if(t.type===18){var r=qr[t.name];if(r===void 0)throw Error(`Attempting to parse an unsupported image function "`+t.name+`"`);return r(e,t.values)}throw Error(`Unsupported image type `+t.type)}};function Kr(e){return!(e.type===20&&e.value===`none`)&&(e.type!==18||!!qr[e.name])}var qr={"linear-gradient":Nr,"-moz-linear-gradient":Pr,"-ms-linear-gradient":Pr,"-o-linear-gradient":Pr,"-webkit-linear-gradient":Pr,"radial-gradient":Ur,"-moz-radial-gradient":Wr,"-ms-radial-gradient":Wr,"-o-radial-gradient":Wr,"-webkit-radial-gradient":Wr,"-webkit-gradient":Fr},Jr={name:`background-image`,initialValue:`none`,type:1,prefix:!1,parse:function(e,t){if(t.length===0)return[];var n=t[0];return n.type===20&&n.value===`none`?[]:t.filter(function(e){return Jn(e)&&Kr(e)}).map(function(t){return q.parse(e,t)})}},Yr={name:`background-origin`,initialValue:`border-box`,prefix:!1,type:1,parse:function(e,t){return t.map(function(e){if(Wn(e))switch(e.value){case`padding-box`:return 1;case`content-box`:return 2}return 0})}},Xr={name:`background-position`,initialValue:`0% 0%`,type:1,prefix:!1,parse:function(e,t){return Yn(t).map(function(e){return e.filter(Qn)}).map($n)}},Zr={name:`background-repeat`,initialValue:`repeat`,prefix:!1,type:1,parse:function(e,t){return Yn(t).map(function(e){return e.filter(Wn).map(function(e){return e.value}).join(` `)}).map(Qr)}},Qr=function(e){switch(e){case`no-repeat`:return 1;case`repeat-x`:case`repeat no-repeat`:return 2;case`repeat-y`:case`no-repeat repeat`:return 3;default:return 0}},$r;(function(e){e.AUTO=`auto`,e.CONTAIN=`contain`,e.COVER=`cover`})($r||={});var ei={name:`background-size`,initialValue:`0`,prefix:!1,type:1,parse:function(e,t){return Yn(t).map(function(e){return e.filter(ti)})}},ti=function(e){return Wn(e)||Qn(e)},ni=function(e){return{name:`border-`+e+`-color`,initialValue:`transparent`,prefix:!1,type:3,format:`color`}},ri=ni(`top`),ii=ni(`right`),ai=ni(`bottom`),oi=ni(`left`),si=function(e){return{name:`border-radius-`+e,initialValue:`0 0`,prefix:!1,type:1,parse:function(e,t){return $n(t.filter(Qn))}}},ci=si(`top-left`),li=si(`top-right`),ui=si(`bottom-right`),di=si(`bottom-left`),fi=function(e){return{name:`border-`+e+`-style`,initialValue:`solid`,prefix:!1,type:2,parse:function(e,t){switch(t){case`none`:return 0;case`dashed`:return 2;case`dotted`:return 3;case`double`:return 4}return 1}}},pi=fi(`top`),mi=fi(`right`),hi=fi(`bottom`),gi=fi(`left`),_i=function(e){return{name:`border-`+e+`-width`,initialValue:`0`,type:0,prefix:!1,parse:function(e,t){return Hn(t)?t.number:0}}},vi=_i(`top`),yi=_i(`right`),bi=_i(`bottom`),xi=_i(`left`),Si={name:`color`,initialValue:`transparent`,prefix:!1,type:3,format:`color`},Ci={name:`direction`,initialValue:`ltr`,prefix:!1,type:2,parse:function(e,t){switch(t){case`rtl`:return 1;default:return 0}}},wi={name:`display`,initialValue:`inline-block`,prefix:!1,type:1,parse:function(e,t){return t.filter(Wn).reduce(function(e,t){return e|Ti(t.value)},0)}},Ti=function(e){switch(e){case`block`:case`-webkit-box`:return 2;case`inline`:return 4;case`run-in`:return 8;case`flow`:return 16;case`flow-root`:return 32;case`table`:return 64;case`flex`:case`-webkit-flex`:return 128;case`grid`:case`-ms-grid`:return 256;case`ruby`:return 512;case`subgrid`:return 1024;case`list-item`:return 2048;case`table-row-group`:return 4096;case`table-header-group`:return 8192;case`table-footer-group`:return 16384;case`table-row`:return 32768;case`table-cell`:return 65536;case`table-column-group`:return 131072;case`table-column`:return 262144;case`table-caption`:return 524288;case`ruby-base`:return 1048576;case`ruby-text`:return 2097152;case`ruby-base-container`:return 4194304;case`ruby-text-container`:return 8388608;case`contents`:return 16777216;case`inline-block`:return 33554432;case`inline-list-item`:return 67108864;case`inline-table`:return 134217728;case`inline-flex`:return 268435456;case`inline-grid`:return 536870912}return 0},Ei={name:`float`,initialValue:`none`,prefix:!1,type:2,parse:function(e,t){switch(t){case`left`:return 1;case`right`:return 2;case`inline-start`:return 3;case`inline-end`:return 4}return 0}},Di={name:`letter-spacing`,initialValue:`0`,prefix:!1,type:0,parse:function(e,t){return t.type===20&&t.value===`normal`?0:t.type===17||t.type===15?t.number:0}},Oi;(function(e){e.NORMAL=`normal`,e.STRICT=`strict`})(Oi||={});var ki={name:`line-break`,initialValue:`normal`,prefix:!1,type:2,parse:function(e,t){switch(t){case`strict`:return Oi.STRICT;default:return Oi.NORMAL}}},Ai={name:`line-height`,initialValue:`normal`,prefix:!1,type:4},ji=function(e,t){return Wn(e)&&e.value===`normal`?1.2*t:e.type===17?t*e.number:Qn(e)?ir(e,t):t},Mi={name:`list-style-image`,initialValue:`none`,type:0,prefix:!1,parse:function(e,t){return t.type===20&&t.value===`none`?null:q.parse(e,t)}},Ni={name:`list-style-position`,initialValue:`outside`,prefix:!1,type:2,parse:function(e,t){switch(t){case`inside`:return 0;default:return 1}}},Pi={name:`list-style-type`,initialValue:`none`,prefix:!1,type:2,parse:function(e,t){switch(t){case`disc`:return 0;case`circle`:return 1;case`square`:return 2;case`decimal`:return 3;case`cjk-decimal`:return 4;case`decimal-leading-zero`:return 5;case`lower-roman`:return 6;case`upper-roman`:return 7;case`lower-greek`:return 8;case`lower-alpha`:return 9;case`upper-alpha`:return 10;case`arabic-indic`:return 11;case`armenian`:return 12;case`bengali`:return 13;case`cambodian`:return 14;case`cjk-earthly-branch`:return 15;case`cjk-heavenly-stem`:return 16;case`cjk-ideographic`:return 17;case`devanagari`:return 18;case`ethiopic-numeric`:return 19;case`georgian`:return 20;case`gujarati`:return 21;case`gurmukhi`:return 22;case`hebrew`:return 22;case`hiragana`:return 23;case`hiragana-iroha`:return 24;case`japanese-formal`:return 25;case`japanese-informal`:return 26;case`kannada`:return 27;case`katakana`:return 28;case`katakana-iroha`:return 29;case`khmer`:return 30;case`korean-hangul-formal`:return 31;case`korean-hanja-formal`:return 32;case`korean-hanja-informal`:return 33;case`lao`:return 34;case`lower-armenian`:return 35;case`malayalam`:return 36;case`mongolian`:return 37;case`myanmar`:return 38;case`oriya`:return 39;case`persian`:return 40;case`simp-chinese-formal`:return 41;case`simp-chinese-informal`:return 42;case`tamil`:return 43;case`telugu`:return 44;case`thai`:return 45;case`tibetan`:return 46;case`trad-chinese-formal`:return 47;case`trad-chinese-informal`:return 48;case`upper-armenian`:return 49;case`disclosure-open`:return 50;case`disclosure-closed`:return 51;default:return-1}}},Fi=function(e){return{name:`margin-`+e,initialValue:`0`,prefix:!1,type:4}},Ii=Fi(`top`),Li=Fi(`right`),Ri=Fi(`bottom`),zi=Fi(`left`),Bi={name:`overflow`,initialValue:`visible`,prefix:!1,type:1,parse:function(e,t){return t.filter(Wn).map(function(e){switch(e.value){case`hidden`:return 1;case`scroll`:return 2;case`clip`:return 3;case`auto`:return 4;default:return 0}})}},Vi={name:`overflow-wrap`,initialValue:`normal`,prefix:!1,type:2,parse:function(e,t){switch(t){case`break-word`:return`break-word`;default:return`normal`}}},Hi=function(e){return{name:`padding-`+e,initialValue:`0`,prefix:!1,type:3,format:`length-percentage`}},Ui=Hi(`top`),Wi=Hi(`right`),Gi=Hi(`bottom`),Ki=Hi(`left`),qi={name:`text-align`,initialValue:`left`,prefix:!1,type:2,parse:function(e,t){switch(t){case`right`:return 2;case`center`:case`justify`:return 1;default:return 0}}},Ji={name:`position`,initialValue:`static`,prefix:!1,type:2,parse:function(e,t){switch(t){case`relative`:return 1;case`absolute`:return 2;case`fixed`:return 3;case`sticky`:return 4}return 0}},Yi={name:`text-shadow`,initialValue:`none`,type:1,prefix:!1,parse:function(e,t){return t.length===1&&Kn(t[0],`none`)?[]:Yn(t).map(function(t){for(var n={color:Cr.TRANSPARENT,offsetX:er,offsetY:er,blur:er},r=0,i=0;i<t.length;i++){var a=t[i];Zn(a)?(r===0?n.offsetX=a:r===1?n.offsetY=a:n.blur=a,r++):n.color=pr.parse(e,a)}return n})}},Xi={name:`text-transform`,initialValue:`none`,prefix:!1,type:2,parse:function(e,t){switch(t){case`uppercase`:return 2;case`lowercase`:return 1;case`capitalize`:return 3}return 0}},Zi={name:`transform`,initialValue:`none`,prefix:!0,type:0,parse:function(e,t){if(t.type===20&&t.value===`none`)return null;if(t.type===18){var n=Qi[t.name];if(n===void 0)throw Error(`Attempting to parse an unsupported transform function "`+t.name+`"`);return n(t.values)}return null}},Qi={matrix:function(e){var t=e.filter(function(e){return e.type===17}).map(function(e){return e.number});return t.length===6?t:null},matrix3d:function(e){var t=e.filter(function(e){return e.type===17}).map(function(e){return e.number}),n=t[0],r=t[1];t[2],t[3];var i=t[4],a=t[5];t[6],t[7],t[8],t[9],t[10],t[11];var o=t[12],s=t[13];return t[14],t[15],t.length===16?[n,r,i,a,o,s]:null}},$i={type:16,number:50,flags:nt},ea=[$i,$i],ta={name:`transform-origin`,initialValue:`50% 50%`,prefix:!0,type:1,parse:function(e,t){var n=t.filter(Qn);return n.length===2?[n[0],n[1]]:ea}},na={name:`visible`,initialValue:`none`,prefix:!1,type:2,parse:function(e,t){switch(t){case`hidden`:return 1;case`collapse`:return 2;default:return 0}}},ra;(function(e){e.NORMAL=`normal`,e.BREAK_ALL=`break-all`,e.KEEP_ALL=`keep-all`})(ra||={});for(var ia={name:`word-break`,initialValue:`normal`,prefix:!1,type:2,parse:function(e,t){switch(t){case`break-all`:return ra.BREAK_ALL;case`keep-all`:return ra.KEEP_ALL;default:return ra.NORMAL}}},aa={name:`z-index`,initialValue:`auto`,prefix:!1,type:0,parse:function(e,t){if(t.type===20)return{auto:!0,order:0};if(Un(t))return{auto:!1,order:t.number};throw Error(`Invalid z-index number parsed`)}},oa={name:`time`,parse:function(e,t){if(t.type===15)switch(t.unit.toLowerCase()){case`s`:return 1e3*t.number;case`ms`:return t.number}throw Error(`Unsupported time type`)}},sa={name:`opacity`,initialValue:`1`,type:0,prefix:!1,parse:function(e,t){return Un(t)?t.number:1}},ca={name:`text-decoration-color`,initialValue:`transparent`,prefix:!1,type:3,format:`color`},la={name:`text-decoration-line`,initialValue:`none`,prefix:!1,type:1,parse:function(e,t){return t.filter(Wn).map(function(e){switch(e.value){case`underline`:return 1;case`overline`:return 2;case`line-through`:return 3;case`none`:return 4}return 0}).filter(function(e){return e!==0})}},ua={name:`font-family`,initialValue:``,prefix:!1,type:1,parse:function(e,t){var n=[],r=[];return t.forEach(function(e){switch(e.type){case 20:case 0:n.push(e.value);break;case 17:n.push(e.number.toString());break;case 4:r.push(n.join(` `)),n.length=0;break}}),n.length&&r.push(n.join(` `)),r.map(function(e){return e.indexOf(` `)===-1?e:`'`+e+`'`})}},da={name:`font-size`,initialValue:`0`,prefix:!1,type:3,format:`length`},fa={name:`font-weight`,initialValue:`normal`,type:0,prefix:!1,parse:function(e,t){if(Un(t))return t.number;if(Wn(t))switch(t.value){case`bold`:return 700;default:return 400}return 400}},pa={name:`font-variant`,initialValue:`none`,type:1,prefix:!1,parse:function(e,t){return t.filter(Wn).map(function(e){return e.value})}},ma={name:`font-style`,initialValue:`normal`,prefix:!1,type:2,parse:function(e,t){switch(t){case`oblique`:return`oblique`;case`italic`:return`italic`;default:return`normal`}}},ha=function(e,t){return(e&t)!==0},ga={name:`content`,initialValue:`none`,type:1,prefix:!1,parse:function(e,t){if(t.length===0)return[];var n=t[0];return n.type===20&&n.value===`none`?[]:t}},_a={name:`counter-increment`,initialValue:`none`,prefix:!0,type:1,parse:function(e,t){if(t.length===0)return null;var n=t[0];if(n.type===20&&n.value===`none`)return null;for(var r=[],i=t.filter(qn),a=0;a<i.length;a++){var o=i[a],s=i[a+1];if(o.type===20){var c=s&&Un(s)?s.number:1;r.push({counter:o.value,increment:c})}}return r}},va={name:`counter-reset`,initialValue:`none`,prefix:!0,type:1,parse:function(e,t){if(t.length===0)return[];for(var n=[],r=t.filter(qn),i=0;i<r.length;i++){var a=r[i],o=r[i+1];if(Wn(a)&&a.value!==`none`){var s=o&&Un(o)?o.number:0;n.push({counter:a.value,reset:s})}}return n}},ya={name:`duration`,initialValue:`0s`,prefix:!1,type:1,parse:function(e,t){return t.filter(Hn).map(function(t){return oa.parse(e,t)})}},ba={name:`quotes`,initialValue:`none`,prefix:!0,type:1,parse:function(e,t){if(t.length===0)return null;var n=t[0];if(n.type===20&&n.value===`none`)return null;var r=[],i=t.filter(Gn);if(i.length%2!=0)return null;for(var a=0;a<i.length;a+=2){var o=i[a].value,s=i[a+1].value;r.push({open:o,close:s})}return r}},xa=function(e,t,n){if(!e)return``;var r=e[Math.min(t,e.length-1)];return r?n?r.open:r.close:``},Sa={name:`box-shadow`,initialValue:`none`,type:1,prefix:!1,parse:function(e,t){return t.length===1&&Kn(t[0],`none`)?[]:Yn(t).map(function(t){for(var n={color:255,offsetX:er,offsetY:er,blur:er,spread:er,inset:!1},r=0,i=0;i<t.length;i++){var a=t[i];Kn(a,`inset`)?n.inset=!0:Zn(a)?(r===0?n.offsetX=a:r===1?n.offsetY=a:r===2?n.blur=a:n.spread=a,r++):n.color=pr.parse(e,a)}return n})}},Ca={name:`paint-order`,initialValue:`normal`,prefix:!1,type:1,parse:function(e,t){var n=[0,1,2],r=[];return t.filter(Wn).forEach(function(e){switch(e.value){case`stroke`:r.push(1);break;case`fill`:r.push(0);break;case`markers`:r.push(2);break}}),n.forEach(function(e){r.indexOf(e)===-1&&r.push(e)}),r}},wa={name:`-webkit-text-stroke-color`,initialValue:`currentcolor`,prefix:!1,type:3,format:`color`},Ta={name:`-webkit-text-stroke-width`,initialValue:`0`,type:0,prefix:!1,parse:function(e,t){return Hn(t)?t.number:0}},Ea=function(){function e(e,t){this.animationDuration=J(e,ya,t.animationDuration),this.backgroundClip=J(e,wr,t.backgroundClip),this.backgroundColor=J(e,Tr,t.backgroundColor),this.backgroundImage=J(e,Jr,t.backgroundImage),this.backgroundOrigin=J(e,Yr,t.backgroundOrigin),this.backgroundPosition=J(e,Xr,t.backgroundPosition),this.backgroundRepeat=J(e,Zr,t.backgroundRepeat),this.backgroundSize=J(e,ei,t.backgroundSize),this.borderTopColor=J(e,ri,t.borderTopColor),this.borderRightColor=J(e,ii,t.borderRightColor),this.borderBottomColor=J(e,ai,t.borderBottomColor),this.borderLeftColor=J(e,oi,t.borderLeftColor),this.borderTopLeftRadius=J(e,ci,t.borderTopLeftRadius),this.borderTopRightRadius=J(e,li,t.borderTopRightRadius),this.borderBottomRightRadius=J(e,ui,t.borderBottomRightRadius),this.borderBottomLeftRadius=J(e,di,t.borderBottomLeftRadius),this.borderTopStyle=J(e,pi,t.borderTopStyle),this.borderRightStyle=J(e,mi,t.borderRightStyle),this.borderBottomStyle=J(e,hi,t.borderBottomStyle),this.borderLeftStyle=J(e,gi,t.borderLeftStyle),this.borderTopWidth=J(e,vi,t.borderTopWidth),this.borderRightWidth=J(e,yi,t.borderRightWidth),this.borderBottomWidth=J(e,bi,t.borderBottomWidth),this.borderLeftWidth=J(e,xi,t.borderLeftWidth),this.boxShadow=J(e,Sa,t.boxShadow),this.color=J(e,Si,t.color),this.direction=J(e,Ci,t.direction),this.display=J(e,wi,t.display),this.float=J(e,Ei,t.cssFloat),this.fontFamily=J(e,ua,t.fontFamily),this.fontSize=J(e,da,t.fontSize),this.fontStyle=J(e,ma,t.fontStyle),this.fontVariant=J(e,pa,t.fontVariant),this.fontWeight=J(e,fa,t.fontWeight),this.letterSpacing=J(e,Di,t.letterSpacing),this.lineBreak=J(e,ki,t.lineBreak),this.lineHeight=J(e,Ai,t.lineHeight),this.listStyleImage=J(e,Mi,t.listStyleImage),this.listStylePosition=J(e,Ni,t.listStylePosition),this.listStyleType=J(e,Pi,t.listStyleType),this.marginTop=J(e,Ii,t.marginTop),this.marginRight=J(e,Li,t.marginRight),this.marginBottom=J(e,Ri,t.marginBottom),this.marginLeft=J(e,zi,t.marginLeft),this.opacity=J(e,sa,t.opacity);var n=J(e,Bi,t.overflow);this.overflowX=n[0],this.overflowY=n[+(n.length>1)],this.overflowWrap=J(e,Vi,t.overflowWrap),this.paddingTop=J(e,Ui,t.paddingTop),this.paddingRight=J(e,Wi,t.paddingRight),this.paddingBottom=J(e,Gi,t.paddingBottom),this.paddingLeft=J(e,Ki,t.paddingLeft),this.paintOrder=J(e,Ca,t.paintOrder),this.position=J(e,Ji,t.position),this.textAlign=J(e,qi,t.textAlign),this.textDecorationColor=J(e,ca,t.textDecorationColor??t.color),this.textDecorationLine=J(e,la,t.textDecorationLine??t.textDecoration),this.textShadow=J(e,Yi,t.textShadow),this.textTransform=J(e,Xi,t.textTransform),this.transform=J(e,Zi,t.transform),this.transformOrigin=J(e,ta,t.transformOrigin),this.visibility=J(e,na,t.visibility),this.webkitTextStrokeColor=J(e,wa,t.webkitTextStrokeColor),this.webkitTextStrokeWidth=J(e,Ta,t.webkitTextStrokeWidth),this.wordBreak=J(e,ia,t.wordBreak),this.zIndex=J(e,aa,t.zIndex)}return e.prototype.isVisible=function(){return this.display>0&&this.opacity>0&&this.visibility===0},e.prototype.isTransparent=function(){return mr(this.backgroundColor)},e.prototype.isTransformed=function(){return this.transform!==null},e.prototype.isPositioned=function(){return this.position!==0},e.prototype.isPositionedWithZIndex=function(){return this.isPositioned()&&!this.zIndex.auto},e.prototype.isFloating=function(){return this.float!==0},e.prototype.isInlineLevel=function(){return ha(this.display,4)||ha(this.display,33554432)||ha(this.display,268435456)||ha(this.display,536870912)||ha(this.display,67108864)||ha(this.display,134217728)},e}(),Da=function(){function e(e,t){this.content=J(e,ga,t.content),this.quotes=J(e,ba,t.quotes)}return e}(),Oa=function(){function e(e,t){this.counterIncrement=J(e,_a,t.counterIncrement),this.counterReset=J(e,va,t.counterReset)}return e}(),J=function(e,t,n){var r=new Bn,i=n==null?t.initialValue:n.toString();r.write(i);var a=new Vn(r.read());switch(t.type){case 2:var o=a.parseComponentValue();return t.parse(e,Wn(o)?o.value:t.initialValue);case 0:return t.parse(e,a.parseComponentValue());case 1:return t.parse(e,a.parseComponentValues());case 4:return a.parseComponentValue();case 3:switch(t.format){case`angle`:return lr.parse(e,a.parseComponentValue());case`color`:return pr.parse(e,a.parseComponentValue());case`image`:return q.parse(e,a.parseComponentValue());case`length`:var s=a.parseComponentValue();return Zn(s)?s:er;case`length-percentage`:var c=a.parseComponentValue();return Qn(c)?c:er;case`time`:return oa.parse(e,a.parseComponentValue())}break}},ka=`data-html2canvas-debug`,Aa=function(e){switch(e.getAttribute(ka)){case`all`:return 1;case`clone`:return 2;case`parse`:return 3;case`render`:return 4;default:return 0}},ja=function(e,t){var n=Aa(e);return n===1||t===n},Ma=function(){function e(e,t){if(this.context=e,this.textNodes=[],this.elements=[],this.flags=0,ja(t,3))debugger;this.styles=new Ea(e,window.getComputedStyle(t,null)),bs(t)&&(this.styles.animationDuration.some(function(e){return e>0})&&(t.style.animationDuration=`0s`),this.styles.transform!==null&&(t.style.transform=`none`)),this.bounds=s(this.context,t),ja(t,4)&&(this.flags|=16)}return e}(),Na=`AAAAAAAAAAAAEA4AGBkAAFAaAAACAAAAAAAIABAAGAAwADgACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAAQABIAEQATAAIABAACAAQAAgAEAAIABAAVABcAAgAEAAIABAACAAQAGAAaABwAHgAgACIAI4AlgAIABAAmwCjAKgAsAC2AL4AvQDFAMoA0gBPAVYBWgEIAAgACACMANoAYgFkAWwBdAF8AX0BhQGNAZUBlgGeAaMBlQGWAasBswF8AbsBwwF0AcsBYwHTAQgA2wG/AOMBdAF8AekB8QF0AfkB+wHiAHQBfAEIAAMC5gQIAAsCEgIIAAgAFgIeAggAIgIpAggAMQI5AkACygEIAAgASAJQAlgCYAIIAAgACAAKBQoFCgUTBRMFGQUrBSsFCAAIAAgACAAIAAgACAAIAAgACABdAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABoAmgCrwGvAQgAbgJ2AggAHgEIAAgACADnAXsCCAAIAAgAgwIIAAgACAAIAAgACACKAggAkQKZAggAPADJAAgAoQKkAqwCsgK6AsICCADJAggA0AIIAAgACAAIANYC3gIIAAgACAAIAAgACABAAOYCCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAkASoB+QIEAAgACAA8AEMCCABCBQgACABJBVAFCAAIAAgACAAIAAgACAAIAAgACABTBVoFCAAIAFoFCABfBWUFCAAIAAgACAAIAAgAbQUIAAgACAAIAAgACABzBXsFfQWFBYoFigWKBZEFigWKBYoFmAWfBaYFrgWxBbkFCAAIAAgACAAIAAgACAAIAAgACAAIAMEFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAMgFCADQBQgACAAIAAgACAAIAAgACAAIAAgACAAIAO4CCAAIAAgAiQAIAAgACABAAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAD0AggACAD8AggACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIANYFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAMDvwAIAAgAJAIIAAgACAAIAAgACAAIAAgACwMTAwgACAB9BOsEGwMjAwgAKwMyAwsFYgE3A/MEPwMIAEUDTQNRAwgAWQOsAGEDCAAIAAgACAAIAAgACABpAzQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFIQUoBSwFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABtAwgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABMAEwACAAIAAgACAAIABgACAAIAAgACAC/AAgACAAyAQgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACAAIAAwAAgACAAIAAgACAAIAAgACAAIAAAARABIAAgACAAIABQASAAIAAgAIABwAEAAjgCIABsAqAC2AL0AigDQAtwC+IJIQqVAZUBWQqVAZUBlQGVAZUBlQGrC5UBlQGVAZUBlQGVAZUBlQGVAXsKlQGVAbAK6wsrDGUMpQzlDJUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAfAKAAuZA64AtwCJALoC6ADwAAgAuACgA/oEpgO6AqsD+AAIAAgAswMIAAgACAAIAIkAuwP5AfsBwwPLAwgACAAIAAgACADRA9kDCAAIAOED6QMIAAgACAAIAAgACADuA/YDCAAIAP4DyQAIAAgABgQIAAgAXQAOBAgACAAIAAgACAAIABMECAAIAAgACAAIAAgACAD8AAQBCAAIAAgAGgQiBCoECAExBAgAEAEIAAgACAAIAAgACAAIAAgACAAIAAgACAA4BAgACABABEYECAAIAAgATAQYAQgAVAQIAAgACAAIAAgACAAIAAgACAAIAFoECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAOQEIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAB+BAcACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAEABhgSMBAgACAAIAAgAlAQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAwAEAAQABAADAAMAAwADAAQABAAEAAQABAAEAAQABHATAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAdQMIAAgACAAIAAgACAAIAMkACAAIAAgAfQMIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACFA4kDCAAIAAgACAAIAOcBCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAIcDCAAIAAgACAAIAAgACAAIAAgACAAIAJEDCAAIAAgACADFAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABgBAgAZgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAbAQCBXIECAAIAHkECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABAAJwEQACjBKoEsgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAC6BMIECAAIAAgACAAIAAgACABmBAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAxwQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAGYECAAIAAgAzgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBd0FXwUIAOIF6gXxBYoF3gT5BQAGCAaKBYoFigWKBYoFigWKBYoFigWKBYoFigXWBIoFigWKBYoFigWKBYoFigWKBYsFEAaKBYoFigWKBYoFigWKBRQGCACKBYoFigWKBQgACAAIANEECAAIABgGigUgBggAJgYIAC4GMwaKBYoF0wQ3Bj4GigWKBYoFigWKBYoFigWKBYoFigWKBYoFigUIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWLBf///////wQABAAEAAQABAAEAAQABAAEAAQAAwAEAAQAAgAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAQADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUAAAAFAAUAAAAFAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAQAAAAUABQAFAAUABQAFAAAAAAAFAAUAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAFAAUAAQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAAABwAHAAcAAAAHAAcABwAFAAEAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAcABwAFAAUAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAQABAAAAAAAAAAAAAAAFAAUABQAFAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAHAAcAAAAHAAcAAAAAAAUABQAHAAUAAQAHAAEABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwABAAUABQAFAAUAAAAAAAAAAAAAAAEAAQABAAEAAQABAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABQANAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAABQAHAAUABQAFAAAAAAAAAAcABQAFAAUABQAFAAQABAAEAAQABAAEAAQABAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUAAAAFAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAUAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAcABwAFAAcABwAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUABwAHAAUABQAFAAUAAAAAAAcABwAAAAAABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAAAAAAAAAAABQAFAAAAAAAFAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAFAAUABQAFAAUAAAAFAAUABwAAAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABwAFAAUABQAFAAAAAAAHAAcAAAAAAAcABwAFAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAAAAAAAAAHAAcABwAAAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAUABQAFAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAHAAcABQAHAAcAAAAFAAcABwAAAAcABwAFAAUAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAFAAcABwAFAAUABQAAAAUAAAAHAAcABwAHAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAHAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUAAAAFAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAUAAAAFAAUAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABwAFAAUABQAFAAUABQAAAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABQAFAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAFAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAHAAUABQAFAAUABQAFAAUABwAHAAcABwAHAAcABwAHAAUABwAHAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABwAHAAcABwAFAAUABwAHAAcAAAAAAAAAAAAHAAcABQAHAAcABwAHAAcABwAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAUABQAFAAUABQAFAAUAAAAFAAAABQAAAAAABQAFAAUABQAFAAUABQAFAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAUABQAFAAUABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABwAFAAcABwAHAAcABwAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAUABQAFAAUABwAHAAUABQAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABQAFAAcABwAHAAUABwAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAcABQAFAAUABQAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAAAAAABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAAAAAAAAAFAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAUABQAHAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAFAAUABQAFAAcABwAFAAUABwAHAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAcABwAFAAUABwAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABQAAAAAABQAFAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAcABwAAAAAAAAAAAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAcABwAFAAcABwAAAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAFAAUABQAAAAUABQAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABwAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAHAAcABQAHAAUABQAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAAABwAHAAAAAAAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAFAAUABwAFAAcABwAFAAcABQAFAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAAAAAABwAHAAcABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAFAAcABwAFAAUABQAFAAUABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAUABQAFAAcABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABQAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAAAAAAFAAUABwAHAAcABwAFAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAHAAUABQAFAAUABQAFAAUABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAABQAAAAUABQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAHAAcAAAAFAAUAAAAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABQAFAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAABQAFAAUABQAFAAUABQAAAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAFAAUABQAFAAUADgAOAA4ADgAOAA4ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAMAAwADAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkAAAAAAAAAAAAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAAAAAAAAAAAAsADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwACwAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAADgAOAA4AAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAAAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4AAAAOAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAAAAAAAAAAAA4AAAAOAAAAAAAAAAAADgAOAA4AAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAA=`,Pa=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Fa=typeof Uint8Array>`u`?[]:new Uint8Array(256),Ia=0;Ia<Pa.length;Ia++)Fa[Pa.charCodeAt(Ia)]=Ia;for(var La=function(e){var t=e.length*.75,n=e.length,r,i=0,a,o,s,c;e[e.length-1]===`=`&&(t--,e[e.length-2]===`=`&&t--);var l=typeof ArrayBuffer<`u`&&typeof Uint8Array<`u`&&Uint8Array.prototype.slice!==void 0?new ArrayBuffer(t):Array(t),u=Array.isArray(l)?l:new Uint8Array(l);for(r=0;r<n;r+=4)a=Fa[e.charCodeAt(r)],o=Fa[e.charCodeAt(r+1)],s=Fa[e.charCodeAt(r+2)],c=Fa[e.charCodeAt(r+3)],u[i++]=a<<2|o>>4,u[i++]=(o&15)<<4|s>>2,u[i++]=(s&3)<<6|c&63;return l},Ra=function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n.push(e[r+1]<<8|e[r]);return n},za=function(e){for(var t=e.length,n=[],r=0;r<t;r+=4)n.push(e[r+3]<<24|e[r+2]<<16|e[r+1]<<8|e[r]);return n},Ba=5,Va=11,Ha=2,Ua=Va-Ba,Wa=65536>>Ba,Ga=(1<<Ba)-1,Ka=Wa+(1024>>Ba)+32,qa=65536>>Va,Ja=(1<<Ua)-1,Ya=function(e,t,n){return e.slice?e.slice(t,n):new Uint16Array(Array.prototype.slice.call(e,t,n))},Xa=function(e,t,n){return e.slice?e.slice(t,n):new Uint32Array(Array.prototype.slice.call(e,t,n))},Za=function(e,t){var n=La(e),r=Array.isArray(n)?za(n):new Uint32Array(n),i=Array.isArray(n)?Ra(n):new Uint16Array(n),a=24,o=Ya(i,a/2,r[4]/2),s=r[5]===2?Ya(i,(a+r[4])/2):Xa(r,Math.ceil((a+r[4])/4));return new Qa(r[0],r[1],r[2],r[3],o,s)},Qa=function(){function e(e,t,n,r,i,a){this.initialValue=e,this.errorValue=t,this.highStart=n,this.highValueIndex=r,this.index=i,this.data=a}return e.prototype.get=function(e){var t;if(e>=0){if(e<55296||e>56319&&e<=65535)return t=this.index[e>>Ba],t=(t<<Ha)+(e&Ga),this.data[t];if(e<=65535)return t=this.index[Wa+(e-55296>>Ba)],t=(t<<Ha)+(e&Ga),this.data[t];if(e<this.highStart)return t=Ka-qa+(e>>Va),t=this.index[t],t+=e>>Ba&Ja,t=this.index[t],t=(t<<Ha)+(e&Ga),this.data[t];if(e<=1114111)return this.data[this.highValueIndex]}return this.errorValue},e}(),$a=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,eo=typeof Uint8Array>`u`?[]:new Uint8Array(256),to=0;to<$a.length;to++)eo[$a.charCodeAt(to)]=to;var no=1,ro=2,io=3,ao=4,oo=5,so=7,co=8,lo=9,uo=10,fo=11,po=12,mo=13,ho=14,go=15,_o=function(e){for(var t=[],n=0,r=e.length;n<r;){var i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<r){var a=e.charCodeAt(n++);(a&64512)==56320?t.push(((i&1023)<<10)+(a&1023)+65536):(t.push(i),n--)}else t.push(i)}return t},vo=function(){var e=[...arguments];if(String.fromCodePoint)return String.fromCodePoint.apply(String,e);var t=e.length;if(!t)return``;for(var n=[],r=-1,i=``;++r<t;){var a=e[r];a<=65535?n.push(a):(a-=65536,n.push((a>>10)+55296,a%1024+56320)),(r+1===t||n.length>16384)&&(i+=String.fromCharCode.apply(String,n),n.length=0)}return i},yo=Za(Na),bo=`×`,xo=`÷`,So=function(e){return yo.get(e)},Co=function(e,t,n){var r=n-2,i=t[r],a=t[n-1],o=t[n];if(a===ro&&o===io)return bo;if(a===ro||a===io||a===ao||o===ro||o===io||o===ao)return xo;if(a===co&&[co,lo,fo,po].indexOf(o)!==-1||(a===fo||a===lo)&&(o===lo||o===uo)||(a===po||a===uo)&&o===uo||o===mo||o===oo||o===so||a===no)return bo;if(a===mo&&o===ho){for(;i===oo;)i=t[--r];if(i===ho)return bo}if(a===go&&o===go){for(var s=0;i===go;)s++,i=t[--r];if(s%2==0)return bo}return xo},wo=function(e){var t=_o(e),n=t.length,r=0,i=0,a=t.map(So);return{next:function(){if(r>=n)return{done:!0,value:null};for(var e=bo;r<n&&(e=Co(t,a,++r))===bo;);if(e!==bo||r===n){var o=vo.apply(null,t.slice(i,r));return i=r,{value:o,done:!1}}return{done:!0,value:null}}}},To=function(e){for(var t=wo(e),n=[],r;!(r=t.next()).done;)r.value&&n.push(r.value.slice());return n},Eo=function(e){var t=123;if(e.createRange){var n=e.createRange();if(n.getBoundingClientRect){var r=e.createElement(`boundtest`);r.style.height=t+`px`,r.style.display=`block`,e.body.appendChild(r),n.selectNode(r);var i=n.getBoundingClientRect(),a=Math.round(i.height);if(e.body.removeChild(r),a===t)return!0}}return!1},Do=function(e){var t=e.createElement(`boundtest`);t.style.width=`50px`,t.style.display=`block`,t.style.fontSize=`12px`,t.style.letterSpacing=`0px`,t.style.wordSpacing=`0px`,e.body.appendChild(t);var n=e.createRange();t.innerHTML=typeof``.repeat==`function`?`👨`.repeat(10):``;var r=t.firstChild,i=l(r.data).map(function(e){return u(e)}),a=0,o={},s=i.every(function(e,t){n.setStart(r,a),n.setEnd(r,a+e.length);var i=n.getBoundingClientRect();a+=e.length;var s=i.x>o.x||i.y>o.y;return o=i,t===0||s});return e.body.removeChild(t),s},Oo=function(){return new Image().crossOrigin!==void 0},ko=function(){return typeof new XMLHttpRequest().responseType==`string`},Ao=function(e){var t=new Image,n=e.createElement(`canvas`),r=n.getContext(`2d`);if(!r)return!1;t.src=`data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>`;try{r.drawImage(t,0,0),n.toDataURL()}catch{return!1}return!0},jo=function(e){return e[0]===0&&e[1]===255&&e[2]===0&&e[3]===255},Mo=function(e){var t=e.createElement(`canvas`),n=100;t.width=n,t.height=n;var r=t.getContext(`2d`);if(!r)return Promise.reject(!1);r.fillStyle=`rgb(0, 255, 0)`,r.fillRect(0,0,n,n);var i=new Image,a=t.toDataURL();i.src=a;var o=No(n,n,0,0,i);return r.fillStyle=`red`,r.fillRect(0,0,n,n),Po(o).then(function(t){r.drawImage(t,0,0);var i=r.getImageData(0,0,n,n).data;r.fillStyle=`red`,r.fillRect(0,0,n,n);var o=e.createElement(`div`);return o.style.backgroundImage=`url(`+a+`)`,o.style.height=n+`px`,jo(i)?Po(No(n,n,0,0,o)):Promise.reject(!1)}).then(function(e){return r.drawImage(e,0,0),jo(r.getImageData(0,0,n,n).data)}).catch(function(){return!1})},No=function(e,t,n,r,i){var a=`http://www.w3.org/2000/svg`,o=document.createElementNS(a,`svg`),s=document.createElementNS(a,`foreignObject`);return o.setAttributeNS(null,`width`,e.toString()),o.setAttributeNS(null,`height`,t.toString()),s.setAttributeNS(null,`width`,`100%`),s.setAttributeNS(null,`height`,`100%`),s.setAttributeNS(null,`x`,n.toString()),s.setAttributeNS(null,`y`,r.toString()),s.setAttributeNS(null,`externalResourcesRequired`,`true`),o.appendChild(s),s.appendChild(i),o},Po=function(e){return new Promise(function(t,n){var r=new Image;r.onload=function(){return t(r)},r.onerror=n,r.src=`data:image/svg+xml;charset=utf-8,`+encodeURIComponent(new XMLSerializer().serializeToString(e))})},Fo={get SUPPORT_RANGE_BOUNDS(){var e=Eo(document);return Object.defineProperty(Fo,"SUPPORT_RANGE_BOUNDS",{value:e}),e},get SUPPORT_WORD_BREAKING(){var e=Fo.SUPPORT_RANGE_BOUNDS&&Do(document);return Object.defineProperty(Fo,"SUPPORT_WORD_BREAKING",{value:e}),e},get SUPPORT_SVG_DRAWING(){var e=Ao(document);return Object.defineProperty(Fo,"SUPPORT_SVG_DRAWING",{value:e}),e},get SUPPORT_FOREIGNOBJECT_DRAWING(){var e=typeof Array.from==`function`&&typeof window.fetch==`function`?Mo(document):Promise.resolve(!1);return Object.defineProperty(Fo,"SUPPORT_FOREIGNOBJECT_DRAWING",{value:e}),e},get SUPPORT_CORS_IMAGES(){var e=Oo();return Object.defineProperty(Fo,"SUPPORT_CORS_IMAGES",{value:e}),e},get SUPPORT_RESPONSE_TYPE(){var e=ko();return Object.defineProperty(Fo,"SUPPORT_RESPONSE_TYPE",{value:e}),e},get SUPPORT_CORS_XHR(){var e=`withCredentials`in new XMLHttpRequest;return Object.defineProperty(Fo,"SUPPORT_CORS_XHR",{value:e}),e},get SUPPORT_NATIVE_TEXT_SEGMENTATION(){var e=!!(typeof Intl<`u`&&Intl.Segmenter);return Object.defineProperty(Fo,"SUPPORT_NATIVE_TEXT_SEGMENTATION",{value:e}),e}},Io=function(){function e(e,t){this.text=e,this.bounds=t}return e}(),Lo=function(e,t,n,r){var i=Ho(t,n),a=[],s=0;return i.forEach(function(t){if(n.textDecorationLine.length||t.trim().length>0)if(Fo.SUPPORT_RANGE_BOUNDS){var i=zo(r,s,t.length).getClientRects();if(i.length>1){var c=Bo(t),l=0;c.forEach(function(t){a.push(new Io(t,o.fromDOMRectList(e,zo(r,l+s,t.length).getClientRects()))),l+=t.length})}else a.push(new Io(t,o.fromDOMRectList(e,i)))}else{var u=r.splitText(t.length);a.push(new Io(t,Ro(e,r))),r=u}else Fo.SUPPORT_RANGE_BOUNDS||(r=r.splitText(t.length));s+=t.length}),a},Ro=function(e,t){var n=t.ownerDocument;if(n){var r=n.createElement(`html2canvaswrapper`);r.appendChild(t.cloneNode(!0));var i=t.parentNode;if(i){i.replaceChild(r,t);var a=s(e,r);return r.firstChild&&i.replaceChild(r.firstChild,r),a}}return o.EMPTY},zo=function(e,t,n){var r=e.ownerDocument;if(!r)throw Error(`Node has no owner document`);var i=r.createRange();return i.setStart(e,t),i.setEnd(e,t+n),i},Bo=function(e){if(Fo.SUPPORT_NATIVE_TEXT_SEGMENTATION){var t=new Intl.Segmenter(void 0,{granularity:`grapheme`});return Array.from(t.segment(e)).map(function(e){return e.segment})}return To(e)},Vo=function(e,t){if(Fo.SUPPORT_NATIVE_TEXT_SEGMENTATION){var n=new Intl.Segmenter(void 0,{granularity:`word`});return Array.from(n.segment(e)).map(function(e){return e.segment})}return Wo(e,t)},Ho=function(e,t){return t.letterSpacing===0?Vo(e,t):Bo(e)},Uo=[32,160,4961,65792,65793,4153,4241],Wo=function(e,t){for(var n=$e(e,{lineBreak:t.lineBreak,wordBreak:t.overflowWrap===`break-word`?`break-word`:t.wordBreak}),r=[],i,a=function(){if(i.value){var e=l(i.value.slice()),t=``;e.forEach(function(e){Uo.indexOf(e)===-1?t+=u(e):(t.length&&r.push(t),r.push(u(e)),t=``)}),t.length&&r.push(t)}};!(i=n.next()).done;)a();return r},Go=function(){function e(e,t,n){this.text=Ko(t.data,n.textTransform),this.textBounds=Lo(e,this.text,n,t)}return e}(),Ko=function(e,t){switch(t){case 1:return e.toLowerCase();case 3:return e.replace(qo,Jo);case 2:return e.toUpperCase();default:return e}},qo=/(^|\s|:|-|\(|\))([a-z])/g,Jo=function(e,t,n){return e.length>0?t+n.toUpperCase():e},Yo=function(e){t(n,e);function n(t,n){var r=e.call(this,t,n)||this;return r.src=n.currentSrc||n.src,r.intrinsicWidth=n.naturalWidth,r.intrinsicHeight=n.naturalHeight,r.context.cache.addImage(r.src),r}return n}(Ma),Xo=function(e){t(n,e);function n(t,n){var r=e.call(this,t,n)||this;return r.canvas=n,r.intrinsicWidth=n.width,r.intrinsicHeight=n.height,r}return n}(Ma),Zo=function(e){t(n,e);function n(t,n){var r=e.call(this,t,n)||this,i=new XMLSerializer,a=s(t,n);return n.setAttribute(`width`,a.width+`px`),n.setAttribute(`height`,a.height+`px`),r.svg=`data:image/svg+xml,`+encodeURIComponent(i.serializeToString(n)),r.intrinsicWidth=n.width.baseVal.value,r.intrinsicHeight=n.height.baseVal.value,r.context.cache.addImage(r.svg),r}return n}(Ma),Qo=function(e){t(n,e);function n(t,n){var r=e.call(this,t,n)||this;return r.value=n.value,r}return n}(Ma),$o=function(e){t(n,e);function n(t,n){var r=e.call(this,t,n)||this;return r.start=n.start,r.reversed=typeof n.reversed==`boolean`&&n.reversed===!0,r}return n}(Ma),es=[{type:15,flags:0,unit:`px`,number:3}],ts=[{type:16,flags:0,number:50}],ns=function(e){return e.width>e.height?new o(e.left+(e.width-e.height)/2,e.top,e.height,e.height):e.width<e.height?new o(e.left,e.top+(e.height-e.width)/2,e.width,e.width):e},rs=function(e){var t=e.type===os?Array(e.value.length+1).join(`•`):e.value;return t.length===0?e.placeholder||``:t},is=`checkbox`,as=`radio`,os=`password`,ss=707406591,cs=function(e){t(n,e);function n(t,n){var r=e.call(this,t,n)||this;switch(r.type=n.type.toLowerCase(),r.checked=n.checked,r.value=rs(n),(r.type===is||r.type===as)&&(r.styles.backgroundColor=3739148031,r.styles.borderTopColor=r.styles.borderRightColor=r.styles.borderBottomColor=r.styles.borderLeftColor=2779096575,r.styles.borderTopWidth=r.styles.borderRightWidth=r.styles.borderBottomWidth=r.styles.borderLeftWidth=1,r.styles.borderTopStyle=r.styles.borderRightStyle=r.styles.borderBottomStyle=r.styles.borderLeftStyle=1,r.styles.backgroundClip=[0],r.styles.backgroundOrigin=[0],r.bounds=ns(r.bounds)),r.type){case is:r.styles.borderTopRightRadius=r.styles.borderTopLeftRadius=r.styles.borderBottomRightRadius=r.styles.borderBottomLeftRadius=es;break;case as:r.styles.borderTopRightRadius=r.styles.borderTopLeftRadius=r.styles.borderBottomRightRadius=r.styles.borderBottomLeftRadius=ts;break}return r}return n}(Ma),ls=function(e){t(n,e);function n(t,n){var r=e.call(this,t,n)||this,i=n.options[n.selectedIndex||0];return r.value=i&&i.text||``,r}return n}(Ma),us=function(e){t(n,e);function n(t,n){var r=e.call(this,t,n)||this;return r.value=n.value,r}return n}(Ma),ds=function(e){t(n,e);function n(t,n){var r=e.call(this,t,n)||this;r.src=n.src,r.width=parseInt(n.width,10)||0,r.height=parseInt(n.height,10)||0,r.backgroundColor=r.styles.backgroundColor;try{if(n.contentWindow&&n.contentWindow.document&&n.contentWindow.document.documentElement){r.tree=hs(t,n.contentWindow.document.documentElement);var i=n.contentWindow.document.documentElement?Sr(t,getComputedStyle(n.contentWindow.document.documentElement).backgroundColor):Cr.TRANSPARENT,a=n.contentWindow.document.body?Sr(t,getComputedStyle(n.contentWindow.document.body).backgroundColor):Cr.TRANSPARENT;r.backgroundColor=mr(i)?mr(a)?r.styles.backgroundColor:a:i}}catch{}return r}return n}(Ma),fs=[`OL`,`UL`,`MENU`],ps=function(e,t,n,r){for(var i=t.firstChild,a=void 0;i;i=a)if(a=i.nextSibling,vs(i)&&i.data.trim().length>0)n.textNodes.push(new Go(e,i,n.styles));else if(ys(i))if(Is(i)&&i.assignedNodes)i.assignedNodes().forEach(function(t){return ps(e,t,n,r)});else{var o=ms(e,i);o.styles.isVisible()&&(gs(i,o,r)?o.flags|=4:_s(o.styles)&&(o.flags|=2),fs.indexOf(i.tagName)!==-1&&(o.flags|=8),n.elements.push(o),i.slot,i.shadowRoot?ps(e,i.shadowRoot,o,r):!Ps(i)&&!Es(i)&&!Fs(i)&&ps(e,i,o,r))}},ms=function(e,t){return As(t)?new Yo(e,t):Os(t)?new Xo(e,t):Es(t)?new Zo(e,t):Ss(t)?new Qo(e,t):Cs(t)?new $o(e,t):ws(t)?new cs(e,t):Fs(t)?new ls(e,t):Ps(t)?new us(e,t):js(t)?new ds(e,t):new Ma(e,t)},hs=function(e,t){var n=ms(e,t);return n.flags|=4,ps(e,t,n,n),n},gs=function(e,t,n){return t.styles.isPositionedWithZIndex()||t.styles.opacity<1||t.styles.isTransformed()||Ds(e)&&n.styles.isTransparent()},_s=function(e){return e.isPositioned()||e.isFloating()},vs=function(e){return e.nodeType===Node.TEXT_NODE},ys=function(e){return e.nodeType===Node.ELEMENT_NODE},bs=function(e){return ys(e)&&e.style!==void 0&&!xs(e)},xs=function(e){return typeof e.className==`object`},Ss=function(e){return e.tagName===`LI`},Cs=function(e){return e.tagName===`OL`},ws=function(e){return e.tagName===`INPUT`},Ts=function(e){return e.tagName===`HTML`},Es=function(e){return e.tagName===`svg`},Ds=function(e){return e.tagName===`BODY`},Os=function(e){return e.tagName===`CANVAS`},ks=function(e){return e.tagName===`VIDEO`},As=function(e){return e.tagName===`IMG`},js=function(e){return e.tagName===`IFRAME`},Ms=function(e){return e.tagName===`STYLE`},Ns=function(e){return e.tagName===`SCRIPT`},Ps=function(e){return e.tagName===`TEXTAREA`},Fs=function(e){return e.tagName===`SELECT`},Is=function(e){return e.tagName===`SLOT`},Ls=function(e){return e.tagName.indexOf(`-`)>0},Rs=function(){function e(){this.counters={}}return e.prototype.getCounterValue=function(e){var t=this.counters[e];return t&&t.length?t[t.length-1]:1},e.prototype.getCounterValues=function(e){return this.counters[e]||[]},e.prototype.pop=function(e){var t=this;e.forEach(function(e){return t.counters[e].pop()})},e.prototype.parse=function(e){var t=this,n=e.counterIncrement,r=e.counterReset,i=!0;n!==null&&n.forEach(function(e){var n=t.counters[e.counter];n&&e.increment!==0&&(i=!1,n.length||n.push(1),n[Math.max(0,n.length-1)]+=e.increment)});var a=[];return i&&r.forEach(function(e){var n=t.counters[e.counter];a.push(e.counter),n||=t.counters[e.counter]=[],n.push(e.reset)}),a},e}(),zs={integers:[1e3,900,500,400,100,90,50,40,10,9,5,4,1],values:[`M`,`CM`,`D`,`CD`,`C`,`XC`,`L`,`XL`,`X`,`IX`,`V`,`IV`,`I`]},Bs={integers:[9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:`Ք.Փ.Ւ.Ց.Ր.Տ.Վ.Ս.Ռ.Ջ.Պ.Չ.Ո.Շ.Ն.Յ.Մ.Ճ.Ղ.Ձ.Հ.Կ.Ծ.Խ.Լ.Ի.Ժ.Թ.Ը.Է.Զ.Ե.Դ.Գ.Բ.Ա`.split(`.`)},Vs={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,400,300,200,100,90,80,70,60,50,40,30,20,19,18,17,16,15,10,9,8,7,6,5,4,3,2,1],values:`י׳.ט׳.ח׳.ז׳.ו׳.ה׳.ד׳.ג׳.ב׳.א׳.ת.ש.ר.ק.צ.פ.ע.ס.נ.מ.ל.כ.יט.יח.יז.טז.טו.י.ט.ח.ז.ו.ה.ד.ג.ב.א`.split(`.`)},Hs={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:`ჵ.ჰ.ჯ.ჴ.ხ.ჭ.წ.ძ.ც.ჩ.შ.ყ.ღ.ქ.ფ.ჳ.ტ.ს.რ.ჟ.პ.ო.ჲ.ნ.მ.ლ.კ.ი.თ.ჱ.ზ.ვ.ე.დ.გ.ბ.ა`.split(`.`)},Us=function(e,t,n,r,i,a){return e<t||e>n?nc(e,i,a.length>0):r.integers.reduce(function(t,n,i){for(;e>=n;)e-=n,t+=r.values[i];return t},``)+a},Ws=function(e,t,n,r){var i=``;do n||e--,i=r(e)+i,e/=t;while(e*t>=t);return i},Gs=function(e,t,n,r,i){var a=n-t+1;return(e<0?`-`:``)+(Ws(Math.abs(e),a,r,function(e){return u(Math.floor(e%a)+t)})+i)},Ks=function(e,t,n){n===void 0&&(n=`. `);var r=t.length;return Ws(Math.abs(e),r,!1,function(e){return t[Math.floor(e%r)]})+n},qs=1,Js=2,Ys=4,Xs=8,Zs=function(e,t,n,r,i,a){if(e<-9999||e>9999)return nc(e,4,i.length>0);var o=Math.abs(e),s=i;if(o===0)return t[0]+s;for(var c=0;o>0&&c<=4;c++){var l=o%10;l===0&&ha(a,qs)&&s!==``?s=t[l]+s:l>1||l===1&&c===0||l===1&&c===1&&ha(a,Js)||l===1&&c===1&&ha(a,Ys)&&e>100||l===1&&c>1&&ha(a,Xs)?s=t[l]+(c>0?n[c-1]:``)+s:l===1&&c>0&&(s=n[c-1]+s),o=Math.floor(o/10)}return(e<0?r:``)+s},Qs=`十百千萬`,$s=`拾佰仟萬`,ec=`マイナス`,tc=`마이너스`,nc=function(e,t,n){var r=n?`. `:``,i=n?`、`:``,a=n?`, `:``,o=n?` `:``;switch(t){case 0:return`•`+o;case 1:return`◦`+o;case 2:return`◾`+o;case 5:var s=Gs(e,48,57,!0,r);return s.length<4?`0`+s:s;case 4:return Ks(e,`〇一二三四五六七八九`,i);case 6:return Us(e,1,3999,zs,3,r).toLowerCase();case 7:return Us(e,1,3999,zs,3,r);case 8:return Gs(e,945,969,!1,r);case 9:return Gs(e,97,122,!1,r);case 10:return Gs(e,65,90,!1,r);case 11:return Gs(e,1632,1641,!0,r);case 12:case 49:return Us(e,1,9999,Bs,3,r);case 35:return Us(e,1,9999,Bs,3,r).toLowerCase();case 13:return Gs(e,2534,2543,!0,r);case 14:case 30:return Gs(e,6112,6121,!0,r);case 15:return Ks(e,`子丑寅卯辰巳午未申酉戌亥`,i);case 16:return Ks(e,`甲乙丙丁戊己庚辛壬癸`,i);case 17:case 48:return Zs(e,`零一二三四五六七八九`,Qs,`負`,i,Js|Ys|Xs);case 47:return Zs(e,`零壹貳參肆伍陸柒捌玖`,$s,`負`,i,qs|Js|Ys|Xs);case 42:return Zs(e,`零一二三四五六七八九`,Qs,`负`,i,Js|Ys|Xs);case 41:return Zs(e,`零壹贰叁肆伍陆柒捌玖`,$s,`负`,i,qs|Js|Ys|Xs);case 26:return Zs(e,`〇一二三四五六七八九`,`十百千万`,ec,i,0);case 25:return Zs(e,`零壱弐参四伍六七八九`,`拾百千万`,ec,i,qs|Js|Ys);case 31:return Zs(e,`영일이삼사오육칠팔구`,`십백천만`,tc,a,qs|Js|Ys);case 33:return Zs(e,`零一二三四五六七八九`,`十百千萬`,tc,a,0);case 32:return Zs(e,`零壹貳參四五六七八九`,`拾百千`,tc,a,qs|Js|Ys);case 18:return Gs(e,2406,2415,!0,r);case 20:return Us(e,1,19999,Hs,3,r);case 21:return Gs(e,2790,2799,!0,r);case 22:return Gs(e,2662,2671,!0,r);case 22:return Us(e,1,10999,Vs,3,r);case 23:return Ks(e,`あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん`);case 24:return Ks(e,`いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす`);case 27:return Gs(e,3302,3311,!0,r);case 28:return Ks(e,`アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン`,i);case 29:return Ks(e,`イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス`,i);case 34:return Gs(e,3792,3801,!0,r);case 37:return Gs(e,6160,6169,!0,r);case 38:return Gs(e,4160,4169,!0,r);case 39:return Gs(e,2918,2927,!0,r);case 40:return Gs(e,1776,1785,!0,r);case 43:return Gs(e,3046,3055,!0,r);case 44:return Gs(e,3174,3183,!0,r);case 45:return Gs(e,3664,3673,!0,r);case 46:return Gs(e,3872,3881,!0,r);default:return Gs(e,48,57,!0,r)}},rc=`data-html2canvas-ignore`,ic=function(){function e(e,t,n){if(this.context=e,this.options=n,this.scrolledElements=[],this.referenceElement=t,this.counters=new Rs,this.quoteDepth=0,!t.ownerDocument)throw Error(`Cloned element does not have an owner document`);this.documentElement=this.cloneNode(t.ownerDocument.documentElement,!1)}return e.prototype.toIFrame=function(e,t){var n=this,a=oc(e,t);if(!a.contentWindow)return Promise.reject(`Unable to find iframe window`);var o=e.defaultView.pageXOffset,s=e.defaultView.pageYOffset,c=a.contentWindow,l=c.document,u=lc(a).then(function(){return r(n,void 0,void 0,function(){var e,n;return i(this,function(r){switch(r.label){case 0:return this.scrolledElements.forEach(mc),c&&(c.scrollTo(t.left,t.top),/(iPad|iPhone|iPod)/g.test(navigator.userAgent)&&(c.scrollY!==t.top||c.scrollX!==t.left)&&(this.context.logger.warn(`Unable to restore scroll position for cloned document`),this.context.windowBounds=this.context.windowBounds.add(c.scrollX-t.left,c.scrollY-t.top,0,0))),e=this.options.onclone,n=this.clonedReferenceElement,n===void 0?[2,Promise.reject(`Error finding the `+this.referenceElement.nodeName+` in the cloned document`)]:l.fonts&&l.fonts.ready?[4,l.fonts.ready]:[3,2];case 1:r.sent(),r.label=2;case 2:return/(AppleWebKit)/g.test(navigator.userAgent)?[4,cc(l)]:[3,4];case 3:r.sent(),r.label=4;case 4:return typeof e==`function`?[2,Promise.resolve().then(function(){return e(l,n)}).then(function(){return a})]:[2,a]}})})});return l.open(),l.write(fc(document.doctype)+`<html></html>`),pc(this.referenceElement.ownerDocument,o,s),l.replaceChild(l.adoptNode(this.documentElement),l.documentElement),l.close(),u},e.prototype.createElementClone=function(e){if(ja(e,2))debugger;if(Os(e))return this.createCanvasClone(e);if(ks(e))return this.createVideoClone(e);if(Ms(e))return this.createStyleClone(e);var t=e.cloneNode(!1);return As(t)&&(As(e)&&e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=``),t.loading===`lazy`&&(t.loading=`eager`)),Ls(t)?this.createCustomElementClone(t):t},e.prototype.createCustomElementClone=function(e){var t=document.createElement(`html2canvascustomelement`);return dc(e.style,t),t},e.prototype.createStyleClone=function(e){try{var t=e.sheet;if(t&&t.cssRules){var n=[].slice.call(t.cssRules,0).reduce(function(e,t){return t&&typeof t.cssText==`string`?e+t.cssText:e},``),r=e.cloneNode(!1);return r.textContent=n,r}}catch(e){if(this.context.logger.error(`Unable to access cssRules property`,e),e.name!==`SecurityError`)throw e}return e.cloneNode(!1)},e.prototype.createCanvasClone=function(e){if(this.options.inlineImages&&e.ownerDocument){var t=e.ownerDocument.createElement(`img`);try{return t.src=e.toDataURL(),t}catch{this.context.logger.info(`Unable to inline canvas contents, canvas is tainted`,e)}}var n=e.cloneNode(!1);try{n.width=e.width,n.height=e.height;var r=e.getContext(`2d`),i=n.getContext(`2d`);if(i)if(!this.options.allowTaint&&r)i.putImageData(r.getImageData(0,0,e.width,e.height),0,0);else{var a=e.getContext(`webgl2`)??e.getContext(`webgl`);a&&a.getContextAttributes()?.preserveDrawingBuffer===!1&&this.context.logger.warn(`Unable to clone WebGL context as it has preserveDrawingBuffer=false`,e),i.drawImage(e,0,0)}return n}catch{this.context.logger.info(`Unable to clone canvas as it is tainted`,e)}return n},e.prototype.createVideoClone=function(e){var t=e.ownerDocument.createElement(`canvas`);t.width=e.offsetWidth,t.height=e.offsetHeight;var n=t.getContext(`2d`);try{return n&&(n.drawImage(e,0,0,t.width,t.height),this.options.allowTaint||n.getImageData(0,0,t.width,t.height)),t}catch{this.context.logger.info(`Unable to clone video as it is tainted`,e)}var r=e.ownerDocument.createElement(`canvas`);return r.width=e.offsetWidth,r.height=e.offsetHeight,r},e.prototype.appendChildNode=function(e,t,n){(!ys(t)||!Ns(t)&&!t.hasAttribute(rc)&&(typeof this.options.ignoreElements!=`function`||!this.options.ignoreElements(t)))&&(!this.options.copyStyles||!ys(t)||!Ms(t))&&e.appendChild(this.cloneNode(t,n))},e.prototype.cloneChildNodes=function(e,t,n){for(var r=this,i=e.shadowRoot?e.shadowRoot.firstChild:e.firstChild;i;i=i.nextSibling)if(ys(i)&&Is(i)&&typeof i.assignedNodes==`function`){var a=i.assignedNodes();a.length&&a.forEach(function(e){return r.appendChildNode(t,e,n)})}else this.appendChildNode(t,i,n)},e.prototype.cloneNode=function(e,t){if(vs(e))return document.createTextNode(e.data);if(!e.ownerDocument)return e.cloneNode(!1);var n=e.ownerDocument.defaultView;if(n&&ys(e)&&(bs(e)||xs(e))){var r=this.createElementClone(e);r.style.transitionProperty=`none`;var i=n.getComputedStyle(e),a=n.getComputedStyle(e,`:before`),o=n.getComputedStyle(e,`:after`);this.referenceElement===e&&bs(r)&&(this.clonedReferenceElement=r),Ds(r)&&bc(r);var s=this.counters.parse(new Oa(this.context,i)),c=this.resolvePseudoContent(e,r,a,ac.BEFORE);Ls(e)&&(t=!0),ks(e)||this.cloneChildNodes(e,r,t),c&&r.insertBefore(c,r.firstChild);var l=this.resolvePseudoContent(e,r,o,ac.AFTER);return l&&r.appendChild(l),this.counters.pop(s),(i&&(this.options.copyStyles||xs(e))&&!js(e)||t)&&dc(i,r),(e.scrollTop!==0||e.scrollLeft!==0)&&this.scrolledElements.push([r,e.scrollLeft,e.scrollTop]),(Ps(e)||Fs(e))&&(Ps(r)||Fs(r))&&(r.value=e.value),r}return e.cloneNode(!1)},e.prototype.resolvePseudoContent=function(e,t,n,r){var i=this;if(n){var a=n.content,o=t.ownerDocument;if(!(!o||!a||a===`none`||a===`-moz-alt-content`||n.display===`none`)){this.counters.parse(new Oa(this.context,n));var s=new Da(this.context,n),c=o.createElement(`html2canvaspseudoelement`);dc(n,c),s.content.forEach(function(t){if(t.type===0)c.appendChild(o.createTextNode(t.value));else if(t.type===22){var n=o.createElement(`img`);n.src=t.value,n.style.opacity=`1`,c.appendChild(n)}else if(t.type===18){if(t.name===`attr`){var r=t.values.filter(Wn);r.length&&c.appendChild(o.createTextNode(e.getAttribute(r[0].value)||``))}else if(t.name===`counter`){var a=t.values.filter(Jn),l=a[0],u=a[1];if(l&&Wn(l)){var d=i.counters.getCounterValue(l.value),f=u&&Wn(u)?Pi.parse(i.context,u.value):3;c.appendChild(o.createTextNode(nc(d,f,!1)))}}else if(t.name===`counters`){var p=t.values.filter(Jn),l=p[0],m=p[1],u=p[2];if(l&&Wn(l)){var h=i.counters.getCounterValues(l.value),g=u&&Wn(u)?Pi.parse(i.context,u.value):3,_=m&&m.type===0?m.value:``,v=h.map(function(e){return nc(e,g,!1)}).join(_);c.appendChild(o.createTextNode(v))}}}else if(t.type===20)switch(t.value){case`open-quote`:c.appendChild(o.createTextNode(xa(s.quotes,i.quoteDepth++,!0)));break;case`close-quote`:c.appendChild(o.createTextNode(xa(s.quotes,--i.quoteDepth,!1)));break;default:c.appendChild(o.createTextNode(t.value))}}),c.className=_c+` `+vc;var l=r===ac.BEFORE?` `+_c:` `+vc;return xs(t)?t.className.baseValue+=l:t.className+=l,c}}},e.destroy=function(e){return e.parentNode?(e.parentNode.removeChild(e),!0):!1},e}(),ac;(function(e){e[e.BEFORE=0]=`BEFORE`,e[e.AFTER=1]=`AFTER`})(ac||={});var oc=function(e,t){var n=e.createElement(`iframe`);return n.className=`html2canvas-container`,n.style.visibility=`hidden`,n.style.position=`fixed`,n.style.left=`-10000px`,n.style.top=`0px`,n.style.border=`0`,n.width=t.width.toString(),n.height=t.height.toString(),n.scrolling=`no`,n.setAttribute(rc,`true`),e.body.appendChild(n),n},sc=function(e){return new Promise(function(t){if(e.complete){t();return}if(!e.src){t();return}e.onload=t,e.onerror=t})},cc=function(e){return Promise.all([].slice.call(e.images,0).map(sc))},lc=function(e){return new Promise(function(t,n){var r=e.contentWindow;if(!r)return n(`No window assigned for iframe`);var i=r.document;r.onload=e.onload=function(){r.onload=e.onload=null;var n=setInterval(function(){i.body.childNodes.length>0&&i.readyState===`complete`&&(clearInterval(n),t(e))},50)}})},uc=[`all`,`d`,`content`],dc=function(e,t){for(var n=e.length-1;n>=0;n--){var r=e.item(n);uc.indexOf(r)===-1&&t.style.setProperty(r,e.getPropertyValue(r))}return t},fc=function(e){var t=``;return e&&(t+=`<!DOCTYPE `,e.name&&(t+=e.name),e.internalSubset&&(t+=e.internalSubset),e.publicId&&(t+=`"`+e.publicId+`"`),e.systemId&&(t+=`"`+e.systemId+`"`),t+=`>`),t},pc=function(e,t,n){e&&e.defaultView&&(t!==e.defaultView.pageXOffset||n!==e.defaultView.pageYOffset)&&e.defaultView.scrollTo(t,n)},mc=function(e){var t=e[0],n=e[1],r=e[2];t.scrollLeft=n,t.scrollTop=r},hc=`:before`,gc=`:after`,_c=`___html2canvas___pseudoelement_before`,vc=`___html2canvas___pseudoelement_after`,yc=`{
|
|
305
|
+
content: "" !important;
|
|
306
|
+
display: none !important;
|
|
307
|
+
}`,bc=function(e){xc(e,`.`+_c+hc+yc+`
|
|
308
|
+
.`+vc+gc+yc)},xc=function(e,t){var n=e.ownerDocument;if(n){var r=n.createElement(`style`);r.textContent=t,e.appendChild(r)}},Sc=function(){function e(){}return e.getOrigin=function(t){var n=e._link;return n?(n.href=t,n.href=n.href,n.protocol+n.hostname+n.port):`about:blank`},e.isSameOrigin=function(t){return e.getOrigin(t)===e._origin},e.setContext=function(t){e._link=t.document.createElement(`a`),e._origin=e.getOrigin(t.location.href)},e._origin=`about:blank`,e}(),Cc=function(){function e(e,t){this.context=e,this._options=t,this._cache={}}return e.prototype.addImage=function(e){var t=Promise.resolve();return this.has(e)||(Ac(e)||Dc(e))&&(this._cache[e]=this.loadImage(e)).catch(function(){}),t},e.prototype.match=function(e){return this._cache[e]},e.prototype.loadImage=function(e){return r(this,void 0,void 0,function(){var t,n,r,a,o=this;return i(this,function(i){switch(i.label){case 0:return t=Sc.isSameOrigin(e),n=!Oc(e)&&this._options.useCORS===!0&&Fo.SUPPORT_CORS_IMAGES&&!t,r=!Oc(e)&&!t&&!Ac(e)&&typeof this._options.proxy==`string`&&Fo.SUPPORT_CORS_XHR&&!n,!t&&this._options.allowTaint===!1&&!Oc(e)&&!Ac(e)&&!r&&!n?[2]:(a=e,r?[4,this.proxy(a)]:[3,2]);case 1:a=i.sent(),i.label=2;case 2:return this.context.logger.debug(`Added image `+e.substring(0,256)),[4,new Promise(function(e,t){var r=new Image;r.onload=function(){return e(r)},r.onerror=t,(kc(a)||n)&&(r.crossOrigin=`anonymous`),r.src=a,r.complete===!0&&setTimeout(function(){return e(r)},500),o._options.imageTimeout>0&&setTimeout(function(){return t(`Timed out (`+o._options.imageTimeout+`ms) loading image`)},o._options.imageTimeout)})];case 3:return[2,i.sent()]}})})},e.prototype.has=function(e){return this._cache[e]!==void 0},e.prototype.keys=function(){return Promise.resolve(Object.keys(this._cache))},e.prototype.proxy=function(e){var t=this,n=this._options.proxy;if(!n)throw Error(`No proxy defined`);var r=e.substring(0,256);return new Promise(function(i,a){var o=Fo.SUPPORT_RESPONSE_TYPE?`blob`:`text`,s=new XMLHttpRequest;s.onload=function(){if(s.status===200)if(o===`text`)i(s.response);else{var e=new FileReader;e.addEventListener(`load`,function(){return i(e.result)},!1),e.addEventListener(`error`,function(e){return a(e)},!1),e.readAsDataURL(s.response)}else a(`Failed to proxy resource `+r+` with status code `+s.status)},s.onerror=a;var c=n.indexOf(`?`)>-1?`&`:`?`;if(s.open(`GET`,``+n+c+`url=`+encodeURIComponent(e)+`&responseType=`+o),o!==`text`&&s instanceof XMLHttpRequest&&(s.responseType=o),t._options.imageTimeout){var l=t._options.imageTimeout;s.timeout=l,s.ontimeout=function(){return a(`Timed out (`+l+`ms) proxying `+r)}}s.send()})},e}(),wc=/^data:image\/svg\+xml/i,Tc=/^data:image\/.*;base64,/i,Ec=/^data:image\/.*/i,Dc=function(e){return Fo.SUPPORT_SVG_DRAWING||!jc(e)},Oc=function(e){return Ec.test(e)},kc=function(e){return Tc.test(e)},Ac=function(e){return e.substr(0,4)===`blob`},jc=function(e){return e.substr(-3).toLowerCase()===`svg`||wc.test(e)},Y=function(){function e(e,t){this.type=0,this.x=e,this.y=t}return e.prototype.add=function(t,n){return new e(this.x+t,this.y+n)},e}(),Mc=function(e,t,n){return new Y(e.x+(t.x-e.x)*n,e.y+(t.y-e.y)*n)},Nc=function(){function e(e,t,n,r){this.type=1,this.start=e,this.startControl=t,this.endControl=n,this.end=r}return e.prototype.subdivide=function(t,n){var r=Mc(this.start,this.startControl,t),i=Mc(this.startControl,this.endControl,t),a=Mc(this.endControl,this.end,t),o=Mc(r,i,t),s=Mc(i,a,t),c=Mc(o,s,t);return n?new e(this.start,r,o,c):new e(c,s,a,this.end)},e.prototype.add=function(t,n){return new e(this.start.add(t,n),this.startControl.add(t,n),this.endControl.add(t,n),this.end.add(t,n))},e.prototype.reverse=function(){return new e(this.end,this.endControl,this.startControl,this.start)},e}(),Pc=function(e){return e.type===1},Fc=function(){function e(e){var t=e.styles,n=e.bounds,r=rr(t.borderTopLeftRadius,n.width,n.height),i=r[0],a=r[1],o=rr(t.borderTopRightRadius,n.width,n.height),s=o[0],c=o[1],l=rr(t.borderBottomRightRadius,n.width,n.height),u=l[0],d=l[1],f=rr(t.borderBottomLeftRadius,n.width,n.height),p=f[0],m=f[1],h=[];h.push((i+s)/n.width),h.push((p+u)/n.width),h.push((a+m)/n.height),h.push((c+d)/n.height);var g=Math.max.apply(Math,h);g>1&&(i/=g,a/=g,s/=g,c/=g,u/=g,d/=g,p/=g,m/=g);var _=n.width-s,v=n.height-d,y=n.width-u,b=n.height-m,x=t.borderTopWidth,S=t.borderRightWidth,C=t.borderBottomWidth,w=t.borderLeftWidth,T=ir(t.paddingTop,e.bounds.width),E=ir(t.paddingRight,e.bounds.width),D=ir(t.paddingBottom,e.bounds.width),O=ir(t.paddingLeft,e.bounds.width);this.topLeftBorderDoubleOuterBox=i>0||a>0?Lc(n.left+w/3,n.top+x/3,i-w/3,a-x/3,Ic.TOP_LEFT):new Y(n.left+w/3,n.top+x/3),this.topRightBorderDoubleOuterBox=i>0||a>0?Lc(n.left+_,n.top+x/3,s-S/3,c-x/3,Ic.TOP_RIGHT):new Y(n.left+n.width-S/3,n.top+x/3),this.bottomRightBorderDoubleOuterBox=u>0||d>0?Lc(n.left+y,n.top+v,u-S/3,d-C/3,Ic.BOTTOM_RIGHT):new Y(n.left+n.width-S/3,n.top+n.height-C/3),this.bottomLeftBorderDoubleOuterBox=p>0||m>0?Lc(n.left+w/3,n.top+b,p-w/3,m-C/3,Ic.BOTTOM_LEFT):new Y(n.left+w/3,n.top+n.height-C/3),this.topLeftBorderDoubleInnerBox=i>0||a>0?Lc(n.left+w*2/3,n.top+x*2/3,i-w*2/3,a-x*2/3,Ic.TOP_LEFT):new Y(n.left+w*2/3,n.top+x*2/3),this.topRightBorderDoubleInnerBox=i>0||a>0?Lc(n.left+_,n.top+x*2/3,s-S*2/3,c-x*2/3,Ic.TOP_RIGHT):new Y(n.left+n.width-S*2/3,n.top+x*2/3),this.bottomRightBorderDoubleInnerBox=u>0||d>0?Lc(n.left+y,n.top+v,u-S*2/3,d-C*2/3,Ic.BOTTOM_RIGHT):new Y(n.left+n.width-S*2/3,n.top+n.height-C*2/3),this.bottomLeftBorderDoubleInnerBox=p>0||m>0?Lc(n.left+w*2/3,n.top+b,p-w*2/3,m-C*2/3,Ic.BOTTOM_LEFT):new Y(n.left+w*2/3,n.top+n.height-C*2/3),this.topLeftBorderStroke=i>0||a>0?Lc(n.left+w/2,n.top+x/2,i-w/2,a-x/2,Ic.TOP_LEFT):new Y(n.left+w/2,n.top+x/2),this.topRightBorderStroke=i>0||a>0?Lc(n.left+_,n.top+x/2,s-S/2,c-x/2,Ic.TOP_RIGHT):new Y(n.left+n.width-S/2,n.top+x/2),this.bottomRightBorderStroke=u>0||d>0?Lc(n.left+y,n.top+v,u-S/2,d-C/2,Ic.BOTTOM_RIGHT):new Y(n.left+n.width-S/2,n.top+n.height-C/2),this.bottomLeftBorderStroke=p>0||m>0?Lc(n.left+w/2,n.top+b,p-w/2,m-C/2,Ic.BOTTOM_LEFT):new Y(n.left+w/2,n.top+n.height-C/2),this.topLeftBorderBox=i>0||a>0?Lc(n.left,n.top,i,a,Ic.TOP_LEFT):new Y(n.left,n.top),this.topRightBorderBox=s>0||c>0?Lc(n.left+_,n.top,s,c,Ic.TOP_RIGHT):new Y(n.left+n.width,n.top),this.bottomRightBorderBox=u>0||d>0?Lc(n.left+y,n.top+v,u,d,Ic.BOTTOM_RIGHT):new Y(n.left+n.width,n.top+n.height),this.bottomLeftBorderBox=p>0||m>0?Lc(n.left,n.top+b,p,m,Ic.BOTTOM_LEFT):new Y(n.left,n.top+n.height),this.topLeftPaddingBox=i>0||a>0?Lc(n.left+w,n.top+x,Math.max(0,i-w),Math.max(0,a-x),Ic.TOP_LEFT):new Y(n.left+w,n.top+x),this.topRightPaddingBox=s>0||c>0?Lc(n.left+Math.min(_,n.width-S),n.top+x,_>n.width+S?0:Math.max(0,s-S),Math.max(0,c-x),Ic.TOP_RIGHT):new Y(n.left+n.width-S,n.top+x),this.bottomRightPaddingBox=u>0||d>0?Lc(n.left+Math.min(y,n.width-w),n.top+Math.min(v,n.height-C),Math.max(0,u-S),Math.max(0,d-C),Ic.BOTTOM_RIGHT):new Y(n.left+n.width-S,n.top+n.height-C),this.bottomLeftPaddingBox=p>0||m>0?Lc(n.left+w,n.top+Math.min(b,n.height-C),Math.max(0,p-w),Math.max(0,m-C),Ic.BOTTOM_LEFT):new Y(n.left+w,n.top+n.height-C),this.topLeftContentBox=i>0||a>0?Lc(n.left+w+O,n.top+x+T,Math.max(0,i-(w+O)),Math.max(0,a-(x+T)),Ic.TOP_LEFT):new Y(n.left+w+O,n.top+x+T),this.topRightContentBox=s>0||c>0?Lc(n.left+Math.min(_,n.width+w+O),n.top+x+T,_>n.width+w+O?0:s-w+O,c-(x+T),Ic.TOP_RIGHT):new Y(n.left+n.width-(S+E),n.top+x+T),this.bottomRightContentBox=u>0||d>0?Lc(n.left+Math.min(y,n.width-(w+O)),n.top+Math.min(v,n.height+x+T),Math.max(0,u-(S+E)),d-(C+D),Ic.BOTTOM_RIGHT):new Y(n.left+n.width-(S+E),n.top+n.height-(C+D)),this.bottomLeftContentBox=p>0||m>0?Lc(n.left+w+O,n.top+b,Math.max(0,p-(w+O)),m-(C+D),Ic.BOTTOM_LEFT):new Y(n.left+w+O,n.top+n.height-(C+D))}return e}(),Ic;(function(e){e[e.TOP_LEFT=0]=`TOP_LEFT`,e[e.TOP_RIGHT=1]=`TOP_RIGHT`,e[e.BOTTOM_RIGHT=2]=`BOTTOM_RIGHT`,e[e.BOTTOM_LEFT=3]=`BOTTOM_LEFT`})(Ic||={});var Lc=function(e,t,n,r,i){var a=4*((Math.sqrt(2)-1)/3),o=n*a,s=r*a,c=e+n,l=t+r;switch(i){case Ic.TOP_LEFT:return new Nc(new Y(e,l),new Y(e,l-s),new Y(c-o,t),new Y(c,t));case Ic.TOP_RIGHT:return new Nc(new Y(e,t),new Y(e+o,t),new Y(c,l-s),new Y(c,l));case Ic.BOTTOM_RIGHT:return new Nc(new Y(c,t),new Y(c,t+s),new Y(e+o,l),new Y(e,l));case Ic.BOTTOM_LEFT:default:return new Nc(new Y(c,l),new Y(c-o,l),new Y(e,t+s),new Y(e,t))}},Rc=function(e){return[e.topLeftBorderBox,e.topRightBorderBox,e.bottomRightBorderBox,e.bottomLeftBorderBox]},zc=function(e){return[e.topLeftContentBox,e.topRightContentBox,e.bottomRightContentBox,e.bottomLeftContentBox]},Bc=function(e){return[e.topLeftPaddingBox,e.topRightPaddingBox,e.bottomRightPaddingBox,e.bottomLeftPaddingBox]},Vc=function(){function e(e,t,n){this.offsetX=e,this.offsetY=t,this.matrix=n,this.type=0,this.target=6}return e}(),Hc=function(){function e(e,t){this.path=e,this.target=t,this.type=1}return e}(),Uc=function(){function e(e){this.opacity=e,this.type=2,this.target=6}return e}(),Wc=function(e){return e.type===0},Gc=function(e){return e.type===1},Kc=function(e){return e.type===2},qc=function(e,t){return e.length===t.length&&e.some(function(e,n){return e===t[n]})},Jc=function(e,t,n,r,i){return e.map(function(e,a){switch(a){case 0:return e.add(t,n);case 1:return e.add(t+r,n);case 2:return e.add(t+r,n+i);case 3:return e.add(t,n+i)}return e})},Yc=function(){function e(e){this.element=e,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]}return e}(),Xc=function(){function e(e,t){if(this.container=e,this.parent=t,this.effects=[],this.curves=new Fc(this.container),this.container.styles.opacity<1&&this.effects.push(new Uc(this.container.styles.opacity)),this.container.styles.transform!==null){var n=this.container.bounds.left+this.container.styles.transformOrigin[0].number,r=this.container.bounds.top+this.container.styles.transformOrigin[1].number,i=this.container.styles.transform;this.effects.push(new Vc(n,r,i))}if(this.container.styles.overflowX!==0){var a=Rc(this.curves),o=Bc(this.curves);qc(a,o)?this.effects.push(new Hc(a,6)):(this.effects.push(new Hc(a,2)),this.effects.push(new Hc(o,4)))}}return e.prototype.getEffects=function(e){for(var t=[2,3].indexOf(this.container.styles.position)===-1,n=this.parent,r=this.effects.slice(0);n;){var i=n.effects.filter(function(e){return!Gc(e)});if(t||n.container.styles.position!==0||!n.parent){if(r.unshift.apply(r,i),t=[2,3].indexOf(n.container.styles.position)===-1,n.container.styles.overflowX!==0){var a=Rc(n.curves),o=Bc(n.curves);qc(a,o)||r.unshift(new Hc(o,6))}}else r.unshift.apply(r,i);n=n.parent}return r.filter(function(t){return ha(t.target,e)})},e}(),Zc=function(e,t,n,r){e.container.elements.forEach(function(i){var a=ha(i.flags,4),o=ha(i.flags,2),s=new Xc(i,e);ha(i.styles.display,2048)&&r.push(s);var c=ha(i.flags,8)?[]:r;if(a||o){var l=a||i.styles.isPositioned()?n:t,u=new Yc(s);if(i.styles.isPositioned()||i.styles.opacity<1||i.styles.isTransformed()){var d=i.styles.zIndex.order;if(d<0){var f=0;l.negativeZIndex.some(function(e,t){return d>e.element.container.styles.zIndex.order?(f=t,!1):f>0}),l.negativeZIndex.splice(f,0,u)}else if(d>0){var p=0;l.positiveZIndex.some(function(e,t){return d>=e.element.container.styles.zIndex.order?(p=t+1,!1):p>0}),l.positiveZIndex.splice(p,0,u)}else l.zeroOrAutoZIndexOrTransformedOrOpacity.push(u)}else i.styles.isFloating()?l.nonPositionedFloats.push(u):l.nonPositionedInlineLevel.push(u);Zc(s,u,a?u:n,c)}else i.styles.isInlineLevel()?t.inlineLevel.push(s):t.nonInlineLevel.push(s),Zc(s,t,n,c);ha(i.flags,8)&&Qc(i,c)})},Qc=function(e,t){for(var n=e instanceof $o?e.start:1,r=e instanceof $o&&e.reversed,i=0;i<t.length;i++){var a=t[i];a.container instanceof Qo&&typeof a.container.value==`number`&&a.container.value!==0&&(n=a.container.value),a.listValue=nc(n,a.container.styles.listStyleType,!0),n+=r?-1:1}},$c=function(e){var t=new Xc(e,null),n=new Yc(t),r=[];return Zc(t,n,n,r),Qc(t.container,r),n},el=function(e,t){switch(t){case 0:return al(e.topLeftBorderBox,e.topLeftPaddingBox,e.topRightBorderBox,e.topRightPaddingBox);case 1:return al(e.topRightBorderBox,e.topRightPaddingBox,e.bottomRightBorderBox,e.bottomRightPaddingBox);case 2:return al(e.bottomRightBorderBox,e.bottomRightPaddingBox,e.bottomLeftBorderBox,e.bottomLeftPaddingBox);default:return al(e.bottomLeftBorderBox,e.bottomLeftPaddingBox,e.topLeftBorderBox,e.topLeftPaddingBox)}},tl=function(e,t){switch(t){case 0:return al(e.topLeftBorderBox,e.topLeftBorderDoubleOuterBox,e.topRightBorderBox,e.topRightBorderDoubleOuterBox);case 1:return al(e.topRightBorderBox,e.topRightBorderDoubleOuterBox,e.bottomRightBorderBox,e.bottomRightBorderDoubleOuterBox);case 2:return al(e.bottomRightBorderBox,e.bottomRightBorderDoubleOuterBox,e.bottomLeftBorderBox,e.bottomLeftBorderDoubleOuterBox);default:return al(e.bottomLeftBorderBox,e.bottomLeftBorderDoubleOuterBox,e.topLeftBorderBox,e.topLeftBorderDoubleOuterBox)}},nl=function(e,t){switch(t){case 0:return al(e.topLeftBorderDoubleInnerBox,e.topLeftPaddingBox,e.topRightBorderDoubleInnerBox,e.topRightPaddingBox);case 1:return al(e.topRightBorderDoubleInnerBox,e.topRightPaddingBox,e.bottomRightBorderDoubleInnerBox,e.bottomRightPaddingBox);case 2:return al(e.bottomRightBorderDoubleInnerBox,e.bottomRightPaddingBox,e.bottomLeftBorderDoubleInnerBox,e.bottomLeftPaddingBox);default:return al(e.bottomLeftBorderDoubleInnerBox,e.bottomLeftPaddingBox,e.topLeftBorderDoubleInnerBox,e.topLeftPaddingBox)}},rl=function(e,t){switch(t){case 0:return il(e.topLeftBorderStroke,e.topRightBorderStroke);case 1:return il(e.topRightBorderStroke,e.bottomRightBorderStroke);case 2:return il(e.bottomRightBorderStroke,e.bottomLeftBorderStroke);default:return il(e.bottomLeftBorderStroke,e.topLeftBorderStroke)}},il=function(e,t){var n=[];return Pc(e)?n.push(e.subdivide(.5,!1)):n.push(e),Pc(t)?n.push(t.subdivide(.5,!0)):n.push(t),n},al=function(e,t,n,r){var i=[];return Pc(e)?i.push(e.subdivide(.5,!1)):i.push(e),Pc(n)?i.push(n.subdivide(.5,!0)):i.push(n),Pc(r)?i.push(r.subdivide(.5,!0).reverse()):i.push(r),Pc(t)?i.push(t.subdivide(.5,!1).reverse()):i.push(t),i},ol=function(e){var t=e.bounds,n=e.styles;return t.add(n.borderLeftWidth,n.borderTopWidth,-(n.borderRightWidth+n.borderLeftWidth),-(n.borderTopWidth+n.borderBottomWidth))},sl=function(e){var t=e.styles,n=e.bounds,r=ir(t.paddingLeft,n.width),i=ir(t.paddingRight,n.width),a=ir(t.paddingTop,n.width),o=ir(t.paddingBottom,n.width);return n.add(r+t.borderLeftWidth,a+t.borderTopWidth,-(t.borderRightWidth+t.borderLeftWidth+r+i),-(t.borderTopWidth+t.borderBottomWidth+a+o))},cl=function(e,t){return e===0?t.bounds:e===2?sl(t):ol(t)},ll=function(e,t){return e===0?t.bounds:e===2?sl(t):ol(t)},ul=function(e,t,n){var r=cl(ml(e.styles.backgroundOrigin,t),e),i=ll(ml(e.styles.backgroundClip,t),e),a=pl(ml(e.styles.backgroundSize,t),n,r),o=a[0],s=a[1],c=rr(ml(e.styles.backgroundPosition,t),r.width-o,r.height-s);return[hl(ml(e.styles.backgroundRepeat,t),c,a,r,i),Math.round(r.left+c[0]),Math.round(r.top+c[1]),o,s]},dl=function(e){return Wn(e)&&e.value===$r.AUTO},fl=function(e){return typeof e==`number`},pl=function(e,t,n){var r=t[0],i=t[1],a=t[2],o=e[0],s=e[1];if(!o)return[0,0];if(Qn(o)&&s&&Qn(s))return[ir(o,n.width),ir(s,n.height)];var c=fl(a);if(Wn(o)&&(o.value===$r.CONTAIN||o.value===$r.COVER))return fl(a)?n.width/n.height<a==(o.value===$r.COVER)?[n.height*a,n.height]:[n.width,n.width/a]:[n.width,n.height];var l=fl(r),u=fl(i),d=l||u;if(dl(o)&&(!s||dl(s)))return l&&u?[r,i]:!c&&!d?[n.width,n.height]:d&&c?[l?r:i*a,u?i:r/a]:[l?r:n.width,u?i:n.height];if(c){var f=0,p=0;return Qn(o)?f=ir(o,n.width):Qn(s)&&(p=ir(s,n.height)),dl(o)?f=p*a:(!s||dl(s))&&(p=f/a),[f,p]}var m=null,h=null;if(Qn(o)?m=ir(o,n.width):s&&Qn(s)&&(h=ir(s,n.height)),m!==null&&(!s||dl(s))&&(h=l&&u?m/r*i:n.height),h!==null&&dl(o)&&(m=l&&u?h/i*r:n.width),m!==null&&h!==null)return[m,h];throw Error(`Unable to calculate background-size for element`)},ml=function(e,t){var n=e[t];return n===void 0?e[0]:n},hl=function(e,t,n,r,i){var a=t[0],o=t[1],s=n[0],c=n[1];switch(e){case 2:return[new Y(Math.round(r.left),Math.round(r.top+o)),new Y(Math.round(r.left+r.width),Math.round(r.top+o)),new Y(Math.round(r.left+r.width),Math.round(c+r.top+o)),new Y(Math.round(r.left),Math.round(c+r.top+o))];case 3:return[new Y(Math.round(r.left+a),Math.round(r.top)),new Y(Math.round(r.left+a+s),Math.round(r.top)),new Y(Math.round(r.left+a+s),Math.round(r.height+r.top)),new Y(Math.round(r.left+a),Math.round(r.height+r.top))];case 1:return[new Y(Math.round(r.left+a),Math.round(r.top+o)),new Y(Math.round(r.left+a+s),Math.round(r.top+o)),new Y(Math.round(r.left+a+s),Math.round(r.top+o+c)),new Y(Math.round(r.left+a),Math.round(r.top+o+c))];default:return[new Y(Math.round(i.left),Math.round(i.top)),new Y(Math.round(i.left+i.width),Math.round(i.top)),new Y(Math.round(i.left+i.width),Math.round(i.height+i.top)),new Y(Math.round(i.left),Math.round(i.height+i.top))]}},gl=`data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7`,_l=`Hidden Text`,vl=function(){function e(e){this._data={},this._document=e}return e.prototype.parseMetrics=function(e,t){var n=this._document.createElement(`div`),r=this._document.createElement(`img`),i=this._document.createElement(`span`),a=this._document.body;n.style.visibility=`hidden`,n.style.fontFamily=e,n.style.fontSize=t,n.style.margin=`0`,n.style.padding=`0`,n.style.whiteSpace=`nowrap`,a.appendChild(n),r.src=gl,r.width=1,r.height=1,r.style.margin=`0`,r.style.padding=`0`,r.style.verticalAlign=`baseline`,i.style.fontFamily=e,i.style.fontSize=t,i.style.margin=`0`,i.style.padding=`0`,i.appendChild(this._document.createTextNode(_l)),n.appendChild(i),n.appendChild(r);var o=r.offsetTop-i.offsetTop+2;n.removeChild(i),n.appendChild(this._document.createTextNode(_l)),n.style.lineHeight=`normal`,r.style.verticalAlign=`super`;var s=r.offsetTop-n.offsetTop+2;return a.removeChild(n),{baseline:o,middle:s}},e.prototype.getMetrics=function(e,t){var n=e+` `+t;return this._data[n]===void 0&&(this._data[n]=this.parseMetrics(e,t)),this._data[n]},e}(),yl=function(){function e(e,t){this.context=e,this.options=t}return e}(),bl=1e4,xl=function(e){t(n,e);function n(t,n){var r=e.call(this,t,n)||this;return r._activeEffects=[],r.canvas=n.canvas?n.canvas:document.createElement(`canvas`),r.ctx=r.canvas.getContext(`2d`),n.canvas||(r.canvas.width=Math.floor(n.width*n.scale),r.canvas.height=Math.floor(n.height*n.scale),r.canvas.style.width=n.width+`px`,r.canvas.style.height=n.height+`px`),r.fontMetrics=new vl(document),r.ctx.scale(r.options.scale,r.options.scale),r.ctx.translate(-n.x,-n.y),r.ctx.textBaseline=`bottom`,r._activeEffects=[],r.context.logger.debug(`Canvas renderer initialized (`+n.width+`x`+n.height+`) with scale `+n.scale),r}return n.prototype.applyEffects=function(e){for(var t=this;this._activeEffects.length;)this.popEffect();e.forEach(function(e){return t.applyEffect(e)})},n.prototype.applyEffect=function(e){this.ctx.save(),Kc(e)&&(this.ctx.globalAlpha=e.opacity),Wc(e)&&(this.ctx.translate(e.offsetX,e.offsetY),this.ctx.transform(e.matrix[0],e.matrix[1],e.matrix[2],e.matrix[3],e.matrix[4],e.matrix[5]),this.ctx.translate(-e.offsetX,-e.offsetY)),Gc(e)&&(this.path(e.path),this.ctx.clip()),this._activeEffects.push(e)},n.prototype.popEffect=function(){this._activeEffects.pop(),this.ctx.restore()},n.prototype.renderStack=function(e){return r(this,void 0,void 0,function(){var t;return i(this,function(n){switch(n.label){case 0:return t=e.element.container.styles,t.isVisible()?[4,this.renderStackContent(e)]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}})})},n.prototype.renderNode=function(e){return r(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:if(ha(e.container.flags,16))debugger;return e.container.styles.isVisible()?[4,this.renderNodeBackgroundAndBorders(e)]:[3,3];case 1:return t.sent(),[4,this.renderNodeContent(e)];case 2:t.sent(),t.label=3;case 3:return[2]}})})},n.prototype.renderTextWithLetterSpacing=function(e,t,n){var r=this;t===0?this.ctx.fillText(e.text,e.bounds.left,e.bounds.top+n):Bo(e.text).reduce(function(t,i){return r.ctx.fillText(i,t,e.bounds.top+n),t+r.ctx.measureText(i).width},e.bounds.left)},n.prototype.createFontStyle=function(e){var t=e.fontVariant.filter(function(e){return e===`normal`||e===`small-caps`}).join(``),n=El(e.fontFamily).join(`, `),r=Hn(e.fontSize)?``+e.fontSize.number+e.fontSize.unit:e.fontSize.number+`px`;return[[e.fontStyle,t,e.fontWeight,r,n].join(` `),n,r]},n.prototype.renderTextNode=function(e,t){return r(this,void 0,void 0,function(){var n,r,a,o,s,c,l,u,d=this;return i(this,function(i){return n=this.createFontStyle(t),r=n[0],a=n[1],o=n[2],this.ctx.font=r,this.ctx.direction=t.direction===1?`rtl`:`ltr`,this.ctx.textAlign=`left`,this.ctx.textBaseline=`alphabetic`,s=this.fontMetrics.getMetrics(a,o),c=s.baseline,l=s.middle,u=t.paintOrder,e.textBounds.forEach(function(e){u.forEach(function(n){switch(n){case 0:d.ctx.fillStyle=hr(t.color),d.renderTextWithLetterSpacing(e,t.letterSpacing,c);var r=t.textShadow;r.length&&e.text.trim().length&&(r.slice(0).reverse().forEach(function(n){d.ctx.shadowColor=hr(n.color),d.ctx.shadowOffsetX=n.offsetX.number*d.options.scale,d.ctx.shadowOffsetY=n.offsetY.number*d.options.scale,d.ctx.shadowBlur=n.blur.number,d.renderTextWithLetterSpacing(e,t.letterSpacing,c)}),d.ctx.shadowColor=``,d.ctx.shadowOffsetX=0,d.ctx.shadowOffsetY=0,d.ctx.shadowBlur=0),t.textDecorationLine.length&&(d.ctx.fillStyle=hr(t.textDecorationColor||t.color),t.textDecorationLine.forEach(function(t){switch(t){case 1:d.ctx.fillRect(e.bounds.left,Math.round(e.bounds.top+c),e.bounds.width,1);break;case 2:d.ctx.fillRect(e.bounds.left,Math.round(e.bounds.top),e.bounds.width,1);break;case 3:d.ctx.fillRect(e.bounds.left,Math.ceil(e.bounds.top+l),e.bounds.width,1);break}}));break;case 1:t.webkitTextStrokeWidth&&e.text.trim().length&&(d.ctx.strokeStyle=hr(t.webkitTextStrokeColor),d.ctx.lineWidth=t.webkitTextStrokeWidth,d.ctx.lineJoin=window.chrome?`miter`:`round`,d.ctx.strokeText(e.text,e.bounds.left,e.bounds.top+c)),d.ctx.strokeStyle=``,d.ctx.lineWidth=0,d.ctx.lineJoin=`miter`;break}})}),[2]})})},n.prototype.renderReplacedElement=function(e,t,n){if(n&&e.intrinsicWidth>0&&e.intrinsicHeight>0){var r=sl(e),i=Bc(t);this.path(i),this.ctx.save(),this.ctx.clip(),this.ctx.drawImage(n,0,0,e.intrinsicWidth,e.intrinsicHeight,r.left,r.top,r.width,r.height),this.ctx.restore()}},n.prototype.renderNodeContent=function(e){return r(this,void 0,void 0,function(){var t,r,a,s,c,l,u,u,d,f,p,m,h,g,_,v,y,b,x,u,S,h,v;return i(this,function(i){switch(i.label){case 0:this.applyEffects(e.getEffects(4)),t=e.container,r=e.curves,a=t.styles,s=0,c=t.textNodes,i.label=1;case 1:return s<c.length?(l=c[s],[4,this.renderTextNode(l,a)]):[3,4];case 2:i.sent(),i.label=3;case 3:return s++,[3,1];case 4:if(!(t instanceof Yo))return[3,8];i.label=5;case 5:return i.trys.push([5,7,,8]),[4,this.context.cache.match(t.src)];case 6:return u=i.sent(),this.renderReplacedElement(t,r,u),[3,8];case 7:return i.sent(),this.context.logger.error(`Error loading image `+t.src),[3,8];case 8:if(t instanceof Xo&&this.renderReplacedElement(t,r,t.canvas),!(t instanceof Zo))return[3,12];i.label=9;case 9:return i.trys.push([9,11,,12]),[4,this.context.cache.match(t.svg)];case 10:return u=i.sent(),this.renderReplacedElement(t,r,u),[3,12];case 11:return i.sent(),this.context.logger.error(`Error loading svg `+t.svg.substring(0,255)),[3,12];case 12:return t instanceof ds&&t.tree?(d=new n(this.context,{scale:this.options.scale,backgroundColor:t.backgroundColor,x:0,y:0,width:t.width,height:t.height}),[4,d.render(t.tree)]):[3,14];case 13:f=i.sent(),t.width&&t.height&&this.ctx.drawImage(f,0,0,t.width,t.height,t.bounds.left,t.bounds.top,t.bounds.width,t.bounds.height),i.label=14;case 14:if(t instanceof cs&&(p=Math.min(t.bounds.width,t.bounds.height),t.type===is?t.checked&&(this.ctx.save(),this.path([new Y(t.bounds.left+p*.39363,t.bounds.top+p*.79),new Y(t.bounds.left+p*.16,t.bounds.top+p*.5549),new Y(t.bounds.left+p*.27347,t.bounds.top+p*.44071),new Y(t.bounds.left+p*.39694,t.bounds.top+p*.5649),new Y(t.bounds.left+p*.72983,t.bounds.top+p*.23),new Y(t.bounds.left+p*.84,t.bounds.top+p*.34085),new Y(t.bounds.left+p*.39363,t.bounds.top+p*.79)]),this.ctx.fillStyle=hr(ss),this.ctx.fill(),this.ctx.restore()):t.type===as&&t.checked&&(this.ctx.save(),this.ctx.beginPath(),this.ctx.arc(t.bounds.left+p/2,t.bounds.top+p/2,p/4,0,Math.PI*2,!0),this.ctx.fillStyle=hr(ss),this.ctx.fill(),this.ctx.restore())),Sl(t)&&t.value.length){switch(m=this.createFontStyle(a),h=m[0],g=m[1],_=this.fontMetrics.getMetrics(h,g).baseline,this.ctx.font=h,this.ctx.fillStyle=hr(a.color),this.ctx.textBaseline=`alphabetic`,this.ctx.textAlign=wl(t.styles.textAlign),v=sl(t),y=0,t.styles.textAlign){case 1:y+=v.width/2;break;case 2:y+=v.width;break}b=v.add(y,0,0,-v.height/2+1),this.ctx.save(),this.path([new Y(v.left,v.top),new Y(v.left+v.width,v.top),new Y(v.left+v.width,v.top+v.height),new Y(v.left,v.top+v.height)]),this.ctx.clip(),this.renderTextWithLetterSpacing(new Io(t.value,b),a.letterSpacing,_),this.ctx.restore(),this.ctx.textBaseline=`alphabetic`,this.ctx.textAlign=`left`}if(!ha(t.styles.display,2048))return[3,20];if(t.styles.listStyleImage===null)return[3,19];if(x=t.styles.listStyleImage,x.type!==0)return[3,18];u=void 0,S=x.url,i.label=15;case 15:return i.trys.push([15,17,,18]),[4,this.context.cache.match(S)];case 16:return u=i.sent(),this.ctx.drawImage(u,t.bounds.left-(u.width+10),t.bounds.top),[3,18];case 17:return i.sent(),this.context.logger.error(`Error loading list-style-image `+S),[3,18];case 18:return[3,20];case 19:e.listValue&&t.styles.listStyleType!==-1&&(h=this.createFontStyle(a)[0],this.ctx.font=h,this.ctx.fillStyle=hr(a.color),this.ctx.textBaseline=`middle`,this.ctx.textAlign=`right`,v=new o(t.bounds.left,t.bounds.top+ir(t.styles.paddingTop,t.bounds.width),t.bounds.width,ji(a.lineHeight,a.fontSize.number)/2+1),this.renderTextWithLetterSpacing(new Io(e.listValue,v),a.letterSpacing,ji(a.lineHeight,a.fontSize.number)/2+2),this.ctx.textBaseline=`bottom`,this.ctx.textAlign=`left`),i.label=20;case 20:return[2]}})})},n.prototype.renderStackContent=function(e){return r(this,void 0,void 0,function(){var t,n,r,a,o,r,s,c,r,l,u,r,d,f,r,p,m,r,h,g,r;return i(this,function(i){switch(i.label){case 0:if(ha(e.element.container.flags,16))debugger;return[4,this.renderNodeBackgroundAndBorders(e.element)];case 1:i.sent(),t=0,n=e.negativeZIndex,i.label=2;case 2:return t<n.length?(r=n[t],[4,this.renderStack(r)]):[3,5];case 3:i.sent(),i.label=4;case 4:return t++,[3,2];case 5:return[4,this.renderNodeContent(e.element)];case 6:i.sent(),a=0,o=e.nonInlineLevel,i.label=7;case 7:return a<o.length?(r=o[a],[4,this.renderNode(r)]):[3,10];case 8:i.sent(),i.label=9;case 9:return a++,[3,7];case 10:s=0,c=e.nonPositionedFloats,i.label=11;case 11:return s<c.length?(r=c[s],[4,this.renderStack(r)]):[3,14];case 12:i.sent(),i.label=13;case 13:return s++,[3,11];case 14:l=0,u=e.nonPositionedInlineLevel,i.label=15;case 15:return l<u.length?(r=u[l],[4,this.renderStack(r)]):[3,18];case 16:i.sent(),i.label=17;case 17:return l++,[3,15];case 18:d=0,f=e.inlineLevel,i.label=19;case 19:return d<f.length?(r=f[d],[4,this.renderNode(r)]):[3,22];case 20:i.sent(),i.label=21;case 21:return d++,[3,19];case 22:p=0,m=e.zeroOrAutoZIndexOrTransformedOrOpacity,i.label=23;case 23:return p<m.length?(r=m[p],[4,this.renderStack(r)]):[3,26];case 24:i.sent(),i.label=25;case 25:return p++,[3,23];case 26:h=0,g=e.positiveZIndex,i.label=27;case 27:return h<g.length?(r=g[h],[4,this.renderStack(r)]):[3,30];case 28:i.sent(),i.label=29;case 29:return h++,[3,27];case 30:return[2]}})})},n.prototype.mask=function(e){this.ctx.beginPath(),this.ctx.moveTo(0,0),this.ctx.lineTo(this.canvas.width,0),this.ctx.lineTo(this.canvas.width,this.canvas.height),this.ctx.lineTo(0,this.canvas.height),this.ctx.lineTo(0,0),this.formatPath(e.slice(0).reverse()),this.ctx.closePath()},n.prototype.path=function(e){this.ctx.beginPath(),this.formatPath(e),this.ctx.closePath()},n.prototype.formatPath=function(e){var t=this;e.forEach(function(e,n){var r=Pc(e)?e.start:e;n===0?t.ctx.moveTo(r.x,r.y):t.ctx.lineTo(r.x,r.y),Pc(e)&&t.ctx.bezierCurveTo(e.startControl.x,e.startControl.y,e.endControl.x,e.endControl.y,e.end.x,e.end.y)})},n.prototype.renderRepeat=function(e,t,n,r){this.path(e),this.ctx.fillStyle=t,this.ctx.translate(n,r),this.ctx.fill(),this.ctx.translate(-n,-r)},n.prototype.resizeImage=function(e,t,n){if(e.width===t&&e.height===n)return e;var r=(this.canvas.ownerDocument??document).createElement(`canvas`);return r.width=Math.max(1,t),r.height=Math.max(1,n),r.getContext(`2d`).drawImage(e,0,0,e.width,e.height,0,0,t,n),r},n.prototype.renderBackgroundImage=function(e){return r(this,void 0,void 0,function(){var t,n,r,a,o,s;return i(this,function(c){switch(c.label){case 0:t=e.styles.backgroundImage.length-1,n=function(n){var a,o,s,c,l,u,d,f,p,m,c,l,u,d,f,h,g,_,v,y,b,x,S,C,p,w,c,T,E,d,f,D,l,u,O,k,A,j,M,N,P,F;return i(this,function(i){switch(i.label){case 0:if(n.type!==0)return[3,5];a=void 0,o=n.url,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,r.context.cache.match(o)];case 2:return a=i.sent(),[3,4];case 3:return i.sent(),r.context.logger.error(`Error loading background-image `+o),[3,4];case 4:return a&&(s=ul(e,t,[a.width,a.height,a.width/a.height]),c=s[0],l=s[1],u=s[2],d=s[3],f=s[4],p=r.ctx.createPattern(r.resizeImage(a,d,f),`repeat`),r.renderRepeat(c,p,l,u)),[3,6];case 5:Gr(n)?(m=ul(e,t,[null,null,null]),c=m[0],l=m[1],u=m[2],d=m[3],f=m[4],h=kr(n.angle,d,f),g=h[0],_=h[1],v=h[2],y=h[3],b=h[4],x=document.createElement(`canvas`),x.width=d,x.height=f,S=x.getContext(`2d`),C=S.createLinearGradient(_,y,v,b),Dr(n.stops,g).forEach(function(e){return C.addColorStop(e.stop,hr(e.color))}),S.fillStyle=C,S.fillRect(0,0,d,f),d>0&&f>0&&(p=r.ctx.createPattern(x,`repeat`),r.renderRepeat(c,p,l,u))):K(n)&&(w=ul(e,t,[null,null,null]),c=w[0],T=w[1],E=w[2],d=w[3],f=w[4],D=n.position.length===0?[tr]:n.position,l=ir(D[0],d),u=ir(D[D.length-1],f),O=Mr(n,l,u,d,f),k=O[0],A=O[1],k>0&&A>0&&(j=r.ctx.createRadialGradient(T+l,E+u,0,T+l,E+u,k),Dr(n.stops,k*2).forEach(function(e){return j.addColorStop(e.stop,hr(e.color))}),r.path(c),r.ctx.fillStyle=j,k===A?r.ctx.fill():(M=e.bounds.left+.5*e.bounds.width,N=e.bounds.top+.5*e.bounds.height,P=A/k,F=1/P,r.ctx.save(),r.ctx.translate(M,N),r.ctx.transform(1,0,0,P,0,0),r.ctx.translate(-M,-N),r.ctx.fillRect(T,F*(E-N)+N,d,f*F),r.ctx.restore()))),i.label=6;case 6:return t--,[2]}})},r=this,a=0,o=e.styles.backgroundImage.slice(0).reverse(),c.label=1;case 1:return a<o.length?(s=o[a],[5,n(s)]):[3,4];case 2:c.sent(),c.label=3;case 3:return a++,[3,1];case 4:return[2]}})})},n.prototype.renderSolidBorder=function(e,t,n){return r(this,void 0,void 0,function(){return i(this,function(r){return this.path(el(n,t)),this.ctx.fillStyle=hr(e),this.ctx.fill(),[2]})})},n.prototype.renderDoubleBorder=function(e,t,n,a){return r(this,void 0,void 0,function(){var r,o;return i(this,function(i){switch(i.label){case 0:return t<3?[4,this.renderSolidBorder(e,n,a)]:[3,2];case 1:return i.sent(),[2];case 2:return r=tl(a,n),this.path(r),this.ctx.fillStyle=hr(e),this.ctx.fill(),o=nl(a,n),this.path(o),this.ctx.fill(),[2]}})})},n.prototype.renderNodeBackgroundAndBorders=function(e){return r(this,void 0,void 0,function(){var t,n,r,a,o,s,c,l,u=this;return i(this,function(i){switch(i.label){case 0:return this.applyEffects(e.getEffects(2)),t=e.container.styles,n=!mr(t.backgroundColor)||t.backgroundImage.length,r=[{style:t.borderTopStyle,color:t.borderTopColor,width:t.borderTopWidth},{style:t.borderRightStyle,color:t.borderRightColor,width:t.borderRightWidth},{style:t.borderBottomStyle,color:t.borderBottomColor,width:t.borderBottomWidth},{style:t.borderLeftStyle,color:t.borderLeftColor,width:t.borderLeftWidth}],a=Cl(ml(t.backgroundClip,0),e.curves),n||t.boxShadow.length?(this.ctx.save(),this.path(a),this.ctx.clip(),mr(t.backgroundColor)||(this.ctx.fillStyle=hr(t.backgroundColor),this.ctx.fill()),[4,this.renderBackgroundImage(e.container)]):[3,2];case 1:i.sent(),this.ctx.restore(),t.boxShadow.slice(0).reverse().forEach(function(t){u.ctx.save();var n=Rc(e.curves),r=t.inset?0:bl,i=Jc(n,-r+(t.inset?1:-1)*t.spread.number,(t.inset?1:-1)*t.spread.number,t.spread.number*(t.inset?-2:2),t.spread.number*(t.inset?-2:2));t.inset?(u.path(n),u.ctx.clip(),u.mask(i)):(u.mask(n),u.ctx.clip(),u.path(i)),u.ctx.shadowOffsetX=t.offsetX.number+r,u.ctx.shadowOffsetY=t.offsetY.number,u.ctx.shadowColor=hr(t.color),u.ctx.shadowBlur=t.blur.number,u.ctx.fillStyle=t.inset?hr(t.color):`rgba(0,0,0,1)`,u.ctx.fill(),u.ctx.restore()}),i.label=2;case 2:o=0,s=0,c=r,i.label=3;case 3:return s<c.length?(l=c[s],l.style!==0&&!mr(l.color)&&l.width>0?l.style===2?[4,this.renderDashedDottedBorder(l.color,l.width,o,e.curves,2)]:[3,5]:[3,11]):[3,13];case 4:return i.sent(),[3,11];case 5:return l.style===3?[4,this.renderDashedDottedBorder(l.color,l.width,o,e.curves,3)]:[3,7];case 6:return i.sent(),[3,11];case 7:return l.style===4?[4,this.renderDoubleBorder(l.color,l.width,o,e.curves)]:[3,9];case 8:return i.sent(),[3,11];case 9:return[4,this.renderSolidBorder(l.color,o,e.curves)];case 10:i.sent(),i.label=11;case 11:o++,i.label=12;case 12:return s++,[3,3];case 13:return[2]}})})},n.prototype.renderDashedDottedBorder=function(e,t,n,a,o){return r(this,void 0,void 0,function(){var r,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,b,x;return i(this,function(i){return this.ctx.save(),r=rl(a,n),s=el(a,n),o===2&&(this.path(s),this.ctx.clip()),Pc(s[0])?(c=s[0].start.x,l=s[0].start.y):(c=s[0].x,l=s[0].y),Pc(s[1])?(u=s[1].end.x,d=s[1].end.y):(u=s[1].x,d=s[1].y),f=Math.abs(n===0||n===2?c-u:l-d),this.ctx.beginPath(),o===3?this.formatPath(r):this.formatPath(s.slice(0,2)),p=t<3?t*3:t*2,m=t<3?t*2:t,o===3&&(p=t,m=t),h=!0,f<=p*2?h=!1:f<=p*2+m?(g=f/(2*p+m),p*=g,m*=g):(_=Math.floor((f+m)/(p+m)),v=(f-_*p)/(_-1),y=(f-(_+1)*p)/_,m=y<=0||Math.abs(m-v)<Math.abs(m-y)?v:y),h&&(o===3?this.ctx.setLineDash([0,p+m]):this.ctx.setLineDash([p,m])),o===3?(this.ctx.lineCap=`round`,this.ctx.lineWidth=t):this.ctx.lineWidth=t*2+1.1,this.ctx.strokeStyle=hr(e),this.ctx.stroke(),this.ctx.setLineDash([]),o===2&&(Pc(s[0])&&(b=s[3],x=s[0],this.ctx.beginPath(),this.formatPath([new Y(b.end.x,b.end.y),new Y(x.start.x,x.start.y)]),this.ctx.stroke()),Pc(s[1])&&(b=s[1],x=s[2],this.ctx.beginPath(),this.formatPath([new Y(b.end.x,b.end.y),new Y(x.start.x,x.start.y)]),this.ctx.stroke())),this.ctx.restore(),[2]})})},n.prototype.render=function(e){return r(this,void 0,void 0,function(){var t;return i(this,function(n){switch(n.label){case 0:return this.options.backgroundColor&&(this.ctx.fillStyle=hr(this.options.backgroundColor),this.ctx.fillRect(this.options.x,this.options.y,this.options.width,this.options.height)),t=$c(e),[4,this.renderStack(t)];case 1:return n.sent(),this.applyEffects([]),[2,this.canvas]}})})},n}(yl),Sl=function(e){return e instanceof us||e instanceof ls||e instanceof cs&&e.type!==as&&e.type!==is},Cl=function(e,t){switch(e){case 0:return Rc(t);case 2:return zc(t);default:return Bc(t)}},wl=function(e){switch(e){case 1:return`center`;case 2:return`right`;default:return`left`}},Tl=[`-apple-system`,`system-ui`],El=function(e){return/iPhone OS 15_(0|1)/.test(window.navigator.userAgent)?e.filter(function(e){return Tl.indexOf(e)===-1}):e},Dl=function(e){t(n,e);function n(t,n){var r=e.call(this,t,n)||this;return r.canvas=n.canvas?n.canvas:document.createElement(`canvas`),r.ctx=r.canvas.getContext(`2d`),r.options=n,r.canvas.width=Math.floor(n.width*n.scale),r.canvas.height=Math.floor(n.height*n.scale),r.canvas.style.width=n.width+`px`,r.canvas.style.height=n.height+`px`,r.ctx.scale(r.options.scale,r.options.scale),r.ctx.translate(-n.x,-n.y),r.context.logger.debug(`EXPERIMENTAL ForeignObject renderer initialized (`+n.width+`x`+n.height+` at `+n.x+`,`+n.y+`) with scale `+n.scale),r}return n.prototype.render=function(e){return r(this,void 0,void 0,function(){var t,n;return i(this,function(r){switch(r.label){case 0:return t=No(this.options.width*this.options.scale,this.options.height*this.options.scale,this.options.scale,this.options.scale,e),[4,Ol(t)];case 1:return n=r.sent(),this.options.backgroundColor&&(this.ctx.fillStyle=hr(this.options.backgroundColor),this.ctx.fillRect(0,0,this.options.width*this.options.scale,this.options.height*this.options.scale)),this.ctx.drawImage(n,-this.options.x*this.options.scale,-this.options.y*this.options.scale),[2,this.canvas]}})})},n}(yl),Ol=function(e){return new Promise(function(t,n){var r=new Image;r.onload=function(){t(r)},r.onerror=n,r.src=`data:image/svg+xml;charset=utf-8,`+encodeURIComponent(new XMLSerializer().serializeToString(e))})},kl=function(){function e(e){var t=e.id,n=e.enabled;this.id=t,this.enabled=n,this.start=Date.now()}return e.prototype.debug=function(){var e=[...arguments];this.enabled&&(typeof window<`u`&&window.console&&typeof console.debug==`function`?console.debug.apply(console,a([this.id,this.getTime()+`ms`],e)):this.info.apply(this,e))},e.prototype.getTime=function(){return Date.now()-this.start},e.prototype.info=function(){var e=[...arguments];this.enabled&&typeof window<`u`&&window.console&&typeof console.info==`function`&&console.info.apply(console,a([this.id,this.getTime()+`ms`],e))},e.prototype.warn=function(){var e=[...arguments];this.enabled&&(typeof window<`u`&&window.console&&typeof console.warn==`function`?console.warn.apply(console,a([this.id,this.getTime()+`ms`],e)):this.info.apply(this,e))},e.prototype.error=function(){var e=[...arguments];this.enabled&&(typeof window<`u`&&window.console&&typeof console.error==`function`?console.error.apply(console,a([this.id,this.getTime()+`ms`],e)):this.info.apply(this,e))},e.instances={},e}(),Al=function(){function e(t,n){this.windowBounds=n,this.instanceName=`#`+e.instanceCount++,this.logger=new kl({id:this.instanceName,enabled:t.logging}),this.cache=t.cache??new Cc(this,t)}return e.instanceCount=1,e}(),jl=function(e,t){return t===void 0&&(t={}),Ml(e,t)};typeof window<`u`&&Sc.setContext(window);var Ml=function(e,t){return r(void 0,void 0,void 0,function(){var r,a,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,D;return i(this,function(i){switch(i.label){case 0:if(!e||typeof e!=`object`)return[2,Promise.reject(`Invalid element provided as first argument`)];if(r=e.ownerDocument,!r)throw Error(`Element is not attached to a Document`);if(a=r.defaultView,!a)throw Error(`Document is not attached to a Window`);return l={allowTaint:t.allowTaint??!1,imageTimeout:t.imageTimeout??15e3,proxy:t.proxy,useCORS:t.useCORS??!1},u=n({logging:t.logging??!0,cache:t.cache},l),d={windowWidth:t.windowWidth??a.innerWidth,windowHeight:t.windowHeight??a.innerHeight,scrollX:t.scrollX??a.pageXOffset,scrollY:t.scrollY??a.pageYOffset},f=new o(d.scrollX,d.scrollY,d.windowWidth,d.windowHeight),p=new Al(u,f),m=t.foreignObjectRendering??!1,h={allowTaint:t.allowTaint??!1,onclone:t.onclone,ignoreElements:t.ignoreElements,inlineImages:m,copyStyles:m},p.logger.debug(`Starting document clone with size `+f.width+`x`+f.height+` scrolled to `+-f.left+`,`+-f.top),g=new ic(p,e,h),_=g.clonedReferenceElement,_?[4,g.toIFrame(r,f)]:[2,Promise.reject(`Unable to find element in cloned iframe`)];case 1:return v=i.sent(),y=Ds(_)||Ts(_)?c(_.ownerDocument):s(p,_),b=y.width,x=y.height,S=y.left,C=y.top,w=Nl(p,_,t.backgroundColor),T={canvas:t.canvas,backgroundColor:w,scale:t.scale??a.devicePixelRatio??1,x:(t.x??0)+S,y:(t.y??0)+C,width:t.width??Math.ceil(b),height:t.height??Math.ceil(x)},m?(p.logger.debug(`Document cloned, using foreign object rendering`),D=new Dl(p,T),[4,D.render(_)]):[3,3];case 2:return E=i.sent(),[3,5];case 3:return p.logger.debug(`Document cloned, element located at `+S+`,`+C+` with size `+b+`x`+x+` using computed rendering`),p.logger.debug(`Starting DOM parsing`),O=hs(p,_),w===O.styles.backgroundColor&&(O.styles.backgroundColor=Cr.TRANSPARENT),p.logger.debug(`Starting renderer for element at `+T.x+`,`+T.y+` with size `+T.width+`x`+T.height),D=new xl(p,T),[4,D.render(O)];case 4:E=i.sent(),i.label=5;case 5:return(t.removeContainer??!0)&&(ic.destroy(v)||p.logger.error(`Cannot detach cloned iframe as it is not in the DOM anymore`)),p.logger.debug(`Finished rendering`),[2,E]}})})},Nl=function(e,t,n){var r=t.ownerDocument,i=r.documentElement?Sr(e,getComputedStyle(r.documentElement).backgroundColor):Cr.TRANSPARENT,a=r.body?Sr(e,getComputedStyle(r.body).backgroundColor):Cr.TRANSPARENT,o=typeof n==`string`?Sr(e,n):n===null?Cr.TRANSPARENT:4294967295;return t===r.documentElement?mr(i)?mr(a)?o:a:i:o};return jl}))}))(),1),dl={jpg:`image/jpeg`,jpeg:`image/jpeg`,png:`image/png`,gif:`image/gif`,webp:`image/webp`,svg:`image/svg+xml`,bmp:`image/bmp`,avif:`image/avif`,mp3:`audio/mpeg`,wav:`audio/wav`,ogg:`audio/ogg`,mp4:`video/mp4`,webm:`video/webm`},fl=100,pl=15e3,ml=1e-6,hl=/(?:^data:image\/(?:gif|webp|avif)[;,]|\.(?:gif|webp|avif)(?:[?#]|$))/i,gl=`svg.block-svg`,_l=16,vl=1e101,yl=`.doc-player__media-clips`,bl=`${yl} video[data-clip-id]`,xl=`.caption-overlay, .social-caption-overlay`,Sl=`.doc-player__block--cover`;function Cl(e=1){return new Promise(t=>{let n=!1,r=null,i=()=>{n||(n=!0,window.clearTimeout(a),r!==null&&window.cancelAnimationFrame(r),t())},a=window.setTimeout(i,document.visibilityState===`visible`?fl:0);if(document.visibilityState!==`visible`)return;let o=e=>{r=window.requestAnimationFrame(()=>{e<=1?i():o(e-1)})};o(Math.max(1,e))})}async function wl(e){let t=e.currentSrc||e.src;if(!t)return;let n=typeof e.decode==`function`?e.decode():new Promise((n,r)=>{if(e.complete){e.naturalWidth>0?n():r(Error(`Image could not be decoded: ${t}`));return}e.addEventListener(`load`,()=>n(),{once:!0}),e.addEventListener(`error`,()=>r(Error(`Image could not be loaded: ${t}`)),{once:!0})}),r;try{await Promise.race([n,new Promise((e,n)=>{r=setTimeout(()=>n(Error(`Image did not become ready within 15s: ${t}`)),pl)})])}finally{r!==void 0&&clearTimeout(r)}}async function Tl(e,t=new WeakSet){let n=e.ownerDocument.fonts;n&&await n.ready;let r=Array.from(e.querySelectorAll(`img`)).filter(e=>!t.has(e));await Promise.all(r.map(async e=>{await wl(e),t.add(e)}))}function El(e,t,n,r){return n()?Promise.resolve():new Promise((i,a)=>{let o=!1,s=[`loadedmetadata`,`durationchange`,`loadeddata`,`canplay`,`seeked`],c=()=>{clearTimeout(f),clearInterval(p),s.forEach(t=>e.removeEventListener(t,d)),e.removeEventListener(`error`,u)},l=()=>{o||(o=!0,c(),i())},u=()=>{o||(o=!0,c(),a(Error(`Video did not become ready while ${t} within 15s: ${e.currentSrc||e.src}`)))};function d(){n()&&l()}let f=setTimeout(u,pl),p=setInterval(d,_l);s.forEach(t=>e.addEventListener(t,d)),e.addEventListener(`error`,u,{once:!0});try{r?.(),queueMicrotask(d)}catch(e){o=!0,c(),a(e)}})}function Dl(e,t){return e.readyState>=HTMLMediaElement.HAVE_METADATA&&e.videoWidth<=0&&e.videoHeight<=0?!1:!t.has(e)||!Number.isFinite(e.duration)}async function Ol(e,t=new WeakSet){let n=Array.from(e.querySelectorAll(`video`)).filter(e=>Dl(e,t)),r=0;return await Promise.all(n.map(async e=>{if(!(e.currentSrc||e.src))return;if(await El(e,`loading capture metadata`,()=>e.readyState>=HTMLMediaElement.HAVE_METADATA),e.videoWidth<=0&&e.videoHeight<=0){t.add(e);return}if(Number.isFinite(e.duration)){e.dataset.captureSequential=`true`,t.add(e);return}let n=Number.isFinite(e.currentTime)?Math.max(0,e.currentTime):0;e.pause(),await El(e,`indexing an indeterminate-duration capture source`,()=>Number.isFinite(e.duration)&&e.duration>0&&!e.seeking&&e.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA,()=>{e.currentTime=vl});let i=Math.min(n,e.duration);await El(e,`restoring the capture source after indexing`,()=>!e.seeking&&e.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA&&Math.abs(e.currentTime-i)<=.01,()=>{e.currentTime=i}),e.dataset.captureSequential=`true`,t.add(e),r+=1})),r}function kl(e){let t=new Map,n=new Map,r=new Map;for(let[i,a]of e){let e=dl[i.split(`.`).pop()?.toLowerCase()??``]??`application/octet-stream`;t.set(i,URL.createObjectURL(new Blob([a],{type:e}))),n.set(i,e),r.set(i,a.byteLength)}return{async resolveUrl(e){return t.get(e)??e},async listMedia(){return[...t.keys()].map(e=>({name:e,mimeType:n.get(e)??`application/octet-stream`,size:r.get(e)??0}))},async addMedia(){throw Error(`Read-only`)},async removeMedia(){throw Error(`Read-only`)},dispose(){t.forEach(e=>URL.revokeObjectURL(e)),t.clear(),r.clear()}}}function Al(e){let t=new Set,n=0,r=0;return{provider:{resolveUrl(r){n+=1;let i=e.resolveUrl(r),a=i.then(()=>{t.delete(a)},()=>{t.delete(a)});return t.add(a),i},listMedia:()=>e.listMedia(),addMedia:(t,n,r)=>e.addMedia(t,n,r),removeMedia:t=>e.removeMedia(t),dispose:()=>void 0},async waitForSettled(){for(;t.size>0;)await Promise.all([...t]);let e=n!==r;return r=n,e}}}async function jl(e){for(;await e?.waitForSettled();)await Cl()}function Ml(e,t){let{head:n}=t.ownerDocument,r=e===n||n.contains(e),i=e===t||e.contains(t)||t.contains(e);return!r&&!i}function Nl(e){return Number.isFinite(e)?e.toFixed(6):`unknown`}function Pl(e,t,n,r){let i=e/t,a=n/r;if(i>a){let n=t*a;return{sx:(e-n)/2,sy:0,sw:n,sh:t}}let o=e/a;return{sx:0,sy:(t-o)/2,sw:e,sh:o}}function Fl(e,t,n,r,i){if(i===`cover`)return{...Pl(e,t,n,r),dx:0,dy:0,dw:n,dh:r};if(i===`contain`||i===`scale-down`){let a=Math.min(n/e,r/t),o=i===`scale-down`?Math.min(1,a):a,s=e*o,c=t*o;return{sx:0,sy:0,sw:e,sh:t,dx:(n-s)/2,dy:(r-c)/2,dw:s,dh:c}}return i===`none`?{sx:0,sy:0,sw:e,sh:t,dx:(n-e)/2,dy:(r-t)/2,dw:e,dh:t}:{sx:0,sy:0,sw:e,sh:t,dx:0,dy:0,dw:n,dh:r}}function Il(e,t){let n=[{original:`.doc-player__media-clips video[data-clip-id]`,clone:`.doc-player__media-clips canvas`},{original:`.block-layer--video video[data-clip-start]`,clone:`.block-layer--video canvas`}].flatMap(({original:n,clone:r})=>{let i=Array.from(e.querySelectorAll(n)),a=Array.from(t.querySelectorAll(r));return i.flatMap((e,t)=>{let n=a[t];return n?[{video:e,canvas:n}]:[]})}),r=n.map(({canvas:e})=>e);return n.forEach(({video:n,canvas:r})=>{r.className=n.className,r.style.cssText=n.style.cssText;for(let e of Array.from(n.attributes))e.name.startsWith(`data-`)&&r.setAttribute(e.name,e.value);r.dataset.videoCaptureClone=`true`;let i=Math.round(n.clientWidth||n.offsetWidth),a=Math.round(n.clientHeight||n.offsetHeight);if(!(n.videoWidth<=0||n.videoHeight<=0||i<=0||a<=0))try{let o=n.ownerDocument.defaultView,s=n.style.objectFit||o?.getComputedStyle(n).objectFit||`fill`,c=Fl(n.videoWidth,n.videoHeight,i,a,s),l=r.getContext(`2d`);if(!l)return;r.width=i,r.height=a,l.drawImage(n,c.sx,c.sy,c.sw,c.sh,c.dx,c.dy,c.dw,c.dh);let u=r.closest(`foreignObject`),d=r.closest(`svg`);if(u&&d){let o=n.closest(`.doc-player__block`)??e,s=d.closest(`.doc-player__block`)??t,c=n.getBoundingClientRect(),l=o.getBoundingClientRect(),f=c.width||i,p=c.height||a,m=Number.parseFloat(u.getAttribute(`x`)??`0`)||0,h=Number.parseFloat(u.getAttribute(`y`)??`0`)||0,g=c.width?c.left-l.left:m,_=c.height?c.top-l.top:h;u.remove(),s===t&&!s.style.position&&(s.style.position=`relative`),r.style.position=`absolute`,r.style.left=`${g}px`,r.style.top=`${_}px`,r.style.width=`${f}px`,r.style.height=`${p}px`,r.style.zIndex=`3`,r.style.margin=`0`,r.style.transform=`none`,s.appendChild(r)}}catch{}}),r}function Ll(){return new Map}function Rl(e){e.canvas.width=0,e.canvas.height=0}function zl(e){e.forEach(Rl),e.clear()}function Bl(e){if(!e)return 0;let t=/^\s*(\d+(?:\.\d+)?|\.\d+)(?:px)?\s*$/i.exec(e);return t?Number.parseFloat(t[1]):0}function Vl(e){let t=(e.getAttribute(`viewBox`)??``).trim().split(/[\s,]+/).map(Number);return t.length===4&&t.every(Number.isFinite)?{width:Math.max(0,t[2]),height:Math.max(0,t[3])}:{width:0,height:0}}function Hl(e,t){let n=e.getBoundingClientRect(),r=t?.getBoundingClientRect(),i=Vl(e),a=t?Vl(t):{width:0,height:0},o=n.width||r?.width||Bl(e.getAttribute(`width`))||(t?Bl(t.getAttribute(`width`)):0)||i.width||a.width,s=n.height||r?.height||Bl(e.getAttribute(`height`))||(t?Bl(t.getAttribute(`height`)):0)||i.height||a.height;return{width:Math.max(1,Math.round(o)),height:Math.max(1,Math.round(s))}}function Ul(e,t){for(let n of Array.from(e.attributes))(n.name===`id`||n.name===`class`||n.name===`style`||n.name.startsWith(`data-`)||n.name.startsWith(`aria-`))&&t.setAttribute(n.name,n.value);t.dataset.svgCaptureClone=`true`}function Wl(e,t){return t.type?t.type:dl[e.split(/[?#]/,1)[0].split(`.`).pop()?.toLowerCase()??``]??`application/octet-stream`}function Gl(e,t){let n=e.type?e:e.slice(0,e.size,Wl(t,e));return new Promise((e,r)=>{let i=new FileReader;i.addEventListener(`load`,()=>{typeof i.result==`string`?e(i.result):r(Error(`Image could not be embedded for SVG capture: ${t}`))},{once:!0}),i.addEventListener(`error`,()=>r(i.error??Error(`Image could not be read for SVG capture: ${t}`)),{once:!0}),i.readAsDataURL(n)})}function Kl(e,t){let n=t.get(e);if(n)return n;let r=fetch(e).then(async t=>{if(!t.ok)throw Error(`Image could not be loaded for SVG capture: ${e}`);return Gl(await t.blob(),e)});return t.set(e,r),r}function ql(e){if(e.localName===`img`){let t=e.getAttribute(`src`)??``;return t?{source:t,replace:t=>e.setAttribute(`src`,t)}:null}let t=`http://www.w3.org/1999/xlink`,n=e.getAttribute(`href`)??e.getAttributeNS(t,`href`)??``;return n?{source:n,replace:n=>{e.hasAttribute(`href`)&&e.setAttribute(`href`,n),e.hasAttributeNS(t,`href`)&&e.setAttributeNS(t,`href`,n)}}:null}async function Jl(e,t){let n=Array.from(e.querySelectorAll(`image, img`)).map(ql).filter(e=>e!==null);for(let e of n){if(/^data:/i.test(e.source)||e.source.startsWith(`#`))continue;let n=await Kl(e.source,t);e.replace(n)}}function Yl(e,t){let n=e.dataset.blockId;return n?`block:${n}`:`index:${t}`}async function Xl(e,t,n=[],r=new Map,i){let a=i??Ll(),o=i===void 0,s=Array.from(e.querySelectorAll(gl)),c=Array.from(t.querySelectorAll(gl)),l=new Set;try{for(let[t,i]of c.entries()){let o=s[t],{width:c,height:u}=Hl(i,o),d=Yl(o??i,t);l.add(d),i.setAttribute(`xmlns`,`http://www.w3.org/2000/svg`),i.setAttribute(`width`,String(c)),i.setAttribute(`height`,String(u));let f=null,p=null,m=null,h=null;try{await Jl(i,r);let t=new XMLSerializer().serializeToString(i),o=a.get(d);if(!o||o.serializedSvg!==t||o.width!==c||o.height!==u){let n=i.querySelector(`foreignObject`)!==null;if(m=i.ownerDocument.createElement(`img`),m.decoding=`sync`,m.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`,await wl(m),!n&&typeof createImageBitmap==`function`)try{f=await createImageBitmap(m)}catch{f=null}h=o?.canvas??e.ownerDocument.createElement(`canvas`),(h.width!==c||h.height!==u)&&(h.width=c,h.height=u);let r=h.getContext(`2d`);if(!r)throw Error(`Could not create the cached SVG raster canvas context`);r.clearRect(0,0,c,u),r.drawImage(f??m,0,0,c,u),o={serializedSvg:t,width:c,height:u,canvas:h},a.set(d,o)}p=i.ownerDocument.createElement(`canvas`),p.width=c,p.height=u,Ul(i,p);let s=p.getContext(`2d`);if(!s)throw Error(`Could not create the SVG capture canvas context`);s.drawImage(o.canvas,0,0,c,u),i.replaceWith(p),n.push(p)}catch(e){p&&!p.isConnected&&(p.width=0,p.height=0),h&&a.get(d)?.canvas!==h&&(h.width=0,h.height=0);let t=e instanceof Error?e.message:String(e);throw Error(`Could not rasterize a full-slide SVG for frame capture: ${t}`)}finally{f?.close(),m?.removeAttribute(`src`)}}for(let[e,t]of a)l.has(e)||(Rl(t),a.delete(e));return n}finally{o&&zl(a)}}function Zl(e){e.forEach(e=>{e.width=0,e.height=0})}function Ql(e){return e.videoWidth>0&&e.videoHeight>0&&e.dataset.active===`true`}function $l(e){return e.closest(yl)?.dataset.presentation}function eu(e,t={}){let n=Array.from(e.querySelectorAll(bl)).filter(Ql);if(n.length===0)return null;let r=[],i=[];for(let e of n){let n=$l(e);if(n===`background`)r.push(e);else if(n===`picture-in-picture`)i.push(e);else if(n===`full-frame`&&t.includeFullFrameOverlays)i.push(e);else return null}return{underlays:r,overlays:i}}function tu(e,t={}){let n=eu(e,t);return n?e.querySelector(Sl)?{underlays:[],overlays:[]}:n:null}function nu(e,t){for(let n of t)for(let t=n.parentElement;t;t=t===e?null:t.parentElement)t.style.backgroundColor=`transparent`,t.style.backgroundImage=`none`}function ru(e){nu(e,Array.from(e.querySelectorAll(`${yl}[data-presentation="background"]`)))}function iu(e){return Array.from(e.querySelectorAll(xl))}function au(e){nu(e,iu(e))}function ou(e,t,n){return Ml(e,t)?!0:e===t||e.contains(t)||!t.contains(e)?!1:!n.some(t=>t===e||t.contains(e)||e.contains(t))}function su(e,t,n,r){return JSON.stringify({markup:e.map(e=>e.outerHTML),fontStatus:t.fonts?.status??`unsupported`,width:n,height:r})}function cu(e){let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function lu(e,t,n){return e.trim().endsWith(`%`)?cu(e)/100*Math.min(t,n):cu(e)}function uu(e,t,n,r){if(!t||t===`none`)return;let i=t.match(/rgba?\([^)]*\)|#[0-9a-f]{3,8}\b/i)?.[0];if(!i)return;let a=Array.from(t.replace(i,``).matchAll(/(-?\d+(?:\.\d+)?)px/g),e=>Number.parseFloat(e[1]));e.shadowColor=i,e.shadowOffsetX=(a[0]??0)*n,e.shadowOffsetY=(a[1]??0)*r,e.shadowBlur=(a[2]??0)*Math.max(n,r)}function du(e,t,n,r,i,a){e.beginPath(),typeof e.roundRect==`function`?e.roundRect(t,n,r,i,Math.max(0,a)):e.rect(t,n,r,i)}function fu(e,t,n){let r=e.getContext(`2d`);if(!r)throw Error(`Could not create the scheduled-video compositor canvas context`);let i=t.getBoundingClientRect();if(i.width<=0||i.height<=0)return 0;let a=e.width/i.width,o=e.height/i.height;for(let e of n){let t=e.getBoundingClientRect();if(t.width<=0||t.height<=0)continue;let n=e.ownerDocument.defaultView?.getComputedStyle(e);if(!n||n.display===`none`||n.visibility===`hidden`||n.visibility===`collapse`)continue;let s=Number.parseFloat(n.opacity||`1`);if(s<=0)continue;let c=cu(n.borderLeftWidth),l=cu(n.borderRightWidth),u=cu(n.borderTopWidth),d=cu(n.borderBottomWidth),f=Math.max(1,t.width-c-l),p=Math.max(1,t.height-u-d),m=(t.left-i.left)*a,h=(t.top-i.top)*o,g=t.width*a,_=t.height*o,v=m+c*a,y=h+u*o,b=f*a,x=p*o,S=lu(n.borderTopLeftRadius,t.width,t.height)*Math.max(a,o),C=Math.max(0,S-Math.max(c*a,u*o)),w=Fl(e.videoWidth,e.videoHeight,f,p,n.objectFit||`fill`);r.save(),r.globalAlpha=Number.isFinite(s)?s:1,uu(r,n.boxShadow,a,o),du(r,m,h,g,_,S),r.fillStyle=n.borderTopStyle===`none`||u<=0?`rgba(0, 0, 0, 0.001)`:n.borderTopColor,r.fill(),r.shadowColor=`rgba(0, 0, 0, 0)`,r.shadowBlur=0,r.shadowOffsetX=0,r.shadowOffsetY=0,du(r,v,y,b,x,C),r.clip(),r.drawImage(e,w.sx,w.sy,w.sw,w.sh,v,y,b,x),r.restore()}return n.length}function pu(e,t,n={}){let r=e.innerHTML,i=!1,a=[];typeof e.getAnimations==`function`?e.getAnimations({subtree:!0}).forEach((e,t)=>{try{let n=e.effect?.getComputedTiming();if(!n){i=!0;return}a.push(`${t}:${e.playState}:${String(n.progress)}:${String(n.currentIteration)}`)}catch{i=!0}}):/\b(?:anim-|transition-)|animation(?:-name)?\s*:/i.test(r)&&(i=!0);let o=Array.from(e.querySelectorAll(`img`)).map(e=>{let t=e.currentSrc||e.src;return hl.test(t)&&(i=!0),`${t}:${e.complete}:${e.naturalWidth}x${e.naturalHeight}`});hl.test(r)&&(i=!0);let s=Array.from(e.querySelectorAll(`video`)).filter(e=>e.videoWidth>0&&e.videoHeight>0&&(!n.ignoreScheduledVideoFrames||!e.closest(yl))).map(e=>`${e.currentSrc||e.src}:${Nl(e.currentTime)}:${e.readyState}:${e.videoWidth}x${e.videoHeight}`);e.querySelector(`canvas, iframe, object, embed, animate, animateMotion, animateTransform, set`)&&(i=!0);let c=e.ownerDocument.fonts?.status??`unsupported`;return JSON.stringify({markup:r,animationStates:a,imageStates:o,videoStates:s,fontStatus:c,timelineTime:i?t.toFixed(6):null})}function mu(){let e=(0,G.useRef)(null),t=(0,G.useRef)(null),n=(0,G.useRef)(null),r=(0,G.useRef)(null),i=(0,G.useRef)(null),a=(0,G.useRef)(!1),o=(0,G.useRef)(null),s=(0,G.useRef)(null),c=(0,G.useRef)(null),l=(0,G.useRef)(!1),u=(0,G.useRef)(new WeakSet),d=(0,G.useRef)(new Map),f=(0,G.useRef)(Ll()),p=(0,G.useRef)(new WeakSet),m=(0,G.useRef)({width:1920,height:1080}),h=(0,G.useRef)(null),g=(0,G.useRef)(null),_=(0,G.useRef)(!1),v=(0,G.useCallback)(async(v,y,b)=>{if(t.current||e.current||r.current||o.current||s.current){let m=t.current,v=e.current,y=r.current,b=a.current,x=o.current,S=s.current,C=h.current;t.current=null,e.current=null,n.current=null,r.current=null,i.current=null,a.current=!1,o.current=null,s.current=null,h.current=null,g.current=null,_.current=!1,c.current=null,l.current=!1,u.current=new WeakSet,d.current.clear(),zl(f.current),f.current=Ll(),p.current=new WeakSet,await new Promise(e=>{setTimeout(()=>{m&&m.unmount(),v&&v.remove(),b&&y?.dispose(),x&&(x.width=0,x.height=0),S&&(S.width=0,S.height=0),C&&(C.width=0,C.height=0),e()},0)})}let x=y.width??1920,S=y.height??1080,w=y.animationsEnabled??!0;m.current={width:x,height:S};let T=document.createElement(`canvas`);T.width=x,T.height=S,T.style.width=`${x}px`,T.style.height=`${S}px`,o.current=T;let E=document.createElement(`canvas`);E.width=x,E.height=S,E.style.width=`${x}px`,E.style.height=`${S}px`,s.current=E,g.current=null,_.current=!1,c.current=null,l.current=!1,u.current=new WeakSet,d.current.clear(),zl(f.current),f.current=Ll(),p.current=new WeakSet;let D=document.createElement(`div`);D.style.cssText=`position:fixed;left:0;top:0;width:${x}px;height:${S}px;opacity:0;pointer-events:none;z-index:-1;overflow:hidden;`,document.body.appendChild(D),e.current=D;let O=document.createElement(`div`);O.id=`squisq-capture-root`,O.style.cssText=`width:${x}px;height:${S}px;`,D.appendChild(O);let k=y.images?kl(y.images):y.mediaProvider??null;r.current=k;let A=k?Al(k):null;i.current=A,a.current=!!y.images;let j=(0,Gr.createRoot)(O);t.current=j;let M=b!==void 0&&b!==`off`,N=b===`social`?`social`:`standard`,P,F=new Promise(e=>{P=e}),I=(0,G.createElement)(Bn,{doc:v,basePath:`.`,renderMode:!0,animationsEnabled:w,showControls:!1,autoPlay:!1,forceViewport:{width:x,height:S,name:`export`},theme:y.theme,displayMode:y.displayMode,dashboardLayout:y.dashboard?.layout,dashboardShowTitle:y.dashboard?.title,dashboardStyle:C(y.dashboard?.style),dashboardDocumentTitle:y.dashboard?.documentTitle,videoPresentation:y.videoPresentation,pipSize:y.pipSize,pipShape:y.pipShape,pipPosition:y.pipPosition,showCoverSlide:y.showCoverSlide,coverSlideTemplate:y.coverSlideTemplate,captionsEnabled:M,captionStyle:N,onRenderAPIReady:t=>{e.current===D&&(n.current=t,t&&P(t))}});return await new Promise(e=>setTimeout(e,0)),k?j.render((0,G.createElement)(pn.Provider,{value:A.provider},I)):j.render(I),new Promise((t,r)=>{let a=setTimeout(()=>{let t=n.current,i=typeof t?.seekTo==`function`,a=typeof t?.getDuration==`function`,o=e.current?.querySelector(`#squisq-capture-root`),s=o?o.querySelector(`.doc-player`)!==null:!1;r(Error(`Render API did not initialize within 15s. seekTo=${i}, getDuration=${a}, player=${s}, root=${!!o}`))},15e3);F.then(async e=>{try{let n=D.querySelector(`#squisq-capture-root`);if(!(n instanceof HTMLElement))throw Error(`Capture root element not found after player initialization.`);await jl(i.current),await Tl(n,u.current),await Ol(n,p.current),clearTimeout(a),t(e.getDuration())}catch(e){clearTimeout(a),r(e)}})})},[]),y=(0,G.useCallback)(async e=>{let t=n.current;if(!t)throw Error(`Frame capture not initialized — call init() first`);e?await t.showCover():await t.hideCover(),c.current=null},[]),b=(0,G.useCallback)(async(t,r={})=>{let a=e.current,v=n.current,y=o.current,b=s.current;if(!a||!v||!y||!b)throw Error(`Frame capture not initialized — call init() first`);let{width:x,height:S}=m.current,C=a.querySelector(`#squisq-capture-root`);if(!C)throw Error(`Capture root element not found`);await Ol(C,p.current);try{await v.seekTo(t)}catch(e){if(!await Ol(C,p.current))throw e;await v.seekTo(t)}await Ol(C,p.current)&&await v.seekTo(t);let w=v.getRenderedTime();if(Math.abs(w-t)>ml)throw Error(`Player committed ${w.toFixed(6)}s while capture requested ${t.toFixed(6)}s.`);await jl(i.current),await Tl(C,u.current);let T=tu(C,{includeFullFrameOverlays:!0}),E=T!==null&&T.underlays.length>0,D=T?E?`base-underlay`:`base`:`full`,O=r.reuseIfUnchanged?`${D}:${pu(C,t,{ignoreScheduledVideoFrames:T!==null})}`:null,k=O===null||!l.current||c.current!==O;if(!k&&!T)return y;let A=T?b:y,j=A.getContext(`2d`);if(!j)throw Error(`Could not create the frame capture canvas context`);k&&(j.setTransform(1,0,0,1,0,0),j.clearRect(0,0,x,S));let M=[];if(k){try{await(0,ul.default)(C,{canvas:A,width:x,height:S,scale:1,useCORS:!0,allowTaint:!0,backgroundColor:E?null:`#000000`,logging:!1,onclone:async(e,t)=>{T&&(E&&ru(t),t.querySelectorAll(yl).forEach(e=>e.remove()),t.querySelectorAll(xl).forEach(e=>e.remove())),M.push(...Il(C,t)),await Xl(C,t,M,d.current,f.current)},ignoreElements:e=>Ml(e,C)})}finally{Zl(M)}l.current=!0,c.current=O}if(T){let e=y.getContext(`2d`);if(!e)throw Error(`Could not create the frame output canvas context`);e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,x,S),e.fillStyle=`#000000`,e.fillRect(0,0,x,S),fu(y,C,T.underlays),e.drawImage(b,0,0),fu(y,C,T.overlays);let t=iu(C);if(t.length>0){let n=t.some(e=>(e.textContent??``).trim().length>0),r=su(t,C.ownerDocument,x,S);if(g.current!==r){if(n){let e=h.current;e||(e=document.createElement(`canvas`),h.current=e),(e.width!==x||e.height!==S)&&(e.width=x,e.height=S);let n=e.getContext(`2d`);if(!n)throw Error(`Could not create the caption layer canvas context`);n.setTransform(1,0,0,1,0,0),n.clearRect(0,0,x,S),await(0,ul.default)(C,{canvas:e,width:x,height:S,scale:1,useCORS:!0,allowTaint:!0,backgroundColor:null,logging:!1,onclone:(e,t)=>{au(t)},ignoreElements:e=>ou(e,C,t)})}g.current=r,_.current=n}if(_.current&&h.current){let n=Number.parseFloat(C.ownerDocument.defaultView?.getComputedStyle(t[0]).opacity??`1`);(!Number.isFinite(n)||n>0)&&(e.save(),e.globalAlpha=Number.isFinite(n)?n:1,e.drawImage(h.current,0,0),e.restore())}}}return y},[]),x=(0,G.useCallback)(async(e,t={})=>{let n=await b(e,t);return createImageBitmap(n)},[b]),S=(0,G.useCallback)(()=>{t.current&&=(t.current.unmount(),null),e.current&&=(e.current.remove(),null),a.current&&r.current?.dispose(),r.current=null,i.current=null,a.current=!1,o.current&&=(o.current.width=0,o.current.height=0,null),s.current&&=(s.current.width=0,s.current.height=0,null),h.current&&=(h.current.width=0,h.current.height=0,null),g.current=null,_.current=!1,c.current=null,l.current=!1,u.current=new WeakSet,d.current.clear(),zl(f.current),f.current=Ll(),p.current=new WeakSet,n.current=null},[]);return(0,G.useMemo)(()=>({init:v,setCoverVisible:y,captureFrame:x,captureCanvasFrame:b,destroy:S}),[v,y,x,b,S])}var hu=64,gu=7680,_u=33177600,vu=[{label:`YouTube cover`,width:1280,height:720}],yu=al;function bu(e,t){return!Number.isSafeInteger(e)||!Number.isSafeInteger(t)?`Width and height must be whole numbers.`:e<hu||t<hu||e>gu||t>gu?`Width and height must be between ${hu} and ${gu} pixels.`:e*t>_u?`Resolution is too large. Choose a size at or below 33 megapixels.`:null}function xu(e,t){return ol(e,`cover`,t)}var Su={position:`fixed`,inset:0,zIndex:1e4,display:`flex`,alignItems:`center`,justifyContent:`center`,background:`rgba(0, 0, 0, 0.55)`},Cu={display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:12},wu={display:`grid`,gap:5,marginBottom:12,fontSize:13,fontWeight:600};function Tu({doc:e,mediaProvider:t,theme:n,coverSlideTemplate:r,defaultWidth:i=1920,defaultHeight:a=1080,defaultFileName:o,colorScheme:s=`light`,saveOutput:c,onClose:l}){let u=(0,G.useRef)(null),d=(0,G.useRef)(null),f=(0,G.useId)(),p=mu(),[m,h]=(0,G.useState)(`png`),[g,_]=(0,G.useState)(i),[v,y]=(0,G.useState)(a),[b,x]=(0,G.useState)(.92),[S,C]=(0,G.useState)(!1),[w,T]=(0,G.useState)(null),E=s===`dark`,D=E?`#111827`:`#ffffff`,O=E?`#0f172a`:`#ffffff`,k=E?`#f8fafc`:`#1f2937`,A=E?`#94a3b8`:`#6b7280`,j=E?`#475569`:`#cbd5e1`,M=xu(o,m),N=bu(g,v),P=(0,G.useCallback)(()=>{S||(p.destroy(),l())},[S,p,l]);Ur({rootRef:u,dialogRef:d,closeOnEscape:!S,onClose:P});let F=(0,G.useCallback)(async()=>{if(!(N||!e.startBlock)){T(null);try{let i=c?void 0:await cl(M,m);if(i===null)return;C(!0),await p.init(e,{width:g,height:v,animationsEnabled:!1,theme:n,mediaProvider:t??void 0,showCoverSlide:!0,coverSlideTemplate:r},`off`),await p.setCoverVisible(!0);let a=await sl(await p.captureCanvasFrame(0),m,b);if(c){if(await c(a,M)===!1){p.destroy();return}}else if(i){let e=await i.createWritable();await e.write(a),await e.close()}else ll(a,M);p.destroy(),l()}catch(e){p.destroy(),T(e instanceof Error?e.message:`The cover image could not be exported.`)}finally{C(!1)}}},[p,r,N,e,M,m,v,t,l,b,c,n,g]),I={boxSizing:`border-box`,width:`100%`,minHeight:34,border:`1px solid ${j}`,borderRadius:4,background:O,color:k,padding:`6px 8px`,colorScheme:s};return(0,K.jsx)(`div`,{ref:u,style:Su,"data-color-scheme":s,onClick:e=>e.stopPropagation(),children:(0,K.jsxs)(`div`,{ref:d,role:`dialog`,"aria-modal":`true`,"aria-labelledby":f,tabIndex:-1,style:{position:`relative`,boxSizing:`border-box`,width:`min(440px, calc(100vw - 32px))`,padding:24,border:`1px solid ${j}`,borderRadius:8,background:D,color:k,boxShadow:`0 18px 48px rgba(0, 0, 0, 0.28)`,fontFamily:`system-ui, -apple-system, sans-serif`,colorScheme:s},onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(`h2`,{id:f,style:{margin:`0 36px 18px 0`,fontSize:19},children:`Export cover slide`}),(0,K.jsx)(`button`,{type:`button`,"aria-label":`Close cover image export`,disabled:S,onClick:P,style:{position:`absolute`,top:12,right:12,width:32,height:32,border:0,background:`transparent`,color:k,fontSize:24,cursor:S?`default`:`pointer`},children:(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`×`})}),(0,K.jsxs)(`label`,{style:wu,children:[`Format`,(0,K.jsx)(`select`,{"aria-label":`Image format`,value:m,disabled:S,onChange:e=>h(e.target.value),style:I,children:Object.entries(yu).map(([e,t])=>(0,K.jsx)(`option`,{value:e,children:t.label},e))})]}),(0,K.jsxs)(`div`,{style:Cu,children:[(0,K.jsxs)(`label`,{style:wu,children:[`Width`,(0,K.jsx)(`input`,{"aria-label":`Image width`,type:`number`,min:hu,max:gu,step:1,value:g,disabled:S,onChange:e=>_(Number(e.target.value)),style:I})]}),(0,K.jsxs)(`label`,{style:wu,children:[`Height`,(0,K.jsx)(`input`,{"aria-label":`Image height`,type:`number`,min:hu,max:gu,step:1,value:v,disabled:S,onChange:e=>y(Number(e.target.value)),style:I})]})]}),(0,K.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8,margin:`-2px 0 14px`},children:[(0,K.jsx)(`button`,{type:`button`,disabled:S,onClick:()=>{_(i),y(a)},children:`1×`}),(0,K.jsx)(`button`,{type:`button`,disabled:S,onClick:()=>{_(i*2),y(a*2)},children:`2×`}),vu.map(e=>(0,K.jsx)(`button`,{type:`button`,disabled:S,title:`${e.width} \xD7 ${e.height} pixels`,onClick:()=>{_(e.width),y(e.height)},children:e.label},e.label)),(0,K.jsxs)(`span`,{style:{alignSelf:`center`,color:A,fontSize:12},children:[g.toLocaleString(),` × `,v.toLocaleString(),` pixels`]})]}),m!==`png`&&(0,K.jsxs)(`label`,{style:wu,children:[`Quality: `,Math.round(b*100),`%`,(0,K.jsx)(`input`,{"aria-label":`Image quality`,type:`range`,min:.5,max:1,step:.05,value:b,disabled:S,onChange:e=>x(Number(e.target.value))})]}),(N||w)&&(0,K.jsx)(`p`,{role:`alert`,style:{margin:`0 0 12px`,color:E?`#fca5a5`:`#b91c1c`},children:N??w}),!e.startBlock&&(0,K.jsx)(`p`,{role:`alert`,style:{margin:`0 0 12px`,color:E?`#fca5a5`:`#b91c1c`},children:`This document does not have a cover slide to export.`}),(0,K.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8},children:[(0,K.jsx)(`button`,{type:`button`,disabled:S,onClick:P,children:`Cancel`}),(0,K.jsx)(`button`,{type:`button`,disabled:S||!!N||!e.startBlock,onClick:()=>void F(),style:{minWidth:132},children:S?`Rendering…`:`Choose location…`})]})]})})}var Eu=[{id:`hd`,label:`HD 1280×720`,width:1280,height:720,family:`landscape`},{id:`fhd`,label:`Full HD 1920×1080`,width:1920,height:1080,family:`landscape`},{id:`4k`,label:`4K UHD 3840×2160`,width:3840,height:2160,family:`landscape`},{id:`square`,label:`Square 1080×1080`,width:1080,height:1080,family:`square`},{id:`square-2k`,label:`Square 2160×2160`,width:2160,height:2160,family:`square`},{id:`portrait`,label:`Portrait 1080×1920`,width:1080,height:1920,family:`portrait`},{id:`portrait-4k`,label:`Portrait 4K 2160×3840`,width:2160,height:3840,family:`portrait`},{id:`standard`,label:`4:3 1440×1080`,width:1440,height:1080,family:`standard`}],Du=7680,Ou=33177600;function ku(e,t){return!Number.isSafeInteger(e)||!Number.isSafeInteger(t)?`Width and height must be whole pixel counts.`:e<64||t<64?`Each dimension must be at least 64 pixels.`:e>7680||t>7680?`Each dimension must be at most ${Du} pixels.`:e*t>33177600?`The image may not exceed ${Ou.toLocaleString(`en-US`)} total pixels.`:null}var Au=`custom`;function ju(e){return e?(e.split(/[\\/]/).pop()??``).replace(/\.[^.]+$/,``).trim():``}var Mu={position:`fixed`,inset:0,zIndex:1e4,display:`flex`,alignItems:`center`,justifyContent:`center`,background:`rgba(0, 0, 0, 0.55)`},Nu={display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:12},Pu={display:`grid`,gap:5,marginBottom:12,fontSize:13,fontWeight:600};function Fu({doc:e,mediaProvider:t,theme:n,defaultResolution:r=`fhd`,defaultLayout:i=fe,defaultShowTitle:a=!0,defaultStyle:o=ge,defaultFileName:s,colorScheme:c=`light`,saveOutput:l,onClose:u}){let d=(0,G.useRef)(null),f=(0,G.useRef)(null),p=(0,G.useId)(),m=mu(),[h,g]=(0,G.useState)(`png`),[_,v]=(0,G.useState)(r),y=Eu.find(e=>e.id===r)??Eu[1],[b,x]=(0,G.useState)(y.width),[S,C]=(0,G.useState)(y.height),[w,T]=(0,G.useState)(i),[E,D]=(0,G.useState)(a),[O,k]=(0,G.useState)(o),[A,j]=(0,G.useState)(.92),[M,N]=(0,G.useState)(!1),[P,F]=(0,G.useState)(null),I=c===`dark`,L=I?`#111827`:`#ffffff`,ee=I?`#0f172a`:`#ffffff`,te=I?`#f8fafc`:`#1f2937`,R=I?`#94a3b8`:`#6b7280`,ne=I?`#475569`:`#cbd5e1`,re=(0,G.useMemo)(()=>Ne(e),[e]),z=_===Au,ie=Eu.find(e=>e.id===_),ae=z?b:ie?.width??y.width,oe=z?S:ie?.height??y.height,se=z?ku(ae,oe):null,ce=ol(s,`dashboard`,h),le=(0,G.useCallback)(()=>{M||(m.destroy(),u())},[M,m,u]);Ur({rootRef:d,dialogRef:f,closeOnEscape:!M,onClose:le});let B=(0,G.useCallback)(async()=>{if(!se){F(null);try{let r=l?void 0:await cl(ce,h);if(r===null)return;N(!0),await m.init(e,{width:ae,height:oe,animationsEnabled:!1,theme:n,mediaProvider:t??void 0,displayMode:`dashboard`,dashboard:{layout:w,title:E,style:O,documentTitle:ju(s)}},`off`);let i=await sl(await m.captureCanvasFrame(0),h,A);if(l){if(await l(i,ce)===!1){m.destroy();return}}else if(r){let e=await r.createWritable();await e.write(i),await e.close()}else ll(i,ce);m.destroy(),u()}catch(e){m.destroy(),F(e instanceof Error?e.message:`The dashboard image could not be exported.`)}finally{N(!1)}}},[m,s,se,e,ce,h,oe,w,t,u,A,l,E,O,n,ae]),ue={boxSizing:`border-box`,width:`100%`,minHeight:34,border:`1px solid ${ne}`,borderRadius:4,background:ee,color:te,padding:`6px 8px`,colorScheme:c},V=re.filter(e=>!e.custom),de=re.filter(e=>e.custom);return(0,K.jsx)(`div`,{ref:d,style:Mu,"data-color-scheme":c,onClick:e=>e.stopPropagation(),children:(0,K.jsxs)(`div`,{ref:f,role:`dialog`,"aria-modal":`true`,"aria-labelledby":p,tabIndex:-1,style:{position:`relative`,boxSizing:`border-box`,width:`min(440px, calc(100vw - 32px))`,padding:24,border:`1px solid ${ne}`,borderRadius:8,background:L,color:te,boxShadow:`0 18px 48px rgba(0, 0, 0, 0.28)`,fontFamily:`system-ui, -apple-system, sans-serif`,colorScheme:c},onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(`h2`,{id:p,style:{margin:`0 36px 18px 0`,fontSize:19},children:`Export dashboard as image`}),(0,K.jsx)(`button`,{type:`button`,"aria-label":`Close dashboard image export`,disabled:M,onClick:le,style:{position:`absolute`,top:12,right:12,width:32,height:32,border:0,background:`transparent`,color:te,fontSize:24,cursor:M?`default`:`pointer`},children:(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`×`})}),(0,K.jsxs)(`label`,{style:Pu,children:[`Format`,(0,K.jsx)(`select`,{"aria-label":`Image format`,value:h,disabled:M,onChange:e=>g(e.target.value),style:ue,children:Object.entries(al).map(([e,t])=>(0,K.jsx)(`option`,{value:e,children:t.label},e))})]}),(0,K.jsxs)(`label`,{style:Pu,children:[`Resolution`,(0,K.jsxs)(`select`,{"aria-label":`Image resolution`,value:_,disabled:M,onChange:e=>v(e.target.value),style:ue,children:[Eu.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.label},e.id)),(0,K.jsx)(`option`,{value:Au,children:`Custom…`})]})]}),z&&(0,K.jsxs)(`div`,{style:Nu,children:[(0,K.jsxs)(`label`,{style:Pu,children:[`Width`,(0,K.jsx)(`input`,{"aria-label":`Image width`,type:`number`,min:64,max:7680,step:1,value:b,disabled:M,onChange:e=>x(Number(e.target.value)),style:ue})]}),(0,K.jsxs)(`label`,{style:Pu,children:[`Height`,(0,K.jsx)(`input`,{"aria-label":`Image height`,type:`number`,min:64,max:7680,step:1,value:S,disabled:M,onChange:e=>C(Number(e.target.value)),style:ue})]})]}),(0,K.jsxs)(`label`,{style:Pu,children:[`Layout`,(0,K.jsxs)(`select`,{"aria-label":`Dashboard layout`,value:w,disabled:M,onChange:e=>T(e.target.value),style:ue,children:[(0,K.jsx)(`option`,{value:fe,children:`Auto`}),V.map(e=>(0,K.jsx)(`option`,{value:e.id,children:`${e.label} (${e.capacity})`},e.id)),de.length>0&&(0,K.jsx)(`optgroup`,{label:`Custom`,children:de.map(e=>(0,K.jsx)(`option`,{value:e.id,children:`${e.label} (${e.capacity})`},e.id))})]})]}),(0,K.jsxs)(`label`,{style:Pu,children:[`Style`,(0,K.jsx)(`select`,{"aria-label":`Dashboard cell style`,value:O,disabled:M,onChange:e=>k(e.target.value),style:ue,children:xe.map(e=>(0,K.jsx)(`option`,{value:e.id,title:e.description,children:e.label},e.id))})]}),(0,K.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:12,fontSize:13,fontWeight:600},children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:E,disabled:M,onChange:e=>D(e.target.checked)}),`Include document title`]}),h!==`png`&&(0,K.jsxs)(`label`,{style:Pu,children:[`Quality: `,Math.round(A*100),`%`,(0,K.jsx)(`input`,{"aria-label":`Image quality`,type:`range`,min:.5,max:1,step:.05,value:A,disabled:M,onChange:e=>j(Number(e.target.value))})]}),(0,K.jsxs)(`p`,{style:{margin:`0 0 12px`,color:R,fontSize:12},children:[ae.toLocaleString(),` × `,oe.toLocaleString(),` pixels`]}),(se||P)&&(0,K.jsx)(`p`,{role:`alert`,style:{margin:`0 0 12px`,color:I?`#fca5a5`:`#b91c1c`},children:se??P}),(0,K.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8},children:[(0,K.jsx)(`button`,{type:`button`,disabled:M,onClick:le,children:`Cancel`}),(0,K.jsx)(`button`,{type:`button`,disabled:M||!!se,onClick:()=>void B(),style:{minWidth:132},children:M?`Rendering…`:`Choose location…`})]})]})})}var Iu=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2`,Lu=`ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2`,Ru=`numeric`,zu=`ascii`,Bu=`alpha`,Vu=`asciinumeric`,Hu=`alphanumeric`,Uu=`domain`,Wu=`emoji`,Gu=`scheme`,Ku=`slashscheme`,qu=`whitespace`;function Ju(e,t){return e in t||(t[e]=[]),t[e]}function Yu(e,t,n){t[Ru]&&(t[Vu]=!0,t[Hu]=!0),t[zu]&&(t[Vu]=!0,t[Bu]=!0),t[Vu]&&(t[Hu]=!0),t[Bu]&&(t[Hu]=!0),t[Hu]&&(t[Uu]=!0),t[Wu]&&(t[Uu]=!0);for(let r in t){let t=Ju(r,n);t.indexOf(e)<0&&t.push(e)}}function Xu(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function Zu(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}Zu.groups={},Zu.prototype={accepts(){return!!this.t},go(e){let t=this,n=t.j[e];if(n)return n;for(let n=0;n<t.jr.length;n++){let r=t.jr[n][0],i=t.jr[n][1];if(i&&r.test(e))return i}return t.jd},has(e,t=!1){return t?e in this.j:!!this.go(e)},ta(e,t,n,r){for(let i=0;i<e.length;i++)this.tt(e[i],t,n,r)},tr(e,t,n,r){r||=Zu.groups;let i;return t&&t.j?i=t:(i=new Zu(t),n&&r&&Yu(t,n,r)),this.jr.push([e,i]),i},ts(e,t,n,r){let i=this,a=e.length;if(!a)return i;for(let t=0;t<a-1;t++)i=i.tt(e[t]);return i.tt(e[a-1],t,n,r)},tt(e,t,n,r){r||=Zu.groups;let i=this;if(t&&t.j)return i.j[e]=t,t;let a=t,o,s=i.go(e);return s?(o=new Zu,Object.assign(o.j,s.j),o.jr.push.apply(o.jr,s.jr),o.jd=s.jd,o.t=s.t):o=new Zu,a&&(r&&(o.t&&typeof o.t==`string`?Yu(a,Object.assign(Xu(o.t,r),n),r):n&&Yu(a,n,r)),o.t=a),i.j[e]=o,o}};var Qu=(e,t,n,r,i)=>e.ta(t,n,r,i),$u=(e,t,n,r,i)=>e.tr(t,n,r,i),ed=(e,t,n,r,i)=>e.ts(t,n,r,i),X=(e,t,n,r,i)=>e.tt(t,n,r,i),td=`WORD`,nd=`UWORD`,rd=`ASCIINUMERICAL`,id=`ALPHANUMERICAL`,ad=`LOCALHOST`,od=`TLD`,sd=`UTLD`,cd=`SCHEME`,ld=`SLASH_SCHEME`,ud=`NUM`,dd=`WS`,fd=`NL`,pd=`OPENBRACE`,md=`CLOSEBRACE`,hd=`OPENBRACKET`,gd=`CLOSEBRACKET`,_d=`OPENPAREN`,vd=`CLOSEPAREN`,yd=`OPENANGLEBRACKET`,bd=`CLOSEANGLEBRACKET`,xd=`FULLWIDTHLEFTPAREN`,Sd=`FULLWIDTHRIGHTPAREN`,Cd=`LEFTCORNERBRACKET`,wd=`RIGHTCORNERBRACKET`,Td=`LEFTWHITECORNERBRACKET`,Ed=`RIGHTWHITECORNERBRACKET`,Dd=`FULLWIDTHLESSTHAN`,Od=`FULLWIDTHGREATERTHAN`,kd=`AMPERSAND`,Ad=`APOSTROPHE`,jd=`ASTERISK`,Md=`AT`,Nd=`BACKSLASH`,Pd=`BACKTICK`,Fd=`CARET`,Id=`COLON`,Ld=`COMMA`,Rd=`DOLLAR`,zd=`DOT`,Bd=`EQUALS`,Vd=`EXCLAMATION`,Hd=`HYPHEN`,Ud=`PERCENT`,Wd=`PIPE`,Gd=`PLUS`,Kd=`POUND`,qd=`QUERY`,Jd=`QUOTE`,Yd=`FULLWIDTHMIDDLEDOT`,Xd=`SEMI`,Zd=`SLASH`,Qd=`TILDE`,$d=`UNDERSCORE`,ef=`EMOJI`,tf=`SYM`,nf=Object.freeze({__proto__:null,ALPHANUMERICAL:id,AMPERSAND:kd,APOSTROPHE:Ad,ASCIINUMERICAL:rd,ASTERISK:jd,AT:Md,BACKSLASH:Nd,BACKTICK:Pd,CARET:Fd,CLOSEANGLEBRACKET:bd,CLOSEBRACE:md,CLOSEBRACKET:gd,CLOSEPAREN:vd,COLON:Id,COMMA:Ld,DOLLAR:Rd,DOT:zd,EMOJI:ef,EQUALS:Bd,EXCLAMATION:Vd,FULLWIDTHGREATERTHAN:Od,FULLWIDTHLEFTPAREN:xd,FULLWIDTHLESSTHAN:Dd,FULLWIDTHMIDDLEDOT:Yd,FULLWIDTHRIGHTPAREN:Sd,HYPHEN:Hd,LEFTCORNERBRACKET:Cd,LEFTWHITECORNERBRACKET:Td,LOCALHOST:ad,NL:fd,NUM:ud,OPENANGLEBRACKET:yd,OPENBRACE:pd,OPENBRACKET:hd,OPENPAREN:_d,PERCENT:Ud,PIPE:Wd,PLUS:Gd,POUND:Kd,QUERY:qd,QUOTE:Jd,RIGHTCORNERBRACKET:wd,RIGHTWHITECORNERBRACKET:Ed,SCHEME:cd,SEMI:Xd,SLASH:Zd,SLASH_SCHEME:ld,SYM:tf,TILDE:Qd,TLD:od,UNDERSCORE:$d,UTLD:sd,UWORD:nd,WORD:td,WS:dd}),rf=/[a-z]/,af=/\p{L}/u,of=/\p{Emoji}/u,sf=/\d/,cf=/\s/,lf=`\r`,uf=`
|
|
309
|
+
`,df=`️`,ff=``,pf=``,mf=null,hf=null;function gf(e=[]){let t={};Zu.groups=t;let n=new Zu;mf??=bf(Iu),hf??=bf(Lu),X(n,`'`,Ad),X(n,`{`,pd),X(n,`}`,md),X(n,`[`,hd),X(n,`]`,gd),X(n,`(`,_d),X(n,`)`,vd),X(n,`<`,yd),X(n,`>`,bd),X(n,`(`,xd),X(n,`)`,Sd),X(n,`「`,Cd),X(n,`」`,wd),X(n,`『`,Td),X(n,`』`,Ed),X(n,`<`,Dd),X(n,`>`,Od),X(n,`&`,kd),X(n,`*`,jd),X(n,`@`,Md),X(n,"`",Pd),X(n,`^`,Fd),X(n,`:`,Id),X(n,`,`,Ld),X(n,`$`,Rd),X(n,`.`,zd),X(n,`=`,Bd),X(n,`!`,Vd),X(n,`-`,Hd),X(n,`%`,Ud),X(n,`|`,Wd),X(n,`+`,Gd),X(n,`#`,Kd),X(n,`?`,qd),X(n,`"`,Jd),X(n,`/`,Zd),X(n,`;`,Xd),X(n,`~`,Qd),X(n,`_`,$d),X(n,`\\`,Nd),X(n,`・`,Yd);let r=$u(n,sf,ud,{[Ru]:!0});$u(r,sf,r);let i=$u(r,rf,rd,{[Vu]:!0}),a=$u(r,af,id,{[Hu]:!0}),o=$u(n,rf,td,{[zu]:!0});$u(o,sf,i),$u(o,rf,o),$u(i,sf,i),$u(i,rf,i);let s=$u(n,af,nd,{[Bu]:!0});$u(s,rf),$u(s,sf,a),$u(s,af,s),$u(a,sf,a),$u(a,rf),$u(a,af,a);let c=X(n,uf,fd,{[qu]:!0}),l=X(n,lf,dd,{[qu]:!0}),u=$u(n,cf,dd,{[qu]:!0});X(n,pf,u),X(l,uf,c),X(l,pf,u),$u(l,cf,u),X(u,lf),X(u,uf),$u(u,cf,u),X(u,pf,u);let d=$u(n,of,ef,{[Wu]:!0});X(d,`#`),$u(d,of,d),X(d,df,d);let f=X(d,ff);X(f,`#`),$u(f,of,d);let p=[[rf,o],[sf,i]],m=[[rf,null],[af,s],[sf,a]];for(let e=0;e<mf.length;e++)yf(n,mf[e],od,td,p);for(let e=0;e<hf.length;e++)yf(n,hf[e],sd,nd,m);Yu(od,{tld:!0,ascii:!0},t),Yu(sd,{utld:!0,alpha:!0},t),yf(n,`file`,cd,td,p),yf(n,`mailto`,cd,td,p),yf(n,`http`,ld,td,p),yf(n,`https`,ld,td,p),yf(n,`ftp`,ld,td,p),yf(n,`ftps`,ld,td,p),Yu(cd,{scheme:!0,ascii:!0},t),Yu(ld,{slashscheme:!0,ascii:!0},t),e=e.sort((e,t)=>e[0]>t[0]?1:-1);for(let t=0;t<e.length;t++){let r=e[t][0],i=e[t][1]?{[Gu]:!0}:{[Ku]:!0};r.indexOf(`-`)>=0?i[Uu]=!0:rf.test(r)?sf.test(r)?i[Vu]=!0:i[zu]=!0:i[Ru]=!0,ed(n,r,r,i)}return ed(n,`localhost`,ad,{ascii:!0}),n.jd=new Zu(tf),{start:n,tokens:Object.assign({groups:t},nf)}}function _f(e,t){let n=vf(t.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,i=[],a=0,o=0;for(;o<r;){let s=e,c=null,l=0,u=null,d=-1,f=-1;for(;o<r&&(c=s.go(n[o]));)s=c,s.accepts()?(d=0,f=0,u=s):d>=0&&(d+=n[o].length,f++),l+=n[o].length,a+=n[o].length,o++;a-=d,o-=f,l-=d,i.push({t:u.t,v:t.slice(a-l,a),s:a-l,e:a})}return i}function vf(e){let t=[],n=e.length,r=0;for(;r<n;){let i=e.charCodeAt(r),a,o=i<55296||i>56319||r+1===n||(a=e.charCodeAt(r+1))<56320||a>57343?e[r]:e.slice(r,r+2);t.push(o),r+=o.length}return t}function yf(e,t,n,r,i){let a,o=t.length;for(let n=0;n<o-1;n++){let o=t[n];e.j[o]?a=e.j[o]:(a=new Zu(r),a.jr=i.slice(),e.j[o]=a),e=a}return a=new Zu(n),a.jr=i.slice(),e.j[t[o-1]]=a,a}function bf(e){let t=[],n=[],r=0;for(;r<e.length;){let i=0;for(;`0123456789`.indexOf(e[r+i])>=0;)i++;if(i>0){t.push(n.join(``));for(let t=parseInt(e.substring(r,r+i),10);t>0;t--)n.pop();r+=i}else n.push(e[r]),r++}return t}var xf={defaultProtocol:`http`,events:null,format:Cf,formatHref:Cf,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Sf(e,t=null){let n=Object.assign({},xf);e&&(n=Object.assign(n,e instanceof Sf?e.o:e));let r=n.ignoreTags,i=[];for(let e=0;e<r.length;e++)i.push(r[e].toUpperCase());this.o=n,t&&(this.defaultRender=t),this.ignoreTags=i}Sf.prototype={o:xf,ignoreTags:[],defaultRender(e){return e},check(e){return this.get(`validate`,e.toString(),e)},get(e,t,n){let r=t!=null,i=this.o[e];return i&&(typeof i==`object`?(i=n.t in i?i[n.t]:xf[e],typeof i==`function`&&r&&(i=i(t,n))):typeof i==`function`&&r&&(i=i(t,n.t,n)),i)},getObj(e,t,n){let r=this.o[e];return typeof r==`function`&&t!=null&&(r=r(t,n.t,n)),r},render(e){let t=e.render(this);return(this.get(`render`,null,e)||this.defaultRender)(t,e.t,e)}};function Cf(e){return e}function wf(e,t){this.t=`token`,this.v=e,this.tk=t}wf.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){let t=this.toString(),n=e.get(`truncate`,t,this),r=e.get(`format`,t,this);return n&&r.length>n?r.substring(0,n)+`…`:r},toFormattedHref(e){return e.get(`formatHref`,this.toHref(e.get(`defaultProtocol`)),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=xf.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get(`validate`,this.toString(),this)},render(e){let t=this,n=this.toHref(e.get(`defaultProtocol`)),r=e.get(`formatHref`,n,this),i=e.get(`tagName`,n,t),a=this.toFormattedString(e),o={},s=e.get(`className`,n,t),c=e.get(`target`,n,t),l=e.get(`rel`,n,t),u=e.getObj(`attributes`,n,t),d=e.getObj(`events`,n,t);return o.href=r,s&&(o.class=s),c&&(o.target=c),l&&(o.rel=l),u&&Object.assign(o,u),{tagName:i,attributes:o,content:a,eventListeners:d}}};function Tf(e,t){class n extends wf{constructor(t,n){super(t,n),this.t=e}}for(let e in t)n.prototype[e]=t[e];return n.t=e,n}var Ef=Tf(`email`,{isLink:!0,toHref(){return`mailto:`+this.toString()}}),Df=Tf(`text`),Of=Tf(`nl`),kf=Tf(`url`,{isLink:!0,toHref(e=xf.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==ad&&e[1].t===Id}}),Af=e=>new Zu(e);function jf({groups:e}){let t=e.domain.concat([kd,jd,Md,Nd,Pd,Fd,Rd,Bd,Hd,ud,Ud,Wd,Gd,Kd,Zd,tf,Qd,$d]),n=[Ad,Id,Ld,zd,Vd,Ud,qd,Jd,Xd,yd,bd,pd,md,gd,hd,_d,vd,xd,Sd,Cd,wd,Td,Ed,Dd,Od],r=[kd,Ad,jd,Nd,Pd,Fd,Rd,Bd,Hd,pd,md,Ud,Wd,Gd,Kd,qd,Zd,tf,Qd,$d],i=Af(),a=X(i,Qd);Qu(a,r,a),Qu(a,e.domain,a);let o=Af(),s=Af(),c=Af();Qu(i,e.domain,o),Qu(i,e.scheme,s),Qu(i,e.slashscheme,c),Qu(o,r,a),Qu(o,e.domain,o);let l=X(o,Md);X(a,Md,l),X(s,Md,l),X(c,Md,l);let u=X(a,zd);Qu(u,r,a),Qu(u,e.domain,a);let d=Af();Qu(l,e.domain,d),Qu(d,e.domain,d);let f=X(d,zd);Qu(f,e.domain,d);let p=Af(Ef);Qu(f,e.tld,p),Qu(f,e.utld,p),X(l,ad,p);let m=X(d,Hd);X(m,Hd,m),Qu(m,e.domain,d),Qu(p,e.domain,d),X(p,zd,f),X(p,Hd,m);let h=X(o,Hd),g=X(o,zd);X(h,Hd,h),Qu(h,e.domain,o),Qu(g,r,a),Qu(g,e.domain,o);let _=Af(kf);Qu(g,e.tld,_),Qu(g,e.utld,_),Qu(_,e.domain,o),Qu(_,r,a),X(_,zd,g),X(_,Hd,h),X(_,Md,l);let v=X(_,Id),y=Af(kf);Qu(v,e.numeric,y);let b=Af(kf),x=Af();Qu(b,t,b),Qu(b,n,x),Qu(x,t,b),Qu(x,n,x),X(_,Zd,b),X(y,Zd,b);let S=X(s,Id),C=X(X(X(c,Id),Zd),Zd);Qu(s,e.domain,o),X(s,zd,g),X(s,Hd,h),Qu(c,e.domain,o),X(c,zd,g),X(c,Hd,h),Qu(S,e.domain,b),X(S,Zd,b),X(S,qd,b),Qu(C,e.domain,b),Qu(C,t,b),X(C,Zd,b);let w=[[pd,md],[hd,gd],[_d,vd],[yd,bd],[xd,Sd],[Cd,wd],[Td,Ed],[Dd,Od]];for(let e=0;e<w.length;e++){let[r,i]=w[e],a=X(b,r);X(x,r,a);let o=Af(kf);Qu(a,t,o);let s=Af();Qu(a,n,s),X(a,i,b),Qu(o,t,o),Qu(o,n,s),Qu(s,t,o),Qu(s,n,s),X(o,i,b),X(s,i,b)}return X(i,ad,_),X(i,fd,Of),{start:i,tokens:nf}}function Mf(e,t,n){let r=n.length,i=0,a=[],o=[];for(;i<r;){let s=e,c=null,l=null,u=0,d=null,f=-1;for(;i<r&&!(c=s.go(n[i].t));)o.push(n[i++]);for(;i<r&&(l=c||s.go(n[i].t));)c=null,s=l,s.accepts()?(f=0,d=s):f>=0&&f++,i++,u++;if(f<0)i-=u,i<r&&(o.push(n[i]),i++);else{o.length>0&&(a.push(Nf(Df,t,o)),o=[]),i-=f,u-=f;let e=d.t,r=n.slice(i-u,i);a.push(Nf(e,t,r))}}return o.length>0&&a.push(Nf(Df,t,o)),a}function Nf(e,t,n){let r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}var Pf=typeof console<`u`&&console&&console.warn||(()=>{}),Ff=`until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`,If={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Lf(){return Zu.groups={},If.scanner=null,If.parser=null,If.tokenQueue=[],If.pluginQueue=[],If.customSchemes=[],If.initialized=!1,If}function Rf(e,t=!1){if(If.initialized&&Pf(`linkifyjs: already initialized - will not register custom scheme "${e}" ${Ff}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw Error(`linkifyjs: incorrect scheme format.
|
|
310
|
+
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
311
|
+
2. Cannot start or end with "-"
|
|
312
|
+
3. "-" cannot repeat`);If.customSchemes.push([e,t])}function zf(){If.scanner=gf(If.customSchemes);for(let e=0;e<If.tokenQueue.length;e++)If.tokenQueue[e][1]({scanner:If.scanner});If.parser=jf(If.scanner.tokens);for(let e=0;e<If.pluginQueue.length;e++)If.pluginQueue[e][1]({scanner:If.scanner,parser:If.parser});return If.initialized=!0,If}function Bf(e){return If.initialized||zf(),Mf(If.parser.start,e,_f(If.scanner.start,e))}Bf.scan=_f;function Vf(e,t=null,n=null){if(t&&typeof t==`object`){if(n)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);n=t,t=null}let r=new Sf(n),i=Bf(e),a=[];for(let e=0;e<i.length;e++){let n=i[e];n.isLink&&(!t||n.t===t)&&r.check(n)&&a.push(n.toFormattedObject(r))}return a}var Hf=`[\0- \xA0 -\u2029 ]`,Uf=new RegExp(Hf),Wf=RegExp(`${Hf}$`),Gf=new RegExp(Hf,`g`);function Kf(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function qf(e){return new pr({key:new Dr(`autolink`),appendTransaction:(t,n,r)=>{let i=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),a=t.some(e=>e.getMeta(`preventAutolink`));if(!i||a)return;let{tr:o}=r;if(zr(_r(n.doc,[...t])).forEach(({newRange:t})=>{let n=Br(r.doc,t,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=r.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length){let e=r.doc.textBetween(t.from,t.to,` `,` `);if(!Wf.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(Uf).filter(Boolean);if(t.length<=0)return!1;let n=t[t.length-1],s=i.pos+a.lastIndexOf(n);if(!n)return!1;let c=Bf(n).map(t=>t.toObject(e.defaultProtocol));if(!Kf(c))return!1;c.filter(e=>e.isLink).map(e=>({...e,from:s+e.start+1,to:s+e.end+1})).filter(e=>!r.schema.marks.code||!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code)).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{hr(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||o.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),o.steps.length)return o}})}function Jf(e){return new pr({key:new Dr(`handleClickLink`),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let i=r.target,a=[];for(;i.nodeName!==`DIV`;)a.push(i),i=i.parentNode;if(!a.find(e=>e.nodeName===`A`))return!1;let o=yr(t.state,e.type.name),s=r.target,c=s?.href??o.href,l=s?.target??o.target;return s&&c?(window.open(c,l),!0):!1}}})}function Yf(e){return new pr({key:new Dr(`handlePasteLink`),props:{handlePaste:(t,n,r)=>{let{state:i}=t,{selection:a}=i,{empty:o}=a;if(o)return!1;let s=``;r.content.forEach(e=>{s+=e.textContent});let c=Vf(s,{defaultProtocol:e.defaultProtocol}).find(e=>e.isLink&&e.value===s);return!s||!c?!1:e.editor.commands.setMark(e.type,{href:c.href})}}})}function Xf(e,t){let n=[`http`,`https`,`ftp`,`ftps`,`mailto`,`tel`,`callto`,`sms`,`cid`,`xmpp`];return t&&t.forEach(e=>{let t=typeof e==`string`?e:e.scheme;t&&n.push(t)}),!e||e.replace(Gf,``).match(RegExp(`^(?:(?:${n.join(`|`)}):|[^a-z]|[a-z0-9+.\-]+(?:[^a-z+.\-:]|$))`,`i`))}var Zf=wr.create({name:`link`,priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{if(typeof e==`string`){Rf(e);return}Rf(e.scheme,e.optionalSlashes)})},onDestroy(){Lf()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:`http`,HTMLAttributes:{target:`_blank`,rel:`noopener noreferrer nofollow`,class:null},isAllowedUri:(e,t)=>!!Xf(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>!!e}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute(`href`)}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:`a[href]`,getAttrs:e=>{let t=e.getAttribute(`href`);return!t||!this.options.isAllowedUri(t,{defaultValidate:e=>!!Xf(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!Xf(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?[`a`,Rr(this.options.HTMLAttributes,e),0]:[`a`,Rr(this.options.HTMLAttributes,{...e,href:``}),0]},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:e=>!!Xf(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta(`preventAutolink`,!0).run():!1},toggleLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:e=>!!Xf(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run():!1},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()}},addPasteRules(){return[ar({find:e=>{let t=[];if(e){let{protocols:n,defaultProtocol:r}=this.options,i=Vf(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!Xf(e,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(e=>t.push({text:e.value,data:{href:e.href},index:e.start}))}return t},type:this.type,getAttributes:e=>({href:e.data?.href})})]},addProseMirrorPlugins(){let e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push(qf({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!Xf(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&e.push(Jf({type:this.type})),this.options.linkOnPaste&&e.push(Yf({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),e}}),Qf=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,$f=Cr.create({name:`image`,addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?`inline`:`block`},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?`img[src]`:`img[src]:not([src^="data:"])`}]},renderHTML({HTMLAttributes:e}){return[`img`,Rr(this.options.HTMLAttributes,e)]},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[gr({find:Qf,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}});function ep(e){let{char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:o}=e,s=n&&!r,c=Lr(t),l=RegExp(`\\s${c}$`),u=a?`^`:``,d=r?``:c,f=RegExp(s?`${u}${c}.*?(?=\\s${d}|$)`:`${u}(?:^)?${c}[^\\s${d}]*`,`gm`),p=o.nodeBefore?.isText&&o.nodeBefore.text;if(!p)return null;let m=o.pos-p.length,h=Array.from(p.matchAll(f)).pop();if(!h||h.input===void 0||h.index===void 0)return null;let g=h.input.slice(Math.max(0,h.index-1),h.index),_=RegExp(`^[${i?.join(``)}\0]?$`).test(g);if(i!==null&&!_)return null;let v=m+h.index,y=v+h[0].length;return s&&l.test(p.slice(y-1,y+1))&&(h[0]+=` `,y+=1),v<o.pos&&y>=o.pos?{range:{from:v,to:y},query:h[0].slice(t.length),text:h[0]}:null}var tp=new Dr(`suggestion`);function np({pluginKey:e=tp,editor:t,char:n=`@`,allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:a=[` `],startOfLine:o=!1,decorationTag:s=`span`,decorationClass:c=`suggestion`,decorationContent:l=``,decorationEmptyClass:u=`is-empty`,command:d=()=>null,items:f=()=>[],render:p=()=>({}),allow:m=()=>!0,findSuggestionMatch:h=ep}){let g,_=p?.(),v=new pr({key:e,view(){return{update:async(e,n)=>{var r,i,a,o,s;let c=this.key?.getState(n),l=this.key?.getState(e.state),u=c.active&&l.active&&c.range.from!==l.range.from,p=!c.active&&l.active,m=c.active&&!l.active,h=!p&&!m&&c.query!==l.query,v=p||u&&h,y=h||u,b=m||u&&h;if(!v&&!y&&!b)return;let x=b&&!v?c:l,S=e.dom.querySelector(`[data-decoration-id="${x.decorationId}"]`);g={editor:t,range:x.range,query:x.query,text:x.text,items:[],command:e=>d({editor:t,range:x.range,props:e}),decorationNode:S,clientRect:S?()=>{let{decorationId:n}=this.key?.getState(t.state);return e.dom.querySelector(`[data-decoration-id="${n}"]`)?.getBoundingClientRect()||null}:null},v&&((r=_?.onBeforeStart)==null||r.call(_,g)),y&&((i=_?.onBeforeUpdate)==null||i.call(_,g)),(y||v)&&(g.items=await f({editor:t,query:x.query})),b&&((a=_?.onExit)==null||a.call(_,g)),y&&((o=_?.onUpdate)==null||o.call(_,g)),v&&((s=_?.onStart)==null||s.call(_,g))},destroy:()=>{var e;g&&((e=_?.onExit)==null||e.call(_,g))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(e,s,c,l){let{isEditable:u}=t,{composing:d}=t.view,{selection:f}=e,{empty:p,from:g}=f,_={...s};if(_.composing=d,u&&(p||t.view.composing)){(g<s.range.from||g>s.range.to)&&!d&&!s.composing&&(_.active=!1);let e=h({char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,$position:f.$from}),c=`id_${Math.floor(Math.random()*4294967295)}`;e&&m({editor:t,state:l,range:e.range,isActive:s.active})?(_.active=!0,_.decorationId=s.decorationId?s.decorationId:c,_.range=e.range,_.query=e.query,_.text=e.text):_.active=!1}else _.active=!1;return _.active||(_.decorationId=null,_.range={from:0,to:0},_.query=null,_.text=null),_}},props:{handleKeyDown(e,t){let{active:n,range:r}=v.getState(e.state);return n&&(_?.onKeyDown)?.call(_,{view:e,event:t,range:r})||!1},decorations(e){let{active:t,range:n,decorationId:r,query:i}=v.getState(e);if(!t)return null;let a=!i?.length,o=[c];return a&&o.push(u),or.create(e.doc,[sr.inline(n.from,n.to,{nodeName:s,class:o.join(` `),"data-decoration-id":r,"data-decoration-content":l})])}}});return v}function rp({editor:e,overrideSuggestionOptions:t,extensionName:n,char:r=`@`}){return{editor:e,char:r,pluginKey:new Dr,command:({editor:e,range:t,props:i})=>{var a;(e.view.state.selection.$to.nodeAfter?.text)?.startsWith(` `)&&(t.to+=1),e.chain().focus().insertContentAt(t,[{type:n,attrs:{...i,mentionSuggestionChar:r}},{type:`text`,text:` `}]).run(),(a=e.view.dom.ownerDocument.defaultView?.getSelection())==null||a.collapseToEnd()},allow:({state:e,range:t})=>{let r=e.doc.resolve(t.from),i=e.schema.nodes[n];return!!r.parent.type.contentMatch.matchType(i)},...t}}function ip(e){return(e.options.suggestions.length?e.options.suggestions:[e.options.suggestion]).map(t=>rp({editor:e.editor,overrideSuggestionOptions:t,extensionName:e.name,char:t.char}))}function ap(e,t){let n=ip(e);return n.find(e=>e.char===t)||(n.length?n[0]:null)}var op=Cr.create({name:`mention`,priority:101,addOptions(){return{HTMLAttributes:{},renderText({node:e,suggestion:t}){return`${t?.char??`@`}${e.attrs.label??e.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:e,node:t,suggestion:n}){return[`span`,Rr(this.HTMLAttributes,e.HTMLAttributes),`${n?.char??`@`}${t.attrs.label??t.attrs.id}`]},suggestions:[],suggestion:{}}},group:`inline`,inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute(`data-id`),renderHTML:e=>e.id?{"data-id":e.id}:{}},label:{default:null,parseHTML:e=>e.getAttribute(`data-label`),renderHTML:e=>e.label?{"data-label":e.label}:{}},mentionSuggestionChar:{default:`@`,parseHTML:e=>e.getAttribute(`data-mention-suggestion-char`),renderHTML:e=>({"data-mention-suggestion-char":e.mentionSuggestionChar})}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:e,HTMLAttributes:t}){let n=ap(this,e.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn(`renderLabel is deprecated use renderText and renderHTML instead`),[`span`,Rr({"data-type":this.name},this.options.HTMLAttributes,t),this.options.renderLabel({options:this.options,node:e,suggestion:n})];let r={...this.options};r.HTMLAttributes=Rr({"data-type":this.name},this.options.HTMLAttributes,t);let i=this.options.renderHTML({options:r,node:e,suggestion:n});return typeof i==`string`?[`span`,Rr({"data-type":this.name},this.options.HTMLAttributes,t),i]:i},renderText({node:e}){let t={options:this.options,node:e,suggestion:ap(this,e.attrs.mentionSuggestionChar)};return this.options.renderLabel===void 0?this.options.renderText(t):(console.warn(`renderLabel is deprecated use renderText and renderHTML instead`),this.options.renderLabel(t))},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:e,state:t})=>{let n=!1,{selection:r}=t,{empty:i,anchor:a}=r;if(!i)return!1;t.doc.nodesBetween(a-1,a,(t,r)=>{if(t.type.name===this.name)return n=!0,e.insertText(this.options.deleteTriggerWithBackspace?``:this.options.suggestion.char||``,r,r+t.nodeSize),!1});let o=new cr,s=0;return t.doc.nodesBetween(a-1,a,(e,t)=>{if(e.type.name===this.name)return n=!0,o=e,s=t,!1}),n&&e.insertText(this.options.deleteTriggerWithBackspace?``:o.attrs.mentionSuggestionChar,s,s+o.nodeSize),n})}},addProseMirrorPlugins(){return ip(this).map(np)}}),sp=new Set([`csv`,`tsv`,`parquet`]),cp={md:`markdown`,markdown:`markdown`,mdown:`markdown`,txt:`plaintext`,ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,cjs:`javascript`,json:`json`,jsonc:`json`,html:`html`,htm:`html`,css:`css`,scss:`scss`,less:`less`,py:`python`,go:`go`,rs:`rust`,rb:`ruby`,java:`java`,c:`c`,h:`c`,cpp:`cpp`,hpp:`cpp`,cc:`cpp`,cs:`csharp`,php:`php`,sh:`shell`,bash:`shell`,zsh:`shell`,yml:`yaml`,yaml:`yaml`,toml:`ini`,ini:`ini`,xml:`xml`,svg:`xml`,sql:`sql`,lua:`lua`,swift:`swift`,kt:`kotlin`,kts:`kotlin`,dockerfile:`dockerfile`,png:`image`,jpg:`image`,jpeg:`image`,gif:`image`,webp:`image`,bmp:`image`,ico:`image`,avif:`image`},lp=new Set([`markdown`,`plaintext`]),up=new Set([`image`]),dp={jsonc:`json`};function fp(e){let t=e.trim();if(!t)return null;let n=t.replace(/^.*[/\\]/,``);if(!n)return null;let r=n.lastIndexOf(`.`);return r===-1?n.toLowerCase():r===n.length-1?null:n.slice(r+1).toLowerCase()}function pp(e){let t=fp(e);return t?cp[t]??null:null}function mp(e,t){if(!t&&e){let t=fp(e);if(t&&sp.has(t))return{mode:`data`,language:`plaintext`}}let n=t??(e?pp(e):null),r=n?dp[n.toLowerCase()]??n:null;if(!r)return{mode:`markdown`,language:`markdown`};let i;return i=up.has(r)?`image`:lp.has(r)?`markdown`:`code`,{mode:i,language:r}}var hp=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?(?:[ \t]*\r?\n)*/;function gp(e){let t=e.match(hp);return t?{body:e.slice(t[0].length),frontmatter:t[0]}:{body:e,frontmatter:``}}function _p(e){let t=e.match(hp);return t?t[0].length:0}function vp(e){let t=[0];for(let n=0;n<e.length;n++)e[n]===`
|
|
313
|
+
`&&t.push(n+1);return t}function yp(e,t,n){return{text:e.slice(t,n),range:{startOffset:t,endOffset:n}}}function bp(e){let t=_p(e),n;try{n=Tt(e)}catch{return[yp(e,t,e.length)]}let r=vp(e),i=[];for(let e of n.children){if(e.type!==`heading`)continue;let t=e.position?.start.line;if(typeof t!=`number`)continue;let n=r[t-1];typeof n==`number`&&i.push(n)}if(i.length===0)return[yp(e,t,e.length)];let a=[],o=i[0];e.slice(t,o).trim().length>0&&a.push(yp(e,t,o));for(let t=0;t<i.length;t++){let n=i[t],r=t+1<i.length?i[t+1]:e.length;a.push(yp(e,n,r))}return a}function xp(e,t,n){return e.slice(0,t.startOffset)+n+e.slice(t.endOffset)}function Sp(e,t){return vp(e)[Math.max(0,t-1)]??e.length}function Cp(e,t){let n=vp(e),r=0,i=n.length-1,a=0;for(;r<=i;){let e=r+i>>1;n[e]<=t?(a=e,r=e+1):i=e-1}return a+1}function wp(e,t){return e.findIndex(e=>t>=e.range.startOffset&&t<e.range.endOffset)}var Tp=`## New section
|
|
314
|
+
|
|
315
|
+
`;function Ep(e,t,n){let r=n?.enabled??!1,i=(0,G.useMemo)(()=>bp(e),[e]),a=i.length,[o,s]=(0,G.useState)(0),c=a===0?0:Math.min(Math.max(o,0),a-1),l=i[c]??null,u=(0,G.useCallback)(e=>{s(e)},[]),d=(0,G.useCallback)(()=>{s(c-1)},[c]),f=(0,G.useCallback)(()=>{s(c+1)},[c]),p=(0,G.useCallback)(t=>{let n=Sp(e,t),r=wp(i,n);r>=0&&s(r)},[e,i]),m=l?Cp(e,l.range.startOffset):null;return{editorSource:r&&l?l.text:e,setEditorSource:(0,G.useCallback)(n=>{if(!r||!l){t(n);return}let i=l.range.endOffset<e.length?n.replace(/\s*$/,``)+`
|
|
316
|
+
|
|
317
|
+
`:n;t(xp(e,l.range,i))},[r,l,e,t]),blockCount:a,activeBlockKey:c,goToBlock:u,goToBlockByLine:p,activeBlockStartLine:m,prevBlock:d,nextBlock:f,addBlock:(0,G.useCallback)(()=>{if(!l){let n=e.replace(/\s*$/,``);t((n?n+`
|
|
318
|
+
|
|
319
|
+
`:``)+Tp),s(a);return}let n=l.range.endOffset,r=e.slice(0,n),i=e.slice(n);t(r+(r===``||r.endsWith(`
|
|
320
|
+
|
|
321
|
+
`)?``:r.endsWith(`
|
|
322
|
+
`)?`
|
|
323
|
+
`:`
|
|
324
|
+
|
|
325
|
+
`)+Tp+i),s(c+1)},[l,e,t,c,a])}}function Dp(){let e=null,t=new Set;return{set(n){e=n;for(let e of t)e(n)},get(){return e},subscribe(e){return t.add(e),()=>t.delete(e)}}}function Op(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function kp(e,t,n){let r=t-n;return r<=0?0:Op(e/r)}function Ap(e,t,n){return Op(e)*Math.max(0,t-n)}function jp(e){return kp(e.getScrollTop(),e.getScrollHeight(),e.getLayoutInfo().height)}function Mp(e,t){e.setScrollTop(Ap(t,e.getScrollHeight(),e.getLayoutInfo().height))}function Np(e){return e.view.dom.closest(`.squisq-wysiwyg-container`)}function Pp(e){let t=Np(e);return t?kp(t.scrollTop,t.scrollHeight,t.clientHeight):null}function Fp(e,t){let n=Np(e);return n?(n.scrollTop=Ap(t,n.scrollHeight,n.clientHeight),!0):!1}var Ip=(0,G.createContext)(null);function Lp(){let e=(0,G.useContext)(Ip);if(!e)throw Error(`useEditorContext must be used within an <EditorProvider>`);return e}var Rp={type:`keep-last-n`,n:50},zp=5e3;function Bp(e){return e===!1||e===`none`?`none`:e===void 0||e===`active`?`active`:`always`}function Vp({initialMarkdown:e=``,initialView:t=`raw`,articleId:n=`untitled`,colorScheme:r=`light`,workspaceContainer:i=null,allowVersioning:a=!1,versionBasename:o,versioningPrunePolicy:s=Rp,versioningAutoSaveIdleMs:c=zp,onSaveVersion:l,mediaProvider:u=null,imageDisplayMode:d=`inline`,mentionProvider:f=null,proofing:p=null,proofingDefaultEnabled:m=!0,proofingSpellingEnabled:h=!0,proofingGrammarEnabled:g=!0,proofingIgnoreStore:_=null,documentLinkProvider:v=null,fenceRenderers:y=null,linkSchemes:b,allowRecording:x=!0,allowNarrate:S=!0,preserveSourceWrapping:C=!0,fileName:w,saveCoverImageOutput:T,saveDashboardImageOutput:E,language:D,findMode:O,onFindModeChange:k,inlinePreview:A=!1,showStatusBar:j=!0,outline:M=!1,blockTags:N,blockTagVisibility:P,themeInheritance:F=`fonts`,layoutMode:I=`document`,viewPreferences:L,onViewPreferencesChange:ee,children:te}){let R=L?.inlinePreview??A,ne=L?.showStatusBar??j,re=L?.outline??M,z=Bp(L?.blockTagVisibility??L?.blockTags??P??N),ie=L?.themeInheritance??F,ae=L?.layoutMode??I,{mode:oe,language:se}=(0,G.useMemo)(()=>mp(w,D),[w,D]),ce=oe===`data`?`code`:oe,[le,ue]=(0,G.useState)(e),[V,de]=(0,G.useState)(null),[fe,H]=(0,G.useState)(null),[pe,me]=(0,G.useState)(ce===`markdown`?t:`raw`),[U,he]=(0,G.useState)(!1),ge=ce!==`image`&&(O??U),_e=(0,G.useCallback)(e=>{ce!==`image`&&(O===void 0&&he(e),k?.(e))},[O,ce,k]),W=(0,G.useRef)(pe);W.current=pe;let ve=(0,G.useRef)(null),ye=(0,G.useRef)(null),be=(0,G.useRef)(null),xe=(0,G.useCallback)(e=>{if(ce===`code`&&e!==`raw`||ce===`image`)return;let t=W.current;if(e===t)return;let n=null,r=null;t===`raw`&&e===`wysiwyg`&&ye.current?(n=jp(ye.current),r=`wysiwyg`):t===`wysiwyg`&&e===`raw`&&ve.current&&(n=Pp(ve.current),r=`raw`),be.current=n===null||r===null?null:{view:r,ratio:n},me(e)},[ce]),[Se,Ce]=(0,G.useState)(null),[we,Te]=(0,G.useState)(!1),[Ee,De]=(0,G.useState)(r),[Oe,ke]=(0,G.useState)(R);(0,G.useEffect)(()=>{L?.inlinePreview===void 0&&ke(A)},[A,L?.inlinePreview]);let[Ae,je]=(0,G.useState)(ne);(0,G.useEffect)(()=>{L?.showStatusBar===void 0&&je(j)},[j,L?.showStatusBar]);let[Me,Ne]=(0,G.useState)(re);(0,G.useEffect)(()=>{L?.outline===void 0&&Ne(M)},[M,L?.outline]);let[Pe,Fe]=(0,G.useState)(z),Ie=Pe!==`none`;(0,G.useEffect)(()=>{L?.blockTagVisibility===void 0&&L?.blockTags===void 0&&Fe(Bp(P??N))},[N,P,L]);let[Le,Re]=(0,G.useState)(ie);(0,G.useEffect)(()=>{L?.themeInheritance===void 0&&Re(F)},[F,L?.themeInheritance]);let[ze,Be]=(0,G.useState)(ae);(0,G.useEffect)(()=>{L?.layoutMode===void 0&&Be(I)},[I,L?.layoutMode]);let[Ve,He]=(0,G.useState)(null),[Ue,We]=(0,G.useState)(0),Ge=(0,G.useCallback)(e=>{He(e)},[]),Ke=(0,G.useCallback)(()=>{He(null)},[]),qe=(0,G.useCallback)(()=>{We(e=>e+1)},[]);(0,G.useEffect)(()=>{L&&(L.inlinePreview!==void 0&&ke(L.inlinePreview),L.showStatusBar!==void 0&&je(L.showStatusBar),L.outline!==void 0&&Ne(L.outline),L.blockTagVisibility===void 0?L.blockTags!==void 0&&Fe(Bp(L.blockTags)):Fe(Bp(L.blockTagVisibility)),L.themeInheritance!==void 0&&Re(L.themeInheritance),L.layoutMode!==void 0&&Be(L.layoutMode))},[L]);let Je=(0,G.useRef)(ee);Je.current=ee;let Ye=(0,G.useRef)(Oe);Ye.current=Oe;let Xe=(0,G.useRef)(Ae);Xe.current=Ae;let Ze=(0,G.useRef)(Me);Ze.current=Me;let Qe=(0,G.useRef)(Pe);Qe.current=Pe;let $e=(0,G.useRef)(Le);$e.current=Le;let et=(0,G.useRef)(ze);et.current=ze;let tt=(0,G.useCallback)(e=>{ke(e),Je.current?.({inlinePreview:e,showStatusBar:Xe.current,outline:Ze.current,blockTags:Qe.current!==`none`,blockTagVisibility:Qe.current,themeInheritance:$e.current,layoutMode:et.current})},[]),nt=(0,G.useCallback)(e=>{je(e),Je.current?.({inlinePreview:Ye.current,showStatusBar:e,outline:Ze.current,blockTags:Qe.current!==`none`,blockTagVisibility:Qe.current,themeInheritance:$e.current,layoutMode:et.current})},[]),rt=(0,G.useCallback)(e=>{Ne(e),Je.current?.({inlinePreview:Ye.current,showStatusBar:Xe.current,outline:e,blockTags:Qe.current!==`none`,blockTagVisibility:Qe.current,themeInheritance:$e.current,layoutMode:et.current})},[]),it=(0,G.useCallback)(e=>{Fe(e),Je.current?.({inlinePreview:Ye.current,showStatusBar:Xe.current,outline:Ze.current,blockTags:e!==`none`,blockTagVisibility:e,themeInheritance:$e.current,layoutMode:et.current})},[]),at=(0,G.useCallback)(e=>it(e?`always`:`none`),[it]),ot=(0,G.useCallback)(e=>{Re(e),Je.current?.({inlinePreview:Ye.current,showStatusBar:Xe.current,outline:Ze.current,blockTags:Qe.current!==`none`,blockTagVisibility:Qe.current,themeInheritance:e,layoutMode:et.current})},[]),st=(0,G.useCallback)(e=>{Be(e),Je.current?.({inlinePreview:Ye.current,showStatusBar:Xe.current,outline:Ze.current,blockTags:Qe.current!==`none`,blockTagVisibility:Qe.current,themeInheritance:$e.current,layoutMode:e})},[]),[ct,lt]=(0,G.useState)(null),[ut,dt]=(0,G.useState)(null),ft=(0,G.useCallback)(e=>{ve.current=e,lt(e)},[]),pt=(0,G.useCallback)(e=>{ye.current=e,dt(e)},[]);(0,G.useEffect)(()=>{let e=be.current;if(!e||e.view!==pe)return;let t=pe===`raw`&&ut?()=>Mp(ut,e.ratio):pe===`wysiwyg`&&ct?()=>Fp(ct,e.ratio):null;if(!t)return;let n=!1,r=()=>{n||(t(),be.current===e&&(be.current=null))};if(typeof requestAnimationFrame==`function`){let e=requestAnimationFrame(r);return()=>{n=!0,cancelAnimationFrame(e)}}let i=setTimeout(r,0);return()=>{n=!0,clearTimeout(i)}},[pe,ut,ct]);let[mt,ht]=(0,G.useState)(null),gt=(0,G.useMemo)(Dp,[]);(0,G.useEffect)(()=>gt.subscribe(ht),[gt]);let _t=(0,G.useRef)(n);_t.current=n;let vt=(0,G.useRef)(w);vt.current=w,(0,G.useEffect)(()=>{De(r)},[r]);let yt=(0,G.useRef)(null),bt=(0,G.useRef)(!!e),xt=(0,G.useCallback)(e=>{Te(!0);try{let t=Tt(e);de(t),Ce(null);try{let e=B(t,{articleId:_t.current,fileName:vt.current});H(e)}catch(e){H(null),console.warn(`Doc generation failed:`,e instanceof Error?e.message:e)}}catch(e){Ce(e instanceof Error?e.message:`Parse error`),de(null),H(null)}finally{Te(!1)}},[]);(0,G.useEffect)(()=>{if(ce===`markdown`){if(bt.current){bt.current=!1;return}return yt.current&&clearTimeout(yt.current),Te(!0),yt.current=setTimeout(()=>{xt(le)},150),()=>{yt.current&&clearTimeout(yt.current)}}},[le,xt,ce]),(0,G.useEffect)(()=>{ce===`markdown`&&e&&xt(e)},[]);let St=(0,G.useCallback)(e=>{ue(e)},[]),{editorSource:Ct,setEditorSource:wt,blockCount:Et,activeBlockKey:Dt,activeBlockStartLine:Ot,goToBlock:kt,goToBlockByLine:At,prevBlock:jt,nextBlock:Mt,addBlock:Nt}=Ep(le,St,{enabled:(ze===`block`||ze===`timeline`)&&ce===`markdown`}),Ft=(0,G.useCallback)(e=>{if(pe===`wysiwyg`&&ct){let t=lr(e);ct.chain().focus().insertContent(t).run()}else if(pe===`raw`&&ut){let t=ut.getPosition();if(t){if(ut.getModel()){let n={startLineNumber:t.lineNumber,startColumn:t.column,endLineNumber:t.lineNumber,endColumn:t.column};ut.executeEdits(`drop`,[{range:n,text:e}])}}else ue(t=>t+`
|
|
326
|
+
|
|
327
|
+
`+e)}else ue(t=>t+`
|
|
328
|
+
|
|
329
|
+
`+e)},[pe,ct,ut]),It=(0,G.useCallback)(e=>{ue(e)},[]),Lt=(0,G.useRef)(!1);(0,G.useEffect)(()=>{a&&!i&&!Lt.current&&(console.warn("[squisq-editor] allowVersioning requires a `workspaceContainer` prop; versioning is disabled."),Lt.current=!0)},[a,i]);let Rt=(0,G.useMemo)(()=>!a||!i?null:new bn(i,{basename:o}),[a,i,o]),zt=(0,G.useRef)(l);zt.current=l;let Bt=(0,G.useRef)(s);Bt.current=s;let Vt=(0,G.useCallback)(async e=>{if(!Rt){let e={saved:!1,version:null,reason:`no-document`};return zt.current?.(e),e}let t=await Rt.saveVersion(e);return zt.current?.(t),t.saved&&Rt.pruneVersions(Bt.current).catch(e=>{console.warn(`[squisq-editor] pruneVersions failed:`,e instanceof Error?e.message:e)}),t},[Rt]),Ht=(0,G.useRef)(null);(0,G.useEffect)(()=>{if(!Rt||c<=0)return;let e=Ht.current;if(Ht.current=le,e!==null&&e===le)return;let t=setTimeout(()=>{Vt({content:le}).catch(e=>{console.warn(`[squisq-editor] auto-save version failed:`,e instanceof Error?e.message:e)})},c);return()=>clearTimeout(t)},[le,Rt,c,Vt]);let Ut=(0,G.useCallback)(e=>{de(e);try{let t=Pt(e);ue(t),Ce(null);try{let t=B(e,{articleId:_t.current,fileName:vt.current});H(t)}catch(e){H(null),console.warn(`Doc generation failed:`,e instanceof Error?e.message:e)}}catch(e){Ce(e instanceof Error?e.message:`Stringify error`)}},[]),Wt=(0,G.useMemo)(()=>({markdownSource:le,markdownDoc:V,doc:fe,activeView:pe,parseError:Se,isParsing:we,colorScheme:Ee,editorMode:ce,findMode:ge,language:se,inlinePreviewVisible:Oe,statusBarVisible:Ae,outlineVisible:Me,blockTagVisibility:Pe,blockTagsVisible:Ie,themeInheritance:Le,layoutMode:ze,editorSource:Ct,blockCount:Et,activeBlockKey:Dt,activeBlockStartLine:Ot,imageEditTarget:Ve,mediaRevision:Ue,allowRecording:x,allowNarrate:S,preserveSourceWrapping:C,tiptapEditor:ct,monacoEditor:ut,activeSceneText:mt,sceneTextChannel:gt,workspaceContainer:i,versioning:Rt,saveVersion:Vt,mediaProvider:u,imageDisplayMode:d,mentionProvider:f,proofing:p,proofingDefaultEnabled:m,proofingSpellingEnabled:h,proofingGrammarEnabled:g,proofingIgnoreStore:_,articleId:n,documentLinkProvider:v,fenceRenderers:y,linkSchemes:b,fileName:w,saveCoverImageOutput:T,saveDashboardImageOutput:E,setMarkdownSource:St,setEditorSource:wt,setLayoutMode:st,goToBlock:kt,goToBlockByLine:At,prevBlock:jt,nextBlock:Mt,addBlock:Nt,setMarkdownDoc:Ut,setActiveView:xe,setFindMode:_e,setTiptapEditor:ft,setMonacoEditor:pt,setColorScheme:De,setInlinePreviewVisible:tt,setStatusBarVisible:nt,setOutlineVisible:rt,setBlockTagVisibility:it,setBlockTagsVisible:at,setThemeInheritance:ot,insertAtCursor:Ft,replaceAll:It,openImageEdit:Ge,closeImageEdit:Ke,bumpMediaRevision:qe}),[le,V,fe,pe,Se,we,Ee,ce,ge,se,Oe,Ae,Me,Pe,Ie,Le,ze,Ct,Et,Dt,Ot,ct,ut,mt,gt,i,Rt,Vt,u,d,f,p,m,h,g,_,n,v,y,b,w,T,E,St,wt,st,kt,At,jt,Mt,Nt,Ut,xe,_e,ft,pt,De,tt,nt,rt,it,at,ot,Ft,It,Ve,Ue,x,S,C,Ge,Ke,qe]);return(0,K.jsx)(Ip.Provider,{value:Wt,children:te})}function Hp(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Up(e){if(Array.isArray(e))return e}function Wp(e,t,n){return(t=$p(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Gp(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Kp(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
330
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function qp(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Jp(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?qp(Object(n),!0).forEach(function(t){Wp(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):qp(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Yp(e,t){if(e==null)return{};var n,r,i=Xp(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Xp(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Zp(e,t){return Up(e)||Gp(e,t)||em(e,t)||Kp()}function Qp(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function $p(e){var t=Qp(e,`string`);return typeof t==`symbol`?t:t+``}function em(e,t){if(e){if(typeof e==`string`)return Hp(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Hp(e,t):void 0}}function tm(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function nm(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function rm(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?nm(Object(n),!0).forEach(function(t){tm(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):nm(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function im(){var e=[...arguments];return function(t){return e.reduceRight(function(e,t){return t(e)},t)}}function am(e){return function t(){var n=this,r=[...arguments];return r.length>=e.length?e.apply(this,r):function(){var e=[...arguments];return t.apply(n,[].concat(r,e))}}}function om(e){return{}.toString.call(e).includes(`Object`)}function sm(e){return!Object.keys(e).length}function cm(e){return typeof e==`function`}function lm(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function um(e,t){return om(t)||hm(`changeType`),Object.keys(t).some(function(t){return!lm(e,t)})&&hm(`changeField`),t}function dm(e){cm(e)||hm(`selectorType`)}function fm(e){cm(e)||om(e)||hm(`handlerType`),om(e)&&Object.values(e).some(function(e){return!cm(e)})&&hm(`handlersType`)}function pm(e){e||hm(`initialIsRequired`),om(e)||hm(`initialType`),sm(e)&&hm(`initialContent`)}function mm(e,t){throw Error(e[t]||e.default)}var hm=am(mm)({initialIsRequired:`initial state is required`,initialType:`initial state should be an object`,initialContent:`initial state shouldn't be an empty object`,handlerType:`handler should be an object or a function`,handlersType:`all handlers should be a functions`,selectorType:`selector should be a function`,changeType:`provided value of changes should be an object`,changeField:`it seams you want to change a field in the state which is not specified in the "initial" state`,default:"an unknown error accured in `state-local` package"}),gm={changes:um,selector:dm,handler:fm,initial:pm};function _m(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};gm.initial(e),gm.handler(t);var n={current:e},r=am(bm)(n,t),i=am(ym)(n),a=am(gm.changes)(e),o=am(vm)(n);function s(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(e){return e};return gm.selector(e),e(n.current)}function c(e){im(r,i,a,o)(e)}return[s,c]}function vm(e,t){return cm(t)?t(e.current):t}function ym(e,t){return e.current=rm(rm({},e.current),t),t}function bm(e,t,n){return cm(t)?t(e.current):Object.keys(n).forEach(function(n){return t[n]?.call(t,e.current[n])}),n}var xm={create:_m},Sm={paths:{vs:`https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs`}};function Cm(e){return function t(){var n=this,r=[...arguments];return r.length>=e.length?e.apply(this,r):function(){var e=[...arguments];return t.apply(n,[].concat(r,e))}}}function wm(e){return{}.toString.call(e).includes(`Object`)}function Tm(e){return e||km(`configIsRequired`),wm(e)||km(`configType`),e.urls?(Em(),{paths:{vs:e.urls.monacoBase}}):e}function Em(){console.warn(Om.deprecation)}function Dm(e,t){throw Error(e[t]||e.default)}var Om={configIsRequired:`the configuration object is required`,configType:`the configuration object should be an object`,default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
|
|
331
|
+
You are using deprecated way of configuration.
|
|
332
|
+
|
|
333
|
+
Instead of using
|
|
334
|
+
monaco.config({ urls: { monacoBase: '...' } })
|
|
335
|
+
use
|
|
336
|
+
monaco.config({ paths: { vs: '...' } })
|
|
337
|
+
|
|
338
|
+
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
339
|
+
`},km=Cm(Dm)(Om),Am={config:Tm},jm=function(){var e=[...arguments];return function(t){return e.reduceRight(function(e,t){return t(e)},t)}};function Mm(e,t){return Object.keys(t).forEach(function(n){t[n]instanceof Object&&e[n]&&Object.assign(t[n],Mm(e[n],t[n]))}),Jp(Jp({},e),t)}var Nm={type:`cancelation`,msg:`operation is manually canceled`};function Pm(e){var t=!1,n=new Promise(function(n,r){e.then(function(e){return t?r(Nm):n(e)}),e.catch(r)});return n.cancel=function(){return t=!0},n}var Fm=[`monaco`],Im=Zp(xm.create({config:Sm,isInitialized:!1,resolve:null,reject:null,monaco:null}),2),Lm=Im[0],Rm=Im[1];function zm(e){var t=Am.config(e),n=t.monaco,r=Yp(t,Fm);Rm(function(e){return{config:Mm(e.config,r),monaco:n}})}function Bm(){var e=Lm(function(e){return{monaco:e.monaco,isInitialized:e.isInitialized,resolve:e.resolve}});if(!e.isInitialized){if(Rm({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Pm(qm);if(window.monaco&&window.monaco.editor)return Gm(window.monaco),e.resolve(window.monaco),Pm(qm);jm(Vm,Um)(Wm)}return Pm(qm)}function Vm(e){return document.body.appendChild(e)}function Hm(e){var t=document.createElement(`script`);return e&&(t.src=e),t}function Um(e){var t=Lm(function(e){return{config:e.config,reject:e.reject}}),n=Hm(`${t.config.paths.vs}/loader.js`);return n.onload=function(){return e()},n.onerror=t.reject,n}function Wm(){var e=Lm(function(e){return{config:e.config,resolve:e.resolve,reject:e.reject}}),t=window.require;t.config(e.config),t([`vs/editor/editor.main`],function(t){var n=t.m||t;Gm(n),e.resolve(n)},function(t){e.reject(t)})}function Gm(e){Lm().monaco||Rm({monaco:e})}function Km(){return Lm(function(e){return e.monaco})}var qm=new Promise(function(e,t){return Rm({resolve:e,reject:t})}),Jm={config:zm,init:Bm,__getMonacoInstance:Km},Ym={wrapper:{display:`flex`,position:`relative`,textAlign:`initial`},fullWidth:{width:`100%`},hide:{display:`none`}},Xm={container:{display:`flex`,height:`100%`,width:`100%`,justifyContent:`center`,alignItems:`center`}};function Zm({children:e}){return G.createElement(`div`,{style:Xm.container},e)}var Qm=Zm;function $m({width:e,height:t,isEditorReady:n,loading:r,_ref:i,className:a,wrapperProps:o}){return G.createElement(`section`,{style:{...Ym.wrapper,width:e,height:t},...o},!n&&G.createElement(Qm,null,r),G.createElement(`div`,{ref:i,style:{...Ym.fullWidth,...!n&&Ym.hide},className:a}))}var eh=(0,G.memo)($m);function th(e){(0,G.useEffect)(e,[])}var nh=th;function rh(e,t,n=!0){let r=(0,G.useRef)(!0);(0,G.useEffect)(r.current||!n?()=>{r.current=!1}:e,t)}var ih=rh;function ah(){}function oh(e,t,n,r){return sh(e,r)||ch(e,t,n,r)}function sh(e,t){return e.editor.getModel(lh(e,t))}function ch(e,t,n,r){return e.editor.createModel(t,n,r?lh(e,r):void 0)}function lh(e,t){return e.Uri.parse(t)}function uh({original:e,modified:t,language:n,originalLanguage:r,modifiedLanguage:i,originalModelPath:a,modifiedModelPath:o,keepCurrentOriginalModel:s=!1,keepCurrentModifiedModel:c=!1,theme:l=`light`,loading:u=`Loading...`,options:d={},height:f=`100%`,width:p=`100%`,className:m,wrapperProps:h={},beforeMount:g=ah,onMount:_=ah}){let[v,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(!0),S=(0,G.useRef)(null),C=(0,G.useRef)(null),w=(0,G.useRef)(null),T=(0,G.useRef)(_),E=(0,G.useRef)(g),D=(0,G.useRef)(!1);nh(()=>{let e=Jm.init();return e.then(e=>(C.current=e)&&x(!1)).catch(e=>e?.type!==`cancelation`&&console.error(`Monaco initialization: error:`,e)),()=>S.current?A():e.cancel()}),ih(()=>{if(S.current&&C.current){let t=S.current.getOriginalEditor(),i=oh(C.current,e||``,r||n||`text`,a||``);i!==t.getModel()&&t.setModel(i)}},[a],v),ih(()=>{if(S.current&&C.current){let e=S.current.getModifiedEditor(),r=oh(C.current,t||``,i||n||`text`,o||``);r!==e.getModel()&&e.setModel(r)}},[o],v),ih(()=>{let e=S.current.getModifiedEditor();e.getOption(C.current.editor.EditorOption.readOnly)?e.setValue(t||``):t!==e.getValue()&&(e.executeEdits(``,[{range:e.getModel().getFullModelRange(),text:t||``,forceMoveMarkers:!0}]),e.pushUndoStop())},[t],v),ih(()=>{S.current?.getModel()?.original.setValue(e||``)},[e],v),ih(()=>{let{original:e,modified:t}=S.current.getModel();C.current.editor.setModelLanguage(e,r||n||`text`),C.current.editor.setModelLanguage(t,i||n||`text`)},[n,r,i],v),ih(()=>{C.current?.editor.setTheme(l)},[l],v),ih(()=>{S.current?.updateOptions(d)},[d],v);let O=(0,G.useCallback)(()=>{if(!C.current)return;E.current(C.current);let s=oh(C.current,e||``,r||n||`text`,a||``),c=oh(C.current,t||``,i||n||`text`,o||``);S.current?.setModel({original:s,modified:c})},[n,t,i,e,r,a,o]),k=(0,G.useCallback)(()=>{!D.current&&w.current&&(S.current=C.current.editor.createDiffEditor(w.current,{automaticLayout:!0,...d}),O(),C.current?.editor.setTheme(l),y(!0),D.current=!0)},[d,l,O]);(0,G.useEffect)(()=>{v&&T.current(S.current,C.current)},[v]),(0,G.useEffect)(()=>{!b&&!v&&k()},[b,v,k]);function A(){let e=S.current?.getModel();s||e?.original?.dispose(),c||e?.modified?.dispose(),S.current?.dispose()}return G.createElement(eh,{width:p,height:f,isEditorReady:v,loading:u,_ref:w,className:m,wrapperProps:h})}var dh=(0,G.memo)(uh);function fh(e){let t=(0,G.useRef)();return(0,G.useEffect)(()=>{t.current=e},[e]),t.current}var ph=fh,mh=new Map;function hh({defaultValue:e,defaultLanguage:t,defaultPath:n,value:r,language:i,path:a,theme:o=`light`,line:s,loading:c=`Loading...`,options:l={},overrideServices:u={},saveViewState:d=!0,keepCurrentModel:f=!1,width:p=`100%`,height:m=`100%`,className:h,wrapperProps:g={},beforeMount:_=ah,onMount:v=ah,onChange:y,onValidate:b=ah}){let[x,S]=(0,G.useState)(!1),[C,w]=(0,G.useState)(!0),T=(0,G.useRef)(null),E=(0,G.useRef)(null),D=(0,G.useRef)(null),O=(0,G.useRef)(v),k=(0,G.useRef)(_),A=(0,G.useRef)(),j=(0,G.useRef)(r),M=ph(a),N=(0,G.useRef)(!1),P=(0,G.useRef)(!1);nh(()=>{let e=Jm.init();return e.then(e=>(T.current=e)&&w(!1)).catch(e=>e?.type!==`cancelation`&&console.error(`Monaco initialization: error:`,e)),()=>E.current?I():e.cancel()}),ih(()=>{let o=oh(T.current,e||r||``,t||i||``,a||n||``);o!==E.current?.getModel()&&(d&&mh.set(M,E.current?.saveViewState()),E.current?.setModel(o),d&&E.current?.restoreViewState(mh.get(a)))},[a],x),ih(()=>{E.current?.updateOptions(l)},[l],x),ih(()=>{!E.current||r===void 0||(E.current.getOption(T.current.editor.EditorOption.readOnly)?E.current.setValue(r):r!==E.current.getValue()&&(P.current=!0,E.current.executeEdits(``,[{range:E.current.getModel().getFullModelRange(),text:r,forceMoveMarkers:!0}]),E.current.pushUndoStop(),P.current=!1))},[r],x),ih(()=>{let e=E.current?.getModel();e&&i&&T.current?.editor.setModelLanguage(e,i)},[i],x),ih(()=>{s!==void 0&&E.current?.revealLine(s)},[s],x),ih(()=>{T.current?.editor.setTheme(o)},[o],x);let F=(0,G.useCallback)(()=>{if(!(!D.current||!T.current)&&!N.current){k.current(T.current);let c=a||n,f=oh(T.current,r||e||``,t||i||``,c||``);E.current=T.current?.editor.create(D.current,{model:f,automaticLayout:!0,...l},u),d&&E.current.restoreViewState(mh.get(c)),T.current.editor.setTheme(o),s!==void 0&&E.current.revealLine(s),S(!0),N.current=!0}},[e,t,n,r,i,a,l,u,d,o,s]);(0,G.useEffect)(()=>{x&&O.current(E.current,T.current)},[x]),(0,G.useEffect)(()=>{!C&&!x&&F()},[C,x,F]),j.current=r,(0,G.useEffect)(()=>{x&&y&&(A.current?.dispose(),A.current=E.current?.onDidChangeModelContent(e=>{P.current||y(E.current.getValue(),e)}))},[x,y]),(0,G.useEffect)(()=>{if(x){let e=T.current.editor.onDidChangeMarkers(e=>{let t=E.current.getModel()?.uri;if(t&&e.find(e=>e.path===t.path)){let e=T.current.editor.getModelMarkers({resource:t});b?.(e)}});return()=>{e?.dispose()}}return()=>{}},[x,b]);function I(){A.current?.dispose(),f?d&&mh.set(a,E.current.saveViewState()):E.current.getModel()?.dispose(),E.current.dispose()}return G.createElement(eh,{width:p,height:m,isEditorReady:x,loading:c,_ref:D,className:h,wrapperProps:g})}var gh=(0,G.memo)(hh),_h=null,vh=null,yh=null,bh=new Set;function xh(e){let t=e.indexOf(`:`),n=t===-1?``:e.slice(t+1);return n?n.split(`,`):[]}async function Sh(e,t){let n=await Ch();return bh.has(e)||(await n.loadMonacoLanguages(xh(e),{languageServices:t}),bh.add(e)),n}async function Ch(){return _h||=Ut(()=>import(`./monaco-DeTXJU-n.js`).then(e=>e.r).then(e=>(Jm.config({monaco:e}),yh=e,e)),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])).catch(e=>{throw _h=null,e}),_h}function wh(){return vh??=Ch().then(e=>e.loadMonacoSuggestions()).catch(e=>{throw vh=null,e}),vh}function Th(e=[],t={}){let n=t.languageServices===!0,r=er(e,{languageServices:n}),[i,a]=(0,G.useState)(()=>yh!==null&&bh.has(r));return(0,G.useEffect)(()=>{let e=!1;return Sh(r,n).then(()=>{e||a(!0)}).catch(()=>{}),()=>{e=!0}},[n,r]),{monaco:yh,ready:yh!==null&&i}}var Eh=[];function Dh(e,t,n){let r=(0,G.useRef)(t);r.current=t,(0,G.useEffect)(()=>{if(!e)return;let t=Symbol(`escape-dismissal`);Eh.push(t);let i=e=>{e.key!==`Escape`||e.defaultPrevented||Eh[Eh.length-1]!==t||(e.preventDefault(),e.stopPropagation(),r.current(),n?.current?.focus({preventScroll:!0}))};return document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`keydown`,i);let e=Eh.lastIndexOf(t);e>=0&&Eh.splice(e,1)}},[e,n])}var Oh={display:`flex`,alignItems:`center`,justifyContent:`center`,width:`100%`,height:`100%`,color:`var(--squisq-text-muted)`,fontSize:12};function kh({original:e,modified:t,theme:n}){let{ready:r}=Th(Qn(`markdown`,`${e}
|
|
340
|
+
${t}`));return r?(0,K.jsx)(dh,{original:e,modified:t,language:`markdown`,theme:n,options:{readOnly:!0,renderSideBySide:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:`on`,automaticLayout:!0,fontSize:12,lineNumbers:`off`,glyphMargin:!1,folding:!1,overviewRulerLanes:0,renderOverviewRuler:!1}}):(0,K.jsx)(`div`,{style:Oh,children:`Loading diff…`})}var Ah={loading:!1,versions:[],selected:null,pendingRevert:null,error:null,currentStamp:new Date,latestSnapshotContent:null},jh=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`});function Mh(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Nh(){let{versioning:e,saveVersion:t,replaceAll:n,markdownSource:r,colorScheme:i}=Lp(),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(Ah),l=(0,G.useRef)(null),u=(0,G.useRef)(null);Dh(a,(0,G.useCallback)(()=>o(!1),[]),u);let d=(0,G.useCallback)(async()=>{if(e){c(e=>({...e,loading:!0,error:null}));try{let t=await e.listVersions(),n=t[0],r=n?await e.readVersion(n):null;c(e=>({...e,loading:!1,versions:t,latestSnapshotContent:r}))}catch(e){let t=e instanceof Error?e.message:`Failed to list versions`;c(e=>({...e,loading:!1,error:t}))}}},[e]);(0,G.useEffect)(()=>{a?(c(e=>({...e,currentStamp:new Date})),d()):c(e=>({...e,selected:null,pendingRevert:null}))},[a,d]),(0,G.useEffect)(()=>{if(!a)return;let e=e=>{l.current&&!l.current.contains(e.target)&&o(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[a]);let f=(0,G.useCallback)(async t=>{if(e){if(s.selected?.version.path===t.path){c(e=>({...e,selected:null}));return}try{let n=await e.readVersion(t);if(n===null){c(e=>({...e,error:`Snapshot is no longer available.`}));return}c(e=>({...e,selected:{version:t,content:n},error:null}))}catch(e){let t=e instanceof Error?e.message:`Failed to read snapshot`;c(e=>({...e,error:t,selected:null}))}}},[e,s.selected]),p=(0,G.useCallback)(async i=>{if(e)try{let a=await t({content:r});if(!a.saved&&a.reason!==`unchanged`){c(e=>({...e,error:`Could not save your current draft as a snapshot (${a.reason}). Revert cancelled so your unsaved edits are not lost.`}));return}if(!(await e.revertToVersion(i,{snapshotCurrent:!1})).reverted){c(e=>({...e,error:`Revert failed — snapshot missing.`}));return}let o=await e.readVersion(i);o!==null&&n(o),c(e=>({...e,pendingRevert:null,selected:null})),await d()}catch(e){let t=e instanceof Error?e.message:`Revert failed`;c(e=>({...e,error:t}))}},[e,t,r,n,d]),m=s.latestSnapshotContent!==null&&s.latestSnapshotContent===r,h=(0,G.useMemo)(()=>m?s.versions.slice(1):s.versions,[s.versions,m]),g=(0,G.useMemo)(()=>new TextEncoder().encode(r).byteLength,[r]),_=s.selected!==null,v=i===`dark`?`vs-dark`:`vs`;return e?(0,K.jsxs)(`div`,{className:`squisq-version-history`,ref:l,children:[(0,K.jsx)(`button`,{ref:u,type:`button`,className:`squisq-toolbar-button squisq-version-history-trigger${a?` squisq-toolbar-button--active`:``}`,"data-tooltip":`Version history`,"aria-label":`Version history`,"aria-expanded":a,onClick:()=>o(e=>!e),children:(0,K.jsx)(q,{icon:`fa-solid fa-clock-rotate-left`})}),a&&(0,K.jsxs)(`div`,{className:`squisq-version-history-popover${_?` squisq-version-history-popover--with-diff`:``}`,role:`dialog`,"aria-label":`Version history`,children:[_&&s.selected&&(0,K.jsxs)(`div`,{className:`squisq-version-history-diff`,children:[(0,K.jsxs)(`div`,{className:`squisq-version-history-diff-header`,children:[(0,K.jsxs)(`span`,{className:`squisq-version-history-diff-label`,children:[(0,K.jsx)(`strong`,{children:`Snapshot`}),` `,jh.format(s.selected.version.timestamp)]}),(0,K.jsx)(`span`,{className:`squisq-version-history-diff-label`,children:(0,K.jsx)(`strong`,{children:`Current`})})]}),(0,K.jsx)(`div`,{className:`squisq-version-history-diff-body`,children:(0,K.jsx)(kh,{original:s.selected.content,modified:r,theme:v})})]}),(0,K.jsxs)(`div`,{className:`squisq-version-history-list-pane`,children:[(0,K.jsx)(`div`,{className:`squisq-version-history-header`,children:(0,K.jsx)(`span`,{className:`squisq-version-history-title`,children:`Version history`})}),s.error&&(0,K.jsx)(`div`,{className:`squisq-version-history-error`,children:s.error}),s.loading?(0,K.jsx)(`div`,{className:`squisq-version-history-empty`,children:`Loading…`}):h.length===0?(0,K.jsx)(`div`,{className:`squisq-version-history-empty`,children:`No versions yet. Versions are saved automatically as you edit.`}):(0,K.jsxs)(`ul`,{className:`squisq-version-history-list`,children:[(0,K.jsx)(`li`,{className:`squisq-version-history-row squisq-version-history-row--current${s.selected===null?` squisq-version-history-row--selected`:``}`,children:(0,K.jsxs)(`button`,{type:`button`,className:`squisq-version-history-row-select`,onClick:()=>c(e=>({...e,selected:null})),children:[(0,K.jsxs)(`span`,{className:`squisq-version-history-row__time`,children:[(0,K.jsx)(`strong`,{children:`Current`}),` · `,jh.format(s.currentStamp)]}),(0,K.jsx)(`span`,{className:`squisq-version-history-row__size`,children:Mh(g)})]})}),h.map(e=>{let t=s.pendingRevert!==null&&s.pendingRevert.path===e.path;return(0,K.jsxs)(`li`,{className:`squisq-version-history-row${s.selected?.version.path===e.path?` squisq-version-history-row--selected`:``}`,children:[(0,K.jsxs)(`button`,{type:`button`,className:`squisq-version-history-row-select`,onClick:()=>void f(e),children:[(0,K.jsx)(`span`,{className:`squisq-version-history-row__time`,children:jh.format(e.timestamp)}),(0,K.jsx)(`span`,{className:`squisq-version-history-row__size`,children:Mh(e.size)})]}),(0,K.jsx)(`span`,{className:`squisq-version-history-row__actions`,children:(0,K.jsx)(`button`,{type:`button`,className:`squisq-version-history-link`,onClick:()=>c(t=>({...t,pendingRevert:e})),children:`Revert`})}),t&&(0,K.jsxs)(`div`,{className:`squisq-version-history-confirm`,children:[(0,K.jsx)(`span`,{children:`Revert to this version? Your current draft will be saved as a new snapshot first. Reverting will reset your editor undo state.`}),(0,K.jsxs)(`span`,{className:`squisq-version-history-confirm-actions`,children:[(0,K.jsx)(`button`,{type:`button`,className:`squisq-version-history-link`,onClick:()=>c(e=>({...e,pendingRevert:null})),children:`Cancel`}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-version-history-link squisq-version-history-link--primary`,onClick:()=>void p(e),children:`Revert`})]})]})]},e.path)})]})]})]})]}):null}var Ph=lt().map(e=>({id:e.id,name:e.name,description:e.description,theme:nt(e.id)}));function Fh(e){return Ph.find(t=>t.id===e)}function Ih(e){return Ye(e.typography.titleFont,st.sans)}function Lh({theme:e,label:t,className:n}){return(0,K.jsx)(`span`,{className:`squisq-theme-picker-name-chip${n?` ${n}`:``}`,"data-theme-id":e.id,style:{background:e.colors.background,color:e.colors.text,fontFamily:Ih(e),borderColor:e.colors.backgroundLight},children:(0,K.jsx)(`span`,{className:`squisq-theme-picker-name-chip-label`,children:t})})}function Rh({theme:e}){return(0,K.jsxs)(`span`,{className:`squisq-theme-picker-swatches`,"aria-hidden":`true`,children:[(0,K.jsx)(`span`,{className:`squisq-theme-picker-swatch`,style:{background:e.colors.primary}}),(0,K.jsx)(`span`,{className:`squisq-theme-picker-swatch`,style:{background:e.colors.secondary}}),(0,K.jsx)(`span`,{className:`squisq-theme-picker-swatch`,style:{background:e.colors.highlight}})]})}function zh({value:e,onChange:t,includeDefault:n,variant:r=`compact`,ariaLabel:i=`Theme`,customThemes:a,onCreateCustom:o,onEditCustom:s,onDeleteCustom:c}){let[l,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)({}),p=(0,G.useRef)(null),m=(0,G.useRef)(null);Dh(l,()=>u(!1),p);let h=`squisq-theme-picker-popover-${(0,G.useId)().replace(/:/g,``)}`,g=(0,G.useMemo)(()=>(a??[]).map(e=>({id:e.id,name:e.name,description:e.description,theme:e})),[a]),_=(0,G.useCallback)(e=>Fh(e)??g.find(t=>t.id===e),[g]),v=(0,G.useMemo)(()=>e?_(e)??null:null,[e,_]),y=!v&&n===!0,b=v??Fh(`standard`)??Ph[0],x=v?v.name:n?`Default`:b?.name??`Theme`,S=(0,G.useCallback)(()=>{if(!p.current)return;let e=p.current.getBoundingClientRect(),t=window.innerWidth,n=window.innerHeight,r=t-16,i=Math.min(r,Math.max(560,e.width)),a=Math.max(8,t-i-8),o=Math.min(Math.max(8,e.left),a),s=m.current?.scrollHeight??520,c=n-e.bottom-8-4,l=e.top-8-4,u,d;s<=c||c>=l?(u=e.bottom+4,d=c):(d=Math.min(s,l),u=e.top-4-d),f({position:`fixed`,top:u,left:o,width:i,maxHeight:d,overflowY:`auto`,zIndex:9999})},[]),C=()=>{l||S(),u(e=>!e)};(0,G.useEffect)(()=>{if(!l)return;let e=e=>{let t=e.target;p.current?.contains(t)||m.current?.contains(t)||u(!1)},t=()=>S();return document.addEventListener(`mousedown`,e),window.addEventListener(`scroll`,t,!0),window.addEventListener(`resize`,t),requestAnimationFrame(S),()=>{document.removeEventListener(`mousedown`,e),window.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,t)}},[l,S]);let w=e=>{t(e),u(!1)},T=l?(0,Wr.createPortal)((0,K.jsxs)(`div`,{ref:m,id:h,className:`squisq-theme-picker-popover`,role:`listbox`,"aria-label":i,style:d,children:[n&&(0,K.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":e===``,"aria-label":`Default`,className:`squisq-theme-picker-row${e===``?` squisq-theme-picker-row--selected`:``}`,onClick:()=>w(``),children:[(0,K.jsx)(Lh,{theme:nt(`standard`),label:`Default`,className:`squisq-theme-picker-name-chip--default`}),(0,K.jsxs)(`span`,{className:`squisq-theme-picker-row-meta`,children:[(0,K.jsx)(`span`,{className:`squisq-theme-picker-row-name`,children:`No explicit theme`}),(0,K.jsx)(`span`,{className:`squisq-theme-picker-row-desc`,children:`Uses the document's default styling.`})]})]}),Ph.map(t=>(0,K.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":e===t.id,"aria-label":t.name,className:`squisq-theme-picker-row${e===t.id?` squisq-theme-picker-row--selected`:``}`,onClick:()=>w(t.id),title:t.description??t.name,children:[(0,K.jsx)(Lh,{theme:t.theme,label:t.name}),(0,K.jsxs)(`span`,{className:`squisq-theme-picker-row-meta`,children:[(0,K.jsx)(Rh,{theme:t.theme}),t.description&&(0,K.jsx)(`span`,{className:`squisq-theme-picker-row-desc`,children:t.description})]})]},t.id)),g.length>0&&(0,K.jsx)(`div`,{className:`squisq-theme-picker-group-label`,children:`Custom`}),g.map(t=>(0,K.jsxs)(`div`,{className:`squisq-theme-picker-custom-wrap`,children:[(0,K.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":e===t.id,"aria-label":t.name,className:`squisq-theme-picker-row${e===t.id?` squisq-theme-picker-row--selected`:``}`,onClick:()=>w(t.id),title:t.description??t.name,children:[(0,K.jsx)(Lh,{theme:t.theme,label:t.name}),(0,K.jsxs)(`span`,{className:`squisq-theme-picker-row-meta`,children:[(0,K.jsx)(Rh,{theme:t.theme}),t.description&&(0,K.jsx)(`span`,{className:`squisq-theme-picker-row-desc`,children:t.description})]})]}),(s||c)&&(0,K.jsxs)(`span`,{className:`squisq-theme-picker-card-actions`,children:[s&&(0,K.jsx)(`button`,{type:`button`,className:`squisq-theme-picker-card-action`,onClick:()=>s(t.id),"aria-label":`Edit ${t.name}`,title:`Edit theme`,children:`✎`}),c&&(0,K.jsx)(`button`,{type:`button`,className:`squisq-theme-picker-card-action`,onClick:()=>c(t.id),"aria-label":`Delete ${t.name}`,title:`Delete theme`,children:`×`})]})]},t.id)),o&&(0,K.jsxs)(`button`,{type:`button`,className:`squisq-theme-picker-row squisq-theme-picker-create`,onClick:()=>{u(!1),o()},children:[(0,K.jsx)(`span`,{className:`squisq-theme-picker-create-plus`,"aria-hidden":`true`,children:`+`}),(0,K.jsxs)(`span`,{className:`squisq-theme-picker-row-meta`,children:[(0,K.jsx)(`span`,{className:`squisq-theme-picker-row-name`,children:`Create custom theme…`}),(0,K.jsx)(`span`,{className:`squisq-theme-picker-row-desc`,children:`Design your own colors, accents, and fonts.`})]})]})]}),document.body):null;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`button`,{ref:p,type:`button`,className:`squisq-theme-picker-trigger squisq-theme-picker-trigger--${r}${l?` squisq-theme-picker-trigger--open`:``}`,onClick:C,"aria-haspopup":`listbox`,"aria-expanded":l,"aria-controls":l?h:void 0,"aria-label":i,children:[b&&(0,K.jsx)(Lh,{theme:b.theme,label:x,className:`squisq-theme-picker-name-chip--trigger${y?` squisq-theme-picker-name-chip--default`:``}`}),b&&r===`full`&&!y&&(0,K.jsx)(Rh,{theme:b.theme}),(0,K.jsx)(`svg`,{className:`squisq-theme-picker-caret`,width:`10`,height:`10`,viewBox:`0 0 10 10`,"aria-hidden":`true`,children:(0,K.jsx)(`path`,{d:`M2 3.5l3 3 3-3`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,fill:`none`})})]}),T]})}var Bh=`squisq:custom-theme-library`;function Vh(){try{return typeof globalThis<`u`&&globalThis.localStorage?globalThis.localStorage:null}catch{return null}}function Hh(){let e=Vh();if(!e)return{version:1,themes:[]};try{let t=e.getItem(Bh);if(!t)return{version:1,themes:[]};let n=JSON.parse(t);if(n&&Array.isArray(n.themes))return{version:1,themes:n.themes.filter(e=>tt(e).valid)}}catch{}return{version:1,themes:[]}}function Uh(e){let t=Vh();if(t)try{t.setItem(Bh,JSON.stringify(e))}catch{}}function Wh(){let{themes:e}=Hh();return e.slice().sort((e,t)=>e.name.localeCompare(t.name))}function Gh(e){let t=Hh(),n=t.themes.findIndex(t=>t.id===e.id);return n>=0?t.themes[n]=e:t.themes.push(e),Uh(t),t.themes.slice().sort((e,t)=>e.name.localeCompare(t.name))}function Kh(e){let t=Hh();return t.themes=t.themes.filter(t=>t.id!==e),Uh(t),t.themes.slice().sort((e,t)=>e.name.localeCompare(t.name))}var qh=(0,G.createContext)(null);function Jh({docThemes:e,onDocThemesChange:t,children:n}){let[r,i]=(0,G.useState)(()=>Wh());(0,G.useEffect)(()=>{i(Wh());let e=e=>{e.key===Bh&&i(Wh())};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]);let a=(0,G.useCallback)(n=>{let r=e.findIndex(e=>e.id===n.id);t(r>=0?e.map((e,t)=>t===r?n:e):[...e,n])},[e,t]),o=(0,G.useCallback)(n=>{let r=e.filter(e=>e.id!==n);r.length!==e.length&&t(r)},[e,t]),s=(0,G.useCallback)(e=>{i(Gh(e))},[]),c=(0,G.useCallback)(e=>{i(Kh(e))},[]),l=(0,G.useCallback)(t=>{let n=e.find(e=>e.id===t.id);return n||a(t),n??t},[e,a]),u=(0,G.useMemo)(()=>{let t=new Set(e.map(e=>e.id));return[...e,...r.filter(e=>!t.has(e.id))]},[e,r]),d=(0,G.useMemo)(()=>({docThemes:e,libraryThemes:r,allThemes:u,upsertDocTheme:a,upsertLibraryTheme:s,removeDocTheme:o,removeLibraryTheme:c,applyTheme:l}),[e,r,u,a,s,o,c,l]);return(0,K.jsx)(qh.Provider,{value:d,children:n})}function Yh(){return(0,G.useContext)(qh)}function Xh(){let{doc:e,markdownSource:t,setMarkdownSource:n}=Lp();return{docThemes:(0,G.useMemo)(()=>e?.customThemes??[],[e?.customThemes]),onDocThemesChange:(0,G.useCallback)(e=>{let r=ie(e),i=We(t,{[rt]:r??null});i!==t&&n(i)},[t,n])}}var Zh={sharp:0,soft:6,rounded:16},Qh={static:0,subtle:1.4,normal:1,expressive:.7},$h={off:!1,on:!0},eg=[`subtle`,`balanced`,`high`],tg=[`none`,`mono`,`duotone`,`warm`,`cool`],ng=[`sans-serif`,`serif`,`monospace`,`system-ui`],rg={name:`My Theme`,seeds:{primary:`#3182ce`,secondary:`#4a5568`,accent:`#63b3ed`,background:`#1a202c`,text:`#f7fafc`},accents:[],accentsEdited:!1,titleFont:{kind:`curated`,stackId:`system-serif`},bodyFont:{kind:`curated`,stackId:`system-sans`},borderRadius:`soft`,animationSpeed:`normal`,textShadow:`on`,contrast:`balanced`,imageTreatment:`none`};function ig(e){if(e===void 0)return`soft`;let t=`soft`,n=1/0;return Object.entries(Zh).forEach(([r,i])=>{let a=Math.abs(i-e);a<n&&(t=r,n=a)}),t}function ag(e){if(e===void 0||e===0)return e===0?`static`:`normal`;let t=`normal`,n=1/0;return Object.entries(Qh).forEach(([r,i])=>{if(i===0)return;let a=Math.abs(i-e);a<n&&(t=r,n=a)}),t}function og(e,t){return e?`stackId`in e?{kind:`curated`,stackId:e.stackId}:`custom`in e?{kind:`custom`,customName:e.custom.name,customFallback:e.custom.fallback}:{kind:`curated`,stackId:t}:{kind:`curated`,stackId:t}}function sg(e){return e.kind===`curated`?{stackId:e.stackId??`system-sans`}:{custom:{name:e.customName??`Sans`,fallback:e.customFallback??`sans-serif`}}}function cg(e){return e?Object.entries(e.colorSchemes).map(([e,t])=>({key:e,color:t.accent})):[]}function lg(e){return Ht(e)}function ug(e){if(!e)return{...rg};let t=e.seedColors??{primary:e.colors.primary,secondary:e.colors.secondary,accent:e.colors.highlight,background:e.colors.background,text:e.colors.text};return{name:e.name,baseId:e.basedOn,seeds:{primary:t.primary,secondary:t.secondary,accent:t.accent,background:t.background,text:t.text},accents:cg(e),accentsEdited:!1,titleFont:og(e.typography.titleFont,`system-serif`),bodyFont:og(e.typography.bodyFont,`system-sans`),borderRadius:ig(e.style.borderRadius),animationSpeed:ag(e.style.animationSpeed),textShadow:e.style.textShadow===!1?`off`:`on`,contrast:`balanced`,imageTreatment:e.style.imageTreatment?.type??`none`}}function dg(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`custom`}function fg(e){let t=ug(e);return{name:t.name,seeds:t.seeds,accents:t.accents,accentsEdited:t.accents.length>0,titleFont:t.titleFont,bodyFont:t.bodyFont}}function pg(e,t={}){let n=t.existingId,r=n&&n.startsWith(`custom-`)?n:`custom-${dg(e.name)}`,i=e.accentsEdited&&e.accents.length>0?Object.fromEntries(e.accents.map(e=>[e.key,lg(e.color)])):void 0;return Vt({id:r,name:e.name,seedColors:e.seeds,typography:{titleFont:sg(e.titleFont),bodyFont:sg(e.bodyFont)},style:{borderRadius:Zh[e.borderRadius],animationSpeed:Qh[e.animationSpeed],textShadow:$h[e.textShadow],...e.imageTreatment===`none`?{}:{imageTreatment:{type:e.imageTreatment,strength:.5}}},...i?{colorSchemes:i}:{}},{contrast:e.contrast,base:t.base})}function mg(e){return{key:`accent${e.length+1}`,color:`#63b3ed`}}var hg=`.docx,.pptx,.xlsx`,gg=/\.(docx|pptx|xlsx)$/i,_g=4;function vg(e){return typeof e.arrayBuffer==`function`?e.arrayBuffer():new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>n(r.error),r.readAsArrayBuffer(e)})}function yg({onImported:e,allowLayouts:t=!1}){let n=(0,G.useRef)(null),[r,i]=(0,G.useState)(!1),[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)([]),[d,f]=(0,G.useState)(!1),p=(0,G.useCallback)(async r=>{if(!gg.test(r.name)){o(`Only .docx, .pptx, or .xlsx files carry a theme.`);return}i(!0),o(null),c(null),u([]);try{let n=await vg(r),{inferThemeFromFile:i}=await Ut(async()=>{let{inferThemeFromFile:e}=await import(`./infer-LEGOsu64.js`);return{inferThemeFromFile:e}},__vite__mapDeps([11,2,12,1,13,14,15,16,17,18,19,20,21])),a=await i(n,{inferLayouts:t,nameHint:r.name.replace(/\.[^.]+$/,``)}),o=a.layouts??[];e(fg(a.theme),{theme:a.theme,...o.length>0?{layouts:o}:{},warnings:a.warnings,fileName:r.name}),c(o.length>0?`Imported colors and fonts from ${r.name} \u2014 ${o.length} slide layout${o.length===1?``:`s`} will be saved with the document.`:`Imported colors and fonts from ${r.name}.`),u(a.warnings)}catch(e){o(e instanceof Error?e.message:`Could not read a theme from that file.`)}finally{i(!1),n.current&&(n.current.value=``)}},[t,e]),m=(0,G.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),f(!0)},[]),h=(0,G.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),f(!1)},[]),g=(0,G.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),f(!1);let t=e.dataTransfer.files?.[0];t&&p(t)},[p]),_=l.slice(0,_g),v=l.length-_.length;return(0,K.jsxs)(`div`,{className:`squisq-theme-import`,children:[(0,K.jsxs)(`div`,{className:`squisq-theme-import-drop${d?` squisq-theme-import-drop--active`:``}${r?` squisq-theme-import-drop--busy`:``}`,onDragOver:m,onDragLeave:h,onDrop:g,children:[(0,K.jsx)(`button`,{type:`button`,className:`squisq-theme-customizer-button`,onClick:()=>n.current?.click(),disabled:r,children:r?`Reading…`:`Choose file…`}),(0,K.jsx)(`span`,{className:`squisq-theme-import-hint`,children:`or drop a .docx / .pptx / .xlsx here`}),(0,K.jsx)(`input`,{ref:n,type:`file`,accept:hg,style:{display:`none`},onChange:e=>{let t=e.target.files?.[0];t&&p(t)},"aria-label":`Import theme from file`})]}),a&&(0,K.jsx)(`div`,{className:`squisq-theme-import-error`,role:`alert`,children:a}),s&&(0,K.jsx)(`div`,{className:`squisq-theme-import-status`,children:s}),_.length>0&&(0,K.jsxs)(`ul`,{className:`squisq-theme-import-warnings`,children:[_.map((e,t)=>(0,K.jsx)(`li`,{children:e},t)),v>0&&(0,K.jsxs)(`li`,{children:[`…and `,v,` more`]})]})]})}function bg({title:e,hint:t,children:n}){return(0,K.jsxs)(`div`,{className:`squisq-theme-customizer-section`,children:[(0,K.jsx)(`div`,{className:`squisq-theme-customizer-section-title`,children:e}),t&&(0,K.jsx)(`div`,{className:`squisq-theme-customizer-section-hint`,children:t}),(0,K.jsx)(`div`,{className:`squisq-theme-customizer-section-body`,children:n})]})}function xg({label:e,value:t,onChange:n}){let r=ut(t)?t:`#000000`;return(0,K.jsxs)(`label`,{className:`squisq-theme-customizer-row`,children:[(0,K.jsx)(`span`,{className:`squisq-theme-customizer-row-label`,children:e}),(0,K.jsx)(`input`,{type:`color`,className:`squisq-theme-customizer-color`,value:r,onChange:e=>n(e.target.value)}),(0,K.jsx)(`input`,{type:`text`,className:`squisq-theme-customizer-input squisq-theme-customizer-input--hex`,value:t,onChange:e=>n(e.target.value),spellCheck:!1,"aria-label":`${e} hex value`})]})}function Sg({label:e,value:t,onChange:n}){let r=t.kind===`curated`?et.find(e=>e.id===t.stackId)?.family:void 0;return(0,K.jsxs)(`div`,{className:`squisq-theme-customizer-row squisq-theme-customizer-row--font`,children:[(0,K.jsx)(`span`,{className:`squisq-theme-customizer-row-label`,children:e}),(0,K.jsxs)(`select`,{className:`squisq-theme-customizer-input`,style:r?{fontFamily:r}:void 0,value:t.kind===`custom`?`__custom__`:t.stackId??``,onChange:e=>{let r=e.target.value;n(r===`__custom__`?{kind:`custom`,customName:t.customName??``,customFallback:t.customFallback??`sans-serif`}:{kind:`curated`,stackId:r})},"aria-label":`${e} font`,children:[et.map(e=>(0,K.jsx)(`option`,{value:e.id,style:{fontFamily:e.family},children:e.label},e.id)),(0,K.jsx)(`option`,{value:`__custom__`,children:`Custom…`})]}),t.kind===`custom`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`input`,{type:`text`,className:`squisq-theme-customizer-input`,placeholder:`Font name`,value:t.customName??``,onChange:e=>n({...t,customName:e.target.value}),"aria-label":`${e} custom font name`}),(0,K.jsx)(`select`,{className:`squisq-theme-customizer-input`,value:t.customFallback??`sans-serif`,onChange:e=>n({...t,customFallback:e.target.value}),"aria-label":`${e} custom font fallback`,children:ng.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))})]})]})}function Cg({label:e,value:t,options:n,onChange:r}){return(0,K.jsxs)(`label`,{className:`squisq-theme-customizer-row`,children:[(0,K.jsx)(`span`,{className:`squisq-theme-customizer-row-label`,children:e}),(0,K.jsx)(`select`,{className:`squisq-theme-customizer-input`,value:t,onChange:e=>r(e.target.value),"aria-label":e,children:n.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))})]})}function wg({accents:e,onChange:t}){let n=(n,r)=>t(e.map((e,t)=>t===n?{...e,color:r}:e)),r=n=>t(e.filter((e,t)=>t!==n));return(0,K.jsxs)(`div`,{className:`squisq-theme-customizer-accents`,children:[e.map((e,t)=>(0,K.jsxs)(`div`,{className:`squisq-theme-customizer-row squisq-theme-customizer-row--accent`,children:[(0,K.jsx)(`input`,{type:`color`,className:`squisq-theme-customizer-color`,value:ut(e.color)?e.color:`#000000`,onChange:e=>n(t,e.target.value),"aria-label":`Accent ${t+1}`}),(0,K.jsx)(`input`,{type:`text`,className:`squisq-theme-customizer-input squisq-theme-customizer-input--hex`,value:e.color,onChange:e=>n(t,e.target.value),spellCheck:!1,"aria-label":`Accent ${t+1} hex value`}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-theme-customizer-accent-remove`,onClick:()=>r(t),"aria-label":`Remove accent ${t+1}`,title:`Remove accent`,children:`×`})]},e.key)),(0,K.jsx)(`button`,{type:`button`,className:`squisq-theme-customizer-button squisq-theme-customizer-accent-add`,onClick:()=>t([...e,mg(e)]),children:`+ Add accent`})]})}function Tg(e){let t=ug(e);return e&&(t.accentsEdited=!0),t}function Eg({value:e,onChange:t,onSave:n,onClose:r}){let[i,a]=(0,G.useState)(()=>Tg(e)),[o,s]=(0,G.useState)(null),c=(0,G.useRef)(null);(0,G.useEffect)(()=>{c.current?.focus(),c.current?.select()},[]),(0,G.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[r]);let l=(0,G.useCallback)(t=>{let n=t.baseId?nt(t.baseId):void 0;return pg(t,{existingId:e?.id,base:n})},[e?.id]),u=(0,G.useCallback)(e=>{a(n=>{let r=typeof e==`function`?e(n):{...n,...e};try{t?.(l(r))}catch{}return r})},[t,l]),d=(0,G.useCallback)((e,t)=>u(n=>({...n,seeds:{...n.seeds,[e]:t}})),[u]),f=(0,G.useCallback)(e=>{try{let t=o&&o.length>0?{templates:o}:void 0;n(l(i),e,t)}catch{}},[i,n,l,o]),p=(0,G.useMemo)(()=>i.baseId?nt(i.baseId):null,[i.baseId]),m=i.accentsEdited?i.accents:cg(p),h=(0,G.useCallback)(e=>u({accents:e,accentsEdited:!0}),[u]);return(0,K.jsxs)(`div`,{className:`squisq-custom-theme-pane`,role:`dialog`,"aria-label":`Design custom theme`,children:[(0,K.jsxs)(`div`,{className:`squisq-doc-settings-header`,children:[(0,K.jsx)(`h2`,{className:`squisq-doc-settings-title`,children:e?`Edit custom theme`:`New custom theme`}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-doc-settings-close`,onClick:r,"aria-label":`Close`,children:`×`})]}),(0,K.jsxs)(`div`,{className:`squisq-doc-settings-body squisq-theme-customizer-body squisq-custom-theme-pane-body`,children:[(0,K.jsx)(bg,{title:`Name`,children:(0,K.jsx)(`input`,{ref:c,type:`text`,className:`squisq-theme-customizer-input`,value:i.name,onChange:e=>u({name:e.target.value}),"aria-label":`Theme name`})}),(0,K.jsx)(bg,{title:`Base theme`,hint:`Inherit render style, motion, and layout from a base.`,children:(0,K.jsx)(zh,{value:i.baseId??``,onChange:e=>u({baseId:e||void 0}),includeDefault:!0,variant:`full`,ariaLabel:`Base theme`})}),(0,K.jsx)(bg,{title:`Import from file`,hint:`Pull colors and fonts from a Word, PowerPoint, or Excel file. PowerPoint slide layouts become custom layouts.`,children:(0,K.jsx)(yg,{allowLayouts:!0,onImported:(e,t)=>{u(e),s(t.layouts??null)}})}),(0,K.jsxs)(bg,{title:`Colors`,hint:`Primary, secondary, and tertiary (accent). The rest is derived.`,children:[(0,K.jsx)(xg,{label:`Primary`,value:i.seeds.primary,onChange:e=>d(`primary`,e)}),(0,K.jsx)(xg,{label:`Secondary`,value:i.seeds.secondary??``,onChange:e=>d(`secondary`,e)}),(0,K.jsx)(xg,{label:`Tertiary`,value:i.seeds.accent??``,onChange:e=>d(`accent`,e)}),(0,K.jsx)(xg,{label:`Background`,value:i.seeds.background??``,onChange:e=>d(`background`,e)}),(0,K.jsx)(xg,{label:`Text`,value:i.seeds.text??``,onChange:e=>d(`text`,e)})]}),(0,K.jsx)(bg,{title:`Accents`,hint:`Per-block accent colors. Add as many as you like.`,children:(0,K.jsx)(wg,{accents:m,onChange:h})}),(0,K.jsxs)(bg,{title:`Typography`,children:[(0,K.jsx)(Sg,{label:`Heading`,value:i.titleFont,onChange:e=>u({titleFont:e})}),(0,K.jsx)(Sg,{label:`Body`,value:i.bodyFont,onChange:e=>u({bodyFont:e})})]}),(0,K.jsxs)(bg,{title:`Style`,children:[(0,K.jsx)(Cg,{label:`Border radius`,value:i.borderRadius,options:Object.keys(Zh),onChange:e=>u({borderRadius:e})}),(0,K.jsx)(Cg,{label:`Animation`,value:i.animationSpeed,options:Object.keys(Qh),onChange:e=>u({animationSpeed:e})}),(0,K.jsx)(Cg,{label:`Text shadow`,value:i.textShadow,options:Object.keys($h),onChange:e=>u({textShadow:e})}),(0,K.jsx)(Cg,{label:`Contrast`,value:i.contrast,options:eg,onChange:e=>u({contrast:e})}),(0,K.jsx)(Cg,{label:`Image grade`,value:i.imageTreatment,options:tg,onChange:e=>u({imageTreatment:e})})]})]}),(0,K.jsxs)(`div`,{className:`squisq-doc-settings-footer squisq-custom-theme-pane-footer`,children:[(0,K.jsx)(`button`,{type:`button`,className:`squisq-doc-settings-btn squisq-doc-settings-btn--secondary`,onClick:r,children:`Cancel`}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-doc-settings-btn squisq-doc-settings-btn--secondary`,onClick:()=>f(`library`),title:o&&o.length>0?`Save to your browser-local library so other docs can use it (imported slide layouts only save to the document)`:`Save to your browser-local library so other docs can use it`,children:`Save to library`}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-doc-settings-btn squisq-doc-settings-btn--primary`,onClick:()=>f(`doc`),children:`Save to document`})]})]})}var Dg=new Set(qn().map(e=>e.id));function Og(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase().replace(/\s+/g,`-`);return t===`datadriven`?`data-driven`:Dg.has(t)?t:null}var Z={theme:{canonical:`squisq-theme`,legacy:[`themeId`,`theme`]},transform:{canonical:`squisq-transform`,legacy:`transform-style`},captions:{canonical:`squisq-captions`,legacy:`caption-style`},coverSlide:ye.enabled,coverTemplate:ye.template,coverDuration:ye.duration,coverPlayback:ye.playback,videoLoop:{canonical:`squisq-video-loop`,legacy:`video-loop`},videoPresentation:{canonical:`squisq-video-presentation`,legacy:`video-presentation`},pipSize:{canonical:`squisq-pip-size`,legacy:`pip-size`},pipShape:{canonical:`squisq-pip-shape`,legacy:`pip-shape`},pipPosition:{canonical:`squisq-pip-position`,legacy:`pip-position`},dashboardLayout:ne.layout,dashboardTitle:ne.showTitle,dashboardStyle:ne.style,proofing:cn.enabled,proofDialect:cn.dialect},kg={theme:`standard`,transform:``,captions:`standard`,coverSlide:De.enabled,coverTemplate:De.template,coverDuration:De.duration,coverPlayback:De.playback,videoLoop:!1,videoPresentation:`background`,pipSize:`small`,pipShape:`square`,pipPosition:`bottom-right`,dashboardLayout:ae.layout,dashboardTitle:ae.showTitle,dashboardStyle:ae.style,proofing:gn.enabled,proofDialect:gn.dialect};function Ag(e,t){return e===t?null:e}var jg=(0,G.createContext)(null);function Mg(){let e=(0,G.useContext)(jg);if(!e)throw Error(`usePreviewSettings must be used within PreviewSettingsProvider`);return e}function Ng(){return(0,G.useContext)(jg)}function Pg(e){return typeof e==`string`?{landscape:`landscape`,"16:9":`landscape`,widescreen:`landscape`,portrait:`portrait`,"9:16":`portrait`,vertical:`portrait`,stories:`portrait`,square:`square`,"1:1":`square`,standard:`standard`,"4:3":`standard`}[e.trim().toLowerCase()]??null:null}function Fg(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return t===`video`||t===`slideshow`||t===`linear`||t===`narrate`?t:t===`slides`||t===`presentation`||t===`deck`?`slideshow`:t===`teleprompter`||t===`prompter`?`narrate`:t===`dashboard`||t===`dash`?`dashboard`:t===`flashcards`||t===`flashcard`||t===`study`||t===`quiz`?`flashcards`:t===`page`||t===`paged`?`linear`:t===`document`||t===`scroll`||t===`html`||t===`plain`||t===`reader`?`page`:null}var Ig=new Set(lt().map(e=>e.id));function Lg(e,t){if(typeof e!=`string`)return null;let n=e.trim(),r=n.toLowerCase();if(Ig.has(r))return r;let i=r.replace(/\s+/g,`-`);return Ig.has(i)?i:t?.has(n)?n:t?.has(r)?r:null}function Rg(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return t===`off`||t===`none`||t===`hidden`||t===`false`||t===`no`?`off`:t===`standard`||t===`cc`||t===`captions`?`standard`:t===`social`||t===`instagram`||t===`tiktok`||t===`reels`?`social`:null}function zg(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return t===`background`||t===`behind`?`background`:t===`full-frame`||t===`fullscreen`||t===`full`?`full-frame`:t===`picture-in-picture`||t===`pip`||t===`overlay`?`picture-in-picture`:null}function Bg(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return t===`small`||t===`sm`||t===`pip-small`?`small`:t===`large`||t===`lg`||t===`big`||t===`pip-large`?`large`:null}function Vg(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return t===`square`||t===`1:1`?`square`:t===`wide`||t===`16:9`||t===`widescreen`?`wide`:null}function Hg(e){return typeof e==`string`?{"top-left":`top-left`,"upper-left":`top-left`,"top-right":`top-right`,"upper-right":`top-right`,"bottom-left":`bottom-left`,"lower-left":`bottom-left`,"bottom-right":`bottom-right`,"lower-right":`bottom-right`}[e.trim().toLowerCase().replace(/[_\s]+/g,`-`)]??null:null}function Ug(e){if(typeof e==`boolean`)return e;if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return t===`true`||t===`yes`||t===`on`||t===`show`||t===`visible`?!0:t===`false`||t===`no`||t===`off`||t===`hide`||t===`hidden`?!1:null}function Wg(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return t?t===`auto`||t==="default"?fe:t:null}function Gg(e,t,n){if(e)return Object.prototype.hasOwnProperty.call(e,t)?e[t]:e[n]}function Kg(e){try{let t=Tt(e).frontmatter;return{themes:de(t)??[],templates:ve(t)??[]}}catch(e){return console.error(`[squisq-editor] could not read the document source to merge custom themes:`,e instanceof Error?e.message:String(e)),null}}var qg=`Could not read the document, so the theme was not saved (saving would have erased the document’s other custom themes). Fix the document, then try again.`;function Jg({doc:e,children:t,defaultViewportPreset:n=`landscape`,themeOverride:r}){let i=e?.frontmatter,{markdownSource:a,setMarkdownSource:o,allowNarrate:s}=Lp(),c=(0,G.useCallback)(e=>{let t=We(a,e);t!==a&&o(t)},[a,o]),l=(0,G.useMemo)(()=>Fg(i?.[`display-mode`]),[i]),[u,d]=(0,G.useState)(null);(0,G.useEffect)(()=>d(null),[l]);let f=u??l??`slideshow`,p=f===`narrate`&&!s?`video`:f,m=(0,G.useMemo)(()=>Pg(i?.[`document-render-as`]),[i]),[h,g]=(0,G.useState)(null);(0,G.useEffect)(()=>g(null),[m]);let _=h??m??(p===`slideshow`||p===`video`||p===`dashboard`?n:`landscape`),v=Ge[_],b=Yh(),x=(0,G.useMemo)(()=>b?.docThemes??e?.customThemes??[],[b,e?.customThemes]),S=(0,G.useMemo)(()=>b?.allThemes??x,[b,x]),w=(0,G.useMemo)(()=>new Set(S.map(e=>e.id)),[S]),T=(0,G.useMemo)(()=>Lg(He(i),w),[i,w]),[E,D]=(0,G.useState)(null);(0,G.useEffect)(()=>D(null),[T]);let O=E??T??kg.theme,k=(0,G.useMemo)(()=>S.find(e=>e.id===O)??y(e,O),[S,e,O]),[A,j]=(0,G.useState)(null),[M,N]=(0,G.useState)(null),[P,F]=(0,G.useState)({open:!1,editing:null}),I=A?.id??r?.id??O,L=A??r??k,ee=(0,G.useCallback)(e=>{if(e===null){D(null);return}let t=S.find(t=>t.id===e),n={[Z.theme.canonical]:Ag(e,kg.theme),[Z.theme.legacy[0]]:null,[Z.theme.legacy[1]]:null};if(t){let r=Kg(a);if(!r){N(qg);return}r.themes.some(t=>t.id===e)||(n[rt]=ie([...r.themes,t])??null)}N(null),D(e),c(n)},[S,a,c]),te=(0,G.useCallback)(e=>{F({open:!0,editing:e}),j(e),N(null)},[]),R=(0,G.useCallback)(()=>{F({open:!1,editing:null}),j(null),N(null)},[]),ne=(0,G.useCallback)((e,t,n)=>{if(t===`library`)b?.upsertLibraryTheme(e);else{let t=Kg(a);if(!t){N(qg);return}let r=t.themes.findIndex(t=>t.id===e.id),i=r>=0?t.themes.map((t,n)=>n===r?e:t):[...t.themes,e],o={[rt]:ie(i)??null,[Z.theme.canonical]:e.id};n?.templates&&n.templates.length>0&&(o[Qe]=Ie([...t.templates.filter(e=>!n.templates.some(t=>t.name===e.name)),...n.templates])??null),N(null),c(o),D(e.id)}R()},[b,a,c,R]),re=(0,G.useCallback)(e=>{b?.removeDocTheme(e),b?.removeLibraryTheme(e)},[b]),z=(0,G.useMemo)(()=>Og(Gg(i,Z.transform.canonical,Z.transform.legacy)),[i]),[ae,oe]=(0,G.useState)(null);(0,G.useEffect)(()=>oe(null),[z]);let se=ae??z??``,ce=(0,G.useCallback)(e=>{oe(e),e!==null&&c({[Z.transform.canonical]:Ag(e,kg.transform),[Z.transform.legacy]:null})},[c]),le=(0,G.useMemo)(()=>!!e&&ot(e).some(e=>e.kind===`video`),[e]),B=(0,G.useMemo)(()=>zg(Gg(i,Z.videoPresentation.canonical,Z.videoPresentation.legacy)),[i]),[ue,V]=(0,G.useState)(null);(0,G.useEffect)(()=>V(null),[B]);let de=ue??B??kg.videoPresentation,fe=(0,G.useCallback)(e=>{V(e),c({[Z.videoPresentation.canonical]:Ag(e,kg.videoPresentation),[Z.videoPresentation.legacy]:null})},[c]),H=(0,G.useMemo)(()=>Bg(Gg(i,Z.pipSize.canonical,Z.pipSize.legacy)),[i]),[me,U]=(0,G.useState)(null);(0,G.useEffect)(()=>U(null),[H]);let he=me??H??kg.pipSize,ge=(0,G.useCallback)(e=>{U(e),c({[Z.pipSize.canonical]:Ag(e,kg.pipSize),[Z.pipSize.legacy]:null})},[c]),_e=(0,G.useMemo)(()=>Vg(Gg(i,Z.pipShape.canonical,Z.pipShape.legacy)),[i]),[W,ve]=(0,G.useState)(null);(0,G.useEffect)(()=>ve(null),[_e]);let ye=W??_e??kg.pipShape,be=(0,G.useCallback)(e=>{ve(e),c({[Z.pipShape.canonical]:Ag(e,kg.pipShape),[Z.pipShape.legacy]:null})},[c]),xe=(0,G.useMemo)(()=>Hg(Gg(i,Z.pipPosition.canonical,Z.pipPosition.legacy)),[i]),[Se,Ce]=(0,G.useState)(null);(0,G.useEffect)(()=>Ce(null),[xe]);let we=Se??xe??kg.pipPosition,Te=(0,G.useCallback)(e=>{Ce(e),c({[Z.pipPosition.canonical]:Ag(e,kg.pipPosition),[Z.pipPosition.legacy]:null})},[c]),Ee=(0,G.useMemo)(()=>Rg(Gg(i,Z.captions.canonical,Z.captions.legacy)),[i]),[De,Oe]=(0,G.useState)(null);(0,G.useEffect)(()=>Oe(null),[Ee]);let ke=De??Ee??kg.captions,Ae=ke!==`off`,je=ke===`social`?`social`:`standard`,Me=(0,G.useCallback)(e=>{Oe(e),c({[Z.captions.canonical]:Ag(e,kg.captions),[Z.captions.legacy]:null})},[c]),Pe=(0,G.useMemo)(()=>Ug(Gg(i,Z.videoLoop.canonical,Z.videoLoop.legacy)),[i]),[Fe,Le]=(0,G.useState)(null);(0,G.useEffect)(()=>Le(null),[Pe]);let Re=Fe??Pe??kg.videoLoop,ze=(0,G.useCallback)(e=>{Le(e),c({[Z.videoLoop.canonical]:Ag(e,kg.videoLoop),[Z.videoLoop.legacy]:null})},[c]),Be=(0,G.useMemo)(()=>pe(i),[i]),Ve=Be.enabled,[Ue,Ke]=(0,G.useState)(null);(0,G.useEffect)(()=>Ke(null),[Ve]);let qe=Ue??Ve,Je=(0,G.useCallback)(e=>{Ke(e),c({[Z.coverSlide.canonical]:Ag(e,kg.coverSlide),[Z.coverSlide.legacy]:null})},[c]),[Ye,Xe]=(0,G.useState)(null);(0,G.useEffect)(()=>Xe(null),[Be.template]);let Ze=Ye??Be.template,$e=(0,G.useCallback)(e=>{Xe(e),c({[Z.coverTemplate.canonical]:Ag(e,kg.coverTemplate),[Z.coverTemplate.legacy]:null})},[c]),[et,tt]=(0,G.useState)(null);(0,G.useEffect)(()=>tt(null),[Be.duration]);let nt=et??Be.duration,it=(0,G.useCallback)(e=>{!Number.isFinite(e)||e<0||e>60||(tt(e),c({[Z.coverDuration.canonical]:Ag(e,kg.coverDuration),[Z.coverDuration.legacy]:null}))},[c]),[at,st]=(0,G.useState)(null);(0,G.useEffect)(()=>st(null),[Be.playback]);let ct=at??Be.playback,lt=(0,G.useCallback)(e=>{st(e),c({[Z.coverPlayback.canonical]:Ag(e,kg.coverPlayback),[Z.coverPlayback.legacy]:null})},[c]),ut=(0,G.useMemo)(()=>P.open?{value:P.editing,onChange:j,onSave:ne,onClose:R}:null,[P.open,P.editing,ne,R]),dt=(0,G.useMemo)(()=>Wg(Gg(i,Z.dashboardLayout.canonical,Z.dashboardLayout.legacy)),[i]),[ft,pt]=(0,G.useState)(null);(0,G.useEffect)(()=>pt(null),[dt]);let mt=ft??dt??kg.dashboardLayout,ht=(0,G.useCallback)(e=>{let t=Wg(e)??kg.dashboardLayout;pt(t),c({[Z.dashboardLayout.canonical]:Ag(t,kg.dashboardLayout),[Z.dashboardLayout.legacy]:null})},[c]),gt=(0,G.useMemo)(()=>Ug(Gg(i,Z.dashboardTitle.canonical,Z.dashboardTitle.legacy)),[i]),[_t,vt]=(0,G.useState)(null);(0,G.useEffect)(()=>vt(null),[gt]);let yt=_t??gt??kg.dashboardTitle,bt=(0,G.useCallback)(e=>{vt(e),c({[Z.dashboardTitle.canonical]:Ag(e,kg.dashboardTitle),[Z.dashboardTitle.legacy]:null})},[c]),xt=(0,G.useMemo)(()=>C(Gg(i,Z.dashboardStyle.canonical,Z.dashboardStyle.legacy)),[i]),[St,Ct]=(0,G.useState)(null);(0,G.useEffect)(()=>Ct(null),[xt]);let wt=St??xt??kg.dashboardStyle,Tt=(0,G.useCallback)(e=>{let t=C(e)??kg.dashboardStyle;Ct(t),c({[Z.dashboardStyle.canonical]:Ag(t,kg.dashboardStyle),[Z.dashboardStyle.legacy]:null})},[c]),Et=(0,G.useMemo)(()=>Ne({frontmatter:i}),[i]),Dt=(0,G.useMemo)(()=>({activePreset:_,setSelectedPreset:g,activeViewport:v,activeDisplayMode:p,setSelectedDisplayMode:d,activeThemeId:I,setSelectedThemeId:ee,activeTheme:L,activeTransformStyle:se,setSelectedTransformStyle:ce,activeCaptionStyle:je,activeCaptionsEnabled:Ae,setCaptionMode:Me,hasVideoMedia:le,activeVideoPresentation:de,setVideoPresentation:fe,activePipSize:he,setPipSize:ge,activePipShape:ye,setPipShape:be,activePipPosition:we,setPipPosition:Te,activeVideoLoop:Re,setVideoLoopEnabled:ze,activeDashboardLayout:mt,setDashboardLayout:ht,activeDashboardTitle:yt,setDashboardTitleEnabled:bt,activeDashboardStyle:wt,setDashboardStyle:Tt,dashboardLayoutOptions:Et,activeCoverSlide:qe,setCoverSlideEnabled:Je,activeCoverSlideTemplate:Ze,setCoverSlideTemplate:$e,activeCoverSlideDuration:nt,setCoverSlideDuration:it,activeCoverSlidePlayback:ct,setCoverSlidePlayback:lt,customThemes:S,openThemeDesigner:te,deleteCustomTheme:re,themeDesigner:ut,themeSaveError:M}),[_,v,p,I,L,se,je,Ae,le,de,he,ye,we,Re,mt,yt,wt,Et,qe,Ze,nt,ct,ee,ce,Me,fe,ge,be,Te,ze,ht,bt,Tt,Je,$e,it,lt,S,te,re,ut,M]);return(0,K.jsx)(jg.Provider,{value:Dt,children:t})}function Yg(){let{themeDesigner:e,themeSaveError:t}=Mg();return e?(0,K.jsxs)(K.Fragment,{children:[t&&(0,K.jsx)(`div`,{className:`squisq-theme-save-error`,role:`alert`,style:f_,children:t}),(0,K.jsx)(Eg,{value:e.value,onChange:e.onChange,onSave:e.onSave,onClose:e.onClose})]}):null}var Xg=[{key:`landscape`,label:`16:9`,w:13,h:7},{key:`square`,label:`1:1`,w:10,h:10},{key:`portrait`,label:`9:16`,w:7,h:12},{key:`standard`,label:`4:3`,w:12,h:9}],Zg=[{key:`background`,label:`Behind`},{key:`full-frame`,label:`Full frame`},{key:`picture-in-picture`,label:`Picture in picture`}],Qg=[{key:`small`,label:`Small`},{key:`large`,label:`Large`}],$g=[{key:`square`,label:`Square`},{key:`wide`,label:`Wide (16:9)`}],e_=[{key:`top-left`,label:`Top left`},{key:`top-right`,label:`Top right`},{key:`bottom-left`,label:`Bottom left`},{key:`bottom-right`,label:`Bottom right`}],t_=[{key:`slideshow`,label:`Slideshow`,icon:`fa-solid fa-images`,summary:`Present designed slides one at a time.`},{key:`flashcards`,label:`Flashcards`,icon:`fa-solid fa-clone`,summary:`Study with progressive reveals and quizzes.`},{key:`video`,label:`Video`,icon:`fa-solid fa-circle-play`,summary:`Play an automatically timed presentation.`},{key:`linear`,label:`Page`,icon:`fa-solid fa-window-maximize`,summary:`Scroll through the fully designed page.`},{key:`dashboard`,label:`Dashboard`,icon:`fa-solid fa-table-cells-large`,summary:`See every block arranged on one canvas.`},{key:`page`,label:`Document`,icon:`fa-solid fa-align-left`,summary:`Read a clean, text-first document.`},{key:`narrate`,label:`Narrate`,icon:`fa-solid fa-microphone-lines`,summary:`Speak with a voice-paced teleprompter.`}];function n_(e){return t_.find(t=>t.key===e)?.label??`Slideshow`}var r_=[{key:``,label:`None`},...qn().map(e=>({key:e.id,label:e.name}))],i_=`Extract and summarize content for presentation with these Use modes. Your underlying content is not changed.`,a_=[`format`,`layout`,`video`,`theme`,`transform`,`captions`,`loop`,`cover`,`dashboardImage`];function o_(e,t){if(e===`flashcards`)return[`theme`,`transform`];if(e===`dashboard`)return[`format`,`layout`,`theme`,`transform`,`dashboardImage`];let n=a_.filter(e=>e!==`layout`&&e!==`dashboardImage`);return e!==`video`&&(n=n.filter(e=>e!==`loop`)),(!t||e!==`slideshow`&&e!==`video`)&&(n=n.filter(e=>e!==`video`)),e===`linear`?n.filter(e=>e!==`format`&&e!==`captions`):n}var s_=4,c_=8,l_=220;function u_(e,t,n){let r=Math.max(c_,n-t-c_);return Math.min(Math.max(c_,e.right-t),r)}var d_={color:`var(--squisq-text-muted)`,fontSize:`12px`,whiteSpace:`nowrap`},f_={padding:`8px 10px`,border:`1px solid var(--squisq-danger-border)`,background:`var(--squisq-danger-soft)`,color:`var(--squisq-danger-strong)`,fontSize:`12px`,maxWidth:`320px`},p_={padding:`2px 6px`,borderRadius:`4px`,border:`1px solid var(--squisq-border)`,background:`var(--squisq-input-bg)`,color:`var(--squisq-text)`,fontSize:`12px`,cursor:`pointer`},m_=336,h_=4,g_=8,__={landscape:`fhd`,portrait:`portrait`,square:`square`,standard:`standard`};function v_({compact:e}){let t=Mg(),{colorScheme:n,doc:r,fileName:i,mediaProvider:a,saveDashboardImageOutput:o}=Lp(),[s,c]=(0,G.useState)(!1);return(0,K.jsxs)(`div`,{className:`squisq-preview-control${e?` squisq-preview-control--compact`:``}`,children:[e&&(0,K.jsx)(`label`,{style:d_,children:`Export:`}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-toolbar-button`,disabled:!r,onClick:()=>c(!0),"aria-label":`Export dashboard as image`,title:`Export dashboard as image`,children:(0,K.jsx)(q,{icon:`fa-solid fa-file-image`})}),s&&r&&(0,Wr.createPortal)((0,K.jsx)(Fu,{doc:r,mediaProvider:a,theme:t.activeTheme,defaultResolution:__[t.activePreset],defaultLayout:t.activeDashboardLayout,defaultShowTitle:t.activeDashboardTitle,defaultStyle:t.activeDashboardStyle,defaultFileName:i,colorScheme:n,saveOutput:o,onClose:()=>c(!1)}),document.body)]})}function y_({compact:e}){let t=Mg(),{colorScheme:n,doc:r,fileName:i,mediaProvider:a,saveCoverImageOutput:o}=Lp(),s=(0,G.useRef)(null),c=(0,G.useRef)(null),[l,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(null),[p,m]=(0,G.useState)(!1),h=(0,G.useCallback)(()=>{let e=s.current;if(!e)return;let t=e.getBoundingClientRect(),n=Math.min(m_,window.innerWidth-g_*2);f({top:t.bottom+h_,left:u_(t,n,window.innerWidth)})},[]),g=(0,G.useCallback)(()=>{u(!1),f(null)},[]);(0,G.useEffect)(()=>{if(!l)return;let e=e=>{let t=e.target;s.current?.contains(t)||c.current?.contains(t)||g()},t=e=>{e.key===`Escape`&&(e.preventDefault(),g(),s.current?.focus())};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),window.addEventListener(`resize`,h),window.addEventListener(`scroll`,h,!0),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t),window.removeEventListener(`resize`,h),window.removeEventListener(`scroll`,h,!0)}},[g,l,h]);let _=!!r?.startBlock,v=(0,G.useMemo)(()=>{if(!l||!r?.startBlock)return null;let e=Ke(t.activeTheme,0,1,t.activeViewport);return{id:`cover-slide-menu-preview`,startTime:-1,duration:0,audioSegment:-1,layers:te(r.startBlock,e,t.activeCoverSlideTemplate)}},[l,r?.startBlock,t.activeTheme,t.activeViewport,t.activeCoverSlideTemplate]);return(0,K.jsxs)(`div`,{className:`squisq-preview-control squisq-cover-slide-control${e?` squisq-preview-control--compact`:``}`,children:[(0,K.jsxs)(`button`,{ref:s,type:`button`,className:`squisq-cover-slide-trigger${l?` squisq-cover-slide-trigger--open`:``}`,"aria-label":`Cover slide settings`,"aria-haspopup":`dialog`,"aria-expanded":l,onClick:()=>{l?g():(h(),u(!0))},children:[(0,K.jsx)(`span`,{className:`squisq-cover-slide-status${t.activeCoverSlide?` squisq-cover-slide-status--enabled`:``}`,"aria-hidden":`true`,children:(0,K.jsx)(q,{icon:t.activeCoverSlide?`fa-solid fa-check`:`fa-solid fa-minus`})}),(0,K.jsx)(`span`,{children:`Cover slide`}),(0,K.jsx)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 10 10`,"aria-hidden":`true`,children:(0,K.jsx)(`path`,{d:`M2 3.5 5 6.5 8 3.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`})})]}),l&&d&&(0,Wr.createPortal)((0,K.jsxs)(`div`,{ref:c,className:`squisq-cover-slide-menu`,"data-theme":n,role:`dialog`,"aria-label":`Cover slide settings`,style:{top:d.top,left:d.left},children:[(0,K.jsxs)(`div`,{className:`squisq-cover-slide-menu-heading`,children:[(0,K.jsx)(`span`,{children:`Cover slide`}),(0,K.jsxs)(`label`,{className:`squisq-cover-slide-switch`,children:[(0,K.jsx)(`input`,{type:`checkbox`,"aria-label":`Cover slide`,checked:t.activeCoverSlide,onChange:e=>t.setCoverSlideEnabled(e.target.checked)}),(0,K.jsx)(`span`,{children:t.activeCoverSlide?`Shown`:`Hidden`})]})]}),(0,K.jsx)(`div`,{className:`squisq-cover-slide-preview${t.activeCoverSlide?``:` squisq-cover-slide-preview--disabled`}`,style:{aspectRatio:`${t.activeViewport.width} / ${t.activeViewport.height}`},children:v?(0,K.jsx)(pn.Provider,{value:a??null,children:(0,K.jsx)(`div`,{className:`squisq-cover-slide-preview-frame`,"aria-hidden":`true`,children:(0,K.jsx)(sn,{block:v,blockTime:0,basePath:`.`,viewport:t.activeViewport,animationsEnabled:!1,muted:!0,theme:t.activeTheme})})}):(0,K.jsxs)(`p`,{className:`squisq-cover-slide-preview-empty`,children:[`No cover to preview yet — start the document with a level-1 heading (`,(0,K.jsx)(`code`,{children:`#\xA0Title`}),`) to generate one.`]})}),(0,K.jsxs)(`label`,{className:`squisq-cover-slide-field`,children:[(0,K.jsx)(`span`,{children:`Appearance`}),(0,K.jsx)(`select`,{"aria-label":`Cover slide appearance`,value:t.activeCoverSlideTemplate,onChange:e=>t.setCoverSlideTemplate(e.target.value),children:Te.map(e=>(0,K.jsx)(`option`,{value:e.id,disabled:e.requiresHeroImage&&!r?.startBlock?.heroSrc,children:e.label},e.id))})]}),(0,K.jsx)(`p`,{className:`squisq-cover-slide-help`,children:Te.find(e=>e.id===t.activeCoverSlideTemplate)?.description}),(0,K.jsxs)(`label`,{className:`squisq-cover-slide-field`,children:[(0,K.jsxs)(`span`,{children:[`Duration`,(0,K.jsxs)(`output`,{children:[t.activeCoverSlideDuration.toFixed(1),`s`]})]}),(0,K.jsx)(`input`,{"aria-label":`Cover slide duration`,type:`range`,min:0,max:10,step:.5,value:t.activeCoverSlideDuration,onChange:e=>t.setCoverSlideDuration(Number(e.target.value))})]}),(0,K.jsxs)(`fieldset`,{className:`squisq-cover-slide-timing`,children:[(0,K.jsx)(`legend`,{children:`Exported video timing`}),(0,K.jsxs)(`label`,{children:[(0,K.jsx)(`input`,{type:`radio`,name:`squisq-cover-playback`,value:`preroll`,checked:t.activeCoverSlidePlayback===`preroll`,onChange:()=>t.setCoverSlidePlayback(`preroll`)}),(0,K.jsxs)(`span`,{children:[`Delay video`,(0,K.jsx)(`small`,{children:`Start the story after the cover.`})]})]}),(0,K.jsxs)(`label`,{children:[(0,K.jsx)(`input`,{type:`radio`,name:`squisq-cover-playback`,value:`overlay`,checked:t.activeCoverSlidePlayback===`overlay`,onChange:()=>t.setCoverSlidePlayback(`overlay`)}),(0,K.jsxs)(`span`,{children:[`Play underneath`,(0,K.jsx)(`small`,{children:`Let the story advance behind the cover.`})]})]})]}),(0,K.jsxs)(`button`,{type:`button`,className:`squisq-cover-slide-export`,disabled:!_,title:_?void 0:`No cover slide to export — start the document with a level-1 heading (# Title) to generate one.`,onClick:()=>{g(),m(!0)},children:[(0,K.jsx)(q,{icon:`fa-solid fa-image`}),`Export cover as image…`]})]}),document.body),p&&r&&(0,Wr.createPortal)((0,K.jsx)(Tu,{doc:r,mediaProvider:a,theme:t.activeTheme,coverSlideTemplate:t.activeCoverSlideTemplate,defaultWidth:t.activeViewport.width,defaultHeight:t.activeViewport.height,defaultFileName:i,colorScheme:n,saveOutput:o,onClose:()=>m(!1)}),document.body)]})}function b_({displayMode:e}={}){let t=Mg(),n=o_(e??t.activeDisplayMode,t.hasVideoMedia),[r,i]=(0,G.useState)(a_.length),[a,o]=(0,G.useState)(!1),s=(0,G.useRef)(null),c=(0,G.useRef)(null),l=(0,G.useRef)(null),u=(0,G.useRef)(null),d=(0,G.useRef)(null),[f,p]=(0,G.useState)(null),m=(0,G.useCallback)(()=>{let e=u.current;if(!e)return;let t=e.getBoundingClientRect(),n=d.current?.getBoundingClientRect().width??l_,r=Math.min(n,window.innerWidth-c_*2);p({top:t.bottom+s_,left:u_(t,r,window.innerWidth)})},[]),h=(0,G.useCallback)(()=>{o(!1),p(null)},[]);(0,G.useLayoutEffect)(()=>{let e=s.current,t=c.current;if(!e||!t)return;let n=()=>{let n=e.clientWidth-9,r=Array.from(t.children).map(e=>e.getBoundingClientRect().width),a=e=>r.slice(0,e).reduce((e,t)=>e+t,0)+6*Math.max(0,e-1);if(a(r.length)<=n){i(r.length);return}let o=n-40-6-2,s=0;for(;s<r.length&&a(s+1)<=o;)s++;i(s)},r=new ResizeObserver(n);return r.observe(e),r.observe(t),n(),()=>r.disconnect()},[n.length]),(0,G.useEffect)(()=>{if(!a)return;let e=e=>{let t=e.target;l.current?.contains(t)||d.current?.contains(t)||h()};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[h,a]),(0,G.useLayoutEffect)(()=>{a&&m()},[a,m,r]),(0,G.useEffect)(()=>{if(a)return window.addEventListener(`resize`,m),window.addEventListener(`scroll`,m,!0),()=>{window.removeEventListener(`resize`,m),window.removeEventListener(`scroll`,m,!0)}},[a,m]);let g=(0,G.useCallback)(()=>{let e=t.customThemes.find(e=>e.id===t.activeThemeId);if(e)t.openThemeDesigner(e);else{let e=t.activeTheme;t.openThemeDesigner({...e,name:`Modified ${e.name}`,basedOn:e.id})}},[t]),_=(e,n)=>{switch(e){case`format`:return(0,K.jsxs)(`div`,{className:`squisq-preview-control squisq-preview-control--seg${n?` squisq-preview-control--compact`:``}`,children:[n&&(0,K.jsx)(`label`,{style:d_,children:`Format:`}),(0,K.jsx)(E_,{})]},`format`);case`layout`:{let e=t.dashboardLayoutOptions.filter(e=>!e.custom),r=t.dashboardLayoutOptions.filter(e=>e.custom);return(0,K.jsxs)(`div`,{className:`squisq-preview-control${n?` squisq-preview-control--compact`:``}`,children:[(0,K.jsx)(`label`,{style:d_,children:`Layout:`}),(0,K.jsxs)(`select`,{"aria-label":`Dashboard layout`,style:p_,value:t.activeDashboardLayout,onChange:e=>t.setDashboardLayout(e.target.value),children:[(0,K.jsx)(`option`,{value:fe,children:`Auto`}),e.map(e=>(0,K.jsx)(`option`,{value:e.id,children:`${e.label} (${e.capacity})`},e.id)),r.length>0&&(0,K.jsx)(`optgroup`,{label:`Custom`,children:r.map(e=>(0,K.jsx)(`option`,{value:e.id,children:`${e.label} (${e.capacity})`},e.id))})]}),(0,K.jsx)(`label`,{style:d_,children:`Style:`}),(0,K.jsx)(`select`,{"aria-label":`Dashboard cell style`,style:p_,value:t.activeDashboardStyle,onChange:e=>t.setDashboardStyle(e.target.value),children:xe.map(e=>(0,K.jsx)(`option`,{value:e.id,title:e.description,children:e.label},e.id))}),(0,K.jsxs)(`label`,{className:`squisq-preview-checkbox`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:t.activeDashboardTitle,onChange:e=>t.setDashboardTitleEnabled(e.target.checked)}),(0,K.jsx)(`span`,{children:`Title`})]})]},`layout`)}case`video`:{let e=t.activeVideoPresentation===`picture-in-picture`;return(0,K.jsxs)(`div`,{className:`squisq-preview-control${n?` squisq-preview-control--compact`:``}`,children:[(0,K.jsx)(`label`,{style:d_,children:`Video:`}),(0,K.jsx)(`select`,{"aria-label":`Video presentation`,style:p_,value:t.activeVideoPresentation,onChange:e=>t.setVideoPresentation(e.target.value),children:Zg.map(e=>(0,K.jsx)(`option`,{value:e.key,children:e.label},e.key))}),e&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`select`,{"aria-label":`Picture-in-picture size`,style:p_,value:t.activePipSize,onChange:e=>t.setPipSize(e.target.value),children:Qg.map(e=>(0,K.jsx)(`option`,{value:e.key,children:e.label},e.key))}),(0,K.jsx)(`select`,{"aria-label":`Picture-in-picture shape`,style:p_,value:t.activePipShape,onChange:e=>t.setPipShape(e.target.value),children:$g.map(e=>(0,K.jsx)(`option`,{value:e.key,children:e.label},e.key))}),(0,K.jsx)(`select`,{"aria-label":`Picture-in-picture position`,style:p_,value:t.activePipPosition,onChange:e=>t.setPipPosition(e.target.value),children:e_.map(e=>(0,K.jsx)(`option`,{value:e.key,children:e.label},e.key))})]})]},`video`)}case`theme`:return(0,K.jsxs)(`div`,{className:`squisq-preview-control${n?` squisq-preview-control--compact`:``}`,children:[(0,K.jsx)(`label`,{style:d_,children:`Theme:`}),(0,K.jsx)(zh,{value:t.activeThemeId,onChange:e=>t.setSelectedThemeId(e),ariaLabel:`Theme`,customThemes:t.customThemes,onCreateCustom:()=>t.openThemeDesigner(null),onEditCustom:e=>t.openThemeDesigner(t.customThemes.find(t=>t.id===e)??null),onDeleteCustom:e=>t.deleteCustomTheme(e)}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-theme-edit-btn`,onClick:g,"aria-label":`Edit theme`,title:`Edit this theme`,children:(0,K.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,K.jsx)(`path`,{d:`M2.5 13.5l1-3 7-7 2 2-7 7-3 1z`}),(0,K.jsx)(`path`,{d:`M9.5 4.5l2 2`})]})}),t.themeSaveError&&(0,K.jsx)(`span`,{className:`squisq-theme-save-error`,role:`alert`,title:t.themeSaveError,style:{color:`var(--squisq-danger-strong)`,fontSize:`12px`},children:`⚠ Theme not saved`})]},`theme`);case`transform`:return(0,K.jsx)(D_,{label:`Summarize`,labelTooltip:i_,value:t.activeTransformStyle,options:r_,onChange:e=>t.setSelectedTransformStyle(e),compact:n},`transform`);case`captions`:{let e=t.activeCaptionsEnabled,r=e&&t.activeCaptionStyle===`standard`,i=e&&t.activeCaptionStyle===`social`;return(0,K.jsxs)(`div`,{className:`squisq-preview-control${n?` squisq-preview-control--compact`:``}`,children:[(0,K.jsx)(`label`,{style:d_,children:`Captions:`}),(0,K.jsxs)(`div`,{className:`squisq-preview-seg`,role:`group`,"aria-label":`Captions`,children:[(0,K.jsx)(`button`,{type:`button`,className:`squisq-preview-seg-btn squisq-preview-seg-btn--icon${r?` squisq-preview-seg-btn--active`:``}`,"aria-pressed":r,"aria-label":`Standard captions`,title:`Standard captions`,onClick:()=>t.setCaptionMode(r?`off`:`standard`),children:(0,K.jsx)(q,{icon:`fa-solid fa-closed-captioning`})}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-preview-seg-btn squisq-preview-seg-btn--icon${i?` squisq-preview-seg-btn--active`:``}`,"aria-pressed":i,"aria-label":`Social captions`,title:`Social captions`,onClick:()=>t.setCaptionMode(i?`off`:`social`),children:(0,K.jsx)(q,{icon:`fa-solid fa-share-nodes`})})]})]},`captions`)}case`loop`:return(0,K.jsx)(`div`,{className:`squisq-preview-control${n?` squisq-preview-control--compact`:``}`,children:(0,K.jsxs)(`label`,{className:`squisq-preview-checkbox`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:t.activeVideoLoop,onChange:e=>t.setVideoLoopEnabled(e.target.checked)}),(0,K.jsx)(`span`,{children:`Loop`})]})},`loop`);case`cover`:return(0,K.jsx)(y_,{compact:n},`cover`);case`dashboardImage`:return(0,K.jsx)(v_,{compact:n},`dashboardImage`)}},v=r<n.length,y=n.slice(0,r),b=n.slice(r);return(0,G.useEffect)(()=>{!v&&a&&h()},[h,v,a]),(0,K.jsxs)(`div`,{className:`squisq-preview-controls`,"data-has-overflow":v?`true`:void 0,ref:s,children:[(0,K.jsx)(`div`,{className:`squisq-preview-controls-probe`,ref:c,"aria-hidden":`true`,children:n.map(e=>_(e,!1))}),y.length>0&&(0,K.jsx)(`div`,{className:`squisq-preview-controls-inline`,children:y.map(e=>_(e,!1))}),v&&(0,K.jsxs)(`div`,{className:`squisq-preview-controls-compact`,ref:l,children:[(0,K.jsx)(`button`,{ref:u,className:`squisq-toolbar-button${a?` squisq-toolbar-button--active`:``}`,onClick:()=>{if(a){h();return}m(),o(!0)},"aria-label":`More preview settings`,title:`More preview settings`,"aria-expanded":a,children:(0,K.jsx)(q,{icon:`fa-solid fa-ellipsis`})}),a&&f&&(0,K.jsx)(`div`,{ref:d,className:`squisq-preview-controls-popover`,style:{top:f.top,left:f.left},children:b.map(e=>_(e,!0))})]})]})}var x_=340,S_=4,C_=8;function w_({openRequest:e=0}){let t=Mg(),{allowNarrate:n,colorScheme:r,setActiveView:i}=Lp(),a=t_.filter(e=>e.key!==`narrate`||n),o=n_(t.activeDisplayMode),s=(0,G.useRef)(null),c=(0,G.useRef)(null),l=(0,G.useId)(),[u,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(null),m=(0,G.useCallback)(()=>{let e=s.current;if(!e)return;let t=e.getBoundingClientRect(),n=Math.min(x_,window.innerWidth-C_*2),r=Math.max(C_,window.innerWidth-n-C_);p({top:t.bottom+S_,left:Math.min(Math.max(C_,t.right-n),r)})},[]),h=(0,G.useCallback)((e=!1)=>{d(!1),p(null),e&&s.current?.focus()},[]),g=(0,G.useCallback)(()=>{m(),d(!0)},[m]);return(0,G.useEffect)(()=>{e>0&&g()},[g,e]),(0,G.useEffect)(()=>{if(!u)return;let e=e=>{let t=e.composedPath();s.current&&t.includes(s.current)||c.current&&t.includes(c.current)||h()},t=e=>{e.key===`Escape`&&(e.preventDefault(),h(!0))};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),window.addEventListener(`resize`,m),window.addEventListener(`scroll`,m,!0),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t),window.removeEventListener(`resize`,m),window.removeEventListener(`scroll`,m,!0)}},[h,u,m]),(0,G.useLayoutEffect)(()=>{if(!u||!f)return;let e=c.current?.querySelector(`[aria-checked="true"]`),t=c.current?.querySelector(`[role="menuitemradio"]`);(e??t)?.focus()},[f,u]),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{ref:s,type:`button`,className:`squisq-use-mode-trigger${u?` squisq-use-mode-trigger--open`:``}`,"aria-label":`Choose Use mode`,"aria-haspopup":`menu`,"aria-expanded":u,title:`Use mode: ${o}`,onClick:()=>u?h():g(),onKeyDown:e=>{e.key===`ArrowDown`&&(e.preventDefault(),g())},children:(0,K.jsx)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 10 10`,"aria-hidden":`true`,children:(0,K.jsx)(`path`,{d:`M2 3.5 5 6.5 8 3.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`})})}),u&&f&&(0,Wr.createPortal)((0,K.jsx)(`div`,{ref:c,className:`squisq-use-mode-menu`,"data-theme":r,role:`menu`,"aria-label":`Use mode`,style:{top:f.top,left:f.left},onKeyDown:e=>{if(![`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=Array.from(e.currentTarget.querySelectorAll(`[role="menuitemradio"]`));if(t.length===0)return;let n=t.indexOf(document.activeElement);t[e.key===`Home`?0:e.key===`End`?t.length-1:e.key===`ArrowUp`?(n-1+t.length)%t.length:(n+1)%t.length]?.focus()},children:a.map(e=>{let n=e.key===t.activeDisplayMode,r=`${l}-${e.key}-label`,a=`${l}-${e.key}-summary`;return(0,K.jsxs)(`button`,{type:`button`,className:`squisq-use-mode-menu-item${n?` squisq-use-mode-menu-item--selected`:``}`,role:`menuitemradio`,"aria-checked":n,"aria-labelledby":r,"aria-describedby":a,onClick:()=>{t.setSelectedDisplayMode(e.key),i(`preview`),h(!0)},children:[(0,K.jsx)(`span`,{className:`squisq-use-mode-menu-icon`,"aria-hidden":`true`,children:(0,K.jsx)(q,{icon:e.icon})}),(0,K.jsxs)(`span`,{className:`squisq-use-mode-menu-copy`,children:[(0,K.jsx)(`span`,{id:r,className:`squisq-use-mode-menu-label`,children:e.label}),(0,K.jsx)(`span`,{id:a,className:`squisq-use-mode-menu-summary`,children:e.summary})]}),(0,K.jsx)(`span`,{className:`squisq-use-mode-menu-check`,"aria-hidden":`true`,children:n&&(0,K.jsx)(q,{icon:`fa-solid fa-check`})})]},e.key)})}),document.body)]})}function T_({w:e,h:t}){return(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,"aria-hidden":`true`,children:(0,K.jsx)(`rect`,{x:(16-e)/2,y:(16-t)/2,width:e,height:t,rx:`1.5`})})}function E_(){let e=Mg();return(0,K.jsx)(`div`,{className:`squisq-preview-seg`,role:`group`,"aria-label":`Aspect ratio`,children:Xg.map(t=>{let n=e.activePreset===t.key;return(0,K.jsx)(`button`,{type:`button`,className:`squisq-preview-seg-btn squisq-preview-seg-btn--icon${n?` squisq-preview-seg-btn--active`:``}`,"aria-pressed":n,"aria-label":t.label,title:t.label,onClick:()=>e.setSelectedPreset(t.key),children:(0,K.jsx)(T_,{w:t.w,h:t.h})},t.key)})})}function D_({label:e,labelTooltip:t,value:n,options:r,onChange:i,compact:a}){return(0,K.jsxs)(`div`,{className:`squisq-preview-control${a?` squisq-preview-control--compact`:``}`,children:[(0,K.jsxs)(`label`,{style:d_,title:t,children:[e,`:`]}),(0,K.jsx)(`select`,{value:n,onChange:e=>i(e.target.value),style:p_,children:r.map(e=>(0,K.jsx)(`option`,{value:e.key,children:e.label},e.key))})]})}var O_=new Dr(`squisq-proofing`);function k_(e,t){let n=e.content.size,r=[];for(let e of t)e.from>=e.to||e.to>n||r.push(sr.inline(e.from,e.to,{class:`squisq-proof-underline squisq-proof-underline--${e.category}`,"data-proof-id":e.findingId},{findingId:e.findingId,category:e.category}));return or.create(e,r)}var A_=kr.create({name:`squisqProofing`,addProseMirrorPlugins(){return[new pr({key:O_,state:{init:()=>({decorations:or.empty}),apply:(e,t)=>{let n=e.getMeta(O_);return n?{decorations:k_(e.doc,n.findings)}:e.docChanged?{decorations:t.decorations.map(e.mapping,e.doc)}:t}},props:{decorations:e=>O_.getState(e)?.decorations??null}})]}});function j_(e,t){e.view.dispatch(e.state.tr.setMeta(O_,{findings:t}))}function M_(e){j_(e,[])}function N_(e,t){let n=O_.getState(e)?.decorations;if(!n)return null;let r=n.find(t,t)[0];if(!r)return null;let i=r.spec;return{findingId:i.findingId,category:i.category,from:r.from,to:r.to}}function P_(e,t){let n=O_.getState(e)?.decorations;if(!n)return null;let r=n.find(void 0,void 0,e=>e.findingId===t)[0];if(!r)return null;let i=r.spec;return{findingId:i.findingId,category:i.category,from:r.from,to:r.to}}function F_(e){let t=[];return e.descendants((e,n)=>{if(e.type.name===`codeBlock`)return!1;if(!e.isTextblock)return!0;let r=[],i=``;return e.descendants((e,t)=>{if(e.isText&&e.text){let a=i.length;i+=e.text,r.push({from:a,to:i.length,docFrom:n+1+t})}else e.isInline&&(i+=e.type.name===`hardBreak`?`
|
|
341
|
+
`:`\0`);return!0}),t.push({text:i,spans:r}),!1}),t}function I_(e,t,n){if(n<=t)return null;let r=e.spans.find(e=>t>=e.from&&t<e.to),i=n-1,a=e.spans.find(e=>i>=e.from&&i<e.to);return!r||!a?null:{from:r.docFrom+(t-r.from),to:a.docFrom+(n-a.from)}}var L_={spelling:`Spelling`,grammar:`Grammar`,style:`Style`};function R_(e){return e.kind===`remove`?`Remove`:e.kind===`insertAfter`?`Insert \u201C${e.text}\u201D after`:e.text}function z_(e,t){return e.suggestions.slice(0,t).map(R_)}function B_(e,t=3){let n=[`**${L_[e.category]}**`,``,V_(e.message)],r=z_(e,t);if(r.length>0){let t=r.map(e=>`\u201C${e}\u201D`).join(`, `),i=e.suggestions.length-r.length;n.push(``,`Suggested: ${t}${i>0?` (+${i} more)`:``}`)}return n.join(`
|
|
342
|
+
`)}function V_(e){return e.replace(/([\\`*_[\]<>])/g,`\\$1`)}function H_(e){return{inlineClassName:`squisq-proof-underline squisq-proof-underline--${e.category}`,hoverMessage:{value:B_(e)},stickiness:1}}function U_(e,t){return t.map(t=>{let n=e.getPositionAt(t.start),r=e.getPositionAt(t.end);return{range:{startLineNumber:n.lineNumber,startColumn:n.column,endLineNumber:r.lineNumber,endColumn:r.column},options:H_(t)}})}function W_(e,t,n){for(let r=0;r<t;r+=1){let t=e.getRange(r);if(!t)continue;let i=n.lineNumber>t.startLineNumber||n.lineNumber===t.startLineNumber&&n.column>=t.startColumn,a=n.lineNumber<t.endLineNumber||n.lineNumber===t.endLineNumber&&n.column<=t.endColumn;if(i&&a)return r}return null}var G_=`\0`,K_=450,q_=300,J_=260,Y_=new WeakMap;function X_(e,t){return e.category===`spelling`?t.spelling:t.grammar}function Z_(){let{proofing:e,proofingDefaultEnabled:t,proofingSpellingEnabled:n,proofingGrammarEnabled:r,proofingIgnoreStore:i,articleId:a,fileName:o,markdownSource:s,setMarkdownSource:c,markdownDoc:l,activeView:u,editorMode:d,tiptapEditor:f,monacoEditor:p,versioning:m,saveVersion:h}=Lp(),[g,_]=(0,G.useState)(`idle`),[v,y]=(0,G.useState)(null),[b,x]=(0,G.useState)(null),[S,C]=(0,G.useState)(!1),[w,T]=(0,G.useState)([]),[E,D]=(0,G.useState)(`wysiwyg`),[O,k]=(0,G.useState)(null),[A,j]=(0,G.useState)(null),[M,N]=(0,G.useState)(null),[P,F]=(0,G.useState)(0),I=(0,G.useRef)(null),L=(0,G.useRef)(!1),ee=(0,G.useRef)(`idle`);ee.current=g;let te=(0,G.useRef)(void 0),R=(0,G.useRef)(0),ne=(0,G.useRef)(!1),re=(0,G.useRef)(!1),z=(0,G.useRef)(null),ie=(0,G.useRef)([]),ae=(0,G.useRef)([]),oe=(0,G.useRef)(void 0),se=(0,G.useRef)(void 0),ce=(0,G.useRef)(null),le=(0,G.useRef)(!1),B=(0,G.useMemo)(()=>an(l?.frontmatter),[l]),ue=n||r,V=e!=null&&d===`markdown`&&ue&&(b??B.enabled??t),de=B.enabled;(0,G.useEffect)(()=>{x(null)},[de]);let fe=(0,G.useRef)(V);fe.current=V;let H=(0,G.useRef)({spelling:n,grammar:r});H.current={spelling:n,grammar:r};let pe=(0,G.useRef)(u);pe.current=u;let me=(0,G.useRef)(f);me.current=f;let U=(0,G.useRef)(p);U.current=p;let he=(0,G.useCallback)(()=>e?(I.current||(typeof e==`function`?(I.current=e(),L.current=!0):(I.current=e,L.current=!1)),I.current):null,[e]),ge=(0,G.useMemo)(()=>({articleId:a,fileName:o}),[a,o]),_e=`${a}\0${o??``}`,W=(0,G.useRef)(ge);W.current=ge;let ve=(0,G.useRef)(_e);ve.current=_e;let ye=(0,G.useRef)(i);ye.current=i;let be=(0,G.useCallback)(async()=>{let e=I.current;if(!e)return;let t=ve.current;if(Y_.get(e)!==t){Y_.set(e,t);try{await e.clearIgnored();let t=await ye.current?.load(W.current);t&&await e.importIgnored(t)}catch(t){Y_.delete(e),console.warn(`squisq proofing: could not restore ignored findings`,t instanceof Error?t.message:t)}}},[]),xe=(0,G.useRef)(be);xe.current=be;let Se=(0,G.useCallback)(()=>{let e=me.current;e&&!e.isDestroyed&&M_(e),z.current?.clear(),ie.current=[],ae.current=[]},[]),Ce=(0,G.useCallback)(async()=>{let e=I.current;if(!e||ee.current!==`ready`||!fe.current)return;if(ne.current){re.current=!0;return}ne.current=!0;let t=++R.current;try{if(await xe.current(),t!==R.current)return;let n=pe.current;if(n===`wysiwyg`){let n=me.current;if(!n||n.isDestroyed)return;let r=n.state.doc,i=F_(r),a=i.map(e=>Kt(e.text)),o=Pn(a.map(e=>e.text)),s=await e.lint(o.text,{language:`plaintext`});if(t!==R.current||n.isDestroyed)return;if(n.state.doc!==r){re.current=!0;return}let c=[],l=[];for(let e of s){if(!X_(e,H.current))continue;let t=qt(o,e.start,e.end);if(!t||a[t.segmentIndex].blanked.some(e=>t.start<e.end&&t.end>e.start)||e.originalText.includes(G_))continue;let n=I_(i[t.segmentIndex],t.start,t.end);n&&(c.push({findingId:e.id,from:n.from,to:n.to,category:e.category}),l.push(e))}ae.current=c,j_(n,c),T(l),D(`wysiwyg`)}else if(n===`raw`){let n=U.current,r=n?.getModel();if(!n||!r)return;let i=r.getVersionId(),{text:a,blanked:o}=Kt(r.getValue()),s=await e.lint(a,{language:`markdown`});if(t!==R.current||U.current!==n||n.getModel()!==r)return;if(r.getVersionId()!==i){re.current=!0;return}let c=s.filter(e=>X_(e,H.current)&&!o.some(t=>e.start<t.end&&e.end>t.start));z.current||=n.createDecorationsCollection([]),z.current.set(U_(r,c)),ie.current=c.map(e=>e.id),T(c),D(`raw`)}}catch(e){t===R.current&&console.warn(`squisq proofing: lint pass failed`,e instanceof Error?e.message:e)}finally{ne.current=!1,re.current&&(re.current=!1,window.setTimeout(()=>void Ce(),0))}},[]),we=(0,G.useCallback)(e=>{window.clearTimeout(te.current),e===`immediate`?Ce():te.current=window.setTimeout(()=>void Ce(),K_)},[Ce]),Te=l!=null;(0,G.useEffect)(()=>{if(!V||!Te||ee.current===`ready`)return;let e=he();if(!e)return;let t=!1;return _(`loading`),y(null),e.setup().then(async()=>{t||(B.dictionary.length>0&&await e.addWords(B.dictionary),B.dialect&&await e.setDialect(B.dialect),await xe.current(),!t&&_(`ready`))}).catch(e=>{t||(_(`error`),y(e instanceof Error?e.message:String(e)))}),()=>{t=!0}},[V,Te,he,P]),(0,G.useEffect)(()=>{g===`ready`&&V&&we(`immediate`)},[g,V,we]);let Ee=`${n}:${r}`,De=(0,G.useRef)(Ee);(0,G.useEffect)(()=>{De.current!==Ee&&(De.current=Ee,Se(),T([]),k(null),g===`ready`&&V&&we(`immediate`))},[Ee,g,V,we,Se]);let Oe=(0,G.useRef)(u);(0,G.useEffect)(()=>{if(g!==`ready`||!V)return;let e=Oe.current!==u;Oe.current=u,!(u!==`wysiwyg`&&u!==`raw`)&&(e?(Se(),T([]),k(null),we(`immediate`)):we(`debounced`))},[s,u,g,V,we,Se]),(0,G.useEffect)(()=>{z.current=null,ie.current=[],g===`ready`&&V&&u===`raw`&&p&&we(`immediate`)},[p]);let ke=B.dictionary.join(`
|
|
343
|
+
`),Ae=(0,G.useRef)(ke);(0,G.useEffect)(()=>{if(g!==`ready`||ke===Ae.current)return;Ae.current=ke;let e=I.current;!e||B.dictionary.length===0||e.addWords(B.dictionary).then(()=>we(`immediate`)).catch(()=>void 0)},[ke,g]);let je=(0,G.useRef)(B.dialect);(0,G.useEffect)(()=>{if(g!==`ready`||B.dialect===je.current)return;je.current=B.dialect;let e=I.current;!e||!B.dialect||e.setDialect(B.dialect).then(()=>we(`immediate`)).catch(()=>void 0)},[B.dialect,g]),(0,G.useEffect)(()=>{V||(window.clearTimeout(te.current),R.current+=1,re.current=!1,Se(),T([]),k(null),j(null))},[V,Se]),(0,G.useEffect)(()=>()=>{window.clearTimeout(te.current),R.current+=1,L.current&&I.current?.dispose()},[]),(0,G.useEffect)(()=>{if(!f||f.isDestroyed)return;let e=f.view.dom;if(V&&g===`ready`)return e.setAttribute(`spellcheck`,`false`),()=>e.removeAttribute(`spellcheck`)},[f,V,g]);let Me=(0,G.useRef)(()=>void 0);(0,G.useEffect)(()=>{if(!V||g!==`ready`)return;let e=f;if(!e||e.isDestroyed)return;let t=e.view.dom,n=t=>{let n=e.view.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return;let r=N_(e.state,n.pos);r&&(t.preventDefault(),Me.current({findingId:r.findingId,x:t.clientX,y:t.clientY}))},r=t=>{if(t.key!==`ContextMenu`&&!(t.shiftKey&&t.key===`F10`))return;let n=e.state.selection.head,r=N_(e.state,n);if(!r)return;t.preventDefault();let i=e.view.coordsAtPos(n);Me.current({findingId:r.findingId,x:i.left,y:i.bottom})};return t.addEventListener(`contextmenu`,n),t.addEventListener(`keydown`,r),()=>{t.removeEventListener(`contextmenu`,n),t.removeEventListener(`keydown`,r)}},[f,V,g]);let Ne=(0,G.useCallback)(()=>{oe.current!==void 0&&window.clearTimeout(oe.current),se.current!==void 0&&window.clearTimeout(se.current),oe.current=void 0,se.current=void 0},[]),Pe=(0,G.useCallback)(()=>{Ne(),ce.current=null,le.current=!1,N(null)},[Ne]),Fe=(0,G.useCallback)(()=>{oe.current!==void 0&&(window.clearTimeout(oe.current),oe.current=void 0),se.current!==void 0&&window.clearTimeout(se.current),se.current=window.setTimeout(()=>{se.current=void 0,!le.current&&(ce.current=null,N(null))},J_)},[]),Ie=(0,G.useCallback)(()=>{le.current=!0,se.current!==void 0&&(window.clearTimeout(se.current),se.current=void 0)},[]),Le=(0,G.useCallback)(()=>{le.current=!1,Fe()},[Fe]);(0,G.useEffect)(()=>{if(!V||g!==`ready`)return;let e=f;if(!e||e.isDestroyed)return;let t=e.view.dom,n=e=>{let t=e.target?.closest?.(`[data-proof-id]`),n=t?.getAttribute(`data-proof-id`)??null;if(!t||!n){ce.current!==null&&Fe();return}if(n===ce.current){se.current!==void 0&&(window.clearTimeout(se.current),se.current=void 0);return}Ne(),le.current=!1,ce.current=n,N(null),oe.current=window.setTimeout(()=>{oe.current=void 0;let e=t.getBoundingClientRect();N({findingId:n,left:e.left,top:e.top,bottom:e.bottom})},q_)},r=()=>{ce.current!==null&&Fe()};return t.addEventListener(`mousemove`,n),t.addEventListener(`mouseleave`,r),t.addEventListener(`mousedown`,Pe),window.addEventListener(`scroll`,Pe,!0),()=>{t.removeEventListener(`mousemove`,n),t.removeEventListener(`mouseleave`,r),t.removeEventListener(`mousedown`,Pe),window.removeEventListener(`scroll`,Pe,!0),Pe()}},[f,V,g,Ne,Pe,Fe]),(0,G.useEffect)(()=>{if(!V||g!==`ready`)return;let e=p,t=e?.getDomNode();if(!e||!t)return;let n=e=>{let t=z.current;if(!t)return null;let n=W_(t,ie.current.length,e);return n===null?null:ie.current[n]??null},r=t=>{let r=e.getTargetAtClientPoint(t.clientX,t.clientY)?.position;if(!r)return;let i=n(r);i&&(t.preventDefault(),t.stopPropagation(),Me.current({findingId:i,x:t.clientX,y:t.clientY}))},i=r=>{if(r.key!==`ContextMenu`&&!(r.shiftKey&&r.key===`F10`))return;let i=e.getPosition();if(!i)return;let a=n(i);if(!a)return;r.preventDefault(),r.stopPropagation();let o=e.getScrolledVisiblePosition(i),s=t.getBoundingClientRect();Me.current({findingId:a,x:s.left+(o?.left??0),y:s.top+(o?.top??0)+(o?.height??16)})};return t.addEventListener(`contextmenu`,r,!0),t.addEventListener(`keydown`,i,!0),()=>{t.removeEventListener(`contextmenu`,r,!0),t.removeEventListener(`keydown`,i,!0)}},[p,V,g]);let Re=(0,G.useCallback)(e=>w.find(t=>t.id===e)??null,[w]),ze=(0,G.useRef)([]);ze.current=w;let Be=(0,G.useCallback)(e=>{let t=ze.current.filter(t=>t.id!==e);T(t),k(t=>t===e?null:t),j(t=>t?.findingId===e?null:t);let n=me.current;if(n&&!n.isDestroyed&&ae.current.some(t=>t.findingId===e)){let t=[];for(let r of ae.current){if(r.findingId===e)continue;let i=P_(n.state,r.findingId);i&&t.push({findingId:i.findingId,from:i.from,to:i.to,category:i.category})}ae.current=t,j_(n,t)}let r=z.current,i=ie.current.indexOf(e);if(r&&i>=0){let n=new Map(t.map(e=>[e.id,e])),i=[];ie.current.forEach((t,a)=>{let o=n.get(t),s=r.getRange(a);t!==e&&o&&s&&i.push({finding:o,range:s})}),ie.current=i.map(e=>e.finding.id),r.set(i.map(e=>({range:e.range,options:H_(e.finding)})))}},[]),Ve=(0,G.useCallback)(()=>{m&&h({content:s}).catch(()=>{})},[m,h,s]),He=(0,G.useCallback)((e,t)=>{let n=Re(e),r=n?.suggestions[t];if(!(!n||!r)){if(Ve(),E===`wysiwyg`){let t=me.current;if(!t||t.isDestroyed)return;let i=P_(t.state,e);if(!i){we(`immediate`);return}if(t.state.doc.textBetween(i.from,i.to,G_,G_)!==n.originalText){we(`immediate`);return}t.chain().focus().command(({tr:e})=>(r.kind===`remove`?e.delete(i.from,i.to):r.kind===`insertAfter`?e.insertText(r.text,i.to,i.to):e.insertText(r.text,i.from,i.to),!0)).run(),Be(e)}else if(E===`raw`){let t=U.current,i=t?.getModel(),a=z.current,o=ie.current.indexOf(e);if(!t||!i||!a||o<0)return;let s=a.getRange(o);if(!s){we(`immediate`);return}if(i.getValueInRange(s)!==n.originalText){we(`immediate`);return}let c=r.kind===`insertAfter`?{range:{startLineNumber:s.endLineNumber,startColumn:s.endColumn,endLineNumber:s.endLineNumber,endColumn:s.endColumn},text:r.text}:{range:s,text:r.kind===`remove`?``:r.text};t.pushUndoStop(),t.executeEdits(`squisq-proofing`,[c]),t.pushUndoStop(),t.focus(),Be(e)}}},[Re,E,Ve,we,Be]),Ue=(0,G.useCallback)(e=>{let t=I.current;!t||!Re(e)||t.ignoreFinding(e).then(()=>t.exportIgnored()).then(async n=>{Be(e),Y_.set(t,ve.current),await ye.current?.save(W.current,n),we(`immediate`)}).catch(e=>{console.warn(`squisq proofing: ignore failed`,e instanceof Error?e.message:e)})},[Re,Be,we]),Ge=(0,G.useCallback)(e=>Re(e)?.originalText.trim()||null,[Re]),Ke=(0,G.useCallback)(e=>{let t=I.current,n=Ge(e);!t||!n||t.addWord(n).then(()=>{Be(e),we(`immediate`)}).catch(e=>{console.warn(`squisq proofing: add-to-dictionary failed`,e instanceof Error?e.message:e)})},[Ge,Be,we]),qe=(0,G.useCallback)(e=>{let t=I.current,n=Ge(e);!t||!n||t.addWords([n]).then(()=>{Be(e),c(We(s,{[cn.dictionary.canonical]:Jt([...B.dictionary,n])})),we(`immediate`)}).catch(e=>{console.warn(`squisq proofing: add-to-doc-word-list failed`,e instanceof Error?e.message:e)})},[Ge,Be,c,s,B.dictionary,we]),Je=(0,G.useCallback)(e=>{if(k(e),E===`wysiwyg`){let t=me.current;if(!t||t.isDestroyed)return;let n=P_(t.state,e);if(!n)return;t.chain().focus().setTextSelection({from:n.from,to:n.to}).scrollIntoView().run()}else if(E===`raw`){let t=U.current,n=z.current,r=ie.current.indexOf(e);if(!t||!n||r<0)return;let i=n.getRange(r);if(!i)return;t.revealRangeInCenter(i),t.setPosition({lineNumber:i.startLineNumber,column:i.startColumn}),t.focus()}},[E]),Ye=(0,G.useCallback)(e=>{if(w.length===0)return;let t=w.findIndex(e=>e.id===O),n=t<0?e===1?0:w.length-1:(t+e+w.length)%w.length;Je(w[n].id)},[w,O,Je]),Xe=(0,G.useCallback)(e=>x(e),[]),Ze=(0,G.useCallback)(()=>{_(`idle`),F(e=>e+1)},[]),Qe=(0,G.useCallback)(e=>{Pe(),j(e)},[Pe]);Me.current=Qe;let $e=(0,G.useCallback)(()=>j(null),[]),et=(I.current??(typeof e==`function`?null:e))?.hasAppDictionary!==!1;return(0,G.useMemo)(()=>!e||!ue?null:{status:g,errorMessage:v,enabled:V,setEnabled:Xe,panelVisible:S,setPanelVisible:C,findings:w,findingsView:E,activeFindingId:O,selectFinding:Je,nextFinding:()=>Ye(1),prevFinding:()=>Ye(-1),applySuggestion:He,ignoreFinding:Ue,addToAppDictionary:Ke,addToDocWordList:qe,canAddToAppDictionary:et,openMenu:Qe,closeMenu:$e,menuAnchor:A,hoverAnchor:M,closeHover:Pe,holdHover:Ie,releaseHover:Le,retrySetup:Ze},[e,ue,g,v,V,Xe,S,w,E,O,Je,Ye,He,Ue,Ke,qe,et,Qe,$e,A,M,Pe,Ie,Le,Ze])}var Q_=5;function $_(e,t){let n=t?.getBoundingClientRect(),r=n?.width??220,i=n?.height??160,a=window.innerWidth,o=window.innerHeight,s=e.y+4;s+i+8>o&&e.y-i-4>=8&&(s=e.y-i-4);let c=Math.min(Math.max(8,e.x),Math.max(8,a-r-8));return{position:`fixed`,top:s,left:c,zIndex:9999}}function ev({anchor:e,finding:t,colorScheme:n,onApply:r,onIgnore:i,onAddToAppDictionary:a,onAddToDocWordList:o,canAddToAppDictionary:s,onClose:c}){let l=(0,G.useRef)(null),[u,d]=(0,G.useState)(()=>$_(e)),[f,p]=(0,G.useState)(0);(0,G.useEffect)(()=>{requestAnimationFrame(()=>d($_(e,l.current)))},[e]),Dh(!0,c),(0,G.useEffect)(()=>{let e=e=>{l.current?.contains(e.target)||c()},t=()=>c(),n=requestAnimationFrame(()=>document.addEventListener(`mousedown`,e));return window.addEventListener(`scroll`,t,!0),window.addEventListener(`resize`,t),()=>{cancelAnimationFrame(n),document.removeEventListener(`mousedown`,e),window.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,t)}},[c]);let m=t.suggestions.slice(0,Q_),h=t.category===`spelling`,g=[...m.map((e,n)=>({key:`s${n}`,label:R_(t.suggestions[n]),run:()=>r(n),className:`squisq-proof-menu-suggestion`})),{key:`ignore`,label:`Ignore`,run:i},...h&&s?[{key:`add-app`,label:`Add to dictionary`,run:a}]:[],...h?[{key:`add-doc`,label:`Add to document word list`,run:o}]:[]];return(0,G.useEffect)(()=>{(l.current?.querySelectorAll(`[role="menuitem"]`))?.[f]?.focus()},[f]),(0,Wr.createPortal)((0,K.jsxs)(`div`,{ref:l,className:`squisq-proof-menu`,"data-theme":n,role:`menu`,"aria-label":`Proofing suggestions`,style:u,onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),p(e=>(e+1)%g.length)):e.key===`ArrowUp`&&(e.preventDefault(),p(e=>(e-1+g.length)%g.length))},children:[(0,K.jsxs)(`div`,{className:`squisq-proof-menu-header`,children:[(0,K.jsx)(`span`,{className:`squisq-proof-dot squisq-proof-dot--${t.category}`,"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`squisq-proof-menu-message`,children:t.message})]}),g.map((e,t)=>(0,K.jsx)(`button`,{type:`button`,role:`menuitem`,tabIndex:t===f?0:-1,className:`squisq-proof-menu-item ${e.className??``}`.trim(),onMouseDown:e=>e.preventDefault(),onClick:e.run,children:e.label},e.key)),m.length===0&&(0,K.jsx)(`div`,{className:`squisq-proof-menu-empty`,children:`No suggestions`})]}),document.body)}var tv=3;function nv(e,t){let n=t?.getBoundingClientRect(),r=n?.width??240,i=n?.height??72,a=e.bottom+6;a+i+8>window.innerHeight&&e.top-i-6>=8&&(a=e.top-i-6);let o=Math.min(Math.max(8,e.left),Math.max(8,window.innerWidth-r-8));return{position:`fixed`,top:a,left:o,zIndex:9998}}function rv({anchor:e,finding:t,colorScheme:n,onApply:r,onIgnore:i,onAddToAppDictionary:a,onAddToDocWordList:o,canAddToAppDictionary:s,onMore:c,onHold:l,onRelease:u}){let d=(0,G.useRef)(null),[f,p]=(0,G.useState)(()=>nv(e));(0,G.useLayoutEffect)(()=>{p(nv(e,d.current))},[e,t.id]);let m=t.suggestions.slice(0,tv),h=t.suggestions.length-m.length,g=t.category===`spelling`;return(0,Wr.createPortal)((0,K.jsxs)(`div`,{ref:d,className:`squisq-proof-tooltip`,"data-theme":n,"data-proof-tooltip-id":t.id,role:`group`,"aria-label":`${L_[t.category]} suggestion`,style:f,onMouseEnter:l,onMouseLeave:u,onMouseDown:e=>e.preventDefault(),children:[(0,K.jsxs)(`div`,{className:`squisq-proof-tooltip-head`,children:[(0,K.jsx)(`span`,{className:`squisq-proof-dot squisq-proof-dot--${t.category}`,"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`squisq-proof-tooltip-category`,children:L_[t.category]})]}),(0,K.jsx)(`div`,{className:`squisq-proof-tooltip-message`,children:t.message}),m.length>0&&(0,K.jsxs)(`div`,{className:`squisq-proof-tooltip-suggestions`,children:[m.map((e,t)=>(0,K.jsx)(`button`,{type:`button`,className:`squisq-proof-tooltip-chip`,onClick:()=>r(t),children:R_(e)},`${t}-${e.kind}-${e.text}`)),h>0&&(0,K.jsxs)(`button`,{type:`button`,className:`squisq-proof-tooltip-more`,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();c(t.left,t.bottom)},children:[`+`,h,` more`]})]}),(0,K.jsxs)(`div`,{className:`squisq-proof-tooltip-actions`,children:[(0,K.jsx)(`button`,{type:`button`,className:`squisq-proof-tooltip-action`,onClick:i,children:`Ignore`}),g&&s&&(0,K.jsx)(`button`,{type:`button`,className:`squisq-proof-tooltip-action`,onClick:a,children:`Add to dictionary`}),g&&(0,K.jsx)(`button`,{type:`button`,className:`squisq-proof-tooltip-action`,onClick:o,children:`Add to document word list`})]})]}),document.body)}var iv=(0,G.createContext)(null);function av(){return(0,G.useContext)(iv)}function ov({children:e}){let{colorScheme:t}=Lp(),n=Z_(),r=n?.menuAnchor==null?null:n.findings.find(e=>e.id===n.menuAnchor?.findingId)??null,i=n?.hoverAnchor!=null&&!n.menuAnchor?n.findings.find(e=>e.id===n.hoverAnchor?.findingId)??null:null;return(0,K.jsxs)(iv.Provider,{value:n,children:[e,n&&n.menuAnchor&&r&&(0,K.jsx)(ev,{anchor:n.menuAnchor,finding:r,colorScheme:t,onApply:e=>{n.applySuggestion(r.id,e),n.closeMenu()},onIgnore:()=>{n.ignoreFinding(r.id),n.closeMenu()},onAddToAppDictionary:()=>{n.addToAppDictionary(r.id),n.closeMenu()},onAddToDocWordList:()=>{n.addToDocWordList(r.id),n.closeMenu()},canAddToAppDictionary:n.canAddToAppDictionary,onClose:n.closeMenu}),n&&n.hoverAnchor&&i&&(0,K.jsx)(rv,{anchor:n.hoverAnchor,finding:i,colorScheme:t,onApply:e=>{n.applySuggestion(i.id,e),n.closeHover()},onIgnore:()=>{n.ignoreFinding(i.id),n.closeHover()},onAddToAppDictionary:()=>{n.addToAppDictionary(i.id),n.closeHover()},onAddToDocWordList:()=>{n.addToDocWordList(i.id),n.closeHover()},canAddToAppDictionary:n.canAddToAppDictionary,onMore:(e,t)=>n.openMenu({findingId:i.id,x:e,y:t}),onHold:n.holdHover,onRelease:n.releaseHover})]})}function sv(){let{inlinePreviewVisible:e,setInlinePreviewVisible:t,statusBarVisible:n,setStatusBarVisible:r,outlineVisible:i,setOutlineVisible:a,blockTagVisibility:o,setBlockTagVisibility:s,themeInheritance:c,setThemeInheritance:l,layoutMode:u,setLayoutMode:d}=Lp(),f=av(),[p,m]=(0,G.useState)(!1),h=(0,G.useRef)(null),g=(0,G.useRef)(null);Dh(p,(0,G.useCallback)(()=>m(!1),[]),g),(0,G.useEffect)(()=>{if(!p)return;let e=e=>{h.current&&!h.current.contains(e.target)&&m(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[p]);let _=(0,G.useCallback)(()=>{t(!e)},[e,t]),v=(0,G.useCallback)(()=>{r(!n)},[n,r]),y=(0,G.useCallback)(()=>{a(!i)},[i,a]);return(0,K.jsxs)(`div`,{className:`squisq-view-menu`,ref:h,children:[(0,K.jsx)(`button`,{ref:g,type:`button`,className:`squisq-toolbar-button squisq-view-menu-trigger${p?` squisq-toolbar-button--active`:``}`,"data-tooltip":`View options`,"aria-label":`View options`,"aria-expanded":p,"aria-haspopup":`menu`,onClick:()=>m(e=>!e),children:(0,K.jsx)(q,{icon:`fa-solid fa-eye`})}),p&&(0,K.jsxs)(`div`,{className:`squisq-view-menu-popover`,role:`menu`,"aria-label":`View options`,children:[(0,K.jsx)(lv,{label:`View`,value:u,onChange:e=>d(e),options:[{value:`document`,label:`Document`},{value:`block`,label:`Block-at-a-time`},{value:`timeline`,label:`Timeline`}]}),(0,K.jsx)(`div`,{className:`squisq-view-menu-separator`,role:`separator`}),(0,K.jsx)(cv,{label:`Show outline`,checked:i,onChange:y}),(0,K.jsx)(cv,{label:`Show block previews`,checked:e,onChange:_}),(0,K.jsx)(lv,{label:`Show block tags`,value:o,onChange:e=>s(e),options:[{value:`none`,label:`No inline block tags`},{value:`active`,label:`Selected/hovered block`},{value:`always`,label:`Always show`}]}),(0,K.jsx)(cv,{label:`Show status bar`,checked:n,onChange:v}),f&&(0,K.jsx)(cv,{label:`Check spelling & grammar`,checked:f.enabled,onChange:()=>f.setEnabled(!f.enabled)}),(0,K.jsx)(`div`,{className:`squisq-view-menu-separator`,role:`separator`}),(0,K.jsx)(lv,{label:`Editor styling from theme`,value:c,onChange:e=>l(e),options:[{value:`none`,label:`Don't inherit`},{value:`fonts`,label:`Fonts only`},{value:`fonts-colors`,label:`Fonts & colors`}]})]})]})}function cv({label:e,checked:t,onChange:n}){return(0,K.jsxs)(`label`,{className:`squisq-view-menu-row`,role:`menuitemcheckbox`,"aria-checked":t,children:[(0,K.jsx)(`input`,{type:`checkbox`,className:`squisq-view-menu-checkbox`,checked:t,onChange:n}),(0,K.jsx)(`span`,{className:`squisq-view-menu-label`,children:e})]})}function lv({label:e,value:t,onChange:n,options:r}){let i=(0,G.useId)();return(0,K.jsxs)(`div`,{className:`squisq-view-menu-row squisq-view-menu-row--radios`,role:`radiogroup`,"aria-label":e,children:[(0,K.jsx)(`span`,{className:`squisq-view-menu-label`,children:e}),r.map(e=>{let r=e.value===t;return(0,K.jsxs)(`label`,{className:`squisq-view-menu-radio-row`,role:`menuitemradio`,"aria-checked":r,children:[(0,K.jsx)(`input`,{type:`radio`,className:`squisq-view-menu-radio`,name:i,value:e.value,checked:r,onChange:()=>n(e.value)}),(0,K.jsx)(`span`,{className:`squisq-view-menu-radio-label`,children:e.label})]},e.value)})]})}var uv=[60,80,100,120];function dv({id:e}){return e===`unwrap`?(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,"data-transform-icon":`unwrap`,children:[(0,K.jsx)(`path`,{d:`M5 3.5h9.5L19 8v12.5H5z`}),(0,K.jsx)(`path`,{d:`M14.5 3.5V8H19`}),(0,K.jsx)(`path`,{d:`M7.8 11.2h8.4M7.8 14.6h8.4M7.8 18h8.4`})]}):e===`wrap`?(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,"data-transform-icon":`wrap`,children:[(0,K.jsx)(`path`,{d:`M5 3.5h9.5L19 8v12.5H5z`}),(0,K.jsx)(`path`,{d:`M14.5 3.5V8H19`}),(0,K.jsx)(`path`,{d:`M12.7 9.7v1.4m0 1.5V14m0 1.5v1.4m0 1.5v1.1`,strokeDasharray:`1 1.5`}),(0,K.jsx)(`path`,{d:`M7.8 11.2h3.1M7.8 14.6h3.1M7.8 18h3.1`})]}):(0,K.jsx)(q,{icon:`fa-solid fa-wand-magic-sparkles`})}function fv(){let{editorMode:e,layoutMode:t,activeView:n,markdownSource:r,setMarkdownSource:i,monacoEditor:a,versioning:o,saveVersion:s}=Lp(),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(80),[f,p]=(0,G.useState)(``),m=(0,G.useRef)(null),h=(0,G.useRef)(null);Dh(c,(0,G.useCallback)(()=>l(!1),[]),h),(0,G.useEffect)(()=>{if(!c)return;let e=e=>{m.current&&!m.current.contains(e.target)&&l(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[c]),(0,G.useEffect)(()=>{c&&p(``)},[c]);let g=(0,G.useMemo)(()=>c?It(r):null,[c,r]),_=n===`preview`,v=t!==`document`,y=_||v,b=v?`Transforms apply to the whole document — switch to the Document layout first.`:_?`Switch to Write or Source view to apply (transforms are undoable there).`:null,x=(0,G.useCallback)(e=>{let t=e===`wrap`?{width:u}:void 0;o&&s({content:r}).catch(()=>{});let c=(e,t)=>{p(e?`Transformed.`:t?`Could not safely transform — document left unchanged.`:`No changes needed.`)};if(n===`raw`&&a){let n=a.getModel();if(n){let r=Mt(e,n.getValue(),t);if(r.changed){let e=r.edits.map(e=>{let t=n.getPositionAt(e.start),r=n.getPositionAt(e.end);return{range:{startLineNumber:t.lineNumber,startColumn:t.column,endLineNumber:r.lineNumber,endColumn:r.column},text:e.text}});a.pushUndoStop(),a.executeEdits(`squisq-transform`,e),a.pushUndoStop()}c(r.changed,r.degraded);return}}let l=Mt(e,r,t);l.changed&&i(l.output),c(l.changed,l.degraded)},[n,r,a,s,i,o,u]);if(e!==`markdown`)return null;let S=g===null?null:g.kind===`wrapped`?`Detected mode: wrapped at ~${g.width} characters wide`:g.kind===`unwrapped`?`Detected mode: unwrapped`:g.kind===`mixed`?`Detected mode: mixed wrapping`:`Detected mode: no prose to judge`,C=g?.kind===`wrapped`?`wrap`:g?.kind===`unwrapped`?`unwrap`:null,w=g?.kind===`wrapped`?`Current (~${g.width} characters wide)`:`Current`;return(0,K.jsxs)(`div`,{className:`squisq-transform-menu`,ref:m,children:[(0,K.jsx)(`button`,{ref:h,type:`button`,className:`squisq-toolbar-button squisq-transform-menu-trigger${c?` squisq-toolbar-button--active`:``}`,"data-tooltip":`Transform`,"aria-label":`Transform document`,"aria-expanded":c,"aria-haspopup":`dialog`,onClick:()=>l(e=>!e),children:(0,K.jsx)(q,{icon:`fa-solid fa-wand-magic-sparkles`})}),c&&(0,K.jsxs)(`div`,{className:`squisq-transform-menu-popover`,role:`dialog`,"aria-label":`Transform document`,children:[S&&(0,K.jsx)(`div`,{className:`squisq-transform-menu-state`,children:S}),Lt.map(e=>{let t=e.id===C;return(0,K.jsxs)(`div`,{className:`squisq-transform-menu-item`,children:[(0,K.jsxs)(`button`,{type:`button`,className:`squisq-transform-menu-action${t?` squisq-transform-menu-action--current`:``}`,"aria-current":t?`true`:void 0,disabled:y,onClick:()=>x(e.id),children:[(0,K.jsx)(`span`,{className:`squisq-transform-menu-action-icon`,"aria-hidden":`true`,children:(0,K.jsx)(dv,{id:e.id})}),(0,K.jsxs)(`span`,{className:`squisq-transform-menu-action-copy`,children:[(0,K.jsxs)(`span`,{className:`squisq-transform-menu-action-heading`,children:[(0,K.jsx)(`span`,{className:`squisq-transform-menu-action-label`,children:e.label}),t&&(0,K.jsx)(`span`,{className:`squisq-transform-menu-current-badge`,children:w})]}),(0,K.jsx)(`span`,{className:`squisq-transform-menu-action-desc`,children:e.description})]})]}),e.id===`wrap`&&(0,K.jsxs)(`div`,{className:`squisq-transform-menu-widths`,"aria-label":`Wrap width`,children:[uv.map(e=>(0,K.jsx)(`button`,{type:`button`,className:`squisq-transform-menu-width${u===e?` squisq-transform-menu-width--active`:``}`,disabled:y,onClick:()=>d(e),children:e},e)),(0,K.jsx)(`input`,{type:`number`,className:`squisq-transform-menu-width-input`,"aria-label":`Custom wrap width`,min:20,max:500,value:u,disabled:y,onChange:e=>{let t=Number(e.target.value);Number.isNaN(t)||d(t)}})]})]},e.id)}),b&&(0,K.jsx)(`div`,{className:`squisq-transform-menu-note`,children:b}),(0,K.jsx)(`div`,{className:`squisq-transform-menu-status`,role:`status`,"aria-live":`polite`,children:f})]})]})}var pv=`squisq:custom-template-library`;function mv(){try{return typeof globalThis<`u`&&globalThis.localStorage?globalThis.localStorage:null}catch{return null}}function hv(){let e=mv();if(!e)return{version:1,templates:[]};try{let t=e.getItem(pv);if(!t)return{version:1,templates:[]};let n=JSON.parse(t);if(n&&Array.isArray(n.templates))return{version:1,templates:n.templates.filter(Ze)}}catch{}return{version:1,templates:[]}}function gv(e){let t=mv();if(t)try{t.setItem(pv,JSON.stringify(e))}catch{}}function _v(){let{templates:e}=hv();return e.slice().sort((e,t)=>e.label.localeCompare(t.label))}function vv(e){let t=hv(),n=t.templates.findIndex(t=>t.name===e.name);return n>=0?t.templates[n]=e:t.templates.push(e),gv(t),t.templates.slice().sort((e,t)=>e.label.localeCompare(t.label))}function yv(e){let t=hv();return t.templates=t.templates.filter(t=>t.name!==e),gv(t),t.templates.slice().sort((e,t)=>e.label.localeCompare(t.label))}var bv=(0,G.createContext)(null);function xv({docTemplates:e,onDocTemplatesChange:t,children:n}){let[r,i]=(0,G.useState)(()=>_v());(0,G.useEffect)(()=>{i(_v());let e=e=>{e.key===pv&&i(_v())};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]);let a=(0,G.useCallback)(n=>{let r=e.findIndex(e=>e.name===n.name);t(r>=0?e.map((e,t)=>t===r?n:e):[...e,n])},[e,t]),o=(0,G.useCallback)(n=>{let r=e.filter(e=>e.name!==n);r.length!==e.length&&t(r)},[e,t]),s=(0,G.useCallback)(e=>{i(vv(e))},[]),c=(0,G.useCallback)(e=>{i(yv(e))},[]),l=(0,G.useCallback)(t=>{let n=e.find(e=>e.name===t.name);return n||a(t),n??t},[e,a]),u=(0,G.useMemo)(()=>{let t=new Set(e.map(e=>e.name));return[...e,...r.filter(e=>!t.has(e.name))]},[e,r]),d=(0,G.useMemo)(()=>({docTemplates:e,libraryTemplates:r,allTemplates:u,upsertDocTemplate:a,upsertLibraryTemplate:s,removeDocTemplate:o,removeLibraryTemplate:c,applyTemplate:l}),[e,r,u,a,s,o,c,l]);return(0,K.jsx)(bv.Provider,{value:d,children:n})}function Sv(){return(0,G.useContext)(bv)}function Cv({layer:e,viewport:t,blockTime:n=0,basePath:r=``}){switch(e.type){case`image`:return(0,K.jsx)(Zt,{layer:e,viewport:t,blockTime:n,basePath:r});case`text`:return(0,K.jsx)(kn,{layer:e,viewport:t,blockTime:n});case`shape`:return(0,K.jsx)(Xt,{layer:e,viewport:t,blockTime:n});case`path`:return(0,K.jsx)(dn,{layer:e,viewport:t,blockTime:n});case`video`:return(0,K.jsx)($t,{layer:e,viewport:t,blockTime:n,basePath:r});case`map`:return(0,K.jsx)(ln,{layer:e,viewport:t,blockTime:n,basePath:r});case`table`:return(0,K.jsx)(en,{layer:e,viewport:t,blockTime:n});default:return null}}var wv=56,Tv=40;function Ev({def:e,width:t=wv,height:n=Tv}){return(0,K.jsxs)(`svg`,{width:t,height:n,viewBox:`0 0 ${e.viewport.width} ${e.viewport.height}`,preserveAspectRatio:`xMidYMid meet`,className:`squisq-template-thumbnail`,"aria-hidden":`true`,children:[(0,K.jsx)(`rect`,{width:e.viewport.width,height:e.viewport.height,fill:`#f8fafc`}),e.layers.map(t=>(0,K.jsx)(`g`,{children:(0,K.jsx)(Cv,{layer:t,viewport:e.viewport})},t.id)),(0,K.jsx)(`rect`,{x:0,y:0,width:e.viewport.width,height:e.viewport.height,fill:`none`,stroke:`#cbd5e1`,strokeWidth:2,vectorEffect:`non-scaling-stroke`})]})}var Dv=/(?:[$\u20ac\u00a3\u00a5]\s?\d+(?:[.,]\d+)*(?:\s?(?:[MBK]|million|billion|thousand))?|\d+(?:[.,]\d+)*\s?(?:%|\u2030|x|\u00d7|[MBK]|million|billion|thousand|percent|years?|days?|hours?)|\d{3,}(?:[.,]\d+)*)/i,Ov=/\b(?:\d{4}-\d{2}-\d{2}|\d{1,2}\/\d{1,2}\/\d{2,4}|Q[1-4]\s+\d{4}|\d{4}s|(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Sept|Oct|Nov|Dec)[a-z]*\.?\s+\d{1,2},?\s+\d{4}|\d{1,2}\s+(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Sept|Oct|Nov|Dec)[a-z]*\.?\s+\d{4})\b/i,kv=/\.(?:aac|flac|m4a|m4v|mkv|mov|mp3|mp4|oga|ogg|ogv|opus|wav|webm)(?:$|[?#\s"'<>),])/i,Av=/<\/?(?:audio|source|video)\b/i,jv=/^(?:audio|video)\//i;function Mv(e,t){let{block:n,theme:r,viewport:i}=t,a=zv(n),o=ke(n.contents),s=n.template===e,c=s&&(n.templateData&&Object.keys(n.templateData).length>0||n.templateOverrides&&Object.keys(n.templateOverrides).length>0),{inputs:l,warning:u}=Nv(e,n,a,o);if(!l&&!c)return{visual:null,warning:u};let d={...n,id:`template-preview-${n.id}-${e}`,template:e,title:a||n.title||e,duration:1,audioSegment:0,layers:void 0,templateData:s?n.templateData:void 0,templateOverrides:s?n.templateOverrides:void 0,...l??{}},f={blockIndex:0,totalBlocks:1,theme:r,viewport:i,customTemplates:t.customTemplates};try{let e=Ce(d,f),{layers:t}=e;return t.length===0?{visual:null,warning:u}:{visual:{...d,layers:t},warning:u??e.diagnostic?.message}}catch{return{visual:null,warning:u}}}function Nv(e,t,n,r){let i=t.contents,a=[n,r].filter(Boolean).join(`
|
|
344
|
+
`);switch(e){case`title`:return{inputs:a?{title:n||Bv(r)||`Untitled`,...n&&r?{subtitle:r}:{}}:null};case`sectionHeader`:{if(!a)return{inputs:null};let e=be(i,1)[0];return{inputs:{title:n||Bv(r)||`Untitled`,...e?{imageSrc:e.src,imageAlt:e.alt||n}:{}}}}case`statHighlight`:return Dv.test(a)?{inputs:L(e,n,i,{placeholders:!1})}:{inputs:null,warning:`No stat found in this block`};case`quote`:case`fullBleedQuote`:return{inputs:ce(i)||r?L(e,n,i,{placeholders:!1}):null};case`pullQuote`:return{inputs:Pv(t,n,r),...be(i,1).length===0?{warning:`No image found in this block`}:{}};case`factCard`:case`definitionCard`:return{inputs:n&&r?L(e,n,i,{placeholders:!1}):null};case`twoColumn`:return{inputs:Fv(t,n,r)};case`dateEvent`:return Ov.test(a)?{inputs:L(e,n,i,{placeholders:!1})}:{inputs:null,warning:`No date found in this block`};case`comparisonBar`:{let e=Iv(t);return{inputs:e,...e?{}:{warning:`No stat found in this block`}}}case`imageWithCaption`:case`leftFeature`:case`rightFeature`:case`photoGrid`:{let t=be(i,e===`photoGrid`?2:1).length,r=e===`photoGrid`?t<2:t===0;return{inputs:r?null:L(e,n,i,{placeholders:!1}),...r?{warning:`No image found in this block`}:{}}}case`map`:return{inputs:null};case`videoWithCaption`:case`videoPullQuote`:return{inputs:null,...Rv(i)?{}:{warning:`No audio/video found in this block`}};case`diagram`:case`layout`:case`drawing`:return{inputs:t.children&&t.children.length>0?{title:n}:null};case`barChart`:case`columnChart`:case`pieChart`:case`donutChart`:case`lineChart`:case`areaChart`:case`scatterChart`:{let t=L(e,n,i,{placeholders:!1});return{inputs:t,...t?{}:{warning:`No table found in this block`}}}default:return{inputs:L(e,n,i,{placeholders:!1})}}}function Pv(e,t,n){let r=be(e.contents,1)[0],i=ce(e.contents)||n||t;return!r||!i?null:{text:i,backgroundImage:{src:r.src,alt:r.alt||t}}}function Fv(e,t,n){let r=Ee(e.contents);if(r.length>=2)return{...t?{header:t}:{},left:{label:Vv(r[0])},right:{label:Vv(r[1])}};let i=n.split(/\n{2,}|\n|(?<=[.!?])\s+/).map(e=>e.trim()).filter(Boolean);return t&&i.length>=1?{left:{label:Vv(t)},right:{label:Vv(i[0])}}:i.length>=2?{left:{label:Vv(i[0])},right:{label:Vv(i[1])}}:null}function Iv(e){let t=H(e.contents);if(t){let e=t.rows.map(e=>({label:e[0]||`Value`,value:Lv(e.slice(1).join(` `))})).filter(e=>e.value!==null);if(e.length>=2)return{leftLabel:Vv(e[0].label,24),leftValue:e[0].value,rightLabel:Vv(e[1].label,24),rightValue:e[1].value}}let n=ke(e.contents),r=Array.from(n.matchAll(new RegExp(Dv.source,`gi`))).map(e=>Lv(e[0])).filter(e=>e!==null);return r.length<2?null:{leftLabel:`A`,leftValue:r[0],rightLabel:`B`,rightValue:r[1]}}function Lv(e){let t=e.replace(/[$\u20ac\u00a3\u00a5,%\u2030]/g,``).replace(/,/g,``).trim().match(/-?\d+(?:\.\d+)?/);if(!t)return null;let n=Number.parseFloat(t[0]);return Number.isFinite(n)?n:null}function Rv(e){if(typeof e==`string`)return Av.test(e)||kv.test(e)||jv.test(e);if(Array.isArray(e))return e.some(Rv);if(!e||typeof e!=`object`)return!1;let t=e,n=typeof t.tagName==`string`?t.tagName.toLowerCase():``;if(n===`audio`||n===`video`||t.type===`audio`||t.type===`video`)return!0;let r=t.attributes;if(r&&typeof r==`object`){let e=r;if(Rv(e.src)||Rv(e.type))return!0}return Object.values(t).some(Rv)}function zv(e){return e.sourceHeading?Ue(e.sourceHeading).trim():(e.title??e.id??``).trim()}function Bv(e){return e.split(/\r?\n/).map(e=>e.trim()).find(Boolean)??``}function Vv(e,t=72){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t-1).trimEnd()}...`}function Hv({templateName:e,source:t,fallback:n}){let r=(0,G.useMemo)(()=>t?Mv(e,t):null,[e,t]);return t?r?.visual?(0,K.jsx)(`div`,{className:`squisq-template-gallery-content-preview`,style:{aspectRatio:`${t.viewport.width} / ${t.viewport.height}`},"aria-hidden":`true`,children:(0,K.jsx)(pn.Provider,{value:t.mediaProvider??null,children:(0,K.jsx)(sn,{block:r.visual,blockTime:0,basePath:t.basePath??`/`,viewport:t.viewport})})}):r?.warning?(0,K.jsxs)(`div`,{className:`squisq-template-gallery-content-preview squisq-template-gallery-content-preview--fallback`,style:{aspectRatio:`${t.viewport.width} / ${t.viewport.height}`},"aria-hidden":`true`,children:[(0,K.jsx)(`div`,{className:`squisq-template-gallery-content-preview-fallback`,children:n}),(0,K.jsx)(`span`,{className:`squisq-template-gallery-content-preview-warning`,children:r.warning})]}):n:n}var Uv=`[data-squisq-template-gallery-portal]`,Wv=`squisq-template-gallery-dialog`,Gv=`squisq-template-gallery-portal`;function Kv(){return`${Gv}-${(0,G.useId)().replace(/:/g,``)}`}var qv=56,Jv=40,Q=`#d1d5db`,Yv=`#9ca3af`,Xv=`#818cf8`;function Zv({children:e}){return(0,K.jsx)(`svg`,{width:qv,height:Jv,viewBox:`0 0 ${qv} ${Jv}`,"aria-hidden":`true`,className:`squisq-template-picker-icon`,children:e})}var Qv={name:``,label:`— none —`,description:`Plain heading block with no visual treatment.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`rect`,{x:4,y:4,width:48,height:32,rx:2,fill:`none`,stroke:Q,strokeWidth:1.5,strokeDasharray:`3 2`}),(0,K.jsx)(`rect`,{x:12,y:15,width:32,height:4,rx:1,fill:Q}),(0,K.jsx)(`rect`,{x:16,y:22,width:24,height:3,rx:1,fill:Q,opacity:.6})]})},$v=[{name:`title`,label:`Title`,description:`A bold opening slide with large title text, perfect for covers and chapters.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`rect`,{x:4,y:4,width:48,height:32,rx:2,fill:Q,opacity:.3}),(0,K.jsx)(`rect`,{x:8,y:11,width:40,height:8,rx:1,fill:Xv}),(0,K.jsx)(`rect`,{x:14,y:23,width:28,height:3,rx:1,fill:Yv}),(0,K.jsx)(`rect`,{x:20,y:29,width:16,height:2,rx:1,fill:Q})]})},{name:`sectionHeader`,label:`Section Header`,description:`A clean section break with a prominent title and optional background image.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`rect`,{x:4,y:4,width:3,height:32,rx:1,fill:Xv}),(0,K.jsx)(`rect`,{x:11,y:8,width:36,height:6,rx:1,fill:Yv}),(0,K.jsx)(`rect`,{x:11,y:18,width:28,height:3,rx:1,fill:Q}),(0,K.jsx)(`rect`,{x:11,y:24,width:20,height:2.5,rx:1,fill:Q,opacity:.7})]})},{name:`bigText`,label:`Big Text`,description:`Gigantic uppercase display text — thumbnail-style — on a theme surface or over an image with a contrast bloom.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`rect`,{x:4,y:4,width:48,height:32,rx:2,fill:Q,opacity:.25}),(0,K.jsx)(`ellipse`,{cx:28,cy:20,rx:22,ry:13,fill:Q,opacity:.35}),(0,K.jsx)(`rect`,{x:8,y:12,width:40,height:10,rx:2,fill:Xv}),(0,K.jsx)(`rect`,{x:16,y:26,width:24,height:4,rx:1,fill:Yv})]})},{name:`transcript`,label:`Transcript`,description:`A conversational beat: speaker avatar and message bubble, with thought, tool, and two-speaker handoff variants.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`circle`,{cx:11,cy:13,r:5,fill:Xv}),(0,K.jsx)(`rect`,{x:19,y:8,width:33,height:11,rx:3,fill:Q,opacity:.5}),(0,K.jsx)(`rect`,{x:22,y:11,width:24,height:2.5,rx:1,fill:Yv}),(0,K.jsx)(`circle`,{cx:45,cy:28,r:5,fill:Yv}),(0,K.jsx)(`rect`,{x:4,y:23,width:33,height:11,rx:3,fill:Q,opacity:.35}),(0,K.jsx)(`rect`,{x:7,y:26,width:24,height:2.5,rx:1,fill:Q})]})},{name:`content`,label:`Content`,description:`Shows a heading and the complete body in a loss-averse content-first layout.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`rect`,{x:7,y:7,width:34,height:5,rx:1,fill:Xv}),(0,K.jsx)(`rect`,{x:7,y:17,width:42,height:2.5,rx:1,fill:Yv}),(0,K.jsx)(`rect`,{x:7,y:22,width:38,height:2.5,rx:1,fill:Q}),(0,K.jsx)(`rect`,{x:7,y:27,width:41,height:2.5,rx:1,fill:Q}),(0,K.jsx)(`rect`,{x:7,y:32,width:30,height:2.5,rx:1,fill:Q,opacity:.7})]})},{name:`statHighlight`,label:`Stat Highlight`,description:`Showcases a single key number or metric with supporting context.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`rect`,{x:14,y:4,width:28,height:16,rx:2,fill:Xv}),(0,K.jsx)(`rect`,{x:10,y:24,width:36,height:3.5,rx:1,fill:Yv}),(0,K.jsx)(`rect`,{x:16,y:30,width:24,height:2.5,rx:1,fill:Q})]})},{name:`quote`,label:`Quote`,description:`Displays a stylized pull quote with decorative marks and attribution.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`text`,{x:5,y:18,fontSize:18,fill:Xv,fontFamily:`serif`,fontWeight:`bold`,opacity:.7,children:`"`}),(0,K.jsx)(`rect`,{x:16,y:8,width:36,height:4,rx:1,fill:Yv}),(0,K.jsx)(`rect`,{x:16,y:15,width:32,height:4,rx:1,fill:Yv}),(0,K.jsx)(`rect`,{x:16,y:22,width:24,height:4,rx:1,fill:Yv}),(0,K.jsx)(`rect`,{x:16,y:31,width:18,height:2.5,rx:1,fill:Q})]})},{name:`factCard`,label:`Fact Card`,description:`Presents a focused fact or insight with a labeled header and body text.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`rect`,{x:4,y:4,width:20,height:6,rx:3,fill:Xv,opacity:.8}),(0,K.jsx)(`rect`,{x:4,y:14,width:48,height:5,rx:1,fill:Yv}),(0,K.jsx)(`rect`,{x:4,y:22,width:44,height:3.5,rx:1,fill:Q}),(0,K.jsx)(`rect`,{x:4,y:28,width:36,height:3,rx:1,fill:Q,opacity:.7})]})},{name:`twoColumn`,label:`Two Column`,description:`Divides the slide into two equal side-by-side content columns.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`rect`,{x:3,y:4,width:23,height:32,rx:2,fill:Q,opacity:.4}),(0,K.jsx)(`rect`,{x:3,y:4,width:23,height:7,rx:2,fill:Yv,opacity:.6}),(0,K.jsx)(`rect`,{x:6,y:15,width:17,height:3,rx:1,fill:Q}),(0,K.jsx)(`rect`,{x:6,y:21,width:14,height:2.5,rx:1,fill:Q,opacity:.7}),(0,K.jsx)(`rect`,{x:30,y:4,width:23,height:32,rx:2,fill:Q,opacity:.4}),(0,K.jsx)(`rect`,{x:30,y:4,width:23,height:7,rx:2,fill:Yv,opacity:.6}),(0,K.jsx)(`rect`,{x:33,y:15,width:17,height:3,rx:1,fill:Q}),(0,K.jsx)(`rect`,{x:33,y:21,width:14,height:2.5,rx:1,fill:Q,opacity:.7})]})},{name:`dateEvent`,label:`Date Event`,description:`Highlights a date-based event or milestone with a prominent date display.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`rect`,{x:3,y:4,width:18,height:18,rx:3,fill:Xv,opacity:.85}),(0,K.jsx)(`rect`,{x:6,y:8,width:12,height:2,rx:1,fill:`white`,opacity:.7}),(0,K.jsx)(`rect`,{x:6,y:13,width:12,height:6,rx:1,fill:`white`,opacity:.5}),(0,K.jsx)(`rect`,{x:25,y:6,width:27,height:5,rx:1,fill:Yv}),(0,K.jsx)(`rect`,{x:25,y:15,width:22,height:3,rx:1,fill:Q}),(0,K.jsx)(`rect`,{x:25,y:21,width:16,height:2.5,rx:1,fill:Q,opacity:.7}),(0,K.jsx)(`rect`,{x:3,y:27,width:50,height:2.5,rx:1,fill:Q,opacity:.5}),(0,K.jsx)(`rect`,{x:3,y:32,width:40,height:2,rx:1,fill:Q,opacity:.4})]})},{name:`imageWithCaption`,label:`Image with Caption`,description:`Displays a full-bleed image with an optional caption below.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`rect`,{x:3,y:3,width:50,height:28,rx:2,fill:Yv,opacity:.5}),(0,K.jsx)(`line`,{x1:3,y1:14,x2:53,y2:14,stroke:`white`,strokeWidth:.5,opacity:.3}),(0,K.jsx)(`polygon`,{points:`22,10 22,20 32,15`,fill:`white`,opacity:.4}),(0,K.jsx)(`rect`,{x:10,y:35,width:36,height:2.5,rx:1,fill:Q})]})},{name:`leftFeature`,label:`Left Feature`,description:`Image on the left, title and body text stacked on the right.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`rect`,{x:3,y:4,width:24,height:32,rx:2,fill:Yv,opacity:.55}),(0,K.jsx)(`polygon`,{points:`11,16 11,24 19,20`,fill:`white`,opacity:.5}),(0,K.jsx)(`rect`,{x:31,y:9,width:20,height:4,rx:1,fill:Xv}),(0,K.jsx)(`rect`,{x:31,y:17,width:22,height:2.5,rx:1,fill:Q}),(0,K.jsx)(`rect`,{x:31,y:22,width:22,height:2.5,rx:1,fill:Q,opacity:.75}),(0,K.jsx)(`rect`,{x:31,y:27,width:16,height:2.5,rx:1,fill:Q,opacity:.6})]})},{name:`rightFeature`,label:`Right Feature`,description:`Image on the right, title and body text stacked on the left.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`rect`,{x:29,y:4,width:24,height:32,rx:2,fill:Yv,opacity:.55}),(0,K.jsx)(`polygon`,{points:`37,16 37,24 45,20`,fill:`white`,opacity:.5}),(0,K.jsx)(`rect`,{x:3,y:9,width:20,height:4,rx:1,fill:Xv}),(0,K.jsx)(`rect`,{x:3,y:17,width:22,height:2.5,rx:1,fill:Q}),(0,K.jsx)(`rect`,{x:3,y:22,width:22,height:2.5,rx:1,fill:Q,opacity:.75}),(0,K.jsx)(`rect`,{x:3,y:27,width:16,height:2.5,rx:1,fill:Q,opacity:.6})]})},{name:`map`,label:`Map`,description:`Embeds an interactive map centered on a geographic location.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`rect`,{x:3,y:3,width:50,height:34,rx:2,fill:Q,opacity:.3}),(0,K.jsx)(`line`,{x1:3,y1:13,x2:53,y2:13,stroke:Q,strokeWidth:1}),(0,K.jsx)(`line`,{x1:3,y1:23,x2:53,y2:23,stroke:Q,strokeWidth:1}),(0,K.jsx)(`line`,{x1:18,y1:3,x2:18,y2:37,stroke:Q,strokeWidth:1}),(0,K.jsx)(`line`,{x1:38,y1:3,x2:38,y2:37,stroke:Q,strokeWidth:1}),(0,K.jsx)(`circle`,{cx:28,cy:18,r:4,fill:Xv,opacity:.8}),(0,K.jsx)(`line`,{x1:28,y1:22,x2:28,y2:26,stroke:Xv,strokeWidth:1.5,opacity:.6})]})},{name:`fullBleedQuote`,label:`Full Bleed Quote`,description:`A full-width quote that spans the entire slide for maximum impact.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`rect`,{x:4,y:4,width:48,height:32,rx:2,fill:Yv,opacity:.2}),(0,K.jsx)(`text`,{x:5,y:15,fontSize:16,fill:Xv,fontFamily:`serif`,fontWeight:`bold`,opacity:.8,children:`"`}),(0,K.jsx)(`rect`,{x:4,y:14,width:48,height:5,rx:1,fill:Yv}),(0,K.jsx)(`rect`,{x:4,y:22,width:44,height:5,rx:1,fill:Yv}),(0,K.jsx)(`rect`,{x:4,y:30,width:30,height:4,rx:1,fill:Yv,opacity:.7})]})},{name:`list`,label:`List`,description:`Renders a bulleted or numbered list in a clean, card-style layout.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`rect`,{x:4,y:5,width:6,height:5,rx:3,fill:Xv,opacity:.8}),(0,K.jsx)(`rect`,{x:14,y:6,width:38,height:4,rx:1,fill:Yv}),(0,K.jsx)(`rect`,{x:4,y:17,width:6,height:5,rx:3,fill:Xv,opacity:.8}),(0,K.jsx)(`rect`,{x:14,y:18,width:34,height:4,rx:1,fill:Yv}),(0,K.jsx)(`rect`,{x:4,y:29,width:6,height:5,rx:3,fill:Xv,opacity:.8}),(0,K.jsx)(`rect`,{x:14,y:30,width:36,height:4,rx:1,fill:Yv})]})},{name:`photoGrid`,label:`Photo Grid`,description:`Arranges multiple photos in a 2×2 or 3×3 mosaic grid.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`rect`,{x:3,y:3,width:23,height:16,rx:1.5,fill:Yv,opacity:.55}),(0,K.jsx)(`rect`,{x:30,y:3,width:23,height:16,rx:1.5,fill:Yv,opacity:.7}),(0,K.jsx)(`rect`,{x:3,y:22,width:23,height:16,rx:1.5,fill:Yv,opacity:.8}),(0,K.jsx)(`rect`,{x:30,y:22,width:23,height:16,rx:1.5,fill:Yv,opacity:.5})]})},{name:`definitionCard`,label:`Definition Card`,description:`Shows a term and its definition in a structured, dictionary-style card.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`rect`,{x:4,y:6,width:32,height:6,rx:1,fill:Xv,opacity:.8}),(0,K.jsx)(`rect`,{x:4,y:17,width:48,height:3.5,rx:1,fill:Q}),(0,K.jsx)(`rect`,{x:4,y:23,width:44,height:3,rx:1,fill:Q,opacity:.8}),(0,K.jsx)(`rect`,{x:4,y:29,width:36,height:3,rx:1,fill:Q,opacity:.6})]})},{name:`comparisonBar`,label:`Comparison Bar`,description:`Visualizes two or more values side-by-side with labeled horizontal bars.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`rect`,{x:4,y:5,width:14,height:3,rx:1,fill:Q}),(0,K.jsx)(`rect`,{x:20,y:4,width:32,height:5,rx:1,fill:Xv,opacity:.85}),(0,K.jsx)(`rect`,{x:4,y:16,width:14,height:3,rx:1,fill:Q}),(0,K.jsx)(`rect`,{x:20,y:15,width:22,height:5,rx:1,fill:Yv,opacity:.7}),(0,K.jsx)(`rect`,{x:4,y:27,width:14,height:3,rx:1,fill:Q}),(0,K.jsx)(`rect`,{x:20,y:26,width:28,height:5,rx:1,fill:Yv,opacity:.5})]})},{name:`pullQuote`,label:`Pull Quote`,description:`A stylized pull quote with large decorative marks and centered text.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`text`,{x:3,y:20,fontSize:26,fill:Xv,fontFamily:`serif`,opacity:.5,children:`"`}),(0,K.jsx)(`rect`,{x:16,y:7,width:36,height:4.5,rx:1,fill:Yv}),(0,K.jsx)(`rect`,{x:16,y:15,width:34,height:4.5,rx:1,fill:Yv}),(0,K.jsx)(`rect`,{x:16,y:23,width:28,height:4.5,rx:1,fill:Yv}),(0,K.jsx)(`rect`,{x:32,y:31,width:20,height:3,rx:1,fill:Q}),(0,K.jsx)(`text`,{x:44,y:42,fontSize:26,fill:Xv,fontFamily:`serif`,opacity:.3,children:`"`})]})},{name:`videoWithCaption`,label:`Video with Caption`,description:`Embeds a video player with an optional caption below.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`rect`,{x:3,y:3,width:50,height:28,rx:2,fill:Q,opacity:.4}),(0,K.jsx)(`rect`,{x:3,y:3,width:50,height:28,rx:2,fill:Yv,opacity:.25}),(0,K.jsx)(`circle`,{cx:28,cy:17,r:8,fill:Xv,opacity:.7}),(0,K.jsx)(`polygon`,{points:`25,13 25,21 33,17`,fill:`white`}),(0,K.jsx)(`rect`,{x:10,y:35,width:36,height:2.5,rx:1,fill:Q})]})},{name:`videoPullQuote`,label:`Video Pull Quote`,description:`Combines a video panel with a highlighted pull quote side-by-side.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`rect`,{x:3,y:4,width:23,height:32,rx:2,fill:Yv,opacity:.35}),(0,K.jsx)(`circle`,{cx:14.5,cy:20,r:6,fill:Xv,opacity:.65}),(0,K.jsx)(`polygon`,{points:`12,17 12,23 18,20`,fill:`white`}),(0,K.jsx)(`rect`,{x:30,y:4,width:23,height:32,rx:2,fill:Q,opacity:.3}),(0,K.jsx)(`text`,{x:32,y:16,fontSize:12,fill:Xv,fontFamily:`serif`,opacity:.6,children:`"`}),(0,K.jsx)(`rect`,{x:30,y:17,width:20,height:3.5,rx:1,fill:Yv}),(0,K.jsx)(`rect`,{x:30,y:23,width:18,height:3,rx:1,fill:Q}),(0,K.jsx)(`rect`,{x:30,y:29,width:14,height:2.5,rx:1,fill:Q,opacity:.7})]})},{name:`dataTable`,label:`Data Table`,description:`Renders tabular data in a clean, styled table with a header row.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`rect`,{x:3,y:3,width:50,height:8,rx:1.5,fill:Xv,opacity:.7}),(0,K.jsx)(`rect`,{x:3,y:13,width:50,height:6,rx:1,fill:Q,opacity:.5}),(0,K.jsx)(`rect`,{x:3,y:21,width:50,height:6,rx:1,fill:Q,opacity:.35}),(0,K.jsx)(`rect`,{x:3,y:29,width:50,height:6,rx:1,fill:Q,opacity:.5}),(0,K.jsx)(`line`,{x1:20,y1:3,x2:20,y2:35,stroke:`white`,strokeWidth:1,opacity:.4}),(0,K.jsx)(`line`,{x1:37,y1:3,x2:37,y2:35,stroke:`white`,strokeWidth:1,opacity:.4})]})},{name:`barChart`,label:`Bar Chart`,description:`Horizontal bars from the block's markdown table — one bar per row.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`rect`,{x:8,y:6,width:40,height:5,rx:1,fill:Xv,opacity:.85}),(0,K.jsx)(`rect`,{x:8,y:14,width:28,height:5,rx:1,fill:Yv,opacity:.8}),(0,K.jsx)(`rect`,{x:8,y:22,width:34,height:5,rx:1,fill:Xv,opacity:.6}),(0,K.jsx)(`rect`,{x:8,y:30,width:18,height:5,rx:1,fill:Q,opacity:.8}),(0,K.jsx)(`line`,{x1:8,y1:4,x2:8,y2:37,stroke:Q,strokeWidth:1.5})]})},{name:`columnChart`,label:`Column Chart`,description:`Vertical columns from the block's markdown table — one column per row.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`rect`,{x:8,y:18,width:7,height:16,rx:1,fill:Yv,opacity:.8}),(0,K.jsx)(`rect`,{x:19,y:10,width:7,height:24,rx:1,fill:Xv,opacity:.85}),(0,K.jsx)(`rect`,{x:30,y:14,width:7,height:20,rx:1,fill:Xv,opacity:.6}),(0,K.jsx)(`rect`,{x:41,y:22,width:7,height:12,rx:1,fill:Q,opacity:.8}),(0,K.jsx)(`line`,{x1:5,y1:34,x2:51,y2:34,stroke:Q,strokeWidth:1.5})]})},{name:`pieChart`,label:`Pie Chart`,description:`A pie of the block's markdown table — each row becomes a labeled slice.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`circle`,{cx:28,cy:20,r:14,fill:Q,opacity:.6}),(0,K.jsx)(`path`,{d:`M 28 20 L 28 6 A 14 14 0 0 1 41.4 24.1 Z`,fill:Xv,opacity:.85}),(0,K.jsx)(`path`,{d:`M 28 20 L 41.4 24.1 A 14 14 0 0 1 20.5 32.9 Z`,fill:Yv,opacity:.8})]})},{name:`donutChart`,label:`Donut Chart`,description:`A donut of the block's markdown table — each row becomes a labeled slice.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`circle`,{cx:28,cy:20,r:14,fill:Q,opacity:.6}),(0,K.jsx)(`path`,{d:`M 28 20 L 28 6 A 14 14 0 0 1 41.4 24.1 Z`,fill:Xv,opacity:.85}),(0,K.jsx)(`path`,{d:`M 28 20 L 41.4 24.1 A 14 14 0 0 1 20.5 32.9 Z`,fill:Yv,opacity:.8}),(0,K.jsx)(`circle`,{cx:28,cy:20,r:7,fill:`white`})]})},{name:`lineChart`,label:`Line Chart`,description:`Lines from the block's markdown table — one line per value column.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`line`,{x1:6,y1:12,x2:50,y2:12,stroke:Q,strokeWidth:1,opacity:.5}),(0,K.jsx)(`line`,{x1:6,y1:22,x2:50,y2:22,stroke:Q,strokeWidth:1,opacity:.5}),(0,K.jsx)(`line`,{x1:6,y1:32,x2:50,y2:32,stroke:Q,strokeWidth:1,opacity:.5}),(0,K.jsx)(`polyline`,{points:`8,28 20,16 32,20 48,8`,fill:`none`,stroke:Xv,strokeWidth:2.5,opacity:.85}),(0,K.jsx)(`polyline`,{points:`8,32 20,26 32,30 48,20`,fill:`none`,stroke:Yv,strokeWidth:2,opacity:.7})]})},{name:`areaChart`,label:`Area Chart`,description:`Filled area lines from the block's markdown table — one area per value column.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`path`,{d:`M 8 28 L 20 16 L 32 20 L 48 8 L 48 34 L 8 34 Z`,fill:Xv,opacity:.4}),(0,K.jsx)(`polyline`,{points:`8,28 20,16 32,20 48,8`,fill:`none`,stroke:Xv,strokeWidth:2.5,opacity:.85}),(0,K.jsx)(`line`,{x1:6,y1:34,x2:50,y2:34,stroke:Q,strokeWidth:1.5})]})},{name:`scatterChart`,label:`Scatter Chart`,description:`An x/y scatter plot from the block's markdown table's numeric columns.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`line`,{x1:8,y1:4,x2:8,y2:34,stroke:Q,strokeWidth:1.5}),(0,K.jsx)(`line`,{x1:8,y1:34,x2:50,y2:34,stroke:Q,strokeWidth:1.5}),(0,K.jsx)(`circle`,{cx:16,cy:26,r:2.5,fill:Yv,opacity:.8}),(0,K.jsx)(`circle`,{cx:22,cy:18,r:2.5,fill:Xv,opacity:.85}),(0,K.jsx)(`circle`,{cx:28,cy:22,r:2.5,fill:Yv,opacity:.8}),(0,K.jsx)(`circle`,{cx:34,cy:12,r:2.5,fill:Xv,opacity:.85}),(0,K.jsx)(`circle`,{cx:40,cy:16,r:2.5,fill:Yv,opacity:.8}),(0,K.jsx)(`circle`,{cx:45,cy:9,r:2.5,fill:Xv,opacity:.85})]})},{name:`diagram`,label:`Diagram`,description:`Renders sub-headings as connected nodes — edit visually as a node-and-edge diagram.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`rect`,{x:4,y:6,width:16,height:10,rx:2,fill:Xv,opacity:.85}),(0,K.jsx)(`rect`,{x:36,y:6,width:16,height:10,rx:2,fill:Yv,opacity:.8}),(0,K.jsx)(`rect`,{x:20,y:24,width:16,height:10,rx:2,fill:Yv,opacity:.8}),(0,K.jsx)(`path`,{d:`M 20 11 L 36 11`,stroke:Xv,strokeWidth:1.5,fill:`none`,opacity:.7}),(0,K.jsx)(`path`,{d:`M 36 11 L 32 8.5 L 32 13.5 Z`,fill:Xv,opacity:.7}),(0,K.jsx)(`path`,{d:`M 12 16 C 12 22, 24 22, 24 24`,stroke:Xv,strokeWidth:1.5,fill:`none`,opacity:.7}),(0,K.jsx)(`path`,{d:`M 44 16 C 44 22, 32 22, 32 24`,stroke:Xv,strokeWidth:1.5,fill:`none`,opacity:.7})]})},{name:`tree`,label:`Tree`,description:`Renders an ASCII file-tree / outline fence as a filesystem-style treeview — edit as an outline.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`rect`,{x:6,y:5,width:16,height:7,rx:1.5,fill:Xv,opacity:.85}),(0,K.jsx)(`path`,{d:`M 12 12 L 12 34 M 12 20 L 22 20 M 12 34 L 22 34`,stroke:Q,strokeWidth:1.5,fill:`none`,opacity:.7}),(0,K.jsx)(`rect`,{x:24,y:16,width:14,height:7,rx:1.5,fill:Yv,opacity:.8}),(0,K.jsx)(`rect`,{x:24,y:30,width:14,height:7,rx:1.5,fill:Yv,opacity:.8}),(0,K.jsx)(`rect`,{x:26,y:2,width:14,height:7,rx:1.5,fill:Yv,opacity:.6})]})},{name:`timeline`,label:`Timeline`,description:`Plots events across one or more horizontal tracks with callouts and optional branching links.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`path`,{d:`M 5 21 L 51 21`,stroke:Q,strokeWidth:1.8,fill:`none`}),(0,K.jsx)(`path`,{d:`M 47 18 L 52 21 L 47 24`,stroke:Q,strokeWidth:1.5,fill:`none`}),(0,K.jsx)(`circle`,{cx:13,cy:21,r:3,fill:Xv}),(0,K.jsx)(`circle`,{cx:29,cy:21,r:3,fill:Yv}),(0,K.jsx)(`circle`,{cx:44,cy:21,r:3,fill:Xv}),(0,K.jsx)(`path`,{d:`M 13 18 L 13 10 M 29 24 L 29 32 M 44 18 L 44 8`,stroke:Q,strokeWidth:1}),(0,K.jsx)(`rect`,{x:7,y:5,width:12,height:3,rx:1,fill:Yv,opacity:.8}),(0,K.jsx)(`rect`,{x:23,y:33,width:12,height:3,rx:1,fill:Yv,opacity:.8}),(0,K.jsx)(`rect`,{x:38,y:3,width:12,height:3,rx:1,fill:Yv,opacity:.8})]})},{name:`layout`,label:`Layout`,description:`Free-form 2D canvas — drag layers into place. Use for one-off block layouts that don't fit a template.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`rect`,{x:3,y:3,width:50,height:34,rx:2,fill:`none`,stroke:Q,strokeWidth:1,strokeDasharray:`3 2`}),(0,K.jsx)(`rect`,{x:7,y:7,width:20,height:12,rx:1.5,fill:Xv,opacity:.85}),(0,K.jsx)(`rect`,{x:30,y:7,width:20,height:26,rx:1.5,fill:Yv,opacity:.7}),(0,K.jsx)(`rect`,{x:7,y:22,width:20,height:11,rx:1.5,fill:Q,opacity:.7})]})},{name:`drawing`,label:`Drawing`,description:`Free-form sketches — draw shapes, paths, and text directly on a 2D surface.`,icon:(0,K.jsxs)(Zv,{children:[(0,K.jsx)(`rect`,{x:3,y:3,width:50,height:34,rx:2,fill:`none`,stroke:Q,strokeWidth:1}),(0,K.jsx)(`path`,{d:`M 8 28 C 14 12, 26 14, 30 22 S 44 32, 50 14`,stroke:Xv,strokeWidth:2,fill:`none`,opacity:.85,strokeLinecap:`round`}),(0,K.jsx)(`circle`,{cx:10,cy:10,r:2.5,fill:Yv}),(0,K.jsx)(`rect`,{x:40,y:28,width:8,height:6,rx:1,fill:Yv,opacity:.7})]})}],ey=$v.map(e=>e.name);function ty(e,t){if(!e)return`— none —`;let n=vt(e),r=s[n];if(r)return r.label;let i=t?.find(e=>e.name===n);return i?i.label:n.replace(/([A-Z])/g,` $1`).replace(/^./,e=>e.toUpperCase())}function ny({value:e,onChange:t,colorScheme:n=`light`,compact:r,recommended:i,onOpenDesigner:a,previewSource:o}){let[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)({}),d=(0,G.useRef)(null),f=(0,G.useRef)(null),p=(0,G.useRef)(null),m=`${Wv}-${(0,G.useId)().replace(/:/g,``)}`;Dh(s,()=>c(!1),f);let h=()=>{f.current&&u(dy(f.current))},g=()=>{h(),c(e=>!e)};(0,G.useEffect)(()=>{if(!s)return;let e=e=>{let t=e.target,n=f.current?.contains(t),r=p.current?.contains(t);!n&&!r&&c(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[s]),(0,G.useEffect)(()=>{if(!s)return;requestAnimationFrame(h);let e=()=>h();return window.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,e)}},[s]);let _=e=>{t(e),c(!1)},v=ty(e),y=e&&$v.find(t=>t.name===e)||Qv,b=ly(o);if(r)return(0,K.jsx)(`select`,{className:`squisq-template-picker-select`,value:e,onChange:e=>t(e.target.value),children:[Qv,...$v].map(e=>(0,K.jsx)(`option`,{value:e.name,children:e.label},e.name))});let x=s?(0,Wr.createPortal)((0,K.jsx)(ry,{dialogRef:p,returnFocusRef:f,dialogId:m,title:b,colorScheme:n,style:l,onClose:()=>c(!1),children:(0,K.jsx)(oy,{value:e,onSelect:_,style:{},recommended:i,onOpenDesigner:a,previewSource:o})}),document.body):null;return(0,K.jsxs)(`div`,{className:`squisq-template-picker-popover-host`,ref:d,children:[(0,K.jsxs)(`button`,{ref:f,type:`button`,className:`squisq-template-picker-trigger${s?` squisq-template-picker-trigger--open`:``}`,onClick:g,"aria-haspopup":`dialog`,"aria-expanded":s,"aria-controls":s?m:void 0,title:`Choose block type`,children:[(0,K.jsx)(`span`,{className:`squisq-template-picker-trigger-label`,children:`Block:`}),(0,K.jsx)(`span`,{className:`squisq-template-picker-trigger-thumb`,"aria-hidden":`true`,children:y.icon}),(0,K.jsx)(`span`,{className:`squisq-template-picker-trigger-value`,children:e?v:`(No visual)`}),(0,K.jsx)(`svg`,{className:`squisq-template-picker-trigger-caret`,width:`10`,height:`10`,viewBox:`0 0 10 10`,fill:`currentColor`,"aria-hidden":`true`,children:(0,K.jsx)(`path`,{d:`M2 3.5l3 3 3-3`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,fill:`none`})})]}),x]})}function ry({dialogRef:e,returnFocusRef:t,dialogId:n,children:r,title:i,colorScheme:a,style:o,onClose:s}){let c=(0,G.useRef)(null),l=(0,G.useId)();return Ur({rootRef:e,dialogRef:c,returnFocusRef:t,onClose:s}),(0,K.jsx)(`div`,{ref:e,id:n,className:`squisq-template-gallery-dialog`,"data-theme":a,style:o,onMouseDown:e=>{e.target===e.currentTarget&&s()},children:(0,K.jsxs)(`div`,{ref:c,className:`squisq-template-gallery-dialog-panel`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":l,tabIndex:-1,children:[(0,K.jsxs)(`div`,{className:`squisq-template-gallery-dialog-header`,children:[(0,K.jsx)(`h2`,{id:l,className:`squisq-template-gallery-dialog-title`,children:i}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-template-gallery-dialog-close`,onClick:s,"aria-label":`Close block type picker`,children:(0,K.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 14 14`,"aria-hidden":`true`,children:(0,K.jsx)(`path`,{d:`M3.2 3.2l7.6 7.6M10.8 3.2l-7.6 7.6`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`})})})]}),(0,K.jsx)(`div`,{className:`squisq-template-gallery-dialog-body`,children:r})]})})}function iy({entry:e,value:t,onSelect:n,previewSource:r}){return(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":t===e.name,className:`squisq-template-gallery-card${t===e.name?` squisq-template-gallery-card--selected`:``}`,onClick:()=>n(e.name),title:e.description,children:[(0,K.jsx)(`div`,{className:`squisq-template-gallery-card-icon`,children:(0,K.jsx)(Hv,{templateName:e.name,source:r,fallback:e.icon})}),(0,K.jsxs)(`div`,{className:`squisq-template-gallery-card-body`,children:[(0,K.jsx)(`span`,{className:`squisq-template-gallery-card-name`,children:e.label}),(0,K.jsx)(`span`,{className:`squisq-template-gallery-card-desc`,children:e.description})]})]})}function ay(e,t){if(!t)return{blockTypeEntries:[...e],contentNeededEntries:[]};let n=[],r=[];for(let i of e)Mv(i.name,t).warning?r.push(i):n.push(i);return{blockTypeEntries:n,contentNeededEntries:r}}function oy({value:e,onSelect:t,style:n,recommended:r,onOpenDesigner:i,previewSource:a}){let o=Kv(),[s,c]=(0,G.useState)(``),l=(0,G.useRef)(null),u=Sv(),d=(0,G.useMemo)(()=>u?.allTemplates??[],[u]);(0,G.useEffect)(()=>{l.current?.focus()},[]);let f=s.trim().toLowerCase(),p=f.length>0,m=(0,G.useMemo)(()=>p?{built:$v.filter(e=>e.label.toLowerCase().includes(f)||e.description.toLowerCase().includes(f)||e.name.toLowerCase().includes(f)),custom:d.filter(e=>e.label.toLowerCase().includes(f)||e.name.toLowerCase().includes(f)||(e.description??``).toLowerCase().includes(f))}:null,[p,f,d]),h=(0,G.useMemo)(()=>r&&r.length>0?new Set(r):null,[r]),g=(0,G.useMemo)(()=>h?$v.filter(e=>h.has(e.name)):[],[h]),_=(0,G.useMemo)(()=>h?$v.filter(e=>!h.has(e.name)):$v,[h]),{blockTypeEntries:v,contentNeededEntries:y}=(0,G.useMemo)(()=>ay(_,a),[_,a]),b=!p&&(g.length>0||y.length>0);return(0,K.jsxs)(`div`,{id:o,"data-squisq-template-gallery-portal":``,className:`squisq-template-gallery${b?` squisq-template-gallery--segmented`:``}`,role:`region`,"aria-label":`Block types`,style:n,children:[(0,K.jsxs)(`div`,{className:`squisq-template-gallery-search`,children:[(0,K.jsxs)(`svg`,{className:`squisq-template-gallery-search-icon`,width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,children:[(0,K.jsx)(`circle`,{cx:`7`,cy:`7`,r:`5`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,K.jsx)(`path`,{d:`M11 11l3 3`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})]}),(0,K.jsx)(`input`,{ref:l,type:`search`,className:`squisq-template-gallery-search-input`,placeholder:`Search block types…`,value:s,onChange:e=>c(e.target.value),"aria-label":`Search block types`})]}),!p&&(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":e===``,className:`squisq-template-gallery-none${e===``?` squisq-template-gallery-card--selected`:``}`,onClick:()=>t(``),children:[Qv.icon,(0,K.jsx)(`span`,{className:`squisq-template-gallery-none-label`,children:Qv.label}),(0,K.jsx)(`span`,{className:`squisq-template-gallery-none-desc`,children:Qv.description})]}),p?m&&(m.built.length>0||m.custom.length>0)?(0,K.jsxs)(K.Fragment,{children:[m.custom.length>0&&(0,K.jsxs)(`div`,{className:`squisq-template-gallery-section`,children:[(0,K.jsx)(`h3`,{className:`squisq-template-gallery-section-title`,children:`Custom`}),(0,K.jsx)(`div`,{className:`squisq-template-gallery-grid`,children:m.custom.map(n=>(0,K.jsx)(sy,{def:n,value:e,onSelect:t},n.name))})]}),m.built.length>0&&(0,K.jsx)(`div`,{className:`squisq-template-gallery-grid`,children:m.built.map(n=>(0,K.jsx)(iy,{entry:n,value:e,onSelect:t,previewSource:a},n.name))})]}):(0,K.jsxs)(`div`,{className:`squisq-template-gallery-empty`,children:[`No block types match "`,s,`".`]}):(0,K.jsxs)(K.Fragment,{children:[i&&(0,K.jsxs)(`button`,{type:`button`,className:`squisq-template-gallery-new`,onClick:i,children:[(0,K.jsx)(`span`,{className:`squisq-template-gallery-new-plus`,"aria-hidden":`true`,children:`+`}),(0,K.jsxs)(`span`,{className:`squisq-template-gallery-new-body`,children:[(0,K.jsx)(`span`,{className:`squisq-template-gallery-new-label`,children:`New block type`}),(0,K.jsxs)(`span`,{className:`squisq-template-gallery-new-desc`,children:[`Design a reusable block type with placeholders for `,`{title}`,` and `,`{content}`,`.`]})]})]}),d.length>0&&(0,K.jsxs)(`div`,{className:`squisq-template-gallery-section`,children:[(0,K.jsx)(`h3`,{className:`squisq-template-gallery-section-title`,children:`Custom`}),(0,K.jsx)(`div`,{className:`squisq-template-gallery-grid`,children:d.map(n=>(0,K.jsx)(sy,{def:n,value:e,onSelect:t},n.name))})]}),g.length>0&&(0,K.jsxs)(`div`,{className:`squisq-template-gallery-section`,children:[(0,K.jsx)(`h3`,{className:`squisq-template-gallery-section-title`,children:`Suggested Block Types`}),(0,K.jsx)(`div`,{className:`squisq-template-gallery-grid`,children:g.map(n=>(0,K.jsx)(iy,{entry:n,value:e,onSelect:t,previewSource:a},n.name))})]}),b?(0,K.jsxs)(K.Fragment,{children:[v.length>0&&(0,K.jsxs)(`div`,{className:`squisq-template-gallery-section`,children:[(0,K.jsx)(`h3`,{className:`squisq-template-gallery-section-title`,children:`Block Types`}),(0,K.jsx)(`div`,{className:`squisq-template-gallery-grid`,children:v.map(n=>(0,K.jsx)(iy,{entry:n,value:e,onSelect:t,previewSource:a},n.name))})]}),y.length>0&&(0,K.jsxs)(`div`,{className:`squisq-template-gallery-section`,children:[(0,K.jsx)(`h3`,{className:`squisq-template-gallery-section-title`,children:`Block Types for Content`}),(0,K.jsx)(`div`,{className:`squisq-template-gallery-grid`,children:y.map(n=>(0,K.jsx)(iy,{entry:n,value:e,onSelect:t,previewSource:a},n.name))})]})]}):(0,K.jsx)(`div`,{className:`squisq-template-gallery-grid`,children:v.map(n=>(0,K.jsx)(iy,{entry:n,value:e,onSelect:t,previewSource:a},n.name))})]})]})}function sy({def:e,value:t,onSelect:n}){return(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":t===e.name,className:`squisq-template-gallery-card${t===e.name?` squisq-template-gallery-card--selected`:``}`,onClick:()=>n(e.name),title:e.description??e.label,children:[(0,K.jsx)(`div`,{className:`squisq-template-gallery-card-icon`,children:(0,K.jsx)(Ev,{def:e})}),(0,K.jsxs)(`div`,{className:`squisq-template-gallery-card-body`,children:[(0,K.jsx)(`span`,{className:`squisq-template-gallery-card-name`,children:e.label}),(0,K.jsx)(`span`,{className:`squisq-template-gallery-card-desc`,children:e.description??`Custom block type`})]})]})}function cy({anchorRect:e,value:t,onChange:n,onClose:r,colorScheme:i=`light`,recommended:a,onOpenDesigner:o,previewSource:s}){let[c,l]=(0,G.useState)(()=>dy(e)),u=(0,G.useRef)(null),d=`${Wv}-${(0,G.useId)().replace(/:/g,``)}`;return(0,G.useEffect)(()=>{let t=requestAnimationFrame(()=>l(dy(e)));return()=>cancelAnimationFrame(t)},[e]),(0,G.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()},t=e=>{let t=e.target;u.current?.contains(t)||r()},n=requestAnimationFrame(()=>{document.addEventListener(`mousedown`,t)});return document.addEventListener(`keydown`,e),()=>{cancelAnimationFrame(n),document.removeEventListener(`mousedown`,t),document.removeEventListener(`keydown`,e)}},[r]),(0,Wr.createPortal)((0,K.jsx)(ry,{dialogRef:u,dialogId:d,title:ly(s),colorScheme:i,style:c,onClose:r,children:(0,K.jsx)(oy,{value:t,onSelect:e=>{n(e),r()},style:{},recommended:a,onOpenDesigner:o,previewSource:s})}),document.body)}function ly(e){return`Block Type for ${uy(e)}`}function uy(e){let t=e?.block;return t&&((t.sourceHeading?Ue(t.sourceHeading).trim():``)||t.title||``).replace(/\s+/g,` `).trim()||`this block`}function dy(e){let t=fy(e),n=Math.max(0,t.left),r=Math.max(0,t.top),i=Math.min(window.innerWidth,t.right),a=Math.min(window.innerHeight,t.bottom);return{position:`fixed`,top:r,left:n,width:Math.max(0,i-n),height:Math.max(0,a-r),zIndex:9999}}function fy(e){if(e instanceof Element){let t=e.closest(`.squisq-editor-shell`);if(t)return t.getBoundingClientRect()}else{let t=e.left+e.width/2,n=e.top+e.height/2;for(let e of document.elementsFromPoint(t,n)){let t=e.closest(`.squisq-editor-shell`);if(t)return t.getBoundingClientRect()}}return new DOMRect(0,0,window.innerWidth,window.innerHeight)}var py={type:``,direction:``,duration:``},my=[`transition`,`transitionDirection`,`transitionDuration`],hy=/^(#{1,6}\s+)([\s\S]*)$/;function gy(e){return e?{type:e.transition??``,direction:e.transitionDirection??``,duration:e.transitionDuration??``}:{...py}}function _y(e,t){let n={};for(let[t,r]of Object.entries(e))my.includes(t)||(n[t]=r);return t.type&&(n.transition=t.type,t.direction&&(n.transitionDirection=t.direction),t.duration&&(n.transitionDuration=t.duration)),n}function vy(e){if(!e.params)return e;let t=_y(e.params,py);return Object.keys(t).length>0?e.params=t:delete e.params,e}function yy(e,t){let n=jt(e),r={};for(let e of t?n.slice(1):n){let t=yt(e);t&&(r[t.key]=t.value)}return r}function by(e){if(!e)return{template:void 0,params:{}};let t=jt(e),n=t.length>0&&t[0].indexOf(`=`)>0||t.length===0?void 0:t[0],r=+!!n,i={};for(let e of t.slice(r)){let t=yt(e);t&&(i[t.key]=t.value)}return{template:n,params:i}}function xy(e){let t=Object.entries(e).map(([e,t])=>`${e}=${gt(t)}`);return t.length>0?t.join(` `):null}function Sy(e,t){let n=[];e&&n.push(e);let r=xy(t);return r&&n.push(r),n.length>0?`{[${n.join(` `)}]}`:null}function Cy(e){let t=e.match(hy);if(!t)return null;let n=t[2],r=``,i=wt(n);i&&(r=n.slice(i.index).trim(),n=n.slice(0,i.index));let a=null,o=_t(n);return o&&(a=o.inner,n=n.slice(0,o.index)),{prefix:t[1],text:n.replace(/\s+$/,``),pandocInner:a,templateText:r}}function wy(e){let t=Cy(e);if(!t)return{...py};let n=t.templateText?by(Ey(t.templateText)).params:{},r=t.pandocInner?Et(t.pandocInner).params??{}:{};return gy({...n,...r})}function Ty(e,t){let n=Cy(e);if(!n)return e;let r=n.pandocInner?Et(n.pandocInner):{};vy(r);let i=ky(r),a=by(n.templateText?Ey(n.templateText):null),o=_y(a.params,t),s=Sy(a.template,o),c=n.prefix+n.text;return i&&(c+=` ${i}`),s&&(c+=` ${s}`),c}function Ey(e){let t=e.match(/^\{\[([\s\S]*)\]\}[\s\]}]*$/);return t?t[1]:e}function Dy(e,t){let n=t?yy(t,!1):{},r=e?Et(e).params??{}:{};return gy({...n,...r})}function Oy(e,t,n){let r=e?Et(e):{};vy(r);let i=ky(r),a=_y(yy(t??``,!1),n);return{blockAttrsInner:i?i.slice(1,-1):null,templateParams:xy(a)}}function ky(e){let t=Ct(e);return t==null||t===`{}`?null:t}var Ay=[{title:`Basic`,entries:[{value:`fade`,label:`Fade`},{value:`dissolve`,label:`Dissolve`},{value:`flash`,label:`Flash`},{value:`morph`,label:`Morph`}]},{title:`Slide & Push`,entries:[{value:`push`,label:`Push`,direction:`lrud`},{value:`cover`,label:`Cover`,direction:`lrud`},{value:`uncover`,label:`Uncover`,direction:`lrud`},{value:`pan`,label:`Pan`,direction:`lrud`},{value:`conveyor`,label:`Conveyor`}]},{title:`Reveal & Wipe`,entries:[{value:`wipe`,label:`Wipe`,direction:`lrud`},{value:`reveal`,label:`Reveal`,direction:`lrud`},{value:`split`,label:`Split`,direction:`axis`},{value:`blinds`,label:`Blinds`},{value:`wedge`,label:`Wedge`},{value:`wheel`,label:`Wheel`},{value:`circle`,label:`Circle`},{value:`diamond`,label:`Diamond`},{value:`checkerboard`,label:`Checkerboard`}]},{title:`3D & Motion`,entries:[{value:`zoom`,label:`Zoom`},{value:`cube`,label:`Cube`},{value:`flip`,label:`Flip`},{value:`rotate`,label:`Rotate`},{value:`doors`,label:`Doors`},{value:`box`,label:`Box`},{value:`gallery`,label:`Gallery`},{value:`pageCurl`,label:`Page Curl`},{value:`origami`,label:`Origami`},{value:`ferrisWheel`,label:`Ferris Wheel`},{value:`orbit`,label:`Orbit`},{value:`flyThrough`,label:`Fly Through`}]},{title:`Effects`,entries:[{value:`ripple`,label:`Ripple`},{value:`honeycomb`,label:`Honeycomb`},{value:`glitter`,label:`Glitter`},{value:`vortex`,label:`Vortex`},{value:`shred`,label:`Shred`},{value:`fracture`,label:`Fracture`},{value:`crush`,label:`Crush`},{value:`prestige`,label:`Prestige`},{value:`curtains`,label:`Curtains`},{value:`drape`,label:`Drape`},{value:`wind`,label:`Wind`},{value:`fallOver`,label:`Fall Over`},{value:`peelOff`,label:`Peel Off`},{value:`airplane`,label:`Airplane`}]}],jy=Ay.flatMap(e=>e.entries),My=new Map(jy.map(e=>[e.value,e])),Ny={lrud:[{value:`left`,label:`Left`},{value:`right`,label:`Right`},{value:`up`,label:`Up`},{value:`down`,label:`Down`}],axis:[{value:`horizontal`,label:`Horizontal`},{value:`vertical`,label:`Vertical`}]};function Py(e){return My.get(e)}function Fy(e){if(!e)return`None`;let t=My.get(e);return t?t.label:e.replace(/([A-Z])/g,` $1`).replace(/^./,e=>e.toUpperCase())}var Iy=`squisq-transition-flyout-portal`,Ly=Iy;function Ry({value:e,onChange:t,colorScheme:n=`light`,accentColor:r}){let[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)({}),c=(0,G.useRef)(null);Dh(i,()=>a(!1),c);let l=()=>{if(!c.current)return;let e=c.current.getBoundingClientRect(),t=document.getElementById(Ly),n=t?.getBoundingClientRect()?.width??460,r=t?.scrollHeight??520,i=window.innerWidth,a=window.innerHeight,o=Math.min(Math.max(8,e.left),Math.max(8,i-n-8)),l=a-e.bottom-6-8,u=e.top-6-8,d=l>=r||l>=u,f=d?e.bottom+6:Math.max(8,e.top-6-Math.min(r,u));s({position:`fixed`,top:f,left:o,maxHeight:Math.max(140,d?l:u),zIndex:9999})},u=()=>{l(),a(e=>!e)};(0,G.useEffect)(()=>{if(!i)return;let e=e=>{let t=e.target,n=c.current?.contains(t),r=document.getElementById(Ly)?.contains(t);!n&&!r&&a(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[i]),(0,G.useEffect)(()=>{if(!i)return;requestAnimationFrame(l);let e=()=>l();return window.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,e)}},[i]);let d=i?(0,Wr.createPortal)((0,K.jsx)(zy,{style:{...o,...By(r)},value:e,onChange:t,colorScheme:n}),document.body):null;return(0,K.jsxs)(`div`,{className:`squisq-transition-picker`,"data-theme":n,style:By(r),children:[(0,K.jsxs)(`button`,{ref:c,type:`button`,className:`squisq-transition-picker-trigger${i?` squisq-transition-picker-trigger--open`:``}`,onClick:u,"aria-haspopup":`menu`,"aria-expanded":i,title:`Block transition`,children:[(0,K.jsx)(`span`,{className:`squisq-transition-picker-trigger-label`,children:`Transition:`}),(0,K.jsx)(`span`,{className:`squisq-transition-picker-trigger-value`,children:Fy(e.type)}),(0,K.jsx)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 10 10`,"aria-hidden":`true`,children:(0,K.jsx)(`path`,{d:`M2 3.5l3 3 3-3`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,fill:`none`})})]}),d]})}function zy({style:e,value:t,onChange:n,colorScheme:r}){let[i,a]=(0,G.useState)(``),o=(0,G.useRef)(null);(0,G.useEffect)(()=>{o.current?.focus()},[]);let s=i.trim().toLowerCase(),c=s.length>0,l=(0,G.useMemo)(()=>c?jy.filter(e=>e.label.toLowerCase().includes(s)||e.value.toLowerCase().includes(s)):null,[c,s]),u=Py(t.type),d=e=>{if(!e){n({...py});return}n({type:e.value,direction:e.direction?t.direction:``,duration:t.duration})},f=e=>{n({...t,direction:t.direction===e?``:e})},p=e=>{n({...t,duration:e.trim()})};return(0,K.jsxs)(`div`,{id:Ly,className:`squisq-transition-flyout`,"data-theme":r,role:`menu`,style:e,children:[(0,K.jsx)(`div`,{className:`squisq-transition-flyout-search`,children:(0,K.jsx)(`input`,{ref:o,type:`search`,className:`squisq-transition-flyout-search-input`,placeholder:`Search transitions…`,value:i,onChange:e=>a(e.target.value),"aria-label":`Search transitions`})}),(0,K.jsxs)(`div`,{className:`squisq-transition-flyout-list`,children:[(0,K.jsx)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":t.type===``,className:`squisq-transition-option${t.type===``?` squisq-transition-option--selected`:``}`,onClick:()=>d(null),children:`None`}),c?l&&l.length>0?(0,K.jsx)(`div`,{className:`squisq-transition-flyout-grid`,children:l.map(e=>(0,K.jsx)(Vy,{entry:e,selected:t.type===e.value,direction:t.type===e.value?t.direction:void 0,onSelect:()=>d(e)},e.value))}):(0,K.jsxs)(`div`,{className:`squisq-transition-flyout-empty`,children:[`No transitions match “`,i,`”.`]}):Ay.map(e=>(0,K.jsxs)(`div`,{className:`squisq-transition-flyout-group`,children:[(0,K.jsx)(`h4`,{className:`squisq-transition-flyout-group-title`,children:e.title}),(0,K.jsx)(`div`,{className:`squisq-transition-flyout-grid`,children:e.entries.map(e=>(0,K.jsx)(Vy,{entry:e,selected:t.type===e.value,direction:t.type===e.value?t.direction:void 0,onSelect:()=>d(e)},e.value))})]},e.title))]}),t.type&&(0,K.jsxs)(`div`,{className:`squisq-transition-flyout-controls`,children:[u?.direction&&(0,K.jsxs)(`div`,{className:`squisq-transition-flyout-control`,children:[(0,K.jsx)(`span`,{className:`squisq-transition-flyout-control-label`,children:`Direction`}),(0,K.jsx)(`div`,{className:`squisq-transition-direction-row`,children:Ny[u.direction].map(e=>(0,K.jsx)(`button`,{type:`button`,className:`squisq-transition-direction-button${t.direction===e.value?` squisq-transition-direction-button--selected`:``}`,onClick:()=>f(e.value),children:e.label},e.value))})]}),(0,K.jsxs)(`div`,{className:`squisq-transition-flyout-control`,children:[(0,K.jsx)(`span`,{className:`squisq-transition-flyout-control-label`,children:`Duration`}),(0,K.jsxs)(`div`,{className:`squisq-transition-duration-row`,children:[(0,K.jsx)(`input`,{type:`number`,min:`0`,step:`0.1`,className:`squisq-transition-duration-input`,placeholder:`0.7`,value:t.duration,onChange:e=>p(e.target.value),"aria-label":`Transition duration in seconds`}),(0,K.jsx)(`span`,{className:`squisq-transition-duration-unit`,children:`sec`})]})]})]})]})}function By(e){return e?{"--squisq-block-props-accent":e}:{}}function Vy({entry:e,selected:t,direction:n,onSelect:r}){let[i,a]=(0,G.useState)(!1),o=i&&e.value?je(e.value,!0,Hy(n)):``;return(0,K.jsx)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":t,className:`squisq-transition-option${t?` squisq-transition-option--selected`:``}`,onClick:r,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:(0,K.jsx)(`span`,{className:`squisq-transition-option-label ${o}`,children:e.label})})}function Hy(e){return e||void 0}function Uy(e,t,n){if(!e)return``;let r=Object.prototype.hasOwnProperty.call(e,t)?e[t]:e[n];return typeof r==`string`?r:``}var Wy=[{key:``,label:`Default (Standard)`},{key:`standard`,label:`Standard`},{key:`social`,label:`Social`}];function Gy({markdownSource:e,onSave:t,onClose:n}){let r=(0,G.useMemo)(()=>Tt(e),[e]),i=r.frontmatter,a=(0,G.useMemo)(()=>ze(r),[r]),o=(0,G.useMemo)(()=>B({...r,frontmatter:{...r.frontmatter,subtitle:null}}).startBlock?.subtitle,[r]),s=typeof i?.title==`string`?i.title:``,c=typeof i?.subtitle==`string`?i.subtitle:``,l=He(i)??``,u=Og(Uy(i,Z.transform.canonical,Z.transform.legacy))??``,d=Uy(i,Z.captions.canonical,Z.captions.legacy),[f,p]=(0,G.useState)(s),[m,h]=(0,G.useState)(c),[g,_]=(0,G.useState)(l),[v,y]=(0,G.useState)(u),[b,x]=(0,G.useState)(d),S=av(),C=Uy(i,cn.enabled.canonical,cn.enabled.legacy).toLowerCase(),w=Uy(i,cn.dialect.canonical,cn.dialect.legacy),[T,E]=(0,G.useState)(typeof i?.[cn.enabled.canonical]==`boolean`?String(i[cn.enabled.canonical]):C===`true`||C===`false`?C:``),[D,O]=(0,G.useState)(w),k=(0,G.useRef)(null),A=(0,G.useRef)(null),j=(0,G.useRef)(null),M=(0,G.useId)();Ur({rootRef:k,dialogRef:A,initialFocusRef:j,onClose:n});let N=(0,G.useCallback)(e=>{e.target===e.currentTarget&&n()},[n]),P=(0,G.useMemo)(()=>[{key:``,label:`None`},...qn().map(e=>({key:e.id,label:e.name}))],[]);return(0,K.jsx)(`div`,{ref:k,className:`squisq-doc-settings-overlay`,onMouseDown:N,children:(0,K.jsxs)(`form`,{ref:A,className:`squisq-doc-settings-dialog`,onSubmit:(0,G.useCallback)(n=>{n.preventDefault();let r=f.trim(),i=!r||a&&r===a?null:r,s=m.trim(),c=!!o&&s===o.trim(),l={title:i,subtitle:!s||c?null:s,[Z.theme.canonical]:Ag(g||kg.theme,kg.theme),[Z.theme.legacy[0]]:null,[Z.theme.legacy[1]]:null,[Z.transform.canonical]:Ag(v,kg.transform),[Z.transform.legacy]:null,[Z.captions.canonical]:Ag(b||kg.captions,kg.captions),[Z.captions.legacy]:null},u=S?{[cn.enabled.canonical]:T===``?null:T===`true`,[cn.enabled.legacy]:null,[cn.dialect.canonical]:D||null,[cn.dialect.legacy]:null}:{};t(We(e,{...l,...u}))},[f,m,g,v,b,S,T,D,a,o,e,t]),role:`dialog`,"aria-modal":`true`,"aria-labelledby":M,tabIndex:-1,children:[(0,K.jsxs)(`div`,{className:`squisq-doc-settings-header`,children:[(0,K.jsx)(`h2`,{id:M,className:`squisq-doc-settings-title`,children:`Document settings`}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-doc-settings-close`,onClick:n,"aria-label":`Close`,children:`×`})]}),(0,K.jsxs)(`div`,{className:`squisq-doc-settings-body`,children:[(0,K.jsxs)(`div`,{className:`squisq-doc-settings-field`,children:[(0,K.jsx)(`label`,{className:`squisq-doc-settings-label`,htmlFor:`squisq-doc-settings-title`,children:`Title`}),(0,K.jsx)(`input`,{ref:j,id:`squisq-doc-settings-title`,type:`text`,className:`squisq-doc-settings-input`,value:f,onChange:e=>p(e.target.value),placeholder:a??`Document title`,spellCheck:!0}),a?(0,K.jsxs)(`span`,{className:`squisq-doc-settings-hint`,children:[`Defaults to `,(0,K.jsx)(`strong`,{children:a}),` — leave blank to use it.`]}):(0,K.jsx)(`span`,{className:`squisq-doc-settings-hint`,children:`No title heading found — set one here or add an H1 to the document.`})]}),(0,K.jsxs)(`div`,{className:`squisq-doc-settings-field`,children:[(0,K.jsx)(`label`,{className:`squisq-doc-settings-label`,htmlFor:`squisq-doc-settings-subtitle`,children:`Subtitle`}),(0,K.jsx)(`input`,{id:`squisq-doc-settings-subtitle`,type:`text`,className:`squisq-doc-settings-input`,value:m,onChange:e=>h(e.target.value),placeholder:o??`Cover subtitle`,spellCheck:!0}),o?(0,K.jsxs)(`span`,{className:`squisq-doc-settings-hint`,children:[`Defaults to `,(0,K.jsx)(`strong`,{children:o}),` — leave blank to use it.`]}):(0,K.jsx)(`span`,{className:`squisq-doc-settings-hint`,children:`Optional supporting text shown on the document cover.`})]}),(0,K.jsxs)(`div`,{className:`squisq-doc-settings-field`,children:[(0,K.jsx)(`span`,{className:`squisq-doc-settings-label`,children:`Theme`}),(0,K.jsx)(zh,{value:g,onChange:_,includeDefault:!0,variant:`full`,ariaLabel:`Theme`})]}),(0,K.jsxs)(`div`,{className:`squisq-doc-settings-field`,children:[(0,K.jsx)(`label`,{className:`squisq-doc-settings-label`,htmlFor:`squisq-doc-settings-transform`,children:`Transform`}),(0,K.jsx)(`select`,{id:`squisq-doc-settings-transform`,className:`squisq-doc-settings-input`,value:v,onChange:e=>y(e.target.value),children:P.map(e=>(0,K.jsx)(`option`,{value:e.key,children:e.label},e.key))})]}),(0,K.jsxs)(`div`,{className:`squisq-doc-settings-field`,children:[(0,K.jsx)(`label`,{className:`squisq-doc-settings-label`,htmlFor:`squisq-doc-settings-captions`,children:`Captions`}),(0,K.jsx)(`select`,{id:`squisq-doc-settings-captions`,className:`squisq-doc-settings-input`,value:b,onChange:e=>x(e.target.value),children:Wy.map(e=>(0,K.jsx)(`option`,{value:e.key,children:e.label},e.key))})]}),S&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`squisq-doc-settings-field`,children:[(0,K.jsx)(`label`,{className:`squisq-doc-settings-label`,htmlFor:`squisq-doc-settings-proofing`,children:`Proofing`}),(0,K.jsxs)(`select`,{id:`squisq-doc-settings-proofing`,className:`squisq-doc-settings-input`,value:T,onChange:e=>E(e.target.value),children:[(0,K.jsx)(`option`,{value:``,children:`Default`}),(0,K.jsx)(`option`,{value:`true`,children:`On`}),(0,K.jsx)(`option`,{value:`false`,children:`Off`})]})]}),(0,K.jsxs)(`div`,{className:`squisq-doc-settings-field`,children:[(0,K.jsx)(`label`,{className:`squisq-doc-settings-label`,htmlFor:`squisq-doc-settings-proof-dialect`,children:`Proofing dialect`}),(0,K.jsxs)(`select`,{id:`squisq-doc-settings-proof-dialect`,className:`squisq-doc-settings-input`,value:D,onChange:e=>O(e.target.value),children:[(0,K.jsx)(`option`,{value:``,children:`Default (American)`}),Fn.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]})]})]})]}),(0,K.jsxs)(`div`,{className:`squisq-doc-settings-footer`,children:[(0,K.jsx)(`button`,{type:`button`,className:`squisq-doc-settings-btn squisq-doc-settings-btn--secondary`,onClick:n,children:`Cancel`}),(0,K.jsx)(`button`,{type:`submit`,className:`squisq-doc-settings-btn squisq-doc-settings-btn--primary`,children:`Save`})]})]})})}function $(e,t,...n){return{char:e,name:t,keywords:[t,...n].join(` `).toLowerCase()}}var Ky=[{id:`smileys`,label:`Smileys`,icon:`😀`,emojis:[$(`😀`,`grinning`),$(`😃`,`smiley`),$(`😄`,`smile`,`happy`),$(`😁`,`grin`,`beaming`),$(`😆`,`laughing`),$(`😅`,`sweat smile`),$(`🤣`,`rofl`,`rolling laughing`),$(`😂`,`joy`,`laughing tears`),$(`🙂`,`slight smile`),$(`🙃`,`upside down`),$(`😉`,`wink`),$(`😊`,`blush`),$(`😇`,`innocent`,`halo`),$(`🥰`,`smiling hearts`),$(`😍`,`heart eyes`),$(`🤩`,`star struck`),$(`😘`,`kiss`,`blow kiss`),$(`😗`,`kissing`),$(`😚`,`kissing closed eyes`),$(`😙`,`kissing smile`),$(`🥲`,`smiling tear`),$(`😋`,`yum`,`tongue`),$(`😛`,`tongue out`),$(`😜`,`wink tongue`),$(`🤪`,`zany`,`crazy`),$(`😝`,`squint tongue`),$(`🤑`,`money face`),$(`🤗`,`hugging`),$(`🤭`,`hand over mouth`),$(`🤫`,`shushing`),$(`🤔`,`thinking`),$(`🤐`,`zipper mouth`),$(`🤨`,`raised eyebrow`),$(`😐`,`neutral`),$(`😑`,`expressionless`),$(`😶`,`no mouth`),$(`😏`,`smirk`),$(`😒`,`unamused`),$(`🙄`,`eye roll`),$(`😬`,`grimace`),$(`🤥`,`lying`,`pinocchio`),$(`😌`,`relieved`),$(`😔`,`pensive`),$(`😪`,`sleepy`),$(`🤤`,`drool`),$(`😴`,`sleeping`,`zzz`),$(`😷`,`mask`),$(`🤒`,`thermometer face`),$(`🤕`,`head bandage`),$(`🤢`,`nauseated`),$(`🤮`,`vomiting`),$(`🤧`,`sneeze`),$(`🥵`,`hot face`),$(`🥶`,`cold face`),$(`🥴`,`woozy`),$(`😵`,`dizzy`),$(`🤯`,`mind blown`,`exploding head`),$(`🤠`,`cowboy`),$(`🥳`,`partying`),$(`🥸`,`disguised`),$(`😎`,`sunglasses`,`cool`),$(`🤓`,`nerd`,`glasses`),$(`🧐`,`monocle`),$(`😕`,`confused`),$(`😟`,`worried`),$(`🙁`,`slight frown`),$(`☹️`,`frown`),$(`😮`,`open mouth`),$(`😯`,`hushed`),$(`😲`,`astonished`),$(`😳`,`flushed`),$(`🥺`,`pleading`),$(`😦`,`frowning open mouth`),$(`😧`,`anguished`),$(`😨`,`fearful`),$(`😰`,`anxious sweat`),$(`😥`,`sad relieved`),$(`😢`,`cry`),$(`😭`,`sobbing`,`loud cry`),$(`😱`,`screaming`,`shocked`),$(`😖`,`confounded`),$(`😣`,`persevering`),$(`😞`,`disappointed`),$(`😓`,`downcast sweat`),$(`😩`,`weary`),$(`😫`,`tired`),$(`😤`,`triumph`),$(`😡`,`pout`,`red angry`),$(`😠`,`angry`),$(`🤬`,`cursing`,`symbols`),$(`😈`,`smiling devil`),$(`👿`,`angry devil`),$(`💀`,`skull`),$(`💩`,`poop`,`pile`),$(`🤡`,`clown`),$(`👻`,`ghost`),$(`👽`,`alien`),$(`🤖`,`robot`),$(`🎃`,`jack o lantern`,`pumpkin`)]},{id:`people`,label:`People`,icon:`👋`,emojis:[$(`👋`,`wave`,`hello`),$(`🤚`,`raised back hand`),$(`🖐️`,`raised hand fingers`),$(`✋`,`raised hand`,`stop`),$(`🖖`,`vulcan`),$(`👌`,`ok hand`),$(`🤌`,`pinched fingers`),$(`🤏`,`pinching`),$(`✌️`,`peace`),$(`🤞`,`crossed fingers`,`luck`),$(`🤟`,`love you gesture`),$(`🤘`,`rock on`,`horns`),$(`🤙`,`call me`),$(`👈`,`point left`),$(`👉`,`point right`),$(`👆`,`point up`),$(`👇`,`point down`),$(`☝️`,`index up`),$(`👍`,`thumbs up`,`like`),$(`👎`,`thumbs down`,`dislike`),$(`✊`,`raised fist`),$(`👊`,`oncoming fist`,`punch`),$(`🤛`,`left fist`,`bump`),$(`🤜`,`right fist`),$(`👏`,`clap`),$(`🙌`,`raised hands`,`praise`),$(`👐`,`open hands`),$(`🤲`,`palms up`),$(`🤝`,`handshake`),$(`🙏`,`pray`,`thanks`),$(`💪`,`muscle`,`strong`),$(`🦵`,`leg`),$(`🦶`,`foot`),$(`👂`,`ear`),$(`🦻`,`ear hearing aid`),$(`👃`,`nose`),$(`🧠`,`brain`),$(`🫀`,`heart anatomy`),$(`🫁`,`lungs`),$(`🦷`,`tooth`),$(`🦴`,`bone`),$(`👀`,`eyes`),$(`👁️`,`eye`),$(`👅`,`tongue`),$(`👄`,`mouth`),$(`💋`,`lipstick kiss`),$(`👶`,`baby`),$(`🧒`,`child`),$(`👦`,`boy`),$(`👧`,`girl`),$(`🧑`,`person`),$(`👨`,`man`),$(`👩`,`woman`),$(`🧓`,`older person`),$(`👴`,`old man`),$(`👵`,`old woman`),$(`👮`,`police`),$(`🕵️`,`detective`),$(`💂`,`guard`),$(`🧑⚕️`,`health worker`),$(`🧑🎓`,`student`),$(`🧑🏫`,`teacher`),$(`🧑🔧`,`mechanic`),$(`🧑💻`,`technologist`,`developer`),$(`🧑🎨`,`artist`),$(`🧑🚀`,`astronaut`),$(`🧑🚒`,`firefighter`),$(`👷`,`construction worker`),$(`🤴`,`prince`),$(`👸`,`princess`),$(`🦸`,`superhero`),$(`🦹`,`supervillain`),$(`🧙`,`mage`,`wizard`),$(`🧚`,`fairy`),$(`🧛`,`vampire`),$(`🧜`,`merperson`),$(`🧝`,`elf`),$(`🧞`,`genie`),$(`🧟`,`zombie`)]},{id:`nature`,label:`Nature`,icon:`🌿`,emojis:[$(`🐶`,`dog face`),$(`🐱`,`cat face`),$(`🐭`,`mouse`),$(`🐹`,`hamster`),$(`🐰`,`rabbit face`),$(`🦊`,`fox`),$(`🐻`,`bear`),$(`🐼`,`panda`),$(`🐻❄️`,`polar bear`),$(`🐨`,`koala`),$(`🐯`,`tiger face`),$(`🦁`,`lion`),$(`🐮`,`cow face`),$(`🐷`,`pig face`),$(`🐽`,`pig nose`),$(`🐸`,`frog`),$(`🐵`,`monkey face`),$(`🙈`,`see no evil`),$(`🙉`,`hear no evil`),$(`🙊`,`speak no evil`),$(`🐒`,`monkey`),$(`🐔`,`chicken`),$(`🐧`,`penguin`),$(`🐦`,`bird`),$(`🐤`,`baby chick`),$(`🐣`,`hatching chick`),$(`🦆`,`duck`),$(`🦅`,`eagle`),$(`🦉`,`owl`),$(`🦇`,`bat`),$(`🐺`,`wolf`),$(`🐗`,`boar`),$(`🐴`,`horse face`),$(`🦄`,`unicorn`),$(`🐝`,`bee`),$(`🐛`,`bug`),$(`🦋`,`butterfly`),$(`🐌`,`snail`),$(`🐞`,`lady beetle`),$(`🐜`,`ant`),$(`🦂`,`scorpion`),$(`🕷️`,`spider`),$(`🐢`,`turtle`),$(`🐍`,`snake`),$(`🦖`,`trex`),$(`🦕`,`sauropod`),$(`🐙`,`octopus`),$(`🦑`,`squid`),$(`🦐`,`shrimp`),$(`🦞`,`lobster`),$(`🦀`,`crab`),$(`🐡`,`blowfish`),$(`🐠`,`tropical fish`),$(`🐟`,`fish`),$(`🐬`,`dolphin`),$(`🐳`,`spouting whale`),$(`🐋`,`whale`),$(`🦈`,`shark`),$(`🐊`,`crocodile`),$(`🐅`,`tiger`),$(`🐆`,`leopard`),$(`🦓`,`zebra`),$(`🦍`,`gorilla`),$(`🦧`,`orangutan`),$(`🐘`,`elephant`),$(`🦛`,`hippopotamus`),$(`🦏`,`rhinoceros`),$(`🐪`,`camel`),$(`🐫`,`two hump camel`),$(`🦒`,`giraffe`),$(`🦘`,`kangaroo`),$(`🐃`,`water buffalo`),$(`🐂`,`ox`),$(`🐄`,`cow`),$(`🐎`,`horse`),$(`🐖`,`pig`),$(`🐏`,`ram`),$(`🐑`,`ewe`),$(`🦙`,`llama`),$(`🐐`,`goat`),$(`🦌`,`deer`),$(`🐕`,`dog`),$(`🐩`,`poodle`),$(`🦮`,`guide dog`),$(`🐕🦺`,`service dog`),$(`🐈`,`cat`),$(`🐈⬛`,`black cat`),$(`🐓`,`rooster`),$(`🦃`,`turkey`),$(`🦚`,`peacock`),$(`🦜`,`parrot`),$(`🦢`,`swan`),$(`🌲`,`evergreen tree`),$(`🌳`,`deciduous tree`),$(`🌴`,`palm tree`),$(`🌵`,`cactus`),$(`🌷`,`tulip`),$(`🌸`,`cherry blossom`),$(`🌹`,`rose`),$(`🥀`,`wilted flower`),$(`🌺`,`hibiscus`),$(`🌻`,`sunflower`),$(`🌼`,`blossom`),$(`🌱`,`seedling`),$(`🪴`,`potted plant`),$(`🌿`,`herb`),$(`☘️`,`shamrock`),$(`🍀`,`four leaf clover`),$(`🍁`,`maple leaf`),$(`🍂`,`fallen leaf`),$(`🍃`,`leaf wind`),$(`🌞`,`sun face`),$(`☀️`,`sun`),$(`🌝`,`full moon face`),$(`🌚`,`new moon face`),$(`🌛`,`first quarter moon face`),$(`🌜`,`last quarter moon face`),$(`🌙`,`crescent moon`),$(`🌎`,`earth americas`),$(`🌍`,`earth europe africa`),$(`🌏`,`earth asia australia`),$(`🪐`,`ringed planet`),$(`⭐`,`star`),$(`🌟`,`glowing star`),$(`✨`,`sparkles`),$(`⚡`,`lightning`,`bolt`),$(`☄️`,`comet`),$(`🔥`,`fire`),$(`💥`,`collision`,`boom`),$(`🌈`,`rainbow`),$(`☁️`,`cloud`),$(`⛅`,`sun behind cloud`),$(`🌧️`,`rain cloud`),$(`⛈️`,`thunder cloud`),$(`🌩️`,`lightning cloud`),$(`🌨️`,`snow cloud`),$(`❄️`,`snowflake`),$(`⛄`,`snowman`),$(`🌪️`,`tornado`),$(`🌫️`,`fog`),$(`🌊`,`wave`),$(`💧`,`droplet`),$(`💦`,`sweat drops`)]},{id:`food`,label:`Food`,icon:`🍎`,emojis:[$(`🍏`,`green apple`),$(`🍎`,`red apple`),$(`🍐`,`pear`),$(`🍊`,`tangerine`,`orange`),$(`🍋`,`lemon`),$(`🍌`,`banana`),$(`🍉`,`watermelon`),$(`🍇`,`grapes`),$(`🍓`,`strawberry`),$(`🫐`,`blueberries`),$(`🍈`,`melon`),$(`🍒`,`cherries`),$(`🍑`,`peach`),$(`🥭`,`mango`),$(`🍍`,`pineapple`),$(`🥥`,`coconut`),$(`🥝`,`kiwi`),$(`🍅`,`tomato`),$(`🍆`,`eggplant`),$(`🥑`,`avocado`),$(`🥦`,`broccoli`),$(`🥬`,`leafy green`),$(`🥒`,`cucumber`),$(`🌶️`,`pepper`),$(`🫑`,`bell pepper`),$(`🌽`,`corn`),$(`🥕`,`carrot`),$(`🫒`,`olive`),$(`🧄`,`garlic`),$(`🧅`,`onion`),$(`🥔`,`potato`),$(`🍠`,`sweet potato`),$(`🥐`,`croissant`),$(`🥯`,`bagel`),$(`🍞`,`bread`),$(`🥖`,`baguette`),$(`🥨`,`pretzel`),$(`🧀`,`cheese`),$(`🥚`,`egg`),$(`🍳`,`cooking`,`frying`),$(`🧈`,`butter`),$(`🥞`,`pancakes`),$(`🧇`,`waffle`),$(`🥓`,`bacon`),$(`🥩`,`cut of meat`),$(`🍗`,`poultry leg`),$(`🍖`,`meat on bone`),$(`🌭`,`hot dog`),$(`🍔`,`hamburger`),$(`🍟`,`fries`),$(`🍕`,`pizza`),$(`🥪`,`sandwich`),$(`🌮`,`taco`),$(`🌯`,`burrito`),$(`🥙`,`stuffed flatbread`),$(`🧆`,`falafel`),$(`🥗`,`salad`),$(`🥘`,`shallow pan of food`),$(`🍝`,`spaghetti`),$(`🍜`,`steaming bowl`),$(`🍲`,`pot of food`),$(`🍛`,`curry`),$(`🍣`,`sushi`),$(`🍱`,`bento`),$(`🥟`,`dumpling`),$(`🍤`,`shrimp tempura`),$(`🍙`,`rice ball`),$(`🍚`,`rice`),$(`🍘`,`rice cracker`),$(`🥠`,`fortune cookie`),$(`🥮`,`moon cake`),$(`🍢`,`oden`),$(`🍡`,`dango`),$(`🦪`,`oyster`),$(`🍦`,`soft serve`),$(`🍧`,`shaved ice`),$(`🍨`,`ice cream`),$(`🍩`,`doughnut`),$(`🍪`,`cookie`),$(`🎂`,`birthday cake`),$(`🍰`,`shortcake`),$(`🧁`,`cupcake`),$(`🥧`,`pie`),$(`🍫`,`chocolate bar`),$(`🍬`,`candy`),$(`🍭`,`lollipop`),$(`🍮`,`custard`),$(`🍯`,`honey`),$(`🍼`,`baby bottle`),$(`🥛`,`milk`),$(`☕`,`coffee`),$(`🫖`,`teapot`),$(`🍵`,`tea`),$(`🍶`,`sake`),$(`🍾`,`champagne`),$(`🍷`,`wine glass`),$(`🍸`,`cocktail`),$(`🍹`,`tropical drink`),$(`🍺`,`beer`),$(`🍻`,`clink beers`),$(`🥂`,`clink champagne`),$(`🥃`,`tumbler`),$(`🥤`,`cup straw`),$(`🧋`,`bubble tea`),$(`🧃`,`juice box`),$(`🧉`,`mate`),$(`🧊`,`ice cube`)]},{id:`travel`,label:`Travel`,icon:`✈️`,emojis:[$(`🚗`,`car`),$(`🚕`,`taxi`),$(`🚙`,`suv`),$(`🚌`,`bus`),$(`🚎`,`trolleybus`),$(`🏎️`,`racing car`),$(`🚓`,`police car`),$(`🚑`,`ambulance`),$(`🚒`,`fire engine`),$(`🚐`,`minibus`),$(`🛻`,`pickup truck`),$(`🚚`,`delivery truck`),$(`🚛`,`semi truck`),$(`🚜`,`tractor`),$(`🛵`,`motor scooter`),$(`🏍️`,`motorcycle`),$(`🚲`,`bicycle`),$(`🛴`,`kick scooter`),$(`🛹`,`skateboard`),$(`🛼`,`roller skate`),$(`🚂`,`locomotive`),$(`🚃`,`railway car`),$(`🚄`,`high speed train`),$(`🚅`,`bullet train`),$(`🚆`,`train`),$(`🚇`,`metro`),$(`🚈`,`light rail`),$(`🚉`,`station`),$(`🚝`,`monorail`),$(`🚞`,`mountain railway`),$(`🚋`,`tram`),$(`🚊`,`tram car`),$(`🚟`,`suspension railway`),$(`🚠`,`mountain cableway`),$(`🚡`,`aerial tramway`),$(`✈️`,`airplane`),$(`🛫`,`departing`),$(`🛬`,`arriving`),$(`🛩️`,`small airplane`),$(`🚁`,`helicopter`),$(`🛸`,`flying saucer`),$(`🚀`,`rocket`),$(`🛰️`,`satellite`),$(`🛶`,`canoe`),$(`⛵`,`sailboat`),$(`🚤`,`speedboat`),$(`🛥️`,`motor boat`),$(`🛳️`,`passenger ship`),$(`⛴️`,`ferry`),$(`🚢`,`ship`),$(`⚓`,`anchor`),$(`🪝`,`hook`),$(`⛽`,`fuel pump`),$(`🚧`,`construction`),$(`🚦`,`traffic light`),$(`🚥`,`horizontal traffic light`),$(`🗺️`,`map`),$(`🗿`,`moai`),$(`🗽`,`statue of liberty`),$(`🗼`,`tokyo tower`),$(`🏰`,`castle`),$(`🏯`,`japanese castle`),$(`🏟️`,`stadium`),$(`🎡`,`ferris wheel`),$(`🎢`,`roller coaster`),$(`🎠`,`carousel`),$(`⛲`,`fountain`),$(`⛱️`,`umbrella ground`),$(`🏖️`,`beach umbrella`),$(`🏝️`,`desert island`),$(`🏜️`,`desert`),$(`🌋`,`volcano`),$(`⛰️`,`mountain`),$(`🏔️`,`snow mountain`),$(`🗻`,`mount fuji`),$(`🏕️`,`camping`),$(`⛺`,`tent`),$(`🛖`,`hut`),$(`🏠`,`house`),$(`🏡`,`house with garden`),$(`🏘️`,`houses`),$(`🏚️`,`derelict house`),$(`🏗️`,`construction site`),$(`🏭`,`factory`),$(`🏢`,`office building`),$(`🏬`,`department store`),$(`🏣`,`japanese post office`),$(`🏤`,`post office`),$(`🏥`,`hospital`),$(`🏦`,`bank`),$(`🏨`,`hotel`),$(`🏪`,`convenience store`),$(`🏫`,`school`),$(`🏩`,`love hotel`),$(`💒`,`wedding`),$(`🏛️`,`classical building`),$(`⛪`,`church`),$(`🕌`,`mosque`),$(`🛕`,`hindu temple`),$(`🕍`,`synagogue`),$(`⛩️`,`shrine`),$(`🌁`,`foggy city`),$(`🌃`,`night stars`),$(`🌄`,`sunrise mountains`),$(`🌅`,`sunrise`),$(`🌆`,`cityscape dusk`),$(`🌇`,`sunset`),$(`🌉`,`bridge night`),$(`♨️`,`hot springs`),$(`🎑`,`moon viewing`),$(`🏞️`,`national park`)]},{id:`activities`,label:`Activities`,icon:`⚽`,emojis:[$(`⚽`,`soccer`),$(`🏀`,`basketball`),$(`🏈`,`football`),$(`⚾`,`baseball`),$(`🥎`,`softball`),$(`🎾`,`tennis`),$(`🏐`,`volleyball`),$(`🏉`,`rugby`),$(`🥏`,`flying disc`,`frisbee`),$(`🎱`,`pool`,`eight ball`),$(`🪀`,`yoyo`),$(`🏓`,`ping pong`),$(`🏸`,`badminton`),$(`🏒`,`ice hockey`),$(`🏑`,`field hockey`),$(`🥍`,`lacrosse`),$(`🏏`,`cricket`),$(`🪃`,`boomerang`),$(`🥅`,`goal net`),$(`⛳`,`flag in hole`,`golf`),$(`🪁`,`kite`),$(`🏹`,`bow and arrow`),$(`🎣`,`fishing`),$(`🤿`,`diving mask`),$(`🥊`,`boxing glove`),$(`🥋`,`martial arts`),$(`🎽`,`running shirt`),$(`🛹`,`skateboard`),$(`🛼`,`roller skate`),$(`🛷`,`sled`),$(`⛸️`,`ice skate`),$(`🥌`,`curling stone`),$(`🎿`,`skis`),$(`⛷️`,`skier`),$(`🏂`,`snowboarder`),$(`🪂`,`parachute`),$(`🏋️`,`weight lifting`),$(`🤼`,`wrestling`),$(`🤸`,`cartwheel`),$(`⛹️`,`bouncing ball`),$(`🤺`,`fencing`),$(`🤾`,`handball`),$(`🏌️`,`golfing`),$(`🏇`,`horse racing`),$(`🧘`,`meditation`,`yoga`),$(`🏄`,`surfing`),$(`🏊`,`swimming`),$(`🤽`,`water polo`),$(`🚣`,`rowing`),$(`🧗`,`climbing`),$(`🚵`,`mountain biker`),$(`🚴`,`biker`),$(`🏆`,`trophy`),$(`🥇`,`gold medal`),$(`🥈`,`silver medal`),$(`🥉`,`bronze medal`),$(`🏅`,`sports medal`),$(`🎖️`,`military medal`),$(`🏵️`,`rosette`),$(`🎗️`,`reminder ribbon`),$(`🎫`,`ticket`),$(`🎟️`,`admission tickets`),$(`🎪`,`circus tent`),$(`🎭`,`theatre masks`),$(`🎨`,`art palette`),$(`🎬`,`clapper board`),$(`🎤`,`microphone`),$(`🎧`,`headphone`),$(`🎼`,`musical score`),$(`🎹`,`piano`),$(`🥁`,`drum`),$(`🪘`,`long drum`),$(`🎷`,`saxophone`),$(`🎺`,`trumpet`),$(`🎸`,`guitar`),$(`🪕`,`banjo`),$(`🎻`,`violin`),$(`🪗`,`accordion`),$(`🎲`,`game die`),$(`♟️`,`chess pawn`),$(`🎯`,`bullseye`,`dart`),$(`🎳`,`bowling`),$(`🎮`,`video game`),$(`🎰`,`slot machine`),$(`🧩`,`jigsaw`)]},{id:`objects`,label:`Objects`,icon:`💡`,emojis:[$(`💡`,`light bulb`,`idea`),$(`🔦`,`flashlight`),$(`🕯️`,`candle`),$(`🪔`,`diya lamp`),$(`🧯`,`fire extinguisher`),$(`🛢️`,`oil drum`),$(`💸`,`money wings`),$(`💵`,`dollar`),$(`💴`,`yen banknote`),$(`💶`,`euro banknote`),$(`💷`,`pound banknote`),$(`💰`,`money bag`),$(`💳`,`credit card`),$(`💎`,`gem`),$(`⚖️`,`balance scale`),$(`🪜`,`ladder`),$(`🧰`,`toolbox`),$(`🔧`,`wrench`),$(`🪛`,`screwdriver`),$(`🔨`,`hammer`),$(`⚒️`,`hammer and pick`),$(`🛠️`,`hammer and wrench`),$(`⛏️`,`pick`),$(`🪚`,`saw`),$(`🔩`,`nut and bolt`),$(`⚙️`,`gear`),$(`🧱`,`brick`),$(`⛓️`,`chains`),$(`🧲`,`magnet`),$(`🔫`,`water pistol`),$(`💣`,`bomb`),$(`🧨`,`firecracker`),$(`🪓`,`axe`),$(`🔪`,`kitchen knife`),$(`🗡️`,`dagger`),$(`⚔️`,`crossed swords`),$(`🛡️`,`shield`),$(`🚬`,`cigarette`),$(`⚰️`,`coffin`),$(`🪦`,`headstone`),$(`⚱️`,`urn`),$(`🏺`,`amphora`),$(`🔮`,`crystal ball`),$(`📿`,`prayer beads`),$(`🧿`,`nazar amulet`),$(`💈`,`barber pole`),$(`⚗️`,`alembic`),$(`🔭`,`telescope`),$(`🔬`,`microscope`),$(`🕳️`,`hole`),$(`🩹`,`bandage`),$(`🩺`,`stethoscope`),$(`💊`,`pill`),$(`💉`,`syringe`),$(`🩸`,`blood drop`),$(`🧬`,`dna`),$(`🦠`,`microbe`),$(`🧫`,`petri dish`),$(`🧪`,`test tube`),$(`🌡️`,`thermometer`),$(`🧹`,`broom`),$(`🪠`,`plunger`),$(`🧺`,`basket`),$(`🧻`,`roll of paper`),$(`🚽`,`toilet`),$(`🚰`,`tap water`),$(`🚿`,`shower`),$(`🛁`,`bathtub`),$(`🛀`,`person bathing`),$(`🧼`,`soap`),$(`🪥`,`toothbrush`),$(`🪒`,`razor`),$(`🧽`,`sponge`),$(`🪣`,`bucket`),$(`🧴`,`lotion`),$(`🛎️`,`bellhop bell`),$(`🔑`,`key`),$(`🗝️`,`old key`),$(`🚪`,`door`),$(`🪑`,`chair`),$(`🛋️`,`couch`),$(`🛏️`,`bed`),$(`🛌`,`person in bed`),$(`🧸`,`teddy bear`),$(`🖼️`,`framed picture`),$(`🪞`,`mirror`),$(`🪟`,`window`),$(`🛍️`,`shopping bags`),$(`🛒`,`cart`),$(`🎁`,`gift`),$(`🎀`,`ribbon`),$(`🎊`,`confetti ball`),$(`🎉`,`party popper`,`celebration`),$(`🎈`,`balloon`),$(`🪄`,`magic wand`),$(`📱`,`mobile`),$(`📲`,`incoming phone`),$(`☎️`,`phone`),$(`📞`,`phone receiver`),$(`📟`,`pager`),$(`📠`,`fax`),$(`🔋`,`battery`),$(`🔌`,`plug`),$(`💻`,`laptop`),$(`🖥️`,`desktop`),$(`🖨️`,`printer`),$(`⌨️`,`keyboard`),$(`🖱️`,`mouse`),$(`🖲️`,`trackball`),$(`💽`,`minidisc`),$(`💾`,`floppy`,`save`),$(`💿`,`cd`),$(`📀`,`dvd`),$(`🧮`,`abacus`),$(`🎥`,`movie camera`),$(`🎞️`,`film frames`),$(`📽️`,`film projector`),$(`📺`,`television`),$(`📷`,`camera`),$(`📸`,`camera flash`),$(`📹`,`video camera`),$(`📼`,`videocassette`),$(`🔍`,`magnifying left`),$(`🔎`,`magnifying right`),$(`🕰️`,`mantelpiece clock`),$(`⏰`,`alarm clock`),$(`⏱️`,`stopwatch`),$(`⏲️`,`timer`),$(`⏳`,`hourglass flowing`),$(`⌛`,`hourglass done`),$(`📡`,`satellite antenna`),$(`📚`,`books`),$(`📖`,`open book`),$(`🔖`,`bookmark`),$(`🏷️`,`tag`),$(`📰`,`newspaper`),$(`🗞️`,`rolled newspaper`),$(`📄`,`page`),$(`📃`,`page curl`),$(`📑`,`bookmark tabs`),$(`📜`,`scroll`),$(`📋`,`clipboard`),$(`📅`,`calendar`),$(`📆`,`tear off calendar`),$(`🗓️`,`spiral calendar`),$(`📇`,`card index`),$(`🗃️`,`card file box`),$(`🗳️`,`ballot box`),$(`🗄️`,`file cabinet`),$(`📂`,`open folder`),$(`📁`,`folder`),$(`📊`,`bar chart`),$(`📈`,`chart up`),$(`📉`,`chart down`),$(`📌`,`pushpin`),$(`📍`,`round pushpin`),$(`📎`,`paperclip`),$(`🖇️`,`linked paperclips`),$(`📏`,`straight ruler`),$(`📐`,`triangular ruler`),$(`✂️`,`scissors`),$(`🖊️`,`pen`),$(`🖋️`,`fountain pen`),$(`✒️`,`black nib`),$(`🖌️`,`paintbrush`),$(`🖍️`,`crayon`),$(`📝`,`memo`,`note`),$(`✏️`,`pencil`),$(`🔏`,`locked with pen`),$(`🔐`,`locked with key`),$(`🔒`,`locked`),$(`🔓`,`unlocked`),$(`🧿`,`amulet`),$(`🪬`,`hamsa`)]},{id:`symbols`,label:`Symbols`,icon:`❤️`,emojis:[$(`❤️`,`red heart`),$(`🧡`,`orange heart`),$(`💛`,`yellow heart`),$(`💚`,`green heart`),$(`💙`,`blue heart`),$(`💜`,`purple heart`),$(`🖤`,`black heart`),$(`🤍`,`white heart`),$(`🤎`,`brown heart`),$(`💔`,`broken heart`),$(`❣️`,`heart exclamation`),$(`💕`,`two hearts`),$(`💞`,`revolving hearts`),$(`💓`,`beating heart`),$(`💗`,`growing heart`),$(`💖`,`sparkling heart`),$(`💘`,`heart arrow`),$(`💝`,`heart with ribbon`),$(`💟`,`heart decoration`),$(`☮️`,`peace`),$(`✝️`,`cross`),$(`☪️`,`star and crescent`),$(`🕉️`,`om`),$(`☸️`,`wheel of dharma`),$(`✡️`,`star of david`),$(`🔯`,`six pointed star`),$(`🕎`,`menorah`),$(`☯️`,`yin yang`),$(`☦️`,`orthodox cross`),$(`🛐`,`place of worship`),$(`⛎`,`ophiuchus`),$(`♈`,`aries`),$(`♉`,`taurus`),$(`♊`,`gemini`),$(`♋`,`cancer`),$(`♌`,`leo`),$(`♍`,`virgo`),$(`♎`,`libra`),$(`♏`,`scorpio`),$(`♐`,`sagittarius`),$(`♑`,`capricorn`),$(`♒`,`aquarius`),$(`♓`,`pisces`),$(`🆔`,`id`),$(`⚛️`,`atom`),$(`🉑`,`accept`),$(`☢️`,`radioactive`),$(`☣️`,`biohazard`),$(`📴`,`phone off`),$(`📳`,`vibration`),$(`🈶`,`not free`),$(`🈚`,`free`),$(`🈸`,`application`),$(`🈺`,`open for business`),$(`🈷️`,`monthly amount`),$(`✴️`,`eight pointed star`),$(`🆚`,`vs`),$(`💮`,`white flower`),$(`🉐`,`bargain`),$(`㊙️`,`secret`),$(`㊗️`,`congratulations`),$(`🈴`,`passing grade`),$(`🈵`,`no vacancy`),$(`🈹`,`discount`),$(`🈲`,`prohibited`),$(`🅰️`,`a button`),$(`🅱️`,`b button`),$(`🆎`,`ab button`),$(`🆑`,`cl button`),$(`🅾️`,`o button`),$(`🆘`,`sos`),$(`❌`,`cross mark`),$(`⭕`,`circle`),$(`🛑`,`stop sign`),$(`⛔`,`no entry`),$(`📛`,`name badge`),$(`🚫`,`prohibited sign`),$(`💯`,`100`,`hundred`),$(`💢`,`anger`),$(`♨️`,`hot springs`),$(`🚷`,`no pedestrians`),$(`🚯`,`no littering`),$(`🚳`,`no bicycles`),$(`🚱`,`non potable`),$(`🔞`,`no minors`),$(`📵`,`no phones`),$(`🚭`,`no smoking`),$(`❗`,`exclamation`),$(`❕`,`white exclamation`),$(`❓`,`question`),$(`❔`,`white question`),$(`‼️`,`double exclamation`),$(`⁉️`,`exclamation question`),$(`🔅`,`dim`),$(`🔆`,`bright`),$(`〽️`,`part alternation`),$(`⚠️`,`warning`),$(`🚸`,`children crossing`),$(`🔱`,`trident`),$(`⚜️`,`fleur de lis`),$(`🔰`,`beginner`),$(`♻️`,`recycle`),$(`✅`,`check mark`),$(`🈯`,`reserved`),$(`💹`,`chart with yen`),$(`❇️`,`sparkle`),$(`✳️`,`eight spoked asterisk`),$(`❎`,`cross box`),$(`🌐`,`globe meridians`),$(`💠`,`diamond`),$(`Ⓜ️`,`circled m`),$(`🌀`,`cyclone`),$(`💤`,`zzz`,`sleep`),$(`🏧`,`atm`),$(`🚾`,`water closet`),$(`♿`,`wheelchair`),$(`🅿️`,`parking`),$(`🛗`,`elevator`),$(`🈳`,`vacancy`),$(`🈂️`,`service`),$(`🛂`,`passport control`),$(`🛃`,`customs`),$(`🛄`,`baggage claim`),$(`🛅`,`left luggage`),$(`🚹`,`mens`),$(`🚺`,`womens`),$(`🚼`,`baby symbol`),$(`🚻`,`restroom`),$(`🚮`,`litter bin`),$(`🎦`,`cinema`),$(`📶`,`antenna bars`),$(`🈁`,`here`),$(`🔣`,`input symbols`),$(`ℹ️`,`info`),$(`🔤`,`input latin`),$(`🔡`,`input lowercase`),$(`🔠`,`input uppercase`),$(`🆖`,`ng`),$(`🆗`,`ok`),$(`🆙`,`up`),$(`🆒`,`cool`),$(`🆕`,`new`),$(`🆓`,`free`),$(`0️⃣`,`keycap 0`),$(`1️⃣`,`keycap 1`),$(`2️⃣`,`keycap 2`),$(`3️⃣`,`keycap 3`),$(`4️⃣`,`keycap 4`),$(`5️⃣`,`keycap 5`),$(`6️⃣`,`keycap 6`),$(`7️⃣`,`keycap 7`),$(`8️⃣`,`keycap 8`),$(`9️⃣`,`keycap 9`),$(`🔟`,`keycap 10`),$(`🔢`,`input numbers`),$(`#️⃣`,`keycap hash`),$(`*️⃣`,`keycap asterisk`),$(`▶️`,`play`),$(`⏸️`,`pause`),$(`⏯️`,`play or pause`),$(`⏹️`,`stop button`),$(`⏺️`,`record`),$(`⏭️`,`next track`),$(`⏮️`,`last track`),$(`⏩`,`fast forward`),$(`⏪`,`fast reverse`),$(`⏫`,`fast up`),$(`⏬`,`fast down`),$(`◀️`,`reverse`),$(`🔼`,`up button`),$(`🔽`,`down button`),$(`➡️`,`right arrow`),$(`⬅️`,`left arrow`),$(`⬆️`,`up arrow`),$(`⬇️`,`down arrow`),$(`↗️`,`up right arrow`),$(`↘️`,`down right arrow`),$(`↙️`,`down left arrow`),$(`↖️`,`up left arrow`),$(`↕️`,`up down arrow`),$(`↔️`,`left right arrow`),$(`↪️`,`right arrow curving`),$(`↩️`,`left arrow curving`),$(`⤴️`,`arrow up curve`),$(`⤵️`,`arrow down curve`),$(`🔀`,`shuffle`),$(`🔁`,`repeat`),$(`🔂`,`repeat single`),$(`🔄`,`arrows ccw`),$(`🔃`,`arrows cw`),$(`🎵`,`note`),$(`🎶`,`notes`),$(`➕`,`plus`),$(`➖`,`minus`),$(`➗`,`divide`),$(`✖️`,`multiply`),$(`🟰`,`equals`),$(`♾️`,`infinity`),$(`💲`,`dollar`),$(`💱`,`currency exchange`),$(`™️`,`tm`),$(`©️`,`copyright`),$(`®️`,`registered`),$(`〰️`,`wavy`),$(`➰`,`curly loop`),$(`➿`,`double curly loop`),$(`🔚`,`end`),$(`🔙`,`back`),$(`🔛`,`on`),$(`🔝`,`top`),$(`🔜`,`soon`),$(`✔️`,`check`),$(`☑️`,`ballot box check`),$(`🔘`,`radio button`),$(`🔴`,`red circle`),$(`🟠`,`orange circle`),$(`🟡`,`yellow circle`),$(`🟢`,`green circle`),$(`🔵`,`blue circle`),$(`🟣`,`purple circle`),$(`🟤`,`brown circle`),$(`⚫`,`black circle`),$(`⚪`,`white circle`),$(`🟥`,`red square`),$(`🟧`,`orange square`),$(`🟨`,`yellow square`),$(`🟩`,`green square`),$(`🟦`,`blue square`),$(`🟪`,`purple square`),$(`🟫`,`brown square`),$(`⬛`,`black square`),$(`⬜`,`white square`),$(`◼️`,`medium black square`),$(`◻️`,`medium white square`),$(`◾`,`small black square`),$(`◽`,`small white square`),$(`▪️`,`tiny black square`),$(`▫️`,`tiny white square`),$(`🔶`,`large orange diamond`),$(`🔷`,`large blue diamond`),$(`🔸`,`small orange diamond`),$(`🔹`,`small blue diamond`),$(`🔺`,`red triangle up`),$(`🔻`,`red triangle down`),$(`🔳`,`white square button`),$(`🔲`,`black square button`)]},{id:`flags`,label:`Flags`,icon:`🏳️`,emojis:[$(`🏁`,`checkered flag`),$(`🚩`,`triangular flag`),$(`🎌`,`crossed flags`),$(`🏴`,`black flag`),$(`🏳️`,`white flag`),$(`🏳️🌈`,`rainbow flag`),$(`🏳️⚧️`,`transgender flag`),$(`🏴☠️`,`pirate flag`),$(`🇺🇸`,`united states`,`us`,`usa`),$(`🇨🇦`,`canada`),$(`🇲🇽`,`mexico`),$(`🇬🇧`,`united kingdom`,`uk`),$(`🇮🇪`,`ireland`),$(`🇫🇷`,`france`),$(`🇩🇪`,`germany`),$(`🇮🇹`,`italy`),$(`🇪🇸`,`spain`),$(`🇵🇹`,`portugal`),$(`🇳🇱`,`netherlands`),$(`🇧🇪`,`belgium`),$(`🇨🇭`,`switzerland`),$(`🇦🇹`,`austria`),$(`🇸🇪`,`sweden`),$(`🇳🇴`,`norway`),$(`🇩🇰`,`denmark`),$(`🇫🇮`,`finland`),$(`🇮🇸`,`iceland`),$(`🇵🇱`,`poland`),$(`🇨🇿`,`czech republic`),$(`🇸🇰`,`slovakia`),$(`🇭🇺`,`hungary`),$(`🇷🇴`,`romania`),$(`🇧🇬`,`bulgaria`),$(`🇬🇷`,`greece`),$(`🇹🇷`,`turkey`),$(`🇷🇺`,`russia`),$(`🇺🇦`,`ukraine`),$(`🇨🇳`,`china`),$(`🇯🇵`,`japan`),$(`🇰🇷`,`south korea`,`korea`),$(`🇮🇳`,`india`),$(`🇵🇰`,`pakistan`),$(`🇧🇩`,`bangladesh`),$(`🇹🇭`,`thailand`),$(`🇻🇳`,`vietnam`),$(`🇮🇩`,`indonesia`),$(`🇵🇭`,`philippines`),$(`🇲🇾`,`malaysia`),$(`🇸🇬`,`singapore`),$(`🇦🇺`,`australia`),$(`🇳🇿`,`new zealand`),$(`🇧🇷`,`brazil`),$(`🇦🇷`,`argentina`),$(`🇨🇱`,`chile`),$(`🇨🇴`,`colombia`),$(`🇵🇪`,`peru`),$(`🇻🇪`,`venezuela`),$(`🇿🇦`,`south africa`),$(`🇪🇬`,`egypt`),$(`🇲🇦`,`morocco`),$(`🇰🇪`,`kenya`),$(`🇳🇬`,`nigeria`),$(`🇸🇦`,`saudi arabia`),$(`🇦🇪`,`uae`),$(`🇮🇱`,`israel`),$(`🇮🇷`,`iran`),$(`🇮🇶`,`iraq`),$(`🇸🇾`,`syria`),$(`🇱🇧`,`lebanon`),$(`🇯🇴`,`jordan`),$(`🇪🇺`,`european union`,`eu`),$(`🇺🇳`,`united nations`,`un`)]}];function qy(e,t){let n=e===`brands`?`github`:e===`solid`?`house`:`face-smile`,r=St.filter(t=>t.family===e),i=r.find(e=>e.name===n)??r[0],a=i?{kind:`icon`,family:e,name:i.name}:{kind:`emoji`,char:`◆`};return{id:`fa-${e}`,label:t,tab:a,entries:r.map(e=>({kind:`icon`,family:e.family,name:e.name,label:e.label,keywords:e.keywords,token:bt(e)}))}}var Jy=[...Ky.map(e=>({id:e.id,label:e.label,tab:{kind:`emoji`,char:e.icon},entries:e.emojis.map(e=>({kind:`emoji`,char:e.char,name:e.name,keywords:e.keywords}))})),qy(`brands`,`Brands`),qy(`solid`,`Solid`),qy(`regular`,`Regular`)],Yy=Jy.flatMap(e=>e.entries);function Xy(e,t=80){let n=e.trim().toLowerCase();if(!n)return[];let r=[];for(let e of Yy)if(e.keywords.includes(n)&&(r.push(e),r.length>=t))break;return r}var Zy={bg:`#fff`,border:`#d4cdb5`,inputBg:`#fff`,text:`#1f2937`,textMuted:`#8a7a5a`,accent:`#8B6914`,accentSoft:`#f3eedb`},Qy={bg:`#1f2937`,border:`#4b5563`,inputBg:`#374151`,text:`#e5e7eb`,textMuted:`#9ca3af`,accent:`#fbbf24`,accentSoft:`#374151`},$y=480,eb=560;function tb(e){return{position:`absolute`,zIndex:100,background:e.bg,border:`1px solid ${e.border}`,borderRadius:6,boxShadow:e===Qy?`0 8px 32px rgba(0, 0, 0, 0.5)`:`0 6px 24px rgba(0, 0, 0, 0.15)`,color:e.text,width:$y,maxWidth:`95vw`,maxHeight:eb,display:`flex`,flexDirection:`column`,overflow:`hidden`}}function nb({open:e,onSelect:t,onClose:n,anchorRef:r,className:i,style:a,theme:o=`light`}){let s=o===`dark`?Qy:Zy,[c,l]=(0,G.useState)(Jy[0].id),[u,d]=(0,G.useState)(``),f=(0,G.useRef)(null);Dh(e,n,r);let p=(0,G.useRef)(null);(0,G.useEffect)(()=>{if(e){let e=setTimeout(()=>p.current?.focus(),0);return()=>clearTimeout(e)}d(``),l(Jy[0].id)},[e]),(0,G.useEffect)(()=>{if(!e)return;let t=e=>{let t=e.target;t&&(f.current?.contains(t)||r?.current?.contains(t)||n())};return document.addEventListener(`mousedown`,t),()=>{document.removeEventListener(`mousedown`,t)}},[e,n,r]);let m=(0,G.useMemo)(()=>{if(u.trim())return Xy(u);let e=Jy.find(e=>e.id===c);return e?e.entries:[]},[u,c]);return e?(0,K.jsxs)(`div`,{ref:f,className:`squisq-emoji-picker ${i??``}`,"data-theme":o,style:{...tb(s),...a},role:`dialog`,"aria-label":`Insert emoji`,"data-testid":`emoji-picker`,children:[(0,K.jsx)(`div`,{style:{padding:`8px 10px`,borderBottom:`1px solid ${s.border}`},children:(0,K.jsx)(`input`,{ref:p,type:`text`,value:u,onChange:e=>d(e.target.value),placeholder:`Search emoji & icons…`,"aria-label":`Search emoji & icons`,style:{width:`100%`,padding:`6px 8px`,fontSize:13,fontFamily:`inherit`,border:`1px solid ${s.border}`,borderRadius:4,background:s.inputBg,color:s.text,boxSizing:`border-box`}})}),!u.trim()&&(0,K.jsx)(`div`,{role:`tablist`,"aria-label":`Emoji & icon categories`,style:{display:`grid`,gridTemplateColumns:`repeat(6, 1fr)`,gap:2,padding:`4px 6px`,borderBottom:`1px solid ${s.border}`},children:Jy.map(e=>{let t=e.id===c;return(0,K.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t,"aria-label":e.label,title:e.label,onClick:()=>l(e.id),style:{fontSize:18,lineHeight:1,padding:`6px 0`,cursor:`pointer`,background:t?s.accentSoft:`transparent`,border:`1px solid transparent`,borderBottom:t?`2px solid ${s.accent}`:`2px solid transparent`,borderRadius:4,color:s.text,display:`flex`,alignItems:`center`,justifyContent:`center`},children:e.tab.kind===`emoji`?e.tab.char:(0,K.jsx)(`i`,{className:`fa-${e.tab.family} fa-${e.tab.name}`,"aria-hidden":`true`})},e.id)})}),(0,K.jsx)(`div`,{style:{padding:6,flex:1,minHeight:0,overflowY:`auto`,display:`grid`,gridTemplateColumns:`repeat(10, 1fr)`,gap:2},children:m.length===0?(0,K.jsx)(`div`,{style:{gridColumn:`1 / -1`,padding:`20px 8px`,textAlign:`center`,color:s.textMuted,fontSize:13},children:u.trim()?`No matches for "${u.trim()}"`:`No entries`}):m.map((e,n)=>{let r=e.kind===`emoji`?e.name:e.label,i=e.kind===`emoji`?`e-${e.char}-${n}`:`i-${e.token}-${n}`;return(0,K.jsx)(`button`,{type:`button`,title:r,"aria-label":r,"data-picker-kind":e.kind,onClick:()=>t(e),style:{fontSize:22,lineHeight:1,padding:4,background:`transparent`,border:`1px solid transparent`,borderRadius:4,cursor:`pointer`,color:s.text,display:`flex`,alignItems:`center`,justifyContent:`center`},onMouseEnter:e=>{e.currentTarget.style.background=s.accentSoft},onMouseLeave:e=>{e.currentTarget.style.background=`transparent`},children:e.kind===`emoji`?e.char:(0,K.jsx)(`i`,{className:`fa-${e.family} fa-${e.name}`,"aria-hidden":`true`})},i)})})]}):null}var rb=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`avif`,`ico`,`mp4`,`webm`,`mov`,`avi`,`mp3`,`wav`,`ogg`,`aac`,`m4a`,`flac`]),ib=new Set([`md`,`txt`,`docx`]),ab=new Set([`csv`,`tsv`,`xlsx`,`parquet`]),ob=new Set([`text/csv`,`text/tab-separated-values`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,`application/vnd.ms-excel`,`application/vnd.apache.parquet`]);function sb(e){let t=e.lastIndexOf(`.`);return t>=0?e.slice(t+1).toLowerCase():``}function cb(e){let t=sb(e.name);return rb.has(t)?`media`:ib.has(t)?`text`:ab.has(t)?`data`:e.type.startsWith(`image/`)||e.type.startsWith(`video/`)||e.type.startsWith(`audio/`)?`media`:e.type===`text/plain`||e.type===`text/markdown`?`text`:ob.has(e.type)?`data`:`unknown`}function lb(e){let t=!1,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(i.kind!==`file`)continue;let a=i.type.toLowerCase();a.startsWith(`image/`)||a.startsWith(`video/`)||a.startsWith(`audio/`)||ob.has(a)?t=!0:(a===`text/plain`||a===`text/markdown`||a===`application/vnd.openxmlformats-officedocument.wordprocessingml.document`||(t=!0),n=!0)}return t&&n?`mixed`:t?`media`:n?`text`:null}function ub({onDrop:e,enabled:t=!0}){let[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(null),o=(0,G.useRef)(0),s=(0,G.useRef)(!1);(0,G.useEffect)(()=>{if(!t)return;let e=()=>{s.current=!0},n=()=>{s.current=!1};return document.addEventListener(`dragstart`,e,!0),document.addEventListener(`dragend`,n,!0),document.addEventListener(`drop`,n,!0),()=>{document.removeEventListener(`dragstart`,e,!0),document.removeEventListener(`dragend`,n,!0),document.removeEventListener(`drop`,n,!0)}},[t]);let c=(0,G.useCallback)(e=>{if(!t||s.current)return;let n=e.dataTransfer.types;if(!(n&&Array.from(n).includes(`Files`)))return;let i=e.dataTransfer.items?lb(e.dataTransfer.items):`mixed`;i&&(e.preventDefault(),o.current++,o.current===1&&(r(!0),a(i)))},[t]),l=(0,G.useCallback)(e=>{t&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)},[t]),u=(0,G.useCallback)(e=>{t&&(e.preventDefault(),o.current=Math.max(0,o.current-1),o.current===0&&(r(!1),a(null)))},[t]),d=(0,G.useCallback)(e=>{t&&(e.preventDefault(),o.current=0,r(!1),a(null))},[t]),f=(0,G.useCallback)(t=>({onDragOver:e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`copy`},onDrop:n=>{n.preventDefault(),n.stopPropagation(),o.current=0,r(!1),a(null);let i=Array.from(n.dataTransfer.files);i.length>0&&e(i,t)}}),[e]);return{isDragging:n,dragContentType:i,containerProps:{onDragEnter:c,onDragOver:l,onDragLeave:u,onDrop:d},zoneProps:f}}function db(e){let t=[],n=[],r=[];for(let i of e){let e=cb(i);e===`media`?t.push(i):e===`text`?n.push(i):e===`data`&&r.push(i)}return{media:t,text:n,data:r}}async function fb(e,t){let n=[];for(let r of e){let e;try{e=await r.arrayBuffer()}catch(e){console.warn(`[squisq-editor] Skipped dropped file "${r.name}" \u2014 could not read its contents.`,`This is typical for drags from virtual sources (Phone Link, screenshot tools, cross-tab drags) whose File reference goes stale before the async read completes.`,e instanceof Error?e.message:e),n.push(null);continue}if(e.byteLength===0){console.warn(`[squisq-editor] Skipped dropped file "${r.name}" \u2014 its contents read as 0 bytes. The drag source likely never materialized the file (try saving it to disk first, then dragging from there).`),n.push(null);continue}let i=r.type||`application/octet-stream`;try{let a=await t.addMedia(r.name,e,i);n.push(a)}catch(e){console.warn(`[squisq-editor] Failed to save "${r.name}" via mediaProvider:`,e instanceof Error?e.message:e),n.push(null)}}return n}var pb={csv:`text/csv`,tsv:`text/tab-separated-values`,xlsx:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,parquet:`application/vnd.apache.parquet`};async function mb(e,t,n){let r=[];if(e.length===0)return r;let i;try{i=new Set((await t.listMedia()).map(e=>e.name))}catch{i=new Set}for(let a of e){let e;try{e=await a.arrayBuffer()}catch(e){console.warn(`[squisq-editor] Skipped dropped file "${a.name}" \u2014 could not read its contents.`,e instanceof Error?e.message:e),r.push(null);continue}if(e.byteLength===0){console.warn(`[squisq-editor] Skipped dropped file "${a.name}" \u2014 its contents read as 0 bytes.`),r.push(null);continue}let o=a.name.split(/[\\/]/).pop()||`data`,s=o.lastIndexOf(`.`),c=s>0?o.slice(0,s):o,l=s>0?o.slice(s):``,u=a.type||pb[l.replace(`.`,``).toLowerCase()]||`application/octet-stream`,d=`${n}${o}`;for(let e=1;i.has(d);e++)d=`${n}${c}-${e}${l}`;try{let n=await t.addMedia(d,e,u);i.add(n),r.push(n)}catch(e){console.warn(`[squisq-editor] Failed to save "${a.name}" via mediaProvider:`,e instanceof Error?e.message:e),r.push(null)}}return r}async function hb(e){let t=e.name.split(`.`).pop()?.toLowerCase()??``;if(t===`md`||t===`txt`)return await e.text();if(t===`docx`){let t=await e.arrayBuffer(),{docxToMarkdownDoc:n}=await Ut(async()=>{let{docxToMarkdownDoc:e}=await import(`./docx-sXa1Rf41.js`);return{docxToMarkdownDoc:e}},__vite__mapDeps([22,23,1,24,18,19,17,25,26,27,28,20,12,13,14,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,2,55,56,57,58,59,60,61,62,63,64]));return Pt(await n(t))}return await e.text()}async function gb(e){let t=[];for(let n of e){let e=await hb(n);t.push(e)}return t.join(`
|
|
345
|
+
|
|
346
|
+
`)}function _b(){let{doc:e,markdownSource:t,setMarkdownSource:n}=Lp();return{docTemplates:(0,G.useMemo)(()=>e?.customTemplates??[],[e?.customTemplates]),onDocTemplatesChange:(0,G.useCallback)(e=>{let r=Ie(e),i=We(t,{[Qe]:r??null});i!==t&&n(i)},[t,n])}}var vb=[{fenceLanguage:`typescript`,label:`TypeScript`,monacoLanguage:`typescript`,starter:`const message: string = 'Hello, world!';`},{fenceLanguage:`javascript`,label:`JavaScript`,monacoLanguage:`javascript`,starter:`const message = 'Hello, world!';`},{fenceLanguage:`tsx`,label:`TSX`,monacoLanguage:`typescript`,starter:`export function Component() {
|
|
347
|
+
return <div>Hello, world!</div>;
|
|
348
|
+
}`},{fenceLanguage:`jsx`,label:`JSX`,monacoLanguage:`javascript`,starter:`export function Component() {
|
|
349
|
+
return <div>Hello, world!</div>;
|
|
350
|
+
}`},{fenceLanguage:`json`,label:`JSON`,monacoLanguage:`json`,starter:`{
|
|
351
|
+
"key": "value"
|
|
352
|
+
}`},{fenceLanguage:`jsonc`,label:`JSONC`,monacoLanguage:`json`,starter:`{
|
|
353
|
+
// Comments are allowed.
|
|
354
|
+
"key": "value"
|
|
355
|
+
}`},{fenceLanguage:`html`,label:`HTML`,monacoLanguage:`html`,starter:`<div>Hello, world!</div>`},{fenceLanguage:`css`,label:`CSS`,monacoLanguage:`css`,starter:`.example {
|
|
356
|
+
color: #2563eb;
|
|
357
|
+
}`},{fenceLanguage:`python`,label:`Python`,monacoLanguage:`python`,starter:`print("Hello, world!")`},{fenceLanguage:`bash`,label:`Shell`,monacoLanguage:`shell`,starter:`echo "Hello, world!"`},{fenceLanguage:`sql`,label:`SQL`,monacoLanguage:`sql`,starter:`SELECT *
|
|
358
|
+
FROM table_name;`},{fenceLanguage:`yaml`,label:`YAML`,monacoLanguage:`yaml`,starter:`key: value`},{fenceLanguage:`markdown`,label:`Markdown`,monacoLanguage:`markdown`,starter:`# Heading`},{fenceLanguage:`java`,label:`Java`,monacoLanguage:`java`,starter:`class Main {
|
|
359
|
+
public static void main(String[] args) {
|
|
360
|
+
}
|
|
361
|
+
}`},{fenceLanguage:`csharp`,label:`C#`,monacoLanguage:`csharp`,starter:`Console.WriteLine("Hello, world!");`},{fenceLanguage:`cpp`,label:`C++`,monacoLanguage:`cpp`,starter:`#include <iostream>
|
|
362
|
+
|
|
363
|
+
int main() {
|
|
364
|
+
return 0;
|
|
365
|
+
}`},{fenceLanguage:`go`,label:`Go`,monacoLanguage:`go`,starter:`package main
|
|
366
|
+
|
|
367
|
+
func main() {
|
|
368
|
+
}`},{fenceLanguage:`rust`,label:`Rust`,monacoLanguage:`rust`,starter:`fn main() {
|
|
369
|
+
println!("Hello, world!");
|
|
370
|
+
}`},{fenceLanguage:`ruby`,label:`Ruby`,monacoLanguage:`ruby`,starter:`puts "Hello, world!"`},{fenceLanguage:`php`,label:`PHP`,monacoLanguage:`php`,starter:`<?php
|
|
371
|
+
echo "Hello, world!";`},{fenceLanguage:`swift`,label:`Swift`,monacoLanguage:`swift`,starter:`print("Hello, world!")`},{fenceLanguage:`kotlin`,label:`Kotlin`,monacoLanguage:`kotlin`,starter:`fun main() {
|
|
372
|
+
println("Hello, world!")
|
|
373
|
+
}`},{fenceLanguage:`dockerfile`,label:`Dockerfile`,monacoLanguage:`dockerfile`,starter:`FROM node:22-alpine`}],yb=new Map(vb.map(e=>[e.fenceLanguage,e])),bb=new Set([`text`,`txt`,`plaintext`,`plain`,`ascii`,`diagram`,`tree`,`timeline`,`mermaid`]),xb={c:`c`,"c++":`cpp`,"c#":`csharp`,cs:`csharp`,cxx:`cpp`,docker:`dockerfile`,htm:`html`,js:`javascript`,jsx:`javascript`,jsonc:`json`,md:`markdown`,py:`python`,rb:`ruby`,sh:`shell`,shell:`shell`,ts:`typescript`,tsx:`typescript`,yml:`yaml`};function Sb(e){return typeof e==`string`?e.trim().split(/\s+/,1)[0]?.toLowerCase()??``:``}function Cb(e){let t=Sb(e);return t.length>0&&!bb.has(t)}function wb(e){let t=Sb(e);return(yb.get(t)?.monacoLanguage??xb[t]??t)||`plaintext`}function Tb(e){let t=Sb(e),n=yb.get(t);return n?n.label:t?t.replace(/(^|[-_])([a-z])/g,(e,t,n)=>n.toUpperCase()):`Code`}function Eb(e,t){return`
|
|
374
|
+
\`\`\`${e}
|
|
375
|
+
${t}
|
|
376
|
+
\`\`\`
|
|
377
|
+
`}var Db=(...e)=>e.join(`
|
|
378
|
+
`),Ob=[{id:`flowchart`,label:`Flowchart`,description:`Processes, decisions, and connected shapes.`,category:`Structure`,preview:`flowchart`,starter:Db(`flowchart LR`,` start["Start"] --> decision{"Ready?"}`,` decision -->|Yes| done["Done"]`,` decision -->|No| start`)},{id:`sequence`,label:`Sequence`,description:`Messages exchanged between participants over time.`,category:`Structure`,preview:`sequence`,starter:Db(`sequenceDiagram`,` participant Client`,` participant Service`,` Client->>Service: Request`,` Service-->>Client: Response`)},{id:`state`,label:`State`,description:`States, transitions, choices, and lifecycles.`,category:`Structure`,preview:`state`,starter:Db(`stateDiagram-v2`,` [*] --> Idle`,` Idle --> Working : start`,` Working --> Idle : finish`,` Working --> [*] : stop`)},{id:`class`,label:`Class`,description:`Classes, members, inheritance, and relationships.`,category:`Structure`,preview:`class`,starter:Db(`classDiagram`,` class Animal {`,` +String name`,` +speak()`,` }`,` Animal <|-- Dog`,` Dog : +fetch()`)},{id:`entity-relationship`,label:`Entity Relationship`,description:`Entities, cardinality, and data relationships.`,category:`Structure`,preview:`er`,starter:Db(`erDiagram`,` CUSTOMER ||--o{ ORDER : places`,` ORDER ||--|{ LINE_ITEM : contains`,` PRODUCT ||--o{ LINE_ITEM : appears_in`)},{id:`mindmap`,label:`Mind Map`,description:`Ideas arranged radially around a central topic.`,category:`Structure`,preview:`mindmap`,starter:Db(`mindmap`,` root((Project))`,` Product`,` Research`,` Design`,` Delivery`,` Build`,` Launch`)},{id:`c4-context`,label:`C4 Context`,description:`People, systems, containers, and dependencies.`,category:`Structure`,preview:`c4`,badge:`Experimental`,starter:Db(`C4Context`,` title System context`,` Person(user, "User")`,` System(app, "Application")`,` System_Ext(api, "External API")`,` Rel(user, app, "Uses")`,` Rel(app, api, "Calls")`)},{id:`architecture`,label:`Architecture`,description:`Cloud services, resources, groups, and ports.`,category:`Structure`,preview:`architecture`,badge:`Beta`,starter:Db(`architecture-beta`,` group api(cloud)[API]`,` service client(internet)[Client]`,` service server(server)[Service] in api`,` service db(database)[Database] in api`,` client:R --> L:server`,` server:R --> L:db`)},{id:`gantt`,label:`Gantt`,description:`Tasks, dependencies, milestones, and dates.`,category:`Planning`,preview:`gantt`,starter:Db(`gantt`,` title Project plan`,` dateFormat YYYY-MM-DD`,` section Build`,` Design :done, design, 2026-01-01, 3d`,` Implement :active, build, after design, 5d`,` Ship :milestone, after build, 0d`)},{id:`timeline`,label:`Timeline`,description:`Events and milestones arranged chronologically.`,category:`Planning`,preview:`timeline`,starter:Db(`timeline`,` title Product launch`,` Q1 : Research`,` Q2 : Build : Test`,` Q3 : Launch`)},{id:`journey`,label:`User Journey`,description:`Experiences, actors, stages, and satisfaction.`,category:`Planning`,preview:`journey`,starter:Db(`journey`,` title Customer journey`,` section Discover`,` Find product: 5: Customer`,` Compare options: 3: Customer`,` section Buy`,` Checkout: 4: Customer`)},{id:`kanban`,label:`Kanban`,description:`Work items organized into workflow columns.`,category:`Planning`,preview:`kanban`,starter:Db(`kanban`,` todo[To do]`,` task1[Plan the work]`,` doing[In progress]`,` task2[Build the feature]`,` done[Done]`,` task3[Ship it]`)},{id:`git-graph`,label:`Git Graph`,description:`Branches, commits, merges, and releases.`,category:`Planning`,preview:`git`,starter:Db(`gitGraph`,` commit id: "Plan"`,` branch feature`,` checkout feature`,` commit id: "Build"`,` checkout main`,` merge feature`,` commit id: "Ship"`)},{id:`pie`,label:`Pie Chart`,description:`A compact part-to-whole comparison.`,category:`Data`,preview:`pie`,starter:Db(`pie showData`,` title Work allocation`,` "Build" : 45`,` "Test" : 30`,` "Plan" : 25`)},{id:`quadrant`,label:`Quadrant`,description:`Items positioned against two dimensions.`,category:`Data`,preview:`quadrant`,starter:Db(`quadrantChart`,` title Impact and effort`,` x-axis Low effort --> High effort`,` y-axis Low impact --> High impact`,` "Quick win": [0.25, 0.80]`,` "Big bet": [0.75, 0.85]`)},{id:`sankey`,label:`Sankey`,description:`Weighted flows between sources and destinations.`,category:`Data`,preview:`sankey`,badge:`Beta`,starter:Db(`sankey-beta`,` Source,Process,80`,` Source,Loss,20`,` Process,Output,70`,` Process,Waste,10`)},{id:`xy-chart`,label:`XY Chart`,description:`Bar and line series on numeric axes.`,category:`Data`,preview:`xy`,badge:`Beta`,starter:Db(`xychart-beta`,` title "Delivery trend"`,` x-axis [Jan, Feb, Mar, Apr]`,` y-axis "Items" 0 --> 100`,` bar [30, 55, 70, 90]`,` line [25, 45, 75, 85]`)},{id:`requirement`,label:`Requirement`,description:`Requirements, elements, risks, and verification.`,category:`Data`,preview:`requirement`,starter:Db(`requirementDiagram`,` requirement secure_auth {`,` id: 1`,` text: Users must authenticate`,` risk: high`,` verifymethod: test`,` }`,` element app {`,` type: system`,` }`,` app - satisfies -> secure_auth`)}],kb=Ob[0];function Ab(e){return`
|
|
379
|
+
\`\`\`mermaid
|
|
380
|
+
${e}
|
|
381
|
+
\`\`\`
|
|
382
|
+
`}function jb({preview:e}){let t={fill:`none`,stroke:`currentColor`,strokeWidth:2},n;switch(e){case`sequence`:n=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`rect`,{x:`14`,y:`8`,width:`28`,height:`12`,rx:`2`}),(0,K.jsx)(`rect`,{x:`78`,y:`8`,width:`28`,height:`12`,rx:`2`}),(0,K.jsx)(`path`,{d:`M28 20v36M92 20v36M30 30h58l-6-4m6 4-6 4M90 45H32l6-4m-6 4 6 4`})]});break;case`state`:n=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`circle`,{cx:`13`,cy:`32`,r:`5`,fill:`currentColor`}),(0,K.jsx)(`rect`,{x:`32`,y:`20`,width:`34`,height:`24`,rx:`10`}),(0,K.jsx)(`circle`,{cx:`101`,cy:`32`,r:`8`}),(0,K.jsx)(`circle`,{cx:`101`,cy:`32`,r:`4`,fill:`currentColor`}),(0,K.jsx)(`path`,{d:`M18 32h14m34 0h27m-5-4 5 4-5 4`})]});break;case`class`:case`requirement`:n=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`rect`,{x:`10`,y:`10`,width:`40`,height:`44`,rx:`2`}),(0,K.jsx)(`path`,{d:`M10 23h40M10 37h40M24 29h18M18 44h24`}),(0,K.jsx)(`rect`,{x:`75`,y:`18`,width:`35`,height:`30`,rx:`2`}),(0,K.jsx)(`path`,{d:`M50 32h25m-6-4 6 4-6 4M82 28h20M82 38h14`})]});break;case`er`:n=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`rect`,{x:`8`,y:`17`,width:`35`,height:`30`,rx:`2`}),(0,K.jsx)(`rect`,{x:`78`,y:`17`,width:`35`,height:`30`,rx:`2`}),(0,K.jsx)(`path`,{d:`M43 32h35M50 26v12m21-12v12M55 32l6-6v12z`})]});break;case`mindmap`:n=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`ellipse`,{cx:`60`,cy:`32`,rx:`20`,ry:`10`}),(0,K.jsx)(`path`,{d:`M40 29L18 16m22 19L18 49m62-20 22-13M80 35l22 14`}),(0,K.jsx)(`circle`,{cx:`15`,cy:`14`,r:`5`}),(0,K.jsx)(`circle`,{cx:`15`,cy:`50`,r:`5`}),(0,K.jsx)(`circle`,{cx:`105`,cy:`14`,r:`5`}),(0,K.jsx)(`circle`,{cx:`105`,cy:`50`,r:`5`})]});break;case`c4`:case`architecture`:n=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`rect`,{x:`6`,y:`7`,width:`108`,height:`50`,rx:`5`,strokeDasharray:`4 3`}),(0,K.jsx)(`rect`,{x:`14`,y:`21`,width:`25`,height:`20`,rx:`3`}),(0,K.jsx)(`rect`,{x:`48`,y:`21`,width:`25`,height:`20`,rx:`3`}),(0,K.jsx)(`ellipse`,{cx:`99`,cy:`31`,rx:`12`,ry:`10`}),(0,K.jsx)(`path`,{d:`M39 31h9m25 0h14m-5-4 5 4-5 4`})]});break;case`gantt`:n=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M20 8v48M20 16h94M20 30h94M20 44h94M40 8v48M65 8v48M90 8v48`,opacity:`.35`}),(0,K.jsx)(`rect`,{x:`28`,y:`19`,width:`30`,height:`7`,rx:`2`,fill:`currentColor`}),(0,K.jsx)(`rect`,{x:`52`,y:`33`,width:`42`,height:`7`,rx:`2`,fill:`currentColor`}),(0,K.jsx)(`path`,{d:`M94 47l5 5 5-5-5-5z`,fill:`currentColor`})]});break;case`timeline`:case`journey`:n=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M8 38h104M18 38V20M58 38V12M99 38V24`}),(0,K.jsx)(`circle`,{cx:`18`,cy:`38`,r:`5`,fill:`currentColor`}),(0,K.jsx)(`circle`,{cx:`58`,cy:`38`,r:`5`,fill:`currentColor`}),(0,K.jsx)(`circle`,{cx:`99`,cy:`38`,r:`5`,fill:`currentColor`}),(0,K.jsx)(`path`,{d:`M12 17h22M48 9h25M88 21h25`})]});break;case`kanban`:n=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`rect`,{x:`7`,y:`8`,width:`31`,height:`48`,rx:`3`}),(0,K.jsx)(`rect`,{x:`44`,y:`8`,width:`31`,height:`48`,rx:`3`}),(0,K.jsx)(`rect`,{x:`81`,y:`8`,width:`31`,height:`48`,rx:`3`}),(0,K.jsx)(`path`,{d:`M13 17h19M50 17h19M87 17h19`}),(0,K.jsx)(`rect`,{x:`12`,y:`24`,width:`21`,height:`10`,rx:`2`,fill:`currentColor`,opacity:`.55`}),(0,K.jsx)(`rect`,{x:`49`,y:`24`,width:`21`,height:`17`,rx:`2`,fill:`currentColor`,opacity:`.55`}),(0,K.jsx)(`rect`,{x:`86`,y:`24`,width:`21`,height:`10`,rx:`2`,fill:`currentColor`,opacity:`.55`})]});break;case`git`:n=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M13 16h94M34 16c10 0 8 32 22 32h40`}),[13,34,68,96].map(e=>(0,K.jsx)(`circle`,{cx:e,cy:`16`,r:`5`,fill:`currentColor`},e)),(0,K.jsx)(`circle`,{cx:`56`,cy:`48`,r:`5`,fill:`currentColor`}),(0,K.jsx)(`circle`,{cx:`96`,cy:`48`,r:`5`,fill:`currentColor`})]});break;case`pie`:n=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`circle`,{cx:`60`,cy:`32`,r:`24`}),(0,K.jsx)(`path`,{d:`M60 32V8a24 24 0 0 1 20.8 36z`,fill:`currentColor`,opacity:`.65`}),(0,K.jsx)(`path`,{d:`M60 32l20.8 12A24 24 0 0 1 38 48z`,fill:`currentColor`,opacity:`.32`})]});break;case`quadrant`:n=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M12 54h98M12 54V8M61 8v46M12 31h98`,opacity:`.55`}),(0,K.jsx)(`circle`,{cx:`35`,cy:`20`,r:`5`,fill:`currentColor`}),(0,K.jsx)(`circle`,{cx:`85`,cy:`17`,r:`5`,fill:`currentColor`,opacity:`.7`}),(0,K.jsx)(`circle`,{cx:`73`,cy:`42`,r:`5`,fill:`currentColor`,opacity:`.45`})]});break;case`sankey`:n=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`rect`,{x:`7`,y:`12`,width:`9`,height:`40`,rx:`2`,fill:`currentColor`}),(0,K.jsx)(`rect`,{x:`55`,y:`8`,width:`9`,height:`48`,rx:`2`,fill:`currentColor`,opacity:`.65`}),(0,K.jsx)(`rect`,{x:`104`,y:`10`,width:`9`,height:`18`,rx:`2`,fill:`currentColor`}),(0,K.jsx)(`rect`,{x:`104`,y:`38`,width:`9`,height:`14`,rx:`2`,fill:`currentColor`,opacity:`.5`}),(0,K.jsx)(`path`,{d:`M16 20C35 20 37 17 55 17M16 44c20 0 21 3 39 3M64 18c20 0 21 0 40 0M64 45c20 0 20 0 40 0`,strokeWidth:`8`,opacity:`.35`})]});break;case`xy`:n=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M15 8v46h96`}),(0,K.jsx)(`rect`,{x:`27`,y:`35`,width:`10`,height:`19`,fill:`currentColor`,opacity:`.35`}),(0,K.jsx)(`rect`,{x:`51`,y:`25`,width:`10`,height:`29`,fill:`currentColor`,opacity:`.35`}),(0,K.jsx)(`rect`,{x:`75`,y:`16`,width:`10`,height:`38`,fill:`currentColor`,opacity:`.35`}),(0,K.jsx)(`path`,{d:`M20 43l24-12 24 5 33-22`,strokeWidth:`3`}),(0,K.jsx)(`circle`,{cx:`44`,cy:`31`,r:`3`,fill:`currentColor`}),(0,K.jsx)(`circle`,{cx:`68`,cy:`36`,r:`3`,fill:`currentColor`}),(0,K.jsx)(`circle`,{cx:`101`,cy:`14`,r:`3`,fill:`currentColor`})]});break;default:n=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`rect`,{x:`8`,y:`18`,width:`35`,height:`28`,rx:`3`}),(0,K.jsx)(`path`,{d:`M43 32h33m-6-5 6 5-6 5`}),(0,K.jsx)(`rect`,{x:`77`,y:`18`,width:`35`,height:`28`,rx:`3`})]})}return(0,K.jsx)(`svg`,{viewBox:`0 0 120 64`,"aria-hidden":`true`,focusable:`false`,...t,children:n})}function Mb(e,t){if(t.length===0)return;let{$from:n}=e.state.selection,r=n.depth>=1?n.after(1):e.state.doc.content.size;e.chain().focus().insertContentAt(r,t).run()}function Nb(e,t){Mb(e,[t])}var Pb=.05;function Fb(e){return String(Math.round(Math.max(0,e)*100)/100)}function Ib(e){if(e.source!==`screen+camera`||!e.camera)return null;let t=Fb(e.duration),n=e.camera.offsetSec,r=n>=Pb?Fb(n):void 0,i=n<=-Pb?Fb(-n):void 0,a=Fb(e.camera.duration),o=`<video src="${e.relativePath}" controls width="480" data-squisq-video-placement="overlay" data-squisq-video-lock-to-block="false" data-squisq-video-clip-end="${t}"></video>`,s=`<video src="${e.camera.relativePath}" controls width="240" data-squisq-video-placement="picture-in-picture" data-squisq-video-lock-to-block="false"`+(r==null?``:` data-squisq-video-start-at="${r}"`)+(i==null?``:` data-squisq-video-clip-start="${i}"`)+` data-squisq-video-clip-end="${a}"></video>`,c={src:e.relativePath,controls:!0,width:480,placement:`overlay`,lockToBlock:!1,clipEnd:Number(t)},l={src:e.camera.relativePath,controls:!0,width:240,placement:`picture-in-picture`,lockToBlock:!1,clipEnd:Number(a)};return r!=null&&(l.startAt=Number(r)),i!=null&&(l.clipStart=Number(i)),{screenTag:o,cameraTag:s,screenAttrs:c,cameraAttrs:l}}var Lb=/^ {0,3}(`{3,}|~{3,})(.*)$/,Rb=/^ {0,3}(`{3,}|~{3,})[ \t]*$/;function zb(e){let t=Lb.exec(e);if(!t)return null;let n=t[1],r=n[0];return r==="`"&&t[2].includes("`")?null:{marker:r,length:n.length}}function Bb(e,t){let n=Rb.exec(e);return!!n&&n[1][0]===t.marker&&n[1].length>=t.length}function Vb(e){let t=e.split(/\r\n|\r|\n/),n=[],r=null;for(let e of t){if(r){n.push(!0),Bb(e,r)&&(r=null);continue}let t=zb(e);n.push(t!=null),r=t}return n}function Hb(e,t){return!Number.isInteger(t)||t<1?!1:Vb(e)[t-1]??!1}function Ub(e){let t=Vb(e),n=0;return e.split(/(\r\n|\r|\n)/).map((e,r)=>r%2==1?e:t[n++]?` `.repeat(e.length):e).join(``)}var Wb=480;function Gb(e){return String(Math.round(Math.max(0,e)*100)/100)}function Kb(e){return/[\s"']/.test(e)?`"${e.replace(/"/g,`\\"`)}"`:e}function qb(e,t){return`<video src="${e}" controls width="${Wb}" data-squisq-video-placement="overlay" data-squisq-video-lock-to-block="false" data-squisq-video-clip-end="${Gb(t)}"></video>`}function Jb(e){return`{[audio src=${Kb(e)} anchor=document]}`}function Yb(e){let t=Ib(e);return t?[t.screenTag,t.cameraTag]:e.mediaKind===`audio`?[Jb(e.relativePath)]:[qb(e.relativePath,e.duration)]}var Xb=/^\{\[audio\s[^\]]*\]\}\s*$/,Zb=/\banchor=(?:"document"|'document'|document)(?:\s|\]|$)/,Qb=/^<video\s[^>]*data-squisq-video-placement="[^"]+"[^>]*><\/video>\s*$/,$b=/\bdata-squisq-video-lock-to-block="(?:false|0)"/;function ex(e){return Xb.test(e)?Zb.test(e):Qb.test(e)&&$b.test(e)}function tx(e){let t=0;if(e[0]?.trim()===`---`){for(let n=1;n<e.length;n++)if(e[n].trim()===`---`){t=n+1;break}}let n=Vb(e.join(`
|
|
383
|
+
`));for(let r=t;r<e.length;r++)if(!n[r]&&/^#{1,6}\s/.test(e[r]))return r+1;return t}function nx(e,t){if(t.length===0)return e;let n=e.split(`
|
|
384
|
+
`),r=tx(n),i=r,a=r;for(;;){for(;i<n.length&&n[i].trim()===``;)i++;if(i>=n.length||!ex(n[i]))break;i++,a=i}if(a>r){for(;a<n.length&&n[a].trim()===``;)a++;n.splice(r,a-r)}let o=[];for(let e of t)o.length>0&&o.push(``),o.push(e);let s=n.slice(0,r),c=n.slice(r);return s.length>0&&s[s.length-1].trim()!==``&&s.push(``),c.length>0&&c[0].trim()!==``&&o.push(``),[...s,...o,...c].join(`
|
|
385
|
+
`)}function rx(e,t){let n=e.getModel();if(!n)return!1;let r=e.getPosition();if(!r)return!1;let i=Vb(n.getValue());for(let a=r.lineNumber;a>=1;a--){if(i[a-1])continue;let r=n.getLineContent(a);if(!/^#{1,6}\s/.test(r))continue;if(/\{\[audio=/.test(r))return!0;let o=r.replace(/\s+$/,``),s=` {[audio=${t}]}`,c=o.length+1;return e.executeEdits(`recorder-annotation`,[{range:{startLineNumber:a,startColumn:c,endLineNumber:a,endColumn:c},text:s}]),!0}return!1}function ix({open:e,onOpenChange:t,showTrigger:n=!0,mode:r=`cursor`}={}){let{mediaProvider:i,workspaceContainer:a,activeView:o,monacoEditor:s,tiptapEditor:c,insertAtCursor:l,bumpMediaRevision:u,markdownSource:d,setMarkdownSource:f,colorScheme:p,doc:m,allowNarrate:h}=Lp(),g=Ng(),_=g?.activeTheme??y(m),v=r===`document-narration`,b=(0,G.useMemo)(()=>v||!h||!i?null:{doc:m,theme:_,recording:{mediaProvider:i,container:a??null,markdownSource:d,setMarkdownSource:f,bumpMediaRevision:u}},[v,h,i,m,_,a,d,f,u]),x=(0,G.useMemo)(()=>m?{doc:m,theme:_,viewport:g?.activeViewport??Ge.landscape,mediaProvider:i,captureTimings:v}:null,[m,_,g?.activeViewport,i,v]),S=(0,G.useCallback)(e=>{if(u(),v){let t=Yb(e);f(nx(d,t));return}if(e.mediaKind===`audio`){e.source===`mic`&&o===`raw`&&s&&rx(s,e.filename);let t=`<audio src="${e.relativePath}" controls></audio>`;if(o===`wysiwyg`&&c){Nb(c,{type:`audio`,attrs:{src:e.relativePath,controls:!0}});return}if(o===`raw`&&s){l(`
|
|
386
|
+
|
|
387
|
+
${t}
|
|
388
|
+
`);return}f(d?`${d}
|
|
389
|
+
|
|
390
|
+
${t}`:t);return}if(e.source===`screen+camera`&&e.camera){let t=Ib(e);if(t){if(o===`wysiwyg`&&c){Mb(c,[{type:`video`,attrs:t.screenAttrs},{type:`video`,attrs:t.cameraAttrs}]);return}let e=`${t.screenTag}
|
|
391
|
+
|
|
392
|
+
${t.cameraTag}`;if(o===`raw`&&s){l(`
|
|
393
|
+
|
|
394
|
+
${e}
|
|
395
|
+
`);return}f(d?`${d}
|
|
396
|
+
|
|
397
|
+
${e}`:e);return}}let t=`<video src="${e.relativePath}" controls width="480"></video>`;if(o===`wysiwyg`&&c){Nb(c,{type:`video`,attrs:{src:e.relativePath,controls:!0,width:480}});return}if(o===`raw`&&s){l(t);return}f(d?`${d}
|
|
398
|
+
|
|
399
|
+
${t}`:t)},[v,o,s,c,l,u,d,f]);return i?(0,K.jsx)(rl,{mediaProvider:i,container:a,colorScheme:p,narration:b,slides:x,onSave:S,className:`squisq-toolbar-button`,open:e,onOpenChange:t,showTrigger:n,initialMode:v?`camera`:`mic`,tooltip:v?`Record document narration`:`Record media`,title:v?`Record document narration`:`Record media`}):null}function ax(e,t){let n=e.children,r=n.indexOf(t);if(r<0)return[];let i=[];for(let e=r+1;e<n.length;e++){let t=n[e];if(t.type===`heading`)break;i.push(t)}return i}function ox(e,t){let n=Tt(e);for(let e of n.children){if(e.type!==`heading`)continue;let r=e.position;if(r&&r.start.line<=t&&r.end.line>=t)return ax(n,e)}return null}function sx(e,t){let n=Tt(e),r=0;for(let e of n.children)if(e.type===`heading`){if(r===t)return ax(n,e);r++}return null}function cx(e){let t=/^\s*([a-z][a-z0-9+.-]*)\s*:/i.exec(e);return t?t[1].toLowerCase():null}function lx({mode:e,initialText:t,initialUrl:n,onConfirm:r,onClose:i,documentLinkProvider:a,linkSchemes:o}){let[s,c]=(0,G.useState)(t),[l,u]=(0,G.useState)(n),[d,f]=(0,G.useState)(`url`),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)([]),[_,v]=(0,G.useState)(!1),y=(0,G.useRef)(null),b=(0,G.useRef)(null),x=(0,G.useRef)(null),S=(0,G.useRef)(null),C=(0,G.useRef)(null),w=(0,G.useId)(),T=(0,G.useId)();Ur({rootRef:S,dialogRef:C,initialFocusRef:t?b:y,onClose:i}),(0,G.useEffect)(()=>{if(!a||d!==`documents`)return;let e=!1;return v(!0),a(p).then(t=>{e||(g(t),v(!1))}).catch(()=>{e||(g([]),v(!1))}),()=>{e=!0}},[p,a,d]),(0,G.useEffect)(()=>{if(d===`documents`){let e=setTimeout(()=>x.current?.focus(),0);return()=>clearTimeout(e)}},[d]);let E=(0,G.useMemo)(()=>{let e=l.trim();if(!e||mt(e,`link`,o?{extraLinkSchemes:o}:void 0)!==null)return null;let t=cx(e);return t?`\u201C${t}:\u201D links aren\u2019t supported \u2014 they won\u2019t open when the document is viewed or exported. Use https:, mailto:, tel:, an anchor like #section, or a relative path.`:`That URL isn’t supported. Use https:, mailto:, tel:, an anchor like #section, or a relative path.`},[l,o]),D=(0,G.useCallback)(e=>{if(e.preventDefault(),E){b.current?.focus();return}r(s,l)},[s,l,r,E]),O=(0,G.useCallback)(e=>{e.target===e.currentTarget&&i()},[i]),k=e===`update`,A=k?`Update`:`Insert`,j=k?`Edit link`:`Insert link`,M=(0,G.useCallback)(e=>{u(e.path),c(t=>t||e.label),f(`url`)},[]);return(0,K.jsx)(`div`,{ref:S,className:`squisq-link-dialog-overlay`,onMouseDown:O,children:(0,K.jsxs)(`form`,{ref:C,className:`squisq-link-dialog`,onSubmit:D,role:`dialog`,"aria-modal":`true`,"aria-labelledby":w,tabIndex:-1,children:[(0,K.jsxs)(`div`,{className:`squisq-link-dialog-header`,children:[(0,K.jsx)(`h2`,{id:w,className:`squisq-link-dialog-title`,children:j}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-link-dialog-close`,onClick:i,"aria-label":`Close`,children:`×`})]}),(0,K.jsxs)(`div`,{className:`squisq-link-dialog-body`,children:[a&&(0,K.jsxs)(`div`,{className:`squisq-link-dialog-tabs`,role:`tablist`,children:[(0,K.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":d===`url`,className:`squisq-link-dialog-tab${d===`url`?` squisq-link-dialog-tab--active`:``}`,onClick:()=>f(`url`),children:`URL`}),(0,K.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":d===`documents`,className:`squisq-link-dialog-tab${d===`documents`?` squisq-link-dialog-tab--active`:``}`,onClick:()=>f(`documents`),children:`Browse documents`})]}),(0,K.jsxs)(`label`,{className:`squisq-link-dialog-field`,children:[(0,K.jsx)(`span`,{className:`squisq-link-dialog-label`,children:`Text`}),(0,K.jsx)(`input`,{ref:y,type:`text`,className:`squisq-link-dialog-input`,value:s,onChange:e=>c(e.target.value),placeholder:`Link caption`})]}),d===`url`?(0,K.jsxs)(`label`,{className:`squisq-link-dialog-field`,children:[(0,K.jsx)(`span`,{className:`squisq-link-dialog-label`,children:`URL`}),(0,K.jsx)(`input`,{ref:b,type:`text`,className:`squisq-link-dialog-input${E?` squisq-link-dialog-input--invalid`:``}`,value:l,onChange:e=>u(e.target.value),placeholder:`https://example.com`,spellCheck:!1,autoComplete:`off`,"aria-invalid":E?!0:void 0,"aria-describedby":E?T:void 0}),E?(0,K.jsx)(`span`,{id:T,className:`squisq-link-dialog-error`,role:`alert`,children:E}):null]}):(0,K.jsxs)(`div`,{className:`squisq-link-dialog-doc-picker`,children:[(0,K.jsxs)(`label`,{className:`squisq-link-dialog-field`,children:[(0,K.jsx)(`span`,{className:`squisq-link-dialog-label`,children:`Search`}),(0,K.jsx)(`input`,{ref:x,type:`text`,className:`squisq-link-dialog-input`,value:p,onChange:e=>m(e.target.value),placeholder:`Type to filter…`,spellCheck:!1,autoComplete:`off`})]}),(0,K.jsx)(`div`,{className:`squisq-link-dialog-doc-list`,role:`listbox`,"aria-label":`Document candidates`,"aria-busy":_,children:_&&h.length===0?(0,K.jsx)(`div`,{className:`squisq-link-dialog-doc-empty`,children:`Loading…`}):h.length===0?(0,K.jsx)(`div`,{className:`squisq-link-dialog-doc-empty`,children:p.trim()?`No matches for "${p.trim()}"`:`No documents`}):h.map(e=>(0,K.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":l===e.path,className:`squisq-link-dialog-doc-item${l===e.path?` squisq-link-dialog-doc-item--selected`:``}`,onClick:()=>M(e),children:[(0,K.jsx)(`span`,{className:`squisq-link-dialog-doc-item-label`,children:e.label}),(0,K.jsx)(`span`,{className:`squisq-link-dialog-doc-item-path`,children:e.path}),e.description&&(0,K.jsx)(`span`,{className:`squisq-link-dialog-doc-item-desc`,children:e.description})]},e.path))}),l&&(0,K.jsxs)(`div`,{className:`squisq-link-dialog-doc-current`,children:[`Selected: `,(0,K.jsx)(`code`,{children:l})]})]})]}),(0,K.jsxs)(`div`,{className:`squisq-link-dialog-footer`,children:[(0,K.jsx)(`button`,{type:`button`,className:`squisq-link-dialog-btn squisq-link-dialog-btn--secondary`,onClick:i,children:`Cancel`}),(0,K.jsx)(`button`,{type:`submit`,className:`squisq-link-dialog-btn squisq-link-dialog-btn--primary`,disabled:E!==null,children:A})]})]})})}function ux(e,t,n=1){return e.width<=0||e.height<=0||t.width<=0||t.height<=0?Math.min(1,n):Math.min(n,t.width/e.width,t.height/e.height)}var dx=Object.freeze({tx:0,ty:0,scale:1}),fx=.02,px=8;function mx(e=dx){let[t,n]=(0,G.useState)(e),r=(0,G.useRef)(t);r.current=t;let i=(0,G.useCallback)(e=>{r.current=e,n(e)},[]);return{transform:t,setTransform:i,panBy:(0,G.useCallback)((e,t)=>{let n=r.current;i({tx:n.tx+e,ty:n.ty+t,scale:n.scale})},[i]),zoomAt:(0,G.useCallback)((e,t,n)=>{let a=r.current,o=hx(a.scale*e,fx,px),s=o/a.scale,c=t-(t-a.tx)*s,l=n-(n-a.ty)*s;i({tx:c,ty:l,scale:o})},[i]),reset:(0,G.useCallback)(()=>i(dx),[i]),fitBox:(0,G.useCallback)((e,t,n=24,r=px)=>{if(e.width<=0||e.height<=0||t.width<=0||t.height<=0)return;let a=Math.max(1,t.width-n*2),o=Math.max(1,t.height-n*2),s=ux({width:e.width,height:e.height},{width:a,height:o},Math.min(px,Math.max(2**-52,r))),c=e.width*s,l=e.height*s,u=(t.width-c)/2-e.x*s,d=(t.height-l)/2-e.y*s;i({tx:u,ty:d,scale:s})},[i]),screenToViewport:(0,G.useCallback)((e,t)=>{let n=r.current;return{x:(e-n.tx)/n.scale,y:(t-n.ty)/n.scale}},[]),viewportToScreen:(0,G.useCallback)((e,t)=>{let n=r.current;return{x:e*n.scale+n.tx,y:t*n.scale+n.ty}},[])}}function hx(e,t,n){return Math.min(n,Math.max(t,e))}function gx(e=[]){let[t,n]=(0,G.useState)(()=>new Set(e));return{selection:t,setSelection:(0,G.useCallback)(e=>{n(new Set(e))},[]),select:(0,G.useCallback)((e,t=!1)=>{n(n=>{if(t){if(n.has(e))return n;let t=new Set(n);return t.add(e),t}return n.size===1&&n.has(e)?n:new Set([e])})},[]),toggle:(0,G.useCallback)(e=>{n(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),clear:(0,G.useCallback)(()=>{n(e=>e.size===0?e:new Set)},[]),isSelected:(0,G.useCallback)(e=>t.has(e),[t])}}function _x(){return{hit:(0,G.useCallback)((e,t)=>{for(let n=t.length-1;n>=0;n--){let r=t[n];if(yx(e,r.bounds))return r.id}return null},[])}}function vx(e,t,n={}){let r=e.position;if(!r)return null;let i=bx(r.width,t.width,n.width),a=bx(r.height,t.height,n.height);if(i==null||a==null)return null;let o=bx(r.x,t.width,0)??0,s=bx(r.y,t.height,0)??0,{ax:c,ay:l}=xx(r.anchor??`top-left`,i,a);return{x:o-c,y:s-l,width:i,height:a}}function yx(e,t){return e.x>=t.x&&e.x<=t.x+t.width&&e.y>=t.y&&e.y<=t.y+t.height}function bx(e,t,n){if(typeof e==`number`)return e;if(typeof e==`string`){if(e.endsWith(`%`)){let n=parseFloat(e);if(Number.isFinite(n))return n/100*t}let n=parseFloat(e);if(Number.isFinite(n))return n}return n}function xx(e,t,n){switch(e){case`center`:return{ax:t/2,ay:n/2};case`top-right`:return{ax:t,ay:0};case`bottom-left`:return{ax:0,ay:n};case`bottom-right`:return{ax:t,ay:n};default:return{ax:0,ay:0}}}var Sx=(0,G.forwardRef)(function({width:e,height:t,transform:n,onWheel:r,onPointerDown:i,onPointerMove:a,onPointerUp:o,onPointerCancel:s,onDoubleClick:c,onDragOver:l,onDrop:u,cursor:d,children:f},p){let m=n,h=`squisq-scene-dot-grid-${(0,G.useId)().replace(/:/g,``)}`,g=`translate(${m.tx} ${m.ty}) scale(${m.scale})`;return(0,K.jsxs)(`svg`,{ref:p,className:`squisq-scene-viewport`,width:e,height:t,"data-cursor":d??`default`,onWheel:r,onPointerDown:i,onPointerMove:a,onPointerUp:o,onPointerCancel:s,onDoubleClick:c,onDragOver:l,onDrop:u,role:`application`,tabIndex:-1,children:[(0,K.jsx)(`defs`,{children:(0,K.jsx)(`pattern`,{id:h,x:m.tx,y:m.ty,width:24*m.scale,height:24*m.scale,patternUnits:`userSpaceOnUse`,children:(0,K.jsx)(`circle`,{cx:1,cy:1,r:1,className:`squisq-scene-dot`})})}),(0,K.jsx)(`rect`,{width:`100%`,height:`100%`,fill:`url(#${h})`}),(0,K.jsx)(`g`,{transform:g,children:f})]})}),Cx=8;function wx({selection:e,hitItems:t,liveOffset:n,liveResize:r,onHandlePointerDown:i,showHandles:a=!0}){if(e.size===0)return null;let o=t.filter(t=>e.has(t.id));if(o.length===0)return null;let s=n??{dx:0,dy:0};return(0,K.jsx)(`g`,{className:`squisq-scene-selection-group`,children:o.map(e=>{let t,n,o,c;r&&r.layerId===e.id?(t=r.bounds.x,n=r.bounds.y,o=r.bounds.width,c=r.bounds.height):(t=e.bounds.x+s.dx,n=e.bounds.y+s.dy,o=e.bounds.width,c=e.bounds.height);let l=[{corner:`nw`,cx:t,cy:n,cursor:`nwse-resize`},{corner:`n`,cx:t+o/2,cy:n,cursor:`ns-resize`},{corner:`ne`,cx:t+o,cy:n,cursor:`nesw-resize`},{corner:`e`,cx:t+o,cy:n+c/2,cursor:`ew-resize`},{corner:`se`,cx:t+o,cy:n+c,cursor:`nwse-resize`},{corner:`s`,cx:t+o/2,cy:n+c,cursor:`ns-resize`},{corner:`sw`,cx:t,cy:n+c,cursor:`nesw-resize`},{corner:`w`,cx:t,cy:n+c/2,cursor:`ew-resize`}];return(0,K.jsxs)(`g`,{className:`squisq-scene-selection`,children:[(0,K.jsx)(`rect`,{x:t,y:n,width:o,height:c,className:`squisq-scene-selection-outline`,pointerEvents:`none`}),a&&l.map(({corner:e,cx:t,cy:n,cursor:r})=>(0,K.jsx)(`rect`,{x:t-Cx/2,y:n-Cx/2,width:Cx,height:Cx,className:`squisq-scene-selection-handle`,style:{cursor:r},onPointerDown:i?t=>i(t,e):void 0,"data-corner":e},e))]},e.id)})})}var Tx=3,Ex=8;function Dx(e){return e.selectDrag??null}function Ox(e,t){e.selectDrag=t??void 0}function kx(e){let t=e.currentTarget.getBoundingClientRect();return{sx:e.clientX-t.left,sy:e.clientY-t.top}}function Ax(e,t){let n=e.hitItems.find(e=>e.id===t);return n?{x:n.bounds.x,y:n.bounds.y}:null}function jx(e,t,n){let r=e.x,i=e.y,a=e.x+e.width,o=e.y+e.height;return t.includes(`w`)&&(r=Math.min(n.x,a-Ex)),t.includes(`e`)&&(a=Math.max(n.x,r+Ex)),t.includes(`n`)&&(i=Math.min(n.y,o-Ex)),t.includes(`s`)&&(o=Math.max(n.y,i+Ex)),{x:r,y:i,width:a-r,height:o-i}}function Mx(e,t){Ox(t,{kind:`resize`,layerId:e.layerId,corner:e.corner,startV:e.startV,startBounds:e.startBounds,currentBounds:e.startBounds})}var Nx={id:`select`,label:`Select`,cursor:`default`,shortcut:`v`,onPointerDown(e,t){if(e.button!==0)return;let{sx:n,sy:r}=kx(e),i=t.screenToViewport(n,r),a=t.hit(i);if(a){let o=e.shiftKey?new Set([...t.selection,a]):t.selection.has(a)?t.selection:new Set([a]);o!==t.selection&&t.setSelection(o);let s=new Map;for(let e of o){let n=Ax(t,e);n&&s.set(e,n)}Ox(t.interaction,{kind:`move`,startV:i,startS:{x:n,y:r},layerStarts:s,currentV:i,movedPastThreshold:!1})}else e.shiftKey||t.setSelection([]),Ox(t.interaction,{kind:`marquee`,startV:i,startS:{x:n,y:r},currentV:i,movedPastThreshold:!1});e.currentTarget.setPointerCapture?.(e.pointerId)},onPointerMove(e,t){let n=Dx(t.interaction);if(!n)return;let{sx:r,sy:i}=kx(e),a=t.screenToViewport(r,i);if(n.kind===`resize`){n.currentBounds=jx(n.startBounds,n.corner,a);return}if(n.currentV=a,!n.movedPastThreshold){let e=r-n.startS.x,t=i-n.startS.y;Math.hypot(e,t)>=Tx&&(n.movedPastThreshold=!0)}if(n.kind===`marquee`){let e=Ix(n.startV,a),r=t.hitItems.filter(t=>Lx(t.bounds,e)).map(e=>e.id);t.setSelection(r)}},onPointerUp(e,t){let n=Dx(t.interaction);if(n){if(n.kind===`move`&&n.movedPastThreshold&&n.layerStarts.size>0){let e=n.currentV.x-n.startV.x,r=n.currentV.y-n.startV.y;for(let[i,a]of n.layerStarts){let n={kind:`moveLayer`,id:i,x:a.x+e,y:a.y+r};t.dispatch(n)}}else if(n.kind===`resize`){let{x:e,y:r,width:i,height:a}=n.currentBounds;t.dispatch({kind:`resizeLayer`,id:n.layerId,x:e,y:r,width:i,height:a})}e.currentTarget.releasePointerCapture?.(e.pointerId),Ox(t.interaction,null)}},onDoubleClick(e,t){let n=e.currentTarget.getBoundingClientRect(),r=t.screenToViewport(e.clientX-n.left,e.clientY-n.top),i=t.hit(r);i&&t.beginTextEdit?.(i)},onKeyDown(e,t){if(e.key===`Delete`||e.key===`Backspace`){for(let e of t.selection)t.dispatch({kind:`removeLayer`,id:e});t.setSelection([]),e.preventDefault()}else e.key===`Escape`&&t.setSelection([])},renderOverlay(e){let t=Dx(e.interaction);if(!t||t.kind!==`marquee`||!t.movedPastThreshold)return null;let n=Ix(t.startV,t.currentV);return(0,G.createElement)(`rect`,{key:`select-marquee`,x:n.x,y:n.y,width:n.width,height:n.height,className:`squisq-scene-marquee`})}};function Px(e){let t=Dx(e);return!t||t.kind!==`move`||!t.movedPastThreshold?null:{dx:t.currentV.x-t.startV.x,dy:t.currentV.y-t.startV.y}}function Fx(e){let t=Dx(e);return!t||t.kind!==`resize`?null:{layerId:t.layerId,bounds:t.currentBounds}}function Ix(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y)}}function Lx(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Rx(e){let[t,n]=(0,G.useState)(null),r=(0,G.useRef)(!1);return r.current=t!=null,{editingId:t,begin:(0,G.useCallback)(t=>{if(!e)return;let r=e.resolveEditableId(t);r&&n(r)},[e]),close:(0,G.useCallback)(()=>n(null),[]),activeRef:r}}function zx(e){return[e===`inline`?br.configure({heading:!1,bulletList:!1,orderedList:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1}):e===`block`?br.configure({heading:!1,horizontalRule:!1}):br.configure({horizontalRule:!1}),Zf.configure({openOnClick:!1})]}function Bx({config:e,layer:t,editableId:n,viewport:r,transform:i,viewportToScreen:a,onClose:o}){let s=(0,G.useMemo)(()=>e.getHtml(n),[e,n]),c=t.type===`text`?t.content.style:void 0,l=(0,G.useRef)(!1),u=(0,G.useRef)(()=>{}),d=(0,G.useRef)(()=>{}),f=Mr({extensions:zx(e.level),content:s,autofocus:`end`,editorProps:{handleKeyDown:(t,n)=>{if(n.key===`Escape`)return n.preventDefault(),d.current(),!0;let r=e.level===`inline`?!n.shiftKey:n.metaKey||n.ctrlKey;return n.key===`Enter`&&r?(n.preventDefault(),u.current(),!0):!1}}});u.current=(0,G.useCallback)(()=>{if(l.current||!f)return;l.current=!0;let t=f.getHTML();e.commit(n,{html:t,text:Be(t)}),o()},[f,e,n,o]),d.current=(0,G.useCallback)(()=>{l.current=!0,o()},[o]),(0,G.useEffect)(()=>{if(!f||!e.channel)return;let t=e.channel;return t.set({editor:f,level:e.level}),()=>{t.get()?.editor===f&&t.set(null)}},[f,e.level,e.channel]);let p=(0,G.useCallback)(e=>{let t=e.relatedTarget;t&&t.closest(`.squisq-toolbar, .squisq-scene-text-overlay`)||u.current()},[]),m=vx(t,r);if(!m)return null;let h=a(m.x,m.y),g=i.scale,_=(c?.fontSize??18)*g,v=(c?.padding??0)*g,y=c?.verticalAlign===`middle`?`center`:c?.verticalAlign===`bottom`?`flex-end`:`flex-start`;return(0,K.jsx)(`div`,{className:`squisq-scene-text-overlay`,onBlur:p,onPointerDown:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),style:{position:`absolute`,left:h.x,top:h.y,width:m.width*g,height:m.height*g,zIndex:20,boxSizing:`border-box`,display:`flex`,flexDirection:`column`,justifyContent:y,padding:v,fontSize:_,fontFamily:c?.fontFamily||`system-ui, -apple-system, "Segoe UI", Roboto, sans-serif`,color:c?.color??`#1e293b`,lineHeight:c?.lineHeight||1.4,textAlign:c?.textAlign??`left`,background:`var(--squisq-surface)`,border:`2px solid var(--squisq-accent)`,borderRadius:4,overflow:`auto`,cursor:`text`},children:(0,K.jsx)(Ir,{editor:f,className:`squisq-scene-text-editor`})})}function Vx({scale:e,fit:t,onZoomOut:n,onZoomIn:r,onFit:i}){return(0,K.jsxs)(`div`,{className:`squisq-scene-view-controls`,role:`toolbar`,"aria-label":`Diagram view`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:n,title:`Zoom out`,"aria-label":`Zoom out`,children:(0,K.jsx)(q,{icon:`fa-solid fa-minus`})}),(0,K.jsxs)(`output`,{className:`squisq-scene-view-scale`,"aria-label":`Diagram zoom`,children:[Math.round(e*100),`%`]}),(0,K.jsx)(`button`,{type:`button`,onClick:r,title:`Zoom in`,"aria-label":`Zoom in`,children:(0,K.jsx)(q,{icon:`fa-solid fa-plus`})}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-scene-view-fit`,"data-active":t||void 0,"aria-pressed":t,onClick:i,title:`Fit all shapes in the canvas`,"aria-label":`Fit diagram`,children:`Fit`})]})}function Hx(e){let{viewport:t,layers:n,edges:r=[],tools:i,activeToolId:a,onActiveToolIdChange:o,onCommand:s,onSelectionChange:c,renderExtras:l,renderLayer:u,layerFollows:d,showMaximize:f,maximized:p,onToggleMaximize:m,showViewControls:h=!1,showToolbar:g=!0,textEditing:_,onDrop:v}=e,y=u??Ux,b=Rx(_),[x,S]=(0,G.useState)(i[0]?.id??`select`),C=a??x,w=(0,G.useCallback)(e=>{o?o(e):S(e)},[o]),T=(0,G.useMemo)(()=>i.find(e=>e.id===C)??i[0],[i,C]),E=mx(),{fitBox:D,zoomAt:O}=E,[k,A]=(0,G.useState)(`fit`),j=gx(),M=j.setSelection,{hit:N}=_x(),P=(0,G.useRef)({}).current,F=(0,G.useCallback)(e=>{let t=new Set(e);M(t),c?.(t)},[M,c]),I=(0,G.useMemo)(()=>{let e=[];for(let r of n){let n=vx(r,t);n&&e.push({id:r.id,layer:r,bounds:n})}return e},[n,t]),L=(0,G.useMemo)(()=>({interaction:P,viewport:t,transform:E.transform,layers:n,edges:r,selection:j.selection,hitItems:I,screenToViewport:E.screenToViewport,viewportToScreen:E.viewportToScreen,hit:e=>N(e,I),setSelection:F,dispatch:s,setActiveTool:w,beginTextEdit:b.begin}),[t,E.transform,E.screenToViewport,E.viewportToScreen,n,r,j.selection,F,I,N,s,w,b.begin,P]),ee=(0,G.useRef)(L);ee.current=L;let te=(0,G.useRef)(null),R=(0,G.useRef)(!1),ne=(0,G.useRef)(null),re=(0,G.useCallback)(e=>{if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();let t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top,i=Math.exp(-e.deltaY*.0015);A(`manual`),E.zoomAt(i,n,r)},[E]),[,z]=(0,G.useState)(0),ie=(0,G.useRef)(!1),ae=(0,G.useCallback)(()=>z(e=>e+1),[]),oe=(0,G.useCallback)(e=>{if(e.currentTarget.focus({preventScroll:!0}),e.button===1||e.button===0&&e.altKey){A(`manual`),R.current=!0,ne.current={x:e.clientX,y:e.clientY},e.currentTarget.setPointerCapture?.(e.pointerId),e.preventDefault();return}ie.current=!0,T?.onPointerDown?.(e,ee.current),ae()},[T,ae]),se=(0,G.useCallback)(e=>{if(R.current&&ne.current){let t=e.clientX-ne.current.x,n=e.clientY-ne.current.y;ne.current={x:e.clientX,y:e.clientY},E.panBy(t,n);return}T?.onPointerMove?.(e,ee.current),ie.current&&ae()},[T,E,ae]),ce=(0,G.useCallback)(e=>{if(ie.current=!1,R.current){R.current=!1,ne.current=null,e.currentTarget.releasePointerCapture?.(e.pointerId);return}T?.onPointerUp?.(e,ee.current)},[T]),le=(0,G.useCallback)(e=>{ie.current=!1,R.current=!1,ne.current=null,P.selectDrag=void 0,P.connect=void 0,e.currentTarget.releasePointerCapture?.(e.pointerId),ae()},[P,ae]);(0,G.useEffect)(()=>()=>{P.selectDrag=void 0,P.connect=void 0},[P]);let B=(0,G.useCallback)(e=>{T?.onDoubleClick?.(e,ee.current)},[T]),ue=(0,G.useCallback)(e=>{v&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)},[v]),V=(0,G.useCallback)(e=>{if(!v)return;e.preventDefault();let t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;v(e,E.screenToViewport(n,r))},[v,E]);(0,G.useEffect)(()=>{let e=te.current;if(!e)return;let t=e=>{if(!b.activeRef.current){if(!e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.length===1){let t=e.key.toLowerCase(),n=i.find(e=>e.shortcut===t);if(n){w(n.id),e.preventDefault();return}}T?.onKeyDown?.(e,ee.current)}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[i,T,w,b.activeRef]);let[de,fe]=(0,G.useState)(null);(0,G.useLayoutEffect)(()=>{if(!te.current)return;let e=te.current,t=()=>{let t=e.getBoundingClientRect();fe({width:t.width,height:t.height})};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let H=(0,G.useMemo)(()=>{if(I.length===0)return null;let e=1/0,t=1/0,n=-1/0,r=-1/0;for(let i of I)i.bounds.x<e&&(e=i.bounds.x),i.bounds.y<t&&(t=i.bounds.y),i.bounds.x+i.bounds.width>n&&(n=i.bounds.x+i.bounds.width),i.bounds.y+i.bounds.height>r&&(r=i.bounds.y+i.bounds.height);return Number.isFinite(e)?{x:e,y:t,width:n-e,height:r-t}:null},[I]),pe=(0,G.useCallback)(()=>{!de||!H||D(H,de,40,1)},[de,H,D]);(0,G.useEffect)(()=>{k===`fit`&&pe()},[pe,k]);let me=(0,G.useCallback)(e=>{A(`manual`),de&&O(e,de.width/2,de.height/2)},[de,O]),U=(0,G.useCallback)(()=>{A(`fit`),pe()},[pe]),he=C===`select`?Px(P):null,ge=C===`select`?Fx(P):null,_e=T?.hideSelectionHandles!==!0,W=e=>{let t=d?.(e.id)??null,n=j.selection.has(e.id)?e.id:t&&j.selection.has(t)?t:null;if(!n)return{};if(ge&&ge.layerId===n){let e=I.find(e=>e.id===n)?.bounds;if(!e)return{};let t=e.width>0?ge.bounds.width/e.width:1,r=e.height>0?ge.bounds.height/e.height:1;return{transform:`matrix(${t} 0 0 ${r} ${ge.bounds.x-e.x*t} ${ge.bounds.y-e.y*r})`}}return he?{transform:`translate(${he.dx} ${he.dy})`}:{}},ve=e=>{if(!ge||ge.layerId!==e.id||e.type!==`text`)return null;let t=ge.bounds;return{...e,position:{...e.position,x:t.x,y:t.y,width:t.width,height:t.height,anchor:`top-left`}}};return(0,K.jsxs)(`div`,{className:`squisq-scene-root`,children:[g&&(0,K.jsx)(Wx,{tools:i,activeId:C,onSelect:w}),(0,K.jsxs)(Sx,{ref:te,width:de?.width??t.width,height:de?.height??t.height,transform:E.transform,cursor:T?.cursor,onWheel:re,onPointerDown:oe,onPointerMove:se,onPointerUp:ce,onPointerCancel:le,onDoubleClick:B,onDragOver:v?ue:void 0,onDrop:v?V:void 0,children:[l&&(0,K.jsx)(`g`,{className:`squisq-scene-extras`,children:l(L)}),n.map(e=>{let n=`squisq-scene-layer squisq-scene-layer--${e.type}`,r=ve(e);return r?(0,K.jsx)(`g`,{className:n,"data-layer-id":e.id,children:y(r,t)},e.id):(0,K.jsx)(`g`,{className:n,"data-layer-id":e.id,...W(e),children:y(e,t)},e.id)}),(0,K.jsx)(wx,{selection:j.selection,hitItems:I,liveOffset:he,liveResize:ge,onHandlePointerDown:_e?(e,t)=>{let n=j.selection.values().next().value;if(!n)return;let r=I.find(e=>e.id===n)?.bounds;if(!r)return;let i=te.current;if(!i)return;let a=i.getBoundingClientRect(),o=e.clientX-a.left,s=e.clientY-a.top;Mx({layerId:n,corner:t,startV:E.screenToViewport(o,s),startBounds:r},P),e.currentTarget.setPointerCapture?.(e.pointerId),ie.current=!0,ae(),e.stopPropagation()}:void 0,showHandles:_e}),T?.renderOverlay?.(L)]}),h&&(0,K.jsx)(Vx,{scale:E.transform.scale,fit:k===`fit`,onZoomOut:()=>me(1/1.2),onZoomIn:()=>me(1.2),onFit:U}),f&&m&&(0,K.jsx)(`button`,{type:`button`,className:`squisq-scene-maximize-btn`,onClick:m,title:p?`Exit fullscreen (Esc)`:`Maximize`,children:p?`✕`:`⛶`}),_&&b.editingId&&(()=>{let e=n.find(e=>e.id===b.editingId);return e?(0,K.jsx)(Bx,{config:_,layer:e,editableId:b.editingId,viewport:t,transform:E.transform,viewportToScreen:E.viewportToScreen,onClose:b.close}):null})()]})}function Ux(e,t){return(0,K.jsx)(Cv,{layer:e,viewport:t})}function Wx({tools:e,activeId:t,onSelect:n}){return e.length<=1?null:(0,K.jsx)(`div`,{className:`squisq-scene-toolbar`,role:`toolbar`,"aria-label":`Scene tools`,children:e.map(e=>(0,K.jsx)(`button`,{type:`button`,className:`squisq-scene-tool${t===e.id?` squisq-scene-tool--active`:``}`,onClick:()=>n(e.id),title:e.shortcut?`${e.label} (${e.shortcut.toUpperCase()})`:e.label,"aria-pressed":t===e.id,children:e.icon??(0,K.jsx)(`span`,{className:`squisq-scene-tool-label`,children:e.label})},e.id))})}var Gx=`layers`;function Kx(e){let t=Qx(e).params?.[Gx];return t?Zx(t):[]}function qx(e,t,n){return e.chain().command(({tr:e})=>{let r=e.doc.nodeAt(t);if(!r||r.type.name!==`heading`)return!1;let i=Qx(r),a={...i.params??{}};n.length===0?delete a[Gx]:a[Gx]=Xx(n);let o={...i};o.params=Object.keys(a).length>0?a:void 0;let s=Ct(o);return e.setNodeAttribute(t,`dataBlockAttrs`,$x(s)),!0}).run()}function Jx(e){let t=new TextEncoder().encode(e);if(typeof globalThis.btoa==`function`){let e=``;for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return globalThis.btoa(e)}return Buffer.from(t).toString(`base64`)}function Yx(e){if(typeof globalThis.atob==`function`){let t=globalThis.atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return new TextDecoder().decode(n)}return Buffer.from(e,`base64`).toString(`utf-8`)}function Xx(e){return Jx(JSON.stringify(e))}function Zx(e){try{let t=JSON.parse(Yx(e));return Array.isArray(t)?t:[]}catch{return[]}}function Qx(e){let t=e.attrs.dataBlockAttrs;return typeof t==`string`&&t.length>0?Et(t):{}}function $x(e){return e==null||e===`{}`?null:e.startsWith(`{`)&&e.endsWith(`}`)?e.slice(1,-1):e}function eS(e){return e.toLowerCase().replace(/[^\w\s-]/g,``).replace(/[\s_]+/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``)||`block`}function tS(e){let t=``;return e.content.forEach(e=>{e.isText&&(t+=e.text??``)}),t}function nS(e){let t=e.attrs.dataBlockAttrs;return typeof t==`string`&&t.length>0?Et(t):{}}function rS(e){return nS(e).id??eS(tS(e))}function iS(e,t){let{state:n}=e,r=n.doc.nodeAt(t);if(!r||r.type.name!==`heading`)return[];let i=r.attrs.level,a;{let e=t+r.nodeSize,o=n.doc.content.size;for(;e<o;){let t=n.doc.nodeAt(e);if(!t)break;if(t.type.name===`heading`){let e=t.attrs.level;if(e<=i)break;(a===void 0||e<a)&&(a=e)}e+=t.nodeSize}}if(a===void 0)return[];let o=[],s=t+r.nodeSize,c=n.doc.content.size;for(;s<c;){let e=n.doc.nodeAt(s);if(!e)break;if(e.type.name===`heading`){let t=e.attrs.level;if(t<=i)break;t===a&&o.push({pos:s,node:e,attrs:nS(e),id:rS(e)})}s+=e.nodeSize}return o}function aS(e,t){let{state:n}=e,r=n.doc.nodeAt(t);if(!r||r.type.name!==`heading`)return t;let i=r.attrs.level,a=t+r.nodeSize,o=n.doc.content.size;for(;a<o;){let e=n.doc.nodeAt(a);if(!e)break;if(e.type.name===`heading`&&e.attrs.level<=i)return a;a+=e.nodeSize}return a}function oS(e,t,n,r){let i=iS(e,t).find(e=>e.id===n);if(!i)return!1;let a=i.pos,o=i.node;return e.chain().command(({tr:e,state:t})=>{let n=a+1,i=a+o.nodeSize-1,s=t.schema.text(r);return e.replaceWith(n,i,s),!0}).run()}function sS(e,t){return iS(e,t).map(t=>{let n=t.node.attrs;return{pos:t.pos,node:t.node,id:t.id,kind:n.dataTemplate??null,params:n.dataTemplateParams?Et(n.dataTemplateParams).params??{}:{},bodyHtml:gS(e,t.pos,t.node),bodyText:_S(e,t.pos,t.node)}})}function cS(e,t,n,r,i,a=``){let o=e.state.doc.nodeAt(t);if(!o||o.type.name!==`heading`)return!1;let s=bS(e,t,o),c=yS(e,t),l=xS(i),u=SS(n);return e.chain().command(({tr:e,state:t})=>{let n=t.schema.nodes.heading;if(!n)return!1;let i=n.create({level:s,dataTemplate:r,dataTemplateParams:l.length>0?l:null,dataBlockAttrs:u}),o=mr.from(i);return a.trim()&&(o=o.append(vS(t.schema,a))),e.insert(c,o),!0}).run()}function lS(e,t,n,r,i){return mS(e,t,n,e=>{e.x=String(Math.round(r)),e.y=String(Math.round(i))})}function uS(e,t,n,r,i){return mS(e,t,n,e=>{e.width=String(Math.round(r)),e.height=String(Math.round(i))})}function dS(e,t,n,r,i){return mS(e,t,n,e=>{i.length===0?delete e[r]:e[r]=i})}function fS(e,t,n,r){let i=sS(e,t).find(e=>e.id===n);if(!i)return!1;let a=i.pos+i.node.nodeSize,[,o]=hS(e,i.pos);return e.chain().command(({tr:e,state:t})=>{if(!e.doc.nodeAt(i.pos))return!1;let n=r.trim()?vS(t.schema,r):mr.empty;return e.replaceWith(a,o,n),!0}).run()}function pS(e,t,n){let r=sS(e,t).find(e=>e.id===n);if(!r)return!1;let[i,a]=hS(e,r.pos);return e.chain().command(({tr:e})=>(e.delete(i,a),!0)).run()}function mS(e,t,n,r){let i=sS(e,t).find(e=>e.id===n);if(!i)return!1;let a={...i.params};r(a);let o=xS(a);return e.chain().command(({tr:e})=>e.doc.nodeAt(i.pos)?(e.setNodeAttribute(i.pos,`dataTemplateParams`,o.length>0?o:null),!0):!1).run()}function hS(e,t){let{state:n}=e,r=n.doc.nodeAt(t);if(!r)return[t,t];let i=t+r.nodeSize,a=n.doc.content.size;for(;i<a;){let e=n.doc.nodeAt(i);if(!e||e.type.name===`heading`||e.type.name===`horizontalRule`)break;i+=e.nodeSize}return[t,i]}function gS(e,t,n){let{state:r}=e,i=t+n.nodeSize,[,a]=hS(e,t);if(a<=i)return``;let o=r.doc.slice(i,a).content;if(o.size===0)return``;let s=fr.fromSchema(r.schema).serializeFragment(o),c=document.createElement(`div`);return c.appendChild(s),c.innerHTML}function _S(e,t,n){let{state:r}=e,i=t+n.nodeSize,[,a]=hS(e,t);return a<=i?``:r.doc.textBetween(i,a,`
|
|
400
|
+
`).trim()}function vS(e,t){let n=document.createElement(`div`);return n.innerHTML=t,dr.fromSchema(e).parse(n).content}function yS(e,t){let n=sS(e,t);return hS(e,n.length>0?n[n.length-1].pos:t)[1]}function bS(e,t,n){let r=n.attrs.level,i=sS(e,t)[0]?.node.attrs.level;return Math.min(6,i??r+1)}function xS(e){return Object.entries(e).map(([e,t])=>`${e}=${gt(t)}`).join(` `)}function SS(e){return CS(Ct({id:e}))}function CS(e){return e==null||e===`{}`?null:e.startsWith(`{`)&&e.endsWith(`}`)?e.slice(1,-1):e}var wS={width:1920,height:1080};function TS(e,t,n={}){let[,r]=(0,G.useState)(0);(0,G.useEffect)(()=>{let t=()=>r(e=>e+1);return e.on(`transaction`,t),()=>{e.off(`transaction`,t)}},[e]);let i=e.state.doc.nodeAt(t)?sS(e,t):[],{layers:a}=x(i.map(e=>({id:e.id,startTime:0,duration:0,audioSegment:0,...e.kind?{template:e.kind}:{},...Object.keys(e.params).length>0?{templateOverrides:e.params}:{}})),wS);for(let e of a){if(e.type!==`text`)continue;let t=i.find(t=>t.id===e.id);t&&(e.content.text=t.bodyText,t.bodyHtml.trim()&&(e.content.html=t.bodyHtml))}let o=(0,G.useRef)(!1);return(0,G.useEffect)(()=>{if(o.current)return;let n=e.state.doc.nodeAt(t);if(!n)return;if(sS(e,t).length>0){o.current=!0;return}let r=Kx(n);if(r.length===0){o.current=!0;return}o.current=!0;for(let n of r){let r=ES(n);cS(e,t,n.id,r.kind,r.params,r.bodyHtml)}qx(e,t,[])},[e,t]),{layers:a,tools:n.tools??[Nx],dispatch:n=>{switch(n.kind){case`moveLayer`:lS(e,t,n.id,n.x,n.y);return;case`resizeLayer`:n.x!==void 0&&n.y!==void 0&&lS(e,t,n.id,n.x,n.y),uS(e,t,n.id,n.width,n.height);return;case`addLayer`:{let r=ES(n.layer);cS(e,t,n.layer.id||jS(e,t,r.kind),r.kind,r.params,r.bodyHtml);return}case`removeLayer`:pS(e,t,n.id);return;case`renameLayer`:fS(e,t,n.id,lr(n.label));return;case`setLayerText`:fS(e,t,n.id,n.html&&n.html.trim()?n.html:lr(n.text));return;case`setLayerAttr`:{let r=kS(n.path);r&&dS(e,t,n.id,r,String(n.value??``));return}case`addEdge`:case`removeEdge`:return}}}}function ES(e){let t=DS(e.position);if(e.type===`text`)return Object.assign(t,OS(e.content.style)),{kind:`text`,params:t,bodyHtml:e.content.html?.trim()?e.content.html:lr(e.content.text??``)};if(e.type===`shape`){let n=e.content,r=n.shape===`rect`?`rectangle`:n.shape;return n.fill&&(t.fill=n.fill),n.stroke&&(t.stroke=n.stroke),n.strokeWidth!=null&&(t.strokeWidth=String(n.strokeWidth)),n.borderStyle&&(t.borderStyle=n.borderStyle),n.borderRadius!=null&&(t.borderRadius=String(n.borderRadius)),{kind:r,params:t,bodyHtml:``}}if(e.type===`path`){let n=e.content;return t.d=n.d,n.stroke&&(t.stroke=n.stroke),n.strokeWidth!=null&&(t.strokeWidth=String(n.strokeWidth)),n.fill&&(t.fill=n.fill),{kind:`path`,params:t,bodyHtml:``}}if(e.type===`image`){let n=e.content;return t.src=n.src,n.alt&&(t.alt=n.alt),n.fit&&(t.fit=n.fit),{kind:`image`,params:t,bodyHtml:``}}return{kind:`text`,params:t,bodyHtml:``}}function DS(e){let t={};return typeof e.x==`number`&&(t.x=String(Math.round(e.x))),typeof e.y==`number`&&(t.y=String(Math.round(e.y))),typeof e.width==`number`&&(t.width=String(Math.round(e.width))),typeof e.height==`number`&&(t.height=String(Math.round(e.height))),t}function OS(e){let t={};return e.fontSize!=null&&(t.fontSize=String(Math.round(e.fontSize))),e.color&&(t.color=e.color),e.fontFamily&&(t.fontFamily=e.fontFamily),e.fontWeight&&e.fontWeight!==`normal`&&(t.fontWeight=e.fontWeight),e.fontStyle&&e.fontStyle!==`normal`&&(t.fontStyle=e.fontStyle),e.textAlign&&(t.align=e.textAlign),e.verticalAlign&&(t.valign=e.verticalAlign),e.lineHeight!=null&&(t.lineHeight=String(e.lineHeight)),e.padding!=null&&(t.padding=String(e.padding)),e.background&&(t.background=e.background),t}function kS(e){switch(e){case`content.style.textAlign`:return`align`;case`content.style.verticalAlign`:return`valign`;case`content.style.fontSize`:return`fontSize`;case`content.style.color`:return`color`;case`content.style.fontFamily`:return`fontFamily`;case`content.style.fontWeight`:return`fontWeight`;case`content.style.fontStyle`:return`fontStyle`;case`content.style.lineHeight`:return`lineHeight`;case`content.style.padding`:return`padding`;case`content.style.background`:return`background`;case`content.fill`:return`fill`;case`content.stroke`:return`stroke`;case`content.strokeWidth`:return`strokeWidth`;case`content.borderStyle`:return`borderStyle`;case`content.borderRadius`:return`borderRadius`;default:return null}}var AS={text:`text`,rectangle:`box`,rect:`box`,circle:`circle`,line:`line`,path:`path`,image:`image`};function jS(e,t,n){let r=new Set(sS(e,t).map(e=>e.id)),i=AS[n]??(n.replace(/[^a-z0-9]/gi,``).toLowerCase()||`layer`),a=1,o=`${i}-${a}`;for(;r.has(o);)o=`${i}-${++a}`;return o}function MS(e){let t=[];for(let n=0;n<e.points.length;n++){let r=e.points[n];switch(r.kind){case`move`:t.push(`M ${NS(r.x)} ${NS(r.y)}`);break;case`line`:t.push(`L ${NS(r.x)} ${NS(r.y)}`);break;case`curve`:{let i=e.points[n-1],a=i?.cpOut??{x:i?.x??r.x,y:i?.y??r.y},o=r.cpIn??{x:r.x,y:r.y};t.push(`C ${NS(a.x)} ${NS(a.y)} ${NS(o.x)} ${NS(o.y)} ${NS(r.x)} ${NS(r.y)}`);break}case`close`:break}}return e.closed&&t.push(`Z`),t.join(` `)}function NS(e){return Number.isInteger(e)?String(e):e.toFixed(3).replace(/\.?0+$/,``)}function PS(e={}){let t=e.stroke??`#1e293b`,n=e.strokeWidth??2,r=e.sampleDistance??4,i=null;function a(e){let t=e.currentTarget.getBoundingClientRect();return{sx:e.clientX-t.left,sy:e.clientY-t.top}}return{id:e.id??`path`,label:e.label??`Pen`,cursor:`crosshair`,shortcut:e.shortcut??`p`,onPointerDown(e,t){if(e.button!==0)return;let{sx:n,sy:r}=a(e);i=[t.screenToViewport(n,r)],e.currentTarget.setPointerCapture?.(e.pointerId)},onPointerMove(e,t){if(!i)return;let{sx:n,sy:o}=a(e),s=t.screenToViewport(n,o),c=i[i.length-1];Math.hypot(s.x-c.x,s.y-c.y)>=r&&i.push(s)},onPointerUp(e,r){if(!i)return;let a=i;if(i=null,e.currentTarget.releasePointerCapture?.(e.pointerId),a.length<2)return;let o=MS(IS(a)),s=LS(a),c={id:`path-${Date.now().toString(36)}-${Math.floor(Math.random()*1e6).toString(36)}`,type:`path`,position:{x:s.x,y:s.y,width:s.width,height:s.height},content:{d:o,stroke:t,strokeWidth:n,fill:`none`}};r.dispatch({kind:`addLayer`,layer:c}),r.setActiveTool?.(`select`)},renderOverlay(){return!i||i.length<2?null:(0,G.createElement)(`path`,{key:`path-preview`,d:FS(i),className:`squisq-scene-connect-preview`,fill:`none`})}}}function FS(e){if(e.length===0)return``;let t=[`M ${e[0].x} ${e[0].y}`];for(let n=1;n<e.length;n++)t.push(`L ${e[n].x} ${e[n].y}`);return t.join(` `)}function IS(e){if(e.length===0)return{points:[],closed:!1};if(e.length===1)return{points:[{kind:`move`,x:e[0].x,y:e[0].y}],closed:!1};let t=[{kind:`move`,x:e[0].x,y:e[0].y}];for(let n=0;n<e.length-1;n++){let r=e[n-1]??e[n],i=e[n],a=e[n+1],o=e[n+2]??a,s={x:i.x+(a.x-r.x)/6,y:i.y+(a.y-r.y)/6},c={x:a.x-(o.x-i.x)/6,y:a.y-(o.y-i.y)/6},l=t[t.length-1];l&&(l.cpOut=s),t.push({kind:`curve`,x:a.x,y:a.y,cpIn:c})}return{points:t,closed:!1}}function LS(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e)a.x<t&&(t=a.x),a.y<n&&(n=a.y),a.x>r&&(r=a.x),a.y>i&&(i=a.y);return{x:t,y:n,width:r-t,height:i-n}}function RS(e={}){let t=e.fontSize??24,n=e.color??`#1e293b`,r=e.textAlign??`left`,i=e.prompt??(()=>window.prompt(`Text:`));return{id:e.id??`text`,label:e.label??`Text`,cursor:`text`,shortcut:e.shortcut??`t`,onPointerDown(e,a){if(e.button!==0)return;let o=e.currentTarget.getBoundingClientRect(),s=e.clientX-o.left,c=e.clientY-o.top,l=a.screenToViewport(s,c),u=i();if(u==null||u.length===0){a.setActiveTool?.(`select`);return}let d={id:`text-${Date.now().toString(36)}-${Math.floor(Math.random()*1e6).toString(36)}`,type:`text`,position:{x:l.x,y:l.y,width:Math.max(t*u.length*.6,80),height:t*1.4},content:{text:u,style:{fontSize:t,color:n,textAlign:r}}};a.dispatch({kind:`addLayer`,layer:d}),a.setActiveTool?.(`select`)}}}var zS=`dshape-`,BS=`dlabel-`,VS=`#1e293b`,HS=`none`;function US(e){let{id:t,x:n,y:r,width:i,height:a}=e,o=e.stroke??VS,s=e.fill??HS,c=e.strokeWidth??2;if(e.kind===`text`)return[{id:`${zS}${t}`,type:`text`,position:{x:n,y:r,width:i,height:a},content:{text:e.text??e.label??``,style:{fontSize:YS(a),color:o,textAlign:`center`}}}];let l;l=e.kind===`rect`||e.kind===`circle`?{id:`${zS}${t}`,type:`shape`,position:{x:n,y:r,width:i,height:a},content:{shape:e.kind,fill:s,stroke:o,strokeWidth:c,...e.kind===`rect`&&e.borderRadius!=null?{borderRadius:e.borderRadius}:{}}}:e.kind===`path`?{id:`${zS}${t}`,type:`path`,position:{x:n,y:r,width:i,height:a},content:{d:e.d??`M ${n} ${r} L ${n+i} ${r+a}`,stroke:o,strokeWidth:c,fill:s,...e.dasharray?{dasharray:e.dasharray}:{}}}:e.kind===`line`?{id:`${zS}${t}`,type:`shape`,position:{x:n,y:r,width:i,height:a},content:{shape:`line`,stroke:o,strokeWidth:c}}:e.kind===`arrow`?{id:`${zS}${t}`,type:`path`,position:{x:n,y:r,width:i,height:a},content:{d:`M ${n} ${r} L ${n+i} ${r+a}`,stroke:o,strokeWidth:c,fill:`none`,endMarker:`arrow`}}:{id:`${zS}${t}`,type:`path`,position:{x:n,y:r,width:i,height:a},content:{d:F(e.kind,n,r,i,a)??`M ${n} ${r} L ${n+i} ${r+a}`,stroke:o,strokeWidth:c,fill:s,...e.dasharray?{dasharray:e.dasharray}:{}}};let u=[l];return e.label&&u.push({id:`${BS}${t}`,type:`text`,position:{x:n+i/2,y:r+a/2,width:i,anchor:`center`},content:{text:e.label,style:{fontSize:YS(a),fontWeight:`bold`,color:o,textAlign:`center`}}}),u}function WS(e){let t=[],n=[];for(let r of e){let[e,i]=US(r);t.push(e),i&&n.push(i)}return[...t,...n]}function GS(e){return e.map(e=>({id:e.id,x:e.x,y:e.y,width:e.width,height:e.height}))}function KS(e){return e.startsWith(BS)?`${zS}${e.slice(BS.length)}`:null}function qS(e){return e.startsWith(zS)?e.slice(zS.length):e.startsWith(BS)?e.slice(BS.length):null}function JS(e){return e.startsWith(zS)}function YS(e){return Math.max(12,Math.min(48,Math.round(e*.34)))}var XS=180,ZS=64;function QS(e){let t=e.width??XS,n=e.height??ZS,r=e.kind===`container`,i={id:`node-card-${e.id}`,type:`shape`,position:{x:e.x,y:e.y,width:t,height:n},content:{shape:`rect`,fill:e.fill??(r?`#94a3b8`:`#ffffff`),...r?{fillOpacity:.12}:{},stroke:e.stroke??(r?`#94a3b8`:`#1e293b`),strokeWidth:2,borderRadius:e.shape===`pill`?n/2:10}},a=r?e.label.split(`
|
|
401
|
+
`)[0]??``:e.label,o=Math.max(12,Math.min(48,Math.round(n*.34))),s=r?{fontSize:16,firstLineOffset:0,textWidth:t}:re(a,t,n,o),{fontSize:c}=s;return[i,{id:`node-label-${e.id}`,type:`text`,position:{x:e.x+t/2,y:r?e.y+c+8:e.y+n/2+s.firstLineOffset,width:s.textWidth,anchor:`center`},content:{text:a,style:{fontSize:c,...r?{}:{lineHeight:Le},fontWeight:`bold`,color:e.stroke??(r?`#64748b`:`#1e293b`),textAlign:`center`}}}]}function $S(e){return e.startsWith(`node-label-`)?`node-card-${e.slice(11)}`:e}function eC(e){return e.startsWith(`node-label-`)?$S(e):null}function tC(e){let t=[],n=[];for(let r of e){let[e,i]=QS(r);t.push(e),n.push(i)}return[...t,...n]}function nC(e){return e.startsWith(`node-card-`)?e.slice(10):e.startsWith(`node-label-`)?e.slice(11):null}function rC(e){let t=new Map;for(let n of e){let e=n.width??XS,r=n.height??ZS;t.set(n.id,{cx:n.x+e/2,cy:n.y+r/2,rx:e/2,ry:r/2})}return t}function iC(e,t){return rC(e).get(t)??null}function aC(e,t,n){let r=iC(e,t);return r?c(r,n):null}function oC(e,t,n,r,i){let a=rC(e),o=a.get(t),s=a.get(n);if(!o||!s)return null;let c=v(o,s);return{start:r?b(o,r):c.start,end:i?b(s,i):c.end}}function sC(e,t){return`M ${e.x} ${e.y} L ${t.x} ${t.y}`}function cC(e,t){let n=Math.abs(t.x-e.x),r=Math.max(40,n/2);return`M ${e.x} ${e.y} C ${e.x+r} ${e.y}, ${t.x-r} ${t.y}, ${t.x} ${t.y}`}function lC(e={}){let t=null;function n(e){let t=e.currentTarget.getBoundingClientRect();return{sx:e.clientX-t.left,sy:e.clientY-t.top}}function r(e,t){let n=e.hitItems.find(e=>e.id===`dshape-${t}`);return n?{id:t,x:n.bounds.x,y:n.bounds.y,width:n.bounds.width,height:n.bounds.height}:null}function i(e,t){let n=e.hit(t);return!n||!JS(n)?null:qS(n)}function a(e,t,n){return n?oC([e,n],e.id,n.id)??{start:t,end:t}:{start:aC([e],e.id,t)??t,end:t}}function o(e,t,n,r){if(r){let i=t===`from`?r:e,a=t===`from`?e:r;return oC([i,a],i.id,a.id)??{start:n,end:n}}let i=aC([e],e.id,n)??n;return t===`from`?{start:n,end:i}:{start:i,end:n}}return{id:`connect`,label:`Connect`,cursor:`crosshair`,shortcut:`c`,onPointerDown(s,c){if(s.button!==0)return;let{sx:l,sy:u}=n(s),d=c.screenToViewport(l,u),f=e.endpointAt?.(d);if(f){let e=r(c,f.fixedShapeId);if(!e)return;let n=o(e,f.end,d,null);t={mode:`retarget`,connectorId:f.connectorId,end:f.end,fixedShapeId:f.fixedShapeId,fixedBox:e,start:n.start,endPoint:n.end,hovered:null},s.currentTarget.setPointerCapture?.(s.pointerId),s.stopPropagation();return}let p=i(c,d);if(!p)return;let m=r(c,p);if(!m)return;let h=a(m,d,null);t={mode:`new`,sourceId:p,sourceBox:m,start:h.start,end:h.end,hovered:null},s.currentTarget.setPointerCapture?.(s.pointerId),s.stopPropagation()},onPointerMove(e,s){if(!t)return;let{sx:c,sy:l}=n(e),u=s.screenToViewport(c,l),d=i(s,u),f=t.mode===`new`?t.sourceId:t.fixedShapeId,p=d&&d!==f?d:null,m=p?r(s,p):null;if(t.mode===`new`){let e=a(t.sourceBox,u,m);t.start=e.start,t.end=e.end}else{let e=o(t.fixedBox,t.end,u,m);t.start=e.start,t.endPoint=e.end}t.hovered=m?.id??null},onPointerUp(n,r){if(!t)return;let i=t;t=null,n.currentTarget.releasePointerCapture?.(n.pointerId),i.hovered&&(i.mode===`new`?r.dispatch({kind:`addEdge`,source:i.sourceId,target:i.hovered}):e.onRetarget?.(i.connectorId,i.end,i.hovered))},renderOverlay(){if(!t)return null;let e=t.start,n=t.mode===`new`?t.end:t.endPoint;return(0,G.createElement)(`g`,{key:`drawing-connect-preview`},(0,G.createElement)(`path`,{d:sC(e,n),className:`squisq-scene-connect-preview`,fill:`none`}),(0,G.createElement)(`circle`,{cx:n.x,cy:n.y,r:4,className:`squisq-scene-connect-preview`}))}}}function uC(e){let t=null;function n(e){let t=e.currentTarget.getBoundingClientRect();return{sx:e.clientX-t.left,sy:e.clientY-t.top}}function r(){let e=t.start,n=t.current;return{x:Math.min(e.x,n.x),y:Math.min(e.y,n.y),width:Math.abs(n.x-e.x),height:Math.abs(n.y-e.y)}}return{id:`draw`,label:`Shape`,cursor:`crosshair`,onPointerDown(r,i){if(r.button!==0||!e.getKind())return;let{sx:a,sy:o}=n(r),s=i.screenToViewport(a,o);t={start:s,current:s},r.currentTarget.setPointerCapture?.(r.pointerId)},onPointerMove(e,r){if(!t)return;let{sx:i,sy:a}=n(e);t.current=r.screenToViewport(i,a)},onPointerUp(n,i){if(!t)return;let a=r(),o=e.getKind();t=null,n.currentTarget.releasePointerCapture?.(n.pointerId),o&&a.width>=4&&a.height>=4&&e.onDraw(o,a),i.setActiveTool?.(`select`)},renderOverlay(){if(!t)return null;let n=r(),i=e.getKind();return(0,G.createElement)(`path`,{key:`draw-preview`,d:(i?F(i,n.x,n.y,n.width,n.height):null)??`M ${n.x} ${n.y} h ${n.width} v ${n.height} h ${-n.width} Z`,className:`squisq-scene-connect-preview`,fill:`none`})}}}var dC=[`arrow`,`open`,`diamond`,`circle`,`square`];function fC(e,t,n){return`${e}-squisq-edge-${t}-${n}`}function pC({nodes:e,edges:t,variant:n=`curved`,selectedId:r,onEdgeClick:i}){let a=rC(e),o=(0,G.useId)().replace(/:/g,``),s=n===`straight`?`straight`:`curved`;return(0,K.jsxs)(`g`,{className:`squisq-scene-edges`,children:[(0,K.jsx)(`defs`,{children:[`start`,`end`].flatMap(e=>dC.map(t=>{let n=Re(t,e);return n?(0,K.jsx)(`marker`,{id:fC(o,t,e),viewBox:`0 0 10 10`,refX:e===`end`?9:1,refY:5,markerWidth:8,markerHeight:8,orient:`auto-start-reverse`,markerUnits:`userSpaceOnUse`,children:(0,K.jsx)(`path`,{d:n.d,className:n.filled?`squisq-scene-edge-arrow`:`squisq-scene-edge-marker-open`})},fC(o,t,e)):null}))}),t.map(t=>{let n=a.get(t.source),c=a.get(t.target);if(!n||!c)return null;let l=oC(e,t.source,t.target,t.sourceAnchor,t.targetAnchor);if(!l)return null;let{start:u,end:d}=l,f=A(t.routing??s,u,d),p=t.startMarker??`none`,m=t.endMarker??`arrow`,h=r===t.id;return(0,K.jsxs)(`g`,{className:h?`squisq-scene-edge selected`:`squisq-scene-edge`,onClick:i?()=>i(t):void 0,children:[(0,K.jsx)(`path`,{d:f,className:`squisq-scene-edge-path`,strokeDasharray:t.dasharray,markerStart:p===`none`?void 0:`url(#${fC(o,p,`start`)})`,markerEnd:m===`none`?void 0:`url(#${fC(o,m,`end`)})`}),t.label?(0,K.jsx)(`text`,{x:(n.cx+c.cx)/2,y:(n.cy+c.cy)/2,className:`squisq-scene-edge-label`,textAnchor:`middle`,dominantBaseline:`middle`,children:t.label}):null,h?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`circle`,{cx:u.x,cy:u.y,r:6,className:`squisq-scene-edge-handle`}),(0,K.jsx)(`circle`,{cx:d.x,cy:d.y,r:6,className:`squisq-scene-edge-handle`})]}):null]},t.id)})]})}function mC(e,t){return iS(e,t).map(e=>{let t=e.node.attrs;return{pos:e.pos,node:e.node,id:e.id,kind:t.dataTemplate??null,params:t.dataTemplateParams?Et(t.dataTemplateParams).params??{}:{},text:jC(e.node)}})}function hC(e,t,n,r,i,a=``){let o=e.state.doc.nodeAt(t);if(!o||o.type.name!==`heading`)return!1;let s=DC(e,t,o),c=aS(e,t),l=OC(i),u=kC(n);return e.chain().command(({tr:e,state:t})=>{let n=t.schema.nodes.heading;if(!n)return!1;let i=a.length>0?t.schema.text(a):null,o=n.create({level:s,dataTemplate:r,dataTemplateParams:l.length>0?l:null,dataBlockAttrs:u},i);return e.insert(c,o),!0}).run()}function gC(e,t,n,r,i){return TC(e,t,n,e=>{e.x=String(Math.round(r)),e.y=String(Math.round(i))})}function _C(e,t,n,r,i){return TC(e,t,n,e=>{e.width=String(Math.round(r)),e.height=String(Math.round(i))})}function vC(e,t,n,r,i){return TC(e,t,n,e=>{i.length===0?delete e[r]:e[r]=i})}function yC(e,t,n,r){return TC(e,t,n,e=>{for(let[t,n]of Object.entries(r))n==null||n.length===0?delete e[t]:e[t]=n})}function bC(e,t,n,r,i,a=`arrow`,o=``){return hC(e,t,n,a,{from:r,to:i},o)}function xC(e,t,n,r,i){return TC(e,t,n,e=>{e[r]=i})}function SC(e,t,n,r){let i=mC(e,t).find(e=>wC(e)&&e.params.from===n&&e.params.to===r);if(!i)return!1;let[a,o]=EC(e,i.pos);return e.chain().command(({tr:e})=>(e.delete(a,o),!0)).run()}function CC(e,t,n){let r=mC(e,t),i=r.find(e=>e.id===n);if(!i)return!1;let a=[EC(e,i.pos)];for(let t of r)t.id!==n&&wC(t)&&(t.params.from===n||t.params.to===n)&&a.push(EC(e,t.pos));return a.sort((e,t)=>t[0]-e[0]),e.chain().command(({tr:e})=>{for(let[t,n]of a)e.delete(t,n);return!0}).run()}function wC(e){return e.kind!==`line`&&e.kind!==`arrow`?!1:e.params.from!=null||e.params.to!=null}function TC(e,t,n,r){let i=mC(e,t).find(e=>e.id===n);if(!i)return!1;let a={...i.params};r(a);let o=OC(a);return e.chain().command(({tr:e})=>e.doc.nodeAt(i.pos)?(e.setNodeAttribute(i.pos,`dataTemplateParams`,o.length>0?o:null),!0):!1).run()}function EC(e,t){let{state:n}=e,r=n.doc.nodeAt(t);if(!r)return[t,t];let i=t+r.nodeSize,a=n.doc.content.size;for(;i<a;){let e=n.doc.nodeAt(i);if(!e||e.type.name===`heading`)break;i+=e.nodeSize}return[t,i]}function DC(e,t,n){let r=n.attrs.level,i=mC(e,t)[0]?.node.attrs.level;return Math.min(6,i??r+1)}function OC(e){return Object.entries(e).map(([e,t])=>`${e}=${gt(t)}`).join(` `)}function kC(e){return AC(Ct({id:e}))}function AC(e){return e==null||e===`{}`?null:e.startsWith(`{`)&&e.endsWith(`}`)?e.slice(1,-1):e}function jC(e){let t=``;return e.content.forEach(e=>{e.isText&&(t+=e.text??``)}),t}var MC=18;function NC(e,t,n={}){let[,r]=(0,G.useState)(0);(0,G.useEffect)(()=>{let t=()=>r(e=>e+1);return e.on(`transaction`,t),()=>{e.off(`transaction`,t)}},[e]);let i=we((e.state.doc.nodeAt(t)?mC(e,t):[]).map(e=>({id:e.id,startTime:0,duration:0,audioSegment:0,...e.kind?{template:e.kind}:{},...Object.keys(e.params).length>0?{templateOverrides:e.params}:{},...e.text?{title:e.text}:{}}))),a=WS(i.shapes),o=GS(i.shapes),s=i.connectors.map(e=>({id:e.id,source:e.from,target:e.to,...e.label?{label:e.label}:{},startMarker:e.startMarker,endMarker:e.endMarker,...e.dasharray?{dasharray:e.dasharray}:{},routing:e.routing})),[c,l]=(0,G.useState)(null),u=(0,G.useRef)(`rectangle`),d=(0,G.useCallback)(e=>{u.current=e},[]),f=(0,G.useRef)({edges:s,boxes:o,selectedEdgeId:c,headingPos:t});f.current={edges:s,boxes:o,selectedEdgeId:c,headingPos:t},(0,G.useEffect)(()=>{c&&!s.some(e=>e.id===c)&&l(null)},[s,c]),(0,G.useEffect)(()=>{let t=t=>{if(t.key!==`Delete`&&t.key!==`Backspace`||VC(t.target))return;let{edges:n,selectedEdgeId:r,headingPos:i}=f.current;if(!r)return;let a=n.find(e=>e.id===r);a&&(t.preventDefault(),SC(e,i,a.source,a.target),l(null))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]);let p=(0,G.useCallback)(e=>{let{edges:t,boxes:n,selectedEdgeId:r}=f.current;if(!r)return null;let i=t.find(e=>e.id===r);if(!i)return null;let a=oC(n,i.source,i.target);return a?BC(a.start,e)?{connectorId:i.id,end:`from`,fixedShapeId:i.target}:BC(a.end,e)?{connectorId:i.id,end:`to`,fixedShapeId:i.source}:null:null},[]),m=(0,G.useCallback)((t,n,r)=>{xC(e,f.current.headingPos,t,n,r)},[e]),h=(0,G.useCallback)((t,n)=>{let r=f.current.headingPos;hC(e,r,RC(e,r,t),t,{x:String(Math.round(n.x)),y:String(Math.round(n.y)),width:String(Math.round(n.width)),height:String(Math.round(n.height))})},[e]);return{layers:a,edges:s,tools:(0,G.useMemo)(()=>[Nx,uC({getKind:()=>u.current,onDraw:h}),PS({stroke:n.stroke}),RS({color:n.stroke}),lC({endpointAt:p,onRetarget:m})],[n.stroke,p,m,h]),dispatch:n=>{switch(n.kind){case`moveLayer`:{if(!JS(n.id))return;let r=qS(n.id);r&&gC(e,t,r,n.x,n.y);return}case`resizeLayer`:{if(!JS(n.id))return;let r=qS(n.id);r&&(n.x!==void 0&&n.y!==void 0&&gC(e,t,r,n.x,n.y),_C(e,t,r,n.width,n.height));return}case`addLayer`:{let r=PC(n.layer);hC(e,t,RC(e,t,r.kind),r.kind,r.params,r.label);return}case`removeLayer`:{let r=qS(n.id);r&&CC(e,t,r);return}case`renameLayer`:{let r=qS(n.id);r&&oS(e,t,r,n.label);return}case`setLayerText`:{let r=qS(n.id);r&&oS(e,t,r,n.text);return}case`setLayerAttr`:{let r=qS(n.id);if(!r)return;let i=IC(n.path);i===`__text__`?oS(e,t,r,String(n.value??``)):i&&vC(e,t,r,i,String(n.value??``));return}case`addEdge`:bC(e,t,zC(e,t),n.source,n.target);return;case`removeEdge`:SC(e,t,n.source,n.target);return}},layerFollows:KS,renderExtras:(0,G.useCallback)(e=>{let{edges:t,boxes:n,selectedEdgeId:r}=f.current;return(0,G.createElement)(pC,{nodes:n,edges:t,variant:`straight`,selectedId:r,onEdgeClick:e=>l(e.id)})},[]),setPendingKind:d,selectedEdgeId:c,selectedEdge:s.find(e=>e.id===c)??null,setConnectorStyle:(n,r)=>{yC(e,t,n,r)},setShapeParam:(n,r,i)=>{vC(e,t,n,r,i)}}}function PC(e){let t=FC(e.position);if(e.type===`shape`){let n=e.content,r=n.shape===`rect`?`rectangle`:n.shape;return n.fill&&(t.fill=n.fill),n.stroke&&(t.stroke=n.stroke),n.strokeWidth!=null&&(t.strokeWidth=String(n.strokeWidth)),n.borderRadius!=null&&(t.borderRadius=String(n.borderRadius)),{kind:r,params:t,label:``}}if(e.type===`path`){let n=e.content;return t.d=n.d,n.stroke&&(t.stroke=n.stroke),n.strokeWidth!=null&&(t.strokeWidth=String(n.strokeWidth)),n.fill&&(t.fill=n.fill),{kind:`path`,params:t,label:``}}return e.type===`text`?{kind:`text`,params:t,label:e.content.text}:{kind:`rectangle`,params:t,label:``}}function FC(e){let t={};return typeof e.x==`number`&&(t.x=String(Math.round(e.x))),typeof e.y==`number`&&(t.y=String(Math.round(e.y))),typeof e.width==`number`&&(t.width=String(Math.round(e.width))),typeof e.height==`number`&&(t.height=String(Math.round(e.height))),t}function IC(e){switch(e){case`content.fill`:return`fill`;case`content.stroke`:case`content.style.color`:return`stroke`;case`content.strokeWidth`:return`strokeWidth`;case`content.borderRadius`:return`borderRadius`;case`content.dasharray`:return`dasharray`;case`content.d`:return`d`;case`content.text`:return`__text__`;default:return null}}var LC={rectangle:`rect`,rect:`rect`,circle:`circle`,line:`line`,arrow:`arrow`,path:`path`,text:`text`};function RC(e,t,n){let r=new Set(mC(e,t).map(e=>e.id)),i=LC[n]??(n.replace(/[^a-z0-9]/gi,``).toLowerCase()||`shape`),a=1,o=`${i}-${a}`;for(;r.has(o);)o=`${i}-${++a}`;return o}function zC(e,t){let n=new Set(mC(e,t).map(e=>e.id)),r=1,i=`edge-${r}`;for(;n.has(i);)i=`edge-${++r}`;return i}function BC(e,t){return Math.hypot(e.x-t.x,e.y-t.y)<=MC}function VC(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t===`INPUT`||t===`TEXTAREA`||e.isContentEditable}function HC({colors:e=[],selects:t=[]}){return e.length===0&&t.length===0?null:(0,K.jsxs)(`div`,{className:`squisq-scene-block-props`,role:`group`,"aria-label":`Selection style`,children:[e.map(e=>(0,K.jsxs)(`span`,{className:`squisq-scene-prop`,children:[(0,K.jsx)(`span`,{className:`squisq-scene-prop-label`,children:e.label}),(0,K.jsx)(`input`,{type:`color`,className:`squisq-scene-prop-color`,"aria-label":`${e.label} color`,value:UC(e.value),onChange:t=>e.onChange(t.target.value)}),e.allowNone&&(0,K.jsx)(`button`,{type:`button`,className:`squisq-scene-prop-clear`,onClick:()=>e.onChange(`none`),children:`none`})]},e.label)),t.map(e=>(0,K.jsxs)(`label`,{className:`squisq-scene-prop`,children:[(0,K.jsx)(`span`,{className:`squisq-scene-prop-label`,children:e.label}),(0,K.jsx)(`select`,{className:`squisq-scene-prop-select`,value:e.value,onChange:t=>e.onChange(t.target.value),children:e.options.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))})]},e.label))]})}function UC(e){return e&&/^#[0-9a-fA-F]{6}$/.test(e)?e:`#000000`}var WC=[{value:`left`,icon:`fa-solid fa-align-left`,label:`Align left`},{value:`center`,icon:`fa-solid fa-align-center`,label:`Align center`},{value:`right`,icon:`fa-solid fa-align-right`,label:`Align right`}];function GC({pos:e}){let t=e===`top`?3.5:e===`middle`?7.5:11.5;return(0,K.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,children:[(0,K.jsx)(`rect`,{x:`2.5`,y:`1.5`,width:`11`,height:`13`,rx:`1`,stroke:`currentColor`,strokeWidth:`1.3`}),(0,K.jsx)(`line`,{x1:`5`,y1:t,x2:`11`,y2:t,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`})]})}var KC=[{value:`top`,label:`Align top`},{value:`middle`,label:`Align middle`},{value:`bottom`,label:`Align bottom`}];function qC({tools:e=[],activeToolId:t,onSelectTool:n,actions:r=[],alignment:i,properties:a,toolPopover:o,leading:s}){let c=e.length>1;return!c&&r.length===0&&!s&&!i&&!a?null:(0,K.jsxs)(`div`,{className:`squisq-scene-block-toolbar`,role:`toolbar`,"aria-label":`Canvas tools`,children:[s,i&&(0,K.jsxs)(`div`,{className:`squisq-scene-block-tools`,"aria-label":`Text alignment`,children:[WC.map(e=>(0,K.jsx)(`button`,{type:`button`,className:`squisq-scene-tool${i.textAlign===e.value?` squisq-scene-tool--active`:``}`,onClick:()=>i.onTextAlign(e.value),title:e.label,"aria-label":e.label,"aria-pressed":i.textAlign===e.value,children:(0,K.jsx)(q,{icon:e.icon})},e.value)),KC.map(e=>(0,K.jsx)(`button`,{type:`button`,className:`squisq-scene-tool${i.verticalAlign===e.value?` squisq-scene-tool--active`:``}`,onClick:()=>i.onVerticalAlign(e.value),title:e.label,"aria-label":e.label,"aria-pressed":i.verticalAlign===e.value,children:(0,K.jsx)(GC,{pos:e.value})},e.value))]}),c&&(0,K.jsx)(`div`,{className:`squisq-scene-block-tools`,children:e.map(e=>{let r=(0,K.jsx)(`button`,{type:`button`,className:`squisq-scene-tool${t===e.id?` squisq-scene-tool--active`:``}`,onClick:()=>n?.(e.id),title:e.shortcut?`${e.label} (${e.shortcut.toUpperCase()})`:e.label,"aria-pressed":t===e.id,children:e.icon??(0,K.jsx)(`span`,{className:`squisq-scene-tool-label`,children:e.label})},e.id);return o&&o.toolId===e.id?(0,K.jsxs)(`span`,{className:`squisq-scene-tool-popover-anchor`,children:[r,o.content]},e.id):r})}),a,r.length>0&&(0,K.jsx)(`div`,{className:`squisq-scene-block-actions`,children:r.map(e=>{let t=(0,K.jsxs)(`button`,{type:`button`,className:`squisq-scene-action${e.active?` squisq-scene-action--active`:``}${e.danger?` squisq-scene-action--danger`:``}`,onClick:e.onClick,disabled:e.disabled,title:e.title??e.label,"aria-label":e.title??e.label,"aria-pressed":e.active||void 0,children:[e.icon&&(0,K.jsx)(`span`,{className:`squisq-scene-action-icon`,children:e.icon}),(0,K.jsx)(`span`,{className:`squisq-scene-action-label`,children:e.label})]},e.id);return e.popover?(0,K.jsxs)(`span`,{className:`squisq-scene-action-popover-anchor`,children:[t,e.popover]},e.id):t})})]})}var JC=196;function YC({children:e}){let t=(0,G.useRef)(null),[n,r]=(0,G.useState)(!1);return(0,G.useLayoutEffect)(()=>{let e=t.current;if(!e)return;let n=e.closest(`.squisq-scene-shell`),i=e.closest(`.squisq-editor-content`),a=e.closest(`.squisq-editor-with-gutter`),o=()=>{if(!n)return;let t=n.getBoundingClientRect().right,o=i?i.getBoundingClientRect().right:document.documentElement.clientWidth;if(a){let t=Array.from(a.children).find(t=>t.contains(e));t&&t.nextElementSibling&&(o=Math.min(o,t.getBoundingClientRect().right))}r(o-t<JC)};o();let s=new ResizeObserver(o),c=new Set;i&&c.add(i),a&&c.add(a),n&&c.add(n),c.forEach(e=>s.observe(e));let l=a?new MutationObserver(o):null;return l&&a&&l.observe(a,{childList:!0}),window.addEventListener(`resize`,o),()=>{s.disconnect(),l?.disconnect(),window.removeEventListener(`resize`,o)}},[]),(0,K.jsx)(`div`,{ref:t,className:n?`squisq-scene-inline-toolbar`:`squisq-scene-side-toolbar`,children:e})}function XC({host:e,onClose:t,children:n}){(0,G.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),t())};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[t]);let r=e??(typeof document<`u`?document.body:null);return r?(0,Wr.createPortal)((0,K.jsx)(`div`,{className:`squisq-diagram-maximized-overlay`,children:(0,K.jsx)(`div`,{className:`squisq-diagram-maximized-content`,children:n})}),r):null}var ZC={width:1920,height:1080},QC=[`none`,`arrow`,`open`,`diamond`,`circle`,`square`],$C=[`straight`,`orthogonal`,`curved`],ew=[`solid`,`dashed`,`dotted`],tw=e=>e===`8 6`?`dashed`:e===`2 6`?`dotted`:`solid`;function nw({editor:e,headingKey:t,fallbackParentPos:n,mode:r,host:i,textChannel:a}){let[o,s]=(0,G.useState)(()=>aw(e,t,r)??n);(0,G.useEffect)(()=>{let n=()=>{let n=aw(e,t,r);n!=null&&n!==o&&s(n)};return e.on(`transaction`,n),()=>{e.off(`transaction`,n)}},[e,t,r,o]);let c=TS(e,o),l=NC(e,o),u=r===`drawing`,d=u?l:c,f=(0,G.useRef)(d.layers);f.current=d.layers;let p=(0,G.useRef)(d.dispatch);p.current=d.dispatch;let m=(0,G.useMemo)(()=>({channel:a,resolveEditableId:e=>{let t=f.current.find(t=>t.id===e);return t&&t.type===`text`?e:null},getHtml:e=>{let t=f.current.find(t=>t.id===e);return!t||t.type!==`text`?``:!u&&t.content.html?.trim()?t.content.html:lr(t.content.text??``)},commit:(e,{html:t,text:n})=>{u?p.current({kind:`renameLayer`,id:e,label:n}):p.current({kind:`setLayerText`,id:e,text:n,html:t})},level:u?`inline`:`block`}),[u,a]),[h,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(`select`),[y,b]=(0,G.useState)(!1),[x,S]=(0,G.useState)(null),C=u&&x?qS(x):null,w=(0,K.jsx)(Hx,{viewport:ZC,layers:d.layers,edges:d.edges,tools:d.tools,onCommand:d.dispatch,onSelectionChange:e=>S(e.values().next().value??null),activeToolId:_,onActiveToolIdChange:v,layerFollows:d.layerFollows,renderExtras:d.renderExtras,showMaximize:!0,maximized:h,onToggleMaximize:()=>g(e=>!e),showToolbar:!1,textEditing:m}),T=u?!!x||!!l.selectedEdgeId:!!x,E=()=>{if(x){d.dispatch({kind:`removeLayer`,id:x}),S(null);return}u&&l.selectedEdge&&d.dispatch({kind:`removeEdge`,source:l.selectedEdge.source,target:l.selectedEdge.target})},D=e=>{let t=new Set(d.layers.map(e=>e.id)),n=1;for(;t.has(`${e}-${n}`);)n++;return`${e}-${n}`},O=e=>d.dispatch({kind:`addLayer`,layer:e}),k={id:`delete`,label:`Delete`,icon:(0,K.jsx)(q,{icon:`fa-solid fa-trash`}),title:`Delete selected`,danger:!0,disabled:!T,onClick:E},A=u?[k]:[{id:`add-text`,label:`Text`,icon:(0,K.jsx)(q,{icon:`fa-solid fa-font`}),title:`Add text`,onClick:()=>O({type:`text`,id:D(`text`),content:{text:`Text`,style:{fontSize:48,color:`#1e293b`,textAlign:`center`,verticalAlign:`middle`}},position:{x:660,y:440,width:600,height:200}})},{id:`add-box`,label:`Box`,icon:(0,K.jsx)(q,{icon:`fa-solid fa-square`}),title:`Add box`,onClick:()=>O({type:`shape`,id:D(`box`),content:{shape:`rect`,fill:`#e0e7ff`,stroke:`#6366f1`,strokeWidth:2,borderRadius:8},position:{x:760,y:390,width:400,height:300}})},k],j=x?d.layers.find(e=>e.id===x):void 0,M=r===`layout`&&j?.type===`text`?{textAlign:j.content.style.textAlign??`left`,verticalAlign:j.content.style.verticalAlign??`top`,onTextAlign:e=>d.dispatch({kind:`setLayerAttr`,id:j.id,path:`content.style.textAlign`,value:e}),onVerticalAlign:e=>d.dispatch({kind:`setLayerAttr`,id:j.id,path:`content.style.verticalAlign`,value:e})}:void 0,N=rw({isDrawing:u,selectedLayer:j,selectedShapeId:C,selectedEdge:u?l.selectedEdge:null,setShapeParam:l.setShapeParam,setConnectorStyle:l.setConnectorStyle,dispatch:d.dispatch}),P=(0,K.jsx)(qC,{tools:d.tools,activeToolId:_,onSelectTool:e=>{v(e),e===`draw`&&b(!0)},actions:A,alignment:M,properties:N,toolPopover:u&&y?{toolId:`draw`,content:(0,K.jsx)(ra,{onPick:e=>{l.setPendingKind(e),v(`draw`),b(!1)},onClose:()=>b(!1)})}:void 0}),F=(0,K.jsx)(`div`,{className:`squisq-scene-stage`,children:w});return h?(0,K.jsx)(`div`,{className:`squisq-scene-inline-placeholder`,children:(0,K.jsx)(XC,{host:i??null,onClose:()=>g(!1),children:(0,K.jsxs)(`div`,{className:`squisq-scene-block-max`,children:[F,(0,K.jsx)(`div`,{className:`squisq-scene-side-toolbar`,children:P})]})})}):(0,K.jsxs)(`div`,{className:`squisq-scene-shell`,children:[(0,K.jsx)(YC,{children:P}),(0,K.jsx)(`div`,{className:`squisq-scene-inline`,children:F})]})}function rw(e){let{isDrawing:t,selectedLayer:n,selectedShapeId:r,selectedEdge:i,setShapeParam:a,setConnectorStyle:o,dispatch:s}=e;if(t&&i){let e=i,t=t=>o(e.id,t);return(0,K.jsx)(HC,{selects:[{label:`End`,value:e.endMarker??`arrow`,options:QC,onChange:e=>t({endStyle:e})},{label:`Start`,value:e.startMarker??`none`,options:QC,onChange:e=>t({startStyle:e})},{label:`Line`,value:tw(e.dasharray),options:ew,onChange:e=>t({lineStyle:e})},{label:`Routing`,value:e.routing??`straight`,options:$C,onChange:e=>t({routing:e})}]})}if(!n)return null;let c=(e,i)=>o=>{t&&r?a(r,e,o):s({kind:`setLayerAttr`,id:n.id,path:i,value:o})};return n.type===`text`?(0,K.jsx)(HC,{colors:[{label:`Color`,value:n.content.style.color,onChange:c(`stroke`,`content.style.color`)}]}):n.type===`shape`||n.type===`path`?(0,K.jsx)(HC,{colors:[{label:`Fill`,value:n.content.fill,allowNone:!0,onChange:c(`fill`,`content.fill`)},{label:`Stroke`,value:n.content.stroke,onChange:c(`stroke`,`content.stroke`)}]}):null}function iw(e,t){let n=e.attrs.dataBlockAttrs;if(typeof n==`string`&&n.length>0){let e=Et(n);if(e.id)return t==null?e.id:`${e.id}@${t}`}let r=``;e.content.forEach(e=>{e.isText&&(r+=e.text??``)});let i=r.toLowerCase().replace(/[^\w\s-]/g,``).replace(/[\s_]+/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``)||`block`;return t==null?i:`${i}@${t}`}function aw(e,t,n){let r=n,i=null;return e.state.doc.descendants((e,n)=>{if(i!=null)return!1;if(e.type.name===`heading`&&e.attrs.dataTemplate===r&&iw(e,n)===t)return i=n,!1}),i}var ow=new Dr(`squisq-scene-block`),sw={layout:`layout`,drawing:`drawing`};function cw(e,t,n){let r=[];return e.doc.descendants((i,a)=>{if(i.type.name!==`heading`)return;let o=i.attrs,s=o.dataTemplate?sw[o.dataTemplate]:void 0;if(!s)return;let c=o.level,l=a+i.nodeSize,u=a,d=iw(i,a);r.push(sr.widget(l,e=>{let r=document.createElement(`div`);r.className=`squisq-scene-widget-host`,r.contentEditable=`false`,r.addEventListener(`mousedown`,e=>e.stopPropagation()),r.addEventListener(`keydown`,e=>e.stopPropagation());let i=(0,Gr.createRoot)(r);return i.render((0,G.createElement)(nw,{editor:t,headingKey:d,fallbackParentPos:u,mode:s,host:e.dom.parentElement??e.dom,textChannel:n})),r.__squisqSceneRoot={el:r,root:i},r},{destroy:e=>{let t=e.__squisqSceneRoot;t&&setTimeout(()=>t.root.unmount(),0)},side:1,ignoreSelection:!0,key:`squisq-scene-${s}-${d}`}));let f=a+i.nodeSize;for(;f<e.doc.content.size;){let t=e.doc.nodeAt(f);if(!t)break;if(t.type.name===`heading`){if(t.attrs.level<=c)break;r.push(sr.node(f,f+t.nodeSize,{"data-squisq-scene-child":`true`}))}f+=t.nodeSize}}),or.create(e.doc,r)}var lw=kr.create({name:`squisqSceneBlock`,addOptions(){return{enabled:!0}},addProseMirrorPlugins(){let e=this.editor;return this.options.enabled===!1?[]:[new pr({key:ow,state:{init:(t,n)=>cw(n,e,this.options.textChannel),apply:(t,n,r,i)=>t.docChanged?cw(i,e,this.options.textChannel):n},props:{decorations(e){return this.getState(e)}}})]}});function uw(e){return e.interaction.connect??null}function dw(e,t){e.interaction.connect=t??void 0}function fw(e){let t=e.currentTarget.getBoundingClientRect();return{sx:e.clientX-t.left,sy:e.clientY-t.top}}function pw(e,t){let n=e.hitItems.find(e=>e.id===`node-card-${t}`);return n?{id:t,x:n.bounds.x,y:n.bounds.y,width:n.bounds.width,height:n.bounds.height}:null}function mw(e){let t=[];for(let n of e.hitItems){if(!n.id.startsWith(`node-card-`))continue;let e=nC(n.id);e&&t.push({id:e,x:n.bounds.x,y:n.bounds.y,width:n.bounds.width,height:n.bounds.height})}return t}function hw(e){let t=e.width??0,n=e.height??0,r=e.x,i=e.x+t,a=e.y,o=e.y+n,s=e.x+t/2,c=e.y+n/2;return[{x:s,y:a},{x:i,y:c},{x:s,y:o},{x:r,y:c},{x:r,y:a},{x:i,y:a},{x:i,y:o},{x:r,y:o}]}function gw(e,t,n){return n?oC([e,n],e.id,n.id)??{start:t,end:t}:{start:aC([e],e.id,t)??t,end:t}}var _w={id:`connect`,label:`Connect`,cursor:`crosshair`,shortcut:`c`,hideSelectionHandles:!0,onPointerDown(e,t){if(e.button!==0)return;let{sx:n,sy:r}=fw(e),i=t.screenToViewport(n,r),a=t.hit(i);if(!a)return;let o=nC(a);if(!o)return;let s=pw(t,o);if(!s)return;let c=gw(s,i,null);dw(t,{sourceNodeId:o,sourceBox:s,start:c.start,end:c.end,hoveredTargetId:null}),e.currentTarget.setPointerCapture?.(e.pointerId),e.stopPropagation()},onPointerMove(e,t){let n=uw(t);if(!n)return;let{sx:r,sy:i}=fw(e),a=t.screenToViewport(r,i),o=t.hit(a),s=o?nC(o):null,c=s&&s!==n.sourceNodeId?s:null,l=c?pw(t,c):null,u=gw(n.sourceBox,a,l);n.start=u.start,n.end=u.end,n.hoveredTargetId=l?.id??null},onPointerUp(e,t){let n=uw(t);if(!n)return;let r=n.hoveredTargetId;r&&t.dispatch({kind:`addEdge`,source:n.sourceNodeId,target:r}),e.currentTarget.releasePointerCapture?.(e.pointerId),dw(t,null)},renderOverlay(e){let t=uw(e),n=mw(e).flatMap(e=>hw(e).map((n,r)=>(0,G.createElement)(`circle`,{key:`${e.id}-${r}`,cx:n.x,cy:n.y,r:4,className:t?.hoveredTargetId===e.id?`squisq-scene-connection-point squisq-scene-connection-point--active`:`squisq-scene-connection-point`})));if(!t)return n.length?(0,G.createElement)(`g`,{key:`connection-points`},...n):null;let{start:r,end:i}=t,a=cC(r,i);return(0,G.createElement)(`g`,{key:`connect-preview`},...n,(0,G.createElement)(`path`,{d:a,className:`squisq-scene-connect-preview`}),(0,G.createElement)(`circle`,{cx:i.x,cy:i.y,r:4,className:`squisq-scene-connect-preview`}))}};function vw(e){return{id:e.id,label:e.label,cursor:e.cursor??`crosshair`,shortcut:e.shortcut,onPointerDown(t,n){if(t.button!==0)return;let r=t.currentTarget.getBoundingClientRect(),i=t.clientX-r.left,a=t.clientY-r.top,o=n.screenToViewport(i,a);n.dispatch({kind:`addLayer`,layer:e.build(o)}),n.setActiveTool?.(`select`)}}}function yw(e,t){let n=e.width??480,r=e.height??(e.kind===`image`?320:72),i=e.fontSize??36,a=e.color??`#0f172a`,o=Sw(e.kind);return e.kind===`text`?{id:o,type:`text`,position:{x:t.x,y:t.y,width:n,height:r},content:{text:e.token,style:{fontSize:i,color:a,textAlign:`left`}}}:{id:o,type:`image`,position:{x:t.x,y:t.y,width:n,height:r},content:{src:e.token,alt:`Placeholder image`,fit:`cover`}}}function bw(e){return vw({id:e.id,label:e.label,shortcut:e.shortcut,build:t=>yw(e,t)})}var xw=0;function Sw(e){return xw+=1,`${e}-token-${Date.now().toString(36)}-${xw}`}function Cw(e,t){let n=e.map(e=>({id:e.id,label:e.data.label,x:e.position.x,y:e.position.y,...e.width==null?{}:{width:e.width},...e.height==null?{}:{height:e.height},...e.kind===`container`?{kind:`container`}:{}}));return{layers:tC(n),edges:t.map(e=>({id:e.id,source:e.source,target:e.target,...e.label?{label:e.label}:{},...e.directed===!1?{endMarker:`none`}:{},...e.sourceAnchor?{sourceAnchor:e.sourceAnchor}:{},...e.targetAnchor?{targetAnchor:e.targetAnchor}:{},...e.routing?{routing:e.routing}:{}})),nodes:n}}function ww(e){let[t,n]=(0,G.useState)(()=>e.initial??[]),r=(0,G.useCallback)(e=>{n(t=>Tw(t,e))},[]);return{layers:t,tools:e.tools,dispatch:r,setLayers:n}}function Tw(e,t){switch(t.kind){case`moveLayer`:return e.map(e=>e.id===t.id?{...e,position:{...e.position,x:t.x,y:t.y}}:e);case`resizeLayer`:return e.map(e=>e.id===t.id?{...e,position:{...e.position,...t.x===void 0?{}:{x:t.x},...t.y===void 0?{}:{y:t.y},width:t.width,height:t.height}}:e);case`addLayer`:return[...e,t.layer];case`removeLayer`:return e.filter(e=>e.id!==t.id);case`setLayerAttr`:return e.map(e=>e.id===t.id?Ew(e,t.path,t.value):e);case`renameLayer`:return e.map(e=>e.id!==t.id||e.type!==`text`?e:{...e,content:{...e.content,text:t.label}});case`setLayerText`:return e.map(e=>{if(e.id!==t.id||e.type!==`text`)return e;let n={...e.content,text:t.text};return t.html&&t.html.trim()?n.html=t.html:delete n.html,{...e,content:n}});case`addEdge`:case`removeEdge`:return e.slice()}return e.slice()}function Ew(e,t,n){let r=t.split(`.`),i=JSON.parse(JSON.stringify(e)),a=i;for(let t=0;t<r.length-1;t++){let n=r[t],i=a[n];if(typeof i!=`object`||!i)return e;a=i}return a[r[r.length-1]]=n,i}function Dw(e,t){return e.map(e=>Ow(e,t))}function Ow(e,t){if(!e.position)return e;let n={...e.position};return n.x!==void 0&&(n.x=kw(n.x,t.width)),n.y!==void 0&&(n.y=kw(n.y,t.height)),n.width!==void 0&&(n.width=kw(n.width,t.width)),n.height!==void 0&&(n.height=kw(n.height,t.height)),{...e,position:n}}function kw(e,t){if(typeof e==`string`){if(e.endsWith(`%`))return e;let n=parseFloat(e);return Number.isFinite(n)&&String(n)===e?Aw(n/t*100):e}return!Number.isFinite(e)||t<=0?String(e):Aw(e/t*100)}function Aw(e){return`${(Math.round(e*100)/100).toString()}%`}var jw=`application/x-squisq-token`,Mw=[{id:`token-title`,label:`Title`,desc:`Substitutes the block's heading text.`,token:`{title}`,kind:`text`},{id:`token-content`,label:`Content`,desc:`Substitutes the block's body text.`,token:`{content}`,kind:`text`},{id:`token-children`,label:`Children`,desc:`Comma-joined list of child heading titles.`,token:`{children}`,kind:`text`},{id:`token-image`,label:`Image`,desc:`The first image found in the block's body.`,token:`{image:0}`,kind:`image`}],Nw=`application/x-squisq-shape`,Pw=[{id:`shape-rect`,label:`Rectangle`,kind:`rect`},{id:`shape-rect-rounded`,label:`Rounded`,kind:`rect`,rounded:!0},{id:`shape-circle`,label:`Ellipse`,kind:`circle`},{id:`shape-line`,label:`Line`,kind:`line`},{id:`shape-triangle`,label:`Triangle`,kind:`triangle`},{id:`shape-right-triangle`,label:`Right triangle`,kind:`right-triangle`},{id:`shape-diamond`,label:`Diamond`,kind:`diamond`},{id:`shape-pentagon`,label:`Pentagon`,kind:`pentagon`},{id:`shape-hexagon`,label:`Hexagon`,kind:`hexagon`},{id:`shape-octagon`,label:`Octagon`,kind:`octagon`},{id:`shape-star`,label:`Star`,kind:`star`},{id:`shape-star4`,label:`4-point star`,kind:`star4`},{id:`shape-star6`,label:`6-point star`,kind:`star6`},{id:`shape-parallelogram`,label:`Parallelogram`,kind:`parallelogram`},{id:`shape-trapezoid`,label:`Trapezoid`,kind:`trapezoid`},{id:`shape-plus`,label:`Plus`,kind:`plus`},{id:`shape-chevron`,label:`Chevron`,kind:`chevron`},{id:`shape-arrow-right`,label:`Arrow right`,kind:`arrow-right`},{id:`shape-arrow-left`,label:`Arrow left`,kind:`arrow-left`},{id:`shape-arrow-up`,label:`Arrow up`,kind:`arrow-up`},{id:`shape-arrow-down`,label:`Arrow down`,kind:`arrow-down`},{id:`shape-double-arrow`,label:`Double arrow`,kind:`double-arrow`},{id:`shape-callout`,label:`Callout`,kind:`callout`},{id:`shape-cylinder`,label:`Cylinder`,kind:`cylinder`},{id:`shape-cloud`,label:`Cloud`,kind:`cloud`},{id:`shape-heart`,label:`Heart`,kind:`heart`},{id:`shape-lightning`,label:`Lightning`,kind:`lightning`}],Fw=new Set([`rect`,`circle`,`line`]),Iw=`#e2e8f0`,Lw=`#475569`,Rw=2,zw=20;function Bw(e){return e===`line`?{width:280,height:120}:{width:220,height:180}}var Vw=0;function Hw(){return Vw+=1,`shape-${Date.now().toString(36)}-${Vw}`}function Uw(e,t){let{width:n,height:r}=Bw(e.kind),i={x:t.x,y:t.y,width:n,height:r},a=Hw();return Fw.has(e.kind)?{id:a,type:`shape`,position:i,content:{shape:e.kind,fill:e.kind===`line`?`none`:Iw,stroke:Lw,strokeWidth:Rw,...e.kind===`rect`?{borderRadius:e.rounded?zw:0}:{}}}:{id:a,type:`path`,position:i,content:{d:F(e.kind,t.x,t.y,n,r)??``,shapeKind:e.kind,fill:Iw,stroke:Lw,strokeWidth:Rw}}}var Ww=30,Gw=24,Kw=3;function qw({kind:e,rounded:t}){let n=Kw,r=Kw,i=Ww-Kw*2,a=Gw-Kw*2,o={fill:`#e2e8f0`,stroke:`#475569`,strokeWidth:1.5},s;return s=e===`rect`?(0,K.jsx)(`rect`,{x:n,y:r,width:i,height:a,rx:t?5:0,...o}):e===`circle`?(0,K.jsx)(`ellipse`,{cx:Ww/2,cy:Gw/2,rx:i/2,ry:a/2,...o}):e===`line`?(0,K.jsx)(`line`,{x1:n,y1:Gw-Kw,x2:Ww-Kw,y2:r,stroke:`#475569`,strokeWidth:2}):(0,K.jsx)(`path`,{d:F(e,n,r,i,a)??``,...o}),(0,K.jsx)(`svg`,{width:Ww,height:Gw,viewBox:`0 0 ${Ww} ${Gw}`,"aria-hidden":`true`,focusable:`false`,children:s})}function Jw({activeToolId:e,onActivate:t,canAddMedia:n,onAddMediaFiles:r}){let i=(0,G.useRef)(null);return(0,K.jsxs)(`aside`,{className:`squisq-template-designer-palette`,"aria-label":`Add to layout`,children:[(0,K.jsx)(`h3`,{className:`squisq-template-designer-palette-title`,children:`Add`}),(0,K.jsxs)(`div`,{className:`squisq-template-designer-palette-section`,children:[(0,K.jsx)(`div`,{className:`squisq-template-designer-palette-section-title`,children:`Placeholders`}),(0,K.jsx)(`div`,{className:`squisq-template-designer-palette-list`,children:Mw.map(n=>(0,K.jsxs)(`button`,{type:`button`,draggable:!0,className:`squisq-template-designer-palette-item${e===n.id?` squisq-template-designer-palette-item--active`:``}`,onDragStart:e=>{e.dataTransfer.setData(jw,n.id),e.dataTransfer.setData(`text/plain`,n.token),e.dataTransfer.effectAllowed=`copy`},onClick:()=>t(n.id),title:n.desc,children:[(0,K.jsx)(`span`,{className:`squisq-template-designer-palette-item-preview`,children:n.token}),(0,K.jsx)(`span`,{className:`squisq-template-designer-palette-item-label`,children:n.label})]},n.id))})]}),(0,K.jsxs)(`div`,{className:`squisq-template-designer-palette-section`,children:[(0,K.jsx)(`div`,{className:`squisq-template-designer-palette-section-title`,children:`Shapes`}),(0,K.jsx)(`div`,{className:`squisq-template-designer-palette-shapes`,children:Pw.map(n=>(0,K.jsx)(`button`,{type:`button`,draggable:!0,className:`squisq-template-designer-shape-item${e===n.id?` squisq-template-designer-shape-item--active`:``}`,onDragStart:e=>{e.dataTransfer.setData(Nw,n.id),e.dataTransfer.setData(`text/plain`,n.label),e.dataTransfer.effectAllowed=`copy`},onClick:()=>t(n.id),title:n.label,"aria-label":n.label,children:(0,K.jsx)(qw,{kind:n.kind,rounded:n.rounded})},n.id))})]}),(0,K.jsxs)(`div`,{className:`squisq-template-designer-palette-section`,children:[(0,K.jsx)(`div`,{className:`squisq-template-designer-palette-section-title`,children:`Media`}),(0,K.jsx)(`p`,{className:`squisq-template-designer-palette-hint`,children:n?`Drop an image on the canvas to add a full-bleed background.`:`Connect media storage to add image backgrounds.`}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-template-designer-palette-media-add`,disabled:!n,onClick:()=>i.current?.click(),children:`Add image…`}),(0,K.jsx)(`input`,{ref:i,type:`file`,accept:`image/*`,multiple:!0,style:{display:`none`},onChange:e=>{let t=Array.from(e.target.files??[]);t.length&&r(t),e.target.value=``}})]})]})}function Yw({layer:e,onAttr:t}){return(0,K.jsxs)(`div`,{className:`squisq-layer-toolbar`,role:`toolbar`,"aria-label":`Layer styling`,children:[e.type===`text`&&(0,K.jsx)(Zw,{layer:e,onAttr:t}),e.type===`shape`&&(0,K.jsx)(eT,{layer:e,onAttr:t}),e.type===`path`&&(0,K.jsx)(tT,{layer:e,onAttr:t}),e.type===`image`&&(0,K.jsx)(nT,{layer:e,onAttr:t})]})}var Xw=[[`Small`,24],[`Medium`,40],[`Large`,72],[`Huge`,120]];function Zw({layer:e,onAttr:t}){let n=e.content.style;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(rT,{label:`Horizontal align`,value:n.textAlign??`left`,onChange:e=>t(`content.style.textAlign`,e),options:[{value:`left`,icon:`fa-solid fa-align-left`,title:`Align left`},{value:`center`,icon:`fa-solid fa-align-center`,title:`Align center`},{value:`right`,icon:`fa-solid fa-align-right`,title:`Align right`}]}),(0,K.jsx)(rT,{label:`Vertical align`,value:n.verticalAlign??`top`,onChange:e=>t(`content.style.verticalAlign`,e),options:[{value:`top`,icon:`fa-solid fa-arrow-up`,title:`Align top`},{value:`middle`,icon:`fa-solid fa-grip-lines`,title:`Align middle`},{value:`bottom`,icon:`fa-solid fa-arrow-down`,title:`Align bottom`}]}),(0,K.jsx)(lT,{}),(0,K.jsx)(`select`,{className:`squisq-layer-toolbar-select`,"aria-label":`Font size`,title:`Font size`,value:Qw(n.fontSize),onChange:e=>t(`content.style.fontSize`,Number(e.target.value)),children:Xw.map(([e,t])=>(0,K.jsx)(`option`,{value:t,children:e},t))}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-layer-toolbar-btn${n.fontWeight===`bold`?` squisq-layer-toolbar-btn--active`:``}`,"aria-label":`Bold`,"aria-pressed":n.fontWeight===`bold`,title:`Bold`,onClick:()=>t(`content.style.fontWeight`,n.fontWeight===`bold`?`normal`:`bold`),children:(0,K.jsx)(q,{icon:`fa-solid fa-bold`})}),(0,K.jsx)(lT,{}),(0,K.jsx)(`span`,{className:`squisq-layer-toolbar-label`,children:(0,K.jsx)(q,{icon:`fa-solid fa-font`})}),(0,K.jsxs)(`select`,{className:`squisq-layer-toolbar-select squisq-layer-toolbar-select--font`,"aria-label":`Font`,title:`Font`,value:n.fontFamily??``,onChange:e=>t(`content.style.fontFamily`,e.target.value||void 0),children:[(0,K.jsx)(`option`,{value:``,children:`Default`}),et.map(e=>(0,K.jsx)(`option`,{value:e.family,children:e.label},e.id))]}),(0,K.jsx)(iT,{label:`Text color`,value:n.color,onChange:e=>t(`content.style.color`,e)}),(0,K.jsx)(lT,{}),(0,K.jsx)(`span`,{className:`squisq-layer-toolbar-label`,title:`Background fill`,children:(0,K.jsx)(q,{icon:`fa-solid fa-fill-drip`})}),(0,K.jsx)(oT,{label:`Background`,color:n.background,opacity:n.backgroundOpacity,gradient:n.backgroundGradient,defaultColor:`#1f2937`,noFillValue:void 0,colorPath:`content.style.background`,opacityPath:`content.style.backgroundOpacity`,gradientPath:`content.style.backgroundGradient`,onAttr:t}),(0,K.jsx)(lT,{}),(0,K.jsx)(`span`,{className:`squisq-layer-toolbar-label`,title:`Border`,children:(0,K.jsx)(q,{icon:`fa-solid fa-border-top-left`})}),(0,K.jsx)(sT,{color:n.borderColor,width:n.borderWidth,style:n.borderStyle,defaultColor:`#1e293b`,noBorderValue:void 0,colorPath:`content.style.borderColor`,widthPath:`content.style.borderWidth`,stylePath:`content.style.borderStyle`,onAttr:t})]})}function Qw(e){let t=Xw[0][1];for(let[,n]of Xw)Math.abs(n-e)<Math.abs(t-e)&&(t=n);return t}function $w({content:e,onAttr:t}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`squisq-layer-toolbar-label`,title:`Fill`,children:(0,K.jsx)(q,{icon:`fa-solid fa-fill-drip`})}),(0,K.jsx)(oT,{label:`Fill`,color:e.fill,opacity:e.fillOpacity,gradient:e.gradient,defaultColor:`#3b82f6`,noFillValue:`none`,colorPath:`content.fill`,opacityPath:`content.fillOpacity`,gradientPath:`content.gradient`,onAttr:t}),(0,K.jsx)(lT,{}),(0,K.jsx)(`span`,{className:`squisq-layer-toolbar-label`,title:`Border`,children:(0,K.jsx)(q,{icon:`fa-solid fa-border-top-left`})}),(0,K.jsx)(sT,{color:e.stroke,width:e.strokeWidth,style:e.borderStyle,defaultColor:`#1e293b`,noBorderValue:`none`,colorPath:`content.stroke`,widthPath:`content.strokeWidth`,stylePath:`content.borderStyle`,onAttr:t})]})}function eT({layer:e,onAttr:t}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`select`,{className:`squisq-layer-toolbar-select`,"aria-label":`Shape`,title:`Shape`,value:e.content.shape,onChange:e=>t(`content.shape`,e.target.value),children:[(0,K.jsx)(`option`,{value:`rect`,children:`Rectangle`}),(0,K.jsx)(`option`,{value:`circle`,children:`Ellipse`}),(0,K.jsx)(`option`,{value:`line`,children:`Line`})]}),(0,K.jsx)(lT,{}),(0,K.jsx)($w,{content:e.content,onAttr:t})]})}function tT({layer:e,onAttr:t}){return(0,K.jsx)($w,{content:e.content,onAttr:t})}function nT({layer:e,onAttr:t}){return(0,K.jsxs)(`select`,{className:`squisq-layer-toolbar-select`,"aria-label":`Image fit`,title:`How the image fills its box`,value:e.content.fit??`cover`,onChange:e=>t(`content.fit`,e.target.value),children:[(0,K.jsx)(`option`,{value:`cover`,children:`Fit: Cover`}),(0,K.jsx)(`option`,{value:`contain`,children:`Fit: Contain`}),(0,K.jsx)(`option`,{value:`fill`,children:`Fit: Stretch`})]})}function rT({label:e,value:t,options:n,onChange:r}){return(0,K.jsx)(`div`,{className:`squisq-layer-toolbar-seg`,role:`group`,"aria-label":e,children:n.map(e=>(0,K.jsx)(`button`,{type:`button`,className:`squisq-layer-toolbar-btn${t===e.value?` squisq-layer-toolbar-btn--active`:``}`,"aria-label":e.title,"aria-pressed":t===e.value,title:e.title,onClick:()=>r(e.value),children:(0,K.jsx)(q,{icon:e.icon})},e.value))})}function iT({label:e,value:t,onChange:n,onClear:r,clearLabel:i,cleared:a}){return(0,K.jsxs)(`span`,{className:`squisq-layer-toolbar-color`,title:e,children:[(0,K.jsx)(`input`,{type:`color`,"aria-label":e,value:uT(t),onChange:e=>n(e.target.value),style:a?{opacity:.4}:void 0}),r&&(0,K.jsx)(`button`,{type:`button`,className:`squisq-layer-toolbar-btn${a?` squisq-layer-toolbar-btn--active`:``}`,"aria-label":i??`None`,title:i??`None`,onClick:r,children:(0,K.jsx)(q,{icon:`fa-solid fa-ban`})})]})}var aT=[[`↓`,0,`Top to bottom`],[`→`,90,`Left to right`],[`↘`,45,`Diagonal ↘`],[`↙`,135,`Diagonal ↙`]];function oT({label:e,color:t,opacity:n,gradient:r,defaultColor:i,noFillValue:a,colorPath:o,opacityPath:s,gradientPath:c,onAttr:l}){let u=!!r,d=t&&t!==`none`?t:i;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`select`,{className:`squisq-layer-toolbar-select`,"aria-label":`${e} style`,title:`${e} style`,value:u?`gradient`:`solid`,onChange:e=>{e.target.value===`gradient`?l(c,{from:d,to:`#ffffff`,angle:0}):l(c,void 0)},children:[(0,K.jsx)(`option`,{value:`solid`,children:`Solid`}),(0,K.jsx)(`option`,{value:`gradient`,children:`Gradient`})]}),u?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(iT,{label:`${e} start color`,value:r.from,onChange:e=>l(c,{...r,from:e})}),(0,K.jsx)(iT,{label:`${e} end color`,value:r.to,onChange:e=>l(c,{...r,to:e})}),(0,K.jsx)(`select`,{className:`squisq-layer-toolbar-select`,"aria-label":`${e} direction`,title:`${e} direction`,value:String(r.angle??0),onChange:e=>l(c,{...r,angle:Number(e.target.value)}),children:aT.map(([e,t,n])=>(0,K.jsx)(`option`,{value:t,title:n,children:e},t))})]}):(0,K.jsx)(iT,{label:`${e} color`,value:d,onChange:e=>l(o,e),clearLabel:`No fill`,onClear:()=>l(o,a),cleared:!t||t===`none`}),(0,K.jsx)(cT,{label:`${e} opacity`,value:n,onChange:e=>l(s,e)})]})}function sT({color:e,width:t,style:n,defaultColor:r,noBorderValue:i,colorPath:a,widthPath:o,stylePath:s,onAttr:c}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(iT,{label:`Border color`,value:e&&e!==`none`?e:r,onChange:e=>c(a,e),clearLabel:`No border`,onClear:()=>c(a,i),cleared:!e||e===`none`}),(0,K.jsx)(`input`,{type:`number`,className:`squisq-layer-toolbar-number`,"aria-label":`Border thickness`,title:`Border thickness`,min:0,max:80,step:1,value:t??0,onChange:e=>c(o,Number(e.target.value))}),(0,K.jsxs)(`select`,{className:`squisq-layer-toolbar-select`,"aria-label":`Border style`,title:`Border style`,value:n??`solid`,onChange:e=>c(s,e.target.value),children:[(0,K.jsx)(`option`,{value:`solid`,children:`Solid`}),(0,K.jsx)(`option`,{value:`dashed`,children:`Dashed`}),(0,K.jsx)(`option`,{value:`dotted`,children:`Dotted`})]})]})}function cT({label:e,value:t,onChange:n}){let r=Math.round((t??1)*100);return(0,K.jsx)(`label`,{className:`squisq-layer-toolbar-opacity`,title:`${e} (${r}%)`,children:(0,K.jsx)(`input`,{type:`range`,"aria-label":e,min:0,max:100,step:5,value:r,onChange:e=>n(Number(e.target.value)/100)})})}function lT(){return(0,K.jsx)(`div`,{className:`squisq-layer-toolbar-sep`,"aria-hidden":`true`})}function uT(e){return/^#[0-9a-f]{6}$/i.test(e)?e:/^#[0-9a-f]{3}$/i.test(e)?`#`+e.slice(1).split(``).map(e=>e+e).join(``):`#000000`}var dT={width:1920,height:1080};function fT(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^[^a-z]+/,``).replace(/^-+|-+$/g,``)}var pT=[{id:`landscape`,label:`16:9`,viewport:{width:1920,height:1080,name:`Landscape`}},{id:`portrait`,label:`9:16`,viewport:{width:1080,height:1920,name:`Portrait`}},{id:`square`,label:`1:1`,viewport:{width:1080,height:1080,name:`Square`}}];function mT({initial:e,onSave:t,onClose:n,embedded:r=!1,primarySaveLabel:i=`Save to this doc`,mediaProvider:a=null,colorScheme:o=`light`}){let s=(0,G.useRef)(null),c=(0,G.useRef)(null),l=(0,G.useId)();Ur({rootRef:s,dialogRef:c,onClose:n});let[u,d]=(0,G.useState)(e?.name??``),[f,p]=(0,G.useState)(e?.label??``),[m,h]=(0,G.useState)(e?.description??``),[g,_]=(0,G.useState)(!e?.name),v=(0,G.useCallback)(e=>{p(e),g&&d(fT(e))},[g]),y=(0,G.useCallback)(e=>{e.trim()===``?(_(!0),d(fT(f))):(_(!1),d(e))},[f]),[b,x]=(0,G.useState)(`landscape`),S=(0,G.useMemo)(()=>[Nx,...Mw.map(e=>bw(e)),...Pw.map(e=>vw({id:e.id,label:e.label,build:t=>Uw(e,t)}))],[]),C=ww({initial:e?.layers??[],tools:S}),w=(0,G.useCallback)(async e=>{if(!a)return;let{media:t}=db(e);if(t.length===0)return;let n=(await fb(t,a)).filter(e=>!!e).map((e,t)=>({id:`bg-${Date.now().toString(36)}-${t}`,type:`image`,position:{x:0,y:0,width:dT.width,height:dT.height},content:{src:e,alt:``,fit:`cover`}}));n.length!==0&&C.setLayers([...n,...C.layers])},[C,a]),T=(0,G.useCallback)((e,t)=>{let n=Mw.find(t=>t.id===e.dataTransfer.getData(jw));if(n){C.dispatch({kind:`addLayer`,layer:yw(n,t)});return}let r=Pw.find(t=>t.id===e.dataTransfer.getData(Nw));if(r){C.dispatch({kind:`addLayer`,layer:Uw(r,t)});return}let i=Array.from(e.dataTransfer.files??[]);i.length>0&&w(i)},[C,w]),[E,D]=(0,G.useState)(null),O=C.layers.find(e=>e.id===E)??null,k=(0,G.useCallback)((e,t)=>{E&&C.dispatch({kind:`setLayerAttr`,id:E,path:e,value:t})},[C,E]),[A,j]=(0,G.useState)(`select`),M=pT.find(e=>e.id===b)?.viewport??dT,N=()=>{let e=u.trim();return e?/^[a-z][a-z0-9-]*$/.test(e)?f.trim()?C.layers.length===0?`Add at least one layer or placeholder.`:null:`Label is required.`:`Name must be lowercase letters, digits, and hyphens (no spaces).`:`Name is required.`},P=e=>{let i=N();if(i){alert(i);return}let a=Dw(C.layers,dT);t({name:u.trim(),label:f.trim(),viewport:dT,layers:a,...m.trim()?{description:m.trim()}:{}},e),r||n()},F=(0,K.jsxs)(`div`,{ref:c,className:`squisq-template-designer-panel${r?` squisq-template-designer-panel--embedded`:``}`,role:r?void 0:`dialog`,"aria-modal":r?void 0:`true`,"aria-labelledby":r?void 0:l,tabIndex:r?void 0:-1,children:[!r&&(0,K.jsxs)(`header`,{className:`squisq-template-designer-header`,children:[(0,K.jsx)(`h2`,{id:l,className:`squisq-template-designer-title`,children:e?`Edit layout`:`New layout`}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-template-designer-close`,onClick:n,"aria-label":`Close designer`,title:`Close (Esc)`,children:`×`})]}),(0,K.jsxs)(`div`,{className:`squisq-template-designer-meta`,children:[(0,K.jsxs)(`label`,{className:`squisq-template-designer-field`,children:[(0,K.jsx)(`span`,{children:`Label`}),(0,K.jsx)(`input`,{type:`text`,value:f,placeholder:`Hero Section`,onChange:e=>v(e.target.value)})]}),(0,K.jsxs)(`label`,{className:`squisq-template-designer-field`,children:[(0,K.jsx)(`span`,{children:`Name`}),(0,K.jsx)(`input`,{type:`text`,value:u,placeholder:`auto from label`,onChange:e=>y(e.target.value),spellCheck:!1}),(0,K.jsx)(`span`,{className:`squisq-template-designer-field-hint`,children:`Auto-derived from the label — edit to override.`})]}),(0,K.jsxs)(`label`,{className:`squisq-template-designer-field`,children:[(0,K.jsx)(`span`,{children:`Description`}),(0,K.jsx)(`input`,{type:`text`,value:m,placeholder:`One-sentence description (optional)`,onChange:e=>h(e.target.value)})]})]}),(0,K.jsxs)(`div`,{className:`squisq-template-designer-body`,children:[(0,K.jsx)(Jw,{activeToolId:A,onActivate:j,canAddMedia:!!a,onAddMediaFiles:e=>void w(e)}),(0,K.jsxs)(`div`,{className:`squisq-template-designer-stage`,children:[(0,K.jsxs)(`div`,{className:`squisq-template-designer-stage-bar`,children:[(0,K.jsx)(`span`,{className:`squisq-template-designer-viewport-label`,children:`Preview`}),(0,K.jsx)(`select`,{className:`squisq-layer-toolbar-select`,"aria-label":`Preview aspect ratio`,title:`Preview aspect ratio`,value:b,onChange:e=>x(e.target.value),children:pT.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.label},e.id))}),O&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`squisq-layer-toolbar-sep`,"aria-hidden":`true`}),(0,K.jsx)(Yw,{layer:O,onAttr:k})]})]}),(0,K.jsx)(`div`,{className:`squisq-template-designer-scene`,children:(0,K.jsx)(pn.Provider,{value:a,children:(0,K.jsx)(Hx,{viewport:M,layers:C.layers,tools:S,activeToolId:A,onActiveToolIdChange:j,onCommand:C.dispatch,onSelectionChange:e=>D(e.values().next().value??null),onDrop:T,showToolbar:!1})})})]})]}),(0,K.jsxs)(`footer`,{className:`squisq-template-designer-footer`,children:[(0,K.jsx)(`span`,{className:`squisq-template-designer-footer-hint`,children:`Layers are saved as % of a 1920×1080 canvas so the layout adapts to any viewport.`}),(0,K.jsxs)(`div`,{className:`squisq-template-designer-footer-actions`,children:[!r&&(0,K.jsx)(`button`,{type:`button`,className:`squisq-template-designer-btn`,onClick:n,children:`Cancel`}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-template-designer-btn`,onClick:()=>P(`library`),title:`Save to your browser-local library so other docs can use it`,children:`Save to library`}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-template-designer-btn squisq-template-designer-btn--primary`,onClick:()=>P(`doc`),children:i})]})]})]});return r?F:(0,Wr.createPortal)((0,K.jsx)(`div`,{ref:s,className:`squisq-editor-shell squisq-template-designer-overlay`,"data-theme":o,onClick:e=>{e.target===e.currentTarget&&n()},children:F}),document.body)}function hT({onClose:e}){let{docTemplates:t,onDocTemplatesChange:n}=_b(),{mediaProvider:r,colorScheme:i}=Lp(),a=(0,G.useRef)(null),o=(0,G.useRef)(null),s=(0,G.useId)();return Ur({rootRef:a,dialogRef:o,onClose:e}),(0,Wr.createPortal)((0,K.jsx)(`div`,{ref:a,className:`squisq-editor-shell squisq-layout-manager-overlay`,"data-theme":i,onClick:t=>{t.target===t.currentTarget&&e()},children:(0,K.jsxs)(`div`,{ref:o,className:`squisq-editor-shell squisq-layout-manager-panel`,"data-theme":i,role:`dialog`,"aria-modal":`true`,"aria-labelledby":s,tabIndex:-1,children:[(0,K.jsxs)(`header`,{className:`squisq-layout-manager-header`,children:[(0,K.jsx)(`h2`,{id:s,className:`squisq-layout-manager-title`,children:`Custom layouts`}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-template-designer-close`,onClick:e,"aria-label":`Close custom layouts`,title:`Close (Esc)`,children:`×`})]}),(0,K.jsx)(xv,{docTemplates:t,onDocTemplatesChange:n,children:(0,K.jsx)(gT,{mediaProvider:r})})]})}),document.body)}function gT({mediaProvider:e}){let t=Sv();return t?(0,K.jsx)(_T,{ctx:t,mediaProvider:e}):null}function _T({ctx:e,mediaProvider:t}){let{docTemplates:n,libraryTemplates:r,upsertDocTemplate:i,upsertLibraryTemplate:a}=e,[o,s]=(0,G.useState)(()=>n[0]?{source:`doc`,name:n[0].name}:r[0]?{source:`library`,name:r[0].name}:`new`),c=o===`new`?void 0:o.def??(o.source===`doc`?n:r).find(e=>e.name===o.name),l=(0,G.useCallback)((e,t)=>{t===`doc`?i(e):a(e),s({source:t===`doc`?`doc`:`library`,name:e.name,def:e})},[i,a]),u=(e,t)=>o!==`new`&&o.source===e&&o.name===t,d=(e,t)=>(0,K.jsxs)(`button`,{type:`button`,className:`squisq-layout-manager-item${u(t,e.name)?` squisq-layout-manager-item--active`:``}`,onClick:()=>s({source:t,name:e.name}),children:[(0,K.jsx)(`span`,{className:`squisq-layout-manager-item-thumb`,children:(0,K.jsx)(Ev,{def:e})}),(0,K.jsxs)(`span`,{className:`squisq-layout-manager-item-text`,children:[(0,K.jsx)(`span`,{className:`squisq-layout-manager-item-label`,children:e.label||e.name}),(0,K.jsx)(`span`,{className:`squisq-layout-manager-item-name`,children:e.name})]})]},`${t}:${e.name}`);return(0,K.jsxs)(`div`,{className:`squisq-layout-manager-body`,children:[(0,K.jsxs)(`aside`,{className:`squisq-layout-manager-sidebar`,children:[(0,K.jsx)(`button`,{type:`button`,className:`squisq-layout-manager-new${o===`new`?` squisq-layout-manager-new--active`:``}`,onClick:()=>s(`new`),children:`+ New layout`}),n.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`squisq-layout-manager-section-title`,children:`This document`}),(0,K.jsx)(`div`,{className:`squisq-layout-manager-list`,children:n.map(e=>d(e,`doc`))})]}),r.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`squisq-layout-manager-section-title`,children:`Library`}),(0,K.jsx)(`div`,{className:`squisq-layout-manager-list`,children:r.map(e=>d(e,`library`))})]}),n.length===0&&r.length===0&&(0,K.jsx)(`p`,{className:`squisq-layout-manager-empty-hint`,children:`No custom layouts yet. Design one on the right and save it to this document or your library.`})]}),(0,K.jsx)(`div`,{className:`squisq-layout-manager-main`,children:(0,K.jsx)(mT,{embedded:!0,initial:c,mediaProvider:t,primarySaveLabel:o!==`new`&&o.source===`doc`?`Save`:`Save to this doc`,onSave:l,onClose:()=>{}},o===`new`?`new`:`${o.source}:${o.name}`)})]})}var vT=`state.json`;function yT(e){return e.split(/[\\/]+/).filter(Boolean)}function bT(e){let t=yT(e.name).map(e=>e.toLowerCase()),n=t[t.length-1]??``;if(n===`.gitignore`||t.includes(`.versions`))return!1;let r=t[t.length-2]??``;return!(n===vT&&(t.includes(`.imageedits`)||r.endsWith(`_files`)))}function xT(e){return e.filter(bT)}function ST(e){return e.replace(/\r\n?/g,`
|
|
402
|
+
`).split(`
|
|
403
|
+
`).map(e=>e.trim()).filter(e=>e.length>0)}function CT(e){let t=e.trim();t.startsWith(`|`)&&(t=t.slice(1)),t.endsWith(`|`)&&!t.endsWith(`\\|`)&&(t=t.slice(0,-1));let n=[],r=``;for(let e=0;e<t.length;e++){let i=t[e];i===`\\`&&t[e+1]===`|`?(r+=`|`,e++):i===`|`?(n.push(r.trim()),r=``):r+=i}return n.push(r.trim()),n}function wT(e){let t=[],n=``,r=!1;for(let i=0;i<e.length;i++){let a=e[i];a===`"`&&!r&&n.trim().length===0?(r=!0,n=``):a===`"`&&r?e[i+1]===`"`?(n+=`"`,i++):r=!1:a===`,`&&!r?(t.push(n.trim()),n=``):n+=a}return r?e.split(`,`).map(e=>e.trim()):(t.push(n.trim()),t)}function TT(e,t){switch(t){case`pipe`:return CT(e);case`comma`:return wT(e);case`tab`:return e.trim().split(` `).map(e=>e.trim());case`multispace`:return e.trim().split(/[ \u00a0]{2,}/).map(e=>e.trim())}}function ET(e){let t=ST(e),n=[`pipe`,`comma`,`tab`,`multispace`];if(t.length>=2)for(let e of n){let n=t.map(t=>TT(t,e)),r=n[0]?.length??0;if(r>=2&&n.every(e=>e.length===r))return{delimiter:e,rows:n}}return{delimiter:null,rows:t.map(e=>[e])}}function DT(e){return e.replace(/\|/g,`\\|`)}function OT(e){let{rows:t}=ET(e);if(t.length===0)return``;let n=e=>`| ${e.map(DT).join(` | `)} |`,r=t[0].map(()=>`---`);return[n(t[0]),n(r),...t.slice(1).map(n)].join(`
|
|
404
|
+
`)}function kT(e){return ST(e).map(e=>{let t=/^[-*+]\s+\[([ xX])\]\s*(.*)$/.exec(e);return t?{checked:t[1].toLowerCase()===`x`,text:t[2].trim()}:{checked:!1,text:e.replace(/^(?:[-*+]\s+|\d+[.)]\s+)/,``).trim()}})}function AT(e){return kT(e).map(e=>`- [${e.checked?`x`:` `}] ${e.text}`).join(`
|
|
405
|
+
`)}function jT(e,t){let n=t.trim();if(!n||!e)return[];let r=new RegExp(PT(n),`giu`),i=[],a;for(;(a=r.exec(e))!==null;)i.push({from:a.index,to:a.index+a[0].length}),a[0].length===0&&(r.lastIndex+=1);return i}function MT(e,t){return t<=0?0:(e%t+t)%t}function NT(e,t){let n=[];return e.descendants((e,r)=>{if(!e.isTextblock)return!0;let i=[],a=``;e.descendants((e,t)=>{if(e.isText&&e.text){let n=a.length;a+=e.text,i.push({from:n,to:a.length,docFrom:r+1+t})}else e.isInline&&(a+=`\0`);return!0});for(let e of jT(a,t)){let t=i.find(t=>e.from>=t.from&&e.from<t.to),r=e.to-1,a=i.find(e=>r>=e.from&&r<e.to);!t||!a||n.push({from:t.docFrom+e.from-t.from,to:a.docFrom+e.to-a.from})}return!1}),n}function PT(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}var FT=new Dr(`squisq-find-highlight`);function IT(e,t,n){let r=NT(e,t),i=MT(n,r.length),a=r.map((e,t)=>sr.inline(e.from,e.to,{class:t===i?`squisq-find-match squisq-find-match--selected`:`squisq-find-match`}));return{query:t,selectedIndex:i,decorations:or.create(e,a)}}var LT=kr.create({name:`squisqFindHighlight`,addProseMirrorPlugins(){return[new pr({key:FT,state:{init:(e,t)=>IT(t.doc,``,0),apply:(e,t,n,r)=>{let i=e.getMeta(FT);return!i&&!e.docChanged?t:IT(r.doc,i?.query??t.query,i?.selectedIndex??t.selectedIndex)}},props:{decorations:e=>FT.getState(e)?.decorations??null}})]}});function RT(e,t,n){let r=NT(e.state.doc,t);return e.view.dispatch(e.state.tr.setMeta(FT,{query:t,selectedIndex:MT(n,r.length)})),r.length}function zT({onClose:e}){let{activeView:t,markdownSource:n,tiptapEditor:r,monacoEditor:i}=Lp(),[a,o]=(0,G.useState)(``),[s,c]=(0,G.useState)(0),[l,u]=(0,G.useState)(0),d=(0,G.useRef)(null),f=(0,G.useId)().replace(/[^a-zA-Z0-9_-]/g,``),p=`squisq-find-${f}`,m=`${p}-selected`;(0,G.useEffect)(()=>{d.current?.focus()},[]),(0,G.useEffect)(()=>{let e=document.createElement(`style`);return e.dataset.squisqFindHighlight=f,e.textContent=`::highlight(${p}) { background: #fde68a; color: inherit; } ::highlight(${m}) { background: #f59e0b; color: #111827; }`,document.head.append(e),()=>e.remove()},[p,m,f]),(0,G.useEffect)(()=>{let e=()=>{},n=0;if(t===`raw`&&i){let t=i.getModel(),r=t?t.findMatches(a.trim(),!1,!1,!1,null,!1):[];n=a.trim()?r.length:0;let o=MT(s,n),c=i.createDecorationsCollection(r.slice(0,n).map((e,t)=>({range:e.range,options:BT(t===o)})));n>0&&i.revealRangeInCenter(r[o].range),e=()=>c.clear()}else if(t===`wysiwyg`&&r&&!r.isDestroyed)n=RT(r,a,s),r.view.dom.querySelector(`.squisq-find-match--selected`)?.scrollIntoView?.({block:`center`,inline:`nearest`}),e=()=>{r.isDestroyed||RT(r,``,0)};else if(t===`preview`){let t=d.current?.closest(`.squisq-editor-shell`)?.querySelector(`[data-testid="preview-panel"]`);if(t){let r=VT(t,a,s,p,m);n=r.count,e=r.cleanup}}return u(n),c(e=>MT(e,n)),e},[t,n,i,p,m,a,s,r]);let h=(0,G.useCallback)(e=>{l!==0&&c(t=>MT(t+e,l))},[l]),g=a.trim()===``?`0 of 0`:l===0?`No results`:`${MT(s,l)+1} of ${l}`;return(0,K.jsxs)(`div`,{className:`squisq-find-toolbar`,role:`search`,"aria-label":`Find in document`,children:[(0,K.jsxs)(`div`,{className:`squisq-find-field`,children:[(0,K.jsx)(q,{icon:`fa-solid fa-magnifying-glass`}),(0,K.jsx)(`input`,{ref:d,type:`search`,value:a,className:`squisq-find-input`,"aria-label":`Find in document`,placeholder:`Find in document`,autoComplete:`off`,spellCheck:!1,onChange:e=>{o(e.target.value),c(0)},onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),h(t.shiftKey?-1:1)):t.key===`Escape`&&(t.preventDefault(),e())}}),(0,K.jsx)(`span`,{className:`squisq-find-count`,"aria-live":`polite`,"aria-atomic":`true`,children:g})]}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-find-button`,"aria-label":`Previous match`,"data-tooltip":`Previous match (Shift+Enter)`,disabled:l===0,onClick:()=>h(-1),children:(0,K.jsx)(q,{icon:`fa-solid fa-chevron-up`})}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-find-button`,"aria-label":`Next match`,"data-tooltip":`Next match (Enter)`,disabled:l===0,onClick:()=>h(1),children:(0,K.jsx)(q,{icon:`fa-solid fa-chevron-down`})}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-find-button squisq-find-close`,"aria-label":`Close find`,"data-tooltip":`Close find (Esc)`,onClick:e,children:(0,K.jsx)(q,{icon:`fa-solid fa-xmark`})})]})}function BT(e){return{inlineClassName:e?`squisq-find-match squisq-find-match--selected`:`squisq-find-match`}}function VT(e,t,n,r,i){let a=HT(e,t),o=MT(n,a.length),s=globalThis.CSS,c=globalThis.Highlight;if(s?.highlights&&c)return s.highlights.set(r,new c(...a)),a.length>0?(s.highlights.set(i,new c(a[o])),UT(a[o])):s.highlights.delete(i),{count:a.length,cleanup:()=>{s.highlights?.delete(r),s.highlights?.delete(i)}};let l=WT(a,o);return l.find(e=>e.classList.contains(`squisq-find-match--selected`))?.scrollIntoView?.({block:`center`,inline:`nearest`}),{count:a.length,cleanup:()=>{let e=new Set;for(let t of l){let n=t.parentNode;n&&(e.add(n),t.replaceWith(...Array.from(t.childNodes)))}e.forEach(e=>e.normalize())}}}function HT(e,t){if(!t.trim())return[];let n=e.ownerDocument,r=n.defaultView?.NodeFilter.SHOW_TEXT??4,i=n.createTreeWalker(e,r),a=[],o=i.nextNode();for(;o;){let e=o,r=e.parentElement;if(r&&!r.closest(`button, input, textarea, select, script, style, [aria-hidden="true"], [data-squisq-find-ignore]`))for(let r of jT(e.data,t)){let t=n.createRange();t.setStart(e,r.from),t.setEnd(e,r.to),a.push(t)}o=i.nextNode()}return a}function UT(e){(e.startContainer instanceof Element?e.startContainer:e.startContainer.parentElement)?.scrollIntoView?.({block:`center`,inline:`nearest`})}function WT(e,t){let n=[];return[...e].map((e,t)=>({range:e,index:t})).reverse().forEach(({range:e,index:r})=>{let i=e.startContainer;if(!(i instanceof Text)||i!==e.endContainer||!i.parentNode)return;i.splitText(e.endOffset);let a=i.splitText(e.startOffset),o=i.ownerDocument.createElement(`mark`);o.className=r===t?`squisq-find-match squisq-find-match--selected`:`squisq-find-match`,a.replaceWith(o),o.append(a),n.push(o)}),n}function GT(e){return e===void 0?typeof navigator>`u`?``:navigator.platform:e}function KT(e,t){return/Mac|iPhone|iPad|iPod/i.test(GT(t))?`\u2318${e}`:`Ctrl+${e}`}var qT=[{id:`bold`,label:`B`,icon:`B`,title:`Bold (Ctrl+B)`,group:`format`,faIcon:`fa-solid fa-bold`},{id:`italic`,label:`I`,icon:`I`,title:`Italic (Ctrl+I)`,group:`format`,faIcon:`fa-solid fa-italic`},{id:`strikethrough`,label:`S`,icon:`S`,title:`Strikethrough`,group:`format`,faIcon:`fa-solid fa-strikethrough`},{id:`ul`,label:`•`,icon:`•`,title:`Bullet list`,group:`lists`,faIcon:`fa-solid fa-list-ul`},{id:`ol`,label:`1.`,icon:`1.`,title:`Numbered list`,group:`lists`,faIcon:`fa-solid fa-list-ol`},{id:`h1`,label:`H1`,icon:`H1`,title:`Heading 1`,group:`structure`},{id:`h2`,label:`H2`,icon:`H2`,title:`Heading 2`,group:`structure`},{id:`h3`,label:`H3`,icon:`H3`,title:`Heading 3`,group:`structure`},{id:`h4`,label:`H4`,icon:`H4`,title:`Heading 4`,group:`structure`},{id:`h5`,label:`H5`,icon:`H5`,title:`Heading 5`,group:`structure`},{id:`h6`,label:`H6`,icon:`H6`,title:`Heading 6`,group:`structure`},{id:`quote`,label:`❝`,icon:`❝`,title:`Blockquote`,group:`insert`,faIcon:`fa-solid fa-quote-left`},{id:`code`,label:`</>`,icon:`</>`,title:`Inline code`,group:`insert`,faIcon:`fa-solid fa-code`},{id:`superscript`,label:`x²`,icon:`x²`,title:`Superscript (Ctrl+.)`,group:`insert`,faIcon:`fa-solid fa-superscript`},{id:`subscript`,label:`x₂`,icon:`x₂`,title:`Subscript (Ctrl+,)`,group:`insert`,faIcon:`fa-solid fa-subscript`},{id:`hr`,label:`—`,icon:`—`,title:`Horizontal rule`,group:`insert`,faIcon:`fa-solid fa-minus`},{id:`link`,label:`🔗`,icon:`🔗`,title:`Insert link`,group:`media`,faIcon:`fa-solid fa-link`},{id:`table`,label:`table`,icon:``,title:`Insert table`,group:`media`,faIcon:`fa-solid fa-table`},{id:`tasklist`,label:`tasks`,icon:``,title:`Insert Task List`,group:`media`,faIcon:`fa-solid fa-list-check`},{id:`chart`,label:`chart`,icon:``,title:`Insert chart`,group:`media`,faIcon:`fa-solid fa-chart-column`},{id:`diagram`,label:`diagram`,icon:``,title:`Insert diagram`,group:`media`,faIcon:`fa-solid fa-diagram-project`},{id:`complexdiagram`,label:`complex diagram`,icon:``,title:`Insert Complex Diagram (Mermaid)`,group:`media`,faIcon:`fa-solid fa-code-branch`},{id:`tree`,label:`tree`,icon:``,title:`Insert tree`,group:`media`,faIcon:`fa-solid fa-folder-tree`},{id:`timeline`,label:`timeline`,icon:``,title:`Insert timeline`,group:`media`,faIcon:`fa-solid fa-timeline`},{id:`drawing`,label:`drawing`,icon:``,title:`Insert drawing`,group:`media`,faIcon:`fa-solid fa-pen-nib`},{id:`layout`,label:`layout`,icon:``,title:`Insert layout`,group:`media`,faIcon:`fa-solid fa-object-group`},{id:`image`,label:`🖼`,icon:`🖼`,title:`Insert image`,group:`media`,faIcon:`fa-solid fa-image`},{id:`emoji`,label:`😊`,icon:`😊`,title:`Insert emoji`,group:`media`,faIcon:`fa-solid fa-face-smile`}],JT=qT.findIndex(e=>e.group===`media`),YT=qT.filter(e=>e.group===`media`),XT=YT.filter(e=>e.id===`table`||e.id===`tasklist`),ZT=200,QT=220,$T=520,eE=360,tE=[`Task 1`,`Task 2`,`Task 3`],nE=tE.map(e=>`- [ ] ${e}`).join(`
|
|
406
|
+
`),rE=new Map(qT.map((e,t)=>[e.id,t]));function iE(e){return e.faIcon?(0,K.jsx)(q,{icon:e.faIcon}):e.icon}function aE(e){return`${e} ${e===1?`file`:`files`}`}function oE(e){return e>99?`99+`:String(e)}function sE(e){return e?{type:`paragraph`,content:[{type:`text`,text:e}]}:{type:`paragraph`}}function cE(e){return{type:`table`,content:e.map((e,t)=>({type:`tableRow`,content:e.map(e=>({type:t===0?`tableHeader`:`tableCell`,content:[sE(e)]}))}))}}function lE(e=tE.map(e=>({checked:!1,text:e}))){return{type:`taskList`,content:e.map(e=>({type:`taskItem`,attrs:{checked:e.checked},content:[sE(e.text)]}))}}function uE(e){let t=e.schema.nodes.taskList&&e.schema.nodes.taskItem?lE():nE;e.chain().focus().insertContent(t).run()}function dE(e){let{from:t,to:n,$from:r,$to:i}=e.state.selection;return{from:r.depth===1&&r.parent.isTextblock&&r.parentOffset===0?r.before(1):t,to:i.depth===1&&i.parent.isTextblock&&i.parentOffset===i.parent.content.size?i.after(1):n}}function fE(e,t){if(!e)return!1;switch(t){case`bold`:return e.isActive(`bold`);case`italic`:return e.isActive(`italic`);case`strikethrough`:return e.isActive(`strike`);case`superscript`:return e.isActive(`superscript`);case`subscript`:return e.isActive(`subscript`);case`code`:return e.isActive(`code`);case`h1`:return e.isActive(`heading`,{level:1});case`h2`:return e.isActive(`heading`,{level:2});case`h3`:return e.isActive(`heading`,{level:3});case`h4`:return e.isActive(`heading`,{level:4});case`h5`:return e.isActive(`heading`,{level:5});case`h6`:return e.isActive(`heading`,{level:6});case`quote`:return e.isActive(`blockquote`);case`ul`:return e.isActive(`bulletList`);case`ol`:return e.isActive(`orderedList`);case`codeblock`:return e.isActive(`codeBlock`);default:return!1}}var pE=`squisq-code-snippet-focus-inserted`;function mE(e){let t=e.getModel();if(!t)return;let n=t.getPositionAt(t.getValueLength());e.setPosition(n),e.revealPositionInCenterIfOutsideViewport(n),e.focus()}var hE=`x=360 y=380 width=1200 height=320 fontSize=64 fontWeight=bold align=center valign=middle color="#1e293b"`,gE=`
|
|
407
|
+
## Layout {[layout]}
|
|
408
|
+
|
|
409
|
+
### {#text-1} {[text ${hE}]}
|
|
410
|
+
|
|
411
|
+
Layout
|
|
412
|
+
`,_E=[``,``,` ┌─────────┐`,` │ Start │`,` └────┬────┘`,` │`,` ▼`,` ┌────┴────┐`,` │ Next │`,` └─────────┘`].join(`
|
|
413
|
+
`),vE="\n```diagram\n"+_E+"\n```\n";function yE(e){kE(e,_E,`diagram`)}var bE=kb.starter,xE=Ab(bE);function SE(e,t=bE){kE(e,t,`mermaid`)}var CE=[`src/`,`├── index.ts`,`└── utils/`,` └── helpers.ts`].join(`
|
|
414
|
+
`),wE="\n```tree\n"+CE+"\n```\n";function TE(e){kE(e,CE,`tree`)}var EE=`Milestones: ● Start {#start} ─────● Review {#review} ─────● Ship {#ship} ───►`,DE="\n```timeline\n"+EE+"\n```\n";function OE(e){kE(e,EE,`timeline`)}function kE(e,t,n,r={}){e.chain().focus().command(({tr:e,state:i,dispatch:a})=>{let o=i.schema.nodes.codeBlock;if(!o)return!1;let s=n?{language:n}:null,c=o.create(s,i.schema.text(t)),{$from:l}=i.selection,u=l.depth>0?l.after(1):i.doc.content.size;return a&&(e.insert(u,c),r.focusInsertedCodeSnippet&&e.setMeta(pE,u)),!0}).run()}function AE(e,t){e.chain().focus().command(({tr:e,state:n,dispatch:r})=>{let{heading:i,paragraph:a,table:o,tableRow:s,tableHeader:c,tableCell:l}=n.schema.nodes;if(!i)return!1;let u=[i.create({level:2,dataTemplate:t.template},n.schema.text(t.headingText))];if(a&&o&&s&&c&&l){let e=(e,t)=>e.create(null,a.create(null,t?n.schema.text(t):void 0)),r=s.create(null,mr.fromArray(t.table.headers.map(t=>e(c,t)))),i=t.table.rows.map(t=>s.create(null,mr.fromArray(t.map(t=>e(l,t)))));u.push(o.create(null,mr.fromArray([r,...i])))}let{$from:d}=n.selection,f=d.depth>0?d.after(1):n.doc.content.size;return r&&(e.insert(f,mr.fromArray(u)),e.setSelection(Er.create(e.doc,f+1))),!0}).run()}function jE(e,t){e.chain().focus().command(({tr:e,state:n,dispatch:r})=>{let i=n.schema.nodes.heading;if(!i)return!1;let a=i.create({level:t.level??2,dataTemplate:t.template,dataBlockAttrs:t.blockAttrs??null},n.schema.text(t.text)),{$from:o}=n.selection,s=o.depth>0?o.after(1):n.doc.content.size;return r&&(e.insert(s,a),e.setSelection(Er.create(e.doc,s+1))),!0}).run()}function ME(e){e.chain().focus().command(({tr:e,state:t,dispatch:n})=>{let r=t.schema.nodes.heading,i=t.schema.nodes.paragraph;if(!r||!i)return!1;let a=r.create({level:2,dataTemplate:`layout`},t.schema.text(`Layout`)),o=r.create({level:3,dataTemplate:`text`,dataTemplateParams:hE,dataBlockAttrs:`#text-1`}),s=i.create(null,t.schema.text(`Layout`)),{$from:c}=t.selection,l=c.depth>0?c.after(1):t.doc.content.size;return n&&(e.insert(l,mr.fromArray([a,o,s])),e.setSelection(Er.create(e.doc,l+1))),!0}).run()}var NE={headers:[`Category`,`Value A`,`Value B`],rows:[[`Alpha`,`40`,`28`],[`Beta`,`55`,`31`],[`Gamma`,`30`,`45`]]},PE={headers:[`Segment`,`Share`],rows:[[`North`,`45`],[`South`,`30`],[`East`,`15`],[`West`,`10`]]},FE={headers:[`Month`,`Revenue`,`Costs`],rows:[[`Jan`,`40`,`28`],[`Feb`,`55`,`31`],[`Mar`,`48`,`30`],[`Apr`,`62`,`35`]]},IE=[{id:`columnChart`,label:`Column`,description:`Vertical columns — one per table row.`,preview:`column`,headingText:`Column chart`,table:NE},{id:`barChart`,label:`Bar`,description:`Horizontal bars — one per table row.`,preview:`bar`,headingText:`Bar chart`,table:NE},{id:`lineChart`,label:`Line`,description:`One line per value column.`,preview:`line`,headingText:`Line chart`,table:FE},{id:`areaChart`,label:`Area`,description:`Filled lines on a zero-based axis.`,preview:`area`,headingText:`Area chart`,table:FE},{id:`pieChart`,label:`Pie`,description:`Each row becomes a labeled slice.`,preview:`pie`,headingText:`Pie chart`,table:PE},{id:`donutChart`,label:`Donut`,description:`A pie with an open center.`,preview:`donut`,headingText:`Donut chart`,table:PE},{id:`scatterChart`,label:`Scatter`,description:`X/Y points from two numeric columns.`,preview:`scatter`,headingText:`Scatter chart`,table:{headers:[`Hours`,`Score`],rows:[[`1`,`40`],[`2`,`52`],[`4`,`65`],[`6`,`74`],[`8`,`90`]]}}],LE=IE[0];function RE(e){return[`| ${e.headers.join(` | `)} |`,`| --- |${e.headers.slice(1).map(()=>` ---: |`).join(``)}`,...e.rows.map(e=>`| ${e.join(` | `)} |`)].join(`
|
|
415
|
+
`)}function zE(e){return`
|
|
416
|
+
## ${e.headingText} {[${e.id}]}
|
|
417
|
+
|
|
418
|
+
${RE(e.table)}
|
|
419
|
+
`}function BE({preview:e}){let t={fill:`none`,stroke:`currentColor`,strokeWidth:2},n;switch(e){case`bar`:n=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M14 8v48`}),(0,K.jsx)(`rect`,{x:`14`,y:`12`,width:`80`,height:`9`,fill:`currentColor`,opacity:`.55`}),(0,K.jsx)(`rect`,{x:`14`,y:`27`,width:`52`,height:`9`,fill:`currentColor`,opacity:`.35`}),(0,K.jsx)(`rect`,{x:`14`,y:`42`,width:`66`,height:`9`,fill:`currentColor`,opacity:`.45`})]});break;case`column`:n=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M10 54h100`}),(0,K.jsx)(`rect`,{x:`22`,y:`26`,width:`14`,height:`28`,fill:`currentColor`,opacity:`.45`}),(0,K.jsx)(`rect`,{x:`44`,y:`14`,width:`14`,height:`40`,fill:`currentColor`,opacity:`.55`}),(0,K.jsx)(`rect`,{x:`66`,y:`22`,width:`14`,height:`32`,fill:`currentColor`,opacity:`.4`}),(0,K.jsx)(`rect`,{x:`88`,y:`34`,width:`14`,height:`20`,fill:`currentColor`,opacity:`.35`})]});break;case`pie`:n=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`circle`,{cx:`60`,cy:`32`,r:`24`}),(0,K.jsx)(`path`,{d:`M60 32V8a24 24 0 0 1 22.6 31.9Z`,fill:`currentColor`,opacity:`.45`}),(0,K.jsx)(`path`,{d:`M60 32 82.6 39.9A24 24 0 0 1 46 53.4Z`,fill:`currentColor`,opacity:`.25`})]});break;case`donut`:n=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`circle`,{cx:`60`,cy:`32`,r:`24`}),(0,K.jsx)(`circle`,{cx:`60`,cy:`32`,r:`11`}),(0,K.jsx)(`path`,{d:`M60 8a24 24 0 0 1 22.6 31.9l-12.4-4.3A11 11 0 0 0 60 21Z`,fill:`currentColor`,opacity:`.45`})]});break;case`line`:n=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M10 54h100M10 8v46`,opacity:`.4`}),(0,K.jsx)(`path`,{d:`M16 46l24-16 24 8 24-20 20 6`,strokeWidth:`3`}),(0,K.jsx)(`circle`,{cx:`40`,cy:`30`,r:`3`,fill:`currentColor`}),(0,K.jsx)(`circle`,{cx:`64`,cy:`38`,r:`3`,fill:`currentColor`}),(0,K.jsx)(`circle`,{cx:`88`,cy:`18`,r:`3`,fill:`currentColor`})]});break;case`area`:n=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M10 54h100`,opacity:`.4`}),(0,K.jsx)(`path`,{d:`M16 46l24-16 24 8 24-20 20 6v30H16Z`,fill:`currentColor`,opacity:`.3`,stroke:`none`}),(0,K.jsx)(`path`,{d:`M16 46l24-16 24 8 24-20 20 6`,strokeWidth:`3`})]});break;case`scatter`:n=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{d:`M14 8v46h92`,opacity:`.4`}),(0,K.jsx)(`circle`,{cx:`30`,cy:`42`,r:`3.5`,fill:`currentColor`,opacity:`.5`}),(0,K.jsx)(`circle`,{cx:`42`,cy:`30`,r:`3.5`,fill:`currentColor`}),(0,K.jsx)(`circle`,{cx:`56`,cy:`36`,r:`3.5`,fill:`currentColor`,opacity:`.5`}),(0,K.jsx)(`circle`,{cx:`70`,cy:`22`,r:`3.5`,fill:`currentColor`}),(0,K.jsx)(`circle`,{cx:`84`,cy:`27`,r:`3.5`,fill:`currentColor`,opacity:`.5`}),(0,K.jsx)(`circle`,{cx:`98`,cy:`14`,r:`3.5`,fill:`currentColor`})]});break}return(0,K.jsx)(`svg`,{viewBox:`0 0 120 64`,"aria-hidden":`true`,focusable:`false`,...t,children:n})}var VE=[{id:`wysiwyg`,label:`Write`,shortcutKey:`1`},{id:`raw`,label:`Source`,shortcutKey:`2`},{id:`preview`,label:`Use`,shortcutKey:`3`}],HE=new Set(Object.keys(pt));function UE(e,t){for(let n of e){let e=n.sourceHeading?.position;if(e&&e.start.line<=t&&e.end.line>=t)return n}return null}function WE(e){let t=wt(e);if(!t)return{text:e.trimEnd(),params:[]};let n=jt(t.inner.trim()),r=n.length>0&&n[0].indexOf(`=`)>0;return{text:e.slice(0,t.index).trimEnd(),params:KE(n.slice(+!r))}}function GE(e,t){let n=e?[e,...t]:t;return n.length>0?`{[${n.join(` `)}]}`:null}function KE(e){return e.filter(e=>{let t=yt(e);return t?HE.has(t.key):!1})}function qE(e){if(!e)return null;let t=KE(jt(e));return t.length>0?t.join(` `):null}function JE({className:e,showFiles:t,fileCount:n,onToggleFiles:r,slotLeft:i,slotAfterTabs:a,slotAfterActions:o,slotRight:s,showPlayTab:c=!0,showFormattingControls:l=!0,showInsertControls:u=!0,hostMode:d=`document`}){let{activeView:f,setActiveView:p,markdownSource:m,doc:g,setMarkdownSource:_,tiptapEditor:v,monacoEditor:y,activeSceneText:b,mediaProvider:x,editorMode:S,findMode:C,setFindMode:w,layoutMode:T,activeBlockStartLine:E,versioning:D,allowRecording:O,documentLinkProvider:A,linkSchemes:j,colorScheme:M,mediaRevision:N,bumpMediaRevision:P}=Lp(),F=Ng(),[I,L]=(0,G.useReducer)(e=>e+1,0),[ee,te]=(0,G.useState)(!1),[R,ne]=(0,G.useState)(!1),re=b?.editor??v,z=b?.level??null,ie=S===`code`,ae=!ie&&d!==`chat`,oe=VE.filter(e=>d===`chat`?e.id===`wysiwyg`:ie?e.id===`raw`:!(e.id===`preview`&&!c)),se=oe.length>1,[ce,le]=(0,G.useState)(0),B=n??ce;(0,G.useEffect)(()=>{if(n!==void 0)return;if(!x){le(0);return}let e=!1;return x.listMedia().then(t=>{e||le(xT(t).length)},()=>{e||le(0)}),()=>{e=!0}},[n,x,N,t]);let ue=(0,G.useRef)(null),[V,de]=(0,G.useState)(null),fe=(0,G.useRef)(null),[H,pe]=(0,G.useState)(null),me=(0,G.useCallback)(()=>{let e=fe.current;if(!e)return;let t=e.getBoundingClientRect(),n=window.innerWidth,r=window.innerHeight,i=t.left;i+$y+8>n&&(i=Math.max(8,n-$y-8));let a=t.bottom+6;if(a+eb+8>r){let e=t.top-eb-6;a=e>=8?e:8}pe({top:a,left:i})},[]),U=(0,G.useCallback)(()=>pe(null),[]),he=(0,G.useRef)(null),ge=(0,G.useRef)(null),_e=(0,G.useRef)(null),W=(0,G.useRef)(null),ve=(0,G.useRef)(null),ye=(0,G.useRef)(null),be=(0,G.useRef)(null),xe=(0,G.useRef)(null),[Ce,we]=(0,G.useState)(null),[Te,Ee]=(0,G.useState)(null),[De,Oe]=(0,G.useState)(null),[ke,Ae]=(0,G.useState)(null),je=(0,G.useCallback)(e=>{let t=e??he.current;if(!t)return;ge.current=e?_e.current:he.current;let n=t.getBoundingClientRect(),r=window.innerWidth,i=n.left;i+ZT+8>r&&(i=Math.max(8,n.right-ZT)),xe.current=n,we({top:n.bottom+4,left:i,placement:`down`}),Ee(null),Oe(null),Ae(null)},[]),Me=(0,G.useCallback)(e=>{let t=e.getBoundingClientRect(),n=window.innerWidth,r=window.innerHeight,i=t.right+4;i+QT+8>n&&(i=Math.max(8,t.left-QT-4));let a=Math.min(440,r-16),o=Math.max(8,Math.min(t.top,r-a-8));Ee({top:o,left:i}),Oe(null),Ae(null)},[]),Ne=(0,G.useCallback)(e=>{let t=e.getBoundingClientRect(),n=window.innerWidth,r=window.innerHeight,i=t.right+4;i+$T+8>n&&(i=Math.max(8,t.left-$T-4));let a=Math.min(600,r-16),o=Math.max(8,Math.min(t.top,r-a-8));Oe({top:o,left:i}),Ee(null),Ae(null)},[]),Pe=(0,G.useCallback)(e=>{let t=e.getBoundingClientRect(),n=window.innerWidth,r=window.innerHeight,i=t.right+4;i+eE+8>n&&(i=Math.max(8,t.left-eE-4));let a=Math.min(600,r-16),o=Math.max(8,Math.min(t.top,r-a-8));Ae({top:o,left:i}),Ee(null),Oe(null)},[]),Fe=(0,G.useCallback)(()=>{xe.current=null,we(null),Ee(null),Oe(null),Ae(null)},[]),Ie=(0,G.useRef)(null),[Le,Re]=(0,G.useState)(null),[ze,Be]=(0,G.useState)(``),[Ve,He]=(0,G.useState)(!1),Ue=(0,G.useRef)(null);Dh(Ve,()=>He(!1),_e),Dh(Ce!==null,Fe,ge);let[We,Ke]=(0,G.useState)(!1),[qe,Je]=(0,G.useState)(!1);(0,G.useEffect)(()=>{C&&(He(!1),Fe(),U())},[U,Fe,C]);let Ye=Le,Xe=new Set(ze?ze.split(`|`):[]);(0,G.useEffect)(()=>{let e=Ie.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect().right,n=e.querySelectorAll(`:scope > .squisq-toolbar-group:not(.squisq-toolbar-contextual) > .squisq-toolbar-button`),r=null;n.forEach(e=>{if(r===null&&e.getBoundingClientRect().right>t+2){let t=Number(e.dataset.btnIndex);r=Number.isNaN(t)?null:t}}),Re(r);let i=[];e.querySelectorAll(`:scope > .squisq-toolbar-contextual`).forEach(e=>{e.getBoundingClientRect().right>t+2&&i.push(e.dataset.contextual??``)}),Be(i.join(`|`))},n=typeof ResizeObserver>`u`?null:new ResizeObserver(t),r=()=>{n?.disconnect(),n?.observe(e),e.querySelectorAll(`:scope > .squisq-toolbar-group`).forEach(e=>n?.observe(e))},i=new MutationObserver(()=>{r(),t()});return i.observe(e,{childList:!0}),n||window.addEventListener(`resize`,t),r(),t(),()=>{n?.disconnect(),n||window.removeEventListener(`resize`,t),i.disconnect()}},[f]),(0,G.useEffect)(()=>{if(!Ve)return;let e=e=>{let t=e.target;Ue.current?.contains(t)||t instanceof Element&&t.closest(`${Uv}, #${Iy}`)||He(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[Ve]),(0,G.useEffect)(()=>{if(!Ce)return;let e=e=>{he.current?.contains(e.target)||W.current?.contains(e.target)||ve.current?.contains(e.target)||ye.current?.contains(e.target)||be.current?.contains(e.target)||Fe()};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[Ce,Fe]);let Ze=Ce!==null;(0,G.useLayoutEffect)(()=>{if(!Ze)return;let e=W.current,t=xe.current;if(!e||!t)return;let n=Math.max(0,window.innerHeight-t.bottom-4-8),r=Math.max(0,t.top-4-8),i=Math.max(e.scrollHeight,e.getBoundingClientRect().height),a=i>n&&r>n?`up`:`down`,o=a===`up`?r:n,s=Math.min(i,o),c=a===`up`?Math.max(8,t.top-4-s):t.bottom+4;we(e=>!e||e.top===c&&e.maxHeight===o&&e.placement===a?e:{...e,top:c,maxHeight:o,placement:a})},[Ze]);let[Qe,$e]=(0,G.useState)(`down`);(0,G.useEffect)(()=>{if(!Ve||!Ue.current)return;let e=Ue.current.querySelector(`.squisq-toolbar-overflow-trigger`);if(!e)return;let t=e.getBoundingClientRect(),n=window.innerHeight-t.bottom,r=t.top;$e(n<260&&r>n?`up`:`down`)},[Ve]);let[,et]=(0,G.useReducer)(e=>e+1,0);(0,G.useEffect)(()=>{if(re)return re.on(`transaction`,et),()=>{re.off(`transaction`,et)}},[re]);let tt=(0,G.useCallback)(e=>{let t=re;if(!t)return;let n=t.chain().focus();switch(e){case`bold`:n.toggleBold().run();break;case`italic`:n.toggleItalic().run();break;case`strikethrough`:n.toggleStrike().run();break;case`superscript`:n.toggleSuperscript().run();break;case`subscript`:n.toggleSubscript().run();break;case`code`:n.toggleCode().run();break;case`h1`:n.toggleHeading({level:1}).run();break;case`h2`:n.toggleHeading({level:2}).run();break;case`h3`:n.toggleHeading({level:3}).run();break;case`h4`:n.toggleHeading({level:4}).run();break;case`h5`:n.toggleHeading({level:5}).run();break;case`h6`:n.toggleHeading({level:6}).run();break;case`quote`:n.toggleBlockquote().run();break;case`ul`:n.toggleBulletList().run();break;case`ol`:n.toggleOrderedList().run();break;case`codeblock`:n.toggleCodeBlock().run();break;case`hr`:n.setHorizontalRule().run();break;case`link`:{let e=t.isActive(`link`),n=``,r=``;if(e){t.chain().focus().extendMarkRange(`link`).run();let e=t.state.selection;n=t.state.doc.textBetween(e.from,e.to,` `),r=t.getAttributes(`link`).href??``}else{let{from:e,to:r,empty:i}=t.state.selection;i||(n=t.state.doc.textBetween(e,r,` `))}de({mode:e?`update`:`insert`,target:`wysiwyg`,initialText:n,initialUrl:r,rawRange:null});break}case`table`:t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run();break;case`tasklist`:uE(t);break;case`chart`:AE(t,{template:LE.id,headingText:LE.headingText,table:LE.table});break;case`diagram`:yE(t);break;case`complexdiagram`:SE(t);break;case`tree`:TE(t);break;case`timeline`:OE(t);break;case`drawing`:jE(t,{template:`drawing`,text:`Drawing`});break;case`layout`:ME(t);break}},[re]),nt=(0,G.useCallback)(e=>{if(y){let t=y.getSelection(),n=y.getModel();if(!t||!n)return;let r=n.getValueInRange(t),i=r.length>0,a=``,o=0,s=(e,t,n)=>{i?a=e+r+t:(a=e+n+t,o=e.length)},c=(e,t)=>{i?a=r.split(`
|
|
420
|
+
`).map(t=>e+t).join(`
|
|
421
|
+
`):(a=e+t,o=e.length)};switch(e){case`bold`:s(`**`,`**`,`bold text`);break;case`italic`:s(`*`,`*`,`italic text`);break;case`strikethrough`:s(`~~`,`~~`,`strikethrough`);break;case`superscript`:s(`<sup>`,`</sup>`,`1`);break;case`subscript`:s(`<sub>`,`</sub>`,`2`);break;case`code`:s("`","`",`code`);break;case`h1`:c(`# `,`Heading 1`);break;case`h2`:c(`## `,`Heading 2`);break;case`h3`:c(`### `,`Heading 3`);break;case`h4`:c(`#### `,`Heading 4`);break;case`h5`:c(`##### `,`Heading 5`);break;case`h6`:c(`###### `,`Heading 6`);break;case`quote`:c(`> `,`Quote`);break;case`ul`:c(`- `,`Item`);break;case`ol`:c(`1. `,`Item`);break;case`codeblock`:a="```\n"+(i?r:`code`)+"\n```",i||(o=4);break;case`hr`:a=`
|
|
422
|
+
---
|
|
423
|
+
`;break;case`link`:{let e=t.startLineNumber,a=n.getLineContent(e),o=t.startColumn,s=/\[([^\]]*)\]\(([^)]*)\)/g,c,l=null;for(;(c=s.exec(a))!==null;){let t=c.index+1,n=t+c[0].length;if(o>=t&&o<=n){l={text:c[1],url:c[2],range:{startLineNumber:e,startColumn:t,endLineNumber:e,endColumn:n}};break}}de({mode:l?`update`:`insert`,target:`raw`,initialText:l?l.text:i?r:``,initialUrl:l?l.url:``,rawRange:l?l.range:null});return}case`table`:a=`
|
|
424
|
+
| Header 1 | Header 2 | Header 3 |
|
|
425
|
+
| --- | --- | --- |
|
|
426
|
+
| Cell | Cell | Cell |
|
|
427
|
+
| Cell | Cell | Cell |
|
|
428
|
+
`,o=3;break;case`tasklist`:a=`
|
|
429
|
+
${nE}
|
|
430
|
+
`,o=a.length;break;case`chart`:a=zE(LE),o=a.length;break;case`diagram`:a=vE,o=a.length;break;case`complexdiagram`:a=xE,o=a.length;break;case`tree`:a=wE,o=a.length;break;case`timeline`:a=DE,o=a.length;break;case`drawing`:a=`
|
|
431
|
+
## Drawing {[drawing]}
|
|
432
|
+
`,o=a.length;break;case`layout`:a=gE,o=a.length;break}let l=t;if(y.executeEdits(`toolbar`,[{range:l,text:a}]),!i&&o>0){let e=n.getPositionAt(n.getOffsetAt(l.getStartPosition())+o);y.setPosition(e),y.revealPositionInCenterIfOutsideViewport(e)}y.focus()}else{let t=``;switch(e){case`bold`:t=`**bold text**`;break;case`italic`:t=`*italic text*`;break;case`strikethrough`:t=`~~strikethrough~~`;break;case`superscript`:t=`<sup>1</sup>`;break;case`subscript`:t=`<sub>2</sub>`;break;case`code`:t="`code`";break;case`h1`:t=`
|
|
433
|
+
# Heading 1
|
|
434
|
+
`;break;case`h2`:t=`
|
|
435
|
+
## Heading 2
|
|
436
|
+
`;break;case`h3`:t=`
|
|
437
|
+
### Heading 3
|
|
438
|
+
`;break;case`quote`:t=`
|
|
439
|
+
> Quote
|
|
440
|
+
`;break;case`ul`:t=`
|
|
441
|
+
- Item
|
|
442
|
+
`;break;case`ol`:t=`
|
|
443
|
+
1. Item
|
|
444
|
+
`;break;case`codeblock`:t="\n```\ncode\n```\n";break;case`hr`:t=`
|
|
445
|
+
---
|
|
446
|
+
`;break;case`link`:t=`[link text](url)`;break;case`table`:t=`
|
|
447
|
+
| Header 1 | Header 2 | Header 3 |
|
|
448
|
+
| --- | --- | --- |
|
|
449
|
+
| Cell | Cell | Cell |
|
|
450
|
+
| Cell | Cell | Cell |
|
|
451
|
+
`;break;case`tasklist`:t=`
|
|
452
|
+
${nE}
|
|
453
|
+
`;break;case`chart`:t=zE(LE);break;case`diagram`:t=vE;break;case`complexdiagram`:t=xE;break;case`tree`:t=wE;break;case`timeline`:t=DE;break;case`drawing`:t=`
|
|
454
|
+
## Drawing {[drawing]}
|
|
455
|
+
`;break;case`layout`:t=gE;break}t&&_(m+t)}},[y,m,_]),rt=(0,G.useCallback)(e=>{if(f===`wysiwyg`&&v){kE(v,e.starter,e.fenceLanguage,{focusInsertedCodeSnippet:!0}),Fe();return}if(y){let t=y.getSelection(),n=y.getModel();if(!t||!n)return;let r=n.getValueInRange(t),i=r.length>0?r:e.starter,a=Eb(e.fenceLanguage,i);if(y.executeEdits(`toolbar-code-snippet`,[{range:t,text:a}]),r.length===0){let r=5+e.fenceLanguage.length+i.length,a=n.getPositionAt(n.getOffsetAt(t.getStartPosition())+r);y.setPosition(a),y.revealPositionInCenterIfOutsideViewport(a)}y.focus(),Fe();return}_(m+Eb(e.fenceLanguage,e.starter)),Fe()},[f,Fe,m,y,_,v]),it=(0,G.useCallback)(e=>{if(f===`wysiwyg`&&v){AE(v,{template:e.id,headingText:e.headingText,table:e.table}),Fe();return}let t=zE(e);if(y){let e=y.getSelection(),n=y.getModel();if(!e||!n)return;y.executeEdits(`toolbar-chart`,[{range:e,text:t}]);let r=n.getPositionAt(n.getOffsetAt(e.getStartPosition())+t.length);y.setPosition(r),y.revealPositionInCenterIfOutsideViewport(r),y.focus(),Fe();return}_(m+t),Fe()},[f,Fe,m,y,_,v]),ot=(0,G.useCallback)(e=>{if(f===`wysiwyg`&&v){SE(v,e.starter),Fe();return}let t=Ab(e.starter);if(y){let e=y.getSelection(),n=y.getModel();if(!e||!n)return;y.executeEdits(`toolbar-mermaid-diagram`,[{range:e,text:t}]);let r=n.getPositionAt(n.getOffsetAt(e.getStartPosition())+t.length);y.setPosition(r),y.revealPositionInCenterIfOutsideViewport(r),y.focus(),Fe();return}_(m+t),Fe()},[f,Fe,m,y,_,v]),st=(0,G.useCallback)(()=>{if(b)return``;if(f===`wysiwyg`&&v){let{from:e,to:t,empty:n}=v.state.selection;return n?``:v.state.doc.textBetween(e,t,`
|
|
456
|
+
`)}if(f===`raw`&&y){let e=y.getSelection(),t=y.getModel();return e&&t?t.getValueInRange(e):``}return``},[b,f,y,v]),ct=(0,G.useCallback)(e=>{let t=st();if(t.trim()){if(f===`wysiwyg`&&v){let n=e===`table`?cE(ET(t).rows):lE(kT(t));v.chain().focus().insertContentAt(dE(v),n).run();return}if(f===`raw`&&y){let n=y.getSelection();if(!n)return;let r=e===`table`?OT(t):AT(t);if(!r)return;let i=/^(?:\r?\n)/.test(t)?`
|
|
457
|
+
`:``,a=/(?:\r?\n)$/.test(t)?`
|
|
458
|
+
`:``;y.executeEdits(`toolbar-convert-selection`,[{range:n,text:i+r+a}]),y.focus()}}},[f,y,st,v]),lt=(0,G.useCallback)(async e=>{if(!x)return;let t=await e.arrayBuffer(),n=await x.addMedia(e.name,t,e.type);P();let r=e.name.replace(/\.[^.]+$/,``).replace(/[-_]/g,` `);if(f===`wysiwyg`&&v)v.chain().focus().setImage({src:n,alt:r}).run();else if(y){let e=y.getSelection(),t=y.getModel();if(e&&t){let t=``;y.executeEdits(`toolbar`,[{range:e,text:t}]),y.focus()}}else _(m+`
|
|
459
|
+

|
|
460
|
+
`)},[x,f,v,y,m,_,P]),ut=(0,G.useCallback)(e=>{if(e===`image`){ue.current?.click();return}if(e===`emoji`){H?U():me();return}b||f===`wysiwyg`&&v?tt(e):nt(e)},[f,v,b,tt,nt,H,me,U]),dt=(0,G.useCallback)(e=>{if(f===`wysiwyg`&&v)e.kind===`emoji`?v.chain().focus().insertContent(e.char).run():v.chain().focus().insertContent({type:`inlineIcon`,attrs:{token:e.token,family:e.family,name:e.name}}).run();else if(f===`raw`&&y){let t=e.kind===`emoji`?e.char:`{[${e.token}]}`,n=y.getPosition();if(n){let e={startLineNumber:n.lineNumber,startColumn:n.column,endLineNumber:n.lineNumber,endColumn:n.column};y.executeEdits(`picker-insert`,[{range:e,text:t}]),y.focus()}else _(m+t)}else{let t=e.kind===`emoji`?e.char:`{[${e.token}]}`;_(m+t)}U()},[f,v,y,m,_,U]);(0,G.useEffect)(()=>{let e=e=>{if(!(e.ctrlKey||e.metaKey)||e.altKey||e.shiftKey||e.key.toLowerCase()!==`k`)return;let t=e.target;t&&t.closest(`.squisq-wysiwyg-editor, .ProseMirror, .squisq-raw-editor-container, .monaco-editor`)&&(e.preventDefault(),e.stopPropagation(),ut(`link`))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[ut]);let ft=(0,G.useCallback)((e,t)=>{if(!V)return;let n=t.trim(),r=e.trim(),i=re;if(V.target===`wysiwyg`&&i){if(!n){V.mode===`update`&&i.chain().focus().unsetLink().run(),de(null);return}let e=r||n;i.chain().focus().insertContent({type:`text`,text:e,marks:[{type:`link`,attrs:{href:n}}]}).run(),de(null);return}if(V.target===`raw`&&y){if(!y.getModel()){de(null);return}if(!n&&V.mode===`update`&&V.rawRange){y.executeEdits(`toolbar-link-edit`,[{range:V.rawRange,text:r||V.initialText}]),y.focus(),de(null);return}if(!n){de(null);return}let e=`[${r||n}](${n})`,t=V.rawRange??y.getSelection();if(!t){de(null);return}y.executeEdits(`toolbar-link-edit`,[{range:t,text:e}]),y.focus(),de(null);return}de(null)},[V,re,y]),pt=[`format`,`lists`,`structure`,`insert`],mt=f===`wysiwyg`&&v,ht=f===`preview`,gt=!!b||mt,_t=new Set([`bold`,`italic`,`strikethrough`,`superscript`,`subscript`,`code`,`link`,`emoji`]),vt=new Set([..._t,`ul`,`ol`,`quote`,`codeblock`]),[yt,bt]=(0,G.useState)(!1);(0,G.useEffect)(()=>{let e=null,t=()=>{e!==null&&clearTimeout(e),e=setTimeout(()=>{e=null;let t=document.activeElement;!t||t===document.body||t===document.documentElement||bt(t.closest(`.squisq-data-card`)!=null)},0)};return document.addEventListener(`focusin`,t),document.addEventListener(`focusout`,t),()=>{e!==null&&clearTimeout(e),document.removeEventListener(`focusin`,t),document.removeEventListener(`focusout`,t)}},[]);let xt=e=>yt?!1:!z||z===`rich`?!0:z===`block`?vt.has(e):_t.has(e),St=Ce!==null&&st().trim().length>0&&XT.some(e=>xt(e.id)),Ct=(0,G.useMemo)(()=>{if(!m)return 0;let e=0,t=m.split(/\r\n|\r|\n/),n=Vb(m);for(let r=0;r<t.length;r++){if(n[r])continue;let i=t[r].trimEnd(),a=/^(#{1,6})\s+\S/.exec(i);a&&a[1].length>e&&(e=a[1].length)}return e},[m]),Tt=Math.min(6,Math.max(3,Ct+1)),Et=e=>{let t=/^h([1-6])$/.exec(e);return!t||Number(t[1])<=Tt},Dt=YT.some(e=>Et(e.id)),Ot=u&&Ye!==null&&Ye<=JT&&Dt,kt=mt?v.isActive(`table`):!1,At=mt&&v.isActive(`heading`)?v.getAttributes(`heading`)?.dataTemplate??``:null,Mt=f===`raw`,[Nt,Pt]=(0,G.useState)(null),[Ft,It]=(0,G.useState)(null),[Lt,Rt]=(0,G.useState)(py);(0,G.useEffect)(()=>{if(!Mt||!y){Pt(null),It(null),Rt(py);return}let e=()=>{let e=y.getModel(),t=y.getPosition();if(!e||!t){Pt(null),It(null),Rt(py);return}if(Hb(e.getValue(),t.lineNumber)){Pt(null),It(null),Rt(py);return}let n=e.getLineContent(t.lineNumber),r=n.match(/^#{1,6}\s+(.+)$/);if(!r){Pt(null),It(null),Rt(py);return}It(t.lineNumber),Rt(wy(n));let i=wt(r[1]);if(i){let e=jt(i.inner.trim()),t=e.length>0&&e[0].indexOf(`=`)>0;Pt(t?``:e[0]??``)}else Pt(``)};e();let t=y.onDidChangeCursorPosition(e),n=y.onDidChangeModelContent(e);return()=>{t.dispose(),n.dispose()}},[Mt,y]);let[zt,Bt]=(0,G.useState)(null);(0,G.useEffect)(()=>{if(!mt||!v){Bt(null);return}let e=()=>{if(!v.isActive(`heading`)){Bt(null);return}let e=v.state.selection.from,t=-1,n=0;v.state.doc.descendants((r,i)=>{if(r.type.name===`heading`){if(i<=e&&i+r.nodeSize>e)return t=n,!1;n++}}),Bt(t>=0?t:null)};return e(),v.on(`selectionUpdate`,e),v.on(`update`,e),()=>{v.off(`selectionUpdate`,e),v.off(`update`,e)}},[mt,v]);let Vt=mt?At:Mt?Nt:null,Ht=(0,G.useMemo)(()=>{if(Vt===null)return;let e=null;if(Mt&&Ft!==null?e=ox(m,Ft):mt&&zt!==null&&(e=sx(m,zt)),e!==null)return h(k(e),ey).recommended},[Vt,Mt,mt,Ft,zt,m]),Ut=(0,G.useMemo)(()=>{if(!g||Vt===null)return null;let e=Se(g.blocks);if(e.length===0)return null;if(Mt&&Ft!==null)return UE(e,Ft);if(mt){if(T!==`document`&&E!==null)return UE(e,E);if(zt!==null)return e[zt]??null}return null},[E,Vt,g,Mt,mt,T,Ft,zt]),Wt=(0,G.useMemo)(()=>Ut?{block:Ut,theme:F?.activeTheme??at,viewport:F?.activeViewport??Ge.landscape,basePath:`/`,mediaProvider:x,customTemplates:g?.customTemplates}:void 0,[x,g?.customTemplates,F?.activeTheme,F?.activeViewport,Ut]),Gt=e=>{if(Mt&&y){let t=y.getModel(),n=y.getPosition();if(!t||!n||Hb(t.getValue(),n.lineNumber))return;let r=n.lineNumber,i=t.getLineContent(r),a=i.match(/^(#{1,6}\s+)(.+)$/);if(!a)return;let o=a[1],{text:s,params:c}=WE(a[2]),l=GE(e,c),u=l?`${o}${s} ${l}`:`${o}${s}`;y.executeEdits(`toolbar-template-pick`,[{range:{startLineNumber:r,startColumn:1,endLineNumber:r,endColumn:i.length+1},text:u}]),y.focus();return}if(!v)return;let t=qE(v.getAttributes(`heading`).dataTemplateParams);e===``?v.chain().focus().updateAttributes(`heading`,{dataTemplate:null,dataTemplateParams:t}).run():v.chain().focus().updateAttributes(`heading`,{dataTemplate:e,dataTemplateParams:t}).run()},Kt=null;if(mt&&At!==null){let e=v.getAttributes(`heading`);Kt=Dy(e.dataBlockAttrs,e.dataTemplateParams)}else Mt&&Nt!==null&&(Kt=Lt);let qt=e=>{if(Mt&&y){let t=y.getModel(),n=y.getPosition();if(!t||!n||Hb(t.getValue(),n.lineNumber))return;let r=n.lineNumber,i=t.getLineContent(r),a=Ty(i,e);if(a===i)return;y.executeEdits(`toolbar-transition-pick`,[{range:{startLineNumber:r,startColumn:1,endLineNumber:r,endColumn:i.length+1},text:a}]),y.focus();return}if(!v)return;let t=v.getAttributes(`heading`),n=Oy(t.dataBlockAttrs,t.dataTemplateParams,e);v.chain().focus().updateAttributes(`heading`,{dataBlockAttrs:n.blockAttrsInner,dataTemplateParams:n.templateParams}).run()},Jt=l&&Vt!==null&&Xe.has(`template`),Yt=l&&Kt!==null&&Xe.has(`transition`),Xt=Jt||Yt,Zt=Vt?ty(Vt):`Heading`,Qt=!C&&!ht&&!ie&&(l&&(Ye!==null||Xe.size>0)||Ot);return(0,K.jsxs)(`div`,{className:`squisq-toolbar${C?` squisq-toolbar--find`:``} ${e||``}`,role:`toolbar`,"aria-label":C?`Find toolbar`:l?`Formatting toolbar`:`Editor toolbar`,children:[(0,K.jsx)(`input`,{ref:ue,type:`file`,accept:`image/*`,style:{display:`none`},onChange:e=>{let t=e.target.files?.[0];t&<(t),e.target.value=``}}),!C&&i,se&&(0,K.jsx)(`div`,{className:`squisq-toolbar-view-tabs`,role:`tablist`,"aria-label":`Editor view`,children:oe.map(e=>{let t=e.id===`preview`&&F?n_(F.activeDisplayMode):e.label,n=(0,K.jsxs)(`button`,{role:`tab`,"data-view":e.id,"aria-selected":f===e.id,className:`squisq-toolbar-view-tab${f===e.id?` squisq-toolbar-view-tab--active`:``}`,onClick:()=>{if(e.id===`preview`&&f===`preview`&&F){L();return}p(e.id)},"data-tooltip":`${t} (${KT(e.shortcutKey)})`,children:[(0,K.jsx)(`span`,{className:`squisq-toolbar-view-tab-label squisq-toolbar-view-tab-label--long`,"data-label":t,children:t}),e.shortLabel&&e.shortLabel!==e.label&&(0,K.jsx)(`span`,{className:`squisq-toolbar-view-tab-label squisq-toolbar-view-tab-label--short`,"data-label":e.shortLabel,children:e.shortLabel})]});return e.id!==`preview`||!F?(0,K.jsx)(`div`,{className:`squisq-toolbar-view-tab-wrap`,role:`presentation`,children:n},e.id):(0,K.jsxs)(`div`,{className:`squisq-toolbar-view-tab-wrap squisq-toolbar-use-tab${f===`preview`?` squisq-toolbar-use-tab--active`:``}`,role:`presentation`,children:[n,(0,K.jsx)(w_,{openRequest:I})]},e.id)})}),C?(0,K.jsx)(zT,{onClose:()=>w(!1)}):a,!C&&!ht&&!ie&&(l||u)&&(0,K.jsxs)(`div`,{className:`squisq-toolbar-actions`,ref:Ie,children:[l&&pt.map((e,t)=>(0,K.jsxs)(`div`,{className:`squisq-toolbar-group`,children:[t>0&&(0,K.jsx)(`div`,{className:`squisq-toolbar-separator`}),qT.filter(t=>t.group===e&&Et(t.id)).map(e=>{let t=e.id===`emoji`?H!==null:gt&&re?fE(re,e.id):!1,n=e.id===`image`&&!x||!xt(e.id),r=rE.get(e.id),i=Ye!==null&&r!==void 0&&r>=Ye;return(0,K.jsx)(`button`,{ref:e.id===`emoji`?fe:void 0,className:`squisq-toolbar-button${t?` squisq-toolbar-button--active`:``}${i?` squisq-toolbar-button--overflowed`:``}`,"data-btn-index":r,"data-tooltip":yt?`Formatting applies to document text — click into the prose first`:n?`Insert image (requires media provider)`:e.title,onClick:()=>ut(e.id),"aria-label":e.title,"aria-pressed":t,disabled:n,children:iE(e)},e.id)})]},e)),u&&(0,K.jsxs)(`div`,{className:`squisq-toolbar-group`,children:[l&&(0,K.jsx)(`div`,{className:`squisq-toolbar-separator`}),(0,K.jsx)(`button`,{ref:he,className:`squisq-toolbar-button${Ce?` squisq-toolbar-button--active`:``}${Ot?` squisq-toolbar-button--overflowed`:``}`,"data-btn-index":JT,"data-tooltip":yt?`Inserts land in document text — click into the prose first`:`Insert...`,onClick:()=>Ce?Fe():je(),"aria-label":`Insert`,"aria-expanded":Ce!==null,"aria-haspopup":`menu`,disabled:yt,children:(0,K.jsx)(q,{icon:`fa-solid fa-plus`})})]}),l&&Vt!==null&&(0,K.jsxs)(`div`,{className:`squisq-toolbar-group squisq-toolbar-contextual squisq-template-picker${Xe.has(`template`)?` squisq-toolbar-contextual--clipped`:``}`,"data-contextual":`template`,children:[(0,K.jsx)(`div`,{className:`squisq-toolbar-separator`}),(0,K.jsx)(ny,{value:Vt,onChange:Gt,colorScheme:M,recommended:Ht,previewSource:Wt})]}),l&&Kt!==null&&(0,K.jsxs)(`div`,{className:`squisq-toolbar-group squisq-toolbar-contextual squisq-transition-picker-group${Xe.has(`transition`)?` squisq-toolbar-contextual--clipped`:``}`,"data-contextual":`transition`,children:[(0,K.jsx)(`div`,{className:`squisq-toolbar-separator`}),(0,K.jsx)(Ry,{value:Kt,onChange:qt,colorScheme:M,accentColor:F?.activeTheme.colors.primary})]}),l&&kt&&(0,K.jsxs)(`div`,{className:`squisq-toolbar-group squisq-toolbar-contextual squisq-table-controls${Xe.has(`table`)?` squisq-toolbar-contextual--clipped`:``}`,"data-contextual":`table`,children:[(0,K.jsx)(`div`,{className:`squisq-toolbar-separator`}),(0,K.jsx)(`span`,{className:`squisq-table-controls-label`,children:`Table:`}),(0,K.jsx)(`button`,{className:`squisq-toolbar-button`,"data-tooltip":`Add column before`,onClick:()=>v.chain().focus().addColumnBefore().run(),"aria-label":`Add column before`,children:(0,K.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:[(0,K.jsx)(`rect`,{x:`7`,y:`2`,width:`8`,height:`12`,rx:`1`}),(0,K.jsx)(`line`,{x1:`11`,y1:`2`,x2:`11`,y2:`14`}),(0,K.jsx)(`line`,{x1:`1`,y1:`8`,x2:`4.5`,y2:`8`}),(0,K.jsx)(`line`,{x1:`2.75`,y1:`6.25`,x2:`2.75`,y2:`9.75`})]})}),(0,K.jsx)(`button`,{className:`squisq-toolbar-button`,"data-tooltip":`Add column after`,onClick:()=>v.chain().focus().addColumnAfter().run(),"aria-label":`Add column after`,children:(0,K.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:[(0,K.jsx)(`rect`,{x:`1`,y:`2`,width:`8`,height:`12`,rx:`1`}),(0,K.jsx)(`line`,{x1:`5`,y1:`2`,x2:`5`,y2:`14`}),(0,K.jsx)(`line`,{x1:`11.5`,y1:`8`,x2:`15`,y2:`8`}),(0,K.jsx)(`line`,{x1:`13.25`,y1:`6.25`,x2:`13.25`,y2:`9.75`})]})}),(0,K.jsx)(`button`,{className:`squisq-toolbar-button`,"data-tooltip":`Delete column`,onClick:()=>v.chain().focus().deleteColumn().run(),"aria-label":`Delete column`,children:(0,K.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:[(0,K.jsx)(`rect`,{x:`4`,y:`1`,width:`8`,height:`14`,rx:`1`}),(0,K.jsx)(`line`,{x1:`6`,y1:`5.5`,x2:`10`,y2:`10.5`}),(0,K.jsx)(`line`,{x1:`10`,y1:`5.5`,x2:`6`,y2:`10.5`})]})}),(0,K.jsx)(`button`,{className:`squisq-toolbar-button`,"data-tooltip":`Add row above`,onClick:()=>v.chain().focus().addRowBefore().run(),"aria-label":`Add row above`,children:(0,K.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:[(0,K.jsx)(`rect`,{x:`2`,y:`6`,width:`12`,height:`9`,rx:`1`}),(0,K.jsx)(`line`,{x1:`2`,y1:`10.5`,x2:`14`,y2:`10.5`}),(0,K.jsx)(`line`,{x1:`8`,y1:`1`,x2:`8`,y2:`4.5`}),(0,K.jsx)(`line`,{x1:`6.25`,y1:`2.75`,x2:`9.75`,y2:`2.75`})]})}),(0,K.jsx)(`button`,{className:`squisq-toolbar-button`,"data-tooltip":`Add row below`,onClick:()=>v.chain().focus().addRowAfter().run(),"aria-label":`Add row below`,children:(0,K.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:[(0,K.jsx)(`rect`,{x:`2`,y:`1`,width:`12`,height:`9`,rx:`1`}),(0,K.jsx)(`line`,{x1:`2`,y1:`5.5`,x2:`14`,y2:`5.5`}),(0,K.jsx)(`line`,{x1:`8`,y1:`11.5`,x2:`8`,y2:`15`}),(0,K.jsx)(`line`,{x1:`6.25`,y1:`13.25`,x2:`9.75`,y2:`13.25`})]})}),(0,K.jsx)(`button`,{className:`squisq-toolbar-button`,"data-tooltip":`Delete row`,onClick:()=>v.chain().focus().deleteRow().run(),"aria-label":`Delete row`,children:(0,K.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:[(0,K.jsx)(`rect`,{x:`1`,y:`4`,width:`14`,height:`8`,rx:`1`}),(0,K.jsx)(`line`,{x1:`5.5`,y1:`6`,x2:`10.5`,y2:`10`}),(0,K.jsx)(`line`,{x1:`10.5`,y1:`6`,x2:`5.5`,y2:`10`})]})}),(0,K.jsx)(`button`,{className:`squisq-toolbar-button squisq-toolbar-button--danger`,"data-tooltip":`Delete table`,onClick:()=>v.chain().focus().deleteTable().run(),"aria-label":`Delete table`,children:(0,K.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,children:[(0,K.jsx)(`rect`,{x:`1`,y:`1`,width:`14`,height:`14`,rx:`1`}),(0,K.jsx)(`line`,{x1:`1`,y1:`5.5`,x2:`15`,y2:`5.5`}),(0,K.jsx)(`line`,{x1:`5.5`,y1:`1`,x2:`5.5`,y2:`15`}),(0,K.jsx)(`line`,{x1:`4.5`,y1:`4.5`,x2:`11.5`,y2:`11.5`,strokeWidth:`2`}),(0,K.jsx)(`line`,{x1:`11.5`,y1:`4.5`,x2:`4.5`,y2:`11.5`,strokeWidth:`2`})]})})]})]}),!C&&!ht&&!ie&&!l&&!u&&(0,K.jsx)(`div`,{className:`squisq-toolbar-actions`}),Qt&&(0,K.jsxs)(`div`,{className:`squisq-toolbar-overflow`,ref:Ue,children:[(0,K.jsx)(`button`,{ref:_e,className:`squisq-toolbar-button squisq-toolbar-overflow-trigger${Ve?` squisq-toolbar-button--active`:``}`,"data-tooltip":`More actions`,onClick:()=>He(e=>!e),"aria-label":`More actions`,"aria-expanded":Ve,children:`···`}),Ve&&(0,K.jsxs)(`div`,{className:`squisq-toolbar-overflow-menu squisq-toolbar-overflow-menu--${Qe}`,children:[l&&qT.slice(Ye??qT.length).filter(e=>Et(e.id)).filter(e=>e.group!==`media`).map(e=>{let t=e.id===`emoji`?H!==null:gt&&re?fE(re,e.id):!1,n=e.id===`image`&&!x||!xt(e.id);return(0,K.jsxs)(`button`,{ref:e.id===`emoji`?fe:void 0,className:`squisq-toolbar-overflow-item${t?` squisq-toolbar-overflow-item--active`:``}`,onClick:()=>{ut(e.id),e.id!==`emoji`&&He(!1)},disabled:n,children:[(0,K.jsx)(`span`,{className:`squisq-toolbar-overflow-icon`,children:iE(e)}),(0,K.jsx)(`span`,{children:e.title})]},e.id)}),Ot&&(0,K.jsxs)(`button`,{className:`squisq-toolbar-overflow-item${Ce?` squisq-toolbar-overflow-item--active`:``}`,onClick:e=>{Ce?Fe():je(e.currentTarget),He(!1)},"aria-haspopup":`menu`,"aria-expanded":Ce!==null,children:[(0,K.jsx)(`span`,{className:`squisq-toolbar-overflow-icon`,children:(0,K.jsx)(q,{icon:`fa-solid fa-plus`})}),(0,K.jsx)(`span`,{children:`Insert...`})]}),Xt&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`squisq-toolbar-separator`,style:{margin:`4px 0`,width:`100%`,height:1}}),(0,K.jsxs)(`div`,{className:`squisq-toolbar-overflow-heading`,children:[Zt,` Block:`]})]}),Jt&&(0,K.jsx)(`div`,{className:`squisq-toolbar-overflow-item squisq-toolbar-overflow-template`,children:(0,K.jsx)(ny,{value:Vt,onChange:e=>{Gt(e),He(!1)},colorScheme:M,recommended:Ht,previewSource:Wt})}),Yt&&(0,K.jsx)(`div`,{className:`squisq-toolbar-overflow-item squisq-toolbar-overflow-template`,children:(0,K.jsx)(Ry,{value:Kt,onChange:qt,colorScheme:M,accentColor:F?.activeTheme.colors.primary})}),l&&kt&&Xe.has(`table`)&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`squisq-toolbar-separator`,style:{margin:`4px 0`,width:`100%`,height:1}}),[{label:`Add column before`,action:()=>v.chain().focus().addColumnBefore().run()},{label:`Add column after`,action:()=>v.chain().focus().addColumnAfter().run()},{label:`Delete column`,action:()=>v.chain().focus().deleteColumn().run()},{label:`Add row above`,action:()=>v.chain().focus().addRowBefore().run()},{label:`Add row below`,action:()=>v.chain().focus().addRowAfter().run()},{label:`Delete row`,action:()=>v.chain().focus().deleteRow().run()},{label:`Delete table`,action:()=>v.chain().focus().deleteTable().run()}].map(e=>(0,K.jsx)(`button`,{className:`squisq-toolbar-overflow-item${e.label.startsWith(`Delete`)?` squisq-toolbar-overflow-item--danger`:``}`,onClick:()=>{e.action(),He(!1)},children:(0,K.jsx)(`span`,{children:e.label})},e.label))]})]})]}),!C&&o,ie&&!C&&(0,K.jsx)(`div`,{style:{flex:1}}),D&&!ie&&(0,K.jsx)(Nh,{}),O&&!ie&&x&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ix,{open:ee,onOpenChange:te,showTrigger:!1}),(0,K.jsx)(ix,{open:R,onOpenChange:ne,showTrigger:!1,mode:`document-narration`})]}),ae&&(0,K.jsx)(`button`,{type:`button`,className:`squisq-toolbar-button${qe?` squisq-toolbar-button--active`:``}`,onClick:()=>Je(!0),"data-tooltip":`Custom layouts`,"aria-label":`Custom layouts`,children:(0,K.jsx)(q,{icon:`fa-solid fa-shapes`})}),ae&&f===`raw`&&(0,K.jsx)(fv,{}),ae&&(0,K.jsx)(sv,{}),ae&&(0,K.jsx)(`button`,{type:`button`,className:`squisq-toolbar-button`,onClick:()=>Ke(!0),"data-tooltip":`Document settings`,"aria-label":`Document settings`,children:(0,K.jsx)(q,{icon:`fa-solid fa-file-lines`})}),r&&(0,K.jsxs)(`button`,{className:`squisq-toolbar-button squisq-toolbar-files-toggle${t?` squisq-toolbar-button--active`:``}`,onClick:r,"data-tooltip":`${t?`Hide`:`Show`} Files panel${B>0?` (${aE(B)})`:``}`,"aria-pressed":t,"aria-label":`Toggle Files panel${B>0?`, ${aE(B)}`:``}`,children:[(0,K.jsx)(q,{icon:`fa-solid fa-paperclip`}),B>0&&(0,K.jsx)(`span`,{className:`squisq-toolbar-files-badge`,"aria-hidden":`true`,children:oE(B)})]}),s,ae&&We&&(0,K.jsx)(Gy,{markdownSource:m,onSave:e=>{_(e),Ke(!1)},onClose:()=>Ke(!1)}),ae&&qe&&(0,K.jsx)(hT,{onClose:()=>Je(!1)}),V&&(0,K.jsx)(lx,{mode:V.mode,initialText:V.initialText,initialUrl:V.initialUrl,onConfirm:ft,onClose:()=>de(null),documentLinkProvider:A,linkSchemes:j}),Ce&&(0,Wr.createPortal)((0,K.jsxs)(`div`,{ref:W,className:`squisq-insert-menu`,"data-theme":M,"data-placement":Ce.placement,style:{position:`fixed`,top:Ce.top,left:Ce.left,maxHeight:Ce.maxHeight},role:`menu`,children:[St&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`squisq-insert-menu-header`,children:`Convert`}),XT.map(e=>{let t=e.id===`table`?`Table`:`Task List`;return(0,K.jsxs)(`button`,{className:`squisq-toolbar-overflow-item`,disabled:!xt(e.id),onClick:()=>{ct(e.id),Fe()},role:`menuitem`,"aria-label":`Convert selection to ${t}`,children:[(0,K.jsx)(`span`,{className:`squisq-toolbar-overflow-icon`,children:iE(e)}),(0,K.jsx)(`span`,{children:t})]},`convert-${e.id}`)})]}),(0,K.jsx)(`div`,{className:`squisq-insert-menu-header${St?` squisq-insert-menu-header--separated`:``}`,children:`Insert`}),YT.filter(e=>Et(e.id)).map(e=>{let t=e.id===`image`&&!x||!xt(e.id),n=e.title.replace(/^Insert\s+/i,``),r=n.charAt(0).toUpperCase()+n.slice(1),i=e.id===`complexdiagram`,a=e.id===`chart`,o=i||a,s=i?De!==null:ke!==null;return(0,K.jsxs)(`button`,{ref:e.id===`emoji`?fe:void 0,className:`squisq-toolbar-overflow-item`,disabled:t,onClick:t=>{if(i){De?Oe(null):Ne(t.currentTarget);return}if(a){ke?Ae(null):Pe(t.currentTarget);return}ut(e.id),e.id!==`emoji`&&Fe()},role:`menuitem`,"aria-haspopup":o?`menu`:void 0,"aria-expanded":o?s:void 0,children:[(0,K.jsx)(`span`,{className:`squisq-toolbar-overflow-icon`,children:iE(e)}),(0,K.jsx)(`span`,{children:r}),o&&(0,K.jsx)(q,{icon:`fa-solid fa-chevron-right`})]},e.id)}),O&&x&&(0,K.jsxs)(`button`,{type:`button`,className:`squisq-toolbar-overflow-item`,onClick:()=>{te(!0),Fe()},role:`menuitem`,"aria-label":`Record media`,children:[(0,K.jsx)(`span`,{className:`squisq-toolbar-overflow-icon`,children:(0,K.jsx)(q,{icon:`fa-solid fa-microphone`})}),(0,K.jsx)(`span`,{children:`Record media`})]}),O&&x&&(0,K.jsxs)(`button`,{type:`button`,className:`squisq-toolbar-overflow-item`,onClick:()=>{ne(!0),Fe()},role:`menuitem`,"aria-label":`Document narration`,children:[(0,K.jsx)(`span`,{className:`squisq-toolbar-overflow-icon`,children:(0,K.jsx)(q,{icon:`fa-solid fa-comment-dots`})}),(0,K.jsx)(`span`,{children:`Document narration`})]}),(0,K.jsxs)(`button`,{className:`squisq-toolbar-overflow-item`,onClick:e=>{Te?Ee(null):Me(e.currentTarget)},role:`menuitem`,"aria-label":`Insert Code Snippet`,"aria-haspopup":`menu`,"aria-expanded":Te!==null,children:[(0,K.jsx)(`span`,{className:`squisq-toolbar-overflow-icon`,children:(0,K.jsx)(q,{icon:`fa-solid fa-file-code`})}),(0,K.jsx)(`span`,{children:`Code Snippet`}),(0,K.jsx)(q,{icon:`fa-solid fa-chevron-right`})]})]}),document.body),De&&(0,Wr.createPortal)((0,K.jsxs)(`div`,{ref:ye,className:`squisq-insert-menu squisq-mermaid-type-menu`,"data-theme":M,style:{position:`fixed`,top:De.top,left:De.left},role:`menu`,"aria-label":`Mermaid diagram type`,children:[(0,K.jsxs)(`div`,{className:`squisq-mermaid-type-menu-heading`,children:[(0,K.jsx)(`strong`,{children:`Complex Diagram`}),(0,K.jsx)(`span`,{children:`Choose a Mermaid diagram type. Flow direction remains a separate edit.`})]}),[`Structure`,`Planning`,`Data`].map(e=>(0,K.jsxs)(`section`,{className:`squisq-mermaid-type-section`,children:[(0,K.jsx)(`div`,{className:`squisq-insert-menu-header`,children:e}),(0,K.jsx)(`div`,{className:`squisq-mermaid-type-grid`,children:Ob.filter(t=>t.category===e).map(e=>(0,K.jsxs)(`button`,{type:`button`,className:`squisq-mermaid-type-card`,onClick:()=>ot(e),role:`menuitem`,"aria-label":`Insert ${e.label} Mermaid diagram`,children:[(0,K.jsx)(`span`,{className:`squisq-mermaid-type-thumbnail`,children:(0,K.jsx)(jb,{preview:e.preview})}),(0,K.jsxs)(`span`,{className:`squisq-mermaid-type-copy`,children:[(0,K.jsxs)(`span`,{className:`squisq-mermaid-type-title`,children:[e.label,e.badge&&(0,K.jsx)(`span`,{className:`squisq-mermaid-type-badge`,children:e.badge})]}),(0,K.jsx)(`span`,{className:`squisq-mermaid-type-description`,children:e.description})]})]},e.id))})]},e))]}),document.body),ke&&(0,Wr.createPortal)((0,K.jsxs)(`div`,{ref:be,className:`squisq-insert-menu squisq-mermaid-type-menu squisq-chart-type-menu`,"data-theme":M,style:{position:`fixed`,top:ke.top,left:ke.left,width:eE},role:`menu`,"aria-label":`Chart type`,children:[(0,K.jsxs)(`div`,{className:`squisq-mermaid-type-menu-heading`,children:[(0,K.jsx)(`strong`,{children:`Chart`}),(0,K.jsx)(`span`,{children:`Choose a chart type. The starter table becomes the chart's data — edit it to update the chart.`})]}),(0,K.jsx)(`section`,{className:`squisq-mermaid-type-section`,children:(0,K.jsx)(`div`,{className:`squisq-mermaid-type-grid`,children:IE.map(e=>(0,K.jsxs)(`button`,{type:`button`,className:`squisq-mermaid-type-card`,onClick:()=>it(e),role:`menuitem`,"aria-label":`Insert ${e.label} chart`,children:[(0,K.jsx)(`span`,{className:`squisq-mermaid-type-thumbnail`,children:(0,K.jsx)(BE,{preview:e.preview})}),(0,K.jsxs)(`span`,{className:`squisq-mermaid-type-copy`,children:[(0,K.jsx)(`span`,{className:`squisq-mermaid-type-title`,children:e.label}),(0,K.jsx)(`span`,{className:`squisq-mermaid-type-description`,children:e.description})]})]},e.id))})})]}),document.body),Te&&(0,Wr.createPortal)((0,K.jsxs)(`div`,{ref:ve,className:`squisq-insert-menu squisq-code-snippet-menu`,"data-theme":M,style:{position:`fixed`,top:Te.top,left:Te.left},role:`menu`,"aria-label":`Code snippet language`,children:[(0,K.jsx)(`div`,{className:`squisq-insert-menu-header`,children:`Code Snippet`}),(0,K.jsxs)(`button`,{className:`squisq-toolbar-overflow-item squisq-code-snippet-language`,onClick:()=>{ut(`codeblock`),Fe()},role:`menuitem`,"aria-label":`Insert Generic Code`,disabled:!xt(`codeblock`),children:[(0,K.jsx)(`span`,{children:`Generic Code`}),(0,K.jsx)(`code`,{children:`plain`})]}),vb.map(e=>(0,K.jsxs)(`button`,{className:`squisq-toolbar-overflow-item squisq-code-snippet-language`,onClick:()=>rt(e),role:`menuitem`,"aria-label":`Insert ${e.label} code snippet`,children:[(0,K.jsx)(`span`,{children:e.label}),(0,K.jsx)(`code`,{children:e.fenceLanguage})]},e.fenceLanguage))]}),document.body),H&&(0,Wr.createPortal)((0,K.jsx)(nb,{open:!0,onSelect:dt,onClose:U,anchorRef:fe,theme:M===`dark`?`dark`:`light`,style:{position:`fixed`,top:H.top,left:H.left}}),document.body)]})}var YE=150;function XE({className:e,slotRight:t}){let{markdownSource:n,doc:r,parseError:i}=Lp(),a=av(),[o,s]=(0,G.useState)(n);(0,G.useEffect)(()=>{if(o===n)return;let e=setTimeout(()=>s(n),YE);return()=>clearTimeout(e)},[n,o]);let c=(0,G.useMemo)(()=>({chars:o.length,words:o.trim()?o.trim().split(/\s+/).length:0,lines:o.split(`
|
|
461
|
+
`).length}),[o]),l=(0,G.useMemo)(()=>r?ee(r.blocks):0,[r]);return(0,K.jsxs)(`div`,{className:`squisq-status-bar ${e||``}`,children:[(0,K.jsxs)(`span`,{className:`squisq-status-item`,children:[c.words,` words`]}),(0,K.jsxs)(`span`,{className:`squisq-status-item`,children:[c.chars,` chars`]}),(0,K.jsxs)(`span`,{className:`squisq-status-item`,children:[c.lines,` lines`]}),(0,K.jsxs)(`span`,{className:`squisq-status-item`,children:[l,` `,l===1?`block`:`blocks`]}),a&&a.enabled&&(0,K.jsxs)(`button`,{type:`button`,className:`squisq-status-item squisq-proof-status${a.status===`error`?` squisq-proof-status--error`:``}`,title:a.status===`error`?`Proofing failed: ${a.errorMessage??`unknown error`} \u2014 click to retry`:`Toggle the proofing panel`,onClick:()=>{a.status===`error`?a.retrySetup():a.setPanelVisible(!a.panelVisible)},children:[a.status===`loading`&&`Proofing…`,a.status===`error`&&`⚠ Proofing`,a.status===`ready`&&(a.findings.length>0?`${a.findings.length} ${a.findings.length===1?`issue`:`issues`}`:`✓ Proofing`),a.status===`idle`&&`Proofing`]}),(0,K.jsx)(`span`,{className:`squisq-status-spacer`}),i&&(0,K.jsx)(`span`,{className:`squisq-status-item squisq-status-error`,title:i,children:`⚠ Error`}),!i&&(0,K.jsx)(`span`,{className:`squisq-status-item squisq-status-ok`,children:`✓ OK`}),t]})}var ZE=(0,G.createContext)(null),QE={"data-editor-context-menu":`own`},$E=`[data-editor-context-menu="own"]`;function eD(){return(0,G.useContext)(ZE)!==null}function tD(e){let t=(0,G.useContext)(ZE),n=(0,G.useRef)(e);if(n.current=e,!t)throw Error(`useEditorContextMenuItems must be used within an <EditorShell>`);(0,G.useEffect)(()=>t.register(()=>n.current),[t])}function nD(e){let t=window.getSelection();return!t||t.isCollapsed||!t.anchorNode||!t.focusNode||!e.contains(t.anchorNode)||!e.contains(t.focusNode)?``:t.toString()}function rD(e,t,n){let r=e.getOffsetAt(n),i=e.getOffsetAt(t.getStartPosition()),a=e.getOffsetAt(t.getEndPosition());return r>=i&&r<=a}function iD(e){e.dispatchEvent(new Event(`input`,{bubbles:!0}))}async function aD(e){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}let t=document.activeElement instanceof HTMLElement?document.activeElement:null,n=window.getSelection(),r=[];if(n)for(let e=0;e<n.rangeCount;e+=1)r.push(n.getRangeAt(e).cloneRange());let i=document.createElement(`textarea`);i.value=e,i.setAttribute(`readonly`,``),i.style.position=`fixed`,i.style.opacity=`0`,document.body.append(i),i.select();let a=document.execCommand?.(`copy`)??!1;if(i.remove(),n&&(n.removeAllRanges(),r.forEach(e=>n.addRange(e))),t?.focus({preventScroll:!0}),!a)throw Error(`Clipboard access is unavailable.`)}async function oD(){if(!navigator.clipboard?.readText)throw Error(`Clipboard access is unavailable.`);return navigator.clipboard.readText()}function sD(e,t){return typeof e.when==`function`?e.when(t):e.when===`selection`?t.hasSelection:e.when!==`location`||!t.hasSelection}function cD(e,t){return typeof e.disabled==`function`?e.disabled(t):!!e.disabled}function lD(){return/Mac|iPhone|iPad/.test(navigator.platform)?`⌘`:`Ctrl+`}function uD(e,t){let n=t?.getBoundingClientRect(),r=n?.width??220,i=n?.height??150,a=e.y+4;a+i+8>window.innerHeight&&e.y-i-4>=8&&(a=e.y-i-4);let o=Math.min(Math.max(8,e.x),Math.max(8,window.innerWidth-r-8));return{position:`fixed`,top:a,left:o,zIndex:9999}}function dD({rootRef:e,readOnly:t=!1,children:n}){let{activeView:r,editorMode:i,colorScheme:a,monacoEditor:o,tiptapEditor:s}=Lp(),c=(0,G.useRef)(new Set),l=(0,G.useRef)(null),[u,d]=(0,G.useState)(null),[f,p]=(0,G.useState)({}),m=(0,G.useCallback)(e=>(c.current.add(e),()=>c.current.delete(e)),[]),h=(0,G.useMemo)(()=>({register:m}),[m]),g=(0,G.useCallback)((n,a,c)=>{let l=n.closest(`.squisq-editor-content`);if(!l||!e.current?.contains(l)||i===`image`||n.closest($E))return null;let u=!t&&r!==`preview`,d=``,f=async()=>void 0,p=async()=>void 0,m=()=>void 0,h=o?.getDomNode();if(o&&h?.contains(n)){let e=o.getModel(),t=o.getSelection(),n=o.getTargetAtClientPoint(a,c)?.position;e&&t&&n&&(t.isEmpty()||!rD(e,t,n))&&(o.setPosition(n),t=o.getSelection()),e&&t&&!t.isEmpty()&&(d=e.getValueInRange(t));let r=t;m=()=>o.focus(),f=async()=>{!e||!r||r.isEmpty()||(o.executeEdits(`squisq-context-menu`,[{range:r,text:``,forceMoveMarkers:!0}]),o.focus())},p=async t=>{if(!e||!r)return;let n=e.getOffsetAt(r.getStartPosition());o.executeEdits(`squisq-context-menu`,[{range:r,text:t,forceMoveMarkers:!0}]);let i=e.getPositionAt(n+t.length);o.setPosition(i),o.focus()}}else if(s&&s.view.dom.contains(n)){let e=s.view.posAtCoords({left:a,top:c}),{from:t,to:n,empty:r}=s.state.selection;e&&(!r&&(e.pos<t||e.pos>n)||r)&&(s.commands.setTextSelection(e.pos),{from:t,to:n,empty:r}=s.state.selection),r||(d=s.state.doc.textBetween(t,n,`
|
|
462
|
+
`)),m=()=>s.commands.focus(),f=async()=>{s.chain().focus().setTextSelection({from:t,to:n}).deleteSelection().run()},p=async e=>{s.chain().focus().setTextSelection({from:t,to:n}).command(({tr:r})=>(r.insertText(e,t,n),!0)).run()}}else if(n instanceof HTMLTextAreaElement||n instanceof HTMLInputElement){let e=n.selectionStart??0,t=n.selectionEnd??e;d=n.value.slice(e,t),m=()=>n.focus({preventScroll:!0}),f=async()=>{n.setRangeText(``,e,t,`end`),iD(n),m()},p=async r=>{n.setRangeText(r,e,t,`end`),iD(n),m()}}else d=nD(l);return{context:{view:r,selectedText:d,hasSelection:d.length>0,editable:u,clientX:a,clientY:c,target:n},copy:()=>aD(d),cut:async()=>{await aD(d),await f()},paste:async()=>{try{await p(await oD())}catch(e){if(m(),document.execCommand?.(`paste`))return;throw e}}}},[r,i,o,t,e,s]),_=(0,G.useCallback)((e,t,n)=>{let r=g(e,t,n);if(!r)return!1;let{context:i}=r,a=lD(),o=[{id:`squisq.cut`,label:`Cut`,shortcut:`${a}X`,group:`clipboard`,disabled:!i.editable||!i.hasSelection,onSelect:r.cut},{id:`squisq.copy`,label:`Copy`,shortcut:`${a}C`,group:`clipboard`,disabled:!i.hasSelection,onSelect:r.copy},{id:`squisq.paste`,label:`Paste`,shortcut:`${a}V`,group:`clipboard`,disabled:!i.editable,onSelect:r.paste}],s=Array.from(c.current).flatMap(e=>e()),l=[...o,...s].filter(e=>sD(e,i)).map(e=>({item:e,disabled:cD(e,i)}));if(!l.some(e=>!e.disabled))return!1;let u={context:i,items:l,x:t,y:n,error:null};return p(uD(u)),d(u),!0},[g]);(0,G.useEffect)(()=>{let t=e.current;if(!t)return;let n=e=>{e.defaultPrevented||!(e.target instanceof Element)||_(e.target,e.clientX,e.clientY)&&(e.preventDefault(),e.stopPropagation())},r=e=>{if(e.defaultPrevented||e.key!==`ContextMenu`&&!(e.shiftKey&&e.key===`F10`)||!(e.target instanceof Element))return;let t=e.target.getBoundingClientRect();_(e.target,t.left+12,t.top+20)&&(e.preventDefault(),e.stopPropagation())};return t.addEventListener(`contextmenu`,n),t.addEventListener(`keydown`,r),()=>{t.removeEventListener(`contextmenu`,n),t.removeEventListener(`keydown`,r)}},[_,e]),(0,G.useEffect)(()=>{if(!u)return;let e=requestAnimationFrame(()=>{p(uD(u,l.current)),l.current?.querySelector(`[role="menuitem"]:not(:disabled)`)?.focus()}),t=e=>{e.target instanceof Node&&l.current?.contains(e.target)||d(null)},n=e=>{e.key===`Escape`&&(e.preventDefault(),d(null))};return document.addEventListener(`pointerdown`,t,!0),window.addEventListener(`scroll`,t,!0),window.addEventListener(`resize`,t),window.addEventListener(`keydown`,n),()=>{cancelAnimationFrame(e),document.removeEventListener(`pointerdown`,t,!0),window.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,t),window.removeEventListener(`keydown`,n)}},[u]);let v=(0,G.useCallback)(async e=>{if(!(!u||e.disabled))try{await e.item.onSelect(u.context),d(null)}catch(e){d(t=>t?{...t,error:e instanceof Error?e.message:`The action could not be completed.`}:null)}},[u]),y=(0,G.useCallback)(e=>{let t=Array.from(e.currentTarget.querySelectorAll(`[role="menuitem"]:not(:disabled)`));if(t.length===0)return;let n=t.indexOf(document.activeElement),r=n;if(e.key===`ArrowDown`)r=(n+1)%t.length;else if(e.key===`ArrowUp`)r=(n-1+t.length)%t.length;else if(e.key===`Home`)r=0;else if(e.key===`End`)r=t.length-1;else return;e.preventDefault(),t[r]?.focus()},[]);return(0,K.jsxs)(ZE.Provider,{value:h,children:[n,u&&(0,Wr.createPortal)((0,K.jsxs)(`div`,{ref:l,className:`squisq-editor-context-menu`,"data-theme":a,role:`menu`,"aria-label":`Editor actions`,style:f,onKeyDown:y,children:[u.items.map((e,t)=>{let n=e.item.group??`host`,r=t>0?u.items[t-1]?.item.group??`host`:n;return(0,K.jsxs)(`div`,{children:[t>0&&n!==r&&(0,K.jsx)(`div`,{className:`squisq-editor-context-menu-separator`,role:`separator`}),(0,K.jsxs)(`button`,{type:`button`,role:`menuitem`,disabled:e.disabled,className:`squisq-editor-context-menu-item`,onMouseDown:e=>e.preventDefault(),onClick:()=>void v(e),children:[e.item.icon&&(0,K.jsx)(`span`,{className:`squisq-editor-context-menu-icon`,"aria-hidden":`true`,children:e.item.icon}),(0,K.jsx)(`span`,{className:`squisq-editor-context-menu-label`,children:e.item.label}),e.item.shortcut&&(0,K.jsx)(`span`,{className:`squisq-editor-context-menu-shortcut`,"aria-hidden":`true`,children:e.item.shortcut})]})]},`${n}:${e.item.id}`)}),u.error&&(0,K.jsx)(`div`,{className:`squisq-editor-context-menu-error`,role:`alert`,children:u.error})]}),document.body)]})}var fD=`application/x-squisq-media`;function pD(e){try{let t=JSON.parse(e);if(typeof t.name==`string`&&typeof t.mimeType==`string`&&typeof t.alt==`string`)return t}catch{}return null}function mD(e){let t=e.toLowerCase();return t.startsWith(`image/`)?`image`:t.startsWith(`video/`)?`video`:t.startsWith(`audio/`)?`audio`:`file`}function hD(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`)}function gD(e){switch(mD(e.mimeType)){case`image`:return``;case`video`:return`<video src="${hD(e.name)}" controls width="480"></video>`;case`audio`:return`<audio src="${hD(e.name)}" controls></audio>`;default:return`[${e.alt}](${e.name})`}}var _D=new WeakMap;function vD(e){let t=e.getVersionId(),n=_D.get(e);if(n?.versionId===t)return n.mask;let r=Vb(e.getValue());return _D.set(e,{versionId:t,mask:r}),r}function yD(e,t){return!Number.isInteger(t)||t<1?!1:vD(e)[t-1]??!1}function bD(e,t){return e.getModel()===t}function xD(e,t){return!e&&!!t?.types.includes(fD)}var SD=`#dcd8d0`,CD=`#0f1219`,wD=`#b0a99a`,TD=`#2a3144`,ED={vs:`squisq-light`,"vs-dark":`squisq-dark`};function DD(e,t){let[n,r]=(0,G.useState)(()=>Qn(e,t));return(0,G.useEffect)(()=>{let n=$n(e)===`markdown`?250:0,i=window.setTimeout(()=>{r(Qn(e,t))},n);return()=>window.clearTimeout(i)},[e,t]),n}function OD({monacoTheme:e=`vs`,minimap:t=!1,fontSize:n=14,wordWrap:r=`on`,className:i,submitOnEnter:a,readOnly:o=!1}){let s=eD(),{editorSource:c,setEditorSource:l,setMonacoEditor:u,language:d,mentionProvider:f,doc:p}=Lp(),{monaco:m,ready:h}=Th(DD(d,c),{languageServices:![`markdown`,`plaintext`].includes($n(d))}),g=(0,G.useRef)(null),_=(0,G.useRef)(null),v=(0,G.useRef)(!1),y=(0,G.useRef)(null),b=(0,G.useRef)(null),x=(0,G.useRef)(null),S=(0,G.useRef)(null),C=(0,G.useRef)(null),w=(0,G.useRef)(null),T=(0,G.useRef)(null),E=(0,G.useRef)(a),D=(0,G.useRef)(o);(0,G.useEffect)(()=>{E.current=a},[a]),(0,G.useEffect)(()=>{D.current=o},[o]);let O=(0,G.useRef)(f);(0,G.useEffect)(()=>{O.current=f},[f]);let k=p?.customTemplates,A=(0,G.useRef)(null);A.current===null&&(A.current=oe().map(e=>({name:e,detail:`Block template`}))),(0,G.useEffect)(()=>{let e=oe().map(e=>({name:e,detail:`Block template`})),t=new Set(e.map(e=>e.name)),n=(k??[]).filter(e=>!t.has(e.name)).map(e=>({name:e.name,detail:e.label?`Custom \u2014 ${e.label}`:`Custom template`}));A.current=[...e,...n]},[k]);let j=(0,G.useCallback)(e=>{e.editor.defineTheme(`squisq-light`,{base:`vs`,inherit:!0,rules:[],colors:{"editorGutter.background":SD,"editorOverviewRuler.background":SD,"editorOverviewRuler.border":wD,"minimap.background":SD}}),e.editor.defineTheme(`squisq-dark`,{base:`vs-dark`,inherit:!0,rules:[],colors:{"editorGutter.background":CD,"editorOverviewRuler.background":CD,"editorOverviewRuler.border":TD,"minimap.background":CD}})},[]),M=(0,G.useCallback)((e,t)=>{g.current=e,u(e);let n=_.current,r=e.getModel();if(n&&r){let t=r.getPositionAt(n.start),i=r.getPositionAt(n.end);e.setSelection({startLineNumber:t.lineNumber,startColumn:t.column,endLineNumber:i.lineNumber,endColumn:i.column}),_.current=null}e.focus(),y.current?.dispose(),y.current=null,b.current?.dispose(),b.current=null,x.current?.dispose(),x.current=null,S.current?.dispose(),S.current=null,d===`markdown`&&(y.current=t.languages.registerCompletionItemProvider(`markdown`,{triggerCharacters:[`[`],provideCompletionItems(n,r){if(!bD(e,n)||yD(n,r.lineNumber))return{suggestions:[]};let i=n.getLineContent(r.lineNumber);if(!/^#{1,6}\s/.test(i))return{suggestions:[]};let a=i.substring(0,r.column-1),o=i.substring(r.column-1),s=a.lastIndexOf(`{[`);if(s===-1||/\s/.test(a.slice(s+2)))return{suggestions:[]};let c=o.match(/^\]\}/)?``:`]}`,l=s+3,u=new t.Range(r.lineNumber,l,r.lineNumber,r.column);return{suggestions:(A.current??[]).map(({name:e,detail:n})=>({label:e,filterText:e,kind:t.languages.CompletionItemKind.Value,insertText:e+c,range:u,detail:n,sortText:e}))}}}),b.current=t.languages.registerCompletionItemProvider(`markdown`,{triggerCharacters:[`@`],async provideCompletionItems(n,r){if(!bD(e,n))return{suggestions:[]};let i=O.current;if(!i)return{suggestions:[]};let a=n.getLineContent(r.lineNumber).substring(0,r.column-1),o=a.lastIndexOf(`@`);if(o===-1)return{suggestions:[]};if(o>0){let e=a[o-1];if(!/[\s\p{P}]/u.test(e))return{suggestions:[]}}let s=a.slice(o+1);if(s.length>40||/\s/.test(s))return{suggestions:[]};let c;try{c=await i(s)}catch{return{suggestions:[]}}let l=new t.Range(r.lineNumber,o+1,r.lineNumber,r.column);return{suggestions:c.map(e=>({label:`@${e.label}`,kind:t.languages.CompletionItemKind.User,insertText:`@[${e.label}](${e.scheme}:${e.id}) `,range:l,...e.description?{detail:e.description}:{},sortText:e.label}))}}}),x.current=t.languages.registerCompletionItemProvider(`markdown`,{triggerCharacters:[`[`],provideCompletionItems(n,r){if(!bD(e,n)||yD(n,r.lineNumber))return{suggestions:[]};let i=n.getLineContent(r.lineNumber),a=i.substring(0,r.column-1),o=i.substring(r.column-1),s=a.lastIndexOf(`{[`);if(s===-1)return{suggestions:[]};let c=a.slice(s+2);if(c.includes(`]`)||c&&!/^[a-zA-Z0-9_:-]*$/.test(c))return{suggestions:[]};let l=c.toLowerCase(),u=o.match(/^\]\}/)?``:`]}`,d=new t.Range(r.lineNumber,s+3,r.lineNumber,r.column);return{suggestions:xt(l,50).map((e,n)=>({label:{label:`${Dt(e.entry)} ${e.token}`,description:`fa-${e.entry.family}`},filterText:e.token,kind:t.languages.CompletionItemKind.Constant,insertText:`${e.token}${u}`,range:d,detail:e.entry.label,documentation:{value:`<i class="fa-${e.entry.family} fa-${e.entry.name}" style="font-size: 2em; display: inline-block; margin-right: 8px; vertical-align: middle"></i> **${e.token}** *(${e.entry.label})*`,isTrusted:!0,supportHtml:!0},sortText:`${e.score}${String(n).padStart(4,`0`)}`}))}}}),S.current=t.languages.registerCompletionItemProvider(`markdown`,{triggerCharacters:[`=`,` `],provideCompletionItems(n,r){if(!bD(e,n)||yD(n,r.lineNumber))return{suggestions:[]};let i=n.getLineContent(r.lineNumber);if(!/^#{1,6}\s/.test(i))return{suggestions:[]};let a=i.substring(0,r.column-1),o=a.lastIndexOf(`{[`);if(o===-1)return{suggestions:[]};let s=a.slice(o+2);if(s.includes(`]`)||!/\s/.test(s))return{suggestions:[]};let c=s.match(/\s(\S*)$/),l=c?c[1]:``,u=r.column-l.length,d=l.indexOf(`=`);if(d>=0){let e=l.slice(0,d),n=kt.find(t=>t.key===e);if(!n?.values)return{suggestions:[]};let i=new t.Range(r.lineNumber,u+d+1,r.lineNumber,r.column);return{suggestions:n.values.map((e,r)=>({label:e,filterText:e,kind:t.languages.CompletionItemKind.EnumMember,insertText:e,range:i,detail:n.description,sortText:String(r).padStart(4,`0`)}))}}let f=i.slice(o+2),p=f.indexOf(`]}`),m=p===-1?f:f.slice(0,p),h=new Set(jt(m).map(e=>{let t=e.indexOf(`=`);return t>0?e.slice(0,t):null}).filter(e=>e!=null));h.delete(l);let g=new t.Range(r.lineNumber,u,r.lineNumber,r.column);return{suggestions:kt.filter(e=>!h.has(e.key)).map((e,n)=>({label:e.key,filterText:e.key,kind:t.languages.CompletionItemKind.Property,insertText:`${e.key}=`,range:g,detail:e.values?e.description:`${e.description} \u2014 ${e.valueHint}`,sortText:String(n).padStart(4,`0`),...e.values?{command:{id:`editor.action.triggerSuggest`,title:``}}:{}}))}}})),T.current?.dispose(),T.current=e.onKeyDown(e=>{wh().catch(()=>void 0),e.keyCode===t.KeyCode.Enter&&E.current&&(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),e.stopPropagation(),E.current()))}),w.current?.();let i=e.getDomNode();if(i){let n=e=>{let t=e.dataTransfer;xD(D.current,t)&&(e.preventDefault(),t.dropEffect=`copy`)},r=n=>{if(!xD(D.current,n.dataTransfer))return;let r=n.dataTransfer;if(!r)return;let i=r.getData(fD);if(!i)return;let a=pD(i);if(!a)return;n.preventDefault(),n.stopPropagation();let o=e.getTargetAtClientPoint(n.clientX,n.clientY)?.position??e.getPosition();if(!o)return;let s=gD(a);e.executeEdits(`squisq-media-drop`,[{range:new t.Range(o.lineNumber,o.column,o.lineNumber,o.column),text:s,forceMoveMarkers:!0}]),e.focus()};i.addEventListener(`dragover`,n,!0),i.addEventListener(`drop`,r,!0),w.current=()=>{i.removeEventListener(`dragover`,n,!0),i.removeEventListener(`drop`,r,!0)}}},[u,d]);(0,G.useEffect)(()=>()=>{u(null),y.current?.dispose(),y.current=null,b.current?.dispose(),b.current=null,x.current?.dispose(),x.current=null,S.current?.dispose(),S.current=null,C.current?.clear(),C.current=null,w.current?.(),w.current=null,T.current?.dispose(),T.current=null},[u]);let N=(0,G.useCallback)(e=>{v.current||e!==void 0&&l(e)},[l]);(0,G.useEffect)(()=>{let e=g.current;if(e){let t=e.getValue();t!==c&&t.replace(/\s+$/,``)!==c.replace(/\s+$/,``)&&(v.current=!0,e.setValue(c),v.current=!1)}},[c]),(0,G.useEffect)(()=>{let e=g.current;if(!e||!m||d!==`markdown`)return;let t=e.getModel();if(!t)return;let n=[],r=t.getLineCount(),i=vD(t),a=/\{\[([a-zA-Z0-9_:-]+)\]\}/g;for(let e=1;e<=r;e++){if(i[e-1])continue;let r=t.getLineContent(e);a.lastIndex=0;let o;for(;(o=a.exec(r))!==null;){let t=At(o[1]);if(!t)continue;let r=Dt(t);if(!r)continue;let i=o.index+1;n.push({range:new m.Range(e,i,e,i),options:{before:{content:r,inlineClassName:`fa-glyph-decoration-${t.family}`}}})}}C.current?C.current.set(n):C.current=e.createDecorationsCollection(n)},[c,d,m]);let P=ED[e]??e;return h?(0,K.jsx)(`div`,{className:i,style:{width:`100%`,height:`100%`},"data-testid":`raw-editor`,children:(0,K.jsx)(gh,{defaultLanguage:d,value:c,theme:P,beforeMount:j,onMount:M,onChange:N,options:{fontSize:n,wordWrap:r,minimap:{enabled:t},lineNumbers:`on`,scrollBeyondLastLine:!1,automaticLayout:!0,tabSize:2,renderWhitespace:`selection`,bracketPairColorization:{enabled:!0},guides:{indentation:!0},padding:{top:12,bottom:12},quickSuggestions:{other:!0,comments:!0,strings:!0},suggestOnTriggerCharacters:!0,lineDecorationsWidth:22,contextmenu:!s,readOnly:o,domReadOnly:o}})}):(0,K.jsx)(`textarea`,{className:i,"aria-label":`Document source`,"aria-busy":`true`,autoFocus:!0,readOnly:o,spellCheck:!1,value:c,onChange:e=>{o||l(e.currentTarget.value)},onSelect:e=>{_.current={start:e.currentTarget.selectionStart,end:e.currentTarget.selectionEnd}},onKeyDown:e=>{e.key===`Enter`&&E.current&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey&&(e.preventDefault(),e.stopPropagation(),E.current())},style:{width:`100%`,height:`100%`,boxSizing:`border-box`,resize:`none`,border:0,outline:0,padding:`12px 22px`,background:`var(--squisq-editor-background)`,color:`var(--squisq-editor-foreground)`,fontFamily:`var(--squisq-code-font, monospace)`,fontSize:n,lineHeight:1.5,whiteSpace:r===`off`?`pre`:`pre-wrap`,overflowWrap:r===`off`?`normal`:`anywhere`},"data-testid":`raw-editor`,"data-monaco-loading":!0})}function kD(e){return e?Et(e).params??{}:{}}function AD(e,t){return kD(e)[t]??``}function jD(e,t,n){let r=e?Et(e):{},i={...r.params??{}},a=n.trim();a===``?delete i[t]:i[t]=a,r.params=i;let o=Ct(r);return o==null||o===`{}`?null:o.slice(1,-1)}function MD(e,t){let n=[],r=Dy(e,t);r.type&&n.push(Fy(qe(r.type)??r.type));let i=kD(e);return i.startTime&&n.push(`${ND(i.startTime)} start`),i.duration&&n.push(`${ND(i.duration)} long`),n.join(` · `)}function ND(e){let t=ht(e);if(t==null)return e;let n=Math.round(t),r=Math.floor(n/60),i=n%60;return`${r}:${String(i).padStart(2,`0`)}`}var PD=Or.extend({addAttributes(){return{...this.parent?.(),dataTemplate:{default:null,parseHTML:e=>e.getAttribute(`data-template`)||null,renderHTML:e=>e.dataTemplate?{"data-template":e.dataTemplate}:{}},dataTemplateParams:{default:null,parseHTML:e=>e.getAttribute(`data-template-params`)||null,renderHTML:e=>e.dataTemplateParams?{"data-template-params":e.dataTemplateParams}:{}},dataTemplateEmpty:{default:!1,parseHTML:e=>e.hasAttribute(`data-template-empty`),renderHTML:e=>e.dataTemplateEmpty?{"data-template-empty":`true`}:{}},dataBlockAttrs:{default:null,parseHTML:e=>e.getAttribute(`data-block-attrs`)||null,renderHTML:e=>e.dataBlockAttrs?{"data-block-attrs":e.dataBlockAttrs}:{}}}},renderHTML({node:e,HTMLAttributes:t}){let n=`h${e.attrs.level}`,r=t[`data-template`],i=MD(t[`data-block-attrs`]??null,t[`data-template-params`]??null);return r?[n,t,[`span`,{class:`squisq-heading-content`},0],[`span`,{class:`squisq-template-badge`,contenteditable:`false`,role:`button`,tabindex:`0`,"aria-haspopup":`listbox`,title:`Change block type`,"data-template":r},[`span`,{class:`squisq-template-badge-core`,"data-template-label":ty(r),"aria-hidden":`true`}]],FD(i)]:[n,t,[`span`,{class:`squisq-heading-content`},0],[`span`,{class:`squisq-template-badge squisq-template-badge--empty`,contenteditable:`false`,role:`button`,tabindex:`0`,"aria-haspopup":`listbox`,title:`Choose block type`},[`span`,{class:`squisq-template-badge-core`,"data-template-label":`Block`,"aria-hidden":`true`}]],FD(i)]}});function FD(e){let t={class:`squisq-props-badge`,contenteditable:`false`,role:`button`,tabindex:`0`,"aria-haspopup":`dialog`,title:e?`Block properties \u2014 ${e}`:`Block properties`};return e&&(t[`data-props-summary`]=e),[`span`,t]}var ID=wr.create({name:`superscript`,excludes:`subscript`,parseHTML(){return[{tag:`sup`},{style:`vertical-align`,getAttrs:e=>e===`super`&&null}]},renderHTML({HTMLAttributes:e}){return[`sup`,Rr(e),0]},addCommands(){return{toggleSuperscript:()=>({commands:e})=>e.toggleMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),LD=wr.create({name:`subscript`,excludes:`superscript`,parseHTML(){return[{tag:`sub`},{style:`vertical-align`,getAttrs:e=>e===`sub`&&null}]},renderHTML({HTMLAttributes:e}){return[`sub`,Rr(e),0]},addCommands(){return{toggleSubscript:()=>({commands:e})=>e.toggleMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),RD={width:1600,height:900},zD=[Nx,_w],BD=zD;function VD({nodes:e,edges:t,onCommand:n,showMaximize:r=!0,maximized:i=!1,onToggleMaximize:a,activeToolId:o,onActiveToolIdChange:s,onSelectionChange:c,textChannel:l}){let u=(0,G.useMemo)(()=>Cw(e,t),[e,t]),[d,f]=(0,G.useState)(`select`),p=o??d,m=s??f,h=(0,G.useCallback)(e=>{switch(e.kind){case`moveLayer`:{if(!e.id.startsWith(`node-card-`))return;let t=nC(e.id);if(!t)return;n({kind:`moveNode`,nodeId:t,x:e.x,y:e.y});return}case`addEdge`:n({kind:`addConnection`,source:e.source,target:e.target,type:e.type});return;case`removeEdge`:n({kind:`removeConnection`,source:e.source,target:e.target,type:e.type});return;case`removeLayer`:{let t=nC(e.id);t&&n({kind:`removeNode`,nodeId:t});return}case`renameLayer`:{let t=nC(e.id);t&&n({kind:`renameNode`,nodeId:t,newLabel:e.label});return}case`setLayerText`:{let t=nC(e.id);t&&n({kind:`renameNode`,nodeId:t,newLabel:e.text});return}case`addLayer`:{let t=e.layer.position;n({kind:`addNode`,x:typeof t.x==`number`?t.x:0,y:typeof t.y==`number`?t.y:0});return}case`resizeLayer`:{if(!e.id.startsWith(`node-card-`))return;let t=nC(e.id);if(!t)return;n({kind:`resizeNode`,nodeId:t,width:e.width,height:e.height,...e.x===void 0?{}:{x:e.x},...e.y===void 0?{}:{y:e.y}});return}case`setLayerAttr`:return}},[n]),g=u.nodes,_=u.edges,v=(0,G.useCallback)(()=>(0,K.jsx)(pC,{nodes:g,edges:_}),[g,_]),y=(0,G.useRef)(e);y.current=e;let b=(0,G.useMemo)(()=>({channel:l,resolveEditableId:e=>nC(e)?e:null,getHtml:e=>{let t=nC(e);return lr(y.current.find(e=>e.id===t)?.data.label??``)},commit:(e,{text:t})=>{h({kind:`renameLayer`,id:e,label:t})},level:`inline`}),[h,l]);return(0,K.jsxs)(`div`,{className:`squisq-diagram-canvas`,children:[(0,K.jsx)(Hx,{viewport:RD,layers:u.layers,edges:u.edges,tools:BD,activeToolId:p,onActiveToolIdChange:m,onSelectionChange:c,onCommand:h,renderExtras:v,layerFollows:eC,showMaximize:r,maximized:i,onToggleMaximize:a,showViewControls:!0,showToolbar:!1,textEditing:b}),u.nodes.length===0&&(0,K.jsx)(HD,{onAdd:()=>{n({kind:`addNode`,x:RD.width/2-90,y:RD.height/2-32})}})]})}function HD({onAdd:e}){return(0,K.jsxs)(`div`,{className:`squisq-diagram-empty`,children:[(0,K.jsx)(`div`,{className:`squisq-diagram-empty-title`,children:`No diagram nodes yet`}),(0,K.jsx)(`div`,{className:`squisq-diagram-empty-hint`,children:`Click "+ Add first node" below, or add sub-headings under this block.`}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-diagram-empty-btn`,onClick:e,children:`+ Add first node`})]})}function UD(e){return e.replace(/[─-╿▲▼◀-◄▶-►←-↓`]/gu,` `).replace(/\s+/g,` `).trim()}function WD(e,t){let n=new Set,r=!0;for(;r;){r=!1;for(let i of e.nodes)n.has(i.id)||(i.containerId===t||i.containerId&&n.has(i.containerId))&&(n.add(i.id),r=!0)}return n}function GD(e,t,n){let r=Math.round(t),i=Math.round(n);return r===0&&i===0?e:{...e,nodes:e.nodes.map(e=>({...e,col:Math.max(0,e.col+r),row:Math.max(0,e.row+i)}))}}function KD(e,t,n,r){let i=e.nodes.find(e=>e.id===t);if(!i)return e;let a=Math.max(0,n)-i.col,o=Math.max(0,r)-i.row;if(a===0&&o===0)return e;let s=WD(e,t);return s.add(t),{...e,nodes:e.nodes.map(e=>s.has(e.id)?{...e,col:Math.max(0,e.col+a),row:Math.max(0,e.row+o)}:e)}}function qD(e,t,n,r){let i=e.nodes.find(e=>e.id===t);if(!i)return e;let a=i.label.length>0?i.label.split(`
|
|
463
|
+
`):[],o=Math.max(3,a.reduce((e,t)=>Math.max(e,t.length),0)+4),s=Math.max(3,a.length+2);return{...e,nodes:e.nodes.map(e=>e.id===t?{...e,wCols:Math.max(o,Math.round(n)),hRows:Math.max(s,Math.round(r))}:e)}}function JD(e,t,n,r){let i=new Set(e.nodes.map(e=>e.id));if(!i.has(t)||!i.has(n)||t===n||e.edges.some(e=>e.source===t&&e.target===n&&(e.label??``)===(r??``)))return e;let a={source:t,target:n,...r?{label:r}:{},directed:!0};return{...e,edges:[...e.edges,a]}}function YD(e,t,n,r){let i=!1,a=e.edges.filter(e=>i?!0:e.source===t&&e.target===n&&(r===void 0||(e.label??``)===r)?(i=!0,!1):!0);return i?{...e,edges:a}:e}function XD(e,t,n){let r=e.nodes.find(e=>e.id===t);if(!r)return e;let i=UD(n);return i.length===0||i===r.label?e:{...e,nodes:e.nodes.map(e=>e.id===t?{...e,label:i}:e)}}function ZD(e,t){let n=t.label;if(!n){let t=1,r=new Set(e.nodes.map(e=>e.label.split(`
|
|
464
|
+
`)[0]));for(;r.has(`Node ${t}`);)t++;n=`Node ${t}`}let r=UD(n)||`Node`,i=Math.max(0,Math.round(t.col)),a=Math.max(0,Math.round(t.row)),o=r.length+4,s=i+o/2,c=a+3/2,l=e.nodes.filter(t=>e.nodes.some(e=>e.containerId===t.id)).filter(e=>s>e.col&&s<e.col+e.wCols&&c>e.row&&c<e.row+e.hRows).sort((e,t)=>e.wCols*e.hRows-t.wCols*t.hRows),u={id:`__new-${e.nodes.length}`,label:r,col:i,row:a,wCols:o,hRows:3,...l[0]?{containerId:l[0].id}:{}};return{diagram:{...e,nodes:[...e.nodes,u]},label:r}}function QD(e,t){let n=e.nodes.find(e=>e.id===t);if(!n)return e;let r=e.nodes.filter(e=>e.id!==t).map(e=>{if(e.containerId!==t)return e;let r={...e};return n.containerId?r.containerId=n.containerId:delete r.containerId,r}),i=e.edges.filter(e=>e.source!==t&&e.target!==t);return{...e,nodes:r,edges:i}}function $D(e,t,n,r){let i=e.before.nodeAt(t.pos);return!i||i.type.name!==r?!1:e.mapping.map(t.pos+i.nodeSize,-1)>n}function eO(e,t,n,r=`codeBlock`){let i=new Map,a=new Set;for(let n of t){let t=e.mapping.mapResult(n.pos,1);t.deleted||(i.set(t.pos,n.id),a.add(n.id))}for(let o of t){if(a.has(o.id))continue;let t=e.mapping.mapResult(o.pos,1);i.has(t.pos)||n.nodeAt(t.pos)?.type.name===r&&$D(e,o,t.pos,r)&&(i.set(t.pos,o.id),a.add(o.id))}return i}var tO=new Dr(`squisq-repairable-diagram`),nO=new WeakMap;function rO(e){let t=e.attrs.language;return typeof t==`string`?t:null}function iO(e){if(e.type.name!==`codeBlock`)return!1;let t=nO.get(e);if(t!==void 0)return t;let n=Me(rO(e))&&z(e.textContent);return nO.set(e,n),n}function aO(e,t){return tO.getState(e.state)?.entries.find(e=>e.id===t)?.pos??null}function oO(e,t,n,r){let i=[];for(let a of t){let t=e.nodeAt(a.pos);if(!t||t.type.name!==`codeBlock`)continue;let o=a.id;i.push(sr.widget(a.pos+t.nodeSize,()=>{let e=document.createElement(`div`);e.className=`squisq-repair-banner`,e.contentEditable=`false`;let t=document.createElement(`span`);t.className=`squisq-repair-banner-text`,t.textContent=`This looks like a diagram that didn’t render cleanly.`;let i=document.createElement(`button`);i.type=`button`,i.className=`squisq-repair-banner-btn`,i.textContent=`⟳ Repair as diagram`;let a=e=>e.stopPropagation();return e.addEventListener(`mousedown`,a),i.addEventListener(`mousedown`,a),i.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),r?.(n,o)}),e.appendChild(t),e.appendChild(i),e},{side:1,ignoreSelection:!0,key:`squisq-repair-${a.id}`}))}return or.create(e,i)}function sO(e,t,n,r,i){if(!e.docChanged)return t;let a=eO(e,t.entries,r),o=t.seq,s=[];return r.descendants((e,t)=>{if(e.type.name===`codeBlock`)return iO(e)&&s.push({id:a.get(t)??`repair-${++o}`,pos:t}),!1}),{entries:s,seq:o,decorations:oO(r,s,n,i)}}var cO=kr.create({name:`squisqRepairableDiagram`,addOptions(){return{enabled:!0}},addProseMirrorPlugins(){let e=this.editor;if(this.options.enabled===!1)return[];let t=this.options.onRepair;return[new pr({key:tO,state:{init:(n,r)=>{let i=0,a=[];return r.doc.descendants((e,t)=>{if(e.type.name===`codeBlock`)return iO(e)&&a.push({id:`repair-${++i}`,pos:t}),!1}),{entries:a,seq:i,decorations:oO(r.doc,a,e,t)}},apply:(n,r,i,a)=>sO(n,r,e,a.doc,t)},props:{decorations(e){return this.getState(e)?.decorations??or.empty}}})]}});function lO(e,t,n,r){return e.isEditable?e.chain().command(({tr:e,state:i})=>{let a=e.doc.nodeAt(t);if(!a||a.type.name!==`codeBlock`)return!1;let o=a.textContent!==n,s=a.attrs.language??null,c=r!==void 0&&s!==r;return!o&&!c?!1:(c&&e.setNodeMarkup(t,void 0,{...a.attrs,language:r}),o&&e.replaceWith(t+1,t+a.nodeSize-1,i.schema.text(n)),!0)}).run():!1}function uO(e,t){if(!e.isEditable)return!1;let n=aO(e,t);if(n===null)return!1;let r=e.state.doc.nodeAt(n);if(!r||r.type.name!==`codeBlock`)return!1;let i=U(r.textContent);return i?lO(e,n,i.art,`diagram`):!1}function dO(e,t,n,r){let i=TO(e,t);if(i===null)return!1;let a=e.state.doc.nodeAt(i);if(!a||a.type.name!==`codeBlock`)return!1;let o=wO(a);if(!o)return!1;let s=r?GD(o,r.col,r.row):o,c=n(s);if(c===s&&s===o)return!1;let l=p(c);return me(l).nodes.length===c.nodes.length&&lO(e,i,l,`diagram`)}function fO(e,t,n,r={}){if(!e.isEditable)return!1;let i=n=>dO(e,t,n,r.diagramOffset);switch(n.kind){case`moveNode`:{let{col:e,row:t}=S(n.x,n.y);return i(r=>KD(r,n.nodeId,e,t))}case`resizeNode`:{let e=Math.max(3,Math.round(n.width/14)),t=Math.max(3,Math.round(n.height/28));return i(r=>{let i=r;if(n.x!==void 0&&n.y!==void 0){let{col:e,row:t}=S(n.x,n.y);i=KD(i,n.nodeId,e,t)}return qD(i,n.nodeId,e,t)})}case`addConnection`:return i(e=>JD(e,n.source,n.target,n.type));case`removeConnection`:return i(e=>YD(e,n.source,n.target,n.type));case`renameNode`:return i(e=>XD(e,n.nodeId,n.newLabel));case`addNode`:{let{col:e,row:t}=S(n.x,n.y);return i(n=>ZD(n,{col:e,row:t}).diagram)}case`removeNode`:return i(e=>QD(e,n.nodeId))}return!1}var pO=160,mO=420;function hO({editor:e,blockId:t,host:n,textChannel:r}){let i=IO(e,t),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(null),d=(0,G.useRef)(null),[f,p]=(0,G.useState)(0),m=(0,G.useRef)(null),h=l??s;i&&d.current===null&&(d.current=NO(i.diagram));let g=(0,G.useMemo)(()=>{if(!i)return null;let e=d.current??{col:0,row:0};return FO(PO(i.diagram,e))},[i,f]),_=(0,G.useCallback)(n=>{let r=d.current??{col:0,row:0};fO(e,t,n,{diagramOffset:r})&&(r.col!==0||r.row!==0)&&(d.current={col:0,row:0},p(e=>e+1))},[e,t]),v=(0,G.useCallback)(e=>{e.preventDefault(),e.stopPropagation();let t=e.clientY,n=m.current?.getBoundingClientRect().height??h??mO,r=e=>Math.max(pO,Math.round(n+(e-t))),i=document.body.style.cursor,a=document.body.style.userSelect;document.body.style.cursor=`ns-resize`,document.body.style.userSelect=`none`;let o=e=>u(r(e.clientY)),s=e=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),document.body.style.cursor=i,document.body.style.userSelect=a,u(null),c(r(e.clientY))};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},[h]),y=(0,G.useCallback)(()=>{u(null),c(null)},[]),[b,x]=(0,G.useState)(`select`),[S,C]=(0,G.useState)(()=>new Set),w=(0,G.useMemo)(()=>[...S].map(e=>nC(e)).filter(e=>e!=null),[S]),T=EO(e,t);if(!i)return null;let E=(0,K.jsx)(qC,{tools:zD,activeToolId:b,onSelectTool:x,actions:[{id:`add-node`,label:`Node`,icon:(0,K.jsx)(q,{icon:`fa-solid fa-plus`}),title:`Add node`,onClick:()=>_({kind:`addNode`,x:RD.width/2-XS/2,y:RD.height/2-ZS/2})},{id:`delete`,label:`Delete`,icon:(0,K.jsx)(q,{icon:`fa-solid fa-trash`}),title:`Delete selected node`,danger:!0,disabled:w.length===0,onClick:()=>w.forEach(e=>_({kind:`removeNode`,nodeId:e}))},{id:`ascii-source`,label:`Source`,icon:(0,K.jsx)(q,{icon:`fa-solid fa-code`}),title:T?`Hide ASCII source`:`Show ASCII source`,onClick:()=>DO(e,t)}]}),D=i.warnings.length>0?(0,K.jsxs)(`details`,{className:`squisq-ascii-diagram-warnings`,children:[(0,K.jsxs)(`summary`,{children:[i.warnings.length,` parser note`,i.warnings.length===1?``:`s`]}),(0,K.jsx)(`ul`,{children:i.warnings.map((e,t)=>(0,K.jsx)(`li`,{children:e},t))})]}):null,O=(0,K.jsx)(VD,{textChannel:r,nodes:g?.nodes??i.nodes,edges:g?.edges??i.edges,onCommand:_,showMaximize:!0,maximized:a,onToggleMaximize:()=>o(e=>!e),activeToolId:b,onActiveToolIdChange:x,onSelectionChange:C});return a?(0,K.jsx)(`div`,{className:`squisq-diagram-inline-placeholder`,style:h==null?void 0:{height:h},children:(0,K.jsx)(XC,{host:n??null,onClose:()=>o(!1),children:(0,K.jsxs)(`div`,{className:`squisq-scene-block-max`,children:[O,(0,K.jsx)(`div`,{className:`squisq-scene-side-toolbar`,children:E})]})})}):(0,K.jsxs)(`div`,{className:`squisq-scene-shell`,children:[(0,K.jsx)(YC,{children:E}),(0,K.jsxs)(`div`,{className:`squisq-diagram-inline`,ref:m,style:h==null?void 0:{height:h},children:[O,(0,K.jsx)(`div`,{className:`squisq-diagram-resize-handle`,onPointerDown:v,onDoubleClick:y,role:`separator`,"aria-orientation":`horizontal`,"aria-label":`Resize diagram height`,title:`Drag to resize · double-click to reset`})]}),D]})}var gO=[`pointerdown`,`mousedown`,`keydown`,`keyup`,`beforeinput`,`input`,`change`,`compositionstart`,`compositionupdate`,`compositionend`,`copy`,`paste`,`cut`];function _O(e){for(let t of gO)e.addEventListener(t,e=>e.stopPropagation())}var vO=new Dr(`squisq-ascii-diagram`),yO=new WeakMap,bO=new WeakMap;function xO(e){let t=e.attrs.language;return typeof t==`string`?t:null}function SO(e){if(e.type.name!==`codeBlock`)return null;let t=yO.get(e);if(t!==void 0)return t;let n=null,r=xO(e);if(Me(r)){let t=Pe(e.textContent,{explicit:f(r)});t.isDiagram&&t.diagram&&(n=t.diagram,bO.set(e,n))}return yO.set(e,n),n}var CO=/[│┃║┌┐└┘├┤┬┴┼╭╮╰╯┏┓┗┛╔╗╚╝┣┫┳┻╋╠╣╦╩╬]/;function wO(e){if(e.type.name!==`codeBlock`)return null;let t=bO.get(e);if(t!==void 0)return t;let n=null;if(Me(xO(e))){let t=me(e.textContent);t.nodes.length>0&&!t.nodes.some(e=>CO.test(e.label))&&(n=t)}return bO.set(e,n),n}function TO(e,t){return vO.getState(e.state)?.entries.find(e=>e.id===t)?.pos??null}function EO(e,t){return vO.getState(e.state)?.sourceVisible.has(t)??!1}function DO(e,t){let n=e.state.tr.setMeta(vO,{toggleSource:t});e.view.dispatch(n)}function OO(e,t,n,r,i){let a=[];for(let o of t){let t=e.nodeAt(o.pos);if(!t||t.type.name!==`codeBlock`)continue;let s=n.has(o.id)?`squisq-ascii-fence-source`:`squisq-ascii-fence-hidden`;a.push(sr.node(o.pos,o.pos+t.nodeSize,{class:s}));let c=o.id,l=o.pos;a.push(sr.widget(o.pos+t.nodeSize,e=>{let t=document.createElement(`div`);t.className=`squisq-ascii-diagram-widget-host`,t.contentEditable=`false`,_O(t);let n=(0,Gr.createRoot)(t);return n.render((0,G.createElement)(hO,{editor:r,blockId:c,fallbackPos:l,host:e.dom.parentElement??e.dom,textChannel:i})),t.__squisqAsciiRoot={root:n},t},{destroy:e=>{let t=e.__squisqAsciiRoot;t&&setTimeout(()=>t.root.unmount(),0)},side:1,ignoreSelection:!0,key:`squisq-ascii-${o.id}`}))}return or.create(e,a)}function kO(e,t,n,r,i){let a=e.getMeta(vO),o=t.sourceVisible;if(a?.toggleSource){let e=new Set(o);e.has(a.toggleSource)?e.delete(a.toggleSource):e.add(a.toggleSource),o=e}if(!e.docChanged)return a?.toggleSource?{...t,sourceVisible:o,decorations:OO(r,t.entries,o,n,i)}:t;let s=eO(e,t.entries,r),c=t.seq,l=[];r.descendants((e,t)=>{if(e.type.name!==`codeBlock`)return;let n=s.get(t);return(n?wO(e):SO(e))&&l.push({id:n??`ascii-${++c}`,pos:t}),!1});let u=new Set(l.map(e=>e.id)),d=new Set([...o].filter(e=>u.has(e)));return{entries:l,seq:c,sourceVisible:d,decorations:OO(r,l,d,n,i)}}var AO=kr.create({name:`squisqAsciiDiagram`,addOptions(){return{enabled:!0}},addProseMirrorPlugins(){let e=this.editor;return this.options.enabled===!1?[]:[new pr({key:vO,state:{init:(t,n)=>{let r=0,i=[];return n.doc.descendants((e,t)=>{if(e.type.name===`codeBlock`)return SO(e)&&i.push({id:`ascii-${++r}`,pos:t}),!1}),{entries:i,seq:r,sourceVisible:new Set,decorations:OO(n.doc,i,new Set,e,this.options.textChannel)}},apply:(t,n,r,i)=>kO(t,n,e,i.doc,this.options.textChannel)},props:{decorations(e){return this.getState(e)?.decorations??or.empty}}})]}}),jO=8,MO=2;function NO(e){if(e.nodes.length===0)return{col:0,row:0};let t=Math.min(...e.nodes.map(e=>e.col)),n=Math.min(...e.nodes.map(e=>e.row));return{col:Math.max(0,jO-t),row:Math.max(0,MO-n)}}function PO(e,t){return GD(e,t.col,t.row)}function FO(e){let t=new Set(e.nodes.map(e=>e.containerId).filter(e=>e!==void 0)),n=t=>{let n=0,r=e.nodes.find(e=>e.id===t);for(;r?.containerId&&(n++,r=e.nodes.find(e=>e.id===r?.containerId),!(n>e.nodes.length)););return n},r=[...e.nodes].sort((e,r)=>!t.has(e.id)-+!t.has(r.id)||n(e.id)-n(r.id)).map(e=>({id:e.id,position:P(e.col,e.row),data:{label:e.label},width:e.wCols*14,height:e.hRows*28,...t.has(e.id)?{kind:`container`}:{}})),i=_(e).edges;return{nodes:r,edges:e.edges.map((e,t)=>({id:e.label?`${e.source}->${e.target}:${e.label}`:`${e.source}->${e.target}`,source:e.source,target:e.target,...e.label?{label:e.label}:{},...e.directed?{}:{directed:!1},...i[t]?.sourceAnchor?{sourceAnchor:i[t].sourceAnchor}:{},...i[t]?.targetAnchor?{targetAnchor:i[t].targetAnchor}:{},...i[t]?.routing?{routing:i[t].routing}:{}}))}}function IO(e,t){let[n,r]=(0,G.useState)(0);return(0,G.useEffect)(()=>{let t=()=>r(e=>e+1);return e.on(`transaction`,t),()=>{e.off(`transaction`,t)}},[e]),(0,G.useMemo)(()=>{let n=TO(e,t);if(n===null)return null;let r=e.state.doc.nodeAt(n);if(!r||r.type.name!==`codeBlock`)return null;let i=wO(r);if(!i)return null;let{nodes:a,edges:o}=FO(i);return{nodes:a,edges:o,warnings:i.warnings,style:i.style,text:r.textContent,diagram:i}},[e,t,n])}function LO(e){if(!e||e.includes("```"))return!1;let t=Pe(e);return t.isDiagram&&(t.diagram?.nodes.length??0)>=2}var RO={addNode:!0,renameNode:!0,duplicateNode:!0,deleteNode:!0,connect:!0,disconnect:!0,edgeLabel:!0,shape:!0,direction:!0,properties:!0};function zO(e){return e.kind===`flowchart`?RO:e.capabilities}function BO(e){let t=zO(e),n=e.kind===`flowchart`?[]:e.properties;return[...e.nodes.filter(e=>t.renameNode&&e.label.trim()).map(e=>({id:`node:${e.id}`,label:e.label,target:`node`,targetId:e.id,deletable:t.deleteNode})),...e.edges.filter(e=>t.edgeLabel&&e.label.trim()).map(e=>({id:`edge:${e.id}`,label:e.label,target:`edge`,targetId:e.id,deletable:e.origin?.labelDeletable!==!1})),...n.filter(e=>e.rendered&&typeof e.value==`string`&&e.value.trim()).map(e=>({id:`property:${e.id}`,label:String(e.value),target:`property`,targetId:e.id,deletable:e.deletable===!0})),...e.texts??[]]}function VO(e){return e.kind===`flowchart`?[{id:`direction`,label:`Flow direction`,value:e.direction===`TD`?`TB`:e.direction,type:`select`,options:[{value:`LR`,label:`Left to right`},{value:`TB`,label:`Top to bottom`},{value:`RL`,label:`Right to left`},{value:`BT`,label:`Bottom to top`}]}]:e.properties}var HO=[{id:`rect`,label:`Process`,category:`Basic`,aliases:[`rectangle`,`proc`]},{id:`rounded`,label:`Event`,category:`Basic`,aliases:[`event`]},{id:`stadium`,label:`Terminal`,category:`Basic`,aliases:[`pill`]},{id:`circle`,label:`Circle`,category:`Basic`,aliases:[`circ`]},{id:`dbl-circ`,label:`Double circle`,category:`Basic`,aliases:[`double-circle`]},{id:`diam`,label:`Decision`,category:`Basic`,aliases:[`diamond`,`question`]},{id:`hex`,label:`Preparation`,category:`Basic`,aliases:[`hexagon`,`prepare`]},{id:`tri`,label:`Extract`,category:`Basic`,aliases:[`triangle`]},{id:`odd`,label:`Odd`,category:`Basic`},{id:`notch-rect`,label:`Card`,category:`Process`,aliases:[`card`]},{id:`delay`,label:`Delay`,category:`Process`},{id:`div-rect`,label:`Divided process`,category:`Process`,aliases:[`div-proc`]},{id:`fork`,label:`Fork / join`,category:`Process`,aliases:[`join`]},{id:`lin-rect`,label:`Lined process`,category:`Process`,aliases:[`lin-proc`]},{id:`st-rect`,label:`Multi-process`,category:`Process`,aliases:[`processes`]},{id:`fr-rect`,label:`Subprocess`,category:`Process`,aliases:[`subprocess`]},{id:`tag-rect`,label:`Tagged process`,category:`Process`,aliases:[`tag-proc`]},{id:`lean-r`,label:`Input / output`,category:`Data`,aliases:[`in-out`]},{id:`lean-l`,label:`Output / input`,category:`Data`,aliases:[`out-in`]},{id:`datastore`,label:`Data store`,category:`Data`,aliases:[`data-store`]},{id:`cyl`,label:`Database`,category:`Data`,aliases:[`database`,`db`]},{id:`h-cyl`,label:`Direct access storage`,category:`Data`,aliases:[`das`]},{id:`lin-cyl`,label:`Disk storage`,category:`Data`,aliases:[`disk`]},{id:`bow-rect`,label:`Stored data`,category:`Data`,aliases:[`stored-data`]},{id:`win-pane`,label:`Internal storage`,category:`Data`,aliases:[`window-pane`]},{id:`doc`,label:`Document`,category:`Documents`},{id:`docs`,label:`Multi-document`,category:`Documents`,aliases:[`documents`]},{id:`lin-doc`,label:`Lined document`,category:`Documents`},{id:`tag-doc`,label:`Tagged document`,category:`Documents`},{id:`flag`,label:`Paper tape`,category:`Documents`,aliases:[`paper-tape`]},{id:`bang`,label:`Bang`,category:`Symbols`},{id:`cloud`,label:`Cloud`,category:`Symbols`},{id:`hourglass`,label:`Collate`,category:`Symbols`,aliases:[`collate`]},{id:`bolt`,label:`Communication link`,category:`Symbols`,aliases:[`com-link`]},{id:`brace`,label:`Comment left`,category:`Symbols`,aliases:[`comment`]},{id:`brace-r`,label:`Comment right`,category:`Symbols`},{id:`braces`,label:`Comment both`,category:`Symbols`},{id:`curv-trap`,label:`Display`,category:`Symbols`,aliases:[`display`]},{id:`notch-pent`,label:`Loop limit`,category:`Symbols`,aliases:[`loop-limit`]},{id:`flip-tri`,label:`Manual file`,category:`Symbols`,aliases:[`manual-file`]},{id:`sl-rect`,label:`Manual input`,category:`Symbols`,aliases:[`manual-input`]},{id:`trap-t`,label:`Manual operation`,category:`Symbols`,aliases:[`manual`]},{id:`trap-b`,label:`Priority action`,category:`Symbols`,aliases:[`priority`]},{id:`f-circ`,label:`Junction`,category:`Symbols`,aliases:[`junction`]},{id:`sm-circ`,label:`Start`,category:`Symbols`,aliases:[`start`]},{id:`fr-circ`,label:`Stop`,category:`Symbols`,aliases:[`stop`]},{id:`cross-circ`,label:`Summary`,category:`Symbols`,aliases:[`summary`]},{id:`text`,label:`Text block`,category:`Symbols`}],UO=new Set(HO.map(e=>e.id)),WO={square:`rect`,rectangle:`rect`,proc:`rect`,round:`rounded`,event:`rounded`,pill:`stadium`,subroutine:`fr-rect`,cylinder:`cyl`,database:`cyl`,db:`cyl`,diamond:`diam`,question:`diam`,hexagon:`hex`,prepare:`hex`,doublecircle:`dbl-circ`,"double-circle":`dbl-circ`,trapezoid:`trap-b`,inv_trapezoid:`trap-t`,lean_right:`lean-r`,lean_left:`lean-l`};function GO(e){return UO.has(e)}function KO(e){if(!e)return`rect`;if(GO(e))return e;let t=WO[e];if(t)return t;for(let t of HO)if(`aliases`in t&&t.aliases.includes(e))return t.id;return`rect`}var qO=`[A-Za-z_][A-Za-z0-9_.-]*`,JO=[`TB`,`BT`,`LR`,`RL`],YO=[{value:`LR`,label:`Left to right`},{value:`TB`,label:`Top to bottom`},{value:`RL`,label:`Right to left`},{value:`BT`,label:`Bottom to top`}],XO={addNode:!0,renameNode:!0,duplicateNode:!0,deleteNode:!0,connect:!1,disconnect:!1,edgeLabel:!1,shape:!1,direction:!1,properties:!0};function ZO(e={}){return{...XO,...e}}function QO(e){return e.split(/\r?\n/)}function $O(e,t){let n=t.join(`
|
|
465
|
+
`).replace(/\n{3,}/g,`
|
|
466
|
+
|
|
467
|
+
`);return n===e?{ok:!1,source:e,reason:`The diagram is unchanged.`}:{ok:!0,source:n}}function ek(e,t){return{ok:!1,source:e,reason:t}}function tk(e){return/^\s*/.exec(e)?.[0]??``}function nk(e){let t=e.trim();return t.length>=2&&(t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`))?t.slice(1,-1):t}function rk(e){return RegExp(`^${qO}$`).test(e)}function ik(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function ak(e,t){return RegExp(`(^|[^A-Za-z0-9_.-])${ik(t)}(?=$|[^A-Za-z0-9_.-])`).test(e)}function ok(e,t,n){return e.replace(RegExp(`(^|[^A-Za-z0-9_.-])${ik(t)}(?=$|[^A-Za-z0-9_.-])`,`g`),(e,t)=>`${t}${n}`)}function sk(e,t){let n=new Set(e.map(e=>e.id));if(!n.has(t))return t;let r=2;for(;n.has(`${t}${r}`);)r+=1;return`${t}${r}`}function ck(e,t,n,r={}){return{id:e,domId:e,label:t,shape:`rect`,classes:[],origin:{line:n,...r}}}function lk(e,t,n,r,i,a={}){return{id:e,source:t,target:n,label:r,origin:{line:i,...a}}}function uk(e){let t=e.origin?.line;return typeof t==`number`?t:null}function dk(e,t,n,r=t,i={}){let a=e.map(e=>RegExp(`^\\s*${r}\\s+(.+?)\\s*$`,`i`).exec(e)).find(Boolean);return{id:t,label:n,value:a?nk(a[1]):``,...i}}function fk(e,t,n,r=t){return dk(e,t,n,r,{rendered:!0,deletable:!0})}function pk(e){let t=dk(e,`direction`,`Direction`,`direction`,{type:`select`,options:YO});return{...t,value:t.value||`TB`}}function mk(e,t,n,r,i,a=`Node`,o=`Connection`,s=[]){let c=r.find(e=>e.id===`direction`)?.value,l=JO.includes(c)?c:void 0;return{kind:e,nodes:t,edges:n,properties:r,texts:s,capabilities:i,nodeNoun:a,edgeNoun:o,...l?{direction:l}:{}}}function hk(e,t,n,r,i,a={}){return{id:e,label:t,target:`source`,targetId:e,deletable:i,origin:{line:n,role:r,...a}}}function gk(e){return Math.max(0,e.findIndex(e=>/\S/.test(e)&&!e.trimStart().startsWith(`%%`)))}function _k(e,t){let n=QO(e);return n.splice(gk(n)+1,0,t),$O(e,n)}function vk(e,t){let n=QO(e);for(;n.length>1&&!n[n.length-1]?.trim();)n.pop();return n.push(t),$O(e,n)}function yk(e){let t=new Map,n=[],r=RegExp(`^\\s*(participant|actor)\\s+(${qO})(?:\\s+as\\s+(.+))?\\s*$`,`i`),i=RegExp(`^\\s*(${qO})\\s*([-.=+x)o<(>]+)\\s*(${qO})\\s*:\\s*(.*?)\\s*$`);e.forEach((e,a)=>{let o=r.exec(e);if(o){t.set(o[2],ck(o[2],nk(o[3]??o[2]),a,{declaration:!0}));return}let s=i.exec(e);!s||!s[2].includes(`>`)&&!s[2].includes(`<`)&&!s[2].includes(`)`)||(t.has(s[1])||t.set(s[1],ck(s[1],s[1],a)),t.has(s[3])||t.set(s[3],ck(s[3],s[3],a)),n.push(lk(`sequence-${a}`,s[1],s[3],s[4],a,{operator:s[2]})))});let a=e.some(e=>/^\s*autonumber\s*$/i.test(e));return mk(`sequence`,[...t.values()],n,[{id:`autonumber`,label:`Number messages`,value:a,type:`boolean`}],ZO({connect:!0,disconnect:!0,edgeLabel:!0}),`Participant`,`Message`)}function bk(e){let t=new Map,n=[],r=RegExp(`^\\s*state\\s+"([^"]+)"\\s+as\\s+(${qO})\\s*$`,`i`),i=RegExp(`^\\s*state\\s+(${qO})(?:\\s+as\\s+"([^"]+)")?\\s*$`,`i`),a=RegExp(`^\\s*(\\[\\*\\]|${qO})\\s*--?>\\s*(\\[\\*\\]|${qO})(?:\\s*:\\s*(.*?))?\\s*$`);return e.forEach((e,o)=>{let s=r.exec(e);if(s){t.set(s[2],ck(s[2],s[1],o,{declaration:!0,aliasFirst:!0}));return}let c=i.exec(e);if(c){t.set(c[1],ck(c[1],c[2]??c[1],o,{declaration:!0}));return}let l=a.exec(e);if(l){for(let e of[l[1],l[2]])e!==`[*]`&&!t.has(e)&&t.set(e,ck(e,e,o));n.push(lk(`state-${o}`,l[1],l[2],l[3]??``,o))}}),mk(`state`,[...t.values()],n,[pk(e)],ZO({connect:!0,disconnect:!0,edgeLabel:!0,direction:!0}),`State`,`Transition`)}function xk(e){let t=new Map,n=[],r=[],i=RegExp(`^\\s*class\\s+(${qO})(?:\\["([^"]+)"\\])?(?:\\s*\\{)?\\s*$`,`i`),a=RegExp(`^\\s*(${qO})(?:\\s+"[^"]+")?\\s+([<|>*o.()\\-]+)\\s+(?:"[^"]+"\\s+)?(${qO})(?:\\s*:\\s*(.*?))?\\s*$`),o=null;return e.forEach((e,s)=>{if(o&&/^\s*}\s*$/.test(e)){o=null;return}if(o&&e.trim()){r.push(hk(`class-member-${s}`,e.trim(),s,`line-content`,!0));return}let c=i.exec(e);if(c){t.set(c[1],ck(c[1],c[2]??c[1],s,{declaration:!0})),/\{\s*$/.test(e)&&(o=c[1]);return}let l=a.exec(e);if(!l||!/--|\.\./.test(l[2])){let t=RegExp(`^\\s*(${qO})\\s*:\\s*(.+?)\\s*$`).exec(e);t&&r.push(hk(`class-member-${s}`,t[2],s,`after-colon`,!0));return}for(let e of[l[1],l[3]])t.has(e)||t.set(e,ck(e,e,s));n.push(lk(`class-${s}`,l[1],l[3],l[4]??``,s,{operator:l[2]}))}),mk(`class`,[...t.values()],n,[pk(e)],ZO({connect:!0,disconnect:!0,edgeLabel:!0,direction:!0}),`Class`,`Relationship`,r)}function Sk(e){let t=new Map,n=[],r=[],i=RegExp(`^\\s*(${qO})\\s+([|}{o]+--[|}{o]+)\\s+(${qO})\\s*:\\s*(.*?)\\s*$`,`i`),a=RegExp(`^\\s*(${qO})\\s*\\{\\s*$`),o=!1;return e.forEach((s,c)=>{if(o&&/^\s*}\s*$/.test(s)){o=!1;return}if(o&&s.trim()){r.push(hk(`er-attribute-${c}`,s.trim(),c,`line-content`,!0));return}let l=a.exec(s);if(l&&!t.has(l[1])){let n=e.findIndex((e,t)=>t>c&&/^\s*}\s*$/.test(e));t.set(l[1],ck(l[1],l[1],c,{declaration:!0,endLine:n>=0?n:c})),o=!0}let u=i.exec(s);if(u){for(let e of[u[1],u[3]])t.has(e)||t.set(e,ck(e,e,c));n.push(lk(`er-${c}`,u[1],u[3],u[4],c,{operator:u[2],labelDeletable:!1}))}}),mk(`er`,[...t.values()],n,[pk(e)],ZO({connect:!0,disconnect:!0,edgeLabel:!0,direction:!0}),`Entity`,`Relationship`,r)}function Ck(e){let t=tk(e),n=e.trim(),r=RegExp(`^(${qO})?([([{]+)(.*?)([)\\]}]+)$`).exec(n);return r?{label:r[3].trim(),prefix:`${t}${r[1]??``}${r[2]}`,suffix:r[4]}:{label:n,prefix:t,suffix:``}}function wk(e){let t=[],n=[],r=[];return e.forEach((i,a)=>{if(a===gk(e)||!i.trim()||i.trimStart().startsWith(`%%`))return;let o=Ck(i),s={node:ck(`mindmap-${a}`,o.label,a,{prefix:o.prefix,suffix:o.suffix}),indent:tk(i).replace(/\t/g,` `).length,prefix:o.prefix,suffix:o.suffix};for(;r.length&&r[r.length-1].indent>=s.indent;)r.pop();let c=r[r.length-1];c&&n.push(lk(`mindmap-edge-${a}`,c.node.id,s.node.id,``,a)),r.push(s),t.push(s)}),mk(`mindmap`,t.map(e=>e.node),n,[],ZO({connect:!0,disconnect:!0,edgeLabel:!1,properties:!1}),`Topic`,`Parent link`)}function Tk(e){let t=new Map,n=[],r=/^\s*(Person(?:_Ext)?|System(?:_Ext)?|Container|Component)\s*\(\s*([^,]+)\s*,\s*"([^"]*)"(.*?)\)\s*$/i,i=/^\s*(Rel(?:_[A-Z]+)?)\s*\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*"([^"]*)"(.*?)\)\s*$/i;return e.forEach((e,a)=>{let o=r.exec(e);if(o){let e=o[2].trim();t.set(e,ck(e,o[3],a,{declaration:o[1],tail:o[4]}));return}let s=i.exec(e);s&&n.push(lk(`c4-${a}`,s[2].trim(),s[3].trim(),s[4],a,{relation:s[1],tail:s[5]}))}),mk(`c4`,[...t.values()],n,[fk(e,`title`,`Title`)],ZO({connect:!0,disconnect:!0,edgeLabel:!0}),`Element`,`Relationship`)}function Ek(e){let t=new Map,n=[],r=[],i=RegExp(`^\\s*group\\s+(${qO})\\([^)]+\\)\\[([^\\]]+)\\]\\s*$`,`i`),a=RegExp(`^\\s*service\\s+(${qO})\\(([^)]+)\\)\\[([^\\]]+)\\](?:\\s+in\\s+(${qO}))?\\s*$`,`i`),o=RegExp(`^\\s*(${qO})(?::[A-Z])?\\s*(-->|<--|<-->)\\s*(?:[A-Z]:)?(${qO})\\s*$`,`i`);return e.forEach((e,s)=>{let c=i.exec(e);if(c){r.push(hk(`architecture-group-${c[1]}`,c[2],s,`bracket-label`,!1));return}let l=a.exec(e);if(l){t.set(l[1],ck(l[1],l[3],s,{icon:l[2],group:l[4]??``}));return}let u=o.exec(e);u&&n.push(lk(`architecture-${s}`,u[1],u[3],``,s,{operator:u[2]}))}),mk(`architecture`,[...t.values()],n,[],ZO({connect:!0,disconnect:!0,properties:!1}),`Service`,`Connection`,r)}var Dk=new Set([`active`,`done`,`crit`,`milestone`]);function Ok(e,t){for(let t of e){let e=t.trim();if(!(Dk.has(e)||e.startsWith(`after `)||/^\d/.test(e)||/^(\d+)(ms|s|m|h|d|w)$/.test(e))&&rk(e))return e}return`gantt-task-${t}`}function kk(e){let t=[],n=[],r=[];return e.forEach((e,i)=>{let a=/^\s*section\s+(.+?)\s*$/i.exec(e);if(a){r.push(hk(`gantt-section-${i}`,a[1],i,`section`,!0));return}let o=/^\s*([^:%][^:]*)\s*:\s*(.+?)\s*$/.exec(e);if(!o||/^(title|dateFormat|axisFormat|tickInterval|excludes|includes|todayMarker)$/i.test(o[1].trim()))return;let s=o[2].split(`,`).map(e=>e.trim()),c=Ok(s,i);t.push(ck(c,o[1].trim(),i,{parts:o[2],generatedId:c.startsWith(`gantt-task-`)}));let l=s.find(e=>e.startsWith(`after `));for(let e of l?.slice(6).trim().split(/\s+/).filter(Boolean)??[])n.push(lk(`gantt-${i}-${e}`,e,c,``,i,{dependency:e}))}),mk(`gantt`,t,n,[fk(e,`title`,`Title`),dk(e,`dateFormat`,`Date format`),dk(e,`axisFormat`,`Axis format`),dk(e,`tickInterval`,`Tick interval`),dk(e,`excludes`,`Excluded dates`),dk(e,`todayMarker`,`Today marker`)],ZO({connect:!0,disconnect:!0}),`Task`,`Dependency`,r)}function Ak(e){let t=[],n=[];return e.forEach((e,r)=>{if(/^\s*title\b/i.test(e))return;let i=/^\s*section\s+(.+?)\s*$/i.exec(e);if(i){n.push(hk(`timeline-section-${r}`,i[1],r,`section`,!0));return}if(/^\s*timeline\b/i.test(e)||!e.includes(`:`))return;let a=e.split(`:`).map(e=>e.trim()),o=a.shift()??``;o&&n.push(hk(`timeline-period-${r}`,o,r,`timeline-period`,!1)),a.forEach((e,n)=>{e&&t.push(ck(`timeline-${r}-${n}`,e,r,{segment:n,period:o}))})}),mk(`timeline`,t,[],[fk(e,`title`,`Title`)],ZO({connectionHint:`Mermaid timelines use chronological order rather than explicit connections.`}),`Event`,`Connection`,n)}function jk(e){let t=[],n=[];return e.forEach((e,r)=>{let i=/^\s*section\s+(.+?)\s*$/i.exec(e);if(i){n.push(hk(`journey-section-${r}`,i[1],r,`section`,!0));return}if(/^\s*(journey|title)\b/i.test(e))return;let a=/^\s*(.+?)\s*:\s*(\d+)\s*:\s*(.+?)\s*$/.exec(e);a&&t.push(ck(`journey-${r}`,a[1],r,{score:a[2],actors:a[3]}))}),mk(`journey`,t,[],[fk(e,`title`,`Title`)],ZO({connectionHint:`User Journey tasks are ordered within sections and do not have explicit connections.`}),`Task`,`Connection`,n)}function Mk(e){let t=[],n=[],r=RegExp(`^(\\s+)(${qO})\\[([^\\]]*)\\]\\s*$`),i=1/0;for(let t of e){let e=r.exec(t);e&&(i=Math.min(i,e[1].length))}return e.forEach((e,a)=>{let o=r.exec(e);if(o){if(o[1].length===i){n.push(hk(`kanban-column-${o[2]}`,o[3],a,`bracket-label`,!1));return}o[1].length<i||t.push(ck(o[2],o[3],a,{indent:o[1],columnIndent:i}))}}),mk(`kanban`,t,[],[],ZO({properties:!1,connectionHint:`Kanban tasks are contained by columns rather than joined by explicit connections.`}),`Task`,`Connection`,n)}function Nk(e){let t=[],n=[];return e.forEach((e,r)=>{let i=/^\s*branch\s+([^\s]+)\s*$/i.exec(e);if(i){n.push(hk(`git-branch-${i[1]}`,i[1],r,`git-branch`,!1,{branch:i[1]}));return}if(!/^\s*commit\b/i.test(e))return;let a=/\bid\s*:\s*"([^"]+)"/i.exec(e),o=a?.[1]??`Commit ${t.length+1}`;t.push(ck(`git-${r}`,o,r,{customId:!!a}))}),mk(`git`,t,[],[],ZO({properties:!1,connectionHint:`Git Graph connections are derived from branch, checkout, and merge commands.`}),`Commit`,`Connection`,n)}function Pk(e){let t=[];return e.forEach((e,n)=>{let r=/^\s*"([^"]+)"\s*:\s*(-?\d+(?:\.\d+)?)\s*$/.exec(e);r&&t.push(ck(`pie-${n}`,r[1],n,{value:r[2]}))}),mk(`pie`,t,[],[fk(e,`title`,`Title`),{id:`showData`,label:`Show values`,value:/\bshowData\b/i.test(e[gk(e)]??``),type:`boolean`}],ZO({connectionHint:`Pie slices are values, so Mermaid does not define connections between them.`}),`Slice`,`Connection`)}function Fk(e){let t=[],n=[];return e.forEach((e,r)=>{let i=/^\s*(x-axis|y-axis)\s+(.+?)\s*-->\s*(.+?)\s*$/i.exec(e);if(i){n.push(hk(`quadrant-${i[1]}-start`,nk(i[2]),r,`axis-endpoint`,!1,{side:`start`}),hk(`quadrant-${i[1]}-end`,nk(i[3]),r,`axis-endpoint`,!1,{side:`end`}));return}let a=/^\s*"?([^":]+?)"?\s*:\s*\[\s*([\d.]+)\s*,\s*([\d.]+)\s*]\s*$/.exec(e);a&&t.push(ck(`quadrant-${r}`,a[1],r,{x:a[2],y:a[3]}))}),mk(`quadrant`,t,[],[fk(e,`title`,`Title`),dk(e,`xAxis`,`X axis`,`x-axis`),dk(e,`yAxis`,`Y axis`,`y-axis`),...[1,2,3,4].map(t=>dk(e,`quadrant${t}`,`Quadrant ${t}`,`quadrant-${t}`,{rendered:!0,deletable:!0}))],ZO({connectionHint:`Quadrant points are positioned values and do not have explicit connections.`}),`Point`,`Connection`,n)}function Ik(e){if(!e.includes(`,`)||e.trimStart().startsWith(`%%`))return null;let t=e.split(`,`).map(e=>nk(e));return t.length===3&&t.every(Boolean)?t:null}function Lk(e){let t=new Map,n=[];return e.forEach((e,r)=>{let i=Ik(e);!i||!Number.isFinite(Number(i[2]))||(t.has(i[0])||t.set(i[0],ck(i[0],i[0],r)),t.has(i[1])||t.set(i[1],ck(i[1],i[1],r)),n.push(lk(`sankey-${r}`,i[0],i[1],i[2],r,{labelDeletable:!1})))}),mk(`sankey`,[...t.values()],n,[],ZO({addNode:!1,duplicateNode:!1,connect:!0,disconnect:!0,edgeLabel:!0,properties:!1}),`Flow node`,`Flow`)}function Rk(e){let t=[],n=[];return e.forEach((e,r)=>{let i=/^\s*x-axis\s+(?:"([^"]+)"\s+)?\[([^\]]*)]\s*$/i.exec(e);if(i){i[1]&&n.push(hk(`xy-x-axis-title`,i[1],r,`quoted-label`,!1)),i[2].split(`,`).map(e=>nk(e)).filter(Boolean).forEach((e,t)=>n.push(hk(`xy-x-axis-${t}`,e,r,`xy-category`,!1,{itemIndex:t})));return}let a=/^\s*y-axis\s+"([^"]+)"/i.exec(e);if(a){n.push(hk(`xy-y-axis-title`,a[1],r,`quoted-label`,!1));return}let o=/^\s*(bar|line)\s+(\[[^\]]*])\s*$/i.exec(e);o&&t.push(ck(`xy-${r}`,`${o[1][0].toUpperCase()}${o[1].slice(1)} ${t.length+1}`,r,{series:o[1].toLowerCase(),values:o[2]}))}),mk(`xy`,t,[],[fk(e,`title`,`Title`),dk(e,`xAxis`,`X axis`,`x-axis`),dk(e,`yAxis`,`Y axis`,`y-axis`)],ZO({renameNode:!1,connectionHint:`XY series share chart axes and do not have explicit connections.`}),`Series`,`Connection`,n)}function zk(e){let t=new Map,n=[],r=RegExp(`^\\s*(requirement|functionalRequirement|interfaceRequirement|performanceRequirement|physicalRequirement|designConstraint|element)\\s+(${qO})\\s*\\{\\s*$`,`i`),i=RegExp(`^\\s*(${qO})\\s+-\\s*(contains|copies|derives|satisfies|verifies|refines|traces)\\s+->\\s+(${qO})\\s*$`,`i`);return e.forEach((a,o)=>{let s=r.exec(a);if(s){let n=e.findIndex((e,t)=>t>o&&/^\s*}\s*$/.test(e)),r=e.slice(o+1,n>=0?n:o+1).find(e=>/^\s*text\s*:/.test(e)),i=r?r.replace(/^\s*text\s*:\s*/,``).trim():s[2];t.set(s[2],ck(s[2],i,o,{declaration:s[1],endLine:n>=0?n:o}));return}let c=i.exec(a);c&&n.push(lk(`requirement-${o}`,c[1],c[3],c[2],o,{labelDeletable:!1}))}),mk(`requirement`,[...t.values()],n,[],ZO({connect:!0,disconnect:!0,edgeLabel:!0,properties:!1}),`Requirement`,`Relationship`)}function Bk(e){let t=QO(e),n=t[gk(t)]?.trim()??``;return/^sequenceDiagram\b/i.test(n)?yk(t):/^stateDiagram(?:-v2)?\b/i.test(n)?bk(t):/^classDiagram\b/i.test(n)?xk(t):/^erDiagram\b/i.test(n)?Sk(t):/^mindmap\b/i.test(n)?wk(t):/^C4(?:Context|Container|Component|Dynamic|Deployment)\b/i.test(n)?Tk(t):/^architecture-beta\b/i.test(n)?Ek(t):/^gantt\b/i.test(n)?kk(t):/^timeline\b/i.test(n)?Ak(t):/^journey\b/i.test(n)?jk(t):/^kanban\b/i.test(n)?Mk(t):/^gitGraph\b/i.test(n)?Nk(t):/^pie\b/i.test(n)?Pk(t):/^quadrantChart\b/i.test(n)?Fk(t):/^sankey(?:-beta)?\b/i.test(n)?Lk(t):/^xychart-beta\b/i.test(n)?Rk(t):/^requirementDiagram\b/i.test(n)?zk(t):null}function Vk(e,t,n){let r=uk(t);if(r===null)return ek(e,`This item can only be changed in Source.`);let i=QO(e);return i[r]?(i[r]=n(i[r]),$O(e,i)):ek(e,`The diagram changed before this edit was applied.`)}function Hk(e,t){let n=sk(t.nodes,t.kind===`class`?`NewClass`:t.kind===`er`?`NEW_ENTITY`:`node`),r;switch(t.kind){case`sequence`:r=_k(e,` participant ${n} as New participant`);break;case`state`:r=_k(e,` state "New state" as ${n}`);break;case`class`:r=_k(e,` class ${n}["New class"]`);break;case`er`:r=vk(e,` ${n} {
|
|
468
|
+
string name
|
|
469
|
+
}`);break;case`mindmap`:{let n=t.nodes[0];if(!n)return{...ek(e,`A mind map needs a root topic before adding children.`)};let i=uk(n)??1,a=QO(e);a.splice(i+1,0,`${tk(a[i])} New topic`),r=$O(e,a);break}case`c4`:r=vk(e,` System(${n}, "New system")`);break;case`architecture`:r=vk(e,` service ${n}(server)[New service]`);break;case`gantt`:r=vk(e,` New task :${n}, 1d`);break;case`timeline`:r=vk(e,` New period : New event`);break;case`journey`:r=vk(e,` New task: 3: User`);break;case`kanban`:{let i=t.nodes[0];if(!i)r=vk(e,` todo[To do]
|
|
470
|
+
${n}[New task]`);else{let t=uk(i)??1,a=QO(e);a.splice(t,0,`${String(i.origin?.indent??` `)}${n}[New task]`),r=$O(e,a)}break}case`git`:r=vk(e,` commit id: "New commit ${t.nodes.length+1}"`);break;case`pie`:r=vk(e,` "New slice" : 1`);break;case`quadrant`:r=vk(e,` "New point": [0.50, 0.50]`);break;case`xy`:r=vk(e,` line [0]`);break;case`requirement`:r=vk(e,` requirement ${n} {
|
|
471
|
+
id: ${t.nodes.length+1}
|
|
472
|
+
text: New requirement
|
|
473
|
+
risk: medium
|
|
474
|
+
verifymethod: test
|
|
475
|
+
}`);break;case`sankey`:return{...ek(e,`Sankey nodes are created by adding a flow between two labels.`)}}return r.ok?{...r,nodeId:n}:r}function Uk(e,t,n,r){let i=r.trim();if(!i)return ek(e,`${t.nodeNoun} labels cannot be empty.`);if(i===n.label)return ek(e,`The label is unchanged.`);switch(t.kind){case`sequence`:return n.origin?.declaration?Vk(e,n,e=>`${tk(e)}participant ${n.id} as ${i}`):_k(e,` participant ${n.id} as ${i}`);case`state`:return n.origin?.declaration?Vk(e,n,e=>`${tk(e)}state "${i.replace(/"/g,`'`)}" as ${n.id}`):_k(e,` state "${i.replace(/"/g,`'`)}" as ${n.id}`);case`class`:return n.origin?.declaration?Vk(e,n,e=>`${tk(e)}class ${n.id}["${i.replace(/"/g,`'`)}"]${/\{\s*$/.test(e)?` {`:``}`):_k(e,` class ${n.id}["${i.replace(/"/g,`'`)}"]`);case`er`:return rk(i)?$O(e,QO(e).map(e=>ok(e,n.id,i))):ek(e,`Entity names must be Mermaid identifiers (letters, numbers, underscores, dots, or dashes).`);case`mindmap`:return Vk(e,n,()=>`${String(n.origin?.prefix??``)}${i}${String(n.origin?.suffix??``)}`);case`c4`:return Vk(e,n,e=>e.replace(/(\(\s*[^,]+\s*,\s*)"[^"]*"/,`$1"${i.replace(/"/g,`'`)}"`));case`architecture`:case`kanban`:return Vk(e,n,e=>e.replace(/\[[^\]]*]/,`[${i.replace(/]/g,``)}]`));case`gantt`:return Vk(e,n,e=>{let t=e.indexOf(`:`);return`${tk(e)}${i.replace(/:/g,` -`)} ${e.slice(t)}`});case`timeline`:{let t=n.origin?.timelineRole;if(t===`title`)return Vk(e,n,e=>`${tk(e)}title ${i.replace(/\r?\n/g,` `)}`);if(t===`period`)return Vk(e,n,e=>{let t=e.indexOf(`:`);return t<0?e:`${tk(e)}${i.replace(/:/g,` -`)} ${e.slice(t)}`});let r=Number(n.origin?.segment??0);return Vk(e,n,e=>{let t=e.split(`:`);return t[r+1]!==void 0&&(t[r+1]=` ${i.replace(/:/g,` -`)} `),t.join(`:`).replace(/\s+$/,``)})}case`journey`:return Vk(e,n,e=>e.replace(/^(\s*)[^:]+(?=\s*:)/,`$1${i.replace(/:/g,` -`)}`));case`git`:return Vk(e,n,e=>{let t=i.replace(/"/g,`'`);return/\bid\s*:/i.test(e)?e.replace(/\bid\s*:\s*"[^"]*"/i,`id: "${t}"`):`${e.trimEnd()} id: "${t}"`});case`pie`:return Vk(e,n,e=>e.replace(/"[^"]+"/,`"${i.replace(/"/g,`'`)}"`));case`quadrant`:return Vk(e,n,e=>e.replace(/^(\s*)"?[^":]+?"?(?=\s*:)/,`$1"${i.replace(/"/g,`'`)}"`));case`sankey`:return $O(e,QO(e).map(e=>{let t=Ik(e);return t?(t[0]===n.id&&(t[0]=i),t[1]===n.id&&(t[1]=i),`${t[0]},${t[1]},${t[2]}`):e}));case`xy`:return ek(e,`Mermaid XY series do not have authored labels; edit the chart title and axes in Properties.`);case`requirement`:{let t=uk(n),r=Number(n.origin?.endLine??t??-1);if(t===null||r<t)return ek(e,`This requirement can only be changed in Source.`);let a=QO(e),o=a.findIndex((e,n)=>n>t&&n<r&&/^\s*text\s*:/.test(e));return o>=0?a[o]=`${tk(a[o])}text: ${i}`:a.splice(t+1,0,`${tk(a[t])} text: ${i}`),$O(e,a)}}}function Wk(e,t,n){if(t.kind===`sankey`)return ek(e,`Duplicate a Sankey flow instead of an implicit flow node.`);let r=uk(n);if(r===null)return ek(e,`This ${t.nodeNoun.toLowerCase()} can only be duplicated in Source.`);let i=QO(e),a=sk(t.nodes,rk(n.id)?`${n.id}_copy`:`node`),o=i[r],s=r+1;switch(t.kind){case`sequence`:o=` participant ${a} as ${n.label} copy`;break;case`state`:o=` state "${n.label.replace(/"/g,`'`)} copy" as ${a}`;break;case`class`:o=` class ${a}["${n.label.replace(/"/g,`'`)} copy"]`;break;case`er`:o=` ${a} {
|
|
476
|
+
string name
|
|
477
|
+
}`,s=Number(n.origin?.endLine??r)+1;break;case`mindmap`:o=`${String(n.origin?.prefix??``)}${n.label} copy${String(n.origin?.suffix??``)}`;break;case`c4`:case`architecture`:case`kanban`:o=ok(o,n.id,a).replace(n.label,`${n.label} copy`);break;case`gantt`:{let e=String(n.origin?.parts??`1d`),t=n.origin?.generatedId?`${a}, ${e}`:ok(e,n.id,a);o=`${tk(o)}${n.label} copy :${t}`;break}case`timeline`:o=`${String(n.origin?.period??`New period`)} : ${n.label} copy`;break;case`journey`:o=`${tk(o)}${n.label} copy: ${String(n.origin?.score??`3`)}: ${String(n.origin?.actors??`User`)}`;break;case`git`:o=` commit id: "${n.label.replace(/"/g,`'`)} copy"`;break;case`pie`:o=` "${n.label.replace(/"/g,`'`)} copy" : ${String(n.origin?.value??`1`)}`;break;case`quadrant`:o=` "${n.label.replace(/"/g,`'`)} copy": [${String(n.origin?.x??`0.5`)}, ${String(n.origin?.y??`0.5`)}]`;break;case`xy`:o=`${tk(o)}${String(n.origin?.series??`line`)} ${String(n.origin?.values??`[0]`)}`;break;case`requirement`:o=` ${String(n.origin?.declaration??`requirement`)} ${a} {
|
|
478
|
+
${n.origin?.declaration===`element`?`type: system`:`id: ${t.nodes.length+1}
|
|
479
|
+
text: ${n.label} copy
|
|
480
|
+
risk: medium
|
|
481
|
+
verifymethod: test`}
|
|
482
|
+
}`,s=Number(n.origin?.endLine??r)+1;break}i.splice(s,0,o);let c=$O(e,i);return c.ok?{...c,nodeId:a}:c}function Gk(e,t,n){let r=uk(n);if(r===null)return ek(e,`This ${t.nodeNoun.toLowerCase()} can only be deleted in Source.`);let i=QO(e);if(t.kind===`mindmap`){let t=tk(i[r]).length,n=r+1;for(;n<i.length&&(!i[n].trim()||tk(i[n]).length>t);)n+=1;return i.splice(r,n-r),$O(e,i)}if(t.kind===`timeline`){let t=i[r].split(`:`),a=Number(n.origin?.segment??0);return t[a+1]===void 0?ek(e,`This timeline event can only be deleted in Source.`):(t.splice(a+1,1),t.length<=1?i.splice(r,1):i[r]=t.map(e=>e.trim()).join(` : `).trimEnd(),$O(e,i))}if(t.kind===`requirement`||t.kind===`er`){let e=Number(n.origin?.endLine??r);i.splice(r,Math.max(1,e-r+1))}else i.splice(r,1);return[`sequence`,`state`,`class`,`er`,`c4`,`architecture`,`requirement`].includes(t.kind)?$O(e,i.filter(e=>!ak(e,n.id))):t.kind===`gantt`?$O(e,i.map(e=>e.replace(RegExp(`after\\s+([^,]*\\b)?${ik(n.id)}\\b\\s*`,`g`),(e,t=``)=>t?`after ${t.trim()} `:``))):t.kind===`sankey`?$O(e,i.filter(e=>{let t=Ik(e);return!t||t[0]!==n.id&&t[1]!==n.id})):$O(e,i)}function Kk(e,t,n,r){let i=n?t.nodes.find(e=>e.id===n):t.nodes[0],a=t.nodes.find(e=>e.id===r);if(!i||!a||i.id===a.id)return ek(e,`Choose two different mind-map topics.`);let o=QO(e),s=uk(i),c=uk(a);if(s===null||c===null)return ek(e,`This hierarchy can only be changed in Source.`);let l=tk(o[c]).length,u=c+1;for(;u<o.length&&tk(o[u]).length>l;)u+=1;if(s>=c&&s<u)return ek(e,`A topic cannot become a child of its own descendant.`);let d=o.splice(c,u-c),f=s>c?s-d.length:s,p=tk(o[f]).length,m=f+1;for(;m<o.length&&tk(o[m]).length>p;)m+=1;let h=p+2-l,g=d.map(e=>`${` `.repeat(Math.max(0,tk(e).length+h))}${e.trimStart()}`);return o.splice(m,0,...g),$O(e,o)}function qk(e,t,n,r){if(n===r)return ek(e,`Choose two different items.`);if(t.edges.some(e=>e.source===n&&e.target===r))return ek(e,`Those items are already connected.`);switch(t.kind){case`sequence`:return vk(e,` ${n}->>${r}: New message`);case`state`:return vk(e,` ${n} --> ${r} : transition`);case`class`:return vk(e,` ${n} --> ${r} : relationship`);case`er`:return vk(e,` ${n} ||--o{ ${r} : relates_to`);case`mindmap`:return Kk(e,t,n,r);case`c4`:return vk(e,` Rel(${n}, ${r}, "Uses")`);case`architecture`:return vk(e,` ${n}:R --> L:${r}`);case`gantt`:{let i=t.nodes.find(e=>e.id===n),a=t.nodes.find(e=>e.id===r);if(!i||!a)return ek(e,`One of the tasks no longer exists.`);let o=QO(e),s=n;if(i.origin?.generatedId){s=sk(t.nodes,`task`);let n=uk(i);if(n===null)return ek(e,`The source task can only be connected in Source.`);let r=o[n],a=r.indexOf(`:`),c=r.slice(0,a+1),l=r.slice(a+1).split(`,`).map(e=>e.trim()).filter(Boolean),u=l.findIndex(e=>!Dk.has(e));l.splice(Math.max(0,u),0,s),o[n]=`${c}${l.join(`, `)}`}let c=uk(a);return c===null?ek(e,`The target task can only be connected in Source.`):(o[c]=(e=>{let t=e.indexOf(`:`),n=e.slice(0,t+1),r=e.slice(t+1).split(`,`).map(e=>e.trim()).filter(Boolean),i=r.findIndex(e=>e.startsWith(`after `));if(i>=0)r[i]=`${r[i]} ${s}`;else{let e=r[r.length-1]??`1d`,t=r.slice(0,-1).filter(e=>!/^\d{4}-\d{2}-\d{2}/.test(e));r.splice(0,r.length,...t,`after ${s}`,e)}return`${n}${r.join(`, `)}`})(o[c]),$O(e,o))}case`sankey`:{let i=t.nodes.find(e=>e.id===n),a=t.nodes.find(e=>e.id===r);return!i||!a?ek(e,`The Sankey endpoints no longer exist.`):vk(e,`${i.label},${a.label},1`)}case`requirement`:return vk(e,` ${n} - satisfies -> ${r}`);default:return ek(e,t.capabilities.connectionHint??`Mermaid ${t.kind} diagrams do not define explicit connections.`)}}function Jk(e,t,n){if(t.kind===`mindmap`)return Kk(e,t,null,n.target);if(t.kind===`gantt`){let r=t.nodes.find(e=>e.id===n.target);return r?Vk(e,r,e=>{let t=RegExp(`(after\\s+)([^,]*)`);return e.replace(t,(e,t,r)=>{let i=r.split(/\s+/).filter(e=>e&&e!==n.source);return i.length?`${t}${i.join(` `)}`:``}).replace(/,\s*,/g,`,`).replace(/:\s*,/,`:`)}):ek(e,`The dependent task no longer exists.`)}let r=uk(n);if(r===null)return ek(e,`This ${t.edgeNoun.toLowerCase()} can only be removed in Source.`);let i=QO(e);return i.splice(r,1),$O(e,i)}function Yk(e,t,n,r){let i=r.trim(),a=uk(n);if(a===null)return ek(e,`This ${t.edgeNoun.toLowerCase()} can only be labeled in Source.`);let o=QO(e),s=o[a];switch(t.kind){case`sequence`:case`state`:case`class`:case`er`:o[a]=s.replace(/(?:\s*:\s*.*)?$/,i?` : ${i.replace(/:/g,` -`)}`:``);break;case`c4`:o[a]=s.replace(/(Rel(?:_[A-Z]+)?\s*\(\s*[^,]+\s*,\s*[^,]+\s*,\s*)"[^"]*"/i,`$1"${i.replace(/"/g,`'`)}"`);break;case`sankey`:{if(!Number.isFinite(Number(i))||Number(i)<0)return ek(e,`A Sankey flow weight must be a non-negative number.`);let t=Ik(s);if(!t)return ek(e,`This Sankey row can only be edited in Source.`);o[a]=`${t[0]},${t[1]},${i}`;break}case`requirement`:{let t=[`contains`,`copies`,`derives`,`satisfies`,`verifies`,`refines`,`traces`];if(!t.includes(i))return ek(e,`Requirement relationships must be one of: ${t.join(`, `)}.`);o[a]=s.replace(/-\s*\w+\s+->/,`- ${i} ->`);break}default:return ek(e,`Mermaid ${t.kind} ${t.edgeNoun.toLowerCase()} labels are not part of this grammar.`)}return $O(e,o)}function Xk(e,t,n,r){let i=QO(e),a=gk(i);if(n===`showData`&&t.kind===`pie`)return i[a]=i[a].replace(/\s+showData\b/i,``),r===!0&&(i[a]=`${i[a].trimEnd()} showData`),$O(e,i);if(n===`autonumber`&&t.kind===`sequence`){let t=i.findIndex(e=>/^\s*autonumber\s*$/i.test(e));return r===!0&&t<0&&i.splice(a+1,0,` autonumber`),r===!1&&t>=0&&i.splice(t,1),$O(e,i)}let o={xAxis:`x-axis`,yAxis:`y-axis`,quadrant1:`quadrant-1`,quadrant2:`quadrant-2`,quadrant3:`quadrant-3`,quadrant4:`quadrant-4`}[n]??n,s=RegExp(`^\\s*${o}\\b`,`i`),c=i.findIndex(e=>s.test(e)),l=String(r).trim();if(!l)return c>=0&&i.splice(c,1),$O(e,i);if(n===`direction`&&!JO.includes(l))return ek(e,`Choose a supported diagram direction.`);let u=t.kind===`xy`&&n===`title`?` title "${l.replace(/"/g,`'`)}"`:` ${o} ${l}`;return c>=0?i[c]=`${tk(i[c])}${u.trimStart()}`:i.splice(a+1,0,u),$O(e,i)}function Zk(e,t,n,r){let i=r.trim();if(!i)return ek(e,`A Mermaid text label cannot be empty.`);if(i===n.label)return ek(e,`The label is unchanged.`);if(n.target===`node`){let r=t.nodes.find(e=>e.id===n.targetId);return r?Uk(e,t,r,i):ek(e,`The selected Mermaid node no longer exists.`)}if(n.target===`edge`){let r=t.edges.find(e=>e.id===n.targetId);return r?Yk(e,t,r,i):ek(e,`The selected Mermaid connection no longer exists.`)}if(n.target===`property`)return Xk(e,t,n.targetId,i);let a=uk(n);if(a===null)return ek(e,`This label can only be changed in Source.`);let o=QO(e),s=o[a];switch(n.origin?.role){case`section`:o[a]=`${tk(s)}section ${i.replace(/\r?\n/g,` `)}`;break;case`bracket-label`:o[a]=s.replace(/\[[^\]]*]/,`[${i.replace(/]/g,``)}]`);break;case`line-content`:o[a]=`${tk(s)}${i.replace(/\r?\n/g,` `)}`;break;case`after-colon`:{let t=s.indexOf(`:`);if(t<0)return ek(e,`This label can only be changed in Source.`);o[a]=`${s.slice(0,t+1)} ${i.replace(/\r?\n/g,` `)}`;break}case`timeline-period`:{let t=s.indexOf(`:`);if(t<0)return ek(e,`This timeline period can only be changed in Source.`);o[a]=`${tk(s)}${i.replace(/:/g,` -`)} ${s.slice(t)}`;break}case`git-branch`:{if(!rk(i))return ek(e,`Choose a Mermaid-safe branch name.`);let t=String(n.origin?.branch??n.label);return $O(e,o.map(e=>/^\s*(branch|checkout|merge)\b/i.test(e)?ok(e,t,i):e))}case`axis-endpoint`:{let t=/^(\s*(?:x-axis|y-axis)\s+)(.+?)(\s*-->\s*)(.+?)\s*$/i.exec(s);if(!t)return ek(e,`This axis label can only be changed in Source.`);o[a]=n.origin?.side===`start`?`${t[1]}${i}${t[3]}${t[4]}`:`${t[1]}${t[2]}${t[3]}${i}`;break}case`quoted-label`:if(!/"[^"]*"/.test(s))return ek(e,`This label can only be changed in Source.`);o[a]=s.replace(/"[^"]*"/,`"${i.replace(/"/g,`'`)}"`);break;case`xy-category`:{let t=/^(.*\[)([^\]]*)(].*)$/.exec(s);if(!t)return ek(e,`This category can only be changed in Source.`);let r=t[2].split(`,`).map(e=>e.trim()),c=Number(n.origin?.itemIndex??-1);if(c<0||c>=r.length)return ek(e,`This category can only be changed in Source.`);r[c]=i.replace(/[,\]]/g,` `),o[a]=`${t[1]}${r.join(`, `)}${t[3]}`;break}default:return ek(e,`This label can only be changed in Source.`)}return $O(e,o)}function Qk(e,t,n){if(!n.deletable)return ek(e,`This label is required by its Mermaid source construct.`);if(n.target===`node`){let r=t.nodes.find(e=>e.id===n.targetId);return r?Gk(e,t,r):ek(e,`The selected Mermaid node no longer exists.`)}if(n.target===`edge`){let r=t.edges.find(e=>e.id===n.targetId);return r?Yk(e,t,r,``):ek(e,`The selected Mermaid connection no longer exists.`)}if(n.target===`property`)return Xk(e,t,n.targetId,``);let r=uk(n);if(r===null)return ek(e,`This label can only be removed in Source.`);let i=QO(e);return i.splice(r,1),$O(e,i)}var $k=null,eA={startOnLoad:!1,securityLevel:`strict`,suppressErrorRendering:!0,deterministicIds:!1,logLevel:`error`};function tA(e){let t=globalThis,n=(t.__squisqMermaidWorkQueue??Promise.resolve()).then(e,e);return t.__squisqMermaidWorkQueue=n.then(()=>void 0,()=>void 0),n}async function nA(){return $k||=Ut(async()=>{let{default:e}=await import(`./mermaid.core-CJfks21t.js`);return{default:e}},__vite__mapDeps([65,2,66,67,1,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84])).then(({default:e})=>e).catch(e=>{throw $k=null,e}),$k}async function rA(e,t,n,r=at){return tA(async()=>{let i=await nA();i.initialize({...eA,theme:`base`,themeVariables:Bt(r)});let a=await iA(i,t),{svg:o,diagramType:s}=await i.render(e,t,n);return a?{svg:o,diagramType:s,model:a}:{svg:o,diagramType:s}})}async function iA(e,t){let n=e.mermaidAPI?.getDiagramFromText;if(typeof n!=`function`)return null;try{let e=await n(t);if(e.type!==`flowchart`&&e.type!==`flowchart-v2`)return Bk(t);let r=e.db;if(typeof r.getVertices!=`function`||typeof r.getEdges!=`function`)return null;let i=[];for(let[e,t]of r.getVertices()){let n=typeof t.id==`string`?t.id:e;n&&i.push({id:n,domId:typeof t.domId==`string`?t.domId:n,label:typeof t.text==`string`?t.text:n,shape:KO(typeof t.type==`string`?t.type:void 0),classes:Array.isArray(t.classes)?t.classes.filter(e=>typeof e==`string`):[]})}let a=r.getEdges().map((e,t)=>({id:typeof e.id==`string`?e.id:`edge-${t}`,source:typeof e.start==`string`?e.start:``,target:typeof e.end==`string`?e.end:``,label:typeof e.text==`string`?e.text:``,...typeof e.type==`string`?{type:e.type}:{},...typeof e.stroke==`string`?{stroke:e.stroke}:{},...typeof e.isUserDefinedId==`boolean`?{userDefinedId:e.isUserDefinedId}:{}})).filter(e=>e.source&&e.target),o=r.getDirection?.();return{kind:`flowchart`,direction:o===`TB`||o===`TD`||o===`BT`||o===`RL`||o===`LR`?o:`TB`,nodes:i,edges:a}}catch{return null}}function aA(e){return(e instanceof Error?e.message:String(e)).split(/\r?\n/).map(e=>e.trimEnd()).filter(Boolean).slice(0,8).join(`
|
|
483
|
+
`)||`Unknown Mermaid rendering error.`}var oA={light:{background:`#ffffff`,backgroundLight:`#f5f5f5`,text:`#1f2937`,textMuted:`#4b5563`},dark:{background:`#111827`,backgroundLight:`#1f2937`,text:`#e5e7eb`,textMuted:`#9ca3af`}};function sA(e){return Je(e.colors.background)<.5?`dark`:`light`}function cA(e,t){return{...e,colors:{...e.colors,...oA[t]}}}function lA(e){let t=e?.closest(`[data-theme-inheritance]`)?.dataset.themeInheritance;return{scheme:e?.closest(`[data-theme]`)?.dataset.theme===`dark`?`dark`:`light`,inheritsThemeColors:t===`fonts-colors`}}function uA(e,t){return e.inheritsThemeColors?t:cA(t,e.scheme)}function dA(e,t){let[n,r]=(0,G.useState)(()=>lA(e));return(0,G.useEffect)(()=>{let t=()=>r(t=>{let n=lA(e);return t.scheme===n.scheme&&t.inheritsThemeColors===n.inheritsThemeColors?t:n});if(t(),typeof MutationObserver>`u`)return;let n=new MutationObserver(t),i=new Set([e?.closest(`[data-theme]`),e?.closest(`[data-theme-inheritance]`)].filter(e=>!!e));for(let e of i)n.observe(e,{attributes:!0,attributeFilter:[`data-theme`,`data-theme-inheritance`]});return()=>n.disconnect()},[e]),(0,G.useMemo)(()=>uA(n,t),[n,t])}var fA=0;function pA(e,t){if(!(e instanceof Element))return!1;let n=e.closest(`button, input, textarea, select, a, [contenteditable="true"]`);return!!(n&&t.contains(n))}function mA(e,t){return e===t||e.endsWith(`-${t}`)}function hA(e){let t=e?.querySelector(`svg`)?.getAttribute(`viewBox`);if(!t)return null;let n=t.trim().split(/[\s,]+/).map(Number),r=n[2],i=n[3];return Number.isFinite(r)&&Number.isFinite(i)&&r>0&&i>0?{width:r,height:i}:null}function gA({source:e,theme:t,maximized:n=!1,onToggleMaximize:r,selection:i,renaming:a,selectedNodeId:o=null,selectedEdgeId:s=null,selectedTextId:c=null,renamingNodeId:l=null,renamingEdgeId:u=null,renamingTextId:d=null,connectSourceId:f=null,connecting:p=!1,onModelChange:m,onSelect:h,onSelectNode:g,onSelectEdge:_,onSelectText:v,onNodeAction:y,onEditEdgeLabel:b,onEditText:x,onCommitRename:S,onCommitEdgeLabel:C,onCommitText:w,onCancelRename:T,onCancelEdgeLabel:E,onCancelText:D,onDisconnectEdge:O,onDeleteText:k}){let A=i===void 0?o:i?.kind===`node`?i.id:null,j=i===void 0?s:i?.kind===`edge`?i.id:null,M=i===void 0?c:i?.kind===`text`?i.id:null,N=a===void 0?l:a?.kind===`node`?a.id:null,P=a===void 0?u:a?.kind===`edge`?a.id:null,F=a===void 0?d:a?.kind===`text`?a.id:null,I=(0,G.useRef)(null),L=(0,G.useRef)(null),ee=(0,G.useRef)(null),te=(0,G.useRef)(null),R=(0,G.useId)(),[ne,re]=(0,G.useState)(``),[z,ie]=(0,G.useState)(null),[ae,oe]=(0,G.useState)(`mermaid`),[se,ce]=(0,G.useState)(``),[le,B]=(0,G.useState)(!0),[ue,V]=(0,G.useState)(1),[de,fe]=(0,G.useState)(`fit`),[H,pe]=(0,G.useState)(null),[me,U]=(0,G.useState)(null),[he,ge]=(0,G.useState)({x:0,y:0}),[_e,W]=(0,G.useState)(!1),[ve,ye]=(0,G.useState)(null),[be,xe]=(0,G.useState)(``);(0,G.useEffect)(()=>{if(!_e)return;let e=()=>{te.current=null,W(!1)},t=t=>{let n=te.current;if(n){if(!(t.buttons&2)){e();return}ge({x:Math.round(n.originX+t.clientX-n.startX),y:Math.round(n.originY+t.clientY-n.startY)}),t.preventDefault()}};return window.addEventListener(`mousemove`,t,!0),window.addEventListener(`mouseup`,e,!0),window.addEventListener(`blur`,e),()=>{window.removeEventListener(`mousemove`,t,!0),window.removeEventListener(`mouseup`,e,!0),window.removeEventListener(`blur`,e)}},[_e]),(0,G.useEffect)(()=>{let n=!0,r=`squisq-mermaid-svg-${++fA}`;return B(!0),ce(``),rA(r,e,void 0,t).then(e=>{if(!n)return;let t=e.model??null;re(e.svg),ie(t),m?.(t),oe(e.diagramType)}).catch(e=>{n&&(re(``),ie(null),m?.(null),ce(aA(e)))}).finally(()=>{n&&B(!1)}),()=>{n=!1}},[e,m,t]),(0,G.useLayoutEffect)(()=>{let e=L.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect(),n=window.getComputedStyle(e),r=(Number.parseFloat(n.paddingLeft)||0)+(Number.parseFloat(n.paddingRight)||0),i=(Number.parseFloat(n.paddingTop)||0)+(Number.parseFloat(n.paddingBottom)||0),a={width:Math.max(0,t.width-r),height:Math.max(0,t.height-i)};U(e=>e?.width===a.width&&e.height===a.height?e:a)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),(0,G.useLayoutEffect)(()=>{pe(hA(I.current))},[ne]);let Se=H&&me?ux(H,me):1,Ce=(0,G.useCallback)(()=>{fe(`fit`),V(Se),ge({x:0,y:0})},[Se]);(0,G.useLayoutEffect)(()=>{de===`fit`&&(V(Se),ge({x:0,y:0}))},[Se,de]);let we=(0,G.useCallback)(e=>{let t=I.current,n=z?.nodes.find(t=>t.id===e);return!t||!n?null:[...t.querySelectorAll(`[data-squisq-node-id]`)].find(t=>t.getAttribute(`data-squisq-node-id`)===e)||([...t.querySelectorAll(`g.node`)].find(e=>mA(e.id,n.domId))??null)},[z]),Te=(0,G.useCallback)(e=>{let t=I.current;return t?[...t.querySelectorAll(`[data-id], [data-squisq-edge-id]`)].filter(t=>t.getAttribute(`data-id`)===e||t.getAttribute(`data-squisq-edge-id`)===e):[]},[]),Ee=(0,G.useCallback)(e=>{let t=I.current;return t?[...t.querySelectorAll(`[data-squisq-text-id]`)].find(t=>t.getAttribute(`data-squisq-text-id`)===e)??null:null},[]),De=(0,G.useCallback)(()=>{let e=I.current,t=M?Ee(M):A?we(A):j?Te(j)[0]:null;if(!e||!t){ye(null);return}let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=r.top-n.top,a=i<52?`below`:`above`;ye({left:Math.min(Math.max(r.left-n.left+r.width/2,82),Math.max(n.width-82,82)),top:a===`above`?i:r.bottom-n.top,placement:a,editorLeft:r.left-n.left+r.width/2,editorTop:i+r.height/2,editorWidth:Math.min(420,Math.max(140,r.width-20))})},[Te,we,Ee,j,A,M]);(0,G.useLayoutEffect)(()=>{let e=N?z?.nodes.find(e=>e.id===N):null,t=P?z?.edges.find(e=>e.id===P):null,n=F?z&&BO(z).find(e=>e.id===F):null,r=e?.label??t?.label??n?.label;if(r===void 0)return;xe(r);let i=window.requestAnimationFrame(()=>{ee.current?.focus(),ee.current?.select()});return()=>window.cancelAnimationFrame(i)},[z,P,N,F]),(0,G.useLayoutEffect)(()=>{let e=I.current;if(!e||!z){ye(null);return}for(let t of e.querySelectorAll(`[data-squisq-text-id]`))t.removeAttribute(`data-squisq-text-id`),t.classList.remove(`squisq-mermaid-text-selected`);for(let t of e.querySelectorAll(`[data-squisq-node-id]`))t.removeAttribute(`data-squisq-node-id`),t.classList.remove(`squisq-mermaid-node-selected`,`squisq-mermaid-connect-source`);let t=new Set,n=[...e.querySelectorAll(`g.node`)];for(let e of n){let n=z.nodes.find(t=>mA(e.id,t.domId));n&&(t.add(e),e.dataset.squisqNodeId=n.id,e.setAttribute(`role`,`button`),e.setAttribute(`tabindex`,`0`),e.setAttribute(`aria-label`,`${n.label}, ${n.shape} Mermaid node`),e.classList.toggle(`squisq-mermaid-node-selected`,n.id===A),e.classList.toggle(`squisq-mermaid-connect-source`,n.id===f))}let r=[...e.querySelectorAll(`text, foreignObject`)],i=new Set;for(let e of z.nodes){if([...t].some(t=>t.getAttribute(`data-squisq-node-id`)===e.id))continue;let n=r.find(t=>!i.has(t)&&t.textContent?.trim()===e.label.trim());if(!n)continue;i.add(n);let a=n.closest(`g`),o=a&&a.querySelectorAll(`text, foreignObject`).length<=2?a:n;t.add(o),o.setAttribute(`data-squisq-node-id`,e.id),o.setAttribute(`role`,`button`),o.setAttribute(`tabindex`,`0`),o.setAttribute(`aria-label`,`${e.label}, Mermaid ${z.kind} item`),o.classList.toggle(`squisq-mermaid-node-selected`,e.id===A),o.classList.toggle(`squisq-mermaid-connect-source`,e.id===f)}let a=new Set;for(let e of BO(z)){let t=r.find(t=>!a.has(t)&&t.textContent?.trim()===e.label.trim());t&&(a.add(t),t.setAttribute(`data-squisq-text-id`,e.id),t.setAttribute(`role`,`button`),t.setAttribute(`tabindex`,`0`),t.setAttribute(`aria-label`,`${e.label}, editable Mermaid text`),t.classList.toggle(`squisq-mermaid-text-selected`,e.id===M))}for(let t of e.querySelectorAll(`.squisq-mermaid-edge-hit-target`))t.remove();for(let t of e.querySelectorAll(`path.flowchart-link`)){let e=t.cloneNode(!1),n=z.edges.find(e=>e.id===t.dataset.id);if(e.removeAttribute(`id`),e.removeAttribute(`marker-start`),e.removeAttribute(`marker-mid`),e.removeAttribute(`marker-end`),e.setAttribute(`class`,`squisq-mermaid-edge-hit-target`),n){let t=z.nodes.find(e=>e.id===n.source)?.label??n.source,r=z.nodes.find(e=>e.id===n.target)?.label??n.target;e.setAttribute(`role`,`button`),e.setAttribute(`tabindex`,`0`),e.setAttribute(`aria-label`,`Connection from ${t} to ${r}${n.label?`: ${n.label}`:``}`)}else e.setAttribute(`aria-hidden`,`true`);t.after(e)}z.kind!==`flowchart`&&[...e.querySelectorAll(`path[marker-end], path[marker-start], line[marker-end], line[marker-start], polyline[marker-end], polyline[marker-start]`)].filter(e=>!e.closest(`defs`)).slice(0,z.edges.length).forEach((e,t)=>{let n=z.edges[t];e.setAttribute(`data-squisq-edge-id`,n.id);let r=e.cloneNode(!1);r.removeAttribute(`id`),r.removeAttribute(`marker-start`),r.removeAttribute(`marker-mid`),r.removeAttribute(`marker-end`),r.setAttribute(`class`,`squisq-mermaid-edge-hit-target`),r.setAttribute(`data-squisq-edge-id`,n.id),r.setAttribute(`role`,`button`),r.setAttribute(`tabindex`,`0`);let i=z.nodes.find(e=>e.id===n.source)?.label??n.source,a=z.nodes.find(e=>e.id===n.target)?.label??n.target;r.setAttribute(`aria-label`,`${z.kind} connection from ${i} to ${a}`),e.after(r)});for(let t of e.querySelectorAll(`.squisq-mermaid-edge-selected`))t.classList.remove(`squisq-mermaid-edge-selected`);if(j)for(let e of Te(j))e.classList.add(`squisq-mermaid-edge-selected`);De()},[f,Te,z,j,A,M,ne,De,ue]),(0,G.useEffect)(()=>{let e=L.current;if(!e)return;let t=()=>De();return e.addEventListener(`scroll`,t,{passive:!0}),window.addEventListener(`resize`,t),()=>{e.removeEventListener(`scroll`,t),window.removeEventListener(`resize`,t)}},[De]);let Oe=e=>e instanceof Element?e.closest(`[data-squisq-node-id]`)?.dataset.squisqNodeId??null:null,ke=e=>e instanceof Element?e.closest(`[data-squisq-text-id]`)?.dataset.squisqTextId??null:null,Ae=e=>{if(!(e instanceof Element)||!z)return null;let t=e.closest(`[data-id], [data-squisq-edge-id]`),n=t?.getAttribute(`data-squisq-edge-id`)??t?.getAttribute(`data-id`);return n&&z.edges.some(e=>e.id===n)?n:null},je=e=>{if(h){h(e);return}g?.(e?.kind===`node`?e.id:null),_?.(e?.kind===`edge`?e.id:null),v?.(e?.kind===`text`?e.id:null)},Me=e=>{let t=ke(e.target);if(t){je({kind:`text`,id:t});return}let n=Oe(e.target);if(n){je({kind:`node`,id:n});return}let r=Ae(e.target);if(r){je({kind:`edge`,id:r});return}je(null)},Ne=e=>{let t=ke(e.target);if(t){x?.(t);return}let n=Oe(e.target);if(n){z&&zO(z).renameNode&&y?.(`rename`,n);return}let r=Ae(e.target);r&&b?.(r)},Pe=e=>{let t=ke(e.target),n=Oe(e.target),r=Ae(e.target);t&&(e.key===`Enter`||e.key===` `)?(je({kind:`text`,id:t}),e.preventDefault()):t&&e.key===`F2`?(je({kind:`text`,id:t}),x?.(t),e.preventDefault()):t&&(e.key===`Delete`||e.key===`Backspace`)?((z&&BO(z).find(e=>e.id===t))?.deletable&&k?.(t),e.preventDefault()):n&&(e.key===`Enter`||e.key===` `)?(je({kind:`node`,id:n}),e.preventDefault()):n&&(e.key===`Delete`||e.key===`Backspace`)?(z&&zO(z).deleteNode&&y?.(`delete`,n),e.preventDefault()):r&&(e.key===`Enter`||e.key===` `)?(je({kind:`edge`,id:r}),e.preventDefault()):r&&e.key===`F2`?(je({kind:`edge`,id:r}),b?.(r),e.preventDefault()):r&&(e.key===`Delete`||e.key===`Backspace`)?(O?.(r),e.preventDefault()):e.key===`Escape`&&je(null)},Fe=e=>{fe(`manual`),V(t=>Math.min(3,Math.max(.02,Math.round((t+e)*100)/100)))},Ie=e=>{e.button!==2||pA(e.target,e.currentTarget)||(fe(`manual`),te.current={startX:e.clientX,startY:e.clientY,originX:he.x,originY:he.y},W(!0),e.preventDefault())},Le=N!==null&&N===A,Re=P!==null&&P===j,ze=F!==null&&F===M,Be=z?zO(z):null,Ve=z&&M?BO(z).find(e=>e.id===M)??null:null,He=()=>{(Le?S?.(N,be)??!0:Re?C?.(P,be)??!0:!ze||(w?.(F,be)??!0))||window.requestAnimationFrame(()=>ee.current?.focus())};return(0,K.jsxs)(`div`,{className:`squisq-mermaid-canvas`,"aria-label":`${ae} diagram editor`,"data-surface":sA(t),style:{background:t.colors.backgroundLight,color:t.colors.text},children:[(0,K.jsx)(Vx,{scale:ue,fit:de===`fit`,onZoomOut:()=>Fe(-.2),onZoomIn:()=>Fe(.2),onFit:Ce}),p&&(0,K.jsx)(`div`,{className:`squisq-mermaid-connect-hint`,children:f?`Choose a target node`:`Choose a source node`}),r&&(0,K.jsx)(`button`,{type:`button`,className:`squisq-diagram-maximize-btn`,onClick:r,"aria-label":n?`Restore diagram`:`Maximize diagram`,title:n?`Restore diagram`:`Maximize diagram`,children:(0,K.jsx)(q,{icon:n?`fa-solid fa-compress`:`fa-solid fa-expand`})}),(0,K.jsxs)(`div`,{ref:L,className:`squisq-mermaid-canvas-scroll`,"data-panning":_e||void 0,title:`Right-drag to pan · Ctrl/⌘ + wheel to zoom`,onMouseDown:Ie,onContextMenu:e=>{pA(e.target,e.currentTarget)||e.preventDefault()},onWheel:e=>{!e.ctrlKey&&!e.metaKey||(e.preventDefault(),Fe(e.deltaY>0?-.1:.1))},children:[le&&(0,K.jsx)(`div`,{className:`squisq-mermaid-status`,children:`Rendering Mermaid diagram…`}),!le&&se&&(0,K.jsxs)(`div`,{className:`squisq-mermaid-error`,role:`alert`,children:[(0,K.jsx)(`strong`,{children:`Mermaid could not render this source.`}),(0,K.jsx)(`pre`,{children:se}),(0,K.jsx)(`span`,{children:`Open Source to edit the code block without losing it.`})]}),!se&&ne&&(0,K.jsxs)(`div`,{ref:I,className:`squisq-mermaid-svg`,style:{width:H?`${H.width*ue}px`:`${ue*100}%`,transform:`translate3d(${he.x}px, ${he.y}px, 0)`},onClick:Me,onDoubleClick:Ne,onKeyDown:Pe,children:[(0,K.jsx)(`div`,{dangerouslySetInnerHTML:{__html:ne}}),ve&&(Le||Re||ze)&&(0,K.jsxs)(`form`,{className:`squisq-mermaid-inline-rename`,"aria-label":Le?`Edit Mermaid node label`:Re?`Edit Mermaid connection label`:`Edit Mermaid text`,contentEditable:!1,style:{left:ve.editorLeft,top:ve.editorTop,width:ve.editorWidth},onClick:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),onSubmit:e=>{e.preventDefault(),He()},children:[(0,K.jsx)(`input`,{ref:ee,type:`text`,value:be,required:Le||ze,spellCheck:!0,"aria-label":Le?`Mermaid node label`:Re?`Mermaid connection label`:`Mermaid text`,"aria-describedby":R,onChange:e=>xe(e.target.value),onBeforeInput:e=>e.stopPropagation(),onInput:e=>{e.stopPropagation(),xe(e.currentTarget.value)},onKeyUp:e=>e.stopPropagation(),onPaste:e=>e.stopPropagation(),onBlur:He,onKeyDown:e=>{if(e.stopPropagation(),e.key===`Enter`){e.preventDefault(),He();return}e.key===`Escape`&&(e.preventDefault(),Le?T?.():Re?E?.():D?.())}}),(0,K.jsx)(`span`,{id:R,"aria-hidden":`true`,children:Re?`Enter to save · leave blank to remove · Esc to cancel`:`Enter to save · Esc to cancel`})]}),ve&&A&&N!==A&&(0,K.jsxs)(`div`,{className:`squisq-mermaid-selection-actions`,role:`toolbar`,"aria-label":`Selected Mermaid node actions`,"data-placement":ve.placement,style:{left:ve.left,top:ve.top},onClick:e=>e.stopPropagation(),children:[Be?.renameNode&&(0,K.jsx)(_A,{icon:`fa-solid fa-pen`,label:`Rename node`,onClick:()=>y?.(`rename`,A)}),Be?.shape&&(0,K.jsx)(_A,{icon:`fa-solid fa-shapes`,label:`Change shape`,onClick:()=>y?.(`shape`,A)}),Be?.duplicateNode&&(0,K.jsx)(_A,{icon:`fa-solid fa-copy`,label:`Duplicate node`,onClick:()=>y?.(`duplicate`,A)}),Be?.connect&&(0,K.jsx)(_A,{icon:`fa-solid fa-link`,label:`Connect node`,onClick:()=>y?.(`connect`,A)}),Be?.deleteNode&&(0,K.jsx)(_A,{icon:`fa-solid fa-trash`,label:`Delete node`,danger:!0,onClick:()=>y?.(`delete`,A)})]}),ve&&j&&P!==j&&(0,K.jsxs)(`div`,{className:`squisq-mermaid-selection-actions`,role:`toolbar`,"aria-label":`Selected Mermaid connection actions`,"data-placement":ve.placement,style:{left:ve.left,top:ve.top},onClick:e=>e.stopPropagation(),children:[Be?.edgeLabel&&(0,K.jsx)(_A,{icon:`fa-solid fa-pen`,label:`Edit connection label`,onClick:()=>b?.(j)}),Be?.disconnect&&(0,K.jsx)(_A,{icon:`fa-solid fa-link-slash`,label:`Disconnect nodes`,danger:!0,onClick:()=>O?.(j)})]}),ve&&M&&F!==M&&(0,K.jsxs)(`div`,{className:`squisq-mermaid-selection-actions`,role:`toolbar`,"aria-label":`Selected Mermaid text actions`,"data-placement":ve.placement,style:{left:ve.left,top:ve.top},onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(_A,{icon:`fa-solid fa-pen`,label:`Edit text`,onClick:()=>x?.(M)}),Ve?.deletable&&(0,K.jsx)(_A,{icon:`fa-solid fa-trash`,label:Ve.target===`node`?`Delete node`:Ve.target===`edge`?`Remove label`:`Delete text`,danger:!0,onClick:()=>k?.(M)})]})]})]})]})}function _A({icon:e,label:t,danger:n=!1,onClick:r}){return(0,K.jsx)(`button`,{type:`button`,title:t,"aria-label":t,"data-danger":n||void 0,onClick:r,children:(0,K.jsx)(q,{icon:e})})}var vA=[`Basic`,`Process`,`Data`,`Documents`,`Symbols`],yA=360,bA=520,xA=6,SA=8;function CA({selected:e,onPick:t,onClose:n}){let[r,i]=(0,G.useState)(``),[a,o]=(0,G.useState)(null),s=(0,G.useRef)(null);(0,G.useEffect)(()=>{let e=e=>{let t=e.target;t?.closest(`.squisq-scene-block-toolbar`)||s.current&&!s.current.contains(t)&&n()},t=e=>{e.key===`Escape`&&n()};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[n]);let c=(0,G.useMemo)(()=>{let e=r.trim().toLowerCase();return vA.map(t=>({category:t,shapes:HO.filter(n=>n.category===t&&(!e||n.label.toLowerCase().includes(e)||n.id.includes(e)||`aliases`in n&&n.aliases.some(t=>t.includes(e))))})).filter(e=>e.shapes.length>0)},[r]);return(0,G.useLayoutEffect)(()=>{let e=s.current,t=e?.parentElement;if(!e||!t)return;let n=e.closest(`.squisq-editor-shell`),r=n?.querySelector(`.squisq-status-bar`),i=()=>{let e=t.getBoundingClientRect(),i=n?.getBoundingClientRect(),a=r?.getBoundingClientRect(),s=document.documentElement.clientWidth||window.innerWidth,c=document.documentElement.clientHeight||window.innerHeight,l=Math.max(SA,(i?.top??0)+SA),u=Math.min(c,a?.top??c)-SA,d=Math.min(bA,Math.floor(c*.7)),f=e.bottom+xA,p=Math.max(0,u-f),m=Math.max(0,e.top-xA-l),h=p<Math.min(d,220)&&m>p,g=Math.max(0,Math.min(d,Math.floor(h?m:p))),_=h?Math.max(l,e.top-xA-g):f,v=Math.max(0,Math.min(yA,s-SA*2)),y=t.closest(`.squisq-scene-side-toolbar`)?e.left-xA-v:e.left,b=Math.max(SA,Math.min(y,s-v-SA)),x={position:`fixed`,top:Math.round(_),left:Math.round(b),right:`auto`,width:Math.round(v),maxHeight:g};o(e=>e&&e.top===x.top&&e.left===x.left&&e.width===x.width&&e.maxHeight===x.maxHeight?e:x)};i();let a=typeof ResizeObserver>`u`?null:new ResizeObserver(i);return a?.observe(t),n&&a?.observe(n),r&&a?.observe(r),window.addEventListener(`resize`,i),window.addEventListener(`scroll`,i,!0),()=>{a?.disconnect(),window.removeEventListener(`resize`,i),window.removeEventListener(`scroll`,i,!0)}},[]),(0,K.jsxs)(`div`,{ref:s,className:`squisq-mermaid-shape-palette`,role:`dialog`,"aria-label":`Mermaid node shapes`,style:a??void 0,children:[(0,K.jsx)(`input`,{className:`squisq-mermaid-shape-search`,type:`search`,value:r,placeholder:`Search 48 Mermaid shapes…`,autoFocus:!0,onChange:e=>i(e.target.value)}),(0,K.jsxs)(`div`,{className:`squisq-mermaid-shape-scroll`,children:[c.map(n=>(0,K.jsxs)(`section`,{children:[(0,K.jsx)(`div`,{className:`squisq-mermaid-shape-heading`,children:n.category}),(0,K.jsx)(`div`,{className:`squisq-mermaid-shape-grid`,children:n.shapes.map(n=>(0,K.jsxs)(`button`,{type:`button`,className:`squisq-mermaid-shape-item${e===n.id?` squisq-mermaid-shape-item--selected`:``}`,onClick:()=>t(n.id),title:`${n.label} (${n.id})`,"aria-label":`${n.label} shape`,"aria-pressed":e===n.id,children:[(0,K.jsx)(wA,{shape:n.id}),(0,K.jsx)(`span`,{children:n.label})]},n.id))})]},n.category)),c.length===0&&(0,K.jsx)(`div`,{className:`squisq-mermaid-shape-empty`,children:`No matching Mermaid shape.`})]})]})}function wA({shape:e}){let t={fill:`none`,stroke:`currentColor`,strokeWidth:1.5};return e.includes(`circ`)||e===`circle`?(0,K.jsxs)(`svg`,{viewBox:`0 0 34 24`,"aria-hidden":`true`,children:[(0,K.jsx)(`ellipse`,{cx:`17`,cy:`12`,rx:`10`,ry:`9`,...t}),(e===`dbl-circ`||e===`fr-circ`||e===`cross-circ`)&&(0,K.jsx)(`ellipse`,{cx:`17`,cy:`12`,rx:`7`,ry:`6`,...t})]}):e===`diam`||e===`hourglass`||e===`bow-rect`?(0,K.jsx)(`svg`,{viewBox:`0 0 34 24`,"aria-hidden":`true`,children:(0,K.jsx)(`path`,{d:e===`diam`?`M17 2 31 12 17 22 3 12Z`:`M4 3 30 3 20 12 30 21 4 21 14 12Z`,...t})}):e===`tri`||e===`flip-tri`?(0,K.jsx)(`svg`,{viewBox:`0 0 34 24`,"aria-hidden":`true`,children:(0,K.jsx)(`path`,{d:e===`tri`?`M17 2 31 21 3 21Z`:`M3 3 31 3 17 22Z`,...t})}):e===`cloud`?(0,K.jsx)(`svg`,{viewBox:`0 0 34 24`,"aria-hidden":`true`,children:(0,K.jsx)(`path`,{d:`M8 20c-7 0-7-9-1-10C7 3 16 1 20 6c6-2 10 3 8 7 6 4 1 8-4 8Z`,...t})}):e===`cyl`||e===`h-cyl`||e===`lin-cyl`?(0,K.jsx)(`svg`,{viewBox:`0 0 34 24`,"aria-hidden":`true`,children:(0,K.jsx)(`path`,{d:`M5 5c0-4 24-4 24 0v14c0 4-24 4-24 0ZM5 5c0 4 24 4 24 0`,...t})}):e===`hex`||e.includes(`pent`)||e.startsWith(`trap`)?(0,K.jsx)(`svg`,{viewBox:`0 0 34 24`,"aria-hidden":`true`,children:(0,K.jsx)(`path`,{d:`M8 3h18l5 9-5 9H8l-5-9Z`,...t})}):(0,K.jsxs)(`svg`,{viewBox:`0 0 34 24`,"aria-hidden":`true`,children:[(0,K.jsx)(`rect`,{x:`3`,y:`4`,width:`28`,height:`16`,rx:e===`rounded`||e===`stadium`||e===`delay`?8:1,...t}),(e.startsWith(`lin-`)||e.startsWith(`fr-`)||e.startsWith(`div-`))&&(0,K.jsx)(`path`,{d:`M8 4v16M26 4v16`,...t})]})}function TA(e,t,n){if(!e.isEditable)return!1;let r=wj(e,t);return r!==null&&e.chain().command(({tr:e,state:t})=>{let i=e.doc.nodeAt(r);if(!i||!Cj(i)||i.textContent===n)return!1;let a=r+1,o=r+i.nodeSize-1;return n?e.replaceWith(a,o,t.schema.text(n)):e.delete(a,o),!0}).run()}function EA(e,t,n){return n.ok&&TA(e,t,n.source)}var DA=`%% squisq:node `,OA=`%% squisq:edge `,kA=/(?:<[-=.]+[ox>]?|[ox<]?[-=.]+[ox>]|~~~)/;function AA(e){return/^[A-Za-z_][A-Za-z0-9_-]*$/.test(e)}function jA(e){return encodeURIComponent(e)}function MA(e){return e.split(/\r?\n/)}function NA(e){return e.join(`
|
|
484
|
+
`)}function PA(e,t){let n=MA(e),r=[];for(let e=0;e<n.length;e+=1){if(n[e].trim()!==t){r.push(n[e]);continue}e+=1,r.length>0&&r[r.length-1]===``&&n[e+1]===``&&r.pop()}return NA(r)}function FA(e,t,n){let r=PA(e,t).replace(/[ \t]+$/gm,``);return`${r}${r.endsWith(`
|
|
485
|
+
|
|
486
|
+
`)?``:r.endsWith(`
|
|
487
|
+
`)?`
|
|
488
|
+
`:`
|
|
489
|
+
|
|
490
|
+
`} ${t}
|
|
491
|
+
${n}`}function IA(e){let t=e.classes.filter(e=>/^[A-Za-z_][A-Za-z0-9_-]*$/.test(e)).map(e=>`:::${e}`).join(``);return`${e.id}@{ shape: ${e.shape}, label: ${JSON.stringify(e.label)} }${t}`}function LA(e,t){return AA(t.id)?{ok:!0,source:FA(e,`${DA}${jA(t.id)}`,IA(t))}:{ok:!1,source:e,reason:`Node id \u201C${t.id}\u201D is not safe for structured source editing.`}}function RA(e,t,n){let r=n.trim();return r?r===t.label?{ok:!1,source:e,reason:`The label is unchanged.`}:LA(e,{...t,label:r}):{ok:!1,source:e,reason:`A node label cannot be empty.`}}function zA(e,t,n){return n===t.shape?{ok:!1,source:e,reason:`The shape is unchanged.`}:LA(e,{...t,shape:n})}function BA(e,t=`node`){let n=new Set(e.nodes.map(e=>e.id));if(!n.has(t))return t;let r=2;for(;n.has(`${t}${r}`);)r+=1;return`${t}${r}`}function VA(e,t,n=`rect`){let r=BA(t),i=LA(e,{id:r,label:`New node`,shape:n,classes:[]});return i.ok?{...i,nodeId:r}:i}function HA(e,t,n){let r=BA(t,`${n.id}_copy`),i=LA(e,{...n,id:r,label:`${n.label} copy`});return i.ok?{...i,nodeId:r}:i}function UA(e,t,n,r){return n===r?{ok:!1,source:e,reason:`Choose a different node to create a connection.`}:!AA(n)||!AA(r)?{ok:!1,source:e,reason:`One of the node ids is not safe to rewrite.`}:t.edges.some(e=>e.source===n&&e.target===r)?{ok:!1,source:e,reason:`Those nodes are already connected.`}:{ok:!0,source:FA(e,`${OA}${jA(n)} ${jA(r)}`,`${n} --> ${r}`)}}function WA(e){let t=``,n=!1,r=``;for(let i of e){if(n){r+=t?` `:i,n=!1;continue}if(i===`\\`){n=!0,r+=t?` `:i;continue}if(t){i===t&&(t=``),r+=` `;continue}if(i===`"`||i===`'`){t=i,r+=` `;continue}r+=i}return r}function GA(e){let t=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return RegExp(`(^|[^A-Za-z0-9_-])${t}(?=$|[^A-Za-z0-9_-])`)}function KA(e,t){return GA(t).test(WA(e))}function qA(e,t){return t.nodes.filter(t=>KA(e,t.id)).map(e=>e.id)}function JA(e){let t=WA(e).trim();return!t.startsWith(`%%`)&&kA.test(t)}function YA(e){return`|${JSON.stringify(e.replace(/\|/g,`|`))}|`}function XA(e,t,n){let r=WA(e),i=kA.exec(r);if(!i)return null;let a=i.index+i[0].length,o=e.slice(a),s=/^(\s*)\|([^|\r\n]*)\|/.exec(o);if(t.label&&!s)return null;let c=s?o.slice(s[0].length):o,l=n?YA(n):``;return`${e.slice(0,a)}${l}${c}`}function ZA(e){return/^\s*/.exec(e)?.[0]??``}function QA(e,t){return`${t}${IA(e)}`}function $A(e,t,n){if(!t.nodes.find(e=>e.id===n))return{ok:!1,source:e,reason:`The selected node no longer exists.`};if(!AA(n))return{ok:!1,source:e,reason:`This node id can only be edited in Source.`};let r=PA(e,`${DA}${jA(n)}`),i=MA(r),a=[],o=!1;for(let r=0;r<i.length;r+=1){let s=i[r],c=s.trim();if(c.startsWith(OA)&&c.slice(OA.length).split(/\s+/).map(decodeURIComponent).includes(n)){o=!0,r+=1;continue}if(!KA(s,n)){a.push(s);continue}if(JA(s)){let r=qA(s,t).filter(e=>e!==n);if(t.edges.some(e=>e.source!==n&&e.target!==n&&r.includes(e.source)&&r.includes(e.target)))return{ok:!1,source:e,reason:`This compact edge statement also contains unrelated connections; edit it in Source.`};let i=ZA(s);for(let e of r){let n=t.nodes.find(t=>t.id===e);n&&a.push(QA(n,i))}o=!0;continue}let l=/^(\s*class\s+)([^\s]+)(\s+.+)$/.exec(s);if(l){let e=l[2].split(`,`).filter(e=>e!==n);e.length>0&&a.push(`${l[1]}${e.join(`,`)}${l[3]}`),o=!0;continue}o=!0}return r=NA(a),o?{ok:!0,source:r.replace(/\n{3,}/g,`
|
|
492
|
+
|
|
493
|
+
`)}:{ok:!1,source:e,reason:`No safe source declaration was found for this node.`}}function ej(e,t,n){let r=PA(e,`${OA}${jA(n.source)} ${jA(n.target)}`);if(r!==e)return{ok:!0,source:r};let i=t.nodes.find(e=>e.id===n.source),a=t.nodes.find(e=>e.id===n.target);if(!i||!a)return{ok:!1,source:e,reason:`The connection endpoints no longer exist.`};let o=MA(e);for(let e=0;e<o.length;e+=1){let r=o[e];if(!JA(r)||!KA(r,n.source)||!KA(r,n.target)||qA(r,t).some(e=>e!==n.source&&e!==n.target))continue;let s=ZA(r);return o.splice(e,1,QA(i,s),QA(a,s)),{ok:!0,source:NA(o)}}return{ok:!1,source:e,reason:`This connection is part of a compact Mermaid statement; edit it in Source.`}}function tj(e,t,n,r){let i=r.trim();if(i===n.label.trim())return{ok:!1,source:e,reason:`The connection label is unchanged.`};if(!AA(n.source)||!AA(n.target))return{ok:!1,source:e,reason:`This connection can only be labeled in Source.`};let a=MA(e),o=`${OA}${jA(n.source)} ${jA(n.target)}`,s=a.findIndex(e=>e.trim()===o);if(s>=0){let t=s+1,r=a[t],o=r?XA(r,n,i):null;return o?(a[t]=o,{ok:!0,source:NA(a)}):{ok:!1,source:e,reason:`This connection label can only be changed in Source.`}}let c=a.map((e,t)=>({line:e,index:t})).filter(({line:e})=>!JA(e)||!KA(e,n.source)||!KA(e,n.target)?!1:!qA(e,t).some(e=>e!==n.source&&e!==n.target));if(c.length!==1)return{ok:!1,source:e,reason:`This connection is part of an ambiguous Mermaid statement; edit it in Source.`};let l=c[0],u=XA(l.line,n,i);return u?(a[l.index]=u,{ok:!0,source:NA(a)}):{ok:!1,source:e,reason:`This connection uses a label form that can only be changed in Source.`}}function nj(e,t){let n=/^(\s*)(flowchart|graph)\b[^\r\n]*$/m;if(!n.test(e))return{ok:!1,source:e,reason:`Only flowchart and graph headers have a direction.`};let r=e.replace(n,(e,n,r)=>`${n}${r} ${t}`);return r===e?{ok:!1,source:e,reason:`The direction is unchanged.`}:{ok:!0,source:r}}var rj=160,ij=420,aj=344,oj=360,sj=320,cj=520,lj=6,uj=8,dj=()=>()=>void 0,fj=()=>at;function pj(e,t){return e?.kind===t?.kind&&e?.id===t?.id}function mj(e,t){return!e||!t?!1:t.kind===`node`?e.nodes.some(e=>e.id===t.id):t.kind===`edge`?e.edges.some(e=>e.id===t.id):BO(e).some(e=>e.id===t.id)}function hj({editor:e,blockId:t,host:n,themeStore:r}){let i=jj(e,t),a=dA(n,(0,G.useSyncExternalStore)(r?.subscribe??dj,r?.getSnapshot??fj,r?.getSnapshot??fj)),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(null),[u,d]=(0,G.useState)(null),[f,p]=(0,G.useState)(!1),[m,h]=(0,G.useState)(null),[g,_]=(0,G.useState)(null),[v,y]=(0,G.useState)(``),[b,x]=(0,G.useState)(!1),[S,C]=(0,G.useState)(null),[w,T]=(0,G.useState)(null),E=(0,G.useRef)(null),D=w??S,O=(0,G.useCallback)(e=>{s(e),l(t=>mj(e,t)?t:null),d(t=>mj(e,t)?t:null),h(t=>t&&e?.nodes.some(e=>e.id===t)?t:null)},[]),k=(0,G.useCallback)(n=>{if(!n.ok)return y(n.reason??`This Mermaid statement can only be changed in Source.`),!1;let r=EA(e,t,n);return y(r?``:`The Mermaid code block changed before this edit was applied.`),r},[t,e]),A=o?BO(o):[],j=c?.kind===`node`?o?.nodes.find(e=>e.id===c.id)??null:null,M=c?.kind===`edge`?o?.edges.find(e=>e.id===c.id)??null:null,N=c?.kind===`text`?A.find(e=>e.id===c.id)??null:null,P=o?zO(o):null,F=o?VO(o):[],I=(0,G.useCallback)(e=>{let t={kind:`node`,id:e.id};l(t),_(null),d(t)},[]),L=(0,G.useCallback)(e=>{let t={kind:`edge`,id:e.id};l(t),_(null),d(t)},[]),ee=(0,G.useCallback)(e=>{let t={kind:`text`,id:e.id};l(t),_(null),d(t)},[]),te=(0,G.useCallback)((e,t)=>{let n=o?.nodes.find(t=>t.id===e);if(!i||!n)return!1;if(t.trim()===n.label)return d(null),!0;let r=k(o?.kind===`flowchart`?RA(i.source,n,t):o?Uk(i.source,o,n,t):{ok:!1,source:i.source});return r&&d(null),r},[k,i,o]),R=(0,G.useCallback)((e,t)=>{let n=o?.edges.find(t=>t.id===e);if(!i||!o||!n)return!1;if(t.trim()===n.label.trim())return d(null),!0;let r=k(o.kind===`flowchart`?tj(i.source,o,n,t):Yk(i.source,o,n,t));return r&&d(null),r},[k,i,o]),ne=(0,G.useCallback)((e,t)=>{let n=o?BO(o).find(t=>t.id===e):null;if(!i||!o||!n)return!1;if(t.trim()===n.label.trim())return d(null),!0;let r;if(o.kind!==`flowchart`)r=Zk(i.source,o,n,t);else if(n.target===`node`){let e=o.nodes.find(e=>e.id===n.targetId);r=e?RA(i.source,e,t):{ok:!1,source:i.source,reason:`The selected node no longer exists.`}}else if(n.target===`edge`){let e=o.edges.find(e=>e.id===n.targetId);r=e?tj(i.source,o,e,t):{ok:!1,source:i.source,reason:`The selected edge no longer exists.`}}else r={ok:!1,source:i.source,reason:`This label can only be edited in Source.`};let a=k(r);return a&&d(null),a},[k,i,o]),re=(0,G.useCallback)(e=>{p(!0),h(e??null),d(null),e&&l({kind:`node`,id:e}),y(``)},[]),z=(0,G.useCallback)(e=>{if(!f||!e||!o||!i){let t=e?{kind:`node`,id:e}:null;l(t),d(e=>pj(e,t)?e:null);return}if(!m){h(e),l({kind:`node`,id:e});return}k(o.kind===`flowchart`?UA(i.source,o,m,e):qk(i.source,o,m,e))&&(p(!1),h(null),l({kind:`node`,id:e}))},[k,m,f,i,o]),ie=(0,G.useCallback)(e=>{if(!e||e.kind===`node`){z(e?.id??null);return}if(f&&e.kind===`text`){let t=o?BO(o).find(t=>t.id===e.id):null;if(t?.target===`node`){z(t.targetId);return}}l(e),d(t=>pj(t,e)?t:null)},[f,z,o]),ae=(0,G.useCallback)((e,t)=>{if(!o||!i)return;let n=o.nodes.find(e=>e.id===t);if(!n)return;let r=zO(o);switch(l({kind:`node`,id:t}),d(null),e){case`rename`:r.renameNode&&I(n);break;case`shape`:r.shape&&_(`shape`);break;case`duplicate`:{if(!r.duplicateNode)break;let e=o.kind===`flowchart`?HA(i.source,o,n):Wk(i.source,o,n);k(e)&&e.nodeId&&l({kind:`node`,id:e.nodeId});break}case`connect`:r.connect&&re(t);break;case`delete`:if(!r.deleteNode)break;k(o.kind===`flowchart`?$A(i.source,o,t):Gk(i.source,o,n))&&(l(null),h(null));break}},[k,re,I,i,o]),oe=(0,G.useCallback)(e=>{if(!o||!i)return;let t=o.edges.find(t=>t.id===e);t&&k(o.kind===`flowchart`?ej(i.source,o,t):Jk(i.source,o,t))&&(l(null),d(null))},[k,i,o]),se=(0,G.useCallback)(e=>{if(!o||!i)return;let t=BO(o).find(t=>t.id===e);if(!t||!t.deletable)return;let n;if(o.kind!==`flowchart`)n=Qk(i.source,o,t);else if(t.target===`node`)n=$A(i.source,o,t.targetId);else if(t.target===`edge`){let e=o.edges.find(e=>e.id===t.targetId);n=e?tj(i.source,o,e,``):{ok:!1,source:i.source,reason:`The selected edge no longer exists.`}}else n={ok:!1,source:i.source,reason:`This label can only be removed in Source.`};k(n)&&(l(null),d(null))},[k,i,o]),ce=(0,G.useCallback)(e=>{e.preventDefault(),e.stopPropagation();let t=e.clientY,n=E.current?.getBoundingClientRect().height??D??ij,r=e=>Math.max(rj,Math.round(n+e-t)),i=document.body.style.cursor,a=document.body.style.userSelect;document.body.style.cursor=`ns-resize`,document.body.style.userSelect=`none`;let o=e=>T(r(e.clientY)),s=e=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),document.body.style.cursor=i,document.body.style.userSelect=a,T(null),C(r(e.clientY))};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},[D]);if((0,G.useEffect)(()=>{if(!v)return;let e=window.setTimeout(()=>y(``),7e3);return()=>window.clearTimeout(e)},[v]),!i)return null;let le=Tj(e,t),B=o!==null,ue=o&&o.kind!==`flowchart`?o.nodeNoun:`Node`,V=F.some(e=>e.id!==`direction`),de=(0,K.jsx)(qC,{actions:[{id:`add-node`,label:ue,icon:(0,K.jsx)(q,{icon:`fa-solid fa-plus`}),title:P?.addNode?`Add Mermaid ${ue.toLowerCase()}`:`This Mermaid grammar cannot represent an isolated node`,disabled:!P?.addNode,onClick:()=>{if(!o)return;let e=o.kind===`flowchart`?VA(i.source,o):Hk(i.source,o);k(e)&&e.nodeId&&l({kind:`node`,id:e.nodeId})}},{id:`connect`,label:`Connect`,icon:(0,K.jsx)(q,{icon:`fa-solid fa-link`}),title:f?`Cancel connection`:P?.connect?`Connect two Mermaid ${ue.toLowerCase()}s`:P?.connectionHint??`This Mermaid grammar has no explicit connections`,disabled:!P?.connect||c!==null&&c.kind!==`node`,active:f,onClick:()=>{f?(p(!1),h(null)):re(j?.id)}},{id:`rename-label`,label:M?`Label`:N?`Text`:`Rename`,icon:(0,K.jsx)(q,{icon:`fa-solid fa-pen`}),title:M?`Edit connection label`:N?`Edit Mermaid text`:`Rename Mermaid node`,disabled:(!j||!P?.renameNode)&&(!M||!P?.edgeLabel)&&!N,active:u!==null,onClick:()=>{j?I(j):M?L(M):N&&ee(N)}},{id:`node-shape`,label:`Shape`,icon:(0,K.jsx)(q,{icon:`fa-solid fa-shapes`}),title:P?.shape?`Change Mermaid node shape`:`Shapes are defined by this diagram grammar`,disabled:!j||!P?.shape,active:g===`shape`,onClick:()=>_(e=>e===`shape`?null:`shape`),popover:g===`shape`&&j?(0,K.jsx)(CA,{selected:j.shape,onClose:()=>_(null),onPick:e=>{k(zA(i.source,j,e)),_(null)}}):void 0},{id:`duplicate-node`,label:`Duplicate`,icon:(0,K.jsx)(q,{icon:`fa-solid fa-copy`}),disabled:!j||!P?.duplicateNode,onClick:()=>j&&ae(`duplicate`,j.id)},{id:`disconnect-edge`,label:`Disconnect`,icon:(0,K.jsx)(q,{icon:`fa-solid fa-link-slash`}),disabled:!M||!P?.disconnect,onClick:()=>M&&oe(M.id)},{id:`delete-node`,label:N?.target===`node`?`Delete node`:N?.target===`edge`?`Remove label`:N?`Delete text`:`Delete`,icon:(0,K.jsx)(q,{icon:`fa-solid fa-trash`}),danger:!0,disabled:(!j||!P?.deleteNode)&&(!N||!N.deletable),onClick:()=>{j?ae(`delete`,j.id):N&&se(N.id)}},{id:`direction`,label:`Direction`,icon:(0,K.jsx)(q,{icon:`fa-solid fa-arrows-up-down-left-right`}),disabled:!P?.direction,active:g===`direction`,onClick:()=>_(e=>e===`direction`?null:`direction`),popover:g===`direction`&&o?.direction?(0,K.jsx)(yj,{selected:o.direction,onClose:()=>_(null),onPick:e=>{k(o.kind===`flowchart`?nj(i.source,e):Xk(i.source,o,`direction`,e)),_(null)}}):void 0},{id:`diagram-properties`,label:`Properties`,icon:(0,K.jsx)(q,{icon:`fa-solid fa-sliders`}),title:`Edit Mermaid diagram properties`,disabled:!B||!V,active:g===`properties`,onClick:()=>_(e=>e===`properties`?null:`properties`),popover:g===`properties`&&o&&V?(0,K.jsx)(vj,{properties:F.filter(e=>e.id!==`direction`),onClose:()=>_(null),onApply:e=>{let t=i.source;for(let[n,r]of Object.entries(e)){if(o.kind===`flowchart`)continue;let e=Xk(t,o,n,r);e.ok&&(t=e.source)}k({ok:t!==i.source,source:t,reason:`The diagram properties are unchanged.`}),_(null)}}):void 0},{id:`mermaid-source`,label:`Source`,icon:(0,K.jsx)(q,{icon:`fa-solid fa-code`}),title:le?`Hide Mermaid source`:`Edit Mermaid source`,onClick:()=>Ej(e,t)}]}),fe=(0,K.jsx)(gA,{source:i.source,theme:a,maximized:b,onToggleMaximize:()=>x(e=>!e),selection:c,renaming:u,connecting:f,connectSourceId:m,onModelChange:O,onSelect:ie,onNodeAction:ae,onEditEdgeLabel:e=>{let t=o?.edges.find(t=>t.id===e);t&&L(t)},onEditText:e=>{let t=A.find(t=>t.id===e);t&&ee(t)},onCommitRename:te,onCommitEdgeLabel:R,onCommitText:ne,onCancelRename:()=>d(null),onCancelEdgeLabel:()=>d(null),onCancelText:()=>d(null),onDisconnectEdge:oe,onDeleteText:se});return b?(0,K.jsx)(`div`,{className:`squisq-diagram-inline-placeholder`,style:D==null?void 0:{height:D},children:(0,K.jsx)(XC,{host:n??null,onClose:()=>x(!1),children:(0,K.jsxs)(`div`,{className:`squisq-scene-block-max`,children:[fe,(0,K.jsx)(`div`,{className:`squisq-scene-side-toolbar`,children:de})]})})}):(0,K.jsxs)(`div`,{className:`squisq-scene-shell squisq-mermaid-shell`,children:[(0,K.jsx)(YC,{children:de}),(0,K.jsxs)(`div`,{className:`squisq-diagram-inline`,ref:E,style:D==null?void 0:{height:D},children:[fe,(0,K.jsx)(`div`,{className:`squisq-diagram-resize-handle`,onPointerDown:ce,onDoubleClick:()=>{T(null),C(null)},role:`separator`,"aria-orientation":`horizontal`,"aria-label":`Resize diagram height`,title:`Drag to resize · double-click to reset`})]}),v&&(0,K.jsxs)(`div`,{className:`squisq-mermaid-edit-notice`,role:`status`,children:[v,` Open Source for the full Mermaid syntax.`]})]})}function gj(e,t){(0,G.useEffect)(()=>{let n=n=>{let r=n.target;r?.closest(`.squisq-scene-block-toolbar`)||e.current&&!e.current.contains(r)&&t()},r=e=>{e.key===`Escape`&&t()};return document.addEventListener(`pointerdown`,n),document.addEventListener(`keydown`,r),()=>{document.removeEventListener(`pointerdown`,n),document.removeEventListener(`keydown`,r)}},[t,e])}function _j(e,t,n){let[r,i]=(0,G.useState)(null);return(0,G.useLayoutEffect)(()=>{let r=e.current,a=r?.parentElement;if(!r||!a)return;let o=r.closest(`.squisq-editor-shell`),s=o?.querySelector(`.squisq-status-bar`),c=()=>{let e=a.getBoundingClientRect(),c=o?.getBoundingClientRect(),l=s?.getBoundingClientRect(),u=document.documentElement.clientWidth||window.innerWidth,d=document.documentElement.clientHeight||window.innerHeight,f=Math.max(uj,(c?.top??0)+uj),p=Math.min(d,l?.top??d)-uj,m=Math.min(n,r.scrollHeight,Math.floor(d*.7)),h=e.bottom+lj,g=Math.max(0,p-h),_=Math.max(0,e.top-lj-f),v=g<m&&_>g,y=Math.max(0,Math.min(m,Math.floor(v?_:g))),b=v?Math.max(f,e.top-lj-y):h,x=Math.max(0,Math.min(t,u-uj*2)),S=a.closest(`.squisq-scene-side-toolbar`)?e.left-lj-x:e.left,C=Math.max(uj,Math.min(S,u-x-uj)),w={position:`fixed`,top:Math.round(b),left:Math.round(C),right:`auto`,width:Math.round(x),maxHeight:y};i(e=>e&&e.top===w.top&&e.left===w.left&&e.width===w.width&&e.maxHeight===w.maxHeight?e:w)};c();let l=typeof ResizeObserver>`u`?null:new ResizeObserver(c);return l?.observe(a),o&&l?.observe(o),s&&l?.observe(s),window.addEventListener(`resize`,c),window.addEventListener(`scroll`,c,!0),()=>{l?.disconnect(),window.removeEventListener(`resize`,c),window.removeEventListener(`scroll`,c,!0)}},[n,t,e]),r}function vj({properties:e,onApply:t,onClose:n}){let[r,i]=(0,G.useState)(()=>Object.fromEntries(e.map(e=>[e.id,e.value]))),a=(0,G.useRef)(null);return gj(a,n),(0,K.jsxs)(`form`,{ref:a,className:`squisq-mermaid-properties`,role:`dialog`,"aria-label":`Mermaid diagram properties`,style:_j(a,sj,cj)??{visibility:`hidden`},onSubmit:e=>{e.preventDefault(),t(r)},children:[(0,K.jsxs)(`div`,{className:`squisq-mermaid-properties-header`,children:[(0,K.jsx)(`strong`,{children:`Diagram properties`}),(0,K.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close diagram properties`,children:(0,K.jsx)(q,{icon:`fa-solid fa-xmark`})})]}),(0,K.jsx)(`div`,{className:`squisq-mermaid-properties-fields`,children:e.map(e=>(0,K.jsx)(`label`,{children:e.type===`boolean`?(0,K.jsxs)(`span`,{className:`squisq-mermaid-property-toggle`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:r[e.id]===!0,onChange:t=>i(n=>({...n,[e.id]:t.currentTarget.checked}))}),(0,K.jsx)(`span`,{children:e.label})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{children:e.label}),e.type===`select`?(0,K.jsx)(`select`,{value:String(r[e.id]??``),onChange:t=>i(n=>({...n,[e.id]:t.currentTarget.value})),children:e.options?.map(e=>(0,K.jsx)(`option`,{value:e.value,children:e.label},e.value))}):(0,K.jsx)(`input`,{type:`text`,value:String(r[e.id]??``),placeholder:e.placeholder,onChange:t=>i(n=>({...n,[e.id]:t.currentTarget.value}))})]})},e.id))}),(0,K.jsxs)(`div`,{className:`squisq-mermaid-properties-footer`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:n,children:`Cancel`}),(0,K.jsx)(`button`,{type:`submit`,"data-primary":`true`,children:`Apply`})]})]})}function yj({selected:e,onPick:t,onClose:n}){let r=(0,G.useRef)(null);return gj(r,n),(0,K.jsxs)(`div`,{ref:r,className:`squisq-mermaid-direction-picker`,role:`dialog`,"aria-label":`Flowchart layout gallery`,style:_j(r,aj,oj)??{visibility:`hidden`},children:[(0,K.jsxs)(`div`,{className:`squisq-mermaid-direction-heading`,children:[(0,K.jsx)(`strong`,{children:`Flow direction`}),(0,K.jsx)(`span`,{children:`Re-layout this flowchart without changing its content.`})]}),[{id:`LR`,label:`Horizontal`,detail:`Left to right`},{id:`TB`,label:`Vertical`,detail:`Top to bottom`},{id:`RL`,label:`Horizontal reversed`,detail:`Right to left`},{id:`BT`,label:`Vertical reversed`,detail:`Bottom to top`}].map(n=>(0,K.jsxs)(`button`,{type:`button`,className:`squisq-mermaid-direction-card`,"aria-label":`${n.label}: ${n.detail.toLowerCase()}`,"aria-pressed":e===n.id||e===`TD`&&n.id===`TB`,onClick:()=>t(n.id),children:[(0,K.jsx)(bj,{direction:n.id}),(0,K.jsxs)(`span`,{className:`squisq-mermaid-direction-copy`,children:[(0,K.jsx)(`strong`,{children:n.label}),(0,K.jsx)(`small`,{children:n.detail})]})]},n.id))]})}function bj({direction:e}){let t=e===`LR`||e===`RL`,n=e===`RL`||e===`BT`,r=t?{x:n?79:7,y:21}:{x:43,y:n?39:3},i=t?{x:n?7:79,y:21}:{x:43,y:n?3:39},a=e===`LR`?`M41 32H75`:e===`RL`?`M79 32H45`:e===`TB`?`M60 25V35`:`M60 39V29`,o=e===`LR`?`75,32 68,28 68,36`:e===`RL`?`45,32 52,28 52,36`:e===`TB`?`60,35 56,28 64,28`:`60,29 56,36 64,36`;return(0,K.jsxs)(`svg`,{viewBox:`0 0 120 64`,"aria-hidden":`true`,children:[(0,K.jsx)(`rect`,{x:r.x,y:r.y,width:`34`,height:`22`,rx:`3`}),(0,K.jsx)(`rect`,{x:i.x,y:i.y,width:`34`,height:`22`,rx:`3`}),(0,K.jsx)(`path`,{d:a}),(0,K.jsx)(`polygon`,{points:o}),(0,K.jsx)(`text`,{x:r.x+17,y:r.y+14,children:`A`}),(0,K.jsx)(`text`,{x:i.x+17,y:i.y+14,children:`B`})]})}var xj=new Dr(`squisq-mermaid-diagram`);function Sj(e){let t=e.attrs.language;return typeof t==`string`?t.trim().toLowerCase():``}function Cj(e){return e.type.name===`codeBlock`&&Sj(e)===`mermaid`}function wj(e,t){return xj.getState(e.state)?.entries.find(e=>e.id===t)?.pos??null}function Tj(e,t){return xj.getState(e.state)?.sourceVisible.has(t)??!1}function Ej(e,t){e.view.dispatch(e.state.tr.setMeta(xj,{toggleSource:t}))}function Dj(e,t,n,r,i){let a=[];for(let o of t){let t=e.nodeAt(o.pos);if(!t||!Cj(t))continue;a.push(sr.node(o.pos,o.pos+t.nodeSize,{class:n.has(o.id)?`squisq-mermaid-fence-source`:`squisq-mermaid-fence-hidden`}));let s=o.id;a.push(sr.widget(o.pos+t.nodeSize,e=>{let t=document.createElement(`div`);t.className=`squisq-mermaid-diagram-widget-host`,t.contentEditable=`false`,_O(t);let n=(0,Gr.createRoot)(t);return n.render((0,G.createElement)(hj,{editor:r,blockId:s,host:e.dom.parentElement??e.dom,themeStore:i})),t.__squisqMermaidRoot={root:n},t},{destroy:e=>{let t=e.__squisqMermaidRoot;t&&setTimeout(()=>t.root.unmount(),0)},ignoreSelection:!0,key:`squisq-mermaid-${o.id}`,side:1}))}return or.create(e,a)}function Oj(e,t,n){let r=eO(e,t.entries,n),i=t.seq,a=[];return n.descendants((e,t)=>{if(e.type.name===`codeBlock`)return Cj(e)&&a.push({id:r.get(t)??`mermaid-${++i}`,pos:t}),!1}),{entries:a,seq:i}}function kj(e,t,n,r,i){let a=e.getMeta(xj),o=t.sourceVisible;if(a?.toggleSource){let e=new Set(o);e.has(a.toggleSource)?e.delete(a.toggleSource):e.add(a.toggleSource),o=e}if(!e.docChanged)return a?.toggleSource?{...t,sourceVisible:o,decorations:Dj(r,t.entries,o,n,i)}:t;let{entries:s,seq:c}=Oj(e,t,r),l=new Set(s.map(e=>e.id)),u=new Set([...o].filter(e=>l.has(e)));return{entries:s,seq:c,sourceVisible:u,decorations:Dj(r,s,u,n,i)}}var Aj=kr.create({name:`squisqMermaidDiagram`,addOptions(){return{enabled:!0}},addProseMirrorPlugins(){if(this.options.enabled===!1)return[];let e=this.editor,t=this.options.themeStore;return[new pr({key:xj,state:{init:(n,r)=>{let i=0,a=[];r.doc.descendants((e,t)=>{if(e.type.name===`codeBlock`)return Cj(e)&&a.push({id:`mermaid-${++i}`,pos:t}),!1});let o=new Set;return{entries:a,seq:i,sourceVisible:o,decorations:Dj(r.doc,a,o,e,t)}},apply:(n,r,i,a)=>kj(n,r,e,a.doc,t)},props:{decorations(e){return this.getState(e)?.decorations??or.empty}}})]}});function jj(e,t){let[n,r]=(0,G.useState)(0);return(0,G.useEffect)(()=>{let t=()=>r(e=>e+1);return e.on(`transaction`,t),()=>{e.off(`transaction`,t)}},[e]),(0,G.useMemo)(()=>{let n=wj(e,t);if(n===null)return null;let r=e.state.doc.nodeAt(n);return!r||!Cj(r)?null:{source:r.textContent}},[e,t,n])}function Mj(e,t){let[n,r]=(0,G.useState)(0);return(0,G.useEffect)(()=>{let t=()=>r(e=>e+1);return e.on(`transaction`,t),()=>{e.off(`transaction`,t)}},[e]),(0,G.useMemo)(()=>{let n=qj(e,t);if(n===null)return null;let r=e.state.doc.nodeAt(n);if(!r||!Kj(r))return null;let i=r.attrs.language,a=typeof i==`string`?i:``;return{fenceLanguage:a,label:Tb(a),monacoLanguage:wb(a),source:r.textContent}},[e,t,n])}var Nj=34,Pj=20,Fj=20,Ij=2,Lj=1;function Rj(e){let t=e.split(`
|
|
494
|
+
`).length;return Ij+Nj+Fj+(t+Lj)*Pj}var zj=0;function Bj(){return zj+=1,zj}function Vj(e){return e?.closest(`[data-theme]`)?.dataset.theme===`dark`?`dark`:`light`}function Hj(e){let[t,n]=(0,G.useState)(()=>e!=null&&!e.isConnected?null:Vj(e));return(0,G.useEffect)(()=>{if(e!=null&&!e.isConnected){n(null);let t=requestAnimationFrame(()=>{e.isConnected&&n(Vj(e))});return()=>cancelAnimationFrame(t)}let t=e?.closest(`[data-theme]`);if(n(Vj(e)),!t||typeof MutationObserver>`u`)return;let r=new MutationObserver(()=>n(Vj(e)));return r.observe(t,{attributes:!0,attributeFilter:[`data-theme`]}),()=>r.disconnect()},[e]),t}function Uj(e){let[t,n]=(0,G.useState)(e.isEditable);return(0,G.useEffect)(()=>{let t=()=>n(e.isEditable);return e.on(`update`,t),e.on(`transaction`,t),()=>{e.off(`update`,t),e.off(`transaction`,t)}},[e]),t}function Wj({editor:e,blockId:t,host:n,focusOnMount:r=!1}){let i=Mj(e,t),{ready:a}=Th(i?.monacoLanguage),o=Hj(n),s=Uj(e),[c]=(0,G.useState)(Bj),l=(0,G.useCallback)(n=>{s&&Qj(e,t,n??``)},[t,s,e]),u=(0,G.useCallback)(e=>{r&&s&&mE(e)},[s,r]);if(!i)return null;let d=Sb(i.fenceLanguage).replace(/[^a-z0-9_-]/g,`-`);return(0,K.jsxs)(`div`,{className:`squisq-code-snippet-shell`,"data-language":i.fenceLanguage,style:{height:Rj(i.source)},children:[(0,K.jsx)(`div`,{className:`squisq-code-snippet-header`,children:(0,K.jsxs)(`span`,{className:`squisq-code-snippet-title`,children:[(0,K.jsx)(q,{icon:`fa-solid fa-file-code`}),(0,K.jsx)(`span`,{children:i.label})]})}),(0,K.jsx)(`div`,{className:`squisq-code-snippet-editor`,"aria-label":`${i.label} code editor`,children:a&&o!==null?(0,K.jsx)(gh,{path:`inmemory://squisq/code-snippet/${c}/${t}.${d||`txt`}`,language:i.monacoLanguage,theme:o===`dark`?`vs-dark`:`vs`,value:i.source,onChange:l,onMount:u,options:{automaticLayout:!0,contextmenu:!0,folding:!0,fontSize:13,lineHeight:Pj,lineNumbers:`on`,minimap:{enabled:!1},padding:{top:10,bottom:10},readOnly:!s,renderLineHighlight:`line`,scrollBeyondLastLine:!1,tabSize:2,wordWrap:`off`}}):(0,K.jsx)(`div`,{className:`squisq-code-snippet-loading`,children:`Loading code editor…`})})]})}var Gj=new Dr(`squisq-code-snippet`);function Kj(e,t){let n=e.attrs.language,r=typeof n==`string`?n:null;return e.type.name!==`codeBlock`||!Cb(r)?!1:!t||!t.has(Sb(r))}function qj(e,t){return Gj.getState(e.state)?.entries.find(e=>e.id===t)?.pos??null}function Jj(e,t,n,r=null,i){let a=[];for(let o of t){let t=e.nodeAt(o.pos);if(!t||!Kj(t,i))continue;a.push(sr.node(o.pos,o.pos+t.nodeSize,{class:`squisq-code-snippet-fence-hidden`}));let s=o.id;a.push(sr.widget(o.pos+t.nodeSize,e=>{let t=document.createElement(`div`);t.className=`squisq-code-snippet-widget-host`,t.contentEditable=`false`,t.addEventListener(`mousedown`,e=>e.stopPropagation()),t.addEventListener(`keydown`,e=>e.stopPropagation());let i=(0,Gr.createRoot)(t);return i.render((0,G.createElement)(Wj,{editor:n,blockId:s,host:e.dom.parentElement??e.dom,focusOnMount:o.id===r})),t.__squisqCodeSnippetRoot={root:i},t},{destroy:e=>{let t=e.__squisqCodeSnippetRoot;t&&setTimeout(()=>t.root.unmount(),0)},ignoreSelection:!0,key:`squisq-code-snippet-${o.id}`,side:1}))}return or.create(e,a)}function Yj(e,t,n,r){let i=new Map,a=new Set;for(let n of t.entries){let t=e.mapping.mapResult(n.pos,1);t.deleted||(i.set(t.pos,n.id),a.add(n.id))}for(let r of t.entries){if(a.has(r.id))continue;let t=e.mapping.mapResult(r.pos,1);i.has(t.pos)||n.nodeAt(t.pos)?.type.name===`codeBlock`&&(i.set(t.pos,r.id),a.add(r.id))}let o=t.seq,s=[];return n.descendants((e,t)=>{if(e.type.name===`codeBlock`)return Kj(e,r)&&s.push({id:i.get(t)??`code-snippet-${++o}`,pos:t}),!1}),{entries:s,seq:o}}function Xj(e,t,n,r,i){if(!e.docChanged)return t;let{entries:a,seq:o}=Yj(e,t,r,i),s=e.getMeta(pE),c=typeof s==`number`?a.find(e=>e.pos===s)?.id??null:null;return{entries:a,seq:o,focusBlockId:c,decorations:Jj(r,a,n,c,i)}}var Zj=kr.create({name:`squisqCodeSnippet`,addOptions(){return{enabled:!0}},addProseMirrorPlugins(){if(this.options.enabled===!1)return[];let e=this.editor,t=this.options.reservedLanguages&&this.options.reservedLanguages.length>0?new Set(this.options.reservedLanguages.map(e=>Sb(e))):void 0;return[new pr({key:Gj,state:{init:(n,r)=>{let i=0,a=[];return r.doc.descendants((e,n)=>{if(e.type.name===`codeBlock`)return Kj(e,t)&&a.push({id:`code-snippet-${++i}`,pos:n}),!1}),{entries:a,seq:i,focusBlockId:null,decorations:Jj(r.doc,a,e,null,t)}},apply:(n,r,i,a)=>Xj(n,r,e,a.doc,t)},props:{decorations(e){return this.getState(e)?.decorations??or.empty}}})]}});function Qj(e,t,n){let r=qj(e,t);if(r===null)return!1;let i=e.state.doc.nodeAt(r);if(!i||!Kj(i))return!1;if(i.textContent===n)return!0;let a=r+1,o=r+i.nodeSize-1,s=n.length>0?e.state.tr.replaceWith(a,o,e.state.schema.text(n)):e.state.tr.delete(a,o);return e.view.dispatch(s),!0}var $j=class extends G.Component{constructor(){super(...arguments),this.state={failed:!1}}static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?this.props.fallback:this.props.children}};function eM({editor:e,blockId:t,getRenderers:n,getTheme:r}){let[i,a]=(0,G.useState)(0);(0,G.useEffect)(()=>{let t=()=>a(e=>e+1);return e.on(`transaction`,t),()=>{e.off(`transaction`,t)}},[e]);let o=(0,G.useMemo)(()=>{let n=rM(e,t);if(n===null)return null;let r=e.state.doc.nodeAt(n);return!r||r.type.name!==`codeBlock`?null:{lang:nM(r),value:r.textContent}},[e,t,i]);if(!o)return null;let s=n()?.[o.lang],c=(0,K.jsx)(`pre`,{className:`squisq-md-code-block`,children:(0,K.jsx)(`code`,{children:o.value})});if(!s)return c;let l=r();return(0,K.jsx)($j,{fallback:c,children:s({lang:o.lang,value:o.value,...l?{theme:l}:{},mode:`edit`,replaceValue:n=>{iM(e,t,n)}})})}var tM=new Dr(`squisq-host-fence`);function nM(e){let t=e.attrs.language;return typeof t==`string`?t.trim().split(/\s+/,1)[0]?.toLowerCase()??``:``}function rM(e,t){return tM.getState(e.state)?.entries.find(e=>e.id===t)?.pos??null}function iM(e,t,n){let r=rM(e,t);return r!==null&&lO(e,r,n)}function aM(e,t,n,r){let i=[];for(let a of t){let t=e.nodeAt(a.pos);if(!t||t.type.name!==`codeBlock`)continue;i.push(sr.node(a.pos,a.pos+t.nodeSize,{class:`squisq-host-fence-hidden`}));let o=a.id;i.push(sr.widget(a.pos+t.nodeSize,()=>{let e=document.createElement(`div`);e.className=`squisq-host-fence-widget-host`,e.contentEditable=`false`,_O(e);let t=(0,Gr.createRoot)(e);return t.render((0,G.createElement)(eM,{editor:n,blockId:o,getRenderers:()=>r.renderers?.(),getTheme:()=>r.theme?.()})),e.__squisqHostFenceRoot={root:t},e},{destroy:e=>{let t=e.__squisqHostFenceRoot;t&&setTimeout(()=>t.root.unmount(),0)},side:1,ignoreSelection:!0,key:`squisq-host-fence-${a.id}`}))}return or.create(e,i)}function oM(e,t){if(e.type.name!==`codeBlock`)return!1;let n=nM(e);return n?!!t.renderers?.()?.[n]:!1}function sM(e,t,n,r,i){if(!e.docChanged)return t;let a=eO(e,t.entries,r),o=t.seq,s=[];return r.descendants((e,t)=>{if(e.type.name===`codeBlock`)return oM(e,i)&&s.push({id:a.get(t)??`host-fence-${++o}`,pos:t}),!1}),{entries:s,seq:o,decorations:aM(r,s,n,i)}}var cM=kr.create({name:`squisqHostFence`,addOptions(){return{enabled:!0}},addProseMirrorPlugins(){let e=this.editor,t=this.options;return t.enabled===!1||!t.renderers?[]:[new pr({key:tM,state:{init:(n,r)=>{let i=0,a=[];return r.doc.descendants((e,n)=>{if(e.type.name===`codeBlock`)return oM(e,t)&&a.push({id:`host-fence-${++i}`,pos:n}),!1}),{entries:a,seq:i,decorations:aM(r.doc,a,e,t)}},apply:(n,r,i,a)=>sM(n,r,e,a.doc,t)},props:{decorations(e){return this.getState(e)?.decorations??or.empty}}})]}});function lM(e){let t=e.split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n>0?t.slice(n+1).toLowerCase():``}var uM=5,dM=6;async function fM(e,t,n){try{let{defaultDataReaders:r}=await Ut(async()=>{let{defaultDataReaders:e}=await import(`./data-B2kHjlc5.js`);return{defaultDataReaders:e}},__vite__mapDeps([85,12,1,13,86,23,24,18,19,17,25,26,27,28,87,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,20,2,55,56,57,58,59,60,61,62,14,88,89,90])),i=r().find(e=>e.extensions.includes(t));if(!i)return null;let a=await i.read(e,{maxRows:n?.maxRows??uM,...n?.sheet?{sheet:n.sheet}:{},...n?.anchor?{anchor:n.anchor}:{}});return{columns:a.headers.slice(0,dM),rows:a.rows.map(e=>e.slice(0,dM)),totalRows:a.totalRows,totalCols:a.totalCols}}catch{return null}}var pM=new Map;function mM(e,t,n){let r=`${t}\0${e}`,i=pM.get(r);if(!i){for(let t of pM.keys())t.endsWith(`\0${e}`)&&t!==r&&pM.delete(t);i=n(),pM.set(r,i)}return i}var hM=`Parquet sidecars are read-only`;function gM(e){return e.includes(`\r
|
|
495
|
+
`)?`\r
|
|
496
|
+
`:`
|
|
497
|
+
`}async function _M(e,t,n){if(t===`csv`||t===`tsv`){let{SIDECAR_CSV_LIMITS:r,parseCsv:i}=await Ut(async()=>{let{SIDECAR_CSV_LIMITS:e,parseCsv:t}=await import(`./csv-62UGQMzZ.js`);return{SIDECAR_CSV_LIMITS:e,parseCsv:t}},__vite__mapDeps([91,86,23,1,24,18,19,17,25,26,27,28,87,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,20,2,55,56,57,58,59,60,61,62])),a=new Uint8Array(e),o=a.length>=3&&a[0]===239&&a[1]===187&&a[2]===191,s=new TextDecoder().decode(e),c=s.slice(0,s.indexOf(`
|
|
498
|
+
`)+1||s.length),l=t===`tsv`||c.includes(` `)&&!c.includes(`,`)?` `:`,`,u=i(s,l,r),d=n.headerRow!==!1&&u.length>0,f=u.reduce((e,t)=>Math.max(e,t.length),0);return{ingest:{headers:d?[...u[0]??[],...Array(Math.max(0,f-(u[0]?.length??0))).fill(``)].map((e,t)=>e===``?`Column ${t+1}`:e):Array.from({length:f},(e,t)=>`Column ${t+1}`),cells:(d?u.slice(1):u).map(e=>Array.from({length:f},(t,n)=>e[n]===``?null:e[n]??null))},csv:{delimiter:l,newline:gM(s),trailingNewline:s.endsWith(`
|
|
499
|
+
`),bom:o,rows:u,hasHeader:d}}}if(t===`xlsx`){let{xlsxToCellGrids:t,gridToTables:r,parseCellRef:i}=await Ut(async()=>{let{xlsxToCellGrids:e,gridToTables:t,parseCellRef:n}=await import(`./xlsx-DyBGuAO1.js`);return{xlsxToCellGrids:e,gridToTables:t,parseCellRef:n}},__vite__mapDeps([92,1,23,24,18,19,17,25,26,27,13,12,86,28,14,88,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,20,2,55,56,57,58,59,60,61,62,29,32])),a=await t(e,{...n.sheet===void 0?{}:{sheet:n.sheet}}),o=new Map(a.sheets.map(e=>[e.name,e])),s=a.sheets.flatMap(e=>r(e.name,e.cells,e.merges)),c=n.anchor&&s.find(e=>e.anchor.toUpperCase()===n.anchor.toUpperCase())||s.reduce((e,t)=>!e||t.rows.length*t.columns.length>e.rows.length*e.columns.length?t:e,null);if(!c)throw Error(`no tabular data found in workbook`);let l=i(c.anchor),u=o.get(c.sheet),d=new Set,f=new Set,p=new Set,m=new Map,h;if(l&&u){let e=l.row+ +!!c.hasHeader;for(let t=0;t<c.rows.length;t++)for(let n=0;n<c.columns.length;n++){let r=u.cells[e+t]?.[l.col+n];if(!r)continue;let i=`${t}:${n}`;(r.formula!==void 0||r.kind===`date`)&&d.add(i),r.kind===`date`&&f.add(i),r.formula!==void 0&&m.set(i,r.formula),r.sharedFormulaRole===`master`&&p.add(i)}h={sheet:c.sheet,anchorRow:l.row,anchorCol:l.col,hasHeader:c.hasHeader,locked:d,dateLocked:f,masterLocked:p,formulas:m,grids:a}}return{ingest:{headers:c.columns.map(e=>e.name),cells:c.rows.map(e=>e.map(e=>e)),hints:c.columns.map(e=>e.kind===`number`||e.kind===`bool`||e.kind===`date`?{kind:e.kind===`bool`?`boolean`:e.kind}:void 0)},...h?{xlsx:h}:{readOnlyReason:`workbook region could not be addressed for editing`}}}if(t===`parquet`){let{parquetDataReader:t}=await Ut(async()=>{let{parquetDataReader:e}=await import(`./data-B2kHjlc5.js`);return{parquetDataReader:e}},__vite__mapDeps([85,12,1,13,86,23,24,18,19,17,25,26,27,28,87,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,20,2,55,56,57,58,59,60,61,62,14,88,89,90])),n=await t.read(e,{maxRows:1/0});return{ingest:{headers:n.headers,cells:n.rows.map(e=>e.map(e=>e===``?null:e))},readOnlyReason:hM}}throw Error(`unsupported data extension ".${t}"`)}var vM=`squisq-block-tags--selected`,yM=`squisq-block-tags--hovered`,bM=new Dr(`squisq-block-tag-activity`);function xM(e){return/^H[1-6]$/.test(e.tagName)}function SM(e,t){let n=0,r=null;for(let i=0;i<e.childCount&&n<=t;i+=1){let t=e.child(i);t.type.name===`heading`&&(r=n),n+=t.nodeSize}return r}function CM(e,t){if(!(t instanceof Node))return null;let n=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;if(!n||n===e||!e.contains(n))return null;for(;n.parentElement&&n.parentElement!==e;)n=n.parentElement;if(n.parentElement!==e)return null;let r=n;for(;r&&!xM(r);)r=r.previousElementSibling;return r&&xM(r)?r:null}function wM(e,t,n){let r=CM(e,t);if(r)return r;if(!(t instanceof Node)||!e.contains(t)||!Number.isFinite(n))return null;let i=Array.from(e.children),a=i[i.length-1];if(!a||n>a.getBoundingClientRect().bottom)return null;let o=null;for(let e of i){if(e.getBoundingClientRect().top>n)break;xM(e)&&(o=e)}return o}function TM(e,t){return t===null?null:e.nodeAt(t)?.type.name===`heading`?t:null}function EM(e,t,n){let r=new Map;if(t!==null&&r.set(t,[vM]),n!==null){let e=r.get(n)??[];e.push(yM),r.set(n,e)}let i=[];for(let[t,n]of r){let r=e.nodeAt(t);!r||r.type.name!==`heading`||i.push(sr.node(t,t+r.nodeSize,{class:n.join(` `)}))}return i.length>0?or.create(e,i):or.empty}function DM(e,t,n){let r=SM(e,t),i=TM(e,n);return{selectedPosition:r,hoveredPosition:i,decorations:EM(e,r,i)}}function OM(e,t,n){let r=e.getMeta(bM);if(r!==void 0)return TM(n,r.hoveredPosition);if(!e.docChanged||t===null)return t;let i=e.mapping.mapResult(t,1);return i.deleted?null:TM(n,i.pos)}function kM(e,t,n){let r=wM(e.dom,t,n);if(!r)return null;try{let t=e.posAtDOM(r,0);return SM(e.state.doc,t)}catch{return null}}function AM(e,t){(bM.getState(e.state)?.hoveredPosition??null)!==t&&e.dispatch(e.state.tr.setMeta(bM,{hoveredPosition:t}).setMeta(`addToHistory`,!1))}var jM=kr.create({name:`squisqBlockTagActivity`,addProseMirrorPlugins(){return[new pr({key:bM,state:{init:(e,t)=>DM(t.doc,t.selection.from,null),apply:(e,t,n,r)=>DM(r.doc,r.selection.from,OM(e,t.hoveredPosition,r.doc))},props:{decorations(e){return this.getState(e)?.decorations??or.empty},handleDOMEvents:{mouseover(e,t){return AM(e,kM(e,t.target,t.clientY)),!1},mousemove(e,t){return t.target===e.dom&&AM(e,kM(e,t.target,t.clientY)),!1},mouseleave(e){return AM(e,null),!1}}}})]}});function MM(e){let t={};if(!e)return t;for(let n of jt(e)){let e=yt(n);e&&(t[e.key]=ft(e.value))}return t}function NM(e,t,n){let r=SM(e.state.doc,t);if(r===null)return{headingPos:null,persisted:!1,params:{}};let i=e.state.doc.nodeAt(r);if(!i||i.type.name!==`heading`)return{headingPos:null,persisted:!1,params:{}};let a=i.attrs,o=MM(a.dataTemplateParams),s=a.dataTemplate?vt(a.dataTemplate):null;return{headingPos:r,persisted:s!==null&&Ot.has(s)&&o.src===n,params:o,...o.sort===void 0?{}:{sortRaw:o.sort},...o.filter===void 0?{}:{filterRaw:o.filter}}}function PM(e){return Object.entries(e).map(([e,t])=>`${e}=${dt(t)?gt(t):t}`).join(` `)}function FM(e,t,n,r){if(!e.isEditable)return!1;let i=NM(e,t,n);if(i.headingPos===null||!i.persisted)return!1;let a=tr(r),o={...i.params};a.sort===void 0?delete o.sort:o.sort=a.sort,a.filter===void 0?delete o.filter:o.filter=a.filter;let s=PM(o),c=i.headingPos;return e.chain().command(({tr:e})=>{let t=e.doc.nodeAt(c);return!t||t.type.name!==`heading`?!1:(e.setNodeAttribute(c,`dataTemplateParams`,s.length>0?s:null),!0)}).run()}function IM(e,t){return nr(e.sortRaw,e.filterRaw,t).view}var LM=3,RM=/^[\t\r\n \uFEFF]*[=+\-@]/;function zM(e){return e===null?``:typeof e==`boolean`?e?`true`:`false`:String(e)}function BM(e){return!RM.test(e)||e.trim()!==``&&Number.isFinite(Number(e.trim()))?e:`'${e}`}async function VM(e,t,n,r){let i=mn(t,new Date);await e.writeFile(i,n,r);let a=`${Tn}${t.replace(/\.[^.]+$/,``).replace(/\//g,`__`)}.`,o=(await e.listFiles(Tn)).filter(e=>e.path.startsWith(a)).map(e=>e.path).sort();for(let t of o.slice(0,Math.max(0,o.length-LM)))await e.removeFile(t)}async function HM(e){let{path:t,originalBytes:n,csv:r,journal:i,mediaProvider:a,container:o}=e,s=[],c=t.toLowerCase().endsWith(`.tsv`)?`text/tab-separated-values`:`text/csv`;try{o?await VM(o,t,n,c):s.push(`no workspace container — saved without a backup copy`);let e=r.rows.map(e=>[...e]),l=+!!r.hasHeader;for(let t of i.entries()){let n=t.rowId+l;for(;e.length<=n;)e.push([]);let r=e[n];for(;r.length<=t.col;)r.push(``);r[t.col]=BM(zM(t.next))}let{serializeCsvRows:u}=await Ut(async()=>{let{serializeCsvRows:e}=await import(`./csv-62UGQMzZ.js`);return{serializeCsvRows:e}},__vite__mapDeps([91,86,23,1,24,18,19,17,25,26,27,28,87,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,20,2,55,56,57,58,59,60,61,62])),d=u(e,{delimiter:r.delimiter,newline:r.newline,trailingNewline:r.trailingNewline,formulaHandling:`preserve`}),f=new TextEncoder().encode(r.bom?`\uFEFF${d}`:d).buffer,p=await a.addMedia(t,f,c);return p===t?(i.clear(),{ok:!0,savedPath:p,notices:s}):{ok:!1,savedPath:p,notices:s,error:`the host saved a copy at "${p}" instead of overwriting "${t}" \u2014 the document still references the original`}}catch(e){return{ok:!1,notices:s,error:e instanceof Error?e.message:String(e)}}}var UM=`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`;async function WM(e){let{path:t,originalBytes:n,xlsx:r,journal:i,formulaEdits:a,mediaProvider:o,container:s}=e,c=[];try{s?await VM(s,t,n,UM):c.push(`no workspace container — saved without a backup copy`);let{patchXlsxCellValues:e,formatCellRef:l}=await Ut(async()=>{let{patchXlsxCellValues:e,formatCellRef:t}=await import(`./xlsx-DyBGuAO1.js`);return{patchXlsxCellValues:e,formatCellRef:t}},__vite__mapDeps([92,1,23,24,18,19,17,25,26,27,13,12,86,28,14,88,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,20,2,55,56,57,58,59,60,61,62,29,32])),u=r.anchorRow+ +!!r.hasHeader,d=i.entries().map(e=>({sheet:r.sheet,ref:l(u+e.rowId,r.anchorCol+e.col),value:e.next}));for(let[e,t]of a??[]){let[n,i]=e.split(`:`).map(Number);d.push({sheet:r.sheet,ref:l(u+n,r.anchorCol+i),formula:t.formula,...t.cachedValue===void 0?{}:{cachedValue:t.cachedValue}})}let f=await e(n,d),p=await o.addMedia(t,f,UM);return p===t?(i.clear(),{ok:!0,savedPath:p,notices:c}):{ok:!1,savedPath:p,notices:c,error:`the host saved a copy at "${p}" instead of overwriting "${t}" \u2014 the document still references the original`}}catch(e){return{ok:!1,notices:c,error:e instanceof Error?e.message:String(e)}}}var GM={maxWorkUnits:1e8,maxEvalTimeMs:15e3};function KM(e,t){return e.isCalcError(t)?t.code:t}function qM(e,t){let{grids:n}=t;return{date1904:n.date1904,sheets:n.sheets.map(t=>({name:t.name,cells:t.cells.map(t=>t.map(t=>{if(!t)return null;if(t.formula!==void 0)return{formula:t.formula};if(t.value===void 0)return null;if(t.kind===`date`&&typeof t.value==`string`){let r=e.serialFromIso(t.value,n.date1904);return r===null?{value:t.value}:{value:r}}return{value:t.value}}))}))}}async function JM(e,t={}){let n;try{n=await Ut(()=>import(`./dist-B9-VrAP8.js`),[])}catch{return null}let r={date1904:e.grids.date1904,budgets:GM},i,a=!1;if(t.engineFactory)try{i=await t.engineFactory(r),a=!0}catch{i=n.createInHouseEngine(r)}else try{i=await n.createWorkerCalcEngine(r)}catch{i=n.createInHouseEngine(r)}if(await i.loadWorkbook(qM(n,e)),(await i.evaluateAll()).status===`budget-exceeded`)return i.dispose(),null;let o=e.anchorRow+ +!!e.hasHeader,s=(t,n)=>({sheet:e.sheet,row:o+t,col:e.anchorCol+n}),c=new Map(e.formulas),l=new Map,u=!1,d=async e=>{let t=e.map(e=>e.split(`:`).map(Number)),r=await i.getCells(t.map(([e,t])=>s(e,t))),a=new Map;return e.forEach((e,t)=>a.set(e,KM(n,r[t].value))),a},f=()=>d([...c.keys()]),p=async(e,t=c.keys())=>{let r=[...new Set(t)],a=r.map(e=>e.split(`:`).map(Number)),o=await i.getCells(a.map(([e,t])=>s(e,t))),l=[];return r.forEach((t,r)=>{let i=o[r].value;if(n.isCalcError(i)&&i.code===`#NAME?`)return;let s=KM(n,i);if(e.get(t)!==s){let[e,t]=a[r];l.push({rowId:e,col:t,value:s})}}),l};return{getFormula:(e,t)=>c.get(`${e}:${t}`),isCellLocked:(t,n)=>{let r=`${t}:${n}`;return e.dateLocked.has(r)||e.masterLocked.has(r)},async commitFormula(e,t,r){if(u)return{ok:!1,error:`session disposed`};try{n.parseFormula(r)}catch(e){if(!a)return{ok:!1,error:e instanceof n.CalcParseError?e.message:`invalid formula`}}let o=`${e}:${t}`,d=s(e,t),m=await i.getCell(d),h=await f();if(h.has(o)||h.set(o,KM(n,m.value)),i.setCellFormula(d,r),(await i.evaluateAll()).status===`budget-exceeded`)return m.formula===void 0?m.value===null||n.isCalcError(m.value)?i.clearCell(d):i.setCellValue(d,m.value):i.setCellFormula(d,m.formula),await i.evaluateAll(),{ok:!1,error:`formula exceeds the calculation budget`};c.set(o,r);let g=(await i.getCell(d)).value;if(n.isCalcError(g)&&g.code===`#NAME?`){let n={formula:r};l.set(o,n);let i=await p(h);return i.push({rowId:e,col:t,value:`#NAME?`}),{ok:!0,updates:i}}let _={formula:r};return!n.isCalcError(g)&&g!==null&&(_.cachedValue=g),l.set(o,_),{ok:!0,updates:await p(h)}},async noteValueEdit(e,t,n){if(u)return[];let r=`${e}:${t}`;c.delete(r),l.delete(r);let a=await f();return i.setCellValue(s(e,t),n),(await i.evaluateAll()).status===`budget-exceeded`?[]:p(a)},get dirtyCount(){return l.size},formulaEdits:()=>l,async discard(){let t=await f(),r=new Set(c.keys());c.clear();for(let[t,n]of e.formulas)c.set(t,n);l.clear(),await i.loadWorkbook(qM(n,e)),await i.evaluateAll();for(let e of c.keys())r.add(e);return p(t,r)},markSaved(){l.clear()},dispose(){u=!0,i.dispose()}}}var YM=new Dr(`squisq-data-card`);function XM(e){if(e.type.name!==`paragraph`||e.childCount===0)return null;let t=null;for(let n=0;n<e.childCount;n++){let r=e.child(n);if(!r.isText||!r.text||!r.text.trim())return null;let i=r.marks.find(e=>e.type.name===`link`)?.attrs?.href;if(typeof i!=`string`)return null;if(t===null)t=i;else if(t!==i)return null}return t!==null&&Fe(t)?t:null}function ZM(e,t,n,r){let i=[];for(let a of t){let t=e.nodeAt(a.pos);if(!t||t.type.name!==`paragraph`)continue;i.push(sr.node(a.pos,a.pos+t.nodeSize,{class:`squisq-data-card-hidden`}));let o=a.id;i.push(sr.widget(a.pos+t.nodeSize,()=>{let e=document.createElement(`div`);e.className=`squisq-data-card-host squisq-block-fill-available`,e.contentEditable=`false`,_O(e);let t=(0,Gr.createRoot)(e);return t.render((0,G.createElement)(sN,{editor:n,blockId:o,getMediaProvider:()=>r.mediaProvider?.(),getMediaRevision:()=>r.mediaRevision?.()??0,getContainer:()=>r.container?.(),onOpenFiles:r.onOpenFiles,onMediaSaved:r.onMediaSaved,getCalcEngineFactory:()=>r.calcEngineFactory?.()})),e.__squisqDataCardRoot={root:t},e},{destroy:e=>{let t=e.__squisqDataCardRoot;t&&setTimeout(()=>t.root.unmount(),0)},side:1,ignoreSelection:!0,key:`squisq-data-card-${a.id}`}))}return or.create(e,i)}function QM(e,t,n){let r=n,i=[];return e.descendants((e,n)=>{if(e.type.name===`paragraph`)return XM(e)&&i.push({id:t?.get(n)??`data-card-${++r}`,pos:n}),!1}),{entries:i,seq:r}}function $M(e,t,n,r,i){if(!e.docChanged)return t;let{entries:a,seq:o}=QM(r,eO(e,t.entries,r,`paragraph`),t.seq);return{entries:a,seq:o,decorations:ZM(r,a,n,i)}}var eN=kr.create({name:`squisqDataCard`,addOptions(){return{enabled:!0}},addProseMirrorPlugins(){let e=this.editor,t=this.options;return t.enabled===!1?[]:[new pr({key:YM,state:{init:(n,r)=>{let{entries:i,seq:a}=QM(r.doc,null,0);return{entries:i,seq:a,decorations:ZM(r.doc,i,e,t)}},apply:(n,r,i,a)=>$M(n,r,e,a.doc,t)},props:{decorations(e){return this.getState(e)?.decorations??or.empty}}})]}}),tN=`Date cells and shared-formula masters stay locked; other formulas are editable`,nN=null;function rN(){return nN??=Ut(()=>import(`./dist-ZnIgkoEi.js`),__vite__mapDeps([93,1,36,37,90])).catch(()=>(nN=null,null)),nN}function iN(e,t){let[n,r]=(0,G.useState)(0);return(0,G.useEffect)(()=>{let t=()=>r(e=>e+1);return e.on(`transaction`,t),()=>{e.off(`transaction`,t)}},[e]),(0,G.useMemo)(()=>{let n=YM.getState(e.state)?.entries.find(e=>e.id===t)?.pos;if(n===void 0)return null;let r=e.state.doc.nodeAt(n);if(!r)return null;let i=XM(r);return i?{href:i,label:r.textContent,pos:n}:null},[e,t,n])}function aN(e){let[t,n]=(0,G.useState)(()=>e());return(0,G.useEffect)(()=>{let t=window.setInterval(()=>{let t=e();n(e=>e===t?e:t)},1500);return()=>window.clearInterval(t)},[e]),t}function oN(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function sN({editor:e,blockId:t,getMediaProvider:n,getMediaRevision:r,getContainer:i,onOpenFiles:a,onMediaSaved:o,getCalcEngineFactory:s}){let c=iN(e,t),l=aN(r),[u,d]=(0,G.useState)({kind:`loading`}),[f,p]=(0,G.useState)(rr),[m,h]=(0,G.useState)(!1),[g,_]=(0,G.useState)(!1),[v,y]=(0,G.useState)(null),[b,x]=(0,G.useState)(0),S=(0,G.useRef)(null),C=c?.href??null,w=c?.pos??null;(0,G.useEffect)(()=>{if(!C||w===null)return;let t=n();if(!t){d({kind:`meta`,size:null,preview:null});return}let r=!1;return d({kind:`loading`}),(async()=>{let n=null;try{let i=(await t.listMedia()).find(e=>e.name===C);if(!i){r||d({kind:`missing`});return}n=i.size;let a=await t.resolveUrl(C);if(a===C){r||d({kind:`meta`,size:n,preview:null,reason:`the host did not provide the file bytes`});return}let o=await fetch(a);if(!o.ok){r||d({kind:`meta`,size:n,preview:null,reason:`the file could not be fetched (${o.status})`});return}let c=await o.arrayBuffer(),u=lM(C),f=await rN();if(f){let t=NM(e,w,C),i=await _M(c,u,{...t.params.sheet?{sheet:t.params.sheet}:{},...t.params.anchor?{anchor:t.params.anchor}:{},...t.params.headerRow===void 0?{}:{headerRow:t.params.headerRow!==`false`}});if(r)return;let a=null;if(i.xlsx)try{let e=s?.();a=await JM(i.xlsx,e?{engineFactory:e}:{})}catch{a=null}if(r){a?.dispose();return}S.current?.formulaSession?.dispose(),S.current?.provider.dispose();let o={module:f,provider:new f.TableStoreClient(i.ingest),journal:f.journalFor(C,l),ingested:i,bytes:c,headers:i.ingest.headers,formulaSession:a};S.current=o,p(IM(t,i.ingest.headers)),h(t.persisted),y(null),x(0),d({kind:`grid`,size:n,grid:o});return}let m=await mM(C,l,()=>fM(c,u));if(r)return;d({kind:`meta`,size:n,preview:m})}catch(e){r||d({kind:`meta`,size:n,preview:null,reason:e instanceof Error?e.message:String(e)})}})(),()=>{r=!0}},[C,l,n,e]),(0,G.useEffect)(()=>()=>{S.current?.formulaSession?.dispose(),S.current?.provider.dispose(),S.current=null},[]);let T=(0,G.useCallback)(t=>{p(t),C!==null&&w!==null&&m&&FM(e,w,C,t)},[e,w,C,m]),E=(0,G.useCallback)(async()=>{let e=S.current,t=n();if(!(!e||!t||!C||!e.ingested.csv&&!e.ingested.xlsx)){_(!0);try{let n={path:C,originalBytes:e.bytes,journal:e.journal,mediaProvider:t,container:i?.()??null},r=e.ingested.csv?await HM({...n,csv:e.ingested.csv}):await WM({...n,xlsx:e.ingested.xlsx,...e.formulaSession?{formulaEdits:e.formulaSession.formulaEdits()}:{}});y(r.ok?r.notices.length>0?`saved (${r.notices.join(`; `)})`:null:r.error??`save failed`),r.ok&&(S.current?.formulaSession?.markSaved(),x(0),o?.())}finally{_(!1)}}},[i,n,C,o]);if(!c||!C)return null;let D=C.split(`/`).pop()??C,O=u.kind===`meta`||u.kind===`grid`?u.size:null,k=u.kind===`grid`?u.grid:null,A=k?.ingested.xlsx,j=!!(k?.ingested.csv||A)&&e.isEditable,M=k?.ingested.readOnlyReason;return(0,K.jsxs)(`div`,{className:`squisq-data-card${u.kind===`missing`?` squisq-data-card--missing`:``}`,"data-proof-exempt":`true`,children:[(0,K.jsxs)(`div`,{className:`squisq-data-card-header`,children:[(0,K.jsx)(`span`,{className:`squisq-data-card-icon`,"aria-hidden":`true`,children:`📊`}),(0,K.jsx)(`span`,{className:`squisq-data-card-name`,title:C,children:D}),(0,K.jsx)(`span`,{className:`squisq-data-card-meta`,children:[u.kind===`missing`?`not found in this document’s files`:null,u.kind===`loading`?`loading…`:null,u.kind===`meta`&&!u.preview&&O!==null?oN(O):null,v].filter(Boolean).join(` · `)}),a&&u.kind!==`missing`&&(0,K.jsx)(`button`,{type:`button`,className:`squisq-data-card-action`,onClick:()=>a(C),children:`Show in Files`})]}),k&&(0,K.jsx)(k.module.DataGrid,{provider:k.provider,journal:j?k.journal:void 0,view:f,onViewChange:T,viewPersisted:m,onSave:j?E:void 0,saving:g,readOnlyReason:e.isEditable?M:void 0,isCellLocked:k.formulaSession?k.formulaSession.isCellLocked:A?(e,t)=>A.locked.has(`${e}:${t}`):void 0,lockedReason:k.formulaSession?tN:A?`Formula and date cells become editable with the calculation engine (Phase 3)`:void 0,formulaSupport:k.formulaSession?{getFormula:k.formulaSession.getFormula,commitFormula:async(e,t,n)=>{let r=await k.formulaSession.commitFormula(e,t,n);return r.ok&&x(k.formulaSession.dirtyCount),r}}:void 0,onCellEdited:k.formulaSession?e=>k.formulaSession.noteValueEdit(e.rowId,e.col,e.value):void 0,extraDirtyCount:b,onDiscardExtra:k.formulaSession?async()=>{let e=await k.formulaSession.discard();e.length>0&&await k.provider.applyEdits?.(e),x(0)}:void 0,className:`squisq-data-card-grid`}),u.kind===`meta`&&u.preview&&u.preview.rows.length>0&&(0,K.jsxs)(`div`,{className:`squisq-data-card-preview`,children:[(0,K.jsxs)(`table`,{children:[(0,K.jsx)(`thead`,{children:(0,K.jsx)(`tr`,{children:u.preview.columns.map((e,t)=>(0,K.jsx)(`th`,{children:e},t))})}),(0,K.jsx)(`tbody`,{children:u.preview.rows.map((e,t)=>(0,K.jsx)(`tr`,{children:e.map((e,t)=>(0,K.jsx)(`td`,{children:e},t))},t))})]}),u.preview.totalRows!==null&&(0,K.jsxs)(`div`,{className:`squisq-data-card-truncation`,children:[u.preview.totalRows>u.preview.rows.length?`showing ${u.preview.rows.length} of ${u.preview.totalRows.toLocaleString()} rows`:`${u.preview.totalRows.toLocaleString()} row${u.preview.totalRows===1?``:`s`}`,u.preview.totalCols===null?``:`, ${u.preview.totalCols} column${u.preview.totalCols===1?``:`s`}`]})]}),u.kind===`meta`&&u.reason&&(0,K.jsxs)(`div`,{className:`squisq-data-card-error`,role:`status`,children:[`data view unavailable — `,u.reason]})]})}function cN(e){return e.replace(/[├└│─┃┏┓┗┛┣┫┳┻╋╰╭╮╯|`]/gu,` `).replace(/\s+/g,` `).trim()}function lN(e){return{id:e.id,label:e.label,children:e.children.map(lN),...e.isDir?{isDir:!0}:{},...e.comment?{comment:e.comment}:{}}}function uN(e){return{roots:e.roots.map(lN),style:e.style,warnings:[...e.warnings]}}function dN(e,t,n=null){for(let r=0;r<e.length;r++){if(e[r].id===t)return{siblings:e,index:r,node:e[r],parent:n};let i=dN(e[r].children,t,e[r]);if(i)return i}return null}function fN(e){e.isDir=e.label.endsWith(`/`)||e.children.length>0}function pN(e,t){return e.id===t||e.children.some(e=>pN(e,t))}function mN(e,t,n){let r=cN(n),i=uN(e),a=dN(i.roots,t);return!a||r.length===0||r===a.node.label?e:(a.node.label=r,fN(a.node),i)}function hN(e,t,n,r,i){let a=uN(e),o=dN(a.roots,t);if(!o)return e;let s=cN(r??``)||CN(a,i);i&&!s.endsWith(`/`)&&(s+=`/`);let c={id:`__new-${s}`,label:s,children:[],...i?{isDir:!0}:{}};return n===`child`?(o.node.children.push(c),fN(o.node)):o.siblings.splice(o.index+1,0,c),a}function gN(e,t){let n=uN(e),r=dN(n.roots,t);return r?(r.siblings.splice(r.index,1),r.parent&&fN(r.parent),n):e}function _N(e,t){let n=uN(e),r=dN(n.roots,t);if(!r||r.index===0)return e;let[i]=r.siblings.splice(r.index,1),a=r.siblings[r.index-1];return a.children.push(i),fN(a),n}function vN(e,t){let n=uN(e),r=dN(n.roots,t);if(!r||!r.parent)return e;let i=dN(n.roots,r.parent.id);if(!i)return e;let[a]=r.siblings.splice(r.index,1);return i.siblings.splice(i.index+1,0,a),fN(r.parent),n}function yN(e,t,n,r){let i=dN(e.roots,t),a=dN(e.roots,n);if(!i||!a||t===n||pN(i.node,n)||i.siblings===a.siblings&&(r===`before`&&i.index===a.index-1||r===`after`&&i.index===a.index+1)||r===`child`&&i.parent?.id===a.node.id&&i.index===i.siblings.length-1)return e;let o=uN(e),s=dN(o.roots,t);if(!s)return e;let[c]=s.siblings.splice(s.index,1);s.parent&&fN(s.parent);let l=dN(o.roots,n);return l?(r===`child`?(l.node.children.push(c),fN(l.node)):l.siblings.splice(l.index+ +(r===`after`),0,c),o):e}function bN(e,t){let n=uN(e),r=dN(n.roots,t);return!r||r.index===0?e:([r.siblings[r.index-1],r.siblings[r.index]]=[r.siblings[r.index],r.siblings[r.index-1]],n)}function xN(e,t){let n=uN(e),r=dN(n.roots,t);return!r||r.index>=r.siblings.length-1?e:([r.siblings[r.index],r.siblings[r.index+1]]=[r.siblings[r.index+1],r.siblings[r.index]],n)}function SN(e,t){let n=uN(e),r=dN(n.roots,t);return r?(r.node.label=r.node.label.endsWith(`/`)?r.node.label.slice(0,-1):`${r.node.label}/`,fN(r.node),n):e}function CN(e,t){let n=new Set,r=e=>e.forEach(e=>(n.add(e.label),r(e.children)));r(e.roots);let i=t?`folder`:`item`,a=1;for(;n.has(`${i}${a}`)||n.has(`${i}${a}/`);)a++;return`${i}${a}`}function wN(e){let t=0;for(let n of e)t+=1+wN(n.children);return t}function TN(e,t,n){let r=VN(e,t);if(r===null)return!1;let i=e.state.doc.nodeAt(r);if(!i||i.type.name!==`codeBlock`)return!1;let a=BN(i);if(!a)return!1;let o=n(a);if(o===a)return!1;let s=D(o);return wN(E(s).roots)===wN(o.roots)&&lO(e,r,s,`tree`)}function EN(e,t,n){if(!e.isEditable)return!1;switch(n.kind){case`addItem`:return TN(e,t,e=>hN(e,n.targetId,n.position,n.label,n.isDir));case`renameItem`:return TN(e,t,e=>mN(e,n.id,n.label));case`indentItem`:return TN(e,t,e=>_N(e,n.id));case`outdentItem`:return TN(e,t,e=>vN(e,n.id));case`moveItem`:return TN(e,t,e=>yN(e,n.id,n.targetId,n.position));case`moveItemUp`:return TN(e,t,e=>bN(e,n.id));case`moveItemDown`:return TN(e,t,e=>xN(e,n.id));case`removeItem`:return TN(e,t,e=>gN(e,n.id));case`toggleDir`:return TN(e,t,e=>SN(e,n.id))}return!1}var DN=`application/x-squisq-tree-node`;function ON(e,t){for(let n of e){if(n.id===t)return n;let e=ON(n.children,t);if(e)return e}return null}function kN(e,t){return e.id===t||e.children.some(e=>kN(e,t))}function AN(e,t,n){let r=ON(e,t);return r!=null&&!kN(r,n)}function jN(e){let t=e.currentTarget.getBoundingClientRect();if(t.height<=0)return`child`;let n=(e.clientY-t.top)/t.height;return n<.3?`before`:n>.7?`after`:`child`}function MN({editor:e,blockId:t}){let n=GN(e,t),[r,i]=(0,G.useState)(()=>new Set),a=(0,G.useRef)(null),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(null),u=(0,G.useCallback)(n=>EN(e,t,n),[e,t]),d=(0,G.useCallback)(e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),f=(0,G.useCallback)(()=>{a.current=null,s(null),l(null)},[]),p=(0,G.useCallback)((e,t)=>{e.stopPropagation(),a.current=t,s(t),l(null),e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(DN,t),e.dataTransfer.setData(`text/plain`,t)},[]),m=(0,G.useCallback)((e,t)=>{let r=a.current;if(!r)return;if(e.preventDefault(),e.stopPropagation(),!n||!AN(n.tree.roots,r,t)){e.dataTransfer.dropEffect=`none`,l(null);return}let i=jN(e);e.dataTransfer.dropEffect=`move`,l(e=>e?.id===t&&e.position===i?e:{id:t,position:i})},[n]),h=(0,G.useCallback)((e,t)=>{let r=a.current;if(!r)return;e.preventDefault(),e.stopPropagation();let o=jN(e),s=n&&AN(n.tree.roots,r,t);f(),s&&u({kind:`moveItem`,id:r,targetId:t,position:o})&&o===`child`&&i(e=>{if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n})},[f,u,n]);if(!n)return null;let g=n.tree.roots,_=g[0]?.id;return(0,K.jsxs)(`div`,{className:`squisq-tree-outline`,children:[(0,K.jsxs)(`div`,{className:`squisq-tree-toolbar`,children:[(0,K.jsxs)(`button`,{type:`button`,className:`squisq-tree-btn`,title:`Add file`,disabled:!_,onClick:()=>_?u({kind:`addItem`,targetId:_,position:`siblingAfter`}):void 0,children:[(0,K.jsx)(q,{icon:`fa-solid fa-plus`}),` Item`]}),(0,K.jsxs)(`button`,{type:`button`,className:`squisq-tree-btn`,title:`Add folder`,disabled:!_,onClick:()=>_?u({kind:`addItem`,targetId:_,position:`siblingAfter`,isDir:!0}):void 0,children:[(0,K.jsx)(q,{icon:`fa-solid fa-folder-plus`}),` Folder`]})]}),(0,K.jsx)(`ul`,{className:`squisq-tree-rows`,role:`tree`,children:g.map(e=>(0,K.jsx)(NN,{node:e,depth:0,collapsed:r,draggedId:o,dropTarget:c,toggleCollapse:d,dispatch:u,onDragStart:p,onDragOver:m,onDrop:h,onDragEnd:f},e.id))}),n.warnings.length>0?(0,K.jsxs)(`div`,{className:`squisq-tree-warnings`,children:[n.warnings.length,` parser note`,n.warnings.length===1?``:`s`]}):null]})}function NN({node:e,depth:t,collapsed:n,draggedId:r,dropTarget:i,toggleCollapse:a,dispatch:o,onDragStart:s,onDragOver:c,onDrop:l,onDragEnd:u}){let d=e.children.length>0,f=n.has(e.id),p=e.isDir||d,[m,h]=(0,G.useState)(e.label),g=i?.id===e.id?i.position:null,_=[`squisq-tree-item`,r===e.id?`squisq-tree-item--dragging`:``,g?`squisq-tree-item--drop-${g}`:``].filter(Boolean).join(` `),v=()=>{m!==e.label&&m.trim().length>0&&o({kind:`renameItem`,id:e.id,label:m})};return(0,K.jsxs)(`li`,{className:_,role:`treeitem`,style:{paddingLeft:`${t*18}px`},children:[(0,K.jsxs)(`div`,{className:`squisq-tree-row`,onDragOver:t=>c(t,e.id),onDrop:t=>l(t,e.id),children:[d?(0,K.jsx)(`button`,{type:`button`,className:`squisq-tree-chevron`,"aria-label":f?`Expand`:`Collapse`,onClick:()=>a(e.id),children:(0,K.jsx)(q,{icon:`fa-solid ${f?`fa-chevron-right`:`fa-chevron-down`}`})}):(0,K.jsx)(`span`,{className:`squisq-tree-chevron squisq-tree-chevron--empty`}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-tree-icon`,title:p?`Make a file`:`Make a folder`,onClick:()=>o({kind:`toggleDir`,id:e.id}),children:(0,K.jsx)(q,{icon:`fa-solid ${p?`fa-folder`:`fa-file`}`})}),(0,K.jsx)(`input`,{className:`squisq-tree-label`,value:m,onChange:e=>h(e.target.value),onBlur:v,onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),v(),o({kind:`addItem`,targetId:e.id,position:`siblingAfter`})):t.key===`Backspace`&&m.length===0?(t.preventDefault(),o({kind:`removeItem`,id:e.id})):t.key===`Tab`&&(t.preventDefault(),v(),o({kind:t.shiftKey?`outdentItem`:`indentItem`,id:e.id}))}}),(0,K.jsxs)(`span`,{className:`squisq-tree-controls`,children:[(0,K.jsx)(`span`,{className:`squisq-tree-drag-handle`,draggable:!0,"aria-hidden":`true`,title:`Drag ${e.label} to move`,onDragStart:t=>s(t,e.id),onDragEnd:u,children:(0,K.jsx)(q,{icon:`fa-solid fa-grip-vertical`})}),(0,K.jsx)(`button`,{type:`button`,title:`Add child`,onClick:()=>o({kind:`addItem`,targetId:e.id,position:`child`}),children:(0,K.jsx)(q,{icon:`fa-solid fa-plus`})}),(0,K.jsx)(`button`,{type:`button`,title:`Outdent`,onClick:()=>o({kind:`outdentItem`,id:e.id}),children:(0,K.jsx)(q,{icon:`fa-solid fa-outdent`})}),(0,K.jsx)(`button`,{type:`button`,title:`Indent`,onClick:()=>o({kind:`indentItem`,id:e.id}),children:(0,K.jsx)(q,{icon:`fa-solid fa-indent`})}),(0,K.jsx)(`button`,{type:`button`,title:`Move up`,onClick:()=>o({kind:`moveItemUp`,id:e.id}),children:(0,K.jsx)(q,{icon:`fa-solid fa-arrow-up`})}),(0,K.jsx)(`button`,{type:`button`,title:`Move down`,onClick:()=>o({kind:`moveItemDown`,id:e.id}),children:(0,K.jsx)(q,{icon:`fa-solid fa-arrow-down`})}),(0,K.jsx)(`button`,{type:`button`,title:`Delete`,className:`squisq-tree-delete`,onClick:()=>o({kind:`removeItem`,id:e.id}),children:(0,K.jsx)(q,{icon:`fa-solid fa-trash`})})]})]}),d&&!f?(0,K.jsx)(`ul`,{className:`squisq-tree-rows`,role:`group`,children:e.children.map(e=>(0,K.jsx)(NN,{node:e,depth:t+1,collapsed:n,draggedId:r,dropTarget:i,toggleCollapse:a,dispatch:o,onDragStart:s,onDragOver:c,onDrop:l,onDragEnd:u},e.id))}):null]})}var PN=new Dr(`squisq-treeview`),FN=new WeakMap,IN=new WeakMap;function LN(e){let t=e.attrs.language;return typeof t==`string`?t:null}function RN(e){let t=0;for(let n of e)t+=1+RN(n.children);return t}function zN(e){if(e.type.name!==`codeBlock`)return null;let t=FN.get(e);if(t!==void 0)return t;let n=null,r=LN(e);if(m(r)){let t=u(e.textContent,{explicit:he(r)});t.isTree&&t.tree&&(n=t.tree,IN.set(e,n))}return FN.set(e,n),n}function BN(e){if(e.type.name!==`codeBlock`)return null;let t=IN.get(e);if(t!==void 0)return t;let n=null;if(m(LN(e))){let t=e.textContent;if(me(t).nodes.length<2){let e=E(t);RN(e.roots)>0&&(n=e)}}return IN.set(e,n),n}function VN(e,t){return PN.getState(e.state)?.entries.find(e=>e.id===t)?.pos??null}function HN(e,t,n){let r=[];for(let i of t){let t=e.nodeAt(i.pos);if(!t||t.type.name!==`codeBlock`)continue;r.push(sr.node(i.pos,i.pos+t.nodeSize,{class:`squisq-tree-fence-hidden`}));let a=i.id,o=i.pos;r.push(sr.widget(i.pos+t.nodeSize,e=>{let t=document.createElement(`div`);t.className=`squisq-tree-widget-host`,t.contentEditable=`false`,_O(t);let r=(0,Gr.createRoot)(t);return r.render((0,G.createElement)(MN,{editor:n,blockId:a,fallbackPos:o,host:e.dom.parentElement??e.dom})),t.__squisqTreeRoot={root:r},t},{destroy:e=>{let t=e.__squisqTreeRoot;t&&setTimeout(()=>t.root.unmount(),0)},side:1,ignoreSelection:!0,key:`squisq-tree-${i.id}`}))}return or.create(e,r)}function UN(e,t,n,r){if(!e.docChanged)return t;let i=eO(e,t.entries,r),a=t.seq,o=[];return r.descendants((e,t)=>{if(e.type.name!==`codeBlock`)return;let n=i.get(t);return(n?BN(e):zN(e))&&o.push({id:n??`tree-${++a}`,pos:t}),!1}),{entries:o,seq:a,decorations:HN(r,o,n)}}var WN=kr.create({name:`squisqTreeView`,addOptions(){return{enabled:!0}},addProseMirrorPlugins(){let e=this.editor;return this.options.enabled===!1?[]:[new pr({key:PN,state:{init:(t,n)=>{let r=0,i=[];return n.doc.descendants((e,t)=>{if(e.type.name===`codeBlock`)return zN(e)&&i.push({id:`tree-${++r}`,pos:t}),!1}),{entries:i,seq:r,decorations:HN(n.doc,i,e)}},apply:(t,n,r,i)=>UN(t,n,e,i.doc)},props:{decorations(e){return this.getState(e)?.decorations??or.empty}}})]}});function GN(e,t){let[n,r]=(0,G.useState)(0);return(0,G.useEffect)(()=>{let t=()=>r(e=>e+1);return e.on(`transaction`,t),()=>{e.off(`transaction`,t)}},[e]),(0,G.useMemo)(()=>{let n=VN(e,t);if(n===null)return null;let r=e.state.doc.nodeAt(n);if(!r||r.type.name!==`codeBlock`)return null;let i=BN(r);return i?{tree:i,text:r.textContent,warnings:i.warnings}:null},[e,t,n])}function KN(e){return!e||e.includes("```")?!1:u(e).isTree}var qN=/[●○◉◆◇•]+/gu,JN=/^[─━═╌╍┄┅┈┉-]+/u,YN=1e3,XN=1/YN/2;function ZN(e){return e.normalize(`NFC`).replace(/[\r\n\t]+/g,` `).replace(qN,`·`).replace(/\*/g,`∗`).replace(/::/g,`∶`).replace(/\s+/g,` `).trim().replace(JN,e=>Array.from(e,e=>e===`-`?`−`:`–`).join(``))}function QN(e,t=`event`){let n=new Set(e.tracks.flatMap(e=>e.events.map(e=>e.id))),r=cP(t,`event`);if(!n.has(r))return r;let i=2;for(;n.has(`${r}-${i}`);)i++;return`${r}-${i}`}function $N(e,t=`track`){let n=new Set(e.tracks.map(e=>e.id)),r=cP(t,`track`);if(!n.has(r))return r;let i=2;for(;n.has(`${r}-${i}`);)i++;return`${r}-${i}`}function eP(e,t={}){let n=ZN(t.label??``)||`New line`,r=ZN(t.eventLabel??``)||`New event`,i=$N(e,t.id??n),a=QN(e,t.eventId??r),{start:o,span:s}=oP(e),c=Math.round((o+s/2)*YN)/YN,l=e.tracks.reduce((e,t)=>Math.max(e,t.row),-1)+1,u={id:i,label:n,row:l,startColumn:o,endColumn:o+s,events:[{id:a,label:r,column:c,side:`above`,marker:`filled`}]};return{timeline:{...e,tracks:[...e.tracks,u],width:Math.max(e.width,Math.ceil(u.endColumn)+1),height:Math.max(e.height,l+1)},trackId:i,eventId:a}}function tP(e,t,n){let r=e.tracks.find(e=>e.id===t),i=ZN(n);return!r||!i||r.label===i?e:{...e,tracks:e.tracks.map(e=>e.id===t?{...e,label:i}:e)}}function nP(e,t){if(e.tracks.length<=1)return e;let n=e.tracks.find(e=>e.id===t);if(!n)return e;let r=new Set(n.events.map(e=>e.id));return{...e,tracks:e.tracks.filter(e=>e.id!==t),links:e.links.filter(e=>!r.has(e.source)&&!r.has(e.target))}}function rP(e,t,n,r={}){if(!Number.isFinite(n))return null;let i=e.tracks.find(e=>e.id===t);if(!i)return null;let a=sP(e,n);if(i.events.some(e=>Math.abs(e.column-a)<=XN))return null;let o=ZN(r.label??``)||`New event`,s=ZN(r.description??``),c=QN(e,r.id??o),l=i.events.filter(e=>e.column<a).length,u=r.side??(l%2==0?`above`:`below`),d={id:c,label:o,...s?{description:s}:{},column:a,side:u,...s&&r.descriptionSide?{descriptionSide:r.descriptionSide}:{},...r.callout===!1?{callout:!1}:{},marker:r.marker??`filled`},f=[...i.events,d].sort((e,t)=>e.column-t.column||e.id.localeCompare(t.id)),p=e.tracks.map(e=>e.id===t?{...e,events:f}:e),m=r.marker===`diamond`?`unicode`:e.style;return{timeline:{...e,tracks:p,style:m},eventId:c}}function iP(e,t,n){let r=lP(e,t);if(!r||Object.keys(n).length===0)return e;let i=Object.prototype.hasOwnProperty.call(n,`label`),a=Object.prototype.hasOwnProperty.call(n,`description`),o=Object.prototype.hasOwnProperty.call(n,`descriptionSide`),s=Object.prototype.hasOwnProperty.call(n,`position`),c=i?ZN(n.label??``):r.event.label;if(!c)return e;let l=a?ZN(n.description??``):r.event.description;l||=void 0;let u=r.event.column;if(s&&(!Number.isFinite(n.position)||(u=sP(e,n.position),r.track.events.some(e=>e.id!==t&&Math.abs(e.column-u)<=XN))))return e;let d=i||a,f=n.callout===void 0?d&&r.event.callout===!1?!0:r.event.callout:n.callout,p=l?o?n.descriptionSide??void 0:r.event.descriptionSide:void 0,m={...r.event,label:c,column:u,...l?{description:l}:{},...n.side?{side:n.side}:{},...p?{descriptionSide:p}:{},...f===void 0?{}:{callout:f},...n.marker?{marker:n.marker}:{}};if(l||delete m.description,p||delete m.descriptionSide,uP(r.event,m))return e;let h=r.track.events.map(e=>e.id===t?m:e).sort((e,t)=>e.column-t.column||e.id.localeCompare(t.id)),g=s&&m.column!==r.event.column,_=g&&Math.abs(r.event.column-r.track.startColumn)<=XN,v=g&&Math.abs(r.event.column-r.track.endColumn)<=XN,y=Math.min(...h.map(e=>e.column)),b=Math.max(...h.map(e=>e.column)),x=_?y:Math.min(r.track.startColumn,y),S=v?b:Math.max(r.track.endColumn,b),C=e.tracks.map(e=>e.id===r.track.id?{...e,startColumn:x,endColumn:S,events:h}:e),w=n.marker===`diamond`?`unicode`:e.style;return{...e,tracks:C,style:w}}function aP(e,t){let n=lP(e,t);if(!n||e.tracks.reduce((e,t)=>e+t.events.length,0)<=1)return e;let r=e.tracks.map(e=>e.id===n.track.id?{...e,events:e.events.filter(e=>e.id!==t)}:e).filter(e=>e.events.length>0),i=e.links.filter(e=>e.source!==t&&e.target!==t);return{...e,tracks:r,links:i}}function oP(e){if(e.tracks.length===0)return{start:0,span:1};let t=Math.min(...e.tracks.map(e=>e.startColumn)),n=Math.max(...e.tracks.map(e=>e.endColumn));return{start:t,span:Math.max(1,n-t)}}function sP(e,t){let{start:n,span:r}=oP(e);return Math.round((n+Math.max(0,Math.min(1,t))*r)*YN)/YN}function cP(e,t){return ZN(e).toLowerCase().replace(/[^a-z0-9_.~-]+/g,`-`).replace(/^-+|-+$/g,``)||t}function lP(e,t){for(let n of e.tracks){let e=n.events.find(e=>e.id===t);if(e)return{track:n,event:e}}return null}function uP(e,t){return e.id===t.id&&e.label===t.label&&e.description===t.description&&e.column===t.column&&e.side===t.side&&e.descriptionSide===t.descriptionSide&&e.callout===t.callout&&e.marker===t.marker}var dP={applied:!1},fP={applied:!1,reason:`read-only`},pP={applied:!1,reason:`unsafe-source`};function mP(e){return e.tracks.reduce((e,t)=>e+t.events.length,0)}function hP(e,t){return e.tracks.some(e=>e.events.some(e=>e.id===t))}function gP(e,t){return e.tracks.some(e=>e.id===t)}function _P(e){return JSON.stringify({style:e.style,tracks:e.tracks.map(e=>({id:e.id,label:e.label,endLabel:e.endLabel,startColumn:e.startColumn,endColumn:e.endColumn,events:e.events.map(e=>({id:e.id,label:e.label,description:e.description,column:e.column,side:e.side,descriptionSide:e.descriptionSide,callout:e.callout,marker:e.marker}))})),links:e.links,warnings:e.warnings})}var vP=/\{([^{}\r\n]*)\}/gu,yP=/^(?:#[^\s{}]*|[A-Za-z][A-Za-z0-9]*=)/u,bP=/(?:\{[^{}\r\n]*(?:#[^\s{}]+|[A-Za-z][A-Za-z0-9]*=)|(?:#[^\s{}]+|[A-Za-z][A-Za-z0-9]*=)[^{}\r\n]*\})/u,xP=/[●○◉◆◇•]/u,SP=new Set([`*`,`o`,`O`]),CP=new Set([`─`,`━`,`═`,`╌`,`╍`,`┄`,`┅`,`┈`,`┉`,`-`]),wP=/[─━═╌╍┄┅┈┉●○◉◆◇•►▶▷→>▲△▼▽│|└┌├┬┘┐╰╭╯╮:\-*]/gu,TP=/[\p{L}\p{N}_]+|[^\s]/gu;function EP(e,t){let n=new Set(t.tracks.map(e=>e.row)),r=e.replace(/\r\n?/g,`
|
|
500
|
+
`).split(`
|
|
501
|
+
`);for(let e=0;e<r.length;e++){let i=r[e],a=n.has(e),o=/[▲△▼▽^v]/u.test(i);if(!a&&!o)continue;let s=a?OP(i,t.style):-1,c=!0,l=i.replace(vP,(e,t,n)=>{let r=t.trim()?t.trim().split(/\s+/u):[];return r.some(e=>yP.test(e))?(DP(r,a&&s>=0&&n<s?`track`:`event`)||(c=!1),` `.repeat(e.length)):e});if(!c||bP.test(l))return null;r[e]=l}return r.join(`
|
|
502
|
+
`)}function DP(e,t){if(e.length===0)return!1;let n=new Set;for(let r of e){let e,i=!1;if(r.startsWith(`#`)&&r.length>1)e=`#`,i=!/[{}\s]/u.test(r.slice(1));else{let n=r.indexOf(`=`);e=n>0?r.slice(0,n):r;let a=n>0?r.slice(n+1):``;t===`track`&&(e===`start`||e===`end`)?i=a.trim()!==``&&Number.isFinite(Number(a)):t===`event`&&e===`side`||t===`event`&&e===`descriptionSide`?i=a===`above`||a===`below`:t===`event`&&e===`column`?i=a.trim()!==``&&Number.isFinite(Number(a)):t===`event`&&e===`callout`&&(i=a===`true`||a===`false`)}if(!i||n.has(e))return!1;n.add(e)}return!0}function OP(e,t){if(t===`unicode`)return e.search(xP);for(let t=0;t<e.length;t++){if(!SP.has(e[t]))continue;let n=kP(e,t,-1),r=kP(e,t,1),i=/[\p{L}\p{N}_]/u.test(e[t-1]??``),a=/[\p{L}\p{N}_]/u.test(e[t+1]??``);if(n>=2&&!a||r>=2&&!i)return t}return-1}function kP(e,t,n){let r=0;for(let i=t+n;CP.has(e[i]??``);i+=n)r++;return r}function AP(e){let t=new Map,n=e.normalize(`NFC`).replace(wP,` `);for(let e of n.matchAll(TP)){let n=e[0].toLocaleLowerCase();t.set(n,(t.get(n)??0)+1)}return t}function jP(e,t){if(e.size!==t.size)return!1;for(let[n,r]of e)if(t.get(n)!==r)return!1;return!0}function MP(e,t){let n=new Set(t.tracks.map(e=>e.row)),r=e.split(`
|
|
503
|
+
`);for(let e=0;e<r.length;e++)if(!(!r[e].trim()||n.has(e))&&AP(r[e]).size===0)return!0;return!1}function NP(e,t){if(t.warnings.length>0)return!1;let n=d(t);if(!n)return!1;let r=w(n),i=_P(t);if(r.warnings.length>0||_P(r)!==i)return!1;if(o(e))return!0;let a=EP(e,t),s=EP(n,r);return!a||!s||MP(a,t)?!1:jP(AP(a),AP(s))}function PP(e,t){if(!t)return null;let n=w(t);if(d(n)!==t||n.tracks.length!==e.tracks.length||mP(n)!==mP(e)||n.links.length!==e.links.length)return null;let r=new Set(n.tracks.flatMap(e=>e.events.map(e=>e.id)));return new Set(n.tracks.map(e=>e.id)).size!==n.tracks.length||r.size!==mP(n)||n.links.some(e=>!r.has(e.source)||!r.has(e.target))?null:n}function FP(e,t,n,r){let i=XP(e,t);if(i===null)return dP;let a=e.state.doc.nodeAt(i);if(!a||a.type.name!==`codeBlock`)return dP;let o=YP(a);if(!o)return dP;if(!NP(a.textContent,o))return pP;let s=n(o);if(!s||s.timeline===o)return dP;let c=d(s.timeline),l=PP(s.timeline,c);return!l||s.eventId&&!hP(l,s.eventId)||s.trackId&&!gP(l,s.trackId)||r&&!r(l)||!lO(e,i,c,`timeline`)?dP:{applied:!0,...s.eventId?{eventId:s.eventId}:{},...s.trackId?{trackId:s.trackId}:{}}}function IP(e,t,n){if(!e.isEditable)return fP;switch(n.kind){case`addTrack`:return FP(e,t,e=>eP(e,{id:n.id,label:n.label,eventId:n.eventId,eventLabel:n.eventLabel}));case`updateTrack`:{let r=ZN(n.label);return FP(e,t,e=>({timeline:tP(e,n.trackId,n.label)}),e=>e.tracks.some(e=>e.id===n.trackId&&e.label===r))}case`removeTrack`:return FP(e,t,e=>({timeline:nP(e,n.trackId)}),e=>!gP(e,n.trackId));case`addEvent`:return FP(e,t,e=>rP(e,n.trackId,n.position,{id:n.id,label:n.label,description:n.description,side:n.side,descriptionSide:n.descriptionSide,callout:n.callout,marker:n.marker}));case`updateEvent`:return FP(e,t,e=>({timeline:iP(e,n.eventId,n.patch)}),e=>hP(e,n.eventId));case`removeEvent`:return FP(e,t,e=>({timeline:aP(e,n.eventId)}),e=>!hP(e,n.eventId))}return dP}var LP=e=>Math.max(0,Math.min(1,e));function RP({editor:e,blockId:t}){let n=eF(e,t),[r,i]=(0,G.useState)(null),[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)(null),p=(0,G.useRef)(null),[m,h]=(0,G.useState)(``),g=(0,G.useCallback)(n=>{let r=IP(e,t,n);return r.reason===`read-only`&&h(`Timeline is read only.`),r.reason===`unsafe-source`&&h(`Visual editing is paused until the timeline source is repaired.`),r},[e,t]),_=n?.text,v=n?.timeline,y=(0,G.useMemo)(()=>_&&v?NP(_,v):!1,[_,v]),b=e.isEditable,x=b&&y,S=(0,G.useMemo)(()=>{if(!n)return[];let e=N(n.timeline).tracks;return n.timeline.tracks.flatMap((t,n)=>{let r=e[n];return t.events.map((e,i)=>({event:e,trackId:t.id,trackIndex:n,position:r?.events[i]?.position??0}))})},[n]),C=(0,G.useMemo)(()=>d?S.map(e=>e.event.id===d.eventId?{...e,position:d.position}:e):S,[d,S]),w=(0,G.useMemo)(()=>new Map(C.map(e=>[e.event.id,e.position])),[C]),T=(0,G.useMemo)(()=>{if(!n||!r)return null;for(let e of n.timeline.tracks){let t=e.events.find(e=>e.id===r);if(t)return{event:t,trackId:e.id,trackLabel:e.label||`Track ${n.timeline.tracks.indexOf(e)+1}`}}return null},[r,n]);if((0,G.useEffect)(()=>{if(!n)return;let e=new Set(n.timeline.tracks.flatMap(e=>e.events.map(e=>e.id)));r&&e.has(r)||i(n.timeline.tracks[0]?.events[0]?.id??null)},[r,n]),(0,G.useEffect)(()=>{x||(o(null),c(null),u(null))},[x]),(0,G.useEffect)(()=>{!s||n?.timeline.tracks.some(e=>e.id===s)||c(null)},[s,n]),!n)return null;let E=S.length,D=()=>{if(!x)return;let e=g({kind:`addTrack`});e.applied&&e.eventId&&e.trackId&&(o(null),c(e.trackId),u(null),i(e.eventId),h(`New timeline line added. Edit its name on the line.`))},O=(e,t)=>{if(!x)return;let n=g({kind:`addEvent`,trackId:e,position:LP(t)});n.applied&&n.eventId&&(o(null),c(null),u(null),i(n.eventId),h(`New timeline point added. Edit its text below.`))},k=(e,t)=>{o(null),u(null),i(e.id),h(`${e.label||`Timeline point`} selected on ${t}.`)},A=(e,t)=>{let n=S.filter(t=>t.trackId!==e);g({kind:`removeTrack`,trackId:e}).applied&&(o(null),c(t=>t===e?null:t),u(null),T?.trackId===e&&i(n[0]?.event.id??null),h(`${t} line deleted.`))},j=e=>{let t=e.currentTarget.closest(`.squisq-ascii-timeline-rail`);if(!t)return null;let n=t.getBoundingClientRect();return n.width<=0||!Number.isFinite(e.clientX)?null:LP((e.clientX-n.left)/n.width)};return(0,K.jsxs)(`section`,{className:`squisq-ascii-timeline-editor`,"aria-label":`Timeline editor`,onKeyDown:e=>{e.key!==`Escape`||!a||(o(null),u(null),h(`Add point cancelled.`))},children:[(0,K.jsxs)(`header`,{className:`squisq-ascii-timeline-header`,children:[(0,K.jsxs)(`span`,{children:[(0,K.jsx)(q,{icon:`fa-solid fa-timeline`}),` Timeline`]}),(0,K.jsxs)(`div`,{className:`squisq-ascii-timeline-header-actions`,children:[x&&a?(0,K.jsx)(`small`,{children:`Click the line to add a point · Esc to cancel`}):x?(0,K.jsx)(`small`,{children:`Use + to add a point · Drag dots to move`}):b?(0,K.jsx)(`small`,{children:`Source repair needed`}):(0,K.jsx)(`small`,{children:`Read only`}),x?(0,K.jsxs)(`button`,{type:`button`,onClick:D,children:[(0,K.jsx)(q,{icon:`fa-solid fa-plus`}),` Add line`]}):null]})]}),(0,K.jsxs)(`div`,{className:`squisq-ascii-timeline-canvas`,style:{"--squisq-ascii-timeline-track-count":n.timeline.tracks.length},children:[n.timeline.links.length>0?(0,K.jsx)(`svg`,{className:`squisq-ascii-timeline-branches`,viewBox:`0 0 100 ${Math.max(1,n.timeline.tracks.length)*96}`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:n.timeline.links.map((e,t)=>{let n=C.find(t=>t.event.id===e.source),r=C.find(t=>t.event.id===e.target);if(!n||!r)return null;let i=n.position*100,a=r.position*100,o=n.trackIndex*96+48,s=r.trackIndex*96+48,c=n.trackIndex===r.trackIndex?o+(n.event.side===`below`?-30:30):(o+s)/2;return(0,K.jsx)(`path`,{d:`M ${i} ${o} C ${i} ${c}, ${a} ${c}, ${a} ${s}`,vectorEffect:`non-scaling-stroke`},`${e.source}-${e.target}-${t}`)})}):null,n.timeline.tracks.map((e,t)=>{let m=e.label||`Track ${t+1}`,_=e.events.map(e=>({event:e,position:w.get(e.id)??0})).sort((e,t)=>e.position-t.position),v=VP(_.map(e=>e.position)),y=x&&a===e.id;return(0,K.jsxs)(`div`,{className:`squisq-ascii-timeline-track`,children:[(0,K.jsxs)(`div`,{className:`squisq-ascii-timeline-track-label`,children:[(0,K.jsx)(zP,{trackId:e.id,label:m,editing:x&&s===e.id,editable:x,dispatch:g,onStart:()=>{o(null),u(null),c(e.id)},onFinish:()=>c(null)}),x?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{type:`button`,className:`squisq-ascii-timeline-track-delete`,"aria-label":`Delete line: ${m}`,disabled:n.timeline.tracks.length<=1,title:n.timeline.tracks.length>1?`Delete ${m} line and all of its points`:`A timeline needs one line`,onClick:()=>A(e.id,m),children:(0,K.jsx)(q,{icon:`fa-solid fa-trash`})}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-ascii-timeline-track-add`,"aria-label":`Add point to ${m} timeline`,"aria-pressed":y,title:y?`Cancel adding a point`:`Choose where to add a point`,onClick:()=>{c(null),o(t=>t===e.id?null:e.id),u(null),h(y?`Add point cancelled.`:`Choose where to add a point on ${m}.`)},children:`+`})]}):null]}),(0,K.jsxs)(`div`,{className:`squisq-ascii-timeline-rail${y?` squisq-ascii-timeline-rail--adding`:``}${x?``:` squisq-ascii-timeline-rail--readonly`}`,role:`group`,"aria-label":`${m} timeline rail`,title:y?`Click anywhere on the line to add a point`:void 0,onPointerMove:t=>{if(!y||d)return;let n=t.currentTarget.getBoundingClientRect();n.width<=0||u({trackId:e.id,position:LP((t.clientX-n.left)/n.width)})},onPointerLeave:()=>u(t=>t?.trackId===e.id?null:t),onClick:t=>{if(!y||t.target!==t.currentTarget)return;let n=t.currentTarget.getBoundingClientRect();n.width<=0||O(e.id,(t.clientX-n.left)/n.width)},children:[(0,K.jsx)(`span`,{className:`squisq-ascii-timeline-rail-line`,"aria-hidden":`true`}),y&&l?.trackId===e.id&&!d?(0,K.jsx)(`span`,{className:`squisq-ascii-timeline-add-ghost`,style:{left:`${l.position*100}%`},"aria-hidden":`true`,children:`+`}):null,y&&!d?v.map(t=>(0,K.jsx)(`button`,{type:`button`,className:`squisq-ascii-timeline-gap-add`,style:{left:`${t*100}%`},"aria-label":`Add point to ${m} at ${Math.round(t*100)} percent`,title:`Add point`,onClick:n=>{n.stopPropagation(),O(e.id,t)},children:`+`},t)):null,_.map(({event:e,position:t},n)=>{let a=r===e.id,s=d?.eventId===e.id,c=e.side??(n%2==0?`above`:`below`),l=e.descriptionSide??c;return(0,K.jsxs)(`span`,{className:`squisq-ascii-timeline-point squisq-ascii-timeline-point--${c}${s?` squisq-ascii-timeline-point--dragging`:``}`,style:{left:`${t*100}%`},children:[e.callout===!1?null:(0,K.jsx)(`span`,{className:`squisq-ascii-timeline-callout squisq-ascii-timeline-callout--${c}`,children:e.label}),e.callout!==!1&&e.description?(0,K.jsx)(`span`,{className:`squisq-ascii-timeline-description squisq-ascii-timeline-description--${l}`,children:e.description}):null,(0,K.jsx)(`button`,{type:`button`,className:`squisq-ascii-timeline-marker squisq-ascii-timeline-marker--${e.marker??`filled`}${a?` squisq-ascii-timeline-marker--selected`:``}`,"aria-label":`Edit ${e.label||`timeline point`}, ${m}, ${Math.round(t*100)} percent`,"aria-pressed":a,"aria-roledescription":x?`draggable timeline point`:void 0,title:x?`${e.description||e.label||`Timeline point`} \xB7 Drag to move`:e.description||e.label,draggable:!1,onPointerDown:n=>{!x||n.button!==void 0&&n.button!==0||j(n)!==null&&(n.stopPropagation(),o(null),u(null),i(e.id),p.current=null,f({eventId:e.id,pointerId:n.pointerId,startClientX:n.clientX,startPosition:t,position:t,moved:!1}),n.currentTarget.setPointerCapture?.(n.pointerId))},onPointerMove:t=>{if(!x||!s||d.pointerId!==t.pointerId)return;let n=j(t);n!==null&&(t.preventDefault(),t.stopPropagation(),f(r=>r?.eventId===e.id&&r.pointerId===t.pointerId?{...r,position:n,moved:r.moved||Math.abs(t.clientX-r.startClientX)>=3}:r))},onPointerUp:t=>{if(!s||d.pointerId!==t.pointerId)return;let n=j(t)??d.position,r=d.moved||Math.abs(t.clientX-d.startClientX)>=3;if(t.preventDefault(),t.stopPropagation(),t.currentTarget.hasPointerCapture?.(t.pointerId)&&t.currentTarget.releasePointerCapture(t.pointerId),f(null),!r){k(e,m);return}p.current=e.id;let i=g({kind:`updateEvent`,eventId:e.id,patch:{position:n}});i.applied?h(`${e.label||`Timeline point`} moved to ${Math.round(n*100)} percent.`):!i.reason&&Math.abs(n-d.startPosition)>.001&&h(`Timeline points cannot overlap. Move the point elsewhere.`)},onPointerCancel:e=>{!s||d.pointerId!==e.pointerId||(e.currentTarget.hasPointerCapture?.(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),f(null),h(`Timeline point move cancelled.`))},onClick:t=>{if(t.stopPropagation(),p.current===e.id){p.current=null;return}k(e,m)},onKeyDown:e=>HP(e)})]},e.id)}),e.endLabel?(0,K.jsx)(`span`,{className:`squisq-ascii-timeline-end-label`,children:e.endLabel}):null]})]},e.id)})]}),n.timeline.links.length>0?(0,K.jsx)(`ul`,{className:`squisq-ascii-timeline-link-list`,"aria-label":`Timeline branches`,children:n.timeline.links.map((e,t)=>(0,K.jsxs)(`li`,{children:[e.source,` → `,e.target,e.label?`: ${e.label}`:``]},`${e.source}-${e.target}-${t}`))}):null,T?(0,K.jsx)(BP,{selected:T,editable:x,canDelete:E>1,dispatch:g,onDelete:()=>{let e=S.filter(e=>e.event.id!==T.event.id);g({kind:`removeEvent`,eventId:T.event.id}).applied&&(i(e[0]?.event.id??null),h(`${T.event.label} deleted.`))}},`${T.trackId}:${T.event.id}`):null,y?null:(0,K.jsxs)(`div`,{className:`squisq-ascii-timeline-warnings`,role:`status`,children:[`Visual editing paused: this timeline contains source the canvas cannot safely rewrite. Repair it in Source view first.`,n.warnings.length>0?` (${n.warnings.length} parser note${n.warnings.length===1?``:`s`})`:``]}),(0,K.jsx)(`div`,{className:`squisq-sr-only`,"aria-live":`polite`,children:m})]})}function zP({trackId:e,label:t,editing:n,editable:r,dispatch:i,onStart:a,onFinish:o}){let[s,c]=(0,G.useState)(t);(0,G.useEffect)(()=>{n&&c(t)},[n,t]);let l=()=>{let n=s.trim();n?n!==t&&(i({kind:`updateTrack`,trackId:e,label:n}).applied||c(t)):c(t),o()};return r?n?(0,K.jsx)(`input`,{className:`squisq-ascii-timeline-track-name-input`,"aria-label":`Rename line: ${t}`,value:s,autoFocus:!0,onFocus:e=>e.currentTarget.select(),onChange:e=>c(e.target.value),onBlur:l,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.stopPropagation(),l()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),c(t),o())}}):(0,K.jsx)(`button`,{type:`button`,className:`squisq-ascii-timeline-track-name`,"aria-label":`Rename line: ${t}`,title:`Rename ${t}`,onClick:a,children:t}):(0,K.jsx)(`span`,{className:`squisq-ascii-timeline-track-name`,children:t})}function BP({selected:e,editable:t,canDelete:n,dispatch:r,onDelete:i}){let{event:a}=e,[o,s]=(0,G.useState)(a.label),[c,l]=(0,G.useState)(a.description??``);(0,G.useEffect)(()=>s(a.label),[a.label]),(0,G.useEffect)(()=>l(a.description??``),[a.description]);let u=e=>r(e),d=()=>{let e=o.trim();if(!e){s(a.label);return}e!==a.label&&(u({kind:`updateEvent`,eventId:a.id,patch:{label:e}}).applied||s(a.label))},f=()=>{let e=c.trim();e!==(a.description??``)&&(u({kind:`updateEvent`,eventId:a.id,patch:{description:e||void 0}}).applied||l(a.description??``))};return(0,K.jsxs)(`fieldset`,{className:`squisq-ascii-timeline-inspector`,disabled:!t,children:[(0,K.jsxs)(`legend`,{children:[`Edit point `,(0,K.jsx)(`span`,{children:e.trackLabel})]}),(0,K.jsxs)(`label`,{children:[(0,K.jsx)(`span`,{children:`Label`}),(0,K.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),onBlur:d,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),d(),e.currentTarget.blur()):e.key===`Escape`&&(s(a.label),e.currentTarget.blur())}})]}),(0,K.jsxs)(`label`,{className:`squisq-ascii-timeline-inspector-description`,children:[(0,K.jsx)(`span`,{children:`Callout text`}),(0,K.jsx)(`textarea`,{rows:2,value:c,onChange:e=>l(e.target.value),onBlur:f,onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&e.key===`Enter`?(e.preventDefault(),f(),e.currentTarget.blur()):e.key===`Escape`&&(l(a.description??``),e.currentTarget.blur())}})]}),(0,K.jsxs)(`label`,{children:[(0,K.jsx)(`span`,{children:`Label side`}),(0,K.jsxs)(`select`,{value:a.side??`above`,onChange:e=>u({kind:`updateEvent`,eventId:a.id,patch:{side:e.target.value}}),children:[(0,K.jsx)(`option`,{value:`above`,children:`Above`}),(0,K.jsx)(`option`,{value:`below`,children:`Below`})]})]}),(0,K.jsxs)(`label`,{children:[(0,K.jsx)(`span`,{children:`Marker`}),(0,K.jsxs)(`select`,{value:a.marker??`filled`,onChange:e=>u({kind:`updateEvent`,eventId:a.id,patch:{marker:e.target.value}}),children:[(0,K.jsx)(`option`,{value:`filled`,children:`Filled dot`}),(0,K.jsx)(`option`,{value:`hollow`,children:`Hollow dot`}),(0,K.jsx)(`option`,{value:`diamond`,children:`Diamond`})]})]}),(0,K.jsxs)(`label`,{className:`squisq-ascii-timeline-checkbox`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:a.callout!==!1,onChange:e=>u({kind:`updateEvent`,eventId:a.id,patch:{callout:e.target.checked}})}),(0,K.jsx)(`span`,{children:`Show callout`})]}),(0,K.jsxs)(`button`,{type:`button`,className:`squisq-ascii-timeline-delete`,disabled:!n,title:n?`Delete point`:`A timeline needs at least one point`,onClick:i,children:[(0,K.jsx)(q,{icon:`fa-solid fa-trash`}),` Delete point`]})]})}function VP(e){if(e.length===0)return[.5];let t=[0,...[...e].sort((e,t)=>e-t),1],n=[];for(let e=0;e<t.length-1;e++){let r=t[e],i=t[e+1];i-r>=.09&&n.push((r+i)/2)}return n}function HP(e){if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;let t=e.currentTarget.closest(`.squisq-ascii-timeline-rail`);if(!t)return;let n=Array.from(t.querySelectorAll(`.squisq-ascii-timeline-marker`)),r=n.indexOf(e.currentTarget);r<0||(e.preventDefault(),(e.key===`Home`?n[0]:e.key===`End`?n[n.length-1]:e.key===`ArrowLeft`?n[Math.max(0,r-1)]:n[Math.min(n.length-1,r+1)])?.focus())}var UP=new Dr(`squisq-timeline-view`),WP=new WeakMap,GP=new WeakMap;function KP(e){let t=e.attrs.language;return typeof t==`string`?t:null}function qP(e){return e.tracks.reduce((e,t)=>e+t.events.length,0)}function JP(e){if(e.type.name!==`codeBlock`)return null;let t=WP.get(e);if(t!==void 0)return t;let n=null,r=KP(e);if(M(r)){let t=j(e.textContent,{explicit:O(r)});t.isTimeline&&t.timeline&&qP(t.timeline)>0&&(n=t.timeline,GP.set(e,n))}return WP.set(e,n),n}function YP(e){if(e.type.name!==`codeBlock`)return null;let t=GP.get(e);if(t!==void 0)return t;let n=null;if(M(KP(e))){let t=j(e.textContent,{explicit:!0});t.isTimeline&&t.timeline&&qP(t.timeline)>0&&(n=t.timeline)}return GP.set(e,n),n}function XP(e,t){return UP.getState(e.state)?.entries.find(e=>e.id===t)?.pos??null}function ZP(e,t,n){let r=[];for(let i of t){let t=e.nodeAt(i.pos);!t||t.type.name!==`codeBlock`||(r.push(sr.node(i.pos,i.pos+t.nodeSize,{class:`squisq-ascii-timeline-fence-hidden`})),r.push(sr.widget(i.pos+t.nodeSize,()=>{let e=document.createElement(`div`);e.className=`squisq-ascii-timeline-widget-host`,e.contentEditable=`false`,_O(e);let t=(0,Gr.createRoot)(e);return t.render((0,G.createElement)(RP,{editor:n,blockId:i.id})),e.__squisqTimelineRoot=t,e},{destroy:e=>{let t=e.__squisqTimelineRoot;t&&setTimeout(()=>t.unmount(),0)},side:1,ignoreSelection:!0,key:`squisq-timeline-${i.id}`})))}return or.create(e,r)}function QP(e,t,n,r){if(!e.docChanged)return t;let i=eO(e,t.entries,r),a=t.seq,o=[];return r.descendants((e,t)=>{if(e.type.name!==`codeBlock`)return;let n=i.get(t);return(n?YP(e):JP(e))&&o.push({id:n??`timeline-${++a}`,pos:t}),!1}),{entries:o,seq:a,decorations:ZP(r,o,n)}}var $P=kr.create({name:`squisqTimelineView`,addOptions(){return{enabled:!0}},addProseMirrorPlugins(){let e=this.editor;return this.options.enabled===!1?[]:[new pr({key:UP,state:{init:(t,n)=>{let r=0,i=[];return n.doc.descendants((e,t)=>{if(e.type.name===`codeBlock`)return JP(e)&&i.push({id:`timeline-${++r}`,pos:t}),!1}),{entries:i,seq:r,decorations:ZP(n.doc,i,e)}},apply:(t,n,r,i)=>QP(t,n,e,i.doc)},props:{decorations(e){return this.getState(e)?.decorations??or.empty}}})]}});function eF(e,t){let[n,r]=(0,G.useState)(0),i=(0,G.useRef)(null);return(0,G.useEffect)(()=>{let t=()=>r(e=>e+1);return e.on(`transaction`,t),e.on(`update`,t),()=>{e.off(`transaction`,t),e.off(`update`,t)}},[e]),(0,G.useMemo)(()=>{let n=XP(e,t);if(n===null)return null;let r=e.state.doc.nodeAt(n);if(!r||r.type.name!==`codeBlock`)return null;let a=r.textContent,o=r.attrs.language,s=typeof o==`string`?o:null,c=i.current;if(c?.text===a&&c.language===s)return c.data;let l=YP(r);if(!l)return null;let u={timeline:l,text:a,warnings:l.warnings};return i.current={text:a,language:s,data:u},u},[e,t,n])}function tF(e){return!e.trim()||/^\s*```/m.test(e)?!1:j(e).isTimeline}var nF=`.squisq-transition-flyout`;function rF({anchorRect:e,blockAttrs:t,templateParams:n,onChange:r,onAnnotationChange:i,colorScheme:a=`light`,accentColor:o,onClose:s}){let c=(0,G.useRef)(null),l=`squisq-block-props-portal-${(0,G.useId)().replace(/:/g,``)}`,[u,d]=(0,G.useState)(t),[f,p]=(0,G.useState)(n),[m,h]=(0,G.useState)(()=>oF(e));(0,G.useEffect)(()=>{requestAnimationFrame(()=>h(oF(e,c.current)))},[e]),(0,G.useEffect)(()=>{let e=e=>{e.key===`Escape`&&s()},t=e=>{let t=e.target,n=c.current?.contains(t),r=t.closest?.(nF);!n&&!r&&s()},n=requestAnimationFrame(()=>document.addEventListener(`mousedown`,t));return document.addEventListener(`keydown`,e),()=>{cancelAnimationFrame(n),document.removeEventListener(`mousedown`,t),document.removeEventListener(`keydown`,e)}},[s]);let g=e=>{d(e),r(e)},_=Dy(u,f),v=AD(u,`duration`),y=AD(u,`startTime`),b=e=>{let t=Oy(u,f,e);d(t.blockAttrsInner),p(t.templateParams),i(t)},x=e=>g(jD(u,`duration`,e)),S=e=>g(jD(u,`startTime`,e));return(0,Wr.createPortal)((0,K.jsxs)(`div`,{ref:c,id:l,className:`squisq-block-props-popover`,"data-theme":a,role:`dialog`,"aria-label":`Block properties`,style:{...m,...iF(o)},children:[(0,K.jsxs)(`div`,{className:`squisq-block-props-row`,children:[(0,K.jsx)(`span`,{className:`squisq-block-props-label`,children:`Transition`}),(0,K.jsx)(Ry,{value:_,onChange:b,colorScheme:a,accentColor:o})]}),(0,K.jsxs)(`div`,{className:`squisq-block-props-row`,children:[(0,K.jsx)(`span`,{className:`squisq-block-props-label`,children:`Duration`}),(0,K.jsx)(aF,{value:v,placeholder:`auto`,unit:`sec`,ariaLabel:`Block duration in seconds`,onChange:x})]}),(0,K.jsxs)(`div`,{className:`squisq-block-props-row`,children:[(0,K.jsx)(`span`,{className:`squisq-block-props-label`,children:`Start time`}),(0,K.jsx)(aF,{value:y,placeholder:`—`,unit:`sec`,ariaLabel:`Block start time in seconds`,onChange:S})]})]}),document.body)}function iF(e){return e?{"--squisq-block-props-accent":e}:{}}function aF({value:e,placeholder:t,unit:n,ariaLabel:r,onChange:i}){return(0,K.jsxs)(`div`,{className:`squisq-block-props-numfield`,children:[(0,K.jsx)(`input`,{type:`number`,min:`0`,step:`0.1`,className:`squisq-block-props-input`,placeholder:t,value:e,onChange:e=>i(e.target.value),"aria-label":r}),(0,K.jsx)(`span`,{className:`squisq-block-props-unit`,children:n})]})}function oF(e,t){let n=t?.getBoundingClientRect(),r=n?.width??280,i=n?.height??160,a=window.innerWidth,o=window.innerHeight,s=o-e.bottom-8,c;c=i+6<=s||e.top-8<i+6?e.bottom+6:e.top-i-6;let l=Math.max(8,a-r-8),u=Math.min(Math.max(8,e.left),l);return{position:`fixed`,top:c,left:u,maxHeight:`${o-16}px`,zIndex:9999}}function sF(e){let t=It(e);return t.kind!==`wrapped`||!t.width?{displayBody:e,state:null}:{displayBody:zt(e),state:t}}function cF(e,t){return!t||t.kind!==`wrapped`||!t.width?e:Nt(e,{width:t.width})}function lF(e){let t=e,n=new Set;return{getSnapshot:()=>t,subscribe:e=>(n.add(e),()=>n.delete(e)),setTheme:e=>{Object.is(t,e)||(t=e,n.forEach(e=>e()))}}}var uF=Cr.create({name:`inlineIcon`,group:`inline`,inline:!0,atom:!0,selectable:!0,draggable:!1,addAttributes(){return{token:{default:``,parseHTML:e=>e.getAttribute(`data-icon`)??``,renderHTML:e=>e.token?{"data-icon":e.token}:{}},family:{default:`solid`,parseHTML:e=>e.getAttribute(`data-family`)??`solid`,renderHTML:e=>e.family?{"data-family":e.family}:{}},name:{default:``,parseHTML:e=>e.getAttribute(`data-name`)??``,renderHTML:e=>e.name?{"data-name":e.name}:{}}}},parseHTML(){return[{tag:`i[data-icon]`,priority:100}]},renderHTML({HTMLAttributes:e}){let t=e[`data-family`]??`solid`,n=e[`data-name`]??``;return[`i`,Rr(e,{class:n?`fa-${t} fa-${n}`:``,contenteditable:`false`})]}});function dF(e){if(!e)return null;let t=e.match(/^https?:\/\/([^/?#]+)\/(.+)$/i);if(!t)return null;let[,n,r]=t;return n.includes(`.`)||n.includes(`:`)||!n.toLowerCase().endsWith(`_files`)?null:`${n}/${r}`}function fF({node:e,selected:t,editor:n,updateAttributes:r}){let{src:i,alt:a,title:o,width:s}=e.attrs,{mediaProvider:c,imageDisplayMode:l,openImageEdit:u,mediaRevision:d}=Lp(),[f,p]=(0,G.useState)(i),[m,h]=(0,G.useState)(!1),g=(0,G.useRef)(null),[_,v]=(0,G.useState)(null),y=l===`thumbnail`,b=n?.isEditable??!0,x=dF(i),S=i&&!i.startsWith(`blob:`)&&!i.startsWith(`http`)&&!i.startsWith(`data:`)&&!i.startsWith(`/`),C=x??(S?i:null);(0,G.useEffect)(()=>{if(!c||!C){p(i);return}let e=!1;return c.resolveUrl(C).then(t=>{e||p(t)},()=>{e||p(i)}),()=>{e=!0}},[i,C,c,d]);let w=b&&S&&c!==null&&(t||m),T=b&&!y,E=T&&(t||m),D=_??s??null,O=e=>{if(!T)return;e.preventDefault(),e.stopPropagation();let t=g.current;if(!t)return;let n=t.getBoundingClientRect().width,i=e.clientX,a=t.naturalWidth||1/0,o=e=>{let t=Math.max(24,Math.min(a,n+(e.clientX-i)));v(Math.round(t))},s=e=>{window.removeEventListener(`mousemove`,o),window.removeEventListener(`mouseup`,s);let c=Math.max(24,Math.min(a,n+(e.clientX-i))),l=t.naturalWidth,u=t.naturalHeight,d=Math.round(c),f=l>0&&u>0?Math.round(d*u/l):null;v(null),r({width:d,height:f})};window.addEventListener(`mousemove`,o),window.addEventListener(`mouseup`,s)},k=e=>{T&&(e.preventDefault(),e.stopPropagation(),v(null),r({width:null,height:null}))},A=y?{maxWidth:`100px`,maxHeight:`100px`,width:`auto`,height:`auto`,objectFit:`contain`,display:`block`}:D?{width:`${D}px`,maxWidth:`100%`,height:`auto`,display:`block`}:{maxWidth:`100%`,height:`auto`,display:`block`};return(0,K.jsxs)(xr,{as:`figure`,draggable:!0,"data-drag-handle":!0,style:{margin:`0.5em 0`,position:`relative`,display:`inline-block`,maxWidth:`100%`},onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),children:[(0,K.jsx)(`img`,{ref:g,src:f,alt:a||``,title:o||void 0,className:y?`squisq-image squisq-image--thumbnail`:`squisq-image`,style:A,draggable:!1,onDragStart:e=>e.preventDefault(),"data-selected":t?`true`:void 0}),w&&(0,K.jsxs)(`button`,{type:`button`,className:`squisq-image-edit-affordance`,"data-testid":`image-edit-affordance`,onMouseDown:e=>e.preventDefault(),onClick:e=>{e.preventDefault(),e.stopPropagation(),u(i)},title:`Edit image`,"aria-label":`Edit image ${a||i}`,children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,style:{fontSize:`0.95em`,lineHeight:1},children:`✎`}),(0,K.jsx)(`span`,{children:`Edit`})]}),E&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`squisq-image-resize-handle`,"data-testid":`image-resize-handle`,onMouseDown:O,onDoubleClick:k,title:`Drag to resize · double-click to reset`,"aria-label":`Resize image`,role:`separator`}),(_!=null||s!=null)&&(0,K.jsxs)(`span`,{className:`squisq-image-resize-readout`,"aria-hidden":`true`,children:[Math.round(D??0),`px`]})]})]})}var pF=$f.extend({draggable:!0,addAttributes(){return{...this.parent?.()??{},width:{default:null,parseHTML:e=>{let t=e.getAttribute(`width`);if(!t)return null;let n=parseInt(t,10);return Number.isFinite(n)&&n>0?n:null},renderHTML:e=>e.width?{width:String(e.width)}:{}},height:{default:null,parseHTML:e=>{let t=e.getAttribute(`height`);if(!t)return null;let n=parseInt(t,10);return Number.isFinite(n)&&n>0?n:null},renderHTML:e=>e.height?{height:String(e.height)}:{}}}},addNodeView(){return Sr(fF)}});function mF(e){let{mediaProvider:t,mediaRevision:n}=Lp(),[r,i]=(0,G.useState)(e),a=!!e&&!e.startsWith(`blob:`)&&!e.startsWith(`http:`)&&!e.startsWith(`https:`)&&!e.startsWith(`data:`)&&!e.startsWith(`/`);return(0,G.useEffect)(()=>{if(!t||!a){i(e);return}let n=!1;return t.resolveUrl(e).then(e=>{n||i(e)},()=>{n||i(e)}),()=>{n=!0}},[e,a,t,n]),r}var hF=[{value:`content`,label:`In layout`,title:`Participate in the block content layout`},{value:`picture-in-picture`,label:`PIP`,title:`Show above the composition as picture in picture`},{value:`overlay`,label:`Overlay`,title:`Show above the composition as full-frame video`}];function gF(e){return e===`picture-in-picture`||e===`overlay`?e:`content`}function _F(e){return e!==!1&&e!==`false`&&e!==0&&e!==`0`}function vF({node:e,updateAttributes:t,selected:n}){let{src:r,width:i,height:a,poster:o,controls:s,placement:c,lockToBlock:l}=e.attrs,u=gF(c),d=_F(l),f=mF(r??``),[p,m]=(0,G.useState)(!1),h=mF(o??``);return(0,G.useEffect)(()=>{m(!1)},[f]),(0,K.jsxs)(xr,{as:`div`,className:`${p?`squisq-inline-audio-player squisq-video-node--audio-only`:`squisq-inline-video-player`} squisq-video-node${n?` squisq-video-node--selected`:``}`,"data-video-placement":u,children:[!p&&(0,K.jsxs)(`div`,{className:`squisq-video-placement-toolbar`,role:`toolbar`,"aria-label":`Video placement`,contentEditable:!1,children:[(0,K.jsx)(`span`,{className:`squisq-video-placement-label`,children:`Video`}),hF.map(e=>(0,K.jsx)(`button`,{type:`button`,className:`squisq-video-placement-button`,"aria-pressed":u===e.value,title:e.title,onMouseDown:e=>e.preventDefault(),onClick:()=>t({placement:e.value}),children:e.label},e.value)),u!==`content`&&(0,K.jsx)(`button`,{type:`button`,className:`squisq-video-placement-button squisq-video-placement-button--lock`,"aria-label":`Lock to block`,"aria-pressed":d,title:d?`Locked to this block; turn off for independent document timing`:`Document-timed; turn on to follow this block`,onMouseDown:e=>e.preventDefault(),onClick:()=>t({lockToBlock:!d}),children:`Lock to block`})]}),p?(0,K.jsx)(`audio`,{"data-drag-handle":!0,draggable:!0,src:f||void 0,controls:s,preload:`metadata`}):(0,K.jsx)(`video`,{"data-drag-handle":!0,draggable:!0,src:f||void 0,poster:o?h:void 0,controls:s,playsInline:!0,preload:`metadata`,width:i??void 0,height:a??void 0,onLoadedMetadata:e=>{let t=e.currentTarget;m(t.videoWidth<=0&&t.videoHeight<=0)}})]})}var yF=Cr.create({name:`video`,group:`block`,atom:!0,draggable:!0,selectable:!0,addOptions(){return{HTMLAttributes:{}}},addAttributes(){return{src:{default:null},width:{default:null},height:{default:null},poster:{default:null},placement:{default:`content`,parseHTML:e=>gF(e.getAttribute(`data-squisq-video-placement`)),renderHTML:e=>{let t=gF(e.placement);return t===`content`?{}:{"data-squisq-video-placement":t}}},lockToBlock:{default:!0,parseHTML:e=>_F(e.getAttribute(`data-squisq-video-lock-to-block`)),renderHTML:e=>{let t=gF(e.placement),n=_F(e.lockToBlock);return t!==`content`&&!n?{"data-squisq-video-lock-to-block":`false`}:{}}},pipSize:{default:null,parseHTML:e=>e.getAttribute(`data-squisq-video-pip-size`),renderHTML:e=>e.pipSize===`small`||e.pipSize===`large`?{"data-squisq-video-pip-size":e.pipSize}:{}},pipShape:{default:null,parseHTML:e=>e.getAttribute(`data-squisq-video-pip-shape`),renderHTML:e=>e.pipShape===`square`||e.pipShape===`wide`?{"data-squisq-video-pip-shape":e.pipShape}:{}},pipPosition:{default:null,parseHTML:e=>e.getAttribute(`data-squisq-video-pip-position`),renderHTML:e=>e.pipPosition===`top-left`||e.pipPosition===`top-right`||e.pipPosition===`bottom-left`||e.pipPosition===`bottom-right`?{"data-squisq-video-pip-position":e.pipPosition}:{}},startAt:{default:null,parseHTML:e=>e.getAttribute(`data-squisq-video-start-at`),renderHTML:e=>(gF(e.placement)===`content`||!_F(e.lockToBlock))&&e.startAt!=null?{"data-squisq-video-start-at":String(e.startAt)}:{}},clipStart:{default:null,parseHTML:e=>e.getAttribute(`data-squisq-video-clip-start`),renderHTML:e=>(gF(e.placement)===`content`||!_F(e.lockToBlock))&&e.clipStart!=null?{"data-squisq-video-clip-start":String(e.clipStart)}:{}},clipEnd:{default:null,parseHTML:e=>e.getAttribute(`data-squisq-video-clip-end`),renderHTML:e=>(gF(e.placement)===`content`||!_F(e.lockToBlock))&&e.clipEnd!=null?{"data-squisq-video-clip-end":String(e.clipEnd)}:{}},controls:{default:!0,parseHTML:e=>e.hasAttribute(`controls`),renderHTML:e=>e.controls?{controls:``}:{}}}},parseHTML(){return[{tag:`video`}]},renderHTML({HTMLAttributes:e}){return[`video`,Rr(this.options.HTMLAttributes,e)]},addNodeView(){return Sr(vF)},addCommands(){return{setVideo:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}}});function bF({node:e}){let{src:t,controls:n}=e.attrs;return(0,K.jsx)(xr,{as:`span`,className:`squisq-inline-audio-player`,"data-drag-handle":!0,draggable:!0,children:(0,K.jsx)(`audio`,{src:mF(t??``)||void 0,controls:n,preload:`metadata`})})}var xF=Cr.create({name:`audio`,group:`block`,atom:!0,draggable:!0,selectable:!0,addOptions(){return{HTMLAttributes:{}}},addAttributes(){return{src:{default:null},controls:{default:!0,parseHTML:e=>e.hasAttribute(`controls`),renderHTML:e=>e.controls?{controls:``}:{}},startAt:{default:null,parseHTML:e=>e.getAttribute(`data-squisq-audio-start-at`),renderHTML:e=>e.startAt==null?{}:{"data-squisq-audio-start-at":String(e.startAt)}},clipStart:{default:null,parseHTML:e=>e.getAttribute(`data-squisq-audio-clip-start`),renderHTML:e=>e.clipStart==null?{}:{"data-squisq-audio-clip-start":String(e.clipStart)}},clipEnd:{default:null,parseHTML:e=>e.getAttribute(`data-squisq-audio-clip-end`),renderHTML:e=>e.clipEnd==null?{}:{"data-squisq-audio-clip-end":String(e.clipEnd)}}}},parseHTML(){return[{tag:`audio`}]},renderHTML({HTMLAttributes:e}){return[`audio`,Rr(this.options.HTMLAttributes,e)]},addNodeView(){return Sr(bF)},addCommands(){return{setAudio:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}}}),SF=`mention`;function CF(e){return op.configure({HTMLAttributes:{class:`mention`,"data-mention":`true`},renderHTML({options:e,node:t}){let n=t.attrs.label??t.attrs.id??``,r=t.attrs.id??``,i=t.attrs.kind??SF;return[`span`,{...e.HTMLAttributes,"data-kind":i,"data-id":r,"data-label":n},`@${n}`]},renderText({node:e}){let t=e.attrs.label??e.attrs.id??``,n=e.attrs.id??``;return`@[${t}](${e.attrs.kind??SF}:${n})`}}).extend({addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute(`data-id`),renderHTML:e=>e.id?{"data-id":e.id}:{}},label:{default:null,parseHTML:e=>e.getAttribute(`data-label`),renderHTML:e=>e.label?{"data-label":e.label}:{}},kind:{default:SF,parseHTML:e=>e.getAttribute(`data-kind`)??SF,renderHTML:e=>({"data-kind":e.kind??SF})}}},addOptions(){return{...this.parent?.()??{},suggestion:{char:`@`,pluginKey:new Dr(`mentionSuggestion`),command:({editor:e,range:t,props:n})=>{let r=n.id??``,i=n.label??r,a=`kind`in n&&typeof n.kind==`string`?n.kind:SF;e.chain().focus().insertContentAt(t,[{type:`mention`,attrs:{id:r,label:i,kind:a}},{type:`text`,text:` `}]).run()},items:async({query:t})=>{let n=e();if(!n)return[];try{return await n(t)}catch{return[]}},render:wF()}}}})}function wF(){return()=>{let e=null,t={items:[],selected:0},n=null,r=()=>{if(!(!e||!n)){if(e.innerHTML=``,t.items.length===0){e.style.display=`none`;return}e.style.display=`block`;for(let n=0;n<t.items.length;n++){let r=t.items[n],a=document.createElement(`button`);a.type=`button`,a.className=`squisq-mention-item`+(n===t.selected?` is-selected`:``),a.dataset.index=String(n),a.innerHTML=``;let o=document.createElement(`span`);if(o.className=`squisq-mention-label`,o.textContent=r.label,a.appendChild(o),r.description){let e=document.createElement(`span`);e.className=`squisq-mention-desc`,e.textContent=r.description,a.appendChild(e)}a.addEventListener(`mousedown`,e=>{e.preventDefault(),i(n)}),e.appendChild(a)}TF(e,n.clientRect)}},i=e=>{let r=t.items[e];!r||!n||n.command({id:r.id,label:r.label,kind:r.scheme})};return{onStart:i=>{n=i,t={items:i.items??[],selected:0},e||(e=document.createElement(`div`),e.className=`squisq-mention-popover`,e.style.position=`absolute`,e.style.zIndex=`10000`,document.body.appendChild(e)),r()},onUpdate:e=>{n=e,Array.isArray(e.items)&&(t={items:e.items,selected:0}),r()},onKeyDown:({event:e})=>t.items.length?e.key===`ArrowDown`?(t.selected=(t.selected+1)%t.items.length,r(),!0):e.key===`ArrowUp`?(t.selected=(t.selected-1+t.items.length)%t.items.length,r(),!0):e.key===`Enter`||e.key===`Tab`?(i(t.selected),!0):e.key===`Escape`?(t={items:[],selected:0},r(),!0):!1:!1,onExit:()=>{e?.parentNode&&e.parentNode.removeChild(e),e=null,n=null}}}}function TF(e,t){let n=t?.();if(!n)return;let r=window.innerHeight,i=Math.min(e.offsetHeight||240,r-16),a=n.top-i-4,o=a>=0;e.style.left=`${n.left+window.scrollX}px`,o?e.style.top=`${a+window.scrollY}px`:e.style.top=`${n.bottom+4+window.scrollY}px`}var EF=[/^#{1,6}\s+\S/,/^[-*+]\s+\S/,/^\d+\.\s+\S/,/^>\s+\S/,/^```/,/^\|.+\|\s*$/,/^[-*+]\s+\[[ xX]\]\s+/],DF=[/\*\*[^*\n]+\*\*/,/__[^_\n]+__/,/`[^`\n]+`/,/\[[^\]\n]+\]\([^)\n]+\)/,/!\[[^\]\n]*\]\([^)\n]+\)/,/~~[^~\n]+~~/];function OF(e){if(!e||e.length<2)return!1;let t=e.split(/\r?\n/);for(let e of t){let t=e.trim();if(t){for(let e of EF)if(e.test(t))return!0}}let n=0;for(let t of DF)if(t.test(e)&&(n++,n>=2))return!0;return!1}async function kF(e,t,n,r){let i=t.map(()=>`squisq-upload:${PF()}`),a=e.state.schema.nodes.image;if(!a)return;let o=e.state.tr;for(let e of i)o=o.replaceSelectionWith(a.create({src:`data:image/gif;base64,R0lGODlhAQABAAAAACw=`,alt:`Uploading image`,title:e}));e.dispatch(o);for(let a=0;a<t.length;a++){let o=t[a],s=i[a];try{let t=await o.arrayBuffer(),i=o.type||`image/png`,a=o.name&&o.name!==`image.png`?o.name:`pasted-${PF()}.${FF(i)}`;jF(e,s,await n.addMedia(a,t,i),a.replace(/\.[^.]+$/,``).replace(/[-_]/g,` `)),r?.()}catch(t){MF(e,s),console.error(`Failed to upload dropped image:`,t)}}}function AF(e,t){let n=null;return e.state.doc.descendants((r,i)=>{if(r.type===e.state.schema.nodes.image&&r.attrs.title===t)return n={pos:i,node:r},!1}),n}function jF(e,t,n,r){let i=AF(e,t);i&&e.dispatch(e.state.tr.setNodeMarkup(i.pos,void 0,{...i.node.attrs,src:n,alt:r,title:null}))}function MF(e,t){let n=AF(e,t);n&&e.dispatch(e.state.tr.delete(n.pos,n.pos+n.node.nodeSize))}var NF=0;function PF(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():(NF=(NF+1)%1e6,`${Date.now()}-${NF.toString(36)}`)}function FF(e){return{"image/png":`png`,"image/jpeg":`jpg`,"image/jpg":`jpg`,"image/gif":`gif`,"image/webp":`webp`,"image/svg+xml":`svg`,"image/avif":`avif`}[e.toLowerCase()]??`png`}function IF(e){let t={};LF(e?.textSize)&&(t[`--squisq-write-text-size`]=`${e.textSize}px`),LF(e?.lineSpacing)&&(t[`--squisq-write-line-spacing`]=String(e.lineSpacing));let n=RF(e?.headerFont);n&&(t[`--squisq-write-header-font`]=n);let r=RF(e?.bodyFont);return r&&(t[`--squisq-write-body-font`]=r),t}function LF(e){return typeof e==`number`&&Number.isFinite(e)&&e>0}function RF(e){if(typeof e!=`string`)return;let t=e.trim();if(t&&!/[;{}<>]/.test(t)&&!/[\x00-\x1f]/.test(t))return t}var zF=`squisq-attachment-link`;function BF(e,t){for(let n of e.querySelectorAll(`a[href]`)){let e=n.getAttribute(`href`)??``;n.classList.toggle(zF,t.has(e))}}var VF=Zf.extend({addAttributes(){return{...this.parent?.(),title:{default:null}}}}),HF=[`Start typing your content, or drop files on top of me...`,`Write anything -- paste markdown, drag in media, or just start typing...`,`Type away. Markdown syntax works too...`,`Chapter 1 begins here...`,`Once upon a time...`,`A blank page. Exciting, isn't it?`,`The first word is always the hardest...`,`Plot twist: this is where it all starts...`],UF={none:`hidden`,active:`active`,always:`visible`};function WF(){return HF[Math.floor(Math.random()*HF.length)]}function GF({placeholder:e,className:t,submitOnEnter:n,readOnly:r=!1,writeCanvasSettings:i,onOpenFilesPanel:a,calcEngineFactory:o}){let{editorSource:s,setEditorSource:c,setTiptapEditor:l,mediaProvider:u,mentionProvider:d,fenceRenderers:f,blockTagVisibility:p,themeInheritance:m,colorScheme:g,bumpMediaRevision:_,mediaRevision:v,workspaceContainer:y,sceneTextChannel:b,preserveSourceWrapping:x,layoutMode:S}=Lp(),C=x&&S===`document`,w=Ng(),T=(0,G.useRef)(c);T.current=c;let E=w?.activeTheme,D=(0,G.useRef)(null);D.current===null&&(D.current=lF(E??at));let O=D.current;(0,G.useEffect)(()=>{O.setTheme(E??at)},[E,O]);let{docTemplates:A,onDocTemplatesChange:j}=_b(),[M,N]=(0,G.useState)(null),P=(0,G.useCallback)((e,t)=>{if(t===`doc`){let t=A.findIndex(t=>t.name===e.name),n=t>=0?A.map((n,r)=>r===t?e:n):[...A,e];j(n)}else vv(e)},[A,j]),F=(0,G.useRef)(d);(0,G.useEffect)(()=>{F.current=d},[d]);let I=(0,G.useRef)(f);(0,G.useEffect)(()=>{I.current=f},[f]);let L=(0,G.useRef)(E);(0,G.useEffect)(()=>{L.current=E},[E]);let ee=(0,G.useMemo)(()=>e??WF(),[e]),te=(0,G.useRef)(!1),R=(0,G.useRef)(s),ne=(0,G.useRef)([]),re=(0,G.useRef)(u),z=(0,G.useRef)(v);(0,G.useEffect)(()=>{z.current=v},[v]);let ie=(0,G.useRef)(a);(0,G.useEffect)(()=>{ie.current=a},[a]);let ae=(0,G.useRef)(o);(0,G.useEffect)(()=>{ae.current=o},[o]);let oe=(0,G.useRef)(y);(0,G.useEffect)(()=>{oe.current=y},[y]);let se=(0,G.useRef)(_);(0,G.useEffect)(()=>{se.current=_},[_]),(0,G.useEffect)(()=>{re.current=u},[u]);let[ce,le]=(0,G.useState)(()=>new Set);(0,G.useEffect)(()=>{if(!u){le(new Set);return}let e=!1;return u.listMedia().then(t=>{e||le(new Set(t.map(e=>e.name)))},()=>{e||le(new Set)}),()=>{e=!0}},[u,v]);let ue=(0,G.useRef)(gp(s).frontmatter),V=(0,G.useRef)(null),de=(0,G.useRef)(void 0);if(de.current===void 0){let e=gp(s).body;if(C){let t=sF(e);V.current=t.state,de.current=t.displayBody}else de.current=e}let fe=(0,G.useRef)(n);(0,G.useEffect)(()=>{fe.current=n},[n]);let H=Mr({editable:!r,extensions:[br.configure({heading:!1,codeBlock:{HTMLAttributes:{class:`squisq-code-block`}}}),PD.configure({levels:[1,2,3,4,5,6]}),ID,LD,jM,AO.configure({textChannel:b}),Aj.configure({themeStore:O}),Zj.configure({reservedLanguages:Gt(f??void 0)}),cM.configure({renderers:()=>I.current??void 0,theme:()=>L.current??void 0}),eN.configure({mediaProvider:()=>re.current,mediaRevision:()=>z.current??0,container:()=>oe.current,onOpenFiles:e=>ie.current?.(e),onMediaSaved:()=>se.current?.(),calcEngineFactory:()=>ae.current}),cO.configure({onRepair:uO}),$P,WN,lw.configure({textChannel:b}),Pr.configure({resizable:!0}),jr,vr,Tr,Nr,Ar.configure({nested:!0}),VF.configure({openOnClick:!1,autolink:!0,HTMLAttributes:{rel:`noopener noreferrer`,target:`_blank`}}),pF.configure({inline:!1}),yF,xF,Fr.configure({placeholder:ee}),CF(()=>F.current),uF,LT,A_],content:lr(de.current),onUpdate:({editor:e})=>{if(te.current)return;let t=cF(ur(e.getHTML()),V.current),n=ue.current+t;ne.current.push(n),R.current=n,T.current(n)},editorProps:{attributes:{class:`squisq-wysiwyg-editor`,"data-testid":`wysiwyg-editor`},handleKeyDown:(e,t)=>{if(t.key!==`Enter`||!fe.current)return!1;let n=e.dom.closest(`.squisq-editor-shell`)?.querySelector(`.squisq-mention-popover`);return n&&n.style.display!==`none`?!1:t.metaKey||t.ctrlKey?(t.preventDefault(),e.dispatch(e.state.tr.replaceSelectionWith(e.state.schema.nodes.hardBreak.create())),!0):t.shiftKey?!1:(t.preventDefault(),fe.current(),!0)},handlePaste:(e,t)=>{let n=t.clipboardData;if(!n)return!1;let r=YF(n);if(r.length>0&&re.current)return t.preventDefault(),kF(e,r,re.current,_),!0;let i=n.getData(`text/plain`);if(!i)return!1;if(LO(i)){let n=e.state.schema.nodes.codeBlock;if(n)return t.preventDefault(),e.dispatch(e.state.tr.replaceSelectionWith(n.create({language:`diagram`},e.state.schema.text(i)))),!0}if(tF(i)){let n=e.state.schema.nodes.codeBlock;if(n)return t.preventDefault(),e.dispatch(e.state.tr.replaceSelectionWith(n.create({language:`timeline`},e.state.schema.text(i)))),!0}if(KN(i)){let n=e.state.schema.nodes.codeBlock;if(n)return t.preventDefault(),e.dispatch(e.state.tr.replaceSelectionWith(n.create({language:`tree`},e.state.schema.text(i)))),!0}if(!OF(i))return!1;let a=lr(i);return a?(t.preventDefault(),e.pasteHTML(a),!0):!1},handleDrop:(e,t,n,r)=>{let i=t.dataTransfer;if(!i||r)return!1;let a=i.getData(fD);if(a){let n=pD(a);if(n)return t.preventDefault(),QF(e,t),ZF(e,n)}let o=JF(i);return o.length===0?((i.files.length>0||i.items.length>0)&&console.warn(`[squisq-editor] Drop received with no recognizable image File. Types:`,Array.from(i.types??[]),`files:`,Array.from(i.files).map(e=>`${e.name} (${e.type||`no-type`})`)),!1):re.current?(t.preventDefault(),QF(e,t),kF(e,o,re.current,_),!0):(console.warn("[squisq-editor] Image drop received but no MediaProvider is wired up; cannot persist the image. Pass `mediaProvider` to EditorShell / EditorProvider."),!1)}}});(0,G.useEffect)(()=>(H&&l(H),()=>l(null)),[H,l]),(0,G.useEffect)(()=>{if(!H)return;let e=()=>{BF(H.view.dom,ce)};return e(),H.on(`update`,e),()=>{H.off(`update`,e)}},[ce,H]),(0,G.useEffect)(()=>{H&&H.setEditable(!r)},[H,r]);let pe=(0,G.useRef)(null),[me,U]=(0,G.useState)(null),[he,ge]=(0,G.useState)(null),_e=(0,G.useCallback)(()=>{U(null),requestAnimationFrame(()=>{H&&!H.isDestroyed&&H.commands.focus()})},[H]);(0,G.useEffect)(()=>{if(!H)return;let e=pe.current;if(!e)return;let t=t=>{let n=t.target;if(!n)return;let r=n.closest(`.squisq-props-badge`),i=n.closest(`.squisq-template-badge`),a=r??i;if(!a||!e.contains(a))return;t.preventDefault(),t.stopPropagation();let o=a.closest(`h1,h2,h3,h4,h5,h6`);if(!o)return;let s=null;try{s=H.view.posAtDOM(o,0)}catch{s=null}if(s==null)return;let c=Math.max(0,s-1),l=H.state.doc.nodeAt(c);if(!l||l.type.name!==`heading`)return;if(r){U(null),ge({rect:a.getBoundingClientRect(),headingPos:c,blockAttrs:l.attrs.dataBlockAttrs??null,templateParams:l.attrs.dataTemplateParams??null});return}let u=0,d=0;H.state.doc.descendants((e,t)=>{if(e.type.name===`heading`){if(t===c)return u=d,!1;d++}}),ge(null),U({rect:a.getBoundingClientRect(),template:l.attrs.dataTemplate??``,headingPos:c,headingIndex:u})};return e.addEventListener(`mousedown`,t),()=>e.removeEventListener(`mousedown`,t)},[H]),(0,G.useEffect)(()=>{if(!H)return;let e=ne.current.lastIndexOf(s);if(e>=0){ne.current.splice(0,e+1),ne.current.length===0&&(R.current=s);return}if(s===R.current)return;if(s.replace(/\s+$/,``)===R.current.replace(/\s+$/,``)){R.current=s;return}te.current=!0;let{body:t,frontmatter:n}=gp(s);ne.current=[],ue.current=n;let r=t;if(C){let e=sF(t);V.current=e.state,r=e.displayBody}else V.current=null;let i=lr(r);H.commands.setContent(i),R.current=s,te.current=!1},[s,H,C]);let W=(0,G.useMemo)(()=>{if(me)try{let e=Se(B(Tt(s),{autoTemplates:!1}).blocks)[me.headingIndex];return e?{block:e,theme:w?.activeTheme??at,viewport:w?.activeViewport??Ge.landscape,basePath:`/`,mediaProvider:u,customTemplates:A}:void 0}catch{return}},[me,A,s,u,w?.activeTheme,w?.activeViewport]),ve=(0,G.useMemo)(()=>{if(!E)return{};let e={"--squisq-block-props-accent":E.colors.primary};if(m===`none`)return e;if(Object.assign(e,{"--squisq-theme-body-font":Ye(E.typography.bodyFont,st.sans),"--squisq-theme-title-font":Ye(E.typography.titleFont,st.sans)}),m===`fonts-colors`){let t=E.colors;e[`--squisq-theme-bg`]=t.background,e[`--squisq-theme-bg-muted`]=t.backgroundLight,e[`--squisq-theme-text`]=t.text,e[`--squisq-theme-text-muted`]=t.textMuted,e[`--squisq-theme-primary`]=t.primary}return e},[E,m]);return(0,K.jsx)(xv,{docTemplates:A,onDocTemplatesChange:j,children:(0,K.jsxs)(`div`,{className:`squisq-wysiwyg-container${t?` ${t}`:``}`,style:{width:`100%`,height:`100%`,overflow:`auto`,...ve,...IF(i)},"data-testid":`wysiwyg-container`,"data-block-tags":UF[p],"data-theme-inheritance":m,ref:pe,children:[(0,K.jsx)(Ir,{editor:H,style:{height:`100%`}}),me&&(0,K.jsx)(cy,{anchorRect:me.rect,value:me.template,colorScheme:g,recommended:(()=>{let e=sx(s,me.headingIndex);if(e)return h(k(e),ey).recommended})(),previewSource:W,onOpenDesigner:()=>{U(null),N({})},onChange:e=>{if(!H)return;let t=H.state.tr.setNodeMarkup(me.headingPos,void 0,{...H.state.doc.nodeAt(me.headingPos)?.attrs,dataTemplate:e===``?null:e});H.view.dispatch(t)},onClose:_e}),he&&(0,K.jsx)(rF,{anchorRect:he.rect,blockAttrs:he.blockAttrs,templateParams:he.templateParams,colorScheme:g,accentColor:E?.colors.primary,onChange:e=>{if(!H)return;let t=H.state.doc.nodeAt(he.headingPos);if(!t||t.type.name!==`heading`)return;let n=H.state.tr.setNodeMarkup(he.headingPos,void 0,{...t.attrs,dataBlockAttrs:e});H.view.dispatch(n)},onAnnotationChange:e=>{if(!H)return;let t=H.state.doc.nodeAt(he.headingPos);if(!t||t.type.name!==`heading`)return;let n=H.state.tr.setNodeMarkup(he.headingPos,void 0,{...t.attrs,dataBlockAttrs:e.blockAttrsInner,dataTemplateParams:e.templateParams});H.view.dispatch(n)},onClose:()=>ge(null)}),M&&(0,K.jsx)(mT,{initial:M.initial,onSave:P,onClose:()=>N(null),mediaProvider:u,colorScheme:g})]})})}var KF=/\.(png|jpe?g|gif|webp|bmp|svg|avif|ico)$/i;function qF(e){return e.type.startsWith(`image/`)?!0:KF.test(e.name)}function JF(e){let t=[],n=new Set;for(let r=0;r<e.files.length;r++){let i=e.files[r];qF(i)&&(t.push(i),n.add(`${i.name}|${i.size}`))}if(e.items)for(let r=0;r<e.items.length;r++){let i=e.items[r];if(i.kind!==`file`)continue;let a=i.getAsFile();if(!a||!qF(a))continue;let o=`${a.name}|${a.size}`;n.has(o)||(t.push(a),n.add(o))}return t}function YF(e){let t=[];if(e.items)for(let n=0;n<e.items.length;n++){let r=e.items[n];if(r.kind===`file`&&r.type.startsWith(`image/`)){let e=r.getAsFile();e&&t.push(e)}}return t}function XF(e,t,n){let{schema:r}=e.state,i=r.nodes.image;if(!i)return;let a=i.create({src:t,alt:n}),o=e.state.tr.replaceSelectionWith(a);e.dispatch(o)}function ZF(e,t){let n=mD(t.mimeType);if(n===`image`)return XF(e,t.name,t.alt),!0;let{state:r}=e;if(n===`video`||n===`audio`){let i=r.schema.nodes[n];if(!i)return!1;let a=n===`video`?{src:t.name,controls:!0,width:480}:{src:t.name,controls:!0},o=i.create(a),{$from:s}=r.selection,c=s.depth>=1?s.after(1):r.doc.content.size;return e.dispatch(r.tr.insert(c,o).scrollIntoView()),!0}let i=r.schema.marks.link;if(!i)return!1;let a=t.alt||t.name,o=r.schema.text(a,[i.create({href:t.name})]);return e.dispatch(r.tr.replaceSelectionWith(o).scrollIntoView()),!0}function QF(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return;let r=e.state.tr.setSelection(ir.near(e.state.doc.resolve(n.pos)));e.dispatch(r)}function $F(e){let{doc:t,activeView:n,monacoEditor:r,tiptapEditor:i}=Lp(),a=(0,G.useMemo)(()=>t?Se(t.blocks):[],[t]),[o,s]=(0,G.useState)([]),[c,l]=(0,G.useState)(null);return(0,G.useEffect)(()=>{if(n!==`wysiwyg`)return;let t=e.current;if(!t)return;let r=eI(t);if(!r)return;let i=r.querySelector(`.squisq-wysiwyg-container`);if(!i)return;let o=0,c=()=>{cancelAnimationFrame(o),o=requestAnimationFrame(()=>{let e=Array.from(i.querySelectorAll(`h1, h2, h3, h4, h5, h6`)),t=r.getBoundingClientRect(),n=i.getBoundingClientRect(),o=[];a.forEach((r,i)=>{let a=e[i];if(!a)return;let s=a.getBoundingClientRect().top-t.top,c=e[i+1],l=c?c.getBoundingClientRect().top-t.top:n.bottom-t.top;o.push({block:r,top:s,bottom:l,annotated:!!a.getAttribute(`data-template`)})}),s(e=>tI(e,o)?e:o);let c=i.querySelector(`.squisq-wysiwyg-editor`);if(c){let e=c.getBoundingClientRect(),n=e.left-t.left,r=e.right-t.left;l(e=>e!=null&&Math.abs(e.left-n)<.5&&Math.abs(e.right-r)<.5?e:{left:n,right:r})}})};c();let u=new ResizeObserver(c);u.observe(i);let d=i.querySelector(`.squisq-wysiwyg-editor`);d&&u.observe(d);let f=new MutationObserver(c);f.observe(i,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:[`data-template`,`data-template-params`]}),i.addEventListener(`scroll`,c,{passive:!0}),window.addEventListener(`resize`,c);let p=window.setTimeout(c,250);return()=>{cancelAnimationFrame(o),window.clearTimeout(p),u.disconnect(),f.disconnect(),i.removeEventListener(`scroll`,c),window.removeEventListener(`resize`,c)}},[n,a,e]),(0,G.useEffect)(()=>{if(n!==`raw`||!r)return;let t=e.current;if(!t)return;let i=eI(t);if(!i)return;let o=0,c=()=>{cancelAnimationFrame(o),o=requestAnimationFrame(()=>{let e=i.getBoundingClientRect(),t=r.getDomNode();if(!t)return;let n=t.getBoundingClientRect(),o=n.top-e.top,c=r.getScrollTop(),u=r.getLayoutInfo(),d=[];a.forEach((e,t)=>{let n=e.sourceHeading?.position?.start.line;if(typeof n!=`number`)return;let i=r.getTopForLineNumber(n)-c+o,s=a[t+1]?.sourceHeading?.position?.start.line,l=typeof s==`number`?r.getTopForLineNumber(s)-c+o:o+u.height,f=e.sourceHeading?.templateAnnotation?.template;d.push({block:e,top:i,bottom:l,annotated:!!f&&se(f)})}),s(e=>tI(e,d)?e:d);let f=n.left-e.left,p=n.right-e.left;l(e=>e!=null&&Math.abs(e.left-f)<.5&&Math.abs(e.right-p)<.5?e:{left:f,right:p})})};c();let u=r.onDidScrollChange(c),d=r.onDidChangeModelContent(c),f=r.onDidLayoutChange(c),p=new ResizeObserver(c),m=r.getDomNode();m&&p.observe(m),window.addEventListener(`resize`,c);let h=window.setTimeout(c,250);return()=>{cancelAnimationFrame(o),window.clearTimeout(h),u.dispose(),d.dispose(),f.dispose(),p.disconnect(),window.removeEventListener(`resize`,c)}},[n,r,a,e]),(0,G.useEffect)(()=>{s([]),l(null)},[n]),{entries:o,pageEdges:c,scrollToBlock:(0,G.useCallback)(t=>{if(n===`wysiwyg`){let n=e.current,r=(n?eI(n):null)?.querySelector(`.squisq-wysiwyg-container`);if(!r)return;let o=r.querySelectorAll(`h1, h2, h3, h4, h5, h6`),s=a.findIndex(e=>e.id===t.id);if(s<0||s>=o.length)return;if(o[s].scrollIntoView({behavior:`smooth`,block:`start`}),i)try{i.chain().focus().run()}catch{}return}if(n===`raw`&&r){let e=t.sourceHeading?.position?.start.line;if(typeof e!=`number`)return;r.revealLineInCenter(e),r.setPosition({lineNumber:e,column:1}),r.focus()}},[n,a,r,e,i]),ready:o.length>0||c!=null}}function eI(e){let t=e.parentElement;for(;t;){if(t.classList.contains(`squisq-editor-with-gutter`))return t;t=t.parentElement}return e.parentElement}function tI(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.block.id!==i.block.id||r.annotated!==i.annotated||Math.abs(r.top-i.top)>.5||Math.abs(r.bottom-i.bottom)>.5)return!1}return!0}function nI(e){let t=e.sourceHeading?.templateAnnotation;return t?!!t.template:!1}function rI(e){return!e||e.length===0?``:e.map(e=>Ue(e)).join(`
|
|
504
|
+
`).trim()}function iI(e){if(!e)return[];let t=[];for(let n of e)if(n.type===`list`)for(let e of n.children){let n=Ue(e).trim();n&&t.push(n)}return t}function aI(e){if(e===void 0)return;let t=parseFloat(e);return Number.isFinite(t)&&t>0?t:void 0}function oI(e){if(!e||e.length===0)return[];let t=[];function n(e){if(e.type===`htmlElement`&&e.tagName===`img`){let n=e.attributes?.src;n&&t.push({src:n,alt:e.attributes?.alt??``,width:aI(e.attributes?.width),height:aI(e.attributes?.height)})}if(Array.isArray(e.children))for(let t of e.children)n(t)}function r(e){if(`type`in e&&e.type===`image`&&`url`in e){let n=e;n.url&&t.push({src:n.url,alt:n.alt??``})}if(`type`in e&&e.type===`htmlBlock`){let t=e;for(let e of t.htmlChildren??[])n(e)}for(let t of Ve(e))r(t)}for(let t of e)r(t);return t}function sI(e){let t=[],n=new Set;function r(e){for(let r of oI(e.contents))n.has(r.src)||(n.add(r.src),t.push(r));for(let t of e.children??[])r(t)}return r(e),t}function cI(e){if(!e)return null;for(let t of e)if(t.type===`table`){let e=t,[n,...r]=e.children;return n?{headers:n.children.map(e=>Ue(e).trim()),rows:r.map(e=>e.children.map(e=>Ue(e).trim())),align:e.align}:null}return null}function lI(e,t,n,r,i=[]){switch(e){case`statHighlight`:return L(e,t,r,{placeholders:!0})??{stat:t,description:n||t};case`quote`:case`fullBleedQuote`:case`pullQuote`:return{quote:n||t};case`factCard`:return{fact:t,explanation:n||t};case`comparisonBar`:return{leftLabel:`A`,leftValue:60,rightLabel:`B`,rightValue:40};case`list`:{let e=iI(r);return{items:e.length>0?e:[`Item 1`,`Item 2`,`Item 3`]}}case`definitionCard`:return{term:t,definition:n||t};case`dateEvent`:return{date:t,description:n||t};case`dataTable`:return cI(r)??{headers:[`Column`],rows:[[`Data`]]};case`imageWithCaption`:{let e=i[0];return{imageSrc:e?.src??``,imageAlt:e?.alt??t,caption:n||t,captionPosition:`bottom`}}case`leftFeature`:case`rightFeature`:{let e=i[0];return{imageSrc:e?.src??``,imageAlt:e?.alt??t,imageWidth:e?.width,imageHeight:e?.height,title:t,body:n}}case`videoWithCaption`:return{videoSrc:i[0]?.src??``,caption:n||t,captionPosition:`bottom`};default:return{}}}var uI=14,dI=16,fI=dI,pI=12;function mI({width:e=320,basePath:t=`/`,viewport:n=Ge.landscape,className:r,connectorWidth:i=24,mediaProvider:a=null}){let{doc:o}=Lp(),s=(0,G.useRef)(null),{entries:c,scrollToBlock:l}=$F(s),u=Ng()?.activeTheme??at,d=(0,G.useMemo)(()=>{if(!o||!o.blocks.length)return[];let e=Se(o.blocks),t=e.length,r=[];return e.forEach((e,i)=>{if(!nI(e))return;let a=e.sourceHeading.templateAnnotation,s=a.template,c=e.sourceHeading?Ue(e.sourceHeading):``,l=rI(e.contents),d={id:e.id,template:s,startTime:0,duration:1,audioSegment:0,title:c,contents:e.contents,children:e.children,...lI(s,c,l,e.contents,sI(e)),...a.params,...e.templateOverrides},f={blockIndex:i,totalBlocks:t,theme:u,viewport:n,customTemplates:o.customTemplates};try{let{layers:t}=Ce(d,f),n={...e,layers:t,template:s};r.push({id:e.id,template:s,headingText:c,block:n})}catch(t){let n=t instanceof Error?t.message:String(t);console.warn(`[InlinePreviewGutter] Skipped block "${e.id}" (${s}): ${n}`)}}),r},[o,n,u]),f=(0,G.useMemo)(()=>{let e=new Map;return c.forEach(t=>e.set(t.block.id,t.top)),e},[c]),[p,m]=(0,G.useState)(new Map);if((0,G.useLayoutEffect)(()=>{if(d.length===0){m(e=>e.size===0?e:new Map);return}let e=s.current;if(!e)return;let t=e.querySelectorAll(`.squisq-inline-preview-card`),n=-1/0,r=new Map;d.forEach((e,i)=>{let a=f.get(e.id);if(a==null)return;let o=Math.max(a,n+12);r.set(e.id,o);let s=t[i];n=o+(s?s.getBoundingClientRect().height:220)}),m(e=>{if(e.size===r.size){let t=!0;for(let[n,i]of r){let r=e.get(n);if(r==null||Math.abs(r-i)>.5){t=!1;break}}if(t)return e}return r})},[d,f]),d.length===0)return null;let h=e+i,g={position:`relative`,width:`${h}px`,flex:`0 0 ${h}px`,overflow:`hidden`};return(0,K.jsxs)(`aside`,{ref:s,className:`squisq-inline-preview-gutter ${r??``}`,style:g,"data-testid":`inline-preview-gutter`,"aria-label":`Block previews`,children:[c.length>0&&(0,K.jsx)(`div`,{className:`squisq-inline-preview-connectors`,"aria-hidden":`true`,style:{position:`absolute`,top:0,left:0,width:i,height:`100%`,overflow:`hidden`,pointerEvents:`none`},children:c.map((e,t)=>{let n=Math.max(2,e.bottom-e.top-6);return(0,K.jsx)(`div`,{className:`squisq-inline-preview-extent${e.annotated?``:` squisq-inline-preview-extent--untagged`}`,style:{position:`absolute`,top:`${e.top}px`,height:`${n}px`,right:`${uI}px`}},`h-${t}-${e.block.id}`)})}),d.length>0&&(0,K.jsx)(`svg`,{className:`squisq-inline-preview-connector-svg`,"aria-hidden":`true`,style:{position:`absolute`,top:0,left:0,width:i+pI,height:`100%`,pointerEvents:`none`,overflow:`visible`},children:d.map(e=>{let t=f.get(e.id),n=p.get(e.id);if(t==null||n==null)return null;let r=i-uI-2,a=t+fI,o=i+pI,s=n+dI;return(0,K.jsxs)(`g`,{children:[(0,K.jsx)(`line`,{x1:r,y1:a,x2:o,y2:s,stroke:`#6366f1`,strokeWidth:`2`,strokeLinecap:`round`}),(0,K.jsx)(`circle`,{cx:r,cy:a,r:`4`,fill:`#6366f1`,stroke:`#ffffff`,strokeWidth:`2`}),(0,K.jsx)(`circle`,{cx:o,cy:s,r:`4`,fill:`#6366f1`,stroke:`#ffffff`,strokeWidth:`2`})]},e.id)})}),(0,K.jsx)(pn.Provider,{value:a??null,children:d.map(e=>{let r=p.get(e.id),a=r==null;return(0,K.jsxs)(`div`,{className:`squisq-inline-preview-card`,"data-template":e.template,style:{position:`absolute`,top:`${r??0}px`,left:i+pI,right:12,visibility:a?`hidden`:`visible`},onClick:()=>l(e.block),children:[(0,K.jsxs)(`div`,{className:`squisq-inline-preview-card-label`,children:[(0,K.jsx)(`span`,{className:`squisq-inline-preview-card-template`,children:ty(e.template)}),e.headingText&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`squisq-inline-preview-card-sep`,children:`—`}),(0,K.jsx)(`span`,{className:`squisq-inline-preview-card-title`,children:e.headingText})]})]}),(0,K.jsx)(`div`,{className:`squisq-inline-preview-card-svg`,style:{aspectRatio:`${n.width} / ${n.height}`},children:(0,K.jsx)(sn,{block:e.block,blockTime:0,basePath:t,viewport:n})})]},e.id)})})]})}function hI(e,t,n,r){if(t===n||r!==`before`&&r!==`after`)return null;let i=gI(e);if(!i)return null;let a=i.find(e=>e.line===t),o=i.find(e=>e.line===n);if(!a||!o||a.depth!==o.depth||a.parentLine!==o.parentLine)return null;let s=i.filter(e=>e.parentLine===a.parentLine),c=s.findIndex(e=>e.line===t),l=s.findIndex(e=>e.line===n);if(c<0||l<0)return null;for(let e=0;e<s.length-1;e++)if(s[e].end!==s[e+1].start)return null;let u=s.map(t=>{let{content:n,gap:r}=vI(e.slice(t.start,t.end));return{...t,content:n,gap:r}}),d=[...u],[f]=d.splice(c,1),p=d.findIndex(e=>e.line===n);if(!f||p<0)return null;let m=p+ +(r===`after`);if(d.splice(m,0,f),d.every((e,t)=>e.line===u[t].line))return null;let h=d.map((e,t)=>e.content+u[t].gap).join(``),g=u[0].start,_=u[u.length-1].end,v=e.slice(0,g)+h+e.slice(_),y=gI(v);return!y||y.length!==i.length?null:v}function gI(e){try{let t=Tt(e),n=_I(e),r=[],i=[];for(let a of t.children){if(a.type!==`heading`||!a.position)continue;let t=a.position.start.line,o=n[t-1];if(o==null)return null;for(;i.length>0&&i[i.length-1].depth>=a.depth;)i.pop();let s={line:t,depth:a.depth,parentLine:i[i.length-1]?.line??null,start:o,end:e.length};r.push(s),i.push(s)}for(let e=0;e<r.length;e++){let t=r[e];for(let n=e+1;n<r.length;n++)if(r[n].depth<=t.depth){t.end=r[n].start;break}}return r}catch{return null}}function _I(e){let t=[0],n=/\r\n|\r|\n/g,r;for(;(r=n.exec(e))!=null;)t.push(r.index+r[0].length);return t}function vI(e){let t=e.match(/(?:\r\n|\r|\n)(?:[ \t]*(?:\r\n|\r|\n))*[ \t]*$/);return!t||t.index==null?{content:e,gap:``}:{content:e.slice(0,t.index),gap:e.slice(t.index)}}var yI=`clamp(260px, 30vw, 460px)`,bI=`application/x-squisq-outline-section`,xI=[];function SI({width:e,className:t,readOnly:n=!1}){let{doc:r,markdownSource:i,setMarkdownSource:a,isParsing:o,layoutMode:s,goToBlockByLine:c,activeBlockStartLine:l,activeView:u,monacoEditor:d,tiptapEditor:f}=Lp(),p=(0,G.useRef)(null),m=TI(),h=(0,G.useRef)(null),[g,_]=(0,G.useState)(null),[v,y]=(0,G.useState)(null),b=r?.blocks??xI,x=(0,G.useRef)(b);EI(x.current,b)||(x.current=b);let S=x.current,C=(0,G.useRef)({doc:r,markdownSource:i,setMarkdownSource:a,isParsing:o,layoutMode:s,goToBlockByLine:c,activeView:u,monacoEditor:d,tiptapEditor:f});C.current={doc:r,markdownSource:i,setMarkdownSource:a,isParsing:o,layoutMode:s,goToBlockByLine:c,activeView:u,monacoEditor:d,tiptapEditor:f};let w=(0,G.useMemo)(()=>s!==`block`||l==null||!r?null:Se(r.blocks).find(e=>e.sourceHeading?.position?.start.line===l)?.id??null,[s,l,r]),T=s===`block`?w:m,E=(0,G.useCallback)(e=>{let t=C.current,n=DI(t.doc,e.id)??e;if(t.layoutMode===`block`){let e=n.sourceHeading?.position?.start.line;if(typeof e==`number`){t.goToBlockByLine(e);return}}if(t.activeView===`wysiwyg`){let e=(p.current?OI(p.current):null)?.querySelector(`.squisq-wysiwyg-container`);if(!e)return;let r=e.querySelectorAll(`h1, h2, h3, h4, h5, h6`),i=(t.doc?Se(t.doc.blocks):[]).findIndex(e=>e.id===n.id);if(i<0||i>=r.length)return;if(r[i].scrollIntoView({behavior:`smooth`,block:`start`}),t.tiptapEditor)try{t.tiptapEditor.chain().focus().run()}catch{}return}if(t.activeView===`raw`&&t.monacoEditor){let e=n.sourceHeading?.position?.start.line;typeof e==`number`&&(t.monacoEditor.revealLineInCenter(e),t.monacoEditor.setPosition({lineNumber:e,column:1}),t.monacoEditor.focus())}},[]),D=(0,G.useCallback)((e,t)=>{let r=C.current;if(n||r.isParsing)return;let i=(DI(r.doc,e.id)??e).sourceHeading?.position?.start.line;if(typeof i!=`number`)return;let a=MI(r.markdownSource,i,t);a!=null&&r.setMarkdownSource(a)},[n]),O=(0,G.useCallback)(()=>{h.current=null,_(null),y(null)},[]),k=(0,G.useCallback)((e,t)=>{let r=C.current;if(n||r.isParsing){e.preventDefault();return}let i=DI(r.doc,t.blockId)?.sourceHeading?.position?.start.line,a=typeof i==`number`?{...t,headingLine:i}:t;h.current={...a,sourceAtStart:r.markdownSource},_(t.blockId),y(null),e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(bI,String(a.headingLine)),e.dataTransfer.setData(`text/plain`,String(a.headingLine))},[n]),A=(0,G.useCallback)((e,t)=>{let r=h.current;if(!r)return;let i=C.current;if(e.preventDefault(),e.stopPropagation(),!kI(r,t)||n||i.isParsing){e.dataTransfer.dropEffect=`none`,y(null);return}let a=AI(e);e.dataTransfer.dropEffect=`move`,y(e=>e?.blockId===t.blockId&&e.placement===a?e:{blockId:t.blockId,placement:a})},[n]),j=(0,G.useCallback)((e,t)=>{let r=h.current;if(!r)return;let i=C.current;e.preventDefault(),e.stopPropagation();let a=AI(e),o=DI(i.doc,t.blockId)?.sourceHeading?.position?.start.line,s=typeof o==`number`?{...t,headingLine:o}:t,c=!n&&!i.isParsing&&r.sourceAtStart===i.markdownSource&&kI(r,s)?hI(i.markdownSource,r.headingLine,s.headingLine,a):null;O(),c!=null&&i.setMarkdownSource(c)},[O,n]),M=Ng()?.activeTheme?.colors?.primary,N=S.length===0||!jI(S),P=e==null?`var(--squisq-outline-width, ${yI})`:`${e}px`,F={width:P,flex:`0 0 ${P}`,overflow:`auto`,...M?{"--squisq-outline-accent":M}:{}};return(0,K.jsx)(`aside`,{ref:p,className:`squisq-outline${t?` ${t}`:``}`,style:F,"data-testid":`outline-panel`,"aria-label":`Document outline`,children:N?(0,K.jsx)(`div`,{className:`squisq-outline-empty`,children:(0,K.jsx)(`p`,{children:`Add a heading to populate the outline.`})}):(0,K.jsx)(CI,{blocks:S,activeBlockId:T,draggedBlockId:g,dropTarget:v,mutationsDisabled:n,onSelect:E,onChangeLevel:D,onDragStart:k,onDragOver:A,onDrop:j,onDragEnd:O})})}var CI=(0,G.memo)(function({blocks:e,...t}){return(0,K.jsx)(`ul`,{className:`squisq-outline-tree`,role:`tree`,children:e.map(e=>(0,K.jsx)(wI,{block:e,parentId:null,...t},e.id))})});function wI({block:e,parentId:t,activeBlockId:n,draggedBlockId:r,dropTarget:i,mutationsDisabled:a,onSelect:o,onChangeLevel:s,onDragStart:c,onDragOver:l,onDrop:u,onDragEnd:d}){let f=e.sourceHeading,p=f?.depth??1,m=f?.position?.start.line,h=f?Ue(f).trim():``,g=f?.templateAnnotation?.template,_=g&&se(g),v=e.id===n,y=!!f&&p>1,b=!!f&&p<6,x=f&&typeof m==`number`?{blockId:e.id,headingLine:m,depth:p,parentId:t}:null,S=x!=null&&!a,C=e.id===r,w=i?.blockId===e.id?i.placement:null;return(0,K.jsxs)(`li`,{className:[`squisq-outline-item`,C?`squisq-outline-item--dragging`:``,w?`squisq-outline-item--drop-${w}`:``].filter(Boolean).join(` `),role:`treeitem`,"aria-current":v||void 0,children:[(0,K.jsxs)(`div`,{className:`squisq-outline-row-wrap`,onDragOver:x?e=>l(e,x):void 0,onDrop:x?e=>u(e,x):void 0,children:[(0,K.jsxs)(`button`,{type:`button`,className:`squisq-outline-row squisq-outline-row--depth-${p}${v?` squisq-outline-row--current`:``}`,onClick:()=>o(e),draggable:S,"aria-grabbed":C||void 0,onDragStart:x?e=>c(e,x):void 0,onDragEnd:d,title:h||`(empty heading)`,children:[S&&(0,K.jsx)(`span`,{className:`squisq-outline-drag-handle`,"aria-hidden":`true`,children:(0,K.jsxs)(`svg`,{width:`8`,height:`12`,viewBox:`0 0 8 12`,children:[(0,K.jsx)(`circle`,{cx:`2`,cy:`2`,r:`1`,fill:`currentColor`}),(0,K.jsx)(`circle`,{cx:`6`,cy:`2`,r:`1`,fill:`currentColor`}),(0,K.jsx)(`circle`,{cx:`2`,cy:`6`,r:`1`,fill:`currentColor`}),(0,K.jsx)(`circle`,{cx:`6`,cy:`6`,r:`1`,fill:`currentColor`}),(0,K.jsx)(`circle`,{cx:`2`,cy:`10`,r:`1`,fill:`currentColor`}),(0,K.jsx)(`circle`,{cx:`6`,cy:`10`,r:`1`,fill:`currentColor`})]})}),(0,K.jsx)(`span`,{className:`squisq-outline-row-text`,children:h||`(untitled)`}),_&&(0,K.jsx)(`span`,{className:`squisq-outline-template-chip`,children:ty(g)})]}),f&&(0,K.jsxs)(`span`,{className:`squisq-outline-row-actions`,children:[(0,K.jsx)(`button`,{type:`button`,className:`squisq-outline-row-arrow`,"aria-label":`Promote heading (currently H${p})`,title:`Promote heading`,disabled:a||!y,onClick:()=>s(e,-1),children:(0,K.jsx)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 10 10`,"aria-hidden":`true`,children:(0,K.jsx)(`path`,{d:`M6.5 2.5 L3 5 L6.5 7.5`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,fill:`none`})})}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-outline-row-arrow`,"aria-label":`Demote heading (currently H${p})`,title:`Demote heading`,disabled:a||!b,onClick:()=>s(e,1),children:(0,K.jsx)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 10 10`,"aria-hidden":`true`,children:(0,K.jsx)(`path`,{d:`M3.5 2.5 L7 5 L3.5 7.5`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,fill:`none`})})})]})]}),e.children&&e.children.length>0&&(0,K.jsx)(`ul`,{className:`squisq-outline-tree`,children:e.children.map(t=>(0,K.jsx)(wI,{block:t,parentId:e.id,activeBlockId:n,draggedBlockId:r,dropTarget:i,mutationsDisabled:a,onSelect:o,onChangeLevel:s,onDragStart:c,onDragOver:l,onDrop:u,onDragEnd:d},t.id))})]})}function TI(){let{doc:e,activeView:t,tiptapEditor:n,monacoEditor:r}=Lp(),i=(0,G.useMemo)(()=>e?Se(e.blocks):[],[e]),a=(0,G.useRef)(i);a.current=i;let o=i.map(e=>`${e.id}:${e.sourceHeading?.position?.start.line??``}`).join(`\0`),[s,c]=(0,G.useState)(null);return(0,G.useEffect)(()=>{c(null)},[t]),(0,G.useEffect)(()=>{if(t!==`wysiwyg`||!n)return;let e=()=>{let{from:e}=n.state.selection,t=-1,r=-1;n.state.doc.forEach((n,i)=>{n.type.name===`heading`&&(r+=1,i<=e&&(t=r))});let i=t>=0?a.current[t]:null;c(i?.id??null)};return e(),n.on(`selectionUpdate`,e),n.on(`update`,e),()=>{n.off(`selectionUpdate`,e),n.off(`update`,e)}},[t,n,o]),(0,G.useEffect)(()=>{if(t!==`raw`||!r)return;let e=()=>{let e=r.getPosition()?.lineNumber;if(typeof e!=`number`){c(null);return}let t=-1;a.current.forEach((n,r)=>{let i=n.sourceHeading?.position?.start.line;typeof i==`number`&&i<=e&&(t=r)});let n=t>=0?a.current[t]:null;c(n?.id??null)};e();let n=r.onDidChangeCursorPosition(e);return()=>n.dispose()},[t,r,o]),s}function EI(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(r.id!==i.id)return!1;let a=r.sourceHeading,o=i.sourceHeading;if(!!a!=!!o||a&&o&&(a.depth!==o.depth||Ue(a).trim()!==Ue(o).trim()||a.templateAnnotation?.template!==o.templateAnnotation?.template)||!EI(r.children??xI,i.children??xI))return!1}return!0}function DI(e,t){return e?Se(e.blocks).find(e=>e.id===t)??null:null}function OI(e){let t=e.parentElement;for(;t;){if(t.classList.contains(`squisq-editor-with-gutter`))return t;t=t.parentElement}return e.parentElement}function kI(e,t){return e.blockId!==t.blockId&&e.depth===t.depth&&e.parentId===t.parentId}function AI(e){let t=e.currentTarget.getBoundingClientRect();return e.clientY<t.top+t.height/2?`before`:`after`}function jI(e){for(let t of e)if(t.sourceHeading||t.children&&jI(t.children))return!0;return!1}function MI(e,t,n){let r=e.split(`
|
|
505
|
+
`),i=t-1;if(i<0||i>=r.length)return null;let a=r[i],o=a.match(/^(#{1,6})(\s|$)/);if(!o)return null;let s=o[1].length,c=s+n;return c<1||c>6?null:(r[i]=`#`.repeat(c)+a.slice(s),r.join(`
|
|
506
|
+
`))}function NI(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Set,i=[],a=[];for(let e of t){if(r.has(e.id))continue;r.add(e.id);let t=n.get(e.id);t?(t.line!==e.line||t.ordinal!==e.ordinal)&&a.push(e):i.push(e)}return{add:i,remove:e.filter(e=>!r.has(e.id)).map(e=>e.id),move:a}}var PI=class e{constructor(e){this.entries=new Map,this.listeners=new Set,this.modelListener=null,this.disposed=!1,this.editor=e,this.modelListener=e.onDidChangeModel(()=>{this.entries.clear(),this.emit()})}sync(t){if(this.disposed)return;let{add:n,remove:r,move:i}=NI([...this.entries.values()].map(e=>e.spec),t);n.length===0&&r.length===0&&i.length===0||(this.editor.changeViewZones(t=>{for(let e of r){let n=this.entries.get(e);n&&(t.removeZone(n.zoneId),this.entries.delete(e))}for(let e of i){let n=this.entries.get(e.id);n&&(n.spec=e,n.delegate.afterLineNumber=Math.max(e.line-1,0),II(n.delegate,e.ordinal),t.layoutZone(n.zoneId))}for(let r of n){let n=document.createElement(`div`);n.className=`squisq-ccx-zone`,n.dataset.sectionId=r.id;let i={afterLineNumber:Math.max(r.line-1,0),heightInPx:e.INITIAL_HEIGHT_PX,domNode:n,suppressMouseDown:!0};II(i,r.ordinal);let a=t.addZone(i);this.entries.set(r.id,{zoneId:a,delegate:i,domNode:n,spec:r})}}),this.emit())}setHeight(e,t){if(this.disposed)return;let n=this.entries.get(e);if(!n)return;let r=Math.max(Math.ceil(t),1);Math.abs((n.delegate.heightInPx??0)-r)<1||(n.delegate.heightInPx=r,this.editor.changeViewZones(e=>{e.layoutZone(n.zoneId)}))}getDomNode(e){return this.entries.get(e)?.domNode}liveIds(){return[...this.entries.keys()]}onDidChangeZones(e){return this.listeners.add(e),()=>this.listeners.delete(e)}dispose(){if(!this.disposed){if(this.disposed=!0,this.modelListener?.dispose(),this.modelListener=null,this.entries.size>0)try{this.editor.changeViewZones(e=>{for(let t of this.entries.values())e.removeZone(t.zoneId)})}catch{}this.entries.clear(),this.listeners.clear()}}emit(){for(let e of[...this.listeners])e()}};PI.INITIAL_HEIGHT_PX=28;var FI=PI;function II(e,t){e.ordinal=t}function LI({section:e,expanded:t,onToggle:n,linkSchemes:r,onLinkClick:i,onRevealLine:a,onMeasure:o}){let s=(0,G.useRef)(null),c=(0,G.useMemo)(()=>Tt(e.summaryMarkdown).children,[e.summaryMarkdown]),l=(0,G.useMemo)(()=>t&&e.markdown?Tt(e.markdown).children:null,[t,e.markdown]);(0,G.useEffect)(()=>{let t=s.current;if(!t||typeof ResizeObserver>`u`)return;let n=()=>{let n=t.offsetHeight;n>0&&o(e.id,n)};n();let r=new ResizeObserver(n);return r.observe(t),()=>r.disconnect()},[e.id,o]);let u=(0,G.useCallback)(t=>{let n=t.target.closest?.(`a`);if(!n)return;let r=n.getAttribute(`href`)??``,o=/^#L(\d+)$/.exec(r);if(o){t.preventDefault(),t.stopPropagation(),a(Number(o[1]));return}i&&i(r,{sectionId:e.id})!==!1&&(t.preventDefault(),t.stopPropagation())},[i,a,e.id]),d=(0,G.useCallback)(e=>{e.stopPropagation()},[]);return(0,K.jsxs)(`div`,{ref:s,className:`squisq-ccx-section${t?` squisq-ccx-section--expanded`:``}`,onClick:u,onMouseDown:d,children:[(0,K.jsxs)(`button`,{type:`button`,className:`squisq-ccx-strip`,"aria-expanded":t,onClick:()=>n(e.id),children:[(0,K.jsx)(`span`,{className:`squisq-ccx-chevron`,"aria-hidden":`true`,children:t?`▾`:`▸`}),(0,K.jsx)(`span`,{className:`squisq-ccx-strip-text`,children:(0,K.jsx)(un,{nodes:c,...r?{linkSchemes:r}:{}})})]}),t&&(l?(0,K.jsx)(`div`,{className:`squisq-ccx-body`,children:(0,K.jsx)(un,{nodes:l,...r?{linkSchemes:r}:{}})}):(0,K.jsx)(`div`,{className:`squisq-ccx-body squisq-ccx-body--loading`,children:`Loading…`}))]})}function RI({options:e}){let{monacoEditor:t}=Lp(),[n,r]=(0,G.useState)(null),[,i]=(0,G.useState)(0),[a,o]=(0,G.useState)({}),s=(0,G.useRef)(new Set);(0,G.useEffect)(()=>{if(!t)return;let e=new FI(t),n=e.onDidChangeZones(()=>i(e=>e+1));return r(e),()=>{n(),e.dispose(),r(null)}},[t]);let c=e.fileTop,l=e.sections,u=(0,G.useMemo)(()=>{let e=[];return c&&e.push({spec:{id:c.id,line:0,ordinal:0},section:c}),l?.forEach((t,n)=>{e.push({spec:{id:t.id,line:t.line,ordinal:n+1},section:t})}),e},[c,l]);(0,G.useEffect)(()=>{n&&(n.sync(u.map(e=>e.spec)),o(e=>{let t=null;for(let{section:n}of u)s.current.has(n.id)||(s.current.add(n.id),n.defaultExpanded&&(t??={...e},t[n.id]=!0));return t??e}))},[n,u]);let d=e.onToggleSection,f=(0,G.useCallback)(e=>{o(t=>{let n=!t[e];return d?.(e,n),{...t,[e]:n}})},[d]),p=(0,G.useCallback)((e,t)=>n?.setHeight(e,t),[n]),m=(0,G.useCallback)(e=>{t?.revealLineInCenter(e),t?.setPosition({lineNumber:e,column:1})},[t]);return n?(0,K.jsx)(K.Fragment,{children:u.map(({section:t})=>{let r=n.getDomNode(t.id);return r?(0,Wr.createPortal)((0,K.jsx)(LI,{section:t,expanded:!!a[t.id],onToggle:f,linkSchemes:e.linkSchemes,onLinkClick:e.onLinkClick,onRevealLine:m,onMeasure:p},t.id),r,t.id):null})}):null}function zI({active:e=!0,blockCount:t,activeBlockKey:n,onPrev:r,onNext:i,onAdd:a,children:o,className:s}){let c=n<=0,l=n>=t-1,u=Math.min(n+1,Math.max(t,1)),d=Math.max(t,1);return(0,K.jsxs)(`div`,{className:`squisq-block-card-frame${e?` squisq-block-card`:``}${s?` ${s}`:``}`,"data-testid":e?`block-card-view`:void 0,children:[(0,K.jsx)(`div`,{className:`squisq-block-card-frame-body${e?` squisq-block-card-body`:``}`,children:o}),e&&(0,K.jsxs)(`div`,{className:`squisq-block-card-nav`,role:`toolbar`,"aria-label":`Block navigation`,children:[(0,K.jsxs)(`button`,{type:`button`,className:`squisq-block-card-button squisq-block-card-prev`,onClick:r,disabled:c,"aria-label":`Previous block`,"data-tooltip":`Previous block`,children:[(0,K.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 14 14`,"aria-hidden":`true`,children:(0,K.jsx)(`path`,{d:`M9 2.5 L4.5 7 L9 11.5`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,fill:`none`})}),(0,K.jsx)(`span`,{children:`Previous`})]}),(0,K.jsxs)(`span`,{className:`squisq-block-card-position`,"aria-live":`polite`,children:[`Block `,u,` of `,d]}),(0,K.jsxs)(`button`,{type:`button`,className:`squisq-block-card-button squisq-block-card-next`,onClick:i,disabled:l,"aria-label":`Next block`,"data-tooltip":`Next block`,children:[(0,K.jsx)(`span`,{children:`Next`}),(0,K.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 14 14`,"aria-hidden":`true`,children:(0,K.jsx)(`path`,{d:`M5 2.5 L9.5 7 L5 11.5`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,fill:`none`})})]}),a&&(0,K.jsxs)(`button`,{type:`button`,className:`squisq-block-card-button squisq-block-card-add`,onClick:a,"aria-label":`Add block`,"data-tooltip":`Add block after this one`,children:[(0,K.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 14 14`,"aria-hidden":`true`,children:(0,K.jsx)(`path`,{d:`M7 3 L7 11 M3 7 L11 7`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,fill:`none`})}),(0,K.jsx)(`span`,{children:`Add block`})]})]})]})}function BI(e){let t=Math.max(0,e);return String(Number.isInteger(t)?t:Math.round(t*100)/100)}function VI(e,t,n){return UI(e,t,`duration`,n)}function HI(e,t,n){return UI(e,t,`startTime`,n)}function UI(e,t,n,r){let i=e.split(`
|
|
507
|
+
`),a=t-1;if(a<0||a>=i.length)return null;let o=i[a];if(!/^#{1,6}\s/.test(o))return null;let s=r==null?null:BI(r),c=o,l=null,u=wt(c);u&&(l=u.inner.trim(),c=c.slice(0,u.index).replace(/\s+$/,``));let d=null,f=_t(c);if(f){let e=Et(f.inner.trim());e.params&&(delete e.params[n],Object.keys(e.params).length===0&&delete e.params);let t=Ct(e);d=t&&t!==`{}`?t:null,c=c.slice(0,f.index).replace(/\s+$/,``)}let p=GI(l,n,s),m=[c];return d&&m.push(d),p&&m.push(p),i[a]=m.join(` `),i.join(`
|
|
508
|
+
`)}function WI(e,t,n){let r=e.split(`
|
|
509
|
+
`),i=t-1;return i<0||i>=r.length||!/^#{1,6}\s/.test(r[i])?null:(r[i]=Ty(r[i],n),r.join(`
|
|
510
|
+
`))}function GI(e,t,n){let r=e?jt(e):[],i=r.length>0&&r[0].indexOf(`=`)>0||r.length===0?void 0:r[0],a={},o=[];for(let e=+!!i;e<r.length;e++){let t=yt(r[e]);t&&(t.key in a||o.push(t.key),a[t.key]=t.value)}if(n===null){delete a[t];let e=o.indexOf(t);e>=0&&o.splice(e,1)}else t in a||o.push(t),a[t]=n;let s=i?[i]:[];for(let e of o)s.push(`${e}=${gt(a[e])}`);return s.length>0?`{[${s.join(` `)}]}`:null}function KI(e,t,n){let r=RegExp(`\\s+${t}(?:\\s*=\\s*(?:"[^"]*"|'[^']*'|[^\\s>]+))?`,`i`);return n===null?e.replace(r,``):r.test(e)?e.replace(r,` ${t}="${n}"`):e.replace(/\s*\/?>(?=$)/,e=>` ${t}="${n}"${e.trimStart()}`)}function qI(e,t){let n=/^\s*<(video|audio)\b/i.exec(e);if(!n)return null;let r=n[1].toLowerCase(),i=RegExp(`<${r}\\b[^>]*>`,`i`).exec(e);if(!i)return null;let a=i[0],o=`data-squisq-${r}`;return t.startAt!==void 0&&(a=KI(a,`${o}-start-at`,t.startAt==null?null:BI(t.startAt))),t.clipStart!==void 0&&(a=KI(a,`${o}-clip-start`,t.clipStart==null?null:BI(t.clipStart))),t.clipEnd!==void 0&&(a=KI(a,`${o}-clip-end`,t.clipEnd==null?null:BI(t.clipEnd))),r===`video`&&t.placement!==void 0&&(a=KI(a,`data-squisq-video-placement`,t.placement==null||t.placement===`content`?null:t.placement)),r===`video`&&t.lockToBlock!==void 0&&(a=KI(a,`data-squisq-video-lock-to-block`,t.lockToBlock==null||t.lockToBlock?null:`false`)),r===`video`&&t.pipSize!==void 0&&(a=KI(a,`data-squisq-video-pip-size`,t.pipSize)),r===`video`&&t.pipShape!==void 0&&(a=KI(a,`data-squisq-video-pip-shape`,t.pipShape)),r===`video`&&t.pipPosition!==void 0&&(a=KI(a,`data-squisq-video-pip-position`,t.pipPosition)),`${e.slice(0,i.index)}${a}${e.slice(i.index+i[0].length)}`}function JI(e,t,n){let r=e.split(`
|
|
511
|
+
`),i=t-1;if(i<0||i>=r.length)return null;let a=r[i],o=qI(a,n);if(o!=null)return r[i]=o,r.join(`
|
|
512
|
+
`);let s=wt(a);if(!s)return null;let c=jt(s.inner.trim()),l=c.length>0&&c[0].indexOf(`=`)>0||c.length===0?void 0:c[0];if(!l||![`audio`,`video`,`media`].includes(l))return null;let u={},d=[];for(let e=1;e<c.length;e++){let t=yt(c[e]);t&&(t.key in u||d.push(t.key),u[t.key]=t.value)}let f=(e,t)=>{if(t===null){delete u[e];let t=d.indexOf(e);t>=0&&d.splice(t,1)}else e in u||d.push(e),u[e]=t};n.startAt!==void 0&&f(`startAt`,n.startAt==null?null:BI(n.startAt)),n.clipStart!==void 0&&f(`clipStart`,n.clipStart==null?null:BI(n.clipStart)),n.clipEnd!==void 0&&f(`clipEnd`,n.clipEnd==null?null:BI(n.clipEnd)),n.spillover!==void 0&&f(`spillover`,n.spillover?`true`:null),n.placement!==void 0&&(f(`presentation`,null),f(`pip`,null),f(`overlay`,null),f(`placement`,n.placement)),n.lockToBlock!==void 0&&f(`lockToBlock`,n.lockToBlock==null?null:n.lockToBlock?`true`:`false`),n.pipSize!==void 0&&f(`pipSize`,n.pipSize),n.pipShape!==void 0&&f(`pipShape`,n.pipShape),n.pipPosition!==void 0&&f(`pipPosition`,n.pipPosition);let p=`{[${[l,...d.map(e=>`${e}=${gt(u[e])}`)].join(` `)}]}`,m=a.slice(0,s.index).replace(/\s+$/,``);return r[i]=m?`${m} ${p}`:p,r.join(`
|
|
513
|
+
`)}function YI(e,t){let n=[e.kind,`src=${gt(e.src)}`];return e.placement&&n.push(`placement=${e.placement}`),e.lockToBlock!=null&&n.push(`lockToBlock=${e.lockToBlock}`),e.pipSize&&n.push(`pipSize=${e.pipSize}`),e.pipShape&&n.push(`pipShape=${e.pipShape}`),e.pipPosition&&n.push(`pipPosition=${e.pipPosition}`),t>0&&n.push(`startAt=${BI(t)}`),e.clipStart!=null&&e.clipStart>0&&n.push(`clipStart=${BI(e.clipStart)}`),e.clipEnd!=null&&n.push(`clipEnd=${BI(e.clipEnd)}`),e.spillover&&n.push(`spillover=true`),`{[${n.join(` `)}]}`}function XI(e,t){for(let n=Math.min(t,e.length-1);n>=0;n--)if(/^#{1,6}\s/.test(e[n]))return n;return-1}function ZI(e,t,n,r,i){let a=e.split(`
|
|
514
|
+
`),o=t-1;if(o<0||o>=a.length)return null;let s=n-1;if(s<0||s>=a.length)return null;let c=Math.max(0,i),l=XI(a,o)===s;if(/^\s*<(?:video|audio)\b/i.test(a[o])){let e=qI(a[o],{startAt:c>0?c:null,...r.clipStart===void 0?{}:{clipStart:r.clipStart},...r.clipEnd===void 0?{}:{clipEnd:r.clipEnd}});if(e==null)return null;if(l)return a[o]=e,a.join(`
|
|
515
|
+
`);a.splice(o,1);let t=s;return o<t&&--t,a.splice(t+1,0,``,e),a.join(`
|
|
516
|
+
`)}let u=YI(r,c);if(l)return a[o]=u,a.join(`
|
|
517
|
+
`);a.splice(o,1);let d=s;return o<d&&--d,a.splice(d+1,0,``,u),a.join(`
|
|
518
|
+
`)}var QI=new Set([`webm`,`mp4`,`mov`,`m4v`,`ogv`]),$I=new Set([`mp3`,`wav`,`ogg`,`oga`,`m4a`,`aac`,`flac`,`opus`]);function eL(e){let t=e.split(`?`)[0].split(`#`)[0].split(`.`).pop()?.toLowerCase();return t?QI.has(t)?`video`:$I.has(t)?`audio`:null:null}function tL(e,t,n){let r=e?.[`data-squisq-${t}-${n}`];if(r!=null)return ht(r)??void 0}function nL(e){let t=[],n=(e,r)=>{if(!e||typeof e!=`object`)return;let i=e,a=i.position?.start?.line??r;if((i.type===`image`||i.type===`link`)&&typeof i.url==`string`){let e=eL(i.url);e&&t.push({src:i.url,kind:e,sourceLine:a})}if(i.type===`htmlElement`&&(i.tagName===`video`||i.tagName===`audio`)){let e=i.tagName===`video`?`video`:`audio`,n=typeof i.attributes?.src==`string`?i.attributes.src:void 0;if(!n&&Array.isArray(i.children))for(let e of i.children){let t=e;if(t.tagName===`source`&&typeof t.attributes?.src==`string`){n=t.attributes.src;break}}if(n){let r=tL(i.attributes,e,`start-at`),o=tL(i.attributes,e,`clip-start`),s=tL(i.attributes,e,`clip-end`);t.push({src:n,kind:e,sourceLine:a,...r==null?{}:{startAt:r},...o==null?{}:{clipStart:o},...s==null?{}:{clipEnd:s}})}}Array.isArray(i.children)&&i.children.forEach(e=>n(e,a)),Array.isArray(i.htmlChildren)&&i.htmlChildren.forEach(e=>n(e,a))};return(e.contents??[]).forEach(e=>n(e,void 0)),t}function rL(e,t){let n=Math.max(0,t.startAt??0),r=Math.max(0,t.clipStart??0),i=e.startTime+n,a=e.startTime+e.duration,o=t.clipEnd==null?null:Math.max(0,t.clipEnd-r),s=o==null?a:Math.min(a,i+o);return{absoluteStart:i,absoluteEnd:Math.max(i,s),sourceIn:r}}function iL(e){let t=[],n=e=>{for(let r of e)nL(r).forEach((e,n)=>{let i=rL(r,e);t.push({id:`embedded:${r.id}:${n}`,kind:e.kind,src:e.src,...i,anchor:`block`,blockId:r.id,...e.sourceLine==null?{}:{sourceLine:e.sourceLine}})}),r.children?.length&&n(r.children)};return n(e.blocks),t}function aL(e){return iL(e).filter(e=>e.kind===`video`)}function oL(e,t){let n=new Set(t.map(e=>e.src)),r=e.audio.segments.map((e,t)=>n.has(e.src)?null:{id:`narration:${t}`,kind:`audio`,src:e.src,absoluteStart:Math.max(0,e.startTime),absoluteEnd:Math.max(0,e.startTime)+Math.max(0,e.duration),sourceIn:0,anchor:`document`}).filter(e=>e!==null&&e.absoluteEnd>e.absoluteStart);return[...t,...iL(e),...r]}function sL(e,t,n){return n<=0?0:Math.min(n,Math.max(0,e+t))}function cL(e,t){e&&e.querySelectorAll(`audio[data-clip-id], video[data-clip-id]`).forEach(e=>{let n=Number(e.dataset.absStart),r=Number(e.dataset.absEnd);if(!(!Number.isFinite(n)||!Number.isFinite(r)||t<n||t>=r))try{e.play()?.catch(()=>{})}catch{}})}function lL(e){let[t,n]=(0,G.useState)(0),[r,i]=(0,G.useState)(!1),a=(0,G.useRef)(null),o=(0,G.useRef)(0),s=(0,G.useRef)(0),c=(0,G.useRef)(!1),l=(0,G.useRef)(null);s.current=t,c.current=r,(0,G.useEffect)(()=>{n(t=>Math.min(t,Math.max(0,e)))},[e]),(0,G.useEffect)(()=>{if(!r)return;o.current=performance.now();let t=r=>{let l=(r-o.current)/1e3;o.current=r,n(t=>{let n=sL(t,l,e);return s.current=n,n>=e?(c.current=!1,i(!1),e):n}),a.current=requestAnimationFrame(t)};return a.current=requestAnimationFrame(t),()=>{a.current!=null&&cancelAnimationFrame(a.current)}},[r,e]);let u=(0,G.useCallback)(e=>{l.current=e},[]),d=(0,G.useCallback)(()=>{let t=e>0&&s.current>=e?0:s.current;s.current=t,cL(l.current,t),n(t),c.current=!0,i(!0)},[e]),f=(0,G.useCallback)(()=>{c.current=!1,i(!1)},[]);return{currentTime:t,isPlaying:r,play:d,pause:f,toggle:(0,G.useCallback)(()=>{c.current?f():d()},[f,d]),seek:(0,G.useCallback)(t=>{let r=Math.min(Math.max(0,t),Math.max(0,e));s.current=r,n(r)},[e]),registerMediaHost:u}}function uL(e,t){let n=e.split(/[?#]/,1)[0]??e,r=n.split(/[\\/]/).pop()||n||e;return t===`video`&&r.replace(/\.[^.]+$/,``)||r}function dL({anchor:e,target:t,colorScheme:n=`light`,accentColor:r,onBlockDuration:i,onBlockStartTime:a,onBlockTransition:o,onVideoPatch:s,onClose:c}){let l=(0,G.useRef)(null),[u,d]=(0,G.useState)(()=>bL(e));return(0,G.useLayoutEffect)(()=>{let t=l.current;if(!t)return;let n=()=>d(bL(e,t));n(),window.addEventListener(`resize`,n);let r=typeof ResizeObserver>`u`?null:new ResizeObserver(n);return r?.observe(t),()=>{window.removeEventListener(`resize`,n),r?.disconnect()}},[e]),(0,G.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),c())},t=e=>{let t=e.target;l.current?.contains(t)||t.closest?.(`.squisq-transition-flyout`)||c()};return document.addEventListener(`keydown`,e),document.addEventListener(`mousedown`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`mousedown`,t)}},[c]),(0,Wr.createPortal)((0,K.jsxs)(`div`,{ref:l,className:`squisq-timeline-item-menu`,"data-theme":n,role:`dialog`,"aria-label":t.kind===`block`?`Timeline block options`:`Timeline video options`,style:{...u,...yL(r)},children:[(0,K.jsxs)(`div`,{className:`squisq-timeline-item-menu-header`,children:[(0,K.jsx)(`span`,{className:`squisq-timeline-item-menu-kind`,children:t.kind===`block`?`Block`:`Video`}),(0,K.jsx)(`span`,{className:`squisq-timeline-item-menu-title`,title:t.title,children:t.title})]}),t.kind===`block`?(0,K.jsx)(fL,{target:t,colorScheme:n,accentColor:r,onDuration:i,onStartTime:a,onTransition:o}):(0,K.jsx)(pL,{target:t,onPatch:s})]}),document.body)}function fL({target:e,colorScheme:t,accentColor:n,onDuration:r,onStartTime:i,onTransition:a}){let[o,s]=(0,G.useState)(e.explicitDuration),[c,l]=(0,G.useState)(gL(e.duration)),[u,d]=(0,G.useState)(e.startTime==null?``:gL(e.startTime)),[f,p]=(0,G.useState)(e.transition),m=t=>{if(s(!t),t)r(null);else{let t=hL(c)??e.duration;l(gL(t)),r(t)}};return(0,K.jsxs)(`div`,{className:`squisq-timeline-item-menu-body`,children:[(0,K.jsxs)(`label`,{className:`squisq-timeline-item-menu-check`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:!o,onChange:e=>m(e.target.checked)}),(0,K.jsx)(`span`,{children:`Autotime block`})]}),(0,K.jsx)(`p`,{className:`squisq-timeline-item-menu-hint`,children:`Uses narration, content, and interior media when no explicit duration is set.`}),(0,K.jsx)(mL,{label:`Duration`,ariaLabel:`Block duration in seconds`,value:c,disabled:!o,onChange:e=>{l(e);let t=hL(e);t!=null&&r(t)}}),(0,K.jsx)(mL,{label:`Start time`,ariaLabel:`Block start time in seconds`,value:u,placeholder:`auto`,onChange:e=>{d(e),i(e.trim()===``?null:hL(e))}}),(0,K.jsxs)(`div`,{className:`squisq-timeline-item-menu-row`,children:[(0,K.jsx)(`span`,{className:`squisq-timeline-item-menu-label`,children:`Transition`}),(0,K.jsx)(Ry,{value:f,colorScheme:t,accentColor:n,onChange:e=>{p(e),a(e)}})]})]})}function pL({target:e,onPatch:t}){let[n,r]=(0,G.useState)(e.placement),[i,a]=(0,G.useState)(e.lockToBlock),[o,s]=(0,G.useState)(e.pipSize??``),[c,l]=(0,G.useState)(e.pipShape??``),[u,d]=(0,G.useState)(e.pipPosition??``),f=n===`picture-in-picture`||n===`overlay`,p=[e.canUseContentPlacement?{value:`content`,label:`In layout`}:{value:`default`,label:`Default`},{value:`picture-in-picture`,label:`PIP`},{value:`overlay`,label:`Overlay`}];return(0,K.jsxs)(`div`,{className:`squisq-timeline-item-menu-body`,children:[(0,K.jsxs)(`div`,{className:`squisq-timeline-item-menu-field`,children:[(0,K.jsx)(`span`,{className:`squisq-timeline-item-menu-label`,children:`Placement`}),(0,K.jsx)(`div`,{className:`squisq-timeline-item-menu-segments`,role:`group`,"aria-label":`Video placement`,children:p.map(e=>(0,K.jsx)(`button`,{type:`button`,"aria-pressed":n===e.value,onClick:()=>{r(e.value);let n=e.value===`content`||e.value==="default";t({placement:e.value==="default"?null:e.value,...n?{lockToBlock:null,pipSize:null,pipShape:null,pipPosition:null}:{}})},children:e.label},e.value))})]}),f&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`label`,{className:`squisq-timeline-item-menu-check`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:i,onChange:n=>{let r=n.target.checked;a(r),t(r?{lockToBlock:!0,startAt:null,clipEnd:null}:{lockToBlock:!1,startAt:e.absoluteStart})}}),(0,K.jsx)(`span`,{children:`Lock to block`})]}),n===`picture-in-picture`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`label`,{className:`squisq-timeline-item-menu-field`,children:[(0,K.jsx)(`span`,{className:`squisq-timeline-item-menu-label`,children:`PIP size`}),(0,K.jsxs)(`select`,{"aria-label":`Picture-in-picture size`,value:o,onChange:e=>{let n=e.target.value;s(n),t({pipSize:n||null})},children:[(0,K.jsxs)(`option`,{value:``,children:[`Document default (`,_L(e.defaultPipSize),`)`]}),(0,K.jsx)(`option`,{value:`small`,children:`Small`}),(0,K.jsx)(`option`,{value:`large`,children:`Large`})]})]}),(0,K.jsxs)(`label`,{className:`squisq-timeline-item-menu-field`,children:[(0,K.jsx)(`span`,{className:`squisq-timeline-item-menu-label`,children:`PIP shape`}),(0,K.jsxs)(`select`,{"aria-label":`Picture-in-picture shape`,value:c,onChange:e=>{let n=e.target.value;l(n),t({pipShape:n||null})},children:[(0,K.jsxs)(`option`,{value:``,children:[`Document default (`,_L(e.defaultPipShape),`)`]}),(0,K.jsx)(`option`,{value:`square`,children:`Square`}),(0,K.jsx)(`option`,{value:`wide`,children:`Wide (16:9)`})]})]}),(0,K.jsxs)(`label`,{className:`squisq-timeline-item-menu-field`,children:[(0,K.jsx)(`span`,{className:`squisq-timeline-item-menu-label`,children:`PIP position`}),(0,K.jsxs)(`select`,{"aria-label":`Picture-in-picture position`,value:u,onChange:e=>{let n=e.target.value;d(n),t({pipPosition:n||null})},children:[(0,K.jsxs)(`option`,{value:``,children:[`Document default (`,vL(e.defaultPipPosition),`)`]}),(0,K.jsx)(`option`,{value:`top-left`,children:`Top left`}),(0,K.jsx)(`option`,{value:`top-right`,children:`Top right`}),(0,K.jsx)(`option`,{value:`bottom-left`,children:`Bottom left`}),(0,K.jsx)(`option`,{value:`bottom-right`,children:`Bottom right`})]})]})]})]})]})}function mL({label:e,ariaLabel:t,value:n,placeholder:r,disabled:i,onChange:a}){return(0,K.jsxs)(`label`,{className:`squisq-timeline-item-menu-field`,children:[(0,K.jsx)(`span`,{className:`squisq-timeline-item-menu-label`,children:e}),(0,K.jsxs)(`span`,{className:`squisq-timeline-item-menu-number`,children:[(0,K.jsx)(`input`,{type:`number`,min:`0`,step:`0.1`,"aria-label":t,placeholder:r,value:n,disabled:i,onChange:e=>a(e.target.value)}),(0,K.jsx)(`span`,{children:`sec`})]})]})}function hL(e){if(e.trim()===``)return null;let t=Number(e);return Number.isFinite(t)&&t>=0?t:null}function gL(e){return String(Number.isInteger(e)?e:Math.round(e*100)/100)}function _L(e){return e.charAt(0).toUpperCase()+e.slice(1)}function vL(e){return e.split(`-`).map(_L).join(` `)}function yL(e){return e?{"--squisq-block-props-accent":e}:{}}function bL(e,t){let n=t?.getBoundingClientRect(),r=n?.width??320,i=n?.height??300,a=Math.max(8,window.innerWidth-r-8),o=Math.min(Math.max(8,e.right-r),a),s=window.innerHeight-e.bottom-5-8,c=e.top-5-8,l=s>=i||s>=c?e.bottom+5:e.top-i-5,u=Math.max(8,window.innerHeight-i-8);return{position:`fixed`,top:Math.min(Math.max(8,l),u),left:o,maxHeight:`calc(100vh - 16px)`,zIndex:9998}}var xL=Ge.landscape,SL=18,CL=4,wL=160,TL=1.4,EL=.5,DL=4,OL=[1,2,5,10,15,30,60,120,300,600],kL=64,AL=72,jL=8;function ML({src:e,sourceStart:t,sourceLength:n,width:r}){let i=mF(e),a=Math.min(jL,Math.max(1,Math.ceil(r/AL)));return(0,K.jsx)(`div`,{className:`squisq-timeline-video-filmstrip`,"aria-hidden":`true`,children:Array.from({length:a},(e,r)=>{let o=Math.max(0,t)+Math.max(0,n)*((r+.5)/a);return(0,K.jsx)(`video`,{src:i,muted:!0,playsInline:!0,preload:`metadata`,tabIndex:-1,draggable:!1,onLoadedMetadata:e=>NL(e.currentTarget,o)},`${r}:${o}`)})})}function NL(e,t){let n=Number.isFinite(e.duration)&&e.duration>0?Math.max(0,e.duration-.04):t,r=Math.max(0,Math.min(t,n));try{e.currentTime=r}catch{}}function PL(e){return e.sourceHeading?.position?.start.line}function FL({height:e=160,basePath:t=`/`,doc:n,clock:r,schedule:i}){let{doc:a,markdownSource:o,setMarkdownSource:s,goToBlockByLine:c,activeBlockStartLine:l,mediaProvider:u,colorScheme:d}=Lp(),f=n??a,[p,m]=(0,G.useState)(null),[h,g]=(0,G.useState)(null),[_,v]=(0,G.useState)(SL),y=(0,G.useRef)(null),b=(0,G.useMemo)(()=>f?Se(f.blocks):[],[f]),x=Ng(),S=x?.activeTheme??at,C=(0,G.useMemo)(()=>{let e=new Map;if(f)for(let t of b){let n=$s(f,t,S,xL);n&&e.set(t.id,n)}return e},[f,b,S]),w=(0,G.useMemo)(()=>f?ot(f):[],[f]),T=i??w,E=(0,G.useMemo)(()=>f?oL(f,T):T,[T,f]),D=(0,G.useMemo)(()=>f?it(f):0,[f]),O=Math.max(D*_,200),k=lL(D),A=r??k,{currentTime:j,isPlaying:M,play:N,pause:P,seek:F}=A,I=(0,G.useCallback)(()=>{m(null),N()},[N]),[L,ee]=(0,G.useState)(!1);(0,G.useEffect)(()=>{if(!L)return;let e=e=>{let t=y.current;if(!t)return;let n=t.getBoundingClientRect(),r=e.clientX-n.left+t.scrollLeft;F(r/_)},t=()=>ee(!1);return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},[L,_,F]);let te=(0,G.useMemo)(()=>{let e=new Map;if(f){for(let t of Se(f.blocks))for(let n of t.media??[])e.set(n.id,n);for(let t of f.documentMedia??[])e.set(t.id,t)}return e},[f]),R=(0,G.useCallback)(e=>{let t=b.filter(e=>PL(e)!=null);if(t.length===0)return null;let n=t[0];for(let r of t)e>=r.startTime&&(n=r);return n},[b]),ne=(0,G.useRef)(null);(0,G.useEffect)(()=>{if(!M){ne.current=null;return}let e=R(j);if(!e||e.id===ne.current)return;ne.current=e.id;let t=PL(e);t!=null&&c(t)},[M,j,R,c]),(0,G.useEffect)(()=>{if(!M)return;let e=y.current;if(!e)return;let t=j*_,n=e.scrollLeft,r=n+e.clientWidth;(t<n||t>r-80)&&(e.scrollLeft=Math.max(0,t-e.clientWidth/2))},[M,j,_]);let re=(0,G.useCallback)((e,t,n,r,i)=>{if(e==null)return;let a=R(r),c=a?PL(a):void 0;if(a==null||c==null)return;let l=Math.max(0,r-a.startTime);if(t===a.id){let t=JI(o,e,{startAt:l,...i});t&&s(t);return}let u=ZI(o,e,c,i?.clipEnd==null?n:{...n,clipEnd:i.clipEnd},l);u&&s(u)},[R,o,s]),z=(0,G.useCallback)((e,t,n)=>{if(e==null)return;let r=R(n),i=r?PL(r):void 0;if(r==null||i==null)return;let a=Math.max(0,n-r.startTime),c=ZI(o,e,i,t,a);c&&s(c)},[R,o,s]),ie=(0,G.useCallback)(()=>v(e=>Math.min(wL,e*TL)),[]),ae=(0,G.useCallback)(()=>v(e=>Math.max(CL,e/TL)),[]),[oe,se]=(0,G.useState)(0);(0,G.useEffect)(()=>{let e=y.current;if(!e||typeof ResizeObserver>`u`)return;let t=()=>se(e.clientWidth);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let ce=(0,G.useRef)(_);ce.current=_;let le=(0,G.useRef)(null);le.current=p;let B=p!=null&&!p.committed;(0,G.useEffect)(()=>{if(!B)return;let e=e=>{let t=le.current;if(!t)return;let n=e.clientX-t.startX,r=t.moved||Math.abs(n)>=DL,i=n/ce.current;m({...t,moved:r,preview:Math.max(t.floor,t.previewBase+i)})},t=()=>{let e=le.current;if(e){if(!e.moved){e.onClick?.(),m(null);return}e.commit(e.preview),m({...e,committed:!0}),window.setTimeout(()=>{le.current?.committed&&m(null)},500)}};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},[B]),(0,G.useEffect)(()=>{le.current?.committed&&m(null)},[f]);let ue=(0,G.useCallback)((e,t,n,r,i,a)=>{e.preventDefault(),e.stopPropagation();let o=a?.floor??(t===`clip-move`||t===`embed-move`?0:EL);m({kind:t,startX:e.clientX,floor:o,preview:r,previewBase:r,commit:i,targetId:n,pivotIndex:a?.pivotIndex,onClick:a?.onClick})},[]),V=(0,G.useCallback)((e,t)=>{F(e);let n=t==null?void 0:b.find(e=>e.id===t),r=n?PL(n):void 0;r!=null&&c(r)},[F,b,c]);if(!f)return null;let de=null;if(h?.kind===`block`){let e=b.find(e=>e.id===h.id);if(e){let t=Ae(e),n=o.split(`
|
|
519
|
+
`)[h.sourceLine-1]??``;de={kind:`block`,key:e.id,title:e.title??e.id,duration:e.duration,explicitDuration:t.duration!=null,startTime:t.startTime??null,transition:wy(n)}}}else if(h?.kind===`video`){let e=h.embedded?null:T.find(e=>e.id===h.id&&e.kind===`video`),t=e?te.get(e.id):void 0;de={kind:`video`,key:h.id,title:uL(h.src,`video`),placement:h.embedded?`content`:e?.placement??`default`,canUseContentPlacement:h.embedded||t?.origin?.format===`html`,lockToBlock:h.embedded||e?.lockToBlock===!0||e?.anchor===`block`,absoluteStart:e?.absoluteStart??h.absoluteStart,pipSize:t?.pipSize,pipShape:t?.pipShape,pipPosition:t?.pipPosition,defaultPipSize:x?.activePipSize??`small`,defaultPipShape:x?.activePipShape??`square`,defaultPipPosition:x?.activePipPosition??`bottom-right`}}let fe=p&&(p.kind===`block-right`||p.kind===`block-left`)?p:null,H=fe?.pivotIndex??-1,pe=fe?fe.preview-fe.previewBase:0,me=e=>(b[e].startTime+(e>H?pe:0))*_,U=e=>Math.max((e===H?fe.preview:b[e].duration)*_,2),he=e=>!fe||e.anchor===`document`||!e.blockId?0:b.findIndex(t=>t.id===e.blockId)>H?pe:0,ge=OL.find(e=>e*_>=kL)??OL[OL.length-1],_e=Math.max(D,oe/_),W=[];for(let e=0;e<=_e+.001&&W.length<1e3;e+=ge)W.push(e);return(0,K.jsxs)(`div`,{className:`squisq-timeline`,style:{height:e},"data-testid":`timeline-track`,children:[(0,K.jsxs)(`div`,{className:`squisq-timeline-controls`,children:[(0,K.jsx)(`button`,{type:`button`,className:`squisq-timeline-zoom-button squisq-timeline-play-button`,onClick:M?P:I,"aria-label":M?`Pause`:`Play`,"data-tooltip":M?`Pause`:`Play`,"data-testid":`timeline-play`,children:M?`❚❚`:`▶`}),(0,K.jsxs)(`span`,{className:`squisq-timeline-time`,"data-testid":`timeline-time`,children:[LL(j),` / `,LL(D)]}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-timeline-zoom-button`,onClick:ae,disabled:_<=CL,"aria-label":`Zoom out`,"data-tooltip":`Zoom out`,children:`−`}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-timeline-zoom-button`,onClick:ie,disabled:_>=wL,"aria-label":`Zoom in`,"data-tooltip":`Zoom in`,children:`+`})]}),(0,K.jsx)(`div`,{className:`squisq-timeline-scroll`,ref:y,children:(0,K.jsxs)(`div`,{className:`squisq-timeline-inner`,style:{width:O},children:[(0,K.jsx)(`div`,{className:`squisq-timeline-row squisq-timeline-row--blocks`,children:b.map((e,t)=>{let n=PL(e),r=n!=null&&n===l,i=me(t),a=U(t),d=t>0?b[t-1]:null;return(0,K.jsxs)(`div`,{className:`squisq-timeline-block${r?` squisq-timeline-block--active`:``}`,style:{left:i,width:a},title:`${e.title??e.id} \u2014 ${RL(e.duration)}`,onClick:()=>{F(e.startTime),n!=null&&c(n)},children:[C.has(e.id)&&(0,K.jsx)(`div`,{className:`squisq-timeline-block-thumb`,"aria-hidden":!0,children:(0,K.jsx)(nc,{visual:C.get(e.id),viewport:xL,mediaProvider:u})}),d&&PL(d)!=null&&(0,K.jsx)(`span`,{className:`squisq-timeline-edge squisq-timeline-edge--left`,onPointerDown:n=>ue(n,`block-left`,e.id,d.duration,e=>{let t=VI(o,PL(d),e);t&&s(t)},{pivotIndex:t-1})}),(0,K.jsx)(`span`,{className:`squisq-timeline-block-label`,children:e.title??e.id}),n!=null&&(0,K.jsx)(`button`,{type:`button`,className:`squisq-timeline-item-menu-trigger`,"aria-label":`Block options for ${e.title??e.id}`,"aria-haspopup":`dialog`,"aria-expanded":h?.kind===`block`&&h.id===e.id,title:`Block options`,onPointerDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),g({kind:`block`,id:e.id,sourceLine:n,anchor:IL(t.currentTarget)})},children:`…`}),n!=null&&(0,K.jsx)(`span`,{className:`squisq-timeline-edge squisq-timeline-edge--right`,onPointerDown:r=>ue(r,`block-right`,e.id,e.duration,e=>{let t=VI(o,n,e);t&&s(t)},{pivotIndex:t})})]},e.id)})}),(0,K.jsxs)(`div`,{className:`squisq-timeline-media-tracks`,"aria-label":`Media tracks`,children:[T.map(e=>{let t=e.absoluteEnd-e.absoluteStart,n=(e.absoluteStart+he(e))*_,r=Math.max(t*_,4);p?.targetId===e.id&&p.kind===`clip-move`?n=p.preview*_:p?.targetId===e.id&&p.kind===`clip-right`&&(r=Math.max(p.preview*_,4));let i=e.sourceLine!=null&&e.lockToBlock!==!0,a=()=>{let t=te.get(e.id);return t?{kind:t.kind,src:t.src,placement:t.placement,lockToBlock:t.lockToBlock,pipSize:t.pipSize,pipShape:t.pipShape,pipPosition:t.pipPosition,clipStart:t.clipStart,clipEnd:t.clipEnd,spillover:t.spillover}:{kind:e.kind,src:e.src,clipStart:e.sourceIn}};return(0,K.jsx)(`div`,{className:`squisq-timeline-row squisq-timeline-row--media`,"data-testid":`timeline-media-track`,"data-track-id":e.id,children:(0,K.jsxs)(`div`,{className:`squisq-timeline-clip squisq-timeline-clip--${e.kind}${e.anchor===`document`?` squisq-timeline-clip--document`:``}${e.lockToBlock===!0?` squisq-timeline-clip--locked`:``}`,style:{left:n,width:r},title:`${e.src} \u2014 ${RL(t)}${e.lockToBlock===!0?` (locked to block)`:e.anchor===`document`?` (independent)`:``}`,onPointerDown:t=>i&&ue(t,`clip-move`,e.id,e.absoluteStart,t=>{if(e.anchor===`document`){let n=JI(o,e.sourceLine,{startAt:t});n&&s(n)}else re(e.sourceLine,e.blockId,a(),t)},{onClick:()=>V(e.absoluteStart,e.blockId)}),onDoubleClick:()=>{if(!i||e.sourceLine==null)return;let t=JI(o,e.sourceLine,{spillover:e.anchor===`block`||null});t&&s(t)},children:[e.kind===`video`&&(0,K.jsx)(ML,{src:e.src,sourceStart:e.sourceIn??0,sourceLength:t,width:r}),(0,K.jsx)(`span`,{className:`squisq-timeline-clip-label`,children:uL(e.src,e.kind)}),e.kind===`video`&&e.sourceLine!=null&&(0,K.jsx)(`button`,{type:`button`,className:`squisq-timeline-item-menu-trigger squisq-timeline-item-menu-trigger--clip`,"aria-label":`Video options for ${uL(e.src,e.kind)}`,"aria-haspopup":`dialog`,"aria-expanded":h?.kind===`video`&&h.id===e.id,title:`Video options`,onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),g({kind:`video`,id:e.id,sourceLine:e.sourceLine,src:e.src,absoluteStart:e.absoluteStart,embedded:!1,anchor:IL(t.currentTarget)})},children:`…`}),i&&(0,K.jsx)(`span`,{className:`squisq-timeline-edge squisq-timeline-edge--right`,onPointerDown:n=>ue(n,`clip-right`,e.id,t,t=>{let n=JI(o,e.sourceLine,{clipEnd:(e.sourceIn??0)+t});n&&s(n)})})]})},`scheduled:${e.id}`)}),b.flatMap((e,t)=>nL(e).map((n,r)=>{let i=`embed:${e.id}:${r}`,a=rL(e,n),o=a.absoluteStart,s=a.absoluteEnd-a.absoluteStart,c=a.sourceIn??0,l=Math.max(0,n.startAt??0),u=n.clipEnd==null?null:Math.max(0,n.clipEnd-c),d=Math.max(0,U(t)/_-l),f=u==null?d:Math.min(u,d),m=me(t),v=U(t);m+=l*_,v=Math.max(f*_,4),p?.targetId===i&&p.kind===`embed-move`?m=p.preview*_:p?.targetId===i&&p.kind===`embed-right`&&(v=Math.max(p.preview*_,4));let y={kind:n.kind,src:n.src,...n.clipStart==null?{}:{clipStart:n.clipStart},...n.clipEnd==null?{}:{clipEnd:n.clipEnd}};return(0,K.jsx)(`div`,{className:`squisq-timeline-row squisq-timeline-row--media`,"data-testid":`timeline-media-track`,"data-track-id":i,children:(0,K.jsxs)(`div`,{className:`squisq-timeline-clip squisq-timeline-clip--${n.kind} squisq-timeline-clip--embedded`,style:{left:m,width:v},title:`${n.src} \u2014 drag to time / move between blocks`,onPointerDown:t=>n.sourceLine!=null&&ue(t,`embed-move`,i,o,e=>{z(n.sourceLine,{...y,clipEnd:c+s},e)},{onClick:()=>V(e.startTime,e.id)}),children:[n.kind===`video`&&(0,K.jsx)(ML,{src:n.src,sourceStart:c,sourceLength:s,width:v}),(0,K.jsx)(`span`,{className:`squisq-timeline-clip-label`,children:uL(n.src,n.kind)}),n.kind===`video`&&n.sourceLine!=null&&(0,K.jsx)(`button`,{type:`button`,className:`squisq-timeline-item-menu-trigger squisq-timeline-item-menu-trigger--clip`,"aria-label":`Video options for ${uL(n.src,n.kind)}`,"aria-haspopup":`dialog`,"aria-expanded":h?.kind===`video`&&h.id===i,title:`Video options`,onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),g({kind:`video`,id:i,sourceLine:n.sourceLine,src:n.src,absoluteStart:o,embedded:!0,anchor:IL(e.currentTarget)})},children:`…`}),n.sourceLine!=null&&(0,K.jsx)(`span`,{className:`squisq-timeline-edge squisq-timeline-edge--right`,onPointerDown:e=>ue(e,`embed-right`,i,s,e=>{z(n.sourceLine,{...y,clipEnd:c+e},o)})})]})},`embedded:${i}`)}))]}),(0,K.jsx)(`div`,{className:`squisq-timeline-row squisq-timeline-row--ruler`,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();F((e.clientX-t.left)/_)},children:W.map(e=>(0,K.jsx)(`div`,{className:`squisq-timeline-tick`,style:{left:e*_},children:(0,K.jsx)(`span`,{className:`squisq-timeline-tick-label`,children:RL(e)})},e))}),(0,K.jsx)(`div`,{className:`squisq-timeline-playhead`,style:{left:j*_},"data-testid":`timeline-playhead`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation(),P(),ee(!0)},children:(0,K.jsx)(`div`,{className:`squisq-timeline-playhead-knob`})})]})}),(0,K.jsx)(`div`,{ref:A.registerMediaHost,className:`squisq-timeline-media-host`,"aria-hidden":!0,children:(0,K.jsx)(pn.Provider,{value:u??null,children:(0,K.jsx)(Rn,{schedule:E,currentTime:j,isPlaying:M,basePath:t})})}),h&&de&&(0,K.jsx)(dL,{anchor:h.anchor,target:de,colorScheme:d,accentColor:x?.activeTheme.colors.primary,onBlockDuration:e=>{if(h.kind!==`block`)return;let t=VI(o,h.sourceLine,e);t&&s(t)},onBlockStartTime:e=>{if(h.kind!==`block`)return;let t=HI(o,h.sourceLine,e);t&&s(t)},onBlockTransition:e=>{if(h.kind!==`block`)return;let t=WI(o,h.sourceLine,e);t&&s(t)},onVideoPatch:e=>{if(h.kind!==`video`)return;let t=JI(o,h.sourceLine,e);t&&s(t)},onClose:()=>g(null)},`${h.kind}:${h.id}`)]})}function IL(e){let t=e.getBoundingClientRect();return{top:t.top,right:t.right,bottom:t.bottom,left:t.left}}function LL(e){let t=Math.max(0,Math.floor(e));return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}function RL(e){let t=Math.round(e*10)/10;if(t<60)return`${t}s`;let n=Math.floor(t/60),r=Math.round(t-n*60);return`${n}:${String(r).padStart(2,`0`)}`}function zL({schedule:e,currentTime:t,isPlaying:n,basePath:r=`/`,onClose:i}){let a=(0,G.useMemo)(()=>e.filter(e=>e.kind===`video`),[e]),o=a.filter(e=>t>=e.absoluteStart&&t<e.absoluteEnd),s=o.length===1?uL(o[0].src,`video`):o.length>1?`${o.length} video clips`:`No video at this time`;return(0,K.jsxs)(`aside`,{className:`squisq-timeline-preview-panel squisq-timeline-video-panel`,"data-testid":`timeline-video-panel`,"aria-label":`Timeline video preview`,children:[(0,K.jsxs)(`header`,{className:`squisq-timeline-video-header`,children:[(0,K.jsx)(`span`,{className:`squisq-timeline-video-title`,children:`Video monitor`}),(0,K.jsx)(`span`,{className:`squisq-timeline-video-label`,title:s,children:s}),(0,K.jsx)(`span`,{className:`squisq-timeline-video-time`,children:BL(t)}),i&&(0,K.jsx)(`button`,{type:`button`,className:`squisq-timeline-video-close`,onClick:i,"aria-label":`Hide video preview`,"data-tooltip":`Hide video preview`,children:`×`})]}),(0,K.jsx)(`div`,{className:`squisq-timeline-video-body`,children:(0,K.jsxs)(`div`,{className:`squisq-timeline-video-stage`,children:[(0,K.jsx)(Rn,{schedule:a,currentTime:t,isPlaying:n,basePath:r,presentation:`full-frame`,honorClipPresentation:!1,muted:!0}),o.length===0&&(0,K.jsx)(`div`,{className:`squisq-timeline-video-empty`,children:`Move the playhead onto a video clip`})]})})]})}function BL(e){let t=Math.max(0,Math.floor(e));return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}var VL=50,HL=new WeakMap;function UL(e,t){let n=HL.get(e);return(!n||n.revision!==t)&&(n={revision:t,cache:new Map},HL.set(e,n)),n.cache}async function WL(e,t,n){try{let{defaultDataReaders:r}=await Ut(async()=>{let{defaultDataReaders:e}=await import(`./data-B2kHjlc5.js`);return{defaultDataReaders:e}},__vite__mapDeps([85,12,1,13,86,23,24,18,19,17,25,26,27,28,87,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,20,2,55,56,57,58,59,60,61,62,14,88,89,90]));return(await T(e,t,{readers:r(),maxPreviewRows:VL,tableCache:UL(t,n)})).doc}catch{return e}}function GL(e,t){return e===t||e.segments.length===t.segments.length&&e.segments.every((e,n)=>{let r=t.segments[n];return e.src===r.src&&e.name===r.name&&e.duration===r.duration&&e.startTime===r.startTime})}function KL(e,t){let n=e?.playerDoc.audio;return!n||!GL(n,t.playerDoc.audio)?t:{...t,playerDoc:{...t.playerDoc,audio:n}}}function qL(e,t,n,r,i){let[o,s]=(0,G.useState)(null);return(0,G.useEffect)(()=>{if(!e||!e.blocks.length){s(null);return}let o=e=>{let n=t?Kn(e,t).doc:e;return{contentDoc:n,playerDoc:le(n,{documentTitle:r,interleaveImages:!(n.documentMedia??[]).some(e=>e.anchor===`document`)})}},c=e=>{s(t=>KL(t,e))};if(n){let t=!1,r=o(e);return a(e,n).then(e=>WL(e,n,i??0)).then(e=>{t||c(o(e))},()=>{t||c(r)}),s(e=>e??r),()=>{t=!0}}c(o(e))},[e,t,n,r,i]),o}function JL({doc:e,clock:t,basePath:n=`/`,workspaceContainer:r,onClose:i}){let{activeViewport:a,activeTheme:o,activeTransformStyle:s,activeCaptionStyle:c,activeCaptionsEnabled:l,activeVideoPresentation:u,activePipSize:d,activePipShape:f,activePipPosition:p,activeCoverSlide:m,activeCoverSlideTemplate:h,activeCoverSlideDuration:g,activeCoverSlidePlayback:_}=Mg(),{fileName:v,mediaRevision:y}=Lp(),b=qL(e,s,r,ue(v),y),x=b?.contentDoc??null,S=b?.playerDoc??null,C=(0,G.useMemo)(()=>S?it(S):0,[S]),w=(0,G.useMemo)(()=>{if(!S)return u;let e=ot(S).find(e=>e.kind===`video`&&t.currentTime>=e.absoluteStart&&t.currentTime<e.absoluteEnd);return e?.placement===`picture-in-picture`?`picture-in-picture`:e?.placement===`overlay`?`full-frame`:u},[u,t.currentTime,S]),T=(0,G.useMemo)(()=>({currentTime:t.currentTime,isPlaying:t.isPlaying,currentSegment:0,totalDuration:C,isEnded:C>0&&t.currentTime>=C,isReady:!0,isAvailable:!0,play:async()=>t.play(),pause:async()=>t.pause(),toggle:async()=>t.toggle(),seekTo:async e=>t.seek(e),skipToSegment:async()=>void 0,restart:async()=>t.seek(0)}),[t,C]);return(0,K.jsxs)(`aside`,{className:`squisq-timeline-preview-panel squisq-timeline-composition-panel`,"data-testid":`timeline-composition-panel`,"aria-label":`Timeline video composition preview`,children:[(0,K.jsxs)(`header`,{className:`squisq-timeline-video-header`,children:[(0,K.jsx)(`span`,{className:`squisq-timeline-video-title`,children:`Video composition`}),(0,K.jsx)(`span`,{className:`squisq-timeline-video-label`,children:XL(w)}),(0,K.jsx)(b_,{displayMode:`video`}),(0,K.jsx)(`span`,{className:`squisq-timeline-video-time`,children:YL(t.currentTime)}),i&&(0,K.jsx)(`button`,{type:`button`,className:`squisq-timeline-video-close`,onClick:i,"aria-label":`Hide video composition`,"data-tooltip":`Hide video composition`,children:`×`})]}),(0,K.jsx)(`div`,{className:`squisq-timeline-video-body`,children:(0,K.jsx)(`div`,{className:`squisq-timeline-composition-stage`,children:S?(0,K.jsx)(Bn,{doc:S,basePath:n,audioController:T,audioMode:x?.audio?.segments?.length?`media`:`synthetic`,showControls:!1,showScrubber:!1,muted:!0,forceViewport:a,displayMode:`video`,theme:o,videoPresentation:u,pipSize:d,pipShape:f,pipPosition:p,captionStyle:c,captionsEnabled:l,showCoverSlide:m,coverSlideTemplate:h,coverSlideDuration:g,coverSlidePlayback:_,enableSwipe:!1,globalKeyboardShortcuts:!1}):(0,K.jsx)(`div`,{className:`squisq-timeline-video-empty`,children:`Preparing video composition…`})})})]})}function YL(e){let t=Math.max(0,Math.floor(e));return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}function XL(e){return e===`picture-in-picture`?`Picture in picture`:e===`full-frame`?`Overlay`:`Background`}function ZL({literalVideoVisible:e,compositionVisible:t,videoAvailable:n,compositionAvailable:r,onToggleLiteralVideo:i,onToggleComposition:a}){return(0,K.jsxs)(`div`,{className:`squisq-timeline-toolbar`,role:`toolbar`,"aria-label":`Timeline view controls`,"data-testid":`timeline-toolbar`,children:[(0,K.jsx)(`span`,{className:`squisq-timeline-toolbar-title`,children:`Preview panes`}),(0,K.jsxs)(`button`,{type:`button`,className:`squisq-timeline-pane-toggle`,onClick:i,disabled:!n,"aria-pressed":e,"data-testid":`timeline-literal-video-toggle`,"data-tooltip":e?`Hide literal video`:`Show literal video`,children:[(0,K.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 15 15`,"aria-hidden":`true`,children:[(0,K.jsx)(`rect`,{x:`1.5`,y:`3`,width:`8.5`,height:`9`,rx:`1.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`}),(0,K.jsx)(`path`,{d:`M10 5.5 13.5 4v7L10 9.5z`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinejoin:`round`})]}),(0,K.jsx)(`span`,{children:`Video monitor`})]}),(0,K.jsxs)(`button`,{type:`button`,className:`squisq-timeline-pane-toggle`,onClick:a,disabled:!r,"aria-pressed":t,"data-testid":`timeline-composition-toggle`,"data-tooltip":t?`Hide video composition`:`Show video composition`,children:[(0,K.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 15 15`,"aria-hidden":`true`,children:[(0,K.jsx)(`rect`,{x:`1.5`,y:`2`,width:`12`,height:`9`,rx:`1.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`}),(0,K.jsx)(`path`,{d:`M5 13h5M7.5 11v2`,stroke:`currentColor`,strokeWidth:`1.4`}),(0,K.jsx)(`path`,{d:`m6.3 5 3 1.5-3 1.5z`,fill:`currentColor`})]}),(0,K.jsx)(`span`,{children:`Video composition`})]})]})}function QL(){if(typeof document>`u`)return;let e=[];for(let t of Array.from(document.styleSheets)){let n=null;try{n=t.cssRules}catch{continue}if(n)for(let t of Array.from(n))$L(t)&&e.push(t.cssText)}return e.length>0?e.join(`
|
|
520
|
+
`):void 0}function $L(e){let t=e.cssText;return e.type===CSSRule.FONT_FACE_RULE?/font-family:\s*['"]?Font Awesome/i.test(t):e.type===CSSRule.STYLE_RULE?/Font Awesome/i.test(t)||/content:\s*["']\\[ef]/.test(t):!1}var eR=null,tR=null;function nR(){return eR?Promise.resolve(eR):(tR||=Ut(()=>import(`./html-BGVOMhkv.js`).then(e=>e.t).then(e=>(eR=e.markdownDocToPlainHtml,eR)),__vite__mapDeps([94,1,23,24,18,19,17,25,26,27,28,20,13,33,95,31])),tR)}var rR={width:`100%`,height:`100%`,border:`none`,background:`#fff`,display:`block`};function iR({markdown:e,title:t,images:n,mediaProvider:r,mediaRevision:i,theme:a,className:o,style:s,globalKeyboardShortcuts:c=!1,onFrameChange:l,onLinkClick:u,showCodeCopyButton:d=!1,onCopyCode:f}){let p=(0,G.useRef)(null),m=(0,G.useRef)(()=>void 0),h=(0,G.useRef)(()=>void 0),g=(0,G.useCallback)(e=>{p.current=e,l?.(e)},[l]),_=(0,G.useMemo)(()=>Tt(e),[e]),[v,y]=(0,G.useState)(null);(0,G.useEffect)(()=>{if(!r){y(null);return}let e=!1,t=Array.from(oR(_));return Promise.all(t.map(async e=>{let t=dF(e);if(!t&&aR(e))return[e,e];let n=t??e;try{return[e,await r.resolveUrl(n)]}catch{return[e,e]}})).then(t=>{if(e)return;let n=new Map(t);y(n)}),()=>{e=!0}},[_,r,i]);let b=(0,G.useMemo)(()=>{if(!v&&!n)return;let e=new Map;if(v)for(let[t,n]of v)e.set(t,n);if(n)for(let[t,r]of n)e.set(t,r);return e},[v,n]),x=(0,G.useMemo)(()=>QL(),[]),[S,C]=(0,G.useState)(()=>eR);(0,G.useEffect)(()=>{if(S)return;let e=!1;return nR().then(t=>{e||C(()=>t)}),()=>{e=!0}},[S]);let w=(0,G.useMemo)(()=>S?S(_,{title:t,images:b,theme:a,iconsCss:x}):``,[S,_,t,b,a,x]),T=(0,G.useCallback)(()=>{m.current(),m.current=()=>void 0;let e=p.current?.contentDocument,t=e?.defaultView?.Element;if(!e||!t||!u)return;let n=n=>{if(n.button!==0)return;let r=(n.target instanceof t?n.target:null)?.closest(`a[href]`);if(!r||!e.contains(r))return;let i=r.getAttribute(`href`);!i||u(i)===!1||(n.preventDefault(),n.stopPropagation())};e.addEventListener(`click`,n,!0),m.current=()=>e.removeEventListener(`click`,n,!0)},[u]);(0,G.useEffect)(()=>(T(),()=>m.current()),[w,T]);let E=(0,G.useCallback)(()=>{h.current(),h.current=()=>void 0;let e=p.current?.contentDocument;if(!e||!d)return;let t=e.createElement(`style`);t.dataset.squisqCodeCopy=``,t.textContent=`
|
|
521
|
+
.squisq-preview-code-copy-frame { position: relative; margin: 1em 0; }
|
|
522
|
+
.squisq-preview-code-copy-frame > pre { margin: 0; padding-right: 5rem; }
|
|
523
|
+
.squisq-preview-code-copy {
|
|
524
|
+
position: absolute; z-index: 1; top: .55rem; right: .55rem;
|
|
525
|
+
min-width: 3.7rem; padding: .28rem .5rem;
|
|
526
|
+
border: 1px solid color-mix(in srgb, var(--plain-text) 20%, transparent);
|
|
527
|
+
border-radius: 5px;
|
|
528
|
+
background: color-mix(in srgb, var(--plain-bg) 90%, transparent);
|
|
529
|
+
color: inherit; font: 500 .72rem/1.2 system-ui, sans-serif;
|
|
530
|
+
cursor: pointer; opacity: .58;
|
|
531
|
+
transition: opacity 120ms ease, background-color 120ms ease;
|
|
532
|
+
}
|
|
533
|
+
.squisq-preview-code-copy-frame:hover > .squisq-preview-code-copy,
|
|
534
|
+
.squisq-preview-code-copy:focus-visible,
|
|
535
|
+
.squisq-preview-code-copy[data-copy-state="copied"],
|
|
536
|
+
.squisq-preview-code-copy[data-copy-state="failed"] { opacity: 1; }
|
|
537
|
+
.squisq-preview-code-copy:hover { background: var(--plain-bg); }
|
|
538
|
+
.squisq-preview-code-copy:disabled { cursor: wait; }
|
|
539
|
+
`,e.head.append(t);let n=[],r=[],i=new Set;for(let t of e.querySelectorAll(`pre.squisq-code-block > code`)){let a=t.parentElement;if(!a?.parentElement)continue;let o=e.createElement(`div`);o.className=`squisq-preview-code-copy-frame`,a.replaceWith(o),o.append(a),r.push(o);let s=e.createElement(`button`);s.type=`button`,s.className=`squisq-preview-code-copy`,s.dataset.copyState=`idle`,s.textContent=`Copy`,s.setAttribute(`aria-label`,`Copy code to clipboard`),o.append(s);let c=Array.from(t.classList).find(e=>e.startsWith(`language-`))?.slice(9)||void 0,l=async()=>{if(s.dataset.copyState!==`copying`){s.dataset.copyState=`copying`,s.textContent=`Copying…`,s.disabled=!0;try{if(f)await f(t.textContent??``,c===void 0?{}:{language:c});else{let n=e.defaultView?.navigator.clipboard??(typeof navigator>`u`?void 0:navigator.clipboard);if(!n?.writeText)throw Error(`Clipboard access is unavailable`);await n.writeText(t.textContent??``)}s.dataset.copyState=`copied`,s.textContent=`Copied`}catch{s.dataset.copyState=`failed`,s.textContent=`Copy failed`}finally{s.disabled=!1;let e=setTimeout(()=>{i.delete(e),s.dataset.copyState=`idle`,s.textContent=`Copy`},1600);i.add(e)}}};s.addEventListener(`click`,l),n.push(()=>s.removeEventListener(`click`,l))}h.current=()=>{for(let e of n)e();for(let e of i)clearTimeout(e);i.clear();for(let e of r){let t=e.firstElementChild;t&&e.parentElement&&e.replaceWith(t)}t.remove()}},[f,d]);return(0,G.useEffect)(()=>(E(),()=>h.current()),[w,E]),(0,G.useEffect)(()=>{if(!c)return;let e=e=>{if(e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||e.key!==`ArrowDown`&&e.key!==`ArrowUp`||(e.target instanceof Element?e.target:null)?.closest(`input, textarea, select, [contenteditable]:not([contenteditable="false"]), [role="textbox"], [role="combobox"], [role="listbox"], [role="menu"], [role="dialog"], [aria-modal="true"], .monaco-editor`))return;let t=p.current?.contentWindow;if(!t)return;e.preventDefault();let n=Math.max(64,Math.round(p.current?.clientHeight??0)*.12);t.scrollBy({top:e.key===`ArrowDown`?n:-n,behavior:`smooth`})};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[c]),(0,K.jsx)(`iframe`,{ref:g,className:o,"data-testid":`plain-html-preview`,title:t??`HTML preview`,srcDoc:w,onLoad:()=>{T(),E()},sandbox:`allow-same-origin`,style:{...rR,...s}})}function aR(e){return!e||e.startsWith(`data:`)||e.startsWith(`blob:`)||e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`//`)}function oR(e){let t=new Set;function n(e){for(let r of e){if(r.type!==`htmlElement`)continue;let e=r.tagName.toLowerCase();if(e===`img`||e===`video`||e===`audio`||e===`source`){let e=r.attributes.src;typeof e==`string`&&e&&t.add(e)}if(e===`video`||e===`audio`){let e=r.attributes.poster;typeof e==`string`&&e&&t.add(e)}n(r.children)}}function r(e){if(!e||typeof e!=`object`)return;let i=e;if(i.type===`image`&&typeof i.url==`string`&&i.url&&t.add(i.url),(i.type===`htmlBlock`||i.type===`htmlInline`)&&Array.isArray(i.htmlChildren)&&n(i.htmlChildren),Array.isArray(i.children))for(let e of i.children)r(e)}for(let t of e.children)r(t);return t}function sR(e){return{type:`paragraph`,children:[{type:`text`,value:e}]}}function cR(e,t=2){return{type:`heading`,depth:t,children:[{type:`text`,value:e}]}}function lR(e,t){let n=e[t];return typeof n==`string`&&n.trim()?n.trim():void 0}function uR(e,t){let n=e[t];return Array.isArray(n)?n.filter(e=>typeof e==`string`&&!!e.trim()):[]}function dR(e){let t=e,n=lR(t,`template`),r=lR(t,`title`);switch(n){case`statHighlight`:return{title:lR(t,`stat`)??r,body:[lR(t,`description`)].filter(Boolean)};case`factCard`:return{title:lR(t,`fact`)??r,body:[lR(t,`explanation`)].filter(Boolean)};case`quote`:return{title:lR(t,`quote`)??r,body:[lR(t,`attribution`)].filter(Boolean)};case`fullBleedQuote`:case`pullQuote`:return{title:lR(t,`text`)??lR(t,`quote`)??r,body:[lR(t,`attribution`)].filter(Boolean)};case`dateEvent`:return{title:lR(t,`date`)??r,body:[lR(t,`description`)].filter(Boolean)};case`definitionCard`:return{title:lR(t,`term`)??r,body:[lR(t,`definition`),lR(t,`origin`)].filter(Boolean)};case`twoColumn`:return{title:lR(t,`header`)??r??`Comparison`,body:[lR(t,`left`),lR(t,`right`)].filter(Boolean)};case`list`:return{title:r??`Highlights`,body:uR(t,`items`)};case`imageWithCaption`:return{title:lR(t,`caption`)??lR(t,`imageAlt`)??r,body:[]};default:return{title:r,body:[lR(t,`body`),lR(t,`description`),lR(t,`text`)].filter(Boolean)}}}function fR(e){return!!(e.sourceHeading||e.standaloneAnnotation||e.contents&&e.contents.length>0)}function pR(e){let t=e.children?.map(pR);if(fR(e))return t===e.children?e:{...e,children:t};let n=dR(e);return{...e,template:void 0,sourceHeading:n.title?cR(n.title):void 0,contents:n.body.map(sR),children:t}}function mR(e){if(e.startBlock?.title?.trim())return e.startBlock.title.trim();let t=e.frontmatter?.title;return typeof t==`string`&&t.trim()?t.trim():void 0}function hR(e){return e.some(e=>e.sourceHeading?.depth===1||(e.children?hR(e.children):!1))}function gR(e){let t=e.blocks.map(pR),n=mR(e),r=n&&!hR(t)?[{id:`transform-document-title`,startTime:0,duration:0,audioSegment:0,sourceHeading:cR(n,1),contents:[]},...t]:t;return Pt(V({...e,blocks:r}))}var _R=(0,G.createContext)(null);function vR(){let e=(0,G.useContext)(_R);if(!e)throw Error(`usePresentationMode must be used within PresentationModeProvider`);return e}function yR(){return(0,G.useContext)(_R)}var bR=1280,xR=720,SR=4e3;function CR(e,t,n){return e.fullscreenElement===t?new Promise(r=>{let i=t=>{e.removeEventListener(`fullscreenchange`,a),window.clearTimeout(o),r(t)},a=()=>{e.fullscreenElement!==t&&i(!0)},o=window.setTimeout(()=>i(e.fullscreenElement!==t),n);e.addEventListener(`fullscreenchange`,a)}):Promise.resolve(!0)}function wR(e,t){for(let n of Array.from(e.styleSheets)){if(n.href){let e=t.createElement(`link`);e.rel=`stylesheet`,e.href=n.href,t.head.appendChild(e);continue}try{let e=Array.from(n.cssRules).map(e=>e.cssText).join(`
|
|
540
|
+
`),r=t.createElement(`style`);r.textContent=e,t.head.appendChild(r)}catch{}}}function TR(e,t){let n=e.ownerDocument.defaultView;if(!n)return;let r=n.getComputedStyle(e);for(let e=0;e<r.length;e+=1){let n=r.item(e);n.startsWith(`--`)&&t.style.setProperty(n,r.getPropertyValue(n))}}function ER(e,t,n,r,i){let a=t.ownerDocument,o=e.document;o.head.replaceChildren(),o.body.replaceChildren(),o.title=n;let s=o.createElement(`base`);s.href=a.baseURI,o.head.appendChild(s);let c=o.createElement(`meta`);c.name=`viewport`,c.content=`width=device-width, initial-scale=1`,o.head.appendChild(c),wR(a,o);let l=o.createElement(`style`);l.textContent=`html,body{width:100%;height:100%;margin:0;overflow:hidden;}#squisq-presentation-root{position:relative;width:100%;height:100%;overflow:hidden;background:var(--squisq-presentation-bg,var(--squisq-bg,#f5f5f5));}`,o.head.appendChild(l);let u=o.createElement(`div`);return u.id=`squisq-presentation-root`,u.className=`squisq-editor-shell squisq-presentation-root`,u.dataset.theme=r,TR(t,u),u.style.setProperty(`--squisq-presentation-bg`,i),o.body.appendChild(u),u}function DR(e){return typeof e==`string`&&e.trim()?`${e.trim()} - Presentation`:`Squisq Presentation`}function OR({rootRef:e,children:t,allowWindow:n=!0,allowFullscreen:r=!0}){let{activeView:i,colorScheme:a,doc:o}=Lp(),{activeTheme:s}=Mg(),c=(0,G.useId)().replace(/[^a-zA-Z0-9_-]/g,``),[l,u]=(0,G.useState)(`control`),[d,f]=(0,G.useState)(null),[p,m]=(0,G.useState)(null),[h,g]=(0,G.useState)(null),[_,v]=(0,G.useState)(null),y=(0,G.useRef)(d);y.current=d;let b=(0,G.useRef)(null),x=(0,G.useRef)(null),S=(0,G.useRef)(null),C=(0,G.useRef)(null),w=typeof document<`u`&&typeof document.documentElement.requestFullscreen==`function`,T=(0,G.useMemo)(()=>[`control`,...n?[`window`]:[],...r?[`fullscreen`]:[]],[r,n]),E=(0,G.useCallback)(e=>{let t=S.current;if(C.current?.(),C.current=null,S.current=null,m(null),f(e=>e===`window`?null:e),e&&t&&!t.closed)try{t.close()}catch{}},[]),D=(0,G.useCallback)(async()=>{let t=y.current;if(t===`window`){E(!0);return}if(t===`fullscreen`){let t=e.current,n=t?.ownerDocument;if(t&&n?.fullscreenElement===t){try{await n.exitFullscreen()}catch{if(n.fullscreenElement===t){g(`Could not exit full screen. Press Escape to leave it.`);return}}if(!await CR(n,t,SR)){g(`Still in full screen. Press Escape to leave it.`);return}}}f(null)},[E,e]),O=(0,G.useCallback)(async()=>{g(null);let t=e.current;if(!t)return;let i=t.ownerDocument.activeElement;if(x.current=i instanceof HTMLElement?i:null,l===`control`){f(`control`);return}if(l===`fullscreen`){if(!r)return;if(typeof t.requestFullscreen!=`function`){g(`Full screen is unavailable here.`);return}try{await t.requestFullscreen({navigationUI:`hide`}),f(`fullscreen`)}catch{g(`Could not enter full screen.`)}return}if(!n)return;let u=null;try{let e=window.screen?.availWidth||bR,n=window.screen?.availHeight||xR,r=Math.min(bR,Math.max(640,Math.round(e*.9))),i=Math.min(xR,Math.max(480,Math.round(n*.9)));if(u=window.open(``,`squisq-presentation-${c}`,`popup=yes,width=${r},height=${i}`),!u)throw Error(`Popup blocked`);let l=ER(u,t,DR(o?.frontmatter?.title),a,s.colors.background);S.current=u,m(l),f(`window`);let d=()=>E(!1),p=e=>{e.key===`Escape`&&E(!0)};u.addEventListener(`pagehide`,d),u.document.addEventListener(`keydown`,p);let h=window.setInterval(()=>{u?.closed&&E(!1)},500);C.current=()=>{u?.removeEventListener(`pagehide`,d),u?.document.removeEventListener(`keydown`,p),window.clearInterval(h)},u.focus()}catch{S.current?E(!0):u&&!u.closed&&u.close(),g(`The presentation window was blocked. Allow pop-ups and try again.`)}},[r,n,s.colors.background,a,o?.frontmatter?.title,c,E,e,l]),k=(0,G.useCallback)(e=>{T.includes(e)&&e!==l&&(u(e),y.current!==null&&D())},[T,l,D]);(0,G.useEffect)(()=>{T.includes(l)||(u(`control`),y.current!==null&&D())},[T,l,D]),(0,G.useEffect)(()=>{let t=e.current,n=t?.ownerDocument;if(!t||!n)return;let r=()=>{y.current===`fullscreen`&&n.fullscreenElement!==t&&f(null)};return n.addEventListener(`fullscreenchange`,r),()=>n.removeEventListener(`fullscreenchange`,r)},[e]),(0,G.useEffect)(()=>{let t=e.current;if(t)return d?t.dataset.presentationMode=d:delete t.dataset.presentationMode,()=>{delete t.dataset.presentationMode}},[d,e]),(0,G.useEffect)(()=>{i!==`preview`&&y.current!==null&&D()},[i,D]),(0,G.useEffect)(()=>{let e=b.current;if(b.current=d,e===null||d!==null)return;let t=x.current;x.current=null,t?.isConnected&&t.focus()},[d]),(0,G.useEffect)(()=>{if(d!==`control`)return;let t=e.current?.ownerDocument;if(!t)return;let n=e=>{e.key===`Escape`&&(e.preventDefault(),D())};return t.addEventListener(`keydown`,n),()=>t.removeEventListener(`keydown`,n)},[d,e,D]),(0,G.useEffect)(()=>{if(!h)return;let e=window.setTimeout(()=>g(null),6e3);return()=>window.clearTimeout(e)},[h]),(0,G.useLayoutEffect)(()=>{if(d!==`fullscreen`){v(null);return}let t=e.current,n=t?.querySelector(`.doc-controls-slideshow`);if(!t||!n){v(null);return}let r=()=>{let e=t.getBoundingClientRect(),r=n.getBoundingClientRect();v({left:`auto`,right:`${Math.max(0,e.right-r.left+8)}px`,transform:`none`})};r();let i=typeof ResizeObserver>`u`?null:new ResizeObserver(r);return i?.observe(t),i?.observe(n),window.addEventListener(`resize`,r),()=>{i?.disconnect(),window.removeEventListener(`resize`,r)}},[d,e]),(0,G.useEffect)(()=>()=>{C.current?.();let t=S.current;t&&!t.closed&&t.close();let n=e.current,r=n?.ownerDocument;n&&r?.fullscreenElement===n&&r.exitFullscreen().catch(()=>void 0)},[e]);let A=(0,G.useMemo)(()=>({selectedTarget:l,activeTarget:d,popupRoot:p,availableTargets:T,fullscreenSupported:w,selectTarget:k,start:O,stop:D}),[l,d,p,T,w,k,O,D]),j={"--squisq-presentation-control-bg":s.colors.backgroundLight,"--squisq-presentation-control-text":s.colors.text,"--squisq-presentation-control-border":s.colors.primary},M=d?(0,K.jsxs)(`button`,{type:`button`,className:`squisq-presentation-exit`,"data-theme":a,style:{...j,..._},onClick:()=>void D(),autoFocus:d===`control`||d===`fullscreen`,"aria-label":`Exit presentation mode`,title:`Exit presentation mode (Esc)`,children:[(0,K.jsx)(q,{icon:`fa-solid fa-compress`}),(0,K.jsx)(`span`,{children:`Exit presentation`})]}):null;return(0,K.jsxs)(_R.Provider,{value:A,children:[t,(d===`control`||d===`fullscreen`)&&M,d===`window`&&p&&M?(0,Wr.createPortal)(M,p):null,h&&typeof document<`u`?(0,Wr.createPortal)((0,K.jsx)(`div`,{className:`squisq-presentation-error`,"data-theme":a,role:`alert`,children:h}),document.body):null]})}var kR=[{target:`control`,label:`Fill canvas`,summary:`Use the entire app canvas.`,icon:`fa-solid fa-window-maximize`},{target:`window`,label:`New window`,summary:`Open an audience view synced to this one.`,icon:`fa-solid fa-up-right-from-square`},{target:`fullscreen`,label:`Full screen`,summary:`Use the entire OS screen.`,icon:`fa-solid fa-expand`}],AR=340,jR=8,MR=4;function NR(){let{selectedTarget:e,activeTarget:t,availableTargets:n,fullscreenSupported:r,selectTarget:i,start:a,stop:o}=vR(),{colorScheme:s}=Lp(),c=(0,G.useRef)(null),l=(0,G.useRef)(null),[u,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(null),m=kR.filter(e=>n.includes(e.target)),h=m.find(t=>t.target===e)??kR[0],g=(0,G.useCallback)(()=>{let e=c.current;if(!e)return;let t=e.getBoundingClientRect(),n=Math.min(AR,window.innerWidth-jR*2);p({top:t.bottom+MR,left:Math.min(Math.max(jR,t.right-n),Math.max(jR,window.innerWidth-n-jR))})},[]),_=(0,G.useCallback)((e=!1)=>{d(!1),p(null),e&&c.current?.focus()},[]),v=(0,G.useCallback)(()=>{g(),d(!0)},[g]);return(0,G.useEffect)(()=>{if(!u)return;let e=e=>{let t=e.target;c.current?.contains(t)||l.current?.contains(t)||_()},t=e=>{e.key===`Escape`&&(e.preventDefault(),_(!0))};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),window.addEventListener(`resize`,g),window.addEventListener(`scroll`,g,!0),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t),window.removeEventListener(`resize`,g),window.removeEventListener(`scroll`,g,!0)}},[_,u,g]),(0,G.useLayoutEffect)(()=>{if(!u||!f)return;let e=l.current?.querySelector(`[aria-checked="true"]`),t=l.current?.querySelector(`[role="menuitemradio"]`);(e??t)?.focus()},[f,u]),(0,K.jsxs)(`div`,{className:`squisq-presentation-control`,children:[(0,K.jsx)(`button`,{type:`button`,className:`squisq-toolbar-button squisq-presentation-start${t?` squisq-toolbar-button--active`:``}`,"aria-label":t?`Stop presentation`:`Present: ${h.label}`,"aria-pressed":t!==null,"data-tooltip":t?`Exit presentation`:`Present: ${h.label}`,onClick:()=>void(t?o():a()),children:(0,K.jsx)(q,{icon:`fa-solid fa-display`})}),m.length>1&&(0,K.jsx)(`button`,{ref:c,type:`button`,className:`squisq-presentation-menu-trigger${u?` squisq-presentation-menu-trigger--open`:``}`,"aria-label":`Presentation options`,"aria-haspopup":`menu`,"aria-expanded":u,title:`Presentation destination: ${h.label}`,onClick:()=>u?_():v(),onKeyDown:e=>{e.key===`ArrowDown`&&(e.preventDefault(),v())},children:(0,K.jsx)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 10 10`,"aria-hidden":`true`,children:(0,K.jsx)(`path`,{d:`M2 3.5 5 6.5 8 3.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`})})}),u&&f?(0,Wr.createPortal)((0,K.jsx)(`div`,{ref:l,className:`squisq-use-mode-menu squisq-presentation-menu`,"data-theme":s,role:`menu`,"aria-label":`Presentation options`,style:{top:f.top,left:f.left},onKeyDown:e=>{if(e.key===`Tab`){e.preventDefault(),_(!0);return}if(![`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=Array.from(e.currentTarget.querySelectorAll(`[role="menuitemradio"]:not(:disabled)`));if(t.length===0)return;let n=t.indexOf(document.activeElement);t[e.key===`Home`?0:e.key===`End`?t.length-1:e.key===`ArrowUp`?(n-1+t.length)%t.length:(n+1)%t.length]?.focus()},children:m.map(t=>{let n=t.target===e,a=t.target===`fullscreen`&&!r;return(0,K.jsxs)(`button`,{type:`button`,className:`squisq-use-mode-menu-item squisq-presentation-menu-item${n?` squisq-use-mode-menu-item--selected squisq-presentation-menu-item--selected`:``}`,role:`menuitemradio`,"aria-checked":n,tabIndex:n?0:-1,disabled:a,onClick:()=>{i(t.target),_(!0)},children:[(0,K.jsx)(`span`,{className:`squisq-use-mode-menu-icon squisq-presentation-menu-icon`,"aria-hidden":`true`,children:(0,K.jsx)(q,{icon:t.icon})}),(0,K.jsxs)(`span`,{className:`squisq-use-mode-menu-copy squisq-presentation-menu-copy`,children:[(0,K.jsx)(`span`,{className:`squisq-use-mode-menu-label squisq-presentation-menu-label`,children:t.label}),(0,K.jsx)(`span`,{className:`squisq-use-mode-menu-summary squisq-presentation-menu-summary`,children:a?`Full screen is unavailable.`:t.summary})]}),(0,K.jsx)(`span`,{className:`squisq-use-mode-menu-check squisq-presentation-menu-check`,"aria-hidden":`true`,children:n&&(0,K.jsx)(q,{icon:`fa-solid fa-check`})})]},t.target)})}),document.body):null]})}var PR=(0,G.createContext)(null);function FR(){let e=(0,G.useContext)(PR);if(!e)throw Error(`usePrintMode must be used within PrintModeProvider`);return e}function IR(){return(0,G.useContext)(PR)}function LR({rootRef:e,children:t}){let{activeView:n}=Lp(),{activeTarget:r,stop:i}=vR(),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(1),l=(0,G.useRef)(null),u=(0,G.useRef)([]),d=(0,G.useCallback)(()=>{(e.current?.ownerDocument)?.body.classList.remove(`squisq-printing`);for(let e of u.current)delete e.dataset.squisqPrintAncestor;u.current=[]},[e]),f=(0,G.useCallback)(()=>{let t=e.current,n=t?.ownerDocument;if(!t||!n)return;d(),n.body.classList.add(`squisq-printing`);let r=t.parentElement;for(;r&&r!==n.body;)r.dataset.squisqPrintAncestor=`true`,u.current.push(r),r=r.parentElement},[e,d]),p=(0,G.useCallback)(()=>{o(!1),l.current=null,d()},[d]),m=(0,G.useCallback)(async()=>{r&&await i(),o(!0)},[r,i]),h=(0,G.useCallback)(e=>(l.current=e,()=>{l.current===e&&(l.current=null)}),[]),g=(0,G.useCallback)(()=>{let t=l.current;if(t){t();return}let n=e.current?.ownerDocument,r=n?.defaultView;!n||!r||(f(),r.print())},[f,e]);(0,G.useEffect)(()=>{let t=e.current;if(t)return a?t.dataset.printPreview=`true`:delete t.dataset.printPreview,()=>{delete t.dataset.printPreview}},[a,e]),(0,G.useEffect)(()=>{n!==`preview`&&a&&p()},[a,n,p]),(0,G.useEffect)(()=>{if(!a)return;let t=e.current?.ownerDocument.defaultView,n=e.current?.ownerDocument;if(!t||!n)return;let r=()=>f(),i=()=>d(),o=e=>{e.key===`Escape`&&(e.preventDefault(),p())};return t.addEventListener(`beforeprint`,r),t.addEventListener(`afterprint`,i),n.addEventListener(`keydown`,o),()=>{t.removeEventListener(`beforeprint`,r),t.removeEventListener(`afterprint`,i),n.removeEventListener(`keydown`,o),i()}},[a,p,f,e,d]);let _=(0,G.useMemo)(()=>({active:a,slidesPerPage:s,setSlidesPerPage:c,open:m,close:p,print:g,registerPrintHandler:h}),[a,p,m,g,h,s]);return(0,K.jsx)(PR.Provider,{value:_,children:t})}function RR(){let{open:e}=FR();return(0,K.jsxs)(`button`,{type:`button`,className:`squisq-print-trigger`,onClick:()=>void e(),"aria-label":`Print`,"data-tooltip":`Print`,children:[(0,K.jsx)(q,{icon:`fa-solid fa-print`}),(0,K.jsx)(`span`,{children:`Print`})]})}var zR=[1,2,9];function BR(){let{activeDisplayMode:e}=Mg(),{slidesPerPage:t,setSlidesPerPage:n,print:r,close:i}=FR();return(0,K.jsxs)(`div`,{className:`squisq-print-toolbar`,"aria-label":`Print preview controls`,children:[(0,K.jsx)(`span`,{className:`squisq-print-toolbar-title`,children:`Print preview`}),e===`slideshow`&&(0,K.jsx)(`div`,{className:`squisq-print-density`,role:`group`,"aria-label":`Slides per page`,children:zR.map(e=>(0,K.jsxs)(`button`,{type:`button`,className:`squisq-print-density-button${t===e?` squisq-print-density-button--active`:``}`,"aria-pressed":t===e,"aria-label":`${e} ${e===1?`slide`:`slides`} per page`,onClick:()=>n(e),children:[(0,K.jsx)(`span`,{children:e}),(0,K.jsxs)(`span`,{className:`squisq-print-density-label`,children:[` `,e===1?`slide`:`slides`,` per page`]})]},e))}),(0,K.jsx)(`div`,{className:`squisq-print-toolbar-spacer`}),(0,K.jsxs)(`button`,{type:`button`,className:`squisq-print-action`,onClick:r,children:[(0,K.jsx)(q,{icon:`fa-solid fa-print`}),(0,K.jsx)(`span`,{children:`Print`})]}),(0,K.jsxs)(`button`,{type:`button`,className:`squisq-print-close`,onClick:i,children:[(0,K.jsx)(q,{icon:`fa-solid fa-xmark`}),(0,K.jsx)(`span`,{children:`Close`})]})]})}function VR(e,t){let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}function HR({displayMode:e,previewDoc:t,contentDoc:n,documentMarkdown:r,basePath:i,viewport:a,theme:o,showCover:s,transformStyle:c,mediaRevision:u}){let{slidesPerPage:d,registerPrintHandler:f}=FR(),p=fn(),m=(0,G.useRef)(null),h=(0,G.useCallback)(e=>{m.current=e},[]),{blocks:g}=Un(t,0,{viewport:a,theme:o}),_=(0,G.useMemo)(()=>{if(!s||!t?.startBlock)return null;let e=Ke(o,0,1,a);return{id:`cover-block`,startTime:-1,duration:0,audioSegment:-1,layers:te(t.startBlock,e)}},[t?.startBlock,s,o,a]),v=(0,G.useMemo)(()=>n?l(n):null,[n]),y=e===`page`||e===`narrate`;(0,G.useEffect)(()=>f(y?()=>{let e=m.current?.contentWindow;e&&e.print()}:null),[y,f]);let b=n?.frontmatter?.title??n?.startBlock?.title??void 0;if(y)return(0,K.jsx)(`div`,{className:`squisq-print-preview squisq-print-preview--document`,children:(0,K.jsx)(`div`,{className:`squisq-print-document-paper`,children:(0,K.jsx)(iR,{markdown:r,title:b,mediaProvider:p,mediaRevision:u,theme:o,onFrameChange:h})})});if(e===`linear`)return(0,K.jsxs)(`div`,{className:`squisq-print-preview squisq-print-preview--page`,children:[(0,K.jsx)(`style`,{children:`@page { margin: 0; }`}),(0,K.jsx)(`div`,{className:`squisq-print-page-paper`,children:(0,K.jsx)(In,{className:`squisq-print-linear`,doc:n??void 0,basePath:i,viewport:a,theme:o,animationsEnabled:!1,showCover:s,transformPage:c?Gn(c).page:void 0})})]});if(e===`flashcards`){let e={theme:o,basePath:i,showCodeCopyButton:!1,viewport:a,customTemplates:n?.customTemplates};return(0,K.jsxs)(`div`,{className:`squisq-print-preview squisq-print-preview--flashcards`,style:{"--squisq-print-flashcard-text":o.colors.text,"--squisq-print-flashcard-muted":o.colors.textMuted,"--squisq-print-flashcard-accent":o.colors.primary,"--squisq-print-flashcard-bg":o.colors.background,"--squisq-print-flashcard-surface":o.colors.backgroundLight},children:[(0,K.jsx)(`style`,{children:`@page { size: landscape; margin: 0; }`}),v?.cards.map((t,n)=>(0,K.jsxs)(`article`,{className:`squisq-print-flashcard-sheet`,children:[(0,K.jsxs)(`header`,{children:[(0,K.jsxs)(`span`,{children:[`Card `,n+1,` of `,v.cards.length]}),t.label&&(0,K.jsx)(`strong`,{children:t.label})]}),(0,K.jsxs)(`div`,{className:`squisq-print-flashcard-pair`,children:[(0,K.jsxs)(`section`,{className:`squisq-print-flashcard-face`,"aria-label":`Question side`,children:[(0,K.jsx)(`small`,{children:`Front`}),(0,K.jsx)(Hn,{...e,face:t.front}),t.kind===`multiple-choice`&&(0,K.jsx)(`ol`,{className:`squisq-print-flashcard-choices`,children:t.choices?.map(t=>(0,K.jsx)(`li`,{children:(0,K.jsx)(Hn,{...e,face:t.content})},t.id))})]}),(0,K.jsxs)(`section`,{className:`squisq-print-flashcard-face`,"aria-label":`Answer side`,children:[(0,K.jsx)(`small`,{children:`Back`}),(0,K.jsx)(Hn,{...e,face:t.back}),t.explanation&&(0,K.jsxs)(`div`,{className:`squisq-print-flashcard-explanation`,children:[(0,K.jsx)(`small`,{children:`Explanation`}),(0,K.jsx)(Hn,{...e,face:t.explanation})]})]})]})]},t.id)),(!v||v.cards.length===0)&&(0,K.jsx)(`p`,{className:`squisq-print-empty`,children:`Nothing to print.`})]})}let x=_?[_,...g]:g,S=e===`slideshow`?d:1,C=VR(x,S),w=a.width>=a.height?`landscape`:`portrait`;return(0,K.jsxs)(`div`,{className:`squisq-print-preview squisq-print-preview--slides`,"data-slides-per-page":S,style:{"--squisq-print-paper-ratio":`${w===`landscape`?`11 / 8.5`:`8.5 / 11`}`,"--squisq-print-slide-bg":o.colors.background},children:[(0,K.jsx)(`style`,{children:`@page { size: ${w}; margin: 0; }`}),C.map((e,t)=>(0,K.jsx)(`div`,{className:`squisq-print-sheet`,"data-slides-per-page":S,"aria-label":`Print page ${t+1}`,children:e.map(e=>(0,K.jsx)(`div`,{className:`squisq-print-slide-cell`,children:(0,K.jsx)(`div`,{className:`squisq-print-slide-frame`,children:(0,K.jsx)(sn,{block:e,blockTime:Math.max(0,e.duration),basePath:i,viewport:a,animationsEnabled:!1,theme:o})})},e.id))},`${S}-${t}`)),C.length===0&&(0,K.jsx)(`p`,{className:`squisq-print-empty`,children:`Nothing to print.`})]})}function UR({basePath:e=`/`,className:t,workspaceContainer:n,onLinkClick:r,showCodeCopyButton:i=!1,onCopyCode:a}){let{doc:o,parseError:s,isParsing:c,markdownSource:l,mediaRevision:u,setMarkdownSource:d,bumpMediaRevision:f,allowRecording:p,colorScheme:m,fileName:h,fenceRenderers:g}=Lp(),_=fn(),v=yR(),y=IR(),{activeViewport:b,activeDisplayMode:x,activeTheme:S,activeTransformStyle:C,activeCaptionStyle:w,activeCaptionsEnabled:T,activeVideoPresentation:E,activePipSize:D,activePipShape:O,activePipPosition:k,activeVideoLoop:A,activeCoverSlide:j,activeCoverSlideTemplate:M,activeCoverSlideDuration:N,activeCoverSlidePlayback:P,activeDashboardLayout:F,activeDashboardTitle:I,activeDashboardStyle:L}=Mg(),ee=(0,G.useRef)(null),te=(0,G.useRef)(null),[R,ne]=(0,G.useState)(null),re=(0,G.useCallback)(e=>{ne(e)},[]),z=qL(o,C,n,ue(h),u),ie=z?.playerDoc??null,ae=z?.contentDoc??null,oe=(0,G.useMemo)(()=>{if(!R||!ie)return null;let e=()=>Promise.resolve();return{currentTime:R.currentTime,isPlaying:R.isPlaying,currentSegment:R.currentSegmentIndex,totalDuration:R.totalDuration,isEnded:R.totalDuration>0&&R.currentTime>=R.totalDuration,isReady:!0,isAvailable:!0,play:e,pause:e,toggle:e,seekTo:e,skipToSegment:e,restart:e}},[R,ie]),se=(0,G.useMemo)(()=>C&&ae?gR(ae):l,[C,ae,l]),ce=x===`page`,le=x===`linear`,B=x===`narrate`,V=x===`dashboard`,de=x===`flashcards`;if((0,G.useEffect)(()=>{v?.activeTarget!==`window`&&ne(null)},[v?.activeTarget]),(0,G.useEffect)(()=>{if(v?.activeTarget!==`window`||!v.popupRoot)return;let e=ee.current,t=te.current;if(!(!e||!t)){if(le){let n=e.querySelector(`.squisq-linear`),r=t.querySelector(`.squisq-linear`);if(!n||!r)return;let i=()=>{let e=Math.max(1,n.scrollHeight-n.clientHeight),t=Math.max(0,r.scrollHeight-r.clientHeight);r.scrollTop=n.scrollTop/e*t};return n.addEventListener(`scroll`,i,{passive:!0}),i(),()=>n.removeEventListener(`scroll`,i)}if(ce){let n=e.querySelector(`iframe`),r=t.querySelector(`iframe`);if(!n||!r)return;let i=null,a=()=>{i?.();try{let e=n.contentWindow,t=r.contentWindow;if(!e||!t)return;let a=()=>{let n=e.document.documentElement,r=t.document.documentElement,i=Math.max(1,n.scrollHeight-e.innerHeight),a=Math.max(0,r.scrollHeight-t.innerHeight);t.scrollTo(0,e.scrollY/i*a)};e.addEventListener(`scroll`,a,{passive:!0}),i=()=>e.removeEventListener(`scroll`,a),a()}catch{}};return n.addEventListener(`load`,a),r.addEventListener(`load`,a),a(),()=>{n.removeEventListener(`load`,a),r.removeEventListener(`load`,a),i?.()}}}},[ae,se,ce,le,v?.activeTarget,v?.popupRoot]),c&&!B&&!ie)return(0,K.jsx)(`div`,{className:`squisq-preview-status ${t||``}`,"data-testid":`preview-panel`,children:(0,K.jsx)(`p`,{children:`Parsing…`})});if(s&&!B)return(0,K.jsxs)(`div`,{className:`squisq-preview-status ${t||``}`,"data-testid":`preview-panel`,children:[(0,K.jsx)(`h3`,{children:`Parse Error`}),(0,K.jsx)(`pre`,{children:s})]});if(!ie&&!ce&&!B)return(0,K.jsx)(`div`,{className:`squisq-preview-status ${t||``}`,"data-testid":`preview-panel`,children:(0,K.jsx)(`p`,{children:`No content to preview. Start typing in the editor.`})});let fe=y?.active||ce||le||B||de?`stretch`:`center`,H=v?.activeTarget===`window`,pe=t=>{if(!t&&y?.active)return(0,K.jsx)(HR,{displayMode:x,previewDoc:ie,contentDoc:ae??o,documentMarkdown:se,basePath:e,viewport:b,theme:S,showCover:j,transformStyle:C,mediaRevision:u});if(ce)return(0,K.jsx)(iR,{markdown:se,title:ae?.frontmatter?.title??void 0,mediaProvider:_,mediaRevision:u,theme:S,globalKeyboardShortcuts:!t,onLinkClick:r,showCodeCopyButton:i,onCopyCode:a});if(B)return t?null:(0,K.jsx)(il,{doc:o,theme:S,workspaceContainer:n??null,basePath:e,presentationTarget:v?.activeTarget===`window`?v.popupRoot:null,recording:p&&_?{mediaProvider:_,container:n??null,markdownSource:l,setMarkdownSource:d,bumpMediaRevision:f}:null});if(le)return(0,K.jsx)(In,{doc:ae??o,basePath:e,viewport:b,theme:S,globalKeyboardShortcuts:!t,showCover:j,transformPage:C?Gn(C).page:void 0,showCodeCopyButton:i,onCopyCode:a,fenceRenderers:g??void 0});if(de)return(0,K.jsx)(zn,{doc:ae??o,basePath:e,theme:S,globalKeyboardShortcuts:!t,showCodeCopyButton:i,onCopyCode:a,fenceRenderers:g??void 0,viewport:b});if(V)return(0,K.jsx)(`div`,{className:`squisq-dashboard-fit`,children:(0,K.jsx)(Wn,{doc:ae??o,basePath:e,viewport:b,theme:S,layout:F,showTitle:I,style:L,documentTitle:ue(h)})});if(t&&!oe)return(0,K.jsx)(`div`,{className:`squisq-presentation-connecting`,children:`Connecting presentation...`});let s=R?.captionMode;return(0,K.jsx)(Bn,{doc:ie,basePath:e,audioMode:z?.contentDoc.audio?.segments?.length?`media`:`synthetic`,showControls:!t,muted:t,forceViewport:b,displayMode:x,theme:S,videoPresentation:E,pipSize:D,pipShape:O,pipPosition:k,loop:!t&&x===`video`&&A,captionStyle:s===`social`?`social`:w,captionsEnabled:t&&s?s!==`off`:T,showCoverSlide:j,coverSlideTemplate:M,coverSlideDuration:N,coverSlidePlayback:P,coverVisible:t?R?.isCoverVisible:void 0,audioController:t?oe:void 0,enableSwipe:!t,globalKeyboardShortcuts:!t,showCodeCopyButton:i,onCopyCode:a,onPlaybackStateChange:!t&&H?re:void 0},`${t?`audience`:`primary`}-${C||`none`}`)},me={flex:1,display:`flex`,alignItems:fe,justifyContent:`center`,overflow:`hidden`,minHeight:0,background:v?.activeTarget?S.colors.background:void 0};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`squisq-preview-container ${t||``}`,"data-testid":`preview-panel`,style:{width:`100%`,height:`100%`,display:`flex`,flexDirection:`column`,overflow:`hidden`,background:`var(--squisq-bg)`},children:(0,K.jsx)(`div`,{ref:ee,className:`squisq-preview-player`,style:me,children:pe(!1)})}),H&&v?.popupRoot&&!B?(0,Wr.createPortal)((0,K.jsx)(`div`,{className:`squisq-editor-shell squisq-presentation-window`,"data-theme":m,children:(0,K.jsx)(`div`,{className:`squisq-preview-container squisq-presentation-window-preview`,children:(0,K.jsx)(`div`,{ref:te,className:`squisq-preview-player squisq-presentation-window-surface`,style:me,"aria-label":`Audience presentation`,children:pe(!0)})})}),v.popupRoot):null]})}function WR(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function GR(e){return e.startsWith(`image/`)?`🖼`:e.startsWith(`audio/`)?`🔊`:e.startsWith(`video/`)?`🎬`:e===`text/csv`||e===`text/tab-separated-values`||e.includes(`spreadsheetml`)||e===`application/vnd.ms-excel`||e.includes(`parquet`)?`📊`:e.includes(`json`)?`{ }`:e.includes(`xml`)||e.includes(`ssml`)?`〈/〉`:`📄`}function KR(e){return e.startsWith(`image/`)}var qR=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`avif`,`ico`]);function JR(e){if(KR(e.type))return!0;let t=e.name.lastIndexOf(`.`);return t>=0&&qR.has(e.name.slice(t+1).toLowerCase())}function YR(e){return e.items.length>0?Array.from(e.items).some(e=>e.kind===`file`&&(e.type===``||KR(e.type))):Array.from(e.files).some(JR)}function XR(e){return e.sort((e,t)=>{let n=+!KR(e.mimeType),r=+!KR(t.mimeType);return n===r?e.name.localeCompare(t.name):n-r})}function ZR(e){return e.split(/[\\/]/).pop()||e}function QR(e,t){let n=document.createElement(`a`);n.href=e,n.download=t,n.rel=`noopener`,n.style.display=`none`,document.body.appendChild(n),n.click(),n.remove()}function $R({mediaProvider:e,isDark:t,refreshKey:n,usedMediaPaths:r,onMediaUploaded:i,onMediaRemoved:a,onCountChange:o,onRecord:s,isRecorderOpen:c=!1,allowBinaryDownloads:l=!0,highlightPath:u=null}){let[d,f]=(0,G.useState)([]),p=(0,G.useRef)(null);(0,G.useEffect)(()=>{if(!u||!p.current)return;let e=p.current.querySelector(`[data-media-path="${CSS.escape(u)}"]`);e instanceof HTMLElement&&e.scrollIntoView({block:`nearest`})},[u,d]);let[m,h]=(0,G.useState)({}),[g,_]=(0,G.useState)(!1),[v,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(null),[S,C]=(0,G.useState)(null),w=(0,G.useRef)(null),T=(0,G.useRef)(null),E=(0,G.useRef)(0),D=(0,G.useCallback)(async e=>{let t=XR(xT(await e.listMedia()));f(t),o?.(t.length);let n={};for(let r of t)if(KR(r.mimeType))try{n[r.name]=await e.resolveUrl(r.name)}catch{}h(n)},[o]);(0,G.useEffect)(()=>{if(!S)return;let e=e=>{T.current?.contains(e.target)||C(null)},t=e=>{e.key===`Escape`&&C(null)},n=()=>C(null);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),window.addEventListener(`scroll`,n,!0),window.addEventListener(`resize`,n),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t),window.removeEventListener(`scroll`,n,!0),window.removeEventListener(`resize`,n)}},[S]),(0,G.useEffect)(()=>{if(!e){f([]),h({}),o?.(0);return}let t=!1;async function n(){_(!0);try{let n=xT(await e.listMedia());if(t)return;XR(n),f(n),o?.(n.length);let r={};for(let t of n)if(KR(t.mimeType))try{r[t.name]=await e.resolveUrl(t.name)}catch{}t||h(r)}finally{t||_(!1)}}return n(),()=>{t=!0}},[e,n,o]);let O=(0,G.useCallback)(()=>{w.current?.click()},[]),k=(0,G.useCallback)(async t=>{if(!(t.length===0||!e)){_(!0);try{for(let n of t){let t=await n.arrayBuffer(),r=n.type||`application/octet-stream`,a=await e.addMedia(n.name,t,r);if(i)try{await i(a,n.name,r)}catch{}}await D(e)}finally{_(!1)}}},[e,i,D]),A=(0,G.useCallback)(async e=>{try{await k(Array.from(e.target.files??[]))}finally{w.current&&(w.current.value=``)}},[k]),j=(0,G.useCallback)(t=>{!e||g||!YR(t.dataTransfer)||(t.preventDefault(),t.stopPropagation(),E.current+=1,y(!0))},[g,e]),M=(0,G.useCallback)(t=>{!e||g||!YR(t.dataTransfer)||(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=`copy`)},[g,e]),N=(0,G.useCallback)(e=>{v&&(e.preventDefault(),e.stopPropagation(),E.current=Math.max(0,E.current-1),E.current===0&&y(!1))},[v]),P=(0,G.useCallback)(t=>{let n=Array.from(t.dataTransfer.files).filter(JR);!e||!v&&n.length===0||(t.preventDefault(),t.stopPropagation(),E.current=0,y(!1),n.length>0&&k(n))},[v,e,k]),F=(0,G.useCallback)(async t=>{if(e){C(null),_(!0);try{if(await e.removeMedia(t.name),a)try{await a(t.name,t)}catch(e){console.warn(`[squisq-editor] Failed to remove media reference from document:`,e instanceof Error?e.message:e)}await D(e)}finally{_(!1)}}},[e,a,D]),I=(0,G.useCallback)(async t=>{if(!(!e||b!==null)){x(t.name);try{QR(await e.resolveUrl(t.name),ZR(t.name))}catch(e){console.warn(`[squisq-editor] Failed to download media file:`,e instanceof Error?e.message:e)}finally{x(null)}}},[b,e]),L=(0,G.useCallback)((e,t,n)=>{C({entry:e,x:t,y:n})},[]),ee=S&&KR(S.entry.mimeType)?`Remove image`:`Remove file`,te={left:S?Math.min(S.x,Math.max(8,window.innerWidth-168)):0,top:S?Math.min(S.y,Math.max(8,window.innerHeight-48)):0},R=(0,G.useCallback)((e,t)=>{if(t.key!==`ContextMenu`&&!(t.shiftKey&&t.key===`F10`))return;t.preventDefault();let n=t.currentTarget.getBoundingClientRect();L(e,n.left+16,n.top+16)},[L]);return(0,K.jsxs)(`div`,{className:[`squisq-media-bin`,t?`squisq-media-bin--dark`:``,v?`squisq-media-bin--drop-active`:``].filter(Boolean).join(` `),onDragEnter:j,onDragOver:M,onDragLeave:N,onDrop:P,"aria-busy":g,...QE,children:[(0,K.jsxs)(`div`,{className:`squisq-media-bin-header`,children:[(0,K.jsxs)(`span`,{className:`squisq-media-bin-title`,children:[`Files `,d.length>0&&`(${d.length})`]}),(0,K.jsxs)(`div`,{className:`squisq-media-bin-actions`,children:[s&&(0,K.jsxs)(`button`,{type:`button`,className:`squisq-media-bin-record`,onClick:s,disabled:!e,title:e?`Record media`:`Load a content zip or select a storage slot first`,"aria-label":`Record media`,"aria-haspopup":`dialog`,"aria-expanded":c,children:[(0,K.jsx)(`span`,{className:`squisq-media-bin-record-dot`,"aria-hidden":`true`}),`Record`]}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-media-bin-upload`,onClick:O,disabled:!e||g,title:e?`Upload files`:`Load a content zip or select a storage slot first`,children:`+ Upload`})]})]}),(0,K.jsxs)(`div`,{className:`squisq-media-bin-list`,ref:p,children:[!e&&(0,K.jsxs)(`div`,{className:`squisq-media-bin-empty`,children:[`No media context.`,(0,K.jsx)(`br`,{}),`Load a content zip or select a storage slot.`]}),e&&d.length===0&&!g&&(0,K.jsx)(`div`,{className:`squisq-media-bin-empty`,children:`No files yet.`}),d.map(t=>{let n=m[t.name],i=ZR(t.name),a=i.replace(/\.[^.]+$/,``).replace(/[-_]/g,` `),o=!!r&&!r.has(t.name);return(0,K.jsxs)(`div`,{"data-media-path":t.name,className:t.name===u?`squisq-media-bin-item squisq-media-bin-item--highlight`:`squisq-media-bin-item`,title:`${t.name}
|
|
541
|
+
${t.mimeType}
|
|
542
|
+
${WR(t.size)}`,draggable:!0,tabIndex:0,onContextMenu:e=>{e.preventDefault(),L(t,e.clientX,e.clientY)},onDragStart:e=>{let n={name:t.name,mimeType:t.mimeType,alt:a};e.dataTransfer.setData(fD,JSON.stringify(n)),e.dataTransfer.setData(`text/plain`,gD(n)),e.dataTransfer.effectAllowed=`copy`},onKeyDown:e=>R(t,e),children:[n?(0,K.jsx)(`img`,{src:n,alt:i,className:`squisq-media-bin-thumb`,draggable:!1}):(0,K.jsx)(`span`,{className:`squisq-media-bin-icon`,children:GR(t.mimeType)}),(0,K.jsxs)(`div`,{className:`squisq-media-bin-meta`,children:[(0,K.jsx)(`div`,{className:`squisq-media-bin-name`,children:i}),(0,K.jsxs)(`div`,{className:`squisq-media-bin-detail-row`,children:[(0,K.jsx)(`span`,{className:`squisq-media-bin-size`,children:WR(t.size)}),o&&(0,K.jsx)(`span`,{className:`squisq-media-bin-unused-badge`,title:`Not used in document`,children:`Unused`})]})]}),l&&(0,K.jsx)(`button`,{type:`button`,className:`squisq-media-bin-download`,title:`Download ${i}`,"aria-label":`Download ${i}`,disabled:!e||b!==null,draggable:!1,onClick:e=>{e.stopPropagation(),I(t)},onDragStart:e=>e.preventDefault(),children:(0,K.jsx)(`span`,{"aria-hidden":`true`,children:b===t.name?`…`:`↓`})})]},t.name)})]}),v&&(0,K.jsxs)(`div`,{className:`squisq-media-bin-drop-target`,"aria-hidden":`true`,children:[(0,K.jsx)(`span`,{className:`squisq-media-bin-drop-target-icon`,children:`+`}),(0,K.jsx)(`strong`,{children:`Drop images here`}),(0,K.jsx)(`span`,{children:`Add to Files`})]}),S&&(0,K.jsx)(`div`,{ref:T,className:`squisq-media-bin-context-menu`,role:`menu`,"aria-label":`${S.entry.name} actions`,style:te,children:(0,K.jsx)(`button`,{type:`button`,role:`menuitem`,className:`squisq-media-bin-context-menu-item squisq-media-bin-context-menu-item--danger`,onClick:()=>F(S.entry),disabled:!e||g,children:ee})}),(0,K.jsx)(`input`,{ref:w,type:`file`,multiple:!0,style:{display:`none`},onChange:A})]})}function ez({dragContentType:e,zoneProps:t,hasMediaProvider:n}){return(0,K.jsx)(`div`,{className:`squisq-drop-overlay`,children:(0,K.jsxs)(`div`,{className:`squisq-drop-overlay-inner`,children:[(e===`media`||e===`mixed`)&&(0,K.jsx)(tz,{target:`media`,zoneProps:t,icon:`📷`,label:`Media`,description:n?`Add to file bin`:`No file storage configured`,disabled:!n,variant:`media`}),(e===`text`||e===`mixed`)&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(tz,{target:`insert`,zoneProps:t,icon:`📋`,label:`Insert`,description:`Insert content at cursor`,variant:`insert`}),(0,K.jsx)(tz,{target:`replace`,zoneProps:t,icon:`🔄`,label:`Replace`,description:`Replace all editor content`,variant:`replace`})]})]})})}function tz({target:e,zoneProps:t,icon:n,label:r,description:i,disabled:a,variant:o}){let[s,c]=(0,G.useState)(!1),l=t(e);return(0,K.jsxs)(`div`,{className:[`squisq-drop-zone`,`squisq-drop-zone--${o}`,s&&!a?`squisq-drop-zone--active`:``,a?`squisq-drop-zone--disabled`:``].filter(Boolean).join(` `),onDragOver:e=>{if(a){e.preventDefault();return}l.onDragOver(e)},onDragEnter:e=>{e.preventDefault(),a||c(!0)},onDragLeave:e=>{e.preventDefault(),c(!1)},onDrop:e=>{if(c(!1),a){e.preventDefault();return}l.onDrop(e)},children:[(0,K.jsx)(`span`,{className:`squisq-drop-zone-icon`,children:n}),(0,K.jsx)(`span`,{className:`squisq-drop-zone-label`,children:r}),(0,K.jsx)(`span`,{className:`squisq-drop-zone-desc`,children:i})]})}var nz=8;function rz(e,t,n,r=nz){let i=r,a=Math.max(i,n-r-t),o=e-t/2;return Math.min(a,Math.max(i,o))}var iz=180;function az(){let[e,t]=(0,G.useState)(null),n=(0,G.useRef)(null),r=(0,G.useRef)(null),i=(0,G.useRef)(null),a=(0,G.useRef)(!1);return(0,G.useLayoutEffect)(()=>{if(!e)return;let t=n.current;if(!t)return;let r=t.getBoundingClientRect().width||t.offsetWidth,i=window.innerWidth||document.documentElement.clientWidth,a=rz(e.anchorX,r,i);t.style.left=`${a}px`,t.style.visibility=`visible`},[e]),(0,G.useEffect)(()=>{let e=()=>{r.current&&=(clearTimeout(r.current),null)},n=()=>{e(),i.current=null,a.current=!1,t(null)},o=(e,n)=>{let r=e.getBoundingClientRect();a.current=!0,t({label:n,top:r.bottom+6,anchorX:r.left+r.width/2})},s=t=>{let n=t.target?.closest?.(`[data-tooltip]`);if(!n||n===i.current)return;let s=n.getAttribute(`data-tooltip`);if(!s)return;let c=a.current;i.current=n,e(),c?o(n,s):r.current=setTimeout(()=>{i.current===n&&document.body.contains(n)&&o(n,s)},iz)},c=e=>{let t=i.current;if(!t)return;let r=e.relatedTarget;r&&t.contains(r)||r?.closest?.(`[data-tooltip]`)||n()},l=()=>n(),u=()=>n();return document.addEventListener(`mouseover`,s),document.addEventListener(`mouseout`,c),document.addEventListener(`scroll`,l,!0),window.addEventListener(`blur`,u),()=>{e(),document.removeEventListener(`mouseover`,s),document.removeEventListener(`mouseout`,c),document.removeEventListener(`scroll`,l,!0),window.removeEventListener(`blur`,u)}},[]),e?(0,Wr.createPortal)((0,K.jsx)(`div`,{role:`tooltip`,className:`squisq-tooltip`,ref:n,style:{position:`fixed`,top:e.top,left:e.anchorX,visibility:`hidden`},children:e.label}),document.body):null}function oz({basePath:e=`/`}){let{doc:t,activeBlockStartLine:n,mediaProvider:r}=Lp(),i=Ng(),a=i?.activeTheme??at,o=i?.activeViewport??Ge.landscape,s=(0,G.useMemo)(()=>{if(!t)return null;let e=Se(t.blocks);return e.length===0?null:e.find(e=>e.sourceHeading?.position?.start.line===n)??e[0]},[t,n]),c=(0,G.useMemo)(()=>t&&s?$s(t,s,a,o):null,[t,s,a,o]);return c?(0,K.jsx)(`div`,{className:`squisq-block-preview-panel`,"data-testid":`block-preview-panel`,"aria-hidden":!0,children:(0,K.jsx)(`div`,{className:`squisq-block-preview-frame`,style:{aspectRatio:`${o.width} / ${o.height}`},children:(0,K.jsx)(nc,{visual:c,viewport:o,basePath:e,mediaProvider:r})})}):null}var sz={spelling:`Spelling`,grammar:`Grammar`,style:`Style`};function cz(){let e=av();if(!e||!e.panelVisible||!e.enabled)return null;let{findings:t,activeFindingId:n}=e;return(0,K.jsxs)(`aside`,{className:`squisq-proof-panel`,"aria-label":`Proofing findings`,children:[(0,K.jsxs)(`div`,{className:`squisq-proof-panel-header`,children:[(0,K.jsxs)(`span`,{className:`squisq-proof-panel-title`,children:[`Proofing`,(0,K.jsx)(`span`,{className:`squisq-proof-panel-count`,children:t.length})]}),(0,K.jsxs)(`span`,{className:`squisq-proof-panel-actions`,children:[(0,K.jsx)(`button`,{type:`button`,className:`squisq-proof-panel-button`,title:`Previous finding`,"aria-label":`Previous finding`,disabled:t.length===0,onClick:e.prevFinding,children:`↑`}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-proof-panel-button`,title:`Next finding`,"aria-label":`Next finding`,disabled:t.length===0,onClick:e.nextFinding,children:`↓`}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-proof-panel-button`,title:`Close panel`,"aria-label":`Close proofing panel`,onClick:()=>e.setPanelVisible(!1),children:`×`})]})]}),e.status===`loading`&&(0,K.jsx)(`div`,{className:`squisq-proof-panel-empty`,children:`Loading proofing engine…`}),e.status===`error`&&(0,K.jsxs)(`div`,{className:`squisq-proof-panel-empty`,children:[`Proofing failed to load.`,(0,K.jsx)(`button`,{type:`button`,className:`squisq-proof-panel-retry`,onClick:e.retrySetup,children:`Retry`})]}),e.status===`ready`&&t.length===0&&(0,K.jsx)(`div`,{className:`squisq-proof-panel-empty`,children:`No issues found.`}),(0,K.jsx)(`ul`,{className:`squisq-proof-panel-list`,children:t.map(t=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,className:t.id===n?`squisq-proof-panel-row squisq-proof-panel-row--active`:`squisq-proof-panel-row`,onClick:()=>e.selectFinding(t.id),children:[(0,K.jsx)(`span`,{className:`squisq-proof-dot squisq-proof-dot--${t.category}`,title:sz[t.category]??t.category,"aria-hidden":!0}),(0,K.jsxs)(`span`,{className:`squisq-proof-panel-row-body`,children:[(0,K.jsx)(`span`,{className:`squisq-proof-panel-excerpt`,children:t.originalText}),(0,K.jsx)(`span`,{className:`squisq-proof-panel-message`,children:t.message})]})]})},t.id))})]})}var lz=new Set([`audio`,`file`,`href`,`image`,`imagesrc`,`path`,`poster`,`src`,`url`,`video`]),uz=[`src`,`href`,`poster`];function dz(e){let t=new Set,n=Ub(e);return hz(n,t),_z(n,t),vz(n,t),t}function fz(e,t){return t?Tz(Tz(pz(e,t),`img`,`src`,t),`a`,`href`,t):e}function pz(e,t){let n=``,r=0;for(;r<e.length;){let i=mz(e,r,t);if(!i)break;n+=e.slice(r,i.start),r=i.end}return n+e.slice(r)}function mz(e,t,n){return gz(e,t,n)?.range??null}function hz(e,t){let n=0;for(;n<e.length;){let r=gz(e,n);if(!r)return;t.add(r.destination),n=Math.max(r.range.end,n+1)}}function gz(e,t,n){let r=e.indexOf(`[`,t);for(;r!==-1;){let t=e[r-1],i=t===`!`;if(t===`@`){r=e.indexOf(`[`,r+1);continue}let a=yz(e,r);if(a===-1||e[a+1]!==`(`){r=e.indexOf(`[`,r+1);continue}let o=a+1,s=bz(e,o);if(s===-1){r=e.indexOf(`[`,r+1);continue}let c=xz(e.slice(o+1,s));if(c&&(n===void 0||c===n))return{destination:c,range:wz(e,i?r-1:r,s+1)};r=e.indexOf(`[`,r+1)}return null}function _z(e,t){let n=/<[a-z][^>]*>/gi,r;for(;r=n.exec(e);){let e=r[0];for(let n of uz){let r=Ez(e,n);r&&t.add(r)}}}function vz(e,t){let n=/\{\[([^\]]*)\]\}/g,r;for(;r=n.exec(e);){let e=r[1];if(!e)continue;let n=jt(e);for(let e of n){let n=yt(e);n&&lz.has(n.key.toLowerCase())&&t.add(n.value)}}}function yz(e,t){let n=0;for(let r=t;r<e.length;r++){if(e[r]===`\\`){r+=1;continue}if(e[r]===`[`&&(n+=1),e[r]===`]`&&(--n,n===0))return r}return-1}function bz(e,t){let n=0,r=!1;for(let i=t;i<e.length;i++){let t=e[i];if(t===`\\`){i+=1;continue}if(r){t===`>`&&(r=!1);continue}if(t===`<`){r=!0;continue}if(t===`(`){n+=1;continue}if(t===`)`&&(--n,n===0))return i}return-1}function xz(e){let t=e.trimStart();if(!t)return``;if(t.startsWith(`<`)){let e=Sz(t,`>`,1);return e===-1?``:Cz(t.slice(1,e))}let n=0;for(let e=0;e<t.length;e++){let r=t[e];if(r===`\\`){e+=1;continue}if(r===`(`){n+=1;continue}if(r===`)`&&n>0){--n;continue}if(n===0&&/\s/.test(r))return Cz(t.slice(0,e))}return Cz(t)}function Sz(e,t,n){for(let r=n;r<e.length;r++){if(e[r]===`\\`){r+=1;continue}if(e[r]===t)return r}return-1}function Cz(e){return e.replace(/\\([\\`*{}[\]()#+\-.!_>])/g,`$1`)}function wz(e,t,n){let r=e.lastIndexOf(`
|
|
543
|
+
`,t-1)+1,i=e.indexOf(`
|
|
544
|
+
`,n),a=i===-1?e.length:i,o=e.slice(r,t),s=e.slice(n,a);return o.trim()===``&&s.trim()===``?{start:r,end:i===-1?a:a+1}:{start:t,end:n}}function Tz(e,t,n,r){let i=t===`img`?/<img\b[^>]*>/gi:/<a\b[^>]*>[\s\S]*?<\/a>/gi;return e.replace(i,e=>Ez(e,n)===r?``:e)}function Ez(e,t){let n=RegExp(`\\b${t}\\s*=\\s*("([^"]*)"|'([^']*)'|([^\\s>]+))`,`i`).exec(e);return n?Dz(n[2]??n[3]??n[4]??``):null}function Dz(e){return e.replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'|'/g,`'`).replace(/&/g,`&`)}function Oz({initialMarkdown:e=``,initialView:t=`wysiwyg`,hostMode:n=`document`,defaultViewportPreset:r=`landscape`,articleId:i=`untitled`,basePath:a=`/`,onChange:o,onLinkClick:s,showCodeCopyButton:c=!1,onCopyCode:l,colorScheme:u=`light`,className:d,height:f=`100vh`,minHeight:p,maxHeight:m,mediaProvider:h,workspaceContainer:g,allowVersioning:_=!1,versionBasename:v,versioningPrunePolicy:y,versioningAutoSaveIdleMs:b,onSaveVersion:x,showFilesToggle:S,showFilesWhenNotEmpty:C=!1,showFormattingControls:w=n!==`chat`,showInsertControls:T=!0,allowBinaryDownloads:E=!0,toolbarSlotLeft:D,toolbarSlotAfterActions:O,toolbarSlotRight:k,statusBarSlotRight:A,showPlayTab:j=!0,allowPresentationWindow:M=!0,allowPresentationFullscreen:N=!0,allowPrint:P=!0,submitOnEnter:F,calcEngineFactory:I,codeContext:L,fullWidth:ee=!1,uxFont:te,thinMargins:R=!1,writeCanvasSettings:ne,showStatusBar:re=!0,imageDisplayMode:z=`inline`,fileName:ie,saveCoverImageOutput:ae,saveDashboardImageOutput:oe,language:se,findMode:ce,onFindModeChange:le,mentionProvider:B,proofing:ue=null,proofingDefaultEnabled:V=!0,proofingSpellingEnabled:de=!0,proofingGrammarEnabled:fe=!0,proofingIgnoreStore:H=null,documentLinkProvider:pe,fenceRenderers:me,linkSchemes:U,allowRecording:he=!0,allowNarrate:ge=!0,preserveSourceWrapping:_e=!0,placeholder:W,readOnly:ve=!1,imageSrc:ye,imageAlt:be,imageMode:xe=`view`,imageEditorContainer:Se,onImageExport:Ce,inlinePreview:we=!1,inlinePreviewWidth:Te=320,outline:Ee=!1,outlineWidth:De,blockTags:Oe,blockTagVisibility:ke,themeInheritance:Ae=`fonts`,viewPreferences:je,onViewPreferencesChange:Me,themeOverride:Ne=null}){let Pe=g??null,Fe=(0,G.useMemo)(()=>{if(h!==void 0)return h;if(Pe)return Zn(Pe)},[h,Pe]),Ie=S??Fe!==void 0,Le=n===`chat`||!j&&t===`preview`?`wysiwyg`:t;return(0,K.jsx)(pn.Provider,{value:Fe??null,children:(0,K.jsx)(Vp,{initialMarkdown:e,initialView:Le,articleId:i,colorScheme:u,workspaceContainer:Pe,allowVersioning:_,versionBasename:v,versioningPrunePolicy:y,versioningAutoSaveIdleMs:b,onSaveVersion:x,mediaProvider:Fe,imageDisplayMode:z,mentionProvider:B,proofing:ue,proofingDefaultEnabled:V,proofingSpellingEnabled:de,proofingGrammarEnabled:fe,proofingIgnoreStore:H,documentLinkProvider:pe,fenceRenderers:me,linkSchemes:U,allowRecording:he,allowNarrate:ge,preserveSourceWrapping:_e,fileName:ie,saveCoverImageOutput:ae,saveDashboardImageOutput:oe,language:se,findMode:ce,onFindModeChange:le,inlinePreview:we,showStatusBar:re,outline:Ee,blockTags:Oe,blockTagVisibility:ke,themeInheritance:Ae,viewPreferences:je,onViewPreferencesChange:Me,children:(0,K.jsx)(ov,{children:(0,K.jsx)(jz,{basePath:a,defaultViewportPreset:r,onChange:o,onLinkClick:s,showCodeCopyButton:c,onCopyCode:l,className:d,height:f,minHeight:p,maxHeight:m,placeholder:W,mediaProvider:Fe??null,workspaceContainer:Pe,filesToggleEnabled:Ie,showFilesWhenNotEmpty:C,showFormattingControls:w,showInsertControls:T,allowBinaryDownloads:E,toolbarSlotLeft:D,toolbarSlotAfterActions:O,toolbarSlotRight:k,statusBarSlotRight:A,showPlayTab:j,hostMode:n,allowPresentationWindow:M,allowPresentationFullscreen:N,allowPrint:P,submitOnEnter:F,calcEngineFactory:I,codeContext:L,fullWidth:ee,uxFont:te,thinMargins:R,writeCanvasSettings:ne,readOnly:ve,imageSrc:ye,imageAlt:be,imageMode:xe,imageEditorContainer:Se,onImageExport:Ce,allowVersioning:_,versioningAutoSaveIdleMs:b,inlinePreviewWidth:Te,outlineWidth:De,themeOverride:Ne})})})})}function kz({allowPrint:e}){return FR().active?(0,K.jsx)(BR,{}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(b_,{}),(0,K.jsx)(NR,{}),e&&(0,K.jsx)(RR,{})]})}function Az({rootRef:e,children:t,allowPresentationWindow:n,allowPresentationFullscreen:r}){return(0,K.jsx)(OR,{rootRef:e,allowWindow:n,allowFullscreen:r,children:(0,K.jsx)(LR,{rootRef:e,children:t})})}function jz({basePath:e,defaultViewportPreset:t,onChange:n,onLinkClick:r,showCodeCopyButton:i,onCopyCode:a,className:o,height:s,minHeight:c,maxHeight:l,placeholder:u,mediaProvider:d,workspaceContainer:f,filesToggleEnabled:p,showFilesWhenNotEmpty:m,showFormattingControls:h,showInsertControls:g,allowBinaryDownloads:_,toolbarSlotLeft:v,toolbarSlotAfterActions:y,toolbarSlotRight:b,statusBarSlotRight:x,showPlayTab:S,hostMode:C,allowPresentationWindow:w,allowPresentationFullscreen:T,allowPrint:E,submitOnEnter:D,calcEngineFactory:O,codeContext:k,fullWidth:A,uxFont:j,thinMargins:M,writeCanvasSettings:N,readOnly:P,imageSrc:F,imageAlt:I,imageMode:L,imageEditorContainer:ee,onImageExport:te,allowVersioning:R,versioningAutoSaveIdleMs:ne,inlinePreviewWidth:re,outlineWidth:z,themeOverride:ie}){let ae=(0,G.useRef)(null),{activeView:oe,markdownSource:se,doc:ce,colorScheme:le,editorMode:B,insertAtCursor:ue,replaceAll:V,tiptapEditor:de,monacoEditor:fe,setMarkdownSource:H,inlinePreviewVisible:pe,statusBarVisible:me,outlineVisible:U,layoutMode:he,blockCount:ge,activeBlockKey:_e,prevBlock:ve,nextBlock:ye,addBlock:be,imageEditTarget:xe,closeImageEdit:Se,bumpMediaRevision:Ce,mediaRevision:we,allowRecording:Te}=Lp(),{docThemes:Ee,onDocThemesChange:De}=Xh(),Oe=oe===`preview`,ke=B===`code`,Ae=B===`image`,je=B===`markdown`,Me=je&&(he===`block`||he===`timeline`)&&!Oe,Ne=je&&he===`timeline`&&!Oe,Pe=qL(Ne?ce:null,``,f)?.contentDoc??ce,Fe=Vn((0,G.useMemo)(()=>Pe?ot(Pe):[],[Pe]),e,d??null),Ie=(0,G.useMemo)(()=>Pe?it(Pe,{intrinsicDuration:e=>Fe.get(e.src)}):0,[Pe,Fe]),Le=(0,G.useMemo)(()=>Pe?ot(Pe,{intrinsicDuration:e=>Fe.get(e.src)}):[],[Pe,Fe]),Re=(0,G.useMemo)(()=>Pe?[...Le.filter(e=>e.kind===`video`),...aL(Pe)]:[],[Pe,Le]),ze=lL(Ne?Ie:0),Be=Re.length>0,[Ve,He]=(0,G.useState)(!1),[Ue,We]=(0,G.useState)(!1),Ge=Number(Ve)+Number(Ue),[Ke,qe]=(0,G.useState)(!1),[Je,Ye]=(0,G.useState)(null),[Ze,Qe]=(0,G.useState)(0),[$e,et]=(0,G.useState)(0),[tt,nt]=(0,G.useState)(!1),rt=Ze+we,at=(0,G.useMemo)(()=>dz(se),[se]),st=(0,G.useRef)(null);st.current===null&&(st.current=new Yn);let lt=st.current,ut=le===`dark`;(0,G.useEffect)(()=>{(!Ne||!Be)&&He(!1)},[Ne,Be]),(0,G.useEffect)(()=>{(!Ne||!ce?.blocks.length)&&We(!1)},[Ne,ce]),(0,G.useEffect)(()=>{if(!d){et(0);return}let e=!1;return d.listMedia().then(t=>{e||et(xT(t).length)},t=>{e||(et(0),console.warn(`[squisq-editor] Failed to read media list:`,t instanceof Error?t.message:t))}),()=>{e=!0}},[d,rt]),(0,G.useEffect)(()=>{m&&$e>0&&qe(!0)},[$e,m]);let ft=(0,G.useCallback)(()=>{qe(e=>!e)},[]),pt=(0,G.useCallback)(()=>{nt(!0)},[]),mt=(0,G.useCallback)((e,t,n)=>{let r=t.replace(/\.[^.]+$/,``).replace(/[-_]/g,` `),i=n.startsWith(`image/`),a=i?``:`[${r}](${e})`;if(oe===`wysiwyg`&&de){i?de.chain().focus().setImage({src:e,alt:r}).run():de.chain().focus().insertContent([{type:`text`,marks:[{type:`link`,attrs:{href:e}}],text:r}]).run();return}if(oe===`raw`&&fe){ue(a);return}H(se?`${se}
|
|
545
|
+
|
|
546
|
+
${a}`:a)},[oe,de,fe,ue,se,H]),ht=(0,G.useRef)(`document`);(0,G.useEffect)(()=>{let e=!1;if(ht.current=`document`,f)return(async()=>{try{let t=await f.getDocumentPath();if(e||!t)return;let n=(t.split(`/`).pop()??``).replace(/\.[^.]+$/,``);n&&(ht.current=n)}catch{}})(),()=>{e=!0}},[f]);let _t=(0,G.useCallback)((e,t)=>{let n=t.replace(/\.[^.]+$/,``),r=`src=${dt(e)?gt(e):e}`,i=`## ${n} {[dataTable ${r}]}
|
|
547
|
+
|
|
548
|
+
[${t}](${e})`;if(oe===`wysiwyg`&&de){de.chain().focus().insertContent([{type:`heading`,attrs:{level:2,dataTemplate:`dataTable`,dataTemplateParams:r},content:[{type:`text`,text:n}]},{type:`paragraph`,content:[{type:`text`,marks:[{type:`link`,attrs:{href:e}}],text:t}]}]).run();return}if(oe===`raw`&&fe){ue(i);return}H(se?`${se}
|
|
549
|
+
|
|
550
|
+
${i}`:i)},[oe,de,fe,ue,se,H]),vt=(0,G.useCallback)((e,t,n)=>{cb({name:t,type:n})===`data`?_t(e,t):mt(e,t,n),Qe(e=>e+1)},[_t,mt]),yt=(0,G.useCallback)(e=>{let t=fz(se,e);t!==se&&V(t),Qe(e=>e+1),Ce()},[Ce,se,V]),{isDragging:bt,dragContentType:xt,containerProps:St,zoneProps:Ct}=ub({onDrop:(0,G.useCallback)(async(e,t)=>{try{let{media:n,text:r,data:i}=db(e);if(i.length>0&&d){let e=await mb(i,d,W(ht.current));Qe(e=>e+1),Ke||qe(!0);for(let t=0;t<i.length;t++){let n=i[t],r=e[t];!n||!r||_t(r,n.name)}}if(n.length>0&&d){let e=await fb(n,d);Qe(e=>e+1),Ke||qe(!0);for(let t=0;t<n.length;t++){let r=n[t],i=e[t];!r||!i||mt(i,r.name,r.type||`application/octet-stream`)}}if(r.length>0)if(t===`replace`){let e=await hb(r[0]);V(e)}else{let e=await gb(r);ue(e)}}catch(e){console.error(`Failed to process dropped files:`,e instanceof Error?e.message:e)}},[d,Ke,V,ue,mt,_t]),enabled:!P});(0,G.useEffect)(()=>{n?.(se)},[se,n]);let wt=(0,G.useCallback)(e=>{if(!e.ctrlKey&&!e.metaKey)return;let t=e.key===`1`?`wysiwyg`:e.key===`2`?`raw`:e.key===`3`?`preview`:null;if(!t||t===`preview`&&!S)return;let n=ae.current?.querySelector(`[data-view="${t}"]`);n&&(e.preventDefault(),e.stopPropagation(),n.click())},[S]),Tt=(0,G.useCallback)(e=>{if(!r||e.button!==0)return;let t=e.target.closest?.(`a[href]`);if(!t||!e.currentTarget.contains(t))return;let n=t.getAttribute(`href`);!n||r(n)===!1||(e.preventDefault(),e.stopPropagation())},[r]),Et=(0,G.useCallback)(e=>{if(!r)return;let t=e.target.closest?.(`a[href]`);if(!t||!e.currentTarget.contains(t))return;let n=t.getAttribute(`href`);!n||t.hasAttribute(`title`)&&!t.hasAttribute(`data-squisq-link-title`)||(t.setAttribute(`title`,n),t.setAttribute(`data-squisq-link-title`,`true`))},[r]),Dt=(0,G.useCallback)(e=>{let t=e.target.closest?.(`a[data-squisq-link-title]`);!t||!e.currentTarget.contains(t)||e.relatedTarget instanceof Node&&t.contains(e.relatedTarget)||(t.removeAttribute(`title`),t.removeAttribute(`data-squisq-link-title`))},[]),Ot=c!==void 0||l!==void 0;return(0,K.jsx)(dD,{rootRef:ae,readOnly:P,children:(0,K.jsxs)(`div`,{ref:ae,onKeyDown:wt,onClickCapture:Tt,onMouseOverCapture:Et,onMouseOutCapture:Dt,className:`squisq-editor-shell ${o||``}`,"data-theme":le,"data-host-mode":C,"data-link-handler":r?`true`:void 0,"data-full-width":A?`true`:void 0,"data-thin-margins":M?`true`:void 0,"data-outline-visible":je&&U?`true`:void 0,style:{display:`flex`,flexDirection:`column`,overflow:`hidden`,...Ot?{minHeight:c,maxHeight:l}:{height:s},...j?{"--squisq-ux-font":j}:{},...IF(N),"--squisq-outline-width":z==null?yI:`${z}px`},...St,children:[(0,K.jsx)(Jh,{docThemes:Ee,onDocThemesChange:De,children:(0,K.jsx)(Jg,{doc:ce,defaultViewportPreset:t,themeOverride:ie,children:(0,K.jsxs)(Az,{rootRef:ae,allowPresentationWindow:w,allowPresentationFullscreen:T,children:[Ae?(v||b)&&(0,K.jsxs)(`div`,{className:`squisq-editor-header squisq-editor-header--image`,children:[v,(0,K.jsx)(`div`,{style:{flex:1}}),b]}):(0,K.jsx)(`div`,{className:`squisq-editor-header`,children:(0,K.jsx)(JE,{showFiles:Ke,fileCount:$e,onToggleFiles:!ke&&p?ft:void 0,slotLeft:v,slotAfterTabs:!ke&&Oe&&(0,K.jsx)(kz,{allowPrint:E}),slotAfterActions:y,slotRight:b,showPlayTab:S,showFormattingControls:h,showInsertControls:g,hostMode:C})}),(0,K.jsxs)(`div`,{className:`squisq-editor-content`,"data-timeline-preview-count":Ne?Ge:void 0,style:{flex:Ot?`1 1 auto`:1,overflowY:Ot?`auto`:`hidden`,overflowX:`hidden`,minHeight:0,position:`relative`,display:`flex`},children:[(0,K.jsxs)(`div`,{className:`squisq-editor-primary`,style:{flex:Ot?`1 1 auto`:1,overflow:Ot?`visible`:`hidden`,minHeight:0,position:`relative`},children:[Ae&&F&&(L===`edit`&&ee?(0,K.jsx)(J,{filesContainer:ee,initialSrc:F,allowVersioning:R,versioningAutoSaveIdleMs:ne,onExport:te,surface:le===`dark`?Xe:ct}):(0,K.jsx)(Yr,{src:F,alt:I,theme:le})),!Ae&&oe===`raw`&&(0,K.jsxs)(`div`,{className:`squisq-editor-with-gutter`,children:[je&&U&&(0,K.jsx)(SI,{width:z,readOnly:P},`outline`),(0,K.jsx)(zI,{active:Me,blockCount:ge,activeBlockKey:_e,onPrev:ve,onNext:ye,onAdd:be,children:(0,K.jsx)(`div`,{className:`squisq-raw-editor-container`,children:(0,K.jsx)(OD,{monacoTheme:le===`dark`?`vs-dark`:`vs`,submitOnEnter:D,readOnly:P})},`raw-editor`)},`raw-frame`),ke&&k&&(0,K.jsx)(RI,{options:k},`code-context`),je&&Me&&pe&&(0,K.jsx)(oz,{basePath:e},`block-preview`),je&&!Me&&pe&&(0,K.jsx)(mI,{width:re,basePath:e,mediaProvider:d},`inline`)]},`raw-shell`),je&&oe===`wysiwyg`&&(0,K.jsxs)(`div`,{className:`squisq-editor-with-gutter`,children:[U&&(0,K.jsx)(SI,{width:z,readOnly:P},`outline`),(0,K.jsx)(zI,{active:Me,blockCount:ge,activeBlockKey:_e,onPrev:ve,onNext:ye,onAdd:be,children:(0,K.jsx)(GF,{submitOnEnter:D,placeholder:u,readOnly:P,calcEngineFactory:O,onOpenFilesPanel:d?e=>{Ye(e??null),qe(!0)}:void 0},`wysiwyg-editor`)},`wysiwyg-frame`),Me&&pe&&(0,K.jsx)(oz,{basePath:e},`block-preview`),!Me&&pe&&(0,K.jsx)(mI,{width:re,basePath:e,mediaProvider:d},`inline`)]},`wysiwyg-shell`),je&&Oe&&(0,K.jsx)(UR,{basePath:e,workspaceContainer:f,onLinkClick:r,showCodeCopyButton:i,onCopyCode:a})]}),Ne&&Ve&&(0,K.jsx)(zL,{schedule:Re,currentTime:ze.currentTime,isPlaying:ze.isPlaying,basePath:e,onClose:()=>He(!1)}),Ne&&Ue&&(0,K.jsx)(JL,{doc:ce,clock:ze,basePath:e,workspaceContainer:f,onClose:()=>We(!1)}),je&&Ke&&(0,K.jsx)($R,{mediaProvider:d,isDark:ut,refreshKey:rt,usedMediaPaths:at,onMediaUploaded:vt,onMediaRemoved:yt,onCountChange:et,allowBinaryDownloads:_,onRecord:Te?pt:void 0,isRecorderOpen:tt,highlightPath:Je}),je&&(0,K.jsx)(cz,{}),je&&(0,K.jsx)(Yg,{}),je&&bt&&!(oe===`wysiwyg`&&xt===`media`)&&(0,K.jsx)(ez,{dragContentType:xt,zoneProps:Ct,hasMediaProvider:d!==null})]}),Ne&&(0,K.jsx)(ZL,{literalVideoVisible:Ve,compositionVisible:Ue,videoAvailable:Be,compositionAvailable:!!ce?.blocks.length,onToggleLiteralVideo:()=>He(e=>!e),onToggleComposition:()=>We(e=>!e)}),Ne&&(0,K.jsx)(FL,{doc:Pe,clock:ze,schedule:Le,basePath:e}),me&&!Ae&&(0,K.jsx)(XE,{slotRight:x}),je&&Te&&d&&(0,K.jsx)(ix,{open:tt,onOpenChange:nt,showTrigger:!1})]})})}),(0,K.jsx)(az,{}),xe!==null&&d&&(0,K.jsx)(Mz,{relativePath:xe,container:f??lt,mediaProvider:d,onClose:Se,onSaved:()=>{Ce(),Se()},allowVersioning:R,versioningAutoSaveIdleMs:ne,shellTheme:le})]})})}function Mz({relativePath:e,container:t,mediaProvider:n,onClose:r,onSaved:i,allowVersioning:a,versioningAutoSaveIdleMs:o,shellTheme:s}){let c=(0,G.useRef)(null),l=(0,G.useRef)(null);Ur({rootRef:c,dialogRef:l,onClose:r});let u=e.split(/[?#]/,1)[0]?.split(`.`).pop()?.toLowerCase(),d=u===`png`?`png`:u===`jpg`||u===`jpeg`?`jpeg`:u===`webp`?`webp`:null,f=(0,G.useMemo)(()=>{let n=e.replace(/[^a-zA-Z0-9._-]+/g,`_`),r=2166136261;for(let t=0;t<e.length;t++)r^=e.charCodeAt(t),r=Math.imul(r,16777619);let i=`${n}-${(r>>>0).toString(36)}`;return Xn(t??new Yn,`.imageEdits/${i}`)},[t,e]),[p,m]=(0,G.useState)(null),[h,g]=(0,G.useState)(null);(0,G.useEffect)(()=>{let t=!1;return m(null),g(null),n.resolveUrl(e).then(e=>{t||m(e)},e=>{t||g(e instanceof Error?e.message:String(e))}),()=>{t=!0}},[n,e]);let _=(0,G.useCallback)((t,r)=>{let a=`image/${r}`;n.addMedia(e,t,a).then(()=>i(),e=>{console.error(`Failed to write image back:`,e instanceof Error?e.message:e)})},[n,e,i]);return(0,K.jsx)(`div`,{ref:c,className:`squisq-image-edit-modal`,"data-testid":`image-edit-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":`Edit ${e}`,onClick:e=>{e.target===e.currentTarget&&r()},children:(0,K.jsxs)(`div`,{ref:l,className:`squisq-image-edit-modal__surface`,children:[(0,K.jsxs)(`header`,{className:`squisq-image-edit-modal__header`,children:[(0,K.jsx)(`span`,{className:`squisq-image-edit-modal__title`,children:`Edit image`}),(0,K.jsx)(`span`,{className:`squisq-image-edit-modal__path`,children:e}),(0,K.jsx)(`button`,{type:`button`,className:`squisq-image-edit-modal__close`,"data-testid":`image-edit-modal-close`,onClick:r,"aria-label":`Close image editor`,children:`×`})]}),(0,K.jsx)(`div`,{className:`squisq-image-edit-modal__body`,children:h?(0,K.jsxs)(`div`,{className:`squisq-image-edit-modal__error`,children:[`Failed to load image: `,h]}):d?p?(0,K.jsx)(J,{filesContainer:f,initialSrc:p,allowVersioning:a,versioningAutoSaveIdleMs:o,onExport:_,saveBehavior:`export`,saveFormat:d,saveLabel:`Save and close`,saveTitle:`Save changes back to the image and close`,surface:s===`dark`?Xe:ct}):(0,K.jsx)(`div`,{className:`squisq-image-edit-modal__loading`,children:`Loading image…`}):(0,K.jsx)(`div`,{className:`squisq-image-edit-modal__error`,children:`Editing supports PNG, JPEG, and WebP images without changing the asset type.`})})]})})}export{tD as a,Pa as c,Lp as i,Fa as l,Oz as n,za as o,GF as r,Na as s,Vp as t};
|